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 |
|---|---|---|---|---|---|---|
execute(int& image, int& drawableId, Location& file) {
if (! _enabled) {
return true;
}
GimpCall call(_gimpFnName);
call.param(GIMP_RUN_NONINTERACTIVE);
call.imageParam(image);
call.drawableParam(drawableId);
addParams(call);
bool result;
call.execute(result);
return result;
} | false | false | false | false | false | 0 |
trie_add(trie_t *s, const char *u, size_t len)
{
size_t i;
int index;
trie_node_t *t;
s->entries++;
/* Loop over the length of the string to add and traverse the trie... */
for (t = s->root, i = 0; i < len; i++)
{
/* The character in u we are processing... */
index = (unsigned char) u[i];
/* Is there a child node for this character? */
if (t->child_list[index] == NULL)
{
t->child_list[index] = trie_node_create();
if (index < t->first)
t->first = index;
if (index > t->last)
t->last = index;
}
/* Move to the new node... and loop */
t = t->child_list[index];
}
t->entry = s->entries;
} | false | false | false | false | false | 0 |
should_remove_suid(struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
umode_t mode = inode->i_mode;
int kill = 0;
/* suid always must be killed */
if (unlikely(mode & S_ISUID))
kill = ATTR_KILL_SUID;
/*
* sgid without any exec bits is just a mandatory locking mark; leave
* it alone. If some exec bits are set, it's a real sgid; kill it.
*/
if (unlikely((mode & S_ISGID) && (mode & S_IXGRP)))
kill |= ATTR_KILL_SGID;
if (unlikely(kill && !capable_wrt_inode_uidgid(inode, CAP_FSETID) &&
S_ISREG(mode)))
return kill;
return 0;
} | false | false | false | false | false | 0 |
setCurrentHole(int hole)
{
if (!holeAction || holeAction->items().count() < hole)
return;
// Golf is 1-based, KListAction is 0-based
holeAction->setCurrentItem(hole - 1);
} | false | false | false | false | false | 0 |
tsys01_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct tsys01_dev *dev_data;
struct iio_dev *indio_dev;
if (!i2c_check_functionality(client->adapter,
I2C_FUNC_SMBUS_WORD_DATA |
I2C_FUNC_SMBUS_WRITE_BYTE |
I2C_FUNC_SMBUS_READ_I2C_BLOCK)) {
dev_err(&client->dev,
"Adapter does not support some i2c transaction\n");
return -ENODEV;
}
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*dev_data));
if (!indio_dev)
return -ENOMEM;
dev_data = iio_priv(indio_dev);
dev_data->client = client;
dev_data->reset = ms_sensors_reset;
dev_data->read_prom_word = ms_sensors_read_prom_word;
dev_data->convert_and_read = ms_sensors_convert_and_read;
i2c_set_clientdata(client, indio_dev);
return tsys01_probe(indio_dev, &client->dev);
} | false | false | false | false | false | 0 |
read_url_async (const gchar *url,
GCancellable *cancellable,
AsyncReadCbFunc callback,
gpointer user_data)
{
AsyncReadCb *arc;
GrlNetWc *wc;
wc = get_wc ();
if (!wc)
return;
arc = g_slice_new0 (AsyncReadCb);
arc->url = g_strdup (url);
arc->callback = callback;
arc->user_data = user_data;
GRL_DEBUG ("Opening async '%s'", url);
grl_net_wc_request_async (wc,
url,
cancellable,
read_done_cb,
arc);
} | false | false | false | false | false | 0 |
FinishLoadingWorkspace(cbProject *activeProject, const wxString &workspaceTitle)
{
RebuildTree();
if (activeProject)
m_pTree->Expand(activeProject->GetProjectNode());
m_pTree->Expand(m_TreeRoot); // make sure the root node is open
m_pTree->SetItemText(m_TreeRoot, workspaceTitle);
UnfreezeTree(true);
} | false | false | false | false | false | 0 |
sprint_realloc_opaque(u_char ** buf, size_t * buf_len,
size_t * out_len, int allow_realloc,
const netsnmp_variable_list * var,
const struct enum_list *enums,
const char *hint, const char *units)
{
if ((var->type != ASN_OPAQUE
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
&& var->type != ASN_OPAQUE_COUNTER64
&& var->type != ASN_OPAQUE_U64
&& var->type != ASN_OPAQUE_I64
&& var->type != ASN_OPAQUE_FLOAT && var->type != ASN_OPAQUE_DOUBLE
#endif /* NETSNMP_WITH_OPAQUE_SPECIAL_TYPES */
) && (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICKE_PRINT))) {
if (snmp_cstrcat(buf, buf_len, out_len, allow_realloc,
"Wrong Type (should be Opaque): ")) {
return sprint_realloc_by_type(buf, buf_len, out_len,
allow_realloc, var, NULL, NULL,
NULL);
} else {
return 0;
}
}
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
switch (var->type) {
case ASN_OPAQUE_COUNTER64:
case ASN_OPAQUE_U64:
case ASN_OPAQUE_I64:
return sprint_realloc_counter64(buf, buf_len, out_len,
allow_realloc, var, enums, hint,
units);
break;
case ASN_OPAQUE_FLOAT:
return sprint_realloc_float(buf, buf_len, out_len, allow_realloc,
var, enums, hint, units);
break;
case ASN_OPAQUE_DOUBLE:
return sprint_realloc_double(buf, buf_len, out_len, allow_realloc,
var, enums, hint, units);
break;
case ASN_OPAQUE:
#endif
if (!netsnmp_ds_get_boolean(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_QUICK_PRINT)) {
u_char str[] = "OPAQUE: ";
if (!snmp_strcat(buf, buf_len, out_len, allow_realloc, str)) {
return 0;
}
}
if (!sprint_realloc_hexstring(buf, buf_len, out_len, allow_realloc,
var->val.string, var->val_len)) {
return 0;
}
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
}
#endif
if (units) {
return (snmp_strcat
(buf, buf_len, out_len, allow_realloc,
(const u_char *) " ")
&& snmp_strcat(buf, buf_len, out_len, allow_realloc,
(const u_char *) units));
}
return 1;
} | false | false | false | false | false | 0 |
jp2_jp_putdata(jp2_box_t *box, jas_stream_t *out)
{
jp2_jp_t *jp = &box->data.jp;
if (jp2_putuint32(out, jp->magic)) {
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
Open(const char *pszFname, const char *pszAccess,
GBool bTestOpenNoError /*= FALSE*/ )
{
char nStatus = 0;
if (m_poIndexTable)
{
CPLError(CE_Failure, CPLE_AssertionFailed,
"Open() failed: object already contains an open file");
return -1;
}
/*-----------------------------------------------------------------
* Validate access mode and call the right open method
*----------------------------------------------------------------*/
if (EQUALN(pszAccess, "r", 1))
{
m_eAccessMode = TABRead;
nStatus = (char)OpenForRead(pszFname, bTestOpenNoError);
}
else
{
CPLError(CE_Failure, CPLE_NotSupported,
"Open() failed: access mode \"%s\" not supported", pszAccess);
return -1;
}
return nStatus;
} | false | false | false | false | false | 0 |
gst_queue2_read_data_at_offset (GstQueue2 * queue, guint64 offset, guint length,
guint8 * dst, gint64 * read_return)
{
guint8 *ring_buffer;
size_t res;
ring_buffer = queue->ring_buffer;
if (QUEUE_IS_USING_TEMP_FILE (queue) && FSEEK_FILE (queue->temp_file, offset))
goto seek_failed;
/* this should not block */
GST_LOG_OBJECT (queue, "Reading %d bytes from offset %" G_GUINT64_FORMAT,
length, offset);
if (QUEUE_IS_USING_TEMP_FILE (queue)) {
res = fread (dst, 1, length, queue->temp_file);
} else {
memcpy (dst, ring_buffer + offset, length);
res = length;
}
GST_LOG_OBJECT (queue, "read %" G_GSIZE_FORMAT " bytes", res);
if (G_UNLIKELY (res < length)) {
if (!QUEUE_IS_USING_TEMP_FILE (queue))
goto could_not_read;
/* check for errors or EOF */
if (ferror (queue->temp_file))
goto could_not_read;
if (feof (queue->temp_file) && length > 0)
goto eos;
}
*read_return = res;
return GST_FLOW_OK;
seek_failed:
{
GST_ELEMENT_ERROR (queue, RESOURCE, SEEK, (NULL), GST_ERROR_SYSTEM);
return GST_FLOW_ERROR;
}
could_not_read:
{
GST_ELEMENT_ERROR (queue, RESOURCE, READ, (NULL), GST_ERROR_SYSTEM);
return GST_FLOW_ERROR;
}
eos:
{
GST_DEBUG ("non-regular file hits EOS");
return GST_FLOW_EOS;
}
} | false | true | false | false | false | 1 |
proxy_connect_helper(const host_addr_t *addr, size_t n, void *udata)
{
bool *in_progress = udata;
g_assert(addr);
g_assert(in_progress);
*in_progress = FALSE;
if (n > 0) {
/* Just pick the first address */
gnet_prop_set_ip_val(PROP_PROXY_ADDR, addr[0]);
g_message("resolved proxy name \"%s\" to %s",
GNET_PROPERTY(proxy_hostname), host_addr_to_string(addr[0]));
} else {
g_message("could not resolve proxy name \"%s\"",
GNET_PROPERTY(proxy_hostname));
}
} | false | false | false | false | false | 0 |
url_open_dyn_buf_internal(ByteIOContext **s, int max_packet_size)
{
DynBuffer *d;
int ret;
unsigned io_buffer_size = max_packet_size ? max_packet_size : 1024;
if(sizeof(DynBuffer) + io_buffer_size < io_buffer_size)
return -1;
d = av_mallocz(sizeof(DynBuffer) + io_buffer_size);
if (!d)
return AVERROR(ENOMEM);
*s = av_mallocz(sizeof(ByteIOContext));
if(!*s) {
av_free(d);
return AVERROR(ENOMEM);
}
d->io_buffer_size = io_buffer_size;
ret = init_put_byte(*s, d->io_buffer, io_buffer_size,
1, d, NULL,
max_packet_size ? dyn_packet_buf_write : dyn_buf_write,
max_packet_size ? NULL : dyn_buf_seek);
if (ret == 0) {
(*s)->max_packet_size = max_packet_size;
} else {
av_free(d);
av_freep(s);
}
return ret;
} | false | false | false | false | false | 0 |
encryptQueue(void* parameters)
{
pdebug("encryptQueue()\n");
bool first_chunk = true;
cryptParams* params = parameters;
chunk* encrypt_chunk = NULL;
uint64_t* chain = NULL;
chain = calloc(params->tf_key->stateSize/8, sizeof(uint64_t));
if(chain == NULL) //check that calloc succeeded
{
*(params->error) = MEMORY_ALLOCATION_FAIL;
return NULL;
}
while(*(params->running) && *(params->error) == 0)
{
if(encrypt_chunk == NULL)
{
pthread_mutex_lock(params->in_mutex);
if(front(params->in) != NULL)
{
encrypt_chunk = front(params->in);
if(encrypt_chunk != NULL) { deque(params->in); }
}
pthread_mutex_unlock(params->in_mutex);
}
if(encrypt_chunk != NULL && encrypt_chunk->action == DONE)
{
pdebug("$$$ encryptQueue() terminating loop $$$\n");
destroyChunk(encrypt_chunk);
break;
}
if(first_chunk && encrypt_chunk != NULL) //assume the first chunk is the header
{
pdebug("$$$ Encrypting header of size %lu $$$\n", encrypt_chunk->data_size);
if(!encryptHeader(params->tf_key, encrypt_chunk->data))
{ //if we failed to encrypt the header
pdebug("$$$ Failed to encrypt header $$$\n");
destroyChunk(encrypt_chunk);
*(params->error) = CIPHER_OPERATION_FAIL; //set the error flag
break; //break out
}
//save the chain of cipher text in the next chunk
getChainInBuffer(encrypt_chunk->data, chain, 2, params->tf_key->stateSize);
first_chunk = false;
}
else if(!first_chunk && encrypt_chunk != NULL)
{
uint64_t num_blocks = getNumBlocks(encrypt_chunk->data_size,
(uint32_t)params->tf_key->stateSize);
encryptInPlace(params->tf_key, chain, encrypt_chunk->data, num_blocks);
getChainInBuffer(encrypt_chunk->data, chain, num_blocks, params->tf_key->stateSize);
}
if(encrypt_chunk != NULL && !queueIsFull(params->out)) //attempt to queue the last encrypted chunk
{
encrypt_chunk->action = GEN_MAC; //change the next queued action
//on success clear the chunk ptr so the next operation can happen
pthread_mutex_lock(params->out_mutex);
if(enque(encrypt_chunk, params->out))
{
pdebug("$$$ Queing encrypted chunk of size %lu $$$\n", encrypt_chunk->data_size);
encrypt_chunk = NULL;
}
pthread_mutex_unlock(params->out_mutex);
} //end queue operation
} //end while loop
//queue Done flag
while(queueIsFull(params->out));
pthread_mutex_lock(params->out_mutex);
if(!queueDone(params->out))
{
pdebug("Error queueing done\n");
*(params->error) = QUEUE_OPERATION_FAIL;
if(chain != NULL) { free(chain); }
return NULL;
}
pthread_mutex_unlock(params->out_mutex);
pdebug("$$$ Done queued $$$ \n");
if(chain != NULL) { free(chain); }
return NULL;
} | false | false | false | false | false | 0 |
isInFront(WorldObject const* target, float distance, float arc) const
{
return IsWithinDist(target, distance) && HasInArc(arc, target);
} | false | false | false | false | false | 0 |
G3d_writeTileDouble(G3D_Map * map, int tileIndex, const void *tile)
{
int status;
if ((status = G3d_writeTile(map, tileIndex, tile, DCELL_TYPE)))
return status;
G3d_error("G3d_writeTileDouble: error in G3d_writeTile");
return 0;
} | false | false | false | false | false | 0 |
TryToIdentify()
{
TokenType t;
TokenValue v;
if (reserved_words.Identify(buffer_low, t, v))
{
MakeToken(t, v);
return true;
}
return false;
} | false | false | false | false | false | 0 |
oldmda_read_params(MDAXMLParams *par, OldMDAFile *mdafile)
{
MDAAxis axis;
mdafile->zres = par->res;
mdafile->xdata = par->xdata;
axis = g_array_index(par->axes, MDAAxis, 0);
if (axis.unitname)
mdafile->siunitz = gwy_si_unit_new(axis.unitname);
else
mdafile->siunitz = gwy_si_unit_new("");
axis = g_array_index(par->axes, MDAAxis, 1);
if (axis.unitname)
mdafile->siunitx = gwy_si_unit_new_parse(axis.unitname,
&mdafile->power10x);
else
mdafile->siunitx = gwy_si_unit_new("");
mdafile->xres = axis.maxindex - axis.minindex + 1;
if (mdafile->xres < 1)
mdafile->xres = 1;
if (axis.scale <= 0.0)
axis.scale = 1.0;
mdafile->xreal = axis.scale * mdafile->xres
* pow(10.0, mdafile->power10x);
axis = g_array_index(par->axes, MDAAxis, 2);
if (axis.unitname)
mdafile->siunity = gwy_si_unit_new_parse(axis.unitname,
&mdafile->power10y);
else
mdafile->siunity = gwy_si_unit_new("");
mdafile->yres = axis.maxindex - axis.minindex + 1;
if (mdafile->yres < 1)
mdafile->yres = 1;
if (axis.scale <= 0.0)
axis.scale = 1.0;
mdafile->yreal = axis.scale * mdafile->yres
* pow(10.0, mdafile->power10y);
} | false | false | false | false | false | 0 |
next_runtime_abi_02_string_decl (tree type, const char *name, string_section where)
{
tree var = start_var_decl (type, name);
switch (where)
{
case class_names:
OBJCMETA (var, objc_meta, meta_class_name);
break;
case meth_var_names:
OBJCMETA (var, objc_meta, meta_meth_name);
break;
case meth_var_types:
OBJCMETA (var, objc_meta, meta_meth_type);
break;
case prop_names_attr:
OBJCMETA (var, objc_meta, meta_prop_name_attr);
break;
default:
OBJCMETA (var, objc_meta, meta_base);
break;
}
return var;
} | false | false | false | false | false | 0 |
add_alt_server(const char *saddr, int default_port, turn_server_addrs_list_t *list)
{
if(saddr && list) {
ioa_addr addr;
turn_mutex_lock(&(list->m));
if(make_ioa_addr_from_full_string((const u08bits*)saddr, default_port, &addr)!=0) {
TURN_LOG_FUNC(TURN_LOG_LEVEL_ERROR, "Wrong IP address format: %s\n",saddr);
} else {
list->addrs = (ioa_addr*)turn_realloc(list->addrs,0,sizeof(ioa_addr)*(list->size+1));
addr_cpy(&(list->addrs[(list->size)++]),&addr);
{
u08bits s[1025];
addr_to_string(&addr, s);
TURN_LOG_FUNC(TURN_LOG_LEVEL_INFO, "Alternate server added: %s\n",s);
}
}
turn_mutex_unlock(&(list->m));
}
} | false | false | false | false | false | 0 |
__db_zero_extend(env, fhp, pgno, last_pgno, pgsize)
ENV *env;
DB_FH *fhp;
db_pgno_t pgno, last_pgno;
u_int32_t pgsize;
{
int ret;
size_t nwrote;
u_int8_t *buf;
if ((ret = __os_calloc(env, 1, pgsize, &buf)) != 0)
return (ret);
memset(buf, 0, pgsize);
for (; pgno <= last_pgno; pgno++)
if ((ret = __os_io(env, DB_IO_WRITE,
fhp, pgno, pgsize, 0, pgsize, buf, &nwrote)) != 0) {
if (ret == 0) {
ret = EIO;
goto err;
}
goto err;
}
err: __os_free(env, buf);
return (ret);
} | false | false | false | false | false | 0 |
brd_lookup_page(struct brd_device *brd, sector_t sector)
{
pgoff_t idx;
struct page *page;
/*
* The page lifetime is protected by the fact that we have opened the
* device node -- brd pages will never be deleted under us, so we
* don't need any further locking or refcounting.
*
* This is strictly true for the radix-tree nodes as well (ie. we
* don't actually need the rcu_read_lock()), however that is not a
* documented feature of the radix-tree API so it is better to be
* safe here (we don't have total exclusion from radix tree updates
* here, only deletes).
*/
rcu_read_lock();
idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */
page = radix_tree_lookup(&brd->brd_pages, idx);
rcu_read_unlock();
BUG_ON(page && page->index != idx);
return page;
} | false | false | false | false | false | 0 |
read_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GVfsAfpVolume *volume = G_VFS_AFP_VOLUME (source_object);
GVfsJobRead *job = G_VFS_JOB_READ (user_data);
AfpHandle *afp_handle = (AfpHandle *)job->handle;
GError *err = NULL;
gsize bytes_read;
if (!g_vfs_afp_volume_read_from_fork_finish (volume, res, &bytes_read, &err))
{
g_vfs_job_failed_from_error (G_VFS_JOB (job), err);
g_error_free (err);
return;
}
afp_handle->offset += bytes_read;
g_vfs_job_read_set_size (job, bytes_read);
g_vfs_job_succeeded (G_VFS_JOB (job));
} | false | false | false | false | false | 0 |
tc358743_g_edid(struct v4l2_subdev *sd,
struct v4l2_subdev_edid *edid)
{
struct tc358743_state *state = to_state(sd);
if (edid->pad != 0)
return -EINVAL;
if (edid->start_block == 0 && edid->blocks == 0) {
edid->blocks = state->edid_blocks_written;
return 0;
}
if (state->edid_blocks_written == 0)
return -ENODATA;
if (edid->start_block >= state->edid_blocks_written ||
edid->blocks == 0)
return -EINVAL;
if (edid->start_block + edid->blocks > state->edid_blocks_written)
edid->blocks = state->edid_blocks_written - edid->start_block;
i2c_rd(sd, EDID_RAM + (edid->start_block * EDID_BLOCK_SIZE), edid->edid,
edid->blocks * EDID_BLOCK_SIZE);
return 0;
} | false | false | false | false | false | 0 |
ExecARDeleteTriggers(EState *estate, ResultRelInfo *relinfo,
ItemPointer tupleid)
{
TriggerDesc *trigdesc = relinfo->ri_TrigDesc;
if (trigdesc && trigdesc->trig_delete_after_row)
{
HeapTuple trigtuple = GetTupleForTrigger(estate, NULL, relinfo,
tupleid, NULL);
AfterTriggerSaveEvent(estate, relinfo, TRIGGER_EVENT_DELETE,
true, trigtuple, NULL, NIL, NULL);
heap_freetuple(trigtuple);
}
} | false | false | false | false | false | 0 |
setAnchorItem(FXint r,FXint c){
anchor.row=FXCLAMP(-1,r,nrows-1);
anchor.col=FXCLAMP(-1,c,ncols-1);
} | false | false | false | false | false | 0 |
_getRequiredSize(struct SFNTContainer *ctr)
{
unsigned ret = 12; /* for offset table */
ret += _getTableDirectorySize(ctr);
for (unsigned i = 0; i < ctr->numTables; ++i)
{
struct SFNTTable *tbl = &ctr->tables[i];
ret += ((tbl->bufSize + 3) / 4) * 4; /* pads out to 4-byte boundary */
}
return ret;
} | false | false | false | false | false | 0 |
gimple_build_debug_bind_stat (tree var, tree value, gimple stmt MEM_STAT_DECL)
{
gimple p = gimple_build_with_ops_stat (GIMPLE_DEBUG,
(unsigned)GIMPLE_DEBUG_BIND, 2
PASS_MEM_STAT);
gimple_debug_bind_set_var (p, var);
gimple_debug_bind_set_value (p, value);
if (stmt)
gimple_set_location (p, gimple_location (stmt));
return p;
} | false | false | false | false | false | 0 |
picolcd_init_framebuffer(struct picolcd_data *data)
{
struct device *dev = &data->hdev->dev;
struct fb_info *info = NULL;
struct picolcd_fb_data *fbdata = NULL;
int i, error = -ENOMEM;
u32 *palette;
/* The extra memory is:
* - 256*u32 for pseudo_palette
* - struct fb_deferred_io
*/
info = framebuffer_alloc(256 * sizeof(u32) +
sizeof(struct fb_deferred_io) +
sizeof(struct picolcd_fb_data) +
PICOLCDFB_SIZE, dev);
if (info == NULL) {
dev_err(dev, "failed to allocate a framebuffer\n");
goto err_nomem;
}
info->fbdefio = info->par;
*info->fbdefio = picolcd_fb_defio;
info->par += sizeof(struct fb_deferred_io);
palette = info->par;
info->par += 256 * sizeof(u32);
for (i = 0; i < 256; i++)
palette[i] = i > 0 && i < 16 ? 0xff : 0;
info->pseudo_palette = palette;
info->fbops = &picolcdfb_ops;
info->var = picolcdfb_var;
info->fix = picolcdfb_fix;
info->fix.smem_len = PICOLCDFB_SIZE*8;
info->flags = FBINFO_FLAG_DEFAULT;
fbdata = info->par;
spin_lock_init(&fbdata->lock);
fbdata->picolcd = data;
fbdata->update_rate = PICOLCDFB_UPDATE_RATE_DEFAULT;
fbdata->bpp = picolcdfb_var.bits_per_pixel;
fbdata->force = 1;
fbdata->vbitmap = info->par + sizeof(struct picolcd_fb_data);
fbdata->bitmap = vmalloc(PICOLCDFB_SIZE*8);
if (fbdata->bitmap == NULL) {
dev_err(dev, "can't get a free page for framebuffer\n");
goto err_nomem;
}
info->screen_base = (char __force __iomem *)fbdata->bitmap;
info->fix.smem_start = (unsigned long)fbdata->bitmap;
memset(fbdata->vbitmap, 0xff, PICOLCDFB_SIZE);
data->fb_info = info;
error = picolcd_fb_reset(data, 1);
if (error) {
dev_err(dev, "failed to configure display\n");
goto err_cleanup;
}
error = device_create_file(dev, &dev_attr_fb_update_rate);
if (error) {
dev_err(dev, "failed to create sysfs attributes\n");
goto err_cleanup;
}
fb_deferred_io_init(info);
error = register_framebuffer(info);
if (error) {
dev_err(dev, "failed to register framebuffer\n");
goto err_sysfs;
}
return 0;
err_sysfs:
device_remove_file(dev, &dev_attr_fb_update_rate);
fb_deferred_io_cleanup(info);
err_cleanup:
data->fb_info = NULL;
err_nomem:
if (fbdata)
vfree(fbdata->bitmap);
framebuffer_release(info);
return error;
} | false | false | false | false | false | 0 |
_print_events(BLURAY *bd)
{
BD_EVENT ev;
do {
bd_read_ext(bd, NULL, 0, &ev);
_print_event(&ev);
} while (ev.event != BD_EVENT_NONE && ev.event != BD_EVENT_ERROR);
} | false | false | false | false | false | 0 |
SSL_pthreads_locking_callback(int mode, int type, char *file, int line)
{
if( my.debug == 4 ){
fprintf(
stderr,"thread=%4d mode=%s lock=%s %s:%d\n", (int)CRYPTO_thread_id(),
(mode&CRYPTO_LOCK)?"l":"u", (type&CRYPTO_READ)?"r":"w",file,line
);
}
if(mode & CRYPTO_LOCK){
pthread_mutex_lock(&(lock_cs[type]));
lock_count[type]++;
}
else{
pthread_mutex_unlock(&(lock_cs[type]));
}
} | false | false | false | false | false | 0 |
compress2_cmd(void){
Blob f1, f2;
if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE");
blob_read_from_file(&f1, g.argv[2]);
blob_read_from_file(&f2, g.argv[3]);
blob_compress2(&f1, &f2, &f1);
blob_write_to_file(&f1, g.argv[4]);
} | false | false | false | false | false | 0 |
dw210x_op_rw(struct usb_device *dev, u8 request, u16 value,
u16 index, u8 * data, u16 len, int flags)
{
int ret;
u8 *u8buf;
unsigned int pipe = (flags == DW210X_READ_MSG) ?
usb_rcvctrlpipe(dev, 0) : usb_sndctrlpipe(dev, 0);
u8 request_type = (flags == DW210X_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
u8buf = kmalloc(len, GFP_KERNEL);
if (!u8buf)
return -ENOMEM;
if (flags == DW210X_WRITE_MSG)
memcpy(u8buf, data, len);
ret = usb_control_msg(dev, pipe, request, request_type | USB_TYPE_VENDOR,
value, index , u8buf, len, 2000);
if (flags == DW210X_READ_MSG)
memcpy(data, u8buf, len);
kfree(u8buf);
return ret;
} | false | true | false | false | false | 1 |
lookupkeywords (char *name, char **keyword, char **value, int nkey)
#else
static char *lookupkeywords(name, keyword, value, nkey)
char *name;
char **keyword;
char **value;
int nkey;
#endif
{
int i;
for(i=0; i<nkey; i++){
if( !strcmp(name, keyword[i]) )
return(value[i]);
}
return(NULL);
} | false | false | false | false | false | 0 |
release_input_file (const void *handle)
{
ASSERT (called_plugin);
handle = handle;
return LDPS_ERR;
} | false | false | false | false | false | 0 |
fixmatch(const char *pattern, char *line, int ignore_case, regmatch_t *match)
{
char *hit;
if (ignore_case)
hit = strcasestr(line, pattern);
else
hit = strstr(line, pattern);
if (!hit) {
match->rm_so = match->rm_eo = -1;
return REG_NOMATCH;
}
else {
match->rm_so = hit - line;
match->rm_eo = match->rm_so + strlen(pattern);
return 0;
}
} | false | false | false | false | false | 0 |
writeNlist(MachSymbolData &MSD,
const MCAsmLayout &Layout) {
const MCSymbol *Symbol = MSD.Symbol;
const MCSymbol &Data = *Symbol;
const MCSymbol *AliasedSymbol = &findAliasedSymbol(*Symbol);
uint8_t SectionIndex = MSD.SectionIndex;
uint8_t Type = 0;
uint64_t Address = 0;
bool IsAlias = Symbol != AliasedSymbol;
const MCSymbol &OrigSymbol = *Symbol;
MachSymbolData *AliaseeInfo;
if (IsAlias) {
AliaseeInfo = findSymbolData(*AliasedSymbol);
if (AliaseeInfo)
SectionIndex = AliaseeInfo->SectionIndex;
Symbol = AliasedSymbol;
// FIXME: Should this update Data as well? Do we need OrigSymbol at all?
}
// Set the N_TYPE bits. See <mach-o/nlist.h>.
//
// FIXME: Are the prebound or indirect fields possible here?
if (IsAlias && Symbol->isUndefined())
Type = MachO::N_INDR;
else if (Symbol->isUndefined())
Type = MachO::N_UNDF;
else if (Symbol->isAbsolute())
Type = MachO::N_ABS;
else
Type = MachO::N_SECT;
// FIXME: Set STAB bits.
if (Data.isPrivateExtern())
Type |= MachO::N_PEXT;
// Set external bit.
if (Data.isExternal() || (!IsAlias && Symbol->isUndefined()))
Type |= MachO::N_EXT;
// Compute the symbol address.
if (IsAlias && Symbol->isUndefined())
Address = AliaseeInfo->StringIndex;
else if (Symbol->isDefined())
Address = getSymbolAddress(OrigSymbol, Layout);
else if (Symbol->isCommon()) {
// Common symbols are encoded with the size in the address
// field, and their alignment in the flags.
Address = Symbol->getCommonSize();
}
// struct nlist (12 bytes)
write32(MSD.StringIndex);
write8(Type);
write8(SectionIndex);
// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
// value.
write16(cast<MCSymbolMachO>(Symbol)->getEncodedFlags());
if (is64Bit())
write64(Address);
else
write32(Address);
} | false | false | false | false | false | 0 |
atoo( char * string )
/*!
Return Value: returns the unsigned long value
Parameters:
Type Name IO Description
------------ ----------- -- ----------- */
#ifdef DOC
char * string ;/* I String to be converted. */
#endif
/*!
Description:
`atoo` converts a character string of octal digits to an unsigned long
value. Conversion is limited to the number of octal digits supported
by an unsigned long, and is terminated if a non-octal digit is
encountered. No indication of either condition is given, because `atoo` is
designed for use in situations where the extent and content of the
octal string has already been verified.
!*/
{
int string_length;
unsigned long value = 0;
int index;
string_length = MIN( sizeof(unsigned long) * 8 / 3, strlen( string ));
for( index=0; index<string_length; index++ ) {
if( !isodigit( string[index] ))
return value;
value <<= 3;
value |= OCTVAL( string[index] );
}
return value;
} | false | false | false | false | false | 0 |
invalidate_loops_containing_label (label)
rtx label;
{
struct loop *loop;
for (loop = uid_loop[INSN_UID (label)]; loop; loop = loop->outer)
loop->invalid = 1;
} | false | false | false | false | false | 0 |
usb_debugfs_init(void)
{
usb_debug_root = debugfs_create_dir("usb", NULL);
if (!usb_debug_root)
return -ENOENT;
usb_debug_devices = debugfs_create_file("devices", 0444,
usb_debug_root, NULL,
&usbfs_devices_fops);
if (!usb_debug_devices) {
debugfs_remove(usb_debug_root);
usb_debug_root = NULL;
return -ENOENT;
}
return 0;
} | false | false | false | false | false | 0 |
get_object1(struct alisp_instance *instance, const char *id)
{
struct alisp_object_pair *p;
struct list_head *pos;
list_for_each(pos, &instance->setobjs_list[get_string_hash(id)]) {
p = list_entry(pos, struct alisp_object_pair, list);
if (!strcmp(p->name, id))
return p->value;
}
return &alsa_lisp_nil;
} | false | false | false | false | false | 0 |
SCSubBy(SplineChar *sc) {
int i,j,k,tot;
char **deps = NULL;
SplineChar **depsc;
char ubuf[200];
SplineFont *sf, *_sf;
PST *pst;
char *buts[3];
buts[0] = _("Show");
buts[1] = _("_Cancel");
buts[2] = NULL;
if ( sc==NULL )
return;
_sf = sc->parent;
if ( _sf->cidmaster!=NULL ) _sf=_sf->cidmaster;
for ( j=0; j<2; ++j ) {
tot = 0;
k=0;
do {
sf = _sf->subfontcnt==0 ? _sf : _sf->subfonts[k];
for ( i=0; i<sf->glyphcnt; ++i ) if ( sf->glyphs[i]!=NULL ) {
for ( pst=sf->glyphs[i]->possub; pst!=NULL; pst=pst->next ) {
if ( pst->type==pst_substitution || pst->type==pst_alternate ||
pst->type==pst_multiple || pst->type==pst_ligature )
if ( UsedIn(sc->name,pst->u.mult.components)) {
if ( deps!=NULL ) {
snprintf(ubuf,sizeof(ubuf),
_("Subtable %.60s in glyph %.60s"),
pst->subtable->subtable_name,
sf->glyphs[i]->name);
deps[tot] = copy(ubuf);
depsc[tot] = sf->glyphs[i];
}
++tot;
}
}
}
++k;
} while ( k<_sf->subfontcnt );
if ( tot==0 )
return;
if ( j==0 ) {
deps = gcalloc(tot+1,sizeof(char *));
depsc = galloc(tot*sizeof(SplineChar *));
}
}
i = gwwv_choose_with_buttons(_("Dependent Substitutions"),(const char **) deps, tot, 0, buts, _("Dependent Substitutions") );
if ( i>-1 ) {
CharViewCreate(depsc[i],(FontView *) (sc->parent->fv),-1);
}
for ( i=0; i<=tot; ++i )
free( deps[i] );
free(deps);
free(depsc);
} | false | false | false | false | false | 0 |
tcs_wrap_RegisterKey(struct tcsd_thread_data *data)
{
TCS_CONTEXT_HANDLE hContext;
TSS_UUID WrappingKeyUUID;
TSS_UUID KeyUUID;
UINT32 cKeySize;
BYTE *rgbKey;
UINT32 cVendorData;
BYTE *gbVendorData;
TSS_RESULT result;
if (getData(TCSD_PACKET_TYPE_UINT32, 0, &hContext, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
if ((result = ctx_verify_context(hContext)))
goto done;
LogDebugFn("thread %ld context %x", THREAD_ID, hContext);
if (getData(TCSD_PACKET_TYPE_UUID, 1, &WrappingKeyUUID, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
if (getData(TCSD_PACKET_TYPE_UUID, 2, &KeyUUID, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
if (getData(TCSD_PACKET_TYPE_UINT32, 3, &cKeySize, 0, &data->comm))
return TCSERR(TSS_E_INTERNAL_ERROR);
rgbKey = calloc(1, cKeySize);
if (rgbKey == NULL) {
LogError("malloc of %d bytes failed.", cKeySize);
return TCSERR(TSS_E_OUTOFMEMORY);
}
if (getData(TCSD_PACKET_TYPE_PBYTE, 4, rgbKey, cKeySize, &data->comm)) {
free(rgbKey);
return TCSERR(TSS_E_INTERNAL_ERROR);
}
if (getData(TCSD_PACKET_TYPE_UINT32, 5, &cVendorData, 0, &data->comm)) {
free(rgbKey);
return TCSERR(TSS_E_INTERNAL_ERROR);
}
if (cVendorData == 0)
gbVendorData = NULL;
else {
gbVendorData = calloc(1, cVendorData);
if (gbVendorData == NULL) {
LogError("malloc of %d bytes failed.", cVendorData);
free(rgbKey);
return TCSERR(TSS_E_OUTOFMEMORY);
}
if (getData(TCSD_PACKET_TYPE_PBYTE, 6, gbVendorData, cVendorData, &data->comm)) {
free(rgbKey);
free(gbVendorData);
return TCSERR(TSS_E_INTERNAL_ERROR);
}
}
result = TCS_RegisterKey_Internal(hContext, &WrappingKeyUUID, &KeyUUID,
cKeySize, rgbKey, cVendorData,
gbVendorData);
free(rgbKey);
free(gbVendorData);
done:
initData(&data->comm, 0);
data->comm.hdr.u.result = result;
return TSS_SUCCESS;
} | false | false | false | false | false | 0 |
PMI_Get_clique_size( int *size )
{
char *env;
if (pmi_debug)
fprintf(stderr, "In: PMI_Get_clique_size\n");
if (size == NULL)
return PMI_ERR_INVALID_ARG;
if (pmi_init == 0)
return PMI_FAIL;
/* Simple operation without srun */
if ((pmi_jobid == 0) && (pmi_stepid == 0)) {
*size = 1;
return PMI_SUCCESS;
}
env = getenv("SLURM_GTIDS");
if (env) {
int i, tids=1;
for (i=0; env[i]; i++) {
if (env[i] == ',')
tids++;
}
*size = tids;
return PMI_SUCCESS;
}
return PMI_FAIL;
} | false | false | false | false | true | 1 |
fill_classic_mro(PyObject *mro, PyObject *cls)
{
PyObject *bases, *base;
Py_ssize_t i, n;
assert(PyList_Check(mro));
assert(PyClass_Check(cls));
i = PySequence_Contains(mro, cls);
if (i < 0)
return -1;
if (!i) {
if (PyList_Append(mro, cls) < 0)
return -1;
}
bases = ((PyClassObject *)cls)->cl_bases;
assert(bases && PyTuple_Check(bases));
n = PyTuple_GET_SIZE(bases);
for (i = 0; i < n; i++) {
base = PyTuple_GET_ITEM(bases, i);
if (fill_classic_mro(mro, base) < 0)
return -1;
}
return 0;
} | false | false | false | false | true | 1 |
paintEvent(QPaintEvent *)
{
generateShade();
QPainter p(this);
p.drawImage(0, 0, m_shade);
p.setPen(QColor(146, 146, 146));
p.drawRect(0, 0, width() - 1, height() - 1);
} | false | false | false | false | false | 0 |
grokclassfn (tree ctype, tree function, enum overload_flags flags, tree quals)
{
tree fn_name = DECL_NAME (function);
int this_quals = TYPE_UNQUALIFIED;
/* Even within an `extern "C"' block, members get C++ linkage. See
[dcl.link] for details. */
SET_DECL_LANGUAGE (function, lang_cplusplus);
if (fn_name == NULL_TREE)
{
error ("name missing for member function");
fn_name = get_identifier ("<anonymous>");
DECL_NAME (function) = fn_name;
}
if (quals)
this_quals = grok_method_quals (ctype, function, quals);
if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
{
/* Must add the class instance variable up front. */
/* Right now we just make this a pointer. But later
we may wish to make it special. */
tree type = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (function)));
tree qual_type;
tree parm;
/* The `this' parameter is implicitly `const'; it cannot be
assigned to. */
this_quals |= TYPE_QUAL_CONST;
qual_type = cp_build_qualified_type (type, this_quals);
parm = build_artificial_parm (this_identifier, qual_type);
c_apply_type_quals_to_decl (this_quals, parm);
TREE_CHAIN (parm) = DECL_ARGUMENTS (function);
DECL_ARGUMENTS (function) = parm;
}
DECL_CONTEXT (function) = ctype;
if (flags == DTOR_FLAG)
DECL_DESTRUCTOR_P (function) = 1;
if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function))
maybe_retrofit_in_chrg (function);
} | false | false | false | false | false | 0 |
eprn_fetch_scan_line(eprn_Device *dev, eprn_OctetString *line)
{
int rc;
const eprn_Octet *str;
rc = gdev_prn_copy_scan_lines((gx_device_printer *)dev, dev->eprn.next_y,
line->str, dev->eprn.octets_per_line);
/* gdev_prn_copy_scan_lines() returns the number of scan lines it fetched
or a negative value on error. The number of lines to fetch is the value
of the last argument divided by the length of a single line, hence in
this case 1. */
if (rc != 1) return 1;
/* Set the length to ignore trailing zero octets in the scan line */
str = line->str + (dev->eprn.octets_per_line - 1);
while (str > line->str && *str == 0) str--;
if (*str == 0) line->length = 0;
else line->length = str - line->str + 1;
/* Ensure we have an integral number of pixels in the line */
if (dev->color_info.depth > 8) {
int rem;
unsigned int octets_per_pixel = dev->color_info.depth/8;
/* If the depth is larger than 8, it is a multiple of 8. */
rem = line->length % octets_per_pixel;
if (rem != 0) line->length += octets_per_pixel - rem;
}
#if 0 && defined(EPRN_TRACE)
if (gs_debug_c(EPRN_TRACE_CHAR)) {
int j;
dmlprintf(dev->memory, "! eprn_fetch_scan_line(): Fetched ");
if (line->length == 0) dmprintf(dev->memory, "empty scan line.");
else {
dmprintf(dev->memory, "scan line: 0x");
for (j = 0; j < line->length; j++) dmprintf1(dev->memory, "%02X", line->str[j]);
}
dmlprintf(dev->memory, "\n");
}
#endif
return 0;
} | false | false | false | false | false | 0 |
ComputeLinkInterface(const char* config)
{
// Construct the property name suffix for this configuration.
std::string suffix = "_";
if(config && *config)
{
suffix += cmSystemTools::UpperCase(config);
}
else
{
suffix += "NOCONFIG";
}
// Lookup the link interface libraries.
const char* libs = 0;
{
// Lookup the per-configuration property.
std::string propName = "LINK_INTERFACE_LIBRARIES";
propName += suffix;
libs = this->GetProperty(propName.c_str());
// If not set, try the generic property.
if(!libs)
{
libs = this->GetProperty("LINK_INTERFACE_LIBRARIES");
}
}
// If still not set, there is no link interface.
if(!libs)
{
return 0;
}
// Allocate the interface.
cmTargetLinkInterface* iface = new cmTargetLinkInterface;
if(!iface)
{
return 0;
}
// Expand the list of libraries in the interface.
cmSystemTools::ExpandListArgument(libs, iface->Libraries);
// Now we need to construct a list of shared library dependencies
// not included in the interface.
if(this->GetType() == cmTarget::SHARED_LIBRARY)
{
// Use a set to keep track of what libraries have been emitted to
// either list.
std::set<cmStdString> emitted;
for(std::vector<std::string>::const_iterator
li = iface->Libraries.begin();
li != iface->Libraries.end(); ++li)
{
emitted.insert(*li);
}
// Compute which library configuration to link.
cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
if(config && cmSystemTools::UpperCase(config) == "DEBUG")
{
linkType = cmTarget::DEBUG;
}
// Construct the list of libs linked for this configuration.
cmTarget::LinkLibraryVectorType const& llibs =
this->GetOriginalLinkLibraries();
for(cmTarget::LinkLibraryVectorType::const_iterator li = llibs.begin();
li != llibs.end(); ++li)
{
// Skip entries that will resolve to the target itself, are empty,
// or are not meant for this configuration.
if(li->first == this->GetName() || li->first.empty() ||
!(li->second == cmTarget::GENERAL || li->second == linkType))
{
continue;
}
// Skip entries that have already been emitted into either list.
if(!emitted.insert(li->first).second)
{
continue;
}
// Add this entry if it is a shared library.
if(cmTarget* tgt = this->Makefile->FindTargetToUse(li->first.c_str()))
{
if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
{
iface->SharedDeps.push_back(li->first);
}
}
else
{
// TODO: Recognize shared library file names. Perhaps this
// should be moved to cmComputeLinkInformation, but that creates
// a chicken-and-egg problem since this list is needed for its
// construction.
}
}
}
// Return the completed interface.
return iface;
} | false | false | false | false | false | 0 |
m_cdfg_emit_expr (pIIR_TypeConversion tc, string &str, RegionStack &rstack, id_type t)
{
if (valid_folded_value(tc)) {
// Print folded value if available
cdfg_emit_folded_value(folded_value(tc), str, rstack, tc->type_mark);
return true;
}
pIIR_Type target_base_type = get_base_type(tc->type_mark);
pIIR_Declaration target_type_decl = get_declaration(tc->type_mark);
string cast_start;
string result_str;
string expr_str;
cdfg_emit_expr(tc->expression, expr_str, rstack, t);
if (target_base_type->is(IR_INTEGER_TYPE))
result_str += expr_str;
else if (target_base_type->is(IR_ENUMERATION_TYPE))
result_str += expr_str;
else if (target_base_type->is(IR_PHYSICAL_TYPE))
result_str += expr_str;
else if (target_base_type->is(IR_FLOATING_TYPE))
result_str += expr_str;
else if (is_array_type(target_base_type)) {
pIIR_ArrayType target_array_base_type = pIIR_ArrayType(target_base_type);
result_str += "(list array-type-conversion \"" +
get_escaped_string(get_long_name(get_declaration(target_array_base_type))) + "\" " +
expr_str + ")";
} else
assert(false);
str += result_str;
return false;
} | false | false | false | false | false | 0 |
clean_rt(int force) {
int i;
for (i = 0; i < ann_len; i++) {
if (difftime(time(NULL), ann_ips[i].l_update) > 10 || force) {
/* network not more reachable */
DEFandNULL(struct rtentry, rtentry)
((struct sockaddr_in *)&rtentry.rt_dst)->sin_family = \
((struct sockaddr_in *)&rtentry.rt_gateway)->sin_family = \
((struct sockaddr_in *)&rtentry.rt_genmask)->sin_family = AF_INET;
((struct sockaddr_in *)&rtentry.rt_dst)->sin_addr.s_addr = ann_ips[i].addr.s_addr;
((struct sockaddr_in *)&rtentry.rt_genmask)->sin_addr.s_addr = ann_ips[i].netmask.s_addr;
((struct sockaddr_in *)&rtentry.rt_gateway)->sin_addr.s_addr = 0;
rtentry.rt_dev = local_ifname;
if(ioctl (sd, SIOCDELRT, &rtentry) == -1) {
perror("ioctl(SIOCDELRT)");
}
annips_del(i);
}
}
} | false | false | false | false | false | 0 |
print_element_list (gboolean print_all)
{
int plugincount = 0, featurecount = 0, blacklistcount = 0;
GList *plugins, *orig_plugins;
orig_plugins = plugins = gst_default_registry_get_plugin_list ();
while (plugins) {
GList *features, *orig_features;
GstPlugin *plugin;
plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins);
plugincount++;
if (plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) {
blacklistcount++;
continue;
}
orig_features = features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) {
GstPluginFeature *feature;
if (G_UNLIKELY (features->data == NULL))
goto next;
feature = GST_PLUGIN_FEATURE (features->data);
featurecount++;
if (GST_IS_ELEMENT_FACTORY (feature)) {
GstElementFactory *factory;
factory = GST_ELEMENT_FACTORY (feature);
if (print_all)
print_element_info (factory, TRUE);
else
g_print ("%s: %s: %s\n", plugin->desc.name,
GST_PLUGIN_FEATURE_NAME (factory),
gst_element_factory_get_longname (factory));
} else if (GST_IS_INDEX_FACTORY (feature)) {
GstIndexFactory *factory;
factory = GST_INDEX_FACTORY (feature);
if (!print_all)
g_print ("%s: %s: %s\n", plugin->desc.name,
GST_PLUGIN_FEATURE_NAME (factory), factory->longdesc);
} else if (GST_IS_TYPE_FIND_FACTORY (feature)) {
GstTypeFindFactory *factory;
factory = GST_TYPE_FIND_FACTORY (feature);
if (!print_all)
g_print ("%s: %s: ", plugin->desc.name,
gst_plugin_feature_get_name (feature));
if (factory->extensions) {
guint i = 0;
while (factory->extensions[i]) {
if (!print_all)
g_print ("%s%s", i > 0 ? ", " : "", factory->extensions[i]);
i++;
}
if (!print_all)
g_print ("\n");
} else {
if (!print_all)
g_print ("no extensions\n");
}
} else {
if (!print_all)
n_print ("%s: %s (%s)\n", plugin->desc.name,
GST_PLUGIN_FEATURE_NAME (feature),
g_type_name (G_OBJECT_TYPE (feature)));
}
next:
features = g_list_next (features);
}
gst_plugin_feature_list_free (orig_features);
}
gst_plugin_list_free (orig_plugins);
g_print ("\n");
g_print (_("Total count: "));
g_print (ngettext ("%d plugin", "%d plugins", plugincount), plugincount);
if (blacklistcount) {
g_print (" (");
g_print (ngettext ("%d blacklist entry", "%d blacklist entries",
blacklistcount), blacklistcount);
g_print (" not shown)");
}
g_print (", ");
g_print (ngettext ("%d feature", "%d features", featurecount), featurecount);
g_print ("\n");
} | false | false | false | true | false | 1 |
Perimeter(const Point* verts) const
{
if(!verts) return 0.0f;
const Point& p0 = verts[0];
const Point& p1 = verts[1];
const Point& p2 = verts[2];
return p0.Distance(p1)
+ p0.Distance(p2)
+ p1.Distance(p2);
} | false | false | false | false | false | 0 |
sg_load_map_owner(struct loaddata *loading)
{
int x, y;
struct player *owner = NULL;
struct tile *claimer = NULL;
/* Check status and return if not OK (sg_success != TRUE). */
sg_check_ret();
if (game.info.is_new_game) {
/* No owner/source information for a new game / scenario. */
return;
}
/* Owner and ownership source are stored as plain numbers */
for (y = 0; y < map.ysize; y++) {
const char *buffer1 = secfile_lookup_str(loading->file,
"map.owner%04d", y);
const char *buffer2 = secfile_lookup_str(loading->file,
"map.source%04d", y);
const char *ptr1 = buffer1;
const char *ptr2 = buffer2;
sg_failure_ret(buffer1 != NULL, "%s", secfile_error());
sg_failure_ret(buffer2 != NULL, "%s", secfile_error());
for (x = 0; x < map.xsize; x++) {
char token1[TOKEN_SIZE];
char token2[TOKEN_SIZE];
int number;
struct tile *ptile = native_pos_to_tile(x, y);
scanin(&ptr1, ",", token1, sizeof(token1));
sg_failure_ret(token1[0] != '\0',
"Map size not correct (map.owner%d).", y);
if (strcmp(token1, "-") == 0) {
owner = NULL;
} else {
sg_failure_ret(str_to_int(token1, &number),
"Got map owner %s in (%d, %d).", token1, x, y);
owner = player_by_number(number);
}
scanin(&ptr2, ",", token2, sizeof(token2));
sg_failure_ret(token2[0] != '\0',
"Map size not correct (map.source%d).", y);
if (strcmp(token2, "-") == 0) {
claimer = NULL;
} else {
sg_failure_ret(str_to_int(token2, &number),
"Got map source %s in (%d, %d).", token2, x, y);
claimer = index_to_tile(number);
}
map_claim_ownership(ptile, owner, claimer);
}
}
} | true | true | false | false | false | 1 |
is_source_positiv(int oper)
{
switch (OPER) {
case ABL_AND: case ABL_NAND:
switch (oper) {
case ABL_AND: case ABL_NAND: return 1;
case ABL_OR: case ABL_NOR: return 0;
default: return -1;
}
case ABL_OR: case ABL_NOR:
switch (oper) {
case ABL_OR: case ABL_NOR: return 1;
case ABL_AND: case ABL_NAND: return 0;
default: return -1;
}
case ABL_XOR:
switch (oper) {
case ABL_XOR: return 1;
case ABL_NXOR: return 1;
default: return -1;
}
case ABL_NXOR:
switch (oper) {
case ABL_XOR: return 1;
case ABL_NXOR: return 1;
default: return -1;
}
case ABL_STABLE: case ABL_NOT: return -1;
default:
fprintf(stderr,"is_source_positiv: %d operator unknown\n",OPER);
exit(1);
}
} | false | false | false | false | false | 0 |
evconnlistener_disable(struct evconnlistener *lev)
{
int r;
LOCK(lev);
lev->enabled = 0;
r = lev->ops->disable(lev);
UNLOCK(lev);
return r;
} | false | false | false | false | false | 0 |
do_timings (mvapich_state_t *st, const char *fmt, ...)
{
static int initialized = 0;
static struct timeval initv = { 0, 0 };
struct timeval tv;
struct timeval result;
char *msg;
va_list ap;
if (!st->do_timing)
return;
if (!initialized) {
if (gettimeofday (&initv, NULL) < 0)
error ("mvapich: do_timings(): gettimeofday(): %m");
initialized = 1;
return;
}
if (gettimeofday (&tv, NULL) < 0) {
error ("mvapich: do_timings(): gettimeofday(): %m");
return;
}
timersub (&tv, &initv, &result);
va_start (ap, fmt);
msg = vmsg (fmt, ap);
va_end (ap);
info ("mvapich: %s took %ld.%03ld seconds", msg,
(long int)result.tv_sec, (long int)result.tv_usec/1000);
xfree (msg);
return;
} | false | false | false | false | false | 0 |
GetArraySetting(int index)
{
if(index >= 0 && index < this->GetNumberOfArrays())
{
return this->Internal->ArraySettings[index];
}
return 0;
} | false | false | false | false | false | 0 |
stonith_api_add_callback(stonith_t * stonith, int call_id, int timeout, int options,
void *user_data, const char *callback_name,
void (*callback) (stonith_t * st, stonith_callback_data_t * data))
{
stonith_callback_client_t *blob = NULL;
stonith_private_t *private = NULL;
CRM_CHECK(stonith != NULL, return -EINVAL);
CRM_CHECK(stonith->private != NULL, return -EINVAL);
private = stonith->private;
if (call_id == 0) {
private->op_callback = callback;
} else if (call_id < 0) {
if (!(options & st_opt_report_only_success)) {
crm_trace("Call failed, calling %s: %s", callback_name, pcmk_strerror(call_id));
invoke_callback(stonith, call_id, call_id, user_data, callback);
} else {
crm_warn("STONITH call failed: %s", pcmk_strerror(call_id));
}
return FALSE;
}
blob = calloc(1, sizeof(stonith_callback_client_t));
blob->id = callback_name;
blob->only_success = (options & st_opt_report_only_success) ? TRUE : FALSE;
blob->user_data = user_data;
blob->callback = callback;
blob->allow_timeout_updates = (options & st_opt_timeout_updates) ? TRUE : FALSE;
if (timeout > 0) {
set_callback_timeout(blob, stonith, call_id, timeout);
}
g_hash_table_insert(private->stonith_op_callback_table, GINT_TO_POINTER(call_id), blob);
crm_trace("Added callback to %s for call %d", callback_name, call_id);
return TRUE;
} | false | false | false | false | false | 0 |
snd_emu10k1_del_controls(struct snd_emu10k1 *emu,
struct snd_emu10k1_fx8010_code *icode)
{
unsigned int i;
struct snd_ctl_elem_id id;
struct snd_ctl_elem_id __user *_id;
struct snd_emu10k1_fx8010_ctl *ctl;
struct snd_card *card = emu->card;
for (i = 0, _id = icode->gpr_del_controls;
i < icode->gpr_del_control_count; i++, _id++) {
if (copy_from_user(&id, _id, sizeof(id)))
return -EFAULT;
down_write(&card->controls_rwsem);
ctl = snd_emu10k1_look_for_ctl(emu, &id);
if (ctl)
snd_ctl_remove(card, ctl->kcontrol);
up_write(&card->controls_rwsem);
}
return 0;
} | false | false | false | false | false | 0 |
test_close_parent(hid_t fapl)
{
hid_t fid1 = -1, fid2 = -1; /* File IDs */
hid_t gidA = -1; /* Group IDs in file #1 */
hid_t gidM = -1; /* Group IDs in file #2 */
char name[NAME_BUF_SIZE]; /* Buffer for filename retrieved */
ssize_t name_len; /* Filename length */
char filename1[1024],
filename2[1024]; /* Name of files to mount */
TESTING("close parent");
h5_fixname(FILENAME[0], fapl, filename1, sizeof filename1);
h5_fixname(FILENAME[1], fapl, filename2, sizeof filename2);
/* Create file #1 */
if((fid1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if((gidA = H5Gcreate2(fid1, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Gclose(gidA) < 0)
TEST_ERROR
if(H5Fclose(fid1) < 0)
TEST_ERROR
/* Create file #2 */
if((fid2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if((gidM = H5Gcreate2(fid2, "M", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR
if(H5Gclose(gidM) < 0)
TEST_ERROR
if(H5Fclose(fid2) < 0)
TEST_ERROR
/* Re-open files and mount file #2 in file #1 */
if((fid1 = H5Fopen(filename1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
TEST_ERROR
if((gidA = H5Gopen2(fid1, "A", H5P_DEFAULT)) < 0)
TEST_ERROR
if((fid2 = H5Fopen(filename2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
TEST_ERROR
/* Mount files together */
if(H5Fmount(gidA, ".", fid2, H5P_DEFAULT) < 0)
TEST_ERROR
/* Open group in mounted file */
if((gidM = H5Gopen2(fid1, "A/M", H5P_DEFAULT)) < 0)
TEST_ERROR
/* Close group in file #1 */
if(H5Gclose(gidA) < 0)
TEST_ERROR
/* Close files #1 & #2 */
if(H5Fclose(fid1) < 0)
TEST_ERROR
if(H5Fclose(fid2) < 0)
TEST_ERROR
/* Check that all file IDs have been closed */
if(H5I_nmembers(H5I_FILE) != 0)
TEST_ERROR
/* Both underlying shared files should be open still */
H5F_sfile_assert_num(2);
/* Check the name of "M" is still defined */
*name = '\0';
if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0)
TEST_ERROR
if(name_len == 0 || HDstrcmp(name, "/A/M"))
TEST_ERROR
/* Unmount file #2 from file #1, closing file #1 */
if(H5Funmount(gidM, "/A") < 0)
TEST_ERROR
/* Check the name of "M" is defined in its file */
*name = '\0';
if((name_len = H5Iget_name(gidM, name, (size_t)NAME_BUF_SIZE )) < 0)
TEST_ERROR
if(name_len == 0 || HDstrcmp(name, "/M"))
TEST_ERROR
/* Just file #2's underlying shared file should be open still */
H5F_sfile_assert_num(1);
/* Close group in file #2, letting file #2 close */
if(H5Gclose(gidM) < 0)
TEST_ERROR
/* All underlying shared file structs should be closed */
H5F_sfile_assert_num(0);
PASSED();
return 0;
error:
H5E_BEGIN_TRY {
H5Gclose(gidM);
H5Gclose(gidA);
H5Fclose(fid2);
H5Fclose(fid1);
} H5E_END_TRY;
return 1;
} | true | true | true | false | false | 1 |
InitHighscores (void)
{
int i;
char fname[255];
FILE *file = NULL;
if (ConfigDir[0] != '\0')
{
sprintf (fname, "%s/highscores", ConfigDir);
if ( (file = fopen (fname, "r")) == NULL)
DebugPrintf (1, "WARNING: no highscores file found... \n");
}
num_highscores = MAX_HIGHSCORES; /* hardcoded for now... */
Highscores = MyMalloc (num_highscores * sizeof(Highscore_entry) + 10);
for (i=0; i< num_highscores; i++)
{
Highscores[i] = MyMalloc (sizeof(highscore_entry));
if (file)
fread (Highscores[i], sizeof(highscore_entry), sizeof(char), file);
else
{
strcpy (Highscores[i]->name, HS_EMPTY_ENTRY);
strcpy (Highscores[i]->date, " --- ");
Highscores[i]->score = -1;
}
}
if (file) fclose (file);
return;
} | true | true | false | false | true | 1 |
uxcopy_stdin (e)
FILE *e;
{
CATCH_PROTECT size_t cread;
char ab[1024];
do
{
size_t cwrite;
/* I want to use fread here, but there is a bug in some versions
of SVR4 which causes fread to return less than a complete
buffer even if EOF has not been reached. This is not online
time, so speed is not critical, but it's still quite annoying
to have to use an inefficient algorithm. */
cread = 0;
if (fsysdep_catch ())
{
usysdep_start_catch ();
while (cread < sizeof (ab))
{
int b;
if (FGOT_SIGNAL ())
uxabort (EX_OSERR);
/* There's an unimportant race here. If the user hits
^C between the FGOT_SIGNAL we just did and the time
we enter getchar, we won't know about the signal
(unless we're doing a longjmp, but we normally
aren't). It's not a big problem, because the user
can just hit ^C again. */
b = getchar ();
if (b == EOF)
break;
ab[cread] = b;
++cread;
}
}
usysdep_end_catch ();
if (FGOT_SIGNAL ())
uxabort (EX_OSERR);
if (cread > 0)
{
cwrite = fwrite (ab, sizeof (char), cread, e);
if (cwrite != cread)
ulog (LOG_FATAL, "fwrite: Wrote %d when attempted %d",
(int) cwrite, (int) cread);
}
}
while (cread == sizeof ab);
} | false | false | false | false | false | 0 |
ImportTIFF_CheckStandardMapping ( const TIFF_Manager::TagInfo & tagInfo, const TIFF_MappingToXMP & mapInfo )
{
XMP_Assert ( (kTIFF_ByteType <= tagInfo.type) && (tagInfo.type <= kTIFF_LastType) );
XMP_Assert ( mapInfo.type <= kTIFF_LastType );
if ( (tagInfo.type < kTIFF_ByteType) || (tagInfo.type > kTIFF_LastType) ) return false;
if ( tagInfo.type != mapInfo.type ) {
if ( mapInfo.type != kTIFF_ShortOrLongType ) return false;
if ( (tagInfo.type != kTIFF_ShortType) && (tagInfo.type != kTIFF_LongType) ) return false;
}
if ( (tagInfo.count != mapInfo.count) && // Maybe there is a problem because the counts don't match.
// (mapInfo.count != kAnyCount) && ... don't need this because of the new check below ...
(mapInfo.count == 1) ) return false; // Be tolerant of mismatch in expected array size.
return true;
} | false | false | false | false | false | 0 |
rt2x00queue_unpause_queue(struct data_queue *queue)
{
if (!test_bit(DEVICE_STATE_PRESENT, &queue->rt2x00dev->flags) ||
!test_bit(QUEUE_STARTED, &queue->flags) ||
!test_and_clear_bit(QUEUE_PAUSED, &queue->flags))
return;
switch (queue->qid) {
case QID_AC_VO:
case QID_AC_VI:
case QID_AC_BE:
case QID_AC_BK:
/*
* For TX queues, we have to enable the queue
* inside mac80211.
*/
ieee80211_wake_queue(queue->rt2x00dev->hw, queue->qid);
break;
case QID_RX:
/*
* For RX we need to kick the queue now in order to
* receive frames.
*/
queue->rt2x00dev->ops->lib->kick_queue(queue);
default:
break;
}
} | false | false | false | false | false | 0 |
on_treeview_row_expanded(GtkWidget *widget, GtkTreeIter *iter, GtkTreePath *path, gpointer user_data)
{
gchar *uri;
gtk_tree_model_get(GTK_TREE_MODEL(treestore), iter, TREEBROWSER_COLUMN_URI, &uri, -1);
if (uri == NULL)
return;
if (flag_on_expand_refresh == FALSE)
{
flag_on_expand_refresh = TRUE;
treebrowser_browse(uri, iter);
gtk_tree_view_expand_row(GTK_TREE_VIEW(treeview), path, FALSE);
flag_on_expand_refresh = FALSE;
}
if (CONFIG_SHOW_ICONS)
{
GdkPixbuf *icon = utils_pixbuf_from_stock(GTK_STOCK_OPEN);
gtk_tree_store_set(treestore, iter, TREEBROWSER_COLUMN_ICON, icon, -1);
g_object_unref(icon);
}
g_free(uri);
} | false | false | false | false | false | 0 |
yy_create_buffer( FILE *file, int size )
#else
YY_BUFFER_STATE yy_create_buffer( file, size )
FILE *file;
int size;
#endif
{
YY_BUFFER_STATE b;
b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
b->yy_buf_size = size;
/* yy_ch_buf has to be 2 characters longer than the size given because
* we need to put in 2 end-of-buffer characters.
*/
b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
yy_init_buffer( b, file );
return b;
} | false | false | false | false | false | 0 |
io_stats_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno,
struct iovec *vector, int32_t count,
struct iatt *buf, struct iobref *iobref, dict_t *xdata)
{
int len = 0;
fd_t *fd = NULL;
struct ios_stat *iosstat = NULL;
fd = frame->local;
frame->local = NULL;
if (op_ret > 0) {
len = iov_length (vector, count);
BUMP_READ (fd, len);
}
UPDATE_PROFILE_STATS (frame, READ);
ios_inode_ctx_get (fd->inode, this, &iosstat);
if (iosstat) {
BUMP_STATS (iosstat, IOS_STATS_TYPE_READ);
BUMP_THROUGHPUT (iosstat, IOS_STATS_THRU_READ);
iosstat = NULL;
}
STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno,
vector, count, buf, iobref, xdata);
return 0;
} | false | false | false | false | false | 0 |
user_print2(hid_t err_stack, FILE *stream)
{
/* Customized way to print errors */
fprintf(stderr, "\n********* Print error stack in customized way *********\n");
if(H5Ewalk2(err_stack, H5E_WALK_UPWARD, (H5E_walk2_t)custom_print_cb2, stream) < 0)
TEST_ERROR;
return 0;
error:
return -1;
} | false | false | false | false | false | 0 |
PR_StringToNetAddr(const char *string, PRNetAddr *addr)
{
if (!_pr_initialized) _PR_ImplicitInitialization();
if (!addr || !string || !*string)
{
PR_SetError(PR_INVALID_ARGUMENT_ERROR, 0);
return PR_FAILURE;
}
#if !defined(_PR_HAVE_GETADDRINFO)
return pr_StringToNetAddrFB(string, addr);
#else
/*
* getaddrinfo with AI_NUMERICHOST is much slower than pr_inet_aton on some
* platforms, such as Mac OS X (bug 404399), Linux glibc 2.10 (bug 344809),
* and most likely others. So we only use it to convert literal IP addresses
* that contain IPv6 scope IDs, which pr_inet_aton cannot convert.
*/
if (!strchr(string, '%'))
return pr_StringToNetAddrFB(string, addr);
#if defined(_PR_INET6_PROBE)
if (!_pr_ipv6_is_present())
return pr_StringToNetAddrFB(string, addr);
#endif
return pr_StringToNetAddrGAI(string, addr);
#endif
} | false | false | false | false | false | 0 |
crypto_unregister_aeads(struct aead_alg *algs, int count)
{
int i;
for (i = count - 1; i >= 0; --i)
crypto_unregister_aead(&algs[i]);
} | false | false | false | false | false | 0 |
Reset(void)
{
mActiveNum = 0;
for (PRUint32 i = 0; i < NUM_OF_PROBERS; i++)
{
if (mProbers[i])
{
mProbers[i]->Reset();
mIsActive[i] = PR_TRUE;
++mActiveNum;
}
else
mIsActive[i] = PR_FALSE;
}
mBestGuess = -1;
mState = eDetecting;
mKeepNext = 0;
} | false | false | false | false | false | 0 |
openLogFile(const wchar_t* filename)
{
CMT3LOG("L3: openLogFile \"%S\"\n",filename?filename:L"");
CMT3EXITLOG;
m_logging = false;
if (m_serial.isOpen())
return m_lastResult = XRV_INVALIDOPERATION;
if (m_logFile.isOpen())
return m_lastResult = XRV_ALREADYOPEN;
m_lastResult = m_logFile.open(filename,true);
if (m_lastResult == XRV_OK)
{
if (refreshCache() == XRV_OK)
m_readFromFile = true;
else
{
m_logFile.close();
m_readFromFile = false;
}
}
return m_lastResult;
} | false | false | false | false | false | 0 |
FreeKMeansResult(bisecting_kmeans_result_t **prResult_p)
{
int iAux;
CKFREE((*prResult_p)->piNObjsPerCluster);
for (iAux=0; iAux<(*prResult_p)->iNClusters; iAux++) {
CKFREE((*prResult_p)->ppiObjIndicesPerCluster[iAux]);
CKFREE((*prResult_p)->ppdClusterCenters[iAux]);
}
CKFREE((*prResult_p)->ppiObjIndicesPerCluster);
CKFREE((*prResult_p)->ppdClusterCenters);
(*prResult_p)->iNClusters = 0;
(*prResult_p)->iDim = 0;
CKFREE(*prResult_p);
} | false | false | false | false | false | 0 |
pf_ctx_init (pf_ctx_t *ctx, const pf_conf_t *conf, struct pf_stat_s *stat)
{
int rc = 0;
memset (ctx, 0, sizeof (*ctx));
ctx->conf = conf;
ctx->stat = stat;
ctx->fd = -1;
ctx->state = PF_CTX_AVAIL;
if (conf->do_init)
rc = conf->do_init(ctx);
return rc;
} | false | false | false | false | false | 0 |
clear_newcaps_for_pt (GstRtpPtDemux * rtpdemux, guint8 pt)
{
GSList *walk;
GST_OBJECT_LOCK (rtpdemux);
for (walk = rtpdemux->srcpads; walk; walk = g_slist_next (walk)) {
GstRtpPtDemuxPad *pad = walk->data;
if (pad->pt == pt) {
pad->newcaps = FALSE;
break;
}
}
GST_OBJECT_UNLOCK (rtpdemux);
} | false | false | false | false | false | 0 |
slapiControlOp2SlapControlMask(unsigned long slapi_mask,
slap_mask_t *slap_mask)
{
*slap_mask = 0;
if ( slapi_mask & SLAPI_OPERATION_BIND )
*slap_mask |= SLAP_CTRL_BIND;
if ( slapi_mask & SLAPI_OPERATION_UNBIND )
*slap_mask |= SLAP_CTRL_UNBIND;
if ( slapi_mask & SLAPI_OPERATION_SEARCH )
*slap_mask |= SLAP_CTRL_SEARCH;
if ( slapi_mask & SLAPI_OPERATION_MODIFY )
*slap_mask |= SLAP_CTRL_MODIFY;
if ( slapi_mask & SLAPI_OPERATION_ADD )
*slap_mask |= SLAP_CTRL_ADD;
if ( slapi_mask & SLAPI_OPERATION_DELETE )
*slap_mask |= SLAP_CTRL_DELETE;
if ( slapi_mask & SLAPI_OPERATION_MODDN )
*slap_mask |= SLAP_CTRL_RENAME;
if ( slapi_mask & SLAPI_OPERATION_COMPARE )
*slap_mask |= SLAP_CTRL_COMPARE;
if ( slapi_mask & SLAPI_OPERATION_ABANDON )
*slap_mask |= SLAP_CTRL_ABANDON;
*slap_mask |= SLAP_CTRL_GLOBAL;
} | false | false | false | false | false | 0 |
do_cmd_toggle_search(cmd_code code, cmd_arg args[])
{
/* Stop searching */
if (p_ptr->searching)
{
/* Clear the searching flag */
p_ptr->searching = FALSE;
/* Recalculate bonuses */
p_ptr->update |= (PU_BONUS);
/* Redraw the state */
p_ptr->redraw |= (PR_STATE);
}
/* Start searching */
else
{
/* Set the searching flag */
p_ptr->searching = TRUE;
/* Update stuff */
p_ptr->update |= (PU_BONUS);
/* Redraw stuff */
p_ptr->redraw |= (PR_STATE | PR_SPEED);
}
} | false | false | false | false | false | 0 |
select_detect(jit_State *J)
{
BCIns ins = J->pc[1];
if (bc_op(ins) == BC_CALLM && bc_b(ins) == 2 && bc_c(ins) == 1) {
cTValue *func = &J->L->base[bc_a(ins)];
if (tvisfunc(func) && funcV(func)->c.ffid == FF_select)
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
char2str(const char c)
{
string ret = "";
ret += c;
return ret;
} | false | false | false | false | false | 0 |
serveroperator()
{
loopv(clients) if(clients[i]->type!=ST_EMPTY && clients[i]->role > CR_DEFAULT) return i;
return -1;
} | false | false | false | false | false | 0 |
powr1220_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct powr1220_data *data;
struct device *hwmon_dev;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return -ENOMEM;
mutex_init(&data->update_lock);
data->client = client;
hwmon_dev = devm_hwmon_device_register_with_groups(&client->dev,
client->name, data, powr1220_groups);
return PTR_ERR_OR_ZERO(hwmon_dev);
} | false | false | false | false | false | 0 |
addModule( const QString& module )
{
/* In case it doesn't exist we just silently drop it.
* This allows people to easily extend containers.
* For example, KCM monitor gamma can be in kdegraphics.
*/
KService::Ptr service = KService::serviceByDesktopName( module );
if ( !service )
{
kDebug(713) << "KCModuleContainer: module '" <<
module << "' was not found and thus not loaded" << endl;
return;
}
if ( service->noDisplay() )
return;
KCModuleProxy* proxy = new KCModuleProxy( service, d->tabWidget );
allModules.append( proxy );
proxy->setObjectName( module.toLatin1() );
d->tabWidget->addTab( proxy, KIcon( proxy->moduleInfo().icon() ),
/* Qt eats ampersands for dinner. But not this time. */
proxy->moduleInfo().moduleName().replace( '&', "&&" ));
d->tabWidget->setTabToolTip( d->tabWidget->indexOf( proxy ), proxy->moduleInfo().comment() );
connect( proxy, SIGNAL(changed(KCModuleProxy*)), SLOT(moduleChanged(KCModuleProxy*)));
/* Collect our buttons - we go for the common deliminator */
setButtons( buttons() | proxy->realModule()->buttons() );
} | false | false | false | false | false | 0 |
get_stored_layout_timestamp (NemoIconContainer *container,
NemoIconData *icon_data,
time_t *timestamp,
NemoIconView *view)
{
NemoFile *file;
NemoDirectory *directory;
if (icon_data == NULL) {
directory = nemo_view_get_model (NEMO_VIEW (view));
if (directory == NULL) {
return FALSE;
}
file = nemo_directory_get_corresponding_file (directory);
*timestamp = nemo_file_get_time_metadata (file,
NEMO_METADATA_KEY_ICON_VIEW_LAYOUT_TIMESTAMP);
nemo_file_unref (file);
} else {
*timestamp = nemo_file_get_time_metadata (NEMO_FILE (icon_data),
NEMO_METADATA_KEY_ICON_POSITION_TIMESTAMP);
}
return TRUE;
} | false | false | false | false | false | 0 |
ja_euc_char_type(chasen_tok_t *tok, unsigned char *str, int len)
{
int mblen = tok->mblen(str, len);
if (mblen == 1) {
if (isalpha(str[0])) {
return HALF_LATIN;
} else if (is_space(str[0])) {
return JA_SPACE;
}
} else if (mblen == 2) {
if ((str[0] == 0xa1) && (str[1] == 0xbc)) {
return PROLONGED;
} else if (str[0] == 0xa5) {
if ((str[1] == 0xa1) || (str[1] == 0xa3) ||
(str[1] == 0xa5) || (str[1] == 0xa7) ||
(str[1] == 0xa9) || (str[1] == 0xc3) ||
(str[1] == 0xe3) || (str[1] == 0xe5) ||
(str[1] == 0xe7) || (str[1] == 0xee)) {
return SMALL_KATAKANA;
} else {
return KATAKANA;
}
} else if ((str[0] == 0xa3) && (str[1] >= 0xc1)) {
return FULL_LATIN;
}
}
return JA_OTHER;
} | false | false | false | false | false | 0 |
SetLogFile(char const* strNewLogFile)
{
if (m_strLogFile == NULL ||
strNewLogFile == NULL ||
strcmp(m_strLogFile,strNewLogFile) != 0)
{
free((void*)m_strLogFile);
m_strLogFile = strNewLogFile == NULL ? (char *)NULL : strdup(strNewLogFile);
m_bOpened = false;
}
} | false | false | false | false | false | 0 |
e132xs_xori(void)
{
UINT32 op1, op2, ret;
op1 = immediate_value();
if( D_BIT )
{
op2 = GET_L_REG(D_CODE);
}
else
{
op2 = GET_G_REG(D_CODE);
}
ret = op1 ^ op2;
SET_RD(ret, NOINC);
SET_Z((ret == 0 ? 1: 0));
e132xs_ICount -= 1;
} | false | false | false | false | false | 0 |
IO_getval(IOobject *self, PyObject *args) {
PyObject *use_pos=Py_None;
int b;
Py_ssize_t s;
if (!IO__opencheck(self)) return NULL;
if (!PyArg_UnpackTuple(args,"getval", 0, 1,&use_pos)) return NULL;
b = PyObject_IsTrue(use_pos);
if (b < 0)
return NULL;
if (b) {
s=self->pos;
if (s > self->string_size) s=self->string_size;
}
else
s=self->string_size;
assert(self->pos >= 0);
return PyString_FromStringAndSize(self->buf, s);
} | false | false | false | false | false | 0 |
NewSceneStats()
{
GF_SceneStatistics *tmp;
GF_SAFEALLOC(tmp, GF_SceneStatistics);
tmp->node_stats = gf_list_new();
tmp->proto_stats = gf_list_new();
tmp->max_2d.x = FIX_MIN;
tmp->max_2d.y = FIX_MIN;
tmp->max_3d.x = FIX_MIN;
tmp->max_3d.y = FIX_MIN;
tmp->max_3d.z = FIX_MIN;
tmp->min_2d.x = FIX_MAX;
tmp->min_2d.y = FIX_MAX;
tmp->min_3d.x = FIX_MAX;
tmp->min_3d.y = FIX_MAX;
tmp->min_3d.z = FIX_MAX;
return tmp;
} | false | false | false | true | false | 1 |
netsnmp_arch_defaultrouter_container_load(netsnmp_container *container,
u_int load_flags)
{
int rc = 0;
DEBUGMSGTL(("access:defaultrouter:entry:arch", "load (linux)\n"));
rc = _load(container);
if (rc < 0) {
u_int flags = NETSNMP_ACCESS_DEFAULTROUTER_FREE_KEEP_CONTAINER;
netsnmp_access_defaultrouter_container_free(container, flags);
}
return rc;
} | false | false | false | false | false | 0 |
text_attribute(gpaint_tool* tool, gpaint_attribute attrib, gpointer data)
{
debug_fn();
GtkStyle *style;
GtkWidget *widget = NULL;
if ((tool->canvas == NULL) || (tool->canvas->drawing_area == NULL)) return FALSE;
widget = GTK_WIDGET(tool->canvas->drawing_area);
style = gtk_widget_get_style(widget);
g_assert(style);
if (attrib == GpaintFont)
{
gpaint_text *text = GPAINT_TEXT(tool);
gtk_widget_modify_font(widget, pango_font_description_from_string((char*) data));
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
TIFFReadDirEntryData(TIFF* tif, uint64 offset, tmsize_t size, void* dest)
{
assert(size>0);
if (!isMapped(tif)) {
if (!SeekOK(tif,offset))
return(TIFFReadDirEntryErrIo);
if (!ReadOK(tif,dest,size))
return(TIFFReadDirEntryErrIo);
} else {
size_t ma,mb;
ma=(size_t)offset;
mb=ma+size;
if (((uint64)ma!=offset)
|| (mb < ma)
|| (mb - ma != (size_t) size)
|| (mb < (size_t)size)
|| (mb > (size_t)tif->tif_size)
)
return(TIFFReadDirEntryErrIo);
_TIFFmemcpy(dest,tif->tif_base+ma,size);
}
return(TIFFReadDirEntryErrOk);
} | false | false | false | false | false | 0 |
vTaskSwitchContext( void )
{
if( uxSchedulerSuspended != ( UBaseType_t ) pdFALSE )
{
/* The scheduler is currently suspended - do not allow a context
switch. */
xYieldPending = pdTRUE;
}
else
{
xYieldPending = pdFALSE;
traceTASK_SWITCHED_OUT();
#if ( configGENERATE_RUN_TIME_STATS == 1 )
{
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalRunTime );
#else
ulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
/* Add the amount of time the task has been running to the
accumulated time so far. The time the task started running was
stored in ulTaskSwitchedInTime. Note that there is no overflow
protection here so count values are only valid until the timer
overflows. The guard against negative values is to protect
against suspect run time stat counter implementations - which
are provided by the application, not the kernel. */
if( ulTotalRunTime > ulTaskSwitchedInTime )
{
pxCurrentTCB->ulRunTimeCounter += ( ulTotalRunTime - ulTaskSwitchedInTime );
}
else
{
mtCOVERAGE_TEST_MARKER();
}
ulTaskSwitchedInTime = ulTotalRunTime;
}
#endif /* configGENERATE_RUN_TIME_STATS */
/* Check for stack overflow, if configured. */
taskCHECK_FOR_STACK_OVERFLOW();
/* Select a new task to run using either the generic C or port
optimised asm code. */
taskSELECT_HIGHEST_PRIORITY_TASK();
traceTASK_SWITCHED_IN();
#if ( configUSE_NEWLIB_REENTRANT == 1 )
{
/* Switch Newlib's _impure_ptr variable to point to the _reent
structure specific to this task. */
_impure_ptr = &( pxCurrentTCB->xNewLib_reent );
}
#endif /* configUSE_NEWLIB_REENTRANT */
}
} | false | false | false | false | false | 0 |
_comedi_dio_write(comedi_t *it,unsigned int subdev,unsigned int chan,
unsigned int val)
{
subdevice *s;
if(!valid_chan(it,subdev,chan))
return -1;
s = it->subdevices+subdev;
if(s->type!=COMEDI_SUBD_DIO &&
s->type!=COMEDI_SUBD_DO)
return -1;
if(it->has_insnlist_ioctl){
comedi_insn insn;
lsampl_t data;
memset(&insn,0,sizeof(insn));
insn.insn = INSN_WRITE;
insn.n = 1;
insn.data = &data;
insn.subdev = subdev;
insn.chanspec = CR_PACK(chan,0,0);
data = val;
return comedi_do_insn(it,&insn);
}else{
comedi_trig trig;
sampl_t data;
data=val;
memset(&trig,0,sizeof(trig));
trig.n_chan=1;
trig.n=1;
trig.flags=TRIG_WRITE;
trig.subdev=subdev;
trig.chanlist=&chan;
trig.data=&data;
return comedi_trigger(it,&trig);
}
} | false | false | false | false | false | 0 |
_read_record_id_range (int *flag,
uint16_t *range1,
uint16_t *range2,
char *arg)
{
char *endptr;
char *range_str = NULL;
char *start_ptr = NULL;
char *range1_str = NULL;
char *range2_str = NULL;
int value = 0;
assert (flag);
assert (range1);
assert (range2);
assert (arg);
(*flag) = 1;
if (!(range_str = strdup (arg)))
{
perror ("strdup");
exit (1);
}
if (!(start_ptr = strchr (range_str, '-')))
{
/* invalid input */
fprintf (stderr, "invalid range input\n");
exit (1);
}
if (!(range2_str = strdup (start_ptr + 1)))
{
perror ("strdup");
exit (1);
}
*start_ptr = '\0';
range1_str = range_str;
errno = 0;
value = strtol (range1_str, &endptr, 10);
if (errno
|| endptr[0] != '\0'
|| value < 0
|| value <= IPMI_SEL_GET_RECORD_ID_FIRST_ENTRY
|| value >= IPMI_SEL_GET_RECORD_ID_LAST_ENTRY)
{
fprintf (stderr, "invalid range record number: %d\n", value);
exit (1);
}
(*range1) = value;
errno = 0;
value = strtol (range2_str, &endptr, 10);
if (errno
|| endptr[0] != '\0'
|| value < 0
|| value <= IPMI_SEL_GET_RECORD_ID_FIRST_ENTRY
|| value >= IPMI_SEL_GET_RECORD_ID_LAST_ENTRY)
{
fprintf (stderr, "invalid range record number: %d\n", value);
exit (1);
}
(*range2) = value;
if ((*range2) < (*range1))
{
fprintf (stderr, "invalid END range\n");
exit (1);
}
free (range1_str);
free (range2_str);
} | false | false | false | false | false | 0 |
dav_fs_patch_rollback(const dav_resource *resource,
int operation,
void *context,
dav_liveprop_rollback *rollback_ctx)
{
apr_fileperms_t perms = resource->info->finfo.protection & ~APR_UEXECUTE;
apr_status_t status;
int value = rollback_ctx != NULL;
/* assert: prop == executable. operation == SET. */
/* restore the executable bit */
if (value)
perms |= APR_UEXECUTE;
if ((status = apr_file_perms_set(resource->info->pathname, perms))
!= APR_SUCCESS) {
return dav_new_error(resource->info->pool,
HTTP_INTERNAL_SERVER_ERROR, 0, status,
"After a failure occurred, the resource's "
"executable flag could not be restored.");
}
/* restore the resource's state */
resource->info->finfo.protection = perms;
return NULL;
} | false | false | false | false | false | 0 |
e_cal_backend_refresh (ECalBackend *backend,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *simple;
g_return_if_fail (E_IS_CAL_BACKEND (backend));
simple = g_simple_async_result_new (
G_OBJECT (backend), callback,
user_data, e_cal_backend_refresh);
g_simple_async_result_set_check_cancellable (simple, cancellable);
cal_backend_push_operation (
backend, simple, cancellable, FALSE,
cal_backend_refresh_thread);
cal_backend_dispatch_next_operation (backend);
g_object_unref (simple);
} | false | false | false | false | false | 0 |
iflinux_add_physical(struct lldpd *cfg,
struct interfaces_device_list *interfaces)
{
struct interfaces_device *iface;
/* White-list some drivers */
const char * const *rif;
const char * const regular_interfaces[] = {
"dsa",
"veth",
NULL
};
TAILQ_FOREACH(iface, interfaces, next) {
if (iface->type & (IFACE_VLAN_T|
IFACE_BOND_T|IFACE_BRIDGE_T))
continue;
iface->type &= ~IFACE_PHYSICAL_T;
/* We request that the interface is able to do either multicast
* or broadcast to be able to send discovery frames. */
if (!(iface->flags & (IFF_MULTICAST|IFF_BROADCAST))) {
log_debug("interfaces", "skip %s: not able to do multicast nor broadcast",
iface->name);
continue;
}
/* Check if the driver is whitelisted */
if (iface->driver) {
for (rif = regular_interfaces; *rif; rif++) {
if (strcmp(iface->driver, *rif) == 0) {
/* White listed! */
log_debug("interfaces", "accept %s: whitelisted",
iface->name);
iface->type |= IFACE_PHYSICAL_T;
continue;
}
}
}
/* If the interface is linked to another one, skip it too. */
if (iface->lower) {
log_debug("interfaces", "skip %s: there is a lower interface (%s)",
iface->name, iface->lower->name);
continue;
}
/* Check queue len. If no queue, this usually means that this
is not a "real" interface. */
if (iface->txqueue == 0) {
log_debug("interfaces", "skip %s: no queue",
iface->name);
continue;
}
/* Get the real MAC address (for example, if the interface is enslaved) */
iflinux_get_permanent_mac(cfg, interfaces, iface);
log_debug("interfaces",
"%s is a physical interface",
iface->name);
iface->type |= IFACE_PHYSICAL_T;
}
} | false | false | false | false | false | 0 |
fill_wedge_from_list_rec(patch_fill_state_t *pfs,
wedge_vertex_list_elem_t *beg, const wedge_vertex_list_elem_t *end,
int level, const patch_color_t *c0, const patch_color_t *c1)
{
if (beg->next == end)
return 0;
else if (beg->next->next == end) {
if (beg->next->divide_count != 1 && beg->next->divide_count != 2)
return_error(gs_error_unregistered); /* Must not happen. */
if (beg->next->divide_count != 1)
return 0;
return fill_triangle_wedge_from_list(pfs, beg, end, beg->next, c0, c1);
} else {
gs_fixed_point p;
wedge_vertex_list_elem_t *e;
patch_color_t *c;
int code;
byte *color_stack_ptr = reserve_colors_inline(pfs, &c, 1);
if (color_stack_ptr == NULL)
return_error(gs_error_unregistered); /* Must not happen. */
p.x = (beg->p.x + end->p.x) / 2;
p.y = (beg->p.y + end->p.y) / 2;
e = wedge_vertex_list_find(beg, end, level + 1);
if (e == NULL)
return_error(gs_error_unregistered); /* Must not happen. */
if (e->p.x != p.x || e->p.y != p.y)
return_error(gs_error_unregistered); /* Must not happen. */
patch_interpolate_color(c, c0, c1, pfs, 0.5);
code = fill_wedge_from_list_rec(pfs, beg, e, level + 1, c0, c);
if (code >= 0)
code = fill_wedge_from_list_rec(pfs, e, end, level + 1, c, c1);
if (code >= 0) {
if (e->divide_count != 1 && e->divide_count != 2)
return_error(gs_error_unregistered); /* Must not happen. */
if (e->divide_count == 1)
code = fill_triangle_wedge_from_list(pfs, beg, end, e, c0, c1);
}
release_colors_inline(pfs, color_stack_ptr, 1);
return code;
}
} | false | false | false | false | false | 0 |
DoubleOr(struct Expression * exp, struct Operand * op1, struct Operand * op2)
{
double value2 = op2->d;
exp->type = 2;
exp->string = PrintDouble(op1->d || value2);
if(!exp->expType)
{
exp->expType = op1->type;
if(op1->type)
op1->type->refCount++;
}
return 0x1;
} | false | false | false | false | false | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.