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
clear_area(int startx, int starty, int xsize, int ysize) { int x; TRACE_LOG("Clearing area %d,%d / %d,%d\n", startx, starty, xsize, ysize); while (ysize > 0) { x = xsize; while (x > 0) { mvaddch(starty + ysize - 2, startx + x - 2, ' '); x--; } ysize--; } }
false
false
false
false
false
0
ReconstructDuList(Statement* head) { Statement* spt; for (spt = head; spt != NULL; spt = spt->next) { delete_def_use_list(spt->use_var_list); delete_def_use_list(spt->def_var_list); delete_def_use_list(spt->use_array_list); delete_def_use_list(spt->def_array_list); spt->def_var_list = NULL; spt->use_var_list = NULL; spt->def_array_list = NULL; spt->use_array_list = NULL; } def_use_statement(head); }
false
false
false
false
false
0
free_speaker(void) { if(Lengths) free(Lengths); if(!audio2fast && commento) fclose(commento); frase = NON_DECISA; game_status = S_NON_INIZIATO; fondolen = sound[FONDO]->Length; fondobase = sound[FONDO]->SoundData; if (audio2fast && comment_file) free(comment_file); Lengths = NULL; commento = NULL; comment_file = NULL; }
false
false
false
false
false
0
mlx4_register_device(struct mlx4_dev *dev) { struct mlx4_priv *priv = mlx4_priv(dev); struct mlx4_interface *intf; mutex_lock(&intf_mutex); dev->persist->interface_state |= MLX4_INTERFACE_STATE_UP; list_add_tail(&priv->dev_list, &dev_list); list_for_each_entry(intf, &intf_list, list) mlx4_add_device(intf, priv); mutex_unlock(&intf_mutex); mlx4_start_catas_poll(dev); return 0; }
false
false
false
false
false
0
Parse_Env_Var(void) { char *p = getenv("LINEDIT"); if (p == NULL) return; if (strstr(p, "gui=no") != NULL) use_gui = 0; if (strstr(p, "ansi=no") != NULL) use_ansi = 0; if ((p = strstr(p, "out=")) != NULL) { p += 4; if (isdigit(*p)) fd_out = strtol(p, NULL, 10); else { char buff[1024]; char *q = buff; while(*p && isprint(*p) && !isspace(*p)) *q++ = *p++; *q = '\0'; fd_out = open(buff, O_WRONLY); /* on error fd_out = -1 */ } } }
true
true
false
false
true
1
nilfs_superblock_sb_update_frequency_store(struct nilfs_superblock_attr *attr, struct the_nilfs *nilfs, const char *buf, size_t count) { unsigned val; int err; err = kstrtouint(skip_spaces(buf), 0, &val); if (err) { printk(KERN_ERR "NILFS: unable to convert string: err=%d\n", err); return err; } if (val < NILFS_SB_FREQ) { val = NILFS_SB_FREQ; printk(KERN_WARNING "NILFS: superblock update frequency cannot be lesser than 10 seconds\n"); } down_write(&nilfs->ns_sem); nilfs->ns_sb_update_freq = val; up_write(&nilfs->ns_sem); return count; }
false
false
false
false
false
0
r_HP_QP(jxr_image_t image, struct rbitstream*str) { unsigned q; for (q = 0 ; q < image->num_hp_qps ; q += 1) { unsigned idx; int ch_mode = get_ch_mode(image, str); DEBUG("HP_QP[%u] CH_MODE: %d ", q, ch_mode); switch (ch_mode) { case 0: /* UNIFORM */ image->HP_QUANT_Y[q] = _jxr_rbitstream_uint8(str); DEBUG("UNIFORM %d", image->hp_quant_ch[0][q]); for (idx = 1 ; idx < image->num_channels ; idx += 1) image->hp_quant_ch[idx][q] = image->hp_quant_ch[0][q]; break; case 1: /* SEPARATE */ image->HP_QUANT_Y[q] = _jxr_rbitstream_uint8(str); image->hp_quant_ch[1][q] = _jxr_rbitstream_uint8(str); DEBUG("SEPARATE Y=%d Chr=%d", image->hp_quant_ch[0][q], image->hp_quant_ch[1][q]); for (idx = 2 ; idx < image->num_channels ; idx += 1) image->hp_quant_ch[idx][q] = image->hp_quant_ch[1][q]; break; case 2: /* INDEPENDENT */ DEBUG("INDEPENDENT ="); for (idx = 0 ; idx < image->num_channels ; idx += 1) { image->hp_quant_ch[idx][q] = _jxr_rbitstream_uint8(str); DEBUG(" %d", image->hp_quant_ch[idx][q]); } break; case 3: /* Reserved */ break; default: assert(0); break; } DEBUG(" bitpos=%zu\n", _jxr_rbitstream_bitpos(str)); } return 0; }
false
false
false
false
false
0
PylonGuardJustDied(Creature* pCreature) { for (uint8 i = 0; i < MAX_GENERATORS; ++i) { // Skip already activated generators if (GetData(TYPE_PYLON_1 + i) == DONE) { continue; } // Only process generator where the npc is sorted in if (m_sSortedGeneratorGuards[i].find(pCreature->GetGUIDLow()) != m_sSortedGeneratorGuards[i].end()) { m_sSortedGeneratorGuards[i].erase(pCreature->GetGUIDLow()); if (m_sSortedGeneratorGuards[i].empty()) { SetData(TYPE_PYLON_1 + i, DONE); } break; } } }
false
false
false
false
false
0
linda_ib_epb_wait ( struct linda *linda, struct QIB_7220_ibsd_epb_transaction_reg *xact ) { unsigned int i; /* Discard first read to allow for signals crossing clock domains */ linda_readq ( linda, xact, QIB_7220_ibsd_epb_transaction_reg_offset ); for ( i = 0 ; i < LINDA_EPB_XACT_MAX_WAIT_US ; i++ ) { linda_readq ( linda, xact, QIB_7220_ibsd_epb_transaction_reg_offset ); if ( BIT_GET ( xact, ib_epb_rdy ) ) { if ( BIT_GET ( xact, ib_epb_req_error ) ) { DBGC ( linda, "Linda %p EPB transaction " "failed\n", linda ); return -EIO; } else { return 0; } } udelay ( 1 ); } DBGC ( linda, "Linda %p timed out waiting for IB EPB transaction\n", linda ); return -ETIMEDOUT; }
false
false
false
false
false
0
median(const double *src, unsigned int len) { unsigned int i, j; double tmp = 0.0; double tempMedian; double medianVal; double* scratch = new double[ len ];//Vector < double > sortedX = Vector < double > ( size ); for ( i = 0; i < len; i++ ) { scratch[i] = src[i]; } for ( i = 0; i < len - 1; i++ ) { for ( j = 0; j < len - 1 - i; j++ ) { if ( scratch[j + 1] < scratch[j] ) { // compare the two neighbors tmp = scratch[j]; // swap a[j] and a[j+1] scratch[j] = scratch[j + 1]; scratch[j + 1] = tmp; } } } int middle; if ( len % 2 == 0 ) { middle = len / 2; tempMedian = ( scratch[middle] + scratch[middle - 1] ) / 2; } else { middle = ( int )floor( len / 2.0 ); tempMedian = scratch[middle]; } medianVal = tempMedian; delete [] scratch; return medianVal; }
false
false
false
false
false
0
img_filename(const char *mapimgfile, enum imageformat format, char *filename, size_t filename_len) { fc_assert_ret_val(imageformat_is_valid(format) , FALSE); fc_snprintf(filename, filename_len, "%s.map.%s", mapimgfile, imageformat_name(format)); return TRUE; }
true
true
false
false
false
1
restore(const KConfigGroup &config) { init(config); d->initialized = true; if (!d->pendingUrls.isEmpty()) { setUrls(d->pendingUrls); d->pendingUrls.clear(); } }
false
false
false
false
false
0
IterateFunctions(ObjectVisitor* v) { for (int i = 0; i < kSubCacheCount; i++) { subcaches[i]->IterateFunctions(v); } }
false
false
false
false
false
0
surrender(int toNationRecno) { news_array.nation_surrender(nation_recno, toNationRecno); //---- the king demote himself to General first ----// if( king_unit_recno ) { unit_array[king_unit_recno]->set_rank(RANK_GENERAL); king_unit_recno = 0; } //------- if the player surrenders --------// if( nation_recno==nation_array.player_recno ) game.game_end(0, 1, toNationRecno); //--- hand over the entire nation to another nation ---// hand_over_to(toNationRecno); }
false
false
false
false
false
0
sigar_net_interface_list_get(sigar_t *sigar, sigar_net_interface_list_t *iflist) { int n, lastlen=0; struct ifreq *ifr; struct ifconf ifc; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) { return errno; } for (;;) { if (!sigar->ifconf_buf || lastlen) { sigar->ifconf_len += sizeof(struct ifreq) * SIGAR_NET_IFLIST_MAX; sigar->ifconf_buf = realloc(sigar->ifconf_buf, sigar->ifconf_len); } ifc.ifc_len = sigar->ifconf_len; ifc.ifc_buf = sigar->ifconf_buf; if (ioctl(sock, MY_SIOCGIFCONF, &ifc) < 0) { /* EINVAL should mean num_interfaces > ifc.ifc_len */ if ((errno != EINVAL) || (lastlen == ifc.ifc_len)) { free(ifc.ifc_buf); return errno; } } if (ifc.ifc_len < sigar->ifconf_len) { break; /* got em all */ } if (ifc.ifc_len != lastlen) { /* might be more */ lastlen = ifc.ifc_len; continue; } break; } close(sock); iflist->number = 0; iflist->size = ifc.ifc_len; iflist->data = malloc(sizeof(*(iflist->data)) * iflist->size); ifr = ifc.ifc_req; for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq), ifr++) { #if defined(_AIX) || defined(__osf__) /* pass the bourbon */ if (ifr->ifr_addr.sa_family != AF_LINK) { /* XXX: dunno if this is right. * otherwise end up with two 'en0' and three 'lo0' * with the same ip address. */ continue; } # ifdef __osf__ /* weed out "sl0", "tun0" and the like */ /* XXX must be a better way to check this */ if (!sigar_netif_configured(sigar, ifr->ifr_name)) { continue; } # endif #endif iflist->data[iflist->number++] = sigar_strdup(ifr->ifr_name); } #ifdef __linux__ proc_net_interface_list_get(sigar, iflist); #endif return SIGAR_OK; }
false
true
false
false
true
1
transport_from_tile(struct unit *punit, struct tile *ptile) { unit_list_iterate(ptile->units, ptransport) { if (could_unit_load(punit, ptransport)) { return ptransport; } } unit_list_iterate_end; return NULL; }
false
false
false
false
false
0
SolveQuadratic( double* c, double* r, int* m ) { if( ! c[0] ) { if( c[1] ) { r[0] = -c[2] / c[1]; m[0] = 1; return 1; } else { if ( c[2] ) return 0; else return -1; } } double delta = c[1] * c[1] - 4. * c[0] * c[2]; if ( delta >= 0. ) { double fac = 1. / ( 2. * c[0] ); // check whether there are 2 simple or 1 double root(s) if ( delta ) { delta = sqrt( delta ); // insert 1st simple real root r[0] = ( - delta - c[1] ) * fac; m[0] = 1; // insert 2nd simple real root r[1] = ( delta - c[1] ) * fac ; m[1] = 1; return 2; } else { // insert single double real root r[0] = - c[1] * fac; m[0] = 2; return 1; } } else { return 0; } }
false
false
false
false
false
0
decodeData(unsigned char * data) { int byteCounter = 0; int loopCounter = 0; for(int i = 0; i < mHeight; i++) { for(int j = 0; j < mWidth; j++) { byteCounter = loopCounter / 8; if (((data[byteCounter] >> (loopCounter % 8)) & 0x01) == 0x01) { maBoard[i][j] = true; } else { maBoard[i][j] = false; } loopCounter++; } } for(int i = 0; i < byteCounter; i++) { maEncodeData[i] = data[i]; } mCurModifyID = 0; mLastModifyID = 0; }
false
false
false
false
false
0
dispatch(Window win, XEvent &ev, bool parent) { EventHandler *evhand = 0; if (parent) { EventHandlerMap::iterator it = m_parent.find(win); if (it == m_parent.end()) return; else evhand = it->second; } else { win = getEventWindow(ev); EventHandlerMap::iterator it = m_eventhandlers.find(win); if (it == m_eventhandlers.end()) return; else evhand = it->second; } if (evhand == 0) return; switch (ev.type) { case KeyPress: evhand->keyPressEvent(ev.xkey); break; case KeyRelease: evhand->keyReleaseEvent(ev.xkey); break; case ButtonPress: evhand->buttonPressEvent(ev.xbutton); break; case ButtonRelease: evhand->buttonReleaseEvent(ev.xbutton); break; case MotionNotify: evhand->motionNotifyEvent(ev.xmotion); break; case Expose: evhand->exposeEvent(ev.xexpose); break; case EnterNotify: evhand->enterNotifyEvent(ev.xcrossing); break; case LeaveNotify: evhand->leaveNotifyEvent(ev.xcrossing); break; default: evhand->handleEvent(ev); break; }; // find out which window is the parent and // dispatch event Window root, parent_win, *children = 0; unsigned int num_children; if (XQueryTree(FbTk::App::instance()->display(), win, &root, &parent_win, &children, &num_children) != 0) { if (children != 0) XFree(children); if (parent_win != 0 && parent_win != root) { if (m_parent[parent_win] == 0) return; // dispatch event to parent dispatch(parent_win, ev, true); } } }
false
false
false
false
false
0
XbaeMatrixSetRowLabel(w, row, value) Widget w; int row; String value; { XbaeMatrixWidget mw; if (!XtIsSubclass(w, xbaeMatrixWidgetClass)) return; mw = (XbaeMatrixWidget) w; if (!mw->matrix.row_labels || !value) { XtAppWarningMsg( XtWidgetToApplicationContext((Widget) mw), "setRowLabel", "noLabels", "XbaeMatrix", "XbaeMatrix: Cannot set row labels when none defined", NULL, 0); return; } XtFree((XtPointer) mw->matrix.row_labels[row]); mw->matrix.row_labels[row] = XtNewString(value); if (xbaeIsRowVisible(mw, row)) { int y; if (IS_LEADING_FIXED_ROW(mw, row)) y = ROW_LABEL_OFFSET(mw) + ROW_HEIGHT(mw) * row; else if (IS_TRAILING_FIXED_ROW(mw, row)) y = TRAILING_FIXED_ROW_LABEL_OFFSET(mw) + ROW_HEIGHT(mw) * (row - TRAILING_VERT_ORIGIN(mw)); else y = ROW_LABEL_OFFSET(mw) + ROW_HEIGHT(mw) * (row - VERT_ORIGIN(mw)); XClearArea(XtDisplay(mw), XtWindow(mw), 0, y, ROW_LABEL_WIDTH(mw), ROW_HEIGHT(mw), False); xbaeDrawRowLabel(mw, row, False); } }
false
false
false
false
false
0
buildTargetRenderState() { // Remove existing destination technique and passes // in order to build it again from scratch. if (mDstTechnique != NULL) { Material* mat = mSrcTechnique->getParent(); for (unsigned short i=0; i < mat->getNumTechniques(); ++i) { if (mat->getTechnique(i) == mDstTechnique) { mat->removeTechnique(i); break; } } destroySGPasses(); } // Create the destination technique and passes. mDstTechnique = mSrcTechnique->getParent()->createTechnique(); mDstTechnique->getUserObjectBindings().setUserAny(SGTechnique::UserKey, Any(this)); *mDstTechnique = *mSrcTechnique; mDstTechnique->setSchemeName(mDstTechniqueSchemeName); createSGPasses(); // Build render state for each pass. for (SGPassIterator itPass = mPassEntries.begin(); itPass != mPassEntries.end(); ++itPass) { assert(!(*itPass)->isIlluminationPass()); // this is not so important, but intended to be so here. (*itPass)->buildTargetRenderState(); } }
false
false
false
false
false
0
OperandsComplete() const { unsigned short NumOperands = TID->getNumOperands(); if (!TID->isVariadic() && getNumOperands()-NumImplicitOps >= NumOperands) return true; // Broken: we have all the operands of this instruction! return false; }
false
false
false
false
false
0
editor() { if( m_localFile ) return m_localFile->editor(); else return Meta::TrackEditorPtr(); }
false
false
false
false
false
0
PyParser_ParseStringObject(const char *s, PyObject *filename, grammar *g, int start, perrdetail *err_ret, int *flags) { struct tok_state *tok; int exec_input = start == file_input; if (initerr(err_ret, filename) < 0) return NULL; if (*flags & PyPARSE_IGNORE_COOKIE) tok = PyTokenizer_FromUTF8(s, exec_input); else tok = PyTokenizer_FromString(s, exec_input); if (tok == NULL) { err_ret->error = PyErr_Occurred() ? E_DECODE : E_NOMEM; return NULL; } #ifndef PGEN Py_INCREF(err_ret->filename); tok->filename = err_ret->filename; #endif return parsetok(tok, g, start, err_ret, flags); }
false
false
false
false
false
0
x509_crt_revoked( const x509_crt *crt, const x509_crl *crl ) { const x509_crl_entry *cur = &crl->entry; while( cur != NULL && cur->serial.len != 0 ) { if( crt->serial.len == cur->serial.len && memcmp( crt->serial.p, cur->serial.p, crt->serial.len ) == 0 ) { if( x509_time_expired( &cur->revocation_date ) ) return( 1 ); } cur = cur->next; } return( 0 ); }
false
false
false
false
false
0
parse_reset(ReaderObj *self) { Py_XDECREF(self->fields); self->fields = PyList_New(0); if (self->fields == NULL) return -1; self->field_len = 0; self->state = START_RECORD; self->numeric_field = 0; return 0; }
false
false
false
false
false
0
add(vector<Edge*> *edges,void* edgeSet) { for (size_t i=0; i<edges->size(); ++i) { Edge *edge=(*edges)[i]; add(edge,edgeSet); } }
false
false
false
false
false
0
count_isoc_trbs_needed(struct xhci_hcd *xhci, struct urb *urb, int i) { int num_trbs = 0; u64 addr, td_len; addr = (u64) (urb->transfer_dma + urb->iso_frame_desc[i].offset); td_len = urb->iso_frame_desc[i].length; num_trbs = DIV_ROUND_UP(td_len + (addr & (TRB_MAX_BUFF_SIZE - 1)), TRB_MAX_BUFF_SIZE); if (num_trbs == 0) num_trbs++; return num_trbs; }
false
false
false
false
false
0
maybe_adjust_types_for_deduction (unification_kind_t strict, tree* parm, tree* arg, tree arg_expr) { int result = 0; switch (strict) { case DEDUCE_CALL: break; case DEDUCE_CONV: { /* Swap PARM and ARG throughout the remainder of this function; the handling is precisely symmetric since PARM will initialize ARG rather than vice versa. */ tree* temp = parm; parm = arg; arg = temp; break; } case DEDUCE_EXACT: /* Core issue #873: Do the DR606 thing (see below) for these cases, too, but here handle it by stripping the reference from PARM rather than by adding it to ARG. */ if (TREE_CODE (*parm) == REFERENCE_TYPE && TYPE_REF_IS_RVALUE (*parm) && TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM && cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED && TREE_CODE (*arg) == REFERENCE_TYPE && !TYPE_REF_IS_RVALUE (*arg)) *parm = TREE_TYPE (*parm); /* Nothing else to do in this case. */ return 0; default: gcc_unreachable (); } if (TREE_CODE (*parm) != REFERENCE_TYPE) { /* [temp.deduct.call] If P is not a reference type: --If A is an array type, the pointer type produced by the array-to-pointer standard conversion (_conv.array_) is used in place of A for type deduction; otherwise, --If A is a function type, the pointer type produced by the function-to-pointer standard conversion (_conv.func_) is used in place of A for type deduction; otherwise, --If A is a cv-qualified type, the top level cv-qualifiers of A's type are ignored for type deduction. */ if (TREE_CODE (*arg) == ARRAY_TYPE) *arg = build_pointer_type (TREE_TYPE (*arg)); else if (TREE_CODE (*arg) == FUNCTION_TYPE) *arg = build_pointer_type (*arg); else *arg = TYPE_MAIN_VARIANT (*arg); } /* From C++0x [14.8.2.1/3 temp.deduct.call] (after DR606), "If P is of the form T&&, where T is a template parameter, and the argument is an lvalue, T is deduced as A& */ if (TREE_CODE (*parm) == REFERENCE_TYPE && TYPE_REF_IS_RVALUE (*parm) && TREE_CODE (TREE_TYPE (*parm)) == TEMPLATE_TYPE_PARM && cp_type_quals (TREE_TYPE (*parm)) == TYPE_UNQUALIFIED && (arg_expr ? real_lvalue_p (arg_expr) /* try_one_overload doesn't provide an arg_expr, but functions are always lvalues. */ : TREE_CODE (*arg) == FUNCTION_TYPE)) *arg = build_reference_type (*arg); /* [temp.deduct.call] If P is a cv-qualified type, the top level cv-qualifiers of P's type are ignored for type deduction. If P is a reference type, the type referred to by P is used for type deduction. */ *parm = TYPE_MAIN_VARIANT (*parm); if (TREE_CODE (*parm) == REFERENCE_TYPE) { *parm = TREE_TYPE (*parm); result |= UNIFY_ALLOW_OUTER_MORE_CV_QUAL; } /* DR 322. For conversion deduction, remove a reference type on parm too (which has been swapped into ARG). */ if (strict == DEDUCE_CONV && TREE_CODE (*arg) == REFERENCE_TYPE) *arg = TREE_TYPE (*arg); return result; }
false
false
false
false
false
0
ping_peer(struct drbd_device *device) { struct drbd_connection *connection = first_peer_device(device)->connection; clear_bit(GOT_PING_ACK, &connection->flags); request_ping(connection); wait_event(connection->ping_wait, test_bit(GOT_PING_ACK, &connection->flags) || device->state.conn < C_CONNECTED); }
false
false
false
false
false
0
toAscii(const FXString& s){ register FXint p=0; FXString result; FXwchar c; while(p<s.length()){ c=s.wc(p); if(0x80<=c){ result.append("\\u"); result.append(FXString::HEX[(c>>12)&15]); result.append(FXString::HEX[(c>>8)&15]); result.append(FXString::HEX[(c>>4)&15]); c=FXString::HEX[c&15]; } result.append(c); p+=s.extent(p); } return result; }
false
false
false
false
false
0
TabbingNextCellEnd(char *t, char **cell_end, char **next_cell) /****************************************************************************** purpose: find the end of this tabbing cell ******************************************************************************/ { char *s; s = t; while (s) { if (*s == '\0') { *cell_end = s; *next_cell = s; return; } if (*s == '\\') { s++; s = skip_verb(s); if (*s == '=' || *s == '>' || *s == '<' || *s == '\'' || *s == '`') { *cell_end = s - 1; *next_cell = s + 1; return; } } if (*s == '\0') { *cell_end = s; *next_cell = s; return; } s++; } }
false
false
false
false
false
0
inf_gtk_chat_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec) { InfGtkChat* chat; InfGtkChatPrivate* priv; chat = INF_GTK_CHAT(object); priv = INF_GTK_CHAT_PRIVATE(chat); switch(prop_id) { case PROP_SESSION: g_value_set_object(value, priv->session); break; case PROP_ACTIVE_USER: g_value_set_object(value, priv->active_user); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; } }
false
false
false
false
false
0
match_init_copy(obj, orig) VALUE obj, orig; { if (obj == orig) return obj; if (!rb_obj_is_instance_of(orig, rb_obj_class(obj))) { rb_raise(rb_eTypeError, "wrong argument class"); } RMATCH(obj)->str = RMATCH(orig)->str; re_free_registers(RMATCH(obj)->regs); RMATCH(obj)->regs->allocated = 0; re_copy_registers(RMATCH(obj)->regs, RMATCH(orig)->regs); return obj; }
false
false
false
false
false
0
s910_decompress (void* handle, struct ng_video_buf* out, struct ng_video_buf* in) { int row, col; int val; int bitpos; unsigned char code; unsigned char* addr; int width; int height; unsigned char* inp; unsigned char* outp; unsigned char* inp_save; struct S910Context* pContext; if (!init_done) return; pContext = (struct S910Context*)handle; width = out->fmt.width; height = out->fmt.height; inp = in->data; outp = pContext->sTempBuffer; inp_save = in->data; bitpos = 0; for (row = 0; row < height; row++) { col = 0; /* first two pixels in first two rows are stored as raw 8-bit */ if (row < 2) { addr = inp + (bitpos >> 3); code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); bitpos += 8; *outp++ = code; addr = inp + (bitpos >> 3); code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); bitpos += 8; *outp++ = code; col += 2; } while (col < width) { /* get bitcode from bitstream */ addr = inp + (bitpos >> 3); code = (addr[0] << (bitpos & 7)) | (addr[1] >> (8 - (bitpos & 7))); /* update bit position */ bitpos += table[code].len; /* update code statistics */ sonix_unknown += table[code].unk; /* calculate pixel value */ val = table[code].val; if (!table[code].is_abs) { /* value is relative to top and left pixel */ if (col < 2) { /* left column: relative to top pixel */ val += outp[-2 * width]; } else if (row < 2) { /* top row: relative to left pixel */ val += outp[-2]; } else { /* main area: average of left pixel and top pixel */ val += (outp[-2] + outp[-2 * width]) / 2; } } /* store pixel */ *outp++ = CLAMP(val); col++; } } in->data = pContext->sTempBuffer; bayer_decompress(NULL, out, in); in->data = inp_save; }
false
false
false
false
false
0
GaussianSetHistogram(struct histogram_s *h, float mean, float sd) { int sc; int hsize, idx; int nbins; float delta; UnfitHistogram(h); h->fit_type = HISTFIT_GAUSSIAN; h->param[GAUSS_MEAN] = mean; h->param[GAUSS_SD] = sd; /* Calculate the expected values for the histogram. */ hsize = h->max - h->min + 1; h->expect = (float *) MallocOrDie(sizeof(float) * hsize); for (idx = 0; idx < hsize; idx++) h->expect[idx] = 0.; /* Note: ideally we'd use the Gaussian distribution function * to find the histogram occupancy in the window sc..sc+1. * However, the distribution function is hard to calculate. * Instead, estimate the histogram by taking the density at sc+0.5. */ for (sc = h->min; sc <= h->max; sc++) { delta = ((float)sc + 0.5) - h->param[GAUSS_MEAN]; h->expect[sc - h->min] = (float) h->total * ((1. / (h->param[GAUSS_SD] * sqrt(2.*3.14159))) * (exp(-1.*delta*delta / (2. * h->param[GAUSS_SD] * h->param[GAUSS_SD])))); } /* Calculate the goodness-of-fit (within whole region) */ h->chisq = 0.; nbins = 0; for (sc = h->lowscore; sc <= h->highscore; sc++) if (h->expect[sc-h->min] >= 5. && h->histogram[sc-h->min] >= 5) { delta = (float) h->histogram[sc-h->min] - h->expect[sc-h->min]; h->chisq += delta * delta / h->expect[sc-h->min]; nbins++; } /* -1 d.f. for normalization */ if (nbins > 1) h->chip = (float) IncompleteGamma((double)(nbins-1)/2., (double) h->chisq/2.); else h->chip = 0.; }
false
false
false
false
false
0
bcast_sched_linear(int rank, int p, int root, NBC_Schedule *schedule, void *buffer, int count, MPI_Datatype datatype) { int peer, res; /* send to all others */ if(rank == root) { for (peer=0; peer<p;peer++) { if(peer != root) { /* send msg to peer */ res = NBC_Sched_send(buffer, false, count, datatype, peer, schedule); if (NBC_OK != res) { printf("Error in NBC_Sched_send() (%i)\n", res); return res; } } } } else { /* recv msg from root */ res = NBC_Sched_recv(buffer, false, count, datatype, root, schedule); if (NBC_OK != res) { printf("Error in NBC_Sched_recv() (%i)\n", res); return res; } } return NBC_OK; }
false
false
false
false
false
0
init_store_cols (void) { int total_lines = lines_per_body * columns; int chars_if_truncate = total_lines * (chars_per_column + 1); free (line_vector); /* FIXME: here's where it was allocated. */ line_vector = xmalloc ((total_lines + 1) * sizeof *line_vector); free (end_vector); end_vector = xmalloc (total_lines * sizeof *end_vector); free (buff); buff_allocated = (use_col_separator ? 2 * chars_if_truncate : chars_if_truncate); /* Tune this. */ buff = xmalloc (buff_allocated); }
false
false
false
false
false
0
_e_gadcon_cb_dnd_leave(void *data, const char *type __UNUSED__, void *event __UNUSED__) { E_Gadcon *gc; gc = data; //INF("DND LEAVE"); /* If we exit the starting container hide the gadcon visual */ if (gc->drag_gcc->gadcon == gc) e_gadcon_client_hide(gc->drag_gcc); /* Delete temporary object */ if (!gc->new_gcc) { if (gc->dnd_leave_cb) gc->dnd_leave_cb(gc, gc->drag_gcc); return; } //INF("DELETING new_gcc"); e_object_del(E_OBJECT(gc->new_gcc)); gc->new_gcc = NULL; evas_object_show(gc->drag_gcc->drag.drag->object); if (gc->dnd_leave_cb) gc->dnd_leave_cb(gc, gc->drag_gcc); }
false
false
false
false
false
0
GetVertices (Coord*& x, Coord*& y, int& n) { Vertices* vertices = (Vertices*) GetGraphic(); Transformer t; const Coord* origx, *origy; n = vertices->GetOriginal(origx, origy); ArrayDup(origx, origy, n, x, y); vertices->TotalTransformation(t); t.TransformList(x, y, n); }
false
false
false
false
false
0
aw_input(const char *title, const char *prompt, const char *default_input) { // prompt user to enter a string // // title = title of window // prompt = question // default_input = default for answer (NULL -> "") // // result is NULL, if cancel was pressed // otherwise result contains the user input (maybe an empty string) static AW_window_message *aw_msg = 0; AW_root *root = AW_root::THIS; if (!aw_msg) create_input_awars(root); // first call -> create awars root->awar(AW_INPUT_TITLE_AWAR)->write_string(prompt); aw_assert(strlen(prompt) <= INPUT_SIZE); AW_awar *inAwar = root->awar(AW_INPUT_AWAR); if (default_input) { input_history_insert(default_input, true); // insert default into history inAwar->write_string(default_input); } else { inAwar->write_string(""); } aw_assert(GB_get_transaction_level(inAwar->gb_var) <= 0); // otherwise history would not work if (!aw_msg) { aw_msg = new_input_window(root, title, NULL); aw_msg->window_fit(); } else { aw_msg->set_window_title(title); aw_msg->window_fit(); } aw_msg->window_fit(); aw_msg->show_grabbed(); char dummy[] = ""; aw_input_cb_result = dummy; root->add_timed_callback_never_disabled(AW_MESSAGE_LISTEN_DELAY, aw_message_timer_listen_event, (AW_CL)aw_msg, 0); root->disable_callbacks = true; while (aw_input_cb_result == dummy) { root->process_events(); } root->disable_callbacks = false; aw_msg->hide(); if (aw_input_cb_result) input_history_insert(aw_input_cb_result, true); return aw_input_cb_result; }
false
false
false
false
false
0
hr222_set_hw_capture_level(struct pcxhr_mgr *mgr, int level_l, int level_r, int level_mic) { /* program all input levels at the same time */ unsigned int data; int i; if (!mgr->capture_chips) return -EINVAL; /* no PCX22 */ data = ((level_mic & 0xff) << 24); /* micro is mono, but apply */ data |= ((level_mic & 0xff) << 16); /* level on both channels */ data |= ((level_r & 0xff) << 8); /* line input right channel */ data |= (level_l & 0xff); /* line input left channel */ PCXHR_INPB(mgr, PCXHR_XLX_DATA); /* activate input codec */ /* send 32 bits (4 x 8 bits) */ for (i = 0; i < 32; i++, data <<= 1) { PCXHR_OUTPB(mgr, PCXHR_XLX_DATA, (data & 0x80000000) ? PCXHR_DATA_CODEC : 0); } PCXHR_INPB(mgr, PCXHR_XLX_RUER); /* close input level codec */ return 0; }
false
false
false
false
false
0
xdr_gfs3_xattrop_rsp (XDR *xdrs, gfs3_xattrop_rsp *objp) { register int32_t *buf; buf = NULL; if (!xdr_int (xdrs, &objp->op_ret)) return FALSE; if (!xdr_int (xdrs, &objp->op_errno)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->dict.dict_val, (u_int *) &objp->dict.dict_len, ~0)) return FALSE; if (!xdr_bytes (xdrs, (char **)&objp->xdata.xdata_val, (u_int *) &objp->xdata.xdata_len, ~0)) return FALSE; return TRUE; }
false
false
false
false
false
0
loadProblem(const CoinPackedMatrix& matrix, const double* collb, const double* colub, const double* obj, const double* rowlb, const double* rowub) { const double inf = getInfinity(); int nrows = matrix.getNumRows(); // int ncols = matrix.getNumCols(); char * rowSense = new char [nrows]; double * rowRhs = new double[nrows]; double * rowRange = new double[nrows]; int i; for ( i = nrows - 1; i >= 0; --i ) { const double lower = rowlb ? rowlb[i] : -inf; const double upper = rowub ? rowub[i] : inf; convertBoundToSense( lower, upper, rowSense[i], rowRhs[i], rowRange[i] ); } loadProblem( matrix, collb, colub, obj, rowSense, rowRhs, rowRange ); delete [] rowSense; delete [] rowRhs; delete [] rowRange; }
false
false
false
false
false
0
table_iter_next(HTableIterator iterator) { if (! iterator) return 0; if (iterator->before_start) { iterator->before_start = 0; iterator->cur_field = iterator->table->fields; } else { if (iterator->cur_field) iterator->cur_field = iterator->cur_field->next; } if (! iterator->cur_field) return 0; return 1; }
false
false
false
false
false
0
compile_script(const char *script) { FILE *f; char fn[256], buf[256], *c; int lineno = 0, x, err; struct adsi_script *scr; if (script[0] == '/') ast_copy_string(fn, script, sizeof(fn)); else snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, script); if (!(f = fopen(fn, "r"))) { ast_log(LOG_WARNING, "Can't open file '%s'\n", fn); return NULL; } if (!(scr = ast_calloc(1, sizeof(*scr)))) { fclose(f); return NULL; } /* Create "main" as first subroutine */ getsubbyname(scr, "main", NULL, 0); while (!feof(f)) { if (!fgets(buf, sizeof(buf), f)) { continue; } if (!feof(f)) { lineno++; /* Trim off trailing return */ buf[strlen(buf) - 1] = '\0'; /* Strip comments */ if ((c = strchr(buf, ';'))) *c = '\0'; if (!ast_strlen_zero(buf)) adsi_process(scr, buf, script, lineno); } } fclose(f); /* Make sure we're in the main routine again */ switch(scr->state) { case STATE_NORMAL: break; case STATE_INSUB: ast_log(LOG_WARNING, "Missing ENDSUB at end of file %s\n", script); ast_free(scr); return NULL; case STATE_INKEY: ast_log(LOG_WARNING, "Missing ENDKEY at end of file %s\n", script); ast_free(scr); return NULL; } err = 0; /* Resolve all keys and record their lengths */ for (x = 0; x < scr->numkeys; x++) { if (!scr->keys[x].defined) { ast_log(LOG_WARNING, "Key '%s' referenced but never defined in file %s\n", scr->keys[x].vname, fn); err++; } } /* Resolve all subs */ for (x = 0; x < scr->numsubs; x++) { if (!scr->subs[x].defined) { ast_log(LOG_WARNING, "Subscript '%s' referenced but never defined in file %s\n", scr->subs[x].vname, fn); err++; } if (x == (scr->numsubs - 1)) { /* Clear out extension bit on last message */ scr->subs[x].data[2] = 0x80; } } if (err) { ast_free(scr); return NULL; } return scr; }
false
false
false
false
false
0
pc_delitem(struct map_session_data *sd, int n, int amount, int type, short dtype) { nullpo_retv(sd); if(sd->status.inventory[n].nameid == 0 || amount <= 0 || sd->status.inventory[n].amount < amount || sd->inventory_data[n] == NULL) return; sd->status.inventory[n].amount -= amount; sd->weight -= sd->inventory_data[n]->weight*amount; if(sd->status.inventory[n].amount <= 0) { if(sd->status.inventory[n].equip) { pc_unequipitem(sd,n,0); } if(sd->status.inventory[n].limit > 0) { int tid = PTR2INT(linkdb_erase(&sd->inventory_timer, INT2PTR(n))); if(tid >= 0) delete_timer(tid, pc_itemlimit_timer); } memset(&sd->status.inventory[n],0,sizeof(sd->status.inventory[0])); sd->inventory_num--; sd->inventory_data[n] = NULL; } if(!(type&1)) clif_delitem(sd,dtype,n,amount); if(!(type&2)) clif_updatestatus(sd,SP_WEIGHT); return; }
false
false
false
false
false
0
rspi_rz_set_config_register(struct rspi_data *rspi, int access_size) { int spbr; /* Sets output mode, MOSI signal, and (optionally) loopback */ rspi_write8(rspi, rspi->sppcr, RSPI_SPPCR); /* Sets transfer bit rate */ spbr = DIV_ROUND_UP(clk_get_rate(rspi->clk), 2 * rspi->max_speed_hz) - 1; rspi_write8(rspi, clamp(spbr, 0, 255), RSPI_SPBR); /* Disable dummy transmission, set byte access */ rspi_write8(rspi, SPDCR_SPLBYTE, RSPI_SPDCR); rspi->byte_access = 1; /* Sets RSPCK, SSL, next-access delay value */ rspi_write8(rspi, 0x00, RSPI_SPCKD); rspi_write8(rspi, 0x00, RSPI_SSLND); rspi_write8(rspi, 0x00, RSPI_SPND); /* Sets SPCMD */ rspi->spcmd |= SPCMD_SPB_8_TO_16(access_size); rspi_write16(rspi, rspi->spcmd, RSPI_SPCMD0); /* Sets RSPI mode */ rspi_write8(rspi, SPCR_MSTR, RSPI_SPCR); return 0; }
false
false
false
false
false
0
GenerateGetFromCache(ZoneList<Expression*>* args) { ASSERT_EQ(2, args->length()); ASSERT_NE(NULL, args->at(0)->AsLiteral()); int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value(); Handle<FixedArray> jsfunction_result_caches( Top::global_context()->jsfunction_result_caches()); if (jsfunction_result_caches->length() <= cache_id) { __ Abort("Attempt to use undefined cache."); frame_->Push(Factory::undefined_value()); return; } Load(args->at(1)); Result key = frame_->Pop(); key.ToRegister(); Result cache = allocator()->Allocate(); ASSERT(cache.is_valid()); __ movq(cache.reg(), ContextOperand(rsi, Context::GLOBAL_INDEX)); __ movq(cache.reg(), FieldOperand(cache.reg(), GlobalObject::kGlobalContextOffset)); __ movq(cache.reg(), ContextOperand(cache.reg(), Context::JSFUNCTION_RESULT_CACHES_INDEX)); __ movq(cache.reg(), FieldOperand(cache.reg(), FixedArray::OffsetOfElementAt(cache_id))); Result tmp = allocator()->Allocate(); ASSERT(tmp.is_valid()); Result scratch = allocator()->Allocate(); ASSERT(scratch.is_valid()); DeferredSearchCache* deferred = new DeferredSearchCache(tmp.reg(), cache.reg(), key.reg(), scratch.reg()); const int kFingerOffset = FixedArray::OffsetOfElementAt(JSFunctionResultCache::kFingerIndex); // tmp.reg() now holds finger offset as a smi. __ SmiToInteger32(tmp.reg(), FieldOperand(cache.reg(), kFingerOffset)); __ cmpq(key.reg(), FieldOperand(cache.reg(), tmp.reg(), times_pointer_size, FixedArray::kHeaderSize)); deferred->Branch(not_equal); __ movq(tmp.reg(), FieldOperand(cache.reg(), tmp.reg(), times_pointer_size, FixedArray::kHeaderSize + kPointerSize)); deferred->BindExit(); frame_->Push(&tmp); }
false
false
false
false
false
0
snd_pcm_route_convert(const snd_pcm_channel_area_t *dst_areas, snd_pcm_uframes_t dst_offset, const snd_pcm_channel_area_t *src_areas, snd_pcm_uframes_t src_offset, unsigned int src_channels, unsigned int dst_channels, snd_pcm_uframes_t frames, snd_pcm_route_params_t *params) { unsigned int dst_channel; snd_pcm_route_ttable_dst_t *dstp; const snd_pcm_channel_area_t *dst_area; dstp = params->dsts; dst_area = dst_areas; for (dst_channel = 0; dst_channel < dst_channels; ++dst_channel) { if (dst_channel >= params->ndsts) snd_pcm_route_convert1_zero(dst_area, dst_offset, src_areas, src_offset, src_channels, frames, dstp, params); else dstp->func(dst_area, dst_offset, src_areas, src_offset, src_channels, frames, dstp, params); dstp++; dst_area++; } }
false
false
false
false
false
0
mt_state_free_null(mt_state_t **mts_ptr) { mt_state_t *mts = *mts_ptr; if (mts != NULL) { mt_state_check(mts); WFREE(mts); *mts_ptr = NULL; } }
false
false
false
false
false
0
nextHasLccc() const { U_ASSERT(state == CHECK_FWD && pos != length); // The lowest code point with ccc!=0 is U+0300 which is CC 80 in UTF-8. // CJK U+4000..U+DFFF except U+Axxx are also FCD-inert. (Lead bytes E4..ED except EA.) UChar32 c = u8[pos]; if(c < 0xcc || (0xe4 <= c && c <= 0xed && c != 0xea)) { return FALSE; } int32_t i = pos; U8_NEXT_OR_FFFD(u8, i, length, c); if(c > 0xffff) { c = U16_LEAD(c); } return CollationFCD::hasLccc(c); }
false
false
false
false
false
0
gretl_model_test_print_direct (const ModelTest *test, int heading, PRN *prn) { const char *tstr; char buf[512]; set_alt_gettext_mode(prn); if (rtf_format(prn)) { pputs(prn, "\\par \\ql "); } if (heading) { gretl_test_print_heading(test, prn); } gretl_test_print_h_0(test, heading, prn); tstr = asy_test(test->teststat)? N_("Asymptotic test statistic") : N_("Test statistic"); get_test_stat_string(test, buf, prn); if (plain_format(prn)) { pprintf(prn, "\n %s: %s\n", _(tstr), buf); } else if (tex_format(prn)) { pprintf(prn, "\\\\\n\\quad %s: %s\\\\\n", I_(tstr), buf); } else if (rtf_format(prn)) { pprintf(prn, "\\par\n %s: %s\\par\n", I_(tstr), buf); } get_test_pval_string(test, buf, prn); if (*buf != '\0') { const char *pvstr = asy_pval(test->teststat) ? N_("with asymptotic p-value") : N_("with p-value"); if (plain_format(prn)) { pprintf(prn, " %s = %s\n\n", _(pvstr), buf); } else if (tex_format(prn)) { pprintf(prn, "\\quad %s = %s\\\\\n", A_(pvstr), buf); } else if (rtf_format(prn)) { pprintf(prn, " %s = %s\\par\n\n", A_(pvstr), buf); } } else if (!na(test->crit) && !na(test->alpha)) { double a = test->alpha * 100.0; if (plain_format(prn)) { sprintf(buf, _("%g percent critical value"), a); pprintf(prn, " (%s = %.2f)\n\n", buf, test->crit); } else if (tex_format(prn)) { sprintf(buf, A_("%g percent critical value"), a); pprintf(prn, "\\quad (%s = %.2f)\\\\\n", buf, test->crit); } else if (rtf_format(prn)) { sprintf(buf, A_("%g percent critical value"), a); pprintf(prn, " (%s = %.2f)\\par\n\n", buf, test->crit); } } else { pputc(prn, '\n'); } }
false
false
false
false
false
0
zxenc_pubkey_enc(zxid_conf* cf, struct zx_str* data, struct zx_xenc_EncryptedKey_s** ekp, X509* cert, char* idsuffix, zxid_entity* meta) { struct rsa_st* rsa_pkey; char symkey[128/8]; struct zx_str symkey_ss; struct zx_str* ss; struct zx_str* b64; struct zx_xenc_EncryptedKey_s* ek = zx_NEW_xenc_EncryptedKey(cf->ctx,0); ek->Id = zx_attrf(cf->ctx, &ek->gg, zx_Id_ATTR, "EK%s", idsuffix); ek->EncryptionMethod = zx_NEW_xenc_EncryptionMethod(cf->ctx, &ek->gg); ek->EncryptionMethod->Algorithm = zx_ref_attr(cf->ctx, &ek->EncryptionMethod->gg, zx_Algorithm_ATTR, ENC_KEYTRAN_ALGO); ek->KeyInfo = zxid_key_info(cf, &ek->gg, cert); if (meta && cf->enckey_opt & 0x01) { /* This hack may help early 2010 vintage Shibboleth SP to work without nested EncryptedKey. * (personal communication w/Scott 20100906 --Sampo) */ ek->Recipient = zx_dup_attr(cf->ctx, &ek->gg, zx_Recipient_ATTR, meta->eid); } zx_rand(symkey, sizeof(symkey)); symkey_ss.len = sizeof(symkey); symkey_ss.s = symkey; rsa_pkey = zx_get_rsa_pub_from_cert(cert, "zxenc_pubkey_enc"); if (!rsa_pkey) return 0; /* The padding setting MUST agree with ENC_KEYTRAN_ALGO setting (see near top of this file). */ #if 1 ss = zx_rsa_pub_enc(cf->ctx, &symkey_ss, rsa_pkey, RSA_PKCS1_PADDING); #else /* *** IBM did not interop with OAEP padding as of 20071025 */ ss = zx_rsa_pub_enc(cf->ctx, &symkey_ss, rsa_pkey, RSA_PKCS1_OAEP_PADDING); #endif b64 = zx_new_len_str(cf->ctx, SIMPLE_BASE64_LEN(ss->len)); base64_fancy_raw(ss->s, ss->len, b64->s, std_basis_64, 0, 0, 0, '='); zx_str_free(cf->ctx, ss); ek->CipherData = zx_NEW_xenc_CipherData(cf->ctx, &ek->gg); ek->CipherData->CipherValue = zx_new_str_elem(cf->ctx, &ek->CipherData->gg, zx_xenc_CipherValue_ELEM, b64); ek->ReferenceList = zx_NEW_xenc_ReferenceList(cf->ctx, &ek->gg); ek->ReferenceList->DataReference = zx_NEW_xenc_DataReference(cf->ctx, &ek->ReferenceList->gg); ek->ReferenceList->DataReference->URI = zx_attrf(cf->ctx, &ek->ReferenceList->DataReference->gg, zx_URI_ATTR, "#ED%s", idsuffix); zx_reverse_elem_lists(&ek->gg); if (ekp) *ekp = ek; ss = zx_strf(cf->ctx, "ED%s", idsuffix); return zxenc_symkey_enc(cf, data, ss, &symkey_ss, ek); }
false
false
false
false
false
0
gitg_repository_exists (GitgRepository *repository) { g_return_val_if_fail (GITG_IS_REPOSITORY (repository), FALSE); if (repository->priv->git_dir == NULL) { return FALSE; } return g_file_query_exists (repository->priv->git_dir, NULL) && g_file_query_exists (repository->priv->work_tree, NULL); }
false
false
false
false
false
0
libhydra_init() { private_hydra_t *this; if (hydra) { /* already initialized, increase refcount */ this = (private_hydra_t*)hydra; ref_get(&this->ref); return !this->integrity_failed; } INIT(this, .public = { .attributes = attribute_manager_create(), }, .ref = 1, ); hydra = &this->public; this->public.kernel_interface = kernel_interface_create(); if (lib->integrity && !lib->integrity->check(lib->integrity, "libhydra", libhydra_init)) { DBG1(DBG_LIB, "integrity check of libhydra failed"); this->integrity_failed = TRUE; } return !this->integrity_failed; }
false
false
false
false
false
0
repaint_point (EMap *map, EMapPoint *point) { gdouble px, py; if (!gtk_widget_is_drawable (GTK_WIDGET (map))) return; e_map_world_to_window (map, point->longitude, point->latitude, &px, &py); gtk_widget_queue_draw_area (GTK_WIDGET (map), (gint) px - 2, (gint) py - 2, 5, 5); }
false
false
false
false
false
0
cdiEncodeTimeval(int date, int time, taxis_t *taxis) { double timevalue; if ( taxis->type == TAXIS_ABSOLUTE ) { if ( taxis->unit == TUNIT_YEAR ) { int year, month, day; cdiDecodeDate(date, &year, &month, &day); timevalue = year; } else if ( taxis->unit == TUNIT_MONTH ) { int year, month, day; cdiDecodeDate(date, &year, &month, &day); if ( day == 0 ) timevalue = date/100; else timevalue = date/100 + 0.5; } else { int hour, minute, second; cdiDecodeTime(time, &hour, &minute, &second); if ( date < 0 ) timevalue = -(-date + (hour*3600 + minute*60 + second)/86400.); else timevalue = date + (hour*3600 + minute*60 + second)/86400.; } } else timevalue = vtime2timeval(date, time, taxis); return (timevalue); }
false
false
false
false
false
0
kunify(k1,o1,k2,o2) /* Unify kind expr (k1,o1) with */ Kind k1,k2; /* (k2,o2) */ Int o1,o2; { Tyvar *kyv1, *kyv2; deRef(kyv1,k1,o1); deRef(kyv2,k2,o2); if (kyv1) if (kyv2) return kvarToVarBind(kyv1,kyv2); /* k1, k2 variables */ else return kvarToTypeBind(kyv1,k2,o2); /* k1 variable, k2 not */ else if (kyv2) return kvarToTypeBind(kyv2,k1,o1); /* k2 variable, k1 not */ else { #if DEBUG_KINDS Printf("unifying kinds: "); printType(stdout,debugType(k1,o1)); Printf(" with "); printType(stdout,debugType(k2,o2)); Putchar('\n'); #endif if (k1==STAR && k2==STAR) /* k1, k2 not vars */ return TRUE; #if TREX else if (k1==ROW && k2==ROW) return TRUE; #endif else if (isAp(k1) && isAp(k2)) return kunify(fst(k1),o1,fst(k2),o2) && kunify(snd(k1),o1,snd(k2),o2); } unifyFails = 0; return FALSE; }
false
false
false
false
false
0
GetMathConstantNumber(int currentIndex) { if (strncmp(&this->Function[currentIndex], "iHat", 4) == 0) { return VTK_PARSER_IHAT; } if (strncmp(&this->Function[currentIndex], "jHat", 4) == 0) { return VTK_PARSER_JHAT; } if (strncmp(&this->Function[currentIndex], "kHat", 4) == 0) { return VTK_PARSER_KHAT; } return 0; }
false
false
false
false
false
0
button_release_cb (GocCanvas *canvas, GdkEventButton *event, G_GNUC_UNUSED gpointer data) { double x, y; GocItem *item; if (event->window != gtk_layout_get_bin_window (&canvas->base)) return TRUE; x = (canvas->direction == GOC_DIRECTION_RTL)? canvas->scroll_x1 + (canvas->width - event->x) / canvas->pixels_per_unit: canvas->scroll_x1 + event->x / canvas->pixels_per_unit; y = canvas->scroll_y1 + event->y / canvas->pixels_per_unit; item = (canvas->grabbed_item != NULL)? canvas->grabbed_item: goc_canvas_get_item_at (canvas, x, y); if (item) { gboolean result; canvas->cur_event = (GdkEvent *) event; result = GOC_ITEM_GET_CLASS (item)->button_released (item, event->button, x, y); canvas->cur_event = NULL; return result; } return FALSE; }
false
false
false
false
false
0
skill(int which) { return _current_skills[which] ? _current_skills[which] : P_UNSKILLED; }
false
false
false
false
false
0
sv_selection_copy (SheetView *sv, WorkbookControl *wbc) { GnmRange const *sel; g_return_val_if_fail (IS_SHEET_VIEW (sv), FALSE); if (!(sel = selection_first_range (sv, GO_CMD_CONTEXT (wbc), _("Copy")))) return FALSE; gnm_app_clipboard_cut_copy (wbc, FALSE, sv, sel, TRUE); return TRUE; }
false
false
false
false
false
0
load_modules(const char *name) { struct conf_sect_t *sect; struct conf_option_t *opt; char *fname; char *path = MODULE_PATH; char *ptr1, *ptr2; struct module_t *m; void *h; sect = conf_get_section(name); if (!sect) { fprintf(stderr, "loader: section '%s' not found\n", name); return -1; } fname = _malloc(PATH_MAX); list_for_each_entry(opt, &sect->items, entry) { if (!strcmp(opt->name,"path") && opt->val) { path = opt->val; continue; } strcpy(fname, path); strcat(fname, "/"); strcat(fname, opt->name); if (access(fname, F_OK)) { strcpy(fname, path); strcat(fname, "/lib"); strcat(fname, opt->name); strcat(fname, ".so"); if (access(fname, F_OK)) { strcpy(fname, opt->name); if (access(opt->name, F_OK)) { triton_log_error("loader: '%s' not found", opt->name); continue; } } } h = dlopen(fname, RTLD_LAZY | RTLD_GLOBAL); if (!h) { triton_log_error("loader: failed to load '%s': %s", opt->name, dlerror()); _free(fname); return -1; } ptr1 = fname; while (1) { ptr2 = strchr(ptr1, '/'); if (!ptr2) break; ptr1 = ptr2 + 1; } if (!strncmp(ptr1, "lib", 3)) ptr1 += 3; ptr2 = strstr(ptr1, ".so\x0"); if (ptr2) *ptr2 = 0; m = _malloc(sizeof(*m)); m->name = _strdup(ptr1); m->handle = h; list_add_tail(&m->entry, &modules); } _free(fname); return 0; }
false
false
false
false
false
0
skipToSeparator(char *pStart, int *pNest) #else char * skipToSeparator(pStart, pNest) char *pStart; int *pNest; #endif { char * p = pStart; for ( ; ; ) { p = skipToSeparatorOrEqualSign(p, pNest); if (*pNest != 0) return p; if (*p == ',') return p; if (*p == 0) return p; p++; } }
false
false
false
false
false
0
setDashes(FXuint dashoffset,const FXchar *dashpattern,FXuint dashlength){ register FXuint len,i; for(i=len=0; i<dashlength; i++){ dashpat[i]=dashpattern[i]; len+=(FXuint)dashpattern[i]; } dashlen=dashlength; dashoff=dashoffset%len; }
false
false
false
false
false
0
align_pt_load_xml(gchar * pt_xml_filename, gchar **perror_buf, AmitkSpace *space) { xmlDocPtr doc; AmitkFiducialMark * new_pt; AmitkPoint point; xmlNodePtr nodes; gchar * temp_string; /* parse the xml file */ if ((doc = xmlParseFile(pt_xml_filename)) == NULL) { amitk_append_str_with_newline(perror_buf, "Couldn't Parse AMIDE alignment point xml file %s", pt_xml_filename); return NULL; } /* get the root of our document */ if ((nodes = xmlDocGetRootElement(doc)) == NULL) { amitk_append_str_with_newline(perror_buf,"AMIDE alignment point xml file doesn't appear to have a root: %s", pt_xml_filename); return NULL; } new_pt = amitk_fiducial_mark_new(); /* get the name */ temp_string = xml_get_string(nodes->children, "text"); if (temp_string != NULL) { amitk_object_set_name(AMITK_OBJECT(new_pt), temp_string); g_free(temp_string); } /* get the document tree */ nodes = nodes->children; /* previous to version xif version 2.0, points were defined only with respect to their parent's space*/ amitk_space_copy_in_place(AMITK_SPACE(new_pt), space); /* the "point" option was eliminated in version 0.7.11, just using the space's offset instead */ point = amitk_point_read_xml(nodes, "point", perror_buf); point = amitk_space_s2b(AMITK_SPACE(new_pt), point); amitk_space_set_offset(AMITK_SPACE(new_pt), point); /* and we're done */ xmlFreeDoc(doc); return new_pt; }
false
false
false
false
false
0
usb_dmac_chan_start_desc(struct usb_dmac_chan *chan) { struct virt_dma_desc *vd; vd = vchan_next_desc(&chan->vc); if (!vd) { chan->desc = NULL; return; } /* * Remove this request from vc->desc_issued. Otherwise, this driver * will get the previous value from vchan_next_desc() after a transfer * was completed. */ list_del(&vd->node); chan->desc = to_usb_dmac_desc(vd); chan->desc->sg_index = 0; usb_dmac_chan_start_sg(chan, 0); }
false
false
false
false
false
0
scn_init(char *addr) { int fd, opt, err; union { struct sockaddr s; struct sockaddr_storage ss; struct sockaddr_in s4; struct sockaddr_in6 s6; } l; socklen_t slen; fd = socket(ss.ss_family, SOCK_STREAM, IPPROTO_TCP); if (fd < 0) { log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); return -errno; } opt = 1; if (ss.ss_family == AF_INET6) { err = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)); if (err) log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); goto out; } err = listen(fd, 5); if (err) { log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); goto out; } slen = sizeof(l.s); err = getsockname(fd, &l.s, &slen); if (err) { log_error("%s %d: %s\n", __FUNCTION__, __LINE__, strerror(errno)); goto out; } /* protocol independent way ? */ if (l.ss.ss_family == AF_INET6) scn_listen_port = ntohs((&l.s6)->sin6_port); else scn_listen_port = ntohs((&l.s4)->sin_port); log_error("scn listen port %u %d %d\n", scn_listen_port, fd, err); out: if (err) close(fd); else { scn_listen_fd = fd; isns_set_fd(isns_fd, scn_listen_fd, scn_fd); } return err; }
false
false
false
false
false
0
getPeople() const { std::vector<Person*> people; for (IdPersonMap::const_iterator P=m_members.begin(); P != m_members.end(); ++P) { if (P->second) people.push_back(P->second); } return people; }
false
false
false
false
false
0
savefile_handle_unknown(CdlInterpreter interp, int argc, const char* argv[]) { CYG_REPORT_FUNCNAME("CdlToplevel::savefile_handle_unknown"); CYG_REPORT_FUNCARG2XV(interp, argc); CYG_PRECONDITION_CLASSC(interp); CdlParse::report_error(interp, "", std::string("Unknown command `") + argv[1] + "'."); CYG_UNUSED_PARAM(int, argc); return TCL_OK; }
false
false
false
false
false
0
rl_signal_handler (sig) int sig; { #if defined (HAVE_POSIX_SIGNALS) sigset_t set; #else /* !HAVE_POSIX_SIGNALS */ # if defined (HAVE_BSD_SIGNALS) long omask; # else /* !HAVE_BSD_SIGNALS */ sighandler_cxt dummy_cxt; /* needed for rl_set_sighandler call */ # endif /* !HAVE_BSD_SIGNALS */ #endif /* !HAVE_POSIX_SIGNALS */ RL_SETSTATE(RL_STATE_SIGHANDLER); #if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS) /* Since the signal will not be blocked while we are in the signal handler, ignore it until rl_clear_signals resets the catcher. */ # if defined (SIGALRM) if (sig == SIGINT || sig == SIGALRM) # else if (sig == SIGINT) # endif rl_set_sighandler (sig, SIG_IGN, &dummy_cxt); #endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */ switch (sig) { case SIGINT: rl_free_line_state (); /* FALLTHROUGH */ case SIGTERM: #if defined (SIGTSTP) case SIGTSTP: case SIGTTOU: case SIGTTIN: #endif /* SIGTSTP */ #if defined (SIGALRM) case SIGALRM: #endif #if defined (SIGQUIT) case SIGQUIT: #endif rl_cleanup_after_signal (); #if defined (HAVE_POSIX_SIGNALS) sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set); sigdelset (&set, sig); #else /* !HAVE_POSIX_SIGNALS */ # if defined (HAVE_BSD_SIGNALS) omask = sigblock (0); # endif /* HAVE_BSD_SIGNALS */ #endif /* !HAVE_POSIX_SIGNALS */ #if defined (__EMX__) signal (sig, SIG_ACK); #endif #if defined (HAVE_KILL) kill (getpid (), sig); #else raise (sig); /* assume we have raise */ #endif /* Let the signal that we just sent through. */ #if defined (HAVE_POSIX_SIGNALS) sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL); #else /* !HAVE_POSIX_SIGNALS */ # if defined (HAVE_BSD_SIGNALS) sigsetmask (omask & ~(sigmask (sig))); # endif /* HAVE_BSD_SIGNALS */ #endif /* !HAVE_POSIX_SIGNALS */ rl_reset_after_signal (); } RL_UNSETSTATE(RL_STATE_SIGHANDLER); SIGHANDLER_RETURN; }
false
false
false
false
false
0
bxt_ddi_vswing_sequence(struct drm_device *dev, u32 level, enum port port, int type) { struct drm_i915_private *dev_priv = dev->dev_private; const struct bxt_ddi_buf_trans *ddi_translations; u32 n_entries, i; uint32_t val; if (type == INTEL_OUTPUT_EDP && dev_priv->edp_low_vswing) { n_entries = ARRAY_SIZE(bxt_ddi_translations_edp); ddi_translations = bxt_ddi_translations_edp; } else if (type == INTEL_OUTPUT_DISPLAYPORT || type == INTEL_OUTPUT_EDP) { n_entries = ARRAY_SIZE(bxt_ddi_translations_dp); ddi_translations = bxt_ddi_translations_dp; } else if (type == INTEL_OUTPUT_HDMI) { n_entries = ARRAY_SIZE(bxt_ddi_translations_hdmi); ddi_translations = bxt_ddi_translations_hdmi; } else { DRM_DEBUG_KMS("Vswing programming not done for encoder %d\n", type); return; } /* Check if default value has to be used */ if (level >= n_entries || (type == INTEL_OUTPUT_HDMI && level == HDMI_LEVEL_SHIFT_UNKNOWN)) { for (i = 0; i < n_entries; i++) { if (ddi_translations[i].default_index) { level = i; break; } } } /* * While we write to the group register to program all lanes at once we * can read only lane registers and we pick lanes 0/1 for that. */ val = I915_READ(BXT_PORT_PCS_DW10_LN01(port)); val &= ~(TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT); I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val); val = I915_READ(BXT_PORT_TX_DW2_LN0(port)); val &= ~(MARGIN_000 | UNIQ_TRANS_SCALE); val |= ddi_translations[level].margin << MARGIN_000_SHIFT | ddi_translations[level].scale << UNIQ_TRANS_SCALE_SHIFT; I915_WRITE(BXT_PORT_TX_DW2_GRP(port), val); val = I915_READ(BXT_PORT_TX_DW3_LN0(port)); val &= ~SCALE_DCOMP_METHOD; if (ddi_translations[level].enable) val |= SCALE_DCOMP_METHOD; if ((val & UNIQUE_TRANGE_EN_METHOD) && !(val & SCALE_DCOMP_METHOD)) DRM_ERROR("Disabled scaling while ouniqetrangenmethod was set"); I915_WRITE(BXT_PORT_TX_DW3_GRP(port), val); val = I915_READ(BXT_PORT_TX_DW4_LN0(port)); val &= ~DE_EMPHASIS; val |= ddi_translations[level].deemphasis << DEEMPH_SHIFT; I915_WRITE(BXT_PORT_TX_DW4_GRP(port), val); val = I915_READ(BXT_PORT_PCS_DW10_LN01(port)); val |= TX2_SWING_CALC_INIT | TX1_SWING_CALC_INIT; I915_WRITE(BXT_PORT_PCS_DW10_GRP(port), val); }
false
false
false
false
false
0
montecarlo_state_init(char *arg, struct board *b) { struct montecarlo *mc = calloc2(1, sizeof(struct montecarlo)); mc->debug_level = 1; mc->gamelen = MC_GAMELEN; if (arg) { char *optspec, *next = arg; while (*next) { optspec = next; next += strcspn(next, ","); if (*next) { *next++ = 0; } else { *next = 0; } char *optname = optspec; char *optval = strchr(optspec, '='); if (optval) *optval++ = 0; if (!strcasecmp(optname, "debug")) { if (optval) mc->debug_level = atoi(optval); else mc->debug_level++; } else if (!strcasecmp(optname, "gamelen") && optval) { mc->gamelen = atoi(optval); } else if (!strcasecmp(optname, "playout") && optval) { char *playoutarg = strchr(optval, ':'); if (playoutarg) *playoutarg++ = 0; if (!strcasecmp(optval, "moggy")) { mc->playout = playout_moggy_init(playoutarg, b, joseki_load(b->size)); } else if (!strcasecmp(optval, "light")) { mc->playout = playout_light_init(playoutarg, b); } else { fprintf(stderr, "MonteCarlo: Invalid playout policy %s\n", optval); } } else { fprintf(stderr, "MonteCarlo: Invalid engine argument %s or missing value\n", optname); } } } if (!mc->playout) mc->playout = playout_light_init(NULL, b); mc->playout->debug_level = mc->debug_level; mc->resign_ratio = 0.1; /* Resign when most games are lost. */ mc->loss_threshold = 5000; /* Stop reading if no loss encountered in first 5000 games. */ return mc; }
false
false
false
false
false
0
dht_bits_for (uint64_t num) { uint64_t bits = 0, ctrl = 1; while (ctrl < num) { ctrl *= 2; bits ++; } return bits; }
false
false
false
false
false
0
DropExtraSpecial (edict_t * ent) { gitem_t *item; if (ent->client->pers.weapon->typeNum == MP5_NUM || ent->client->pers.weapon->typeNum == M4_NUM || ent->client->pers.weapon->typeNum == M3_NUM || ent->client->pers.weapon->typeNum == HC_NUM || ent->client->pers.weapon->typeNum == SNIPER_NUM) { item = ent->client->pers.weapon; // if they have more than 1 then they are willing to drop one if (ent->client->pers.inventory[ITEM_INDEX (item)] > 1) { Drop_Weapon (ent, ent->client->pers.weapon); return; } } // otherwise drop some weapon they aren't using if (INV_AMMO(ent, SNIPER_NUM) > 0 && SNIPER_NUM != ent->client->pers.weapon->typeNum) Drop_Weapon (ent, GET_ITEM(SNIPER_NUM)); else if (INV_AMMO(ent, HC_NUM) > 0 && HC_NUM != ent->client->pers.weapon->typeNum) Drop_Weapon (ent, GET_ITEM(HC_NUM)); else if (INV_AMMO(ent, M3_NUM) > 0 && M3_NUM != ent->client->pers.weapon->typeNum) Drop_Weapon (ent, GET_ITEM(M3_NUM)); else if (INV_AMMO(ent, MP5_NUM) > 0 && MP5_NUM != ent->client->pers.weapon->typeNum) Drop_Weapon (ent, GET_ITEM(MP5_NUM)); else if (INV_AMMO(ent, M4_NUM) > 0 && M4_NUM != ent->client->pers.weapon->typeNum) Drop_Weapon (ent, GET_ITEM(M4_NUM)); else gi.dprintf ("Couldn't find the appropriate weapon to drop.\n"); }
false
false
false
false
false
0
signal_cleanup(void) { t_signal **svec, *sig, *sig2; int i; while (sig = signal_usedlist) { signal_usedlist = sig->s_nextused; if (!sig->s_isborrowed) t_freebytes(sig->s_vec, sig->s_vecsize * sizeof (*sig->s_vec)); t_freebytes(sig, sizeof *sig); } for (i = 0; i <= MAXLOGSIG; i++) signal_freelist[i] = 0; signal_freeborrowed = 0; }
false
false
false
false
false
0
__repmgr_check_listener(env) ENV *env; { DB_REP *db_rep; REP *rep; SITEINFO *sites; db_timespec t; int ret; db_rep = env->rep_handle; rep = db_rep->region; ret = 0; /* * Only subordinate rep-aware process can take over listener role, so * no need to check listener in listener process or rep unaware process. */ if (!IS_LISTENER_CAND(db_rep)) return (0); /* * If the listener quits due to site removal, no subordinate process * should take over as listener as the current site is not expected * to be active in the group. Check the status from the site array * in the shared region instead of that in the GMDB. We do this * because the GMDB doesn't apply the change yet when replication * is stopped on the removed site. */ sites = R_ADDR(env->reginfo, rep->siteinfo_off); if (sites[rep->self_eid].status == SITE_DELETING) return (0); /* * Check the listener after timeout. If there is no listener, we * take over. During takeover, we will refresh all connections. * A subordinate process does not have an up-to-date site list, so sync * up addresses from the in-memory site array before takeover. */ __os_gettime(env, &t, 1); if (timespeccmp(&t, &db_rep->l_listener_chk, >=)) { /* Compute the next timeout. */ TIMESPEC_ADD_DB_TIMEOUT(&t, db_rep->l_listener_wait); db_rep->l_listener_chk = t; /* Check if site address information needs to be refreshed. */ if ((rep->siteinfo_seq > db_rep->siteinfo_seq) && (ret = __repmgr_sync_siteaddr(env)) != 0) return (ret); if (rep->listener == 0) ret = __repmgr_start_takeover(env); } return (ret); }
false
false
false
false
false
0
make_references(hid_t loc_id) { herr_t ret = SUCCEED; herr_t status; /* add target objects */ status = gen_refered_objs(loc_id); if (status == FAIL) { fprintf(stderr, "Failed to generate referenced object.\n"); ret = FAIL; } /* add object reference */ status = gen_obj_ref(loc_id); if (status == FAIL) { fprintf(stderr, "Failed to generate object reference.\n"); ret = FAIL; } /* add region reference */ status = gen_region_ref(loc_id); if (status == FAIL) { fprintf(stderr, "Failed to generate region reference.\n"); ret = FAIL; } return ret; }
false
false
false
false
false
0
ap_mpm_rewrite_args(process_rec *process) { apr_array_header_t *mpm_new_argv; apr_status_t rv; apr_getopt_t *opt; char optbuf[3]; const char *optarg; mpm_new_argv = apr_array_make(process->pool, process->argc, sizeof(const char **)); *(const char **)apr_array_push(mpm_new_argv) = process->argv[0]; apr_getopt_init(&opt, process->pool, process->argc, process->argv); opt->errfn = NULL; optbuf[0] = '-'; /* option char returned by apr_getopt() will be stored in optbuf[1] */ optbuf[2] = '\0'; while ((rv = apr_getopt(opt, "k:" AP_SERVER_BASEARGS, optbuf + 1, &optarg)) == APR_SUCCESS) { switch(optbuf[1]) { case 'k': if (!dash_k_arg) { if (!strcmp(optarg, "start") || !strcmp(optarg, "stop") || !strcmp(optarg, "restart") || !strcmp(optarg, "graceful") || !strcmp(optarg, "graceful-stop")) { dash_k_arg = optarg; break; } } default: *(const char **)apr_array_push(mpm_new_argv) = apr_pstrdup(process->pool, optbuf); if (optarg) { *(const char **)apr_array_push(mpm_new_argv) = optarg; } } } /* back up to capture the bad argument */ if (rv == APR_BADCH || rv == APR_BADARG) { opt->ind--; } while (opt->ind < opt->argc) { *(const char **)apr_array_push(mpm_new_argv) = apr_pstrdup(process->pool, opt->argv[opt->ind++]); } process->argc = mpm_new_argv->nelts; process->argv = (const char * const *)mpm_new_argv->elts; if (NULL == dash_k_arg) { dash_k_arg = dash_k_arg_noarg; } APR_REGISTER_OPTIONAL_FN(ap_signal_server); }
true
true
true
false
false
1
Separator_Draw( menuseparator_s *s ) { if ( s->generic.name ) Menu_DrawStringR2LDark( s->generic.x + s->generic.parent->x, s->generic.y + s->generic.parent->y, s->generic.name ); }
false
false
false
false
false
0
read_cache_pages(struct address_space *mapping, struct list_head *pages, int (*filler)(void *, struct page *), void *data) { struct page *page; int ret = 0; while (!list_empty(pages)) { page = list_to_page(pages); list_del(&page->lru); if (add_to_page_cache_lru(page, mapping, page->index, mapping_gfp_constraint(mapping, GFP_KERNEL))) { read_cache_pages_invalidate_page(mapping, page); continue; } page_cache_release(page); ret = filler(data, page); if (unlikely(ret)) { read_cache_pages_invalidate_pages(mapping, pages); break; } task_io_account_read(PAGE_CACHE_SIZE); } return ret; }
false
false
false
false
false
0
pinconf_generic_dump_one(struct pinctrl_dev *pctldev, struct seq_file *s, const char *gname, unsigned pin, const struct pin_config_item *items, int nitems) { int i; for (i = 0; i < nitems; i++) { unsigned long config; int ret; /* We want to check out this parameter */ config = pinconf_to_config_packed(items[i].param, 0); if (gname) ret = pin_config_group_get(dev_name(pctldev->dev), gname, &config); else ret = pin_config_get_for_pin(pctldev, pin, &config); /* These are legal errors */ if (ret == -EINVAL || ret == -ENOTSUPP) continue; if (ret) { seq_printf(s, "ERROR READING CONFIG SETTING %d ", i); continue; } /* Space between multiple configs */ seq_puts(s, " "); seq_puts(s, items[i].display); /* Print unit if available */ if (items[i].has_arg) { seq_printf(s, " (%u", pinconf_to_config_argument(config)); if (items[i].format) seq_printf(s, " %s)", items[i].format); else seq_puts(s, ")"); } } }
false
false
false
false
false
0
mpz_tdiv_qr(mpz_ptr q, mpz_ptr r, mpz_ptr z, mpz_ptr d) { int cmp; int err; if (d->l == 0) /* division by zero */ return SBN_INVAL; if (z == d) { err = mpz_set_ui(q, 1); /* a/a = 1 */ if (err != SBN_OK) return err; mpz_setzero(r); /* a%a = 0 */ return SBN_OK; } cmp = mpz_cmpabs(z, d); if (cmp < 0) { /* z < d */ err = mpz_set(r, z); /* a%b = a with a<b */ if (err != SBN_OK) return err; mpz_setzero(q); /* a/b = 0 with a<b */ return SBN_OK; } else if (cmp == 0) { /* z = d */ err = mpz_set_ui(q, 1); /* a/a = 1 */ if (err != SBN_OK) return err; mpz_setzero(r); /* a%a = 0 */ return SBN_OK; } /* handle the case where z is the same element as q or r */ if (z == q || z == r) _mpz_clone_stack(z); /* handle the case where d is the same element as q or r */ if (d == q || d == r) _mpz_clone_stack(d); /* the normal case */ q->s = z->s^d->s; /* the sign is the xor of the two sings */ r->s = z->s; /* the sign of the remainder is the sign of the divident */ return mpz_divi_qr_raw(q, r, z, d->d, d->l); }
false
false
false
false
false
0
gettheta(sex_, LINK) thetavalues **sex_; struct LOC_readloci *LINK; { thetarray oldtheta; long i; thetavalues *WITH; long FORLIM; #if !PARALLEL *sex_ = (thetavalues *)Malloc(sizeof(thetavalues)); for (i = 0; i < maxlocus; i++) (*sex_)->theta[i] = 0.0; #endif nuneed = 7; for(i = 2; i < mlocus; i++) nuneed = 5 * nuneed - 3; if (*sex_ == NULL) malloc_err("item of type thetavalues"); /*Next line added by A. A. Schaffer*/ (*sex_)->segprob = (double*) malloc(nuneed * sizeof(double)); if ((*sex_)->segprob == NULL) malloc_err("a segprob array in procedure gettheta"); WITH = *sex_; if (*sex_ == maletheta || readfemale) { FORLIM = mlocus - 2; for (i = 0; i <= FORLIM; i++) fscanf(datafile, "%lf", &(*sex_)->theta[i]); if (interfer && !mapping) fscanf(datafile, "%lf", &(*sex_)->theta[mlocus - 1]); fscanf(datafile, "%*[^\n]"); getc(datafile); } else { fscanf(datafile, "%lf%*[^\n]", &distratio); getc(datafile); } /* FOR j:=1 TO maxneed DO segprob[j]:=0.0;*/ if (!interfer || mapping) return; memcpy(oldtheta, WITH->theta, sizeof(thetarray)); WITH->theta[0] = (oldtheta[0] + oldtheta[mlocus - 1] - oldtheta[mlocus - 2]) / 2.0; WITH->theta[mlocus - 2] = (oldtheta[mlocus - 2] + oldtheta[mlocus - 1] - oldtheta[0]) / 2.0; WITH->theta[mlocus - 1] = (oldtheta[0] + oldtheta[mlocus - 2] - oldtheta[mlocus - 1]) / 2.0; for (i = 0; i < mlocus; i++) { /*=ln(1/0.0001-1.0)*/ if (WITH->theta[i] > 0.0) { if (WITH->theta[i] < 0.999) WITH->theta[i] = log(1.0 / WITH->theta[i] - 1.0); else WITH->theta[i] = -6.9; /*=ln(1/0.999-1.0)*/ } else WITH->theta[i] = 9.21; } }
false
true
false
false
false
1
smime_get_cert_info(const char* x509_cert_pem, char** modulus, /* public key modulus */ char** fingerprint) /* finger print that identifies */ { long serial = -1; X509* x509 = NULL; if (modulus) *modulus = NULL; if (fingerprint) *fingerprint = NULL; if (!(x509 = extract_certificate(x509_cert_pem))) goto err; serial = get_cert_info(x509, modulus, fingerprint); err: if (x509) X509_free(x509); return serial; }
false
false
false
false
false
0
Done(int restart, char *command) { cleanupDone=1; #ifdef M4 if (m4_enable) { extern char *fvwm_file; /* With m4 processing, a temporary file was created to hold the processed file. Delete the file now because we don't need it any more. It will be created again during restart. */ unlink(fvwm_file); } #endif #ifndef NON_VIRTUAL MoveViewport(0,0,False); #endif /* Close all my pipes */ ClosePipes(); Reborder (); if(restart) { SaveDesktopState(); /* I wonder why ... */ /* Really make sure that the connection is closed and cleared! */ XSelectInput(dpy, Scr.Root, 0 ); XSync(dpy, 0); XCloseDisplay(dpy); { char *my_argv[10]; int i,done,j; i=0; j=0; done = 0; while((g_argv[j] != NULL)&&(i<8)) { if(strcmp(g_argv[j],"-s")!=0) { my_argv[i] = g_argv[j]; i++; j++; } else j++; } if(strstr(command,"fvwm")!= NULL) my_argv[i++] = "-s"; while(i<10) my_argv[i++] = NULL; /* really need to destroy all windows, explicitly, * not sleep, but this is adequate for now */ sleep(1); ReapChildren(); execvp(command,my_argv); } fprintf(stderr, "FVWM: Call of '%s' failed!!!!\n",command); execvp(g_argv[0], g_argv); /* that _should_ work */ fprintf(stderr, "FVWM: Call of '%s' failed!!!!\n", g_argv[0]); } else { XCloseDisplay(dpy); exit(0); } }
true
true
true
false
true
1
camel_pointer_tracker_untrack (gpointer ptr) { g_return_if_fail (ptr != NULL); G_LOCK (ptr_tracker); if (!ptr_tracker) g_printerr ("Pointer tracker not initialized, thus cannot remove %p\n", ptr); else if (!g_hash_table_lookup (ptr_tracker, ptr)) g_printerr ("Pointer %p is not tracked\n", ptr); else g_hash_table_remove (ptr_tracker, ptr); G_UNLOCK (ptr_tracker); }
false
false
false
false
false
0
__GEOIP_PREPARE_TEREDO(geoipv6_t * v6) { int i; if ((v6->s6_addr[0]) != 0x20) { return; } if ((v6->s6_addr[1]) != 0x01) { return; } if ((v6->s6_addr[2]) != 0x00) { return; } if ((v6->s6_addr[3]) != 0x00) { return; } for (i = 0; i < 12; i++) { v6->s6_addr[i] = 0; } for (; i < 16; i++) { v6->s6_addr[i] ^= 0xff; } }
true
true
false
false
false
1
t11_reset(void *param) { static const UINT16 initial_pc[] = { 0xc000, 0x8000, 0x4000, 0x2000, 0x1000, 0x0000, 0xf600, 0xf400 }; struct t11_setup *setup = param; int i; /* reset the state */ memset(&t11, 0, sizeof(t11)); /* initial SP is 376 octal, or 0xfe */ SP = 0x00fe; /* initial PC comes from the setup word */ PC = initial_pc[setup->mode >> 13]; /* PSW starts off at highest priority */ PSW = 0xe0; /* initialize the banking */ for (i = 0; i < 8; i++) t11.bank[i] = &OP_RAM[i * 0x2000]; /* initialize the IRQ state */ t11.irq_state = 0; }
false
false
false
false
false
0
ajMartGetAttributesRetry(AjPSeqin seqin, const AjPStr dataset) { AjPMartquery mq = NULL; AjPStr orighost = NULL; AjPStr origpath = NULL; AjPStr schema = NULL; ajuint origport = 0; AjBool ret = ajFalse; mq = ajMartGetMartqueryPtr(seqin); if(!mq) return ajFalse; if(!mq->Marthost || !mq->Martpath) { ajWarn("ajMartGetAttributesRetry: No previous Mart queried.\n" "Invalid Mart location Host=%S Path=%S", mq->Marthost,mq->Martpath); return ajFalse; } ajMartAttributeDel(&mq->Atts); mq->Atts = ajMartAttributeNew(); orighost = ajStrNew(); origpath = ajStrNew(); ajStrAssignS(&orighost, mq->Marthost); ajStrAssignS(&origpath, mq->Martpath); origport = mq->Martport; ajStrAssignC(&mq->Marthost, DEFAULT_BIOMART_MART_HOST); ajStrAssignC(&mq->Martpath, DEFAULT_BIOMART_MART_PATH); mq->Martport = DEFAULT_BIOMART_MART_PORT; schema = ajStrNewC("default"); ret = ajMartGetAttributesSchema(seqin,dataset,schema); ajStrAssignS(&mq->Marthost, orighost); ajStrAssignS(&mq->Martpath, origpath); mq->Martport = origport; ajStrDel(&orighost); ajStrDel(&origpath); ajStrDel(&schema); return ret; }
false
false
false
false
false
0
gl_puts (buf) char *buf; { int len; if (buf) { len = strlen (buf); write (1, buf, len); } }
false
false
false
false
false
0
kook_NEW_asm(CTX ctx, kStmtExpr *stmt, int espidx) { kMethod *mtd = tkNN(stmt, 0)->mtd; kclass_t cid = (tkNN(stmt, 1))->cid; kClass *c = new_Type(ctx, cid); CALL(ctx, COMPILER_API.NEW, 4, stmt, NN(espidx), c, mtd); }
false
false
false
false
false
0
rrule_parse_weekly_days (char *s, struct icalrecurrencetype *recur, char **error_message) { int i; /* If we've already found an error, just return. */ if (*error_message) return NULL; for (i = 0; i < ICAL_BY_DAY_SIZE; i++) { char *e = s; int found_day, day; found_day = -1; for (day = 0; day < 7; day++) { if (!strncmp (weekdays[day], s, 2)) { /* Check the next char is whitespace or the end of string. */ e = s + 2; if (*e == ' ' || *e == '\t' || *e == '\0') { found_day = day; break; } } } if (found_day == -1) break; recur->by_day[i] = weekday_codes[day]; s = e; /* Skip any whitespace. */ while (*s == ' ' || *s == '\t') s++; } /* Terminate the array, if it isn't full. */ if (i < ICAL_BY_DAY_SIZE) recur->by_day[i] = ICAL_RECURRENCE_ARRAY_MAX; return s; }
false
false
false
false
false
0
SerializeColumns(DataStructures::Table *in, RakNet::BitStream *out, DataStructures::List<int> &skipColumnIndices) { const DataStructures::List<DataStructures::Table::ColumnDescriptor> &columns=in->GetColumns(); out->Write((unsigned)columns.Size()-skipColumnIndices.Size()); unsigned i; for (i=0; i<columns.Size(); i++) { if (skipColumnIndices.GetIndexOf(i)==(unsigned)-1) { StringCompressor::Instance()->EncodeString(columns[i].columnName, _TABLE_MAX_COLUMN_NAME_LENGTH, out); out->Write((unsigned char)columns[i].columnType); } } }
false
false
false
false
false
0
create_access (tree expr, gimple stmt, bool write) { struct access *access; HOST_WIDE_INT offset, size, max_size; tree base = expr; bool ptr, unscalarizable_region = false; base = get_ref_base_and_extent (expr, &offset, &size, &max_size); if (sra_mode == SRA_MODE_EARLY_IPA && TREE_CODE (base) == MEM_REF) { base = get_ssa_base_param (TREE_OPERAND (base, 0)); if (!base) return NULL; ptr = true; } else ptr = false; if (!DECL_P (base) || !bitmap_bit_p (candidate_bitmap, DECL_UID (base))) return NULL; if (sra_mode == SRA_MODE_EARLY_IPA) { if (size < 0 || size != max_size) { disqualify_candidate (base, "Encountered a variable sized access."); return NULL; } if (TREE_CODE (expr) == COMPONENT_REF && DECL_BIT_FIELD (TREE_OPERAND (expr, 1))) { disqualify_candidate (base, "Encountered a bit-field access."); return NULL; } gcc_checking_assert ((offset % BITS_PER_UNIT) == 0); if (ptr) mark_parm_dereference (base, offset + size, stmt); } else { if (size != max_size) { size = max_size; unscalarizable_region = true; } if (size < 0) { disqualify_candidate (base, "Encountered an unconstrained access."); return NULL; } } access = create_access_1 (base, offset, size); access->expr = expr; access->type = TREE_TYPE (expr); access->write = write; access->grp_unscalarizable_region = unscalarizable_region; access->stmt = stmt; if (TREE_CODE (expr) == COMPONENT_REF && DECL_NONADDRESSABLE_P (TREE_OPERAND (expr, 1))) access->non_addressable = 1; return access; }
false
false
false
false
false
0
mailimap_body_ext_1part_1_parse(mailstream * fd, MMAPString * buffer, size_t * indx, struct mailimap_body_fld_dsp ** fld_dsp, struct mailimap_body_fld_lang ** fld_lang, clist ** body_ext_list, size_t progr_rate, progress_function * progr_fun) { size_t cur_token; int r; cur_token = * indx; * fld_dsp = NULL; * fld_lang = NULL; * body_ext_list = NULL; r = mailimap_space_parse(fd, buffer, &cur_token); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_body_fld_dsp_parse(fd, buffer, &cur_token, fld_dsp, progr_rate, progr_fun); if (r != MAILIMAP_NO_ERROR) return r; r = mailimap_body_ext_1part_2_parse(fd, buffer, &cur_token, fld_lang, body_ext_list, progr_rate, progr_fun); if ((r != MAILIMAP_NO_ERROR) && (r != MAILIMAP_ERROR_PARSE)) return r; * indx = cur_token; return MAILIMAP_NO_ERROR; }
false
false
false
false
false
0
i2c_read_le16(struct i2c_client *client) { u8 buf[2]; int status; status = i2c_master_recv(client, buf, 2); if (status < 0) return status; return (buf[1] << 8) | buf[0]; }
false
false
false
false
false
0
draw_keys (int draw) { char s[20]; static char *key[4] = {"UP", "DOWN", "LEFT", "RIGHT"}; static char *rkey[3] = {"ACCELERATION", "ROTATE LEFT", "ROTATE RIGHT"}; if (!draw) return; nmenu = 2; sprintf (s, "PLAYER:%i", player + 1); DrawWhiteMaskedText ((int) (MAPWIDTH / 2 - 4 * strlen (s)), (int) YPOSITION (0), s); if (rotation[player]) sprintf (s, "KEY:%s", rkey[keynum]); else sprintf (s, "KEY:%s", key[keynum]); DrawWhiteMaskedText ((int) (MAPWIDTH / 2 - 4 * strlen (s)), (int) YPOSITION (1), s); }
true
true
false
false
false
1
hns_dsaf_fix_mac_mode(struct hns_mac_cb *mac_cb) { enum dsaf_port_rate_mode mode; struct dsaf_device *dsaf_dev = mac_cb->dsaf_dev; int mac_id = mac_cb->mac_id; if (mac_cb->mac_type != HNAE_PORT_SERVICE) return; if (mac_cb->phy_if == PHY_INTERFACE_MODE_XGMII) mode = DSAF_PORT_RATE_10000; else mode = DSAF_PORT_RATE_1000; hns_dsaf_port_work_rate_cfg(dsaf_dev, mac_id, mode); }
false
false
false
false
false
0