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
out( MifOutputByteStream &os ) { os << '\n' << MifOutputByteStream::INDENT << "<PolyLine "; os.indent(); outObjectProperties( os ); CHECK_PROPERTY( HeadCap ); CHECK_PROPERTY( TailCap ); for( size_t i = 0; i < Points.size(); i++ ) os << '\n' << MifOutputByteStream::INDENT << "<Point " << Points[i] << ">"; os.undent(); os << '\n' << MifOutputByteStream::INDENT << ">"; }
false
false
false
false
false
0
lyxRead(Lexer & lex, FontInfo const & fi) { FontInfo f = fi; bool error = false; bool finished = false; while (!finished && lex.isOK() && !error) { lex.next(); string const tok = ascii_lowercase(lex.getString()); if (tok.empty()) { continue; } else if (tok == "endfont") { finished = true; } else if (tok == "family") { lex.next(); string const ttok = lex.getString(); setLyXFamily(ttok, f); } else if (tok == "series") { lex.next(); string const ttok = lex.getString(); setLyXSeries(ttok, f); } else if (tok == "shape") { lex.next(); string const ttok = lex.getString(); setLyXShape(ttok, f); } else if (tok == "size") { lex.next(); string const ttok = lex.getString(); setLyXSize(ttok, f); } else if (tok == "misc") { lex.next(); string const ttok = ascii_lowercase(lex.getString()); if (ttok == "no_bar") { f.setUnderbar(FONT_OFF); } else if (ttok == "no_strikeout") { f.setStrikeout(FONT_OFF); } else if (ttok == "no_uuline") { f.setUuline(FONT_OFF); } else if (ttok == "no_uwave") { f.setUwave(FONT_OFF); } else if (ttok == "no_emph") { f.setEmph(FONT_OFF); } else if (ttok == "no_noun") { f.setNoun(FONT_OFF); } else if (ttok == "emph") { f.setEmph(FONT_ON); } else if (ttok == "underbar") { f.setUnderbar(FONT_ON); } else if (ttok == "strikeout") { f.setStrikeout(FONT_ON); } else if (ttok == "uuline") { f.setUuline(FONT_ON); } else if (ttok == "uwave") { f.setUwave(FONT_ON); } else if (ttok == "noun") { f.setNoun(FONT_ON); } else { lex.printError("Illegal misc type"); } } else if (tok == "color") { lex.next(); string const ttok = lex.getString(); setLyXColor(ttok, f); } else { lex.printError("Unknown tag"); error = true; } } return f; }
false
false
false
false
false
0
setup_stdio() { if (fd_read!=-1 || fd_write!=-1) { MAKE_WARNING(NO_MORE_IO); return false; } setup_stdin(); setup_stdout(); return true; }
false
false
false
false
false
0
search_oneatatime(struct searchinfo *si, unsigned long i, struct searchinfo *sihead, const char *charset, int isuid, void (*callback_func)(struct searchinfo *, struct searchinfo *, int, unsigned long, void *), void *voidarg) { struct searchinfo *p; struct imapflags flags; int fd; FILE *fp; struct stat stat_buf; int rc; { for (p=sihead; p; p=p->next) p->value= -1; /* Search result unknown */ /* First, see if non-content search will be sufficient */ get_message_flags(current_maildir_info.msgs+i, 0, &flags); for (p=sihead; p; p=p->next) fill_search_veryquick(p, i, &flags); if ((rc=search_evaluate(si)) >= 0) { if (rc > 0) (*callback_func)(si, sihead, isuid, i, voidarg); return; } fd=imapscan_openfile(current_mailbox, &current_maildir_info, i); if (fd < 0) return; if ((fp=fdopen(fd, "r")) == 0) write_error_exit(0); if (fstat(fileno(fp), &stat_buf)) { fclose(fp); return; } /* First, see if non-content search will be sufficient */ for (p=sihead; p; p=p->next) fill_search_quick(p, i, &stat_buf); if ((rc=search_evaluate(si)) < 0) { /* No, search the headers then */ /* struct rfc2045 *rfcp=rfc2045_fromfp(fp); */ struct rfc2045 *rfcp=rfc2045header_fromfp(fp); fill_search_header(sihead, charset, rfcp, fp, current_maildir_info.msgs+i); rc=search_evaluate(si); rfc2045_free(rfcp); if (rc < 0) { /* Ok, search message contents */ struct rfc2045 *rfcp=rfc2045_fromfp(fp); fill_search_body(sihead, rfcp, fp, current_maildir_info.msgs+i); /* ** If there are still UNKNOWN nodes, change ** them to fail. */ for (p=sihead; p; p=p->next) if (p->value < 0) p->value=0; rc=search_evaluate(si); rfc2045_free(rfcp); } /* rfc2045_free(rfcp); */ } if (rc > 0) { (*callback_func)(si, sihead, isuid, i, voidarg); } fclose(fp); close(fd); } }
false
false
false
false
true
1
ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) { struct ata_device *dev = args->dev; u64 last_lba = dev->n_sectors - 1; /* LBA of the last block */ u32 sector_size; /* physical sector size in bytes */ u8 log2_per_phys; u16 lowest_aligned; sector_size = ata_id_logical_sector_size(dev->id); log2_per_phys = ata_id_log2_per_physical_sector(dev->id); lowest_aligned = ata_id_logical_sector_offset(dev->id, log2_per_phys); VPRINTK("ENTER\n"); if (args->cmd->cmnd[0] == READ_CAPACITY) { if (last_lba >= 0xffffffffULL) last_lba = 0xffffffff; /* sector count, 32-bit */ rbuf[0] = last_lba >> (8 * 3); rbuf[1] = last_lba >> (8 * 2); rbuf[2] = last_lba >> (8 * 1); rbuf[3] = last_lba; /* sector size */ rbuf[4] = sector_size >> (8 * 3); rbuf[5] = sector_size >> (8 * 2); rbuf[6] = sector_size >> (8 * 1); rbuf[7] = sector_size; } else { /* sector count, 64-bit */ rbuf[0] = last_lba >> (8 * 7); rbuf[1] = last_lba >> (8 * 6); rbuf[2] = last_lba >> (8 * 5); rbuf[3] = last_lba >> (8 * 4); rbuf[4] = last_lba >> (8 * 3); rbuf[5] = last_lba >> (8 * 2); rbuf[6] = last_lba >> (8 * 1); rbuf[7] = last_lba; /* sector size */ rbuf[ 8] = sector_size >> (8 * 3); rbuf[ 9] = sector_size >> (8 * 2); rbuf[10] = sector_size >> (8 * 1); rbuf[11] = sector_size; rbuf[12] = 0; rbuf[13] = log2_per_phys; rbuf[14] = (lowest_aligned >> 8) & 0x3f; rbuf[15] = lowest_aligned; if (ata_id_has_trim(args->id) && !(dev->horkage & ATA_HORKAGE_NOTRIM)) { rbuf[14] |= 0x80; /* LBPME */ if (ata_id_has_zero_after_trim(args->id) && dev->horkage & ATA_HORKAGE_ZERO_AFTER_TRIM) { ata_dev_info(dev, "Enabling discard_zeroes_data\n"); rbuf[14] |= 0x40; /* LBPRZ */ } } } return 0; }
false
false
false
false
false
0
trans(int c) { static char buf[] = "\\x0000"; static char hex[] = "0123456789abcdef"; switch(c) { case '\b': return "\\b"; case '\n': return "\\n"; case '\r': return "\\r"; case '\t': return "\\t"; case '\\': return "\\\\"; } buf[2] = hex[(c>>12)&0xF]; buf[3] = hex[(c>>8)&0xF]; buf[4] = hex[(c>>4)&0xF]; buf[5] = hex[c&0xF]; return buf; }
false
false
false
false
false
0
ctt_str_to_pdu(char* value, dchat_pdu_t* pdu) { int found = 0; dchat_content_types_t ctt; if (init_dchat_content_types(&ctt) == -1) { return -1; } for (int i = 0; i < CTT_AMOUNT; i++) { if (!strcmp(value, ctt.type[i].ctt_name)) { pdu->content_type = ctt.type[i].ctt_id; found = 1; } } return found ? 0 : -1; }
false
false
false
false
false
0
SHPOpenDiskTree( const char* pszQIXFilename, SAHooks *psHooks ) { SHPTreeDiskHandle hDiskTree; hDiskTree = (SHPTreeDiskHandle) calloc(sizeof(struct SHPDiskTreeInfo),1); if (psHooks == NULL) SASetupDefaultHooks( &(hDiskTree->sHooks) ); else memcpy( &(hDiskTree->sHooks), psHooks, sizeof(SAHooks) ); hDiskTree->fpQIX = hDiskTree->sHooks.FOpen(pszQIXFilename, "rb"); if (hDiskTree->fpQIX == NULL) { free(hDiskTree); return NULL; } return hDiskTree; }
false
false
false
false
false
0
fdUpdateBiggest(int fd, int opening) { if (fd < Biggest_FD) return; assert(fd < Squid_MaxFD); if (fd > Biggest_FD) { /* * assert that we are not closing a FD bigger than * our known biggest FD */ assert(opening); Biggest_FD = fd; return; } /* if we are here, then fd == Biggest_FD */ /* * assert that we are closing the biggest FD; we can't be * re-opening it */ assert(!opening); while (!fd_table[Biggest_FD].flags.open && Biggest_FD > 0) Biggest_FD--; }
false
false
false
false
true
1
stacks_with(item rhs) { bool stacks = (type == rhs.type && damage == rhs.damage && active == rhs.active && charges == rhs.charges && contents.size() == rhs.contents.size() && (!goes_bad() || bday == rhs.bday)); if ((corpse == NULL && rhs.corpse != NULL) || (corpse != NULL && rhs.corpse == NULL) ) return false; if (corpse != NULL && rhs.corpse != NULL && corpse->id != rhs.corpse->id) return false; if (contents.size() != rhs.contents.size()) return false; for (int i = 0; i < contents.size() && stacks; i++) stacks &= contents[i].stacks_with(rhs.contents[i]); return stacks; }
false
false
false
false
false
0
hash_corrupted(HTAB *hashp) { /* * If the corruption is in a shared hashtable, we'd better force a * systemwide restart. Otherwise, just shut down this one backend. */ if (hashp->isshared) elog(PANIC, "hash table \"%s\" corrupted", hashp->tabname); else elog(FATAL, "hash table \"%s\" corrupted", hashp->tabname); }
false
false
false
false
false
0
allot_array_1(CELL obj) { REGISTER_ROOT(obj); F_ARRAY *a = allot_array_internal(ARRAY_TYPE,1); UNREGISTER_ROOT(obj); set_array_nth(a,0,obj); return tag_object(a); }
false
false
false
false
false
0
uhc_ipp_extract(gnutella_node_t *n, const char *payload, int paylen, enum net_type type) { int i, cnt; int len = NET_TYPE_IPV6 == type ? 18 : 6; const void *p; g_assert(0 == paylen % len); cnt = paylen / len; if (GNET_PROPERTY(bootstrap_debug)) g_debug("extracting %d host%s in UDP IPP pong #%s from %s", cnt, cnt == 1 ? "" : "s", guid_hex_str(gnutella_header_get_muid(&n->header)), node_addr(n)); for (i = 0, p = payload; i < cnt; i++, p = const_ptr_add_offset(p, len)) { host_addr_t ha; uint16 port; host_ip_port_peek(p, type, &ha, &port); hcache_add_caught(HOST_ULTRA, ha, port, "UDP-HC"); if (GNET_PROPERTY(bootstrap_debug) > 2) g_debug("BOOT collected %s from UDP IPP pong from %s", host_addr_port_to_string(ha, port), node_addr(n)); } if (!uhc_connecting) return; /* * Check whether this was a reply from our request. * * The reply could come well after we decided it timed out and picked * another UDP host cache, which ended-up replying, so we must really * check whether we're still in a probing cycle. */ if (!guid_eq(&uhc_ctx.muid, gnutella_header_get_muid(&n->header))) return; if (GNET_PROPERTY(bootstrap_debug)) { g_debug("BOOT UDP cache \"%s\" replied: got %d host%s from %s", uhc_ctx.host, cnt, cnt == 1 ? "" : "s", node_addr(n)); } /* * Terminate the probing cycle if we got hosts. */ if (cnt > 0) { char msg[256]; cq_cancel(&uhc_ctx.timeout_ev); uhc_connecting = FALSE; str_bprintf(msg, sizeof(msg), NG_("Got %d host from UDP host cache %s", "Got %d hosts from UDP host cache %s", cnt), cnt, uhc_ctx.host); gcu_statusbar_message(msg); } else { uhc_try_random(); } }
false
false
false
false
false
0
IoList_rawAtPut(IoList *self, int i, IoObject *v) { while (List_size(DATA(self)) < i) /* not efficient */ { List_append_(DATA(self), IONIL(self)); } List_at_put_(DATA(self), i, IOREF(v)); IoObject_isDirty_(self, 1); }
false
false
false
false
false
0
mwifiex_hscfg_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct mwifiex_private *priv = (void *)file->private_data; unsigned long addr = get_zeroed_page(GFP_KERNEL); char *buf = (char *)addr; size_t buf_size = min_t(size_t, count, PAGE_SIZE - 1); int ret, arg_num; struct mwifiex_ds_hs_cfg hscfg; int conditions = HS_CFG_COND_DEF; u32 gpio = HS_CFG_GPIO_DEF, gap = HS_CFG_GAP_DEF; if (!buf) return -ENOMEM; if (copy_from_user(buf, ubuf, buf_size)) { ret = -EFAULT; goto done; } arg_num = sscanf(buf, "%d %x %x", &conditions, &gpio, &gap); memset(&hscfg, 0, sizeof(struct mwifiex_ds_hs_cfg)); if (arg_num > 3) { mwifiex_dbg(priv->adapter, ERROR, "Too many arguments\n"); ret = -EINVAL; goto done; } if (arg_num >= 1 && arg_num < 3) mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_GET, MWIFIEX_SYNC_CMD, &hscfg); if (arg_num) { if (conditions == HS_CFG_CANCEL) { mwifiex_cancel_hs(priv, MWIFIEX_ASYNC_CMD); ret = count; goto done; } hscfg.conditions = conditions; } if (arg_num >= 2) hscfg.gpio = gpio; if (arg_num == 3) hscfg.gap = gap; hscfg.is_invoke_hostcmd = false; mwifiex_set_hs_params(priv, HostCmd_ACT_GEN_SET, MWIFIEX_SYNC_CMD, &hscfg); mwifiex_enable_hs(priv->adapter); priv->adapter->hs_enabling = false; ret = count; done: free_page(addr); return ret; }
false
false
false
false
false
0
v4l2_match_dv_timings(const struct v4l2_dv_timings *t1, const struct v4l2_dv_timings *t2, unsigned pclock_delta) { if (t1->type != t2->type || t1->type != V4L2_DV_BT_656_1120) return false; if (t1->bt.width == t2->bt.width && t1->bt.height == t2->bt.height && t1->bt.interlaced == t2->bt.interlaced && t1->bt.polarities == t2->bt.polarities && t1->bt.pixelclock >= t2->bt.pixelclock - pclock_delta && t1->bt.pixelclock <= t2->bt.pixelclock + pclock_delta && t1->bt.hfrontporch == t2->bt.hfrontporch && t1->bt.vfrontporch == t2->bt.vfrontporch && t1->bt.vsync == t2->bt.vsync && t1->bt.vbackporch == t2->bt.vbackporch && (!t1->bt.interlaced || (t1->bt.il_vfrontporch == t2->bt.il_vfrontporch && t1->bt.il_vsync == t2->bt.il_vsync && t1->bt.il_vbackporch == t2->bt.il_vbackporch))) return true; return false; }
false
false
false
false
false
0
config() { /* get string variables */ if (!( (log_fname = getenv("log_file")) && (song_path = getenv("stimulus_path")) && (data_fname = getenv("data_file")) && (song[0] = getenv("stimulus1")) && (song[1] = getenv("stimulus2")) ) ) { fprintf(stderr,"Environment variables not set\n"); exit(1); } /* get numeric variables */ const char *str; if ((str=getenv("ethernet"))) ethernet = atoi(str); if ((str=getenv("session_duration"))) session_min = atoi(str); if ((str=getenv("intertrial_interval"))) intertrial_sec = atoi(str); if ((str=getenv("interbout_interval"))) interbout_sec = atoi(str); if ((str=getenv("forced_trials"))) forced_trials = atoi(str); if ((str=getenv("free_trials"))) free_trials = atoi(str); if (forced_trials > 64) forced_trials = 64; /* create song name strings */ strncpy(song_name[0], song[0], 64); strncpy(song_name[1], song[1], 64); char *c = strrchr(song_name[0], '.'); if (c) *c = '\0'; c = strrchr(song_name[1], '.'); if (c) *c = '\0'; return 0; }
false
false
false
false
false
0
zend_do_add_variable(znode *result, const znode *op1, const znode *op2 TSRMLS_DC) /* {{{ */ { zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = ZEND_ADD_VAR; if (op1) { SET_NODE(opline->op1, op1); SET_NODE(opline->result, op1); } else { SET_UNUSED(opline->op1); opline->result_type = IS_TMP_VAR; opline->result.var = get_temporary_variable(CG(active_op_array)); } SET_NODE(opline->op2, op2); GET_NODE(result, opline->result); }
false
false
false
false
false
0
hostaddr_expr_1() { try { // for error handling hostaddr_expr(); } catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) { if( inputState->guessing == 0 ) { reportError(ex); recover(ex,_tokenSet_27); } else { throw; } } }
false
false
false
false
false
0
find_newline (const gchar *ptr, const gchar *end, const gchar **line_end) { while (ptr < end) { gunichar c; c = g_utf8_get_char (ptr); if (c == '\n') { /* That's it */ *line_end = g_utf8_next_char (ptr); return ptr; } else if (c == '\r') { gchar *next; next = g_utf8_next_char (ptr); if (next < end) { gunichar n = g_utf8_get_char (next); if (n == '\n') { /* Consume both! */ *line_end = g_utf8_next_char (next); return ptr; } else { /* That's it! */ *line_end = next; return ptr; } } else { /* Need to save it, it might come later... */ break; } } ptr = g_utf8_next_char (ptr); } return NULL; }
false
false
false
false
false
0
gkm_ssh_private_key_get_attribute (GkmObject *base, GkmSession *session, CK_ATTRIBUTE_PTR attr) { GkmSshPrivateKey *self = GKM_SSH_PRIVATE_KEY (base); gchar *digest; CK_RV rv; switch (attr->type) { case CKA_LABEL: return gkm_attribute_set_string (attr, self->label); /* COMPAT: Previous versions of gnome-keyring used this to save unlock passwords */ case CKA_GNOME_INTERNAL_SHA1: if (!self->private_bytes) { gkm_debug ("CKR_ATTRIBUTE_TYPE_INVALID: no CKA_GNOME_INTERNAL_SHA1 attribute"); return CKR_ATTRIBUTE_TYPE_INVALID; } digest = gkm_ssh_openssh_digest_private_key (self->private_bytes); rv = gkm_attribute_set_string (attr, digest); g_free (digest); return rv; } return GKM_OBJECT_CLASS (gkm_ssh_private_key_parent_class)->get_attribute (base, session, attr); }
false
false
false
false
false
0
read(void *buf, offile_off_t buflen) { if (status_.bad() || (current_ == NULL) || (buf == NULL)) return 0; unsigned char *target = OFstatic_cast(unsigned char *, buf); offile_off_t offset = 0; offile_off_t availBytes = 0; offile_off_t result = 0; do { // copy bytes from output buffer to user provided block of data if (outputBufCount_) { // determine next block of data in output buffer offset = outputBufStart_ + outputBufPutback_; if (offset >= DCMZLIBINPUTFILTER_BUFSIZE) offset -= DCMZLIBINPUTFILTER_BUFSIZE; availBytes = outputBufCount_; if (offset + availBytes > DCMZLIBINPUTFILTER_BUFSIZE) availBytes = DCMZLIBINPUTFILTER_BUFSIZE - offset; if (availBytes > buflen) availBytes = buflen; if (availBytes) memcpy(target, outputBuf_ + offset, OFstatic_cast(size_t, availBytes)); target += availBytes; result += availBytes; buflen -= availBytes; // adjust pointers outputBufPutback_ += availBytes; outputBufCount_ -= availBytes; if (outputBufPutback_ > DCMZLIBINPUTFILTER_PUTBACKSIZE) { outputBufStart_ += outputBufPutback_ - DCMZLIBINPUTFILTER_PUTBACKSIZE; if (outputBufStart_ >= DCMZLIBINPUTFILTER_BUFSIZE) outputBufStart_ -= DCMZLIBINPUTFILTER_BUFSIZE; outputBufPutback_ = DCMZLIBINPUTFILTER_PUTBACKSIZE; } } // refill output buffer fillOutputBuffer(); } while (buflen && outputBufCount_); // we're either done or the output buffer is empty because of producer suspension return result; }
false
false
false
false
false
0
nextTip() { if (m_tip == NULL) return; m_tip->setText(QString("<a href='tip' style='text-decoration:none; color:#2e94af;'>%1</a>").arg(TipsAndTricks::randomTip())); }
false
false
false
false
false
0
_free_filetxt_header(void *object) { filetxt_header_t *header = (filetxt_header_t *)object; if (header) { xfree(header->partition); #ifdef HAVE_BG xfree(header->blockid); #endif } }
false
false
false
false
false
0
gf_cfg_init(const char *file, Bool *new_cfg) { GF_Config *cfg; char szPath[GF_MAX_PATH]; if (new_cfg) *new_cfg = 0; if (file) { cfg = gf_cfg_new(NULL, file); /*force creation of a new config*/ if (!cfg) { FILE *fcfg = fopen(file, "wt"); if (fcfg) { fclose(fcfg); cfg = gf_cfg_new(NULL, file); if (new_cfg) *new_cfg = 1; } } if (cfg) { check_modules_dir(cfg); return cfg; } } if (!get_default_install_path(szPath, GF_PATH_CFG)) { fprintf(stderr, "Fatal error: Cannot create a configuration file in application or user home directory - no write access\n"); return NULL; } cfg = gf_cfg_new(szPath, CFG_FILE_NAME); if (!cfg) { fprintf(stderr, "GPAC config file %s not found in %s - creating new file\n", CFG_FILE_NAME, szPath); cfg = create_default_config(szPath); } if (!cfg) { fprintf(stderr, "Cannot create config file %s in %s directory\n", CFG_FILE_NAME, szPath); return NULL; } fprintf(stderr, "Using config file in %s directory\n", szPath); check_modules_dir(cfg); if (new_cfg) *new_cfg = 1; return cfg; }
false
false
false
false
false
0
aclLookupProxyAuthStart(aclCheck_t * checklist) { auth_user_request_t *auth_user_request; /* make sure someone created auth_user_request for us */ assert(checklist->auth_user_request != NULL); auth_user_request = checklist->auth_user_request; assert(authenticateValidateUser(auth_user_request)); authenticateStart(auth_user_request, aclLookupProxyAuthDone, checklist); }
false
false
false
false
false
0
select_obstacles_on_tile(int x, int y) { int idx, a; for (a = 0; a < EditLevel()->map[y][x].glued_obstacles.size; a++) { idx = ((int *)(EditLevel()->map[y][x].glued_obstacles.arr))[a]; if (!element_in_selection(&EditLevel()->obstacle_list[idx])) { add_object_to_list(&selected_elements, &EditLevel()->obstacle_list[idx], OBJECT_OBSTACLE); state.rect_nbelem_selected++; } } }
false
false
false
false
false
0
add_trace_hashed (CallContext *traces, int size, BackTrace *bt, uint64_t value) { int i; unsigned int start_pos; start_pos = bt->hash % size; i = start_pos; do { if (traces [i].bt == bt) { traces [i].count += value; return 0; } else if (!traces [i].bt) { traces [i].bt = bt; traces [i].count += value; return 1; } /* wrap around */ if (++i == size) i = 0; } while (i != start_pos); /* should not happen */ printf ("failed trace store\n"); return 0; }
false
false
false
false
false
0
recruit_jobless_worker(Firm* destFirmPtr, int preferedRaceId) { #define MIN_AI_TOWN_POP 8 int needSpecificRace, raceId; // the race of the needed unit if( preferedRaceId ) { raceId = preferedRaceId; needSpecificRace = 1; } else { if( destFirmPtr->firm_id == FIRM_BASE ) // for seat of power, the race must be specific { raceId = firm_res.get_build(destFirmPtr->firm_build_id)->race_id; needSpecificRace = 1; } else { raceId = destFirmPtr->majority_race(); needSpecificRace = 0; } } if( !raceId ) return 0; //----- locate the best town for recruiting the unit -----// Town *townPtr; int curDist, curRating, bestRating=0, bestTownRecno=0; for( int i=0; i<ai_town_count; i++ ) { townPtr = town_array[ai_town_array[i]]; err_when( townPtr->nation_recno != nation_recno ); if( !townPtr->jobless_population ) // no jobless population or currently a unit is being recruited continue; if( !townPtr->should_ai_migrate() ) // if the town is going to migrate, disregard the minimum population consideration { if( townPtr->population < MIN_AI_TOWN_POP ) // don't recruit workers if the population is low continue; } if( !townPtr->has_linked_own_camp && townPtr->has_linked_enemy_camp ) // cannot recruit from this town if there are enemy camps but no own camps continue; if( townPtr->region_id != destFirmPtr->region_id ) continue; //--- get the distance beteween town & the destination firm ---// curDist = misc.points_distance(townPtr->center_x, townPtr->center_y, destFirmPtr->center_x, destFirmPtr->center_y); curRating = 100-100*curDist/MAX_WORLD_X_LOC; //--- recruit units from non-base town first ------// if( !townPtr->is_base_town ) curRating += 100; //---- if the town has the race that the firm needs most ----// if( townPtr->can_recruit(raceId) ) { curRating += 50 + (int) townPtr->race_loyalty_array[raceId-1]; } else { if( needSpecificRace ) // if the firm must need this race, don't consider the town if it doesn't have the race. continue; } if( curRating > bestRating ) { bestRating = curRating; bestTownRecno = townPtr->town_recno; } } if( !bestTownRecno ) return 0; //---------- recruit the unit ------------// townPtr = town_array[bestTownRecno]; if( townPtr->recruitable_race_pop(raceId, 1) == 0 ) { err_when( needSpecificRace ); raceId = townPtr->pick_random_race(0, 1); // 0-pick jobless only, 1-pick spy units if( !raceId ) return 0; } //--- if the chosen race is not recruitable, pick any recruitable race ---// if( !townPtr->can_recruit(raceId) ) { //---- if the loyalty is too low to recruit, grant the town people first ---// if( cash > 0 && townPtr->accumulated_reward_penalty < 10 ) townPtr->reward(COMMAND_AI); //---- if the loyalty is still too low, return now ----// if( !townPtr->can_recruit(raceId) ) return 0; } return townPtr->recruit(-1, raceId, COMMAND_AI); }
false
false
false
false
false
0
graph_open_window(const char *title, const char *geometry, REAL *world, MESH *mesh) { FUNCNAME("graph_open_window"); switch(mesh->dim) { #if DIM_OF_WORLD == 1 case 1: return graph_open_window_1d(title, geometry, world, mesh); #endif #if DIM_OF_WORLD == 2 case 2: return graph_open_window_2d(title, geometry, world, mesh); #endif case 3: ERROR("Not implemented for dim == 3!\n"); return 0; default: ERROR_EXIT("Illegal mesh->dim: must equal DIM_OF_WORLD\n"); } return 0; }
false
false
false
false
false
0
iterate_fix_dominators (dom, bbs, n) dominance_info dom; basic_block *bbs; int n; { int i, changed = 1; basic_block old_dom, new_dom; while (changed) { changed = 0; for (i = 0; i < n; i++) { old_dom = get_immediate_dominator (dom, bbs[i]); new_dom = recount_dominator (dom, bbs[i]); if (old_dom != new_dom) { changed = 1; set_immediate_dominator (dom, bbs[i], new_dom); } } } }
false
false
false
false
false
0
update_loyalty() { if( firm_res[firm_id]->live_in_town ) // only for those who do not live in town return; //----- update loyalty of the soldiers -----// Worker* workerPtr = worker_array; for( int i=0 ; i<worker_count ; i++, workerPtr++ ) { int targetLoyalty = workerPtr->target_loyalty(firm_recno); if( targetLoyalty > workerPtr->worker_loyalty ) { int incValue = (targetLoyalty - workerPtr->worker_loyalty)/10; int newLoyalty = (int) workerPtr->worker_loyalty + MAX(1, incValue); if( newLoyalty > targetLoyalty ) newLoyalty = targetLoyalty; workerPtr->worker_loyalty = newLoyalty; } else if( targetLoyalty < workerPtr->worker_loyalty ) { workerPtr->worker_loyalty--; } } }
false
false
false
false
false
0
gs_job_scan(void) { if (slurmctld_conf.debug_flags & DEBUG_FLAG_GANG) info("gang: entering gs_job_scan"); pthread_mutex_lock(&data_mutex); _scan_slurm_job_list(); pthread_mutex_unlock(&data_mutex); _preempt_job_dequeue(); /* MUST BE OUTSIDE OF data_mutex lock */ if (slurmctld_conf.debug_flags & DEBUG_FLAG_GANG) info("gang: leaving gs_job_scan"); return SLURM_SUCCESS; }
false
false
false
false
false
0
read(char* s, std::streamsize n) { #ifdef BOOST_IOSTREAMS_WINDOWS DWORD result; if (!::ReadFile(handle_, s, n, &result, NULL)) { // report EOF if the write-side of a pipe has been closed if (GetLastError() == ERROR_BROKEN_PIPE) { result = 0; } else throw_system_failure("failed reading"); } return result == 0 ? -1 : static_cast<std::streamsize>(result); #else // #ifdef BOOST_IOSTREAMS_WINDOWS errno = 0; std::streamsize result = BOOST_IOSTREAMS_FD_READ(handle_, s, n); if (errno != 0) throw_system_failure("failed reading"); return result == 0 ? -1 : result; #endif // #ifdef BOOST_IOSTREAMS_WINDOWS }
false
false
false
false
false
0
wm_adsp1_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event) { struct snd_soc_codec *codec = snd_soc_dapm_to_codec(w->dapm); struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); struct wm_adsp *dsp = &dsps[w->shift]; struct wm_adsp_alg_region *alg_region; struct wm_coeff_ctl *ctl; int ret; int val; dsp->card = codec->component.card; switch (event) { case SND_SOC_DAPM_POST_PMU: regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, ADSP1_SYS_ENA, ADSP1_SYS_ENA); /* * For simplicity set the DSP clock rate to be the * SYSCLK rate rather than making it configurable. */ if(dsp->sysclk_reg) { ret = regmap_read(dsp->regmap, dsp->sysclk_reg, &val); if (ret != 0) { adsp_err(dsp, "Failed to read SYSCLK state: %d\n", ret); return ret; } val = (val & dsp->sysclk_mask) >> dsp->sysclk_shift; ret = regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_31, ADSP1_CLK_SEL_MASK, val); if (ret != 0) { adsp_err(dsp, "Failed to set clock rate: %d\n", ret); return ret; } } ret = wm_adsp_load(dsp); if (ret != 0) goto err; ret = wm_adsp1_setup_algs(dsp); if (ret != 0) goto err; ret = wm_adsp_load_coeff(dsp); if (ret != 0) goto err; /* Initialize caches for enabled and unset controls */ ret = wm_coeff_init_control_caches(dsp); if (ret != 0) goto err; /* Sync set controls */ ret = wm_coeff_sync_controls(dsp); if (ret != 0) goto err; /* Start the core running */ regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, ADSP1_CORE_ENA | ADSP1_START, ADSP1_CORE_ENA | ADSP1_START); break; case SND_SOC_DAPM_PRE_PMD: /* Halt the core */ regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, ADSP1_CORE_ENA | ADSP1_START, 0); regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_19, ADSP1_WDMA_BUFFER_LENGTH_MASK, 0); regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, ADSP1_SYS_ENA, 0); list_for_each_entry(ctl, &dsp->ctl_list, list) ctl->enabled = 0; while (!list_empty(&dsp->alg_regions)) { alg_region = list_first_entry(&dsp->alg_regions, struct wm_adsp_alg_region, list); list_del(&alg_region->list); kfree(alg_region); } break; default: break; } return 0; err: regmap_update_bits(dsp->regmap, dsp->base + ADSP1_CONTROL_30, ADSP1_SYS_ENA, 0); return ret; }
false
false
false
false
false
0
au_qu_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 Australia/Queensland. */ { register int day; register int i; ptr_cc_id = "AU_QU"; au_hdy (init_data, detected, easter, year, hd_elems, fday, count); holiday (*init_data, detected, _(hd_text[HD_GOOD_SATURDAY].ht_text), ptr_cc_id, "+", easter - 1, 0, year, hd_elems, fday, count); day = 26; i = weekday_of_date (day, MONTH_MAX, year); if (i > 5) day += 2; else if (i == DAY_MIN) day++; holiday (*init_data, detected, _(hd_text[HD_BOXING_DAY].ht_text), ptr_cc_id, "+", day, MONTH_MAX, year, hd_elems, fday, count); day = eval_holiday (DAY_MIN, 6, year, DAY_MIN, TRUE) + DAY_MAX; holiday (*init_data, detected, _(hd_text[HD_THE_QUEENS_BIRTHDAY].ht_text), ptr_cc_id, "+", day, 6, year, hd_elems, fday, count); day = eval_holiday (DAY_MIN, 5, year, DAY_MIN, TRUE); holiday (*init_data, detected, _(hd_text[HD_LABOUR_DAY].ht_text), ptr_cc_id, "+", day, 5, year, hd_elems, fday, count); }
false
false
false
false
false
0
hyperexp_complete_gradient(double *p, int np, void *dptr, double *dp) { struct hyperexp_data *data = (struct hyperexp_data *) dptr; ESL_HYPEREXP *h = data->h; double pdf; int i,k; int pidx; hyperexp_unpack_paramvector(p, np, h); esl_vec_DSet(dp, np, 0.); for (i = 0; i < data->n; i++) { /* FIXME: I think the calculation below may need to be done * in log space, to avoid underflow errors; see complete_binned_gradient() */ /* Precalculate q_k PDF_k(x) terms, and their sum */ for (k = 0; k < h->K; k++) h->wrk[k] = h->q[k] * esl_exp_pdf(data->x[i], h->mu, h->lambda[k]); pdf = esl_vec_DSum(h->wrk, h->K); pidx = 0; if (! h->fixmix) { for (k = 1; k < h->K; k++) /* generic d/dQ solution for mixture models */ dp[pidx++] -= h->wrk[k]/pdf - h->q[k]; } for (k = 0; k < h->K; k++) if (! h->fixlambda[k]) dp[pidx++] -= (1.-h->lambda[k]*(data->x[i]-h->mu))*h->wrk[k]/pdf; /* d/dw */ } }
false
false
false
false
false
0
reset_ep_state(struct htc_target *target) { struct htc_endpoint *endpoint; int i; for (i = ENDPOINT_0; i < ENDPOINT_MAX; i++) { endpoint = &target->endpoint[i]; memset(&endpoint->cred_dist, 0, sizeof(endpoint->cred_dist)); endpoint->svc_id = 0; endpoint->len_max = 0; endpoint->max_txq_depth = 0; memset(&endpoint->ep_st, 0, sizeof(endpoint->ep_st)); INIT_LIST_HEAD(&endpoint->rx_bufq); INIT_LIST_HEAD(&endpoint->txq); endpoint->target = target; } /* reset distribution list */ /* FIXME: free existing entries */ INIT_LIST_HEAD(&target->cred_dist_list); }
false
false
false
false
false
0
EvaluateNE(IODSCellEvaluator* poEvaluator) { CPLAssert( eNodeType == SNT_OPERATION ); CPLAssert( eOp == ODS_NE ); eOp = ODS_EQ; if (!EvaluateEQ(poEvaluator)) return FALSE; int_value = !int_value; return TRUE; }
false
false
false
false
false
0
mark_beginning_as_normal (mach) register int mach; { switch (state_type[mach]) { case STATE_NORMAL: /* Oh, we've already visited here. */ return; case STATE_TRAILING_CONTEXT: state_type[mach] = STATE_NORMAL; if (transchar[mach] == SYM_EPSILON) { if (trans1[mach] != NO_TRANSITION) mark_beginning_as_normal (trans1[mach]); if (trans2[mach] != NO_TRANSITION) mark_beginning_as_normal (trans2[mach]); } break; default: flexerror (_ ("bad state type in mark_beginning_as_normal()")); break; } }
false
false
false
false
false
0
aim_send_login(aim_session_t *sess, aim_conn_t *conn, const char *sn, const char *password, struct client_info_s *ci, const char *key) { aim_frame_t *fr; aim_tlvlist_t *tl = NULL; fu8_t digest[16]; aim_snacid_t snacid; if (!ci || !sn || !password) return -EINVAL; /* * What the XORLOGIN flag _really_ means is that its an ICQ login, * which is really stupid and painful, so its not done here. * */ if (sess->flags & AIM_SESS_FLAGS_XORLOGIN) return goddamnicq2(sess, conn, sn, password, ci); if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 1152))) return -ENOMEM; snacid = aim_cachesnac(sess, 0x0017, 0x0002, 0x0000, NULL, 0); aim_putsnac(&fr->data, 0x0017, 0x0002, 0x0000, snacid); aim_addtlvtochain_raw(&tl, 0x0001, strlen(sn), (unsigned char *)sn); aim_encode_password_md5(password, key, digest); aim_addtlvtochain_raw(&tl, 0x0025, 16, digest); /* * Newer versions of winaim have an empty type x004c TLV here. */ if (ci->clientstring) aim_addtlvtochain_raw(&tl, 0x0003, strlen(ci->clientstring), (unsigned char *)ci->clientstring); aim_addtlvtochain16(&tl, 0x0016, (fu16_t) ci->clientid); aim_addtlvtochain16(&tl, 0x0017, (fu16_t) ci->major); aim_addtlvtochain16(&tl, 0x0018, (fu16_t) ci->minor); aim_addtlvtochain16(&tl, 0x0019, (fu16_t) ci->point); aim_addtlvtochain16(&tl, 0x001a, (fu16_t) ci->build); aim_addtlvtochain32(&tl, 0x0014, (fu32_t) ci->distrib); aim_addtlvtochain_raw(&tl, 0x000e, strlen(ci->country), (unsigned char *)ci->country); aim_addtlvtochain_raw(&tl, 0x000f, strlen(ci->lang), (unsigned char *)ci->lang); #ifndef NOSSI /* * If set, old-fashioned buddy lists will not work. You will need * to use SSI. */ aim_addtlvtochain8(&tl, 0x004a, 0x01); #endif aim_writetlvchain(&fr->data, &tl); aim_freetlvchain(&tl); aim_tx_enqueue(sess, fr); return 0; }
false
false
false
false
false
0
get_mixer_info(int dev, void __user *arg) { mixer_info info; memset(&info, 0, sizeof(info)); strlcpy(info.id, mixer_devs[dev]->id, sizeof(info.id)); strlcpy(info.name, mixer_devs[dev]->name, sizeof(info.name)); info.modify_counter = mixer_devs[dev]->modify_counter; if (__copy_to_user(arg, &info, sizeof(info))) return -EFAULT; return 0; }
false
false
false
false
false
0
Clp_NewParser(int argc, const char * const *argv, int nopt, const Clp_Option *opt) { Clp_Parser *clp = (Clp_Parser *)malloc(sizeof(Clp_Parser)); Clp_Internal *cli = (Clp_Internal *)malloc(sizeof(Clp_Internal)); Clp_InternOption *iopt = (Clp_InternOption *)malloc(sizeof(Clp_InternOption) * nopt); if (cli) cli->valtype = (Clp_ValType *)malloc(sizeof(Clp_ValType) * Clp_InitialValType); if (!clp || !cli || !iopt || !cli->valtype) goto failed; clp->negated = 0; clp->have_val = 0; clp->vstr = 0; clp->user_data = 0; clp->internal = cli; cli->opt = opt; cli->nopt = nopt; cli->iopt = iopt; cli->opt_generation = 0; cli->error_handler = 0; /* Assign program name (now so we can call Clp_OptionError) */ if (argc > 0) { const char *slash = strrchr(argv[0], '/'); cli->program_name = slash ? slash + 1 : argv[0]; } else cli->program_name = 0; /* Assign arguments, skipping program name */ Clp_SetArguments(clp, argc - 1, argv + 1); /* Initialize UTF-8 status and option classes */ { char *s = getenv("LANG"); cli->utf8 = (s && (strstr(s, "UTF-8") != 0 || strstr(s, "UTF8") != 0 || strstr(s, "utf8") != 0)); } cli->oclass[0].c = '-'; cli->oclass[0].type = Clp_Short; cli->noclass = 1; cli->long1pos = cli->long1neg = 0; /* Add default type parsers */ cli->nvaltype = 0; Clp_AddType(clp, Clp_ValString, 0, parse_string, 0); Clp_AddType(clp, Clp_ValStringNotOption, Clp_DisallowOptions, parse_string, 0); Clp_AddType(clp, Clp_ValInt, 0, parse_int, 0); Clp_AddType(clp, Clp_ValUnsigned, 0, parse_int, (void *)cli); Clp_AddType(clp, Clp_ValBool, 0, parse_bool, 0); Clp_AddType(clp, Clp_ValDouble, 0, parse_double, 0); /* Set options */ Clp_SetOptions(clp, nopt, opt); return clp; failed: if (cli && cli->valtype) free(cli->valtype); if (cli) free(cli); if (clp) free(clp); if (iopt) free(iopt); return 0; }
false
true
false
false
false
1
doAutoCorr(gdouble** Dipole, gdouble* X, gint M) { int m,n,j; for (m = 0; m < M; m++) X[m] = 0.0; /* This algorithm was adapted from the formulas given in J. Kohanoff Comp. Mat. Sci. 2 221-232 (1994). The estimator formulation used here is unbiased and statistically consistent, Looping through all time origins to collect an average - */ int NCorr = 3*M/4; int Nav = M - NCorr; for (m = 0; m < NCorr; m++) for (n = 0; n < Nav; n++) for (j = 0; j < 3; j++) X[m] += Dipole[n + m][j] * Dipole[n][j]; for (m = 0; m < NCorr; m++) X[m] /= Nav; return NCorr; }
false
false
false
false
false
0
process_delete(unsigned char *cp, size_t len) { struct isakmp_delete *hdr = (struct isakmp_delete *) cp; char *msg; char *hex_spi; unsigned char *delete_spi; size_t spi_len; if (len < sizeof(struct isakmp_delete) || ntohs(hdr->isad_length) < sizeof(struct isakmp_delete)) return make_message("Delete (packet too short to decode)"); delete_spi = cp + sizeof(struct isakmp_delete); spi_len = ntohs(hdr->isad_length) < len ? ntohs(hdr->isad_length) : len; spi_len -= sizeof(struct isakmp_delete); hex_spi = hexstring(delete_spi, spi_len); msg=make_message("Delete=(SPI_Size=%u, SPI_Count=%u, SPI_Data=%s)", hdr->isad_spisize, ntohs(hdr->isad_nospi), hex_spi); free(hex_spi); return msg; }
false
false
false
false
false
0
mei_me_hw_ready_wait(struct mei_device *dev) { mutex_unlock(&dev->device_lock); wait_event_timeout(dev->wait_hw_ready, dev->recvd_hw_ready, mei_secs_to_jiffies(MEI_HW_READY_TIMEOUT)); mutex_lock(&dev->device_lock); if (!dev->recvd_hw_ready) { dev_err(dev->dev, "wait hw ready failed\n"); return -ETIME; } mei_me_hw_reset_release(dev); dev->recvd_hw_ready = false; return 0; }
false
false
false
false
false
0
start_test_context (CutStreamParserPrivate *priv, GMarkupParseContext *context, const gchar *element_name, GError **error) { if (g_str_equal("test-suite", element_name)) { CutTestSuite *test_suite; PUSH_STATE(priv, IN_TEST_SUITE); test_suite = cut_test_suite_new_empty(); cut_test_context_set_test_suite(PEEK_TEST_CONTEXT(priv), test_suite); PUSH_TEST_SUITE(priv, test_suite); g_object_unref(test_suite); } else if (g_str_equal("test-case", element_name)) { CutTestCase *test_case; PUSH_STATE(priv, IN_TEST_CASE); test_case = cut_test_case_new_empty(); cut_test_context_set_test_case(PEEK_TEST_CONTEXT(priv), test_case); PUSH_TEST_CASE(priv, test_case); g_object_unref(test_case); } else if (g_str_equal("test-iterator", element_name)) { CutTestIterator *test_iterator; PUSH_STATE(priv, IN_TEST_ITERATOR); test_iterator = cut_test_iterator_new_empty(); cut_test_context_set_test_iterator(PEEK_TEST_CONTEXT(priv), test_iterator); PUSH_TEST_ITERATOR(priv, test_iterator); g_object_unref(test_iterator); } else if (g_str_equal("test", element_name)) { CutTest *test; PUSH_STATE(priv, IN_TEST); test = cut_test_new_empty(); cut_test_context_set_test(PEEK_TEST_CONTEXT(priv), test); PUSH_TEST(priv, test); g_object_unref(test); } else if (g_str_equal("iterated-test", element_name)) { CutIteratedTest *iterated_test; PUSH_STATE(priv, IN_ITERATED_TEST); iterated_test = cut_iterated_test_new_empty(); cut_test_context_set_test(PEEK_TEST_CONTEXT(priv), CUT_TEST(iterated_test)); PUSH_TEST(priv, CUT_TEST(iterated_test)); g_object_unref(iterated_test); } else if (g_str_equal("test-data", element_name)) { CutTestData *test_data; PUSH_STATE(priv, IN_TEST_DATA); test_data = cut_test_data_new_empty(); cut_test_context_set_data(PEEK_TEST_CONTEXT(priv), test_data); PUSH_TEST_DATA(priv, test_data); g_object_unref(test_data); } else if (g_str_equal("failed", element_name)) { PUSH_STATE(priv, IN_TEST_CONTEXT_FAILED); } else { invalid_element(priv, context, error); } }
false
false
false
false
false
0
snd_usb_caiaq_ep4_reply_dispatch(struct urb *urb) { struct snd_usb_caiaqdev *cdev = urb->context; unsigned char *buf = urb->transfer_buffer; struct device *dev = &urb->dev->dev; int ret; if (urb->status || !cdev || urb != cdev->ep4_in_urb) return; switch (cdev->chip.usb_id) { case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLX1): if (urb->actual_length < 24) goto requeue; if (buf[0] & 0x3) snd_caiaq_input_read_io(cdev, buf + 1, 7); if (buf[0] & 0x4) snd_caiaq_input_read_analog(cdev, buf + 8, 16); break; case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_TRAKTORKONTROLS4): snd_usb_caiaq_tks4_dispatch(cdev, buf, urb->actual_length); break; case USB_ID(USB_VID_NATIVEINSTRUMENTS, USB_PID_MASCHINECONTROLLER): if (urb->actual_length < (MASCHINE_PADS * MASCHINE_MSGBLOCK_SIZE)) goto requeue; snd_usb_caiaq_maschine_dispatch(cdev, buf, urb->actual_length); break; } requeue: cdev->ep4_in_urb->actual_length = 0; ret = usb_submit_urb(cdev->ep4_in_urb, GFP_ATOMIC); if (ret < 0) dev_err(dev, "unable to submit urb. OOM!?\n"); }
false
false
false
false
false
0
isValid(const QVariant& value) const { if (value.canConvert(QVariant::Bool)) { QString str(value.toString()); return (str == "true" || str == "false"); } return false; }
false
false
false
false
false
0
reset_trig_time() { if (!auto_rate) auto_rate = 1; auto_trig_time = mnow() + 300 / (1 + auto_rate); }
false
false
false
false
false
0
balance_need_close(struct btrfs_fs_info *fs_info) { /* cancel requested || normal exit path */ return atomic_read(&fs_info->balance_cancel_req) || (atomic_read(&fs_info->balance_pause_req) == 0 && atomic_read(&fs_info->balance_cancel_req) == 0); }
false
false
false
false
false
0
_gwy_scratch_buffer_ensure(gdouble *buffer, guint n) { _GwyScratchBuffer *buf; if (buffer) { buf = _GWY_SCRATCH_BUFFER_GET(buffer); if (n <= buf->head.info.alloc_len) return buffer; _gwy_scratch_buffer_free_backend(buf, buf->head.info.alloc_len); } n = _GWY_SCRATCH_BUFFER_ALIGN(n, _GWY_SCRATCH_BUFFER_ALIGNMENT); buf = _gwy_scratch_buffer_alloc_backend(n); buf->head.info.alloc_len = n; return &buf->data[0]; }
false
false
false
false
false
0
globus_hashtable_copy( globus_hashtable_t * dest_table, globus_hashtable_t * src_table, globus_hashtable_copy_func_t copy_func) { globus_l_hashtable_t * src_itable; globus_l_hashtable_t * dest_itable; int i; int size; globus_l_hashtable_bucket_entry_t * list; globus_l_hashtable_bucket_entry_t dummy_entry; if(dest_table == GLOBUS_NULL || src_table == GLOBUS_NULL || *src_table == GLOBUS_NULL) { goto error_parm; } src_itable = *src_table; if(globus_hashtable_init( dest_table, src_itable->size, src_itable->hash_func, src_itable->keyeq_func) != GLOBUS_SUCCESS) { goto error_init; } dest_itable = *dest_table; size = src_itable->size; dest_itable->load = src_itable->load; dummy_entry.next = GLOBUS_NULL; list = &dummy_entry; for(i = 0; i < size; i++) { if(src_itable->buckets[i].first) { globus_l_hashtable_bucket_entry_t * src_entry; globus_l_hashtable_bucket_entry_t * dest_entry; globus_l_hashtable_bucket_entry_t ** bucket_first; src_entry = src_itable->buckets[i].first; bucket_first = &list->next; do { dest_entry = (globus_l_hashtable_bucket_entry_t *) globus_memory_pop_node(&dest_itable->memory); if(!dest_entry) { goto error_alloc; } if(copy_func) { copy_func( &dest_entry->key, &dest_entry->datum, src_entry->key, src_entry->datum); } else { dest_entry->key = src_entry->key; dest_entry->datum = src_entry->datum; } dest_entry->prev = list; dest_entry->next = GLOBUS_NULL; list->next = dest_entry; list = dest_entry; src_entry = src_entry->next; } while( src_entry && src_entry->prev != src_itable->buckets[i].last); dest_itable->buckets[i].first = *bucket_first; dest_itable->buckets[i].last = dest_entry; dest_itable->last = dest_entry; } } if(dummy_entry.next) { dest_itable->first = dummy_entry.next; dummy_entry.next->prev = GLOBUS_NULL; } return GLOBUS_SUCCESS; error_alloc: globus_hashtable_destroy(dest_table); error_init: *dest_table = GLOBUS_NULL; error_parm: return GLOBUS_FAILURE; }
false
false
false
false
false
0
nvkm_perfmon_child_get(struct nvkm_object *object, int index, struct nvkm_oclass *oclass) { if (index == 0) { oclass->base.oclass = NVIF_IOCTL_NEW_V0_PERFDOM; oclass->base.minver = 0; oclass->base.maxver = 0; oclass->ctor = nvkm_perfmon_child_new; return 0; } return -EINVAL; }
false
false
false
false
false
0
border_draw_title_deep( FvwmWindow *fw, titlebar_descr *td, title_draw_descr *tdd, FlocaleWinString *fstr, Pixmap dest_pix, Window w) { DecorFace *df; pixmap_background_type bg; bg.flags.use_pixmap = 0; for (df = tdd->df; df != NULL; df = df->next) { if (df->style.face_type == MultiPixmap) { border_mp_draw_mp_titlebar( fw, td, df, dest_pix, w); } else { bg.pixel = df->u.back; border_draw_decor_to_pixmap( fw, dest_pix, w, &bg, &td->layout.title_g, df, td, td->tbstate.tstate, True, tdd->is_toggled, 1); } } FlocaleDrawString(dpy, fw->title_font, &tdd->fstr, 0); return; }
false
false
false
false
false
0
decode_level0_header(LHAFileHeader **header, LHAInputStream *stream) { uint8_t header_len; uint8_t header_csum; size_t path_len; size_t min_len; header_len = RAW_DATA(header, 0); header_csum = RAW_DATA(header, 1); // Sanity check header length. This is the minimum header length // for a header that has a zero-length path. switch ((*header)->header_level) { case 0: min_len = LEVEL_0_MIN_HEADER_LEN; break; case 1: min_len = LEVEL_1_MIN_HEADER_LEN; break; default: return 0; } if (header_len < min_len) { return 0; } // We only have a partial header so far. Read the full header. if (!extend_raw_data(header, stream, header_len + 2 - RAW_DATA_LEN(header))) { return 0; } // Checksum the header. if (!check_l0_checksum(&RAW_DATA(header, 2), RAW_DATA_LEN(header) - 2, header_csum)) { return 0; } // Compression method: memcpy((*header)->compress_method, &RAW_DATA(header, 2), 5); (*header)->compress_method[5] = '\0'; // File lengths: (*header)->compressed_length = lha_decode_uint32(&RAW_DATA(header, 7)); (*header)->length = lha_decode_uint32(&RAW_DATA(header, 11)); // Timestamp: (*header)->timestamp = decode_ftime(&RAW_DATA(header, 15)); // Read path. Check path length field - is the header long enough // to hold this full path? path_len = RAW_DATA(header, 21); if (min_len + path_len > header_len) { return 0; } // OS type? if ((*header)->header_level == 0) { (*header)->os_type = LHA_OS_TYPE_UNKNOWN; } else { (*header)->os_type = RAW_DATA(header, 24 + path_len); } // Read filename field: if (!process_level0_path(*header, &RAW_DATA(header, 22), path_len)) { return 0; } // CRC field. (*header)->crc = lha_decode_uint16(&RAW_DATA(header, 22 + path_len)); // Level 0 headers can contain extended data through different schemes // to the extended header system used in level 1+. if ((*header)->header_level == 0 && header_len > LEVEL_0_MIN_HEADER_LEN + path_len) { process_level0_extended_area(*header, &RAW_DATA(header, LEVEL_0_MIN_HEADER_LEN + 2 + path_len), header_len - LEVEL_0_MIN_HEADER_LEN - path_len); } return 1; }
false
true
false
false
false
1
rb_ary_pop(VALUE ary) { long n; rb_ary_modify_check(ary); if (RARRAY_LEN(ary) == 0) return Qnil; if (ARY_OWNS_HEAP_P(ary) && RARRAY_LEN(ary) * 3 < ARY_CAPA(ary) && ARY_CAPA(ary) > ARY_DEFAULT_SIZE) { ary_resize_capa(ary, RARRAY_LEN(ary) * 2); } n = RARRAY_LEN(ary)-1; ARY_SET_LEN(ary, n); return RARRAY_PTR(ary)[n]; }
false
false
false
false
false
0
save_preference() { gchar filename[512]; xmlDoc *doc; xmlNode *xpreference; gint items; gint i; gchar buff[512]; LOG(LOG_DEBUG, "IN : save_preference()"); sprintf(filename, "%s%s%s", user_dir, DIR_DELIMITER, FILENAME_PREFERENCE); doc = xml_doc_new(); doc->encoding = strdup("euc-jp"); doc->version = strdup("1.0"); xpreference = xml_add_child(doc->root, "preference", NULL); items = sizeof (preferences) / sizeof (preferences[0]); for(i=0 ; i<items ; i++){ switch(preferences[i].type){ case PREF_TYPE_INTEGER: case PREF_TYPE_BOOLEAN: sprintf(buff, "%d", *((int *)preferences[i].addr)); xml_add_child(xpreference, preferences[i].name, buff); break; case PREF_TYPE_FLOAT: sprintf(buff, "%f", *((float *)preferences[i].addr)); xml_add_child(xpreference, preferences[i].name, buff); break; case PREF_TYPE_STRING: // if((preferences[i].addr == NULL) xml_add_child(xpreference, preferences[i].name, *((gchar **)preferences[i].addr)); break; default: break; } } xml_save_file(filename, doc); xml_destroy_document(doc); LOG(LOG_DEBUG, "OUT : save_preference()"); return(TRUE); }
false
true
true
false
false
1
da903x_set_voltage_sel(struct regulator_dev *rdev, unsigned selector) { struct da903x_regulator_info *info = rdev_get_drvdata(rdev); struct device *da9034_dev = to_da903x_dev(rdev); uint8_t val, mask; if (rdev->desc->n_voltages == 1) return -EINVAL; val = selector << info->vol_shift; mask = ((1 << info->vol_nbits) - 1) << info->vol_shift; return da903x_update(da9034_dev, info->vol_reg, val, mask); }
false
false
false
false
false
0
read_gabedit_orbitals(gchar* FileName) { gint i; gint typefile; gint typebasis; gboolean OkAlpha = FALSE; gboolean OkBeta = FALSE; gchar* t = NULL; typefile =get_type_file_orb(FileName); if(typefile==GABEDIT_TYPEFILE_UNKNOWN) return; if(typefile != GABEDIT_TYPEFILE_GABEDIT) { Message(_("Sorry, This file is not in Gabedit Format\n"),_("Error"),TRUE); return ; } free_data_all(); t = get_name_file(FileName); set_status_label_info(_("File name"),t); g_free(t); set_status_label_info(_("File type"),"Gabedit"); set_status_label_info(_("Mol. Orb."),_("Reading")); free_orbitals(); if(!gl_read_gabedit_file_geom(FileName)) { set_status_label_info(_("File name"),_("Nothing")); set_status_label_info(_("File type"),_("Nothing")); set_status_label_info(_("Mol. Orb."),_("Nothing")); return; } InitializeAll(); if(!DefineGabeditBasisType(FileName)) { set_status_label_info(_("File name"),_("Nothing")); set_status_label_info(_("File type"),_("Nothing")); set_status_label_info(_("Mol. Orb."),_("Nothing")); return; } typebasis =get_type_basis_in_gabedit_file(FileName); if(typebasis == 1) { DefineSphericalBasis(); sphericalBasis = TRUE; } else { DefineCartBasis(); sphericalBasis = FALSE; } NormaliseAllBasis(); /* PrintAllBasis();*/ DefineNOccs(); OkBeta = read_orbitals_in_gabedit_or_molden_file(FileName,2);/* if beta orbital*/ OkAlpha = read_orbitals_in_gabedit_or_molden_file(FileName,1); if(!OkBeta && OkAlpha) { CoefBetaOrbitals = CoefAlphaOrbitals; EnerBetaOrbitals = EnerAlphaOrbitals; SymBetaOrbitals = SymAlphaOrbitals; NBetaOrb = NAlphaOrb; OccBetaOrbitals = g_malloc(NOrb*sizeof(gdouble)); NBetaOcc = 0; for(i=0;i<NBetaOrb;i++) { if(OccAlphaOrbitals[i]>1.0) { NBetaOcc++; OccBetaOrbitals[i] = OccAlphaOrbitals[i]/2; OccAlphaOrbitals[i] = OccBetaOrbitals[i]; } else OccBetaOrbitals[i] = 0.0; } if(NBetaOrb>0) OkBeta = TRUE; } if(OkAlpha || OkBeta) { read_gabedit_atomic_orbitals(FileName); set_status_label_info(_("Mol. Orb."),_("Ok")); glarea_rafresh(GLArea); /* for geometry*/ NumSelOrb = NAlphaOcc-1; create_list_orbitals(); } else { set_status_label_info(_("File name"),_("Nothing")); set_status_label_info(_("File type"),_("Nothing")); set_status_label_info(_("Mol. Orb."),_("Nothing")); } DefineType(); }
false
false
false
false
false
0
pg_identify(struct pg *dev, int log) { int s; char *ms[2] = { "master", "slave" }; char mf[10], id[18]; char id_cmd[12] = { ATAPI_IDENTIFY, 0, 0, 0, 36, 0, 0, 0, 0, 0, 0, 0 }; char buf[36]; s = pg_command(dev, id_cmd, 36, jiffies + PG_TMO); if (s) return -1; s = pg_completion(dev, buf, jiffies + PG_TMO); if (s) return -1; if (log) { xs(buf + 8, mf, 8); xs(buf + 16, id, 16); printk("%s: %s %s, %s\n", dev->name, mf, id, ms[dev->drive]); } return 0; }
false
false
false
false
false
0
pageDone(u_int ppm, u_int& ppr) { static char ppmCodes[3] = { 0x2C, 0x3B, 0x2E }; char eop[2]; if (ppm == PPH_SKIP) { ppr = PPR_MCF; return true; } eop[0] = DLE; eop[1] = ppmCodes[ppm]; ppr = 0; // something invalid if (putModemData(eop, sizeof (eop))) { for (;;) { switch (atResponse(rbuf, conf.pageDoneTimeout)) { case AT_FHNG: waitFor(AT_OK); if (!isNormalHangup()) { return (false); } ppr = PPR_MCF; return (true); case AT_OK: /* * We do explicit status query e.g. to * distinguish between MCF, RTP, and PIP. * If we don't understand the response, * assume that our query isn't supported. */ { if (strcasecmp(conf.class2PTSQueryCmd, "none") != 0) { fxStr s; if(!atQuery(conf.class2PTSQueryCmd, s) || sscanf(s, "%u", &ppr) != 1) { protoTrace("MODEM protocol botch (\"%s\"), %s", (const char*)s, "can not parse PPR"); ppr = PPR_MCF; } } else ppr = PPR_MCF; // could be PPR_RTP/PPR_PIP } return (true); case AT_ERROR: /* * We do explicit status query e.g. to * distinguish between RTN and PIN * If we don't understand the response, * assume that our query isn't supported. */ { if (strcasecmp(conf.class2PTSQueryCmd, "none") != 0) { fxStr s; if(!atQuery(conf.class2PTSQueryCmd, s) || sscanf(s, "%u", &ppr) != 1) { protoTrace("MODEM protocol botch (\"%s\"), %s", (const char*)s, "can not parse PPR"); ppr = PPR_RTN; } } else ppr = PPR_RTN; // could be PPR_PIN } return (true); case AT_EMPTYLINE: case AT_TIMEOUT: case AT_NOCARRIER: case AT_NODIALTONE: case AT_NOANSWER: goto bad; } } } bad: processHangup("50"); // Unspecified Phase D error return (false); }
false
false
false
false
false
0
gee_tree_set_fix_removal (GeeTreeSet* self, GeeTreeSetNode** node, gpointer* key) { gpointer _vala_key = NULL; GeeTreeSetNode* n = NULL; GeeTreeSetNode* _tmp0_ = NULL; GeeTreeSetNode* _tmp1_ = NULL; gpointer _tmp2_ = NULL; GeeTreeSetNode* _tmp3_ = NULL; GeeTreeSetNode* _tmp4_ = NULL; GeeTreeSetNode* _tmp11_ = NULL; GeeTreeSetNode* _tmp12_ = NULL; gint _tmp19_ = 0; g_return_if_fail (self != NULL); g_return_if_fail (*node != NULL); _tmp0_ = *node; *node = NULL; n = _tmp0_; _tmp1_ = n; _tmp2_ = _tmp1_->key; _tmp1_->key = NULL; ((_vala_key == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (_vala_key = (self->priv->g_destroy_func (_vala_key), NULL)); _vala_key = _tmp2_; _tmp3_ = n; _tmp4_ = _tmp3_->prev; if (_tmp4_ != NULL) { GeeTreeSetNode* _tmp5_ = NULL; GeeTreeSetNode* _tmp6_ = NULL; GeeTreeSetNode* _tmp7_ = NULL; GeeTreeSetNode* _tmp8_ = NULL; _tmp5_ = n; _tmp6_ = _tmp5_->prev; _tmp7_ = n; _tmp8_ = _tmp7_->next; _tmp6_->next = _tmp8_; } else { GeeTreeSetNode* _tmp9_ = NULL; GeeTreeSetNode* _tmp10_ = NULL; _tmp9_ = n; _tmp10_ = _tmp9_->next; self->priv->_first = _tmp10_; } _tmp11_ = n; _tmp12_ = _tmp11_->next; if (_tmp12_ != NULL) { GeeTreeSetNode* _tmp13_ = NULL; GeeTreeSetNode* _tmp14_ = NULL; GeeTreeSetNode* _tmp15_ = NULL; GeeTreeSetNode* _tmp16_ = NULL; _tmp13_ = n; _tmp14_ = _tmp13_->next; _tmp15_ = n; _tmp16_ = _tmp15_->prev; _tmp14_->prev = _tmp16_; } else { GeeTreeSetNode* _tmp17_ = NULL; GeeTreeSetNode* _tmp18_ = NULL; _tmp17_ = n; _tmp18_ = _tmp17_->prev; self->priv->_last = _tmp18_; } _gee_tree_set_node_free0 (*node); *node = NULL; _tmp19_ = self->priv->_size; self->priv->_size = _tmp19_ - 1; _gee_tree_set_node_free0 (n); if (key) { *key = _vala_key; } else { ((_vala_key == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (_vala_key = (self->priv->g_destroy_func (_vala_key), NULL)); } }
false
false
false
false
false
0
ParseMethodNameAndIndex( void *theEnv, char *readSource, unsigned *theIndex) { SYMBOL_HN *gname; *theIndex = 0; gname = GetConstructNameAndComment(theEnv,readSource,&DefgenericData(theEnv)->GenericInputToken,"defgeneric", EnvFindDefgeneric,NULL,"&",TRUE,FALSE,TRUE); if (gname == NULL) return(NULL); if (GetType(DefgenericData(theEnv)->GenericInputToken) == INTEGER) { int tmp; PPBackup(theEnv); PPBackup(theEnv); SavePPBuffer(theEnv," "); SavePPBuffer(theEnv,DefgenericData(theEnv)->GenericInputToken.printForm); tmp = (int) ValueToLong(GetValue(DefgenericData(theEnv)->GenericInputToken)); if (tmp < 1) { PrintErrorID(theEnv,"GENRCPSR",6,FALSE); EnvPrintRouter(theEnv,WERROR,"Method index out of range.\n"); return(NULL); } *theIndex = (unsigned) tmp; PPCRAndIndent(theEnv); GetToken(theEnv,readSource,&DefgenericData(theEnv)->GenericInputToken); } if (GetType(DefgenericData(theEnv)->GenericInputToken) == STRING) { PPBackup(theEnv); PPBackup(theEnv); SavePPBuffer(theEnv," "); SavePPBuffer(theEnv,DefgenericData(theEnv)->GenericInputToken.printForm); PPCRAndIndent(theEnv); GetToken(theEnv,readSource,&DefgenericData(theEnv)->GenericInputToken); } return(gname); }
false
false
false
false
false
0
ssl3_ComputeECDHKeyHash(SECOidTag hashAlg, SECItem ec_params, SECItem server_ecpoint, SSL3Random *client_rand, SSL3Random *server_rand, SSL3Hashes *hashes, PRBool bypassPKCS11) { PRUint8 * hashBuf; PRUint8 * pBuf; SECStatus rv = SECSuccess; unsigned int bufLen; /* * XXX For now, we only support named curves (the appropriate * checks are made before this method is called) so ec_params * takes up only two bytes. ECPoint needs to fit in 256 bytes * (because the spec says the length must fit in one byte) */ PRUint8 buf[2*SSL3_RANDOM_LENGTH + 2 + 1 + 256]; bufLen = 2*SSL3_RANDOM_LENGTH + ec_params.len + 1 + server_ecpoint.len; if (bufLen <= sizeof buf) { hashBuf = buf; } else { hashBuf = PORT_Alloc(bufLen); if (!hashBuf) { return SECFailure; } } memcpy(hashBuf, client_rand, SSL3_RANDOM_LENGTH); pBuf = hashBuf + SSL3_RANDOM_LENGTH; memcpy(pBuf, server_rand, SSL3_RANDOM_LENGTH); pBuf += SSL3_RANDOM_LENGTH; memcpy(pBuf, ec_params.data, ec_params.len); pBuf += ec_params.len; pBuf[0] = (PRUint8)(server_ecpoint.len); pBuf += 1; memcpy(pBuf, server_ecpoint.data, server_ecpoint.len); pBuf += server_ecpoint.len; PORT_Assert((unsigned int)(pBuf - hashBuf) == bufLen); rv = ssl3_ComputeCommonKeyHash(hashAlg, hashBuf, bufLen, hashes, bypassPKCS11); PRINT_BUF(95, (NULL, "ECDHkey hash: ", hashBuf, bufLen)); PRINT_BUF(95, (NULL, "ECDHkey hash: MD5 result", hashes->u.s.md5, MD5_LENGTH)); PRINT_BUF(95, (NULL, "ECDHkey hash: SHA1 result", hashes->u.s.sha, SHA1_LENGTH)); if (hashBuf != buf) PORT_Free(hashBuf); return rv; }
false
true
false
false
false
1
event_ReplaceAll(void) { UT_UCS4String findEntryText; UT_UCS4String replaceEntryText; findEntryText = get_combobox_text(m_comboFind); replaceEntryText = get_combobox_text(m_comboReplace); setFindString(findEntryText.ucs4_str()); setReplaceString(replaceEntryText.ucs4_str()); findReplaceAll(); }
false
false
false
false
false
0
ADD_u32(uint32_t a, uint32_t b) { /* overflow -> saturate */ uint64_t result = (uint64_t)a + b; return result < 0xffffffff ? (uint32_t)result : 0xffffffff; }
false
false
false
false
false
0
__disk_unblock_events(struct gendisk *disk, bool check_now) { struct disk_events *ev = disk->ev; unsigned long intv; unsigned long flags; spin_lock_irqsave(&ev->lock, flags); if (WARN_ON_ONCE(ev->block <= 0)) goto out_unlock; if (--ev->block) goto out_unlock; /* * Not exactly a latency critical operation, set poll timer * slack to 25% and kick event check. */ intv = disk_events_poll_jiffies(disk); set_timer_slack(&ev->dwork.timer, intv / 4); if (check_now) queue_delayed_work(system_freezable_power_efficient_wq, &ev->dwork, 0); else if (intv) queue_delayed_work(system_freezable_power_efficient_wq, &ev->dwork, intv); out_unlock: spin_unlock_irqrestore(&ev->lock, flags); }
false
false
false
false
false
0
xmalloc(int size) { void *ptr; ptr = malloc(size); if (ptr == NULL) { fprintf(stderr, _("\nMemory allocation error, exiting.\n")); exit(EXIT_FAILURE); } return ptr; }
false
false
false
false
false
0
IsCommentFiltered(const wxString& comment) { if (s_FilterComments) { wxStringTokenizer tokenizer( s_CommentFilterString, wxT(",") ); while (tokenizer.HasMoreTokens()) { if ( comment.Lower().Trim(false).Trim(true).Contains( tokenizer.GetNextToken().Lower().Trim(false).Trim(true))) { return true; } } } return false; }
false
false
false
false
false
0
flush(void) { if (input_offset) { if (output_fd >= 0) write_or_die(output_fd, input_buffer, input_offset); git_SHA1_Update(&input_ctx, input_buffer, input_offset); memmove(input_buffer, input_buffer + input_offset, input_len); input_offset = 0; } }
false
false
false
false
false
0
print_info(struct gfs2_sbd *sdp) { log_notice("FS: %-22s%s\n", _("Mount point:"), sdp->path_name); log_notice("FS: %-22s%s\n", _("Device:"), sdp->device_name); log_notice("FS: %-22s%llu (0x%llx)\n", _("Size:"), (unsigned long long)fssize, (unsigned long long)fssize); log_notice("FS: %-22s%u (0x%x)\n", _("Resource group size:"), rgsize, rgsize); log_notice("DEV: %-22s%llu (0x%llx)\n", _("Length:"), (unsigned long long)sdp->device.length, (unsigned long long)sdp->device.length); log_notice(_("The file system grew by %lluMB.\n"), (unsigned long long)fsgrowth / MB); }
false
false
false
false
false
0
fmm_parse_magic_file(PerlFMM *state, char *file) { int ws_offset; int lineno; int errs; /* char line[BUFSIZ + 1];*/ PerlIO *fhandle; SV *err; SV *sv = sv_2mortal(newSV(BUFSIZ)); SV *PL_rs_orig = newSVsv(PL_rs); char *line; fhandle = PerlIO_open(file, "r"); if (! fhandle) { err = newSVpvf( "Failed to open %s: %s", file, strerror(errno)); FMM_SET_ERROR(state, err); PerlIO_close(fhandle); return -1; } /* * Parse it line by line * $/ (slurp mode) is needed here */ PL_rs = sv_2mortal(newSVpvn("\n", 1)); for(lineno = 1; sv_gets(sv, fhandle, 0) != NULL; lineno++) { line = SvPV_nolen(sv); /* delete newline */ if (line[0]) { line[strlen(line) - 1] = '\0'; } /* skip leading whitespace */ ws_offset = 0; while (line[ws_offset] && isSPACE(line[ws_offset])) { ws_offset++; } /* skip blank lines */ if (line[ws_offset] == 0) { continue; } if (line[ws_offset] == '#') { continue; } if (fmm_parse_magic_line(state, line, lineno) != 0) { ++errs; } } PerlIO_close(fhandle); PL_rs = PL_rs_orig; return 1; }
false
false
false
false
false
0
git_revwalk_new(git_revwalk **revwalk_out, git_repository *repo) { git_revwalk *walk; walk = git__malloc(sizeof(git_revwalk)); if (walk == NULL) return GIT_ENOMEM; memset(walk, 0x0, sizeof(git_revwalk)); walk->commits = git_hashtable_alloc(64, object_table_hash, (git_hash_keyeq_ptr)git_oid_cmp); if (walk->commits == NULL) { free(walk); return GIT_ENOMEM; } git_pqueue_init(&walk->iterator_time, 8, commit_time_cmp); git_vector_init(&walk->memory_alloc, 8, NULL); alloc_chunk(walk); walk->get_next = &revwalk_next_unsorted; walk->enqueue = &revwalk_enqueue_unsorted; walk->repo = repo; *revwalk_out = walk; return GIT_SUCCESS; }
false
false
false
false
false
0
add_to_partition_kill_list (temp_expr_table_p tab, int p, int ver) { if (!tab->kill_list[p]) { tab->kill_list[p] = BITMAP_ALLOC (NULL); bitmap_set_bit (tab->partition_in_use, p); } bitmap_set_bit (tab->kill_list[p], ver); }
false
false
false
false
false
0
ixgbe_free_fcoe_ddp_resources(struct ixgbe_adapter *adapter) { struct ixgbe_fcoe *fcoe = &adapter->fcoe; int cpu, i, ddp_max; /* do nothing if no DDP pools were allocated */ if (!fcoe->ddp_pool) return; ddp_max = IXGBE_FCOE_DDP_MAX; /* X550 has different DDP Max limit */ if (adapter->hw.mac.type == ixgbe_mac_X550) ddp_max = IXGBE_FCOE_DDP_MAX_X550; for (i = 0; i < ddp_max; i++) ixgbe_fcoe_ddp_put(adapter->netdev, i); for_each_possible_cpu(cpu) ixgbe_fcoe_dma_pool_free(fcoe, cpu); dma_unmap_single(&adapter->pdev->dev, fcoe->extra_ddp_buffer_dma, IXGBE_FCBUFF_MIN, DMA_FROM_DEVICE); kfree(fcoe->extra_ddp_buffer); fcoe->extra_ddp_buffer = NULL; fcoe->extra_ddp_buffer_dma = 0; }
false
false
false
false
false
0
event_base_set(struct event_base *base, struct event *ev) { /* Only innocent events may be assigned to a different base */ if (ev->ev_flags != EVLIST_INIT) return (-1); _event_debug_assert_is_setup(ev); ev->ev_base = base; ev->ev_pri = base->nactivequeues/2; return (0); }
false
false
false
false
false
0
bricks_add_grow_mod( int x, int y, int id ) { BrickHit *hit; if ( cur_game->mod.brick_hit_count > MAX_MODS ) return; /* drop hit */ hit = &cur_game->mod.brick_hits[cur_game->mod.brick_hit_count++]; memset(hit,0,sizeof(BrickHit)); /* clear hit */ hit->x = x; hit->y = y; hit->brick_id = id; hit->type = HT_GROW; }
false
false
false
false
false
0
vnc_connection_has_auth_type(gpointer data) { VncConnection *conn = data; VncConnectionPrivate *priv = conn->priv; if (priv->has_error) return TRUE; if (priv->auth_type == VNC_CONNECTION_AUTH_INVALID) return FALSE; return TRUE; }
false
false
false
false
false
0
HTMLPreformatted(li, env, text, len) HTMLInfo li; HTMLEnv env; char *text; size_t len; { char *cp, *lastcp, *start; size_t ptlen; char *s; bool tabbed; lastcp = text + len; tabbed = false; for (ptlen = 0, start = cp = text; cp < lastcp; cp++) { if (*cp == '\r') continue; else if (*cp == '\n') { if (tabbed) { s = ExpandTabs(li, start, cp - start, ptlen); HTMLEnvAddBox(li, env, HTMLCreateTextBox(li, env, s, ptlen)); } else { HTMLEnvAddBox(li, env, HTMLCreateTextBox(li, env, start, ptlen)); } HTMLAddLineBreak(li, env); ptlen = 0; start = cp + 1; tabbed = false; } else if (*cp == '\t') { ptlen += TAB_EXPANSION; tabbed = true; } else ptlen++; } if (tabbed) { s = ExpandTabs(li, start, cp - start, ptlen); HTMLEnvAddBox(li, env, HTMLCreateTextBox(li, env, s, ptlen)); } else { HTMLEnvAddBox(li, env, HTMLCreateTextBox(li, env, start, ptlen)); } return; }
false
false
false
false
false
0
FactGetVarPN3( void *theEnv, struct lhsParseNode *theNode) { struct factGetVarPN3Call hack; /*===================================================*/ /* Clear the bitmap for storing the argument values. */ /*===================================================*/ ClearBitString(&hack,sizeof(struct factGetVarPN3Call)); /*=======================================*/ /* Store the slot in the fact from which */ /* the value will be retrieved. */ /*=======================================*/ hack.whichSlot = (unsigned short) (theNode->slotNumber - 1); /*==============================================================*/ /* If a single field variable value is being retrieved, then... */ /*==============================================================*/ if ((theNode->type == SF_WILDCARD) || (theNode->type == SF_VARIABLE)) { /*=========================================================*/ /* If no multifield values occur before the variable, then */ /* the variable's value can be retrieved based on its */ /* offset from the beginning of the slot's value */ /* regardless of the number of multifield variables or */ /* wildcards following the variable being retrieved. */ /*=========================================================*/ if (theNode->multiFieldsBefore == 0) { hack.fromBeginning = 1; hack.fromEnd = 0; hack.beginOffset = theNode->singleFieldsBefore; hack.endOffset = 0; } /*===============================================*/ /* Otherwise the variable is retrieved based its */ /* position relative to the end of the slot. */ /*===============================================*/ else { hack.fromBeginning = 0; hack.fromEnd = 1; hack.beginOffset = 0; hack.endOffset = theNode->singleFieldsAfter; } return(AddBitMap(theEnv,&hack,sizeof(struct factGetVarPN3Call))); } /*============================================================*/ /* A multifield variable value is being retrieved. This means */ /* that there are no other multifield variables or wildcards */ /* in the slot. The multifield value is retrieved by storing */ /* the number of single field values which come before and */ /* after the multifield value. The multifield value can then */ /* be retrieved based on the length of the value in the slot */ /* and the number of single field values which must occur */ /* before and after the multifield value. */ /*============================================================*/ hack.fromBeginning = 1; hack.fromEnd = 1; hack.beginOffset = theNode->singleFieldsBefore; hack.endOffset = theNode->singleFieldsAfter; /*=============================*/ /* Return the argument bitmap. */ /*=============================*/ return(AddBitMap(theEnv,&hack,sizeof(struct factGetVarPN3Call))); }
false
false
false
false
false
0
gtk_xtext_strip_color (unsigned char *text, int len, unsigned char *outbuf, int *newlen, int *mb_ret, GSList **slp, int strip_hidden) { int i = 0; int rcol = 0, bgcol = 0; int hidden = FALSE; unsigned char *new_str; int mb = FALSE; GSList *sl = NULL; unsigned char *text0 = text; int off1, len1; offlen_t data; if (outbuf == NULL) new_str = malloc (len + 2); else new_str = outbuf; off1 = 0; len1 = 0; data.u = 0; while (len > 0) { if (*text >= 128) mb = TRUE; if (rcol > 0 && (isdigit (*text) || (*text == ',' && isdigit (text[1]) && !bgcol))) { if (text[1] != ',') rcol--; if (*text == ',') { rcol = 2; bgcol = 1; } } else { rcol = bgcol = 0; switch (*text) { case ATTR_COLOR: rcol = 2; break; case ATTR_BEEP: case ATTR_RESET: case ATTR_REVERSE: case ATTR_BOLD: case ATTR_UNDERLINE: case ATTR_ITALICS: break; case ATTR_HIDDEN: hidden = !hidden; break; default: if (!(hidden && strip_hidden)) { if (text - text0 - off1 != len1) { if (len1) { data.o.off = off1; data.o.len = len1; sl = g_slist_append (sl, GUINT_TO_POINTER (data.u)); len1 = 0; } off1 = text - text0; } len1++; new_str[i++] = *text; } } } text++; len--; } if (len1) { data.o.off = off1; data.o.len = len1; sl = g_slist_append (sl, GUINT_TO_POINTER (data.u)); } new_str[i] = 0; if (newlen != NULL) *newlen = i; if (mb_ret != NULL) *mb_ret = mb; if (slp) *slp = sl; else g_slist_free (sl); return new_str; }
false
false
false
false
false
0
b43_nphy_get_tx_gain_table(struct b43_wldev *dev) { struct b43_phy *phy = &dev->phy; enum ieee80211_band band = b43_current_band(dev->wl); struct ssb_sprom *sprom = dev->dev->bus_sprom; if (dev->phy.rev < 3) return b43_ntab_tx_gain_rev0_1_2; /* rev 3+ */ if ((dev->phy.n->ipa2g_on && band == IEEE80211_BAND_2GHZ) || (dev->phy.n->ipa5g_on && band == IEEE80211_BAND_5GHZ)) { return b43_nphy_get_ipa_gain_table(dev); } else if (b43_current_band(dev->wl) == IEEE80211_BAND_5GHZ) { switch (phy->rev) { case 6: case 5: return b43_ntab_tx_gain_epa_rev5_5g; case 4: return sprom->fem.ghz5.extpa_gain == 3 ? b43_ntab_tx_gain_epa_rev4_5g : b43_ntab_tx_gain_epa_rev4_hi_pwr_5g; case 3: return b43_ntab_tx_gain_epa_rev3_5g; default: b43err(dev->wl, "No 5GHz EPA gain table available for this device\n"); return NULL; } } else { switch (phy->rev) { case 6: case 5: if (sprom->fem.ghz2.extpa_gain == 3) return b43_ntab_tx_gain_epa_rev3_hi_pwr_2g; /* fall through */ case 4: case 3: return b43_ntab_tx_gain_epa_rev3_2g; default: b43err(dev->wl, "No 2GHz EPA gain table available for this device\n"); return NULL; } } }
false
false
false
false
false
0
exynos_adc_v2_init_hw(struct exynos_adc *info) { u32 con1, con2; if (info->data->needs_adc_phy) regmap_write(info->pmu_map, info->data->phy_offset, 1); con1 = ADC_V2_CON1_SOFT_RESET; writel(con1, ADC_V2_CON1(info->regs)); con2 = ADC_V2_CON2_OSEL | ADC_V2_CON2_ESEL | ADC_V2_CON2_HIGHF | ADC_V2_CON2_C_TIME(0); writel(con2, ADC_V2_CON2(info->regs)); /* Enable interrupts */ writel(1, ADC_V2_INT_EN(info->regs)); }
false
false
false
false
false
0
convert_hline_str4 (paintinfo * p, int y) { int i; guint8 *A = p->ap + y * p->ystride; guint8 *R = p->yp + y * p->ystride; guint8 *G = p->up + y * p->ustride; guint8 *B = p->vp + y * p->vstride; guint8 *argb = p->tmpline; for (i = 0; i < p->width; i++) { A[4 * i] = 0xff; R[4 * i] = argb[4 * i + 1]; G[4 * i] = argb[4 * i + 2]; B[4 * i] = argb[4 * i + 3]; } }
false
false
false
false
false
0
node_remove (Node *node) { Node *tup = node->up, *tdown = node->down; /* if we're wiping the tree, add a temp node for later reference to the empty tree */ if ((node_left (node) == 0) && (node_up (node) == 0) && (node_down (node) == 0)) { Node *tnode = node_insert_down (node); node_setflag (tnode, F_temp, 1); tdown = node_down (node); } /* remove all children */ while (node_right (node)) node_remove (node_right (node)); /* close the gap in the linked list */ if (tup) tup->down = tdown; if (tdown) tdown->up = tup; /* if we are a top-most child (parent says we are master of our siblings) */ if ((node_left (node)) && (node_right (node_left (node)) == node)) { if (tdown) /* rearrange parents pointer */ node->left->right = tdown; else { /* if no siblings remove ourselves, and return parent */ Node *tnode = node_left (node); node->left->right = 0; node_free (node); return tnode; } } node_free (node); if (tup) return tup; if (tdown) return tdown; printf ("we're not where we should be\n"); return 0; }
false
false
false
false
false
0
xmlnode_get_attrib(xmlnode owner, const char *name) { xmlnode attrib; if (owner != NULL && owner->firstattrib != NULL) { attrib = _xmlnode_search(owner->firstattrib, name, NTYPE_ATTRIB); if (attrib != NULL) return (char *)attrib->data; } return NULL; }
false
false
false
false
false
0
ArgusPrintSrcBytes (char *buf, struct ArgusRecord *argus) { int src_bytes = 0; if (argus->ahdr.type & ARGUS_MAR) src_bytes = argus->argus_mar.bytesRcvd; else { if (Aflag) { src_bytes = argus->argus_far.src.appbytes; } else { src_bytes = argus->argus_far.src.bytes; } } sprintf (buf, "%-12u", src_bytes); }
false
false
false
false
false
0
xlog_recover_process_data( struct xlog *log, struct hlist_head rhash[], struct xlog_rec_header *rhead, char *dp, int pass) { struct xlog_op_header *ohead; char *end; int num_logops; int error; end = dp + be32_to_cpu(rhead->h_len); num_logops = be32_to_cpu(rhead->h_num_logops); /* check the log format matches our own - else we can't recover */ if (xlog_header_check_recover(log->l_mp, rhead)) return -EIO; while ((dp < end) && num_logops) { ohead = (struct xlog_op_header *)dp; dp += sizeof(*ohead); ASSERT(dp <= end); /* errors will abort recovery */ error = xlog_recover_process_ophdr(log, rhash, rhead, ohead, dp, end, pass); if (error) return error; dp += be32_to_cpu(ohead->oh_len); num_logops--; } return 0; }
false
false
false
false
false
0
UnpackString(const Buffer *b,int *offset,int limit,xstring *str_out) { if(limit-*offset<4) { // We unpack strings when we have already received complete packet, // so it is not possible to receive any more data. LogError(2,"bad string in reply (truncated length field)"); return UNPACK_WRONG_FORMAT; } int len=b->UnpackUINT32BE(*offset); if(len>limit-*offset-4) { LogError(2,"bad string in reply (invalid length field)"); return UNPACK_WRONG_FORMAT; } *offset+=4; const char *data; int data_len; b->Get(&data,&data_len); str_out->nset(data+*offset,len); *offset+=len; return UNPACK_SUCCESS; }
false
false
false
false
false
0
normalize() { if (idx() > lastidx()) { lyxerr << "this should not really happen - 1: " << idx() << ' ' << nargs() << " in: " << &inset() << endl; idx() = lastidx(); } if (pos() > lastpos()) { lyxerr << "this should not really happen - 2: " << pos() << ' ' << lastpos() << " in idx: " << idx() << " in atom: '"; odocstringstream os; WriteStream wi(os, false, true, WriteStream::wsDefault); inset().asInsetMath()->write(wi); lyxerr << to_utf8(os.str()) << endl; pos() = lastpos(); } }
false
false
false
false
false
0
showbutton(int id) { pbutton pb; int c; char mss = getmousestatus(); if (mss == 2) mousevisible(false); pb = firstbutton; while (pb != NULL) { if (pb->id == id) if ( pb->pressed == 0) { c = pb->status; pb->status = 1; if (pb->active) enablebutton(id); else disablebutton(id); if (pb->art == 5) { showbutton ( id + 1); showbutton ( id + 2); } /* endif */ if (c != 1) rebuildtaborder(); } pb = pb->next; } if (mss == 2) mousevisible(true); }
false
false
false
false
false
0
session_setup_clone_command(void) { gint i; SmPropValue *vals = g_new(SmPropValue, sm_argc); SmProp prop = { .name = g_strdup(SmCloneCommand), .type = g_strdup(SmLISTofARRAY8), .num_vals = sm_argc, .vals = vals }; SmProp *list = &prop; ob_debug_type(OB_DEBUG_SM, "Setting clone command: (%d)", sm_argc); for (i = 0; i < sm_argc; ++i) { vals[i].value = sm_argv[i]; vals[i].length = strlen(sm_argv[i]) + 1; ob_debug_type(OB_DEBUG_SM, " %s", vals[i].value); } SmcSetProperties(sm_conn, 1, &list); g_free(prop.name); g_free(prop.type); g_free(vals); }
false
false
false
false
false
0
do_blank_screen(int entering_gfx) { struct vc_data *vc = vc_cons[fg_console].d; int i; WARN_CONSOLE_UNLOCKED(); if (console_blanked) { if (blank_state == blank_vesa_wait) { blank_state = blank_off; vc->vc_sw->con_blank(vc, vesa_blank_mode + 1, 0); } return; } /* entering graphics mode? */ if (entering_gfx) { hide_cursor(vc); save_screen(vc); vc->vc_sw->con_blank(vc, -1, 1); console_blanked = fg_console + 1; blank_state = blank_off; set_origin(vc); return; } if (blank_state != blank_normal_wait) return; blank_state = blank_off; /* don't blank graphics */ if (vc->vc_mode != KD_TEXT) { console_blanked = fg_console + 1; return; } hide_cursor(vc); del_timer_sync(&console_timer); blank_timer_expired = 0; save_screen(vc); /* In case we need to reset origin, blanking hook returns 1 */ i = vc->vc_sw->con_blank(vc, vesa_off_interval ? 1 : (vesa_blank_mode + 1), 0); console_blanked = fg_console + 1; if (i) set_origin(vc); if (console_blank_hook && console_blank_hook(1)) return; if (vesa_off_interval && vesa_blank_mode) { blank_state = blank_vesa_wait; mod_timer(&console_timer, jiffies + vesa_off_interval); } vt_event_post(VT_EVENT_BLANK, vc->vc_num, vc->vc_num); }
false
false
false
false
false
0
updatewindow(strm, end, copy) z_streamp strm; const Bytef *end; unsigned copy; { struct inflate_state FAR *state; unsigned dist; state = (struct inflate_state FAR *)strm->state; /* if it hasn't been done already, allocate space for the window */ if (state->window == Z_NULL) { state->window = (unsigned char FAR *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char)); if (state->window == Z_NULL) return 1; } /* if window not in use yet, initialize */ if (state->wsize == 0) { state->wsize = 1U << state->wbits; state->wnext = 0; state->whave = 0; } /* copy state->wsize or less output bytes into the circular window */ if (copy >= state->wsize) { zmemcpy(state->window, end - state->wsize, state->wsize); state->wnext = 0; state->whave = state->wsize; } else { dist = state->wsize - state->wnext; if (dist > copy) dist = copy; zmemcpy(state->window + state->wnext, end - copy, dist); copy -= dist; if (copy) { zmemcpy(state->window, end - copy, copy); state->wnext = copy; state->whave = state->wsize; } else { state->wnext += dist; if (state->wnext == state->wsize) state->wnext = 0; if (state->whave < state->wsize) state->whave += dist; } } return 0; }
false
false
false
false
false
0
gsb_csv_export_sort_by_value_date_or_date ( gpointer transaction_pointer_1, gpointer transaction_pointer_2 ) { gint transaction_number_1; gint transaction_number_2; const GDate *value_date_1; const GDate *value_date_2; transaction_number_1 = gsb_data_transaction_get_transaction_number ( transaction_pointer_1 ); transaction_number_2 = gsb_data_transaction_get_transaction_number ( transaction_pointer_2 ); value_date_1 = gsb_data_transaction_get_value_date ( transaction_number_1 ); if ( ! value_date_1 ) value_date_1 = gsb_data_transaction_get_date ( transaction_number_1 ); value_date_2 = gsb_data_transaction_get_value_date ( transaction_number_2 ); if ( ! value_date_2 ) value_date_2 = gsb_data_transaction_get_date ( transaction_number_2 ); if ( value_date_1 ) return ( g_date_compare ( value_date_1, value_date_2 ) ); else return -1; }
false
false
false
false
false
0
rank1(const size_t i) const { if(i>=length) return (size_t)-1; if(ones==0) return 0; if(ones==length) return i+1; size_t ini = 1; size_t fin = ones; while(ini<fin) { size_t pos = (ini+fin)/2; size_t bp = select1(pos); if(bp==i) return pos; if(bp<i) ini = pos+1; else fin = pos-1; } if(select1(ini)>i) return ini-1; return ini; }
false
false
false
false
false
0
status_open(struct view *view) { reset_view(view); add_line_data(view, NULL, LINE_STAT_HEAD); status_update_onbranch(); io_run_bg(update_index_argv); if (is_initial_commit()) { if (!status_run(view, status_list_no_head_argv, 'A', LINE_STAT_STAGED)) return FALSE; } else if (!status_run(view, status_diff_index_argv, 0, LINE_STAT_STAGED)) { return FALSE; } if (!status_run(view, status_diff_files_argv, 0, LINE_STAT_UNSTAGED) || !status_run(view, status_list_other_argv, '?', LINE_STAT_UNTRACKED)) return FALSE; /* Restore the exact position or use the specialized restore * mode? */ if (!view->p_restore) status_restore(view); return TRUE; }
false
false
false
false
false
0
askEmbedOrSave(int flags) { if (d->autoEmbedMimeType(flags)) return Embed; // don't use KStandardGuiItem::open() here which has trailing ellipsis! d->setButtonGuiItem(BrowserOpenOrSaveQuestionPrivate::OpenDefault, KGuiItem(i18nc("@label:button", "&Open"), "document-open")); d->showButton(BrowserOpenOrSaveQuestionPrivate::OpenWith, false); d->questionLabel->setText(i18nc("@info", "Open '%1'?", d->url.pathOrUrl())); d->questionLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); const QString dontAskAgain = QLatin1String("askEmbedOrSave")+ d->mimeType; // KEEP IN SYNC!!! // SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC SYNC const int choice = d->executeDialog(dontAskAgain); return choice == BrowserOpenOrSaveQuestionPrivate::Save ? Save : (choice == BrowserOpenOrSaveQuestionPrivate::Cancel ? Cancel : Embed); }
false
false
false
false
false
0
mailpop3_top(mailpop3 * f, unsigned int indx, unsigned int count, char ** result, size_t * result_len) { char command[POP3_STRING_SIZE]; struct mailpop3_msg_info * msginfo; int r; if (f->pop3_state != POP3_STATE_TRANSACTION) return MAILPOP3_ERROR_BAD_STATE; msginfo = find_msg(f, indx); if (msginfo == NULL) { f->pop3_response = NULL; return MAILPOP3_ERROR_NO_SUCH_MESSAGE; } snprintf(command, POP3_STRING_SIZE, "TOP %i %i\r\n", indx, count); r = send_command(f, command); if (r == -1) return MAILPOP3_ERROR_STREAM; return mailpop3_get_content(f, msginfo, result, result_len); }
false
false
false
false
false
0