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 |
|---|---|---|---|---|---|---|
Do_Asus_Video_Info()
{
ifstream file_in;
char *filename;
int type;
filename = "/proc/acpi/asus/disp";
file_in.open(filename);
if (!file_in)
{
if(Be_asus_quiet)
{
cout<<"<not available>"<<endl;
return 0;
}
else
{
cout<<" Could not open file : "<<filename<<endl;
cout<<" function Do_Asus_Video_Info : make sure your kernel has Asus ACPI support enabled."<<endl;
return -1;
}
}
cout<<" Video output : ";
file_in>>type;
switch(type)
{
case 0 : cout<<"no display"<<endl;
break;
case 1 : cout<<"LCD only"<<endl;
break;
case 2 : cout<<"CRT only"<<endl;
break;
case 3 : cout<<"LCD + CRT"<<endl;
break;
case 4 : cout<<"TV-out only"<<endl;
break;
case 5 : cout<<"LCD + TV-out"<<endl;
break;
case 6 : cout<<"CRT + TV-out"<<endl;
break;
case 7 : cout<<"LCD + CRT + TV-out"<<endl;
break;
default : cout<<"Undefined video out option. Check this! Video type = "<<type<<endl;
break;
}
file_in.close();
return 0;
} | false | false | false | false | false | 0 |
account_miner_job_traverse_folder (GomAccountMinerJob *job,
const gchar *folder_id,
GError **error)
{
GList *entries, *l;
entries = zpj_skydrive_list_folder_id (ZPJ_SKYDRIVE (job->service),
folder_id,
job->cancellable,
error);
if (*error != NULL)
goto out;
for (l = entries; l != NULL; l = l->next)
{
ZpjSkydriveEntry *entry = (ZpjSkydriveEntry *) l->data;
const gchar *id;
id = zpj_skydrive_entry_get_id (entry);
if (ZPJ_IS_SKYDRIVE_FOLDER (entry))
{
account_miner_job_traverse_folder (job, id, error);
if (*error != NULL)
goto out;
}
else if (ZPJ_IS_SKYDRIVE_PHOTO (entry))
continue;
account_miner_job_process_entry (job, entry, error);
if (*error != NULL)
{
g_warning ("Unable to process entry %p: %s", l->data, (*error)->message);
g_clear_error (error);
}
}
out:
if (entries != NULL)
g_list_free_full (entries, g_object_unref);
} | false | false | false | false | false | 0 |
TCMalloc_ResumeAllProcessThreads(int num_threads, pid_t *thread_pids) {
int detached_at_least_one = 0;
while (num_threads-- > 0) {
detached_at_least_one |= sys_ptrace_detach(thread_pids[num_threads]) >= 0;
}
return detached_at_least_one;
} | false | false | false | false | false | 0 |
get_sem_info(struct sem_info *sem_info, ulong shp, int id)
{
char buf[BUFSIZE];
sem_info->sem_array = shp - OFFSET(sem_array_sem_perm);
/*
* cache sem_array
*/
readmem(sem_info->sem_array, KVADDR, buf, SIZE(sem_array),
"sem_array", FAULT_ON_ERROR);
sem_info->key = INT(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_key));
if (VALID_MEMBER(sem_array_sem_id))
sem_info->semid = INT(buf + OFFSET(sem_array_sem_id));
else if (VALID_MEMBER(kern_ipc_perm_id))
sem_info->semid = INT(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_id));
else {
ulong seq;
seq = ULONG(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_seq));
sem_info->semid = ipcs_table.seq_multiplier * seq + id;
}
sem_info->uid = UINT(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_uid));
if (BITS32())
sem_info->perms = USHORT(buf +
OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_mode));
else
sem_info->perms = UINT(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_mode));
sem_info->nsems = ULONG(buf + OFFSET(sem_array_sem_nsems));
sem_info->deleted = UINT(buf + OFFSET(sem_array_sem_perm) +
OFFSET(kern_ipc_perm_deleted));
} | false | false | false | false | false | 0 |
size_of_encoded_value (int encoding)
{
if (encoding == DW_EH_PE_omit)
return 0;
switch (encoding & 0x07)
{
case DW_EH_PE_absptr:
return POINTER_SIZE / BITS_PER_UNIT;
case DW_EH_PE_udata2:
return 2;
case DW_EH_PE_udata4:
return 4;
case DW_EH_PE_udata8:
return 8;
}
abort ();
} | true | true | false | false | false | 1 |
c_alpha_read(gs_composite_t ** ppcte, const byte * data, uint size,
gs_memory_t * mem)
{
gs_composite_alpha_params_t params;
int code, nbytes = 1;
if (size < 1 || *data > composite_op_last)
return_error(gs_error_rangecheck);
params.op = *data;
if_debug1m('v', mem, "[v]c_alpha_read(%d)\n", params.op);
if (params.op == composite_Dissolve) {
if (size < 1 + sizeof(params.delta))
return_error(gs_error_rangecheck);
memcpy(¶ms.delta, data + 1, sizeof(params.delta));
nbytes += sizeof(params.delta);
}
code = gs_create_composite_alpha(ppcte, ¶ms, mem);
return code < 0 ? code : nbytes;
} | false | true | false | false | false | 1 |
git_zstream_deflatebuf(git_buf *out, const void *in, size_t in_len)
{
git_zstream zs = GIT_ZSTREAM_INIT;
int error = 0;
if ((error = git_zstream_init(&zs)) < 0)
return error;
if ((error = git_zstream_set_input(&zs, in, in_len)) < 0)
goto done;
while (!git_zstream_done(&zs)) {
size_t step = git_zstream_suggest_output_len(&zs), written;
if ((error = git_buf_grow(out, out->size + step)) < 0)
goto done;
written = out->asize - out->size;
if ((error = git_zstream_get_output(
out->ptr + out->size, &written, &zs)) < 0)
goto done;
out->size += written;
}
/* NULL terminate for consistency if possible */
if (out->size < out->asize)
out->ptr[out->size] = '\0';
done:
git_zstream_free(&zs);
return error;
} | false | false | false | false | false | 0 |
irplib_matrix_product_normal_create(const cpl_matrix * self)
{
double sum;
cpl_matrix * product;
const double * ai = cpl_matrix_get_data_const(self);
const double * aj;
double * bwrite;
const int m = cpl_matrix_get_nrow(self);
const int n = cpl_matrix_get_ncol(self);
int i, j, k;
cpl_ensure(self != NULL, CPL_ERROR_NULL_INPUT, NULL);
#if 0
/* Initialize all values to zero.
This is done to avoid access of uninitilized memory, in case
someone passes the matrix to for example cpl_matrix_dump(). */
product = cpl_matrix_new(m, m);
bwrite = cpl_matrix_get_data(product);
#else
bwrite = (double *) cpl_malloc(m * m * sizeof(double));
product = cpl_matrix_wrap(m, m, bwrite);
#endif
/* The result at (i,j) is the dot-product of i'th and j'th row */
for (i = 0; i < m; i++, bwrite += m, ai += n) {
aj = ai; /* aj points to first entry in j'th row */
for (j = i; j < m; j++, aj += n) {
sum = 0.0;
for (k = 0; k < n; k++) {
sum += ai[k] * aj[k];
}
bwrite[j] = sum;
}
}
return product;
} | false | false | false | false | false | 0 |
format(MSString& aString_,const MSFormat& aFormat_) const
{ return (aFormat_.formatType()==MSFormat::Rate)?format(aString_,aFormat_.rateFormat()):format(aString_); } | false | false | false | false | false | 0 |
cd_window_import_free_helper (CdWindowSetWidgetHelper *helper)
{
if (helper->cancellable != NULL)
g_object_unref (helper->cancellable);
g_object_unref (helper->window);
g_object_unref (helper->res);
g_free (helper);
} | false | false | false | false | false | 0 |
amdkfd_fence_wait_timeout(unsigned int *fence_addr,
unsigned int fence_value,
unsigned long timeout)
{
BUG_ON(!fence_addr);
timeout += jiffies;
while (*fence_addr != fence_value) {
if (time_after(jiffies, timeout)) {
pr_err("kfd: qcm fence wait loop timeout expired\n");
return -ETIME;
}
schedule();
}
return 0;
} | false | false | false | false | false | 0 |
Execute () {
Editor* ed = GetEditor();
if (OnlyOneEditorOf(ed->GetComponent()) && !ReadyToClose(ed)) {
return;
}
Style* style;
boolean reset_caption = false;
if (chooser_ == nil) {
style = new Style(Session::instance()->style());
chooser_ = DialogKit::instance()->file_chooser(".", style);
Resource::ref(chooser_);
char buf[CHARBUFSIZE];
const char* domain = unidraw->GetCatalog()->GetAttribute("domain");
domain = (domain == nil) ? "component" : domain;
sprintf(buf, "Select a %s to open:", domain);
style->attribute("caption", "");
style->attribute("subcaption", buf);
} else {
style = chooser_->style();
}
while (chooser_->post_for(ed->GetWindow())) {
const String* s = chooser_->selected();
NullTerminatedString ns(*s);
const char* name = ns.string();
Catalog* catalog = unidraw->GetCatalog();
GraphicComp* comp;
if (catalog->Retrieve(name, (Component*&) comp)) {
ModifStatusVar* modif = (ModifStatusVar*) ed->GetState(
"ModifStatusVar"
);
Component* orig = ed->GetComponent();
ed->SetComponent(comp);
unidraw->Update();
StateVar* sv = ed->GetState("CompNameVar");
CompNameVar* cnv = (CompNameVar*) sv;
if (cnv != nil) cnv->SetComponent(comp);
if (modif != nil) modif->SetComponent(comp);
if (orig != nil && unidraw->FindAny(orig) == nil) {
Component* root = orig->GetRoot();
delete root;
}
break;
} else {
chooser_->bodyclear();
style->attribute("caption", "Open failed!");
reset_caption = true;
}
}
if (reset_caption) {
chooser_->bodyclear();
style->attribute("caption", "");
}
} | false | false | false | false | false | 0 |
update_attributes_model (Compselect *compselect, TOPLEVEL *preview_toplevel)
{
GtkListStore *model;
GtkTreeIter iter;
GtkTreeViewColumn *column;
GList *listiter, *o_iter, *o_attrlist, *filter_list;
gchar *name, *value;
OBJECT *o_current;
model = (GtkListStore*) gtk_tree_view_get_model (compselect->attrtreeview);
gtk_list_store_clear (model);
/* Invalidate the column width for the attribute value column, so
* the column is re-sized based on the new data being shown. Symbols
* with long values are common, and we don't want having viewed those
* forcing a h-scroll-bar on symbols with short valued attributes.
*
* We might also consider invalidating the attribute name columns,
* however that gives an inconsistent column division when swithing
* between symbols, which doesn't look nice. For now, assume that
* the name column can keep the max width gained whilst previewing.
*/
column = gtk_tree_view_get_column (compselect->attrtreeview,
ATTRIBUTE_COLUMN_VALUE);
gtk_tree_view_column_queue_resize (column);
if (preview_toplevel->page_current == NULL) {
return;
}
o_attrlist = o_attrib_find_floating_attribs (
s_page_objects (preview_toplevel->page_current));
filter_list = GSCHEM_DIALOG (compselect)->w_current->component_select_attrlist;
if (filter_list != NULL
&& strcmp (filter_list->data, "*") == 0) {
/* display all attributes in alphabetical order */
o_attrlist = g_list_sort (o_attrlist, (GCompareFunc) sort_object_text);
for (o_iter = o_attrlist; o_iter != NULL; o_iter = g_list_next (o_iter)) {
o_current = o_iter->data;
o_attrib_get_name_value (o_current, &name, &value);
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter, 0, name, 1, value, -1);
g_free (name);
g_free (value);
}
} else {
/* display only attribute that are in the filter list */
for (listiter = filter_list;
listiter != NULL;
listiter = g_list_next (listiter)) {
for (o_iter = o_attrlist; o_iter != NULL; o_iter = g_list_next (o_iter)) {
o_current = o_iter->data;
if (o_attrib_get_name_value (o_current, &name, &value)) {
if (strcmp (name, listiter->data) == 0) {
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter, 0, name, 1, value, -1);
}
g_free (name);
g_free (value);
}
}
}
}
g_list_free (o_attrlist);
} | false | false | false | false | false | 0 |
cfg_shutdown_callback(corosync_cfg_handle_t h, corosync_cfg_shutdown_flags_t flags)
{
crm_info("Corosync wants to shut down: %s",
(flags == COROSYNC_CFG_SHUTDOWN_FLAG_IMMEDIATE) ? "immediate" :
(flags == COROSYNC_CFG_SHUTDOWN_FLAG_REGARDLESS) ? "forced" : "optional");
/* Never allow corosync to shut down while we're running */
corosync_cfg_replyto_shutdown(h, COROSYNC_CFG_SHUTDOWN_FLAG_NO);
} | false | false | false | false | false | 0 |
mx_stylable_iface_init (MxStylableIface *iface)
{
static gboolean is_initialized = FALSE;
if (!is_initialized)
{
GParamSpec *pspec;
ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
ClutterColor bg_color = { 0xff, 0xff, 0xff, 0x00 };
is_initialized = TRUE;
pspec = clutter_param_spec_color ("background-color",
"Background Color",
"The background color of an actor",
&bg_color,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = clutter_param_spec_color ("color",
"Text Color",
"The color of the text of an actor",
&color,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_boxed ("background-image",
"Background Image",
"Background image filename",
MX_TYPE_BORDER_IMAGE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_string ("font-family",
"Font Family",
"Name of the font to use",
"Sans",
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_int ("font-size",
"Font Size",
"Size of the font to use in pixels",
0, G_MAXINT, 12,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_enum ("font-weight",
"Font Weight",
"Font Weight",
MX_TYPE_FONT_WEIGHT,
MX_FONT_WEIGHT_NORMAL,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_boxed ("border-image",
"Border image",
"9-slice image to use for drawing borders and background",
MX_TYPE_BORDER_IMAGE,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_boxed ("padding",
"Padding",
"Padding between the widget's borders "
"and its content",
MX_TYPE_PADDING,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_uint ("x-mx-border-image-transition-duration",
"background transition duration",
"Length of the cross fade when changing images"
" in milliseconds",
0, G_MAXUINT, 0,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
/*
pspec = g_param_spec_uint ("x-mx-transition-duration",
"transition duration",
"Length of transition in milliseconds",
0, G_MAXUINT, 0,
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
pspec = g_param_spec_string ("x-mx-transition-property",
"transition property",
"Property to apply the transition too",
"",
G_PARAM_READWRITE);
mx_stylable_iface_install_property (iface, MX_TYPE_WIDGET, pspec);
*/
iface->style_changed = mx_widget_style_changed;
iface->get_style = mx_widget_get_style;
iface->set_style = mx_widget_set_style;
iface->get_style_pseudo_class = _mx_stylable_get_style_pseudo_class;
iface->set_style_pseudo_class = _mx_stylable_set_style_pseudo_class;
iface->get_style_class = _mx_widget_get_style_class;
iface->set_style_class = _mx_widget_set_style_class;
}
} | false | false | false | false | false | 0 |
hget_header(hashp, page_size)
HTAB *hashp;
u_int32_t page_size;
{
u_int32_t num_copied, i;
u_int8_t *hdr_dest;
num_copied = 0;
i = 0;
hdr_dest = (u_int8_t *)&hashp->hdr;
/*
* XXX
* This should not be printing to stderr on a "normal" error case.
*/
lseek(hashp->fp, 0, SEEK_SET);
num_copied = read(hashp->fp, hdr_dest, sizeof(HASHHDR));
if (num_copied != sizeof(HASHHDR)) {
fprintf(stderr, "hash: could not retrieve header");
return (0);
}
#if DB_BYTE_ORDER == DB_LITTLE_ENDIAN
swap_header(hashp);
#endif
return (num_copied);
} | false | false | false | false | false | 0 |
similarity_measure(
int *score,
git_diff_list *diff,
const git_diff_find_options *opts,
void **cache,
size_t a_idx,
size_t b_idx)
{
git_diff_file *a_file = similarity_get_file(diff, a_idx);
git_diff_file *b_file = similarity_get_file(diff, b_idx);
bool exact_match = FLAG_SET(opts, GIT_DIFF_FIND_EXACT_MATCH_ONLY);
*score = -1;
/* don't try to compare files of different types */
if (GIT_MODE_TYPE(a_file->mode) != GIT_MODE_TYPE(b_file->mode))
return 0;
/* if exact match is requested, force calculation of missing OIDs now */
if (exact_match) {
if (git_oid_iszero(&a_file->oid) &&
diff->old_src == GIT_ITERATOR_TYPE_WORKDIR &&
!git_diff__oid_for_file(diff->repo, a_file->path,
a_file->mode, a_file->size, &a_file->oid))
a_file->flags |= GIT_DIFF_FLAG_VALID_OID;
if (git_oid_iszero(&b_file->oid) &&
diff->new_src == GIT_ITERATOR_TYPE_WORKDIR &&
!git_diff__oid_for_file(diff->repo, b_file->path,
b_file->mode, b_file->size, &b_file->oid))
b_file->flags |= GIT_DIFF_FLAG_VALID_OID;
}
/* check OID match as a quick test */
if (git_oid__cmp(&a_file->oid, &b_file->oid) == 0) {
*score = 100;
return 0;
}
/* don't calculate signatures if we are doing exact match */
if (exact_match) {
*score = 0;
return 0;
}
/* update signature cache if needed */
if (!cache[a_idx] && similarity_calc(diff, opts, a_idx, cache) < 0)
return -1;
if (!cache[b_idx] && similarity_calc(diff, opts, b_idx, cache) < 0)
return -1;
/* some metrics may not wish to process this file (too big / too small) */
if (!cache[a_idx] || !cache[b_idx])
return 0;
/* compare signatures */
return opts->metric->similarity(
score, cache[a_idx], cache[b_idx], opts->metric->payload);
} | false | false | false | false | false | 0 |
png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
error_message)
{
int iout = 0, iin = 0;
while (iin < 4)
{
int c = png_ptr->chunk_name[iin++];
if (isnonalpha(c))
{
buffer[iout++] = '[';
buffer[iout++] = png_digit[(c & 0xf0) >> 4];
buffer[iout++] = png_digit[c & 0x0f];
buffer[iout++] = ']';
}
else
{
buffer[iout++] = (png_byte)c;
}
}
if (error_message == NULL)
buffer[iout] = 0;
else
{
buffer[iout++] = ':';
buffer[iout++] = ' ';
png_strncpy(buffer+iout, error_message, 63);
buffer[iout+63] = 0;
}
} | false | false | false | false | false | 0 |
compare_keys (gcry_sexp_t key, gcry_sexp_t sexp)
{
guchar hash1[20], hash2[20];
guchar *p;
/* Now compare them */
p = gcry_pk_get_keygrip (key, hash1);
g_assert ("couldn't get key id for private key" && p == hash1);
p = gcry_pk_get_keygrip (sexp, hash2);
g_assert ("couldn't get key id for parsed private key" && p == hash2);
return memcmp (hash1, hash2, 20) == 0;
} | false | false | false | false | false | 0 |
gar_nod_parse_nod3(struct gar_subfile *sub)
{
int i, rc;
off_t o;
int x,y,p;
struct nod_bond nb;
if (!sub->net || !sub->net->nod) {
return -1;
}
if (!sub->net->nod->nod3_offset || !sub->net->nod->nod3_length) {
log(1, "NOD: No boundary nodes defined\n");
return 0;
}
log(11, "nod3recsize=%d nodbond=%d\n", sub->net->nod->nod3_recsize,
sizeof(struct nod_bond));
o = sub->net->nod->nodoff + sub->net->nod->nod3_offset;
if (glseek(sub->gimg, o, SEEK_SET) != o) {
log(1, "NOD: Error can not seek to %ld\n", o);
return 0;
}
log(11, "Boundary nodes %d\n", sub->net->nod->nod3_length/sub->net->nod->nod3_recsize);
for (i=0; i < sub->net->nod->nod3_length/sub->net->nod->nod3_recsize; i++) {
rc = gread(sub->gimg, &nb, sizeof(struct nod_bond));
if (rc != sizeof(struct nod_bond)) {
log(1, "NOD: Can not read node\n");
return 0;
}
x = get_u24(&nb.east);
x = SIGN3B(x);
y = get_u24(&nb.north);
y = SIGN3B(y);
p = get_u24(&nb.offset);
log(11, "%d %f %f %x\n", i, GARDEG(x), GARDEG(y), p);
}
return 0;
} | false | false | false | false | false | 0 |
lm49453_set_bias_level(struct snd_soc_codec *codec,
enum snd_soc_bias_level level)
{
struct lm49453_priv *lm49453 = snd_soc_codec_get_drvdata(codec);
switch (level) {
case SND_SOC_BIAS_ON:
case SND_SOC_BIAS_PREPARE:
break;
case SND_SOC_BIAS_STANDBY:
if (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)
regcache_sync(lm49453->regmap);
snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
LM49453_PMC_SETUP_CHIP_EN, LM49453_CHIP_EN);
break;
case SND_SOC_BIAS_OFF:
snd_soc_update_bits(codec, LM49453_P0_PMC_SETUP_REG,
LM49453_PMC_SETUP_CHIP_EN, 0);
break;
}
return 0;
} | false | false | false | false | false | 0 |
init_orientation(Gtk::Orientation const &orientation)
{
static_cast<Gtk::Toolbar*>(_widget)->set_orientation(orientation);
if (orientation == Gtk::ORIENTATION_VERTICAL) {
set_handle_position(Gtk::POS_TOP);
}
switch (orientation) {
case Gtk::ORIENTATION_HORIZONTAL: {
Glib::RefPtr<Gtk::RadioAction>::cast_static(_detach_grp->get_action("OrientHoriz"))
->set_active();
break;
}
case Gtk::ORIENTATION_VERTICAL: {
Glib::RefPtr<Gtk::RadioAction>::cast_static(_detach_grp->get_action("OrientVert"))
->set_active();
break;
}
}
} | false | false | false | false | false | 0 |
MakeWMOFilename(char* fn, std::string fname)
{
if(loadFromMPQ)
sprintf(fn,"%s",fname.c_str());
else
{
NormalizeFilename(_PathToFileName(fname));
sprintf(fn,"./data/wmos/%s",fname.c_str());
}
} | false | false | false | false | false | 0 |
multi_pxo_process_nick_change(char *data)
{
char *from, *to;
player_list *lookup;
// get the new string
from = strtok(data," ");
to = strtok(NULL,"");
if((from != NULL) && (to != NULL)){
lookup = multi_pxo_find_player(from);
if(lookup != NULL){
strcpy_s(lookup->name,to);
// if this is also my nick, change it
if(!stricmp(Multi_pxo_nick,from)){
strcpy_s(Multi_pxo_nick,to);
}
}
}
} | false | false | false | false | false | 0 |
capture_read_data_cb(struct libusb_transfer *transfer)
{
struct fpi_ssm *ssm = transfer->user_data;
struct fp_img_dev *dev = ssm->priv;
struct aes2550_dev *aesdev = dev->priv;
unsigned char *data = transfer->buffer;
int r;
if (transfer->status != LIBUSB_TRANSFER_COMPLETED) {
fp_dbg("request is not completed, %d", transfer->status);
fpi_ssm_mark_aborted(ssm, -EIO);
goto out;
}
fp_dbg("request completed, len: %.4x", transfer->actual_length);
if (transfer->actual_length >= 2)
fp_dbg("data: %.2x %.2x", (int)data[0], (int)data[1]);
switch (transfer->actual_length) {
case AES2550_STRIP_SIZE:
r = process_strip_data(ssm, data);
if (r < 0) {
fp_dbg("Processing strip data failed: %d", r);
fpi_ssm_mark_aborted(ssm, -EPROTO);
goto out;
}
aesdev->heartbeat_cnt = 0;
fpi_ssm_jump_to_state(ssm, CAPTURE_READ_DATA);
break;
case AES2550_HEARTBEAT_SIZE:
if (data[0] == AES2550_HEARTBEAT_MAGIC) {
/* No data for a long time => finger was removed or there's no movement */
aesdev->heartbeat_cnt++;
if (aesdev->heartbeat_cnt == 3) {
/* Got 3 heartbeat message, that's enough to consider that finger was removed,
* assemble image and submit it to the library */
fp_dbg("Got 3 heartbeats => finger removed");
fpi_ssm_next_state(ssm);
} else {
fpi_ssm_jump_to_state(ssm, CAPTURE_READ_DATA);
}
}
break;
default:
fp_dbg("Short frame %d, skip", transfer->actual_length);
fpi_ssm_jump_to_state(ssm, CAPTURE_READ_DATA);
break;
}
out:
g_free(transfer->buffer);
libusb_free_transfer(transfer);
} | false | false | false | false | false | 0 |
_dxf_CREATE_HW_TRANSLATION (void *win)
{
#if defined(DX_NATIVE_WINDOWS)
return NULL;
#else
int i ;
DEFWINDATA(win) ;
hwTranslationP ret ;
char *gammaStr;
ENTRY(("_dxf_CREATE_HW_TRANSLATION (0x%x)",win));
if (! (ret = (hwTranslationP) tdmAllocate(sizeof(translationT))))
{
EXIT(("ERROR: Alloc failed ret = 0"));
return 0 ;
}
ret->dpy = DPY ;
ret->visual = NULL ;
ret->cmap = CLRMAP ;
ret->depth = 24 ;
ret->invertY = FALSE ;
#if sgi
ret->gamma = 1.0 ;
#else
ret->gamma = 2.0 ;
#endif
ret->translationType = ThreeMap ;
ret->redRange = 256 ;
ret->greenRange = 256 ;
ret->blueRange = 256 ;
ret->usefulBits = 8 ;
ret->rtable = &ret->data[256*3] ;
ret->gtable = &ret->data[256*2] ;
ret->btable = &ret->data[256] ;
ret->table = NULL ;
for(i=0 ; i<256 ; i++)
{
ret->rtable[i] = i << 24 ;
ret->gtable[i] = i << 16 ;
ret->btable[i] = i << 8 ;
}
if ((gammaStr=getenv("DXHWGAMMA")))
{
ret->gamma = atof(gammaStr);
if (ret->gamma < 0) ret->gamma = 0.0;
PRINT(("gamma environment var: ",atof(gammaStr)));
PRINT(("gamma: ",ret->gamma));
}
EXIT(("ret = 0x%x",ret));
return (translationO)ret ;
#endif
} | false | false | false | false | false | 0 |
fillPuzzleList (KSelectAction * s, const PuzzleItem itemList [])
{
QStringList list;
for (uint i=0; (strcmp (itemList[i].menuText, "END") != 0); i++) {
list.append (i18n(itemList[i].menuText));
}
s->setItems(list);
return (list.count() - 1);
} | false | false | false | false | false | 0 |
gt_graphics_cairo_get_text_height(GtGraphics *gg)
{
GtGraphicsCairo *g = gt_graphics_cairo_cast(gg);
gt_assert(g);
return g->font_height;
} | false | false | false | false | false | 0 |
sd_wait_voltage_stable_1(struct realtek_pci_sdmmc *host)
{
struct rtsx_pcr *pcr = host->pcr;
int err;
u8 stat;
/* Reference to Signal Voltage Switch Sequence in SD spec.
* Wait for a period of time so that the card can drive SD_CMD and
* SD_DAT[3:0] to low after sending back CMD11 response.
*/
mdelay(1);
/* SD_CMD, SD_DAT[3:0] should be driven to low by card;
* If either one of SD_CMD,SD_DAT[3:0] is not low,
* abort the voltage switch sequence;
*/
err = rtsx_pci_read_register(pcr, SD_BUS_STAT, &stat);
if (err < 0)
return err;
if (stat & (SD_CMD_STATUS | SD_DAT3_STATUS | SD_DAT2_STATUS |
SD_DAT1_STATUS | SD_DAT0_STATUS))
return -EINVAL;
/* Stop toggle SD clock */
err = rtsx_pci_write_register(pcr, SD_BUS_STAT,
0xFF, SD_CLK_FORCE_STOP);
if (err < 0)
return err;
return 0;
} | false | false | false | false | false | 0 |
fuse_write_update_size(struct inode *inode, loff_t pos)
{
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
bool ret = false;
spin_lock(&fc->lock);
fi->attr_version = ++fc->attr_version;
if (pos > inode->i_size) {
i_size_write(inode, pos);
ret = true;
}
spin_unlock(&fc->lock);
return ret;
} | false | false | false | false | false | 0 |
transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
{
Query *result = makeNode(Query);
List *argtype_oids; /* argtype OIDs in a list */
Oid *argtoids = NULL; /* and as an array */
int nargs;
List *queries;
int i;
result->commandType = CMD_UTILITY;
result->utilityStmt = (Node *) stmt;
/* Transform list of TypeNames to list (and array) of type OIDs */
nargs = list_length(stmt->argtypes);
if (nargs)
{
ListCell *l;
argtoids = (Oid *) palloc(nargs * sizeof(Oid));
i = 0;
foreach(l, stmt->argtypes)
{
TypeName *tn = lfirst(l);
Oid toid = typenameTypeId(pstate, tn);
argtoids[i++] = toid;
}
}
/*
* Analyze the statement using these parameter types (any parameters
* passed in from above us will not be visible to it), allowing
* information about unknown parameters to be deduced from context.
*/
queries = parse_analyze_varparams((Node *) stmt->query,
pstate->p_sourcetext,
&argtoids, &nargs);
/*
* Shouldn't get any extra statements, since grammar only allows
* OptimizableStmt
*/
if (list_length(queries) != 1)
elog(ERROR, "unexpected extra stuff in prepared statement");
/*
* Check that all parameter types were determined, and convert the array
* of OIDs into a list for storage.
*/
argtype_oids = NIL;
for (i = 0; i < nargs; i++)
{
Oid argtype = argtoids[i];
if (argtype == InvalidOid || argtype == UNKNOWNOID)
ereport(ERROR,
(errcode(ERRCODE_INDETERMINATE_DATATYPE),
errmsg("could not determine data type of parameter $%d",
i + 1)));
argtype_oids = lappend_oid(argtype_oids, argtype);
}
stmt->argtype_oids = argtype_oids;
stmt->query = linitial(queries);
return result;
} | false | false | false | false | false | 0 |
textControls (char *buf)
{
if (controls == CONTROLS_KEYBOARD) sprintf (buf, "%s", "KEYBOARD");
else if (controls == CONTROLS_MOUSE) sprintf (buf, "%s", "MOUSE");
else if (controls == CONTROLS_JOYSTICK) sprintf (buf, "%s", "JOYSTICK");
} | false | false | false | false | false | 0 |
create_font_btn (const PreferencesWidget * widget, GtkWidget * * label,
GtkWidget * * font_btn, const char * domain)
{
*font_btn = gtk_font_button_new();
gtk_font_button_set_use_font(GTK_FONT_BUTTON(*font_btn), TRUE);
gtk_font_button_set_use_size(GTK_FONT_BUTTON(*font_btn), TRUE);
gtk_widget_set_hexpand(*font_btn, TRUE);
if (widget->label) {
* label = gtk_label_new_with_mnemonic (dgettext (domain, widget->label));
gtk_label_set_use_markup(GTK_LABEL(*label), TRUE);
gtk_misc_set_alignment(GTK_MISC(*label), 1, 0.5);
gtk_label_set_justify(GTK_LABEL(*label), GTK_JUSTIFY_RIGHT);
gtk_label_set_mnemonic_widget(GTK_LABEL(*label), *font_btn);
}
if (widget->data.font_btn.title)
gtk_font_button_set_title (GTK_FONT_BUTTON (* font_btn),
dgettext (domain, widget->data.font_btn.title));
char * name = widget_get_string (widget);
if (name)
{
gtk_font_button_set_font_name ((GtkFontButton *) * font_btn, name);
g_free (name);
}
g_signal_connect (* font_btn, "font_set", (GCallback) on_font_btn_font_set, (void *) widget);
} | false | false | false | false | false | 0 |
GraalDelInstance( InstanceRds )
rdsins_list *InstanceRds;
{
phins_list *InstanceMbk;
rdsrec_list *ScanRec;
rdsrec_list *DelRec;
char Layer;
rdsbegin();
*(rdsins_list **)(InstanceRds->USER) = InstanceRds->NEXT;
if ( InstanceRds->NEXT != (rdsins_list *)NULL )
{
InstanceRds->NEXT->USER = InstanceRds->USER;
}
InstanceMbk = (phins_list *)GRAAL_MBK( InstanceRds->LAYERTAB[ RDS_ABOX ] );
*(phins_list **)(InstanceMbk->USER) = InstanceMbk->NEXT;
if ( InstanceMbk->NEXT != (phins_list *)NULL )
{
InstanceMbk->NEXT->USER = InstanceMbk->USER;
}
for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )
{
ScanRec = InstanceRds->LAYERTAB[ Layer ];
while( ScanRec != (rdsrec_list *)NULL )
{
DelRec = ScanRec;
ScanRec = ScanRec->NEXT;
GraalEraseRectangle( DelRec );
freerdsrec( DelRec, GRAAL_SIZE );
}
}
freerdsins( InstanceRds );
mbkfree( InstanceMbk );
rdsend();
} | false | false | false | false | false | 0 |
v9fs_file_lock_dotl(struct file *filp, int cmd, struct file_lock *fl)
{
struct inode *inode = file_inode(filp);
int ret = -ENOLCK;
p9_debug(P9_DEBUG_VFS, "filp: %p cmd:%d lock: %p name: %pD\n",
filp, cmd, fl, filp);
/* No mandatory locks */
if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
goto out_err;
if ((IS_SETLK(cmd) || IS_SETLKW(cmd)) && fl->fl_type != F_UNLCK) {
filemap_write_and_wait(inode->i_mapping);
invalidate_mapping_pages(&inode->i_data, 0, -1);
}
if (IS_SETLK(cmd) || IS_SETLKW(cmd))
ret = v9fs_file_do_lock(filp, cmd, fl);
else if (IS_GETLK(cmd))
ret = v9fs_file_getlock(filp, fl);
else
ret = -EINVAL;
out_err:
return ret;
} | false | false | false | false | false | 0 |
SetLayer (int layer)
{
char *state = NULL;
Window mRootWin = RootWindow (_display, DefaultScreen (_display));
XEvent xev;
memset (&xev, 0, sizeof(xev));
if (_wmType & wm_LAYER) {
if (!_state.origLayer)
_state.origLayer = GetGnomeLayer ();
xev.type = ClientMessage;
xev.xclient.display = _display;
xev.xclient.window = _XWindow;
xev.xclient.message_type = XA_WIN_LAYER;
xev.xclient.format = 32;
xev.xclient.data.l [0] = layer ? WIN_LAYER_ABOVE_DOCK : _state.origLayer;
xev.xclient.data.l [1] = CurrentTime;
PTRACE(4, "X11\tLayered style stay on top (layer " << xev.xclient.data.l[0] << ")");
XLockDisplay (_display);
XSendEvent (_display, mRootWin, FALSE, SubstructureNotifyMask, &xev);
XUnlockDisplay (_display);
}
else if (_wmType & wm_NETWM) {
xev.type = ClientMessage;
xev.xclient.message_type = XA_NET_WM_STATE;
xev.xclient.display = _display;
xev.xclient.window = _XWindow;
xev.xclient.format = 32;
xev.xclient.data.l [0] = layer;
if (_wmType & wm_STAYS_ON_TOP)
xev.xclient.data.l [1] = XA_NET_WM_STATE_STAYS_ON_TOP;
else
if (_wmType & wm_ABOVE)
xev.xclient.data.l [1] = XA_NET_WM_STATE_ABOVE;
else
if (_wmType & wm_FULLSCREEN)
xev.xclient.data.l [1] = XA_NET_WM_STATE_FULLSCREEN;
else
if (_wmType & wm_BELOW)
xev.xclient.data.l [1] = XA_NET_WM_STATE_BELOW;
XLockDisplay (_display);
XSendEvent (_display, mRootWin, FALSE, SubstructureRedirectMask, &xev);
state = XGetAtomName (_display, xev.xclient.data.l [1]);
PTRACE(4, "X11\tNET style stay on top (layer " << layer << "). Using state " << state );
XFree (state);
XUnlockDisplay (_display);
}
} | false | false | false | false | false | 0 |
generate_simple_sort(int size, char * name, int left)
{
// please make sure that i,j,k,z can be modified
fprintf(codefile,
" // sorting %s\n"
" // only if there is more than 1 permutation in class\n"
" if (Perm.MTO_class_%s())\n"
" {\n"
" for (i=0; i<%d; i++)\n"
" for (j=0; j<%d; j++)\n"
" pos_%s[i][j]=FALSE;\n"
" count_%s = 0;\n",
name, // sorting %s
name, // MTO_class_%s
size, size, name, // i-for j-for pos_%s
name // count_%s
);
if (elementtype->issimple())
{
fprintf(codefile,
" for (i=0; i<%d; i++)\n"
" {\n"
" for (j=0; j<count_%s; j++)\n"
" {\n"
" compare = CompareWeight(value[j],"
"(*this)[i+%d]);\n"
" if (compare==0)\n"
" {\n"
" pos_%s[j][i]= TRUE;\n"
" break;\n"
" }\n",
size, // i-for
name, // count_%s i.e. j-for
left, // array[i+%d]
name // pos_%s
);
fprintf(codefile,
" else if (compare>0)\n"
" {\n"
" for (k=count_%s; k>j; k--)\n"
" {\n"
" value[k].value(value[k-1].value());\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[k][z] = pos_%s[k-1][z];\n"
" }\n"
" value[j].value((*this)[i+%d].value());\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[j][z] = FALSE;\n"
" pos_%s[j][i] = TRUE;\n"
" count_%s++;\n"
" break;\n"
" }\n"
" }\n",
name, // count_%s
size, // z-for
name, name, // pos_%s pos_%s
left, // array[i+%d]
size, // z-for
name, // pos_%s
name, // pos_%s
name // count_%s
);
fprintf(codefile,
" if (j==count_%s)\n"
" {\n"
" value[j].value((*this)[i+%d].value());\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[j][z] = FALSE;\n"
" pos_%s[j][i] = TRUE;\n"
" count_%s++;\n"
" }\n"
" }\n"
" }\n",
name, // count_%s
left,
size, // z-for
name, // pos_%s
name, // pos_%s
name // count_%s
);
}
else
{
fprintf(codefile,
" for (i=0; i<%d; i++)\n"
" {\n"
" for (j=0; j<count_%s; j++)\n"
" {\n"
" compare = CompareWeight(value[j],"
"(*this)[i+%d]);\n"
" if (compare==0)\n"
" {\n"
" pos_%s[j][i]= TRUE;\n"
" break;\n"
" }\n",
size, // i-for
name, // count_%s i.e. j-for
left,
name // pos_%s
);
fprintf(codefile,
" else if (compare>0)\n"
" {\n"
" for (k=count_%s; k>j; k--)\n"
" {\n"
" value[k] = value[k-1];\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[k][z] = pos_%s[k-1][z];\n"
" }\n"
" value[j] = (*this)[i+%d];\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[j][z] = FALSE;\n"
" pos_%s[j][i] = TRUE;\n"
" count_%s++;\n"
" break;\n"
" }\n"
" }\n",
name, // count_%s
size, // z-for
name, name, // pos_%s pos_%s
left,
size, // z-for
name, // pos_%s
name, // pos_%s
name // count_%s
);
fprintf(codefile,
" if (j==count_%s)\n"
" {\n"
" value[j] = (*this)[i+%d];\n"
" for (z=0; z<%d; z++)\n"
" pos_%s[j][z] = FALSE;\n"
" pos_%s[j][i] = TRUE;\n"
" count_%s++;\n"
" }\n"
" }\n"
" }\n",
name, // count_%s
left,
size, // z-for
name, // pos_%s
name, // pos_%s
name // count_%s
);
}
} | false | false | false | false | false | 0 |
bpq_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{
struct bpq_ethaddr __user *ethaddr = ifr->ifr_data;
struct bpqdev *bpq = netdev_priv(dev);
struct bpq_req req;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
switch (cmd) {
case SIOCSBPQETHOPT:
if (copy_from_user(&req, ifr->ifr_data, sizeof(struct bpq_req)))
return -EFAULT;
switch (req.cmd) {
case SIOCGBPQETHPARAM:
case SIOCSBPQETHPARAM:
default:
return -EINVAL;
}
break;
case SIOCSBPQETHADDR:
if (copy_from_user(bpq->dest_addr, ethaddr->destination, ETH_ALEN))
return -EFAULT;
if (copy_from_user(bpq->acpt_addr, ethaddr->accept, ETH_ALEN))
return -EFAULT;
break;
default:
return -EINVAL;
}
return 0;
} | false | false | false | false | false | 0 |
ToStdString(std::string &str) const
{
str.reserve(size() + 1);
Convert::Unicode::UTF32ToANSI(begin(), end(), std::back_inserter(str), 0);
return str;
} | false | false | false | false | false | 0 |
Term_mn(CTX ctx, kTerm *tk)
{
if(TT_(tk) == TT_FUNCNAME || TT_(tk) == TT_NAME || TT_(tk) == TT_UNAME || TT_(tk) == TT_UFUNCNAME) {
TT_(tk) = TT_MN;
(tk)->mn = knh_getmn(ctx, TK_tobytes(tk), MN_NEWID);
}
if(TT_(tk) == TT_NEW) {
TT_(tk) = TT_MN;
(tk)->mn = knh_getmn(ctx, TK_tobytes(tk), MN_NEWID);
}
DBG_ASSERT(TT_(tk) == TT_MN);
if(Term_isISBOOL(tk)) {
(tk)->mn = MN_toISBOOL(MN_toFN((tk)->mn));
Term_setISBOOL(tk, 0);
}
else if(Term_isGetter(tk)) {
(tk)->mn = MN_toGETTER(MN_toFN((tk)->mn));
Term_setGetter(tk, 0);
}
else if(Term_isSetter(tk)) {
(tk)->mn = MN_toSETTER(MN_toFN((tk)->mn));
Term_setSetter(tk, 0);
}
return (tk)->mn;
} | false | false | false | false | false | 0 |
gw_menu_popup_catalog_rename ( GtkMenuItem *m, GtkCTreeNode *node) {
gboolean result = FALSE;
GtkWindow *window = NULL;
GWCatalogPlugin *plugin = NULL;
GWDBContext *context = gw_am_get_current_catalog_context ( );
GWDBCatalog *catalog = NULL;
#ifdef GW_DEBUG_GUI_CALLBACK_COMPONENT
g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif
if ( node != NULL && context != NULL) {
if ( (plugin = (GWCatalogPlugin*)gw_db_context_get_plugin ( context)) != NULL ) {
catalog = plugin->gw_db_catalog_get_db_catalog ( context);
window = gw_gui_manager_main_interface_get_main_window ( );
node_gw_menu_popup_callback = node;
gw_capture_box_create ( window, _( "Rename catalog"), _( "Enter new catalog name"), gw_db_catalog_get_name ( catalog), GTK_SIGNAL_FUNC ( gw_menu_popup_catalog_rename_ok));
gw_db_catalog_free ( catalog);
result = TRUE;
}
}
return result;
} | false | false | false | false | false | 0 |
check_onebit (void)
{
static const long data[] = {
-513, -512, -511, -65, -64, -63, -32, -1,
0, 1, 32, 53, 54, 64, 128, 256, 511, 512, 513
};
mpf_t f;
double got, want;
long got_exp, want_exp;
int i;
mpf_init2 (f, 1024L);
for (i = 0; i < numberof (data); i++)
{
mpf_set_ui (f, 1L);
if (data[i] >= 0)
mpf_mul_2exp (f, f, data[i]);
else
mpf_div_2exp (f, f, -data[i]);
want = 0.5;
want_exp = data[i] + 1;
got = mpf_get_d_2exp (&got_exp, f);
if (got != want || got_exp != want_exp)
{
printf ("mpf_get_d_2exp wrong on 2**%ld\n", data[i]);
mpf_trace (" f ", f);
d_trace (" want ", want);
d_trace (" got ", got);
printf (" want exp %ld\n", want_exp);
printf (" got exp %ld\n", got_exp);
abort();
}
}
mpf_clear (f);
} | false | false | false | false | false | 0 |
_getBufferUTF32Str() const
{
if ( mBufferType != bt_utf32string ) {
_cleanBuffer();
mBuffer.mUTF32StrBuffer = new utf32string();
mBufferType = bt_utf32string;
}
mBuffer.mUTF32StrBuffer->clear();
} | false | false | false | false | false | 0 |
get_icon() override
{
return gnote::IconManager::obj().get_icon(gnote::IconManager::SPECIAL_NOTES, 22);
}
} | false | false | false | false | false | 0 |
fixListHierarchy(void)
{
UT_uint32 iNumLists = m_vecLists.getItemCount();
fl_AutoNum * pAutoNum;
if (iNumLists == 0)
{
return false;
}
else
{
// Some documents may contain empty lists
// that appear as a result of importing ODT file which contains
// nested lists without paragraphs. To get rid of them we should
// delete all lists that are defined but doesn't contain any items
std::vector<unsigned int> itemsToRemove;
for (UT_uint32 i = 0; i < iNumLists; i++)
{
pAutoNum = m_vecLists.getNthItem(i);
if (pAutoNum->getFirstItem() == NULL)
{
itemsToRemove.push_back(i);
}
else
{
pAutoNum->fixHierarchy();
}
}
while(!itemsToRemove.empty())
{
m_vecLists.deleteNthItem(itemsToRemove.back());
itemsToRemove.pop_back();
}
return true;
}
} | false | false | false | false | false | 0 |
EmptyWidth(EmptyOp empty) {
int id = AllocInst(1);
if (id < 0)
return NoMatch();
inst_[id].InitEmptyWidth(empty, 0);
if (empty & (kEmptyBeginLine|kEmptyEndLine))
prog_->MarkByteRange('\n', '\n');
if (empty & (kEmptyWordBoundary|kEmptyNonWordBoundary)) {
int j;
for (int i = 0; i < 256; i = j) {
for (j = i+1; j < 256 && Prog::IsWordChar(i) == Prog::IsWordChar(j); j++)
;
prog_->MarkByteRange(i, j-1);
}
}
return Frag(id, PatchList::Mk(id << 1));
} | false | false | false | false | false | 0 |
gwy_func_use_info_compare(gconstpointer a,
gconstpointer b)
{
const GwyFunctionUseInfo *ainfo, *binfo;
gdouble aw, bw;
ainfo = (const GwyFunctionUseInfo*)a;
binfo = (const GwyFunctionUseInfo*)b;
aw = ainfo->global + ainfo->local;
bw = binfo->global + binfo->local;
if (aw < bw)
return 1;
else if (aw > bw)
return -1;
return 0;
} | false | false | false | false | false | 0 |
add(const ClpSimplex * /*model*/, double * array,
int iColumn, double multiplier) const
{
CoinBigIndex j = iColumn << 1;
int iRowM = indices_[j];
int iRowP = indices_[j+1];
if (iRowM >= 0)
array[iRowM] -= multiplier;
if (iRowP >= 0)
array[iRowP] += multiplier;
} | false | false | false | false | false | 0 |
php_array_key_compare(const void *a, const void *b TSRMLS_DC) /* {{{ */
{
Bucket *f;
Bucket *s;
zval result;
zval first;
zval second;
f = *((Bucket **) a);
s = *((Bucket **) b);
if (f->nKeyLength == 0) {
Z_TYPE(first) = IS_LONG;
Z_LVAL(first) = f->h;
} else {
Z_TYPE(first) = IS_STRING;
Z_STRVAL(first) = f->arKey;
Z_STRLEN(first) = f->nKeyLength - 1;
}
if (s->nKeyLength == 0) {
Z_TYPE(second) = IS_LONG;
Z_LVAL(second) = s->h;
} else {
Z_TYPE(second) = IS_STRING;
Z_STRVAL(second) = s->arKey;
Z_STRLEN(second) = s->nKeyLength - 1;
}
if (ARRAYG(compare_func)(&result, &first, &second TSRMLS_CC) == FAILURE) {
return 0;
}
if (Z_TYPE(result) == IS_DOUBLE) {
if (Z_DVAL(result) < 0) {
return -1;
} else if (Z_DVAL(result) > 0) {
return 1;
} else {
return 0;
}
}
convert_to_long(&result);
if (Z_LVAL(result) < 0) {
return -1;
} else if (Z_LVAL(result) > 0) {
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
rb_if_indextoname(const char *succ_prefix, const char *fail_prefix, unsigned int ifindex, char *buf, size_t len)
{
#if defined(HAVE_IF_INDEXTONAME)
char ifbuf[IFNAMSIZ];
if (if_indextoname(ifindex, ifbuf) == NULL)
return snprintf(buf, len, "%s%u", fail_prefix, ifindex);
else
return snprintf(buf, len, "%s%s", succ_prefix, ifbuf);
#else
# ifndef IFNAMSIZ
# define IFNAMSIZ (sizeof(unsigned int)*3+1)
# endif
return snprintf(buf, len, "%s%u", fail_prefix, ifindex);
#endif
} | false | false | false | false | false | 0 |
read_row_values(TABLE *table,
unsigned char *buf,
Field **fields,
bool read_all)
{
Field *f;
if (unlikely(! m_row_exists))
return HA_ERR_RECORD_DELETED;
/* Set the null bits */
DBUG_ASSERT(table->s->null_bytes == 1);
buf[0]= 0;
for (; (f= *fields) ; fields++)
{
if (read_all || bitmap_is_set(table->read_set, f->field_index))
{
switch(f->field_index)
{
case 0: /* NAME */
set_field_varchar_utf8(f, m_row.m_name, m_row.m_name_length);
break;
case 1: /* OBJECT_INSTANCE */
set_field_ulonglong(f, (intptr) m_row.m_identity);
break;
case 2: /* WRITE_LOCKED_BY_THREAD_ID */
if (m_row.m_write_locked)
set_field_ulong(f, m_row.m_write_locked_by_thread_id);
else
f->set_null();
break;
case 3: /* READ_LOCKED_BY_COUNT */
set_field_ulong(f, m_row.m_readers);
break;
default:
DBUG_ASSERT(false);
}
}
}
return 0;
} | false | false | false | false | false | 0 |
ufs_rmdir (struct inode * dir, struct dentry *dentry)
{
struct inode * inode = d_inode(dentry);
int err= -ENOTEMPTY;
if (ufs_empty_dir (inode)) {
err = ufs_unlink(dir, dentry);
if (!err) {
inode->i_size = 0;
inode_dec_link_count(inode);
inode_dec_link_count(dir);
}
}
return err;
} | false | false | false | false | false | 0 |
freetuxtv_cellrenderer_recordingslist_finalize (GObject *object)
{
FreetuxTVCellRendererRecordingsList *self;
self = FREETUXTV_CELLRENDERER_RECORDINGSLIST(object);
G_OBJECT_CLASS (freetuxtv_cellrenderer_recordingslist_parent_class)->finalize (object);
if(self->szTitle){
g_free(self->szTitle);
self->szTitle = NULL;
}
if(self->szLogoPath){
g_free(self->szLogoPath);
self->szLogoPath = NULL;
}
} | false | false | false | false | false | 0 |
update_size_window (MetaResizePopup *popup)
{
char *str;
int x, y;
int width, height;
g_return_if_fail (popup->size_window != NULL);
/* Translators: This represents the size of a window. The first number is
* the width of the window and the second is the height.
*/
str = g_strdup_printf (_("%d x %d"),
popup->horizontal_size,
popup->vertical_size);
gtk_label_set_text (GTK_LABEL (popup->size_label), str);
g_free (str);
gtk_window_get_size (GTK_WINDOW (popup->size_window), &width, &height);
x = popup->rect.x + (popup->rect.width - width) / 2;
y = popup->rect.y + (popup->rect.height - height) / 2;
if (gtk_widget_get_realized (popup->size_window))
{
/* using move_resize to avoid jumpiness */
gdk_window_move_resize (gtk_widget_get_window (popup->size_window),
x, y,
width, height);
}
else
{
gtk_window_move (GTK_WINDOW (popup->size_window),
x, y);
}
} | false | false | false | false | false | 0 |
_get_icon(void *data)
{
Evas *evas;
E_Config_Dialog_Data *cfdata;
Evas_Object *icon = NULL;
char buf[4096];
cfdata = data;
if (!cfdata) return NULL;
e_widget_disabled_set(cfdata->gui.icon, 1);
if (cfdata->gui.icon)
evas_object_del(cfdata->gui.icon);
cfdata->gui.icon = NULL;
if (cfdata->type == DEFAULT) return NULL;
evas = evas_object_evas_get(cfdata->gui.icon_wid);
switch (cfdata->type)
{
case THUMB:
icon = edje_object_add(evas);
e_theme_edje_object_set(icon, "base/theme/fileman", "e/icons/fileman/file");
break;
case THEME:
icon = edje_object_add(evas);
snprintf(buf, sizeof(buf), "e/icons/fileman/mime/%s", cfdata->mime);
if (!e_theme_edje_object_set(icon, "base/theme/fileman", buf))
e_theme_edje_object_set(icon, "base/theme/fileman", "e/icons/fileman/file");
break;
case EDJ:
icon = edje_object_add(evas);
edje_object_file_set(icon, cfdata->file, "icon");
e_widget_disabled_set(cfdata->gui.icon_wid, 0);
break;
case IMG:
icon = e_widget_image_add_from_file(evas, cfdata->file, 48, 48);
e_widget_disabled_set(cfdata->gui.icon_wid, 0);
break;
default:
break;
}
cfdata->gui.icon = icon;
return icon;
} | false | false | false | false | false | 0 |
search_oid (const char *oid, int *algorithm, gcry_md_oid_spec_t *oid_spec)
{
gcry_module_t module;
int ret = 0;
if (oid && ((! strncmp (oid, "oid.", 4))
|| (! strncmp (oid, "OID.", 4))))
oid += 4;
module = gcry_md_lookup_oid (oid);
if (module)
{
gcry_md_spec_t *digest = module->spec;
int i;
for (i = 0; digest->oids[i].oidstring && !ret; i++)
if (! stricmp (oid, digest->oids[i].oidstring))
{
if (algorithm)
*algorithm = module->mod_id;
if (oid_spec)
*oid_spec = digest->oids[i];
ret = 1;
}
_gcry_module_release (module);
}
return ret;
} | false | false | false | false | false | 0 |
internalOpen(void)
{
mySocket->init();
ArLog::log(ArLog::Verbose, "ArTcpConnection::internalOpen: Connecting to %s %d", myHostName.c_str(), myPortNum);
if (mySocket->connect(const_cast<char *>(myHostName.c_str()), myPortNum,
ArSocket::TCP))
{
myStatus = STATUS_OPEN;
mySocket->setNonBlock();
mySocket->setNoDelay(true);
return 0;
}
myStatus = STATUS_OPEN_FAILED;
switch(mySocket->getError())
{
case ArSocket::NetFail:
return OPEN_NET_FAIL;
case ArSocket::ConBadHost:
return OPEN_BAD_HOST;
case ArSocket::ConNoRoute:
return OPEN_NO_ROUTE;
case ArSocket::ConRefused:
return OPEN_CON_REFUSED;
case ArSocket::NoErr:
ArLog::log(ArLog::Terse, "ArTcpConnection::open: No error!\n");
default:
return -1;
}
} | false | false | false | false | false | 0 |
ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
{
struct usbnet *dev = netdev_priv(net);
u8 opt;
if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD,
1, 1, &opt) < 0) {
wolinfo->supported = 0;
wolinfo->wolopts = 0;
return;
}
wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
wolinfo->wolopts = 0;
if (opt & AX_MONITOR_MODE_RWLC)
wolinfo->wolopts |= WAKE_PHY;
if (opt & AX_MONITOR_MODE_RWMP)
wolinfo->wolopts |= WAKE_MAGIC;
} | false | false | false | false | false | 0 |
insertPlaylists( int topModelRow, Playlists::PlaylistList playlists )
{
TrackLoader *loader = new TrackLoader(); // auto-deletes itself
loader->setProperty( "topModelRow", QVariant( topModelRow ) );
connect( loader, SIGNAL(finished(Meta::TrackList)),
SLOT(slotLoaderWithRowFinished(Meta::TrackList)) );
loader->init( playlists );
} | false | false | false | false | false | 0 |
_rtl8152_set_rx_mode(struct net_device *netdev)
{
struct r8152 *tp = netdev_priv(netdev);
u32 mc_filter[2]; /* Multicast hash filter */
__le32 tmp[2];
u32 ocp_data;
netif_stop_queue(netdev);
ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR);
ocp_data &= ~RCR_ACPT_ALL;
ocp_data |= RCR_AB | RCR_APM;
if (netdev->flags & IFF_PROMISC) {
/* Unconditionally log net taps. */
netif_notice(tp, link, netdev, "Promiscuous mode enabled\n");
ocp_data |= RCR_AM | RCR_AAP;
mc_filter[1] = 0xffffffff;
mc_filter[0] = 0xffffffff;
} else if ((netdev_mc_count(netdev) > multicast_filter_limit) ||
(netdev->flags & IFF_ALLMULTI)) {
/* Too many to filter perfectly -- accept all multicasts. */
ocp_data |= RCR_AM;
mc_filter[1] = 0xffffffff;
mc_filter[0] = 0xffffffff;
} else {
struct netdev_hw_addr *ha;
mc_filter[1] = 0;
mc_filter[0] = 0;
netdev_for_each_mc_addr(ha, netdev) {
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
ocp_data |= RCR_AM;
}
}
tmp[0] = __cpu_to_le32(swab32(mc_filter[1]));
tmp[1] = __cpu_to_le32(swab32(mc_filter[0]));
pla_ocp_write(tp, PLA_MAR, BYTE_EN_DWORD, sizeof(tmp), tmp);
ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data);
netif_wake_queue(netdev);
} | false | false | false | false | false | 0 |
startDisplayP2(struct display *d)
{
char *cname, *cgname;
openCtrl(d);
debug("forking session\n");
ASPrintf(&cname, "sub-daemon for display %s", d->name);
ASPrintf(&cgname, "greeter for display %s", d->name);
switch (gFork(&d->pipe, "master daemon", cname,
&d->gpipe, cgname, 0, &d->pid)) {
case 0:
td = d;
#ifndef NOXDMTITLE
setproctitle("%s", d->name);
#endif
ASPrintf(&prog, "%s: %s", prog, d->name);
reInitErrorLog();
if (debugLevel & DEBUG_WSESS)
sleep(100);
mstrtalk.pipe = &d->pipe;
(void)Signal(SIGPIPE, SIG_IGN);
setAuthorization(d);
waitForServer(d);
if ((d->displayType & d_location) == dLocal) {
gSet(&mstrtalk);
if (Setjmp(mstrtalk.errjmp))
exit(EX_UNMANAGE_DPY);
gSendInt(D_XConnOk);
}
manageSession();
/* NOTREACHED */
case -1:
closeCtrl(d);
d->status = notRunning;
break;
default:
debug("forked session, pid %d\n", d->pid);
/* (void) fcntl (d->pipe.fd.r, F_SETFL, O_NONBLOCK); */
/* (void) fcntl (d->gpipe.fd.r, F_SETFL, O_NONBLOCK); */
registerInput(d->pipe.fd.r);
registerInput(d->gpipe.fd.r);
d->hstent->lock = d->hstent->rLogin = d->hstent->goodExit =
d->sdRec.how = 0;
d->lastStart = now;
break;
}
} | false | false | false | false | false | 0 |
next(Dbt &key, Dbt &data)
{
if (*p_ == (u_int32_t)-1) {
key.set_data(0);
key.set_size(0);
data.set_data(0);
data.set_size(0);
p_ = 0;
} else {
key.set_data(data_ + *p_);
p_--;
key.set_size(*p_);
p_--;
data.set_data(data_ + *p_);
p_--;
data.set_size(*p_);
p_--;
}
return (p_ != 0);
} | false | false | false | false | false | 0 |
get_ip_name (name_add_t *nt)
{
if (nt->dir == INBOUND)
fill_node_id(&nt->node_id, IP, nt, 16, 0, AF_INET);
else
fill_node_id(&nt->node_id, IP, nt, 12, 0, AF_INET);
if (!pref.name_res)
add_name (ipv4_to_str (nt->node_id.addr.ip.addr_v4),
NULL, &nt->node_id, nt);
else
add_name (ipv4_to_str (nt->node_id.addr.ip.addr_v4),
dns_lookup (&nt->node_id.addr.ip),
&nt->node_id, nt);
/* IPv4 header length can be variable */
nt->offset += nt->offset < nt->packet_size ?
(nt->p[nt->offset] & 15) << 2 : 0;
return TRUE;
} | false | false | false | false | false | 0 |
GetColorInterpretation()
{
NITFBandInfo *psBandInfo = psImage->pasBandInfo + nBand - 1;
if( poColorTable != NULL )
return GCI_PaletteIndex;
if( EQUAL(psBandInfo->szIREPBAND,"R") )
return GCI_RedBand;
if( EQUAL(psBandInfo->szIREPBAND,"G") )
return GCI_GreenBand;
if( EQUAL(psBandInfo->szIREPBAND,"B") )
return GCI_BlueBand;
if( EQUAL(psBandInfo->szIREPBAND,"M") )
return GCI_GrayIndex;
if( EQUAL(psBandInfo->szIREPBAND,"Y") )
return GCI_YCbCr_YBand;
if( EQUAL(psBandInfo->szIREPBAND,"Cb") )
return GCI_YCbCr_CbBand;
if( EQUAL(psBandInfo->szIREPBAND,"Cr") )
return GCI_YCbCr_CrBand;
return GCI_Undefined;
} | false | false | false | false | false | 0 |
smb_fdata(const u_char *buf, const char *fmt, const u_char *maxbuf,
int unicodestr)
{
static int depth = 0;
char s[128];
char *p;
while (*fmt) {
switch (*fmt) {
case '*':
fmt++;
while (buf < maxbuf) {
const u_char *buf2;
depth++;
buf2 = smb_fdata(buf, fmt, maxbuf, unicodestr);
depth--;
if (buf2 == NULL)
return(NULL);
if (buf2 == buf)
return(buf);
buf = buf2;
}
return(buf);
case '|':
fmt++;
if (buf >= maxbuf)
return(buf);
break;
case '%':
fmt++;
buf = maxbuf;
break;
case '#':
fmt++;
return(buf);
break;
case '[':
fmt++;
if (buf >= maxbuf)
return(buf);
memset(s, 0, sizeof(s));
p = strchr(fmt, ']');
if ((size_t)(p - fmt + 1) > sizeof(s)) {
/* overrun */
return(buf);
}
strncpy(s, fmt, p - fmt);
s[p - fmt] = '\0';
fmt = p + 1;
buf = smb_fdata1(buf, s, maxbuf, unicodestr);
if (buf == NULL)
return(NULL);
break;
default:
putchar(*fmt);
fmt++;
fflush(stdout);
break;
}
}
if (!depth && buf < maxbuf) {
size_t len = PTR_DIFF(maxbuf, buf);
printf("Data: (%lu bytes)\n", (unsigned long)len);
print_data(buf, len);
return(buf + len);
}
return(buf);
} | false | false | false | false | false | 0 |
UnloadBlob_PCR_COMPOSITE(UINT64 *offset, BYTE *blob, TCPA_PCR_COMPOSITE *out)
{
TSS_RESULT rc;
if (!out) {
UINT32 size;
if ((rc = UnloadBlob_PCR_SELECTION(offset, blob, NULL)))
return rc;
UnloadBlob_UINT32(offset, &size, blob);
if (size > 0)
UnloadBlob(offset, size, blob, NULL);
return TSS_SUCCESS;
}
if ((rc = UnloadBlob_PCR_SELECTION(offset, blob, &out->select)))
return rc;
UnloadBlob_UINT32(offset, &out->valueSize, blob);
out->pcrValue = malloc(out->valueSize);
if (out->pcrValue == NULL) {
LogError("malloc of %u bytes failed.", out->valueSize);
out->valueSize = 0;
return TCSERR(TSS_E_OUTOFMEMORY);
}
UnloadBlob(offset, out->valueSize, blob, (BYTE *) out->pcrValue);
return TSS_SUCCESS;
} | false | false | false | false | false | 0 |
frob_into_branch_around (gimple tp, eh_region region, tree over)
{
gimple x;
gimple_seq cleanup, result;
location_t loc = gimple_location (tp);
cleanup = gimple_try_cleanup (tp);
result = gimple_try_eval (tp);
if (region)
emit_post_landing_pad (&eh_seq, region);
if (gimple_seq_may_fallthru (cleanup))
{
if (!over)
over = create_artificial_label (loc);
x = gimple_build_goto (over);
gimple_set_location (x, loc);
gimple_seq_add_stmt (&cleanup, x);
}
gimple_seq_add_seq (&eh_seq, cleanup);
if (over)
{
x = gimple_build_label (over);
gimple_seq_add_stmt (&result, x);
}
return result;
} | false | false | false | false | false | 0 |
FcCharSetInsertLeaf (FcCharSet *fcs, FcChar32 ucs4, FcCharLeaf *leaf)
{
int pos;
pos = FcCharSetFindLeafPos (fcs, ucs4);
if (pos >= 0)
{
FcMemFree (FC_MEM_CHARLEAF, sizeof (FcCharLeaf));
free (FcCharSetLeaf (fcs, pos));
FcCharSetLeaves(fcs)[pos] = FcPtrToOffset (FcCharSetLeaves(fcs),
leaf);
return FcTrue;
}
pos = -pos - 1;
return FcCharSetPutLeaf (fcs, ucs4, leaf, pos);
} | false | false | false | false | false | 0 |
fireball_play_warphole_close_sound(fireball *fb)
{
int sound_index;
object *fireball_objp;
fireball_objp = &Objects[fb->objnum];
sound_index = SND_WARP_OUT;
if ( fb->warp_close_sound_index > -1 ) {
sound_index = fb->warp_close_sound_index;
} else if ( fb->flags & FBF_WARP_CAPITAL_SIZE ) {
sound_index = SND_CAPITAL_WARP_OUT;
} else {
return;
}
snd_play_3d(&Snds[sound_index], &fireball_objp->pos, &Eye_position, fireball_objp->radius); // play warp sound effect
} | false | false | false | false | false | 0 |
merge_info(FILE_INFO& new_info) {
char buf[256];
if (max_nbytes <= 0 && new_info.max_nbytes) {
max_nbytes = new_info.max_nbytes;
sprintf(buf, " <max_nbytes>%.0f</max_nbytes>\n", new_info.max_nbytes);
}
// replace existing URLs with new ones
//
download_urls.replace(new_info.download_urls);
upload_urls.replace(new_info.upload_urls);
download_gzipped = new_info.download_gzipped;
// replace signatures
//
if (strlen(new_info.file_signature)) {
safe_strcpy(file_signature, new_info.file_signature);
}
if (strlen(new_info.xml_signature)) {
safe_strcpy(xml_signature, new_info.xml_signature);
}
// If the file is supposed to be executable and is PRESENT,
// make sure it's actually executable.
// This deals with cases where somehow a file didn't
// get protected right when it was initially downloaded.
//
if (status == FILE_PRESENT && new_info.executable) {
int retval = set_permissions();
if (retval) {
msg_printf(project, MSG_INTERNAL_ERROR,
"merge_info(): failed to change permissions of %s", name
);
}
return retval;
}
return 0;
} | false | false | false | false | false | 0 |
l_dnaCreateFromIArray(l_int32 *iarray,
l_int32 size)
{
l_int32 i;
L_DNA *da;
PROCNAME("l_dnaCreateFromIArray");
if (!iarray)
return (L_DNA *)ERROR_PTR("iarray not defined", procName, NULL);
if (size <= 0)
return (L_DNA *)ERROR_PTR("size must be > 0", procName, NULL);
da = l_dnaCreate(size);
for (i = 0; i < size; i++)
l_dnaAddNumber(da, iarray[i]);
return da;
} | false | false | false | false | false | 0 |
ast_say_datetime_th(struct ast_channel *chan, time_t t, const char *ints, const char *lang)
{
struct timeval when = { t, 0 };
struct ast_tm tm;
char fn[256];
int res = 0;
int hour;
ast_localtime(&when, &tm, NULL);
if (!res) {
snprintf(fn, sizeof(fn), "digits/day-%d", tm.tm_wday);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res) {
snprintf(fn, sizeof(fn), "digits/mon-%d", tm.tm_mon);
res = ast_streamfile(chan, fn, lang);
if (!res)
res = ast_waitstream(chan, ints);
}
if (!res){
ast_copy_string(fn, "digits/posor", sizeof(fn));
res = ast_streamfile(chan, fn, lang);
res = ast_say_number(chan, tm.tm_year + 1900 + 543, ints, lang, (char *) NULL);
}
if (!res)
res = ast_say_number(chan, tm.tm_mday, ints, lang, (char *) NULL);
hour = tm.tm_hour;
if (!hour)
hour = 24;
if (!res){
ast_copy_string(fn, "digits/wela", sizeof(fn));
res = ast_streamfile(chan, fn, lang);
}
if (!res)
res = ast_say_number(chan, hour, ints, lang, (char *) NULL);
if (!res)
res = ast_say_number(chan, tm.tm_min, ints, lang, (char *) NULL);
return res;
} | true | true | false | false | false | 1 |
bfa_iocpf_sm_ready(struct bfa_iocpf_s *iocpf, enum iocpf_event event)
{
struct bfa_ioc_s *ioc = iocpf->ioc;
bfa_trc(ioc, event);
switch (event) {
case IOCPF_E_DISABLE:
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_disabling);
break;
case IOCPF_E_GETATTRFAIL:
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_initfail_sync);
break;
case IOCPF_E_FAIL:
bfa_fsm_set_state(iocpf, bfa_iocpf_sm_fail_sync);
break;
default:
bfa_sm_fault(ioc, event);
}
} | false | false | false | false | false | 0 |
kmx61_get_mode(struct kmx61_data *data, u8 *mode, u8 device)
{
int ret;
ret = i2c_smbus_read_byte_data(data->client, KMX61_REG_STBY);
if (ret < 0) {
dev_err(&data->client->dev, "Error reading reg_stby\n");
return ret;
}
*mode = 0;
if (device & KMX61_ACC) {
if (ret & KMX61_ACC_STBY_BIT)
*mode |= KMX61_ACC_STBY_BIT;
else
*mode &= ~KMX61_ACC_STBY_BIT;
}
if (device & KMX61_MAG) {
if (ret & KMX61_MAG_STBY_BIT)
*mode |= KMX61_MAG_STBY_BIT;
else
*mode &= ~KMX61_MAG_STBY_BIT;
}
return 0;
} | false | false | false | false | false | 0 |
vs_exist(virtual_server_t * old_vs)
{
element e;
list l = check_data->vs;
virtual_server_t *vs;
virtual_server_group_t *vsg;
if (LIST_ISEMPTY(l))
return NULL;
for (e = LIST_HEAD(l); e; ELEMENT_NEXT(e)) {
vs = ELEMENT_DATA(e);
if (VS_ISEQ(old_vs, vs)) {
/* Check if group exist */
if (vs->vsgname) {
vsg = ipvs_get_group_by_name(old_vs->vsgname,
check_data->vs_group);
if (!vsg)
return NULL;
else
if (!clear_diff_vsg(old_vs))
return NULL;
}
/*
* Exist so set alive.
*/
SET_ALIVE(vs);
return vs;
}
}
return NULL;
} | false | false | false | false | false | 0 |
sync_getflags(struct dlist *kl,
struct mailbox *mailbox,
struct index_record *record)
{
struct dlist *ki;
int userflag;
for (ki = kl->head; ki; ki = ki->next) {
char *s = xstrdup(ki->sval);
if (s[0] == '\\') {
/* System flags */
lcase(s);
if (!strcmp(s, "\\seen")) {
record->system_flags |= FLAG_SEEN;
} else if (!strcmp(s, "\\expunged")) {
record->system_flags |= FLAG_EXPUNGED;
} else if (!strcmp(s, "\\answered")) {
record->system_flags |= FLAG_ANSWERED;
} else if (!strcmp(s, "\\flagged")) {
record->system_flags |= FLAG_FLAGGED;
} else if (!strcmp(s, "\\deleted")) {
record->system_flags |= FLAG_DELETED;
} else if (!strcmp(s, "\\draft")) {
record->system_flags |= FLAG_DRAFT;
} else {
syslog(LOG_ERR, "Unknown system flag: %s", s);
}
}
else {
if (mailbox_user_flag(mailbox, s, &userflag)) {
syslog(LOG_ERR, "Unable to record user flag: %s", s);
return IMAP_IOERROR;
}
record->user_flags[userflag/32] |= 1<<(userflag&31);
}
free(s);
}
return 0;
} | false | false | false | false | false | 0 |
gradientbevelfilter_type(const fn_call& fn)
{
GradientBevelFilter_as* ptr = ensure<ThisIsNative<GradientBevelFilter_as> >(fn);
if (fn.nargs == 0)
{
switch (ptr->m_type)
{
case GradientBevelFilter::FULL_BEVEL:
return as_value("full");
break;
default:
case GradientBevelFilter::INNER_BEVEL:
return as_value("inner");
break;
case GradientBevelFilter::OUTER_BEVEL:
return as_value("outer");
break;
}
}
std::string type = fn.arg(0).to_string();
if (type == "outer")
ptr->m_type = GradientBevelFilter::OUTER_BEVEL;
if (type == "inner")
ptr->m_type = GradientBevelFilter::INNER_BEVEL;
if (type == "full")
ptr->m_type = GradientBevelFilter::FULL_BEVEL;
return as_value();
} | false | false | false | false | false | 0 |
F_mpz_neg(F_mpz_t f1, const F_mpz_t f2)
{
if (!COEFF_IS_MPZ(*f2)) // coeff is small
{
F_mpz t = -*f2; // Need to save value in case of aliasing
_F_mpz_demote(f1);
*f1 = t;
} else // coeff is large
{
// No need to retain value in promotion, as if aliased, both already large
__mpz_struct * mpz_ptr = _F_mpz_promote(f1);
mpz_neg(mpz_ptr, F_mpz_arr + COEFF_TO_OFF(*f2));
}
} | false | false | false | false | false | 0 |
io2_read(CTX ctx, kio_t *io2, char *buf, size_t bufsiz)
{
size_t rsize = 0;
while(bufsiz > 0) {
long remsiz = io2->tail - io2->top;
if(remsiz > 0) {
if(remsiz <= bufsiz) {
knh_memcpy(buf, io2->buffer + io2->top, bufsiz);
io2->top += bufsiz;
rsize += bufsiz;
return rsize;
}
else {
knh_memcpy(buf, io2->buffer + io2->top, remsiz);
buf += remsiz;
rsize += remsiz;
bufsiz -= remsiz;
}
}
if(!io2->isRunning) break;
io2->_read(ctx, io2);
}
return rsize;
} | false | false | false | false | false | 0 |
do_dungeon()
{
int rcnt = 0;
Sprintf(filename, DATA_IN_TEMPLATE, DGN_I_FILE);
if (!(ifp = fopen(filename, RDTMODE))) {
perror(filename);
exit(EXIT_FAILURE);
}
filename[0]='\0';
#ifdef FILE_PREFIX
Strcat(filename, file_prefix);
#endif
Sprintf(eos(filename), DGN_TEMPLATE, DGN_O_FILE);
if (!(ofp = fopen(filename, WRTMODE))) {
perror(filename);
exit(EXIT_FAILURE);
}
Fprintf(ofp,"%s",Dont_Edit_Data);
while (fgets(in_line, sizeof in_line, ifp) != 0) {
SpinCursor(3);
rcnt++;
if(in_line[0] == '#') continue; /* discard comments */
recheck:
if(in_line[0] == '%') {
int i = check_control(in_line);
if(i >= 0) {
if(!deflist[i].true_or_false) {
while (fgets(in_line, sizeof in_line, ifp) != 0)
if(check_control(in_line) != i) goto recheck;
} else
(void) fputs(without_control(in_line),ofp);
} else {
Fprintf(stderr, "Unknown control option '%s' in file %s at line %d.\n",
in_line, DGN_I_FILE, rcnt);
exit(EXIT_FAILURE);
}
} else
(void) fputs(in_line,ofp);
}
Fclose(ifp);
Fclose(ofp);
return;
} | false | false | false | false | true | 1 |
cmdGetBuffer610p (int cmd, int len, unsigned char *buffer)
{
int status, i, tmp;
int word[5];
int read, needed, max;
if (gMode == UMAX_PP_PARPORT_EPP)
return EPPcmdGetBuffer610p (cmd, len, buffer);
/* first we set length and channel */
/* compute word */
word[0] = len / 65536;
word[1] = (len / 256) % 256;
word[2] = len % 256;
word[3] = (cmd & 0x0F) | 0xC0;
word[4] = -1;
connect610p ();
sync610p ();
if (sendLength610p (word) == 0)
{
DBG (0, "sendLength610p(word) failed... (%s:%d)\n", __FILE__, __LINE__);
return 0;
}
status = getStatus610p ();
scannerStatus = status;
if ((status != 0xC0) && (status != 0xD0))
{
DBG (1, "Found 0x%X expected 0xC0 or 0xD0 (%s:%d)\n", status, __FILE__,
__LINE__);
return 0;
}
disconnect610p ();
if (sanei_umax_pp_getfull () == 1)
max = 2550 / 3;
else
max = 32768;
read = 0;
while (read < len)
{
if (len - read > max)
needed = max;
else
needed = len - read;
if (sanei_umax_pp_getfull () == 0)
status = getStatus610p ();
else
status = 0x20;
/* wait for data ready */
while ((status & 0x80) == 0x00)
{
connect610p ();
Outb (CONTROL, 0x07);
Outb (DATA, 0xFF);
tmp = Inb (DATA);
if (tmp != 0xFF)
{
DBG (0,
"cmdGetBuffer610p found 0x%02X expected 0xFF (%s:%d)\n",
tmp, __FILE__, __LINE__);
return 0;
}
status = Inb (STATUS) & 0xF8;
if ((status & 0x80) == 0x00)
disconnect610p ();
else
{
Outb (CONTROL, 0x04);
sync610p ();
byteMode ();
}
}
i = 0;
while (i < needed)
{
if (sanei_umax_pp_getfull () == 0)
{
status = Inb (STATUS) & 0xF8;
if (status == 0xC8)
{
for (tmp = 0; tmp < 18; tmp++)
status = Inb (STATUS) & 0xF8;
break;
}
}
Outb (CONTROL, 0x26); /* data reverse+ 'reg' */
buffer[read + i] = Inb (DATA);
Outb (CONTROL, 0x24); /* data reverse+ 'reg' */
i++;
}
byteMode ();
disconnect610p ();
read += i;
}
return 1;
} | false | false | false | false | false | 0 |
patest1Callback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
{
patest1data *data = (patest1data*)userData;
float *in = (float*)inputBuffer;
float *out = (float*)outputBuffer;
int framesToCalc = framesPerBuffer;
unsigned long i = 0;
int finished;
if( data->sampsToGo < framesPerBuffer )
{
framesToCalc = data->sampsToGo;
finished = paComplete;
}
else
{
finished = paContinue;
}
for( ; i<framesToCalc; i++ )
{
*out++ = *in++ * data->sine[data->phase]; /* left */
*out++ = *in++ * data->sine[data->phase++]; /* right */
if( data->phase >= 100 )
data->phase = 0;
}
data->sampsToGo -= framesToCalc;
/* zero remainder of final buffer if not already done */
for( ; i<framesPerBuffer; i++ )
{
*out++ = 0; /* left */
*out++ = 0; /* right */
}
return finished;
} | false | false | false | false | false | 0 |
counterTypeToString( uint32_t properties ) {
switch( properties & OTF_COUNTER_TYPE_BITS ) {
CASE_RETURN( TYPE, ACC );
CASE_RETURN( TYPE, ABS );
default: {
static char unknown_buffer[ 64 ];
sprintf( unknown_buffer, "UNKNOWN <%u>",
properties & OTF_COUNTER_TYPE_BITS );
return unknown_buffer;
}
}
} | false | false | false | false | false | 0 |
cos_array_unadd(cos_array_t *pca, cos_value_t *pvalue)
{
cos_array_element_t *pcae = pca->elements;
if (pcae == 0 ||
pcae->index != (pcae->next == 0 ? 0 : pcae->next->index + 1)
)
return_error(gs_error_rangecheck);
*pvalue = pcae->value;
pca->elements = pcae->next;
gs_free_object(COS_OBJECT_MEMORY(pca), pcae, "cos_array_unadd");
pca->md5_valid = false;
return 0;
} | false | false | false | false | false | 0 |
qof_query_kvp_predicate (QofQueryCompare how,
QofQueryParamList *path, const KvpValue *value)
{
query_kvp_t pdata;
QofQueryParamList *node;
g_return_val_if_fail (path && value, NULL);
pdata = g_new0 (query_kvp_def, 1);
pdata->pd.type_name = query_kvp_type;
pdata->pd.how = how;
pdata->value = kvp_value_copy (value);
pdata->path = g_slist_copy (path);
for (node = pdata->path; node; node = node->next)
node->data = g_strdup (node->data);
return ((QofQueryPredData*)pdata);
} | false | false | false | false | false | 0 |
SySetGetNextEntry(SySet *pSet, void **ppEntry)
{
register unsigned char *zSrc;
if( pSet->nCursor >= pSet->nUsed ){
/* Reset cursor */
pSet->nCursor = 0;
return SXERR_EOF;
}
zSrc = (unsigned char *)SySetBasePtr(pSet);
if( ppEntry ){
*ppEntry = (void *)&zSrc[pSet->nCursor * pSet->eSize];
}
pSet->nCursor++;
return SXRET_OK;
} | false | false | false | false | false | 0 |
amitk_data_set_set_injected_dose(AmitkDataSet * ds,amide_data_t new_injected_dose) {
g_return_if_fail(AMITK_IS_DATA_SET(ds));
if (ds->injected_dose != new_injected_dose) {
ds->injected_dose = new_injected_dose;
amitk_data_set_set_scale_factor(ds, calculate_scale_factor(ds));
}
} | false | false | false | false | false | 0 |
file_write(struct wif *wi, unsigned char *h80211, int len,
struct tx_info *ti)
{
struct priv_file *pn = wi_priv(wi);
if (h80211 && ti && pn) {}
return len;
} | false | false | false | false | false | 0 |
Lower(const MachineInstr *MI, MCInst &OutMI) const {
OutMI.setOpcode(MI->getOpcode());
for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
const MachineOperand &MO = MI->getOperand(i);
MCOperand MCOp;
switch (MO.getType()) {
default:
MI->dump();
llvm_unreachable("unknown operand type");
case MachineOperand::MO_Register:
// Ignore all implicit register operands.
if (MO.isImplicit())
continue;
MCOp = MCOperand::createReg(MO.getReg());
break;
case MachineOperand::MO_Immediate:
MCOp = MCOperand::createImm(MO.getImm());
break;
case MachineOperand::MO_MachineBasicBlock:
MCOp = MCOperand::createExpr(
MCSymbolRefExpr::create(MO.getMBB()->getSymbol(), Ctx));
break;
case MachineOperand::MO_RegisterMask:
continue;
case MachineOperand::MO_GlobalAddress:
MCOp = LowerSymbolOperand(MO, GetGlobalAddressSymbol(MO));
break;
}
OutMI.addOperand(MCOp);
}
} | false | false | false | false | false | 0 |
determine_unroll_factor (vec<chain_p> chains)
{
chain_p chain;
unsigned factor = 1, af, nfactor, i;
unsigned max = PARAM_VALUE (PARAM_MAX_UNROLL_TIMES);
FOR_EACH_VEC_ELT (chains, i, chain)
{
if (chain->type == CT_INVARIANT || chain->combined)
continue;
/* The best unroll factor for this chain is equal to the number of
temporary variables that we create for it. */
af = chain->length;
if (chain->has_max_use_after)
af++;
nfactor = factor * af / gcd (factor, af);
if (nfactor <= max)
factor = nfactor;
}
return factor;
} | false | false | false | false | false | 0 |
relocate(
void * pvOldAlloc,
void * pvNewAlloc)
{
FlmRecord * pOldRec = (FlmRecord *)pvOldAlloc;
FlmRecord * pNewRec = (FlmRecord *)pvNewAlloc;
RCACHE * pRCache;
RCACHE * pVersion;
flmAssert( pOldRec->getRefCount() == 1);
flmAssert( pOldRec->isCached());
flmAssert( pvNewAlloc < pvOldAlloc);
// Update the record pointer in the data buffer
if( pNewRec->m_pucBuffer)
{
flmAssert( *((FlmRecord **)pOldRec->m_pucBuffer) == pOldRec);
*((FlmRecord **)pNewRec->m_pucBuffer) = pNewRec;
}
if( pNewRec->m_pucFieldIdTable)
{
flmAssert( *((FlmRecord **)pOldRec->m_pucFieldIdTable) == pOldRec);
*((FlmRecord **)pNewRec->m_pucFieldIdTable) = pNewRec;
}
// Find the record
pRCache = *(FLM_RCA_HASH( pNewRec->m_uiRecordID));
while( pRCache)
{
if( pRCache->uiDrn == pNewRec->m_uiRecordID)
{
pVersion = pRCache;
while( pVersion)
{
if( pVersion->pRecord == pOldRec)
{
pVersion->pRecord = pNewRec;
goto Done;
}
pVersion = pVersion->pOlderVersion;
}
}
pRCache = pRCache->pNextInBucket;
}
Done:
flmAssert( pRCache);
} | false | false | false | false | false | 0 |
neo_tasklet(unsigned long data)
{
struct dgnc_board *bd = (struct dgnc_board *)data;
struct channel_t *ch;
unsigned long flags;
int i;
int state = 0;
int ports = 0;
if (!bd || bd->magic != DGNC_BOARD_MAGIC)
return;
/* Cache a couple board values */
spin_lock_irqsave(&bd->bd_lock, flags);
state = bd->state;
ports = bd->nasync;
spin_unlock_irqrestore(&bd->bd_lock, flags);
/*
* Do NOT allow the interrupt routine to read the intr registers
* Until we release this lock.
*/
spin_lock_irqsave(&bd->bd_intr_lock, flags);
/*
* If board is ready, parse deeper to see if there is anything to do.
*/
if ((state == BOARD_READY) && (ports > 0)) {
/* Loop on each port */
for (i = 0; i < ports; i++) {
ch = bd->channels[i];
/* Just being careful... */
if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
continue;
/*
* NOTE: Remember you CANNOT hold any channel
* locks when calling the input routine.
*
* During input processing, its possible we
* will call the Linux ld, which might in turn,
* do a callback right back into us, resulting
* in us trying to grab the channel lock twice!
*/
dgnc_input(ch);
/*
* Channel lock is grabbed and then released
* inside both of these routines, but neither
* call anything else that could call back into us.
*/
neo_copy_data_from_queue_to_uart(ch);
dgnc_wakeup_writes(ch);
/*
* Call carrier carrier function, in case something
* has changed.
*/
dgnc_carrier(ch);
/*
* Check to see if we need to turn off a sending break.
* The timing check is done inside clear_break()
*/
if (ch->ch_stop_sending_break)
neo_clear_break(ch, 0);
}
}
/* Allow interrupt routine to access the interrupt register again */
spin_unlock_irqrestore(&bd->bd_intr_lock, flags);
} | false | false | false | false | false | 0 |
recv_control_msg(struct au0828_dev *dev, u16 request, u32 value,
u16 index, unsigned char *cp, u16 size)
{
int status = -ENODEV;
mutex_lock(&dev->mutex);
if (dev->usbdev) {
status = usb_control_msg(dev->usbdev,
usb_rcvctrlpipe(dev->usbdev, 0),
request,
USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
value, index,
dev->ctrlmsg, size, 1000);
status = min(status, 0);
if (status < 0) {
pr_err("%s() Failed receiving control message, error %d.\n",
__func__, status);
}
/* the host controller requires heap allocated memory, which
is why we didn't just pass "cp" into usb_control_msg */
memcpy(cp, dev->ctrlmsg, size);
}
mutex_unlock(&dev->mutex);
return status;
} | false | false | false | false | false | 0 |
process( std::string name_, const ssize_t argc, const char **argv )
{
modifyImage();
size_t status =
InvokeDynamicImageFilter( name_.c_str(), &image(), argc, argv,
&image()->exception );
if (status == false)
throwException( image()->exception );
} | false | false | false | false | false | 0 |
setTransformType(const TransformType &type)
{
if (type == d_ptr->transType)
return;
d_ptr->transType = type;
emit transformTypeChanged(type);
} | false | false | false | false | false | 0 |
btrfs_lookup_inode_extref(struct btrfs_trans_handle *trans,
struct btrfs_root *root,
struct btrfs_path *path,
const char *name, int name_len,
u64 inode_objectid, u64 ref_objectid, int ins_len,
int cow)
{
int ret;
struct btrfs_key key;
struct btrfs_inode_extref *extref;
key.objectid = inode_objectid;
key.type = BTRFS_INODE_EXTREF_KEY;
key.offset = btrfs_extref_hash(ref_objectid, name, name_len);
ret = btrfs_search_slot(trans, root, &key, path, ins_len, cow);
if (ret < 0)
return ERR_PTR(ret);
if (ret > 0)
return NULL;
if (!btrfs_find_name_in_ext_backref(path, ref_objectid, name, name_len, &extref))
return NULL;
return extref;
} | false | false | false | false | false | 0 |
align_to_column(chunk_t *pc, int column)
{
if (column == pc->column)
{
return;
}
LOG_FMT(LINDLINE, "%s: %d] col %d on %.*s [%s] => %d\n",
__func__, pc->orig_line, pc->column, pc->len, pc->str,
get_token_name(pc->type), column);
int col_delta = column - pc->column;
int min_col = column;
int min_delta;
pc->column = column;
do
{
chunk_t *next = chunk_get_next(pc);
chunk_t *prev;
align_mode almod = ALMODE_SHIFT;
if (next == NULL)
{
break;
}
min_delta = space_col_align(pc, next);
min_col += min_delta;
prev = pc;
pc = next;
if (chunk_is_comment(pc) && (pc->parent_type != CT_COMMENT_EMBED))
{
almod = (chunk_is_single_line_comment(pc) &&
cpd.settings[UO_indent_relative_single_line_comments].b) ?
ALMODE_KEEP_REL : ALMODE_KEEP_ABS;
}
if (almod == ALMODE_KEEP_ABS)
{
/* Keep same absolute column */
pc->column = pc->orig_col;
if (pc->column < min_col)
{
pc->column = min_col;
}
}
else if (almod == ALMODE_KEEP_REL)
{
/* Keep same relative column */
int orig_delta = pc->orig_col - prev->orig_col;
if (orig_delta < min_delta)
{
orig_delta = min_delta;
}
pc->column = prev->column + orig_delta;
}
else /* ALMODE_SHIFT */
{
/* Shift by the same amount */
pc->column += col_delta;
if (pc->column < min_col)
{
pc->column = min_col;
}
}
LOG_FMT(LINDLINED, " %s set column of %s on line %d to col %d (orig %d)\n",
(almod == ALMODE_KEEP_ABS) ? "abs" :
(almod == ALMODE_KEEP_REL) ? "rel" : "sft",
get_token_name(pc->type), pc->orig_line, pc->column, pc->orig_col);
} while ((pc != NULL) && (pc->nl_count == 0));
} | false | false | false | false | false | 0 |
max_error_bound()
{
if (mode_!=estimate_condition && mode_ != estimate_condition_verbose)
return 0;
if (!factored_)
{
spFactor(pmatrix_);
if (!est_condition())
return 0;
factored_ = true;
}
double roundoff = spRoundoff(pmatrix_, largest_);
if (rcond_>0)
return roundoff/rcond_;
return 0;
} | false | false | false | false | false | 0 |
RPCEvaluate( double *padfTerms, double *padfCoefs )
{
double dfSum = 0.0;
int i;
for( i = 0; i < 20; i++ )
dfSum += padfTerms[i] * padfCoefs[i];
return dfSum;
} | false | false | false | false | false | 0 |
size_request (GtkWidget *widget,
GtkRequisition *requisition,
BonoboDockItem *dock_item)
{
GtkBin *bin;
GtkRequisition child_requisition;
bin = GTK_BIN (widget);
/* If our child is not visible, we still request its size, since
we won't have any useful hint for our size otherwise. */
if (bin->child != NULL)
gtk_widget_size_request (bin->child, &child_requisition);
else
{
child_requisition.width = 0;
child_requisition.height = 0;
}
if (dock_item->orientation == GTK_ORIENTATION_HORIZONTAL)
{
requisition->width =
BONOBO_DOCK_ITEM_NOT_LOCKED (dock_item) ? DRAG_HANDLE_SIZE : 0;
if (bin->child != NULL)
{
requisition->width += child_requisition.width;
requisition->height = child_requisition.height;
}
else
requisition->height = 0;
}
else
{
requisition->height =
BONOBO_DOCK_ITEM_NOT_LOCKED (dock_item) ? DRAG_HANDLE_SIZE : 0;
if (bin->child != NULL)
{
requisition->width = child_requisition.width;
requisition->height += child_requisition.height;
}
else
requisition->width = 0;
}
requisition->width += GTK_CONTAINER (widget)->border_width * 2;
requisition->height += GTK_CONTAINER (widget)->border_width * 2;
} | 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.