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
|
---|---|---|---|---|---|---|
register_timer_ticks(void* this_ptr, bx_timer_handler_t funct,
Bit64u ticks, bx_bool continuous, bx_bool active, const char *id)
{
unsigned i;
// If the timer frequency is rediculously low, make it more sane.
// This happens when 'ips' is too low.
if (ticks < MinAllowableTimerPeriod) {
//BX_INFO(("register_timer_ticks: adjusting ticks of %llu to min of %u",
// ticks, MinAllowableTimerPeriod));
ticks = MinAllowableTimerPeriod;
}
// search for new timer for i=1, i=0 is reserved for NullTimer
for (i=1; i < numTimers; i++) {
if (timer[i].inUse == 0)
break;
}
#if BX_TIMER_DEBUG
if (i==0)
BX_PANIC(("register_timer: cannot register NullTimer again!"));
if (numTimers >= BX_MAX_TIMERS)
BX_PANIC(("register_timer: too many registered timers"));
if (this_ptr == NULL)
BX_PANIC(("register_timer_ticks: this_ptr is NULL!"));
if (funct == NULL)
BX_PANIC(("register_timer_ticks: funct is NULL!"));
#endif
timer[i].inUse = 1;
timer[i].period = ticks;
timer[i].timeToFire = (ticksTotal + Bit64u(currCountdownPeriod-currCountdown)) +
ticks;
timer[i].active = active;
timer[i].continuous = continuous;
timer[i].funct = funct;
timer[i].this_ptr = this_ptr;
strncpy(timer[i].id, id, BxMaxTimerIDLen);
timer[i].id[BxMaxTimerIDLen-1] = 0; // Null terminate if not already.
if (active) {
if (ticks < Bit64u(currCountdown)) {
// This new timer needs to fire before the current countdown.
// Skew the current countdown and countdown period to be smaller
// by the delta.
currCountdownPeriod -= (currCountdown - Bit32u(ticks));
currCountdown = Bit32u(ticks);
}
}
BX_DEBUG(("timer id %d registered for '%s'", i, id));
// If we didn't find a free slot, increment the bound, numTimers.
if (i==numTimers)
numTimers++; // One new timer installed.
// Return timer id.
return(i);
} | false | false | false | false | false | 0 |
sanei_hp_device_support_get (const char *devname, HpScl scl,
int *minval, int *maxval)
{HpDeviceInfo *info;
HpSclSupport *sclsupport;
int inqid;
/* #define HP_TEST_SIMULATE */
#ifdef HP_TEST_SIMULATE
if (scl == SCL_BRIGHTNESS) return SANE_STATUS_UNSUPPORTED;
if (scl == SCL_CONTRAST) return SANE_STATUS_UNSUPPORTED;
if (scl == SCL_DOWNLOAD_TYPE)
{
*minval = 2; *maxval = 14;
return SANE_STATUS_GOOD;
}
#endif
info = sanei_hp_device_info_get ( devname );
if (!info) return SANE_STATUS_INVAL;
inqid = SCL_INQ_ID(scl)-HP_SCL_INQID_MIN;
sclsupport = &(info->sclsupport[inqid]);
if ( !(sclsupport->checked) ) return SANE_STATUS_INVAL;
if ( !(sclsupport->is_supported) ) return SANE_STATUS_UNSUPPORTED;
if (minval) *minval = sclsupport->minval;
if (maxval) *maxval = sclsupport->maxval;
return SANE_STATUS_GOOD;
} | false | false | false | false | false | 0 |
createInstance(const Locale & inLocale, UErrorCode& status) {
if (U_FAILURE(status)) {
return NULL;
}
UBool nsResolved = TRUE;
UBool usingFallback = FALSE;
char buffer[ULOC_KEYWORDS_CAPACITY];
int32_t count = inLocale.getKeywordValue("numbers",buffer, sizeof(buffer),status);
if ( count > 0 ) { // @numbers keyword was specified in the locale
buffer[count] = '\0'; // Make sure it is null terminated.
if ( !uprv_strcmp(buffer,gDefault) || !uprv_strcmp(buffer,gNative) ||
!uprv_strcmp(buffer,gTraditional) || !uprv_strcmp(buffer,gFinance)) {
nsResolved = FALSE;
}
} else {
uprv_strcpy(buffer,gDefault);
nsResolved = FALSE;
}
if (!nsResolved) { // Resolve the numbering system ( default, native, traditional or finance ) into a "real" numbering system
UErrorCode localStatus = U_ZERO_ERROR;
UResourceBundle *resource = ures_open(NULL, inLocale.getName(), &localStatus);
UResourceBundle *numberElementsRes = ures_getByKey(resource,gNumberElements,NULL,&localStatus);
while (!nsResolved) {
localStatus = U_ZERO_ERROR;
count = 0;
const UChar *nsName = ures_getStringByKeyWithFallback(numberElementsRes, buffer, &count, &localStatus);
if ( count > 0 && count < ULOC_KEYWORDS_CAPACITY ) { // numbering system found
u_UCharsToChars(nsName,buffer,count);
buffer[count] = '\0'; // Make sure it is null terminated.
nsResolved = TRUE;
}
if (!nsResolved) { // Fallback behavior per TR35 - traditional falls back to native, finance and native fall back to default
if (!uprv_strcmp(buffer,gNative) || !uprv_strcmp(buffer,gFinance)) {
uprv_strcpy(buffer,gDefault);
} else if (!uprv_strcmp(buffer,gTraditional)) {
uprv_strcpy(buffer,gNative);
} else { // If we get here we couldn't find even the default numbering system
usingFallback = TRUE;
nsResolved = TRUE;
}
}
}
ures_close(numberElementsRes);
ures_close(resource);
}
if (usingFallback) {
status = U_USING_FALLBACK_WARNING;
NumberingSystem *ns = new NumberingSystem();
return ns;
} else {
return NumberingSystem::createInstanceByName(buffer,status);
}
} | false | false | false | false | false | 0 |
commitLanguages(const CI18nTranslator& inTranslator){
for(CLanguageList::const_iterator i=mLanguages.begin();
i!=mLanguages.end();
i++){
if(inTranslator.hasLanguage(*i)){
mPreferredLanguage=*i;
break;
}
}
} | false | false | false | false | false | 0 |
ScrollSignal(GtkAdjustment *adj, ScintillaGTK *sciThis) {
try {
#if GTK_CHECK_VERSION(3,0,0)
sciThis->ScrollTo(static_cast<int>(gtk_adjustment_get_value(adj)), false);
#else
sciThis->ScrollTo(static_cast<int>(adj->value), false);
#endif
} catch (...) {
sciThis->errorStatus = SC_STATUS_FAILURE;
}
} | false | false | false | false | false | 0 |
cert_FreeEntry(void *pool, PLHashEntry *he, PRUintn flag)
{
SECITEM_FreeItem((SECItem*)(he->value), PR_TRUE);
if (flag == HT_FREE_ENTRY) {
SECITEM_FreeItem((SECItem*)(he->key), PR_TRUE);
PORT_Free(he);
}
} | false | false | false | false | false | 0 |
print(raw_ostream &OS, const SelectionDAG *G) const {
printr(OS, G);
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
if (i) OS << ", "; else OS << " ";
printOperand(OS, G, getOperand(i));
}
} | false | false | false | false | false | 0 |
shuffle_playlist()
{
size_t loop;
size_t rannum;
if(pl.fill >= 2)
{
/* Refer to bug 1777621 for discussion on that.
It's Durstenfeld... */
for (loop = 0; loop < pl.fill; loop++)
{
struct listitem tmp;
rannum = loop + rando(pl.fill-loop);
/*
Small test on your binary operation skills (^ is XOR):
a = b^(a^b)
b = (a^b)^(b^(a^b))
And, understood? ;-)
pl.list[loop] ^= pl.list[rannum];
pl.list[rannum] ^= pl.list[loop];
pl.list[loop] ^= pl.list[rannum];
But since this is not allowed with pointers and any speed gain questionable (well, saving _some_ memory...), doing it the lame way:
*/
tmp = pl.list[rannum];
pl.list[rannum] = pl.list[loop];
pl.list[loop] = tmp;
}
}
if(param.verbose > 1)
{
/* print them */
fprintf(stderr, "\nshuffled playlist:\n");
print_playlist(stderr, 0);
fprintf(stderr, "\n");
}
} | false | false | false | false | false | 0 |
decode_I_options (char *line, char *abbrev, char *name, char *units, char *size, char *comment, double parameters[])
{ /* -I<abbrev>/<name>/<units>/<size>/<scale>/<offset>/\"comment\" */
GMT_LONG i = 0, k, error;
GMT_LONG pos = 0;
char p[BUFSIZ];
while (i < 7 && GMT_strtok (line, "/", &pos, p)) { /* Process the 7 items */
switch (i) {
case 0:
strcpy (abbrev, p);
/* Check abbrev for COARDS compliance as well as being lower case */
for (k = error = 0; abbrev[k]; k++) {
if (isupper ((int)abbrev[k])) error++;
if (isalpha ((int)abbrev[k])) continue;
if (isdigit ((int)abbrev[k]) && k > 0) continue;
if (abbrev[k] == '_' && k > 0) continue;
error++;
}
if (error) {
fprintf (stderr, "%s: Abbreviation name should only contain lower case letters, digits, and underscores\n", GMT_program);
return (TRUE);
}
break;
case 1:
strcpy (name, p);
break;
case 2:
strcpy (units, p);
break;
case 3:
*size = p[0];
break;
case 4:
parameters[COL_SCALE] = atof (p);
break;
case 5:
parameters[COL_OFFSET] = atof (p);
break;
case 6:
strcpy (comment, p);
break;
}
i++;
}
switch (*size) { /* Given size, set the NC type */
case 'b':
parameters[COL_TYPE] = NC_BYTE;
break;
case 'd':
parameters[COL_TYPE] = NC_DOUBLE;
break;
case 'f':
parameters[COL_TYPE] = NC_FLOAT;
break;
case 'i':
parameters[COL_TYPE] = NC_INT;
break;
case 's':
parameters[COL_TYPE] = NC_SHORT;
break;
case 't':
parameters[COL_TYPE] = NC_CHAR;
break;
default:
fprintf (stderr, "%s: Unknown data type flag %c\n", GMT_program, *size);
parameters[COL_TYPE] = MGD77_NOT_SET;
break;
}
return ((GMT_LONG)(irint (parameters[COL_TYPE]) == MGD77_NOT_SET) || (i != 7));
} | false | false | false | false | false | 0 |
TI_buildRemoteImages(TI_DBEntry *db, TI_StudyEntry *study, TI_SeriesEntry *series)
{
TI_GenericCallbackStruct cbs;
DcmDataset *query = NULL;
OFBool ok = OFTrue;
cbs.db = NULL;
cbs.study = NULL; cbs.series = series;
TI_destroyImageEntries(series);
/* get all known studies */
TI_buildImageQuery(&query, study, series);
ok = TI_remoteFindQuery(db, query, TI_genericEntryCallback, &cbs);
delete query;
return ok;
} | false | false | false | false | false | 0 |
carl9170_debugfs_write(struct file *file,
const char __user *userbuf, size_t count, loff_t *ppos)
{
struct carl9170_debugfs_fops *dfops;
struct ar9170 *ar;
char *buf = NULL;
int err = 0;
if (!count)
return 0;
if (count > PAGE_SIZE)
return -E2BIG;
ar = file->private_data;
if (!ar)
return -ENODEV;
dfops = container_of(file->f_op, struct carl9170_debugfs_fops, fops);
if (!dfops->write)
return -ENOSYS;
buf = vmalloc(count);
if (!buf)
return -ENOMEM;
if (copy_from_user(buf, userbuf, count)) {
err = -EFAULT;
goto out_free;
}
if (mutex_trylock(&ar->mutex) == 0) {
err = -EAGAIN;
goto out_free;
}
if (!CHK_DEV_STATE(ar, dfops->req_dev_state)) {
err = -ENODEV;
goto out_unlock;
}
err = dfops->write(ar, buf, count);
if (err)
goto out_unlock;
out_unlock:
mutex_unlock(&ar->mutex);
out_free:
vfree(buf);
return err;
} | false | false | false | false | false | 0 |
remove_quoted_nulls (string)
char *string;
{
register size_t slen;
register int i, j, prev_i;
DECLARE_MBSTATE;
if (strchr (string, CTLNUL) == 0) /* XXX */
return string; /* XXX */
slen = strlen (string);
i = j = 0;
while (i < slen)
{
if (string[i] == CTLESC)
{
/* Old code had j++, but we cannot assume that i == j at this
point -- what if a CTLNUL has already been removed from the
string? We don't want to drop the CTLESC or recopy characters
that we've already copied down. */
i++; string[j++] = CTLESC;
if (i == slen)
break;
}
else if (string[i] == CTLNUL)
i++;
prev_i = i;
ADVANCE_CHAR (string, slen, i);
if (j < prev_i)
{
do string[j++] = string[prev_i++]; while (prev_i < i);
}
else
j = i;
}
string[j] = '\0';
return (string);
} | false | false | false | false | false | 0 |
bxt_a_get_seqno(struct intel_engine_cs *ring, bool lazy_coherency)
{
/*
* On BXT A steppings there is a HW coherency issue whereby the
* MI_STORE_DATA_IMM storing the completed request's seqno
* occasionally doesn't invalidate the CPU cache. Work around this by
* clflushing the corresponding cacheline whenever the caller wants
* the coherency to be guaranteed. Note that this cacheline is known
* to be clean at this point, since we only write it in
* bxt_a_set_seqno(), where we also do a clflush after the write. So
* this clflush in practice becomes an invalidate operation.
*/
if (!lazy_coherency)
intel_flush_status_page(ring, I915_GEM_HWS_INDEX);
return intel_read_status_page(ring, I915_GEM_HWS_INDEX);
} | false | false | false | false | false | 0 |
ck_rhs_map_probe_rm(struct ck_rhs *hs,
struct ck_rhs_map *map,
unsigned long *n_probes,
long *priority,
unsigned long h,
const void *key,
const void **object,
unsigned long probe_limit,
enum ck_rhs_probe_behavior behavior)
{
const void *k;
const void *compare;
long pr = -1;
unsigned long offset, probes, opl;
#ifdef CK_RHS_PP
/* If we are storing object pointers, then we may leverage pointer packing. */
unsigned long hv = 0;
if (hs->mode & CK_RHS_MODE_OBJECT) {
hv = (h >> 25) & CK_RHS_KEY_MASK;
compare = CK_RHS_VMA(key);
} else {
compare = key;
}
#else
compare = key;
#endif
*object = NULL;
if (behavior != CK_RHS_PROBE_ROBIN_HOOD) {
probes = 0;
offset = h & map->mask;
} else {
/* Restart from the bucket we were previously in */
probes = *n_probes;
offset = ck_rhs_map_probe_next(map, *priority,
probes);
}
opl = probe_limit;
for (;;) {
if (probes++ == probe_limit) {
if (probe_limit == opl || pr != -1) {
k = CK_RHS_EMPTY;
goto leave;
}
/*
* If no eligible slot has been found yet, continue probe
* sequence with original probe limit.
*/
probe_limit = opl;
}
k = ck_pr_load_ptr(&map->entries.no_entries.entries[offset]);
if (k == CK_RHS_EMPTY)
goto leave;
if (behavior != CK_RHS_PROBE_NO_RH) {
struct ck_rhs_entry_desc *desc = (void *)&map->entries.no_entries.descs[offset];
if (pr == -1 &&
desc->in_rh == false && desc->probes < probes) {
pr = offset;
*n_probes = probes;
if (behavior == CK_RHS_PROBE_RH ||
behavior == CK_RHS_PROBE_ROBIN_HOOD) {
k = CK_RHS_EMPTY;
goto leave;
}
}
}
if (behavior != CK_RHS_PROBE_ROBIN_HOOD) {
#ifdef CK_RHS_PP
if (hs->mode & CK_RHS_MODE_OBJECT) {
if (((uintptr_t)k >> CK_MD_VMA_BITS) != hv) {
offset = ck_rhs_map_probe_next(map, offset, probes);
continue;
}
k = CK_RHS_VMA(k);
}
#endif
if (k == compare)
goto leave;
if (hs->compare == NULL) {
offset = ck_rhs_map_probe_next(map, offset, probes);
continue;
}
if (hs->compare(k, key) == true)
goto leave;
}
offset = ck_rhs_map_probe_next(map, offset, probes);
}
leave:
if (probes > probe_limit) {
offset = -1;
} else {
*object = k;
}
if (pr == -1)
*n_probes = probes;
*priority = pr;
return offset;
} | false | false | false | false | false | 0 |
Echo(struct paRecordData* data, AudBuff *proc_buff, struct audio_effects *aud_eff, int delay_ms, float decay)
{
int samp=0;
SAMPLE out;
if(aud_eff->ECHO == NULL)
{
aud_eff->ECHO = g_new0(delay_data, 1);
aud_eff->ECHO->buff_size = (int) delay_ms * data->samprate * 0.001;
aud_eff->ECHO->delayBuff1 = g_new0(SAMPLE, aud_eff->ECHO->buff_size);
aud_eff->ECHO->delayBuff2 = NULL;
if(data->channels > 1)
aud_eff->ECHO->delayBuff2 = g_new0(SAMPLE, aud_eff->ECHO->buff_size);
}
for(samp = 0; samp < data->aud_numSamples; samp = samp + data->channels)
{
out = (0.7 * proc_buff->frame[samp]) +
(0.3 * aud_eff->ECHO->delayBuff1[aud_eff->ECHO->delayIndex]);
aud_eff->ECHO->delayBuff1[aud_eff->ECHO->delayIndex] = proc_buff->frame[samp] +
(aud_eff->ECHO->delayBuff1[aud_eff->ECHO->delayIndex] * decay);
proc_buff->frame[samp] = clip_float(out);
/*if stereo process second channel in separate*/
if (data->channels > 1)
{
out = (0.7 * proc_buff->frame[samp+1]) +
(0.3 * aud_eff->ECHO->delayBuff2[aud_eff->ECHO->delayIndex]);
aud_eff->ECHO->delayBuff2[aud_eff->ECHO->delayIndex] = proc_buff->frame[samp] +
(aud_eff->ECHO->delayBuff2[aud_eff->ECHO->delayIndex] * decay);
proc_buff->frame[samp+1] = clip_float(out);
}
if(++(aud_eff->ECHO->delayIndex) >= aud_eff->ECHO->buff_size) aud_eff->ECHO->delayIndex=0;
}
} | false | false | false | false | false | 0 |
Scm_MakeIntegerU(u_long i)
{
if (i <= (u_long)SCM_SMALL_INT_MAX) return SCM_MAKE_INT(i);
else return Scm_MakeBignumFromUI(i);
} | false | false | false | false | false | 0 |
mud_connections_connect_cb(GtkWidget *widget, MudConnections *conn)
{
GList *selected =
gtk_icon_view_get_selected_items(
GTK_ICON_VIEW(conn->priv->iconview));
GtkTreeIter iter;
gchar *buf, *mud_name, *key, *strip_name,
*profile, *host, *logon, *char_name;
gint port;
gchar **mud_tuple;
gint len;
GConfClient *client = gconf_client_get_default();
MudConnectionView *view;
if(g_list_length(selected) == 0)
return;
logon = char_name = NULL;
gtk_tree_model_get_iter(conn->priv->icon_model, &iter,
(GtkTreePath *)selected->data);
gtk_tree_model_get(conn->priv->icon_model, &iter, 0, &buf, -1);
mud_tuple = g_strsplit(buf, "\n", -1);
len = g_strv_length(mud_tuple);
switch(len)
{
case 1:
mud_name = g_strdup(mud_tuple[0]);
break;
case 2:
char_name = remove_whitespace(mud_tuple[0]);
mud_name = g_strdup(mud_tuple[1]);
break;
default:
g_warning("Malformed mud name passed to delete.");
return;
}
g_strfreev(mud_tuple);
g_free(buf);
strip_name = remove_whitespace(mud_name);
key = g_strdup_printf("/apps/gnome-mud/muds/%s/host", strip_name);
host = gconf_client_get_string(client, key, NULL);
g_free(key);
key = g_strdup_printf("/apps/gnome-mud/muds/%s/profile", strip_name);
profile = gconf_client_get_string(client, key, NULL);
g_free(key);
key = g_strdup_printf("/apps/gnome-mud/muds/%s/port", strip_name);
port = gconf_client_get_int(client, key, NULL);
g_free(key);
if(char_name && strlen(char_name) > 0)
{
key = g_strdup_printf(
"/apps/gnome-mud/muds/%s/characters/%s/logon",
strip_name, char_name);
logon = gconf_client_get_string(client, key, NULL);
g_free(key);
}
mud_tray_update_icon(conn->priv->tray, offline);
view = mud_connection_view_new("Default", host, port,
conn->priv->winwidget,
(GtkWidget *)conn->priv->tray, mud_name);
mud_window_add_connection_view(conn->priv->parent, view, mud_name);
mud_connection_view_set_profile(view, get_profile(profile));
mud_window_profile_menu_set_active(profile, conn->priv->parent);
if(logon && strlen(logon) != 0)
mud_connection_view_set_connect_string(view, logon);
g_free(mud_name);
g_free(strip_name);
g_object_unref(client);
g_list_foreach(selected, (GFunc)gtk_tree_path_free, NULL);
g_list_free(selected);
gtk_widget_destroy(conn->priv->window);
} | false | false | false | false | false | 0 |
orte_plm_base_vm_ready(int fd, short args, void *cbdata)
{
orte_state_caddy_t *caddy = (orte_state_caddy_t*)cbdata;
/* progress the job */
caddy->jdata->state = ORTE_JOB_STATE_VM_READY;
/* position any required files */
if (ORTE_SUCCESS != orte_filem.preposition_files(caddy->jdata, files_ready, caddy->jdata)) {
ORTE_FORCED_TERMINATE(ORTE_ERROR_DEFAULT_EXIT_CODE);
}
/* cleanup */
OBJ_RELEASE(caddy);
} | false | false | false | false | false | 0 |
gt_huffman_encode(const GtHuffman *huffman,
unsigned long symbol,
GtBitsequence *code,
unsigned int *codelength)
{
gt_assert(huffman != NULL);
gt_assert(symbol < huffman->num_of_symbols);
*code = huffman->code_tab[symbol].code;
*codelength = huffman->code_tab[symbol].numofbits;
} | false | false | false | false | false | 0 |
PrintSelf(std::ostream & os, Indent indent) const
{
Superclass::PrintSelf(os, indent);
os << indent << "LineSearchAccuracy: "
<< m_LineSearchAccuracy << std::endl;
os << indent << "DefaultStepLength: "
<< m_DefaultStepLength << std::endl;
if ( this->m_VnlOptimizer )
{
os << indent << "Vnl LBFGS Failure Code: "
<< this->m_VnlOptimizer->get_failure_code() << std::endl;
}
} | false | false | false | false | false | 0 |
cb_Graph_Complement (wxCommandEvent &event)
{
Graph *orig = graph;
Graph::e_const_iterator eit;
Graph::v_const_iterator vit, vit2;
undoableAction (_("Complement graph"));
graph = new Graph;
for (vit = orig->v_begin (); vit != orig->v_end (); ++vit)
graph->add (new Vertex (**vit));
// Method: create a new complete graph, then remove the edges that were
// in the original. TODO: speed this up!
for (vit = graph->v_begin (); vit != graph->v_end (); ++vit)
for (vit2 = vit + 1; vit2 != graph->v_end (); ++vit2)
graph->add (new Edge (*vit, *vit2));
for (eit = orig->e_begin (); eit != orig->e_end (); ++eit) {
Vertex *v1, *v2;
v1 = graph->find ((*eit)->v->label);
v2 = graph->find ((*eit)->w->label);
graph->remove (graph->find (v1, v2));
}
delete orig;
canvas->redraw ();
} | false | false | false | false | false | 0 |
create_coupling (int fd, int is_pull)
{
int pipefd[2];
struct coupling *c = malloc(sizeof(struct coupling));
if (!c) return NULL;
int r = pipe(pipefd);
if (r < 0) return NULL;
r = set_nonblock(pipefd[0]);
if (r < 0) return NULL;
assert(pipefd[0] >= 0);
r = set_nonblock(pipefd[1]);
if (r < 0) return NULL;
assert(pipefd[1] >= 0);
if (is_pull) {
c->is_pull = 1;
c->pullfd = fd;
c->pushfd = pipefd[1];
c->exposedfd = pipefd[0];
} else {
c->is_pull = 0;
c->pushfd = fd;
c->pullfd = pipefd[0];
c->exposedfd = pipefd[1];
}
r = pthread_create(&c->tid, NULL, pump_thread, c);
if (r < 0) return NULL;
return c;
} | false | false | false | false | false | 0 |
gribpr(struct grhdr *ghdr) {
if (bigflg) {
printf ("%6i % 10ld % 3i % 1i % 5i % 4i % 4i %-5i % 10ld % 10ld % 3i ",
irec,(long)fpos,ghdr->id,ghdr->gdsflg,ghdr->bmsflg,ghdr->parm,ghdr->ltyp,
ghdr->level,(long)ghdr->ldpos,(long)ghdr->lbpos,ghdr->bnum);
}
else {
printf ("%6i % 10ld % 3i % 1i % 5i % 4i % 4i %-5i % 10i % 10i % 3i ",
irec,(long)fpos,ghdr->id,ghdr->gdsflg,ghdr->bmsflg,ghdr->parm,ghdr->ltyp,
ghdr->level,ghdr->dpos,ghdr->bpos,ghdr->bnum);
}
printf ("btim: %04i%02i%02i%02i:%02i ",ghdr->btim.yr,
ghdr->btim.mo,ghdr->btim.dy,ghdr->btim.hr,ghdr->btim.mn);
printf ("tau: % 6i ",ghdr->fcstt);
printf ("dtim: %04i%02i%02i%02i:%02i ",ghdr->dtim.yr,
ghdr->dtim.mo,ghdr->dtim.dy,ghdr->dtim.hr,ghdr->dtim.mn);
printf("\n");
} | false | false | false | false | false | 0 |
real_buffer_resync(void)
{
if(buffermem->justwait)
{
buffermem->wakeme[XF_WRITER] = TRUE;
xfermem_putcmd(buffermem->fd[XF_WRITER], XF_CMD_RESYNC);
xfermem_getcmd(buffermem->fd[XF_WRITER], TRUE);
}
else buffer_sig(SIGINT, TRUE);
} | false | false | false | false | false | 0 |
gst_element_factory_list_filter (GList * list,
const GstCaps * caps, GstPadDirection direction, gboolean subsetonly)
{
GQueue results = G_QUEUE_INIT;
GST_DEBUG ("finding factories");
/* loop over all the factories */
for (; list; list = list->next) {
GstElementFactory *factory;
const GList *templates;
GList *walk;
factory = (GstElementFactory *) list->data;
GST_DEBUG ("Trying %s",
gst_plugin_feature_get_name ((GstPluginFeature *) factory));
/* get the templates from the element factory */
templates = gst_element_factory_get_static_pad_templates (factory);
for (walk = (GList *) templates; walk; walk = g_list_next (walk)) {
GstStaticPadTemplate *templ = walk->data;
/* we only care about the sink templates */
if (templ->direction == direction) {
GstCaps *tmpl_caps;
/* try to intersect the caps with the caps of the template */
tmpl_caps = gst_static_caps_get (&templ->static_caps);
/* FIXME, intersect is not the right method, we ideally want to check
* for a subset here */
/* check if the intersection is empty */
if ((subsetonly && gst_caps_is_subset (caps, tmpl_caps)) ||
(!subsetonly && gst_caps_can_intersect (caps, tmpl_caps))) {
/* non empty intersection, we can use this element */
g_queue_push_tail (&results, gst_object_ref (factory));
gst_caps_unref (tmpl_caps);
break;
}
gst_caps_unref (tmpl_caps);
}
}
}
return results.head;
} | false | false | false | false | false | 0 |
test_ev_writefd(void)
{
int reader_pid;
int p[2];
/* make a pipe */
if (pipe(p) == -1) {
exit(1);
}
/* fork off the reader */
switch (reader_pid = fork()) {
case 0: /* child */
close(p[1]);
test_ev_writefd_consumer(p[0], TEST_EV_WRITEFD_SIZE);
exit(0);
break;
case -1: /* error */
perror("fork");
return FALSE;
default: /* parent */
break;
}
/* set up a EV_WRITEFD on the write end of the pipe */
cb_fd = p[1];
fcntl(cb_fd, F_SETFL, O_NONBLOCK);
global = TEST_EV_WRITEFD_SIZE;
close(p[0]);
hdl[0] = event_register(p[1], EV_WRITEFD, test_ev_writefd_cb, NULL);
/* let it run */
event_loop(0);
tu_dbg("waiting for reader to die..\n");
waitpid(reader_pid, NULL, 0);
/* and see what we got */
if (global != 0) {
tu_dbg("writes did not complete\n");
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
DumpFreeSpaceMap(int code, Datum arg)
{
FILE *fp;
FsmCacheFileHeader header;
FSMRelation *fsmrel;
/* Try to create file */
unlink(FSM_CACHE_FILENAME); /* in case it exists w/wrong permissions */
fp = AllocateFile(FSM_CACHE_FILENAME, PG_BINARY_W);
if (fp == NULL)
{
elog(LOG, "could not write \"%s\": %m", FSM_CACHE_FILENAME);
return;
}
LWLockAcquire(FreeSpaceLock, LW_EXCLUSIVE);
/* Write file header */
MemSet(&header, 0, sizeof(header));
strcpy(header.label, FSM_CACHE_LABEL);
header.endian = FSM_CACHE_ENDIAN;
header.version = FSM_CACHE_VERSION;
header.numRels = FreeSpaceMap->numRels;
if (fwrite(&header, 1, sizeof(header), fp) != sizeof(header))
goto write_failed;
/* For each relation, in order from least to most recently used... */
for (fsmrel = FreeSpaceMap->usageListTail;
fsmrel != NULL;
fsmrel = fsmrel->priorUsage)
{
FsmCacheRelHeader relheader;
int nPages;
/* Write relation header */
MemSet(&relheader, 0, sizeof(relheader));
relheader.key = fsmrel->key;
relheader.isIndex = fsmrel->isIndex;
relheader.avgRequest = fsmrel->avgRequest;
relheader.interestingPages = fsmrel->interestingPages;
relheader.storedPages = fsmrel->storedPages;
if (fwrite(&relheader, 1, sizeof(relheader), fp) != sizeof(relheader))
goto write_failed;
/* Write the per-page data directly from the arena */
nPages = fsmrel->storedPages;
if (nPages > 0)
{
Size len;
char *data;
if (fsmrel->isIndex)
len = nPages * sizeof(IndexFSMPageData);
else
len = nPages * sizeof(FSMPageData);
data = (char *)
(FreeSpaceMap->arena + fsmrel->firstChunk * CHUNKBYTES);
if (fwrite(data, 1, len, fp) != len)
goto write_failed;
}
}
/* Clean up */
LWLockRelease(FreeSpaceLock);
if (FreeFile(fp))
{
elog(LOG, "could not write \"%s\": %m", FSM_CACHE_FILENAME);
/* Remove busted cache file */
unlink(FSM_CACHE_FILENAME);
}
return;
write_failed:
elog(LOG, "could not write \"%s\": %m", FSM_CACHE_FILENAME);
/* Clean up */
LWLockRelease(FreeSpaceLock);
FreeFile(fp);
/* Remove busted cache file */
unlink(FSM_CACHE_FILENAME);
} | false | false | false | false | false | 0 |
fs_lock_taken(fs_backend *be, const char *name)
{
struct stat junk;
char *fn = g_strdup_printf(FS_FILE_LOCK, fs_backend_get_kb(be), fs_backend_get_segment(be), name);
int ret = stat(fn, &junk);
g_free(fn);
if (ret == -1 && errno == ENOENT) {
return 0;
}
return 1;
} | false | false | false | false | false | 0 |
doLocking ( const dmtcp::vector<int>& fds )
{
errno = 0;
JASSERT ( fcntl ( fds[0], F_SETOWN, _real_getpid() ) == 0 )
( fds[0] ) ( JASSERT_ERRNO );
} | false | false | false | false | false | 0 |
addArg(char *longOption,char shortOption, int has_arg, char type, void *dataPtr, int dataSize, char *help) {
myOption_t *o,*p;
o = myOptionAlloc(longOption,shortOption,has_arg,type,dataPtr,dataSize, help);
if ( ! o ) return 1;
if ( ! myargs) myargs = o;
else {
p = lastOption(myargs);
p->next = (void *)o;
}
return 0;
} | false | false | false | false | false | 0 |
SubVec( double a[3], double b[3], double c[3])
{
int i;
for( i=0; i < 2; i++ )
c[i] = a[i] - b[i];
} | false | false | false | false | false | 0 |
bch_bbio_count_io_errors(struct cache_set *c, struct bio *bio,
int error, const char *m)
{
struct bbio *b = container_of(bio, struct bbio, bio);
struct cache *ca = PTR_CACHE(c, &b->key, 0);
unsigned threshold = bio->bi_rw & REQ_WRITE
? c->congested_write_threshold_us
: c->congested_read_threshold_us;
if (threshold) {
unsigned t = local_clock_us();
int us = t - b->submit_time_us;
int congested = atomic_read(&c->congested);
if (us > (int) threshold) {
int ms = us / 1024;
c->congested_last_us = t;
ms = min(ms, CONGESTED_MAX + congested);
atomic_sub(ms, &c->congested);
} else if (congested < 0)
atomic_inc(&c->congested);
}
bch_count_io_errors(ca, error, m);
} | false | false | false | false | false | 0 |
Scm_NormalizeBignum(ScmBignum *b)
{
int size = b->size;
int i;
for (i=size-1; i>0; i--) {
if (b->values[i] == 0) size--;
else break;
}
if (i==0) {
if (b->sign == 0) {
return SCM_MAKE_INT(0);
}
if (b->sign > 0 && b->values[0] <= (u_long)SCM_SMALL_INT_MAX) {
return SCM_MAKE_INT(b->values[0]);
}
if (b->sign < 0 && b->values[0] <= (u_long)-SCM_SMALL_INT_MIN) {
return SCM_MAKE_INT(-((signed long)b->values[0]));
}
}
b->size = size;
return SCM_OBJ(b);
} | false | false | false | false | false | 0 |
StrLower(string in_str) {
string thestr = in_str;
for (unsigned int i = 0; i < thestr.length(); i++)
thestr[i] = tolower(thestr[i]);
return thestr;
} | false | false | false | false | false | 0 |
brcms_c_ampdu_shm_upd(struct ampdu_info *ampdu)
{
struct brcms_c_info *wlc = ampdu->wlc;
/*
* Extend ucode internal watchdog timer to
* match larger received frames
*/
if ((ampdu->rx_factor & IEEE80211_HT_AMPDU_PARM_FACTOR) ==
IEEE80211_HT_MAX_AMPDU_64K) {
brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_MAX);
brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_MAX);
} else {
brcms_b_write_shm(wlc->hw, M_MIMO_MAXSYM, MIMO_MAXSYM_DEF);
brcms_b_write_shm(wlc->hw, M_WATCHDOG_8TU, WATCHDOG_8TU_DEF);
}
} | false | false | false | false | false | 0 |
process_term (int linger_)
{
terminating = true;
register_term_acks (inpipes.size () + outpipes.size ());
for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end ();
++it)
it->reader->terminate ();
for (outpipes_t::iterator it = outpipes.begin (); it != outpipes.end ();
++it)
it->second.writer->terminate ();
socket_base_t::process_term (linger_);
} | false | false | false | false | false | 0 |
__GooCanvas_class_init(gpointer gclass, PyTypeObject *pyclass)
{
PyObject *o;
GooCanvasClass *klass = GOO_CANVAS_CLASS(gclass);
PyObject *gsignals = PyDict_GetItemString(pyclass->tp_dict, "__gsignals__");
o = PyObject_GetAttrString((PyObject *) pyclass, "do_set_scroll_adjustments");
if (o == NULL)
PyErr_Clear();
else {
if (!PyObject_TypeCheck(o, &PyCFunction_Type)
&& !(gsignals && PyDict_GetItemString(gsignals, "set_scroll_adjustments")))
klass->set_scroll_adjustments = _wrap_GooCanvas__proxy_do_set_scroll_adjustments;
Py_DECREF(o);
}
o = PyObject_GetAttrString((PyObject *) pyclass, "do_create_item");
if (o == NULL)
PyErr_Clear();
else {
if (!PyObject_TypeCheck(o, &PyCFunction_Type)
&& !(gsignals && PyDict_GetItemString(gsignals, "create_item")))
klass->create_item = _wrap_GooCanvas__proxy_do_create_item;
Py_DECREF(o);
}
o = PyObject_GetAttrString((PyObject *) pyclass, "do_item_created");
if (o == NULL)
PyErr_Clear();
else {
if (!PyObject_TypeCheck(o, &PyCFunction_Type)
&& !(gsignals && PyDict_GetItemString(gsignals, "item_created")))
klass->item_created = _wrap_GooCanvas__proxy_do_item_created;
Py_DECREF(o);
}
return 0;
} | false | false | false | false | false | 0 |
dns_config_find_zone(char *name, int class)
{
int len, buflen, match_len = -1;
char buf[DNS_NAME_MAX];
dns_config_root_t *root;
dns_config_zone_t *zone, *candidate = NULL;
if ((root = ConfigRoot) == NULL)
return NULL;
STRLCPY(buf, name, sizeof(buf));
STRLOWER(buf);
buflen = strlen(buf);
zone = (dns_config_zone_t *) dns_list_head(&root->r_zone);
while (zone != NULL) {
if (zone->z_class == class || class == DNS_CLASS_ANY) {
len = strlen(zone->z_name);
if (buflen >= len && len > match_len) {
if (buflen == len || buf[buflen - len - 1] == '.' || len == 0) {
if (strcmp(&buf[buflen - len], zone->z_name) == 0) {
candidate = zone;
match_len = len;
}
}
}
}
zone = (dns_config_zone_t *) dns_list_next(&root->r_zone, &zone->z_elem);
}
if (candidate == NULL)
plog(LOG_DEBUG, "%s: no zone found", MODULE);
else
plog(LOG_DEBUG, "%s: found zone \"%s\"", MODULE, candidate->z_name);
return candidate;
} | true | true | false | false | false | 1 |
befs_count_blocks(struct super_block * sb, befs_data_stream * ds)
{
befs_blocknr_t blocks;
befs_blocknr_t datablocks; /* File data blocks */
befs_blocknr_t metablocks; /* FS metadata blocks */
struct befs_sb_info *befs_sb = BEFS_SB(sb);
befs_debug(sb, "---> %s", __func__);
datablocks = ds->size >> befs_sb->block_shift;
if (ds->size & (befs_sb->block_size - 1))
datablocks += 1;
metablocks = 1; /* Start with 1 block for inode */
/* Size of indirect block */
if (ds->size > ds->max_direct_range)
metablocks += ds->indirect.len;
/*
Double indir block, plus all the indirect blocks it mapps
In the double-indirect range, all block runs of data are
BEFS_DBLINDIR_BRUN_LEN blocks long. Therefore, we know
how many data block runs are in the double-indirect region,
and from that we know how many indirect blocks it takes to
map them. We assume that the indirect blocks are also
BEFS_DBLINDIR_BRUN_LEN blocks long.
*/
if (ds->size > ds->max_indirect_range && ds->max_indirect_range != 0) {
uint dbl_bytes;
uint dbl_bruns;
uint indirblocks;
dbl_bytes =
ds->max_double_indirect_range - ds->max_indirect_range;
dbl_bruns =
dbl_bytes / (befs_sb->block_size * BEFS_DBLINDIR_BRUN_LEN);
indirblocks = dbl_bruns / befs_iaddrs_per_block(sb);
metablocks += ds->double_indirect.len;
metablocks += indirblocks;
}
blocks = datablocks + metablocks;
befs_debug(sb, "<--- %s %u blocks", __func__, (unsigned int)blocks);
return blocks;
} | false | false | false | false | false | 0 |
attr_syntax_add_by_oid(const char *oid, struct asyntaxinfo *a, int lock)
{
if (0 != attr_syntax_init()) return;
if (lock) {
AS_LOCK_WRITE(oid2asi_lock);
}
PL_HashTableAdd(oid2asi, oid, a);
if (lock) {
AS_UNLOCK_WRITE(oid2asi_lock);
}
} | false | false | false | false | false | 0 |
cgiparse_set_input(Http_method method, FILE *fp, char *buf,
unsigned long len, int have_length, CGI_options *options)
{
CGI_input *in;
if (fp == NULL && (!have_length || buf == NULL))
return(NULL);
in = ALLOC(CGI_input);
in->method = method;
in->fp = fp;
in->buf = in->ptr = buf;
in->length = in->rem = len;
in->have_length = have_length;
in->got_peeked_char = 0;
in->peeked_char = 0;
if (options == NULL)
in->split_textarea = 1; /* For backward compatibility */
else
in->split_textarea = options->split_textarea;
#ifdef NOTDEF
in->debug_fp = NULL;
#endif
return(in);
} | false | false | false | false | false | 0 |
sgen_los_update_cardtable_mod_union (void)
{
LOSObject *obj;
for (obj = los_object_list; obj; obj = obj->next) {
if (!SGEN_OBJECT_HAS_REFERENCES (obj->data))
continue;
sgen_card_table_update_mod_union (get_cardtable_mod_union_for_object (obj),
(char*)obj->data, sgen_los_object_size (obj), NULL);
}
} | false | false | false | false | false | 0 |
createTclEnvironment(Hinst application)
{
Tcl_SetPanicProc((void (*)(const char *, ...)) WishPanic);
// *** Create Tcl-interpreter and register command procedures
Tcl_FindExecutable( (char*) application );
Tcl_Interp* interp = Tcl_CreateInterp();
#ifdef TCL_MEM_DEBUG
Tcl_InitMemory(interp);
#endif
// *** Invoke application-specific initialization.
if (My_Tcl_AppInit(interp) != TCL_OK) {
WishPanic("My_Tcl_AppInit failed: %s\n", interp->result);
}
// Result value is the Tcl interpreter
return interp;
} | false | false | false | false | false | 0 |
inf_communication_registry_add_connection(InfCommunicationRegistry* registry,
InfXmlConnection* connection)
{
InfCommunicationRegistryPrivate* priv;
gpointer reg;
priv = INF_COMMUNICATION_REGISTRY_PRIVATE(registry);
reg = g_hash_table_lookup(priv->connections, connection);
g_hash_table_steal(priv->connections, connection);
if(reg == NULL)
{
g_hash_table_insert(
priv->connections,
connection,
GUINT_TO_POINTER(1)
);
g_object_ref(connection);
g_signal_connect(
G_OBJECT(connection),
"received",
G_CALLBACK(inf_communication_registry_received_cb),
registry
);
g_signal_connect(
G_OBJECT(connection),
"sent",
G_CALLBACK(inf_communication_registry_sent_cb),
registry
);
g_signal_connect(
G_OBJECT(connection),
"notify::status",
G_CALLBACK(inf_communication_registry_notify_status_cb),
registry
);
}
else
{
g_hash_table_insert(
priv->connections,
connection,
GUINT_TO_POINTER(1+GPOINTER_TO_UINT(reg))
);
}
} | false | false | false | false | false | 0 |
ioeCallback(dummy)
XPointer dummy;
{
ObjRec *objp = ObjList;
/*
* I/O Error callback function.
* Does minimum cleanup -- i.e. saving dictionaries.
*/
while (objp != NULL) {
if (objp->obj->ccWnn.jcbuf != NULL) {
jcSaveDic(objp->obj->ccWnn.jcbuf);
}
objp = objp->next;
}
} | false | false | false | false | false | 0 |
GetIndex(const_iterator record) const
{
const_iterator i = begin();
for( int index = 0; i != end(); ++i, index++ ) {
if( i == record )
return index;
}
return -1;
} | false | false | false | false | false | 0 |
processData()
{
if (openElementFlags_.size() > 0
&& (openElementFlags_.back() & ignoreData))
return 0;
if (!currentElement().declaredEmpty()
&& currentElement().tryTransitionPcdata())
return 1;
else if (openElementFlags_.size() > 0
&& (openElementFlags_.back() & condIgnoreData))
return 0;
else {
// Only give this error once per element
if (openElementFlags_.size() > 0) {
if (openElementFlags_.back() & recoverData)
return 1;
openElementFlags_.back() |= recoverData;
}
Messenger::message(ArcEngineMessages::invalidData);
return 1;
}
} | false | false | false | false | false | 0 |
rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz)
{
struct sta_info *psta = NULL;
struct stainfo_stats *pstats = NULL;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) {
pxmitpriv->tx_bytes += sz;
pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num;
psta = pxmitframe->attrib.psta;
if (psta) {
pstats = &psta->sta_stats;
pstats->tx_pkts += pxmitframe->agg_num;
pstats->tx_bytes += sz;
}
}
} | false | false | false | false | false | 0 |
readtcp (char *ctptr, char *buf, int len)
{
struct ct_data *ct = (struct ct_data *)ctptr;
struct pollfd fd;
int milliseconds = (ct->ct_wait.tv_sec * 1000) +
(ct->ct_wait.tv_usec / 1000);
if (len == 0)
return 0;
fd.fd = ct->ct_sock;
fd.events = POLLIN;
while (TRUE)
{
switch (__poll(&fd, 1, milliseconds))
{
case 0:
ct->ct_error.re_status = RPC_TIMEDOUT;
return -1;
case -1:
if (errno == EINTR)
continue;
ct->ct_error.re_status = RPC_CANTRECV;
ct->ct_error.re_errno = errno;
return -1;
}
break;
}
switch (len = __read (ct->ct_sock, buf, len))
{
case 0:
/* premature eof */
ct->ct_error.re_errno = ECONNRESET;
ct->ct_error.re_status = RPC_CANTRECV;
len = -1; /* it's really an error */
break;
case -1:
ct->ct_error.re_errno = errno;
ct->ct_error.re_status = RPC_CANTRECV;
break;
}
return len;
} | false | false | false | false | false | 0 |
disabled_store(struct class *class, struct class_attribute *attr,
const char *buf, size_t count)
{
long tmp = simple_strtol(buf, NULL, 10);
/*
* This essentially makes the attribute write-once, since you can't
* go back to not having it disabled. This is intentional, it serves
* as a system lockdown feature.
*/
if (tmp != 1)
return -EINVAL;
devcd_disabled = true;
class_for_each_device(&devcd_class, NULL, NULL, devcd_free);
return count;
} | false | false | false | false | false | 0 |
drawpen(long x0, long y0, long radius)
{
int x,y,d,deltaE,deltaSE;
x = 0;
y = radius;
d = 1-radius;
deltaE = 3;
deltaSE = -2 * radius + 5;
circlepoints(x,y,x0,y0);
while (y > x){
if (d < 0) {
d = d + deltaE;
deltaE += 2;
deltaSE += 2;
x++;
}
else {
d+=deltaSE;
deltaE += 2;
deltaSE += 4;
x++;
y--;
}
circlepoints(x,y,x0,y0);
}
} | false | false | false | false | false | 0 |
autosave()
{
statusBar->clearstatus();
statusBar->status(_("Autosaving..."));
autosave_int();
} | false | false | false | false | false | 0 |
length() const
{
//if downloaded get the duration from the file, else use the value read from the feed
if( m_localFile.isNull() )
return m_duration * 1000;
return m_localFile->length();
} | false | false | false | false | false | 0 |
NudgeCropPlanesToBounds(
int tolPtId[3][4], double planes[3][4], double tol)
{
for (int dim = 0; dim < 3; dim++)
{
tolPtId[dim][0] = 0; tolPtId[dim][1] = 1;
tolPtId[dim][2] = 2; tolPtId[dim][3] = 3;
if (planes[dim][1] - planes[dim][0] < tol) { tolPtId[dim][1] = 0; }
if (planes[dim][3] - planes[dim][2] < tol) { tolPtId[dim][2] = 3; }
}
} | false | false | false | false | false | 0 |
getp_close_file(VMG_ vm_obj_id_t self, vm_val_t *retval,
uint *argc)
{
static CVmNativeCodeDesc desc(0);
/* check arguments */
if (get_prop_check_argc(retval, argc, &desc))
return TRUE;
/* make sure we are allowed to perform operations on the file */
check_valid_file(vmg0_);
/* close the underlying system file */
osfcls(get_ext()->fp);
/* forget the underlying system file, since it's no longer valid */
get_ext()->fp = 0;
/* no return value */
retval->set_nil();
/* handled */
return TRUE;
} | false | false | false | false | false | 0 |
val_reply(struct gspca_dev *gspca_dev, const char *reply, int rc)
{
if (rc < 0) {
PERR("reply has error %d", rc);
return -EIO;
}
if (rc != 1) {
PERR("Bad reply size %d", rc);
return -EIO;
}
if (reply[0] != 0x08) {
PERR("Bad reply 0x%02X", reply[0]);
return -EIO;
}
return 0;
} | false | false | false | false | false | 0 |
HtmlImageServerReport(clientData, interp, objc, objv)
ClientData clientData; /* The HTML widget data structure */
Tcl_Interp *interp; /* Current interpreter. */
int objc; /* Number of arguments. */
Tcl_Obj *CONST objv[]; /* Argument strings. */
{
HtmlTree *pTree = (HtmlTree *)clientData;
Tcl_HashSearch search;
Tcl_HashEntry *pEntry;
Tcl_Obj *pRet = Tcl_NewObj();
for (
pEntry = Tcl_FirstHashEntry(&pTree->pImageServer->aImage, &search);
pEntry;
pEntry = Tcl_NextHashEntry(&search)
) {
HtmlImage2 *pImage = (HtmlImage2 *)Tcl_GetHashValue(pEntry);
for( ; pImage; pImage = pImage->pNext){
Tcl_Obj *p = Tcl_NewObj();
const char *zUrl = "";
if( !pImage->pUnscaled ){
zUrl = pImage->zUrl;
}
Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(zUrl, -1));
if (pImage->pImageName) {
Tcl_ListObjAppendElement(interp, p, pImage->pImageName);
} else {
Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj("", -1));
}
Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(
pImage->pixmap?"PIX":"", -1));
Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(pImage->width));
Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(pImage->height));
Tcl_ListObjAppendElement(interp, p, Tcl_NewStringObj(
pImage->eAlpha==ALPHA_CHANNEL_UNKNOWN?"unknown":
pImage->eAlpha==ALPHA_CHANNEL_TRUE?"true":
pImage->eAlpha==ALPHA_CHANNEL_FALSE?"false":"internal error!", -1));
Tcl_ListObjAppendElement(interp, p, Tcl_NewIntObj(pImage->nRef));
Tcl_ListObjAppendElement(interp, pRet, p);
}
}
Tcl_SetObjResult(interp, pRet);
return TCL_OK;
} | false | false | false | false | false | 0 |
get_bg1_tile_info(int tile_index)
{
/*- BG1 RAM Format -**
2 bytes per tile
CCCC TTTT tttt tttt
C = Colour Bank (0-15)
T = Tile Number (0 - 4095)
**- End of Comments -*/
data16_t *tilebase;
int tileno;
int colbank;
tilebase = &wwfwfest_bg1_videoram[tile_index];
tileno = (tilebase[0] & 0x0fff);
colbank = (tilebase[0] & 0xf000) >> 12;
SET_TILE_INFO(
3,
tileno,
colbank,
0)
} | false | false | false | false | false | 0 |
RandomRotorSearchInitialize(unsigned int conformers, unsigned int geomSteps)
{
if (!_validSetup)
return;
OBRotorList rl;
OBRotamerList rotamers;
OBRotorIterator ri;
OBRotor *rotor;
OBRandom generator;
generator.TimeSeed();
_origLogLevel = _loglvl;
if (_mol.GetCoordinates() == NULL)
return;
OBBitVec fixed = _constraints.GetFixedBitVec();
rl.SetFixAtoms(fixed);
rl.Setup(_mol);
rotamers.SetBaseCoordinateSets(_mol);
rotamers.Setup(_mol, rl);
IF_OBFF_LOGLVL_LOW {
OBFFLog("\nR A N D O M R O T O R S E A R C H\n\n");
snprintf(_logbuf, BUFF_SIZE, " NUMBER OF ROTATABLE BONDS: %lu\n", (unsigned long)rl.Size());
OBFFLog(_logbuf);
unsigned long int combinations = 1;
for (rotor = rl.BeginRotor(ri); rotor;
rotor = rl.NextRotor(ri)) {
combinations *= rotor->GetResolution().size();
}
snprintf(_logbuf, BUFF_SIZE, " NUMBER OF POSSIBLE ROTAMERS: %lu\n", combinations);
OBFFLog(_logbuf);
}
if (!rl.Size()) { // only one conformer
IF_OBFF_LOGLVL_LOW
OBFFLog(" GENERATED ONLY ONE CONFORMER\n\n");
_loglvl = OBFF_LOGLVL_NONE;
ConjugateGradients(geomSteps); // energy minimization for conformer
_loglvl = _origLogLevel;
return;
}
std::vector<int> rotorKey(rl.Size() + 1, 0); // indexed from 1
for (int c = 0; c < conformers; ++c) {
rotor = rl.BeginRotor(ri);
for (int i = 1; i < rl.Size() + 1; ++i, rotor = rl.NextRotor(ri)) {
// foreach rotor
rotorKey[i] = generator.NextInt() % rotor->GetResolution().size();
}
rotamers.AddRotamer(rotorKey);
}
rotamers.ExpandConformerList(_mol, _mol.GetConformers());
IF_OBFF_LOGLVL_LOW {
snprintf(_logbuf, BUFF_SIZE, " GENERATED %d CONFORMERS\n\n", _mol.NumConformers());
OBFFLog(_logbuf);
OBFFLog("CONFORMER ENERGY\n");
OBFFLog("--------------------\n");
}
_current_conformer = 0;
_energies.clear();
} | false | false | false | false | false | 0 |
lenstr_free( lenstr **l )
{
if ( NULL != l && NULL != *l ) {
lenstr *tl = *l;
if ( tl->ls_buf != NULL ) {
slapi_ch_free((void **) &tl->ls_buf );
}
slapi_ch_free((void **) l );
}
} | false | false | false | false | false | 0 |
gain_buffers (struct scanner *s, int setup)
{
SANE_Status ret = SANE_STATUS_GOOD;
int side;
DBG (10, "gain_buffers: start\n");
for(side=0;side<2;side++){
if (s->f_gain[side]) {
DBG (15, "gain_buffers: free f_gain %d.\n",side);
free(s->f_gain[side]);
s->f_gain[side] = NULL;
}
if(setup){
s->f_gain[side] = calloc (1,s->s.Bpl);
if (!s->f_gain[side]) {
DBG (5, "gain_buffers: error, no f_gain %d.\n",side);
return SANE_STATUS_NO_MEM;
}
}
}
DBG (10, "gain_buffers: finish\n");
return ret;
} | false | false | false | false | false | 0 |
main_hall_get_name(unsigned int index)
{
if (index>Main_hall_defines.at(gr_screen.res).size()) {
return "";
} else {
return Main_hall_defines.at(gr_screen.res).at(index).name;
}
} | false | false | false | false | false | 0 |
next(int32_t *resultLength, UErrorCode &status) {
const UnicodeString *s=snext(status);
if(U_SUCCESS(status) && s!=NULL) {
unistr=*s;
ensureCharsCapacity(unistr.length()+1, status);
if(U_SUCCESS(status)) {
if(resultLength!=NULL) {
*resultLength=unistr.length();
}
unistr.extract(0, INT32_MAX, chars, charsCapacity, US_INV);
return chars;
}
}
return NULL;
} | false | false | false | false | false | 0 |
Set (char *today, int hours, int minutes) {
int h = hours;
if (mode==CIVIL) {
if (hours > 12) {
h -= 12;
} else if ( hours == 0 ) {
h = 12; // midnight is 12:xx
}
}
unsigned long fade = FadeDelay * (1 << (min(4,max(0,FadeRate))) );
Event e;
boolean done_fading = false;
while (showTime && !done_fading && !done) {
if (Read(0, fade, e)) {
e.target->Handle(e);
if (done) {
return;
}
}
done_fading = true;
if (mode == CIVIL && h < 10) {
done_fading &= ht->Set(-1); // blank digit
} else {
done_fading &= ht->Set(h/10);
}
done_fading &= hu->Set(h%10);
done_fading &= mt->Set(minutes/10);
done_fading &= mu->Set(minutes%10);
}
if (showTime && mode==CIVIL) {
AMPMMODE newAMPM = (hours >= 12) ? PM : AM;
if (AMPMmode == BLANK) {
AMPMmode = newAMPM;
DrawAMPM(output);
} else if (AMPMmode != newAMPM) {
DrawAMPM(invertor); // erase old
AMPMmode = newAMPM;
DrawAMPM(output); // draw new
}
}
if (showDate && strcmp(date.text, today) != 0) {
strcpy(date.text, today);
date.len = strlen(today);
DrawDate();
if (showBorder) {
DrawBorder();
}
}
} | false | false | false | false | false | 0 |
cat_tail_move(tenm_object *my, double turn_per_frame)
{
double dx_temp;
double dy_temp;
/* sanity check */
if (my == NULL)
{
fprintf(stderr, "cat_tail_move: my is NULL\n");
return 0;
}
if (turn_per_frame <= 0.5)
{
fprintf(stderr, "cat_tail_move: strange turn_per_frame (%f)\n",
turn_per_frame);
return 0;
}
if ((my->count[2] == 2) && (my->count[3] < 0))
return 0;
dx_temp = my->count_d[0] / turn_per_frame;
dy_temp = my->count_d[1] / turn_per_frame;
my->x += dx_temp;
my->y += dy_temp;
if (my->mass != NULL)
tenm_move_mass(my->mass, dx_temp, dy_temp);
return 0;
} | false | false | false | false | false | 0 |
gd_header_button_set_symbolic_icon_name (GdHeaderButton *self,
const gchar *symbolic_icon_name)
{
if (symbolic_icon_name != NULL &&
!g_str_has_suffix (symbolic_icon_name, "-symbolic"))
{
g_warning ("gd_header_button_set_symbolic_icon_name was called with "
"a non-symbolic name.");
return;
}
g_object_set (self, "symbolic-icon-name", symbolic_icon_name, NULL);
} | false | false | false | false | false | 0 |
handle_upload_file_status() {
char path[MAXPATHLEN], buf[MAXPATHLEN], log_name[MAXPATHLEN], *p, log_buf[256];
std::string filename;
int status;
relative_to_absolute("", path);
DirScanner dirscan(path);
while (dirscan.scan(filename)) {
strlcpy(buf, filename.c_str(), sizeof(buf));
if (strstr(buf, UPLOAD_FILE_STATUS_PREFIX) != buf) continue;
strlcpy(log_name, buf+strlen(UPLOAD_FILE_STATUS_PREFIX), sizeof(log_name));
FILE* f = boinc_fopen(filename.c_str(), "r");
if (!f) {
fprintf(stderr,
"%s handle_file_upload_status: can't open %s\n",
boinc_msg_prefix(buf, sizeof(buf)), filename.c_str()
);
continue;
}
p = fgets(buf, sizeof(buf), f);
fclose(f);
if (p && parse_int(buf, "<status>", status)) {
UPLOAD_FILE_STATUS uf;
uf.name = std::string(log_name);
uf.status = status;
upload_file_status.push_back(uf);
} else {
fprintf(stderr, "%s handle_upload_file_status: can't parse %s\n",
boinc_msg_prefix(log_buf, sizeof(log_buf)), buf
);
}
}
} | false | false | false | false | false | 0 |
btrfs_account_dev_extents_size(struct btrfs_device *device, u64 start,
u64 end, u64 *length)
{
struct btrfs_key key;
struct btrfs_root *root = device->dev_root;
struct btrfs_dev_extent *dev_extent;
struct btrfs_path *path;
u64 extent_end;
int ret;
int slot;
struct extent_buffer *l;
*length = 0;
if (start >= device->total_bytes || device->is_tgtdev_for_dev_replace)
return 0;
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
path->reada = 2;
key.objectid = device->devid;
key.offset = start;
key.type = BTRFS_DEV_EXTENT_KEY;
ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
if (ret < 0)
goto out;
if (ret > 0) {
ret = btrfs_previous_item(root, path, key.objectid, key.type);
if (ret < 0)
goto out;
}
while (1) {
l = path->nodes[0];
slot = path->slots[0];
if (slot >= btrfs_header_nritems(l)) {
ret = btrfs_next_leaf(root, path);
if (ret == 0)
continue;
if (ret < 0)
goto out;
break;
}
btrfs_item_key_to_cpu(l, &key, slot);
if (key.objectid < device->devid)
goto next;
if (key.objectid > device->devid)
break;
if (key.type != BTRFS_DEV_EXTENT_KEY)
goto next;
dev_extent = btrfs_item_ptr(l, slot, struct btrfs_dev_extent);
extent_end = key.offset + btrfs_dev_extent_length(l,
dev_extent);
if (key.offset <= start && extent_end > end) {
*length = end - start + 1;
break;
} else if (key.offset <= start && extent_end > start)
*length += extent_end - start;
else if (key.offset > start && extent_end <= end)
*length += extent_end - key.offset;
else if (key.offset > start && key.offset <= end) {
*length += end - key.offset + 1;
break;
} else if (key.offset > end)
break;
next:
path->slots[0]++;
}
ret = 0;
out:
btrfs_free_path(path);
return ret;
} | false | false | false | false | false | 0 |
frogr_config_set_tags_autocompletion (FrogrConfig *self, gboolean value)
{
FrogrConfigPrivate * priv = NULL;
g_return_if_fail (FROGR_IS_CONFIG (self));
priv = FROGR_CONFIG_GET_PRIVATE (self);
priv->tags_autocompletion = value;
} | false | false | false | false | false | 0 |
getopts_perror (GetOptsContext *ctx, int err)
{
const char *long_opt, *eq;
const char *reason;
if (ctx->index >= ctx->argc || ctx->argv[ctx->index][0] != '-')
return;
if (ctx->subindex == 0) {
if (!strncmp (ctx->argv[ctx->index], "--", 2))
long_opt = ctx->argv[ctx->index] + 2;
else
long_opt = ctx->argv[ctx->index] + 1;
eq = long_opt;
while (*eq && *eq != '=')
eq++;
}
switch (err) {
case GETOPTS_ERROR_BAD_OPTION:
if (ctx->subindex == 0) {
fprintf (stderr, "%s: unrecognized option `--%.*s'\n",
basename (ctx->argv[0]), eq - long_opt, long_opt);
} else {
fprintf (stderr, "%s: unrecognized option -- %c\n",
basename (ctx->argv[0]), ctx->argv[ctx->index][ctx->subindex]);
}
break;
case GETOPTS_ERROR_MISSING_ARG:
if (ctx->subindex == 0) {
fprintf (stderr, "%s: option `--%.*s' requires an argument\n",
basename (ctx->argv[0]), eq - long_opt, long_opt);
} else {
fprintf (stderr, "%s: option requires an argument -- %c\n",
basename (ctx->argv[0]), ctx->argv[ctx->index][ctx->subindex]);
}
break;
case GETOPTS_ERROR_INVALID_ARG:
switch (ctx->err) {
case EOVERFLOW:
reason = "overflow error";
break;
default:
reason = NULL;
}
if (ctx->subindex == 0) {
fprintf (stderr, "%s: invalid argument passed to option `--%.*s'%s%s\n",
basename (ctx->argv[0]), eq - long_opt, long_opt,
reason ? ": " : "", reason ? reason : "");
} else {
fprintf (stderr, "%s: invalid argument passed to option -- %c%s%s\n",
basename (ctx->argv[0]), ctx->argv[ctx->index][ctx->subindex],
reason ? ": " : "", reason ? reason : "");
}
break;
default:
break;
}
} | false | false | false | false | false | 0 |
insert_symbols()
{
size_t i= 0;
SYMBOL *cur;
for (cur= symbols; i<array_elements(symbols); cur++, i++){
hash_lex_struct *root=
get_hash_struct_by_len(&root_by_len,cur->length,&max_len);
insert_into_hash(root,cur->name,0,(uint) i,0);
}
} | false | false | false | false | false | 0 |
handle_talk_ascii(struct linked_server *ls,
const void *data, size_t length)
{
const struct uo_packet_talk_ascii *p = data;
size_t text_length;
if (length < sizeof(*p))
return PA_DISCONNECT;
text_length = length - sizeof(*p);
if (p->text[text_length] != 0)
return PA_DISCONNECT;
return handle_talk(ls, p->text);
} | false | false | false | false | false | 0 |
mailimap_section_text_send(mailstream * fd,
struct mailimap_section_text * section_text)
{
switch (section_text->sec_type) {
case MAILIMAP_SECTION_TEXT_SECTION_MSGTEXT:
return mailimap_section_msgtext_send(fd, section_text->sec_msgtext);
case MAILIMAP_SECTION_TEXT_MIME:
return mailimap_token_send(fd, "MIME");
default:
/* should not happen */
return MAILIMAP_NO_ERROR;
}
} | false | false | false | false | false | 0 |
towupper (wc)
wint_t wc;
{
size_t i = _NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MAP_OFFSET) + __TOW_toupper;
const char *desc = _NL_CURRENT (LC_CTYPE, i);
return wctrans_table_lookup (desc, wc);
} | false | false | false | false | false | 0 |
mei_cl_all_wakeup(struct mei_device *dev)
{
struct mei_cl *cl;
list_for_each_entry(cl, &dev->file_list, link) {
if (waitqueue_active(&cl->rx_wait)) {
cl_dbg(dev, cl, "Waking up reading client!\n");
wake_up_interruptible(&cl->rx_wait);
}
if (waitqueue_active(&cl->tx_wait)) {
cl_dbg(dev, cl, "Waking up writing client!\n");
wake_up_interruptible(&cl->tx_wait);
}
/* synchronized under device mutex */
if (waitqueue_active(&cl->ev_wait)) {
cl_dbg(dev, cl, "Waking up waiting for event clients!\n");
wake_up_interruptible(&cl->ev_wait);
}
}
} | false | false | false | false | false | 0 |
DISPLAY_ALERT(SSL *ssl, int alert)
{
if (!IS_SET_SSL_FLAG(SSL_DISPLAY_STATES))
return;
printf("Alert: ");
switch (alert)
{
case SSL_ALERT_CLOSE_NOTIFY:
printf("close notify");
break;
case SSL_ALERT_INVALID_VERSION:
printf("invalid version");
break;
case SSL_ALERT_BAD_CERTIFICATE:
printf("bad certificate");
break;
case SSL_ALERT_UNEXPECTED_MESSAGE:
printf("unexpected message");
break;
case SSL_ALERT_BAD_RECORD_MAC:
printf("bad record mac");
break;
case SSL_ALERT_HANDSHAKE_FAILURE:
printf("handshake failure");
break;
case SSL_ALERT_ILLEGAL_PARAMETER:
printf("illegal parameter");
break;
case SSL_ALERT_DECODE_ERROR:
printf("decode error");
break;
case SSL_ALERT_DECRYPT_ERROR:
printf("decrypt error");
break;
case SSL_ALERT_NO_RENEGOTIATION:
printf("no renegotiation");
break;
default:
printf("alert - (unknown %d)", alert);
break;
}
printf("\n");
TTY_FLUSH();
} | false | false | false | false | false | 0 |
apply_prop_kline(struct Client *source_p, struct ConfItem *aconf,
const char *reason, const char *oper_reason, int tkline_time)
{
aconf->flags |= CONF_FLAGS_MYOPER | CONF_FLAGS_TEMPORARY;
aconf->hold = rb_current_time() + tkline_time;
aconf->lifetime = aconf->hold;
replace_old_ban(aconf);
rb_dlinkAddAlloc(aconf, &prop_bans);
add_conf_by_address(aconf->host, CONF_KILL, aconf->user, NULL, aconf);
/* no oper reason.. */
if(EmptyString(oper_reason))
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added global %d min. K-Line for [%s@%s] [%s]",
get_oper_name(source_p), tkline_time / 60,
aconf->user, aconf->host, reason);
ilog(L_KLINE, "K %s %d %s %s %s",
get_oper_name(source_p), tkline_time / 60, aconf->user, aconf->host, reason);
}
else
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
"%s added global %d min. K-Line for [%s@%s] [%s|%s]",
get_oper_name(source_p), tkline_time / 60,
aconf->user, aconf->host, reason, oper_reason);
ilog(L_KLINE, "K %s %d %s %s %s|%s",
get_oper_name(source_p), tkline_time / 60,
aconf->user, aconf->host, reason, oper_reason);
}
sendto_one_notice(source_p, ":Added global %d min. K-Line [%s@%s]",
tkline_time / 60, aconf->user, aconf->host);
sendto_server(NULL, NULL, CAP_BAN|CAP_TS6, NOCAPS,
":%s BAN K %s %s %lu %d %d * :%s%s%s",
source_p->id, aconf->user, aconf->host,
(unsigned long)aconf->created,
(int)(aconf->hold - aconf->created),
(int)(aconf->lifetime - aconf->created),
reason,
oper_reason ? "|" : "",
oper_reason ? oper_reason : "");
} | false | false | false | false | false | 0 |
on_snippets_editor_close_request (SnippetsEditor *snippets_editor,
gpointer user_data)
{
SnippetsBrowserPrivate *priv = NULL;
/* Assertions */
g_return_if_fail (ANJUTA_IS_SNIPPETS_BROWSER (user_data));
priv = ANJUTA_SNIPPETS_BROWSER_GET_PRIVATE (user_data);
gtk_toggle_button_set_active (priv->edit_button, FALSE);
} | false | false | false | false | false | 0 |
at_cmd_plus_FIT(at_state_t *s, const char *t)
{
/* T.31 8.5.4 - DTE inactivity timeout */
t += 4;
if (!parse_2_out(s, &t, &s->dte_inactivity_timeout, 255, &s->dte_inactivity_action, 1, "+FIT:", "(0-255),(0-1)"))
return NULL;
return t;
} | false | false | false | false | false | 0 |
send_next_ecm_frame(t30_state_t *s)
{
int i;
uint8_t frame[3];
if (s->ecm_current_tx_frame < s->ecm_frames)
{
/* Search for the next frame, within the current partial page, which has
not been tagged as transferred OK. */
for (i = s->ecm_current_tx_frame; i < s->ecm_frames; i++)
{
if (s->ecm_len[i] >= 0)
{
send_frame(s, s->ecm_data[i], s->ecm_len[i]);
s->ecm_current_tx_frame = i + 1;
s->ecm_frames_this_tx_burst++;
return 0;
}
}
s->ecm_current_tx_frame = s->ecm_frames;
}
if (s->ecm_current_tx_frame <= s->ecm_frames + 3)
{
/* We have sent all the FCD frames. Send some RCP frames. Three seems to be
a popular number, to minimise the risk of a bit error stopping the receiving
end from recognising the RCP. */
s->ecm_current_tx_frame++;
/* The RCP frame is an odd man out, as its a simple 1 byte control
frame, but is specified to not have the final bit set. It doesn't
seem to have the DIS received bit set, either. */
frame[0] = 0xFF;
frame[1] = 0x03;
frame[2] = T4_RCP;
send_frame(s, frame, 3);
/* In case we are just after a CTC/CTR exchange, which kicked us back to long training */
s->short_train = TRUE;
return 0;
}
return -1;
} | false | false | false | false | false | 0 |
diff_setup(struct diff_options *options)
{
memset(options, 0, sizeof(*options));
options->file = stdout;
options->line_termination = '\n';
options->break_opt = -1;
options->rename_limit = -1;
options->dirstat_percent = 3;
options->context = 3;
options->change = diff_change;
options->add_remove = diff_addremove;
if (diff_use_color_default > 0)
DIFF_OPT_SET(options, COLOR_DIFF);
options->detect_rename = diff_detect_rename_default;
if (!diff_mnemonic_prefix) {
options->a_prefix = "a/";
options->b_prefix = "b/";
}
} | false | false | false | false | false | 0 |
inplaceIntent() const
{
Q_D( const TextAnnotation );
if (!d->pdfAnnot)
return d->inplaceIntent;
if (d->pdfAnnot->getType() == Annot::typeFreeText)
{
const AnnotFreeText * ftextann = static_cast<const AnnotFreeText*>(d->pdfAnnot);
return (TextAnnotation::InplaceIntent)ftextann->getIntent();
}
return TextAnnotation::Unknown;
} | false | false | false | false | false | 0 |
HAsearch_atom(group_t grp, /* IN: Group to search for the object in */
HAsearch_func_t func, /* IN: Ptr to the comparison function */
const void * key /* IN: pointer to key to compare against */
)
{
CONSTR(FUNC, "HAsearch_atom"); /* for HERROR */
atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
intn i; /* local counting variable */
void * ret_value=NULL;
HEclear();
if(grp<=BADGROUP || grp>=MAXGROUP)
HGOTO_ERROR(DFE_ARGS, NULL);
grp_ptr=atom_group_list[grp];
if(grp_ptr==NULL || grp_ptr->count<=0)
HGOTO_ERROR(DFE_INTERNAL, NULL);
/* Start at the beginning of the array */
for(i=0; i<grp_ptr->hash_size; i++)
{
atm_ptr=grp_ptr->atom_list[i];
while(atm_ptr!=NULL)
{
if((*func)(atm_ptr->obj_ptr,key))
HGOTO_DONE(atm_ptr->obj_ptr); /* found the item we are looking for */
atm_ptr=atm_ptr->next;
} /* end while */
} /* end for */
done:
if(ret_value == NULL)
{ /* Error condition cleanup */
} /* end if */
/* Normal function cleanup */
return ret_value;
} | false | false | false | false | false | 0 |
setDeviceDescriptor(jtag_device_def_type *dev)
{
uchar *response = NULL;
uchar *command = (uchar *)(&dev->dev_desc1);
response = doJtagCommand(command, sizeof dev->dev_desc1, 1);
check(response[0] == JTAG_R_OK,
"JTAG ICE: Failed to set device description");
delete [] response;
} | false | false | false | false | false | 0 |
setredblue(struct gspca_dev *gspca_dev)
{
struct sd *sd = (struct sd *) gspca_dev;
if (sd->sensor == SENSOR_PO2030N) {
u8 rg1b[] = /* red green1 blue (no g2) */
{0xc1, 0x6e, 0x16, 0x00, 0x40, 0x00, 0x00, 0x10};
/* 0x40 = normal value = gain x 1 */
rg1b[3] = sd->red_bal->val * 2;
rg1b[5] = sd->blue_bal->val * 2;
i2c_w8(gspca_dev, rg1b);
return;
}
reg_w1(gspca_dev, 0x05, sd->red_bal->val);
/* reg_w1(gspca_dev, 0x07, 32); */
reg_w1(gspca_dev, 0x06, sd->blue_bal->val);
} | false | false | false | false | false | 0 |
brcmstb_gpio_remove(struct platform_device *pdev)
{
struct brcmstb_gpio_priv *priv = platform_get_drvdata(pdev);
struct list_head *pos;
struct brcmstb_gpio_bank *bank;
int ret = 0;
if (!priv) {
dev_err(&pdev->dev, "called %s without drvdata!\n", __func__);
return -EFAULT;
}
/*
* You can lose return values below, but we report all errors, and it's
* more important to actually perform all of the steps.
*/
list_for_each(pos, &priv->bank_list) {
bank = list_entry(pos, struct brcmstb_gpio_bank, node);
ret = bgpio_remove(&bank->bgc);
if (ret)
dev_err(&pdev->dev, "gpiochip_remove fail in cleanup\n");
}
if (priv->reboot_notifier.notifier_call) {
ret = unregister_reboot_notifier(&priv->reboot_notifier);
if (ret)
dev_err(&pdev->dev,
"failed to unregister reboot notifier\n");
}
return ret;
} | false | false | false | false | false | 0 |
ParseSwallow(
char **ss, unsigned int *flags, unsigned int *mask, button_info *b)
{
char *swallowopts[] =
{
"nohints", "hints",
"nokill", "kill",
"noclose", "close",
"respawn", "norespawn",
"useold", "noold",
"usetitle", "notitle",
"fvwmmodule", "nofvwmmodule",
"swallownew",
NULL
};
char *t, *s = *ss;
while (*s && *s != ')')
{
s = trimleft(s);
if (*s == ',')
{
s++;
continue;
}
switch (GetTokenIndex(s, swallowopts, -1, &s))
{
case 0: /* NoHints */
*flags |= b_NoHints;
*mask |= b_NoHints;
break;
case 1: /* Hints */
*flags &= ~b_NoHints;
*mask |= b_NoHints;
break;
case 2: /* NoKill */
*flags &= ~b_Kill;
*mask |= b_Kill;
break;
case 3: /* Kill */
*flags |= b_Kill;
*mask |= b_Kill;
break;
case 4: /* NoClose */
*flags |= b_NoClose;
*mask |= b_NoClose;
break;
case 5: /* Close */
*flags &= ~b_NoClose;
*mask |= b_NoClose;
break;
case 6: /* Respawn */
*flags |= b_Respawn;
*mask |= b_Respawn;
b->newflags.do_swallow_new = 0;
break;
case 7: /* NoRespawn */
*flags &= ~b_Respawn;
*mask |= b_Respawn;
b->newflags.do_swallow_new = 0;
break;
case 8: /* UseOld */
*flags |= b_UseOld;
*mask |= b_UseOld;
break;
case 9: /* NoOld */
*flags &= ~b_UseOld;
*mask |= b_UseOld;
break;
case 10: /* UseTitle */
*flags |= b_UseTitle;
*mask |= b_UseTitle;
break;
case 11: /* NoTitle */
*flags &= ~b_UseTitle;
*mask |= b_UseTitle;
break;
case 12: /* FvwmModule */
*flags |= b_FvwmModule;
*mask |= b_FvwmModule;
break;
case 13: /* NoFvwmModule */
*flags &= ~b_FvwmModule;
*mask |= b_FvwmModule;
break;
case 14: /* SwallowNew */
*flags &= ~b_Respawn;
*mask |= b_Respawn;
b->newflags.do_swallow_new = 1;
break;
default:
t = seekright(&s);
fprintf(stderr,
"%s: Illegal Swallow option \"%s\"\n", MyName,
(t) ? t : "");
if (t)
{
free(t);
}
}
}
if (*s)
{
s++;
}
*ss = s;
} | false | false | false | false | false | 0 |
lib3ds_mesh_calculate_normals(Lib3dsMesh *mesh, Lib3dsVector *normalL)
{
Lib3dsFaces **fl;
Lib3dsFaces *fa;
unsigned i,j,k;
if (!mesh->faces) {
return;
}
fl=calloc(sizeof(Lib3dsFaces*),mesh->points);
ASSERT(fl);
fa=calloc(sizeof(Lib3dsFaces),3*mesh->faces);
ASSERT(fa);
k=0;
for (i=0; i<mesh->faces; ++i) {
Lib3dsFace *f=&mesh->faceL[i];
for (j=0; j<3; ++j) {
Lib3dsFaces* l=&fa[k++];
ASSERT(f->points[j]<mesh->points);
l->face=f;
l->next=fl[f->points[j]];
fl[f->points[j]]=l;
}
}
for (i=0; i<mesh->faces; ++i) {
Lib3dsFace *f=&mesh->faceL[i];
for (j=0; j<3; ++j) {
// FIXME: static array needs at least check!!
Lib3dsVector n,N[128];
Lib3dsFaces *p;
int k,l;
int found;
ASSERT(f->points[j]<mesh->points);
if (f->smoothing) {
lib3ds_vector_zero(n);
k=0;
for (p=fl[f->points[j]]; p; p=p->next) {
found=0;
for (l=0; l<k; ++l) {
if( l >= 128 )
printf("array N overflow: i=%d, j=%d, k=%d\n", i,j,k);
if (fabs(lib3ds_vector_dot(N[l], p->face->normal)-1.0)<1e-5) {
found=1;
break;
}
}
if (!found) {
if (f->smoothing & p->face->smoothing) {
lib3ds_vector_add(n,n, p->face->normal);
lib3ds_vector_copy(N[k], p->face->normal);
++k;
}
}
}
}
else {
lib3ds_vector_copy(n, f->normal);
}
lib3ds_vector_normalize(n);
lib3ds_vector_copy(normalL[3*i+j], n);
}
}
free(fa);
free(fl);
} | false | false | false | false | false | 0 |
collectTemporary_terms(const temporary_terms_t &temporary_terms, temporary_terms_inuse_t &temporary_terms_inuse, int Curr_Block) const
{
temporary_terms_t::const_iterator it = temporary_terms.find(const_cast<NumConstNode *>(this));
if (it != temporary_terms.end())
temporary_terms_inuse.insert(idx);
} | false | false | false | false | false | 0 |
do_redirect(action_list_t *a, const char *addr, int cancel_keep)
{
action_list_t *b = NULL;
/* xxx we should validate addr */
/* see if this conflicts with any previous actions taken on this message */
while (a != NULL) {
b = a;
if (a->a == ACTION_REJECT)
return SIEVE_RUN_ERROR;
a = a->next;
}
/* add to the action list */
a = (action_list_t *) xmalloc(sizeof(action_list_t));
if (a == NULL)
return SIEVE_NOMEM;
a->a = ACTION_REDIRECT;
a->cancel_keep = cancel_keep;
a->u.red.addr = addr;
a->next = NULL;
b->next = a;
return 0;
} | false | false | false | true | false | 1 |
get ( int id )
{
IdentCache::iterator f = identCache.find ( id );
if ( f != identCache.end() )
return &(*(f->second));
else
return NULL;
} | false | false | false | false | false | 0 |
save_bool(PicklerObject *self, PyObject *obj)
{
if (self->proto >= 2) {
const char bool_op = (obj == Py_True) ? NEWTRUE : NEWFALSE;
if (_Pickler_Write(self, &bool_op, 1) < 0)
return -1;
}
else {
/* These aren't opcodes -- they're ways to pickle bools before protocol 2
* so that unpicklers written before bools were introduced unpickle them
* as ints, but unpicklers after can recognize that bools were intended.
* Note that protocol 2 added direct ways to pickle bools.
*/
const char *bool_str = (obj == Py_True) ? "I01\n" : "I00\n";
if (_Pickler_Write(self, bool_str, strlen(bool_str)) < 0)
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
ocfs2_init_meta_steal_slot(struct ocfs2_super *osb)
{
spin_lock(&osb->osb_lock);
osb->s_meta_steal_slot = OCFS2_INVALID_SLOT;
spin_unlock(&osb->osb_lock);
atomic_set(&osb->s_num_meta_stolen, 0);
} | false | false | false | false | false | 0 |
mono_init_delegate_virtual (MonoDelegate *del, MonoObject *target, MonoMethod *method)
{
g_assert (target);
method = mono_object_get_virtual_method (target, method);
MONO_OBJECT_SETREF (del, target, target);
del->method = method;
del->method_ptr = mono_compile_method (method);
if (mono_method_needs_static_rgctx_invoke (method, FALSE))
del->rgctx = mini_method_get_rgctx (method);
} | false | false | false | false | false | 0 |
cache_nbs(struct pci_dev *pdev, u32 cap_ptr)
{
int i;
if (amd_cache_northbridges() < 0)
return -ENODEV;
if (!amd_nb_has_feature(AMD_NB_GART))
return -ENODEV;
i = 0;
for (i = 0; i < amd_nb_num(); i++) {
struct pci_dev *dev = node_to_amd_nb(i)->misc;
if (fix_northbridge(dev, pdev, cap_ptr) < 0) {
dev_err(&dev->dev, "no usable aperture found\n");
#ifdef __x86_64__
/* should port this to i386 */
dev_err(&dev->dev, "consider rebooting with iommu=memaper=2 to get a good aperture\n");
#endif
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
free_server(aServer *serv)
{
aClient *cptr = serv->bcptr;
/* decrement reference counter, and eventually free it */
if (--serv->refcnt <= 0)
{
if (serv->refcnt == -211001)
{
/* Loop detected, break it.
* XXX: Remove loop detection before 2.11.0 - jv */
sendto_flag(SCH_DEBUG, "* %#x free_server loop %s *",
serv, serv->namebuf);
return;
}
/* Decrease (and possibly free) refcnt of the user struct
* of who connected this server.
*/
if (serv->user)
{
int cnt = serv->refcnt;
serv->refcnt = -211000; /* Loop detection */
free_user(serv->user);
serv->user = NULL;
serv->refcnt = cnt;
}
if (serv->refcnt < 0 || serv->prevs || serv->nexts ||
serv->bcptr || serv->user)
{
char buf[512];
sprintf(buf, "%d %p %p %p %p (%s)",
serv->refcnt, (void *)serv->prevs,
(void *)serv->nexts, (void *)serv->user,
(void *)serv->bcptr,
(serv->bcptr) ? serv->bcptr->name : "none");
#ifdef DEBUGMODE
dumpcore("%#x server %s %s",
cptr, cptr ? cptr->name : "<noname>", buf);
servs.inuse--;
#else
sendto_flag(SCH_ERROR, "* %#x server %s %s *",
cptr, cptr ? cptr->name : "<noname>", buf);
#endif
}
MyFree(serv);
}
} | true | true | false | false | false | 1 |
getChannel(uint idx)
{
uint rem = idx % 4;
switch(rem)
{
case 0:
default:
return "r";
case 1:
return "g";
case 2:
return "b";
case 3:
return "a";
};
} | false | false | false | false | false | 0 |
cliConnect(int force) {
if (context == NULL || force) {
if (context != NULL)
redisFree(context);
if (config.hostsocket == NULL) {
context = redisConnect(config.hostip,config.hostport);
} else {
context = redisConnectUnix(config.hostsocket);
}
if (context->err) {
fprintf(stderr,"Could not connect to Redis at ");
if (config.hostsocket == NULL)
fprintf(stderr,"%s:%d: %s\n",config.hostip,config.hostport,context->errstr);
else
fprintf(stderr,"%s: %s\n",config.hostsocket,context->errstr);
redisFree(context);
context = NULL;
return REDIS_ERR;
}
/* Do AUTH and select the right DB. */
if (cliAuth() != REDIS_OK)
return REDIS_ERR;
if (cliSelect() != REDIS_OK)
return REDIS_ERR;
}
return REDIS_OK;
} | false | false | false | false | false | 0 |
gz_path_add_line_notes(gx_path * ppath, fixed x, fixed y, segment_notes notes)
{
subpath *psub;
line_segment *lp;
if (ppath->bbox_set)
check_in_bbox(ppath, x, y);
path_open();
path_alloc_segment(lp, line_segment, &st_line, s_line, notes,
"gx_path_add_line");
path_alloc_link(lp);
path_set_point(lp, x, y);
path_update_draw(ppath);
trace_segment("[P]", ppath->memory, (segment *) lp);
return 0;
} | false | false | false | false | false | 0 |
sftk_handleKeyParameterObject(SFTKSession *session, SFTKObject *object)
{
SFTKAttribute *attribute;
CK_KEY_TYPE key_type;
CK_BBOOL ckfalse = CK_FALSE;
CK_RV crv;
/* verify the required fields */
if ( !sftk_hasAttribute(object,CKA_KEY_TYPE) ) {
return CKR_TEMPLATE_INCOMPLETE;
}
/* now verify the common fields */
crv = sftk_defaultAttribute(object,CKA_LOCAL,&ckfalse,sizeof(CK_BBOOL));
if (crv != CKR_OK) return crv;
/* get the key type */
attribute = sftk_FindAttribute(object,CKA_KEY_TYPE);
if (!attribute) {
return CKR_ATTRIBUTE_VALUE_INVALID;
}
key_type = *(CK_KEY_TYPE *)attribute->attrib.pValue;
sftk_FreeAttribute(attribute);
switch (key_type) {
case CKK_DSA:
return sftk_handleDSAParameterObject(session,object);
default:
break;
}
return CKR_KEY_TYPE_INCONSISTENT;
} | false | false | false | false | false | 0 |