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
getFixupOffset(const MCAsmLayout &Layout, const MCFragment *Fragment, const MCFixup &Fixup) { uint32_t FixupOffset = Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); // On Mach-O, ppc_fixup_half16 relocations must refer to the // start of the instruction, not the second halfword, as ELF does if (unsigned(Fixup.getKind()) == PPC::fixup_ppc_half16) FixupOffset &= ~uint32_t(3); return FixupOffset; }
false
false
false
false
false
0
circuit_try_clearing_isolation_state(origin_circuit_t *circ) { if (/* The circuit may have become non-open if it was cannibalized.*/ circ->_base.state == CIRCUIT_STATE_OPEN && /* If !isolation_values_set, there is nothing to clear. */ circ->isolation_values_set && /* It's not legal to clear a circuit's isolation info if it's ever had * streams attached */ !circ->isolation_any_streams_attached) { /* If we have any isolation information set on this circuit, and * we didn't manage to attach any streams to it, then we can * and should clear it and try again. */ circuit_clear_isolation(circ); return 1; } else { return 0; } }
false
false
false
false
false
0
rtpm_children_show(struct device *dev, struct device_attribute *attr, char *buf) { return sprintf(buf, "%d\n", dev->power.ignore_children ? 0 : atomic_read(&dev->power.child_count)); }
false
false
false
false
false
0
mgag200_modeset_init(struct mga_device *mdev) { struct drm_encoder *encoder; struct drm_connector *connector; int ret; mdev->mode_info.mode_config_initialized = true; mdev->dev->mode_config.max_width = MGAG200_MAX_FB_WIDTH; mdev->dev->mode_config.max_height = MGAG200_MAX_FB_HEIGHT; mdev->dev->mode_config.fb_base = mdev->mc.vram_base; mga_crtc_init(mdev); encoder = mga_encoder_init(mdev->dev); if (!encoder) { DRM_ERROR("mga_encoder_init failed\n"); return -1; } connector = mga_vga_init(mdev->dev); if (!connector) { DRM_ERROR("mga_vga_init failed\n"); return -1; } drm_mode_connector_attach_encoder(connector, encoder); ret = mgag200_fbdev_init(mdev); if (ret) { DRM_ERROR("mga_fbdev_init failed\n"); return ret; } return 0; }
false
false
false
false
false
0
update_saturation_from_rgb(unsigned short *rgb, const unsigned short *brightness_lookup, double adjust, double isat, int do_usermap) { double h, s, l; calc_rgb_to_hsl(rgb, &h, &s, &l); if (do_usermap) { unsigned short ub = (unsigned short) (l * 65535); unsigned short val = brightness_lookup[ub]; l = ((double) val) / 65535; if (val < ub) s = s * (65535 - ub) / (65535 - val); } s = update_saturation(s, adjust, isat, 0); calc_hsl_to_rgb(rgb, h, s, l); }
false
false
false
false
false
0
single_arg_report_root (MonoObject **obj, void *gc_data) { if (*obj) add_profile_gc_root (root_report, *obj, MONO_PROFILE_GC_ROOT_OTHER, 0); }
false
false
false
false
false
0
sort_keyword_list_and_remove_duplicates (GList *keywords) { GList *p; GList *duplicate_link; if (keywords != NULL) { keywords = eel_g_str_list_alphabetize (keywords); p = keywords; while (p->next != NULL) { if (strcmp ((const char *) p->data, (const char *) p->next->data) == 0) { duplicate_link = p->next; keywords = g_list_remove_link (keywords, duplicate_link); g_list_free_full (duplicate_link, g_free); } else { p = p->next; } } } return keywords; }
false
false
false
false
false
0
recompute_size_for_slice (GList *elements, guint width, guint height, guint total_width, guint total_height, guint offset_x, guint offset_y) { GList *l; gint x; gint extra; /* first steal all the allocated minimum width OR fixed_width for each element - then * distribute remaining pixels based on the size_ratio and add * the allocated minimum width. */ extra = width; for (l = elements; l != NULL; l = l->next) { GridElement *element = l->data; if (element->fixed_width > 0) extra -= element->fixed_width; else extra -= get_num_elements_for_slice (element->embedded_elements) * ELEMENT_MINIMUM_WIDTH; } x = 0; for (l = elements; l != NULL; l = l->next) { GridElement *element = l->data; gint element_width; gboolean is_last; guint element_depth; is_last = (l->next == NULL); element_depth = get_depth (element->embedded_elements); //g_debug ("element_depth = %d (x,y)=(%d,%d) height=%d", element_depth, offset_x, offset_y, height); if (is_last) { element_width = width - x; } else { if (element->fixed_width > 0) { g_warn_if_fail (element->size_ratio == 0.0); element_width = element->fixed_width; } else { element_width = element->size_ratio * extra; element_width += get_num_elements_for_slice (element->embedded_elements) * ELEMENT_MINIMUM_WIDTH; } } element->x = x + offset_x; element->y = offset_y; element->width = element_width; if (element_depth > 0) { element->height = height / (element_depth + 1); } else { element->height = height; } if (element->x == 0) element->edge_flags |= GRID_EDGE_LEFT; if (element->y == 0) element->edge_flags |= GRID_EDGE_TOP; if (element->x + element->width == total_width) element->edge_flags |= GRID_EDGE_RIGHT; #if 0 if (element->y + element->height == total_height) element->edge_flags |= GRID_EDGE_BOTTOM; #endif x += element_width; recompute_size_for_slice (element->embedded_elements, element->width, height - element->height, total_width, total_height, element->x, element->height + element->y); } }
false
false
false
false
false
0
msp430_fetch_integer (unsigned int loc) { char *m = &alu.mem[0xffff & loc]; short res; if (wpr[0xffff & loc]) alu.signal = SIGTRAP; res = (0xff & (*m)) | (short) (*(m + 1)) << 8; return res; }
false
false
false
false
false
0
tidyup(__maybe_unused void *arg) { mutex_lock(&quit_restart_lock); SOCKETTYPE *apisock = (SOCKETTYPE *)arg; bye = true; if (*apisock != INVSOCK) { shutdown(*apisock, SHUT_RDWR); CLOSESOCKET(*apisock); *apisock = INVSOCK; } if (ipaccess != NULL) { free(ipaccess); ipaccess = NULL; } io_free(); mutex_unlock(&quit_restart_lock); }
false
false
false
false
false
0
gt_shell_init (GTShell *shell) { g_return_if_fail(gt_shell == NULL); gt_shell = shell; g_object_add_weak_pointer(G_OBJECT(gt_shell), &gt_shell); shell->priv = G_TYPE_INSTANCE_GET_PRIVATE(shell, GT_TYPE_SHELL, GTShellPrivate); shell->priv->translate_session = translate_session_new(NULL); shell->priv->client = gconf_client_get_default(); gt_shell_set_proxy(shell); gt_shell_set_services(shell); gconf_client_notify_add(shell->priv->client, GT_CONF_SERVICES, gt_shell_services_notify_cb, shell, NULL, NULL); gconf_client_add_dir(shell->priv->client, CONF_HTTP_PROXY_NAMESPACE, GCONF_CLIENT_PRELOAD_NONE, NULL); gconf_client_notify_add(shell->priv->client, CONF_HTTP_PROXY_NAMESPACE, gt_shell_proxy_notify_cb, shell, NULL, NULL); gconf_client_add_dir(shell->priv->client, CONF_PROXY_NAMESPACE, GCONF_CLIENT_PRELOAD_NONE, NULL); gconf_client_notify_add(shell->priv->client, CONF_PROXY_NAMESPACE, gt_shell_proxy_notify_cb, shell, NULL, NULL); }
false
false
false
false
false
0
askCompletion(QString stem, QStringList completions) { CompView *view = new CompView(stem, completions, e); int selected = view->exec(e->cursorRect().bottomRight()); delete view; return selected; }
false
false
false
false
false
0
GMT_read_grd_info (char *file, struct GRD_HEADER *header) { /* file: File name * header: grid structure header */ GMT_LONG err; double scale, offset, nan_value; /* Initialize grid information */ GMT_grd_init (header, 0, (char **)VNULL, FALSE); /* Save parameters on file name suffix before issuing GMT_io_readinfo */ GMT_err_trap (GMT_grd_get_format (file, header, TRUE)); scale = header->z_scale_factor, offset = header->z_add_offset, nan_value = header->nan_value; GMT_err_trap ((*GMT_io_readinfo[header->type]) (header)); GMT_grd_get_units (header); if (!GMT_is_dnan(scale)) header->z_scale_factor = scale, header->z_add_offset = offset; if (!GMT_is_dnan(nan_value)) header->nan_value = nan_value; if (header->z_scale_factor == 0.0) fprintf (stderr, "GMT Warning: scale_factor should not be 0.\n"); GMT_err_pass (GMT_grd_RI_verify (header, 0), file); header->z_min = header->z_min * header->z_scale_factor + header->z_add_offset; header->z_max = header->z_max * header->z_scale_factor + header->z_add_offset; header->xy_off = 0.5 * header->node_offset; return (GMT_NOERROR); }
false
false
false
false
false
0
catchsignal(int signum, void(*handler)()))() { struct sigaction new_sa; struct sigaction old_sa; #ifdef DONT_CATCH_SIGNALS fprintf (stderr, "Not catching any signals.\n"); return ((void (*)()) -1); #endif new_sa.sa_handler = handler; sigemptyset(&new_sa.sa_mask); new_sa.sa_flags = 0; if (sigaction(signum, &new_sa, &old_sa) == -1) return ((void (*)()) -1); return (old_sa.sa_handler); }
false
false
false
false
false
0
InitEmptyCeosRecord(CeosRecord_t *record, int32 sequence, CeosTypeCode_t typecode, int32 length) { if(record) { if((record->Buffer = HMalloc(length)) == NULL) { return; } /* First we zero fill the buffer */ memset(record->Buffer,0,length); /* Setup values inside the CeosRecord_t header */ record->Sequence = sequence; record->Flavour = 0; record->FileId = 0; record->TypeCode = typecode; record->Subsequence = 0; record->Length = length; /* Now we fill in the buffer portion as well */ NativeToCeos( record->Buffer+__SEQUENCE_OFF, &(record->Sequence), sizeof(record->Sequence), sizeof( record->Sequence ) ); memcpy(record->Buffer+__TYPE_OFF, &( record->TypeCode.Int32Code ), sizeof( record->TypeCode.Int32Code ) ); NativeToCeos( record->Buffer+__LENGTH_OFF, &length, sizeof( length ), sizeof( length ) ); } }
false
false
false
false
false
0
chasen_standalone(char **argv, FILE * output) { /* * standalone */ if (chasen_getopt_argv(argv, stderr)) return 1; argv += Cha_optind; if (*argv == NULL) do_chasen_standalone(stdin, output); else for (; *argv; argv++) do_chasen_standalone(cha_fopen(*argv, "r", 1), output); return 0; }
false
false
false
false
false
0
CacheInvalidateRelcacheByTuple(HeapTuple classTuple) { Form_pg_class classtup = (Form_pg_class) GETSTRUCT(classTuple); Oid databaseId; Oid relationId; RelFileNode rnode; relationId = HeapTupleGetOid(classTuple); if (classtup->relisshared) databaseId = InvalidOid; else databaseId = MyDatabaseId; if (classtup->reltablespace) rnode.spcNode = classtup->reltablespace; else rnode.spcNode = MyDatabaseTableSpace; rnode.dbNode = databaseId; rnode.relNode = classtup->relfilenode; RegisterRelcacheInvalidation(databaseId, relationId); RegisterSmgrInvalidation(rnode); }
false
false
false
true
false
1
expand_end_all_catch () { struct eh_region *try_region; if (! doing_eh (0)) return; try_region = cfun->eh->try_region; cfun->eh->try_region = try_region->u.try.prev_try; emit_label (try_region->u.try.continue_label); }
false
false
false
false
false
0
MaxCutRandomized(SDPCone sdpcone,int nnodes){ int i,j,derror,info; double dd,scal=RAND_MAX,*vv,*tt,*cc,ymin=0; vv=(double*)malloc(nnodes*sizeof(double)); tt=(double*)malloc(nnodes*sizeof(double)); cc=(double*)malloc((nnodes+2)*sizeof(double)); info=SDPConeComputeXV(sdpcone,0,&derror); for (i=0;i<nnodes;i++){ for (j=0;j<nnodes;j++){dd = (( rand())/scal - .5); vv[j] = tan(3.1415926*dd);} info=SDPConeXVMultiply(sdpcone,0,vv,tt,nnodes); for (j=0;j<nnodes;j++){if (tt[j]<0) tt[j]=-1; else tt[j]=1;} for (j=0;j<nnodes+2;j++){cc[j]=0;} info=SDPConeAddXVAV(sdpcone,0,tt,nnodes,cc,nnodes+2); if (cc[0]<ymin) ymin=cc[0]; } printf("Best integer solution: %4.2f\n",ymin); free(vv); free(tt); free(cc); return(0); }
false
true
false
false
false
1
Initialize() { if (!m_overwriteNpcEntry) m_overwriteNpcEntry = m_owner->GetEntry(); // Loading passengers (rough version only!) SQLMultiStorage::SQLMSIteratorBounds<VehicleAccessory> bounds = sVehicleAccessoryStorage.getBounds<VehicleAccessory>(m_overwriteNpcEntry); for (SQLMultiStorage::SQLMultiSIterator<VehicleAccessory> itr = bounds.first; itr != bounds.second; ++itr) { if (Creature* summoned = m_owner->SummonCreature(itr->passengerEntry, m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), 2 * m_owner->GetOrientation(), TEMPSUMMON_DEAD_DESPAWN, 0)) { DEBUG_LOG("VehicleInfo(of %s)::Initialize: Load vehicle accessory %s onto seat %u", m_owner->GetGuidStr().c_str(), summoned->GetGuidStr().c_str(), itr->seatId); m_accessoryGuids.insert(summoned->GetObjectGuid()); int32 basepoint0 = itr->seatId + 1; summoned->CastCustomSpell((Unit*)m_owner, SPELL_RIDE_VEHICLE_HARDCODED, &basepoint0, NULL, NULL, true); } } // Initialize movement limitations uint32 vehicleFlags = GetVehicleEntry()->m_flags; Unit* pVehicle = (Unit*)m_owner; if (vehicleFlags & VEHICLE_FLAG_NO_STRAFE) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_STRAFE); if (vehicleFlags & VEHICLE_FLAG_NO_JUMPING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_NO_JUMPING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDTURNING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDTURNING); if (vehicleFlags & VEHICLE_FLAG_ALLOW_PITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_ALLOW_PITCHING); if (vehicleFlags & VEHICLE_FLAG_FULLSPEEDPITCHING) pVehicle->m_movementInfo.AddMovementFlags2(MOVEFLAG2_FULLSPEEDPITCHING); // Initialize power type based on DBC values (creatures only) if (pVehicle->GetTypeId() == TYPEID_UNIT) { if (PowerDisplayEntry const* powerEntry = sPowerDisplayStore.LookupEntry(GetVehicleEntry()->m_powerDisplayID)) pVehicle->SetPowerType(Powers(powerEntry->power)); } m_isInitialized = true; }
false
false
false
false
false
0
operator>>(std::istream& in, level& l) { std::string tk; in >> tk; if (!in.bad()) { if (tk == "single") { l = single; } else if (tk == "funneled") { l = funneled; } else if (tk == "serialized") { l = serialized; } else if (tk == "multiple") { l = multiple; } else { in.setstate(std::ios::badbit); } } return in; }
false
false
false
false
false
0
pin_down_extent(struct btrfs_root *root, struct btrfs_block_group_cache *cache, u64 bytenr, u64 num_bytes, int reserved) { spin_lock(&cache->space_info->lock); spin_lock(&cache->lock); cache->pinned += num_bytes; cache->space_info->bytes_pinned += num_bytes; if (reserved) { cache->reserved -= num_bytes; cache->space_info->bytes_reserved -= num_bytes; } spin_unlock(&cache->lock); spin_unlock(&cache->space_info->lock); set_extent_dirty(root->fs_info->pinned_extents, bytenr, bytenr + num_bytes - 1, GFP_NOFS | __GFP_NOFAIL); if (reserved) trace_btrfs_reserved_extent_free(root, bytenr, num_bytes); return 0; }
false
false
false
false
false
0
static_measure_face_vertices (double *min, double *max, double *average, double *deviation, gamgi_voronoi *voronoi) { gamgi_polyhedron *polyhedron; gamgi_face *face; gamgi_vertex *vertex; gamgi_slist *slist_v, *slist_f; int n_seeds, n_faces, n_vertices, i; *min = DBL_MAX; *max = -DBL_MAX; *average = 0.0; *deviation = 0.0; n_faces = 0; n_seeds = voronoi->n_seeds; /*************************************************** * initialize vertex->last, so this function will * * work fine when placed in a different sequence * ***************************************************/ for (i = 0; i < n_seeds; i++) { polyhedron = voronoi->polyhedron[i]; if (polyhedron == NULL) continue; for (slist_v = polyhedron->vertex; slist_v != NULL; slist_v = slist_v->next) { vertex = (gamgi_vertex *) slist_v->data; vertex = static_vertex (vertex); vertex->last = NULL; } } /****************** * count vertices * ******************/ for (i = 0; i < n_seeds; i++) { polyhedron = voronoi->polyhedron[i]; if (polyhedron == NULL) continue; for (slist_f = polyhedron->face; slist_f != NULL; slist_f = slist_f->next) { face = (gamgi_face *) slist_f->data; /************************************* * inner faces are counted only once * *************************************/ if (face->area < voronoi->area) continue; if (face->global == 0 && face->local > polyhedron->local && voronoi->polyhedron[face->local] != NULL) continue; n_faces++; n_vertices = 0; for (slist_v = face->vertex; slist_v != NULL; slist_v = slist_v->next) { vertex = (gamgi_vertex *) slist_v->data; /*************************************************** * vertices in the same face are counted only once * ***************************************************/ vertex = static_vertex (vertex); if (vertex->last == face) continue; vertex->last = face; n_vertices++; } /************** * statistics * **************/ if (n_vertices < *min) *min = n_vertices; if (n_vertices > *max) *max = n_vertices; *average += n_vertices; *deviation += n_vertices * n_vertices; } } static_expectancy (average, deviation, n_faces); }
false
false
false
false
false
0
ipc_create_pmc_devices(void) { int ret; ret = ipc_create_tco_device(); if (ret) { dev_err(ipcdev.dev, "Failed to add tco platform device\n"); return ret; } ret = ipc_create_punit_device(); if (ret) { dev_err(ipcdev.dev, "Failed to add punit platform device\n"); platform_device_unregister(ipcdev.tco_dev); } if (!ipcdev.telem_res_inval) { ret = ipc_create_telemetry_device(); if (ret) dev_warn(ipcdev.dev, "Failed to add telemetry platform device\n"); } return ret; }
false
false
false
false
false
0
dpm_get_reqs_by_u_desc(dbfd, bol, u_token, uid, dpm_req, endlist, dblistptr) struct dpm_dbfd *dbfd; int bol; char *u_token; uid_t uid; struct dpm_req *dpm_req; int endlist; DBLISTPTR *dblistptr; { char func[23]; static char queryo[] = "SELECT \ R_ORDINAL, R_TOKEN, R_UID, \ R_GID, CLIENT_DN, CLIENTHOST, \ R_TYPE, U_TOKEN, \ FLAGS, RETRYTIME, NBREQFILES, \ CTIME, STIME, ETIME, \ STATUS, ERRSTRING, GROUPS \ FROM dpm_req \ WHERE r_uid = %d"; static char queryto[] = "SELECT \ R_ORDINAL, R_TOKEN, R_UID, \ R_GID, CLIENT_DN, CLIENTHOST, \ R_TYPE, U_TOKEN, \ FLAGS, RETRYTIME, NBREQFILES, \ CTIME, STIME, ETIME, \ STATUS, ERRSTRING, GROUPS \ FROM dpm_req \ WHERE u_token = '%s' AND r_uid = %d"; PGresult *res; char sql_stmt[1024]; strcpy (func, "dpm_get_reqs_by_u_desc"); if (endlist) { PQclear (dblistptr->res); return (1); } if (bol) { if (*u_token) sprintf (sql_stmt, queryto, u_token, uid); else sprintf (sql_stmt, queryo, uid); res = PQexec (dbfd->Pconn, sql_stmt); if (PQresultStatus (res) != PGRES_TUPLES_OK) { dpm_libpq_error (func, "SELECT", res, dbfd); return (-1); } dblistptr->res = res; dblistptr->row = 0; } if (dblistptr->row >= PQntuples (dblistptr->res)) return (1); dpm_decode_xferreq_entry (dblistptr->res, dblistptr->row, 0, NULL, dpm_req); dblistptr->row++; return (0); }
false
false
false
false
false
0
FFTHiPassFilter( double fc, wxPlotData::FFTFilter_Type filter, double n ) { wxCHECK_MSG( Ok() && (n>0), wxPlotData(), wxT("Invalid wxPlotData") ); wxPlotData xform( FFT(true) ); int i, count = xform.GetCount(); double f, x; double *ydata = xform.GetYData(), *yidata = xform.GetYiData(); for (i=0; i<count; i++) { x = xform.GetXData()[i]; if ((filter == FilterStep) && (x < fc)) { *ydata = 0; *yidata = 0; } else { if (filter == FilterButterworth) f = 1.0 - 1.0/(1.0 + pow(x/fc, 2.0*n)); else if (filter == FilterGaussian) f = exp(-fc*fc/(2.0*x*x)); else // (filter == FilterFermi) f = 1.0/(1.0+exp((fc-x)/(n))); *ydata *= f; *yidata *= f; } ydata++; yidata++; } wxPlotData dest( xform.FFT(false) ); dest.OffsetX(M_PLOTDATA->m_Xdata[0]); dest.CalcBoundingRect(); return dest; }
false
false
false
false
false
0
tinf_getbit(TINF_DATA *d) { unsigned int bit; /* check if tag is empty */ if (!d->bitcount--) { /* load next tag */ if((d->sourceLen + 1) > d->sourceSize) return 0; // better than ignoring it d->tag = *d->source++; d->sourceLen++; d->bitcount = 7; } /* shift bit out of tag */ bit = d->tag & 0x01; d->tag >>= 1; return bit; }
false
false
false
false
false
0
inzcont(register char **const fields, const int nfields) { if (nfields < ZONEC_MINFIELDS || nfields > ZONEC_MAXFIELDS) { error(_("wrong number of fields on Zone continuation line")); return FALSE; } return inzsub(fields, nfields, TRUE); }
false
false
false
false
false
0
tpm_check_resource(struct acpi_resource *ares, void *data) { struct tpm_info *tpm_info = (struct tpm_info *) data; struct resource res; if (acpi_dev_resource_interrupt(ares, 0, &res)) tpm_info->irq = res.start; else if (acpi_dev_resource_memory(ares, &res)) { tpm_info->res = res; tpm_info->res.name = NULL; } return 1; }
false
false
false
false
false
0
get_pgm_tx_tilemap_tile_info(int tile_index) { /* 0x904000 - 0x90ffff is the Text Overlay Ram (pgm_tx_videoram) each tile uses 4 bytes, the tilemap is 64x128? the layer uses 4bpp 8x8 tiles from the 'T' roms colours from 0xA01000 - 0xA017FF scroll registers are at 0xB05000 (Y) and 0xB06000 (X) ---- ---- ffpp ppp- nnnn nnnn nnnn nnnn n = tile number p = palette f = flip */ int tileno,colour,flipyx; //,game; tileno = pgm_tx_videoram[tile_index *2] & 0xffff; colour = (pgm_tx_videoram[tile_index*2+1] & 0x3e) >> 1; flipyx = (pgm_tx_videoram[tile_index*2+1] & 0xc0) >> 6;; if (tileno > 0xbfff) { tileno -= 0xc000 ; tileno += 0x20000; } /* not sure about this */ SET_TILE_INFO(0,tileno,colour,TILE_FLIPYX(flipyx)) }
false
false
false
false
false
0
champlain_network_tile_source_dispose (GObject *object) { ChamplainNetworkTileSourcePrivate *priv = CHAMPLAIN_NETWORK_TILE_SOURCE (object)->priv; if (priv->soup_session) { soup_session_abort (priv->soup_session); g_object_unref (priv->soup_session); priv->soup_session = NULL; } G_OBJECT_CLASS (champlain_network_tile_source_parent_class)->dispose (object); }
false
false
false
false
false
0
getline_r210 (ColorspaceConvert * convert, guint8 * dest, const guint8 * src, int j) { int i; const guint8 *srcline = FRAME_GET_LINE (src, 0, j); for (i = 0; i < convert->width; i++) { guint8 x; dest[i * 4 + 0] = 0xff; x = GST_READ_UINT32_BE (srcline + i * 4); dest[i * 4 + 1] = (x >> 22) & 0xff; dest[i * 4 + 2] = (x >> 12) & 0xff; dest[i * 4 + 3] = (x >> 2) & 0xff; } }
false
false
false
false
false
0
qlcnic_82xx_get_mac_address(struct qlcnic_adapter *adapter, u8 *mac, u8 function) { int err, i; struct qlcnic_cmd_args cmd; u32 mac_low, mac_high; err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_MAC_ADDRESS); if (err) return err; cmd.req.arg[1] = function | BIT_8; err = qlcnic_issue_cmd(adapter, &cmd); if (err == QLCNIC_RCODE_SUCCESS) { mac_low = cmd.rsp.arg[1]; mac_high = cmd.rsp.arg[2]; for (i = 0; i < 2; i++) mac[i] = (u8) (mac_high >> ((1 - i) * 8)); for (i = 2; i < 6; i++) mac[i] = (u8) (mac_low >> ((5 - i) * 8)); } else { dev_err(&adapter->pdev->dev, "Failed to get mac address%d\n", err); err = -EIO; } qlcnic_free_mbx_args(&cmd); return err; }
false
false
false
false
false
0
hasChildren( const QModelIndex &parent ) const { if( !parent.isValid() ) return true; if( isGroup( parent ) ) return !m_groupHash.value( parent.row() ).isEmpty(); return sourceModel()->hasChildren( mapToSource( parent ) ); }
false
false
false
false
false
0
cc_background_item_get_frame_thumbnail (CcBackgroundItem *item, GnomeDesktopThumbnailFactory *thumbs, int width, int height, int frame, gboolean force_size) { GdkPixbuf *pixbuf = NULL; GIcon *icon = NULL; g_return_val_if_fail (CC_IS_BACKGROUND_ITEM (item), NULL); g_return_val_if_fail (width > 0 && height > 0, NULL); set_bg_properties (item); if (force_size) { /* FIXME: this doesn't play nice with slideshow stepping at all, * because it will always render the current slideshow frame, which * might not be what we want. * We're lacking an API to draw a high-res GnomeBG manually choosing * the slideshow frame though, so we can't do much better than this * for now. */ pixbuf = render_at_size (item->priv->bg, width, height); } else { if (frame >= 0) { pixbuf = gnome_bg_create_frame_thumbnail (item->priv->bg, thumbs, gdk_screen_get_default (), width, height, frame); } else { pixbuf = gnome_bg_create_thumbnail (item->priv->bg, thumbs, gdk_screen_get_default (), width, height); } } if (pixbuf != NULL && frame != -2 && gnome_bg_changes_with_time (item->priv->bg)) { GEmblem *emblem; emblem = get_slideshow_icon (); icon = g_emblemed_icon_new (G_ICON (pixbuf), emblem); g_object_unref (emblem); g_object_unref (pixbuf); } else { icon = G_ICON (pixbuf); } gnome_bg_get_image_size (item->priv->bg, thumbs, width, height, &item->priv->width, &item->priv->height); update_size (item); return icon; }
false
false
false
false
false
0
sLadTlg_create(List *block_list) { sLadTlg *tlg; tlg = (sLadTlg *)malloc(sizeof(sLadTlg)); if (tlg == NULL) fatal("alloc failed\n"); tlg->lad_list = dir2lad(block_list); return tlg; }
false
false
false
false
false
0
outswoffset (offset) offset_T offset; { #ifdef FRAMEPOINTER outoffset(offset - softsp - framep); #else outoffset(offset - softsp - sp); #endif outplus(); outswstacklab(); #ifdef I8088 bumplc(); #ifdef I80386 if (i386_32) bumplc2(); #endif #endif }
false
false
false
false
false
0
draw_vline (GtkStyle * style, GdkWindow * window, GtkStateType state_type, GdkRectangle * area, GtkWidget * widget, const gchar * detail, gint y1, gint y2, gint x) { if (DETAIL ("handlebox") || DETAIL ("dockitem")) { real_draw_line (style, window, GTK_ORIENTATION_VERTICAL, area, GTK_SHADOW_OUT, state_type, detail, y1, y2, x, 0); } else { real_draw_line (style, window, GTK_ORIENTATION_VERTICAL, area, GTK_SHADOW_IN, state_type, detail, y1, y2, x, 0); } }
false
false
false
false
false
0
series_2(double r, gsl_sf_result * result) { static const int kmax = 100; double rk = r; double sum = 0.5 * r; int k; for(k=2; k<10; k++) { double ds; rk *= r; ds = rk/(k*k*(k+1.0)); sum += ds; } for(; k<kmax; k++) { double ds; rk *= r; ds = rk/(k*k*(k+1.0)); sum += ds; if(fabs(ds/sum) < 0.5*GSL_DBL_EPSILON) break; } result->val = sum; result->err = 2.0 * kmax * GSL_DBL_EPSILON * fabs(sum); return GSL_SUCCESS; }
false
false
false
false
false
0
init_context_stack() { static bool did_init = false; if ( !did_init ) { did_init = true; context_stack[0] = current_alloc_context = 0; } }
false
false
false
false
false
0
SetMagnification (float m) { register Perspective* p = perspective; float factor; Coord cx, cy, halfw, halfh; if (_zooming == Binary) { m = NearestPow2(m); } factor = LimitMagnification(m)/_mag; if (_graphic != nil && factor != 1.0) { halfw = p->curwidth/2; halfh = p->curheight/2; cx = p->curx + halfw; cy = p->cury + halfh; _graphic->Scale(factor, factor, float(halfw), float(halfh)); _x0 = Math::round((_x0 - halfw)*factor + halfw); _y0 = Math::round((_y0 - halfh)*factor + halfh); p->width = Math::round(p->width * factor); p->height = Math::round(p->height * factor); p->curx = Math::round(float(cx) * factor) - halfw; p->cury = Math::round(float(cy) * factor) - halfh; p->Update(); Draw(); } _mag *= factor; }
false
false
false
false
false
0
patestCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { paTestData *data = (paTestData*)userData; float *out = (float*)outputBuffer; unsigned long i; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) inputBuffer; for( i=0; i<framesPerBuffer; i++ ) { *out++ = data->sine[data->left_phase]; /* left */ *out++ = data->sine[data->right_phase]; /* right */ data->left_phase += 1; if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE; data->right_phase += 3; /* higher pitch so we can distinguish left and right. */ if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE; } return paContinue; }
false
false
false
false
false
0
intel_pstate_setup(char *str) { if (!str) return -EINVAL; if (!strcmp(str, "disable")) no_load = 1; if (!strcmp(str, "no_hwp")) { pr_info("intel_pstate: HWP disabled\n"); no_hwp = 1; } if (!strcmp(str, "force")) force_load = 1; if (!strcmp(str, "hwp_only")) hwp_only = 1; return 0; }
false
false
false
false
false
0
cb_search_keypress (GtkWidget *widget, GdkEventKey *event, gpointer data) { gint index; gchar text[20]; strcpy (text, gtk_entry_get_text (GTK_ENTRY(search_entry))); if ( (strlen (text)) <= 1 ) { gimmix_update_library_with_dir ("/"); return; } index = gtk_combo_box_get_active (GTK_COMBO_BOX(search_combo)); gimmix_library_search (index, text); return; }
false
true
false
false
false
1
data_address_ok(const sockaddr_u *dp,bool verify_address,bool verify_port) { sockaddr_u d; sockaddr_u c; socklen_t len; len=sizeof(d); if(dp) d=*dp; else if(getpeername(data_sock,&d.sa,&len)==-1) { LogError(0,"getpeername(data_sock): %s\n",strerror(errno)); return !verify_address && !verify_port; } len=sizeof(c); if(getpeername(control_sock,&c.sa,&len)==-1) { LogError(0,"getpeername(control_sock): %s\n",strerror(errno)); return !verify_address; } #if INET6 if(d.sa.sa_family==AF_INET && c.sa.sa_family==AF_INET6 && IN6_IS_ADDR_V4MAPPED(&c.in6.sin6_addr)) { if(memcmp(&d.in.sin_addr,&c.in6.sin6_addr.s6_addr[12],4)) goto address_mismatch; if(d.in.sin_port!=htons(FTP_DATA_PORT) && d.in.sin_port!=htons(FTPS_DATA_PORT)) goto wrong_port; } #endif if(d.sa.sa_family!=c.sa.sa_family) return false; if(d.sa.sa_family==AF_INET) { if(memcmp(&d.in.sin_addr,&c.in.sin_addr,sizeof(d.in.sin_addr))) goto address_mismatch; if(d.in.sin_port!=htons(FTP_DATA_PORT) && d.in.sin_port!=htons(FTPS_DATA_PORT)) goto wrong_port; return true; } #if INET6 # ifndef IN6_ARE_ADDR_EQUAL # define IN6_ARE_ADDR_EQUAL(a,b) (!memcmp((a),(b),16)) # endif if(d.sa.sa_family==AF_INET6) { if(!IN6_ARE_ADDR_EQUAL(&d.in6.sin6_addr,&c.in6.sin6_addr)) goto address_mismatch; if(d.in6.sin6_port!=htons(FTP_DATA_PORT) && d.in6.sin6_port!=htons(FTPS_DATA_PORT)) goto wrong_port; return true; } #endif return true; wrong_port: if(!verify_port) return true; LogError(0,_("Data connection peer has wrong port number")); return false; address_mismatch: if(!verify_address) return true; LogError(0,_("Data connection peer has mismatching address")); return false; }
false
false
false
false
false
0
setbitCommand(redisClient *c) { robj *o; char *err = "bit is not an integer or out of range"; size_t bitoffset; int byte, bit; int byteval, bitval; long on; if (getBitOffsetFromArgument(c,c->argv[2],&bitoffset) != REDIS_OK) return; if (getLongFromObjectOrReply(c,c->argv[3],&on,err) != REDIS_OK) return; /* Bits can only be set or cleared... */ if (on & ~1) { addReplyError(c,err); return; } o = lookupKeyWrite(c->db,c->argv[1]); if (o == NULL) { o = createObject(REDIS_STRING,sdsempty()); dbAdd(c->db,c->argv[1],o); } else { if (checkType(c,o,REDIS_STRING)) return; o = dbUnshareStringValue(c->db,c->argv[1],o); } /* Grow sds value to the right length if necessary */ byte = bitoffset >> 3; o->ptr = sdsgrowzero(o->ptr,byte+1); /* Get current values */ byteval = ((uint8_t*)o->ptr)[byte]; bit = 7 - (bitoffset & 0x7); bitval = byteval & (1 << bit); /* Update byte with new bit value and return original value */ byteval &= ~(1 << bit); byteval |= ((on & 0x1) << bit); ((uint8_t*)o->ptr)[byte] = byteval; signalModifiedKey(c->db,c->argv[1]); notifyKeyspaceEvent(REDIS_NOTIFY_STRING,"setbit",c->argv[1],c->db->id); server.dirty++; addReply(c, bitval ? shared.cone : shared.czero); }
false
false
false
false
false
0
flickcurl_error_varargs(flickcurl* fc, const char *message, va_list arguments) { if(fc && fc->error_handler) { char *buffer = my_vsnprintf(message, arguments); if(!buffer) { fprintf(stderr, "flickcurl: Out of memory\n"); return; } fc->error_handler(fc->error_data, buffer); free(buffer); } else { fprintf(stderr, "flickcurl error - "); vfprintf(stderr, message, arguments); fputc('\n', stderr); } }
false
false
false
false
true
1
handleGetLimit(UCalendarDateFields field, ELimitType limitType) const { switch(field) { case UCAL_ERA: if (limitType == UCAL_LIMIT_MINIMUM || limitType == UCAL_LIMIT_GREATEST_MINIMUM) { return 0; } return kCurrentEra; case UCAL_YEAR: { switch (limitType) { case UCAL_LIMIT_MINIMUM: case UCAL_LIMIT_GREATEST_MINIMUM: return 1; case UCAL_LIMIT_LEAST_MAXIMUM: return 1; case UCAL_LIMIT_COUNT: //added to avoid warning case UCAL_LIMIT_MAXIMUM: return GregorianCalendar::handleGetLimit(UCAL_YEAR, UCAL_LIMIT_MAXIMUM) - kEraInfo[kCurrentEra].year; default: return 1; // Error condition, invalid limitType } } default: return GregorianCalendar::handleGetLimit(field,limitType); } }
false
false
false
false
false
0
string_tolower2(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t buflen) { char *bufptr, *dataptr = data; if (buflen > -1) { ast_str_make_space(buf, buflen > 0 ? buflen : strlen(data) + 1); } bufptr = ast_str_buffer(*buf); while ((bufptr < ast_str_buffer(*buf) + ast_str_size(*buf) - 1) && (*bufptr++ = tolower(*dataptr++))); ast_str_update(*buf); return 0; }
false
false
false
false
false
0
out_byte(struct rubin_state *rs, unsigned char byte) { int i, ret; struct rubin_state rs_copy; rs_copy = *rs; for (i=0; i<8; i++) { ret = encode(rs, rs->bit_divider-rs->bits[i], rs->bits[i], byte & 1); if (ret) { /* Failed. Restore old state */ *rs = rs_copy; return ret; } byte >>= 1 ; } return 0; }
false
false
false
false
false
0
srv_header(int argc, char **argv) { vaheader_t header; int fd; char *msgname; if ((!client_spool) || (!client_user) || (!(client_access & VBOXD_ACC_READ))) { message("%s Access denied (no read access).\r\n", VBOXD_VAL_ACCESSDENIED); return; } if (argc != 2) { message("%s usage: %s <message>\r\n", VBOXD_VAL_BADARGS, argv[0]); return; } if (chdir(client_spool) != 0) { message("%s Access denied (messagebox inaccessible).\r\n", VBOXD_VAL_ACCESSDENIED); return; } if (!(msgname = rindex(argv[1], '/'))) { msgname = argv[1]; } else msgname++; if ((fd = open(msgname, O_RDONLY)) != -1) { if (header_get(fd, &header)) { message("%s %d\r\n", VBOXD_VAL_HEADER, sizeof(vaheader_t)); pullmsg(stdout); write(STDOUT_FILENO, (char *)&header, sizeof(vaheader_t)); message("%s .\r\n", VBOXD_VAL_HEADER); pullmsg(stdout); } else message("%s Not a vbox message.\r\n", VBOXD_VAL_BADMESSAGE); } else message("%s Can't open message (%s).\r\n", VBOXD_VAL_TEMPERROR, strerror(errno)); }
false
false
false
false
true
1
GetAttrib(const string& inName) { map<std::string, string>::const_iterator p = TopAttrib().find(inName); if (p != TopAttrib().end()) { return MushcoreScalar(p->second); } else { return MushcoreScalar(""); } }
false
false
false
false
false
0
nutscan_scan_nut(const char* startIP, const char* stopIP, const char* port,long usec_timeout) { nutscan_ip_iter_t ip; char * ip_str = NULL; char * ip_dest = NULL; char buf[SMALLBUF]; struct sigaction oldact; int change_action_handler = 0; int i; struct scan_nut_arg *nut_arg; #ifdef HAVE_PTHREAD pthread_t thread; pthread_t * thread_array = NULL; int thread_count = 0; pthread_mutex_init(&dev_mutex,NULL); #endif if( !nutscan_avail_nut ) { return NULL; } /* Ignore SIGPIPE if the caller hasn't set a handler for it yet */ if( sigaction(SIGPIPE, NULL, &oldact) == 0 ) { if( oldact.sa_handler == SIG_DFL ) { change_action_handler = 1; signal(SIGPIPE,SIG_IGN); } } ip_str = nutscan_ip_iter_init(&ip,startIP,stopIP); while( ip_str != NULL ) { if( port ) { if( ip.type == IPv4 ) { snprintf(buf,sizeof(buf),"%s:%s",ip_str,port); } else { snprintf(buf,sizeof(buf),"[%s]:%s",ip_str,port); } ip_dest = strdup(buf); } else { ip_dest = strdup(ip_str); } if((nut_arg = malloc(sizeof(struct scan_nut_arg))) == NULL ) { free(ip_dest); break; } nut_arg->timeout = usec_timeout; nut_arg->hostname = ip_dest; #ifdef HAVE_PTHREAD if (pthread_create(&thread,NULL,list_nut_devices,(void*)nut_arg)==0){ thread_count++; thread_array = realloc(thread_array, thread_count*sizeof(pthread_t)); thread_array[thread_count-1] = thread; } #else list_nut_devices(nut_arg); #endif free(ip_str); ip_str = nutscan_ip_iter_inc(&ip); } #ifdef HAVE_PTHREAD for ( i=0; i < thread_count ; i++) { pthread_join(thread_array[i],NULL); } pthread_mutex_destroy(&dev_mutex); free(thread_array); #endif if(change_action_handler) { signal(SIGPIPE,SIG_DFL); } return dev_ret; }
false
false
false
false
false
0
generaConjunts(int tipusTangram){ //eliminam les peces actuals sceneFiguresPrograma->clear(); sceneFiguresNoves->clear(); sceneComparacio->clear(); conjuntMostraPrograma=new ConjuntPeces(tipusTangram,ESCALA_MOSTRA); conjuntMostraPrograma->conjuntDeMostra(); conjuntMostraPrograma->conjuntVisible(false); conjuntMostraNovesFigures=new ConjuntPeces(tipusTangram,ESCALA_MOSTRA); conjuntMostraNovesFigures->conjuntDeMostra(); conjuntMostraNovesFigures->conjuntVisible(false); conjuntComparacioOriginal=new ConjuntPeces(tipusTangram,ESCALA_GENERAL); conjuntComparacioOriginal->conjuntDeMostra(); conjuntComparacioOriginal->conjuntVisible(false); conjuntComparacioComparada=new ConjuntPeces(tipusTangram,ESCALA_GENERAL); conjuntComparacioComparada->conjuntDeMostra(); conjuntComparacioComparada->conjuntVisible(false); //ara afegim les peces a l'scena for(int i=0;i<=conjuntMostraPrograma->arrayPeces.size()-1;i++){ conjuntMostraPrograma->arrayPeces[i]->setZValue(0); sceneFiguresPrograma->addItem(conjuntMostraPrograma->arrayPeces[i]); conjuntMostraNovesFigures->arrayPeces[i]->setZValue(0); sceneFiguresNoves->addItem(conjuntMostraNovesFigures->arrayPeces[i]); conjuntComparacioOriginal->arrayPeces[i]->setZValue(0); sceneComparacio->addItem(conjuntComparacioOriginal->arrayPeces[i]); conjuntComparacioComparada->arrayPeces[i]->setZValue(0); sceneComparacio->addItem(conjuntComparacioComparada->arrayPeces[i]); } }
false
false
false
false
false
0
ClientUserinfoChanged(edict_t * ent, char *userinfo) { char *s, *r, tnick[16]; qboolean nickChanged = false; // check for malformed or illegal info strings if (!Info_Validate(userinfo)) { strcpy(userinfo, "\\name\\badinfo\\skin\\male/grunt"); } // set name s = Info_ValueForKey(userinfo, "name"); Q_strncpyz(tnick, s, sizeof(tnick)); if(!tnick[0]) strcpy(tnick, "unnamed"); if(strcmp(ent->client->pers.netname, tnick)) { // on the initial update, we won't broadcast the message. if (ent->client->pers.netname[0]) { gi.bprintf(PRINT_MEDIUM, "%s is now known as %s.\n", ent->client->pers.netname, tnick); //TempFile IRC_printf(IRC_T_SERVER, "%n is now known as %n.", ent->client->pers.netname, tnick); nickChanged = true; } strcpy(ent->client->pers.netname, tnick); } //FIREBLADE s = Info_ValueForKey(userinfo, "spectator"); ent->client->pers.spectator = (strcmp(s, "0") != 0); r = Info_ValueForKey(userinfo, "rate"); ent->client->rate = atoi(r); //FIREBLADE // set skin s = Info_ValueForKey(userinfo, "skin"); // AQ:TNG - JBravo fixing $$ Skin server crash bug if (strstr(s, "$$")) { Info_SetValueForKey(userinfo, "skin", "male/grunt"); s = Info_ValueForKey(userinfo, "skin"); } // End $$ Skin server crash bug // combine name and skin into a configstring AssignSkin(ent, s, nickChanged); /* Not used in Action. // fov if (deathmatch->value && ((int)dmflags->value & DF_FIXED_FOV)) { ent->client->ps.fov = 90; } else { ent->client->ps.fov = atoi(Info_ValueForKey(userinfo, "fov")); if (ent->client->ps.fov < 1) ent->client->ps.fov = 90; else if (ent->client->ps.fov > 160) ent->client->ps.fov = 160; } */ ent->client->pers.firing_style = ACTION_FIRING_CENTER; // handedness s = Info_ValueForKey(userinfo, "hand"); if (strlen(s)) { ent->client->pers.hand = atoi(s); if (strstr(s, "classic high") != NULL) ent->client->pers.firing_style = ACTION_FIRING_CLASSIC_HIGH; else if (strstr(s, "classic") != NULL) ent->client->pers.firing_style = ACTION_FIRING_CLASSIC; } // save off the userinfo in case we want to check something later Q_strncpyz(ent->client->pers.userinfo, userinfo, sizeof(ent->client->pers.userinfo)); // zucc vwep ShowGun(ent); }
true
true
true
false
true
1
modeNumber(bool & cc, tcPDPtr parent, const tPDVector & children) const { vector<long> id; id.push_back(parent->id()); for(unsigned int ix=0;ix<children.size();++ix) id.push_back(children[ix]->id()); return modeNumber(cc,id); }
false
false
false
false
false
0
more_args() const { return next_alias_arg != alias_args.begin() || argc > 0; }
false
false
false
false
false
0
cmp_mean_interarriv_tim(word64 *timvalp, struct q_hdr_t *q_p) { register int32 qi, i; word64 avgtim, arrdif, quot, rem; /* for one or less size q mean always 0 */ if (q_p->q_size <= 1) { *timvalp = 0ULL; return; } avgtim = 0ULL; if (q_p->q_fifo) { for (qi = q_p->q_hdr, i = 0; i < q_p->q_size; i++) { if ((++qi) >= q_p->q_size) qi = 0; if (i == 0) continue; arrdif = q_p->qarr[qi].enter_tim - q_p->qarr[qi - 1].enter_tim; avgtim += arrdif; } } else { /* easy lifo stack case */ for (qi = 0; qi < q_p->q_size; qi++) { if (qi == 0) continue; arrdif = q_p->qarr[qi].enter_tim - q_p->qarr[qi - 1].enter_tim; avgtim += arrdif; } } /* divide - round - know q at least 2 elements to get here */ /* SJM 02/03/00 - cast of negative (>2**31) sign extends need word32 1st */ quot = avgtim/((word64) (((word32) q_p->q_size) - 1)); rem = avgtim % ((word64) (((word32) q_p->q_size) - 1)); avgtim = quot; if (rem >= ((word64) (((word32) q_p->q_size)/2))) avgtim++; *timvalp = avgtim; }
false
false
false
false
false
0
SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion /* = CEC_VERSION_1_4 */) { if (m_iLogicalAddress == CECDEVICE_UNREGISTERED) return; { CLockObject lock(m_mutex); switch (newStatus) { case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC: if (m_deviceStatus != newStatus) LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'handled by libCEC'", GetLogicalAddressName(), m_iLogicalAddress); SetPowerStatus (CEC_POWER_STATUS_ON); SetVendorId (CEC_VENDOR_PULSE_EIGHT); SetMenuState (CEC_MENU_STATE_ACTIVATED); SetCecVersion (libCECSpecVersion); SetStreamPath (CEC_INVALID_PHYSICAL_ADDRESS); MarkAsInactiveSource(); m_iLastActive = 0; m_deviceStatus = newStatus; break; case CEC_DEVICE_STATUS_PRESENT: if (m_deviceStatus != newStatus) LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'present'", GetLogicalAddressName(), m_iLogicalAddress); m_deviceStatus = newStatus; m_iLastActive = GetTimeMs(); break; case CEC_DEVICE_STATUS_NOT_PRESENT: if (m_deviceStatus != newStatus) { LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'not present'", GetLogicalAddressName(), m_iLogicalAddress); ResetDeviceStatus(true); m_deviceStatus = newStatus; } break; default: ResetDeviceStatus(); break; } } }
false
false
false
false
false
0
set_pwm(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count) { struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr); struct adt7462_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; long temp; if (kstrtol(buf, 10, &temp)) return -EINVAL; temp = clamp_val(temp, 0, 255); mutex_lock(&data->lock); data->pwm[attr->index] = temp; i2c_smbus_write_byte_data(client, ADT7462_REG_PWM(attr->index), temp); mutex_unlock(&data->lock); return count; }
false
false
false
false
false
0
lt_lang_db_ref(lt_lang_db_t *langdb) { lt_return_val_if_fail (langdb != NULL, NULL); return lt_mem_ref((lt_mem_t *)langdb); }
false
false
false
false
false
0
skipLock(skipList list, UINT32 key, skipItem *save, INT32 top) { INT32 i; skipItem x, y; if(list->threaded) readLock(list); x = list->header; /* header contains all levels */ for(i = top; /* loop from top level down to level 0 */ i >= 0; i--) { y = x->next[i]; /* get next item at this level */ while(y->key < key) { /* if y has a smaller key, try the next item */ x = y; /* save x in case we overshoot */ y = x->next[i]; /* get next item */ } save[i] = x; /* preserve item with next pointer in save */ } if(list->threaded) writeLock(list); /* lock list for update */ /* validate we have the closest previous item */ return skipClosest(x, key, 0); }
false
false
false
false
false
0
style_symbol_type_draw(struct style *style, cairo_t *cairoctx, enum key_action_type type, gdouble w, gdouble h) { START_FUNC GSList *item=style->type_symbols; while (item && (type!=((struct symbol *)item->data)->id.type)) { item=g_slist_next(item); } if (item) { if (((struct symbol *)item->data)->label) { style_draw_text(style, cairoctx, ((struct symbol *)item->data)->label, w, h); } else { style_render_svg(cairoctx, ((struct symbol *)item->data)->svg, w, h, TRUE, NULL); } } else flo_error(_("No style symbol for action key %d"), type); END_FUNC }
false
false
false
false
false
0
x509_self_test( int verbose ) { #if defined(POLARSSL_CERTS_C) && defined(POLARSSL_MD5_C) int ret; int flags; size_t i, j; x509_cert cacert; x509_cert clicert; rsa_context rsa; #if defined(POLARSSL_DHM_C) dhm_context dhm; #endif if( verbose != 0 ) printf( " X.509 certificate load: " ); memset( &clicert, 0, sizeof( x509_cert ) ); ret = x509parse_crt( &clicert, (unsigned char *) test_cli_crt, strlen( test_cli_crt ) ); if( ret != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } memset( &cacert, 0, sizeof( x509_cert ) ); ret = x509parse_crt( &cacert, (unsigned char *) test_ca_crt, strlen( test_ca_crt ) ); if( ret != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n X.509 private key load: " ); i = strlen( test_ca_key ); j = strlen( test_ca_pwd ); rsa_init( &rsa, RSA_PKCS_V15, 0 ); if( ( ret = x509parse_key( &rsa, (unsigned char *) test_ca_key, i, (unsigned char *) test_ca_pwd, j ) ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n X.509 signature verify: "); ret = x509parse_verify( &clicert, &cacert, NULL, "PolarSSL Client 2", &flags, NULL, NULL ); if( ret != 0 ) { printf("%02x", flags); if( verbose != 0 ) printf( "failed\n" ); return( ret ); } #if defined(POLARSSL_DHM_C) if( verbose != 0 ) printf( "passed\n X.509 DHM parameter load: " ); i = strlen( test_dhm_params ); j = strlen( test_ca_pwd ); if( ( ret = x509parse_dhm( &dhm, (unsigned char *) test_dhm_params, i ) ) != 0 ) { if( verbose != 0 ) printf( "failed\n" ); return( ret ); } if( verbose != 0 ) printf( "passed\n\n" ); #endif x509_free( &cacert ); x509_free( &clicert ); rsa_free( &rsa ); #if defined(POLARSSL_DHM_C) dhm_free( &dhm ); #endif return( 0 ); #else ((void) verbose); return( POLARSSL_ERR_X509_FEATURE_UNAVAILABLE ); #endif }
false
false
false
false
false
0
uptime(void) { #ifdef __FreeBSD__ struct timeval boottime; time_t now; int mib[2]; size_t size; time_t u; static char buf[1025]; (void)time(&now); mib[0] = CTL_KERN; mib[1] = KERN_BOOTTIME; size = sizeof(boottime); if (sysctl(mib, 2, &boottime, &size, NULL, 0) != -1 && boottime.tv_sec != 0) { u = now - boottime.tv_sec; if (u > 60) u += 30; if (SNCHECK(snprintf(buf, sizeof buf, "%lu days, %lu:%02lu:%02lu", u / 86400UL, u / 3600UL % 24UL, u / 60UL % 60UL, u % 60UL), sizeof buf)) { _exit(EXIT_FAILURE); } } return buf; #else int f; ssize_t r; unsigned long u; static char buf[1025]; if ((f = open("/proc/uptime", O_RDONLY)) == -1) { return "?"; } while ((r = read(f, buf, sizeof buf - 1U)) < (ssize_t) 0 && errno == EINTR); if (r <= (ssize_t) 0) { close(f); return "?"; } close(f); u = strtoul(buf, NULL, 10); if (SNCHECK(snprintf(buf, sizeof buf, "%lu days, %lu:%02lu:%02lu", u / 86400UL, u / 3600UL % 24UL, u / 60UL % 60UL, u % 60UL), sizeof buf)) { _exit(EXIT_FAILURE); } return buf; #endif }
false
false
false
false
false
0
shell_interaction_close() { if(has_terminal) set_term_mod(initial); if(input >= 0) { close(input); input = -1; } }
false
false
false
false
false
0
eina_stringshare_del(Eina_Stringshare *str) { int slen; if (!str) return; /* special cases */ if (str[0] == '\0') slen = 0; else if (str[1] == '\0') slen = 1; else if (str[2] == '\0') slen = 2; else if (str[3] == '\0') slen = 3; else slen = 4; /* handled later */ if (slen < 2) return; else if (slen < 4) { eina_share_common_population_del(stringshare_share, slen); eina_lock_take(&_mutex_small); _eina_stringshare_small_del(str, slen); eina_lock_release(&_mutex_small); return; } if (!eina_share_common_del(stringshare_share, str)) CRITICAL("EEEK trying to del non-shared stringshare \"%s\"", str); }
false
false
false
false
true
1
enable() { data->old_pbuffer = glXGetCurrentDrawable(); data->old_context = glXGetCurrentContext(); if(!glXMakeCurrent(data->display,data->pbuffer,data->context)) { error("PBuffer::enable(): glXMakeCurrent() failed"); } }
false
false
false
false
false
0
_parse_cookie (CGI *cgi) { NEOERR *err; char *cookie; char *k, *v, *l; HDF *obj; err = hdf_get_copy (cgi->hdf, "HTTP.Cookie", &cookie, NULL); if (err != STATUS_OK) return nerr_pass(err); if (cookie == NULL) return STATUS_OK; err = hdf_set_value (cgi->hdf, "Cookie", cookie); if (err != STATUS_OK) { free(cookie); return nerr_pass(err); } obj = hdf_get_obj (cgi->hdf, "Cookie"); k = l = cookie; while (*l && *l != '=' && *l != ';') l++; while (*k) { if (*l == '=') { if (*l) *l++ = '\0'; v = l; while (*l && *l != ';') l++; if (*l) *l++ = '\0'; } else { v = ""; if (*l) *l++ = '\0'; } k = neos_strip (k); v = neos_strip (v); if (k[0] && v[0]) { err = hdf_set_value (obj, k, v); if (nerr_match(err, NERR_ASSERT)) { STRING str; string_init(&str); nerr_error_string(err, &str); ne_warn("Unable to set Cookie value: %s = %s: %s", k, v, str.buf); string_clear(&str); nerr_ignore(&err); } if (err) break; } k = l; while (*l && *l != '=' && *l != ';') l++; } free (cookie); return nerr_pass(err); }
false
false
false
false
false
0
closeio(Posn p) { close(io); io = 0; if(p >= 0) dprint("#%lud\n", p); }
false
false
false
false
false
0
PyLong_FromLong(long ival) { PyLongObject *v; unsigned long abs_ival; unsigned long t; /* unsigned so >> doesn't propagate sign bit */ int ndigits = 0; int negative = 0; if (ival < 0) { /* if LONG_MIN == -LONG_MAX-1 (true on most platforms) then ANSI C says that the result of -ival is undefined when ival == LONG_MIN. Hence the following workaround. */ abs_ival = (unsigned long)(-1-ival) + 1; negative = 1; } else { abs_ival = (unsigned long)ival; } /* Count the number of Python digits. We used to pick 5 ("big enough for anything"), but that's a waste of time and space given that 5*15 = 75 bits are rarely needed. */ t = abs_ival; while (t) { ++ndigits; t >>= PyLong_SHIFT; } v = _PyLong_New(ndigits); if (v != NULL) { digit *p = v->ob_digit; v->ob_size = negative ? -ndigits : ndigits; t = abs_ival; while (t) { *p++ = (digit)(t & PyLong_MASK); t >>= PyLong_SHIFT; } } return (PyObject *)v; }
false
false
false
false
true
1
persistent_ram_init_ecc(struct persistent_ram_zone *prz, struct persistent_ram_ecc_info *ecc_info) { int numerr; struct persistent_ram_buffer *buffer = prz->buffer; int ecc_blocks; size_t ecc_total; if (!ecc_info || !ecc_info->ecc_size) return 0; prz->ecc_info.block_size = ecc_info->block_size ?: 128; prz->ecc_info.ecc_size = ecc_info->ecc_size ?: 16; prz->ecc_info.symsize = ecc_info->symsize ?: 8; prz->ecc_info.poly = ecc_info->poly ?: 0x11d; ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_info.ecc_size, prz->ecc_info.block_size + prz->ecc_info.ecc_size); ecc_total = (ecc_blocks + 1) * prz->ecc_info.ecc_size; if (ecc_total >= prz->buffer_size) { pr_err("%s: invalid ecc_size %u (total %zu, buffer size %zu)\n", __func__, prz->ecc_info.ecc_size, ecc_total, prz->buffer_size); return -EINVAL; } prz->buffer_size -= ecc_total; prz->par_buffer = buffer->data + prz->buffer_size; prz->par_header = prz->par_buffer + ecc_blocks * prz->ecc_info.ecc_size; /* * first consecutive root is 0 * primitive element to generate roots = 1 */ prz->rs_decoder = init_rs(prz->ecc_info.symsize, prz->ecc_info.poly, 0, 1, prz->ecc_info.ecc_size); if (prz->rs_decoder == NULL) { pr_info("init_rs failed\n"); return -EINVAL; } prz->corrected_bytes = 0; prz->bad_blocks = 0; numerr = persistent_ram_decode_rs8(prz, buffer, sizeof(*buffer), prz->par_header); if (numerr > 0) { pr_info("error in header, %d\n", numerr); prz->corrected_bytes += numerr; } else if (numerr < 0) { pr_info("uncorrectable error in header\n"); prz->bad_blocks++; } return 0; }
false
false
false
false
false
0
_doSetFixedOutputState(ArchiveHandle *AH) { /* Select the correct character set encoding */ ahprintf(AH, "SET client_encoding = '%s';\n", pg_encoding_to_char(AH->public.encoding)); /* Select the correct string literal syntax */ ahprintf(AH, "SET standard_conforming_strings = %s;\n", AH->public.std_strings ? "on" : "off"); /* Make sure function checking is disabled */ ahprintf(AH, "SET check_function_bodies = false;\n"); /* Avoid annoying notices etc */ ahprintf(AH, "SET client_min_messages = warning;\n"); if (!AH->public.std_strings) ahprintf(AH, "SET escape_string_warning = off;\n"); ahprintf(AH, "\n"); }
false
false
false
false
false
0
load_data(struct dict_radix **dictp) { clock_t t1, t2; if(hspell_debug){ fprintf(stderr,"Loading data files... "); t1=clock(); } *dictp = new_dict_radix(); if(!read_dict(*dictp, hspell_dictionary)){ delete_dict_radix(*dictp); return -1; } if(hspell_debug){ t2=clock(); fprintf(stderr,"done (%d ms).\n", (int)((t2-t1)/(CLOCKS_PER_SEC/1000))); } return 0; }
false
false
false
false
false
0
set_rows_count(gulong rows_count_min, gulong rows_count_max) { m_rows_count_min = rows_count_min; m_rows_count_max = rows_count_max; //Keep the values sane: if(m_rows_count_max < m_rows_count_min) m_rows_count_max = m_rows_count_min; }
false
false
false
false
false
0
mxf_metadata_generic_sound_essence_descriptor_handle_tag (MXFMetadataBase * metadata, MXFPrimerPack * primer, guint16 tag, const guint8 * tag_data, guint tag_size) { MXFMetadataGenericSoundEssenceDescriptor *self = MXF_METADATA_GENERIC_SOUND_ESSENCE_DESCRIPTOR (metadata); gboolean ret = TRUE; #ifndef GST_DISABLE_GST_DEBUG gchar str[48]; #endif switch (tag) { case 0x3d03: if (!mxf_fraction_parse (&self->audio_sampling_rate, tag_data, tag_size)) goto error; GST_DEBUG (" audio sampling rate = %d/%d", self->audio_sampling_rate.n, self->audio_sampling_rate.d); break; case 0x3d02: if (tag_size != 1) goto error; self->locked = (GST_READ_UINT8 (tag_data) != 0); GST_DEBUG (" locked = %s", (self->locked) ? "yes" : "no"); break; case 0x3d04: if (tag_size != 1) goto error; self->audio_ref_level = GST_READ_UINT8 (tag_data); GST_DEBUG (" audio ref level = %d", self->audio_ref_level); break; case 0x3d05: if (tag_size != 1) goto error; self->electro_spatial_formulation = GST_READ_UINT8 (tag_data); GST_DEBUG (" electro spatial formulation = %u", self->electro_spatial_formulation); break; case 0x3d07: if (tag_size != 4) goto error; self->channel_count = GST_READ_UINT32_BE (tag_data); GST_DEBUG (" channel count = %u", self->channel_count); break; case 0x3d01: if (tag_size != 4) goto error; self->quantization_bits = GST_READ_UINT32_BE (tag_data); GST_DEBUG (" quantization bits = %u", self->quantization_bits); break; case 0x3d0c: if (tag_size != 1) goto error; self->dial_norm = GST_READ_UINT8 (tag_data); GST_DEBUG (" dial norm = %d", self->dial_norm); break; case 0x3d06: if (tag_size != 16) goto error; memcpy (&self->sound_essence_compression, tag_data, 16); GST_DEBUG (" sound essence compression = %s", mxf_ul_to_string (&self->sound_essence_compression, str)); break; default: ret = MXF_METADATA_BASE_CLASS (mxf_metadata_generic_sound_essence_descriptor_parent_class)->handle_tag (metadata, primer, tag, tag_data, tag_size); break; } return ret; error: GST_ERROR ("Invalid generic sound essence descriptor local tag 0x%04x of size %u", tag, tag_size); return FALSE; }
false
false
false
false
false
0
QuoteString(const string &Str, const char *Bad) { string Res; for (string::const_iterator I = Str.begin(); I != Str.end(); ++I) { if (strchr(Bad,*I) != 0 || isprint(*I) == 0 || *I == 0x25 || // percent '%' char *I <= 0x20 || *I >= 0x7F) // control chars { char Buf[10]; sprintf(Buf,"%%%02x",(int)*I); Res += Buf; } else Res += *I; } return Res; }
false
false
false
false
false
0
ixgbe_get_vf_reta(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf) { u32 i, j; u32 *out_buf = &msgbuf[1]; const u8 *reta = adapter->rss_indir_tbl; u32 reta_size = ixgbe_rss_indir_tbl_entries(adapter); /* Check if operation is permitted */ if (!adapter->vfinfo[vf].rss_query_enabled) return -EPERM; /* verify the PF is supporting the correct API */ if (adapter->vfinfo[vf].vf_api != ixgbe_mbox_api_12) return -EOPNOTSUPP; /* This mailbox command is supported (required) only for 82599 and x540 * VFs which support up to 4 RSS queues. Therefore we will compress the * RETA by saving only 2 bits from each entry. This way we will be able * to transfer the whole RETA in a single mailbox operation. */ for (i = 0; i < reta_size / 16; i++) { out_buf[i] = 0; for (j = 0; j < 16; j++) out_buf[i] |= (u32)(reta[16 * i + j] & 0x3) << (2 * j); } return 0; }
false
false
false
false
false
0
stp_request_udma_await_tc_event(struct isci_request *ireq, u32 completion_code) { enum sci_status status = SCI_SUCCESS; switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): ireq->scu_status = SCU_TASK_DONE_GOOD; ireq->sci_status = SCI_SUCCESS; sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); break; case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_UNEXP_FIS): case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_REG_ERR): /* We must check ther response buffer to see if the D2H * Register FIS was received before we got the TC * completion. */ if (ireq->stp.rsp.fis_type == FIS_REGD2H) { sci_remote_device_suspend(ireq->target_device, SCI_SW_SUSPEND_NORMAL); ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); } else { /* If we have an error completion status for the * TC then we can expect a D2H register FIS from * the device so we must change state to wait * for it */ sci_change_state(&ireq->sm, SCI_REQ_STP_UDMA_WAIT_D2H); } break; /* TODO Check to see if any of these completion status need to * wait for the device to host register fis. */ /* TODO We can retry the command for SCU_TASK_DONE_CMD_LL_R_ERR * - this comes only for B0 */ default: /* All other completion status cause the IO to be complete. */ ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); break; } return status; }
false
false
false
false
false
0
state_init(SRE_STATE* state, PatternObject* pattern, PyObject* string, Py_ssize_t start, Py_ssize_t end) { /* prepare state object */ Py_ssize_t length; int logical_charsize, charsize; void* ptr; memset(state, 0, sizeof(SRE_STATE)); state->lastmark = -1; state->lastindex = -1; state->buffer.buf = NULL; ptr = getstring(string, &length, &logical_charsize, &charsize, &state->buffer); if (!ptr) goto err; if (logical_charsize == 1 && pattern->logical_charsize > 1) { PyErr_SetString(PyExc_TypeError, "can't use a string pattern on a bytes-like object"); goto err; } if (logical_charsize > 1 && pattern->logical_charsize == 1) { PyErr_SetString(PyExc_TypeError, "can't use a bytes pattern on a string-like object"); goto err; } /* adjust boundaries */ if (start < 0) start = 0; else if (start > length) start = length; if (end < 0) end = 0; else if (end > length) end = length; state->logical_charsize = logical_charsize; state->charsize = charsize; state->beginning = ptr; state->start = (void*) ((char*) ptr + start * state->charsize); state->end = (void*) ((char*) ptr + end * state->charsize); Py_INCREF(string); state->string = string; state->pos = start; state->endpos = end; if (pattern->flags & SRE_FLAG_LOCALE) state->lower = sre_lower_locale; else if (pattern->flags & SRE_FLAG_UNICODE) state->lower = sre_lower_unicode; else state->lower = sre_lower; return string; err: if (state->buffer.buf) PyBuffer_Release(&state->buffer); return NULL; }
false
false
false
false
false
0
cfg_layout_delete_block (basic_block bb) { rtx insn, next, prev = PREV_INSN (BB_HEAD (bb)), *to, remaints; if (bb->il.rtl->header) { next = BB_HEAD (bb); if (prev) NEXT_INSN (prev) = bb->il.rtl->header; else set_first_insn (bb->il.rtl->header); PREV_INSN (bb->il.rtl->header) = prev; insn = bb->il.rtl->header; while (NEXT_INSN (insn)) insn = NEXT_INSN (insn); NEXT_INSN (insn) = next; PREV_INSN (next) = insn; } next = NEXT_INSN (BB_END (bb)); if (bb->il.rtl->footer) { insn = bb->il.rtl->footer; while (insn) { if (BARRIER_P (insn)) { if (PREV_INSN (insn)) NEXT_INSN (PREV_INSN (insn)) = NEXT_INSN (insn); else bb->il.rtl->footer = NEXT_INSN (insn); if (NEXT_INSN (insn)) PREV_INSN (NEXT_INSN (insn)) = PREV_INSN (insn); } if (LABEL_P (insn)) break; insn = NEXT_INSN (insn); } if (bb->il.rtl->footer) { insn = BB_END (bb); NEXT_INSN (insn) = bb->il.rtl->footer; PREV_INSN (bb->il.rtl->footer) = insn; while (NEXT_INSN (insn)) insn = NEXT_INSN (insn); NEXT_INSN (insn) = next; if (next) PREV_INSN (next) = insn; else set_last_insn (insn); } } if (bb->next_bb != EXIT_BLOCK_PTR) to = &bb->next_bb->il.rtl->header; else to = &cfg_layout_function_footer; rtl_delete_block (bb); if (prev) prev = NEXT_INSN (prev); else prev = get_insns (); if (next) next = PREV_INSN (next); else next = get_last_insn (); if (next && NEXT_INSN (next) != prev) { remaints = unlink_insn_chain (prev, next); insn = remaints; while (NEXT_INSN (insn)) insn = NEXT_INSN (insn); NEXT_INSN (insn) = *to; if (*to) PREV_INSN (*to) = insn; *to = remaints; } }
false
false
false
false
false
0
FindTokensInFile(const wxString& filename, TokenIdxSet& result, short int kindMask) { result.clear(); size_t tokens_found = 0; TRACE(_T("Parser::FindTokensInFile() : Searching for file '%s' in tokens tree..."), filename.wx_str()); CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex) TokenIdxSet tmpresult; if ( m_TokenTree->FindTokensInFile(filename, tmpresult, kindMask) ) { for (TokenIdxSet::const_iterator it = tmpresult.begin(); it != tmpresult.end(); ++it) { const Token* token = m_TokenTree->at(*it); if (token) result.insert(*it); } tokens_found = result.size(); } CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex) return tokens_found; }
false
false
false
false
false
0
print_end_redirection (PRN *prn) { int err = 0; if (prn != NULL) { if (prn->fixed) { prn->fixed = 0; } else if (prn->fp != NULL) { if (prn->fp != stdout && prn->fp != stderr) { fclose(prn->fp); } prn->fp = prn->fpaux; prn->fpaux = NULL; } } else { err = 1; } return err; }
false
false
false
false
false
0
is_allowed_whitespace(unsigned c) { return c == ' ' || Allowed_Whitespace[c & 0xff]; }
false
false
false
false
false
0
clar_print_error(int num, const struct clar_error *error) { (void)num; printf(" ---\n"); printf(" message : %s\n", error->error_msg); printf(" severity: fail\n"); printf(" suite : %s\n", error->suite); printf(" test : %s\n", error->test); printf(" file : %s\n", error->file); printf(" line : %d\n", error->line_number); if (error->description != NULL) printf(" description: %s\n", error->description); printf(" ...\n"); }
false
false
false
false
false
0
rehash (Hash *t) { int i; int nold = nhash(t); Node *vold = nodevector(t); nhash(t) = luaI_redimension(nhash(t)); nodevector(t) = hashnodecreate(nhash(t)); for (i=0; i<nold; i++) { Node *n = vold+i; if (tag(ref(n)) != LUA_T_NIL && tag(val(n)) != LUA_T_NIL) *node(t, present(t, ref(n))) = *n; /* copy old node to new hahs */ } luaI_free(vold); }
false
false
false
false
false
0
get_function_name(xp, idx) expand_T *xp; int idx; { static int intidx = -1; char_u *name; if (idx == 0) intidx = -1; if (intidx < 0) { name = get_user_func_name(xp, idx); if (name != NULL) return name; } if (++intidx < (int)(sizeof(functions) / sizeof(struct fst))) { STRCPY(IObuff, functions[intidx].f_name); STRCAT(IObuff, "("); if (functions[intidx].f_max_argc == 0) STRCAT(IObuff, ")"); return IObuff; } return NULL; }
false
false
false
false
false
0
audioresample_buffer_new_subbuffer (AudioresampleBuffer * buffer, int offset, int length) { AudioresampleBuffer *subbuffer = audioresample_buffer_new (); if (buffer->parent) { audioresample_buffer_ref (buffer->parent); subbuffer->parent = buffer->parent; } else { audioresample_buffer_ref (buffer); subbuffer->parent = buffer; } subbuffer->data = buffer->data + offset; subbuffer->length = length; subbuffer->free = audioresample_buffer_free_subbuffer; return subbuffer; }
false
false
false
false
false
0
kc_ht_free_single_elements #ifdef KC_USE_PROTOTYPES (kc_hashtable_t kc_a_hashtable_t, int kc_i, int kc_m) #else (kc_a_hashtable_t, kc_i, kc_m) kc_hashtable_t kc_a_hashtable_t; int kc_i; int kc_m; #endif { int kc_j; if ((int)kc_m == (int)kc_ht_store_static) { for (kc_j=0; kc_j < kc_a_hashtable_t->hashtable[kc_i][kc_m].nr; kc_j++) { (*kc_a_hashtable_t->free_element)((kc_voidptr_t)kc_a_hashtable_t->hashtable[kc_i][kc_m].index[kc_j].yt_casestring, kc_a_hashtable_t->static_malloc_private_data); } } else { kc_voidptr_t kc_a_private_data = 0; if ((kc_a_hashtable_t->dynamic_malloc_private_data == 0) || (kc_a_hashtable_t->dynamic_malloc_private_data->malloc_private_data == 0)) { kc_a_private_data = 0; } else if (kc_a_hashtable_t->dynamic_malloc_private_data->next == 0) { kc_a_private_data = kc_a_hashtable_t->dynamic_malloc_private_data->malloc_private_data; } for (kc_j=0; kc_j < kc_a_hashtable_t->hashtable[kc_i][kc_m].nr; kc_j++) { (*kc_a_hashtable_t->free_element)((kc_voidptr_t)kc_a_hashtable_t->hashtable[kc_i][kc_m].index[kc_j].yt_casestring, kc_a_private_data); } } }
false
false
false
false
false
0
free_entry(UResourceDataEntry *entry) { UResourceDataEntry *alias; res_unload(&(entry->fData)); if(entry->fName != NULL && entry->fName != entry->fNameBuffer) { uprv_free(entry->fName); } if(entry->fPath != NULL) { uprv_free(entry->fPath); } if(entry->fPool != NULL) { --entry->fPool->fCountExisting; } alias = entry->fAlias; if(alias != NULL) { while(alias->fAlias != NULL) { alias = alias->fAlias; } --alias->fCountExisting; } uprv_free(entry); }
false
false
false
false
false
0
reportException(ExecState *exec, JSValue *exceptionVal) { if (!hasHandledException(exec, exceptionVal)) exception(exec, exec->currentBody() ? exec->currentBody()->sourceId() : lastSourceParsed, lastLineRan, exceptionVal); }
false
false
false
false
false
0
hdrl_set_masks_on_imagelist(cpl_imagelist * list, cpl_mask ** masks) { cpl_ensure_code(list, CPL_ERROR_NULL_INPUT); cpl_ensure_code(masks, CPL_ERROR_NULL_INPUT); for (size_t i = 0; i < (size_t)cpl_imagelist_get_size(list); i++) { cpl_image * img = cpl_imagelist_get(list, i); cpl_mask * img_mask = cpl_image_get_bpm(img); /* zero mask */ cpl_mask_xor(img_mask, img_mask); /* add new mask */ cpl_mask_or(img_mask, masks[i]); } return cpl_error_get_code(); }
false
false
false
false
false
0
real_get_obj_matrix (void *p, GretlObjType type, int idx, int *err) { gretl_matrix *M = NULL; if (idx <= 0) { *err = 1; return M; } if (type == GRETL_OBJ_EQN) { MODEL *pmod = (MODEL *) p; M = gretl_model_get_matrix(pmod, idx, err); } else if (type == GRETL_OBJ_SYS) { equation_system *sys = (equation_system *) p; M = equation_system_get_matrix(sys, idx, err); } else if (type == GRETL_OBJ_VAR) { GRETL_VAR *var = (GRETL_VAR *) p; M = gretl_VAR_get_matrix(var, idx, err); } return M; }
false
false
false
false
false
0
pull(int) { Packet *p = input(0).pull(); if (!p) return 0; ErrorHandler *errh = ErrorHandler::default_handler(); ContextErrorHandler cerrh(errh, "While executing %<%{element}%>:", this); // This is slow, but it probably doesn't need to be fast. int i = find_variable(String::make_stable("input", 5), true); _vars[i + 1] = String::make_stable("0", 1); _insn_pos = 0; step(0, STEP_JUMP, 0, &cerrh); String out; complete_step(&out); int port = -1; (void) IntArg().parse(out, port); if (port == 0) return p; else { checked_output_push(port, p); return 0; } }
false
false
false
false
false
0
device_cancel_authentication(struct btd_device *device, gboolean aborted) { struct authentication_req *auth = device->authr; char addr[18]; if (!auth) return; ba2str(&device->bdaddr, addr); DBG("Canceling authentication request for %s", addr); if (auth->agent) agent_cancel(auth->agent); if (!aborted) cancel_authentication(auth); device_auth_req_free(device); }
false
false
false
false
false
0
goodix_process_events(struct goodix_ts_data *ts) { u8 point_data[1 + GOODIX_CONTACT_SIZE * GOODIX_MAX_CONTACTS]; int touch_num; int i; touch_num = goodix_ts_read_input_report(ts, point_data); if (touch_num < 0) return; for (i = 0; i < touch_num; i++) goodix_ts_report_touch(ts, &point_data[1 + GOODIX_CONTACT_SIZE * i]); input_mt_sync_frame(ts->input_dev); input_sync(ts->input_dev); }
false
false
false
false
false
0
gx_device_copy_color_procs(gx_device *dev, const gx_device *target) { dev_proc_map_cmyk_color((*from_cmyk)) = dev_proc(dev, map_cmyk_color); dev_proc_map_rgb_color((*from_rgb)) = dev_proc(dev, map_rgb_color); dev_proc_map_color_rgb((*to_rgb)) = dev_proc(dev, map_color_rgb); /* The logic in this function seems a bit stale; it sets the old-style color procs, but not the new ones (get_color_mapping_procs, get_color_comp_index, encode_color, and decode_color). It should probably copy those as well. */ if (from_cmyk == gx_forward_map_cmyk_color || from_cmyk == cmyk_1bit_map_cmyk_color || from_cmyk == cmyk_8bit_map_cmyk_color) { from_cmyk = dev_proc(target, map_cmyk_color); set_dev_proc(dev, map_cmyk_color, (from_cmyk == cmyk_1bit_map_cmyk_color || from_cmyk == cmyk_8bit_map_cmyk_color ? from_cmyk : gx_forward_map_cmyk_color)); } if (from_rgb == gx_forward_map_rgb_color || from_rgb == gx_default_rgb_map_rgb_color) { from_rgb = dev_proc(target, map_rgb_color); set_dev_proc(dev, map_rgb_color, (from_rgb == gx_default_rgb_map_rgb_color ? from_rgb : gx_forward_map_rgb_color)); } if (to_rgb == gx_forward_map_color_rgb || to_rgb == cmyk_1bit_map_color_rgb || to_rgb == cmyk_8bit_map_color_rgb) { to_rgb = dev_proc(target, map_color_rgb); set_dev_proc(dev, map_color_rgb, (to_rgb == cmyk_1bit_map_color_rgb || to_rgb == cmyk_8bit_map_color_rgb ? to_rgb : gx_forward_map_color_rgb)); } }
false
false
false
false
false
0
process_frame(int curX, int curY) { //---- restore the screen area overwritten by the last frame ---// if( frame_shown ) { vga_front.fast_put_bitmap( frame_x1, frame_y1, frame_top_save_scr ); vga_front.fast_put_bitmap( frame_x1, frame_y2, frame_bottom_save_scr ); vga_front.fast_put_bitmap( frame_x1, frame_y1, frame_left_save_scr ); vga_front.fast_put_bitmap( frame_x2, frame_y1, frame_right_save_scr ); } //---------- update frame position ----------// if( !frame_shown ) // a new frame { frame_origin_x = curX; frame_origin_y = curY; frame_x1 = curX; frame_y1 = curY; frame_x2 = curX; frame_y2 = curY; } else // update the postion of the existing frame { //---------- update frame position ----------// if( curX > frame_origin_x ) { if( curY > frame_origin_y ) // stretching towards the lower right end { frame_x1 = frame_origin_x; frame_y1 = frame_origin_y; frame_x2 = curX; frame_y2 = curY; } else // stretching towards the upper right end { frame_x1 = frame_origin_x; frame_y1 = curY; frame_x2 = curX; frame_y2 = frame_origin_y; } } else { if( curY > frame_origin_y ) // stretching towards the lower left end { frame_x1 = curX; frame_y1 = frame_origin_y; frame_x2 = frame_origin_x; frame_y2 = curY; } else // stretching towards the upper left end { frame_x1 = curX; frame_y1 = curY; frame_x2 = frame_origin_x; frame_y2 = frame_origin_y; } } } //------- save the screen area and display the frame ------// disp_frame(&vga_front); }
false
false
false
false
false
0
USBD_SetConfig(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req) { static uint8_t cfgidx; cfgidx = (uint8_t)(req->wValue); if (cfgidx > USBD_CFG_MAX_NUM ) { USBD_CtlError(pdev , req); } else { switch (pdev->dev.device_status) { case USB_OTG_ADDRESSED: if (cfgidx) { pdev->dev.device_config = cfgidx; pdev->dev.device_status = USB_OTG_CONFIGURED; USBD_SetCfg(pdev , cfgidx); USBD_CtlSendStatus(pdev); } else { USBD_CtlSendStatus(pdev); } break; case USB_OTG_CONFIGURED: if (cfgidx == 0) { pdev->dev.device_status = USB_OTG_ADDRESSED; pdev->dev.device_config = cfgidx; USBD_ClrCfg(pdev , cfgidx); USBD_CtlSendStatus(pdev); } else if (cfgidx != pdev->dev.device_config) { /* Clear old configuration */ USBD_ClrCfg(pdev , pdev->dev.device_config); /* set new configuration */ pdev->dev.device_config = cfgidx; USBD_SetCfg(pdev , cfgidx); USBD_CtlSendStatus(pdev); } else { USBD_CtlSendStatus(pdev); } break; default: USBD_CtlError(pdev , req); break; } } }
false
false
false
false
false
0
shape_func_bottom (gdouble x) { gdouble y1 = 0.2/4.; gdouble y2 = 1e-6/4.; if (x <= -0.25) return y1; if (x < 0.25) return y2 + 0.5*(y1 - y2)*(1. + cos (2.*M_PI*(x + 0.25))); return y2; }
false
false
false
false
false
0