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 |
|---|---|---|---|---|---|---|
ujfs_adjtree(int8_t * treep, int32_t l2leaves, int32_t l2min)
{
int32_t nleaves, leaf_index, l2max, nextb, bsize, index;
int32_t l2free, leaf, num_this_level, nextp;
int8_t *cp0, *cp1, *cp = treep;
/*
* Determine the number of leaves of the tree and the
* index of the first leaf.
* Note: I don't know why the leaf_index calculation works, but it does.
*/
nleaves = (1 << l2leaves);
leaf_index = (nleaves - 1) / 3;
/*
* Determine the maximum free string possible for the leaves.
*/
l2max = l2min + l2leaves;
/*
* Try to combine buddies starting with a buddy size of 1 (i.e. two leaves).
* At a buddy size of 1 two buddy leaves can be combined if both buddies
* have a maximum free of l2min; the combination will result in the
* left-most buddy leaf having a maximum free of l2min+1. After processing
* all buddies for a certain size, process buddies at the next higher buddy
* size (i.e. current size * 2) and the next maximum free
* (current free + 1). This continues until the maximum possible buddy
* combination yields maximum free.
*/
for (l2free = l2min, bsize = 1; l2free < l2max; l2free++, bsize = nextb) {
nextb = bsize << 1;
for (cp0 = cp + leaf_index, index = 0; index < nleaves;
index += nextb, cp0 += nextb) {
if (*cp0 == l2free && *(cp0 + bsize) == l2free) {
*cp0 = l2free + 1;
*(cp0 + bsize) = -1;
}
}
}
/*
* With the leaves reflecting maximum free values bubble this information up
* the tree. Starting at the leaf node level, the four nodes described by
* the higher level parent node are compared for a maximum free and this
* maximum becomes the value of the parent node. All lower level nodes are
* processed in this fashion then we move up to the next level (parent
* becomes a lower level node) and continue the process for that level.
*/
for (leaf = leaf_index, num_this_level = nleaves >> 2; num_this_level > 0;
num_this_level >>= 2, leaf = nextp) {
nextp = (leaf - 1) >> 2;
/*
* Process all lower level nodes at this level setting the value of the
* parent node as the maximum of the four lower level nodes.
*/
for (cp0 = cp + leaf, cp1 = cp + nextp, index = 0;
index < num_this_level; index++, cp0 += 4, cp1++) {
*cp1 = TREEMAX(cp0);
}
}
return (*cp);
} | false | false | false | false | false | 0 |
selectCommand(redisClient *c) {
int id = atoi(c->argv[1]->ptr);
if (selectDb(c,id) == REDIS_ERR) {
addReplyError(c,"invalid DB index");
} else {
addReply(c,shared.ok);
}
} | false | false | false | false | false | 0 |
filteredUri( const KUrl &uri, const QStringList& filters )
{
KUriFilterData data(uri);
filterUri( data, filters );
return data.uri();
} | false | false | false | false | false | 0 |
uv_tcp_getpeername(uv_tcp_t* handle, struct sockaddr* name,
int* namelen) {
socklen_t socklen;
int saved_errno;
int rv = 0;
/* Don't clobber errno. */
saved_errno = errno;
if (handle->delayed_error) {
uv__set_sys_error(handle->loop, handle->delayed_error);
rv = -1;
goto out;
}
if (handle->fd < 0) {
uv__set_sys_error(handle->loop, EINVAL);
rv = -1;
goto out;
}
/* sizeof(socklen_t) != sizeof(int) on some systems. */
socklen = (socklen_t)*namelen;
if (getpeername(handle->fd, name, &socklen) == -1) {
uv__set_sys_error(handle->loop, errno);
rv = -1;
} else {
*namelen = (int)socklen;
}
out:
errno = saved_errno;
return rv;
} | false | false | false | false | false | 0 |
hashsig_add_hashes(
git_hashsig *sig,
const char *data,
size_t size,
hashsig_in_progress *prog)
{
const char *scan = data, *end = data + size;
hashsig_state state, shift_n, rmv;
if (prog->win_len < HASHSIG_HASH_WINDOW)
hashsig_initial_window(sig, &scan, size, prog);
state = prog->state;
shift_n = prog->shift_n;
/* advance window, adding new chars and removing old */
for (; scan < end; ++scan) {
char ch = *scan;
if (!hashsig_include_char(ch, sig->opt, &prog->saw_lf))
continue;
rmv = shift_n * prog->window[prog->win_pos];
state = (state - rmv) & HASHSIG_HASH_MASK;
state = (state * HASHSIG_HASH_SHIFT) & HASHSIG_HASH_MASK;
state = (state + ch) & HASHSIG_HASH_MASK;
hashsig_heap_insert(&sig->mins, (hashsig_t)state);
hashsig_heap_insert(&sig->maxs, (hashsig_t)state);
sig->considered++;
prog->window[prog->win_pos] = ch;
prog->win_pos = (prog->win_pos + 1) % HASHSIG_HASH_WINDOW;
}
prog->state = state;
return 0;
} | false | false | false | false | false | 0 |
autohelperowl_attackpat68(int trans, int move, int color, int action)
{
int a, b, c, A;
UNUSED(color);
UNUSED(action);
a = AFFINE_TRANSFORM(610, trans, move);
b = AFFINE_TRANSFORM(685, trans, move);
c = AFFINE_TRANSFORM(720, trans, move);
A = AFFINE_TRANSFORM(721, trans, move);
return (somewhere(OTHER_COLOR(color), 0, 1, a) || ! safe_move(a, color)) && !play_attack_defend_n(OTHER_COLOR(color), 0, 3, move, b, c, A);
} | false | false | false | false | false | 0 |
intel_th_output_attributes(struct gth_device *gth)
{
struct output_attribute *out_attrs;
struct attribute **attrs;
int i, j, nouts = TH_POSSIBLE_OUTPUTS;
int nparms = ARRAY_SIZE(output_parms);
int nattrs = nouts * nparms + 1;
attrs = devm_kcalloc(gth->dev, nattrs, sizeof(void *), GFP_KERNEL);
if (!attrs)
return -ENOMEM;
out_attrs = devm_kcalloc(gth->dev, nattrs,
sizeof(struct output_attribute),
GFP_KERNEL);
if (!out_attrs)
return -ENOMEM;
for (i = 0; i < nouts; i++) {
for (j = 0; j < nparms; j++) {
unsigned int idx = i * nparms + j;
char *name;
name = devm_kasprintf(gth->dev, GFP_KERNEL, "%d_%s", i,
output_parms[j].name);
if (!name)
return -ENOMEM;
out_attrs[idx].attr.attr.name = name;
if (output_parms[j].readable) {
out_attrs[idx].attr.attr.mode |= S_IRUGO;
out_attrs[idx].attr.show = output_attr_show;
}
if (output_parms[j].writable) {
out_attrs[idx].attr.attr.mode |= S_IWUSR;
out_attrs[idx].attr.store = output_attr_store;
}
sysfs_attr_init(&out_attrs[idx].attr.attr);
attrs[idx] = &out_attrs[idx].attr.attr;
out_attrs[idx].gth = gth;
out_attrs[idx].port = i;
out_attrs[idx].parm = j;
}
}
gth->output_group.name = "outputs";
gth->output_group.attrs = attrs;
return sysfs_create_group(>h->dev->kobj, >h->output_group);
} | false | false | false | false | false | 0 |
obj_add_collider(int obj_index)
{
object *objp = &Objects[obj_index];
#ifdef OBJECT_CHECK
CheckObjects[obj_index].type = objp->type;
CheckObjects[obj_index].signature = objp->signature;
CheckObjects[obj_index].flags = objp->flags & ~(OF_NOT_IN_COLL);
CheckObjects[obj_index].parent_sig = objp->parent_sig;
CheckObjects[obj_index].parent_type = objp->parent_type;
#endif
if(!(objp->flags & OF_NOT_IN_COLL)){
return;
}
Collision_sort_list.push_back(obj_index);
objp->flags &= ~OF_NOT_IN_COLL;
} | false | false | false | false | false | 0 |
_local_create_dummy(localobject *self)
{
PyObject *tdict, *ldict = NULL, *wr = NULL;
localdummyobject *dummy = NULL;
int r;
tdict = PyThreadState_GetDict();
if (tdict == NULL) {
PyErr_SetString(PyExc_SystemError,
"Couldn't get thread-state dictionary");
goto err;
}
ldict = PyDict_New();
if (ldict == NULL)
goto err;
dummy = (localdummyobject *) localdummytype.tp_alloc(&localdummytype, 0);
if (dummy == NULL)
goto err;
dummy->localdict = ldict;
wr = PyWeakref_NewRef((PyObject *) dummy, self->wr_callback);
if (wr == NULL)
goto err;
/* As a side-effect, this will cache the weakref's hash before the
dummy gets deleted */
r = PyDict_SetItem(self->dummies, wr, ldict);
if (r < 0)
goto err;
Py_CLEAR(wr);
r = PyDict_SetItem(tdict, self->key, (PyObject *) dummy);
if (r < 0)
goto err;
Py_CLEAR(dummy);
Py_DECREF(ldict);
return ldict;
err:
Py_XDECREF(ldict);
Py_XDECREF(wr);
Py_XDECREF(dummy);
return NULL;
} | false | false | false | false | false | 0 |
doProcessSimple(bool &outThereIsObservation, CObservation2DRangeScan &outObservation, bool &hardwareError)
{
if(!m_turnedOn)
{
hardwareError = true;
outThereIsObservation = false;
return;
}
hardwareError = false;
char msg[] = {"sRN LMDscandata"};
sendCommand(msg);
char buffIn[16*1024];
//size_t read = m_client.readAsync(buffIn, sizeof(buffIn), 100, 100);
//cout << "read :" << read << endl;
//while(m_client.readAsync(buffIn, sizeof(buffIn), 100, 100)) cout << "Lit dans le vent" << endl;
m_client.readAsync(buffIn, sizeof(buffIn), 40, 40);
if(decodeScan(buffIn, outObservation))
{
// Do filter:
C2DRangeFinderAbstract::filterByExclusionAreas( outObservation );
C2DRangeFinderAbstract::filterByExclusionAngles( outObservation );
// Do show preview:
C2DRangeFinderAbstract::processPreview(outObservation);
outThereIsObservation = true;
hardwareError = false;
}else
{
hardwareError = true;
outThereIsObservation = false;
printf_debug("doProcessSimple failed\n");
}
} | false | false | false | false | false | 0 |
gzrewind ()
{
z_err = Z_OK;
z_eof = 0;
stream.avail_in = 0;
stream.next_in = inbuf;
crc = crc32(0L, Z_NULL, 0);
if (!transparent) (void)inflateReset(&stream);
in = 0;
out = 0;
return VSIFSeekL((VSILFILE*)poBaseHandle, startOff, SEEK_SET);
} | false | false | false | false | false | 0 |
expand_items()
{
maxitems += 300;
pitem = (bucket **) REALLOC(pitem, maxitems*sizeof(bucket *));
if (pitem == 0) no_space();
} | false | false | false | false | false | 0 |
get_tinfo_decl (tree type)
{
tree name;
tree d;
if (variably_modified_type_p (type, /*fn=*/NULL_TREE))
{
error ("cannot create type information for type %qT because "
"it involves types of variable size",
type);
return error_mark_node;
}
if (TREE_CODE (type) == METHOD_TYPE)
type = build_function_type (TREE_TYPE (type),
TREE_CHAIN (TYPE_ARG_TYPES (type)));
type = complete_type (type);
/* For a class type, the variable is cached in the type node
itself. */
if (CLASS_TYPE_P (type))
{
d = CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type));
if (d)
return d;
}
name = mangle_typeinfo_for_type (type);
d = IDENTIFIER_GLOBAL_VALUE (name);
if (!d)
{
int ix = get_pseudo_ti_index (type);
tinfo_s *ti = &(*tinfo_descs)[ix];
d = build_lang_decl (VAR_DECL, name, ti->type);
SET_DECL_ASSEMBLER_NAME (d, name);
/* Remember the type it is for. */
TREE_TYPE (name) = type;
DECL_TINFO_P (d) = 1;
DECL_ARTIFICIAL (d) = 1;
DECL_IGNORED_P (d) = 1;
TREE_READONLY (d) = 1;
TREE_STATIC (d) = 1;
/* Mark the variable as undefined -- but remember that we can
define it later if we need to do so. */
DECL_EXTERNAL (d) = 1;
DECL_NOT_REALLY_EXTERN (d) = 1;
set_linkage_according_to_type (type, d);
d = pushdecl_top_level_and_finish (d, NULL_TREE);
if (CLASS_TYPE_P (type))
CLASSTYPE_TYPEINFO_VAR (TYPE_MAIN_VARIANT (type)) = d;
/* Add decl to the global array of tinfo decls. */
vec_safe_push (unemitted_tinfo_decls, d);
}
return d;
} | false | false | false | false | false | 0 |
GetRemoteEncoding( CString hubname, CString hubhost )
{
DCConfigHubProfile profile;
if ( GetBookmarkHubProfile( hubname, hubhost, &profile ) )
{
if ( profile.m_sRemoteEncoding.NotEmpty() )
{
return profile.m_sRemoteEncoding;
}
}
return m_sRemoteEncoding;
} | false | false | false | false | false | 0 |
subrip_prevwp_pr(const waypoint *waypointp)
{
/* Now that we have the next waypoint, we can write out the subtitle for
* the previous one.
*/
time_t starttime;
time_t endtime;
if (prevwpp->creation_time >= time_offset)
/* if this condition is not true, the waypoint is before the beginning of
* the video and will be ignored
*/
{
starttime = gps_to_video_time(prevwpp->creation_time);
if (!waypointp) {
endtime = starttime + 1;
} else {
endtime = gps_to_video_time(waypointp->creation_time);
}
gbfprintf(fout, "%d\n", stnum);
stnum++;
subrip_write_duration(starttime, endtime);
if WAYPT_HAS(prevwpp, speed) {
gbfprintf(fout, "%d km/h",
(int)(MPS_TO_KPH(prevwpp->speed) + 0.5));
}
if (prevwpp->altitude != unknown_alt) {
if WAYPT_HAS(prevwpp, speed) {
gbfprintf(fout, ", ");
}
gbfprintf(fout, "%d m\n",
(int)(prevwpp->altitude + 0.5));
} else if WAYPT_HAS(prevwpp, speed) {
gbfprintf(fout, "\n");
}
subrip_write_time(prevwpp->creation_time);
gbfprintf(fout, " Lat=%0.5lf Lon=%0.5lf\n",
prevwpp->latitude + .000005,
prevwpp->longitude + .000005);
gbfprintf(fout, "\n");
}
} | false | false | false | false | false | 0 |
eio_monitor_add(const char *path)
{
const char *tmp;
Eio_Monitor *ret;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
tmp = eina_stringshare_add(path);
ret = eio_monitor_stringshared_add(tmp);
eina_stringshare_del(tmp);
return ret;
} | false | false | false | false | false | 0 |
reparse_options ( int argc, char **argv, struct command_descriptor *cmd,
void *opts ) {
struct option longopts[ cmd->num_options + 1 /* help */ + 1 /* end */ ];
char shortopts[ cmd->num_options * 3 /* possible "::" */ + 1 /* "h" */
+ 1 /* NUL */ ];
unsigned int shortopt_idx = 0;
int ( * parse ) ( char *text, void *value );
void *value;
unsigned int i;
unsigned int j;
unsigned int num_args;
int c;
int rc;
/* Construct long and short option lists for getopt_long() */
memset ( longopts, 0, sizeof ( longopts ) );
for ( i = 0 ; i < cmd->num_options ; i++ ) {
longopts[i].name = cmd->options[i].longopt;
longopts[i].has_arg = cmd->options[i].has_arg;
longopts[i].val = cmd->options[i].shortopt;
shortopts[shortopt_idx++] = cmd->options[i].shortopt;
assert ( cmd->options[i].has_arg <= optional_argument );
for ( j = cmd->options[i].has_arg ; j > 0 ; j-- )
shortopts[shortopt_idx++] = ':';
}
longopts[i].name = "help";
longopts[i].val = 'h';
shortopts[shortopt_idx++] = 'h';
shortopts[shortopt_idx++] = '\0';
assert ( shortopt_idx <= sizeof ( shortopts ) );
DBGC ( cmd, "Command \"%s\" has options \"%s\", %d-%d args, len %d\n",
argv[0], shortopts, cmd->min_args, cmd->max_args, cmd->len );
/* Parse options */
while ( ( c = getopt_long ( argc, argv, shortopts, longopts,
NULL ) ) >= 0 ) {
switch ( c ) {
case 'h' :
/* Print help */
print_usage ( cmd, argv );
return -ECANCELED_NO_OP;
case '?' :
/* Print usage message */
print_usage ( cmd, argv );
return -EINVAL_UNKNOWN_OPTION;
case ':' :
/* Print usage message */
print_usage ( cmd, argv );
return -EINVAL_MISSING_ARGUMENT;
default:
/* Search for an option to parse */
for ( i = 0 ; i < cmd->num_options ; i++ ) {
if ( c != cmd->options[i].shortopt )
continue;
parse = cmd->options[i].parse;
value = ( opts + cmd->options[i].offset );
if ( ( rc = parse ( optarg, value ) ) != 0 )
return rc;
break;
}
assert ( i < cmd->num_options );
}
}
/* Check remaining arguments */
num_args = ( argc - optind );
if ( ( num_args < cmd->min_args ) || ( num_args > cmd->max_args ) ) {
print_usage ( cmd, argv );
return -ERANGE;
}
return 0;
} | true | true | false | false | true | 1 |
weak_key_compare(const ScmHashCore *hc, intptr_t key,
intptr_t entrykey)
{
ScmWeakHashTable *wh = SCM_WEAK_HASH_TABLE(hc->data);
ScmWeakBox *box = (ScmWeakBox *)entrykey;
intptr_t realkey = (intptr_t)Scm_WeakBoxRef(box);
if (Scm_WeakBoxEmptyP(box)) {
fprintf(stderr, "gang!\n");
return FALSE;
} else {
return wh->cmpfn(hc, key, realkey);
}
} | false | false | false | false | false | 0 |
fprintDoubleWithPrefix (FILE *f, double a, const char *fmt)
{
if (a >= 0.999999) {
fprintf (f,fmt,a);
return;
}
a *= 1000.0;
if (a >= 0.999999) {
fprintf (f,fmt,a);
fprintf (f,"m");
return;
}
a *= 1000.0;
if (a >= 0.999999) {
fprintf (f,fmt,a);
fprintf (f,"u");
return;
}
a *= 1000.0;
fprintf (f,fmt,a);
fprintf (f,"n");
} | false | false | false | false | false | 0 |
airo_open(struct net_device *dev) {
struct airo_info *ai = dev->ml_priv;
int rc = 0;
if (test_bit(FLAG_FLASHING, &ai->flags))
return -EIO;
/* Make sure the card is configured.
* Wireless Extensions may postpone config changes until the card
* is open (to pipeline changes and speed-up card setup). If
* those changes are not yet committed, do it now - Jean II */
if (test_bit(FLAG_COMMIT, &ai->flags)) {
disable_MAC(ai, 1);
writeConfigRid(ai, 1);
}
if (ai->wifidev != dev) {
clear_bit(JOB_DIE, &ai->jobs);
ai->airo_thread_task = kthread_run(airo_thread, dev, "%s",
dev->name);
if (IS_ERR(ai->airo_thread_task))
return (int)PTR_ERR(ai->airo_thread_task);
rc = request_irq(dev->irq, airo_interrupt, IRQF_SHARED,
dev->name, dev);
if (rc) {
airo_print_err(dev->name,
"register interrupt %d failed, rc %d",
dev->irq, rc);
set_bit(JOB_DIE, &ai->jobs);
kthread_stop(ai->airo_thread_task);
return rc;
}
/* Power on the MAC controller (which may have been disabled) */
clear_bit(FLAG_RADIO_DOWN, &ai->flags);
enable_interrupts(ai);
try_auto_wep(ai);
}
enable_MAC(ai, 1);
netif_start_queue(dev);
return 0;
} | false | false | false | false | false | 0 |
setFullScreen (bool fullScreen)
{
setBooleanValue ("screen", "fullscreen", fullScreen);
} | false | false | false | false | false | 0 |
read_metadata_info_ready_cb (GList *files,
GError *error,
gpointer user_data)
{
ReadMetadataOpData *read_metadata = user_data;
GthFileData *result;
GFile *gio_file;
if (error != NULL) {
read_metadata->callback (G_OBJECT (read_metadata->file_source), error, read_metadata->data);
read_metadata_free (read_metadata);
return;
}
result = files->data;
g_file_info_copy_into (result->info, read_metadata->file_data->info);
update_file_info (read_metadata->file_source, read_metadata->file_data->file, read_metadata->file_data->info);
gio_file = gth_catalog_file_to_gio_file (read_metadata->file_data->file);
gth_catalog_load_from_file_async (gio_file,
gth_file_source_get_cancellable (read_metadata->file_source),
read_metadata_catalog_ready_cb,
read_metadata);
g_object_unref (gio_file);
} | false | false | false | false | false | 0 |
led_exit(void)
{
unsigned int i;
for (i = 0; i < TPACPI_LED_NUMLEDS; i++) {
if (tpacpi_leds[i].led_classdev.name)
led_classdev_unregister(&tpacpi_leds[i].led_classdev);
}
flush_workqueue(tpacpi_wq);
kfree(tpacpi_leds);
} | false | false | false | false | false | 0 |
h_endcritical(OMPragma* p, ostream& os) {
OMPRegion* r = RTop(p);
int n = RExit(p);
if ( p->name[0] != '$' ) {
string cname = p->find_sub_name();
if ( cname != r->sub_name ) {
cerr << infile << ":" << r->begin_first_line
<< ": ERROR: missing end critical(" << r->sub_name
<< ") directive\n";
cerr << infile << ":" << p->lineno
<< ": ERROR: non-matching end critical(" << cname
<< ") directive\n";
cleanup_and_exit();
}
}
generate_call("end", "critical", n, os);
print_pragma(p, os);
generate_call("exit", "critical", n, os);
if ( keepSrcInfo ) reset_src_info(p, os);
} | false | false | false | false | false | 0 |
empty_msg_lists(void)
{
Msg *msg;
#ifndef NO_WAP
if (gwlist_len(incoming_wdp) > 0 || gwlist_len(outgoing_wdp) > 0)
warning(0, "Remaining WDP: %ld incoming, %ld outgoing",
gwlist_len(incoming_wdp), gwlist_len(outgoing_wdp));
info(0, "Total WDP messages: received %ld, sent %ld",
counter_value(incoming_wdp_counter),
counter_value(outgoing_wdp_counter));
#endif
while ((msg = gwlist_extract_first(incoming_wdp)) != NULL)
msg_destroy(msg);
while ((msg = gwlist_extract_first(outgoing_wdp)) != NULL)
msg_destroy(msg);
gwlist_destroy(incoming_wdp, NULL);
gwlist_destroy(outgoing_wdp, NULL);
counter_destroy(incoming_wdp_counter);
counter_destroy(outgoing_wdp_counter);
#ifndef NO_SMS
/* XXX we should record these so that they are not forever lost... */
if (gwlist_len(incoming_sms) > 0 || gwlist_len(outgoing_sms) > 0)
debug("bb", 0, "Remaining SMS: %ld incoming, %ld outgoing",
gwlist_len(incoming_sms), gwlist_len(outgoing_sms));
info(0, "Total SMS messages: received %ld, sent %ld",
counter_value(incoming_sms_counter),
counter_value(outgoing_sms_counter));
#endif
gwlist_destroy(incoming_sms, msg_destroy_item);
gwlist_destroy(outgoing_sms, msg_destroy_item);
counter_destroy(incoming_sms_counter);
counter_destroy(outgoing_sms_counter);
load_destroy(incoming_sms_load);
load_destroy(outgoing_sms_load);
} | false | false | false | false | false | 0 |
afr_sh_entry_impunge_subvol (call_frame_t *frame, xlator_t *this)
{
afr_private_t *priv = NULL;
afr_local_t *local = NULL;
afr_self_heal_t *sh = NULL;
int32_t active_src = 0;
priv = this->private;
local = frame->local;
sh = &local->self_heal;
active_src = sh->active_source;
gf_log (this->name, GF_LOG_DEBUG, "%s: readdir from offset %zd",
local->loc.path, sh->offset);
STACK_WIND (frame, afr_sh_entry_impunge_readdir_cbk,
priv->children[active_src],
priv->children[active_src]->fops->readdirp,
sh->healing_fd, sh->block_size, sh->offset, NULL);
return 0;
} | false | false | false | false | false | 0 |
mul(const char *endpoint, const char *soap_action, double a, double b, double &result)
{ struct soap *soap = this;
struct ns2__mul soap_tmp_ns2__mul;
struct ns2__mulResponse *soap_tmp_ns2__mulResponse;
if (endpoint)
soap_endpoint = endpoint;
if (soap_endpoint == NULL)
soap_endpoint = "http://websrv.cs.fsu.edu/~engelen/calcserver.cgi";
if (soap_action == NULL)
soap_action = "";
soap_begin(soap);
soap->encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/";
soap_tmp_ns2__mul.a = a;
soap_tmp_ns2__mul.b = b;
soap_serializeheader(soap);
soap_serialize_ns2__mul(soap, &soap_tmp_ns2__mul);
if (soap_begin_count(soap))
return soap->error;
if (soap->mode & SOAP_IO_LENGTH)
{ if (soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put_ns2__mul(soap, &soap_tmp_ns2__mul, "ns2:mul", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap))
return soap->error;
}
if (soap_end_count(soap))
return soap->error;
if (soap_connect(soap, soap_url(soap, soap_endpoint, NULL), soap_action)
|| soap_envelope_begin_out(soap)
|| soap_putheader(soap)
|| soap_body_begin_out(soap)
|| soap_put_ns2__mul(soap, &soap_tmp_ns2__mul, "ns2:mul", NULL)
|| soap_body_end_out(soap)
|| soap_envelope_end_out(soap)
|| soap_end_send(soap))
return soap_closesock(soap);
if (!&result)
return soap_closesock(soap);
soap_default_double(soap, &result);
if (soap_begin_recv(soap)
|| soap_envelope_begin_in(soap)
|| soap_recv_header(soap)
|| soap_body_begin_in(soap))
return soap_closesock(soap);
if (soap_recv_fault(soap, 1))
return soap->error;
soap_tmp_ns2__mulResponse = soap_get_ns2__mulResponse(soap, NULL, "", "");
if (!soap_tmp_ns2__mulResponse || soap->error)
return soap_recv_fault(soap, 0);
if (soap_body_end_in(soap)
|| soap_envelope_end_in(soap)
|| soap_end_recv(soap))
return soap_closesock(soap);
result = soap_tmp_ns2__mulResponse->result;
return soap_closesock(soap);
} | false | false | false | false | false | 0 |
check_base(char chr,long position, int direction) {
if (direction < 0) position --;
if (position <0 && position >= seq_len) return new AD_ERR();
if (seq[position] != chr){
return new AD_ERR(); // beep beep
}
return 0;
} | false | false | false | false | false | 0 |
zr36050_control (struct videocodec *codec,
int type,
int size,
void *data)
{
struct zr36050 *ptr = (struct zr36050 *) codec->data;
int *ival = (int *) data;
dprintk(2, "%s: control %d call with %d byte\n", ptr->name, type,
size);
switch (type) {
case CODEC_G_STATUS: /* get last status */
if (size != sizeof(int))
return -EFAULT;
zr36050_read_status1(ptr);
*ival = ptr->status1;
break;
case CODEC_G_CODEC_MODE:
if (size != sizeof(int))
return -EFAULT;
*ival = CODEC_MODE_BJPG;
break;
case CODEC_S_CODEC_MODE:
if (size != sizeof(int))
return -EFAULT;
if (*ival != CODEC_MODE_BJPG)
return -EINVAL;
/* not needed, do nothing */
return 0;
case CODEC_G_VFE:
case CODEC_S_VFE:
/* not needed, do nothing */
return 0;
case CODEC_S_MMAP:
/* not available, give an error */
return -ENXIO;
case CODEC_G_JPEG_TDS_BYTE: /* get target volume in byte */
if (size != sizeof(int))
return -EFAULT;
*ival = ptr->total_code_vol;
break;
case CODEC_S_JPEG_TDS_BYTE: /* get target volume in byte */
if (size != sizeof(int))
return -EFAULT;
ptr->total_code_vol = *ival;
/* (Kieran Morrissey)
* code copied from zr36060.c to ensure proper bitrate */
ptr->real_code_vol = (ptr->total_code_vol * 6) >> 3;
break;
case CODEC_G_JPEG_SCALE: /* get scaling factor */
if (size != sizeof(int))
return -EFAULT;
*ival = zr36050_read_scalefactor(ptr);
break;
case CODEC_S_JPEG_SCALE: /* set scaling factor */
if (size != sizeof(int))
return -EFAULT;
ptr->scalefact = *ival;
break;
case CODEC_G_JPEG_APP_DATA: { /* get appn marker data */
struct jpeg_app_marker *app = data;
if (size != sizeof(struct jpeg_app_marker))
return -EFAULT;
*app = ptr->app;
break;
}
case CODEC_S_JPEG_APP_DATA: { /* set appn marker data */
struct jpeg_app_marker *app = data;
if (size != sizeof(struct jpeg_app_marker))
return -EFAULT;
ptr->app = *app;
break;
}
case CODEC_G_JPEG_COM_DATA: { /* get comment marker data */
struct jpeg_com_marker *com = data;
if (size != sizeof(struct jpeg_com_marker))
return -EFAULT;
*com = ptr->com;
break;
}
case CODEC_S_JPEG_COM_DATA: { /* set comment marker data */
struct jpeg_com_marker *com = data;
if (size != sizeof(struct jpeg_com_marker))
return -EFAULT;
ptr->com = *com;
break;
}
default:
return -EINVAL;
}
return size;
} | false | false | false | false | false | 0 |
closeGraph(graph_t * cg)
{
node_t *n;
for (n = agfstnode(cg); n; n = agnxtnode(cg, n)) {
free_list(ND_in(n));
free_list(ND_out(n));
}
agclose(cg);
} | false | false | false | false | false | 0 |
setParms(float c, float b, float g)
{
double x0, y0, x1, y1;
double startX, startY, endX, endY;
currContrast = (c < -1.0) ? -1.0:c;
currBrightness = b;
currGamma = g;
computeEndPoints(x0, y0, x1, y1);
findExtremes(x0, y0, x1, y1,
&startX, &startY,
&endX, &endY);
// This is temporary until we find the time of implementing
// separate transfer function controls for R, G and B
gammas[0] = gammas[1] = gammas[2] = g;
leftX[0] = leftX[1] = leftX[2] = startX;
leftY[0] = leftY[1] = leftY[2] = startY;
rightX[0] = rightX[1] = rightX[2] = endX;
rightY[0] = rightY[1] = rightY[2] = endY;
// this will update the image if need be,
// and will put the right numbers in the input widget fields
buildFunction(x0, y0, x1, y1);
redraw();
return;
} | false | false | false | false | false | 0 |
dns_mnemonic_totext(unsigned int value, isc_buffer_t *target,
struct tbl *table)
{
int i = 0;
char buf[sizeof("4294967296")];
while (table[i].name != NULL) {
if (table[i].value == value) {
return (str_totext(table[i].name, target));
}
i++;
}
snprintf(buf, sizeof(buf), "%u", value);
return (str_totext(buf, target));
} | true | true | false | false | false | 1 |
cut_diff_writer_write_character_n_times (CutDiffWriter *writer,
gchar character,
guint n,
CutDiffWriterTag tag)
{
GString *string;
guint i;
string = g_string_new(NULL);
for (i = 0; i < n; i++) {
g_string_append_c(string, character);
}
cut_diff_writer_write(writer, string->str, tag);
g_string_free(string, TRUE);
} | false | false | false | false | false | 0 |
GetNextWord(Accessor &styler, unsigned int start, char *s, size_t sLen) {
unsigned int i = 0;
for (; i < sLen-1; i++) {
char ch = static_cast<char>(styler.SafeGetCharAt(start + i));
if ((i == 0) && !IsAWordStart(ch))
break;
if ((i > 0) && !IsAWordChar(ch))
break;
s[i] = ch;
}
s[i] = '\0';
return s;
} | false | false | false | false | false | 0 |
blr_ebl(const char *cc, const char *suffix, char *separator, int sep_len, char* apex, int apex_len)
{
struct ebl_context context;
char domain[128] = "";
char *p1,*p2;
int ret;
ast_mutex_lock(&enumlock);
ast_verb(4, "blr_ebl() cc='%s', suffix='%s', c_bl='%s'\n", cc, suffix, ienum_branchlabel);
if (sizeof(domain) < (strlen(cc) * 2 + strlen(ienum_branchlabel) + strlen(suffix) + 2)) {
ast_mutex_unlock(&enumlock);
ast_log(LOG_WARNING, "ERROR: string sizing in blr_EBL.\n");
return -1;
}
p1 = domain + snprintf(domain, sizeof(domain), "%s.", ienum_branchlabel);
ast_mutex_unlock(&enumlock);
for (p2 = (char *) cc + strlen(cc) - 1; p2 >= cc; p2--) {
if (isdigit(*p2)) {
*p1++ = *p2;
*p1++ = '.';
}
}
strcat(p1, suffix);
ast_verb(4, "blr_ebl() FQDN for EBL record: %s, cc was %s\n", domain, cc);
ret = ast_search_dns(&context, domain, C_IN, T_EBL, ebl_callback);
if (ret > 0) {
ret = context.pos;
if ((ret >= 0) && (ret < 20)) {
ast_verb(3, "blr_txt() BLR EBL record for %s is %d/%s/%s)\n", cc, ret, context.separator, context.apex);
ast_copy_string(separator, context.separator, sep_len);
ast_copy_string(apex, context.apex, apex_len);
return ret;
}
}
ast_verb(3, "blr_txt() BLR EBL record for %s not found (apex: %s)\n", cc, suffix);
return -1;
} | true | true | false | false | false | 1 |
cf_section_alloc(const char *name1, const char *name2,
CONF_SECTION *parent)
{
size_t name1_len, name2_len = 0;
char *p;
CONF_SECTION *cs;
if (!name1) return NULL;
name1_len = strlen(name1) + 1;
if (name2) name2_len = strlen(name2) + 1;
p = rad_malloc(sizeof(*cs) + name1_len + name2_len);
cs = (CONF_SECTION *) p;
memset(cs, 0, sizeof(*cs));
cs->item.type = CONF_ITEM_SECTION;
cs->item.parent = parent;
p += sizeof(*cs);
memcpy(p, name1, name1_len);
cs->name1 = p;
if (name2 && *name2) {
p += name1_len;
memcpy(p, name2, name2_len);
cs->name2 = p;
}
cs->pair_tree = rbtree_create(pair_cmp, NULL, 0);
if (!cs->pair_tree) {
cf_section_free(&cs);
return NULL;
}
/*
* Don't create a data tree, it may not be needed.
*/
/*
* Don't create the section tree here, it may not
* be needed.
*/
if (parent) cs->depth = parent->depth + 1;
return cs;
} | false | false | false | false | false | 0 |
buildin_setdragon(struct script_state *st)
{
int type = 0;
if( st->end > st->start+2 )
type = conv_num(st,& (st->stack->stack_data[st->start+2]));
pc_setdragon( script_rid2sd(st), type );
return 0;
} | false | false | false | false | false | 0 |
ids_sasl_mech_supported(Slapi_PBlock *pb, const char *mech)
{
int i, ret = 0;
char **mechs;
char *dupstr;
const char *str;
int sasl_result = 0;
sasl_conn_t *sasl_conn = (sasl_conn_t *)pb->pb_conn->c_sasl_conn;
LDAPDebug( LDAP_DEBUG_TRACE, "=> ids_sasl_mech_supported\n", 0, 0, 0 );
/* sasl_listmech is not thread-safe - caller must lock pb_conn */
sasl_result = sasl_listmech(sasl_conn,
NULL, /* username */
"", ",", "",
&str, NULL, NULL);
if (sasl_result != SASL_OK) {
return 0;
}
dupstr = slapi_ch_strdup(str);
mechs = slapi_str2charray(dupstr, ",");
for (i = 0; mechs[i] != NULL; i++) {
if (strcasecmp(mech, mechs[i]) == 0) {
ret = 1;
break;
}
}
charray_free(mechs);
slapi_ch_free((void**)&dupstr);
LDAPDebug( LDAP_DEBUG_TRACE, "<= ids_sasl_mech_supported\n", 0, 0, 0 );
return ret;
} | false | false | false | false | false | 0 |
zval_scan(zval *pz TSRMLS_DC)
{
Bucket *p;
tail_call:
if (GC_ZVAL_GET_COLOR(pz) == GC_GREY) {
p = NULL;
if (pz->refcount__gc > 0) {
zval_scan_black(pz TSRMLS_CC);
} else {
GC_ZVAL_SET_COLOR(pz, GC_WHITE);
if (Z_TYPE_P(pz) == IS_OBJECT && EG(objects_store).object_buckets) {
zend_object_get_gc_t get_gc;
struct _store_object *obj = &EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].bucket.obj;
if (GC_GET_COLOR(obj->buffered) == GC_GREY) {
if (obj->refcount > 0) {
zobj_scan_black(obj, pz TSRMLS_CC);
} else {
GC_SET_COLOR(obj->buffered, GC_WHITE);
if (EXPECTED(EG(objects_store).object_buckets[Z_OBJ_HANDLE_P(pz)].valid &&
(get_gc = Z_OBJ_HANDLER_P(pz, get_gc)) != NULL)) {
int i, n;
zval **table;
HashTable *props = get_gc(pz, &table, &n TSRMLS_CC);
while (n > 0 && !table[n-1]) n--;
for (i = 0; i < n; i++) {
if (table[i]) {
pz = table[i];
if (!props && i == n - 1) {
goto tail_call;
} else {
zval_scan(pz TSRMLS_CC);
}
}
}
if (!props) {
return;
}
p = props->pListHead;
}
}
}
} else if (Z_TYPE_P(pz) == IS_ARRAY) {
if (Z_ARRVAL_P(pz) == &EG(symbol_table)) {
GC_ZVAL_SET_BLACK(pz);
} else {
p = Z_ARRVAL_P(pz)->pListHead;
}
}
}
while (p != NULL) {
if (p->pListNext == NULL) {
pz = *(zval**)p->pData;
goto tail_call;
} else {
zval_scan(*(zval**)p->pData TSRMLS_CC);
}
p = p->pListNext;
}
}
} | false | false | false | false | false | 0 |
charmap_string_to_mask(
int *ret, const char *string, charmap_t *table, char *errstring)
{
int len = strlen(string);
int error = 0;
int i;
*ret = 0;
for (i = 0; i < len; ++i)
{
int found_match;
int j;
char c;
c = tolower(string[i]);
for (j = 0, found_match = 0; table[j].key != 0; j++)
{
if (table[j].key == c)
{
*ret |= table[j].value;
found_match = 1;
break;
}
}
if (!found_match)
{
fputs("charmap_string_to_mask: ", stderr);
if (errstring != NULL)
{
fputs(errstring, stderr);
}
fputc(' ', stderr);
fputc(c, stderr);
fputc('\n', stderr);
error = 1;
}
}
return error;
} | false | false | false | false | false | 0 |
int8larger(PG_FUNCTION_ARGS)
{
int64 arg1 = PG_GETARG_INT64(0);
int64 arg2 = PG_GETARG_INT64(1);
int64 result;
result = ((arg1 > arg2) ? arg1 : arg2);
PG_RETURN_INT64(result);
} | false | false | false | false | false | 0 |
abraca_collections_view_on_cell_edited (AbracaCollectionsView* self, GtkCellRendererText* renderer, const gchar* path, const gchar* new_text) {
GtkTreeIter iter = {0};
gint type = 0;
gchar* name = NULL;
gchar* ns = NULL;
GtkTreeModel* _tmp0_;
GtkTreeModel* _tmp1_;
const gchar* _tmp2_;
GtkTreeIter _tmp3_ = {0};
GtkTreeModel* _tmp4_;
GtkTreeModel* _tmp5_;
GtkTreeIter _tmp6_;
gint _tmp7_;
AbracaClient* _tmp10_;
xmmsc_connection_t* _tmp11_;
xmmsc_connection_t* _tmp12_;
const gchar* _tmp13_;
const gchar* _tmp14_;
const gchar* _tmp15_;
xmmsc_result_t* _tmp16_ = NULL;
xmmsc_result_t* _tmp17_;
g_return_if_fail (self != NULL);
g_return_if_fail (renderer != NULL);
g_return_if_fail (path != NULL);
g_return_if_fail (new_text != NULL);
_tmp0_ = gtk_tree_view_get_model ((GtkTreeView*) self);
_tmp1_ = _tmp0_;
_tmp2_ = path;
gtk_tree_model_get_iter_from_string (_tmp1_, &_tmp3_, _tmp2_);
iter = _tmp3_;
_tmp4_ = gtk_tree_view_get_model ((GtkTreeView*) self);
_tmp5_ = _tmp4_;
_tmp6_ = iter;
gtk_tree_model_get (_tmp5_, &_tmp6_, ABRACA_COLLECTIONS_MODEL_COLUMN_Name, &name, ABRACA_COLLECTIONS_MODEL_COLUMN_Type, &type, -1);
_tmp7_ = type;
if (_tmp7_ == ((gint) ABRACA_COLLECTIONS_MODEL_COLLECTION_TYPE_Playlist)) {
gchar* _tmp8_;
_tmp8_ = g_strdup (XMMS_COLLECTION_NS_PLAYLISTS);
_g_free0 (ns);
ns = _tmp8_;
} else {
gchar* _tmp9_;
_tmp9_ = g_strdup (XMMS_COLLECTION_NS_COLLECTIONS);
_g_free0 (ns);
ns = _tmp9_;
}
_tmp10_ = self->priv->client;
_tmp11_ = abraca_client_get_xmms (_tmp10_);
_tmp12_ = _tmp11_;
_tmp13_ = name;
_tmp14_ = new_text;
_tmp15_ = ns;
_tmp16_ = xmmsc_coll_rename (_tmp12_, _tmp13_, _tmp14_, _tmp15_);
_tmp17_ = _tmp16_;
_xmmsc_result_unref0 (_tmp17_);
_g_free0 (ns);
_g_free0 (name);
} | false | false | false | false | false | 0 |
lDechainElem(lList *lp, lListElem *ep)
{
int i;
DENTER(CULL_LAYER, "lDechainElem");
if (!lp) {
LERROR(LELISTNULL);
DRETURN(NULL);
}
if (!ep) {
LERROR(LEELEMNULL);
DRETURN(NULL);
}
if (lp->descr != ep->descr) {
CRITICAL((SGE_EVENT,"Dechaining element from other list !!!"));
DEXIT;
abort();
}
if (ep->prev) {
ep->prev->next = ep->next;
}
else {
lp->first = ep->next;
}
if (ep->next) {
ep->next->prev = ep->prev;
}
else {
lp->last = ep->prev;
}
/* remove hash entries */
for(i = 0; mt_get_type(ep->descr[i].mt) != lEndT; i++) {
if(ep->descr[i].ht != NULL) {
cull_hash_remove(ep, i);
}
}
/* NULL the ep next and previous pointers */
ep->prev = ep->next = (lListElem *) NULL;
ep->descr = lCopyDescr(ep->descr);
ep->status = FREE_ELEM;
lp->nelem--;
lp->changed = true;
DRETURN(ep);
} | false | false | false | false | false | 0 |
homePath( const char *resource )
{
if ( qstrncmp( "data", resource, 4 ) == 0 ) {
if ( instance()->mDataHome.isEmpty() ) {
instance()->mDataHome = instance()->homePath( "XDG_DATA_HOME", ".local/share" );
}
return instance()->mDataHome;
} else if ( qstrncmp( "config", resource, 6 ) == 0 ) {
if ( instance()->mConfigHome.isEmpty() ) {
instance()->mConfigHome = instance()->homePath( "XDG_CONFIG_HOME", ".config" );
}
return instance()->mConfigHome;
}
return QString();
} | false | false | false | false | false | 0 |
do_selection(int fd, unsigned int set_selection, struct v4l2_selection &vsel,
v4l2_buf_type type)
{
struct v4l2_selection in_selection;
in_selection.type = type;
in_selection.target = vsel.target;
if (doioctl(fd, VIDIOC_G_SELECTION, &in_selection) == 0) {
if (set_selection & SelectionWidth)
in_selection.r.width = vsel.r.width;
if (set_selection & SelectionHeight)
in_selection.r.height = vsel.r.height;
if (set_selection & SelectionLeft)
in_selection.r.left = vsel.r.left;
if (set_selection & SelectionTop)
in_selection.r.top = vsel.r.top;
in_selection.flags = (set_selection & SelectionFlags) ? vsel.flags : 0;
doioctl(fd, VIDIOC_S_SELECTION, &in_selection);
}
} | false | false | false | false | false | 0 |
uprv_getPOSIXIDForCategory(int category)
{
const char* posixID = NULL;
if (category == LC_MESSAGES || category == LC_CTYPE) {
/*
* On Solaris two different calls to setlocale can result in
* different values. Only get this value once.
*
* We must check this first because an application can set this.
*
* LC_ALL can't be used because it's platform dependent. The LANG
* environment variable seems to affect LC_CTYPE variable by default.
* Here is what setlocale(LC_ALL, NULL) can return.
* HPUX can return 'C C C C C C C'
* Solaris can return /en_US/C/C/C/C/C on the second try.
* Linux can return LC_CTYPE=C;LC_NUMERIC=C;...
*
* The default codepage detection also needs to use LC_CTYPE.
*
* Do not call setlocale(LC_*, "")! Using an empty string instead
* of NULL, will modify the libc behavior.
*/
posixID = setlocale(category, NULL);
if ((posixID == 0)
|| (uprv_strcmp("C", posixID) == 0)
|| (uprv_strcmp("POSIX", posixID) == 0))
{
/* Maybe we got some garbage. Try something more reasonable */
posixID = getenv("LC_ALL");
if (posixID == 0) {
posixID = getenv(category == LC_MESSAGES ? "LC_MESSAGES" : "LC_CTYPE");
if (posixID == 0) {
posixID = getenv("LANG");
}
}
}
}
if ((posixID==0)
|| (uprv_strcmp("C", posixID) == 0)
|| (uprv_strcmp("POSIX", posixID) == 0))
{
/* Nothing worked. Give it a nice POSIX default value. */
posixID = "en_US_POSIX";
}
return posixID;
} | false | false | false | false | false | 0 |
filterEvent( XEvent* ev_P )
{
if( ev_P->type == ClientMessage )
{
// kDebug() << "got ClientMessage";
if( ev_P->xclient.message_type != Private::manager_atom
|| ev_P->xclient.data.l[ 1 ] != static_cast< long >( d->selection ))
return;
// kDebug() << "handling message";
if( static_cast< long >( owner()) == ev_P->xclient.data.l[ 2 ] )
{
// owner() emits newOwner() if needed, no need to do it twice
}
return;
}
if( ev_P->type == DestroyNotify )
{
if( d->selection_owner == None || ev_P->xdestroywindow.window != d->selection_owner )
return;
d->selection_owner = None; // in case the exactly same ID gets reused as the owner
if( owner() == None )
emit lostOwner(); // it must be safe to delete 'this' in a slot
return;
}
return;
} | false | false | false | false | false | 0 |
e_name_western_str_count_words (const gchar *str)
{
gint word_count;
const gchar *p;
word_count = 0;
for (p = str; p != NULL; p = g_utf8_strchr (p, -1, ' ')) {
word_count++;
p = g_utf8_next_char (p);
}
return word_count;
} | false | false | false | false | false | 0 |
qinstance_state_set_error(lListElem *this_elem, bool set_state)
{
bool changed;
DENTER(QINSTANCE_STATE_LAYER, "qinstance_state_set_error");
changed = qinstance_set_state(this_elem, set_state, QI_ERROR);
DRETURN(changed);
} | false | false | false | false | false | 0 |
OnChar()
{
switch (this->Interactor->GetKeyCode())
{
case 'r':
case 'R':
//r toggles the rubber band selection mode for mouse button 1
if (this->CurrentMode == VTKISRBP_ORIENT)
{
this->CurrentMode = VTKISRBP_SELECT;
}
else
{
this->CurrentMode = VTKISRBP_ORIENT;
}
break;
case 'p' :
case 'P' :
{
vtkRenderWindowInteractor *rwi = this->Interactor;
int *eventPos = rwi->GetEventPosition();
this->FindPokedRenderer(eventPos[0], eventPos[1]);
this->StartPosition[0] = eventPos[0];
this->StartPosition[1] = eventPos[1];
this->EndPosition[0] = eventPos[0];
this->EndPosition[1] = eventPos[1];
this->Pick();
break;
}
default:
this->Superclass::OnChar();
}
} | false | false | false | false | false | 0 |
avdtp_getcap_cmd(struct avdtp *session, uint8_t transaction,
struct seid_req *req, unsigned int size,
gboolean get_all)
{
GSList *l, *caps;
struct avdtp_local_sep *sep = NULL;
unsigned int rsp_size;
uint8_t err, buf[1024], *ptr = buf;
uint8_t cmd;
cmd = get_all ? AVDTP_GET_ALL_CAPABILITIES : AVDTP_GET_CAPABILITIES;
if (size < sizeof(struct seid_req)) {
err = AVDTP_BAD_LENGTH;
goto failed;
}
sep = find_local_sep_by_seid(session->server, req->acp_seid);
if (!sep) {
err = AVDTP_BAD_ACP_SEID;
goto failed;
}
if (get_all && session->server->version < 0x0103)
return avdtp_unknown_cmd(session, transaction, cmd);
if (!sep->ind->get_capability(session, sep, get_all, &caps,
&err, sep->user_data))
goto failed;
for (l = caps, rsp_size = 0; l != NULL; l = g_slist_next(l)) {
struct avdtp_service_capability *cap = l->data;
if (rsp_size + cap->length + 2 > sizeof(buf))
break;
memcpy(ptr, cap, cap->length + 2);
rsp_size += cap->length + 2;
ptr += cap->length + 2;
g_free(cap);
}
g_slist_free(caps);
return avdtp_send(session, transaction, AVDTP_MSG_TYPE_ACCEPT, cmd,
buf, rsp_size);
failed:
return avdtp_send(session, transaction, AVDTP_MSG_TYPE_REJECT, cmd,
&err, sizeof(err));
} | false | false | false | false | false | 0 |
sound_free_dma(int chn)
{
if (dma_alloc_map[chn] == DMA_MAP_UNAVAIL) {
/* printk( "sound_free_dma: Bad access to DMA channel %d\n", chn); */
return;
}
free_dma(chn);
dma_alloc_map[chn] = DMA_MAP_UNAVAIL;
} | false | false | false | false | false | 0 |
m_get_context(pIIR_AttrTypeFunc a, ContextInfo &ctxt, RegionStack &rstack,
bool target, int level)
{
pAccessDescriptor p = get_context(a->prefix, ctxt, rstack, false, level);
if (a->argument != NULL)
get_context(a->argument, ctxt, rstack, false, level + 1);
return p;
} | false | false | false | false | false | 0 |
oparray_cleanup(i_ctx_t *i_ctx_p)
{ /* esp points just below the cleanup procedure. */
es_ptr ep = esp;
uint ocount_old = (uint) ep[3].value.intval;
uint dcount_old = (uint) ep[4].value.intval;
uint ocount = ref_stack_count(&o_stack);
uint dcount = ref_stack_count(&d_stack);
if (ocount > ocount_old)
ref_stack_pop(&o_stack, ocount - ocount_old);
if (dcount > dcount_old) {
ref_stack_pop(&d_stack, dcount - dcount_old);
dict_set_top();
}
return 0;
} | false | false | false | false | false | 0 |
drag_data_received
(
GtkWidget *widget,
GdkDragContext *context,
gint x,
gint y,
GtkSelectionData *seldata,
guint info,
guint time,
gpointer udata // Should point to Shape_draw.
)
{
Chunk_chooser *chooser = (Chunk_chooser *) udata;
cout << "Chunk drag_data_received" << endl;
if (seldata->type == gdk_atom_intern(U7_TARGET_CHUNKID_NAME, 0) &&
seldata->format == 8 && seldata->length > 0)
{
int cnum;
Get_u7_chunkid(seldata->data, cnum);
chooser->group->add(cnum);
chooser->render();
// chooser->adjust_scrollbar(); ++++++Probably need to do this.
}
} | false | false | false | false | false | 0 |
ftp_init(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
struct FTP *ftp;
if(data->reqdata.proto.ftp)
return CURLE_OK;
ftp = (struct FTP *)calloc(sizeof(struct FTP), 1);
if(!ftp)
return CURLE_OUT_OF_MEMORY;
data->reqdata.proto.ftp = ftp;
/* get some initial data into the ftp struct */
ftp->bytecountp = &data->reqdata.keep.bytecount;
/* no need to duplicate them, this connectdata struct won't change */
ftp->user = conn->user;
ftp->passwd = conn->passwd;
if (isBadFtpString(ftp->user) || isBadFtpString(ftp->passwd))
return CURLE_URL_MALFORMAT;
return CURLE_OK;
} | false | false | false | false | false | 0 |
drawSquare(int index, const QColor &colour)
{
QBrush brush(colour, Qt::SolidPattern);
addRect(QRectF(qreal((index%width)*spacing), qreal((index/width)*spacing), qreal(spacing), qreal(spacing)), QPen(), brush)->setZValue(-1);
} | false | false | false | false | false | 0 |
g2_packet_clone(g2_packet_t *p)
{
g2_packet_t *t;
if(!p)
return p;
t = g2_packet_alloc();
if(!t)
return t;
*t = *p;
INIT_LIST_HEAD(&t->list);
INIT_LIST_HEAD(&t->children);
t->is_freeable = true;
return t;
} | false | false | false | false | false | 0 |
bna_rx_sm_stop_wait(struct bna_rx *rx, enum bna_rx_event event)
{
switch (event) {
case RX_E_FAIL:
case RX_E_STOPPED:
bfa_fsm_set_state(rx, bna_rx_sm_cleanup_wait);
rx->rx_cleanup_cbfn(rx->bna->bnad, rx);
break;
case RX_E_STARTED:
bna_rx_enet_stop(rx);
break;
default:
bfa_sm_fault(event);
break;
}
} | false | false | false | false | false | 0 |
isscalar(int idnumber) const
{
if (idnumber<nvars)
return (arraytype[idnumber]==scalar);
else
return -1;
} | false | false | false | false | false | 0 |
at76_probe(struct usb_interface *interface,
const struct usb_device_id *id)
{
int ret;
struct at76_priv *priv;
struct fwentry *fwe;
struct usb_device *udev;
int op_mode;
int need_ext_fw = 0;
struct mib_fw_version *fwv = NULL;
int board_type = (int)id->driver_info;
udev = usb_get_dev(interface_to_usbdev(interface));
fwv = kmalloc(sizeof(*fwv), GFP_KERNEL);
if (!fwv) {
ret = -ENOMEM;
goto exit;
}
/* Load firmware into kernel memory */
fwe = at76_load_firmware(udev, board_type);
if (!fwe) {
ret = -ENOENT;
goto exit;
}
op_mode = at76_get_op_mode(udev);
at76_dbg(DBG_DEVSTART, "opmode %d", op_mode);
/* we get OPMODE_NONE with 2.4.23, SMC2662W-AR ???
we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */
if (op_mode == OPMODE_HW_CONFIG_MODE) {
dev_err(&interface->dev,
"cannot handle a device in HW_CONFIG_MODE\n");
ret = -EBUSY;
goto exit;
}
if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH
&& op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) {
/* download internal firmware part */
dev_printk(KERN_DEBUG, &interface->dev,
"downloading internal firmware\n");
ret = at76_load_internal_fw(udev, fwe);
if (ret < 0) {
dev_err(&interface->dev,
"error %d downloading internal firmware\n",
ret);
goto exit;
}
usb_put_dev(udev);
goto exit;
}
/* Internal firmware already inside the device. Get firmware
* version to test if external firmware is loaded.
* This works only for newer firmware, e.g. the Intersil 0.90.x
* says "control timeout on ep0in" and subsequent
* at76_get_op_mode() fail too :-( */
/* if version >= 0.100.x.y or device with built-in flash we can
* query the device for the fw version */
if ((fwe->fw_version.major > 0 || fwe->fw_version.minor >= 100)
|| (op_mode == OPMODE_NORMAL_NIC_WITH_FLASH)) {
ret = at76_get_mib(udev, MIB_FW_VERSION, fwv, sizeof(*fwv));
if (ret < 0 || (fwv->major | fwv->minor) == 0)
need_ext_fw = 1;
} else
/* No way to check firmware version, reload to be sure */
need_ext_fw = 1;
if (need_ext_fw) {
dev_printk(KERN_DEBUG, &interface->dev,
"downloading external firmware\n");
ret = at76_load_external_fw(udev, fwe);
if (ret < 0)
goto exit;
/* Re-check firmware version */
ret = at76_get_mib(udev, MIB_FW_VERSION, fwv, sizeof(*fwv));
if (ret < 0) {
dev_err(&interface->dev,
"error %d getting firmware version\n", ret);
goto exit;
}
}
priv = at76_alloc_new_device(udev);
if (!priv) {
ret = -ENOMEM;
goto exit;
}
usb_set_intfdata(interface, priv);
memcpy(&priv->fw_version, fwv, sizeof(struct mib_fw_version));
priv->board_type = board_type;
ret = at76_init_new_device(priv, interface);
if (ret < 0)
at76_delete_device(priv);
exit:
kfree(fwv);
if (ret < 0)
usb_put_dev(udev);
return ret;
} | false | false | false | false | false | 0 |
amiga_state_save(int slot) {
if (slot < 0) {
return 0;
}
if (slot >= 9) {
return 0;
}
write_log("amiga_state_save %d\n", slot);
int code = AKS_STATESAVEQUICK1 + slot * 2;
inputdevice_add_inputcode(code, 1);
return 1;
} | false | false | false | false | false | 0 |
createTimeZone(const UnicodeString& ID)
{
/* We first try to lookup the zone ID in our system list. If this
* fails, we try to parse it as a custom string GMT[+-]hh:mm. If
* all else fails, we return GMT, which is probably not what the
* user wants, but at least is a functioning TimeZone object.
*
* We cannot return NULL, because that would break compatibility
* with the JDK.
*/
TimeZone* result = createSystemTimeZone(ID);
if (result == 0) {
U_DEBUG_TZ_MSG(("failed to load system time zone with id - falling to custom"));
result = createCustomTimeZone(ID);
}
if (result == 0) {
U_DEBUG_TZ_MSG(("failed to load time zone with id - falling to GMT"));
const TimeZone* temptz = getGMT();
if (temptz == NULL) {
result = NULL;
} else {
result = temptz->clone();
}
}
return result;
} | false | false | false | false | false | 0 |
vimoswcscominit (vimoswcs, i, command)
struct WorldCoor *vimoswcs; /* World coordinate system structure */
int i; /* Number of command (0-9) to initialize */
char *command; /* command with %s where coordinates will go */
{
int lcom,icom;
if (isvimoswcs(vimoswcs)) {
lcom = strlen (command);
if (lcom > 0) {
if (vimoswcs->command_format[i] != NULL)
free (vimoswcs->command_format[i]);
vimoswcs->command_format[i] = (char *) calloc (lcom+2, 1);
if (vimoswcs->command_format[i] == NULL)
return;
for (icom = 0; icom < lcom; icom++) {
if (command[icom] == '_')
vimoswcs->command_format[i][icom] = ' ';
else
vimoswcs->command_format[i][icom] = command[icom];
}
vimoswcs->command_format[i][lcom] = 0;
}
}
return;
} | false | false | false | false | false | 0 |
putIterationsScfInTextEditor()
{
gchar buffer[BSIZE];
if(molcasScf.numberOfNDDOIterations == 0 && molcasScf.numberOfRHFIterations == 0) return;
gabedit_text_insert (GABEDIT_TEXT(text), NULL, &molcasColorFore.subProgram, NULL, "Iterations\n",-1);
sprintf(buffer,"* NDDO and RHF iterations\n");
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
sprintf(buffer," %d %d\n", molcasScf.numberOfNDDOIterations, molcasScf.numberOfRHFIterations);
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, buffer,-1);
} | false | true | true | false | false | 1 |
bfad_debugfs_write_regrd(struct file *file, const char __user *buf,
size_t nbytes, loff_t *ppos)
{
struct bfad_debug_info *regrd_debug = file->private_data;
struct bfad_port_s *port = (struct bfad_port_s *)regrd_debug->i_private;
struct bfad_s *bfad = port->bfad;
struct bfa_s *bfa = &bfad->bfa;
struct bfa_ioc_s *ioc = &bfa->ioc;
int addr, rc, i;
u32 len;
u32 *regbuf;
void __iomem *rb, *reg_addr;
unsigned long flags;
void *kern_buf;
kern_buf = memdup_user(buf, nbytes);
if (IS_ERR(kern_buf))
return PTR_ERR(kern_buf);
rc = sscanf(kern_buf, "%x:%x", &addr, &len);
if (rc < 2 || len > (UINT_MAX >> 2)) {
printk(KERN_INFO
"bfad[%d]: %s failed to read user buf\n",
bfad->inst_no, __func__);
kfree(kern_buf);
return -EINVAL;
}
kfree(kern_buf);
kfree(bfad->regdata);
bfad->regdata = NULL;
bfad->reglen = 0;
bfad->regdata = kzalloc(len << 2, GFP_KERNEL);
if (!bfad->regdata) {
printk(KERN_INFO "bfad[%d]: Failed to allocate regrd buffer\n",
bfad->inst_no);
return -ENOMEM;
}
bfad->reglen = len << 2;
rb = bfa_ioc_bar0(ioc);
addr &= BFA_REG_ADDRMSK(ioc);
/* offset and len sanity check */
rc = bfad_reg_offset_check(bfa, addr, len);
if (rc) {
printk(KERN_INFO "bfad[%d]: Failed reg offset check\n",
bfad->inst_no);
kfree(bfad->regdata);
bfad->regdata = NULL;
bfad->reglen = 0;
return -EINVAL;
}
reg_addr = rb + addr;
regbuf = (u32 *)bfad->regdata;
spin_lock_irqsave(&bfad->bfad_lock, flags);
for (i = 0; i < len; i++) {
*regbuf = readl(reg_addr);
regbuf++;
reg_addr += sizeof(u32);
}
spin_unlock_irqrestore(&bfad->bfad_lock, flags);
return nbytes;
} | false | false | false | false | false | 0 |
PutBit(bool on)
{
assert(this->CurrentBytePos < 8);
if (on)
{
unsigned char pos = this->CurrentBytePos;
unsigned char mask = (unsigned char)(0x80 >> pos);
this->CurrentByte |= mask;
}
this->CurrentBytePos++;
TryFlush();
} | false | false | false | false | false | 0 |
simpleForm(MprTestGroup *gp, char *uri, char *formData, int expectStatus)
{
HttpConn *conn;
MprOff contentLen;
ssize len;
int status;
contentLen = 0;
if (expectStatus <= 0) {
expectStatus = 200;
}
if (startRequest(gp, "POST", uri) < 0) {
return 0;
}
conn = getConn(gp);
if (formData) {
httpSetHeader(conn, "Content-Type", "application/x-www-form-urlencoded");
len = slen(formData);
if (httpWrite(conn->writeq, formData, len) != len) {
return MPR_ERR_CANT_WRITE;
}
}
httpFinalize(conn);
if (httpWait(conn, HTTP_STATE_COMPLETE, -1) < 0) {
return MPR_ERR_CANT_READ;
}
status = httpGetStatus(conn);
if (status != expectStatus) {
mprLog(0, "Client failed for %s, response code: %d, msg %s\n", uri, status, httpGetStatusMessage(conn));
return 0;
}
gp->content = httpReadString(conn);
contentLen = httpGetContentLength(conn);
if (! assert(gp->content != 0 && contentLen > 0)) {
return 0;
}
mprLog(4, "Response content %s", gp->content);
return 1;
} | false | false | false | false | false | 0 |
inset_bbox_YCoCg(unsigned char *mincolor, unsigned char *maxcolor)
{
int inset[4], mini[4], maxi[4];
inset[2] = (maxcolor[2] - mincolor[2]) - ((1 << (INSET_SHIFT - 1)) - 1);
inset[1] = (maxcolor[1] - mincolor[1]) - ((1 << (INSET_SHIFT - 1)) - 1);
mini[2] = ((mincolor[2] << INSET_SHIFT) + inset[2]) >> INSET_SHIFT;
mini[1] = ((mincolor[1] << INSET_SHIFT) + inset[1]) >> INSET_SHIFT;
maxi[2] = ((maxcolor[2] << INSET_SHIFT) - inset[2]) >> INSET_SHIFT;
maxi[1] = ((maxcolor[1] << INSET_SHIFT) - inset[1]) >> INSET_SHIFT;
mini[2] = (mini[2] >= 0) ? mini[2] : 0;
mini[1] = (mini[1] >= 0) ? mini[1] : 0;
maxi[2] = (maxi[2] <= 255) ? maxi[2] : 255;
maxi[1] = (maxi[1] <= 255) ? maxi[1] : 255;
mincolor[2] = (mini[2] & 0xf8) | (mini[2] >> 5);
mincolor[1] = (mini[1] & 0xfc) | (mini[1] >> 6);
maxcolor[2] = (maxi[2] & 0xf8) | (maxi[2] >> 5);
maxcolor[1] = (maxi[1] & 0xfc) | (maxi[1] >> 6);
} | false | false | false | false | false | 0 |
krb5_k_make_checksum_iov(krb5_context context,
krb5_cksumtype cksumtype,
krb5_key key,
krb5_keyusage usage,
krb5_crypto_iov *data,
size_t num_data)
{
krb5_error_code ret;
krb5_data cksum_data;
krb5_crypto_iov *checksum;
const struct krb5_cksumtypes *ctp;
if (cksumtype == 0) {
ret = krb5int_c_mandatory_cksumtype(context, key->keyblock.enctype,
&cksumtype);
if (ret != 0)
return ret;
}
ctp = find_cksumtype(cksumtype);
if (ctp == NULL)
return KRB5_BAD_ENCTYPE;
ret = verify_key(ctp, key);
if (ret != 0)
return ret;
checksum = krb5int_c_locate_iov(data, num_data, KRB5_CRYPTO_TYPE_CHECKSUM);
if (checksum == NULL || checksum->data.length < ctp->output_size)
return(KRB5_BAD_MSIZE);
ret = alloc_data(&cksum_data, ctp->compute_size);
if (ret != 0)
return ret;
ret = ctp->checksum(ctp, key, usage, data, num_data, &cksum_data);
if (ret != 0)
goto cleanup;
memcpy(checksum->data.data, cksum_data.data, ctp->output_size);
checksum->data.length = ctp->output_size;
cleanup:
zapfree(cksum_data.data, ctp->compute_size);
return ret;
} | false | false | false | false | false | 0 |
set_bidder_signature(struct archive_read_filter_bidder *bidder,
struct program_bidder *state, const void *signature, size_t signature_len)
{
if (signature != NULL && signature_len > 0) {
state->signature_len = signature_len;
state->signature = malloc(signature_len);
memcpy(state->signature, signature, signature_len);
}
/*
* Fill in the bidder object.
*/
bidder->data = state;
bidder->bid = program_bidder_bid;
bidder->init = program_bidder_init;
bidder->options = NULL;
bidder->free = program_bidder_free;
return (ARCHIVE_OK);
} | false | true | false | false | false | 1 |
ucftp_mkdir(ventry *ve, avmode_t mode)
{
int res;
struct ucftpfs *fs = ucftp_ventry_ucftpfs(ve);
struct ucftpentry *ent = ucftp_ventry_ucftpentry(ve);
if(ent->node != NULL)
return -EEXIST;
res = ucftp_op(OP_MKD, ve);
if(res < 0)
return res;
res = ucftp_make_node(fs, ent, mode | AV_IFDIR);
if(res < 0)
return res;
if(ent->parent != NULL &&
ent->parent->node != NULL)
ent->parent->node->valid = 0;
return 0;
} | false | false | false | false | false | 0 |
create_the_forms() {
form = new Fl_Window(550,370);
strcpy(label, "Hello, world!\n");
int i = strlen(label);
uchar c;
for (c = ' '+1; c < 127; c++) {
if (!(c&0x1f)) label[i++]='\n';
if (c=='@') label[i++]=c;
label[i++]=c;
}
label[i++] = '\n';
for (c = 0xA1; c; c++) {if (!(c&0x1f)) label[i++]='\n'; label[i++]=c;}
label[i] = 0;
textobj = new FontDisplay(FL_FRAME_BOX,10,10,530,170,label);
textobj->align(FL_ALIGN_TOP|FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
textobj->color(9,47);
fontobj = new Fl_Hold_Browser(10, 190, 390, 170);
fontobj->box(FL_FRAME_BOX);
fontobj->color(53,3);
fontobj->callback(font_cb);
form->resizable(fontobj);
sizeobj = new Fl_Hold_Browser(410, 190, 130, 170);
sizeobj->box(FL_FRAME_BOX);
sizeobj->color(53,3);
sizeobj->callback(size_cb);
form->end();
} | false | false | false | false | false | 0 |
_unlock_lock(struct dlm_rsb *r, struct dlm_lkb *lkb)
{
int error;
if (is_remote(r)) {
/* receive_unlock() calls do_unlock() on remote node */
error = send_unlock(r, lkb);
} else {
error = do_unlock(r, lkb);
/* for remote locks the unlock_reply is sent
between do_unlock and do_unlock_effects */
do_unlock_effects(r, lkb, error);
}
return error;
} | false | false | false | false | false | 0 |
tomoyo_cred_free(struct cred *cred)
{
struct tomoyo_domain_info *domain = cred->security;
if (domain)
atomic_dec(&domain->users);
} | false | false | false | false | false | 0 |
load_files(GtkListStore * store, char * dirpath) {
gtk_list_store_clear(store);
GDir * dir = g_dir_open(dirpath, 0, NULL);
if (!dir) {
return;
}
const char * file;
while ((file = g_dir_read_name(dir))) {
char * filepath = g_build_filename(dirpath, file, NULL);
if ((g_file_test(filepath, G_FILE_TEST_IS_DIR) &&
dirname_filter(file)) ||
filename_filter(file)) {
GtkTreeIter iter;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter, 0, file, 1, filepath, -1);
}
g_free(filepath);
}
g_dir_close(dir);
} | false | false | false | false | false | 0 |
_pager_popup_cb_action_show(E_Object *obj __UNUSED__, const char *params __UNUSED__, Ecore_Event_Key *ev __UNUSED__)
{
if (_pager_popup_show())
_pager_popup_modifiers_set(ev->modifiers);
} | false | false | false | false | false | 0 |
SCPI_ParamNumber(scpi_t * context, scpi_number_t * value, bool_t mandatory) {
bool_t result;
const char * param;
size_t len;
size_t numlen;
/* read parameter and shift to the next one */
result = SCPI_ParamString(context, ¶m, &len, mandatory);
/* value not initializes */
if (!value) {
return FALSE;
}
value->type = SCPI_NUM_DEF;
/* if parameter was not found, return TRUE or FALSE according
* to fact that parameter was mandatory or not */
if (!result) {
return mandatory ? FALSE : TRUE;
}
/* convert string to special number type */
if (translateSpecialNumber(context->special_numbers, param, len, value)) {
/* found special type */
return TRUE;
}
/* convert text from double - no special type */
numlen = strToDouble(param, &value->value);
/* transform units of value */
if (numlen <= len) {
return transformNumber(context, param + numlen, len - numlen, value);
}
return FALSE;
} | false | false | false | false | false | 0 |
run_match(
Macro *macro, /* macro to run */
String *text, /* argument text that matched trigger/hook */
int hooknum) /* hook number */
{
int ran = 0;
struct Sock *callingsock = xsock;
RegInfo *old;
if (hooknum < 0) { /* trigger */
if (!borg) return 0;
if (text && max_trig > 0 && !test_max_counter(&trig_ctr)) return 0;
} else { /* hook */
if (max_hook > 0 && !test_max_counter(&hook_ctr)) return 0;
}
if (text)
old = new_reg_scope(hooknum>=0 ? macro->hargs.ri : macro->trig.ri, text);
/* Execute the macro. */
if ((hooknum>=0 && hookflag) || (hooknum<0 && borg)) {
callingsock = xsock;
if (macro->prob == 100 || RRAND(0, 99) < macro->prob) {
if (macro->shots && !--macro->shots) kill_macro(macro);
if (mecho > macro->invis) {
char numbuf[16];
if (!*macro->name) sprintf(numbuf, "#%d", macro->num);
tfprintf(tferr, "%S%s%s: /%s %S%A", do_mprefix(),
hooknum>=0 ? hook_table[hooknum].name : "",
hooknum>=0 ? " HOOK" : "TRIGGER",
*macro->name ? macro->name : numbuf,
text, mecho_attr);
}
if (macro->body && macro->body->len) {
do_macro(macro, text, 0, hooknum>=0 ? USED_HOOK : USED_TRIG, 0);
ran += !macro->quiet;
}
}
/* Restore xsock, in case macro called fg_sock(). main_loop() will
* set xsock=fsock, so any fg_sock() will effect xsock after the
* find_and_run_matches() loop is complete.
*/
xsock = callingsock;
}
if (text)
restore_reg_scope(old);
return ran;
} | false | false | false | false | false | 0 |
psw_fill_mask(gx_device * dev,
const byte * data, int data_x, int raster, gx_bitmap_id id,
int x, int y, int w, int h,
const gx_drawing_color * pdcolor, int depth,
gs_logical_operation_t lop, const gx_clip_path * pcpath)
{
gx_device_vector *const vdev = (gx_device_vector *)dev;
gx_device_pswrite *const pdev = (gx_device_pswrite *)vdev;
CHECK_BEGIN_PAGE(pdev);
if (w <= 0 || h <= 0)
return 0;
/* gdev_vector_update_clip_path may output a grestore and gsave,
* causing the setting of the color to be lost. Therefore, we
* must update the clip path first.
*/
if (depth > 1 ||
gdev_vector_update_clip_path(vdev, pcpath) < 0 ||
gdev_vector_update_fill_color(vdev, NULL, pdcolor) < 0 ||
gdev_vector_update_log_op(vdev, lop) < 0
)
return gx_default_fill_mask(dev, data, data_x, raster, id,
x, y, w, h, pdcolor, depth, lop, pcpath);
(*dev_proc(vdev->bbox_device, fill_mask))
((gx_device *) vdev->bbox_device, data, data_x, raster, id,
x, y, w, h, pdcolor, depth, lop, pcpath);
/* Update the clipping path now. */
gdev_vector_update_clip_path(vdev, pcpath);
return psw_image_write(pdev, ",", data, data_x, raster, id,
x, y, w, h, 1);
} | false | false | false | false | false | 0 |
glfs_pwritev (struct glfs_fd *glfd, const struct iovec *iovec, int iovcnt,
off_t offset, int flags)
{
xlator_t *subvol = NULL;
int ret = -1;
size_t size = -1;
struct iobref *iobref = NULL;
struct iobuf *iobuf = NULL;
struct iovec iov = {0, };
fd_t *fd = NULL;
__glfs_entry_fd (glfd);
subvol = glfs_active_subvol (glfd->fs);
if (!subvol) {
ret = -1;
errno = EIO;
goto out;
}
fd = glfs_resolve_fd (glfd->fs, subvol, glfd);
if (!fd) {
ret = -1;
errno = EBADFD;
goto out;
}
size = iov_length (iovec, iovcnt);
iobuf = iobuf_get2 (subvol->ctx->iobuf_pool, size);
if (!iobuf) {
ret = -1;
errno = ENOMEM;
goto out;
}
iobref = iobref_new ();
if (!iobref) {
iobuf_unref (iobuf);
errno = ENOMEM;
ret = -1;
goto out;
}
ret = iobref_add (iobref, iobuf);
if (ret) {
iobuf_unref (iobuf);
iobref_unref (iobref);
errno = ENOMEM;
ret = -1;
goto out;
}
iov_unload (iobuf_ptr (iobuf), iovec, iovcnt); /* FIXME!!! */
iov.iov_base = iobuf_ptr (iobuf);
iov.iov_len = size;
ret = syncop_writev (subvol, fd, &iov, 1, offset, iobref, flags);
iobuf_unref (iobuf);
iobref_unref (iobref);
if (ret <= 0)
goto out;
glfd->offset = (offset + size);
out:
if (fd)
fd_unref (fd);
glfs_subvol_done (glfd->fs, subvol);
return ret;
} | false | false | false | false | false | 0 |
SetInformationWeak(vtkInformation* inf)
{
if (!this->ReferenceIsWeak)
{
this->SetInformation(0);
}
this->ReferenceIsWeak = true;
if (this->Information != inf)
{
this->Information = inf;
this->Modified();
}
} | false | false | false | false | false | 0 |
modemDIS() const
{
FaxParams dis_caps = FaxModem::modemDIS();
// signalling rates
for (u_short i = 0; i < 4; i++) dis_caps.setBit(11+i, (discap & (0x08>>i)));
if (useV34) dis_caps.setBit(FaxParams::BITNUM_V8_CAPABLE, true);
// preferred ECM frame size
if (conf.class1ECMFrameSize == 64) dis_caps.setBit(FaxParams::BITNUM_FRAMESIZE_DIS, true);
// we set both units preferences to allow the sender to choose
dis_caps.setBit(FaxParams::BITNUM_METRIC_RES, true);
dis_caps.setBit(FaxParams::BITNUM_INCH_RES, true);
// we indicate both letter and legal page size support
dis_caps.setBit(FaxParams::BITNUM_LETTER_SIZE, true);
dis_caps.setBit(FaxParams::BITNUM_LEGAL_SIZE, true);
// selective polling, subaddressing, password
dis_caps.setBit(FaxParams::BITNUM_SEP, true);
dis_caps.setBit(FaxParams::BITNUM_SUB, true);
dis_caps.setBit(FaxParams::BITNUM_PWD, true);
if (conf.class1ECMSupport) {
// JBIG
if (jbigSupported) {
dis_caps.setBit(FaxParams::BITNUM_JBIG_BASIC, true);
dis_caps.setBit(FaxParams::BITNUM_JBIG_L0, true); // JBIG library can handle L0 = 1-Yd
}
/* - disabled for now
// JBIG grey/color requires JPEG grey/color
if (conf.class1GreyJBIGSupport || conf.class1ColorJBIGSupport) {
dis_caps.setBit(FaxParams::BITNUM_JPEG, true);
dis_caps.setBit(FaxParams::BITNUM_JBIG, true);
}
if (conf.class1ColorJBIGSupport)
dis_caps.setBit(FaxParams::BITNUM_FULLCOLOR, true);
*/
// JPEG
if (conf.class1GreyJPEGSupport || conf.class1ColorJPEGSupport)
dis_caps.setBit(FaxParams::BITNUM_JPEG, true);
if (conf.class1ColorJPEGSupport)
dis_caps.setBit(FaxParams::BITNUM_FULLCOLOR, true);
}
return dis_caps;
} | false | false | false | false | false | 0 |
Append(Dlist *l1, Dlist *l2)
{
if (l1 == NULL || l2 == NULL) return iError.NullPtrError("iDlist.Append");
if ((l1->Flags & CONTAINER_READONLY) || (l2->Flags & CONTAINER_READONLY)) {
l1->RaiseError("iDlist.Append",CONTAINER_ERROR_READONLY,l1);
return CONTAINER_ERROR_READONLY;
}
if (l2->ElementSize != l1->ElementSize) {
l1->RaiseError("iDlist.Append",CONTAINER_ERROR_INCOMPATIBLE);
return CONTAINER_ERROR_INCOMPATIBLE;
}
if (l1->count == 0) {
l1->First = l2->First;
l1->Last = l2->Last;
}
else if (l2->count > 0) {
l1->Last->Next = l2->First;
l2->First->Previous = l1->Last;
l1->Last = l2->Last;
}
l1->count += l2->count;
l1->timestamp++;
if (l1->Flags & CONTAINER_HAS_OBSERVER)
iObserver.Notify(l1,CCL_APPEND,l2,NULL);
if (l2->Flags & CONTAINER_HAS_OBSERVER)
iObserver.Notify(l2,CCL_FINALIZE,NULL,NULL);
l2->Allocator->free(l2);
return 1;
} | false | false | false | false | false | 0 |
ColourisePHPScriptDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[],
Accessor &styler) {
if (startPos == 0)
initStyle = SCE_HPHP_DEFAULT;
ColouriseHTMLDoc(startPos, length, initStyle, keywordlists, styler);
} | false | false | false | false | false | 0 |
NewGF_IPMPX_MutualAuthentication()
{
GF_IPMPX_MutualAuthentication *ptr;
GF_IPMPX_DATA_ALLOC(ptr, GF_IPMPX_MutualAuthentication, GF_IPMPX_MUTUAL_AUTHENTICATION_TAG);
ptr->candidateAlgorithms = gf_list_new();
ptr->agreedAlgorithms = gf_list_new();
ptr->certificates = gf_list_new();
return (GF_IPMPX_Data *) ptr;
} | false | false | false | false | false | 0 |
rmatrixbdunpackpt(const ap::real_2d_array& qp,
int m,
int n,
const ap::real_1d_array& taup,
int ptrows,
ap::real_2d_array& pt)
{
int i;
int j;
ap::ap_error::make_assertion(ptrows<=n, "RMatrixBDUnpackPT: PTRows>N!");
ap::ap_error::make_assertion(ptrows>=0, "RMatrixBDUnpackPT: PTRows<0!");
if( m==0||n==0||ptrows==0 )
{
return;
}
//
// prepare PT
//
pt.setbounds(0, ptrows-1, 0, n-1);
for(i = 0; i <= ptrows-1; i++)
{
for(j = 0; j <= n-1; j++)
{
if( i==j )
{
pt(i,j) = 1;
}
else
{
pt(i,j) = 0;
}
}
}
//
// Calculate
//
rmatrixbdmultiplybyp(qp, m, n, taup, pt, ptrows, n, true, true);
} | false | false | false | false | false | 0 |
GetDefinition(const char* name) const
{
#ifdef CMAKE_STRICT
if (this->GetCMakeInstance())
{
this->GetCMakeInstance()->
RecordPropertyAccess(name,cmProperty::VARIABLE);
}
#endif
const char* def = 0;
DefinitionMap::const_iterator pos =
this->DefinitionStack.back().find(name);
if(pos != this->DefinitionStack.back().end())
{
def = (*pos).second.c_str();
}
else
{
def = this->GetCacheManager()->GetCacheValue(name);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
cmVariableWatch* vv = this->GetVariableWatch();
if ( vv )
{
if ( def )
{
vv->VariableAccessed(name, cmVariableWatch::VARIABLE_READ_ACCESS,
def, this);
}
else
{
// are unknown access allowed
DefinitionMap::const_iterator pos2 =
this->DefinitionStack.back()
.find("CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS");
if (pos2 != this->DefinitionStack.back().end() &&
cmSystemTools::IsOn((*pos2).second.c_str()))
{
vv->VariableAccessed(name,
cmVariableWatch::ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS, def, this);
}
else
{
vv->VariableAccessed(name,
cmVariableWatch::UNKNOWN_VARIABLE_READ_ACCESS, def, this);
}
}
}
#endif
return def;
} | false | false | false | false | false | 0 |
sync_persist_terminate (PRThread *tid)
{
SyncRequest *cur;
int rc = 1;
if ( SYNC_IS_INITIALIZED() && NULL != tid ) {
SYNC_LOCK_READ();
/* Find and change */
cur = sync_request_list->sync_req_head;
while ( NULL != cur ) {
if ( cur->req_tid == tid ) {
cur->req_active = PR_FALSE;
cur->req_complete = PR_TRUE;
rc = 0;
break;
}
cur = cur->req_next;
}
SYNC_UNLOCK_READ();
}
if (rc == 0) {
sync_remove_request(cur);
}
return(rc);
} | false | false | false | false | false | 0 |
pt_write_cont(pt_Continuation *op, PRInt16 revents)
{
PRIntn bytes;
/*
* We want to write the entire amount out, no matter how many
* tries it takes. Keep advancing the buffer and the decrementing
* the amount until the amount goes away. Return the total bytes
* (which should be the original amount) when finished (or an
* error).
*/
bytes = write(op->arg1.osfd, op->arg2.buffer, op->arg3.amount);
op->syserrno = errno;
if (bytes >= 0) /* this is progress */
{
char *bp = (char*)op->arg2.buffer;
bp += bytes; /* adjust the buffer pointer */
op->arg2.buffer = bp;
op->result.code += bytes; /* accumulate the number sent */
op->arg3.amount -= bytes; /* and reduce the required count */
return (0 == op->arg3.amount) ? PR_TRUE : PR_FALSE;
}
else if ((EWOULDBLOCK != op->syserrno) && (EAGAIN != op->syserrno))
{
op->result.code = -1;
return PR_TRUE;
}
else return PR_FALSE;
} | false | false | false | false | false | 0 |
exif_ifd_from_string (const char *string)
{
unsigned int i;
if (!string)
return (-1);
for (i = 0; i < EXIF_IFD_COUNT; i++) {
if (!strcmp (string, exif_ifd_get_name (i)))
return (i);
}
return (-1);
} | false | false | false | false | false | 0 |
doDeserialize()
{
if(_reader->get().type() != cxxtools::xml::Node::StartElement)
_reader->nextElement();
_processNode = &XmlDeserializer::beginDocument;
_startDepth = _reader->depth();
for(cxxtools::xml::XmlReader::Iterator it = _reader->current(); it != _reader->end(); ++it)
{
(this->*_processNode)(*it);
if( (it->type() == cxxtools::xml::Node::EndElement) && (_reader->depth() < _startDepth) )
{
break;
}
}
} | false | false | false | false | false | 0 |
nv04_dac_output_offset(struct drm_encoder *encoder)
{
struct dcb_output *dcb = nouveau_encoder(encoder)->dcb;
int offset = 0;
if (dcb->or & (8 | DCB_OUTPUT_C))
offset += 0x68;
if (dcb->or & (8 | DCB_OUTPUT_B))
offset += 0x2000;
return offset;
} | false | false | false | false | false | 0 |
luaB_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE);
getfunc(L, 0);
lua_pushvalue(L, 2);
if (lua_isnumber(L, 1) && lua_tonumber(L, 1) == 0) {
/* change environment of current thread */
lua_pushthread(L);
lua_insert(L, -2);
lua_setfenv(L, -2);
return 0;
}
else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
luaL_error(L,
LUA_QL("setfenv") " cannot change environment of given object");
return 1;
} | false | false | false | false | false | 0 |
ael2005_get_module_type(struct cphy *phy, int delay_ms)
{
int v;
unsigned int stat;
v = t3_mdio_read(phy, MDIO_MMD_PMAPMD, AEL2005_GPIO_CTRL, &stat);
if (v)
return v;
if (stat & (1 << 8)) /* module absent */
return phy_modtype_none;
return ael2xxx_get_module_type(phy, delay_ms);
} | false | false | false | false | false | 0 |
ade7754_initial_setup(struct iio_dev *indio_dev)
{
int ret;
struct ade7754_state *st = iio_priv(indio_dev);
struct device *dev = &indio_dev->dev;
/* use low spi speed for init */
st->us->mode = SPI_MODE_3;
spi_setup(st->us);
/* Disable IRQ */
ret = ade7754_set_irq(dev, false);
if (ret) {
dev_err(dev, "disable irq failed");
goto err_ret;
}
ade7754_reset(dev);
msleep(ADE7754_STARTUP_DELAY);
err_ret:
return ret;
} | false | false | false | false | false | 0 |
prepare_enc_data(unsigned char *indata,
int indata_len,
unsigned char **outdata,
int *outdata_len)
{
int retval = -1;
ASN1_const_CTX c;
long length = indata_len;
int Ttag, Tclass;
long Tlen;
c.pp = (const unsigned char **)&indata;
c.q = *(const unsigned char **)&indata;
c.error = ERR_R_NESTED_ASN1_ERROR;
c.p= *(const unsigned char **)&indata;
c.max = (length == 0)?0:(c.p+length);
asn1_GetSequence(&c,&length);
ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen);
c.p += Tlen;
ASN1_get_object(&c.p,&Tlen,&Ttag,&Tclass,c.slen);
asn1_const_Finish(&c);
*outdata = malloc((size_t)Tlen);
if (*outdata == NULL) {
retval = ENOMEM;
goto cleanup;
}
memcpy(*outdata, c.p, (size_t)Tlen);
*outdata_len = Tlen;
retval = 0;
cleanup:
return retval;
} | false | false | false | false | false | 0 |
sexp_to_key (gcry_sexp_t sexp, int want_private, const char *override_elems,
gcry_mpi_t **retarray, gcry_module_t *retalgo)
{
gcry_err_code_t err = 0;
gcry_sexp_t list, l2;
char *name;
const char *elems;
gcry_mpi_t *array;
gcry_module_t module;
gcry_pk_spec_t *pubkey;
pk_extra_spec_t *extraspec;
int is_ecc;
/* Check that the first element is valid. */
list = gcry_sexp_find_token (sexp,
want_private? "private-key":"public-key", 0);
if (!list)
return GPG_ERR_INV_OBJ; /* Does not contain a key object. */
l2 = gcry_sexp_cadr( list );
gcry_sexp_release ( list );
list = l2;
name = _gcry_sexp_nth_string (list, 0);
if (!name)
{
gcry_sexp_release ( list );
return GPG_ERR_INV_OBJ; /* Invalid structure of object. */
}
ath_mutex_lock (&pubkeys_registered_lock);
module = gcry_pk_lookup_name (name);
ath_mutex_unlock (&pubkeys_registered_lock);
/* Fixme: We should make sure that an ECC key is always named "ecc"
and not "ecdsa". "ecdsa" should be used for the signature
itself. We need a function to test whether an algorithm given
with a key is compatible with an application of the key (signing,
encryption). For RSA this is easy, but ECC is the first
algorithm which has many flavours. */
is_ecc = ( !strcmp (name, "ecdsa")
|| !strcmp (name, "ecdh")
|| !strcmp (name, "ecc") );
gcry_free (name);
if (!module)
{
gcry_sexp_release (list);
return GPG_ERR_PUBKEY_ALGO; /* Unknown algorithm. */
}
else
{
pubkey = (gcry_pk_spec_t *) module->spec;
extraspec = module->extraspec;
}
if (override_elems)
elems = override_elems;
else if (want_private)
elems = pubkey->elements_skey;
else
elems = pubkey->elements_pkey;
array = gcry_calloc (strlen (elems) + 1, sizeof (*array));
if (!array)
err = gpg_err_code_from_syserror ();
if (!err)
{
if (is_ecc)
err = sexp_elements_extract_ecc (list, elems, array, extraspec);
else
err = sexp_elements_extract (list, elems, array, pubkey->name);
}
gcry_sexp_release (list);
if (err)
{
gcry_free (array);
ath_mutex_lock (&pubkeys_registered_lock);
_gcry_module_release (module);
ath_mutex_unlock (&pubkeys_registered_lock);
}
else
{
*retarray = array;
*retalgo = module;
}
return err;
} | false | false | false | false | false | 0 |
eval (bool evaluate)
{
VALUE *l;
VALUE *r;
#ifdef EVAL_TRACE
trace ("eval");
#endif
l = eval1 (evaluate);
while (1)
{
if (nextarg ("|"))
{
r = eval1 (evaluate && null (l));
if (null (l))
{
freev (l);
l = r;
if (null (l))
{
freev (l);
l = int_value (0);
}
}
else
freev (r);
}
else
return l;
}
} | false | false | false | false | false | 0 |
constrainOperandRegClass(const MCInstrDesc &II, unsigned Op,
unsigned OpNum) {
if (TargetRegisterInfo::isVirtualRegister(Op)) {
const TargetRegisterClass *RegClass =
TII.getRegClass(II, OpNum, &TRI, *FuncInfo.MF);
if (!MRI.constrainRegClass(Op, RegClass)) {
// If it's not legal to COPY between the register classes, something
// has gone very wrong before we got here.
unsigned NewOp = createResultReg(RegClass);
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(TargetOpcode::COPY), NewOp).addReg(Op);
return NewOp;
}
}
return Op;
} | 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.