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
skipValue( FLMUINT uiTag) { RCODE rc = FERR_OK; switch( ((uiTag & WIRE_VALUE_TYPE_MASK) >> WIRE_VALUE_TYPE_START_BIT)) { case WIRE_VALUE_TYPE_GEN_0: { break; } case WIRE_VALUE_TYPE_GEN_1: { if( RC_BAD( rc = m_pDIStream->skip( 1))) { goto Exit; } break; } case WIRE_VALUE_TYPE_GEN_2: { if( RC_BAD( rc = m_pDIStream->skip( 2))) { goto Exit; } break; } case WIRE_VALUE_TYPE_GEN_4: { if( RC_BAD( rc = m_pDIStream->skip( 4))) { goto Exit; } break; } case WIRE_VALUE_TYPE_GEN_8: { if( RC_BAD( rc = m_pDIStream->skip( 8))) { goto Exit; } break; } case WIRE_VALUE_TYPE_BINARY: { if( RC_BAD( rc = m_pDIStream->readBinary( NULL, NULL, NULL))) { goto Exit; } break; } case WIRE_VALUE_TYPE_LARGE_BINARY: { if( RC_BAD( rc = m_pDIStream->readLargeBinary( NULL, NULL, NULL))) { goto Exit; } break; } case WIRE_VALUE_TYPE_HTD: { if( RC_BAD( rc = m_pDIStream->readHTD( NULL, 0, 0, NULL, NULL))) { goto Exit; } break; } case WIRE_VALUE_TYPE_RECORD: { if( RC_BAD( rc = receiveRecord( NULL))) { goto Exit; } } case WIRE_VALUE_TYPE_UTF: { if( RC_BAD( rc = m_pDIStream->readUTF( NULL, NULL))) { goto Exit; } break; } default: { rc = RC_SET( FERR_FAILURE); goto Exit; } } Exit: return( rc); }
false
false
false
false
false
0
cirrusfb_create_object(struct cirrus_fbdev *afbdev, struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **gobj_p) { struct drm_device *dev = afbdev->helper.dev; struct cirrus_device *cdev = dev->dev_private; u32 bpp, depth; u32 size; struct drm_gem_object *gobj; int ret = 0; drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp); if (!cirrus_check_framebuffer(cdev, mode_cmd->width, mode_cmd->height, bpp, mode_cmd->pitches[0])) return -EINVAL; size = mode_cmd->pitches[0] * mode_cmd->height; ret = cirrus_gem_create(dev, size, true, &gobj); if (ret) return ret; *gobj_p = gobj; return ret; }
false
false
false
false
false
0
ql_stop_loopback(struct ql_adapter *qdev) { qdev->link_config &= ~CFG_LOOPBACK_PCS; ql_mb_set_port_cfg(qdev); if (test_bit(QL_LB_LINK_UP, &qdev->flags)) { netif_carrier_on(qdev->ndev); clear_bit(QL_LB_LINK_UP, &qdev->flags); } }
false
false
false
false
false
0
smp_fetch_rdp_cookie(struct proxy *px, struct session *s, void *l7, unsigned int opt, const struct arg *args, struct sample *smp, const char *kw) { return fetch_rdp_cookie_name(s, smp, args ? args->data.str.str : NULL, args ? args->data.str.len : 0); }
false
false
false
false
false
0
on_key_press_event(GtkWidget* widget, GdkEventKey* evt) { GtkTreeView* tree_view = GTK_TREE_VIEW(widget); GtkTreeSelection* tree_sel; GtkTreeModel* model; GtkTreeIter it; GtkTreePath* tp; // int modifier = (evt->state & gtk_accelerator_get_default_mod_mask()); switch(evt->keyval) { case GDK_KEY_Left: tree_sel = gtk_tree_view_get_selection(tree_view); if(gtk_tree_selection_get_selected(tree_sel, &model, &it)) { tp = gtk_tree_model_get_path(model, &it); if(gtk_tree_view_row_expanded(tree_view, tp)) gtk_tree_view_collapse_row(tree_view, tp); else { gtk_tree_path_up(tp); gtk_tree_view_set_cursor(tree_view, tp, NULL, FALSE); gtk_tree_selection_select_path(tree_sel, tp); } gtk_tree_path_free(tp); } break; case GDK_KEY_Right: tree_sel = gtk_tree_view_get_selection(tree_view); if(gtk_tree_selection_get_selected(tree_sel, &model, &it)) { tp = gtk_tree_model_get_path(model, &it); gtk_tree_view_expand_row(tree_view, tp, FALSE); gtk_tree_path_free(tp); } break; #if 0 /* if we support Menu key then we should also position the menu right at item */ case GDK_KEY_Menu: if (modifier) break; tree_sel = gtk_tree_view_get_selection(tree_view); if(gtk_tree_selection_get_selected(tree_sel, &model, &it)) fm_dir_tree_view_item_popup(widget, model, &it, evt->time); break; case GDK_KEY_F10: if (modifier != GDK_SHIFT_MASK) break; tree_sel = gtk_tree_view_get_selection(tree_view); if(gtk_tree_selection_get_selected(tree_sel, &model, &it)) fm_dir_tree_view_item_popup(widget, model, &it, evt->time); break; #endif } return GTK_WIDGET_CLASS(fm_dir_tree_view_parent_class)->key_press_event(widget, evt); }
false
false
false
false
false
0
Pk11Install_ListIter_reset(Pk11Install_ListIter* _this) { if(_this->list) { _this->current = _this->list->head; } }
false
false
false
false
false
0
e_mixer_theme_path(void) { #define TF "/e-module-mixer.edj" size_t dirlen; dirlen = strlen(mixer_mod->dir); if (dirlen >= sizeof(tmpbuf) - sizeof(TF)) return NULL; memcpy(tmpbuf, mixer_mod->dir, dirlen); memcpy(tmpbuf + dirlen, TF, sizeof(TF)); return tmpbuf; #undef TF }
false
false
false
false
false
0
vg_integrate( VolumeGeometry *obj, FMField *out, FMField *in ) { int32 iel; for (iel = 0; iel < obj->bfGM->nCell; iel++) { FMF_SetCell( obj->det, iel ); FMF_SetCell( in, iel ); FMF_SetCell( out, iel ); fmf_sumLevelsMulF( out, in, obj->det->val ); } return( RET_OK ); }
false
false
false
false
false
0
__pyx_pf_9xmmsvalue_20CollectionAttributes_16__contains__(PyObject *__pyx_v_self, PyObject *__pyx_v_name) { char *__pyx_v_value; int __pyx_r; __Pyx_RefNannyDeclarations char *__pyx_t_1; int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; __Pyx_RefNannySetupContext("__contains__"); /* "xmmsvalue.pyx":539 * * def __contains__(self, name): * cdef char *value = NULL # <<<<<<<<<<<<<< * return xmmsv_coll_attribute_get(self.coll, name, &value) * */ __pyx_v_value = NULL; /* "xmmsvalue.pyx":540 * def __contains__(self, name): * cdef char *value = NULL * return xmmsv_coll_attribute_get(self.coll, name, &value) # <<<<<<<<<<<<<< * * cdef class CollectionOperands(CollectionRef): */ __pyx_t_1 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_r = xmmsv_coll_attribute_get(((struct __pyx_obj_9xmmsvalue_CollectionAttributes *)__pyx_v_self)->__pyx_base.coll, __pyx_t_1, (&__pyx_v_value)); goto __pyx_L0; __pyx_r = 0; goto __pyx_L0; __pyx_L1_error:; __Pyx_AddTraceback("xmmsvalue.CollectionAttributes.__contains__", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = -1; __pyx_L0:; __Pyx_RefNannyFinishContext(); return __pyx_r; }
false
false
false
false
false
0
appendLocal(const spi::InternalLoggingEvent& event) { int const level = getSysLogLevel(event.getLogLevel()); internal::appender_sratch_pad & appender_sp = internal::get_appender_sp (); detail::clear_tostringstream (appender_sp.oss); layout->formatAndAppend(appender_sp.oss, event); appender_sp.str = OFString(appender_sp.oss.str().c_str(), appender_sp.oss.str().length()); ::syslog(facility | level, "%s", DCMTK_LOG4CPLUS_TSTRING_TO_STRING(appender_sp.str).c_str()); }
false
false
false
false
false
0
xmms_ringbuf_bytes_used (const xmms_ringbuf_t *ringbuf) { g_return_val_if_fail (ringbuf, 0); if (ringbuf->wr_index >= ringbuf->rd_index) { return ringbuf->wr_index - ringbuf->rd_index; } return ringbuf->buffer_size - (ringbuf->rd_index - ringbuf->wr_index); }
false
false
false
false
false
0
pdb_read_rec_by_id(pdbfile *fin, const gbuint32 rec_id, gbuint8 *flags, gbuint8 *category, void **data) { pdbrec_t *rec; for (rec = fin->rec_list; rec; rec = rec->next) { if (rec->id == rec_id) { if (data) { *data = rec->data; } if (flags) { *flags = rec->flags; } if (category) { *category = rec->category; } return rec->size; } } return -1; }
false
false
false
false
false
0
getSelectedFiles(FXStringList & files){ if (dirselector) { getApp()->reg().writeStringEntry("directories","last-import-dirs",dirselector->getDirectory().text()); files.append(dirselector->getDirectory()); } else if (fileselector){ getApp()->reg().writeStringEntry("directories","last-import-files",fileselector->getDirectory().text()); fileselector->getSelectedFiles(files); } }
false
false
false
false
false
0
accessLogFreeLogFormat(logformat_token ** tokens) { while (*tokens) { logformat_token *token = *tokens; *tokens = token->next; safe_free(token->data.string); xfree(token); } }
false
false
false
false
false
0
setRenderSize(const QSize &renderSize) { KGameRenderedItem::setRenderSize(renderSize); QList<QGraphicsItem*> children = childItems(); foreach( QGraphicsItem* item, children) { ((KGameRenderedItem*)item)->setRenderSize(renderSize); } }
false
false
false
false
false
0
doGet(const void* target) const { const GpuProgram* t = static_cast<const GpuProgram*>(target); if (t->getType() == GPT_VERTEX_PROGRAM) { return "vertex_program"; } else if (t->getType() == GPT_GEOMETRY_PROGRAM) { return "geometry_program"; } else if (t->getType() == GPT_DOMAIN_PROGRAM) { return "domain_program"; } else if (t->getType() == GPT_HULL_PROGRAM) { return "hull_program"; } else if (t->getType() == GPT_COMPUTE_PROGRAM) { return "compute_program"; } else { return "fragment_program"; } }
false
false
false
false
false
0
Initialize() { // Prepares state for use. if (store_.length() >= PreparseDataConstants::kHeaderSize) { function_index_ = PreparseDataConstants::kHeaderSize; int symbol_data_offset = PreparseDataConstants::kHeaderSize + store_[PreparseDataConstants::kFunctionsSizeOffset]; if (store_.length() > symbol_data_offset) { symbol_data_ = reinterpret_cast<byte*>(&store_[symbol_data_offset]); } else { // Partial preparse causes no symbol information. symbol_data_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); } symbol_data_end_ = reinterpret_cast<byte*>(&store_[0] + store_.length()); } }
false
false
false
false
false
0
esl_mixdchlet_Fit_Multipass(ESL_RANDOMNESS *r, double **c, int nc, int reps, ESL_MIXDCHLET *best_md, int verbose) { int i, q, k, status; double best_lk = -eslINFINITY; double lk; ESL_MIXDCHLET *md = esl_mixdchlet_Create(best_md->N, best_md->K); int err_cnt = 0; for (i=0; i<reps; i++) { /* for each pass, establish a new random starting point */ for (q = 0; q < md->N; q++) { md->pq[q] = esl_rnd_UniformPositive(r); for (k = 0; k < md->K; k++) md->alpha[q][k] = 10.0 * esl_rnd_UniformPositive(r); } esl_vec_DNorm(md->pq, md->N); /* then use Fit to do local search */ status = esl_mixdchlet_Fit(c, nc, md, 0); if (status != eslOK) { err_cnt++; if (err_cnt==2*reps) { goto ERROR; } else { i--; /* try another starting point */ continue; } } esl_dirichlet_LogProbDataSet_Mixture (nc, c, md, &lk); if (verbose) { fprintf(stderr, "Repetition # %d\n------------\n", i); esl_mixdchlet_Dump(stderr, md); fprintf(stderr, "llk = %.3f (vs best = %.3f)\n", lk, best_lk); } if (lk > best_lk) { if (verbose) fprintf(stderr, "... so copy md -> best_md\n"); best_lk = lk; esl_mixdchlet_Copy(md, best_md); } } if (verbose) { fprintf(stdout, "\n\n----------------\nbest mixture:\n"); esl_mixdchlet_Dump(stdout, best_md); fprintf(stdout, "llk = %.3f", best_lk); } ERROR: esl_mixdchlet_Destroy(md); return status; }
false
false
false
false
true
1
findVariable(const char *line) { /* Parse global and class variable names (C.x) from assignment statements. * Object attributes (obj.x) are ignored. * Assignment to a tuple 'x, y = 2, 3' not supported. * TODO: ignore duplicate tags from reassignment statements. */ const char *cp, *sp, *eq, *start; cp = strstr(line, "="); if (!cp) return NULL; eq = cp + 1; while (*eq) { if (*eq == '=') return NULL; /* ignore '==' operator and 'x=5,y=6)' function lines */ if (*eq == '(' || *eq == '#') break; /* allow 'x = func(b=2,y=2,' lines and comments at the end of line */ eq++; } /* go backwards to the start of the line, checking we have valid chars */ start = cp - 1; while (start >= line && isspace ((int) *start)) --start; while (start >= line && isIdentifierCharacter ((int) *start)) --start; if (!isIdentifierFirstCharacter(*(start + 1))) return NULL; sp = start; while (sp >= line && isspace ((int) *sp)) --sp; if ((sp + 1) != line) /* the line isn't a simple variable assignment */ return NULL; /* the line is valid, parse the variable name */ ++start; return start; }
false
false
false
false
false
0
us_reactor_destroy( us_reactor_t *self ) { while ( self->m_handlers ) { self->remove_item( self, self->m_handlers ); } #if defined( US_REACTOR_USE_POLL ) us_delete( self->m_allocator, self->m_poll_handlers ); self->m_poll_handlers = 0; #endif }
false
false
false
false
false
0
WebPSafeFree(void* const ptr) { if (ptr != NULL) { Increment(&num_free_calls); SubMem(ptr); } free(ptr); }
false
false
false
false
false
0
select_active_source_name (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { GdictPrefDialog *dialog = GDICT_PREF_DIALOG (data); gboolean is_active; gtk_tree_model_get (model, iter, SOURCES_ACTIVE_COLUMN, &is_active, -1); if (is_active) { GtkTreeSelection *selection; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->sources_view)); gtk_tree_selection_select_iter (selection, iter); return TRUE; } return FALSE; }
false
false
false
false
false
0
ReadPGM(FILE *fp) { int char1, char2, width, height, max, c1, c2, c3, r, c; char1 = fgetc(fp); char2 = fgetc(fp); SkipComments(fp); c1 = fscanf(fp, "%d", &width); SkipComments(fp); c2 = fscanf(fp, "%d", &height); SkipComments(fp); c3 = fscanf(fp, "%d", &max); if (char1 != 'P' || char2 != '5' || c1 != 1 || c2 != 1 || c3 != 1 || max > 255) { fprintf(stderr, "ERROR: Input is not a standard raw PGM file.\n" "Use xv or PNM tools to convert file to 8-bit PGM format.\n"); exit(1); } fgetc(fp); /* Discard exactly one byte after header. */ /* Create floating point image with pixels in range [0.0,1.0]. */ Image image(height, width); for (r = 0; r < height; r++) for (c = 0; c < width; c++) image.pixels[r][c] = ((float) fgetc(fp)) / 255.0; return image; }
false
false
false
false
false
0
Write(const char* data, int data_size) { if (is_sealed_) { return 0; } if ((write_pos_ + data_size) <= (max_size_ - seal_size_)) { return WriteInternal(data, data_size); } else { return Seal(); } }
false
false
false
false
false
0
mcode_alloc(jit_State *J, size_t sz) { /* Target an address in the static assembler code (64K aligned). ** Try addresses within a distance of target-range/2+1MB..target+range/2-1MB. ** Use half the jump range so every address in the range can reach any other. */ #if LJ_TARGET_MIPS /* Use the middle of the 256MB-aligned region. */ uintptr_t target = ((uintptr_t)(void *)lj_vm_exit_handler & 0xf0000000u) + 0x08000000u; #else uintptr_t target = (uintptr_t)(void *)lj_vm_exit_handler & ~(uintptr_t)0xffff; #endif const uintptr_t range = (1u << (LJ_TARGET_JUMPRANGE-1)) - (1u << 21); /* First try a contiguous area below the last one. */ uintptr_t hint = J->mcarea ? (uintptr_t)J->mcarea - sz : 0; int i; for (i = 0; i < 32; i++) { /* 32 attempts ought to be enough ... */ if (mcode_validptr(hint)) { void *p = mcode_alloc_at(J, hint, sz, MCPROT_GEN); if (mcode_validptr(p) && ((uintptr_t)p + sz - target < range || target - (uintptr_t)p < range)) return p; if (p) mcode_free(J, p, sz); /* Free badly placed area. */ } /* Next try probing pseudo-random addresses. */ do { hint = (0x78fb ^ LJ_PRNG_BITS(J, 15)) << 16; /* 64K aligned. */ } while (!(hint + sz < range)); hint = target + hint - (range>>1); } lj_trace_err(J, LJ_TRERR_MCODEAL); /* Give up. OS probably ignores hints? */ return NULL; }
false
false
false
false
false
0
event_whois_oper(IRC_SERVER_REC *server, const char *data) { char *params, *nick, *type; g_return_if_fail(data != NULL); params = event_get_params(data, 3, NULL, &nick, &type); /* Bugfix: http://bugs.irssi.org/?do=details&id=99 * Author: Geert Hauwaerts <[email protected]> * Date: Wed Sep 15 20:17:24 CEST 2004 */ if ((!strncmp(type, "is an ", 6)) || (!strncmp(type, "is a ", 5))) { type += 5; if (*type == ' ') type++; } if (*type == '\0') type = "IRC Operator"; printformat(server, nick, MSGLEVEL_CRAP, IRCTXT_WHOIS_OPER, nick, type); g_free(params); }
false
false
false
false
false
0
tool_file_format_addPatterns(ToolFileFormat *fmt, const gchar **patterns) { gint n; g_return_if_fail(IS_TOOL_FILE_FORMAT(fmt)); for (n = 0; patterns[n]; n++) fmt->priv->fileType = g_list_append(fmt->priv->fileType, g_strdup(patterns[n])); _buildLabel(fmt); }
false
false
false
false
false
0
do_or_append_insn(char *op, struct pnode *parms) { gpasmVal r; if (!state.mac_prev || (strcasecmp(op, "endm") == 0) || (state.while_head && (strcasecmp(op, "endw") == 0))) { r = do_insn(op, parms); } else { macro_append(); r = 0; } return r; }
false
false
false
false
false
0
hash_iterator_unlock (struct hash_iterator *hi) { if (hi->bucket) { if (hi->bucket_marked) { hash_remove_marked (hi->hash, hi->bucket); hi->bucket_marked = false; } if (hi->autolock) { mutex_unlock (&hi->bucket->mutex); } hi->bucket = NULL; hi->last = NULL; } }
false
false
false
false
false
0
copy_structures(struct activity *act[], unsigned int id_seq[], struct record_header record_hdr[], int dest, int src) { int i, p; memcpy(&record_hdr[dest], &record_hdr[src], RECORD_HEADER_SIZE); for (i = 0; i < NR_ACT; i++) { if (!id_seq[i]) continue; if (((p = get_activity_position(act, id_seq[i])) < 0) || (act[p]->nr < 1) || (act[p]->nr2 < 1)) { PANIC(1); } memcpy(act[p]->buf[dest], act[p]->buf[src], act[p]->msize * act[p]->nr * act[p]->nr2); } }
false
false
false
false
false
0
calc_image_params (struct hp5590_scanner *scanner, unsigned int *pixel_bits, unsigned int *pixels_per_line, unsigned int *bytes_per_line, unsigned int *lines, unsigned int *image_size) { unsigned int _pixel_bits; SANE_Status ret; unsigned int _pixels_per_line; unsigned int _bytes_per_line; unsigned int _lines; unsigned int _image_size; float var; DBG (DBG_proc, "%s\n", __FUNCTION__); if (!scanner) return SANE_STATUS_INVAL; ret = hp5590_calc_pixel_bits (scanner->dpi, scanner->depth, &_pixel_bits); if (ret != SANE_STATUS_GOOD) return ret; var = (float) (1.0 * (scanner->br_x - scanner->tl_x) * scanner->dpi); _pixels_per_line = var; if (var > _pixels_per_line) _pixels_per_line++; var = (float) (1.0 * (scanner->br_y - scanner->tl_y) * scanner->dpi); _lines = var; if (var > _lines) _lines++; var = (float) (1.0 * _pixels_per_line / 8 * _pixel_bits); _bytes_per_line = var; if (var > _bytes_per_line) _bytes_per_line++; _image_size = _lines * _bytes_per_line; DBG (DBG_verbose, "%s: pixel_bits: %u, pixels_per_line: %u, " "bytes_per_line: %u, lines: %u, image_size: %u\n", __FUNCTION__, _pixel_bits, _pixels_per_line, _bytes_per_line, _lines, _image_size); if (pixel_bits) *pixel_bits = _pixel_bits; if (pixels_per_line) *pixels_per_line = _pixels_per_line; if (bytes_per_line) *bytes_per_line = _bytes_per_line; if (lines) *lines = _lines; if (image_size) *image_size = _image_size; return SANE_STATUS_GOOD; }
false
false
false
false
false
0
DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName, char chType, int nWidth, int nDecimals ) { char *pszFInfo; int i; /* -------------------------------------------------------------------- */ /* Do some checking to ensure we can add records to this file. */ /* -------------------------------------------------------------------- */ if( psDBF->nRecords > 0 ) return( -1 ); if( !psDBF->bNoHeader ) return( -1 ); if( nWidth < 1 ) return -1; if( nWidth > 255 ) nWidth = 255; /* -------------------------------------------------------------------- */ /* SfRealloc all the arrays larger to hold the additional field */ /* information. */ /* -------------------------------------------------------------------- */ psDBF->nFields++; psDBF->panFieldOffset = (int *) SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields ); psDBF->panFieldSize = (int *) SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields ); psDBF->panFieldDecimals = (int *) SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields ); psDBF->pachFieldType = (char *) SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields ); /* -------------------------------------------------------------------- */ /* Assign the new field information fields. */ /* -------------------------------------------------------------------- */ psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength; psDBF->nRecordLength += nWidth; psDBF->panFieldSize[psDBF->nFields-1] = nWidth; psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals; psDBF->pachFieldType[psDBF->nFields-1] = chType; /* -------------------------------------------------------------------- */ /* Extend the required header information. */ /* -------------------------------------------------------------------- */ psDBF->nHeaderLength += 32; psDBF->bUpdated = FALSE; psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,psDBF->nFields*32); pszFInfo = psDBF->pszHeader + 32 * (psDBF->nFields-1); for( i = 0; i < 32; i++ ) pszFInfo[i] = '\0'; if( (int) strlen(pszFieldName) < 10 ) strncpy( pszFInfo, pszFieldName, strlen(pszFieldName)); else strncpy( pszFInfo, pszFieldName, 10); pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1]; if( chType == 'C' ) { pszFInfo[16] = (unsigned char) (nWidth % 256); pszFInfo[17] = (unsigned char) (nWidth / 256); } else { pszFInfo[16] = (unsigned char) nWidth; pszFInfo[17] = (unsigned char) nDecimals; } /* -------------------------------------------------------------------- */ /* Make the current record buffer appropriately larger. */ /* -------------------------------------------------------------------- */ psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord, psDBF->nRecordLength); return( psDBF->nFields-1 ); }
false
true
false
false
false
1
calcWidth(bool) { // Check that above threshold. if (ps == 0.) return; // Widths to fermion pairs. if (id1Abs < 19) { widNow = preFac * pow3(ps) * (1. + 8. * mr1 / 3.) / 320.; if (id1Abs < 9) widNow *= colQ; // Widths to gluon and photon pair. } else if (id1Abs == 21) { widNow = preFac / 20.; } else if (id1Abs == 22) { widNow = preFac / 160.; // Widths to Z0 Z0 and W+ W- pair. } else if (id1Abs == 23 || id1Abs == 24) { // Longitudinal W/Z only. if (eDvlvl) { widNow = preFac * pow(ps,5) / 480.; // Transverse W/Z contributions as well. } else { widNow = preFac * ps * (13. / 12. + 14. * mr1 / 3. + 4. * mr1 * mr1) / 80.; } if (id1Abs == 23) widNow *= 0.5; // Widths to h h pair. } else if (id1Abs == 25) { widNow = preFac * pow(ps,5) / 960.; } // RS graviton coupling if (eDsmbulk) widNow *= 2. * pow2(eDcoupling[min( id1Abs, 26)] * mHat); else widNow *= pow2(kappaMG); }
false
false
false
false
false
0
gt_encseq_has_multiseq_support(const GtEncseq *encseq) { bool ret = encseq->sat == GT_ACCESS_TYPE_EQUALLENGTH || encseq->has_ssptab || encseq->accesstype_via_utables; return ret; }
false
false
false
false
false
0
quote_fmt_reset_vartable(void) { if (var_table) { g_hash_table_destroy(var_table); var_table = NULL; } if (attachments) { GList *cur = attachments; while (cur) { g_free(cur->data); cur = g_list_next(cur); } g_list_free(attachments); attachments = NULL; } }
false
false
false
false
false
0
owner_excluded(struct archive_match *a, struct archive_entry *entry) { int r; if (a->inclusion_uids.count) { if (!match_owner_id(&(a->inclusion_uids), archive_entry_uid(entry))) return (1); } if (a->inclusion_gids.count) { if (!match_owner_id(&(a->inclusion_gids), archive_entry_gid(entry))) return (1); } if (a->inclusion_unames.count) { #if defined(_WIN32) && !defined(__CYGWIN__) r = match_owner_name_wcs(a, &(a->inclusion_unames), archive_entry_uname_w(entry)); #else r = match_owner_name_mbs(a, &(a->inclusion_unames), archive_entry_uname(entry)); #endif if (!r) return (1); else if (r < 0) return (r); } if (a->inclusion_gnames.count) { #if defined(_WIN32) && !defined(__CYGWIN__) r = match_owner_name_wcs(a, &(a->inclusion_gnames), archive_entry_gname_w(entry)); #else r = match_owner_name_mbs(a, &(a->inclusion_gnames), archive_entry_gname(entry)); #endif if (!r) return (1); else if (r < 0) return (r); } return (0); }
false
false
false
false
false
0
newDirect(But *but, bool value) { Setup *setup = but_packet(but); uint directFlags; assert(MAGIC(setup)); if (value) directFlags = BUT_DRAWABLE | BUT_PRESSABLE; else directFlags = BUT_DRAWABLE | BUT_NOPRESS | BUT_NOKEY; clp_setStrNum(setup->cg->clp, "client.direct", (value ? "t" : "f"), setup->srvNum); butText_setColor(setup->srvComp, BUT_FG, !value); but_setFlags(setup->srvCompIn, directFlags); butText_setColor(setup->srvPort, BUT_FG, !value); but_setFlags(setup->srvPortIn, directFlags); butText_setColor(setup->srvCmdLabel, BUT_FG, value); but_setFlags(setup->srvCmd, directFlags ^ (BUT_PRESSABLE|BUT_NOPRESS|BUT_NOKEY)); return(0); }
false
false
false
false
false
0
gdImageGrayScale(gdImagePtr src) { int x, y; int r,g,b,a; int new_pxl, pxl; FuncPtr f; if (src==NULL) { return 0; } f = GET_PIXEL_FUNCTION(src); for (y=0; y<src->sy; ++y) { for (x=0; x<src->sx; ++x) { pxl = f (src, x, y); r = gdImageRed(src, pxl); g = gdImageGreen(src, pxl); b = gdImageBlue(src, pxl); a = gdImageAlpha(src, pxl); r = g = b = (int) (.299 * r + .587 * g + .114 * b); new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a); if (new_pxl == -1) { new_pxl = gdImageColorClosestAlpha(src, r, g, b, a); } gdImageSetPixel (src, x, y, new_pxl); } } return 1; }
false
false
false
false
false
0
cli_scanmschm(cli_ctx *ctx) { int ret = CL_CLEAN, rc; chm_metadata_t metadata; char *dir; unsigned int viruses_found = 0; cli_dbgmsg("in cli_scanmschm()\n"); /* generate the temporary directory */ if(!(dir = cli_gentemp(ctx->engine->tmpdir))) return CL_EMEM; if(mkdir(dir, 0700)) { cli_dbgmsg("CHM: Can't create temporary directory %s\n", dir); free(dir); return CL_ETMPDIR; } ret = cli_chm_open(dir, &metadata, ctx); if (ret != CL_SUCCESS) { if(!ctx->engine->keeptmp) cli_rmdirs(dir); free(dir); cli_dbgmsg("CHM: Error: %s\n", cl_strerror(ret)); return ret; } do { ret = cli_chm_prepare_file(&metadata); if (ret != CL_SUCCESS) { break; } ret = cli_chm_extract_file(dir, &metadata, ctx); if (ret == CL_SUCCESS) { rc = cli_magic_scandesc(metadata.ofd, ctx); close(metadata.ofd); if (rc == CL_VIRUS) { cli_dbgmsg("CHM: infected with %s\n", cli_get_last_virus(ctx)); if (SCAN_ALL) viruses_found++; else { ret = CL_VIRUS; break; } } } } while(ret == CL_SUCCESS); cli_chm_close(&metadata); if(!ctx->engine->keeptmp) cli_rmdirs(dir); free(dir); cli_dbgmsg("CHM: Exit code: %d\n", ret); if (ret == CL_BREAK) ret = CL_CLEAN; if (SCAN_ALL && viruses_found) return CL_VIRUS; return ret; }
false
false
false
false
false
0
get_name_filldir(struct dir_context *ctx, const char *name, int length, loff_t offset, u64 inum, unsigned int type) { struct get_name_filldir *gnfd = container_of(ctx, struct get_name_filldir, ctx); if (inum != gnfd->inum.no_addr) return 0; memcpy(gnfd->name, name, length); gnfd->name[length] = 0; return 1; }
false
false
false
false
false
0
karea_draw_character (GtkWidget *w, int index, int selected) { PangoLayout *layout; gchar *string_utf; gint char_width, char_height; gint x; karea_get_char_size (w, &char_width, &char_height); if (selected >= 0) { gdk_draw_rectangle (kpixmap, selected ? w->style->bg_gc[GTK_STATE_SELECTED] : w->style->white_gc, TRUE, 0, (char_height + 6) *index, w->allocation.width - 1, char_height + 5); } string_utf = utf8_for_char (kanjiguess[index]); layout = gtk_widget_create_pango_layout (w, string_utf); g_free (string_utf); x = (w->allocation.width - char_width) / 2; gdk_draw_layout (kpixmap, (selected > 0) ? w->style->white_gc : w->style->black_gc, x, (char_height + 6) * index + 3, layout); g_object_unref (layout); }
false
false
false
false
false
0
upload_firmware(struct zd_usb *usb) { int r; u16 fw_bcdDevice; u16 bcdDevice; struct usb_device *udev = zd_usb_to_usbdev(usb); const struct firmware *ub_fw = NULL; const struct firmware *uph_fw = NULL; char fw_name[128]; bcdDevice = get_bcdDevice(udev); r = request_fw_file(&ub_fw, get_fw_name(usb, fw_name, sizeof(fw_name), "ub"), &udev->dev); if (r) goto error; fw_bcdDevice = get_word(ub_fw->data, E2P_DATA_OFFSET); if (fw_bcdDevice != bcdDevice) { dev_info(&udev->dev, "firmware version %#06x and device bootcode version " "%#06x differ\n", fw_bcdDevice, bcdDevice); if (bcdDevice <= 0x4313) dev_warn(&udev->dev, "device has old bootcode, please " "report success or failure\n"); r = handle_version_mismatch(usb, ub_fw); if (r) goto error; } else { dev_dbg_f(&udev->dev, "firmware device id %#06x is equal to the " "actual device id\n", fw_bcdDevice); } r = request_fw_file(&uph_fw, get_fw_name(usb, fw_name, sizeof(fw_name), "uphr"), &udev->dev); if (r) goto error; r = upload_code(udev, uph_fw->data, uph_fw->size, FW_START, REBOOT); if (r) { dev_err(&udev->dev, "Could not upload firmware code uph. Error number %d\n", r); } /* FALL-THROUGH */ error: release_firmware(ub_fw); release_firmware(uph_fw); return r; }
true
true
false
false
false
1
method_D4(const int *account, int *weight) { // note this is a slightly modified version of the old method D1 if (account[0] == 0) return AccountNumberCheck::ERROR; // note: from here on this method is quite similar to method_C6 number2Array("2121212120", weight); int result = algo03(10, weight, true, account, 0, 8); // quick hack: the processed leading numbers "428259" boil down to a constant factor of 29 result += 29; // calc the check number, note: 1000 should be large enough. result = (1000 - result) % 10; // compare the result with the real check number if (account[9] == result) return AccountNumberCheck::OK; else return AccountNumberCheck::ERROR; }
false
false
false
false
false
0
builtin (void) /***** builtin interpret a builtin command, number no. *****/ { unsigned long l; commandtyp *p; int comn; if (*next==3) { next++; #ifdef SPECIAL_ALIGNMENT memmove((char *)(&comn),next,sizeof(int)); #else comn=*((int *)next); #endif p=command_list+comn; l=sizeof(int); } else if (udfon) return 0; else p=preview_command(&l); if (p) { next+=l; p->f(); if (*next==';' || *next==',') next++; commandtype=p->nr; return 1; } return 0; }
false
false
false
false
false
0
buckets_destroy(bucket* buckets, int32_t count) { for (int32_t i = 0; i < count; ++i) { bucket_destroy(buckets + i); } free(buckets); }
false
false
false
false
false
0
cob_decimal_get_packed (cob_decimal *d, cob_field *f, const int opt) { unsigned char *data; unsigned char *p; unsigned char *q; size_t size; size_t n; size_t i; int diff; int sign; int digits; unsigned char x; /* build string */ sign = mpz_sgn (d->value); mpz_abs (d->value, d->value); mpz_get_str ((char *)num_buff_ptr, 10, d->value); size = strlen ((char *)num_buff_ptr); /* store number */ data = f->data; /* Fixme */ digits = COB_FIELD_DIGITS(f); q = num_buff_ptr; diff = (int)(digits - size); if (diff < 0) { /* overflow */ cob_set_exception (COB_EC_SIZE_OVERFLOW); /* if the statement has ON SIZE ERROR or NOT ON SIZE ERROR, then throw an exception */ if (opt & COB_STORE_KEEP_ON_OVERFLOW) { return cob_exception_code; } q += size - digits; size = digits; } memset (data, 0, f->size); p = data + (digits / 2) - (size / 2); diff = 1 - (int)(size % 2); for (i = diff, n = 0; i < size + diff; i++, n++) { x = cob_d2i (q[n]); if (i % 2 == 0) { *p = x << 4; } else { *p++ |= x; } } p = f->data + f->size - 1; if (!COB_FIELD_HAVE_SIGN (f)) { *p = (*p & 0xf0) | 0x0f; } else if (sign < 0) { *p = (*p & 0xf0) | 0x0d; } else { *p = (*p & 0xf0) | 0x0c; } return 0; }
false
false
false
false
false
0
LUsolve(const MAT *LU, PERM *pivot, const VEC *b, VEC *x) #endif { if ( ! LU || ! b || ! pivot ) error(E_NULL,"LUsolve"); if ( LU->m != LU->n || LU->n != b->dim ) error(E_SIZES,"LUsolve"); x = v_resize(x,b->dim); px_vec(pivot,b,x); /* x := P.b */ Lsolve(LU,x,x,1.0); /* implicit diagonal = 1 */ Usolve(LU,x,x,0.0); /* explicit diagonal */ return (x); }
false
false
false
true
false
1
pop_expr(struct state *state) { if (state->exprs_used > 0) { state->exprs_used -= 1; return state->exprs[state->exprs_used]; } else { STATE_ERROR(state, PATHX_EINTERNAL); assert(0); return NULL; } }
false
false
false
false
false
0
git_tags_pane_init (GitTagsPane *self) { gchar *objects[] = {"tags_pane", "tags_list_model", NULL}; GError *error = NULL; GtkTreeView *tags_view; GtkCellRenderer *tags_selected_renderer; self->priv = g_new0 (GitTagsPanePriv, 1); self->priv->builder = gtk_builder_new (); if (!gtk_builder_add_objects_from_file (self->priv->builder, BUILDER_FILE, objects, &error)) { g_warning ("Couldn't load builder file: %s", error->message); g_error_free (error); } tags_view = GTK_TREE_VIEW (gtk_builder_get_object (self->priv->builder, "tags_view")); self->priv->tags_list_model = GTK_LIST_STORE (gtk_builder_get_object (self->priv->builder, "tags_list_model")); tags_selected_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (self->priv->builder, "tags_selected_renderer")); /* DND */ gtk_tree_view_enable_model_drag_source (tags_view, GDK_BUTTON1_MASK, drag_targets, G_N_ELEMENTS (drag_targets), GDK_ACTION_COPY); g_signal_connect (G_OBJECT (tags_view), "drag-data-get", G_CALLBACK (on_tags_list_view_drag_data_get), NULL); g_signal_connect (G_OBJECT (tags_selected_renderer), "toggled", G_CALLBACK (on_selected_renderer_toggled), self); }
false
false
false
false
false
0
done() { if (mboxAccount.tasks.front() != this) LIBMAIL_THROW("Assertion failed: mail::mbox::task::done"); mboxAccount.tasks.pop(); delete this; }
false
false
false
false
false
0
dcbp_set_code(struct p_compressed_bm *p, enum drbd_bitmap_code code) { BUG_ON(code & ~0xf); p->encoding = (p->encoding & ~0xf) | code; }
false
false
false
false
false
0
get_chain_operator_parameter(void) const { // -------- DBC_REQUIRE(is_selected() == true); DBC_REQUIRE(selected_chains().size() == 1); // -------- unsigned int p = selected_chainsetup_repp->first_selected_chain(); if (p < selected_chainsetup_repp->chains.size()) { if (selected_chainsetup_repp->chains[p]->selected_chain_operator() > 0 && selected_chainsetup_repp->chains[p]->selected_chain_operator_parameter() > 0) return selected_chainsetup_repp->chains[p]->get_parameter(); } return 0.0f; }
false
false
false
false
false
0
__Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) { PyTypeObject* tp = Py_TYPE(obj); if (likely(tp->tp_getattro)) return tp->tp_getattro(obj, attr_name); #if PY_MAJOR_VERSION < 3 if (likely(tp->tp_getattr)) return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); #endif return PyObject_GetAttr(obj, attr_name); }
false
false
false
false
false
0
copy_from_filestruct(filestruct *file_top, filestruct *file_bot) { filestruct *top_save; size_t current_x_save = openfile->current_x; bool edittop_inside; #ifndef NANO_TINY bool right_side_up = FALSE, single_line = FALSE; #endif assert(file_top != NULL && file_bot != NULL); #ifndef NANO_TINY /* Keep track of whether the mark begins inside the partition and * will need adjustment. */ if (openfile->mark_set) { filestruct *top, *bot; size_t top_x, bot_x; mark_order((const filestruct **)&top, &top_x, (const filestruct **)&bot, &bot_x, &right_side_up); single_line = (top == bot); } #endif /* Partition the filestruct so that it contains no text, and keep * track of whether the top of the edit window is inside the * partition. */ filepart = partition_filestruct(openfile->current, openfile->current_x, openfile->current, openfile->current_x); edittop_inside = (openfile->edittop == openfile->fileage); /* Put the top and bottom of the filestruct at copies of file_top * and file_bot. */ openfile->fileage = copy_filestruct(file_top); openfile->filebot = openfile->fileage; while (openfile->filebot->next != NULL) openfile->filebot = openfile->filebot->next; /* Restore the current line and cursor position. If the mark begins * inside the partition, adjust the mark coordinates to compensate * for the change in the current line. */ openfile->current = openfile->filebot; openfile->current_x = strlen(openfile->filebot->data); if (openfile->fileage == openfile->filebot) { #ifndef NANO_TINY if (openfile->mark_set) { openfile->mark_begin = openfile->current; if (!right_side_up) openfile->mark_begin_x += openfile->current_x; } #endif openfile->current_x += current_x_save; } #ifndef NANO_TINY else if (openfile->mark_set) { if (!right_side_up) { if (single_line) { openfile->mark_begin = openfile->current; openfile->mark_begin_x -= current_x_save; } else openfile->mark_begin_x -= openfile->current_x; } } #endif /* Get the number of characters in the copied text, and add it to * totsize. */ openfile->totsize += get_totsize(openfile->fileage, openfile->filebot); /* Update the current y-coordinate to account for the number of * lines the copied text has, less one since the first line will be * tacked onto the current line. */ openfile->current_y += openfile->filebot->lineno - 1; top_save = openfile->fileage; /* If the top of the edit window is inside the partition, set it to * where the copied text now starts. */ if (edittop_inside) openfile->edittop = openfile->fileage; /* Unpartition the filestruct so that it contains all the text * again, plus the copied text. */ unpartition_filestruct(&filepart); /* Renumber starting with the beginning line of the old * partition. */ renumber(top_save); /* If the NO_NEWLINES flag isn't set, and the text doesn't end with * a magicline, add a new magicline. */ if (!ISSET(NO_NEWLINES) && openfile->filebot->data[0] != '\0') new_magicline(); }
false
false
false
false
false
0
LookupForWrite(JSObject* object, String* name, LookupResult* lookup) { object->LocalLookup(name, lookup); if (!StoreICableLookup(lookup)) { return false; } if (lookup->type() == INTERCEPTOR) { if (object->GetNamedInterceptor()->setter()->IsUndefined()) { object->LocalLookupRealNamedProperty(name, lookup); return StoreICableLookup(lookup); } } return true; }
false
false
false
false
false
0
haifa_change_pattern (rtx insn, rtx new_pat) { sched_change_pattern (insn, new_pat); /* Invalidate INSN_COST, so it'll be recalculated. */ INSN_COST (insn) = -1; /* Invalidate INSN_TICK, so it'll be recalculated. */ INSN_TICK (insn) = INVALID_TICK; }
false
false
false
false
false
0
CalculateKadUsersNew() { // the idea of calculating the user count with this method is simple: // whenever we do a search for any NodeID (except in certain cases where the result is not usable), // we remember the distance of the closest node we found. Because we assume all NodeIDs are distributed // equally, we can calculate based on this distance how "filled" the possible NodesID room is and by this // calculate how many users there are. Of course this only works if we have enough samples, because // each single sample will be wrong, but the average of them should produce a usable number. To avoid // drifts caused by a a single (or more) really close or really far away hits, we do use median-average instead through // doesn't work well if we have no files to index and nothing to download and the numbers seems to be a bit too low // compared to our other method. So let's stay with the old one for now, but keep this here as an alternative if (m_statsEstUsersProbes.size() < 10) { return 0; } uint32_t median = 0; std::list<uint32_t> medianList; for (std::list<uint32_t>::iterator it1 = m_statsEstUsersProbes.begin(); it1 != m_statsEstUsersProbes.end(); ++it1) { uint32_t probe = *it1; bool inserted = false; for (std::list<uint32_t>::iterator it2 = medianList.begin(); it2 != medianList.end(); ++it2) { if (*it2 > probe) { medianList.insert(it2, probe); inserted = true; break; } } if (!inserted) { medianList.push_back(probe); } } // cut away 1/3 of the values - 1/6 of the top and 1/6 of the bottom to avoid spikes having too much influence, build the average of the rest std::list<uint32_t>::size_type cut = medianList.size() / 6; for (std::list<uint32_t>::size_type i = 0; i != cut; ++i) { medianList.pop_front(); medianList.pop_back(); } uint64_t average = 0; for (std::list<uint32_t>::iterator it = medianList.begin(); it != medianList.end(); ++it) { average += *it; } median = (uint32_t)(average / medianList.size()); // LowIDModififier // Modify count by assuming 20% of the users are firewalled and can't be a contact for < 0.49b nodes // Modify count by actual statistics of Firewalled ratio for >= 0.49b if we are not firewalled ourself // Modify count by 40% for >= 0.49b if we are firewalled ourself (the actual Firewalled count at this date on kad is 35-55%) const float firewalledModifyOld = 1.20f; float firewalledModifyNew = 0.0; if (CUDPFirewallTester::IsFirewalledUDP(true)) { firewalledModifyNew = 1.40f; // we are firewalled and can't get the real statistics, assume 40% firewalled >=0.49b nodes } else if (GetPrefs()->StatsGetFirewalledRatio(true) > 0) { firewalledModifyNew = 1.0 + (CKademlia::GetPrefs()->StatsGetFirewalledRatio(true)); // apply the firewalled ratio to the modify wxASSERT(firewalledModifyNew > 1.0 && firewalledModifyNew < 1.90); } float newRatio = CKademlia::GetPrefs()->StatsGetKadV8Ratio(); float firewalledModifyTotal = 0.0; if (newRatio > 0 && firewalledModifyNew > 0) { // weigth the old and the new modifier based on how many new contacts we have firewalledModifyTotal = (newRatio * firewalledModifyNew) + ((1 - newRatio) * firewalledModifyOld); } else { firewalledModifyTotal = firewalledModifyOld; } wxASSERT(firewalledModifyTotal > 1.0 && firewalledModifyTotal < 1.90); return (uint32_t)((float)median * firewalledModifyTotal); }
false
false
false
false
false
0
get_queue_member_status(struct member *cur) { return ast_strlen_zero(cur->state_exten) ? ast_device_state(cur->state_interface) : extensionstate2devicestate(ast_extension_state(NULL, cur->state_context, cur->state_exten)); }
false
false
false
false
false
0
do_sys_ftruncate(unsigned int fd, loff_t length, int small) { struct inode *inode; struct dentry *dentry; struct fd f; int error; error = -EINVAL; if (length < 0) goto out; error = -EBADF; f = fdget(fd); if (!f.file) goto out; /* explicitly opened as large or we are on 64-bit box */ if (f.file->f_flags & O_LARGEFILE) small = 0; dentry = f.file->f_path.dentry; inode = dentry->d_inode; error = -EINVAL; if (!S_ISREG(inode->i_mode) || !(f.file->f_mode & FMODE_WRITE)) goto out_putf; error = -EINVAL; /* Cannot ftruncate over 2^31 bytes without large file support */ if (small && length > MAX_NON_LFS) goto out_putf; error = -EPERM; if (IS_APPEND(inode)) goto out_putf; sb_start_write(inode->i_sb); error = locks_verify_truncate(inode, f.file, length); if (!error) error = security_path_truncate(&f.file->f_path); if (!error) error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file); sb_end_write(inode->i_sb); out_putf: fdput(f); out: return error; }
false
false
false
false
false
0
stripe_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, dict_t *xattr) { int call_cnt = 0; stripe_local_t *local = NULL; VALIDATE_OR_GOTO (frame, out); VALIDATE_OR_GOTO (frame->local, out); local = frame->local; LOCK (&frame->lock); { call_cnt = --local->wind_count; } UNLOCK (&frame->lock); if (!xattr || (op_ret < 0)) goto out; local->op_ret = 0; if (!local->xattr) { local->xattr = dict_ref (xattr); } else { stripe_aggregate_xattr (local->xattr, xattr); } out: if (!call_cnt) { STRIPE_STACK_UNWIND (getxattr, frame, local->op_ret, op_errno, local->xattr); } return 0; }
false
false
false
true
false
1
p_is_debug_feature_item_enabled(const char *debug_item) { gboolean enable; char *filename; enable = FALSE; filename = p_get_gapdebug_storyboard_config_file(); if(filename) { if(gap_debug) { printf("debug feature filename:'%s'\n", filename); } if(g_file_test(filename, G_FILE_TEST_EXISTS)) { FILE *l_fp; char l_buf[400]; if(gap_debug) { printf("check for item:'%s'\n", debug_item); } l_fp = g_fopen(filename, "r"); if(l_fp) { while (NULL != fgets (l_buf, sizeof(l_buf)-1, l_fp)) { l_buf[sizeof(l_buf)-1] = '\0'; gap_file_chop_trailingspace_and_nl(&l_buf[0]); if(gap_debug) { printf(" CFG:'%s'\n", l_buf); } if (strcmp(l_buf, debug_item) == 0) { enable = TRUE; break; } } fclose(l_fp); } } g_free(filename); } return(enable); }
true
true
false
false
false
1
getChildren(const std::string& name) { NodeList result(0); NodeList::const_iterator iter; // search for all occurances of nodename and insert them into the new list for(iter = mNodeList.begin(); iter != mNodeList.end(); ++iter) { const std::string node_name = (*iter)->getName(); if (node_name == name) { result.push_back(*iter); } } return result; }
false
false
false
false
false
0
widget_pokemem_keyhandler( input_key key ) { int new_selected; new_selected = selected; switch ( key ) { case INPUT_KEY_Return: /* Do pokes */ case INPUT_KEY_KP_Enter: case INPUT_JOYSTICK_FIRE_1: widget_end_all( WIDGET_FINISHED_OK ); break; case INPUT_KEY_Escape: /* Close widget */ case INPUT_JOYSTICK_FIRE_2: widget_end_widget( WIDGET_FINISHED_CANCEL ); return; case INPUT_KEY_a: /* Add poke */ if( !widget_pokemem_add_custom_poke() ) new_selected = pokemem_count - 1; break; case INPUT_KEY_Home: new_selected = 0; break; case INPUT_KEY_End: new_selected = pokemem_count - 1; break; case INPUT_KEY_Page_Up: new_selected = ( selected > page_size )? selected - page_size : 0; break; case INPUT_KEY_Page_Down: new_selected = selected + page_size; if( new_selected >= pokemem_count ) new_selected = pokemem_count - 1; break; case INPUT_KEY_Up: case INPUT_KEY_7: case INPUT_JOYSTICK_UP: if( selected ) new_selected = selected - 1; break; case INPUT_KEY_Down: case INPUT_KEY_6: case INPUT_JOYSTICK_DOWN: if( selected + 1 < pokemem_count ) new_selected = selected + 1; break; case INPUT_KEY_space: case INPUT_KEY_8: case INPUT_JOYSTICK_RIGHT: if( !widget_pokemem_trainer_click( selected ) ) widget_pokemem_update_line( menu_left_edge_x, menu_width, selected ); return; default:; } if( store && new_selected != selected ) { if( new_selected < top_index ) { top_index = new_selected; highlight_line = new_selected - top_index; widget_pokemem_print_list( menu_left_edge_x, menu_width ); } else if( new_selected >= top_index + page_size ) { top_index = new_selected - page_size + 1; highlight_line = new_selected - top_index; widget_pokemem_print_list( menu_left_edge_x, menu_width ); } else { /* Otherwise, print the current trainer uninverted and the new current trainer inverted */ highlight_line = new_selected - top_index; if( selected >= 0 ) widget_pokemem_update_line( menu_left_edge_x, menu_width, selected ); widget_pokemem_update_line( menu_left_edge_x, menu_width, new_selected ); widget_display_lines( 3, page_size ); } selected = new_selected; } }
false
false
false
false
false
0
reader_process (void * data) { Artec48U_Scanner * s = (Artec48U_Scanner *) data; int fd = s->reader_pipe; SANE_Status status; struct SIGACTION act; sigset_t ignore_set; ssize_t bytes_written = 0; XDBG ((1, "reader process...\n")); if (sanei_thread_is_forked()) close (s->pipe); sigfillset (&ignore_set); sigdelset (&ignore_set, SIGTERM); sigdelset (&ignore_set, SIGUSR1); #if defined (__APPLE__) && defined (__MACH__) sigdelset (&ignore_set, SIGUSR2); #endif sigprocmask (SIG_SETMASK, &ignore_set, 0); memset (&act, 0, sizeof (act)); sigaction (SIGTERM, &act, 0); sigaction (SIGUSR1, &act, 0); cancelRead = SANE_FALSE; if (sigemptyset (&(act.sa_mask)) < 0) XDBG ((2, "(child) reader_process: sigemptyset() failed\n")); act.sa_flags = 0; act.sa_handler = reader_process_sigterm_handler; if (sigaction (SIGTERM, &act, 0) < 0) XDBG ((2, "(child) reader_process: sigaction(SIGTERM,...) failed\n")); act.sa_handler = usb_reader_process_sigterm_handler; if (sigaction (SIGUSR1, &act, 0) < 0) XDBG ((2, "(child) reader_process: sigaction(SIGUSR1,...) failed\n")); XDBG ((2, "(child) reader_process: s=%p, fd=%d\n", (void *) s, fd)); /*read line by line into buffer */ /*copy buffer pointers to line_buffer */ XDBG ((2, "(child) reader_process: byte_cnt %d\n", (int) s->byte_cnt)); s->eof = SANE_FALSE; while (s->lines_to_read > 0) { if (cancelRead == SANE_TRUE) { XDBG ((2, "(child) reader_process: cancelRead == SANE_TRUE\n")); s->scanning = SANE_FALSE; s->eof = SANE_FALSE; return SANE_STATUS_CANCELLED; } if (s->scanning != SANE_TRUE) { XDBG ((2, "(child) reader_process: scanning != SANE_TRUE\n")); return SANE_STATUS_CANCELLED; } status = artec48u_scanner_read_line (s, s->buffer_pointers, SANE_TRUE); if (status != SANE_STATUS_GOOD) { XDBG ((2, "(child) reader_process: scanner_read_line failed\n")); return SANE_STATUS_IO_ERROR; } copy_scan_line (s); s->lines_to_read -= 1; bytes_written = write (fd, s->line_buffer, s->sane_params.bytes_per_line); if (bytes_written < 0) { XDBG ((2, "(child) reader_process: write returned %s\n", strerror (errno))); s->eof = SANE_FALSE; return SANE_STATUS_IO_ERROR; } XDBG ((2, "(child) reader_process: lines to read %i\n", s->lines_to_read)); } s->eof = SANE_TRUE; close (fd); return SANE_STATUS_GOOD; }
false
false
false
false
false
0
itolg(ints, dims, imap, ndims) int *ints; /* multi-dimensional array of integers */ long *dims; /* list of dimensions */ long *imap; /* memory access index mapping vector */ int ndims; /* number of dimensions in list */ { long iocount = dimprod (dims, ndims); long *longs = (long *) malloc (iocount * sizeof (long)); if (longs != NULL && iocount > 0) { int idim; char *ip = (char*)ints; long *lp = longs; long length[MAX_NC_DIMS]; long coords[MAX_NC_DIMS]; for (idim = 0; idim < ndims; ++idim) { length[idim] = dims[idim]*imap[idim]; coords[idim] = 0; } for (;;) { *lp++ = (long)*(int*)ip; idim = ndims - 1; carry: ip += imap[idim]; if (++coords[idim] >= dims[idim]) { coords[idim] = 0; ip -= length[idim]; if (--idim < 0) break; goto carry; } } } return longs; }
false
false
false
false
true
1
commit(CdlTransaction transaction) { // The new name is already installed, nothing more needs to happen. CYG_UNUSED_PARAM(CdlTransaction, transaction); }
false
false
false
false
false
0
Togl_HideOverlay(Togl *togl) { if (togl->OverlayWindow && togl->OverlayIsMapped) { (void) XUnmapWindow(Tk_Display(togl->TkWin), togl->OverlayWindow); togl->OverlayIsMapped = False; } }
false
false
false
false
false
0
strtoll_or_err(const char *str, const char *errmesg) { long long num; char *end = NULL; if (str == NULL || *str == '\0') goto err; errno = 0; num = strtoll(str, &end, 10); if (errno || str == end || (end && *end)) goto err; return num; err: if (errno) err(EXIT_FAILURE, "%s: '%s'", errmesg, str); else errx(EXIT_FAILURE, "%s: '%s'", errmesg, str); return 0; }
false
false
false
false
false
0
pam_sm_authenticate(pam_handle_t *pamh, int flags, int argc, const char **argv) { const char *rhost = NULL; const char *username; guint i; int r; bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); g_type_init (); dbus_g_object_register_marshaller (fprintd_marshal_VOID__STRING_BOOLEAN, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_INVALID); pam_get_item(pamh, PAM_RHOST, (const void **)(const void*) &rhost); if (rhost != NULL && strlen(rhost) > 0) { /* remote login (e.g. over SSH) */ return PAM_AUTHINFO_UNAVAIL; } r = pam_get_user(pamh, &username, NULL); if (r != PAM_SUCCESS) return PAM_AUTHINFO_UNAVAIL; for (i = 0; i < argc; i++) { if (argv[i] != NULL) { if(g_str_equal (argv[i], "debug")) { g_message ("debug on"); debug = TRUE; } else if (strncmp(argv[i], MAX_TRIES_MATCH, strlen (MAX_TRIES_MATCH)) == 0 && strlen(argv[i]) == strlen (MAX_TRIES_MATCH) + 1) { max_tries = atoi (argv[i] + strlen (MAX_TRIES_MATCH)); if (max_tries < 1) max_tries = DEFAULT_MAX_TRIES; D(pamh, "max_tries specified as: %d", max_tries); } else if (strncmp(argv[i], TIMEOUT_MATCH, strlen (TIMEOUT_MATCH)) == 0 && strlen(argv[i]) <= strlen (TIMEOUT_MATCH) + 2) { timeout = atoi (argv[i] + strlen (TIMEOUT_MATCH)); if (timeout < 10) timeout = DEFAULT_TIMEOUT; D(pamh, "timeout specified as: %d", timeout); } } } r = do_auth(pamh, username); return r; }
false
false
false
false
false
0
mergeXdmCfg(const char *path) { char *p; XrmDatabase db; ASPrintf(&p, "%s/xdm-config", path); if ((db = XrmGetFileDatabase(p))) { printf("Information: reading xdm config file %s\n", p); usedFile(p); free(p); XrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels, dumpEntry, (XPointer)0); applyDefs(xdmdefs, as(xdmdefs), path); mod_usebg = True; return True; } free(p); return False; }
false
false
false
false
false
0
H5O_fill_old_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill) { const H5O_fill_t *fill = (const H5O_fill_t *)_fill; FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); HDassert(p); HDassert(fill && NULL == fill->type); UINT32ENCODE(p, fill->size); if(fill->buf) HDmemcpy(p, fill->buf, (size_t)fill->size); FUNC_LEAVE_NOAPI(SUCCEED) }
false
false
false
false
false
0
cs_file_sec(const char *attr, size_t len) { struct my_cs_file_section_st *s; for (s=sec; s->str; s++) { if (!strncmp(attr,s->str,len)) return s; } return NULL; }
false
false
false
false
false
0
mod_case_brace_add(chunk_t *cl_colon) { chunk_t *pc = cl_colon; chunk_t *last = NULL; chunk_t *next = chunk_get_next_ncnl(cl_colon, CNAV_PREPROC); chunk_t *br_open; chunk_t *br_close; chunk_t chunk; LOG_FMT(LMCB, "%s: line %d", __func__, pc->orig_line); while ((pc = chunk_get_next_ncnl(pc, CNAV_PREPROC)) != NULL) { if (pc->level < cl_colon->level) { LOG_FMT(LMCB, " - level drop\n"); return(next); } if ((pc->level == cl_colon->level) && ((pc->type == CT_CASE) || (pc->type == CT_BREAK))) { last = pc; //if (pc->type == CT_BREAK) //{ // /* Step past the semicolon */ // last = chunk_get_next_ncnl(chunk_get_next_ncnl(last)); //} break; } } if (last == NULL) { LOG_FMT(LMCB, " - NULL last\n"); return(next); } LOG_FMT(LMCB, " - adding before '%.*s' on line %d\n", last->len, last->str, last->orig_line); memset(&chunk, 0, sizeof(chunk)); chunk.type = CT_BRACE_OPEN; chunk.orig_line = cl_colon->orig_line; chunk.parent_type = CT_CASE; chunk.level = cl_colon->level; chunk.brace_level = cl_colon->brace_level; chunk.flags = pc->flags & PCF_COPY_FLAGS; chunk.str = "{"; chunk.len = 1; br_open = chunk_add_after(&chunk, cl_colon); chunk.type = CT_BRACE_CLOSE; chunk.orig_line = last->orig_line; chunk.str = "}"; br_close = chunk_add_before(&chunk, last); newline_add_before(last); for (pc = chunk_get_next(br_open, CNAV_PREPROC); pc != br_close; pc = chunk_get_next(pc, CNAV_PREPROC)) { pc->level++; pc->brace_level++; } return(br_open); }
false
false
false
false
false
0
Set(const char *string) { char **token = g_strsplit(string, " ", Size()); for (int i = 0; i < Size(); i++) { if (token[i] == NULL) { Set(i, ufnumberarray->Default[i]); } else { double number; int count = sscanf(token[i], "%lf", &number); if (count != 1) Throw("String '%s' is not a number", string); Set(i, number); } } g_strfreev(token); }
false
false
false
false
false
0
DoOpenProject(const wxString& filename, bool addToHistory) { // Manager::Get()->GetLogManager()->DebugLog(_T("Opening project '%s'"), filename.wx_str()); if (!wxFileExists(filename)) { cbMessageBox(_("The project file does not exist..."), _("Error"), wxICON_ERROR); return false; } ShowHideStartPage(true); // hide startherepage, so we can use full tab-range cbProject* prj = Manager::Get()->GetProjectManager()->LoadProject(filename, true); if (prj) { if (addToHistory) m_projectsHistory.AddToHistory(prj->GetFilename()); return true; } ShowHideStartPage(); // show/hide startherepage, dependant of settings, if loading failed return false; }
false
false
false
false
false
0
cc770_rtr_interrupt(struct net_device *dev, unsigned int o) { struct cc770_priv *priv = netdev_priv(dev); unsigned int mo = obj2msgobj(o); u8 ctrl0, ctrl1; int n = CC770_MAX_MSG; while (n--) { ctrl0 = cc770_read_reg(priv, msgobj[mo].ctrl0); if (!(ctrl0 & INTPND_SET)) break; ctrl1 = cc770_read_reg(priv, msgobj[mo].ctrl1); cc770_rx(dev, mo, ctrl1); cc770_write_reg(priv, msgobj[mo].ctrl0, MSGVAL_SET | TXIE_RES | RXIE_SET | INTPND_RES); cc770_write_reg(priv, msgobj[mo].ctrl1, NEWDAT_RES | CPUUPD_SET | TXRQST_RES | RMTPND_RES); } }
false
false
false
false
false
0
my_strdup(const char *str) /**************************************************************************** purpose: duplicate string --- exists to ease porting ****************************************************************************/ { char *s = NULL; unsigned long strsize; strsize = strlen(str) + 1; s = (char *) malloc(strsize); *s = '\0'; if (s == NULL) diagnostics(ERROR, "Cannot allocate memory to duplicate string"); my_strlcpy(s, str, strsize); return s; }
false
false
false
false
false
0
test_gtk_plugin_manager_configure_button_sensitivity (TestFixture *fixture) { GtkTreeIter iter; PeasPluginInfo *info; testing_util_push_log_hook ("Could not find plugin 'does-not-exist'*"); /* Must come first otherwise the first iter may * be after a revealed builtin plugin */ peas_gtk_plugin_manager_view_set_show_builtin (fixture->view, TRUE); /* So we can configure them */ info = peas_engine_get_plugin_info (fixture->engine, "builtin-configurable"); peas_engine_load_plugin (fixture->engine, info); info = peas_engine_get_plugin_info (fixture->engine, "configurable"); peas_engine_load_plugin (fixture->engine, info); /* Causes the plugin to become unavailable */ info = peas_engine_get_plugin_info (fixture->engine, "unavailable"); peas_engine_load_plugin (fixture->engine, info); g_assert (gtk_tree_model_get_iter_first (fixture->model, &iter)); do { gboolean sensitive; gtk_tree_selection_select_iter (fixture->selection, &iter); info = testing_get_plugin_info_for_iter (fixture->view, &iter); if (!peas_plugin_info_is_loaded (info)) { sensitive = FALSE; } else { sensitive = peas_engine_provides_extension (fixture->engine, info, PEAS_GTK_TYPE_CONFIGURABLE); } g_assert_cmpint (gtk_widget_get_sensitive (fixture->configure_button), ==, sensitive); } while (gtk_tree_model_iter_next (fixture->model, &iter)); }
false
false
false
false
false
0
standardise(const QString& string, SpellingType spellingType) const { //remove exterraneous characters QString standardised = string; standardised.remove(QRegExp("[.,\\s-_()]")); if(spellingType == Player) { //capitalise first letter standardised.replace(0, 1, string.at(0).toUpper()); //standardise captilisation of names beginning with "Van de" standardised.replace("van de", "Van de", Qt::CaseInsensitive); } return standardised; }
false
false
false
false
false
0
_css_length (const char *str,GR_Graphics* pG, UT_sint32 *iDisplayLength,UT_sint32 *iLayoutLength) { UT_sint32 dim = UT_determineDimension(static_cast<const char*>(str), DIM_PX); if (dim != DIM_PX && dim != DIM_none) { if (pG == 0) { *iDisplayLength = static_cast<UT_sint32>((UT_convertToInches(str) * 72.0) + 0.05); } else { *iDisplayLength = UT_convertToLogicalUnits(str); } *iLayoutLength = UT_convertToLogicalUnits(str); } else { double iImageLength = UT_convertDimensionless(str); double fScale = pG ? (pG->getResolution() / 72.0) : 1; *iDisplayLength = static_cast<UT_sint32>(iImageLength * fScale); fScale = 1440.0 / 72.0; *iLayoutLength = static_cast<UT_sint32>(iImageLength * fScale); } }
false
false
false
false
false
0
krb5_config_vget_string_default (krb5_context context, const krb5_config_section *c, const char *def_value, va_list args) { const char *ret; ret = krb5_config_vget_string (context, c, args); if (ret == NULL) ret = def_value; return ret; }
false
false
false
false
false
0
SMB2_set_compression(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid) { int rc; struct compress_ioctl fsctl_input; char *ret_data = NULL; fsctl_input.CompressionState = cpu_to_le16(COMPRESSION_FORMAT_DEFAULT); rc = SMB2_ioctl(xid, tcon, persistent_fid, volatile_fid, FSCTL_SET_COMPRESSION, true /* is_fsctl */, (char *)&fsctl_input /* data input */, 2 /* in data len */, &ret_data /* out data */, NULL); cifs_dbg(FYI, "set compression rc %d\n", rc); return rc; }
false
false
false
false
false
0
str2txid(const char *s, const char **endp) { txid val = 0; txid cutoff = MAX_TXID / 10; txid cutlim = MAX_TXID % 10; for (; *s; s++) { unsigned d; if (*s < '0' || *s > '9') break; d = *s - '0'; /* * check for overflow */ if (val > cutoff || (val == cutoff && d > cutlim)) { val = 0; break; } val = val * 10 + d; } if (endp) *endp = s; return val; }
false
false
false
false
false
0
source_registry_compare_nodes (GNode *node_a, GNode *node_b) { ESource *source_a = E_SOURCE (node_a->data); ESource *source_b = E_SOURCE (node_b->data); const gchar *uid_a, *uid_b; uid_a = e_source_get_uid (source_a); uid_b = e_source_get_uid (source_b); /* Sanity check, with runtime warnings. */ if (uid_a == NULL) { g_warn_if_reached (); uid_a = ""; } if (uid_b == NULL) { g_warn_if_reached (); uid_b = ""; } /* The built-in "local-stub" source comes first at depth 1. */ if (g_strcmp0 (uid_a, "local-stub") == 0) return -1; if (g_strcmp0 (uid_b, "local-stub") == 0) return 1; /* The built-in "system-*" sources come first at depth 2. */ if (g_str_has_prefix (uid_a, "system-")) return -1; if (g_str_has_prefix (uid_b, "system-")) return 1; return e_source_compare_by_display_name (source_a, source_b); }
false
false
false
false
false
0
drr_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt) { struct rtattr *tb[TCA_DRR_MAX + 1]; SPRINT_BUF(b1); if (opt == NULL) return 0; parse_rtattr_nested(tb, TCA_DRR_MAX, opt); if (tb[TCA_DRR_QUANTUM]) fprintf(f, "quantum %s ", sprint_size(rta_getattr_u32(tb[TCA_DRR_QUANTUM]), b1)); return 0; }
false
false
false
false
false
0
ui_vis_timeout_func (GtkWidget * widget, guchar * data) { if (config.vis_type == VIS_ANALYZER) { const gint n = (config.analyzer_type == ANALYZER_BARS) ? 19 : 75; for (gint i = 0; i < n; i++) { if (data[i] > vis.data[i]) { vis.data[i] = data[i]; if (vis.data[i] > vis.peak[i]) { vis.peak[i] = vis.data[i]; vis.peak_speed[i] = 0.01; } else if (vis.peak[i] > 0.0) { vis.peak[i] -= vis.peak_speed[i]; vis.peak_speed[i] *= vis_pfalloff_speeds[config.peaks_falloff]; if (vis.peak[i] < vis.data[i]) vis.peak[i] = vis.data[i]; if (vis.peak[i] < 0.0) vis.peak[i] = 0.0; } } else { if (vis.data[i] > 0.0) { vis.data[i] -= vis_afalloff_speeds[config.analyzer_falloff]; if (vis.data[i] < 0.0) vis.data[i] = 0.0; } if (vis.peak[i] > 0.0) { vis.peak[i] -= vis.peak_speed[i]; vis.peak_speed[i] *= vis_pfalloff_speeds[config.peaks_falloff]; if (vis.peak[i] < vis.data[i]) vis.peak[i] = vis.data[i]; if (vis.peak[i] < 0.0) vis.peak[i] = 0.0; } } } } else if (config.vis_type == VIS_VOICEPRINT) { for (gint i = 0; i < 16; i++) vis.data[i] = data[15 - i]; vis.voiceprint_advance = TRUE; } else { for (gint i = 0; i < 75; i++) vis.data[i] = data[i]; } vis.active = TRUE; gtk_widget_queue_draw (widget); }
false
false
false
false
false
0
sdio_uart_change_speed(struct sdio_uart_port *port, struct ktermios *termios, struct ktermios *old) { unsigned char cval, fcr = 0; unsigned int baud, quot; switch (termios->c_cflag & CSIZE) { case CS5: cval = UART_LCR_WLEN5; break; case CS6: cval = UART_LCR_WLEN6; break; case CS7: cval = UART_LCR_WLEN7; break; default: case CS8: cval = UART_LCR_WLEN8; break; } if (termios->c_cflag & CSTOPB) cval |= UART_LCR_STOP; if (termios->c_cflag & PARENB) cval |= UART_LCR_PARITY; if (!(termios->c_cflag & PARODD)) cval |= UART_LCR_EPAR; for (;;) { baud = tty_termios_baud_rate(termios); if (baud == 0) baud = 9600; /* Special case: B0 rate. */ if (baud <= port->uartclk) break; /* * Oops, the quotient was zero. Try again with the old * baud rate if possible, otherwise default to 9600. */ termios->c_cflag &= ~CBAUD; if (old) { termios->c_cflag |= old->c_cflag & CBAUD; old = NULL; } else termios->c_cflag |= B9600; } quot = (2 * port->uartclk + baud) / (2 * baud); if (baud < 2400) fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; else fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_10; port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; if (termios->c_iflag & INPCK) port->read_status_mask |= UART_LSR_FE | UART_LSR_PE; if (termios->c_iflag & (BRKINT | PARMRK)) port->read_status_mask |= UART_LSR_BI; /* * Characters to ignore */ port->ignore_status_mask = 0; if (termios->c_iflag & IGNPAR) port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; if (termios->c_iflag & IGNBRK) { port->ignore_status_mask |= UART_LSR_BI; /* * If we're ignoring parity and break indicators, * ignore overruns too (for real raw support). */ if (termios->c_iflag & IGNPAR) port->ignore_status_mask |= UART_LSR_OE; } /* * ignore all characters if CREAD is not set */ if ((termios->c_cflag & CREAD) == 0) port->ignore_status_mask |= UART_LSR_DR; /* * CTS flow control flag and modem status interrupts */ port->ier &= ~UART_IER_MSI; if ((termios->c_cflag & CRTSCTS) || !(termios->c_cflag & CLOCAL)) port->ier |= UART_IER_MSI; port->lcr = cval; sdio_out(port, UART_IER, port->ier); sdio_out(port, UART_LCR, cval | UART_LCR_DLAB); sdio_out(port, UART_DLL, quot & 0xff); sdio_out(port, UART_DLM, quot >> 8); sdio_out(port, UART_LCR, cval); sdio_out(port, UART_FCR, fcr); sdio_uart_write_mctrl(port, port->mctrl); }
false
false
false
false
false
0
gib_list_randomize(gib_list * list) { int len, r, i; gib_list **farray, *f, *t; if (!list) return (NULL); len = gib_list_length(list); if (len <= 1) return (list); farray = (gib_list **) gib_emalloc(sizeof(gib_list *) * len); for (f = list, i = 0; f; f = f->next, i++) { farray[i] = f; } srand(getpid() * time(NULL) % ((unsigned int) -1)); for (i = 0; i < len - 1; i++) { r = (int) ((len - i - 1) * ((float) rand()) / (RAND_MAX + 1.0)) + i + 1; if (i == r) abort(); t = farray[i]; farray[i] = farray[r]; farray[r] = t; } list = farray[0]; list->prev = NULL; list->next = farray[1]; for (i = 1, f = farray[1]; i < len - 1; i++, f = f->next) { f->prev = farray[i - 1]; f->next = farray[i + 1]; } f->prev = farray[len - 2]; f->next = NULL; gib_efree(farray); return (list); }
false
false
false
false
true
1
brasero_volume_source_open_device_handle (BraseroDeviceHandle *handle, GError **error) { int size; BraseroVolSrc *src; BraseroScsiResult result; BraseroScsiGetConfigHdr *hdr = NULL; g_return_val_if_fail (handle != NULL, NULL); src = g_new0 (BraseroVolSrc, 1); src->ref = 1; src->data = handle; src->seek = brasero_volume_source_seek_device_handle; /* check which read function should be used. */ result = brasero_mmc2_get_configuration_feature (handle, BRASERO_SCSI_FEAT_RD_CD, &hdr, &size, NULL); if (result == BRASERO_SCSI_OK && hdr->desc->current) { BRASERO_MEDIA_LOG ("READ CD current. Using READCD"); src->read = brasero_volume_source_readcd_device_handle; g_free (hdr); return src; } /* clean and retry */ g_free (hdr); hdr = NULL; result = brasero_mmc2_get_configuration_feature (handle, BRASERO_SCSI_FEAT_RD_RANDOM, &hdr, &size, NULL); if (result == BRASERO_SCSI_OK && hdr->desc->current) { BRASERO_MEDIA_LOG ("READ DVD current. Using READ10"); src->read = brasero_volume_source_read10_device_handle; g_free (hdr); } else { BRASERO_MEDIA_LOG ("READ DVD not current. Using READCD."); src->read = brasero_volume_source_readcd_device_handle; g_free (hdr); } return src; }
false
false
false
false
false
0
to (bool right) { if (!deep()) host->split(half); history[layer()] = half; // FIXME pos = pos.to(right); layer_--; if ( (host->twist_mask >> layer()) & 1 ) right = !right; // twist it! half = (host->halves[half]<<1) + right; }
false
false
false
false
false
0
onAskForHideNodes(VisuData *visuData, gboolean *redraw, gpointer data _U_) { VisuColorization *dt; /* No data, useless to stay here. */ if (!flagDataFileIsLoaded) return; if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkHideMinValues))) { DBG_fprintf(stderr, "Panel DataFile: caught the 'AskForShowHide' signal for" " VisuData %p.\n", (gpointer)visuData); dt = visu_colorization_get(visuData, FALSE, (gboolean*)0); hidingData.column = (guint)gtk_spin_button_get_value(GTK_SPIN_BUTTON(spinHideMinValues)) - 1; hidingData.value = visu_ui_numerical_entry_getValue(VISU_UI_NUMERICAL_ENTRY(entryHideMinValues)); *redraw = visu_colorization_applyHide(dt, visuData) || *redraw; } }
false
false
false
false
false
0
gnrm_Write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s; //carefull we are not writing the box type but the entry type so switch for write ptr->type = ptr->EntryType; e = gf_isom_box_write_header(s, bs); if (e) return e; ptr->type = GF_ISOM_BOX_TYPE_GNRM; gf_bs_write_data(bs, ptr->reserved, 6); gf_bs_write_u16(bs, ptr->dataReferenceIndex); gf_bs_write_data(bs, ptr->data, ptr->data_size); return GF_OK; }
false
false
false
false
false
0
points (xfieldP xf, helperFunc helper, int firstConnection, int lastConnection, int face, enum approxE approx, int skip) { static int translation[8]; static float fscratch[3]; static long iscratch; int i = 0, c; dependencyT odep; int translu = 0; ENTRY(("points (0x%x, 0x%x, %d, %d, %d, %d, %d)", xf, helper, firstConnection, lastConnection, face, approx, skip)); SENDPERFIELD(NOT_LIT); if (doesTrans) { switch(odep = xf->opacitiesDep) { case dep_none: translu = 0; break; case dep_field: translu = OPACITY(0) < 1.0f; break; default: break; } if (! translu) { for(c=firstConnection;c<lastConnection;c+=skip) { if(!xf->invCntns || ! DXIsElementInvalid(xf->invCntns,c)) { int c1; if (xf->connections) c1 = *(int*)DXGetArrayEntry(xf->connections, c, (Pointer)iscratch); else c1 = c; if(xf->invPositions && DXIsElementInvalid(xf->invPositions, c1)) continue; if (odep == dep_connections) translu |= OPACITY(c) < 1.0f; else if (odep == dep_positions) translu |= OPACITY(c1) < 1.0f; if (! translu) { if (i == 0) glBegin(GL_POINTS); (*helper)(xf,1,c,&c1); if (++i == 256) { i = 0; glEnd(); } } } } if (i) glEnd(); } } else { for(c=firstConnection;c<lastConnection;c+=skip) { if(!xf->invCntns || ! DXIsElementInvalid(xf->invCntns,c)) { int c1; if (xf->connections) c1 = *(int*)DXGetArrayEntry(xf->connections, c, (Pointer)iscratch); else c1 = c; if(xf->invPositions && DXIsElementInvalid(xf->invPositions, c1)) continue; if (i == 0) glBegin(GL_POINTS); (*helper)(xf,xf->posPerConn,c,translation); if (++i == 256) { i = 0; glEnd(); } } } if (i) glEnd(); } ENDPERFIELD(); EXIT(("")); return OK; }
false
false
false
false
false
0
enum_dump (mca_base_var_enum_t *self, char **out) { int i; char *tmp; int ret; *out = NULL; if (NULL == self) { return OPAL_ERROR; } tmp = NULL; for (i = 0; i < self->enum_value_count && self->enum_values[i].string ; ++i) { ret = asprintf (out, "%s%s%d:\"%s\"", tmp ? tmp : "", tmp ? ", " : "", self->enum_values[i].value, self->enum_values[i].string); if (tmp) free (tmp); if (0 > ret) { return OPAL_ERR_OUT_OF_RESOURCE; } tmp = *out; } return OPAL_SUCCESS; }
false
false
false
false
false
0
listForeach(List root, void (*fun)(void*, void*), void* arg) { root = listBegin(root); while (root) { fun(root->v, arg); root = listNext(root); } }
false
false
false
false
false
0
uvc_video_stats_dump(struct uvc_streaming *stream, char *buf, size_t size) { unsigned int scr_sof_freq; unsigned int duration; struct timespec ts; size_t count = 0; ts.tv_sec = stream->stats.stream.stop_ts.tv_sec - stream->stats.stream.start_ts.tv_sec; ts.tv_nsec = stream->stats.stream.stop_ts.tv_nsec - stream->stats.stream.start_ts.tv_nsec; if (ts.tv_nsec < 0) { ts.tv_sec--; ts.tv_nsec += 1000000000; } /* Compute the SCR.SOF frequency estimate. At the nominal 1kHz SOF * frequency this will not overflow before more than 1h. */ duration = ts.tv_sec * 1000 + ts.tv_nsec / 1000000; if (duration != 0) scr_sof_freq = stream->stats.stream.scr_sof_count * 1000 / duration; else scr_sof_freq = 0; count += scnprintf(buf + count, size - count, "frames: %u\npackets: %u\nempty: %u\n" "errors: %u\ninvalid: %u\n", stream->stats.stream.nb_frames, stream->stats.stream.nb_packets, stream->stats.stream.nb_empty, stream->stats.stream.nb_errors, stream->stats.stream.nb_invalid); count += scnprintf(buf + count, size - count, "pts: %u early, %u initial, %u ok\n", stream->stats.stream.nb_pts_early, stream->stats.stream.nb_pts_initial, stream->stats.stream.nb_pts_constant); count += scnprintf(buf + count, size - count, "scr: %u count ok, %u diff ok\n", stream->stats.stream.nb_scr_count_ok, stream->stats.stream.nb_scr_diffs_ok); count += scnprintf(buf + count, size - count, "sof: %u <= sof <= %u, freq %u.%03u kHz\n", stream->stats.stream.min_sof, stream->stats.stream.max_sof, scr_sof_freq / 1000, scr_sof_freq % 1000); return count; }
false
false
false
false
false
0
Listen(Sensor* s) { cursensor = s; if (window == nil) { /* can't set input interest without window */ return; } Mask m = ExposureMask; if (s != nil) { m |= s->mask; } WindowRep* w = window->rep(); XSelectInput(w->display_->rep()->display_, w->xwindow_, m); }
false
false
false
false
false
0
show (std::string name) { GtkWindow *dialog = GTK_WINDOW (get ("dialog")); // Update window manager decorations gboolean decorated = gtk_window_get_decorated (dialog); if (decorated != biff_->value_bool ("applet_use_decoration")) gtk_window_set_decorated (dialog, biff_->value_bool ("applet_use_decoration")); gtk_widget_show (GTK_WIDGET (dialog)); if (biff_->value_bool ("applet_use_geometry")) gtk_window_parse_geometry (dialog, biff_->value_gchar ("applet_geometry")); if (biff_->value_bool ("applet_be_sticky")) gtk_window_stick (dialog); else gtk_window_unstick (dialog); gtk_window_set_keep_above(dialog, biff_->value_bool ("applet_keep_above")); gtk_window_set_skip_pager_hint (dialog,!biff_->value_bool("applet_pager")); gtk_window_set_skip_taskbar_hint (dialog, !biff_->value_bool ("applet_taskbar")); }
false
false
false
false
false
0
pline(P *p, long line) { if (line > p->b->eof->line) { pset(p, p->b->eof); return p; } if (line < labs(p->line - line)) pset(p, p->b->bof); if (labs(p->b->eof->line - line) < labs(p->line - line)) pset(p, p->b->eof); if (p->line == line) { p_goto_bol(p); return p; } while (line > p->line) pnextl(p); if (line < p->line) { while (line < p->line) pprevl(p); p_goto_bol(p); } return p; }
false
false
false
false
false
0
SSL_GetChannelInfo(PRFileDesc *fd, SSLChannelInfo *info, PRUintn len) { sslSocket * ss; SSLChannelInfo inf; sslSessionID * sid; if (!info || len < sizeof inf.length) { PORT_SetError(SEC_ERROR_INVALID_ARGS); return SECFailure; } ss = ssl_FindSocket(fd); if (!ss) { SSL_DBG(("%d: SSL[%d]: bad socket in SSL_GetChannelInfo", SSL_GETPID(), fd)); return SECFailure; } memset(&inf, 0, sizeof inf); inf.length = PR_MIN(sizeof inf, len); if (ss->opt.useSecurity && ss->enoughFirstHsDone) { sid = ss->sec.ci.sid; inf.protocolVersion = ss->version; inf.authKeyBits = ss->sec.authKeyBits; inf.keaKeyBits = ss->sec.keaKeyBits; if (ss->version < SSL_LIBRARY_VERSION_3_0) { /* SSL2 */ inf.cipherSuite = ss->sec.cipherType | 0xff00; inf.compressionMethod = ssl_compression_null; inf.compressionMethodName = "N/A"; } else if (ss->ssl3.initialized) { /* SSL3 and TLS */ ssl_GetSpecReadLock(ss); /* XXX The cipher suite should be in the specs and this * function should get it from cwSpec rather than from the "hs". * See bug 275744 comment 69 and bug 766137. */ inf.cipherSuite = ss->ssl3.hs.cipher_suite; inf.compressionMethod = ss->ssl3.cwSpec->compression_method; ssl_ReleaseSpecReadLock(ss); inf.compressionMethodName = ssl_GetCompressionMethodName(inf.compressionMethod); } if (sid) { inf.creationTime = sid->creationTime; inf.lastAccessTime = sid->lastAccessTime; inf.expirationTime = sid->expirationTime; if (ss->version < SSL_LIBRARY_VERSION_3_0) { /* SSL2 */ inf.sessionIDLength = SSL2_SESSIONID_BYTES; memcpy(inf.sessionID, sid->u.ssl2.sessionID, SSL2_SESSIONID_BYTES); } else { unsigned int sidLen = sid->u.ssl3.sessionIDLength; sidLen = PR_MIN(sidLen, sizeof inf.sessionID); inf.sessionIDLength = sidLen; memcpy(inf.sessionID, sid->u.ssl3.sessionID, sidLen); } } } memcpy(info, &inf, inf.length); return SECSuccess; }
false
false
false
false
false
0