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
read_NC(NC *ncp) { int status = NC_NOERR; free_NC_dimarrayV(&ncp->dims); free_NC_attrarrayV(&ncp->attrs); free_NC_vararrayV(&ncp->vars); status = nc_get_NC(ncp); if(status == NC_NOERR) fClr(ncp->flags, NC_NDIRTY | NC_HDIRTY); return status; }
false
false
false
false
false
0
isEditable() { return ((m_type == TEXT) || (m_type == PASSWORD) || (m_type == ISINDEX) || (m_type == FILE)); }
false
false
false
false
false
0
M_Read(void) { if(!MET_Read(*m_ReadStream, & m_Fields)) { METAIO_STREAM::cout << "MetaForm: Read: MET_Read Failed" << METAIO_STREAM::endl; return false; } MetaForm::InitializeEssential(); MET_FieldRecordType * mF; mF = MET_GetFieldRecord("Comment", &m_Fields); if(mF && mF->defined) { strcpy(m_Comment, (char *)(mF->value)); } mF = MET_GetFieldRecord("FormTypeName", &m_Fields); if(mF && mF->defined) { strcpy(m_FormTypeName, (char *)(mF->value)); } mF = MET_GetFieldRecord("Name", &m_Fields); if(mF && mF->defined) { strcpy(m_Name, (char *)(mF->value)); } mF = MET_GetFieldRecord("BinaryData", &m_Fields); if(mF && mF->defined) { if(((char *)(mF->value))[0] == 'T' || ((char *)(mF->value))[0] == 't' || ((char *)(mF->value))[0] == '1') { m_BinaryData = true; } else { m_BinaryData = false; } } else { m_BinaryData = false; } mF = MET_GetFieldRecord("BinaryDataByteOrderMSB", &m_Fields); if(mF && mF->defined) { if(((char *)(mF->value))[0] == 'T' || ((char *)(mF->value))[0] == 't' || ((char *)(mF->value))[0] == '1') { m_BinaryDataByteOrderMSB = true; } else { m_BinaryDataByteOrderMSB = false; } } mF = MET_GetFieldRecord("CompressedData", &m_Fields); if(mF && mF->defined) { if(((char *)(mF->value))[0] == 'T' || ((char *)(mF->value))[0] == 't' || ((char *)(mF->value))[0] == '1') { m_CompressedData = true; } else { m_CompressedData = false; } } else { m_CompressedData = false; } // Set the read record field in the m_UserDefinedWriteFields FieldsContainerType::iterator it = m_UserDefinedReadFields.begin(); FieldsContainerType::iterator end = m_UserDefinedReadFields.end(); while( it != end ) { mF = MET_GetFieldRecord((*it)->name, &m_Fields); m_UserDefinedWriteFields.push_back(mF); ++it; } return true; }
false
false
false
false
false
0
r_consonant_pair(struct SN_env * z) { { int m_test = z->l - z->c; /* test, line 53 */ { int mlimit; /* setlimit, line 54 */ int m1 = z->l - z->c; (void)m1; if (z->c < z->I[0]) return 0; z->c = z->I[0]; /* tomark, line 54 */ mlimit = z->lb; z->lb = z->c; z->c = z->l - m1; z->ket = z->c; /* [, line 54 */ if (z->c - 1 <= z->lb || z->p[z->c - 1] != 116) { z->lb = mlimit; return 0; } if (!(find_among_b(z, a_1, 2))) { z->lb = mlimit; return 0; } /* substring, line 54 */ z->bra = z->c; /* ], line 54 */ z->lb = mlimit; } z->c = z->l - m_test; } if (z->c <= z->lb) return 0; z->c--; /* next, line 59 */ z->bra = z->c; /* ], line 59 */ { int ret = slice_del(z); /* delete, line 59 */ if (ret < 0) return ret; } return 1; }
false
false
false
false
false
0
fix_placeholder_input_needed_levels(PlannerInfo *root) { ListCell *lc; foreach(lc, root->placeholder_list) { PlaceHolderInfo *phinfo = (PlaceHolderInfo *) lfirst(lc); Relids eval_at = phinfo->ph_eval_at; /* No work unless it'll be evaluated above baserel level */ if (bms_membership(eval_at) == BMS_MULTIPLE) { List *vars = pull_var_clause((Node *) phinfo->ph_var->phexpr, PVC_INCLUDE_PLACEHOLDERS); add_vars_to_targetlist(root, vars, eval_at); list_free(vars); } } }
false
false
false
false
false
0
CrawlerAttacks(int destination) const { for(int i=0; i<nRay; ++i) { if( destination == mailbox[ mailbox2board[square] + ray[i] ] ) return true; } return false; }
false
false
false
false
false
0
bwins(BW *w, long int l, long int n, int flg) { if (l + flg + n < w->top->line + w->h && l + flg >= w->top->line && l + flg <= w->b->eof->line) { if (flg) w->t->t->sary[w->y + l - w->top->line] = w->t->t->li; nscrldn(w->t->t, (int) (w->y + l + flg - w->top->line), w->y + w->h, (int) n); } if (l < w->top->line + w->h && l >= w->top->line) { if (n >= w->h - (l - w->top->line)) { msetI(w->t->t->updtab + w->y + l - w->top->line, 1, w->h - (int) (l - w->top->line)); msetI(w->t->t->syntab + w->y + l - w->top->line, -1, w->h - (int) (l - w->top->line)); } else { msetI(w->t->t->updtab + w->y + l - w->top->line, 1, (int) n + 1); msetI(w->t->t->syntab + w->y + l - w->top->line, -1, (int) n + 1); } } }
false
false
false
false
false
0
expand_builtin_strchr (tree arglist, rtx target, enum machine_mode mode) { if (!validate_arglist (arglist, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE)) return 0; else { tree s1 = TREE_VALUE (arglist), s2 = TREE_VALUE (TREE_CHAIN (arglist)); const char *p1; if (TREE_CODE (s2) != INTEGER_CST) return 0; p1 = c_getstr (s1); if (p1 != NULL) { char c; const char *r; if (target_char_cast (s2, &c)) return 0; r = strchr (p1, c); if (r == NULL) return const0_rtx; /* Return an offset into the constant string argument. */ return expand_expr (fold (build (PLUS_EXPR, TREE_TYPE (s1), s1, convert (TREE_TYPE (s1), ssize_int (r - p1)))), target, mode, EXPAND_NORMAL); } /* FIXME: Should use here strchrM optab so that ports can optimize this. */ return 0; } }
false
false
false
false
false
0
nic_add(nic_t *nic) { /* Add this device to our list of nics */ if (nic_list == NULL) { nic_list = nic; } else { nic_t *current = nic_list; while (current->next != NULL) current = current->next; current->next = nic; } }
false
false
false
false
false
0
usb_wwan_resume(struct usb_serial *serial) { int i, j; struct usb_serial_port *port; struct usb_wwan_intf_private *intfdata = usb_get_serial_data(serial); struct usb_wwan_port_private *portdata; struct urb *urb; int err; int err_count = 0; spin_lock_irq(&intfdata->susp_lock); for (i = 0; i < serial->num_ports; i++) { port = serial->port[i]; if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) continue; portdata = usb_get_serial_port_data(port); if (port->interrupt_in_urb) { err = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC); if (err) { dev_err(&port->dev, "%s: submit int urb failed: %d\n", __func__, err); err_count++; } } err = usb_wwan_submit_delayed_urbs(port); if (err) err_count++; for (j = 0; j < N_IN_URB; j++) { urb = portdata->in_urbs[j]; err = usb_submit_urb(urb, GFP_ATOMIC); if (err < 0) { dev_err(&port->dev, "%s: submit read urb %d failed: %d\n", __func__, i, err); err_count++; } } } intfdata->suspended = 0; spin_unlock_irq(&intfdata->susp_lock); if (err_count) return -EIO; return 0; }
false
false
false
false
false
0
maybe_autolink(MMIOT *f) { register int c; int size; /* greedily scan forward for the end of a legitimate link. */ for ( size=0; (c=peek(f, size+1)) != EOF; size++ ) if ( c == '\\' ) { if ( peek(f, size+2) != EOF ) ++size; } else if ( isspace(c) || strchr("'\"()[]{}<>`", c) ) break; if ( (size > 1) && process_possible_link(f, size) ) { shift(f, size); return 1; } return 0; }
false
false
false
false
false
0
ves_icall_System_Math_Asin (gdouble x) { if (x < -1 || x > 1) return NaN.d; return asin (x); }
false
false
false
false
false
0
dbmw_foreach(dbmw_t *dw, dbmw_cb_t cb, void *arg) { struct foreach_ctx ctx; struct cache_foreach_ctx fctx; dbmw_check(dw); if (dbg_ds_debugging(dw->dbg, 1, DBG_DSF_ITERATOR)) { dbg_ds_log(dw->dbg, dw, "%s: starting with %s(%p)", G_STRFUNC, stacktrace_function_name(cb), arg); } /* * Before iterating we flush the deleted keys we know about in the cache * and whose deletion was deferred, so that the underlying map will * not have to iterate on them. */ dbmw_sync(dw, DBMW_SYNC_CACHE | DBMW_DELETED_ONLY); /* * Some values may be present only in the cache. Hence we clear all * marks in the cache and each traversed value that happens to be * present in the cache will be marked as "traversed". * * We flushed deleted keys above, but that does not remove them from * the cache structure. We don't need to traverse these after iterating * on the map, so we make sure they are artifically set to "traversed". */ ctx.u.cb = cb; ctx.arg = arg; ctx.dw = dw; map_foreach(dw->values, cache_reset_before_traversal, NULL); dbmap_foreach(dw->dm, dbmw_foreach_trampoline, &ctx); /* * Continue traversal with all the cached entries that were not traversed * already because they do not exist in the underlying map. * * We count these and remember how many there are so that we can determine * the correct overall item count after an iteration without having to * flush all the dirty values! */ ZERO(&fctx); fctx.foreach = &ctx; fctx.u.cb = dbmw_foreach_trampoline; map_foreach(dw->values, cache_finish_traversal, &fctx); dw->cached = fctx.cached; dw->count_needs_sync = FALSE; /* We just counted items the slow way! */ if (dbg_ds_debugging(dw->dbg, 1, DBG_DSF_ITERATOR)) { dbg_ds_log(dw->dbg, dw, "%s: done with %s(%p)" "has %zu unflushed entr%s in cache", G_STRFUNC, stacktrace_function_name(cb), arg, dw->cached, 1 == dw->cached ? "y" : "ies"); } }
false
false
false
false
false
0
do_encode_md (byte ** r_frame, size_t * r_flen, const byte * md, int algo, size_t len, unsigned nbits, const byte * asn, size_t asnlen) { byte *frame = NULL; size_t nframe = (nbits + 7) / 8; ssize_t i; size_t n = 0; if (!asn || !md || !r_frame || !r_flen) return CDK_Inv_Value; if (len + asnlen + 4 > nframe) return CDK_General_Error; frame = cdk_calloc (1, nframe); if (!frame) return CDK_Out_Of_Core; frame[n++] = 0; frame[n++] = 1; i = nframe - len - asnlen - 3; if (i < 0) { cdk_free (frame); return CDK_Inv_Value; } memset (frame + n, 0xFF, i); n += i; frame[n++] = 0; memcpy (frame + n, asn, asnlen); n += asnlen; memcpy (frame + n, md, len); n += len; if (n != nframe) { cdk_free (frame); return CDK_Inv_Value; } *r_frame = frame; *r_flen = n; return 0; }
false
false
false
false
false
0
setAuto() { gint autoLevels = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(_auto)); if (autoLevels) { _op._auto = true; gtk_widget_set_sensitive(_manualFrame, FALSE); } else { _op._auto = false; gtk_widget_set_sensitive(_manualFrame, TRUE); } }
false
false
false
false
false
0
TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx) { int ret = 0; int i; STACK_OF(CONF_VALUE) *list = NULL; char *digests = NCONF_get_string(conf, section, ENV_DIGESTS); if (!digests) { TS_CONF_lookup_fail(section, ENV_DIGESTS); goto err; } if (!(list = X509V3_parse_list(digests))) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } if (sk_CONF_VALUE_num(list) == 0) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } for (i = 0; i < sk_CONF_VALUE_num(list); ++i) { CONF_VALUE *val = sk_CONF_VALUE_value(list, i); const char *extval = val->value ? val->value : val->name; const EVP_MD *md; if (!(md = EVP_get_digestbyname(extval))) { TS_CONF_invalid(section, ENV_DIGESTS); goto err; } if (!TS_RESP_CTX_add_md(ctx, md)) goto err; } ret = 1; err: sk_CONF_VALUE_pop_free(list, X509V3_conf_free); return ret; }
false
false
false
false
false
0
test_commit_signature__create_empties(void) { // can not create a signature with empty name or email cl_git_pass(try_build_signature("nulltoken", "emeric.fermas@gmail.com", 1234567890, 60)); cl_git_fail(try_build_signature("", "emeric.fermas@gmail.com", 1234567890, 60)); cl_git_fail(try_build_signature(" ", "emeric.fermas@gmail.com", 1234567890, 60)); cl_git_fail(try_build_signature("nulltoken", "", 1234567890, 60)); cl_git_fail(try_build_signature("nulltoken", " ", 1234567890, 60)); }
false
false
false
false
false
0
gnc_account_create_transfer_balance (QofBook *book, Account *account, Account *transfer, gnc_numeric balance, time64 date) { Transaction *trans; Split *split; if (gnc_numeric_zero_p (balance)) return TRUE; g_return_val_if_fail (account != NULL, FALSE); g_return_val_if_fail (transfer != NULL, FALSE); xaccAccountBeginEdit (account); xaccAccountBeginEdit (transfer); trans = xaccMallocTransaction (book); xaccTransBeginEdit (trans); xaccTransSetCurrency (trans, gnc_account_or_default_currency (account, NULL)); xaccTransSetDatePostedSecsNormalized (trans, date); xaccTransSetDescription (trans, _("Opening Balance")); split = xaccMallocSplit (book); xaccTransAppendSplit (trans, split); xaccAccountInsertSplit (account, split); xaccSplitSetAmount (split, balance); xaccSplitSetValue (split, balance); balance = gnc_numeric_neg (balance); split = xaccMallocSplit (book); xaccTransAppendSplit (trans, split); xaccAccountInsertSplit (transfer, split); xaccSplitSetAmount (split, balance); xaccSplitSetValue (split, balance); xaccTransCommitEdit (trans); xaccAccountCommitEdit (transfer); xaccAccountCommitEdit (account); return TRUE; }
false
false
false
false
false
0
aclParseUserMaxIP(void *data) { acl_user_ip_data **acldata = data; char *t = NULL; CBDATA_INIT_TYPE(acl_user_ip_data); if (*acldata) { debug(28, 1) ("Attempting to alter already set User max IP acl\n"); return; } *acldata = cbdataAlloc(acl_user_ip_data); t = strtokFile(); if (!t) goto error; debug(28, 5) ("aclParseUserMaxIP: First token is %s\n", t); if (strcmp("-s", t) == 0) { debug(28, 5) ("aclParseUserMaxIP: Going strict\n"); (*acldata)->flags.strict = 1; t = strtokFile(); if (!t) goto error; } (*acldata)->max = xatoi(t); debug(28, 5) ("aclParseUserMaxIP: Max IP address's %d\n", (int) (*acldata)->max); return; error: self_destruct(); }
false
false
false
false
false
0
const_get_coll_prop(VMG_ vm_prop_id_t prop, vm_val_t *retval, const vm_val_t *self_val, vm_obj_id_t *src_obj, uint *argc) { uint func_idx; /* presume no source object */ *src_obj = VM_INVALID_OBJ; /* translate the property index to an index into our function table */ func_idx = G_meta_table ->prop_to_vector_idx(metaclass_reg_->get_reg_idx(), prop); /* call the appropriate function */ if ((this->*func_table_[func_idx])(vmg_ retval, self_val, argc)) return TRUE; /* not found */ return FALSE; }
false
false
false
false
false
0
get_relevance_for_snippet (AnjutaSnippet *snippet, GList *words_list) { gchar *cur_word = NULL, *name = NULL, *trigger = NULL, *cur_keyword = NULL; gdouble relevance = 0.0, cur_relevance = 0.0, cur_keyword_relevance = 0.0; GList *iter = NULL, *keywords = NULL, *keywords_down = NULL, *iter2 = NULL; /* Assertions */ g_return_val_if_fail (ANJUTA_IS_SNIPPET (snippet), 0.0); /* If the user hasn't typed anything we just consider all snippets relevant */ if (words_list == NULL) return 1.0; /* Get the snippet data */ trigger = g_utf8_strdown (snippet_get_trigger_key (snippet), -1); name = g_utf8_strdown (snippet_get_name (snippet), -1); keywords = snippet_get_keywords_list (snippet); for (iter = g_list_first (keywords); iter != NULL; iter = g_list_next (iter)) { keywords_down = g_list_append (keywords_down, g_utf8_strdown ((gchar *)iter->data, -1)); } g_list_free (keywords); /* We iterate over all the words */ for (iter = g_list_first (words_list); iter != NULL; iter = g_list_next (iter)) { cur_word = (gchar *)iter->data; /* Check the trigger-key */ cur_relevance = get_relevance_for_word (cur_word, trigger); cur_relevance *= TRIGGER_RELEVANCE; relevance += cur_relevance; /* Check the name */ cur_relevance = get_relevance_for_word (cur_word, name); cur_relevance *= NAME_RELEVANCE; relevance += cur_relevance; /* Check each keyword */ cur_keyword_relevance = FIRST_KEYWORD_RELEVANCE; for (iter2 = g_list_first (keywords_down); iter2 != NULL; iter2 = g_list_next (iter2)) { /* If we have too many keywords */ if (cur_keyword_relevance < 0.0) break; cur_keyword = (gchar *)iter2->data; cur_relevance = get_relevance_for_word (cur_word, cur_keyword); cur_relevance *= cur_keyword_relevance; relevance += cur_relevance; cur_keyword_relevance -= KEYWORD_RELEVANCE_DEC; } } return relevance; }
false
false
false
false
false
0
update_worklist_report_dialog(void) { GtkTreeIter it; gtk_list_store_clear(worklists_store); global_worklists_iterate(pgwl) { gtk_list_store_append(worklists_store, &it); gtk_list_store_set(worklists_store, &it, 0, global_worklist_name(pgwl), 1, global_worklist_id(pgwl), -1); } global_worklists_iterate_end; }
false
false
false
false
false
0
numaGetIValue(NUMA *na, l_int32 index, l_int32 *pival) { l_float32 val; PROCNAME("numaGetIValue"); if (!pival) return ERROR_INT("&ival not defined", procName, 1); *pival = 0; if (!na) return ERROR_INT("na not defined", procName, 1); if (index < 0 || index >= na->n) return ERROR_INT("index not valid", procName, 1); val = na->array[index]; *pival = (l_int32)(val + L_SIGN(val) * 0.5); return 0; }
false
false
false
false
false
0
get_url(const char *url) { int retry_count = 0; response_buffer *b = new response_buffer(); do { CURL *c = curl_easy_init(); curl_easy_setopt(c,CURLOPT_WRITEFUNCTION,buffer_write); curl_easy_setopt(c,CURLOPT_WRITEDATA,b); curl_easy_setopt(c,CURLOPT_URL,url); int success = curl_easy_perform(c); curl_easy_getinfo(c,CURLINFO_RESPONSE_CODE,&b->result); curl_easy_cleanup(c); } while(b->result!=200 && ++retry_count<s3_retry_max); s3_request_retry_count = retry_count; return b; }
false
false
false
false
false
0
soap_xpath_foreach(xmlDocPtr doc, const char *xpath, soap_xmlnode_callback cb, void *userdata) { int i = 0; xmlNodeSetPtr nodeset; xmlXPathObjectPtr xpathobj; xpathobj = soap_xpath_eval(doc, xpath); if (!xpathobj) return 0; nodeset = xpathobj->nodesetval; if (!nodeset) return 0; for (i = 0; i < nodeset->nodeNr; i++) { if (!cb(nodeset->nodeTab[i], userdata)) break; } xmlXPathFreeObject((xmlXPathObjectPtr) nodeset); return i; }
false
false
false
false
false
0
dynamicNormalizerMain(int argc, CHR* argv[]) { printLogo(); Parameters parameters; if(!parameters.parseArgs(argc, argv)) { PRINT2_ERR(TXT("Invalid or incomplete command-line arguments have been detected.\n\nPlease type \"%s --help\" for details!\n"), appName(argv[0])); return EXIT_FAILURE; } if(parameters.showHelp()) { printHelpScreen(argc, argv); return EXIT_SUCCESS; } PRINT(TXT("Using ") FMT_CHAR TXT(", by Erik de Castro Lopo <erikd@mega-nerd.com>.\n\n"), AudioIO_SndFile::libraryVersion()); MDynamicAudioNormalizer::setLogFunction(parameters.verboseMode() ? loggingCallback_verbose : loggingCallback_default); AudioIO *sourceFile = NULL, *outputFile = NULL; if(!openFiles(parameters, &sourceFile, &outputFile)) { PRINT_ERR(TXT("Failed to open input and/or output file -> aborting!\n")); return EXIT_FAILURE; } FILE *logFile = NULL; if(parameters.dbgLogFile()) { if(!(logFile = FOPEN(parameters.dbgLogFile(), TXT("w")))) { PRINT_WRN(TXT("Failed to open log file -> No log file will be created!\n")); } } const clock_t clockStart = clock(); const int result = processFiles(parameters, sourceFile, outputFile, logFile); const double elapsed = double(clock() - clockStart) / double(CLOCKS_PER_SEC); sourceFile->close(); outputFile->close(); MY_DELETE(sourceFile); MY_DELETE(outputFile); if(logFile) { fclose(logFile); logFile = NULL; } PRINT(TXT("--------------\n\n")); PRINT(TXT("%s\n\nOperation took %.1f seconds.\n\n"), ((result != EXIT_SUCCESS) ? TXT("Sorry, something went wrong :-(") : TXT("Everything completed successfully :-)")), elapsed); return result; }
false
false
false
false
false
0
crm_time_add_months(crm_time_t * a_time, int extra) { int lpc; uint32_t y, m, d, dmax; crm_time_get_gregorian(a_time, &y, &m, &d); crm_trace("Adding %d months to %.4d-%.2d-%.2d", extra, y, m, d); if (extra > 0) { for (lpc = extra; lpc > 0; lpc--) { m++; if (m == 13) { m = 1; y++; } } } else { for (lpc = -extra; lpc > 0; lpc--) { m--; if (m == 0) { m = 12; y--; } } } dmax = crm_time_days_in_month(m, y); if (dmax < d) { /* Preserve day-of-month unless the month doesn't have enough days */ d = dmax; } crm_trace("Calculated %.4d-%.2d-%.2d", y, m, d); a_time->years = y; a_time->days = get_ordinal_days(y, m, d); crm_time_get_gregorian(a_time, &y, &m, &d); crm_trace("Got %.4d-%.2d-%.2d", y, m, d); }
false
false
false
false
false
0
alloc_ep_req(struct usb_ep *ep, int len, int default_len) { struct usb_request *req; req = usb_ep_alloc_request(ep, GFP_ATOMIC); if (req) { req->length = len ?: default_len; req->buf = kmalloc(req->length, GFP_ATOMIC); if (!req->buf) { usb_ep_free_request(ep, req); req = NULL; } } return req; }
false
false
false
false
false
0
do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg) { struct fuse_access_in *arg = (struct fuse_access_in *) inarg; if (req->f->op.access) req->f->op.access(req, nodeid, arg->mask); else fuse_reply_err(req, ENOSYS); }
false
false
false
false
true
1
bufferedrandom_init(buffered *self, PyObject *args, PyObject *kwds) { char *kwlist[] = {"raw", "buffer_size", NULL}; Py_ssize_t buffer_size = DEFAULT_BUFFER_SIZE; PyObject *raw; self->ok = 0; self->detached = 0; if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|n:BufferedRandom", kwlist, &raw, &buffer_size)) { return -1; } if (_PyIOBase_check_seekable(raw, Py_True) == NULL) return -1; if (_PyIOBase_check_readable(raw, Py_True) == NULL) return -1; if (_PyIOBase_check_writable(raw, Py_True) == NULL) return -1; Py_CLEAR(self->raw); Py_INCREF(raw); self->raw = raw; self->buffer_size = buffer_size; self->readable = 1; self->writable = 1; if (_buffered_init(self) < 0) return -1; _bufferedreader_reset_buf(self); _bufferedwriter_reset_buf(self); self->pos = 0; self->fast_closed_checks = (Py_TYPE(self) == &PyBufferedRandom_Type && Py_TYPE(raw) == &PyFileIO_Type); self->ok = 1; return 0; }
false
false
false
false
false
0
GetPunctuationChars() const { int msg = SCI_GETPUNCTUATIONCHARS; const long len = SendMsg(msg, 0, (uptr_t)NULL); if (!len) return wxEmptyString; wxMemoryBuffer mbuf(len+1); char* buf = (char*)mbuf.GetWriteBuf(len+1); SendMsg(msg, 0, (uptr_t)buf); mbuf.UngetWriteBuf(len); mbuf.AppendByte(0); return sci2wx(buf); }
false
false
false
false
false
0
go_path_data_buffer_new (void) { GOPathDataBuffer *buffer; buffer = g_new (GOPathDataBuffer, 1); if (buffer == NULL) { g_warning ("[GOPathDataBuffer::new] can't create data buffer"); return NULL; } buffer->points = g_new (GOPathPoint, GO_PATH_DEFAULT_BUFFER_SIZE); if (buffer->points == NULL) { g_warning ("[GOPathDataBuffer::new] can't create data buffer"); g_free (buffer); return NULL; } buffer->actions = g_new (GOPathAction, GO_PATH_DEFAULT_BUFFER_SIZE); if (buffer->actions == NULL) { g_warning ("[GOPathDataBuffer::new] can't create data buffer"); g_free (buffer->points); g_free (buffer); return NULL; } buffer->n_points = 0; buffer->n_actions =0; buffer->next = NULL; buffer->previous = NULL; return buffer; }
false
false
false
false
false
0
_e_smart_clip_set(Evas_Object *obj, Evas_Object *clip) { E_Smart_Data *sd; /* try to get the objects smart data */ if (!(sd = evas_object_smart_data_get(obj))) return; /* set the clip */ if (sd->o_stand) evas_object_clip_set(sd->o_stand, clip); if (sd->o_frame) evas_object_clip_set(sd->o_frame, clip); if (sd->o_base) evas_object_clip_set(sd->o_base, clip); }
false
false
false
false
false
0
wake_all_kswapds(unsigned int order, const struct alloc_context *ac) { struct zoneref *z; struct zone *zone; for_each_zone_zonelist_nodemask(zone, z, ac->zonelist, ac->high_zoneidx, ac->nodemask) wakeup_kswapd(zone, order, zone_idx(ac->preferred_zone)); }
false
false
false
false
false
0
getNextToken(const UnicodeString& ruleData, int32_t *ruleIndex, UnicodeString& token, tokenType& type, UErrorCode &status) { int32_t curIndex= *ruleIndex; UChar ch; tokenType prevType=none; if (U_FAILURE(status)) { return; } while (curIndex<ruleData.length()) { ch = ruleData.charAt(curIndex); if ( !inRange(ch, type) ) { status = U_ILLEGAL_CHARACTER; return; } switch (type) { case tSpace: if ( *ruleIndex != curIndex ) { // letter token=UnicodeString(ruleData, *ruleIndex, curIndex-*ruleIndex); *ruleIndex=curIndex; type=prevType; getKeyType(token, type, status); return; } else { *ruleIndex=*ruleIndex+1; } break; // consective space case tColon: case tSemiColon: if ( *ruleIndex != curIndex ) { token=UnicodeString(ruleData, *ruleIndex, curIndex-*ruleIndex); *ruleIndex=curIndex; type=prevType; getKeyType(token, type, status); return; } else { *ruleIndex=curIndex+1; return; } case tLetter: if ((type==prevType)||(prevType==none)) { prevType=type; break; } break; case tNumber: if ((type==prevType)||(prevType==none)) { prevType=type; break; } else { *ruleIndex=curIndex+1; return; } case tDot: if (prevType==none) { // first dot prevType=type; continue; } else { if ( *ruleIndex != curIndex ) { token=UnicodeString(ruleData, *ruleIndex, curIndex-*ruleIndex); *ruleIndex=curIndex; // letter type=prevType; getKeyType(token, type, status); return; } else { // two consective dots *ruleIndex=curIndex+2; return; } } default: status = U_UNEXPECTED_TOKEN; return; } curIndex++; } if ( curIndex>=ruleData.length() ) { if ( (type == tLetter)||(type == tNumber) ) { token=UnicodeString(ruleData, *ruleIndex, curIndex-*ruleIndex); getKeyType(token, type, status); if (U_FAILURE(status)) { return; } } *ruleIndex = ruleData.length(); } }
false
false
false
false
false
0
ClearDialogs () { map <string, Dialog *>::iterator i; while (!Dialogs.empty ()) { i = Dialogs.begin (); if ((*i).second) (*i).second->Destroy (); else Dialogs.erase (i); } } }
false
false
false
false
false
0
RequestInformation( vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) { FILE* xyzFp; if ( this->CheckGeometryFile(xyzFp) != VTK_OK) { return 0; } this->CalculateFileSize(xyzFp); this->ReadGeometryHeader(xyzFp); fclose(xyzFp); vtkInformation* info = outputVector->GetInformationObject(0); info->Set( vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), 1); return 1; }
false
false
false
false
false
0
find_call(const struct sockaddr_atmpvc *in, const struct sockaddr_atmpvc *out) { USER_CALL *u_call; for (u_call = calls; u_call; u_call = u_call->next) if (atm_equal((struct sockaddr *) in, (struct sockaddr *) &u_call->call.in.pvc,0,0) && atm_equal((struct sockaddr *) out, (struct sockaddr *) &u_call->call.out.pvc,0,0)) break; return u_call; }
false
false
false
false
false
0
operator*(const HepSymMatrix &m1,const HepVector &m2) #ifdef HEP_GNU_OPTIMIZED_RETURN return mret(m1.num_row()); { #else { HepVector mret(m1.num_row()); #endif CHK_DIM_1(m1.num_col(),m2.num_row(),*); HepMatrix::mcIter sp,snp,vpt; double temp; int step,stept; HepMatrix::mIter vrp=mret.m.begin(); for(step=1,snp=m1.m.begin();step<=m1.num_row();++step) { sp=snp; vpt=m2.m.begin(); snp+=step; temp=0; while(sp<snp) temp+=*(sp++)*(*(vpt++)); if(step<m1.num_row()) sp+=step-1; for(stept=step+1;stept<=m1.num_row();stept++) { temp+=*sp*(*(vpt++)); if(stept<m1.num_row()) sp+=stept; } *(vrp++)=temp; } // for(step return mret; }
false
false
false
false
false
0
worm_reasons(int color) { int pos; int k; for (pos = BOARDMIN; pos < BOARDMAX; pos++) { if (!ON_BOARD(pos) || board[pos] == EMPTY) continue; if (!is_worm_origin(pos, pos)) continue; if (board[pos] == OTHER_COLOR(color)) { for (k = 0; k < MAX_TACTICAL_POINTS; k++) { if (worm[pos].attack_codes[k] != 0) add_attack_move(worm[pos].attack_points[k], pos, worm[pos].attack_codes[k]); if (worm[pos].attack_threat_codes[k] != 0) add_attack_threat_move(worm[pos].attack_threat_points[k], pos, worm[pos].attack_threat_codes[k]); } } if (board[pos] == color) { for (k = 0; k < MAX_TACTICAL_POINTS; k++) { if (worm[pos].defense_codes[k] != 0) add_defense_move(worm[pos].defense_points[k], pos, worm[pos].defense_codes[k]); if (worm[pos].defense_threat_codes[k] != 0) add_defense_threat_move(worm[pos].defense_threat_points[k], pos, worm[pos].defense_threat_codes[k]); } } } }
false
false
false
false
false
0
pki_key_ecdsa_to_nid(EC_KEY *k) { const EC_GROUP *g = EC_KEY_get0_group(k); int nid; nid = EC_GROUP_get_curve_name(g); if (nid) { return nid; } return -1; }
false
false
false
false
false
0
eof_callback() { if(layer_ == LAYER_STREAM) return false; if(error_occurred_) return true; return (bool)feof(file_); }
false
false
false
false
false
0
PySequence_SetSlice(PyObject *s, Py_ssize_t i1, Py_ssize_t i2, PyObject *o) { PyMappingMethods *mp; if (s == NULL) { null_error(); return -1; } mp = s->ob_type->tp_as_mapping; if (mp && mp->mp_ass_subscript) { int res; PyObject *slice = _PySlice_FromIndices(i1, i2); if (!slice) return -1; res = mp->mp_ass_subscript(s, slice, o); Py_DECREF(slice); return res; } type_error("'%.200s' object doesn't support slice assignment", s); return -1; }
false
false
false
false
false
0
btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder, int flush, struct block_device **bdev, struct buffer_head **bh) { int ret; *bdev = blkdev_get_by_path(device_path, flags, holder); if (IS_ERR(*bdev)) { ret = PTR_ERR(*bdev); goto error; } if (flush) filemap_write_and_wait((*bdev)->bd_inode->i_mapping); ret = set_blocksize(*bdev, 4096); if (ret) { blkdev_put(*bdev, flags); goto error; } invalidate_bdev(*bdev); *bh = btrfs_read_dev_super(*bdev); if (IS_ERR(*bh)) { ret = PTR_ERR(*bh); blkdev_put(*bdev, flags); goto error; } return 0; error: *bdev = NULL; *bh = NULL; return ret; }
false
false
false
false
false
0
hsep_get_static_str(int row, int column) { const char *ret = NULL; hsep_triple hsep_table[G_N_ELEMENTS(hsep_global_table)]; hsep_triple other[1]; uint64 v; hsep_get_global_table(hsep_table, G_N_ELEMENTS(hsep_table)); hsep_get_non_hsep_triple(other); switch (column) { case HSEP_IDX_NODES: { static char buf[UINT64_DEC_BUFLEN]; v = hsep_table[row][HSEP_IDX_NODES] + other[0][HSEP_IDX_NODES]; uint64_to_string_buf(v, buf, sizeof buf); ret = buf; } break; case HSEP_IDX_FILES: { static char buf[UINT64_DEC_BUFLEN]; v = hsep_table[row][HSEP_IDX_FILES] + other[0][HSEP_IDX_FILES]; uint64_to_string_buf(v, buf, sizeof buf); ret = buf; } break; case HSEP_IDX_KIB: { static char buf[UINT64_DEC_BUFLEN]; /* Make a copy because concurrent usage of short_kb_size() * could be hard to discover. */ v = hsep_table[row][HSEP_IDX_KIB] + other[0][HSEP_IDX_KIB]; g_strlcpy(buf, short_kb_size(v, GNET_PROPERTY(display_metric_units)), sizeof buf); ret = buf; } break; } g_assert(ret != NULL); return ret; }
false
false
false
false
false
0
position(int yy) { if (yy < 0) yy = 0; if (yy == position_) return; position_ = yy; if (yy != real_position_) redraw_lines(); }
false
false
false
false
false
0
kvm_lapic_enable_pv_eoi(struct kvm_vcpu *vcpu, u64 data) { u64 addr = data & ~KVM_MSR_ENABLED; if (!IS_ALIGNED(addr, 4)) return 1; vcpu->arch.pv_eoi.msr_val = data; if (!pv_eoi_enabled(vcpu)) return 0; return kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.pv_eoi.data, addr, sizeof(u8)); }
false
false
false
false
false
0
input_pad_gtk_window_set_priv (InputPadGtkWindow *window) { InputPadGtkWindowPrivate *priv = INPUT_PAD_GTK_WINDOW_GET_PRIVATE (window); GdkColor color; if (priv->group == NULL) { priv->group = input_pad_group_parse_all_files (NULL, NULL); } priv->char_button_sensitive = TRUE; if (!gdk_color_parse ("gray", &color)) { color.red = color.green = color.blue = 0xffff; } #if !GTK_CHECK_VERSION(2, 90, 0) gdk_colormap_alloc_color (gdk_colormap_get_system(), &color, FALSE, TRUE); #endif priv->color_gray = gdk_color_copy (&color); if (kbdui_name) { priv->kbdui_name = g_strdup (kbdui_name); } window->priv = priv; }
false
false
false
false
false
0
glkputa_confirm(GLKDisplay *fd, int len, unsigned char *str) { int i; int retval; retval = 0; /* Assume Success */ for (i = len; !retval && i; ++str, --i) { retval = glkput_confirm(fd, *str); } return(retval); }
false
false
false
false
false
0
ParseFieldOptions(FieldDescriptorProto* field, const LocationRecorder& field_location) { if (!LookingAt("[")) return true; LocationRecorder location(field_location, FieldDescriptorProto::kOptionsFieldNumber); DO(Consume("[")); // Parse field options. do { if (LookingAt("default")) { // We intentionally pass field_location rather than location here, since // the default value is not actually an option. DO(ParseDefaultAssignment(field, field_location)); } else { DO(ParseOptionAssignment(field->mutable_options(), location)); } } while (TryConsume(",")); DO(Consume("]")); return true; }
false
false
false
false
false
0
pdf14_copy_planes(gx_device * dev, const byte * data, int data_x, int raster, gx_bitmap_id id, int x, int y, int w, int h, int plane_height) { pdf14_device *pdev = (pdf14_device *)dev; #if RAW_DUMP pdf14_ctx *ctx = pdev->ctx; #endif pdf14_buf *buf = pdev->ctx->stack; int num_planes = dev->color_info.num_components; byte *dptr = (byte *)data + data_x; int yinc, xinc, pi; gx_drawing_color dcolor; int code = 0; fit_fill_xywh(dev, x, y, w, h); if (w <= 0 || h <= 0) return 0; dcolor.type = gx_dc_type_devn; /* Because of the complexity of the blending and my desire to finish this planar sep device work, I am going to make this a series of rect fills. ToDo: optimize this for more efficient planar operation. It would be interesting to use the put_image procedure. */ for (yinc = 0; yinc < h; yinc++) { for (xinc = 0; xinc < w; xinc++) { for (pi = 0; pi < num_planes; pi++) { dcolor.colors.devn.values[pi] = *(dptr + plane_height * raster * pi) << 8; } if (buf->knockout) code = pdf14_mark_fill_rectangle_ko_simple(dev, x + xinc, y + yinc, 1, 1, 0, &dcolor, true); else code = pdf14_mark_fill_rectangle(dev, x + xinc, y + yinc, 1, 1, 0, &dcolor, true); dptr++; } dptr = (byte *)data + raster * yinc + data_x; } return code; }
false
false
false
false
false
0
format4(struct ftio *ftio, struct options *opt) { struct ftver ftv; struct ftencode fte; char *rec; int ret; /* initialize encode struct */ ftencode_init(&fte, 0); /* copy version from io stream */ ftio_get_ver(ftio, &ftv); bcopy(&ftv, &fte.ver, sizeof ftv); /* foreach flow */ while ((rec = ftio_read(ftio))) { retry: ret = fts3rec_pdu_encode(&fte, rec); /* ret == 0 then send and clear out buffer * ret > 0 then encode another * ret < 0 then this encoding failed, send and clear out buffer */ if (ret <= 0) { /* convert pdu to network byte order */ #if BYTE_ORDER == LITTLE_ENDIAN ftpdu_swap(fte.buf_enc, BYTE_ORDER); #endif /* BYTE_ORDER == LITTLE_ENDIAN */ if (fwrite(&fte.buf, fte.buf_size, 1, stdout) != 1) fterr_err(1, "fwrite()"); /* reset encode buffer */ ftencode_reset(&fte); /* if ret < 0 then the current record was not encoded */ if (ret < 0) goto retry; } ++opt->records; } /* any left over? */ if (fte.buf_size) { /* convert pdu to network byte order */ ftpdu_swap(fte.buf_enc, BYTE_ORDER); if (fwrite(&fte.buf, fte.buf_size, 1, stdout) != 1) fterr_err(1, "fwrite()"); } /* fte.buf_size */ return 0; }
false
false
false
false
false
0
Copy () { OverlayComp* dest = (_group == nil) ? nil : (OverlayComp*) _group->Copy(); Command* copy = new OvGroupCmd(CopyControlInfo(), dest); InitCopy(copy); return copy; }
false
false
false
false
false
0
ast_dial_option_global_disable(struct ast_dial *dial, enum ast_dial_option option) { /* If the option is not enabled, return failure */ if (!dial->options[option]) { return -1; } /* Execute callback of option to disable if it exists */ if (option_types[option].disable) option_types[option].disable(dial->options[option]); /* Finally disable option on the structure */ dial->options[option] = NULL; return 0; }
false
false
false
false
false
0
excel_formula_write_NAME_v7 (PolishData *pd, GnmExpr const *expr, XLOpType target_type) { guint8 data [25]; gpointer tmp; unsigned name_idx; memset (data, 0, sizeof data); tmp = g_hash_table_lookup (pd->ewb->names, (gpointer)expr->name.name); g_return_if_fail (tmp != NULL); name_idx = GPOINTER_TO_UINT (tmp); if (expr->name.optional_scope == NULL) { GSF_LE_SET_GUINT8 (data + 0, FORMULA_PTG_NAME + xl_get_op_class (pd, XL_REF, target_type)); GSF_LE_SET_GUINT16 (data + 1, name_idx); ms_biff_put_var_write (pd->ewb->bp, data, 15); } else { int externsheet = (pd->sheet == expr->name.optional_scope) ? (int) (pd->ewb->esheets->len + 1) : expr->name.optional_scope->index_in_wb; guint32 id = ++(pd->ewb->unique_name_id); GSF_LE_SET_GUINT8 (data + 0, FORMULA_PTG_NAME_X + xl_get_op_class (pd, XL_REF, target_type)); GSF_LE_SET_GUINT16 (data + 1, -(externsheet+1)); GSF_LE_SET_GUINT16 (data + 11, name_idx); GSF_LE_SET_GUINT16 (data + 9, 1); /* undocumented marked 'reserved' */ GSF_LE_SET_GUINT16 (data + 19, 0xf); /* undocumented marked 'reserved' */ GSF_LE_SET_GUINT32 (data + 21, id); /* undocumented marked 'reserved' */ ms_biff_put_var_write (pd->ewb->bp, data, 25); } }
false
false
false
false
false
0
wait_till_ready(struct spi_device *spi_nand) { unsigned long deadline; int retval; u8 stat = 0; deadline = jiffies + MAX_WAIT_JIFFIES; do { retval = spinand_read_status(spi_nand, &stat); if (retval < 0) return -1; else if (!(stat & 0x1)) break; cond_resched(); } while (!time_after_eq(jiffies, deadline)); if ((stat & 0x1) == 0) return 0; return -1; }
false
false
false
false
false
0
sieve(int n) { prime.clear(); prime.insert(prime.end(), 1); prime.insert(prime.end(), 2); for (int i = 3; i <= n; i += 2) { bool composite = false; for (simple_vector<int>::const_iterator j = prime.begin(); j != prime.end(); ++j) { if (*j != 1 && i % *j == 0) { composite = true; break; } } if (!composite) prime.insert(prime.end(), i); } }
false
false
false
false
false
0
parallel_transfer_all_new_dbs(DbInfoArr *old_db_arr, DbInfoArr *new_db_arr, char *old_pgdata, char *new_pgdata, char *old_tablespace) { #ifndef WIN32 pid_t child; #else HANDLE child; transfer_thread_arg *new_arg; #endif if (user_opts.jobs <= 1) /* throw_error must be true to allow jobs */ transfer_all_new_dbs(old_db_arr, new_db_arr, old_pgdata, new_pgdata, NULL); else { /* parallel */ #ifdef WIN32 if (thread_handles == NULL) thread_handles = pg_malloc(user_opts.jobs * sizeof(HANDLE)); if (transfer_thread_args == NULL) { int i; transfer_thread_args = pg_malloc(user_opts.jobs * sizeof(transfer_thread_arg *)); /* * For safety and performance, we keep the args allocated during * the entire life of the process, and we don't free the args in a * thread different from the one that allocated it. */ for (i = 0; i < user_opts.jobs; i++) transfer_thread_args[i] = pg_malloc0(sizeof(transfer_thread_arg)); } cur_thread_args = (void **) transfer_thread_args; #endif /* harvest any dead children */ while (reap_child(false) == true) ; /* must we wait for a dead child? */ if (parallel_jobs >= user_opts.jobs) reap_child(true); /* set this before we start the job */ parallel_jobs++; /* Ensure stdio state is quiesced before forking */ fflush(NULL); #ifndef WIN32 child = fork(); if (child == 0) { transfer_all_new_dbs(old_db_arr, new_db_arr, old_pgdata, new_pgdata, old_tablespace); /* if we take another exit path, it will be non-zero */ /* use _exit to skip atexit() functions */ _exit(0); } else if (child < 0) /* fork failed */ pg_fatal("could not create worker process: %s\n", strerror(errno)); #else /* empty array element are always at the end */ new_arg = transfer_thread_args[parallel_jobs - 1]; /* Can only pass one pointer into the function, so use a struct */ new_arg->old_db_arr = old_db_arr; new_arg->new_db_arr = new_db_arr; if (new_arg->old_pgdata) pg_free(new_arg->old_pgdata); new_arg->old_pgdata = pg_strdup(old_pgdata); if (new_arg->new_pgdata) pg_free(new_arg->new_pgdata); new_arg->new_pgdata = pg_strdup(new_pgdata); if (new_arg->old_tablespace) pg_free(new_arg->old_tablespace); new_arg->old_tablespace = old_tablespace ? pg_strdup(old_tablespace) : NULL; child = (HANDLE) _beginthreadex(NULL, 0, (void *) win32_transfer_all_new_dbs, new_arg, 0, NULL); if (child == 0) pg_fatal("could not create worker thread: %s\n", strerror(errno)); thread_handles[parallel_jobs - 1] = child; #endif } return; }
false
false
false
false
false
0
xlsx_find_border (GnmStyle const *style, GPtrArray *styles) { unsigned i; for (i = 0 ; i < styles->len ; i++) { GnmStyle const *old_style = g_ptr_array_index (styles, i); if (style == old_style) return (gint) i; if (gnm_style_is_element_set (style, MSTYLE_BORDER_TOP) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_TOP) || gnm_style_is_element_set (style, MSTYLE_BORDER_BOTTOM) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_BOTTOM) || gnm_style_is_element_set (style, MSTYLE_BORDER_LEFT) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_LEFT) || gnm_style_is_element_set (style, MSTYLE_BORDER_RIGHT) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_RIGHT) || gnm_style_is_element_set (style, MSTYLE_BORDER_REV_DIAGONAL) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_REV_DIAGONAL) || gnm_style_is_element_set (style, MSTYLE_BORDER_DIAGONAL) != gnm_style_is_element_set (old_style, MSTYLE_BORDER_DIAGONAL)) continue; if (gnm_style_get_border (style, MSTYLE_BORDER_TOP) != gnm_style_get_border (old_style, MSTYLE_BORDER_TOP) || gnm_style_get_border (style, MSTYLE_BORDER_BOTTOM) != gnm_style_get_border (old_style, MSTYLE_BORDER_BOTTOM) || gnm_style_get_border (style, MSTYLE_BORDER_LEFT) != gnm_style_get_border (old_style, MSTYLE_BORDER_LEFT) || gnm_style_get_border (style, MSTYLE_BORDER_RIGHT) != gnm_style_get_border (old_style, MSTYLE_BORDER_RIGHT) || gnm_style_get_border (style, MSTYLE_BORDER_REV_DIAGONAL) != gnm_style_get_border (old_style, MSTYLE_BORDER_REV_DIAGONAL) || gnm_style_get_border (style, MSTYLE_BORDER_DIAGONAL) != gnm_style_get_border (old_style, MSTYLE_BORDER_DIAGONAL)) continue; return (gint) i; } return -1; }
false
false
false
false
false
0
main () { int i=0,j=0, N=100; float dt=0.05, t; Raptor player(40,40), Charlie(0,0), Temp; player.vx= 4.0; player.vy= -4.0; player.speed=sqrt(player.vx*player.vx+player.vy*player.vy); //Initial data t=i*dt; cout <<t<<"\t"<<player.x<<"\t"<<player.y<<"\t"<<Charlie.x<<"\t"<<Charlie.y<<endl; // RUN!! for(i=1;i<N;i++){ t=i*dt; Charlie.Track(player); // Charlie.vx=Temp.vx; // Charlie.vy=Temp.vy; player.x+= player.vx*dt; player.y+= player.vy*dt; Charlie.x+= Charlie.vx*dt; Charlie.y+= Charlie.vy*dt; cout <<t<<"\t"<<player.x<<"\t"<<player.y<<"\t"<<Charlie.x<<"\t"<<Charlie.y<<endl; } //cout<<"Player is death, Charlie wins \n"; return 0; }
false
false
false
false
false
0
tree_key_press_event(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, GigoloBrowseNetworkPanel *panel) { if (event->keyval == GDK_Return || event->keyval == GDK_ISO_Enter || event->keyval == GDK_KP_Enter || event->keyval == GDK_space) { mount_share(panel, GIGOLO_BE_MODE_CONNECT); return TRUE; } return FALSE; }
false
false
false
false
false
0
Get_chk_log_entries(int sim_handle, int chk_handle, int num_entries, Output_log_struct *entries) { int i; int isim; int count; Sim_entry_type *sim; int return_status = REG_SUCCESS; if(!entries) return REG_FAILURE; if((isim = Sim_index_from_handle(sim_handle)) != -1){ sim = &(Sim_table.sim[isim]); count = 0; for(i=0; i<sim->Chk_log.num_entries; i++){ if(sim->Chk_log.entry[i].chk_handle == chk_handle){ Get_log_entry_details(&(sim->Params_table), &(sim->Chk_log.entry[i]), &(entries[count])); count++; if (count >= num_entries) break; } } } else{ return_status = REG_FAILURE; } return return_status; }
false
false
false
false
false
0
init_sound() { try { open_sound_device(); configure_sound_device(); sound = true; } catch (SoundError &se) { sound = false; switch (se.code) { case SE_OPENFAIL: g_message("An error occured while opening the sound device\n\t%s", se.description); break; case SE_FRAGFAIL: g_message("An error occured while setting the sound card's fragment size"); g_message("\t%s\nThe requested value was: %x", se.description, se.requested); break; }; } if(sound) load_sounds(); }
false
false
false
false
false
0
may_propagate_copy_into_stmt (gimple dest, tree orig) { tree type_d; tree type_o; /* If the statement is a switch or a single-rhs assignment, then the expression to be replaced by the propagation may be an SSA_NAME. Fortunately, there is an explicit tree for the expression, so we delegate to may_propagate_copy. */ if (gimple_assign_single_p (dest)) return may_propagate_copy (gimple_assign_rhs1 (dest), orig); else if (gimple_code (dest) == GIMPLE_SWITCH) return may_propagate_copy (gimple_switch_index (dest), orig); /* In other cases, the expression is not materialized, so there is no destination to pass to may_propagate_copy. On the other hand, the expression cannot be an SSA_NAME, so the analysis is much simpler. */ if (TREE_CODE (orig) == SSA_NAME && SSA_NAME_OCCURS_IN_ABNORMAL_PHI (orig)) return false; if (is_gimple_assign (dest)) type_d = TREE_TYPE (gimple_assign_lhs (dest)); else if (gimple_code (dest) == GIMPLE_COND) type_d = boolean_type_node; else if (is_gimple_call (dest) && gimple_call_lhs (dest) != NULL_TREE) type_d = TREE_TYPE (gimple_call_lhs (dest)); else gcc_unreachable (); type_o = TREE_TYPE (orig); if (!useless_type_conversion_p (type_d, type_o)) return false; return true; }
false
false
false
false
false
0
gpx_write_common_extensions(const waypoint* waypointp, const char* indent) { if (((opt_humminbirdext || opt_garminext) && (waypointp->depth != 0 || waypointp->temperature != 0)) || (opt_garminext && (waypointp->heartrate != 0 || waypointp->cadence != 0))) { gbfprintf(ofd, "%s<extensions>\n", indent); if (waypointp->depth != 0) { if (opt_humminbirdext) gbfprintf(ofd, "%s <h:depth>%f</h:depth>\n", indent, waypointp->depth*100.0); if (opt_garminext) gbfprintf(ofd, "%s <gpxx:Depth>%f</gpxx:Depth>\n", indent, waypointp->depth); } if (waypointp->temperature != 0) { if (opt_humminbirdext) gbfprintf(ofd, "%s <h:temperature>%f</h:temperature>\n", indent, waypointp->temperature); if (opt_garminext) gbfprintf(ofd, "%s <gpxx:Temperature>%f</gpxx:Temperature>\n", indent, waypointp->temperature); } if (opt_garminext && (waypointp->heartrate != 0 || waypointp->cadence != 0)) { gbfprintf(ofd, "%s <gpxtpx:TrackPointExtension>\n", indent); if (waypointp->heartrate != 0) gbfprintf(ofd, "%s <gpxtpx:hr>%u</gpxtpx:hr>\n", indent, waypointp->heartrate); if (waypointp->cadence != 0) gbfprintf(ofd, "%s <gpxtpx:cad>%u</gpxtpx:cad>\n", indent, waypointp->cadence); gbfprintf(ofd, "%s </gpxtpx:TrackPointExtension>\n", indent); } gbfprintf(ofd, "%s</extensions>\n", indent); } }
false
false
false
false
false
0
format10(struct fmtargs *args) { struct fts3rec_offsets fo; struct fopd32 cur; struct ftver ftv; struct ftchash *ftch; struct ftchash_rec_ip2 ftch_recip2, *ftch_recip2p; struct fopd total; u_int32 hash; char *rec; ftio_get_ver(&args->ftio, &ftv); if (ftio_check_xfield(&args->ftio, FT_XFIELD_DPKTS | FT_XFIELD_DOCTETS | FT_XFIELD_FIRST | FT_XFIELD_LAST | FT_XFIELD_SRCADDR | FT_XFIELD_DSTADDR)) { fterr_warnx("Flow record missing required field for format."); return -1; } fts3rec_compute_offsets(&fo, &ftv); bzero(&total, sizeof total); bzero(&ftch_recip2, sizeof ftch_recip2); if (!(ftch = ftchash_new(65536, sizeof (struct ftchash_rec_ip2), 8, 65536))) { fterr_warnx("ftchash_new(): failed"); return -1; } cur.flows = 1; while ((rec = ftio_read(&args->ftio))) { CUR_GET_PLUS_FLOWS; TOTAL_INC; ftch_recip2.src_addr = *((u_int32*)(rec+fo.srcaddr)); ftch_recip2.dst_addr = *((u_int32*)(rec+fo.dstaddr)); hash = (ftch_recip2.src_addr>>16) ^ (ftch_recip2.src_addr & 0xFFFF) ^ (ftch_recip2.dst_addr>>16) ^ (ftch_recip2.dst_addr & 0xFFFF); if (!(ftch_recip2p = ftchash_update(ftch, &ftch_recip2, hash))) { fterr_warnx("ftch_update(): failed"); ftchash_free(ftch); return -1; } STAT_INCP(ftch_recip2p); } chash_ip2_dump(ftch, args->cc, args->sort_order, args->options, &total); ftchash_free(ftch); return 0; }
false
false
false
false
false
0
__pci_dev_reset(struct pci_dev *dev, int probe) { int rc; might_sleep(); rc = pci_dev_specific_reset(dev, probe); if (rc != -ENOTTY) goto done; rc = pcie_flr(dev, probe); if (rc != -ENOTTY) goto done; rc = pci_af_flr(dev, probe); if (rc != -ENOTTY) goto done; rc = pci_pm_reset(dev, probe); if (rc != -ENOTTY) goto done; rc = pci_dev_reset_slot_function(dev, probe); if (rc != -ENOTTY) goto done; rc = pci_parent_bus_reset(dev, probe); done: return rc; }
false
false
false
false
false
0
rtl_block_ends_with_call_p (basic_block bb) { rtx insn = BB_END (bb); while (!CALL_P (insn) && insn != BB_HEAD (bb) && (keep_with_call_p (insn) || NOTE_P (insn) || DEBUG_INSN_P (insn))) insn = PREV_INSN (insn); return (CALL_P (insn)); }
false
false
false
false
false
0
gst_auto_audio_src_create_element_with_pretty_name (GstAutoAudioSrc * src, GstElementFactory * factory) { GstElement *element; gchar *name, *marker; marker = g_strdup (GST_OBJECT_NAME (factory)); if (g_str_has_suffix (marker, "src")) marker[strlen (marker) - 4] = '\0'; if (g_str_has_prefix (marker, "gst")) g_memmove (marker, marker + 3, strlen (marker + 3) + 1); name = g_strdup_printf ("%s-actual-src-%s", GST_OBJECT_NAME (src), marker); g_free (marker); element = gst_element_factory_create (factory, name); g_free (name); return element; }
false
false
false
false
false
0
init(MEM_ROOT *mem, const char *host_arg, const char *user_arg, const char *proxied_host_arg, const char *proxied_user_arg, bool with_grant_arg) { init ((host_arg && *host_arg) ? strdup_root (mem, host_arg) : NULL, (user_arg && *user_arg) ? strdup_root (mem, user_arg) : NULL, (proxied_host_arg && *proxied_host_arg) ? strdup_root (mem, proxied_host_arg) : NULL, (proxied_user_arg && *proxied_user_arg) ? strdup_root (mem, proxied_user_arg) : NULL, with_grant_arg); }
false
false
false
false
false
0
lad_sm_search_last_mod_use_block(StripMining *sm, Array_table *ldm, int work) { List *li; StripMiningInnerLoop *smil; Block *block, *last; Array_def_use_table_semnode *mod_use, *aduts; int mod_use_entry; int flag; last = NULL; mod_use = NULL; for (li = sm->loops; li != NULL; li = li->next) { smil = SMIL(li->data); block = smil->block; if (work == 2) { mod_use = (Array_def_use_table_semnode *)get_array_mayuse(block); } else if (work == 1) { mod_use = (Array_def_use_table_semnode *)get_array_maymod(block); } mod_use = copy_array_def_use_table_semnode(mod_use); for (aduts = mod_use; aduts != NULL; aduts = aduts->next) { flag = lad_sm_check_entry_strip_mining_cmp(sm->cmp_head, aduts->entry); if (flag == 0) { mod_use_entry = lad_sm_get_csm_ldm_entry_strip_mining_cmp(sm->cmp_head, aduts->entry); if (mod_use_entry == ldm->entry) { last = block; } } } } return last; }
false
false
false
false
false
0
AddChildNode ( XMP_Node * xmpParent, const XML_Node & xmlNode, const XMP_StringPtr value, bool isTopLevel ) { #if 0 cout << "AddChildNode, parent = " << xmpParent->name << ", child = " << xmlNode.name; cout << ", value = \"" << value << '"'; if ( isTopLevel ) cout << ", top level"; cout << endl; #endif if ( xmlNode.ns.empty() ) { XMP_Throw ( "XML namespace required for all elements and attributes", kXMPErr_BadRDF ); } XMP_StringPtr childName = xmlNode.name.c_str(); const bool isArrayItem = (xmlNode.name == "rdf:li"); const bool isValueNode = (xmlNode.name == "rdf:value"); XMP_OptionBits childOptions = 0; if ( isTopLevel ) { // Lookup the schema node, adjust the XMP parent pointer. XMP_Assert ( xmpParent->parent == 0 ); // Incoming parent must be the tree root. XMP_Node * schemaNode = FindSchemaNode ( xmpParent, xmlNode.ns.c_str(), kXMP_CreateNodes ); if ( schemaNode->options & kXMP_NewImplicitNode ) schemaNode->options ^= kXMP_NewImplicitNode; // Clear the implicit node bit. // *** Should use "opt &= ~flag" (no conditional), need runtime check for proper 32 bit code. xmpParent = schemaNode; // If this is an alias set the isAlias flag in the node and the hasAliases flag in the tree. if ( sRegisteredAliasMap->find ( xmlNode.name ) != sRegisteredAliasMap->end() ) { childOptions |= kXMP_PropIsAlias; schemaNode->parent->options |= kXMP_PropHasAliases; } } // Make sure that this is not a duplicate of a named node. if ( ! (isArrayItem | isValueNode) ) { if ( FindChildNode ( xmpParent, childName, kXMP_ExistingOnly ) != 0 ) { XMP_Throw ( "Duplicate property or field node", kXMPErr_BadXMP ); } } // Add the new child to the XMP parent node. XMP_Node * newChild = new XMP_Node ( xmpParent, childName, value, childOptions ); if ( (! isValueNode) || xmpParent->children.empty() ) { xmpParent->children.push_back ( newChild ); } else { xmpParent->children.insert ( xmpParent->children.begin(), newChild ); } if ( isValueNode ) { if ( isTopLevel || (! (xmpParent->options & kXMP_PropValueIsStruct)) ) XMP_Throw ( "Misplaced rdf:value element", kXMPErr_BadRDF ); xmpParent->options |= kRDF_HasValueElem; } if ( isArrayItem ) { if ( ! (xmpParent->options & kXMP_PropValueIsArray) ) XMP_Throw ( "Misplaced rdf:li element", kXMPErr_BadRDF ); newChild->name = kXMP_ArrayItemName; #if 0 // *** XMP_DebugBuild newChild->_namePtr = newChild->name.c_str(); #endif } return newChild; }
false
false
false
false
false
0
snd_ak4531_mixer(struct snd_card *card, struct snd_ak4531 *_ak4531, struct snd_ak4531 **rak4531) { unsigned int idx; int err; struct snd_ak4531 *ak4531; static struct snd_device_ops ops = { .dev_free = snd_ak4531_dev_free, }; if (snd_BUG_ON(!card || !_ak4531)) return -EINVAL; if (rak4531) *rak4531 = NULL; ak4531 = kzalloc(sizeof(*ak4531), GFP_KERNEL); if (ak4531 == NULL) return -ENOMEM; *ak4531 = *_ak4531; mutex_init(&ak4531->reg_mutex); if ((err = snd_component_add(card, "AK4531")) < 0) { snd_ak4531_free(ak4531); return err; } strcpy(card->mixername, "Asahi Kasei AK4531"); ak4531->write(ak4531, AK4531_RESET, 0x03); /* no RST, PD */ udelay(100); ak4531->write(ak4531, AK4531_CLOCK, 0x00); /* CODEC ADC and CODEC DAC use {LR,B}CLK2 and run off LRCLK2 PLL */ for (idx = 0; idx <= 0x19; idx++) { if (idx == AK4531_RESET || idx == AK4531_CLOCK) continue; ak4531->write(ak4531, idx, ak4531->regs[idx] = snd_ak4531_initial_map[idx]); /* recording source is mixer */ } for (idx = 0; idx < ARRAY_SIZE(snd_ak4531_controls); idx++) { if ((err = snd_ctl_add(card, snd_ctl_new1(&snd_ak4531_controls[idx], ak4531))) < 0) { snd_ak4531_free(ak4531); return err; } } snd_ak4531_proc_init(card, ak4531); if ((err = snd_device_new(card, SNDRV_DEV_CODEC, ak4531, &ops)) < 0) { snd_ak4531_free(ak4531); return err; } #if 0 snd_ak4531_dump(ak4531); #endif if (rak4531) *rak4531 = ak4531; return 0; }
false
true
false
false
false
1
DLM_QueueCheck( CString nick, CString hubname, CString hubhost, CString remotename, CString localname, CString localpath, CString localrootpath, eltMedium, ulonglong size, CString tth ) { m_pDownloadQueue->pQueueMutex->Lock(); // this should really be fixed globally if ( tth.Left(4).ToUpper() == "TTH:" ) { tth = tth.Mid(4); } CDir dir; CString sfile; int res = 0; DCTransferQueueObject * TransferObject; DCTransferFileObject * TransferFileObject = 0; if ( (TransferObject = m_pDownloadQueue->GetUserTransferObject( nick, hubname, hubhost )) != 0 ) { if ( (TransferFileObject = m_pDownloadQueue->GetUserFileObject( nick, hubname, hubhost, remotename )) != 0 ) { res = 1; } } // check if a local file allready exist if ( (res == 0) && (remotename != DC_USER_FILELIST) ) { if ( localrootpath.IsEmpty() ) { sfile = CConfig::Instance()->GetDownloadFolder(); } else { sfile = localrootpath; } localpath = localpath.Replace(':',""); localname = localname.Replace(':',""); sfile += '/'; sfile += localpath; sfile += '/'; sfile += localname; sfile = CDir::SimplePath(sfile); DCFileChunkObject * FileChunkObject; m_pDownloadQueue->pChunksMutex->Lock(); if ( m_pDownloadQueue->pChunkList->Get( sfile, &FileChunkObject ) == 0 ) { // allow manual addition of non-TTH sources to files with TTHs // and allow addition of TTH sources to files with no TTH if ( ((tth.IsEmpty() || FileChunkObject->m_sHash.IsEmpty()) && (FileChunkObject->m_nSize == size)) || (FileChunkObject->m_sHash == tth) ) { if ( FileChunkObject->m_bMulti ) { res = 2; } else { res = 3; } } else { res = 4; } } m_pDownloadQueue->pChunksMutex->UnLock(); } m_pDownloadQueue->pQueueMutex->UnLock(); return res; }
false
false
false
false
false
0
GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target, ImportPropertyMap const& properties, const std::set<std::string>& importedLocations) { // Construct the imported target name. std::string targetName = this->Namespace; targetName += target->GetExportName(); os << "list(APPEND _IMPORT_CHECK_TARGETS " << targetName << " )\n" "list(APPEND _IMPORT_CHECK_FILES_FOR_" << targetName << " "; for(std::set<std::string>::const_iterator li = importedLocations.begin(); li != importedLocations.end(); ++li) { ImportPropertyMap::const_iterator pi = properties.find(*li); if (pi != properties.end()) { os << "\"" << pi->second << "\" "; } } os << ")\n\n"; }
false
false
false
false
false
0
anthy_input_move(struct anthy_input_context* ictx, int lr) { switch (ictx->state) { case ANTHY_INPUT_ST_OFF: break; case ANTHY_INPUT_ST_NONE: break; case ANTHY_INPUT_ST_EDIT: cmd_move_cursor(ictx, lr); break; case ANTHY_INPUT_ST_CONV: cmd_move_selection(ictx, lr); break; case ANTHY_INPUT_ST_CSEG: cmd_unhiragana_candidate(ictx); leave_cseg_state(ictx); enter_conv_state_noinit(ictx); cmd_move_selection(ictx, lr); break; } }
false
false
false
false
false
0
parseLimitLine(char *line) { char *value = next_field(&line); if (!value) { _output->setError(RESPONSE_CODE_INVALID_HEADER, "Header Limit: missing value"); } else { int limit = atoi(value); if (!isdigit(value[0]) || limit < 0) _output->setError(RESPONSE_CODE_INVALID_HEADER, "Invalid value for Limit: must be non-negative integer"); else _limit = limit; } }
false
false
false
false
false
0
simple_method_enter (MonoProfiler *prof, MonoMethod *method) { static int guithread; static gboolean guithread_set = FALSE; MonoClass* klass; const char* name_space; klass = mono_method_get_class (method); name_space = mono_class_get_namespace (klass); int current_thread_id = (int) pthread_self(); if (strstr (name_space, "Gtk") == name_space || strstr (name_space, "Gdk") == name_space) { const char* method_name = mono_method_get_name (method); const char* klass_name = mono_class_get_name (klass); if (!guithread_set && strcmp (klass_name, "Application")==0 && strcmp (method_name, "Init")==0) { guithread_set = TRUE; guithread = current_thread_id; printf ("*** GUI THREAD INITIALIZED: %u\n", guithread); fflush (NULL); return; } if (!guithread_set) { return; } if (current_thread_id != guithread && !(strcmp (klass_name, "Object")==0 && strcmp (method_name, "Dispose")==0) && !(strcmp (klass_name, "Widget")==0 && strcmp (method_name, "Dispose")==0) && !(strcmp (klass_name, "Application")==0 && strcmp (method_name, "Invoke")==0) && !(strcmp (method_name, "Finalize")==0) && !(strcmp (method_name, "get_NativeDestroyHandler")==0) && !(strcmp (method_name, "remove_InternalDestroyed")==0) && !(strcmp (method_name, "remove_Destroyed")==0) ) { printf ("*** GTK CALL NOT IN GUI THREAD: %s.%s\n", klass_name, method_name); mono_stack_walk_no_il (stack_walk_fn, NULL); fflush (NULL); } } }
false
false
false
false
false
0
ili922x_read(struct spi_device *spi, u8 reg, u16 *rx) { struct spi_message msg; struct spi_transfer xfer_regindex, xfer_regvalue; unsigned char tbuf[CMD_BUFSIZE]; unsigned char rbuf[CMD_BUFSIZE]; int ret, len = 0, send_bytes; memset(&xfer_regindex, 0, sizeof(struct spi_transfer)); memset(&xfer_regvalue, 0, sizeof(struct spi_transfer)); spi_message_init(&msg); xfer_regindex.tx_buf = tbuf; xfer_regindex.rx_buf = rbuf; xfer_regindex.cs_change = 1; CHECK_FREQ_REG(spi, &xfer_regindex); tbuf[0] = set_tx_byte(START_BYTE(ili922x_id, START_RS_INDEX, START_RW_WRITE)); tbuf[1] = set_tx_byte(0); tbuf[2] = set_tx_byte(reg); xfer_regindex.bits_per_word = 8; len = xfer_regindex.len = 3; spi_message_add_tail(&xfer_regindex, &msg); send_bytes = len; tbuf[len++] = set_tx_byte(START_BYTE(ili922x_id, START_RS_REG, START_RW_READ)); tbuf[len++] = set_tx_byte(0); tbuf[len] = set_tx_byte(0); xfer_regvalue.cs_change = 1; xfer_regvalue.len = 3; xfer_regvalue.tx_buf = &tbuf[send_bytes]; xfer_regvalue.rx_buf = &rbuf[send_bytes]; CHECK_FREQ_REG(spi, &xfer_regvalue); spi_message_add_tail(&xfer_regvalue, &msg); ret = spi_sync(spi, &msg); if (ret < 0) { dev_dbg(&spi->dev, "Error sending SPI message 0x%x", ret); return ret; } *rx = (rbuf[1 + send_bytes] << 8) + rbuf[2 + send_bytes]; return 0; }
true
true
false
false
false
1
GetStandbyLimitTime(void) { TimestampTz rtime; bool fromStream; /* * The cutoff time is the last WAL data receipt time plus the appropriate * delay variable. Delay of -1 means wait forever. */ GetXLogReceiptTime(&rtime, &fromStream); if (fromStream) { if (max_standby_streaming_delay < 0) return 0; /* wait forever */ return TimestampTzPlusMilliseconds(rtime, max_standby_streaming_delay); } else { if (max_standby_archive_delay < 0) return 0; /* wait forever */ return TimestampTzPlusMilliseconds(rtime, max_standby_archive_delay); } }
false
false
false
false
false
0
time_stamp(uschar *timebuf, int size) { int diff_hour, diff_min, len; time_t now = time(NULL); struct tm *gmt; struct tm local; memcpy(&local, localtime(&now), sizeof(struct tm)); gmt = gmtime(&now); diff_min = 60*(local.tm_hour - gmt->tm_hour) + local.tm_min - gmt->tm_min; if (local.tm_year != gmt->tm_year) diff_min += (local.tm_year > gmt->tm_year)? 1440 : -1440; else if (local.tm_yday != gmt->tm_yday) diff_min += (local.tm_yday > gmt->tm_yday)? 1440 : -1440; diff_hour = diff_min/60; diff_min = abs(diff_min - diff_hour*60); len = Ustrftime(timebuf, size, "%a, ", &local); (void) sprintf(CS timebuf + len, "%02d ", local.tm_mday); len += Ustrlen(timebuf + len); len += Ustrftime(timebuf + len, size - len, "%b %Y %H:%M:%S", &local); (void) sprintf(CS timebuf + len, " %+03d%02d", diff_hour, diff_min); return timebuf; }
false
false
false
false
false
0
AB_ImExporterYN__ReadLNE_LNS(AB_IMEXPORTER *ie, AB_IMEXPORTER_ACCOUNTINFO *ai, GWEN_XMLNODE *node) { GWEN_XMLNODE *n; n=GWEN_XMLNode_FindFirstTag(node, "SG6", 0, 0); if (n) { AB_TRANSACTION *t; GWEN_XMLNODE *nn; GWEN_TIME *ti=0; AB_VALUE *val=0; t=AB_Transaction_new(); /* get date */ nn=GWEN_XMLNode_FindFirstTag(n, "DTM", 0, 0); if (nn) ti=AB_ImExporterYN__ReadTime(ie, nn, 209); AB_Transaction_SetValutaDate(t, ti); GWEN_Time_free(ti); ti=0; /* read amount */ nn=GWEN_XMLNode_FindFirstTag(n, "MOA", 0, 0); if (nn) { /* Gutschrift */ val=AB_ImExporterYN__ReadValue(ie, nn, 210); if (val) { if (AB_Value_IsZero(val)) { AB_Value_free(val); val=NULL; } } if (val==NULL) { val=AB_ImExporterYN__ReadValue(ie, nn, 211); if (val) AB_Value_Negate(val); } } if (val==NULL) val=AB_Value_new(); AB_Value_SetCurrency(val, AB_ImExporterAccountInfo_GetCurrency(ai)); AB_Transaction_SetValue(t, val); AB_Value_free(val); val=0; /* read purpose */ nn=GWEN_XMLNode_GetNodeByXPath(n, "FTX/C108", GWEN_PATH_FLAGS_NAMEMUSTEXIST); if (nn) { GWEN_XMLNODE *nnn; nnn=GWEN_XMLNode_FindFirstTag(nn, "D_4440", 0, 0); while(nnn) { GWEN_XMLNODE *nData; nData=GWEN_XMLNode_GetFirstData(nnn); if (nData) { const char *s; s=GWEN_XMLNode_GetData(nData); if (s) { GWEN_BUFFER *xbuf; xbuf=GWEN_Buffer_new(0, 256, 0, 1); AB_ImExporter_Iso8859_1ToUtf8(s, strlen(s), xbuf); AB_Transaction_AddPurpose(t, GWEN_Buffer_GetStart(xbuf), 0); GWEN_Buffer_free(xbuf); } } nnn=GWEN_XMLNode_FindNextTag(nnn, "D_4440", 0, 0); } } return t; } return 0; }
false
false
false
false
false
0
r852_update_media_status(struct r852_device *dev) { uint8_t reg; unsigned long flags; int readonly; spin_lock_irqsave(&dev->irqlock, flags); if (!dev->card_detected) { message("card removed"); spin_unlock_irqrestore(&dev->irqlock, flags); return ; } readonly = r852_read_reg(dev, R852_CARD_STA) & R852_CARD_STA_RO; reg = r852_read_reg(dev, R852_DMA_CAP); dev->sm = (reg & (R852_DMA1 | R852_DMA2)) && (reg & R852_SMBIT); message("detected %s %s card in slot", dev->sm ? "SmartMedia" : "xD", readonly ? "readonly" : "writeable"); dev->readonly = readonly; spin_unlock_irqrestore(&dev->irqlock, flags); }
false
false
false
false
false
0
validate ( QString &str, int &pos ) const { str = str.toLower(); for(int i = 0; i < pos; i++) { if( ! ((str[i] >= 'a' && str[i] <= 'f') || (str[i] >= '0' && str[i] <= '9') ) && ! (i == 1 && str[i] == 'x' ) ) { return Invalid; } } return Acceptable; }
false
false
false
false
false
0
report_verbose(const bench_problem *p, double *t, int st) { struct stats s; char bmin[64], bmax[64], bavg[64], bmedian[64], btmin[64]; char bsetup[64]; int copyp = tensor_sz(p->sz) == 1; mkstat(t, st, &s); sprintf_time(s.min, bmin, 64); sprintf_time(s.max, bmax, 64); sprintf_time(s.avg, bavg, 64); sprintf_time(s.median, bmedian, 64); sprintf_time(time_min, btmin, 64); sprintf_time(p->setup_time, bsetup, 64); ovtpvt("Problem: %s, setup: %s, time: %s, %s: %.5g\n", p->pstring, bsetup, bmin, copyp ? "fp-move/us" : "``mflops''", mflops(p, s.min)); if (verbose) { ovtpvt("Took %d measurements for at least %s each.\n", st, btmin); ovtpvt("Time: min %s, max %s, avg %s, median %s\n", bmin, bmax, bavg, bmedian); } }
false
false
false
false
false
0
queue (dump_info_p di, const_tree t, int flags) { dump_queue_p dq; dump_node_info_p dni; unsigned int index; /* Assign the next available index to T. */ index = ++di->index; /* Obtain a new queue node. */ if (di->free_list) { dq = di->free_list; di->free_list = dq->next; } else dq = XNEW (struct dump_queue); /* Create a new entry in the splay-tree. */ dni = XNEW (struct dump_node_info); dni->index = index; dni->binfo_p = ((flags & DUMP_BINFO) != 0); dq->node = splay_tree_insert (di->nodes, (splay_tree_key) t, (splay_tree_value) dni); /* Add it to the end of the queue. */ dq->next = 0; if (!di->queue_end) di->queue = dq; else di->queue_end->next = dq; di->queue_end = dq; /* Return the index. */ return index; }
false
false
false
false
false
0
lldp_mgmt_addr_tlv_print(const u_char *pptr, u_int len) { u_int8_t mgmt_addr_len, intf_num_subtype, oid_len; const u_char *tptr; u_int tlen; tlen = len; tptr = pptr; mgmt_addr_len = *tptr++; tlen--; if (tlen < mgmt_addr_len) { return 0; } printf("\n\t Management Address length %u, %s", mgmt_addr_len, lldp_network_addr_print(tptr)); tptr += mgmt_addr_len; tlen -= mgmt_addr_len; if (tlen < LLDP_INTF_NUM_LEN) { return 0; } intf_num_subtype = *tptr; printf("\n\t %s Interface Numbering (%u): %u", tok2str(lldp_intf_numb_subtype_values, "Unknown", intf_num_subtype), intf_num_subtype, EXTRACT_32BITS(tptr+1)); tptr += LLDP_INTF_NUM_LEN; tlen -= LLDP_INTF_NUM_LEN; /* * The OID is optional. */ if (tlen) { oid_len = *tptr; if (oid_len) { printf("\n\t OID length %u", oid_len); safeputs((const char *)tptr+1, oid_len); } } return 1; }
false
false
false
false
false
0
tracing_record_cmdline(struct task_struct *tsk) { if (atomic_read(&trace_record_cmdline_disabled) || !tracing_is_on()) return; if (!__this_cpu_read(trace_cmdline_save)) return; if (trace_save_cmdline(tsk)) __this_cpu_write(trace_cmdline_save, false); }
false
false
false
false
false
0
count_map_constraints(struct isl_sched_graph *graph, struct isl_sched_edge *edge, __isl_take isl_map *map, int *n_eq, int *n_ineq, int carry, int use_coincidence) { isl_basic_set *coef; int f = edge_multiplicity(edge, carry, use_coincidence); if (f == 0) { isl_map_free(map); return 0; } if (edge->src == edge->dst) coef = intra_coefficients(graph, map); else coef = inter_coefficients(graph, map); if (!coef) return -1; *n_eq += f * coef->n_eq; *n_ineq += f * coef->n_ineq; isl_basic_set_free(coef); return 0; }
false
false
false
false
false
0
ocfs2_read_blocks_sync(struct ocfs2_super *osb, u64 block, unsigned int nr, struct buffer_head *bhs[]) { int status = 0; unsigned int i; struct buffer_head *bh; trace_ocfs2_read_blocks_sync((unsigned long long)block, nr); if (!nr) goto bail; for (i = 0 ; i < nr ; i++) { if (bhs[i] == NULL) { bhs[i] = sb_getblk(osb->sb, block++); if (bhs[i] == NULL) { status = -ENOMEM; mlog_errno(status); goto bail; } } bh = bhs[i]; if (buffer_jbd(bh)) { trace_ocfs2_read_blocks_sync_jbd( (unsigned long long)bh->b_blocknr); continue; } if (buffer_dirty(bh)) { /* This should probably be a BUG, or * at least return an error. */ mlog(ML_ERROR, "trying to sync read a dirty " "buffer! (blocknr = %llu), skipping\n", (unsigned long long)bh->b_blocknr); continue; } lock_buffer(bh); if (buffer_jbd(bh)) { mlog(ML_ERROR, "block %llu had the JBD bit set " "while I was in lock_buffer!", (unsigned long long)bh->b_blocknr); BUG(); } clear_buffer_uptodate(bh); get_bh(bh); /* for end_buffer_read_sync() */ bh->b_end_io = end_buffer_read_sync; submit_bh(READ, bh); } for (i = nr; i > 0; i--) { bh = bhs[i - 1]; /* No need to wait on the buffer if it's managed by JBD. */ if (!buffer_jbd(bh)) wait_on_buffer(bh); if (!buffer_uptodate(bh)) { /* Status won't be cleared from here on out, * so we can safely record this and loop back * to cleanup the other buffers. */ status = -EIO; put_bh(bh); bhs[i - 1] = NULL; } } bail: return status; }
false
false
false
false
false
0
dump_kern_db(FILE *fp, int to_hist) { struct nstat_ent *n, *h; const char *eol = "\n"; h = hist_db; if (json_output) fprintf(fp, "{ \"%s\":{", info_source); else fprintf(fp, "#%s\n", info_source); for (n=kern_db; n; n=n->next) { unsigned long long val = n->val; if (!dump_zeros && !val && !n->rate) continue; if (!match(n->id)) { struct nstat_ent *h1; if (!to_hist) continue; for (h1 = h; h1; h1 = h1->next) { if (strcmp(h1->id, n->id) == 0) { val = h1->val; h = h1->next; break; } } } if (json_output) { fprintf(fp, "%s \"%s\":%llu", eol, n->id, val); eol = ",\n"; } else fprintf(fp, "%-32s%-16llu%6.1f\n", n->id, val, n->rate); } if (json_output) fprintf(fp, "\n} }\n"); }
false
false
false
false
false
0
drsuapi_dissect_DsReplicaCoursor3Ctr(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *parent_tree, dcerpc_info *di _U_, guint8 *drep _U_, int hf_index, guint32 param _U_) { proto_item *item=NULL; proto_tree *tree=NULL; int old_offset; ALIGN_TO_8_BYTES; old_offset=offset; if(parent_tree){ item=proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, ENC_NA); tree=proto_item_add_subtree(item, ett_drsuapi_DsReplicaCoursor3Ctr); } offset=drsuapi_dissect_DsReplicaCoursor3Ctr_count(tvb, offset, pinfo, tree, di, drep); offset=drsuapi_dissect_DsReplicaCoursor3Ctr_enumeration_context(tvb, offset, pinfo, tree, di, drep); offset=ucarray_drsuapi_dissect_DsReplicaCoursor3Ctr_array(tvb, offset, pinfo, tree, di, drep); proto_item_set_len(item, offset-old_offset); return offset; }
false
false
false
false
false
0
ex_spellinfo(eap) exarg_T *eap; { int lpi; langp_T *lp; char_u *p; if (no_spell_checking(curwin)) return; msg_start(); for (lpi = 0; lpi < curbuf->b_langp.ga_len && !got_int; ++lpi) { lp = LANGP_ENTRY(curbuf->b_langp, lpi); msg_puts((char_u *)"file: "); msg_puts(lp->lp_slang->sl_fname); msg_putchar('\n'); p = lp->lp_slang->sl_info; if (p != NULL) { msg_puts(p); msg_putchar('\n'); } } msg_end(); }
false
false
false
false
false
0
client_player_each(void (*callback)(const client_player_t *player, void *opaque), void *opaque) { for (int n = 0; n < MAXPLAYERS; n++) { const client_player_t *player = &players[n]; if (!PLAYER_USED(player)) continue; callback(player, opaque); } }
false
false
false
false
false
0
get_ups_statuscode() { BYTE length; riello_init_serial(); length = riello_prepare_rc(&bufOut[0], gpser_error_control); if (ser_send_buf(upsfd, bufOut, length) == 0) { upsdebugx (3, "Communication error while writing to port"); return -1; } riello_serialcomm(&bufIn[0], DEV_RIELLOGPSER); if (!wait_packet && foundbadcrc) { upsdebugx (3, "Get statuscode Ko: bad CRC or Checksum"); return 1; } if (!wait_packet && foundnak) { upsdebugx (3, "Get statuscode Ko: command not supported"); return 1; } upsdebugx (3, "Get statuscode Ok: received byte %u", buf_ptr_length); riello_parse_rc(&bufIn[0], &DevData); return 0; }
false
false
false
false
false
0
pass(char *passwd) { int rval; /* some clients insists on sending a password */ if (logged_in && askpasswd == 0){ reply(230, "Password not necessary"); return; } if (logged_in || askpasswd == 0) { reply(503, "Login with USER first."); return; } askpasswd = 0; rval = 1; if (!guest) { /* "ftp" is only account allowed no password */ if (pw == NULL) rval = 1; /* failure below */ #ifdef OTP else if (otp_verify_user (&otp_ctx, passwd) == 0) { rval = 0; } #endif else if((auth_level & AUTH_OTP) == 0) { #ifdef KRB5 rval = krb5_verify(pw, passwd); #endif if (rval) rval = unix_verify_user(pw->pw_name, passwd); } else { #ifdef OTP char *s; if ((s = otp_error(&otp_ctx)) != NULL) lreply(530, "OTP: %s", s); #endif } memset (passwd, 0, strlen(passwd)); /* * If rval == 1, the user failed the authentication * check above. If rval == 0, either Kerberos or * local authentication succeeded. */ if (rval) { char data_addr[256]; if (inet_ntop (his_addr->sa_family, socket_get_address(his_addr), data_addr, sizeof(data_addr)) == NULL) strlcpy (data_addr, "unknown address", sizeof(data_addr)); reply(530, "Login incorrect."); if (logging) syslog(LOG_NOTICE, "FTP LOGIN FAILED FROM %s(%s), %s", remotehost, data_addr, curname); pw = NULL; if (login_attempts++ >= 5) { syslog(LOG_NOTICE, "repeated login failures from %s(%s)", remotehost, data_addr); exit(0); } return; } } if(!do_login(230, passwd)) return; /* Forget all about it... */ end_login(); }
false
false
false
false
false
0
curl_debug_cb(__maybe_unused CURL *handle, curl_infotype type, __maybe_unused char *data, size_t size, void *userdata) { struct pool *pool = (struct pool *)userdata; switch(type) { case CURLINFO_HEADER_IN: case CURLINFO_DATA_IN: case CURLINFO_SSL_DATA_IN: pool->cgminer_pool_stats.net_bytes_received += size; break; case CURLINFO_HEADER_OUT: case CURLINFO_DATA_OUT: case CURLINFO_SSL_DATA_OUT: pool->cgminer_pool_stats.net_bytes_sent += size; break; case CURLINFO_TEXT: default: break; } return 0; }
false
false
false
false
false
0
add_png_text_chunk_string(png_text *chunk, const gchar *key, const gchar *str, gboolean take) { chunk->compression = PNG_TEXT_COMPRESSION_NONE; chunk->key = (char*)key; chunk->text = take ? (char*)str : g_strdup(str); chunk->text_length = strlen(chunk->text); }
false
false
false
false
false
0
compute_data_dependences_for_loop (struct loop *loop, bool compute_self_and_read_read_dependences, VEC (loop_p, heap) **loop_nest, VEC (data_reference_p, heap) **datarefs, VEC (ddr_p, heap) **dependence_relations) { bool res = true; memset (&dependence_stats, 0, sizeof (dependence_stats)); /* If the loop nest is not well formed, or one of the data references is not computable, give up without spending time to compute other dependences. */ if (!loop || !find_loop_nest (loop, loop_nest) || find_data_references_in_loop (loop, datarefs) == chrec_dont_know || !compute_all_dependences (*datarefs, dependence_relations, *loop_nest, compute_self_and_read_read_dependences)) res = false; if (dump_file && (dump_flags & TDF_STATS)) { fprintf (dump_file, "Dependence tester statistics:\n"); fprintf (dump_file, "Number of dependence tests: %d\n", dependence_stats.num_dependence_tests); fprintf (dump_file, "Number of dependence tests classified dependent: %d\n", dependence_stats.num_dependence_dependent); fprintf (dump_file, "Number of dependence tests classified independent: %d\n", dependence_stats.num_dependence_independent); fprintf (dump_file, "Number of undetermined dependence tests: %d\n", dependence_stats.num_dependence_undetermined); fprintf (dump_file, "Number of subscript tests: %d\n", dependence_stats.num_subscript_tests); fprintf (dump_file, "Number of undetermined subscript tests: %d\n", dependence_stats.num_subscript_undetermined); fprintf (dump_file, "Number of same subscript function: %d\n", dependence_stats.num_same_subscript_function); fprintf (dump_file, "Number of ziv tests: %d\n", dependence_stats.num_ziv); fprintf (dump_file, "Number of ziv tests returning dependent: %d\n", dependence_stats.num_ziv_dependent); fprintf (dump_file, "Number of ziv tests returning independent: %d\n", dependence_stats.num_ziv_independent); fprintf (dump_file, "Number of ziv tests unimplemented: %d\n", dependence_stats.num_ziv_unimplemented); fprintf (dump_file, "Number of siv tests: %d\n", dependence_stats.num_siv); fprintf (dump_file, "Number of siv tests returning dependent: %d\n", dependence_stats.num_siv_dependent); fprintf (dump_file, "Number of siv tests returning independent: %d\n", dependence_stats.num_siv_independent); fprintf (dump_file, "Number of siv tests unimplemented: %d\n", dependence_stats.num_siv_unimplemented); fprintf (dump_file, "Number of miv tests: %d\n", dependence_stats.num_miv); fprintf (dump_file, "Number of miv tests returning dependent: %d\n", dependence_stats.num_miv_dependent); fprintf (dump_file, "Number of miv tests returning independent: %d\n", dependence_stats.num_miv_independent); fprintf (dump_file, "Number of miv tests unimplemented: %d\n", dependence_stats.num_miv_unimplemented); } return res; }
false
false
false
false
false
0
eXdbmPathList(DB_ID dbid, char *path) { TDbmListEntry *search; char *found; int ret; /* the database manager must be initialized */ ret = DbmIsInit(); if( ret == -1) return(NULL); /* check the dbid parameter */ if(CheckDbIdent(dbid) == -1) { RaiseError(DBM_WRONG_ID); return(NULL); } /* parse the path string */ search = DbmDbList->dblist[dbid].root; found = strtok(path, ":"); while(found!=NULL) { /* search entryname in list */ search = SearchListEntry (search, found); if(search==NULL) return(NULL); found = strtok(NULL, ":"); } return(search); }
false
false
false
false
false
0