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
return_replies_thread(void *arg) { Octstr *body; struct request_data *p; int status; Octstr *final_url; List *headers; while (run_status == running) { p = http_receive_result(caller, &status, &final_url, &headers, &body); if (p == NULL) break; return_reply(status, body, headers, p->client_SDU_size, p->event, p->session_id, p->method, p->url, p->x_wap_tod, p->request_headers, p->msisdn); wap_event_destroy(p->event); http_destroy_headers(p->request_headers); octstr_destroy(p->msisdn); gw_free(p); octstr_destroy(final_url); } }
false
false
false
false
false
0
pcnet32_nway_reset(struct net_device *dev) { struct pcnet32_private *lp = netdev_priv(dev); unsigned long flags; int r = -EOPNOTSUPP; if (lp->mii) { spin_lock_irqsave(&lp->lock, flags); r = mii_nway_restart(&lp->mii_if); spin_unlock_irqrestore(&lp->lock, flags); } return r; }
false
false
false
false
false
0
forward(double mult) { if(active) { if(expl) { explosiontime+=mult; if(explosiontime>(timeToGo-0.001)) explosiontime=timeToGo-0.01; setFrame((int)explosiontime); } } else { activateTime-=(double)mult; if(activateTime<0.0) { active=true; setFrame(1); } } if(fuel<0.001) MobileSprite::forward(mult); }
false
false
false
false
false
0
AVCBinWriteArc(AVCBinFile *psFile, AVCArc *psArc) { if (psFile->eFileType != AVCFileARC) return -1; return _AVCBinWriteArc(psFile->psRawBinFile, psArc, psFile->nPrecision, psFile->psIndexFile); }
false
false
false
false
false
0
gf_sk_accept(GF_Socket *sock, GF_Socket **newConnection) { u32 client_address_size; SOCKET sk; #ifndef __SYMBIAN32__ s32 ready; struct timeval timeout; fd_set Group; #endif *newConnection = NULL; if (!sock || !(sock->flags & GF_SOCK_IS_LISTENING) ) return GF_BAD_PARAM; #ifndef __SYMBIAN32__ //can we read? FD_ZERO(&Group); FD_SET(sock->socket, &Group); timeout.tv_sec = 0; timeout.tv_usec = SOCK_MICROSEC_WAIT; ready = select(sock->socket+1, &Group, NULL, NULL, &timeout); if (ready == SOCKET_ERROR) { switch (LASTSOCKERROR) { case EAGAIN: return GF_IP_SOCK_WOULD_BLOCK; default: return GF_IP_NETWORK_FAILURE; } } if (!ready || !FD_ISSET(sock->socket, &Group)) return GF_IP_NETWORK_EMPTY; #endif #ifdef GPAC_HAS_IPV6 client_address_size = sizeof(struct sockaddr_in6); #else client_address_size = sizeof(struct sockaddr_in); #endif sk = accept(sock->socket, (struct sockaddr *) &sock->dest_addr, &client_address_size); //we either have an error or we have no connections if (sk == INVALID_SOCKET) { // if (sock->flags & GF_SOCK_NON_BLOCKING) return GF_IP_NETWORK_FAILURE; switch (LASTSOCKERROR) { case EAGAIN: return GF_IP_SOCK_WOULD_BLOCK; default: return GF_IP_NETWORK_FAILURE; } } (*newConnection) = (GF_Socket *) gf_malloc(sizeof(GF_Socket)); (*newConnection)->socket = sk; (*newConnection)->flags = sock->flags & ~GF_SOCK_IS_LISTENING; #ifdef GPAC_HAS_IPV6 memcpy( &(*newConnection)->dest_addr, &sock->dest_addr, client_address_size); memset(&sock->dest_addr, 0, sizeof(struct sockaddr_in6)); #else memcpy( &(*newConnection)->dest_addr, &sock->dest_addr, client_address_size); memset(&sock->dest_addr, 0, sizeof(struct sockaddr_in)); #endif #if defined(WIN32) || defined(_WIN32_WCE) wsa_init++; #endif (*newConnection)->dest_addr_len = client_address_size; return GF_OK; }
false
false
false
false
false
0
build_x_compound_expr_from_vec (vec<tree, va_gc> *vec, const char *msg, tsubst_flags_t complain) { if (vec_safe_is_empty (vec)) return NULL_TREE; else if (vec->length () == 1) return (*vec)[0]; else { tree expr; unsigned int ix; tree t; if (msg != NULL) { if (complain & tf_error) permerror (input_location, "%s expression list treated as compound expression", msg); else return error_mark_node; } expr = (*vec)[0]; for (ix = 1; vec->iterate (ix, &t); ++ix) expr = build_x_compound_expr (EXPR_LOCATION (t), expr, t, complain); return expr; } }
false
false
false
false
false
0
scsi_alloc_sdev(struct scsi_target *starget, u64 lun, void *hostdata) { struct scsi_device *sdev; int display_failure_msg = 1, ret; struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); extern void scsi_evt_thread(struct work_struct *work); extern void scsi_requeue_run_queue(struct work_struct *work); sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size, GFP_ATOMIC); if (!sdev) goto out; sdev->vendor = scsi_null_device_strs; sdev->model = scsi_null_device_strs; sdev->rev = scsi_null_device_strs; sdev->host = shost; sdev->queue_ramp_up_period = SCSI_DEFAULT_RAMP_UP_PERIOD; sdev->id = starget->id; sdev->lun = lun; sdev->channel = starget->channel; sdev->sdev_state = SDEV_CREATED; INIT_LIST_HEAD(&sdev->siblings); INIT_LIST_HEAD(&sdev->same_target_siblings); INIT_LIST_HEAD(&sdev->cmd_list); INIT_LIST_HEAD(&sdev->starved_entry); INIT_LIST_HEAD(&sdev->event_list); spin_lock_init(&sdev->list_lock); INIT_WORK(&sdev->event_work, scsi_evt_thread); INIT_WORK(&sdev->requeue_work, scsi_requeue_run_queue); sdev->sdev_gendev.parent = get_device(&starget->dev); sdev->sdev_target = starget; /* usually NULL and set by ->slave_alloc instead */ sdev->hostdata = hostdata; /* if the device needs this changing, it may do so in the * slave_configure function */ sdev->max_device_blocked = SCSI_DEFAULT_DEVICE_BLOCKED; /* * Some low level driver could use device->type */ sdev->type = -1; /* * Assume that the device will have handshaking problems, * and then fix this field later if it turns out it * doesn't */ sdev->borken = 1; if (shost_use_blk_mq(shost)) sdev->request_queue = scsi_mq_alloc_queue(sdev); else sdev->request_queue = scsi_alloc_queue(sdev); if (!sdev->request_queue) { /* release fn is set up in scsi_sysfs_device_initialise, so * have to free and put manually here */ put_device(&starget->dev); kfree(sdev); goto out; } WARN_ON_ONCE(!blk_get_queue(sdev->request_queue)); sdev->request_queue->queuedata = sdev; if (!shost_use_blk_mq(sdev->host)) { blk_queue_init_tags(sdev->request_queue, sdev->host->cmd_per_lun, shost->bqt, shost->hostt->tag_alloc_policy); } scsi_change_queue_depth(sdev, sdev->host->cmd_per_lun ? sdev->host->cmd_per_lun : 1); scsi_sysfs_device_initialize(sdev); if (shost->hostt->slave_alloc) { ret = shost->hostt->slave_alloc(sdev); if (ret) { /* * if LLDD reports slave not present, don't clutter * console with alloc failure messages */ if (ret == -ENXIO) display_failure_msg = 0; goto out_device_destroy; } } return sdev; out_device_destroy: __scsi_remove_device(sdev); out: if (display_failure_msg) printk(ALLOC_FAILURE_MSG, __func__); return NULL; }
false
false
false
false
false
0
RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); vtkHierarchicalBoxDataSet *input = vtkHierarchicalBoxDataSet::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT())); if (!input) {return 0;} vtkInformation* info = outputVector->GetInformationObject(0); vtkHierarchicalBoxDataSet *output = vtkHierarchicalBoxDataSet::SafeDownCast( info->Get(vtkDataObject::DATA_OBJECT())); if (!output) {return 0;} unsigned int numLevels = input->GetNumberOfLevels(); output->SetNumberOfLevels(numLevels); // copy level meta data. for (unsigned int cc=0; cc < numLevels; cc++) { if (input->HasLevelMetaData(cc)) { output->GetLevelMetaData(cc)->Copy(input->GetLevelMetaData(cc)); } } unsigned int last_level = 0; vtkExtractLevel::vtkSet::iterator iter; for (iter = this->Levels->begin(); iter != this->Levels->end(); ++iter) { unsigned int level = (*iter); last_level = level; unsigned int numDataSets = input->GetNumberOfDataSets(level); output->SetNumberOfDataSets(level, numDataSets); for (unsigned int kk = 0; kk < numDataSets; kk++) { // Copy meta data. if (input->HasMetaData(level, kk)) { vtkInformation* copy = output->GetMetaData(level, kk); copy->Copy(input->GetMetaData(level, kk)); } // Copy data object. vtkAMRBox box; vtkUniformGrid* data = input->GetDataSet(level, kk, box); if (data) { vtkUniformGrid* copy = data->NewInstance(); copy->ShallowCopy(data); output->SetDataSet(level, kk, box, copy); copy->Delete(); } else { output->SetDataSet(level, kk, box, NULL); } } } // Last levelfshould not be blanked (uniform grid only) unsigned int numDataSets = output->GetNumberOfDataSets(last_level); for (unsigned int nn=0; nn < numDataSets; nn++) { vtkAMRBox temp; vtkUniformGrid* ug = vtkUniformGrid::SafeDownCast( output->GetDataSet(numLevels-1, nn, temp)); if (ug) { ug->SetCellVisibilityArray(0); } } return 1; }
false
false
false
false
false
0
mct_decode_real( float* restrict c0, float* restrict c1, float* restrict c2, int n) { int i; #ifdef __SSE__ __m128 vrv, vgu, vgv, vbu; vrv = _mm_set1_ps(1.402f); vgu = _mm_set1_ps(0.34413f); vgv = _mm_set1_ps(0.71414f); vbu = _mm_set1_ps(1.772f); for (i = 0; i < (n >> 3); ++i) { __m128 vy, vu, vv; __m128 vr, vg, vb; vy = _mm_load_ps(c0); vu = _mm_load_ps(c1); vv = _mm_load_ps(c2); vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); _mm_store_ps(c0, vr); _mm_store_ps(c1, vg); _mm_store_ps(c2, vb); c0 += 4; c1 += 4; c2 += 4; vy = _mm_load_ps(c0); vu = _mm_load_ps(c1); vv = _mm_load_ps(c2); vr = _mm_add_ps(vy, _mm_mul_ps(vv, vrv)); vg = _mm_sub_ps(_mm_sub_ps(vy, _mm_mul_ps(vu, vgu)), _mm_mul_ps(vv, vgv)); vb = _mm_add_ps(vy, _mm_mul_ps(vu, vbu)); _mm_store_ps(c0, vr); _mm_store_ps(c1, vg); _mm_store_ps(c2, vb); c0 += 4; c1 += 4; c2 += 4; } n &= 7; #endif for(i = 0; i < n; ++i) { float y = c0[i]; float u = c1[i]; float v = c2[i]; float r = y + (v * 1.402f); float g = y - (u * 0.34413f) - (v * (0.71414f)); float b = y + (u * 1.772f); c0[i] = r; c1[i] = g; c2[i] = b; } }
false
false
false
false
false
0
_PyLong_FromBytes(const char *s, Py_ssize_t len, int base) { PyObject *result, *strobj; char *end = NULL; result = PyLong_FromString((char*)s, &end, base); if (end == NULL || (result != NULL && end == s + len)) return result; Py_XDECREF(result); strobj = PyBytes_FromStringAndSize(s, Py_MIN(len, 200)); if (strobj != NULL) { PyErr_Format(PyExc_ValueError, "invalid literal for int() with base %d: %.200R", base, strobj); Py_DECREF(strobj); } return NULL; }
false
false
false
false
false
0
igb_link_test(struct igb_adapter *adapter, u64 *data) { struct e1000_hw *hw = &adapter->hw; *data = 0; if (hw->phy.media_type == e1000_media_type_internal_serdes) { int i = 0; hw->mac.serdes_has_link = false; /* On some blade server designs, link establishment * could take as long as 2-3 minutes */ do { hw->mac.ops.check_for_link(&adapter->hw); if (hw->mac.serdes_has_link) return *data; msleep(20); } while (i++ < 3750); *data = 1; } else { hw->mac.ops.check_for_link(&adapter->hw); if (hw->mac.autoneg) msleep(5000); if (!(rd32(E1000_STATUS) & E1000_STATUS_LU)) *data = 1; } return *data; }
false
false
false
false
false
0
unit_betray(int unitRecno, int betrayToNationRecno) { Unit* unitPtr = unit_array[unitRecno]; err_when( unitPtr->nation_recno != nation_array.player_recno && betrayToNationRecno != nation_array.player_recno ); News* newsPtr = add_news( NEWS_UNIT_BETRAY, NEWS_NORMAL, unitPtr->nation_recno, betrayToNationRecno ); if( !newsPtr ) // only news of nations that have contact with the player are added return; newsPtr->short_para1 = unitPtr->race_id; newsPtr->short_para2 = unitPtr->name_id; newsPtr->short_para3 = unitPtr->rank_id; //------- set location --------// if( betrayToNationRecno == nation_array.player_recno ) newsPtr->set_loc( unitPtr->next_x_loc(), unitPtr->next_y_loc(), NEWS_LOC_UNIT, unitRecno, unitPtr->name_id ); else newsPtr->set_loc( unitPtr->next_x_loc(), unitPtr->next_y_loc(), NEWS_LOC_ANY ); }
false
false
false
false
false
0
tls_get_addr_tail (GET_ADDR_ARGS, dtv_t *dtv, struct link_map *the_map) { /* The allocation was deferred. Do it now. */ if (the_map == NULL) { /* Find the link map for this module. */ size_t idx = GET_ADDR_MODULE; struct dtv_slotinfo_list *listp = GL(dl_tls_dtv_slotinfo_list); while (idx >= listp->len) { idx -= listp->len; listp = listp->next; } the_map = listp->slotinfo[idx].map; } again: /* Make sure that, if a dlopen running in parallel forces the variable into static storage, we'll wait until the address in the static TLS block is set up, and use that. If we're undecided yet, make sure we make the decision holding the lock as well. */ if (__builtin_expect (the_map->l_tls_offset != FORCED_DYNAMIC_TLS_OFFSET, 0)) { __rtld_lock_lock_recursive (GL(dl_load_lock)); if (__builtin_expect (the_map->l_tls_offset == NO_TLS_OFFSET, 1)) { the_map->l_tls_offset = FORCED_DYNAMIC_TLS_OFFSET; __rtld_lock_unlock_recursive (GL(dl_load_lock)); } else { __rtld_lock_unlock_recursive (GL(dl_load_lock)); if (__builtin_expect (the_map->l_tls_offset != FORCED_DYNAMIC_TLS_OFFSET, 1)) { void *p = dtv[GET_ADDR_MODULE].pointer.val; if (__builtin_expect (p == TLS_DTV_UNALLOCATED, 0)) goto again; return (char *) p + GET_ADDR_OFFSET; } } } void *p = dtv[GET_ADDR_MODULE].pointer.val = allocate_and_init (the_map); dtv[GET_ADDR_MODULE].pointer.is_static = false; return (char *) p + GET_ADDR_OFFSET; }
false
false
false
false
false
0
tree_view_restore_widths(GtkTreeView *treeview, property_t prop) { gint i; g_return_if_fail(treeview); for (i = 0; i < INT_MAX; i++) { GtkTreeViewColumn *c; guint32 width; c = gtk_tree_view_get_column(treeview, i); if (!c) break; gui_prop_get_guint32(prop, &width, i, 1); g_object_set(G_OBJECT(c), "fixed-width", MAX(1, (gint32) width), (void *) 0); } }
false
false
false
false
false
0
_gtk_window_resize_to_fit_screen_height (GtkWidget *window, int default_width) { GdkScreen *screen; screen = gtk_widget_get_screen (window); if ((screen != NULL) && (gdk_screen_get_height (screen) < 768)) /* maximize on netbooks */ gtk_window_maximize (GTK_WINDOW (window)); else /* This should fit on a XGA/WXGA (height 768) screen * with top and bottom panels */ gtk_window_set_default_size (GTK_WINDOW (window), default_width, 670); }
false
false
false
false
false
0
cx231xx_write_i2c_data(struct cx231xx *dev, u8 dev_addr, u16 saddr, u8 saddr_len, u32 data, u8 data_len) { int status = 0; u8 value[4] = { 0, 0, 0, 0 }; struct cx231xx_i2c_xfer_data req_data; value[0] = (u8) data; value[1] = (u8) (data >> 8); value[2] = (u8) (data >> 16); value[3] = (u8) (data >> 24); if (saddr_len == 0) saddr = 0; else if (saddr_len == 1) saddr &= 0xff; /* prepare xfer_data struct */ req_data.dev_addr = dev_addr >> 1; req_data.direction = 0; req_data.saddr_len = saddr_len; req_data.saddr_dat = saddr; req_data.buf_size = data_len; req_data.p_buffer = value; /* usb send command */ status = dev->cx231xx_send_usb_command(&dev->i2c_bus[0], &req_data); return status; }
false
false
false
false
false
0
isPipe(FILE *p) { int i; for (i = 0; i < numPipes && Pipe[i] != p; i++); if (i == numPipes) return FALSE; Pipe[i] = Pipe[--numPipes]; return TRUE; }
false
false
false
false
true
1
enic_unset_port_profile(struct enic *enic, int vf) { int err; ENIC_DEVCMD_PROXY_BY_INDEX(vf, err, enic, vnic_dev_deinit); if (err) return enic_dev_status_to_errno(err); if (vf == PORT_SELF_VF) enic_reset_addr_lists(enic); return 0; }
false
false
false
false
false
0
ecolor(ECOLOR color) { FILE *f = stdout; /* Try and guess a valid tty */ if (!isatty(fileno(f))) { f = stderr; if (!isatty(fileno(f))) { f = stdin; if (!isatty(fileno(f))) f = NULL; } } return _ecolor(f, color); }
false
false
false
false
false
0
adjust_panel_help(int y, int x, bool help) { bool changed = FALSE; int j; int screen_hgt_main = help ? (Term->hgt - ROW_MAP - 3) : (Term->hgt - ROW_MAP - 1); /* Scan windows */ for (j = 0; j < ANGBAND_TERM_MAX; j++) { int wx, wy; int screen_hgt, screen_wid; term *t = angband_term[j]; /* No window */ if (!t) continue; /* No relevant flags */ if ((j > 0) && !(op_ptr->window_flag[j] & PW_MAP)) continue; wy = t->offset_y; wx = t->offset_x; screen_hgt = (j == 0) ? screen_hgt_main : t->hgt; screen_wid = (j == 0) ? (Term->wid - COL_MAP - 1) : t->wid; /* Bigtile panels need adjustment */ screen_wid = screen_wid / tile_width; screen_hgt = screen_hgt / tile_height; /* Adjust as needed */ while (y >= wy + screen_hgt) wy += screen_hgt / 2; while (y < wy) wy -= screen_hgt / 2; /* Adjust as needed */ while (x >= wx + screen_wid) wx += screen_wid / 2; while (x < wx) wx -= screen_wid / 2; /* Use "modify_panel" */ if (modify_panel(t, wy, wx)) changed = TRUE; } return (changed); }
false
false
false
false
false
0
sortDecrIndex() { // Should replace with std sort double * elements = new double [nElements_]; CoinZeroN (elements,nElements_); CoinSort_2(indices_, indices_ + nElements_, elements, CoinFirstGreater_2<int, double>()); delete [] elements; }
false
false
false
false
false
0
ms_biff_put_len_next (BiffPut *bp, guint16 opcode, guint32 len) { g_return_val_if_fail (bp, NULL); g_return_val_if_fail (bp->output, NULL); g_return_val_if_fail (bp->data == NULL, NULL); g_return_val_if_fail (bp->len_fixed == -1, NULL); if (bp->version >= MS_BIFF_V8) XL_CHECK_CONDITION_VAL (len < MAX_BIFF8_RECORD_SIZE, NULL); else XL_CHECK_CONDITION_VAL (len < MAX_BIFF7_RECORD_SIZE, NULL); #if BIFF_DEBUG > 0 g_printerr ("Biff put len 0x%x\n", opcode); #endif bp->len_fixed = +1; bp->opcode = opcode; bp->length = len; bp->streamPos = gsf_output_tell (bp->output); if (len > 0) { bp->data = g_new (guint8, len); bp->data_malloced = TRUE; } return bp->data; }
false
false
false
false
false
0
e_map_do_tween_cb (gpointer data) { EMap *map = data; GSList *walk; map->priv->timer_current_ms = g_timer_elapsed (map->priv->timer, NULL) * 1000; gtk_widget_queue_draw (GTK_WIDGET (map)); /* Can't use for loop here, because we need to advance * the list before deleting. */ walk = map->priv->tweens; while (walk) { EMapTween *tween = walk->data; walk = walk->next; if (tween->end_time <= map->priv->timer_current_ms) e_map_tween_destroy (map, tween); } return TRUE; }
false
false
false
false
false
0
FindNode_TxtorPos( s ) char *s; { long x, y; tptr t; if( sscanf( &s[3], "%ld,%ld", &x, &y ) != 2 ) return( NULL ); if( (t = FindTxtorPos( x, y )) == NULL ) return( NULL ); switch( s[2] ) { case 'g': return( t->gate ); case 'd': return( t->drain ); case 's': return( t->source ); } return( NULL ); }
false
false
false
false
false
0
RemoveFromWorld() { ///- Remove the gameobject from the accessor if (IsInWorld()) { // Notify the outdoor pvp script if (OutdoorPvP* outdoorPvP = sOutdoorPvPMgr.GetScript(GetZoneId())) outdoorPvP->HandleGameObjectRemove(this); // Remove GO from owner if (ObjectGuid owner_guid = GetOwnerGuid()) { if (Unit* owner = ObjectAccessor::GetUnit(*this, owner_guid)) owner->RemoveGameObject(this, false); else { sLog.outError("Delete %s with SpellId %u LinkedGO %u that lost references to owner %s GO list. Crash possible later.", GetGuidStr().c_str(), m_spellId, GetGOInfo()->GetLinkedGameObjectEntry(), owner_guid.GetString().c_str()); } } if (m_model && GetMap()->ContainsGameObjectModel(*m_model)) GetMap()->RemoveGameObjectModel(*m_model); GetMap()->GetObjectsStore().erase<GameObject>(GetObjectGuid(), (GameObject*)NULL); } Object::RemoveFromWorld(); }
false
false
false
false
false
0
ST_drawNumFontY(int x, int y, int num) { if(!num) V_DrawPatch(x, y, invfonty[0]); while(num) { V_DrawPatch(x, y, invfonty[num % 10]); x -= SHORT(invfonty[0]->width) + 1; num /= 10; } }
false
false
false
false
false
0
nonce_nonceg_create() { private_nonce_nonceg_t *this; INIT(this, .public = { .nonce_gen = { .get_nonce = _get_nonce, .allocate_nonce = _allocate_nonce, .destroy = _destroy, }, }, ); this->rng = lib->crypto->create_rng(lib->crypto, RNG_WEAK); if (!this->rng) { DBG1(DBG_LIB, "no RNG found for quality %N", rng_quality_names, RNG_WEAK); destroy(this); return NULL; } return &this->public; }
false
false
false
false
false
0
ReportRegExpErrorHelper(CompilerState *state, uintN flags, uintN errorNumber, const jschar *arg) { if (state->tokenStream) { return js_ReportCompileErrorNumber(state->context, state->tokenStream, NULL, JSREPORT_UC | flags, errorNumber, arg); } return JS_ReportErrorFlagsAndNumberUC(state->context, flags, js_GetErrorMessage, NULL, errorNumber, arg); }
false
false
false
false
false
0
info_exists_command( Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl ){ int rc; if( argc!=3 ){ return Th_WrongNumArgs(interp, "info exists var"); } rc = Th_ExistsVar(interp, argv[2], argl[2]); Th_SetResultInt(interp, rc); return TH_OK; }
false
false
false
false
false
0
snmpTargetAddr_addTagList(struct targetAddrTable_struct *entry, char *cptr) { if (cptr == NULL) { DEBUGMSGTL(("snmpTargetAddrEntry", "ERROR snmpTargetAddrEntry: no tag list in config string\n")); return (0); } else { size_t len = strlen(cptr); /* * spec check for string 0-255 */ if (len > 255) { DEBUGMSGTL(("snmpTargetAddrEntry", "ERROR snmpTargetAddrEntry: tag list out of range in config string\n")); return (0); } SNMP_FREE(entry->tagList); entry->tagList = (char *) malloc(len + 1); strncpy(entry->tagList, cptr, len); entry->tagList[len] = '\0'; } return (1); }
false
false
false
false
false
0
AddCompositionOffset(GF_CompositionOffsetBox *ctts, u32 offset) { if (!ctts) return GF_BAD_PARAM; if (ctts->nb_entries && (ctts->entries[ctts->nb_entries-1].decodingOffset==offset)) { ctts->entries[ctts->nb_entries-1].sampleCount++; } else { if (ctts->alloc_size==ctts->nb_entries) { ALLOC_INC(ctts->alloc_size); ctts->entries = gf_realloc(ctts->entries, sizeof(GF_DttsEntry)*ctts->alloc_size); if (!ctts->entries) return GF_OUT_OF_MEM; memset(&ctts->entries[ctts->nb_entries], 0, sizeof(GF_DttsEntry)*(ctts->alloc_size-ctts->nb_entries) ); } ctts->entries[ctts->nb_entries].decodingOffset = offset; ctts->entries[ctts->nb_entries].sampleCount = 1; ctts->nb_entries++; } ctts->w_LastSampleNumber++; return GF_OK; }
false
false
false
true
false
1
getCurrentDateTime(OFString &dicomDateTime, const OFBool seconds, const OFBool fraction, const OFBool timeZone) { OFCondition l_error = EC_IllegalCall; OFDateTime dateTimeValue; /* get the current system time */ if (dateTimeValue.setCurrentDateTime()) { /* format: YYYYMMDDHHMM[SS[.FFFFFF]] */ if (dateTimeValue.getISOFormattedDateTime(dicomDateTime, seconds, fraction, timeZone, OFFalse /*showDelimiter*/)) l_error = EC_Normal; } /* set default date/time if an error occurred */ if (l_error.bad()) { /* format: YYYYMMDDHHMM */ dicomDateTime = "190001010000"; if (seconds) { /* format: SS */ dicomDateTime += "00"; if (fraction) { /* format: .FFFFFF */ dicomDateTime += ".000000"; } } if (timeZone) { /* format: CHHMM */ dicomDateTime += "+0000"; } } return l_error; }
false
false
false
false
false
0
cpl_table_copy_structure(cpl_table *table, const cpl_table *mtable) { const char *unit = NULL; const char *form = NULL; cpl_column **column; cpl_type type; cpl_size width = cpl_table_get_ncol(mtable); cpl_size i = 0; if (table == 0x0 || mtable == 0x0) return cpl_error_set_(CPL_ERROR_NULL_INPUT); if (table->nc > 0) return cpl_error_set_(CPL_ERROR_ILLEGAL_INPUT); column = mtable->columns; for (i = 0; i < width; i++, column++) { type = cpl_column_get_type(*column); unit = cpl_column_get_unit(*column); form = cpl_column_get_format(*column); if (type & CPL_TYPE_POINTER) { cpl_table_new_column_array(table, cpl_column_get_name(*column), type, cpl_column_get_depth(*column)); } else { cpl_table_new_column(table, cpl_column_get_name(*column), type); } cpl_table_set_column_unit(table, cpl_column_get_name(*column), unit); cpl_table_set_column_format(table, cpl_column_get_name(*column), form); } return CPL_ERROR_NONE; }
false
false
false
false
false
0
alps_command_mode_read_reg(struct psmouse *psmouse, int addr) { if (alps_command_mode_set_addr(psmouse, addr)) return -1; return __alps_command_mode_read_reg(psmouse, addr); }
false
false
false
false
false
0
skipspace(scheme *sc) { int c; while (isspace(c=inchar(sc))) ; if(c!=EOF) { backchar(sc,c); } }
false
false
false
false
false
0
amitk_objects_unref(GList * objects) { AmitkObject * object; if (objects == NULL) return NULL; objects->next = amitk_objects_unref(objects->next); /* recurse */ g_return_val_if_fail(AMITK_IS_OBJECT(objects->data), NULL); object = objects->data; objects = g_list_remove(objects, object); /* should return NULL */ amitk_object_unref(object); return NULL; }
false
false
false
false
false
0
_pick_idle_node_cnt(bitstr_t *avail_bitmap, resv_desc_msg_t *resv_desc_ptr, uint32_t node_cnt, bitstr_t **core_bitmap) { ListIterator job_iterator; struct job_record *job_ptr; bitstr_t *save_bitmap, *ret_bitmap, *tmp_bitmap; if (bit_set_count(avail_bitmap) < node_cnt) { verbose("reservation requests more nodes than are available"); return NULL; } save_bitmap = bit_copy(avail_bitmap); bit_or(avail_bitmap, save_bitmap); /* restore avail_bitmap */ job_iterator = list_iterator_create(job_list); if (job_iterator == NULL) fatal("list_iterator_create: malloc failure"); while ((job_ptr = (struct job_record *) list_next(job_iterator))) { if (!IS_JOB_RUNNING(job_ptr) && !IS_JOB_SUSPENDED(job_ptr)) continue; if (job_ptr->end_time < resv_desc_ptr->start_time) continue; if (resv_desc_ptr->core_cnt == 0) { bit_not(job_ptr->node_bitmap); bit_and(avail_bitmap, job_ptr->node_bitmap); bit_not(job_ptr->node_bitmap); } else { _check_job_compatibility(job_ptr, avail_bitmap, core_bitmap); } } list_iterator_destroy(job_iterator); ret_bitmap = select_g_resv_test(avail_bitmap, node_cnt, resv_desc_ptr->core_cnt, core_bitmap); if (ret_bitmap) goto fini; /* Next: Try to reserve nodes that will be allocated to a limited * number of running jobs. We could sort the jobs by priority, QOS, * size or other criterion if desired. Right now we just go down * the unsorted job list. */ if (resv_desc_ptr->flags & RESERVE_FLAG_IGN_JOBS) { job_iterator = list_iterator_create(job_list); if (!job_iterator) fatal("list_iterator_create: malloc failure"); while ((job_ptr = (struct job_record *) list_next(job_iterator))) { if (!IS_JOB_RUNNING(job_ptr) && !IS_JOB_SUSPENDED(job_ptr)) continue; if (job_ptr->end_time < resv_desc_ptr->start_time) continue; tmp_bitmap = bit_copy(save_bitmap); bit_and(tmp_bitmap, job_ptr->node_bitmap); if (bit_set_count(tmp_bitmap) > 0) { bit_or(avail_bitmap, tmp_bitmap); ret_bitmap = select_g_resv_test(avail_bitmap, node_cnt, resv_desc_ptr->core_cnt, core_bitmap); } FREE_NULL_BITMAP(tmp_bitmap); if (ret_bitmap) break; } list_iterator_destroy(job_iterator); } fini: FREE_NULL_BITMAP(save_bitmap); #if 0 if (ret_bitmap) { char str[300]; bit_fmt(str, (sizeof(str) - 1), ret_bitmap); info("pick_idle_nodes getting %s from select cons_res", str); if (*core_bitmap) { bit_fmt(str, (sizeof(str) - 1), *core_bitmap); info("pick_idle_nodes getting core_cnt:%d coremap:%s " "from select/cons_res", resv_desc_ptr->core_cnt, str); } } #endif return ret_bitmap; }
false
false
false
false
false
0
new_performance_monitor(struct gl_context *ctx, GLuint index) { unsigned i; struct gl_perf_monitor_object *m = ctx->Driver.NewPerfMonitor(ctx); if (m == NULL) return NULL; m->Name = index; m->Active = false; m->ActiveGroups = rzalloc_array(NULL, unsigned, ctx->PerfMonitor.NumGroups); m->ActiveCounters = ralloc_array(NULL, BITSET_WORD *, ctx->PerfMonitor.NumGroups); if (m->ActiveGroups == NULL || m->ActiveCounters == NULL) goto fail; for (i = 0; i < ctx->PerfMonitor.NumGroups; i++) { const struct gl_perf_monitor_group *g = &ctx->PerfMonitor.Groups[i]; m->ActiveCounters[i] = rzalloc_array(m->ActiveCounters, BITSET_WORD, BITSET_WORDS(g->NumCounters)); if (m->ActiveCounters[i] == NULL) goto fail; } return m; fail: ralloc_free(m->ActiveGroups); ralloc_free(m->ActiveCounters); ctx->Driver.DeletePerfMonitor(ctx, m); return NULL; }
false
false
false
false
false
0
brcmf_fweh_event_worker(struct work_struct *work) { struct brcmf_pub *drvr; struct brcmf_if *ifp; struct brcmf_fweh_info *fweh; struct brcmf_fweh_queue_item *event; int err = 0; struct brcmf_event_msg_be *emsg_be; struct brcmf_event_msg emsg; fweh = container_of(work, struct brcmf_fweh_info, event_work); drvr = container_of(fweh, struct brcmf_pub, fweh); while ((event = brcmf_fweh_dequeue_event(fweh))) { brcmf_dbg(EVENT, "event %s (%u) ifidx %u bsscfg %u addr %pM\n", brcmf_fweh_event_name(event->code), event->code, event->emsg.ifidx, event->emsg.bsscfgidx, event->emsg.addr); /* convert event message */ emsg_be = &event->emsg; emsg.version = be16_to_cpu(emsg_be->version); emsg.flags = be16_to_cpu(emsg_be->flags); emsg.event_code = event->code; emsg.status = be32_to_cpu(emsg_be->status); emsg.reason = be32_to_cpu(emsg_be->reason); emsg.auth_type = be32_to_cpu(emsg_be->auth_type); emsg.datalen = be32_to_cpu(emsg_be->datalen); memcpy(emsg.addr, emsg_be->addr, ETH_ALEN); memcpy(emsg.ifname, emsg_be->ifname, sizeof(emsg.ifname)); emsg.ifidx = emsg_be->ifidx; emsg.bsscfgidx = emsg_be->bsscfgidx; brcmf_dbg(EVENT, " version %u flags %u status %u reason %u\n", emsg.version, emsg.flags, emsg.status, emsg.reason); brcmf_dbg_hex_dump(BRCMF_EVENT_ON(), event->data, min_t(u32, emsg.datalen, 64), "event payload, len=%d\n", emsg.datalen); /* special handling of interface event */ if (event->code == BRCMF_E_IF) { brcmf_fweh_handle_if_event(drvr, &emsg, event->data); goto event_free; } if (event->code == BRCMF_E_TDLS_PEER_EVENT) ifp = drvr->iflist[0]; else ifp = drvr->iflist[emsg.bsscfgidx]; err = brcmf_fweh_call_event_handler(ifp, event->code, &emsg, event->data); if (err) { brcmf_err("event handler failed (%d)\n", event->code); err = 0; } event_free: kfree(event); } }
false
false
false
false
false
0
dump_data_dependence_relation (FILE *outf, struct data_dependence_relation *ddr) { struct data_reference *dra, *drb; fprintf (outf, "(Data Dep: \n"); if (!ddr || DDR_ARE_DEPENDENT (ddr) == chrec_dont_know) { if (ddr) { dra = DDR_A (ddr); drb = DDR_B (ddr); if (dra) dump_data_reference (outf, dra); else fprintf (outf, " (nil)\n"); if (drb) dump_data_reference (outf, drb); else fprintf (outf, " (nil)\n"); } fprintf (outf, " (don't know)\n)\n"); return; } dra = DDR_A (ddr); drb = DDR_B (ddr); dump_data_reference (outf, dra); dump_data_reference (outf, drb); if (DDR_ARE_DEPENDENT (ddr) == chrec_known) fprintf (outf, " (no dependence)\n"); else if (DDR_ARE_DEPENDENT (ddr) == NULL_TREE) { unsigned int i; struct loop *loopi; for (i = 0; i < DDR_NUM_SUBSCRIPTS (ddr); i++) { fprintf (outf, " access_fn_A: "); print_generic_stmt (outf, DR_ACCESS_FN (dra, i), 0); fprintf (outf, " access_fn_B: "); print_generic_stmt (outf, DR_ACCESS_FN (drb, i), 0); dump_subscript (outf, DDR_SUBSCRIPT (ddr, i)); } fprintf (outf, " inner loop index: %d\n", DDR_INNER_LOOP (ddr)); fprintf (outf, " loop nest: ("); FOR_EACH_VEC_ELT (DDR_LOOP_NEST (ddr), i, loopi) fprintf (outf, "%d ", loopi->num); fprintf (outf, ")\n"); for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++) { fprintf (outf, " distance_vector: "); print_lambda_vector (outf, DDR_DIST_VECT (ddr, i), DDR_NB_LOOPS (ddr)); } for (i = 0; i < DDR_NUM_DIR_VECTS (ddr); i++) { fprintf (outf, " direction_vector: "); print_direction_vector (outf, DDR_DIR_VECT (ddr, i), DDR_NB_LOOPS (ddr)); } } fprintf (outf, ")\n"); }
false
false
false
false
false
0
process_events(void){ Arc::Time now; event_lock.lock(); for (std::list<DTR_ptr>::iterator event = events.begin(); event != events.end();) { DTR_ptr tmp = *event; event_lock.unlock(); if (tmp->get_process_time() <= now) { map_state_and_process(tmp); // If final state, the DTR is returned to the generator and deleted if (tmp->is_in_final_state()) { ProcessDTRFINAL_STATE(tmp); event_lock.lock(); event = events.erase(event); continue; } // If the event was sent on to a queue, erase it from the list if (tmp->is_destined_for_pre_processor() || tmp->is_destined_for_delivery() || tmp->is_destined_for_post_processor()) { event_lock.lock(); event = events.erase(event); continue; } } event_lock.lock(); ++event; } event_lock.unlock(); }
false
false
false
false
false
0
brasero_file_node_move_to (BraseroFileNode *node, BraseroFileNode *parent, GCompareFunc sort_func) { BraseroFileTreeStats *stats; guint depth = 0; /* NOTE: for the time being no backend supports moving imported files */ if (node->is_imported) return; /* reinsert it now at the new location */ parent->union2.children = brasero_file_node_insert (BRASERO_FILE_NODE_CHILDREN (parent), node, sort_func, NULL); node->parent = parent; if (!node->is_grafted) { BraseroFileNode *parent; /* propagate the size change for new parent */ for (parent = node->parent; parent && !parent->is_root; parent = parent->parent) { parent->union3.sectors += BRASERO_FILE_NODE_SECTORS (node); if (parent->is_grafted) break; } } /* NOTE: here stats about the tree can change if the parent has a depth * > 6 and if previous didn't. Other stats remains unmodified. */ stats = brasero_file_node_get_tree_stats (node->parent, &depth); if (node->is_file) { if (depth < 6) return; } else if (depth < 5) return; stats->num_deep ++; node->is_deep = TRUE; }
false
false
false
false
false
0
cloog_loop_components_tarjan(struct cloog_loop_sort *s, CloogLoop **loop_array, int i, int level, int scalar, int *scaldims, int nb_scattdims, int (*follows)(CloogLoop *loop1, CloogLoop *loop2, int level, int scalar, int *scaldims, int nb_scattdims, int def)) { int j; s->node[i].index = s->index; s->node[i].min_index = s->index; s->node[i].on_stack = 1; s->index++; s->stack[s->sp++] = i; for (j = s->len - 1; j >= 0; --j) { int f; if (j == i) continue; if (s->node[j].index >= 0 && (!s->node[j].on_stack || s->node[j].index > s->node[i].min_index)) continue; f = follows(loop_array[i], loop_array[j], level, scalar, scaldims, nb_scattdims, i > j); if (!f) continue; if (s->node[j].index < 0) { cloog_loop_components_tarjan(s, loop_array, j, level, scalar, scaldims, nb_scattdims, follows); if (s->node[j].min_index < s->node[i].min_index) s->node[i].min_index = s->node[j].min_index; } else if (s->node[j].index < s->node[i].min_index) s->node[i].min_index = s->node[j].index; } if (s->node[i].index != s->node[i].min_index) return; do { j = s->stack[--s->sp]; s->node[j].on_stack = 0; s->order[s->op++] = j; } while (j != i); s->order[s->op++] = -1; }
false
false
false
false
false
0
GetProcParamExpressions( void *theEnv) { register int i; if ((ProceduralPrimitiveData(theEnv)->ProcParamArray == NULL) || (ProceduralPrimitiveData(theEnv)->ProcParamExpressions != NULL)) return(ProceduralPrimitiveData(theEnv)->ProcParamExpressions); ProceduralPrimitiveData(theEnv)->ProcParamExpressions = (EXPRESSION *) gm2(theEnv,(sizeof(EXPRESSION) * ProceduralPrimitiveData(theEnv)->ProcParamArraySize)); for (i = 0 ; i < ProceduralPrimitiveData(theEnv)->ProcParamArraySize ; i++) { ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i].type = ProceduralPrimitiveData(theEnv)->ProcParamArray[i].type; if (ProceduralPrimitiveData(theEnv)->ProcParamArray[i].type != MULTIFIELD) ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i].value = ProceduralPrimitiveData(theEnv)->ProcParamArray[i].value; else ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i].value = (void *) &ProceduralPrimitiveData(theEnv)->ProcParamArray[i]; ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i].argList = NULL; ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i].nextArg = ((i + 1) != ProceduralPrimitiveData(theEnv)->ProcParamArraySize) ? &ProceduralPrimitiveData(theEnv)->ProcParamExpressions[i+1] : NULL; } return(ProceduralPrimitiveData(theEnv)->ProcParamExpressions); }
false
false
false
false
false
0
gamgi_chem_atom_color (gamgi_atom_class *atom_class) { float *red = atom_class->red; float *green = atom_class->green; float *blue = atom_class->blue; int element, offset; /******************************************* * set default color for Dummy atoms (Z=0) * * * * set default color for all elements * *******************************************/ red[GAMGI_CHEM_DU] = GAMGI_CHEM_DU_R; green[GAMGI_CHEM_DU] = GAMGI_CHEM_DU_G; blue[GAMGI_CHEM_DU] = GAMGI_CHEM_DU_B; /************************************** * set all the default element colors * **************************************/ for (element = 1; element <= GAMGI_CHEM_ATOM_MAX; element++) { offset = element - 1; red[element] = gamgi_chem_property_color[3*offset + 0]; green[element] = gamgi_chem_property_color[3*offset + 1]; blue[element] = gamgi_chem_property_color[3*offset + 2]; } }
false
false
false
false
false
0
read(byte* buf, long rcount) { long avail = p_->size_ - p_->idx_; long allow = EXV_MIN(rcount, avail); std::memcpy(buf, &p_->data_[p_->idx_], allow); p_->idx_ += allow; if (rcount > avail) p_->eof_ = true; return allow; }
false
false
false
false
false
0
set_define_list_for_heap(Block *loop, Statement *spt, Define_table *define_heap_list, Define_table *modified_heap_list) { Def_use_table *def_heap; Define_table *temp; Boolean find_heap = FALSE; for(def_heap = spt->def_heap_list; def_heap != NULL; def_heap = def_heap->next){ if (def_heap->mem == MEM_LM) continue; if( array_has_self_equal_dd_vec(loop, def_heap) ) continue; for( temp = define_heap_list; temp->cur_pt; temp = temp->next){ if (temp->cur_pt->entry == def_heap->entry) break; } if (temp->cur_pt == NULL){ temp->next = malloc_Define_table(); temp->next->prev = temp; temp->cur_pt = def_heap; temp->first_def_qpt = def_heap->qpt; temp->first_def_spt = def_heap->qpt->stm; find_heap = TRUE; } } for(def_heap = spt->mod_heap_list; def_heap != NULL; def_heap = def_heap->next){ if (def_heap->mem == MEM_LM) continue; if( array_has_self_equal_dd_vec(loop, def_heap) ) continue; for( temp = define_heap_list; temp->cur_pt; temp = temp->next){ if (temp->cur_pt->entry == def_heap->entry) break; } if (temp->cur_pt == NULL){ temp->next = malloc_Define_table(); temp->next->prev = temp; temp->cur_pt = def_heap; temp->first_def_qpt = def_heap->qpt; temp->first_def_spt = def_heap->qpt->stm; find_heap = TRUE; } } return find_heap; }
false
false
false
false
false
0
AboutConfig( Gtk::Window* parent ) : SKELETON::PrefDiag( parent, "", true ) { CONFIG::bkup_conf(); pack_widgets(); }
false
false
false
false
false
0
lmc_led_off(lmc_softc_t * const sc, u32 led) /*fold00*/ { lmc_trace(sc->lmc_device, "lmc_led_off in"); if(sc->lmc_miireg16 & led){ /* Already set don't do anything */ lmc_trace(sc->lmc_device, "lmc_led_off aoff out"); return; } sc->lmc_miireg16 |= led; lmc_mii_writereg(sc, 0, 16, sc->lmc_miireg16); lmc_trace(sc->lmc_device, "lmc_led_off out"); }
false
false
false
false
false
0
itemDeclaration(const CfgEntry *e, const CfgConfig &cfg) { if (cfg.itemAccessors) return QString(); QString fCap = e->name(); fCap[0] = fCap[0].toUpper(); return " "+cfg.inherits+"::Item"+itemType( e->type() ) + " *item" + fCap + ( (!e->param().isEmpty())?(QString("[%1]").arg(e->paramMax()+1)) : QString()) + ";\n"; }
false
false
false
false
false
0
flat_texgen (double x, double y, double z, int jcnt, int which_end) { if (FRONT == which_end) { T2F_D (x, accum_seg_len); } if (BACK == which_end) { T2F_D (x, accum_seg_len + segment_length); } }
false
false
false
false
false
0
krb5_is_enctype_weak(krb5_context context, krb5_enctype enctype) { struct _krb5_encryption_type *et = _krb5_find_enctype(enctype); if(et == NULL || (et->flags & F_WEAK)) return TRUE; return FALSE; }
false
false
false
false
false
0
insertChild(MSWidget *widget_) { MSLayoutEntry *entry=getEntry(widget_); if (entry==0&&widget_!=0) { entry=new MSLayoutEntry(widget_); entry->at().constraints(widget_->resizeConstraints()); MSNodeItem *np=new MSNodeItem((void *)entry); np->insert(childListHead()); // fifo _childCount++; setDefaultChildPosition(entry); // allow subclasses to set the default position if (widget_->mapped()==MSTrue) childMap(widget_); } }
false
false
false
false
false
0
clk_recalc_rate(struct ccu_data *ccu, struct bcm_clk_div *div, struct bcm_clk_div *pre_div, unsigned long parent_rate) { u64 scaled_parent_rate; u64 scaled_div; u64 result; if (!divider_exists(div)) return parent_rate; if (parent_rate > (unsigned long)LONG_MAX) return 0; /* actually this would be a caller bug */ /* * If there is a pre-divider, divide the scaled parent rate * by the pre-divider value first. In this case--to improve * accuracy--scale the parent rate by *both* the pre-divider * value and the divider before actually computing the * result of the pre-divider. * * If there's only one divider, just scale the parent rate. */ if (pre_div && divider_exists(pre_div)) { u64 scaled_rate; scaled_rate = scale_rate(pre_div, parent_rate); scaled_rate = scale_rate(div, scaled_rate); scaled_div = divider_read_scaled(ccu, pre_div); scaled_parent_rate = DIV_ROUND_CLOSEST_ULL(scaled_rate, scaled_div); } else { scaled_parent_rate = scale_rate(div, parent_rate); } /* * Get the scaled divisor value, and divide the scaled * parent rate by that to determine this clock's resulting * rate. */ scaled_div = divider_read_scaled(ccu, div); result = DIV_ROUND_CLOSEST_ULL(scaled_parent_rate, scaled_div); return (unsigned long)result; }
false
false
false
false
false
0
calib_area_finish (CalibArea *area, XYinfo *new_axis, gboolean *swap_xy) { g_return_val_if_fail (area != NULL, FALSE); *new_axis = area->axis; *swap_xy = area->swap; if (area->success) g_debug ("Final calibration: %d, %d, %d, %d\n", new_axis->x_min, new_axis->y_min, new_axis->x_max, new_axis->y_max); else g_debug ("Calibration was aborted or timed out"); return area->success; }
false
false
false
false
false
0
on_proposal_changed (GtkSourceCompletionProposal *proposal, GList *proposal_node) { ProposalInfo *proposal_info = proposal_node->data; ProviderInfo *provider_info = proposal_info->provider_node->data; if (provider_info->visible) { GtkTreeIter iter; GtkTreePath *path; iter.user_data = proposal_node; path = get_proposal_path (provider_info->model, proposal_node); gtk_tree_model_row_changed (GTK_TREE_MODEL (provider_info->model), path, &iter); gtk_tree_path_free (path); } }
false
false
false
false
false
0
maxima(MaximaStream & os) const { os << "diff("; for (idx_type idx = 0; idx < nargs(); ++idx) { if (idx != 0) os << ','; os << cell(idx); if (idx != 0) os << ",1"; } os << ')'; }
false
false
false
false
false
0
cd_sensor_client_remove (CdSensorClient *sensor_client, GUdevDevice *device) { CdSensor *sensor; const gchar *device_file; const gchar *device_path; const gchar *tmp; guint i; /* interesting device? */ tmp = g_udev_device_get_property (device, "COLORD_SENSOR_KIND"); if (tmp == NULL) goto out; /* actual device? */ device_file = g_udev_device_get_device_file (device); if (device_file == NULL) goto out; /* get data */ device_path = g_udev_device_get_sysfs_path (device); g_debug ("removing color management device: %s [%s]", device_path, device_file); for (i = 0; i < sensor_client->priv->array_sensors->len; i++) { sensor = g_ptr_array_index (sensor_client->priv->array_sensors, i); if (g_strcmp0 (cd_sensor_get_device_path (sensor), device_path) == 0) { g_debug ("emit: removed"); g_signal_emit (sensor_client, signals[SIGNAL_SENSOR_REMOVED], 0, sensor); g_ptr_array_remove_index_fast (sensor_client->priv->array_sensors, i); goto out; } } /* nothing found */ g_warning ("removed CM sensor that was never added"); out: return; }
false
false
false
false
false
0
icon_list_modify_with_splash(icon_list_t *icons, char *dirname, char *newdirname) { g_assert(icons != NULL); splash_show(icons->iconsel->apwal->splash); icon_list_modify(icons, dirname, newdirname); splash_hide(icons->iconsel->apwal->splash); }
false
false
false
false
false
0
resetError() { m_error = NO_ERROR; m_error_string = std::string(""); }
false
false
false
false
false
0
ves_icall_System_Environment_InternalSetEnvironmentVariable (MonoString *name, MonoString *value) { #ifdef HOST_WIN32 gunichar2 *utf16_name, *utf16_value; #else gchar *utf8_name, *utf8_value; MonoError error; #endif #ifdef HOST_WIN32 utf16_name = mono_string_to_utf16 (name); if ((value == NULL) || (mono_string_length (value) == 0) || (mono_string_chars (value)[0] == 0)) { SetEnvironmentVariable (utf16_name, NULL); g_free (utf16_name); return; } utf16_value = mono_string_to_utf16 (value); SetEnvironmentVariable (utf16_name, utf16_value); g_free (utf16_name); g_free (utf16_value); #else utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */ if ((value == NULL) || (mono_string_length (value) == 0) || (mono_string_chars (value)[0] == 0)) { g_unsetenv (utf8_name); g_free (utf8_name); return; } utf8_value = mono_string_to_utf8_checked (value, &error); if (!mono_error_ok (&error)) { g_free (utf8_name); mono_error_raise_exception (&error); } g_setenv (utf8_name, utf8_value, TRUE); g_free (utf8_name); g_free (utf8_value); #endif }
false
false
false
false
false
0
pagecache_get_page(struct address_space *mapping, pgoff_t offset, int fgp_flags, gfp_t gfp_mask) { struct page *page; repeat: page = find_get_entry(mapping, offset); if (radix_tree_exceptional_entry(page)) page = NULL; if (!page) goto no_page; if (fgp_flags & FGP_LOCK) { if (fgp_flags & FGP_NOWAIT) { if (!trylock_page(page)) { page_cache_release(page); return NULL; } } else { lock_page(page); } /* Has the page been truncated? */ if (unlikely(page->mapping != mapping)) { unlock_page(page); page_cache_release(page); goto repeat; } VM_BUG_ON_PAGE(page->index != offset, page); } if (page && (fgp_flags & FGP_ACCESSED)) mark_page_accessed(page); no_page: if (!page && (fgp_flags & FGP_CREAT)) { int err; if ((fgp_flags & FGP_WRITE) && mapping_cap_account_dirty(mapping)) gfp_mask |= __GFP_WRITE; if (fgp_flags & FGP_NOFS) gfp_mask &= ~__GFP_FS; page = __page_cache_alloc(gfp_mask); if (!page) return NULL; if (WARN_ON_ONCE(!(fgp_flags & FGP_LOCK))) fgp_flags |= FGP_LOCK; /* Init accessed so avoid atomic mark_page_accessed later */ if (fgp_flags & FGP_ACCESSED) __SetPageReferenced(page); err = add_to_page_cache_lru(page, mapping, offset, gfp_mask & GFP_RECLAIM_MASK); if (unlikely(err)) { page_cache_release(page); page = NULL; if (err == -EEXIST) goto repeat; } } return page; }
false
false
false
false
false
0
initialize_width_data (a_paragraph *p, const a_width *line_widths) { unsigned int nwidths = 0; p->max_widths = line_widths; /* compute the muber of line widths given */ for (; *line_widths; ++line_widths) ++nwidths; p->nmax_widths = nwidths; /* allocate the break buffers */ XMALLOC_ARRAY (p->break_data, p->nmax_widths * p->nwords); XMALLOC_ARRAY (p->break_cost_data, p->nmax_widths * p->nwords); /* distribute amounts of these buffers to all words */ { unsigned int n; const a_word **w = p->break_data; a_cost *c = p->break_cost_data; for (n = 0; n < p->nwords; ++n) { p->words[n].next_break = w; p->words[n].next_break_cost = c; w += p->nmax_widths; c += p->nmax_widths; } } return p; }
false
false
false
false
false
0
mpfr_rand_raw (mpfr_limb_ptr mp, gmp_randstate_t rstate, mpfr_prec_t nbits) { mpz_t z; MPFR_ASSERTN (nbits >= 1); /* To be sure to avoid the potential allocation of mpz_urandomb */ ALLOC(z) = SIZ(z) = MPFR_PREC2LIMBS (nbits); PTR(z) = mp; #if __MPFR_GMP(5,0,0) /* Check for integer overflow (unless mp_bitcnt_t is signed, but according to the GMP manual, this shouldn't happen). Note: mp_bitcnt_t has been introduced in GMP 5.0.0. */ MPFR_ASSERTN ((mp_bitcnt_t) -1 < 0 || nbits <= (mp_bitcnt_t) -1); #endif mpz_urandomb (z, rstate, nbits); }
false
false
false
false
false
0
parse(const UnicodeString& text, ParsePosition& pos) const { UDate d = 0; // Error return UDate is 0 (the epoch) if (fCalendar != NULL) { int32_t start = pos.getIndex(); // Parse may update TimeZone used by the calendar. TimeZone *tzsav = (TimeZone*)fCalendar->getTimeZone().clone(); fCalendar->clear(); parse(text, *fCalendar, pos); if (pos.getIndex() != start) { UErrorCode ec = U_ZERO_ERROR; d = fCalendar->getTime(ec); if (U_FAILURE(ec)) { // We arrive here if fCalendar is non-lenient and there // is an out-of-range field. We don't know which field // was illegal so we set the error index to the start. pos.setIndex(start); pos.setErrorIndex(start); d = 0; } } // Restore TimeZone fCalendar->adoptTimeZone(tzsav); } return d; }
false
false
false
false
false
0
ckh_evict_reloc_insert(ckh_t *ckh, size_t argbucket, void const **argkey, void const **argdata) { const void *key, *data, *tkey, *tdata; ckhc_t *cell; size_t hash1, hash2, bucket, tbucket; unsigned i; bucket = argbucket; key = *argkey; data = *argdata; while (true) { /* * Choose a random item within the bucket to evict. This is * critical to correct function, because without (eventually) * evicting all items within a bucket during iteration, it * would be possible to get stuck in an infinite loop if there * were an item for which both hashes indicated the same * bucket. */ prn32(i, LG_CKH_BUCKET_CELLS, ckh->prn_state, CKH_A, CKH_C); cell = &ckh->tab[(bucket << LG_CKH_BUCKET_CELLS) + i]; assert(cell->key != NULL); /* Swap cell->{key,data} and {key,data} (evict). */ tkey = cell->key; tdata = cell->data; cell->key = key; cell->data = data; key = tkey; data = tdata; #ifdef CKH_COUNT ckh->nrelocs++; #endif /* Find the alternate bucket for the evicted item. */ ckh->hash(key, ckh->lg_curbuckets, &hash1, &hash2); tbucket = hash2 & ((ZU(1) << ckh->lg_curbuckets) - 1); if (tbucket == bucket) { tbucket = hash1 & ((ZU(1) << ckh->lg_curbuckets) - 1); /* * It may be that (tbucket == bucket) still, if the * item's hashes both indicate this bucket. However, * we are guaranteed to eventually escape this bucket * during iteration, assuming pseudo-random item * selection (true randomness would make infinite * looping a remote possibility). The reason we can * never get trapped forever is that there are two * cases: * * 1) This bucket == argbucket, so we will quickly * detect an eviction cycle and terminate. * 2) An item was evicted to this bucket from another, * which means that at least one item in this bucket * has hashes that indicate distinct buckets. */ } /* Check for a cycle. */ if (tbucket == argbucket) { *argkey = key; *argdata = data; return (true); } bucket = tbucket; if (ckh_try_bucket_insert(ckh, bucket, key, data) == false) return (false); } }
false
false
false
false
false
0
get_new_message_count(MAILSTREAM *stream, int imapstatus, long *new, long *unseen) { if(new) *new = 0L; if(unseen) *unseen = 0L; if(imapstatus){ if(new) *new = count_flagged(stream, F_RECENT | F_UNSEEN | F_UNDEL); if(!IS_NEWS(stream)){ if(unseen) *unseen = count_flagged(stream, F_UNSEEN | F_UNDEL); } else if(unseen) *unseen = -1L; } else{ if(IS_NEWS(stream)){ if(F_ON(F_FAKE_NEW_IN_NEWS, ps_global)){ if(new) *new = count_flagged(stream, F_RECENT | F_UNSEEN | F_UNDEL); } } else{ if(new) *new = count_flagged(stream, F_UNSEEN | F_UNDEL | F_UNANS); } } }
false
false
false
false
false
0
interp_T(const double * restrict geop, const double * restrict gt, double *pt, const double * restrict fullp, const double * restrict halfp, const int *nx, const double * restrict plev, long nplev, long ngp, long nhlev, double missval) { long lp, i; long nl, nh; const int *nxl; double *ptl; double pres; #if defined(_OPENMP) #pragma omp parallel for default(shared) private(i, pres, nl, nh, nxl, ptl) #endif for ( lp = 0; lp < nplev; lp++ ) { pres = plev[lp]; nxl = nx + lp*ngp; ptl = pt + lp*ngp; #if defined(CRAY) #pragma _CRI inline extra_T #endif for ( i = 0; i < ngp; i++ ) { nl = nxl[i]; if ( nl < 0 ) ptl[i] = missval; else { if ( nl > nhlev-2 ) { if ( Mars ) ptl[i] = gt[(nhlev-1)*ngp+i]; else #if defined(SX) #pragma cdir inline #endif ptl[i] = extra_T(pres, halfp[nhlev*ngp+i], fullp[(nhlev-1)*ngp+i], geop[i], gt[(nhlev-1)*ngp+i]); } else { nh = nl + 1; ptl[i] = gt[nl*ngp+i] + (pres-fullp[nl*ngp+i]) * (gt[nh*ngp+i] - gt[nl*ngp+i]) / (fullp[nh*ngp+i] - fullp[nl*ngp+i]); } } } } }
false
false
false
false
false
0
xmlXPathGetElementsByIds (xmlDocPtr doc, const xmlChar *ids) { xmlNodeSetPtr ret; const xmlChar *cur = ids; xmlChar *ID; xmlAttrPtr attr; xmlNodePtr elem = NULL; if (ids == NULL) return(NULL); ret = xmlXPathNodeSetCreate(NULL); while (IS_BLANK_CH(*cur)) cur++; while (*cur != 0) { while ((!IS_BLANK_CH(*cur)) && (*cur != 0)) cur++; ID = xmlStrndup(ids, cur - ids); if (ID != NULL) { /* * We used to check the fact that the value passed * was an NCName, but this generated much troubles for * me and Aleksey Sanin, people blatantly violated that * constaint, like Visa3D spec. * if (xmlValidateNCName(ID, 1) == 0) */ attr = xmlGetID(doc, ID); if (attr != NULL) { if (attr->type == XML_ATTRIBUTE_NODE) elem = attr->parent; else if (attr->type == XML_ELEMENT_NODE) elem = (xmlNodePtr) attr; else elem = NULL; if (elem != NULL) xmlXPathNodeSetAdd(ret, elem); } xmlFree(ID); } while (IS_BLANK_CH(*cur)) cur++; ids = cur; } return(ret); }
false
false
false
false
false
0
resume_proxies(void) { int err; struct proxy *p; struct peers *prs; err = 0; p = proxy; tv_update_date(0,1); /* else, the old time before select will be used */ while (p) { err |= !resume_proxy(p); p = p->next; } prs = peers; while (prs) { p = prs->peers_fe; err |= !resume_proxy(p); prs = prs->next; } if (err) { Warning("Some proxies refused to resume, a restart is probably needed to resume safe operations.\n"); send_log(p, LOG_WARNING, "Some proxies refused to resume, a restart is probably needed to resume safe operations.\n"); } }
false
false
false
false
false
0
_plug_iovec_to_buf(const sasl_utils_t *utils, const struct iovec *vec, unsigned numiov, buffer_info_t **output) { unsigned i; int ret; buffer_info_t *out; char *pos; if(!utils || !vec || !output) { if(utils) PARAMERROR( utils ); return SASL_BADPARAM; } if(!(*output)) { *output = utils->malloc(sizeof(buffer_info_t)); if(!*output) { MEMERROR(utils); return SASL_NOMEM; } memset(*output,0,sizeof(buffer_info_t)); } out = *output; out->curlen = 0; for(i=0; i<numiov; i++) out->curlen += vec[i].iov_len; ret = _plug_buf_alloc(utils, &out->data, &out->reallen, out->curlen); if(ret != SASL_OK) { MEMERROR(utils); return SASL_NOMEM; } memset(out->data, 0, out->reallen); pos = out->data; for(i=0; i<numiov; i++) { memcpy(pos, vec[i].iov_base, vec[i].iov_len); pos += vec[i].iov_len; } return SASL_OK; }
false
true
false
false
false
1
maybe_add_info_score (struct COMPARE *cmp, const MODEL *pmodA, const MODEL *pmodB) { if (pmodA != NULL && pmodB != NULL) { int i; cmp->score = 0; for (i=0; i<C_MAX; i++) { if (na(pmodB->criterion[i]) || na(pmodA->criterion[i])) { cmp->score = -1; break; } else if (pmodB->criterion[i] < pmodA->criterion[i]) { cmp->score++; } } } }
false
false
false
false
false
0
output_name_type( fields *info, FILE *outptr, int level, char *map[], int nmap, char *tag ) { newstr ntag; int i, j, n=0, code; newstr_init( &ntag ); for ( j=0; j<nmap; ++j ) { for ( i=0; i<info->nfields; ++i ) { code = extract_name_and_info( &ntag, &(info->tag[i]) ); if ( strcasecmp( ntag.data, map[j] ) ) continue; if ( n==0 ) fprintf( outptr, "<%s><b:NameList>\n", tag ); if ( code != NAME ) output_name_nomangle( outptr, info->data[i].data ); else output_name( outptr, info->data[i].data ); fields_setused( info, i ); n++; } } newstr_free( &ntag ); if ( n ) fprintf( outptr, "</b:NameList></%s>\n", tag ); }
false
false
false
false
false
0
get_to_local(VMG0_) const { /* if there's no mapper, throw an exception */ if (get_ext_ptr()->to_local == 0) { /* throw an UnknownCharacterSetException */ G_interpreter->throw_new_class(vmg_ G_predef->charset_unknown_exc, 0, "unknown character set"); } /* return the mapper */ return get_ext_ptr()->to_local; }
false
false
false
false
false
0
string_from_fortran(char *c, long int *pn) { char *p, *t; string *out; int n = *pn; if(n < 0) { n = strlen(c); } p = (char *) malloc(sizeof(char) * (n + 1)); p[0] = '\0'; p = strncpy(p, c, n); p[n] = '\0'; t = strchr_reverse_isnot(p, n, ' '); t[1] = '\0'; out = string_new(p); free(p); return out; }
false
true
false
false
false
1
Luse_package() { # line 1036 "package.d" object l; int narg; register object *DPPbase=vs_base; #define pack DPPbase[0] #define pa DPPbase[1+0] narg = vs_top - vs_base; if (narg < 1) too_few_arguments(); if (narg <= 1 + 0) { vs_push(current_package()); narg++; } if (narg > 1 + 1) too_many_arguments(); # line 1038 "package.d" check_package_designator(pa); pa = coerce_to_package(pa); BEGIN: switch (type_of(pack)) { case t_symbol: if (pack == Cnil) break; case t_string: case t_package: case t_character: use_package(pack, pa); break; case t_cons: for (l = pack; !endp(l); l = l->c.c_cdr) use_package(l->c.c_car, pa); break; default: check_type_package(&pack); goto BEGIN; } { vs_base[0] = Ct; vs_top = vs_base + 1; return; } # line 1062 "package.d" #undef pack #undef pa }
false
false
false
false
false
0
attempt_atomic_deletion() { ndeletion_attempts += 1.0; if (ngas == 0) return; int i = pick_random_gas_atom(); int success = 0; if (i >= 0) { double deletion_energy = energy(i,ngcmc_type,-1,atom->x[i]); if (random_unequal->uniform() < ngas*exp(beta*deletion_energy)/(zz*volume)) { atom->avec->copy(atom->nlocal-1,i,1); atom->nlocal--; success = 1; } } int success_all = 0; MPI_Allreduce(&success,&success_all,1,MPI_INT,MPI_MAX,world); if (success_all) { if (atom->tag_enable) { atom->natoms--; if (atom->map_style) atom->map_init(); } atom->nghost = 0; comm->borders(); update_gas_atoms_list(); ndeletion_successes += 1.0; } }
false
false
false
false
false
0
lodepng_inspect(unsigned* w, unsigned* h, LodePNGState* state, const unsigned char* in, size_t insize) { LodePNGInfo* info = &state->info_png; if(insize == 0 || in == 0) { CERROR_RETURN_ERROR(state->error, 48); /*error: the given data is empty*/ } if(insize < 33) { CERROR_RETURN_ERROR(state->error, 27); /*error: the data length is smaller than the length of a PNG header*/ } /*when decoding a new PNG image, make sure all parameters created after previous decoding are reset*/ lodepng_info_cleanup(info); lodepng_info_init(info); if(in[0] != 137 || in[1] != 80 || in[2] != 78 || in[3] != 71 || in[4] != 13 || in[5] != 10 || in[6] != 26 || in[7] != 10) { CERROR_RETURN_ERROR(state->error, 28); /*error: the first 8 bytes are not the correct PNG signature*/ } if(in[12] != 'I' || in[13] != 'H' || in[14] != 'D' || in[15] != 'R') { CERROR_RETURN_ERROR(state->error, 29); /*error: it doesn't start with a IHDR chunk!*/ } /*read the values given in the header*/ *w = lodepng_read32bitInt(&in[16]); *h = lodepng_read32bitInt(&in[20]); info->color.bitdepth = in[24]; info->color.colortype = (LodePNGColorType)in[25]; info->compression_method = in[26]; info->filter_method = in[27]; info->interlace_method = in[28]; if(*w == 0 || *h == 0) { CERROR_RETURN_ERROR(state->error, 93); } if(!state->decoder.ignore_crc) { unsigned CRC = lodepng_read32bitInt(&in[29]); unsigned checksum = lodepng_crc32(&in[12], 17); if(CRC != checksum) { CERROR_RETURN_ERROR(state->error, 57); /*invalid CRC*/ } } /*error: only compression method 0 is allowed in the specification*/ if(info->compression_method != 0) CERROR_RETURN_ERROR(state->error, 32); /*error: only filter method 0 is allowed in the specification*/ if(info->filter_method != 0) CERROR_RETURN_ERROR(state->error, 33); /*error: only interlace methods 0 and 1 exist in the specification*/ if(info->interlace_method > 1) CERROR_RETURN_ERROR(state->error, 34); state->error = checkColorValidity(info->color.colortype, info->color.bitdepth); return state->error; }
false
false
false
false
false
0
_PHY_SetBWMode23a92C(struct rtw_adapter *Adapter) { struct hal_data_8723a *pHalData = GET_HAL_DATA(Adapter); u8 regBwOpMode; u8 regRRSR_RSC; if (Adapter->bDriverStopped) return; /* 3 */ /* 3<1>Set MAC register */ /* 3 */ regBwOpMode = rtl8723au_read8(Adapter, REG_BWOPMODE); regRRSR_RSC = rtl8723au_read8(Adapter, REG_RRSR+2); switch (pHalData->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: regBwOpMode |= BW_OPMODE_20MHZ; rtl8723au_write8(Adapter, REG_BWOPMODE, regBwOpMode); break; case HT_CHANNEL_WIDTH_40: regBwOpMode &= ~BW_OPMODE_20MHZ; rtl8723au_write8(Adapter, REG_BWOPMODE, regBwOpMode); regRRSR_RSC = (regRRSR_RSC & 0x90) | (pHalData->nCur40MhzPrimeSC << 5); rtl8723au_write8(Adapter, REG_RRSR+2, regRRSR_RSC); break; default: break; } /* 3 */ /* 3<2>Set PHY related register */ /* 3 */ switch (pHalData->CurrentChannelBW) { /* 20 MHz channel*/ case HT_CHANNEL_WIDTH_20: PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT(10), 1); break; /* 40 MHz channel*/ case HT_CHANNEL_WIDTH_40: PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); /* Set Control channel to upper or lower. These settings are required only for 40MHz */ PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC >> 1)); PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); PHY_SetBBReg(Adapter, rFPGA0_AnalogParameter2, BIT(10), 0); PHY_SetBBReg(Adapter, 0x818, BIT(26) | BIT(27), (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2:1); break; default: break; } /* Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 */ /* Added it for 20/40 mhz switch time evaluation by guangan 070531 */ /* NowL = PlatformEFIORead4Byte(Adapter, TSFR); */ /* NowH = PlatformEFIORead4Byte(Adapter, TSFR+4); */ /* EndTime = ((u64)NowH << 32) + NowL; */ rtl8723a_phy_rf6052set_bw(Adapter, pHalData->CurrentChannelBW); }
false
false
false
false
false
0
my_fgets(char *s, char *w, int max, FILE *file, int wide) { int i = 0; char prev = 1; char c = 1; while (c != '\n' && !feof(file) && max) { c = (char)fgetc(file); /* printf("char = %c\n",c); */ if (!c && (!prev && !wide) ) break; /* Stop on 1 (or 2 if wide) null */ prev = c; if (c != '\r') { *(s+i) = c; *(w+i) = c; i++; } max--; } *(s+i) = 0; *(s+i+1) = 0; *(w+i) = 0; *(w+i+1) = 0; if (wide) { /* Convert to C string, de widing it.. */ cheap_uni2ascii(w, s, i); // printf("cheap returns len = %d : %s\n",strlen(s), s); fgetc(file); /* Skip second byte of CR/LF termination */ } // printf("my_fgets returning :\n"); //hexdump(w, 0, i, 1); //printf("====== hexdump end\n"); return(s); }
false
false
false
false
false
0
prepare_uprobe(struct uprobe *uprobe, struct file *file, struct mm_struct *mm, unsigned long vaddr) { int ret = 0; if (test_bit(UPROBE_COPY_INSN, &uprobe->flags)) return ret; /* TODO: move this into _register, until then we abuse this sem. */ down_write(&uprobe->consumer_rwsem); if (test_bit(UPROBE_COPY_INSN, &uprobe->flags)) goto out; ret = copy_insn(uprobe, file); if (ret) goto out; ret = -ENOTSUPP; if (is_trap_insn((uprobe_opcode_t *)&uprobe->arch.insn)) goto out; ret = arch_uprobe_analyze_insn(&uprobe->arch, mm, vaddr); if (ret) goto out; /* uprobe_write_opcode() assumes we don't cross page boundary */ BUG_ON((uprobe->offset & ~PAGE_MASK) + UPROBE_SWBP_INSN_SIZE > PAGE_SIZE); smp_wmb(); /* pairs with rmb() in find_active_uprobe() */ set_bit(UPROBE_COPY_INSN, &uprobe->flags); out: up_write(&uprobe->consumer_rwsem); return ret; }
false
false
false
false
false
0
templates_load (AutoFormatState *state) { GSList *l; gint n_templates; g_return_val_if_fail (state != NULL, FALSE); if (state->category_groups == NULL) return FALSE; state->templates = category_group_get_templates_list ( state->current_category_group, GO_CMD_CONTEXT (state->wbcg)); for (l = state->templates; l != NULL; l = l->next) { GnmFormatTemplate *ft = l->data; range_init (&ft->dimension, 0, 0, PREVIEW_COLS - 1, PREVIEW_ROWS - 1); ft->invalidate_hash = TRUE; } n_templates = g_slist_length (state->templates); /* * We need to temporary lock the preview loading/freeing or * else our scrollbar will trigger an event (value_changed) and create the * previews. (which we don't want to happen at this moment) */ state->previews_locked = TRUE; { GtkAdjustment *adjustment = gtk_range_get_adjustment (GTK_RANGE (state->scroll)); gtk_adjustment_configure (adjustment, 0, 0, n_templates / 2, 1, 3, 3); } state->previews_locked = FALSE; /* * Hide the scrollbar when it's not needed */ gtk_widget_set_visible (GTK_WIDGET (state->scroll), n_templates > NUM_PREVIEWS); return TRUE; }
false
false
false
false
false
0
evas_common_font_query_char_at_coords(RGBA_Font *fn, const Evas_Text_Props *text_props, int x, int y, int *cx, int *cy, int *cw, int *ch) { int asc, desc; int ret_val = -1; EVAS_FONT_WALK_TEXT_INIT(); asc = evas_common_font_max_ascent_get(fn); desc = evas_common_font_max_descent_get(fn); Evas_Coord cluster_start = 0; int prev_cluster = -1; int found = 0, items = 1; EVAS_FONT_WALK_TEXT_START() { EVAS_FONT_WALK_TEXT_WORK(); if (prev_cluster != (int) EVAS_FONT_WALK_POS) { if (found) { break; } else { cluster_start = EVAS_FONT_WALK_PEN_X; } } if (!EVAS_FONT_WALK_IS_VISIBLE) continue; /* we need to see if the char at the visual position is the char, * we check that by checking if it's before the current pen * position and the next */ if ((x >= EVAS_FONT_WALK_PEN_X) && (x <= (EVAS_FONT_WALK_PEN_X_AFTER)) && (y >= -asc) && (y <= desc)) { #ifdef OT_SUPPORT items = evas_common_font_ot_cluster_size_get(text_props, char_index); #endif found = 1; } prev_cluster = EVAS_FONT_WALK_POS; } EVAS_FONT_WALK_TEXT_END(); if (found) { int item_pos; Evas_Coord cluster_adv; cluster_adv = EVAS_FONT_WALK_PEN_X - cluster_start; if (text_props->bidi.dir == EVAS_BIDI_DIRECTION_LTR) { double part; part = cluster_adv / items; item_pos = (int) ((x - cluster_start) / part); } else { double part; part = cluster_adv / items; item_pos = items - ((int) ((x - cluster_start) / part)) - 1; } if (cx) *cx = EVAS_FONT_WALK_PEN_X + ((cluster_adv / items) * (item_pos - 1)); if (cy) *cy = -asc; if (cw) *cw = (cluster_adv / items); if (ch) *ch = asc + desc; ret_val = prev_cluster + item_pos; goto end; } end: return ret_val; }
false
false
false
false
false
0
rtl_hw_start_8169(struct net_device *dev) { struct rtl8169_private *tp = netdev_priv(dev); void *ioaddr = tp->mmio_addr; struct pci_device *pdev = tp->pci_dev; DBGP ( "rtl_hw_start_8169\n" ); if (tp->mac_version == RTL_GIGA_MAC_VER_05) { RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW); pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08); } RTL_W8(Cfg9346, Cfg9346_Unlock); if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || (tp->mac_version == RTL_GIGA_MAC_VER_02) || (tp->mac_version == RTL_GIGA_MAC_VER_03) || (tp->mac_version == RTL_GIGA_MAC_VER_04)) RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); RTL_W8(EarlyTxThres, EarlyTxThld); rtl_set_rx_max_size(ioaddr); if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || (tp->mac_version == RTL_GIGA_MAC_VER_02) || (tp->mac_version == RTL_GIGA_MAC_VER_03) || (tp->mac_version == RTL_GIGA_MAC_VER_04)) rtl_set_rx_tx_config_registers(tp); tp->cp_cmd |= rtl_rw_cpluscmd(ioaddr) | PCIMulRW; if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || (tp->mac_version == RTL_GIGA_MAC_VER_03)) { DBG ( "Set MAC Reg C+CR Offset 0xE0. " "Bit-3 and bit-14 MUST be 1\n" ); tp->cp_cmd |= (1 << 14); } RTL_W16(CPlusCmd, tp->cp_cmd); rtl8169_set_magic_reg(ioaddr, tp->mac_version); /* * Undocumented corner. Supposedly: * (TxTimer << 12) | (TxPackets << 8) | (RxTimer << 4) | RxPackets */ RTL_W16(IntrMitigate, 0x0000); rtl_set_rx_tx_desc_registers(tp, ioaddr); if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && (tp->mac_version != RTL_GIGA_MAC_VER_02) && (tp->mac_version != RTL_GIGA_MAC_VER_03) && (tp->mac_version != RTL_GIGA_MAC_VER_04)) { RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); rtl_set_rx_tx_config_registers(tp); } RTL_W8(Cfg9346, Cfg9346_Lock); /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ RTL_R8(IntrMask); RTL_W32(RxMissed, 0); rtl_set_rx_mode(dev); /* no early-rx interrupts */ RTL_W16(MultiIntr, RTL_R16(MultiIntr) & 0xF000); // RTL_W16(IntrMask, tp->intr_event); }
false
false
false
false
false
0
saa7164_dl_wait_ack(struct saa7164_dev *dev, u32 reg) { u32 timeout = SAA_DEVICE_TIMEOUT; while ((saa7164_readl(reg) & 0x01) == 0) { timeout -= 10; if (timeout == 0) { printk(KERN_ERR "%s() timeout (no d/l ack)\n", __func__); return -EBUSY; } msleep(100); } return 0; }
false
false
false
false
false
0
build_row_from_vars(PLpgSQL_variable **vars, int numvars) { PLpgSQL_row *row; int i; row = palloc0(sizeof(PLpgSQL_row)); row->dtype = PLPGSQL_DTYPE_ROW; row->rowtupdesc = CreateTemplateTupleDesc(numvars, false); row->nfields = numvars; row->fieldnames = palloc(numvars * sizeof(char *)); row->varnos = palloc(numvars * sizeof(int)); for (i = 0; i < numvars; i++) { PLpgSQL_variable *var = vars[i]; Oid typoid = RECORDOID; int32 typmod = -1; switch (var->dtype) { case PLPGSQL_DTYPE_VAR: typoid = ((PLpgSQL_var *) var)->datatype->typoid; typmod = ((PLpgSQL_var *) var)->datatype->atttypmod; break; case PLPGSQL_DTYPE_REC: break; case PLPGSQL_DTYPE_ROW: if (((PLpgSQL_row *) var)->rowtupdesc) { typoid = ((PLpgSQL_row *) var)->rowtupdesc->tdtypeid; typmod = ((PLpgSQL_row *) var)->rowtupdesc->tdtypmod; } break; default: elog(ERROR, "unrecognized dtype: %d", var->dtype); } row->fieldnames[i] = var->refname; row->varnos[i] = var->dno; TupleDescInitEntry(row->rowtupdesc, i + 1, var->refname, typoid, typmod, 0); } return row; }
false
false
false
false
false
0
searchInBM(char *x, int m, char *y, int n, int * addr) { int i, j, bmGs[m], bmBc[CACHESIZE]; /* Preprocessing */ preBmGs(x, m, bmGs); preBmBc(x, m, bmBc); /* Searching */ j = 0; while (j <= n - m) { for (i = m - 1; i >= 0 && x[i] == y[i + j]; --i); if (i < 0) { // binary representation of matches *addr += (1 << j); j += bmGs[0]; } else j += max(bmGs[i], bmBc[y[i + j]-'0'] - m + 1 + i); } }
false
false
false
false
false
0
list(int op, int n, char *names[]) { struct gfarm_user_info *users; gfarm_error_t e, *errs; GFARM_MALLOC_ARRAY(users, n); GFARM_MALLOC_ARRAY(errs, n); if (users == NULL || errs == NULL) { e = GFARM_ERR_NO_MEMORY; goto free_users; } e = gfm_client_user_info_get_by_names( gfm_server, n, (const char **)names, errs, users); if (e != GFARM_ERR_NO_ERROR) goto free_users; display_user(op, n, names, errs, users); free_users: if (users != NULL) free(users); if (errs != NULL) free(errs); return (e); }
false
false
false
false
false
0
PrintSelf(ostream& os, vtkIndent indent) { int idx; this->Superclass::PrintSelf(os,indent); // this->File, this->Colors need not be printed os << indent << "FileName: " << (this->FileName ? this->FileName : "(none)") << "\n"; os << indent << "FileNames: " << this->FileNames << "\n"; os << indent << "FilePrefix: " << (this->FilePrefix ? this->FilePrefix : "(none)") << "\n"; os << indent << "FilePattern: " << (this->FilePattern ? this->FilePattern : "(none)") << "\n"; os << indent << "FileNameSliceOffset: " << this->FileNameSliceOffset << "\n"; os << indent << "FileNameSliceSpacing: " << this->FileNameSliceSpacing << "\n"; os << indent << "DataScalarType: " << vtkImageScalarTypeNameMacro(this->DataScalarType) << "\n"; os << indent << "NumberOfScalarComponents: " << this->NumberOfScalarComponents << "\n"; os << indent << "File Dimensionality: " << this->FileDimensionality << "\n"; os << indent << "File Lower Left: " << (this->FileLowerLeft ? "On\n" : "Off\n"); os << indent << "Swap Bytes: " << (this->SwapBytes ? "On\n" : "Off\n"); os << indent << "DataIncrements: (" << this->DataIncrements[0]; for (idx = 1; idx < 2; ++idx) { os << ", " << this->DataIncrements[idx]; } os << ")\n"; os << indent << "DataExtent: (" << this->DataExtent[0]; for (idx = 1; idx < 6; ++idx) { os << ", " << this->DataExtent[idx]; } os << ")\n"; os << indent << "DataSpacing: (" << this->DataSpacing[0]; for (idx = 1; idx < 3; ++idx) { os << ", " << this->DataSpacing[idx]; } os << ")\n"; os << indent << "DataOrigin: (" << this->DataOrigin[0]; for (idx = 1; idx < 3; ++idx) { os << ", " << this->DataOrigin[idx]; } os << ")\n"; os << indent << "HeaderSize: " << this->HeaderSize << "\n"; if ( this->InternalFileName ) { os << indent << "Internal File Name: " << this->InternalFileName << "\n"; } else { os << indent << "Internal File Name: (none)\n"; } }
false
false
false
false
false
0
toXml(QDomDocument& doc) const { QDomElement item = doc.createElement("item"); if (type_ == JidType) item.setAttribute("type","jid"); else if (type_ == GroupType) item.setAttribute("type","group"); else if (type_ == SubscriptionType) item.setAttribute("type","subscription"); if (type_ != FallthroughType) item.setAttribute("value",value_); if (action_ == Allow) item.setAttribute("action","allow"); else item.setAttribute("action","deny"); item.setAttribute("order", order_); if (!(message_ && presenceIn_ && presenceOut_ && iq_)) { if (message_) item.appendChild(doc.createElement("message")); if (presenceIn_) item.appendChild(doc.createElement("presence-in")); if (presenceOut_) item.appendChild(doc.createElement("presence-out")); if (iq_) item.appendChild(doc.createElement("iq")); } return item; }
false
false
false
false
false
0
HMARK_ip4_print(const void *ip, const struct xt_entry_target *target, int numeric) { const struct xt_hmark_info *info = (const struct xt_hmark_info *)target->data; printf(" HMARK "); if (info->flags & XT_HMARK_FLAG(XT_HMARK_MODULUS)) printf("mod %u ", info->hmodulus); if (info->flags & XT_HMARK_FLAG(XT_HMARK_OFFSET)) printf("+ 0x%x ", info->hoffset); if (info->flags & XT_HMARK_FLAG(XT_HMARK_CT)) printf("ct, "); if (info->flags & XT_HMARK_FLAG(XT_HMARK_SADDR_MASK)) printf("src-prefix %u ", xtables_ipmask_to_cidr(&info->src_mask.in)); if (info->flags & XT_HMARK_FLAG(XT_HMARK_DADDR_MASK)) printf("dst-prefix %u ", xtables_ipmask_to_cidr(&info->dst_mask.in)); HMARK_print(info); }
false
false
false
false
false
0
runadd(runcxdef *ctx, runsdef *val, runsdef *val2, uint below) { if (val->runstyp == DAT_LIST) { int len1 = osrp2(val->runsv.runsvstr); int len2 = runsiz(val2); int newlen; /* if concatenating a list, take out length + datatype from 2nd */ if (val2->runstyp == DAT_LIST) newlen = len1 + len2 - 2; /* leave out second list len */ else newlen = len1 + len2 + 1; /* add in datatype header */ /* get space in heap, copy first list, and set new length */ runhres2(ctx, newlen, below, val, val2); memcpy(ctx->runcxhp, val->runsv.runsvstr, (size_t)len1); oswp2(ctx->runcxhp, newlen); /* append the new element or list of elements */ if (val2->runstyp == DAT_LIST) memcpy(ctx->runcxhp + len1, val2->runsv.runsvstr + 2, (size_t)(len2 - 2)); else runputbuf(ctx->runcxhp + len1, val2); /* set up return value and update heap pointer */ val->runsv.runsvstr = ctx->runcxhp; ctx->runcxhp += newlen; } else if (val->runstyp==DAT_SSTRING && val2->runstyp==DAT_SSTRING) { int len1 = osrp2(val->runsv.runsvstr); int len2 = osrp2(val2->runsv.runsvstr); /* reserve space, and concatenate the two strings */ runhres2(ctx, len1 + len2 - 2, below, val, val2); memcpy(ctx->runcxhp, val->runsv.runsvstr, (size_t)len1); memcpy(ctx->runcxhp + len1, val2->runsv.runsvstr + 2, (size_t)len2 - 2); /* set length to sum of two lengths, minus 2nd length word */ oswp2(ctx->runcxhp, len1 + len2 - 2); val->runsv.runsvstr = ctx->runcxhp; ctx->runcxhp += len1 + len2 - 2; } else if (val->runstyp == DAT_NUMBER && val2->runstyp == DAT_NUMBER) val->runsv.runsvnum += val2->runsv.runsvnum; else runsig(ctx, ERR_INVADD); }
false
false
false
false
false
0
parse_int(apr_pool_t *p, const char *arg, int *val) { char *endptr; *val = strtol(arg, &endptr, 10); if (arg == endptr) { return apr_psprintf(p, "Value '%s' not numerical", endptr); } if (*endptr != '\0') { return apr_psprintf(p, "Cannot parse '%s'", endptr); } if (*val < 0) { return "Value must be non-negative"; } return NULL; }
false
false
false
false
false
0
mnearto( struct monst *mtmp, xchar x, xchar y, bool move_other) /* make sure mtmp gets to x, y! so move m_at(x, y) */ { struct monst *othermon = (struct monst *)0; xchar newx, newy; coord mm; if ((mtmp->mx == x) && (mtmp->my == y)) return false; if (move_other && (othermon = m_at(x, y))) { if (othermon->wormno) remove_worm(othermon); else remove_monster(x, y); } newx = x; newy = y; if (!goodpos(newx, newy, mtmp, 0)) { /* actually we have real problems if enexto ever fails. * migrating_mons that need to be placed will cause * no end of trouble. */ if (!enexto(&mm, newx, newy, mtmp->data)) return false; newx = mm.x; newy = mm.y; } rloc_to(mtmp, newx, newy); if (move_other && othermon) { othermon->mx = othermon->my = 0; mnearto(othermon, x, y, false); if ((othermon->mx != x) || (othermon->my != y)) return true; } return false; }
false
false
false
false
false
0
brcmf_update_ht_cap(struct ieee80211_supported_band *band, u32 bw_cap[2], u32 nchain) { band->ht_cap.ht_supported = true; if (bw_cap[band->band] & WLC_BW_40MHZ_BIT) { band->ht_cap.cap |= IEEE80211_HT_CAP_SGI_40; band->ht_cap.cap |= IEEE80211_HT_CAP_SUP_WIDTH_20_40; } band->ht_cap.cap |= IEEE80211_HT_CAP_SGI_20; band->ht_cap.cap |= IEEE80211_HT_CAP_DSSSCCK40; band->ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_64K; band->ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_16; memset(band->ht_cap.mcs.rx_mask, 0xff, nchain); band->ht_cap.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; }
false
false
false
false
false
0
aic3x_i2c_remove(struct i2c_client *client) { struct aic3x_priv *aic3x = i2c_get_clientdata(client); snd_soc_unregister_codec(&client->dev); if (gpio_is_valid(aic3x->gpio_reset) && !aic3x_is_shared_reset(aic3x)) { gpio_set_value(aic3x->gpio_reset, 0); gpio_free(aic3x->gpio_reset); } return 0; }
false
false
false
false
false
0
profileAlignMenu(void) { while (true) { lin1 = ""; cout<<"\n\n\n"; cout<<"****** PROFILE AND STRUCTURE ALIGNMENT MENU ******\n\n\n"; cout<<" 1. Input 1st. profile "; if (!userParameters->getProfile1Empty()) { cout<<"(loaded)"; } cout<<"\n"; cout<<" 2. Input 2nd. profile/sequences "; if (!userParameters->getProfile2Empty()) { cout<<"(loaded)"; } cout<<"\n\n"; cout<<" 3. Align 2nd. profile to 1st. profile\n"; cout<<" 4. Align sequences to 1st. profile " <<((!userParameters->getQuickPairAlign()) ? "(Slow/Accurate)\n\n" : "(Fast/Approximate)\n\n"); cout<<" 5. Toggle Slow/Fast pairwise alignments = " <<((!userParameters->getQuickPairAlign()) ? "SLOW\n\n" : "FAST\n\n"); cout<<" 6. Pairwise alignment parameters\n"; cout<<" 7. Multiple alignment parameters\n\n"; cout<<" 8. Toggle screen display = " <<((!userParameters->getShowAlign()) ? "OFF\n" : "ON\n"); cout<<" 9. Output format options\n"; cout<<" 0. Secondary structure options\n\n"; cout<<" S. Execute a system command\n"; cout<<" H. HELP\n"; cout<<" or press [RETURN] to go back to main menu\n\n\n"; choice = utilityObject->getChoice(string("Your choice")); if (choice == '\n') { return ; } switch (toupper(choice)) { case '1': clustalObj->profile1Input(); break; case '2': clustalObj->profile2Input(); break; case '3': clustalObj->profileAlign(&p1TreeName, &p2TreeName); break; case '4': /* align new sequences to profile 1 */ clustalObj->sequencesAlignToProfile(&phylipName); break; case '5': userParameters->toggleQuickPairAlign(); break; case '6': pairwiseMenu(); break; case '7': multiMenu(); break; case '8': userParameters->toggleShowAlign(); break; case '9': formatOptionsMenu(); break; case '0': ssOptionsMenu(); break; case 'S': doSystem(); break; case '?': case 'H': clustalObj->getHelp('6'); break; case 'Q': case 'X': return ; default: cout<<"\n\nUnrecognised Command\n\n"; break; } } }
false
false
false
false
false
0
editor(int flag) { const char *pgm = git_editor(); if (!pgm && flag & IDENT_ERROR_ON_NO_NAME) die("Terminal is dumb, but EDITOR unset"); return pgm; }
false
false
false
false
false
0
rb_reg_regcomp(VALUE str) { volatile VALUE save_str = str; if (reg_cache && RREGEXP_SRC_LEN(reg_cache) == RSTRING_LEN(str) && ENCODING_GET(reg_cache) == ENCODING_GET(str) && memcmp(RREGEXP_SRC_PTR(reg_cache), RSTRING_PTR(str), RSTRING_LEN(str)) == 0) return reg_cache; return reg_cache = rb_reg_new_str(save_str, 0); }
false
false
false
false
false
0
sizeCallback(void *data, t_floatarg m_CellSize) { int size=static_cast<int>(m_CellSize); if(size<1){ GetMyClass(data)->error("size must not be < 0"); size=1; } if(size>nMaxCellSize){ GetMyClass(data)->error("size must not be > %d", nMaxCellSize); size=nMaxCellSize; } GetMyClass(data)->m_CellSize=size; GetMyClass(data)->setPixModified(); }
false
false
false
false
false
0