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 |
|---|---|---|---|---|---|---|
gl843_stop_action (Genesys_Device * dev)
{
SANE_Status status;
uint8_t val40, val;
unsigned int loop;
DBG (DBG_proc, "%s\n", __FUNCTION__);
status = sanei_genesys_get_status (dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
val40 = 0;
status = sanei_genesys_read_register (dev, REG40, &val40);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n", __FUNCTION__,
sane_strstatus (status));
DBG (DBG_proc, "%s: completed\n", __FUNCTION__);
return status;
}
/* only stop action if needed */
if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG))
{
DBG (DBG_info, "%s: already stopped\n", __FUNCTION__);
DBG (DBG_proc, "%s: completed\n", __FUNCTION__);
return SANE_STATUS_GOOD;
}
/* ends scan 646 */
val = sanei_genesys_read_reg_from_set (dev->reg, REG01);
val &= ~REG01_SCAN;
sanei_genesys_set_reg_from_set (dev->reg, REG01, val);
status = sanei_genesys_write_register (dev, REG01, val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error, "%s: failed to write register 01: %s\n", __FUNCTION__,
sane_strstatus (status));
return status;
}
usleep (100 * 1000);
loop = 10;
while (loop > 0)
{
status = sanei_genesys_get_status (dev, &val);
if (DBG_LEVEL >= DBG_io)
{
sanei_genesys_print_status (val);
}
val40 = 0;
status = sanei_genesys_read_register (dev, 0x40, &val40);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"%s: failed to read home sensor: %s\n", __FUNCTION__,
sane_strstatus (status));
DBGCOMPLETED;
return status;
}
/* if scanner is in command mode, we are done */
if (!(val40 & REG40_DATAENB) && !(val40 & REG40_MOTMFLG)
&& !(val & REG41_MOTORENB))
{
DBGCOMPLETED;
return SANE_STATUS_GOOD;
}
usleep (100 * 1000);
loop--;
}
DBGCOMPLETED;
return SANE_STATUS_IO_ERROR;
} | false | false | false | false | true | 1 |
Typeout(const char *fmt, ...)
#else
/*VARARGS1*/ void
Typeout(fmt, va_alist)
const char *fmt;
va_dcl
#endif
{
char string[MAX_TYPEOUT+1];
va_list ap;
va_init(ap, fmt);
format(string, sizeof string, fmt, ap);
va_end(ap);
if (UseBuffers) {
ins_str(string);
ins_str("\n");
} else {
char outbuf[MAXCOLS + PPWIDTH]; /* assert(CO <= MAXCOLS); */
if (LineNo == ILI - 2) {
TOprompt("--more--");
LineNo = 0;
}
if (!TOabort) {
DeTab(string, 0, outbuf, outbuf + CO, NO);
TOlineFits(outbuf);
LineNo += 1;
}
}
} | false | false | false | false | false | 0 |
CleanMetaData(MetaData::Pointer in) const
{
Acquisition::MetaDataIterator it = in->Begin();
while (it != in->End())
{
this->CleanMetaData(*it);
if (!(*it)->HasChildren() && !(*it)->HasInfo())
it = in->RemoveChild(it);
else
++it;
}
} | false | false | false | false | false | 0 |
qif_file_parse(QifContext ctx, gpointer ui_args)
{
g_return_val_if_fail(ctx, QIF_E_BADARGS);
g_return_val_if_fail(!qif_file_needs_account(ctx), QIF_E_BADSTATE);
qif_parse_all(ctx, ui_args);
ctx->parsed = TRUE;
return QIF_E_OK;
} | false | false | false | false | false | 0 |
do_scheduled_accept(int status, FdEventHandlerPtr event)
{
AcceptRequestPtr request = (AcceptRequestPtr)&event->data;
int rc, done;
unsigned len;
struct sockaddr_in addr;
if(status) {
done = request->handler(status, event, request);
if(done) return done;
}
len = sizeof(struct sockaddr_in);
rc = accept(request->fd, (struct sockaddr*)&addr, &len);
if(rc >= 0)
done = request->handler(rc, event, request);
else
done = request->handler(-errno, event, request);
return done;
} | false | false | false | false | false | 0 |
gst_rtp_buffer_get_csrc (GstRTPBuffer * rtp, guint8 idx)
{
guint8 *data;
data = rtp->data[0];
g_return_val_if_fail (idx < GST_RTP_HEADER_CSRC_COUNT (data), 0);
return GST_READ_UINT32_BE (GST_RTP_HEADER_CSRC_LIST_OFFSET (data, idx));
} | false | false | false | false | false | 0 |
apol_infoflow_analysis_trans_further_next(const apol_policy_t * p, apol_infoflow_graph_t * g, apol_vector_t ** v)
{
apol_infoflow_node_t *start_node;
int retval = -1;
if (p == NULL || g == NULL || v == NULL) {
ERR(p, "%s", strerror(EINVAL));
errno = EINVAL;
return -1;
}
if (*v == NULL) {
*v = apol_vector_create(infoflow_result_free);
}
if (g->further_start == NULL) {
ERR(p, "%s", "Infoflow graph was not prepared yet.");
goto cleanup;
}
start_node = apol_vector_get_element(g->further_start, g->current_start);
if (apol_infoflow_analysis_trans_further(p, g, start_node, *v) < 0) {
goto cleanup;
}
g->current_start++;
if (g->current_start >= apol_vector_get_size(g->further_start)) {
g->current_start = 0;
}
retval = 0;
cleanup:
return retval;
} | false | false | false | false | false | 0 |
Maxent_donor_prob_revcomp (char *sequence) {
double maxentscore, odds;
if (sequence_okay(sequence,DONOR_MODEL_RIGHT_MARGIN+DONOR_MODEL_LEFT_MARGIN) == false) {
return 0.0;
} else {
maxentscore = me2x3donor[hashseq_skip_revcomp(&(sequence[0]),4,2,3)];
odds = score_donor_dinucleotide_revcomp(sequence[DONOR_MODEL_RIGHT_MARGIN-1],
sequence[DONOR_MODEL_RIGHT_MARGIN])*maxentscore;
return odds/(1.0 + odds);
}
} | false | false | false | false | false | 0 |
gtk_term_get_name(GtkWidget *widget)
{
GtkTerm *term;
g_return_val_if_fail (widget != NULL,0);
g_return_val_if_fail (GTK_IS_TERM (widget),0);
term = GTK_TERM (widget);
return term->name->str;
} | false | false | false | false | false | 0 |
Perl_ck_sort(pTHX_ OP *o)
{
dVAR;
OP *firstkid;
HV * const hinthv = GvHV(PL_hintgv);
PERL_ARGS_ASSERT_CK_SORT;
if (hinthv) {
SV ** const svp = hv_fetchs(hinthv, "sort", FALSE);
if (svp) {
const I32 sorthints = (I32)SvIV(*svp);
if ((sorthints & HINT_SORT_QUICKSORT) != 0)
o->op_private |= OPpSORT_QSORT;
if ((sorthints & HINT_SORT_STABLE) != 0)
o->op_private |= OPpSORT_STABLE;
}
}
if (o->op_flags & OPf_STACKED)
simplify_sort(o);
firstkid = cLISTOPo->op_first->op_sibling; /* get past pushmark */
if (o->op_flags & OPf_STACKED) { /* may have been cleared */
OP *kid = cUNOPx(firstkid)->op_first; /* get past null */
if (kid->op_type == OP_SCOPE || kid->op_type == OP_LEAVE) {
LINKLIST(kid);
if (kid->op_type == OP_LEAVE)
op_null(kid); /* wipe out leave */
/* Prevent execution from escaping out of the sort block. */
kid->op_next = 0;
/* provide scalar context for comparison function/block */
kid = scalar(firstkid);
kid->op_next = kid;
o->op_flags |= OPf_SPECIAL;
}
firstkid = firstkid->op_sibling;
}
/* provide list context for arguments */
list(firstkid);
return o;
} | false | false | false | false | false | 0 |
snd_seq_oss_synth_sysex(struct seq_oss_devinfo *dp, int dev, unsigned char *buf, struct snd_seq_event *ev)
{
int i, send;
unsigned char *dest;
struct seq_oss_synth_sysex *sysex;
if (! snd_seq_oss_synth_is_valid(dp, dev))
return -ENXIO;
sysex = dp->synths[dev].sysex;
if (sysex == NULL) {
sysex = kzalloc(sizeof(*sysex), GFP_KERNEL);
if (sysex == NULL)
return -ENOMEM;
dp->synths[dev].sysex = sysex;
}
send = 0;
dest = sysex->buf + sysex->len;
/* copy 6 byte packet to the buffer */
for (i = 0; i < 6; i++) {
if (buf[i] == 0xff) {
send = 1;
break;
}
dest[i] = buf[i];
sysex->len++;
if (sysex->len >= MAX_SYSEX_BUFLEN) {
sysex->len = 0;
sysex->skip = 1;
break;
}
}
if (sysex->len && send) {
if (sysex->skip) {
sysex->skip = 0;
sysex->len = 0;
return -EINVAL; /* skip */
}
/* copy the data to event record and send it */
ev->flags = SNDRV_SEQ_EVENT_LENGTH_VARIABLE;
if (snd_seq_oss_synth_addr(dp, dev, ev))
return -EINVAL;
ev->data.ext.len = sysex->len;
ev->data.ext.ptr = sysex->buf;
sysex->len = 0;
return 0;
}
return -EINVAL; /* skip */
} | false | false | false | false | false | 0 |
infd_tcp_server_get_property(GObject* object,
guint prop_id,
GValue* value,
GParamSpec* pspec)
{
InfdTcpServer* server;
InfdTcpServerPrivate* priv;
server = INFD_TCP_SERVER(object);
priv = INFD_TCP_SERVER_PRIVATE(server);
switch(prop_id)
{
case PROP_IO:
g_value_set_object(value, G_OBJECT(priv->io));
break;
case PROP_STATUS:
g_value_set_enum(value, priv->status);
break;
case PROP_LOCAL_ADDRESS:
g_value_set_static_boxed(value, priv->local_address);
break;
case PROP_LOCAL_PORT:
g_value_set_uint(value, priv->local_port);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
} | false | false | false | false | false | 0 |
rhs (cs_complex_t *x, cs_complex_t *b, cs_long_t m)
{
cs_long_t i ;
for (i = 0 ; i < m ; i++) b [i] = 1 + ((double) i) / m ;
for (i = 0 ; i < m ; i++) x [i] = b [i] ;
} | false | false | false | false | false | 0 |
gms_graphics_restart (void)
{
if (gms_graphics_enabled && gms_graphics_are_displayed ())
{
/*
* If the picture is animated, we'll need to be able to re-get the
* first animation frame so that the picture can be treated as if
* it is a new one. So here, we'll try to re-extract the current
* picture to do this. Calling ms_extract() is safe because we
* don't get here unless graphics are displayed, and graphics aren't
* displayed until there's a valid picture loaded, and ms_showpic
* only loads a picture after it's called ms_extract and set the
* picture id into gms_graphics_picture.
*
* The bitmap and other picture stuff can be ignored because it's
* the precise same stuff as we already have in picture details
* variables. If the ms_extract() fails, we'll carry on regardless,
* which may, or may not, result in the ideal picture display.
*
* One or two non-animated pictures return NULL from ms_extract()
* being re-called, so we'll restrict calls to animations only.
* And just to be safe, we'll also call only if we're already
* holding a bitmap (and we should be; how else could the graphics
* animation flag be set?...).
*/
if (gms_graphics_animated && gms_graphics_bitmap)
{
type8 *bitmap, animated;
type16 width, height, palette[GMS_PALETTE_SIZE];
/* Extract the bitmap into dummy variables. */
bitmap = ms_extract (gms_graphics_picture, &width, &height,
palette, &animated);
}
/* Set the new picture flag, and start graphics. */
gms_graphics_new_picture = TRUE;
gms_graphics_start ();
}
} | false | false | false | false | false | 0 |
gnav_trl_write_trkpt(const waypoint* wpt)
{
gnav_trl_t rec;
le_write32(&rec.time, wpt->creation_time);
le_write_float(&rec.lat, wpt->latitude);
le_write_float(&rec.lon, wpt->longitude);
if (wpt->altitude != unknown_alt) {
write_altitude(&rec.alt, wpt->altitude);
} else {
write_altitude(&rec.alt, 0);
}
gbfwrite(&rec, sizeof(rec), 1, fout);
} | false | false | false | false | false | 0 |
unused_rules(void)
{
register int i;
register action *p;
rules_used = (short *) MALLOC(nrules*sizeof(short));
if (rules_used == 0) no_space();
for (i = 0; i < nrules; ++i)
rules_used[i] = 0;
for (i = 0; i < nstates; ++i)
{
for (p = parser[i]; p; p = p->next)
{
if (p->action_code == REDUCE && p->suppressed == 0)
rules_used[p->number] = 1;
}
}
nunused = 0;
for (i = 3; i < nrules; ++i)
if (!rules_used[i]) ++nunused;
if (nunused){
if (nunused == 1)
fprintf(stderr, "1 rule never reduced\n");
else
fprintf(stderr, "%d rules never reduced\n", nunused);
}
} | false | false | false | false | false | 0 |
ShallowCopy(vtkProp *prop)
{
vtkActor *a = vtkActor::SafeDownCast(prop);
if ( a != NULL )
{
this->SetMapper(a->GetMapper());
this->SetProperty(a->GetProperty());
this->SetBackfaceProperty(a->GetBackfaceProperty());
this->SetTexture(a->GetTexture());
}
// Now do superclass
this->vtkProp3D::ShallowCopy(prop);
} | false | false | false | false | false | 0 |
seat_xdmcp_session_create_display_server (Seat *seat, const gchar *session_type)
{
XAuthority *authority;
gchar *host;
XServerRemote *x_server;
if (strcmp (session_type, "x") != 0)
return NULL;
authority = xdmcp_session_get_authority (SEAT_XDMCP_SESSION (seat)->priv->session);
host = g_inet_address_to_string (xdmcp_session_get_address (SEAT_XDMCP_SESSION (seat)->priv->session));
x_server = x_server_remote_new (host, xdmcp_session_get_display_number (SEAT_XDMCP_SESSION (seat)->priv->session), authority);
g_free (host);
return DISPLAY_SERVER (x_server);
} | false | false | false | false | false | 0 |
StackOverflow() {
HandleScope scope;
Handle<String> key = factory()->stack_overflow_symbol();
Handle<JSObject> boilerplate =
Handle<JSObject>::cast(GetProperty(js_builtins_object(), key));
Handle<Object> exception = Copy(boilerplate);
// TODO(1240995): To avoid having to call JavaScript code to compute
// the message for stack overflow exceptions which is very likely to
// double fault with another stack overflow exception, we use a
// precomputed message.
DoThrow(*exception, NULL);
return Failure::Exception();
} | false | false | false | false | false | 0 |
makeLock( const char* /*lockName*/ )
{
if ( singletonLock == NULL ) {
singletonLock = _CLNEW NoLock();
}
return singletonLock;
} | false | false | false | false | false | 0 |
ioh_irq_disable(struct irq_data *d)
{
struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
struct ioh_gpio *chip = gc->private;
unsigned long flags;
u32 ien;
spin_lock_irqsave(&chip->spinlock, flags);
ien = ioread32(&chip->reg->regs[chip->ch].ien);
ien &= ~(1 << (d->irq - chip->irq_base));
iowrite32(ien, &chip->reg->regs[chip->ch].ien);
spin_unlock_irqrestore(&chip->spinlock, flags);
} | false | false | false | false | false | 0 |
pw_val2scheme( char *val, char **valpwdp, int first_is_default )
{
struct pw_scheme *pwsp;
int namelen, prefixlen;
char *end, buf[ PWD_MAX_NAME_LEN + 1 ];
if ( *val != PWD_HASH_PREFIX_START ||
( end = strchr( val, PWD_HASH_PREFIX_END )) == NULL ||
( namelen = end - val - 1 ) > PWD_MAX_NAME_LEN ) {
if ( !first_is_default ) {
return( NULL );
}
pwsp = pw_name2scheme("CLEAR"); /* default to first scheme */
prefixlen = 0;
} else {
memcpy( buf, val + 1, namelen );
buf[ namelen ] = '\0';
pwsp = pw_name2scheme(buf);
if ( pwsp == NULL ) {
if ( !first_is_default ) {
return( NULL );
}
pwsp = pw_name2scheme("CLEAR");
prefixlen = 0;
} else {
prefixlen = pwsp->pws_len + 2;
}
}
if ( valpwdp != NULL ) {
*valpwdp = val + prefixlen;
}
return( pwsp );
} | false | false | false | false | false | 0 |
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
PgnImporter *_t = static_cast<PgnImporter *>(_o);
switch (_id) {
case 0: _t->databaseRead((*reinterpret_cast< PgnDatabase*(*)>(_a[1]))); break;
case 1: _t->databaseReadStatus((*reinterpret_cast< const QTime(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
case 2: _t->error((*reinterpret_cast< int(*)>(_a[1]))); break;
case 3: _t->abort(); break;
default: ;
}
}
} | false | false | false | false | false | 0 |
dw210x_set_voltage(struct dvb_frontend *fe,
enum fe_sec_voltage voltage)
{
static u8 command_13v[] = {0x00, 0x01};
static u8 command_18v[] = {0x01, 0x01};
static u8 command_off[] = {0x00, 0x00};
struct i2c_msg msg = {
.addr = DW2102_VOLTAGE_CTRL,
.flags = 0,
.buf = command_off,
.len = 2,
};
struct dvb_usb_adapter *udev_adap =
(struct dvb_usb_adapter *)(fe->dvb->priv);
if (voltage == SEC_VOLTAGE_18)
msg.buf = command_18v;
else if (voltage == SEC_VOLTAGE_13)
msg.buf = command_13v;
i2c_transfer(&udev_adap->dev->i2c_adap, &msg, 1);
return 0;
} | false | false | false | false | false | 0 |
main(int argc, char** argv)
{
long maxcount;
if (argc < 2){
usage(argv[0]);
return 1;
}
maxcount = atoi(argv[1]);
cl_log_set_entity("logtest");
cl_log_set_facility(HA_LOG_FACILITY);
cl_log_set_uselogd(TRUE);
if(!cl_log_test_logd()){
return EXIT_FAIL;
}
cl_log_set_logd_channel_source(NULL, NULL);
g_idle_add(send_log_msg, (gpointer)maxcount);
loop = g_main_loop_new(NULL, FALSE);
g_main_run(loop);
return(1);
} | false | false | false | false | true | 1 |
wdtpci_stop(void)
{
unsigned long flags;
/* Turn the card off */
spin_lock_irqsave(&wdtpci_lock, flags);
inb(WDT_DC); /* Disable watchdog */
udelay(8);
wdtpci_ctr_load(2, 0); /* 0 length reset pulses now */
spin_unlock_irqrestore(&wdtpci_lock, flags);
return 0;
} | false | false | false | false | false | 0 |
remove_redundant_iv_tests (struct loop *loop)
{
struct nb_iter_bound *elt;
bool changed = false;
if (!loop->any_upper_bound)
return false;
for (elt = loop->bounds; elt; elt = elt->next)
{
/* Exit is pointless if it won't be taken before loop reaches
upper bound. */
if (elt->is_exit && loop->any_upper_bound
&& loop->nb_iterations_upper_bound.ult (elt->bound))
{
basic_block bb = gimple_bb (elt->stmt);
edge exit_edge = EDGE_SUCC (bb, 0);
struct tree_niter_desc niter;
if (!loop_exit_edge_p (loop, exit_edge))
exit_edge = EDGE_SUCC (bb, 1);
/* Only when we know the actual number of iterations, not
just a bound, we can remove the exit. */
if (!number_of_iterations_exit (loop, exit_edge,
&niter, false, false)
|| !integer_onep (niter.assumptions)
|| !integer_zerop (niter.may_be_zero)
|| !niter.niter
|| TREE_CODE (niter.niter) != INTEGER_CST
|| !loop->nb_iterations_upper_bound.ult
(tree_to_double_int (niter.niter)))
continue;
if (dump_file && (dump_flags & TDF_DETAILS))
{
fprintf (dump_file, "Removed pointless exit: ");
print_gimple_stmt (dump_file, elt->stmt, 0, 0);
}
if (exit_edge->flags & EDGE_TRUE_VALUE)
gimple_cond_make_false (elt->stmt);
else
gimple_cond_make_true (elt->stmt);
update_stmt (elt->stmt);
changed = true;
}
}
return changed;
} | false | false | false | false | false | 0 |
ov7660_set_auto_gain(struct gspca_dev *gspca_dev, __s32 val)
{
int err;
u8 i2c_data;
struct sd *sd = (struct sd *) gspca_dev;
PDEBUG(D_CONF, "Set auto gain control to %d", val);
err = m5602_read_sensor(sd, OV7660_COM8, &i2c_data, 1);
if (err < 0)
return err;
i2c_data = ((i2c_data & 0xfb) | ((val & 0x01) << 2));
return m5602_write_sensor(sd, OV7660_COM8, &i2c_data, 1);
} | false | false | false | false | false | 0 |
any(c, s)
int c;
char *s;
{
while (*s)
if (*s++ == c)
return(1);
return(0);
} | false | false | false | false | false | 0 |
find_unused(unsigned char *map)
{
int i, byte, bit, step;
/* Scan down the combined bitmap to find an open CID */
#if LAM_WANT_IMPI
step = 3;
#else
step = 1;
#endif
for (i = 0; i < map_size * 8; i += step) {
byte = (i / (sizeof(char) * 8));
bit = (1 << (i % (sizeof(char) * 8)));
if ((map[byte] & bit) == 0)
return i;
}
/* We didn't find out. Doh! */
return LAMERROR;
} | false | false | false | false | false | 0 |
git_diff_find_init_options(
git_diff_find_options *opts, unsigned int version)
{
GIT_INIT_STRUCTURE_FROM_TEMPLATE(
opts, version, git_diff_find_options, GIT_DIFF_FIND_OPTIONS_INIT);
return 0;
} | false | false | false | false | false | 0 |
ossl_engine_ctrl_cmd(int argc, VALUE *argv, VALUE self)
{
ENGINE *e;
VALUE cmd, val;
int ret;
GetEngine(self, e);
rb_scan_args(argc, argv, "11", &cmd, &val);
StringValue(cmd);
if (!NIL_P(val)) StringValue(val);
ret = ENGINE_ctrl_cmd_string(e, RSTRING_PTR(cmd),
NIL_P(val) ? NULL : RSTRING_PTR(val), 0);
if (!ret) ossl_raise(eEngineError, NULL);
return self;
} | false | false | false | false | false | 0 |
sinfo_new_vector_to_image( Vector * spectrum )
{
cpl_image * returnIm ;
int i ;
float* podata=NULL;
if ( spectrum == NULL )
{
sinfo_msg_error(" no spectrum given!\n") ;
return NULL ;
}
/* allocate memory */
if ( NULL == (returnIm = cpl_image_new(1, spectrum->n_elements,
CPL_TYPE_FLOAT)) )
{
sinfo_msg_error(" no spectrum given!\n") ;
sinfo_new_destroy_vector(spectrum) ;
return NULL ;
}
podata=cpl_image_get_data_float(returnIm);
for ( i = 0 ; i < spectrum->n_elements ; i++ )
{
podata[i] = spectrum -> data[i] ;
}
sinfo_new_destroy_vector (spectrum) ;
return returnIm ;
} | false | false | false | false | false | 0 |
stacktrace_chop_length(const struct stacktrace *st)
{
size_t i;
/*
* Until they called stacktrace_init(), we don't know whether we're
* running as part of a statically linked program or whether the whole
* program is held in shared libraries, the main() entry point being
* just there to load the initial shared libraray.
*
* This means stack_is_our_text() is unsafe.
*
* NB: This is only really needed when this library is used outside
* of gtk-gnutella. The whole gtk-gnutella code is statically linked,
* and we know it calls stacktrace_init().
* --RAM, 2012-05-11
*/
if (!stacktrace_inited)
return st->len;
for (i = st->len; i != 0; i--) {
if (stack_is_our_text(st->stack[i - 1])) {
break; /* Last addres is our text, keep it */
}
}
return i;
} | false | false | false | false | false | 0 |
setPixmaps()
{
pl1timg.set_image( 80, 70, open_pixmap_from_file("board_N_2"));
pl2timg.set_image( 80, 70, open_pixmap_from_file("board_N_1"));
pl1img.set_image( 80, 70, open_pixmap_from_file("board_N_2"));
pl2img.set_image( 80, 70, open_pixmap_from_file("board_N_1"));
} | false | false | false | false | false | 0 |
on_reposition(int pos_x, int pos_y)
{
menu->raise(); // make menu be on top of other components.
int items_width = menu->get_items_width() + 4;
if( items_width < 90 )
items_width = 90;
int items_height = menu->get_items_height();
if( items_height < 20 )
items_height = 20;
CL_Rect menu_rect(
pos_x, pos_y,
pos_x + items_width + 3,
pos_y + items_height );
if( menu->is_auto_resize() )
{
menu->set_position( menu_rect );
}
std::list<CL_MenuNode*> &children = menu->get_node_list();
if( !children.empty() )
{
int X=2, Y=1;
// calculate a new position for each menu node, and
// update the positions of all submenus.
std::list<CL_MenuNode*>::iterator it;
for( it = children.begin(); it != children.end(); ++it )
{
CL_Component *item = (*it)->get_data();
const CL_Rect &ipos = item->get_position();
(*it)->set_position(
CL_Rect(
X, Y,
menu->is_vertical() ? X + items_width : X + item->get_width(),
Y + ipos.top + item->get_height() + 4 ));
if( menu->is_vertical() )
{
// don't resize elements not placed originally at (0,0) or (1,0)
if( ipos.top == 0 && ipos.left == 0 )
item->set_position(1,0);
}
else
item->set_position(0,0);
(*it)->reposition_submenus();
if( menu->is_vertical() )
Y += ipos.top + item->get_height() + 4;
else
X += ipos.left + item->get_width() + 4;
}
}
if( menu->is_auto_resize() )
{
CL_Rect child_rect = menu->get_children_rect();
if( menu->is_vertical() )
menu->set_width(child_rect.right);
else
menu->set_width(menu->get_parent()->get_width());
menu->set_height(child_rect.bottom+2);
}
} | false | false | false | false | false | 0 |
wrap_mode_checkbutton_toggled (GtkToggleButton *button,
GeditPreferencesDialog *dlg)
{
GtkWrapMode mode;
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->wrap_text_checkbutton)))
{
mode = GTK_WRAP_NONE;
gtk_widget_set_sensitive (dlg->priv->split_checkbutton,
FALSE);
gtk_toggle_button_set_inconsistent (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), TRUE);
}
else
{
gtk_widget_set_sensitive (dlg->priv->split_checkbutton,
TRUE);
gtk_toggle_button_set_inconsistent (
GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton), FALSE);
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dlg->priv->split_checkbutton)))
{
split_button_state = TRUE;
mode = GTK_WRAP_WORD;
}
else
{
split_button_state = FALSE;
mode = GTK_WRAP_CHAR;
}
}
g_settings_set_enum (dlg->priv->editor,
GEDIT_SETTINGS_WRAP_MODE,
mode);
} | false | false | false | false | false | 0 |
fix_input_buffer(buf, len, script)
char_u *buf;
int len;
int script; /* TRUE when reading from a script */
{
int i;
char_u *p = buf;
/*
* Two characters are special: NUL and K_SPECIAL.
* When compiled With the GUI CSI is also special.
* Replace NUL by K_SPECIAL KS_ZERO KE_FILLER
* Replace K_SPECIAL by K_SPECIAL KS_SPECIAL KE_FILLER
* Replace CSI by K_SPECIAL KS_EXTRA KE_CSI
* Don't replace K_SPECIAL when reading a script file.
*/
for (i = len; --i >= 0; ++p)
{
#ifdef FEAT_GUI
/* When the GUI is used any character can come after a CSI, don't
* escape it. */
if (gui.in_use && p[0] == CSI && i >= 2)
{
p += 2;
i -= 2;
}
/* When the GUI is not used CSI needs to be escaped. */
else if (!gui.in_use && p[0] == CSI)
{
mch_memmove(p + 3, p + 1, (size_t)i);
*p++ = K_SPECIAL;
*p++ = KS_EXTRA;
*p = (int)KE_CSI;
len += 2;
}
else
#endif
if (p[0] == NUL || (p[0] == K_SPECIAL && !script
#ifdef FEAT_AUTOCMD
/* timeout may generate K_CURSORHOLD */
&& (i < 2 || p[1] != KS_EXTRA || p[2] != (int)KE_CURSORHOLD)
#endif
#if defined(WIN3264) && !defined(FEAT_GUI)
/* Win32 console passes modifiers */
&& (i < 2 || p[1] != KS_MODIFIER)
#endif
))
{
mch_memmove(p + 3, p + 1, (size_t)i);
p[2] = K_THIRD(p[0]);
p[1] = K_SECOND(p[0]);
p[0] = K_SPECIAL;
p += 2;
len += 2;
}
}
*p = NUL; /* add trailing NUL */
return len;
} | false | false | false | false | false | 0 |
js_script_filename_sweeper(JSHashEntry *he, intN i, void *arg)
{
ScriptFilenameEntry *sfe = (ScriptFilenameEntry *) he;
if (!sfe->mark)
return HT_ENUMERATE_REMOVE;
sfe->mark = JS_FALSE;
return HT_ENUMERATE_NEXT;
} | false | false | false | false | false | 0 |
vacm_parse_setaccess(const char *token, char *param)
{
char *name, *context, *viewname, *viewval;
int imodel, ilevel, iprefix;
int viewnum;
char *st;
struct vacm_accessEntry *ap;
if (_vacm_parse_access_common(token, param, &st, &name,
&context, &imodel, &ilevel, &iprefix)
== PARSE_FAIL) {
return;
}
viewname = strtok_r(NULL, " \t\n", &st);
if (!viewname) {
config_perror("missing viewname parameter");
return;
}
viewval = strtok_r(NULL, " \t\n", &st);
if (!viewval) {
config_perror("missing viewval parameter");
return;
}
if (strlen(viewval) + 1 > sizeof(ap->views[VACM_VIEW_NOTIFY])) {
config_perror("View value too long");
return;
}
viewnum = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, viewname);
if (viewnum < 0 || viewnum >= VACM_MAX_VIEWS) {
config_perror("Illegal view name");
return;
}
ap = vacm_getAccessEntry(name, context, imodel, ilevel);
if (!ap) {
ap = vacm_createAccessEntry(name, context, imodel, ilevel);
DEBUGMSGTL(("vacm:conf:setaccess",
"no existing access found; creating a new one\n"));
} else {
DEBUGMSGTL(("vacm:conf:setaccess",
"existing access found, using it\n"));
}
if (!ap) {
config_perror("failed to create access entry");
return;
}
if (!ap) {
config_perror("failed to create access entry");
return;
}
strcpy(ap->views[viewnum], viewval);
ap->contextMatch = iprefix;
ap->storageType = SNMP_STORAGE_PERMANENT;
ap->status = SNMP_ROW_ACTIVE;
free(ap->reserved);
ap->reserved = NULL;
} | false | true | true | false | false | 1 |
put_variable(const Variable *v, FILE *fp)
{
out_printf(fp, "\t");
print_type(fp, v->vtype, FALSE);
out_printf(fp, "%s%s;", v->id,
v->vtype->postfix?
v->vtype->postfix:"");
if(v->scope == PROTECTED_SCOPE)
out_printf(fp, " /* protected */");
out_printf(fp, "\n");
} | false | false | false | false | false | 0 |
cState_prepare_buffer(VALUE self)
{
FBuffer *buffer = fbuffer_alloc();
GET_STATE(self);
if (state->object_delim) {
fbuffer_clear(state->object_delim);
} else {
state->object_delim = fbuffer_alloc_with_length(16);
}
fbuffer_append_char(state->object_delim, ',');
if (state->object_delim2) {
fbuffer_clear(state->object_delim2);
} else {
state->object_delim2 = fbuffer_alloc_with_length(16);
}
fbuffer_append_char(state->object_delim2, ':');
if (state->space) fbuffer_append(state->object_delim2, state->space, state->space_len);
if (state->array_delim) {
fbuffer_clear(state->array_delim);
} else {
state->array_delim = fbuffer_alloc_with_length(16);
}
fbuffer_append_char(state->array_delim, ',');
if (state->array_nl) fbuffer_append(state->array_delim, state->array_nl, state->array_nl_len);
return buffer;
} | false | false | false | false | false | 0 |
_comedi_dio_get_config(comedi_t *it,unsigned int subdev, unsigned int chan, unsigned int *io)
{
subdevice *s;
comedi_insn insn;
lsampl_t data[2];
int retval;
if(!valid_chan(it,subdev,chan))
return -1;
s=it->subdevices+subdev;
if(s->type!=COMEDI_SUBD_DIO)
return -1;
if(it->has_insnlist_ioctl == 0)
return -1;
memset(&insn,0,sizeof(insn));
insn.insn = INSN_CONFIG;
insn.n = sizeof(data) / sizeof(data[0]);
insn.data = data;
insn.subdev = subdev;
insn.chanspec = CR_PACK(chan,0,0);
memset(data, 0, insn.n * sizeof(*data));
data[0] = INSN_CONFIG_DIO_QUERY;
retval = comedi_do_insn(it,&insn);
if(retval < 0) return retval;
*io = data[1];
return 0;
} | false | false | false | false | false | 0 |
glade_gtk_menu_shell_delete_child (GladeBaseEditor * editor,
GladeWidget * gparent,
GladeWidget * gchild, gpointer data)
{
GObject *item = glade_widget_get_object (gparent);
GtkWidget *submenu = NULL;
GList list = { 0, };
gint n_children = 0;
if (GTK_IS_MENU_ITEM (item) &&
(submenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (item))))
{
GList *l = gtk_container_get_children (GTK_CONTAINER (submenu));
n_children = g_list_length (l);
g_list_free (l);
}
if (submenu && n_children == 1)
list.data = glade_widget_get_parent (gchild);
else
list.data = gchild;
/* Remove widget */
glade_command_delete (&list);
return TRUE;
} | false | false | false | false | false | 0 |
gst_text_renderer_image_to_argb (GstTextRender * render, guchar * pixbuf,
int xpos, int ypos, int stride)
{
int i, j;
guchar *p, *bitp;
int width, height;
width = render->image_width;
height = render->image_height;
for (i = 0; i < height && ypos + i < render->height; i++) {
p = pixbuf + (ypos + i) * stride + xpos * 4;
bitp = render->text_image + i * width * 4;
for (j = 0; j < width && j < render->width; j++) {
p[0] = bitp[CAIRO_ARGB_A];
p[1] = bitp[CAIRO_ARGB_R];
p[2] = bitp[CAIRO_ARGB_G];
p[3] = bitp[CAIRO_ARGB_B];
/* Cairo uses pre-multiplied ARGB, unpremultiply it */
CAIRO_UNPREMULTIPLY (p[0], p[1], p[2], p[3]);
bitp += 4;
p += 4;
}
}
} | false | false | false | false | false | 0 |
gwy_widgets_type_init(void)
{
static guint types_initialized = FALSE;
if (types_initialized)
return;
gwy_draw_type_init();
g_type_class_peek(GWY_TYPE_GRAPH_CURVE_MODEL);
g_type_class_peek(GWY_TYPE_GRAPH_MODEL);
g_type_class_peek(GWY_TYPE_3D_LABEL);
g_type_class_peek(GWY_TYPE_3D_SETUP);
g_type_class_peek(GWY_TYPE_SELECTION_GRAPH_POINT);
g_type_class_peek(GWY_TYPE_SELECTION_GRAPH_AREA);
g_type_class_peek(GWY_TYPE_SELECTION_GRAPH_ZOOM);
g_type_class_peek(GWY_TYPE_SELECTION_GRAPH_LINE);
g_type_class_peek(GWY_TYPE_SELECTION_GRAPH_1DAREA);
types_initialized = 1;
gtk_rc_parse_string
(/* graph window statusbar */
"style \"gwyflatstatusbar\" {\n"
" GtkStatusbar::shadow_type = 0\n"
"}\n"
"widget \"*.gwyflatstatusbar\" style \"gwyflatstatusbar\"\n"
"\n");
} | false | false | false | false | false | 0 |
Allocate(int size_in_bytes, int* wasted_bytes) {
ASSERT(0 < size_in_bytes);
ASSERT(size_in_bytes <= kMaxBlockSize);
ASSERT(IsAligned(size_in_bytes, kPointerSize));
if (needs_rebuild_) RebuildSizeList();
int index = size_in_bytes >> kPointerSizeLog2;
// Check for a perfect fit.
if (free_[index].head_node_ != NULL) {
FreeListNode* node = FreeListNode::FromAddress(free_[index].head_node_);
// If this was the last block of its size, remove the size.
if ((free_[index].head_node_ = node->next()) == NULL) RemoveSize(index);
available_ -= size_in_bytes;
*wasted_bytes = 0;
ASSERT(!FLAG_always_compact); // We only use the freelists with mark-sweep.
return node;
}
// Search the size list for the best fit.
int prev = finger_ < index ? finger_ : kHead;
int cur = FindSize(index, &prev);
ASSERT(index < cur);
if (cur == kEnd) {
// No large enough size in list.
*wasted_bytes = 0;
return Failure::RetryAfterGC(owner_);
}
ASSERT(!FLAG_always_compact); // We only use the freelists with mark-sweep.
int rem = cur - index;
int rem_bytes = rem << kPointerSizeLog2;
FreeListNode* cur_node = FreeListNode::FromAddress(free_[cur].head_node_);
ASSERT(cur_node->Size() == (cur << kPointerSizeLog2));
FreeListNode* rem_node = FreeListNode::FromAddress(free_[cur].head_node_ +
size_in_bytes);
// Distinguish the cases prev < rem < cur and rem <= prev < cur
// to avoid many redundant tests and calls to Insert/RemoveSize.
if (prev < rem) {
// Simple case: insert rem between prev and cur.
finger_ = prev;
free_[prev].next_size_ = rem;
// If this was the last block of size cur, remove the size.
if ((free_[cur].head_node_ = cur_node->next()) == NULL) {
free_[rem].next_size_ = free_[cur].next_size_;
} else {
free_[rem].next_size_ = cur;
}
// Add the remainder block.
rem_node->set_size(rem_bytes);
rem_node->set_next(free_[rem].head_node_);
free_[rem].head_node_ = rem_node->address();
} else {
// If this was the last block of size cur, remove the size.
if ((free_[cur].head_node_ = cur_node->next()) == NULL) {
finger_ = prev;
free_[prev].next_size_ = free_[cur].next_size_;
}
if (rem_bytes < kMinBlockSize) {
// Too-small remainder is wasted.
rem_node->set_size(rem_bytes);
available_ -= size_in_bytes + rem_bytes;
*wasted_bytes = rem_bytes;
return cur_node;
}
// Add the remainder block and, if needed, insert its size.
rem_node->set_size(rem_bytes);
rem_node->set_next(free_[rem].head_node_);
free_[rem].head_node_ = rem_node->address();
if (rem_node->next() == NULL) InsertSize(rem);
}
available_ -= size_in_bytes;
*wasted_bytes = 0;
return cur_node;
} | false | false | false | false | false | 0 |
stop_motions(int id)
{
Motion **s = &allMotions;
Motion *n;
while (*s) {
if ((*s)->moving_id == id) {
/* Should we finish partially-complete animations? */
n = (*s)->next;
OOGLFree(*s);
*s = n;
} else {
s = &(*s)->next;
}
}
} | false | false | false | false | false | 0 |
show_pci_irq(int argc __unused, char **argv __unused,
struct s_hardware *hardware)
{
struct pci_device *pci_device;
bool nopciids = false;
reset_more_printf();
more_printf("%d PCI devices detected\n", hardware->nb_pci_devices);
more_printf("IRQ : product\n");
more_printf("-------------\n");
if (hardware->pci_ids_return_code == -ENOPCIIDS) {
nopciids = true;
}
/* For every detected pci device, compute its submenu */
for_each_pci_func(pci_device, hardware->pci_domain) {
/* Only display valid IRQs */
if ((pci_device->dev_info->irq > 0)
&& (pci_device->dev_info->irq < 255)) {
if (nopciids == false) {
more_printf("%02d : %s %s \n",
pci_device->dev_info->irq,
pci_device->dev_info->vendor_name,
pci_device->dev_info->product_name);
} else {
more_printf("%02d : %04x:%04x [%04x:%04x] \n",
pci_device->dev_info->irq,
pci_device->vendor,
pci_device->product,
pci_device->sub_vendor, pci_device->sub_product);
}
}
}
} | false | false | false | false | false | 0 |
writeSettings() const
{
const ConnectionSettings settings;
bool fRet(writeCommonSetting((settings.commonSettings(m_strConnectionName))));
if (fRet) fRet = writeIPsecSetting((settings.ipsecSettings(m_strConnectionName)));
if (fRet) fRet = writeL2tpSettings((settings.l2tpSettings(m_strConnectionName)));
if (fRet) fRet = writePppSettings((settings.pppSettings(m_strConnectionName)));
return(fRet);
} | false | false | false | false | false | 0 |
get_n_bits_from_tablesize(uint16_t *intable, struct UNSP *read_struct, uint32_t backsize) {
if (!getbit_from_table(intable, read_struct))
return get_n_bits_from_table(&intable[(backsize<<3)+2], 3, read_struct);
if (!getbit_from_table(&intable[1], read_struct))
return 8+get_n_bits_from_table(&intable[(backsize<<3)+0x82], 3, read_struct);
return 0x10+get_n_bits_from_table(&intable[0x102], 8, read_struct);
} | false | false | false | false | false | 0 |
getSelection()
{
std::list< PD_RDFStatement > ret;
GtkTreeModel* model = GTK_TREE_MODEL(m_resultsModel);
list_gtktreeiter_t l = getIterList( GTK_WIDGET(m_resultsView), true );
for( list_gtktreeiter_t::iterator iter = l.begin(); iter != l.end(); ++iter )
{
GtkTreeIter giter = *iter;
gchar* s;
gchar* p;
gchar* o;
gtk_tree_model_get( model, &giter,
C_SUBJ_COLUMN, &s,
C_PRED_COLUMN, &p,
C_OBJ_COLUMN, &o,
-1 );
PD_RDFStatement st( getModel(), PD_URI(s), PD_URI(p), PD_Object(o) );
ret.push_back( st );
xxx_UT_DEBUGMSG(("getSelection() st: %s\n", st.toString().utf8_str()));
}
return ret;
} | false | false | false | false | false | 0 |
mon_text_del(struct mon_bus *mbus)
{
debugfs_remove(mbus->dent_u);
if (mbus->dent_t != NULL)
debugfs_remove(mbus->dent_t);
debugfs_remove(mbus->dent_s);
} | false | false | false | false | false | 0 |
composite(SplashBitmap *src, int xSrc, int ySrc,
int xDest, int yDest, int w, int h,
GBool noClip, GBool nonIsolated) {
SplashPipe pipe;
SplashColor pixel;
Guchar alpha;
Guchar *ap;
int x, y;
if (src->mode != bitmap->mode) {
return splashErrModeMismatch;
}
if (src->alpha) {
pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha,
gTrue, nonIsolated);
for (y = 0; y < h; ++y) {
pipeSetXY(&pipe, xDest, yDest + y);
ap = src->getAlphaPtr() + (ySrc + y) * src->getWidth() + xSrc;
for (x = 0; x < w; ++x) {
alpha = *ap++;
if (noClip || state->clip->test(xDest + x, yDest + y)) {
// this uses shape instead of alpha, which isn't technically
// correct, but works out the same
src->getPixel(xSrc + x, ySrc + y, pixel);
pipe.shape = (SplashCoord)(alpha / 255.0);
pipeRun(&pipe);
updateModX(xDest + x);
updateModY(yDest + y);
} else {
pipeIncX(&pipe);
}
}
}
} else {
pipeInit(&pipe, xDest, yDest, NULL, pixel, state->fillAlpha,
gFalse, nonIsolated);
for (y = 0; y < h; ++y) {
pipeSetXY(&pipe, xDest, yDest + y);
for (x = 0; x < w; ++x) {
if (noClip || state->clip->test(xDest + x, yDest + y)) {
src->getPixel(xSrc + x, ySrc + y, pixel);
pipeRun(&pipe);
updateModX(xDest + x);
updateModY(yDest + y);
} else {
pipeIncX(&pipe);
}
}
}
}
return splashOk;
} | false | false | false | false | false | 0 |
find(string_ty *a_name)
{
static symtab_ty *stp;
if (!stp)
{
stp = symtab_alloc(SIZEOF(table));
for (const request *const *tpp = table; tpp < ENDOF(table); ++tpp)
{
const request *rp = *tpp;
string_ty *key = str_from_c(rp->name());
symtab_assign(stp, key, (void *)rp);
str_free(key);
}
}
const request *rp = (const request *)symtab_query(stp, a_name);
if (!rp)
{
rp = new request_unknown(a_name);
symtab_assign(stp, a_name, (void *)rp);
}
return rp;
} | false | false | false | false | false | 0 |
rsvg_new_filter (void)
{
RsvgFilter *filter;
filter = g_new (RsvgFilter, 1);
_rsvg_node_init (&filter->super, RSVG_NODE_TYPE_FILTER);
filter->filterunits = objectBoundingBox;
filter->primitiveunits = userSpaceOnUse;
filter->x = _rsvg_css_parse_length ("-10%");
filter->y = _rsvg_css_parse_length ("-10%");
filter->width = _rsvg_css_parse_length ("120%");
filter->height = _rsvg_css_parse_length ("120%");
filter->super.set_atts = rsvg_filter_set_args;
return (RsvgNode *) filter;
} | false | false | false | false | false | 0 |
istgt_lu_dvd_shutdown(ISTGT_Ptr istgt, ISTGT_LU_Ptr lu)
{
ISTGT_LU_DVD *spec;
int rc;
int i;
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "istgt_lu_dvd_shutdown\n");
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "LU%d TargetName=%s\n",
lu->num, lu->name);
for (i = 0; i < lu->maxlun; i++) {
if (lu->lun[i].type == ISTGT_LU_LUN_TYPE_NONE) {
ISTGT_TRACELOG(ISTGT_TRACE_DEBUG, "LU%d: LUN%d none\n",
lu->num, i);
continue;
}
if (lu->lun[i].type != ISTGT_LU_LUN_TYPE_REMOVABLE) {
ISTGT_ERRLOG("LU%d: unsupported type\n", lu->num);
return -1;
}
spec = (ISTGT_LU_DVD *) lu->lun[i].spec;
if (!spec->lu->readonly
&& !(spec->mflags & ISTGT_LU_FLAG_MEDIA_READONLY)) {
rc = istgt_lu_dvd_sync(spec, 0, spec->size);
if (rc < 0) {
//ISTGT_ERRLOG("LU%d: lu_dvd_sync() failed\n", lu->num);
/* ignore error */
}
}
rc = istgt_lu_dvd_close(spec);
if (rc < 0) {
//ISTGT_ERRLOG("LU%d: lu_dvd_close() failed\n", lu->num);
/* ignore error */
}
xfree(spec);
lu->lun[i].spec = NULL;
}
return 0;
} | false | false | false | false | false | 0 |
fits_check_double_size(const qfits_header* header) {
int doublesz;
doublesz = qfits_header_getint(header, "DUBL_SZ", -1);
if (sizeof(double) != doublesz) {
fprintf(stderr, "File was written with sizeof(double)=%i, but currently sizeof(double)=%u.\n",
doublesz, (uint)sizeof(double));
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
gp2ap020a00f_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2,
long mask)
{
struct gp2ap020a00f_data *data = iio_priv(indio_dev);
int err = -EINVAL;
mutex_lock(&data->lock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
if (iio_buffer_enabled(indio_dev)) {
err = -EBUSY;
goto error_unlock;
}
err = gp2ap020a00f_read_channel(data, chan, val);
break;
}
error_unlock:
mutex_unlock(&data->lock);
return err < 0 ? err : IIO_VAL_INT;
} | false | false | false | false | false | 0 |
bnx2fc_vport_create(struct fc_vport *vport, bool disabled)
{
struct Scsi_Host *shost = vport_to_shost(vport);
struct fc_lport *n_port = shost_priv(shost);
struct fcoe_port *port = lport_priv(n_port);
struct bnx2fc_interface *interface = port->priv;
struct net_device *netdev = interface->netdev;
struct fc_lport *vn_port;
int rc;
char buf[32];
rc = fcoe_validate_vport_create(vport);
if (rc) {
fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf));
printk(KERN_ERR PFX "Failed to create vport, "
"WWPN (0x%s) already exists\n",
buf);
return rc;
}
if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) {
printk(KERN_ERR PFX "vn ports cannot be created on"
"this interface\n");
return -EIO;
}
rtnl_lock();
mutex_lock(&bnx2fc_dev_lock);
vn_port = bnx2fc_if_create(interface, &vport->dev, 1);
mutex_unlock(&bnx2fc_dev_lock);
rtnl_unlock();
if (!vn_port) {
printk(KERN_ERR PFX "bnx2fc_vport_create (%s) failed\n",
netdev->name);
return -EIO;
}
if (disabled) {
fc_vport_set_state(vport, FC_VPORT_DISABLED);
} else {
vn_port->boot_time = jiffies;
fc_lport_init(vn_port);
fc_fabric_login(vn_port);
fc_vport_setlink(vn_port);
}
return 0;
} | false | false | false | false | false | 0 |
recoil(bool with_ammo)
{
if (!is_gun())
return 0;
it_gun* gun = dynamic_cast<it_gun*>(type);
int ret = gun->recoil;
if (with_ammo && curammo != NULL)
ret += curammo->recoil;
for (int i = 0; i < contents.size(); i++) {
if (contents[i].is_gunmod())
ret += (dynamic_cast<it_gunmod*>(contents[i].type))->recoil;
}
return ret;
} | false | false | false | false | false | 0 |
writeSettings()
{
settings()->saveState(this, DrugsWidget::Constants::S_STATEPREFIX);
fileManager()->saveRecentFiles();
settings()->sync();
} | false | false | false | false | false | 0 |
get_next_send_range(mca_pml_bfo_send_request_t* sendreq,
mca_pml_bfo_send_range_t *range)
{
OPAL_THREAD_LOCK(&sendreq->req_send_range_lock);
opal_list_remove_item(&sendreq->req_send_ranges, (opal_list_item_t *)range);
OMPI_FREE_LIST_RETURN_MT(&mca_pml_bfo.send_ranges, &range->base);
range = get_send_range_nolock(sendreq);
OPAL_THREAD_UNLOCK(&sendreq->req_send_range_lock);
return range;
} | false | false | false | false | false | 0 |
_getv(Object *args)
{
char *name;
if (DXExtractString(args[0], &name))
if (! DXGetVariable(name, &args[1]))
args[1] = NULL;
return OK;
} | false | false | false | false | false | 0 |
handle_cli_database_showkey(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int counter = 0;
switch (cmd) {
case CLI_INIT:
e->command = "database showkey";
e->usage =
"Usage: database showkey <keytree>\n"
" Shows Asterisk database contents, restricted to a given key.\n";
return NULL;
case CLI_GENERATE:
return NULL;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
ast_mutex_lock(&dblock);
if (!ast_strlen_zero(a->argv[2]) && (sqlite3_bind_text(showkey_stmt, 1, a->argv[2], -1, SQLITE_STATIC) != SQLITE_OK)) {
ast_log(LOG_WARNING, "Could bind %s to stmt: %s\n", a->argv[2], sqlite3_errmsg(astdb));
sqlite3_reset(showkey_stmt);
ast_mutex_unlock(&dblock);
return NULL;
}
while (sqlite3_step(showkey_stmt) == SQLITE_ROW) {
const char *key_s, *value_s;
if (!(key_s = (const char *) sqlite3_column_text(showkey_stmt, 0))) {
break;
}
if (!(value_s = (const char *) sqlite3_column_text(showkey_stmt, 1))) {
break;
}
++counter;
ast_cli(a->fd, "%-50s: %-25s\n", key_s, value_s);
}
sqlite3_reset(showkey_stmt);
ast_mutex_unlock(&dblock);
ast_cli(a->fd, "%d results found.\n", counter);
return CLI_SUCCESS;
} | false | false | false | false | false | 0 |
could_be_bitflip(u32 xor_val) {
u32 sh = 0;
if (!xor_val) return 1;
/* Shift left until first bit set. */
while (!(xor_val & 1)) { sh++; xor_val >>= 1; }
/* 1-, 2-, and 4-bit patterns are OK anywhere. */
if (xor_val == 1 || xor_val == 3 || xor_val == 15) return 1;
/* 8-, 16-, and 32-bit patterns are OK only if shift factor is
divisible by 8, since that's the stepover for these ops. */
if (sh & 7) return 0;
if (xor_val == 0xff || xor_val == 0xffff || xor_val == 0xffffffff)
return 1;
return 0;
} | false | false | false | false | false | 0 |
cy_cflags_changed(struct cyclades_port *info, unsigned long arg,
struct cyclades_icount *cprev)
{
struct cyclades_icount cnow;
unsigned long flags;
int ret;
spin_lock_irqsave(&info->card->card_lock, flags);
cnow = info->icount; /* atomic copy */
spin_unlock_irqrestore(&info->card->card_lock, flags);
ret = ((arg & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
((arg & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
((arg & TIOCM_CD) && (cnow.dcd != cprev->dcd)) ||
((arg & TIOCM_CTS) && (cnow.cts != cprev->cts));
*cprev = cnow;
return ret;
} | false | false | false | false | false | 0 |
test2()
{
#define LIMIT 10000000
cout << "Calculating all primes below " << LIMIT << endl;
for ( uint64_t n=0; n < LIMIT/10; n += 56789 ) {
cout << "phi(" << n << ") = "
<< phi<LIMIT>(n) << endl;
}
for ( uint64_t n=1000000; n < LIMIT; n += 1122334/2 ) {
cout << "phi(" << n << ") = "
<< phi<LIMIT>(n) << endl;
}
} | false | false | false | false | false | 0 |
test_slist_sort ()
{
int i, j, mul;
GSList *list = NULL;
for (i = 0; i < N_ELEMS; ++i)
list = g_slist_prepend (list, GINT_TO_POINTER (i));
list = g_slist_sort (list, intcompare);
if (!verify_sort (list, N_ELEMS))
return FAILED ("decreasing list");
g_slist_free (list);
list = NULL;
for (i = 0; i < N_ELEMS; ++i)
list = g_slist_prepend (list, GINT_TO_POINTER (-i));
list = g_slist_sort (list, intcompare);
if (!verify_sort (list, N_ELEMS))
return FAILED ("increasing list");
g_slist_free (list);
list = g_slist_prepend (NULL, GINT_TO_POINTER (0));
for (i = 1; i < N_ELEMS; ++i) {
list = g_slist_prepend (list, GINT_TO_POINTER (-i));
list = g_slist_prepend (list, GINT_TO_POINTER (i));
}
list = g_slist_sort (list, intcompare);
if (!verify_sort (list, 2*N_ELEMS-1))
return FAILED ("alternating list");
g_slist_free (list);
list = NULL;
mul = 1;
for (i = 1; i < N_ELEMS; ++i) {
mul = -mul;
for (j = 0; j < i; ++j)
list = g_slist_prepend (list, GINT_TO_POINTER (mul * j));
}
list = g_slist_sort (list, intcompare);
if (!verify_sort (list, (N_ELEMS*N_ELEMS - N_ELEMS)/2))
return FAILED ("wavering list");
g_slist_free (list);
return OK;
} | false | false | false | false | false | 0 |
is_owned_by_user_and_socket (const char *path)
{
struct stat s;
if (stat (path, &s) == -1)
return FALSE;
if (s.st_uid != geteuid ())
return FALSE;
if ((s.st_mode & S_IFSOCK) != S_IFSOCK)
return FALSE;
return TRUE;
} | false | false | false | false | false | 0 |
deleteRules(void) {
delete fInitialRule;
fInitialRule = NULL;
if (fHistoricRules != NULL) {
while (!fHistoricRules->isEmpty()) {
delete (TimeZoneRule*)(fHistoricRules->orphanElementAt(0));
}
delete fHistoricRules;
fHistoricRules = NULL;
}
if (fFinalRules != NULL) {
while (!fFinalRules->isEmpty()) {
delete (AnnualTimeZoneRule*)(fFinalRules->orphanElementAt(0));
}
delete fFinalRules;
fFinalRules = NULL;
}
} | false | false | false | false | false | 0 |
e_table_field_chooser_dialog_response (GtkDialog *dialog,
gint id)
{
if (id == GTK_RESPONSE_OK)
gtk_widget_destroy (GTK_WIDGET (dialog));
} | false | false | false | false | false | 0 |
get_not_associated_device(void *opaque,
const char *last_seek,
const enum device_type desired_type,
const enum device_type not_desired_type)
{
struct media_devices *md = opaque;
struct media_device_entry *md_ptr = md->md_entry;
int i, skip = 0, found = 0;
char *prev = "", *result = NULL;
/* Step 1: Find a device without seek_type node */
for (i = 0; i < md->md_size; i++, md_ptr++) {
if (last_seek && !strcmp(md_ptr->node, last_seek)) {
found = 1;
continue;
}
if (last_seek && !found)
continue;
if (strcmp(prev, md_ptr->device)) {
if (!skip && result)
break;
prev = md_ptr->device;
skip = 0;
result = NULL;
}
if (md_ptr->type == not_desired_type)
skip = 1;
else if (!skip && !result && md_ptr->type == desired_type)
result = md_ptr->node;
}
if (skip)
result = NULL;
return result;
} | false | false | false | false | false | 0 |
main()
{
FileParser P(Stdin);
IntegerVector v=P.parseIntegerVector();
for(int i=0;i<v.size();i++)
if(v[i]!=0)printf("%i\n",i);
return 0;
} | false | false | false | false | false | 0 |
swaptest()
{
union {unsigned short i; unsigned char c[2];} u;
u.i = 1;
if (u.c[0] == 1)
swap_bytes = True;
else
swap_bytes = False;
} | false | false | false | false | false | 0 |
repeat_message()
{
if (State == ASKMORE)
{
msg_moremsg(TRUE); /* display --more-- message again */
msg_row = Rows - 1;
}
#ifdef FEAT_CON_DIALOG
else if (State == CONFIRM)
{
display_confirm_msg(); /* display ":confirm" message again */
msg_row = Rows - 1;
}
#endif
else if (State == EXTERNCMD)
{
windgoto(msg_row, msg_col); /* put cursor back */
}
else if (State == HITRETURN || State == SETWSIZE)
{
if (msg_row == Rows - 1)
{
/* Avoid drawing the "hit-enter" prompt below the previous one,
* overwrite it. Esp. useful when regaining focus and a
* FocusGained autocmd exists but didn't draw anything. */
msg_didout = FALSE;
msg_col = 0;
msg_clr_eos();
}
hit_return_msg();
msg_row = Rows - 1;
}
} | false | false | false | false | false | 0 |
gst_rtp_session_event_recv_rtp_src (GstPad * pad, GstObject * parent,
GstEvent * event)
{
GstRtpSession *rtpsession;
gboolean forward = TRUE;
gboolean ret = TRUE;
const GstStructure *s;
guint32 ssrc;
guint pt;
rtpsession = GST_RTP_SESSION (parent);
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CUSTOM_UPSTREAM:
s = gst_event_get_structure (event);
if (gst_structure_has_name (s, "GstForceKeyUnit") &&
gst_structure_get_uint (s, "ssrc", &ssrc) &&
gst_structure_get_uint (s, "payload", &pt)) {
gboolean all_headers = FALSE;
gint count = -1;
gst_structure_get_boolean (s, "all-headers", &all_headers);
if (gst_structure_get_int (s, "count", &count) && count < 0)
count += G_MAXINT; /* Make sure count is positive if present */
if (gst_rtp_session_request_remote_key_unit (rtpsession, ssrc, pt,
all_headers, count))
forward = FALSE;
} else if (gst_structure_has_name (s, "GstRTPRetransmissionRequest")) {
GstClockTime running_time;
guint seqnum, delay, deadline, max_delay;
if (!gst_structure_get_clock_time (s, "running-time", &running_time))
running_time = -1;
if (!gst_structure_get_uint (s, "ssrc", &ssrc))
ssrc = -1;
if (!gst_structure_get_uint (s, "seqnum", &seqnum))
seqnum = -1;
if (!gst_structure_get_uint (s, "delay", &delay))
delay = 0;
if (!gst_structure_get_uint (s, "deadline", &deadline))
deadline = 100;
/* remaining time to receive the packet */
max_delay = deadline;
if (max_delay > delay)
max_delay -= delay;
/* estimated RTT */
if (max_delay > 40)
max_delay -= 40;
else
max_delay = 0;
if (rtp_session_request_nack (rtpsession->priv->session, ssrc, seqnum,
max_delay * GST_MSECOND))
forward = FALSE;
}
break;
default:
break;
}
if (forward) {
GstPad *recv_rtp_sink;
GST_RTP_SESSION_LOCK (rtpsession);
if ((recv_rtp_sink = rtpsession->recv_rtp_sink))
gst_object_ref (recv_rtp_sink);
GST_RTP_SESSION_UNLOCK (rtpsession);
if (recv_rtp_sink) {
ret = gst_pad_push_event (recv_rtp_sink, event);
gst_object_unref (recv_rtp_sink);
} else
gst_event_unref (event);
} else {
gst_event_unref (event);
}
return ret;
} | false | false | false | false | false | 0 |
DrawCloseButton(wxDC& dc,
GtkWidget *widget,
int button_state,
wxRect const &in_rect,
int orientation,
GdkRectangle* clipRect)
{
GtkStyle *style_button = get_style_button();
int xthickness = style_button->xthickness;
int ythickness = style_button->ythickness;
wxBitmap bmp;
bmp.SetPixbuf(gtk_widget_render_icon(widget, GTK_STOCK_CLOSE, GTK_ICON_SIZE_SMALL_TOOLBAR, "tab"));
if(bmp.GetWidth() != s_CloseIconSize || bmp.GetHeight() != s_CloseIconSize)
{
wxImage img = bmp.ConvertToImage();
img.Rescale(s_CloseIconSize, s_CloseIconSize);
bmp = img;
}
int button_size = s_CloseIconSize + 2 * xthickness;
wxRect out_rect;
if (orientation == wxLEFT)
out_rect.x = in_rect.x - ythickness;
else
out_rect.x = in_rect.x + in_rect.width - button_size - ythickness;
out_rect.y = in_rect.y + (in_rect.height - button_size) / 2;
out_rect.width = button_size;
out_rect.height = button_size;
#if wxCHECK_VERSION(2, 9, 0)
wxGTKDCImpl *impldc = (wxGTKDCImpl*) dc.GetImpl();
GdkWindow* pWin = impldc->GetGDKWindow();
#else
GdkWindow* pWin = dc.GetGDKWindow();
#endif
if (button_state == wxAUI_BUTTON_STATE_HOVER)
{
gtk_paint_box(style_button, pWin,
GTK_STATE_PRELIGHT, GTK_SHADOW_OUT, clipRect, widget, "button",
out_rect.x, out_rect.y, out_rect.width, out_rect.height);
}
else if (button_state == wxAUI_BUTTON_STATE_PRESSED)
{
gtk_paint_box(style_button, pWin,
GTK_STATE_ACTIVE, GTK_SHADOW_IN, clipRect, widget, "button",
out_rect.x, out_rect.y, out_rect.width, out_rect.height);
}
dc.DrawBitmap(bmp, out_rect.x + xthickness, out_rect.y + ythickness, true);
return out_rect;
} | false | false | false | false | false | 0 |
refmpn_sqrtrem (mp_ptr sp, mp_ptr rp, mp_srcptr np, mp_size_t nsize)
{
mp_ptr tp, dp;
mp_size_t ssize, talloc, tsize, dsize, ret, ilimbs;
unsigned ibit;
long i;
mp_limb_t c;
ASSERT (nsize >= 0);
/* If n==0, then s=0 and r=0. */
if (nsize == 0)
return 0;
ASSERT (np[nsize - 1] != 0);
ASSERT (rp == NULL || MPN_SAME_OR_SEPARATE_P (np, rp, nsize));
ASSERT (rp == NULL || ! MPN_OVERLAP_P (sp, (nsize + 1) / 2, rp, nsize));
ASSERT (! MPN_OVERLAP_P (sp, (nsize + 1) / 2, np, nsize));
/* root */
ssize = (nsize+1)/2;
refmpn_zero (sp, ssize);
/* the remainder so far */
dp = refmpn_memdup_limbs (np, nsize);
dsize = nsize;
/* temporary */
talloc = 2*ssize + 1;
tp = refmpn_malloc_limbs (talloc);
for (i = GMP_NUMB_BITS * ssize - 1; i >= 0; i--)
{
/* t = 2*s*2^i + 2^(2*i), being the amount s^2 will increase by if 2^i
is added to it */
ilimbs = (i+1) / GMP_NUMB_BITS;
ibit = (i+1) % GMP_NUMB_BITS;
refmpn_zero (tp, ilimbs);
c = refmpn_lshift_or_copy (tp+ilimbs, sp, ssize, ibit);
tsize = ilimbs + ssize;
tp[tsize] = c;
tsize += (c != 0);
ilimbs = (2*i) / GMP_NUMB_BITS;
ibit = (2*i) % GMP_NUMB_BITS;
if (ilimbs + 1 > tsize)
{
refmpn_zero_extend (tp, tsize, ilimbs + 1);
tsize = ilimbs + 1;
}
c = refmpn_add_1 (tp+ilimbs, tp+ilimbs, tsize-ilimbs,
CNST_LIMB(1) << ibit);
ASSERT (tsize < talloc);
tp[tsize] = c;
tsize += (c != 0);
if (refmpn_cmp_twosizes (dp, dsize, tp, tsize) >= 0)
{
/* set this bit in s and subtract from the remainder */
refmpn_setbit (sp, i);
ASSERT_NOCARRY (refmpn_sub_n (dp, dp, tp, dsize));
dsize = refmpn_normalize (dp, dsize);
}
}
if (rp == NULL)
{
ret = ! refmpn_zero_p (dp, dsize);
}
else
{
ASSERT (dsize == 0 || dp[dsize-1] != 0);
refmpn_copy (rp, dp, dsize);
ret = dsize;
}
free (dp);
free (tp);
return ret;
} | false | false | false | false | false | 0 |
xmlSchemaCloneWildcardNsConstraints(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaWildcardPtr dest,
xmlSchemaWildcardPtr source)
{
xmlSchemaWildcardNsPtr cur, tmp, last;
if ((source == NULL) || (dest == NULL))
return(-1);
dest->any = source->any;
cur = source->nsSet;
last = NULL;
while (cur != NULL) {
tmp = xmlSchemaNewWildcardNsConstraint(ctxt);
if (tmp == NULL)
return(-1);
tmp->value = cur->value;
if (last == NULL)
dest->nsSet = tmp;
else
last->next = tmp;
last = tmp;
cur = cur->next;
}
if (dest->negNsSet != NULL)
xmlSchemaFreeWildcardNsSet(dest->negNsSet);
if (source->negNsSet != NULL) {
dest->negNsSet = xmlSchemaNewWildcardNsConstraint(ctxt);
if (dest->negNsSet == NULL)
return(-1);
dest->negNsSet->value = source->negNsSet->value;
} else
dest->negNsSet = NULL;
return(0);
} | false | false | false | false | false | 0 |
done()
{
if(!k->isNull())
{
if(!wasBlocking)
{
k->setParent(0);
k->moveToThread(0);
}
dest->setKey(k);
k = 0;
key.change(dest);
dest = 0;
}
else
{
delete k;
k = 0;
delete dest;
dest = 0;
}
if(!wasBlocking)
emit parent->finished();
} | false | false | false | false | false | 0 |
list_fromwire(isccc_region_t *source, isccc_sexpr_t **listp)
{
isccc_sexpr_t *list, *value;
isc_result_t result;
list = NULL;
while (!REGION_EMPTY(*source)) {
value = NULL;
result = value_fromwire(source, &value);
if (result != ISC_R_SUCCESS) {
isccc_sexpr_free(&list);
return (result);
}
if (isccc_sexpr_addtolist(&list, value) == NULL) {
isccc_sexpr_free(&value);
isccc_sexpr_free(&list);
return (result);
}
}
*listp = list;
return (ISC_R_SUCCESS);
} | false | false | false | false | false | 0 |
tp_weak_ref_destroy (TpWeakRef *self)
{
if (self->object != NULL)
g_object_remove_weak_pointer (self->object, &self->object);
if (self->destroy != NULL)
(self->destroy) (self->user_data);
g_slice_free (TpWeakRef, self);
} | false | false | false | false | false | 0 |
CreateRadianceProbesSurfaceIntegrator(const ParamSet ¶mSet) {
string filename = paramSet.FindOneFilename("filename", "probes.out");
return new UseRadianceProbes(filename);
} | false | false | false | false | false | 0 |
up_device_supply_refresh (UpDevice *device)
{
gboolean ret;
GTimeVal timeval;
UpDeviceSupply *supply = UP_DEVICE_SUPPLY (device);
UpDeviceKind type;
if (supply->priv->poll_timer_id > 0) {
g_source_remove (supply->priv->poll_timer_id);
supply->priv->poll_timer_id = 0;
}
g_object_get (device, "type", &type, NULL);
switch (type) {
case UP_DEVICE_KIND_LINE_POWER:
ret = up_device_supply_refresh_line_power (supply);
break;
default:
ret = up_device_supply_refresh_battery (supply);
/* Seems that we don't get change uevents from the
* kernel on some BIOS types */
up_device_supply_setup_poll (device);
break;
}
/* reset time if we got new data */
if (ret) {
g_get_current_time (&timeval);
g_object_set (device, "update-time", (guint64) timeval.tv_sec, NULL);
}
return ret;
} | false | false | false | false | false | 0 |
cmulex_dist_to_vowel(const cst_val *rest)
{
if (rest == 0)
return 0; /* shouldn't get here */
else if (cmu_is_vowel(val_string(val_car(rest))))
return 0;
else
return 1+cmulex_dist_to_vowel(val_cdr(rest));
} | false | false | false | false | false | 0 |
_dbus_connection_do_iteration_unlocked (DBusConnection *connection,
DBusPendingCall *pending,
unsigned int flags,
int timeout_milliseconds)
{
_dbus_verbose ("start\n");
HAVE_LOCK_CHECK (connection);
if (connection->n_outgoing == 0)
flags &= ~DBUS_ITERATION_DO_WRITING;
if (_dbus_connection_acquire_io_path (connection,
(flags & DBUS_ITERATION_BLOCK) ? timeout_milliseconds : 0))
{
HAVE_LOCK_CHECK (connection);
if ( (pending != NULL) && _dbus_pending_call_get_completed_unlocked(pending))
{
_dbus_verbose ("pending call completed while acquiring I/O path");
}
else if ( (pending != NULL) &&
_dbus_connection_peek_for_reply_unlocked (connection,
_dbus_pending_call_get_reply_serial_unlocked (pending)))
{
_dbus_verbose ("pending call completed while acquiring I/O path (reply found in queue)");
}
else
{
_dbus_transport_do_iteration (connection->transport,
flags, timeout_milliseconds);
}
_dbus_connection_release_io_path (connection);
}
HAVE_LOCK_CHECK (connection);
_dbus_verbose ("end\n");
} | false | false | false | false | false | 0 |
bag_new(bag_t **bag)
{
bag_t *b = malloc(sizeof(*b));
if (!b)
return -ENOMEM;
INIT_LIST_HEAD(b);
*bag = b;
return 0;
} | false | false | false | false | false | 0 |
convert_mgmt_class(u8 mgmt_class)
{
/* Alias IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE to 0 */
return mgmt_class == IB_MGMT_CLASS_SUBN_DIRECTED_ROUTE ?
0 : mgmt_class;
} | false | false | false | false | false | 0 |
Profile(FoldingSetNodeID &ID, const AttributeWithIndex *Attr,
unsigned NumAttrs) {
for (unsigned i = 0; i != NumAttrs; ++i)
ID.AddInteger(uint64_t(Attr[i].Attrs) << 32 | unsigned(Attr[i].Index));
}
} | false | false | false | false | false | 0 |
cik_sdma_enable(struct radeon_device *rdev, bool enable)
{
u32 me_cntl, reg_offset;
int i;
if (enable == false) {
cik_sdma_gfx_stop(rdev);
cik_sdma_rlc_stop(rdev);
}
for (i = 0; i < 2; i++) {
if (i == 0)
reg_offset = SDMA0_REGISTER_OFFSET;
else
reg_offset = SDMA1_REGISTER_OFFSET;
me_cntl = RREG32(SDMA0_ME_CNTL + reg_offset);
if (enable)
me_cntl &= ~SDMA_HALT;
else
me_cntl |= SDMA_HALT;
WREG32(SDMA0_ME_CNTL + reg_offset, me_cntl);
}
cik_sdma_ctx_switch_enable(rdev, enable);
} | false | false | false | false | false | 0 |
gfx_pixmap_free_index_data(gfx_pixmap_t *pixmap)
{
if (!pixmap->index_data) {
GFXWARN("Attempt to free pixmap index data twice!\n");
return pixmap;
}
free(pixmap->index_data);
pixmap->index_data = NULL;
return pixmap;
} | false | false | false | false | false | 0 |
rect_list_node_pool_put(list_node_t *node)
{
if (list_node_pool.len < list_node_pool.max)
{
node->next = list_node_pool.node;
list_node_pool.node = node;
list_node_pool.len++;
}
else
free(node);
} | false | false | false | false | false | 0 |
manifest_cache_insert(Manifest *p){
while( p ){
int i;
Manifest *pBaseline = p->pBaseline;
p->pBaseline = 0;
for(i=0; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.apManifest[i]==0 ) break;
}
if( i>=MX_MANIFEST_CACHE ){
int oldest = 0;
int oldestAge = manifestCache.aAge[0];
for(i=1; i<MX_MANIFEST_CACHE; i++){
if( manifestCache.aAge[i]<oldestAge ){
oldest = i;
oldestAge = manifestCache.aAge[i];
}
}
manifest_destroy(manifestCache.apManifest[oldest]);
i = oldest;
}
manifestCache.aAge[i] = ++manifestCache.nxAge;
manifestCache.apManifest[i] = p;
p = pBaseline;
}
} | false | false | false | false | false | 0 |
createRow(Mdb *mdb, MdbTable *table)
{
MdbRow *row;
int ncols;
ncols = max(table->schema->ncols, 1);
if ((row = mprAllocMem(sizeof(MdbRow) + sizeof(EdiField) * ncols, MPR_ALLOC_MANAGER | MPR_ALLOC_ZERO)) == 0) {
return 0;
}
mprSetManager(row, manageRow);
row->table = table;
row->nfields = ncols;
row->rid = mprAddItem(table->rows, row);
return row;
} | false | false | false | false | false | 0 |
_mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length,
GLenum *binaryFormat, GLvoid *binary)
{
struct gl_shader_program *shProg;
GET_CURRENT_CONTEXT(ctx);
shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetProgramBinary");
if (!shProg)
return;
if (!shProg->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glGetProgramBinary(program %u not linked)",
shProg->Name);
return;
}
if (bufSize < 0){
_mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramBinary(bufSize < 0)");
return;
}
/* The ARB_get_program_binary spec says:
*
* "If <length> is NULL, then no length is returned."
*/
if (length != NULL)
*length = 0;
(void) binaryFormat;
(void) binary;
} | false | false | false | false | false | 0 |
read(std::istream& is)
{
if (ruleHeader.mParamCount == 0)
return;
is.read((char*)(&((this+1)->typeInfo)), sizeof(AST::ASTparameters*));
for (iterator it = iterator::begin(this), e = iterator::end(); it != e; ++it) {
switch (it.type().mType) {
case AST::ASTexpression::NumericType:
case AST::ASTexpression::ModType:
is.read((char*)(&*it), it.type().mTuplesize * sizeof(StackType));
break;
case AST::ASTexpression::RuleType:
it->rule = readHeader(is);
break;
default:
assert(false);
break;
}
}
} | false | false | false | false | false | 0 |
register_cmu_us_slt(const char *voxdir)
{
cst_voice *vox;
cst_lexicon *lex;
if (cmu_us_slt_cg)
return cmu_us_slt_cg; /* Already registered */
vox = new_voice();
vox->name = "slt";
/* Sets up language specific parameters in the cmu_us_slt. */
usenglish_init(vox);
/* Things that weren't filled in already. */
flite_feat_set_string(vox->features,"name","cmu_us_slt");
/* Lexicon */
lex = cmu_lex_init();
flite_feat_set(vox->features,"lexicon",lexicon_val(lex));
flite_feat_set(vox->features,"postlex_func",uttfunc_val(lex->postlex));
/* No standard segment durations are needed as its done at the */
/* HMM state level */
flite_feat_set_string(vox->features,"no_segment_duration_model","1");
flite_feat_set_string(vox->features,"no_f0_target_model","1");
/* Waveform synthesis */
flite_feat_set(vox->features,"wave_synth_func",uttfunc_val(&cg_synth));
flite_feat_set(vox->features,"cg_db",cg_db_val(&cmu_us_slt_cg_db));
flite_feat_set_int(vox->features,"sample_rate",cmu_us_slt_cg_db.sample_rate);
cmu_us_slt_cg = vox;
return cmu_us_slt_cg;
} | false | false | false | false | false | 0 |
ConcreteConfigure(const ProcessingConfig& c)
throw(ErrProcessingObj)
{
CopyAsConcreteConfig(mConfig, c);
if (mpDevice)
mpDevice->Unregister(*this);
AudioManager *m;
try {
m = &(AudioManager::Current());
}
catch (Err &e) {
ErrProcessingObj ne("AudioOut::ConcreteConfigure(): No AudioManager found.",this);
ne.Embed(e);
throw(ne);
}
bool res;
try {
res = m->Register(*this);
}
catch (Err &e) {
AddConfigErrorMessage( e.what() );
res = false;
}
if (res == false)
AddConfigErrorMessage( "AudioOut::ConcreteConfigure(): "
"Failed to register in AudioManager.") ;
mInput.SetSize(mConfig.GetFrameSize());
return res;
} | false | false | false | false | false | 0 |
open_path(const char *path, const char* name, const char* subdir)
{
FILE *fp = NULL;
char *pf = strdup(path);
char *p = pf;
while (NULL != p) {
char *p1 = strchr(p, ENVSEP);
if (NULL != p1)
*p1 = '\0';
if (NULL != subdir) {
char *pft = strdup_together(p, subdir);
fp = try_path(pft, name);
free(pft);
} else {
fp = try_path(p, name);
}
if (NULL != fp)
break;
p = (p1) ? p1 + 1 : NULL;
}
free(pf);
return fp;
} | 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.