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 |
|---|---|---|---|---|---|---|
bindtextdomain(const char* domainname,const char* dirname) {
if (dir) free(dir);
if (!(dir=strdup(dirname))) return 0;
return dir;
} | false | false | false | false | false | 0 |
createProxy( const btVector3& aabbMin, const btVector3& aabbMax,int shapeType,void* userPtr, short int collisionFilterGroup,short int collisionFilterMask, btDispatcher* dispatcher,void* /*ignoreMe*/)
{
//void* ignoreMe -> we could think of recursive multi-sap, if someone is interested
void* mem = btAlignedAlloc(sizeof(btMultiSapProxy),16);
btMultiSapProxy* proxy = new (mem)btMultiSapProxy(aabbMin, aabbMax,shapeType,userPtr, collisionFilterGroup,collisionFilterMask);
m_multiSapProxies.push_back(proxy);
///this should deal with inserting/removal into child broadphases
setAabb(proxy,aabbMin,aabbMax,dispatcher);
return proxy;
} | false | false | false | false | false | 0 |
marshal_struct (DBusMessageIter *iter,
const GValue *value)
{
GType gtype;
DBusMessageIter subiter;
guint size, i;
GValue val = {0,};
gtype = G_VALUE_TYPE (value);
size = dbus_g_type_get_struct_size (gtype);
if (!dbus_message_iter_open_container (iter,
DBUS_TYPE_STRUCT,
NULL,
&subiter))
oom ();
for (i = 0; i < size; i++)
{
g_value_init (&val, dbus_g_type_get_struct_member_type
(G_VALUE_TYPE(value), i));
if (!dbus_g_type_struct_get_member (value, i, &val))
goto abandon;
if (!_dbus_gvalue_marshal (&subiter, &val))
goto abandon;
g_value_unset(&val);
}
return dbus_message_iter_close_container (iter, &subiter);
abandon:
dbus_message_iter_abandon_container (iter, &subiter);
return FALSE;
} | false | false | false | false | false | 0 |
menu_get_current_item(Menu *menu)
{
return (MenuItem*) ((menu != NULL)
? menu_get_subitem(menu, menu->data.menu.selector_pos)
: NULL);
} | false | false | false | false | false | 0 |
list_proxies_foreach (gpointer key,
gpointer value,
gpointer user_data)
{
DBusGProxyList *list;
GSList **ret;
GSList *tmp;
list = value;
ret = user_data;
tmp = list->proxies;
while (tmp != NULL)
{
DBusGProxy *proxy = DBUS_G_PROXY (tmp->data);
g_object_ref (proxy);
*ret = g_slist_prepend (*ret, proxy);
tmp = tmp->next;
}
} | false | false | false | false | false | 0 |
id_verb(void)
/* Identify verb at ip=i ; return verb id if found, 0 otherwise */
{
word w;
int j, canon_word, tmp;
w=comb_verb(); /* Combine 2-word verbs */
if (w==0) return 0;
/* Pre-Canonization of w: see if w has any built-in synonyms */
canon_word=verb_builtin(w);
if (canon_word!=0) {
if (aver<AGX00 && orig_agt_verb(w))
/* In orig AGT, author-defined verbs don't override builtin syns */
tmp=0;
else
tmp=verb_authorsyn(w); /* Author-defined verbs override built-in ones */
if (tmp==0 || tmp==canon_word)
w=syntbl[auxsyn[canon_word]];
}
/* Now check room-specific synonyms (being the most localized,
they have the highest priority) */
for(j=room[loc].replacing_word;syntbl[j]!=0;j++)
if (w==syntbl[j])
w=room[loc].replace_word;
/* Next check to see if we already have the canonical form of the verb. */
/* and go through the built-in list of synonyms */
canon_word=verb_code(w);
if (!PURE_DUMMY && canon_word==57) canon_word=0; /* AFTER */
return canon_word;
} | false | false | false | false | false | 0 |
uconf_log_file_preference_write_xml(const output::pointer &fp, const char *name, uconf_log_file_preference_ty this_thing, bool show)
{
if (this_thing == 0)
{
if (!show || type_enum_option_query())
return;
}
assert(name);
assert(this_thing < uconf_log_file_preference_max);
fp->fputc('<');
fp->fputs(name);
fp->fputc('>');
fp->fputs(uconf_log_file_preference_s[this_thing]);
fp->fputs("</");
fp->fputs(name);
fp->fputs(">\n");
} | false | false | false | false | false | 0 |
amp_group_node_update_node (AmpGroupNode *group, AmpGroupNode *new_group)
{
gint i;
GHashTable *hash;
if (group->monitor != NULL)
{
g_object_unref (group->monitor);
group->monitor = NULL;
}
if (group->makefile != NULL)
{
g_object_unref (group->makefile);
group->monitor = NULL;
}
if (group->preset_token != NULL)
{
anjuta_token_free (group->preset_token);
group->preset_token = NULL;
}
if (group->tfile) anjuta_token_file_free (group->tfile);
for (i = 0; i < AM_GROUP_TOKEN_LAST; i++)
{
if (group->tokens[i] != NULL) g_list_free (group->tokens[i]);
}
if (group->variables) g_hash_table_remove_all (group->variables);
group->dist_only = new_group->dist_only;
group->makefile = new_group->makefile;
new_group->makefile = NULL;
group->tfile = new_group->tfile;
new_group->tfile = NULL;
group->make_token = new_group->make_token;
new_group->make_token = NULL;
group->preset_token = new_group->preset_token;
new_group->preset_token = NULL;
memcpy (group->tokens, new_group->tokens, sizeof (group->tokens));
memset (new_group->tokens, 0, sizeof (new_group->tokens));
hash = group->variables;
group->variables = new_group->variables;
new_group->variables = hash;
if (group->makefile != NULL)
{
group->monitor = g_file_monitor_file (group->makefile,
G_FILE_MONITOR_NONE,
NULL,
NULL);
if (group->monitor != NULL)
{
g_signal_connect (G_OBJECT (group->monitor),
"changed",
G_CALLBACK (on_group_monitor_changed),
group);
}
}
} | false | true | false | false | false | 1 |
builtin_scale(GwyNLFitPreset *preset,
gdouble *param,
gdouble xscale,
gdouble yscale,
gint dir)
{
guint i;
g_return_if_fail(preset->builtin);
if (preset->builtin->scale_params) {
preset->builtin->scale_params(preset, param, xscale, yscale, dir);
return;
}
/* Generic parameter scaling when there are no peculiarities */
for (i = 0; i < preset->builtin->nparams; i++) {
const GwyNLFitParam *p = preset->builtin->param + i;
param[i] *= pow(xscale, -dir*p->power_x)*pow(yscale, -dir*p->power_y);
}
} | false | false | false | false | false | 0 |
gpiod_direction_input(struct gpio_desc *desc)
{
struct gpio_chip *chip;
int status = -EINVAL;
if (!desc || !desc->chip) {
pr_warn("%s: invalid GPIO\n", __func__);
return -EINVAL;
}
chip = desc->chip;
if (!chip->get || !chip->direction_input) {
gpiod_warn(desc,
"%s: missing get() or direction_input() operations\n",
__func__);
return -EIO;
}
status = chip->direction_input(chip, gpio_chip_hwgpio(desc));
if (status == 0)
clear_bit(FLAG_IS_OUT, &desc->flags);
trace_gpio_direction(desc_to_gpio(desc), 1, status);
return status;
} | false | false | false | false | false | 0 |
aclnewowner(const Acl *old_acl, Oid oldOwnerId, Oid newOwnerId)
{
Acl *new_acl;
AclItem *new_aip;
AclItem *old_aip;
AclItem *dst_aip;
AclItem *src_aip;
AclItem *targ_aip;
bool newpresent = false;
int dst,
src,
targ,
num;
check_acl(old_acl);
/*
* Make a copy of the given ACL, substituting new owner ID for old
* wherever it appears as either grantor or grantee. Also note if the new
* owner ID is already present.
*/
num = ACL_NUM(old_acl);
old_aip = ACL_DAT(old_acl);
new_acl = allocacl(num);
new_aip = ACL_DAT(new_acl);
memcpy(new_aip, old_aip, num * sizeof(AclItem));
for (dst = 0, dst_aip = new_aip; dst < num; dst++, dst_aip++)
{
if (dst_aip->ai_grantor == oldOwnerId)
dst_aip->ai_grantor = newOwnerId;
else if (dst_aip->ai_grantor == newOwnerId)
newpresent = true;
if (dst_aip->ai_grantee == oldOwnerId)
dst_aip->ai_grantee = newOwnerId;
else if (dst_aip->ai_grantee == newOwnerId)
newpresent = true;
}
/*
* If the old ACL contained any references to the new owner, then we may
* now have generated an ACL containing duplicate entries. Find them and
* merge them so that there are not duplicates. (This is relatively
* expensive since we use a stupid O(N^2) algorithm, but it's unlikely to
* be the normal case.)
*
* To simplify deletion of duplicate entries, we temporarily leave them in
* the array but set their privilege masks to zero; when we reach such an
* entry it's just skipped. (Thus, a side effect of this code will be to
* remove privilege-free entries, should there be any in the input.) dst
* is the next output slot, targ is the currently considered input slot
* (always >= dst), and src scans entries to the right of targ looking for
* duplicates. Once an entry has been emitted to dst it is known
* duplicate-free and need not be considered anymore.
*/
if (newpresent)
{
dst = 0;
for (targ = 0, targ_aip = new_aip; targ < num; targ++, targ_aip++)
{
/* ignore if deleted in an earlier pass */
if (ACLITEM_GET_RIGHTS(*targ_aip) == ACL_NO_RIGHTS)
continue;
/* find and merge any duplicates */
for (src = targ + 1, src_aip = targ_aip + 1; src < num;
src++, src_aip++)
{
if (ACLITEM_GET_RIGHTS(*src_aip) == ACL_NO_RIGHTS)
continue;
if (aclitem_match(targ_aip, src_aip))
{
ACLITEM_SET_RIGHTS(*targ_aip,
ACLITEM_GET_RIGHTS(*targ_aip) |
ACLITEM_GET_RIGHTS(*src_aip));
/* mark the duplicate deleted */
ACLITEM_SET_RIGHTS(*src_aip, ACL_NO_RIGHTS);
}
}
/* and emit to output */
new_aip[dst] = *targ_aip;
dst++;
}
/* Adjust array size to be 'dst' items */
ARR_DIMS(new_acl)[0] = dst;
SET_VARSIZE(new_acl, ACL_N_SIZE(dst));
}
return new_acl;
} | false | false | false | false | false | 0 |
H5F_accum_reset(const H5F_t *f, hid_t dxpl_id, hbool_t flush)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
HDassert(f);
HDassert(f->shared);
/* Flush any dirty data in accumulator, if requested */
if(flush)
if(H5F_accum_flush(f, dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "can't flush metadata accumulator")
/* Check if we need to reset the metadata accumulator information */
if(f->shared->feature_flags & H5FD_FEAT_ACCUMULATE_METADATA) {
/* Sanity check */
HDassert(!f->closing || FALSE == f->shared->accum.dirty);
/* Free the buffer */
if(f->shared->accum.buf)
f->shared->accum.buf = H5FL_BLK_FREE(meta_accum, f->shared->accum.buf);
/* Reset the buffer sizes & location */
f->shared->accum.alloc_size = f->shared->accum.size = 0;
f->shared->accum.loc = HADDR_UNDEF;
f->shared->accum.dirty = FALSE;
f->shared->accum.dirty_len = 0;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} | false | false | false | false | false | 0 |
IsDuplicateDescription(pkgCache::DescIterator Desc,
MD5SumValue const &CurMd5, std::string const &CurLang)
{
// Descriptions in the same link-list have all the same md5
if (Desc.end() == true || MD5SumValue(Desc.md5()) != CurMd5)
return false;
for (; Desc.end() == false; ++Desc)
if (Desc.LanguageCode() == CurLang)
return true;
return false;
} | false | false | false | false | false | 0 |
tiadc_step_config(struct iio_dev *indio_dev)
{
struct tiadc_device *adc_dev = iio_priv(indio_dev);
struct device *dev = adc_dev->mfd_tscadc->dev;
unsigned int stepconfig;
int i, steps = 0;
/*
* There are 16 configurable steps and 8 analog input
* lines available which are shared between Touchscreen and ADC.
*
* Steps forwards i.e. from 0 towards 16 are used by ADC
* depending on number of input lines needed.
* Channel would represent which analog input
* needs to be given to ADC to digitalize data.
*/
for (i = 0; i < adc_dev->channels; i++) {
int chan;
chan = adc_dev->channel_line[i];
if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
dev_warn(dev, "chan %d step_avg truncating to %d\n",
chan, STEPCONFIG_AVG_16);
adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
}
if (adc_dev->step_avg[i])
stepconfig =
STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
STEPCONFIG_FIFO1;
else
stepconfig = STEPCONFIG_FIFO1;
if (iio_buffer_enabled(indio_dev))
stepconfig |= STEPCONFIG_MODE_SWCNT;
tiadc_writel(adc_dev, REG_STEPCONFIG(steps),
stepconfig | STEPCONFIG_INP(chan));
if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
chan);
adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
}
if (adc_dev->sample_delay[i] > 0xFF) {
dev_warn(dev, "chan %d sample delay truncating to 0xFF\n",
chan);
adc_dev->sample_delay[i] = 0xFF;
}
tiadc_writel(adc_dev, REG_STEPDELAY(steps),
STEPDELAY_OPEN(adc_dev->open_delay[i]) |
STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
adc_dev->channel_step[i] = steps;
steps++;
}
} | false | false | false | false | false | 0 |
put_ebml_size_unknown(ByteIOContext *pb, int bytes)
{
assert(bytes <= 8);
put_byte(pb, 0x1ff >> bytes);
while (--bytes)
put_byte(pb, 0xff);
} | false | false | false | false | false | 0 |
newScene()
{
//Save if necessary
//saveOrCancelDialog == false <=> cancel
if ( !saveOrCancelDialog() )
return;
//Clear the scene
reinitScene( START_SCENE_RECT );
mGraphicsView->centerOn( 0 , 0 );
mGraphicsView->setTransform( QTransform() );
//Update states
setWindowFilePath("");
updateWindowState();
updateZoomLabel();
mSceneHasChanged = false;
} | false | false | false | false | false | 0 |
showAllFields(void){
int i;
cgi_printf("<font color=\"blue\">\n"
"<p>Database fields:</p><ul>\n");
for(i=0; i<nField; i++){
cgi_printf("<li>aField[%d].zName = \"%h\";\n"
"originally = \"%h\";\n"
"currently = \"%h\"\";\n",(i),(aField[i].zName),(aField[i].zValue),(PD(aField[i].zName,"")));
if( aField[i].zAppend ){
cgi_printf("zAppend = \"%h\";\n",(aField[i].zAppend));
}
cgi_printf("mUsed = %d;\n",(aField[i].mUsed));
}
cgi_printf("</ul></font>\n");
} | false | false | false | false | false | 0 |
handle_client(socket_struct *ns, player *pl) {
int len, i;
unsigned char *data;
/* Loop through this - maybe we have several complete packets here. */
while (1) {
/* If it is a player, and they don't have any speed left, we
* return, and will read in the data when they do have time.
*/
if (pl && pl->state == ST_PLAYING && pl->ob != NULL && pl->ob->speed_left < 0) {
return;
}
i = SockList_ReadPacket(ns->fd, &ns->inbuf, sizeof(ns->inbuf.buf)-1);
if (i < 0) {
#ifdef ESRV_DEBUG
LOG(llevDebug, "handle_client: Read error on connection player %s\n", (pl ? pl->ob->name : "None"));
#endif
/* Caller will take care of cleaning this up */
ns->status = Ns_Dead;
return;
}
/* Still dont have a full packet */
if (i == 0)
return;
SockList_NullTerminate(&ns->inbuf); /* Terminate buffer - useful for string data */
/* First, break out beginning word. There are at least
* a few commands that do not have any paremeters. If
* we get such a command, don't worry about trying
* to break it up.
*/
data = (unsigned char *)strchr((char *)ns->inbuf.buf+2, ' ');
if (data) {
*data = '\0';
data++;
len = ns->inbuf.len-(data-ns->inbuf.buf);
} else
len = 0;
for (i = 0; client_commands[i].cmdname != NULL; i++) {
if (strcmp((char *)ns->inbuf.buf+2, client_commands[i].cmdname) == 0) {
client_commands[i].cmdproc((char *)data, len, ns);
SockList_ResetRead(&ns->inbuf);
return;
}
}
/* Player must be in the playing state or the flag on the
* the command must be zero for the user to use the command -
* otherwise, a player cam save, be in the play_again state, and
* the map they were on getsswapped out, yet things that try to look
* at the map causes a crash. If the command is valid, but
* one they can't use, we still swallow it up.
*/
if (pl)
for (i = 0; player_commands[i].cmdname != NULL; i++) {
if (strcmp((char *)ns->inbuf.buf+2, player_commands[i].cmdname) == 0) {
if (pl->state == ST_PLAYING || player_commands[i].flag == 0)
player_commands[i].cmdproc((char *)data, len, pl);
SockList_ResetRead(&ns->inbuf);
return;
}
}
/* If we get here, we didn't find a valid command. Logging
* this might be questionable, because a broken client/malicious
* user could certainly send a whole bunch of invalid commands.
*/
LOG(llevDebug, "Bad command from client (%s)\n", ns->inbuf.buf+2);
SockList_ResetRead(&ns->inbuf);
}
} | false | false | false | false | false | 0 |
ap_proxyerror(request_rec *r, int statuscode, const char *message)
{
const char *uri = ap_escape_html(r->pool, r->uri);
apr_table_setn(r->notes, "error-notes",
apr_pstrcat(r->pool,
"The proxy server could not handle the request <em><a href=\"",
uri, "\">", ap_escape_html(r->pool, r->method), " ", uri,
"</a></em>.<p>\n"
"Reason: <strong>", ap_escape_html(r->pool, message),
"</strong></p>",
NULL));
/* Allow "error-notes" string to be printed by ap_send_error_response() */
apr_table_setn(r->notes, "verbose-error-to", "*");
r->status_line = apr_psprintf(r->pool, "%3.3u Proxy Error", statuscode);
ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00898) "%s returned by %s", message,
r->uri);
return statuscode;
} | false | false | false | false | false | 0 |
nls_list_add(nls_node *ent, nls_node *item)
{
nls_list *list;
nls_node *tail, *new;
tail = nls_list_tail_entry(ent);
list = &(tail->nn_list);
new = nls_list_new(item);
if (!new) {
return 1;
}
list->nl_rest = nls_grab(new);
return 0;
} | false | false | false | false | false | 0 |
ep_alloc_request(struct usb_ep *ep, gfp_t gfp_flags)
{
struct ci_hw_req *hwreq = NULL;
if (ep == NULL)
return NULL;
hwreq = kzalloc(sizeof(struct ci_hw_req), gfp_flags);
if (hwreq != NULL) {
INIT_LIST_HEAD(&hwreq->queue);
INIT_LIST_HEAD(&hwreq->tds);
}
return (hwreq == NULL) ? NULL : &hwreq->req;
} | false | false | false | false | false | 0 |
ssh_auth_reply_default(ssh_session session,int partial) {
char methods_c[128] = {0};
ssh_string methods = NULL;
int rc = SSH_ERROR;
if (buffer_add_u8(session->out_buffer, SSH2_MSG_USERAUTH_FAILURE) < 0) {
return rc;
}
if (session->auth_methods == 0) {
session->auth_methods = SSH_AUTH_METHOD_PUBLICKEY | SSH_AUTH_METHOD_PASSWORD;
}
if (session->auth_methods & SSH_AUTH_METHOD_PUBLICKEY) {
strncat(methods_c, "publickey,",
sizeof(methods_c) - strlen(methods_c) - 1);
}
if (session->auth_methods & SSH_AUTH_METHOD_GSSAPI_MIC){
strncat(methods_c,"gssapi-with-mic,",
sizeof(methods_c) - strlen(methods_c) - 1);
}
if (session->auth_methods & SSH_AUTH_METHOD_INTERACTIVE) {
strncat(methods_c, "keyboard-interactive,",
sizeof(methods_c) - strlen(methods_c) - 1);
}
if (session->auth_methods & SSH_AUTH_METHOD_PASSWORD) {
strncat(methods_c, "password,",
sizeof(methods_c) - strlen(methods_c) - 1);
}
if (session->auth_methods & SSH_AUTH_METHOD_HOSTBASED) {
strncat(methods_c, "hostbased,",
sizeof(methods_c) - strlen(methods_c) - 1);
}
if (methods_c[0] == '\0' || methods_c[strlen(methods_c)-1] != ',') {
return SSH_ERROR;
}
/* Strip the comma. */
methods_c[strlen(methods_c) - 1] = '\0'; // strip the comma. We are sure there is at
SSH_LOG(SSH_LOG_PACKET,
"Sending a auth failure. methods that can continue: %s", methods_c);
methods = ssh_string_from_char(methods_c);
if (methods == NULL) {
goto error;
}
if (buffer_add_ssh_string(session->out_buffer, methods) < 0) {
goto error;
}
if (partial) {
if (buffer_add_u8(session->out_buffer, 1) < 0) {
goto error;
}
} else {
if (buffer_add_u8(session->out_buffer, 0) < 0) {
goto error;
}
}
rc = packet_send(session);
error:
ssh_string_free(methods);
return rc;
} | false | false | false | false | false | 0 |
readilist(ivec,z,n0,n1,pad)
char *z;
int *ivec, n0, n1, pad;
{ int i, n, nd;
n = 1;
for (i=0; i<strlen(z); i++)
if (z[i]==',') { z[i]=' '; n++; }
if (n>n1)
{ WARN(("too many items in ilist"));
n = n1;
}
for (i=0; i<n; i++)
{ nd = sscanf(z,"%d",&ivec[i]);
if (nd!=1) WARN(("problem scaning ilist %s",&ivec[i]));
if (i<n-1) while (*z!=' ') z++;
}
if (pad)
{ for (i=n; i<n1; i++) ivec[i] = ivec[0];
n = n1;
}
if (n<n0) WARN(("too few items in ilist"));
return(n);
} | false | false | false | false | false | 0 |
storeLastIndex()
{
// if first run, or invalid previous index
if (lastIndex[1] < 0 || lastIndex[1] >= q->count()) {
lastIndex[0] = q->currentIndex();
} else {
lastIndex[0] = lastIndex[1];
}
lastIndex[1] = q->currentIndex();
} | false | false | false | false | false | 0 |
sinfo_balance_companion_matrix (double *m, size_t nc)
{
int not_converged = 1;
double row_norm = 0;
double col_norm = 0;
while (not_converged)
{
size_t i, j;
double g, f, s;
not_converged = 0;
for (i = 0; i < nc; i++)
{
/* column norm, excluding the diagonal */
if (i != nc - 1)
{
col_norm = fabs (MAT (m, i + 1, i, nc));
}
else
{
col_norm = 0;
for (j = 0; j < nc - 1; j++)
{
col_norm += fabs (MAT (m, j, nc - 1, nc));
}
}
/* row norm, excluding the diagonal */
if (i == 0)
{
row_norm = fabs (MAT (m, 0, nc - 1, nc));
}
else if (i == nc - 1)
{
row_norm = fabs (MAT (m, i, i - 1, nc));
}
else
{
row_norm = (fabs (MAT (m, i, i - 1, nc))
+ fabs (MAT (m, i, nc - 1, nc)));
}
if (col_norm == 0 || row_norm == 0)
{
continue;
}
g = row_norm / RADIX;
f = 1;
s = col_norm + row_norm;
while (col_norm < g)
{
f *= RADIX;
col_norm *= RADIX2;
}
g = row_norm * RADIX;
while (col_norm > g)
{
f /= RADIX;
col_norm /= RADIX2;
}
if ((row_norm + col_norm) < 0.95 * s * f)
{
not_converged = 1;
g = 1 / f;
if (i == 0)
{
MAT (m, 0, nc - 1, nc) *= g;
}
else
{
MAT (m, i, i - 1, nc) *= g;
MAT (m, i, nc - 1, nc) *= g;
}
if (i == nc - 1)
{
for (j = 0; j < nc; j++)
{
MAT (m, j, i, nc) *= f;
}
}
else
{
MAT (m, i + 1, i, nc) *= f;
}
}
}
}
} | false | false | false | false | false | 0 |
hb_string_isdigit(gchar *str)
{
gboolean valid = TRUE;
while(*str && valid)
valid = g_ascii_isdigit(*str++);
return valid;
} | false | false | false | false | false | 0 |
hashcash_valid_for( time_t token_time, long validity_period,
long grace_period, time_t now_time )
{
long expiry_time = 0 ;
/* for ever -- return infinity */
if ( validity_period == 0 ) { return HASHCASH_VALID_FOREVER; }
/* future date in token */
if ( token_time > now_time + grace_period ) {
return HASHCASH_VALID_IN_FUTURE;
}
expiry_time = token_time + validity_period;
if ( expiry_time + grace_period > now_time ) {
/* valid return seconds left */
return expiry_time + grace_period - now_time;
}
return HASHCASH_EXPIRED; /* otherwise expired */
} | false | false | false | false | false | 0 |
tray_added (NaTrayManager *manager,
GtkWidget *icon,
TraysScreen *trays_screen)
{
NaTray *tray;
NaTrayPrivate *priv;
int position;
tray = get_tray (trays_screen);
if (tray == NULL)
return;
priv = tray->priv;
g_assert (priv->trays_screen == trays_screen);
g_hash_table_insert (trays_screen->icon_table, icon, tray);
position = find_icon_position (tray, icon);
gtk_box_pack_start (GTK_BOX (priv->box), icon, FALSE, FALSE, 0);
gtk_box_reorder_child (GTK_BOX (priv->box), icon, position);
gtk_widget_show (icon);
} | false | false | false | false | false | 0 |
flipToLittleEndian(void* pData, size_t size, size_t count)
{
if(mFlipEndian)
{
Bitwise::bswapChunks(pData, size, count);
}
} | false | false | false | false | false | 0 |
local_connect(
git_transport *transport,
const char *url,
git_cred_acquire_cb cred_acquire_cb,
void *cred_acquire_payload,
int direction, int flags)
{
git_repository *repo;
int error;
transport_local *t = (transport_local *) transport;
const char *path;
git_buf buf = GIT_BUF_INIT;
GIT_UNUSED(cred_acquire_cb);
GIT_UNUSED(cred_acquire_payload);
if (t->connected)
return 0;
t->url = git__strdup(url);
GITERR_CHECK_ALLOC(t->url);
t->direction = direction;
t->flags = flags;
/* 'url' may be a url or path; convert to a path */
if ((error = git_path_from_url_or_path(&buf, url)) < 0) {
git_buf_free(&buf);
return error;
}
path = git_buf_cstr(&buf);
error = git_repository_open(&repo, path);
git_buf_free(&buf);
if (error < 0)
return -1;
t->repo = repo;
if (store_refs(t) < 0)
return -1;
t->connected = 1;
return 0;
} | false | false | false | false | false | 0 |
ax25_aton_entry(const char *name, char *buf)
{
int ct = 0;
int ssid = 0;
const char *p = name;
char c;
while (ct < 6) {
c = toupper(*p);
if (c == '-' || c == '\0')
break;
if (!isalnum(c)) {
printf("axutils: invalid symbol in callsign '%s'\n", name);
return -1;
}
buf[ct] = c << 1;
p++;
ct++;
}
while (ct < 6) {
buf[ct] = ' ' << 1;
ct++;
}
if (*p != '\0') {
p++;
if (sscanf(p, "%d", &ssid) != 1 || ssid < 0 || ssid > 15) {
printf("axutils: SSID must follow '-' and be numeric in the range 0-15 - '%s'\n", name);
return -1;
}
}
buf[6] = ((ssid + '0') << 1) & 0x1E;
return 0;
} | false | false | false | false | false | 0 |
S_incpush_if_exists(pTHX_ AV *const av, SV *dir, SV *const stem)
{
dVAR;
Stat_t tmpstatbuf;
PERL_ARGS_ASSERT_INCPUSH_IF_EXISTS;
if (PerlLIO_stat(SvPVX_const(dir), &tmpstatbuf) >= 0 &&
S_ISDIR(tmpstatbuf.st_mode)) {
av_push(av, dir);
dir = newSVsv(stem);
} else {
/* Truncate dir back to stem. */
SvCUR_set(dir, SvCUR(stem));
}
return dir;
} | false | false | false | false | false | 0 |
dentry_lru_add(struct dentry *dentry)
{
if (unlikely(!(dentry->d_flags & DCACHE_LRU_LIST)))
d_lru_add(dentry);
} | false | false | false | false | false | 0 |
input_string_internal (struct data_in *data_in, struct lto_input_block *ib,
unsigned int *rlen)
{
struct lto_input_block str_tab;
unsigned int len;
unsigned int loc;
const char *result;
loc = lto_input_uleb128 (ib);
LTO_INIT_INPUT_BLOCK (str_tab, data_in->strings, loc, data_in->strings_len);
len = lto_input_uleb128 (&str_tab);
*rlen = len;
if (str_tab.p + len > data_in->strings_len)
internal_error ("bytecode stream: string too long for the string table");
result = (const char *)(data_in->strings + str_tab.p);
return result;
} | false | false | false | false | false | 0 |
assignchaingapcostfunction(
GtChain2Dimkind chainkind,
bool gapsL1)
{
if (chainkind == GLOBALCHAININGWITHOVERLAPS)
{
return gt_chain2dim_overlapcost;
}
if (chainkind != GLOBALCHAININGALLCHAINS && chainkind != GLOBALCHAINING)
{
if (gapsL1)
{
return gapcostL1;
}
return gapcostCc;
}
return NULL;
} | false | false | false | false | false | 0 |
ChangeXHeight(FontViewBase *fv,CharViewBase *cv, struct xheightinfo *xi) {
int cnt, enc, gid;
SplineChar *sc;
SplineFont *sf = fv!=NULL ? fv->sf : cv->sc->parent;
int layer = fv!=NULL ? fv->active_layer : CVLayer(cv);
extern int detect_diagonal_stems;
int dds = detect_diagonal_stems;
detect_diagonal_stems = true;
if ( cv!=NULL )
SCChangeXHeight(cv->sc,layer,xi);
else {
cnt=0;
for ( enc=0; enc<fv->map->enccount; ++enc ) {
if ( (gid=fv->map->map[enc])!=-1 && fv->selected[enc] && (sc=sf->glyphs[gid])!=NULL ) {
++cnt;
sc->ticked = false;
}
}
if ( cnt!=0 ) {
ff_progress_start_indicator(10,_("Change X-Height"),
_("Change X-Height"),NULL,cnt,1);
for ( enc=0; enc<fv->map->enccount; ++enc ) {
if ( (gid=fv->map->map[enc])!=-1 && fv->selected[enc] &&
(sc=sf->glyphs[gid])!=NULL && !sc->ticked ) {
if ( !FVChangeXHeight(fv,sc,layer,xi))
break;
}
}
ff_progress_end_indicator();
}
}
detect_diagonal_stems = dds;
} | false | false | false | false | false | 0 |
cgraph_node_can_be_local_p (struct cgraph_node *node)
{
return (!node->symbol.address_taken
&& !cgraph_for_node_and_aliases (node,
cgraph_node_cannot_be_local_p_1,
NULL, true));
} | false | false | false | false | false | 0 |
hrequest_new(void)
{
hrequest_t *req;
if (!(req = (hrequest_t *) malloc(sizeof(hrequest_t)))) {
log_error1("malloc failed");
return NULL;
}
req->method = HTTP_REQUEST_GET;
req->version = HTTP_1_1;
req->query = NULL;
req->header = NULL;
req->in = NULL;
req->attachments = NULL;
req->content_type = NULL;
return req;
} | false | false | false | false | false | 0 |
b64_encode(struct archive_string *as, const unsigned char *p, size_t len)
{
int c;
for (; len >= 3; p += 3, len -= 3) {
c = p[0] >> 2;
archive_strappend_char(as, base64[c]);
c = ((p[0] & 0x03) << 4) | ((p[1] & 0xf0) >> 4);
archive_strappend_char(as, base64[c]);
c = ((p[1] & 0x0f) << 2) | ((p[2] & 0xc0) >> 6);
archive_strappend_char(as, base64[c]);
c = p[2] & 0x3f;
archive_strappend_char(as, base64[c]);
}
if (len > 0) {
c = p[0] >> 2;
archive_strappend_char(as, base64[c]);
c = (p[0] & 0x03) << 4;
if (len == 1) {
archive_strappend_char(as, base64[c]);
archive_strappend_char(as, '=');
archive_strappend_char(as, '=');
} else {
c |= (p[1] & 0xf0) >> 4;
archive_strappend_char(as, base64[c]);
c = (p[1] & 0x0f) << 2;
archive_strappend_char(as, base64[c]);
archive_strappend_char(as, '=');
}
}
archive_strappend_char(as, '\n');
} | false | false | false | false | false | 0 |
pm860x_bulk_read(struct i2c_client *i2c, int reg,
int count, unsigned char *buf)
{
struct pm860x_chip *chip = i2c_get_clientdata(i2c);
struct regmap *map = (i2c == chip->client) ? chip->regmap
: chip->regmap_companion;
int ret;
ret = regmap_raw_read(map, reg, buf, count);
return ret;
} | false | false | false | false | false | 0 |
features_show(struct device *_d,
struct device_attribute *attr, char *buf)
{
struct virtio_device *dev = dev_to_virtio(_d);
unsigned int i;
ssize_t len = 0;
/* We actually represent this as a bitstring, as it could be
* arbitrary length in future. */
for (i = 0; i < sizeof(dev->features)*8; i++)
len += sprintf(buf+len, "%c",
__virtio_test_bit(dev, i) ? '1' : '0');
len += sprintf(buf+len, "\n");
return len;
} | false | true | false | false | false | 1 |
p_do_2nd_filter_dialogs(char *filter_procname,
GapFiltPdbApplyMode l_apply_mode,
char *last_frame_filename,
gint32 sel_mode, gint32 sel_case,
gint32 sel_invert, char *sel_pattern,
gboolean operate_on_layermask
)
{
gint32 l_drawable_id;
gint32 l_dpy_id;
int l_rc;
int l_idx;
static char l_key_to[512];
static char l_key_from[512];
gint32 l_last_image_id;
GapModLayliElem *l_layli_ptr;
gint l_nlayers;
gint32 l_sel_cnt;
gint l_plugin_data_len;
l_layli_ptr = NULL;
l_rc = -1; /* assume cancel or error */
l_last_image_id = -1;
l_dpy_id = -1;
/* 2.nd INTERACTIV Filtercall dialog */
/* --------------------------------- */
if(last_frame_filename == NULL)
{
return (-1); /* there is no 2.nd frame for 2.nd filter call */
}
if(p_pitstop_dialog(0, filter_procname) < 0)
goto cleanup;
/* load last frame into temporary image */
l_last_image_id = gap_lib_load_image(last_frame_filename);
if (l_last_image_id < 0)
goto cleanup;
/* get informations (id, visible, selected) about all layers */
l_layli_ptr = gap_mod_alloc_layli(l_last_image_id, &l_sel_cnt, &l_nlayers,
sel_mode, sel_case, sel_invert, sel_pattern);
if (l_layli_ptr == NULL)
goto cleanup;
/* get 1.st selected layer (of last handled frame in range ) */
l_idx = gap_mod_get_1st_selected(l_layli_ptr, l_nlayers);
if(l_idx < 0)
{
g_message (_("Modify Layers cancelled: No layer selected in last handled frame"));
goto cleanup;
}
l_drawable_id = l_layli_ptr[l_idx].layer_id;
if(operate_on_layermask)
{
l_drawable_id = gimp_layer_get_mask(l_layli_ptr[l_idx].layer_id);
if(l_drawable_id < 0)
{
g_message (_("Modify Layers cancelled: first selected layer \"%s\"\nin last frame has no layermask"),
gimp_drawable_get_name(l_layli_ptr[l_idx].layer_id)
);
goto cleanup;
}
}
/* open a view for the last handled frame */
l_dpy_id = gimp_display_new (l_last_image_id);
/* 2.nd INTERACTIV Filtercall dialog */
/* --------------------------------- */
l_rc = gap_filt_pdb_call_plugin(filter_procname, l_last_image_id, l_drawable_id, GIMP_RUN_INTERACTIVE);
/* get values, then store with suffix "-ITER-TO" */
l_plugin_data_len = gap_filt_pdb_get_data(filter_procname);
if(l_plugin_data_len <= 0)
goto cleanup;
g_snprintf(l_key_to, sizeof(l_key_to), "%s%s", filter_procname, GAP_ITER_TO_SUFFIX);
gap_filt_pdb_set_data(l_key_to, l_plugin_data_len);
/* get FROM values */
g_snprintf(l_key_from, sizeof(l_key_from), "%s%s", filter_procname, GAP_ITER_FROM_SUFFIX);
l_plugin_data_len = gap_filt_pdb_get_data(l_key_from);
gap_filt_pdb_set_data(filter_procname, l_plugin_data_len);
l_rc = p_pitstop_dialog(1, filter_procname);
cleanup:
if(l_last_image_id >= 0)
{
gimp_image_delete(l_last_image_id);
}
if(l_dpy_id >= 0)
{
gimp_display_delete(l_dpy_id);
}
if(l_layli_ptr != NULL)
{
g_free(l_layli_ptr);
}
return (l_rc);
} | true | true | false | false | false | 1 |
do_crypt(FILE* in, FILE* out, int action, char* key_str){
/* Local Vars */
/* Buffers */
unsigned char inbuf[BLOCKSIZE];
int inlen;
/* Allow enough space in output buffer for additional cipher block */
unsigned char outbuf[BLOCKSIZE + EVP_MAX_BLOCK_LENGTH];
int outlen;
int writelen;
/* OpenSSL libcrypto vars */
EVP_CIPHER_CTX ctx;
unsigned char key[32];
unsigned char iv[32];
int nrounds = 5;
/* tmp vars */
int i;
/* Setup Encryption Key and Cipher Engine if in cipher mode */
if(action >= 0){
if(!key_str){
/* Error */
fprintf(stderr, "Key_str must not be NULL\n");
return 0;
}
/* Build Key from String */
i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), NULL,
(unsigned char*)key_str, strlen(key_str), nrounds, key, iv);
if (i != 32) {
/* Error */
fprintf(stderr, "Key size is %d bits - should be 256 bits\n", i*8);
return 0;
}
/* Init Engine */
EVP_CIPHER_CTX_init(&ctx);
EVP_CipherInit_ex(&ctx, EVP_aes_256_cbc(), NULL, key, iv, action);
}
/* Loop through Input File*/
for(;;){
/* Read Block */
inlen = fread(inbuf, sizeof(*inbuf), BLOCKSIZE, in);
if(inlen <= 0){
/* EOF -> Break Loop */
break;
}
/* If in cipher mode, perform cipher transform on block */
if(action >= 0){
if(!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
{
/* Error */
EVP_CIPHER_CTX_cleanup(&ctx);
return 0;
}
}
/* If in pass-through mode. copy block as is */
else{
memcpy(outbuf, inbuf, inlen);
outlen = inlen;
}
/* Write Block */
writelen = fwrite(outbuf, sizeof(*outbuf), outlen, out);
if(writelen != outlen){
/* Error */
perror("fwrite error");
EVP_CIPHER_CTX_cleanup(&ctx);
return 0;
}
}
/* If in cipher mode, handle necessary padding */
if(action >= 0){
/* Handle remaining cipher block + padding */
if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
{
/* Error */
EVP_CIPHER_CTX_cleanup(&ctx);
return 0;
}
/* Write remainign cipher block + padding*/
fwrite(outbuf, sizeof(*inbuf), outlen, out);
EVP_CIPHER_CTX_cleanup(&ctx);
}
/* Success */
return 1;
} | false | false | false | false | true | 1 |
e_filter_part_eq (EFilterPart *part_a,
EFilterPart *part_b)
{
GList *link_a, *link_b;
g_return_val_if_fail (E_IS_FILTER_PART (part_a), FALSE);
g_return_val_if_fail (E_IS_FILTER_PART (part_b), FALSE);
if (g_strcmp0 (part_a->name, part_b->name) != 0)
return FALSE;
if (g_strcmp0 (part_a->title, part_b->title) != 0)
return FALSE;
if (g_strcmp0 (part_a->code, part_b->code) != 0)
return FALSE;
link_a = part_a->elements;
link_b = part_b->elements;
while (link_a != NULL && link_b != NULL) {
EFilterElement *element_a = link_a->data;
EFilterElement *element_b = link_b->data;
if (!e_filter_element_eq (element_a, element_b))
return FALSE;
link_a = g_list_next (link_a);
link_b = g_list_next (link_b);
}
if (link_a != NULL || link_b != NULL)
return FALSE;
return TRUE;
} | false | false | false | false | false | 0 |
ADLStateToInternal(const std::string& s, bool optional, Logger& logger) {
if(s == "ACCEPTED") {
return "ACCEPTED";
} else if(s == "PREPROCESSING") {
return "PREPARING";
} else if(s == "PROCESSING") {
return "INLRMS";
} else if(s == "PROCESSING-ACCEPTING") {
} else if(s == "PROCESSING-QUEUED") {
} else if(s == "PROCESSING-RUNNING") {
} else if(s == "POSTPROCESSING") {
return "FINISHING";
} else if(s == "TERMINAL") {
return "FINISHED";
};
logger.msg(optional?WARNING:ERROR, "[ADLParser] Unsupported EMI ES state %s.",s);
return "";
} | false | false | false | false | false | 0 |
acpi_pad_notify(acpi_handle handle, u32 event,
void *data)
{
struct acpi_device *device = data;
switch (event) {
case ACPI_PROCESSOR_AGGREGATOR_NOTIFY:
acpi_pad_handle_notify(handle);
acpi_bus_generate_netlink_event(device->pnp.device_class,
dev_name(&device->dev), event, 0);
break;
default:
pr_warn("Unsupported event [0x%x]\n", event);
break;
}
} | false | false | false | false | false | 0 |
byteoffset (lua_State *L) {
size_t len;
const char *s = luaL_checklstring(L, 1, &len);
lua_Integer n = luaL_checkinteger(L, 2);
lua_Integer posi = (n >= 0) ? 1 : len + 1;
posi = u_posrelat(luaL_optinteger(L, 3, posi), len);
luaL_argcheck(L, 1 <= posi && --posi <= (lua_Integer)len, 3,
"position out of range");
if (n == 0) {
/* find beginning of current byte sequence */
while (posi > 0 && iscont(s + posi)) posi--;
}
else {
if (iscont(s + posi))
luaL_error(L, "initial position is a continuation byte");
if (n < 0) {
while (n < 0 && posi > 0) { /* move back */
do { /* find beginning of previous character */
posi--;
} while (posi > 0 && iscont(s + posi));
n++;
}
}
else {
n--; /* do not move for 1st character */
while (n > 0 && posi < (lua_Integer)len) {
do { /* find beginning of next character */
posi++;
} while (iscont(s + posi)); /* (cannot pass final '\0') */
n--;
}
}
}
if (n == 0) /* did it find given character? */
lua_pushinteger(L, posi + 1);
else /* no such character */
lua_pushnil(L);
return 1;
} | false | false | false | false | false | 0 |
mprCreateHash(int hashSize, int flags)
{
MprHash *hash;
if ((hash = mprAllocObj(MprHash, manageHashTable)) == 0) {
return 0;
}
if (hashSize < MPR_DEFAULT_HASH_SIZE) {
hashSize = MPR_DEFAULT_HASH_SIZE;
}
if ((hash->buckets = mprAllocZeroed(sizeof(MprKey*) * hashSize)) == 0) {
return NULL;
}
hash->size = hashSize;
hash->flags = flags;
hash->length = 0;
hash->mutex = mprCreateLock();
#if BLD_CHAR_LEN > 1
if (hash->flags & MPR_HASH_UNICODE) {
if (hash->flags & MPR_HASH_CASELESS) {
hash->fn = (MprHashProc) whashlower;
} else {
hash->fn = (MprHashProc) whash;
}
} else
#endif
{
if (hash->flags & MPR_HASH_CASELESS) {
hash->fn = (MprHashProc) shashlower;
} else {
hash->fn = (MprHashProc) shash;
}
}
return hash;
} | false | false | false | false | false | 0 |
solveIntegerProgramIneq(IntegerMatrix const &M, IntegerVector const &rightHandSide, IntegerVector &solution)
{
int d=M.getHeight();
int n=M.getWidth();
IntegerMatrix M2(d,n+d);
for(int i=0;i<d;i++)
{
for(int j=0;j<n;j++)
M2[i][j]=M[i][j];
M2[i][n+i]=-1;
}
AsciiPrinter P(Stderr);
P.printVectorList(M2.getRows());
IntegerVectorList b=latticeIdealRevLex(M2);
IntegerVector ret=IntegerVector(d+n);
{
IntegerVectorList::const_iterator i;
while((i=findImproving(b,ret))!=b.end())
{
ret-=*i;
}
}
solution=ret.subvector(n,n+d);
return ret.subvector(0,n).isZero();
} | false | false | false | false | false | 0 |
H5IMmake_image_8bit( hid_t loc_id,
const char *dset_name,
hsize_t width,
hsize_t height,
const unsigned char *buf )
{
hsize_t dims[IMAGE8_RANK];
/* Initialize the image dimensions */
dims[0] = height;
dims[1] = width;
/* Make the dataset */
if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buf ) < 0)
return -1;
/* Attach the CLASS attribute */
if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0)
return -1;
/* Attach the VERSION attribute */
if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0)
return -1;
/* Attach the IMAGE_SUBCLASS attribute */
if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0)
return -1;
return 0;
} | false | false | false | false | false | 0 |
get_base_socket_path (apr_pool_t *pool, xsp_data *conf)
{
if (conf->filename && conf->filename [0])
return conf->filename;
else
return get_default_socket_name (pool, conf->alias, SOCKET_FILE);
} | false | false | false | false | false | 0 |
set_request_path_attr(struct inode *rinode, struct dentry *rdentry,
const char *rpath, u64 rino,
const char **ppath, int *pathlen,
u64 *ino, int *freepath)
{
int r = 0;
if (rinode) {
r = build_inode_path(rinode, ppath, pathlen, ino, freepath);
dout(" inode %p %llx.%llx\n", rinode, ceph_ino(rinode),
ceph_snap(rinode));
} else if (rdentry) {
r = build_dentry_path(rdentry, ppath, pathlen, ino, freepath);
dout(" dentry %p %llx/%.*s\n", rdentry, *ino, *pathlen,
*ppath);
} else if (rpath || rino) {
*ino = rino;
*ppath = rpath;
*pathlen = rpath ? strlen(rpath) : 0;
dout(" path %.*s\n", *pathlen, rpath);
}
return r;
} | false | false | false | false | false | 0 |
xfs_qm_init_quotainfo(
xfs_mount_t *mp)
{
xfs_quotainfo_t *qinf;
int error;
xfs_dquot_t *dqp;
ASSERT(XFS_IS_QUOTA_RUNNING(mp));
qinf = mp->m_quotainfo = kmem_zalloc(sizeof(xfs_quotainfo_t), KM_SLEEP);
error = list_lru_init(&qinf->qi_lru);
if (error)
goto out_free_qinf;
/*
* See if quotainodes are setup, and if not, allocate them,
* and change the superblock accordingly.
*/
error = xfs_qm_init_quotainos(mp);
if (error)
goto out_free_lru;
INIT_RADIX_TREE(&qinf->qi_uquota_tree, GFP_NOFS);
INIT_RADIX_TREE(&qinf->qi_gquota_tree, GFP_NOFS);
INIT_RADIX_TREE(&qinf->qi_pquota_tree, GFP_NOFS);
mutex_init(&qinf->qi_tree_lock);
/* mutex used to serialize quotaoffs */
mutex_init(&qinf->qi_quotaofflock);
/* Precalc some constants */
qinf->qi_dqchunklen = XFS_FSB_TO_BB(mp, XFS_DQUOT_CLUSTER_SIZE_FSB);
qinf->qi_dqperchunk = xfs_calc_dquots_per_chunk(qinf->qi_dqchunklen);
mp->m_qflags |= (mp->m_sb.sb_qflags & XFS_ALL_QUOTA_CHKD);
/*
* We try to get the limits from the superuser's limits fields.
* This is quite hacky, but it is standard quota practice.
*
* We look at the USR dquot with id == 0 first, but if user quotas
* are not enabled we goto the GRP dquot with id == 0.
* We don't really care to keep separate default limits for user
* and group quotas, at least not at this point.
*
* Since we may not have done a quotacheck by this point, just read
* the dquot without attaching it to any hashtables or lists.
*/
error = xfs_qm_dqread(mp, 0,
XFS_IS_UQUOTA_RUNNING(mp) ? XFS_DQ_USER :
(XFS_IS_GQUOTA_RUNNING(mp) ? XFS_DQ_GROUP :
XFS_DQ_PROJ),
XFS_QMOPT_DOWARN, &dqp);
if (!error) {
xfs_disk_dquot_t *ddqp = &dqp->q_core;
/*
* The warnings and timers set the grace period given to
* a user or group before he or she can not perform any
* more writing. If it is zero, a default is used.
*/
qinf->qi_btimelimit = ddqp->d_btimer ?
be32_to_cpu(ddqp->d_btimer) : XFS_QM_BTIMELIMIT;
qinf->qi_itimelimit = ddqp->d_itimer ?
be32_to_cpu(ddqp->d_itimer) : XFS_QM_ITIMELIMIT;
qinf->qi_rtbtimelimit = ddqp->d_rtbtimer ?
be32_to_cpu(ddqp->d_rtbtimer) : XFS_QM_RTBTIMELIMIT;
qinf->qi_bwarnlimit = ddqp->d_bwarns ?
be16_to_cpu(ddqp->d_bwarns) : XFS_QM_BWARNLIMIT;
qinf->qi_iwarnlimit = ddqp->d_iwarns ?
be16_to_cpu(ddqp->d_iwarns) : XFS_QM_IWARNLIMIT;
qinf->qi_rtbwarnlimit = ddqp->d_rtbwarns ?
be16_to_cpu(ddqp->d_rtbwarns) : XFS_QM_RTBWARNLIMIT;
qinf->qi_bhardlimit = be64_to_cpu(ddqp->d_blk_hardlimit);
qinf->qi_bsoftlimit = be64_to_cpu(ddqp->d_blk_softlimit);
qinf->qi_ihardlimit = be64_to_cpu(ddqp->d_ino_hardlimit);
qinf->qi_isoftlimit = be64_to_cpu(ddqp->d_ino_softlimit);
qinf->qi_rtbhardlimit = be64_to_cpu(ddqp->d_rtb_hardlimit);
qinf->qi_rtbsoftlimit = be64_to_cpu(ddqp->d_rtb_softlimit);
xfs_qm_dqdestroy(dqp);
} else {
qinf->qi_btimelimit = XFS_QM_BTIMELIMIT;
qinf->qi_itimelimit = XFS_QM_ITIMELIMIT;
qinf->qi_rtbtimelimit = XFS_QM_RTBTIMELIMIT;
qinf->qi_bwarnlimit = XFS_QM_BWARNLIMIT;
qinf->qi_iwarnlimit = XFS_QM_IWARNLIMIT;
qinf->qi_rtbwarnlimit = XFS_QM_RTBWARNLIMIT;
}
qinf->qi_shrinker.count_objects = xfs_qm_shrink_count;
qinf->qi_shrinker.scan_objects = xfs_qm_shrink_scan;
qinf->qi_shrinker.seeks = DEFAULT_SEEKS;
qinf->qi_shrinker.flags = SHRINKER_NUMA_AWARE;
register_shrinker(&qinf->qi_shrinker);
return 0;
out_free_lru:
list_lru_destroy(&qinf->qi_lru);
out_free_qinf:
kmem_free(qinf);
mp->m_quotainfo = NULL;
return error;
} | false | false | false | false | false | 0 |
wtp_pdu_type(Octstr *data) {
long bitpos;
long lastpos = -1;
long lastnumbits = -1;
long lastval = -1;
int thistype;
/* This code looks slow, but an optimizing compiler will
* reduce it considerably. gcc -O2 will produce a single
* call to octstr_get_bits, folllowed by a sequence of
* tests on lastval. */
/* Only UINT and RESERVED fields may precede the TYPE */
#define PDU(name, docstring, fields, is_valid) \
bitpos = 0; \
thistype = name; \
fields
#define UINT(field, docstring, bits) bitpos += (bits);
#define UINTVAR(field, docstring)
#define OCTSTR(field, docstring, lengthfield)
#define REST(field, docstring)
#define TYPE(bits, value) \
if ((bits) != lastnumbits || bitpos != lastpos) { \
lastval = octstr_get_bits(data, bitpos, (bits)); \
} \
if (lastval == (value)) \
return thistype; \
lastnumbits = (bits); \
lastpos = bitpos;
#define RESERVED(bits) bitpos += (bits);
#define TPI(confield)
#include "wtp_pdu.def"
#undef TPI
#undef RESERVED
#undef TYPE
#undef REST
#undef OCTSTR
#undef UINTVAR
#undef UINT
#undef PDU
return -1;
} | false | false | false | false | false | 0 |
SyncChr(void) {
int i;
for (i = 0; i < 8; i++)
setchr1(i << 10, chr[i]);
setmirror(mirr ^ 1);
} | false | false | false | false | false | 0 |
iscsi_tcp_event_handler(int fd, int events, void *data)
{
struct iscsi_connection *conn = (struct iscsi_connection *) data;
if (events & EPOLLIN)
iscsi_rx_handler(conn);
if (conn->state == STATE_CLOSE)
dprintf("connection closed\n");
if (conn->state != STATE_CLOSE && events & EPOLLOUT)
iscsi_tx_handler(conn);
if (conn->state == STATE_CLOSE) {
dprintf("connection closed %p\n", conn);
conn_close(conn);
}
} | false | false | false | false | false | 0 |
ch_wrap(Var *var)
{
if (screen_mode < 0) /* e.g., called by init_variables() */
return 1;
redraw_window(display_screen, 0);
transmit_window_size();
return 1;
} | false | false | false | false | false | 0 |
globus_l_gfs_data_active_kickout(
void * user_arg)
{
globus_l_gfs_data_active_bounce_t * bounce_info;
globus_gfs_finished_info_t reply;
GlobusGFSName(globus_l_gfs_data_active_kickout);
GlobusGFSDebugEnter();
bounce_info = (globus_l_gfs_data_active_bounce_t *) user_arg;
memset(&reply, '\0', sizeof(globus_gfs_finished_info_t));
reply.type = GLOBUS_GFS_OP_ACTIVE;
reply.id = bounce_info->id;
reply.result = bounce_info->result;
reply.info.data.bi_directional = bounce_info->bi_directional;
/* as soon as we finish the data handle can be in play, set its
state appropriately. if not success then we never created a
handle */
if(bounce_info->result == GLOBUS_SUCCESS)
{
bounce_info->handle->state = GLOBUS_L_GFS_DATA_HANDLE_VALID;
bounce_info->handle->is_mine = GLOBUS_TRUE;
reply.info.data.data_arg = (void *) globus_handle_table_insert(
&bounce_info->handle->session_handle->handle_table,
bounce_info->handle,
1);
}
else
{
globus_assert(bounce_info->handle == NULL);
}
if(bounce_info->callback != NULL)
{
bounce_info->callback(
&reply,
bounce_info->user_arg);
}
else
{
globus_gfs_ipc_reply_finished(
bounce_info->ipc_handle,
&reply);
}
globus_free(bounce_info);
GlobusGFSDebugExit();
} | false | false | false | false | false | 0 |
set_rotation_rate (UDisksDrive *iface,
UDisksLinuxDevice *device)
{
gint rate;
if (!g_udev_device_get_sysfs_attr_as_boolean (device->udev_device, "queue/rotational"))
{
rate = 0;
}
else
{
rate = -1;
if (device->ata_identify_device_data != NULL)
{
guint word_217 = 0;
/* ATA8: 7.16 IDENTIFY DEVICE - ECh, PIO Data-In - Table 29 IDENTIFY DEVICE data
*
* Table 37 - Nominal Media Rotation Rate:
*
* 0000h Rate not reported
* 0001h Non-rotating media (e.g., solid state device)
* 0002h-0400h Reserved
* 0401h-FFFEh Nominal media rotation rate in rotations per minute (rpm) (e.g., 7200 rpm = 1C20h)
* FFFFh Reserved
*/
word_217 = udisks_ata_identify_get_word (device->ata_identify_device_data, 217);
if (word_217 == 0x0001)
rate = 0;
else if (word_217 >= 0x0401 && word_217 <= 0xfffe)
rate = word_217;
}
}
udisks_drive_set_rotation_rate (iface, rate);
} | false | false | false | false | false | 0 |
krb5int_fast_process_error(krb5_context context,
struct krb5int_fast_request_state *state,
krb5_error **err_replyptr,
krb5_pa_data ***out_padata,
krb5_boolean *retry)
{
krb5_error_code retval = 0;
krb5_error *err_reply = *err_replyptr;
krb5_pa_data *fx_error_pa;
krb5_pa_data **result = NULL;
krb5_data scratch = empty_data();
krb5_error *fx_error = NULL;
krb5_fast_response *fast_response = NULL;
if (out_padata)
*out_padata = NULL;
if (retry)
*retry = 0;
if (state->armor_key) {
retval = decode_krb5_padata_sequence(&err_reply->e_data, &result);
if (retval == 0)
retval = decrypt_fast_reply(context, state, result,
&fast_response);
if (retval) {
/*
* This can happen if the KDC does not understand FAST. We don't
* expect that, but treating it as the fatal error indicated by the
* KDC seems reasonable.
*/
if (retry != NULL)
*retry = 0;
krb5_free_pa_data(context, result);
return 0;
}
if (retval == 0) {
fx_error_pa = krb5int_find_pa_data(context, fast_response->padata,
KRB5_PADATA_FX_ERROR);
if (fx_error_pa == NULL) {
krb5_set_error_message(context, KRB5KDC_ERR_PREAUTH_FAILED,
_("Expecting FX_ERROR pa-data inside "
"FAST container"));
retval = KRB5KDC_ERR_PREAUTH_FAILED;
}
}
if (retval == 0) {
scratch = make_data(fx_error_pa->contents, fx_error_pa->length);
retval = decode_krb5_error(&scratch, &fx_error);
}
if (retval == 0) {
krb5_free_error(context, err_reply);
*err_replyptr = fx_error;
fx_error = NULL;
if (out_padata) {
*out_padata = fast_response->padata;
fast_response->padata = NULL;
}
/*
* If there is more than the fx_error padata, then we want
* to retry the error if a cookie is present
*/
if (retry != NULL) {
*retry = (*out_padata)[1] != NULL;
if (krb5int_find_pa_data(context, *out_padata,
KRB5_PADATA_FX_COOKIE) == NULL)
*retry = 0;
}
}
} else { /*not FAST*/
/* Possibly retry if there's any e_data to process. */
if (retry)
*retry = (err_reply->e_data.length > 0);
/* Try to decode e_data as pa-data or typed-data for out_padata. */
if (out_padata) {
retval = decode_krb5_padata_sequence(&err_reply->e_data,
out_padata);
if (retval != 0) {
(void)decode_krb5_typed_data(&err_reply->e_data, out_padata);
retval = 0;
}
}
}
krb5_free_pa_data(context, result);
krb5_free_fast_response(context, fast_response);
if (fx_error)
krb5_free_error(context, fx_error);
return retval;
} | false | false | false | true | false | 1 |
cgit_print_refs()
{
html("<table class='list nowrap'>");
if (ctx.qry.path && !strncmp(ctx.qry.path, "heads", 5))
cgit_print_branches(0);
else if (ctx.qry.path && !strncmp(ctx.qry.path, "tags", 4))
cgit_print_tags(0);
else {
cgit_print_branches(0);
html("<tr class='nohover'><td colspan='4'> </td></tr>");
cgit_print_tags(0);
}
html("</table>");
} | false | false | false | false | false | 0 |
minimal_update(int p) {
if (damage() & FL_DAMAGE_ALL) return; // don't waste time if it won't be done
if (damage() & FL_DAMAGE_EXPOSE) {
if (p < mu_p) mu_p = p;
} else {
mu_p = p;
}
damage(FL_DAMAGE_EXPOSE);
erase_cursor_only = 0;
} | false | false | false | false | false | 0 |
RemapValue(SDValue &N) {
DenseMap<SDValue, SDValue>::iterator I = ReplacedValues.find(N);
if (I != ReplacedValues.end()) {
// Use path compression to speed up future lookups if values get multiply
// replaced with other values.
RemapValue(I->second);
N = I->second;
// Note that it is possible to have N.getNode()->getNodeId() == NewNode at
// this point because it is possible for a node to be put in the map before
// being processed.
}
} | false | false | false | false | false | 0 |
vector_print(char *s, int n, real *x){
int i;
printf("%s{",s);
for (i = 0; i < n; i++) {
if (i > 0) printf(",");
printf("%f",x[i]);
}
printf("}\n");
} | false | false | false | false | false | 0 |
last_argument(void)
{
char **av = NULL;
char *p;
el_status_t s;
int ac;
if (H.Size == 1 || (p = (char *)H.Lines[H.Size - 2]) == NULL)
return el_ring_bell();
p = strdup(p);
if (!p)
return CSstay;
ac = argify(p, &av);
if (Repeat != NO_ARG)
s = Repeat < ac ? insert_string(av[Repeat]) : el_ring_bell();
else
s = ac ? insert_string(av[ac - 1]) : CSstay;
if (av)
free(av);
free(p);
return s;
} | false | false | false | false | false | 0 |
httpGetParam(HttpConn *conn, cchar *var, cchar *defaultValue)
{
MprHash *vars;
cchar *value;
vars = httpGetParams(conn);
value = mprLookupKey(vars, var);
return (value) ? value : defaultValue;
} | false | false | false | false | false | 0 |
Terminate(gn_data *data, struct gn_statemachine *state)
{
if (AT_DRVINST(state)) {
if (AT_DRVINST(state)->cached_capabilities) {
map_free(&(AT_DRVINST(state)->cached_capabilities));
AT_DRVINST(state)->cached_capabilities = NULL;
}
if (AT_DRVINST(state)->timezone) {
free(AT_DRVINST(state)->timezone);
AT_DRVINST(state)->timezone = NULL;
}
free(AT_DRVINST(state));
AT_DRVINST(state) = NULL;
}
return pgen_terminate(data, state);
} | false | false | false | false | false | 0 |
check_box_dirichlet (GfsBox * box, CompatPar * p)
{
FttDirection d;
for (d = 0; d < FTT_NEIGHBORS; d++)
if (GFS_IS_BOUNDARY (box->neighbor[d])) {
GfsBoundary * b = GFS_BOUNDARY (box->neighbor[d]);
GfsBc * bc = gfs_boundary_lookup_bc (b, p->lhs);
if (GFS_IS_BC_DIRICHLET (bc)) {
p->dirichlet = TRUE;
return;
}
}
} | false | false | false | false | false | 0 |
filewrjobfull(File *f, job j)
{
int nl;
fileaddjob(f, j);
nl = strlen(j->tube->name);
return
filewrite(f, j, &nl, sizeof nl) &&
filewrite(f, j, j->tube->name, nl) &&
filewrite(f, j, &j->r, sizeof j->r) &&
filewrite(f, j, j->body, j->r.body_size);
} | false | false | false | false | false | 0 |
tcp_idle_timeout(gpointer user_data)
{
struct server_data *server = user_data;
DBG("");
if (server == NULL)
return FALSE;
destroy_server(server);
return FALSE;
} | false | false | false | false | false | 0 |
ProcessBody( char* szBuffer, int nBufLength, bool bEOF )
{
bool MoreBodyNeeded = false;
for ( list<SignatureInfo>::iterator i = Signatures.begin(); i != Signatures.end(); ++i )
{
if ( i->Status == DKIM_SUCCESS )
{
if ( i->BodyCanonicalization == DKIM_CANON_SIMPLE )
{
if (nBufLength > 0)
{
while (i->EmptyLineCount > 0)
{
i->Hash( "\r\n", 2, true );
i->EmptyLineCount--;
}
i->Hash( szBuffer, nBufLength, true );
i->Hash( "\r\n", 2, true );
}
else
{
i->EmptyLineCount++;
if (bEOF)
i->Hash( "\r\n", 2, true);
}
}
else if ( i->BodyCanonicalization == DKIM_CANON_RELAXED )
{
CompressSWSP( szBuffer, nBufLength );
if (nBufLength > 0)
{
while (i->EmptyLineCount > 0)
{
i->Hash( "\r\n", 2, true );
i->EmptyLineCount--;
}
i->Hash( szBuffer, nBufLength, true );
if ( !bEOF )
i->Hash( "\r\n", 2, true);
}
else
i->EmptyLineCount++;
}
else if ( i->BodyCanonicalization == DKIM_CANON_NOWSP )
{
RemoveSWSP( szBuffer, nBufLength );
i->Hash( szBuffer, nBufLength, true );
}
if ( i->UnverifiedBodyCount == 0 )
MoreBodyNeeded = true;
}
}
if ( !MoreBodyNeeded )
return DKIM_FINISHED_BODY;
return DKIM_SUCCESS;
} | false | false | false | false | false | 0 |
il3945_hw_nic_init(struct il_priv *il)
{
int rc;
unsigned long flags;
struct il_rx_queue *rxq = &il->rxq;
spin_lock_irqsave(&il->lock, flags);
il3945_apm_init(il);
spin_unlock_irqrestore(&il->lock, flags);
il3945_set_pwr_vmain(il);
il3945_nic_config(il);
/* Allocate the RX queue, or reset if it is already allocated */
if (!rxq->bd) {
rc = il_rx_queue_alloc(il);
if (rc) {
IL_ERR("Unable to initialize Rx queue\n");
return -ENOMEM;
}
} else
il3945_rx_queue_reset(il, rxq);
il3945_rx_replenish(il);
il3945_rx_init(il, rxq);
/* Look at using this instead:
rxq->need_update = 1;
il_rx_queue_update_write_ptr(il, rxq);
*/
il_wr(il, FH39_RCSR_WPTR(0), rxq->write & ~7);
rc = il3945_txq_ctx_reset(il);
if (rc)
return rc;
set_bit(S_INIT, &il->status);
return 0;
} | false | false | false | false | false | 0 |
MousePoint(mproto)
int mproto;
{
last_mouse_act = LMA_NONE;
if (MouseParams(mproto))
SetCursor();
} | false | false | false | false | false | 0 |
udf_put_super(struct super_block *sb)
{
struct udf_sb_info *sbi;
sbi = UDF_SB(sb);
iput(sbi->s_vat_inode);
#ifdef CONFIG_UDF_NLS
if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
unload_nls(sbi->s_nls_map);
#endif
if (!(sb->s_flags & MS_RDONLY))
udf_close_lvid(sb);
brelse(sbi->s_lvid_bh);
udf_sb_free_partitions(sb);
mutex_destroy(&sbi->s_alloc_mutex);
kfree(sb->s_fs_info);
sb->s_fs_info = NULL;
} | false | false | false | false | false | 0 |
gm_dup(greymap_t *gm) {
greymap_t *gm1 = gm_new(gm->w, gm->h);
if (!gm1) {
return NULL;
}
memcpy(gm1->map, gm->map, gm->w*gm->h*2);
return gm1;
} | false | false | false | false | false | 0 |
e_init_status_set(const char *str)
{
if (!init_exe) return;
// printf("---STAT %p %s\n", client, str);
if (!client)
{
stats = eina_list_append(stats, eina_stringshare_add(str));
return;
}
// printf("---SEND\n");
ecore_ipc_client_send(client, E_IPC_DOMAIN_INIT, 1, 0, 0, 0, (void *)str,
strlen(str) + 1);
ecore_ipc_client_flush(client);
} | false | false | false | false | false | 0 |
conn_ov_running(struct drbd_connection *connection)
{
struct drbd_peer_device *peer_device;
bool rv = false;
int vnr;
rcu_read_lock();
idr_for_each_entry(&connection->peer_devices, peer_device, vnr) {
struct drbd_device *device = peer_device->device;
if (device->state.conn == C_VERIFY_S ||
device->state.conn == C_VERIFY_T) {
rv = true;
break;
}
}
rcu_read_unlock();
return rv;
} | false | false | false | false | false | 0 |
create_happiness_dialog(struct city *pcity)
{
int i;
struct happiness_dialog *pdialog;
GtkWidget *ebox, *label, *table;
static const char *happiness_label_str[NUM_HAPPINESS_MODIFIERS] = {
N_("Cities:"),
N_("Luxuries:"),
N_("Buildings:"),
N_("Units:"),
N_("Wonders:"),
};
static bool happiness_label_str_done;
pdialog = fc_malloc(sizeof(struct happiness_dialog));
pdialog->pcity = pcity;
pdialog->shell = gtk_grid_new();
gtk_orientable_set_orientation(GTK_ORIENTABLE(pdialog->shell),
GTK_ORIENTATION_VERTICAL);
pdialog->cityname_label = gtk_frame_new(_("Happiness"));
gtk_container_add(GTK_CONTAINER(pdialog->shell), pdialog->cityname_label);
table = gtk_grid_new();
g_object_set(table, "margin", 4, NULL);
gtk_grid_set_row_spacing(GTK_GRID(table), 10);
intl_slist(ARRAY_SIZE(happiness_label_str), happiness_label_str,
&happiness_label_str_done);
gtk_container_add(GTK_CONTAINER(pdialog->cityname_label), table);
for (i = 0; i < NUM_HAPPINESS_MODIFIERS; i++) {
/* set spacing between lines of citizens*/
/* happiness labels */
label = gtk_label_new(happiness_label_str[i]);
pdialog->happiness_label[i] = label;
gtk_widget_set_name(label, "city_label");
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_grid_attach(GTK_GRID(table), label, 0, i, 1, 1);
/* list of citizens */
ebox = gtk_event_box_new();
gtk_widget_set_margin_left(ebox, 5);
gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE);
g_object_set_data(G_OBJECT(ebox), "pdialog", pdialog);
g_signal_connect(ebox, "button_press_event",
G_CALLBACK(show_happiness_popup), GUINT_TO_POINTER(i));
pdialog->happiness_ebox[i] = ebox;
pdialog->hpixmaps[i] = gtk_pixcomm_new(PIXCOMM_WIDTH, PIXCOMM_HEIGHT);
gtk_container_add(GTK_CONTAINER(ebox), pdialog->hpixmaps[i]);
gtk_misc_set_alignment(GTK_MISC(pdialog->hpixmaps[i]), 0, 0);
gtk_grid_attach(GTK_GRID(table), ebox, 1, i, 1, 1);
}
/* TRANS: the width of this text defines the width of the city dialog. */
label = gtk_label_new(_("Additional information is available via left "
"click on the citizens."));
gtk_widget_set_name(label, "city_label");
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
gtk_grid_attach(GTK_GRID(table), label, 0, NUM_HAPPINESS_MODIFIERS, 2, 1);
gtk_widget_show_all(pdialog->shell);
dialog_list_prepend(dialog_list, pdialog);
refresh_happiness_dialog(pcity);
return pdialog;
} | false | false | false | false | false | 0 |
newScope(const char* name)
{
if (name[0] == '_') ++name;
int len = strlen(current()) + strlen(name) + 2;
char* str = new char[len];
strcpy(str, current());
if (str[0] != '\0') strcat(str, "/");
strcat(str, name);
new Prefix(str, 0);
} | false | false | false | false | false | 0 |
ldbm_back_monitor_search(Slapi_PBlock *pb, Slapi_Entry *e,
Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg)
{
struct ldbminfo *li = (struct ldbminfo *)arg;
struct berval val;
struct berval *vals[2];
char buf[BUFSIZ];
DB_MPOOL_STAT *mpstat = NULL;
DB_MPOOL_FSTAT **mpfstat = NULL;
u_int32_t cache_tries;
vals[0] = &val;
vals[1] = NULL;
/* database name */
PR_snprintf(buf, sizeof(buf), "%s", li->li_plugin->plg_name);
MSET("database");
/* we have to ask for file stats in order to get correct global stats */
if (dblayer_memp_stat(li, &mpstat, &mpfstat) != 0) {
*returncode = LDAP_OPERATIONS_ERROR;
return SLAPI_DSE_CALLBACK_ERROR;
}
/* cache hits*/
sprintf(buf, "%lu", (unsigned long)mpstat->st_cache_hit);
MSET("dbCacheHits");
/* cache tries*/
cache_tries = (mpstat->st_cache_miss + mpstat->st_cache_hit);
sprintf(buf, "%u", cache_tries);
MSET("dbCacheTries");
/* cache hit ratio*/
sprintf(buf, "%lu", (unsigned long)(100.0 * (double)mpstat->st_cache_hit / (double)(cache_tries > 0 ? cache_tries : 1) ));
MSET("dbCacheHitRatio");
sprintf(buf, "%lu", (unsigned long)mpstat->st_page_in);
MSET("dbCachePageIn");
sprintf(buf, "%lu", (unsigned long)mpstat->st_page_out);
MSET("dbCachePageOut");
sprintf(buf, "%lu", (unsigned long)mpstat->st_ro_evict);
MSET("dbCacheROEvict");
sprintf(buf, "%lu", (unsigned long)mpstat->st_rw_evict);
MSET("dbCacheRWEvict");
slapi_ch_free((void **)&mpstat);
if (mpfstat) {
#if 1000*DB_VERSION_MAJOR + 100*DB_VERSION_MINOR + DB_VERSION_PATCH <= 3204
/* In DB 3.2.4 and earlier, we need to free each element */
int i;
for (i = 0; mpfstat[i]; i++)
slapi_ch_free((void **)&mpfstat[i]);
#endif
slapi_ch_free((void **)&mpfstat);
}
*returncode = LDAP_SUCCESS;
return SLAPI_DSE_CALLBACK_OK;
} | false | false | false | false | false | 0 |
Ndf1dimN(int Nvec, double x, double *p, double *xi, unsigned long n, double *stimuli, int *locator, unsigned long Nspikes, unsigned long Ntrials)
{
unsigned long j;
double df1 = 0.0;
for(j = 1; j <= n; j++) xt[j] = p[j + (Nvec-1)*n] + x * xi[j];
(*nrdfundN)(Nvec, x, p, xt, df, stimuli, n, locator, Nspikes, Ntrials);
for(j = 1; j <= n; j++) df1 += df[j]*xi[j];
return df1;
} | false | false | false | false | false | 0 |
pi_create(
const opj_image_t *image,
const opj_cp_t *cp,
OPJ_UINT32 tileno
)
{
// loop
OPJ_UINT32 pino, compno;
// number of poc in the p_pi
OPJ_UINT32 l_poc_bound;
// pointers to tile coding parameters and components.
opj_pi_iterator_t *l_pi = 00;
opj_tcp_t *tcp = 00;
const opj_tccp_t *tccp = 00;
// current packet iterator being allocated
opj_pi_iterator_t *l_current_pi = 00;
// preconditions in debug
assert(cp != 00);
assert(image != 00);
assert(tileno < cp->tw * cp->th);
// initializations
tcp = &cp->tcps[tileno];
l_poc_bound = tcp->numpocs+1;
// memory allocations
l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound), sizeof(opj_pi_iterator_t));
if
(!l_pi)
{
return 00;
}
memset(l_pi,0,l_poc_bound * sizeof(opj_pi_iterator_t));
l_current_pi = l_pi;
for
(pino = 0; pino < l_poc_bound ; ++pino)
{
l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps, sizeof(opj_pi_comp_t));
if
(! l_current_pi->comps)
{
pi_destroy(l_pi, l_poc_bound);
return 00;
}
l_current_pi->numcomps = image->numcomps;
memset(l_current_pi->comps,0,image->numcomps * sizeof(opj_pi_comp_t));
for
(compno = 0; compno < image->numcomps; ++compno)
{
opj_pi_comp_t *comp = &l_current_pi->comps[compno];
tccp = &tcp->tccps[compno];
comp->resolutions = (opj_pi_resolution_t*) opj_malloc(tccp->numresolutions * sizeof(opj_pi_resolution_t));
if
(!comp->resolutions)
{
pi_destroy(l_pi, l_poc_bound);
return 00;
}
comp->numresolutions = tccp->numresolutions;
memset(comp->resolutions,0,tccp->numresolutions * sizeof(opj_pi_resolution_t));
}
++l_current_pi;
}
return l_pi;
} | false | true | false | false | true | 1 |
cmd_log_walk(struct rev_info *rev)
{
struct commit *commit;
int saved_nrl = 0;
int saved_dcctc = 0;
if (rev->early_output)
setup_early_output(rev);
if (prepare_revision_walk(rev))
die(_("revision walk setup failed"));
if (rev->early_output)
finish_early_output(rev);
/*
* For --check and --exit-code, the exit code is based on CHECK_FAILED
* and HAS_CHANGES being accumulated in rev->diffopt, so be careful to
* retain that state information if replacing rev->diffopt in this loop
*/
while ((commit = get_revision(rev)) != NULL) {
if (!log_tree_commit(rev, commit) &&
rev->max_count >= 0)
/*
* We decremented max_count in get_revision,
* but we didn't actually show the commit.
*/
rev->max_count++;
if (!rev->reflog_info) {
/* we allow cycles in reflog ancestry */
free(commit->buffer);
commit->buffer = NULL;
}
free_commit_list(commit->parents);
commit->parents = NULL;
if (saved_nrl < rev->diffopt.needed_rename_limit)
saved_nrl = rev->diffopt.needed_rename_limit;
if (rev->diffopt.degraded_cc_to_c)
saved_dcctc = 1;
}
rev->diffopt.degraded_cc_to_c = saved_dcctc;
rev->diffopt.needed_rename_limit = saved_nrl;
if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&
DIFF_OPT_TST(&rev->diffopt, CHECK_FAILED)) {
return 02;
}
return diff_result_code(&rev->diffopt, 0);
} | false | false | false | false | false | 0 |
evutil_check_ifaddrs(void)
{
#if defined(EVENT__HAVE_GETIFADDRS)
/* Most free Unixy systems provide getifaddrs, which gives us a linked list
* of struct ifaddrs. */
struct ifaddrs *ifa = NULL;
const struct ifaddrs *i;
if (getifaddrs(&ifa) < 0) {
event_warn("Unable to call getifaddrs()");
return -1;
}
for (i = ifa; i; i = i->ifa_next) {
if (!i->ifa_addr)
continue;
evutil_found_ifaddr(i->ifa_addr);
}
freeifaddrs(ifa);
return 0;
#elif defined(_WIN32)
/* Windows XP began to provide GetAdaptersAddresses. Windows 2000 had a
"GetAdaptersInfo", but that's deprecated; let's just try
GetAdaptersAddresses and fall back to connect+getsockname.
*/
HANDLE lib = evutil_load_windows_system_library_(TEXT("ihplapi.dll"));
GetAdaptersAddresses_fn_t fn;
ULONG size, res;
IP_ADAPTER_ADDRESSES *addresses = NULL, *address;
int result = -1;
#define FLAGS (GAA_FLAG_SKIP_ANYCAST | \
GAA_FLAG_SKIP_MULTICAST | \
GAA_FLAG_SKIP_DNS_SERVER)
if (!lib)
goto done;
if (!(fn = (GetAdaptersAddresses_fn_t) GetProcAddress(lib, "GetAdaptersAddresses")))
goto done;
/* Guess how much space we need. */
size = 15*1024;
addresses = mm_malloc(size);
if (!addresses)
goto done;
res = fn(AF_UNSPEC, FLAGS, NULL, addresses, &size);
if (res == ERROR_BUFFER_OVERFLOW) {
/* we didn't guess that we needed enough space; try again */
mm_free(addresses);
addresses = mm_malloc(size);
if (!addresses)
goto done;
res = fn(AF_UNSPEC, FLAGS, NULL, addresses, &size);
}
if (res != NO_ERROR)
goto done;
for (address = addresses; address; address = address->Next) {
IP_ADAPTER_UNICAST_ADDRESS *a;
for (a = address->FirstUnicastAddress; a; a = a->Next) {
/* Yes, it's a linked list inside a linked list */
struct sockaddr *sa = a->Address.lpSockaddr;
evutil_found_ifaddr(sa);
}
}
result = 0;
done:
if (lib)
FreeLibrary(lib);
if (addresses)
mm_free(addresses);
return result;
#else
return -1;
#endif
} | false | false | false | false | false | 0 |
wgrow(W *w)
{
W *nextw;
/* If we're the last window on the screen, shrink the previous window */
if ((w->link.next == w->t->topwin || w->link.next->y == -1) && w != w->t->topwin)
return wshrink(w->link.prev->main);
/* Get to next variable size window */
for (nextw = w->link.next; nextw->fixed && nextw != w->t->topwin; nextw = nextw->link.next) ;
/* Is it below us, on screen and big enough to take space from? */
if (nextw == w->t->topwin || nextw->y == -1 || nextw->h <= FITHEIGHT)
return -1;
/* Increase this window's height */
seth(w, w->h + 1);
/* Decrease next window's height */
seth(nextw, nextw->h - 1);
/* Do it */
wfit(w->t);
return 0;
} | false | false | false | false | false | 0 |
xlog_state_done_syncing(
xlog_in_core_t *iclog,
int aborted)
{
struct xlog *log = iclog->ic_log;
spin_lock(&log->l_icloglock);
ASSERT(iclog->ic_state == XLOG_STATE_SYNCING ||
iclog->ic_state == XLOG_STATE_IOERROR);
ASSERT(atomic_read(&iclog->ic_refcnt) == 0);
ASSERT(iclog->ic_bwritecnt == 1 || iclog->ic_bwritecnt == 2);
/*
* If we got an error, either on the first buffer, or in the case of
* split log writes, on the second, we mark ALL iclogs STATE_IOERROR,
* and none should ever be attempted to be written to disk
* again.
*/
if (iclog->ic_state != XLOG_STATE_IOERROR) {
if (--iclog->ic_bwritecnt == 1) {
spin_unlock(&log->l_icloglock);
return;
}
iclog->ic_state = XLOG_STATE_DONE_SYNC;
}
/*
* Someone could be sleeping prior to writing out the next
* iclog buffer, we wake them all, one will get to do the
* I/O, the others get to wait for the result.
*/
wake_up_all(&iclog->ic_write_wait);
spin_unlock(&log->l_icloglock);
xlog_state_do_callback(log, aborted, iclog); /* also cleans log */
} | false | false | false | false | false | 0 |
hid_debug_rdesc_show(struct seq_file *f, void *p)
{
struct hid_device *hdev = f->private;
const __u8 *rdesc = hdev->rdesc;
unsigned rsize = hdev->rsize;
int i;
if (!rdesc) {
rdesc = hdev->dev_rdesc;
rsize = hdev->dev_rsize;
}
/* dump HID report descriptor */
for (i = 0; i < rsize; i++)
seq_printf(f, "%02x ", rdesc[i]);
seq_printf(f, "\n\n");
/* dump parsed data and input mappings */
hid_dump_device(hdev, f);
seq_printf(f, "\n");
hid_dump_input_mapping(hdev, f);
return 0;
} | false | false | false | false | false | 0 |
RaParseComplete (int sig)
{
long long total_count, total_dst_count, total_src_count;
long long total_bytes, total_dst_bytes, total_src_bytes;
if ((sig >= 0) && aflag) {
putchar ('\n');
total_src_count = tcp_src_count + udp_src_count + icmp_src_count +
ip_src_count + arp_src_count + nonip_src_count;
total_dst_count = tcp_dst_count + udp_dst_count + icmp_dst_count +
ip_dst_count + arp_dst_count + nonip_dst_count;
total_count = total_dst_count + total_src_count;
total_src_bytes = tcp_src_bytes + udp_src_bytes + icmp_src_bytes +
ip_src_bytes + arp_src_bytes + nonip_src_bytes;
total_dst_bytes = tcp_dst_bytes + udp_dst_bytes + icmp_dst_bytes +
ip_dst_bytes + arp_dst_bytes + nonip_dst_bytes;
total_bytes = total_dst_bytes + total_src_bytes;
if (total_count) {
printf (" total_pkts src_pkts dst_pkts total_bytes src_bytes dst_bytes\n");
printf ("tcp %16lld %16lld %16lld %16lld %16lld %16lld\n",
tcp_dst_count + tcp_src_count, tcp_src_count, tcp_dst_count,
tcp_dst_bytes + tcp_src_bytes, tcp_src_bytes, tcp_dst_bytes);
printf ("udp %16lld %16lld %16lld %16lld %16lld %16lld\n",
udp_dst_count + udp_src_count, udp_src_count, udp_dst_count,
udp_dst_bytes + udp_src_bytes, udp_src_bytes, udp_dst_bytes);
printf ("icmp %16lld %16lld %16lld %16lld %16lld %16lld\n",
icmp_dst_count + icmp_src_count, icmp_src_count, icmp_dst_count,
icmp_dst_bytes + icmp_src_bytes, icmp_src_bytes, icmp_dst_bytes);
printf ("ip %16lld %16lld %16lld %16lld %16lld %16lld\n",
ip_dst_count + ip_src_count, ip_src_count, ip_dst_count,
ip_dst_bytes + ip_src_bytes, ip_src_bytes, ip_dst_bytes);
printf ("arp %16lld %16lld %16lld %16lld %16lld %16lld\n",
arp_dst_count + arp_src_count, arp_src_count, arp_dst_count,
arp_dst_bytes + arp_src_bytes, arp_src_bytes, arp_dst_bytes);
printf ("non-ip %16lld %16lld %16lld %16lld %16lld %16lld\n",
nonip_dst_count + nonip_src_count, nonip_src_count, nonip_dst_count,
nonip_dst_bytes + nonip_src_bytes, nonip_src_bytes, nonip_dst_bytes);
printf ("sum %16lld %16lld %16lld %16lld %16lld %16lld",
total_count, total_src_count, total_dst_count,
total_bytes, total_src_bytes, total_dst_bytes);
printf ("\n\n");
} else
printf ("No data seen.\n");
fflush (stdout);
}
if (sig == SIGINT)
_exit(0);
} | false | false | false | false | false | 0 |
adjust_rcv_timeout(struct qib_ctxtdata *rcd, int npkts)
{
struct qib_devdata *dd = rcd->dd;
u32 timeout = dd->cspec->rcvavail_timeout[rcd->ctxt];
/*
* Dynamically adjust idle timeout on chip
* based on number of packets processed.
*/
if (npkts < rcv_int_count && timeout > 2)
timeout >>= 1;
else if (npkts >= rcv_int_count && timeout < rcv_int_timeout)
timeout = min(timeout << 1, rcv_int_timeout);
else
return;
dd->cspec->rcvavail_timeout[rcd->ctxt] = timeout;
qib_write_kreg(dd, kr_rcvavailtimeout + rcd->ctxt, timeout);
} | false | false | false | false | false | 0 |
getusershell (void)
{
char *ret;
if (curshell == NULL)
curshell = initshells();
ret = *curshell;
if (ret != NULL)
curshell++;
return (ret);
} | false | false | false | false | false | 0 |
xmlSecGCryptDigestFinalize(xmlSecTransformPtr transform) {
xmlSecGCryptDigestCtxPtr ctx;
xmlSecAssert(xmlSecGCryptDigestCheckId(transform));
xmlSecAssert(xmlSecTransformCheckSize(transform, xmlSecGCryptDigestSize));
ctx = xmlSecGCryptDigestGetCtx(transform);
xmlSecAssert(ctx != NULL);
if(ctx->digestCtx != NULL) {
gcry_md_close(ctx->digestCtx);
}
memset(ctx, 0, sizeof(xmlSecGCryptDigestCtx));
} | false | false | false | false | false | 0 |
cache_fetch_done(long art_no)
{
int i;
i = cache_find(trail_cache, trail_size, art_no);
if (i >= 0)
trail_cache[i].status = StatusOk;
else
fprintf(stderr, "done but no node %ld\n", art_no);
if (cache_notice)
show_cache_stats();
} | false | false | false | false | false | 0 |
P_ArtiTele(player_t * player)
{
int i;
int selections;
fixed_t destX;
fixed_t destY;
angle_t destAngle;
if (deathmatch)
{
selections = deathmatch_p - deathmatchstarts;
i = P_Random() % selections;
destX = deathmatchstarts[i].x << FRACBITS;
destY = deathmatchstarts[i].y << FRACBITS;
destAngle = ANG45 * (deathmatchstarts[i].angle / 45);
}
else
{
destX = playerstarts[0].x << FRACBITS;
destY = playerstarts[0].y << FRACBITS;
destAngle = ANG45 * (playerstarts[0].angle / 45);
}
P_Teleport(player->mo, destX, destY, destAngle);
S_StartSound(NULL, sfx_wpnup); // Full volume laugh
} | false | false | false | false | false | 0 |
g_vfs_ftp_dir_cache_purge_file (GVfsFtpDirCache * cache,
const GVfsFtpFile *file)
{
GVfsFtpFile *dir;
g_return_if_fail (cache != NULL);
g_return_if_fail (file != NULL);
if (g_vfs_ftp_file_is_root (file))
return;
dir = g_vfs_ftp_file_new_parent (file);
g_vfs_ftp_dir_cache_purge_dir (cache, dir);
g_vfs_ftp_file_free (dir);
} | false | false | false | false | false | 0 |
fixup_var_refs_insns (insn, var, promoted_mode, unsignedp, toplevel, may_share)
rtx insn;
rtx var;
enum machine_mode promoted_mode;
int unsignedp;
int toplevel;
rtx may_share;
{
while (insn)
{
/* fixup_var_refs_insn might modify insn, so save its next
pointer now. */
rtx next = NEXT_INSN (insn);
/* CALL_PLACEHOLDERs are special; we have to switch into each of
the three sequences they (potentially) contain, and process
them recursively. The CALL_INSN itself is not interesting. */
if (GET_CODE (insn) == CALL_INSN
&& GET_CODE (PATTERN (insn)) == CALL_PLACEHOLDER)
{
int i;
/* Look at the Normal call, sibling call and tail recursion
sequences attached to the CALL_PLACEHOLDER. */
for (i = 0; i < 3; i++)
{
rtx seq = XEXP (PATTERN (insn), i);
if (seq)
{
push_to_sequence (seq);
fixup_var_refs_insns (seq, var, promoted_mode, unsignedp, 0,
may_share);
XEXP (PATTERN (insn), i) = get_insns ();
end_sequence ();
}
}
}
else if (INSN_P (insn))
fixup_var_refs_insn (insn, var, promoted_mode, unsignedp, toplevel,
may_share);
insn = next;
}
} | false | false | false | false | false | 0 |
resetAllContactItemNames()
{
Q3PtrListIterator<Entry> it(d->roster);
for(Entry *e; (e = it.current()); ++it) {
Q3PtrListIterator<ContactViewItem> cvi_it(e->cvi);
for(ContactViewItem *i; (i = cvi_it.current()); ++cvi_it) {
i->resetName();
contactView()->filterContact(i);
}
}
} | false | false | false | false | false | 0 |
getTagObject()
{
if (getTagging())
{
string tagobj_id = getOptionsObject()->getStr("tagobject_id");
if (!tagobj_id.empty())
{
return getRoot()->findInIndex(
FWObjectDatabase::getIntId(tagobj_id));
}
}
return NULL;
} | false | false | false | false | false | 0 |
get_user_cmd_nargs(xp, idx)
expand_T *xp UNUSED;
int idx;
{
static char *user_cmd_nargs[] = {"0", "1", "*", "?", "+"};
if (idx >= (int)(sizeof(user_cmd_nargs) / sizeof(user_cmd_nargs[0])))
return NULL;
return (char_u *)user_cmd_nargs[idx];
} | false | false | false | false | false | 0 |
tiger_compress(hash_state *md, unsigned char *buf)
#endif
{
ulong64 a, b, c, x[8];
unsigned long i;
/* load words */
for (i = 0; i < 8; i++) {
LOAD64L(x[i],&buf[8*i]);
}
a = md->tiger.state[0];
b = md->tiger.state[1];
c = md->tiger.state[2];
pass(&a,&b,&c,x,5);
key_schedule(x);
pass(&c,&a,&b,x,7);
key_schedule(x);
pass(&b,&c,&a,x,9);
/* store state */
md->tiger.state[0] = a ^ md->tiger.state[0];
md->tiger.state[1] = b - md->tiger.state[1];
md->tiger.state[2] = c + md->tiger.state[2];
return CRYPT_OK;
} | false | false | false | false | false | 0 |
BackupNumber(const char *Pos, const char *FirstChar) {
// If we didn't stop in the middle of a number, don't backup.
if (!isNumberChar(*Pos)) return Pos;
// Otherwise, return to the start of the number.
bool HasPeriod = false;
while (Pos > FirstChar && isNumberChar(Pos[-1])) {
// Backup over at most one period.
if (Pos[-1] == '.') {
if (HasPeriod)
break;
HasPeriod = true;
}
--Pos;
if (Pos > FirstChar && isSignedChar(Pos[0]) && !isExponentChar(Pos[-1]))
break;
}
return Pos;
} | false | false | false | false | true | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.