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
|
---|---|---|---|---|---|---|
parsenumber(struct compiling *c, const char *s)
{
const char *end;
long x;
double dx;
Py_complex compl;
int imflag;
assert(s != NULL);
errno = 0;
end = s + strlen(s) - 1;
imflag = *end == 'j' || *end == 'J';
if (s[0] == '0') {
x = (long) PyOS_strtoul((char *)s, (char **)&end, 0);
if (x < 0 && errno == 0) {
return PyLong_FromString((char *)s,
(char **)0,
0);
}
}
else
x = PyOS_strtol((char *)s, (char **)&end, 0);
if (*end == '\0') {
if (errno != 0)
return PyLong_FromString((char *)s, (char **)0, 0);
return PyLong_FromLong(x);
}
/* XXX Huge floats may silently fail */
if (imflag) {
compl.real = 0.;
compl.imag = PyOS_string_to_double(s, (char **)&end, NULL);
if (compl.imag == -1.0 && PyErr_Occurred())
return NULL;
return PyComplex_FromCComplex(compl);
}
else
{
dx = PyOS_string_to_double(s, NULL, NULL);
if (dx == -1.0 && PyErr_Occurred())
return NULL;
return PyFloat_FromDouble(dx);
}
} | false | false | false | false | false | 0 |
SkipNextWord()
{
while (isspace(*ptr)) ++ptr;
while (!isspace(*ptr)) ++ptr;
while (isspace(*ptr)) ++ptr;
return true;
} | false | false | false | false | false | 0 |
gwy_debug_objects_creation_detailed(GObject *object,
const gchar *details)
{
DebugObjectInfo *info;
if (!G_UNLIKELY(debug_objects_enabled))
return;
if (!id) {
g_assert(!debug_objects_timer && !debug_objects);
debug_objects_timer = g_timer_new();
}
info = g_slice_new(DebugObjectInfo);
info->id = ++id;
info->type = G_TYPE_FROM_INSTANCE(object);
info->address = object;
info->details = details;
info->create_time = g_timer_elapsed(debug_objects_timer, NULL);
info->destroy_time = -1;
g_object_weak_ref(info->address, &debug_objects_set_time,
&info->destroy_time);
debug_objects = g_list_prepend(debug_objects, info);
gwy_debug("Added watch for %s %p",
g_type_name(info->type), info->address);
} | false | false | false | false | false | 0 |
not(uint32_t args) {
ONE_ARG(arg);
if (arg == C_FALSE) return C_TRUE;
else return C_FALSE;
} | false | false | false | false | false | 0 |
setWindowSize(size_t newSize)
{
delete[] m_prevMag;
m_windowSize = newSize;
m_prevMag = new float[m_windowSize/2 + 1];
reset();
} | false | false | false | false | false | 0 |
get_result (char *buf, RcvMsg * rmsg)
{
enum ck_msg_type type;
CheckMsg msg;
int n;
n = upack (buf, &msg, &type);
if (n == -1)
eprintf ("Error in call to upack", __FILE__, __LINE__ - 2);
if (type == CK_MSG_CTX) {
CtxMsg *cmsg = (CtxMsg *) & msg;
rcvmsg_update_ctx (rmsg, cmsg->ctx);
} else if (type == CK_MSG_LOC) {
LocMsg *lmsg = (LocMsg *) & msg;
if (rmsg->failctx == CK_CTX_INVALID) {
rcvmsg_update_loc (rmsg, lmsg->file, lmsg->line);
}
free (lmsg->file);
} else if (type == CK_MSG_FAIL) {
FailMsg *fmsg = (FailMsg *) & msg;
if (rmsg->msg == NULL) {
rmsg->msg = emalloc (strlen (fmsg->msg) + 1);
strcpy (rmsg->msg, fmsg->msg);
rmsg->failctx = rmsg->lastctx;
} else {
/* Skip subsequent failure messages, only happens for CK_NOFORK */
}
free (fmsg->msg);
} else
check_type (type, __FILE__, __LINE__);
return n;
} | false | true | false | false | false | 1 |
SITEsetlist(patlist, subbed, poison, poisonEntry)
char **patlist;
char *subbed;
char *poison;
BOOL *poisonEntry;
{
register char *pat;
register char *p;
register char *u;
register char subvalue;
register char poisonvalue;
register NEWSGROUP *ngp;
register int i;
while ((pat = *patlist++) != NULL) {
subvalue = *pat != SUB_NEGATE && *pat != SUB_POISON;
poisonvalue = *pat == SUB_POISON;
if (!subvalue)
pat++;
if (!*pat)
continue;
/* See if pattern is a simple newsgroup name. If so, set the
* right subbed element for that one group (if found); if not,
* pattern-match against all the groups. */
for (p = pat; *p; p++)
if (*p == '?' || *p == '*' || *p == '[')
break;
if (*p == '\0') {
/* Simple string; look it up, set it. */
if ((ngp = NGfind(pat)) != NULL) {
subbed[ngp - Groups] = subvalue;
poison[ngp - Groups] = poisonvalue;
}
}
else
for (p = subbed, u = poison, ngp = Groups, i = nGroups;
--i >= 0; ngp++, p++, u++)
if (wildmat(ngp->Name, pat)) {
*p = subvalue;
*u = poisonvalue;
}
}
} | false | false | false | false | false | 0 |
recv(int sock, struct packet_header *p, struct inet_address *from)
{
int s;
int r;
UDPpacket u;
s = sock - 1;
if (s < 0 || s >= MAX_UDP_SOCKETS || !udp_socket_list[s])
return 0;
u.channel = -1;
u.data = (Uint8 *)p;
u.maxlen = p->size;
r = SDLNet_UDP_Recv(udp_socket_list[s], &u);
if (r == -1)
{
MSG("Couldn't receive on socket.\n");
return 0;
}
if (!r)
return 0;
if (u.len != p->size + sizeof(struct packet_header))
return 0;
from->host = u.address.host;
from->port = u.address.port;
return u.len;
} | false | false | false | false | false | 0 |
historyRecall(history_ *r, double *data, int length)
{
ReturnErrIf(r == NULL);
ReturnErrIf(data == NULL);
ReturnErrIf(length != r->length);
memcpy(data, r->data, length*sizeof(double));
return 0;
} | false | false | false | false | false | 0 |
warn_if_date_trouble (WorkbookControl *wbc, GnmCellRegion *cr)
{
Workbook *wb = wb_control_get_workbook (wbc);
const GODateConventions *wb_date_conv = workbook_date_conv (wb);
if (cr->date_conv == NULL)
return;
if (go_date_conv_equal (cr->date_conv, wb_date_conv))
return;
/* We would like to show a warning, but it seems we cannot via a context. */
{
GError *err;
err = g_error_new (go_error_invalid(), 0,
_("Copying between files with different date conventions.\n"
"It is possible that some dates could be copied\n"
"incorrectly."));
go_cmd_context_error (GO_CMD_CONTEXT (wbc), err);
g_error_free (err);
}
} | false | false | false | false | false | 0 |
copy(int32_t start, int32_t limit, int32_t dest) {
if (limit <= start) {
return; // Nothing to do; avoid bogus malloc call
}
UChar* text = (UChar*) uprv_malloc( sizeof(UChar) * (limit - start) );
// Check to make sure text is not null.
if (text != NULL) {
extractBetween(start, limit, text, 0);
insert(dest, text, 0, limit - start);
uprv_free(text);
}
} | false | false | false | false | false | 0 |
gsql_variable_class_init (GSQLVariableClass *klass)
{
GSQL_TRACE_FUNC;
GObjectClass *obj_class;
g_return_if_fail (klass != NULL);
obj_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
variable_signals [SIG_ON_FREE] =
g_signal_new ("on_free",
G_TYPE_FROM_CLASS (obj_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GSQLVariableClass,
on_free),
NULL, // GSignalAccumulator
NULL, g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
obj_class->dispose = gsql_variable_dispose;
obj_class->finalize = gsql_variable_finalize;
} | false | false | false | false | false | 0 |
isABalanced(scapegoat *goat, btree* run, btree* parent, size_t *size){
size_t a = 0, b = 0;
a = *size;
//btree_info(run, NULL, NULL, NULL, NULL, &a, NULL, NULL);
//determine which child run->data is (avoid re-evaluating the lhs)
btree_info(btree_sibling(parent, run), NULL, NULL, NULL, NULL, &b, NULL, NULL);
//wparent += w + 1;
*size = a+1+b;//goes up by at least 1
return (a <= (goat->a*(a+1+b))) && (b <= (goat->a*(a+1+b)));
} | false | false | false | false | false | 0 |
BraceSmartIndentEnabled()const
{
return Manager::Get()->GetConfigManager(_T("editor"))->ReadBool(_T("/brace_smart_indent"), true);
} | false | false | false | false | false | 0 |
add_job_report(u_long32 jobid, u_long32 jataskid, const char *petaskid, lListElem *jep)
{
lListElem *jr, *jatep = NULL;
DENTER(TOP_LAYER, "add_job_report");
if (jr_list == NULL)
jr_list = lCreateList("job report list", JR_Type);
if (jr_list == NULL || (jr=lCreateElem(JR_Type)) == NULL) {
ERROR((SGE_EVENT, MSG_JOB_TYPEMALLOC));
DRETURN(NULL);
}
lSetUlong(jr, JR_job_number, jobid);
lSetUlong(jr, JR_ja_task_number, jataskid);
if (petaskid != NULL) {
lSetString(jr, JR_pe_task_id_str, petaskid);
}
lAppendElem(jr_list, jr);
DPRINTF(("adding job report for "sge_U32CFormat"."sge_U32CFormat"\n", sge_u32c(jobid), sge_u32c(jataskid)));
if (jep != NULL) {
jatep = job_search_task(jep, NULL, jataskid);
if (jatep != NULL) {
lListElem *petep = NULL;
if (petaskid != NULL) {
petep = ja_task_search_pe_task(jatep, petaskid);
}
job_report_init_from_job(jr, jep, jatep, petep);
}
}
DRETURN(jr);
} | false | false | false | false | false | 0 |
dfb_layer_context_set_src_colorkey( CoreLayerContext *context,
u8 r, u8 g, u8 b, int index )
{
DFBResult ret;
CoreLayerRegionConfig config;
D_ASSERT( context != NULL );
D_DEBUG_AT( Core_Layers, "%s (%02x %02x %02x - %d)\n", __FUNCTION__, r, g, b, index );
/* Lock the context. */
if (dfb_layer_context_lock( context ))
return DFB_FUSION;
/* Take the current configuration. */
config = context->primary.config;
/* Change the color key. */
config.src_key.r = r;
config.src_key.g = g;
config.src_key.b = b;
if (index >= 0)
config.src_key.index = index & 0xff;
/* Try to set the new configuration. */
ret = update_primary_region_config( context, &config, CLRCF_SRCKEY );
/* Unlock the context. */
dfb_layer_context_unlock( context );
return ret;
} | false | false | false | false | false | 0 |
makeconstdata(nc_type nctype)
{
Constant con = nullconstant;
consttype = nctype;
con.nctype = nctype;
con.lineno = lineno;
switch (nctype) {
case NC_CHAR: con.value.charv = char_val; break;
case NC_BYTE: con.value.int8v = byte_val; break;
case NC_SHORT: con.value.int16v = int16_val; break;
case NC_INT: con.value.int32v = int32_val; break;
case NC_FLOAT:
con.value.floatv = float_val;
break;
case NC_DOUBLE:
con.value.doublev = double_val;
break;
case NC_STRING: { /* convert to a set of chars*/
int len;
len = strlen(lextext);
con.value.stringv.len = len;
con.value.stringv.stringv = nulldup(lextext);
}
break;
/* Allow these constants even in netcdf-3 */
case NC_UBYTE: con.value.uint8v = ubyte_val; break;
case NC_USHORT: con.value.uint16v = uint16_val; break;
case NC_UINT: con.value.uint32v = uint32_val; break;
case NC_INT64: con.value.int64v = int64_val; break;
case NC_UINT64: con.value.uint64v = uint64_val; break;
#ifdef USE_NETCDF4
case NC_OPAQUE: {
char* s;
int len,padlen;
len = strlen(lextext);
padlen = len;
if(padlen < 16) padlen = 16;
if((padlen % 2) == 1) padlen++;
s = (char*)emalloc(padlen+1);
memset((void*)s,'0',padlen);
s[padlen]='\0';
strncpy(s,lextext,len);
con.value.opaquev.stringv = s;
con.value.opaquev.len = padlen;
} break;
#endif
case NC_FILLVALUE:
break; /* no associated value*/
default:
yyerror("Data constant: unexpected NC type: %s",
nctypename(nctype));
con.value.stringv.stringv = NULL;
con.value.stringv.len = 0;
}
return con;
} | false | true | false | false | false | 1 |
bfa_ioc_is_disabled(struct bfa_ioc_s *ioc)
{
return bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabling) ||
bfa_fsm_cmp_state(ioc, bfa_ioc_sm_disabled);
} | false | false | false | false | false | 0 |
fs_rtp_bin_error_downgrade_register (void)
{
static gsize initialization_value = 0;
if (g_once_init_enter (&initialization_value))
{
gsize setup_value = gst_element_register (NULL, "fsrtpbinerrordowngrade",
GST_RANK_MARGINAL, FS_TYPE_RTP_BIN_ERROR_DOWNGRADE);
g_once_init_leave (&initialization_value, setup_value);
}
} | false | false | false | false | false | 0 |
stacktrace_memory_used(void)
{
size_t res;
res = NULL == symbols ? 0 : symbols_memory_size(symbols);
if (stack_atoms != NULL) {
res += hash_table_arena_memory(stack_atoms);
}
return res;
} | false | false | false | false | false | 0 |
binlog_close_connection(handlerton *hton, THD *thd)
{
binlog_cache_mngr *const cache_mngr=
(binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton);
DBUG_ASSERT(cache_mngr->trx_cache.empty() && cache_mngr->stmt_cache.empty());
thd_set_ha_data(thd, binlog_hton, NULL);
cache_mngr->~binlog_cache_mngr();
my_free(cache_mngr);
return 0;
} | false | false | false | false | false | 0 |
buildAll_LocalAnimatedMatrices()
{
for (u32 i=0; i<AllJoints.size(); ++i)
{
SJoint *joint = AllJoints[i];
//Could be faster:
if (joint->UseAnimationFrom &&
(joint->UseAnimationFrom->PositionKeys.size() ||
joint->UseAnimationFrom->ScaleKeys.size() ||
joint->UseAnimationFrom->RotationKeys.size() ))
{
joint->LocalAnimatedMatrix=joint->Animatedrotation.getMatrix();
// --- joint->LocalAnimatedMatrix *= joint->Animatedrotation.getMatrix() ---
f32 *m1 = joint->LocalAnimatedMatrix.pointer();
core::vector3df &Pos = joint->Animatedposition;
m1[0] += Pos.X*m1[3];
m1[1] += Pos.Y*m1[3];
m1[2] += Pos.Z*m1[3];
m1[4] += Pos.X*m1[7];
m1[5] += Pos.Y*m1[7];
m1[6] += Pos.Z*m1[7];
m1[8] += Pos.X*m1[11];
m1[9] += Pos.Y*m1[11];
m1[10] += Pos.Z*m1[11];
m1[12] += Pos.X*m1[15];
m1[13] += Pos.Y*m1[15];
m1[14] += Pos.Z*m1[15];
// -----------------------------------
joint->GlobalSkinningSpace=false;
if (joint->ScaleKeys.size())
{
/*
core::matrix4 scaleMatrix;
scaleMatrix.setScale(joint->Animatedscale);
joint->LocalAnimatedMatrix *= scaleMatrix;
*/
// -------- joint->LocalAnimatedMatrix *= scaleMatrix -----------------
core::matrix4& mat = joint->LocalAnimatedMatrix;
mat[0] *= joint->Animatedscale.X;
mat[1] *= joint->Animatedscale.X;
mat[2] *= joint->Animatedscale.X;
mat[3] *= joint->Animatedscale.X;
mat[4] *= joint->Animatedscale.Y;
mat[5] *= joint->Animatedscale.Y;
mat[6] *= joint->Animatedscale.Y;
mat[7] *= joint->Animatedscale.Y;
mat[8] *= joint->Animatedscale.Z;
mat[9] *= joint->Animatedscale.Z;
mat[10] *= joint->Animatedscale.Z;
mat[11] *= joint->Animatedscale.Z;
// -----------------------------------
}
}
else
{
joint->LocalAnimatedMatrix=joint->LocalMatrix;
}
}
} | false | false | false | false | false | 0 |
read_data_mode(VMG_ vm_val_t *retval)
{
char buf[32];
CVmObjString *str_obj;
vm_obj_id_t str_id;
osfildef *fp = get_ext()->fp;
/* read the type flag */
if (osfrb(fp, buf, 1))
{
/* end of file - return nil */
retval->set_nil();
return;
}
/* see what we have */
switch((vm_datatype_t)buf[0])
{
case VMOBJFILE_TAG_INT:
/* read the INT4 value */
if (osfrb(fp, buf, 4))
goto io_error;
/* set the integer value from the buffer */
retval->set_int(osrp4(buf));
break;
case VMOBJFILE_TAG_ENUM:
/* read the UINT4 value */
if (osfrb(fp, buf, 4))
goto io_error;
/* set the 'enum' value */
retval->set_enum(t3rp4u(buf));
break;
case VMOBJFILE_TAG_STRING:
/*
* read the string's length - note that this length is two
* higher than the actual length of the string, because it
* includes the length prefix bytes
*/
if (osfrb(fp, buf, 2))
goto io_error;
/*
* allocate a new string of the required size (deducting two
* bytes from the indicated size, since the string allocator
* only wants to know about the bytes of the string we want to
* store, not the length prefix part)
*/
str_id = CVmObjString::create(vmg_ FALSE, osrp2(buf) - 2);
str_obj = (CVmObjString *)vm_objp(vmg_ str_id);
/* read the bytes of the string into the object's buffer */
if (osfrb(fp, str_obj->cons_get_buf(), osrp2(buf) - 2))
goto io_error;
/* success - set the string return value, and we're done */
retval->set_obj(str_id);
break;
case VMOBJFILE_TAG_TRUE:
/* it's a simple 'true' value */
retval->set_true();
break;
case VMOBJFILE_TAG_BIGNUM:
/* read the BigNumber value and return a new BigNumber object */
if (CVmObjBigNum::read_from_data_file(vmg_ retval, fp))
goto io_error;
break;
case VMOBJFILE_TAG_BYTEARRAY:
/* read the ByteArray value and return a new ByteArray object */
if (CVmObjByteArray::read_from_data_file(vmg_ retval, fp))
goto io_error;
break;
default:
/* invalid data - throw an error */
G_interpreter->throw_new_class(vmg_ G_predef->file_io_exc,
0, "file I/O error");
}
/* done */
return;
io_error:
/*
* we'll come here if we read the type tag correctly but encounter
* an I/O error reading the value - this indicates a corrupted input
* stream, so throw an I/O error
*/
G_interpreter->throw_new_class(vmg_ G_predef->file_io_exc,
0, "file I/O error");
} | false | false | false | false | false | 0 |
scm_s_define_internal(enum ScmObjType permitted,
ScmObj var, ScmObj exp, ScmObj env)
{
ScmObj val;
DECLARE_INTERNAL_FUNCTION("define");
#if SCM_USE_HYGIENIC_MACRO
SCM_ASSERT(SYMBOLP(var) || SYMBOLP(SCM_FARSYMBOL_SYM(var)));
#else
SCM_ASSERT(SYMBOLP(var));
#endif
var = SCM_UNWRAP_KEYWORD(var);
val = EVAL(exp, env);
CHECK_VALID_BINDEE(permitted, val);
SCM_SYMBOL_SET_VCELL(var, val);
} | false | false | false | false | false | 0 |
test_truncate ()
{
GString *s = g_string_new ("0123456789");
g_string_truncate (s, 3);
if (strlen (s->str) != 3)
return FAILED ("size of string should have been 3, instead it is [%s]\n", s->str);
g_string_free (s, TRUE);
s = g_string_new ("a");
s = g_string_truncate (s, 10);
if (strlen (s->str) != 1)
return FAILED ("The size is not 1");
g_string_truncate (s, (gsize)-1);
if (strlen (s->str) != 1)
return FAILED ("The size is not 1");
g_string_truncate (s, 0);
if (strlen (s->str) != 0)
return FAILED ("The size is not 0");
g_string_free (s, TRUE);
return NULL;
} | false | false | false | false | false | 0 |
snd_usb_add_audio_stream(struct snd_usb_audio *chip,
int stream,
struct audioformat *fp)
{
struct snd_usb_stream *as;
struct snd_usb_substream *subs;
struct snd_pcm *pcm;
int err;
list_for_each_entry(as, &chip->pcm_list, list) {
if (as->fmt_type != fp->fmt_type)
continue;
subs = &as->substream[stream];
if (subs->ep_num == fp->endpoint) {
list_add_tail(&fp->list, &subs->fmt_list);
subs->num_formats++;
subs->formats |= fp->formats;
return 0;
}
}
/* look for an empty stream */
list_for_each_entry(as, &chip->pcm_list, list) {
if (as->fmt_type != fp->fmt_type)
continue;
subs = &as->substream[stream];
if (subs->ep_num)
continue;
err = snd_pcm_new_stream(as->pcm, stream, 1);
if (err < 0)
return err;
snd_usb_init_substream(as, stream, fp);
return add_chmap(as->pcm, stream, subs);
}
/* create a new pcm */
as = kzalloc(sizeof(*as), GFP_KERNEL);
if (!as)
return -ENOMEM;
as->pcm_index = chip->pcm_devs;
as->chip = chip;
as->fmt_type = fp->fmt_type;
err = snd_pcm_new(chip->card, "USB Audio", chip->pcm_devs,
stream == SNDRV_PCM_STREAM_PLAYBACK ? 1 : 0,
stream == SNDRV_PCM_STREAM_PLAYBACK ? 0 : 1,
&pcm);
if (err < 0) {
kfree(as);
return err;
}
as->pcm = pcm;
pcm->private_data = as;
pcm->private_free = snd_usb_audio_pcm_free;
pcm->info_flags = 0;
if (chip->pcm_devs > 0)
sprintf(pcm->name, "USB Audio #%d", chip->pcm_devs);
else
strcpy(pcm->name, "USB Audio");
snd_usb_init_substream(as, stream, fp);
/*
* Keep using head insertion for M-Audio Audiophile USB (tm) which has a
* fix to swap capture stream order in conf/cards/USB-audio.conf
*/
if (chip->usb_id == USB_ID(0x0763, 0x2003))
list_add(&as->list, &chip->pcm_list);
else
list_add_tail(&as->list, &chip->pcm_list);
chip->pcm_devs++;
snd_usb_proc_pcm_format_add(as);
return add_chmap(pcm, stream, &as->substream[stream]);
} | false | true | false | false | false | 1 |
print_cb(Fl_Widget *w, void *data)
{
Fl_Printer printer;
Fl_Window *win = Fl::first_window();
if(!win) return;
if( printer.start_job(1) ) return;
if( printer.start_page() ) return;
printer.scale(0.5,0.5);
printer.print_widget( win );
printer.end_page();
printer.end_job();
} | false | false | false | false | false | 0 |
gtk_source_view_get_show_right_margin (GtkSourceView *view)
{
g_return_val_if_fail (GTK_SOURCE_IS_VIEW (view), FALSE);
return (view->priv->show_right_margin != FALSE);
} | false | false | false | false | false | 0 |
set_frame(unsigned int frame)
{
if(frame < 0)
impl->current_frame = 0;
else if(frame >= impl->frames.size())
impl->current_frame = impl->frames.size() - 1;
else
impl->current_frame = frame;
} | false | false | false | false | false | 0 |
slotOnItem( Q3ListBoxItem *item )
{
if ( item && m_bChangeCursorOverItem && m_bUseSingle )
viewport()->setCursor(Qt::PointingHandCursor);
if ( item && (m_autoSelectDelay > -1) && m_bUseSingle ) {
m_pAutoSelect->setSingleShot( true );
m_pAutoSelect->start( m_autoSelectDelay );
m_pCurrentItem = item;
}
} | false | false | false | false | false | 0 |
check_vendor_extension(u64 paddr,
struct set_error_type_with_address *v5param)
{
int offset = v5param->vendor_extension;
struct vendor_error_type_extension *v;
u32 sbdf;
if (!offset)
return;
v = acpi_os_map_iomem(paddr + offset, sizeof(*v));
if (!v)
return;
sbdf = v->pcie_sbdf;
sprintf(vendor_dev, "%x:%x:%x.%x vendor_id=%x device_id=%x rev_id=%x\n",
sbdf >> 24, (sbdf >> 16) & 0xff,
(sbdf >> 11) & 0x1f, (sbdf >> 8) & 0x7,
v->vendor_id, v->device_id, v->rev_id);
acpi_os_unmap_iomem(v, sizeof(*v));
} | false | true | false | false | false | 1 |
get_opname(Oid opno)
{
HeapTuple tp;
tp = SearchSysCache(OPEROID,
ObjectIdGetDatum(opno),
0, 0, 0);
if (HeapTupleIsValid(tp))
{
Form_pg_operator optup = (Form_pg_operator) GETSTRUCT(tp);
char *result;
result = pstrdup(NameStr(optup->oprname));
ReleaseSysCache(tp);
return result;
}
else
return NULL;
} | false | false | false | false | false | 0 |
clearAllSelections_impl(void)
{
// flag used so we can track if we did anything.
bool modified = false;
for (uint i = 0; i < getRowCount(); ++i)
{
for (uint j = 0; j < getColumnCount(); ++j)
{
ListboxItem* item = d_grid[i][j];
// if slot has an item, and item is selected
if ((item != 0) && item->isSelected())
{
// clear selection state and set modified flag
item->setSelected(false);
modified = true;
}
}
}
// signal whether or not we did anything.
return modified;
} | false | false | false | false | false | 0 |
up_input_finalize (GObject *object)
{
UpInput *input;
g_return_if_fail (object != NULL);
g_return_if_fail (UP_IS_INPUT (object));
input = UP_INPUT (object);
g_return_if_fail (input->priv != NULL);
if (input->priv->daemon != NULL)
g_object_unref (input->priv->daemon);
if (input->priv->eventfp >= 0)
close (input->priv->eventfp);
if (input->priv->channel) {
g_io_channel_shutdown (input->priv->channel, FALSE, NULL);
g_io_channel_unref (input->priv->channel);
}
G_OBJECT_CLASS (up_input_parent_class)->finalize (object);
} | false | false | false | false | false | 0 |
lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
uint32_t mirrors, uint32_t stripes, uint32_t stripe_size,
uint32_t region_size, uint32_t log_count,
struct dm_list *pvs, alloc_policy_t alloc, uint32_t flags)
{
if (!mirrors && !log_count) {
log_error("No conversion is requested");
return 0;
}
if (vg_is_clustered(lv->vg)) {
/* FIXME: review check of lv_is_active_remotely */
/* FIXME: move this test out of this function */
/* Skip test for pvmove mirrors, it can use local mirror */
if (!(lv->status & (PVMOVE | LOCKED)) &&
!_cluster_mirror_is_available(lv)) {
log_error("Shared cluster mirrors are not available.");
return 0;
}
/*
* No mirrored logs for cluster mirrors until
* log daemon is multi-threaded.
*/
if (log_count > 1) {
log_error("Log type, \"mirrored\", is unavailable to cluster mirrors");
return 0;
}
}
/* For corelog mirror, activation code depends on
* the global mirror_in_sync status. As we are adding
* a new mirror, it should be set as 'out-of-sync'
* so that the sync starts. */
/* However, MIRROR_SKIP_INIT_SYNC even overrides it. */
if (flags & MIRROR_SKIP_INIT_SYNC)
init_mirror_in_sync(1);
else if (!log_count)
init_mirror_in_sync(0);
if (flags & MIRROR_BY_SEG) {
if (log_count) {
log_error("Persistent log is not supported on "
"segment-by-segment mirroring");
return 0;
}
if (stripes > 1) {
log_error("Striped-mirroring is not supported on "
"segment-by-segment mirroring");
return 0;
}
return add_mirrors_to_segments(cmd, lv, mirrors,
region_size, pvs, alloc);
} else if (flags & MIRROR_BY_LV) {
if (!mirrors)
return add_mirror_log(cmd, lv, log_count,
region_size, pvs, alloc);
return add_mirror_images(cmd, lv, mirrors,
stripes, stripe_size, region_size,
pvs, alloc, log_count);
}
log_error("Unsupported mirror conversion type");
return 0;
} | false | false | false | false | false | 0 |
load_proto(struct iptables_command_state *cs)
{
if (!should_load_proto(cs))
return NULL;
return find_proto(cs->protocol, XTF_TRY_LOAD,
cs->options & OPT_NUMERIC, &cs->matches);
} | false | false | false | false | false | 0 |
isns_scn_deregister(char *name)
{
int err;
uint16_t flags, length = 0;
char buf[2048];
struct isns_hdr *hdr = (struct isns_hdr *) buf;
struct isns_tlv *tlv;
if (!isns_fd)
if (isns_connect() < 0)
return 0;
memset(buf, 0, sizeof(buf));
tlv = (struct isns_tlv *) hdr->pdu;
length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1,
name);
length += isns_tlv_set(&tlv, ISNS_ATTR_ISCSI_NAME, strlen(name) + 1,
name);
flags = ISNS_FLAG_CLIENT | ISNS_FLAG_LAST_PDU | ISNS_FLAG_FIRST_PDU;
isns_hdr_init(hdr, ISNS_FUNC_SCN_DEREG, length, flags,
++transaction, 0);
err = write(isns_fd, buf, length + sizeof(struct isns_hdr));
if (err < 0)
log_error("%s %d: %s", __FUNCTION__, __LINE__, strerror(errno));
return 0;
} | false | false | false | false | false | 0 |
bnx2x_update_sge_prod(struct bnx2x_fastpath *fp,
u16 sge_len,
struct eth_end_agg_rx_cqe *cqe)
{
struct bnx2x *bp = fp->bp;
u16 last_max, last_elem, first_elem;
u16 delta = 0;
u16 i;
if (!sge_len)
return;
/* First mark all used pages */
for (i = 0; i < sge_len; i++)
BIT_VEC64_CLEAR_BIT(fp->sge_mask,
RX_SGE(le16_to_cpu(cqe->sgl_or_raw_data.sgl[i])));
DP(NETIF_MSG_RX_STATUS, "fp_cqe->sgl[%d] = %d\n",
sge_len - 1, le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1]));
/* Here we assume that the last SGE index is the biggest */
prefetch((void *)(fp->sge_mask));
bnx2x_update_last_max_sge(fp,
le16_to_cpu(cqe->sgl_or_raw_data.sgl[sge_len - 1]));
last_max = RX_SGE(fp->last_max_sge);
last_elem = last_max >> BIT_VEC64_ELEM_SHIFT;
first_elem = RX_SGE(fp->rx_sge_prod) >> BIT_VEC64_ELEM_SHIFT;
/* If ring is not full */
if (last_elem + 1 != first_elem)
last_elem++;
/* Now update the prod */
for (i = first_elem; i != last_elem; i = NEXT_SGE_MASK_ELEM(i)) {
if (likely(fp->sge_mask[i]))
break;
fp->sge_mask[i] = BIT_VEC64_ELEM_ONE_MASK;
delta += BIT_VEC64_ELEM_SZ;
}
if (delta > 0) {
fp->rx_sge_prod += delta;
/* clear page-end entries */
bnx2x_clear_sge_mask_next_elems(fp);
}
DP(NETIF_MSG_RX_STATUS,
"fp->last_max_sge = %d fp->rx_sge_prod = %d\n",
fp->last_max_sge, fp->rx_sge_prod);
} | false | false | false | false | true | 1 |
agx_compute_index(void)
/* This computes the blocksize and offset values for all blocks */
{
int i;
for(i=0;i<AGX_NUMBLOCK;i++)
gindex[i].blocksize=gindex[i].recsize*gindex[i].numrec;
gindex[0].file_offset=16;
gindex[11].file_offset=gindex[0].file_offset+gindex[0].blocksize;
gindex[12].file_offset=gindex[11].file_offset+gindex[11].blocksize;
gindex[1].file_offset=gindex[12].file_offset+gindex[12].blocksize;
for(i=2;i<=AGX_NUMBLOCK-1;i++)
if (i==13)
gindex[13].file_offset=gindex[10].file_offset+gindex[10].blocksize;
else if (i!=11 && i!=12)
gindex[i].file_offset=gindex[i-1].file_offset+gindex[i-1].blocksize;
} | false | false | false | false | false | 0 |
ensQcalignmentCalculateQueryCoverageQueryQuery(
const EnsPQcalignment qca1,
const EnsPQcalignment qca2,
ajuint *Pscore)
{
ajint end1 = 0;
ajint end2 = 0;
ajint start1 = 0;
ajint start2 = 0;
if (!qca1)
return ajFalse;
if (!Pscore)
return ajFalse;
*Pscore = 0;
/*
** If either of the Alignment objects has no target assigned, the score is
** automatically 0.
*/
if (!qca1->TargetSequence)
return ajTrue;
if (!qca2)
return ajTrue;
if (!qca2->TargetSequence)
return ajTrue;
/* The first Alignment object is always defined. (1*2**0=1) */
*Pscore += 1U;
if (qca2)
{
/*
** Check whether the query Ensembl Quality Check Sequence object is
** the same in both Ensembl Quality Check Alignment objects.
*/
if (!ensQcsequenceMatch(qca1->QuerySequence, qca2->QuerySequence))
{
*Pscore = 0U;
return ajTrue;
}
/* The second Alignment object is defined. (1*2**1=2) */
*Pscore += 2U;
/*
** Determine the relative orientation of the query sequences in the
** alignment.
*/
if (qca1->QueryStrand == qca2->QueryStrand)
{
/* Parallel query sequences. */
start1 = qca1->QueryStart;
end1 = qca1->QueryEnd;
start2 = qca2->QueryStart;
end2 = qca2->QueryEnd;
}
else
{
/* Anti-parallel query sequences. */
start1 = qca1->QueryStart;
end1 = qca1->QueryEnd;
start2 = qca2->QueryEnd;
end2 = qca2->QueryStart;
}
/* Evaluate query start coordinates. */
/* The first alignment is longer. (1*2**5=32) */
if (start1 < start2)
*Pscore += 32U;
/* The first alignment is as long as the second. (1*2**7=128) */
else if (start1 == start2)
*Pscore += 128U;
/* The first alignment is shorter. (1*2**3=8) */
else if (start1 > start2)
*Pscore += 8U;
else
ajWarn("Unexpected query start coordinate relationship.");
/* Evaluate query end coordinates. */
/* The first alignment is longer. (1*2**4=16) */
if (end1 > end2)
*Pscore += 16U;
/* The first alignment is as long as the second. (1*2**6=64) */
else if (end1 == end2)
*Pscore += 64U;
/* The first alignment is shorter. (1*2**2=4) */
else if (end1 < end2)
*Pscore += 4U;
else
ajWarn("Unexpected query end coordinate releationship.");
}
/*
** Test for perfect query coverage in genome alignments. See
** ensQcalignmentCalculateQueryCoverageProteinGenome and
** ensQcalignmentCalculateQueryCoverageDnaGenome for details.
** Since this method is called for the genome alignment, the test
** refers to the first alignment (qca1).
*/
/* Perfect N- or 5'-terminus (1*2**6=64) */
if (qca1->Coverage & 64U)
*Pscore += 512U;
/* Perfect C- or 3'-terminus (1*2**5=32) */
if (qca1->Coverage & 32U)
*Pscore += 256U;
return ajTrue;
} | false | false | false | false | false | 0 |
setStopConflict() {
if (!hasConflict()) {
// we use the nogood {FALSE} to represent the unrecoverable conflict -
// note that {FALSE} can otherwise never be a violated nogood because
// TRUE is always true in every solver
conflict_.push_back(negLit(0));
// remember the current root-level
conflict_.push_back(Literal::fromRep(rootLevel_));
// remember the current propagation queue
conflict_.push_back(Literal::fromRep(assign_.front));
}
// artificially increase root level -
// this way, the solver is prevented from resolving the conflict
pushRootLevel(decisionLevel());
} | false | false | false | false | false | 0 |
_check_polkit_for_action_internal (CphMechanism *mechanism,
GDBusMethodInvocation *context,
const char *action_method,
gboolean allow_user_interaction,
GError **error)
{
const char *sender;
PolkitSubject *subject;
PolkitAuthorizationResult *pk_result;
char *action;
GError *local_error;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
local_error = NULL;
action = g_strdup_printf ("org.opensuse.cupspkhelper.mechanism.%s",
action_method);
/* Check that caller is privileged */
sender = g_dbus_method_invocation_get_sender (context);
subject = polkit_system_bus_name_new (sender);
pk_result = polkit_authority_check_authorization_sync (mechanism->priv->pol_auth,
subject,
action,
NULL,
allow_user_interaction ?
POLKIT_CHECK_AUTHORIZATION_FLAGS_ALLOW_USER_INTERACTION :
POLKIT_CHECK_AUTHORIZATION_FLAGS_NONE,
NULL,
&local_error);
g_object_unref (subject);
if (local_error) {
g_propagate_error (error, local_error);
g_free (action);
return FALSE;
}
if (!polkit_authorization_result_get_is_authorized (pk_result)) {
g_set_error (error,
CPH_MECHANISM_ERROR,
CPH_MECHANISM_ERROR_NOT_PRIVILEGED,
"Not Authorized for action: %s", action);
g_free (action);
g_object_unref (pk_result);
return FALSE;
}
g_free (action);
g_object_unref (pk_result);
return TRUE;
} | false | false | false | false | false | 0 |
playback_exec(struct ast_channel *chan, const char *data)
{
int res = 0;
int mres = 0;
char *tmp;
int option_skip=0;
int option_say=0;
int option_noanswer = 0;
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filenames);
AST_APP_ARG(options);
);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
return -1;
}
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
if (args.options) {
if (strcasestr(args.options, "skip"))
option_skip = 1;
if (strcasestr(args.options, "say"))
option_say = 1;
if (strcasestr(args.options, "noanswer"))
option_noanswer = 1;
}
if (ast_channel_state(chan) != AST_STATE_UP) {
if (option_skip) {
/* At the user's option, skip if the line is not up */
goto done;
} else if (!option_noanswer) {
/* Otherwise answer unless we're supposed to send this while on-hook */
res = ast_answer(chan);
}
}
if (!res) {
char *back = args.filenames;
char *front;
ast_stopstream(chan);
while (!res && (front = strsep(&back, "&"))) {
if (option_say)
res = say_full(chan, front, "", ast_channel_language(chan), NULL, -1, -1);
else
res = ast_streamfile(chan, front, ast_channel_language(chan));
if (!res) {
res = ast_waitstream(chan, "");
ast_stopstream(chan);
} else {
ast_log(LOG_WARNING, "ast_streamfile failed on %s for %s\n", ast_channel_name(chan), (char *)data);
res = 0;
mres = 1;
}
}
}
done:
pbx_builtin_setvar_helper(chan, "PLAYBACKSTATUS", mres ? "FAILED" : "SUCCESS");
return res;
} | false | false | false | false | false | 0 |
pcm_open(struct snd_pcm_substream *substream)
{
struct snd_efw *efw = substream->private_data;
unsigned int sampling_rate;
enum snd_efw_clock_source clock_source;
int err;
err = snd_efw_stream_lock_try(efw);
if (err < 0)
goto end;
err = pcm_init_hw_params(efw, substream);
if (err < 0)
goto err_locked;
err = snd_efw_command_get_clock_source(efw, &clock_source);
if (err < 0)
goto err_locked;
/*
* When source of clock is not internal or any PCM streams are running,
* available sampling rate is limited at current sampling rate.
*/
if ((clock_source != SND_EFW_CLOCK_SOURCE_INTERNAL) ||
amdtp_stream_pcm_running(&efw->tx_stream) ||
amdtp_stream_pcm_running(&efw->rx_stream)) {
err = snd_efw_command_get_sampling_rate(efw, &sampling_rate);
if (err < 0)
goto err_locked;
substream->runtime->hw.rate_min = sampling_rate;
substream->runtime->hw.rate_max = sampling_rate;
}
snd_pcm_set_sync(substream);
end:
return err;
err_locked:
snd_efw_stream_lock_release(efw);
return err;
} | false | false | false | false | false | 0 |
piix4_get_smb(void)
{
unsigned long x;
int result;
result = pci_conf_read(0, smbdev, smbfun, 0x08, 1, &x);
if(x < 0x40){
// SB600/700
result = pci_conf_read(0, smbdev, smbfun, 0x90, 2, &x);
if (result == 0) smbusbase = (unsigned short) x & 0xFFFE;
} else {
// SB800
sb800_get_smb();
}
} | false | false | false | false | false | 0 |
apply_constraint(struct dev_pm_qos_request *req,
enum pm_qos_req_action action, s32 value)
{
struct dev_pm_qos *qos = req->dev->power.qos;
int ret;
switch(req->type) {
case DEV_PM_QOS_RESUME_LATENCY:
ret = pm_qos_update_target(&qos->resume_latency,
&req->data.pnode, action, value);
if (ret) {
value = pm_qos_read_value(&qos->resume_latency);
blocking_notifier_call_chain(&dev_pm_notifiers,
(unsigned long)value,
req);
}
break;
case DEV_PM_QOS_LATENCY_TOLERANCE:
ret = pm_qos_update_target(&qos->latency_tolerance,
&req->data.pnode, action, value);
if (ret) {
value = pm_qos_read_value(&qos->latency_tolerance);
req->dev->power.set_latency_tolerance(req->dev, value);
}
break;
case DEV_PM_QOS_FLAGS:
ret = pm_qos_update_flags(&qos->flags, &req->data.flr,
action, value);
break;
default:
ret = -EINVAL;
}
return ret;
} | false | false | false | false | false | 0 |
encode_1d_row(t4_state_t *s)
{
int i;
/* Do our work in the reference row buffer, and it is already in place if
we need a reference row for a following 2D encoded row. */
s->ref_steps = row_to_run_lengths(s->ref_runs, s->row_buf, s->image_width);
put_1d_span(s, s->ref_runs[0], t4_white_codes);
for (i = 1; i < s->ref_steps; i++)
put_1d_span(s, s->ref_runs[i] - s->ref_runs[i - 1], (i & 1) ? t4_black_codes : t4_white_codes);
/* Stretch the row a little, so when we step by 2 we are guaranteed to
hit an entry showing the row length */
s->ref_runs[s->ref_steps] =
s->ref_runs[s->ref_steps + 1] =
s->ref_runs[s->ref_steps + 2] = s->ref_runs[s->ref_steps - 1];
} | false | false | false | false | false | 0 |
read_string (LexState *LS, int del, SemInfo *seminfo) {
size_t l = 0;
checkbuffer(LS, l);
save_and_next(LS, l);
while (LS->current != del) {
checkbuffer(LS, l);
switch (LS->current) {
case EOZ:
save(LS, '\0', l);
luaX_lexerror(LS, "unfinished string", TK_EOS);
break; /* to avoid warnings */
case '\n':
save(LS, '\0', l);
luaX_lexerror(LS, "unfinished string", TK_STRING);
break; /* to avoid warnings */
case '\\':
next(LS); /* do not save the `\' */
switch (LS->current) {
case 'a': save(LS, '\a', l); next(LS); break;
case 'b': save(LS, '\b', l); next(LS); break;
case 'f': save(LS, '\f', l); next(LS); break;
case 'n': save(LS, '\n', l); next(LS); break;
case 'r': save(LS, '\r', l); next(LS); break;
case 't': save(LS, '\t', l); next(LS); break;
case 'v': save(LS, '\v', l); next(LS); break;
case '\n': save(LS, '\n', l); inclinenumber(LS); break;
case EOZ: break; /* will raise an error next loop */
default: {
if (!isdigit(LS->current))
save_and_next(LS, l); /* handles \\, \", \', and \? */
else { /* \xxx */
int c = 0;
int i = 0;
do {
c = 10*c + (LS->current-'0');
next(LS);
} while (++i<3 && isdigit(LS->current));
if (c > UCHAR_MAX) {
save(LS, '\0', l);
luaX_lexerror(LS, "escape sequence too large", TK_STRING);
}
save(LS, c, l);
}
}
}
break;
default:
save_and_next(LS, l);
}
}
save_and_next(LS, l); /* skip delimiter */
save(LS, '\0', l);
seminfo->ts = luaS_newlstr(LS->L, luaZ_buffer(LS->buff) + 1, l - 3);
} | false | false | false | false | false | 0 |
read_sane_extended(FILE *f, FLAC__uint32 *val, const char *fn)
/* Read an IEEE 754 80-bit (aka SANE) extended floating point value from 'f',
* convert it into an integral value and store in 'val'. Return false if only
* between 1 and 9 bytes remain in 'f', if 0 bytes remain in 'f', or if the
* value is negative, between zero and one, or too large to be represented by
* 'val'; return true otherwise.
*/
{
unsigned int i;
FLAC__byte buf[10];
FLAC__uint64 p = 0;
FLAC__int16 e;
FLAC__int16 shift;
if(!read_bytes(f, buf, sizeof(buf), /*eof_ok=*/false, fn))
return false;
e = ((FLAC__uint16)(buf[0])<<8 | (FLAC__uint16)(buf[1]))-0x3FFF;
shift = 63-e;
if((buf[0]>>7)==1U || e<0 || e>63) {
flac__utils_printf(stderr, 1, "%s: ERROR: invalid floating-point value\n", fn);
return false;
}
for(i = 0; i < 8; ++i)
p |= (FLAC__uint64)(buf[i+2])<<(56U-i*8);
*val = (FLAC__uint32)((p>>shift)+(p>>(shift-1) & 0x1));
return true;
} | false | false | false | false | false | 0 |
fwd_uses_fwd_cmap_procs(gx_device * dev)
{
const gx_cm_color_map_procs *pprocs;
pprocs = dev_proc(dev, get_color_mapping_procs)(dev);
if (pprocs == &FwdDevice_cm_map_procs) {
return true;
}
return false;
} | false | false | false | false | false | 0 |
IncrementalCopy(const char* src, char* op, int len) {
DCHECK_GT(len, 0);
do {
*op++ = *src++;
} while (--len > 0);
} | false | false | false | false | false | 0 |
parse_prefix6(struct parse *cfile, struct group *group) {
struct iaddr lo, hi;
int bits;
enum dhcp_token token;
const char *val;
struct iaddrcidrnetlist *nets;
struct iaddrcidrnetlist *p;
if (local_family != AF_INET6) {
parse_warn(cfile, "prefix6 statement is only supported "
"in DHCPv6 mode.");
skip_to_semi(cfile);
return;
}
/* This is enforced by the caller, so it's just a sanity check. */
if (group->subnet == NULL)
log_fatal("Impossible condition at %s:%d.", MDL);
/*
* Read starting and ending address.
*/
if (!parse_ip6_addr(cfile, &lo)) {
return;
}
if (!parse_ip6_addr(cfile, &hi)) {
return;
}
/*
* Next is '/' number ';'.
*/
token = next_token(NULL, NULL, cfile);
if (token != SLASH) {
parse_warn(cfile, "expecting '/'");
if (token != SEMI)
skip_to_semi(cfile);
return;
}
token = next_token(&val, NULL, cfile);
if (token != NUMBER) {
parse_warn(cfile, "expecting number");
if (token != SEMI)
skip_to_semi(cfile);
return;
}
bits = atoi(val);
if ((bits <= 0) || (bits >= 128)) {
parse_warn(cfile, "networks have 0 to 128 bits (exclusive)");
return;
}
if (!is_cidr_mask_valid(&lo, bits) ||
!is_cidr_mask_valid(&hi, bits)) {
parse_warn(cfile, "network mask too short");
return;
}
token = next_token(NULL, NULL, cfile);
if (token != SEMI) {
parse_warn(cfile, "semicolon expected.");
skip_to_semi(cfile);
return;
}
/*
* Convert our range to a set of CIDR networks.
*/
nets = NULL;
if (range2cidr(&nets, &lo, &hi) != ISC_R_SUCCESS) {
log_fatal("Error converting prefix to CIDR");
}
for (p = nets; p != NULL; p = p->next) {
/* Normalize and check. */
if (p->cidrnet.bits == 128) {
p->cidrnet.bits = bits;
}
if (p->cidrnet.bits > bits) {
parse_warn(cfile, "impossible mask length");
continue;
}
add_ipv6_pool_to_subnet(group->subnet, D6O_IA_PD,
&p->cidrnet.lo_addr,
p->cidrnet.bits, bits);
}
free_iaddrcidrnetlist(&nets);
} | false | false | false | false | true | 1 |
ComputeWorldPosition( vtkRenderer *ren,
double displayPos[2],
double worldPos[3],
double vtkNotUsed(worldOrient)[9] )
{
vtkDebugMacro( << "Request for computing world position at " <<
"display position of " << displayPos[0] << "," << displayPos[1] );
if ( this->CellPicker->Pick(displayPos[0],
displayPos[1], 0.0, ren) )
{
if (vtkAssemblyPath *path = this->CellPicker->GetPath())
{
// We are checking if the prop present in the path is present
// in the list supplied to us.. If it is, that prop will be picked.
// If not, no prop will be picked.
bool found = false;
vtkAssemblyNode *node = NULL;
vtkCollectionSimpleIterator sit;
this->PickProps->InitTraversal(sit);
while (vtkProp *p = this->PickProps->GetNextProp(sit))
{
vtkCollectionSimpleIterator psit;
path->InitTraversal(psit);
for ( int i = 0; i < path->GetNumberOfItems() && !found ; ++i )
{
node = path->GetNextNode(psit);
found = ( node->GetViewProp() == p );
}
if (found)
{
vtkIdType pickedCellId = this->CellPicker->GetCellId();
vtkCell * pickedCell = this->CellPicker->
GetDataSet()->GetCell(pickedCellId);
if (this->Mode == vtkCellCentersPointPlacer::ParametricCenter)
{
double pcoords[3];
pickedCell->GetParametricCenter(pcoords);
double *weights = new double[pickedCell->GetNumberOfPoints()];
int subId;
pickedCell->EvaluateLocation( subId, pcoords, worldPos, weights );
delete [] weights;
}
if (this->Mode == vtkCellCentersPointPlacer::CellPointsMean)
{
const vtkIdType nPoints = pickedCell->GetNumberOfPoints();
vtkPoints *points = pickedCell->GetPoints();
worldPos[0] = worldPos[1] = worldPos[2] = 0.0;
double pp[3];
for (vtkIdType i = 0; i < nPoints; i++)
{
points->GetPoint(i, pp);
worldPos[0] += pp[0];
worldPos[1] += pp[1];
worldPos[2] += pp[2];
}
worldPos[0] /= (static_cast< double >(nPoints));
worldPos[1] /= (static_cast< double >(nPoints));
worldPos[2] /= (static_cast< double >(nPoints));
}
if (this->Mode == vtkCellCentersPointPlacer::None)
{
this->CellPicker->GetPickPosition(worldPos);
}
return 1;
}
}
}
}
return 0;
} | false | false | false | false | false | 0 |
initialize()
{
setSceneAlignment( AlignHCenter | AlignVCenter );
setDeckContents();
// Create the talon to the left.
talon = new PatPile( this, 0, "talon" );
talon->setPileRole(PatPile::Stock);
talon->setLayoutPos(0, 0);
talon->setSpread(0, 0);
talon->setKeyboardSelectHint( KCardPile::NeverFocus );
talon->setKeyboardDropHint( KCardPile::NeverFocus );
connect( talon, SIGNAL(clicked(KCard*)), this, SLOT(newCards()) );
const qreal distx = 1.1;
// Create 4 piles where the cards will be placed during the game.
for( int i = 0; i < 4; ++i )
{
m_play[i] = new PatPile( this, i + 1, QString( "play%1" ).arg( i ));
m_play[i]->setPileRole(PatPile::Tableau);
m_play[i]->setLayoutPos(1.5 + distx * i, 0);
m_play[i]->setBottomPadding( 2 );
m_play[i]->setHeightPolicy( KCardPile::GrowDown );
m_play[i]->setKeyboardSelectHint( KCardPile::AutoFocusTop );
m_play[i]->setKeyboardDropHint( KCardPile::AutoFocusTop );
}
// Create the discard pile to the right
m_away = new PatPile( this, 5, "away" );
m_away->setPileRole(PatPile::Foundation);
m_away->setLayoutPos(1.9 + distx * 4, 0);
m_away->setSpread(0, 0);
m_away->setKeyboardSelectHint(KCardPile::NeverFocus);
m_away->setKeyboardDropHint(KCardPile::ForceFocusTop);
connect( this, SIGNAL(cardClicked(KCard*)), this, SLOT(tryAutomaticMove(KCard*)) );
setActions(DealerScene::Hint | DealerScene::Demo | DealerScene::Deal);
setSolver( new IdiotSolver(this ) );
} | false | false | false | false | false | 0 |
gnm_expr_top_relocate_sheet (GnmExprTop const *texpr,
Sheet const *src,
Sheet const *dst)
{
GnmExprRelocateInfo rinfo;
GnmExprTop const *res;
g_return_val_if_fail (IS_GNM_EXPR_TOP (texpr), NULL);
g_return_val_if_fail (IS_SHEET (src), NULL);
g_return_val_if_fail (IS_SHEET (dst), NULL);
rinfo.reloc_type = GNM_EXPR_RELOCATE_MOVE_RANGE;
rinfo.origin_sheet = (Sheet *)src;
rinfo.target_sheet = (Sheet *)dst;
rinfo.col_offset = rinfo.row_offset = 0;
range_init_full_sheet (&rinfo.origin, src);
/* Not sure what sheet to use, but it doesn't seem to matter. */
parse_pos_init_sheet (&rinfo.pos, rinfo.target_sheet);
res = gnm_expr_top_relocate (texpr, &rinfo, FALSE);
if (!res) {
if (gnm_expr_top_is_array_corner (texpr))
res = gnm_expr_top_new (gnm_expr_copy (texpr->expr));
else
gnm_expr_top_ref ((res = texpr));
}
return res;
} | false | false | false | false | false | 0 |
Iidlerun (int argc, lvar_t *argv) {
Tobj mo;
char *ms;
int mode;
if (Tgettype ((mo = argv[0].o)) != T_STRING)
return L_SUCCESS;
ms = Tgetstring (mo);
if (strcmp (ms, "on") == 0)
mode = 1;
else if (strcmp (ms, "off") == 0)
mode = 0;
else
return L_FAILURE;
idlerunmode = mode;
return L_SUCCESS;
} | false | false | true | false | true | 1 |
GetScalarResult()
{
if (!(this->IsScalarResult()))
{
vtkErrorMacro("GetScalarResult: no valid scalar result");
return VTK_PARSER_ERROR_RESULT;
}
return this->Stack[0];
} | false | false | false | false | false | 0 |
setAxis(const SbLine& a)
{
#if COIN_DEBUG
if (!(a.getDirection().length() > 0.0f))
SoDebugError::postWarning("SbCylinder::setAxis",
"Axis has zero length => undefined");
#endif // COIN_DEBUG
this->axis = a;
} | false | false | false | false | false | 0 |
drm_poll(struct file *filp, struct poll_table_struct *wait)
{
struct drm_file *file_priv = filp->private_data;
unsigned int mask = 0;
poll_wait(filp, &file_priv->event_wait, wait);
if (!list_empty(&file_priv->event_list))
mask |= POLLIN | POLLRDNORM;
return mask;
} | false | false | false | false | false | 0 |
walgc(Wal *w)
{
File *f;
while (w->head && !w->head->refs) {
f = w->head;
w->head = f->next;
if (w->tail == f) {
w->tail = f->next; // also, f->next == NULL
}
w->nfile--;
unlink(f->path);
free(f->path);
free(f);
}
} | false | false | false | false | false | 0 |
brasero_burn_powermanagement (BraseroBurn *self,
gboolean wake)
{
BraseroBurnPrivate *priv = BRASERO_BURN_PRIVATE (self);
if (wake)
priv->appcookie = brasero_inhibit_suspend (_("Burning CD/DVD"));
else
brasero_uninhibit_suspend (priv->appcookie);
} | false | false | false | false | false | 0 |
l2tp_tunnel_start(struct l2tp_conn_t *conn,
triton_event_func start_func,
void *start_param)
{
if (triton_context_register(&conn->ctx, NULL) < 0) {
log_error("l2tp: impossible to start new tunnel:"
" context registration failed\n");
goto err;
}
triton_md_register_handler(&conn->ctx, &conn->hnd);
if (triton_md_enable_handler(&conn->hnd, MD_MODE_READ) < 0) {
log_error("l2tp: impossible to start new tunnel:"
" enabling handler failed\n");
goto err_ctx;
}
triton_context_wakeup(&conn->ctx);
if (triton_timer_add(&conn->ctx, &conn->timeout_timer, 0) < 0) {
log_error("l2tp: impossible to start new tunnel:"
" setting tunnel establishment timer failed\n");
goto err_ctx_md;
}
if (triton_context_call(&conn->ctx, start_func, start_param) < 0) {
log_error("l2tp: impossible to start new tunnel:"
" call to tunnel context failed\n");
goto err_ctx_md_timer;
}
return 0;
err_ctx_md_timer:
triton_timer_del(&conn->timeout_timer);
err_ctx_md:
triton_md_unregister_handler(&conn->hnd, 0);
err_ctx:
triton_context_unregister(&conn->ctx);
err:
return -1;
} | false | true | false | false | true | 1 |
sbitmap_resize (sbitmap bmap, unsigned int n_elms, int def)
{
unsigned int bytes, size, amt;
unsigned int last_bit;
size = SBITMAP_SET_SIZE (n_elms);
bytes = size * sizeof (SBITMAP_ELT_TYPE);
if (bytes > bmap->bytes)
{
amt = (sizeof (struct simple_bitmap_def)
+ bytes - sizeof (SBITMAP_ELT_TYPE));
bmap = xrealloc (bmap, amt);
}
if (n_elms > bmap->n_bits)
{
if (def)
{
memset (bmap->elms + bmap->size, -1, bytes - bmap->bytes);
/* Set the new bits if the original last element. */
last_bit = bmap->n_bits % SBITMAP_ELT_BITS;
if (last_bit)
bmap->elms[bmap->size - 1]
|= ~((SBITMAP_ELT_TYPE)-1 >> (SBITMAP_ELT_BITS - last_bit));
/* Clear the unused bit in the new last element. */
last_bit = n_elms % SBITMAP_ELT_BITS;
if (last_bit)
bmap->elms[size - 1]
&= (SBITMAP_ELT_TYPE)-1 >> (SBITMAP_ELT_BITS - last_bit);
}
else
memset (bmap->elms + bmap->size, 0, bytes - bmap->bytes);
}
else if (n_elms < bmap->n_bits)
{
/* Clear the surplus bits in the last word. */
last_bit = n_elms % SBITMAP_ELT_BITS;
if (last_bit)
bmap->elms[size - 1]
&= (SBITMAP_ELT_TYPE)-1 >> (SBITMAP_ELT_BITS - last_bit);
}
bmap->n_bits = n_elms;
bmap->size = size;
bmap->bytes = bytes;
return bmap;
} | false | false | false | false | false | 0 |
changeoutgroup()
{
long i, maxinput;
boolean ok;
maxinput = 1;
do {
printf("Which node should be the new outgroup? ");
inpnum(&i, &ok);
ok = (ok && i >= 1 && i <= nonodes && i != root->index);
if (ok)
ok = (ok && !nodep[i - 1]->deleted);
if (ok)
ok = !nodep[nodep[i - 1]->back->index - 1]->deleted;
if (ok)
outgrno = i;
maxinput++;
if (maxinput == 100) {
printf("ERROR: too many tries at choosing option\n");
embExitBad();
}
} while (!ok);
copytree();
reroot(nodep[outgrno - 1]);
printree();
written = false;
} | false | false | false | false | false | 0 |
flip_faces(Mesh &mesh)
{
Buffer<vertex_t> &p_meshv = mesh.vertices();
Buffer<index_t> &p_meshi = mesh.indices();
// Invert the faces.
for (unsigned int i = 0; i < p_meshi.count(); i+=3) {
int temp = p_meshi[i];
p_meshi[i] = p_meshi[i+2];
p_meshi[i+2] = temp;
}
// Correct the normals.
for (unsigned int i = 0; i < p_meshv.count(); i++) {
p_meshv[i].nx *= -1.0f;
p_meshv[i].ny *= -1.0f;
p_meshv[i].nz *= -1.0f;
}
return 0;
} | false | false | false | false | false | 0 |
_wi_data_hash(wi_runtime_instance_t *instance) {
wi_data_t *data = instance;
return wi_hash_data(data->bytes, WI_MIN(data->length, 16));
} | false | false | false | false | false | 0 |
pcap_ts_event_touch(int pirq, void *data)
{
struct pcap_ts *pcap_ts = data;
if (pcap_ts->read_state == PCAP_ADC_TS_M_STANDBY) {
pcap_ts->read_state = PCAP_ADC_TS_M_PRESSURE;
schedule_delayed_work(&pcap_ts->work, 0);
}
return IRQ_HANDLED;
} | false | false | false | false | false | 0 |
get_property (GObject *object, guint prop_id,
GValue *value, GParamSpec *pspec)
{
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
NMSettingBond *setting = NM_SETTING_BOND (object);
switch (prop_id) {
case PROP_INTERFACE_NAME:
g_value_set_string (value, nm_setting_bond_get_interface_name (setting));
break;
case PROP_OPTIONS:
g_value_set_boxed (value, priv->options);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} | false | false | false | false | false | 0 |
move_repair(piece_info_t *obj)
{
path_map_t path_map[MAP_SIZE];
loc_t loc;
ASSERT (obj->type > FIGHTER);
if (obj->hits == piece_attr[obj->type].max_hits) {
obj->func = NOFUNC;
return;
}
if (user_map[obj->loc].contents == 'O') { /* it is in port? */
obj->moved += 1;
return;
}
loc = vmap_find_wobj (path_map, user_map, obj->loc, &user_ship_repair);
if (loc == obj->loc) return; /* no reachable city */
vmap_mark_path (path_map, user_map, loc);
/* try to be next to ocean to avoid enemy pieces */
loc = vmap_find_dir (path_map, user_map, obj->loc, ".O", ".");
if (loc != obj->loc) move_obj (obj, loc);
} | false | false | false | false | false | 0 |
coord2bin(double *x)
{
int ix,iy,iz;
if (x[0] >= bboxhi[0])
ix = static_cast<int> ((x[0]-bboxhi[0])*bininvx) + nbinx;
else if (x[0] >= bboxlo[0]) {
ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx);
ix = MIN(ix,nbinx-1);
} else
ix = static_cast<int> ((x[0]-bboxlo[0])*bininvx) - 1;
if (x[1] >= bboxhi[1])
iy = static_cast<int> ((x[1]-bboxhi[1])*bininvy) + nbiny;
else if (x[1] >= bboxlo[1]) {
iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy);
iy = MIN(iy,nbiny-1);
} else
iy = static_cast<int> ((x[1]-bboxlo[1])*bininvy) - 1;
if (x[2] >= bboxhi[2])
iz = static_cast<int> ((x[2]-bboxhi[2])*bininvz) + nbinz;
else if (x[2] >= bboxlo[2]) {
iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz);
iz = MIN(iz,nbinz-1);
} else
iz = static_cast<int> ((x[2]-bboxlo[2])*bininvz) - 1;
return (iz-mbinzlo)*mbiny*mbinx + (iy-mbinylo)*mbinx + (ix-mbinxlo);
} | false | false | false | false | false | 0 |
vgacon_save_screen(struct vc_data *c)
{
static int vga_bootup_console = 0;
if (!vga_bootup_console) {
/* This is a gross hack, but here is the only place we can
* set bootup console parameters without messing up generic
* console initialization routines.
*/
vga_bootup_console = 1;
c->vc_x = screen_info.orig_x;
c->vc_y = screen_info.orig_y;
}
/* We can't copy in more than the size of the video buffer,
* or we'll be copying in VGA BIOS */
if (!vga_is_gfx)
scr_memcpyw((u16 *) c->vc_screenbuf, (u16 *) c->vc_origin,
c->vc_screenbuf_size > vga_vram_size ? vga_vram_size : c->vc_screenbuf_size);
} | false | false | false | false | false | 0 |
vt_ioexit(uint32_t tid, uint64_t* time, uint64_t* etime, uint32_t fid,
uint64_t hid, uint32_t op, uint64_t bytes)
{
GET_THREAD_ID(tid);
if (VTTHRD_TRACE_STATUS(VTThrdv[tid]) != VT_TRACE_ON) return;
VTGen_write_FILE_OPERATION(VTTHRD_GEN(VTThrdv[tid]),
time,
etime,
fid,
hid,
op,
bytes,
0);
vt_exit(tid, etime);
} | false | false | false | false | false | 0 |
acfg_free (MonoAotCompile *acfg)
{
int i;
img_writer_destroy (acfg->w);
for (i = 0; i < acfg->nmethods; ++i)
if (acfg->cfgs [i])
g_free (acfg->cfgs [i]);
g_free (acfg->cfgs);
g_free (acfg->static_linking_symbol);
g_free (acfg->got_symbol);
g_free (acfg->plt_symbol);
g_ptr_array_free (acfg->methods, TRUE);
g_ptr_array_free (acfg->got_patches, TRUE);
g_ptr_array_free (acfg->image_table, TRUE);
g_ptr_array_free (acfg->globals, TRUE);
g_ptr_array_free (acfg->unwind_ops, TRUE);
g_hash_table_destroy (acfg->method_indexes);
g_hash_table_destroy (acfg->method_depth);
g_hash_table_destroy (acfg->plt_offset_to_entry);
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i) {
if (acfg->patch_to_plt_entry [i])
g_hash_table_destroy (acfg->patch_to_plt_entry [i]);
}
g_free (acfg->patch_to_plt_entry);
g_hash_table_destroy (acfg->patch_to_got_offset);
g_hash_table_destroy (acfg->method_to_cfg);
g_hash_table_destroy (acfg->token_info_hash);
g_hash_table_destroy (acfg->method_to_pinvoke_import);
g_hash_table_destroy (acfg->image_hash);
g_hash_table_destroy (acfg->unwind_info_offsets);
g_hash_table_destroy (acfg->method_label_hash);
g_hash_table_destroy (acfg->export_names);
g_hash_table_destroy (acfg->plt_entry_debug_sym_cache);
g_hash_table_destroy (acfg->klass_blob_hash);
g_hash_table_destroy (acfg->method_blob_hash);
for (i = 0; i < MONO_PATCH_INFO_NUM; ++i)
g_hash_table_destroy (acfg->patch_to_got_offset_by_type [i]);
g_free (acfg->patch_to_got_offset_by_type);
mono_mempool_destroy (acfg->mempool);
g_free (acfg);
} | false | false | false | false | false | 0 |
connect_to_socks5_proxy (CamelTcpStreamRaw *raw,
const gchar *proxy_host,
gint proxy_port,
const gchar *host,
const gchar *service,
gint fallback_port,
GCancellable *cancellable,
GError **error)
{
PRFileDesc *fd;
gint port;
fd = connect_to_proxy (
raw, proxy_host, proxy_port, cancellable, error);
if (!fd)
goto error;
port = resolve_port (service, fallback_port, cancellable, error);
if (port == 0)
goto error;
if (!socks5_initiate_and_request_authentication (raw, fd, cancellable, error))
goto error;
if (!socks5_request_connect (raw, fd, host, port, cancellable, error))
goto error;
d (g_print (" success\n"));
goto out;
error:
if (fd) {
gint save_errno;
save_errno = errno;
PR_Shutdown (fd, PR_SHUTDOWN_BOTH);
PR_Close (fd);
errno = save_errno;
fd = NULL;
}
d (g_print (" returning errno %d\n", errno));
out:
d (g_print ("}\n"));
return fd;
} | false | false | false | false | false | 0 |
ensGvpopulationadaptorFetchAllbyGvindividuals(
EnsPGvpopulationadaptor gvpa,
AjPList gvis,
AjPList gvps)
{
/*
** NOTE: This function does not use the Ensembl Base Adaptor
** functionality, because an additional 'individual_population' table is
** required.
*/
const char *template =
"SELECT "
"population.sample_id, "
"sample.name, "
"sample.size, "
"sample.description "
"FROM "
"population p, "
"individual_population ip, "
"sample s "
"WHERE "
"sample.sample_id = individual_population.population_sample_id "
"AND "
"sample.sample_id = population.sample_id "
"AND "
"individual_population.individual_sample_id IN (%S)";
register ajuint i = 0U;
AjIList iter = NULL;
AjPStr csv = NULL;
AjPStr statement = NULL;
EnsPGvindividual gvi = NULL;
if (!gvpa)
return ajFalse;
if (!gvis)
return ajFalse;
if (!gvps)
return ajFalse;
csv = ajStrNew();
iter = ajListIterNew(gvis);
while (!ajListIterDone(iter)) {
gvi = (EnsPGvindividual) ajListIterGet(iter);
ajFmtPrintAppS(&csv, "%u, ", ensGvindividualGetIdentifier(gvi));
/*
** Run the statement if the maximum chunk size is exceed or
** if there are no more AJAX List elements to process.
*/
if ((((i + 1U) % ensKBaseadaptorMaximumIdentifiers) == 0) ||
ajListIterDone(iter))
{
/* Remove the last comma and space. */
ajStrCutEnd(&csv, 2);
if (ajStrGetLen(csv))
{
statement = ajFmtStr(template, csv);
gvpopulationadaptorFetchAllbyStatement(
gvpa,
statement,
(EnsPAssemblymapper) NULL,
(EnsPSlice) NULL,
gvps);
ajStrDel(&statement);
}
ajStrAssignClear(&csv);
}
i++;
}
ajListIterDel(&iter);
return ajTrue;
} | false | false | false | false | false | 0 |
dot(const double* v1, unsigned s, const double* v2, unsigned n)
{
double sum=0.0;
for (unsigned i=0;i<n;++i,v1+=s) sum+= (*v1)*v2[i];
return sum;
} | false | false | false | false | false | 0 |
oggpack_read(oggpack_buffer *b, int bits) {
unsigned long ret;
unsigned long m=mask[bits];
bits+=b->endbit;
if (b->endbyte+4>=b->storage) {
ret=(unsigned long)-1;
if (b->endbyte+(bits-1)/8>=b->storage) goto overflow;
}
ret=b->ptr[0]>>b->endbit;
if (bits>8) {
ret|=b->ptr[1]<<(8-b->endbit);
if (bits>16) {
ret|=b->ptr[2]<<(16-b->endbit);
if (bits>24) {
ret|=b->ptr[3]<<(24-b->endbit);
if (bits>32 && b->endbit) {
ret|=b->ptr[4]<<(32-b->endbit);
}
}
}
}
ret&=m;
overflow:
b->ptr+=bits/8;
b->endbyte+=bits/8;
b->endbit=bits&7;
return ret;
} | false | false | false | false | false | 0 |
ib_uverbs_close(struct inode *inode, struct file *filp)
{
struct ib_uverbs_file *file = filp->private_data;
struct ib_uverbs_device *dev = file->device;
mutex_lock(&file->cleanup_mutex);
if (file->ucontext) {
ib_uverbs_cleanup_ucontext(file, file->ucontext);
file->ucontext = NULL;
}
mutex_unlock(&file->cleanup_mutex);
mutex_lock(&file->device->lists_mutex);
if (!file->is_closed) {
list_del(&file->list);
file->is_closed = 1;
}
mutex_unlock(&file->device->lists_mutex);
if (file->async_file)
kref_put(&file->async_file->ref, ib_uverbs_release_event_file);
kref_put(&file->ref, ib_uverbs_release_file);
kobject_put(&dev->kobj);
return 0;
} | false | false | false | false | false | 0 |
gettagsandvalues(uint8_t *buffer, int length, std::map<std::string,
struct tagvalue> &tagvalues, int messageextentoffset)
{
int counter = 0;
uint8_t *p = buffer;
uint8_t marker1 = YAHOO_OLD_MARKER1;
uint8_t marker2 = YAHOO_OLD_MARKER2;
if (yahooversion == YAHOO_VERSION_FLASH)
{
marker1 = YAHOO_FLASH_MARKER1;
marker2 = YAHOO_FLASH_MARKER2;
}
while (p - buffer < length)
{
std::string tag; struct tagvalue tagvalue;
while (!(p[0] == marker1 && p[1] == marker2))
{
if (p - buffer >= length) break;
tag += *p;
p++;
}
p += 2;
/* Build the message extent now. */
tagvalue.messageextent.start = p - buffer + messageextentoffset;
tagvalue.messageextent.length = 0; /* NULL terminate. */
while (!(p[0] == marker1 && p[1] == marker2))
{
if (p - buffer >= length) break;
tagvalue.text += *p;
tagvalue.messageextent.length++;
p++;
}
p += 2;
tagvalues[tag] = tagvalue;
counter++;
debugprint(localdebugmode, PROTOCOL_NAME ": Tag: %s Value: %s", tag.c_str(), tagvalue.text.c_str());
}
return counter;
} | false | false | false | false | false | 0 |
clone(const String& newName) const
{
Animation* newAnim = OGRE_NEW Animation(newName, mLength);
newAnim->mInterpolationMode = mInterpolationMode;
newAnim->mRotationInterpolationMode = mRotationInterpolationMode;
// Clone all tracks
for (NodeTrackList::const_iterator i = mNodeTrackList.begin();
i != mNodeTrackList.end(); ++i)
{
i->second->_clone(newAnim);
}
for (NumericTrackList::const_iterator i = mNumericTrackList.begin();
i != mNumericTrackList.end(); ++i)
{
i->second->_clone(newAnim);
}
for (VertexTrackList::const_iterator i = mVertexTrackList.begin();
i != mVertexTrackList.end(); ++i)
{
i->second->_clone(newAnim);
}
newAnim->_keyFrameListChanged();
return newAnim;
} | false | false | false | false | false | 0 |
bfusb_load_firmware(struct bfusb_data *data,
const unsigned char *firmware, int count)
{
unsigned char *buf;
int err, pipe, len, size, sent = 0;
BT_DBG("bfusb %p udev %p", data, data->udev);
BT_INFO("BlueFRITZ! USB loading firmware");
buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_KERNEL);
if (!buf) {
BT_ERR("Can't allocate memory chunk for firmware");
return -ENOMEM;
}
pipe = usb_sndctrlpipe(data->udev, 0);
if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION,
0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) {
BT_ERR("Can't change to loading configuration");
kfree(buf);
return -EBUSY;
}
data->udev->toggle[0] = data->udev->toggle[1] = 0;
pipe = usb_sndbulkpipe(data->udev, data->bulk_out_ep);
while (count) {
size = min_t(uint, count, BFUSB_MAX_BLOCK_SIZE + 3);
memcpy(buf, firmware + sent, size);
err = usb_bulk_msg(data->udev, pipe, buf, size,
&len, BFUSB_BLOCK_TIMEOUT);
if (err || (len != size)) {
BT_ERR("Error in firmware loading");
goto error;
}
sent += size;
count -= size;
}
err = usb_bulk_msg(data->udev, pipe, NULL, 0,
&len, BFUSB_BLOCK_TIMEOUT);
if (err < 0) {
BT_ERR("Error in null packet request");
goto error;
}
pipe = usb_sndctrlpipe(data->udev, 0);
err = usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION,
0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
if (err < 0) {
BT_ERR("Can't change to running configuration");
goto error;
}
data->udev->toggle[0] = data->udev->toggle[1] = 0;
BT_INFO("BlueFRITZ! USB device ready");
kfree(buf);
return 0;
error:
kfree(buf);
pipe = usb_sndctrlpipe(data->udev, 0);
usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION,
0, 0, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
return err;
} | false | true | false | false | false | 1 |
dw_mci_translate_sglist(struct dw_mci *host, struct mmc_data *data,
unsigned int sg_len)
{
unsigned int desc_len;
int i;
if (host->dma_64bit_address == 1) {
struct idmac_desc_64addr *desc_first, *desc_last, *desc;
desc_first = desc_last = desc = host->sg_cpu;
for (i = 0; i < sg_len; i++) {
unsigned int length = sg_dma_len(&data->sg[i]);
u64 mem_addr = sg_dma_address(&data->sg[i]);
for ( ; length ; desc++) {
desc_len = (length <= DW_MCI_DESC_DATA_LENGTH) ?
length : DW_MCI_DESC_DATA_LENGTH;
length -= desc_len;
/*
* Set the OWN bit and disable interrupts
* for this descriptor
*/
desc->des0 = IDMAC_DES0_OWN | IDMAC_DES0_DIC |
IDMAC_DES0_CH;
/* Buffer length */
IDMAC_64ADDR_SET_BUFFER1_SIZE(desc, desc_len);
/* Physical address to DMA to/from */
desc->des4 = mem_addr & 0xffffffff;
desc->des5 = mem_addr >> 32;
/* Update physical address for the next desc */
mem_addr += desc_len;
/* Save pointer to the last descriptor */
desc_last = desc;
}
}
/* Set first descriptor */
desc_first->des0 |= IDMAC_DES0_FD;
/* Set last descriptor */
desc_last->des0 &= ~(IDMAC_DES0_CH | IDMAC_DES0_DIC);
desc_last->des0 |= IDMAC_DES0_LD;
} else {
struct idmac_desc *desc_first, *desc_last, *desc;
desc_first = desc_last = desc = host->sg_cpu;
for (i = 0; i < sg_len; i++) {
unsigned int length = sg_dma_len(&data->sg[i]);
u32 mem_addr = sg_dma_address(&data->sg[i]);
for ( ; length ; desc++) {
desc_len = (length <= DW_MCI_DESC_DATA_LENGTH) ?
length : DW_MCI_DESC_DATA_LENGTH;
length -= desc_len;
/*
* Set the OWN bit and disable interrupts
* for this descriptor
*/
desc->des0 = cpu_to_le32(IDMAC_DES0_OWN |
IDMAC_DES0_DIC |
IDMAC_DES0_CH);
/* Buffer length */
IDMAC_SET_BUFFER1_SIZE(desc, desc_len);
/* Physical address to DMA to/from */
desc->des2 = cpu_to_le32(mem_addr);
/* Update physical address for the next desc */
mem_addr += desc_len;
/* Save pointer to the last descriptor */
desc_last = desc;
}
}
/* Set first descriptor */
desc_first->des0 |= cpu_to_le32(IDMAC_DES0_FD);
/* Set last descriptor */
desc_last->des0 &= cpu_to_le32(~(IDMAC_DES0_CH |
IDMAC_DES0_DIC));
desc_last->des0 |= cpu_to_le32(IDMAC_DES0_LD);
}
wmb(); /* drain writebuffer */
} | false | false | false | false | false | 0 |
reparent_children (struct file_link *dlink, struct file_link *slink)
{
void **slot = idh.idh_file_link_table.ht_vec;
void **end = &idh.idh_file_link_table.ht_vec[idh.idh_file_link_table.ht_size];
for ( ; slot < end; slot++)
{
if (!HASH_VACANT (*slot))
{
struct file_link *child = (struct file_link *) *slot;
if (child->fl_parent == slink)
{
void **new_slot;
*slot = hash_deleted_item;
child->fl_parent = dlink;
new_slot = hash_find_slot (&idh.idh_file_link_table, child);
*new_slot = child;
}
}
}
} | false | false | false | false | false | 0 |
set_psm_initial(PatchSetMember * psm)
{
psm->pre_rev = NULL;
if (psm->post_rev->dead)
{
/*
* we expect a 'file xyz initially added on branch abc' here
* but there can only be one such member in a given patchset
*/
if (psm->ps->branch_add)
debug(DEBUG_APPMSG1, "WARNING: branch_add already set!");
psm->ps->branch_add = 1;
}
} | false | false | false | false | false | 0 |
remove_vertex(int i)
/* removes vertex i from the graph and returns an edge with the
new face on the left. Note that afterwards the vertices are
in general no more numbered 0...nv-1, but maybe e.g. 0...nv
with some number in the middle missing.
*/
{
EDGE *run, *end, *buffer;
nv--;
ne -= 2*degree[i];
run=end=firstedge[i];
do {
buffer=run->invers;
buffer->prev->next=buffer->next;
buffer->next->prev=buffer->prev;
(degree[buffer->start])--;
firstedge[buffer->start]=buffer->next;
run=run->next;
} while (run!=end);
missing_vertex = i;
outside_face_size = degree[i];
return buffer->next;
} | false | false | false | false | false | 0 |
test_refs_races__create_matching(void)
{
git_reference *ref, *ref2, *ref3;
git_oid id, other_id;
git_oid_fromstr(&id, commit_id);
git_oid_fromstr(&other_id, other_commit_id);
cl_git_fail_with(GIT_EMODIFIED, git_reference_create_matching(&ref, g_repo, refname, &other_id, 1, &other_id, NULL, NULL));
cl_git_pass(git_reference_lookup(&ref, g_repo, refname));
cl_git_pass(git_reference_create_matching(&ref2, g_repo, refname, &other_id, 1, &id, NULL, NULL));
cl_git_fail_with(GIT_EMODIFIED, git_reference_set_target(&ref3, ref, &other_id, NULL, NULL));
git_reference_free(ref);
git_reference_free(ref2);
git_reference_free(ref3);
} | false | false | false | false | false | 0 |
thread_function_2(void *anArg)
{
DENTER(TOP_LAYER, "thread_function_2");
sleep(6);
SGE_LOCK(LOCK_GLOBAL, LOCK_WRITE);
sleep(2);
SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
DEXIT;
return (void *)NULL;
} | false | false | false | false | false | 0 |
load_config(gchar *path)
{
FILE *f;
PluginConfigRec *cfg;
gchar buf[128+32+2], config[32], arg[128];
gchar *s, *plugin_config_block = NULL;
//g_print("Trying to load config from file '%s'\n", path);
f = g_fopen(path, "r");
if (!f)
return;
while (fgets(buf, sizeof(buf), f))
{
if (!buf[0] || buf[0] == '#')
continue;
if (buf[0] == '[' || buf[0] == '<')
{
if (buf[1] == '/')
{
g_free(plugin_config_block);
plugin_config_block = NULL;
}
else
{
if ( (s = strchr(buf, ']')) != NULL
|| (s = strchr(buf, '>')) != NULL
)
*s = '\0';
plugin_config_block = g_strdup(&buf[1]);
}
continue;
}
if (plugin_config_block)
{
cfg = g_new0(PluginConfigRec, 1);
cfg->name = g_strdup(plugin_config_block);
if ((s = strchr(buf, '\n')) != NULL)
*s = '\0';
cfg->line = g_strdup(buf);
gkrellmd_plugin_config_list
= g_list_append(gkrellmd_plugin_config_list, cfg);
}
else /* main gkrellmd config line */
{
arg[0] = '\0';
sscanf(buf, "%31s %127s", config, arg);
parse_config(config, arg);
}
}
fclose(f);
} | false | false | false | false | false | 0 |
clipToRect(SplashCoord x0, SplashCoord y0,
SplashCoord x1, SplashCoord y1) {
if (x0 < x1) {
if (x0 > xMin) {
xMin = x0;
xMinI = splashFloor(xMin);
}
if (x1 < xMax) {
xMax = x1;
xMaxI = splashFloor(xMax);
}
} else {
if (x1 > xMin) {
xMin = x1;
xMinI = splashFloor(xMin);
}
if (x0 < xMax) {
xMax = x0;
xMaxI = splashFloor(xMax);
}
}
if (y0 < y1) {
if (y0 > yMin) {
yMin = y0;
yMinI = splashFloor(yMin);
}
if (y1 < yMax) {
yMax = y1;
yMaxI = splashFloor(yMax);
}
} else {
if (y1 > yMin) {
yMin = y1;
yMinI = splashFloor(yMin);
}
if (y0 < yMax) {
yMax = y0;
yMaxI = splashFloor(yMax);
}
}
return splashOk;
} | false | false | false | false | false | 0 |
read ( void * buf,
unsigned int len ) throw ( Exception )
{
int ret;
if ( !isOpen() ) {
return 0;
}
ret = recv( sockfd, buf, len, 0);
if ( ret == -1 ) {
switch (errno) {
case ECONNRESET:
// re-open the socket if it has been reset by the peer
close();
Util::sleep(1L, 0L);
open();
break;
default:
::close( sockfd);
sockfd = 0;
throw Exception( __FILE__, __LINE__, "recv error", errno);
}
}
return ret;
} | false | false | false | false | false | 0 |
H5I_dec_ref(hid_t id)
{
H5I_id_info_t *id_ptr; /*ptr to the new ID */
int ret_value; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Sanity check */
HDassert(id >= 0);
/* General lookup of the ID */
if(NULL == (id_ptr = H5I__find_id(id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID")
/*
* If this is the last reference to the object then invoke the type's
* free method on the object. If the free method is undefined or
* successful then remove the object from the type; otherwise leave
* the object in the type without decrementing the reference
* count. If the reference count is more than one then decrement the
* reference count without calling the free method.
*
* Beware: the free method may call other H5I functions.
*
* If an object is closing, we can remove the ID even though the free
* method might fail. This can happen when a mandatory filter fails to
* write when a dataset is closed and the chunk cache is flushed to the
* file. We have to close the dataset anyway. (SLU - 2010/9/7)
*/
if(1 == id_ptr->count) {
H5I_id_type_t *type_ptr; /*ptr to the type */
/* Get the ID's type */
type_ptr = H5I_id_type_list_g[H5I_TYPE(id)];
/* (Casting away const OK -QAK) */
if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) {
/* Remove the node from the type */
if(NULL == H5I__remove_common(type_ptr, id))
HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node")
ret_value = 0;
} /* end if */
else
ret_value = FAIL;
} /* end if */
else {
--(id_ptr->count);
ret_value = (int)id_ptr->count;
} /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
} | false | false | false | false | false | 0 |
gf_odf_write_esd_remove(GF_BitStream *bs, GF_ESDRemove *esdRem)
{
GF_Err e;
u32 size, i;
if (! esdRem) return GF_BAD_PARAM;
e = gf_odf_size_esd_remove(esdRem, &size);
if (e) return e;
e = gf_odf_write_base_descriptor(bs, esdRem->tag, size);
if (e) return e;
gf_bs_write_int(bs, esdRem->ODID, 10);
gf_bs_write_int(bs, 0, 6); //aligned
for (i = 0; i < esdRem->NbESDs ; i++) {
gf_bs_write_int(bs, esdRem->ES_ID[i], 16);
}
//OD commands are aligned (but we are already aligned....
gf_bs_align(bs);
return GF_OK;
} | false | false | false | false | false | 0 |
mono_tramp_info_register (MonoTrampInfo *info)
{
MonoTrampInfo *copy;
if (!info)
return;
copy = g_new0 (MonoTrampInfo, 1);
copy->code = info->code;
copy->code_size = info->code_size;
copy->name = g_strdup (info->name);
mono_jit_lock ();
tramp_infos = g_slist_prepend (tramp_infos, copy);
mono_jit_unlock ();
mono_save_trampoline_xdebug_info (info);
if (mono_jit_map_is_enabled ())
mono_emit_jit_tramp (info->code, info->code_size, info->name);
mono_tramp_info_free (info);
} | false | false | false | false | false | 0 |
Connect(const Request ¬ification)
{
QSharedPointer<Edge> edge = notification.GetFrom().dynamicCast<Edge>();
if(!edge) {
qWarning() << "Connection attempt not from an Edge: " <<
notification.GetFrom()->ToString();
return;
}
QByteArray brem_id = notification.GetData().toByteArray();
if(brem_id.isEmpty()) {
qWarning() << "Invalid ConnectionEstablished, no id";
return;
}
Id rem_id(brem_id);
if(_local_id < rem_id) {
qWarning() << "We should be sending CM::Connect, not the remote side.";
return;
}
QSharedPointer<Connection> old_con = _con_tab.GetConnection(rem_id);
// XXX if there is an old connection and the node doesn't want it, we need
// to close it
if(old_con) {
qDebug() << "Disconnecting old connection";
old_con->Disconnect();
}
CreateConnection(edge, rem_id);
} | false | false | false | false | false | 0 |
focus_in_event_ModelessOther(GtkWidget *widget,GdkEvent */*event*/,
std::pointer_to_unary_function<int, gboolean> *other_function)
{
XAP_App *pApp=static_cast<XAP_App *>(g_object_get_data(G_OBJECT(widget), "pApp"));
XAP_Frame *pFrame= pApp->getLastFocussedFrame();
if(pFrame == static_cast<XAP_Frame *>(NULL))
{
UT_uint32 nframes = pApp->getFrameCount();
if(nframes > 0 && nframes < 10)
{
pFrame = pApp->getFrame(0);
}
else
{
return FALSE;
}
}
if(pFrame == static_cast<XAP_Frame *>(NULL))
return FALSE;
AV_View * pView = pFrame->getCurrentView();
if(pView!= NULL)
{
pView->focusChange(AV_FOCUS_MODELESS);
(*other_function)(0);
}
return FALSE;
} | false | false | false | false | false | 0 |
upsdrv_initinfo(void)
{
char *v;
/* setup the basics */
dstate_setinfo("ups.mfr", "%s", ((v = getval("mfr")) != NULL) ? v : upstab[upstype].mfr);
dstate_setinfo("ups.model", "%s", ((v = getval("model")) != NULL) ? v : upstab[upstype].model);
if ((v = getval("serial")) != NULL) {
dstate_setinfo("ups.serial", "%s", v);
}
/*
User wants to override the input signal definitions. See also upsdrv_initups().
*/
if ((v = getval("OL")) != NULL) {
parse_input_signals(v, &upstab[upstype].line_ol, &upstab[upstype].val_ol);
upsdebugx(2, "parse_input_signals: OL overridden with %s\n", v);
}
if ((v = getval("LB")) != NULL) {
parse_input_signals(v, &upstab[upstype].line_bl, &upstab[upstype].val_bl);
upsdebugx(2, "parse_input_signals: LB overridden with %s\n", v);
}
} | false | false | false | false | false | 0 |
isFlagged() const {
DebugAssert(!isNull(), "CVC3::Theorem::isFlagged: we are Null");
if (isRefl()) return exprValue()->d_em->getTM()->isFlagged((long)d_expr);
else return thm()->isFlagged();
} | false | false | false | false | false | 0 |
tryPropagateBranch(BasicBlock *bb)
{
for (Instruction *i = bb->getExit(); i && i->op == OP_BRA; i = i->prev) {
BasicBlock *bf = i->asFlow()->target.bb;
if (bf->getInsnCount() != 1)
continue;
FlowInstruction *bra = i->asFlow();
FlowInstruction *rep = bf->getExit()->asFlow();
if (!rep || rep->getPredicate())
continue;
if (rep->op != OP_BRA &&
rep->op != OP_JOIN &&
rep->op != OP_EXIT)
continue;
// TODO: If there are multiple branches to @rep, only the first would
// be replaced, so only remove them after this pass is done ?
// Also, need to check all incident blocks for fall-through exits and
// add the branch there.
bra->op = rep->op;
bra->target.bb = rep->target.bb;
if (bf->cfg.incidentCount() == 1)
bf->remove(rep);
}
} | false | false | false | false | false | 0 |
build_user_pbes(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
u32 num_pbes)
{
struct ocrdma_pbe *pbe;
struct scatterlist *sg;
struct ocrdma_pbl *pbl_tbl = mr->hwmr.pbl_table;
struct ib_umem *umem = mr->umem;
int shift, pg_cnt, pages, pbe_cnt, entry, total_num_pbes = 0;
if (!mr->hwmr.num_pbes)
return;
pbe = (struct ocrdma_pbe *)pbl_tbl->va;
pbe_cnt = 0;
shift = ilog2(umem->page_size);
for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) {
pages = sg_dma_len(sg) >> shift;
for (pg_cnt = 0; pg_cnt < pages; pg_cnt++) {
/* store the page address in pbe */
pbe->pa_lo =
cpu_to_le32(sg_dma_address
(sg) +
(umem->page_size * pg_cnt));
pbe->pa_hi =
cpu_to_le32(upper_32_bits
((sg_dma_address
(sg) +
umem->page_size * pg_cnt)));
pbe_cnt += 1;
total_num_pbes += 1;
pbe++;
/* if done building pbes, issue the mbx cmd. */
if (total_num_pbes == num_pbes)
return;
/* if the given pbl is full storing the pbes,
* move to next pbl.
*/
if (pbe_cnt ==
(mr->hwmr.pbl_size / sizeof(u64))) {
pbl_tbl++;
pbe = (struct ocrdma_pbe *)pbl_tbl->va;
pbe_cnt = 0;
}
}
}
} | false | false | false | false | false | 0 |
isnotblank(char *line,int flag)
{
int c;
if (!strcmp(line,EMPTY_LINE))
return 0;
if (flag)
return 1;
if (!*line)
return 0;
while (*line)
if (*line=='~')
if (!getcolor(&line,&c,1))
return 1;
else
line++;
else
if (isspace(*line))
line++;
else
return 1;
return 0;
} | false | false | false | false | false | 0 |