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
get_signals(SLMP_INFO *info) { u16 status = read_reg(info, SR3); u16 gpstatus = read_status_reg(info); u16 testbit; /* clear all serial signals except RTS and DTR */ info->serial_signals &= SerialSignal_RTS | SerialSignal_DTR; /* set serial signal bits to reflect MISR */ if (!(status & BIT3)) info->serial_signals |= SerialSignal_CTS; if ( !(status & BIT2)) info->serial_signals |= SerialSignal_DCD; testbit = BIT1 << (info->port_num * 2); // Port 0..3 RI is GPDATA<1,3,5,7> if (!(gpstatus & testbit)) info->serial_signals |= SerialSignal_RI; testbit = BIT0 << (info->port_num * 2); // Port 0..3 DSR is GPDATA<0,2,4,6> if (!(gpstatus & testbit)) info->serial_signals |= SerialSignal_DSR; }
false
false
false
false
false
0
_map_size( char *buf ) { long b_size; char *end_ptr; b_size = strtol(buf, &end_ptr, 10); if ((b_size == LONG_MIN) || (b_size == LONG_MAX) || (b_size < 0)) { fprintf(stderr, "size specification is invalid, ignored\n"); b_size = 0; } else if (end_ptr[0] == '\0') ; else if ((end_ptr[0] == 'k') || (end_ptr[0] == 'K')) b_size *= 1024; else if ((end_ptr[0] == 'm') || (end_ptr[0] == 'M')) b_size *= (1024 * 1024); else { fprintf(stderr, "size specification is invalid, ignored\n"); b_size = 0; } return (uint32_t) b_size; }
false
false
false
false
false
0
tableInsert(table_t *table, const char *key, int value) { const int v = tableFind(table, key); if(v > 0) /* duplicate key */ return (v == value) ? value : -1; /* allow real dups */ assert(value != -1); /* that would confuse us */ if(table->tableHead == NULL) table->tableLast = table->tableHead = (tableEntry *)cli_malloc(sizeof(tableEntry)); else { /* * Re-use deleted items */ if(table->flags&TABLE_HAS_DELETED_ENTRIES) { tableEntry *tableItem; assert(table->tableHead != NULL); for(tableItem = table->tableHead; tableItem; tableItem = tableItem->next) if(tableItem->key == NULL) { /* This item has been deleted */ tableItem->key = cli_strdup(key); tableItem->value = value; return value; } table->flags &= ~TABLE_HAS_DELETED_ENTRIES; } table->tableLast = table->tableLast->next = (tableEntry *)cli_malloc(sizeof(tableEntry)); } if(table->tableLast == NULL) { cli_dbgmsg("tableInsert: Unable to allocate memory for table\n"); return -1; } table->tableLast->next = NULL; table->tableLast->key = cli_strdup(key); table->tableLast->value = value; return value; }
false
false
false
false
false
0
posix_confstr(PyObject *self, PyObject *args) { PyObject *result = NULL; int name; char buffer[255]; int len; if (!PyArg_ParseTuple(args, "O&:confstr", conv_confstr_confname, &name)) return NULL; errno = 0; len = confstr(name, buffer, sizeof(buffer)); if (len == 0) { if (errno) { posix_error(); return NULL; } else { Py_RETURN_NONE; } } if ((unsigned int)len >= sizeof(buffer)) { char *buf = PyMem_Malloc(len); if (buf == NULL) return PyErr_NoMemory(); confstr(name, buf, len); result = PyUnicode_DecodeFSDefaultAndSize(buf, len-1); PyMem_Free(buf); } else result = PyUnicode_DecodeFSDefaultAndSize(buffer, len-1); return result; }
false
false
false
false
false
0
set_line_numbers(ScintillaObject * sci, gboolean set) { if (set) { gchar tmp_str[15]; gint len = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0); gint width; g_snprintf(tmp_str, 15, "_%d", len); width = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, (sptr_t) tmp_str); scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, width); scintilla_send_message(sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */ } else { scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, 0); } }
false
false
false
false
false
0
gplotAddPlot(GPLOT *gplot, NUMA *nax, NUMA *nay, l_int32 plotstyle, const char *plottitle) { char buf[L_BUF_SIZE]; char emptystring[] = ""; char *datastr, *title; l_int32 n, i; l_float32 valx, valy, startx, delx; SARRAY *sa; PROCNAME("gplotAddPlot"); if (!gplot) return ERROR_INT("gplot not defined", procName, 1); if (!nay) return ERROR_INT("nay not defined", procName, 1); if (plotstyle != GPLOT_LINES && plotstyle != GPLOT_POINTS && plotstyle != GPLOT_IMPULSES && plotstyle != GPLOT_LINESPOINTS && plotstyle != GPLOT_DOTS) return ERROR_INT("invalid plotstyle", procName, 1); n = numaGetCount(nay); numaGetXParameters(nay, &startx, &delx); if (nax) { if (n != numaGetCount(nax)) return ERROR_INT("nax and nay sizes differ", procName, 1); } /* Save plotstyle and plottitle */ numaAddNumber(gplot->plotstyles, plotstyle); if (plottitle) { title = stringNew(plottitle); sarrayAddString(gplot->plottitles, title, L_INSERT); } else sarrayAddString(gplot->plottitles, emptystring, L_COPY); /* Generate and save data filename */ gplot->nplots++; snprintf(buf, L_BUF_SIZE, "%s.data.%d", gplot->rootname, gplot->nplots); sarrayAddString(gplot->datanames, buf, L_COPY); /* Generate data and save as a string */ sa = sarrayCreate(n); for (i = 0; i < n; i++) { if (nax) numaGetFValue(nax, i, &valx); else valx = startx + i * delx; numaGetFValue(nay, i, &valy); snprintf(buf, L_BUF_SIZE, "%f %f\n", valx, valy); sarrayAddString(sa, buf, L_COPY); } datastr = sarrayToString(sa, 0); sarrayAddString(gplot->plotdata, datastr, L_INSERT); sarrayDestroy(&sa); return 0; }
true
true
false
false
false
1
ms_uid(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { struct Client *target_p; time_t newts = 0; newts = atol(parv[3]); if(parc != 10) { sendto_realops_flags(UMODE_ALL, L_ALL, "Dropping server %s due to (invalid) command 'UID' " "with %d arguments (expecting 10)", client_p->name, parc); ilog(L_SERVER, "Excess parameters (%d) for command 'UID' from %s.", parc, client_p->name); exit_client(client_p, client_p, client_p, "Excess parameters to UID command"); return 0; } /* if nicks erroneous, or too long, kill */ if(!clean_nick(parv[1], 0)) { ServerStats.is_kill++; sendto_realops_flags(UMODE_DEBUG, L_ALL, "Bad Nick: %s From: %s(via %s)", parv[1], source_p->name, client_p->name); sendto_one(client_p, ":%s KILL %s :%s (Bad Nickname)", me.id, parv[8], me.name); return 0; } if(!clean_username(parv[5]) || !clean_host(parv[6])) { ServerStats.is_kill++; sendto_realops_flags(UMODE_DEBUG, L_ALL, "Bad user@host: %s@%s From: %s(via %s)", parv[5], parv[6], source_p->name, client_p->name); sendto_one(client_p, ":%s KILL %s :%s (Bad user@host)", me.id, parv[8], me.name); return 0; } if(!clean_uid(parv[8])) { ServerStats.is_kill++; sendto_realops_flags(UMODE_DEBUG, L_ALL, "Bad UID: %s From: %s(via %s)", parv[8], source_p->name, client_p->name); sendto_one(client_p, ":%s KILL %s :%s (Bad UID)", me.id, parv[8], me.name); return 0; } /* check length of clients gecos */ if(strlen(parv[9]) > REALLEN) { parv[9] = LOCAL_COPY_N(parv[9], REALLEN); } target_p = find_client(parv[1]); if(target_p == NULL) { register_client(client_p, source_p, parv[1], newts, parc, parv); } else if(IsUnknown(target_p)) { exit_client(NULL, target_p, &me, "Overridden"); register_client(client_p, source_p, parv[1], newts, parc, parv); } /* we've got a collision! */ else perform_nick_collides(source_p, client_p, target_p, parc, parv, newts, parv[1], parv[8]); return 0; }
false
false
false
false
true
1
srtp_stream_init_from_ekt(srtp_stream_t stream, const void *srtcp_hdr, unsigned pkt_octet_len) { err_status_t err; const uint8_t *master_key; srtp_policy_t srtp_policy; uint32_t roc; /* * NOTE: at present, we only support a single ekt_policy at a time. */ if (stream->ekt->data->spi != srtcp_packet_get_ekt_spi(srtcp_hdr, pkt_octet_len)) return err_status_no_ctx; if (stream->ekt->data->ekt_cipher_type != EKT_CIPHER_AES_128_ECB) return err_status_bad_param; /* decrypt the Encrypted Master Key field */ master_key = srtcp_packet_get_emk_location(srtcp_hdr, pkt_octet_len); /* FIX!? This decrypts the master key in-place, and never uses it */ /* FIX!? It's also passing to ekt_dec_key (which is an aes_expanded_key_t) * to a function which expects a raw (unexpanded) key */ aes_decrypt_with_raw_key((void*)master_key, &stream->ekt->data->ekt_dec_key, 16); /* set the SRTP ROC */ roc = srtcp_packet_get_ekt_roc(srtcp_hdr, pkt_octet_len); err = rdbx_set_roc(&stream->rtp_rdbx, roc); if (err) return err; err = srtp_stream_init(stream, &srtp_policy); if (err) return err; return err_status_ok; }
false
false
false
false
false
0
print_bm(struct BM *bm) { int i, j; for (i = 0; i < bm->rows; i++) { for (j = 0; j < bm->cols; j++) { fprintf(stderr, "%d ", BM_get(bm, j, i)); } fprintf(stderr, "\n"); } return; }
false
false
false
false
false
0
config_setting_get_string(const config_setting_t *setting) { return((setting->type == CONFIG_TYPE_STRING) ? setting->value.sval : NULL); }
false
false
false
false
false
0
bl_alloc_init_bio(int npg, struct block_device *bdev, sector_t disk_sector, bio_end_io_t end_io, struct parallel_io *par) { struct bio *bio; npg = min(npg, BIO_MAX_PAGES); bio = bio_alloc(GFP_NOIO, npg); if (!bio && (current->flags & PF_MEMALLOC)) { while (!bio && (npg /= 2)) bio = bio_alloc(GFP_NOIO, npg); } if (bio) { bio->bi_iter.bi_sector = disk_sector; bio->bi_bdev = bdev; bio->bi_end_io = end_io; bio->bi_private = par; } return bio; }
false
false
false
false
false
0
stats_ziplinks (struct Client *source_p) { rb_dlink_node *ptr; struct Client *target_p; struct ZipStats *zipstats; int sent_data = 0; char buf[128], buf1[128]; RB_DLINK_FOREACH (ptr, serv_list.head) { target_p = ptr->data; if(IsCapable (target_p, CAP_ZIP)) { zipstats = target_p->localClient->zipstats; sprintf(buf, "%.2f%%", zipstats->out_ratio); sprintf(buf1, "%.2f%%", zipstats->in_ratio); sendto_one_numeric(source_p, RPL_STATSDEBUG, "Z :ZipLinks stats for %s send[%s compression " "(%llu kB data/%llu kB wire)] recv[%s compression " "(%llu kB data/%llu kB wire)]", target_p->name, buf, zipstats->out >> 10, zipstats->out_wire >> 10, buf1, zipstats->in >> 10, zipstats->in_wire >> 10); sent_data++; } } sendto_one_numeric(source_p, RPL_STATSDEBUG, "Z :%u ziplink(s)", sent_data); }
true
true
false
false
false
1
is_closed(int *closed) const { uint32 n_points; double x1, y1, x2, y2; const char *data= m_data; if (no_data(data, 4)) return 1; n_points= uint4korr(data); if (n_points == 1) { *closed=1; return 0; } data+= 4; if (n_points == 0 || not_enough_points(data, n_points)) return 1; /* Get first point */ get_point(&x1, &y1, data); /* get last point */ data+= SIZEOF_STORED_DOUBLE*2 + (n_points-2)*POINT_DATA_SIZE; get_point(&x2, &y2, data); *closed= (x1==x2) && (y1==y2); return 0; }
false
false
false
false
false
0
cmd_store_env_value_and_pop2(struct lldpctl_conn_t *conn, struct writer *w, struct cmd_env *env, void *key) { return (cmdenv_put(env, key, cmdenv_arg(env)) != -1 && cmdenv_pop(env, 2) != -1); }
false
false
false
false
false
0
remove_arg (gint num, gint *argc, gchar **argv[]) { gint n; g_assert (num <= (*argc)); for (n = num; (*argv)[n] != NULL; n++) (*argv)[n] = (*argv)[n+1]; (*argv)[n] = NULL; (*argc) = (*argc) - 1; }
false
false
false
false
false
0
decode_line_short_2_of_2_to_float(void* source_array, EPR_SBandId* band_id, int offset_x, int raster_width, int step_x, void* raster_buffer, int raster_pos) { int x, x1, x2; short* sa = (short*) source_array; float* buf = (float*) raster_buffer; x1 = offset_x; x2 = x1 + raster_width - 1; if (band_id->scaling_method == e_smid_log) { for (x = x1; x <= x2; x += step_x) { buf[raster_pos++] = (float)pow(10, band_id->scaling_offset + band_id->scaling_factor * sa[2 * x + 1]); } } else if (band_id->scaling_method == e_smid_lin) { for (x = x1; x <= x2; x += step_x) { buf[raster_pos++] = band_id->scaling_offset + band_id->scaling_factor * sa[2 * x + 1]; } } else { for (x = x1; x <= x2; x += step_x) { buf[raster_pos++] = (float)(sa[2 * x + 1]); } } }
false
false
false
false
false
0
_dxfBoundaryCollapse2KndGeometricallyOk(SimpData *simp_data, int v0, int v1, /* this procedure must be run twice, once for the star of the vertex v0 and once for the star of the vertex v1 Here, v1 rather stands for the first vertex of the star */ int *star0, int *vstar0, int val0, Vertex *s_normal0, float *s_area0, int direction, float min_scalprod_nor, float compactness_ratio) { int collapsible = 1, i = 0; Vertex faceVert[3]; float *s_comp0 = s_area0 + val0, min_compactness_before, min_compactness_after; /* labeling system for directed triangle stars v*1\ /v*0 e*1\ *1/e*0 *val0-1 \ / *0 ___________\/___________ we omit on purpose the first vertex, because in the case v*val0-1 v0 v1 of a boundary edge, we know it already */ /* retrieve the compactness of the first triangle */ min_compactness_before = simp_data->compactness[star0[0]]; min_compactness_after = 1; /* initialization of the compactness after simplification */ while (collapsible && i < val0-1) { /* retrieve the face compactness before simplification */ min_compactness_before = MIN ( simp_data->compactness[star0[i+1]], min_compactness_before); /* recompute the compactness after changing the first vertex */ memcpy(faceVert[0], simp_data->simplified_vertex, sizeof (Vertex)); if (direction == DIRECTION_CLOCKWISE) { /* reverse the order of triangle vertices, so that the normal that we will compute will respect the surface orientation */ memcpy(faceVert[2], simp_data->vert[vstar0[i]], sizeof (Vertex)); memcpy(faceVert[1], simp_data->vert[vstar0[i+1]], sizeof (Vertex)); } else { memcpy(faceVert[1], simp_data->vert[vstar0[i]], sizeof (Vertex)); memcpy(faceVert[2], simp_data->vert[vstar0[i+1]], sizeof (Vertex)); } s_comp0[i+1] = _dxfFastCompactness3DTriangle2(faceVert, s_area0+i+1); min_compactness_after = MIN ( s_comp0[i+1], min_compactness_after); /* recompute the face normal assuming that the vertex v0 has moved and save this normal for future use*/ _dxfTriangleNormalQR2(faceVert, s_normal0[i+1]); /* check whether the triangle normal orientation is consistent */ collapsible = ((SCALPROD3(s_normal0[i+1], simp_data->normal[star0[i+1]])) > min_scalprod_nor); i++; } if (collapsible) /* check whether the minimum triangle compactness is too much degraded */ collapsible = min_compactness_after > (compactness_ratio * min_compactness_before); return collapsible; }
false
false
false
false
false
0
spif_str_dup(spif_str_t self) { spif_str_t tmp; ASSERT_RVAL(!SPIF_STR_ISNULL(self), SPIF_NULL_TYPE(str)); tmp = SPIF_ALLOC(str); memcpy(tmp, self, SPIF_SIZEOF_TYPE(str)); tmp->s = SPIF_CAST(charptr) STRDUP(SPIF_CONST_CAST_C(char *) SPIF_STR_STR(self)); tmp->len = self->len; tmp->size = self->size; return tmp; }
false
false
false
false
false
0
cfread_ushort(CFILE *file, int ver, ushort deflt) { ushort s; if (file->version < ver) return deflt; if (cfread( &s, sizeof(s), 1, file) != 1) return deflt; s = INTEL_SHORT(s); return s; }
false
false
false
false
false
0
LinkController(FCDController* controller) { bool ret = true; if (controller->GetBaseTarget() == NULL) { if (controller->IsSkin()) { ret &= FArchiveXML::LinkSkinController(controller->GetSkinController()); } else if (controller->IsMorph()) { ret &= FArchiveXML::LinkMorphController(controller->GetMorphController()); } else return false; // If our target is a controller, link it too. FCDEntity* entity = controller->GetBaseTarget(); if (entity != NULL && entity->GetType() == FCDEntity::CONTROLLER) { ret &= FArchiveXML::LinkController((FCDController*)entity); } } return ret; }
false
false
false
false
false
0
iwl_mvm_enter_d0i3_iterator(void *_data, u8 *mac, struct ieee80211_vif *vif) { struct iwl_d0i3_iter_data *data = _data; struct iwl_mvm *mvm = data->mvm; struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); u32 flags = CMD_ASYNC | CMD_HIGH_PRIO | CMD_SEND_IN_IDLE; IWL_DEBUG_RPM(mvm, "entering D0i3 - vif %pM\n", vif->addr); if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc) return; /* * in case of pending tx packets or active aggregations, * avoid offloading features in order to prevent reuse of * the same qos seq counters. */ if (iwl_mvm_disallow_offloading(mvm, vif, data)) data->disable_offloading = true; iwl_mvm_update_d0i3_power_mode(mvm, vif, true, flags); iwl_mvm_send_proto_offload(mvm, vif, data->disable_offloading, flags); /* * on init/association, mvm already configures POWER_TABLE_CMD * and REPLY_MCAST_FILTER_CMD, so currently don't * reconfigure them (we might want to use different * params later on, though). */ data->ap_sta_id = mvmvif->ap_sta_id; data->vif_count++; }
false
false
false
false
false
0
base64( const std::string& str ) { char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; int lng = str.length(); std::string out; out.reserve( lng * 2 ); std::string data = str + "\0\0\0\0"; for( int i = 0; i < lng; i += 3 ){ unsigned char* cstr = (unsigned char*)( data.c_str() + i ); unsigned char key[ 4 ]; key[ 0 ] = (*cstr) >> 2; key[ 1 ] = ( ( (*cstr) << 4 ) + ( (*(cstr+1)) >> 4 ) ); key[ 2 ] = ( ( (*(cstr+1)) << 2 ) + ( (*(cstr+2)) >> 6 ) ); key[ 3 ] = *(cstr+2); for( int j = 0; j < 4; ++j ){ key[ j ] &= 0x3f; out += table[ key[ j ] ]; } } if( lng % 3 == 1 ){ out[ out.length()-2 ] = '='; out[ out.length()-1 ] = '='; } else if( lng % 3 == 2 ){ out[ out.length()-1 ] = '='; } #ifdef _DEBUG std::cout << "MISC::base64 " << str << " -> " << out << std::endl; #endif return out; }
false
false
false
false
false
0
fcoe_interface_create(struct net_device *netdev, enum fip_state fip_mode) { struct fcoe_ctlr_device *ctlr_dev; struct fcoe_ctlr *ctlr; struct fcoe_interface *fcoe; int size; int err; if (!try_module_get(THIS_MODULE)) { FCOE_NETDEV_DBG(netdev, "Could not get a reference to the module\n"); fcoe = ERR_PTR(-EBUSY); goto out; } size = sizeof(struct fcoe_ctlr) + sizeof(struct fcoe_interface); ctlr_dev = fcoe_ctlr_device_add(&netdev->dev, &fcoe_sysfs_templ, size); if (!ctlr_dev) { FCOE_DBG("Failed to add fcoe_ctlr_device\n"); fcoe = ERR_PTR(-ENOMEM); goto out_putmod; } ctlr = fcoe_ctlr_device_priv(ctlr_dev); ctlr->cdev = ctlr_dev; fcoe = fcoe_ctlr_priv(ctlr); dev_hold(netdev); /* * Initialize FIP. */ fcoe_ctlr_init(ctlr, fip_mode); ctlr->send = fcoe_fip_send; ctlr->update_mac = fcoe_update_src_mac; ctlr->get_src_addr = fcoe_get_src_mac; err = fcoe_interface_setup(fcoe, netdev); if (err) { fcoe_ctlr_destroy(ctlr); fcoe_ctlr_device_delete(ctlr_dev); dev_put(netdev); fcoe = ERR_PTR(err); goto out_putmod; } goto out; out_putmod: module_put(THIS_MODULE); out: return fcoe; }
false
false
false
false
false
0
getLength() { if (!linDict.isDict()) return 0; int length; if (linDict.getDict()->lookupInt("L", NULL, &length) && length > 0) { return length; } else { error(-1, "Length in linearization table is invalid"); return 0; } }
false
false
false
false
false
0
dht_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, fd_t *fd, dict_t *xdata) { dht_local_t *local = NULL; int this_call_cnt = 0; call_frame_t *prev = NULL; local = frame->local; prev = cookie; LOCK (&frame->lock); { if (op_ret == -1) { local->op_errno = op_errno; gf_log (this->name, GF_LOG_DEBUG, "subvolume %s returned -1 (%s)", prev->this->name, strerror (op_errno)); goto unlock; } local->op_ret = 0; } unlock: UNLOCK (&frame->lock); this_call_cnt = dht_frame_return (frame); if (is_last_call (this_call_cnt)) DHT_STACK_UNWIND (open, frame, local->op_ret, local->op_errno, local->fd, NULL); return 0; }
false
false
false
false
true
1
_concatenate(const UChar *left, int32_t leftLength, const UChar *right, int32_t rightLength, UChar *dest, int32_t destCapacity, const Normalizer2 *n2, UErrorCode *pErrorCode) { if(U_FAILURE(*pErrorCode)) { return 0; } if(destCapacity<0 || (dest==NULL && destCapacity>0) || left==NULL || leftLength<-1 || right==NULL || rightLength<-1) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } /* check for overlapping right and destination */ if( dest!=NULL && ((right>=dest && right<(dest+destCapacity)) || (rightLength>0 && dest>=right && dest<(right+rightLength))) ) { *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; return 0; } /* allow left==dest */ UnicodeString destString; if(left==dest) { destString.setTo(dest, leftLength, destCapacity); } else { destString.setTo(dest, 0, destCapacity); destString.append(left, leftLength); } return n2->append(destString, UnicodeString(rightLength<0, right, rightLength), *pErrorCode). extract(dest, destCapacity, *pErrorCode); }
false
false
false
false
false
0
ap_rxplus_exec(apr_pool_t *pool, ap_rxplus_t *rx, const char *pattern, char **newpattern) { int ret = 1; int startl, oldl, newl, diffsz; const char *remainder; char *subs; /* snrf process_regexp from mod_headers */ if (ap_regexec(&rx->rx, pattern, rx->nmatch, rx->pmatch, rx->flags) != 0) { rx->match = NULL; return 0; /* no match, nothing to do */ } rx->match = pattern; if (rx->subs) { *newpattern = ap_pregsub(pool, rx->subs, pattern, rx->nmatch, rx->pmatch); if (!*newpattern) { return 0; /* FIXME - should we do more to handle error? */ } startl = rx->pmatch[0].rm_so; oldl = rx->pmatch[0].rm_eo - startl; newl = strlen(*newpattern); diffsz = newl - oldl; remainder = pattern + startl + oldl; if (rx->flags & AP_REG_MULTI) { /* recurse to do any further matches */ ret += ap_rxplus_exec(pool, rx, remainder, &subs); if (ret > 1) { /* a further substitution happened */ diffsz += strlen(subs) - strlen(remainder); remainder = subs; } } subs = apr_palloc(pool, strlen(pattern) + 1 + diffsz); memcpy(subs, pattern, startl); memcpy(subs+startl, *newpattern, newl); strcpy(subs+startl+newl, remainder); *newpattern = subs; } return ret; }
false
false
false
false
true
1
svnic_dev_notify_set(struct vnic_dev *vdev, u16 intr) { u64 a0, a1; int wait = VNIC_DVCMD_TMO; if (!vdev->notify) { vdev->notify = pci_alloc_consistent(vdev->pdev, sizeof(struct vnic_devcmd_notify), &vdev->notify_pa); if (!vdev->notify) return -ENOMEM; } a0 = vdev->notify_pa; a1 = ((u64)intr << 32) & VNIC_NOTIFY_INTR_MASK; a1 += sizeof(struct vnic_devcmd_notify); return svnic_dev_cmd(vdev, CMD_NOTIFY, &a0, &a1, wait); }
false
false
false
false
false
0
panel_context_menu_check_for_screen (GtkWidget *w, GdkEvent *ev, gpointer data) { static int times = 0; if (!w) { times = 0; return FALSE; } if (ev->type != GDK_KEY_PRESS) return FALSE; if (ev->key.keyval == GDK_KEY_f || ev->key.keyval == GDK_KEY_F) { times++; if (times == 3) { times = 0; start_screen_check (); } } return FALSE; }
false
false
false
false
false
0
setMifTag(int& next_tag) { for (int i = 0; i < data.nofComponents; i++) { data.components[i]->setMifTag(next_tag); } }
false
false
false
false
false
0
set_fieldtype_arg(FIELDTYPE *typ, void *(*const make_arg)(va_list *), void *(*const copy_arg)(const void *), void (*const free_arg) (void *)) { T((T_CALLED("set_fieldtype_arg(%p,%p,%p,%p)"), typ, make_arg, copy_arg, free_arg)); if (typ != 0 && make_arg != (void *)0) { typ->status |= _HAS_ARGS; typ->makearg = make_arg; typ->copyarg = copy_arg; typ->freearg = free_arg; RETURN(E_OK); } RETURN(E_BAD_ARGUMENT); }
false
false
false
false
false
0
e_dbus_object_skeleton_get_property (GObject *gobject, guint prop_id, GValue *value, GParamSpec *pspec) { EDBusObjectSkeleton *object = E_DBUS_OBJECT_SKELETON (gobject); GDBusInterface *interface; switch (prop_id) { case 1: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source"); g_value_take_object (value, interface); break; case 2: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source.Removable"); g_value_take_object (value, interface); break; case 3: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source.Writable"); g_value_take_object (value, interface); break; case 4: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source.RemoteCreatable"); g_value_take_object (value, interface); break; case 5: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source.RemoteDeletable"); g_value_take_object (value, interface); break; case 6: interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), "org.gnome.evolution.dataserver.Source.OAuth2Support"); g_value_take_object (value, interface); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec); break; } }
false
false
false
false
false
0
_AVCE00ReadScanE00(AVCE00ReadE00Ptr psRead) { AVCE00ParseInfo *psInfo = psRead->hParseInfo; const char *pszLine; const char *pszName = 0; void *obj; int iSect = 0; while (CPLGetLastErrorNo() == 0 && (pszLine = CPLReadLine(psRead->hFile) ) != NULL ) { obj = _AVCE00ReadNextLineE00(psRead, pszLine); if (obj) { pszName = 0; switch (psInfo->eFileType) { case AVCFileARC: pszName = "ARC"; break; case AVCFilePAL: pszName = "PAL"; break; case AVCFileCNT: pszName = "CNT"; break; case AVCFileLAB: pszName = "LAB"; break; case AVCFileRPL: pszName = "RPL"; break; case AVCFileTXT: pszName = "TXT"; break; case AVCFileTX6: pszName = "TX6"; break; case AVCFilePRJ: pszName = "PRJ"; break; case AVCFileTABLE: pszName = psInfo->hdr.psTableDef->szTableName; break; default: break; } if (pszName && (psRead->numSections == 0 || psRead->pasSections[iSect].eType != psInfo->eFileType || !EQUAL(pszName, psRead->pasSections[iSect].pszName))) { iSect = _AVCIncreaseSectionsArray(&(psRead->pasSections), &(psRead->numSections), 1); psRead->pasSections[iSect].eType = psInfo->eFileType; /* psRead->pasSections[iSect].pszName = CPLStrdup(psRead->pszCoverName); */ psRead->pasSections[iSect].pszName = CPLStrdup(pszName); psRead->pasSections[iSect].pszFilename = CPLStrdup(psRead->pszCoverPath); psRead->pasSections[iSect].nLineNum = psInfo->nStartLineNum; psRead->pasSections[iSect].nFeatureCount = 0; } if (pszName && psRead->numSections) { /* increase feature count for current layer */ ++psRead->pasSections[iSect].nFeatureCount; } } } }
false
false
false
false
true
1
display_mime(struct mailmime * mime) { clistiter * cur; switch (mime->mm_type) { case MAILMIME_SINGLE: printf("single part\n"); break; case MAILMIME_MULTIPLE: printf("multipart\n"); break; case MAILMIME_MESSAGE: printf("message\n"); break; } if (mime->mm_mime_fields != NULL) { if (clist_begin(mime->mm_mime_fields->fld_list) != NULL) { printf("MIME headers begin\n"); display_mime_fields(mime->mm_mime_fields); printf("MIME headers end\n"); } } display_mime_content(mime->mm_content_type); switch (mime->mm_type) { case MAILMIME_SINGLE: display_mime_data(mime->mm_data.mm_single); break; case MAILMIME_MULTIPLE: for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ; cur != NULL ; cur = clist_next(cur)) { display_mime(clist_content(cur)); } break; case MAILMIME_MESSAGE: if (mime->mm_data.mm_message.mm_fields) { if (clist_begin(mime->mm_data.mm_message.mm_fields->fld_list) != NULL) { printf("headers begin\n"); display_fields(mime->mm_data.mm_message.mm_fields); printf("headers end\n"); } if (mime->mm_data.mm_message.mm_msg_mime != NULL) { display_mime(mime->mm_data.mm_message.mm_msg_mime); } break; } } }
false
false
false
false
false
0
budget_stop_feed(struct dvb_demux_feed *feed) { struct dvb_demux *demux = feed->demux; struct budget *budget = (struct budget *) demux->priv; int status = 0; dprintk(2, "budget: %p\n", budget); spin_lock(&budget->feedlock); if (--budget->feeding == 0) status = stop_ts_capture(budget); spin_unlock(&budget->feedlock); return status; }
false
false
false
false
false
0
SetDriver(uint8 driverId) { switch(driverId) { case DIRECTX9: _driverType = video::EDT_DIRECT3D9; break; case DIRECTX8: _driverType = video::EDT_DIRECT3D8; break; case OPENGL: _driverType = video::EDT_OPENGL; break; case SOFTWARE: _driverType = video::EDT_SOFTWARE; break; case BURNINGSVIDEO: _driverType = video::EDT_BURNINGSVIDEO; break; case NULLDEVICE: _driverType = video::EDT_NULL; break; default: _driverType = video::EDT_BURNINGSVIDEO; // if no valid driver detected, use software } // TODO: add support for changing driver during runtime? }
false
false
false
false
false
0
create_cattr_named_arg (void *minfo, MonoObject *typedarg) { static MonoClass *klass; static MonoMethod *ctor; MonoObject *retval; void *unboxed, *params [2]; if (!klass) klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "CustomAttributeNamedArgument"); if (!ctor) ctor = mono_class_get_method_from_name (klass, ".ctor", 2); params [0] = minfo; params [1] = typedarg; retval = mono_object_new (mono_domain_get (), klass); unboxed = mono_object_unbox (retval); mono_runtime_invoke (ctor, unboxed, params, NULL); return retval; }
false
false
false
false
false
0
XToTime(x) Coord x; { float tmp; int denom; if ((x <= traceBox.left) || (x >= traceBox.right)) return TIME_BOUND; denom = traceBox.right - traceBox.left - 2; if (denom == 0) return TIME_BOUND; /* avoid divide-by-zero */ tmp = (float)tims.steps / (float)denom; return (tims.start + Round((x - traceBox.left - 1) * tmp)); }
false
false
false
false
false
0
InternalIsFileLoaded(const string& filename) const { MutexLockMaybe lock(mutex_); return tables_->FindFile(filename) != NULL; }
false
false
false
false
false
0
propfind_curprivset(const xmlChar *name, xmlNsPtr ns, struct propfind_ctx *fctx, xmlNodePtr resp, struct propstat propstat[], void *rock __attribute__((unused))) { int rights; unsigned flags = 0; xmlNodePtr set; if (!fctx->mailbox) return HTTP_NOT_FOUND; if (((rights = cyrus_acl_myrights(fctx->authstate, fctx->mailbox->acl)) & DACL_READ) != DACL_READ) { return HTTP_UNAUTHORIZED; } /* Add in implicit rights */ if (fctx->userisadmin) { rights |= DACL_ADMIN; } else if (mboxname_userownsmailbox(fctx->int_userid, fctx->mailbox->name)) { rights |= config_implicitrights; } /* Build the rest of the XML response */ set = xml_add_prop(HTTP_OK, fctx->ns[NS_DAV], &propstat[PROPSTAT_OK], name, ns, NULL, 0); if (fctx->req_tgt->collection) { if (fctx->req_tgt->namespace == URL_NS_CALENDAR) { flags = PRIV_IMPLICIT; if (!strcmp(fctx->req_tgt->collection, SCHED_INBOX)) flags = PRIV_INBOX; else if (!strcmp(fctx->req_tgt->collection, SCHED_OUTBOX)) flags = PRIV_OUTBOX; } add_privs(rights, flags, set, resp->parent, fctx->ns); } return 0; }
false
false
false
false
false
0
command(char c) { int index = static_cast<uint>(c); if (index < 0 || index >= 0x100) return NULL; return cmdMap_[index]; }
false
false
false
false
false
0
start_new_outpacket(int userid, char *data, int datalen) /* Copies data to .outpacket and resets all counters. data is expected to be compressed already. */ { datalen = MIN(datalen, sizeof(users[userid].outpacket.data)); memcpy(users[userid].outpacket.data, data, datalen); users[userid].outpacket.len = datalen; users[userid].outpacket.offset = 0; users[userid].outpacket.sentlen = 0; users[userid].outpacket.seqno = (users[userid].outpacket.seqno + 1) & 7; users[userid].outpacket.fragment = 0; users[userid].outfragresent = 0; }
false
false
false
false
false
0
esl_wei_pdf(double x, double mu, double lambda, double tau) { double y = lambda * (x-mu); double val; if (x < mu) return 0.; if (x == mu) { if (tau < 1.) return eslINFINITY; else if (tau > 1.) return 0.; else if (tau == 1.) return lambda; } val = lambda * tau * exp((tau-1)*log(y)) * exp(- exp(tau * log(y))); return val; }
false
false
false
false
false
0
GetNextBlock(struct Block * block) { if(block->subBlocks.first) block = block->subBlocks.first; else { for(; block; ) { if(block->next) { block = block->next; break; } block = block->parent; } } return block; }
false
false
false
false
false
0
horizontalSpacing() const { if (m_hSpace >= 0) { return m_hSpace; } else { return smartSpacing(QStyle::PM_LayoutHorizontalSpacing); } }
false
false
false
false
false
0
pch_setup_backlight(struct intel_connector *connector, enum pipe unused) { struct drm_device *dev = connector->base.dev; struct drm_i915_private *dev_priv = dev->dev_private; struct intel_panel *panel = &connector->panel; u32 cpu_ctl2, pch_ctl1, pch_ctl2, val; pch_ctl1 = I915_READ(BLC_PWM_PCH_CTL1); panel->backlight.active_low_pwm = pch_ctl1 & BLM_PCH_POLARITY; pch_ctl2 = I915_READ(BLC_PWM_PCH_CTL2); panel->backlight.max = pch_ctl2 >> 16; if (!panel->backlight.max) panel->backlight.max = get_backlight_max_vbt(connector); if (!panel->backlight.max) return -ENODEV; panel->backlight.min = get_backlight_min_vbt(connector); val = pch_get_backlight(connector); panel->backlight.level = intel_panel_compute_brightness(connector, val); cpu_ctl2 = I915_READ(BLC_PWM_CPU_CTL2); panel->backlight.enabled = (cpu_ctl2 & BLM_PWM_ENABLE) && (pch_ctl1 & BLM_PCH_PWM_ENABLE) && panel->backlight.level != 0; return 0; }
false
false
false
false
false
0
mem_crc32(u32 crc, const char *buff, size_t size) { const char *buff_end = buff + size; crc ^= 0xFFFFFFFFL; while (buff < buff_end) { crc = crc32_table[(crc ^ (*buff++)) & 0xFF] ^ (crc >> 8); } return crc ^ 0xFFFFFFFFL; }
false
false
false
false
false
0
operator-=(date_time_period_set const &v) { for(unsigned i=0;i<v.size();i++) { *this-=v[i]; } return *this; }
false
false
false
false
false
0
to_nd_blk_region(struct device *dev) { struct nd_region *nd_region = to_nd_region(dev); WARN_ON(!is_nd_blk(dev)); return container_of(nd_region, struct nd_blk_region, nd_region); }
false
false
false
false
false
0
static_extruded_remove (FT_Library freetype, FT_Face face, gamgi_extruded *extruded, char *error) { gamgi_bool valid = TRUE; /************************* * remove Mesa resources * *************************/ gluDeleteTess (extruded->tesselator); /************************** * remove Gamgi resources * **************************/ gamgi_engine_darray_remove (extruded->contour); gamgi_engine_darray_remove (extruded->normals); free (extruded); /***************************** * remove Freetype resources * *****************************/ if (FT_Done_Face (face) != 0) { if (error != NULL) sprintf (error, "Unable to close the font"); valid = FALSE; } if (FT_Done_FreeType (freetype) != 0) { if (error != NULL) sprintf (error, "Unable to close the FreeType library"); valid = FALSE; } return valid; }
false
false
false
false
false
0
readZipCodes() { if (!zipCodes.isEmpty()) return; QString c = Utils::readTextFile(m_Path + "/zipcodes.csv"); if (c.isEmpty()) Utils::Log::addError("Randomizer", "Can not read zip codes.", __FILE__, __LINE__); foreach(const QString &s, c.split("\n", QString::SkipEmptyParts)) { QStringList z = s.split("\t"); if (z.count() != 2) continue; zipCodes.insert(z.at(1).toInt(), z.at(0).toUpper()); } }
false
false
false
false
false
0
InsertChild(w) Widget w; { if (((CompositeWidget)XtParent(w))->composite.num_children > 1) { XtAppWarningMsg( XtWidgetToApplicationContext(w), "insertChild", "badChild", "XbaeCaption", "XbaeCaption: Cannot add more than one child.", (String *)NULL, (Cardinal *)NULL); return; } (*((CompositeWidgetClass) (xbaeCaptionWidgetClass->core_class.superclass))->composite_class. insert_child) (w); }
false
false
false
false
false
0
IsPDF(const unsigned char *magick,const size_t offset) { if (offset < 5) return(False); if (LocaleNCompare((char *) magick,"%PDF-",5) == 0) return(True); return(False); }
false
false
false
false
false
0
attach(GMainContext *ctx) { g_assert(_ctx == NULL); // just to be sane _ctx = ctx ? ctx : g_main_context_default(); g_main_context_ref(_ctx); // create the source for dispatching messages _source = g_source_new((GSourceFuncs *) &dispatcher_funcs, sizeof(DispatcherSource)); ((DispatcherSource *)_source)->dispatcher = this; g_source_attach(_source, _ctx); }
false
false
false
false
false
0
CmdIndex(int code) { char *text, *r, *s, *t; getNonBlank(); text = getDelimitedText('{', '}', TRUE); diagnostics(4, "CmdIndex \\index{%s}", text); fprintRTF("{\\xe{\\v "); t = text; while (t) { s = t; t = strchr(s, '!'); if (t) *t = '\0'; r = strchr(s, '@'); if (r) s = r + 1; ConvertString(s); /* while (*s && *s != '@') fprintRTF("%c",*s++); */ if (t) { fprintRTF("\\:"); t++; } } fprintRTF("}}"); diagnostics(4, "leaving CmdIndex"); safe_free(text); }
false
false
false
false
false
0
ConstantFoldInstruction(Instruction *I, const DataLayout &DL, const TargetLibraryInfo *TLI) { // Handle PHI nodes quickly here... if (PHINode *PN = dyn_cast<PHINode>(I)) { Constant *CommonValue = nullptr; for (Value *Incoming : PN->incoming_values()) { // If the incoming value is undef then skip it. Note that while we could // skip the value if it is equal to the phi node itself we choose not to // because that would break the rule that constant folding only applies if // all operands are constants. if (isa<UndefValue>(Incoming)) continue; // If the incoming value is not a constant, then give up. Constant *C = dyn_cast<Constant>(Incoming); if (!C) return nullptr; // Fold the PHI's operands. if (ConstantExpr *NewC = dyn_cast<ConstantExpr>(C)) C = ConstantFoldConstantExpression(NewC, DL, TLI); // If the incoming value is a different constant to // the one we saw previously, then give up. if (CommonValue && C != CommonValue) return nullptr; CommonValue = C; } // If we reach here, all incoming values are the same constant or undef. return CommonValue ? CommonValue : UndefValue::get(PN->getType()); } // Scan the operand list, checking to see if they are all constants, if so, // hand off to ConstantFoldInstOperands. SmallVector<Constant*, 8> Ops; for (User::op_iterator i = I->op_begin(), e = I->op_end(); i != e; ++i) { Constant *Op = dyn_cast<Constant>(*i); if (!Op) return nullptr; // All operands not constant! // Fold the Instruction's operands. if (ConstantExpr *NewCE = dyn_cast<ConstantExpr>(Op)) Op = ConstantFoldConstantExpression(NewCE, DL, TLI); Ops.push_back(Op); } if (const CmpInst *CI = dyn_cast<CmpInst>(I)) return ConstantFoldCompareInstOperands(CI->getPredicate(), Ops[0], Ops[1], DL, TLI); if (const LoadInst *LI = dyn_cast<LoadInst>(I)) return ConstantFoldLoadInst(LI, DL); if (InsertValueInst *IVI = dyn_cast<InsertValueInst>(I)) { return ConstantExpr::getInsertValue( cast<Constant>(IVI->getAggregateOperand()), cast<Constant>(IVI->getInsertedValueOperand()), IVI->getIndices()); } if (ExtractValueInst *EVI = dyn_cast<ExtractValueInst>(I)) { return ConstantExpr::getExtractValue( cast<Constant>(EVI->getAggregateOperand()), EVI->getIndices()); } return ConstantFoldInstOperands(I->getOpcode(), I->getType(), Ops, DL, TLI); }
false
false
false
false
false
0
jcnf_add_key_internal( jcnf *p, char *key, /* Key path name */ jc_type type, void *data, size_t dataSize, /* Data size (including string nul) */ char *comment ) { jc_error ev; jc_key *kp; if (key == NULL || (type != jc_null && (data == NULL || dataSize == 0))) return jc_bad_addkey_params; if (p->nkeys >= p->akeys) { /* Need more pointer space */ p->akeys = p->akeys ? 2 * p->akeys : 10; if ((p->keys = realloc(p->keys, p->akeys * sizeof(jc_key*))) == NULL) { return jc_malloc; } } if ((kp = p->keys[p->nkeys] = calloc(1, sizeof(jc_key))) == NULL) { return jc_malloc; } p->nkeys++; if ((ev = jcnf_set_key_internal(p, kp, key, type, data, dataSize, comment)) != jc_ok) return ev; p->lk = kp; return jc_ok; }
false
false
false
false
false
0
slotExpanded( const QModelIndex &index ) { if( !m_treeModel ) return; if( m_filterModel ) m_treeModel->slotExpanded( m_filterModel->mapToSource( index )); else m_treeModel->slotExpanded( index ); }
false
false
false
false
false
0
retrieve_contents (bfd *abfd, asection *sec, bfd_boolean keep_memory) { bfd_byte *contents; bfd_size_type sec_size; sec_size = bfd_get_section_limit (abfd, sec); contents = elf_section_data (sec)->this_hdr.contents; if (contents == NULL && sec_size != 0) { if (!bfd_malloc_and_get_section (abfd, sec, &contents)) { if (contents) free (contents); return NULL; } if (keep_memory) elf_section_data (sec)->this_hdr.contents = contents; } return contents; }
false
false
false
false
false
0
c3745_nm_stop_online(vm_instance_t *vm,u_int slot,u_int subslot) { if (!slot) { vm_error(vm,"OIR not supported on slot 0.\n"); return(-1); } /* The NM driver must be initialized */ if (!vm_slot_get_card_ptr(vm,slot)) { vm_error(vm,"trying to shut down empty slot %u.\n",slot); return(-1); } /* Disable all NIOs to stop traffic forwarding */ vm_slot_disable_all_nio(vm,slot); /* We can safely trigger the OIR event */ c3745_trigger_oir_event(VM_C3745(vm),1 << (slot - 1)); /* * Suspend CPU activity while removing the hardware (since we change the * memory maps). */ vm_suspend(vm); /* Device removal */ if (vm_slot_shutdown(vm,slot) != 0) vm_error(vm,"unable to shutdown slot %u.\n",slot); /* Resume normal operations */ vm_resume(vm); return(0); }
false
false
false
false
false
0
gnc_table_get_cell_location (Table *table, const char *cell_name, VirtualCellLocation vcell_loc, VirtualLocation *virt_loc) { VirtualCell *vcell; CellBlock *cellblock; int cell_row, cell_col; if (table == NULL) return FALSE; vcell = gnc_table_get_virtual_cell (table, vcell_loc); if (vcell == NULL) return FALSE; cellblock = vcell->cellblock; for (cell_row = 0; cell_row < cellblock->num_rows; cell_row++) for (cell_col = 0; cell_col < cellblock->num_cols; cell_col++) { BasicCell *cell; cell = gnc_cellblock_get_cell (cellblock, cell_row, cell_col); if (!cell) continue; if (gnc_basic_cell_has_name (cell, cell_name)) { if (virt_loc != NULL) { virt_loc->vcell_loc = vcell_loc; virt_loc->phys_row_offset = cell_row; virt_loc->phys_col_offset = cell_col; } return TRUE; } } return FALSE; }
false
false
false
false
false
0
createTestGroup(MprTestService *sp, MprTestDef *def, MprTestGroup *parent) { MprTestGroup *gp, *child; MprTestDef **dp; MprTestCase *tc; char name[80]; static int counter = 0; mprAssert(sp); mprAssert(def); gp = mprAllocObj(MprTestGroup, manageTestGroup); if (gp == 0) { return 0; } gp->service = sp; if (parent) { gp->dispatcher = parent->dispatcher; } else { mprSprintf(name, sizeof(name), "Test-%d", counter++); gp->dispatcher = mprCreateDispatcher(name, 1); } gp->failures = mprCreateList(0, 0); if (gp->failures == 0) { return 0; } gp->cases = mprCreateList(0, MPR_LIST_STATIC_VALUES); if (gp->cases == 0) { return 0; } gp->groups = mprCreateList(0, 0); if (gp->groups == 0) { return 0; } gp->def = def; gp->name = sclone(def->name); gp->success = 1; for (tc = def->caseDefs; tc->proc; tc++) { if (mprAddItem(gp->cases, tc) < 0) { return 0; } } if (def->groupDefs) { for (dp = &def->groupDefs[0]; *dp && (*dp)->name; dp++) { child = createTestGroup(sp, *dp, gp); if (child == 0) { return 0; } if (mprAddItem(gp->groups, child) < 0) { return 0; } child->parent = gp; child->root = gp->parent; } } return gp; }
false
false
false
true
false
1
parse_car_or_cdr_element (GMarkupParseContext *context, const gchar *element_name, const gchar **attribute_names, const gchar **attribute_values, ParseInfo *info, GError **error) { ParseState current_state; GConfValue *value; GConfValue *pair; current_state = ELEMENT_IS ("car") ? STATE_CAR : STATE_CDR; push_state (info, current_state); value = NULL; parse_value_element (context, element_name, attribute_names, attribute_values, &value, error); if (value == NULL) return; pair = value_stack_peek (info); if (pair->type == GCONF_VALUE_PAIR) { if (current_state == STATE_CAR) { if (gconf_value_get_car (pair) == NULL) { gconf_value_set_car_nocopy (pair, value); value_stack_push (info, value, FALSE); /* pair owns it */ } else { gconf_value_free (value); set_error (error, context, GCONF_ERROR_PARSE_ERROR, _("Two <car> elements given for same pair")); } } else { if (gconf_value_get_cdr (pair) == NULL) { gconf_value_set_cdr_nocopy (pair, value); value_stack_push (info, value, FALSE); /* pair owns it */ } else { gconf_value_free (value); set_error (error, context, GCONF_ERROR_PARSE_ERROR, _("Two <cdr> elements given for same pair")); } } } else { gconf_value_free (value); set_error (error, context, GCONF_ERROR_PARSE_ERROR, _("<%s> provided but current element does not have type %s"), current_state == STATE_CAR ? "car" : "cdr", "pair"); } }
false
false
false
false
false
0
wakeUp (TimeoutId id, void *data) { InnListener lis = (InnListener) data ; Buffer *readArray ; ASSERT (id == lis->inputEOFSleepId) ; lis->inputEOFSleepId = 0 ; readArray = makeBufferArray (bufferTakeRef (lis->inputBuffer), NULL) ; prepareRead (lis->myep,readArray,newArticleCommand,lis,1) ; }
false
false
false
false
false
0
length_KDCDHKeyInfo(const KDCDHKeyInfo *data) { size_t ret = 0; { size_t Top_tag_oldret = ret; ret = 0; ret += der_length_bit_string(&(data)->subjectPublicKey); ret += 1 + der_length_len (ret); ret += 1 + der_length_len (ret); ret += Top_tag_oldret; } { size_t Top_tag_oldret = ret; ret = 0; ret += der_length_unsigned(&(data)->nonce); ret += 1 + der_length_len (ret); ret += 1 + der_length_len (ret); ret += Top_tag_oldret; } if((data)->dhKeyExpiration){ size_t Top_tag_oldret = ret; ret = 0; ret += length_KerberosTime((data)->dhKeyExpiration); ret += 1 + der_length_len (ret); ret += Top_tag_oldret; } ret += 1 + der_length_len (ret); return ret; }
false
false
false
false
false
0
xfx(double x, double Q) { vector<double> r(13); fevolvepdf(&x, &Q, &r[0]); return r; }
false
false
false
false
false
0
test_write_read(void) { int i = 0; int *write_buf, *read_buf; TESTING("simple write/read to/from metadata accumulator"); /* Allocate buffers */ write_buf = (int *)HDmalloc(1024 * sizeof(int)); HDassert(write_buf); read_buf = (int *)HDcalloc(1024, sizeof(int)); HDassert(read_buf); /* Fill buffer with data, zero out read buffer */ for(i = 0; i < 1024; i++) write_buf[i] = i + 1; /* Do a simple write/read/verify of data */ /* Write 1KB at Address 0 */ if(accum_write(0, 1024, write_buf) < 0) FAIL_STACK_ERROR; if(accum_read(0, 1024, read_buf) < 0) FAIL_STACK_ERROR; if(HDmemcmp(write_buf, read_buf, 1024) != 0) TEST_ERROR; if(accum_reset() < 0) FAIL_STACK_ERROR; PASSED(); /* Release memory */ HDfree(write_buf); HDfree(read_buf); return 0; error: /* Release memory */ HDfree(write_buf); HDfree(read_buf); return 1; }
false
false
false
false
false
0
brasero_filtered_uri_clear (BraseroFilteredUri *filtered) { BraseroFilteredUriPrivate *priv; GHashTableIter iter; gpointer key; priv = BRASERO_FILTERED_URI_PRIVATE (filtered); g_hash_table_iter_init (&iter, priv->restored); while (g_hash_table_iter_next (&iter, &key, NULL)) { brasero_utils_unregister_string (key); g_hash_table_iter_remove (&iter); } gtk_list_store_clear (GTK_LIST_STORE (filtered)); }
false
false
false
false
false
0
keys_init (void) { gl_tls_key_init (buffer_key, free); gl_tls_key_init (bufmax_key, NULL); /* The per-thread initial values are NULL and 0, respectively. */ }
false
false
false
false
false
0
bq24190_remove(struct i2c_client *client) { struct bq24190_dev_info *bdi = i2c_get_clientdata(client); pm_runtime_get_sync(bdi->dev); bq24190_register_reset(bdi); pm_runtime_put_sync(bdi->dev); bq24190_sysfs_remove_group(bdi); power_supply_unregister(bdi->battery); power_supply_unregister(bdi->charger); pm_runtime_disable(bdi->dev); if (bdi->gpio_int) gpio_free(bdi->gpio_int); return 0; }
false
false
false
false
false
0
copy_1symtab(struct symtab_t *osytp) { int32 ofreezes; struct symtab_t *nsytp; ofreezes = osytp->freezes; nsytp = __alloc_symtab(ofreezes); *nsytp = *osytp; /* must leave as NULL if empty table */ if (osytp->numsyms == 0) nsytp->stsyms = NULL; else nsytp->stsyms = copy_stsyms(osytp->stsyms, osytp->numsyms); /* when above symbol table was copied, old symbol links to new */ /* SJM 12/26/03 - specify symbol table has no associated symbol */ if (osytp->sypofsyt != NULL) nsytp->sypofsyt = osytp->sypofsyt->spltsy; else nsytp->sypofsyt = NULL; /* must link old to point to new (n_head now unused) */ osytp->n_head = (struct tnode_t *) nsytp; return(nsytp); }
false
false
false
false
false
0
toshiba_bluetooth_present(acpi_handle handle) { acpi_status result; u64 bt_present; /* * Some Toshiba laptops may have a fake TOS6205 device in * their ACPI BIOS, so query the _STA method to see if there * is really anything there. */ result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present); if (ACPI_FAILURE(result)) { pr_err("ACPI call to query Bluetooth presence failed"); return -ENXIO; } else if (!bt_present) { pr_info("Bluetooth device not present\n"); return -ENODEV; } return 0; }
false
false
false
false
false
0
ompi_win_destruct(ompi_win_t *win) { if (NULL != win->w_keyhash) { ompi_attr_delete_all(WIN_ATTR, win, win->w_keyhash); OBJ_RELEASE(win->w_keyhash); } if (NULL != win->error_handler) { OBJ_RELEASE(win->error_handler); } if (NULL != win->w_group) { ompi_group_decrement_proc_count(win->w_group); OBJ_RELEASE(win->w_group); } OBJ_DESTRUCT(&win->w_lock); }
false
false
false
false
false
0
hash_bytes(SHA_CTX * pctx, U8 * pdata, int length, int padding) { /* This buffer size is FIXED as per the algorithm */ U8 buffer[64]; int pos, avail, offset; if (padding > sizeof(buffer)) { return; } memset(buffer, 0, padding); pos = padding; offset = 0; while (length > 0) { avail = sizeof(buffer) - pos; if (length >= avail) { memcpy(&buffer[pos],pdata+offset, avail); length -= avail; offset += avail; } else { /* Length + 0's */ memcpy(&buffer[pos],pdata+offset, length); memset(&buffer[pos+length],0, avail - length); /* offset is meaningless now */ length = 0; } SHA1_Update(pctx, buffer, sizeof(buffer)); pos = 0; } }
false
true
false
false
false
1
draw_vsep_win(wp, row) win_T *wp; int row; { int hl; int c; if (wp->w_vsep_width) { /* draw the vertical separator right of this window */ c = fillchar_vsep(&hl); screen_fill(W_WINROW(wp) + row, W_WINROW(wp) + wp->w_height, W_ENDCOL(wp), W_ENDCOL(wp) + 1, c, ' ', hl); } }
false
false
false
false
false
0
clone_method(ID mid, const rb_method_entry_t *me, struct clone_method_data *data) { VALUE newiseqval; if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { rb_iseq_t *iseq; newiseqval = rb_iseq_clone(me->def->body.iseq->self, data->klass); GetISeqPtr(newiseqval, iseq); rb_add_method(data->klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); RB_GC_GUARD(newiseqval); } else { rb_method_entry_set(data->klass, mid, me, me->flag); } return ST_CONTINUE; }
false
false
false
false
false
0
run( const gchar * name, gint nparams, // !!! Always 3 for INTERACTIVE, not lengthof(param)? const GimpParam * param, gint * nreturn_vals, GimpParam ** return_vals) { static GimpParam values[1]; // return values persist after run() returns TGimpAdapterParameters parameters; gboolean ok; /* Unless anything goes wrong, result is success */ *nreturn_vals = 1; *return_vals = values; values[0].type = GIMP_PDB_STATUS; values[0].data.d_status = GIMP_PDB_SUCCESS; /* Initialize i18n support */ #if defined(G_OS_WIN32) bindtextdomain (GETTEXT_PACKAGE, gimp_locale_directory()); #else bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #endif #ifdef HAVE_BIND_TEXTDOMAIN_CODESET bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif textdomain (GETTEXT_PACKAGE); /* Don't really need the drawable or its tiles until we get to the engine. */ gint32 drawable_id; drawable_id = param[2].data.d_drawable; /* Assert the image type is OK because Gimp checked it. */ /* Deal with run mode */ ok = FALSE; switch(param[0].data.d_int32) { case GIMP_RUN_INTERACTIVE : get_last_parameters(&parameters, drawable_id, RESYNTH_CONTROLS_PDB_NAME ); init_gtk(); /* GUI dialog. */ ok = get_parameters_by_asking(&parameters,drawable_id); if (ok) /* Not canceled and not an exception. */ set_last_parameters(&parameters, drawable_id); break; case GIMP_RUN_NONINTERACTIVE : /* GUI CAN be called noninteractively, in batch mode or otherwise. */ ok = get_parameters_from_list(&parameters, nparams, param); break; case GIMP_RUN_WITH_LAST_VALS : ok = get_last_parameters(&parameters,drawable_id, RESYNTH_CONTROLS_PDB_NAME); break; } if (!ok) { /* No message displayed here because it is usually Cancel button, else the resynthesizer control panel GUI already displayed an error message? */ values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR; return; } /* Prepare params for engine: augment passed params with user's choices. */ static GimpParam temp[RESYNTH_PARAMETER_COUNT]; set_parameters_to_list(&parameters, param, nparams, GIMP_RUN_NONINTERACTIVE, temp); /* Call resynthesizer engine. */ GimpParam * engine_result; gint engine_n_return_vals; engine_result = gimp_run_procedure2( RESYNTH_ENGINE_PDB_NAME, &engine_n_return_vals, RESYNTH_PARAMETER_COUNT, /* !!! Not nparams */ temp ); /* Always a status. */ if (engine_result[0].data.d_status != GIMP_PDB_SUCCESS) { /* Reraise engine error. */ *nreturn_vals = engine_n_return_vals; *return_vals = engine_result; } else { /* Free engine result, return our own. */ gimp_destroy_params(engine_result, engine_n_return_vals); } }
false
false
false
false
false
0
text_block(const string& s, double width, int justify, int innerjust) { double ox,oy,x,y,ll,rr,uu,dd; double a,b,c,d; set_base_size(); g_get_bounds(&a,&b,&c,&d); g_init_bounds(); dont_print = true; fftext_block(s,width,justify); dont_print = false; g_get_bounds(&ll,&dd,&rr,&uu); if (ll > rr) {ll=0; rr=0; uu=0; dd=0;} g_get_xy(&ox,&oy); x = ox; y = oy; g_dotjust(&x,&y,ll,rr,uu,dd,justify); g_move(x,y); g_init_bounds(); if (a<=c) { g_update_bounds(a,b); g_update_bounds(c,d); } g_get_bounds(&a,&b,&c,&d); text_draw(gt_pbuff,gt_plen); g_get_bounds(&a,&b,&c,&d); g_move(ox,oy); }
false
false
false
false
false
0
submit_work_async(struct work *work_in, struct timeval *tv_work_found) { struct work *work = copy_work(work_in); pthread_t submit_thread; if (tv_work_found) copy_time(&work->tv_work_found, tv_work_found); applog(LOG_DEBUG, "Pushing submit work to work thread"); if (unlikely(pthread_create(&submit_thread, NULL, submit_work_thread, (void *)work))) quit(1, "Failed to create submit_work_thread"); }
false
false
false
false
false
0
luaQ_pcall(lua_State *L, int na, int nr, int eh, int oh) { QtLuaEngine *engine = luaQ_engine(L); QObject *obj = engine; if (oh) obj = luaQ_toqobject(L, oh); if (! obj) luaL_error(L, "invalid qobject"); return luaQ_pcall(L, na, nr, eh, obj); }
false
false
false
false
false
0
getAnnotationVal(UT_uint32 annpid) const { UT_sint32 i =0; UT_sint32 pos = 0; fl_AnnotationLayout * pAL = NULL; for(i=0; i<m_vecAnnotations.getItemCount(); i++) { pAL = getNthAnnotation(i); if(pAL->getAnnotationPID() == annpid) { pos = i; break; } } if(pos != i) pos = -1; return pos; }
false
false
false
false
false
0
create_postproc (PostProcessing *postproc) { GtkWidget *dialog; GtkWidget *dialog_vbox2; GtkWidget *vbox1; GtkWidget *label4; GtkWidget *hseparator1; GtkWidget *scrolledwindow2; GtkWidget *textview; GtkWidget *dialog_action_area2; GtkWidget *button_cancel; GtkWidget *button_ok; dialog = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dialog), _("Post traitement")); gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_DIALOG); dialog_vbox2 = GTK_DIALOG (dialog)->vbox; gtk_widget_show (dialog_vbox2); vbox1 = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox1); gtk_box_pack_start (GTK_BOX (dialog_vbox2), vbox1, TRUE, TRUE, 0); label4 = gtk_label_new (_("For all simulations:")); gtk_widget_show (label4); gtk_box_pack_start (GTK_BOX (vbox1), label4, FALSE, FALSE, 0); hseparator1 = gtk_hseparator_new (); gtk_widget_show (hseparator1); gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, FALSE, TRUE, 5); scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_show (scrolledwindow2); gtk_box_pack_start (GTK_BOX (vbox1), scrolledwindow2, TRUE, TRUE, 0); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN); textview = gtk_text_view_new (); gtk_widget_show (textview); gtk_container_add (GTK_CONTAINER (scrolledwindow2), textview); dialog_action_area2 = GTK_DIALOG (dialog)->action_area; gtk_widget_show (dialog_action_area2); gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area2), GTK_BUTTONBOX_END); button_cancel = gtk_button_new_from_stock ("gtk-cancel"); gtk_widget_show (button_cancel); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button_cancel, GTK_RESPONSE_CANCEL); GTK_WIDGET_SET_FLAGS (button_cancel, GTK_CAN_DEFAULT); button_ok = gtk_button_new_from_stock ("gtk-ok"); gtk_widget_show (button_ok); gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button_ok, GTK_RESPONSE_OK); GTK_WIDGET_SET_FLAGS (button_ok, GTK_CAN_DEFAULT); g_signal_connect ((gpointer) dialog, "destroy", G_CALLBACK (on_postprocessing_destroy), postproc); g_signal_connect ((gpointer) button_cancel, "clicked", G_CALLBACK (on_postprocessing_button_cancel_clicked), postproc); g_signal_connect ((gpointer) button_ok, "clicked", G_CALLBACK (on_postprocessing_button_ok_clicked), postproc); /* Store pointers to all widgets, for use by lookup_widget(). */ GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog, "dialog"); GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog_vbox2, "dialog_vbox2"); GLADE_HOOKUP_OBJECT (dialog, vbox1, "vbox1"); GLADE_HOOKUP_OBJECT (dialog, label4, "label4"); GLADE_HOOKUP_OBJECT (dialog, hseparator1, "hseparator1"); GLADE_HOOKUP_OBJECT (dialog, scrolledwindow2, "scrolledwindow2"); GLADE_HOOKUP_OBJECT (dialog, textview, "textview"); GLADE_HOOKUP_OBJECT_NO_REF (dialog, dialog_action_area2, "dialog_action_area2"); GLADE_HOOKUP_OBJECT (dialog, button_cancel, "button_cancel"); GLADE_HOOKUP_OBJECT (dialog, button_ok, "button_ok"); return dialog; }
false
false
false
false
false
0
aerror(C *a, C *b, int n) { if (n > 0) { /* compute the relative Linf error */ double e = 0.0, mag = 0.0; int i; for (i = 0; i < n; ++i) { e = dmax(e, norm2(c_re(a[i]) - c_re(b[i]), c_im(a[i]) - c_im(b[i]))); mag = dmax(mag, dmin(norm2(c_re(a[i]), c_im(a[i])), norm2(c_re(b[i]), c_im(b[i])))); } e /= mag; #ifdef HAVE_ISNAN BENCH_ASSERT(!isnan(e)); #endif return e; } else return 0.0; }
false
false
false
false
true
1
dwarf_get_abbrev(Dwarf_Debug dbg, Dwarf_Unsigned offset, Dwarf_Abbrev * returned_abbrev, Dwarf_Unsigned * length, Dwarf_Unsigned * abbr_count, Dwarf_Error * error) { Dwarf_Small *abbrev_ptr = 0; Dwarf_Small *abbrev_section_end = 0; Dwarf_Half attr = 0; Dwarf_Half attr_form = 0; Dwarf_Abbrev ret_abbrev = 0; Dwarf_Unsigned labbr_count = 0; Dwarf_Unsigned utmp = 0; if (dbg == NULL) { _dwarf_error(NULL, error, DW_DLE_DBG_NULL); return (DW_DLV_ERROR); } if (dbg->de_debug_abbrev.dss_data == 0) { /* Loads abbrev section (and .debug_info as we do those together). */ int res = _dwarf_load_debug_info(dbg, error); if (res != DW_DLV_OK) { return res; } } if (offset >= dbg->de_debug_abbrev.dss_size) { return (DW_DLV_NO_ENTRY); } ret_abbrev = (Dwarf_Abbrev) _dwarf_get_alloc(dbg, DW_DLA_ABBREV, 1); if (ret_abbrev == NULL) { _dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL); return (DW_DLV_ERROR); } ret_abbrev->ab_dbg = dbg; if (returned_abbrev == 0 || abbr_count == 0) { dwarf_dealloc(dbg, ret_abbrev, DW_DLA_ABBREV); _dwarf_error(dbg, error, DW_DLE_DWARF_ABBREV_NULL); return (DW_DLV_ERROR); } *abbr_count = 0; if (length != NULL) *length = 1; abbrev_ptr = dbg->de_debug_abbrev.dss_data + offset; abbrev_section_end = dbg->de_debug_abbrev.dss_data + dbg->de_debug_abbrev.dss_size; DECODE_LEB128_UWORD(abbrev_ptr, utmp); ret_abbrev->ab_code = (Dwarf_Word) utmp; if (ret_abbrev->ab_code == 0) { *returned_abbrev = ret_abbrev; *abbr_count = 0; if (length) { *length = 1; } return (DW_DLV_OK); } DECODE_LEB128_UWORD(abbrev_ptr, utmp); ret_abbrev->ab_tag = utmp; ret_abbrev->ab_has_child = *(abbrev_ptr++); ret_abbrev->ab_abbrev_ptr = abbrev_ptr; do { Dwarf_Unsigned utmp2; DECODE_LEB128_UWORD(abbrev_ptr, utmp2); attr = (Dwarf_Half) utmp2; DECODE_LEB128_UWORD(abbrev_ptr, utmp2); attr_form = (Dwarf_Half) utmp2; if (attr != 0) (labbr_count)++; } while (abbrev_ptr < abbrev_section_end && (attr != 0 || attr_form != 0)); if (abbrev_ptr > abbrev_section_end) { dwarf_dealloc(dbg, ret_abbrev, DW_DLA_ABBREV); _dwarf_error(dbg, error, DW_DLE_ABBREV_DECODE_ERROR); return (DW_DLV_ERROR); } if (length != NULL) *length = abbrev_ptr - dbg->de_debug_abbrev.dss_data - offset; *returned_abbrev = ret_abbrev; *abbr_count = labbr_count; return (DW_DLV_OK); }
false
false
false
false
false
0
AABBTest (dxGeom *o, dReal aabb[6]) { dGeomClass *c = &user_classes[type-dFirstUserClass]; if (c->aabb_test) return c->aabb_test (this,o,aabb); else return 1; }
false
false
false
false
false
0
_gcr_gnupg_records_get_fingerprint (GPtrArray *records) { GcrRecord *record; record = _gcr_records_find (records, GCR_RECORD_SCHEMA_FPR); if (record != NULL) return _gcr_record_get_raw (record, GCR_RECORD_FPR_FINGERPRINT); return NULL; }
false
false
false
false
false
0
print_keydata(kdbe_key_t *keys, unsigned int len) { unsigned int i; for (i = 0; i < len; i++, keys++) { print_key(keys); } }
false
false
false
false
false
0
setup_state (guint n_sources, guint source_types, guint database_state, gpointer *state) { gint i; for (i = 0; i < n_sources; i++) { guint contents = database_state % 7; GvdbTable *table = NULL; gchar *filename; if (contents) { table = dconf_mock_gvdb_table_new (); /* Even numbers get the value setup */ if ((contents & 1) == 0) dconf_mock_gvdb_table_insert (table, "/value", g_variant_new_uint32 (i), NULL); /* Numbers above 2 get the locks table */ if (contents > 2) { GvdbTable *locks; locks = dconf_mock_gvdb_table_new (); /* Numbers above 4 get the lock set */ if (contents > 4) dconf_mock_gvdb_table_insert (locks, "/value", g_variant_new_boolean (TRUE), NULL); dconf_mock_gvdb_table_insert (table, ".locks", NULL, locks); } } if (source_types & (1u << i)) { if (state) { if (table) state[i] = dconf_mock_gvdb_table_ref (table); else state[i] = NULL; } filename = g_strdup_printf ("/etc/dconf/db/db%d", i); } else { if (state) state[i] = g_strdup_printf ("db%d", i); filename = g_strdup_printf ("/HOME/.config/dconf/db%d", i); } dconf_mock_gvdb_install (filename, table); g_free (filename); database_state /= 7; } }
false
false
false
false
false
0
ssl3_InitCompressionContext(ssl3CipherSpec *pwSpec) { /* Setup the compression functions */ switch (pwSpec->compression_method) { case ssl_compression_null: pwSpec->compressor = NULL; pwSpec->decompressor = NULL; pwSpec->compressContext = NULL; pwSpec->decompressContext = NULL; pwSpec->destroyCompressContext = NULL; pwSpec->destroyDecompressContext = NULL; break; #ifdef NSS_ENABLE_ZLIB case ssl_compression_deflate: pwSpec->compressor = ssl3_DeflateCompress; pwSpec->decompressor = ssl3_DeflateDecompress; pwSpec->compressContext = PORT_Alloc(SSL3_DEFLATE_CONTEXT_SIZE); pwSpec->decompressContext = PORT_Alloc(SSL3_DEFLATE_CONTEXT_SIZE); pwSpec->destroyCompressContext = ssl3_DestroyCompressContext; pwSpec->destroyDecompressContext = ssl3_DestroyDecompressContext; ssl3_DeflateInit(pwSpec->compressContext); ssl3_InflateInit(pwSpec->decompressContext); break; #endif /* NSS_ENABLE_ZLIB */ default: PORT_Assert(0); PORT_SetError(SEC_ERROR_LIBRARY_FAILURE); return SECFailure; } return SECSuccess; }
false
false
false
false
false
0
flush_buffer(struct tty_struct *tty) { struct slgt_info *info = tty->driver_data; unsigned long flags; if (sanity_check(info, tty->name, "flush_buffer")) return; DBGINFO(("%s flush_buffer\n", info->device_name)); spin_lock_irqsave(&info->lock, flags); info->tx_count = 0; spin_unlock_irqrestore(&info->lock, flags); tty_wakeup(tty); }
false
false
false
false
false
0
main(int argc, char **argv) { using fst::script::FstClass; using fst::script::MutableFstClass; using fst::script::ArcSort; string usage = "Sorts arcs of an FST.\n\n Usage: "; usage += argv[0]; usage += " [in.fst [out.fst]]\n"; std::set_new_handler(FailedNewHandler); SET_FLAGS(usage.c_str(), &argc, &argv, true); if (argc > 3) { ShowUsage(); return 1; } string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : ""; string out_name = argc > 2 ? argv[2] : ""; MutableFstClass *fst = MutableFstClass::Read(in_name, true); if (!fst) return 1; if (FLAGS_sort_type == "ilabel") { ArcSort(fst, fst::script::ILABEL_COMPARE); } else if (FLAGS_sort_type == "olabel") { ArcSort(fst, fst::script::OLABEL_COMPARE); } else { LOG(ERROR) << argv[0] << ": Unknown sort type \"" << FLAGS_sort_type << "\"\n"; return 1; } fst->Write(out_name); return 0; }
false
false
false
false
false
0
ueConstStrSeek( const char *src, size_t n ) { size_t i = 0; const char *iter = src; for ( i = 0; i < n; i++ ) { iter += ueBytesFromChar( iter[0] ); } return iter; }
false
false
false
false
false
0
forward_socket(struct sockaddr *to, dns_tls_t *tls) { int i, s, port; uint16_t r; /* try 10 times */ for (i = 0; i < 10; i++) { r = xarc4random(&tls->tls_arctx); port = FORWARD_PORT_MIN + (r & 0xf000); if ((s = dns_util_socket(PF_INET, SOCK_DGRAM, port)) > 0) { plog(LOG_DEBUG, "%s: src port = %u", __func__, port); return s; } } return -1; }
false
false
false
false
false
0
try_update_version (NMShellWatcher *watcher) { NMShellWatcherPrivate *priv = watcher->priv; GVariant *v; char *version, *p; v = g_dbus_proxy_get_cached_property (priv->shell_proxy, "ShellVersion"); if (!v) { /* The shell has claimed the name, but not yet registered its interfaces... * (https://bugzilla.gnome.org/show_bug.cgi?id=673182). There's no way * to make GDBusProxy re-read the properties at this point, so we * have to destroy this proxy and try again. */ if (priv->signal_id) { g_signal_handler_disconnect (priv->shell_proxy, priv->signal_id); priv->signal_id = 0; } g_object_unref (priv->shell_proxy); priv->shell_proxy = NULL; priv->retry_timeout = g_timeout_add_seconds (2, retry_create_shell_proxy, watcher); return; } g_warn_if_fail (g_variant_is_of_type (v, G_VARIANT_TYPE_STRING)); version = g_variant_dup_string (v, NULL); if (version) { guint major, minor; major = strtoul (version, &p, 10); if (*p == '.') minor = strtoul (p + 1, NULL, 10); else minor = 0; g_warn_if_fail (major < 256); g_warn_if_fail (minor < 256); priv->shell_version = (major << 8) | minor; priv->shell_version_set = TRUE; g_object_notify (G_OBJECT (watcher), "shell-version"); } g_variant_unref (v); }
false
false
false
false
false
0
is_pte_valid(const gpt_entry *pte, const u64 lastlba) { if ((!efi_guidcmp(pte->partition_type_guid, NULL_GUID)) || le64_to_cpu(pte->starting_lba) > lastlba || le64_to_cpu(pte->ending_lba) > lastlba) return 0; return 1; }
false
false
false
false
false
0
SaveShip(char *shipname) { char *LevelMem; /* linear memory for one Level */ char *MapHeaderString; FILE *ShipFile; // to this file we will save all the ship data... char filename[FILENAME_LEN+1]; int level_anz; int array_i, array_num; int i; DebugPrintf (2, "\nint SaveShip(char *shipname): real function call confirmed."); /* Get the complete filename */ strcpy(filename, shipname); strcat(filename, SHIP_EXT); /* count the levels */ level_anz = 0; while(curShip.AllLevels[level_anz++]); level_anz --; DebugPrintf (2, "\nint SaveShip(char *shipname): now opening the ship file..."); /* open file */ if( (ShipFile = fopen(filename, "w")) == NULL) { printf("\n\nError opening ship file...\n\nTerminating...\n\n"); Terminate(ERR); return ERR; } //-------------------- // Now that the file is opend for writing, we can start writing. And the first thing // we will write to the file will be a fine header, indicating what this file is about // and things like that... // MapHeaderString="\n\ ----------------------------------------------------------------------\n\ This file was generated using the Freedroid level editor.\n\ Please feel free to make any modifications you like, but in order for you\n\ to have an easier time, it is recommended that you use the Freedroid level\n\ editor for this purpose. If you have created some good new maps, please \n\ send a short notice (not too large files attached) to the freedroid project.\n\ \n\ freedroid-discussion@lists.sourceforge.net\n\ ----------------------------------------------------------------------\n\ \n"; fwrite ( MapHeaderString , strlen( MapHeaderString), sizeof(char), ShipFile); // Now we write the area name back into the file fwrite ( AREA_NAME_STRING , strlen( AREA_NAME_STRING ), sizeof(char), ShipFile); fwrite ( curShip.AreaName , strlen( curShip.AreaName ), sizeof(char), ShipFile); fwrite( "\"\n\n ", strlen( "\"\n\n " ) , sizeof(char) , ShipFile ); /* Save all Levels */ DebugPrintf (2, "\nint SaveShip(char *shipname): now saving levels..."); for( i=0; i<level_anz; i++) { //-------------------- // What the heck does this do? // Do we really need this? Why? // array_i =-1; array_num = -1; while( curShip.AllLevels[++array_i] != NULL) { if( curShip.AllLevels[array_i]->levelnum == i) { if( array_num != -1 ) { printf("\n\nIdentical Levelnumber Error in SaveShip...\n\nTerminating\n\n"); Terminate(ERR); return ERR; } else array_num = array_i; } } // while if ( array_num == -1 ) { printf("\n\nMissing Levelnumber error in SaveShip...\n\nTerminating\n\n"); Terminate(ERR); level_anz ++; continue; } //-------------------- // Now comes the real saving part FOR ONE LEVEL. First THE LEVEL is packed into a string and // then this string is wirtten to the file. easy. simple. // LevelMem = StructToMem(curShip.AllLevels[array_num]); fwrite(LevelMem, strlen(LevelMem), sizeof(char), ShipFile); free(LevelMem); } //-------------------- // Now we are almost done writing. Everything that is missing is // the termination string for the ship file. This termination string // is needed later for the ship loading functions to find the end of // the data and to be able to terminate the long file-string with a // null character at the right position. // fwrite( END_OF_SHIP_DATA_STRING , strlen( END_OF_SHIP_DATA_STRING ) , sizeof(char) , ShipFile ); fwrite( "\n\n ", strlen( "\n\n " ) , sizeof(char) , ShipFile ); DebugPrintf (2, "\nint SaveShip(char *shipname): now closing ship file..."); if( fclose(ShipFile) == EOF) { printf("\n\nClosing of ship file failed in SaveShip...\n\nTerminating\n\n"); Terminate(ERR); return ERR; } DebugPrintf (2, "\nint SaveShip(char *shipname): end of function reached."); return OK; }
false
false
false
false
false
0
getCallerSavedRegs(const MachineFunction *MF) const { static const MCPhysReg CallerSavedRegsV4[] = { Hexagon::R0, Hexagon::R1, Hexagon::R2, Hexagon::R3, Hexagon::R4, Hexagon::R5, Hexagon::R6, Hexagon::R7, Hexagon::R8, Hexagon::R9, Hexagon::R10, Hexagon::R11, Hexagon::R12, Hexagon::R13, Hexagon::R14, Hexagon::R15, 0 }; auto &HST = static_cast<const HexagonSubtarget&>(MF->getSubtarget()); switch (HST.getHexagonArchVersion()) { case HexagonSubtarget::V4: case HexagonSubtarget::V5: case HexagonSubtarget::V55: case HexagonSubtarget::V60: return CallerSavedRegsV4; } llvm_unreachable( "Callee saved registers requested for unknown archtecture version"); }
false
false
false
false
false
0
isc_ratelimiter_release(isc_ratelimiter_t *rl) { isc_result_t result = ISC_R_SUCCESS; LOCK(&rl->lock); switch (rl->state) { case isc_ratelimiter_shuttingdown: result = ISC_R_SHUTTINGDOWN; break; case isc_ratelimiter_stalled: if (!ISC_LIST_EMPTY(rl->pending)) { result = isc_timer_reset(rl->timer, isc_timertype_ticker, NULL, &rl->interval, ISC_FALSE); if (result == ISC_R_SUCCESS) rl->state = isc_ratelimiter_ratelimited; } else rl->state = isc_ratelimiter_idle; break; case isc_ratelimiter_ratelimited: case isc_ratelimiter_idle: break; } UNLOCK(&rl->lock); return (result); }
false
false
false
false
false
0
senescent_p (void) { time_t now = time ((time_t *) 0); struct tm *tm = localtime (&now); const char *s = screensaver_id; char mon[4], year[5]; int m, y, months; s = strchr (s, ' '); if (!s) abort(); s++; s = strchr (s, '('); if (!s) abort(); s++; s = strchr (s, '-'); if (!s) abort(); s++; strncpy (mon, s, 3); mon[3] = 0; s = strchr (s, '-'); if (!s) abort(); s++; strncpy (year, s, 4); year[4] = 0; y = atoi (year); if (!strcmp(mon, "Jan")) m = 0; else if (!strcmp(mon, "Feb")) m = 1; else if (!strcmp(mon, "Mar")) m = 2; else if (!strcmp(mon, "Apr")) m = 3; else if (!strcmp(mon, "May")) m = 4; else if (!strcmp(mon, "Jun")) m = 5; else if (!strcmp(mon, "Jul")) m = 6; else if (!strcmp(mon, "Aug")) m = 7; else if (!strcmp(mon, "Sep")) m = 8; else if (!strcmp(mon, "Oct")) m = 9; else if (!strcmp(mon, "Nov")) m = 10; else if (!strcmp(mon, "Dec")) m = 11; else abort(); months = ((((tm->tm_year + 1900) * 12) + tm->tm_mon) - (y * 12 + m)); return (months > 12); }
false
false
false
false
false
0
init_ldap_userdir(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s) { for (; s; s = s->next) { ldap_userdir_config *s_cfg = (ldap_userdir_config *) ap_get_module_config(s->module_config, &ldap_userdir_module); apply_config_defaults(s_cfg); } ap_add_version_component(pconf, "mod_ldap_userdir/1.1.19"); return OK; }
false
false
false
false
false
0