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
setClockModeLabel() { _FB_USES_NLS; if (FbTk::StringUtil::findCharFromAlphabetAfterTrigger( m_tool.timeFormat(), '%', SWITCHES_24_12H, 3, 0) != std::string::npos) { setLabel( _FB_XTEXT(Toolbar, Clock24, "Clock: 24h", "set Clockmode to 24h") ); } else { setLabel( _FB_XTEXT(Toolbar, Clock12, "Clock: 12h", "set Clockmode to 12h") ); } }
false
false
false
false
false
0
command_trie_find_leaf (command_trie_t *trie) { GList *succ; command_trie_t *leaf = NULL; if (trie) { succ = g_list_first (trie->next); if (succ && succ->next == NULL && !command_trie_valid_match (trie)) { /* Not a matching node, a single successor: recurse */ leaf = command_trie_find_leaf ((command_trie_t *) succ->data); } else if (!succ && command_trie_valid_match (trie)) { leaf = trie; } } return leaf; }
false
false
false
false
false
0
nsend(nhead) struct nmsg *nhead; /* network message header */ { int f_nreel; /* NREEL status flag */ int4 length; /* remaining length */ int4 save_flags; /* saved flags */ int4 save_length; /* saved length */ int4 save_data0; /* saved data[0] */ char *save_msg; /* saved message ptr */ /* * Get the routing information. */ if ((nhead->nh_flags & NOBUF) || ((nhead->nh_node != LOCAL) && (nhead->nh_node != getnodeid()))) { if (getroute(nhead)) return(LAMERROR); } else { nhead->nh_dl_event = EVBUFFERD; } /* * If this send is for a multireel, nh_data[6] contains the packet number. */ f_nreel = FALSE; if (nhead->nh_flags & NREEL) { f_nreel = TRUE; nhead->nh_data[6] = 0; } /* * multi-packet message */ if (nhead->nh_length > MAXNMSGLEN) { save_flags = nhead->nh_flags; save_msg = nhead->nh_msg; save_length = nhead->nh_length; save_data0 = nhead->nh_data[0]; length = save_length; nhead->nh_length = MAXNMSGLEN; nhead->nh_flags |= NMORE; nhead->nh_data[0] = save_length; /* * Send first packet. */ if (dsend(nhead)) { nhead->nh_length = save_length; nhead->nh_flags = save_flags; return(LAMERROR); } nhead->nh_flags &= ~KTRY; nhead->nh_flags |= N2ND; nhead->nh_data[0] = save_data0; length -= MAXNMSGLEN; nhead->nh_msg += MAXNMSGLEN; if (f_nreel) { nhead->nh_data[6]++; } /* * Send the middle packets. */ while (length > MAXNMSGLEN) { if (dsend(nhead)) { nhead->nh_flags = save_flags; nhead->nh_length = save_length; nhead->nh_msg = save_msg; return(LAMERROR); } length -= MAXNMSGLEN; nhead->nh_msg += MAXNMSGLEN; if (f_nreel) { nhead->nh_data[6]++; } } nhead->nh_length = length; nhead->nh_flags &= ~NMORE; /* * Send the last packet. */ if (dsend(nhead)) { nhead->nh_flags = save_flags; nhead->nh_length = save_length; nhead->nh_msg = save_msg; return(LAMERROR); } nhead->nh_msg = save_msg; nhead->nh_length = save_length; nhead->nh_flags = save_flags; } else { if (dsend(nhead)) return(LAMERROR); } return(0); }
false
false
false
false
false
0
Parse(const String &query_string) { error = ""; Token().Set(query_string); Query *result = ParseExpression(); if(result && !Token().IsEnd()) { Expected("end of query"); // delete result; result = 0; } return result; }
false
false
false
false
false
0
ipa_tm_insert_gettmclone_call (struct cgraph_node *node, struct tm_region *region, gimple_stmt_iterator *gsi, gimple stmt) { tree gettm_fn, ret, old_fn, callfn; gimple g, g2; bool safe; old_fn = gimple_call_fn (stmt); if (TREE_CODE (old_fn) == ADDR_EXPR) { tree fndecl = TREE_OPERAND (old_fn, 0); tree clone = get_tm_clone_pair (fndecl); /* By transforming the call into a TM_GETTMCLONE, we are technically taking the address of the original function and its clone. Explain this so inlining will know this function is needed. */ cgraph_mark_address_taken_node (cgraph_get_node (fndecl)); if (clone) cgraph_mark_address_taken_node (cgraph_get_node (clone)); } safe = is_tm_safe (TREE_TYPE (old_fn)); gettm_fn = builtin_decl_explicit (safe ? BUILT_IN_TM_GETTMCLONE_SAFE : BUILT_IN_TM_GETTMCLONE_IRR); ret = create_tmp_var (ptr_type_node, NULL); if (!safe) transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); /* Discard OBJ_TYPE_REF, since we weren't able to fold it. */ if (TREE_CODE (old_fn) == OBJ_TYPE_REF) old_fn = OBJ_TYPE_REF_EXPR (old_fn); g = gimple_build_call (gettm_fn, 1, old_fn); ret = make_ssa_name (ret, g); gimple_call_set_lhs (g, ret); gsi_insert_before (gsi, g, GSI_SAME_STMT); cgraph_create_edge (node, cgraph_get_create_node (gettm_fn), g, 0, compute_call_stmt_bb_frequency (node->symbol.decl, gimple_bb(g))); /* Cast return value from tm_gettmclone* into appropriate function pointer. */ callfn = create_tmp_var (TREE_TYPE (old_fn), NULL); g2 = gimple_build_assign (callfn, fold_build1 (NOP_EXPR, TREE_TYPE (callfn), ret)); callfn = make_ssa_name (callfn, g2); gimple_assign_set_lhs (g2, callfn); gsi_insert_before (gsi, g2, GSI_SAME_STMT); /* ??? This is a hack to preserve the NOTHROW bit on the call, which we would have derived from the decl. Failure to save this bit means we might have to split the basic block. */ if (gimple_call_nothrow_p (stmt)) gimple_call_set_nothrow (stmt, true); gimple_call_set_fn (stmt, callfn); /* Discarding OBJ_TYPE_REF above may produce incompatible LHS and RHS for a call statement. Fix it. */ { tree lhs = gimple_call_lhs (stmt); tree rettype = TREE_TYPE (gimple_call_fntype (stmt)); if (lhs && !useless_type_conversion_p (TREE_TYPE (lhs), rettype)) { tree temp; temp = create_tmp_reg (rettype, 0); gimple_call_set_lhs (stmt, temp); g2 = gimple_build_assign (lhs, fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (lhs), temp)); gsi_insert_after (gsi, g2, GSI_SAME_STMT); } } update_stmt (stmt); return true; }
false
false
false
false
false
0
pixcompGetDimensions(PIXC *pixc, l_int32 *pw, l_int32 *ph, l_int32 *pd) { PROCNAME("pixcompGetDimensions"); if (!pixc) return ERROR_INT("pixc not defined", procName, 1); if (pw) *pw = pixc->w; if (ph) *ph = pixc->h; if (pd) *pd = pixc->d; }
false
false
false
false
false
0
validate_recv_mgnt_frame(struct rtw_adapter *padapter, struct recv_frame *precv_frame) { struct sta_info *psta; struct sk_buff *skb; struct ieee80211_hdr *hdr; /* struct mlme_priv *pmlmepriv = &adapter->mlmepriv; */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, "+validate_recv_mgnt_frame\n"); precv_frame = recvframe_chk_defrag23a(padapter, precv_frame); if (precv_frame == NULL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, "%s: fragment packet\n", __func__); return _SUCCESS; } skb = precv_frame->pkt; hdr = (struct ieee80211_hdr *) skb->data; /* for rx pkt statistics */ psta = rtw_get_stainfo23a(&padapter->stapriv, hdr->addr2); if (psta) { psta->sta_stats.rx_mgnt_pkts++; if (ieee80211_is_beacon(hdr->frame_control)) psta->sta_stats.rx_beacon_pkts++; else if (ieee80211_is_probe_req(hdr->frame_control)) psta->sta_stats.rx_probereq_pkts++; else if (ieee80211_is_probe_resp(hdr->frame_control)) { if (ether_addr_equal(padapter->eeprompriv.mac_addr, hdr->addr1)) psta->sta_stats.rx_probersp_pkts++; else if (is_broadcast_ether_addr(hdr->addr1) || is_multicast_ether_addr(hdr->addr1)) psta->sta_stats.rx_probersp_bm_pkts++; else psta->sta_stats.rx_probersp_uo_pkts++; } } mgt_dispatcher23a(padapter, precv_frame); return _SUCCESS; }
false
false
false
false
false
0
label_changed_cb (glLabel *label, glWindow *window) { gl_debug (DEBUG_WINDOW, "START"); g_return_if_fail (label && GL_IS_LABEL (label)); g_return_if_fail (window && GL_IS_WINDOW (window)); gl_ui_update_undo_redo_verbs (window->ui, label); gl_debug (DEBUG_WINDOW, "END"); }
false
false
false
false
false
0
method_e(Interp &interp, const RefPtr<Expr> &arg, const RefPtr<Obj> &/*data*/) { Val tmp_prev=interp.top_scope()->self(); if(!tmp_prev.obj()->is_arg_name()) { return interp.nil_val(); } Val tmp_rcvr=tmp_prev.obj()->rcvr(); Method new_method; RefPtr<Obj> new_data; if(tmp_rcvr.obj()->rcvr().obj().get()!=0) { new_method=Method(tmp_prev.obj()->arg_name(), arg, true); do { new_data=interp.arg_obj()->clone(); new_data->def_method("a", new_method); new_data->set_arg_name(tmp_rcvr.obj()->arg_name()); new_method=Method(arg_a, new_data); tmp_prev=tmp_rcvr; tmp_rcvr=tmp_prev.obj()->rcvr(); } while(tmp_rcvr.obj()->rcvr().obj().get()!=0); } else { new_method=Method(tmp_prev.obj()->arg_name(), arg); } Val new_rcvr(tmp_rcvr.i(), tmp_rcvr.obj()->clone()); new_rcvr.obj()->def_method(tmp_prev.obj()->method_name(), new_method); return new_rcvr; }
false
false
false
false
false
0
cfapi_map_update_position(int *type, ...) { va_list args; mapstruct *map; int x, y; va_start(args, type); map = va_arg(args, mapstruct *); x = va_arg(args, int); y = va_arg(args, int); update_position(map, x, y); va_end(args); *type = CFAPI_NONE; }
false
false
false
false
false
0
getCard(char chcard) { if(tolower(chcard) == 'a') return eCARD_A; else if(tolower(chcard) == 'k') return eCARD_K; else if(tolower(chcard) == 'q') return eCARD_Q; else if(tolower(chcard) == 'j') return eCARD_J; else if(tolower(chcard) == 't') return eCARD_10; else if(isdigit(chcard)) { if(((int)chcard >= (int)'2') && ((int)chcard <= (int)'9')) return (enum eCard)(14 - (int)chcard + (int)'0'); } return eCARD_NONE; }
false
false
false
false
false
0
appendSlash(std::string &path) { // first check boundary size_t len = path.length(); if ((len == 0) || (path[len - 1] != SEPARATOR_CHAR && path[len - 1] != OTHER_SEPARATOR_CHAR)) { path += SEPARATOR_STRING; } }
false
false
false
false
false
0
adnp_irq(int irq, void *data) { struct adnp *adnp = data; unsigned int num_regs, i; num_regs = 1 << adnp->reg_shift; for (i = 0; i < num_regs; i++) { unsigned int base = i << adnp->reg_shift, bit; u8 changed, level, isr, ier; unsigned long pending; int err; mutex_lock(&adnp->i2c_lock); err = adnp_read(adnp, GPIO_PLR(adnp) + i, &level); if (err < 0) { mutex_unlock(&adnp->i2c_lock); continue; } err = adnp_read(adnp, GPIO_ISR(adnp) + i, &isr); if (err < 0) { mutex_unlock(&adnp->i2c_lock); continue; } err = adnp_read(adnp, GPIO_IER(adnp) + i, &ier); if (err < 0) { mutex_unlock(&adnp->i2c_lock); continue; } mutex_unlock(&adnp->i2c_lock); /* determine pins that changed levels */ changed = level ^ adnp->irq_level[i]; /* compute edge-triggered interrupts */ pending = changed & ((adnp->irq_fall[i] & ~level) | (adnp->irq_rise[i] & level)); /* add in level-triggered interrupts */ pending |= (adnp->irq_high[i] & level) | (adnp->irq_low[i] & ~level); /* mask out non-pending and disabled interrupts */ pending &= isr & ier; for_each_set_bit(bit, &pending, 8) { unsigned int child_irq; child_irq = irq_find_mapping(adnp->gpio.irqdomain, base + bit); handle_nested_irq(child_irq); } } return IRQ_HANDLED; }
false
false
false
false
false
0
new_position(x1, y1, bearing, velocity) double x1, y1, bearing, velocity; { double delta_x, delta_y; double radians; /* * Object two in which quadrant compared to object one? 0 x = opp, y = * ajd + 0 degrees 1 x = adj, y = opp + 90 degrees 2 x = opp, y = ajd * + 180 degrees 3 x = adj, y = opp + 270 degrees */ /* * sin finds opp, cos finds adj */ if (bearing < 91) { radians = bearing * 2.0 * M_PI / 360.; delta_x = velocity * sin(radians); delta_y = velocity * cos(radians); new_x = x1 + delta_x; new_y = y1 + delta_y; } else if (bearing < 181) { bearing -= 90; radians = bearing * 2.0 * M_PI / 360.; delta_y = velocity * sin(radians); delta_x = velocity * cos(radians); new_x = x1 + delta_x; new_y = y1 - delta_y; } else if (bearing < 271) { bearing -= 180; radians = bearing * 2.0 * M_PI / 360.; delta_x = velocity * sin(radians); delta_y = velocity * cos(radians); new_x = x1 - delta_x; new_y = y1 - delta_y; } else { bearing -= 270; radians = bearing * 2.0 * M_PI / 360.; delta_y = velocity * sin(radians); delta_x = velocity * cos(radians); new_x = x1 - delta_x; new_y = y1 + delta_y; } }
false
false
false
false
false
0
moving_vof_cell_coarse_fine (FttCell * cell, GfsVariable * v) { FttCell * parent = ftt_cell_parent (cell); GfsVariableTracerVOF * t = GFS_VARIABLE_TRACER_VOF (v); gdouble f = GFS_VALUE (parent, v); FttComponent c; guint i; if (GFS_IS_FULL (f)) { GFS_VALUE (cell, v) = f; for (c = 1; c < FTT_DIMENSION; c++) GFS_VALUE (cell, t->m[c]) = 0.; GFS_VALUE (cell, t->m[0]) = 1.; GFS_VALUE (cell, t->alpha) = f; } else { gdouble alpha = GFS_VALUE (parent, t->alpha); FttVector m; for (i = 0; i < FTT_DIMENSION; i++) (&m.x)[i] = GFS_VALUE (parent, t->m[i]); gdouble alpha1 = alpha; FttVector p; ftt_cell_relative_pos (cell, &p); for (c = 0; c < FTT_DIMENSION; c++) { alpha1 -= (&m.x)[c]*(0.25 + (&p.x)[c]); GFS_VALUE (cell, t->m[c]) = (&m.x)[c]; } GFS_VALUE (cell, v) = gfs_plane_volume (&m, 2.*alpha1); GFS_VALUE (cell, t->alpha) = 2.*alpha1; } }
false
false
false
false
false
0
max1363_alloc_scan_masks(struct iio_dev *indio_dev) { struct max1363_state *st = iio_priv(indio_dev); unsigned long *masks; int i; masks = devm_kzalloc(&indio_dev->dev, BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) * (st->chip_info->num_modes + 1), GFP_KERNEL); if (!masks) return -ENOMEM; for (i = 0; i < st->chip_info->num_modes; i++) bitmap_copy(masks + BITS_TO_LONGS(MAX1363_MAX_CHANNELS)*i, max1363_mode_table[st->chip_info->mode_list[i]] .modemask, MAX1363_MAX_CHANNELS); indio_dev->available_scan_masks = masks; return 0; }
false
false
false
false
false
0
PrepareForTupleInvalidation(Relation relation, HeapTuple tuple) { Oid tupleRelId; Oid databaseId; Oid relationId; /* Do nothing during bootstrap */ if (IsBootstrapProcessingMode()) return; /* * We only need to worry about invalidation for tuples that are in system * relations; user-relation tuples are never in catcaches and can't affect * the relcache either. */ if (!IsSystemRelation(relation)) return; /* * TOAST tuples can likewise be ignored here. Note that TOAST tables are * considered system relations so they are not filtered by the above test. */ if (IsToastRelation(relation)) return; /* * First let the catcache do its thing */ PrepareToInvalidateCacheTuple(relation, tuple, RegisterCatcacheInvalidation); /* * Now, is this tuple one of the primary definers of a relcache entry? */ tupleRelId = RelationGetRelid(relation); if (tupleRelId == RelationRelationId) { Form_pg_class classtup = (Form_pg_class) GETSTRUCT(tuple); relationId = HeapTupleGetOid(tuple); if (classtup->relisshared) databaseId = InvalidOid; else databaseId = MyDatabaseId; } else if (tupleRelId == AttributeRelationId) { Form_pg_attribute atttup = (Form_pg_attribute) GETSTRUCT(tuple); relationId = atttup->attrelid; /* * KLUGE ALERT: we always send the relcache event with MyDatabaseId, * even if the rel in question is shared (which we can't easily tell). * This essentially means that only backends in this same database * will react to the relcache flush request. This is in fact * appropriate, since only those backends could see our pg_attribute * change anyway. It looks a bit ugly though. (In practice, shared * relations can't have schema changes after bootstrap, so we should * never come here for a shared rel anyway.) */ databaseId = MyDatabaseId; } else if (tupleRelId == IndexRelationId) { Form_pg_index indextup = (Form_pg_index) GETSTRUCT(tuple); /* * When a pg_index row is updated, we should send out a relcache inval * for the index relation. As above, we don't know the shared status * of the index, but in practice it doesn't matter since indexes of * shared catalogs can't have such updates. */ relationId = indextup->indexrelid; databaseId = MyDatabaseId; } else return; /* * Yes. We need to register a relcache invalidation event. */ RegisterRelcacheInvalidation(databaseId, relationId); }
false
false
false
false
false
0
process_idle_times (ThreadPool *tp, gint64 t) { gint64 ticks; gint64 avg; gboolean compute_avg; gint new_threads; gint64 per1; if (tp->ignore_times || t <= 0) return; compute_avg = FALSE; ticks = mono_100ns_ticks (); t = ticks - t; SPIN_LOCK (tp->sp_lock); if (tp->ignore_times) { SPIN_UNLOCK (tp->sp_lock); return; } tp->time_sum += t; tp->n_sum++; if (tp->last_check == 0) tp->last_check = ticks; else if (tp->last_check > 0 && (ticks - tp->last_check) > 5000000) { tp->ignore_times = 1; compute_avg = TRUE; } SPIN_UNLOCK (tp->sp_lock); if (!compute_avg) return; //printf ("Items: %d Time elapsed: %.3fs\n", tp->n_sum, (ticks - tp->last_check) / 10000.0); tp->last_check = ticks; new_threads = 0; avg = tp->time_sum / tp->n_sum; if (tp->averages [1] == 0) { tp->averages [1] = avg; } else { per1 = ((100 * (ABS (avg - tp->averages [1]))) / tp->averages [1]); if (per1 > 5) { if (avg > tp->averages [1]) { if (tp->averages [1] < tp->averages [0]) { new_threads = -1; } else { new_threads = 1; } } else if (avg < tp->averages [1] && tp->averages [1] < tp->averages [0]) { new_threads = 1; } } else { int min, n; min = tp->min_threads; n = tp->nthreads; if ((n - min) < min && tp->busy_threads == n) new_threads = 1; } /* if (new_threads != 0) { printf ("n: %d per1: %lld avg=%lld avg1=%lld avg0=%lld\n", new_threads, per1, avg, tp->averages [1], tp->averages [0]); } */ } tp->time_sum = 0; tp->n_sum = 0; tp->averages [0] = tp->averages [1]; tp->averages [1] = avg; tp->ignore_times = 0; if (new_threads == -1) { if (tp->destroy_thread == 0 && InterlockedCompareExchange (&tp->destroy_thread, 1, 0) == 0) pulse_on_new_job (tp); } }
false
false
false
false
false
0
panel_widget_force_grab_focus (GtkWidget *widget) { gboolean can_focus = gtk_widget_get_can_focus (widget); /* * This follows what gtk_socket_claim_focus() does */ if (!can_focus) gtk_widget_set_can_focus (widget, TRUE); gtk_widget_grab_focus (widget); if (!can_focus) gtk_widget_set_can_focus (widget, FALSE); }
false
false
false
false
false
0
vlog_verbose(const char *prefix, const char *pattern, va_list ap) { if ( VERBOSITY == FALSE ) return; first_line_verbose(); fprintf(stdout, "%-*s", INDENT_LEVEL,"" ); if(prefix) { fputs(prefix, stdout); } vfprintf(stdout, pattern, ap); fflush(stdout); va_end(ap); GLOBAL_PRINT_COUNT++; if((*pattern==0) || (pattern[strlen(pattern)-1]!='\n')) { HANGING_OUTPUT=1; } else { HANGING_OUTPUT=0; } }
false
false
false
false
true
1
engine_search (Pos *pos/*, int player*/) { int tag; byte *move; engine_stop_search = FALSE; if (game_search) game_search (pos, &move); else if (game_single_player) move = NULL; else { tag = g_timeout_add (2 * time_per_move, engine_timeout_cb, NULL); move = ab_dfid (pos, pos->player); g_source_remove (tag); } return move; }
false
false
false
false
false
0
rl_key_action(c, flag) int c; char flag; { KEYMAP *kp; int size; if (ISMETA(c)) { kp = MetaMap; size = METAMAPSIZE; } else { kp = Map; size = MAPSIZE; } for ( ; --size >= 0; kp++) if (kp->Key == c) { kp->Active = c ? 1 : 0; return 1; } return -1; }
false
false
false
false
false
0
is_float(char *arg ) { char *s; for (s=arg; *s; s++) { if (*s != '.' && (*s < '0' || *s > '9')) return 0; } return 1; }
false
false
false
false
false
0
xfs_error_report( const char *tag, int level, struct xfs_mount *mp, const char *filename, int linenum, void *ra) { if (level <= xfs_error_level) { xfs_alert_tag(mp, XFS_PTAG_ERROR_REPORT, "Internal error %s at line %d of file %s. Caller %pS", tag, linenum, filename, ra); xfs_stack_trace(); } }
false
false
false
false
false
0
Perl_pad_compname_type(pTHX_ const PADOFFSET po) { dVAR; SV* const * const av = av_fetch(PL_comppad_name, po, FALSE); if ( SvPAD_TYPED(*av) ) { return SvSTASH(*av); } return NULL; }
false
false
false
false
false
0
gnttab_free_auto_xlat_frames(void) { if (!xen_auto_xlat_grant_frames.count) return; kfree(xen_auto_xlat_grant_frames.pfn); xen_unmap(xen_auto_xlat_grant_frames.vaddr); xen_auto_xlat_grant_frames.pfn = NULL; xen_auto_xlat_grant_frames.count = 0; xen_auto_xlat_grant_frames.vaddr = NULL; }
false
false
false
false
false
0
mimetype_option_menu(const char *zMimetype){ unsigned i; cgi_printf("Markup style: <select name=\"mimetype\" size=\"1\">\n"); for(i=0; i<sizeof(azStyles)/sizeof(azStyles[0]); i+=2){ if( fossil_strcmp(zMimetype,azStyles[i])==0 ){ cgi_printf("<option value=\"%s\" selected>%s</option>\n",(azStyles[i]),(azStyles[i+1])); }else{ cgi_printf("<option value=\"%s\">%s</option>\n",(azStyles[i]),(azStyles[i+1])); } } cgi_printf("</select>\n"); }
false
false
false
false
false
0
linuxOvercommitMemoryValue(void) { FILE *fp = fopen("/proc/sys/vm/overcommit_memory","r"); char buf[64]; if (!fp) return -1; if (fgets(buf,64,fp) == NULL) { fclose(fp); return -1; } fclose(fp); return atoi(buf); }
true
true
true
false
true
1
I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) { uint16_t tmpreg = 0, freqrange = 0; uint16_t result = 0x04; uint32_t pclk1 = 8000000; RCC_ClocksTypeDef rcc_clocks; /* Check the parameters */ assert_param(IS_I2C_ALL_PERIPH(I2Cx)); assert_param(IS_I2C_CLOCK_SPEED(I2C_InitStruct->I2C_ClockSpeed)); assert_param(IS_I2C_MODE(I2C_InitStruct->I2C_Mode)); assert_param(IS_I2C_DUTY_CYCLE(I2C_InitStruct->I2C_DutyCycle)); assert_param(IS_I2C_OWN_ADDRESS1(I2C_InitStruct->I2C_OwnAddress1)); assert_param(IS_I2C_ACK_STATE(I2C_InitStruct->I2C_Ack)); assert_param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AcknowledgedAddress)); /*---------------------------- I2Cx CR2 Configuration ------------------------*/ /* Get the I2Cx CR2 value */ tmpreg = I2Cx->CR2; /* Clear frequency FREQ[5:0] bits */ tmpreg &= (uint16_t)~((uint16_t)I2C_CR2_FREQ); /* Get pclk1 frequency value */ RCC_GetClocksFreq(&rcc_clocks); pclk1 = rcc_clocks.PCLK1_Frequency; /* Set frequency bits depending on pclk1 value */ freqrange = (uint16_t)(pclk1 / 1000000); tmpreg |= freqrange; /* Write to I2Cx CR2 */ I2Cx->CR2 = tmpreg; /*---------------------------- I2Cx CCR Configuration ------------------------*/ /* Disable the selected I2C peripheral to configure TRISE */ I2Cx->CR1 &= (uint16_t)~((uint16_t)I2C_CR1_PE); /* Reset tmpreg value */ /* Clear F/S, DUTY and CCR[11:0] bits */ tmpreg = 0; /* Configure speed in standard mode */ if (I2C_InitStruct->I2C_ClockSpeed <= 100000) { /* Standard mode speed calculate */ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed << 1)); /* Test if CCR value is under 0x4*/ if (result < 0x04) { /* Set minimum allowed value */ result = 0x04; } /* Set speed value for standard mode */ tmpreg |= result; /* Set Maximum Rise Time for standard mode */ I2Cx->TRISE = freqrange + 1; } /* Configure speed in fast mode */ /* To use the I2C at 400 KHz (in fast mode), the PCLK1 frequency (I2C peripheral input clock) must be a multiple of 10 MHz */ else /*(I2C_InitStruct->I2C_ClockSpeed <= 400000)*/ { if (I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_2) { /* Fast mode speed calculate: Tlow/Thigh = 2 */ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 3)); } else /*I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_16_9*/ { /* Fast mode speed calculate: Tlow/Thigh = 16/9 */ result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 25)); /* Set DUTY bit */ result |= I2C_DutyCycle_16_9; } /* Test if CCR value is under 0x1*/ if ((result & I2C_CCR_CCR) == 0) { /* Set minimum allowed value */ result |= (uint16_t)0x0001; } /* Set speed value and set F/S bit for fast mode */ tmpreg |= (uint16_t)(result | I2C_CCR_FS); /* Set Maximum Rise Time for fast mode */ I2Cx->TRISE = (uint16_t)(((freqrange * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1); } /* Write to I2Cx CCR */ I2Cx->CCR = tmpreg; /* Enable the selected I2C peripheral */ I2Cx->CR1 |= I2C_CR1_PE; /*---------------------------- I2Cx CR1 Configuration ------------------------*/ /* Get the I2Cx CR1 value */ tmpreg = I2Cx->CR1; /* Clear ACK, SMBTYPE and SMBUS bits */ tmpreg &= CR1_CLEAR_MASK; /* Configure I2Cx: mode and acknowledgement */ /* Set SMBTYPE and SMBUS bits according to I2C_Mode value */ /* Set ACK bit according to I2C_Ack value */ tmpreg |= (uint16_t)((uint32_t)I2C_InitStruct->I2C_Mode | I2C_InitStruct->I2C_Ack); /* Write to I2Cx CR1 */ I2Cx->CR1 = tmpreg; /*---------------------------- I2Cx OAR1 Configuration -----------------------*/ /* Set I2Cx Own Address1 and acknowledged address */ I2Cx->OAR1 = (I2C_InitStruct->I2C_AcknowledgedAddress | I2C_InitStruct->I2C_OwnAddress1); }
false
false
false
false
false
0
theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet) { GstVideoEncoder *benc; GstFlowReturn ret; GstVideoCodecFrame *frame; benc = GST_VIDEO_ENCODER (enc); frame = gst_video_encoder_get_oldest_frame (benc); if (gst_video_encoder_allocate_output_frame (benc, frame, packet->bytes) != GST_FLOW_OK) { GST_WARNING_OBJECT (enc, "Could not allocate buffer"); gst_video_codec_frame_unref (frame); ret = GST_FLOW_ERROR; goto done; } if (packet->bytes > 0) gst_buffer_fill (frame->output_buffer, 0, packet->packet, packet->bytes); /* the second most significant bit of the first data byte is cleared * for keyframes */ if (packet->bytes > 0 && (packet->packet[0] & 0x40) == 0) { GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (frame); } else { GST_VIDEO_CODEC_FRAME_UNSET_SYNC_POINT (frame); } enc->packetno++; ret = gst_video_encoder_finish_frame (benc, frame); done: return ret; }
false
false
false
false
false
0
getScaledParametersPS(BOX *box, l_int32 wpix, l_int32 hpix, l_int32 res, l_float32 scale, l_float32 *pxpt, l_float32 *pypt, l_float32 *pwpt, l_float32 *phpt) { l_float32 winch, hinch, xinch, yinch, fres; PROCNAME("getScaledParametersPS"); if (res == 0) res = DEFAULT_PRINTER_RES; fres = (l_float32)res; /* Allow the PS interpreter to scale the resolution */ if (scale == 0.0) scale = 1.0; if (scale != 1.0) { fres = (l_float32)res / scale; res = (l_int32)fres; } /* Limit valid resolution interval */ if (res < MIN_RES || res > MAX_RES) { L_WARNING_INT("res %d out of bounds; using default res; no scaling", procName, res); res = DEFAULT_PRINTER_RES; fres = (l_float32)res; } if (!box) { /* center on page */ winch = (l_float32)wpix / fres; hinch = (l_float32)hpix / fres; xinch = (8.5 - winch) / 2.; yinch = (11.0 - hinch) / 2.; } else { if (box->w == 0) winch = (l_float32)wpix / fres; else winch = (l_float32)box->w / 1000.; if (box->h == 0) hinch = (l_float32)hpix / fres; else hinch = (l_float32)box->h / 1000.; xinch = (l_float32)box->x / 1000.; yinch = (l_float32)box->y / 1000.; } if (xinch < 0) L_WARNING("left edge < 0.0 inch", procName); if (xinch + winch > 8.5) L_WARNING("right edge > 8.5 inch", procName); if (yinch < 0.0) L_WARNING("bottom edge < 0.0 inch", procName); if (yinch + hinch > 11.0) L_WARNING("top edge > 11.0 inch", procName); *pwpt = 72. * winch; *phpt = 72. * hinch; *pxpt = 72. * xinch; *pypt = 72. * yinch; return; }
false
false
false
false
false
0
getfreeMinBytes(Stream_t *Dir, mt_size_t size) { Stream_t *Stream = GetFs(Dir); DeclareThis(Fs_t); size_t size2; size2 = size / (This->sector_size * This->cluster_size); if(size % (This->sector_size * This->cluster_size)) size2++; return getfreeMinClusters(Dir, size2); }
false
false
false
false
false
0
smgrclose(SMgrRelation reln) { SMgrRelation *owner; if (!(*(smgrsw[reln->smgr_which].smgr_close)) (reln)) ereport(ERROR, (errcode_for_file_access(), errmsg("could not close relation %u/%u/%u: %m", reln->smgr_rnode.spcNode, reln->smgr_rnode.dbNode, reln->smgr_rnode.relNode))); owner = reln->smgr_owner; if (hash_search(SMgrRelationHash, (void *) &(reln->smgr_rnode), HASH_REMOVE, NULL) == NULL) elog(ERROR, "SMgrRelation hashtable corrupted"); /* * Unhook the owner pointer, if any. We do this last since in the remote * possibility of failure above, the SMgrRelation object will still exist. */ if (owner) *owner = NULL; }
false
false
false
false
false
0
fifo_has_reader(const char *path, int prepare) { int fd; /* ** Check that fifo exists and is a fifo. ** If not, there can be no reader process. */ switch (fifo_exists(path, prepare)) { case 0: return 0; case -1: return -1; } /* ** Open the fifo for non-blocking write. ** If there is no reader process, open() ** will fail with errno == ENXIO. */ if ((fd = open(path, O_WRONLY | O_NONBLOCK)) == -1) return (errno == ENXIO) ? 0 : -1; if (close(fd) == -1) return -1; return 1; }
false
false
false
false
false
0
GetUuidFromPath(std::string path) { std::stringstream query; query << "SELECT uuid FROM resource_uuid WHERE path='" << path << "'"; this->Database->ExecuteQuery(query.str().c_str()); std::string uuid = this->Database->GetNextRow() ? this->Database->GetValueAsString(0) : ""; while(this->Database->GetNextRow()); return uuid; }
false
false
false
false
false
0
__chk_spec_delay(struct expr_t *ndp, char *emsg) { /* first must be expr. of numbers and parameters only */ if (!__chk_paramexpr(ndp, 0)) { __sgferr(898, "%s must be specify constant expression", emsg); return; } /* then must fold */ fold_subexpr(ndp); /* finally check to make sure number delay - prep code scales */ __chk_numdelay(ndp, emsg); ndp->ibase = BDEC; }
false
false
false
false
false
0
quote_string(const string& str) { string res; const char* i = str.c_str(); while (*i) { char c = *i++; if (c == ' ' || c == '(' || c == ')' || c =='\'') res += '\\'; res += c; } return res; }
false
false
false
false
false
0
isLinearized() { Parser *parser; Object obj1, obj2, obj3, obj4, obj5; GBool lin; lin = gFalse; obj1.initNull(); parser = new Parser(xref, new Lexer(xref, str->makeSubStream(str->getStart(), gFalse, 0, &obj1)), gTrue); parser->getObj(&obj1); parser->getObj(&obj2); parser->getObj(&obj3); parser->getObj(&obj4); if (obj1.isInt() && obj2.isInt() && obj3.isCmd("obj") && obj4.isDict()) { obj4.dictLookup("Linearized", &obj5); if (obj5.isNum() && obj5.getNum() > 0) { lin = gTrue; } obj5.free(); } obj4.free(); obj3.free(); obj2.free(); obj1.free(); delete parser; return lin; }
false
false
false
false
false
0
get_nr_dirty_inodes(void) { /* not actually dirty inodes, but a wild approximation */ long nr_dirty = get_nr_inodes() - get_nr_inodes_unused(); return nr_dirty > 0 ? nr_dirty : 0; }
false
false
false
false
false
0
channel_elements_from_project() { trace(("rss_feed::channel_elements_from_project()\n{\n")); title = rss_feed_attribute(project, filename, rss_feed_title); if (title.empty() && cp) { title = nstring::format ( "Changes in state %s", cstate_state_ename(cp->cstate_data->state) ); } nstring projname(project_name_get(project)); title = "Project " + projname + ", " + title; // // "Phrase or sentence describing the channel." // // We will set it from the project attributes every time. // That way it can be changed. // description = rss_feed_attribute(project, filename, rss_feed_description); if (description.empty() && cp) { cstate_ty *cstate_data = cp->cstate_get(); description = nstring::format ( "Feed of changes in state %s", cstate_state_ename(cstate_data->state) ); } link = rss_script_name_placeholder; link += "/"; link += nstring(project_name_get(project)); link += "/?menu"; language = rss_feed_attribute(project, filename, rss_feed_language); if (language.empty()) language = "en-US"; trace(("}\n")); }
false
false
false
false
false
0
tty_aux_input(vtty_t *vtty) { struct ns16552_data *d = vtty->priv_data; if (d->channel[1].ier & IER_ERXRDY) vm_set_irq(d->vm,d->irq); }
false
false
false
false
false
0
qstrunchar(char *str, char head, char tail) { if (str == NULL) return NULL; int len = strlen(str); if (len >= 2 && str[0] == head && str[len - 1] == tail) { memmove(str, str + 1, len - 2); str[len - 2] = '\0'; } else { return NULL; } return str; }
false
false
false
false
false
0
set_read_p(bool state) { if (_var) { _var->set_read_p(state); } BaseType::set_read_p(state); }
false
false
false
false
false
0
idio_16_init(void) { int err; idio_16_device = platform_device_alloc(idio_16_driver.driver.name, -1); if (!idio_16_device) return -ENOMEM; err = platform_device_add(idio_16_device); if (err) goto err_platform_device; err = platform_driver_probe(&idio_16_driver, idio_16_probe); if (err) goto err_platform_driver; return 0; err_platform_driver: platform_device_del(idio_16_device); err_platform_device: platform_device_put(idio_16_device); return err; }
false
false
false
false
false
0
checkNotify() { if(m_loading) return; for (QHashIterator<CachedObjectClient*,CachedObjectClient*> it( m_clients ); it.hasNext();) it.next().value()->notifyFinished(this); }
false
false
false
false
false
0
vgem_gem_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { struct drm_gem_object *gem_object; uint64_t size; uint64_t pitch = args->width * DIV_ROUND_UP(args->bpp, 8); size = args->height * pitch; if (size == 0) return -EINVAL; gem_object = vgem_gem_create(dev, file, &args->handle, size); if (IS_ERR(gem_object)) { DRM_DEBUG_DRIVER("object creation failed\n"); return PTR_ERR(gem_object); } args->size = gem_object->size; args->pitch = pitch; DRM_DEBUG_DRIVER("Created object of size %lld\n", size); return 0; }
false
false
false
false
false
0
item_window_empty(SBAR_ITEM_REC *item, int get_size_only) { WINDOW_REC *window; window = active_win; if (item->bar->parent_window != NULL) window = item->bar->parent_window->active; if (window != NULL && window->active == NULL) { statusbar_item_default_handler(item, get_size_only, NULL, "", TRUE); } else if (get_size_only) { item->min_size = item->max_size = 0; } }
false
false
false
false
false
0
emf_outputStatistics(ostream& out) { short is = ESF_INDENT_SIZE; const ModelStatistics* ms = model->getModelStatistics(); emf_outputSectionStart(out); // Header LibFront::output_string(out, is, 0, "Statistics"); LibFront::output_scalar(out, is, 1, "Nof Bodies", NULL, ms->nofBodies); LibFront::output_scalar(out, is, 1, "Nof Loops", NULL, ms->nofElementLoops); // Calc nof body_elements to be output int nof_elements = 0; int index = 0; while (true) { BodyElement* be = model->getBoundary(index++); if (be==NULL) break; //-Check status beStatus be_stat = be->getStatus(); if ( !(be_stat & (BE_DEVIDED | BE_SWAPPED)) ) nof_elements++; } LibFront::output_scalar(out, is, 1, "Nof Elements", NULL, nof_elements); LibFront::output_scalar(out, is, 1, "Nof Outer Boundaries", NULL, ms->nofOuterBoundaries); LibFront::output_scalar(out, is, 1, "Nof Inner Boundaries", NULL, ms->nofInnerBoundaries); LibFront::output_scalar(out, is, 1, "Nof Vertices", NULL, ms->nofVertices); // Calc max loop size int max_loop_size = 0; index = 0; while (true) { BodyElementLoop* bel = model->getBodyElementLoop(index++); if (bel==NULL) break; int size = bel->getNofElements(); if (size > max_loop_size) max_loop_size = size; } LibFront::output_scalar(out, is, 1, "Max Loop Count", NULL, max_loop_size); emf_outputSectionEnd(out); return out; }
false
false
false
false
false
0
camel_store_get_inbox_folder (CamelStore *store, gint io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { CamelStoreClass *class; g_return_if_fail (CAMEL_IS_STORE (store)); class = CAMEL_STORE_GET_CLASS (store); g_return_if_fail (class->get_inbox_folder != NULL); class->get_inbox_folder ( store, io_priority, cancellable, callback, user_data); }
false
false
false
true
false
1
qla83xx_restart_nic_firmware(scsi_qla_host_t *vha) { int rval; mbx_cmd_t mc; mbx_cmd_t *mcp = &mc; struct qla_hw_data *ha = vha->hw; if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha)) return QLA_FUNCTION_FAILED; ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__); mcp->mb[0] = MBC_RESTART_NIC_FIRMWARE; mcp->out_mb = MBX_0; mcp->in_mb = MBX_1|MBX_0; mcp->tov = MBX_TOV_SECONDS; mcp->flags = 0; rval = qla2x00_mailbox_command(vha, mcp); if (rval != QLA_SUCCESS) { ql_dbg(ql_dbg_mbx, vha, 0x1144, "Failed=%x mb[0]=%x mb[1]=%x.\n", rval, mcp->mb[0], mcp->mb[1]); ha->isp_ops->fw_dump(vha, 0); } else { ql_dbg(ql_dbg_mbx, vha, 0x1145, "Done %s.\n", __func__); } return rval; }
false
false
false
false
false
0
_parse_pip_metadata_extension(BITSTREAM *bits, MPLS_PL *pl) { MPLS_PIP_METADATA *data; int ii; uint32_t start_address = (uint32_t)bs_pos(bits) / 8; uint32_t len = bs_read(bits, 32); int entries = bs_read(bits, 16); if (len < 1 || entries < 1) { return 0; } data = calloc(entries, sizeof(MPLS_PIP_METADATA)); for (ii = 0; ii < entries; ii++) { if (!_parse_pip_metadata_block(bits, start_address, data)) { X_FREE(data); fprintf(stderr, "error parsing pip metadata extension\n"); return 0; } } pl->ext_pip_data_count = entries; pl->ext_pip_data = data; return 1; }
false
false
false
false
false
0
onAnimationUnpaused() { if (d_eventReceiver) { AnimationEventArgs args(this); d_eventReceiver->fireEvent(EventAnimationUnpaused, args, EventNamespace); } }
false
false
false
false
false
0
parse_residue(offset, pat) int offset; char **pat; /* this is so that the possition in the */ /* pattern string is updated */ { PatternResidue *pr; int num = 0; char *tmp; if (**pat != '[') { /* it is only one residue */ /* declare space for the pattern residue and the character string */ CheckMem( pr = (PatternResidue *) malloc(sizeof(PatternResidue)) ); CheckMem( pr->residues = (char *) malloc(sizeof(char)*2) ); /* initialize the structure */ pr->offset = offset; pr->num_residues = 1; pr->next = NULL; /* set the residues string */ pr->residues[0] = **pat; pr->residues[1] = '\0'; /* don't move the move the pattern pointer/marker ahead since it is done once in the calling function. */ return pr; } else { /* it is more than one residue */ num = 0; tmp = *pat; tmp++; /* move over the '[' */ while (*tmp != ']') { num++; tmp++; } *tmp = '\0'; /* make place a null to end the residues */ /* declare space for the pattern residue and the character string */ CheckMem( pr = (PatternResidue *) malloc(sizeof(PatternResidue)) ); CheckMem( pr->residues = (char *) malloc(sizeof(char)*(num+1)) ); /* initialize the structure */ pr->offset = offset; pr->num_residues = num; pr->next = NULL; /* set the residues string */ strcpy(pr->residues, (*pat)+1); pr->residues[num] = '\0'; /* move the pattern pointer/marker ahead, all but one. It is moved ahead one position automatically */ *pat = *pat + 1 + num; return pr; } assert(0); /* shouldn't get here */ }
false
false
false
true
false
1
doflags(FILE *fp, struct fetchinfo *fi, struct imapscaninfo *i, unsigned long msgnum, struct rfc2045 *mimep) { struct libmail_kwMessageEntry *kme; char buf[256]; #if SMAP if (smapflag) { writes(" FLAGS="); get_message_flags(i->msgs+msgnum, buf, 0); writes(buf); } else #endif { struct libmail_kwMessage *km; writes("FLAGS "); get_message_flags(i->msgs+msgnum, buf, 0); writes("("); writes(buf); if (buf[0]) strcpy(buf, " "); if ((km=i->msgs[msgnum].keywordMsg) != NULL) for (kme=km->firstEntry; kme; kme=kme->next) { writes(buf); strcpy(buf, " "); writes(keywordName(kme->libmail_keywordEntryPtr)); } writes(")"); } i->msgs[msgnum].changedflags=0; }
true
true
false
false
false
1
GetComment() const { const char* no_comment = 0; return this->HaveComment? this->Comment.c_str() : no_comment; }
false
false
false
false
false
0
zend_std_get_static_property(zend_class_entry *ce, char *property_name, int property_name_len, zend_bool silent TSRMLS_DC) /* {{{ */ { zval **retval = NULL; zend_class_entry *tmp_ce = ce; zend_property_info *property_info; zend_property_info std_property_info; if (zend_hash_find(&ce->properties_info, property_name, property_name_len+1, (void **) &property_info)==FAILURE) { std_property_info.flags = ZEND_ACC_PUBLIC; std_property_info.name = property_name; std_property_info.name_length = property_name_len; std_property_info.h = zend_get_hash_value(std_property_info.name, std_property_info.name_length+1); std_property_info.ce = ce; property_info = &std_property_info; } #if DEBUG_OBJECT_HANDLERS zend_printf("Access type for %s::%s is %s\n", ce->name, property_name, zend_visibility_string(property_info->flags)); #endif if (!zend_verify_property_access(property_info, ce TSRMLS_CC)) { if (!silent) { zend_error(E_ERROR, "Cannot access %s property %s::$%s", zend_visibility_string(property_info->flags), ce->name, property_name); } return NULL; } zend_update_class_constants(tmp_ce TSRMLS_CC); zend_hash_quick_find(CE_STATIC_MEMBERS(tmp_ce), property_info->name, property_info->name_length+1, property_info->h, (void **) &retval); if (!retval) { if (silent) { return NULL; } else { zend_error(E_ERROR, "Access to undeclared static property: %s::$%s", ce->name, property_name); } } return retval; }
false
false
false
false
false
0
extractPrecisionOption() { tstring opt = extractOption(); int r = 0; if (! opt.empty ()) r = atoi(DCMTK_LOG4CPLUS_TSTRING_TO_STRING(opt).c_str()); return r; }
false
false
false
false
false
0
LowerCallResult(SDValue Chain, SDValue InFlag, CallingConv::ID CallConv, bool isVarArg, const SmallVectorImpl<ISD::InputArg> &Ins, SDLoc dl, SelectionDAG &DAG, SmallVectorImpl<SDValue> &InVals, const SmallVectorImpl<SDValue> &OutVals, SDValue Callee) const { // Assign locations to each value returned by this call. SmallVector<CCValAssign, 16> RVLocs; CCState CCInfo(CallConv, isVarArg, DAG.getMachineFunction(), RVLocs, *DAG.getContext()); CCInfo.AnalyzeCallResult(Ins, RetCC_Hexagon); // Copy all of the result registers out of their specified physreg. for (unsigned i = 0; i != RVLocs.size(); ++i) { Chain = DAG.getCopyFromReg(Chain, dl, RVLocs[i].getLocReg(), RVLocs[i].getValVT(), InFlag).getValue(1); InFlag = Chain.getValue(2); InVals.push_back(Chain.getValue(0)); } return Chain; }
false
false
false
false
false
0
avlID_add(avlID_tree * root, const long k, const long n) { int d = 0; /* -1 if the new node is the left child 1 if the new node is the right child */ int pos1 = 0, pos2 = 0; int rotation = 0; /* rotation type to balance tree */ avlID_node *node_temp = NULL; avlID_node *critical = NULL; avlID_node *p = NULL; /* father pointer of new node */ if ((root == NULL) || (*root == NULL)) return AVL_ERR; /* find where insert the new node */ node_temp = avlID_individua(*root, k, &p, &d); if (node_temp != NULL) { node_temp->counter = node_temp->counter + n; return AVL_PRES; /* key already exists in the tree, only update the counter */ } /* create the new node */ node_temp = avlID_make(k, n); if (node_temp == NULL) return AVL_ERR; /* insert the new node */ node_temp->father = p; if (d == -1) p->left_child = node_temp; else { if (d == 1) p->right_child = node_temp; else { G_free(node_temp); return AVL_ERR; } } /* if necessary balance the tree */ critical = critical_node(node_temp, &pos1, &pos2, NULL); if (critical == NULL) return AVL_ADD; /* not necessary */ /* balance */ rotation = (pos1 * 10) + pos2; switch (rotation) { /* rotate */ case AVL_SS: avlID_rotation_ll(critical); break; case AVL_SD: avlID_rotation_lr(critical); break; case AVL_DS: avlID_rotation_rl(critical); break; case AVL_DD: avlID_rotation_rr(critical); break; default: G_fatal_error("avl, avlID_add: balancing error\n"); return AVL_ERR; } /* if after rotation there is a new root update the root pointer */ while ((*root)->father != NULL) *root = (*root)->father; return AVL_ADD; }
false
false
false
false
false
0
lldp_private_8021_print(const u_char *tptr, u_int tlv_len) { int subtype, hexdump = FALSE; u_int sublen; if (tlv_len < 4) { return hexdump; } subtype = *(tptr+3); printf("\n\t %s Subtype (%u)", tok2str(lldp_8021_subtype_values, "unknown", subtype), subtype); switch (subtype) { case LLDP_PRIVATE_8021_SUBTYPE_PORT_VLAN_ID: if (tlv_len < 6) { return hexdump; } printf("\n\t port vlan id (PVID): %u", EXTRACT_16BITS(tptr+4)); break; case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_VLAN_ID: if (tlv_len < 7) { return hexdump; } printf("\n\t port and protocol vlan id (PPVID): %u, flags [%s] (0x%02x)", EXTRACT_16BITS(tptr+5), bittok2str(lldp_8021_port_protocol_id_values, "none", *(tptr+4)), *(tptr+4)); break; case LLDP_PRIVATE_8021_SUBTYPE_VLAN_NAME: if (tlv_len < 6) { return hexdump; } printf("\n\t vlan id (VID): %u", EXTRACT_16BITS(tptr+4)); if (tlv_len < 7) { return hexdump; } sublen = *(tptr+6); if (tlv_len < 7+sublen) { return hexdump; } printf("\n\t vlan name: "); safeputs((const char *)tptr+7, sublen); break; case LLDP_PRIVATE_8021_SUBTYPE_PROTOCOL_IDENTITY: if (tlv_len < 5) { return hexdump; } sublen = *(tptr+4); if (tlv_len < 5+sublen) { return hexdump; } printf("\n\t protocol identity: "); safeputs((const char *)tptr+5, sublen); break; default: hexdump = TRUE; break; } return hexdump; }
false
false
false
false
false
0
usbhsc_hotplug(struct usbhs_priv *priv) { struct platform_device *pdev = usbhs_priv_to_pdev(priv); struct usbhs_mod *mod = usbhs_mod_get_current(priv); int id; int enable; int cable; int ret; /* * get vbus status from platform */ enable = usbhs_platform_call(priv, get_vbus, pdev); /* * get id from platform */ id = usbhs_platform_call(priv, get_id, pdev); if (enable && !mod) { if (priv->edev) { cable = extcon_get_cable_state_(priv->edev, EXTCON_USB_HOST); if ((cable > 0 && id != USBHS_HOST) || (!cable && id != USBHS_GADGET)) { dev_info(&pdev->dev, "USB cable plugged in doesn't match the selected role!\n"); return; } } ret = usbhs_mod_change(priv, id); if (ret < 0) return; dev_dbg(&pdev->dev, "%s enable\n", __func__); /* power on */ if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) usbhsc_power_ctrl(priv, enable); /* bus init */ usbhsc_set_buswait(priv); usbhsc_bus_init(priv); /* module start */ usbhs_mod_call(priv, start, priv); } else if (!enable && mod) { dev_dbg(&pdev->dev, "%s disable\n", __func__); /* module stop */ usbhs_mod_call(priv, stop, priv); /* bus init */ usbhsc_bus_init(priv); /* power off */ if (usbhsc_flags_has(priv, USBHSF_RUNTIME_PWCTRL)) usbhsc_power_ctrl(priv, enable); usbhs_mod_change(priv, -1); /* reset phy for next connection */ usbhs_platform_call(priv, phy_reset, pdev); } }
false
false
false
false
false
0
get_cac_tdp_table(struct pp_hwmgr *hwmgr, struct phm_cac_tdp_table **ptable, const ATOM_PowerTune_Table *table, uint16_t us_maximum_power_delivery_limit) { unsigned long table_size; struct phm_cac_tdp_table *tdp_table; table_size = sizeof(unsigned long) + sizeof(struct phm_cac_tdp_table); tdp_table = kzalloc(table_size, GFP_KERNEL); if (NULL == tdp_table) return -ENOMEM; tdp_table->usTDP = le16_to_cpu(table->usTDP); tdp_table->usConfigurableTDP = le16_to_cpu(table->usConfigurableTDP); tdp_table->usTDC = le16_to_cpu(table->usTDC); tdp_table->usBatteryPowerLimit = le16_to_cpu(table->usBatteryPowerLimit); tdp_table->usSmallPowerLimit = le16_to_cpu(table->usSmallPowerLimit); tdp_table->usLowCACLeakage = le16_to_cpu(table->usLowCACLeakage); tdp_table->usHighCACLeakage = le16_to_cpu(table->usHighCACLeakage); tdp_table->usMaximumPowerDeliveryLimit = us_maximum_power_delivery_limit; *ptable = tdp_table; return 0; }
false
false
false
false
false
0
check_attendee(icalproperty *p, struct options_struct *opt){ const char* s = icalproperty_get_attendee(p); char* lower_attendee = lowercase(s); char* local_attendee = opt->calid; /* Check that attendee begins with "mailto:" */ if (strncmp(lower_attendee,"mailto:",7) == 0){ /* skip over the mailto: part */ lower_attendee += 7; if(strcmp(lower_attendee,local_attendee) == 0){ return 1; } lower_attendee -= 7; free(lower_attendee); } return 0; }
true
true
false
false
false
1
generate_free_switch_expr(const zend_switch_entry *switch_entry TSRMLS_DC) /* {{{ */ { zend_op *opline; if (switch_entry->cond.op_type != IS_VAR && switch_entry->cond.op_type != IS_TMP_VAR) { return (switch_entry->cond.op_type == IS_UNUSED); } opline = get_next_op(CG(active_op_array) TSRMLS_CC); opline->opcode = (switch_entry->cond.op_type == IS_TMP_VAR) ? ZEND_FREE : ZEND_SWITCH_FREE; SET_NODE(opline->op1, &switch_entry->cond); SET_UNUSED(opline->op2); opline->extended_value = 0; return 0; }
false
false
false
false
false
0
glade_string_list_copy (GList *string_list) { GList *ret = NULL, *list; GladeString *string, *copy; for (list = string_list; list; list = list->next) { string = list->data; copy = glade_string_copy (string); ret = g_list_prepend (ret, copy); } return g_list_reverse (ret); }
false
false
false
false
false
0
fromancr_get_tile_info(int tile_index, int vram, int layer) { int tile, color; tile = fromanc2_videoram[vram][layer][tile_index] | (fromanc2_gfxbank[vram][layer] << 16); color = vram; SET_TILE_INFO(layer, tile, color, 0) }
false
false
false
false
false
0
on_fss__button_OK_clicked (GtkButton *button, GapCmeGlobalParams *gpp) { const gchar *filename; GtkEntry *entry; if(gap_debug) printf("CB: on_fss__button_OK_clicked\n"); if(gpp == NULL) return; if(gpp->fss__fileselection) { filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (gpp->fss__fileselection)); g_snprintf(gpp->val.storyboard_file, sizeof(gpp->val.storyboard_file), "%s" , filename); entry = GTK_ENTRY(gpp->cme__entry_stb); on_fss__button_cancel_clicked(NULL, (gpointer)gpp); if(entry) { gtk_entry_set_text(entry, filename); } } }
false
false
false
false
false
0
get_symbols(const UDateFormat *fmt, UDateFormatSymbolType type, UChar *array[], int32_t arrayLength, int32_t lowestIndex, int32_t firstIndex, UErrorCode *status) { int32_t count, i; if (U_FAILURE(*status)) { return; } count = udat_countSymbols(fmt, type); if(count != arrayLength + lowestIndex) { return; } for(i = 0; i < arrayLength; i++) { int32_t idx = (i + firstIndex) % arrayLength; int32_t size = 1 + udat_getSymbols(fmt, type, idx + lowestIndex, NULL, 0, status); array[idx] = (UChar *) malloc(sizeof(UChar) * size); *status = U_ZERO_ERROR; udat_getSymbols(fmt, type, idx + lowestIndex, array[idx], size, status); } }
false
false
false
false
false
0
complete_remove (GkmTransaction *transaction, GObject *obj, gpointer user_data) { GkmSecretCollection *collection = GKM_SECRET_COLLECTION (user_data); if (gkm_transaction_get_failed (transaction)) add_collection (GKM_SECRET_MODULE (obj), NULL, collection); g_object_unref (collection); return TRUE; }
false
false
false
false
false
0
read_ride_summary(int *bytes_read = NULL, int *sum = NULL) { data_version = read_bytes(1, bytes_read, sum); // data_version read_bytes(1, bytes_read, sum); // firmware_minor_version QDateTime t = read_date(bytes_read, sum); rideFile->setStartTime(t); read_bytes(148, bytes_read, sum); if (data_version >= 4) read_bytes(8, bytes_read, sum); }
false
false
false
false
false
0
open_output_module( const char* names ) { mpg123_module_t *module = NULL; audio_output_t *ao = NULL; int result = 0; char *curname, *modnames; if(param.usebuffer || names==NULL) return NULL; /* Use internal code. */ if(param.outmode != DECODE_AUDIO) return open_fake_module(); modnames = strdup(names); if(modnames == NULL) { error("Error allocating memory for module names."); return NULL; } /* Now loop over the list of possible modules to find one that works. */ curname = strtok(modnames, ","); while(curname != NULL) { char* name = curname; curname = strtok(NULL, ","); if(param.verbose > 1) fprintf(stderr, "Trying output module %s.\n", name); /* Open the module, initial check for availability+libraries. */ module = open_module( "output", name ); if(module == NULL) continue; /* Check if module supports output */ if(module->init_output == NULL) { error1("Module '%s' does not support audio output.", name); close_module(module); continue; /* Try next one. */ } /* Allocation+initialization of memory for audio output type. */ ao = alloc_audio_output(); if(ao==NULL) { error("Failed to allocate audio output structure."); close_module(module); break; /* This is fatal. */ } /* Call the init function */ ao->device = param.output_device; ao->flags = param.output_flags; /* Should I do funny stuff with stderr file descriptor instead? */ if(curname == NULL) { if(param.verbose > 1) fprintf(stderr, "Note: %s is the last output option... showing you any error messages now.\n", name); } else ao->auxflags |= MPG123_OUT_QUIET; /* Probing, so don't spill stderr with errors. */ ao->is_open = FALSE; ao->module = module; /* Need that to close module later. */ result = module->init_output(ao); if(result == 0) { /* Try to open the device. I'm only interested in actually working modules. */ result = open_output(ao); close_output(ao); } else error2("Module '%s' init failed: %i", name, result); if(result!=0) { /* Try next one... */ close_module(module); free(ao); ao = NULL; } else { /* All good, leave the loop. */ if(param.verbose > 1) fprintf(stderr, "Output module '%s' chosen.\n", name); ao->auxflags &= ~MPG123_OUT_QUIET; break; } } free(modnames); if(ao==NULL) error1("Unable to find a working output module in this list: %s", names); return ao; }
false
false
false
false
false
0
mount_not_mounted_callback (GObject *source_object, GAsyncResult *res, gpointer user_data) { MountNotMountedData *data; NautilusWindowSlot *slot; GError *error; GCancellable *cancellable; data = user_data; slot = data->slot; cancellable = data->cancellable; g_free (data); if (g_cancellable_is_cancelled (cancellable)) { /* Cancelled, don't call back */ g_object_unref (cancellable); return; } slot->details->mount_cancellable = NULL; slot->details->determine_view_file = nautilus_file_get (slot->details->pending_location); error = NULL; if (!g_file_mount_enclosing_volume_finish (G_FILE (source_object), res, &error)) { slot->details->mount_error = error; got_file_info_for_view_selection_callback (slot->details->determine_view_file, slot); slot->details->mount_error = NULL; g_error_free (error); } else { nautilus_file_invalidate_all_attributes (slot->details->determine_view_file); nautilus_file_call_when_ready (slot->details->determine_view_file, NAUTILUS_FILE_ATTRIBUTE_INFO | NAUTILUS_FILE_ATTRIBUTE_MOUNT, got_file_info_for_view_selection_callback, slot); } g_object_unref (cancellable); }
false
false
false
false
false
0
walk_wild_section_specs2_wild1 (lang_wild_statement_type *ptr, lang_input_statement_type *file, callback_t callback, void *data) { asection *s; struct wildcard_list *sec0 = ptr->handler_data[0]; struct wildcard_list *wildsec1 = ptr->handler_data[1]; bfd_boolean multiple_sections_found; asection *s0 = find_section (file, sec0, &multiple_sections_found); if (multiple_sections_found) { walk_wild_section_general (ptr, file, callback, data); return; } /* Note that if the section was not found, s0 is NULL and we'll simply never succeed the s == s0 test below. */ for (s = file->the_bfd->sections; s != NULL; s = s->next) { /* Recall that in this code path, a section cannot satisfy more than one spec, so if s == s0 then it cannot match wildspec1. */ if (s == s0) walk_wild_consider_section (ptr, file, s, sec0, callback, data); else { const char *sname = bfd_get_section_name (file->the_bfd, s); bfd_boolean skip = !match_simple_wild (wildsec1->spec.name, sname); if (!skip) walk_wild_consider_section (ptr, file, s, wildsec1, callback, data); } } }
false
false
false
false
false
0
HUlib_addMessageToSText ( hu_stext_t* s, char* prefix, char* msg ) { HUlib_addLineToSText(s); if (prefix) while (*prefix) HUlib_addCharToTextLine(&s->l[s->cl], *(prefix++)); while (*msg) HUlib_addCharToTextLine(&s->l[s->cl], *(msg++)); }
false
false
false
false
false
0
_gck_call_async_ready (gpointer data, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GckArguments *args = (GckArguments*)data; g_assert (GCK_IS_CALL (args->call)); args->call->cancellable = cancellable; if (cancellable) { g_assert (G_IS_CANCELLABLE (cancellable)); g_object_ref (cancellable); } args->call->callback = callback; args->call->user_data = user_data; return args->call; }
false
false
false
false
false
0
transformIndirection(ParseState *pstate, Node *basenode, List *indirection) { Node *result = basenode; List *subscripts = NIL; int location = exprLocation(basenode); ListCell *i; /* * We have to split any field-selection operations apart from * subscripting. Adjacent A_Indices nodes have to be treated as a single * multidimensional subscript operation. */ foreach(i, indirection) { Node *n = lfirst(i); if (IsA(n, A_Indices)) subscripts = lappend(subscripts, n); else if (IsA(n, A_Star)) { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("row expansion via \"*\" is not supported here"), parser_errposition(pstate, location))); } else { Node *newresult; Assert(IsA(n, String)); /* process subscripts before this field selection */ if (subscripts) result = (Node *) transformArraySubscripts(pstate, result, exprType(result), InvalidOid, exprTypmod(result), subscripts, NULL); subscripts = NIL; newresult = ParseFuncOrColumn(pstate, list_make1(n), list_make1(result), NIL, false, false, false, NULL, true, location); if (newresult == NULL) unknown_attribute(pstate, result, strVal(n), location); result = newresult; } } /* process trailing subscripts, if any */ if (subscripts) result = (Node *) transformArraySubscripts(pstate, result, exprType(result), InvalidOid, exprTypmod(result), subscripts, NULL); return result; }
false
false
false
false
false
0
EnvGetNextInstance( void *theEnv, void *iptr) { if (iptr == NULL) return((void *) InstanceData(theEnv)->InstanceList); if (((INSTANCE_TYPE *) iptr)->garbage == 1) return(NULL); return((void *) ((INSTANCE_TYPE *) iptr)->nxtList); }
false
false
false
false
false
0
get_addr_from_global_cache (rtx const loc) { rtx x; void **slot; gcc_checking_assert (GET_CODE (loc) == VALUE); slot = pointer_map_insert (global_get_addr_cache, loc); if (*slot) return (rtx)*slot; x = canon_rtx (get_addr (loc)); /* Tentative, avoiding infinite recursion. */ *slot = x; if (x != loc) { rtx nx = vt_canonicalize_addr (NULL, x); if (nx != x) { /* The table may have moved during recursion, recompute SLOT. */ slot = pointer_map_contains (global_get_addr_cache, loc); *slot = x = nx; } } return x; }
false
false
false
false
false
0
GdipDeleteStringFormat (GpStringFormat *format) { if (!format) return InvalidParameter; if (format->tabStops) { GdipFree (format->tabStops); format->tabStops = NULL; } if (format->charRanges) { GdipFree (format->charRanges); format->charRanges = NULL; } GdipFree (format); return Ok; }
false
false
false
false
false
0
CWB_ensure(CTX ctx, CWB_t *cwb, kbytes_t t, size_t reqsize) { if(!(cwb->ba->bu.len + reqsize < cwb->ba->dim->capacity)) { const char *p = cwb->ba->bu.text; if(p <= t.text && t.text <= p + cwb->pos) { size_t s = t.text - p; knh_Bytes_expands(ctx, cwb->ba, reqsize); t.text = cwb->ba->bu.text + s; } else { knh_Bytes_expands(ctx, cwb->ba, reqsize); } } return t; }
false
false
false
false
false
0
paint(Graphics &g, const YRect &/*r*/) { ref<YFont> font = inputFont; int min, max, minOfs = 0, maxOfs = 0; int textLen = fText.length(); if (curPos > markPos) { min = markPos; max = curPos; } else { min = curPos; max = markPos; } if (curPos == markPos || fText == null || font == null || !fHasFocus) { g.setColor(inputBg); g.fillRect(0, 0, width(), height()); } else { minOfs = font->textWidth(fText.substring(0, min)) - leftOfs; maxOfs = font->textWidth(fText.substring(0, max)) - leftOfs; if (minOfs > 0) { g.setColor(inputBg); g.fillRect(0, 0, minOfs, height()); } /// !!! optimize (0, width) if (minOfs < maxOfs) { g.setColor(inputSelectionBg); g.fillRect(minOfs, 0, maxOfs - minOfs, height()); } if (maxOfs < int(width())) { g.setColor(inputBg); g.fillRect(maxOfs, 0, width() - maxOfs, height()); } } if (font != null) { int yp = 1 + font->ascent(); int curOfs = font->textWidth(fText.substring(0, curPos)); int cx = curOfs - leftOfs; g.setFont(font); if (curPos == markPos || !fHasFocus || fText == null) { g.setColor(inputFg); if (fText != null) g.drawChars(fText.substring(0, textLen), -leftOfs, yp); if (fHasFocus && fCursorVisible) g.drawLine(cx, 0, cx, font->height() + 2); } else { if (min > 0) { g.setColor(inputFg); g.drawChars(fText.substring(0, min), -leftOfs, yp); } /// !!! same here if (min < max) { g.setColor(inputSelectionFg); g.drawChars(fText.substring(min, max - min), minOfs, yp); } if (max < textLen) { g.setColor(inputFg); g.drawChars(fText.substring(max, textLen - max), maxOfs, yp); } } } }
false
false
false
true
false
1
dump(orbOptions::sequenceString& result) { CORBA::String_var v(CORBA::string_alloc(3)); sprintf(v,"%1d.%1d",orbParameters::maxGIOPVersion.major, orbParameters::maxGIOPVersion.minor); orbOptions::addKVString(key(),v,result); }
false
false
false
false
false
0
hpfs_file_fsync(struct file *file, loff_t start, loff_t end, int datasync) { struct inode *inode = file->f_mapping->host; int ret; ret = filemap_write_and_wait_range(file->f_mapping, start, end); if (ret) return ret; return sync_blockdev(inode->i_sb->s_bdev); }
false
false
false
false
false
0
gimple_ic_transform (gimple stmt) { histogram_value histogram; gcov_type val, count, all, bb_all; gcov_type prob; tree callee; gimple modify; struct cgraph_node *direct_call; if (gimple_code (stmt) != GIMPLE_CALL) return false; callee = gimple_call_fn (stmt); if (TREE_CODE (callee) == FUNCTION_DECL) return false; if (gimple_call_internal_p (stmt)) return false; histogram = gimple_histogram_value_of_type (cfun, stmt, HIST_TYPE_INDIR_CALL); if (!histogram) return false; val = histogram->hvalue.counters [0]; count = histogram->hvalue.counters [1]; all = histogram->hvalue.counters [2]; gimple_remove_histogram_value (cfun, stmt, histogram); if (4 * count <= 3 * all) return false; bb_all = gimple_bb (stmt)->count; /* The order of CHECK_COUNTER calls is important - since check_counter can correct the third parameter and we want to make count <= all <= bb_all. */ if ( check_counter (stmt, "ic", &all, &bb_all, bb_all) || check_counter (stmt, "ic", &count, &all, all)) return false; if (all > 0) prob = (count * REG_BR_PROB_BASE + all / 2) / all; else prob = 0; direct_call = find_func_by_pid ((int)val); if (direct_call == NULL) return false; modify = gimple_ic (stmt, direct_call, prob, count, all); if (dump_file) { fprintf (dump_file, "Indirect call -> direct call "); print_generic_expr (dump_file, gimple_call_fn (stmt), TDF_SLIM); fprintf (dump_file, "=> "); print_generic_expr (dump_file, direct_call->decl, TDF_SLIM); fprintf (dump_file, " transformation on insn "); print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM); fprintf (dump_file, " to "); print_gimple_stmt (dump_file, modify, 0, TDF_SLIM); fprintf (dump_file, "hist->count "HOST_WIDEST_INT_PRINT_DEC " hist->all "HOST_WIDEST_INT_PRINT_DEC"\n", count, all); } return true; }
false
false
false
false
false
0
zd_tx_watchdog_handler(struct work_struct *work) { struct zd_usb *usb = container_of(work, struct zd_usb, tx.watchdog_work.work); struct zd_usb_tx *tx = &usb->tx; if (!atomic_read(&tx->enabled) || !tx->watchdog_enabled) goto out; if (!zd_tx_timeout(usb)) goto out; /* TX halted, try reset */ dev_warn(zd_usb_dev(usb), "TX-stall detected, resetting device..."); usb_queue_reset_device(usb->intf); /* reset will stop this worker, don't rearm */ return; out: queue_delayed_work(zd_workqueue, &tx->watchdog_work, ZD_TX_WATCHDOG_INTERVAL); }
false
false
false
false
false
0
last_rec(Node *n) { int maxkey; if (n->emap == 0) return NULL; /* for safety in MT situation */ maxkey = Scm__HighestBitNumber(n->emap); if (NODE_ARC_IS_LEAF(n, maxkey)) { return (Leaf*)NODE_ENTRY(n, NODE_INDEX2OFF(n, maxkey)); } else { return last_rec((Node*)NODE_ENTRY(n, NODE_INDEX2OFF(n, maxkey))); } }
false
false
false
false
false
0
cl_randseed(void) { char buf[16]; FILE* fs; struct timeval tv; const char * randdevname [] = {"/dev/urandom", "/dev/random"}; int idev; #if 0 long horrid; #endif /* * Notes, based on reading of man pages of Solaris, FreeBSD and Linux, * and on proof-of-concept tests on Solaris and Linux (32- and 64-bit). * * Reminder of a subtlety: our intention is not to return a random * number, but rather to return a random-enough seed for future * random numbers. So don't bother trying (e.g.) "rand()" and * "random()". * * /dev/random and dev/urandom seem to be a related pair. In the * words of the song: "You can't have one without the other". * * /dev/random is probably the best. But it can block. The Solaris * implementation can apparently honour "O_NONBLOCK" and "O_NDELAY". * But can others? For this reason, I chose not to use it at present. * * /dev/urandom (with the "u") is also good. This doesn't block. * But some OSes may lack it. It is tempting to detect its presence * with autoconf and use the result in a "hash-if" here. BUT... in * at least one OS, its presence can vary depending upon patch levels, * so a binary/package built on an enabled machine might hit trouble * when run on one where it is absent. (And vice versa: a build on a * disabled machine would be unable to take advantage of it on an * enabled machine.) Therefore always try for it at run time. * * "gettimeofday()" returns a random-ish number in its millisecond * component. * * -- David Lee, Jan 2006 */ /* * Each block below is logically of the form: * if good-feature appears present { * try feature * if feature worked { * return its result * } * } * -- fall through to not-quite-so-good feature -- */ /* * Does any of the random device names work? */ for (idev=0; idev < DIMOF(randdevname); ++idev) { fs = fopen(randdevname[idev], "r"); if (fs == NULL) { cl_log(LOG_INFO, "%s: Opening file %s failed" , __FUNCTION__, randdevname[idev]); }else{ if (fread(buf, 1, sizeof(buf), fs)!= sizeof(buf)){ cl_log(LOG_INFO, "%s: reading file %s failed" , __FUNCTION__, randdevname[idev]); fclose(fs); }else{ fclose(fs); return (unsigned int)cl_binary_to_int(buf, sizeof(buf)); } } } /* * Try "gettimeofday()"; use its microsecond output. * (Might it be prudent to let, say, the seconds further adjust this, * in case the microseconds are too predictable?) */ if (gettimeofday(&tv, NULL) != 0) { cl_log(LOG_INFO, "%s: gettimeofday failed", __FUNCTION__); }else{ return (unsigned int) tv.tv_usec; } /* * times(2) returns the number of clock ticks since * boot. Fairly predictable, but not completely so... */ return (unsigned int) cl_times(); #if 0 /* * If all else has failed, return (as a number) the address of * something on the stack. * Poor, but at least it has a chance of some sort of variability. */ horrid = (long) &tv; return (unsigned int) horrid; /* pointer to local variable exposed */ #endif }
true
true
false
false
true
1
getNkoProperties(const unsigned short *chars, int len, HB_ArabicProperties *properties) { int lastPos = 0; int i = 0; Joining j = getNkoJoining(chars[0]); ArabicShape shape = joining_table[XIsolated][j].form2; properties[0].justification = HB_NoJustification; for (i = 1; i < len; ++i) { properties[i].justification = (HB_GetUnicodeCharCategory(chars[i]) == HB_Separator_Space) ? ArabicSpace : ArabicNone; j = getNkoJoining(chars[i]); if (j == JTransparent) { properties[i].shape = XIsolated; continue; } properties[lastPos].shape = joining_table[shape][j].form1; shape = joining_table[shape][j].form2; lastPos = i; } properties[lastPos].shape = joining_table[shape][JNone].form1; /* for (int i = 0; i < len; ++i) qDebug("nko properties(%d): uc=%x shape=%d, justification=%d", i, chars[i], properties[i].shape, properties[i].justification); */ }
false
false
false
false
false
0
iwl_get_max_txpwr_half_dbm(const struct iwl_nvm_data *data, struct iwl_eeprom_enhanced_txpwr *txp) { s8 result = 0; /* (.5 dBm) */ /* Take the highest tx power from any valid chains */ if (data->valid_tx_ant & ANT_A && txp->chain_a_max > result) result = txp->chain_a_max; if (data->valid_tx_ant & ANT_B && txp->chain_b_max > result) result = txp->chain_b_max; if (data->valid_tx_ant & ANT_C && txp->chain_c_max > result) result = txp->chain_c_max; if ((data->valid_tx_ant == ANT_AB || data->valid_tx_ant == ANT_BC || data->valid_tx_ant == ANT_AC) && txp->mimo2_max > result) result = txp->mimo2_max; if (data->valid_tx_ant == ANT_ABC && txp->mimo3_max > result) result = txp->mimo3_max; return result; }
false
false
false
false
false
0
pkey_dsa_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, const char *value) { if (!strcmp(type, "dsa_paramgen_bits")) { int nbits; nbits = atoi(value); return EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits); } if (!strcmp(type, "dsa_paramgen_q_bits")) { int qbits = atoi(value); return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS, qbits, NULL); } if (!strcmp(type, "dsa_paramgen_md")) { return EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, EVP_PKEY_CTRL_DSA_PARAMGEN_MD, 0, (void *)EVP_get_digestbyname(value)); } return -2; }
false
false
false
false
false
0
glade_gtk_tool_button_set_stock_id (GObject * object, const GValue * value) { const gchar *stock_id; g_return_if_fail (GTK_IS_TOOL_BUTTON (object)); stock_id = g_value_get_string (value); if (stock_id && strlen (stock_id) == 0) stock_id = NULL; gtk_tool_button_set_stock_id (GTK_TOOL_BUTTON (object), stock_id); }
false
false
false
false
false
0
per_scan_setup (j_compress_ptr cinfo) /* Do computations that are needed before processing a JPEG scan */ /* cinfo->comps_in_scan and cinfo->cur_comp_info[] are already set */ { int ci, mcublks, tmp; jpeg_component_info *compptr; int data_unit = cinfo->data_unit; if (cinfo->comps_in_scan == 1) { /* Noninterleaved (single-component) scan */ compptr = cinfo->cur_comp_info[0]; /* Overall image size in MCUs */ cinfo->MCUs_per_row = compptr->width_in_data_units; cinfo->MCU_rows_in_scan = compptr->height_in_data_units; /* For noninterleaved scan, always one block per MCU */ compptr->MCU_width = 1; compptr->MCU_height = 1; compptr->MCU_data_units = 1; compptr->MCU_sample_width = data_unit; compptr->last_col_width = 1; /* For noninterleaved scans, it is convenient to define last_row_height * as the number of block rows present in the last iMCU row. */ tmp = (int) (compptr->height_in_data_units % compptr->v_samp_factor); if (tmp == 0) tmp = compptr->v_samp_factor; compptr->last_row_height = tmp; /* Prepare array describing MCU composition */ cinfo->data_units_in_MCU = 1; cinfo->MCU_membership[0] = 0; } else { /* Interleaved (multi-component) scan */ if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN) ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan, MAX_COMPS_IN_SCAN); /* Overall image size in MCUs */ cinfo->MCUs_per_row = (JDIMENSION) jdiv_round_up((long) cinfo->image_width, (long) (cinfo->max_h_samp_factor*data_unit)); cinfo->MCU_rows_in_scan = (JDIMENSION) jdiv_round_up((long) cinfo->image_height, (long) (cinfo->max_v_samp_factor*data_unit)); cinfo->data_units_in_MCU = 0; for (ci = 0; ci < cinfo->comps_in_scan; ci++) { compptr = cinfo->cur_comp_info[ci]; /* Sampling factors give # of blocks of component in each MCU */ compptr->MCU_width = compptr->h_samp_factor; compptr->MCU_height = compptr->v_samp_factor; compptr->MCU_data_units = compptr->MCU_width * compptr->MCU_height; compptr->MCU_sample_width = compptr->MCU_width * data_unit; /* Figure number of non-dummy blocks in last MCU column & row */ tmp = (int) (compptr->width_in_data_units % compptr->MCU_width); if (tmp == 0) tmp = compptr->MCU_width; compptr->last_col_width = tmp; tmp = (int) (compptr->height_in_data_units % compptr->MCU_height); if (tmp == 0) tmp = compptr->MCU_height; compptr->last_row_height = tmp; /* Prepare array describing MCU composition */ mcublks = compptr->MCU_data_units; if (cinfo->data_units_in_MCU + mcublks > C_MAX_DATA_UNITS_IN_MCU) ERREXIT(cinfo, JERR_BAD_MCU_SIZE); while (mcublks-- > 0) { cinfo->MCU_membership[cinfo->data_units_in_MCU++] = ci; } } } /* Convert restart specified in rows to actual MCU count. */ /* Note that count must fit in 16 bits, so we provide limiting. */ if (cinfo->restart_in_rows > 0) { long nominal = (long) cinfo->restart_in_rows * (long) cinfo->MCUs_per_row; cinfo->restart_interval = (unsigned int) MIN(nominal, 65535L); } }
false
false
false
false
false
0
_rtl92s_firmware_downloadcode(struct ieee80211_hw *hw, u8 *code_virtual_address, u32 buffer_len) { struct rtl_priv *rtlpriv = rtl_priv(hw); struct sk_buff *skb; struct rtl_tcb_desc *tcb_desc; unsigned char *seg_ptr; u16 frag_threshold = MAX_FIRMWARE_CODE_SIZE; u16 frag_length, frag_offset = 0; u16 extra_descoffset = 0; u8 last_inipkt = 0; _rtl92s_fw_set_rqpn(hw); if (buffer_len >= MAX_FIRMWARE_CODE_SIZE) { RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, "Size over FIRMWARE_CODE_SIZE!\n"); return false; } extra_descoffset = 0; do { if ((buffer_len - frag_offset) > frag_threshold) { frag_length = frag_threshold + extra_descoffset; } else { frag_length = (u16)(buffer_len - frag_offset + extra_descoffset); last_inipkt = 1; } /* Allocate skb buffer to contain firmware */ /* info and tx descriptor info. */ skb = dev_alloc_skb(frag_length); if (!skb) return false; skb_reserve(skb, extra_descoffset); seg_ptr = (u8 *)skb_put(skb, (u32)(frag_length - extra_descoffset)); memcpy(seg_ptr, code_virtual_address + frag_offset, (u32)(frag_length - extra_descoffset)); tcb_desc = (struct rtl_tcb_desc *)(skb->cb); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->cmd_or_init = DESC_PACKET_TYPE_INIT; tcb_desc->last_inipkt = last_inipkt; _rtl92s_cmd_send_packet(hw, skb, last_inipkt); frag_offset += (frag_length - extra_descoffset); } while (frag_offset < buffer_len); rtl_write_byte(rtlpriv, TP_POLL, TPPOLL_CQ); return true ; }
false
false
false
false
false
0
G_quant_set_pos_infinite_rule(struct Quant *q, DCELL dRight, CELL c) { q->infiniteDRight = dRight; q->infiniteCRight = c; quant_update_limits(q, dRight, dRight, c, c); /* update lookup table */ if (q->fp_lookup.active) { q->fp_lookup.inf_dmax = q->infiniteDRight; q->fp_lookup.inf_max = q->infiniteCRight; } q->infiniteRightSet = 1; }
false
false
false
false
false
0
free_mi_tree(struct mi_root *parent) { struct mi_node *p, *q; for(p = parent->node.kids ; p ; ){ q = p; p = p->next; free_mi_node(q); } if (use_shm) shm_free(parent); else pkg_free(parent); }
false
true
false
false
false
1
xsh_interpolate_spectrum( int biny, int oversample, int absorder, double lambda_step, cpl_vector *init_pos, cpl_vector *std_flux, cpl_vector *std_err, cpl_vector *std_qual, cpl_vector *opt_flux, cpl_vector *opt_err, cpl_vector *opt_qual, cpl_vector **res_pos, cpl_vector **res_std_flux, cpl_vector **res_std_err, cpl_vector **res_std_qual, cpl_vector **res_opt_flux, cpl_vector **res_opt_err, cpl_vector **res_opt_qual) { int init_size; double lambda_min, lambda_max; double binlambda_min, binlambda_max; int mult_min, mult_max; int res_size, i; XSH_ASSURE_NOT_NULL( init_pos); XSH_ASSURE_NOT_NULL( std_flux); XSH_ASSURE_NOT_NULL( std_err); XSH_ASSURE_NOT_NULL( std_qual); XSH_ASSURE_NOT_NULL( opt_flux); XSH_ASSURE_NOT_NULL( opt_err); XSH_ASSURE_NOT_NULL( opt_qual); XSH_ASSURE_NOT_NULL( res_pos); XSH_ASSURE_NOT_NULL( res_std_flux); XSH_ASSURE_NOT_NULL( res_std_err); XSH_ASSURE_NOT_NULL( res_std_qual); XSH_ASSURE_NOT_NULL( res_opt_flux); XSH_ASSURE_NOT_NULL( res_opt_err); XSH_ASSURE_NOT_NULL( res_opt_qual); check( init_size = cpl_vector_get_size( init_pos)); check( lambda_min = cpl_vector_get( init_pos, 0)); check( lambda_max = cpl_vector_get( init_pos, init_size-1)); /* round value to be multiple of lambda_step */ mult_min = (int) ceil(lambda_min/lambda_step)+1; binlambda_min = mult_min*lambda_step; mult_max = (int) floor(lambda_max/lambda_step)-1; binlambda_max = mult_max*lambda_step; xsh_msg("lambda_min %f lambda_max %f TEST %f %f : step %f", lambda_min, lambda_max, binlambda_min, binlambda_max, lambda_step); res_size = mult_max-mult_min+1; check( *res_pos = cpl_vector_new( res_size)); for( i=0; i< res_size; i++){ check( cpl_vector_set( *res_pos, i,binlambda_min+i*lambda_step)); } check( *res_std_flux = xsh_vector_integrate( biny, absorder, oversample, init_pos, lambda_step, std_flux, std_err, std_qual, *res_pos, res_std_err, res_std_qual)); check( *res_opt_flux = xsh_vector_integrate( biny, absorder, oversample, init_pos, lambda_step, opt_flux, opt_err, opt_qual, *res_pos, res_opt_err, res_opt_qual)); cleanup: if (cpl_error_get_code() != CPL_ERROR_NONE){ xsh_free_vector( res_pos); xsh_free_vector( res_std_flux); xsh_free_vector( res_std_err); xsh_free_vector( res_std_qual); xsh_free_vector( res_opt_flux); xsh_free_vector( res_opt_err); xsh_free_vector( res_opt_qual); } return; }
false
false
false
false
false
0
mainWindows() { clean(); QList<BrowserMainWindow*> list; for (int i = 0; i < m_mainWindows.count(); ++i) list.append(m_mainWindows.at(i)); return list; }
false
false
false
false
false
0
try_swap_copy_prop (loop, replacement, regno) const struct loop *loop; rtx replacement; unsigned int regno; { rtx insn; rtx set = NULL_RTX; unsigned int new_regno; new_regno = REGNO (replacement); for (insn = next_insn_in_loop (loop, loop->scan_start); insn != NULL_RTX; insn = next_insn_in_loop (loop, insn)) { /* Search for the insn that copies REGNO to NEW_REGNO? */ if (INSN_P (insn) && (set = single_set (insn)) && GET_CODE (SET_DEST (set)) == REG && REGNO (SET_DEST (set)) == new_regno && GET_CODE (SET_SRC (set)) == REG && REGNO (SET_SRC (set)) == regno) break; } if (insn != NULL_RTX) { rtx prev_insn; rtx prev_set; /* Some DEF-USE info would come in handy here to make this function more general. For now, just check the previous insn which is the most likely candidate for setting REGNO. */ prev_insn = PREV_INSN (insn); if (INSN_P (insn) && (prev_set = single_set (prev_insn)) && GET_CODE (SET_DEST (prev_set)) == REG && REGNO (SET_DEST (prev_set)) == regno) { /* We have: (set (reg regno) (expr)) (set (reg new_regno) (reg regno)) so try converting this to: (set (reg new_regno) (expr)) (set (reg regno) (reg new_regno)) The former construct is often generated when a global variable used for an induction variable is shadowed by a register (NEW_REGNO). The latter construct improves the chances of GIV replacement and BIV elimination. */ validate_change (prev_insn, &SET_DEST (prev_set), replacement, 1); validate_change (insn, &SET_DEST (set), SET_SRC (set), 1); validate_change (insn, &SET_SRC (set), replacement, 1); if (apply_change_group ()) { if (loop_dump_stream) fprintf (loop_dump_stream, " Swapped set of reg %d at %d with reg %d at %d.\n", regno, INSN_UID (insn), new_regno, INSN_UID (prev_insn)); /* Update first use of REGNO. */ if (REGNO_FIRST_UID (regno) == INSN_UID (prev_insn)) REGNO_FIRST_UID (regno) = INSN_UID (insn); /* Now perform copy propagation to hopefully remove all uses of REGNO within the loop. */ try_copy_prop (loop, replacement, regno); } } } }
false
false
false
false
false
0
ext4_es_list_add(struct inode *inode) { struct ext4_inode_info *ei = EXT4_I(inode); struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); if (!list_empty(&ei->i_es_list)) return; spin_lock(&sbi->s_es_lock); if (list_empty(&ei->i_es_list)) { list_add_tail(&ei->i_es_list, &sbi->s_es_list); sbi->s_es_nr_inode++; } spin_unlock(&sbi->s_es_lock); }
false
false
false
false
false
0
filetype_from_mode(mode_t mode) { sigar_file_type_e type; switch (mode & S_IFMT) { case S_IFREG: type = SIGAR_FILETYPE_REG; break; case S_IFDIR: type = SIGAR_FILETYPE_DIR; break; case S_IFLNK: type = SIGAR_FILETYPE_LNK; break; case S_IFCHR: type = SIGAR_FILETYPE_CHR; break; case S_IFBLK: type = SIGAR_FILETYPE_BLK; break; #if defined(S_IFFIFO) case S_IFFIFO: type = SIGAR_FILETYPE_PIPE; break; #endif #if !defined(BEOS) && defined(S_IFSOCK) case S_IFSOCK: type = SIGAR_FILETYPE_SOCK; break; #endif default: /* Work around missing S_IFxxx values above * for Linux et al. */ #if !defined(S_IFFIFO) && defined(S_ISFIFO) if (S_ISFIFO(mode)) { type = SIGAR_FILETYPE_PIPE; } else #endif #if !defined(BEOS) && !defined(S_IFSOCK) && defined(S_ISSOCK) if (S_ISSOCK(mode)) { type = SIGAR_FILETYPE_SOCK; } else #endif type = SIGAR_FILETYPE_UNKFILE; } return type; }
false
false
false
false
false
0