functionSource
stringlengths
20
97.4k
CWE-119
bool
2 classes
CWE-120
bool
2 classes
CWE-469
bool
2 classes
CWE-476
bool
2 classes
CWE-other
bool
2 classes
combine
int64
0
1
parse_string_array2 (VALUE value) { xmmsv_t *list; list = xmmsv_new_list (); if (!NIL_P (rb_check_array_type (value))) { VALUE *ary = RARRAY_PTR (value); int i, ary_len = RARRAY_LEN (value); for (i = 0; i < ary_len; i++) { xmmsv_t *elem; elem = xmmsv_new_string (StringValuePtr (ary[i])); xmmsv_list_append (list, elem); xmmsv_unref (elem); } } else { xmmsv_t *elem; elem = xmmsv_new_string (StringValuePtr (value)); xmmsv_list_append (list, elem); xmmsv_unref (elem); } return list; }
false
false
false
false
false
0
auth_stratum(struct pool *pool) { json_t *val = NULL, *res_val, *err_val; char s[RBUFSIZE], *sret = NULL; json_error_t err; bool ret = false; sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}", swork_id++, pool->rpc_user, pool->rpc_pass); if (!stratum_send(pool, s, strlen(s))) return ret; /* Parse all data in the queue and anything left should be auth */ while (42) { sret = recv_line(pool); if (!sret) return ret; if (parse_method(pool, sret)) free(sret); else break; } val = JSON_LOADS(sret, &err); free(sret); res_val = json_object_get(val, "result"); err_val = json_object_get(val, "error"); if (!res_val || json_is_false(res_val) || (err_val && !json_is_null(err_val))) { char *ss; if (err_val) ss = json_dumps(err_val, JSON_INDENT(3)); else ss = strdup("(unknown reason)"); applog(LOG_INFO, "pool %d JSON stratum auth failed: %s", pool->pool_no, ss); free(ss); suspend_stratum(pool); goto out; } ret = true; applog(LOG_INFO, "Stratum authorisation success for pool %d", pool->pool_no); pool->probed = true; successful_connect = true; out: json_decref(val); return ret; }
false
false
false
false
false
0
args_tuple(PyObject *object, const char *errors) { PyObject *args; args = PyTuple_New(1 + (errors != NULL)); if (args == NULL) return NULL; Py_INCREF(object); PyTuple_SET_ITEM(args,0,object); if (errors) { PyObject *v; v = PyUnicode_FromString(errors); if (v == NULL) { Py_DECREF(args); return NULL; } PyTuple_SET_ITEM(args, 1, v); } return args; }
false
false
false
false
true
1
gst_rtsp_connection_accept (gint sock, GstRTSPConnection ** conn) { int fd; union gst_sockaddr sa; socklen_t slen = sizeof (sa); gchar ip[INET6_ADDRSTRLEN]; guint16 port; g_return_val_if_fail (sock >= 0, GST_RTSP_EINVAL); g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL); memset (&sa, 0, slen); #ifndef G_OS_WIN32 fd = accept (sock, &sa.sa, &slen); #else fd = accept (sock, &sa.sa, (gint *) & slen); #endif /* G_OS_WIN32 */ if (fd == -1) goto accept_failed; if (getnameinfo (&sa.sa, slen, ip, sizeof (ip), NULL, 0, NI_NUMERICHOST) != 0) goto getnameinfo_failed; if (sa.sa.sa_family == AF_INET) port = sa.sa_in.sin_port; else if (sa.sa.sa_family == AF_INET6) port = sa.sa_in6.sin6_port; else goto wrong_family; return gst_rtsp_connection_create_from_fd (fd, ip, port, NULL, conn); /* ERRORS */ accept_failed: { return GST_RTSP_ESYS; } getnameinfo_failed: wrong_family: { CLOSE_SOCKET (fd); return GST_RTSP_ERROR; } }
false
false
false
false
false
0
gtv_sr_selection_to_blank (GncTreeViewSplitReg *view) { GncTreeModelSplitReg *model; GtkTreePath *bpath, *spath; Split *bsplit; /* give gtk+ a chance to handle pending events */ while (gtk_events_pending ()) gtk_main_iteration (); /* Make sure we have expanded splits */ if (view->priv->expanded == FALSE) return FALSE; model = gnc_tree_view_split_reg_get_model_from_view (view); bsplit = gnc_tree_model_split_get_blank_split (model); bpath = gnc_tree_model_split_reg_get_path_to_split_and_trans (model, bsplit, NULL); spath = gnc_tree_view_split_reg_get_sort_path_from_model_path (view, bpath); /* Set cursor to new spath */ gtk_tree_view_set_cursor (GTK_TREE_VIEW (view), spath, NULL, FALSE); gtk_tree_path_free (bpath); gtk_tree_path_free (spath); return FALSE; }
false
false
false
false
false
0
txv_text_append_with_color(GtkWidget *wid, const gchar *text, gsize length, const GdkColor *color) { TxvInfo *txi; GtkTextIter start, end; gchar tname[32]; gint pos; GtkTextTagTable *ttab; GtkTextTag *tag; if(color == NULL) { txv_text_append(wid, text, length); return; } if((wid == NULL) || ((txi = g_object_get_data(G_OBJECT(wid), "user")) == NULL) || length < 1) return; pos = gtk_text_buffer_get_char_count(GTK_TEXT_BUFFER(txi->buffer)); do_text_append(txi, text, length); gtk_text_buffer_get_iter_at_offset(GTK_TEXT_BUFFER(txi->buffer), &start, pos); gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(txi->buffer), &end); /* Be clever. Build a tag name that depends on the color, to re-use tags. */ g_snprintf(tname, sizeof tname, "txv-%04x%04x%04x", color->red, color->green, color->blue); /* If a tag by this name already exists, re-use it. */ ttab = gtk_text_buffer_get_tag_table(GTK_TEXT_BUFFER(txi->buffer)); if((tag = gtk_text_tag_table_lookup(ttab, tname)) == NULL) tag = gtk_text_buffer_create_tag(GTK_TEXT_BUFFER(txi->buffer), tname, "foreground-gdk", color, NULL); gtk_text_buffer_apply_tag(GTK_TEXT_BUFFER(txi->buffer), tag, &start, &end); }
false
false
false
false
false
0
ojc_to_str(ojcVal val, int indent) { struct _Buf b; buf_init(&b, 0); fill_buf(&b, val, indent, 0); if (OJC_OK != b.err) { return 0; } *b.tail = '\0'; if (b.base == b.head) { return strdup(b.head); } return b.head; }
false
false
false
false
false
0
parse(MYSQL_ROW& r) { int i=0; clear(); id = atoi(r[i++]); strcpy2(name, r[i++]); workunitid = atoi(r[i++]); appid = atoi(r[i++]); server_state = atoi(r[i++]); hostid = atoi(r[i++]); userid = atoi(r[i++]); sent_time = atoi(r[i++]); received_time = atoi(r[i++]); validate_state = atoi(r[i++]); outcome = atoi(r[i++]); client_state = atoi(r[i++]); file_delete_state = atoi(r[i++]); app_version_id = atoi(r[i++]); }
false
false
false
false
false
0
as3645a_set_output(struct as3645a *flash, bool strobe) { enum as_mode mode; bool on; switch (flash->led_mode) { case V4L2_FLASH_LED_MODE_NONE: on = flash->indicator_current != 0; mode = AS_MODE_INDICATOR; break; case V4L2_FLASH_LED_MODE_TORCH: on = true; mode = AS_MODE_ASSIST; break; case V4L2_FLASH_LED_MODE_FLASH: on = strobe; mode = AS_MODE_FLASH; break; default: BUG(); } /* Configure output parameters and operation mode. */ return as3645a_set_control(flash, mode, on); }
false
false
false
false
false
0
get_node_attribute_value_as_decimal_double(const xmlpp::Element* node, const Glib::ustring& strAttributeName) { double result = 0; const Glib::ustring value_string = get_node_attribute_value(node, strAttributeName); //Get number for string: if(!value_string.empty()) { std::stringstream thestream; thestream.imbue( std::locale::classic() ); //The C locale. thestream.str(value_string); thestream >> result; } return result; }
false
false
false
false
false
0
ide_tape_stall_queue(ide_drive_t *drive) { idetape_tape_t *tape = drive->driver_data; ide_debug_log(IDE_DBG_FUNC, "cmd: 0x%x, dsc_poll_freq: %lu", drive->hwif->rq->cmd[0], tape->dsc_poll_freq); tape->postponed_rq = true; ide_stall_queue(drive, tape->dsc_poll_freq); }
false
false
false
false
false
0
ldestroy(But *but) { ButWin *win = but->win; ButEnv *env = win->env; Menu *m = but->iPacket; But *sbut = m->parent; int x, y; int minX, minY; minX = but->x; minY = but->y; x = sbut->x + sbut->w/2; y = sbut->y + sbut->h/2; while (win->parent != NULL) { minX += win->xOff; x += win->xOff; minY += win->yOff; y += win->yOff; win = win->parent; } XWarpPointer(env->dpy, win->win, win->win, minX, minY, but->w, but->h, x, y); m->child = NULL; return(0); }
false
false
false
false
false
0
es_skip (estream_t stream, size_t size) { int err; if (stream->data_offset + size > stream->data_len) { _set_errno (EINVAL); err = -1; } else { stream->data_offset += size; err = 0; } return err; }
false
false
false
false
false
0
LookupInputChannel(word32 channelId) const { map<word32, unsigned int>::const_iterator it = m_inputChannelMap.find(channelId); if (it == m_inputChannelMap.end()) return m_threshold; else return it->second; }
false
false
false
false
false
0
containsInvalidInstruction(MachineLoop *L, bool IsInnerHWLoop) const { const std::vector<MachineBasicBlock *> &Blocks = L->getBlocks(); DEBUG(dbgs() << "\nhw_loop head, BB#" << Blocks[0]->getNumber();); for (unsigned i = 0, e = Blocks.size(); i != e; ++i) { MachineBasicBlock *MBB = Blocks[i]; for (MachineBasicBlock::iterator MII = MBB->begin(), E = MBB->end(); MII != E; ++MII) { const MachineInstr *MI = &*MII; if (isInvalidLoopOperation(MI, IsInnerHWLoop)) { DEBUG(dbgs()<< "\nCannot convert to hw_loop due to:"; MI->dump();); return true; } } } return false; }
false
false
false
false
false
0
xpc_handle_notify_mq_msg_uv(struct xpc_partition *part, struct xpc_notify_mq_msg_uv *msg) { struct xpc_partition_uv *part_uv = &part->sn.uv; struct xpc_channel *ch; struct xpc_channel_uv *ch_uv; struct xpc_notify_mq_msg_uv *msg_slot; unsigned long irq_flags; int ch_number = msg->hdr.ch_number; if (unlikely(ch_number >= part->nchannels)) { dev_err(xpc_part, "xpc_handle_notify_IRQ_uv() received invalid " "channel number=0x%x in message from partid=%d\n", ch_number, XPC_PARTID(part)); /* get hb checker to deactivate from the remote partition */ spin_lock_irqsave(&xpc_activate_IRQ_rcvd_lock, irq_flags); if (part_uv->act_state_req == 0) xpc_activate_IRQ_rcvd++; part_uv->act_state_req = XPC_P_ASR_DEACTIVATE_UV; part_uv->reason = xpBadChannelNumber; spin_unlock_irqrestore(&xpc_activate_IRQ_rcvd_lock, irq_flags); wake_up_interruptible(&xpc_activate_IRQ_wq); return; } ch = &part->channels[ch_number]; xpc_msgqueue_ref(ch); if (!(ch->flags & XPC_C_CONNECTED)) { xpc_msgqueue_deref(ch); return; } /* see if we're really dealing with an ACK for a previously sent msg */ if (msg->hdr.size == 0) { xpc_handle_notify_mq_ack_uv(ch, msg); xpc_msgqueue_deref(ch); return; } /* we're dealing with a normal message sent via the notify_mq */ ch_uv = &ch->sn.uv; msg_slot = ch_uv->recv_msg_slots + (msg->hdr.msg_slot_number % ch->remote_nentries) * ch->entry_size; BUG_ON(msg_slot->hdr.size != 0); memcpy(msg_slot, msg, msg->hdr.size); xpc_put_fifo_entry_uv(&ch_uv->recv_msg_list, &msg_slot->hdr.u.next); if (ch->flags & XPC_C_CONNECTEDCALLOUT_MADE) { /* * If there is an existing idle kthread get it to deliver * the payload, otherwise we'll have to get the channel mgr * for this partition to create a kthread to do the delivery. */ if (atomic_read(&ch->kthreads_idle) > 0) wake_up_nr(&ch->idle_wq, 1); else xpc_send_chctl_local_msgrequest_uv(part, ch->number); } xpc_msgqueue_deref(ch); }
false
false
false
false
false
0
orderBy( qint64 value, bool descending ) { d->orderByField = value; d->orderDescending = descending; switch( value ) { case Meta::valYear: case Meta::valDiscNr: case Meta::valTrackNr: case Meta::valScore: case Meta::valRating: case Meta::valPlaycount: case Meta::valFilesize: case Meta::valSamplerate: case Meta::valBitrate: case Meta::valLength: { d->orderByNumberField = true; break; } //TODO: what about Meta::valFirstPlayed, Meta::valCreateDate or Meta::valLastPlayed?? default: d->orderByNumberField = false; } return this; }
false
false
false
false
false
0
inspect_find_recursive(GtkTreeIter *iter, gint i, const char *key) { do { gboolean flag = !key; if (flag) { gint scid; gtk_tree_model_get(model, iter, INSPECT_SCID, &scid, -1); if (scid == i) return TRUE; } else { char *var1; size_t len; gboolean match; gtk_tree_model_get(model, iter, INSPECT_VAR1, &var1, -1); len = var1 ? strlen(var1) : 0; match = var1 && !strncmp(key, var1, len); g_free(var1); if (match) { if (key[len] == '\0') return TRUE; flag = key[len] == '.' && key[len + 1]; } } if (flag) { GtkTreeIter child; if (gtk_tree_model_iter_children(model, &child, iter) && inspect_find_recursive(&child, i, key)) { *iter = child; return TRUE; } } } while (gtk_tree_model_iter_next(model, iter)); return FALSE; }
false
false
false
false
false
0
getULong(Glib::ustring &str, unsigned long *val) { const char *begin = str.raw().c_str(); char *end; unsigned long ival = strtoul(begin, &end, 10); if (str == end) return false; *val = ival; return true; }
false
false
false
false
false
0
_gdContributionsCalc(unsigned int line_size, unsigned int src_size, double scale_d, const interpolation_method pFilter) { double width_d; double scale_f_d = 1.0; const double filter_width_d = DEFAULT_BOX_RADIUS; int windows_size; unsigned int u; LineContribType *res; if (scale_d < 1.0) { width_d = filter_width_d / scale_d; scale_f_d = scale_d; } else { width_d= filter_width_d; } windows_size = 2 * (int)ceil(width_d) + 1; res = _gdContributionsAlloc(line_size, windows_size); if (res == NULL) { return NULL; } for (u = 0; u < line_size; u++) { const double dCenter = (double)u / scale_d; /* get the significant edge points affecting the pixel */ register int iLeft = MAX(0, (int)floor (dCenter - width_d)); int iRight = MIN((int)ceil(dCenter + width_d), (int)src_size - 1); double dTotalWeight = 0.0; int iSrc; /* Cut edge points to fit in filter window in case of spill-off */ if (iRight - iLeft + 1 > windows_size) { if (iLeft < ((int)src_size - 1 / 2)) { iLeft++; } else { iRight--; } } res->ContribRow[u].Left = iLeft; res->ContribRow[u].Right = iRight; for (iSrc = iLeft; iSrc <= iRight; iSrc++) { dTotalWeight += (res->ContribRow[u].Weights[iSrc-iLeft] = scale_f_d * (*pFilter)(scale_f_d * (dCenter - (double)iSrc))); } if (dTotalWeight < 0.0) { _gdContributionsFree(res); return NULL; } if (dTotalWeight > 0.0) { for (iSrc = iLeft; iSrc <= iRight; iSrc++) { res->ContribRow[u].Weights[iSrc-iLeft] /= dTotalWeight; } } } return res; }
false
false
false
false
false
0
Seeder_WordInfo_add_Seed(Seeder *seeder, Seeder_WordInfo *word_info, Seeder_Context *context, Match_Score query_expect, gint qpos){ register Seeder_Seed *seed; g_assert(word_info); if(seeder->saturate_threshold){ if(!word_info->match_mailbox) /* Already blocked */ return; /* Apply saturate_threshold to frequent query words */ if(++word_info->match_count > query_expect){ word_info->match_mailbox = 0; /* block */ Seeder_WordInfo_empty(seeder, word_info); return; } } seed = RecycleBin_alloc(seeder->recycle_seed); seed->next = word_info->seed_list; seed->query_pos = qpos; seed->context = context; word_info->seed_list = seed; return; }
false
false
false
false
false
0
drm_modeset_lock_crtc(struct drm_crtc *crtc, struct drm_plane *plane) { struct drm_modeset_acquire_ctx *ctx; int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (WARN_ON(!ctx)) return; drm_modeset_acquire_init(ctx, 0); retry: ret = drm_modeset_lock(&crtc->mutex, ctx); if (ret) goto fail; if (plane) { ret = drm_modeset_lock(&plane->mutex, ctx); if (ret) goto fail; if (plane->crtc) { ret = drm_modeset_lock(&plane->crtc->mutex, ctx); if (ret) goto fail; } } WARN_ON(crtc->acquire_ctx); /* now we hold the locks, so now that it is safe, stash the * ctx for drm_modeset_unlock_crtc(): */ crtc->acquire_ctx = ctx; return; fail: if (ret == -EDEADLK) { drm_modeset_backoff(ctx); goto retry; } }
false
false
false
false
false
0
updateLastModInfo() { helpers::FileInfo fi; if (helpers::getFileInfo (&fi, propertyFilename) == 0) lastFileInfo = fi; }
false
false
false
false
false
0
get_mountport(struct pmap *pm_mnt, struct sockaddr_in *server_addr, long unsigned prog, long unsigned version, long unsigned proto, long unsigned port) { struct pmaplist *pmap; server_addr->sin_port = PMAPPORT; /* glibc 2.4 (still) has pmap_getmaps(struct sockaddr_in *). * I understand it like "IPv6 for this is not 100% ready" */ pmap = pmap_getmaps(server_addr); if (version > MAX_NFSPROT) version = MAX_NFSPROT; if (!prog) prog = MOUNTPROG; pm_mnt->pm_prog = prog; pm_mnt->pm_vers = version; pm_mnt->pm_prot = proto; pm_mnt->pm_port = port; while (pmap) { if (pmap->pml_map.pm_prog != prog) goto next; if (!version && pm_mnt->pm_vers > pmap->pml_map.pm_vers) goto next; if (version > 2 && pmap->pml_map.pm_vers != version) goto next; if (version && version <= 2 && pmap->pml_map.pm_vers > 2) goto next; if (pmap->pml_map.pm_vers > MAX_NFSPROT || (proto && pm_mnt->pm_prot && pmap->pml_map.pm_prot != proto) || (port && pmap->pml_map.pm_port != port) ) { goto next; } memcpy(pm_mnt, &pmap->pml_map, sizeof(*pm_mnt)); next: pmap = pmap->pml_next; } if (!pm_mnt->pm_vers) pm_mnt->pm_vers = MOUNTVERS; if (!pm_mnt->pm_port) pm_mnt->pm_port = MOUNTPORT; if (!pm_mnt->pm_prot) pm_mnt->pm_prot = IPPROTO_TCP; }
false
false
false
false
false
0
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a) { if (_c == QMetaObject::InvokeMetaMethod) { Q_ASSERT(staticMetaObject.cast(_o)); AbstractCalendarModel *_t = static_cast<AbstractCalendarModel *>(_o); switch (_id) { case 0: _t->dataChanged((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1]))); break; case 1: _t->itemInserted((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1]))); break; case 2: _t->itemModified((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1])),(*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[2]))); break; case 3: _t->itemRemoved((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1]))); break; case 4: _t->reset(); break; case 5: _t->clearAll(); break; case 6: { bool _r = _t->submitAll(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 7: { bool _r = _t->submit((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 8: { bool _r = _t->revert((*reinterpret_cast< const Calendar::CalendarItem(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; default: ; } } }
false
false
false
false
false
0
spGetSize( spMatrix eMatrix, int External ) { MatrixPtr Matrix = (MatrixPtr)eMatrix; /* Begin `spGetSize'. */ ASSERT_IS_SPARSE( Matrix ); #if TRANSLATE if (External) return Matrix->ExtSize; else return Matrix->Size; #else return Matrix->Size; #endif }
false
false
false
false
false
0
write_code_fromdb_c(ARGUMENTS *args, GWEN_XMLNODE *node, GWEN_SYNCIO *sio) { const char *prefix; const char *styp; const char *fromDbName; const char *fromDbAcc; prefix=get_struct_property(node, "prefix", 0); if (!prefix) { DBG_ERROR(0, "No prefix in struct"); return -1; } styp=get_struct_property(node, "id", 0); if (!styp) { DBG_ERROR(0, "No id in struct"); return -1; } fromDbAcc=get_struct_property(node, "dup-access", get_struct_property(node, "access", 0)); fromDbName=get_struct_property(node, "fromdb-name", 0); if (fromDbAcc && strcasecmp(fromDbAcc, "none")!=0) { GWEN_SyncIo_WriteString(sio, styp); GWEN_SyncIo_WriteString(sio, " *"); GWEN_SyncIo_WriteString(sio, prefix); if (fromDbName) GWEN_SyncIo_WriteString(sio, fromDbName); else GWEN_SyncIo_WriteString(sio, "_fromDb"); GWEN_SyncIo_WriteLine(sio, "(GWEN_DB_NODE *db) {"); GWEN_SyncIo_WriteString(sio, " "); GWEN_SyncIo_WriteString(sio, styp); GWEN_SyncIo_WriteLine(sio, " *st;"); GWEN_SyncIo_WriteLine(sio, ""); GWEN_SyncIo_WriteLine(sio, " assert(db);"); GWEN_SyncIo_WriteString(sio, " st="); GWEN_SyncIo_WriteString(sio, prefix); GWEN_SyncIo_WriteLine(sio, "_new();"); GWEN_SyncIo_WriteString(sio, " "); GWEN_SyncIo_WriteString(sio, prefix); GWEN_SyncIo_WriteLine(sio, "_ReadDb(st, db);"); GWEN_SyncIo_WriteLine(sio, " st->_modified=0;"); GWEN_SyncIo_WriteLine(sio, " return st;"); GWEN_SyncIo_WriteLine(sio, "}"); } /* if fromDb wanted */ return 0; }
false
false
false
false
false
0
numeric_uminus(PG_FUNCTION_ARGS) { Numeric num = PG_GETARG_NUMERIC(0); Numeric res; /* * Handle NaN */ if (NUMERIC_IS_NAN(num)) PG_RETURN_NUMERIC(make_result(&const_nan)); /* * Do it the easy way directly on the packed format */ res = (Numeric) palloc(VARSIZE(num)); memcpy(res, num, VARSIZE(num)); /* * The packed format is known to be totally zero digit trimmed always. So * we can identify a ZERO by the fact that there are no digits at all. Do * nothing to a zero. */ if (VARSIZE(num) != NUMERIC_HDRSZ) { /* Else, flip the sign */ if (NUMERIC_SIGN(num) == NUMERIC_POS) res->n_sign_dscale = NUMERIC_NEG | NUMERIC_DSCALE(num); else res->n_sign_dscale = NUMERIC_POS | NUMERIC_DSCALE(num); } PG_RETURN_NUMERIC(res); }
false
true
false
false
false
1
automember_add_member_value(Slapi_Entry *member_e, const char *group_dn, char *grouping_attr, char *grouping_value, PRFileDesc *ldif_fd) { Slapi_PBlock *mod_pb = slapi_pblock_new(); int result = LDAP_SUCCESS; LDAPMod mod; LDAPMod *mods[2]; char *vals[2]; char *member_value = NULL; int freeit = 0; int rc = 0; /* If grouping_value is dn, we need to fetch the dn instead. */ if (slapi_attr_type_cmp(grouping_value, "dn", SLAPI_TYPE_CMP_EXACT) == 0) { member_value = slapi_entry_get_ndn(member_e); } else { member_value = slapi_entry_attr_get_charptr(member_e, grouping_value); freeit = 1; } /* * If ldif_fd is set, we are performing an export task. Write the changes to the * file instead of performing them */ if(ldif_fd){ PR_fprintf(ldif_fd, "dn: %s\n", group_dn); PR_fprintf(ldif_fd, "changetype: modify\n"); PR_fprintf(ldif_fd, "add: %s\n", grouping_attr); PR_fprintf(ldif_fd, "%s: %s\n", grouping_attr, member_value); PR_fprintf(ldif_fd, "\n"); goto out; } if (member_value) { /* Set up the operation. */ vals[0] = member_value; vals[1] = 0; mod.mod_op = LDAP_MOD_ADD; mod.mod_type = grouping_attr; mod.mod_values = vals; mods[0] = &mod; mods[1] = 0; /* Perform the modify operation. */ slapi_log_error(SLAPI_LOG_PLUGIN, AUTOMEMBER_PLUGIN_SUBSYSTEM, "automember_add_member_value: Adding \"%s\" as " "a \"%s\" value to group \"%s\".\n", member_value, grouping_attr, group_dn); slapi_modify_internal_set_pb(mod_pb, group_dn, mods, 0, 0, automember_get_plugin_id(), 0); slapi_modify_internal_pb(mod_pb); slapi_pblock_get(mod_pb, SLAPI_PLUGIN_INTOP_RESULT, &result); if ((result != LDAP_SUCCESS) && (result != LDAP_TYPE_OR_VALUE_EXISTS)) { slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM, "automember_add_member_value: Unable to add \"%s\" as " "a \"%s\" value to group \"%s\" (%s).\n", member_value, grouping_attr, group_dn, ldap_err2string(result)); rc = result; } } else { slapi_log_error(SLAPI_LOG_FATAL, AUTOMEMBER_PLUGIN_SUBSYSTEM, "automember_add_member_value: Unable to find grouping " "value attribute \"%s\" in entry \"%s\".\n", grouping_value, slapi_entry_get_dn(member_e)); } out: /* Cleanup */ if (freeit) { slapi_ch_free_string(&member_value); } slapi_pblock_destroy(mod_pb); return rc; }
false
false
false
false
false
0
gst_pad_push_list (GstPad * pad, GstBufferList * list) { GstBuffer *buf; GstPadPushCache *cache; GstFlowReturn ret; gpointer *cache_ptr; GstPad *peer; GstCaps *caps; g_return_val_if_fail (GST_IS_PAD (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_PAD_IS_SRC (pad), GST_FLOW_ERROR); g_return_val_if_fail (GST_IS_BUFFER_LIST (list), GST_FLOW_ERROR); cache_ptr = (gpointer *) & pad->abidata.ABI.priv->cache_ptr; cache = pad_take_cache (pad, cache_ptr); if (G_UNLIKELY (cache == NULL)) goto slow_path; /* check caps */ if ((buf = gst_buffer_list_get (list, 0, 0))) caps = GST_BUFFER_CAPS (buf); else caps = NULL; if (G_UNLIKELY (caps && caps != cache->caps)) { pad_free_cache (cache); goto slow_path; } peer = cache->peer; GST_PAD_STREAM_LOCK (peer); if (G_UNLIKELY (g_atomic_pointer_get (cache_ptr) == PAD_CACHE_INVALID)) goto invalid; ret = GST_PAD_CHAINLISTFUNC (peer) (peer, list); GST_PAD_STREAM_UNLOCK (peer); pad_put_cache (pad, cache, cache_ptr); return ret; /* slow path */ slow_path: { GstPadPushCache scache = { NULL, }; GST_LOG_OBJECT (pad, "Taking slow path"); ret = gst_pad_push_data (pad, FALSE, list, &scache); if (scache.peer) { GstPadPushCache *ncache; GST_LOG_OBJECT (pad, "Caching push data"); /* make cache structure */ ncache = g_slice_new (GstPadPushCache); *ncache = scache; pad_put_cache (pad, ncache, cache_ptr); } return ret; } invalid: { GST_PAD_STREAM_UNLOCK (peer); pad_free_cache (cache); goto slow_path; } }
false
false
false
false
false
0
ft_stroke_border_export( FT_StrokeBorder border, FT_Outline* outline ) { /* copy point locations */ FT_ARRAY_COPY( outline->points + outline->n_points, border->points, border->num_points ); /* copy tags */ { FT_UInt count = border->num_points; FT_Byte* read = border->tags; FT_Byte* write = (FT_Byte*)outline->tags + outline->n_points; for ( ; count > 0; count--, read++, write++ ) { if ( *read & FT_STROKE_TAG_ON ) *write = FT_CURVE_TAG_ON; else if ( *read & FT_STROKE_TAG_CUBIC ) *write = FT_CURVE_TAG_CUBIC; else *write = FT_CURVE_TAG_CONIC; } } /* copy contours */ { FT_UInt count = border->num_points; FT_Byte* tags = border->tags; FT_Short* write = outline->contours + outline->n_contours; FT_Short idx = (FT_Short)outline->n_points; for ( ; count > 0; count--, tags++, idx++ ) { if ( *tags & FT_STROKE_TAG_END ) { *write++ = idx; outline->n_contours++; } } } outline->n_points += (short)border->num_points; FT_ASSERT( FT_Outline_Check( outline ) == 0 ); }
false
true
false
false
true
1
mt6397_set_buck_vosel_reg(struct platform_device *pdev) { struct mt6397_chip *mt6397 = dev_get_drvdata(pdev->dev.parent); int i; u32 regval; for (i = 0; i < MT6397_MAX_REGULATOR; i++) { if (mt6397_regulators[i].vselctrl_reg) { if (regmap_read(mt6397->regmap, mt6397_regulators[i].vselctrl_reg, &regval) < 0) { dev_err(&pdev->dev, "Failed to read buck ctrl\n"); return -EIO; } if (regval & mt6397_regulators[i].vselctrl_mask) { mt6397_regulators[i].desc.vsel_reg = mt6397_regulators[i].vselon_reg; } } } return 0; }
false
false
false
false
false
0
removeBranchesBelowThreshold(CallerNode* root) { int i; int max; if (!root) return (0); for (i = 0; i < root->noCallees; i++) { if (removeBranchesBelowThreshold(root->callees[i])) { free(root->callees[i]); if (root->noCallees > 1) { root->callees[i] = root->callees[root->noCallees - 1]; root->callees[root->noCallees - 1] = 0; } else if (root->noCallees == 1) root->callees[i] = 0; root->noCallees--; i--; } } if (root->noCallees == 0 && root->mallocs < mallThreshold ) return (1); return (0); }
false
false
false
false
false
0
serializeList(const QList<QByteArray> &list) { QByteArray value = ""; if (!list.isEmpty()) { QList<QByteArray>::ConstIterator it = list.constBegin(); const QList<QByteArray>::ConstIterator end = list.constEnd(); value = QByteArray(*it).replace('\\', "\\\\").replace(',', "\\,"); while (++it != end) { // In the loop, so it is not done when there is only one element. // Doing it repeatedly is a pretty cheap operation. value.reserve(4096); value += ','; value += QByteArray(*it).replace('\\', "\\\\").replace(',', "\\,"); } // To be able to distinguish an empty list from a list with one empty element. if (value.isEmpty()) value = "\\0"; } return value; }
false
false
false
false
false
0
auth_sasldb ( /* PARAMETERS */ #ifdef AUTH_SASLDB const char *login, /* I: plaintext authenticator */ const char *password, /* I: plaintext password */ const char *service __attribute__((unused)), const char *realm #else const char *login __attribute__((unused)),/* I: plaintext authenticator */ const char *password __attribute__((unused)), /* I: plaintext password */ const char *service __attribute__((unused)), const char *realm __attribute__((unused)) #endif /* END PARAMETERS */ ) { #ifdef AUTH_SASLDB /* VARIABLES */ char pw[1024]; /* pointer to passwd file entry */ sasl_utils_t utils; int ret, outsize; const char *use_realm; char realm_buf[MAXHOSTNAMELEN]; /* END VARIABLES */ init_lame_utils(&utils); _sasl_check_db(&utils, (void *)0x1); if(!realm || !strlen(realm)) { ret = gethostname(realm_buf,MAXHOSTNAMELEN); if(ret) RETURN("NO"); use_realm = realm_buf; } else { use_realm = realm; } ret = _sasldb_getdata(&utils, (void *)0x1, login, use_realm, "userPassword", pw, 1024, &outsize); if (ret != SASL_OK) { RETURN("NO"); } if (strcmp(pw, password)) { RETURN("NO"); } RETURN("OK"); #else RETURN("NO"); #endif }
false
false
false
false
false
0
qrihrm(real_t **a, int n, real_t val[], real_t **vr, real_t **vi, real_t em[]) { real_t *allocate_real_vector(int, int); void free_real_vector(real_t *, int); void hshhrmtri(real_t **, int, real_t [], real_t [], real_t [], real_t [], real_t [], real_t []); int qrisymtri(real_t **, int, real_t [], real_t [], real_t [], real_t []); void bakhrmtri(real_t **, int, int, int, real_t **, real_t **, real_t [], real_t []); int i,j; real_t *b,*bb,*tr,*ti; b=allocate_real_vector(1,n); bb=allocate_real_vector(1,n); tr=allocate_real_vector(1,n-1); ti=allocate_real_vector(1,n-1); hshhrmtri(a,n,val,b,bb,em,tr,ti); for (i=1; i<=n; i++) { vr[i][i]=1.0; for (j=i+1; j<=n; j++) vr[i][j]=vr[j][i]=0.0; } b[n]=bb[n]=0.0; i=qrisymtri(vr,n,val,b,bb,em); bakhrmtri(a,n,i+1,n,vr,vi,tr,ti); free_real_vector(b,1); free_real_vector(bb,1); free_real_vector(tr,1); free_real_vector(ti,1); return i; }
false
false
false
false
false
0
_nrrdCopy(Nrrd *nout, const Nrrd *nin, int bitflag) { static const char me[]="_nrrdCopy"; size_t size[NRRD_DIM_MAX]; if (!(nin && nout)) { biffAddf(NRRD, "%s: got NULL pointer", me); return 1; } if (nout == nin) { /* its not the case that we have nothing to do- the semantics of copying cannot be achieved if the input and output nrrd are the same; this is an error */ biffAddf(NRRD, "%s: nout==nin disallowed", me); return 1; } if (!nrrdElementSize(nin)) { biffAddf(NRRD, "%s: input nrrd reports zero element size!", me); return 1; } nrrdAxisInfoGet_nva(nin, nrrdAxisInfoSize, size); if (nin->data) { if (nrrdMaybeAlloc_nva(nout, nin->type, nin->dim, size)) { biffAddf(NRRD, "%s: couldn't allocate data", me); return 1; } memcpy(nout->data, nin->data, nrrdElementNumber(nin)*nrrdElementSize(nin)); } else { /* someone is trying to copy structs without data, fine fine fine */ if (nrrdWrap_nva(nout, NULL, nin->type, nin->dim, size)) { biffAddf(NRRD, "%s: couldn't allocate data", me); return 1; } } nrrdAxisInfoCopy(nout, nin, NULL, NRRD_AXIS_INFO_SIZE_BIT); /* if nin->data non-NULL (second branch above), this will harmlessly unset and set type and dim */ nrrdBasicInfoInit(nout, NRRD_BASIC_INFO_DATA_BIT | bitflag); if (nrrdBasicInfoCopy(nout, nin, NRRD_BASIC_INFO_DATA_BIT | bitflag)) { biffAddf(NRRD, "%s: trouble copying basic info", me); return 1; } return 0; }
false
true
false
false
false
1
gcr_certificate_get_fingerprint_hex (GcrCertificate *self, GChecksumType type) { GChecksum *sum; guchar *digest; gsize n_digest; gssize length; gchar *hex; g_return_val_if_fail (GCR_IS_CERTIFICATE (self), NULL); sum = digest_certificate (self, type); if (sum == NULL) return NULL; length = g_checksum_type_get_length (type); g_return_val_if_fail (length > 0, NULL); digest = g_malloc (length); n_digest = length; g_checksum_get_digest (sum, digest, &n_digest); hex = egg_hex_encode_full (digest, n_digest, TRUE, " ", 1); g_checksum_free (sum); g_free (digest); return hex; }
false
false
false
false
false
0
collection_table_popup_print_cb(GtkWidget *widget, gpointer data) { CollectTable *ct = data; FileData *fd; fd = (ct->click_info) ? ct->click_info->fd : NULL; print_window_new(fd, collection_table_selection_get_list(ct), collection_table_get_list(ct), ct->listview); }
false
false
false
false
false
0
flip_screen_x_set(int on) { if (on) on = ~0; if (flip_screen_x != on) { set_vh_global_attribute(&flip_screen_x,on); updateflip(); } }
false
false
false
false
false
0
mca_btl_sctp_set_socket_options(int sd) { int optval, flags; struct sctp_event_subscribe evnts; /* register io event here to see populated sndrcvinfo struct */ memset(&evnts, 0, sizeof(evnts)); evnts.sctp_data_io_event = 1; if(setsockopt(sd, IPPROTO_SCTP, SCTP_EVENTS, &evnts, sizeof(evnts)) < 0) { BTL_ERROR(("setsockopt(SCTP_EVENTS) failed with errno=%d", opal_socket_errno)); return OMPI_ERROR; } /*TODO set maximum number of streams */ #if defined(SCTP_NODELAY) optval = mca_btl_sctp_component.sctp_use_nodelay; if(setsockopt(sd, IPPROTO_SCTP, SCTP_NODELAY, (char *)&optval, sizeof(optval)) < 0) { BTL_ERROR(("setsockopt(SCTP_NODELAY) failed with errno=%d", opal_socket_errno)); return OMPI_ERROR; } #endif #if defined(SO_SNDBUF) if(mca_btl_sctp_component.sctp_sndbuf > 0 && setsockopt(sd, SOL_SOCKET, SO_SNDBUF, (char *)&mca_btl_sctp_component.sctp_sndbuf, sizeof(int)) < 0) { BTL_ERROR(("setsockopt(SO_SNDBUF) failed with errno %d", opal_socket_errno)); return OMPI_ERROR; } #endif #if defined(SO_RCVBUF) if(mca_btl_sctp_component.sctp_rcvbuf > 0 && setsockopt(sd, SOL_SOCKET, SO_RCVBUF, (char *)&mca_btl_sctp_component.sctp_rcvbuf, sizeof(int)) < 0) { BTL_ERROR(("setsockopt(SO_RCVBUF) failed with errno %d", opal_socket_errno)); return OMPI_ERROR; } #endif /* set socket up to be non-blocking */ if((flags = fcntl(sd, F_GETFL, 0)) < 0) { BTL_ERROR(("fcntl(F_GETFL) failed with errno=%d", opal_socket_errno)); return OMPI_ERROR; } else { flags |= O_NONBLOCK; if(fcntl(sd, F_SETFL, flags) < 0) { BTL_ERROR(("fcntl(F_SETFL) failed with errno=%d", opal_socket_errno)); return OMPI_ERROR; } } return OMPI_SUCCESS; }
false
false
false
false
false
0
routerGetPortType( struct sProfile *psProfile, const char *pnName ) { const char *pnPortName; int nIndex; if ( pnName != NULL ) { for ( nIndex = 0; nIndex < NAME_COUNT; nIndex++ ) { pnPortName = routerGetPortName( psProfile, asPortNames[ nIndex ].pnName ); if ( strcmp( pnName, pnPortName ) == 0 ) { return asPortNames[ nIndex ].nType; } } } else { return asPortNames[ 0 ].nType; } return 0; }
false
false
false
false
false
0
ce_write_entry(git_SHA_CTX *c, int fd, struct cache_entry *ce) { int size = ondisk_ce_size(ce); struct ondisk_cache_entry *ondisk = xcalloc(1, size); char *name; int result; ondisk->ctime.sec = htonl(ce->ce_ctime.sec); ondisk->mtime.sec = htonl(ce->ce_mtime.sec); ondisk->ctime.nsec = htonl(ce->ce_ctime.nsec); ondisk->mtime.nsec = htonl(ce->ce_mtime.nsec); ondisk->dev = htonl(ce->ce_dev); ondisk->ino = htonl(ce->ce_ino); ondisk->mode = htonl(ce->ce_mode); ondisk->uid = htonl(ce->ce_uid); ondisk->gid = htonl(ce->ce_gid); ondisk->size = htonl(ce->ce_size); hashcpy(ondisk->sha1, ce->sha1); ondisk->flags = htons(ce->ce_flags); if (ce->ce_flags & CE_EXTENDED) { struct ondisk_cache_entry_extended *ondisk2; ondisk2 = (struct ondisk_cache_entry_extended *)ondisk; ondisk2->flags2 = htons((ce->ce_flags & CE_EXTENDED_FLAGS) >> 16); name = ondisk2->name; } else name = ondisk->name; memcpy(name, ce->name, ce_namelen(ce)); result = ce_write(c, fd, ondisk, size); free(ondisk); return result; }
false
true
false
false
false
1
test_kvp_frame_get_frame_or_null_slash_trash( Fixture *fixture, gconstpointer pData ) { g_test_message( "Test null checks" ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( NULL, "test" ) == NULL ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, NULL ) == NULL ); g_test_message( "Test single slash and trailing slash path" ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, "/" ) == fixture->frame ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, "////" ) == fixture->frame ); g_test_message( "Test non existing path" ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, "/test" ) == NULL ); g_test_message( "Test existing path when value is not frame" ); kvp_frame_set_gint64( fixture->frame, "/test", 2 ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, "/test" ) == NULL ); g_test_message( "Test existing path when value is frame" ); kvp_frame_set_frame( fixture->frame, "/test2", kvp_frame_new() ); g_assert( p_kvp_frame_get_frame_or_null_slash_trash( fixture->frame, "/test2" ) != NULL ); }
false
false
false
false
false
0
AppendFortranFormatFlags(std::string& flags, cmSourceFile& source) { const char* srcfmt = source.GetProperty("Fortran_FORMAT"); cmLocalGenerator::FortranFormat format = this->LocalGenerator->GetFortranFormat(srcfmt); if(format == cmLocalGenerator::FortranFormatNone) { const char* tgtfmt = this->Target->GetProperty("Fortran_FORMAT"); format = this->LocalGenerator->GetFortranFormat(tgtfmt); } const char* var = 0; switch (format) { case cmLocalGenerator::FortranFormatFixed: var = "CMAKE_Fortran_FORMAT_FIXED_FLAG"; break; case cmLocalGenerator::FortranFormatFree: var = "CMAKE_Fortran_FORMAT_FREE_FLAG"; break; default: break; } if(var) { this->LocalGenerator->AppendFlags( flags, this->Makefile->GetDefinition(var)); } }
false
false
false
false
false
0
TcpReadFromProxy() { if(!_running) { qDebug("SOCKS read but not running"); return; } QTcpSocket* socket = qobject_cast<QTcpSocket*>(sender()); if(!socket) { qWarning("SOCKS Illegal call to ReadFromClient()"); return; } if(!CheckSession()) { qDebug("SOCKS read but no session"); return; } do { QByteArray data = socket->read(64000); qDebug() << "SOCKS Read" << data.count() << "bytes from proxy socket"; TcpResponsePacket resp(_table.IdForConnection(socket), data); //GetSession()->Send(resp.ToByteArray()); //qDebug() << "SOCKS " << data; SendReply(resp.ToByteArray()); } while(socket->bytesAvailable()); qDebug() << "MEM active" << _table.Count(); }
false
false
false
false
false
0
ndmda_send_notice (struct ndm_session *sess) { struct ndm_data_agent * da = &sess->data_acb; if (!da->data_notify_pending) return; da->data_notify_pending = 0; switch (da->data_state.state) { case NDMP9_DATA_STATE_HALTED: ndma_notify_data_halted (sess); break; default: /* Hmm. Why are we here. Race? */ break; } }
false
false
false
false
false
0
memstr(const void *haystack, const char *needle, size_t n) { const u_char *pos = haystack; size_t l; if (!haystack || !needle || (l = strlen(needle)) == 0) { return NULL; } for (; n >= l; ++pos, --n) { if (memeq(pos, needle, l)) { return (void*)pos; } } return NULL; }
false
false
false
false
false
0
boxGuiIds() { return QStringList() << "Frameless" << "Boxed" << "ovalbox" << "Ovalbox" << "Shadowbox" << "Shaded" << "Doublebox"; }
false
false
false
false
false
0
gf_add_cmdline_options (glusterfs_graph_t *graph, cmd_args_t *cmd_args) { int ret = 0; xlator_t *trav = NULL; xlator_cmdline_option_t *cmd_option = NULL; trav = graph->first; while (trav) { list_for_each_entry (cmd_option, &cmd_args->xlator_options, cmd_args) { if (!fnmatch (cmd_option->volume, trav->name, FNM_NOESCAPE)) { ret = dict_set_str (trav->options, cmd_option->key, cmd_option->value); if (ret == 0) { gf_log (trav->name, GF_LOG_INFO, "adding option '%s' for " "volume '%s' with value '%s'", cmd_option->key, trav->name, cmd_option->value); } else { gf_log (trav->name, GF_LOG_WARNING, "adding option '%s' for " "volume '%s' failed: %s", cmd_option->key, trav->name, strerror (-ret)); } } } trav = trav->next; } }
false
false
false
false
false
0
_elm_layout_smart_box_remove_all(Evas_Object *obj, const char *part, Eina_Bool clear) { EINA_SAFETY_ON_NULL_RETURN_VAL(part, EINA_FALSE); ELM_LAYOUT_DATA_GET(obj, sd); Elm_Layout_Sub_Object_Data *sub_d; Eina_List *lst; lst = eina_list_clone(sd->subs); EINA_LIST_FREE (lst, sub_d) { if (!_sub_box_is(sub_d)) continue; if (!strcmp(sub_d->part, part)) { /* original item's deletion handled at sub-obj-del */ Evas_Object *child = _sub_box_remove(obj, sd, sub_d); if ((clear) && (child)) evas_object_del(child); } } /* eventually something may not be added with elm_layout, delete them * as well */ edje_object_part_box_remove_all (ELM_WIDGET_DATA(sd)->resize_obj, part, clear); return EINA_TRUE; }
false
false
false
false
false
0
store_attrs(struct mthca_sqp *sqp, const struct ib_qp_attr *attr, int attr_mask) { if (attr_mask & IB_QP_PKEY_INDEX) sqp->pkey_index = attr->pkey_index; if (attr_mask & IB_QP_QKEY) sqp->qkey = attr->qkey; if (attr_mask & IB_QP_SQ_PSN) sqp->send_psn = attr->sq_psn; }
false
false
false
false
false
0
apple_input_mapped(struct hid_device *hdev, struct hid_input *hi, struct hid_field *field, struct hid_usage *usage, unsigned long **bit, int *max) { struct apple_sc *asc = hid_get_drvdata(hdev); if (asc->quirks & APPLE_MIGHTYMOUSE) { if (usage->hid == HID_GD_Z) hid_map_usage(hi, usage, bit, max, EV_REL, REL_HWHEEL); else if (usage->code == BTN_1) hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_2); else if (usage->code == BTN_2) hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_1); } return 0; }
false
false
false
false
false
0
accept_table_arg(struct Table *table, char *arg) { if (table->name == NULL) { table->name = strdup(arg); if (table->name == NULL) { perror("strdup"); return -1; } } else { fprintf(stderr, "Unexpected table argument: %s\n", arg); return -1; } return 1; }
false
false
false
false
false
0
flushOutputBuffer() { if (outputBufCount_) { // flush from outputBufStart_ to end of data or end of buffer, whatever comes first offile_off_t numBytes = (outputBufStart_ + outputBufCount_ > DCMZLIBOUTPUTFILTER_BUFSIZE) ? (DCMZLIBOUTPUTFILTER_BUFSIZE - outputBufStart_) : outputBufCount_ ; offile_off_t written = current_->write(outputBuf_ + outputBufStart_, numBytes); // adjust counters outputBufCount_ -= written; outputBufStart_ += written; if (outputBufStart_ == DCMZLIBOUTPUTFILTER_BUFSIZE) { // wrapped around outputBufStart_ = 0; // now flush to end of data if (outputBufCount_ && written) { written = current_->write(outputBuf_, outputBufCount_); // adjust counters outputBufCount_ -= written; outputBufStart_ += written; } } // reset buffer start to make things faster if (outputBufCount_ == 0) outputBufStart_ = 0; } }
false
false
false
false
false
0
efivarfs_ioc_getxflags(struct file *file, void __user *arg) { struct inode *inode = file->f_mapping->host; unsigned int i_flags; unsigned int flags = 0; i_flags = inode->i_flags; if (i_flags & S_IMMUTABLE) flags |= FS_IMMUTABLE_FL; if (copy_to_user(arg, &flags, sizeof(flags))) return -EFAULT; return 0; }
false
false
false
false
false
0
GetFirst(Iterator *itrav) { struct TreeMapIterator *trav = (struct TreeMapIterator *)itrav; if (trav->timestamp != trav->bst_table->timestamp) return NULL; trav->bst_node = bt_first(trav->bst_table); if (trav->bst_node) return trav->bst_node->data; return NULL; }
false
false
false
false
false
0
cpl_errorstate_set(cpl_errorstate self) { const size_t myself = (const size_t)self; if (myself == 0) { cpl_error_reset(); } else if (myself < estate.current) { if (!cpl_error_is_readonly()) estate.current = myself; } }
false
false
false
false
false
0
OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert) { if (!resp->certs && !(resp->certs = sk_X509_new_null())) return 0; if(!sk_X509_push(resp->certs, cert)) return 0; CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); return 1; }
false
false
false
false
false
0
test_must(void) { char *pc; if(must) return 1; pc=getenv("chroot"); if(pc && strcmp(pc,"must")==0) return 1; else return 0; }
false
false
true
false
true
1
WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) { EVT VT = N->getValueType(0); EVT WidenVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT); unsigned WidenNumElts = WidenVT.getVectorNumElements(); SDValue InOp = N->getOperand(0); SDValue Idx = N->getOperand(1); DebugLoc dl = N->getDebugLoc(); if (getTypeAction(InOp.getValueType()) == WidenVector) InOp = GetWidenedVector(InOp); EVT InVT = InOp.getValueType(); ConstantSDNode *CIdx = dyn_cast<ConstantSDNode>(Idx); if (CIdx) { unsigned IdxVal = CIdx->getZExtValue(); // Check if we can just return the input vector after widening. if (IdxVal == 0 && InVT == WidenVT) return InOp; // Check if we can extract from the vector. unsigned InNumElts = InVT.getVectorNumElements(); if (IdxVal % WidenNumElts == 0 && IdxVal + WidenNumElts < InNumElts) return DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, WidenVT, InOp, Idx); } // We could try widening the input to the right length but for now, extract // the original elements, fill the rest with undefs and build a vector. SmallVector<SDValue, 16> Ops(WidenNumElts); EVT EltVT = VT.getVectorElementType(); EVT IdxVT = Idx.getValueType(); unsigned NumElts = VT.getVectorNumElements(); unsigned i; if (CIdx) { unsigned IdxVal = CIdx->getZExtValue(); for (i=0; i < NumElts; ++i) Ops[i] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp, DAG.getConstant(IdxVal+i, IdxVT)); } else { Ops[0] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp, Idx); for (i=1; i < NumElts; ++i) { SDValue NewIdx = DAG.getNode(ISD::ADD, dl, Idx.getValueType(), Idx, DAG.getConstant(i, IdxVT)); Ops[i] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp, NewIdx); } } SDValue UndefVal = DAG.getUNDEF(EltVT); for (; i < WidenNumElts; ++i) Ops[i] = UndefVal; return DAG.getNode(ISD::BUILD_VECTOR, dl, WidenVT, &Ops[0], WidenNumElts); }
false
false
false
false
false
0
pci_serr_error(unsigned char reason, struct pt_regs *regs) { /* check to see if anyone registered against these types of errors */ if (nmi_handle(NMI_SERR, regs)) return; pr_emerg("NMI: PCI system error (SERR) for reason %02x on CPU %d.\n", reason, smp_processor_id()); /* * On some machines, PCI SERR line is used to report memory * errors. EDAC makes use of it. */ #if defined(CONFIG_EDAC) if (edac_handler_set()) { edac_atomic_assert_error(); return; } #endif if (panic_on_unrecovered_nmi) panic("NMI: Not continuing"); pr_emerg("Dazed and confused, but trying to continue\n"); /* Clear and disable the PCI SERR error line. */ reason = (reason & NMI_REASON_CLEAR_MASK) | NMI_REASON_CLEAR_SERR; outb(reason, NMI_REASON_PORT); }
false
false
false
false
false
0
_sel_desk_cb(void *data) { E_Config_Dialog_Data *cfdata = data; if (cfdata->seldest) { const char *s = e_widget_ilist_selected_value_get(cfdata->obj.deflist); if (*(cfdata->seldest)) eina_stringshare_del(*(cfdata->seldest)); *(cfdata->seldest) = NULL; if (s) *(cfdata->seldest) = eina_stringshare_add(s); if ((*(cfdata->seldest)) && (cfdata->seldest == &(cfdata->browser_desktop))) { Eina_List *l; Efreet_Desktop *desk; EINA_LIST_FOREACH(cfdata->desks, l, desk) { if ((!strcmp(desk->orig_path, *(cfdata->seldest))) || (!strcmp(ecore_file_file_get(desk->orig_path), *(cfdata->seldest)))) { if (desk->exec) { char *p; free(cfdata->browser_custom); cfdata->browser_custom = strdup(desk->exec); for (p = cfdata->browser_custom; *p; p++) { if (p > cfdata->browser_custom) { if ((isspace(*p)) && (p[-1] != '\\')) { *p = 0; break; } } } p = strdup(cfdata->browser_custom); if (p) { e_widget_entry_text_set(cfdata->obj.entry, p); free(p); } } break; } } } } }
false
false
false
false
false
0
AddTextureSampleWrapperInvocation(UniformParameterPtr textureSampler,UniformParameterPtr textureSamplerState, GpuConstantType samplerType, Function* function, int groupOrder, int& internalCounter) { FunctionInvocation* curFuncInvocation = NULL; ParameterPtr samplerWrapperParam = GetSamplerWrapperParam(textureSampler, function); curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_CONSTRUCT_SAMPLER_WRAPPER, groupOrder, internalCounter++); curFuncInvocation->pushOperand(textureSampler, Operand::OPS_IN); if (Ogre::RTShader::ShaderGenerator::getSingletonPtr()->IsHlsl4()) curFuncInvocation->pushOperand(textureSamplerState, Operand::OPS_IN); curFuncInvocation->pushOperand(samplerWrapperParam, Operand::OPS_OUT); function->addAtomInstance(curFuncInvocation); }
false
false
false
false
false
0
alias_lookup_cb(const char *k, const char *v, void *cb) { if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_key)) { if (!v) return config_error_nonbool(k); alias_val = xstrdup(v); return 0; } return 0; }
false
false
false
false
false
0
gnl_object_to_media_time (GnlObject * object, GstClockTime otime, GstClockTime * mtime) { g_return_val_if_fail (mtime, FALSE); GST_DEBUG_OBJECT (object, "ObjectTime : %" GST_TIME_FORMAT, GST_TIME_ARGS (otime)); GST_DEBUG_OBJECT (object, "Start/Stop:[%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT "] " "Media [%" GST_TIME_FORMAT " -- %" GST_TIME_FORMAT "]", GST_TIME_ARGS (object->start), GST_TIME_ARGS (object->stop), GST_TIME_ARGS (object->media_start), GST_TIME_ARGS (object->media_stop)); /* limit check */ if (G_UNLIKELY ((otime < object->start))) { GST_DEBUG_OBJECT (object, "ObjectTime is before start"); *mtime = (object->media_start == GST_CLOCK_TIME_NONE) ? 0 : object->media_start; return FALSE; } if (G_UNLIKELY ((otime >= object->stop))) { GST_DEBUG_OBJECT (object, "ObjectTime is after stop"); if (G_LIKELY (GST_CLOCK_TIME_IS_VALID (object->media_stop))) *mtime = object->media_stop; else if (GST_CLOCK_TIME_IS_VALID (object->media_start)) *mtime = object->media_start + object->duration; else *mtime = object->stop - object->start; return FALSE; } if (G_UNLIKELY (object->media_start == GST_CLOCK_TIME_NONE)) { /* no time shifting, for live sources ? */ *mtime = otime - object->start; } else if (G_LIKELY (object->rate_1)) { *mtime = otime - object->start + object->media_start; } else { *mtime = (otime - object->start) * object->rate + object->media_start; } GST_DEBUG_OBJECT (object, "Returning MediaTime : %" GST_TIME_FORMAT, GST_TIME_ARGS (*mtime)); return TRUE; }
false
false
false
false
false
0
JPEG_ProcessData(GF_MediaDecoder *ifcg, char *inBuffer, u32 inBufferLength, u16 ES_ID, char *outBuffer, u32 *outBufferLength, u8 PaddingBits, u32 mmlevel) { #ifndef GPAC_DISABLE_AV_PARSERS GF_Err e; JPEGCTX(); e = gf_img_jpeg_dec(inBuffer, inBufferLength, &ctx->width, &ctx->height, &ctx->pixel_format, outBuffer, outBufferLength, ctx->BPP); switch (ctx->pixel_format) { case GF_PIXEL_GREYSCALE: ctx->BPP = 1; break; case GF_PIXEL_RGB_24: ctx->BPP = 3; break; } ctx->out_size = *outBufferLength; return e; #else return GF_NOT_SUPPORTED; #endif //GPAC_DISABLE_AV_PARSERS }
false
false
false
false
false
0
powerclamp_adjust_controls(unsigned int target_ratio, unsigned int guard, unsigned int win) { static u64 msr_last, tsc_last; u64 msr_now, tsc_now; u64 val64; /* check result for the last window */ msr_now = pkg_state_counter(); tsc_now = rdtsc(); /* calculate pkg cstate vs tsc ratio */ if (!msr_last || !tsc_last) current_ratio = 1; else if (tsc_now-tsc_last) { val64 = 100*(msr_now-msr_last); do_div(val64, (tsc_now-tsc_last)); current_ratio = val64; } /* update record */ msr_last = msr_now; tsc_last = tsc_now; adjust_compensation(target_ratio, win); /* * too many external interrupts, set flag such * that we can take measure later. */ reduce_irq = atomic_read(&idle_wakeup_counter) >= 2 * win * num_online_cpus(); atomic_set(&idle_wakeup_counter, 0); /* if we are above target+guard, skip */ return set_target_ratio + guard <= current_ratio; }
false
false
false
false
false
0
stdIn() const { File* f = new File( GetContext() ); if( !f->Open( stdin, QFile::ReadOnly ) ) return QVariant(); return GetContext()->AddObjToJSContext( f ); }
false
false
false
false
false
0
start_listener(slistener * l) { if (network_listen(l->nlistener)) { oklog("LISTEN: #%d now listening on %s\n", l->oid, l->name); return 1; } else { errlog("LISTEN: Can't start #%d listening on %s!\n", l->oid, l->name); return 0; } }
false
false
false
false
false
0
multi_team_set_captain(net_player *pl,int set) { // only the host should ever get here! Assert(Net_player->flags & NETINFO_FLAG_AM_MASTER); // set the player flags as being a captain and notify everyone else of this if(set){ nprintf(("Network","MULTI TEAM : Server setting player %s team %d captain\n",pl->m_player->callsign,pl->p_info.team)); pl->flags |= NETINFO_FLAG_TEAM_CAPTAIN; } else { nprintf(("Network","MULTI TEAM : Server unsetting player %s as team %d captain\n",pl->m_player->callsign,pl->p_info.team)); pl->flags &= ~(NETINFO_FLAG_TEAM_CAPTAIN); } }
false
false
false
false
false
0
GPS_Util_Put_Short(UC* s, const US v) { UC* p; p = (UC*)&v; if (!GPS_Little) { *s++ = *(p+1); *s = *p; } else { *s++ = *p; *s = *(p+1); } return; }
false
false
false
false
false
0
load_pixbuf(IconInfo *ico, const gchar *name) { const gchar *fname; IconGfx *ig; ig = g_malloc(sizeof *ig); g_strlcpy(ig->name, name, sizeof ig->name); if(strcmp(name, ICON_NONE) == 0) /* Is it the special, reserved, blank icon? */ { ig->pixbuf = ico->empty; return ig; } if((fname = fut_locate(ico->path, name)) != NULL) { if((ig->pixbuf = gdk_pixbuf_new_from_file(fname, NULL)) != NULL) return ig; } return NULL; }
false
false
false
false
false
0
init_uni_dc_tab(void) { int level, uni_code, uni_len; for(level=-256; level<256; level++){ int size, v, l; /* find number of bits */ size = 0; v = abs(level); while (v) { v >>= 1; size++; } if (level < 0) l= (-level) ^ ((1 << size) - 1); else l= level; /* luminance */ uni_code= DCtab_lum[size][0]; uni_len = DCtab_lum[size][1]; if (size > 0) { uni_code<<=size; uni_code|=l; uni_len+=size; if (size > 8){ uni_code<<=1; uni_code|=1; uni_len++; } } uni_DCtab_lum_bits[level+256]= uni_code; uni_DCtab_lum_len [level+256]= uni_len; /* chrominance */ uni_code= DCtab_chrom[size][0]; uni_len = DCtab_chrom[size][1]; if (size > 0) { uni_code<<=size; uni_code|=l; uni_len+=size; if (size > 8){ uni_code<<=1; uni_code|=1; uni_len++; } } uni_DCtab_chrom_bits[level+256]= uni_code; uni_DCtab_chrom_len [level+256]= uni_len; } }
false
false
false
false
false
0
_add_acl_pattern(struct mosquitto_db *db, const char *topic, int access) { struct _mosquitto_acl *acl, *acl_tail; char *local_topic; if(!db || !topic) return MOSQ_ERR_INVAL; local_topic = _mosquitto_strdup(topic); if(!local_topic){ return MOSQ_ERR_NOMEM; } acl = _mosquitto_malloc(sizeof(struct _mosquitto_acl)); if(!acl) return MOSQ_ERR_NOMEM; acl->access = access; acl->topic = local_topic; acl->next = NULL; if(db->acl_patterns){ acl_tail = db->acl_patterns; while(acl_tail->next){ acl_tail = acl_tail->next; } acl_tail->next = acl; }else{ db->acl_patterns = acl; } return MOSQ_ERR_SUCCESS; }
false
false
false
false
false
0
makePolyline(graph_t* g, edge_t * e) { Ppolyline_t spl, line = ED_path(e); Ppoint_t p0, q0; p0 = line.ps[0]; q0 = line.ps[line.pn - 1]; make_polyline (line, &spl); if (Verbose > 1) fprintf(stderr, "polyline %s %s\n", agnameof(agtail(e)), agnameof(aghead(e))); clip_and_install(e, aghead(e), spl.ps, spl.pn, &sinfo); addEdgeLabels(g, e, p0, q0); }
false
false
false
false
false
0
update_option(const char *this, char *val, int flags) { struct opt_list *po; SLIST_FOREACH(po, &otab, o_next) { if (eq(po->o_name, this)) { free(po->o_file); po->o_file = val; po->o_flags = flags; return; } } /* * Option not found, but that's OK, we just ignore it since it * may be for another arch. */ return; }
false
false
false
false
false
0
git_repository_is_empty(git_repository *repo) { git_reference *head = NULL; int is_empty = 0; if (git_reference_lookup(&head, repo, GIT_HEAD_FILE) < 0) return -1; if (git_reference_type(head) == GIT_REF_SYMBOLIC) is_empty = (strcmp(git_reference_symbolic_target(head), GIT_REFS_HEADS_DIR "master") == 0) && repo_contains_no_reference(repo); git_reference_free(head); return is_empty; }
false
false
false
false
false
0
in_conditional (NODE_T *p) { for (; p != NO_NODE; FORWARD (p)) { if (IS (p, IF_PART) || IS (p, ELIF_IF_PART)) { NODE_T *what = NO_NODE; int pop_ind = ind; put_sym (SUB (p), KEYWORD); BLANK; ind = col; in_serial (NEXT_SUB (p), !ONE_LINER, &what); ind = pop_ind; put_nl (); } else if (IS (p, THEN_PART)) { NODE_T *what = NO_NODE; int pop_ind = ind; put_sym (SUB (p), KEYWORD); BLANK; ind = col; in_serial (NEXT_SUB (p), !ONE_LINER, &what); ind = pop_ind; put_nl (); } else if (IS (p, ELSE_PART)) { NODE_T *what = NO_NODE; int pop_ind = ind; put_sym (SUB (p), KEYWORD); BLANK; ind = col; in_serial (NEXT_SUB (p), !ONE_LINER, &what); ind = pop_ind; put_nl (); } else if (IS (p, ELIF_PART)) { in_conditional (SUB (p)); } else if (IS (p, FI_SYMBOL)) { put_sym (p, KEYWORD); } else if (IS (p, OPEN_PART)) { NODE_T *what = NO_NODE; put_sym (SUB (p), KEYWORD); in_serial (NEXT_SUB (p), ONE_LINER, &what); } else if (IS (p, ELSE_OPEN_PART)) { NODE_T *what = NO_NODE; BLANK; put_sym (SUB (p), KEYWORD); BLANK; in_serial (NEXT_SUB (p), ONE_LINER, &what); } else if (IS (p, CHOICE)) { NODE_T *what = NO_NODE; BLANK; put_sym (SUB (p), KEYWORD); BLANK; in_serial (NEXT_SUB (p), ONE_LINER, &what); } else if (IS (p, BRIEF_ELIF_PART)) { in_conditional (SUB (p)); } else if (IS_CLOSE_SYMBOL (p)) { put_sym (p, KEYWORD); } } }
false
false
false
false
false
0
get_probe(const char* description) { int i; for (i = 0; i < ARRAY_SIZE(builtins); i++) { if (!strcmp(builtins[i].description, description)) { return builtins[i].probe; } } /* Special case of "regex" probe (we don't want to set it in builtins * because builtins is also used to build the command-line options and * regexp is not legal on the command line)*/ if (!strcmp(description, "regex")) return regex_probe; return NULL; }
false
false
false
false
false
0
script_add_library(void* closurev, const char* name, size_t length) { Parser_closure* closure = static_cast<Parser_closure*>(closurev); std::string name_string(name, length); if (name_string[0] != 'l') gold_error(_("library name must be prefixed with -l")); Input_file_argument file(name_string.c_str() + 1, Input_file_argument::INPUT_FILE_TYPE_LIBRARY, "", false, closure->position_dependent_options()); Input_argument& arg = closure->inputs()->add_file(file); arg.set_script_info(closure->script_info()); }
false
false
false
false
false
0
get_pci_device_id(drm_intel_bufmgr_gem *bufmgr_gem) { char *devid_override; int devid; int ret; drm_i915_getparam_t gp; if (geteuid() == getuid()) { devid_override = getenv("INTEL_DEVID_OVERRIDE"); if (devid_override) { bufmgr_gem->no_exec = true; return strtod(devid_override, NULL); } } VG_CLEAR(devid); VG_CLEAR(gp); gp.param = I915_PARAM_CHIPSET_ID; gp.value = &devid; ret = drmIoctl(bufmgr_gem->fd, DRM_IOCTL_I915_GETPARAM, &gp); if (ret) { fprintf(stderr, "get chip id failed: %d [%d]\n", ret, errno); fprintf(stderr, "param: %d, val: %d\n", gp.param, *gp.value); } return devid; }
false
false
false
false
true
1
get_col(const MAT *mat, unsigned int col, VEC *vec) #endif { unsigned int i; if ( mat==(MAT *)NULL ) error(E_NULL,"get_col"); if ( col >= mat->n ) error(E_RANGE,"get_col"); if ( vec==(VEC *)NULL || vec->dim<mat->m ) vec = v_resize(vec,mat->m); for ( i=0; i<mat->m; i++ ) vec->ve[i] = mat->me[i][col]; return (vec); }
false
false
false
true
false
1
cib_notify_send(xmlNode * xml) { struct iovec *iov; struct cib_notification_s update; ssize_t rc = crm_ipc_prepare(0, xml, &iov); crm_trace("Notifying clients"); if (rc > 0) { update.msg = xml; update.iov = iov; g_hash_table_foreach_remove(client_connections, cib_notify_send_one, &update); } else { crm_notice("Notification failed: %s (%d)", pcmk_strerror(rc), rc); } if (iov) { free(iov[0].iov_base); free(iov[1].iov_base); free(iov); } crm_trace("Notify complete"); }
false
false
false
false
false
0
say_last_char(struct vc_data *vc) { int len = get_line(vc); u_char ch; spk_parked |= 0x01; if (len == 0) { synth_printf("%s\n", spk_msg_get(MSG_BLANK)); return; } ch = buf[--len]; spk_pos -= (spk_x - len) * 2; spk_x = len; synth_printf("%d, ", ++len); speak_char(ch); }
false
false
false
false
false
0
gt_BWTSeqCRLoad(const BWTSeq *bwtSeq, const char *projectName, short mapIntervalLog2) { unsigned long seqLen; unsigned short bitsPerUlong; BWTSeqContextRetriever *gt_newBWTSeqCR; gt_assert(bwtSeq && projectName); seqLen = BWTSeqLength(bwtSeq); bitsPerUlong = requiredUlongBits(seqLen - 1); gt_newBWTSeqCR = gt_malloc(sizeof (*gt_newBWTSeqCR)); gt_newBWTSeqCR->bitsPerUlong = bitsPerUlong; gt_newBWTSeqCR->bwtSeq = bwtSeq; if (mapIntervalLog2 != CTX_MAP_ILOG_AUTOSIZE) { if (!BWTSeqCRMapOpen(mapIntervalLog2, bitsPerUlong, seqLen, projectName, false, gt_newBWTSeqCR)) { gt_free(gt_newBWTSeqCR); return NULL; } } else { short mapIntervalLog2Max = bitsPerUlong; mapIntervalLog2 = 0; while (!BWTSeqCRMapOpen(mapIntervalLog2, bitsPerUlong, seqLen, projectName, false, gt_newBWTSeqCR) && mapIntervalLog2 < mapIntervalLog2Max) ++mapIntervalLog2; if (!gt_newBWTSeqCR->revMap) { gt_free(gt_newBWTSeqCR); return NULL; } } gt_newBWTSeqCR->mapIntervalLog2 = mapIntervalLog2; gt_newBWTSeqCR->mapInterval = 1 << mapIntervalLog2; gt_newBWTSeqCR->mapMask = gt_newBWTSeqCR->mapInterval - 1; return gt_newBWTSeqCR; }
false
false
false
false
false
0
notifyImageInfo(int _width, int _height) { if (!ImageManager::isAcceptableSize(_width, _height)) { kWarning() << "ImageLoader somehow fed us an illegal size, killing it!"; loadError(); return; } width = _width; height = _height; owner->imageHasGeometry(this, width, height); }
false
false
false
false
false
0
vnic_wq_get_ctrl(struct vnic_dev *vdev, struct vnic_wq *wq, unsigned int index, enum vnic_res_type res_type) { wq->ctrl = svnic_dev_get_res(vdev, res_type, index); if (!wq->ctrl) return -EINVAL; return 0; }
false
false
false
false
false
0
string_sum(register unsigned char *aar, unsigned int dim) {register unsigned char *endar; register unsigned int count = 0; endar=aar+dim; for ( ; aar< endar; aar++) count += *aar; return count; }
false
false
false
false
false
0
read_name_map (pfile, dirname) cpp_reader *pfile; const char *dirname; { struct file_name_map_list *map_list_ptr; char *name; FILE *f; /* Check the cache of directories, and mappings in their remap file. */ for (map_list_ptr = CPP_OPTION (pfile, map_list); map_list_ptr; map_list_ptr = map_list_ptr->map_list_next) if (! strcmp (map_list_ptr->map_list_name, dirname)) return map_list_ptr->map_list_map; map_list_ptr = ((struct file_name_map_list *) xmalloc (sizeof (struct file_name_map_list))); map_list_ptr->map_list_name = xstrdup (dirname); /* The end of the list ends in NULL. */ map_list_ptr->map_list_map = NULL; name = (char *) alloca (strlen (dirname) + strlen (FILE_NAME_MAP_FILE) + 2); strcpy (name, dirname); if (*dirname) strcat (name, "/"); strcat (name, FILE_NAME_MAP_FILE); f = fopen (name, "r"); /* Silently return NULL if we cannot open. */ if (f) { int ch; while ((ch = getc (f)) != EOF) { char *from, *to; struct file_name_map *ptr; if (is_space (ch)) continue; from = read_filename_string (ch, f); while ((ch = getc (f)) != EOF && is_hspace (ch)) ; to = read_filename_string (ch, f); ptr = ((struct file_name_map *) xmalloc (sizeof (struct file_name_map))); ptr->map_from = from; /* Make the real filename absolute. */ if (IS_ABSOLUTE_PATHNAME (to)) ptr->map_to = to; else { ptr->map_to = concat (dirname, "/", to, NULL); free (to); } ptr->map_next = map_list_ptr->map_list_map; map_list_ptr->map_list_map = ptr; while ((ch = getc (f)) != '\n') if (ch == EOF) break; } fclose (f); } /* Add this information to the cache. */ map_list_ptr->map_list_next = CPP_OPTION (pfile, map_list); CPP_OPTION (pfile, map_list) = map_list_ptr; return map_list_ptr->map_list_map; }
false
false
false
false
false
0
_e_fm_op_idler_handle_error(int *mark, Eina_List **queue, Eina_List **node, E_Fm_Op_Task *task) { if (_e_fm_op_overwrite) { if (_e_fm_op_overwrite_response != E_FM_OP_NONE) { task->overwrite = _e_fm_op_overwrite_response; _e_fm_op_work_error = 0; _e_fm_op_scan_error = 0; } else { /* No response yet. */ /* So, delete this idler. It'll be added back when response is there. */ _e_fm_op_delete_idler(mark); return 1; } } else if (*mark) { if (_e_fm_op_error_response == E_FM_OP_NONE) { /* No response yet. */ /* So, delete this idler. It'll be added back when response is there. */ _e_fm_op_delete_idler(mark); return 1; } else { E_FM_OP_DEBUG("Got response.\n"); /* Got response. */ if (_e_fm_op_error_response == E_FM_OP_ERROR_RESPONSE_ABORT) { /* Mark as abort. */ _e_fm_op_abort = 1; _e_fm_op_error_response = E_FM_OP_NONE; _e_fm_op_rollback(task); } else if (_e_fm_op_error_response == E_FM_OP_ERROR_RESPONSE_RETRY) { *mark = 0; _e_fm_op_error_response = E_FM_OP_NONE; } else if (_e_fm_op_error_response == E_FM_OP_ERROR_RESPONSE_IGNORE_THIS) { _e_fm_op_rollback(task); _e_fm_op_remove_link_task(task); *queue = eina_list_remove_list(*queue, *node); _e_fm_op_error_response = E_FM_OP_NONE; *mark = 0; *node = NULL; return 1; } else if (_e_fm_op_error_response == E_FM_OP_ERROR_RESPONSE_IGNORE_ALL) { E_FM_OP_DEBUG("E_Fm_Op_Task '%s' --> '%s' was automatically aborted.\n", task->src.name, task->dst.name); _e_fm_op_rollback(task); _e_fm_op_remove_link_task(task); *queue = eina_list_remove_list(*queue, *node); *node = NULL; *mark = 0; /* Do not clean out _e_fm_op_error_response. This way when another error * occures, it would be handled automatically. */ return 1; } } } else if ((_e_fm_op_work_error) || (_e_fm_op_scan_error)) return 1; return 0; }
false
false
false
false
false
0
pluto_dma_end(struct pluto *pluto, unsigned int nbpackets) { /* synchronize the DMA transfer with the CPU * first so that we see updated contents. */ pci_dma_sync_single_for_cpu(pluto->pdev, pluto->dma_addr, TS_DMA_BYTES, PCI_DMA_FROMDEVICE); /* Workaround for broken hardware: * [1] On startup NBPACKETS seems to contain an uninitialized value, * but no packets have been transferred. * [2] Sometimes (actually very often) NBPACKETS stays at zero * although one packet has been transferred. * [3] Sometimes (actually rarely), the card gets into an erroneous * mode where it continuously generates interrupts, claiming it * has received nbpackets>TS_DMA_PACKETS packets, but no packet * has been transferred. Only a reset seems to solve this */ if ((nbpackets == 0) || (nbpackets > TS_DMA_PACKETS)) { unsigned int i = 0; while (pluto->dma_buf[i] == 0x47) i += 188; nbpackets = i / 188; if (i == 0) { pluto_reset_ts(pluto, 1); dev_printk(KERN_DEBUG, &pluto->pdev->dev, "resetting TS because of invalid packet counter\n"); } } dvb_dmx_swfilter_packets(&pluto->demux, pluto->dma_buf, nbpackets); /* clear the dma buffer. this is needed to be able to identify * new valid ts packets above */ memset(pluto->dma_buf, 0, nbpackets * 188); /* reset the dma address */ pluto_set_dma_addr(pluto); /* sync the buffer and give it back to the card */ pci_dma_sync_single_for_device(pluto->pdev, pluto->dma_addr, TS_DMA_BYTES, PCI_DMA_FROMDEVICE); }
false
false
false
false
false
0
tree_book_name(struct board *b) { static char buf[256]; if (b->handicap > 0) { sprintf(buf, "ucttbook-%d-%02.01f-h%d.pachitree", b->size - 2, b->komi, b->handicap); } else { sprintf(buf, "ucttbook-%d-%02.01f.pachitree", b->size - 2, b->komi); } return buf; }
false
false
false
false
false
0
cpl_matrix_fill(cpl_matrix *matrix, double value) { cpl_size size; double *m; if (matrix == NULL) return cpl_error_set_(CPL_ERROR_NULL_INPUT); size = matrix->nr * matrix->nc; m = matrix->m; while (size--) *m++ = value; return CPL_ERROR_NONE; }
false
false
false
false
false
0
PortUnRegister(jack_port_id_t port_index) { CheckClient("PortUnRegister"); int res = fClient->PortUnRegister(port_index); fOpenPortNumber--; int i; for (i = (fTotalPortNumber - 1); i >= 0; i--) { // We search the record into the history if (fPortList[i].idport == port_index) { // We found the last record if (fPortList[i].IsUnregistered != 0) *fStream << "!!! ERROR !!! : '" << fClientName << "' id deregistering port '" << fPortList[i].name << "' that have already been unregistered !" << endl; fPortList[i].IsUnregistered++; break; } } if (i == 0) // Port is not found *fStream << "JackClientDebug : PortUnregister : port " << port_index << " was not previously registered !" << endl; if (res != 0) *fStream << "Client '" << fClientName << "' try to do PortUnregister and server return " << res << endl; *fStream << "Client '" << fClientName << "' unregister port '" << port_index << "'." << endl; return res; }
false
false
false
false
false
0
script_parse_url(char *url, struct http_parser_url *parts) { if (!http_parser_parse_url(url, strlen(url), 0, parts)) { if (!(parts->field_set & (1 << UF_SCHEMA))) return 0; if (!(parts->field_set & (1 << UF_HOST))) return 0; return 1; } return 0; }
false
false
false
false
false
0
esas2r_unmap_regions(struct esas2r_adapter *a) { if (a->regs) iounmap((void __iomem *)a->regs); a->regs = NULL; pci_release_region(a->pcid, 2); if (a->data_window) iounmap((void __iomem *)a->data_window); a->data_window = NULL; pci_release_region(a->pcid, 0); }
false
false
false
false
false
0
decode(const UINT8*in, UINT32 inlen, UINT8*out, UINT32*outlen) { if(outlen==NULL) return E_UNKNOWN; if(in==NULL||inlen==0) { *outlen=0; return E_SUCCESS; } EVP_ENCODE_CTX oCTX; EVP_DecodeInit(&oCTX); int len=0; *outlen=0; //ensure that in and out are disjunct - otherwise copy in if(((out>=in)&&(in+inlen>out))||((out<in)&&(out+*outlen>in))) { UINT8*tmpIn=new UINT8[inlen]; memcpy(tmpIn, in, inlen); EVP_DecodeUpdate(&oCTX, out, (int*) outlen, tmpIn, (int)inlen); delete[] tmpIn; tmpIn = NULL; } else { EVP_DecodeUpdate(&oCTX, out, (int*) outlen, (unsigned char*) in, (int)inlen); } EVP_DecodeFinal(&oCTX, out+(*outlen), &len); (*outlen)+=len; return E_SUCCESS; }
false
false
false
false
false
0
getg(double w, double *g[2], int size) { long i, j, totsize, n, g_row; float rsq, sigma, two_ssq, val, sum = 0.0; totsize = size * size; n = size / 2; for (i = 0; i < totsize; i++) { *(g[0] + i) = 0.0; *(g[1] + i) = 0.0; } sigma = w / (2.0 * sqrt((double)2.0)); two_ssq = 2.0 * sigma * sigma; for (i = 0; i < n; i++) { g_row = i * size; /* start of row */ for (j = 0; j < n; j++) { rsq = i * i + j * j; val = (rsq / two_ssq - 1) * exp(-rsq / two_ssq); *(g[0] + g_row + j) = val; sum += val; /* reflect into other quadrants */ if (j > 0) { *(g[0] + g_row + (size - j)) = val; sum += val; } if (i > 0) { *(g[0] + (size - i) * size + j) = val; sum += val; } if (i > 0 && j > 0) { *(g[0] + (size - i) * size + (size - j)) = val; sum += val; } } } *(g[0] + 0) -= sum; /* make sure sum of all values is zero */ return 0; }
false
false
false
false
false
0
ves_icall_System_Net_Sockets_Socket_Send_array_internal(SOCKET sock, MonoArray *buffers, gint32 flags, gint32 *error) { int ret, count; DWORD sent; WSABUF *wsabufs; DWORD sendflags = 0; gboolean interrupted; *error = 0; wsabufs = mono_array_addr (buffers, WSABUF, 0); count = mono_array_length (buffers); sendflags = convert_socketflags (flags); if (sendflags == -1) { *error = WSAEOPNOTSUPP; return(0); } mono_thread_info_install_interrupt (abort_syscall, (gpointer) (gsize) mono_native_thread_id_get (), &interrupted); if (interrupted) { *error = WSAEINTR; return 0; } MONO_PREPARE_BLOCKING; ret = WSASend (sock, wsabufs, count, &sent, sendflags, NULL, NULL); MONO_FINISH_BLOCKING; mono_thread_info_uninstall_interrupt (&interrupted); if (interrupted) { *error = WSAEINTR; return 0; } if (ret == SOCKET_ERROR) { *error = WSAGetLastError (); return(0); } return(sent); }
false
false
false
false
false
0