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 |
|---|---|---|---|---|---|---|
PR_RWLock_Wlock(PRRWLock *rwlock)
{
#if defined(DEBUG)
PRThread *me = PR_GetCurrentThread();
#endif
#if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)
int err;
#endif
#ifdef _PR_RWLOCK_RANK_ORDER_DEBUG
/*
* assert that rank ordering is not violated; the rank of 'rwlock' should
* be equal to or greater than the highest rank of all the locks held by
* the thread.
*/
PR_ASSERT((rwlock->rw_rank == PR_RWLOCK_RANK_NONE) ||
(rwlock->rw_rank >= _PR_GET_THREAD_RWLOCK_RANK()));
#endif
#if defined(HAVE_UNIX98_RWLOCK) || defined(HAVE_UI_RWLOCK)
err = RWLOCK_WRLOCK(&rwlock->rw_lock);
PR_ASSERT(err == 0);
#else
PR_Lock(rwlock->rw_lock);
/*
* wait if read locked
*/
while (rwlock->rw_lock_cnt != 0) {
rwlock->rw_writer_cnt++;
PR_WaitCondVar(rwlock->rw_writer_waitq, PR_INTERVAL_NO_TIMEOUT);
rwlock->rw_writer_cnt--;
}
/*
* apply write lock
*/
rwlock->rw_lock_cnt--;
PR_ASSERT(rwlock->rw_lock_cnt == -1);
#ifdef DEBUG
PR_ASSERT(me != NULL);
rwlock->rw_owner = me;
#endif
PR_Unlock(rwlock->rw_lock);
#endif
#ifdef _PR_RWLOCK_RANK_ORDER_DEBUG
/*
* update thread's lock rank
*/
if (rwlock->rw_rank != PR_RWLOCK_RANK_NONE)
_PR_SET_THREAD_RWLOCK_RANK(rwlock);
#endif
} | false | false | false | false | false | 0 |
clone_nodeset(struct nodeset *ns, struct state *state)
{
struct nodeset *clone;
if (ALLOC(clone) < 0) {
STATE_ENOMEM;
return NULL;
}
if (ALLOC_N(clone->nodes, ns->used) < 0) {
free(clone);
STATE_ENOMEM;
return NULL;
}
clone->used = ns->used;
clone->size = ns->used;
for (int i=0; i < ns->used; i++)
clone->nodes[i] = ns->nodes[i];
return clone;
} | false | false | false | false | false | 0 |
FindBucketFor(const void *Ptr) const {
unsigned Bucket = Hash(Ptr);
unsigned ArraySize = CurArraySize;
unsigned ProbeAmt = 1;
const void *const *Array = CurArray;
const void *const *Tombstone = 0;
while (1) {
// Found Ptr's bucket?
if (Array[Bucket] == Ptr)
return Array+Bucket;
// If we found an empty bucket, the pointer doesn't exist in the set.
// Return a tombstone if we've seen one so far, or the empty bucket if
// not.
if (Array[Bucket] == getEmptyMarker())
return Tombstone ? Tombstone : Array+Bucket;
// If this is a tombstone, remember it. If Ptr ends up not in the set, we
// prefer to return it than something that would require more probing.
if (Array[Bucket] == getTombstoneMarker() && !Tombstone)
Tombstone = Array+Bucket; // Remember the first tombstone found.
// It's a hash collision or a tombstone. Reprobe.
Bucket = (Bucket + ProbeAmt++) & (ArraySize-1);
}
} | false | false | false | false | false | 0 |
HandleTranslationUnit(ASTContext &Ctx)
{
doAnalysis();
if (QueryInstanceOnly)
return;
if (TransformationCounter > ValidInstanceNum) {
TransError = TransMaxInstanceError;
return;
}
TransAssert(TheRecordDecl && "Cannot have NULL TheRecordDecl!");
TransAssert(TheDeclaratorSet && "Cannot have NULL TheDeclaratorSet!");
rewriteRecordDecls();
rewriteDeclarators();
Ctx.getDiagnostics().setSuppressAllDiagnostics(false);
if (Ctx.getDiagnostics().hasErrorOccurred() ||
Ctx.getDiagnostics().hasFatalErrorOccurred())
TransError = TransInternalError;
} | false | false | false | false | false | 0 |
strlist_print (sl, prefix)
STRINGLIST *sl;
char *prefix;
{
register int i;
if (sl == 0)
return;
for (i = 0; i < sl->list_len; i++)
printf ("%s%s\n", prefix ? prefix : "", sl->list[i]);
} | false | false | false | false | false | 0 |
dft_lin_resp_worker(void *data)
{
static const int LINRESP_ERROR = 1;
LinData *ld = (LinData*)data;
try {
ld->electrons =
dft_lin_respao(*ld->bis, *ld->mol, *ld->gss,
ld->density, ld->inputVec, ld->transformedVec,
ld->nThreads);
} catch(const char *s) {
do_output(LOG_CAT_ERROR, LOG_AREA_DFT,
"dft_lin_resp_worker thread caught an exception '%s'", s);
return (void*)&LINRESP_ERROR;
} catch(const std::bad_alloc & e) {
do_output(LOG_CAT_ERROR, LOG_AREA_DFT,
"dft_lin_resp_worker thread caught an exception '%s'", e.what());
return (void*)&LINRESP_ERROR;
} catch(...) {
do_output(LOG_CAT_ERROR, LOG_AREA_DFT,
"dft_lin_resp_worker thread caught unexpected exception.");
return (void*)&LINRESP_ERROR;
}
return NULL;
} | false | false | false | false | false | 0 |
servlist_select_and_show (GtkTreeView *treeview, GtkTreeIter *iter,
GtkListStore *store)
{
GtkTreePath *path;
GtkTreeSelection *sel;
sel = gtk_tree_view_get_selection (treeview);
/* select this network */
gtk_tree_selection_select_iter (sel, iter);
/* and make sure it's visible */
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), iter);
if (path)
{
gtk_tree_view_scroll_to_cell (treeview, path, NULL, TRUE, 0.5, 0.5);
gtk_tree_view_set_cursor (treeview, path, NULL, FALSE);
gtk_tree_path_free (path);
}
} | false | false | false | false | false | 0 |
guess_got_query_key(enum udp_ping_ret type,
const struct gnutella_node *n, void *data)
{
struct guess_qk_context *ctx = data;
guess_t *gq;
const gnet_host_t *host = ctx->host;
gq = guess_is_alive(ctx->gid);
if (NULL == gq) {
if (UDP_PING_EXPIRED == type || UDP_PING_TIMEDOUT == type)
guess_qk_context_free(ctx);
return;
}
g_assert(atom_is_host(ctx->host));
switch (type) {
case UDP_PING_TIMEDOUT:
/*
* Maybe we got the query key through a ping sent separately (by
* the background GUESS discovery logic)?
*/
{
struct qkdata *qk = get_qkdata(host);
if (
qk != NULL && qk->length != 0 &&
delta_time(tm_time(), qk->last_update) <= GUESS_QK_LIFE
) {
if (GNET_PROPERTY(guess_client_debug) > 2) {
g_info("GUESS QUERY[%s] concurrently got query key for %s",
nid_to_string(&gq->gid), gnet_host_to_string(host));
}
guess_send_query(gq, host);
guess_qk_context_free(ctx);
break;
}
/*
* If we don't have the host in the query key cache, it may mean
* its IP:port is plain wrong. LimeWire nodes are known to
* generate wrong pongs for incoming GUESS ultrapeer connections
* because they use the port of the incoming TCP connection instead
* of parsing the Node: header from the handshake to gather the
* proper listening port.
*/
if (NULL == qk) {
if (GNET_PROPERTY(guess_client_debug) > 2) {
g_debug("GUESS QUERY[%s] timed out waiting query key "
"from new host %s",
nid_to_string(&gq->gid), gnet_host_to_string(host));
}
guess_alien_host(gq, host, FALSE);
guess_qk_context_free(ctx);
goto no_query_key;
}
}
if (GNET_PROPERTY(guess_client_debug) > 2) {
g_debug("GUESS QUERY[%s] timed out waiting query key from %s",
nid_to_string(&gq->gid), gnet_host_to_string(host));
}
/*
* Mark timeout from host. This will delay further usage of the
* host by other queries.
*/
guess_timeout_from(host);
aging_remove(guess_qk_reqs, host);
/* FALL THROUGH */
case UDP_PING_EXPIRED:
guess_qk_context_free(ctx);
goto no_query_key;
case UDP_PING_REPLY:
if G_UNLIKELY(NULL == link_cache)
break;
guess_traffic_from(host);
if (guess_extract_qk(n, host)) {
if (GNET_PROPERTY(guess_client_debug) > 2) {
g_debug("GUESS QUERY[%s] got query key from %s, sending query",
nid_to_string(&gq->gid), gnet_host_to_string(host));
}
guess_send_query(gq, host);
} else {
uint16 port = peek_le16(&n->data[0]);
host_addr_t addr = guess_extract_host_addr(n);
/*
* This is probably a batch of Pong messages we're getting in
* reply from our Ping.
*/
if (GNET_PROPERTY(guess_client_debug) > 4) {
g_debug("GUESS QUERY[%s] extra pong %s from %s",
nid_to_string(&gq->gid),
host_addr_port_to_string(addr, port),
gnet_host_to_string(host));
}
/*
* If it is a pong for itself, and we don't know the query
* key for the host yet, then we got a plain pong because
* the host did not understand the "QK" GGEP key in the ping.
*
* This is not a GUESS host so remove it from the cache.
*/
if (
gnet_host_get_port(host) == port &&
host_addr_equal(gnet_host_get_addr(host), addr)
) {
struct qkdata *qk = get_qkdata(host);
if (NULL == qk || 0 == qk->length) {
guess_alien_host(gq, host, TRUE);
}
if (qk != NULL)
delete_qkdata(host);
guess_remove_link_cache(host);
goto no_query_key;
}
}
guess_extract_ipp(gq, n, host);
break;
}
return;
no_query_key:
guess_iterate(gq);
} | false | false | false | false | false | 0 |
dwmac1000_rx_ipc_enable(struct mac_device_info *hw)
{
void __iomem *ioaddr = hw->pcsr;
u32 value = readl(ioaddr + GMAC_CONTROL);
if (hw->rx_csum)
value |= GMAC_CONTROL_IPC;
else
value &= ~GMAC_CONTROL_IPC;
writel(value, ioaddr + GMAC_CONTROL);
value = readl(ioaddr + GMAC_CONTROL);
return !!(value & GMAC_CONTROL_IPC);
} | false | false | false | false | false | 0 |
window_make(int origin_x, int origin_y, int end_x, int end_y)
{
int n;
region to_clear;
to_clear.col = origin_x;
to_clear.row = origin_y;
to_clear.width = end_x - origin_x;
to_clear.page_rows = end_y - origin_y;
region_erase(&to_clear);
Term_putch(origin_x, origin_y, TERM_WHITE, '+');
Term_putch(end_x, origin_y, TERM_WHITE, '+');
Term_putch(origin_x, end_y, TERM_WHITE, '+');
Term_putch(end_x, end_y, TERM_WHITE, '+');
for (n = 1; n < (end_x - origin_x); n++)
{
Term_putch(origin_x + n, origin_y, TERM_WHITE, '-');
Term_putch(origin_x + n, end_y, TERM_WHITE, '-');
}
for (n = 1; n < (end_y - origin_y); n++)
{
Term_putch(origin_x, origin_y + n, TERM_WHITE, '|');
Term_putch(end_x, origin_y + n, TERM_WHITE, '|');
}
} | false | false | false | false | false | 0 |
git_push_status_foreach(git_push *push,
int (*cb)(const char *ref, const char *msg, void *data),
void *data)
{
push_status *status;
unsigned int i;
git_vector_foreach(&push->status, i, status) {
if (cb(status->ref, status->msg, data) < 0)
return GIT_EUSER;
}
return 0;
} | false | false | false | false | false | 0 |
ParmList_str_defaultargs(ParmList *p) {
String *out = NewStringEmpty();
while (p) {
String *value = Getattr(p, "value");
String *pstr = SwigType_str(Getattr(p, "type"), Getattr(p, "name"));
Append(out, pstr);
if (value) {
Printf(out, "=%s", value);
}
p = nextSibling(p);
if (p) {
Append(out, ",");
}
Delete(pstr);
}
return out;
} | false | false | false | false | false | 0 |
ast_audiohook_detach(struct ast_audiohook *audiohook)
{
if (audiohook->status == AST_AUDIOHOOK_STATUS_NEW || audiohook->status == AST_AUDIOHOOK_STATUS_DONE)
return 0;
ast_audiohook_update_status(audiohook, AST_AUDIOHOOK_STATUS_SHUTDOWN);
while (audiohook->status != AST_AUDIOHOOK_STATUS_DONE)
ast_audiohook_trigger_wait(audiohook);
return 0;
} | false | false | false | false | false | 0 |
btsdio_remove(struct sdio_func *func)
{
struct btsdio_data *data = sdio_get_drvdata(func);
struct hci_dev *hdev;
BT_DBG("func %p", func);
if (!data)
return;
hdev = data->hdev;
sdio_set_drvdata(func, NULL);
hci_unregister_dev(hdev);
hci_free_dev(hdev);
} | false | false | false | false | false | 0 |
on_copy_text_messages_activate (GtkMenuItem * menuitem,
gpointer user_data)
{
GSQL_TRACE_FUNC;
GtkTreeView *treeview = user_data;
GtkTreeSelection *sel;
GtkTreeModel *model;
GdkDisplay *disp;
GtkClipboard *clip;
GtkTreeIter iter;
gchar *body_message;
gchar *tmp;
sel = gtk_tree_view_get_selection(treeview);
model = gtk_tree_view_get_model (treeview);
gtk_tree_selection_set_mode (sel, GTK_SELECTION_SINGLE);
if (!gtk_tree_selection_get_selected (sel, &model, &iter))
// have no one selected.
return;
gtk_tree_model_get (model, &iter,
3, &body_message, -1);
gtk_tree_selection_set_mode (sel, GTK_SELECTION_MULTIPLE);
pango_parse_markup (body_message, -1, 0, NULL, &tmp, NULL, NULL);
body_message = tmp;
disp = gdk_display_get_default();
clip = gtk_clipboard_get_for_display (disp, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_text (clip, body_message, GSQL_MESSAGE_LEN);
} | false | false | false | false | false | 0 |
knh_isDefinedEvent(CTX ctx, kbytes_t t)
{
int eid;
kintptr_t loc = knh_bytes_index(t, '!');
if(loc != -1) {
t = knh_bytes_first(t, loc);
}
OLD_LOCK(ctx, LOCK_SYSTBL, NULL);
eid = (kevent_t)knh_DictSet_get(ctx, ctx->share->eventDictSet, t);
OLD_UNLOCK(ctx, LOCK_SYSTBL, NULL);
return (eid > 0) ;
} | false | false | false | false | false | 0 |
libdicthash_table_get(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)
{
ScmObj hash_scm;
ScmHashTable* hash;
ScmObj key_scm;
ScmObj key;
ScmObj fallback_scm;
ScmObj fallback;
ScmObj SCM_SUBRARGS[4];
int SCM_i;
SCM_ENTER_SUBR("hash-table-get");
if (SCM_ARGCNT >= 4
&& !SCM_NULLP(SCM_ARGREF(SCM_ARGCNT-1)))
Scm_Error("too many arguments: up to 3 is expected, %d given.", SCM_ARGCNT + Scm_Length(SCM_ARGREF(SCM_ARGCNT-1)) - 1);
for (SCM_i=0; SCM_i<4; SCM_i++) {
SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
}
hash_scm = SCM_SUBRARGS[0];
if (!SCM_HASH_TABLE_P(hash_scm)) Scm_Error("hash table required, but got %S", hash_scm);
hash = SCM_HASH_TABLE(hash_scm);
key_scm = SCM_SUBRARGS[1];
key = (key_scm);
if (SCM_ARGCNT > 2+1) {
fallback_scm = SCM_SUBRARGS[2];
} else {
fallback_scm = SCM_UNBOUND;
}
fallback = (fallback_scm);
{
{
ScmObj SCM_RESULT;
#line 144 "libdict.scm"
{ScmObj v=Scm_HashTableRef(hash,key,fallback);if (SCM_UNBOUNDP(v)){{Scm_Error("%S doesn't have an entry for key %S",hash,key);}}SCM_RESULT=(v);}
SCM_RETURN(SCM_OBJ_SAFE(SCM_RESULT));
}
}
} | false | false | false | false | false | 0 |
lg_SetTrustAttribute(LGObjectCache *obj, const CK_ATTRIBUTE *attr)
{
unsigned int flags;
CK_TRUST trust;
NSSLOWCERTCertificate *cert;
NSSLOWCERTCertDBHandle *certHandle;
NSSLOWCERTCertTrust dbTrust;
SECStatus rv;
CK_RV crv;
if (attr->type == CKA_LABEL) {
return CKR_OK;
}
crv = lg_GetULongAttribute(attr->type, attr, 1, &trust);
if (crv != CKR_OK) {
return crv;
}
flags = lg_MapTrust(trust, (PRBool) (attr->type == CKA_TRUST_CLIENT_AUTH));
certHandle = lg_getCertDB(obj->sdb);
if (certHandle == NULL) {
crv = CKR_TOKEN_WRITE_PROTECTED;
goto done;
}
cert = lg_getCert(obj, certHandle);
if (cert == NULL) {
crv = CKR_OBJECT_HANDLE_INVALID;
goto done;
}
dbTrust = *cert->trust;
switch (attr->type) {
case CKA_TRUST_EMAIL_PROTECTION:
dbTrust.emailFlags = flags |
(cert->trust->emailFlags & CERTDB_PRESERVE_TRUST_BITS);
break;
case CKA_TRUST_CODE_SIGNING:
dbTrust.objectSigningFlags = flags |
(cert->trust->objectSigningFlags & CERTDB_PRESERVE_TRUST_BITS);
break;
case CKA_TRUST_CLIENT_AUTH:
dbTrust.sslFlags = flags | (cert->trust->sslFlags &
(CERTDB_PRESERVE_TRUST_BITS|CERTDB_TRUSTED_CA));
break;
case CKA_TRUST_SERVER_AUTH:
dbTrust.sslFlags = flags | (cert->trust->sslFlags &
(CERTDB_PRESERVE_TRUST_BITS|CERTDB_TRUSTED_CLIENT_CA));
break;
default:
crv = CKR_ATTRIBUTE_READ_ONLY;
goto done;
}
rv = nsslowcert_ChangeCertTrust(certHandle, cert, &dbTrust);
crv = (rv == SECSuccess) ? CKR_OK : CKR_DEVICE_ERROR;
done:
return crv;
} | false | false | false | false | false | 0 |
filetypes_detect_from_document(GeanyDocument *doc)
{
GeanyFiletype *ft;
gchar *lines[GEANY_FILETYPE_SEARCH_LINES + 1];
gint i;
if (doc == NULL)
return filetypes[GEANY_FILETYPES_NONE];
for (i = 0; i < GEANY_FILETYPE_SEARCH_LINES; ++i)
{
lines[i] = sci_get_line(doc->editor->sci, i);
}
lines[i] = NULL;
ft = filetypes_detect_from_file_internal(doc->file_name, lines);
for (i = 0; i < GEANY_FILETYPE_SEARCH_LINES; ++i)
{
g_free(lines[i]);
}
return ft;
} | false | false | false | false | false | 0 |
splitPathAtDirectory(const char *pathname,
char **pdir,
char **ptail)
{
char *cpathname, *lastslash;
PROCNAME("splitPathAtDirectory");
if (!pdir && !ptail)
return ERROR_INT("null input for both strings", procName, 1);
if (pdir) *pdir = NULL;
if (ptail) *ptail = NULL;
if (!pathname)
return ERROR_INT("pathname not defined", procName, 1);
cpathname = stringNew(pathname);
if ((lastslash = strrchr(cpathname, sepchar))) {
if (ptail)
*ptail = stringNew(lastslash + 1);
if (pdir) {
*(lastslash + 1) = '\0';
*pdir = cpathname;
}
else
FREE(cpathname);
}
else { /* no directory */
if (pdir)
*pdir = stringNew("");
if (ptail)
*ptail = cpathname;
else
FREE(cpathname);
}
return 0;
} | false | false | false | false | false | 0 |
xconvert(const char* x, unsigned long& out, const char** errPos, int) {
if (empty(x, errPos)) { return 0; }
char* err;
if (std::strncmp(x, "umax", 4) == 0) {
out = static_cast<unsigned long>(-1);
err = (char*)x+4;
}
else if (std::strncmp(x, "-1", 2) == 0) {
out = static_cast<unsigned long>(-1);
err = (char*)x+2;
}
else if (*x != '-') {
out = std::strtoul(x, &err, detectBase(x));
if (out == ULONG_MAX && errno == ERANGE) { err = (char*)x; }
}
else { err = (char*)x; }
return parsed(err != x, err, errPos);
} | false | false | false | false | false | 0 |
rhcs_parse_config_info(struct pluginDevice* sd, StonithNVpair * info)
{
char * key;
char * value;
StonithNVpair * nv;
sd->hostlist = NULL;
sd->cmd_opts = g_hash_table_new(g_str_hash, g_str_equal);
/* TODO: Maybe treat "" as delimeters too so
* whitespace can be passed to the plugins... */
for (nv = info; nv->s_name; nv++) {
if (!nv->s_name || !nv->s_value) {
continue;
}
key = STRDUP(nv->s_name);
if (!key) {
goto err_mem;
}
value = STRDUP(nv->s_value);
if (!value) {
FREE(key);
goto err_mem;
}
if (!strcmp(key,"hostlist")) {
sd->hostlist = value;
FREE(key);
} else {
g_hash_table_insert(sd->cmd_opts, key, value);
}
}
return(S_OK);
err_mem:
LOG(PIL_CRIT, "%s: out of memory!", __FUNCTION__);
rhcs_unconfig(sd);
return(S_OOPS);
} | false | false | false | false | false | 0 |
c3600_show_hardware(c3600_t *router)
{
vm_instance_t *vm = router->vm;
printf("C3600 instance '%s' (id %d):\n",vm->name,vm->instance_id);
printf(" VM Status : %d\n",vm->status);
printf(" RAM size : %u Mb\n",vm->ram_size);
printf(" NVRAM size : %u Kb\n",vm->nvram_size);
printf(" Chassis : %s\n",router->chassis_driver->chassis_type);
printf(" IOS image : %s\n\n",vm->ios_image);
if (vm->debug_level > 0) {
dev_show_list(vm);
pci_dev_show_list(vm->pci_bus[0]);
pci_dev_show_list(vm->pci_bus[1]);
printf("\n");
}
} | false | false | false | false | false | 0 |
DrawingAreaVisualDisk()
{
selected_vp = NULL ;
//set and allocated some standard colors
color_used .set( Utils::get_color( GParted::FS_USED ) );
get_colormap() ->alloc_color( color_used ) ;
color_unused .set( Utils::get_color( GParted::FS_UNUSED ) );
get_colormap() ->alloc_color( color_unused ) ;
color_unallocated .set( Utils::get_color( GParted::FS_UNALLOCATED ) );
get_colormap() ->alloc_color( color_unallocated ) ;
color_text .set( "black" );
get_colormap() ->alloc_color( color_text ) ;
add_events( Gdk::BUTTON_PRESS_MASK );
set_size_request( -1, HEIGHT ) ;
} | false | false | false | false | false | 0 |
_thread_id_intercept(DB_ENV *dbenv,
pid_t *pidp, db_threadid_t *thridp)
{
DbEnv *cxxenv = DbEnv::get_DbEnv(dbenv);
if (cxxenv == 0) {
DB_ERROR(DbEnv::get_DbEnv(dbenv),
"DbEnv::thread_id_callback", EINVAL, ON_ERROR_UNKNOWN);
} else
cxxenv->thread_id_callback_(cxxenv, pidp, thridp);
} | false | false | false | false | false | 0 |
libbfio_pool_append_handle_to_last_used_list(
libbfio_internal_pool_t *internal_pool,
libbfio_handle_t *handle,
libcerror_error_t **error )
{
libbfio_internal_handle_t *internal_handle = NULL;
libcdata_list_element_t *last_used_list_element = NULL;
static char *function = "libbfio_pool_append_handle_to_last_used_list";
if( internal_pool == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid pool.",
function );
return( -1 );
}
if( internal_pool->last_used_list == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: invalid pool - missing last used list.",
function );
return( -1 );
}
if( handle == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid handle.",
function );
return( -1 );
}
/* Check if there is room in the pool for another open handle
*/
if( ( internal_pool->maximum_number_of_open_handles != LIBBFIO_POOL_UNLIMITED_NUMBER_OF_OPEN_HANDLES )
&& ( ( internal_pool->number_of_open_handles + 1 ) >= internal_pool->maximum_number_of_open_handles ) )
{
if( libcdata_list_get_last_element(
internal_pool->last_used_list,
&last_used_list_element,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve last list element from last used list.",
function );
return( -1 );
}
if( libcdata_list_element_get_value(
last_used_list_element,
(intptr_t **) &internal_handle,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_GET_FAILED,
"%s: unable to retrieve value from last used list element.",
function );
return( -1 );
}
if( libcdata_list_remove_element(
internal_pool->last_used_list,
last_used_list_element,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_REMOVE_FAILED,
"%s: unable to remove last list element from last used list.",
function );
return( -1 );
}
if( internal_handle != NULL )
{
if( libbfio_handle_close(
(libbfio_handle_t *) internal_handle,
error ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_IO,
LIBCERROR_IO_ERROR_CLOSE_FAILED,
"%s: unable to close handle.",
function );
libcdata_list_element_free(
&last_used_list_element,
NULL,
NULL );
return( -1 );
}
internal_handle->pool_last_used_list_element = NULL;
/* Make sure the truncate flag is removed from the handle
*/
internal_handle->access_flags &= ~( LIBBFIO_ACCESS_FLAG_TRUNCATE );
}
/* The last used list element is reused to contain the new last used entry
*/
}
else
{
if( libcdata_list_element_initialize(
&last_used_list_element,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
"%s: unable to create last used list element.",
function );
return( -1 );
}
internal_pool->number_of_open_handles++;
}
internal_handle = (libbfio_internal_handle_t *) handle;
if( libcdata_list_element_set_value(
last_used_list_element,
(intptr_t *) handle,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_SET_FAILED,
"%s: unable to set value int last used list element.",
function );
return( -1 );
}
internal_handle->pool_last_used_list_element = last_used_list_element;
if( libcdata_list_prepend_element(
internal_pool->last_used_list,
last_used_list_element,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_APPEND_FAILED,
"%s: unable to prepend last used list element to list.",
function );
libcdata_list_element_free(
&last_used_list_element,
NULL,
NULL );
return( -1 );
}
return( 1 );
} | false | false | false | false | false | 0 |
bch_cache_accounting_add_kobjs(struct cache_accounting *acc,
struct kobject *parent)
{
int ret = kobject_add(&acc->total.kobj, parent,
"stats_total");
ret = ret ?: kobject_add(&acc->five_minute.kobj, parent,
"stats_five_minute");
ret = ret ?: kobject_add(&acc->hour.kobj, parent,
"stats_hour");
ret = ret ?: kobject_add(&acc->day.kobj, parent,
"stats_day");
return ret;
} | false | false | false | false | false | 0 |
getByte(int pos) {
if (!fillBuf(pos, 1)) {
return -1;
}
return buf[pos - bufPos] & 0xff;
} | false | false | false | false | false | 0 |
AcpiDsDoImplicitReturn (
ACPI_OPERAND_OBJECT *ReturnDesc,
ACPI_WALK_STATE *WalkState,
BOOLEAN AddReference)
{
ACPI_FUNCTION_NAME (DsDoImplicitReturn);
/*
* Slack must be enabled for this feature, and we must
* have a valid return object
*/
if ((!AcpiGbl_EnableInterpreterSlack) ||
(!ReturnDesc))
{
return (FALSE);
}
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
"Result %p will be implicitly returned; Prev=%p\n",
ReturnDesc,
WalkState->ImplicitReturnObj));
/*
* Delete any "stale" implicit return value first. However, in
* complex statements, the implicit return value can be
* bubbled up several levels, so we don't clear the value if it
* is the same as the ReturnDesc.
*/
if (WalkState->ImplicitReturnObj)
{
if (WalkState->ImplicitReturnObj == ReturnDesc)
{
return (TRUE);
}
AcpiDsClearImplicitReturn (WalkState);
}
/* Save the implicit return value, add a reference if requested */
WalkState->ImplicitReturnObj = ReturnDesc;
if (AddReference)
{
AcpiUtAddReference (ReturnDesc);
}
return (TRUE);
} | false | false | false | false | false | 0 |
serialize_nodes(FILE *file, dns_rbtnode_t *node, uintptr_t parent,
dns_rbtdatawriter_t datawriter, void *writer_arg,
uintptr_t *where, isc_uint64_t *crc)
{
uintptr_t left = 0, right = 0, down = 0, data = 0;
off_t location = 0, offset_adjust;
isc_result_t result;
if (node == NULL) {
if (where != NULL)
*where = 0;
return (ISC_R_SUCCESS);
}
/* Reserve space for current node. */
CHECK(isc_stdio_tell(file, &location));
location = dns_rbt_serialize_align(location);
CHECK(isc_stdio_seek(file, location, SEEK_SET));
offset_adjust = dns_rbt_serialize_align(location + NODE_SIZE(node));
CHECK(isc_stdio_seek(file, offset_adjust, SEEK_SET));
/*
* Serialize the rest of the tree.
*
* WARNING: A change in the order (from left, right, down)
* will break the way the crc hash is computed.
*/
CHECK(serialize_nodes(file, getleft(node, NULL), location,
datawriter, writer_arg, &left, crc));
CHECK(serialize_nodes(file, getright(node, NULL), location,
datawriter, writer_arg, &right, crc));
CHECK(serialize_nodes(file, getdown(node, NULL), location,
datawriter, writer_arg, &down, crc));
if (node->data != NULL) {
off_t ret;
CHECK(isc_stdio_tell(file, &ret));
ret = dns_rbt_serialize_align(ret);
CHECK(isc_stdio_seek(file, ret, SEEK_SET));
data = ret;
datawriter(file, node->data, writer_arg, crc);
}
/* Seek back to reserved space. */
CHECK(isc_stdio_seek(file, location, SEEK_SET));
/* Serialize the current node. */
CHECK(serialize_node(file, node, left, right, down, parent, data, crc));
/* Ensure we are always at the end of the file. */
CHECK(isc_stdio_seek(file, 0, SEEK_END));
if (where != NULL)
*where = (uintptr_t) location;
cleanup:
return (result);
} | false | false | false | false | false | 0 |
liblistreverseX(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)
{
ScmObj list_scm;
ScmObj list;
ScmObj tail_scm;
ScmObj tail;
ScmObj SCM_SUBRARGS[3];
int SCM_i;
SCM_ENTER_SUBR("reverse!");
if (SCM_ARGCNT >= 3
&& !SCM_NULLP(SCM_ARGREF(SCM_ARGCNT-1)))
Scm_Error("too many arguments: up to 2 is expected, %d given.", SCM_ARGCNT + Scm_Length(SCM_ARGREF(SCM_ARGCNT-1)) - 1);
for (SCM_i=0; SCM_i<3; SCM_i++) {
SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
}
list_scm = SCM_SUBRARGS[0];
list = (list_scm);
if (SCM_ARGCNT > 1+1) {
tail_scm = SCM_SUBRARGS[1];
} else {
tail_scm = SCM_NIL;
}
tail = (tail_scm);
{
{
ScmObj SCM_RESULT;
SCM_RESULT=(Scm_Reverse2X(list,tail));
SCM_RETURN(SCM_OBJ_SAFE(SCM_RESULT));
}
}
} | false | false | false | false | false | 0 |
egl_pipe_create_drm_screen(const char *name, int fd)
{
if (strcmp(name, "i915") == 0)
return pipe_i915_create_screen(fd);
else if (strcmp(name, "i965") == 0)
return pipe_ilo_create_screen(fd);
else if (strcmp(name, "nouveau") == 0)
return pipe_nouveau_create_screen(fd);
else if (strcmp(name, "r300") == 0)
return pipe_r300_create_screen(fd);
else if (strcmp(name, "r600") == 0)
return pipe_r600_create_screen(fd);
else if (strcmp(name, "radeonsi") == 0)
return pipe_radeonsi_create_screen(fd);
else if (strcmp(name, "vmwgfx") == 0)
return pipe_vmwgfx_create_screen(fd);
else if ((strcmp(name, "kgsl") == 0) || (strcmp(name, "msm") == 0))
return pipe_freedreno_create_screen(fd);
else
return NULL;
} | false | false | false | false | false | 0 |
i2c_lpc2k_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
int msg_num)
{
struct lpc2k_i2c *i2c = i2c_get_adapdata(adap);
int ret, i;
u32 stat;
/* Check for bus idle condition */
stat = readl(i2c->base + LPC24XX_I2STAT);
if (stat != M_I2C_IDLE) {
/* Something is holding the bus, try to clear it */
return i2c_lpc2k_clear_arb(i2c);
}
/* Process a single message at a time */
for (i = 0; i < msg_num; i++) {
/* Save message pointer and current message data index */
i2c->msg = &msgs[i];
i2c->msg_idx = 0;
i2c->msg_status = -EBUSY;
i2c->is_last = (i == (msg_num - 1));
ret = lpc2k_process_msg(i2c, i);
if (ret)
return ret;
}
return msg_num;
} | false | false | false | false | false | 0 |
top_stack(PDFSCAN *ps)
{
if (ps->ostack_idx <= 0) {
pdf_scan_msgf(ps, "top_stack: stack is empty\n");
return invalidref;
}
return ps->ostack[ps->ostack_idx];
} | false | false | false | false | false | 0 |
max8997_muic_chg_handler(struct max8997_muic_info *info)
{
int chg_type;
bool attached;
int adc;
chg_type = max8997_muic_get_cable_type(info,
MAX8997_CABLE_GROUP_CHG, &attached);
switch (chg_type) {
case MAX8997_CHARGER_TYPE_NONE:
break;
case MAX8997_CHARGER_TYPE_USB:
adc = info->status[0] & STATUS1_ADC_MASK;
adc >>= STATUS1_ADC_SHIFT;
if ((adc & STATUS1_ADC_MASK) == MAX8997_MUIC_ADC_OPEN) {
max8997_muic_handle_usb(info,
MAX8997_USB_DEVICE, attached);
}
break;
case MAX8997_CHARGER_TYPE_DOWNSTREAM_PORT:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_CDP,
attached);
break;
case MAX8997_CHARGER_TYPE_DEDICATED_CHG:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_DCP,
attached);
break;
case MAX8997_CHARGER_TYPE_500MA:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_SLOW,
attached);
break;
case MAX8997_CHARGER_TYPE_1A:
extcon_set_cable_state_(info->edev, EXTCON_CHG_USB_FAST,
attached);
break;
default:
dev_err(info->dev,
"failed to detect %s unknown chg cable (type:0x%x)\n",
attached ? "attached" : "detached", chg_type);
return -EINVAL;
}
return 0;
} | false | false | false | false | false | 0 |
tagtoname(char const tag[],char const *&t)
{
char const *s;
for(s=tag;isspace(*s);s++);
for(t=s;(*t)&&((*t)!='>')&&((*t)!='/')&&!isspace(*t);++t);
return GUTF8String(s,t-s);
} | false | false | false | false | false | 0 |
tableiter_next(tableiterobject *ti, PyObject *args)
{
apr_table_entry_t *elts = (apr_table_entry_t *) ti->table->table->a.elts;
/* make sure the table hasn't change while being iterated */
if (ti->ti_nelts != ti->table->table->a.nelts) {
PyErr_SetString(PyExc_RuntimeError,
"table changed size during iteration");
return NULL;
}
/* return the next key/val */
if (ti->ti_pos < ti->table->table->a.nelts) {
return (*ti->ti_select)(&elts[ti->ti_pos++]);
}
/* the end has been reached */
PyErr_SetObject(PyExc_StopIteration, Py_None);
return NULL;
} | false | false | false | false | false | 0 |
session_set_udata_flag(session *s, int flag)
{
if (!s || (flag < 0) || (flag > 63))
return;
s->udata_flags |= ((uint64_t)1) << flag;
} | false | false | false | false | false | 0 |
brief_maybe_flash_button()
{
UI_BUTTON *b;
if ( Num_brief_stages <= 0 )
return;
if ( Closeup_icon != NULL ) {
common_flash_button_init();
return;
}
if ( common_flash_bright() ) {
if ( Current_brief_stage == (Num_brief_stages-1) ) {
// AL 30-3-98: Don't flash ship selection button if in a training mission,
if ( brief_only_allow_briefing() ) {
return;
}
b = &Common_buttons[Current_screen-1][gr_screen.res][1].button; // ship select button
} else {
b = &Brief_buttons[gr_screen.res][1].button; // next stage button
}
if ( b->button_hilighted() ) {
common_flash_button_init();
} else {
b->draw_forced(1);
}
}
} | false | false | false | false | false | 0 |
LookToRead_Look_Exact(void *pp, const void **buf, size_t *size)
{
SRes res = SZ_OK;
CLookToRead *p = (CLookToRead *)pp;
size_t size2 = p->size - p->pos;
if (size2 == 0 && *size > 0)
{
p->pos = 0;
if (*size > LookToRead_BUF_SIZE)
*size = LookToRead_BUF_SIZE;
res = p->realStream->Read(p->realStream, p->buf, size);
size2 = p->size = *size;
}
if (size2 < *size)
*size = size2;
*buf = p->buf + p->pos;
return res;
} | false | false | false | false | false | 0 |
plotstuff_set_wcs_file(plot_args_t* pargs, const char* filename, int ext) {
anwcs_t* wcs = anwcs_open(filename, ext);
if (!wcs) {
ERROR("Failed to read WCS file \"%s\", extension %i", filename, ext);
return -1;
}
return plotstuff_set_wcs(pargs, wcs);
} | false | false | false | false | false | 0 |
timestamp_recv(PG_FUNCTION_ARGS)
{
StringInfo buf = (StringInfo) PG_GETARG_POINTER(0);
#ifdef NOT_USED
Oid typelem = PG_GETARG_OID(1);
#endif
int32 typmod = PG_GETARG_INT32(2);
Timestamp timestamp;
struct pg_tm tt,
*tm = &tt;
fsec_t fsec;
#ifdef HAVE_INT64_TIMESTAMP
timestamp = (Timestamp) pq_getmsgint64(buf);
#else
timestamp = (Timestamp) pq_getmsgfloat8(buf);
#endif
/* rangecheck: see if timestamp_out would like it */
if (TIMESTAMP_NOT_FINITE(timestamp))
/* ok */ ;
else if (timestamp2tm(timestamp, NULL, tm, &fsec, NULL, NULL) != 0)
ereport(ERROR,
(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
errmsg("timestamp out of range")));
AdjustTimestampForTypmod(×tamp, typmod);
PG_RETURN_TIMESTAMP(timestamp);
} | false | false | false | false | false | 0 |
child_watch(GPid pid, gint status, gpointer data) {
GtkTextBuffer *buffer;
GtkTextIter iter;
gchar *tmpc, *str, buf[5];
sprintf(buf, "%i", WEXITSTATUS(status));
str = g_strconcat(_("Rsync process exit status: "), buf, "\n", NULL);
buffer = gtk_text_view_get_buffer((GtkTextView*)data);
if (status == 0) {
gtk_text_buffer_insert_at_cursor(buffer, str, -1);
} else {
gtk_text_buffer_get_end_iter(buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, str, -1, "fore-red", NULL);
tmpc = g_strconcat(error_list, str, NULL);
g_free(error_list);
error_list = tmpc;
had_error = TRUE;
}
scroll_to_end((GtkTextView*)data, FALSE);
if (config_log) fputs(str, log_file);
g_free(str);
rsync_cleanup(NULL);
must_scroll = TRUE;
} | false | false | false | false | false | 0 |
recent_backend_open_for_read (GVfsBackend *vfs_backend,
GVfsJobOpenForRead *job,
const char *filename)
{
GVfsBackendRecent *backend = G_VFS_BACKEND_RECENT (vfs_backend);
GError *error = NULL;
if (filename[1] == '\0')
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY,
_("Can't open directory"));
else
{
GFile *real;
real = recent_backend_get_file (backend, filename, NULL, &error);
if (real)
{
GFileInputStream *stream;
stream = g_file_read (real, G_VFS_JOB (job)->cancellable, &error);
g_object_unref (real);
if (stream)
{
g_vfs_job_open_for_read_set_handle (job, stream);
g_vfs_job_open_for_read_set_can_seek (job, TRUE);
g_vfs_job_succeeded (G_VFS_JOB (job));
return TRUE;
}
}
}
g_vfs_job_failed_from_error (G_VFS_JOB (job), error);
g_error_free (error);
return TRUE;
} | false | false | false | false | false | 0 |
operator==(const PeerAddrEntry& entry) const
{
return ipaddr_ == entry.ipaddr_ && port_ == entry.port_;
} | false | false | false | false | false | 0 |
search_empty(struct snd_util_memhdr *hdr, int size)
{
struct snd_util_memblk *blk;
int page, psize;
struct list_head *p;
psize = get_aligned_page(size + ALIGN_PAGE_SIZE -1);
page = 0;
list_for_each(p, &hdr->block) {
blk = list_entry(p, struct snd_util_memblk, list);
if (page + psize <= firstpg(blk))
goto __found_pages;
page = lastpg(blk) + 1;
}
if (page + psize > MAX_ALIGN_PAGES)
return NULL;
__found_pages:
/* create a new memory block */
blk = __snd_util_memblk_new(hdr, psize * ALIGN_PAGE_SIZE, p->prev);
if (blk == NULL)
return NULL;
blk->offset = aligned_page_offset(page); /* set aligned offset */
firstpg(blk) = page;
lastpg(blk) = page + psize - 1;
return blk;
} | false | false | false | false | false | 0 |
tp_connection_status_changed (TpConnection *self,
guint status,
guint reason)
{
DEBUG ("%p: %d -> %d because %d", self, self->priv->status, status, reason);
if (status == TP_CONNECTION_STATUS_CONNECTED)
{
if (self->priv->introspection_call != NULL &&
!self->priv->introspecting_after_connected)
{
/* We thought we knew what was going on, but now the connection has
* gone to CONNECTED and all bets are off. Start again! */
DEBUG ("Cancelling pre-CONNECTED introspection and starting again");
tp_proxy_pending_call_cancel (self->priv->introspection_call);
self->priv->introspection_call = NULL;
g_list_free (self->priv->introspect_needed);
self->priv->introspect_needed = NULL;
}
self->priv->introspecting_after_connected = TRUE;
/* we defer the perceived change to CONNECTED until ready */
if (self->priv->introspection_call == NULL)
{
self->priv->introspection_call =
tp_cli_dbus_properties_call_get_all (self, -1,
TP_IFACE_CONNECTION, _tp_connection_got_properties, NULL, NULL, NULL);
}
}
else
{
self->priv->status = status;
self->priv->status_reason = reason;
g_object_notify ((GObject *) self, "status");
g_object_notify ((GObject *) self, "status-reason");
}
} | false | false | false | false | false | 0 |
get_stasche_lm_dt_for_block(Block *lm_block)
{
Stasche_lm_dt *sld = NULL;
if (lm_block == NULL) return NULL;
if (Qmap_lookup(sld_map, lm_block, (void *)&sld)) {
return sld;
}
return NULL;
} | false | false | false | false | false | 0 |
fr_command_ar_extract (FrCommand *comm,
const char *from_file,
GList *file_list,
const char *dest_dir,
gboolean overwrite,
gboolean skip_older,
gboolean junk_paths)
{
GList *scan;
fr_process_begin_command (comm->process, "ar");
if (dest_dir != NULL)
fr_process_set_working_dir (comm->process, dest_dir);
fr_process_add_arg (comm->process, "x");
fr_process_add_arg (comm->process, comm->filename);
for (scan = file_list; scan; scan = scan->next)
fr_process_add_arg (comm->process, scan->data);
fr_process_end_command (comm->process);
} | false | false | false | false | false | 0 |
_e_mod_ind_win_cb_menu_pre(void *data, E_Menu *mn)
{
Ind_Win *iwin;
E_Menu_Item *mi;
if (!(iwin = data)) return;
e_menu_pre_activate_callback_set(mn, NULL, NULL);
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Set Contents"));
e_util_menu_item_theme_icon_set(mi, "preferences-desktop-shelf");
e_menu_item_callback_set(mi, _e_mod_ind_win_cb_menu_contents, iwin);
mi = e_menu_item_new(mn);
if (iwin->gadcon->editing)
e_menu_item_label_set(mi, _("End Move/Resize Items"));
else
e_menu_item_label_set(mi, _("Begin Move/Resize Items"));
e_util_menu_item_theme_icon_set(mi, "transform-scale");
e_menu_item_callback_set(mi, _e_mod_ind_win_cb_menu_edit, iwin);
} | false | false | false | false | false | 0 |
isMergableIan ( const modelCacheIan* q ) const
{
if ( posDConcepts.intersects(q->negDConcepts)
|| q->posDConcepts.intersects(negDConcepts)
# ifdef RKG_USE_SIMPLE_RULES
|| getExtra(/*det=*/true).intersects(q->getExtra(/*det=*/true))
# endif
)
return csInvalid;
else if ( posDConcepts.intersects(q->negNConcepts)
|| posNConcepts.intersects(q->negDConcepts)
|| posNConcepts.intersects(q->negNConcepts)
|| q->posDConcepts.intersects(negNConcepts)
|| q->posNConcepts.intersects(negDConcepts)
|| q->posNConcepts.intersects(negNConcepts)
# ifdef RKG_USE_SIMPLE_RULES
|| getExtra(/*det=*/true).intersects(q->getExtra(/*det=*/false))
|| getExtra(/*det=*/false).intersects(q->getExtra(/*det=*/true))
|| getExtra(/*det=*/false).intersects(q->getExtra(/*det=*/false))
# endif
|| existsRoles.intersects(q->forallRoles)
|| q->existsRoles.intersects(forallRoles)
|| funcRoles.intersects(q->funcRoles) )
return csFailed;
else // could be merged
return csValid;
} | false | false | false | false | false | 0 |
insertRowBefore(unsigned row_,const MSBinaryVector& aBinaryVector_)
{
if (row_+1>rows()) return *this;
if (aBinaryVector_.length()!=columns())
{
error("MSBinaryMatrix length error.");
return *this;
}
unsigned newLength=(rows()+1)*columns();
MSTypeData<unsigned char,MSAllocator<unsigned char> > *d=MSTypeData<unsigned char,MSAllocator<unsigned char> >::allocateWithLength(newLength);
unsigned char *dp=d->elements();
unsigned char *mp=data();
unsigned char *vp=aBinaryVector_.data();
unsigned i,j;
for (j=0;j<rows()+1;j++)
{
for (i=0;i<columns();i++) *dp++=(j==row_)?*vp++:*mp++;
}
freeData();
_pData=d;
_rows++;
_count=newLength;
changed();
return *this;
} | false | false | false | true | false | 1 |
gth_transition_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GthTransition *self = GTH_TRANSITION (object);
switch (property_id) {
case PROP_ID:
g_free (self->priv->id);
self->priv->id = g_value_dup_string (value);
if (self->priv->id == NULL)
self->priv->id = g_strdup ("");
break;
case PROP_DISPLAY_NAME:
g_free (self->priv->display_name);
self->priv->display_name = g_value_dup_string (value);
if (self->priv->display_name == NULL)
self->priv->display_name = g_strdup ("");
break;
case PROP_FRAME_FUNC:
self->priv->frame_func = g_value_get_pointer (value);
break;
default:
break;
}
} | false | false | false | false | false | 0 |
mgrib_drawCline(HPoint3 *p1, HPoint3 *p2)
{
Pt3Coord angle,length;
Point3 t,axis;
Point3 start, end;
HPoint3 Hstart, Hend;
static float unitz[3] = {0.0, 0.0, 1.0};
float radius = 0.004;
float size;
int bounded(Point3 *p);
HPt3Dehomogenize(p1, &Hstart);
HPt3Dehomogenize(p2, &Hend);
start.x = Hstart.x;
start.y = Hstart.y;
start.z = Hstart.z;
end.x = Hend.x;
end.y = Hend.y;
end.z = Hend.z;
if (! Pt3Equal(&start,&end)) {
size = radius*_mgc->astk->ap.linewidth;
Pt3Sub(&end,&start,&t);
length = Pt3Length(&t);
Pt3Cross((Point3*)(void *)unitz,&t,&axis);
Pt3Unit(&t);
angle = Pt3Dot((Point3*)(void *)unitz,&t);
angle = acos(angle);
mrti(mr_transformbegin, mr_NULL);
if (bounded(&start))
mrti(mr_translate,
mr_float, start.x,
mr_float, start.y,
mr_float, start.z, mr_NULL);
if ( (t.x == 0.0) && (t.y == 0.0) && (t.z < 0.0)) {
/* if along negative z axis cross product is 0
but rotation by 180 degrees is necessary
(angle is computed correctly) */
axis.y = 1.0;
}
if (bounded(&axis))
mrti(mr_rotate, mr_float, DEGREES(angle),
mr_float, axis.x, mr_float, axis.y, mr_float, axis.z, mr_NULL);
if (length < MAXCLINE)
mrti(mr_cylinder, mr_float, size, mr_float, 0.,
mr_float, length, mr_float, 360., mr_NULL);
mrti(mr_transformend, mr_NULL);
}
} | false | false | false | false | false | 0 |
r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
{
struct drm_device *dev = encoder->dev;
struct radeon_device *rdev = dev->dev_private;
if (mute)
WREG32_OR(HDMI0_GC + offset, HDMI0_GC_AVMUTE);
else
WREG32_AND(HDMI0_GC + offset, ~HDMI0_GC_AVMUTE);
} | false | false | false | false | false | 0 |
avatar_image_real_set_pixbuf (GiggleAvatarImage *image,
GdkPixbuf *pixbuf)
{
GiggleAvatarImagePriv *priv = GET_PRIV (image);
if (pixbuf == priv->pixbuf)
return;
if (priv->pixbuf) {
g_object_unref (priv->pixbuf);
priv->pixbuf = NULL;
}
if (pixbuf)
priv->pixbuf = g_object_ref (pixbuf);
gtk_widget_queue_resize (GTK_WIDGET (image));
} | false | false | false | false | false | 0 |
rpr0521_runtime_resume(struct device *dev)
{
struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
struct rpr0521_data *data = iio_priv(indio_dev);
int ret;
if (data->als_ps_need_en) {
ret = rpr0521_als_enable(data, RPR0521_MODE_ALS_ENABLE);
if (ret < 0)
return ret;
data->als_ps_need_en = false;
}
if (data->pxs_ps_need_en) {
ret = rpr0521_pxs_enable(data, RPR0521_MODE_PXS_ENABLE);
if (ret < 0)
return ret;
data->pxs_ps_need_en = false;
}
return 0;
} | false | false | false | false | false | 0 |
readHeader( char *buffer, QString &name, QString &symlink ) {
name.truncate(0);
symlink.truncate(0);
while (true) {
qint64 n = readRawHeader(buffer);
if (n != 0x200) return n;
// is it a longlink?
if (strcmp(buffer,"././@LongLink") == 0) {
char typeflag = buffer[0x9c];
QByteArray longlink;
readLonglink(buffer,longlink);
switch (typeflag) {
case 'L': name = QFile::decodeName(longlink); break;
case 'K': symlink = QFile::decodeName(longlink); break;
}/*end switch*/
} else {
break;
}/*end if*/
}/*wend*/
// if not result of longlink, read names directly from the header
if (name.isEmpty())
// there are names that are exactly 100 bytes long
// and neither longlink nor \0 terminated (bug:101472)
name = QFile::decodeName(QByteArray(buffer, 100));
if (symlink.isEmpty())
symlink = QFile::decodeName(QByteArray(buffer + 0x9d /*?*/, 100));
return 0x200;
} | false | false | false | false | false | 0 |
vorbis_inverse_coupling(float *mag, float *ang, int blocksize)
{
int i;
for(i=0; i<blocksize; i++)
{
if (mag[i]>0.0) {
if (ang[i]>0.0) {
ang[i]=mag[i]-ang[i];
} else {
float temp=ang[i];
ang[i]=mag[i];
mag[i]+=temp;
}
} else {
if (ang[i]>0.0) {
ang[i]+=mag[i];
} else {
float temp=ang[i];
ang[i]=mag[i];
mag[i]-=temp;
}
}
}
} | false | false | false | false | false | 0 |
addonestring (luaL_Buffer *b, CapState *cs, const char *what) {
switch (captype(cs->cap)) {
case Cstring:
stringcap(b, cs); /* add capture directly to buffer */
return 1;
case Csubst:
substcap(b, cs); /* add capture directly to buffer */
return 1;
default: {
lua_State *L = cs->L;
int n = pushcapture(cs);
if (n > 0) {
if (n > 1) lua_pop(L, n - 1); /* only one result */
if (!lua_isstring(L, -1))
luaL_error(L, "invalid %s value (a %s)", what, luaL_typename(L, -1));
luaL_addvalue(b);
}
return n;
}
}
} | false | false | false | false | false | 0 |
GetInfoGene( )
{
gint i;
if(StrLink)
{
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,StrLink,-1);
g_free(StrLink);
StrLink = NULL;
}
for (i=0;i<8;i++) {
if(TestButtonActive(CheckButtons[i]) )
{
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"\n#",-1);
break;
}
}
if(TestButtonActive(CheckButtons[0]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Gfinput IOP(6/7=3) ",-1);
if(TestButtonActive(CheckButtons[1]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Pop=full ",-1);
if(TestButtonActive(CheckButtons[5]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Density ",-1);
if(TestButtonActive(CheckButtons[2]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Archive ",-1);
else
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Test ",-1);
if(TestButtonActive(CheckButtons[3]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Nosymm ",-1);
if(TestButtonActive(CheckButtons[6]) || TestButtonActive(CheckButtons[7]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Guess(",-1);
if(TestButtonActive(CheckButtons[6]))
{
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Mix",-1);
if(TestButtonActive(CheckButtons[7]))
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,",Read",-1);
}else
{
if(TestButtonActive(CheckButtons[7]))
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,"Read",-1);
}
if(TestButtonActive(CheckButtons[6]) || TestButtonActive(CheckButtons[7]) )
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL,") ",-1);
if(TestButtonActive(CheckButtons[8]) )
{
gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL," Geom=Check ",-1);
GeomFromCheck = TRUE;
}
} | false | false | false | false | false | 0 |
source_get_properties(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct audio_device *device = data;
struct source *source = device->source;
DBusMessage *reply;
DBusMessageIter iter;
DBusMessageIter dict;
const char *state;
reply = dbus_message_new_method_return(msg);
if (!reply)
return NULL;
dbus_message_iter_init_append(reply, &iter);
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
/* State */
state = state2str(source->state);
if (state)
dict_append_entry(&dict, "State", DBUS_TYPE_STRING, &state);
dbus_message_iter_close_container(&iter, &dict);
return reply;
} | false | false | false | false | false | 0 |
pkg_installLibrary(const char *installDir, const char *targetDir) {
int32_t result = 0;
char cmd[SMALL_BUFFER_MAX_SIZE];
sprintf(cmd, "cd %s && %s %s %s%s%s",
targetDir,
pkgDataFlags[INSTALL_CMD],
libFileNames[LIB_FILE_VERSION],
installDir, PKGDATA_FILE_SEP_STRING, libFileNames[LIB_FILE_VERSION]
);
result = system(cmd);
if (result != 0) {
return result;
}
return pkg_createSymLinks(installDir);
} | false | false | false | false | false | 0 |
put_8(char *p, unsigned int v)
{
if(p >= (buf + WAVE_PARTIAL_VCD_RING_BUFFER_SIZE))
{
p -= WAVE_PARTIAL_VCD_RING_BUFFER_SIZE;
}
*p = (unsigned char)v;
} | false | false | false | false | false | 0 |
create_greeter_session (Seat *seat)
{
gchar *sessions_dir, **argv;
SessionConfig *session_config;
Greeter *greeter_session;
const gchar *greeter_wrapper;
l_debug (seat, "Creating greeter session");
sessions_dir = config_get_string (config_get_instance (), "LightDM", "greeters-directory");
session_config = find_session_config (seat, sessions_dir, seat_get_string_property (seat, "greeter-session"));
g_free (sessions_dir);
if (!session_config)
return NULL;
argv = get_session_argv (seat, session_config, NULL);
greeter_wrapper = seat_get_string_property (seat, "greeter-wrapper");
if (greeter_wrapper)
{
gchar *path;
path = g_find_program_in_path (greeter_wrapper);
prepend_argv (&argv, path ? path : greeter_wrapper);
g_free (path);
}
greeter_session = SEAT_GET_CLASS (seat)->create_greeter_session (seat);
session_set_session_type (SESSION (greeter_session), session_config_get_session_type (session_config));
seat->priv->sessions = g_list_append (seat->priv->sessions, SESSION (greeter_session));
g_signal_connect (greeter_session, "notify::active-username", G_CALLBACK (greeter_active_username_changed_cb), seat);
g_signal_connect (greeter_session, "authentication-complete", G_CALLBACK (session_authentication_complete_cb), seat);
g_signal_connect (greeter_session, "stopped", G_CALLBACK (session_stopped_cb), seat);
set_session_env (SESSION (greeter_session));
session_set_env (SESSION (greeter_session), "XDG_SESSION_CLASS", "greeter");
session_set_pam_service (SESSION (greeter_session), GREETER_SERVICE);
if (getuid () == 0)
{
gchar *greeter_user;
greeter_user = config_get_string (config_get_instance (), "LightDM", "greeter-user");
session_set_username (SESSION (greeter_session), greeter_user);
g_free (greeter_user);
}
else
{
/* In test mode run the greeter as ourself */
session_set_username (SESSION (greeter_session), user_get_name (accounts_get_current_user ()));
}
session_set_argv (SESSION (greeter_session), argv);
g_strfreev (argv);
greeter_set_pam_services (greeter_session, USER_SERVICE, AUTOLOGIN_SERVICE);
g_signal_connect (greeter_session, "create-session", G_CALLBACK (greeter_create_session_cb), seat);
g_signal_connect (greeter_session, "start-session", G_CALLBACK (greeter_start_session_cb), seat);
/* Set hints to greeter */
greeter_set_hint (greeter_session, "default-session", seat_get_string_property (seat, "user-session"));
greeter_set_allow_guest (greeter_session, seat_get_allow_guest (seat));
greeter_set_hint (greeter_session, "hide-users", seat_get_boolean_property (seat, "greeter-hide-users") ? "true" : "false");
greeter_set_hint (greeter_session, "show-manual-login", seat_get_boolean_property (seat, "greeter-show-manual-login") ? "true" : "false");
greeter_set_hint (greeter_session, "show-remote-login", seat_get_boolean_property (seat, "greeter-show-remote-login") ? "true" : "false");
greeter_set_hint (greeter_session, "has-guest-account", seat_get_allow_guest (seat) && seat_get_boolean_property (seat, "greeter-allow-guest") ? "true" : "false");
g_object_unref (session_config);
return greeter_session;
} | false | false | false | false | false | 0 |
GrowHeap(Length n) {
ASSERT(kMaxPages >= kMinSystemAlloc);
if (n > kMaxValidPages) return false;
Length ask = (n>kMinSystemAlloc) ? n : static_cast<Length>(kMinSystemAlloc);
size_t actual_size;
void* ptr = NULL;
if (EnsureLimit(ask)) {
ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize);
}
if (ptr == NULL) {
if (n < ask) {
// Try growing just "n" pages
ask = n;
if (EnsureLimit(ask)) {
ptr = TCMalloc_SystemAlloc(ask << kPageShift, &actual_size, kPageSize);
}
}
if (ptr == NULL) return false;
}
ask = actual_size >> kPageShift;
RecordGrowth(ask << kPageShift);
uint64_t old_system_bytes = stats_.system_bytes;
stats_.system_bytes += (ask << kPageShift);
const PageID p = reinterpret_cast<uintptr_t>(ptr) >> kPageShift;
ASSERT(p > 0);
// If we have already a lot of pages allocated, just pre allocate a bunch of
// memory for the page map. This prevents fragmentation by pagemap metadata
// when a program keeps allocating and freeing large blocks.
if (old_system_bytes < kPageMapBigAllocationThreshold
&& stats_.system_bytes >= kPageMapBigAllocationThreshold) {
pagemap_.PreallocateMoreMemory();
}
// Make sure pagemap_ has entries for all of the new pages.
// Plus ensure one before and one after so coalescing code
// does not need bounds-checking.
if (pagemap_.Ensure(p-1, ask+2)) {
// Pretend the new area is allocated and then Delete() it to cause
// any necessary coalescing to occur.
Span* span = NewSpan(p, ask);
RecordSpan(span);
Delete(span);
ASSERT(Check());
return true;
} else {
// We could not allocate memory within "pagemap_"
// TODO: Once we can return memory to the system, return the new span
return false;
}
} | false | false | false | false | false | 0 |
cl_SF_to_DF (const cl_SF& x)
{
// x entpacken:
var cl_signean sign;
var sintL exp;
var uint32 mant;
SF_decode(x, { return cl_DF_0; }, sign=,exp=,mant=);
// Mantisse um 52-16=36 Nullbits erweitern:
#if (cl_word_size==64)
return encode_DF(sign,exp,(uint64)mant<<(DF_mant_len-SF_mant_len));
#else
return encode_DF(sign,exp,mant<<(DF_mant_len-SF_mant_len-32),0);
#endif
}
} | false | false | false | false | false | 0 |
bnx2x_mcast_hdl_restore_e1h(struct bnx2x *bp,
struct bnx2x_mcast_obj *o, struct bnx2x_mcast_ramrod_params *p,
u32 *mc_filter)
{
int bit;
for (bit = bnx2x_mcast_get_next_bin(o, 0);
bit >= 0;
bit = bnx2x_mcast_get_next_bin(o, bit + 1)) {
BNX2X_57711_SET_MC_FILTER(mc_filter, bit);
DP(BNX2X_MSG_SP, "About to set bin %d\n", bit);
}
} | false | false | false | false | false | 0 |
cmd_exit(void)
{
/*
* "exit" is a synonym for quit except in engine mode
* when it means leave analyze mode
*/
if ( flags & ANALYZE ){
flags = preanalyze_flags ; /* this implicitly clears ANALYZE flag */
} else {
cmd_quit();
}
} | false | false | false | false | false | 0 |
RightTrim(char *Buf)
{
char *cp;
int Strlen = strlen(Buf);
if(Strlen > 0) {
cp = Buf + Strlen - 1;
for( ; ; ) {
if(*cp == ' ') {
*cp = 0;
}
else {
break;
}
if(cp-- == Buf) {
break;
}
}
}
} | false | false | false | false | false | 0 |
ipmi_sdr_parse_sensor_capabilities (ipmi_sdr_parse_ctx_t ctx,
const void *sdr_record,
unsigned int sdr_record_len,
uint8_t *event_message_control_support,
uint8_t *threshold_access_support,
uint8_t *hysteresis_support,
uint8_t *auto_re_arm_support,
uint8_t *entity_ignore_support)
{
fiid_obj_t obj_sdr_record = NULL;
uint32_t acceptable_record_types;
uint64_t val;
int rv = -1;
if (!ctx || ctx->magic != IPMI_SDR_PARSE_CTX_MAGIC)
{
ERR_TRACE (ipmi_sdr_parse_ctx_errormsg (ctx), ipmi_sdr_parse_ctx_errnum (ctx));
return (-1);
}
if (!sdr_record || !sdr_record_len)
{
SDR_PARSE_SET_ERRNUM (ctx, IPMI_SDR_PARSE_ERR_PARAMETERS);
return (-1);
}
acceptable_record_types = IPMI_SDR_PARSE_RECORD_TYPE_FULL_SENSOR_RECORD;
acceptable_record_types |= IPMI_SDR_PARSE_RECORD_TYPE_COMPACT_SENSOR_RECORD;
if (!(obj_sdr_record = _sdr_record_get_common (ctx,
sdr_record,
sdr_record_len,
acceptable_record_types)))
goto cleanup;
if (event_message_control_support)
{
if (FIID_OBJ_GET (obj_sdr_record,
"sensor_capabilities.event_message_control_support",
&val) < 0)
{
SDR_PARSE_FIID_OBJECT_ERROR_TO_SDR_PARSE_ERRNUM (ctx, obj_sdr_record);
goto cleanup;
}
*event_message_control_support = val;
}
if (threshold_access_support)
{
if (FIID_OBJ_GET (obj_sdr_record,
"sensor_capabilities.threshold_access_support",
&val) < 0)
{
SDR_PARSE_FIID_OBJECT_ERROR_TO_SDR_PARSE_ERRNUM (ctx, obj_sdr_record);
goto cleanup;
}
*threshold_access_support = val;
}
if (hysteresis_support)
{
if (FIID_OBJ_GET (obj_sdr_record,
"sensor_capabilities.hysteresis_support",
&val) < 0)
{
SDR_PARSE_FIID_OBJECT_ERROR_TO_SDR_PARSE_ERRNUM (ctx, obj_sdr_record);
goto cleanup;
}
*hysteresis_support = val;
}
if (auto_re_arm_support)
{
if (FIID_OBJ_GET (obj_sdr_record,
"sensor_capabilities.auto_re_arm_support",
&val) < 0)
{
SDR_PARSE_FIID_OBJECT_ERROR_TO_SDR_PARSE_ERRNUM (ctx, obj_sdr_record);
goto cleanup;
}
*auto_re_arm_support = val;
}
if (entity_ignore_support)
{
if (FIID_OBJ_GET (obj_sdr_record,
"sensor_capabilities.entity_ignore_support",
&val) < 0)
{
SDR_PARSE_FIID_OBJECT_ERROR_TO_SDR_PARSE_ERRNUM (ctx, obj_sdr_record);
goto cleanup;
}
*entity_ignore_support = val;
}
rv = 0;
ctx->errnum = IPMI_SDR_PARSE_ERR_SUCCESS;
cleanup:
fiid_obj_destroy (obj_sdr_record);
return (rv);
} | false | false | false | false | false | 0 |
myremove(struct filter *f)
{
struct threeddata *d = (struct threeddata *) f->data;
fractalc_resize_to(f->fractalc, f->image->width * f->image->pixelwidth,
f->image->height * f->image->pixelheight);
if (d->savedpalette != NULL) {
restorepalette(f->image->palette, d->savedpalette);
destroypalette(d->savedpalette);
d->savedpalette = NULL;
}
} | false | false | false | false | false | 0 |
Outline_cellhd(View * view, struct Cell_head *cellhd)
{
int row, col;
int top, bottom, left, right;
row = northing_to_row(&view->cell.head, cellhd->north) + .5;
top = row_to_view(view, row);
if (top < view->top)
top = view->top;
col = easting_to_col(&view->cell.head, cellhd->west) + .5;
left = col_to_view(view, col);
if (left < view->left)
left = view->left;
row = northing_to_row(&view->cell.head, cellhd->south) + .5;
bottom = row_to_view(view, row);
if (bottom > view->bottom)
bottom = view->bottom;
col = easting_to_col(&view->cell.head, cellhd->east) + .5;
right = col_to_view(view, col);
if (right > view->right)
right = view->right;
Outline_box(top, bottom, left, right);
return 0;
} | false | false | false | false | false | 0 |
mkplan_real_split(bench_problem *p, unsigned flags)
{
FFTW(plan) pln;
bench_tensor *sz = p->sz, *vecsz = p->vecsz;
FFTW(iodim) *dims, *howmany_dims;
bench_real *ri, *ii, *ro, *io;
int n2 = halfish_sizeof_problem(p);
extract_reim_split(FFTW_FORWARD, n2, (bench_real *) p->in, &ri, &ii);
extract_reim_split(FFTW_FORWARD, n2, (bench_real *) p->out, &ro, &io);
dims = bench_tensor_to_fftw_iodim(sz);
howmany_dims = bench_tensor_to_fftw_iodim(vecsz);
if (p->sign < 0) {
if (verbose > 2) printf("using plan_guru_split_dft_r2c\n");
pln = FFTW(plan_guru_split_dft_r2c)(sz->rnk, dims,
vecsz->rnk, howmany_dims,
ri, ro, io, flags);
}
else {
if (verbose > 2) printf("using plan_guru_split_dft_c2r\n");
pln = FFTW(plan_guru_split_dft_c2r)(sz->rnk, dims,
vecsz->rnk, howmany_dims,
ri, ii, ro, flags);
}
bench_free(dims);
bench_free(howmany_dims);
return pln;
} | false | false | false | false | false | 0 |
get_line_len(const char *buf, int buf_len) {
int len = 0;
while (len < buf_len && buf[len] != '\n') len++;
return buf[len] == '\n' ? len + 1: -1;
} | false | false | false | false | true | 1 |
HandlePhysRegDef(unsigned Reg, MachineInstr *MI,
SmallVectorImpl<unsigned> &Defs) {
// What parts of the register are previously defined?
SmallSet<unsigned, 32> Live;
if (PhysRegDef[Reg] || PhysRegUse[Reg]) {
for (MCSubRegIterator SubRegs(Reg, TRI, /*IncludeSelf=*/true);
SubRegs.isValid(); ++SubRegs)
Live.insert(*SubRegs);
} else {
for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
unsigned SubReg = *SubRegs;
// If a register isn't itself defined, but all parts that make up of it
// are defined, then consider it also defined.
// e.g.
// AL =
// AH =
// = AX
if (Live.count(SubReg))
continue;
if (PhysRegDef[SubReg] || PhysRegUse[SubReg]) {
for (MCSubRegIterator SS(SubReg, TRI, /*IncludeSelf=*/true);
SS.isValid(); ++SS)
Live.insert(*SS);
}
}
}
// Start from the largest piece, find the last time any part of the register
// is referenced.
HandlePhysRegKill(Reg, MI);
// Only some of the sub-registers are used.
for (MCSubRegIterator SubRegs(Reg, TRI); SubRegs.isValid(); ++SubRegs) {
unsigned SubReg = *SubRegs;
if (!Live.count(SubReg))
// Skip if this sub-register isn't defined.
continue;
HandlePhysRegKill(SubReg, MI);
}
if (MI)
Defs.push_back(Reg); // Remember this def.
} | false | false | false | false | false | 0 |
cxd2841er_read_snr_t(struct cxd2841er_priv *priv, u32 *snr)
{
u32 reg;
u8 data[2];
*snr = 0;
if (priv->state != STATE_ACTIVE_TC) {
dev_dbg(&priv->i2c->dev,
"%s(): invalid state %d\n", __func__, priv->state);
return -EINVAL;
}
cxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x10);
cxd2841er_read_regs(priv, I2C_SLVT, 0x28, data, sizeof(data));
reg = ((u32)data[0] << 8) | (u32)data[1];
if (reg == 0) {
dev_dbg(&priv->i2c->dev,
"%s(): reg value out of range\n", __func__);
return 0;
}
if (reg > 4996)
reg = 4996;
*snr = 10000 * ((intlog10(reg) - intlog10(5350 - reg)) >> 24) + 28500;
return 0;
} | false | false | false | false | false | 0 |
acpi_os_unmap_iomem(void __iomem *virt, acpi_size size)
{
struct acpi_ioremap *map;
if (!acpi_gbl_permanent_mmap) {
__acpi_unmap_table(virt, size);
return;
}
mutex_lock(&acpi_ioremap_lock);
map = acpi_map_lookup_virt(virt, size);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
WARN(true, PREFIX "%s: bad address %p\n", __func__, virt);
return;
}
acpi_os_drop_map_ref(map);
mutex_unlock(&acpi_ioremap_lock);
acpi_os_map_cleanup(map);
} | false | false | false | false | false | 0 |
brasero_metadata_set_new_uri (BraseroMetadata *self,
const gchar *uri)
{
BraseroMetadataPrivate *priv;
GstBus *bus;
priv = BRASERO_METADATA_PRIVATE (self);
BRASERO_UTILS_LOG ("New retrieval for %s %p", uri, self);
if (priv->error) {
g_error_free (priv->error);
priv->error = NULL;
}
brasero_metadata_info_free (priv->info);
priv->info = NULL;
if (priv->silence) {
g_free (priv->silence);
priv->silence = NULL;
}
priv->info = g_new0 (BraseroMetadataInfo, 1);
priv->info->uri = g_strdup (uri);
if (priv->pipeline){
gst_element_set_state (priv->pipeline, GST_STATE_NULL);
if (priv->source) {
gst_bin_remove (GST_BIN (priv->pipeline), priv->source);
priv->source = NULL;
}
if (priv->audio) {
gst_bin_remove (GST_BIN (priv->pipeline), priv->audio);
priv->audio = NULL;
}
if (priv->video) {
gst_bin_remove (GST_BIN (priv->pipeline), priv->video);
priv->snapshot = NULL;
priv->video = NULL;
}
}
else if (!brasero_metadata_create_pipeline (self))
return FALSE;
if (!gst_uri_is_valid (uri))
return FALSE;
priv->video_linked = 0;
priv->audio_linked = 0;
priv->snapshot_started = 0;
/* create a necessary source */
priv->source = gst_element_make_from_uri (GST_URI_SRC,
uri,
NULL, NULL);
if (!priv->source) {
priv->error = g_error_new (BRASERO_UTILS_ERROR,
BRASERO_UTILS_ERROR_GENERAL,
"Can't create file source");
return FALSE;
}
gst_bin_add (GST_BIN (priv->pipeline), priv->source);
gst_element_link (priv->source, priv->decode);
/* apparently we need to reconnect to the bus every time */
if (priv->watch)
g_source_remove (priv->watch);
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
priv->watch = gst_bus_add_watch (bus,
(GstBusFunc) brasero_metadata_bus_messages,
self);
gst_object_unref (bus);
return TRUE;
} | false | false | false | false | false | 0 |
img_set_blush(img, brush)
VALUE img, brush;
{
gdImagePtr im, br;
Data_Get_Struct(img, gdImage, im);
image_req(brush);
Data_Get_Struct(brush, gdImage, br);
gdImageSetBrush(im, br);
return img;
} | false | false | false | false | false | 0 |
copy_constant (tree exp)
{
switch (TREE_CODE (exp))
{
case ADDR_EXPR:
/* For ADDR_EXPR, we do not want to copy the decl whose address
is requested. We do want to copy constants though. */
if (CONSTANT_CLASS_P (TREE_OPERAND (exp, 0)))
return build1 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)));
else
return copy_node (exp);
case INTEGER_CST:
case REAL_CST:
case FIXED_CST:
case STRING_CST:
return copy_node (exp);
case COMPLEX_CST:
return build_complex (TREE_TYPE (exp),
copy_constant (TREE_REALPART (exp)),
copy_constant (TREE_IMAGPART (exp)));
case PLUS_EXPR:
case POINTER_PLUS_EXPR:
case MINUS_EXPR:
return build2 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)),
copy_constant (TREE_OPERAND (exp, 1)));
CASE_CONVERT:
case VIEW_CONVERT_EXPR:
return build1 (TREE_CODE (exp), TREE_TYPE (exp),
copy_constant (TREE_OPERAND (exp, 0)));
case VECTOR_CST:
return build_vector (TREE_TYPE (exp),
copy_list (TREE_VECTOR_CST_ELTS (exp)));
case CONSTRUCTOR:
{
tree copy = copy_node (exp);
VEC(constructor_elt, gc) *v;
unsigned HOST_WIDE_INT idx;
tree purpose, value;
v = VEC_alloc(constructor_elt, gc, VEC_length(constructor_elt,
CONSTRUCTOR_ELTS (exp)));
FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (exp), idx, purpose, value)
{
constructor_elt *ce = VEC_quick_push (constructor_elt, v, NULL);
ce->index = purpose;
ce->value = copy_constant (value);
}
CONSTRUCTOR_ELTS (copy) = v;
return copy;
}
default:
gcc_unreachable ();
}
} | false | false | false | false | false | 0 |
New(const char *proto,const char *host,const char *port)
{
ClassInit();
if(proto==0)
proto="file";
if(!strcmp(proto,"slot"))
{
const FA *session=ConnectionSlot::FindSession(host);
return session?session->Clone():0;
}
FA *session=Protocol::NewSession(proto);
if(!session)
return 0;
const char *n_proto=session->ProtocolSubstitution(host);
if(n_proto && strcmp(n_proto,proto))
{
FA *n_session=Protocol::NewSession(n_proto);
if(n_session)
{
delete session;
session=n_session;
session->SetVisualProto(proto);
}
}
if(host)
session->Connect(host,port);
return session;
} | false | false | false | false | false | 0 |
prune_remote(const char *remote, int dry_run)
{
int result = 0, i;
struct ref_states states;
const char *dangling_msg = dry_run
? " %s will become dangling!\n"
: " %s has become dangling!\n";
memset(&states, 0, sizeof(states));
get_remote_ref_states(remote, &states, GET_REF_STATES);
if (states.stale.nr) {
printf("Pruning %s\n", remote);
printf("URL: %s\n",
states.remote->url_nr
? states.remote->url[0]
: "(no URL)");
}
for (i = 0; i < states.stale.nr; i++) {
const char *refname = states.stale.items[i].util;
if (!dry_run)
result |= delete_ref(refname, NULL, 0);
printf(" * [%s] %s\n", dry_run ? "would prune" : "pruned",
abbrev_ref(refname, "refs/remotes/"));
warn_dangling_symref(stdout, dangling_msg, refname);
}
free_remote_ref_states(&states);
return result;
} | false | false | false | false | false | 0 |
nautilus_canvas_view_init (NautilusCanvasView *canvas_view)
{
NautilusCanvasContainer *canvas_container;
g_return_if_fail (gtk_bin_get_child (GTK_BIN (canvas_view)) == NULL);
canvas_view->details = g_new0 (NautilusCanvasViewDetails, 1);
canvas_view->details->sort = &sort_criteria[0];
canvas_container = create_canvas_container (canvas_view);
g_signal_connect_swapped (nautilus_preferences,
"changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_ORDER,
G_CALLBACK (default_sort_order_changed_callback),
canvas_view);
g_signal_connect_swapped (nautilus_preferences,
"changed::" NAUTILUS_PREFERENCES_DEFAULT_SORT_IN_REVERSE_ORDER,
G_CALLBACK (default_sort_in_reverse_order_changed_callback),
canvas_view);
g_signal_connect_swapped (nautilus_preferences,
"changed::" NAUTILUS_PREFERENCES_SHOW_FILE_THUMBNAILS,
G_CALLBACK (image_display_policy_changed_callback),
canvas_view);
g_signal_connect_swapped (nautilus_icon_view_preferences,
"changed::" NAUTILUS_PREFERENCES_ICON_VIEW_CAPTIONS,
G_CALLBACK (text_attribute_names_changed_callback),
canvas_view);
g_signal_connect_object (canvas_container, "handle-netscape-url",
G_CALLBACK (canvas_view_handle_netscape_url), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-uri-list",
G_CALLBACK (canvas_view_handle_uri_list), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-text",
G_CALLBACK (canvas_view_handle_text), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-raw",
G_CALLBACK (canvas_view_handle_raw), canvas_view, 0);
g_signal_connect_object (canvas_container, "handle-hover",
G_CALLBACK (canvas_view_handle_hover), canvas_view, 0);
canvas_view->details->clipboard_handler_id =
g_signal_connect (nautilus_clipboard_monitor_get (),
"clipboard-info",
G_CALLBACK (canvas_view_notify_clipboard_info), canvas_view);
} | false | false | false | false | false | 0 |
__pyx_mp_ass_subscript_memoryview(PyObject *o, PyObject *i, PyObject *v) {
if (v) {
return __pyx_memoryview___setitem__(o, i, v);
}
else {
PyErr_Format(PyExc_NotImplementedError,
"Subscript deletion not supported by %s", Py_TYPE(o)->tp_name);
return -1;
}
} | false | false | false | false | false | 0 |
process_psqlrc(char *argv0)
{
char home[MAXPGPATH];
char rc_file[MAXPGPATH];
char my_exec_path[MAXPGPATH];
char etc_path[MAXPGPATH];
find_my_exec(argv0, my_exec_path);
get_etc_path(my_exec_path, etc_path);
snprintf(rc_file, MAXPGPATH, "%s/%s", etc_path, SYSPSQLRC);
process_psqlrc_file(rc_file);
if (get_home_path(home))
{
snprintf(rc_file, MAXPGPATH, "%s/%s", home, PSQLRC);
process_psqlrc_file(rc_file);
}
} | true | true | false | false | true | 1 |
getOutcome(StochasticNode const *snode)
{
LinkNode const *lnode = 0;
switch(glm::GLMMethod::getFamily(snode)) {
case GLM_NORMAL:
return BGLM_NORMAL;
case GLM_BERNOULLI: case GLM_BINOMIAL:
lnode = dynamic_cast<LinkNode const*>(snode->parents()[0]);
if (!lnode) {
throwLogicError("No link in BinaryGLM");
}
else if (lnode->linkName() == "probit") {
return BGLM_PROBIT;
}
else if (lnode->linkName() == "logit") {
return BGLM_LOGIT;
}
else {
throwLogicError("Invalid link in BinaryGLM");
}
break;
default:
throwLogicError("Invalid family in BinaryGLM");
}
return BGLM_NORMAL; //-Wall
} | false | false | false | false | false | 0 |
luaK_setcallreturns (FuncState *fs, expdesc *e, int nresults) {
if (e->k == VCALL) { /* expression is an open function call? */
SETARG_C(getcode(fs, e), nresults+1);
if (nresults == 1) { /* `regular' expression? */
e->k = VNONRELOC;
e->info = GETARG_A(getcode(fs, e));
}
}
} | false | false | false | false | false | 0 |
write_exit_mmio(struct kvm_vcpu *vcpu, gpa_t gpa,
void *val, int bytes)
{
struct kvm_mmio_fragment *frag = &vcpu->mmio_fragments[0];
memcpy(vcpu->run->mmio.data, frag->data, min(8u, frag->len));
return X86EMUL_CONTINUE;
} | false | false | false | false | false | 0 |
mwl8k_send_fw_load_cmd(struct mwl8k_priv *priv, void *data, int length)
{
void __iomem *regs = priv->regs;
dma_addr_t dma_addr;
int loops;
dma_addr = pci_map_single(priv->pdev, data, length, PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(priv->pdev, dma_addr))
return -ENOMEM;
iowrite32(dma_addr, regs + MWL8K_HIU_GEN_PTR);
iowrite32(0, regs + MWL8K_HIU_INT_CODE);
iowrite32(MWL8K_H2A_INT_DOORBELL,
regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
iowrite32(MWL8K_H2A_INT_DUMMY,
regs + MWL8K_HIU_H2A_INTERRUPT_EVENTS);
loops = 1000;
do {
u32 int_code;
if (priv->is_8764) {
int_code = ioread32(regs +
MWL8K_HIU_H2A_INTERRUPT_STATUS);
if (int_code == 0)
break;
} else {
int_code = ioread32(regs + MWL8K_HIU_INT_CODE);
if (int_code == MWL8K_INT_CODE_CMD_FINISHED) {
iowrite32(0, regs + MWL8K_HIU_INT_CODE);
break;
}
}
cond_resched();
udelay(1);
} while (--loops);
pci_unmap_single(priv->pdev, dma_addr, length, PCI_DMA_TODEVICE);
return loops ? 0 : -ETIMEDOUT;
} | false | false | false | false | false | 0 |
tabmanagergui_create_page (GuTabContext* tc, GuEditor* editor) {
GuTabPage* tp = g_new0(GuTabPage, 1);
tc->page = tp;
int pos;
tp->scrollw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW(tp->scrollw),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gchar* labeltext = tabmanager_get_tabname (tc);
tabmanagergui_create_label (tp, labeltext);
g_signal_connect (tp->button, "clicked",
G_CALLBACK (on_menu_close_activate), tc);
tabmanagergui_create_infobar (tp);
gtk_container_add (GTK_CONTAINER (tp->scrollw),
GTK_WIDGET (editor->view));
tp->editorbox = gtk_vbox_new (FALSE, 0);
gtk_box_pack_start (GTK_BOX (tp->editorbox), tp->infobar, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (tp->editorbox), tp->scrollw, TRUE, TRUE, 0);
pos = gtk_notebook_append_page (GTK_NOTEBOOK (g_tabnotebook),
tp->editorbox, GTK_WIDGET (tp->labelbox));
gtk_widget_show_all (tp->editorbox);
return pos;
} | false | false | false | false | false | 0 |
stp_string_list_create_from_params(const stp_param_string_t *list,
size_t count)
{
size_t i = 0;
stp_string_list_t *retval = stp_string_list_create();
for (i = 0; i < count; i++)
stp_string_list_add_string(retval, list[i].name, list[i].text);
return retval;
} | false | false | false | false | false | 0 |
page_width_set(int n)
{
sub_context_ty *scp;
if (page_width)
{
arg_duplicate(arglex_token_page_width, 0);
/* NOTREACHED */
}
if (n < MIN_PAGE_WIDTH || n > MAX_PAGE_WIDTH)
{
scp = sub_context_new();
sub_var_set(scp, "Number", "%d", n);
fatal_intl(scp, i18n("page width $number out of range"));
/* NOTREACHED */
}
page_width = n;
} | false | false | false | false | false | 0 |
ST_PrintDate2(STDTIME2 odate, BOOL fixfmt) {
static UBYTE _odata[60];
LONG tenth_ms;
UBYTE msprt[8];
if (fixfmt) {
sprintf(_odata,"%04d,%03d,%02d:%02d:%02d.%04d",
(int) odate.year,
(int) odate.day,
(int) odate.hour,
(int) odate.minute,
(int) odate.second,
(int) odate.tenth_msec);
return(_odata);
}
tenth_ms = odate.tenth_msec;
if (tenth_ms == 0)
msprt[0] = '\0';
else
if (tenth_ms%1000 == 0)
sprintf(msprt,".%01d", (int)tenth_ms/1000);
else
if (tenth_ms%100 == 0)
sprintf(msprt,".%02d", (int) tenth_ms/100);
else
if (tenth_ms%10 == 0)
sprintf(msprt,".%03d", (int) tenth_ms/10);
else
sprintf(msprt,".%04d", (int) tenth_ms);
sprintf(_odata,"%d,%d,%d:%02d:%02d%s",
(int) odate.year,
(int) odate.day,
(int) odate.hour,
(int) odate.minute,
(int) odate.second,
msprt);
return(_odata);
} | false | false | false | false | false | 0 |
parse_binding_parameter_string(const char* parameter, binding_type_t* type,
dstring* strategy, int* amount, int* stepsize, int* firstsocket,
int* firstcore, dstring* socketcorelist, dstring* error)
{
bool retval = true;
if (parameter == NULL) {
sge_dstring_sprintf(error, "input parameter was NULL");
return false;
}
/* check the type [pe|env|set] (set is default) */
if (strstr(parameter, "pe ") != NULL) {
*type = BINDING_TYPE_PE;
} else if (strstr(parameter, "env ") != NULL) {
*type = BINDING_TYPE_ENV;
} else {
*type = BINDING_TYPE_SET;
}
if (strstr(parameter, "linear") != NULL) {
*amount = binding_linear_parse_amount(parameter);
if (*amount < 0) {
/* couldn't parse amount of cores */
sge_dstring_sprintf(error, "couldn't parse amount (linear)");
return false;
}
*firstsocket = binding_linear_parse_socket_offset(parameter);
*firstcore = binding_linear_parse_core_offset(parameter);
if (*firstsocket < 0 || *firstcore < 0) {
/* couldn't find start <socket,core> -> must be determined
automatically */
sge_dstring_sprintf(strategy, "linear_automatic");
/* this might be an error on shepherd side only */
*firstsocket = -1;
*firstcore = -1;
} else {
sge_dstring_sprintf(strategy, "linear");
}
/* set step size to dummy */
*stepsize = -1;
} else if (strstr(parameter, "striding") != NULL) {
*amount = binding_striding_parse_amount(parameter);
if (*amount < 0) {
/* couldn't parse amount of cores */
sge_dstring_sprintf(error, "couldn't parse amount (striding)");
return false;
}
*stepsize = binding_striding_parse_step_size(parameter);
if (*stepsize < 0) {
sge_dstring_sprintf(error, "couldn't parse stepsize (striding)");
return false;
}
*firstsocket = binding_striding_parse_first_socket(parameter);
*firstcore = binding_striding_parse_first_core(parameter);
if (*firstsocket < 0 || *firstcore < 0) {
sge_dstring_sprintf(strategy, "striding_automatic");
/* this might be an error on shepherd side only */
*firstsocket = -1;
*firstcore = -1;
} else {
sge_dstring_sprintf(strategy, "striding");
}
} else if (strstr(parameter, "explicit") != NULL) {
if (binding_explicit_has_correct_syntax(parameter) == false) {
sge_dstring_sprintf(error, "couldn't parse <socket>,<core> list (explicit)");
retval = false;
} else {
sge_dstring_sprintf(strategy, "explicit");
/* explicit:<socket>,<core>:... */
if (socketcorelist == NULL) {
sge_dstring_sprintf(error, "BUG detected: DSTRING NOT INITIALIZED");
retval = false;
} else {
char* pos = strstr(parameter, "explicit");
sge_dstring_copy_string(socketcorelist, pos);
pos = NULL;
}
}
} else {
/* error: no valid strategy found */
sge_dstring_sprintf(error, "couldn't parse binding parameter (no strategy found)");
retval = false;
}
return retval;
} | false | false | false | false | false | 0 |
varchar_input(const char *s, size_t len, int32 atttypmod)
{
VarChar *result;
size_t maxlen;
maxlen = atttypmod - VARHDRSZ;
if (atttypmod >= (int32) VARHDRSZ && len > maxlen)
{
/* Verify that extra characters are spaces, and clip them off */
size_t mbmaxlen = pg_mbcharcliplen(s, len, maxlen);
size_t j;
for (j = mbmaxlen; j < len; j++)
{
if (s[j] != ' ')
ereport(ERROR,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character varying(%d)",
(int) maxlen)));
}
len = mbmaxlen;
}
result = (VarChar *) cstring_to_text_with_len(s, len);
return result;
} | false | false | false | false | false | 0 |
enchant_dict_is_added (EnchantDict * dict, const char *const word,
ssize_t len)
{
EnchantSession * session;
g_return_val_if_fail (dict, 0);
g_return_val_if_fail (word, 0);
if (len < 0)
len = strlen (word);
g_return_val_if_fail (len, 0);
g_return_val_if_fail (g_utf8_validate(word, len, NULL), 0);
session = ((EnchantDictPrivateData*)dict->enchant_private_data)->session;
enchant_session_clear_error (session);
return enchant_session_contains (session, word, len);
} | false | false | false | false | false | 0 |
getMips16HelperFunctionStubNumber
(ArgListTy &Args) const {
unsigned int resultNum = 0;
if (Args.size() >= 1) {
Type *t = Args[0].Ty;
if (t->isFloatTy()) {
resultNum = 1;
}
else if (t->isDoubleTy()) {
resultNum = 2;
}
}
if (resultNum) {
if (Args.size() >=2) {
Type *t = Args[1].Ty;
if (t->isFloatTy()) {
resultNum += 4;
}
else if (t->isDoubleTy()) {
resultNum += 8;
}
}
}
return resultNum;
} | false | false | false | false | false | 0 |
attach(gpsimObject *pNode, gpsimObjectList_t *pPinList)
{
stimuli_attach(pNode, pPinList);
//cout <<"deleting stimulus list\n";
pPinList->clear();
delete pPinList;
} | false | false | false | false | false | 0 |
total_conflicts()
{
fprintf(stderr, "%s: ", myname);
if (SRtotal == 1)
fprintf(stderr, "1 shift/reduce conflict");
else if (SRtotal > 1)
fprintf(stderr, "%d shift/reduce conflicts", SRtotal);
if (SRtotal && RRtotal)
fprintf(stderr, ", ");
if (RRtotal == 1)
fprintf(stderr, "1 reduce/reduce conflict");
else if (RRtotal > 1)
fprintf(stderr, "%d reduce/reduce conflicts", RRtotal);
fprintf(stderr, ".\n");
} | 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.