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 |
|---|---|---|---|---|---|---|
gsql_session_set_active (GSQLSession *session)
{
GSQL_TRACE_FUNC;
g_return_if_fail (GSQL_SESSION (session) != NULL);
active_session = session;
} | false | false | false | false | false | 0 |
thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
{
struct thermal_hwmon_device *hwmon;
mutex_lock(&thermal_hwmon_list_lock);
list_for_each_entry(hwmon, &thermal_hwmon_list, node)
if (!strcmp(hwmon->type, tz->type)) {
mutex_unlock(&thermal_hwmon_list_lock);
return hwmon;
}
mutex_unlock(&thermal_hwmon_list_lock);
return NULL;
} | false | false | false | false | false | 0 |
ptql_args_branch_init(ptql_parse_branch_t *parsed,
ptql_branch_t *branch,
sigar_ptql_error_t *error)
{
if (strEQ(parsed->attr, "*")) {
branch->op_flags |= PTQL_OP_FLAG_GLOB;
}
else {
char *end;
SIGAR_CLEAR_ERRNO();
branch->data.ui32 =
strtol(parsed->attr, &end, 10);
if (strtonum_failed(parsed->attr, end)) {
/* conversion failed */
return ptql_error(error, "%s is not a number", parsed->attr);
}
}
return SIGAR_OK;
} | false | false | false | false | false | 0 |
init_style()
{
// insure use of CHARMM pair_style if any weight factors are non-zero
// set local ptrs to LJ 14 arrays setup by Pair
if (weightflag) {
int itmp;
if (force->pair == NULL)
error->all(FLERR,"Dihedral charmm is incompatible with Pair style");
lj14_1 = (double **) force->pair->extract("lj14_1",itmp);
lj14_2 = (double **) force->pair->extract("lj14_2",itmp);
lj14_3 = (double **) force->pair->extract("lj14_3",itmp);
lj14_4 = (double **) force->pair->extract("lj14_4",itmp);
int *ptr = (int *) force->pair->extract("implicit",itmp);
if (!lj14_1 || !lj14_2 || !lj14_3 || !lj14_4 || !ptr)
error->all(FLERR,"Dihedral charmm is incompatible with Pair style");
implicit = *ptr;
}
} | false | false | false | true | false | 1 |
SetEntriesDominators() {
// This array is used for maintaining reverse postorder of nodes.
ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length());
FillReversePostorderIndexes(&ordered_entries);
ScopedVector<HeapEntry*> dominators(ordered_entries.length());
if (!BuildDominatorTree(ordered_entries, &dominators)) return false;
for (int i = 0; i < ordered_entries.length(); ++i) {
ASSERT(dominators[i] != NULL);
ordered_entries[i]->set_dominator(dominators[i]);
}
return true;
} | false | false | false | false | false | 0 |
_dxf_ExPrintProgram(Program *p)
{
int i;
gfunc *gf;
static char *reqnames[] =
{"NOT_SET",
"NOT_REQUIRED",
"REQUIRED",
"ALREADY_RUN",
"REQD_IFNOT_CACHED",
"RUNNING"};
printf("%d Functions:\n", SIZE_LIST(p->funcs));
for (i = 0; i < SIZE_LIST(p->funcs); ++i)
{
gf = FETCH_LIST(p->funcs, i);
if(gf->ftype == F_MACRO && gf->func.subP) {
printf("macro %s ", gf->name);
_dxf_ExPrintProgram(gf->func.subP);
}
else
printf(
"%c%c %3d: %s: required: %s, procgroupid: %s, flags: 0x%08x\n",
p->cursor+1 == i? '>': ' ',
p->first_skipped != -1 && p->first_skipped == i? '*': ' ',
i,
_dxf_ExGFuncPathToString(gf),
reqnames[gf->required+1],
gf->procgroupid? gf->procgroupid: "(NULL)",
gf->flags);
}
return (0);
} | false | false | false | false | false | 0 |
destroy_permissions(struct permissionlist *permlist)
{
struct permission *perm;
while ((perm = AST_LIST_REMOVE_HEAD(permlist, list)))
ast_free(perm);
} | false | false | false | false | false | 0 |
gegl_operation_sink_process (GeglOperation *operation,
GeglOperationContext *context,
const gchar *output_prop,
const GeglRectangle *result,
gint level)
{
GeglOperationSinkClass *klass;
GeglBuffer *input;
gboolean success = FALSE;
klass = GEGL_OPERATION_SINK_GET_CLASS (operation);
g_assert (klass->process);
input = gegl_operation_context_get_source (context, "input");
if (input)
{
success = klass->process (operation, input, result, level);
g_object_unref (input);
}
return success;
} | false | false | false | false | false | 0 |
r700_vram_gtt_location(struct radeon_device *rdev, struct radeon_mc *mc)
{
u64 size_bf, size_af;
if (mc->mc_vram_size > 0xE0000000) {
/* leave room for at least 512M GTT */
dev_warn(rdev->dev, "limiting VRAM\n");
mc->real_vram_size = 0xE0000000;
mc->mc_vram_size = 0xE0000000;
}
if (rdev->flags & RADEON_IS_AGP) {
size_bf = mc->gtt_start;
size_af = mc->mc_mask - mc->gtt_end;
if (size_bf > size_af) {
if (mc->mc_vram_size > size_bf) {
dev_warn(rdev->dev, "limiting VRAM\n");
mc->real_vram_size = size_bf;
mc->mc_vram_size = size_bf;
}
mc->vram_start = mc->gtt_start - mc->mc_vram_size;
} else {
if (mc->mc_vram_size > size_af) {
dev_warn(rdev->dev, "limiting VRAM\n");
mc->real_vram_size = size_af;
mc->mc_vram_size = size_af;
}
mc->vram_start = mc->gtt_end + 1;
}
mc->vram_end = mc->vram_start + mc->mc_vram_size - 1;
dev_info(rdev->dev, "VRAM: %lluM 0x%08llX - 0x%08llX (%lluM used)\n",
mc->mc_vram_size >> 20, mc->vram_start,
mc->vram_end, mc->real_vram_size >> 20);
} else {
radeon_vram_location(rdev, &rdev->mc, 0);
rdev->mc.gtt_base_align = 0;
radeon_gtt_location(rdev, mc);
}
} | false | false | false | false | false | 0 |
remove_odd_key(void *key, size_t keybits, void *uv, void *uu)
{
uint8 *p = key;
g_assert(keybits == 32);
(void) uv; (void) uu;
return (p[3] & 0x1) ? TRUE : FALSE;
} | true | true | false | false | false | 1 |
TCSP_MakeIdentity2_Internal(TCS_CONTEXT_HANDLE hContext, /* in */
TCPA_ENCAUTH identityAuth, /* in */
TCPA_CHOSENID_HASH IDLabel_PrivCAHash, /* in */
UINT32 idKeyInfoSize, /* in */
BYTE * idKeyInfo, /* in */
TPM_AUTH * pSrkAuth, /* in, out */
TPM_AUTH * pOwnerAuth, /* in, out */
UINT32 * idKeySize, /* out */
BYTE ** idKey, /* out */
UINT32 * pcIdentityBindingSize, /* out */
BYTE ** prgbIdentityBinding) /* out */
{
UINT64 offset;
UINT32 paramSize;
TSS_RESULT result;
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
if ((result = ctx_verify_context(hContext)))
goto done;
if (pSrkAuth) {
if ((result = auth_mgr_check(hContext, &pSrkAuth->AuthHandle)))
goto done;
}
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
goto done;
offset = 0;
if ((result = tpm_rqu_build(TPM_ORD_MakeIdentity, &offset, txBlob, identityAuth.authdata,
IDLabel_PrivCAHash.digest, idKeyInfoSize, idKeyInfo, pSrkAuth,
pOwnerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
goto done;
result = UnloadBlob_Header(txBlob, ¶mSize);
if (!result) {
if ((result = tpm_rsp_parse(TPM_ORD_MakeIdentity, txBlob, paramSize, idKeySize,
idKey, pcIdentityBindingSize, prgbIdentityBinding,
pSrkAuth, pOwnerAuth)))
goto done;
}
LogResult("Make Identity", result);
done:
auth_mgr_release_auth(pSrkAuth, pOwnerAuth, hContext);
return result;
} | false | false | false | false | false | 0 |
basic_expand( BitStream *inStream, unsigned char *outPtr)
{
unsigned short newCode;
unsigned short oldCode;
unsigned char character;
unsigned int count;
long outByteLen = 0;
initialize_storage();
for ( ; ; )
{
initialize_dictionary();
oldCode = inStream->input_bits( current_code_bits );
if ( oldCode == END_OF_STREAM )
{
// free_storage();
return outByteLen;
}
character = (unsigned char) oldCode;
if( outPtr )
outPtr[outByteLen] = character;
outByteLen++;
for ( ; ; )
{
newCode = inStream->input_bits( current_code_bits );
if ( newCode == END_OF_STREAM )
{
// free_storage();
return outByteLen;
}
if ( newCode == FLUSH_CODE )
break;
if ( newCode == BUMP_CODE )
{
current_code_bits++;
continue;
}
if ( newCode >= next_code )
{
decode_stack[ 0 ] = character;
count = decode_string( 1, oldCode );
}
else
count = decode_string( 0, newCode );
character = decode_stack[ count - 1 ];
if( outPtr )
{
while ( count > 0 )
outPtr[outByteLen++] = decode_stack[ --count ];
}
else
{
outByteLen += count;
}
err_when( next_code >= TABLE_SIZE);
DICT( next_code ).parent_code = oldCode;
DICT( next_code ).character = character;
next_code++;
oldCode = newCode;
}
}
// free_storage();
return outByteLen;
} | false | false | false | false | false | 0 |
Response_deletemarkedmatches(resprec *r)
{
machrec *mr, *mr_next;
int tot = 0;
mr = r->matches;
while(mr != NULL)
{
mr_next = mr->next;
if(mr->flags & MACHREC_DELETEME)
{
Response_deletematch(r,mr);
tot++;
}
mr = mr_next;
}
return tot;
} | false | false | false | false | false | 0 |
geany_entry_action_create_tool_item(GtkAction *action)
{
GtkWidget *toolitem;
GeanyEntryActionPrivate *priv = GEANY_ENTRY_ACTION_GET_PRIVATE(action);
priv->entry = gtk_entry_new();
if (priv->numeric)
gtk_entry_set_width_chars(GTK_ENTRY(priv->entry), 9);
ui_entry_add_clear_icon(GTK_ENTRY(priv->entry));
ui_entry_add_activate_backward_signal(GTK_ENTRY(priv->entry));
gtk_widget_show(priv->entry);
toolitem = g_object_new(GTK_TYPE_TOOL_ITEM, NULL);
gtk_container_add(GTK_CONTAINER(toolitem), priv->entry);
return toolitem;
} | false | false | false | false | false | 0 |
xmlRelaxNGDefaultTypeCompare(void *data ATTRIBUTE_UNUSED,
const xmlChar * type,
const xmlChar * value1,
xmlNodePtr ctxt1 ATTRIBUTE_UNUSED,
void *comp1 ATTRIBUTE_UNUSED,
const xmlChar * value2,
xmlNodePtr ctxt2 ATTRIBUTE_UNUSED)
{
int ret = -1;
if (xmlStrEqual(type, BAD_CAST "string")) {
ret = xmlStrEqual(value1, value2);
} else if (xmlStrEqual(type, BAD_CAST "token")) {
if (!xmlStrEqual(value1, value2)) {
xmlChar *nval, *nvalue;
/*
* TODO: trivial optimizations are possible by
* computing at compile-time
*/
nval = xmlRelaxNGNormalize(NULL, value1);
nvalue = xmlRelaxNGNormalize(NULL, value2);
if ((nval == NULL) || (nvalue == NULL))
ret = -1;
else if (xmlStrEqual(nval, nvalue))
ret = 1;
else
ret = 0;
if (nval != NULL)
xmlFree(nval);
if (nvalue != NULL)
xmlFree(nvalue);
} else
ret = 1;
}
return (ret);
} | false | false | false | false | false | 0 |
tasteFall(){
mBlop[0].execEvent(event_keyfall);
mBlop[1].execEvent(event_keyfall);
if (steuerbar()) {
mSchnell = !mSchnell;
}
} | false | false | false | false | false | 0 |
parse(const std::string& line)
{
void* parser;
size_t offset = 0;
CTreeNode::ptr_set_t temp_set;
std::list<CParserNode*> nodes;
SState state = {offset: 0, syntax_error: 0, root: NULL, vpool: &m_variables_pool, temp_set: &temp_set};
m_state = EPS_UNDEFINED;
if (line.empty())
{
m_state = EPS_ERROR;
std::cerr << RED "Line may not be empty" RESET << std::endl;
return false;
}
parser = ParseAlloc(malloc);
scanner::CToken t;
for (t = scanner::scan(line, offset);
ET_ERROR != t.token() && ET_EOF != t.token();
t = scanner::scan(line, offset))
{
if (ET_SPACE == t.token())
{
continue;
}
CParserNode* node = CTreeNodeFactory::createParserNode(t.value());
nodes.push_back(node);
Parse(parser, t.token(), node, &state);
if (state.syntax_error)
{
break;
}
state.offset = offset;
}
if (!state.syntax_error)
{
Parse(parser, ET_END, ET_END, &state);
}
if (state.syntax_error || ET_ERROR == t.token())
{
m_state = EPS_ERROR;
std::cerr << GREEN "Syntax error at offset " << state.offset << RESET << std::endl;
std::string msg = line;
msg.insert(state.offset, BLUE);
msg = "'" + msg;
msg.append(RESET "'");
std::cerr << msg << std::endl;
for (CTreeNode::ptr_set_t::const_iterator i = temp_set.begin(); i != temp_set.end(); i++)
{
delete *i;
}
temp_set.clear();
}
else
{
m_state = EPS_READY;
m_tree.root(static_cast<CTreeNode*>(state.root));
}
ParseFree(parser, free);
while (!nodes.empty())
{
delete nodes.front();
nodes.pop_front();
}
return EPS_READY == m_state;
} | false | false | false | false | false | 0 |
num_slots() const
{
// Disconnected slots may still be in the list of slots if
// a) this is called while slots are being invoked (call_depth > 0)
// b) an exception was thrown in remove_disconnected_slots
std::size_t count = 0;
for (iterator i = slots_.begin(); i != slots_.end(); ++i) {
if (i->first.connected())
++count;
}
return count;
} | false | false | false | false | false | 0 |
getJSEventListener(JSValue *val, bool html)
{
// This function is so hot that it's worth coding it directly with imps.
KHTMLPart *part = qobject_cast<KHTMLPart*>(m_frame->m_part);
if (!part || val->type() != ObjectType)
return 0;
// It's ObjectType, so it must be valid.
JSObject *listenerObject = val->getObject();
JSObject *thisObject = listenerObject;
// 'listener' is not a simple ecma function. (Always use sanity checks: Better safe than sorry!)
if (!listenerObject->implementsCall() && part && part->jScript() && part->jScript()->interpreter())
{
Interpreter *interpreter = part->jScript()->interpreter();
// 'listener' probably is an EventListener object containing a 'handleEvent' function.
JSValue *handleEventValue = listenerObject->get(interpreter->globalExec(), Identifier("handleEvent"));
JSObject *handleEventObject = handleEventValue->getObject();
if(handleEventObject && handleEventObject->implementsCall())
{
thisObject = listenerObject;
listenerObject = handleEventObject;
}
}
JSEventListener *existingListener = jsEventListeners.value(QPair<void*, bool>(thisObject, html));
if (existingListener) {
assert( existingListener->isHTMLEventListener() == html );
return existingListener;
}
// Note that the JSEventListener constructor adds it to our jsEventListeners list
return new JSEventListener(listenerObject, thisObject, this, html);
} | false | false | false | false | false | 0 |
rest_of_handle_final (tree decl, rtx insns)
{
timevar_push (TV_FINAL);
{
rtx x;
const char *fnname;
/* Get the function's name, as described by its RTL. This may be
different from the DECL_NAME name used in the source file. */
x = DECL_RTL (decl);
if (GET_CODE (x) != MEM)
abort ();
x = XEXP (x, 0);
if (GET_CODE (x) != SYMBOL_REF)
abort ();
fnname = XSTR (x, 0);
assemble_start_function (decl, fnname);
final_start_function (insns, asm_out_file, optimize);
final (insns, asm_out_file, optimize, 0);
final_end_function ();
#ifdef IA64_UNWIND_INFO
/* ??? The IA-64 ".handlerdata" directive must be issued before
the ".endp" directive that closes the procedure descriptor. */
output_function_exception_table ();
#endif
assemble_end_function (decl, fnname);
#ifndef IA64_UNWIND_INFO
/* Otherwise, it feels unclean to switch sections in the middle. */
output_function_exception_table ();
#endif
if (! quiet_flag)
fflush (asm_out_file);
/* Release all memory allocated by flow. */
free_basic_block_vars (0);
/* Release all memory held by regsets now. */
regset_release_memory ();
}
timevar_pop (TV_FINAL);
ggc_collect ();
} | false | false | false | false | false | 0 |
client3_1_finodelk (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_args_t *args = NULL;
gfs3_finodelk_req req = {{0,},};
int32_t gf_cmd = 0;
int32_t gf_type = 0;
int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
int ret = 0;
if (!frame || !this || !data)
goto unwind;
args = data;
conf = this->private;
CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind);
if (args->cmd == F_GETLK || args->cmd == F_GETLK64)
gf_cmd = GF_LK_GETLK;
else if (args->cmd == F_SETLK || args->cmd == F_SETLK64)
gf_cmd = GF_LK_SETLK;
else if (args->cmd == F_SETLKW || args->cmd == F_SETLKW64)
gf_cmd = GF_LK_SETLKW;
else {
gf_log (this->name, GF_LOG_WARNING,
"Unknown cmd (%d)!", gf_cmd);
goto unwind;
}
switch (args->flock->l_type) {
case F_RDLCK:
gf_type = GF_LK_F_RDLCK;
break;
case F_WRLCK:
gf_type = GF_LK_F_WRLCK;
break;
case F_UNLCK:
gf_type = GF_LK_F_UNLCK;
break;
}
req.volume = (char *)args->volume;
req.fd = remote_fd;
req.cmd = gf_cmd;
req.type = gf_type;
gf_proto_flock_from_flock (&req.flock, args->flock);
memcpy (req.gfid, args->fd->inode->gfid, 16);
GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FINODELK,
client3_1_finodelk_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_finodelk_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (finodelk, frame, -1, op_errno, NULL);
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
return 0;
} | false | true | false | true | false | 1 |
do_request_to_session (SoupSession *session, const char *uri,
const char *comment, gboolean expect_timeout)
{
SoupRequest *req;
SoupMessage *msg;
GInputStream *stream;
GError *error = NULL;
gboolean finished = FALSE;
debug_printf (1, " req %s\n", comment);
req = soup_session_request (session, uri, NULL);
msg = soup_request_http_get_message (SOUP_REQUEST_HTTP (req));
g_signal_connect (msg, "finished",
G_CALLBACK (message_finished), &finished);
stream = soup_test_request_send (req, NULL, 0, &error);
if (expect_timeout && !error) {
debug_printf (1, " FAILED: request did not time out\n");
errors++;
} else if (expect_timeout && !g_error_matches (error, G_IO_ERROR,
G_IO_ERROR_TIMED_OUT)) {
debug_printf (1, " FAILED: wrong error: %s\n",
error->message);
errors++;
} else if (!expect_timeout && error) {
debug_printf (1, " FAILED: expected success but got error: %s\n",
error->message);
errors++;
}
g_clear_error (&error);
if (stream) {
soup_test_request_read_all (req, stream, NULL, &error);
if (error) {
debug_printf (1, " ERROR reading stream: %s\n",
error->message);
errors++;
}
}
if (stream) {
soup_test_request_close_stream (req, stream, NULL, &error);
if (error) {
debug_printf (1, " ERROR closing stream: %s\n",
error->message);
errors++;
}
g_object_unref (stream);
}
if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code) &&
!soup_message_is_keepalive (msg)) {
debug_printf (1, " ERROR: message is not keepalive!\n");
errors++;
}
if (!finished) {
debug_printf (1, " ERROR: 'finished' was not emitted\n");
errors++;
}
g_signal_handlers_disconnect_by_func (msg,
G_CALLBACK (message_finished),
&finished);
g_object_unref (msg);
g_object_unref (req);
} | false | false | false | false | false | 0 |
save_CompressedTexImage3DARB(GLenum target, GLint level,
GLenum internalFormat, GLsizei width,
GLsizei height, GLsizei depth, GLint border,
GLsizei imageSize, const GLvoid * data)
{
GET_CURRENT_CONTEXT(ctx);
if (target == GL_PROXY_TEXTURE_3D) {
/* don't compile, execute immediately */
CALL_CompressedTexImage3D(ctx->Exec, (target, level, internalFormat,
width, height, depth, border,
imageSize, data));
}
else {
Node *n;
ASSERT_OUTSIDE_SAVE_BEGIN_END_AND_FLUSH(ctx);
n = alloc_instruction(ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D,
8 + POINTER_DWORDS);
if (n) {
n[1].e = target;
n[2].i = level;
n[3].e = internalFormat;
n[4].i = (GLint) width;
n[5].i = (GLint) height;
n[6].i = (GLint) depth;
n[7].i = border;
n[8].i = imageSize;
save_pointer(&n[9],
copy_data(data, imageSize, "glCompressedTexImage3DARB"));
}
if (ctx->ExecuteFlag) {
CALL_CompressedTexImage3D(ctx->Exec,
(target, level, internalFormat, width,
height, depth, border, imageSize,
data));
}
}
} | false | false | false | false | false | 0 |
replace_out_block_in_code (MonoBasicBlock *bb, MonoBasicBlock *orig, MonoBasicBlock *repl) {
MonoInst *ins;
#if defined(__native_client_codegen__)
/* Need to maintain this flag for the new block because */
/* we can't jump indirectly to a non-aligned block. */
if (orig->flags & BB_INDIRECT_JUMP_TARGET)
{
repl->flags |= BB_INDIRECT_JUMP_TARGET;
}
#endif
for (ins = bb->code; ins != NULL; ins = ins->next) {
switch (ins->opcode) {
case OP_BR:
if (ins->inst_target_bb == orig)
ins->inst_target_bb = repl;
break;
case OP_CALL_HANDLER:
if (ins->inst_target_bb == orig)
ins->inst_target_bb = repl;
break;
case OP_SWITCH: {
int i;
int n = GPOINTER_TO_INT (ins->klass);
for (i = 0; i < n; i++ ) {
if (ins->inst_many_bb [i] == orig)
ins->inst_many_bb [i] = repl;
}
break;
}
default:
if (MONO_IS_COND_BRANCH_OP (ins)) {
if (ins->inst_true_bb == orig)
ins->inst_true_bb = repl;
if (ins->inst_false_bb == orig)
ins->inst_false_bb = repl;
} else if (MONO_IS_JUMP_TABLE (ins)) {
int i;
MonoJumpInfoBBTable *table = MONO_JUMP_TABLE_FROM_INS (ins);
for (i = 0; i < table->table_size; i++ ) {
if (table->table [i] == orig)
table->table [i] = repl;
}
}
break;
}
}
} | false | false | false | false | false | 0 |
equalsNonOriented(const QuadEdge &qe) const
{
if (equalsOriented(qe))
return true;
if (equalsOriented(qe.sym()))
return true;
return false;
} | false | false | false | false | false | 0 |
jme_check_link(struct net_device *netdev, int testonly)
{
struct jme_adapter *jme = netdev->priv;
u32 phylink, ghc, cnt = JME_SPDRSV_TIMEOUT, gpreg1;
int rc = 0;
phylink = jread32(jme, JME_PHY_LINK);
if (phylink & PHY_LINK_UP) {
/*
* Keep polling for speed/duplex resolve complete
*/
while (!(phylink & PHY_LINK_SPEEDDPU_RESOLVED) &&
--cnt) {
udelay(1);
phylink = jread32(jme, JME_PHY_LINK);
}
if (!cnt)
DBG("Waiting speed resolve timeout.\n");
if (jme->phylink == phylink) {
rc = 1;
goto out;
}
if (testonly)
goto out;
jme->phylink = phylink;
ghc = jme->reg_ghc & ~(GHC_SPEED | GHC_DPX |
GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE |
GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY);
switch (phylink & PHY_LINK_SPEED_MASK) {
case PHY_LINK_SPEED_10M:
ghc |= GHC_SPEED_10M |
GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE;
break;
case PHY_LINK_SPEED_100M:
ghc |= GHC_SPEED_100M |
GHC_TO_CLK_PCIE | GHC_TXMAC_CLK_PCIE;
break;
case PHY_LINK_SPEED_1000M:
ghc |= GHC_SPEED_1000M |
GHC_TO_CLK_GPHY | GHC_TXMAC_CLK_GPHY;
break;
default:
break;
}
if (phylink & PHY_LINK_DUPLEX) {
jwrite32(jme, JME_TXMCS, TXMCS_DEFAULT);
ghc |= GHC_DPX;
} else {
jwrite32(jme, JME_TXMCS, TXMCS_DEFAULT |
TXMCS_BACKOFF |
TXMCS_CARRIERSENSE |
TXMCS_COLLISION);
jwrite32(jme, JME_TXTRHD, TXTRHD_TXPEN |
((0x2000 << TXTRHD_TXP_SHIFT) & TXTRHD_TXP) |
TXTRHD_TXREN |
((8 << TXTRHD_TXRL_SHIFT) & TXTRHD_TXRL));
}
gpreg1 = GPREG1_DEFAULT;
if (is_buggy250(jme->pdev->device, jme->chiprev)) {
if (!(phylink & PHY_LINK_DUPLEX))
gpreg1 |= GPREG1_HALFMODEPATCH;
switch (phylink & PHY_LINK_SPEED_MASK) {
case PHY_LINK_SPEED_10M:
jme_set_phyfifoa(jme);
gpreg1 |= GPREG1_RSSPATCH;
break;
case PHY_LINK_SPEED_100M:
jme_set_phyfifob(jme);
gpreg1 |= GPREG1_RSSPATCH;
break;
case PHY_LINK_SPEED_1000M:
jme_set_phyfifoa(jme);
break;
default:
break;
}
}
jwrite32(jme, JME_GPREG1, gpreg1);
jwrite32(jme, JME_GHC, ghc);
jme->reg_ghc = ghc;
DBG("Link is up at %d Mbps, %s-Duplex, MDI%s.\n",
((phylink & PHY_LINK_SPEED_MASK)
== PHY_LINK_SPEED_1000M) ? 1000 :
((phylink & PHY_LINK_SPEED_MASK)
== PHY_LINK_SPEED_100M) ? 100 : 10,
(phylink & PHY_LINK_DUPLEX) ? "Full" : "Half",
(phylink & PHY_LINK_MDI_STAT) ? "-X" : "");
netdev_link_up(netdev);
} else {
if (testonly)
goto out;
DBG("Link is down.\n");
jme->phylink = 0;
netdev_link_down(netdev);
}
out:
return rc;
} | false | false | false | false | false | 0 |
tds_send_login_ack(TDSSOCKET * tds, const char *progname)
{
tds_put_byte(tds, TDS_LOGINACK_TOKEN);
tds_put_smallint(tds, 10 + (IS_TDS7_PLUS(tds)? 2 : 1) * strlen(progname)); /* length of message */
if (IS_TDS50(tds)) {
tds_put_byte(tds, 5);
tds_put_byte(tds, 5);
tds_put_byte(tds, 0);
} else {
tds_put_byte(tds, 1);
tds_put_byte(tds, TDS_MAJOR(tds));
tds_put_byte(tds, TDS_MINOR(tds));
}
tds_put_byte(tds, 0); /* unknown */
tds_put_byte(tds, 0); /* unknown */
tds_put_byte(tds, strlen(progname));
/* FIXME ucs2 */
tds_put_string(tds, progname, strlen(progname));
/* server version, for mssql 1.0.1 */
tds_put_byte(tds, 1); /* unknown */
tds_put_byte(tds, 0); /* unknown */
tds_put_byte(tds, 0); /* unknown */
tds_put_byte(tds, 1); /* unknown */
} | false | false | false | false | false | 0 |
create_terminal_mappings(struct kui_manager *kuim, struct kuictx *i)
{
struct kui_map_set *terminal_map;
/* Create the terminal kui map */
terminal_map = kui_term_get_terminal_mappings();
if (!terminal_map)
return -1;
kuim->terminal_key_set = terminal_map;
if (kui_add_map_set(i, terminal_map) == -1)
return -1;
return 0;
} | false | false | false | false | false | 0 |
qspi_write_msg(struct ti_qspi *qspi, struct spi_transfer *t,
int count)
{
int wlen, xfer_len;
unsigned int cmd;
const u8 *txbuf;
u32 data;
txbuf = t->tx_buf;
cmd = qspi->cmd | QSPI_WR_SNGL;
wlen = t->bits_per_word >> 3; /* in bytes */
xfer_len = wlen;
while (count) {
if (qspi_is_busy(qspi))
return -EBUSY;
switch (wlen) {
case 1:
dev_dbg(qspi->dev, "tx cmd %08x dc %08x data %02x\n",
cmd, qspi->dc, *txbuf);
if (count >= QSPI_WLEN_MAX_BYTES) {
u32 *txp = (u32 *)txbuf;
data = cpu_to_be32(*txp++);
writel(data, qspi->base +
QSPI_SPI_DATA_REG_3);
data = cpu_to_be32(*txp++);
writel(data, qspi->base +
QSPI_SPI_DATA_REG_2);
data = cpu_to_be32(*txp++);
writel(data, qspi->base +
QSPI_SPI_DATA_REG_1);
data = cpu_to_be32(*txp++);
writel(data, qspi->base +
QSPI_SPI_DATA_REG);
xfer_len = QSPI_WLEN_MAX_BYTES;
cmd |= QSPI_WLEN(QSPI_WLEN_MAX_BITS);
} else {
writeb(*txbuf, qspi->base + QSPI_SPI_DATA_REG);
cmd = qspi->cmd | QSPI_WR_SNGL;
xfer_len = wlen;
cmd |= QSPI_WLEN(wlen);
}
break;
case 2:
dev_dbg(qspi->dev, "tx cmd %08x dc %08x data %04x\n",
cmd, qspi->dc, *txbuf);
writew(*((u16 *)txbuf), qspi->base + QSPI_SPI_DATA_REG);
break;
case 4:
dev_dbg(qspi->dev, "tx cmd %08x dc %08x data %08x\n",
cmd, qspi->dc, *txbuf);
writel(*((u32 *)txbuf), qspi->base + QSPI_SPI_DATA_REG);
break;
}
ti_qspi_write(qspi, cmd, QSPI_SPI_CMD_REG);
if (ti_qspi_poll_wc(qspi)) {
dev_err(qspi->dev, "write timed out\n");
return -ETIMEDOUT;
}
txbuf += xfer_len;
count -= xfer_len;
}
return 0;
} | false | false | false | false | false | 0 |
canvas_event_cb(GtkWidget* widget, GdkEvent * event, gpointer data) {
tb_profile_t * tb_profile = data;
AmitkCanvasPoint canvas_cpoint;
GnomeCanvas * canvas;
gdouble x_point;
gboolean find_new_initial = FALSE;
AmitkLineProfileDataElement * element;
gboolean initialized;
gdouble peak_x=0.0;
gdouble peak_y=0.0;
int i,j;
result_t * result;
canvas = GNOME_CANVAS(widget);
gnome_canvas_window_to_world(canvas, event->button.x, event->button.y, &canvas_cpoint.x, &canvas_cpoint.y);
gnome_canvas_w2c_d(canvas, canvas_cpoint.x, canvas_cpoint.y, &canvas_cpoint.x, &canvas_cpoint.y);
switch (event->type) {
case GDK_BUTTON_RELEASE:
x_point = ((canvas_cpoint.x-EDGE_SPACING)/tb_profile->scale_x)+tb_profile->min_x;
switch (event->button.button) {
case 1:
if (x_point < tb_profile->x_limit[1])
tb_profile->x_limit[0] = x_point;
find_new_initial = TRUE;
break;
case 3:
if (x_point > tb_profile->x_limit[0])
tb_profile->x_limit[1] = x_point;
find_new_initial = TRUE;
break;
case 2:
default:
tb_profile->initial_x = x_point;
break;
}
/* find new peaks */
if (find_new_initial) {
tb_profile->initial_x = -1.0;
for (i=0; i < tb_profile->results->len; i++) {
result = g_ptr_array_index(tb_profile->results, i);
g_return_val_if_fail(result != NULL, FALSE);
initialized = FALSE;
for (j=0; j<result->line->len; j++) {
element = g_ptr_array_index(result->line, j);
if ((element->location >= tb_profile->x_limit[0]) &&
(element->location <= tb_profile->x_limit[1])) {
if ((!initialized) || (peak_y < element->value)) {
peak_x = element->location;
peak_y = element->value;
initialized = TRUE;
}
}
}
if (initialized) result->peak_location = peak_x;
}
}
/* redisplay */
if (tb_profile->calc_gaussian_fit)
display_gaussian_fit(tb_profile);
break;
default:
break;
}
return FALSE;
} | false | false | false | false | false | 0 |
bsched_timer(void)
{
tm_t tv;
GSList *l;
int out_used = 0;
int in_used = 0;
bool read_data = FALSE;
tm_now(&tv);
/*
* First pass: compute bandwidth used.
*/
for (l = bws_list; l; l = g_slist_next(l)) {
bsched_bws_t bws = GPOINTER_TO_UINT(l->data);
bsched_heartbeat(bsched_get(bws), &tv);
}
/*
* Second pass: possibly steal bandwidth from schedulers that
* have not used up all their quota.
*/
for (l = bws_list; l; l = g_slist_next(l)) {
bsched_bws_t bws = GPOINTER_TO_UINT(l->data);
bsched_stealbeat(bsched_get(bws));
}
/*
* Third pass: begin new timeslice.
*/
for (l = bws_list; l; l = g_slist_next(l)) {
bsched_bws_t bws = GPOINTER_TO_UINT(l->data);
bsched_begin_timeslice(bsched_get(bws));
}
/*
* Fourth pass: update the average bandwidth used.
*/
for (l = bws_out_list; l; l = g_slist_next(l)) {
bsched_bws_t bws = GPOINTER_TO_UINT(l->data);
bsched_t *bs = bsched_get(bws);
out_used += (int) (bs->bw_last_period * 1000.0 / bs->period_ema);
}
bws_out_ema += (out_used >> 6) - (bws_out_ema >> 6); /* Slow EMA */
if (GNET_PROPERTY(bsched_debug) > 3)
g_debug("BSCHED outgoing b/w EMA = %d bytes/s", bws_out_ema);
for (l = bws_in_list; l; l = g_slist_next(l)) {
bsched_bws_t bws = GPOINTER_TO_UINT(l->data);
bsched_t *bs = bsched_get(bws);
in_used += (int) (bs->bw_last_period * 1000.0 / bs->period_ema);
if (bs->flags & BS_F_DATA_READ) {
read_data = TRUE;
bs->flags &= ~BS_F_DATA_READ;
}
}
bws_in_ema += (in_used >> 6) - (bws_in_ema >> 6); /* Slow EMA */
if (GNET_PROPERTY(bsched_debug) > 3)
g_debug("BSCHED incoming b/w EMA = %d bytes/s", bws_in_ema);
/*
* Don't simply rely on in_used > 0 since we fake input data when
* sockets are closed or timeout on connection. We really want to know
* whether there has been actual data read.
* --RAM, 2005-06-29
*/
if (read_data)
inet_read_activity();
} | false | false | false | false | false | 0 |
snd_hdac_stream_reset(struct hdac_stream *azx_dev)
{
unsigned char val;
int timeout;
snd_hdac_stream_clear(azx_dev);
snd_hdac_stream_updateb(azx_dev, SD_CTL, 0, SD_CTL_STREAM_RESET);
udelay(3);
timeout = 300;
do {
val = snd_hdac_stream_readb(azx_dev, SD_CTL) &
SD_CTL_STREAM_RESET;
if (val)
break;
} while (--timeout);
val &= ~SD_CTL_STREAM_RESET;
snd_hdac_stream_writeb(azx_dev, SD_CTL, val);
udelay(3);
timeout = 300;
/* waiting for hardware to report that the stream is out of reset */
do {
val = snd_hdac_stream_readb(azx_dev, SD_CTL) &
SD_CTL_STREAM_RESET;
if (!val)
break;
} while (--timeout);
/* reset first position - may not be synced with hw at this time */
if (azx_dev->posbuf)
*azx_dev->posbuf = 0;
} | false | false | false | false | false | 0 |
crc_accept(options_t *o, char* accept_string, unsigned type)
{
file_mask_array** ptr = (type ? &o->crc_accept : &o->files_accept);
if(!*ptr) *ptr = file_mask_new();
file_mask_add_list(*ptr, accept_string);
} | false | false | false | false | false | 0 |
stop_mod (int i, int x, int y)
{
int l = 0;
if (y < 112) {
if (y > 98)
l = 2;
if (x >= 305)
l++;
if (cote)
ddef[i].info.param[l] ^= 1;
else
level_map[i].info.param[l] ^= 1;
} else {
if (y >= 112 && y < 119) {
if (cote)
ddef[i].info.tunnel.output = 0x1010101;
else
level_map[i].info.tunnel.output = 0x1010101;
} else if (y >= 119 && y < 126) {
if (cote)
ddef[i].info.tunnel.output = 0;
else
level_map[i].info.tunnel.output = 0;
}
}
} | false | false | false | false | false | 0 |
ImproveSkill(int *skill)
{
if (*skill >= NUMBER_OF_SKILL_LEVELS - 1)
return;
(*skill)++;
} | false | false | false | false | false | 0 |
add_entropy(FState * st, const unsigned char *data, unsigned len)
{
unsigned pos;
unsigned char hash[BLOCK];
MD_CTX md;
/* hash given data */
md_init(&md);
md_update(&md, data, len);
md_result(&md, hash);
/*
* Make sure the pool 0 is initialized, then update randomly.
*/
if (st->reseed_count == 0)
pos = 0;
else
pos = get_rand_pool(st);
md_update(&st->pool[pos], hash, BLOCK);
if (pos == 0)
st->pool0_bytes += len;
memset(hash, 0, BLOCK);
memset(&md, 0, sizeof(md));
} | true | true | false | false | false | 1 |
inf_text_session_set_xml_user_props(InfSession* session,
const GParameter* params,
guint n_params,
xmlNodePtr xml)
{
const GParameter* param;
INF_SESSION_CLASS(parent_class)->set_xml_user_props(
session,
params,
n_params,
xml
);
param = inf_session_lookup_user_property(
params,
n_params,
"caret-position"
);
if(param != NULL)
{
inf_xml_util_set_attribute_uint(
xml,
"caret",
g_value_get_uint(¶m->value)
);
}
param = inf_session_lookup_user_property(
params,
n_params,
"selection-length"
);
if(param != NULL)
{
inf_xml_util_set_attribute_int(
xml,
"selection",
g_value_get_int(¶m->value)
);
}
param = inf_session_lookup_user_property(
params,
n_params,
"hue"
);
if(param != NULL)
{
inf_xml_util_set_attribute_double(
xml,
"hue",
g_value_get_double(¶m->value)
);
}
} | false | false | false | false | false | 0 |
ar9003_hw_spectral_scan_config(struct ath_hw *ah,
struct ath_spec_scan *param)
{
u8 count;
if (!param->enabled) {
REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_ENABLE);
return;
}
REG_SET_BIT(ah, AR_PHY_RADAR_0, AR_PHY_RADAR_0_FFT_ENA);
REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE);
/* on AR93xx and newer, count = 0 will make the the chip send
* spectral samples endlessly. Check if this really was intended,
* and fix otherwise.
*/
count = param->count;
if (param->endless)
count = 0;
else if (param->count == 0)
count = 1;
if (param->short_repeat)
REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT);
else
REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT);
REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_COUNT, count);
REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_PERIOD, param->period);
REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
AR_PHY_SPECTRAL_SCAN_FFT_PERIOD, param->fft_period);
return;
} | false | false | false | false | false | 0 |
layer_fog_read(Lib3dsLayerFog *fog, Lib3dsIo *io)
{
Lib3dsChunk c;
Lib3dsWord chunk;
Lib3dsBool have_lin=LIB3DS_FALSE;
if (!lib3ds_chunk_read_start(&c, LIB3DS_LAYER_FOG, io)) {
return(LIB3DS_FALSE);
}
fog->near_y=lib3ds_io_read_float(io);
fog->far_y=lib3ds_io_read_float(io);
fog->density=lib3ds_io_read_float(io);
fog->flags=lib3ds_io_read_dword(io);
lib3ds_chunk_read_tell(&c, io);
while ((chunk=lib3ds_chunk_read_next(&c, io))!=0) {
switch (chunk) {
case LIB3DS_LIN_COLOR_F:
lib3ds_io_read_rgb(io, fog->col);
have_lin=LIB3DS_TRUE;
break;
case LIB3DS_COLOR_F:
lib3ds_io_read_rgb(io, fog->col);
break;
default:
lib3ds_chunk_unknown(chunk);
}
}
lib3ds_chunk_read_end(&c, io);
return(LIB3DS_TRUE);
} | false | false | false | false | false | 0 |
set_title_info(uchar tfillchar, uchar titleattr)
{
if (tfillchar != 0xFF)
ms->tfillchar = tfillchar;
if (titleattr != 0xFF)
ms->titleattr = titleattr;
} | false | false | false | false | false | 0 |
nyx_set_input_audio(nyx_audio_callback callback,
void *userdata,
int num_channels,
long len, double rate)
{
LVAL val;
int ch;
nyx_set_audio_params(rate, len);
if (num_channels > 1) {
val = newvector(num_channels);
}
xlprot1(val);
for (ch = 0; ch < num_channels; ch++) {
nyx_susp_type susp;
sound_type snd;
falloc_generic(susp, nyx_susp_node, "nyx_set_input_audio");
susp->callback = callback;
susp->userdata = userdata;
susp->len = len;
susp->channel = ch;
susp->susp.fetch = nyx_susp_fetch;
susp->susp.keep_fetch = NULL;
susp->susp.free = nyx_susp_free;
susp->susp.mark = NULL;
susp->susp.print_tree = nyx_susp_print_tree;
susp->susp.name = "nyx";
susp->susp.toss_cnt = 0;
susp->susp.current = 0;
susp->susp.sr = rate;
susp->susp.t0 = 0.0;
susp->susp.log_stop_cnt = 0;
snd = sound_create((snd_susp_type) susp, 0.0, rate, 1.0);
if (num_channels > 1) {
setelement(val, ch, cvsound(snd));
}
else {
val = cvsound(snd);
}
}
setvalue(xlenter("S"), val);
xlpop();
} | false | false | false | false | true | 1 |
IsVisible (Finepoint objpos)
{
float a_x; /* Vector Influencer->objectpos */
float a_y;
finepoint step; /* effective step */
int step_num; /* number of neccessary steps */
float a_len; /* Lenght of a */
int i;
finepoint testpos;
float influ_x = Me.pos.x;
float influ_y = Me.pos.y;
DebugPrintf (2, "\nint IsVisible(Point objpos): Funktion echt aufgerufen.");
a_x = influ_x - objpos->x;
a_y = influ_y - objpos->y;
a_len = sqrt ( a_x * a_x + a_y * a_y );
step_num = a_len * 4.0;
if (step_num == 0)
step_num = 1;
step.x = a_x / step_num;
step.y = a_y / step_num;
testpos.x = objpos->x;
testpos.y = objpos->y;
for (i = 1; i < step_num; i++)
{
testpos.x += step.x;
testpos.y += step.y;
if (IsPassable (testpos.x, testpos.y, LIGHT) != CENTER)
{
DebugPrintf (2, "\nint IsVisible(Point objpos): Funktionsende erreicht.");
return FALSE;
}
}
DebugPrintf (2, "\nint IsVisible(Point objpos): Funktionsende erreicht.");
return TRUE;
} | false | false | false | false | false | 0 |
destroy_priv(struct kref *kref)
{
struct parport_uss720_private *priv = container_of(kref, struct parport_uss720_private, ref_count);
dev_dbg(&priv->usbdev->dev, "destroying priv datastructure\n");
usb_put_dev(priv->usbdev);
kfree(priv);
} | false | false | false | false | false | 0 |
__gst_vasprintf (char **result, char const *format, va_list args)
{
size_t length;
*result = vasnprintf (NULL, &length, format, args);
if (*result == NULL)
return -1;
return length;
} | false | false | false | false | false | 0 |
isl_printer_print_local_space(__isl_take isl_printer *p,
__isl_keep isl_local_space *ls)
{
struct isl_print_space_data data = { 0 };
unsigned n_div;
if (!ls)
goto error;
if (isl_local_space_dim(ls, isl_dim_param) > 0) {
p = print_tuple(ls->dim, p, isl_dim_param, &data);
p = isl_printer_print_str(p, " -> ");
}
p = isl_printer_print_str(p, "{ ");
p = print_space(ls->dim, p, 0, &data);
n_div = isl_local_space_dim(ls, isl_dim_div);
if (n_div > 0) {
p = isl_printer_print_str(p, " : ");
p = isl_printer_print_str(p, s_open_exists[0]);
p = print_div_list(p, ls->dim, ls->div, 0);
} else if (isl_space_is_params(ls->dim))
p = isl_printer_print_str(p, s_such_that[0]);
p = isl_printer_print_str(p, " }");
return p;
error:
isl_printer_free(p);
return NULL;
} | false | false | false | false | false | 0 |
start_child_listen_async(int size_of_message)
#else
int
start_child_listen_async(size_of_message)
int size_of_message;
#endif
{
int tsize;
int s;
int rc;
int xx;
int tmp_port;
int sockerr;
int recv_buf_size=65536;
int optval=1;
xx = 0;
tsize=size_of_message; /* Number of messages to receive */
s = socket(AF_INET, SOCK_STREAM, 0);
if (s < 0)
{
perror("socket failed:");
exit(19);
}
sockerr = setsockopt (s, SOL_SOCKET, SO_RCVBUF, (char *)
&recv_buf_size, sizeof(int));
if ( sockerr == -1 ) {
perror("Error in setsockopt 5\n");
}
sockerr = setsockopt (s, SOL_SOCKET, SO_REUSEADDR, (char *)
&optval, sizeof(int));
if ( sockerr == -1 ) {
perror("Error in setsockopt 6\n");
}
bzero(&child_async_sock, sizeof(struct sockaddr_in));
tmp_port=CHILD_ALIST_PORT;
child_async_sock.sin_port = htons(tmp_port);
child_async_sock.sin_family = AF_INET;
child_async_sock.sin_addr.s_addr = INADDR_ANY;
rc = -1;
while (rc < 0)
{
rc = bind(s, (struct sockaddr *)&child_async_sock,
sizeof(struct sockaddr_in));
if(rc < 0)
{
tmp_port++;
child_async_sock.sin_port=htons(tmp_port);
continue;
}
}
child_async_port = ntohs(child_async_sock.sin_port);
if(cdebug ==1)
{
fprintf(newstdout,"Child %d: Async Listen: Bound at port %d\n",
(int)chid,tmp_port);
fflush(newstdout);
}
if(rc < 0)
{
fprintf(newstdout,"bind failed. Errno %d \n",errno);
fflush(newstdout);
exit(20);
}
return(s);
} | false | false | false | false | false | 0 |
load_one_monster(fd, m)
dlb *fd;
monster *m;
{
int size;
Fread((genericptr_t) m, 1, sizeof *m, fd);
if ((size = m->name.len) != 0) {
m->name.str = (char *) alloc((unsigned)size + 1);
Fread((genericptr_t) m->name.str, 1, size, fd);
m->name.str[size] = '\0';
} else
m->name.str = (char *) 0;
if ((size = m->appear_as.len) != 0) {
m->appear_as.str = (char *) alloc((unsigned)size + 1);
Fread((genericptr_t) m->appear_as.str, 1, size, fd);
m->appear_as.str[size] = '\0';
} else
m->appear_as.str = (char *) 0;
} | false | false | false | false | false | 0 |
session_ticket_pack (extension_priv_data_t epriv, gnutls_buffer_st * ps)
{
session_ticket_ext_st *priv = epriv.ptr;
int ret;
BUFFER_APPEND_PFX (ps, priv->session_ticket, priv->session_ticket_len);
BUFFER_APPEND_NUM (ps, priv->session_ticket_enable);
return 0;
} | false | false | false | false | false | 0 |
attributes_write_xml(const output::pointer &fp, const char *name, attributes_ty *this_thing)
{
if (!this_thing)
return;
trace(("attributes_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing));
assert(name);
assert(((attributes_ty *)this_thing)->reference_count > 0);
trace(("rc = %ld;\n", ((attributes_ty *)this_thing)->reference_count));
assert(name);
fp->fputc('<');
fp->fputs(name);
fp->fputs(">\n");
string_write_xml(fp, "name", this_thing->name);
string_write_xml(fp, "value", this_thing->value);
fp->fputs("</");
fp->fputs(name);
fp->fputs(">\n");
} | false | false | false | false | false | 0 |
do_yp_remove (ypdata_t *yp, char *s, unsigned len)
{
int ret = 0;
if (yp->sid)
{
ret = snprintf (s, len, "action=remove&sid=%s", yp->sid);
if (ret >= (signed)len)
return ret+1;
INFO1 ("clearing up YP entry for %s", yp->mount);
ret = send_to_yp ("remove", yp, s);
free (yp->sid);
yp->sid = NULL;
}
yp->remove = 1;
yp->process = do_yp_add;
yp_update = 1;
return ret;
} | false | false | false | false | false | 0 |
applyLinearFit(l_float32 a,
l_float32 b,
l_float32 x,
l_float32 *py)
{
PROCNAME("applyLinearFit");
if (!py)
return ERROR_INT("&y not defined", procName, 1);
*py = a * x + b;
return 0;
} | false | false | false | false | false | 0 |
JAXeventnow(Jax *jax)
{
if(JAXeventsqueued(jax))
{
XNextEvent(jax->d, &jax->xe);
switch(jax->xe.type)
{
case MappingNotify:
XRefreshKeyboardMapping((XMappingEvent*)&jax->xe);
jax->xe.type=0;
break;
default:
if (jax->EH)
jax->EH(jax);
break;
}
}
return(0);
} | false | false | false | false | false | 0 |
create_rader_aux(int p, int flags)
{
fftw_complex *omega, *work;
int g, ginv, gpower;
int i;
FFTW_TRIG_REAL twoPiOverN;
fftw_real scale = 1.0 / (p - 1); /* for convolution */
fftw_plan plan;
fftw_rader_data *d;
if (p < 2)
fftw_die("non-prime order in Rader\n");
flags &= ~FFTW_IN_PLACE;
d = (fftw_rader_data *) fftw_malloc(sizeof(fftw_rader_data));
g = find_generator(p);
ginv = power_mod(g, p - 2, p);
omega = (fftw_complex *) fftw_malloc((p - 1) * sizeof(fftw_complex));
plan = fftw_create_plan(p - 1, FFTW_FORWARD,
flags & ~FFTW_NO_VECTOR_RECURSE);
work = (fftw_complex *) fftw_malloc((p - 1) * sizeof(fftw_complex));
twoPiOverN = FFTW_K2PI / (FFTW_TRIG_REAL) p;
gpower = 1;
for (i = 0; i < p - 1; ++i) {
c_re(work[i]) = scale * FFTW_TRIG_COS(twoPiOverN * gpower);
c_im(work[i]) = FFTW_FORWARD * scale * FFTW_TRIG_SIN(twoPiOverN
* gpower);
gpower = MULMOD(gpower, ginv, p);
}
/* fft permuted roots of unity */
fftw_executor_simple(p - 1, work, omega, plan->root, 1, 1,
plan->recurse_kind);
fftw_free(work);
d->plan = plan;
d->omega = omega;
d->g = g;
d->ginv = ginv;
d->p = p;
d->flags = flags;
d->refcount = 1;
d->next = NULL;
d->cdesc = (fftw_codelet_desc *) fftw_malloc(sizeof(fftw_codelet_desc));
d->cdesc->name = NULL;
d->cdesc->codelet = NULL;
d->cdesc->size = p;
d->cdesc->dir = FFTW_FORWARD;
d->cdesc->type = FFTW_RADER;
d->cdesc->signature = g;
d->cdesc->ntwiddle = 0;
d->cdesc->twiddle_order = NULL;
return d;
} | false | false | false | false | false | 0 |
finish_qualified_id_expr (tree qualifying_class, tree expr, bool done,
bool address_p)
{
if (error_operand_p (expr))
return error_mark_node;
/* If EXPR occurs as the operand of '&', use special handling that
permits a pointer-to-member. */
if (address_p && done)
{
if (TREE_CODE (expr) == SCOPE_REF)
expr = TREE_OPERAND (expr, 1);
expr = build_offset_ref (qualifying_class, expr,
/*address_p=*/true);
return expr;
}
if (TREE_CODE (expr) == FIELD_DECL)
expr = finish_non_static_data_member (expr, current_class_ref,
qualifying_class);
else if (BASELINK_P (expr) && !processing_template_decl)
{
tree fns;
/* See if any of the functions are non-static members. */
fns = BASELINK_FUNCTIONS (expr);
if (TREE_CODE (fns) == TEMPLATE_ID_EXPR)
fns = TREE_OPERAND (fns, 0);
/* If so, the expression may be relative to the current
class. */
if (!shared_member_p (fns)
&& current_class_type
&& DERIVED_FROM_P (qualifying_class, current_class_type))
expr = (build_class_member_access_expr
(maybe_dummy_object (qualifying_class, NULL),
expr,
BASELINK_ACCESS_BINFO (expr),
/*preserve_reference=*/false));
else if (done)
/* The expression is a qualified name whose address is not
being taken. */
expr = build_offset_ref (qualifying_class, expr, /*address_p=*/false);
}
return expr;
} | false | false | false | true | true | 1 |
xmlRegNewRange(xmlRegParserCtxtPtr ctxt,
int neg, xmlRegAtomType type, int start, int end) {
xmlRegRangePtr ret;
ret = (xmlRegRangePtr) xmlMalloc(sizeof(xmlRegRange));
if (ret == NULL) {
xmlRegexpErrMemory(ctxt, "allocating range");
return(NULL);
}
ret->neg = neg;
ret->type = type;
ret->start = start;
ret->end = end;
return(ret);
} | false | false | false | false | false | 0 |
cpl_plugin_get_type_string(const cpl_plugin *self)
{
const char *stype;
if (self == NULL) {
cpl_error_set_(CPL_ERROR_NULL_INPUT);
return NULL;
}
switch (self->type) {
case (unsigned long)CPL_PLUGIN_TYPE_NONE:
stype = "none";
break;
case (unsigned long)CPL_PLUGIN_TYPE_RECIPE:
stype = "recipe";
break;
default:
stype = "undefined";
break;
}
return cx_strdup(stype);
} | false | false | false | false | false | 0 |
erase_xfer(partition_t *part,
uint16_t xfernum)
{
int ret;
struct xfer_info_t *xfer;
struct erase_info *erase;
xfer = &part->XferInfo[xfernum];
pr_debug("ftl_cs: erasing xfer unit at 0x%x\n", xfer->Offset);
xfer->state = XFER_ERASING;
/* Is there a free erase slot? Always in MTD. */
erase=kmalloc(sizeof(struct erase_info), GFP_KERNEL);
if (!erase)
return -ENOMEM;
erase->mtd = part->mbd.mtd;
erase->callback = ftl_erase_callback;
erase->addr = xfer->Offset;
erase->len = 1 << part->header.EraseUnitSize;
erase->priv = (u_long)part;
ret = mtd_erase(part->mbd.mtd, erase);
if (!ret)
xfer->EraseCount++;
else
kfree(erase);
return ret;
} | false | false | false | false | false | 0 |
addCurrentPatient()
{
onPatientSelected(patient()->data(Core::IPatient::FullName).toString(), patient()->uuid());
} | false | false | false | false | false | 0 |
getArrayIndex(struct symbolTableNode *tmp, int index)
{
if(!tmp)
exit(intern);
struct dataTypeArray *dta = tmp->other;
if(index < dta->low || index > dta->high)
exit(intern);
int real_index = abs(dta->low - index);
return dta->data[real_index];
} | false | false | false | false | false | 0 |
prompt_get_boolean_property (GcrSystemPrompt *self,
const gchar *property_name)
{
GVariant *variant;
gconstpointer key;
g_return_val_if_fail (GCR_IS_SYSTEM_PROMPT (self), FALSE);
key = g_intern_string (property_name);
variant = g_hash_table_lookup (self->pv->properties, key);
if (variant != NULL)
return g_variant_get_boolean (variant);
return FALSE;
} | false | false | false | false | false | 0 |
GetObjectFilePath(cmSourceFile* source) const
{
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if(!path.empty())
path += "/";
std::string const& objectName = this->GeneratorTarget->Objects[source];
path += this->LocalGenerator->GetTargetDirectory(*this->Target);
path += "/";
path += objectName;
return path;
} | false | false | false | false | false | 0 |
pow_hh(shortint *ap, shortint *bp)
#endif
{
shortint pow, x, n;
unsigned u;
x = *ap;
n = *bp;
if (n <= 0) {
if (n == 0 || x == 1)
return 1;
if (x != -1)
return x == 0 ? 1/x : 0;
n = -n;
}
u = n;
for(pow = 1; ; )
{
if(u & 01)
pow *= x;
if(u >>= 1)
x *= x;
else
break;
}
return(pow);
} | false | false | false | false | false | 0 |
search_sub_worker(jk_ws_service_t *s,
status_endpoint_t *p,
jk_worker_t *jw,
const char *worker,
lb_sub_worker_t **wrp,
const char *sub_worker,
unsigned int *idx,
jk_logger_t *l)
{
lb_worker_t *lb = NULL;
lb_sub_worker_t *wr = NULL;
status_worker_t *w = p->worker;
unsigned int i = 0;
JK_TRACE_ENTER(l);
if (JK_IS_DEBUG_LEVEL(l))
jk_log(l, JK_LOG_DEBUG,
"Status worker '%s' searching sub worker '%s' of worker '%s'",
w->name, sub_worker ? sub_worker : "(null)",
worker ? worker : "(null)");
if (!sub_worker || !sub_worker[0]) {
jk_log(l, JK_LOG_WARNING,
"Status worker '%s' NULL or EMPTY sub_worker param",
w->name);
p->msg = "NULL or EMPTY sub_worker param";
JK_TRACE_EXIT(l);
return JK_FALSE;
}
if (check_valid_lb(s, p, jw, worker, &lb, 1, l) == JK_FALSE) {
JK_TRACE_EXIT(l);
return JK_FALSE;
}
if (idx)
i = *idx;
for (; i < lb->num_of_workers; i++) {
wr = &(lb->lb_workers[i]);
if (idx) {
if (jk_wildchar_match(wr->name, sub_worker, 0) == 0) {
*idx = i + 1;
break;
}
}
else if (strcmp(sub_worker, wr->name) == 0)
break;
}
*wrp = wr;
if (!wr || i == lb->num_of_workers) {
jk_log(l, JK_LOG_WARNING,
"Status worker '%s' could not find sub worker '%s' of worker '%s'",
w->name, sub_worker, worker ? worker : "(null)");
p->msg = "could not find sub worker";
JK_TRACE_EXIT(l);
return JK_FALSE;
}
p->msg = "OK";
JK_TRACE_EXIT(l);
return JK_TRUE;
} | false | false | false | false | false | 0 |
GetMin(int e_numb) {
switch(e_numb) {
case 0:
return min_x_;
case 1:
return min_y_;
case 2:
return min_z_;
default:
assert(false);
}
} | false | false | false | false | false | 0 |
icalattachtype_get_url(struct icalattachtype* v)
{
icalerror_check_arg( (v!=0),"v");
return v->url;
} | false | false | false | true | false | 1 |
pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask)
{
int i;
/* Wait for Transaction Pending bit clean */
for (i = 0; i < 4; i++) {
u16 status;
if (i)
msleep((1 << (i - 1)) * 100);
pci_read_config_word(dev, pos, &status);
if (!(status & mask))
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
remove_stars_of_type(struct gui_star_list *gsl, int type_mask, int flag_mask)
{
struct gui_star *gs;
GSList *sl=NULL, *osl=NULL, *head = gsl->sl;
sl = head;
while (sl != NULL) {
gs = GUI_STAR(sl->data);
if ((TYPE_MASK_GSTAR(gs) & type_mask) != 0 &&
(gs->flags & flag_mask) == flag_mask) {
gs->flags &= ~STAR_HAS_PAIR;
// d3_printf("gs release\n");
gui_star_release(gs);
if (osl != NULL) {
osl->next = sl->next;
sl->next = NULL;
// d3_printf("free 1sl\n");
g_slist_free_1(sl);
sl = osl->next;
} else {
head = sl->next;
sl->next = NULL;
// d3_printf("free 1sl\n");
g_slist_free_1(sl);
sl = head;
}
} else {
osl = sl;
sl = g_slist_next(sl);
}
}
gsl->sl = head;
} | false | false | false | false | false | 0 |
_eina_value_type_double_compare(const Eina_Value_Type *type __UNUSED__, const void *a, const void *b)
{
const double *ta = a, *tb = b;
if (*ta < *tb)
return -1;
else if (*ta > *tb)
return 1;
return 0;
} | false | false | false | false | false | 0 |
gutsOfDestructor2()
{
delete [] integerInfo_;
integerInfo_ = NULL;
delete [] integerVariable_;
integerVariable_ = NULL;
int i;
if (ownObjects_) {
for (i = 0; i < numberObjects_; i++)
delete object_[i];
delete [] object_;
}
ownObjects_ = true;
object_ = NULL;
numberIntegers_ = 0;
numberObjects_ = 0;
// Below here is whatever consensus is
ownership_ = 0x80000000;
delete branchingMethod_;
branchingMethod_ = NULL;
delete cutModifier_;
cutModifier_ = NULL;
topOfTree_ = NULL;
resetModel();
} | false | false | false | false | false | 0 |
write_meta_page(struct f2fs_sb_info *sbi, struct page *page)
{
struct f2fs_io_info fio = {
.sbi = sbi,
.type = META,
.rw = WRITE_SYNC | REQ_META | REQ_PRIO,
.blk_addr = page->index,
.page = page,
.encrypted_page = NULL,
};
if (unlikely(page->index >= MAIN_BLKADDR(sbi)))
fio.rw &= ~REQ_META;
set_page_writeback(page);
f2fs_submit_page_mbio(&fio);
} | false | false | false | false | false | 0 |
replaceStreamData(PointerHolder<Buffer> data,
QPDFObjectHandle const& filter,
QPDFObjectHandle const& decode_parms)
{
this->stream_data = data;
this->stream_provider = 0;
replaceFilterData(filter, decode_parms, data->getSize());
} | false | false | false | false | false | 0 |
decode_home_uri (const char *uri)
{
char *home_uri;
char *decoded_uri;
if (g_str_has_prefix (uri, "file:")) {
decoded_uri = g_strdup (uri);
} else {
home_uri = nautilus_get_home_directory_uri ();
decoded_uri = g_strconcat (home_uri, "/", uri, NULL);
g_free (home_uri);
}
return decoded_uri;
} | false | false | false | false | false | 0 |
NumLWLocks(void)
{
int numLocks;
/*
* Possibly this logic should be spread out among the affected modules,
* the same way that shmem space estimation is done. But for now, there
* are few enough users of LWLocks that we can get away with just keeping
* the knowledge here.
*/
/* Predefined LWLocks */
numLocks = (int) NumFixedLWLocks;
/* bufmgr.c needs two for each shared buffer */
numLocks += 2 * NBuffers;
/* clog.c needs one per CLOG buffer */
numLocks += NUM_CLOG_BUFFERS;
/* subtrans.c needs one per SubTrans buffer */
numLocks += NUM_SUBTRANS_BUFFERS;
/* multixact.c needs two SLRU areas */
numLocks += NUM_MXACTOFFSET_BUFFERS + NUM_MXACTMEMBER_BUFFERS;
/* async.c needs one per Async buffer */
numLocks += NUM_ASYNC_BUFFERS;
/*
* Add any requested by loadable modules; for backwards-compatibility
* reasons, allocate at least NUM_USER_DEFINED_LWLOCKS of them even if
* there are no explicit requests.
*/
lock_addin_request_allowed = false;
numLocks += Max(lock_addin_request, NUM_USER_DEFINED_LWLOCKS);
return numLocks;
} | false | false | false | false | false | 0 |
pd6729_pci_remove(struct pci_dev *dev)
{
int i;
struct pd6729_socket *socket = pci_get_drvdata(dev);
for (i = 0; i < MAX_SOCKETS; i++) {
/* Turn off all interrupt sources */
indirect_write(&socket[i], I365_CSCINT, 0);
indirect_write(&socket[i], I365_INTCTL, 0);
pcmcia_unregister_socket(&socket[i].socket);
}
if (irq_mode == 1)
free_irq(dev->irq, socket);
else
del_timer_sync(&socket->poll_timer);
pci_release_regions(dev);
pci_disable_device(dev);
kfree(socket);
} | false | false | false | false | false | 0 |
copy(void)
{
char *dest;
int count = 0;
PRECOND(gotlock);
dest = ne_concat(res, "-copydest", NULL);
ne_delete(i_session2, dest);
ONNREQ2("could not COPY locked resource",
ne_copy(i_session, 1, NE_DEPTH_ZERO, res, dest));
ONNREQ2("LOCK discovery failed",
ne_lock_discover(i_session, dest, count_discover, &count));
ONV(count != 0,
("found %d locks on copied resource", count));
ONNREQ2("could not delete copy of locked resource",
ne_delete(i_session, dest));
free(dest);
return OK;
} | false | false | false | false | false | 0 |
hswep_cbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)
{
struct hw_perf_event_extra *reg1 = &event->hw.extra_reg;
struct extra_reg *er;
int idx = 0;
for (er = hswep_uncore_cbox_extra_regs; er->msr; er++) {
if (er->event != (event->hw.config & er->config_mask))
continue;
idx |= er->idx;
}
if (idx) {
reg1->reg = HSWEP_C0_MSR_PMON_BOX_FILTER0 +
HSWEP_CBO_MSR_OFFSET * box->pmu->pmu_idx;
reg1->config = event->attr.config1 & hswep_cbox_filter_mask(idx);
reg1->idx = idx;
}
return 0;
} | false | false | false | false | false | 0 |
gfx_v7_0_fini_pg(struct amdgpu_device *adev)
{
if (adev->pg_flags & (AMD_PG_SUPPORT_GFX_PG |
AMD_PG_SUPPORT_GFX_SMG |
AMD_PG_SUPPORT_GFX_DMG |
AMD_PG_SUPPORT_CP |
AMD_PG_SUPPORT_GDS |
AMD_PG_SUPPORT_RLC_SMU_HS)) {
gfx_v7_0_update_gfx_pg(adev, false);
if (adev->pg_flags & AMD_PG_SUPPORT_GFX_PG) {
gfx_v7_0_enable_cp_pg(adev, false);
gfx_v7_0_enable_gds_pg(adev, false);
}
}
} | false | false | false | false | false | 0 |
store_word(spin, word, flags, region, pfxlist, need_affix)
spellinfo_T *spin;
char_u *word;
int flags; /* extra flags, WF_BANNED */
int region; /* supported region(s) */
char_u *pfxlist; /* list of prefix IDs or NULL */
int need_affix; /* only store word with affix ID */
{
int len = (int)STRLEN(word);
int ct = captype(word, word + len);
char_u foldword[MAXWLEN];
int res = OK;
char_u *p;
(void)spell_casefold(word, len, foldword, MAXWLEN);
for (p = pfxlist; res == OK; ++p)
{
if (!need_affix || (p != NULL && *p != NUL))
res = tree_add_word(spin, foldword, spin->si_foldroot, ct | flags,
region, p == NULL ? 0 : *p);
if (p == NULL || *p == NUL)
break;
}
++spin->si_foldwcount;
if (res == OK && (ct == WF_KEEPCAP || (flags & WF_KEEPCAP)))
{
for (p = pfxlist; res == OK; ++p)
{
if (!need_affix || (p != NULL && *p != NUL))
res = tree_add_word(spin, word, spin->si_keeproot, flags,
region, p == NULL ? 0 : *p);
if (p == NULL || *p == NUL)
break;
}
++spin->si_keepwcount;
}
return res;
} | false | false | false | false | false | 0 |
initializeStorage(int matrixSize){
return MAXSUMSTORAGE(matrixSize, vector<vector<vector<int> > > (matrixSize, vector<vector<int> > (matrixSize, vector<int>(matrixSize, 0))));
} | false | false | false | false | false | 0 |
gnm_pane_object_update_bbox (GnmPane *pane, SheetObject *so)
{
GocItem **ctrl_pts = g_hash_table_lookup (pane->drag.ctrl_pts, so);
double const *pts = g_hash_table_lookup (
pane->simple.scg->selected_objects, so);
int radius, outline, total_size;
if (ctrl_pts == NULL) {
ctrl_pts = g_new0 (GocItem *, 10);
g_hash_table_insert (pane->drag.ctrl_pts, so, ctrl_pts);
}
g_return_if_fail (ctrl_pts != NULL);
gtk_widget_style_get (GTK_WIDGET (pane),
"control-circle-size", &radius,
"control-circle-outline", &outline,
NULL);
/* space for 2 halves and a full */
total_size = radius * 4 + outline * 2;
/* set the acetate 1st so that the other points will override it */
set_acetate_coords (pane, so, ctrl_pts, pts[0], pts[1], pts[2], pts[3]);
if (sheet_object_can_resize (so)) {
set_item_x_y (pane, so, ctrl_pts, 0, pts[0], pts[1], TRUE);
set_item_x_y (pane, so, ctrl_pts, 1, (pts[0] + pts[2]) / 2, pts[1],
fabs (pts[2]-pts[0]) >= total_size);
set_item_x_y (pane, so, ctrl_pts, 2, pts[2], pts[1], TRUE);
set_item_x_y (pane, so, ctrl_pts, 3, pts[0], (pts[1] + pts[3]) / 2,
fabs (pts[3]-pts[1]) >= total_size);
set_item_x_y (pane, so, ctrl_pts, 4, pts[2], (pts[1] + pts[3]) / 2,
fabs (pts[3]-pts[1]) >= total_size);
set_item_x_y (pane, so, ctrl_pts, 5, pts[0], pts[3], TRUE);
set_item_x_y (pane, so, ctrl_pts, 6, (pts[0] + pts[2]) / 2, pts[3],
fabs (pts[2]-pts[0]) >= total_size);
set_item_x_y (pane, so, ctrl_pts, 7, pts[2], pts[3], TRUE);
}
} | false | false | false | false | false | 0 |
bdx_hw_stop(struct bdx_priv *priv)
{
ENTER;
bdx_disable_interrupts(priv);
free_irq(priv->pdev->irq, priv->ndev);
netif_carrier_off(priv->ndev);
netif_stop_queue(priv->ndev);
RET();
} | false | false | false | false | false | 0 |
client3_1_fstat (call_frame_t *frame, xlator_t *this,
void *data)
{
clnt_args_t *args = NULL;
gfs3_fstat_req req = {{0,},};
int64_t remote_fd = -1;
clnt_conf_t *conf = NULL;
int op_errno = ESTALE;
int ret = 0;
if (!frame || !this || !data)
goto unwind;
args = data;
conf = this->private;
CLIENT_GET_REMOTE_FD(conf, args->fd, remote_fd, op_errno, unwind);
req.fd = remote_fd;
memcpy (req.gfid, args->fd->inode->gfid, 16);
GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),
req.xdata.xdata_len, op_errno, unwind);
ret = client_submit_request (this, &req, frame, conf->fops,
GFS3_OP_FSTAT, client3_1_fstat_cbk, NULL,
NULL, 0, NULL, 0,
NULL, (xdrproc_t)xdr_gfs3_fstat_req);
if (ret) {
gf_log (this->name, GF_LOG_WARNING, "failed to send the fop");
}
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
return 0;
unwind:
CLIENT_STACK_UNWIND (fstat, frame, -1, op_errno, NULL, NULL);
if (req.xdata.xdata_val)
GF_FREE (req.xdata.xdata_val);
return 0;
} | false | true | false | true | false | 1 |
gth_toggle_menu_action_finalize (GObject *base)
{
GthToggleMenuAction *self = GTH_TOGGLE_MENU_ACTION (base);
if (self->priv->show_menu_data_destroy != NULL)
self->priv->show_menu_data_destroy (self->priv->show_menu_data);
if (self->priv->menu != NULL)
g_object_unref (self->priv->menu);
G_OBJECT_CLASS (gth_toggle_menu_action_parent_class)->finalize (base);
} | false | false | false | false | false | 0 |
initialise_shutdown ()
{
// Broadcast 'terminate_writer' to all associated pipes.
for (pipes_t::iterator it = pipes.begin (); it != pipes.end (); it ++)
(*it)->terminate_writer ();
} | false | false | false | false | false | 0 |
UpdateTimeInformation()
{
if ( this->Metadata->OpenFile( this->FileName ) )
{
this->Metadata->UpdateTimeInformation();
if ( ! this->GetHasModeShapes() )
{
int nTimes = (int) this->Metadata->Times.size();
if ( nTimes )
{
this->TimeStepRange[0] = 0;
this->TimeStepRange[1] = nTimes - 1;
}
}
this->Metadata->CloseFile();
}
} | false | false | false | false | false | 0 |
removeDirRecursively(const QString &absPath, QString *error)
{
if (error)
error->clear();
QDir dir(absPath);
if (!dir.exists())
return true;
// remove all dirs inside this dir (recursively)
foreach(const QString &dirPath, dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) {
QString er;
if (!removeDirRecursively(dir.absolutePath() + QDir::separator() + dirPath, &er)) {
if (error)
error->append(er);
return false;
}
}
// remove this dir
QString er;
if (!removeDir(dir.absolutePath(), &er)) {
if (error)
error->append(er);
return false;
}
return true;
} | false | false | false | false | false | 0 |
GetStreamInfo(stream_info *info)
{
int result = 0;
memset(info, 0, sizeof(stream_info));
Lock();
if (plugin && plugin->stream_info && info && the_object) {
result = plugin->stream_info(the_object, info);
}
Unlock();
return result;
} | false | false | false | false | false | 0 |
tta_read_header(AVFormatContext *s, AVFormatParameters *ap)
{
TTAContext *c = s->priv_data;
AVStream *st;
int i, channels, bps, samplerate, datalen, framelen;
uint64_t framepos;
if (get_le32(s->pb) != AV_RL32("TTA1"))
return -1; // not tta file
url_fskip(s->pb, 2); // FIXME: flags
channels = get_le16(s->pb);
bps = get_le16(s->pb);
samplerate = get_le32(s->pb);
if(samplerate <= 0 || samplerate > 1000000){
av_log(s, AV_LOG_ERROR, "nonsense samplerate\n");
return -1;
}
datalen = get_le32(s->pb);
if(datalen < 0){
av_log(s, AV_LOG_ERROR, "nonsense datalen\n");
return -1;
}
url_fskip(s->pb, 4); // header crc
framelen = samplerate*256/245;
c->totalframes = datalen / framelen + ((datalen % framelen) ? 1 : 0);
c->currentframe = 0;
if(c->totalframes >= UINT_MAX/sizeof(uint32_t)){
av_log(s, AV_LOG_ERROR, "totalframes too large\n");
return -1;
}
st = av_new_stream(s, 0);
if (!st)
return AVERROR(ENOMEM);
av_set_pts_info(st, 64, 1, samplerate);
st->start_time = 0;
st->duration = datalen;
framepos = url_ftell(s->pb) + 4*c->totalframes + 4;
for (i = 0; i < c->totalframes; i++) {
uint32_t size = get_le32(s->pb);
av_add_index_entry(st, framepos, i*framelen, size, 0, AVINDEX_KEYFRAME);
framepos += size;
}
url_fskip(s->pb, 4); // seektable crc
st->codec->codec_type = CODEC_TYPE_AUDIO;
st->codec->codec_id = CODEC_ID_TTA;
st->codec->channels = channels;
st->codec->sample_rate = samplerate;
st->codec->bits_per_coded_sample = bps;
st->codec->extradata_size = url_ftell(s->pb);
if(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE <= (unsigned)st->codec->extradata_size){
//this check is redundant as get_buffer should fail
av_log(s, AV_LOG_ERROR, "extradata_size too large\n");
return -1;
}
st->codec->extradata = av_mallocz(st->codec->extradata_size+FF_INPUT_BUFFER_PADDING_SIZE);
url_fseek(s->pb, 0, SEEK_SET);
get_buffer(s->pb, st->codec->extradata, st->codec->extradata_size);
return 0;
} | false | false | false | false | false | 0 |
GetNumTracksWithEvents() const
{
int i;
for ( i = number_of_tracks - 1; i >= 0; --i )
{
if ( !tracks[i]->IsTrackEmpty() )
break;
}
return i+1;
} | false | false | false | false | false | 0 |
node_merge_stmt(struct grecs_node *to_node, struct grecs_node *from_node,
struct grecs_keyword *kwp, int flags)
{
if (kwp &&
(flags & GRECS_AGGR) ^ (kwp->flags & GRECS_AGGR) &&
((kwp->flags & GRECS_LIST) || kwp->callback))
node_aggregate_stmt(to_node, from_node,
kwp->flags & GRECS_LIST);
else {
grecs_value_free(from_node->v.value);
from_node->v.value = NULL;
}
} | false | false | false | false | false | 0 |
brd_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
int error;
struct brd_device *brd = bdev->bd_disk->private_data;
if (cmd != BLKFLSBUF)
return -ENOTTY;
/*
* ram device BLKFLSBUF has special semantics, we want to actually
* release and destroy the ramdisk data.
*/
mutex_lock(&brd_mutex);
mutex_lock(&bdev->bd_mutex);
error = -EBUSY;
if (bdev->bd_openers <= 1) {
/*
* Kill the cache first, so it isn't written back to the
* device.
*
* Another thread might instantiate more buffercache here,
* but there is not much we can do to close that race.
*/
kill_bdev(bdev);
brd_free_pages(brd);
error = 0;
}
mutex_unlock(&bdev->bd_mutex);
mutex_unlock(&brd_mutex);
return error;
} | false | true | false | false | false | 1 |
pgoto(P *p, long loc)
{
if (loc > p->byte)
pfwrd(p, loc - p->byte);
else if (loc < p->byte)
pbkwd(p, p->byte - loc);
return p;
} | false | false | false | false | false | 0 |
ncp_iget(struct super_block *sb, struct ncp_entry_info *info)
{
struct inode *inode;
if (info == NULL) {
pr_err("%s: info is NULL\n", __func__);
return NULL;
}
inode = new_inode(sb);
if (inode) {
atomic_set(&NCP_FINFO(inode)->opened, info->opened);
inode->i_ino = info->ino;
ncp_set_attr(inode, info);
if (S_ISREG(inode->i_mode)) {
inode->i_op = &ncp_file_inode_operations;
inode->i_fop = &ncp_file_operations;
} else if (S_ISDIR(inode->i_mode)) {
inode->i_op = &ncp_dir_inode_operations;
inode->i_fop = &ncp_dir_operations;
#ifdef CONFIG_NCPFS_NFS_NS
} else if (S_ISCHR(inode->i_mode) || S_ISBLK(inode->i_mode) || S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) {
init_special_inode(inode, inode->i_mode,
new_decode_dev(info->i.nfs.rdev));
#endif
#if defined(CONFIG_NCPFS_EXTRAS) || defined(CONFIG_NCPFS_NFS_NS)
} else if (S_ISLNK(inode->i_mode)) {
inode->i_op = &ncp_symlink_inode_operations;
inode->i_data.a_ops = &ncp_symlink_aops;
#endif
} else {
make_bad_inode(inode);
}
insert_inode_hash(inode);
} else
pr_err("%s: iget failed!\n", __func__);
return inode;
} | false | false | false | false | false | 0 |
store_sampling_rate(struct dbs_data *dbs_data, const char *buf,
size_t count)
{
struct cs_dbs_tuners *cs_tuners = dbs_data->tuners;
unsigned int input;
int ret;
ret = sscanf(buf, "%u", &input);
if (ret != 1)
return -EINVAL;
cs_tuners->sampling_rate = max(input, dbs_data->min_sampling_rate);
return count;
} | false | false | false | false | false | 0 |
cs_latin1(char *mstr, int *lenptr)
{
int ilen, olen, i;
char *latin1, *ptr;
const char *subst;
unsigned char ch;
UCS2 unicode;
ilen = lenptr ? *lenptr : strlen(mstr);
olen = 0;
for (i = 0; i < ilen; ++i)
{
ch = *((unsigned char *) mstr + i);
unicode = macroman[ch];
if (unicode & 0xff00)
olen += strlen(macroman_subst[ch & 0x7f]);
else
++olen;
}
latin1 = malloc(olen + 1);
if (latin1 == 0)
return 0;
ptr = latin1;
for (i = 0; i < ilen; ++i)
{
ch = *(unsigned char *) mstr++;
unicode = macroman[ch];
if (unicode & 0xff00)
{
/* substitute similar Latin-1 character(s) */
subst = macroman_subst[ch & 0x7f];
strcpy(ptr, subst);
ptr += strlen(subst);
}
else
*ptr++ = unicode;
}
*ptr = 0;
if (lenptr)
*lenptr = olen;
return latin1;
} | false | false | false | false | false | 0 |
_elm_notify_smart_content_get(const Evas_Object *obj,
const char *part)
{
ELM_NOTIFY_DATA_GET(obj, sd);
if (part && strcmp(part, "default")) return NULL;
return sd->content;
} | false | false | false | false | false | 0 |
act2_close_dev(struct act2_eegdev* a2dev)
{
// Close the USB device
if (a2dev->hudev != NULL) {
libusb_release_interface(a2dev->hudev, 0);
libusb_close(a2dev->hudev);
}
// Close the session to libusb
if (a2dev->ctx) {
pthread_mutex_lock(&a2dev->mtx);
a2dev->stopusb = 1;
pthread_mutex_unlock(&a2dev->mtx);
pthread_join(a2dev->thread_id, NULL);
pthread_mutex_destroy(&a2dev->mtx);
pthread_cond_destroy(&a2dev->cond);
libusb_exit(a2dev->ctx);
}
return 0;
} | false | false | false | false | false | 0 |
removeAStarBefore(const Decl *D)
{
SourceLocation LocStart = D->getLocation();
const char *StartBuf = SrcManager->getCharacterData(LocStart);
int Offset = 0;
while (*StartBuf != '*') {
StartBuf--;
Offset--;
}
SourceLocation StarLoc = LocStart.getLocWithOffset(Offset);
return !TheRewriter->RemoveText(StarLoc, 1);
} | false | false | false | false | true | 1 |
iraw_loop(unsigned numbytes, struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
struct bc_state *bcs = cs->bcs;
int inputstate = bcs->inputstate;
struct sk_buff *skb = bcs->rx_skb;
unsigned char *src = inbuf->data + inbuf->head;
unsigned procbytes = 0;
unsigned char c;
if (!skb) {
/* skip this block */
gigaset_new_rx_skb(bcs);
return numbytes;
}
while (procbytes < numbytes && skb->len < bcs->rx_bufsize) {
c = *src++;
procbytes++;
if (c == DLE_FLAG) {
if (inputstate & INS_DLE_char) {
/* quoted DLE: clear quote flag */
inputstate &= ~INS_DLE_char;
} else if (cs->dle || (inputstate & INS_DLE_command)) {
/* DLE escape, pass up for handling */
inputstate |= INS_DLE_char;
break;
}
}
/* regular data byte: append to current skb */
inputstate |= INS_have_data;
*__skb_put(skb, 1) = bitrev8(c);
}
/* pass data up */
if (inputstate & INS_have_data) {
gigaset_skb_rcvd(bcs, skb);
inputstate &= ~INS_have_data;
gigaset_new_rx_skb(bcs);
}
bcs->inputstate = inputstate;
return procbytes;
} | false | false | false | false | false | 0 |
VCLS_Poll(struct VCLS *cs, int timeout)
{
struct VCLS_fd *cfd, *cfd2;
int i, j, k;
CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC);
if (cs->nfd == 0) {
errno = 0;
return (-1);
}
assert(cs->nfd > 0);
{
struct pollfd pfd[cs->nfd];
i = 0;
VTAILQ_FOREACH(cfd, &cs->fds, list) {
pfd[i].fd = cfd->fdi;
pfd[i].events = POLLIN;
pfd[i].revents = 0;
i++;
}
assert(i == cs->nfd);
j = poll(pfd, cs->nfd, timeout);
if (j <= 0)
return (j);
i = 0;
VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) {
assert(pfd[i].fd == cfd->fdi);
if (pfd[i].revents & POLLHUP)
k = 1;
else
k = VLU_Fd(cfd->fdi, cfd->cli->vlu);
if (k)
cls_close_fd(cs, cfd);
i++;
}
assert(i == j);
}
return (j);
} | false | false | false | true | false | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.