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 |
|---|---|---|---|---|---|---|
GetStyleString()
{
if (m_pszStyleString == NULL)
{
m_pszStyleString = CPLStrdup(GetPenStyleString());
}
return m_pszStyleString;
} | false | false | false | false | false | 0 |
dir_hier_path(
const char* filename, const char* root, int fanout,
char* path, bool create
) {
char dir[256], dirpath[MAXPATHLEN];
int retval;
if (fanout==0) {
sprintf(path, "%s/%s", root, filename);
return 0;
}
filename_hash(filename, fanout, dir);
sprintf(dirpath, "%s/%s", root, dir);
if (create) {
retval = boinc_mkdir(dirpath);
if (retval && (errno != EEXIST)) {
fprintf(stderr, "boinc_mkdir(%s): %s: errno %d\n",
dirpath, boincerror(retval), errno
);
return ERR_MKDIR;
}
}
sprintf(path, "%s/%s", dirpath, filename);
return 0;
} | false | false | false | false | false | 0 |
dstrcatf(dstr_t *ds, const char *src, ...)
{
va_list ap;
size_t restlen = ds->alloc - ds->len;
size_t srclen;
va_start(ap, src);
srclen = vsnprintf(&ds->data[ds->len], restlen, src, ap);
va_end(ap);
if (srclen >= restlen) {
do {
ds->alloc *= 2;
restlen = ds->alloc - ds->len;
} while (srclen >= restlen);
ds->data = realloc(ds->data, ds->alloc);
va_start(ap, src);
srclen = vsnprintf(&ds->data[ds->len], restlen, src, ap);
va_end(ap);
}
ds->len += srclen;
} | false | false | false | false | true | 1 |
directory_all_unreachable(time_t now)
{
connection_t *conn;
(void)now;
stats_n_seconds_working=0; /* reset it */
while ((conn = connection_get_by_type_state(CONN_TYPE_AP,
AP_CONN_STATE_CIRCUIT_WAIT))) {
entry_connection_t *entry_conn = TO_ENTRY_CONN(conn);
log_notice(LD_NET,
"Is your network connection down? "
"Failing connection to '%s:%d'.",
safe_str_client(entry_conn->socks_request->address),
entry_conn->socks_request->port);
connection_mark_unattached_ap(entry_conn,
END_STREAM_REASON_NET_UNREACHABLE);
}
control_event_general_status(LOG_ERR, "DIR_ALL_UNREACHABLE");
} | false | false | false | false | false | 0 |
reset(bool resetManualBones)
{
BoneList::iterator i;
for (i = mBoneList.begin(); i != mBoneList.end(); ++i)
{
if(!(*i)->isManuallyControlled() || resetManualBones)
(*i)->reset();
}
} | false | false | false | false | false | 0 |
ReportUnexpectedToken(Token::Value token) {
// We don't report stack overflows here, to avoid increasing the
// stack depth even further. Instead we report it after parsing is
// over, in ParseProgram/ParseJson.
if (token == Token::ILLEGAL && stack_overflow_) return;
// Four of the tokens are treated specially
switch (token) {
case Token::EOS:
return ReportMessage("unexpected_eos", Vector<const char*>::empty());
case Token::NUMBER:
return ReportMessage("unexpected_token_number",
Vector<const char*>::empty());
case Token::STRING:
return ReportMessage("unexpected_token_string",
Vector<const char*>::empty());
case Token::IDENTIFIER:
return ReportMessage("unexpected_token_identifier",
Vector<const char*>::empty());
case Token::FUTURE_RESERVED_WORD:
return ReportMessage("unexpected_reserved",
Vector<const char*>::empty());
case Token::FUTURE_STRICT_RESERVED_WORD:
return ReportMessage(top_scope_->is_strict_mode() ?
"unexpected_strict_reserved" :
"unexpected_token_identifier",
Vector<const char*>::empty());
default:
const char* name = Token::String(token);
ASSERT(name != NULL);
ReportMessage("unexpected_token", Vector<const char*>(&name, 1));
}
} | false | false | false | false | false | 0 |
SelectShift(const Instruction *I,
ARM_AM::ShiftOpc ShiftTy) {
// We handle thumb2 mode by target independent selector
// or SelectionDAG ISel.
if (isThumb2)
return false;
// Only handle i32 now.
EVT DestVT = TLI.getValueType(DL, I->getType(), true);
if (DestVT != MVT::i32)
return false;
unsigned Opc = ARM::MOVsr;
unsigned ShiftImm;
Value *Src2Value = I->getOperand(1);
if (const ConstantInt *CI = dyn_cast<ConstantInt>(Src2Value)) {
ShiftImm = CI->getZExtValue();
// Fall back to selection DAG isel if the shift amount
// is zero or greater than the width of the value type.
if (ShiftImm == 0 || ShiftImm >=32)
return false;
Opc = ARM::MOVsi;
}
Value *Src1Value = I->getOperand(0);
unsigned Reg1 = getRegForValue(Src1Value);
if (Reg1 == 0) return false;
unsigned Reg2 = 0;
if (Opc == ARM::MOVsr) {
Reg2 = getRegForValue(Src2Value);
if (Reg2 == 0) return false;
}
unsigned ResultReg = createResultReg(&ARM::GPRnopcRegClass);
if(ResultReg == 0) return false;
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(Opc), ResultReg)
.addReg(Reg1);
if (Opc == ARM::MOVsi)
MIB.addImm(ARM_AM::getSORegOpc(ShiftTy, ShiftImm));
else if (Opc == ARM::MOVsr) {
MIB.addReg(Reg2);
MIB.addImm(ARM_AM::getSORegOpc(ShiftTy, 0));
}
AddOptionalDefs(MIB);
updateValueMap(I, ResultReg);
return true;
} | false | false | false | false | false | 0 |
packed_host_unpack_addr(
const struct packed_host *phost, /* MUST be a pointer */
host_addr_t *addr_ptr)
{
g_assert(phost != NULL);
switch (phost->ha.net) {
case NET_TYPE_IPV4:
if (addr_ptr) {
/*
* Compiler hack alert!
*
* Ensure generated code will NEVER try to access the whole array
* since only the necessary bytes may have been allocated to hold
* the packed representation! When "phost->ha.addr" causes a
* memory fault if the structure is tighly allocated, taking the
* address of the first byte alleviates all problems since we
* know host_addr_peek_ipv4() will behave sanely with the pointer
* it is passed and will not try to access beyond the size of
* the expected IPv4 address.
*
* --RAM, 2011-05-03
*/
*addr_ptr = host_addr_peek_ipv4(&phost->ha.addr[0]);
}
return;
case NET_TYPE_IPV6:
if (addr_ptr) {
*addr_ptr = host_addr_peek_ipv6(phost->ha.addr);
}
return;
case NET_TYPE_LOCAL:
if (addr_ptr) {
*addr_ptr = local_host_addr;
}
return;
case NET_TYPE_NONE:
if (addr_ptr) {
*addr_ptr = zero_host_addr;
}
return;
}
/*
* Because this routine can be used through gnet_host_get_addr() to grab
* the address from a packed structure coming from a DBMW file, we cannot
* abort the execution when faced with an invalid structure (coming from
* the disk).
*/
g_carp("corrupted packed host: unknown net address type %d", phost->ha.net);
*addr_ptr = zero_host_addr;
} | false | false | false | false | false | 0 |
mgslpc_write_room(struct tty_struct *tty)
{
MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
int ret;
if (mgslpc_paranoia_check(info, tty->name, "mgslpc_write_room"))
return 0;
if (info->params.mode == MGSL_MODE_HDLC) {
/* HDLC (frame oriented) mode */
if (info->tx_active)
return 0;
else
return HDLC_MAX_FRAME_SIZE;
} else {
ret = TXBUFSIZE - info->tx_count - 1;
if (ret < 0)
ret = 0;
}
if (debug_level >= DEBUG_LEVEL_INFO)
printk("%s(%d):mgslpc_write_room(%s)=%d\n",
__FILE__, __LINE__, info->device_name, ret);
return ret;
} | false | false | false | false | false | 0 |
instr_typify(struct instrdata *id) {
int i, len = id->instr_cnt, cnt, j, lh;
uint8 *instrs = id->instrs;
uint8 *bts;
if ( id->bts==NULL )
id->bts = galloc(len+1);
bts = id->bts;
for ( i=lh=0; i<len; ++i ) {
bts[i] = bt_instr;
++lh;
if ( instrs[i]==ttf_npushb ) {
/* NPUSHB */
bts[++i] = bt_cnt;
cnt = instrs[i];
for ( j=0 ; j<cnt; ++j)
bts[++i] = bt_byte;
lh += 1+cnt;
} else if ( instrs[i]==ttf_npushw ) {
/* NPUSHW */
bts[++i] = bt_cnt; ++lh;
cnt = instrs[i];
for ( j=0 ; j<cnt; ++j) {
bts[++i] = bt_wordhi;
bts[++i] = bt_wordlo;
}
lh += 1+cnt;
} else if ( (instrs[i]&0xf8) == 0xb0 ) {
/* PUSHB[n] */
cnt = (instrs[i]&7)+1;
for ( j=0 ; j<cnt; ++j)
bts[++i] = bt_byte;
lh += cnt;
} else if ( (instrs[i]&0xf8) == 0xb8 ) {
/* PUSHW[n] */
cnt = (instrs[i]&7)+1;
for ( j=0 ; j<cnt; ++j) {
bts[++i] = bt_wordhi;
bts[++i] = bt_wordlo;
}
lh += cnt;
}
}
bts[i] = bt_impliedreturn;
return( lh );
} | false | false | false | false | false | 0 |
sirf_usp_pcm_runtime_resume(struct device *dev)
{
struct sirf_usp *usp = dev_get_drvdata(dev);
int ret;
ret = clk_prepare_enable(usp->clk);
if (ret) {
dev_err(dev, "clk_enable failed: %d\n", ret);
return ret;
}
sirf_usp_i2s_init(usp);
return 0;
} | false | false | false | false | false | 0 |
fix_file_permissions(const std::string &fname,bool executable) {
mode_t mode = S_IRUSR | S_IWUSR;
if(executable) { mode |= S_IXUSR; };
return (chmod(fname.c_str(),mode) == 0);
} | false | false | false | false | false | 0 |
show_shell_usage (fp, extra)
FILE *fp;
int extra;
{
int i;
char *set_opts, *s, *t;
if (extra)
fprintf (fp, _("GNU bash, version %s-(%s)\n"), shell_version_string (), MACHTYPE);
fprintf (fp, _("Usage:\t%s [GNU long option] [option] ...\n\t%s [GNU long option] [option] script-file ...\n"),
shell_name, shell_name);
fputs (_("GNU long options:\n"), fp);
for (i = 0; long_args[i].name; i++)
fprintf (fp, "\t--%s\n", long_args[i].name);
fputs (_("Shell options:\n"), fp);
fputs (_("\t-irsD or -c command or -O shopt_option\t\t(invocation only)\n"), fp);
for (i = 0, set_opts = 0; shell_builtins[i].name; i++)
if (STREQ (shell_builtins[i].name, "set"))
set_opts = savestring (shell_builtins[i].short_doc);
if (set_opts)
{
s = strchr (set_opts, '[');
if (s == 0)
s = set_opts;
while (*++s == '-')
;
t = strchr (s, ']');
if (t)
*t = '\0';
fprintf (fp, _("\t-%s or -o option\n"), s);
free (set_opts);
}
if (extra)
{
fprintf (fp, _("Type `%s -c \"help set\"' for more information about shell options.\n"), shell_name);
fprintf (fp, _("Type `%s -c help' for more information about shell builtin commands.\n"), shell_name);
fprintf (fp, _("Use the `bashbug' command to report bugs.\n"));
}
} | false | false | false | false | false | 0 |
globus_gram_job_manager_read_callback_contacts(
globus_gram_jobmanager_request_t * request,
FILE * fp)
{
globus_gram_job_manager_contact_t * contact;
globus_list_t ** tmp;
int count;
int rc;
long off1, off2;
int i;
request->client_contacts = NULL;
tmp = &request->client_contacts;
rc = fscanf(fp, "%d%*[\n]", &count);
if (rc != 1)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_read_count;
}
for (i = 0; i < count; i++)
{
contact = malloc(sizeof(globus_gram_job_manager_contact_t));
if (contact == NULL)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED;
goto failed_malloc_contact;
}
off1 = ftell(fp);
if (off1 < 0)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_ftell;
}
rc = fscanf(fp, "%d %*s%*[\n]", &contact->job_state_mask);
if (rc < 1)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_read_mask;
}
off2 = ftell(fp);
if (rc < 0)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_ftell2;
}
rc = fseek(fp, off1, SEEK_SET);
if (rc < 0)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_fseek;
}
contact->contact = malloc(off2-off1+1);
if (contact->contact == NULL)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED;
goto failed_malloc_contact_string_failed;
}
rc = fscanf(fp, "%*d %s%*[\n]", contact->contact);
if (rc < 1)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_READING_STATE_FILE;
goto failed_scan_contact;
}
contact->failed_count = 0;
rc = globus_list_insert(tmp, contact);
if (rc != GLOBUS_SUCCESS)
{
rc = GLOBUS_GRAM_PROTOCOL_ERROR_MALLOC_FAILED;
goto failed_list_insert;
}
tmp = globus_list_rest_ref(*tmp);
}
rc = GLOBUS_SUCCESS;
if (rc != GLOBUS_SUCCESS)
{
failed_list_insert:
failed_scan_contact:
free(contact->contact);
failed_malloc_contact_string_failed:
failed_fseek:
failed_ftell2:
failed_read_mask:
failed_ftell:
free(contact);
failed_malloc_contact:
globus_gram_job_manager_contact_list_free(request);
failed_read_count:
;
}
return rc;
} | false | false | false | false | false | 0 |
onLeftBtnPress(FXObject*,FXSelector,void* ptr){
FXEvent* event=(FXEvent*)ptr;
FXint index;
flags&=~FLAG_TIP;
handle(this,FXSEL(SEL_FOCUS_SELF,0),ptr);
if(isEnabled()){
grab();
flags&=~FLAG_UPDATE;
// First change callback
if(target && target->tryHandle(this,FXSEL(SEL_LEFTBUTTONPRESS,message),ptr)) return 1;
// Locate item
index=getItemAt(event->win_x,event->win_y);
// No item
if(index<0){
return 1;
}
// Previous selection state
state=items[index]->isSelected();
// Change current item
setCurrentItem(index,true);
// Change item selection
switch(options&SELECT_MASK){
case TRACKLIST_EXTENDEDSELECT:
if(event->state&SHIFTMASK){
if(0<=anchor){
selectItem(anchor,true);
extendSelection(index,true);
}
else{
selectItem(index,true);
setAnchorItem(index);
}
}
else if(event->state&CONTROLMASK){
if(!state) selectItem(index,true);
setAnchorItem(index);
}
else{
if(!state){ killSelection(true); selectItem(index,true); }
setAnchorItem(index);
}
break;
case TRACKLIST_MULTIPLESELECT:
case TRACKLIST_SINGLESELECT:
if(!state) selectItem(index,true);
break;
}
// Are we dragging?
if(state && items[index]->isSelected() && items[index]->isDraggable()){
flags|=FLAG_TRYDRAG;
}
flags|=FLAG_PRESSED;
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
getchar_raw (void)
{
SDL_Event event;
int Returnkey = 0;
// keyboard_update (); /* treat all pending keyboard-events */
while ( !Returnkey )
{
SDL_WaitEvent (&event); /* wait for next event */
switch (event.type)
{
case SDL_KEYDOWN:
/*
* here we use the fact that, I cite from SDL_keyboard.h:
* "The keyboard syms have been cleverly chosen to map to ASCII"
* ... I hope that this design feature is portable, and durable ;)
*/
Returnkey = (int) event.key.keysym.sym;
if ( event.key.keysym.mod & KMOD_SHIFT )
Returnkey = toupper( (int)event.key.keysym.sym );
break;
case SDL_JOYBUTTONDOWN:
if (event.jbutton.button == 0)
Returnkey = JOY_BUTTON1;
else if (event.jbutton.button == 1)
Returnkey = JOY_BUTTON2;
else if (event.jbutton.button == 2)
Returnkey = JOY_BUTTON3;
break;
case SDL_MOUSEBUTTONDOWN:
if (event.button.button == SDL_BUTTON_LEFT)
Returnkey = MOUSE_BUTTON1;
else if (event.button.button == SDL_BUTTON_RIGHT)
Returnkey = MOUSE_BUTTON2;
else if (event.button.button == SDL_BUTTON_MIDDLE)
Returnkey = MOUSE_BUTTON3;
else if (event.button.button == SDL_BUTTON_WHEELUP)
Returnkey = MOUSE_WHEELUP;
else if (event.button.button == SDL_BUTTON_WHEELDOWN)
Returnkey = MOUSE_WHEELDOWN;
break;
default:
SDL_PushEvent (&event); /* put this event back into the queue */
update_input (); /* and treat it the usual way */
continue;
}
} /* while(1) */
return ( Returnkey );
} | false | false | false | false | false | 0 |
print_hex(uint32_t msg_len, uint8_t *msg_pt) {
uint8_t *temp = (uint8_t *) malloc(3 * msg_len + 1);
uint8_t *pt = temp;
int i;
for (i = 0; i < msg_len; i++) {
if (i == 0) {
sprintf((char *) pt, "%02x", msg_pt[i]);
pt += 2;
} else if (i % 4 == 0) {
sprintf((char *) pt, ":%02x", msg_pt[i]);
pt += 3;
} else {
sprintf((char *) pt, " %02x", msg_pt[i]);
pt += 3;
}
}
temp[3 * msg_len] = '\0';
PRINT_IMPORTANT("msg='%s'\n", temp);
free(temp);
} | false | true | false | false | false | 1 |
add_to_showcmd(c)
int c;
{
char_u *p;
int old_len;
int extra_len;
int overflow;
#if defined(FEAT_MOUSE)
int i;
static int ignore[] =
{
# ifdef FEAT_GUI
K_VER_SCROLLBAR, K_HOR_SCROLLBAR,
K_LEFTMOUSE_NM, K_LEFTRELEASE_NM,
# endif
K_IGNORE,
K_LEFTMOUSE, K_LEFTDRAG, K_LEFTRELEASE,
K_MIDDLEMOUSE, K_MIDDLEDRAG, K_MIDDLERELEASE,
K_RIGHTMOUSE, K_RIGHTDRAG, K_RIGHTRELEASE,
K_MOUSEDOWN, K_MOUSEUP, K_MOUSELEFT, K_MOUSERIGHT,
K_X1MOUSE, K_X1DRAG, K_X1RELEASE, K_X2MOUSE, K_X2DRAG, K_X2RELEASE,
K_CURSORHOLD,
0
};
#endif
if (!p_sc || msg_silent != 0)
return FALSE;
if (showcmd_visual)
{
showcmd_buf[0] = NUL;
showcmd_visual = FALSE;
}
#if defined(FEAT_MOUSE)
/* Ignore keys that are scrollbar updates and mouse clicks */
if (IS_SPECIAL(c))
for (i = 0; ignore[i] != 0; ++i)
if (ignore[i] == c)
return FALSE;
#endif
p = transchar(c);
old_len = (int)STRLEN(showcmd_buf);
extra_len = (int)STRLEN(p);
overflow = old_len + extra_len - SHOWCMD_COLS;
if (overflow > 0)
mch_memmove(showcmd_buf, showcmd_buf + overflow,
old_len - overflow + 1);
STRCAT(showcmd_buf, p);
if (char_avail())
return FALSE;
display_showcmd();
return TRUE;
} | false | false | false | false | false | 0 |
__add_array (int32_t *dest, int32_t *src, int count)
{
int i = 0;
for (i = 0; i < count; i++) {
dest[i] = hton32 (ntoh32 (dest[i]) + ntoh32 (src[i]));
}
} | false | false | false | false | false | 0 |
lock_screen (GsmInhibitDialog *dialog)
{
GError *error;
error = NULL;
g_spawn_command_line_async ("gnome-screensaver-command --lock", &error);
if (error != NULL) {
g_warning ("Couldn't lock screen: %s", error->message);
g_error_free (error);
}
} | false | false | false | false | false | 0 |
rend_client_rendcirc_has_opened(origin_circuit_t *circ)
{
tor_assert(circ->_base.purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND);
log_info(LD_REND,"rendcirc is open");
/* generate a rendezvous cookie, store it in circ */
if (rend_client_send_establish_rendezvous(circ) < 0) {
return;
}
} | false | false | false | false | false | 0 |
unplug()
{
fakeDevice()->setProperty("isPlugged", false);
emit plugStateChanged(false, fakeDevice()->udi());
} | false | false | false | false | false | 0 |
reset_all()
{
std::list< CL_SharedPtr<CL_EventTrigger_Generic> >::iterator it;
for (it = triggers.begin(); it != triggers.end(); it++) (*it)->reset();
} | false | false | false | false | false | 0 |
stripe_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata)
{
xlator_list_t *trav = NULL;
stripe_local_t *local = NULL;
stripe_private_t *priv = NULL;
int32_t op_errno = EINVAL;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (loc, err);
VALIDATE_OR_GOTO (loc->path, err);
VALIDATE_OR_GOTO (loc->inode, err);
priv = this->private;
trav = this->children;
/* don't delete a directory if any of the subvolume is down */
if (priv->nodes_down) {
op_errno = ENOTCONN;
goto err;
}
/* Initialization */
local = mem_get0 (this->local_pool);
if (!local) {
op_errno = ENOMEM;
goto err;
}
local->op_ret = -1;
frame->local = local;
loc_copy (&local->loc, loc);
local->flags = flags;
local->call_count = priv->child_count;
trav = trav->next; /* skip the first child */
while (trav) {
STACK_WIND (frame, stripe_rmdir_cbk, trav->xlator,
trav->xlator->fops->rmdir, loc, flags, NULL);
trav = trav->next;
}
return 0;
err:
STRIPE_STACK_UNWIND (rmdir, frame, -1, op_errno, NULL, NULL, NULL);
return 0;
} | false | false | false | false | false | 0 |
applyQuarticFit(l_float32 a,
l_float32 b,
l_float32 c,
l_float32 d,
l_float32 e,
l_float32 x,
l_float32 *py)
{
l_float32 x2;
PROCNAME("applyQuarticFit");
if (!py)
return ERROR_INT("&y not defined", procName, 1);
x2 = x * x;
*py = a * x2 * x2 + b * x2 * x + c * x2 + d * x + e;
return 0;
} | false | false | false | false | false | 0 |
genie_tan_complex (NODE_T * p)
{
A68_REAL *im = (A68_REAL *) (STACK_OFFSET (-ALIGNED_SIZE_OF (A68_REAL)));
A68_REAL *re = (A68_REAL *) (STACK_OFFSET (-2 * ALIGNED_SIZE_OF (A68_REAL)));
double r, i;
A68_REAL u, v;
RESET_ERRNO;
r = VALUE (re);
i = VALUE (im);
PUSH_PRIMITIVE (p, r, A68_REAL);
PUSH_PRIMITIVE (p, i, A68_REAL);
genie_sin_complex (p);
POP_OBJECT (p, &v, A68_REAL);
POP_OBJECT (p, &u, A68_REAL);
PUSH_PRIMITIVE (p, r, A68_REAL);
PUSH_PRIMITIVE (p, i, A68_REAL);
genie_cos_complex (p);
VALUE (re) = VALUE (&u);
VALUE (im) = VALUE (&v);
genie_div_complex (p);
MATH_RTE (p, errno != 0, MODE (REAL), NO_TEXT);
} | false | false | false | false | false | 0 |
copy_select_jobinfo(select_jobinfo_t *jobinfo)
{
struct select_jobinfo *rc = NULL;
if (jobinfo == NULL)
;
else if (jobinfo->magic != JOBINFO_MAGIC)
error("copy_jobinfo: jobinfo magic bad");
else {
rc = xmalloc(sizeof(struct select_jobinfo));
rc->dim_cnt = jobinfo->dim_cnt;
memcpy(rc->geometry, jobinfo->geometry, sizeof(rc->geometry));
memcpy(rc->conn_type, jobinfo->conn_type,
sizeof(rc->conn_type));
memcpy(rc->start_loc, jobinfo->start_loc,
sizeof(rc->start_loc));
rc->reboot = jobinfo->reboot;
rc->rotate = jobinfo->rotate;
rc->bg_record = jobinfo->bg_record;
rc->bg_block_id = xstrdup(jobinfo->bg_block_id);
rc->magic = JOBINFO_MAGIC;
rc->mp_str = xstrdup(jobinfo->mp_str);
rc->ionode_str = xstrdup(jobinfo->ionode_str);
rc->block_cnode_cnt = jobinfo->block_cnode_cnt;
rc->cleaning = jobinfo->cleaning;
rc->cnode_cnt = jobinfo->cnode_cnt;
rc->altered = jobinfo->altered;
rc->blrtsimage = xstrdup(jobinfo->blrtsimage);
rc->linuximage = xstrdup(jobinfo->linuximage);
rc->mloaderimage = xstrdup(jobinfo->mloaderimage);
rc->ramdiskimage = xstrdup(jobinfo->ramdiskimage);
if (jobinfo->units_avail)
rc->units_avail = bit_copy(jobinfo->units_avail);
if (jobinfo->units_used)
rc->units_used = bit_copy(jobinfo->units_used);
rc->user_name = xstrdup(jobinfo->user_name);
}
return rc;
} | false | false | false | false | false | 0 |
printDebugLoc(DebugLoc DL, const MachineFunction *MF,
raw_ostream &CommentOS) {
const LLVMContext &Ctx = MF->getFunction()->getContext();
if (!DL.isUnknown()) { // Print source line info.
DIScope Scope(DL.getScope(Ctx));
// Omit the directory, because it's likely to be long and uninteresting.
if (Scope.Verify())
CommentOS << Scope.getFilename();
else
CommentOS << "<unknown>";
CommentOS << ':' << DL.getLine();
if (DL.getCol() != 0)
CommentOS << ':' << DL.getCol();
DebugLoc InlinedAtDL = DebugLoc::getFromDILocation(DL.getInlinedAt(Ctx));
if (!InlinedAtDL.isUnknown()) {
CommentOS << " @[ ";
printDebugLoc(InlinedAtDL, MF, CommentOS);
CommentOS << " ]";
}
}
} | false | false | false | false | false | 0 |
replace_newlines_to_str( const std::string& str_in, const std::string& replace )
{
if( str_in.empty() || replace.empty() ) return str_in;
std::string str_out;
str_out.reserve( str_in.length() );
size_t pos = 0, found = 0;
while( ( found = str_in.find_first_of( "\r\n", pos ) ) != std::string::npos )
{
str_out.append( str_in, pos, ( found - pos ) );
str_out.append( replace );
pos = found + 1;
if( str_in[ found ] == '\r' && str_in[ found + 1 ] == '\n' ) ++pos;
}
str_out.append( str_in, pos, str_in.length() );
return str_out;
} | false | false | false | false | false | 0 |
gmpi_thr_destroy(gmpi_state_t *st)
{
if (st != NULL) {
if (st->tid != (pthread_t)-1) {
pthread_cancel(st->tid);
pthread_join(st->tid, NULL);
}
gmpi_state_destroy(st);
}
return SLURM_SUCCESS;
} | false | false | false | false | false | 0 |
bad_number_method(ScmObj *args, int nargs, ScmGeneric *gf)
{
const char *fn = (const char *)SCM_GENERIC_DATA(gf);
if (nargs == 1) {
Scm_Error("operation %s is not defined on object %S", fn, args[0]);
} else if (nargs == 2) {
Scm_Error("operation %s is not defined between %S and %S",
fn, args[0], args[1]);
} else {
Scm_Error("generic function for %s is called with args %S",
fn, Scm_ArrayToList(args, nargs));
}
return SCM_UNDEFINED;
} | false | false | false | false | false | 0 |
get_contents(memory_file & contents) const
{
if(value != NULL)
contents.set_raw_data(*value);
else
contents.set_raw_data(storage(0));
} | false | false | false | false | false | 0 |
isString()
{
TY nty = next->toBasetype()->ty;
return nty == Tchar || nty == Twchar || nty == Tdchar;
} | false | false | false | false | false | 0 |
ep93xx_spi_read_write(struct ep93xx_spi *espi)
{
struct spi_message *msg = espi->current_msg;
struct spi_transfer *t = msg->state;
/* read as long as RX FIFO has frames in it */
while ((ep93xx_spi_read_u8(espi, SSPSR) & SSPSR_RNE)) {
ep93xx_do_read(espi, t);
espi->fifo_level--;
}
/* write as long as TX FIFO has room */
while (espi->fifo_level < SPI_FIFO_SIZE && espi->tx < t->len) {
ep93xx_do_write(espi, t);
espi->fifo_level++;
}
if (espi->rx == t->len)
return 0;
return -EINPROGRESS;
} | false | false | false | false | false | 0 |
match(InputText* textIn)
{
const uint8_t *input = textIn->fRawInput;
int32_t limit = (textIn->fRawLength / 4) * 4;
int32_t numValid = 0;
int32_t numInvalid = 0;
bool hasBOM = FALSE;
int32_t confidence = 0;
if (getChar(input, 0) == 0x0000FEFFUL) {
hasBOM = TRUE;
}
for(int32_t i = 0; i < limit; i += 4) {
int32_t ch = getChar(input, i);
if (ch < 0 || ch >= 0x10FFFF || (ch >= 0xD800 && ch <= 0xDFFF)) {
numInvalid += 1;
} else {
numValid += 1;
}
}
// Cook up some sort of confidence score, based on presense of a BOM
// and the existence of valid and/or invalid multi-byte sequences.
if (hasBOM && numInvalid==0) {
confidence = 100;
} else if (hasBOM && numValid > numInvalid*10) {
confidence = 80;
} else if (numValid > 3 && numInvalid == 0) {
confidence = 100;
} else if (numValid > 0 && numInvalid == 0) {
confidence = 80;
} else if (numValid > numInvalid*10) {
// Probably corruput UTF-32BE data. Valid sequences aren't likely by chance.
confidence = 25;
}
return confidence;
} | false | false | false | false | false | 0 |
gog_tool_resize_object_render (GogView *view)
{
if (GOG_MANUAL_SIZE_AUTO == gog_object_get_manual_size_mode (view->model))
return;
gog_renderer_draw_grip (view->renderer,
view->allocation.x + view->allocation.w,
view->allocation.y + view->allocation.h);
} | false | false | false | false | false | 0 |
check_day_hour(bitfield *days, bitfield *hours, const time_t check)
{
struct tm *tp, t;
if (!days[INCLUDE] && !days[EXCLUDE] && !hours[INCLUDE] && !hours[EXCLUDE])
return 0;
if ( !(tp = localtime(&check)) )
return 2;
t = *tp; /* save result from further time.h functioncalls */
if ( hours[INCLUDE] && !(hours[INCLUDE] & (1 << t.tm_hour)) )
return 1; /* hour is not included */
if ( hours[EXCLUDE] && hours[EXCLUDE] & (1 << t.tm_hour) )
return 1; /* hour is excluded */
if ( days[INCLUDE] && !isDay(&t, days[INCLUDE], 0) )
return 1; /* day is not included */
if ( days[EXCLUDE] && isDay(&t, days[EXCLUDE], 0) )
return 1; /* day is excluded */
return 0;
} | false | false | false | false | false | 0 |
pkix_pl_KeyComparator_Default(
PKIX_UInt32 *firstKey,
PKIX_UInt32 *secondKey,
PKIX_Boolean *pResult,
void *plContext)
{
/* Assume both keys are pointers to PKIX_UInt32 */
PKIX_UInt32 firstInt, secondInt;
PKIX_ENTER(HASHTABLE, "pkix_pl_KeyComparator_Default");
PKIX_NULLCHECK_THREE(firstKey, secondKey, pResult);
firstInt = *firstKey;
secondInt = *secondKey;
*pResult = (firstInt == secondInt)?PKIX_TRUE:PKIX_FALSE;
PKIX_RETURN(HASHTABLE);
} | false | false | false | false | false | 0 |
process_perf(struct ib_device *ibdev, u8 port,
const struct ib_mad *in_mad,
struct ib_mad *out_mad)
{
struct ib_pma_mad *pmp = (struct ib_pma_mad *)out_mad;
int ret;
*out_mad = *in_mad;
if (pmp->mad_hdr.class_version != 1) {
pmp->mad_hdr.status |= IB_SMP_UNSUP_VERSION;
ret = reply((struct ib_smp *) pmp);
goto bail;
}
switch (pmp->mad_hdr.method) {
case IB_MGMT_METHOD_GET:
switch (pmp->mad_hdr.attr_id) {
case IB_PMA_CLASS_PORT_INFO:
ret = pma_get_classportinfo(pmp, ibdev);
goto bail;
case IB_PMA_PORT_SAMPLES_CONTROL:
ret = pma_get_portsamplescontrol(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_SAMPLES_RESULT:
ret = pma_get_portsamplesresult(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_SAMPLES_RESULT_EXT:
ret = pma_get_portsamplesresult_ext(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS:
ret = pma_get_portcounters(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS_EXT:
ret = pma_get_portcounters_ext(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS_CONG:
ret = pma_get_portcounters_cong(pmp, ibdev, port);
goto bail;
default:
pmp->mad_hdr.status |= IB_SMP_UNSUP_METH_ATTR;
ret = reply((struct ib_smp *) pmp);
goto bail;
}
case IB_MGMT_METHOD_SET:
switch (pmp->mad_hdr.attr_id) {
case IB_PMA_PORT_SAMPLES_CONTROL:
ret = pma_set_portsamplescontrol(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS:
ret = pma_set_portcounters(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS_EXT:
ret = pma_set_portcounters_ext(pmp, ibdev, port);
goto bail;
case IB_PMA_PORT_COUNTERS_CONG:
ret = pma_set_portcounters_cong(pmp, ibdev, port);
goto bail;
default:
pmp->mad_hdr.status |= IB_SMP_UNSUP_METH_ATTR;
ret = reply((struct ib_smp *) pmp);
goto bail;
}
case IB_MGMT_METHOD_TRAP:
case IB_MGMT_METHOD_GET_RESP:
/*
* The ib_mad module will call us to process responses
* before checking for other consumers.
* Just tell the caller to process it normally.
*/
ret = IB_MAD_RESULT_SUCCESS;
goto bail;
default:
pmp->mad_hdr.status |= IB_SMP_UNSUP_METHOD;
ret = reply((struct ib_smp *) pmp);
}
bail:
return ret;
} | false | false | false | false | false | 0 |
WI_initAnimatedBack(void)
{
int i;
anim_t* a;
if (gamemode == commercial)
return;
if (wbs->epsd > 2)
return;
for (i=0;i<NUMANIMS[wbs->epsd];i++)
{
a = &anims[wbs->epsd][i];
// init variables
a->ctr = -1;
// specify the next time to draw it
if (a->type == ANIM_ALWAYS)
a->nexttic = bcnt + 1 + (M_Random()%a->period);
else if (a->type == ANIM_RANDOM)
a->nexttic = bcnt + 1 + a->data2+(M_Random()%a->data1);
else if (a->type == ANIM_LEVEL)
a->nexttic = bcnt + 1;
}
} | false | false | false | false | false | 0 |
hash_pop(bool blocking)
{
struct work *work = NULL, *tmp;
int hc;
mutex_lock(stgd_lock);
if (!HASH_COUNT(staged_work)) {
/* Increase the queue if we reach zero and we know we can reach
* the maximum we're asking for. */
if (work_filled && max_queue < opt_queue) {
max_queue++;
work_filled = false;
}
work_emptied = true;
if (!blocking)
goto out_unlock;
do {
struct timespec then;
struct timeval now;
int rc;
cgtime(&now);
then.tv_sec = now.tv_sec + 10;
then.tv_nsec = now.tv_usec * 1000;
pthread_cond_signal(&gws_cond);
rc = pthread_cond_timedwait(&getq->cond, stgd_lock, &then);
/* Check again for !no_work as multiple threads may be
* waiting on this condition and another may set the
* bool separately. */
if (rc && !no_work) {
no_work = true;
applog(LOG_WARNING, "Waiting for work to be available from pools.");
}
} while (!HASH_COUNT(staged_work));
}
if (no_work) {
applog(LOG_WARNING, "Work available from pools, resuming.");
no_work = false;
}
hc = HASH_COUNT(staged_work);
/* Find clone work if possible, to allow masters to be reused */
if (hc > staged_rollable) {
HASH_ITER(hh, staged_work, work, tmp) {
if (!work_rollable(work))
break;
}
} else
work = staged_work;
HASH_DEL(staged_work, work);
if (work_rollable(work))
staged_rollable--;
/* Signal the getwork scheduler to look for more work */
pthread_cond_signal(&gws_cond);
/* Signal hash_pop again in case there are mutliple hash_pop waiters */
pthread_cond_signal(&getq->cond);
/* Keep track of last getwork grabbed */
last_getwork = time(NULL);
out_unlock:
mutex_unlock(stgd_lock);
return work;
} | false | false | false | true | false | 1 |
camel_folder_count_by_expression (CamelFolder *folder,
const gchar *expression,
GCancellable *cancellable,
GError **error)
{
CamelFolderClass *class;
g_return_val_if_fail (CAMEL_IS_FOLDER (folder), 0);
class = CAMEL_FOLDER_GET_CLASS (folder);
g_return_val_if_fail (class->count_by_expression != NULL, 0);
/* NOTE: that it is upto the callee to CAMEL_FOLDER_REC_LOCK */
return class->count_by_expression (folder, expression, cancellable, error);
} | false | false | false | true | false | 1 |
handle_action(struct linked_server *ls,
const void *data __attr_unused, size_t length __attr_unused)
{
if (ls->connection->client.reconnecting) {
uo_server_speak_console(ls->server,
"please wait until uoproxy finishes reconnecting");
return PA_DROP;
}
return PA_ACCEPT;
} | false | false | false | false | false | 0 |
es_ttf_fontFaces(sdl_data *sd, int len, char *buff)
{
char *bp, *start;
int sendlen;
TTF_Font *font;
long numfaces;
bp = buff;
POPGLPTR(font, bp);
numfaces = TTF_FontFaces(font);
start = bp = sdl_get_temp_buff(sd, 4);
put32be(bp, numfaces);
sendlen = bp - start;
sdl_send(sd, sendlen);
} | false | false | false | false | false | 0 |
setCommon(FaxParam& parm, u_int v)
{
if (v != this->*parm.pv) {
if (0 < v && v < parm.NparmNames) {
if (command("%s %s", parm.cmd, parm.parmNames[v]) != COMPLETE) {
printError("%s", (const char*) lastResponse);
return (false);
}
} else {
printError(NLS::TEXT("Bad %s parameter value %u."), parm.cmd, v);
return (false);
}
this->*parm.pv = v;
}
return (true);
} | false | false | false | false | false | 0 |
ui_pay_manage_dialog_remove(GtkWidget *widget, gpointer user_data)
{
struct ui_pay_manage_dialog_data *data;
guint32 key;
Payee *item;
gint result;
gboolean do_remove;
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
DB( g_print("(ui_pay_manage_dialog) remove (data=%p)\n", data) );
do_remove = TRUE;
key = ui_pay_listview_get_selected_key(GTK_TREE_VIEW(data->LV_pay));
if( key > 0 )
{
if( payee_is_used(key) == TRUE )
{
item = da_pay_get(key);
result = ui_dialog_msg_question(
GTK_WINDOW(data->window),
_("Remove a payee ?"),
_("If you remove '%s', archive and transaction referencing this payee\n"
"will set place to 'no payee'"),
item->name,
NULL
);
if( result == GTK_RESPONSE_YES )
{
payee_move(key, 0);
}
else if( result == GTK_RESPONSE_NO )
{
do_remove = FALSE;
}
}
if( do_remove )
{
da_pay_remove(key);
ui_pay_listview_remove_selected(GTK_TREE_VIEW(data->LV_pay));
data->change++;
}
}
} | false | false | false | false | false | 0 |
write_real_cst (const tree value)
{
if (abi_version_at_least (2))
{
long target_real[4]; /* largest supported float */
char buffer[9]; /* eight hex digits in a 32-bit number */
int i, limit, dir;
tree type = TREE_TYPE (value);
int words = GET_MODE_BITSIZE (TYPE_MODE (type)) / 32;
real_to_target (target_real, &TREE_REAL_CST (value),
TYPE_MODE (type));
/* The value in target_real is in the target word order,
so we must write it out backward if that happens to be
little-endian. write_number cannot be used, it will
produce uppercase. */
if (FLOAT_WORDS_BIG_ENDIAN)
i = 0, limit = words, dir = 1;
else
i = words - 1, limit = -1, dir = -1;
for (; i != limit; i += dir)
{
sprintf (buffer, "%08lx", target_real[i]);
write_chars (buffer, 8);
}
}
else
{
/* In G++ 3.3 and before the REAL_VALUE_TYPE was written out
literally. Note that compatibility with 3.2 is impossible,
because the old floating-point emulator used a different
format for REAL_VALUE_TYPE. */
size_t i;
for (i = 0; i < sizeof (TREE_REAL_CST (value)); ++i)
write_number (((unsigned char *) &TREE_REAL_CST (value))[i],
/*unsigned_p*/ 1,
/*base*/ 16);
G.need_abi_warning = 1;
}
} | false | false | false | false | false | 0 |
peak_pciec_set_leds(struct peak_pciec_card *card, u8 led_mask, u8 s)
{
u8 new_led = card->led_cache;
int i;
/* first check what is to do */
for (i = 0; i < card->chan_count; i++)
if (led_mask & PCA9553_LED(i)) {
new_led &= ~PCA9553_LED_MASK(i);
new_led |= PCA9553_LED_STATE(s, i);
}
/* check if LS0 settings changed, only update i2c if so */
peak_pciec_write_pca9553(card, 5, new_led);
} | false | false | false | false | false | 0 |
note_get_default_ref(const char **out, git_repository *repo)
{
int ret;
git_config *cfg;
*out = NULL;
if (git_repository_config__weakptr(&cfg, repo) < 0)
return -1;
ret = git_config_get_string(out, cfg, "core.notesRef");
if (ret == GIT_ENOTFOUND) {
*out = GIT_NOTES_DEFAULT_REF;
return 0;
}
return ret;
} | false | false | false | false | false | 0 |
Vector_Add( real* dest, real c, real* v, int k )
{
for( --k; k>=0; --k )
dest[k] += c * v[k];
} | false | false | false | false | false | 0 |
refcounted_strmap_free(refcounted_strmap *map)
{
if (!map)
return;
if (git_atomic_dec(&map->refcount) != 0)
return;
free_vars(map->values);
git__free(map);
} | false | false | false | false | false | 0 |
VowelChartDir(wxDC *dc, wxBitmap *bitmap)
{//=================================================
int ix;
int nf;
int count = 0;
SpectSeq *spectseq;
SpectFrame *frame1;
SpectFrame *frame2=NULL;
wxFileName filename;
wxString dir = wxDirSelector(_T("Directory of vowel files"),path_phsource);
if(dir.IsEmpty()) return(0);
wxString path = wxFindFirstFile(dir+_T("/*"),wxFILE);
while (!path.empty())
{
if((spectseq = new SpectSeq) == NULL) break;
filename = wxFileName(path);
wxFileInputStream stream(path);
if(stream.Ok() == FALSE)
{
path = wxFindNextFile();
continue;
}
spectseq->Load(stream);
nf = 0;
frame1 = NULL;
if(spectseq->numframes > 0)
{
frame2 = spectseq->frames[0];
}
for(ix=0; ix<spectseq->numframes; ix++)
{
if(spectseq->frames[ix]->keyframe)
{
nf++;
frame2 = spectseq->frames[ix];
if(frame2->markers & FRFLAG_VOWEL_CENTRE)
frame1 = frame2;
}
}
if((nf >= 3) && (frame1 != NULL))
{
DrawVowel(dc,wxString(filename.GetName()),
frame1->peaks[1].pkfreq, frame1->peaks[2].pkfreq, frame1->peaks[3].pkfreq,
frame2->peaks[1].pkfreq, frame2->peaks[2].pkfreq);
count++;
}
delete spectseq;
path = wxFindNextFile();
}
filename.SetPath(dir);
filename.SetFullName(_T("vowelchart.png"));
bitmap->SaveFile(filename.GetFullPath(),wxBITMAP_TYPE_PNG);
return(count);
} | false | false | false | false | false | 0 |
dundi_helper(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *data, int flag)
{
struct dundi_result results[MAX_RESULTS];
int res;
int x;
int found = 0;
if (!strncasecmp(context, "macro-", 6)) {
if (!chan) {
ast_log(LOG_NOTICE, "Can't use macro mode without a channel!\n");
return -1;
}
/* If done as a macro, use macro extension */
if (!strcasecmp(exten, "s")) {
exten = pbx_builtin_getvar_helper(chan, "ARG1");
if (ast_strlen_zero(exten))
exten = ast_channel_macroexten(chan);
if (ast_strlen_zero(exten))
exten = ast_channel_exten(chan);
if (ast_strlen_zero(exten)) {
ast_log(LOG_WARNING, "Called in Macro mode with no ARG1 or MACRO_EXTEN?\n");
return -1;
}
}
if (ast_strlen_zero(data))
data = "e164";
} else {
if (ast_strlen_zero(data))
data = context;
}
res = dundi_lookup(results, MAX_RESULTS, chan, data, exten, 0);
for (x=0;x<res;x++) {
if (ast_test_flag(results + x, flag))
found++;
}
if (found >= priority)
return 1;
return 0;
} | false | false | false | false | false | 0 |
parse_node_finalize (ParseNode* obj) {
ParseNode * self;
self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PARSE_NODE, ParseNode);
_parser_unref0 (self->parser);
_parse_node_unref0 (self->parent);
_parse_node_unref0 (self->left);
_parse_node_unref0 (self->right);
_lexer_token_unref0 (self->token);
_g_free0 (self->value);
} | false | false | false | false | false | 0 |
clk_byte_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct clk_rcg2 *rcg = to_clk_rcg2(hw);
const struct freq_tbl *f = rcg->freq_tbl;
int index = qcom_find_src_index(hw, rcg->parent_map, f->src);
unsigned long parent_rate, div;
u32 mask = BIT(rcg->hid_width) - 1;
struct clk_hw *p;
if (req->rate == 0)
return -EINVAL;
req->best_parent_hw = p = clk_hw_get_parent_by_index(hw, index);
req->best_parent_rate = parent_rate = clk_hw_round_rate(p, req->rate);
div = DIV_ROUND_UP((2 * parent_rate), req->rate) - 1;
div = min_t(u32, div, mask);
req->rate = calc_rate(parent_rate, 0, 0, 0, div);
return 0;
} | false | false | false | false | false | 0 |
patricia_foreach_remove(patricia_t *pt, patricia_cbr_t cb, void *u)
{
struct remove_ctx ctx;
GSList *sl;
patricia_check(pt);
g_assert(cb);
ctx.sl = NULL;
ctx.last_was_removed = FALSE;
ctx.cb = cb;
ctx.u = u;
ctx.removed = 0;
patricia_traverse(pt,
patricia_traverse_foreach_node, &ctx,
patricia_traverse_foreach_item, &ctx);
sl = ctx.sl;
while (sl) {
struct patricia_node *pn = sl->data;
remove_node(pt, pn);
sl = g_slist_next(sl);
}
gm_slist_free_null(&ctx.sl);
return ctx.removed;
} | false | false | false | false | false | 0 |
hasDeallocation(const Token *first, const Token *last)
{
// This function is called when no simple check was found for assignment
// to self. We are currently looking for a specific sequence of:
// deallocate member ; ... member = allocate
// This check is far from ideal because it can cause false negatives.
// Unfortunately, this is necessary to prevent false positives.
// This check needs to do careful analysis someday to get this
// correct with a high degree of certainty.
for (const Token *tok = first; tok && (tok != last); tok = tok->next())
{
// check for deallocating memory
if (Token::Match(tok, "{|;|, free ( %var%"))
{
const Token *var = tok->tokAt(3);
// we should probably check that var is a pointer in this class
const Token *tok1 = tok->tokAt(4);
while (tok1 && (tok1 != last))
{
if (Token::Match(tok1, "%var% ="))
{
if (tok1->str() == var->str())
return true;
}
tok1 = tok1->next();
}
}
else if (Token::Match(tok, "{|;|, delete [ ] %var%"))
{
const Token *var = tok->tokAt(4);
// we should probably check that var is a pointer in this class
const Token *tok1 = tok->tokAt(5);
while (tok1 && (tok1 != last))
{
if (Token::Match(tok1, "%var% = new %type% ["))
{
if (tok1->str() == var->str())
return true;
}
tok1 = tok1->next();
}
}
else if (Token::Match(tok, "{|;|, delete %var%"))
{
const Token *var = tok->tokAt(2);
// we should probably check that var is a pointer in this class
const Token *tok1 = tok->tokAt(3);
while (tok1 && (tok1 != last))
{
if (Token::Match(tok1, "%var% = new"))
{
if (tok1->str() == var->str())
return true;
}
tok1 = tok1->next();
}
}
}
return false;
} | false | false | false | false | false | 0 |
CalculateWorldTransform() const
{
const FCDSceneNode* parent = GetParent();
if (parent != NULL)
{
//FMMatrix44 tm1 = parent->CalculateWorldTransform();
//FMMatrix44 tm2 = CalculateLocalTransform();
//return tm1 * tm2;
return parent->CalculateWorldTransform() * CalculateLocalTransform();
}
else
{
return CalculateLocalTransform();
}
} | false | false | false | false | false | 0 |
xtransformer_write(transformer_state_t *xstate, const void *buf, size_t bufsize)
{
ssize_t nwrote = transformer_write(xstate, buf, bufsize);
if (nwrote != (ssize_t)bufsize) {
xfunc_die();
}
return nwrote;
} | false | false | false | false | false | 0 |
setCurrentUserIsServerManager()
{
if (WarnAllProcesses)
qWarning() << Q_FUNC_INFO;
d->checkNullUser();
// if (userBase()->database().driverName()=="QSQLITE") {
// return false;
// }
if (!d->m_Sql->database().isOpen()) {
if (!d->m_Sql->database().open()) {
LOG_ERROR(tkTr(Trans::Constants::UNABLE_TO_OPEN_DATABASE_1_ERROR_2).arg(d->m_Sql->database().connectionName().arg(d->m_Sql->database().lastError().text())));
return false;
}
}
QList<IUserListener *> listeners = pluginManager()->getObjects<IUserListener>();
// 1. Ask all listeners to prepare the current user disconnection
foreach(IUserListener *l, listeners) {
if (!l->userAboutToChange())
return false;
}
// 2. Check "in memory" users
QString uuid = ::SERVER_ADMINISTRATOR_UUID;
Internal::UserData *u = d->m_Uuid_UserList.value(uuid, 0);
if (!u) {
u = new Internal::UserData(uuid);
u->setUsualName(tr("Database server administrator"));
u->setRights(Constants::USER_ROLE_USERMANAGER, Core::IUser::AllRights);
u->setModified(false);
d->m_Uuid_UserList.insert(uuid, u);
}
// 3. Ask all listeners for the current user disconnection
if (!d->m_CurrentUserUuid.isEmpty()) {
Q_EMIT userAboutToDisconnect(d->m_CurrentUserUuid);
foreach(IUserListener *l, listeners) {
if (!l->currentUserAboutToDisconnect())
return false;
}
}
Q_EMIT userDisconnected(d->m_CurrentUserUuid);
// 4. Connect new user
Q_EMIT(userAboutToConnect(uuid));
LOG(tr("Setting current user uuid to %1 (su)").arg(uuid));
d->m_CurrentUserRights = Core::IUser::AllRights;
d->m_CurrentUserUuid = uuid;
foreach(Internal::UserData *user, d->m_Uuid_UserList.values()) {
if (!user || user->uuid().isEmpty()) {
// paranoid code -> if one user is corrupt -> clear all
LOG_ERROR("Null user in model");
qDeleteAll(d->m_Uuid_UserList);
d->m_Uuid_UserList.clear();
u = new Internal::UserData(uuid);
u->setUsualName(tr("Database server administrator"));
u->setRights(Constants::USER_ROLE_USERMANAGER, Core::IUser::AllRights);
u->setCurrent(false);
d->m_Uuid_UserList.insert(uuid, u);
break;
}
user->setCurrent(false);
}
u->setCurrent(true);
u->setModified(false);
LOG(tkTr(Trans::Constants::CONNECTED_AS_1).arg(u->fullName()));
foreach(IUserListener *l, listeners)
l->newUserConnected(d->m_CurrentUserUuid);
Q_EMIT userConnected(uuid);
d->checkNullUser();
return true;
} | false | false | false | false | false | 0 |
init_swinst( void )
{
static int initialized = 0;
DEBUGMSGTL(("swinst", "init called\n"));
if (initialized)
return; /* already initialized */
/*
* call arch init code
*/
netsnmp_swinst_arch_init();
} | false | false | false | false | false | 0 |
exit_client(struct Client *client_p, /* The local client originating the
* exit or NULL, if this exit is
* generated by this server for
* internal reasons.
* This will not get any of the
* generated messages. */
struct Client *source_p, /* Client exiting */
struct Client *from, /* Client firing off this Exit,
* never NULL! */
const char *comment /* Reason for the exit */
)
{
hook_data_client_exit hdata;
if(IsClosing(source_p))
return -1;
/* note, this HAS to be here, when we exit a client we attempt to
* send them data, if this generates a write error we must *not* add
* them to the abort list --fl
*/
SetClosing(source_p);
hdata.local_link = client_p;
hdata.target = source_p;
hdata.from = from;
hdata.comment = comment;
call_hook(h_client_exit, &hdata);
if(MyConnect(source_p))
{
/* Local clients of various types */
if(IsPerson(source_p))
return exit_local_client(client_p, source_p, from, comment);
else if(IsServer(source_p))
return exit_local_server(client_p, source_p, from, comment);
/* IsUnknown || IsConnecting || IsHandShake */
else if(!IsReject(source_p))
return exit_unknown_client(client_p, source_p, from, comment);
}
else
{
/* Remotes */
if(IsPerson(source_p))
return exit_remote_client(client_p, source_p, from, comment);
else if(IsServer(source_p))
return exit_remote_server(client_p, source_p, from, comment);
}
return -1;
} | false | false | false | false | false | 0 |
BitBlt_PATINVERT_32bpp(HGDI_DC hdcDest, int nXDest, int nYDest, int nWidth, int nHeight)
{
int x, y;
uint8 *dstp;
uint8 *patp;
uint32 color32;
uint32 *dstp32;
if(hdcDest->brush->style == GDI_BS_SOLID)
{
color32 = gdi_get_color_32bpp(hdcDest, hdcDest->brush->color);
for (y = 0; y < nHeight; y++)
{
dstp32 = (uint32*) gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
if (dstp32 != 0)
{
for (x = 0; x < nWidth; x++)
{
*dstp32 ^= color32;
dstp32++;
}
}
}
}
else
{
for (y = 0; y < nHeight; y++)
{
dstp = gdi_get_bitmap_pointer(hdcDest, nXDest, nYDest + y);
if (dstp != 0)
{
for (x = 0; x < nWidth; x++)
{
patp = gdi_get_brush_pointer(hdcDest, x, y);
*dstp = *patp ^ *dstp;
patp++;
dstp++;
*dstp = *patp ^ *dstp;
patp++;
dstp++;
*dstp = *patp ^ *dstp;
dstp += 2;
}
}
}
}
return 0;
} | false | false | false | false | false | 0 |
_untagged_variant_declaration_free(struct bt_declaration *declaration)
{
struct declaration_untagged_variant *untagged_variant_declaration =
container_of(declaration, struct declaration_untagged_variant, p);
unsigned long i;
bt_free_declaration_scope(untagged_variant_declaration->scope);
g_hash_table_destroy(untagged_variant_declaration->fields_by_tag);
for (i = 0; i < untagged_variant_declaration->fields->len; i++) {
struct declaration_field *declaration_field =
&g_array_index(untagged_variant_declaration->fields,
struct declaration_field, i);
bt_declaration_unref(declaration_field->declaration);
}
g_array_free(untagged_variant_declaration->fields, true);
g_free(untagged_variant_declaration);
} | false | false | false | false | false | 0 |
bnx2_init_5706s_phy(struct bnx2 *bp, int reset_phy)
{
if (reset_phy)
bnx2_reset_phy(bp);
bp->phy_flags &= ~BNX2_PHY_FLAG_PARALLEL_DETECT;
if (BNX2_CHIP(bp) == BNX2_CHIP_5706)
BNX2_WR(bp, BNX2_MISC_GP_HW_CTL0, 0x300);
if (bp->dev->mtu > 1500) {
u32 val;
/* Set extended packet length bit */
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, (val & 0xfff8) | 0x4000);
bnx2_write_phy(bp, 0x1c, 0x6c00);
bnx2_read_phy(bp, 0x1c, &val);
bnx2_write_phy(bp, 0x1c, (val & 0x3ff) | 0xec02);
}
else {
u32 val;
bnx2_write_phy(bp, 0x18, 0x7);
bnx2_read_phy(bp, 0x18, &val);
bnx2_write_phy(bp, 0x18, val & ~0x4007);
bnx2_write_phy(bp, 0x1c, 0x6c00);
bnx2_read_phy(bp, 0x1c, &val);
bnx2_write_phy(bp, 0x1c, (val & 0x3fd) | 0xec00);
}
return 0;
} | false | false | false | false | false | 0 |
deviceSendDiscoverRequest(std::string deviceName, Address address, std::vector<std::string>* returnedNodes, std::vector<std::string>* returnedLeaves, std::vector<std::string>* returnedAttributes)
{
Device* currentDevice;
std::map<std::string, Device*>::iterator it;
std::map<std::string, Plugin*>::iterator it2;
// find the device
it = netDevices->find(deviceName);
if (it != netDevices->end()) {
currentDevice = it->second;
// find the plugin
it2 = netPlugins->find(currentDevice->getPluginToUse());
if (it2 != netPlugins->end() && it2->second != NULL)
return it2->second->deviceSendDiscoverRequest(currentDevice, address, returnedNodes, returnedLeaves, returnedAttributes);
else
std::cout << "DeviceManager::deviceSendDiscoverRequest : no plugin for the device named " << deviceName << std::endl;
}else
std::cout << "DeviceManager::deviceSendDiscoverRequest : no device named " << deviceName << std::endl;
return NO_ANSWER;
} | false | false | false | false | false | 0 |
Track(const Meta::TrackPtr& originalTrack)
: m_track( originalTrack )
, m_album( 0 )
, m_artist( 0 )
, m_composer( 0 )
, m_genre( 0 )
, m_year( 0 )
{
Q_ASSERT( originalTrack );
} | false | false | false | false | false | 0 |
session_logout_task(int sid, queue_task_t *qtask)
{
iscsi_session_t *session;
iscsi_conn_t *conn;
int rc = ISCSI_SUCCESS;
session = session_find_by_sid(sid);
if (!session) {
log_debug(1, "session sid %d not found.\n", sid);
return ISCSI_ERR_SESS_NOT_FOUND;
}
conn = &session->conn[0];
/*
* If syncing up or if this is the initial login and mgmt_ipc
* has not been notified of that result fail the logout request
*/
if (session->notify_qtask ||
((conn->state == ISCSI_CONN_STATE_XPT_WAIT ||
conn->state == ISCSI_CONN_STATE_IN_LOGIN) &&
(session->r_stage == R_STAGE_NO_CHANGE ||
session->r_stage == R_STAGE_SESSION_REDIRECT))) {
invalid_state:
log_error("session in invalid state for logout. "
"Try again later\n");
return ISCSI_ERR_INTERNAL;
}
/* FIXME: logout all active connections */
conn = &session->conn[0];
if (conn->logout_qtask)
goto invalid_state;
qtask->conn = conn;
qtask->rsp.command = MGMT_IPC_SESSION_LOGOUT;
conn->logout_qtask = qtask;
switch (conn->state) {
case ISCSI_CONN_STATE_LOGGED_IN:
if (!session_unbind(session))
return ISCSI_SUCCESS;
/* LLDs that offload login also offload logout */
if (!(session->t->caps & CAP_LOGIN_OFFLOAD)) {
/* unbind is not supported so just do old logout */
if (!iscsi_send_logout(conn))
return ISCSI_SUCCESS;
}
log_error("Could not send logout pdu. Dropping session\n");
/* fallthrough */
default:
rc = session_conn_shutdown(conn, qtask, ISCSI_SUCCESS);
break;
}
return rc;
} | false | false | false | false | false | 0 |
variables() const
{
vector<int> res;
for (Tvarmap::const_iterator it = vars.begin();
it != vars.end(); ++it) {
const Tlagmap& lmap = (*it).second;
for (Tlagmap::const_iterator itt = lmap.begin();
itt != lmap.end(); ++itt)
res.push_back((*itt).second);
}
return res;
} | false | false | false | false | false | 0 |
generate_histogram_rgb (Histogram histogram, gGraphImagePtr img)
{
int x;
int y;
int red;
int green;
int blue;
unsigned char *p_in;
ColorFreq *col;
zero_histogram_rgb (histogram);
for (y = 0; y < img->height; y++)
{
p_in = img->pixels + (y * img->scanline_width);
for (x = 0; x < img->width; x++)
{
/* retrieving a pixel */
if (img->pixel_format == GG_PIXEL_RGB)
{
red = *p_in++;
green = *p_in++;
blue = *p_in++;
}
else if (img->pixel_format == GG_PIXEL_RGBA)
{
red = *p_in++;
green = *p_in++;
blue = *p_in++;
p_in++; /* skipping alpha */
}
else if (img->pixel_format == GG_PIXEL_ARGB)
{
p_in++; /* skipping alpha */
blue = *p_in++;
green = *p_in++;
red = *p_in++;
}
else if (img->pixel_format == GG_PIXEL_BGR)
{
blue = *p_in++;
green = *p_in++;
red = *p_in++;
}
else if (img->pixel_format == GG_PIXEL_BGRA)
{
blue = *p_in++;
green = *p_in++;
red = *p_in++;
p_in++; /* skipping alpha */
}
else if (img->pixel_format == GG_PIXEL_GRAYSCALE)
{
red = *p_in++;
green = red;
blue = red;
}
else if (img->pixel_format == GG_PIXEL_PALETTE)
{
int index = *p_in++;
red = img->palette_red[index];
green = img->palette_green[index];
blue = img->palette_blue[index];
}
col = &histogram[(red >> R_SHIFT) * MR
+ (green >> G_SHIFT) * MG + (blue >> B_SHIFT)];
(*col)++;
}
}
} | false | false | false | false | false | 0 |
get_device_events_reply (DBusPendingCall *pending, void *user_data)
{
DBusMessage *reply = dbus_pending_call_steal_reply (pending);
DBusMessageIter iter, iter_array, iter_struct;
if (!reply)
goto done;
if (strncmp (dbus_message_get_signature (reply), "a(s", 3) != 0)
{
g_warning ("atk-bridge: get_device_events_reply: unknown signature");
goto done;
}
dbus_message_iter_init (reply, &iter);
dbus_message_iter_recurse (&iter, &iter_array);
while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)
{
char *bus_name;
dbus_message_iter_recurse (&iter_array, &iter_struct);
dbus_message_iter_get_basic (&iter_struct, &bus_name);
spi_atk_add_client (bus_name);
dbus_message_iter_next (&iter_array);
}
done:
if (reply)
dbus_message_unref (reply);
if (pending)
dbus_pending_call_unref (pending);
tally_event_reply ();
} | false | false | false | false | false | 0 |
mca_btl_openib_endpoint_cpc_complete(mca_btl_openib_endpoint_t *endpoint)
{
/* If the CPC uses the CTS protocol, then start it up */
if (endpoint->endpoint_local_cpc->cbm_uses_cts) {
int transport_type_ib_p = 0;
/* Post our receives, which will make credit management happy
(i.e., rd_credits will be 0) */
if (OMPI_SUCCESS != mca_btl_openib_endpoint_post_recvs(endpoint)) {
BTL_ERROR(("Failed to post receive buffers"));
mca_btl_openib_endpoint_invoke_error(endpoint);
return;
}
endpoint->endpoint_posted_recvs = true;
/* If this is IB, send the CTS immediately. If this is iWARP,
then only send the CTS if this endpoint was the initiator
of the connection (the receiver will send its CTS when it
receives this side's CTS). Also send the CTS if we already
received the peer's CTS (e.g., if this process was slow to
call cpc_complete(). */
#if defined(HAVE_STRUCT_IBV_DEVICE_TRANSPORT_TYPE)
transport_type_ib_p = (IBV_TRANSPORT_IB == endpoint->endpoint_btl->device->ib_dev->transport_type);
#endif
OPAL_OUTPUT((-1, "cpc_complete to peer %s: is IB %d, initiatior %d, cts received: %d",
(NULL == endpoint->endpoint_proc->proc_ompi->proc_hostname) ?
"unknown" : endpoint->endpoint_proc->proc_ompi->proc_hostname,
transport_type_ib_p,
endpoint->endpoint_initiator,
endpoint->endpoint_cts_received));
if (transport_type_ib_p ||
endpoint->endpoint_initiator ||
endpoint->endpoint_cts_received) {
mca_btl_openib_endpoint_send_cts(endpoint);
/* If we've already got the CTS from the other side, then
mark us as connected */
if (endpoint->endpoint_cts_received) {
OPAL_OUTPUT((-1, "cpc_complete to %s -- already got CTS, so marking endpoint as complete",
(NULL == endpoint->endpoint_proc->proc_ompi->proc_hostname) ?
"unknown" : endpoint->endpoint_proc->proc_ompi->proc_hostname));
mca_btl_openib_endpoint_connected(endpoint);
}
}
OPAL_OUTPUT((-1, "cpc_complete to %s -- done",
(NULL == endpoint->endpoint_proc->proc_ompi->proc_hostname) ?
"unknown" : endpoint->endpoint_proc->proc_ompi->proc_hostname));
return;
}
/* Otherwise, just set the endpoint to "connected" */
mca_btl_openib_endpoint_connected(endpoint);
} | false | false | false | false | false | 0 |
parseString (vString *const string, const int delimiter)
{
boolean end = FALSE;
while (! end)
{
int c = fileGetc ();
if (c == EOF)
end = TRUE;
/*
else if (c == '\\')
{
c = fileGetc(); // This maybe a ' or ". //
vStringPut(string, c);
}
*/
else if (c == delimiter)
end = TRUE;
else
vStringPut (string, c);
}
vStringTerminate (string);
} | false | false | false | false | false | 0 |
xmms_xml_init (xmms_xform_t *xform)
{
gchar *mime, *root_node = NULL;
root_node = get_root_node_name (xform);
if (!root_node) {
XMMS_DBG ("unable to find root node of xml document");
return FALSE;
}
mime = g_strconcat ("application/x-xmms2-xml+", root_node, NULL);
xmms_xform_outdata_type_add (xform,
XMMS_STREAM_TYPE_MIMETYPE,
mime,
XMMS_STREAM_TYPE_END);
g_free (root_node);
g_free (mime);
return TRUE;
} | false | false | false | false | false | 0 |
writeV5Config( const char *configFile,
const boost::shared_ptr<EncFSConfig> &config )
{
ConfigReader cfg;
cfg["creator"] << config->creator;
cfg["subVersion"] << config->subVersion;
cfg["cipher"] << config->cipherIface;
cfg["naming"] << config->nameIface;
cfg["keySize"] << config->keySize;
cfg["blockSize"] << config->blockSize;
string key;
key.assign((char *)config->getKeyData(), config->keyData.size());
cfg["keyData"] << key;
cfg["blockMACBytes"] << config->blockMACBytes;
cfg["blockMACRandBytes"] << config->blockMACRandBytes;
cfg["uniqueIV"] << config->uniqueIV;
cfg["chainedIV"] << config->chainedNameIV;
cfg["externalIV"] << config->externalIVChaining;
return cfg.save( configFile );
} | false | false | false | false | false | 0 |
bsched_free(bsched_t *bs)
{
GList *iter;
bsched_check(bs);
for (iter = bs->sources; iter; iter = g_list_next(iter)) {
bio_source_t *bio = iter->data;
bio_check(bio);
g_assert(bsched_get(bio->bws) == bs);
bio->bws = BSCHED_BWS_INVALID; /* Mark orphan source */
}
gm_list_free_null(&bs->sources);
gm_slist_free_null(&bs->stealers);
HFREE_NULL(bs->name);
bs->magic = 0;
WFREE(bs);
} | false | false | false | false | false | 0 |
ping_members(struct dlm_ls *ls)
{
struct dlm_member *memb;
int error = 0;
list_for_each_entry(memb, &ls->ls_nodes, list) {
error = dlm_recovery_stopped(ls);
if (error)
break;
error = dlm_rcom_status(ls, memb->nodeid, 0);
if (error)
break;
}
if (error)
log_rinfo(ls, "ping_members aborted %d last nodeid %d",
error, ls->ls_recover_nodeid);
return error;
} | false | false | false | false | false | 0 |
mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size){
AVCodecContext *avctx= s->avctx;
Mpeg1Context *s1 = (Mpeg1Context*)s;
/* start frame decoding */
if(s->first_field || s->picture_structure==PICT_FRAME){
if(MPV_frame_start(s, avctx) < 0)
return -1;
ff_er_frame_start(s);
/* first check if we must repeat the frame */
s->current_picture_ptr->repeat_pict = 0;
if (s->repeat_first_field) {
if (s->progressive_sequence) {
if (s->top_field_first)
s->current_picture_ptr->repeat_pict = 4;
else
s->current_picture_ptr->repeat_pict = 2;
} else if (s->progressive_frame) {
s->current_picture_ptr->repeat_pict = 1;
}
}
*s->current_picture_ptr->pan_scan= s1->pan_scan;
}else{ //second field
int i;
if(!s->current_picture_ptr){
av_log(s->avctx, AV_LOG_ERROR, "first field missing\n");
return -1;
}
for(i=0; i<4; i++){
s->current_picture.data[i] = s->current_picture_ptr->data[i];
if(s->picture_structure == PICT_BOTTOM_FIELD){
s->current_picture.data[i] += s->current_picture_ptr->linesize[i];
}
}
}
if (avctx->hwaccel) {
if (avctx->hwaccel->start_frame(avctx, buf, buf_size) < 0)
return -1;
}
// MPV_frame_start will call this function too,
// but we need to call it on every field
if(CONFIG_MPEG_XVMC_DECODER && s->avctx->xvmc_acceleration)
if(ff_xvmc_field_start(s,avctx) < 0)
return -1;
return 0;
} | false | false | false | false | false | 0 |
cb_wbcg_drag_data_received (GtkWidget *widget, GdkDragContext *context,
gint x, gint y, GtkSelectionData *selection_data,
guint info, guint time, WBCGtk *wbcg)
{
gchar *target_type = gdk_atom_name (gtk_selection_data_get_target (selection_data));
if (!strcmp (target_type, "text/uri-list")) { /* filenames from nautilus */
scg_drag_data_received (wbcg_cur_scg (wbcg),
gtk_drag_get_source_widget (context), 0, 0,
selection_data);
} else if (!strcmp (target_type, "GNUMERIC_SHEET")) {
/* The user wants to reorder the sheets but hasn't dropped
* the sheet onto a label. Never mind. We figure out
* where the arrow is currently located and simulate a drop
* on that label. */
GtkWidget *label = wbcg_get_label_for_position (wbcg,
gtk_drag_get_source_widget (context), x);
cb_sheet_label_drag_data_received (label, context, x, y,
selection_data, info, time, wbcg);
} else {
GtkWidget *source_widget = gtk_drag_get_source_widget (context);
if (wbcg_is_local_drag (wbcg, source_widget))
g_printerr ("autoscroll complete - stop it\n");
else
scg_drag_data_received (wbcg_cur_scg (wbcg),
source_widget, 0, 0, selection_data);
}
g_free (target_type);
} | false | false | false | false | false | 0 |
parseMappedAttribute(MappedAttribute* attr)
{
if (attr->name() == SVGNames::clipPathUnitsAttr) {
if (attr->value() == "userSpaceOnUse")
setClipPathUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_USERSPACEONUSE);
else if (attr->value() == "objectBoundingBox")
setClipPathUnitsBaseValue(SVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX);
} else {
if (SVGTests::parseMappedAttribute(attr))
return;
if (SVGLangSpace::parseMappedAttribute(attr))
return;
if (SVGExternalResourcesRequired::parseMappedAttribute(attr))
return;
SVGStyledTransformableElement::parseMappedAttribute(attr);
}
} | false | false | false | false | false | 0 |
SetTrackLen(double trackLen)
{
mTrackLen = trackLen;
int len = mEnv.Count();
for (int i = 0; i < len; i++)
if (mEnv[i]->GetT() > mTrackLen) {
delete mEnv[i];
mEnv.RemoveAt(i);
len--;
i--;
}
} | false | false | false | false | false | 0 |
gadget_to_dummy_hcd(struct usb_gadget *gadget)
{
struct dummy *dum = container_of(gadget, struct dummy, gadget);
if (dum->gadget.speed == USB_SPEED_SUPER)
return dum->ss_hcd;
else
return dum->hs_hcd;
} | false | false | false | false | false | 0 |
sh_dmae_rst(struct sh_dmae_device *shdev)
{
unsigned short dmaor;
unsigned long flags;
spin_lock_irqsave(&sh_dmae_lock, flags);
dmaor = dmaor_read(shdev) & ~(DMAOR_NMIF | DMAOR_AE | DMAOR_DME);
if (shdev->pdata->chclr_present) {
int i;
for (i = 0; i < shdev->pdata->channel_num; i++) {
struct sh_dmae_chan *sh_chan = shdev->chan[i];
if (sh_chan)
channel_clear(sh_chan);
}
}
dmaor_write(shdev, dmaor | shdev->pdata->dmaor_init);
dmaor = dmaor_read(shdev);
spin_unlock_irqrestore(&sh_dmae_lock, flags);
if (dmaor & (DMAOR_AE | DMAOR_NMIF)) {
dev_warn(shdev->shdma_dev.dma_dev.dev, "Can't initialize DMAOR.\n");
return -EIO;
}
if (shdev->pdata->dmaor_init & ~dmaor)
dev_warn(shdev->shdma_dev.dma_dev.dev,
"DMAOR=0x%x hasn't latched the initial value 0x%x.\n",
dmaor, shdev->pdata->dmaor_init);
return 0;
} | false | false | false | false | false | 0 |
objc_add_method_declaration (bool is_class_method, tree decl, tree attributes)
{
if (!objc_interface_context)
{
/* PS: At the moment, due to how the parser works, it should be
impossible to get here. But it's good to have the check in
case the parser changes.
*/
fatal_error ("method declaration not in @interface context");
}
if (flag_objc1_only && attributes)
error_at (input_location, "method attributes are not available in Objective-C 1.0");
objc_decl_method_attributes (&decl, attributes, 0);
objc_add_method (objc_interface_context,
decl,
is_class_method,
objc_method_optional_flag);
} | false | false | false | false | false | 0 |
gda_ddl_creator_set_dest_from_file (GdaDDLCreator *ddlc, const gchar *xml_spec_file, GError **error)
{
g_return_val_if_fail (GDA_IS_DDL_CREATOR (ddlc), FALSE);
g_return_val_if_fail (xml_spec_file && *xml_spec_file, FALSE);
if (ddlc->priv->d_mstruct)
g_object_unref (ddlc->priv->d_mstruct);
ddlc->priv->d_mstruct = (GdaMetaStruct*) g_object_new (GDA_TYPE_META_STRUCT, NULL);
if (!gda_meta_struct_load_from_xml_file (ddlc->priv->d_mstruct, NULL, NULL, xml_spec_file, error) ||
!load_customization (ddlc, xml_spec_file, error)) {
g_object_unref (ddlc->priv->d_mstruct);
ddlc->priv->d_mstruct = NULL;
return FALSE;
}
else
return TRUE;
} | false | false | false | false | false | 0 |
test_dns_name_countlabels(char *test_name, unsigned int exp_nlabels) {
int result;
unsigned int nlabels;
isc_result_t dns_result;
dns_fixedname_t fixed;
dns_name_t *dns_name;
result = T_UNRESOLVED;
t_info("testing %s\n", test_name);
dns_fixedname_init(&fixed);
dns_name = dns_fixedname_name(&fixed);
dns_result = dns_name_fromstring2(dns_name, test_name, NULL, 0, NULL);
if (dns_result == ISC_R_SUCCESS) {
nlabels = dns_name_countlabels(dns_name);
if (nlabels != exp_nlabels) {
t_info("expected %d, got %d\n", exp_nlabels, nlabels);
result = T_FAIL;
} else
result = T_PASS;
} else {
t_info("dns_name_fromstring2 failed, result == %s\n",
dns_result_totext(dns_result));
}
return (result);
} | false | false | false | false | false | 0 |
gnome_scan_param_widget_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
{
g_return_if_fail (GNOME_IS_SCAN_PARAM_WIDGET (object));
switch (prop_id)
{
case PROP_PARAM_SPEC:
/* TODO: Add getter for "param-spec" property here */
break;
case PROP_VALUE:
g_value_set_boxed (value,
gnome_scan_param_widget_get_value (GNOME_SCAN_PARAM_WIDGET (object)));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} | false | false | false | false | false | 0 |
StartMultiplayerGame(PG_MessageObject* c): ConfigurableWindow( NULL, PG_Rect::null, "newmultiplayergame", false ), startButton(false), success(false), newMap(NULL), page(ModeSelection), mode ( 0 ), replay(true), supervisorEnabled(false),
mapParameterEditor(NULL), mapParameterEditorParent(NULL),
allianceSetup(NULL), allianceSetupParent(NULL),
playerSetup(NULL), playerSetupParent(NULL),
emailSetup(NULL), emailSetupParent(NULL),
pbemserver(NULL)
{
setup();
sigClose.connect( SigC::slot( *this, &StartMultiplayerGame::QuitModal ));
PG_RadioButton* b1 = dynamic_cast<PG_RadioButton*>(FindChild(buttonLabels[0], true ));
if ( b1 )
b1->SetPressed();
PG_Button* next = dynamic_cast<PG_Button*>(FindChild("next", true ));
if ( next )
next->sigClick.connect( SigC::slot( *this, &StartMultiplayerGame::nextPage ));
PG_Button* start = dynamic_cast<PG_Button*>(FindChild("start", true ));
if ( start )
start->sigClick.connect( SigC::slot( *this, &StartMultiplayerGame::start ));
PG_Button* qstart = dynamic_cast<PG_Button*>(FindChild("quickstart", true ));
if ( qstart )
qstart->sigClick.connect( SigC::slot( *this, &StartMultiplayerGame::quickstart ));
PG_CheckButton* supervisor = dynamic_cast<PG_CheckButton*>(FindChild("SupervisorOn", true ));
if ( supervisor ) {
if ( supervisorEnabled )
supervisor->SetPressed();
else
supervisor->SetUnpressed();
supervisor->sigClick.connect( SigC::slot( *this, &StartMultiplayerGame::togglesupervisor ));
}
PG_LineEdit* s1 = dynamic_cast<PG_LineEdit*>( FindChild( "SupervisorPlain", true ));
if ( s1 )
s1->SetPassHidden ('*');
PG_CheckButton* cb = dynamic_cast<PG_CheckButton*>( FindChild( "Replay", true ));
if ( cb ) {
if ( replay )
cb->SetPressed( );
else
cb->SetUnpressed();
}
showPage();
showButtons(false,false,true);
loadPBEMServerDefaults();
loadCampaigns();
} | false | false | false | false | false | 0 |
showclient(rule)
const struct rule_t *rule;
{
char addr[MAXRULEADDRSTRING];
slog(LOG_INFO, "client-rule #%u, line #%lu",
rule->number, rule->linenumber);
slog(LOG_INFO, "verdict: %s", verdict2string(rule->verdict));
slog(LOG_INFO, "src: %s",
ruleaddress2string(&rule->src, addr, sizeof(addr)));
slog(LOG_INFO, "dst: %s",
ruleaddress2string(&rule->dst, addr, sizeof(addr)));
showmethod(rule->state.methodc, rule->state.methodv);
showuser(rule->user);
#if HAVE_PAM
if (*rule->pamservicename != NUL)
slog(LOG_INFO, "pamservicename: %s", rule->pamservicename);
#endif /* HAVE_PAM */
if (rule->bw != NULL)
slog(LOG_INFO, "max bandwidth to use: %ld B/s", rule->bw->maxbps);
if (rule->ss != NULL)
slog(LOG_INFO, "max sessions: %d", rule->ss->maxsessions);
showlog(&rule->log);
#if HAVE_LIBWRAP
if (*rule->libwrap != NUL)
slog(LOG_INFO, "libwrap: %s", rule->libwrap);
#endif /* HAVE_LIBWRAP */
} | false | false | false | false | false | 0 |
ioc_release_fn(struct work_struct *work)
{
struct io_context *ioc = container_of(work, struct io_context,
release_work);
unsigned long flags;
/*
* Exiting icq may call into put_io_context() through elevator
* which will trigger lockdep warning. The ioc's are guaranteed to
* be different, use a different locking subclass here. Use
* irqsave variant as there's no spin_lock_irq_nested().
*/
spin_lock_irqsave_nested(&ioc->lock, flags, 1);
while (!hlist_empty(&ioc->icq_list)) {
struct io_cq *icq = hlist_entry(ioc->icq_list.first,
struct io_cq, ioc_node);
struct request_queue *q = icq->q;
if (spin_trylock(q->queue_lock)) {
ioc_destroy_icq(icq);
spin_unlock(q->queue_lock);
} else {
spin_unlock_irqrestore(&ioc->lock, flags);
cpu_relax();
spin_lock_irqsave_nested(&ioc->lock, flags, 1);
}
}
spin_unlock_irqrestore(&ioc->lock, flags);
kmem_cache_free(iocontext_cachep, ioc);
} | false | false | false | false | false | 0 |
fileio_readall(fileio *self)
{
#ifdef HAVE_FSTAT
struct stat st;
Py_off_t pos, end;
#endif
PyObject *result;
Py_ssize_t total = 0;
int n;
size_t newsize;
if (self->fd < 0)
return err_closed();
if (!_PyVerify_fd(self->fd))
return PyErr_SetFromErrno(PyExc_IOError);
result = PyBytes_FromStringAndSize(NULL, SMALLCHUNK);
if (result == NULL)
return NULL;
#ifdef HAVE_FSTAT
#if defined(MS_WIN64) || defined(MS_WINDOWS)
pos = _lseeki64(self->fd, 0L, SEEK_CUR);
#else
pos = lseek(self->fd, 0L, SEEK_CUR);
#endif
if (fstat(self->fd, &st) == 0)
end = st.st_size;
else
end = (Py_off_t)-1;
#endif
while (1) {
#ifdef HAVE_FSTAT
newsize = new_buffersize(self, total, pos, end);
#else
newsize = new_buffersize(self, total);
#endif
if (newsize > PY_SSIZE_T_MAX || newsize <= 0) {
PyErr_SetString(PyExc_OverflowError,
"unbounded read returned more bytes "
"than a Python string can hold ");
Py_DECREF(result);
return NULL;
}
if (PyBytes_GET_SIZE(result) < (Py_ssize_t)newsize) {
if (_PyBytes_Resize(&result, newsize) < 0) {
if (total == 0) {
Py_DECREF(result);
return NULL;
}
PyErr_Clear();
break;
}
}
Py_BEGIN_ALLOW_THREADS
errno = 0;
n = read(self->fd,
PyBytes_AS_STRING(result) + total,
newsize - total);
Py_END_ALLOW_THREADS
if (n == 0)
break;
if (n < 0) {
if (total > 0)
break;
if (errno == EAGAIN) {
Py_DECREF(result);
Py_RETURN_NONE;
}
Py_DECREF(result);
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
}
total += n;
#ifdef HAVE_FSTAT
pos += n;
#endif
}
if (PyBytes_GET_SIZE(result) > total) {
if (_PyBytes_Resize(&result, total) < 0) {
/* This should never happen, but just in case */
Py_DECREF(result);
return NULL;
}
}
return result;
} | false | false | false | false | false | 0 |
ParseAlloc(Instruction *&Inst, PerFunctionState &PFS) {
Value *Size = 0;
LocTy SizeLoc;
unsigned Alignment = 0;
Type *Ty = 0;
if (ParseType(Ty)) return true;
bool AteExtraComma = false;
if (EatIfPresent(lltok::comma)) {
if (Lex.getKind() == lltok::kw_align) {
if (ParseOptionalAlignment(Alignment)) return true;
} else if (Lex.getKind() == lltok::MetadataVar) {
AteExtraComma = true;
} else {
if (ParseTypeAndValue(Size, SizeLoc, PFS) ||
ParseOptionalCommaAlign(Alignment, AteExtraComma))
return true;
}
}
if (Size && !Size->getType()->isIntegerTy())
return Error(SizeLoc, "element count must have integer type");
Inst = new AllocaInst(Ty, Size, Alignment);
return AteExtraComma ? InstExtraComma : InstNormal;
} | false | false | false | false | false | 0 |
get_traj(FILE *traj_fd, long long *traj_size, float *delay, long which)
#else
long long
get_traj(traj_fd, traj_size, delay, which)
FILE *traj_fd;
long long *traj_size;
float *delay;
long which;
#endif
{
long long traj_offset = 0;
long long tmp2 = 0;
int tmp = 0;
int tokens;
int ret=0;
char *ret1,*where;
char buf[200];
char sbuf[200];
int got_line;
got_line=0;
while(got_line==0)
{
tokens=0;
ret1=fgets(buf,200,traj_fd);
if(ret1==(char *)0)
{
printf("\n\n\tEarly end of telemetry file. Results not accurate.\n");
signal_handler();
}
where=(char *)&buf[0];
strcpy(sbuf,buf);
if((*where=='#') || (*where=='\n'))
continue;
tokens++;
strtok(where," ");
while( (char *)(strtok( (char *)0," ")) != (char *)0)
{
tokens++;
}
got_line=1;
}
if(tokens == 3)
{
#ifdef NO_PRINT_LLD
ret=sscanf(sbuf,"%ld %ld %d\n",&traj_offset,&tmp2,&tmp);
#else
ret=sscanf(sbuf,"%lld %lld %d\n",&traj_offset,&tmp2,&tmp);
#endif
/*printf("\nReading %s trajectory with %d items\n",which?"write":"read",tokens);*/
*traj_size=tmp2;
*delay= ((float)tmp/1000);
}
if(tokens == 2)
{
#ifdef NO_PRINT_LLD
ret=sscanf(sbuf,"%ld %ld\n",&traj_offset,traj_size);
#else
ret=sscanf(sbuf,"%lld %lld\n",&traj_offset,traj_size);
#endif
*delay=compute_time;
/*printf("\nReading %s trajectory with %d items\n",which?"write":"read",tokens);*/
}
if((tokens != 2) && (tokens !=3))
{
printf("\n\tInvalid entry in telemetry file. > %s <\n",sbuf);
exit(178);
}
if(ret==EOF)
{
printf("\n\n\tEarly end of telemetry file. Results not accurate.\n");
signal_handler();
}
#ifdef DEBUG
#ifdef NO_PRINT_LLD
if(!silent) printf("\nOffset %lld Size %ld Compute delay %f\n",traj_offset, *traj_size,*delay);
#else
if(!silent) printf("\nOffset %lld Size %lld Compute delay %f\n",traj_offset, *traj_size,*delay);
#endif
#endif
return(traj_offset);
} | false | false | false | false | false | 0 |
Curl_ssl_config_matches(struct ssl_config_data* data,
struct ssl_config_data* needle)
{
if((data->version == needle->version) &&
(data->verifypeer == needle->verifypeer) &&
(data->verifyhost == needle->verifyhost) &&
safe_strequal(data->CApath, needle->CApath) &&
safe_strequal(data->CAfile, needle->CAfile) &&
safe_strequal(data->random_file, needle->random_file) &&
safe_strequal(data->egdsocket, needle->egdsocket) &&
safe_strequal(data->cipher_list, needle->cipher_list))
return TRUE;
return FALSE;
} | false | false | false | false | false | 0 |
u_free_uhp(uhp)
u_header_T *uhp;
{
u_entry_T *nuep;
u_entry_T *uep;
uep = uhp->uh_entry;
while (uep != NULL)
{
nuep = uep->ue_next;
u_freeentry(uep, uep->ue_size);
uep = nuep;
}
vim_free(uhp);
} | false | false | false | false | false | 0 |
set (const ACEXML_URL_Addr &addr)
{
ACE_OS::free (this->path_name_);
ACE_OS::free (this->addr_string_);
if (this->ACE_INET_Addr::set (addr) == -1)
return -1;
else
{
if (addr.path_name_)
ACE_ALLOCATOR_RETURN (this->path_name_,
ACE_OS::strdup (addr.path_name_),
-1);
if (addr.addr_string_)
ACE_ALLOCATOR_RETURN (this->addr_string_,
ACE_OS::strdup (addr.addr_string_),
-1);
this->addr_string_len_ = addr.addr_string_len_;
return 0;
}
} | false | false | false | false | false | 0 |
gwy_delaunay_add_point(GwyDelaunayVertex *p, GwyDelaunayMesh *m)
{
gint i, j, k, attempt;
gdouble o;
simplex *new, *s, **update;
// If the list arguments are NULL, then we create local lists.
// Otherwise, we return the list of updates we did.
// This is so that we can easily perform point removal.
// This will set a list of conflicting non-Delaunay simplicies in the mesh
// structure.
updateConflictingSimplicies(p,m);
// We now have a list of simplicies which contain the point p within
// their circum-sphere.
// We now want to create a new tetrahedralisation in the polytope formed
// by removing the old simplicies.
// We know which faces we should connect to our point, by deleting every
// face which is shared by another conflicting simplex.
for (j=0; j< arrayListSize(m->conflicts); j++)
{
s = getFromArrayList(m->conflicts,j);
// Now go through each face, if it is not shared by any other face
// on the stack, we will create a new simplex which is joined to
// our point.
for (i=0; i<4; i++)
{
GwyDelaunayVertex *v1, *v2, *v3, *v4;
getFaceVerticies(s, i, &v1, &v2, &v3, &v4);
// Now, check to see whether or not this face is shared with any
// other simplicies in the list.
if (! arrayListContains(m->conflicts, s->s[i]))
{
// We will create a new simplex connecting this face to our point.
new = newSimplex(m);
new->p[0] = v1;
new->p[1] = v2;
new->p[2] = v3;
new->p[3] = p;
attempt = 0;
// Detect degenerecies resulting from coplanar points.
o = orient3dfast(v1->v, v2->v, v3->v, p->v);
if (o<=0)
{
m->coplanar_degenerecies ++;
while (o<=0)
{
randomPerturbation(p, attempt);
o = orient3dfast(v1->v, v2->v, v3->v, p->v);
attempt ++;
}
// We are going to have to start adding this point again.
// That means removing all changes we have done so far.
undoNeighbourUpdates(m->neighbourUpdates);
for (k=0; k<arrayListSize(m->updates); k++)
{
removeSimplexFromMesh(m, getFromArrayList(m->updates,k));
push(m->deadSimplicies, getFromArrayList(m->updates, k));
}
emptyArrayList(m->updates);
emptyArrayList(m->conflicts);
// Start adding this point again, now that we have
// (hopefully) removed the coplanar dependencies.
gwy_delaunay_add_point(p,m);
return;
}
// We know that every successful face will be pointing
// outwards from the point. We can therefore directly set the neighbour
// to be the same as the one that was with this face before.
new->s[0] = s->s[i];
// update, storing each neighbour pointer change we make.
update = swapSimplexNeighbour(s->s[i], s, new);
pushNeighbourUpdate(m->neighbourUpdates, update, s);
// This is a list of all the new tets created whilst adding
// this point.
addToArrayList(m->updates, new);
addSimplexToMesh(m, new);
}
}
}
// Connect up the ginternal neighbours of all our new simplicies.
setNeighbours(m->updates);
// Remove the conflicting simplicies.
for (i=0; i<arrayListSize(m->conflicts); i++)
{
s = getFromArrayList(m->conflicts, i);
removeSimplexFromMesh(m,s);
}
} | false | false | false | false | false | 0 |
NewSet( void )
#else
NewSet( )
#endif
{
setnum++;
if ( setnum==BitsPerWord ) /* is current setwd full? */
{
DumpSetWd(); NewSetWd(); setnum = 0;
}
} | false | false | false | false | false | 0 |
explain_buffer_errno_wait_explanation(explain_string_buffer_t *sb,
int errnum, const char *syscall_name, int *status)
{
/*
* http://www.opengroup.org/onlinepubs/009695399/functions/wait.html
*/
(void)status;
switch (errnum)
{
case ECHILD:
explain_buffer_no_outstanding_children(sb);
explain_buffer_note_sigchld(sb);
break;
case EFAULT:
explain_buffer_efault(sb, "status");
break;
case EINTR:
explain_buffer_eintr(sb, syscall_name);
break;
default:
explain_buffer_errno_generic(sb, errnum, syscall_name);
break;
}
} | false | false | false | false | false | 0 |
ride()
{
if (ride_) return ride_;
// open the ride file
QFile file(path + "/" + fileName);
ride_ = RideFileFactory::instance().openRideFile(main, file, errors_);
if (ride_ == NULL) return NULL; // failed to read ride
setDirty(false); // we're gonna use on-disk so by
// definition it is clean - but do it *after*
// we read the file since it will almost
// certainly be referenced by consuming widgets
// stay aware of state changes to our ride
// MainWindow saves and RideFileCommand modifies
connect(ride_, SIGNAL(modified()), this, SLOT(modified()));
connect(ride_, SIGNAL(saved()), this, SLOT(saved()));
connect(ride_, SIGNAL(reverted()), this, SLOT(reverted()));
return ride_;
} | 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.