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
omninet_write(struct tty_struct *tty, struct usb_serial_port *port, const unsigned char *buf, int count) { struct usb_serial *serial = port->serial; struct usb_serial_port *wport = serial->port[1]; struct omninet_data *od = usb_get_serial_port_data(port); struct omninet_header *header = (struct omninet_header *) wport->write_urb->transfer_buffer; int result; if (count == 0) { dev_dbg(&port->dev, "%s - write request of 0 bytes\n", __func__); return 0; } if (!test_and_clear_bit(0, &port->write_urbs_free)) { dev_dbg(&port->dev, "%s - already writing\n", __func__); return 0; } count = (count > OMNINET_PAYLOADSIZE) ? OMNINET_PAYLOADSIZE : count; memcpy(wport->write_urb->transfer_buffer + OMNINET_HEADERLEN, buf, count); usb_serial_debug_data(&port->dev, __func__, count, wport->write_urb->transfer_buffer); header->oh_seq = od->od_outseq++; header->oh_len = count; header->oh_xxx = 0x03; header->oh_pad = 0x00; /* send the data out the bulk port, always 64 bytes */ wport->write_urb->transfer_buffer_length = OMNINET_BULKOUTSIZE; result = usb_submit_urb(wport->write_urb, GFP_ATOMIC); if (result) { set_bit(0, &wport->write_urbs_free); dev_err_console(port, "%s - failed submitting write urb, error %d\n", __func__, result); } else result = count; return result; }
false
false
false
false
false
0
reg_r(struct gspca_dev *gspca_dev, u16 reg) { struct usb_device *udev = gspca_dev->dev; int ret; if (gspca_dev->usb_err < 0) return 0; ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x01, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, 0x00, reg, gspca_dev->usb_buf, 1, CTRL_TIMEOUT); PDEBUG(D_USBI, "reg_r [%04x] -> %02x", reg, gspca_dev->usb_buf[0]); if (ret < 0) { pr_err("reg_r err %d\n", ret); gspca_dev->usb_err = ret; } return gspca_dev->usb_buf[0]; }
false
false
false
false
false
0
average_add(struct average *avg, s16 val) { avg->sum -= avg->entries[avg->pos]; avg->sum += val; avg->entries[avg->pos++] = val; if (unlikely(avg->pos == AVG_ENTRIES)) { avg->init = 1; avg->pos = 0; } }
false
false
false
false
false
0
get_timeout_interval(void) { const char *svalue; get_pref(PREF_TIME, NULL, &svalue); if (strstr(svalue,"%S")) return CLOCK_TICK; else return 60*CLOCK_TICK; }
false
false
false
false
false
0
fso_framework_bin_builder_uint32_convert (FsoFrameworkBinBuilder* self, guint32 val) { guint32 result = 0U; GDataStreamByteOrder _tmp0_ = 0; g_return_val_if_fail (self != NULL, 0U); _tmp0_ = self->priv->_endianess; if (_tmp0_ == G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN) { guint32 _tmp1_ = 0U; guint32 _tmp2_ = 0U; _tmp1_ = val; _tmp2_ = GUINT32_TO_BE (_tmp1_); result = _tmp2_; return result; } else { GDataStreamByteOrder _tmp3_ = 0; _tmp3_ = self->priv->_endianess; if (_tmp3_ == G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN) { guint32 _tmp4_ = 0U; guint32 _tmp5_ = 0U; _tmp4_ = val; _tmp5_ = GUINT32_TO_LE (_tmp4_); result = _tmp5_; return result; } else { guint32 _tmp6_ = 0U; _tmp6_ = val; result = _tmp6_; return result; } } }
false
false
false
false
false
0
ldrd_strd_offset_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED) { return (const_int_operand (op, mode)) && ( #line 170 "../../src/gcc/config/arm/predicates.md" (TARGET_LDRD && offset_ok_for_ldrd_strd (INTVAL (op)))); }
false
false
false
false
false
0
simplify(const Expr& e) { //TODO: add to interactive interface return simplifyThm(e).getRHS(); }
false
false
false
false
false
0
mixer_set_sample_frequency(int ch, int freq) { struct mixer_channel_data *channel = &mixer_channel[ch]; assert( !channel->is_stream ); if (channel->is_playing) { mixerlogerror(("Mixer:mixer_set_sample_frequency(%s,%d)\n",channel->name,freq)); mixer_update_channel(channel, sound_scalebufferpos(samples_this_frame)); mixer_channel_resample_set(channel,freq,channel->request_lowpass_frequency,0); } }
false
false
false
false
false
0
notifyDisplaySizeChanged(const Size& size) { d_horzScaling = size.d_width / d_nativeHorzRes; d_vertScaling = size.d_height / d_nativeVertRes; if (d_autoScale) updateFont(); }
false
false
false
false
false
0
xmmsc_playlist_insert_args (xmmsc_connection_t *c, const char *playlist, int pos, const char *url, int numargs, const char **args) { xmmsc_result_t *res; char *enc_url; x_check_conn (c, NULL); x_api_error_if (!url, "with a NULL url", NULL); enc_url = _xmmsc_medialib_encode_url_old (url, numargs, args); if (!enc_url) return NULL; res = xmmsc_playlist_insert_encoded (c, playlist, pos, enc_url); free (enc_url); return res; }
false
false
false
false
false
0
Do(OBBase* pOb, const char* OptionText, OpMap* pmap, OBConversion* pConv=NULL) { OBMol* pmol = dynamic_cast<OBMol*>(pOb); if(!pmol) return false; if(pConv->IsFirstInput()) { pConv->AddOption("writeconformers", OBConversion::GENOPTIONS); rmsd_cutoff = 0.5; energy_cutoff = 50.0; conf_cutoff = 1000000; // 1 Million verbose = false; include_original = false; OpMap::const_iterator iter; iter = pmap->find("rcutoff"); if(iter!=pmap->end()) rmsd_cutoff = atof(iter->second.c_str()); iter = pmap->find("ecutoff"); if(iter!=pmap->end()) energy_cutoff = atof(iter->second.c_str()); iter = pmap->find("conf"); if(iter!=pmap->end()) conf_cutoff = atoi(iter->second.c_str()); iter = pmap->find("verbose"); if(iter!=pmap->end()) verbose = true; iter = pmap->find("original"); if(iter!=pmap->end()) include_original = true; cout << "**Starting Confab " << CONFAB_VER << "\n"; cout << "**To support, cite Journal of Cheminformatics, 2011, 3, 8.\n"; pff = OpenBabel::OBForceField::FindType("mmff94"); if (!pff) { cout << "!!Cannot find forcefield!" << endl; exit(-1); } DisplayConfig(pConv); } Run(pConv, pmol); return false; }
false
false
false
false
false
0
ssl_ConfigSecureServer(sslSocket *ss, CERTCertificate *cert, const CERTCertificateList *certChain, ssl3KeyPair *keyPair, SSLKEAType kea) { CERTCertificateList *localCertChain = NULL; sslServerCerts *sc = ss->serverCerts + kea; /* load the server certificate */ if (sc->serverCert != NULL) { CERT_DestroyCertificate(sc->serverCert); sc->serverCert = NULL; sc->serverKeyBits = 0; } /* load the server cert chain */ if (sc->serverCertChain != NULL) { CERT_DestroyCertificateList(sc->serverCertChain); sc->serverCertChain = NULL; } if (cert) { sc->serverCert = CERT_DupCertificate(cert); /* get the size of the cert's public key, and remember it */ sc->serverKeyBits = SECKEY_PublicKeyStrengthInBits(keyPair->pubKey); if (!certChain) { localCertChain = CERT_CertChainFromCert(sc->serverCert, certUsageSSLServer, PR_TRUE); if (!localCertChain) goto loser; } sc->serverCertChain = (certChain) ? CERT_DupCertList(certChain) : localCertChain; if (!sc->serverCertChain) { goto loser; } localCertChain = NULL; /* consumed */ } /* get keyPair */ if (sc->serverKeyPair != NULL) { ssl3_FreeKeyPair(sc->serverKeyPair); sc->serverKeyPair = NULL; } if (keyPair) { SECKEY_CacheStaticFlags(keyPair->privKey); sc->serverKeyPair = ssl3_GetKeyPairRef(keyPair); } if (kea == kt_rsa && cert && sc->serverKeyBits > 512 && !ss->opt.noStepDown && !ss->stepDownKeyPair) { if (ssl3_CreateRSAStepDownKeys(ss) != SECSuccess) { goto loser; } } return SECSuccess; loser: if (localCertChain) { CERT_DestroyCertificateList(localCertChain); } if (sc->serverCert != NULL) { CERT_DestroyCertificate(sc->serverCert); sc->serverCert = NULL; } if (sc->serverCertChain != NULL) { CERT_DestroyCertificateList(sc->serverCertChain); sc->serverCertChain = NULL; } if (sc->serverKeyPair != NULL) { ssl3_FreeKeyPair(sc->serverKeyPair); sc->serverKeyPair = NULL; } return SECFailure; }
false
false
false
false
false
0
sepdp_get_tag_file(const pdp_ctx_t* ctx, unsigned int index, void *buf, unsigned int *len) { pdp_sepdp_tag_t **tag_ptr = (pdp_sepdp_tag_t **) buf; pdp_sepdp_tag_t *tag = NULL; static FILE* tagfile = NULL; unsigned char *data = NULL; unsigned int data_len = 0; int status = -1; // If buf is NULL, it is a signal to re-set the stateful variables if (!buf && tagfile) { fclose(tagfile); tagfile = NULL; return 0; } if (!ctx || !tag_ptr) return -1; // if file is not open already, open it if (!tagfile && ((tagfile = fopen(ctx->ofilepath, "r")) == NULL)) { PDP_ERR("%d", ferror(tagfile)); PDP_ERR("unable to open %s", ctx->ofilepath); return -1; } // Allocate space for the tag if ((tag = malloc(sizeof(pdp_sepdp_tag_t))) == NULL) goto cleanup; memset(tag, 0, sizeof(pdp_sepdp_tag_t)); if (*tag_ptr != NULL) { // there is already a tag here, so free it sepdp_tag_free(ctx, *tag_ptr); } *tag_ptr = tag; data_len = sepdp_serialized_tag_size(ctx); if ((data = malloc(data_len)) == NULL) goto cleanup; memset(data, 0, data_len); // We seek directly to the index of the i-th tag if (fseek(tagfile, index * data_len, SEEK_SET) < 0) goto cleanup; fread(data, 1, data_len, tagfile); if (ferror(tagfile)) goto cleanup; // de-serialize the data block if (sepdp_deserialize_tag(ctx, tag, data, data_len) != 0) goto cleanup; status = 0; cleanup: sfree(data, data_len); if (status && tag_ptr && *tag_ptr) { sepdp_tag_free(ctx, *tag_ptr); *tag_ptr = NULL; } return status; }
false
false
false
false
true
1
really_clear_connection(connecttab * c, struct timeval *tvP) { stats_bytes += c->hc->bytes_sent; if (c->conn_state != CNST_PAUSING) fdwatch_del_fd(c->hc->conn_fd); httpd_close_conn(c->hc, tvP); clear_throttles(c, tvP); if (c->linger_timer != (Timer *) 0) { tmr_cancel(c->linger_timer); c->linger_timer = 0; } c->conn_state = CNST_FREE; c->next_free_connect = first_free_connect; first_free_connect = c - connects; /* division by sizeof is * implied */ --num_connects; }
false
false
false
false
false
0
rend_client_report_intro_point_failure(extend_info_t *failed_intro, const rend_data_t *rend_query, unsigned int failure_type) { int i, r; rend_cache_entry_t *ent; connection_t *conn; r = rend_cache_lookup_entry(rend_query->onion_address, -1, &ent); if (r<0) { log_warn(LD_BUG, "Malformed service ID %s.", escaped_safe_str_client(rend_query->onion_address)); return -1; } if (r==0) { log_info(LD_REND, "Unknown service %s. Re-fetching descriptor.", escaped_safe_str_client(rend_query->onion_address)); rend_client_refetch_v2_renddesc(rend_query); return 0; } for (i = 0; i < smartlist_len(ent->parsed->intro_nodes); i++) { rend_intro_point_t *intro = smartlist_get(ent->parsed->intro_nodes, i); if (tor_memeq(failed_intro->identity_digest, intro->extend_info->identity_digest, DIGEST_LEN)) { switch (failure_type) { default: log_warn(LD_BUG, "Unknown failure type %u. Removing intro point.", failure_type); tor_fragile_assert(); /* fall through */ case INTRO_POINT_FAILURE_GENERIC: rend_intro_point_free(intro); smartlist_del(ent->parsed->intro_nodes, i); break; case INTRO_POINT_FAILURE_TIMEOUT: intro->timed_out = 1; break; case INTRO_POINT_FAILURE_UNREACHABLE: ++(intro->unreachable_count); { int zap_intro_point = intro->unreachable_count >= MAX_INTRO_POINT_REACHABILITY_FAILURES; log_info(LD_REND, "Failed to reach this intro point %u times.%s", intro->unreachable_count, zap_intro_point ? " Removing from descriptor.": ""); if (zap_intro_point) { rend_intro_point_free(intro); smartlist_del(ent->parsed->intro_nodes, i); } } break; } break; } } if (! rend_client_any_intro_points_usable(ent)) { log_info(LD_REND, "No more intro points remain for %s. Re-fetching descriptor.", escaped_safe_str_client(rend_query->onion_address)); rend_client_refetch_v2_renddesc(rend_query); /* move all pending streams back to renddesc_wait */ while ((conn = connection_get_by_type_state_rendquery(CONN_TYPE_AP, AP_CONN_STATE_CIRCUIT_WAIT, rend_query->onion_address))) { conn->state = AP_CONN_STATE_RENDDESC_WAIT; } return 0; } log_info(LD_REND,"%d options left for %s.", smartlist_len(ent->parsed->intro_nodes), escaped_safe_str_client(rend_query->onion_address)); return 1; }
false
false
false
false
false
0
Vect_cidx_find_next(struct Map_info *Map, int field_index, int cat, int type_mask, int start_index, int *type, int *id) { int *catp, cat_index; struct Cat_index *ci; G_debug(3, "Vect_cidx_find_next() cat = %d, type_mask = %d, start_index = %d", cat, type_mask, start_index); check_status(Map); /* This check is slow ? */ *type = *id = 0; if (field_index >= Map->plus.n_cidx) G_fatal_error(_("Layer index out of range")); if (start_index < 0) start_index = 0; if (start_index >= Map->plus.cidx[field_index].n_cats) return -1; /* outside range */ /* pointer to beginning of searched part of category index */ ci = &(Map->plus.cidx[field_index]); /* calc with pointers is using sizeof(int) !!! */ catp = bsearch(&cat, (int *)ci->cat + start_index * 3, (size_t) ci->n_cats - start_index, 3 * sizeof(int), cmp_cat); G_debug(3, "catp = %p", catp); if (!catp) return -1; /* get index from pointer, the difference between pointers is using sizeof(int) !!! */ cat_index = (catp - (int *)ci->cat) / 3; G_debug(4, "cat_index = %d", cat_index); /* Go down to the first if multiple */ while (cat_index > start_index) { if (ci->cat[cat_index - 1][0] != cat) { break; } cat_index--; } G_debug(4, "cat_index = %d", cat_index); do { G_debug(3, " cat_index = %d", cat_index); if (ci->cat[cat_index][0] == cat && ci->cat[cat_index][1] & type_mask) { *type = ci->cat[cat_index][1]; *id = ci->cat[cat_index][2]; G_debug(3, " type match -> record found"); return cat_index; } cat_index++; } while (cat_index < ci->n_cats); return -1; }
false
false
false
false
false
0
remove_file_source (FileSource *source, gboolean abort_transfers) { FileteaNode *self = FILETEA_NODE (source->node); g_hash_table_remove (self->priv->sources_by_id, source->id); if (abort_transfers) { /* @TODO */ } }
false
false
false
false
false
0
drxk_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) { struct drxk_state *state = fe->demodulator_priv; u16 err; dprintk(1, "\n"); if (state->m_drxk_state == DRXK_NO_DEV) return -ENODEV; if (state->m_drxk_state == DRXK_UNINITIALIZED) return -EAGAIN; dvbtqam_get_acc_pkt_err(state, &err); *ucblocks = (u32) err; return 0; }
false
false
false
false
false
0
ipw_ethtool_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom, u8 * bytes) { struct ipw_priv *p = libipw_priv(dev); int i; if (eeprom->offset + eeprom->len > IPW_EEPROM_IMAGE_SIZE) return -EINVAL; mutex_lock(&p->mutex); memcpy(&p->eeprom[eeprom->offset], bytes, eeprom->len); for (i = 0; i < IPW_EEPROM_IMAGE_SIZE; i++) ipw_write8(p, i + IPW_EEPROM_DATA, p->eeprom[i]); mutex_unlock(&p->mutex); return 0; }
false
false
false
false
false
0
StartRestoreBlob(ArchiveHandle *AH, Oid oid, bool drop) { bool old_blob_style = (AH->version < K_VERS_1_12); Oid loOid; AH->blobCount++; /* Initialize the LO Buffer */ AH->lo_buf_used = 0; ahlog(AH, 1, "restoring large object with OID %u\n", oid); /* With an old archive we must do drop and create logic here */ if (old_blob_style && drop) DropBlobIfExists(AH, oid); if (AH->connection) { if (old_blob_style) { loOid = lo_create(AH->connection, oid); if (loOid == 0 || loOid != oid) exit_horribly(modulename, "could not create large object %u: %s", oid, PQerrorMessage(AH->connection)); } AH->loFd = lo_open(AH->connection, oid, INV_WRITE); if (AH->loFd == -1) exit_horribly(modulename, "could not open large object %u: %s", oid, PQerrorMessage(AH->connection)); } else { if (old_blob_style) ahprintf(AH, "SELECT pg_catalog.lo_open(pg_catalog.lo_create('%u'), %d);\n", oid, INV_WRITE); else ahprintf(AH, "SELECT pg_catalog.lo_open('%u', %d);\n", oid, INV_WRITE); } AH->writingBlob = 1; }
false
false
false
false
false
0
drawArcAsBezier(double alpha) { // Vector p0(1.0, 0.0); Vector p1(1.0, BETA); Vector p2(BETA, 1.0); Vector p3(0.0, 1.0); Vector q1(-BETA, 1.0); Vector q2(-1.0, BETA); Vector q3(-1.0, 0.0); double begAngle = 0.0; if (alpha > IpeHalfPi) { curveTo(p1, p2, p3); begAngle = IpeHalfPi; } if (alpha > IpePi) { curveTo(q1, q2, q3); begAngle = IpePi; } if (alpha > PI15) { curveTo(-p1, -p2, -p3); begAngle = PI15; } if (alpha >= IpeTwoPi) { curveTo(-q1, -q2, -q3); } else { alpha -= begAngle; double alpha2 = alpha / 2.0; double divi = 3.0 * sin(alpha2); if (divi == 0.0) return; // alpha2 is close to zero double beta = 4.0 * (1.0 - cos(alpha2)) / divi; Linear m = Linear(Angle(begAngle)); Vector pp1(1.0, beta); Vector pp2 = Linear(Angle(alpha)) * Vector(1.0, -beta); Vector pp3 = Vector(Angle(alpha)); curveTo(m * pp1, m * pp2, m * pp3); } }
false
false
false
false
false
0
GetLoginName() { char* login_name; if (!(login_name = getenv("LOGNAME")) && !(login_name = getlogin()) && !(login_name = getenv("USER"))) { struct passwd * passwd_entry = getpwuid(getuid()); if (!passwd_entry) passwd_entry = getpwuid(geteuid()); login_name = passwd_entry ? passwd_entry->pw_name : (char*) "nobody"; } return login_name; }
false
false
false
false
false
0
mps_route_wpt_w_unique_wrapper(const waypoint* wpt) { waypoint* wptfound = NULL; /* Search for this waypoint in the ones already written */ wptfound = mps_find_wpt_q_by_name(&written_wpt_head, wpt->shortname); if (wptfound == NULL) /* so, not a real wpt, so must check route wpts already written as reals */ { wptfound = mps_find_wpt_q_by_name(&written_route_wpt_head, wpt->shortname); } /* if this waypoint hasn't been written then it is okay to do so but assume it is only required for the route */ if (wptfound == NULL) { /* Although we haven't written one out, this might still be a "real" waypoint If so, we need to write it out now accordingly */ wptfound = find_waypt_by_name(wpt->shortname); if (wptfound == NULL) { /* well, we tried to find: it wasn't written and isn't a real waypoint */ mps_waypoint_w(mps_file_out, mps_ver_out, wpt, (1==1)); mps_wpt_q_add(&written_route_wpt_head, wpt); } else { mps_waypoint_w(mps_file_out, mps_ver_out, wpt, (1==0)); /* Simulated real user waypoint */ mps_wpt_q_add(&written_wpt_head, wpt); } } }
false
false
false
false
false
0
modem_hw_off(const char* pm_base_dir) { LOG(LOG_DEBUG, "Enter"); SYSCHECK(modem_hw_(pm_base_dir, "power_on", 0)); SYSCHECK(modem_hw_(pm_base_dir, "reset", 0)); LOG(LOG_DEBUG, "Leave"); return 0; }
false
false
false
false
false
0
getAllNames() const { OFVector<tstring> tmp; { thread::MutexGuard guard (mutex); for(ObjectMap::const_iterator it=data.begin(); it!=data.end(); ++it) tmp.push_back( (*it).first ); } return tmp; }
false
false
false
false
false
0
slotSignFile() { if (!m_keysRead || m_gpgRunning) { QTimer::singleShot(5, this, SLOT(slotSignFile())); return; } QStringList secretKeys; for (QMap<QString, KeyStruct>::Iterator it = m_keys.begin(); it != m_keys.end(); ++it) { if (it.value().secret) secretKeys.append(it.key()); } if (secretKeys.count() == 0) { emit fileSigned(-1); return; } m_result = 0; QFileInfo f(m_fileName); //create the MD5 sum QString md5sum; const char* c = ""; KMD5 context(c); QFile file(m_fileName); if (file.open(QIODevice::ReadOnly)) { context.reset(); context.update(file); md5sum = context.hexDigest(); file.close(); } file.setFileName(f.path() + "/md5sum"); if (file.open(QIODevice::WriteOnly)) { QTextStream stream(&file); stream << md5sum; m_result |= MD5_OK; file.close(); } if (secretKeys.count() > 1) { bool ok; secretKeys = KInputDialog::getItemList(i18n("Select Signing Key"), i18n("Key used for signing:"), secretKeys, QStringList(secretKeys[0]), false, &ok); if (ok) m_secretKey = secretKeys[0]; else { emit fileSigned(0); return; } } else m_secretKey = secretKeys[0]; //verify the signature m_process = new KProcess(); *m_process << "gpg" << "--no-secmem-warning" << "--status-fd=2" << "--command-fd=0" << "--no-tty" << "--detach-sign" << "-u" << m_secretKey << "-o" << f.path() + "/signature" << m_fileName; connect(m_process, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(slotFinished(int,QProcess::ExitStatus))); connect(m_process, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadyReadStandardOutput())); m_runMode = Sign; m_process->start(); if (m_process->waitForStarted()) m_gpgRunning = true; else { KMessageBox::error(0L, i18n("<qt>Cannot start <i>gpg</i> and sign the file. Make sure that <i>gpg</i> is installed, otherwise signing of the resources will not be possible.</qt>")); emit fileSigned(0); delete m_process; m_process = 0; } }
false
false
false
false
false
0
job_container_init(void) { int retval = SLURM_SUCCESS; char *plugin_type = "job_container"; char *container_plugin_type = NULL; char *last = NULL, *job_container_plugin_list, *job_container = NULL; if (init_run && (g_container_context_num >= 0)) return retval; slurm_mutex_lock(&g_container_context_lock); if (g_container_context_num >= 0) goto done; container_plugin_type = slurm_get_job_container_plugin(); g_container_context_num = 0; /* mark it before anything else */ if ((container_plugin_type == NULL) || (container_plugin_type[0] == '\0')) goto done; job_container_plugin_list = container_plugin_type; while ((job_container = strtok_r(job_container_plugin_list, ",", &last))) { xrealloc(ops, sizeof(job_container_ops_t) * (g_container_context_num + 1)); xrealloc(g_container_context, (sizeof(plugin_context_t *) * (g_container_context_num + 1))); if (strncmp(job_container, "job_container/", 14) == 0) job_container += 14; /* backward compatibility */ job_container = xstrdup_printf("job_container/%s", job_container); g_container_context[g_container_context_num] = plugin_context_create( plugin_type, job_container, (void **)&ops[g_container_context_num], syms, sizeof(syms)); if (!g_container_context[g_container_context_num]) { error("cannot create %s context for %s", plugin_type, job_container); xfree(job_container); retval = SLURM_ERROR; break; } xfree(job_container); g_container_context_num++; job_container_plugin_list = NULL; /* for next iteration */ } init_run = true; done: slurm_mutex_unlock(&g_container_context_lock); xfree(container_plugin_type); if (retval != SLURM_SUCCESS) job_container_fini(); return retval; }
false
false
false
false
false
0
keep_voltages() { if (!_freezetime) { for (int ii = 1; ii <= _total_nodes; ++ii) { _vdc[ii] = _v0[ii]; } _last_time = (_time0 > 0.) ? _time0 : 0.; }else{untested(); } }
false
false
false
false
false
0
replaceNeighbour(rcRegion& reg, unsigned short oldId, unsigned short newId) { bool neiChanged = false; for (int i = 0; i < reg.connections.size(); ++i) { if (reg.connections[i] == oldId) { reg.connections[i] = newId; neiChanged = true; } } for (int i = 0; i < reg.floors.size(); ++i) { if (reg.floors[i] == oldId) reg.floors[i] = newId; } if (neiChanged) removeAdjacentNeighbours(reg); }
false
false
false
false
false
0
xdrrec_putbytes(XDR *xdrs, caddr_t addr, u_int len) { register RECSTREAM *rstrm = (RECSTREAM *)(xdrs->x_private); register size_t current; while (len > 0) { current = (size_t) ((long)rstrm->out_boundry - (long)rstrm->out_finger); current = (len < current) ? len : current; memmove(rstrm->out_finger, addr, current); rstrm->out_finger += current; addr += current; len -= current; if (rstrm->out_finger == rstrm->out_boundry) { rstrm->frag_sent = TRUE; if (! flush_out(rstrm, FALSE)) return (FALSE); } } return (TRUE); }
false
false
false
false
false
0
applyConfiguration() { Configuration& config = Persistent<Configuration>( "settings" ); QFont font = config.mainFont(); LOG(logDEBUG) << "CrawlerWidget::applyConfiguration"; // Whatever font we use, we should NOT use kerning font.setKerning( false ); font.setFixedPitch( true ); #if QT_VERSION > 0x040700 // Necessary on systems doing subpixel positionning (e.g. Ubuntu 12.04) font.setStyleStrategy( QFont::ForceIntegerMetrics ); #endif logMainView->setFont(font); filteredView->setFont(font); logMainView->setLineNumbersVisible( config.mainLineNumbersVisible() ); filteredView->setLineNumbersVisible( config.filteredLineNumbersVisible() ); overview_->setVisible( config.isOverviewVisible() ); logMainView->refreshOverview(); logMainView->updateDisplaySize(); logMainView->update(); filteredView->updateDisplaySize(); filteredView->update(); // Update the SearchLine (history) updateSearchCombo(); }
false
false
false
false
false
0
checkSizes (lua_State *L, global_State *g) { if (g->gckind != KGC_EMERGENCY) { l_mem olddebt = g->GCdebt; luaZ_freebuffer(L, &g->buff); /* free concatenation buffer */ if (g->strt.nuse < g->strt.size / 4) /* string table too big? */ luaS_resize(L, g->strt.size / 2); /* shrink it a little */ g->GCestimate += g->GCdebt - olddebt; /* update estimate */ } }
false
false
false
false
false
0
CmdSoundSequence(void) { mobj_t *mobj; mobj = NULL; if (ACScript->line) { mobj = (mobj_t *) & ACScript->line->frontsector->soundorg; } SN_StartSequenceName(mobj, ACStrings[Pop()]); return SCRIPT_CONTINUE; }
false
false
false
false
false
0
read_entry_data_values(int old_data_buffer_size, int new_data_buffer_size, int data_count, int* data_sizes, int& read_count) { if (data_count == 0) { read_count = 0; return true; } // Default data value sizes (for logical and numeric data) for (int i = 0; i < data_count; i++) data_sizes[i] = 1; // Character data if ( flags->readingProcedureName || currentBufferType == LibFront::EMF_STRING || currentBufferType == LibFront::EMF_FILE ) { if ( !read_string_data(old_data_buffer_size, new_data_buffer_size, data_count, data_sizes, read_count) ) { return false; } // Logical data } else if ( currentBufferType == LibFront::EMF_LOGICAL ) { if ( !read_logical_data(old_data_buffer_size, new_data_buffer_size, read_count) ) { return false; } // Numeric data } else { if ( !read_numeric_data(old_data_buffer_size, new_data_buffer_size, read_count) ) { return false; } } return true; }
false
false
false
false
false
0
ovSetRegion( CoreLayer *layer, void *driver_data, void *layer_data, void *region_data, CoreLayerRegionConfig *config, CoreLayerRegionConfigFlags updated, CoreSurface *surface, CorePalette *palette, CoreSurfaceBufferLock *lock ) { Mach64DriverData *mdrv = (Mach64DriverData*) driver_data; Mach64OverlayLayerData *mov = (Mach64OverlayLayerData*) layer_data; /* remember configuration */ mov->config = *config; if (updated == CLRCF_ALL) ov_reset( mdrv ); if (updated & (CLRCF_WIDTH | CLRCF_HEIGHT | CLRCF_FORMAT | CLRCF_SOURCE | CLRCF_DEST | CLRCF_OPTIONS)) { ov_calc_buffer( mdrv, mov, config, surface, lock ); ov_calc_regs( mdrv, mov, config, surface, lock ); ov_set_buffer( mdrv, mov ); ov_set_regs( mdrv, mov ); } if (updated & (CLRCF_OPTIONS | CLRCF_SRCKEY | CLRCF_DSTKEY)) { ov_calc_colorkey( mdrv, mov, config ); ov_set_colorkey( mdrv, mov ); } if (updated & CLRCF_OPTIONS) ov_set_field( mdrv, mov ); if (updated & (CLRCF_DEST | CLRCF_OPACITY)) { ov_calc_opacity( mdrv, mov, config ); ov_set_opacity( mdrv, mov ); } return DFB_OK; }
false
false
false
false
false
0
createPPCMCCodeGenInfo(StringRef TT, Reloc::Model RM, CodeModel::Model CM) { MCCodeGenInfo *X = new MCCodeGenInfo(); if (RM == Reloc::Default) { Triple T(TT); if (T.isOSDarwin()) RM = Reloc::DynamicNoPIC; else RM = Reloc::Static; } X->InitMCCodeGenInfo(RM, CM); return X; }
false
false
false
false
false
0
ath3k_init(int fd, int speed, int init_speed, char *bdaddr, struct termios *ti) { int r; int err = 0; struct timespec tm = { 0, 500000 }; unsigned char cmd[MAX_CMD_LEN], rsp[HCI_MAX_EVENT_SIZE]; unsigned char *ptr = cmd + 1; hci_command_hdr *ch = (void *)ptr; cmd[0] = HCI_COMMAND_PKT; /* set both controller and host baud rate to maximum possible value */ err = set_cntrlr_baud(fd, speed); if (err < 0) return err; err = set_speed(fd, ti, speed); if (err < 0) { perror("Can't set required baud rate"); return err; } /* Download PS and patch */ r = ath_ps_download(fd); if (r < 0) { perror("Failed to Download configuration"); err = -ETIMEDOUT; goto failed; } /* Write BDADDR */ if (bdaddr) { ch->opcode = htobs(cmd_opcode_pack(HCI_VENDOR_CMD_OGF, HCI_PS_CMD_OCF)); ch->plen = 10; ptr += HCI_COMMAND_HDR_SIZE; ptr[0] = 0x01; ptr[1] = 0x01; ptr[2] = 0x00; ptr[3] = 0x06; str2ba(bdaddr, (bdaddr_t *)(ptr + 4)); if (write(fd, cmd, WRITE_BDADDR_CMD_LEN) != WRITE_BDADDR_CMD_LEN) { perror("Failed to write BD_ADDR command\n"); err = -ETIMEDOUT; goto failed; } if (read_hci_event(fd, rsp, sizeof(rsp)) < 0) { perror("Failed to set BD_ADDR\n"); err = -ETIMEDOUT; goto failed; } } /* Send HCI Reset */ cmd[1] = 0x03; cmd[2] = 0x0C; cmd[3] = 0x00; r = write(fd, cmd, 4); if (r != 4) { err = -ETIMEDOUT; goto failed; } nanosleep(&tm, NULL); if (read_hci_event(fd, rsp, sizeof(rsp)) < 0) { err = -ETIMEDOUT; goto failed; } err = set_cntrlr_baud(fd, speed); if (err < 0) return err; failed: if (err < 0) { set_cntrlr_baud(fd, init_speed); set_speed(fd, ti, init_speed); } return err; }
false
false
false
false
false
0
ch_ai_hdy (init_data, detected, easter, year, hd_elems, fday, count) Bool *init_data; const Bool detected; int easter; const int year; int *hd_elems; const int fday; const int count; /* Manages all specific holidays celebrated in Switzerland/Appenzell-Innerrhoden. */ { if (!use_other_cc) { ptr_cc_id = "CH_AI"; ch_base_hdy (init_data, detected, easter, year, hd_elems, fday, count); } holiday (*init_data, detected, _(hd_text[HD_ALL_SAINTS_DAY].ht_text), ptr_cc_id, "+", DAY_MIN, 11, year, hd_elems, fday, count); holiday (*init_data, detected, _(hd_text[HD_FEAST_OF_CORPUS_CHRISTI].ht_text), ptr_cc_id, "+", easter + 60, 0, year, hd_elems, fday, count); holiday (*init_data, detected, _(hd_text[HD_MARYS_ASCENSION_DAY].ht_text), ptr_cc_id, "+", 15, 8, year, hd_elems, fday, count); holiday (*init_data, detected, _(hd_text[HD_MARYS_IMMACULATE_CONCEPTION].ht_text), ptr_cc_id, "+", 8, MONTH_MAX, year, hd_elems, fday, count); }
false
false
false
false
false
0
poly_basis_fn(ssize_t n, double x, double y) { /* Return the result for this polynomial term */ switch(n) { case 0: return( 1.0 ); /* constant */ case 1: return( x ); case 2: return( y ); /* affine order = 1 terms = 3 */ case 3: return( x*y ); /* bilinear order = 1.5 terms = 4 */ case 4: return( x*x ); case 5: return( y*y ); /* quadratic order = 2 terms = 6 */ case 6: return( x*x*x ); case 7: return( x*x*y ); case 8: return( x*y*y ); case 9: return( y*y*y ); /* cubic order = 3 terms = 10 */ case 10: return( x*x*x*x ); case 11: return( x*x*x*y ); case 12: return( x*x*y*y ); case 13: return( x*y*y*y ); case 14: return( y*y*y*y ); /* quartic order = 4 terms = 15 */ case 15: return( x*x*x*x*x ); case 16: return( x*x*x*x*y ); case 17: return( x*x*x*y*y ); case 18: return( x*x*y*y*y ); case 19: return( x*y*y*y*y ); case 20: return( y*y*y*y*y ); /* quintic order = 5 terms = 21 */ } return( 0 ); /* should never happen */ }
false
false
false
false
false
0
tifm_sd_end_cmd(unsigned long data) { struct tifm_sd *host = (struct tifm_sd*)data; struct tifm_dev *sock = host->dev; struct mmc_host *mmc = tifm_get_drvdata(sock); struct mmc_request *mrq; struct mmc_data *r_data = NULL; unsigned long flags; spin_lock_irqsave(&sock->lock, flags); del_timer(&host->timer); mrq = host->req; host->req = NULL; if (!mrq) { pr_err(" %s : no request to complete?\n", dev_name(&sock->dev)); spin_unlock_irqrestore(&sock->lock, flags); return; } r_data = mrq->cmd->data; if (r_data) { if (host->no_dma) { writel((~TIFM_MMCSD_BUFINT) & readl(sock->addr + SOCK_MMCSD_INT_ENABLE), sock->addr + SOCK_MMCSD_INT_ENABLE); } else { tifm_unmap_sg(sock, &host->bounce_buf, 1, (r_data->flags & MMC_DATA_WRITE) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); tifm_unmap_sg(sock, r_data->sg, r_data->sg_len, (r_data->flags & MMC_DATA_WRITE) ? PCI_DMA_TODEVICE : PCI_DMA_FROMDEVICE); } r_data->bytes_xfered = r_data->blocks - readl(sock->addr + SOCK_MMCSD_NUM_BLOCKS) - 1; r_data->bytes_xfered *= r_data->blksz; r_data->bytes_xfered += r_data->blksz - readl(sock->addr + SOCK_MMCSD_BLOCK_LEN) + 1; } writel((~TIFM_CTRL_LED) & readl(sock->addr + SOCK_CONTROL), sock->addr + SOCK_CONTROL); spin_unlock_irqrestore(&sock->lock, flags); mmc_request_done(mmc, mrq); }
false
false
false
false
false
0
ArSystemStatusRefreshThread(int refreshFrequency) : myRefreshFrequency(refreshFrequency) { setThreadName("ArSystemStatusRefreshThread"); }
false
false
false
false
false
0
is_terrain_alter_possible_in_range(const struct tile *target_tile, enum req_range range, bool survives, enum terrain_alteration alteration) { if (!target_tile) { return TRI_MAYBE; } switch (range) { case REQ_RANGE_LOCAL: return BOOL_TO_TRISTATE(terrain_can_support_alteration(tile_terrain(target_tile), alteration)); case REQ_RANGE_CADJACENT: case REQ_RANGE_ADJACENT: /* XXX Could in principle support ADJACENT. */ case REQ_RANGE_CITY: case REQ_RANGE_CONTINENT: case REQ_RANGE_PLAYER: case REQ_RANGE_WORLD: case REQ_RANGE_COUNT: break; } fc_assert_msg(FALSE, "Invalid range %d.", range); return TRI_MAYBE; }
false
false
false
false
false
0
print_page (void) { int j; int lines_left_on_page; COLUMN *p; /* Used as an accumulator (with | operator) of successive values of pad_vertically. The trick is to set pad_vertically to false before each run through the inner loop, then after that loop, it tells us whether a line was actually printed (whether a newline needs to be output -- or two for double spacing). But those values have to be accumulated (in pv) so we can invoke pad_down properly after the outer loop completes. */ bool pv; init_page (); if (cols_ready_to_print () == 0) return false; if (extremities) print_a_header = true; /* Don't pad unless we know a page was printed. */ pad_vertically = false; pv = false; lines_left_on_page = lines_per_body; if (double_space) lines_left_on_page *= 2; while (lines_left_on_page > 0 && cols_ready_to_print () > 0) { output_position = 0; spaces_not_printed = 0; separators_not_printed = 0; pad_vertically = false; align_empty_cols = false; empty_line = true; for (j = 1, p = column_vector; j <= columns; ++j, ++p) { input_position = 0; if (p->lines_to_print > 0 || p->status == FF_FOUND) { FF_only = false; padding_not_printed = p->start_position; if (!(p->print_func) (p)) read_rest_of_line (p); pv |= pad_vertically; --p->lines_to_print; if (p->lines_to_print <= 0) { if (cols_ready_to_print () <= 0) break; } /* File p changed its status to ON_HOLD or CLOSED */ if (parallel_files && p->status != OPEN) { if (empty_line) align_empty_cols = true; else if (p->status == CLOSED || (p->status == ON_HOLD && FF_only)) align_column (p); } } else if (parallel_files) { /* File status ON_HOLD or CLOSED */ if (empty_line) align_empty_cols = true; else align_column (p); } /* We need it also with an empty column */ if (use_col_separator) ++separators_not_printed; } if (pad_vertically) { putchar ('\n'); --lines_left_on_page; } if (cols_ready_to_print () <= 0 && !extremities) break; if (double_space && pv) { putchar ('\n'); --lines_left_on_page; } } if (lines_left_on_page == 0) for (j = 1, p = column_vector; j <= columns; ++j, ++p) if (p->status == OPEN) p->full_page_printed = true; pad_vertically = pv; if (pad_vertically && extremities) pad_down (lines_left_on_page + lines_per_footer); else if (keep_FF && print_a_FF) { putchar ('\f'); print_a_FF = false; } if (last_page_number < ++page_number) return false; /* Stop printing with LAST_PAGE */ reset_status (); /* Change ON_HOLD to OPEN. */ return true; /* More pages to go. */ }
false
false
false
false
false
0
pdf_count_pages(const char *filename) { char gscommand[CMDLINE_MAX]; char output[31] = ""; int pagecount; size_t bytes; snprintf(gscommand, CMDLINE_MAX, "%s -dNODISPLAY -q -c " "'/pdffile (%s) (r) file def pdfdict begin pdffile pdfopen begin " "(PageCount: ) print pdfpagecount == flush currentdict pdfclose " "end end quit'", gspath, filename); FILE *pd = popen(gscommand, "r"); if (!pd) rip_die(EXIT_STARVED, "Failed to execute ghostscript to determine number of input pages!\n"); bytes = fread(output, 1, 31, pd); pclose(pd); if (bytes <= 0 || sscanf(output, "PageCount: %d", &pagecount) < 1) pagecount = -1; return pagecount; }
false
false
false
false
true
1
peer_permit ( GHashTable *conf, peer *p ) { g_assert( p != NULL ); if (p->status != PEER_ACCEPT) { if (fw_perform( "PermitCmd", conf, p ) == 0) { p->status = PEER_ACCEPT; } else { return -1; } } peer_extend_timeout(conf, p); return 0; }
false
false
false
false
false
0
gfarm_base_host_info_validate(void *vinfo) { struct gfarm_host_info *info = vinfo; /* info->hostaliases may be NULL */ return ( info->hostname != NULL && info->architecture != NULL && info->ncpu != GFARM_HOST_INFO_NCPU_NOT_SET ); }
false
false
false
false
false
0
operator<( const QTreeWidgetItem & other ) const { const InstrItem* ii1 = this; const InstrItem* ii2 = (InstrItem*) &other; int col = treeWidget()->sortColumn(); if (col==1) return (ii1->_pure < ii2->_pure); if (col==2) return (ii1->_pure2 < ii2->_pure2); if (col==0) { if (ii1->_addr < ii2->_addr) return true; if (ii1->_addr > ii2->_addr) return false; // Same address: code gets above calls/jumps if (!ii1->_instrCall && !ii1->_instrJump) return true; if (!ii2->_instrCall && !ii2->_instrJump) return false; // calls above jumps if (ii1->_instrCall && !ii2->_instrCall) return true; if (ii2->_instrCall && !ii1->_instrCall) return false; if (ii1->_instrCall && ii2->_instrCall) { // Two calls: desending sort according costs if (ii1->_pure < ii2->_pure) return true; if (ii1->_pure > ii2->_pure) return false; // Two calls: sort according function names TraceFunction* f1 = ii1->_instrCall->call()->called(); TraceFunction* f2 = ii2->_instrCall->call()->called(); return (f1->prettyName() < f2->prettyName()); } // Two jumps: descending sort according target address return (ii1->_instrJump->instrTo()->addr() < ii2->_instrJump->instrTo()->addr()); } return QTreeWidgetItem::operator<(other); }
false
false
false
false
false
0
ad5064_read_raw(struct iio_dev *indio_dev, struct iio_chan_spec const *chan, int *val, int *val2, long m) { struct ad5064_state *st = iio_priv(indio_dev); int scale_uv; switch (m) { case IIO_CHAN_INFO_RAW: *val = st->dac_cache[chan->channel]; return IIO_VAL_INT; case IIO_CHAN_INFO_SCALE: scale_uv = ad5064_get_vref(st, chan); if (scale_uv < 0) return scale_uv; *val = scale_uv / 1000; *val2 = chan->scan_type.realbits; return IIO_VAL_FRACTIONAL_LOG2; default: break; } return -EINVAL; }
false
false
false
false
false
0
show_stat(struct res_db *db) { struct res_stat *rs; int i; /**/ printf("%d items\n", db->total); for (i = 0; i < 2; i++) { if (i == 0) { printf("conversion result\n"); rs = &db->res; } else { printf("split result\n"); rs = &db->split; } printf("ok : %d\n", rs->ok); printf("miss : %d\n", rs->miss); printf("unknown : %d\n", rs->unknown); printf("\n"); } }
false
false
false
false
false
0
attachSharedObjectStaticInterface(as_object& o) { VM& vm = getVM(o); const int flags = 0; Global_as& gl = getGlobal(o); o.init_member("getLocal", gl.createFunction(sharedobject_getLocal), flags); o.init_member("getRemote", gl.createFunction(sharedobject_getRemote), flags); const int hiddenOnly = PropFlags::dontEnum; o.init_member("deleteAll", vm.getNative(2106, 206), hiddenOnly); o.init_member("getDiskUsage", vm.getNative(2106, 207), hiddenOnly); }
false
false
false
false
false
0
efi_pstore_scan_sysfs_exit(struct efivar_entry *pos, struct efivar_entry *next, struct list_head *head, bool stop) { __efi_pstore_scan_sysfs_exit(pos, true); if (stop) __efi_pstore_scan_sysfs_exit(next, &next->list != head); }
false
false
false
false
false
0
run_target_start(struct ladish_command_change_app_state * cmd_ptr, ladish_app_supervisor_handle supervisor, ladish_app_handle app) { ASSERT(cmd_ptr->command.state == LADISH_COMMAND_STATE_PENDING); ASSERT(cmd_ptr->initiate_stop == NULL); if (!ladish_studio_is_started()) { log_error("cannot start app because studio is not started", cmd_ptr->opath); ladish_notify_simple(LADISH_NOTIFY_URGENCY_HIGH, "Cannot start app because studio is not started", NULL); return false; } if (ladish_app_is_running(app)) { log_error("App %s is already running", ladish_app_get_name(app)); ladish_notify_simple(LADISH_NOTIFY_URGENCY_HIGH, "Cannot start app because it is already running", NULL); return false; } if (!ladish_app_supervisor_start_app(supervisor, app)) { ladish_notify_simple(LADISH_NOTIFY_URGENCY_HIGH, "Cannot start app (execution failed)", NULL); return false; } cmd_ptr->command.state = LADISH_COMMAND_STATE_DONE; return true; }
false
false
false
false
false
0
score_knights(Color side) { int score = 0; Square sq; Bitboard knights = board->get_knights(side); while (knights) { sq = knights.firstbit(); knights.clearbit(sq); /* Positional score */ score += knight_scores[sq]; #ifdef EVAL_KNIGHTMOBILITY /* Simple mobility bonus */ Bitboard ka = board->knight_attacks(sq) & ~board->get_pieces(side); score += ka.popcnt() * EVAL_KNIGHTMOBILITY; #endif #ifdef EVAL_PINNEDKNIGHT /* Pinned knight? */ if (pinned_on_king[side].testbit(sq)) { score += EVAL_PINNEDKNIGHT; } #endif } return score; }
false
false
false
false
false
0
gdl_dock_master_foreach_toplevel (GdlDockMaster *master, gboolean include_controller, GFunc function, gpointer user_data) { GList *l; g_return_if_fail (master != NULL && function != NULL); for (l = master->priv->toplevel_docks; l; ) { GdlDockObject *object = GDL_DOCK_OBJECT (l->data); l = l->next; if (object != master->priv->controller || include_controller) (* function) (GTK_WIDGET (object), user_data); } }
false
false
false
false
false
0
get_key_from_keytab(krb5_context context, krb5_ap_req *ap_req, krb5_const_principal server, krb5_keytab keytab, krb5_keyblock **out_key) { krb5_keytab_entry entry; krb5_error_code ret; int kvno; krb5_keytab real_keytab; if(keytab == NULL) krb5_kt_default(context, &real_keytab); else real_keytab = keytab; if (ap_req->ticket.enc_part.kvno) kvno = *ap_req->ticket.enc_part.kvno; else kvno = 0; ret = krb5_kt_get_entry (context, real_keytab, server, kvno, ap_req->ticket.enc_part.etype, &entry); if(ret) goto out; ret = krb5_copy_keyblock(context, &entry.keyblock, out_key); krb5_kt_free_entry (context, &entry); out: if(keytab == NULL) krb5_kt_close(context, real_keytab); return ret; }
false
false
false
false
false
0
change_postfix(char *filename, char *affix1, char *affix2) { if (!strcmp(&filename[strlen(filename) - strlen(affix1)], affix1)) filename[strlen(filename) - strlen(affix1)] = '\0'; strcat(filename, affix2); }
false
false
false
false
false
0
PageHuge(struct page *page) { if (!PageCompound(page)) return 0; page = compound_head(page); return page[1].compound_dtor == HUGETLB_PAGE_DTOR; }
false
false
false
false
false
0
drawer_get_transform(int from_id, Transform T, int to_id) { DObject *obj; Transform Tfrom, Tto, Ttoinv; if(from_id == to_id || to_id == SELF) { TmIdentity(T); return; } if((obj = drawer_get_object(from_id)) == NULL) { if(to_id == UNIVERSE) { OOGLError(1, "drawer_get_transform: can't handle from_id %d", from_id); TmIdentity(T); return; } } else { if(from_id < 0) from_id = obj->id; if (ISGEOM(from_id)) { switch(to_id) { case UNIVERSE: get_geom_transform(DGobj(obj), T); if(DGobj(obj)->citizenship == ORDINARY) { get_geom_transform(dgeom[0], Tfrom); TmConcat(T, Tfrom, T); } return; case WORLDGEOM: if(DGobj(obj)->citizenship == ORDINARY) { get_geom_transform(DGobj(obj), T); return; } } } else if (ISCAM(from_id)) { if(to_id == UNIVERSE) { CamGet(DVobj(obj)->cam, CAM_C2W, T); return; } } else if (ISCAM(to_id)) { if(from_id == UNIVERSE) { CamGet(DVobj(obj)->cam, CAM_W2C, T); return; } } } /* If the above easy cases couldn't hack it, do it the hard way: * Handle A -> B as (A -> UNIVERSE) * (B -> UNIVERSE)^-1 */ drawer_get_transform(to_id, Tto, UNIVERSE); TmInvert(Tto, Ttoinv); drawer_get_transform(from_id, Tfrom, UNIVERSE); TmConcat(Tfrom, Ttoinv, T); }
false
false
false
false
false
0
hexstr2bin(char *hexstr, int len, uint8_t *buf, size_t offset, size_t buf_len) { char c; int i; uint8_t int8 = 0; int sec = 0; size_t bufpos = 0; if (len % 2 != 0) { return 0; } for (i=0; i<len; i++) { c = hexstr[i]; /* case insensitive, skip spaces */ if (c != ' ') { if (c >= '0' && c <= '9') { int8 += c & 0x0f; } else if (c >= 'a' && c <= 'z') { int8 += (c & 0x0f) + 9; } else if (c >= 'A' && c <= 'Z') { int8 += (c & 0x0f) + 9; } else { return 0; } if (sec == 0) { int8 = int8 << 4; sec = 1; } else { if (bufpos + offset + 1 <= buf_len) { buf[bufpos+offset] = int8; int8 = 0; sec = 0; bufpos++; } else { fprintf(stderr, "Buffer too small in hexstr2bin"); } } } } return bufpos; }
false
false
false
false
false
0
do_static_branch (VerifyContext *ctx, int delta) { int target = ctx->ip_offset + delta; if (target < 0 || target >= ctx->code_size) { ADD_VERIFY_ERROR (ctx, g_strdup_printf ("branch target out of code at 0x%04x", ctx->ip_offset)); return; } switch (is_valid_branch_instruction (ctx->header, ctx->ip_offset, target)) { case 1: CODE_NOT_VERIFIABLE (ctx, g_strdup_printf ("Branch target escapes out of exception block at 0x%04x", ctx->ip_offset)); break; case 2: ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Branch target escapes out of exception block at 0x%04x", ctx->ip_offset)); break; } ctx->target = target; }
false
false
false
false
false
0
run() { m_file_mutex.lock(); do { File file = m_files.takeLast(); m_files.clear(); m_file_mutex.unlock(); CacheFile cache_file = { file, QImage() }; int index = m_cache.indexOf(cache_file); if (index != -1) { cache_file = m_cache.at(index); } else { cache_file.image = Theme::renderBackground(file.image_path, file.position, file.color, file.rect.size()); m_cache.prepend(cache_file); while (m_cache.size() > 10) { m_cache.removeLast(); } } m_image_mutex.lock(); m_image = cache_file.image; m_image_mutex.unlock(); m_file_mutex.lock(); } while (!m_files.isEmpty()); m_file_mutex.unlock(); }
false
false
false
false
false
0
sendsusp (void) { NET2ADD (IAC, SUSP); printoption ("SENT", IAC, SUSP); flushline = 1; if (autoflush) { doflush (); } if (autosynch) { dosynch (); } }
false
false
false
false
false
0
do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { struct fuse_lk_in *arg = (struct fuse_lk_in *) inarg; struct fuse_file_info fi; struct flock flock; memset(&fi, 0, sizeof(fi)); fi.fh = arg->fh; fi.lock_owner = arg->owner; convert_fuse_file_lock(&arg->lk, &flock); if (req->f->op.getlk) req->f->op.getlk(req, nodeid, &fi, &flock); else fuse_reply_err(req, ENOSYS); }
false
false
false
false
false
0
plugin_close_file_emit_signal (void) { int i = 0; g_return_if_fail (plugin_list); while ( plugin_list[i++].start_plugin_function ) { if ( plugin_list[i - 1].close_file_plugin_signal && activate_plugin[i - 1] ) plugin_list[i - 1].close_file_plugin_signal (); } }
false
false
false
false
false
0
get_expected_numevents(icalcomponent *c) { icalproperty *p; const char* note = 0; int num_events = 0; if(c != 0){ for(p = icalcomponent_get_first_property(c,ICAL_X_PROPERTY); p!= 0; p = icalcomponent_get_next_property(c,ICAL_X_PROPERTY)){ if(strcmp(icalproperty_get_x_name(p),"X-EXPECT-NUMEVENTS")==0){ note = icalproperty_get_x(p); } } } if(note != 0){ num_events = atoi(note); } return num_events; }
false
false
false
false
true
1
ndmca_td_idle (struct ndm_session *sess) { int rc; ndmca_test_phase (sess, "D-IDLE", "Data IDLE State Series"); rc = ndmca_test_check_data_state (sess, NDMP9_DATA_STATE_IDLE, 0); if (rc) return rc; rc = ndmca_test_data_abort (sess, NDMP9_ILLEGAL_STATE_ERR); if (rc) return rc; rc = ndmca_test_data_stop (sess, NDMP9_ILLEGAL_STATE_ERR); if (rc) return rc; return 0; /* pass */ }
false
false
false
false
false
0
sha1(const QString &string) { QByteArray hashData = QCryptographicHash::hash(string.toUtf8(), QCryptographicHash::Sha1); return hashData.toHex(); }
false
false
false
false
false
0
WriteStringAttribute(const char* name, const char* value) { ostream& os = *(this->Stream); os << " " << name << "=\"" << value << "\""; os.flush(); if (os.fail()) { this->SetErrorCode(vtkErrorCode::GetLastSystemError()); } return (os? 1:0); }
false
false
false
false
false
0
set_status( const std::string& stat ) { if( stat == m_status ) return; m_status = stat; #if GTKMM_CHECK_VERSION(2,5,0) m_label_stat.set_text( stat ); m_tooltip.set_tip( m_label_stat_ebox, stat ); #else m_statbar.push( stat ); #endif }
false
false
false
false
false
0
cgraph_rtl_info (tree decl) { struct cgraph_node *node; if (TREE_CODE (decl) != FUNCTION_DECL) abort (); node = cgraph_node (decl); if (decl != current_function_decl && !TREE_ASM_WRITTEN (node->decl)) return NULL; return &node->rtl; }
false
false
false
false
false
0
_cx_string_rtrim(cx_string *self) { cxchar *tmp = NULL; cxsize i = 0; cx_assert(self != NULL); tmp = self->data + self->sz - 1; while (isspace((cxint)*tmp)) { tmp--; i++; } *++tmp = (cxchar) '\0'; self->sz -= i; return self; }
false
false
false
false
false
0
criteria_test_nonempty (GnmValue const *x, GnmCriteria *crit) { return !VALUE_IS_EMPTY (x); }
false
false
false
false
false
0
errstr(PyObject *self, PyObject *args) { const char *errmsg; int res; if(!PyArg_ParseTuple(args, "i", &res)) return NULL; errmsg = fko_errstr(res); return Py_BuildValue("s", errmsg); }
false
false
false
false
false
0
deleteAll(void) { xxx_UT_DEBUGMSG(("fl_Squiggles::deleteAll()\n")); // Remove any existing squiggles from the screen... UT_sint32 iSquiggles = _getCount(); UT_sint32 j; for (j = iSquiggles-1; j >= 0 ; j--) { _deleteNth(j); } return (0 == iSquiggles) ? false : true; }
false
false
false
false
false
0
mono_ftnptr_to_delegate (MonoClass *klass, gpointer ftn) { guint32 gchandle; MonoDelegate *d; if (ftn == NULL) return NULL; mono_marshal_lock (); if (delegate_hash_table == NULL) delegate_hash_table = delegate_hash_table_new (); if (mono_gc_is_moving ()) { gchandle = GPOINTER_TO_UINT (g_hash_table_lookup (delegate_hash_table, ftn)); mono_marshal_unlock (); if (gchandle) d = (MonoDelegate*)mono_gchandle_get_target (gchandle); else d = NULL; } else { d = (MonoDelegate *)g_hash_table_lookup (delegate_hash_table, ftn); mono_marshal_unlock (); } if (d == NULL) { /* This is a native function, so construct a delegate for it */ MonoMethodSignature *sig; MonoMethod *wrapper; MonoMarshalSpec **mspecs; MonoMethod *invoke = mono_get_delegate_invoke (klass); MonoMethodPInvoke piinfo; MonoObject *this_obj; int i; if (use_aot_wrappers) { wrapper = mono_marshal_get_native_func_wrapper_aot (klass); this_obj = mono_value_box (mono_domain_get (), mono_defaults.int_class, &ftn); } else { memset (&piinfo, 0, sizeof (piinfo)); parse_unmanaged_function_pointer_attr (klass, &piinfo); mspecs = g_new0 (MonoMarshalSpec*, mono_method_signature (invoke)->param_count + 1); mono_method_get_marshal_info (invoke, mspecs); /* Freed below so don't alloc from mempool */ sig = mono_metadata_signature_dup (mono_method_signature (invoke)); sig->hasthis = 0; wrapper = mono_marshal_get_native_func_wrapper (klass->image, sig, &piinfo, mspecs, ftn); this_obj = NULL; for (i = mono_method_signature (invoke)->param_count; i >= 0; i--) if (mspecs [i]) mono_metadata_free_marshal_spec (mspecs [i]); g_free (mspecs); g_free (sig); } d = (MonoDelegate*)mono_object_new (mono_domain_get (), klass); mono_delegate_ctor_with_method ((MonoObject*)d, this_obj, mono_compile_method (wrapper), wrapper); } if (d->object.vtable->domain != mono_domain_get ()) mono_raise_exception (mono_get_exception_not_supported ("Delegates cannot be marshalled from native code into a domain other than their home domain")); return d; }
false
false
false
false
false
0
make_channel(gint fd) { GIOChannel *channel; GError *err = NULL; channel = g_io_channel_unix_new(fd); g_io_channel_set_close_on_unref(channel, TRUE); g_io_channel_set_encoding(channel, NULL, &err); if (err != NULL) { g_printerr("%s\n", err->message); g_error_free(err); g_io_channel_unref(channel); channel = NULL; } return channel; }
false
false
false
false
false
0
__efi_enter_virtual_mode(void) { int count = 0, pg_shift = 0; void *new_memmap = NULL; efi_status_t status; efi.systab = NULL; efi_merge_regions(); new_memmap = efi_map_regions(&count, &pg_shift); if (!new_memmap) { pr_err("Error reallocating memory, EFI runtime non-functional!\n"); clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); return; } save_runtime_map(); BUG_ON(!efi.systab); if (efi_setup_page_tables(__pa(new_memmap), 1 << pg_shift)) { clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); return; } efi_sync_low_kernel_mappings(); efi_dump_pagetable(); if (efi_is_native()) { status = phys_efi_set_virtual_address_map( memmap.desc_size * count, memmap.desc_size, memmap.desc_version, (efi_memory_desc_t *)__pa(new_memmap)); } else { status = efi_thunk_set_virtual_address_map( efi_phys.set_virtual_address_map, memmap.desc_size * count, memmap.desc_size, memmap.desc_version, (efi_memory_desc_t *)__pa(new_memmap)); } if (status != EFI_SUCCESS) { pr_alert("Unable to switch EFI into virtual mode (status=%lx)!\n", status); panic("EFI call to SetVirtualAddressMap() failed!"); } /* * Now that EFI is in virtual mode, update the function * pointers in the runtime service table to the new virtual addresses. * * Call EFI services through wrapper functions. */ efi.runtime_version = efi_systab.hdr.revision; if (efi_is_native()) efi_native_runtime_setup(); else efi_thunk_runtime_setup(); efi.set_virtual_address_map = NULL; efi_runtime_mkexec(); /* * We mapped the descriptor array into the EFI pagetable above but we're * not unmapping it here. Here's why: * * We're copying select PGDs from the kernel page table to the EFI page * table and when we do so and make changes to those PGDs like unmapping * stuff from them, those changes appear in the kernel page table and we * go boom. * * From setup_real_mode(): * * ... * trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd; * * In this particular case, our allocation is in PGD 0 of the EFI page * table but we've copied that PGD from PGD[272] of the EFI page table: * * pgd_index(__PAGE_OFFSET = 0xffff880000000000) = 272 * * where the direct memory mapping in kernel space is. * * new_memmap's VA comes from that direct mapping and thus clearing it, * it would get cleared in the kernel page table too. * * efi_cleanup_page_tables(__pa(new_memmap), 1 << pg_shift); */ free_pages((unsigned long)new_memmap, pg_shift); /* clean DUMMY object */ efi_delete_dummy_variable(); }
false
false
false
false
false
0
intelFinish(struct gl_context * ctx) { struct brw_context *brw = brw_context(ctx); intel_glFlush(ctx); if (brw->batch.last_bo) drm_intel_bo_wait_rendering(brw->batch.last_bo); }
false
false
false
false
false
0
get_selection_vfunc_callback(AtkText* self, gint selection_num, gint* start_offset, gint* end_offset) { Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>( Glib::ObjectBase::_get_current_wrapper((GObject*)self)); // Non-gtkmmproc-generated custom classes implicitly call the default // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- // generated classes can use this optimisation, which avoids the unnecessary // parameter conversions if there is no possibility of the virtual function // being overridden: if(obj_base && obj_base->is_derived_()) { CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base); if(obj) // This can be NULL during destruction. { #ifdef GLIBMM_EXCEPTIONS_ENABLED try // Trap C++ exceptions which would normally be lost because this is a C callback. { #endif //GLIBMM_EXCEPTIONS_ENABLED // Call the virtual member method, which derived classes might override. return g_strdup((obj->get_selection_vfunc(selection_num , *(start_offset) , *(end_offset) )).c_str()); #ifdef GLIBMM_EXCEPTIONS_ENABLED } catch(...) { Glib::exception_handlers_invoke(); } #endif //GLIBMM_EXCEPTIONS_ENABLED } } BaseClassType *const base = static_cast<BaseClassType*>( g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. ) ); // Call the original underlying C function: if(base && base->get_selection) { gchar* retval = (*base->get_selection)(self, selection_num, start_offset, end_offset); return retval; } typedef gchar* RType; return RType(); }
false
false
false
false
false
0
alt_size_entry_update_refval (AltSizeEntryField *gsef, gdouble refval) { if (gsef->stop_recursion > 1) return; gsef->refval = refval; switch (gsef->gse->update_policy) { case ALT_SIZE_ENTRY_UPDATE_NONE: break; case ALT_SIZE_ENTRY_UPDATE_SIZE: switch (gsef->gse->unit) { case GIMP_UNIT_PIXEL: gsef->value = refval; break; case GIMP_UNIT_PERCENT: gsef->value = CLAMP (100 * (refval - gsef->lower) / (gsef->upper - gsef->lower), gsef->min_value, gsef->max_value); break; default: gsef->value = CLAMP (refval * gimp_unit_get_factor (gsef->gse->unit) / gsef->resolution, gsef->min_value, gsef->max_value); break; } gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment), gsef->value); break; case ALT_SIZE_ENTRY_UPDATE_RESOLUTION: gsef->value = CLAMP (refval / gimp_unit_get_factor (gsef->gse->unit), gsef->min_value, gsef->max_value); gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->value_adjustment), gsef->value); break; default: break; } g_signal_emit (gsef->gse, alt_size_entry_signals[REFVAL_CHANGED], 0); }
false
false
false
false
false
0
Realloc(int size) { if ( size == m_len ) { return false; } if (size == 0) { delete [] m_buff; m_buff = 0; m_len = 0; return true; } uint8 *buff = new uint8[size]; if (m_len == 0) { memset(buff, 0, size); } else if ( size > m_len ) { memset(buff + m_len, 0, size - m_len); memcpy(buff, m_buff, m_len); } else { memcpy(buff, m_buff, size); } delete [] m_buff; m_buff = buff; m_len = size; return true; }
false
false
false
false
false
0
get_ec_player_id( long unsigned int dpPlayerId ) { if( dpPlayerId == BROADCAST_PID || dpPlayerId == 0) return 0; for( char ecPlayerId = 1; ecPlayerId <= MAX_PLAYER; ++ecPlayerId ) { if( dpPlayerId == dp_id[ecPlayerId-1] ) return ecPlayerId; } return 0; }
false
false
false
false
false
0
find_next_wrap (GtkXText * xtext, textentry * ent, unsigned char *str, int win_width, int indent) { unsigned char *last_space = str; unsigned char *orig_str = str; int str_width = indent; int rcol = 0, bgcol = 0; int hidden = FALSE; int mbl; int char_width; int ret; int limit_offset = 0; /* single liners */ if (win_width >= ent->str_width + ent->indent) return ent->str_len; /* it does happen! */ if (win_width < 1) { ret = ent->str_len - (str - ent->str); goto done; } while (1) { if (rcol > 0 && (isdigit (*str) || (*str == ',' && isdigit (str[1]) && !bgcol))) { if (str[1] != ',') rcol--; if (*str == ',') { rcol = 2; bgcol = 1; } limit_offset++; str++; } else { rcol = bgcol = 0; switch (*str) { case ATTR_COLOR: rcol = 2; case ATTR_BEEP: case ATTR_RESET: case ATTR_REVERSE: case ATTR_BOLD: case ATTR_UNDERLINE: case ATTR_ITALICS: limit_offset++; str++; break; case ATTR_HIDDEN: if (xtext->ignore_hidden) goto def; hidden = !hidden; limit_offset++; str++; break; default: def: char_width = backend_get_char_width (xtext, str, &mbl); if (!hidden) str_width += char_width; if (str_width > win_width) { if (xtext->wordwrap) { if (str - last_space > WORDWRAP_LIMIT + limit_offset) ret = str - orig_str; /* fall back to character wrap */ else { if (*last_space == ' ') last_space++; ret = last_space - orig_str; if (ret == 0) /* fall back to character wrap */ ret = str - orig_str; } goto done; } ret = str - orig_str; goto done; } /* keep a record of the last space, for wordwrapping */ if (is_del (*str)) { last_space = str; limit_offset = 0; } /* progress to the next char */ str += mbl; } } if (str >= ent->str + ent->str_len) { ret = str - orig_str; goto done; } } done: /* must make progress */ if (ret < 1) ret = 1; return ret; }
false
false
false
false
false
0
save( QTextStream * ts, int indent ) { indentation( ts, indent ); *ts << "<bonus type=\"" << (uint)_type << "\">" << endl; uint nbParam = _params.count(); for( uint i = 0; i < nbParam; i++ ) { indentation( ts, indent+1 ); *ts << "<param>" << _params.at( i ) << "</param>" << endl; } indentation( ts, indent ); *ts << "</bonus>" << endl; *ts << flush; }
false
false
false
false
false
0
StartTransaction(void) { TransactionState s; VirtualTransactionId vxid; /* * Let's just make sure the state stack is empty */ s = &TopTransactionStateData; CurrentTransactionState = s; /* * check the current transaction state */ if (s->state != TRANS_DEFAULT) elog(WARNING, "StartTransaction while in %s state", TransStateAsString(s->state)); /* * set the current transaction state information appropriately during * start processing */ s->state = TRANS_START; s->transactionId = InvalidTransactionId; /* until assigned */ /* * Make sure we've freed any old snapshot, and reset xact state variables */ FreeXactSnapshot(); XactIsoLevel = DefaultXactIsoLevel; XactReadOnly = DefaultXactReadOnly; forceSyncCommit = false; MyXactAccessedTempRel = false; /* * reinitialize within-transaction counters */ s->subTransactionId = TopSubTransactionId; currentSubTransactionId = TopSubTransactionId; currentCommandId = FirstCommandId; currentCommandIdUsed = false; /* * must initialize resource-management stuff first */ AtStart_Memory(); AtStart_ResourceOwner(); /* * Assign a new LocalTransactionId, and combine it with the backendId to * form a virtual transaction id. */ vxid.backendId = MyBackendId; vxid.localTransactionId = GetNextLocalTransactionId(); /* * Lock the virtual transaction id before we announce it in the proc array */ VirtualXactLockTableInsert(vxid); /* * Advertise it in the proc array. We assume assignment of * LocalTransactionID is atomic, and the backendId should be set already. */ Assert(MyProc->backendId == vxid.backendId); MyProc->lxid = vxid.localTransactionId; PG_TRACE1(transaction__start, vxid.localTransactionId); /* * set transaction_timestamp() (a/k/a now()). We want this to be the same * as the first command's statement_timestamp(), so don't do a fresh * GetCurrentTimestamp() call (which'd be expensive anyway). Also, mark * xactStopTimestamp as unset. */ xactStartTimestamp = stmtStartTimestamp; xactStopTimestamp = 0; pgstat_report_xact_timestamp(xactStartTimestamp); /* * initialize current transaction state fields * * note: prevXactReadOnly is not used at the outermost level */ s->nestingLevel = 1; s->gucNestLevel = 1; s->childXids = NULL; s->nChildXids = 0; s->maxChildXids = 0; GetUserIdAndSecContext(&s->prevUser, &s->prevSecContext); /* SecurityRestrictionContext should never be set outside a transaction */ Assert(s->prevSecContext == 0); /* * initialize other subsystems for new transaction */ AtStart_GUC(); AtStart_Inval(); AtStart_Cache(); AfterTriggerBeginXact(); /* * done with start processing, set current transaction state to "in * progress" */ s->state = TRANS_INPROGRESS; ShowTransactionState("StartTransaction"); }
false
false
false
false
false
0
initFS( EncFS_Context *ctx, const shared_ptr<EncFS_Opts> &opts ) { RootPtr rootInfo; boost::shared_ptr<EncFSConfig> config(new EncFSConfig); if(readConfig( opts->rootDir, config ) != Config_None) { if(opts->reverseEncryption) { if (config->blockMACBytes != 0 || config->blockMACRandBytes != 0 || config->uniqueIV || config->externalIVChaining || config->chainedNameIV ) { cout << _("The configuration loaded is not compatible with --reverse\n"); return rootInfo; } } // first, instanciate the cipher. shared_ptr<Cipher> cipher = config->getCipher(); if(!cipher) { rError(_("Unable to find cipher %s, version %i:%i:%i"), config->cipherIface.name().c_str(), config->cipherIface.current(), config->cipherIface.revision(), config->cipherIface.age()); // xgroup(diag) cout << _("The requested cipher interface is not available\n"); return rootInfo; } // get user key CipherKey userKey; if(opts->passwordProgram.empty()) { rDebug( "useStdin: %i", opts->useStdin ); userKey = config->getUserKey( opts->useStdin ); } else userKey = config->getUserKey( opts->passwordProgram, opts->rootDir ); if(!userKey) return rootInfo; rDebug("cipher key size = %i", cipher->encodedKeySize()); // decode volume key.. CipherKey volumeKey = cipher->readKey( config->getKeyData(), userKey, opts->checkKey); userKey.reset(); if(!volumeKey) { // xgroup(diag) cout << _("Error decoding volume key, password incorrect\n"); return rootInfo; } shared_ptr<NameIO> nameCoder = NameIO::New( config->nameIface, cipher, volumeKey ); if(!nameCoder) { rError(_("Unable to find nameio interface %s, version %i:%i:%i"), config->nameIface.name().c_str(), config->nameIface.current(), config->nameIface.revision(), config->nameIface.age()); // xgroup(diag) cout << _("The requested filename coding interface is " "not available\n"); return rootInfo; } nameCoder->setChainedNameIV( config->chainedNameIV ); nameCoder->setReverseEncryption( opts->reverseEncryption ); FSConfigPtr fsConfig( new FSConfig ); fsConfig->cipher = cipher; fsConfig->key = volumeKey; fsConfig->nameCoding = nameCoder; fsConfig->config = config; fsConfig->forceDecode = opts->forceDecode; fsConfig->reverseEncryption = opts->reverseEncryption; fsConfig->opts = opts; rootInfo = RootPtr( new EncFS_Root ); rootInfo->cipher = cipher; rootInfo->volumeKey = volumeKey; rootInfo->root = shared_ptr<DirNode>( new DirNode( ctx, opts->rootDir, fsConfig )); } else { if(opts->createIfNotFound) { // creating a new encrypted filesystem rootInfo = createV6Config( ctx, opts ); } } return rootInfo; }
false
false
false
false
false
0
no_double_slashes(char *buf) { /* * Clean slashes */ char *c = buf; while(c[0]) { if(c[0] == '/') { if(0 == c[1]) c[0] = 0; else while('/' == c[1]) strdel(c + 1, 1); } ++c; } }
false
false
false
false
false
0
load_gen(int size, SFBags *bagp, FILE *fd) { int i; size /= 4; bagp->gen = NEW(SFGenRec, size); for (i = 0; i < size; i++) { READW(bagp->gen[i].oper, fd); READW(bagp->gen[i].amount, fd); } bagp->ngens = size; }
false
false
false
false
false
0
st_sensors_i2c_read_byte(struct st_sensor_transfer_buffer *tb, struct device *dev, u8 reg_addr, u8 *res_byte) { int err; err = i2c_smbus_read_byte_data(to_i2c_client(dev), reg_addr); if (err < 0) goto st_accel_i2c_read_byte_error; *res_byte = err & 0xff; st_accel_i2c_read_byte_error: return err < 0 ? err : 0; }
false
false
false
false
false
0
gt_ltr_visitor_feature_node(GtNodeVisitor *nv, GtFeatureNode *fn, GT_UNUSED GtError *err) { GtLTRVisitor *lv; GtRange node_range; GtArray *pdomarr = NULL; const char *pfamname; const char *fnt; lv = gt_ltr_visitor_cast(nv); gt_assert(lv); gt_error_check(err); fnt = gt_feature_node_get_type(fn); if (strcmp(fnt, gt_ft_LTR_retrotransposon) == 0) { lv->element->mainnode = fn; } else if (strcmp(fnt, gt_ft_long_terminal_repeat) == 0) { if (lv->element->leftLTR == NULL) { node_range = gt_genome_node_get_range((GtGenomeNode*) fn); lv->element->leftLTR = fn; /* compensate for 1-based node coords */ lv->element->leftLTR_5 = node_range.start - 1; lv->element->leftLTR_3 = node_range.end - 1; } else { node_range = gt_genome_node_get_range((GtGenomeNode*) fn); lv->element->rightLTR = fn; /* compensate for 1-based node coords */ lv->element->rightLTR_5 = node_range.start - 1; lv->element->rightLTR_3 = node_range.end - 1; } } else if (strcmp(fnt, gt_ft_target_site_duplication) == 0) { if (lv->element->leftTSD == NULL) { lv->element->leftTSD = fn; } else { lv->element->rightTSD = fn; } } else if (strcmp(fnt, gt_ft_RR_tract) == 0) { if (lv->element->ppt == NULL) { lv->element->ppt = fn; } } else if (strcmp(fnt, gt_ft_primer_binding_site) == 0) { if (lv->element->pbs == NULL) { lv->element->pbs = fn; } } else if (strcmp(fnt, gt_ft_protein_match) == 0) { if (!lv->element->pdoms) { lv->element->pdoms = gt_hashmap_new(GT_HASH_STRING, gt_free_func, (GtFree) gt_array_delete); } pfamname = gt_feature_node_get_attribute(fn, "name"); if (!(pdomarr = (GtArray*) gt_hashmap_get(lv->element->pdoms, pfamname))) { char *pfamcpy = gt_cstr_dup(pfamname); pdomarr = gt_array_new(sizeof (GtFeatureNode*)); gt_hashmap_add(lv->element->pdoms, pfamcpy, pdomarr); if (lv->element->pdomorder != NULL) gt_array_add(lv->element->pdomorder, pfamcpy); } gt_array_add(pdomarr, fn); } return 0; }
false
false
false
false
false
0
__ecereProp___ecereNameSpace__ecere__gui__controls__EditBox_Set_noCaret(struct __ecereNameSpace__ecere__com__Instance * this, unsigned int value) { struct __ecereNameSpace__ecere__gui__controls__EditBox * __ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox = (struct __ecereNameSpace__ecere__gui__controls__EditBox *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__EditBox->offset) : 0); __ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style = (__ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style & ~0x200) | (((unsigned int)value) << 9); if(value) { __ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style = (__ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style & ~0x2) | (((unsigned int)0x1) << 1); __ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style = (__ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox->style & ~0x8) | (((unsigned int)0x1) << 3); } __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(this, __ecereProp___ecereNameSpace__ecere__gui__controls__EditBox_noCaret), __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(this, __ecerePropM___ecereNameSpace__ecere__gui__controls__EditBox_noCaret); }
false
false
false
true
false
1
container_add_actor (ClutterContainer *container, ClutterActor *actor) { ClutterActor *parent; parent = clutter_actor_get_parent (actor); if (G_UNLIKELY (parent != NULL)) { g_warning ("Attempting to add actor of type '%s' to a " "container of type '%s', but the actor has " "already a parent of type '%s'.", g_type_name (G_OBJECT_TYPE (actor)), g_type_name (G_OBJECT_TYPE (container)), g_type_name (G_OBJECT_TYPE (parent))); return; } clutter_container_create_child_meta (container, actor); #ifdef CLUTTER_ENABLE_DEBUG if (G_UNLIKELY (_clutter_diagnostic_enabled ())) { ClutterContainerIface *iface = CLUTTER_CONTAINER_GET_IFACE (container); if (iface->add != container_real_add) _clutter_diagnostic_message ("The ClutterContainer::add() virtual " "function has been deprecated and it " "should not be overridden by newly " "written code"); } #endif /* CLUTTER_ENABLE_DEBUG */ CLUTTER_CONTAINER_GET_IFACE (container)->add (container, actor); }
false
false
false
true
false
1
mhdriver_cached_expunge_folder(mailsession * session) { struct mailmh_folder * folder; int res; char filename_flags[PATH_MAX]; struct mail_cache_db * cache_db_flags; MMAPString * mmapstr; struct mh_cached_session_state_data * cached_data; unsigned int i; int r; cached_data = get_cached_data(session); if (cached_data->mh_quoted_mb == NULL) { res = MAIL_ERROR_BAD_STATE; goto err; } mh_flags_store_process(cached_data->mh_flags_directory, cached_data->mh_quoted_mb, cached_data->mh_flags_store); folder = get_mh_cur_folder(session); if (folder == NULL) { res = MAIL_ERROR_BAD_STATE; goto err; } snprintf(filename_flags, PATH_MAX, "%s/%s/%s", cached_data->mh_flags_directory, cached_data->mh_quoted_mb, FLAGS_NAME); r = mail_cache_db_open_lock(filename_flags, &cache_db_flags); if (r < 0) { res = MAIL_ERROR_FILE; goto err; } mmapstr = mmap_string_new(""); if (mmapstr == NULL) { res = MAIL_ERROR_MEMORY; goto close_db_flags; } for(i = 0 ; i < carray_count(folder->fl_msgs_tab) ; i++) { struct mailmh_msg_info * mh_info; struct mail_flags * flags; mh_info = carray_get(folder->fl_msgs_tab, i); if (mh_info == NULL) continue; r = mhdriver_get_cached_flags(cache_db_flags, mmapstr, session, mh_info->msg_index, &flags); if (r != MAIL_NO_ERROR) continue; if (flags->fl_flags & MAIL_FLAG_DELETED) { r = mailmh_folder_remove_message(folder, mh_info->msg_index); } mail_flags_free(flags); } mmap_string_free(mmapstr); mail_cache_db_close_unlock(filename_flags, cache_db_flags); mailmh_folder_update(folder); return MAIL_NO_ERROR; close_db_flags: mail_cache_db_close_unlock(filename_flags, cache_db_flags); err: return res; }
true
true
false
false
false
1
_build_user_job_list(uint32_t user_id, char* job_name) { List job_queue; ListIterator job_iterator; struct job_record *job_ptr = NULL; job_queue = list_create(NULL); if (job_queue == NULL) fatal("list_create memory allocation failure"); job_iterator = list_iterator_create(job_list); if (job_iterator == NULL) fatal("list_iterator_create malloc failure"); while ((job_ptr = (struct job_record *) list_next(job_iterator))) { xassert (job_ptr->magic == JOB_MAGIC); if (job_ptr->user_id != user_id) continue; if (job_name && job_ptr->name && strcmp(job_name, job_ptr->name)) continue; list_append(job_queue, job_ptr); } list_iterator_destroy(job_iterator); return job_queue; }
false
false
false
false
false
0
disable_pots(struct w6692_ch *wch) { struct w6692_hw *card = wch->bch.hw; if (!(card->fmask & pots)) return -ENODEV; wch->b_mode &= ~(W_B_MODE_EPCM | W_B_MODE_BSW0); WriteW6692B(wch, W_B_MODE, wch->b_mode); WriteW6692B(wch, W_B_CMDR, W_B_CMDR_RRST | W_B_CMDR_RACT | W_B_CMDR_XRST); return 0; }
false
false
false
false
false
0
readByte() throw(GsmException) { if (_oldChar != -1) { int result = _oldChar; _oldChar = -1; return result; } unsigned char c; int timeElapsed = 0; struct timeval oneSecond; bool readDone = false; while (!readDone && timeElapsed < _timeoutVal) { if (interrupted()) throwModemException(_("interrupted when reading from TA")); // setup fd_set data structure for select() fd_set fdSet; oneSecond.tv_sec = 1; oneSecond.tv_usec = 0; FD_ZERO(&fdSet); FD_SET(_fd, &fdSet); switch (select(FD_SETSIZE, &fdSet, NULL, NULL, &oneSecond)) { case 1: { int res = read(_fd, &c, 1); if (res != 1) throwModemException(_("end of file when reading from TA")); else readDone = true; break; } case 0: ++timeElapsed; break; default: if (errno != EINTR) throwModemException(_("reading from TA")); break; } } if (!readDone) throwModemException(_("timeout when reading from TA")); #ifndef NDEBUG if (debugLevel() >= 2) { // some useful debugging code if (c == LF) std::cerr << "<LF>"; else if (c == CR) std::cerr << "<CR>"; else std::cerr << "<'" << (char) c << "'>"; std::cerr.flush(); } #endif return c; }
false
false
false
false
false
0
test_exact (void) { const char *val[] = { "@NaN@", "-@Inf@", "-2", "-1", "-0", "0", "1", "2", "@Inf@" }; int sv = sizeof (val) / sizeof (*val); int i, j, k; int rnd; mpfr_t a, b, c, r1, r2; mpfr_inits2 (8, a, b, c, r1, r2, (mpfr_ptr) 0); for (i = 0; i < sv; i++) for (j = 0; j < sv; j++) for (k = 0; k < sv; k++) RND_LOOP (rnd) { if (mpfr_set_str (a, val[i], 10, MPFR_RNDN) || mpfr_set_str (b, val[j], 10, MPFR_RNDN) || mpfr_set_str (c, val[k], 10, MPFR_RNDN) || mpfr_mul (r1, a, b, (mpfr_rnd_t) rnd) || mpfr_add (r1, r1, c, (mpfr_rnd_t) rnd)) { printf ("test_exact internal error for (%d,%d,%d,%d)\n", i, j, k, rnd); exit (1); } if (mpfr_fma (r2, a, b, c, (mpfr_rnd_t) rnd)) { printf ("test_exact(%d,%d,%d,%d): mpfr_fma should be exact\n", i, j, k, rnd); exit (1); } if (MPFR_IS_NAN (r1)) { if (MPFR_IS_NAN (r2)) continue; printf ("test_exact(%d,%d,%d,%d): mpfr_fma should be NaN\n", i, j, k, rnd); exit (1); } if (mpfr_cmp (r1, r2) || MPFR_SIGN (r1) != MPFR_SIGN (r2)) { printf ("test_exact(%d,%d,%d,%d):\nexpected ", i, j, k, rnd); mpfr_out_str (stdout, 10, 0, r1, MPFR_RNDN); printf ("\n got "); mpfr_out_str (stdout, 10, 0, r2, MPFR_RNDN); printf ("\n"); exit (1); } } mpfr_clears (a, b, c, r1, r2, (mpfr_ptr) 0); }
false
false
false
false
false
0
close_stdout (void) { if (close_stream (stdout) != 0) { char const *write_error = _("write error"); if (file_name) error (0, errno, "%s: %s", quotearg_colon (file_name), write_error); else error (0, errno, "%s", write_error); _exit (exit_failure); } if (close_stream (stderr) != 0) _exit (exit_failure); }
false
false
false
false
false
0
objectNameGetter(ExecState *exec, JSObject*, const Identifier& name, const PropertySlot& slot) { HTMLDocument *thisObj = static_cast<HTMLDocument*>(slot.slotBase()); DOM::HTMLCollectionImpl objectLike(thisObj->impl(), DOM::HTMLCollectionImpl::DOC_APPLETS); return getDOMNode(exec, objectLike.namedItem(name.domString())); }
false
false
false
false
false
0
ompit_var_type_to_datatype (mca_base_var_type_t type, MPI_Datatype *datatype) { switch (type) { case MCA_BASE_VAR_TYPE_INT: *datatype = MPI_INT; break; case MCA_BASE_VAR_TYPE_UNSIGNED_INT: *datatype = MPI_UNSIGNED; break; case MCA_BASE_VAR_TYPE_UNSIGNED_LONG: *datatype = MPI_UNSIGNED_LONG; break; case MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG: *datatype = MPI_UNSIGNED_LONG_LONG; break; case MCA_BASE_VAR_TYPE_SIZE_T: if (sizeof (size_t) == sizeof (unsigned)) { *datatype = MPI_UNSIGNED; } else if (sizeof (size_t) == sizeof (unsigned long)) { *datatype = MPI_UNSIGNED_LONG; } else if (sizeof (size_t) == sizeof (unsigned long long)) { *datatype = MPI_UNSIGNED_LONG_LONG; } else { /* not supported -- fixme */ assert (0); } break; case MCA_BASE_VAR_TYPE_STRING: *datatype = MPI_CHAR; break; case MCA_BASE_VAR_TYPE_BOOL: if (sizeof (bool) == sizeof (char)) { *datatype = MPI_CHAR; } else if (sizeof (bool) == sizeof (int)) { *datatype = MPI_INT; } else { /* not supported -- fixme */ assert (0); } break; case MCA_BASE_VAR_TYPE_DOUBLE: *datatype = MPI_DOUBLE; break; default: /* not supported -- fixme */ assert (0); break; } return OMPI_SUCCESS; }
false
false
false
false
false
0