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 |
|---|---|---|---|---|---|---|
e1000e_get_variants_82571(struct e1000_adapter *adapter)
{
struct e1000_hw *hw = &adapter->hw;
static int global_quad_port_a; /* global port a indication */
struct pci_device *pdev = adapter->pdev;
u16 eeprom_data = 0;
int is_port_b = er32(STATUS) & E1000_STATUS_FUNC_1;
/* tag quad port adapters first, it's used below */
switch (pdev->device) {
case E1000_DEV_ID_82571EB_QUAD_COPPER:
case E1000_DEV_ID_82571EB_QUAD_FIBER:
case E1000_DEV_ID_82571EB_QUAD_COPPER_LP:
case E1000_DEV_ID_82571PT_QUAD_COPPER:
adapter->flags |= FLAG_IS_QUAD_PORT;
/* mark the first port */
if (global_quad_port_a == 0)
adapter->flags |= FLAG_IS_QUAD_PORT_A;
/* Reset for multiple quad port adapters */
global_quad_port_a++;
if (global_quad_port_a == 4)
global_quad_port_a = 0;
break;
default:
break;
}
switch (adapter->hw.mac.type) {
case e1000_82571:
/* these dual ports don't have WoL on port B at all */
if (((pdev->device == E1000_DEV_ID_82571EB_FIBER) ||
(pdev->device == E1000_DEV_ID_82571EB_SERDES) ||
(pdev->device == E1000_DEV_ID_82571EB_COPPER)) &&
(is_port_b))
adapter->flags &= ~FLAG_HAS_WOL;
/* quad ports only support WoL on port A */
if (adapter->flags & FLAG_IS_QUAD_PORT &&
(!(adapter->flags & FLAG_IS_QUAD_PORT_A)))
adapter->flags &= ~FLAG_HAS_WOL;
/* Does not support WoL on any port */
if (pdev->device == E1000_DEV_ID_82571EB_SERDES_QUAD)
adapter->flags &= ~FLAG_HAS_WOL;
break;
case e1000_82573:
if (pdev->device == E1000_DEV_ID_82573L) {
if (e1000e_read_nvm(&adapter->hw, NVM_INIT_3GIO_3, 1,
&eeprom_data) < 0)
break;
if (!(eeprom_data & NVM_WORD1A_ASPM_MASK)) {
adapter->flags |= FLAG_HAS_JUMBO_FRAMES;
adapter->max_hw_frame_size = DEFAULT_JUMBO;
}
}
break;
default:
break;
}
return 0;
} | false | false | false | false | false | 0 |
panels_can_be_displayed()
{
if (tty_lines >= 7)
{
if (two_panel_mode)
{
if (tty_columns >= 6 * 2)
return ON;
}
else
if (tty_columns >= 6)
return ON;
}
return OFF;
} | false | false | false | false | false | 0 |
min_expand (MatchState *ms, const char *s,
const char *p, const char *ep) {
for (;;) {
const char *res = match(ms, s, ep+1);
if (res != NULL)
return res;
else if (singlematch(ms, s, p, ep))
s++; /* try with one more repetition */
else return NULL;
}
} | false | false | false | false | false | 0 |
valid_entry(Level *level)
{
gboolean result=FALSE;
gchar *error;
GtkWidget *dialog;
g_assert(level->questions);
g_assert(level->answers);
if ( strlen(level->questions) == 0 )
{
error = g_strdup (_("Questions cannot be empty.") );
goto error;
}
/* Now check all chars in questions are in answers */
guint n_answers = g_utf8_strlen (level->answers, -1);
guint n_questions = g_utf8_strlen (level->questions, -1);
if ( n_answers == 0 )
{
error = g_strdup( _("Answers cannot be empty.") );
goto error;
}
if ( n_answers > MAX_N_ANSWER )
{
error = g_strdup_printf( _("Too many characters in the Answer (maximum is %d)."),
MAX_N_ANSWER );
goto error;
}
/* The shuffle is not important, we are using it to get an array of chars */
gchar **answers = shuffle_utf8(level->answers);
gchar **questions = shuffle_utf8(level->questions);
guint a;
guint q;
for ( q = 0; q < n_questions; q++)
{
gboolean found = FALSE;
for ( a = 0; a < n_answers; a++)
{
if ( strcmp( answers[a], questions[q] ) == 0 )
{
found = TRUE;
break;
}
}
if ( ! found )
{
error = g_strdup ( _("All the characters in Questions must also be in the Answers.") );
g_strfreev(questions);
g_strfreev(answers);
goto error;
}
}
g_strfreev(questions);
g_strfreev(answers);
return TRUE;
error:
dialog = \
gtk_message_dialog_new (NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Invalid entry:\n"
"At level %d, Questions '%s' / Answers '%s'\n%s"),
level->level, level->questions, level->answers,
error);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_free(error);
return result;
} | false | false | false | false | false | 0 |
strcat_oids( char *buf, char *prefix, char **oids, int schema_ds4x_compat )
{
char *p;
int i;
if ( NULL != oids && NULL != oids[0] ) {
p = buf + strlen(buf); /* skip past existing content */
if ( NULL == oids[1] && !schema_ds4x_compat ) {
sprintf( p, "%s %s ", prefix, oids[0] ); /* just one oid */
} else {
sprintf( p, "%s ( ", prefix ); /* oidlist */
for ( i = 0; oids[i] != NULL; ++i ) {
if ( i > 0 ) {
strcat( p, " $ " );
}
strcat( p, oids[i] );
}
strcat( p, " ) " );
}
}
} | false | true | false | false | false | 1 |
glade_clipboard_add (GladeClipboard *clipboard, GList *widgets)
{
GladeWidget *widget;
GList *list;
/*
* Clear selection for the new widgets.
*/
glade_clipboard_selection_clear (clipboard);
/*
* Add the widgets to the list of children.
*/
for (list = widgets; list && list->data; list = list->next)
{
widget = list->data;
clipboard->widgets =
g_list_prepend (clipboard->widgets,
g_object_ref (G_OBJECT (widget)));
glade_clipboard_selection_add (clipboard, widget);
}
} | false | false | false | false | false | 0 |
FinePortamentoDown(MODCHANNEL *pChn, UINT param)
//---------------------------------------------------------------
{
if (m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))
{
if (param) pChn->nOldFinePortaUpDown = param; else param = pChn->nOldFinePortaUpDown;
}
if (m_dwSongFlags & SONG_FIRSTTICK)
{
if ((pChn->nPeriod) && (param))
{
if ((m_dwSongFlags & SONG_LINEARSLIDES) && (!(m_nType & (MOD_TYPE_XM|MOD_TYPE_MT2))))
{
pChn->nPeriod = _muldivr(pChn->nPeriod, LinearSlideUpTable[param & 0x0F], 65536);
} else
{
pChn->nPeriod += (int)(param * 4);
}
if (pChn->nPeriod > 0xFFFF) pChn->nPeriod = 0xFFFF;
}
}
} | false | false | false | false | false | 0 |
param_is_printable(int i)const
{
switch (MODEL_BUILT_IN_DIODE::param_count() - 1 - i) {
case 0: return (false);
case 1: return (true);
case 2: return (true);
case 3: return (true);
case 4: return (true);
case 5: return (true);
case 6: return (true);
case 7: return (true);
case 8: return (true);
case 9: return (true);
case 10: return (true);
case 11: return (kf.has_hard_value());
case 12: return (af.has_hard_value());
case 13: return (true);
case 14: return (bv.has_hard_value());
case 15: return (has_good_value(bv));
case 16: return (cjsw != 0.);
case 17: return (cjsw != 0.);
case 18: return (cjsw != 0.);
case 19: return (gparallel != 0.);
case 20: return (!(flags & USE_OPT));
case 21: return (mos_level.has_hard_value());
default: return false;
}
} | false | false | false | false | false | 0 |
__ecereRegisterModule_CallStackView(struct __ecereNameSpace__ecere__com__Instance * module)
{
struct __ecereNameSpace__ecere__com__Class * class;
class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "CallStackView", "ecere::gui::Window", sizeof(struct CallStackView), 0, __ecereConstructor_CallStackView, __ecereDestructor_CallStackView, module, 2, 1);
if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + 24)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + 24)))->application && class)
__ecereClass_CallStackView = class;
__ecereNameSpace__ecere__com__eClass_AddVirtualMethod(class, "OnSelectFrame", "void OnSelectFrame(int frameIndex)", 0, 2);
__ecereNameSpace__ecere__com__eClass_AddVirtualMethod(class, "OnToggleBreakpoint", "void OnToggleBreakpoint()", 0, 2);
} | false | false | false | false | false | 0 |
update_view_title(struct view *view)
{
char buf[SIZEOF_STR];
char state[SIZEOF_STR];
size_t bufpos = 0, statelen = 0;
WINDOW *window = display[0] == view ? display_title[0] : display_title[1];
assert(view_is_displayed(view));
if (!view_has_flags(view, VIEW_CUSTOM_STATUS) && view->lines) {
unsigned int view_lines = view->offset + view->height;
unsigned int lines = view->lines
? MIN(view_lines, view->lines) * 100 / view->lines
: 0;
string_format_from(state, &statelen, " - %s %d of %d (%d%%)",
view->ops->type,
view->lineno + 1,
view->lines,
lines);
}
if (view->pipe) {
time_t secs = time(NULL) - view->start_time;
/* Three git seconds are a long time ... */
if (secs > 2)
string_format_from(state, &statelen, " loading %lds", secs);
}
string_format_from(buf, &bufpos, "[%s]", view->name);
if (*view->ref && bufpos < view->width) {
size_t refsize = strlen(view->ref);
size_t minsize = bufpos + 1 + /* abbrev= */ 7 + 1 + statelen;
if (minsize < view->width)
refsize = view->width - minsize + 7;
string_format_from(buf, &bufpos, " %.*s", (int) refsize, view->ref);
}
if (statelen && bufpos < view->width) {
string_format_from(buf, &bufpos, "%s", state);
}
if (view == display[current_view])
wbkgdset(window, get_line_attr(LINE_TITLE_FOCUS));
else
wbkgdset(window, get_line_attr(LINE_TITLE_BLUR));
mvwaddnstr(window, 0, 0, buf, bufpos);
wclrtoeol(window);
wnoutrefresh(window);
} | false | false | false | false | false | 0 |
read_cis_cache(struct pcmcia_socket *s, int attr, u_int addr,
size_t len, void *ptr)
{
struct cis_cache_entry *cis;
int ret = 0;
if (s->state & SOCKET_CARDBUS)
return -EINVAL;
mutex_lock(&s->ops_mutex);
if (s->fake_cis) {
if (s->fake_cis_len >= addr+len)
memcpy(ptr, s->fake_cis+addr, len);
else {
memset(ptr, 0xff, len);
ret = -EINVAL;
}
mutex_unlock(&s->ops_mutex);
return ret;
}
list_for_each_entry(cis, &s->cis_cache, node) {
if (cis->addr == addr && cis->len == len && cis->attr == attr) {
memcpy(ptr, cis->cache, len);
mutex_unlock(&s->ops_mutex);
return 0;
}
}
ret = pcmcia_read_cis_mem(s, attr, addr, len, ptr);
if (ret == 0) {
/* Copy data into the cache */
cis = kmalloc(sizeof(struct cis_cache_entry) + len, GFP_KERNEL);
if (cis) {
cis->addr = addr;
cis->len = len;
cis->attr = attr;
memcpy(cis->cache, ptr, len);
list_add(&cis->node, &s->cis_cache);
}
}
mutex_unlock(&s->ops_mutex);
return ret;
} | false | false | false | false | false | 0 |
Init() {
static ClassDocumentation<SMHiggsFermionsDecayer> documentation
("The SMHiggsFermionsDecayer class implements the decat of the Standard Model"
" Higgs boson to the Standard Model fermions");
static ParVector<SMHiggsFermionsDecayer,double> interfaceMaxWeights
("MaxWeights",
"Maximum weights for the various decays",
&SMHiggsFermionsDecayer::_maxwgt, 9, 1.0, 0.0, 10.0,
false, false, Interface::limited);
} | false | false | false | false | false | 0 |
cleanup(void)
{
outs(exit_attribute_mode);
if (!outs(orig_colors))
outs(orig_pair);
outs(clear_screen);
outs(cursor_normal);
printf("\n\n%ld total chars, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (time((time_t *) 0) - started)));
} | false | false | false | false | false | 0 |
maximum_absolute_value() const
{
REPORT
if (storage == 0) NullMatrixError(this);
Real maxval = 0.0; int l = storage; Real* s = store;
while (l--) { Real a = fabs(*s++); if (maxval < a) maxval = a; }
((GeneralMatrix&)*this).tDelete(); return maxval;
} | false | false | false | false | false | 0 |
x_server_finalize (GObject *object)
{
XServer *self;
self = X_SERVER (object);
g_free (self->priv->hostname);
g_free (self->priv->address);
if (self->priv->authority)
g_object_unref (self->priv->authority);
if (self->priv->connection)
xcb_disconnect (self->priv->connection);
G_OBJECT_CLASS (x_server_parent_class)->finalize (object);
} | false | false | false | false | false | 0 |
sort_and_combine_web_pairs (int for_move)
{
unsigned int i;
struct web_pair **sorted;
struct web_pair *p;
if (!num_web_pairs)
return;
sorted = xmalloc (num_web_pairs * sizeof (sorted[0]));
for (p = web_pair_list, i = 0; p; p = p->next_list)
sorted[i++] = p;
if (i != num_web_pairs)
abort ();
qsort (sorted, num_web_pairs, sizeof (sorted[0]), comp_web_pairs);
/* After combining one pair, we actually should adjust the savings
of the other pairs, if they are connected to one of the just coalesced
pair. Later. */
for (i = 0; i < num_web_pairs; i++)
{
struct web *w1, *w2;
p = sorted[i];
w1 = alias (p->smaller);
w2 = alias (p->larger);
if (!for_move && (w1->type == PRECOLORED || w2->type == PRECOLORED))
continue;
else if (w2->type == PRECOLORED)
{
struct web *h = w1;
w1 = w2;
w2 = h;
}
if (w1 != w2
&& !TEST_BIT (sup_igraph, w1->id * num_webs + w2->id)
&& !TEST_BIT (sup_igraph, w2->id * num_webs + w1->id)
&& w2->type != PRECOLORED
&& hard_regs_intersect_p (&w1->usable_regs, &w2->usable_regs))
{
if (w1->type != PRECOLORED
|| (w1->type == PRECOLORED && ok (w2, w1)))
combine (w1, w2);
else if (w1->type == PRECOLORED)
SET_HARD_REG_BIT (w2->prefer_colors, w1->color);
}
}
free (sorted);
} | false | false | false | false | false | 0 |
ad_tree_set_security(AW_root *aw_root)
{
if (GLOBAL_gb_main) {
GB_transaction dummy(GLOBAL_gb_main);
char *treename = aw_root->awar(AWAR_TREE_NAME)->read_string();
GBDATA *ali_cont = GBT_get_tree(GLOBAL_gb_main,treename);
if (ali_cont) {
long prot = aw_root->awar(AWAR_TREE_SECURITY)->read_int();
long old;
old = GB_read_security_delete(ali_cont);
GB_ERROR error = 0;
if (old != prot){
error = GB_write_security_delete(ali_cont,prot);
if (!error)
error = GB_write_security_write(ali_cont,prot);
}
if (error ) aw_message(error);
}
free(treename);
}
} | false | false | false | false | false | 0 |
CreateDefaultExecutive()
{
if (vtkAlgorithm::DefaultExecutivePrototype)
{
return vtkAlgorithm::DefaultExecutivePrototype->NewInstance();
}
return vtkStreamingDemandDrivenPipeline::New();
} | false | false | false | false | false | 0 |
migrate_to_level(mtmp, tolev, xyloc, cc)
register struct monst *mtmp;
xchar tolev; /* destination level */
xchar xyloc; /* MIGR_xxx destination xy location: */
coord *cc; /* optional destination coordinates */
{
register struct obj *obj;
d_level new_lev;
xchar xyflags;
int num_segs = 0; /* count of worm segments */
if (mtmp->isshk)
set_residency(mtmp, TRUE);
if (mtmp->wormno) {
register int cnt;
/* **** NOTE: worm is truncated to # segs = max wormno size **** */
cnt = count_wsegs(mtmp);
num_segs = min(cnt, MAX_NUM_WORMS - 1);
wormgone(mtmp);
}
/* set minvent's obj->no_charge to 0 */
for(obj = mtmp->minvent; obj; obj = obj->nobj) {
if (Has_contents(obj))
picked_container(obj); /* does the right thing */
obj->no_charge = 0;
}
if (mtmp->mleashed) {
mtmp->mtame--;
m_unleash(mtmp, TRUE);
}
relmon(mtmp);
mtmp->nmon = migrating_mons;
migrating_mons = mtmp;
newsym(mtmp->mx,mtmp->my);
new_lev.dnum = ledger_to_dnum((xchar)tolev);
new_lev.dlevel = ledger_to_dlev((xchar)tolev);
/* overload mtmp->[mx,my], mtmp->[mux,muy], and mtmp->mtrack[] as */
/* destination codes (setup flag bits before altering mx or my) */
xyflags = (depth(&new_lev) < depth(&u.uz)); /* 1 => up */
if (In_W_tower(mtmp->mx, mtmp->my, &u.uz)) xyflags |= 2;
mtmp->wormno = num_segs;
mtmp->mlstmv = monstermoves;
mtmp->mtrack[1].x = cc ? cc->x : mtmp->mx;
mtmp->mtrack[1].y = cc ? cc->y : mtmp->my;
mtmp->mtrack[0].x = xyloc;
mtmp->mtrack[0].y = xyflags;
mtmp->mux = new_lev.dnum;
mtmp->muy = new_lev.dlevel;
mtmp->mx = mtmp->my = 0; /* this implies migration */
} | false | false | false | false | false | 0 |
headerClicked(int col)
{
// name columns should be sortable in both ways
if (col == 3) return;
// all others only descending
sortByColumn(col, Qt::DescendingOrder);
} | false | false | false | false | false | 0 |
getpacket(int *we_know){
fd_set readfds;
struct timeval tv;
int bytes_per_packet=0;
int ret;
static const char *packet_id=NULL;
static char buf[256];
const char *s;
ssize_t r;
bytes_per_packet=*we_know;
D(printf("getpacket with %d\n",bytes_per_packet);)
FD_ZERO(&readfds);
FD_SET(upsfd,&readfds);
/* Wait up to 2 seconds. */
tv.tv_sec = 5;
tv.tv_usec = 0;
ret=select(upsfd+1, &readfds, NULL, NULL, &tv);
if (!ret) {
s="Nothing received from UPS. Check cable conexion";
upslogx(LOG_ERR, "%s", s);
D(printf("%s\n",s);)
return NULL;
}
r=read(upsfd,buf,255);
D(printf("%d bytes read: ",r);)
buf[r]=0;
if (bytes_per_packet && r < bytes_per_packet){
ssize_t rr;
D(printf("short read...\n");)
usleep(500000);
tv.tv_sec = 2;
tv.tv_usec = 0;
ret=select(upsfd+1, &readfds, NULL, NULL, &tv);
if (!ret) return NULL;
rr=read(upsfd,buf+r,255-r);
r += rr;
if (r < bytes_per_packet) return NULL;
}
if (!bytes_per_packet){ /* packet size determination */
/* if (r%10 && r%9) {
printf("disregarding incomplete packet\n");
return NULL;
}*/
if (r%10==0) *we_know=10;
else if (r%9==0) *we_know=9;
return NULL;
}
/* by here we have bytes_per_packet and a complete packet */
/* lets check if within the complete packet we have a valid packet */
if (bytes_per_packet == 10) packet_id="&&&"; else packet_id="***";
s=strstr(buf,packet_id);
/* check validity of packet */
if (!s) {
s="isbmex: no valid packet signature!";
upslogx(LOG_ERR, "%s", s);
D(printf("%s\n",s);)
*we_know=0;
return NULL;
}
D(if (s != buf) printf("overlapping packet received\n");)
if ((int) strlen(s) < bytes_per_packet) {
D(printf("incomplete packet information\n");)
return NULL;
}
#ifdef DEBUG
printf("Got signal:");
{int i;for (i=0;i<strlen(s);i++) printf(" <%d>",(unsigned char)s[i]);}
printf("\n");
#endif
return s;
} | false | false | false | false | false | 0 |
asd_find_dir_entry(struct asd_ocm_dir *dir, u8 type,
u32 *offs, u32 *size)
{
int i;
struct asd_ocm_dir_ent *ent;
for (i = 0; i < dir->num_de; i++) {
if (dir->entry[i].type == type)
break;
}
if (i >= dir->num_de)
return -ENOENT;
ent = &dir->entry[i];
*offs = (u32) THREE_TO_NUM(ent->offs);
*size = (u32) THREE_TO_NUM(ent->size);
return 0;
} | false | false | false | false | false | 0 |
StrInStrNoCase(StringRef s1, StringRef s2) {
size_t N = s2.size(), M = s1.size();
if (N > M)
return StringRef::npos;
for (size_t i = 0, e = M - N + 1; i != e; ++i)
if (s1.substr(i, N).equals_lower(s2))
return i;
return StringRef::npos;
} | false | false | false | false | false | 0 |
GMT_f_test (double chisq1, GMT_LONG nu1, double chisq2, GMT_LONG nu2, double *prob)
{
/* Routine to compute the probability that
two variances are the same.
chisq1 is distributed as chisq with
nu1 degrees of freedom; ditto for
chisq2 and nu2. If these are independent
and we form the ratio
F = max(chisq1,chisq2)/min(chisq1,chisq2)
then we can ask what is the probability
that an F greater than this would occur
by chance. It is this probability that
is returned in prob. When prob is small,
it is likely that the two chisq represent
two different populations; the confidence
that the two do not represent the same pop
is 1.0 - prob. This is a two-sided test.
This follows some ideas in Numerical Recipes, CRC Handbook,
and Abramowitz and Stegun. */
double f, df1, df2, p1, p2;
if ( chisq1 <= 0.0) {
fprintf(stderr,"GMT_f_test: Chi-Square One <= 0.0\n");
return(-1);
}
if ( chisq2 <= 0.0) {
fprintf(stderr,"GMT_f_test: Chi-Square Two <= 0.0\n");
return(-1);
}
if (chisq1 > chisq2) {
f = chisq1/chisq2;
df1 = (double)nu1;
df2 = (double)nu2;
}
else {
f = chisq2/chisq1;
df1 = (double)nu2;
df2 = (double)nu1;
}
if (GMT_inc_beta(0.5*df2, 0.5*df1, df2/(df2+df1*f), &p1) ) {
fprintf(stderr,"GMT_f_test: Trouble on 1st GMT_inc_beta call.\n");
return(-1);
}
if (GMT_inc_beta(0.5*df1, 0.5*df2, df1/(df1+df2/f), &p2) ) {
fprintf(stderr,"GMT_f_test: Trouble on 2nd GMT_inc_beta call.\n");
return(-1);
}
*prob = p1 + (1.0 - p2);
return(0);
} | false | false | false | false | false | 0 |
MakeRfmLabel(NameDict name_dict, RfmStm stm)
{
RfmLabel prev;
RfmLabel label;
RfmLabel new;
prev = NULL;
for (label = RFM_ModuleCurrent->label_list;
label != NULL;
label = label->next) {
if ((label->name_dict) &&
(label->name_dict == name_dict)) {
return(label);
}
prev = label;
}
new = GET_RFM_LABEL_TABLE();
if (name_dict) {
new->name_dict = name_dict;
} else {
new->is_generate = TRUE;
}
new->stm = stm;
new->module = RFM_ModuleCurrent;
if (prev) {
prev->next = new;
new->prev = prev;
} else {
RFM_ModuleCurrent->label_list = new;
}
return(new);
} | false | false | false | false | false | 0 |
deleteHash(int index,int row, int column)
{
if (index<numberItems_) {
int ipos = hashValue ( row, column );
while ( ipos>=0 ) {
int j1 = hash_[ipos].index;
if ( j1!=index) {
ipos = hash_[ipos].next;
} else {
hash_[ipos].index=-1; // available
break;
}
}
}
} | false | false | false | false | false | 0 |
CCthrottle(av)
char *av[];
{
char *p;
p = av[0];
switch (Mode) {
case OMpaused:
if (*p && !EQ(p, ModeReason))
return "1 Already paused";
/* FALLTHROUGH */
case OMrunning:
return CCblock(OMthrottled, p);
case OMthrottled:
return "1 Already throttled";
}
return "1 unknown mode";
} | false | false | false | false | false | 0 |
ParseConfig(char *file)
{
char line[256];
char *tline;
FILE *ptr;
ptr=fopen(file,"r");
if(ptr != (FILE *)NULL) {
tline = fgets(line,(sizeof line)-1,ptr);
while(tline != (char *)0) {
while(isspace((unsigned char)*tline))tline++;
if(strlen(tline)>1) {
if(mystrncasecmp(tline, CatString3(Module, "Font",""),Clength+4)==0)
CopyString(&font_string,&tline[Clength+4]);
else if(mystrncasecmp(tline,CatString3(Module,"Fore",""), Clength+4)==0)
CopyString(&ForeColor,&tline[Clength+4]);
else if(mystrncasecmp(tline,CatString3(Module, "Geometry",""), Clength+8)==0)
CopyString(&geometry,&tline[Clength+8]);
else if(mystrncasecmp(tline,CatString3(Module, "Back",""), Clength+4)==0)
CopyString(&BackColor,&tline[Clength+4]);
else if(mystrncasecmp(tline,CatString3(Module, "NoAnchor",""),
Clength+8)==0) Anchor=0;
else if(mystrncasecmp(tline,CatString3(Module, "Action",""), Clength+6)==0)
LinkAction(&tline[Clength+6]);
else if(mystrncasecmp(tline,CatString3(Module, "UseSkipList",""),
Clength+11)==0) UseSkipList=1;
else if(mystrncasecmp(tline,CatString3(Module, "UseIconNames",""),
Clength+12)==0) UseIconNames=1;
}
tline = fgets(line,(sizeof line)-1,ptr);
}
}
} | false | false | false | false | true | 1 |
gst_rtp_mp4v_depay_process (GstRTPBaseDepayload * depayload, GstBuffer * buf)
{
GstRtpMP4VDepay *rtpmp4vdepay;
GstBuffer *pbuf, *outbuf = NULL;
GstRTPBuffer rtp = { NULL };
gboolean marker;
rtpmp4vdepay = GST_RTP_MP4V_DEPAY (depayload);
/* flush remaining data on discont */
if (GST_BUFFER_IS_DISCONT (buf))
gst_adapter_clear (rtpmp4vdepay->adapter);
gst_rtp_buffer_map (buf, GST_MAP_READ, &rtp);
pbuf = gst_rtp_buffer_get_payload_buffer (&rtp);
marker = gst_rtp_buffer_get_marker (&rtp);
gst_rtp_buffer_unmap (&rtp);
gst_adapter_push (rtpmp4vdepay->adapter, pbuf);
/* if this was the last packet of the VOP, create and push a buffer */
if (marker) {
guint avail;
avail = gst_adapter_available (rtpmp4vdepay->adapter);
outbuf = gst_adapter_take_buffer (rtpmp4vdepay->adapter, avail);
GST_DEBUG ("gst_rtp_mp4v_depay_chain: pushing buffer of size %"
G_GSIZE_FORMAT, gst_buffer_get_size (outbuf));
}
return outbuf;
} | false | false | false | false | false | 0 |
mlxsw_pci_queue_group_fini(struct mlxsw_pci *mlxsw_pci,
const struct mlxsw_pci_queue_ops *q_ops)
{
struct mlxsw_pci_queue_type_group *queue_group;
int i;
queue_group = mlxsw_pci_queue_type_group_get(mlxsw_pci, q_ops->type);
for (i = 0; i < queue_group->count; i++)
mlxsw_pci_queue_fini(mlxsw_pci, q_ops, &queue_group->q[i]);
kfree(queue_group->q);
} | false | false | false | false | false | 0 |
nicvf_snd_pkt_handler(struct net_device *netdev,
struct cmp_queue *cq,
struct cqe_send_t *cqe_tx, int cqe_type)
{
struct sk_buff *skb = NULL;
struct nicvf *nic = netdev_priv(netdev);
struct snd_queue *sq;
struct sq_hdr_subdesc *hdr;
struct sq_hdr_subdesc *tso_sqe;
sq = &nic->qs->sq[cqe_tx->sq_idx];
hdr = (struct sq_hdr_subdesc *)GET_SQ_DESC(sq, cqe_tx->sqe_ptr);
if (hdr->subdesc_type != SQ_DESC_TYPE_HEADER)
return;
netdev_dbg(nic->netdev,
"%s Qset #%d SQ #%d SQ ptr #%d subdesc count %d\n",
__func__, cqe_tx->sq_qs, cqe_tx->sq_idx,
cqe_tx->sqe_ptr, hdr->subdesc_cnt);
nicvf_check_cqe_tx_errs(nic, cq, cqe_tx);
skb = (struct sk_buff *)sq->skbuff[cqe_tx->sqe_ptr];
if (skb) {
/* Check for dummy descriptor used for HW TSO offload on 88xx */
if (hdr->dont_send) {
/* Get actual TSO descriptors and free them */
tso_sqe =
(struct sq_hdr_subdesc *)GET_SQ_DESC(sq, hdr->rsvd2);
nicvf_put_sq_desc(sq, tso_sqe->subdesc_cnt + 1);
}
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
prefetch(skb);
dev_consume_skb_any(skb);
sq->skbuff[cqe_tx->sqe_ptr] = (u64)NULL;
} else {
/* In case of SW TSO on 88xx, only last segment will have
* a SKB attached, so just free SQEs here.
*/
if (!nic->hw_tso)
nicvf_put_sq_desc(sq, hdr->subdesc_cnt + 1);
}
} | false | false | false | false | false | 0 |
parse_variable(struct reader *reader, char **var_name, char **var_value)
{
const char *var_end = NULL;
const char *value_start = NULL;
char *line;
int quote_count;
line = reader_readline(reader, true);
if (line == NULL)
return -1;
quote_count = strip_comments(line, 0);
var_end = strchr(line, '=');
if (var_end == NULL)
var_end = strchr(line, '\0');
else
value_start = var_end + 1;
do var_end--;
while (var_end>line && git__isspace(*var_end));
*var_name = git__strndup(line, var_end - line + 1);
GITERR_CHECK_ALLOC(*var_name);
/* If there is no value, boolean true is assumed */
*var_value = NULL;
/*
* Now, let's try to parse the value
*/
if (value_start != NULL) {
while (git__isspace(value_start[0]))
value_start++;
if (is_multiline_var(value_start)) {
git_buf multi_value = GIT_BUF_INIT;
char *proc_line = fixup_line(value_start, 0);
GITERR_CHECK_ALLOC(proc_line);
git_buf_puts(&multi_value, proc_line);
git__free(proc_line);
if (parse_multiline_variable(reader, &multi_value, quote_count) < 0 || git_buf_oom(&multi_value)) {
git__free(*var_name);
git__free(line);
git_buf_free(&multi_value);
return -1;
}
*var_value = git_buf_detach(&multi_value);
}
else if (value_start[0] != '\0') {
*var_value = fixup_line(value_start, 0);
GITERR_CHECK_ALLOC(*var_value);
} else { /* equals sign but missing rhs */
*var_value = git__strdup("");
GITERR_CHECK_ALLOC(*var_value);
}
}
git__free(line);
return 0;
} | false | false | false | false | false | 0 |
snapscani_check_device(
int fd,
SnapScan_Bus bus_type,
char* vendor,
char* model,
SnapScan_Model* model_num
) {
static const char me[] = "snapscani_check_device";
SANE_Status status = SANE_STATUS_GOOD;
int supported_vendor = 0;
int i;
DBG (DL_CALL_TRACE, "%s()\n", me);
/* check that the device is legitimate */
if ((status = mini_inquiry (bus_type, fd, vendor, model)) != SANE_STATUS_GOOD)
{
DBG (DL_MAJOR_ERROR,
"%s: mini_inquiry failed with %s.\n",
me,
sane_strstatus (status));
return status;
}
DBG (DL_VERBOSE,
"%s: Is vendor \"%s\" model \"%s\" a supported scanner?\n",
me,
vendor,
model);
/* check if this is one of our supported vendors */
for (i = 0; i < known_vendors; i++)
{
if (0 == strcasecmp (vendor, vendors[i]))
{
supported_vendor = 1;
break;
}
}
if (supported_vendor)
{
/* Known vendor. Check if it is one of our supported models */
*model_num = snapscani_get_model_id(model, fd, bus_type);
}
if (!supported_vendor || UNKNOWN == model_num)
{
DBG (DL_MINOR_ERROR,
"%s: \"%s %s\" is not one of %s\n",
me,
vendor,
model,
"AGFA SnapScan 300, 310, 600, 1212, 1236, e10, e20, e25, e26, "
"e40, e42, e50, e52 or e60\n"
"Acer 300, 310, 610, 610+, "
"620, 620+, 640, 1240, 3300, 4300 or 5300\n"
"Guillemot MaxiScan A4 Deluxe");
status = SANE_STATUS_INVAL;
} else {
DBG(DL_VERBOSE, "%s: Autodetected driver: %s\n", me, get_driver_name(*model_num));
}
return status;
} | false | false | false | false | false | 0 |
s48_cons_2(s48_call_t call, s48_ref_t v1, s48_ref_t v2)
{
s48_ref_t ref;
ref = s48_make_local_ref(call, s48_allocate_stob(S48_STOBTYPE_PAIR, 2));
s48_unsafe_set_car_2(call, ref, v1);
s48_unsafe_set_cdr_2(call, ref, v2);
return ref;
} | false | false | false | false | false | 0 |
method_63(const int *account, int *weight) {
if (0 != account[0])
return AccountNumberCheck::ERROR; // Added by Jens Gecius, check on invalid accountIDs
number2Array("0121212000", weight);
if (0 == account[0] && 0 == account[1] && 0 == account[2]) {
// shift left, add 00 as subaccount id
int account_buf[10];
number2Array(array2Number(account).substr(2) + "00", account_buf);
return algo01(10, weight, true, 8, account_buf);
} else {
return algo01(10, weight, true, 8, account);
}
} | false | false | false | false | false | 0 |
dupe_window_add_collection(DupeWindow *dw, CollectionData *collection)
{
CollectInfo *info;
info = collection_get_first(collection);
while (info)
{
dupe_files_add(dw, collection, info, NULL, FALSE);
info = collection_next_by_info(collection, info);
}
dupe_check_start(dw);
} | false | false | false | false | false | 0 |
first_dirty_cnode(struct ubifs_nnode *nnode)
{
ubifs_assert(nnode);
while (1) {
int i, cont = 0;
for (i = 0; i < UBIFS_LPT_FANOUT; i++) {
struct ubifs_cnode *cnode;
cnode = nnode->nbranch[i].cnode;
if (cnode &&
test_bit(DIRTY_CNODE, &cnode->flags)) {
if (cnode->level == 0)
return cnode;
nnode = (struct ubifs_nnode *)cnode;
cont = 1;
break;
}
}
if (!cont)
return (struct ubifs_cnode *)nnode;
}
} | false | false | false | false | false | 0 |
dumpDatabases(PGconn *conn)
{
PGresult *res;
int i;
if (server_version >= 70100)
res = executeQuery(conn, "SELECT datname FROM pg_database WHERE datallowconn ORDER BY 1");
else
res = executeQuery(conn, "SELECT datname FROM pg_database ORDER BY 1");
for (i = 0; i < PQntuples(res); i++)
{
int ret;
char *dbname = PQgetvalue(res, i, 0);
if (verbose)
fprintf(stderr, _("%s: dumping database \"%s\"...\n"), progname, dbname);
fprintf(OPF, "\\connect %s\n\n", fmtId(dbname));
/*
* Restore will need to write to the target cluster. This connection
* setting is emitted for pg_dumpall rather than in the code also used
* by pg_dump, so that a cluster with databases or users which have
* this flag turned on can still be replicated through pg_dumpall
* without editing the file or stream. With pg_dump there are many
* other ways to allow the file to be used, and leaving it out allows
* users to protect databases from being accidental restore targets.
*/
fprintf(OPF, "SET default_transaction_read_only = off;\n\n");
if (filename)
fclose(OPF);
ret = runPgDump(dbname);
if (ret != 0)
{
fprintf(stderr, _("%s: pg_dump failed on database \"%s\", exiting\n"), progname, dbname);
exit_nicely(1);
}
if (filename)
{
OPF = fopen(filename, PG_BINARY_A);
if (!OPF)
{
fprintf(stderr, _("%s: could not re-open the output file \"%s\": %s\n"),
progname, filename, strerror(errno));
exit_nicely(1);
}
}
}
PQclear(res);
} | false | false | false | false | true | 1 |
EnterDup(Tcl_Interp *interp, SOCKET sock)
{
sock = ns_sockdup(sock);
if (sock == INVALID_SOCKET) {
Tcl_AppendResult(interp, "could not dup socket: ",
ns_sockstrerror(errno), NULL);
return TCL_ERROR;
}
return EnterSock(interp, sock);
} | false | false | false | false | false | 0 |
gt_encseq_access_type_str(GtEncseqAccessType at)
{
gt_assert((int) at < (int) GT_ACCESS_TYPE_UNDEFINED);
return wpa[at].name;
} | false | false | false | false | false | 0 |
f_call(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
char_u *func;
dict_T *selfdict = NULL;
if (argvars[1].v_type != VAR_LIST)
{
EMSG(_(e_listreq));
return;
}
if (argvars[1].vval.v_list == NULL)
return;
if (argvars[0].v_type == VAR_FUNC)
func = argvars[0].vval.v_string;
else
func = get_tv_string(&argvars[0]);
if (*func == NUL)
return; /* type error or empty name */
if (argvars[2].v_type != VAR_UNKNOWN)
{
if (argvars[2].v_type != VAR_DICT)
{
EMSG(_(e_dictreq));
return;
}
selfdict = argvars[2].vval.v_dict;
}
(void)func_call(func, &argvars[1], selfdict, rettv);
} | false | false | false | false | false | 0 |
import_record(const jdns_rr_t *in)
{
QJDns::Record out;
out.owner = QByteArray((const char *)in->owner);
out.ttl = in->ttl;
out.type = in->type;
out.rdata = QByteArray((const char *)in->rdata, in->rdlength);
// known
if(in->haveKnown)
{
int type = in->type;
if(type == QJDns::A || type == QJDns::Aaaa)
{
out.haveKnown = true;
out.address = addr2qt(in->data.address);
}
else if(type == QJDns::Mx)
{
out.haveKnown = true;
out.name = QByteArray((const char *)in->data.server->name);
out.priority = in->data.server->priority;
}
else if(type == QJDns::Srv)
{
out.haveKnown = true;
out.name = QByteArray((const char *)in->data.server->name);
out.priority = in->data.server->priority;
out.weight = in->data.server->weight;
out.port = in->data.server->port;
}
else if(type == QJDns::Cname || type == QJDns::Ptr || type == QJDns::Ns)
{
out.haveKnown = true;
out.name = QByteArray((const char *)in->data.name);
}
else if(type == QJDns::Txt)
{
out.haveKnown = true;
out.texts.clear();
for(int n = 0; n < in->data.texts->count; ++n)
out.texts += str2qt(in->data.texts->item[n]);
}
else if(type == QJDns::Hinfo)
{
out.haveKnown = true;
out.cpu = str2qt(in->data.hinfo.cpu);
out.os = str2qt(in->data.hinfo.os);
}
}
return out;
} | false | false | false | false | false | 0 |
gp_processor_check_bank(enum proc_class class, int address)
{
int bank;
switch (class) {
case PROC_CLASS_EEPROM8:
case PROC_CLASS_EEPROM16:
assert(0);
break;
case PROC_CLASS_GENERIC:
case PROC_CLASS_PIC12:
case PROC_CLASS_SX:
bank = (address >> 5) & 0x3;
break;
case PROC_CLASS_PIC14:
bank = (address >> 7) & 0x3;
break;
case PROC_CLASS_PIC16:
case PROC_CLASS_PIC16E:
bank = (address >> 8) & 0xff;
break;
default:
assert(0);
}
return bank;
} | false | false | false | false | false | 0 |
Perl_parse_label(pTHX_ U32 flags)
{
if (flags & ~PARSE_OPTIONAL)
Perl_croak(aTHX_ "Parsing code internal error (%s)", "parse_label");
if (PL_lex_state == LEX_KNOWNEXT) {
PL_parser->yychar = yylex();
if (PL_parser->yychar == LABEL) {
char * const lpv = pl_yylval.pval;
STRLEN llen = strlen(lpv);
PL_parser->yychar = YYEMPTY;
return newSVpvn_flags(lpv, llen, lpv[llen+1] ? SVf_UTF8 : 0);
} else {
yyunlex();
goto no_label;
}
} else {
char *s, *t;
STRLEN wlen, bufptr_pos;
lex_read_space(0);
t = s = PL_bufptr;
if (!isIDFIRST_lazy_if(s, UTF))
goto no_label;
t = scan_word(s, PL_tokenbuf, sizeof PL_tokenbuf, FALSE, &wlen);
if (word_takes_any_delimeter(s, wlen))
goto no_label;
bufptr_pos = s - SvPVX(PL_linestr);
PL_bufptr = t;
lex_read_space(LEX_KEEP_PREVIOUS);
t = PL_bufptr;
s = SvPVX(PL_linestr) + bufptr_pos;
if (t[0] == ':' && t[1] != ':') {
PL_oldoldbufptr = PL_oldbufptr;
PL_oldbufptr = s;
PL_bufptr = t+1;
return newSVpvn_flags(s, wlen, UTF ? SVf_UTF8 : 0);
} else {
PL_bufptr = s;
no_label:
if (flags & PARSE_OPTIONAL) {
return NULL;
} else {
qerror(Perl_mess(aTHX_ "Parse error"));
return newSVpvs("x");
}
}
}
} | false | false | false | false | false | 0 |
as102_fe_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{
struct as102_state *state = fe->demodulator_priv;
if (state->demod_stats.has_started)
*ucblocks = state->demod_stats.bad_frame_count;
else
*ucblocks = 0;
return 0;
} | false | false | false | false | false | 0 |
SetXValues( int start_index, int count, double x )
{
wxCHECK_RET( Ok(), wxT("Invalid wxPlotData") );
if (count == 0) return;
if (count < 0) count = M_PLOTDATA->m_count-start_index;
int end_index = start_index + count - 1;
wxPCHECK_MINMAX_RET(start_index, 0, M_PLOTDATA->m_count-1, wxT("Invalid starting index"));
wxPCHECK_MINMAX_RET(end_index, 0, M_PLOTDATA->m_count-1, wxT("Invalid ending index"));
double *x_data = M_PLOTDATA->m_Xdata;
for (int n = start_index; n <= end_index; n++)
*x_data++ = x;
} | false | false | false | false | false | 0 |
deletekey (CONST int scancode)
{
struct keyrec *key;
if (!(key = findkey (scancode)))
{
printf ("Key not found!\n");
return;
}
if (key->last)
key->last->next = key->next;
else
ffirstkey = key->next;
if (key->next)
key->next->last = key->last;
free (key);
} | false | false | false | false | false | 0 |
meta_frames_repaint_frame (MetaFrames *frames,
Window xwindow)
{
MetaUIFrame *frame;
frame = meta_frames_lookup_window (frames, xwindow);
g_assert (frame);
/* repaint everything, so the other frame don't
* lag behind if they are exposed
*/
gdk_window_process_all_updates ();
} | false | false | false | false | false | 0 |
FreeBlocks() {
for ( int i = 1; i < blocks_alloced_; ++i ) { // keep first block alloced
free(first_blocks_[i].mem);
first_blocks_[i].mem = NULL;
first_blocks_[i].size = 0;
}
blocks_alloced_ = 1;
if (overflow_blocks_ != NULL) {
vector<AllocatedBlock>::iterator it;
for (it = overflow_blocks_->begin(); it != overflow_blocks_->end(); ++it) {
free(it->mem);
}
delete overflow_blocks_; // These should be used very rarely
overflow_blocks_ = NULL;
}
} | false | false | false | false | false | 0 |
compute_merit (struct occurrence *occ)
{
struct occurrence *occ_child;
basic_block dom = occ->bb;
for (occ_child = occ->children; occ_child; occ_child = occ_child->next)
{
basic_block bb;
if (occ_child->children)
compute_merit (occ_child);
if (flag_exceptions)
bb = single_noncomplex_succ (dom);
else
bb = dom;
if (dominated_by_p (CDI_POST_DOMINATORS, bb, occ_child->bb))
occ->num_divisions += occ_child->num_divisions;
}
} | false | false | false | false | false | 0 |
DateCalc_Weeks_in_Year(Z_int year)
{
return( 52 + ((DateCalc_Day_of_Week(year,1,1) == 4) or
(DateCalc_Day_of_Week(year,12,31) == 4)) );
} | false | false | false | false | false | 0 |
appliFontToViews(const QFont &font)
{
QList<Templates::TemplatesView *> allViews = Core::ICore::instance()->mainWindow()->findChildren<Templates::TemplatesView *>();
for(int i = 0; i < allViews.count(); ++i) {
allViews.at(i)->setFont(font);
}
} | false | false | false | false | false | 0 |
check_blank_configurations(void)
{
if (trusted_host_num == 0) {
trusted_host_num = 1;
prog_config.trusted[0] = (char *) malloc(10);
sprintf(prog_config.trusted[0], "localhost");
}
if (rejected_host_num == 0) {
rejected_host_num = 1;
prog_config.rejected[0] = (char *) malloc(8);
sprintf(prog_config.rejected[0], "0.0.0.0");
}
if (forward_host_num == 0) {
forward_host_num = 1;
prog_config.forward[0] = (char *) malloc(10);
sprintf(prog_config.forward[0], "localhost");
/* Patch by Larry Daffner (vizzie@airmail.net) */
if (prog_config.config_bits2 & SHOW_FINGERFWD)
prog_config.config_bits2 &= ~SHOW_FINGERFWD;
}
if (fakeuser_num == 0) {
prog_config.fusers[fakeuser_num].user = (char *) malloc(5);
prog_config.fusers[fakeuser_num].script = (char *) malloc(10);
prog_config.fusers[fakeuser_num].description = (char *) malloc(5);
sprintf(prog_config.fusers[fakeuser_num].user, "None");
sprintf(prog_config.fusers[fakeuser_num].script, "/dev/null");
sprintf(prog_config.fusers[fakeuser_num].description, "None");
prog_config.fusers[fakeuser_num].searchable = FALSE;
fakeuser_num = 1;
}
if (num_finger_sites == 0) {
prog_config.finger_sites[num_finger_sites] = (char *) malloc(10);
sprintf(prog_config.finger_sites[num_finger_sites], "localhost");
num_finger_sites = 1;
}
if (prog_config.mailbox_file == NULL) {
prog_config.mailbox_file = (char *) malloc(sizeof(MAIL_SPOOL_DIR)+7);
sprintf(prog_config.mailbox_file, "%s/$USER", MAIL_SPOOL_DIR);
}
} | false | false | false | false | false | 0 |
close_all_cb(GtkWidget *, gpointer data)
{
GtkWidget *list = (GtkWidget *)data;
if (list) {
scope_entry *current = root_scope;
while (current) {
GDK_THREADS_LEAVE();
if (current->sp) current->sp->stop();
GDK_THREADS_ENTER();
current = current->next;
}
}
} | false | false | false | false | false | 0 |
dvbsky_get_rc_config(struct dvb_usb_device *d, struct dvb_usb_rc *rc)
{
if (dvb_usb_dvbsky_disable_rc) {
rc->map_name = NULL;
return 0;
}
rc->allowed_protos = RC_BIT_RC5;
rc->query = dvbsky_rc_query;
rc->interval = 300;
return 0;
} | false | false | false | false | false | 0 |
resolve_generic_type(Oid declared_type,
Oid context_actual_type,
Oid context_declared_type)
{
if (declared_type == ANYARRAYOID)
{
if (context_declared_type == ANYARRAYOID)
{
/* Use actual type, but it must be an array */
Oid array_typelem = get_element_type(context_actual_type);
if (!OidIsValid(array_typelem))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyarray\" is not an array but type %s",
format_type_be(context_actual_type))));
return context_actual_type;
}
else if (context_declared_type == ANYELEMENTOID)
{
/* Use the array type corresponding to actual type */
Oid array_typeid = get_array_type(context_actual_type);
if (!OidIsValid(array_typeid))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("could not find array type for data type %s",
format_type_be(context_actual_type))));
return array_typeid;
}
}
else if (declared_type == ANYELEMENTOID)
{
if (context_declared_type == ANYARRAYOID)
{
/* Use the element type corresponding to actual type */
Oid array_typelem = get_element_type(context_actual_type);
if (!OidIsValid(array_typelem))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("argument declared \"anyarray\" is not an array but type %s",
format_type_be(context_actual_type))));
return array_typelem;
}
else if (context_declared_type == ANYELEMENTOID)
{
/* Use the actual type; it doesn't matter if array or not */
return context_actual_type;
}
}
else
{
/* declared_type isn't polymorphic, so return it as-is */
return declared_type;
}
/* If we get here, declared_type is polymorphic and context isn't */
/* NB: this is a calling-code logic error, not a user error */
elog(ERROR, "could not determine ANYARRAY/ANYELEMENT type because context isn't polymorphic");
return InvalidOid; /* keep compiler quiet */
} | false | false | false | false | false | 0 |
CreateNLSocket (void)
{
int sock;
struct sockaddr_nl sa;
int ret;
sock = socket (AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
ret = fcntl (sock, F_GETFL, 0);
if (ret != -1) {
ret |= O_NONBLOCK;
ret = fcntl (sock, F_SETFL, ret);
if (ret < 0)
return -1;
}
memset (&sa, 0, sizeof (sa));
if (sock < 0)
return -1;
sa.nl_family = AF_NETLINK;
sa.nl_pid = getpid ();
sa.nl_groups = RTMGRP_IPV4_ROUTE | RTMGRP_IPV6_ROUTE | RTMGRP_NOTIFY;
/* RTNLGRP_IPV4_IFADDR | RTNLGRP_IPV6_IFADDR
* RTMGRP_LINK */
if (bind (sock, (struct sockaddr *) &sa, sizeof (sa)) < 0)
return -1;
return sock;
} | false | false | false | false | false | 0 |
create_semaphore(key_t key){
int id, retval;
SEMUN s;
id = semget(key, 1, IPC_CREAT|IPC_EXCL|0777);
if (id < 0) {
return ERR_SEMGET;
}
memset(&s, 0, sizeof(s));
s.val = 1;
retval = semctl(id, 0, SETVAL, s);
if (retval) {
return ERR_SEMCTL;
}
return 0;
} | false | false | false | false | false | 0 |
gda_sqlite_free_cnc_data (SqliteConnectionData *cdata)
{
if (!cdata)
return;
if (cdata->gdacnc)
g_object_remove_weak_pointer (G_OBJECT (cdata->gdacnc), (gpointer*) &(cdata->gdacnc));
if (cdata->connection)
SQLITE3_CALL (sqlite3_close) (cdata->connection);
g_free (cdata->file);
if (cdata->types_hash)
g_hash_table_destroy (cdata->types_hash);
if (cdata->types_array)
g_free (cdata->types_array);
g_free (cdata);
} | false | false | false | false | false | 0 |
make_ban_reason(const char *reason, const char *oper_reason)
{
static char buf[IRCD_BUFSIZE];
if(!EmptyString(oper_reason))
{
snprintf(buf, sizeof(buf), "%s|%s", reason, oper_reason);
return buf;
}
else
return reason;
} | false | false | false | false | false | 0 |
currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
{
Q_UNUSED(previous);
removeButton->setEnabled(current.isValid());
int row = current.row();
moveUpButton->setEnabled(row > 0);
moveDownButton->setEnabled(row != -1 && row < m_model.rowCount() - 1);
} | false | false | false | false | false | 0 |
pxav3_gen_init_74_clocks(struct sdhci_host *host, u8 power_mode)
{
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
struct sdhci_pxa *pxa = pltfm_host->priv;
u16 tmp;
int count;
if (pxa->power_mode == MMC_POWER_UP
&& power_mode == MMC_POWER_ON) {
dev_dbg(mmc_dev(host->mmc),
"%s: slot->power_mode = %d,"
"ios->power_mode = %d\n",
__func__,
pxa->power_mode,
power_mode);
/* set we want notice of when 74 clocks are sent */
tmp = readw(host->ioaddr + SD_CE_ATA_2);
tmp |= SDCE_MISC_INT_EN;
writew(tmp, host->ioaddr + SD_CE_ATA_2);
/* start sending the 74 clocks */
tmp = readw(host->ioaddr + SD_CFG_FIFO_PARAM);
tmp |= SDCFG_GEN_PAD_CLK_ON;
writew(tmp, host->ioaddr + SD_CFG_FIFO_PARAM);
/* slowest speed is about 100KHz or 10usec per clock */
udelay(740);
count = 0;
while (count++ < MAX_WAIT_COUNT) {
if ((readw(host->ioaddr + SD_CE_ATA_2)
& SDCE_MISC_INT) == 0)
break;
udelay(10);
}
if (count == MAX_WAIT_COUNT)
dev_warn(mmc_dev(host->mmc), "74 clock interrupt not cleared\n");
/* clear the interrupt bit if posted */
tmp = readw(host->ioaddr + SD_CE_ATA_2);
tmp |= SDCE_MISC_INT;
writew(tmp, host->ioaddr + SD_CE_ATA_2);
}
pxa->power_mode = power_mode;
} | false | false | false | false | false | 0 |
dm_internal_resume_fast(struct mapped_device *md)
{
if (dm_suspended_md(md) || dm_suspended_internally_md(md))
goto done;
dm_queue_flush(md);
done:
mutex_unlock(&md->suspend_lock);
} | false | false | false | false | false | 0 |
get_is_last_row(const Gtk::TreeModel::iterator& iter) const
{
if(iter)
{
//TODO: Avoid this. iter::operator() might not work properly with our custom tree model.
return iter == get_last_row();
}
else
return false;
} | false | false | false | false | false | 0 |
setSocketOptions(int opts)
{
QMutexLocker locker(mutex());
KSocketBase::setSocketOptions(opts); // call parent
bool result = socketDevice()->setSocketOptions(opts); // and set the implementation
copyError();
return result;
} | false | false | false | false | false | 0 |
haltAll() {
return ( transmit("H") && receive("H",NULL) );
} | false | false | false | false | false | 0 |
refactor_eh_r (gimple_seq seq)
{
gimple_stmt_iterator gsi;
gimple one, two;
one = NULL;
two = NULL;
gsi = gsi_start (seq);
while (1)
{
one = two;
if (gsi_end_p (gsi))
two = NULL;
else
two = gsi_stmt (gsi);
if (one
&& two
&& gimple_code (one) == GIMPLE_TRY
&& gimple_code (two) == GIMPLE_TRY
&& gimple_try_kind (one) == GIMPLE_TRY_FINALLY
&& gimple_try_kind (two) == GIMPLE_TRY_FINALLY)
optimize_double_finally (one, two);
if (one)
switch (gimple_code (one))
{
case GIMPLE_TRY:
refactor_eh_r (gimple_try_eval (one));
refactor_eh_r (gimple_try_cleanup (one));
break;
case GIMPLE_CATCH:
refactor_eh_r (gimple_catch_handler (one));
break;
case GIMPLE_EH_FILTER:
refactor_eh_r (gimple_eh_filter_failure (one));
break;
default:
break;
}
if (two)
gsi_next (&gsi);
else
break;
}
} | false | false | false | false | false | 0 |
key_ringing(struct unistimsession *pte, char keycode)
{
switch (keycode) {
case KEY_FAV0:
case KEY_FAV1:
case KEY_FAV2:
case KEY_FAV3:
case KEY_FAV4:
case KEY_FAV5:
handle_key_fav(pte, keycode);
break;
case KEY_FUNC3:
ignore_call(pte);
break;
case KEY_HANGUP:
case KEY_FUNC4:
discard_call(pte);
break;
case KEY_LOUDSPK:
pte->device->output = OUTPUT_SPEAKER;
handle_call_incoming(pte);
break;
case KEY_HEADPHN:
pte->device->output = OUTPUT_HEADPHONE;
handle_call_incoming(pte);
break;
case KEY_FUNC1:
handle_call_incoming(pte);
break;
}
return;
} | false | false | false | false | false | 0 |
GetStringTableString(P_WBXML_NODE node, long index)
{
/* Find the string table node */
P_WBXML_NODE pStringsNode = node;
while (pStringsNode->m_parent)
{
pStringsNode = pStringsNode->m_parent;
}
while (pStringsNode->m_next)
{
pStringsNode = pStringsNode->m_next;
}
while (pStringsNode->m_prev && pStringsNode->m_type != NODE_STRING_TABLE)
{
pStringsNode = pStringsNode->m_prev;
}
if (pStringsNode->m_type != NODE_STRING_TABLE)
{
return "!!NO STRING TABLE!!";
}
/* Find the indexed string */
if ((index >= 0) && (index < mb_u_int32_to_long(&((P_WBXML_STRING_TABLE)pStringsNode->m_data)->m_length)))
{
return (const char*) &(((P_WBXML_STRING_TABLE)pStringsNode->m_data)->m_strings[index]);
}
else
{
return "!!STRING TABLE INDEX TOO LARGE!!";
}
} | false | false | false | false | false | 0 |
filtering(const IplImage &src, IplImage* rst) {
for (int row = 0; row < src.height; row++) {
uchar* pImg = (uchar*) (src.imageData + row * src.widthStep);
uchar* pResult = (uchar*) (rst->imageData + row * rst->widthStep);
for (int col = 0; col < src.width; col++) {
for (int ch = 0; ch < 3; ++ch) {
if (ch == 0)
pResult[3 * col + ch] = gammaTableB[pImg[3 * col + ch]];
if (ch == 1)
pResult[3 * col + ch] = gammaTableG[pImg[3 * col + ch]];
if (ch == 2)
pResult[3 * col + ch] = gammaTableR[pImg[3 * col + ch]];
}
}
}
cvCopy(rst, backupResultImg);
} | false | false | false | false | false | 0 |
server_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, gf_dirent_t *entries, dict_t *xdata)
{
gfs3_readdir_rsp rsp = {0,};
server_state_t *state = NULL;
rpcsvc_request_t *req = NULL;
int ret = 0;
req = frame->local;
state = CALL_STATE(frame);
if (op_ret > 0) {
ret = serialize_rsp_dirent (entries, &rsp);
if (ret == -1) {
op_ret = -1;
op_errno = ENOMEM;
goto out;
}
} else {
/* (op_ret == 0) is valid, and means EOF, don't log for that */
gf_log (this->name, (op_ret) ? GF_LOG_INFO : GF_LOG_TRACE,
"%"PRId64": READDIR %"PRId64" (%s) ==> %"PRId32
" (%s)", frame->root->unique, state->resolve.fd_no,
state->fd ? uuid_utoa (state->fd->inode->gfid) : "--",
op_ret, strerror (op_errno));
}
GF_PROTOCOL_DICT_SERIALIZE (this, xdata, (&rsp.xdata.xdata_val),
rsp.xdata.xdata_len, op_errno, out);
out:
rsp.op_ret = op_ret;
rsp.op_errno = gf_errno_to_error (op_errno);
server_submit_reply (frame, req, &rsp, NULL, 0, NULL,
(xdrproc_t)xdr_gfs3_readdir_rsp);
if (rsp.xdata.xdata_val)
GF_FREE (rsp.xdata.xdata_val);
readdir_rsp_cleanup (&rsp);
return 0;
} | false | false | false | false | false | 0 |
sspm_property_name(const char* line)
{
static char name[1024];
char *c = strchr(line,':');
if(c != 0){
strncpy(name,line,(size_t)c-(size_t)line);
name[(size_t)c-(size_t)line] = '\0';
return name;
} else {
return 0;
}
} | true | true | false | false | false | 1 |
printgroup(char *name)
{
struct grouphead *gh;
struct group *gp;
if ((gh = findgroup(name)) == NULL) {
printf(catgets(catd, CATSET, 202, "\"%s\": not a group\n"),
name);
return;
}
printf("%s\t", gh->g_name);
for (gp = gh->g_list; gp != NULL; gp = gp->ge_link)
printf(" %s", gp->ge_name);
putchar('\n');
} | false | false | false | false | true | 1 |
_bfd_elf_add_dynamic_entry (struct bfd_link_info *info,
bfd_vma tag,
bfd_vma val)
{
struct elf_link_hash_table *hash_table;
const struct elf_backend_data *bed;
asection *s;
bfd_size_type newsize;
bfd_byte *newcontents;
Elf_Internal_Dyn dyn;
hash_table = elf_hash_table (info);
if (! is_elf_hash_table (hash_table))
return FALSE;
bed = get_elf_backend_data (hash_table->dynobj);
s = bfd_get_linker_section (hash_table->dynobj, ".dynamic");
BFD_ASSERT (s != NULL);
newsize = s->size + bed->s->sizeof_dyn;
newcontents = (bfd_byte *) bfd_realloc (s->contents, newsize);
if (newcontents == NULL)
return FALSE;
dyn.d_tag = tag;
dyn.d_un.d_val = val;
bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->size);
s->size = newsize;
s->contents = newcontents;
return TRUE;
} | false | false | false | true | false | 1 |
kanjiputs3(s, cx2, len2, ptr, top)
CONST char *s;
int cx2, len2, ptr, top;
{
int n, width;
if (!searchmode || ptr + len2 <= top || ptr >= cx2) {
VOID_C kanjiputs2(s, len2, ptr);
return;
}
width = cx2 - top;
n = top - ptr;
if (n <= 0) width += n;
else {
VOID_C kanjiputs2(s, n, ptr);
ptr += n;
len2 -= n;
}
VOID_C attrkanjiputs2(s, width, ptr);
ptr += width;
len2 -= width;
if (len2 > 0) VOID_C kanjiputs2(s, len2, ptr);
} | false | false | false | false | false | 0 |
CCinit(context_type *context)
{
struct CCpool *new = (struct CCpool *) malloc(sizeof(struct CCpool));
/* Set context->CCroot to 0 if new == 0 to tell CCdestroy to lay off */
context->CCroot = context->CCcurrent = new;
if (new == 0) {
CCout_of_memory(context);
}
new->next = NULL;
new->segSize = CCSegSize;
context->CCfree_size = CCSegSize;
context->CCfree_ptr = &new->space[0];
} | false | false | false | false | false | 0 |
extract_bo(uint32 insn, bool *invalid)
{
uint32 value;
value = (insn >> 21) & 0x1f;
if (invalid != NULL && !valid_bo(value))
*invalid = true;
return value;
} | false | false | false | false | false | 0 |
get_augroup_name(xp, idx)
expand_T *xp UNUSED;
int idx;
{
if (idx == augroups.ga_len) /* add "END" add the end */
return (char_u *)"END";
if (idx >= augroups.ga_len) /* end of list */
return NULL;
if (AUGROUP_NAME(idx) == NULL) /* skip deleted entries */
return (char_u *)"";
return AUGROUP_NAME(idx); /* return a name */
} | false | false | false | false | false | 0 |
animationState(const QStyleOption &option,
const QModelIndex &index,
const QAbstractItemView *view)
{
// We can't do animations reliably when an item is being dragged, since that
// item will be drawn in two locations at the same time and hovered in one and
// not the other. We can't tell them apart because they both have the same index.
if (!view || static_cast<const ProtectedAccessor*>(view)->draggingState())
return NULL;
AnimationState *state = findAnimationState(view, index);
bool hover = option.state & QStyle::State_MouseOver;
// If the cursor has entered an item
if (!state && hover)
{
state = new AnimationState(index);
addAnimationState(state, view);
if (!fadeInAddTime.isValid() ||
(fadeInAddTime.isValid() && fadeInAddTime.elapsed() > 300))
{
startAnimation(state);
}
else
{
state->animating = false;
state->progress = 1.0;
state->direction = QTimeLine::Forward;
}
fadeInAddTime.restart();
eventuallyStartIteration(index);
}
else if (state)
{
// If the cursor has exited an item
if (!hover && (!state->animating || state->direction == QTimeLine::Forward))
{
state->direction = QTimeLine::Backward;
if (state->creationTime.elapsed() < 200)
state->progress = 0.0;
startAnimation(state);
// Stop sequence iteration
if (index == sequenceModelIndex)
{
setSequenceIndex(0);
sequenceModelIndex = QPersistentModelIndex();
}
}
else if (hover && state->direction == QTimeLine::Backward)
{
// This is needed to handle the case where an item is dragged within
// the view, and dropped in a different location. State_MouseOver will
// initially not be set causing a "hover out" animation to start.
// This reverses the direction as soon as we see the bit being set.
state->direction = QTimeLine::Forward;
if (!state->animating)
startAnimation(state);
eventuallyStartIteration(index);
}
}
else if (!state && index.model()->data(index, KDirModel::HasJobRole).toBool())
{
state = new AnimationState(index);
addAnimationState(state, view);
startAnimation(state);
state->setJobAnimation(true);
}
return state;
} | false | false | false | false | false | 0 |
gfs_xmlattr_ctx_free(struct gfs_xmlattr_ctx *ctxp, int freepath)
{
if (ctxp != NULL) {
gfs_xmlattr_ctx_free_entries(ctxp, freepath);
free(ctxp->path);
free(ctxp->expr);
free(ctxp->cookie_path);
free(ctxp->cookie_attrname);
free(ctxp->workpath);
free(ctxp);
}
} | false | false | false | false | false | 0 |
UnsetRace(ARegionArray *pArr)
{
int x, y;
for(x = 0; x < pArr->x; x++) {
for(y = 0; y < pArr->y; y++) {
ARegion *reg = pArr->GetRegion(x, y);
if(!reg) continue;
reg->race = - 1;
}
}
} | false | false | false | false | false | 0 |
btree_remove(struct btree *btree, const void *key)
{
btree_iterator iter;
bool success = false;
bool multi = btree->multi;
do {
if (btree_find_first(btree, key, iter)) {
btree_remove_at(iter);
success = true;
}
} while (multi);
return success;
} | false | false | false | false | false | 0 |
sanitname(char *name)
{
while(*name) {
if(!isascii(*name) || strchr("%\\\t\n\r", *name))
*name = '_';
name++;
}
} | false | false | false | false | false | 0 |
__d_obtain_alias(struct inode *inode, int disconnected)
{
static const struct qstr anonstring = QSTR_INIT("/", 1);
struct dentry *tmp;
struct dentry *res;
unsigned add_flags;
if (!inode)
return ERR_PTR(-ESTALE);
if (IS_ERR(inode))
return ERR_CAST(inode);
res = d_find_any_alias(inode);
if (res)
goto out_iput;
tmp = __d_alloc(inode->i_sb, &anonstring);
if (!tmp) {
res = ERR_PTR(-ENOMEM);
goto out_iput;
}
spin_lock(&inode->i_lock);
res = __d_find_any_alias(inode);
if (res) {
spin_unlock(&inode->i_lock);
dput(tmp);
goto out_iput;
}
/* attach a disconnected dentry */
add_flags = d_flags_for_inode(inode);
if (disconnected)
add_flags |= DCACHE_DISCONNECTED;
spin_lock(&tmp->d_lock);
__d_set_inode_and_type(tmp, inode, add_flags);
hlist_add_head(&tmp->d_u.d_alias, &inode->i_dentry);
hlist_bl_lock(&tmp->d_sb->s_anon);
hlist_bl_add_head(&tmp->d_hash, &tmp->d_sb->s_anon);
hlist_bl_unlock(&tmp->d_sb->s_anon);
spin_unlock(&tmp->d_lock);
spin_unlock(&inode->i_lock);
security_d_instantiate(tmp, inode);
return tmp;
out_iput:
if (res && !IS_ERR(res))
security_d_instantiate(res, inode);
iput(inode);
return res;
} | false | false | false | false | false | 0 |
RefUnderlyingRasterBand()
{
poUnderlyingMainRasterBand = poMainBand->RefUnderlyingRasterBand();
if (poUnderlyingMainRasterBand == NULL)
return NULL;
nRefCountUnderlyingMainRasterBand ++;
return poUnderlyingMainRasterBand->GetMaskBand();
} | false | false | false | false | false | 0 |
get_faction_from_id(int faction_id)
{
if ((faction_id < 0) || (faction_id >= (sizeof(factions) / sizeof(factions[0])))) {
ErrorMessage(__FUNCTION__, "Malformed faction id! Faction %d does not exist.", PLEASE_INFORM, IS_WARNING_ONLY, faction_id);
return factions[FACTION_SELF].name;
}
return factions[faction_id].name;
} | false | false | false | false | false | 0 |
FBottomTransform(SplineChar *sc,int layer,ItalicInfo *ii) {
if ( ii->f_rotate_top )
FBottomFromTop(sc,layer,ii);
else
FBottomGrows(sc,layer,ii);
} | false | false | false | false | false | 0 |
gf_clock_buffer_on(GF_Clock *ck)
{
gf_mx_p(ck->mx);
if (!ck->Buffering) gf_clock_pause(ck);
ck->Buffering += 1;
gf_mx_v(ck->mx);
} | false | false | false | false | false | 0 |
eval(const SeExprFuncNode* node, SeVec3d& result) const
{
SeVec3d param;
node->child(0)->eval(param);
bool processVec = node->child(0)->isVec();
CurveData<double> *data = (CurveData<double> *) node->getData();
if (processVec) {
for(int i=0;i<3;i++) result[i] = data->curve.getChannelValue(param[i], i);
} else {
result[0]=result[1]=result[2]=data->curve.getValue(param[0]);
}
} | false | false | false | false | false | 0 |
parse_greeting(mailimap * session,
struct mailimap_greeting ** result)
{
size_t indx;
struct mailimap_greeting * greeting;
int r;
indx = 0;
session->imap_response = NULL;
r = mailimap_greeting_parse(session->imap_stream,
session->imap_stream_buffer,
&indx, &greeting, session->imap_progr_rate,
session->imap_progr_fun);
if (r != MAILIMAP_NO_ERROR)
return r;
#if 0
mailimap_greeting_print(greeting);
#endif
greeting_store(session, greeting);
if (greeting->gr_type == MAILIMAP_GREETING_RESP_COND_BYE) {
if (greeting->gr_data.gr_bye->rsp_text->rsp_text != NULL) {
if (mmap_string_assign(session->imap_response_buffer,
greeting->gr_data.gr_bye->rsp_text->rsp_text) == NULL)
return MAILIMAP_ERROR_MEMORY;
}
session->imap_response = session->imap_response_buffer->str;
return MAILIMAP_ERROR_DONT_ACCEPT_CONNECTION;
}
if (greeting->gr_data.gr_auth->rsp_text->rsp_text != NULL) {
if (mmap_string_assign(session->imap_response_buffer,
greeting->gr_data.gr_auth->rsp_text->rsp_text) == NULL)
return MAILIMAP_ERROR_MEMORY;
}
session->imap_response = session->imap_response_buffer->str;
* result = greeting;
return MAILIMAP_NO_ERROR;
} | false | false | false | false | false | 0 |
data_vels(int n, char *buf)
{
int j,m,tagdata;
char *next;
next = strchr(buf,'\n');
*next = '\0';
int nwords = count_words(buf);
*next = '\n';
if (nwords != avec->size_data_vel)
error->all(FLERR,"Incorrect velocity format in data file");
char **values = new char*[nwords];
// loop over lines of atom velocities
// tokenize the line into values
// if I own atom tag, unpack its values
for (int i = 0; i < n; i++) {
next = strchr(buf,'\n');
values[0] = strtok(buf," \t\n\r\f");
for (j = 1; j < nwords; j++)
values[j] = strtok(NULL," \t\n\r\f");
tagdata = atoi(values[0]);
if (tagdata <= 0 || tagdata > map_tag_max)
error->one(FLERR,"Invalid atom ID in Velocities section of data file");
if ((m = map(tagdata)) >= 0) avec->data_vel(m,&values[1]);
buf = next + 1;
}
delete [] values;
} | false | false | false | false | false | 0 |
UploadFile(const char* url, const char* filename)
{
if(m_APIToken == "")
{
std::cerr << "Token should be defined to upload to MIDAS.";
std::cerr << "Please use the Login() function to get a token." << std::endl;
this->GetRestXMLParser()->SetErrorMessage("Cannot push using anonymous access.");
return false;
}
std::string completeUrl = url;
completeUrl += "&token=";
completeUrl += m_APIToken;
return m_RestAPI->UploadPost(filename,completeUrl);
} | false | false | false | false | false | 0 |
mei_ioctl_connect_client(struct file *file,
struct mei_connect_client_data *data)
{
struct mei_device *dev;
struct mei_client *client;
struct mei_me_client *me_cl;
struct mei_cl *cl;
int rets;
cl = file->private_data;
dev = cl->dev;
if (dev->dev_state != MEI_DEV_ENABLED)
return -ENODEV;
if (cl->state != MEI_FILE_INITIALIZING &&
cl->state != MEI_FILE_DISCONNECTED)
return -EBUSY;
/* find ME client we're trying to connect to */
me_cl = mei_me_cl_by_uuid(dev, &data->in_client_uuid);
if (!me_cl ||
(me_cl->props.fixed_address && !dev->allow_fixed_address)) {
dev_dbg(dev->dev, "Cannot connect to FW Client UUID = %pUl\n",
&data->in_client_uuid);
mei_me_cl_put(me_cl);
return -ENOTTY;
}
dev_dbg(dev->dev, "Connect to FW Client ID = %d\n",
me_cl->client_id);
dev_dbg(dev->dev, "FW Client - Protocol Version = %d\n",
me_cl->props.protocol_version);
dev_dbg(dev->dev, "FW Client - Max Msg Len = %d\n",
me_cl->props.max_msg_length);
/* if we're connecting to amthif client then we will use the
* existing connection
*/
if (uuid_le_cmp(data->in_client_uuid, mei_amthif_guid) == 0) {
dev_dbg(dev->dev, "FW Client is amthi\n");
if (!mei_cl_is_connected(&dev->iamthif_cl)) {
rets = -ENODEV;
goto end;
}
mei_cl_unlink(cl);
kfree(cl);
cl = NULL;
dev->iamthif_open_count++;
file->private_data = &dev->iamthif_cl;
client = &data->out_client_properties;
client->max_msg_length = me_cl->props.max_msg_length;
client->protocol_version = me_cl->props.protocol_version;
rets = dev->iamthif_cl.status;
goto end;
}
/* prepare the output buffer */
client = &data->out_client_properties;
client->max_msg_length = me_cl->props.max_msg_length;
client->protocol_version = me_cl->props.protocol_version;
dev_dbg(dev->dev, "Can connect?\n");
rets = mei_cl_connect(cl, me_cl, file);
end:
mei_me_cl_put(me_cl);
return rets;
} | false | false | false | false | false | 0 |
playlistLayoutChanged()
{
if ( LayoutManager::instance()->activeLayout().inlineControls() )
m_animationTimer->start();
else
m_animationTimer->stop();
// -- update the tooltip columns in the playlist model
bool tooltipColumns[Playlist::NUM_COLUMNS];
for( int i=0; i<Playlist::NUM_COLUMNS; ++i )
tooltipColumns[i] = true;
// bool excludeCover = false;
for( int part = 0; part < PlaylistLayout::NumParts; part++ )
{
// bool single = ( part == PlaylistLayout::Single );
Playlist::PlaylistLayout layout = Playlist::LayoutManager::instance()->activeLayout();
Playlist::LayoutItemConfig item = layout.layoutForPart( (PlaylistLayout::Part)part );
for (int activeRow = 0; activeRow < item.rows(); activeRow++)
{
for (int activeElement = 0; activeElement < item.row(activeRow).count();activeElement++)
{
Playlist::Column column = (Playlist::Column)item.row(activeRow).element(activeElement).value();
tooltipColumns[column] = false;
}
}
// excludeCover |= item.showCover();
}
Playlist::Model::setTooltipColumns( tooltipColumns );
Playlist::Model::enableToolTip( Playlist::LayoutManager::instance()->activeLayout().tooltips() );
update();
// Schedule a re-scroll to the active playlist row. Assumption: Qt will run this *after* the repaint.
QTimer::singleShot( 0, this, SLOT(slotPlaylistActiveTrackChanged()) );
} | false | false | false | false | false | 0 |
cp_event(struct hid_device *hdev, struct hid_field *field,
struct hid_usage *usage, __s32 value)
{
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
!usage->type || !(quirks & CP_2WHEEL_MOUSE_HACK))
return 0;
if (usage->hid == 0x00090005) {
if (value)
quirks |= CP_2WHEEL_MOUSE_HACK_ON;
else
quirks &= ~CP_2WHEEL_MOUSE_HACK_ON;
hid_set_drvdata(hdev, (void *)quirks);
return 1;
}
if (usage->code == REL_WHEEL && (quirks & CP_2WHEEL_MOUSE_HACK_ON)) {
struct input_dev *input = field->hidinput->input;
input_event(input, usage->type, REL_HWHEEL, value);
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
typicalValue(double *x, unsigned int length,
vector<double const *> const &par,
vector<unsigned int> const &len,
double const *lower, double const *upper) const
{
double alphasum = 0.0;
for (unsigned int i = 0; i < length; ++i) {
alphasum += ALPHA(par)[i];
}
for (unsigned int i = 0; i < length; ++i) {
x[i] = ALPHA(par)[i]/alphasum;
}
} | false | false | false | false | false | 0 |
readXmlFile(const char *ifname,
DcmFileFormat &fileformat,
E_TransferSyntax &xfer,
const OFBool metaInfo,
const OFBool checkNamespace,
const OFBool validateDocument)
{
OFCondition result = EC_Normal;
xfer = EXS_Unknown;
xmlGenericError(xmlGenericErrorContext, "--- libxml parsing ------\n");
/* build an XML tree from the file */
xmlDocPtr doc = xmlParseFile(ifname);
xmlGenericError(xmlGenericErrorContext, "-------------------------\n");
if (doc != NULL)
{
/* validate document */
if (validateDocument)
result = validateXmlDocument(doc);
if (result.good())
{
/* check whether the document is of the right kind */
xmlNodePtr current = xmlDocGetRootElement(doc);
if (current != NULL)
{
/* check namespace declaration (if required) */
if (!checkNamespace || (xmlSearchNsByHref(doc, current, OFreinterpret_cast(const xmlChar *, DCMTK_XML_NAMESPACE_URI)) != NULL))
{
/* check whether to parse a "file-format" or "data-set" */
if (xmlStrcmp(current->name, OFreinterpret_cast(const xmlChar *, "file-format")) == 0)
{
OFLOG_INFO(xml2dcmLogger, "parsing file-format ...");
if (metaInfo)
OFLOG_INFO(xml2dcmLogger, "parsing meta-header ...");
else
OFLOG_INFO(xml2dcmLogger, "skipping meta-header ...");
current = current->xmlChildrenNode;
/* ignore blank (empty or whitespace only) nodes */
while ((current != NULL) && xmlIsBlankNode(current))
current = current->next;
/* parse/skip "meta-header" */
result = parseMetaHeader(fileformat.getMetaInfo(), current, metaInfo /*parse*/);
if (result.good())
{
current = current->next;
/* ignore blank (empty or whitespace only) nodes */
while ((current != NULL) && xmlIsBlankNode(current))
current = current->next;
}
}
/* there should always be a "data-set" node */
if (result.good())
{
OFLOG_INFO(xml2dcmLogger, "parsing data-set ...");
/* parse "data-set" */
result = checkNode(current, "data-set");
if (result.good())
{
DcmDataset *dataset = fileformat.getDataset();
/* determine stored transfer syntax */
xmlChar *xferUID = xmlGetProp(current, OFreinterpret_cast(const xmlChar *, "xfer"));
if (xferUID != NULL)
xfer = DcmXfer(OFreinterpret_cast(char *, xferUID)).getXfer();
result = parseDataSet(dataset, current->xmlChildrenNode, xfer);
/* free allocated memory */
xmlFree(xferUID);
}
}
if (result.bad() && xmlLogger.isEnabledFor(OFLogger::DEBUG_LOG_LEVEL))
{
/* dump XML document for debugging purposes */
xmlChar *str;
int size;
xmlDocDumpFormatMemory(doc, &str, &size, 1);
OFLOG_DEBUG(xmlLogger, str);
xmlFree(str);
}
} else {
OFLOG_ERROR(xml2dcmLogger, "document has wrong type, dcmtk namespace not found");
result = EC_IllegalCall;
}
} else {
OFLOG_ERROR(xml2dcmLogger, "document is empty: " << ifname);
result = EC_IllegalCall;
}
}
} else {
OFLOG_ERROR(xml2dcmLogger, "could not parse document: " << ifname);
result = EC_IllegalCall;
}
/* free allocated memory */
xmlFreeDoc(doc);
return result;
} | false | false | false | false | false | 0 |
stat_to_cpio (struct cpio_file_stat *hdr, struct stat *st)
{
hdr->c_dev_maj = major (st->st_dev);
hdr->c_dev_min = minor (st->st_dev);
hdr->c_ino = st->st_ino;
/* For POSIX systems that don't define the S_IF macros,
we can't assume that S_ISfoo means the standard Unix
S_IFfoo bit(s) are set. So do it manually, with a
different name. Bleah. */
hdr->c_mode = (st->st_mode & 07777);
if (S_ISREG (st->st_mode))
hdr->c_mode |= CP_IFREG;
else if (S_ISDIR (st->st_mode))
hdr->c_mode |= CP_IFDIR;
#ifdef S_ISBLK
else if (S_ISBLK (st->st_mode))
hdr->c_mode |= CP_IFBLK;
#endif
#ifdef S_ISCHR
else if (S_ISCHR (st->st_mode))
hdr->c_mode |= CP_IFCHR;
#endif
#ifdef S_ISFIFO
else if (S_ISFIFO (st->st_mode))
hdr->c_mode |= CP_IFIFO;
#endif
#ifdef S_ISLNK
else if (S_ISLNK (st->st_mode))
hdr->c_mode |= CP_IFLNK;
#endif
#ifdef S_ISSOCK
else if (S_ISSOCK (st->st_mode))
hdr->c_mode |= CP_IFSOCK;
#endif
#ifdef S_ISNWK
else if (S_ISNWK (st->st_mode))
hdr->c_mode |= CP_IFNWK;
#endif
hdr->c_nlink = st->st_nlink;
hdr->c_uid = CPIO_UID (st->st_uid);
hdr->c_gid = CPIO_GID (st->st_gid);
hdr->c_rdev_maj = major (st->st_rdev);
hdr->c_rdev_min = minor (st->st_rdev);
hdr->c_mtime = st->st_mtime;
hdr->c_filesize = st->st_size;
hdr->c_chksum = 0;
hdr->c_tar_linkname = NULL;
} | false | false | false | false | false | 0 |
ompi_coll_tuned_allgather_intra_do_forced(void *sbuf, int scount,
struct ompi_datatype_t *sdtype,
void* rbuf, int rcount,
struct ompi_datatype_t *rdtype,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_tuned_module_t *tuned_module = (mca_coll_tuned_module_t*) module;
mca_coll_tuned_comm_t *data = tuned_module->tuned_data;
OPAL_OUTPUT((ompi_coll_tuned_stream,
"coll:tuned:allgather_intra_do_forced selected algorithm %d",
data->user_forced[ALLGATHER].algorithm));
switch (data->user_forced[ALLGATHER].algorithm) {
case (0):
return ompi_coll_tuned_allgather_intra_dec_fixed (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (1):
return ompi_coll_tuned_allgather_intra_basic_linear (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (2):
return ompi_coll_tuned_allgather_intra_bruck (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (3):
return ompi_coll_tuned_allgather_intra_recursivedoubling (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (4):
return ompi_coll_tuned_allgather_intra_ring (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (5):
return ompi_coll_tuned_allgather_intra_neighborexchange (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
case (6):
return ompi_coll_tuned_allgather_intra_two_procs (sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm, module);
default:
OPAL_OUTPUT((ompi_coll_tuned_stream,
"coll:tuned:allgather_intra_do_forced attempt to select algorithm %d when only 0-%d is valid?",
data->user_forced[ALLGATHER].algorithm,
ompi_coll_tuned_forced_max_algorithms[ALLGATHER]));
return (MPI_ERR_ARG);
} /* switch */
} | false | false | false | false | false | 0 |
setContent( QString text, QString *errorMsg,
int *errorLine, int *errorColumn )
{
clear();
QString prefix = "<?xml version=\"2.0\"?>\n";
prefix.append( entityDeclarations() );
uint prefix_lines = 0;
for ( int i = 0; i < prefix.length(); ++i )
{
if ( prefix.at( i ) == '\n' )
++prefix_lines;
}
QDomDocument dom;
if ( !dom.setContent( prefix + text, false, errorMsg, errorLine, errorColumn ) )
{
if ( errorLine != 0 )
*errorLine -= prefix_lines;
return false;
}
// we don't have access to line info from now on
if ( errorLine != 0 ) *errorLine = -1;
if ( errorColumn != 0 ) *errorColumn = -1;
bool ok;
QwtMmlNode *root_node = domToMml( dom, &ok, errorMsg );
if ( !ok )
return false;
if ( root_node == 0 )
{
if ( errorMsg != 0 )
*errorMsg = "empty document";
return false;
}
insertChild( 0, root_node, 0 );
layout();
/* QFile of("/tmp/dump.xml");
of.open(IO_WriteOnly);
QTextStream os(&of);
os.setEncoding(QTextStream::UnicodeUTF8);
os << dom.toString(); */
return true;
} | 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.