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
addFastRegAlloc(FunctionPass *RegAllocPass) { addPass(&PHIEliminationID, false); addPass(&TwoAddressInstructionPassID, false); if (RegAllocPass) addPass(RegAllocPass); }
false
false
false
false
false
0
parse_uint16(char *value, uint16_t *uint16) { int v; enum command_result result; result = parse_int(value, &v); if (result != command_success) return command_error; if (v < 0 || v > 0xffff) return command_error; *uint16 = v; return command_success; }
false
false
false
false
false
0
PyFFFont_Round(PyFF_Font *self, PyObject *args) { double factor=1; FontViewBase *fv = self->fv; SplineFont *sf = fv->sf; EncMap *map = fv->map; int i, gid; if ( !PyArg_ParseTuple(args,"|d",&factor ) ) return( NULL ); for ( i=0; i<map->enccount; ++i ) if ( (gid=map->map[i])!=-1 && sf->glyphs[gid]!=NULL && fv->selected[i] ) { SplineChar *sc = sf->glyphs[gid]; SCRound2Int( sc,fv->active_layer,factor); } Py_RETURN( self ); }
false
false
false
false
false
0
fill_buffer(aac_buffer *b) { int bread; if (b->bytes_consumed > 0) { if (b->bytes_into_buffer) { memmove((void*)b->buffer, (void*)(b->buffer + b->bytes_consumed), b->bytes_into_buffer*sizeof(unsigned char)); } if (!b->at_eof) { bread = fread((void*)(b->buffer + b->bytes_into_buffer), 1, b->bytes_consumed, b->infile); if (bread != b->bytes_consumed) b->at_eof = 1; b->bytes_into_buffer += bread; } b->bytes_consumed = 0; if (b->bytes_into_buffer > 3) { if (memcmp(b->buffer, "TAG", 3) == 0) b->bytes_into_buffer = 0; } if (b->bytes_into_buffer > 11) { if (memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) b->bytes_into_buffer = 0; } if (b->bytes_into_buffer > 8) { if (memcmp(b->buffer, "APETAGEX", 8) == 0) b->bytes_into_buffer = 0; } } return 1; }
false
false
false
false
false
0
scalarproduct_int16_c(int16_t * v1, int16_t * v2, int order, int shift) { int res = 0; while (order--) res += (*v1++ * *v2++) >> shift; return res; }
false
false
false
false
false
0
ks0127_init(struct v4l2_subdev *sd) { u8 *table = reg_defaults; int i; v4l2_dbg(1, debug, sd, "reset\n"); msleep(1); /* initialize all registers to known values */ /* (except STAT, 0x21, 0x22, TEST and 0x38,0x39) */ for (i = 1; i < 33; i++) ks0127_write(sd, i, table[i]); for (i = 35; i < 40; i++) ks0127_write(sd, i, table[i]); for (i = 41; i < 56; i++) ks0127_write(sd, i, table[i]); for (i = 58; i < 64; i++) ks0127_write(sd, i, table[i]); if ((ks0127_read(sd, KS_STAT) & 0x80) == 0) { v4l2_dbg(1, debug, sd, "ks0122s found\n"); return; } switch (ks0127_read(sd, KS_CMDE) & 0x0f) { case 0: v4l2_dbg(1, debug, sd, "ks0127 found\n"); break; case 9: v4l2_dbg(1, debug, sd, "ks0127B Revision A found\n"); break; default: v4l2_dbg(1, debug, sd, "unknown revision\n"); break; } }
false
false
false
false
false
0
do_matrix_peek(int *image, int row, int col, int en) { int n, h, shift, next_shift; int row_array_len = read_int(image, 0, en); int column_array_len; int cell_offset; /* find row */ if (row_array_len == 0) { return 0; } for (n = 0; ; n++) { h = hash(row, row_array_len, n); if (read_int(image, 2+ h * 2, en) == row) { shift = read_int(image, 2+h*2+1, en); break; } if (read_int(image, 2+ h * 2, en) == -1) { return 0; } if (n > MAX_FAILURE) { return 0; } } /* find shift count of next row */ if (h == row_array_len - 1) { /* last one */ next_shift = read_int(image, 1, en); } else { /* not last one */ next_shift = read_int(image, 2+h*2+2+1, en); } /* crammed width of this row */ column_array_len = next_shift - shift; /* cells in this image */ cell_offset = 2 + row_array_len * 2; for (n = 0; ; n++) { h = hash(col, column_array_len, n); if (read_int(image, cell_offset + shift * 2+ h * 2, en) == col) { return read_int(image, cell_offset + shift * 2 + h*2+1, en); } if (read_int(image, cell_offset + shift * 2+ h * 2, en) == -1) { /* not exist */ return 0; } if (n > MAX_FAILURE) { return 0; } } return 0; }
false
false
false
false
false
0
getCube( DdManager * manager, st_table * visited, DdNode * f, int cost) { DdNode *sol, *tmp; DdNode *my_dd, *T, *E; cuddPathPair *T_pair, *E_pair; int Tcost, Ecost; int complement; my_dd = Cudd_Regular(f); complement = Cudd_IsComplement(f); sol = one; cuddRef(sol); while (!cuddIsConstant(my_dd)) { Tcost = cost - 1; Ecost = cost - 1; T = cuddT(my_dd); E = cuddE(my_dd); if (complement) {T = Cudd_Not(T); E = Cudd_Not(E);} if (!st_lookup(visited, Cudd_Regular(T), &T_pair)) return(NULL); if ((Cudd_IsComplement(T) && T_pair->neg == Tcost) || (!Cudd_IsComplement(T) && T_pair->pos == Tcost)) { tmp = cuddBddAndRecur(manager,manager->vars[my_dd->index],sol); if (tmp == NULL) { Cudd_RecursiveDeref(manager,sol); return(NULL); } cuddRef(tmp); Cudd_RecursiveDeref(manager,sol); sol = tmp; complement = Cudd_IsComplement(T); my_dd = Cudd_Regular(T); cost = Tcost; continue; } if (!st_lookup(visited, Cudd_Regular(E), &E_pair)) return(NULL); if ((Cudd_IsComplement(E) && E_pair->neg == Ecost) || (!Cudd_IsComplement(E) && E_pair->pos == Ecost)) { tmp = cuddBddAndRecur(manager,Cudd_Not(manager->vars[my_dd->index]),sol); if (tmp == NULL) { Cudd_RecursiveDeref(manager,sol); return(NULL); } cuddRef(tmp); Cudd_RecursiveDeref(manager,sol); sol = tmp; complement = Cudd_IsComplement(E); my_dd = Cudd_Regular(E); cost = Ecost; continue; } (void) fprintf(manager->err,"We shouldn't be here!\n"); manager->errorCode = CUDD_INTERNAL_ERROR; return(NULL); } cuddDeref(sol); return(sol); }
false
false
false
false
false
0
gee_concurrent_list_node_try_mark (GeeConcurrentListNode* self) { g_return_if_fail (self != NULL); { gboolean _tmp0_ = FALSE; _tmp0_ = TRUE; while (TRUE) { gboolean _tmp1_ = FALSE; GeeConcurrentListNode* next_node = NULL; GeeConcurrentListNode* _tmp3_ = NULL; gboolean _result_ = FALSE; GeeConcurrentListNode* _tmp4_ = NULL; GeeConcurrentListNode* _tmp5_ = NULL; gboolean _tmp6_ = FALSE; gboolean _tmp7_ = FALSE; _tmp1_ = _tmp0_; if (!_tmp1_) { GeeConcurrentListState _tmp2_ = 0; _tmp2_ = gee_concurrent_list_node_get_state (self); if (!(_tmp2_ != GEE_CONCURRENT_LIST_STATE_MARKED)) { break; } } _tmp0_ = FALSE; _tmp3_ = gee_concurrent_list_node_get_next (self); next_node = _tmp3_; _tmp4_ = next_node; _tmp5_ = next_node; _tmp6_ = gee_concurrent_list_node_compare_and_exchange (self, _tmp4_, GEE_CONCURRENT_LIST_STATE_NONE, _tmp5_, GEE_CONCURRENT_LIST_STATE_MARKED); _result_ = _tmp6_; _tmp7_ = _result_; if (!_tmp7_) { GeeConcurrentListState state = 0; GeeConcurrentListState _tmp8_ = 0; GeeConcurrentListNode* _tmp9_ = NULL; GeeConcurrentListState _tmp10_ = 0; _tmp9_ = gee_concurrent_list_node_get_succ (self, &_tmp8_); state = _tmp8_; _gee_concurrent_list_node_unref0 (next_node); next_node = _tmp9_; _tmp10_ = state; if (_tmp10_ == GEE_CONCURRENT_LIST_STATE_FLAGGED) { GeeConcurrentListNode* _tmp11_ = NULL; _tmp11_ = next_node; gee_concurrent_list_node_help_flagged (self, _tmp11_); } } _gee_concurrent_list_node_unref0 (next_node); } } }
false
false
false
false
false
0
show_state(int) { ssp->show(stderr); if (config.hr_allocate_slots) { hr_info.show(stderr); } }
false
false
false
false
false
0
vnic_dev_init_devcmd1(struct vnic_dev *vdev) { vdev->devcmd = vnic_dev_get_res(vdev, RES_TYPE_DEVCMD, 0); if (!vdev->devcmd) return -ENODEV; vdev->devcmd_rtn = _vnic_dev_cmd; return 0; }
false
false
false
false
false
0
ntru_mult_int_64(NtruIntPoly *a, NtruIntPoly *b, NtruIntPoly *c, uint16_t modulus) { uint16_t N = a->N; if (N != b->N) return 0; if (modulus & (modulus-1)) /* check that modulus is a power of 2 */ return 0; c->N = N; ntru_mult_karatsuba_64((int16_t*)&a->coeffs, (int16_t*)&b->coeffs, (int16_t*)&c->coeffs, N, N, modulus); ntru_mod(c, modulus); return 1; }
false
false
false
false
false
0
fe_add_rawlog (server *serv, char *text, int len, int outbound) { char **split_text; char *new_text; int i; if (!serv->gui->rawlog_window) return; split_text = g_strsplit (text, "\r\n", 0); for (i = 0; i < g_strv_length (split_text); i++) { if (split_text[i][0] == 0) break; if (outbound) new_text = g_strconcat ("\0034<<\017 ", split_text[i], NULL); else new_text = g_strconcat ("\0033>>\017 ", split_text[i], NULL); gtk_xtext_append (GTK_XTEXT (serv->gui->rawlog_textlist)->buffer, new_text, strlen (new_text)); g_free (new_text); } g_strfreev (split_text); }
false
false
false
false
false
0
run() { uint16 raport = sConfig.GetIntDefault("Ra.Port", 3443); std::string stringip = sConfig.GetStringDefault("Ra.IP", "0.0.0.0"); ACE_INET_Addr listen_addr(raport, stringip.c_str()); if (m_Acceptor->open(listen_addr, m_Reactor, ACE_NONBLOCK) == -1) { sLog.outError("MaNGOS RA can not bind to port %d on %s", raport, stringip.c_str()); } sLog.outString("Starting Remote access listner on port %d on %s", raport, stringip.c_str()); while (!m_Reactor->reactor_event_loop_done()) { ACE_Time_Value interval(0, 10000); if (m_Reactor->run_reactor_event_loop(interval) == -1) break; if (World::IsStopped()) { m_Acceptor->close(); break; } } sLog.outString("RARunnable thread ended"); }
false
false
false
false
false
0
_add_connection(netsnmp_tcpconn_entry *entry, netsnmp_container *container) { tcpConnectionTable_rowreq_ctx *rowreq_ctx; DEBUGMSGTL(("tcpConnectionTable:access", "creating new entry\n")); /* * allocate an row context and set the index(es), then add it to * the container */ rowreq_ctx = tcpConnectionTable_allocate_rowreq_ctx(entry, NULL); if ((NULL != rowreq_ctx) && (MFD_SUCCESS == tcpConnectionTable_indexes_set(rowreq_ctx, entry->loc_addr_len, entry->loc_addr, entry->loc_addr_len, entry->loc_port, entry->rmt_addr_len, entry->rmt_addr, entry->rmt_addr_len, entry->rmt_port))) { if (CONTAINER_INSERT(container, rowreq_ctx)) { NETSNMP_LOGONCE((LOG_DEBUG, "Error inserting entry to tcpConnectionTable,"\ " entry already exists.\n")); tcpConnectionTable_release_rowreq_ctx(rowreq_ctx); } } else { if (rowreq_ctx) { snmp_log(LOG_ERR, "error setting index while loading " "tcpConnectionTable cache.\n"); tcpConnectionTable_release_rowreq_ctx(rowreq_ctx); } else { snmp_log(LOG_ERR, "memory allocation failed while loading " "tcpConnectionTable cache.\n"); netsnmp_access_tcpconn_entry_free(entry); } } }
false
false
false
false
false
0
__subn_set_opa_sl_to_sc(struct opa_smp *smp, u32 am, u8 *data, struct ib_device *ibdev, u8 port, u32 *resp_len) { struct hfi1_ibport *ibp = to_iport(ibdev, port); u8 *p = data; int i; if (am) { smp->status |= IB_SMP_INVALID_FIELD; return reply((struct ib_mad_hdr *)smp); } for (i = 0; i < ARRAY_SIZE(ibp->sl_to_sc); i++) ibp->sl_to_sc[i] = *p++; return __subn_get_opa_sl_to_sc(smp, am, data, ibdev, port, resp_len); }
false
false
false
false
false
0
main(argc, argv) int argc; char **argv; { if (argc != 3) exit(E_ARGCNT); dacport = atoi(argv[1]); /* obtain DAC port */ // printf(" FDD. Dacport (%d) \n", dacport); debug = atoi(argv[2]); host_list = NULL; host_end = NULL; hlist_cnt = 0; dachostid = sng_gethostid(); initFdd(); startFdd(); }
false
false
false
false
false
0
PyFFGlyphPen_lineTo(PyObject *self, PyObject *args) { SplineChar *sc = ((PyFF_GlyphPen *) self)->sc; int layer = ((PyFF_GlyphPen *) self)->layer; SplinePoint *sp; SplineSet *ss; double x,y; if ( ((PyFF_GlyphPen *) self)->ended ) { PyErr_Format(PyExc_EnvironmentError, "The lineTo operator must be preceded by a moveTo operator" ); return( NULL ); } if ( !PyArg_ParseTuple( args, "(dd)", &x, &y )) { PyErr_Clear(); if ( !PyArg_ParseTuple( args, "dd", &x, &y )) return( NULL ); } ss = sc->layers[layer].splines; sp = SplinePointCreate(x,y); SplineMake(ss->last,sp,sc->layers[layer].order2); ss->last = sp; Py_RETURN( self ); }
false
false
false
false
false
0
findProfile( const gchar *pnName ) { GList *psList = getProfiles(); struct sProfile *psProfile = NULL; while ( psList != NULL ) { psProfile = psList -> data; if ( psProfile != NULL ) { if ( !strcmp( psProfile -> pnName, pnName ) ) { return psProfile; } } psList = psList -> next; } return NULL; }
false
false
false
false
false
0
search_files_editor_loaded (SearchFiles* sf, IAnjutaEditor* editor) { search_box_set_search_string(sf->priv->search_box, sf->priv->last_search_string); if (sf->priv->last_replace_string) { search_box_set_replace_string(sf->priv->search_box, sf->priv->last_replace_string); search_box_set_replace(sf->priv->search_box, TRUE); } else { search_box_set_replace(sf->priv->search_box, FALSE); } search_box_toggle_case_sensitive(sf->priv->search_box, sf->priv->case_sensitive); search_box_toggle_highlight(sf->priv->search_box, TRUE); search_box_toggle_regex(sf->priv->search_box, sf->priv->regex); search_box_highlight_all(sf->priv->search_box); search_box_incremental_search(sf->priv->search_box, TRUE, TRUE, FALSE); gtk_widget_show (GTK_WIDGET(sf->priv->search_box)); }
false
false
false
false
false
0
kvm_vcpu_compat_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { struct kvm_vcpu *vcpu = filp->private_data; void __user *argp = compat_ptr(arg); int r; if (vcpu->kvm->mm != current->mm) return -EIO; switch (ioctl) { case KVM_SET_SIGNAL_MASK: { struct kvm_signal_mask __user *sigmask_arg = argp; struct kvm_signal_mask kvm_sigmask; compat_sigset_t csigset; sigset_t sigset; if (argp) { r = -EFAULT; if (copy_from_user(&kvm_sigmask, argp, sizeof(kvm_sigmask))) goto out; r = -EINVAL; if (kvm_sigmask.len != sizeof(csigset)) goto out; r = -EFAULT; if (copy_from_user(&csigset, sigmask_arg->sigset, sizeof(csigset))) goto out; sigset_from_compat(&sigset, &csigset); r = kvm_vcpu_ioctl_set_sigmask(vcpu, &sigset); } else r = kvm_vcpu_ioctl_set_sigmask(vcpu, NULL); break; } default: r = kvm_vcpu_ioctl(filp, ioctl, arg); } out: return r; }
false
false
false
false
false
0
ossl_rsa_to_text(VALUE self) { EVP_PKEY *pkey; BIO *out; VALUE str; GetPKeyRSA(self, pkey); if (!(out = BIO_new(BIO_s_mem()))) { ossl_raise(eRSAError, NULL); } if (!RSA_print(out, pkey->pkey.rsa, 0)) { /* offset = 0 */ BIO_free(out); ossl_raise(eRSAError, NULL); } str = ossl_membio2str(out); return str; }
false
false
false
false
false
0
FindName(const char* name, const kwsys_stl::vector<kwsys_stl::string>& userPaths, bool no_system_path) { // Add the system search path to our path first kwsys_stl::vector<kwsys_stl::string> path; if (!no_system_path) { SystemTools::GetPath(path, "CMAKE_FILE_PATH"); SystemTools::GetPath(path); } // now add the additional paths { for(kwsys_stl::vector<kwsys_stl::string>::const_iterator i = userPaths.begin(); i != userPaths.end(); ++i) { path.push_back(*i); } } // Add a trailing slash to all paths to aid the search process. { for(kwsys_stl::vector<kwsys_stl::string>::iterator i = path.begin(); i != path.end(); ++i) { kwsys_stl::string& p = *i; if(p.empty() || p[p.size()-1] != '/') { p += "/"; } } } // now look for the file kwsys_stl::string tryPath; for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin(); p != path.end(); ++p) { tryPath = *p; tryPath += name; if(SystemTools::FileExists(tryPath.c_str())) { return tryPath; } } // Couldn't find the file. return ""; }
false
false
false
false
false
0
SetCells(vtkIdType ncells, vtkIdTypeArray *cells) { if ( cells && cells != this->Ia ) { this->Modified(); this->Ia->Delete(); this->Ia = cells; this->Ia->Register(this); this->NumberOfCells = ncells; this->InsertLocation = cells->GetMaxId() + 1; this->TraversalLocation = 0; } }
false
false
false
false
false
0
unique_input_switch_destroy( UniqueInputSwitch *input_switch ) { int i; DirectLink *n; SwitchConnection *connection; UniqueContext *context; D_MAGIC_ASSERT( input_switch, UniqueInputSwitch ); context = input_switch->context; D_MAGIC_ASSERT( context, UniqueContext ); D_DEBUG_AT( UniQuE_InpSw, "unique_input_switch_destroy( %p )\n", input_switch ); direct_list_foreach_safe (connection, n, input_switch->connections) { D_MAGIC_ASSERT( connection, SwitchConnection ); purge_connection( input_switch, connection ); } D_ASSERT( input_switch->connections == NULL ); for (i=0; i<_UDCI_NUM; i++) { UniqueInputFilter *filter; UniqueInputTarget *target = &input_switch->targets[i]; direct_list_foreach_safe (filter, n, target->filters) { D_MAGIC_ASSERT( filter, UniqueInputFilter ); D_MAGIC_ASSERT( filter->channel, UniqueInputChannel ); D_DEBUG_AT( UniQuE_InpSw, " -> filter %p, index %d, channel %p\n", filter, filter->index, filter->channel ); direct_list_remove( &target->filters, &filter->link ); D_MAGIC_CLEAR( filter ); SHFREE( context->shmpool, filter ); } D_ASSERT( target->filters == NULL ); } D_MAGIC_CLEAR( input_switch ); SHFREE( context->shmpool, input_switch ); return DFB_OK; }
false
false
false
false
false
0
locks(Task_locker* tl) { if (this->member_ != NULL) tl->add(this, this->next_blocker_); }
false
false
false
false
false
0
dib8000_update_lna(struct dib8000_state *state) { u16 dyn_gain; if (state->cfg.update_lna) { // read dyn_gain here (because it is demod-dependent and not tuner) dyn_gain = dib8000_read_word(state, 390); if (state->cfg.update_lna(state->fe[0], dyn_gain)) { dib8000_restart_agc(state); return 1; } } return 0; }
false
false
false
false
false
0
mgdevice_OPENGL() { _mgf = mgopenglfuncs; if (_mgc != NULL && _mgc->devno != MGD_OPENGL) _mgc = NULL; return(0); }
false
false
false
false
false
0
il_write_targ_mem(struct il_priv *il, u32 addr, u32 val) { unsigned long reg_flags; spin_lock_irqsave(&il->reg_lock, reg_flags); if (likely(_il_grab_nic_access(il))) { _il_wr(il, HBUS_TARG_MEM_WADDR, addr); _il_wr(il, HBUS_TARG_MEM_WDAT, val); _il_release_nic_access(il); } spin_unlock_irqrestore(&il->reg_lock, reg_flags); }
false
false
false
false
false
0
murrine_draw_slider_path (cairo_t *cr, int x, int y, int width, int height, int roundness) { int radius = MIN (roundness, MIN (width/2.0, height/2.0)); cairo_move_to (cr, x+radius, y); cairo_arc (cr, x+width-radius, y+radius, radius, M_PI*1.5, M_PI*2); cairo_line_to (cr, x+width, y+height-width/2.0); cairo_line_to (cr, x+width/2.0, y+height); cairo_line_to (cr, x, y+height-width/2.0); cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5); }
false
false
false
false
false
0
phylogeneticTree(string* phylipName, string* clustalName, string* distName, string* nexusName, string pimName) { TreeNames treeNames; treeNames.clustalName = *clustalName; treeNames.distName = *distName; treeNames.nexusName = *nexusName; treeNames.phylipName = *phylipName; treeNames.pimName = pimName; TreeInterface tree; tree.treeFromAlignment(&treeNames, &alignmentObj); }
false
false
false
false
false
0
prune_extra_labels(struct rooted_tree *target_tree, struct hash *kept) { struct list_elem *el; for (el=target_tree->nodes_in_order->head; NULL != el; el=el->next) { struct rnode *current = el->data; char *label = current->label; if (0 == strcmp("", label)) continue; if (is_root(current)) continue; if (NULL == hash_get(kept, current->label)) { /* not in 'kept': remove */ struct rnode *unlink_root; enum unlink_rnode_status result = unlink_rnode(current); switch(result) { case UNLINK_RNODE_DONE: break; case UNLINK_RNODE_ROOT_CHILD: unlink_root = get_unlink_rnode_root_child(); unlink_root->parent = NULL; target_tree->root = unlink_root; break; case UNLINK_RNODE_ERROR: fprintf (stderr, "Memory error - " "exiting.\n"); exit(EXIT_FAILURE); default: assert(0); /* programmer error */ } } } /* Topology may have been altered: recompute nodes_in_order. */ destroy_llist(target_tree->nodes_in_order); target_tree->nodes_in_order = get_nodes_in_order(target_tree->root); }
false
false
false
false
false
0
nfs3_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label) { struct nfs3_diropargs arg = { .fh = NFS_FH(dir), .name = name->name, .len = name->len }; struct nfs3_diropres res = { .fh = fhandle, .fattr = fattr }; struct rpc_message msg = { .rpc_proc = &nfs3_procedures[NFS3PROC_LOOKUP], .rpc_argp = &arg, .rpc_resp = &res, }; int status; dprintk("NFS call lookup %s\n", name->name); res.dir_attr = nfs_alloc_fattr(); if (res.dir_attr == NULL) return -ENOMEM; nfs_fattr_init(fattr); status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); nfs_refresh_inode(dir, res.dir_attr); if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) { msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR]; msg.rpc_argp = fhandle; msg.rpc_resp = fattr; status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0); } nfs_free_fattr(res.dir_attr); dprintk("NFS reply lookup: %d\n", status); return status; }
false
false
false
false
false
0
glfwGetOSMesaContext(GLFWwindow* handle) { _GLFWwindow* window = (_GLFWwindow*) handle; _GLFW_REQUIRE_INIT_OR_RETURN(NULL); if (window->context.client == GLFW_NO_API) { _glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL); return NULL; } return window->context.osmesa.handle; }
false
false
false
false
false
0
distance(v1,v2) vertex_id v1,v2; { REAL *c1,*c2; REAL sum; int i; c1 = get_coord(v1); c2 = get_coord(v2); sum = 0.0; for ( i = 0 ; i < SDIM ; i++ ) sum += (c1[i] - c2[i])*(c1[i] - c2[i]); return sqrt(sum); }
false
false
false
false
false
0
qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport, int defer) { struct fc_rport *rport; scsi_qla_host_t *base_vha; unsigned long flags; if (!fcport->rport) return; rport = fcport->rport; if (defer) { base_vha = pci_get_drvdata(vha->hw->pdev); spin_lock_irqsave(vha->host->host_lock, flags); fcport->drport = rport; spin_unlock_irqrestore(vha->host->host_lock, flags); qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); qla2xxx_wake_dpc(base_vha); } else { int now; if (rport) fc_remote_port_delete(rport); qlt_do_generation_tick(vha, &now); qlt_fc_port_deleted(vha, fcport, now); } }
false
false
false
false
false
0
pid_create(const char* file) { FILE *fp; int lock; size_t i; strncpy(pid_file, file, sizeof(pid_file) - 5); pid_file[sizeof(pid_file)-5] = '\0'; for(i = strlen(pid_file); i != 0; i--) { if(pid_file[i] == '/' || pid_file[i] == '\\') break; if(pid_file[i] == '.') { pid_file[i] = '\0'; break; } } strcat(pid_file, ".pid"); fp = lock_fopen(pid_file, &lock); if(fp) { #ifdef WINDOWS fprintf(fp,"%lu", (unsigned long)GetCurrentProcessId()); #else fprintf(fp,"%d", getpid()); #endif lock_fclose(fp, pid_file, &lock); atexit(pid_delete); } }
false
false
false
false
false
0
gl841_bulk_read_data (Genesys_Device * dev, uint8_t addr, uint8_t * data, size_t len) { SANE_Status status; size_t size, target; uint8_t outdata[8], *buffer; DBG (DBG_io, "gl841_bulk_read_data: requesting %lu bytes\n", (u_long) len); if (len == 0) return SANE_STATUS_GOOD; status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER, VALUE_SET_REGISTER, INDEX, 1, &addr); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "gl841_bulk_read_data failed while setting register: %s\n", sane_strstatus (status)); return status; } outdata[0] = BULK_IN; outdata[1] = BULK_RAM; outdata[2] = VALUE_BUFFER & 0xff; outdata[3] = (VALUE_BUFFER >> 8) & 0xff; outdata[4] = (len & 0xff); outdata[5] = ((len >> 8) & 0xff); outdata[6] = ((len >> 16) & 0xff); outdata[7] = ((len >> 24) & 0xff); status = sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_BUFFER, VALUE_BUFFER, INDEX, sizeof (outdata), outdata); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "gl841_bulk_read_data failed while writing command: %s\n", sane_strstatus (status)); return status; } target = len; buffer = data; while (target) { if (target > BULKIN_MAXSIZE) size = BULKIN_MAXSIZE; else size = target; DBG (DBG_io2, "gl841_bulk_read_data: trying to read %lu bytes of data\n", (u_long) size); status = sanei_usb_read_bulk (dev->dn, data, &size); if (status != SANE_STATUS_GOOD) { DBG (DBG_error, "gl841_bulk_read_data failed while reading bulk data: %s\n", sane_strstatus (status)); return status; } DBG (DBG_io2, "gl841_bulk_read_data read %lu bytes, %lu remaining\n", (u_long) size, (u_long) (target - size)); target -= size; data += size; } if (DBG_LEVEL >= DBG_data && dev->binary!=NULL) { fwrite(buffer, len, 1, dev->binary); } DBGCOMPLETED; return SANE_STATUS_GOOD; }
false
false
false
false
false
0
dJointGetPistonPositionRate ( dJointID j ) { dxJointPiston* joint = ( dxJointPiston* ) j; dUASSERT ( joint, "bad joint argument" ); checktype ( joint, Piston ); // get axis in global coordinates dVector3 ax; dMULTIPLY0_331 ( ax, joint->node[0].body->posr.R, joint->axis1 ); // The linear velocity created by the rotation can be discarded since // the rotation is along the prismatic axis and this rotation don't create // linear velocity in the direction of the prismatic axis. if ( joint->node[1].body ) { return ( dDOT ( ax, joint->node[0].body->lvel ) - dDOT ( ax, joint->node[1].body->lvel ) ); } else { dReal rate = dDOT ( ax, joint->node[0].body->lvel ); return ( (joint->flags & dJOINT_REVERSE) ? -rate : rate); } }
false
false
false
false
false
0
NsDbOpen(Ns_DbHandle *handle) { DbDriver *driverPtr = NsDbGetDriver(handle); Ns_Log(Notice, "dbdrv: opening database '%s:%s'", handle->driver, handle->datasource); if (driverPtr == NULL || driverPtr->openProc == NULL || (*driverPtr->openProc) (handle) != NS_OK) { Ns_Log(Error, "dbdrv: failed to open database '%s:%s'", handle->driver, handle->datasource); handle->connected = NS_FALSE; return NS_ERROR; } return NS_OK; }
false
false
false
false
false
0
xsocket_type(len_and_sockaddr **lsap, int family, int sock_type) { len_and_sockaddr *lsa; int fd; int len; if (family == AF_UNSPEC) { #if ENABLE_FEATURE_IPV6 fd = socket(AF_INET6, sock_type, 0); if (fd >= 0) { family = AF_INET6; goto done; } #endif family = AF_INET; } fd = xsocket(family, sock_type, 0); len = sizeof(struct sockaddr_in); if (family == AF_UNIX) len = sizeof(struct sockaddr_un); #if ENABLE_FEATURE_IPV6 if (family == AF_INET6) { done: len = sizeof(struct sockaddr_in6); } #endif lsa = xzalloc(LSA_LEN_SIZE + len); lsa->len = len; lsa->u.sa.sa_family = family; *lsap = lsa; return fd; }
false
false
false
false
false
0
iax2_parse_allow_disallow(struct ast_codec_pref *pref, iax2_format *formats, const char *list, int allowing) { int res; struct ast_format_cap *cap = ast_format_cap_alloc_nolock(); if (!cap) { return 1; } ast_format_cap_from_old_bitfield(cap, *formats); res = ast_parse_allow_disallow(pref, cap, list, allowing); *formats = ast_format_cap_to_old_bitfield(cap); cap = ast_format_cap_destroy(cap); return res; }
false
false
false
false
false
0
hotkey_notify_wakeup(const u32 hkey, bool *send_acpi_ev, bool *ignore_acpi_ev) { /* 0x2000-0x2FFF: Wakeup reason */ *send_acpi_ev = true; *ignore_acpi_ev = false; switch (hkey) { case TP_HKEY_EV_WKUP_S3_UNDOCK: /* suspend, undock */ case TP_HKEY_EV_WKUP_S4_UNDOCK: /* hibernation, undock */ hotkey_wakeup_reason = TP_ACPI_WAKEUP_UNDOCK; *ignore_acpi_ev = true; break; case TP_HKEY_EV_WKUP_S3_BAYEJ: /* suspend, bay eject */ case TP_HKEY_EV_WKUP_S4_BAYEJ: /* hibernation, bay eject */ hotkey_wakeup_reason = TP_ACPI_WAKEUP_BAYEJ; *ignore_acpi_ev = true; break; case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ case TP_HKEY_EV_WKUP_S4_BATLOW: /* Battery on critical low level/S4 */ pr_alert("EMERGENCY WAKEUP: battery almost empty\n"); /* how to auto-heal: */ /* 2313: woke up from S3, go to S4/S5 */ /* 2413: woke up from S4, go to S5 */ break; default: return false; } if (hotkey_wakeup_reason != TP_ACPI_WAKEUP_NONE) { pr_info("woke up due to a hot-unplug request...\n"); hotkey_wakeup_reason_notify_change(); } return true; }
false
false
false
false
false
0
alx_init_sw(struct alx_priv *alx) { struct pci_dev *pdev = alx->hw.pdev; struct alx_hw *hw = &alx->hw; int err; err = alx_identify_hw(alx); if (err) { dev_err(&pdev->dev, "unrecognized chip, aborting\n"); return err; } alx->hw.lnk_patch = pdev->device == ALX_DEV_ID_AR8161 && pdev->subsystem_vendor == PCI_VENDOR_ID_ATTANSIC && pdev->subsystem_device == 0x0091 && pdev->revision == 0; hw->smb_timer = 400; hw->mtu = alx->dev->mtu; alx->rxbuf_size = ALIGN(ALX_RAW_MTU(hw->mtu), 8); alx->tx_ringsz = 256; alx->rx_ringsz = 512; hw->imt = 200; alx->int_mask = ALX_ISR_MISC; hw->dma_chnl = hw->max_dma_chnl; hw->ith_tpd = alx->tx_ringsz / 3; hw->link_speed = SPEED_UNKNOWN; hw->duplex = DUPLEX_UNKNOWN; hw->adv_cfg = ADVERTISED_Autoneg | ADVERTISED_10baseT_Half | ADVERTISED_10baseT_Full | ADVERTISED_100baseT_Full | ADVERTISED_100baseT_Half | ADVERTISED_1000baseT_Full; hw->flowctrl = ALX_FC_ANEG | ALX_FC_RX | ALX_FC_TX; hw->rx_ctrl = ALX_MAC_CTRL_WOLSPED_SWEN | ALX_MAC_CTRL_MHASH_ALG_HI5B | ALX_MAC_CTRL_BRD_EN | ALX_MAC_CTRL_PCRCE | ALX_MAC_CTRL_CRCE | ALX_MAC_CTRL_RXFC_EN | ALX_MAC_CTRL_TXFC_EN | 7 << ALX_MAC_CTRL_PRMBLEN_SHIFT; return err; }
false
false
false
false
false
0
tonga_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode) { if (hwmgr->fan_ctrl_is_in_default_mode) { hwmgr->fan_ctrl_default_mode = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, FDO_PWM_MODE); hwmgr->tmin = PHM_READ_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TMIN); hwmgr->fan_ctrl_is_in_default_mode = false; } PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, TMIN, 0); PHM_WRITE_VFPF_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC, CG_FDO_CTRL2, FDO_PWM_MODE, mode); return 0; }
false
false
false
false
false
0
bnx2x_dcbx_read_mib(struct bnx2x *bp, u32 *base_mib_addr, u32 offset, int read_mib_type) { int max_try_read = 0; u32 mib_size, prefix_seq_num, suffix_seq_num; struct lldp_remote_mib *remote_mib ; struct lldp_local_mib *local_mib; switch (read_mib_type) { case DCBX_READ_LOCAL_MIB: mib_size = sizeof(struct lldp_local_mib); break; case DCBX_READ_REMOTE_MIB: mib_size = sizeof(struct lldp_remote_mib); break; default: return 1; /*error*/ } offset += BP_PORT(bp) * mib_size; do { bnx2x_read_data(bp, base_mib_addr, offset, mib_size); max_try_read++; switch (read_mib_type) { case DCBX_READ_LOCAL_MIB: local_mib = (struct lldp_local_mib *) base_mib_addr; prefix_seq_num = local_mib->prefix_seq_num; suffix_seq_num = local_mib->suffix_seq_num; break; case DCBX_READ_REMOTE_MIB: remote_mib = (struct lldp_remote_mib *) base_mib_addr; prefix_seq_num = remote_mib->prefix_seq_num; suffix_seq_num = remote_mib->suffix_seq_num; break; default: return 1; /*error*/ } } while ((prefix_seq_num != suffix_seq_num) && (max_try_read < DCBX_LOCAL_MIB_MAX_TRY_READ)); if (max_try_read >= DCBX_LOCAL_MIB_MAX_TRY_READ) { BNX2X_ERR("MIB could not be read\n"); return 1; } return 0; }
false
false
false
false
false
0
afr_sh_data_fxattrop (call_frame_t *frame, xlator_t *this, afr_fxattrop_cbk_t fxattrop_cbk) { afr_self_heal_t *sh = NULL; afr_local_t *local = NULL; afr_private_t *priv = NULL; dict_t *xattr_req = NULL; int32_t *zero_pending = NULL; int call_count = 0; int i = 0; int ret = 0; priv = this->private; local = frame->local; sh = &local->self_heal; call_count = afr_up_children_count (local->child_up, priv->child_count); local->call_count = call_count; xattr_req = dict_new(); if (!xattr_req) { ret = -1; goto out; } for (i = 0; i < priv->child_count; i++) { zero_pending = GF_CALLOC (3, sizeof (*zero_pending), gf_afr_mt_int32_t); if (!zero_pending) { ret = -1; goto out; } ret = dict_set_dynptr (xattr_req, priv->pending_key[i], zero_pending, 3 * sizeof (*zero_pending)); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "Unable to set dict value"); goto out; } else { zero_pending = NULL; } } afr_reset_xattr (sh->xattr, priv->child_count); afr_reset_children (sh->success_children, priv->child_count); sh->success_count = 0; for (i = 0; i < priv->child_count; i++) { if (local->child_up[i]) { STACK_WIND_COOKIE (frame, fxattrop_cbk, (void *) (long) i, priv->children[i], priv->children[i]->fops->fxattrop, sh->healing_fd, GF_XATTROP_ADD_ARRAY, xattr_req); if (!--call_count) break; } } out: if (xattr_req) dict_unref (xattr_req); if (ret) { if (zero_pending) GF_FREE (zero_pending); sh->op_failed = 1; afr_sh_data_done (frame, this); } return 0; }
false
false
false
false
false
0
catchhup(int n) { unsigned cnt; struct hhash *hp, *np; #ifdef UNSAFE_SIGNALS signal(n, SIG_IGN); #endif for (cnt = 0; cnt < NETHASHMOD; cnt++) { for (hp = nhashtab[cnt]; hp; hp = np) { if (hp->dosname) free(hp->dosname); if (hp->actname) free(hp->actname); np = hp->hn_next; free((char *) hp); } nhashtab[cnt] = (struct hhash *) 0; } zap_clu_hash(); process_hfile(); un_rpwfile(); send_askall(); #ifdef UNSAFE_SIGNALS signal(n, catchhup); #endif }
false
false
false
false
false
0
speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out) { int i; spx_int32_t N; float float_out[MAX_IN_SAMPLES]; int ret; speex_decoder_ctl(state, SPEEX_GET_FRAME_SIZE, &N); ret = (*((SpeexMode**)state))->dec(state, bits, float_out); for (i=0;i<N;i++) { if (float_out[i]>32767.f) out[i] = 32767; else if (float_out[i]<-32768.f) out[i] = -32768; else out[i] = (spx_int16_t)floor(.5+float_out[i]); } return ret; }
false
false
false
false
false
0
iscsi_login_post_auth_non_zero_tsih( struct iscsi_conn *conn, u16 cid, u32 exp_statsn) { struct iscsi_conn *conn_ptr = NULL; struct iscsi_conn_recovery *cr = NULL; struct iscsi_session *sess = conn->sess; /* * By following item 5 in the login table, if we have found * an existing ISID and a valid/existing TSIH and an existing * CID we do connection reinstatement. Currently we dont not * support it so we send back an non-zero status class to the * initiator and release the new connection. */ conn_ptr = iscsit_get_conn_from_cid_rcfr(sess, cid); if (conn_ptr) { pr_err("Connection exists with CID %hu for %s," " performing connection reinstatement.\n", conn_ptr->cid, sess->sess_ops->InitiatorName); iscsit_connection_reinstatement_rcfr(conn_ptr); iscsit_dec_conn_usage_count(conn_ptr); } /* * Check for any connection recovery entires containing CID. * We use the original ExpStatSN sent in the first login request * to acknowledge commands for the failed connection. * * Also note that an explict logout may have already been sent, * but the response may not be sent due to additional connection * loss. */ if (sess->sess_ops->ErrorRecoveryLevel == 2) { cr = iscsit_get_inactive_connection_recovery_entry( sess, cid); if (cr) { pr_debug("Performing implicit logout" " for connection recovery on CID: %hu\n", conn->cid); iscsit_discard_cr_cmds_by_expstatsn(cr, exp_statsn); } } /* * Else we follow item 4 from the login table in that we have * found an existing ISID and a valid/existing TSIH and a new * CID we go ahead and continue to add a new connection to the * session. */ pr_debug("Adding CID %hu to existing session for %s.\n", cid, sess->sess_ops->InitiatorName); if ((atomic_read(&sess->nconn) + 1) > sess->sess_ops->MaxConnections) { pr_err("Adding additional connection to this session" " would exceed MaxConnections %d, login failed.\n", sess->sess_ops->MaxConnections); iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_INITIATOR_ERR, ISCSI_LOGIN_STATUS_ISID_ERROR); return -1; } return 0; }
false
false
false
false
false
0
oss_get_volume( void ) { int v, cmd, devs; int curvol = 0; if( fd < 0 ) fd = open( mixer_device, O_RDONLY ); if( fd != -1 ) { ioctl( fd, SOUND_MIXER_READ_DEVMASK, &devs ); if( devs & mixer_dev_mask ) { cmd = MIXER_READ( mixer_channel ); } else { return curvol; } ioctl( fd, cmd, &v ); curvol = ( v & 0xFF00 ) >> 8; } return curvol; }
false
false
false
false
false
0
expat_default_handler(XMLParserObject* self, const XML_Char* data_in, int data_len) { PyObject* key; PyObject* value; PyObject* res; if (data_len < 2 || data_in[0] != '&') return; if (PyErr_Occurred()) return; key = PyUnicode_DecodeUTF8(data_in + 1, data_len - 2, "strict"); if (!key) return; value = PyDict_GetItem(self->entity, key); if (value) { if (TreeBuilder_CheckExact(self->target)) res = treebuilder_handle_data( (TreeBuilderObject*) self->target, value ); else if (self->handle_data) res = PyObject_CallFunction(self->handle_data, "O", value); else res = NULL; Py_XDECREF(res); } else if (!PyErr_Occurred()) { /* Report the first error, not the last */ char message[128] = "undefined entity "; strncat(message, data_in, data_len < 100?data_len:100); expat_set_error( XML_ERROR_UNDEFINED_ENTITY, EXPAT(GetErrorLineNumber)(self->parser), EXPAT(GetErrorColumnNumber)(self->parser), message ); } Py_DECREF(key); }
true
true
false
false
false
1
chkArg2(STRPTR command, STRPTR arg1, STRPTR arg2) { BOOL ok = TRUE; if (cmdArgNum != 2) { fprintf(stderr, "two arguments required for command `%s': " "%s and %s\n", command, arg1, arg2); set_return_code(RC_ERROR); ok = FALSE; } return (ok); }
false
false
false
false
false
0
gs_shading_Fb_init(gs_shading_t ** ppsh, const gs_shading_Fb_params_t * params, gs_memory_t * mem) { gs_shading_Fb_t *psh; gs_matrix imat; int code = check_CBFD((const gs_shading_params_t *)params, params->Function, params->Domain, 2); if (code < 0 || (code = gs_matrix_invert(&params->Matrix, &imat)) < 0 ) return code; ALLOC_SHADING(&st_shading_Fb, shading_type_Function_based, shading_Fb_procs, "gs_shading_Fb_init"); return 0; }
false
false
false
false
false
0
iommu_pc_get_set_reg_val(struct amd_iommu *iommu, u8 bank, u8 cntr, u8 fxn, u64 *value, bool is_write) { u32 offset; u32 max_offset_lim; /* Check for valid iommu and pc register indexing */ if (WARN_ON((fxn > 0x28) || (fxn & 7))) return -ENODEV; offset = (u32)(((0x40|bank) << 12) | (cntr << 8) | fxn); /* Limit the offset to the hw defined mmio region aperture */ max_offset_lim = (u32)(((0x40|iommu->max_banks) << 12) | (iommu->max_counters << 8) | 0x28); if ((offset < MMIO_CNTR_REG_OFFSET) || (offset > max_offset_lim)) return -EINVAL; if (is_write) { writel((u32)*value, iommu->mmio_base + offset); writel((*value >> 32), iommu->mmio_base + offset + 4); } else { *value = readl(iommu->mmio_base + offset + 4); *value <<= 32; *value = readl(iommu->mmio_base + offset); } return 0; }
false
false
false
false
false
0
process_send_command_request(bool entry) { if (entry) { // Prepare the request command buffer m_buffer[0] = SOCKS4_VERSION; switch (m_proxyCommand) { case PROXY_CMD_CONNECT: m_buffer[1] = SOCKS4_CMD_CONNECT; break; case PROXY_CMD_BIND: m_buffer[1] = SOCKS4_CMD_BIND; break; case PROXY_CMD_UDP_ASSOCIATE: m_ok = false; return; break; } RawPokeUInt16(m_buffer+2, ENDIAN_HTONS(m_peerAddress->Service())); // Special processing for SOCKS4a switch (m_proxyData.m_proxyType) { case PROXY_SOCKS4a: PokeUInt32(m_buffer+4, StringIPtoUint32(wxT("0.0.0.1"))); break; case PROXY_SOCKS4: default: PokeUInt32(m_buffer+4, StringIPtoUint32(m_peerAddress->IPAddress())); break; } // Common processing for SOCKS4/SOCKS4a unsigned int offsetUser = 8; unsigned char lenUser = m_proxyData.m_userName.Len(); memcpy(m_buffer + offsetUser, unicode2char(m_proxyData.m_userName), lenUser); m_buffer[offsetUser + lenUser] = 0; // Special processing for SOCKS4a switch (m_proxyData.m_proxyType) { case PROXY_SOCKS4a: { unsigned int offsetDomain = offsetUser + lenUser + 1; unsigned char lenDomain = m_peerAddress->Hostname().Len(); memcpy(m_buffer + offsetDomain, unicode2char(m_peerAddress->Hostname()), lenDomain); m_buffer[offsetDomain + lenDomain] = 0; m_packetLenght = 1 + 1 + 2 + 4 + lenUser + 1 + lenDomain + 1; break; } case PROXY_SOCKS4: default: m_packetLenght = 1 + 1 + 2 + 4 + lenUser + 1; break; } // Send the command packet ProxyWrite(*m_proxyClientSocket, m_buffer, m_packetLenght); } }
false
false
false
false
false
0
caml_final_do_young_roots (scanning_action f) { uintnat i; Assert (old <= young); for (i = old; i < young; i++){ Call_action (f, final_table[i].fun); Call_action (f, final_table[i].val); } }
false
false
false
false
false
0
md5_final_text(char *buf, MD5_CONTEXT *ctx) { static const char *chars = "abcdefghijklmnopqrstuvwxyz234567"; int bit; if (!ctx->finalized) do_final(ctx); for (bit = 0; bit < 16*8; bit += 5) { int first_char = bit / 8; int val = ctx->buf[first_char] >> (bit % 8); if (bit + 8 > (first_char + 1) * 8 && first_char < 15) val += ctx->buf[first_char + 1] << (8 - (bit % 8)); *buf++ = chars[val & 0x1F]; } *buf++ = 0; }
false
false
false
false
false
0
test_extension_python_activatable_subject_refcount (PeasEngine *engine, PeasPluginInfo *info) { PeasExtension *extension; GObject *object; PyObject *wrapper; /* Create the 'object' property value, to be similar to a GtkWindow * instance: a sunk GInitiallyUnowned object. */ object = g_object_new (G_TYPE_INITIALLY_UNOWNED, NULL); g_object_ref_sink (object); g_assert_cmpint (object->ref_count, ==, 1); /* we pre-create the wrapper to make it easier to check reference count */ extension = peas_engine_create_extension (engine, info, PEAS_TYPE_ACTIVATABLE, "object", object, NULL); g_assert (PEAS_IS_EXTENSION (extension)); /* The python wrapper created around our dummy object should have increased * its refcount by 1. */ g_assert_cmpint (object->ref_count, ==, 2); /* Ensure the python wrapper is only reffed once, by the extension */ wrapper = g_object_get_data (object, "PyGObject::wrapper"); g_assert_cmpint (wrapper->ob_refcnt, ==, 1); g_assert_cmpint (G_OBJECT (extension)->ref_count, ==, 1); g_object_unref (extension); /* We unreffed the extension, so it should have been destroyed and our dummy * object refcount should be back to 1. */ g_assert_cmpint (object->ref_count, ==, 1); g_object_unref (object); }
false
false
false
false
false
0
gdl_dock_item_button_image_draw (GtkWidget *widget, cairo_t *cr) { GdlDockItemButtonImage *button_image; GtkStyleContext *context; GdkRGBA color; g_return_val_if_fail (widget != NULL, 0); button_image = GDL_DOCK_ITEM_BUTTON_IMAGE (widget); /* Set up the pen */ cairo_set_line_width(cr, 1.0); context = gtk_widget_get_style_context (widget); gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &color); color.alpha = 0.55; gdk_cairo_set_source_rgba(cr, &color); /* Draw the icon border */ cairo_move_to (cr, 10.5, 2.5); cairo_arc (cr, 10.5, 4.5, 2, -0.5 * M_PI, 0); cairo_line_to (cr, 12.5, 10.5); cairo_arc (cr, 10.5, 10.5, 2, 0, 0.5 * M_PI); cairo_line_to (cr, 4.5, 12.5); cairo_arc (cr, 4.5, 10.5, 2, 0.5 * M_PI, M_PI); cairo_line_to (cr, 2.5, 4.5); cairo_arc (cr, 4.5, 4.5, 2, M_PI, 1.5 * M_PI); cairo_close_path (cr); cairo_stroke (cr); /* Draw the icon */ cairo_new_path (cr); switch(button_image->image_type) { case GDL_DOCK_ITEM_BUTTON_IMAGE_CLOSE: cairo_move_to (cr, 4.0, 5.5); cairo_line_to (cr, 4.0, 5.5); cairo_line_to (cr, 6.0, 7.5); cairo_line_to (cr, 4.0, 9.5); cairo_line_to (cr, 5.5, 11.0); cairo_line_to (cr, 7.5, 9.0); cairo_line_to (cr, 9.5, 11.0); cairo_line_to (cr, 11.0, 9.5); cairo_line_to (cr, 9.0, 7.5); cairo_line_to (cr, 11.0, 5.5); cairo_line_to (cr, 9.5, 4.0); cairo_line_to (cr, 7.5, 6.0); cairo_line_to (cr, 5.5, 4.0); cairo_close_path (cr); break; case GDL_DOCK_ITEM_BUTTON_IMAGE_ICONIFY: if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_RTL) { cairo_move_to (cr, 4.5, 7.5); cairo_line_to (cr, 10.0, 4.75); cairo_line_to (cr, 10.0, 10.25); cairo_close_path (cr); } else { cairo_move_to (cr, 10.5, 7.5); cairo_line_to (cr, 5, 4.75); cairo_line_to (cr, 5, 10.25); cairo_close_path (cr); } break; default: break; } cairo_fill (cr); return FALSE; }
false
false
false
false
false
0
gdk_pixbuf_loader_get_pixbuf (GdkPixbufLoader *loader) { GdkPixbufLoaderPrivate *priv; g_return_val_if_fail (GDK_IS_PIXBUF_LOADER (loader), NULL); priv = loader->priv; if (priv->animation) return gdk_pixbuf_animation_get_static_image (priv->animation); else return NULL; }
false
false
false
false
false
0
_rtl88e_get_chnl_group(u8 chnl) { u8 group = 0; if (chnl < 3) group = 0; else if (chnl < 6) group = 1; else if (chnl < 9) group = 2; else if (chnl < 12) group = 3; else if (chnl < 14) group = 4; else if (chnl == 14) group = 5; return group; }
false
false
false
false
false
0
updateLitScores(bool firstTime) { TRACE("search literals", "updateLitScores(size=", d_litsByScores.size(), ") {"); unsigned count, score; if (firstTime && followChaff) { ::stable_sort(d_litsByScores.begin(), d_litsByScores.end(), compareLits); } for(size_t i=0; i< d_litsByScores.size(); ++i) { // Reading by value, since we'll be modifying the attributes. Literal lit = d_litsByScores[i]; // First, clean up the unused literals while(lit.count()==0 && i+1 < d_litsByScores.size()) { TRACE("search literals", "Removing lit["+int2string(i)+"] = ", lit, " from d_litsByScores"); // Remove this literal from the list lit.added()=false; lit = d_litsByScores.back(); d_litsByScores[i] = lit; d_litsByScores.pop_back(); } // Take care of the last literal in the vector if(lit.count()==0 && i+1 == d_litsByScores.size()) { TRACE("search literals", "Removing last lit["+int2string(i)+"] = ", lit, " from d_litsByScores"); lit.added()=false; d_litsByScores.pop_back(); break; // Break out of the loop -- no more literals to process } TRACE("search literals", "Updating lit["+int2string(i)+"] = ", lit, " {"); DebugAssert(lit == d_litsByScores[i], "lit = "+lit.toString()); DebugAssert(lit.added(), "lit = "+lit.toString()); DebugAssert(lit.count()>0, "lit = "+lit.toString()); count = lit.count(); unsigned& countPrev = lit.countPrev(); int& scoreRef = lit.score(); score = scoreRef/2 + count - countPrev; scoreRef = score; countPrev = count; TRACE("search literals", "Updated lit["+int2string(i)+"] = ", lit, " }"); // Literal neglit(!lit); // count = neglit.count(); // unsigned& negcountPrev = neglit.countPrev(); // unsigned& negscoreRef = neglit.score(); // negscore = negscoreRef/2 + count - negcountPrev; // negscoreRef = negscore; // negcountPrev = count; // if(negscore > score) d_litsByScores[i] = neglit; } ::stable_sort(d_litsByScores.begin(), d_litsByScores.end(), compareLits); d_litsMaxScorePos = 0; d_litSortCount=d_litsByScores.size(); TRACE("search splitters","updateLitScores => ", lits2str(d_litsByScores),""); TRACE("search literals", "updateLitScores(size=", d_litsByScores.size(), ") => }"); }
false
false
false
false
false
0
abs_diff (const unsigned char *in1, const unsigned char *in2, const int stride) { int s; int i, j, diff; s = 0; for (i = 0; i < 2 * DCTSIZE; i++) { for (j = 0; j < 2 * DCTSIZE; j++) { diff = in1[j] - in2[j]; s += diff * diff; } in1 += stride; in2 += stride; } return s; }
false
false
false
false
false
0
close() { thread::MutexGuard guard (access_mutex); out.close(); delete[] buffer; buffer = 0; closed = true; }
false
false
false
false
false
0
ir_edit_gainline(GxIREdit *ir_edit, cairo_t *c, GdkEventExpose *event) { GxRgba clr; get_color(ir_edit, &clr, "gain-line-color", &gain_line_color); double j, g; int n; gain_points *p; if (ir_edit->linear || !ir_edit->data) { return; } cairo_save(c); cairo_rectangle(c,0, 0, ir_edit->graph_x, ir_edit->graph_y); cairo_clip(c); cairo_set_line_width(c,1.0); cairo_set_source_rgba(c, clr.red, clr.green, clr.blue, clr.alpha); gboolean first = TRUE; for (p = ir_edit->gains, n = 0; n < ir_edit->gains_len; n++, p++) { j = int(p->i / ir_edit->scale) - ir_edit->current_offset; g = (p->g - ir_edit->max_y) * ir_edit->scale_height; if (first) { first = FALSE; cairo_move_to(c,j, g); } else { cairo_line_to(c,j, g); } } cairo_stroke(c); for (p = ir_edit->gains, n = 0; n < ir_edit->gains_len; n++, p++) { j = int(p->i / ir_edit->scale) - ir_edit->current_offset + 0.5; g = (p->g - ir_edit->max_y) * ir_edit->scale_height + 0.5; cairo_arc(c,j, g, ir_edit->dot_diameter, 0.0, 2.0*M_PI); cairo_fill(c); } cairo_restore(c); }
false
false
false
false
false
0
log_window_show(LogWindow *logwin) { GtkTextView *text = GTK_TEXT_VIEW(logwin->text); GtkTextBuffer *buffer = logwin->buffer; GtkTextMark *mark; logwin->hidden = FALSE; if (logwin->never_shown) gtk_text_view_set_buffer(GTK_TEXT_VIEW(logwin->text), logwin->buffer); logwin->never_shown = FALSE; mark = gtk_text_buffer_get_mark(buffer, "end"); gtk_text_view_scroll_mark_onscreen(text, mark); gtk_window_deiconify(GTK_WINDOW(logwin->window)); gtk_widget_show(logwin->window); gtk_window_present(GTK_WINDOW(logwin->window)); }
false
false
false
false
false
0
edit(const CoordinateSequence *cs, const Geometry *geom) { if (cs->getSize()==0) return NULL; unsigned int csSize=cs->getSize(); vector<Coordinate> *vc = new vector<Coordinate>(csSize); // copy coordinates and reduce for (unsigned int i=0; i<csSize; ++i) { Coordinate coord=cs->getAt(i); sgpr->getPrecisionModel()->makePrecise(&coord); //reducedCoords->setAt(*coord,i); (*vc)[i] = coord; } // reducedCoords take ownership of 'vc' CoordinateSequence *reducedCoords = geom->getFactory()->getCoordinateSequenceFactory()->create(vc); // remove repeated points, to simplify returned geometry as // much as possible. // CoordinateSequence *noRepeatedCoords=CoordinateSequence::removeRepeatedPoints(reducedCoords); /** * Check to see if the removal of repeated points * collapsed the coordinate List to an invalid length * for the type of the parent geometry. * It is not necessary to check for Point collapses, * since the coordinate list can * never collapse to less than one point. * If the length is invalid, return the full-length coordinate array * first computed, or null if collapses are being removed. * (This may create an invalid geometry - the client must handle this.) */ unsigned int minLength = 0; if (typeid(*geom)==typeid(LineString)) minLength = 2; if (typeid(*geom)==typeid(LinearRing)) minLength = 4; CoordinateSequence *collapsedCoords = reducedCoords; if (sgpr->getRemoveCollapsed()) { delete reducedCoords; reducedCoords=0; collapsedCoords=0; } // return null or orginal length coordinate array if (noRepeatedCoords->getSize()<minLength) { delete noRepeatedCoords; return collapsedCoords; } // ok to return shorter coordinate array delete reducedCoords; return noRepeatedCoords; } }
false
false
false
false
false
0
anzeigen() { Color c = Color(150, 150, 150); Area::fillBorder(c); int spz = Cuyo::getSpielerZahl(); malRahmen(spz == 1 ? L_fenster_breite_1sp : L_fenster_breite_2sp); if (spz == 1) { malVertRand(chooseX(L_spielfeld_x, 1, 0) - L_rand); } else { malVertRand(chooseX(L_spielfeld_x, 2, 0) - L_rand); malVertRand(chooseX(L_spielfeld_x, 2, 1) - L_rand); malVertRand(chooseX(L_infos_x, 2, 1) - L_rand); } for (int i = 0; i < spz; i++) { Area::enter(SDLTools::rect(chooseX(L_spielfeld_x, spz, i), L_spielfeld_y, L_spielfeld_breite, L_spielfeld_hoehe)); Cuyo::malSpielfeld(i); Area::leave(); malInfos(i, chooseX(L_infos_x, spz, i)); } /* Neue Randfarbe? Dann alles an den xserver schicken */ if (mDekoUpdaten) { Area::updateAll(); } mDekoUpdaten = false; }
false
false
false
false
false
0
R_PointToDist(fixed_t x, fixed_t y) { int angle; fixed_t dx, dy, temp; fixed_t dist; dx = abs(x - viewx); dy = abs(y - viewy); if (dy > dx) { temp = dx; dx = dy; dy = temp; } angle = (tantoangle[FixedDiv(dy, dx) >> DBITS] + ANG90) >> ANGLETOFINESHIFT; dist = FixedDiv(dx, finesine[angle]); // use as cosine return dist; }
false
false
false
false
false
0
recv_tiger(struct tiger_hw *card, u8 irq_stat) { u32 idx; int cnt = card->recv.size / 2; /* Note receive is via the WRITE DMA channel */ card->last_is0 &= ~NJ_IRQM0_WR_MASK; card->last_is0 |= (irq_stat & NJ_IRQM0_WR_MASK); if (irq_stat & NJ_IRQM0_WR_END) idx = cnt - 1; else idx = card->recv.size - 1; if (test_bit(FLG_ACTIVE, &card->bc[0].bch.Flags)) read_dma(&card->bc[0], idx, cnt); if (test_bit(FLG_ACTIVE, &card->bc[1].bch.Flags)) read_dma(&card->bc[1], idx, cnt); }
false
false
false
false
false
0
fprintROWS () { struct row_s *pRow; for (pRow = LV_row; pRow != NULL; pRow = pRow->next) { fprintf (DEF_FILE, "ROW %s %s %ld %ld %s DO %ld BY %ld STEP %ld %ld ;\n", pRow->rowName, pRow->rowType, pRow->x, pRow->y, DEF_orient2a(pRow->orient), pRow->doNumber, pRow->byNumber, pRow->stepX, pRow->stepY); } }
false
false
false
false
false
0
usbhs_fifo_clear_dcp(struct usbhs_pipe *pipe) { struct usbhs_priv *priv = usbhs_pipe_to_priv(pipe); struct usbhs_fifo *fifo = usbhsf_get_cfifo(priv); /* CFIFO */ /* clear DCP FIFO of transmission */ if (usbhsf_fifo_select(pipe, fifo, 1) < 0) return; usbhsf_fifo_clear(pipe, fifo); usbhsf_fifo_unselect(pipe, fifo); /* clear DCP FIFO of reception */ if (usbhsf_fifo_select(pipe, fifo, 0) < 0) return; usbhsf_fifo_clear(pipe, fifo); usbhsf_fifo_unselect(pipe, fifo); }
false
false
false
false
false
0
irc_getchan_int(session_t *s, const char *name, int checkchan) { char *ret, *tmp; irc_private_t *j = irc_private(s); if (!xstrlen(name)) return NULL; if (!xstrncasecmp(name, IRC4, 4)) ret = xstrdup(name); else ret = irc_uid(name); if (checkchan == 2) return ret; tmp = SOP(_005_CHANTYPES); if (tmp && ((!!xstrchr(tmp, ret[4]))-checkchan) ) return ret; else xfree(ret); return NULL; }
false
false
false
false
false
0
atkin_chunk_sieve_psquares(char* chunk, llong lower, llong upper, const char* sieved) { const llong chunk_size = upper - lower; for (llong p = 7; p * p < upper; ++p) { if (sieved[p] == 1) { llong p_sqr = p*p; llong mod = lower % p_sqr; llong i = p_sqr * (mod != 0) - mod; for (; i < chunk_size; i += p_sqr) { bitset_clear(chunk, i); } } } return 0; }
false
false
false
false
false
0
ar5523_cmd_tx_cb(struct urb *urb) { struct ar5523_tx_cmd *cmd = urb->context; struct ar5523 *ar = cmd->ar; if (urb->status) { ar5523_err(ar, "Failed to TX command. Status = %d\n", urb->status); cmd->res = urb->status; complete(&cmd->done); return; } if (!(cmd->flags & AR5523_CMD_FLAG_READ)) { cmd->res = 0; complete(&cmd->done); } }
false
false
false
false
false
0
ping_try (GdmHostChooserWidget *widget) { do_ping (widget, FALSE); widget->priv->ping_tries --; if (widget->priv->ping_tries <= 0) { widget->priv->ping_try_id = 0; return FALSE; } else { return TRUE; } }
false
false
false
false
false
0
gst_rtp_mux_readjust_rtp_timestamp_locked (GstRTPMux * rtp_mux, GstRTPMuxPadPrivate * padpriv, GstRTPBuffer * rtpbuffer) { guint32 ts; guint32 sink_ts_base = 0; if (padpriv && padpriv->have_clock_base) sink_ts_base = padpriv->clock_base; ts = gst_rtp_buffer_get_timestamp (rtpbuffer) - sink_ts_base + rtp_mux->ts_base; GST_LOG_OBJECT (rtp_mux, "Re-adjusting RTP ts %u to %u", gst_rtp_buffer_get_timestamp (rtpbuffer), ts); gst_rtp_buffer_set_timestamp (rtpbuffer, ts); }
false
false
false
false
false
0
mcp23s17_read_regs(struct mcp23s08 *mcp, unsigned reg, u16 *vals, unsigned n) { u8 tx[2]; int status; if ((n + reg) > sizeof(mcp->cache)) return -EINVAL; tx[0] = mcp->addr | 0x01; tx[1] = reg << 1; status = spi_write_then_read(mcp->data, tx, sizeof(tx), (u8 *)vals, n * 2); if (status >= 0) { while (n--) vals[n] = __le16_to_cpu((__le16)vals[n]); } return status; }
false
false
false
false
false
0
computeScale(int& width, int& height, double borderX, double borderY, bool modify, agg::trans_affine* trans, bool exact) { double scale; double virtual_width = mMax_X - mMin_X; double virtual_height = mMax_Y - mMin_Y; double target_width = width - 2.0 * borderX; double target_height = height - 2.0 * borderY; if (!mValid) virtual_width = virtual_height = 1.0; int newWidth = width; int newHeight = height; if (virtual_width / target_width > virtual_height / target_height) { scale = target_width / virtual_width; newHeight = (int)floor(scale * virtual_height + 2.0 * borderY + 0.5); if (!exact) newHeight = newHeight + ((newHeight ^ height) & 0x1); if (modify) { height = newHeight; } } else { scale = target_height / virtual_height; newWidth = (int)floor(scale * virtual_width + 2.0 * borderX + 0.5); if (!exact) newWidth = newWidth + ((newWidth ^ width) & 0x1); if (modify) { width = newWidth; } } if (trans) { double offsetX = scale * (mMax_X + mMin_X) / 2.0 - newWidth / 2.0; double offsetY = scale * (mMax_Y + mMin_Y) / 2.0 - newHeight / 2.0; agg::trans_affine_scaling sc(scale); agg::trans_affine_translation tr(-offsetX, -offsetY); *trans = sc; *trans *= tr; } return scale; }
false
false
false
false
false
0
command_file(argument_count, arguments) int argument_count; char *arguments[]; { Book *book; char absolute_path[PATH_MAX + 1]; EBNet_Content_Type content_type; const char *prefix; char actual_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; char message[EBNET_MAX_LINE_LENGTH + 1]; EBNet_Error_Code error_code; /* * Check arguments. */ error_code = parse_and_check_book_name(arguments[1], &book, &content_type); if (error_code != EBNET_ERROR_OK) goto error; error_code = check_directory_path(book, content_type, arguments[2]); if (error_code != EBNET_ERROR_OK) goto error; if (EB_MAX_FILE_NAME_LENGTH < strlen(arguments[3])) { error_code = EBNET_ERROR_BAD_PATH; goto error; } if (strcmp(arguments[2], "/") == 0) { error_code = check_root_file_name(arguments[3]); if (error_code != EBNET_ERROR_OK) goto error; } else { error_code = check_path_parent_directory(arguments[3]); if (error_code != EBNET_ERROR_OK) goto error; } /* * Get an actual file name. */ if (content_type == EBNET_CONTENT_TYPE_BOOK) prefix = book->path; else prefix = book->appendix_path; if (PATH_MAX < strlen(prefix) + 1 + strlen(arguments[2])) { error_code = EBNET_ERROR_BAD_PATH; goto error; } sprintf(absolute_path, "%s%s", prefix, arguments[2]); if (eb_find_file_name(absolute_path, arguments[3], actual_file_name) != EB_SUCCESS) { error_code = EBNET_ERROR_BAD_PATH; goto error; } /* * Send a response message. */ syslog(LOG_INFO, "%s: cmd=FILE, book=%s, path=%s, file=%s, host=%s(%s)", "ok", arguments[1], arguments[2], arguments[3], client_host_name, client_address); if (write_string_all(accepted_out_file, idle_timeout, "!OK; actual file name follows\r\n") <= 0) return -1; if (write_string_all(accepted_out_file, idle_timeout, actual_file_name) <= 0) return -1; if (write_string_all(accepted_out_file, idle_timeout, "\r\n") <= 0) return -1; return 0; /* * An error occurs... */ error: /* +4 for ".app" */ truncate_string(arguments[1], MAX_BOOK_NAME_LENGTH + 4); truncate_string(arguments[2], EBNET_MAX_PATH_LENGTH); truncate_string(arguments[3], EB_MAX_FILE_NAME_LENGTH); syslog(LOG_INFO, "%s: cmd=FILE, book=%s, path=%s, file=%s, host=%s(%s)", error_messages[error_code], arguments[1], arguments[2], arguments[3], client_host_name, client_address); sprintf(message, "!%s; %s\r\n", error_categories[error_code], error_messages[error_code]); if (write_string_all(accepted_out_file, idle_timeout, message) <= 0) return -1; return 0; }
false
false
false
false
false
0
ParseStanza(vector<metaIndex *> &List, pkgTagSection &Tags, int i, FileFd &Fd) { map<string, string> Options; string Enabled = Tags.FindS("Enabled"); if (Enabled.size() > 0 && StringToBool(Enabled) == false) return true; // Define external/internal options const char* option_deb822[] = { "Architectures", "Architectures-Add", "Architectures-Remove", "Trusted", }; const char* option_internal[] = { "arch", "arch+", "arch-", "trusted", }; for (unsigned int j=0; j < sizeof(option_deb822)/sizeof(char*); j++) if (Tags.Exists(option_deb822[j])) { // for deb822 the " " is the delimiter, but the backend expects "," std::string option = Tags.FindS(option_deb822[j]); std::replace(option.begin(), option.end(), ' ', ','); Options[option_internal[j]] = option; } // now create one item per suite/section string Suite = Tags.FindS("Suites"); Suite = SubstVar(Suite,"$(ARCH)",_config->Find("APT::Architecture")); string const Section = Tags.FindS("Sections"); string URIS = Tags.FindS("URIs"); std::vector<std::string> list_uris = StringSplit(URIS, " "); std::vector<std::string> list_dist = StringSplit(Suite, " "); std::vector<std::string> list_section = StringSplit(Section, " "); for (std::vector<std::string>::const_iterator U = list_uris.begin(); U != list_uris.end(); U++) { std::string URI = (*U); if (!FixupURI(URI)) { _error->Error(_("Malformed stanza %u in source list %s (URI parse)"),i,Fd.Name().c_str()); return false; } for (std::vector<std::string>::const_iterator I = list_dist.begin(); I != list_dist.end(); I++) { for (std::vector<std::string>::const_iterator J = list_section.begin(); J != list_section.end(); J++) { if (CreateItem(List, URI, (*I), (*J), Options) == false) { return false; } } } } return true; }
false
false
false
false
false
0
lp8788_config_ldo_enable_mode(struct platform_device *pdev, struct lp8788_ldo *ldo, enum lp8788_ldo_id id) { struct lp8788 *lp = ldo->lp; struct lp8788_platform_data *pdata = lp->pdata; enum lp8788_ext_ldo_en_id enable_id; u8 en_mask[] = { [EN_ALDO1] = LP8788_EN_SEL_ALDO1_M, [EN_ALDO234] = LP8788_EN_SEL_ALDO234_M, [EN_ALDO5] = LP8788_EN_SEL_ALDO5_M, [EN_ALDO7] = LP8788_EN_SEL_ALDO7_M, [EN_DLDO7] = LP8788_EN_SEL_DLDO7_M, [EN_DLDO911] = LP8788_EN_SEL_DLDO911_M, }; switch (id) { case DLDO7: enable_id = EN_DLDO7; break; case DLDO9: case DLDO11: enable_id = EN_DLDO911; break; case ALDO1: enable_id = EN_ALDO1; break; case ALDO2 ... ALDO4: enable_id = EN_ALDO234; break; case ALDO5: enable_id = EN_ALDO5; break; case ALDO7: enable_id = EN_ALDO7; break; default: return 0; } /* if no platform data for ldo pin, then set default enable mode */ if (!pdata || !pdata->ldo_pin || !pdata->ldo_pin[enable_id]) goto set_default_ldo_enable_mode; ldo->en_pin = pdata->ldo_pin[enable_id]; return 0; set_default_ldo_enable_mode: return lp8788_update_bits(lp, LP8788_EN_SEL, en_mask[enable_id], 0); }
false
false
false
false
false
0
BERDecode(BufferedTransformation &bt) { BERSequenceDecoder subjectPublicKeyInfo(bt); BERSequenceDecoder algorithm(subjectPublicKeyInfo); GetAlgorithmID().BERDecodeAndCheck(algorithm); bool parametersPresent = algorithm.EndReached() ? false : BERDecodeAlgorithmParameters(algorithm); algorithm.MessageEnd(); BERGeneralDecoder subjectPublicKey(subjectPublicKeyInfo, BIT_STRING); subjectPublicKey.CheckByte(0); // unused bits BERDecodePublicKey(subjectPublicKey, parametersPresent, (size_t)subjectPublicKey.RemainingLength()); subjectPublicKey.MessageEnd(); subjectPublicKeyInfo.MessageEnd(); }
false
false
false
false
false
0
FoldGui4Cli(unsigned int startPos, int length, int, WordList *[], Accessor &styler) { bool foldCompact = styler.GetPropertyInt("fold.compact", 1) != 0; unsigned int endPos = startPos + length; int visibleChars = 0; int lineCurrent = styler.GetLine(startPos); char chNext = styler[startPos]; int styleNext = styler.StyleAt(startPos); bool headerPoint = false; for (unsigned int i = startPos; i < endPos; i++) { char ch = chNext; chNext = styler[i+1]; int style = styleNext; styleNext = styler.StyleAt(i + 1); bool atEOL = (ch == '\r' && chNext != '\n') || (ch == '\n'); if (style == SCE_GC_EVENT || style == SCE_GC_GLOBAL) { headerPoint = true; // fold at events and globals } if (atEOL) { int lev = SC_FOLDLEVELBASE+1; if (headerPoint) lev = SC_FOLDLEVELBASE; if (visibleChars == 0 && foldCompact) lev |= SC_FOLDLEVELWHITEFLAG; if (headerPoint) lev |= SC_FOLDLEVELHEADERFLAG; if (lev != styler.LevelAt(lineCurrent)) // set level, if not already correct { styler.SetLevel(lineCurrent, lev); } lineCurrent++; // re-initialize our flags visibleChars = 0; headerPoint = false; } if (!(isspacechar(ch))) // || (style == SCE_GC_COMMENTLINE) || (style != SCE_GC_COMMENTBLOCK))) visibleChars++; } int lev = headerPoint ? SC_FOLDLEVELBASE : SC_FOLDLEVELBASE+1; int flagsNext = styler.LevelAt(lineCurrent) & ~SC_FOLDLEVELNUMBERMASK; styler.SetLevel(lineCurrent, lev | flagsNext); }
false
false
false
false
false
0
fixup_botched_add(struct ctlr_info *h, struct hpsa_scsi_dev_t *added) { /* called when scsi_add_device fails in order to re-adjust * h->dev[] to match the mid layer's view. */ unsigned long flags; int i, j; spin_lock_irqsave(&h->lock, flags); for (i = 0; i < h->ndevices; i++) { if (h->dev[i] == added) { for (j = i; j < h->ndevices-1; j++) h->dev[j] = h->dev[j+1]; h->ndevices--; break; } } spin_unlock_irqrestore(&h->lock, flags); kfree(added); }
false
false
false
false
false
0
unregister_index(netsnmp_variable_list * varbind, int remember, netsnmp_session * ss) { struct snmp_index *idxptr, *idxptr2; struct snmp_index *prev_oid_ptr, *prev_idx_ptr; int res, res2, i; #if defined(USING_AGENTX_SUBAGENT_MODULE) && !defined(TESTING) if (netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE) == SUB_AGENT) { return (agentx_unregister_index(ss, varbind)); } #endif /* * Look for the requested OID entry */ prev_oid_ptr = NULL; prev_idx_ptr = NULL; res = 1; res2 = 1; for (idxptr = snmp_index_head; idxptr != NULL; prev_oid_ptr = idxptr, idxptr = idxptr->next_oid) { if ((res = snmp_oid_compare(varbind->name, varbind->name_length, idxptr->varbind->name, idxptr->varbind->name_length)) <= 0) break; } if (res != 0) return INDEX_ERR_NOT_ALLOCATED; if (varbind->type != idxptr->varbind->type) return INDEX_ERR_WRONG_TYPE; for (idxptr2 = idxptr; idxptr2 != NULL; prev_idx_ptr = idxptr2, idxptr2 = idxptr2->next_idx) { i = SNMP_MIN(varbind->val_len, idxptr2->varbind->val_len); res2 = memcmp(varbind->val.string, idxptr2->varbind->val.string, i); if (res2 <= 0) break; } if (res2 != 0 || (res2 == 0 && !idxptr2->allocated)) { return INDEX_ERR_NOT_ALLOCATED; } if (ss != idxptr2->session) return INDEX_ERR_WRONG_SESSION; /* * If this is a "normal" index unregistration, * mark the index entry as unused, but leave * it in situ. This allows differentiation * between ANY_INDEX and NEW_INDEX */ if (remember) { idxptr2->allocated = 0; /* Unused index */ idxptr2->session = NULL; return SNMP_ERR_NOERROR; } /* * If this is a failed attempt to register a * number of indexes, the successful ones * must be removed completely. */ if (prev_idx_ptr) { prev_idx_ptr->next_idx = idxptr2->next_idx; } else if (prev_oid_ptr) { if (idxptr2->next_idx) /* Use p_idx_ptr as a temp variable */ prev_idx_ptr = idxptr2->next_idx; else prev_idx_ptr = idxptr2->next_oid; while (prev_oid_ptr) { prev_oid_ptr->next_oid = prev_idx_ptr; prev_oid_ptr = prev_oid_ptr->next_idx; } } else { if (idxptr2->next_idx) snmp_index_head = idxptr2->next_idx; else snmp_index_head = idxptr2->next_oid; } snmp_free_var(idxptr2->varbind); free(idxptr2); return SNMP_ERR_NOERROR; }
false
false
false
false
false
0
selectVSplatUimmPow2(SDValue N, SDValue &Imm) const { APInt ImmValue; EVT EltTy = N->getValueType(0).getVectorElementType(); if (N->getOpcode() == ISD::BITCAST) N = N->getOperand(0); if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && ImmValue.getBitWidth() == EltTy.getSizeInBits()) { int32_t Log2 = ImmValue.exactLogBase2(); if (Log2 != -1) { Imm = CurDAG->getTargetConstant(Log2, SDLoc(N), EltTy); return true; } } return false; }
false
false
false
false
false
0
xen_boot_params_init_edd(void) { #if IS_ENABLED(CONFIG_EDD) struct xen_platform_op op; struct edd_info *edd_info; u32 *mbr_signature; unsigned nr; int ret; edd_info = boot_params.eddbuf; mbr_signature = boot_params.edd_mbr_sig_buffer; op.cmd = XENPF_firmware_info; op.u.firmware_info.type = XEN_FW_DISK_INFO; for (nr = 0; nr < EDDMAXNR; nr++) { struct edd_info *info = edd_info + nr; op.u.firmware_info.index = nr; info->params.length = sizeof(info->params); set_xen_guest_handle(op.u.firmware_info.u.disk_info.edd_params, &info->params); ret = HYPERVISOR_dom0_op(&op); if (ret) break; #define C(x) info->x = op.u.firmware_info.u.disk_info.x C(device); C(version); C(interface_support); C(legacy_max_cylinder); C(legacy_max_head); C(legacy_sectors_per_track); #undef C } boot_params.eddbuf_entries = nr; op.u.firmware_info.type = XEN_FW_DISK_MBR_SIGNATURE; for (nr = 0; nr < EDD_MBR_SIG_MAX; nr++) { op.u.firmware_info.index = nr; ret = HYPERVISOR_dom0_op(&op); if (ret) break; mbr_signature[nr] = op.u.firmware_info.u.disk_mbr_signature.mbr_signature; } boot_params.edd_mbr_sig_buf_entries = nr; #endif }
false
false
false
false
false
0
lua_isnumber (lua_State *L, int idx) { TObject n; const TObject *o = luaA_indexAcceptable(L, idx); return (o != NULL && tonumber(o, &n)); }
false
false
false
false
false
0
Set_location ( char *text // ->first digit of line #. ) { char *name; int line = strtol(text, &name, 10); char *ename; name = Find_name(name, ename); if (!name) return; //cout << "Setting location at line " << line - 1 << endl; // We're 0-based. Uc_location::set_cur(name, line - 1); *name = '"'; // Restore text. }
false
false
false
false
false
0
save_result(GabeditFileChooser *SelecFile, gint response_id) { gchar *fileName; GtkWidget *textResult = NULL; gchar *temp; FILE *file; gint i; if(response_id != GTK_RESPONSE_OK) return; fileName = gabedit_file_chooser_get_current_file(SelecFile); if ((!fileName) || (strcmp(fileName,"") == 0)) { Message(_("Sorry\n No selected file"),_("Error"),TRUE); return ; } textResult = g_object_get_data (G_OBJECT (SelecFile), "TextResult"); if(!textResult) return; gtk_widget_hide(GTK_WIDGET(SelecFile)); while( gtk_events_pending() ) gtk_main_iteration(); file = FOpen(fileName, "wb"); if(file == NULL) { Message(_("Sorry, I can not save file"),_("Error"),TRUE); return; } temp=gabedit_text_get_chars(textResult,0,-1); for(i=0;i<strlen(temp);i++) if(temp[i]=='\r') temp[i] = ' '; fprintf(file,"%s",temp); fclose(file); g_free(temp); }
false
false
false
false
false
0
e_int_border_menu_hook_add(E_Border_Menu_Hook_Cb cb, const void *data) { E_Border_Menu_Hook *h; if (!cb) return NULL; h = E_NEW(E_Border_Menu_Hook, 1); if (!h) return NULL; h->cb = cb; h->data = (void*)data; menu_hooks = eina_list_append(menu_hooks, h); return h; }
false
false
false
false
false
0
cmdline_parser_release (struct gengetopt_args_info *args_info) { unsigned int i; free_string_field (&(args_info->add_all_arg)); free_string_field (&(args_info->add_all_orig)); free_string_field (&(args_info->recursive_arg)); free_string_field (&(args_info->recursive_orig)); free_string_field (&(args_info->sort_arg)); free_string_field (&(args_info->sort_orig)); free_string_field (&(args_info->shuffle_arg)); free_string_field (&(args_info->shuffle_orig)); free_string_field (&(args_info->force_load_arg)); free_string_field (&(args_info->force_load_orig)); free_string_field (&(args_info->client_arg)); free_string_field (&(args_info->client_orig)); free_string_field (&(args_info->client_clear_arg)); free_string_field (&(args_info->client_clear_orig)); free_string_field (&(args_info->build_menus_arg)); free_string_field (&(args_info->build_menus_orig)); free_string_field (&(args_info->glivrc_arg)); free_string_field (&(args_info->glivrc_orig)); free_string_field (&(args_info->slide_show_arg)); free_string_field (&(args_info->slide_show_orig)); free_string_field (&(args_info->null_arg)); free_string_field (&(args_info->null_orig)); free_string_field (&(args_info->collection_arg)); free_string_field (&(args_info->collection_orig)); free_string_field (&(args_info->geometry_arg)); free_string_field (&(args_info->geometry_orig)); for (i = 0; i < args_info->inputs_num; ++i) free (args_info->inputs [i]); if (args_info->inputs_num) free (args_info->inputs); clear_given (args_info); }
false
false
false
false
false
0
irqsoff_print_header(struct seq_file *s) { struct trace_array *tr = irqsoff_trace; if (is_graph(tr)) print_graph_headers_flags(s, GRAPH_TRACER_FLAGS); else trace_default_header(s); }
false
false
false
false
false
0
HPDF_Annotation_New (HPDF_MMgr mmgr, HPDF_Xref xref, HPDF_AnnotType type, HPDF_Rect rect) { HPDF_Annotation annot; HPDF_Array array; HPDF_STATUS ret = HPDF_OK; HPDF_REAL tmp; HPDF_PTRACE((" HPDF_Annotation_New\n")); annot = HPDF_Dict_New (mmgr); if (!annot) return NULL; if (HPDF_Xref_Add (xref, annot) != HPDF_OK) return NULL; array = HPDF_Array_New (mmgr); if (!array) return NULL; if (HPDF_Dict_Add (annot, "Rect", array) != HPDF_OK) return NULL; if (rect.top < rect.bottom) { tmp = rect.top; rect.top = rect.bottom; rect.bottom = tmp; } ret += HPDF_Array_AddReal (array, rect.left); ret += HPDF_Array_AddReal (array, rect.bottom); ret += HPDF_Array_AddReal (array, rect.right); ret += HPDF_Array_AddReal (array, rect.top); ret += HPDF_Dict_AddName (annot, "Type", "Annot"); ret += HPDF_Dict_AddName (annot, "Subtype", HPDF_ANNOT_TYPE_NAMES[(HPDF_INT)type]); if (ret != HPDF_OK) return NULL; annot->header.obj_class |= HPDF_OSUBCLASS_ANNOTATION; return annot; }
false
false
false
false
false
0
srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, u64 lun, u8 func, u8 *status) { struct srp_target_port *target = ch->target; struct srp_rport *rport = target->rport; struct ib_device *dev = target->srp_host->srp_dev->dev; struct srp_iu *iu; struct srp_tsk_mgmt *tsk_mgmt; int res; if (!ch->connected || target->qp_in_error) return -1; /* * Lock the rport mutex to avoid that srp_create_ch_ib() is * invoked while a task management function is being sent. */ mutex_lock(&rport->mutex); spin_lock_irq(&ch->lock); iu = __srp_get_tx_iu(ch, SRP_IU_TSK_MGMT); spin_unlock_irq(&ch->lock); if (!iu) { mutex_unlock(&rport->mutex); return -1; } ib_dma_sync_single_for_cpu(dev, iu->dma, sizeof *tsk_mgmt, DMA_TO_DEVICE); tsk_mgmt = iu->buf; memset(tsk_mgmt, 0, sizeof *tsk_mgmt); tsk_mgmt->opcode = SRP_TSK_MGMT; int_to_scsilun(lun, &tsk_mgmt->lun); tsk_mgmt->tsk_mgmt_func = func; tsk_mgmt->task_tag = req_tag; spin_lock_irq(&ch->lock); ch->tsk_mgmt_tag = (ch->tsk_mgmt_tag + 1) | SRP_TAG_TSK_MGMT; tsk_mgmt->tag = ch->tsk_mgmt_tag; spin_unlock_irq(&ch->lock); init_completion(&ch->tsk_mgmt_done); ib_dma_sync_single_for_device(dev, iu->dma, sizeof *tsk_mgmt, DMA_TO_DEVICE); if (srp_post_send(ch, iu, sizeof(*tsk_mgmt))) { srp_put_tx_iu(ch, iu, SRP_IU_TSK_MGMT); mutex_unlock(&rport->mutex); return -1; } res = wait_for_completion_timeout(&ch->tsk_mgmt_done, msecs_to_jiffies(SRP_ABORT_TIMEOUT_MS)); if (res > 0 && status) *status = ch->tsk_mgmt_status; mutex_unlock(&rport->mutex); WARN_ON_ONCE(res < 0); return res > 0 ? 0 : -1; }
false
false
false
false
false
0
ldns_dnssec_zone_add_rr(ldns_dnssec_zone *zone, ldns_rr *rr) { ldns_status result = LDNS_STATUS_OK; ldns_dnssec_name *cur_name; ldns_rbnode_t *cur_node; ldns_rr_type type_covered = 0; if (!zone || !rr) { return LDNS_STATUS_ERR; } if (!zone->names) { zone->names = ldns_rbtree_create(ldns_dname_compare_v); if(!zone->names) return LDNS_STATUS_MEM_ERR; } /* we need the original of the hashed name if this is an NSEC3, or an RRSIG that covers an NSEC3 */ if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_RRSIG) { type_covered = ldns_rdf2rr_type(ldns_rr_rrsig_typecovered(rr)); } if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_NSEC3 || type_covered == LDNS_RR_TYPE_NSEC3) { cur_node = ldns_dnssec_zone_find_nsec3_original(zone, rr); if (!cur_node) { return LDNS_STATUS_DNSSEC_NSEC3_ORIGINAL_NOT_FOUND; } } else { cur_node = ldns_rbtree_search(zone->names, ldns_rr_owner(rr)); } if (!cur_node) { /* add */ cur_name = ldns_dnssec_name_new_frm_rr(rr); if(!cur_name) return LDNS_STATUS_MEM_ERR; cur_node = LDNS_MALLOC(ldns_rbnode_t); if(!cur_node) { ldns_dnssec_name_free(cur_name); return LDNS_STATUS_MEM_ERR; } cur_node->key = ldns_rr_owner(rr); cur_node->data = cur_name; (void)ldns_rbtree_insert(zone->names, cur_node); ldns_dnssec_name_make_hashed_name(zone, cur_name, NULL); } else { cur_name = (ldns_dnssec_name *) cur_node->data; result = ldns_dnssec_name_add_rr(cur_name, rr); } if (ldns_rr_get_type(rr) == LDNS_RR_TYPE_SOA) { zone->soa = cur_name; } return result; }
false
false
false
false
false
0
mtr_min(A) VARIABLE *A; { VARIABLE *C; double *a = MATR(A), *c; int nrowa = NROW(A), ncola = NCOL(A); int i, j; if (nrowa == 1 || ncola == 1) { C = var_temp_new(TYPE_DOUBLE, 1, 1); c = MATR(C); *c = *a++; nrowa = max(ncola, nrowa); for(i = 1; i < nrowa; i++, a++) *c = min(*c, *a); } else { C = var_temp_new(TYPE_DOUBLE, 1, ncola); c = MATR(C); for(i = 0; i < ncola; i++, c++) { *c = MA(0, i); for(j = 1; j < nrowa; j++) *c = min(*c, MA(j, i)); } } return C; }
false
false
false
false
false
0
bringSlavesUpToMin(EventSelector *es, int fd, unsigned int flags, void *data) { Slave *s; char reason[200]; minScheduled = 0; if (NUM_RUNNING_SLAVES >= Settings.minSlaves) { /* Enough slaves, so do nothing */ return; } /* Start a slave */ s = Slaves[STATE_STOPPED]; if (s) { snprintf(reason, sizeof(reason), "Bringing slaves up to minSlaves (%d)", Settings.minSlaves); if (activateSlave(s, reason) >= 0) { /* Check for and handle queued requests, if there are any */ /* FOR THE FUTURE handle_queued_request(); */ } } /* Reschedule if necessary */ if (NUM_RUNNING_SLAVES < Settings.minSlaves) { scheduleBringSlavesUpToMin(es); } }
true
true
false
false
false
1