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
inf_communication_central_method_dispose(GObject* object) { InfCommunicationCentralMethod* method; InfCommunicationCentralMethodPrivate* priv; method = INF_COMMUNICATION_CENTRAL_METHOD(object); priv = INF_COMMUNICATION_CENTRAL_METHOD_PRIVATE(method); while(priv->connections != NULL) { inf_communication_method_remove_member( INF_COMMUNICATION_METHOD(method), INF_XML_CONNECTION(priv->connections->data) ); } inf_communication_central_method_set_group(method, NULL); inf_communication_central_method_set_registry(method, NULL); G_OBJECT_CLASS(parent_class)->dispose(object); }
false
false
false
false
false
0
group_add_one(void *closure, struct gfarm_group_info *gi) { gfarm_error_t e = group_info_add(gi); if (e != GFARM_ERR_NO_ERROR) { /* cannot use gi.groupname, since it's freed here */ gflog_warning(GFARM_MSG_1002314, "group_add_one(): %s", gfarm_error_string(e)); } }
false
false
false
false
false
0
_xmlreader_get_relaxNG(char *source, int source_len, int type, xmlRelaxNGValidityErrorFunc error_func, xmlRelaxNGValidityWarningFunc warn_func TSRMLS_DC) { char *valid_file = NULL; xmlRelaxNGParserCtxtPtr parser = NULL; xmlRelaxNGPtr sptr; char resolved_path[MAXPATHLEN + 1]; switch (type) { case XMLREADER_LOAD_FILE: valid_file = _xmlreader_get_valid_file_path(source, resolved_path, MAXPATHLEN TSRMLS_CC); if (!valid_file) { return NULL; } parser = xmlRelaxNGNewParserCtxt(valid_file); break; case XMLREADER_LOAD_STRING: parser = xmlRelaxNGNewMemParserCtxt(source, source_len); /* If loading from memory, we need to set the base directory for the document but it is not apparent how to do that for schema's */ break; default: return NULL; } if (parser == NULL) { return NULL; } if (error_func || warn_func) { xmlRelaxNGSetParserErrors(parser, (xmlRelaxNGValidityErrorFunc) error_func, (xmlRelaxNGValidityWarningFunc) warn_func, parser); } sptr = xmlRelaxNGParse(parser); xmlRelaxNGFreeParserCtxt(parser); return sptr; }
false
false
false
false
false
0
language_untitled_setup_lexer(Language_Provider *lguntitled) { g_return_if_fail(lguntitled); Language_UntitledDetails *lguntitleddet = LANGUAGE_UNTITLED_GET_PRIVATE(lguntitled); gtk_scintilla_clear_document_style (lguntitleddet->sci); /* SCLEX_NULL to select no lexing action */ gtk_scintilla_set_lexer(GTK_SCINTILLA (lguntitleddet->sci), SCLEX_NULL); gtk_scintilla_colourise(lguntitleddet->sci, 0, -1); }
false
false
false
false
false
0
destroy_hash_table(struct hash_table *tbl, void (*delete_obj)(void *)) { struct list_head *head, *next, *tmp; struct hash_entry *entry; int i; for (i = 0; i < tbl->ht_size; i++) { head = &tbl->ht_lists[i]; next = head->next; while (next != head) { tmp = next->next; entry = list_entry(next, struct hash_entry, he_list); if (delete_obj) delete_obj(entry->he_obj); free(entry); next = tmp; } } free(tbl); }
false
false
false
false
false
0
cm_submit_e_save_ca_cookie(struct cm_store_entry *entry, struct cm_submit_state *state) { int status; long delay; const char *msg; char *p; talloc_free(entry->cm_ca_cookie); entry->cm_ca_cookie = NULL; status = cm_subproc_get_exitstatus(entry, state->subproc); if (WIFEXITED(status) && ((WEXITSTATUS(status) == CM_SUBMIT_STATUS_WAIT) || (WEXITSTATUS(status) == CM_SUBMIT_STATUS_WAIT_WITH_DELAY))) { msg = cm_subproc_get_msg(entry, state->subproc, NULL); if ((msg != NULL) && (strlen(msg) > 0)) { if (WEXITSTATUS(status) == CM_SUBMIT_STATUS_WAIT_WITH_DELAY) { delay = strtol(msg, &p, 10); if ((p == NULL) || (strchr("\r\n", *p) == NULL)) { cm_log(1, "Error parsing result: %s.\n", msg); return -1; } state->pvt.delay = delay; msg = p + strspn(p, "\r\n"); } entry->cm_ca_cookie = talloc_strdup(entry, msg); if (entry->cm_ca_cookie == NULL) { cm_log(1, "Out of memory.\n"); return -ENOMEM; } cm_log(1, "Saved cookie.\n"); return 0; } else { cm_log(1, "No cookie.\n"); return -1; } } return -1; }
false
false
false
false
false
0
utf32_decompose_hangul_char(uint32 uc, uint32 *buf) { /* * Take advantage of algorithmic Hangul decomposition to reduce * the size of the lookup table drastically. See also: * * http://www.unicode.org/reports/tr15/#Hangul */ #define T_COUNT 28 #define V_COUNT 21 #define N_COUNT (T_COUNT * V_COUNT) static const uint32 l_base = 0x1100; static const uint32 v_base = 0x1161; static const uint32 t_base = 0x11A7; const uint32 i = uc - UNI_HANGUL_FIRST; uint32 t_mod = i % T_COUNT; buf[0] = l_base + i / N_COUNT; buf[1] = v_base + (i % N_COUNT) / T_COUNT; #undef N_COUNT #undef V_COUNT #undef T_COUNT if (!t_mod) return 2; buf[2] = t_base + t_mod; return 3; }
false
false
false
false
false
0
u_printf_char_handler(const u_printf_stream_handler *handler, void *context, ULocaleBundle *formatBundle, const u_printf_spec_info *info, const ufmt_args *args) { UChar s[U16_MAX_LENGTH+1]; int32_t len = 1, written; unsigned char arg = (unsigned char)(args[0].int64Value); /* convert from default codepage to Unicode */ ufmt_defaultCPToUnicode((const char *)&arg, 2, s, sizeof(s)/sizeof(UChar)); /* Remember that this may be an MBCS character */ if (arg != 0) { len = u_strlen(s); } /* width = minimum # of characters to write */ /* precision = maximum # of characters to write */ /* precision is ignored when handling a char */ written = handler->pad_and_justify(context, info, s, len); return written; }
false
false
false
false
false
0
cvector_add(struct cvector *vector, const char *string) { size_t next = vector->count; if (vector->count == vector->allocated) cvector_resize(vector, vector->allocated + 1); vector->strings[next] = string; vector->count++; }
false
false
false
true
false
1
argify(CHAR16 *buf, UINTN len, CHAR16 **argv) { UINTN i=0, j=0; CHAR16 *p = buf; if (buf == 0) { argv[0] = NULL; return 0; } /* len represents the number of bytes, not the number of 16 bytes chars */ len = len >> 1; /* * Here we use CHAR_NULL as the terminator rather than the length * because it seems like the EFI shell return rather bogus values for it. * Apparently, we are guaranteed to find the '\0' character in the buffer * where the real input arguments stop, so we use it instead. */ for(;;) { while (buf[i] == CHAR_SPACE && buf[i] != CHAR_NULL && i < len) i++; if (buf[i] == CHAR_NULL || i == len) goto end; p = buf+i; i++; while (buf[i] != CHAR_SPACE && buf[i] != CHAR_NULL && i < len) i++; argv[j++] = p; if (buf[i] == CHAR_NULL) goto end; buf[i] = CHAR_NULL; if (i == len) goto end; i++; if (j == MAX_ARGS-1) { ERR_PRT((L"too many arguments (%d) truncating", j)); goto end; } } end: #if 0 if (i != len) { ERR_PRT((L"ignoring trailing %d characters on command line", len-i)); } #endif argv[j] = NULL; return j; }
false
false
false
false
false
0
item_unlink(item *it) { if (it->it_flags & ITEM_LINKED) { it->it_flags &= ~ITEM_LINKED; stats.curr_bytes -= ITEM_ntotal(it); stats.curr_items -= 1; assoc_delete(ITEM_key(it)); item_unlink_q(it); } if (it->refcount == 0) item_free(it); }
false
false
false
false
false
0
lj_ir_emit(jit_State *J) { IRRef ref = lj_ir_nextins(J); IRIns *ir = IR(ref); IROp op = fins->o; ir->prev = J->chain[op]; J->chain[op] = (IRRef1)ref; ir->o = op; ir->op1 = fins->op1; ir->op2 = fins->op2; J->guardemit.irt |= fins->t.irt; return TREF(ref, irt_t((ir->t = fins->t))); }
false
false
false
false
false
0
cmor_have_NetCDF3(void) { char version[50]; int major; strncpy(version,nc_inq_libvers(),50); if (version[0]!='"') return 1; sscanf(version,"%*c%1d%*s",&major); if (major!=3) return 1; return 0; }
false
false
false
false
false
0
cs5530_qc_issue(struct ata_queued_cmd *qc) { struct ata_port *ap = qc->ap; struct ata_device *adev = qc->dev; struct ata_device *prev = ap->private_data; /* See if the DMA settings could be wrong */ if (ata_dma_enabled(adev) && adev != prev && prev != NULL) { /* Maybe, but do the channels match MWDMA/UDMA ? */ if ((ata_using_udma(adev) && !ata_using_udma(prev)) || (ata_using_udma(prev) && !ata_using_udma(adev))) /* Switch the mode bits */ cs5530_set_dmamode(ap, adev); } return ata_bmdma_qc_issue(qc); }
false
false
false
false
false
0
setNumCapabilities (nat new_n_capabilities USED_IF_THREADS) { #if !defined(THREADED_RTS) if (new_n_capabilities != 1) { errorBelch("setNumCapabilities: not supported in the non-threaded RTS"); } return; #elif defined(NOSMP) if (new_n_capabilities != 1) { errorBelch("setNumCapabilities: not supported on this platform"); } return; #else Task *task; Capability *cap; nat sync; StgTSO* t; nat g, n; Capability *old_capabilities = NULL; if (new_n_capabilities == enabled_capabilities) return; debugTrace(DEBUG_sched, "changing the number of Capabilities from %d to %d", enabled_capabilities, new_n_capabilities); cap = rts_lock(); task = cap->running_task; do { sync = requestSync(&cap, task, SYNC_OTHER); } while (sync); acquireAllCapabilities(cap,task); pending_sync = 0; if (new_n_capabilities < enabled_capabilities) { // Reducing the number of capabilities: we do not actually // remove the extra capabilities, we just mark them as // "disabled". This has the following effects: // // - threads on a disabled capability are migrated away by the // scheduler loop // // - disabled capabilities do not participate in GC // (see scheduleDoGC()) // // - No spark threads are created on this capability // (see scheduleActivateSpark()) // // - We do not attempt to migrate threads *to* a disabled // capability (see schedulePushWork()). // // but in other respects, a disabled capability remains // alive. Threads may be woken up on a disabled capability, // but they will be immediately migrated away. // // This approach is much easier than trying to actually remove // the capability; we don't have to worry about GC data // structures, the nursery, etc. // for (n = new_n_capabilities; n < enabled_capabilities; n++) { capabilities[n].disabled = rtsTrue; traceCapDisable(&capabilities[n]); } enabled_capabilities = new_n_capabilities; } else { // Increasing the number of enabled capabilities. // // enable any disabled capabilities, up to the required number for (n = enabled_capabilities; n < new_n_capabilities && n < n_capabilities; n++) { capabilities[n].disabled = rtsFalse; traceCapEnable(&capabilities[n]); } enabled_capabilities = n; if (new_n_capabilities > n_capabilities) { #if defined(TRACING) // Allocate eventlog buffers for the new capabilities. Note this // must be done before calling moreCapabilities(), because that // will emit events about creating the new capabilities and adding // them to existing capsets. tracingAddCapapilities(n_capabilities, new_n_capabilities); #endif // Resize the capabilities array // NB. after this, capabilities points somewhere new. Any pointers // of type (Capability *) are now invalid. old_capabilities = moreCapabilities(n_capabilities, new_n_capabilities); // update our own cap pointer cap = &capabilities[cap->no]; // Resize and update storage manager data structures storageAddCapabilities(n_capabilities, new_n_capabilities); // Update (Capability *) refs in the Task manager. updateCapabilityRefs(); // Update (Capability *) refs from TSOs for (g = 0; g < RtsFlags.GcFlags.generations; g++) { for (t = generations[g].threads; t != END_TSO_QUEUE; t = t->global_link) { t->cap = &capabilities[t->cap->no]; } } } } // We're done: release the original Capabilities releaseAllCapabilities(cap,task); // Start worker tasks on the new Capabilities startWorkerTasks(n_capabilities, new_n_capabilities); // finally, update n_capabilities if (new_n_capabilities > n_capabilities) { n_capabilities = enabled_capabilities = new_n_capabilities; } // We can't free the old array until now, because we access it // while updating pointers in updateCapabilityRefs(). if (old_capabilities) { stgFree(old_capabilities); } rts_unlock(cap); #endif // THREADED_RTS }
false
false
false
false
false
0
__wb_calc_thresh(struct dirty_throttle_control *dtc) { struct wb_domain *dom = dtc_dom(dtc); unsigned long thresh = dtc->thresh; u64 wb_thresh; long numerator, denominator; unsigned long wb_min_ratio, wb_max_ratio; /* * Calculate this BDI's share of the thresh ratio. */ fprop_fraction_percpu(&dom->completions, dtc->wb_completions, &numerator, &denominator); wb_thresh = (thresh * (100 - bdi_min_ratio)) / 100; wb_thresh *= numerator; do_div(wb_thresh, denominator); wb_min_max_ratio(dtc->wb, &wb_min_ratio, &wb_max_ratio); wb_thresh += (thresh * wb_min_ratio) / 100; if (wb_thresh > (thresh * wb_max_ratio) / 100) wb_thresh = thresh * wb_max_ratio / 100; return wb_thresh; }
false
false
false
false
false
0
loadSystem() { bool ok = true; QString cur_system = PsiOptions::instance()->getOption("options.iconsets.system").toString(); if (d->cur_system != cur_system) { Iconset sys = d->systemIconset(&ok); d->loadIconset(&d->system, &sys); //d->system = d->systemIconset(); d->system.addToFactory(); d->cur_system = cur_system; } return ok; }
false
false
false
false
false
0
enchant_pwl_refresh_from_file(EnchantPWL* pwl) { char buffer[BUFSIZ]; char* line; size_t line_number = 1; FILE *f; struct stat stats; if(!pwl->filename) return; if(g_stat(pwl->filename, &stats)!=0) return; /*presumably I won't be able to open the file either*/ if(pwl->file_changed == stats.st_mtime) return; /*nothing changed since last read*/ enchant_trie_free(pwl->trie); pwl->trie = NULL; g_hash_table_destroy (pwl->words_in_trie); pwl->words_in_trie = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); f = enchant_fopen(pwl->filename, "r"); if (!f) return; pwl->file_changed = stats.st_mtime; enchant_lock_file (f); for (;NULL != (fgets (buffer, sizeof (buffer), f));++line_number) { const gunichar BOM = 0xfeff; size_t l; line = buffer; if(line_number == 1 && BOM == g_utf8_get_char(line)) line = g_utf8_next_char(line); l = strlen(line)-1; if (line[l]=='\n') line[l] = '\0'; else if(!feof(f)) /* ignore lines longer than BUFSIZ. */ { g_warning ("Line too long (ignored) in %s at line:%u\n", pwl->filename, line_number); while (NULL != (fgets (buffer, sizeof (buffer), f))) { if (line[strlen(buffer)-1]=='\n') break; } continue; } if( line[0] != '#') { if(g_utf8_validate(line, -1, NULL)) enchant_pwl_add_to_trie(pwl, line, strlen(line)); else g_warning ("Bad UTF-8 sequence in %s at line:%u\n", pwl->filename, line_number); } } enchant_unlock_file (f); fclose (f); }
false
false
false
false
false
0
DIMSE_dumpMessage(OFString &str, T_DIMSE_C_MoveRQ &msg, enum DIMSE_direction dir, DcmItem *dataset, T_ASC_PresentationContextID presID) { OFOStringStream stream; const char *uid = dcmFindNameOfUID(msg.AffectedSOPClassUID); DIMSE_dumpMessage_start(str, dir); stream << "Message Type : C-MOVE RQ" << OFendl; if (presID > 0) { stream << "Presentation Context ID : " << OFstatic_cast(int, presID) << OFendl; } stream << "Message ID : " << msg.MessageID << OFendl << "Affected SOP Class UID : " << (uid ? uid : msg.AffectedSOPClassUID) << OFendl << "Data Set : " << ((msg.DataSetType==DIMSE_DATASET_NULL) ? "none" : "present") << OFendl << "Priority : "; switch (msg.Priority) { case DIMSE_PRIORITY_LOW: stream << "low"; break; case DIMSE_PRIORITY_MEDIUM: stream << "medium"; break; case DIMSE_PRIORITY_HIGH: stream << "high"; break; } stream << OFendl << "Move Destination : " << msg.MoveDestination; OFSTRINGSTREAM_GETSTR(stream, result) str += result; OFSTRINGSTREAM_FREESTR(stream) DIMSE_dumpMessage_end(str, dataset); return str; }
false
false
false
false
false
0
lammps_extract_global(void *ptr, char *name) { LAMMPS *lmp = (LAMMPS *) ptr; if (strcmp(name,"dt") == 0) return (void *) &lmp->update->dt; if (strcmp(name,"boxxlo") == 0) return (void *) &lmp->domain->boxlo[0]; if (strcmp(name,"boxxhi") == 0) return (void *) &lmp->domain->boxhi[0]; if (strcmp(name,"boxylo") == 0) return (void *) &lmp->domain->boxlo[1]; if (strcmp(name,"boxyhi") == 0) return (void *) &lmp->domain->boxhi[1]; if (strcmp(name,"boxzlo") == 0) return (void *) &lmp->domain->boxlo[2]; if (strcmp(name,"boxzhi") == 0) return (void *) &lmp->domain->boxhi[2]; if (strcmp(name,"natoms") == 0) return (void *) &lmp->atom->natoms; if (strcmp(name,"nlocal") == 0) return (void *) &lmp->atom->nlocal; return NULL; }
false
false
false
false
false
0
getSingleSuccessor() { succ_iterator SI = succ_begin(this), E = succ_end(this); if (SI == E) return nullptr; // no successors BasicBlock *TheSucc = *SI; ++SI; return (SI == E) ? TheSucc : nullptr /* multiple successors */; }
false
false
false
false
false
0
inclc(int i) { while (i-- > 0) { if( pass2 && getloc(lc) ) error("Location counter overlaps"); if( pass2 ) setloc(lc); lc += 1; } if( lc > 0xffff ) error("Location counter has exceeded 16-bits"); }
false
false
false
false
false
0
save(std::ostream& out, bool doIndent, bool doNewline) { // output all processing instructions NodeList::const_iterator iter, stop; iter = mProcInstructions.begin(); stop = mProcInstructions.end(); out << "<?xml version=\"1.0\" ?>" << std::endl; for(; iter!=stop; ++iter) { NodePtr np = *iter; // output pi tag out << "<?" << np->getName(); // output all attributes Attributes::const_iterator aiter, astop; aiter = mAttributes.begin(); astop = mAttributes.end(); for(; aiter!=astop; ++aiter) { Attributes::value_type attr = *aiter; out << ' ' << attr.first << '=' << '\"' << attr.second.getString() << '\"'; } // output closing brace out << "?>" << std::endl; } // call save() method of the first (and hopefully only) node in Document (*mNodeList.begin())->save(out, 0, doIndent, doNewline); }
false
false
false
false
false
0
clcache_new_busy_list () { CLC_Busy_List *bl; int welldone = 0; do { if ( NULL == (bl = ( CLC_Busy_List* ) slapi_ch_calloc (1, sizeof(CLC_Busy_List)) )) break; if ( NULL == (bl->bl_lock = PR_NewLock ()) ) break; /* if ( NULL == (bl->bl_max_csn = csn_new ()) ) break; */ welldone = 1; } while (0); if ( !welldone ) { clcache_delete_busy_list ( &bl ); } return bl; }
false
false
false
false
false
0
ext4_dax_pmd_fault(struct vm_area_struct *vma, unsigned long addr, pmd_t *pmd, unsigned int flags) { int result; handle_t *handle = NULL; struct inode *inode = file_inode(vma->vm_file); struct super_block *sb = inode->i_sb; bool write = flags & FAULT_FLAG_WRITE; if (write) { sb_start_pagefault(sb); file_update_time(vma->vm_file); down_read(&EXT4_I(inode)->i_mmap_sem); handle = ext4_journal_start_sb(sb, EXT4_HT_WRITE_PAGE, ext4_chunk_trans_blocks(inode, PMD_SIZE / PAGE_SIZE)); } else down_read(&EXT4_I(inode)->i_mmap_sem); if (IS_ERR(handle)) result = VM_FAULT_SIGBUS; else result = __dax_pmd_fault(vma, addr, pmd, flags, ext4_get_block_dax, ext4_end_io_unwritten); if (write) { if (!IS_ERR(handle)) ext4_journal_stop(handle); up_read(&EXT4_I(inode)->i_mmap_sem); sb_end_pagefault(sb); } else up_read(&EXT4_I(inode)->i_mmap_sem); return result; }
false
false
false
false
false
0
sshv2_decode_file_attributes (gftp_request * request, sshv2_message * message, gftp_file * fle) { guint32 attrs, num, count, i; int ret; if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &attrs)) < 0) return (ret); if (attrs & SSH_FILEXFER_ATTR_SIZE) { if ((ret = sshv2_buffer_get_int64 (request, message, 0, 0, &fle->size)) < 0) return (ret); } if (attrs & SSH_FILEXFER_ATTR_UIDGID) { if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0) return (ret); fle->user = g_strdup_printf ("%d", num); if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0) return (ret); fle->group = g_strdup_printf ("%d", num); } if (attrs & SSH_FILEXFER_ATTR_PERMISSIONS) { if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0) return (ret); fle->st_mode = num; } if (attrs & SSH_FILEXFER_ATTR_ACMODTIME) { if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, NULL)) < 0) return (num); if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0) return (ret); fle->datetime = num; } if (attrs & SSH_FILEXFER_ATTR_EXTENDED) { if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &count)) < 0) return (ret); for (i=0; i<count; i++) { if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0 || message->pos + num + 4 > message->end) return (GFTP_EFATAL); message->pos += num + 4; if ((ret = sshv2_buffer_get_int32 (request, message, 0, 0, &num)) < 0 || message->pos + num + 4 > message->end) return (GFTP_EFATAL); message->pos += num + 4; } } return (0); }
false
false
false
false
false
0
createEngine(const QString& managerName, const QMap<QString, QString>& parameters) { m_engine = 0; QString builtManagerName = managerName.isEmpty() ? QContactManager::availableManagers().value(0) : managerName; if (builtManagerName == QLatin1String("memory")) { m_engine = new QContactManagerEngineV2Wrapper(QContactMemoryEngine::createMemoryEngine(parameters)); #ifdef QT_SIMULATOR } else if (builtManagerName == QLatin1String("simulator")) { m_engine = new QContactManagerEngineV2Wrapper(QContactSimulatorEngine::createSimulatorEngine(parameters)); #endif } else { int implementationVersion = parameterValue(parameters, QTCONTACTS_IMPLEMENTATION_VERSION_NAME, -1); bool found = false; bool loadedDynamic = false; /* First check static factories */ loadStaticFactories(); /* See if we got a fast hit */ QList<QContactManagerEngineFactory*> factories = m_engines.values(builtManagerName); m_error = QContactManager::NoError; while(!found) { foreach (QContactManagerEngineFactory* f, factories) { QList<int> versions = f->supportedImplementationVersions(); if (implementationVersion == -1 ||//no given implementation version required versions.isEmpty() || //the manager engine factory does not report any version versions.contains(implementationVersion)) { QContactManagerEngine* engine = f->engine(parameters, &m_error); // if it's a V2, use it m_engine = qobject_cast<QContactManagerEngineV2*>(engine); if (!m_engine && engine) { // Nope, v1, so wrap it m_engine = new QContactManagerEngineV2Wrapper(engine); } found = true; break; } } // Break if found or if this is the second time through if (loadedDynamic || found) break; // otherwise load dynamic factories and reloop loadFactories(); factories = m_engines.values(builtManagerName); loadedDynamic = true; } // XXX remove this // the engine factory could lie to us, so check the real implementation version if (m_engine && (implementationVersion != -1 && m_engine->managerVersion() != implementationVersion)) { m_error = QContactManager::VersionMismatchError; m_engine = 0; } if (!m_engine) { if (m_error == QContactManager::NoError) m_error = QContactManager::DoesNotExistError; m_engine = new QContactInvalidEngine(); } } }
false
false
false
false
false
0
ecdsa_verify_nif(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) {/* (Type, Data|{digest,Digest}, Signature, Curve, Key) */ #if defined(HAVE_EC) ErlNifBinary data_bin, sign_bin; unsigned char hmacbuf[SHA512_LEN]; int i; EC_KEY* key = NULL; const ERL_NIF_TERM type = argv[0]; const ERL_NIF_TERM* tpl_terms; int tpl_arity; struct digest_type_t* digp = NULL; unsigned char* digest = NULL; digp = get_digest_type(type); if (!digp) { return enif_make_badarg(env); } if (!digp->len) { return atom_notsup; } if (!enif_inspect_binary(env, argv[2], &sign_bin) || !get_ec_key(env, argv[3], atom_undefined, argv[4], &key)) goto badarg; if (enif_get_tuple(env, argv[1], &tpl_arity, &tpl_terms)) { if (tpl_arity != 2 || tpl_terms[0] != atom_digest || !enif_inspect_binary(env, tpl_terms[1], &data_bin) || data_bin.size != digp->len) { goto badarg; } digest = data_bin.data; } else if (enif_inspect_binary(env, argv[1], &data_bin)) { digest = hmacbuf; digp->funcp(data_bin.data, data_bin.size, digest); } else { goto badarg; } i = ECDSA_verify(digp->NID_type, digest, digp->len, sign_bin.data, sign_bin.size, key); EC_KEY_free(key); return (i==1 ? atom_true : atom_false); badarg: if (key) EC_KEY_free(key); return enif_make_badarg(env); #else return atom_notsup; #endif }
false
false
false
false
false
0
_wrap_lfc_registerfiles(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; int arg1 ; struct lfc_filereg *arg2 = (struct lfc_filereg *) 0 ; int *arg3 = (int *) 0 ; int **arg4 = (int **) 0 ; PyObject * obj0 = 0 ; RETURNCODE result; { int tmp_int; int *tmp_tab; arg3 = &tmp_int; arg4 = &tmp_tab; } if (!PyArg_ParseTuple(args,(char *)"O:lfc_registerfiles",&obj0)) SWIG_fail; { /* Check the input list */ if (!PyList_Check (obj0)) { PyErr_SetString (PyExc_ValueError, "Expecting a list"); return NULL; } /* No error */ else { /* Length of the python list (how many structs we will need) */ arg1 = PyList_Size (obj0); /* Reserve space to store all the list members in an array (after converting them) */ arg2 = (struct lfc_filereg *) calloc (arg1, sizeof (struct lfc_filereg)) ; int i; for (i=0; i<arg1; i++) { PyObject * aux_object = PyList_GetItem (obj0, i); /* Temp pointer */ struct lfc_filereg * aux_p; /* This moves aux_p to point to a newly allocated Cns_filereg struct representing the item in the python list */ SWIG_ConvertPtr (aux_object, (void**) &aux_p, SWIGTYPE_p_lfc_filereg, SWIG_POINTER_EXCEPTION); /* Copy the value to the array */ arg2[i] = *aux_p; } }/* end of: No error */ } result = (RETURNCODE)lfc_registerfiles(arg1,arg2,arg3,arg4); if (result < 0) { PyErr_SetString (serrno2pyexc (serrno), serrbuf); return (NULL); } is_returncode = 1; resultobj = Py_None; { PyObject *myresult; /* Error */ if (result < 0 || *arg3 < 0) { Py_INCREF (Py_None); myresult = Py_None; } /* No error */ else { int i; PyObject *aux_obj; myresult = PyList_New (*arg3); for (i = 0; i < *arg3; i++) { aux_obj = PyInt_FromLong ((long) (*arg4)[i]); PyList_SetItem (myresult, i, aux_obj); }/* end of for */ }/* end of: No error */ resultobj = my_t_output_helper(resultobj, myresult); } { if (arg2) free (arg2); } return resultobj; fail: { if (arg2) free (arg2); } return NULL; }
false
false
false
false
false
0
_request_firmware_load(struct firmware_priv *fw_priv, unsigned int opt_flags, long timeout) { int retval = 0; struct device *f_dev = &fw_priv->dev; struct firmware_buf *buf = fw_priv->buf; /* fall back on userspace loading */ buf->is_paged_buf = true; dev_set_uevent_suppress(f_dev, true); retval = device_add(f_dev); if (retval) { dev_err(f_dev, "%s: device_register failed\n", __func__); goto err_put_dev; } mutex_lock(&fw_lock); list_add(&buf->pending_list, &pending_fw_head); mutex_unlock(&fw_lock); if (opt_flags & FW_OPT_UEVENT) { buf->need_uevent = true; dev_set_uevent_suppress(f_dev, false); dev_dbg(f_dev, "firmware: requesting %s\n", buf->fw_id); kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); } else { timeout = MAX_JIFFY_OFFSET; } timeout = wait_for_completion_interruptible_timeout(&buf->completion, timeout); if (timeout == -ERESTARTSYS || !timeout) { retval = timeout; mutex_lock(&fw_lock); fw_load_abort(fw_priv); mutex_unlock(&fw_lock); } else if (timeout > 0) { retval = 0; } if (is_fw_load_aborted(buf)) retval = -EAGAIN; else if (!buf->data) retval = -ENOMEM; device_del(f_dev); err_put_dev: put_device(f_dev); return retval; }
false
false
false
false
false
0
print_archive_ref(const char *refname, const unsigned char *sha1, int flags, void *cb_data) { struct tag *tag; struct taginfo *info; struct object *obj; char buf[256], *url; unsigned char fileid[20]; int *header = (int *)cb_data; if (prefixcmp(refname, "refs/archives")) return 0; strncpy(buf, refname+14, sizeof(buf)); obj = parse_object(sha1); if (!obj) return 1; if (obj->type == OBJ_TAG) { tag = lookup_tag(sha1); if (!tag || parse_tag(tag) || !(info = cgit_parse_tag(tag))) return 0; hashcpy(fileid, tag->tagged->sha1); } else if (obj->type != OBJ_BLOB) { return 0; } else { hashcpy(fileid, sha1); } if (!*header) { html("<h1>download</h1>\n"); *header = 1; } url = cgit_pageurl(ctx.qry.repo, "blob", fmt("id=%s&amp;path=%s", sha1_to_hex(fileid), buf)); html_link_open(url, NULL, "menu"); html_txt(strlpart(buf, 20)); html_link_close(); return 0; }
true
true
false
false
false
1
obj_policy_set_delegation_index(TSS_HPOLICY hPolicy, UINT32 index) { struct tsp_object *obj; struct tr_policy_obj *policy; TPM_DELEGATE_PUBLIC public; TSS_RESULT result; if ((obj = obj_list_get_obj(&policy_list, hPolicy)) == NULL) return TSPERR(TSS_E_INVALID_HANDLE); policy = (struct tr_policy_obj *)obj->data; if ((result = get_delegate_index(obj->tspContext, index, &public))) goto done; free(public.pcrInfo.pcrSelection.pcrSelect); obj_policy_clear_delegation(policy); switch (public.permissions.delegateType) { case TPM_DEL_OWNER_BITS: policy->delegationType = TSS_DELEGATIONTYPE_OWNER; break; case TPM_DEL_KEY_BITS: policy->delegationType = TSS_DELEGATIONTYPE_KEY; break; default: result = TSPERR(TSS_E_BAD_PARAMETER); goto done; } policy->delegationIndex = index; policy->delegationIndexSet = TRUE; done: obj_list_put(&policy_list); return result; }
false
false
false
false
false
0
init_conf_file(MarkdownConfig *conf) { GError *error = NULL; gchar *def_tmpl, *dirn; dirn = g_path_get_dirname(conf->priv->filename); if (!g_file_test(dirn, G_FILE_TEST_IS_DIR)) { g_mkdir_with_parents(dirn, 0755); } if (!g_file_test(conf->priv->filename, G_FILE_TEST_EXISTS)) { if (!g_file_set_contents(conf->priv->filename, DEFAULT_CONF, -1, &error)) { g_warning("Unable to write default configuration file: %s", error->message); g_error_free(error); error = NULL; } } def_tmpl = g_build_filename(dirn, "template.html", NULL); if (!g_file_test(def_tmpl, G_FILE_TEST_EXISTS)) { if (!g_file_set_contents(def_tmpl, MARKDOWN_HTML_TEMPLATE, -1, &error)) { g_warning("Unable to write default template file: %s", error->message); g_error_free(error); error = NULL; } } g_free(dirn); g_free(def_tmpl); }
false
false
false
false
false
0
test_token(struct client *c1, int32_t hc1, struct client *c2, int32_t hc2, int wrap_ext) { int32_t val; int i; for (i = 0; i < 10; i++) { /* mic */ test_mic(c1, hc1, c2, hc2); test_mic(c2, hc2, c1, hc1); /* wrap */ val = test_wrap(c1, hc1, c2, hc2, 0); if (val) return val; val = test_wrap(c2, hc2, c1, hc1, 0); if (val) return val; val = test_wrap(c1, hc1, c2, hc2, 1); if (val) return val; val = test_wrap(c2, hc2, c1, hc1, 1); if (val) return val; if (wrap_ext) { /* wrap ext */ val = test_wrap_ext(c1, hc1, c2, hc2, 1, 0); if (val) return val; val = test_wrap_ext(c2, hc2, c1, hc1, 1, 0); if (val) return val; val = test_wrap_ext(c1, hc1, c2, hc2, 1, 1); if (val) return val; val = test_wrap_ext(c2, hc2, c1, hc1, 1, 1); if (val) return val; val = test_wrap_ext(c1, hc1, c2, hc2, 0, 0); if (val) return val; val = test_wrap_ext(c2, hc2, c1, hc1, 0, 0); if (val) return val; val = test_wrap_ext(c1, hc1, c2, hc2, 0, 1); if (val) return val; val = test_wrap_ext(c2, hc2, c1, hc1, 0, 1); if (val) return val; } } return GSMERR_OK; }
false
false
false
false
false
0
_cirrus_bitblt_system_to_screen(struct cpssp *cpssp) { #ifdef CIRRUS_DEBUG_BITBLT faum_log(FAUM_LOG_DEBUG, __FUNCTION__, "", "\n"); #endif /* source pitch is a don't care, calculate it to length of one src line in bytes */ if (cpssp->bitblt.mode & BITBLT_COLOR_EXPAND) { int bpl; /* source bits needed per line */ bpl = cpssp->bitblt.width / cpssp->bitblt.color_expand_width; if (cpssp->bitblt.mode_extensions & BITBLT_32BIT_GRANULARITY) { /* position of the first byte within the first dword of each destination scanline */ bpl += ((cpssp->bitblt.dest_left_side_clipping & BITBLT_SYSTEM_TO_SCREEN_DWORD_POINTER) >> 5) * 8; /* how many bytes needed per scanline? */ cpssp->bitblt.src_pitch = ((bpl + 31) >> 5) * 4; } else { /* 8bit granularity */ cpssp->bitblt.src_pitch = (bpl + 7) >> 3; } } else { /* always align to 32bits */ cpssp->bitblt.src_pitch = (cpssp->bitblt.width + 3) & ~3; } if (BITBLT_LINE_BUFFER_SIZE < cpssp->bitblt.src_pitch) { /* this should never happen */ #ifdef CIRRUS_DEBUG_BITBLT faum_log(FAUM_LOG_DEBUG, __FUNCTION__, "", "System-to-screen line buffer too small, required " "are %d bytes\n", cpssp->bitblt.src_pitch); #endif _cirrus_bitblt_reset(cpssp); return; } /* set up bitblt engine for single line execution */ cpssp->bitblt.src_counter = /* total bytes for rop */ cpssp->bitblt.src_pitch * cpssp->bitblt.height; cpssp->bitblt.line_pointer = BITBLT_LINE_BUFFER_START; cpssp->bitblt.line_pointer_end = BITBLT_LINE_BUFFER_START + cpssp->bitblt.src_pitch; cpssp->bitblt.height = 1; cpssp->bitblt.source_pointer = BITBLT_LINE_BUFFER_START; }
false
false
false
false
false
0
term_to_topform(Term t, BOOL is_formula) { Topform c = get_topform(); Term t_start; if (is_term(t, attrib_sym(), 2)) { c->attributes = term_to_attributes(ARG(t,1), attrib_sym()); t_start = ARG(t,0); } else t_start = t; c->is_formula = is_formula; if (is_formula) c->formula = term_to_formula(t_start); else { c->literals = term_to_literals(t_start, NULL); upward_clause_links(c); } return(c); }
false
false
false
false
false
0
value_pair_get_value(LList *pairs, const char *key) { LList *node; for (node = pairs; node; node = node->next) { value_pair *vp = node->data; if (!strcasecmp(key, vp->key)) { if (!vp->value) return strdup(""); else return strdup(vp->value); } } return NULL; }
false
false
false
false
false
0
cik_sdma_ring_ib_execute(struct radeon_device *rdev, struct radeon_ib *ib) { struct radeon_ring *ring = &rdev->ring[ib->ring]; u32 extra_bits = (ib->vm ? ib->vm->ids[ib->ring].id : 0) & 0xf; if (rdev->wb.enabled) { u32 next_rptr = ring->wptr + 5; while ((next_rptr & 7) != 4) next_rptr++; next_rptr += 4; radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_WRITE, SDMA_WRITE_SUB_OPCODE_LINEAR, 0)); radeon_ring_write(ring, ring->next_rptr_gpu_addr & 0xfffffffc); radeon_ring_write(ring, upper_32_bits(ring->next_rptr_gpu_addr)); radeon_ring_write(ring, 1); /* number of DWs to follow */ radeon_ring_write(ring, next_rptr); } /* IB packet must end on a 8 DW boundary */ while ((ring->wptr & 7) != 4) radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_NOP, 0, 0)); radeon_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_INDIRECT_BUFFER, 0, extra_bits)); radeon_ring_write(ring, ib->gpu_addr & 0xffffffe0); /* base must be 32 byte aligned */ radeon_ring_write(ring, upper_32_bits(ib->gpu_addr)); radeon_ring_write(ring, ib->length_dw); }
false
false
false
false
false
0
mk_dbversion_fullpath(struct ldbminfo *li, const char *directory, char *filename) { if (li) { if (is_fullpath((char *)directory)) { PR_snprintf(filename, MAXPATHLEN*2, "%s/%s", directory, DBVERSION_FILENAME); } else { char *home_dir = dblayer_get_home_dir(li, NULL); /* if relpath, nsslapd-dbhome_directory should be set */ PR_snprintf(filename, MAXPATHLEN*2,"%s/%s/%s", home_dir,directory,DBVERSION_FILENAME); } } else { PR_snprintf(filename, MAXPATHLEN*2, "%s/%s", directory, DBVERSION_FILENAME); } }
false
false
false
false
false
0
shpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int rc; struct controller *ctrl; if (!is_shpc_capable(pdev)) return -ENODEV; ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); if (!ctrl) { dev_err(&pdev->dev, "%s: Out of memory\n", __func__); goto err_out_none; } INIT_LIST_HEAD(&ctrl->slot_list); rc = shpc_init(ctrl, pdev); if (rc) { ctrl_dbg(ctrl, "Controller initialization failed\n"); goto err_out_free_ctrl; } pci_set_drvdata(pdev, ctrl); /* Setup the slot information structures */ rc = init_slots(ctrl); if (rc) { ctrl_err(ctrl, "Slot initialization failed\n"); goto err_out_release_ctlr; } rc = shpchp_create_ctrl_files(ctrl); if (rc) goto err_cleanup_slots; return 0; err_cleanup_slots: cleanup_slots(ctrl); err_out_release_ctlr: ctrl->hpc_ops->release_ctlr(ctrl); err_out_free_ctrl: kfree(ctrl); err_out_none: return -ENODEV; }
false
false
false
false
false
0
EmitAtomOp(JSContext *cx, JSParseNode *pn, JSOp op, JSCodeGenerator *cg) { JSAtomListElement *ale; JS_ASSERT(JOF_OPTYPE(op) == JOF_ATOM); if (op == JSOP_GETPROP && pn->pn_atom == cx->runtime->atomState.lengthAtom) { return js_Emit1(cx, cg, JSOP_LENGTH) >= 0; } ale = cg->atomList.add(cg->compiler, pn->pn_atom); if (!ale) return JS_FALSE; return EmitIndexOp(cx, op, ALE_INDEX(ale), cg); }
false
false
false
false
false
0
menu_invoke_by_title(int x, int y, Window win, char *title, Time timestamp) { menu_t *menu; REQUIRE(title != NULL); REQUIRE(menu_list != NULL); menu = find_menu_by_title(menu_list, title); if (!menu) { D_MENU(("Menu \"%s\" not found!\n", title)); return; } menu_invoke(x, y, win, menu, timestamp); }
false
false
false
false
false
0
int_log2(uint32_t v) { int c = 0; if (v & 0xffff0000u) { v >>= 16; c |= 16; } if (v & 0xff00) { v >>= 8; c |= 8; } if (v & 0xf0) { v >>= 4; c |= 4; } if (v & 0xc) { v >>= 2; c |= 2; } if (v & 0x2) c |= 1; return c; }
false
false
false
false
false
0
rebase_readfile( git_buf *out, git_buf *state_path, const char *filename) { size_t state_path_len = state_path->size; int error; git_buf_clear(out); if ((error = git_buf_joinpath(state_path, state_path->ptr, filename)) < 0 || (error = git_futils_readbuffer(out, state_path->ptr)) < 0) goto done; git_buf_rtrim(out); done: git_buf_truncate(state_path, state_path_len); return error; }
false
false
false
false
false
0
findColorSchemeByName (GList * schemes, const gchar * name) { colorschemed *s; gint i, n; n = g_list_length (schemes); for (i = 0; i < n; i++) { s = (colorschemed *) g_list_nth_data (schemes, i); if (strcmp (name, s->name) == 0) return (s); } return (NULL); }
false
false
false
false
false
0
unchanger() { if (uamul && uamul->otyp == AMULET_OF_UNCHANGING) return uamul; return 0; }
false
false
false
false
false
0
write (::zmq_msg_t *msg_) { // Once we've got peer's identity we aren't interested in subsequent // messages. if (has_peer_identity) return false; // Retreieve the remote identity. We'll use it as a local session name. has_peer_identity = true; peer_identity.assign ((const char*) zmq_msg_data (msg_), zmq_msg_size (msg_)); return true; }
false
false
false
false
false
0
gstspu_vobsub_get_rle_code (SpuState * state, guint16 * rle_offset) { guint16 code; code = gstspu_vobsub_get_nibble (state, rle_offset); if (code < 0x4) { /* 4 .. f */ code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset); if (code < 0x10) { /* 1x .. 3x */ code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset); if (code < 0x40) { /* 04x .. 0fx */ code = (code << 4) | gstspu_vobsub_get_nibble (state, rle_offset); } } } return code; }
false
false
false
false
false
0
intersect(const Ray &ray) { Vector u, v, n; double d, t; Point i, N; u = Pa - Pb; v = Pc - Pb; n = u.cross(v).normalized(); // No intersection if the ray is perpendicular to the triangle normal d = n.dot(ray.D); if (d == 0) return Hit::NO_HIT(); t = n.dot(Pa - ray.O) / d; // No intersection if the ray originates behind the surface if (t < 0) return Hit::NO_HIT(); i = ray.at(t); // No intersection if point is on the outside of the triangle edges if ((i - Pa).cross(Pb - Pa).dot(n) <= 0 || (i - Pb).cross(Pc - Pb).dot(n) <= 0 || (i - Pc).cross(Pa - Pc).dot(n) <= 0) return Hit::NO_HIT(); // Interpolate normals Vector distA, distB, distC; float totArea, area1, area2, area3; distA = Pa - i; distB = Pb - i; distC = Pc - i; totArea = (Pa-Pb).cross(Pa-Pc).length(); area1 = distB.cross(distC).length() / totArea; area2 = distC.cross(distA).length() / totArea; area3 = distB.cross(distA).length() / totArea; N = Na * area1 + Nb * area2 + Nc * area3; return Hit(t, N.normalized(), material); }
false
false
false
false
false
0
on_click_button_couleur_cadre(wxCommandEvent& event) { wxColourDialog dialog(this); if (dialog.ShowModal()==wxID_OK) { wxColourData retData=dialog.GetColourData(); wxColour col=retData.GetColour(); button_couleur_cadre->SetBackgroundColour(col); button_couleur_cadre->SetForegroundColour(col); } }
false
false
false
false
false
0
may_direct (struct conf_node *other) { if (match_list (allow_direct, other->nodename)) return true; if (match_list (deny_direct, other->nodename)) return false; return true; }
false
false
false
false
false
0
stlOutOfBoundsError(const Token *tok, const std::string &num, const std::string &var, bool at) { if (at) reportError(tok, Severity::error, "stlOutOfBounds", "When " + num + "==" + var + ".size(), " + var + ".at(" + num + ") is out of bounds."); else reportError(tok, Severity::error, "stlOutOfBounds", "When " + num + "==" + var + ".size(), " + var + "[" + num + "] is out of bounds."); }
false
false
false
false
false
0
timer_unregister(dns_timer_t *timer) { if (timer->t_prev != NULL) timer->t_prev->t_next = timer->t_next; if (timer->t_next != NULL) timer->t_next->t_prev = timer->t_prev; if (TimerHead == timer) TimerHead = timer->t_next; if (TimerTail == timer) TimerTail = timer->t_prev; timer->t_prev = NULL; timer->t_next = NULL; }
false
false
false
false
false
0
DestructorCheck() { if(!Stopped() && Started()) { Stop("Destructor"); } }
false
false
false
false
false
0
cgroup_get_controller(struct cgroup *cgroup, const char *name) { int i; struct cgroup_controller *cgc; if (!cgroup) return NULL; for (i = 0; i < cgroup->index; i++) { cgc = cgroup->controller[i]; if (!strcmp(cgc->name, name)) return cgc; } return NULL; }
false
false
false
false
false
0
init_twi_main() { freertos_peripheral_options_t async_driver_options = { NULL, /* This peripheral does not need a receive buffer, so this parameter is just set to NULL. */ 0, /* There is no Rx buffer, so the rx buffer size is not used. */ (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1), /* The priority used by the TWI interrupts. It is essential that the priority does not have a numerically lower value than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY*/ TWI_I2C_MASTER, /* TWI is configured as an I2C master. */ 0, /* The asynchronous driver is used, so WAIT_TX_COMPLETE and WAIT_RX_COMPLETE are not set. */ }; freertos_peripheral_options_t async_driver_options1 = { NULL, /* This peripheral does not need a receive buffer, so this parameter is just set to NULL. */ 0, /* There is no Rx buffer, so the rx buffer size is not used. */ (configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1), /* The priority used by the TWI interrupts. It is essential that the priority does not have a numerically lower value than configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY*/ TWI_I2C_MASTER, /* TWI is configured as an I2C master. */ 0, /* The asynchronous driver is used, so WAIT_TX_COMPLETE and WAIT_RX_COMPLETE are not set. */ }; freertos_twi_if twi_0 = freertos_twi_master_init(TWI0, &async_driver_options); /*Initialize twi bus 0, available at pin xx and xx on the Arduino due*/ freertos_twi_if twi_1 = freertos_twi_master_init(TWI1, &async_driver_options1); /*Initialize twi bus 1, available at pin xx and xx on the Arduino due*/ if (twi_0 == NULL || twi_1 == NULL) { for (;;) { // ERROR, TODO set error flag and halt execution*/ } } twi_set_speed(TWI0, 400000, sysclk_get_cpu_hz()); /*High speed TWI setting*/ twi_set_speed(TWI1, 400000, sysclk_get_cpu_hz()); /*High speed TWI setting*/ }
false
false
false
false
false
0
eina_str_tolower(char **str) { char *p; if ((!str) || (!(*str))) return; for (p = *str; (*p); p++) *p = tolower((unsigned char )(*p)); }
false
false
false
false
false
0
validate(QString & qtext, int & dummy) const { if (qtext == autotext_) return QValidator::Acceptable; return LengthValidator::validate(qtext, dummy); }
false
false
false
false
false
0
fm_folder_view_select_file_paths(FmFolderView* fv, FmPathList* paths) { GList* l; FmFolderViewInterface* iface; g_return_if_fail(FM_IS_FOLDER_VIEW(fv)); iface = FM_FOLDER_VIEW_GET_IFACE(fv); for(l = fm_path_list_peek_head_link(paths);l; l=l->next) { FmPath* path = FM_PATH(l->data); iface->select_file_path(fv, path); } }
false
false
false
false
false
0
AcpiNsExternalizeName ( UINT32 InternalNameLength, const char *InternalName, UINT32 *ConvertedNameLength, char **ConvertedName) { UINT32 NamesIndex = 0; UINT32 NumSegments = 0; UINT32 RequiredLength; UINT32 PrefixLength = 0; UINT32 i = 0; UINT32 j = 0; ACPI_FUNCTION_TRACE (NsExternalizeName); if (!InternalNameLength || !InternalName || !ConvertedName) { return_ACPI_STATUS (AE_BAD_PARAMETER); } /* Check for a prefix (one '\' | one or more '^') */ switch (InternalName[0]) { case AML_ROOT_PREFIX: PrefixLength = 1; break; case AML_PARENT_PREFIX: for (i = 0; i < InternalNameLength; i++) { if (ACPI_IS_PARENT_PREFIX (InternalName[i])) { PrefixLength = i + 1; } else { break; } } if (i == InternalNameLength) { PrefixLength = i; } break; default: break; } /* * Check for object names. Note that there could be 0-255 of these * 4-byte elements. */ if (PrefixLength < InternalNameLength) { switch (InternalName[PrefixLength]) { case AML_MULTI_NAME_PREFIX_OP: /* <count> 4-byte names */ NamesIndex = PrefixLength + 2; NumSegments = (UINT8) InternalName[(ACPI_SIZE) PrefixLength + 1]; break; case AML_DUAL_NAME_PREFIX: /* Two 4-byte names */ NamesIndex = PrefixLength + 1; NumSegments = 2; break; case 0: /* NullName */ NamesIndex = 0; NumSegments = 0; break; default: /* one 4-byte name */ NamesIndex = PrefixLength; NumSegments = 1; break; } } /* * Calculate the length of ConvertedName, which equals the length * of the prefix, length of all object names, length of any required * punctuation ('.') between object names, plus the NULL terminator. */ RequiredLength = PrefixLength + (4 * NumSegments) + ((NumSegments > 0) ? (NumSegments - 1) : 0) + 1; /* * Check to see if we're still in bounds. If not, there's a problem * with InternalName (invalid format). */ if (RequiredLength > InternalNameLength) { ACPI_ERROR ((AE_INFO, "Invalid internal name")); return_ACPI_STATUS (AE_BAD_PATHNAME); } /* Build the ConvertedName */ *ConvertedName = ACPI_ALLOCATE_ZEROED (RequiredLength); if (!(*ConvertedName)) { return_ACPI_STATUS (AE_NO_MEMORY); } j = 0; for (i = 0; i < PrefixLength; i++) { (*ConvertedName)[j++] = InternalName[i]; } if (NumSegments > 0) { for (i = 0; i < NumSegments; i++) { if (i > 0) { (*ConvertedName)[j++] = '.'; } /* Copy and validate the 4-char name segment */ ACPI_MOVE_NAME (&(*ConvertedName)[j], &InternalName[NamesIndex]); AcpiUtRepairName (&(*ConvertedName)[j]); j += ACPI_NAME_SIZE; NamesIndex += ACPI_NAME_SIZE; } } if (ConvertedNameLength) { *ConvertedNameLength = (UINT32) RequiredLength; } return_ACPI_STATUS (AE_OK); }
false
false
false
false
false
0
mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev, unsigned long start, unsigned long end, unsigned long newflags) { struct mm_struct *mm = vma->vm_mm; unsigned long oldflags = vma->vm_flags; long nrpages = (end - start) >> PAGE_SHIFT; unsigned long charged = 0; pgoff_t pgoff; int error; int dirty_accountable = 0; if (newflags == oldflags) { *pprev = vma; return 0; } /* * If we make a private mapping writable we increase our commit; * but (without finer accounting) cannot reduce our commit if we * make it unwritable again. hugetlb mapping were accounted for * even if read-only so there is no need to account for them here */ if (newflags & VM_WRITE) { if (!(oldflags & (VM_ACCOUNT|VM_WRITE|VM_HUGETLB| VM_SHARED|VM_NORESERVE))) { charged = nrpages; if (security_vm_enough_memory_mm(mm, charged)) return -ENOMEM; newflags |= VM_ACCOUNT; } } /* * First try to merge with previous and/or next vma. */ pgoff = vma->vm_pgoff + ((start - vma->vm_start) >> PAGE_SHIFT); *pprev = vma_merge(mm, *pprev, start, end, newflags, vma->anon_vma, vma->vm_file, pgoff, vma_policy(vma), vma->vm_userfaultfd_ctx); if (*pprev) { vma = *pprev; goto success; } *pprev = vma; if (start != vma->vm_start) { error = split_vma(mm, vma, start, 1); if (error) goto fail; } if (end != vma->vm_end) { error = split_vma(mm, vma, end, 0); if (error) goto fail; } success: /* * vm_flags and vm_page_prot are protected by the mmap_sem * held in write mode. */ vma->vm_flags = newflags; dirty_accountable = vma_wants_writenotify(vma); vma_set_page_prot(vma); change_protection(vma, start, end, vma->vm_page_prot, dirty_accountable, 0); /* * Private VM_LOCKED VMA becoming writable: trigger COW to avoid major * fault on access. */ if ((oldflags & (VM_WRITE | VM_SHARED | VM_LOCKED)) == VM_LOCKED && (newflags & VM_WRITE)) { populate_vma_page_range(vma, start, end, NULL); } vm_stat_account(mm, oldflags, vma->vm_file, -nrpages); vm_stat_account(mm, newflags, vma->vm_file, nrpages); perf_event_mmap(vma); return 0; fail: vm_unacct_memory(charged); return error; }
false
false
false
false
false
0
blogc_fix_description(const char *paragraph) { if (paragraph == NULL) return NULL; sb_string_t *rv = sb_string_new(); bool last = false; bool newline = false; char *tmp = NULL; size_t start = 0; size_t current = 0; while (true) { switch (paragraph[current]) { case '\0': last = true; case '\r': case '\n': if (newline) break; tmp = sb_strndup(paragraph + start, current - start); sb_string_append(rv, sb_str_strip(tmp)); free(tmp); tmp = NULL; if (!last) sb_string_append_c(rv, ' '); start = current + 1; newline = true; break; default: newline = false; } if (last) break; current++; } tmp = blogc_htmlentities(sb_str_strip(rv->str)); sb_string_free(rv, true); return tmp; }
false
false
false
false
false
0
copy(void) const { GP<DjVuANT> ant=new DjVuANT(*this); // Now process the list of hyperlinks. ant->map_areas.empty(); for(GPosition pos=map_areas;pos;++pos) ant->map_areas.append(map_areas[pos]->get_copy()); return ant; }
false
false
false
false
false
0
addUnit(lyx::Length::UNIT unit) { QString const val = lyx::toqstr(lyx::stringFromUnit(unit)); int num = QComboBox::count(); for (int i = 0; i < num; i++) { if (QComboBox::itemData(i).toString() == val) { // already there, nothing to do return; } } insertItem(int(unit), lyx::qt_(lyx::unit_name_gui[int(unit)]), lyx::toqstr(lyx::unit_name[int(unit)])); }
false
false
false
false
false
0
resize(const QSize &sz) { if (cfgSize.isEmpty()) { QDialog::resize(sz); cfgSize=sz; } }
false
false
false
false
false
0
_GIO_translateURL(unichar_t *path, enum giofuncs gf) { struct transtab *test; if ( transtab==NULL ) return( NULL ); for ( test = transtab; test->old!=NULL; ++test ) { if ( (test->gf_mask&(1<<gf)) && u_strncmp(path,test->old,test->olen)==0 ) { unichar_t *res = galloc((u_strlen(path)-test->olen+u_strlen(test->new)+1)*sizeof(unichar_t)); u_strcpy(res,test->new); u_strcat(res,path+test->olen); return( res ); } } return( NULL ); }
false
false
false
false
false
0
ffghad(fitsfile *fptr, /* I - FITS file pointer */ long *headstart, /* O - byte offset to beginning of CHDU */ long *datastart, /* O - byte offset to beginning of next HDU */ long *dataend, /* O - byte offset to beginning of next HDU */ int *status) /* IO - error status */ /* Return the address (= byte offset) in the FITS file to the beginning of the current HDU, the beginning of the data unit, and the end of the data unit. */ { LONGLONG shead, sdata, edata; if (*status > 0) return(*status); ffghadll(fptr, &shead, &sdata, &edata, status); if (headstart) { if (shead > LONG_MAX) *status = NUM_OVERFLOW; else *headstart = (long) shead; } if (datastart) { if (sdata > LONG_MAX) *status = NUM_OVERFLOW; else *datastart = (long) sdata; } if (dataend) { if (edata > LONG_MAX) *status = NUM_OVERFLOW; else *dataend = (long) edata; } return(*status); }
false
false
false
false
false
0
hawki_distortion_correct_detector (cpl_image * image, cpl_image * dist_x, cpl_image * dist_y) { cpl_image * corr; cpl_vector * profile ; /* Test entries */ if (image == NULL) return NULL; if (dist_x == NULL) return NULL; if (dist_y == NULL) return NULL; /* Create the output image */ corr = cpl_image_new(cpl_image_get_size_x(image), cpl_image_get_size_y(image), CPL_TYPE_FLOAT) ; /* Create the interpolation profile */ profile = cpl_vector_new(CPL_KERNEL_DEF_SAMPLES) ; cpl_vector_fill_kernel_profile(profile, CPL_KERNEL_DEFAULT, CPL_KERNEL_DEF_WIDTH) ; /* Apply the distortion */ if (cpl_image_warp(corr, image, dist_x, dist_y, profile, CPL_KERNEL_DEF_WIDTH, profile, CPL_KERNEL_DEF_WIDTH) != CPL_ERROR_NONE) { cpl_msg_error(__func__, "Cannot warp the image") ; cpl_image_delete(corr) ; cpl_vector_delete(profile) ; return NULL; } cpl_vector_delete(profile) ; /* Return */ return corr; }
false
false
false
false
false
0
php_replace_in_subject(zval *regex, zval *replace, zval **subject, int *result_len, int limit, int is_callable_replace, int *replace_count TSRMLS_DC) { zval **regex_entry, **replace_entry = NULL, *replace_value, empty_replace; char *subject_value, *result; int subject_len; /* Make sure we're dealing with strings. */ convert_to_string_ex(subject); /* FIXME: This might need to be changed to STR_EMPTY_ALLOC(). Check if this zval could be dtor()'ed somehow */ ZVAL_STRINGL(&empty_replace, "", 0, 0); /* If regex is an array */ if (Z_TYPE_P(regex) == IS_ARRAY) { /* Duplicate subject string for repeated replacement */ subject_value = estrndup(Z_STRVAL_PP(subject), Z_STRLEN_PP(subject)); subject_len = Z_STRLEN_PP(subject); *result_len = subject_len; zend_hash_internal_pointer_reset(Z_ARRVAL_P(regex)); replace_value = replace; if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) zend_hash_internal_pointer_reset(Z_ARRVAL_P(replace)); /* For each entry in the regex array, get the entry */ while (zend_hash_get_current_data(Z_ARRVAL_P(regex), (void **)&regex_entry) == SUCCESS) { /* Make sure we're dealing with strings. */ convert_to_string_ex(regex_entry); /* If replace is an array and not a callable construct */ if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) { /* Get current entry */ if (zend_hash_get_current_data(Z_ARRVAL_P(replace), (void **)&replace_entry) == SUCCESS) { if (!is_callable_replace) { convert_to_string_ex(replace_entry); } replace_value = *replace_entry; zend_hash_move_forward(Z_ARRVAL_P(replace)); } else { /* We've run out of replacement strings, so use an empty one */ replace_value = &empty_replace; } } /* Do the actual replacement and put the result back into subject_value for further replacements. */ if ((result = php_pcre_replace(Z_STRVAL_PP(regex_entry), Z_STRLEN_PP(regex_entry), subject_value, subject_len, replace_value, is_callable_replace, result_len, limit, replace_count TSRMLS_CC)) != NULL) { efree(subject_value); subject_value = result; subject_len = *result_len; } else { efree(subject_value); return NULL; } zend_hash_move_forward(Z_ARRVAL_P(regex)); } return subject_value; } else { result = php_pcre_replace(Z_STRVAL_P(regex), Z_STRLEN_P(regex), Z_STRVAL_PP(subject), Z_STRLEN_PP(subject), replace, is_callable_replace, result_len, limit, replace_count TSRMLS_CC); return result; } }
false
false
false
false
false
0
feed_more(mpg123_handle *fr, const unsigned char *in, long count) { int ret = 0; if(VERBOSE3) debug("feed_more"); if((ret = bc_add(&fr->rdat.buffer, in, count)) != 0) { ret = READER_ERROR; if(NOQUIET) error1("Failed to add buffer, return: %i", ret); } else /* Not talking about filelen... that stays at 0. */ if(VERBOSE3) debug3("feed_more: %p %luB bufsize=%lu", fr->rdat.buffer.last->data, (unsigned long)fr->rdat.buffer.last->size, (unsigned long)fr->rdat.buffer.size); return ret; }
false
false
false
false
false
0
expand_builtin_return_addr (enum built_in_function fndecl_code, int count) { int i; #ifdef INITIAL_FRAME_ADDRESS_RTX rtx tem = INITIAL_FRAME_ADDRESS_RTX; #else rtx tem; /* For a zero count with __builtin_return_address, we don't care what frame address we return, because target-specific definitions will override us. Therefore frame pointer elimination is OK, and using the soft frame pointer is OK. For a nonzero count, or a zero count with __builtin_frame_address, we require a stable offset from the current frame pointer to the previous one, so we must use the hard frame pointer, and we must disable frame pointer elimination. */ if (count == 0 && fndecl_code == BUILT_IN_RETURN_ADDRESS) tem = frame_pointer_rtx; else { tem = hard_frame_pointer_rtx; /* Tell reload not to eliminate the frame pointer. */ crtl->accesses_prior_frames = 1; } #endif /* Some machines need special handling before we can access arbitrary frames. For example, on the SPARC, we must first flush all register windows to the stack. */ #ifdef SETUP_FRAME_ADDRESSES if (count > 0) SETUP_FRAME_ADDRESSES (); #endif /* On the SPARC, the return address is not in the frame, it is in a register. There is no way to access it off of the current frame pointer, but it can be accessed off the previous frame pointer by reading the value from the register window save area. */ #ifdef RETURN_ADDR_IN_PREVIOUS_FRAME if (fndecl_code == BUILT_IN_RETURN_ADDRESS) count--; #endif /* Scan back COUNT frames to the specified frame. */ for (i = 0; i < count; i++) { /* Assume the dynamic chain pointer is in the word that the frame address points to, unless otherwise specified. */ #ifdef DYNAMIC_CHAIN_ADDRESS tem = DYNAMIC_CHAIN_ADDRESS (tem); #endif tem = memory_address (Pmode, tem); tem = gen_frame_mem (Pmode, tem); tem = copy_to_reg (tem); } /* For __builtin_frame_address, return what we've got. But, on the SPARC for example, we may have to add a bias. */ if (fndecl_code == BUILT_IN_FRAME_ADDRESS) #ifdef FRAME_ADDR_RTX return FRAME_ADDR_RTX (tem); #else return tem; #endif /* For __builtin_return_address, get the return address from that frame. */ #ifdef RETURN_ADDR_RTX tem = RETURN_ADDR_RTX (count, tem); #else tem = memory_address (Pmode, plus_constant (tem, GET_MODE_SIZE (Pmode))); tem = gen_frame_mem (Pmode, tem); #endif return tem; }
false
false
false
false
false
0
CopyText(int length, const char *text) { SelectionText selectedText; selectedText.Copy(std::string(text, length), pdoc->dbcsCodePage, vs.styles[STYLE_DEFAULT].characterSet, false, false); CopyToClipboard(selectedText); }
false
false
false
false
false
0
GetFirstTag(const std::string& name) { if( object_reference.find(name) == object_reference.end() ) return AddTag(name); if( object_reference[name].begin() == object_reference[name].end() ) return AddTag(name); return **object_reference[name].begin(); }
false
false
false
false
false
0
command_list_mounts(client_t *client, int response) { DEBUG0("List mounts request"); if (response == PLAINTEXT) { snprintf (client->refbuf->data, PER_CLIENT_REFBUF_SIZE, "HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"); client->refbuf->len = strlen (client->refbuf->data); client->respcode = 200; client->refbuf->next = stats_get_streams (); fserve_add_client (client, NULL); } else { xmlDocPtr doc; avl_tree_rlock (global.source_tree); doc = admin_build_sourcelist(NULL); avl_tree_unlock (global.source_tree); admin_send_response(doc, client, response, LISTMOUNTS_TRANSFORMED_REQUEST); xmlFreeDoc(doc); } }
false
false
false
false
false
0
send_info_text(struct Client *source_p) { const char **text = infotext; while(*text) { sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), *text++); } sendto_one_numeric(source_p, RPL_INFO, form_str(RPL_INFO), ""); }
false
false
false
false
false
0
chooseScalarFunctionAlias(Node *funcexpr, char *funcname, Alias *alias, int nfuncs) { char *pname; /* * If the expression is a simple function call, and the function has a * single OUT parameter that is named, use the parameter's name. */ if (funcexpr && IsA(funcexpr, FuncExpr)) { pname = get_func_result_name(((FuncExpr *) funcexpr)->funcid); if (pname) return pname; } /* * If there's just one function in the RTE, and the user gave an RTE alias * name, use that name. (This makes FROM func() AS foo use "foo" as the * column name as well as the table alias.) */ if (nfuncs == 1 && alias) return alias->aliasname; /* * Otherwise use the function name. */ return funcname; }
false
false
false
false
false
0
mwifiex_interrupt_status(struct mwifiex_adapter *adapter) { struct sdio_mmc_card *card = adapter->card; u8 sdio_ireg; unsigned long flags; if (mwifiex_read_data_sync(adapter, card->mp_regs, card->reg->max_mp_regs, REG_PORT | MWIFIEX_SDIO_BYTE_MODE_MASK, 0)) { mwifiex_dbg(adapter, ERROR, "read mp_regs failed\n"); return; } sdio_ireg = card->mp_regs[card->reg->host_int_status_reg]; if (sdio_ireg) { /* * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS * For SDIO new mode CMD port interrupts * DN_LD_CMD_PORT_HOST_INT_STATUS and/or * UP_LD_CMD_PORT_HOST_INT_STATUS * Clear the interrupt status register */ mwifiex_dbg(adapter, INTR, "int: sdio_ireg = %#x\n", sdio_ireg); spin_lock_irqsave(&adapter->int_lock, flags); adapter->int_status |= sdio_ireg; spin_unlock_irqrestore(&adapter->int_lock, flags); } }
false
false
false
false
false
0
__pool_table_remove(struct pool *pool) { BUG_ON(!mutex_is_locked(&dm_thin_pool_table.mutex)); list_del(&pool->list); }
false
false
false
false
false
0
ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t offset) { ra_file_t *file = NULL; ra_local_t *local = NULL; ra_conf_t *conf = NULL; int op_errno = EINVAL; char expected_offset = 1; uint64_t tmp_file = 0; GF_ASSERT (frame); GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind); GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind); conf = this->private; gf_log (this->name, GF_LOG_TRACE, "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"", offset, size); fd_ctx_get (fd, this, &tmp_file); file = (ra_file_t *)(long)tmp_file; if (!file || file->disabled) { goto disabled; } if (file->offset != offset) { gf_log (this->name, GF_LOG_TRACE, "unexpected offset (%"PRId64" != %"PRId64") resetting", file->offset, offset); expected_offset = file->expected = file->page_count = 0; } else { gf_log (this->name, GF_LOG_TRACE, "expected offset (%"PRId64") when page_count=%d", offset, file->page_count); if (file->expected < (conf->page_size * conf->page_count)) { file->expected += size; file->page_count = min ((file->expected / file->page_size), conf->page_count); } } if (!expected_offset) { flush_region (frame, file, 0, file->pages.prev->offset + 1); } local = (void *) GF_CALLOC (1, sizeof (*local), gf_ra_mt_ra_local_t); if (!local) { op_errno = ENOMEM; goto unwind; } local->fd = fd; local->offset = offset; local->size = size; local->wait_count = 1; local->fill.next = &local->fill; local->fill.prev = &local->fill; pthread_mutex_init (&local->local_lock, NULL); frame->local = local; dispatch_requests (frame, file); flush_region (frame, file, 0, floor (offset, file->page_size)); read_ahead (frame, file); ra_frame_return (frame); file->offset = offset + size; return 0; unwind: STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL); return 0; disabled: STACK_WIND (frame, ra_readv_disabled_cbk, FIRST_CHILD (frame->this), FIRST_CHILD (frame->this)->fops->readv, fd, size, offset); return 0; }
false
false
false
true
false
1
slotReplaceText(const QString &text, int replacementIndex, int replacedLength, int matchedLength) { //kDebug() << "Replace: [" << text << "] ri:" << replacementIndex << " rl:" << replacedLength << " ml:" << matchedLength; QTextCursor tc = parent->textCursor(); tc.setPosition(replacementIndex); tc.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, matchedLength); tc.removeSelectedText(); tc.insertText(text.mid(replacementIndex, replacedLength)); if (replace->options() & KReplaceDialog::PromptOnReplace) { parent->setTextCursor(tc); parent->ensureCursorVisible(); } lastReplacedPosition = replacementIndex; }
false
false
false
false
false
0
gee_linked_list_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GEqualFunc equal_func) { GeeLinkedList * self = NULL; GEqualFunc _tmp0_ = NULL; GEqualFunc _tmp2_ = NULL; self = (GeeLinkedList*) gee_abstract_list_construct (object_type, g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func); self->priv->g_type = g_type; self->priv->g_dup_func = g_dup_func; self->priv->g_destroy_func = g_destroy_func; _tmp0_ = equal_func; if (_tmp0_ == NULL) { GEqualFunc _tmp1_ = NULL; _tmp1_ = gee_functions_get_equal_func_for (g_type); equal_func = _tmp1_; } _tmp2_ = equal_func; gee_linked_list_set_equal_func (self, _tmp2_); return self; }
false
false
false
false
false
0
gnc_date_cell_commit (DateCell *cell) { PopBox *box = cell->cell.gui_private; char buff[DATE_BUF]; if (!cell) return; gnc_parse_date (&(box->date), cell->cell.value); qof_print_date_dmy_buff (buff, MAX_DATE_LENGTH, box->date.tm_mday, box->date.tm_mon + 1, box->date.tm_year + 1900); gnc_basic_cell_set_value_internal (&cell->cell, buff); if (!box->date_picker) return; block_picker_signals (cell); gnc_date_picker_set_date (box->date_picker, box->date.tm_mday, box->date.tm_mon, box->date.tm_year + 1900); unblock_picker_signals (cell); }
false
false
false
false
false
0
parse_mode(uint32_t *mode, char *option_arg) { char *tok; char *arg = strdup(option_arg); if (!arg) return -1; for (tok = strtok(arg, ",|"); tok; tok = strtok(NULL, ",|")) { if (!strcmp(tok, "dstip")) *mode |= XT_HASHLIMIT_HASH_DIP; else if (!strcmp(tok, "srcip")) *mode |= XT_HASHLIMIT_HASH_SIP; else if (!strcmp(tok, "srcport")) *mode |= XT_HASHLIMIT_HASH_SPT; else if (!strcmp(tok, "dstport")) *mode |= XT_HASHLIMIT_HASH_DPT; else { free(arg); return -1; } } free(arg); return 0; }
false
false
false
false
false
0
VBE_UseHealth(const struct director *vdi) { struct vdi_simple *vs; ASSERT_CLI(); if (strcmp(vdi->name, "simple")) return; CAST_OBJ_NOTNULL(vs, vdi->priv, VDI_SIMPLE_MAGIC); if (vs->vrt->probe == NULL) return; VBP_Use(vs->backend, vs->vrt->probe); }
false
false
true
true
false
1
network_host(PG_FUNCTION_ARGS) { inet *ip = PG_GETARG_INET_P(0); text *ret; int len; char *ptr; char tmp[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; /* force display of max bits, regardless of masklen... */ if (inet_net_ntop(ip_family(ip), ip_addr(ip), ip_maxbits(ip), tmp, sizeof(tmp)) == NULL) ereport(ERROR, (errcode(ERRCODE_INVALID_BINARY_REPRESENTATION), errmsg("could not format inet value: %m"))); /* Suppress /n if present (shouldn't happen now) */ if ((ptr = strchr(tmp, '/')) != NULL) *ptr = '\0'; /* Return string as a text datum */ len = strlen(tmp); ret = (text *) palloc(len + VARHDRSZ); VARATT_SIZEP(ret) = len + VARHDRSZ; memcpy(VARDATA(ret), tmp, len); PG_RETURN_TEXT_P(ret); }
true
true
false
false
false
1
gnc_lot_set_account(GNCLot* lot, Account* account) { if (lot != NULL) { LotPrivate* priv; priv = GET_PRIVATE(lot); priv->account = account; } }
false
false
false
false
false
0
octstr_get_char(const Octstr *ostr, long pos) { seems_valid(ostr); if (pos >= ostr->len || pos < 0) return -1; return ostr->data[pos]; }
false
false
false
false
false
0
HDF5ListGroupObjects( HDF5GroupObjects *poRootGroup, int bSUBDATASET ) { char szTemp[8192]; char szDim[8192]; HDF5Dataset *poDS; poDS=this; if( poRootGroup->nbObjs >0 ) for( hsize_t i=0; i < poRootGroup->nbObjs; i++ ) { poDS->HDF5ListGroupObjects( poRootGroup->poHchild+i, bSUBDATASET ); } if( poRootGroup->nType == H5G_GROUP ) { CreateMetadata( poRootGroup, H5G_GROUP ); } /* -------------------------------------------------------------------- */ /* Create Sub dataset list */ /* -------------------------------------------------------------------- */ if( (poRootGroup->nType == H5G_DATASET ) && bSUBDATASET && poDS->GetDataType( poRootGroup->native ) == GDT_Unknown ) { CPLDebug( "HDF5", "Skipping unsupported %s of type %s", poRootGroup->pszUnderscorePath, poDS->GetDataTypeName( poRootGroup->native ) ); } else if( (poRootGroup->nType == H5G_DATASET ) && bSUBDATASET ) { CreateMetadata( poRootGroup, H5G_DATASET ); szDim[0]='\0'; switch( poRootGroup->nRank ) { case 3: sprintf( szTemp,"%dx%dx%d", (int)poRootGroup->paDims[0], (int)poRootGroup->paDims[1], (int)poRootGroup->paDims[2] ); break; case 2: sprintf( szTemp,"%dx%d", (int)poRootGroup->paDims[0], (int)poRootGroup->paDims[1] ); break; default: return CE_None; } strcat( szDim,szTemp ); sprintf( szTemp, "SUBDATASET_%d_NAME", ++(poDS->nSubDataCount) ); poDS->papszSubDatasets = CSLSetNameValue( poDS->papszSubDatasets, szTemp, CPLSPrintf( "HDF5:\"%s\":%s", poDS->GetDescription(), poRootGroup->pszUnderscorePath ) ); sprintf( szTemp, "SUBDATASET_%d_DESC", poDS->nSubDataCount ); poDS->papszSubDatasets = CSLSetNameValue( poDS->papszSubDatasets, szTemp, CPLSPrintf( "[%s] %s (%s)", szDim, poRootGroup->pszUnderscorePath, poDS->GetDataTypeName ( poRootGroup->native ) ) ); } return CE_None; }
false
false
false
false
false
0
OGRSQLiteGetSpatialiteVersionNumber() { int v = 0; #ifdef HAVE_SPATIALITE if( bSpatialiteLoaded ) { v = (int)(( atof( spatialite_version() ) + 0.001 ) * 10.0); } #endif return v; }
false
false
false
false
false
0
buildGeometry() { _faces_.clear(); QList<sMarching_Square> cubos; sMarching_Square cubo; cubos = ejecutar(); // printf("Cubos: %d\n",cubos.count()); foreach(cubo,cubos) { //Puede que ahora sea innecesario cambiar el tipo... // if(cubo.tipo > 127){ // cubo.tipo = 255 - cubo.tipo; // } identificar_tipo(cubo); } }
false
false
false
false
false
0
nssov_escape(struct berval *src,struct berval *dst) { size_t pos=0; int i; /* go over all characters in source string */ for (i=0;i<src->bv_len;i++) { /* check if char will fit */ if (pos>=(dst->bv_len-4)) return -1; /* do escaping for some characters */ switch (src->bv_val[i]) { case '*': strcpy(dst->bv_val+pos,"\\2a"); pos+=3; break; case '(': strcpy(dst->bv_val+pos,"\\28"); pos+=3; break; case ')': strcpy(dst->bv_val+pos,"\\29"); pos+=3; break; case '\\': strcpy(dst->bv_val+pos,"\\5c"); pos+=3; break; default: /* just copy character */ dst->bv_val[pos++]=src->bv_val[i]; break; } } /* terminate destination string */ dst->bv_val[pos]='\0'; dst->bv_len = pos; return 0; }
false
true
false
false
false
1
cson_output_bool( cson_value const * src, cson_data_dest_f f, void * state ) { if( !f ) return cson_rc.ArgError; else { char const v = cson_value_get_bool(src); return f(state, v ? "true" : "false", v ? 4 : 5); } }
false
false
false
false
false
0
get_types(list<pair<pIIR_Expression, pIIR_Root> > &acl_expr_list, const pIIR_Type type) { vector<pair<pIIR_Type, pIIR_Type> > result; pIIR_Type basic_type = type; // Loop through all acl elements. Note that for each element an // appropriate entry is generated on the result list. list<pair<pIIR_Expression, pIIR_Root> >::iterator it = acl_expr_list.begin(); while (it != acl_expr_list.end ()) { // Remove an subtypes that only add resolution functions. basic_type = get_basic_type (basic_type); if (basic_type->is (IR_ARRAY_TYPE) || basic_type->is (IR_ARRAY_SUBTYPE)) { // Ok, the current acl element is an array index (or perhaps // a array range) pIIR_TypeList type_list = basic_type->is (IR_ARRAY_TYPE)? pIIR_ArrayType (basic_type)->index_types : pIIR_ArraySubtype (basic_type)->constraint; // Add as many pairs to the list as index values are stored // in acl_expr_list. However, stop if all dimensions of the // current array are processed. for (pIIR_TypeList tl = type_list; tl && (it != acl_expr_list.end ()); tl = tl->rest, it ++) result.push_back (pair<pIIR_Type, pIIR_Type> (basic_type, tl->first)); } else if (basic_type->is (IR_RECORD_TYPE) || basic_type->is (IR_RECORD_SUBTYPE)) { // Ok, the current acl element is an record type. First, get // base type (i.e., remove any resolution function subtypes) // of type. basic_type = get_base_type (basic_type); result.push_back (pair<pIIR_Type, pIIR_Type> (basic_type, basic_type)); } else // Should never happen! assert (false); } return result; }
false
false
false
false
false
0
regop (buf_t *ibuf, buf_t *obuf, vars_t *vars) { loc_t *result; /* ibuf->ptr points at the % */ putword (" ", obuf, 2); result = declare_check (ibuf->ptr, vars); if (!result) { result = declare (ibuf->ptr, vars); putword ("IREGISTER ", obuf, strlen ("IREGISTER ")); } /* Skip the % for printing. */ ibuf->ptr++; putword (ibuf->ptr, obuf, wordlen (ibuf->ptr)); putword (" = ", obuf, strlen (" = ")); /* Skip to function: increment to = sign, then look at first token past the = sign, which should be an instruction. */ ibuf->ptr = strchr (ibuf->ptr, '='); if (!ibuf->ptr) error ("Invalid statement."); ibuf->ptr++; skip_space (ibuf); if (xstrcmp (ibuf->ptr, "select", wordlen ("select"))) instr_select (ibuf, obuf, vars); else if (xstrcmp (ibuf->ptr, "icmp", wordlen ("icmp"))) instr_icmp (ibuf, obuf, vars); else instr_binop (ibuf, obuf, vars, result); }
false
false
false
false
false
0
fsnotify_remove_first_event(struct fsnotify_group *group) { struct fsnotify_event *event; BUG_ON(!mutex_is_locked(&group->notification_mutex)); pr_debug("%s: group=%p\n", __func__, group); event = list_first_entry(&group->notification_list, struct fsnotify_event, list); /* * We need to init list head for the case of overflow event so that * check in fsnotify_add_event() works */ list_del_init(&event->list); group->q_len--; return event; }
false
false
false
false
false
0
operator!() const { for (unsigned i=0; i<reg.size(); i++) if (reg[i]) return false; return true; }
false
false
false
false
false
0
titleLen() { ustring title = getFrame()->client()->windowTitle(); int tlen = title != null ? titleFont->textWidth(title) : 0; return tlen; }
false
false
false
true
false
1
sendSetGain (unsigned char transducerNumber, unsigned char gain) { ArRobotPacket sendPacket(HEADER1, HEADER2); sendPacket.setID (SET_GAIN); sendPacket.uByteToBuf (transducerNumber); sendPacket.uByteToBuf (gain); if (!mySender->sendPacket(&sendPacket)) { ArLog::log (ArLog::Terse, "%s::sendSetGain() Could not send set gain request to Sonar", getNameWithBoard()); return false; } IFDEBUG ( ArLog::log (ArLog::Normal, "%s::sendSetGain() set gain sent to Sonar 0x%x 0x%x", getNameWithBoard(), transducerNumber, gain); ); // end IFDEBUG return true; }
false
false
false
false
false
0
movactor(void) #else static void movactor() #endif { ScrElem *scr; StepElem *step; ActElem *act = (ActElem *) &acts[cur.act-ACTMIN]; cur.loc = where(cur.act); if (cur.act == HERO) { parse(); fail = FALSE; /* fail only aborts one actor */ rules(); } else if (act->script != 0) { for (scr = (ScrElem *) addrTo(act->scradr); !endOfTable(scr); scr++) if (scr->code == act->script) { /* Find correct step in the list by indexing */ step = (StepElem *) addrTo(scr->steps); step = (StepElem *) &step[act->step]; /* Now execute it, maybe. First check wait count */ if (step->after > act->count) { /* Wait some more */ if (trcflg) { printf("\n<ACTOR %d, ", cur.act); debugsay(cur.act); printf(" (at "); debugsay(cur.loc); printf("), SCRIPT %ld, STEP %ld, Waiting %ld more>\n", act->script, act->step+1, step->after-act->count); } act->count++; rules(); return; } else act->count = 0; /* Then check possible expression */ if (step->exp != 0) { if (trcflg) { printf("\n<ACTOR %d, ", cur.act); debugsay(cur.act); printf(" (at "); debugsay(cur.loc); printf("), SCRIPT %ld, STEP %ld, Evaluating:>\n", act->script, act->step+1); } interpret(step->exp); if (!(Abool)pop()) { rules(); return; /* Hadn't happened yet */ } } /* OK, so finally let him do his thing */ act->step++; /* Increment step number before executing... */ if (trcflg) { printf("\n<ACTOR %d, ", cur.act); debugsay(cur.act); printf(" (at "); debugsay(cur.loc); printf("), SCRIPT %ld, STEP %ld, Executing:>\n", act->script, act->step); } interpret(step->stm); step++; /* ... so that we can see if he is USEing another script now */ if (act->step != 0 && endOfTable(step)) /* No more steps in this script, so stop him */ act->script = 0; fail = FALSE; /* fail only aborts one actor */ rules(); return; } syserr("Unknown actor script."); } else if (trcflg) { printf("\n<ACTOR %d, ", cur.act); debugsay(cur.act); printf(" (at "); debugsay(cur.loc); printf("), Idle>\n"); rules(); return; } }
false
false
false
false
false
0
do_qc2_regstore(struct net_t *np, struct qcval_t *qcvalp, struct xstk_t *xsp) { int32 nd_itpop, nd_xpop; struct xstk_t *xsp2; /* know lhs always entire reg but rhs may need select out */ /* rhsbi field is low bit of section from lhs concatenate if needed */ if (qcvalp->qcrhsbi != -1) { push_xstk_(xsp2, np->nwid); __rhspsel(xsp2->ap, xsp->ap, qcvalp->qcrhsbi, np->nwid); __rhspsel(xsp2->bp, xsp->bp, qcvalp->qcrhsbi, np->nwid); nd_xpop = TRUE;; } else { xsp2 = xsp; nd_xpop = FALSE; } if (qcvalp->lhsitp != NULL) { nd_itpop = TRUE; __push_itstk(qcvalp->lhsitp); } else nd_itpop = FALSE; /* emit debug tracing message if needed */ if (__debug_flg && __ev_tracing) { __tr_msg(" QC immediate store of %s into reg %s\n", __xregab_tostr(__xs2, xsp2->ap, xsp2->bp, xsp2->xslen, qcvalp->qcstp->st.sqca->qcrhsx), np->nsym->synam); } __chg_st_val(np, xsp2->ap, xsp2->bp); if (nd_xpop) __pop_xstk(); if (nd_itpop) __pop_itstk(); }
false
false
false
false
false
0