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
swallow_to_glyph(int mnum, int loc) { if (loc < S_sw_tl || S_sw_br < loc) { impossible("swallow_to_glyph: bad swallow location"); loc = S_sw_br; } return ((int) (what_mon(mnum)<<3) | (loc - S_sw_tl)) + GLYPH_SWALLOW_OFF; }
false
false
false
false
false
0
mpl_alloc(const struct mempool *mpl) { unsigned tsz; struct memitem *mi; CHECK_OBJ_NOTNULL(mpl, MEMPOOL_MAGIC); tsz = *mpl->cur_size; mi = calloc(sizeof *mi + tsz, 1); AN(mi); mi->magic = MEMITEM_MAGIC; mi->size = tsz; mpl->vsc->sz_wanted = tsz; mpl->vsc->sz_needed = tsz + sizeof *mi; return (mi); }
false
false
false
true
false
1
cert_RememberOCSPProcessingFailure(CERTOCSPCertID *certID, PRBool *certIDWasConsumed) { SECStatus rv = SECSuccess; PR_EnterMonitor(OCSP_Global.monitor); if (OCSP_Global.maxCacheEntries >= 0) { rv = ocsp_CreateOrUpdateCacheEntry(&OCSP_Global.cache, certID, NULL, certIDWasConsumed); } PR_ExitMonitor(OCSP_Global.monitor); return rv; }
false
false
false
false
false
0
zc_crk_bforce_start(struct zc_crk_bforce *crk, char *out_pw, size_t out_pw_size) { struct zc_key key; struct zc_key key_cache[out_pw_size]; size_t idem_char = 0; bool found = false; if (!out_pw || !is_valid_cracker(crk)) return -EINVAL; memset(&key_cache, 0, out_pw_size * sizeof(struct zc_key)); set_default_encryption_keys(key_cache); do { size_t lastidx = init_key_cache(crk->gen.pw, key_cache, idem_char); found = true; for (size_t i = 0; i < crk->vdata_size; ++i) { /* reset key to last key_cache entry */ key = key_cache[lastidx]; if (decrypt_header(crk->vdata[i].encryption_header, &key) == crk->vdata[i].magic) continue; found = false; break; } if (found) { memset(out_pw, 0, out_pw_size); strncpy(out_pw, crk->gen.pw, out_pw_size - 1); break; } pwgen_generate(&crk->gen, &idem_char); } while (crk->gen.pw); return found == true ? 0 : -1; }
false
false
false
false
false
0
pixel_status(GwyDataField *data_field, gint i, gint j) { if (data_field->data[j + data_field->xres * i] == 0) return 0; else return 1; }
false
false
false
false
false
0
gnucash_cursor_set_cell (GnucashCursor *cursor, gint cell_row, gint cell_col) { GnucashItemCursor *item_cursor; SheetBlockStyle *style; g_return_if_fail (cursor != NULL); g_return_if_fail (GNUCASH_IS_CURSOR (cursor)); item_cursor = GNUCASH_ITEM_CURSOR(cursor->cursor[GNUCASH_CURSOR_CELL]); style = cursor->style; if (cell_row < 0 || cell_row >= style->nrows || cell_col < 0 || cell_col >= style->ncols) return; item_cursor->row = cell_row; item_cursor->col = cell_col; }
false
false
false
false
false
0
load(istream* is, const SparseVector& sparseWeights) { FeatureArray entry; while (!is->eof()) { if (!is->good()) { cerr << "ERROR FeatureData::load inFile.good()" << endl; } entry.clear(); entry.load(is, sparseWeights); if (entry.size() == 0) break; if (size() == 0) setFeatureMap(entry.Features()); add(entry); } }
false
false
false
false
false
0
SCGetObjectValue(CmdSet &Set) { WorldSession *ws = ((PseuInstance*)parentMethod)->GetWSession(); if(!ws) { logerror("Invalid Script call: SCGetObjectValue: WorldSession not valid"); DEF_RETURN_ERROR; } uint64 guid = DefScriptTools::toUint64(Set.defaultarg); Object *o = ws->objmgr.GetObj(guid); if(o) { uint32 v = (uint32)DefScriptTools::toUint64(Set.arg[0]); if(v > o->GetValuesCount()) { logerror("SCGetObjectValue ["I64FMTD", type %u]: invalid value index: %u",guid,o->GetTypeId(),v); return ""; } else { if(DefScriptTools::stringToLower(Set.arg[1]) == "f") return toString((ldbl)o->GetFloatValue((UpdateFieldName)v)); else if(DefScriptTools::stringToLower(Set.arg[1]) == "i64") return toString(o->GetUInt64Value((UpdateFieldName)v)); else return toString((uint64)o->GetUInt32Value((UpdateFieldName)v)); } } return ""; }
false
false
false
false
false
0
aes128rounds(const u32 rk[/*44*/], const u8 pt[16], u8 ct[16], int rounds, int start) { u32 s[4]; int i; s[0] = GETU32(pt ); s[1] = GETU32(pt + 4); s[2] = GETU32(pt + 8); s[3] = GETU32(pt + 12); for (i=0; i<rounds; i++) { aes128round(s, rk+4*(start+i)); } PUTU32(ct , s[0]); PUTU32(ct + 4 , s[1]); PUTU32(ct + 8 , s[2]); PUTU32(ct + 12, s[3]); }
false
false
false
false
false
0
fw_core_handle_bus_reset(struct fw_card *card, int node_id, int generation, int self_id_count, u32 *self_ids, bool bm_abdicate) { struct fw_node *local_node; unsigned long flags; /* * If the selfID buffer is not the immediate successor of the * previously processed one, we cannot reliably compare the * old and new topologies. */ if (!is_next_generation(generation, card->generation) && card->local_node != NULL) { fw_destroy_nodes(card); card->bm_retries = 0; } spin_lock_irqsave(&card->lock, flags); card->broadcast_channel_allocated = card->broadcast_channel_auto_allocated; card->node_id = node_id; /* * Update node_id before generation to prevent anybody from using * a stale node_id together with a current generation. */ smp_wmb(); card->generation = generation; card->reset_jiffies = get_jiffies_64(); card->bm_node_id = 0xffff; card->bm_abdicate = bm_abdicate; fw_schedule_bm_work(card, 0); local_node = build_tree(card, self_ids, self_id_count); update_topology_map(card, self_ids, self_id_count); card->color++; if (local_node == NULL) { fw_err(card, "topology build failed\n"); /* FIXME: We need to issue a bus reset in this case. */ } else if (card->local_node == NULL) { card->local_node = local_node; for_each_fw_node(card, local_node, report_found_node); } else { update_tree(card, local_node); } spin_unlock_irqrestore(&card->lock, flags); }
false
false
false
false
false
0
log_init(int level, const char *file) { loglvl = level; if (!file) logf = stderr; else { if ((logf = fopen(file, "a")) == NULL) { perror("error opening log file"); fprintf(stderr, "%s\n", "falling back to standard error"); logf = stderr; } } log_print(LOG_VERBOSE, "", "", "Logging initialized with level %s", log_lvlstr[level]); }
false
false
false
false
true
1
Listen(int backlog) { ASSERT(SOCK_STREAM == type_); ASSERT(CS_CLOSED == state_); if (local_addr_.IsAny()) { error_ = EINVAL; return -1; } ASSERT(NULL == listen_queue_); listen_queue_ = new ListenQueue; state_ = CS_CONNECTING; return 0; }
false
false
false
false
false
0
walk_kbnode( KBNODE root, KBNODE *context, int all ) { KBNODE n; do { if( !*context ) { *context = root; n = root; } else { n = (*context)->next; *context = n; } } while( !all && n && is_deleted_kbnode(n) ); return n; }
false
false
false
false
false
0
transfer_instant_pull(const char *path) { int res; char *pc, *pr; size_t p_len = strlen(path); bool path_equal = false; VERBOSE("instant_pulling %s", path); pthread_mutex_lock(&m_instant_pull); worker_block(); pr = remote_path2(path, p_len); pc = cache_path2(path, p_len); pthread_mutex_lock(&m_transfer); if (t_state.active) path_equal = !strcmp(path, t_state.job->path); pthread_mutex_unlock(&m_transfer); /* requested file is already being transfered (normally). just continue the transfer until it is finished */ if (path_equal) { /* continuing a running transfer() only works if !worker_blocked() */ worker_unblock(); do { res = transfer(NULL, NULL); } while (ONLINE && res == TRANSFER_OK); res = (res == TRANSFER_FINISH) ? 0 : 1; worker_block(); } else { res = copy_file(pr, pc); /* if copy_file failed, possibly because the file's directory didn't exist in the cache yet. create it and retry */ if (res && errno == ENOENT) { char *dir = dirname_r(path); if (dir) { transfer_pull_dir(dir); free(dir); res = copy_file(pr, pc); } } } worker_unblock(); copy_attrs(pr, pc); free(pr); free(pc); /* if copying failed, return error and dont set sync */ if (res) { ERROR("instant_pull on %s FAILED", path); pthread_mutex_unlock(&m_instant_pull); return -1; } /* file is in sync now */ job_delete(path, JOB_PULL); sync_set(path, 0); pthread_mutex_unlock(&m_instant_pull); return 0; }
false
false
false
false
false
0
sge_mirror_update_master_list_host_key(lList **list, const lDescr *list_descr, int key_nm, const char *key, sge_event_action action, lListElem *event) { lListElem *ep; sge_mirror_error ret; DENTER(TOP_LAYER, "sge_mirror_update_master_list_host_key"); ep = lGetElemHost(*list, key_nm, key); ret = sge_mirror_update_master_list(list, list_descr, ep, key, action, event); DRETURN(ret); }
false
false
false
false
false
0
AttackStart(Unit* pWho) { if (!pWho) { return; } if (m_creature->Attack(pWho, true)) { m_creature->AddThreat(pWho); m_creature->SetInCombatWith(pWho); pWho->SetInCombatWith(m_creature); if (IsCombatMovement()) { m_creature->GetMotionMaster()->MoveChase(pWho); } } }
false
false
false
false
false
0
xaw_key_unit_road_or_trade_route(Widget w, XEvent *event, String *argv, Cardinal *argc) { unit_list_iterate(get_units_in_focus(), punit) { if (unit_can_est_trade_route_here(punit)) { key_unit_trade_route(); } else { key_unit_road(); } } unit_list_iterate_end; }
false
false
false
false
false
0
writecell(std::ostream &os, node *root, int depth) { g_uintptr_t thiscell = 0 ; if (root == zeronode(depth)) return 0 ; if (depth == 2) { if (root->nw != 0) return (g_uintptr_t)(root->nw) ; } else { if (marked2(root)) return (g_uintptr_t)(root->next) ; unhash_node(root) ; mark2(root) ; } if (depth == 2) { int i, j ; unsigned int top, bot ; leaf *n = (leaf *)root ; thiscell = ++cellcounter ; root->nw = (node *)thiscell ; unpack8x8(n->nw, n->ne, n->sw, n->se, &top, &bot) ; for (j=7; (top | bot) && j>=0; j--) { int bits = (top >> 24) ; top = (top << 8) | (bot >> 24) ; bot = (bot << 8) ; for (i=0; bits && i<8; i++, bits = (bits << 1) & 255) if (bits & 128) os << '*' ; else os << '.' ; os << '$' ; } os << '\n' ; } else { g_uintptr_t nw = writecell(os, root->nw, depth-1) ; g_uintptr_t ne = writecell(os, root->ne, depth-1) ; g_uintptr_t sw = writecell(os, root->sw, depth-1) ; g_uintptr_t se = writecell(os, root->se, depth-1) ; thiscell = ++cellcounter ; root->next = (node *)thiscell ; os << depth+1 << ' ' << nw << ' ' << ne << ' ' << sw << ' ' << se << '\n'; } return thiscell ; }
false
false
false
false
false
0
shrink_cb (GtkButton *button, VgRuleEditor *editor) { int i; if (editor->callers->len == 1) return; i = editor->callers->len - 1; gtk_widget_destroy (editor->callers->pdata[i]); g_ptr_array_remove_index (editor->callers, editor->callers->len - 1); }
false
false
false
false
false
0
print_pids(guint64 which, guint64 arg) { pid_t *pids; unsigned i; glibtop_proclist buf; pids = glibtop_get_proclist(&buf, which, arg); printf("glibtop_get_proclist(%#llx, %llu) -> %lu processes\n", which, arg, (unsigned long)buf.number); for (i = 0; i < buf.number; ++i) printf("%u ", pids[i]); putchar('\n'); putchar('\n'); g_free(pids); }
false
false
false
false
false
0
SeekToLast() { for (int i = 0; i < n_; i++) { children_[i].SeekToLast(); } FindLargest(); direction_ = kReverse; }
false
false
false
false
false
0
output_state_ainsn_table (state_ainsn_table_t tab, char *table_name, void (*output_full_vect_name_func) (FILE *, automaton_t), void (*output_comb_vect_name_func) (FILE *, automaton_t), void (*output_check_vect_name_func) (FILE *, automaton_t), void (*output_base_vect_name_func) (FILE *, automaton_t)) { if (!comb_vect_p (tab)) { fprintf (output_file, "/* Vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_comb_vect_el_value, tab->max_comb_vect_el_value); fprintf (output_file, " "); (*output_full_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (VLA_HWINT_BEGIN (tab->full_vect), VLA_HWINT_LENGTH (tab->full_vect)); fprintf (output_file, "};\n\n"); } else { fprintf (output_file, "/* Comb vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_comb_vect_el_value, tab->max_comb_vect_el_value); fprintf (output_file, " "); (*output_comb_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] ATTRIBUTE_UNUSED = {\n"); output_vect (VLA_HWINT_BEGIN (tab->comb_vect), VLA_HWINT_LENGTH (tab->comb_vect)); fprintf (output_file, "};\n\n"); fprintf (output_file, "/* Check vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, 0, tab->automaton->achieved_states_num); fprintf (output_file, " "); (*output_check_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] = {\n"); output_vect (VLA_HWINT_BEGIN (tab->check_vect), VLA_HWINT_LENGTH (tab->check_vect)); fprintf (output_file, "};\n\n"); fprintf (output_file, "/* Base vector for %s. */\n", table_name); fprintf (output_file, "static const "); output_range_type (output_file, tab->min_base_vect_el_value, tab->max_base_vect_el_value); fprintf (output_file, " "); (*output_base_vect_name_func) (output_file, tab->automaton); fprintf (output_file, "[] = {\n"); output_vect (VLA_HWINT_BEGIN (tab->base_vect), VLA_HWINT_LENGTH (tab->base_vect)); fprintf (output_file, "};\n\n"); } }
false
false
false
false
false
0
inxsearch(int b, int g, int r) { int i, j, dist, a, bestd; int *p; int best; bestd = 1000; // biggest possible dist is 256*3 best = -1; i = netindex[g]; // index on g j = i-1; // start at netindex[g] and work outwards while ((i < netsize) || (j >= 0)) { if (i < netsize) { p = network[i]; dist = p[FI_RGBA_GREEN] - g; // inx key if (dist >= bestd) i = netsize; // stop iter else { i++; if (dist < 0) dist = -dist; a = p[FI_RGBA_BLUE] - b; if (a < 0) a = -a; dist += a; if (dist < bestd) { a = p[FI_RGBA_RED] - r; if (a<0) a = -a; dist += a; if (dist < bestd) { bestd = dist; best = p[3]; } } } } if (j >= 0) { p = network[j]; dist = g - p[FI_RGBA_GREEN]; // inx key - reverse dif if (dist >= bestd) j = -1; // stop iter else { j--; if (dist < 0) dist = -dist; a = p[FI_RGBA_BLUE] - b; if (a<0) a = -a; dist += a; if (dist < bestd) { a = p[FI_RGBA_RED] - r; if (a<0) a = -a; dist += a; if (dist < bestd) { bestd = dist; best = p[3]; } } } } } return best; }
false
false
false
false
false
0
ParseSEHRegisterNumber(unsigned &RegNo) { SMLoc startLoc = getLexer().getLoc(); if (getLexer().is(AsmToken::Percent)) { const MCRegisterInfo &MRI = getContext().getRegisterInfo(); SMLoc endLoc; unsigned LLVMRegNo; if (getParser().getTargetParser().ParseRegister(LLVMRegNo,startLoc,endLoc)) return true; #if 0 // FIXME: TargetAsmInfo::getCalleeSavedRegs() commits a serious layering // violation so this validation code is disabled. // Check that this is a non-volatile register. const unsigned *NVRegs = TAI.getCalleeSavedRegs(); unsigned i; for (i = 0; NVRegs[i] != 0; ++i) if (NVRegs[i] == LLVMRegNo) break; if (NVRegs[i] == 0) return Error(startLoc, "expected non-volatile register"); #endif int SEHRegNo = MRI.getSEHRegNum(LLVMRegNo); if (SEHRegNo < 0) return Error(startLoc,"register can't be represented in SEH unwind info"); RegNo = SEHRegNo; } else { int64_t n; if (getParser().ParseAbsoluteExpression(n)) return true; if (n > 15) return Error(startLoc, "register number is too high"); RegNo = n; } return false; }
false
false
false
false
false
0
WorkSuspend(char* url, char* name) { int iRetVal = 0; RESULT* pStateResult = state.lookup_result(url, name); if (pStateResult) { iRetVal = rpc.result_op((*pStateResult), "suspend"); } else { ForceCacheUpdate(); } return iRetVal; }
false
false
false
false
false
0
vxml_record_fatal_error(vxml_parser_t *vp, vxml_error_t error) { vp->error = error; vp->flags |= VXML_F_FATAL_ERROR; if (vp->options & VXML_O_FATAL) g_error("VXML fatal error: %s", vxml_strerror(error)); }
false
false
false
false
false
0
_e_border_cb_efreet_cache_update(void *data __UNUSED__, int ev_type __UNUSED__, void *ev __UNUSED__) { Eina_List *l; E_Border *bd; /* mark all borders for desktop/icon updates */ EINA_LIST_FOREACH(borders, l, bd) { if (bd->desktop) { efreet_desktop_free(bd->desktop); bd->desktop = NULL; } bd->changes.icon = 1; bd->changed = 1; } /* e_init_status_set(_("Desktop files scan done")); e_init_done(); */ return ECORE_CALLBACK_PASS_ON; }
false
false
false
false
false
0
quiesce_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata) { call_stub_t *stub = NULL; quiesce_local_t *local = NULL; local = frame->local; frame->local = NULL; if ((op_ret == -1) && (op_errno == ENOTCONN)) { /* Re-transmit (by putting in the queue) */ stub = fop_fgetxattr_stub (frame, default_fgetxattr_resume, local->fd, local->name, xdata); if (!stub) { STACK_UNWIND_STRICT (fgetxattr, frame, -1, ENOMEM, NULL, NULL); goto out; } gf_quiesce_enqueue (this, stub); goto out; } STACK_UNWIND_STRICT (fgetxattr, frame, op_ret, op_errno, dict, xdata); out: gf_quiesce_local_wipe (this, local); return 0; }
false
false
false
false
false
0
Curl_hash_init(struct curl_hash *h, int slots, curl_hash_dtor dtor) { int i; h->dtor = dtor; h->size = 0; h->slots = slots; h->table = (struct curl_llist **) malloc(slots * sizeof(struct curl_llist *)); if(h->table) { for (i = 0; i < slots; ++i) { h->table[i] = Curl_llist_alloc((curl_llist_dtor) hash_element_dtor); if(!h->table[i]) { while(i--) Curl_llist_destroy(h->table[i], NULL); free(h->table); return 1; /* failure */ } } return 0; /* fine */ } else return 1; /* failure */ }
false
false
false
false
false
0
gimplify_omp_workshare (tree *expr_p, gimple_seq *pre_p) { tree expr = *expr_p; gimple stmt; gimple_seq body = NULL; gimplify_scan_omp_clauses (&OMP_CLAUSES (expr), pre_p, ORT_WORKSHARE); gimplify_and_add (OMP_BODY (expr), &body); gimplify_adjust_omp_clauses (&OMP_CLAUSES (expr)); if (TREE_CODE (expr) == OMP_SECTIONS) stmt = gimple_build_omp_sections (body, OMP_CLAUSES (expr)); else if (TREE_CODE (expr) == OMP_SINGLE) stmt = gimple_build_omp_single (body, OMP_CLAUSES (expr)); else gcc_unreachable (); gimplify_seq_add_stmt (pre_p, stmt); }
false
false
false
false
false
0
qlcnic_sriov_vf_init_driver(struct qlcnic_adapter *adapter) { struct qlcnic_hardware_context *ahw = adapter->ahw; struct qlcnic_info nic_info; int err; err = qlcnic_sriov_get_vf_vport_info(adapter, &nic_info, 0); if (err) return err; ahw->max_mc_count = nic_info.max_rx_mcast_mac_filters; err = qlcnic_get_nic_info(adapter, &nic_info, ahw->pci_func); if (err) return -EIO; if (qlcnic_83xx_get_port_info(adapter)) return -EIO; qlcnic_sriov_vf_cfg_buff_desc(adapter); adapter->flags |= QLCNIC_ADAPTER_INITIALIZED; dev_info(&adapter->pdev->dev, "HAL Version: %d\n", adapter->ahw->fw_hal_version); ahw->physical_port = (u8) nic_info.phys_port; ahw->switch_mode = nic_info.switch_mode; ahw->max_mtu = nic_info.max_mtu; ahw->op_mode = nic_info.op_mode; ahw->capabilities = nic_info.capabilities; return 0; }
false
false
false
false
false
0
run_timer(Timer *) { uint32_t part = (_max_thresh - _min_thresh) / 2; uint32_t avg = _size.unscaled_average(); if (avg < _min_thresh + part && _max_p > ONE_HUNDREDTH) { _max_p = (_max_p * NINE_TENTHS) >> 16; } else if (avg > _max_thresh - part && _max_p < 0x8000) { uint32_t alpha = ONE_HUNDREDTH; if (alpha > _max_p/4) alpha = _max_p/4; _max_p = _max_p + alpha; } set_C1_and_C2(); _timer.reschedule_after_msec(ADAPTIVE_INTERVAL); }
false
false
false
false
false
0
serial_proxy_init(struct serial_adapter *adapter) { GKeyFile *config; GError *gerr = NULL; const char *file = CONFIGDIR "/serial.conf"; char **group_list; int i; config = g_key_file_new(); if (!g_key_file_load_from_file(config, file, 0, &gerr)) { error("Parsing %s failed: %s", file, gerr->message); g_error_free(gerr); g_key_file_free(config); return; } group_list = g_key_file_get_groups(config, NULL); for (i = 0; group_list[i] != NULL; i++) { char *group_str = group_list[i], *uuid_str, *address; int err; struct serial_proxy *prx; /* string length of "Proxy" is 5 */ if (strlen(group_str) < 5 || strncmp(group_str, "Proxy", 5)) continue; uuid_str = g_key_file_get_string(config, group_str, "UUID", &gerr); if (gerr) { DBG("%s: %s", file, gerr->message); g_error_free(gerr); g_key_file_free(config); g_strfreev(group_list); return; } address = g_key_file_get_string(config, group_str, "Address", &gerr); if (gerr) { DBG("%s: %s", file, gerr->message); g_error_free(gerr); g_key_file_free(config); g_free(uuid_str); g_strfreev(group_list); return; } err = register_proxy(adapter, uuid_str, address, &prx); if (err == -EINVAL) error("Invalid address."); else if (err == -EALREADY) DBG("Proxy already exists."); else if (err < 0) error("Proxy creation failed (%s)", strerror(-err)); else { err = enable_proxy(prx); if (err < 0) error("Proxy enable failed (%s)", strerror(-err)); } g_free(uuid_str); g_free(address); } g_strfreev(group_list); g_key_file_free(config); }
false
false
false
false
false
0
clear_s_newconf(void) { struct server_conf *server_p; rb_dlink_node *ptr; rb_dlink_node *next_ptr; RB_DLINK_FOREACH_SAFE(ptr, next_ptr, shared_conf_list.head) { /* ptr here is ptr->data->node */ rb_dlinkDelete(ptr, &shared_conf_list); free_remote_conf(ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, cluster_conf_list.head) { rb_dlinkDelete(ptr, &cluster_conf_list); free_remote_conf(ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, hubleaf_conf_list.head) { rb_dlinkDelete(ptr, &hubleaf_conf_list); free_remote_conf(ptr->data); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, oper_conf_list.head) { free_oper_conf(ptr->data); rb_dlinkDestroy(ptr, &oper_conf_list); } RB_DLINK_FOREACH_SAFE(ptr, next_ptr, server_conf_list.head) { server_p = ptr->data; if(!server_p->servers) { rb_dlinkDelete(ptr, &server_conf_list); free_server_conf(ptr->data); } else server_p->flags |= SERVER_ILLEGAL; } }
false
false
false
false
false
0
sd_start(struct gspca_dev *gspca_dev) { struct sd *sd = (struct sd *) gspca_dev; int ret, value; /* create the JPEG header */ jpeg_define(sd->jpeg_hdr, gspca_dev->pixfmt.height, gspca_dev->pixfmt.width, 0x22); /* JPEG 411 */ jpeg_set_qual(sd->jpeg_hdr, QUALITY); /* work on alternate 1 */ usb_set_interface(gspca_dev->dev, gspca_dev->iface, 1); set_par(gspca_dev, 0x10000000); set_par(gspca_dev, 0x00000000); set_par(gspca_dev, 0x8002e001); set_par(gspca_dev, 0x14000000); if (gspca_dev->pixfmt.width > 320) value = 0x8002e001; /* 640x480 */ else value = 0x4001f000; /* 320x240 */ set_par(gspca_dev, value); ret = usb_set_interface(gspca_dev->dev, gspca_dev->iface, gspca_dev->alt); if (ret < 0) { pr_err("set intf %d %d failed\n", gspca_dev->iface, gspca_dev->alt); gspca_dev->usb_err = ret; goto out; } reg_r(gspca_dev, 0x0630); rcv_val(gspca_dev, 0x000020); /* << (value ff ff ff ff) */ reg_r(gspca_dev, 0x0650); snd_val(gspca_dev, 0x000020, 0xffffffff); reg_w(gspca_dev, 0x0620, 0); reg_w(gspca_dev, 0x0630, 0); reg_w(gspca_dev, 0x0640, 0); reg_w(gspca_dev, 0x0650, 0); reg_w(gspca_dev, 0x0660, 0); set_par(gspca_dev, 0x09800000); /* Red ? */ set_par(gspca_dev, 0x0a800000); /* Green ? */ set_par(gspca_dev, 0x0b800000); /* Blue ? */ set_par(gspca_dev, 0x0d030000); /* Gamma ? */ /* start the video flow */ set_par(gspca_dev, 0x01000000); set_par(gspca_dev, 0x01000000); if (gspca_dev->usb_err >= 0) PDEBUG(D_STREAM, "camera started alt: 0x%02x", gspca_dev->alt); out: return gspca_dev->usb_err; }
false
false
false
false
false
0
AddLogLine( const wxString &file, int line, bool critical, DebugType /*type*/, const std::ostringstream &msg) { std::string s; if (critical) { s = "Critical message: "; } printf("%s(%d): %s%s\n", (const char *)unicode2char(file), line, s.c_str(), msg.str().c_str()); }
false
false
false
false
false
0
readPIR(struct ReadSeqVars *V) { char *sptr; /* load first line of entry */ while (!feof(V->f) && strncmp(V->buf, "ENTRY", 5) != 0) { SeqfileGetLine(V); } if (feof(V->f)) return; if (V->ssimode >= 0) V->r_off = V->ssioffset; if ((sptr = strtok(V->buf + 15, "\n\t ")) != NULL) { SetSeqinfoString(V->sqinfo, sptr, SQINFO_NAME); SetSeqinfoString(V->sqinfo, sptr, SQINFO_ID); } do { SeqfileGetLine(V); if (!feof(V->f) && strncmp(V->buf, "TITLE", 5) == 0) SetSeqinfoString(V->sqinfo, V->buf+15, SQINFO_DESC); else if (!feof(V->f) && strncmp(V->buf, "ACCESSION", 9) == 0) { if ((sptr = strtok(V->buf+15, " \t\n")) != NULL) SetSeqinfoString(V->sqinfo, sptr, SQINFO_ACC); } } while (! feof(V->f) && (strncmp(V->buf,"SEQUENCE", 8) != 0)); SeqfileGetLine(V); /* skip next line, coords */ readLoop(0, endPIR, V); /* reading a real PIR-CODATA database file, we keep the source coords */ V->sqinfo->start = 1; V->sqinfo->stop = V->seqlen; V->sqinfo->olen = V->seqlen; V->sqinfo->flags |= SQINFO_START | SQINFO_STOP | SQINFO_OLEN; /* get next line */ while (!feof(V->f) && strncmp(V->buf, "ENTRY", 5) != 0) { SeqfileGetLine(V); } }
false
false
false
false
false
0
cache_add(SSL *ssl, SSL_SESSION *sess) { struct tls_info *info=SSL_get_app_data(ssl); unsigned char buffer[BUFSIZ]; unsigned char *ucp; time_t timeout= (time_t)SSL_SESSION_get_time(sess) + SSL_SESSION_get_timeout(sess); void *session_id=(void *)sess->session_id; size_t session_id_len=sess->session_id_length; size_t sess_len=i2d_SSL_SESSION(sess, NULL); if (sizeof(timeout) + sizeof(session_id_len) + session_id_len + sess_len > sizeof(buffer)) { fprintf(stderr, "WARN: starttls.c: buffer not big enough to cache SSL_SESSION\n"); return (0); /* Too big */ } memcpy(buffer, &timeout, sizeof(timeout)); memcpy(buffer+sizeof(timeout), &session_id_len, sizeof(session_id_len)); memcpy(buffer+sizeof(timeout)+sizeof(session_id_len), session_id, session_id_len); ucp=buffer+sizeof(timeout)+ sizeof(session_id_len)+session_id_len; i2d_SSL_SESSION(sess, &ucp); if (tls_cache_add(info->tlscache, (char *)buffer, (size_t)(sizeof(timeout) + sizeof(session_id_len) + session_id_len + sess_len))) perror("ALERT: tls_cache_add: "); #ifdef TLSCACHEDEBUG fprintf(stderr, "INFO: TLSCACHE: added\n"); #endif return 0; }
true
true
false
false
false
1
rb_xfade_stream_dispose (GObject *object) { RBXFadeStream *sd = RB_XFADE_STREAM (object); rb_debug ("disposing stream %s", sd->uri); if (sd->decoder != NULL) { gst_object_unref (sd->decoder); sd->decoder = NULL; } if (sd->volume != NULL) { gst_object_unref (sd->volume); sd->volume = NULL; } if (sd->fader != NULL) { gst_object_unref (sd->fader); sd->fader = NULL; } if (sd->audioconvert != NULL) { gst_object_unref (sd->audioconvert); sd->audioconvert = NULL; } if (sd->audioresample != NULL) { gst_object_unref (sd->audioresample); sd->audioresample = NULL; } if (sd->player != NULL) { g_object_unref (sd->player); sd->player = NULL; } if (sd->tags != NULL) { rb_list_destroy_free (sd->tags, (GDestroyNotify) gst_tag_list_unref); sd->tags = NULL; } rb_xfade_stream_dispose_stream_data (sd); G_OBJECT_CLASS (rb_xfade_stream_parent_class)->dispose (object); }
false
false
false
false
false
0
azx_via_get_position(struct azx *chip, struct azx_dev *azx_dev) { unsigned int link_pos, mini_pos, bound_pos; unsigned int mod_link_pos, mod_dma_pos, mod_mini_pos; unsigned int fifo_size; link_pos = snd_hdac_stream_get_pos_lpib(azx_stream(azx_dev)); if (azx_dev->core.substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { /* Playback, no problem using link position */ return link_pos; } /* Capture */ /* For new chipset, * use mod to get the DMA position just like old chipset */ mod_dma_pos = le32_to_cpu(*azx_dev->core.posbuf); mod_dma_pos %= azx_dev->core.period_bytes; /* azx_dev->fifo_size can't get FIFO size of in stream. * Get from base address + offset. */ fifo_size = readw(azx_bus(chip)->remap_addr + VIA_IN_STREAM0_FIFO_SIZE_OFFSET); if (azx_dev->insufficient) { /* Link position never gather than FIFO size */ if (link_pos <= fifo_size) return 0; azx_dev->insufficient = 0; } if (link_pos <= fifo_size) mini_pos = azx_dev->core.bufsize + link_pos - fifo_size; else mini_pos = link_pos - fifo_size; /* Find nearest previous boudary */ mod_mini_pos = mini_pos % azx_dev->core.period_bytes; mod_link_pos = link_pos % azx_dev->core.period_bytes; if (mod_link_pos >= fifo_size) bound_pos = link_pos - mod_link_pos; else if (mod_dma_pos >= mod_mini_pos) bound_pos = mini_pos - mod_mini_pos; else { bound_pos = mini_pos - mod_mini_pos + azx_dev->core.period_bytes; if (bound_pos >= azx_dev->core.bufsize) bound_pos = 0; } /* Calculate real DMA position we want */ return bound_pos + mod_dma_pos; }
false
false
false
false
false
0
dump_udp(packet_t *pkt) { udp_header_t udp; service_func_t app_src; service_func_t app_dst; /* Set the layer */ set_layer(LAYER_TRANSPORT); /* Stats accounting */ stats_update(STATS_UDP); /* * Get the UDP header */ if (get_packet_bytes((u_int8_t *) &udp, pkt, 8) == 0) return; /* * Conversions */ udp.src = ntohs(udp.src); udp.dst = ntohs(udp.dst); udp.length = ntohs(udp.length); udp.checksum = ntohs(udp.checksum); /* * Minimal mode */ if (my_args->m && !my_args->t) { display_minimal_string("| UDP "); display_minimal((u_int8_t *) &udp.src, 2, DISP_DEC); display_minimal_string("->"); display_minimal((u_int8_t *) &udp.dst, 2, DISP_DEC); display_minimal_string(" "); } else if (!my_args->t) { /* announcement */ display_header_banner("UDP Header"); /* dump fields */ display_strmap("Source port", udp.src, port_map); display_strmap("Destination port", udp.dst, port_map); display("Length", (char *) &udp.length, 2, DISP_DEC); display("Checksum", (char *) &udp.checksum, 2, DISP_DEC); } /* Add state */ state_set_srcport(udp.src); state_set_dstport(udp.dst); /* dump the hex buffer */ if (!my_args->t) hexbuffer_flush(); /* * Let's try to decode the application from the port number. If both * match a decoder, we choose the lowest, assuming that the higher * one is probably ephemeral. */ app_src = port2func(udp.src); app_dst = port2func(udp.dst); if (app_src && app_dst) { if (udp.src < udp.dst) app_src(pkt); else app_dst(pkt); } else { if (app_src) app_src(pkt); else if (app_dst) app_dst(pkt); } return; }
false
false
false
false
false
0
select_next_imf(gpointer dialog) { GList *sel = NULL; GtkList *list; int index, len; GtkWidget *scw; GtkAdjustment *vadj; double nv; d3_printf("select next\n"); list = gtk_object_get_data(GTK_OBJECT(dialog), "image_file_list"); g_return_if_fail(list != NULL); sel = list->selection; if (sel == NULL) { gtk_list_select_item(list, 0); update_selected_status_label(dialog); return; } index = gtk_list_child_position(list, GTK_WIDGET(sel->data)); d3_printf("initial position is %d\n", index); /* we reuse sel here! */ sel = gtk_container_children(GTK_CONTAINER(list)); len = g_list_length(sel); g_list_free(sel); if (index + 1 < len) { gtk_list_unselect_all(list); index ++; gtk_list_select_item(list, index); } else if (index + 1 == len) { gtk_list_unselect_all(list); gtk_list_select_item(list, index); } scw = gtk_object_get_data(GTK_OBJECT(dialog), "scrolledwindow"); g_return_if_fail(scw != NULL); vadj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scw)); d3_printf("vadj at %.3f\n", vadj->value); if (len != 0) { nv = (vadj->upper + vadj->lower) * index / len - vadj->page_size / 2; clamp_double(&nv, vadj->lower, vadj->upper - vadj->page_size); gtk_adjustment_set_value(vadj, nv); d3_printf("vadj set to %.3f\n", vadj->value); } update_selected_status_label(dialog); }
false
false
false
false
false
0
dropRank2(t,alpha,n) /* Drop a (potentially) rank2 type */ Type t; Int alpha; Int n; { if (whatIs(t)==RANK2) { Cell r = fst(snd(t)); Int i = intOf(r); Type as = NIL; for (t=snd(snd(t)); i>0; i--) { Type a = arg(fun(t)); if (isPolyType(a)) a = dropRank1(a,alpha,n); as = fn(a,as); t = arg(t); } t = ap(RANK2,pair(r,revOnto(as,t))); } return t; }
false
false
false
false
false
0
joinPath(upath dir, upath name) { if (dir == null) return name; if (name.isAbsolute()) return name; return dir.relative(name); }
false
false
false
false
false
0
delAttachment(std::string filename) // att*.txt { restartAutosaveTimer(); std::vector<AttachmentButton *>::iterator b, e, p; b=attachmentList.begin(); e=attachmentList.end(); while (b != e) { p=b; AttachmentButton *a= *b++; if (a && a->getFilename() == filename) { a->erase(); bool needFocus=false; if (b != e && *b) (*b)->requestFocus(); else needFocus=true; delete a; unlink(filename.c_str()); *p=NULL; attachmentList.erase(p); resized(); if (needFocus) { if (attachmentList.size() > 0 && attachmentList[attachmentList.size()-1]) attachmentList[attachmentList.size()-1] ->requestFocus(); else newAttachment.requestFocus(); } break; } } }
false
false
false
false
false
0
get_word_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo) /* This version is for reading raw-word-format PGM files with any maxval */ { ppm_source_ptr source = (ppm_source_ptr) sinfo; register JSAMPROW ptr; register U_CHAR * bufferptr; register JSAMPLE *rescale = source->rescale; JDIMENSION col; if (! ReadOK(source->pub.input_file, source->iobuffer, source->buffer_width)) ERREXIT(cinfo, JERR_INPUT_EOF); ptr = source->pub.buffer[0]; bufferptr = source->iobuffer; for (col = cinfo->image_width; col > 0; col--) { register int temp; temp = UCH(*bufferptr++); temp |= UCH(*bufferptr++) << 8; *ptr++ = rescale[temp]; } return 1; }
false
false
false
false
false
0
php_disable_classes(TSRMLS_D) { char *s = NULL, *e; if (!*(INI_STR("disable_classes"))) { return; } e = PG(disable_classes) = strdup(INI_STR("disable_classes")); while (*e) { switch (*e) { case ' ': case ',': if (s) { *e = '\0'; zend_disable_class(s, e-s TSRMLS_CC); s = NULL; } break; default: if (!s) { s = e; } break; } e++; } if (s) { zend_disable_class(s, e-s TSRMLS_CC); } }
false
false
false
false
false
0
find_or_add_name(Names ** names, const char *str) { unsigned i; for (i = 0; i < (*names)->size; i++) if (!mystrcasecmp((*names)->names[i], str)) { /* old name */ return i; } if ((*names)->size == (*names)->max_size) { unsigned old_max = (*names)->max_size; Names *new = new_names(old_max * 2); unsigned i; for (i = 0; i < old_max; i++) new->names[i] = (*names)->names[i]; new->size = old_max; myfree((*names)->names, M_NAMES); myfree(*names, M_NAMES); *names = new; } (*names)->names[(*names)->size] = str_dup(str); return (*names)->size++; }
false
false
false
false
false
0
db_unescape_object(JCR *jcr, char *from, int32_t expected_len, POOLMEM **dest, int32_t *dest_len) { if (!from) { *dest[0] = 0; *dest_len = 0; return; } *dest = check_pool_memory_size(*dest, expected_len+1); base64_to_bin(*dest, expected_len+1, from, strlen(from)); *dest_len = expected_len; (*dest)[expected_len]=0; }
false
false
false
false
false
0
panel_action_button_set_type (PanelActionButton *button, PanelActionButtonType type) { g_return_if_fail (type > PANEL_ACTION_NONE && type < PANEL_ACTION_LAST); if (panel_action_get_is_deprecated (type)) return; if (type == button->priv->type) return; button->priv->type = type; if (actions [type].icon_name != NULL) button_widget_set_icon_name (BUTTON_WIDGET (button), actions [type].icon_name); panel_util_set_tooltip_text (GTK_WIDGET (button), _(actions [type].tooltip)); panel_a11y_set_atk_name_desc (GTK_WIDGET (button), _(actions [type].tooltip), NULL); panel_action_button_update_sensitivity (panel_lockdown_get (), button); }
false
false
false
false
false
0
asymmetric_key_generate_id(const void *val_1, size_t len_1, const void *val_2, size_t len_2) { struct asymmetric_key_id *kid; kid = kmalloc(sizeof(struct asymmetric_key_id) + len_1 + len_2, GFP_KERNEL); if (!kid) return ERR_PTR(-ENOMEM); kid->len = len_1 + len_2; memcpy(kid->data, val_1, len_1); memcpy(kid->data + len_1, val_2, len_2); return kid; }
false
false
false
false
false
0
transport_find_fn(const char *url, git_transport_cb *callback, void **param) { size_t i = 0; unsigned priority = 0; transport_definition *definition = NULL, *definition_iter; // First, check to see if it's an obvious URL, which a URL scheme for (i = 0; i < GIT_TRANSPORT_COUNT; ++i) { definition_iter = &transports[i]; if (strncasecmp(url, definition_iter->prefix, strlen(definition_iter->prefix))) continue; if (definition_iter->priority > priority) definition = definition_iter; } if (!definition) { /* still here? Check to see if the path points to a file on the local file system */ if ((git_path_exists(url) == 0) && git_path_isdir(url)) definition = &local_transport_definition; /* It could be a SSH remote path. Check to see if there's a : */ if (strrchr(url, ':')) definition = &dummy_transport_definition; /* SSH is an unsupported transport mechanism in this version of libgit2 */ } if (!definition) return -1; *callback = definition->fn; *param = definition->param; return 0; }
false
false
false
false
false
0
QueryGeometry(w, req, ret) Widget w; XtWidgetGeometry *req; XtWidgetGeometry *ret; { ICLabelWidget iclw = (ICLabelWidget)w; ret->request_mode = CWWidth | CWHeight; ret->width = iclw->iclabel.width + iclw->iclabel.hspace * 2; ret->height = iclw->iclabel.fontheight + iclw->iclabel.vspace * 2; if ((!(req->request_mode & CWWidth) || ret->width == req->width) && (!(req->request_mode & CWHeight) || ret->height == req->height)) { return XtGeometryYes; } else if (ret->width == iclw->core.width && ret->height == iclw->core.height) { return XtGeometryNo; } return XtGeometryAlmost; }
false
false
false
false
false
0
count_bound_coefficient_constraints(isl_ctx *ctx, struct isl_sched_graph *graph, int *n_eq, int *n_ineq) { int i; if (ctx->opt->schedule_max_coefficient == -1) return 0; for (i = 0; i < graph->n; ++i) *n_ineq += 2 * graph->node[i].nparam + 2 * graph->node[i].nvar; return 0; }
false
false
false
false
false
0
city_build_free_buildings(struct city *pcity) { struct player *pplayer; struct nation_type *nation; int i; bool has_small_wonders; fc_assert_ret(NULL != pcity); pplayer = city_owner(pcity); fc_assert_ret(NULL != pplayer); nation = nation_of_player(pplayer); fc_assert_ret(NULL != nation); if (pplayer->server.capital) { /* Already got it. */ return; } has_small_wonders = FALSE; /* Global free buildings. */ for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) { Impr_type_id n = game.rgame.global_init_buildings[i]; struct impr_type *pimprove; if (n == B_LAST) { break; } pimprove = improvement_by_number(n); city_add_improvement(pcity, pimprove); if (is_small_wonder(pimprove)) { has_small_wonders = TRUE; } fc_assert(!is_great_wonder(pimprove)); } /* Nation specific free buildings. */ for (i = 0; i < MAX_NUM_BUILDING_LIST; i++) { Impr_type_id n = nation->init_buildings[i]; struct impr_type *pimprove; if (n == B_LAST) { break; } pimprove = improvement_by_number(n); city_add_improvement(pcity, pimprove); if (is_small_wonder(pimprove)) { has_small_wonders = TRUE; } } pplayer->server.capital = TRUE; /* Update wonder infos. */ if (has_small_wonders) { send_game_info(NULL); /* No need to send to detached connections. */ send_player_info_c(pplayer, NULL); } else if (has_small_wonders) { /* No need to send to detached connections. */ send_player_info_c(pplayer, NULL); } }
false
false
false
false
true
1
Disengage() { if (!engaged_) return; // Stop receiving ticks. LOGGER->ticker_->ClearProfiler(); // Terminate the worker thread by setting running_ to false, // inserting a fake element in the queue and then wait for // the thread to terminate. running_ = false; TickSample sample; // Reset 'paused_' flag, otherwise semaphore may not be signalled. resume(); Insert(&sample); Join(); LOG(ISOLATE, UncheckedStringEvent("profiler", "end")); }
false
false
false
false
false
0
Jim_FreeTimeHandler(Jim_Interp *interp, Jim_TimeEvent *te) { if (te->finalizerProc) te->finalizerProc(interp, te->clientData); Jim_Free(te); }
false
false
false
false
false
0
git_fetch_download_pack(git_remote *remote, git_off_t *bytes, git_indexer_stats *stats) { if(!remote->need_pack) return 0; return remote->transport->download_pack(remote->transport, remote->repo, bytes, stats); }
false
false
false
false
false
0
writePeer(int fd, const char* buffer, int n) { int nbytes = write(fd,buffer,n); if (nbytes < 0) { ERROR2("[DS]: writePeer() error %d",errno); errnoDebug("[DS]: writePeer() write ",errno); // testing debug } return nbytes; }
false
false
false
false
false
0
parseJSON(char *filename) { FILE *fp; size_t fsize; char *fbuf; cJSON* json; if( (fp=fopen(filename, "rb")) == NULL ) { fprintf(stderr, "Error0: Couldn't open '%s' for reading\n", filename); return NULL; } if( fseek(fp,0,SEEK_END) == -1) { fprintf(stderr, "Error1: Couldn't determain filesize of '%s'\n", filename); return NULL; } else { /* Allocate memory for file */ if( (fsize=ftell(fp)) != 255 ) if( (fbuf = malloc(sizeof(char)*fsize)) == NULL ) { fprintf(stderr, "Error2: Couldn't allocate memory for '%s'\n", filename); return NULL; } rewind(fp); } if( fread(fbuf, sizeof(char), fsize, fp) != fsize ) { fprintf(stderr, "Error3: Couldn't copy '%s' to buffer\n", filename); return NULL; } fclose(fp); json=cJSON_Parse(fbuf); free(fbuf); return json; }
false
false
false
false
true
1
grsdef(void) { /* C----> C**** GRSDEF - Initial (default) setting of common area variables C for GRIBEX package. C C Purpose. C -------- C C Sets initial values for common area variables for all C routines of GRIBEX package, if not already done. C C** Interface. C ---------- C C CALL GRSDEF C C Input Parameters. C ----------------- C C None. C C Output Parameters. C ------------------ C C None. C C Method. C ------- C C Self-explanatory. C C Externals. C ---------- C C None. C C Reference. C ---------- C C See subroutine GRIBEX. C C Comments. C --------- C C None C C Author. C ------- C C J. Clochard, Meteo France, for ECMWF - March 1998. C C Modifications. C -------------- C C J. Clochard, Meteo France, for ECMWF - June 1999. C Add variable NSUBCE. C Use a static variable to determine if initialisation has already C been done. NUSER removed . C Reverse defaults for NEXT2O and NLOC2O, for consistency with C version 13.023 of software . C */ /* C ---------------------------------------------------------------- C* Section 0 . Definition of variables. C ---------------------------------------------------------------- */ char *envString; char *env_stream; static int lfirst = TRUE; extern int CGRIBEX_Const; if ( ! lfirst ) return; /* ---------------------------------------------------------------- Section 1 . Set values, conditionally. ---------------------------------------------------------------- */ /* Common area variables have not been set. Set them. User supplied reference value. */ fref = 0.0; /* Reference value supplied by user flag. Set to off. */ nfref = 0; /* User supplied maximum value. */ fmaxval = 0.0; /* Maximum value supplied by user flag. Set to off. */ nfmaxval = 0; /* Set rounding to 120 bytes on. */ nrnd = 1; /* Set GRIB calendar. */ if ( grib_calendar == -1 ) { grib_calendar = CALENDAR_PROLEPTIC; envString = getenv("GRIB_CALENDAR"); if ( envString ) { if ( strncmp(envString, "standard", 8) == 0 ) grib_calendar = CALENDAR_STANDARD; else if ( strncmp(envString, "proleptic", 9) == 0 ) grib_calendar = CALENDAR_PROLEPTIC; else if ( strncmp(envString, "360days", 7) == 0 ) grib_calendar = CALENDAR_360DAYS; else if ( strncmp(envString, "365days", 7) == 0 ) grib_calendar = CALENDAR_365DAYS; else if ( strncmp(envString, "366days", 7) == 0 ) grib_calendar = CALENDAR_366DAYS; else if ( strncmp(envString, "none", 4) == 0 ) grib_calendar = CALENDAR_NONE; } } /* Set debug print off. */ ndbg = 0; envString = getenv("GRIBEX_DEBUG"); if ( envString != NULL ) { if ( !strncmp(envString, "ON", 2) ) ndbg = 1; else if( *envString == '1') ndbg = 1; else if( *envString == '2') ndbg = 2; else ndbg = 0; } /* Set GRIBEX compatibility mode. */ envString = getenv("GRIB_GRIBEX_MODE_ON"); if ( envString != NULL ) { if ( atoi(envString) == 1 ) CGRIBEX_Const = 0; } /* Set GRIB value checking on. */ nvck = 1; envString = getenv("GRIBEX_CHECK"); if ( envString ) { if ( !strncmp(envString, "OFF", 3) ) nvck = 0; else nvck = 1; } /* See if output stream needs changing */ grprsm = stdout; env_stream = getenv("GRPRS_STREAM"); if ( env_stream ) { if ( isdigit((int) env_stream[0]) ) { int unit; unit = atoi(env_stream); if ( unit < 1 || unit > 99 ) Warning("Invalid number for GRPRS_STREAM: %d", unit); else if ( unit == 2 ) grprsm = stderr; else if ( unit == 6 ) grprsm = stdout; else { char filename[] = "unit.00"; sprintf(filename, "%2.2d", unit); grprsm = fopen(filename, "w"); if ( ! grprsm ) SysError("GRPRS_STREAM = %d", unit); } } else { if ( env_stream[0] ) { grprsm = fopen(env_stream, "w"); if ( ! grprsm ) SysError("GRPRS_STREAM = %s", env_stream); } } } /* Set P factor switch to default, user supplies the P factor. */ nonoff = 0; /* Set abort flag to NO abort */ noabort = 1; /* Mark common area values set by user. */ lfirst = FALSE; /* Exhaustive use of all possible second-order packing methods for HOPER='K'. Set to off. */ num2ok = 0; /* Use of extended second-order packing methods for grid-point encoding (HOPER='C' and 'K'). Set to on. */ next2o = 1; /* Use of non-local second-order packing methods for grid-point encoding (HOPER='C' and 'K'). Set to on. */ nloc2o = 1; /* Use of (all valid) sub-centre values for ECMWF fields encoding . encoding. Set to off. */ nsubce = 0; }
false
false
false
false
true
1
message_calc_anim_start_frame(int time, generic_anim *ani, int reverse) { float wave_time, anim_time; int start_frame; start_frame=0; // If no voice clip exists, start from beginning of anim if ( time <= 0 ) { return; } // convert time to seconds wave_time = time/1000.0f; anim_time = ani->total_time; // If voice clip is longer than anim, start from beginning of anim if ( wave_time >= (anim_time) ) { return; } float fps = ani->num_frames / ani->total_time; if ( reverse ) { start_frame = (ani->num_frames-1) - fl2i(fps * wave_time + 0.5f); } else { int num_frames_extra; num_frames_extra = fl2i(fps * (anim_time - wave_time) + 0.5f); if ( num_frames_extra > 0 ) { start_frame=rand()%num_frames_extra; } } if ( start_frame < 0 ) { Int3(); start_frame=0; } ani->current_frame = start_frame; ani->anim_time = start_frame / fps; }
false
false
false
false
false
0
gt_priorityqueue_delete_min(GtPriorityQueue *pq) { gt_assert(pq != NULL && !gt_priorityqueue_is_empty(pq)); if (pq->capacity < (unsigned long) GT_MINPQSIZE) { pq->minelement = pq->elements[--pq->numofelements]; gt_priorityqueue_checkorder(pq); } else { unsigned long idx, child; GtPriorityQueueElementType lastelement; pq->minelement = pq->elements[1]; lastelement = pq->elements[pq->numofelements--]; for (idx = 1UL; idx * 2 <= pq->numofelements; idx = child) { child = idx * 2; gt_assert(child > 0); if (child != pq->numofelements && pq->elements[child + 1].sortkey < pq->elements[child].sortkey) { child++; } if (lastelement.sortkey > pq->elements[child].sortkey) { pq->elements[idx] = pq->elements[child]; } else { break; } } gt_assert(idx > 0); pq->elements[idx] = lastelement; } return &pq->minelement; }
false
false
false
false
false
0
VLight_InitAnormTable (void) { int x, y; float angle; float sp, sy, cp, cy; for ( x = 0; x < VLIGHT_GRIDSIZE_X; x++ ) { angle = (x * 360 / VLIGHT_GRIDSIZE_X) * ( M_PI / 180.0f ); sy = sin(angle); cy = cos(angle); for ( y = 0; y < VLIGHT_GRIDSIZE_Y; y++ ) { angle = (y * 360 / VLIGHT_GRIDSIZE_X) * ( M_PI / 180.0f ); sp = sin(angle); cp = cos(angle); vlightgrid[x][y][0] = cp*cy; vlightgrid[x][y][1] = cp*sy; vlightgrid[x][y][2] = -sp; } } }
false
false
false
false
false
0
RecordCodeGeneration(Code* code, MacroAssembler* masm) { code->set_major_key(MajorKey()); PROFILE(CodeCreateEvent(Logger::STUB_TAG, code, GetName())); GDBJIT(AddCode(GDBJITInterface::STUB, GetName(), code)); Counters::total_stubs_code_size.Increment(code->instruction_size()); #ifdef ENABLE_DISASSEMBLER if (FLAG_print_code_stubs) { #ifdef DEBUG Print(); #endif code->Disassemble(GetName()); PrintF("\n"); } #endif }
false
false
false
false
false
0
osinfo_avatar_format_get_property(GObject *object, guint property_id, GValue *value, GParamSpec *pspec) { OsinfoAvatarFormat *avatar = OSINFO_AVATAR_FORMAT (object); switch (property_id) { case PROP_MIME_TYPES: { GList *mime_types; mime_types = osinfo_avatar_format_get_mime_types(avatar); g_value_set_pointer(value, mime_types); break; } case PROP_WIDTH: g_value_set_int(value, osinfo_avatar_format_get_width(avatar)); break; case PROP_HEIGHT: g_value_set_int(value, osinfo_avatar_format_get_height(avatar)); break; case PROP_ALPHA: g_value_set_boolean(value, osinfo_avatar_format_get_alpha(avatar)); break; default: /* We don't have any other property... */ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; } }
false
false
false
false
false
0
recordNameToType(const char *recordTypeName) { E_DirRecType recType = ERT_Private; if (recordTypeName != NULL) { short i = 0; while (i < DIM_OF_DRTypeNames && strcmp(DRTypeNames[i], recordTypeName) != 0) i++; if (i < DIM_OF_DRTypeNames && strcmp(DRTypeNames[i], recordTypeName) == 0) recType = OFstatic_cast(E_DirRecType, i); else if (strcmp(recordTypeName,"STRUCT REPORT") == 0) recType = ERT_SRDocument; // we recognise the old name as well DCMDATA_TRACE("DcmDirectoryRecord::recordNameToType() input char*=\"" << recordTypeName << "\" output enum=" << recType); } return recType; }
false
false
false
false
false
0
Indexdb_write_positions (char *positionsfile, char *gammaptrsfile, char *offsetscompfile, FILE *sequence_fp, IIT_T chromosome_iit, int offsetscomp_basesize, #ifdef PMAP int alphabet_size, int index1part_aa, bool watsonp, #else int index1part, #endif int index1interval, bool genome_lc_p, bool writefilep, char *fileroot, bool mask_lowercase_p) { FILE *positions_fp; /* For building positions in memory */ int positions_fd; /* For building positions in file */ Positionsptr_T *offsets = NULL, totalcounts; Genomicpos_T *positions; Oligospace_T oligospace; #ifdef PMAP offsets = Indexdb_offsets_from_gammas(gammaptrsfile,offsetscompfile,offsetscomp_basesize, alphabet_size,index1part_aa); oligospace = power(alphabet_size,index1part_aa); #else offsets = Indexdb_offsets_from_gammas(gammaptrsfile,offsetscompfile,offsetscomp_basesize,index1part); oligospace = power(4,index1part); #endif totalcounts = offsets[oligospace]; if (totalcounts == 0) { fprintf(stderr,"Something is wrong with the offsets file. Total counts is zero.\n"); exit(9); } if (writefilep == true) { fprintf(stderr,"User requested build of positions in file\n"); positions_fd = Access_fileio_rw(positionsfile); #ifdef PMAP compute_positions_in_file(positions_fd,offsets,sequence_fp,chromosome_iit, index1part_aa,watsonp,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #else compute_positions_in_file(positions_fd,offsets,sequence_fp,chromosome_iit, index1part,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #endif close(positions_fd); } else { fprintf(stderr,"Trying to allocate %u*%d bytes of memory...",totalcounts,(int) sizeof(Genomicpos_T)); positions = (Genomicpos_T *) CALLOC_NO_EXCEPTION(totalcounts,sizeof(Genomicpos_T)); if (positions == NULL) { fprintf(stderr,"failed. Building positions in file.\n"); positions_fd = Access_fileio_rw(positionsfile); #ifdef PMAP compute_positions_in_file(positions_fd,offsets,sequence_fp,chromosome_iit, index1part_aa,watsonp,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #else compute_positions_in_file(positions_fd,offsets,sequence_fp,chromosome_iit, index1part,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #endif close(positions_fd); } else { fprintf(stderr,"succeeded. Building positions in memory.\n"); if ((positions_fp = FOPEN_WRITE_BINARY(positionsfile)) == NULL) { fprintf(stderr,"Can't open file %s\n",positionsfile); exit(9); } #ifdef PMAP compute_positions_in_memory(positions,offsets,sequence_fp,chromosome_iit, index1part_aa,watsonp,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #else compute_positions_in_memory(positions,offsets,sequence_fp,chromosome_iit, index1part,index1interval,genome_lc_p,fileroot,mask_lowercase_p); #endif fprintf(stderr,"Writing %u genomic positions to file %s ...\n", totalcounts,positionsfile); FWRITE_UINTS(positions,totalcounts,positions_fp); fclose(positions_fp); FREE(positions); } } FREE(offsets); return; }
false
false
false
false
false
0
_length(Request& r, MethodParams& params) { const String& s=params.as_string(0, "text must not be code"); VImage& vimage=GET_SELF(r, VImage); r.write_no_lang(*new VInt(vimage.font().string_width(s))); }
false
false
false
false
false
0
FindOrCreate(const FontParameters &fp) { FontID ret = 0; FontMutexLock(); int hashFind = HashFont(fp); for (FontCached *cur = first; cur; cur = cur->next) { if ((cur->hash == hashFind) && cur->SameAs(fp)) { cur->usage++; ret = cur->fid; } } if (ret == 0) { FontCached *fc = new FontCached(fp); fc->next = first; first = fc; ret = fc->fid; } FontMutexUnlock(); return ret; }
false
false
false
false
false
0
decodeConsUInt8 (OOCTXT* pctxt, ASN1UINT8* pvalue, ASN1UINT lower, ASN1UINT upper) { ASN1UINT range_value, value; ASN1UINT adjusted_value; int stat = ASN_OK; /* Check for special case: if lower is 0 and upper is ASN1UINT_MAX, */ /* set range to ASN1UINT_MAX; otherwise to upper - lower + 1 */ range_value = (lower == 0 && upper == ASN1UINT_MAX) ? ASN1UINT_MAX : upper - lower + 1; if (lower != upper) { ASN1UINT range_bitcnt = 0; /* If range is <= 255, bit-field case (10.5.7a) */ if (range_value <= 255) { range_bitcnt = getUIntBitCount (range_value - 1); } /* If range is exactly 256, one-octet case (10.5.7b) */ else if (range_value == 256) { stat = decodeByteAlign (pctxt); if (stat != ASN_OK) return LOG_ASN1ERR (pctxt, stat); range_bitcnt = 8; } stat = decodeBits (pctxt, &adjusted_value, range_bitcnt); if (stat == ASN_OK) { value = adjusted_value + lower; if (value < lower || value > upper) stat = ASN_E_CONSVIO; *pvalue = (ASN1OCTET)value; } } else *pvalue = (ASN1OCTET)lower; return stat; }
false
false
false
false
false
0
IsInstalled() { if (mInstalled == eUnknown) { mInstalled = IsPluginInstalled() ? eTrue : eFalse; } return mInstalled == eTrue; }
false
false
false
false
false
0
bg_out(const string &fname) { ofstream o; o.open(fname.c_str()); if(o.fail()) { cerr << "error: could not open `" << fname << "` for writing" << endl; exit(1); } o << setfill('0') << setbase(16); o.setf(ios::uppercase); #define USECODE_INTRINSIC_PTR(NAME) std::string(__STRING(NAME)) std::string bgut[] = { #include "bgintrinsics.h" }; #undef USECODE_INTRINSIC_PTR o << "<intrinsics>" << endl; for(unsigned int i=0; i<0x100; i++) o << "\t<0x" << setw(2) << i << "> " << bgut[i] << "_" << setw(2) << i << " </>" << endl; o << "</>" << endl; o.close(); }
false
false
false
false
false
0
list_keynames(dns_view_t *view, dns_tsig_keyring_t *ring, isc_buffer_t *text, unsigned int *foundkeys) { char namestr[DNS_NAME_FORMATSIZE]; char creatorstr[DNS_NAME_FORMATSIZE]; isc_result_t result; dns_rbtnodechain_t chain; dns_name_t foundname; dns_fixedname_t fixedorigin; dns_name_t *origin; dns_rbtnode_t *node; dns_tsigkey_t *tkey; unsigned int n; const char *viewname; if (view != NULL) viewname = view->name; else viewname = "(global)"; dns_name_init(&foundname, NULL); dns_fixedname_init(&fixedorigin); origin = dns_fixedname_name(&fixedorigin); dns_rbtnodechain_init(&chain, ring->mctx); result = dns_rbtnodechain_first(&chain, ring->keys, &foundname, origin); if (result == ISC_R_NOTFOUND) { dns_rbtnodechain_invalidate(&chain); return (ISC_R_SUCCESS); } if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { dns_rbtnodechain_invalidate(&chain); return (result); } for (;;) { node = NULL; dns_rbtnodechain_current(&chain, &foundname, origin, &node); tkey = node->data; if (tkey != NULL) { (*foundkeys)++; dns_name_format(&tkey->name, namestr, sizeof(namestr)); if (tkey->generated) { dns_name_format(tkey->creator, creatorstr, sizeof(creatorstr)); n = snprintf((char *)isc_buffer_used(text), isc_buffer_availablelength(text), "view \"%s\"; type \"dynamic\"; key \"%s\"; creator \"%s\";\n", viewname, namestr, creatorstr); } else { n = snprintf((char *)isc_buffer_used(text), isc_buffer_availablelength(text), "view \"%s\"; type \"static\"; key \"%s\";\n", viewname, namestr); } if (n >= isc_buffer_availablelength(text)) { dns_rbtnodechain_invalidate(&chain); return (ISC_R_NOSPACE); } isc_buffer_add(text, n); } result = dns_rbtnodechain_next(&chain, &foundname, origin); if (result == ISC_R_NOMORE) break; if (result != ISC_R_SUCCESS && result != DNS_R_NEWORIGIN) { dns_rbtnodechain_invalidate(&chain); return (result); } } return (ISC_R_SUCCESS); }
false
false
false
false
false
0
eat_para_separator(const string& line, size_t start, GB_ERROR& error) { size_t para_sep = next_non_white(line, start); if (para_sep == string::npos) { error = "',' or ')' expected after parameter"; } else { switch (line[para_sep]) { case ')' : was_last_parameter = true; break; case ',' : break; default : error = "',' or ')' expected after parameter"; break; } if (!error) para_sep++; } return para_sep; }
false
false
false
false
false
0
apbps2_open(struct serio *io) { struct apbps2_priv *priv = io->port_data; int limit; unsigned long tmp; /* clear error flags */ iowrite32be(0, &priv->regs->status); /* Clear old data if available (unlikely) */ limit = 1024; while ((ioread32be(&priv->regs->status) & APBPS2_STATUS_DR) && --limit) tmp = ioread32be(&priv->regs->data); /* Enable reciever and it's interrupt */ iowrite32be(APBPS2_CTRL_RE | APBPS2_CTRL_RI, &priv->regs->ctrl); return 0; }
false
false
false
false
false
0
store_color_common(struct device *dev, const char *buf, int color) { struct i2c_client *client; struct blinkm_data *data; int ret; u8 value; client = to_i2c_client(dev); data = i2c_get_clientdata(client); ret = kstrtou8(buf, 10, &value); if (ret < 0) { dev_err(dev, "BlinkM: value too large!\n"); return ret; } switch (color) { case RED: data->next_red = value; break; case GREEN: data->next_green = value; break; case BLUE: data->next_blue = value; break; default: return -EINVAL; } dev_dbg(dev, "next_red = %d, next_green = %d, next_blue = %d\n", data->next_red, data->next_green, data->next_blue); /* if mode ... */ ret = blinkm_transfer_hw(client, BLM_GO_RGB); if (ret < 0) { dev_err(dev, "BlinkM: can't set RGB\n"); return ret; } return 0; }
false
false
false
false
false
0
pop_stack(hscriptlet *r, bytecode *value) { if (!r->it_stack) return empty_tc; bytecode code = &r->stack[--r->it_stack]; if (code->tc == int_tc) *value = code; else if (code->tc == real_tc) *value = code; else if (code->tc == string_tc) *value = code; return code->tc; }
false
false
false
false
false
0
_menu_cb_post(void *data, E_Menu *m __UNUSED__) { Instance *inst = data; if (inst) e_gadcon_locked_set(inst->gcc->gadcon, 0); if (!cpufreq_config->menu) return; e_object_del(E_OBJECT(cpufreq_config->menu)); cpufreq_config->menu = NULL; if (cpufreq_config->menu_poll) e_object_del(E_OBJECT(cpufreq_config->menu_poll)); cpufreq_config->menu_poll = NULL; if (cpufreq_config->menu_governor) e_object_del(E_OBJECT(cpufreq_config->menu_governor)); cpufreq_config->menu_governor = NULL; if (cpufreq_config->menu_frequency) e_object_del(E_OBJECT(cpufreq_config->menu_frequency)); cpufreq_config->menu_frequency = NULL; if (cpufreq_config->menu_powersave) e_object_del(E_OBJECT(cpufreq_config->menu_powersave)); cpufreq_config->menu_powersave = NULL; }
false
false
false
false
false
0
s48_read_char(FILE *port) { int result; while(1) { if (ferror(port) && errno == EINTR) { clearerr(port); result = getc(port); if (EOF != result) return result; } else return EOF; } }
false
true
false
false
true
1
xyzoptfunc(void *cntx, double *v) { clink *p = (clink *)cntx; double swxyz[3], jab[3], dev[MAX_CHAN]; double rv; int rc = 0; rv = 2.0 - v[0]; /* Make Y as large as possible */ /* If we wanted to use this function to maximise the brightness */ /* we would not limit the scale to 1.0 */ if (v[0] > 1.0) { rv += 1000.0; return rv; } if (v[0] < 0.0) { rv += 100.0; return rv; } swxyz[0] = v[0] * p->swxyz[0]; swxyz[1] = v[0] * p->swxyz[1]; swxyz[2] = v[0] * p->swxyz[2]; //printf("~1 scaled white XYZ = %f %f %f\n", swxyz[0], swxyz[1], swxyz[2]); if (p->pcsor == icxSigJabData) { /* We're being bad in delving inside the xluo, but we'll fix it latter */ p->out.luo->cam->XYZ_to_cam(p->out.luo->cam, jab, swxyz); } else error("Internal :- not setup to handle Y scaling and non-Jab PCS"); //printf("~1 scaled white Jab = %f %f %f\n", jab[0], jab[1], jab[2]); /* Run the target PCS backwards through the output space to see if it clips */ switch(p->out.alg) { case icmMonoBwdType: { icxLuMono *lu = (icxLuMono *)p->out.luo; /* Safe to coerce */ rc = lu->bwd_lookup(p->out.luo, dev, jab); break; } case icmMatrixBwdType: { icxLuMatrix *lu = (icxLuMatrix *)p->out.luo; /* Safe to coerce */ rc = lu->bwd_lookup(p->out.luo, dev, jab); break; } case icmLutType: { icxLuLut *lu = (icxLuLut *)p->out.luo; /* Safe to coerce */ if (p->mode < 2) /* Using B2A table */ rc = lu->lookup(p->out.luo, dev, jab); else /* Use inverse A2B table */ rc = lu->inv_lookup(p->out.luo, dev, jab); break; } default: error("Unexpected algorithm type %d in devop of devip_devop()",p->out.alg); } //printf("~1 device = %f %f %f, rc = %d\n", dev[0], dev[1], dev[2], rc); if (rc != 0) rv += 500.0; //printf("~1 xyzoptfunc rv %f from xyzscale %f\n\n",rv,v[0]); return rv; }
false
false
false
false
false
0
fftw_destroy_twiddle(fftw_twiddle * tw) { fftw_twiddle **p; --tw->refcnt; if (tw->refcnt == 0) { /* remove from the list of known twiddle factors */ for (p = &twlist; p; p = &((*p)->next)) if (*p == tw) { *p = tw->next; fftw_twiddle_size -= tw->n; fftw_free(tw->twarray); fftw_free(tw); return; } fftw_die("BUG in fftw_destroy_twiddle\n"); } }
false
false
false
false
false
0
intel_gmch_probe(struct pci_dev *bridge_pdev, struct pci_dev *gpu_pdev, struct agp_bridge_data *bridge) { int i, mask; /* * Can be called from the fake agp driver but also directly from * drm/i915.ko. Hence we need to check whether everything is set up * already. */ if (intel_private.driver) { intel_private.refcount++; return 1; } for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) { if (gpu_pdev) { if (gpu_pdev->device == intel_gtt_chipsets[i].gmch_chip_id) { intel_private.pcidev = pci_dev_get(gpu_pdev); intel_private.driver = intel_gtt_chipsets[i].gtt_driver; break; } } else if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) { intel_private.driver = intel_gtt_chipsets[i].gtt_driver; break; } } if (!intel_private.driver) return 0; intel_private.refcount++; #if IS_ENABLED(CONFIG_AGP_INTEL) if (bridge) { bridge->driver = &intel_fake_agp_driver; bridge->dev_private_data = &intel_private; bridge->dev = bridge_pdev; } #endif intel_private.bridge_dev = pci_dev_get(bridge_pdev); dev_info(&bridge_pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name); mask = intel_private.driver->dma_mask_size; if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(mask))) dev_err(&intel_private.pcidev->dev, "set gfx device dma mask %d-bit failed!\n", mask); else pci_set_consistent_dma_mask(intel_private.pcidev, DMA_BIT_MASK(mask)); if (intel_gtt_init() != 0) { intel_gmch_remove(); return 0; } return 1; }
false
false
false
false
false
0
mpd_qsset_ssize(mpd_t *result, mpd_ssize_t a, const mpd_context_t *ctx, uint32_t *status) { mpd_uint_t u; uint8_t sign = MPD_POS; if (a < 0) { if (a == MPD_SSIZE_MIN) { u = (mpd_uint_t)MPD_SSIZE_MAX + (-(MPD_SSIZE_MIN+MPD_SSIZE_MAX)); } else { u = -a; } sign = MPD_NEG; } else { u = a; } _ssettriple(result, sign, u, 0); mpd_qfinalize(result, ctx, status); }
false
false
false
false
false
0
each_with_parse (CSPARSE *parse, int cmd, char *arg) { NEOERR *err; CSTREE *node; char *lvar; char *p; char tmp[256]; err = alloc_node (&node, parse); if (err) return nerr_pass(err); node->cmd = cmd; if (arg[0] == '!') node->flags |= CSF_REQUIRED; arg++; p = lvar = neos_strip(arg); while (*p && !isspace(*p) && *p != '=') p++; if (*p == '\0') { dealloc_node(&node); return nerr_raise (NERR_PARSE, "%s Improperly formatted %s directive: %s", find_context(parse, -1, tmp, sizeof(tmp)), Commands[cmd].cmd, arg); } if (*p != '=') { *p++ = '\0'; while (*p && *p != '=') p++; if (*p == '\0') { dealloc_node(&node); return nerr_raise (NERR_PARSE, "%s Improperly formatted %s directive: %s", find_context(parse, -1, tmp, sizeof(tmp)), Commands[cmd].cmd, arg); } p++; } else { *p++ = '\0'; } while (*p && isspace(*p)) p++; if (*p == '\0') { dealloc_node(&node); return nerr_raise (NERR_PARSE, "%s Improperly formatted %s directive: %s", find_context(parse, -1, tmp, sizeof(tmp)), Commands[cmd].cmd, arg); } node->arg1.op_type = CS_TYPE_VAR; node->arg1.s = lvar; err = parse_expr(parse, p, 0, &(node->arg2)); if (err) { dealloc_node(&node); return nerr_pass(err); } /* ne_warn ("each %s %s", lvar, p); */ *(parse->next) = node; parse->next = &(node->case_0); parse->current = node; return STATUS_OK; }
false
false
false
true
false
1
LookInList(name_list *list_head, char *name, XClassHint *class) { name_list *nptr; /* look for the name first */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (match (nptr->name, name)) return (nptr->ptr); if (class) { /* look for the res_name next */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (match (nptr->name, class->res_name)) return (nptr->ptr); /* finally look for the res_class */ for (nptr = list_head; nptr != NULL; nptr = nptr->next) if (match (nptr->name, class->res_class)) return (nptr->ptr); } return (NULL); }
false
false
false
false
false
0
addscpcel( Column ) scpcol_list *Column; { scpcel_list *Cell; Cell = allocscpcel(); Cell->COL = Column; Cell->NEXT = Column->CELL; Cell->PREV = NULL; if ( Column->CELL != NULL ) { Column->CELL->PREV = Cell; } else { Column->LAST_CELL = Cell; } Column->CELL = Cell; Column->NUMBER_CELL++; return( Cell ); }
false
false
false
false
false
0
nv_split(char *buf, struct nv_pair *nv) { /* Get the name part */ char *ptr, *saved=NULL; nv->name = NULL; nv->value = NULL; ptr = audit_strsplit_r(buf, &saved); if (ptr == NULL) return 0; /* If there's nothing, go to next line */ if (ptr[0] == '#') return 0; /* If there's a comment, go to next line */ nv->name = ptr; /* Check for a '=' */ ptr = audit_strsplit_r(NULL, &saved); if (ptr == NULL) return 1; if (strcmp(ptr, "=") != 0) return 2; /* get the value */ ptr = audit_strsplit_r(NULL, &saved); if (ptr == NULL) return 1; nv->value = ptr; /* Make sure there's nothing else */ ptr = audit_strsplit_r(NULL, &saved); if (ptr) return 1; /* Everything is OK */ return 0; }
false
false
false
false
false
0
loadTrigger(fxStr& emsg) { if (sendQueuerACK(emsg, "T%s", (const char*) trigSpec) && fifoResponse.length() > 2) { tid = atoi(&fifoResponse[2]); return (true); } else return (false); }
false
false
false
false
false
0
polynomial_irreg_reg_nonans( int nin, double *xi, double *yi, int nout, double xo0, double dxo, int order) { double *tmpVals = NULL, *x = NULL, *y = NULL; int new_size = 0; KMCLIPM_TRY { remove_2nans(nin, xi, yi, &new_size, &x, &y); tmpVals = polynomial_irreg_reg(new_size, x, y, nout, xo0, dxo, order); cpl_free(x); cpl_free(y); } KMCLIPM_CATCH { } return tmpVals; }
false
false
false
false
false
0
tpo_process_waypoints(void) { unsigned int waypoint_count; unsigned int ii; //printf("Processing Waypoints...\n"); // Find block 0x0e0000 (GPS-Waypoints) if (tpo_find_block(0x0e0000)) { return; } // Read the number of waypoints. 8/16/32-bit value. waypoint_count = tpo_read_int(); //printf("Total Waypoints: %d\n", waypoint_count); // Fetch storage for the waypoint index (needed later for // routes) tpo_wp_index = (waypoint **)(char *) xmalloc(sizeof(waypoint *) * waypoint_count); if (waypoint_count == 0) { return; } // Read/process each waypoint in the file for (ii = 0; ii < waypoint_count; ii++) { waypoint* waypoint_temp; waypoint* waypoint_temp2; unsigned int name_length; char *waypoint_name; int lat; int lon; int altitude; //UNKNOWN DATA LENGTH (void)tpo_read_int(); // 0x00 //UNKNOWN DATA LENGTH (void)tpo_read_int(); // 0x00 //UNKNOWN DATA LENGTH // Fetch name length name_length = tpo_read_int(); //printf("\nName Length: %d\n", name_length); if (name_length) { waypoint_name = (char *) xmalloc(name_length+1); waypoint_name[0] = '\0'; gbfread(waypoint_name, 1, name_length, tpo_file_in); waypoint_name[name_length] = '\0'; // Terminator } else { // Assign a generic waypoint name waypoint_name = (char *) xmalloc(15); sprintf(waypoint_name, "WPT %d", ii+1); } //printf("\tWaypoint Name: %s\n", waypoint_name); //UNKNOWN DATA LENGTH (void)tpo_read_int(); lon = gbfgetint32(tpo_file_in); lat = gbfgetint32(tpo_file_in); // Allocate space for waypoint and store lat/lon waypoint_temp = tpo_convert_ll(lat, lon); // Assign the waypoint name waypoint_temp->shortname = waypoint_name; // Grab the altitude in meters altitude = gbfgetint32(tpo_file_in); if (altitude == 0xfffd000c) { // Unknown altitude altitude = 0; } waypoint_temp->altitude = altitude / 100; // Meters //printf("\tAltitude: %1.0f meters\n", waypoint_temp->altitude); //UNKNOWN DATA LENGTH // Fetch comment length name_length = tpo_read_int(); //printf("\tComment length: %d\n", name_length); if (name_length) { char *comment; comment = (char *) xmalloc(name_length+1); comment[0] = '\0'; gbfread(comment, 1, name_length, tpo_file_in); comment[name_length] = '\0'; // Terminator waypoint_temp->description = comment; //printf("\tComment: %s\n", waypoint_name); } else { // waypoint_temp->description = NULL; } // waypoint_temp->notes = NULL; // waypoint_temp->url = NULL; // waypoint_temp->url_link_text = NULL; // For routes (later), we need a duplicate of each waypoint // indexed by the order we read them in. waypoint_temp2 = waypt_dupe(waypoint_temp); // Attach the copy to our index tpo_wp_index[tpo_index_ptr++] = waypoint_temp2; // Add the original waypoint to the chain of waypoints waypt_add(waypoint_temp); //UNKNOWN DATA LENGTH // (void)tpo_read_int(); (void) gbfgetc(tpo_file_in); //UNKNOWN DATA LENGTH // (void)tpo_read_int(); (void) gbfgetc(tpo_file_in); //UNKNOWN DATA LENGTH // (void)tpo_read_int(); (void) gbfgetc(tpo_file_in); //UNKNOWN DATA LENGTH // (void)tpo_read_int(); (void) gbfgetc(tpo_file_in); } }
false
true
false
false
false
1
release() { free(const_cast<void*>(ptr)); delete this; }
false
false
false
false
false
0
obuf_putsnumw(obuf* out, long data, unsigned width, char pad, unsigned base, const char* digits) { int sign; sign = 0; if (data < 0) { sign = 1; data = -data; if (width) -- width; } if (data < (long)base) { if (width) { if (!obuf_sign_pad(out, sign, width-1, pad)) return 0; } else if (sign) if (!obuf_putc(out, '-')) return 0; return obuf_putc(out, data + '0'); } return obuf_putsnumw_rec(out, data, sign, width, pad, base, digits); }
false
false
false
false
false
0
lpfc_pci_resume_one_s4(struct pci_dev *pdev) { struct Scsi_Host *shost = pci_get_drvdata(pdev); struct lpfc_hba *phba = ((struct lpfc_vport *)shost->hostdata)->phba; uint32_t intr_mode; int error; lpfc_printf_log(phba, KERN_INFO, LOG_INIT, "0292 PCI device Power Management resume.\n"); /* Restore device state from PCI config space */ pci_set_power_state(pdev, PCI_D0); pci_restore_state(pdev); /* * As the new kernel behavior of pci_restore_state() API call clears * device saved_state flag, need to save the restored state again. */ pci_save_state(pdev); if (pdev->is_busmaster) pci_set_master(pdev); /* Startup the kernel thread for this host adapter. */ phba->worker_thread = kthread_run(lpfc_do_work, phba, "lpfc_worker_%d", phba->brd_no); if (IS_ERR(phba->worker_thread)) { error = PTR_ERR(phba->worker_thread); lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0293 PM resume failed to start worker " "thread: error=x%x.\n", error); return error; } /* Configure and enable interrupt */ intr_mode = lpfc_sli4_enable_intr(phba, phba->intr_mode); if (intr_mode == LPFC_INTR_ERROR) { lpfc_printf_log(phba, KERN_ERR, LOG_INIT, "0294 PM resume Failed to enable interrupt\n"); return -EIO; } else phba->intr_mode = intr_mode; /* Restart HBA and bring it online */ lpfc_sli_brdrestart(phba); lpfc_online(phba); /* Log the current active interrupt mode */ lpfc_log_intr_mode(phba, phba->intr_mode); return 0; }
false
false
false
false
false
0
checkSparkCountInvariant (void) { SparkCounters sparks = { 0, 0, 0, 0, 0, 0 }; StgWord64 remaining = 0; nat i; for (i = 0; i < n_capabilities; i++) { sparks.created += capabilities[i].spark_stats.created; sparks.dud += capabilities[i].spark_stats.dud; sparks.overflowed+= capabilities[i].spark_stats.overflowed; sparks.converted += capabilities[i].spark_stats.converted; sparks.gcd += capabilities[i].spark_stats.gcd; sparks.fizzled += capabilities[i].spark_stats.fizzled; remaining += sparkPoolSize(capabilities[i].sparks); } /* The invariant is * created = converted + remaining + gcd + fizzled */ debugTrace(DEBUG_sparks,"spark invariant: %ld == %ld + %ld + %ld + %ld " "(created == converted + remaining + gcd + fizzled)", sparks.created, sparks.converted, remaining, sparks.gcd, sparks.fizzled); return (sparks.created == sparks.converted + remaining + sparks.gcd + sparks.fizzled); }
false
false
false
false
false
0
set_peer_operational( n2n_edge_t * eee, const n2n_mac_t mac, const n2n_sock_t * peer ) { struct peer_info * prev = NULL; struct peer_info * scan; macstr_t mac_buf; n2n_sock_str_t sockbuf; traceEvent( TRACE_INFO, "set_peer_operational: %s -> %s", macaddr_str( mac_buf, mac), sock_to_cstr( sockbuf, peer ) ); scan=eee->pending_peers; while ( NULL != scan ) { if ( 0 == memcmp( scan->mac_addr, mac, N2N_MAC_SIZE ) ) { break; /* found. */ } prev = scan; scan = scan->next; } if ( scan ) { /* Remove scan from pending_peers. */ if ( prev ) { prev->next = scan->next; } else { eee->pending_peers = scan->next; } /* Add scan to known_peers. */ scan->next = eee->known_peers; eee->known_peers = scan; scan->sock = *peer; traceEvent( TRACE_DEBUG, "=== new peer %s -> %s", macaddr_str( mac_buf, scan->mac_addr), sock_to_cstr( sockbuf, &(scan->sock) ) ); traceEvent( TRACE_INFO, "Pending peers list size=%u", (unsigned int)peer_list_size( eee->pending_peers ) ); traceEvent( TRACE_INFO, "Operational peers list size=%u", (unsigned int)peer_list_size( eee->known_peers ) ); scan->last_seen = time(NULL); } else { traceEvent( TRACE_DEBUG, "Failed to find sender in pending_peers." ); } }
false
false
false
false
false
0
merge(void *priv, int (*cmp)(void *priv, struct flist_head *a, struct flist_head *b), struct flist_head *a, struct flist_head *b) { struct flist_head head, *tail = &head; while (a && b) { /* if equal, take 'a' -- important for sort stability */ if ((*cmp)(priv, a, b) <= 0) { tail->next = a; a = a->next; } else { tail->next = b; b = b->next; } tail = tail->next; } tail->next = a?:b; return head.next; }
false
false
false
false
false
0
getNumPoints() const { size_t numPoints = shell->getNumPoints(); for(size_t i=0, n=holes->size(); i<n; ++i) { const LinearRing* lr = dynamic_cast<const LinearRing *>((*holes)[i]); numPoints += lr->getNumPoints(); } return numPoints; }
false
false
false
false
false
0
connectTo(const char *host, int port) { char localhost[maxHostNameLen()]; myError = NoErr; myErrorStr.clear(); if (myFD < 0) return(false); if (!host) { if (gethostname(localhost, sizeof(localhost)) == 1) { myErrorStr="Failure to locate host '"; myErrorStr+=localhost; myErrorStr+="'"; ArLog::logErrorFromOS(ArLog::Normal, "ArSocket::connectTo: gethostname failed"); return(false); } host=localhost; } char useHost[1024]; int usePort; separateHost(host, port, useHost, sizeof(useHost), &usePort); bzero(&mySin, sizeof(mySin)); if (!hostAddr(useHost, mySin.sin_addr)) return(false); setRawIPString(); mySin.sin_family=AF_INET; mySin.sin_port=hostToNetOrder(usePort); return(connectTo(&mySin)); }
false
false
false
false
false
0
axnet_suspend(struct pcmcia_device *link) { struct net_device *dev = link->priv; if (link->open) netif_device_detach(dev); return 0; }
false
false
false
false
false
0