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
cancelNewAttack(AttackFleet *fleet) { if (!m_newAttacks.removeAll(fleet)) { if(!m_standingOrders.removeAll(fleet)) return; } else fleet->source->fleet().absorb(fleet); fleet->deleteLater(); }
false
false
false
false
false
0
gretl_trunc (char *str, size_t n) { if (n < strlen(str)) { str[n] = '\0'; } return str; }
false
false
false
false
false
0
cpa(struct child *c) { int i, n; double t0 = now(); srandom(kvtest_first_seed + c->childno); for(i = 0; i < CPN; i++){ char key[512], val[512]; long x = random(); sprintf(key, "%ld", x); sprintf(val, "%ld", x + 1); aput(c, Str(key), Str(val)); } n = i; checkasync(c, 2); double t1 = now(); Json result = Json().set("total", (long) (n / (t1 - t0))) .set("puts", n) .set("puts_per_sec", n / (t1 - t0)); printf("%s\n", result.unparse().c_str()); }
false
false
false
false
false
0
getName() const { return haveC1Bytes? "windows-1255" : "ISO-8859-8-I"; }
false
false
false
false
false
0
unsupportedTypedef(const Token *tok) const { if (!_settings->debugwarnings) return; std::ostringstream str; const Token *tok1 = tok; while (tok && tok->str() != ";") { if (tok != tok1) str << " "; str << tok->str(); tok = tok->next(); } if (tok) str << " ;"; std::list<ErrorLogger::ErrorMessage::FileLocation> locationList; ErrorLogger::ErrorMessage::FileLocation loc; loc.line = tok1->linenr(); loc.setfile(file(tok1)); locationList.push_back(loc); const ErrorLogger::ErrorMessage errmsg(locationList, Severity::debug, "Failed to parse \'" + str.str() + "\'. The checking continues anyway.", "debug"); if (_errorLogger) _errorLogger->reportErr(errmsg); else Check::reportError(errmsg); }
false
false
false
false
false
0
inc_new_count(unsigned int length, int count, char *charset, char *allchars, char *char1, char2_table char2, chars_table *chars) { int pos, ci; int size; int error; log_event("- Expanding tables for length %d to character count %d", length + 1, count + 1); size = count + 2; error = expand(char1, allchars, size); if (length) error |= expand((*char2)[CHARSET_SIZE], allchars, size); for (pos = 0; pos <= (int)length - 2; pos++) error |= expand((*chars[pos])[CHARSET_SIZE][CHARSET_SIZE], allchars, size); for (ci = 0; ci < real_count; ci++) { int i = real_chars[ci]; int cj; if (length) error |= expand((*char2)[i], (*char2)[CHARSET_SIZE], size); for (cj = 0; cj < real_count; cj++) { int j = real_chars[cj]; for (pos = 0; pos <= (int)length - 2; pos++) { error |= expand((*chars[pos])[i][j], (*chars[pos])[CHARSET_SIZE][j], size); error |= expand((*chars[pos])[i][j], (*chars[pos])[CHARSET_SIZE][CHARSET_SIZE], size); } } } if (error) inc_format_error(charset); }
false
false
false
false
false
0
gnome_rr_config_new_current (GnomeRRScreen *screen, GError **error) { GnomeRRConfig *self = g_object_new (GNOME_TYPE_RR_CONFIG, "screen", screen, NULL); if (gnome_rr_config_load_current (self, error)) return self; else { g_object_unref (self); return NULL; } }
false
false
false
false
false
0
scripting_GetIntegerResult(int *i) { if(lua_isnumber(L, -1)) { *i = (int)lua_tonumber(L, -1); lua_pop(L, 1); /* restore stack */ return 0; } else { showStack(); return 1; } }
false
false
false
false
false
0
mod_clear_paths(void) { struct module_path *pathst; dlink_node *ptr; dlink_node *next_ptr; DLINK_FOREACH_SAFE(ptr, next_ptr, mod_paths.head) { pathst = ptr->data; dlinkDelete(&pathst->node, &mod_paths); MyFree(pathst); } DLINK_FOREACH_SAFE(ptr, next_ptr, conf_modules.head) { pathst = ptr->data; dlinkDelete(&pathst->node, &conf_modules); MyFree(pathst); } }
false
false
false
false
false
0
cb_reset_conn_cpt( cb_backend_instance *cb ) { if (cb->monitor_availability.cpt > 0) { slapi_lock_mutex(cb->monitor_availability.cpt_lock); cb->monitor_availability.cpt = 0 ; if (cb->monitor_availability.farmserver_state == FARMSERVER_UNAVAILABLE) { cb->monitor_availability.farmserver_state = FARMSERVER_AVAILABLE ; slapi_log_error( SLAPI_LOG_PLUGIN, CB_PLUGIN_SUBSYSTEM, "cb_reset_conn_cpt: Farm server is back"); } slapi_unlock_mutex(cb->monitor_availability.cpt_lock); } }
false
false
false
false
false
0
update_offsets(unsigned long poly_add, uint32_t * poly_corr, QS_t * qs_inf, poly_t * poly_inf) { unsigned long num_primes = qs_inf->num_primes; uint32_t * soln1 = poly_inf->soln1; uint32_t * soln2 = poly_inf->soln2; prime_t * factor_base = qs_inf->factor_base; unsigned long p, correction; for (unsigned long prime = 2; prime < num_primes; prime++) { if (soln2[prime] == -1) continue; p = factor_base[prime].p; correction = (poly_add ? p - poly_corr[prime] : poly_corr[prime]); soln1[prime] += correction; if (soln1[prime] >= p) soln1[prime] -= p; soln2[prime] += correction; if (soln2[prime] >= p) soln2[prime] -= p; } }
false
false
false
false
false
0
socket_flush_if_writable(void) { int res; /* Quick exit if nothing to do */ if (PqSendPointer == PqSendStart) return 0; /* No-op if reentrant call */ if (PqCommBusy) return 0; /* Temporarily put the socket into non-blocking mode */ socket_set_nonblocking(true); PqCommBusy = true; res = internal_flush(); PqCommBusy = false; return res; }
false
false
false
false
false
0
own_random(dst_work *work) { int dir = 0, b; int bytes, n, cmd = 0, dig = 0; /* * now get the initial seed to put into the quick random function from * the address of the work structure */ bytes = (int) getpid(); /* * proceed while needed */ while (work->filled < work->needed) { EREPORT(("own_random r %08x b %6d t %6d f %6d\n", ran_val, bytes, work->in_temp, work->filled)); /* pick a random number in the range of 0..7 based on that random number * perform some operations that yield random data */ n = (dst_s_quick_random(bytes) >> DST_SHIFT) & 0x07; switch (n) { case 0: case 3: if (sizeof(cmds) > 2 *sizeof(*cmds)) { b = unix_cmd(work); cmd += b; } break; case 1: case 7: if (sizeof(dirs) > 2 *sizeof(*dirs)) { b = do_ls(work); dir += b; } break; case 4: case 5: /* retry getting data from /dev/random */ b = get_dev_random(&work->output[work->filled], work->needed - work->filled); if (b > 0) work->filled += b; break; case 6: if (sizeof(files) > 2 * sizeof(*files)) { b = digest_file(work); dig += b; } break; case 2: default: /* to make sure we make some progress */ work->output[work->filled++] = 0xff & dst_s_quick_random(bytes); b = 1; break; } if (b > 0) bytes += b; } return (work->filled); }
false
false
false
false
false
0
alloc_chrdev_region(dev_t *dev, unsigned baseminor, unsigned count, const char *name) { struct char_device_struct *cd; cd = __register_chrdev_region(0, baseminor, count, name); if (IS_ERR(cd)) return PTR_ERR(cd); *dev = MKDEV(cd->major, cd->baseminor); return 0; }
false
false
false
false
false
0
saveSettings() { Prefs::setTileSet(theTiles.path()); Prefs::setLayout(theBoardLayout.path()); Prefs::setBackground(theBackground.path()); Prefs::setAngle(m_angle); Prefs::self()->writeConfig(); }
false
false
false
false
false
0
gameWalk(int op) { Board *b=0; ChessGame *cg=0; int id; global.debug("MainWindow","gameWalk"); id=notebook->getCurrentPageId(); if (id<=-2) // text panes return; if (id==-1) b=global.BoardList.front(); else { cg=global.getGame(id); if (cg) b=cg->getBoard(); } if (!b) return; // examining if (cg) if (cg->protodata[0]==258) { switch(op) { case 0: global.protocol->exaBackward(999); return; case 1: global.protocol->exaBackward(1); return; case 2: global.protocol->exaForward(1); return; case 3: global.protocol->exaForward(999); return; } } switch(op) { case 0: b->walkBackAll(); break; case 1: b->walkBack1(); break; case 2: b->walkForward1(); break; case 3: b->walkForwardAll(); break; case 4: b->openMovelist(); break; case 5: if ((id<=0)||(!cg)) break; if ( (cg->protodata[1]) || ( ! global.protocol ) || (cg->LocalEdit) ) { cg->protodata[1]=0; global.ebook->removePage(cg->GameNumber); global.removeBoard(b); delete(b); cg->setBoard(NULL); if (cg->LocalEdit) global.deleteGame(cg); } else { if ((id>0)&&(global.protocol!=NULL)) global.protocol->discardGame(cg->GameNumber); } break; case 6: b->setFlipInversion(!b->getFlipInversion()); break; case 7: // clone on scratch cloneOnScratch(b->getGame()); break; } }
false
false
false
false
false
0
chgroman(str, len, kbuf) CONST char *str; int len; CONST u_short *kbuf; { romantable *tmp; int n; if ((n = searchroman(str, len)) < 0) { n = maxromanlist; tmp = (romantable *)realloc(romanlist, (maxromanlist + 1) * sizeof(romantable)); if (!tmp) return(-1); romanlist = tmp; maxromanlist++; } else if (!kbuf) { memmove((char *)(&romanlist[n]), (char *)(&romanlist[n + 1]), (--maxromanlist - n) * sizeof(romantable)); return(0); } Xstrcpy(romanlist[n].str, str); romanlist[n].len = len; memcpy((char *)romanlist[n].code, (char *)kbuf, R_MAXKANA * sizeof(u_short)); return(0); }
false
false
false
false
false
0
ext_tree_mark_written(struct pnfs_block_layout *bl, sector_t start, sector_t len) { struct rb_root *root = &bl->bl_ext_rw; sector_t end = start + len; struct pnfs_block_extent *be; int err = 0; spin_lock(&bl->bl_ext_lock); /* * First remove all COW extents or holes from written to range. */ err = __ext_tree_remove(&bl->bl_ext_ro, start, end); if (err) goto out; /* * Then mark all invalid extents in the range as written to. */ for (be = __ext_tree_search(root, start); be; be = ext_tree_next(be)) { if (be->be_f_offset >= end) break; if (be->be_state != PNFS_BLOCK_INVALID_DATA || be->be_tag) continue; if (be->be_f_offset < start) { struct pnfs_block_extent *left = ext_tree_prev(be); if (left && ext_can_merge(left, be)) { sector_t diff = start - be->be_f_offset; left->be_length += diff; be->be_f_offset += diff; be->be_v_offset += diff; be->be_length -= diff; } else { err = ext_tree_split(root, be, start); if (err) goto out; } } if (ext_f_end(be) > end) { struct pnfs_block_extent *right = ext_tree_next(be); if (right && ext_can_merge(be, right)) { sector_t diff = end - be->be_f_offset; be->be_length -= diff; right->be_f_offset -= diff; right->be_v_offset -= diff; right->be_length += diff; } else { err = ext_tree_split(root, be, end); if (err) goto out; } } if (be->be_f_offset >= start && ext_f_end(be) <= end) { be->be_tag = EXTENT_WRITTEN; be = ext_try_to_merge_left(root, be); be = ext_try_to_merge_right(root, be); } } out: spin_unlock(&bl->bl_ext_lock); return err; }
false
false
false
false
false
0
isofs_bread(struct inode *inode, sector_t block) { sector_t blknr = isofs_bmap(inode, block); if (!blknr) return NULL; return sb_bread(inode->i_sb, blknr); }
false
false
false
false
false
0
ArgCountError(int m, int n) { char text[256]; const char *name = this->MethodName; int nargs = this->N; sprintf(text, "%.200s%s takes %s %d argument%s (%d given)", (name ? name : "function"), (name ? "()" : ""), ((m == n) ? "exactly" : ((nargs < m) ? "at least" : "at most")), ((nargs < m) ? m : n), ((((nargs < m) ? m : n)) == 1 ? "" : "s"), nargs); PyErr_SetString(PyExc_TypeError, text); return false; }
false
false
false
false
false
0
marshalReplyHeader(giopStream* g) { char* hdr = (char*) g->pd_currentOutputBuffer + g->pd_currentOutputBuffer->start; hdr[7] = (char) GIOP::Reply; GIOP_S& giop_s = *(GIOP_S*)g; cdrStream& s = (cdrStream&) *g; CORBA::ULong rc = GIOP::NO_EXCEPTION; { // calculate the request header size cdrCountingStream cs(g->TCS_C(),g->TCS_W(),12); giop_s.service_contexts() >>= cs; giop_s.requestId() >>= cs; rc >>= cs; *((CORBA::ULong*)(hdr+8)) = cs.total(); #if defined(PRE_CALCULATE_MESSAGE_SIZE) omniORB::logs(30, "Pre-calculating GIOP 1.0 message size."); giop_s.calldescriptor()->marshalReturnedValues(cs); CORBA::ULong msgsz = cs.total() - 12; *((CORBA::ULong*)(hdr + 8)) = msgsz; outputSetMessageSize(g,msgsz); #endif } // Service context giop_s.service_contexts() >>= s; // request id giop_s.requestId() >>= s; // reply status rc >>= s; }
false
false
false
false
false
0
Step(Threadq* runq, Threadq* nextq, int c, int flag, const char* p) { nextq->clear(); for (Threadq::iterator i = runq->begin(); i != runq->end(); ++i) { Thread* t = i->second; if (t == NULL) continue; if (longest_) { // Can skip any threads started after our current best match. if (matched_ && match_[0] < t->capture[0]) { FreeThread(t); continue; } } int id = t->id; Prog::Inst* ip = prog_->inst(id); switch (ip->opcode()) { default: // Should only see the values handled below. LOG(DFATAL) << "Unhandled " << ip->opcode() << " in step"; break; case kInstByteRange: if (ip->Matches(c)) AddToThreadq(nextq, ip->out(), flag, p+1, t->capture); break; case kInstAltMatch: if (i != runq->begin()) break; // The match is ours if we want it. if (ip->greedy(prog_) || longest_) { CopyCapture((const char**)match_, t->capture); FreeThread(t); for (++i; i != runq->end(); ++i) FreeThread(i->second); runq->clear(); matched_ = true; if (ip->greedy(prog_)) return ip->out1(); return ip->out(); } break; case kInstMatch: if (endmatch_ && p != etext_) break; const char* old = t->capture[1]; // previous end pointer t->capture[1] = p; if (longest_) { // Leftmost-longest mode: save this match only if // it is either farther to the left or at the same // point but longer than an existing match. if (!matched_ || t->capture[0] < match_[0] || (t->capture[0] == match_[0] && t->capture[1] > match_[1])) CopyCapture((const char**)match_, t->capture); } else { // Leftmost-biased mode: this match is by definition // better than what we've already found (see next line). CopyCapture((const char**)match_, t->capture); // Cut off the threads that can only find matches // worse than the one we just found: don't run the // rest of the current Threadq. t->capture[0] = old; FreeThread(t); for (++i; i != runq->end(); ++i) FreeThread(i->second); runq->clear(); matched_ = true; return 0; } t->capture[0] = old; matched_ = true; break; } FreeThread(t); } runq->clear(); return 0; }
false
false
false
false
false
0
do_throw(cstack) struct condstack *cstack; { int idx; int inactivate_try = FALSE; /* * Cleanup and inactivate up to the next surrounding try conditional that * is not in its finally clause. Normally, do not inactivate the try * conditional itself, so that its ACTIVE flag can be tested below. But * if a previous error or interrupt has not been converted to an exception, * inactivate the try conditional, too, as if the conversion had been done, * and reset the did_emsg or got_int flag, so this won't happen again at * the next surrounding try conditional. */ if (did_emsg && !THROW_ON_ERROR) { inactivate_try = TRUE; did_emsg = FALSE; } if (got_int && !THROW_ON_INTERRUPT) { inactivate_try = TRUE; got_int = FALSE; } idx = cleanup_conditionals(cstack, 0, inactivate_try); if (idx >= 0) { /* * If this try conditional is active and we are before its first * ":catch", set THROWN so that the ":catch" commands will check * whether the exception matches. When the exception came from any of * the catch clauses, it will be made pending at the ":finally" (if * present) and rethrown at the ":endtry". This will also happen if * the try conditional is inactive. This is the case when we are * throwing an exception due to an error or interrupt on the way from * a preceding ":continue", ":break", ":return", ":finish", error or * interrupt (not converted to an exception) to the finally clause or * from a preceding throw of a user or error or interrupt exception to * the matching catch clause or the finally clause. */ if (!(cstack->cs_flags[idx] & CSF_CAUGHT)) { if (cstack->cs_flags[idx] & CSF_ACTIVE) cstack->cs_flags[idx] |= CSF_THROWN; else /* THROWN may have already been set for a catchable exception * that has been discarded. Ensure it is reset for the new * exception. */ cstack->cs_flags[idx] &= ~CSF_THROWN; } cstack->cs_flags[idx] &= ~CSF_ACTIVE; cstack->cs_exception[idx] = current_exception; } #if 0 /* TODO: Add optimization below. Not yet done because of interface * problems to eval.c and ex_cmds2.c. (Servatius) */ else { /* * There are no catch clauses to check or finally clauses to execute. * End the current script or function. The exception will be rethrown * in the caller. */ if (getline_equal(eap->getline, eap->cookie, get_func_line)) current_funccal->returned = TRUE; elseif (eap->get_func_line == getsourceline) ((struct source_cookie *)eap->cookie)->finished = TRUE; } #endif did_throw = TRUE; }
false
false
false
false
false
0
__read_targetid(__be32 *p, struct pnfs_osd_targetid* targetid) { u32 oti_type; oti_type = be32_to_cpup(p++); targetid->oti_type = oti_type; switch (oti_type) { case OBJ_TARGET_SCSI_NAME: case OBJ_TARGET_SCSI_DEVICE_ID: p = __read_u8_opaque(p, &targetid->oti_scsi_device_id); } return p; }
false
false
false
false
false
0
unw_print_grmask (char *cp, unsigned int mask) { int sep = 0; int i; for (i = 0; i < 4; ++i) { if (mask & 1) { if (sep) *cp++ = ','; *cp++ = 'r'; *cp++ = i + 4 + '0'; sep = 1; } mask >>= 1; } *cp = '\0'; }
false
false
false
false
false
0
TerminateExecution(int thread_id) { if (!i::V8::IsRunning()) return; API_ENTRY_CHECK("V8::GetCurrentThreadId()"); // If the thread_id identifies the current thread just terminate // execution right away. Otherwise, ask the thread manager to // terminate the thread with the given id if any. if (thread_id == i::Top::thread_id()) { i::StackGuard::TerminateExecution(); } else { i::ThreadManager::TerminateExecution(thread_id); } }
false
false
false
false
false
0
Curl_readwrite_init(struct connectdata *conn) { struct SessionHandle *data = conn->data; struct Curl_transfer_keeper *k = &conn->keep; /* NB: the content encoding software depends on this initialization of Curl_transfer_keeper. */ memset(k, 0, sizeof(struct Curl_transfer_keeper)); k->start = Curl_tvnow(); /* start time */ k->now = k->start; /* current time is now */ k->header = TRUE; /* assume header */ k->httpversion = -1; /* unknown at this point */ data = conn->data; /* there's the root struct */ k->buf = data->state.buffer; k->uploadbuf = data->state.uploadbuffer; k->maxfd = (conn->sockfd>conn->writesockfd? conn->sockfd:conn->writesockfd)+1; k->hbufp = data->state.headerbuff; k->ignorebody=FALSE; Curl_pgrsTime(data, TIMER_PRETRANSFER); Curl_speedinit(data); Curl_pgrsSetUploadCounter(data, 0); Curl_pgrsSetDownloadCounter(data, 0); if (!conn->bits.getheader) { k->header = FALSE; if(conn->size > 0) Curl_pgrsSetDownloadSize(data, conn->size); } /* we want header and/or body, if neither then don't do this! */ if(conn->bits.getheader || !conn->bits.no_body) { if(conn->sockfd != CURL_SOCKET_BAD) { k->keepon |= KEEP_READ; } if(conn->writesockfd != CURL_SOCKET_BAD) { /* HTTP 1.1 magic: Even if we require a 100-return code before uploading data, we might need to write data before that since the REQUEST may not have been finished sent off just yet. Thus, we must check if the request has been sent before we set the state info where we wait for the 100-return code */ if (data->set.expect100header && (conn->proto.http->sending == HTTPSEND_BODY)) { /* wait with write until we either got 100-continue or a timeout */ k->write_after_100_header = TRUE; k->start100 = k->start; } else { if(data->set.expect100header) /* when we've sent off the rest of the headers, we must await a 100-continue */ k->wait100_after_headers = TRUE; k->keepon |= KEEP_WRITE; } } } return CURLE_OK; }
false
false
false
false
false
0
netdev_rx_err ( struct net_device *netdev, struct io_buffer *iobuf, int rc ) { DBGC ( netdev, "NETDEV %s failed to receive %p: %s\n", netdev->name, iobuf, strerror ( rc ) ); /* Discard packet */ free_iob ( iobuf ); /* Update statistics counter */ netdev_record_stat ( &netdev->rx_stats, rc ); }
false
false
false
false
false
0
netok_clicked(G_GNUC_UNUSED GtkWidget *widget, G_GNUC_UNUSED gpointer data) { int counter=0; int connection=0; if (netmode) return FALSE; gtk_widget_hide(dialogbarbut[ISave-NumMainIcons]); for (; counter < 3; counter++) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(netlrad[counter]))) { connection = counter; break; } for (counter = 0; counter < 2; counter++) if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(netrrad[counter]))) { category = counter + 1; break; } switch (connection) { case 0: /* Auto */ setstat("Trying client..."); if (initnet(0, gtk_entry_get_text(GTK_ENTRY(netentry[0])), gtk_entry_get_text(GTK_ENTRY(netentry[1])))) netmode = 1; else { setstat("Trying server..."); if (initnet(1, gtk_entry_get_text(GTK_ENTRY(netentry[0])), gtk_entry_get_text(GTK_ENTRY(netentry[1])))) netmode = 2; else { netmode = 0; setstat("Could not set up networking!"); } } break; case 1: /* Client */ if (!initnet(0, gtk_entry_get_text(GTK_ENTRY(netentry[0])), gtk_entry_get_text(GTK_ENTRY(netentry[1])))) { netmode = 0; } else netmode = 1; break; case 2: /* Server */ if (!initnet(1, gtk_entry_get_text(GTK_ENTRY(netentry[0])), gtk_entry_get_text(GTK_ENTRY(netentry[1])))) { netmode = 0; } else netmode = 2; break; } return FALSE; }
false
false
false
false
false
0
Connect () { #ifdef HAVE_LOAD_DEFAULTS const char *host; const char *user; const char *passwd; const char *socket; /////// // Converting empty strings into NULL pointer // This allows MySQL server to act as default /////// if (! MySQLHost.length()) host=NULL; else host = MySQLHost.c_str(); if (! MySQLUser.length()) user=0; else user = MySQLUser.c_str(); if (! MySQLPasswd.length()) passwd=0; else passwd = MySQLPasswd.c_str(); if (! MySQLSocket.length()) socket=0; else socket = MySQLSocket.c_str(); if (debug > 0) cout << "Connecting to MySQL server on " << (host?host:"localhost") << " as " << (user?user:"session") << " user" << endl; /////// // Connecting using Htmysql::Connect Interface method /////// if (! Htmysql::Connect (host, user, passwd, 0, MySQLPort, socket)) return 0; // Something has gone wrong ... Let's check it outside here #else /////// // Connecting using Htmysql::Connect Interface method (using default attributes) /////// if (! Htmysql::Connect()) return 0; // Something has gone wrong ... Let's check it outside here #endif // Set the client encoding if (ClientCharset.length() > 0) { std::string SQLStatement = "SET NAMES " + ClientCharset; if (Query (SQLStatement) == -1) { cout << "Check the value of the 'mysql_client_charset' configuration option: " << ClientCharset << endl; return 0; // An error occured } } return 1; }
false
false
false
false
false
0
rtl8225se_rf_set_channel(struct ieee80211_hw *dev, struct ieee80211_conf *conf) { int chan = ieee80211_frequency_to_channel(conf->chandef.chan->center_freq); rtl8225sez2_rf_set_tx_power(dev, chan); rtl8187se_rf_writereg(dev, 0x7, rtl8225se_chan[chan - 1]); if ((rtl8187se_rf_readreg(dev, 0x7) & 0x0F80) != rtl8225se_chan[chan - 1]) rtl8187se_rf_writereg(dev, 0x7, rtl8225se_chan[chan - 1]); usleep_range(10000, 20000); }
false
false
false
false
false
0
enable_multicast(unsigned short eth_nic_base) { unsigned char mcfilter[8]; int i; memset(mcfilter, 0xFF, 8); outb(4, eth_nic_base+D8390_P0_RCR); outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS1, eth_nic_base + D8390_P0_COMMAND); for(i=0;i<8;i++) { outb(mcfilter[i], eth_nic_base + 8 + i); if(inb(eth_nic_base + 8 + i)!=mcfilter[i]) printf("Error SMC 83C690 Multicast filter read/write mishap %d\n",i); } outb(D8390_COMMAND_RD2 + D8390_COMMAND_PS0, eth_nic_base + D8390_P0_COMMAND); outb(4 | 0x08, eth_nic_base+D8390_P0_RCR); }
true
true
false
false
false
1
dumpAMF(AMFObject *obj, char *ptr) { int i; const char opt[] = "NBSO Z"; for (i = 0; i < obj->o_num; i++) { AMFObjectProperty *p = &obj->o_props[i]; if (p->p_type > 5) continue; ptr += sprintf(ptr, " -C "); if (p->p_name.av_val) *ptr++ = 'N'; *ptr++ = opt[p->p_type]; *ptr++ = ':'; if (p->p_name.av_val) ptr += sprintf(ptr, "%.*s:", p->p_name.av_len, p->p_name.av_val); switch (p->p_type) { case AMF_BOOLEAN: *ptr++ = p->p_vu.p_number != 0 ? '1' : '0'; break; case AMF_STRING: memcpy(ptr, p->p_vu.p_aval.av_val, p->p_vu.p_aval.av_len); ptr += p->p_vu.p_aval.av_len; break; case AMF_NUMBER: ptr += sprintf(ptr, "%f", p->p_vu.p_number); break; case AMF_OBJECT: *ptr++ = '1'; ptr = dumpAMF(&p->p_vu.p_object, ptr); ptr += sprintf(ptr, " -C O:0"); break; case AMF_NULL: default: break; } } return ptr; }
false
true
false
false
false
1
check_def_in_ance_block(Block *block_head, Operand *var, IntSet pre_node_set) { int i; for (i = 0; i < block_head->ncfpre; i++) { if (block_head->no > block_head->cfpre[i]->no) { if (block_head->cfpre[i]->def_var_list != NULL && block_head->cfpre[i]->def_var_list->scalar_bv != NULL && in_IntSet(block_head->cfpre[i]->def_var_list->scalar_bv, var->entry)) { return TRUE; } if (!in_IntSet(pre_node_set, block_head->cfpre[i]->no) && check_def_in_ance_block(block_head->cfpre[i], var, pre_node_set)) { return TRUE; } add1_IntSet(pre_node_set, block_head->cfpre[i]->no); } } return FALSE; }
false
false
false
false
false
0
closeEvent(QCloseEvent *cl_event) { int i, button_nr=0; if(annotations_edited) { QMessageBox messagewindow; messagewindow.setText("There are unsaved annotations,\n are you sure you want to quit?"); messagewindow.setIcon(QMessageBox::Question); messagewindow.setStandardButtons(QMessageBox::Cancel | QMessageBox::Close); messagewindow.setDefaultButton(QMessageBox::Cancel); button_nr = messagewindow.exec(); } if(button_nr == QMessageBox::Cancel) { cl_event->ignore(); } else { exit_in_progress = 1; for(i=0; i<MAXSPECTRUMDIALOGS; i++) { if(spectrumdialog[i] != NULL) { delete spectrumdialog[i]; spectrumdialog[i] = NULL; } } for(i=0; i<MAXAVERAGECURVEDIALOGS; i++) { if(averagecurvedialog[i] != NULL) { delete averagecurvedialog[i]; averagecurvedialog[i] = NULL; } } for(i=0; i<MAXZSCOREDIALOGS; i++) { if(zscoredialog[i] != NULL) { delete zscoredialog[i]; zscoredialog[i] = NULL; } } annotations_edited = 0; close_all_files(); write_settings(); free(spectrum_colorbar); free(zoomhistory); free(import_annotations_var); free(export_annotations_var); cl_event->accept(); } }
false
false
false
false
false
0
MetadataDownloaded() { xstring new_info_hash; SHA1(md_download,new_info_hash); if(info_hash && info_hash.ne(new_info_hash)) { LogError(1,"downloaded metadata does not match info_hash, retrying"); StartMetadataDownload(); return; } SetMetadata(md_download); md_download.unset(); }
false
false
false
false
false
0
avoid_crc32(dundi_eid *avoid[]) { /* Idea is that we're calculating a checksum which is independent of the order that the EID's are listed in */ uint32_t acrc32 = 0; int x; for (x=0;avoid[x];x++) { /* Order doesn't matter */ if (avoid[x+1]) { acrc32 ^= crc32(0L, (unsigned char *)avoid[x], sizeof(dundi_eid)); } } return acrc32; }
false
false
false
false
false
0
gck_builder_ref (GckBuilder *builder) { GckRealBuilder *real = (GckRealBuilder *)builder; gboolean stack; g_return_val_if_fail (builder != NULL, NULL); stack = g_atomic_int_add (&real->refs, 1) == 0; if G_UNLIKELY (stack) { g_warning ("Never call gck_builder_ref() on a stack allocated GckBuilder structure"); return NULL; } return builder; }
false
false
false
false
false
0
arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, unsigned long addr) { struct insn insn; u8 fix_ip_or_call = UPROBE_FIX_IP; int ret; ret = uprobe_init_insn(auprobe, &insn, is_64bit_mm(mm)); if (ret) return ret; ret = branch_setup_xol_ops(auprobe, &insn); if (ret != -ENOSYS) return ret; /* * Figure out which fixups default_post_xol_op() will need to perform, * and annotate defparam->fixups accordingly. */ switch (OPCODE1(&insn)) { case 0x9d: /* popf */ auprobe->defparam.fixups |= UPROBE_FIX_SETF; break; case 0xc3: /* ret or lret -- ip is correct */ case 0xcb: case 0xc2: case 0xca: case 0xea: /* jmp absolute -- ip is correct */ fix_ip_or_call = 0; break; case 0x9a: /* call absolute - Fix return addr, not ip */ fix_ip_or_call = UPROBE_FIX_CALL; break; case 0xff: switch (MODRM_REG(&insn)) { case 2: case 3: /* call or lcall, indirect */ fix_ip_or_call = UPROBE_FIX_CALL; break; case 4: case 5: /* jmp or ljmp, indirect */ fix_ip_or_call = 0; break; } /* fall through */ default: riprel_analyze(auprobe, &insn); } auprobe->defparam.ilen = insn.length; auprobe->defparam.fixups |= fix_ip_or_call; auprobe->ops = &default_xol_ops; return 0; }
false
false
false
false
false
0
classNameOfToplevel( int number ) { if ( !qApp->isSessionRestored() ) return QString(); KConfig *config = kapp->sessionConfig(); if ( !config ) return QString(); QString s; s.setNum( number ); s.prepend( QLatin1String("WindowProperties") ); KConfigGroup group( config, s ); if ( !group.hasKey( "ClassName" ) ) return QString(); else return group.readEntry( "ClassName" ); }
false
false
false
false
false
0
open_socket_out_wrapped(char *host, int port, const char *bind_addr, int af_hint) { char *prog = getenv("RSYNC_CONNECT_PROG"); if (prog && strchr(prog, '%')) { int hlen = strlen(host); int len = strlen(prog) + 1; char *f, *t; for (f = prog; *f; f++) { if (*f != '%') continue; /* Compute more than enough room. */ if (f[1] == '%') f++; else len += hlen; } f = prog; if (!(prog = new_array(char, len))) out_of_memory("open_socket_out_wrapped"); for (t = prog; *f; f++) { if (*f == '%') { switch (*++f) { case '%': /* Just skips the extra '%'. */ break; case 'H': memcpy(t, host, hlen); t += hlen; continue; default: f--; /* pass % through */ break; } } *t++ = *f; } *t = '\0'; } if (DEBUG_GTE(CONNECT, 1)) { rprintf(FINFO, "%sopening tcp connection to %s port %d\n", prog ? "Using RSYNC_CONNECT_PROG instead of " : "", host, port); } if (prog) return sock_exec(prog); return open_socket_out(host, port, bind_addr, af_hint); }
true
true
false
false
true
1
abraca_tool_bar_create_cover_image (AbracaToolBar* self) { GtkImage* _tmp0_; GtkImage* _tmp1_; GtkEventBox* _tmp2_; GtkEventBox* _tmp3_; GtkEventBox* eventbox; GtkImage* _tmp4_; g_return_if_fail (self != NULL); abraca_tool_bar_set_default_coverart (self); _tmp0_ = self->priv->_coverart; gtk_widget_set_has_tooltip ((GtkWidget*) _tmp0_, TRUE); _tmp1_ = self->priv->_coverart; g_signal_connect_object ((GtkWidget*) _tmp1_, "query-tooltip", (GCallback) _abraca_tool_bar_on_coverart_tooltip_gtk_widget_query_tooltip, self, 0); _tmp2_ = (GtkEventBox*) gtk_event_box_new (); _tmp3_ = g_object_ref_sink (_tmp2_); eventbox = _tmp3_; g_signal_connect_object ((GtkWidget*) eventbox, "button-release-event", (GCallback) _abraca_tool_bar_on_coverart_clicked_gtk_widget_button_release_event, self, 0); _tmp4_ = self->priv->_coverart; gtk_container_add ((GtkContainer*) eventbox, (GtkWidget*) _tmp4_); gtk_box_pack_start ((GtkBox*) self, (GtkWidget*) eventbox, FALSE, FALSE, (guint) 4); _g_object_unref0 (eventbox); }
false
false
false
false
false
0
binomial_random( int32_t nb_drawings, double prob ) { int32_t nb_success; // The binomial distribution is invariant under changing // ProbSuccess to 1-ProbSuccess, if we also change the answer to // NbTrials minus itself; we ll remember to do this below. double p; if ( prob <= 0.5 ) p = prob; else p = 1.0 - prob; // mean of the deviate to be produced double mean = nb_drawings * p; if ( nb_drawings < 25 ) // Use the direct method while NbTrials is not too large. // This can require up to 25 calls to the uniform random. { nb_success = 0; for ( int32_t j = 1 ; j <= nb_drawings ; j++ ) { if ( random() < p ) nb_success++; } } else if ( mean < 1.0 ) // If fewer than one event is expected out of 25 or more trials, // then the distribution is quite accurately Poisson. Use direct Poisson method. { double g = exp( -mean ); double t = 1.0; int32_t j; for ( j = 0; j <= nb_drawings ; j++ ) { t = t * random(); if ( t < g ) break; } if ( j <= nb_drawings ) nb_success = j; else nb_success = nb_drawings; } else // Use the rejection method. { double en = nb_drawings; double oldg = gammln( en + 1.0 ); double pc = 1.0 - p; double plog = log( p ); double pclog = log( pc ); // rejection method with a Lorentzian comparison function. double sq = sqrt( 2.0 * mean * pc ); double angle, y, em, t; do { do { angle = M_PI * random(); y = tan( angle ); em = sq*y + mean; } while ( em < 0.0 || em >= (en + 1.0) ); // Reject. em = floor( em ); // Trick for integer-valued distribution. t = 1.2 * sq * (1.0 + y*y) * exp( oldg - gammln(em + 1.0) - gammln(en - em + 1.0) + em * plog + (en - em) * pclog ); } while ( random() > t ); // Reject. This happens about 1.5 times per deviate, on average. nb_success = (int32_t) rint( em ); } // Undo the symmetry transformation. if ( p != prob ) nb_success = nb_drawings - nb_success; return nb_success; }
false
false
false
false
false
0
get_struct_property(GWEN_XMLNODE *node, const char *pname, const char *defval) { GWEN_XMLNODE *n; if (GWEN_XMLNode_GetType(node)==GWEN_XMLNodeTypeTag) if (strcasecmp(GWEN_XMLNode_GetData(node), "type")==0) { return GWEN_XMLNode_GetProperty(node, pname, defval); } /* find typedef for this type */ n=GWEN_XMLNode_GetParent(node); if (n) return get_struct_property(n, pname, defval); return defval; }
false
false
false
false
false
0
initialize(const Locale& loc, UErrorCode& status) { if (U_FAILURE(status)) { return; } delete fLocale; fLocale = loc.clone(); if (fPluralRules) { delete fPluralRules; } fPluralRules = PluralRules::forLocale(loc, status); setupCurrencyPluralPattern(loc, status); }
false
false
false
false
false
0
call_func_retnr(func, argc, argv, safe) char_u *func; int argc; char_u **argv; int safe; /* use the sandbox */ { typval_T rettv; long retval; if (call_vim_function(func, argc, argv, safe, &rettv) == FAIL) return -1; retval = get_tv_number_chk(&rettv, NULL); clear_tv(&rettv); return retval; }
false
false
false
false
false
0
getFileNameList() const { QStringList list; if(p->getFileInfoList(&list)) { return list; } else { return QStringList(); } }
false
false
false
false
false
0
gar_alloc_cp(void) { struct cpoint *p; p = calloc(1, sizeof(*p)); if (!p) return NULL; list_init(&p->l); return p; }
false
false
false
false
false
0
cbf_count_getopt_options ( cbf_getopt_handle handle, unsigned int * options ) { if ( !handle ) return CBF_ARGUMENT; if ( options ) *options = handle->optstructs_size; return 0; }
false
false
false
false
false
0
floatformat_i387_ext_is_valid (const struct floatformat *fmt, const void *from) { /* In the i387 double-extended format, if the exponent is all ones, then the integer bit must be set. If the exponent is neither 0 nor ~0, the intbit must also be set. Only if the exponent is zero can it be zero, and then it must be zero. */ unsigned long exponent, int_bit; const unsigned char *ufrom = (const unsigned char *) from; exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->exp_start, fmt->exp_len); int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->man_start, 1); if ((exponent == 0) != (int_bit == 0)) return 0; else return 1; }
false
false
false
false
false
0
getMarkComponent(le_int32 markPosition) const { le_int32 component = 0; le_int32 posn; for (posn = position; posn != markPosition; posn += direction) { if (glyphStorage[posn] == 0xFFFE) { component += 1; } } return component; }
false
false
false
false
false
0
select_item( const std::string& url ) { const Gtk::TreeModel::Row row = get_row_from_url( url ); if( row ){ Gtk::TreePath path = GET_PATH( row ); m_treeview.get_selection()->unselect_all(); m_treeview.set_cursor( path ); } }
false
false
false
false
false
0
loadFromConfigFile( const mrpt::utils::CConfigFileBase &iniFile, const std::string &section) { MRPT_LOAD_CONFIG_VAR(vocab_path,string, iniFile, section ); MRPT_LOAD_CONFIG_VAR(vocabName,string, iniFile, section ); MRPT_LOAD_CONFIG_VAR(p_obs_given_exists,double, iniFile, section ); MRPT_LOAD_CONFIG_VAR(p_at_new_place,double, iniFile, section ); MRPT_LOAD_CONFIG_VAR(df_lik_smooth,double, iniFile, section ); }
false
false
false
false
false
0
def_function(int datatype, long int size, char *size_text, Token *id, Token *args) #else /* K&R style */ def_function(datatype,size,size_text,id,args) #endif /* HAVE_STDC */ /* Installs function or subroutine name */ #if HAVE_STDC /* in global table */ #else /* K&R style */ int datatype; /* in global table */ long size; char *size_text; Token *id,*args; #endif /* HAVE_STDC */ { int storage_class; int h=id->value.integer; Lsymtab *symt; Gsymtab *gsymt; TokenListHeader *TH_ptr; storage_class = class_SUBPROGRAM; if((symt = (hashtab[h].loc_symtab)) == NULL) { /* Symbol is new to local symtab: install it. Since this is the current routine, it has storage class of a variable. */ symt = install_local(h,datatype,class_VAR); symt->line_declared = id->line_num; symt->file_declared = inctable_index; symt->size = size; symt->src.text = size_text; } if(! symt->entry_point) /* seen before but not as entry */ symt->info.toklist = NULL; if(symt->external) { /* warn if entry point was declared external */ syntax_error(id->line_num,id->col_num, "Entry point was declared external:"); msg_tail(symt->name); /* try to undo the damage */ symt->type = type_byte(class_VAR,datatype_of(symt->type)); symt->external = FALSE; } if((gsymt = (hashtab[h].glob_symtab)) == NULL) { /* Symbol is new to global symtab: install it */ gsymt = install_global(h,datatype,storage_class); gsymt->size = size; gsymt->info.arglist = NULL; } else { /* Symbol is already in global symtab. Put the declared datatype into symbol table. */ gsymt->type = type_byte(storage_class,datatype); gsymt->size = size; } /* Restore args list to original order */ if(args != NULL) args->next_token = reverse_tokenlist(args->next_token); /* Insert the new list onto linked list of token lists */ TH_ptr=make_TL_head(id); /* If this is an implied PROGRAM statement it may occur in an include file, which we do not want to appear in diagnostic messages about it. */ if(top_filename != current_filename && datatype == type_PROGRAM) { TH_ptr->filename = top_filename; TH_ptr->line_num = top_file_line_num; } TH_ptr->tokenlist = (args == NULL ? NULL: args->next_token); TH_ptr->next = symt->info.toklist; symt->info.toklist = TH_ptr; symt->entry_point = TRUE; /* library mode: set the flag so no complaint will be issued if function never invoked. */ if(library_mode) symt->library_module = TRUE; if(datatype == type_PROGRAM) { #ifdef VCG_SUPPORT /* Get name of file containing main module */ main_filename = top_filename; #endif } }
false
false
false
false
false
0
gf_general_set_up_single_timing_test(int w, void *ra, void *rb, int size) { void *top; gf_general_t g; uint8_t *r8, *r8a; uint16_t *r16; uint32_t *r32; uint64_t *r64; int i; top = (uint8_t *)rb+size; /* If w is 8, 16, 32, 64 or 128, fill the regions with random bytes. However, don't allow for zeros in rb, because that will screw up division. When w is 4, you fill the regions with random 4-bit words in each byte. Otherwise, treat every four bytes as an uint32_t and fill it with a random value mod (1 << w). */ if (w == 8 || w == 16 || w == 32 || w == 64 || w == 128) { MOA_Fill_Random_Region (ra, size); while (rb < top) { gf_general_set_random(&g, w, 0); switch (w) { case 8: r8 = (uint8_t *) rb; *r8 = g.w32; break; case 16: r16 = (uint16_t *) rb; *r16 = g.w32; break; case 32: r32 = (uint32_t *) rb; *r32 = g.w32; break; case 64: r64 = (uint64_t *) rb; *r64 = g.w64; break; case 128: r64 = (uint64_t *) rb; r64[0] = g.w128[0]; r64[1] = g.w128[1]; break; } rb = (uint8_t *)rb + (w/8); } } else if (w == 4) { r8a = (uint8_t *) ra; r8 = (uint8_t *) rb; while (r8 < (uint8_t *) top) { gf_general_set_random(&g, w, 1); *r8a = g.w32; gf_general_set_random(&g, w, 0); *r8 = g.w32; r8a++; r8++; } } else { r32 = (uint32_t *) ra; for (i = 0; i < size/4; i++) r32[i] = MOA_Random_W(w, 1); r32 = (uint32_t *) rb; for (i = 0; i < size/4; i++) r32[i] = MOA_Random_W(w, 0); } }
false
false
false
false
false
0
render(render_guts_t* guts, int indentation) const { return this->_childNodes.front()->render(guts, indentation) + "::" + this->_childNodes.back()->render(guts, indentation); }
false
false
false
false
false
0
FlmGetStats( FLM_STATS * pFlmStats) { RCODE rc = FERR_OK; // Get the statistics if( RC_BAD( rc = flmStatCopy( pFlmStats, &gv_FlmSysData.Stats))) { goto Exit; } Exit: return( rc); }
false
false
false
false
false
0
test(std::istream& in) const { if (read_binary_number_nocheck<unsigned long>(in) == binary_magic_number && read_binary_number_nocheck<unsigned long>(in) == format_version) return true; in.clear(); in.seekg(0, std::ios::beg); return false; }
false
false
false
false
false
0
setParent(BasicBlock *P) { if (getParent()) { if (!P) LeakDetector::addGarbageObject(this); } else { if (P) LeakDetector::removeGarbageObject(this); } Parent = P; }
false
false
false
false
false
0
ruv_add_csn_inprogress (RUV *ruv, const CSN *csn) { RUVElement* replica; char csn_str[CSN_STRSIZE]; int rc = RUV_SUCCESS; int rid = csn_get_replicaid (csn); PR_ASSERT (ruv && csn); /* locate ruvElement */ slapi_rwlock_wrlock (ruv->lock); if(is_cleaned_rid(rid)){ /* return success because we want to consume the update, but not perform it */ rc = RUV_COVERS_CSN; goto done; } replica = ruvGetReplica (ruv, rid); if (replica == NULL) { replica = ruvAddReplicaNoCSN (ruv, rid, NULL/*purl*/); if (replica == NULL) { if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to add replica" " that created csn %s\n", csn_as_string (csn, PR_FALSE, csn_str)); } rc = RUV_MEMORY_ERROR; goto done; } } /* check first that this csn is not already covered by this RUV */ if (ruv_covers_csn_internal(ruv, csn, PR_FALSE)) { if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " "the csn %s has already be seen - ignoring\n", csn_as_string (csn, PR_FALSE, csn_str)); } rc = RUV_COVERS_CSN; goto done; } rc = csnplInsert (replica->csnpl, csn); if (rc == 1) /* we already seen this csn */ { if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: " "the csn %s has already be seen - ignoring\n", csn_as_string (csn, PR_FALSE, csn_str)); } rc = RUV_COVERS_CSN; } else if(rc != 0) { if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: failed to insert csn %s" " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str)); } rc = RUV_UNKNOWN_ERROR; } else { if (slapi_is_loglevel_set(SLAPI_LOG_REPL)) { slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, "ruv_add_csn_inprogress: successfully inserted csn %s" " into pending list\n", csn_as_string (csn, PR_FALSE, csn_str)); } rc = RUV_SUCCESS; } done: slapi_rwlock_unlock (ruv->lock); return rc; }
true
true
false
false
false
1
gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc) { struct buffer_head *bh, *head; int nr_underway = 0; int write_op = REQ_META | REQ_PRIO | (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); BUG_ON(!PageLocked(page)); BUG_ON(!page_has_buffers(page)); head = page_buffers(page); bh = head; do { if (!buffer_mapped(bh)) continue; /* * If it's a fully non-blocking write attempt and we cannot * lock the buffer then redirty the page. Note that this can * potentially cause a busy-wait loop from flusher thread and kswapd * activity, but those code paths have their own higher-level * throttling. */ if (wbc->sync_mode != WB_SYNC_NONE) { lock_buffer(bh); } else if (!trylock_buffer(bh)) { redirty_page_for_writepage(wbc, page); continue; } if (test_clear_buffer_dirty(bh)) { mark_buffer_async_write(bh); } else { unlock_buffer(bh); } } while ((bh = bh->b_this_page) != head); /* * The page and its buffers are protected by PageWriteback(), so we can * drop the bh refcounts early. */ BUG_ON(PageWriteback(page)); set_page_writeback(page); do { struct buffer_head *next = bh->b_this_page; if (buffer_async_write(bh)) { submit_bh(write_op, bh); nr_underway++; } bh = next; } while (bh != head); unlock_page(page); if (nr_underway == 0) end_page_writeback(page); return 0; }
false
false
false
false
false
0
is_base_type (tree type) { switch (TREE_CODE (type)) { case ERROR_MARK: case VOID_TYPE: case INTEGER_TYPE: case REAL_TYPE: case FIXED_POINT_TYPE: case COMPLEX_TYPE: case BOOLEAN_TYPE: return 1; case ARRAY_TYPE: case RECORD_TYPE: case UNION_TYPE: case QUAL_UNION_TYPE: case ENUMERAL_TYPE: case FUNCTION_TYPE: case METHOD_TYPE: case POINTER_TYPE: case REFERENCE_TYPE: case NULLPTR_TYPE: case OFFSET_TYPE: case LANG_TYPE: case VECTOR_TYPE: return 0; default: gcc_unreachable (); } return 0; }
false
false
false
false
false
0
qtdemux_is_brand_3gp (GstQTDemux * qtdemux, gboolean major) { if (major) { return ((qtdemux->major_brand & GST_MAKE_FOURCC (255, 255, 0, 0)) == GST_MAKE_FOURCC ('3', 'g', 0, 0)); } else if (qtdemux->comp_brands != NULL) { GstMapInfo map; guint8 *data; gsize size; gboolean res = FALSE; gst_buffer_map (qtdemux->comp_brands, &map, GST_MAP_READ); data = map.data; size = map.size; while (size >= 4) { res = res || ((QT_FOURCC (data) & GST_MAKE_FOURCC (255, 255, 0, 0)) == GST_MAKE_FOURCC ('3', 'g', 0, 0)); data += 4; size -= 4; } gst_buffer_unmap (qtdemux->comp_brands, &map); return res; } else { return FALSE; } }
false
false
false
false
false
0
bquote1(LVAL expr) { LVAL val,list,last,new; /* handle atoms */ if (atomp(expr)) val = expr; /* handle (comma <expr>) */ else if (car(expr) == s_comma) { if (atomp(cdr(expr))) xlfail("bad comma expression"); val = xleval(car(cdr(expr))); } /* handle ((comma-at <expr>) ... ) */ else if (consp(car(expr)) && car(car(expr)) == s_comat) { xlstkcheck(2); xlsave(list); xlsave(val); if (atomp(cdr(car(expr)))) xlfail("bad comma-at expression"); list = xleval(car(cdr(car(expr)))); for (last = NIL; consp(list); list = cdr(list)) { new = consa(car(list)); if (last) rplacd(last,new); else val = new; last = new; } if (last) rplacd(last,bquote1(cdr(expr))); else val = bquote1(cdr(expr)); xlpopn(2); } /* handle any other list */ else { xlsave1(val); val = consa(NIL); rplaca(val,bquote1(car(expr))); rplacd(val,bquote1(cdr(expr))); xlpop(); } /* return the result */ return (val); }
false
false
false
false
false
0
_mgt_dispatcher23a(struct rtw_adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) { struct sk_buff *skb = precv_frame->pkt; struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; if (ptable->func) { /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (!ether_addr_equal(hdr->addr1, myid(&padapter->eeprompriv))&& !is_broadcast_ether_addr(hdr->addr1)) return; ptable->func(padapter, precv_frame); } }
false
false
false
false
false
0
remove_volatile_obstacles(int level_num) { int i; // We pass through all the obstacles, deleting those // that are 'blood'. // for (i = 0; i < MAX_OBSTACLES_ON_MAP; i++) { int obstacle_type = curShip.AllLevels[level_num]->obstacle_list[i].type; if (obstacle_type == -1) continue; if (get_obstacle_spec(obstacle_type)->flags & IS_VOLATILE) del_obstacle(&curShip.AllLevels[level_num]->obstacle_list[i]); } }
false
false
false
false
false
0
WriteDependencies( const std::set<std::string>& sources, const std::string& obj, std::ostream&, std::ostream&) { // Make sure this is a scanning instance. if(sources.empty() || sources.begin()->empty()) { cmSystemTools::Error("Cannot scan dependencies without a source file."); return false; } if(obj.empty()) { cmSystemTools::Error("Cannot scan dependencies without an object file."); return false; } bool okay = true; for(std::set<std::string>::const_iterator it = sources.begin(); it != sources.end(); ++it) { const std::string& src = *it; // Get the information object for this source. cmDependsFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj.c_str(), src.c_str()); // Make a copy of the macros defined via ADD_DEFINITIONS std::set<std::string> ppDefines(this->PPDefinitions.begin(), this->PPDefinitions.end()); // Create the parser object. The constructor takes ppMacro and info per // reference, so we may look into the resulting objects later. cmDependsFortranParser parser(this, ppDefines, info); // Push on the starting file. cmDependsFortranParser_FilePush(&parser, src.c_str()); // Parse the translation unit. if(cmDependsFortran_yyparse(parser.Scanner) != 0) { // Failed to parse the file. Report failure to write dependencies. okay = false; } } return okay; }
false
false
false
false
false
0
pbx_checkcondition(const char *condition) { int res; if (ast_strlen_zero(condition)) { /* NULL or empty strings are false */ return 0; } else if (sscanf(condition, "%30d", &res) == 1) { /* Numbers are evaluated for truth */ return res; } else { /* Strings are true */ return 1; } }
false
false
false
false
false
0
headerbar_bitmap(unsigned bmap_id, unsigned alignment, void (*f)(void)) { unsigned hb_index; if ((bx_headerbar_entries+1) > BX_MAX_HEADERBAR_ENTRIES) BX_PANIC(("x: too many headerbar entries, increase BX_MAX_HEADERBAR_ENTRIES")); bx_headerbar_entries++; hb_index = bx_headerbar_entries - 1; bx_headerbar_entry[hb_index].bitmap = bx_bitmaps[bmap_id].bmap; bx_headerbar_entry[hb_index].xdim = bx_bitmaps[bmap_id].xdim; bx_headerbar_entry[hb_index].ydim = bx_bitmaps[bmap_id].ydim; bx_headerbar_entry[hb_index].alignment = alignment; bx_headerbar_entry[hb_index].f = f; if (alignment == BX_GRAVITY_LEFT) { bx_headerbar_entry[hb_index].xorigin = bx_bitmap_left_xorigin; bx_headerbar_entry[hb_index].yorigin = 0; bx_bitmap_left_xorigin += bx_bitmaps[bmap_id].xdim; } else { // BX_GRAVITY_RIGHT bx_bitmap_right_xorigin += bx_bitmaps[bmap_id].xdim; bx_headerbar_entry[hb_index].xorigin = bx_bitmap_right_xorigin; bx_headerbar_entry[hb_index].yorigin = 0; } return(hb_index); }
false
false
false
false
false
0
emitMessage(void *arg, int msg_level) const { jpeg_common_struct *cinfo = (jpeg_common_struct *)arg; // This is how we map the message levels: // -1 - 0: Warning (could also be errors, but no way to find out) // 1 : Debug // Everything else: Trace (No point in splitting this further up) OFLogger::LogLevel level; switch (msg_level) { case -1: case 0: level = OFLogger::WARN_LOG_LEVEL; break; case 1: level = OFLogger::DEBUG_LOG_LEVEL; break; default: level = OFLogger::TRACE_LOG_LEVEL; break; } if (cinfo && DCM_dcmjpegGetLogger().isEnabledFor(level)) { char buffer[JMSG_LENGTH_MAX]; (*cinfo->err->format_message)(cinfo, buffer); /* Create the message */ DCM_dcmjpegGetLogger().forcedLog(level, buffer, __FILE__, __LINE__); } }
false
false
false
false
false
0
morekbd() { auto char s[BIGBUFSIZ * 2]; auto char *ps = s; auto int n, chan; if ((n = read(sockets[STDIN].descriptor, ps, BIGBUFSIZ)) > 0) { ps += n; *ps = 0; switch (*s) { case 'l' : print_msg(PRT_SHOWNUMBERS, "Recent caller's:\n"); addlist(-1, SETUP, 3); break; case 'h' : print_msg(PRT_SHOWNUMBERS, "\n\t*** s)tatus, l)ist, u)p, d)own ***\n"); break; case 'u' : /* huptime(0, 0); */ break; case 'd' : /* huptime(0, 0); */ break; case 's' : now(); print_msg(PRT_SHOWNUMBERS, "\n\t*** %s\n", stl); for (chan = 0; chan < MAXCHAN; chan++) { if (call[chan].bchan == -1) sprintf(s, "\t*** BCHAN#%d : FREE ***\n", chan + 1); else { sprintf(s, "\t*** BCHAN#%d : %d %s %s %s ***\n", chan + 1, call[chan].bchan, call[chan].vnum[0], call[chan].dialin ? "<-" : "->", call[chan].vnum[1]); } /* else */ print_msg(PRT_SHOWNUMBERS, "%s", s); } /* for */ break; } /* switch */ } /* if */ }
true
true
false
false
true
1
find_last_not_of( const UTFString& str, size_type index /*= npos*/, size_type num /*= npos */ ) const { size_type i = 0; const size_type len = length(); if ( index > len ) index = len - 1; while ( i < num && ( index - i ) != npos ) { size_type j = index - i; // careful to step full Unicode characters if ( j != 0 && _utf16_surrogate_follow( at( j ) ) && _utf16_surrogate_lead( at( j - 1 ) ) ) { j = index - ++i; } // and back to the usual dull test unicode_char ch = getChar( j ); if ( !str.inString( ch ) ) return j; i++; } return npos; }
false
false
false
false
false
0
tray_icon2_preferences_construct(GtkWidget * container) { gchar *path = gmpc_get_full_glade_path("preferences-trayicon.ui"); tray_icon2_preferences_xml = gtk_builder_new(); gtk_builder_add_from_file(tray_icon2_preferences_xml, path, NULL); q_free(path); if (tray_icon2_preferences_xml) { GtkWidget *vbox = (GtkWidget *) gtk_builder_get_object(tray_icon2_preferences_xml, "tray-pref-vbox"); gtk_container_add(GTK_CONTAINER(container), vbox); tray_update_settings(); update_popup_settings(); gtk_builder_connect_signals(tray_icon2_preferences_xml, NULL); } gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_builder_get_object(tray_icon2_preferences_xml, "pm-combo")), cfg_get_single_value_as_int_with_default(config, "Default", "min-error-level", ERROR_INFO)); }
false
false
false
false
false
0
net80211_change_channel ( struct net80211_device *dev, int channel ) { int i, oldchan = dev->channel; assert ( dev->netdev->state & NETDEV_OPEN ); for ( i = 0; i < dev->nr_channels; i++ ) { if ( dev->channels[i].channel_nr == channel ) { dev->channel = i; break; } } if ( i == dev->nr_channels ) return -ENOENT; if ( i != oldchan ) return dev->op->config ( dev, NET80211_CFG_CHANNEL ); return 0; }
false
false
false
false
false
0
joinpath(char *buffer, char *stuff) { size_t n, k; if (stuff[0] == SEP) n = 0; else { n = strlen(buffer); if (n > 0 && buffer[n-1] != SEP && n < MAXPATHLEN) buffer[n++] = SEP; } if (n > MAXPATHLEN) Py_FatalError("buffer overflow in getpath.c's joinpath()"); k = strlen(stuff); if (n + k > MAXPATHLEN) k = MAXPATHLEN - n; strncpy(buffer+n, stuff, k); buffer[n+k] = '\0'; }
false
true
false
false
false
1
registerResources(QTextDocument *document) const { if (!document) { return; } QHashIterator<QString, ToolTipResource> it(d->resources); while (it.hasNext()) { it.next(); const ToolTipResource &r = it.value(); QTextDocument::ResourceType t = QTextDocument::ImageResource; switch (r.type) { case ImageResource: break; case HtmlResource: t = QTextDocument::HtmlResource; break; case CssResource: t = QTextDocument::StyleSheetResource; break; } document->addResource(t, it.key(), r.data); } }
false
false
false
false
false
0
TimerHandler(int n,int c,int count,double stepTime) { if( count == 0 ) { /* Reset FM Timer */ timer_enable(Timer[n][c], 0); } else { /* Start FM Timer */ double timeSec = (double)count * stepTime; double slack; slack = timer_get_time() - lastfired[n][c]; /* hackish way to make bstars intro sync without */ /* breaking sonicwi2 command 0x35 */ if (slack < 0.000050) slack = 0; if (!timer_enable(Timer[n][c], 1)) timer_adjust(Timer[n][c], timeSec - slack, (c<<7)|n, 0); } }
false
false
false
false
false
0
arggetc(arg_t *arg) { if(*arg->s == '\0') return(ARG_EOS); if((!(arg->opts & ARG_NO_ESCAPE) && *arg->s == '\\') && !(arg->quote && *(arg->s + 1) != '"')) { if(*(++arg->s) == '\0') return(ARG_EOS); return((int) *(arg->s++)); } if(!(arg->opts & ARG_NO_QUOTE) && *arg->s == '"') { arg->s++; arg->quote = !arg->quote; return(arggetc(arg)); } if(arg->quote) return((int) *(arg->s++)); if(strchr(arg->sep, *arg->s)) { arg->s++; return(ARG_EOA); } return((int) *(arg->s++)); }
false
false
false
false
false
0
traverse(CXMLElementVisitor& inoutVisitor){ //if there are children, visit them if(inoutVisitor.startVisit(*this)){ if(mChildren.size()){ for(lCChildren::const_iterator i=mChildren.begin(); i!=mChildren.end(); i++){ (*i)->traverse(inoutVisitor); } } inoutVisitor.endVisit(*this); } }
false
false
false
false
false
0
SetUserViewTransform(vtkHomogeneousTransform *transform) { if (transform == this->UserViewTransform) { return; } if (this->UserViewTransform) { this->UserViewTransform->RemoveObserver( this->UserViewTransformCallbackCommand); this->UserViewTransform->Delete(); this->UserViewTransform = NULL; } if (transform) { this->UserViewTransform = transform; this->UserViewTransform->Register(this); if (!this->UserViewTransformCallbackCommand) { this->UserViewTransformCallbackCommand = vtkCameraCallbackCommand::New(); this->UserViewTransformCallbackCommand->Self = this; } this->UserViewTransform->AddObserver( vtkCommand::ModifiedEvent, this->UserViewTransformCallbackCommand); } this->Modified(); this->ComputeViewTransform(); this->ComputeDistance(); this->ComputeCameraLightTransform(); }
false
false
false
false
false
0
MOA_Seed(uint32_t seed) { int i; uint32_t s = seed; for (i = 0; i < 5; i++) { s = s * 29943829 - 1; MOA_X[i] = s; } for (i=0; i<19; i++) MOA_Random_32(); }
false
false
false
false
false
0
ssd_get_ot_status(struct ssd_device *dev, int *status) { uint32_t off; uint32_t val; int i; if (!dev || !status) { return -EINVAL; } if (dev->protocol_info.ver >= SSD_PROTOCOL_V3_2_2) { for (i=0; i<dev->hw_info.nr_ctrl; i++) { off = SSD_READ_OT_REG0 + (i * SSD_CTRL_REG_ZONE_SZ); val = ssd_reg32_read(dev->ctrlp + off); if ((val >> 22) & 0x1) { *status = 1; goto out; } off = SSD_WRITE_OT_REG0 + (i * SSD_CTRL_REG_ZONE_SZ); val = ssd_reg32_read(dev->ctrlp + off); if ((val >> 22) & 0x1) { *status = 1; goto out; } } } else { *status = !!dev->ot_delay; } out: return 0; }
false
false
false
false
false
0
knotu(int n,int c,int x[]) { int nplusc,nplus2,i; nplusc = n + c; nplus2 = n + 2; x[1] = 0; for (i = 2; i <= nplusc; i++){ x[i] = i-1; } }
false
false
false
false
false
0
addPredefinedGlobalIdent(const char *ident) { if (!global.params.versionids) global.params.versionids = new Strings(); global.params.versionids->push((char *)ident); }
false
false
false
false
false
0
runOnFunction(Function &F) { if (skipOptnoneFunction(F)) return false; TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE(); // Traverse the dominator tree in the depth-first order. This order makes sure // all bases of a candidate are in Candidates when we process it. for (auto node = GraphTraits<DominatorTree *>::nodes_begin(DT); node != GraphTraits<DominatorTree *>::nodes_end(DT); ++node) { for (auto &I : *node->getBlock()) allocateCandidatesAndFindBasis(&I); } // Rewrite candidates in the reverse depth-first order. This order makes sure // a candidate being rewritten is not a basis for any other candidate. while (!Candidates.empty()) { const Candidate &C = Candidates.back(); if (C.Basis != nullptr) { rewriteCandidateWithBasis(C, *C.Basis); } Candidates.pop_back(); } // Delete all unlink instructions. for (auto *UnlinkedInst : UnlinkedInstructions) { for (unsigned I = 0, E = UnlinkedInst->getNumOperands(); I != E; ++I) { Value *Op = UnlinkedInst->getOperand(I); UnlinkedInst->setOperand(I, nullptr); RecursivelyDeleteTriviallyDeadInstructions(Op); } delete UnlinkedInst; } bool Ret = !UnlinkedInstructions.empty(); UnlinkedInstructions.clear(); return Ret; }
false
false
false
false
false
0
apol_context_create_from_qpol_context(const apol_policy_t * p, const qpol_context_t * context) { apol_context_t *c = NULL; const qpol_user_t *user; const qpol_role_t *role; const qpol_type_t *type; const qpol_mls_range_t *range; const char *user_name, *role_name, *type_name; apol_mls_range_t *apol_range = NULL; if ((c = apol_context_create()) == NULL) { ERR(p, "%s", strerror(ENOMEM)); goto err; } if (qpol_context_get_user(p->p, context, &user) < 0 || qpol_context_get_role(p->p, context, &role) < 0 || qpol_context_get_type(p->p, context, &type) < 0 || qpol_context_get_range(p->p, context, &range) < 0) { goto err; } if (qpol_user_get_name(p->p, user, &user_name) < 0 || qpol_role_get_name(p->p, role, &role_name) < 0 || qpol_type_get_name(p->p, type, &type_name) < 0) { goto err; } if (qpol_policy_has_capability(p->p, QPOL_CAP_MLS)) { /* if the policy is MLS then convert the range, else * rely upon the default value of NULL */ if ((apol_range = apol_mls_range_create_from_qpol_mls_range(p, range)) == NULL) { goto err; } } if (apol_context_set_user(p, c, user_name) < 0 || apol_context_set_role(p, c, role_name) < 0 || apol_context_set_type(p, c, type_name) < 0 || apol_context_set_range(p, c, apol_range) < 0) { goto err; } return c; err: apol_mls_range_destroy(&apol_range); apol_context_destroy(&c); return NULL; }
false
false
false
false
false
0
getOpRegClass(const MachineInstr &MI, unsigned OpNo) const { const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo(); const MCInstrDesc &Desc = get(MI.getOpcode()); if (MI.isVariadic() || OpNo >= Desc.getNumOperands() || Desc.OpInfo[OpNo].RegClass == -1) { unsigned Reg = MI.getOperand(OpNo).getReg(); if (TargetRegisterInfo::isVirtualRegister(Reg)) return MRI.getRegClass(Reg); return RI.getPhysRegClass(Reg); } unsigned RCID = Desc.OpInfo[OpNo].RegClass; return RI.getRegClass(RCID); }
false
false
false
false
false
0
lme2510_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) { struct dvb_usb_device *d = i2c_get_adapdata(adap); struct lme2510_state *st = d->priv; static u8 obuf[64], ibuf[64]; int i, read, read_o; u16 len; u8 gate = st->i2c_gate; mutex_lock(&d->i2c_mutex); if (gate == 0) gate = 5; for (i = 0; i < num; i++) { read_o = msg[i].flags & I2C_M_RD; read = i + 1 < num && msg[i + 1].flags & I2C_M_RD; read |= read_o; gate = (msg[i].addr == st->i2c_tuner_addr) ? (read) ? st->i2c_tuner_gate_r : st->i2c_tuner_gate_w : st->i2c_gate; obuf[0] = gate | (read << 7); if (gate == 5) obuf[1] = (read) ? 2 : msg[i].len + 1; else obuf[1] = msg[i].len + read + 1; obuf[2] = msg[i].addr << 1; if (read) { if (read_o) len = 3; else { memcpy(&obuf[3], msg[i].buf, msg[i].len); obuf[msg[i].len+3] = msg[i+1].len; len = msg[i].len+4; } } else { memcpy(&obuf[3], msg[i].buf, msg[i].len); len = msg[i].len+3; } if (lme2510_msg(d, obuf, len, ibuf, 64) < 0) { deb_info(1, "i2c transfer failed."); mutex_unlock(&d->i2c_mutex); return -EAGAIN; } if (read) { if (read_o) memcpy(msg[i].buf, &ibuf[1], msg[i].len); else { memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len); i++; } } } mutex_unlock(&d->i2c_mutex); return i; }
false
true
false
false
true
1
iscsit_release_discovery_tpg(void) { struct iscsi_portal_group *tpg = iscsit_global->discovery_tpg; if (!tpg) return; core_tpg_deregister(&tpg->tpg_se_tpg); kfree(tpg); iscsit_global->discovery_tpg = NULL; }
false
false
false
false
false
0
GetFeature( long nFeatureId ) { if (!TouchLayer()) return NULL; OGRFeature *poFeature = NULL; poFeature = SHPReadOGRFeature( hSHP, hDBF, poFeatureDefn, nFeatureId, NULL, osEncoding ); if( poFeature != NULL ) { if( poFeature->GetGeometryRef() != NULL ) { poFeature->GetGeometryRef()->assignSpatialReference( GetSpatialRef() ); } m_nFeaturesRead++; return poFeature; } /* * Reading shape feature failed. */ return NULL; }
false
false
false
false
false
0
me_unkline(struct Client *client_p, struct Client *source_p, int parc, const char *parv[]) { const char *user, *host; /* user host */ if(!IsClient(source_p)) return 0; user = parv[1]; host = parv[2]; if(!find_shared_conf(source_p->username, source_p->host, source_p->servptr->name, SHARED_UNKLINE)) return 0; if(remove_temp_kline(source_p, user, host)) return 0; remove_perm_kline(source_p, user, host); return 0; }
false
false
false
false
false
0
evhttp_get_request(struct evhttp *http, int fd, struct sockaddr *sa, socklen_t salen) { struct evhttp_connection *evcon; evcon = evhttp_get_request_connection(http, fd, sa, salen); if (evcon == NULL) return; /* the timeout can be used by the server to close idle connections */ if (http->timeout != -1) evhttp_connection_set_timeout(evcon, http->timeout); /* * if we want to accept more than one request on a connection, * we need to know which http server it belongs to. */ evcon->http_server = http; TAILQ_INSERT_TAIL(&http->connections, evcon, next); if (evhttp_associate_new_request_with_connection(evcon) == -1) evhttp_connection_free(evcon); }
false
false
false
false
false
0
blogic_deladapter(struct blogic_adapter *adapter) { struct Scsi_Host *host = adapter->scsi_host; scsi_remove_host(host); /* FlashPoint Host Adapters must first be released by the FlashPoint SCCB Manager. */ if (blogic_flashpoint_type(adapter)) FlashPoint_ReleaseHostAdapter(adapter->cardhandle); /* Destroy the CCBs and release any system resources acquired to support Host Adapter. */ blogic_destroy_ccbs(adapter); blogic_relres(adapter); /* Release usage of the I/O Address range. */ release_region(adapter->io_addr, adapter->addr_count); /* Remove Host Adapter from the list of registered BusLogic Host Adapters. */ list_del(&adapter->host_list); scsi_host_put(host); return 0; }
false
false
false
false
false
0
cisco_autorp_print(register const u_char *bp, register u_int len) { int type; int numrps; int hold; TCHECK(bp[0]); (void)printf(" auto-rp "); type = bp[0]; switch (type) { case 0x11: (void)printf("candidate-advert"); break; case 0x12: (void)printf("mapping"); break; default: (void)printf("type-0x%02x", type); break; } TCHECK(bp[1]); numrps = bp[1]; TCHECK2(bp[2], 2); (void)printf(" Hold "); hold = EXTRACT_16BITS(&bp[2]); if (hold) relts_print(EXTRACT_16BITS(&bp[2])); else printf("FOREVER"); /* Next 4 bytes are reserved. */ bp += 8; len -= 8; /*XXX skip unless -v? */ /* * Rest of packet: * numrps entries of the form: * 32 bits: RP * 6 bits: reserved * 2 bits: PIM version supported, bit 0 is "supports v1", 1 is "v2". * 8 bits: # of entries for this RP * each entry: 7 bits: reserved, 1 bit: negative, * 8 bits: mask 32 bits: source * lather, rinse, repeat. */ while (numrps--) { int nentries; char s; TCHECK2(bp[0], 4); (void)printf(" RP %s", ipaddr_string(bp)); TCHECK(bp[4]); switch (bp[4] & 0x3) { case 0: printf(" PIMv?"); break; case 1: printf(" PIMv1"); break; case 2: printf(" PIMv2"); break; case 3: printf(" PIMv1+2"); break; } if (bp[4] & 0xfc) (void)printf(" [rsvd=0x%02x]", bp[4] & 0xfc); TCHECK(bp[5]); nentries = bp[5]; bp += 6; len -= 6; s = ' '; for (; nentries; nentries--) { TCHECK2(bp[0], 6); (void)printf("%c%s%s/%d", s, bp[0] & 1 ? "!" : "", ipaddr_string(&bp[2]), bp[1]); if (bp[0] & 0xfe) (void)printf("[rsvd=0x%02x]", bp[0] & 0xfe); s = ','; bp += 6; len -= 6; } } return; trunc: (void)printf("[|autorp]"); return; }
false
false
false
false
false
0
GetScratchRegister(bool Is64Bit, const MachineFunction &MF) { if (Is64Bit) { return X86::R11; } else { CallingConv::ID CallingConvention = MF.getFunction()->getCallingConv(); bool IsNested = HasNestArgument(&MF); if (CallingConvention == CallingConv::X86_FastCall) { if (IsNested) { report_fatal_error("Segmented stacks does not support fastcall with " "nested function."); return -1; } else { return X86::EAX; } } else { if (IsNested) return X86::EDX; else return X86::ECX; } } }
false
false
false
false
false
0
s_alloc_state(gs_memory_t * mem, gs_memory_type_ptr_t stype, client_name_t cname) { stream_state *st = gs_alloc_struct(mem, stream_state, stype, cname); if_debug3m('s', mem, "[s]alloc_state %s(%s) = 0x%lx\n", client_name_string(cname), client_name_string(stype->sname), (ulong) st); if (st) s_init_state(st, NULL, mem); return st; }
false
false
false
false
false
0
M_ReactToDamage (edict_t * targ, edict_t * attacker) { if (!(attacker->client) && !(attacker->svflags & SVF_MONSTER)) return; if (attacker == targ || attacker == targ->enemy) return; // if we are a good guy monster and our attacker is a player // or another good guy, do not get mad at them if (targ->monsterinfo.aiflags & AI_GOOD_GUY) { if (attacker->client || (attacker->monsterinfo.aiflags & AI_GOOD_GUY)) return; } // we now know that we are not both good guys // if attacker is a client, get mad at them because he's good and we're not if (attacker->client) { // this can only happen in coop (both new and old enemies are clients) // only switch if can't see the current enemy if (targ->enemy && targ->enemy->client) { if (visible (targ, targ->enemy)) { targ->oldenemy = attacker; return; } targ->oldenemy = targ->enemy; } targ->enemy = attacker; if (!(targ->monsterinfo.aiflags & AI_DUCKED)) FoundTarget (targ); return; } // it's the same base (walk/swim/fly) type and a different classname and it's not a tank // (they spray too much), get mad at them if (((targ->flags & (FL_FLY | FL_SWIM)) == (attacker->flags & (FL_FLY | FL_SWIM))) && (strcmp (targ->classname, attacker->classname) != 0) && (strcmp (attacker->classname, "monster_tank") != 0) && (strcmp (attacker->classname, "monster_supertank") != 0) && (strcmp (attacker->classname, "monster_makron") != 0) && (strcmp (attacker->classname, "monster_jorg") != 0)) { if (targ->enemy && targ->enemy->client) targ->oldenemy = targ->enemy; targ->enemy = attacker; if (!(targ->monsterinfo.aiflags & AI_DUCKED)) FoundTarget (targ); } else // otherwise get mad at whoever they are mad at (help our buddy) { if (targ->enemy && targ->enemy->client) targ->oldenemy = targ->enemy; targ->enemy = attacker->enemy; if (!(targ->monsterinfo.aiflags & AI_DUCKED)) FoundTarget (targ); } }
false
false
false
false
false
0
sharedsv_scalar_store(pTHX_ SV *sv, SV *ssv) { dTHXc; bool allowed = TRUE; assert(PL_sharedsv_lock.owner == aTHX); if (!PL_dirty && SvROK(ssv) && SvREFCNT(SvRV(ssv)) == 1) { SV *sv = sv_newmortal(); sv_upgrade(sv, SVt_RV); get_RV(sv, SvRV(ssv)); } if (SvROK(sv)) { SV *obj = SvRV(sv); SV *sobj = Perl_sharedsv_find(aTHX_ obj); if (sobj) { SHARED_CONTEXT; (void)SvUPGRADE(ssv, SVt_RV); sv_setsv_nomg(ssv, &PL_sv_undef); SvRV_set(ssv, SvREFCNT_inc(sobj)); SvROK_on(ssv); if (SvOBJECT(sobj)) { /* Remove any old blessing */ SvREFCNT_dec(SvSTASH(sobj)); SvOBJECT_off(sobj); } if (SvOBJECT(obj)) { SV* fake_stash = newSVpv(HvNAME_get(SvSTASH(obj)),0); SvOBJECT_on(sobj); SvSTASH_set(sobj, (HV*)fake_stash); } CALLER_CONTEXT; } else { allowed = FALSE; } } else { SvTEMP_off(sv); SHARED_CONTEXT; sv_setsv_nomg(ssv, sv); if (SvOBJECT(ssv)) { /* Remove any old blessing */ SvREFCNT_dec(SvSTASH(ssv)); SvOBJECT_off(ssv); } if (SvOBJECT(sv)) { SV* fake_stash = newSVpv(HvNAME_get(SvSTASH(sv)),0); SvOBJECT_on(ssv); SvSTASH_set(ssv, (HV*)fake_stash); } CALLER_CONTEXT; } if (!allowed) { Perl_croak(aTHX_ "Invalid value for shared scalar"); } }
false
false
false
false
false
0
extstate_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { char *exten, *context; if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); return -1; } context = exten = data; strsep(&context, "@"); if (ast_strlen_zero(context)) context = "default"; if (ast_strlen_zero(exten)) { ast_log(LOG_WARNING, "EXTENSION_STATE requires an extension\n"); return -1; } ast_copy_string(buf, ast_extstate_str(ast_extension_state(chan, context, exten)), len); return 0; }
false
false
false
false
false
0
btrfs_free_dev_extent(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 start, u64 *dev_extent_len) { int ret; struct btrfs_path *path; struct btrfs_root *root = device->dev_root; struct btrfs_key key; struct btrfs_key found_key; struct extent_buffer *leaf = NULL; struct btrfs_dev_extent *extent = NULL; path = btrfs_alloc_path(); if (!path) return -ENOMEM; key.objectid = device->devid; key.offset = start; key.type = BTRFS_DEV_EXTENT_KEY; again: ret = btrfs_search_slot(trans, root, &key, path, -1, 1); if (ret > 0) { ret = btrfs_previous_item(root, path, key.objectid, BTRFS_DEV_EXTENT_KEY); if (ret) goto out; leaf = path->nodes[0]; btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); extent = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent); BUG_ON(found_key.offset > start || found_key.offset + btrfs_dev_extent_length(leaf, extent) < start); key = found_key; btrfs_release_path(path); goto again; } else if (ret == 0) { leaf = path->nodes[0]; extent = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent); } else { btrfs_std_error(root->fs_info, ret, "Slot search failed"); goto out; } *dev_extent_len = btrfs_dev_extent_length(leaf, extent); ret = btrfs_del_item(trans, root, path); if (ret) { btrfs_std_error(root->fs_info, ret, "Failed to remove dev extent item"); } else { set_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags); } out: btrfs_free_path(path); return ret; }
false
false
false
false
false
0