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 |
|---|---|---|---|---|---|---|
setBorderColor(UT_RGBColor clr)
{
m_borderColor = clr;
UT_String s = UT_String_sprintf("%02x%02x%02x", clr.m_red, clr.m_grn, clr.m_blu);
m_vecProps.addOrReplaceProp("left-color", s.c_str());
m_vecProps.addOrReplaceProp("right-color", s.c_str());
m_vecProps.addOrReplaceProp("top-color", s.c_str());
m_vecProps.addOrReplaceProp("bot-color", s.c_str());
// m_vecPropsAdjRight.addOrReplaceProp("left-color", s.c_str());
// m_vecPropsAdjBottom.addOrReplaceProp("top-color", s.c_str());
m_bSettingsChanged = true;
UT_DEBUGMSG(("Maleesh ======================= setBorderColor\n"));
} | false | false | false | false | false | 0 |
getRandomSurfacePoint(Vector3& p, Vector3& N) const {
float h = height();
float r = radius();
// Create a random point on a standard cylinder and then rotate to the global frame.
// Relative areas (factor of 2PI already taken out)
float capRelArea = square(r) / 2.0f;
float sideRelArea = r * h;
float r1 = uniformRandom(0, capRelArea * 2 + sideRelArea);
if (r1 < capRelArea * 2) {
// Select a point uniformly at random on a disk
// @cite http://mathworld.wolfram.com/DiskPointPicking.html
float a = uniformRandom(0, (float)twoPi());
float r2 = sqrt(uniformRandom(0, 1)) * r;
p.x = cos(a) * r2;
p.z = sin(a) * r2;
N.x = 0;
N.z = 0;
if (r1 < capRelArea) {
// Top
p.y = h / 2.0f;
N.y = 1;
} else {
// Bottom
p.y = -h / 2.0f;
N.y = -1;
}
} else {
// Side
float a = uniformRandom(0, (float)twoPi());
N.x = cos(a);
N.y = 0;
N.z = sin(a);
p.x = N.x * r;
p.z = N.y * r;
p.y = uniformRandom(-h / 2.0f, h / 2.0f);
}
// Transform to world space
CoordinateFrame cframe;
getReferenceFrame(cframe);
p = cframe.pointToWorldSpace(p);
N = cframe.normalToWorldSpace(N);
} | false | false | false | false | false | 0 |
string_array_contains (char **array,
const char *str)
{
char **p;
if (!array)
return FALSE;
for (p = array; *p; p++)
if (g_ascii_strcasecmp (*p, str) == 0) {
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
setIndirectBoundaries(uint32_t indexR, uint32_t *start, uint32_t *end) {
// Set values for the top - TODO: once we have values for all the indirects, we are going
// to initalize here.
ucolIndirectBoundaries[indexR].startCE = start[0];
ucolIndirectBoundaries[indexR].startContCE = start[1];
if(end) {
ucolIndirectBoundaries[indexR].limitCE = end[0];
ucolIndirectBoundaries[indexR].limitContCE = end[1];
} else {
ucolIndirectBoundaries[indexR].limitCE = 0;
ucolIndirectBoundaries[indexR].limitContCE = 0;
}
} | false | false | false | false | false | 0 |
grl_metadata_store_source_store_metadata (GrlSource *source,
GrlSourceStoreMetadataSpec *sms)
{
GRL_DEBUG ("grl_metadata_store_source_set_metadata");
const gchar *media_id, *source_id;
GError *error = NULL;
GList *failed_keys = NULL;
source_id = grl_media_get_source (sms->media);
media_id = grl_media_get_id (sms->media);
/* We need the source id */
if (!source_id) {
GRL_WARNING ("Failed to update metadata: source-id not available");
error = g_error_new (GRL_CORE_ERROR,
GRL_CORE_ERROR_STORE_METADATA_FAILED,
_("Failed to update metadata: %s"),
_("\"source-id\" not available"));
failed_keys = g_list_copy (sms->keys);
} else {
/* Special case for root categories */
if (!media_id) {
media_id = "";
}
failed_keys = write_keys (GRL_METADATA_STORE_SOURCE (source)->priv->db,
source_id, media_id, sms, &error);
}
sms->callback (sms->source, sms->media, failed_keys, sms->user_data, error);
g_clear_error (&error);
g_list_free (failed_keys);
} | false | false | false | false | false | 0 |
remove_object_files(const char *odb_dir, object_data *d)
{
if (gitfo_unlink(d->file) < 0) {
fprintf(stderr, "can't delete object file \"%s\"\n", d->file);
return -1;
}
if ((gitfo_rmdir(d->dir) < 0) && (errno != ENOTEMPTY)) {
fprintf(stderr, "can't remove object directory \"%s\"\n", d->dir);
return -1;
}
if (gitfo_rmdir(odb_dir) < 0) {
fprintf(stderr, "can't remove directory \"%s\"\n", odb_dir);
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
zx_scan_pi_or_comment(struct zx_ctx* c)
{
const char* name;
char quote;
switch (*c->p) {
case '?': /* processing instruction <?xml ... ?> */
name = c->p-1;
DD("Processing Instruction detected (%.*s)", 5, name);
while (1) {
quote = '>';
ZX_LOOK_FOR(c,'>');
if (c->p[-1] == '?')
break;
}
++c->p;
DD("Processing Instruction scanned (%.*s)", c->p-name, name);
/*ZX_PI_DEC_EXT(pi);*/
return 0;
case '!': /* comment <!-- ... --> or <!DOCTYPE...> */
name = c->p-1;
if (!memcmp(c->p+1, "DOCTYPE", sizeof("DOCTYPE")-1)) {
D("DOCTYPE detected (%.*s)", 60, c->p-1);
ZX_LOOK_FOR(c,'>');
++c->p;
D("DOCTYPE scanned (%.*s)", ((int)(c->p-name)), name);
return 0;
}
c->p += 2;
if (c->p[-1] != '-' || c->p[0] != '-') {
c->p -= 3;
return 1;
}
D("Comment detected (%.*s)", 8, name);
c->p += 2;
while (1) {
quote = '>';
ZX_LOOK_FOR(c,'>');
if (c->p[-2] == '-' && c->p[-1] == '-') {
break;
}
}
++c->p;
D("Comment scanned (%.*s)", ((int)(c->p-name)), name);
/*ZX_COMMENT_DEC_EXT(comment);*/
return 0;
}
return 1;
look_for_not_found:
zx_xml_parse_err(c, quote, (const char*)__FUNCTION__, "look for not found");
return 1;
} | false | false | false | false | true | 1 |
str16ncpy(dest, src, n)
char16 *dest, *src;
size_t n;
{
while ((n > 0) && *src)
{
*dest++ = *src++;
n--;
}
*dest = 0; /* We always terminate the string here */
} | false | false | false | false | false | 0 |
get_seed_file_info( char *file_name, seed_file_info* file_info,
bool print_file_info ) {
FILE *file_handle = NULL;
uint8_t *buffer = NULL;
long end_offset;
long file_length;
long records_read;
seed_header header_seed; /* SEED header struct*/
uint8_t* header_ptr = NULL;
file_info->good = false;
if ( print_file_info ) {
printf( "Getting file info for %s\n", file_name );
}
if ( !file_name ) {
fprintf( stderr, "No file name supplied.\n" );
goto clean;
}
buffer = malloc( (size_t)(RECORD_SIZE) );
if ( !buffer ) {
fprintf( stderr, "Could not allocate memory for read buffer.\n" );
goto clean;
}
file_handle = fopen( file_name, "rb" );
if ( !file_handle ) {
fprintf( stderr, "Unable to open file '%s' for reading.\n", file_name );
goto clean;
}
fseek( file_handle, 0, SEEK_END );
file_length = ftell( file_handle );
if ( file_length < (long)RECORD_SIZE ) {
fprintf( stderr, "File is too small to contain seed records.\n" );
goto clean;
}
end_offset = file_length % (long)RECORD_SIZE
? file_length / (long)RECORD_SIZE
? file_length - (file_length % (long)RECORD_SIZE) - (long)RECORD_SIZE
: (long)0
: file_length - (long)RECORD_SIZE;
if ( print_file_info ) {
printf( "File size is %li bytes.\n", file_length );
}
if ( print_file_info ) {
printf( "Reading at position [%li]\n", (long)0 );
}
fseek( file_handle, 0, SEEK_SET );
records_read = fread( buffer, (size_t)RECORD_SIZE, 1, file_handle );
header_ptr = buffer;
loadseedhdr( (pbyte *)&header_ptr, &header_seed, false );
if ( print_file_info ) {
print_seed_header( &header_seed );
}
if ( !records_read ) {
goto clean;
}
file_info->start_time = header_seed.starting_time;
if ( print_file_info ) {
printf( "Reading at position [%li]\n", end_offset );
}
fseek( file_handle, end_offset, SEEK_SET );
records_read = fread( buffer, (size_t)RECORD_SIZE, 1, file_handle );
header_ptr = buffer;
loadseedhdr( (pbyte *)&header_ptr, &header_seed, false );
if ( print_file_info ) {
print_seed_header( &header_seed );
}
if ( !records_read ) {
goto clean;
}
file_info->end_time = header_seed.starting_time;
fclose( file_handle );
file_info->length = file_length;
file_info->good = true;
clean:
if ( buffer ) {
free( buffer );
}
} | false | false | false | false | true | 1 |
profile_enter( OBJECT * rulename, profile_frame * frame )
{
if ( DEBUG_PROFILE )
{
clock_t start = clock();
profile_info * p;
if ( !profile_hash && rulename )
profile_hash = hashinit( sizeof( profile_info ), "profile" );
if ( rulename )
{
int found;
p = (profile_info *)hash_insert( profile_hash, rulename, &found );
if ( !found )
{
p->name = rulename;
p->cumulative = 0;
p->net = 0;
p->num_entries = 0;
p->stack_count = 0;
p->memory = 0;
}
}
else
{
p = &profile_other;
}
++p->num_entries;
++p->stack_count;
frame->info = p;
frame->caller = profile_stack;
profile_stack = frame;
frame->entry_time = clock();
frame->overhead = 0;
frame->subrules = 0;
/* caller pays for the time it takes to play with the hash table */
if ( frame->caller )
frame->caller->overhead += frame->entry_time - start;
}
} | false | false | false | false | false | 0 |
bnx2_init_rxbd_rings(struct bnx2_rx_bd *rx_ring[], dma_addr_t dma[],
u32 buf_size, int num_rings)
{
int i;
struct bnx2_rx_bd *rxbd;
for (i = 0; i < num_rings; i++) {
int j;
rxbd = &rx_ring[i][0];
for (j = 0; j < BNX2_MAX_RX_DESC_CNT; j++, rxbd++) {
rxbd->rx_bd_len = buf_size;
rxbd->rx_bd_flags = RX_BD_FLAGS_START | RX_BD_FLAGS_END;
}
if (i == (num_rings - 1))
j = 0;
else
j = i + 1;
rxbd->rx_bd_haddr_hi = (u64) dma[j] >> 32;
rxbd->rx_bd_haddr_lo = (u64) dma[j] & 0xffffffff;
}
} | false | false | false | false | false | 0 |
msgcache_write_tags(MsgInfo *msginfo, FILE *fp)
{
GSList *cur = msginfo->tags;
int w_err = 0, wrote = 0;
WRITE_CACHE_DATA_INT(msginfo->msgnum, fp);
for (; cur; cur = cur->next) {
gint id = GPOINTER_TO_INT(cur->data);
if (tags_get_tag(id) != NULL) {
WRITE_CACHE_DATA_INT(id, fp);
}
}
WRITE_CACHE_DATA_INT(-1, fp);
return w_err ? -1 : wrote;
} | false | false | false | false | false | 0 |
io_tofilep(lua_State *L)
{
if (!(L->base < L->top && tvisudata(L->base) &&
udataV(L->base)->udtype == UDTYPE_IO_FILE))
lj_err_argtype(L, 1, "FILE*");
return (IOFileUD *)uddata(udataV(L->base));
} | false | false | false | false | false | 0 |
show_ggvis_window (GtkAction *action, PluginInstance *inst)
{
GSList *l;
GGobiData *d;
gboolean ok = false;
/* Before doing anything, make sure there is input data, and that
it includes an edge set */
if (g_slist_length(inst->gg->d) < 1) {
g_printerr ("ggvis: can't initialize without data\n");
return;
}
for (l = inst->gg->d; l; l = l->next) {
d = (GGobiData *) l->data;
if (d->edge.n > 0) {
ok = true;
break;
}
}
if (!ok) {
quick_message ("ggvis requires edges to define pairwise distances", false);
return;
}
if (inst->data == NULL) {
ggvisd *ggv = (ggvisd *) g_malloc (sizeof (ggvisd));
ggvis_init (ggv, inst->gg);
ggv_histogram_init (ggv, inst->gg);
create_ggvis_window (ggv, inst);
} else {
gtk_widget_show_now ((GtkWidget*) inst->data); /* ie, window */
}
} | false | false | false | false | false | 0 |
TrimRepresentation(Vector<char> representation) {
int len = strlen(representation.start());
int i;
for (i = len - 1; i >= 0; --i) {
if (representation[i] != '0') break;
}
representation[i + 1] = '\0';
} | false | false | false | false | false | 0 |
remove_block_if_useless (MonoCompile *cfg, MonoBasicBlock *bb, MonoBasicBlock *previous_bb) {
MonoBasicBlock *target_bb = NULL;
MonoInst *inst;
/* Do not touch handlers */
if (bb->region != -1) {
bb->not_useless = TRUE;
return FALSE;
}
MONO_BB_FOR_EACH_INS (bb, inst) {
switch (inst->opcode) {
case OP_NOP:
break;
case OP_BR:
target_bb = inst->inst_target_bb;
break;
default:
bb->not_useless = TRUE;
return FALSE;
}
}
if (target_bb == NULL) {
if ((bb->out_count == 1) && (bb->out_bb [0] == bb->next_bb)) {
target_bb = bb->next_bb;
} else {
/* Do not touch empty BBs that do not "fall through" to their next BB (like the exit BB) */
return FALSE;
}
}
/* Do not touch BBs following a switch (they are the "default" branch) */
if ((previous_bb->last_ins != NULL) && (previous_bb->last_ins->opcode == OP_SWITCH)) {
return FALSE;
}
/* Do not touch BBs following the entry BB and jumping to something that is not */
/* thiry "next" bb (the entry BB cannot contain the branch) */
if ((previous_bb == cfg->bb_entry) && (bb->next_bb != target_bb)) {
return FALSE;
}
/*
* Do not touch BBs following a try block as the code in
* mini_method_compile needs them to compute the length of the try block.
*/
if (MONO_BBLOCK_IS_IN_REGION (previous_bb, MONO_REGION_TRY))
return FALSE;
/* Check that there is a target BB, and that bb is not an empty loop (Bug 75061) */
if ((target_bb != NULL) && (target_bb != bb)) {
int i;
if (cfg->verbose_level > 1) {
printf ("remove_block_if_useless, removed BB%d\n", bb->block_num);
}
/* unlink_bblock () modifies the bb->in_bb array so can't use a for loop here */
while (bb->in_count) {
MonoBasicBlock *in_bb = bb->in_bb [0];
mono_unlink_bblock (cfg, in_bb, bb);
mono_link_bblock (cfg, in_bb, target_bb);
replace_out_block_in_code (in_bb, bb, target_bb);
}
mono_unlink_bblock (cfg, bb, target_bb);
if (previous_bb != cfg->bb_entry && mono_bb_is_fall_through (cfg, previous_bb)) {
for (i = 0; i < previous_bb->out_count; i++) {
if (previous_bb->out_bb [i] == target_bb) {
MonoInst *jump;
MONO_INST_NEW (cfg, jump, OP_BR);
MONO_ADD_INS (previous_bb, jump);
jump->cil_code = previous_bb->cil_code;
jump->inst_target_bb = target_bb;
break;
}
}
}
previous_bb->next_bb = bb->next_bb;
mono_nullify_basic_block (bb);
return TRUE;
} else {
return FALSE;
}
} | false | false | false | false | false | 0 |
preprocess(std::istream &istr, std::map<std::string, std::string> &result, const std::string &filename, const std::list<std::string> &includePaths)
{
std::list<std::string> configs;
std::string data;
preprocess(istr, data, configs, filename, includePaths);
for (std::list<std::string>::const_iterator it = configs.begin(); it != configs.end(); ++it) {
if (_settings && (_settings->userUndefs.find(*it) == _settings->userUndefs.end())) {
result[ *it ] = getcode(data, *it, filename);
}
}
} | false | false | false | false | false | 0 |
Xsettimeout(fp, timeout)
XFILE *fp;
int timeout;
{
if (checkfp(fp, 0) < 0) return;
fp -> timeout = timeout;
} | false | false | false | false | false | 0 |
lbcd_proto2_convert(struct lbcd_reply *lb)
{
uint32_t weightval_i;
uint16_t weightval_s;
/* Convert host weight to a short, handling network byte order */
weightval_i = ntohl(lb->weights[0].host_weight);
if (weightval_i > (uint16_t) -1)
weightval_s = (uint16_t) -1;
else
weightval_s = weightval_i;
/*
* lbnamed v2 only used l1, tot_users, and uniq_users, although Rob thinks
* all the loads may be used, so set them all just in case.
*/
lb->l1 = htons(weightval_s);
lb->l5 = htons(weightval_s);
lb->l15 = htons(weightval_s);
lb->tot_users = 0;
lb->uniq_users = 0;
} | false | false | false | false | false | 0 |
cp_parser_objc_method_definition_list (cp_parser* parser)
{
cp_token *token = cp_lexer_peek_token (parser->lexer);
while (token->keyword != RID_AT_END && token->type != CPP_EOF)
{
tree meth;
if (token->type == CPP_PLUS || token->type == CPP_MINUS)
{
cp_token *ptk;
tree sig, attribute;
bool is_class_method;
if (token->type == CPP_PLUS)
is_class_method = true;
else
is_class_method = false;
push_deferring_access_checks (dk_deferred);
sig = cp_parser_objc_method_signature (parser, &attribute);
if (sig == error_mark_node)
{
cp_parser_skip_to_end_of_block_or_statement (parser);
token = cp_lexer_peek_token (parser->lexer);
continue;
}
objc_start_method_definition (is_class_method, sig, attribute,
NULL_TREE);
/* For historical reasons, we accept an optional semicolon. */
if (cp_lexer_next_token_is (parser->lexer, CPP_SEMICOLON))
cp_lexer_consume_token (parser->lexer);
ptk = cp_lexer_peek_token (parser->lexer);
if (!(ptk->type == CPP_PLUS || ptk->type == CPP_MINUS
|| ptk->type == CPP_EOF || ptk->keyword == RID_AT_END))
{
perform_deferred_access_checks ();
stop_deferring_access_checks ();
meth = cp_parser_function_definition_after_declarator (parser,
false);
pop_deferring_access_checks ();
objc_finish_method_definition (meth);
}
}
/* The following case will be removed once @synthesize is
completely implemented. */
else if (token->keyword == RID_AT_PROPERTY)
cp_parser_objc_at_property_declaration (parser);
else if (token->keyword == RID_AT_SYNTHESIZE)
cp_parser_objc_at_synthesize_declaration (parser);
else if (token->keyword == RID_AT_DYNAMIC)
cp_parser_objc_at_dynamic_declaration (parser);
else if (token->keyword == RID_ATTRIBUTE
&& cp_parser_objc_method_maybe_bad_prefix_attributes(parser))
warning_at (token->location, OPT_Wattributes,
"prefix attributes are ignored for methods");
else
/* Allow for interspersed non-ObjC++ code. */
cp_parser_objc_interstitial_code (parser);
token = cp_lexer_peek_token (parser->lexer);
}
if (token->type != CPP_EOF)
cp_lexer_consume_token (parser->lexer); /* Eat '@end'. */
else
cp_parser_error (parser, "expected %<@end%>");
objc_finish_implementation ();
} | false | false | false | false | false | 0 |
globus_l_gass_copy_ftp_read_callback(
void * callback_arg,
globus_ftp_client_handle_t * handle,
globus_object_t * error,
globus_byte_t * bytes,
globus_size_t nbytes,
globus_off_t offset,
globus_bool_t eof)
{
globus_gass_copy_handle_t * copy_handle
= (globus_gass_copy_handle_t *) callback_arg;
globus_gass_copy_state_t * state
= copy_handle->state;
globus_bool_t last_data= GLOBUS_FALSE;
#ifdef GLOBUS_I_GASS_COPY_DEBUG
globus_libc_fprintf(stderr,
"ftp_read_callback(): start, n_pending: %d, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n",
state->source.n_pending, nbytes, offset, eof);
#endif
if(error == GLOBUS_SUCCESS) /* no error occured */
{
last_data = eof;
if(eof)
{
#ifdef GLOBUS_I_GASS_COPY_DEBUG
globus_libc_fprintf(stderr,
"ftp_read_callback(): source TARGET_DONE, nbytes: %d, offset: %"GLOBUS_OFF_T_FORMAT", eof: %d\n",
nbytes, offset, eof);
#endif
/*
globus_mutex_lock(&(state->source.mutex));
{
state->source.status = GLOBUS_I_GASS_COPY_TARGET_DONE;
}
globus_mutex_unlock(&(state->source.mutex));
*/
if((copy_handle->status != GLOBUS_GASS_COPY_STATUS_FAILURE) &&
(copy_handle->status < GLOBUS_GASS_COPY_STATUS_READ_COMPLETE))
copy_handle->status = GLOBUS_GASS_COPY_STATUS_READ_COMPLETE;
}
}
else /* there was an error */
{
#ifdef GLOBUS_I_GASS_COPY_DEBUG
globus_libc_fprintf(stderr, "ftp_read_callback: was passed an ERROR\n");
#endif
{
if(!state->cancel) /* cancel has not been set already */
{
globus_i_gass_copy_set_error(copy_handle, error);
state->cancel = GLOBUS_I_GASS_COPY_CANCEL_TRUE;
copy_handle->status = GLOBUS_GASS_COPY_STATUS_FAILURE;
state->source.data.ftp.data_err = copy_handle->err;
}
else
{
globus_mutex_lock(&(state->source.mutex));
state->source.n_pending--;
globus_mutex_unlock(&(state->source.mutex));
return;
}
}
} /* else (there was an error) */
globus_l_gass_copy_generic_read_callback(
copy_handle,
bytes,
nbytes,
offset,
last_data);
} | false | false | false | false | false | 0 |
nvpair_database_insert( struct nvpair_database *db, const char *key, struct nvpair *nv )
{
struct nvpair *old = hash_table_remove(db->table,key);
hash_table_insert(db->table,key,nv);
if(db->logdir) {
if(old) {
log_updates(db,key,old,nv);
nvpair_delete(old);
} else {
log_create(db,key,nv);
}
}
log_flush(db);
} | false | false | false | false | true | 1 |
ValidateBaseCode()
{
bool pass = true, fail;
byte data[255];
for (unsigned int i=0; i<255; i++)
data[i] = i;
const char *hexEncoded =
"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F2021222324252627"
"28292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F"
"505152535455565758595A5B5C5D5E5F606162636465666768696A6B6C6D6E6F7071727374757677"
"78797A7B7C7D7E7F808182838485868788898A8B8C8D8E8F909192939495969798999A9B9C9D9E9F"
"A0A1A2A3A4A5A6A7A8A9AAABACADAEAFB0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC0C1C2C3C4C5C6C7"
"C8C9CACBCCCDCECFD0D1D2D3D4D5D6D7D8D9DADBDCDDDEDFE0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF"
"F0F1F2F3F4F5F6F7F8F9FAFBFCFDFE";
const char *base32Encoded =
"AAASEA2EAWDAQCAJBIFS2DIQB6IBCESVCSKTNF22DEPBYHA7D2RUAIJCENUCKJTHFAWUWK3NFWZC8NBT"
"GI3VIPJYG66DUQT5HS8V6R4AIFBEGTCFI3DWSUKKJPGE4VURKBIXEW4WKXMFQYC3MJPX2ZK8M7SGC2VD"
"NTUYN35IPFXGY5DPP3ZZA6MUQP4HK7VZRB6ZW856RX9H9AEBSKB2JBNGS8EIVCWMTUG27D6SUGJJHFEX"
"U4M3TGN4VQQJ5HW9WCS4FI7EWYVKRKFJXKX43MPQX82MDNXVYU45PP72ZG7MZRF7Z496BSQC2RCNMTYH"
"3DE6XU8N3ZHN9WGT4MJ7JXQY49NPVYY55VQ77Z9A6HTQH3HF65V8T4RK7RYQ55ZR8D29F69W8Z5RR8H3"
"9M7939R8";
const char *base64AndHexEncoded =
"41414543417751464267634943516F4C4441304F4478415245684D554652595847426B6147787764"
"486838674953496A4A43556D4A7967704B6973734C5334764D4445794D7A51310A4E6A63344F546F"
"375044302B50304242516B4E4552555A4853456C4B5330784E546B395155564A5456465657563168"
"5A576C746358563566594746695932526C5A6D646F615770720A6247317562334278636E4E306458"
"5A3365486C3665337839666E2B4167594B44684957476834694A696F754D6A5936506B4A47536B35"
"53566C7065596D5A71626E4A32656E3643680A6F714F6B7061616E714B6D717136797472712B7773"
"624B7A744C573274376935757275387662362F774D484377385446787366497963724C7A4D334F7A"
"39445230745055316462580A324E6E6132397A6433742F6734654C6A354F586D352B6A7036757673"
"3765377638504879382F5431397666342B6672372F50332B0A";
cout << "\nBase64, base32 and hex coding validation suite running...\n\n";
fail = !TestFilter(HexEncoder().Ref(), data, 255, (const byte *)hexEncoded, strlen(hexEncoded));
cout << (fail ? "FAILED " : "passed ");
cout << "Hex Encoding\n";
pass = pass && !fail;
fail = !TestFilter(HexDecoder().Ref(), (const byte *)hexEncoded, strlen(hexEncoded), data, 255);
cout << (fail ? "FAILED " : "passed ");
cout << "Hex Decoding\n";
pass = pass && !fail;
fail = !TestFilter(Base32Encoder().Ref(), data, 255, (const byte *)base32Encoded, strlen(base32Encoded));
cout << (fail ? "FAILED " : "passed ");
cout << "Base32 Encoding\n";
pass = pass && !fail;
fail = !TestFilter(Base32Decoder().Ref(), (const byte *)base32Encoded, strlen(base32Encoded), data, 255);
cout << (fail ? "FAILED " : "passed ");
cout << "Base32 Decoding\n";
pass = pass && !fail;
fail = !TestFilter(Base64Encoder(new HexEncoder).Ref(), data, 255, (const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded));
cout << (fail ? "FAILED " : "passed ");
cout << "Base64 Encoding\n";
pass = pass && !fail;
fail = !TestFilter(HexDecoder(new Base64Decoder).Ref(), (const byte *)base64AndHexEncoded, strlen(base64AndHexEncoded), data, 255);
cout << (fail ? "FAILED " : "passed ");
cout << "Base64 Decoding\n";
pass = pass && !fail;
return pass;
} | false | false | false | false | false | 0 |
setinst(unsigned char chan)
{
unsigned char op = op_table[chan];
unsigned short insnr = channel[chan].inst;
// set instrument data
opl->write(0x63 + op, inst[insnr].data[0]);
opl->write(0x83 + op, inst[insnr].data[1]);
opl->write(0x23 + op, inst[insnr].data[3]);
opl->write(0xe3 + op, inst[insnr].data[4]);
opl->write(0x60 + op, inst[insnr].data[5]);
opl->write(0x80 + op, inst[insnr].data[6]);
opl->write(0x20 + op, inst[insnr].data[8]);
opl->write(0xe0 + op, inst[insnr].data[9]);
if(version)
opl->write(0xc0 + chan, inst[insnr].data[10]);
else
opl->write(0xc0 + chan, (inst[insnr].data[10] << 1) + (inst[insnr].tunelev & 1));
} | false | false | false | false | false | 0 |
rtw_ies_remove_ie23a(u8 *ies, uint *ies_len, uint offset, u8 eid,
u8 *oui, u8 oui_len)
{
int ret = _FAIL;
u8 *target_ie;
u32 target_ielen;
u8 *start;
uint search_len;
if (!ies || !ies_len || *ies_len <= offset)
goto exit;
start = ies + offset;
search_len = *ies_len - offset;
while (1) {
target_ie = rtw_get_ie23a_ex(start, search_len, eid, oui, oui_len,
NULL, &target_ielen);
if (target_ie && target_ielen) {
u8 buf[MAX_IE_SZ] = {0};
u8 *remain_ies = target_ie + target_ielen;
uint remain_len = search_len - (remain_ies - start);
memcpy(buf, remain_ies, remain_len);
memcpy(target_ie, buf, remain_len);
*ies_len = *ies_len - target_ielen;
ret = _SUCCESS;
start = target_ie;
search_len = remain_len;
} else {
break;
}
}
exit:
return ret;
} | false | false | false | false | false | 0 |
setup_convert_check(struct git_attr_check *check)
{
static struct git_attr *attr_crlf;
static struct git_attr *attr_ident;
static struct git_attr *attr_filter;
if (!attr_crlf) {
attr_crlf = git_attr("crlf", 4);
attr_ident = git_attr("ident", 5);
attr_filter = git_attr("filter", 6);
user_convert_tail = &user_convert;
git_config(read_convert_config);
}
check[0].attr = attr_crlf;
check[1].attr = attr_ident;
check[2].attr = attr_filter;
} | false | false | false | false | false | 0 |
_c2s_component_presence(c2s_t c2s, nad_t nad) {
int attr;
char from[1024];
sess_t sess;
union xhashv xhv;
if((attr = nad_find_attr(nad, 0, -1, "from", NULL)) < 0) {
nad_free(nad);
return;
}
strncpy(from, NAD_AVAL(nad, attr), NAD_AVAL_L(nad, attr));
from[NAD_AVAL_L(nad, attr)] = '\0';
if(nad_find_attr(nad, 0, -1, "type", NULL) < 0) {
log_debug(ZONE, "component available from '%s'", from);
log_debug(ZONE, "sm for serviced domain '%s' online", from);
xhash_put(c2s->sm_avail, pstrdup(xhash_pool(c2s->sm_avail), from), (void *) 1);
nad_free(nad);
return;
}
if(nad_find_attr(nad, 0, -1, "type", "unavailable") < 0) {
nad_free(nad);
return;
}
log_debug(ZONE, "component unavailable from '%s'", from);
if(xhash_get(c2s->sm_avail, from) != NULL) {
log_debug(ZONE, "sm for serviced domain '%s' offline", from);
if(xhash_iter_first(c2s->sessions))
do {
xhv.sess_val = &sess;
xhash_iter_get(c2s->sessions, NULL, NULL, xhv.val);
if(sess->resources != NULL && strcmp(sess->resources->jid->domain, from) == 0) {
log_debug(ZONE, "killing session %s", jid_user(sess->resources->jid));
sess->active = 0;
if(sess->s) sx_close(sess->s);
}
} while(xhash_iter_next(c2s->sessions));
xhash_zap(c2s->sm_avail, from);
}
} | false | false | false | false | true | 1 |
wbcg_find_for_workbook (Workbook *wb,
WBCGtk *candidate,
GdkScreen *pref_screen,
GdkDisplay *pref_display)
{
gboolean has_screen, has_display;
g_return_val_if_fail (IS_WORKBOOK (wb), NULL);
g_return_val_if_fail (candidate == NULL || IS_WBC_GTK (candidate), NULL);
if (candidate && wb_control_get_workbook (WORKBOOK_CONTROL (candidate)) == wb)
return candidate;
if (!pref_screen && candidate)
pref_screen = wbcg_get_screen (candidate);
if (!pref_display && pref_screen)
pref_display = gdk_screen_get_display (pref_screen);
candidate = NULL;
has_screen = FALSE;
has_display = FALSE;
WORKBOOK_FOREACH_CONTROL(wb, wbv, wbc, {
if (IS_WBC_GTK (wbc)) {
WBCGtk *wbcg = WBC_GTK (wbc);
GdkScreen *screen = wbcg_get_screen (wbcg);
GdkDisplay *display = gdk_screen_get_display (screen);
if (pref_screen == screen && !has_screen) {
has_screen = has_display = TRUE;
candidate = wbcg;
} else if (pref_display == display && !has_display) {
has_display = TRUE;
candidate = wbcg;
} else if (!candidate)
candidate = wbcg;
}
});
return candidate;
} | false | false | false | false | false | 0 |
edit_input_c2d(byte b)
{
int h = -1;
if (b >= '0' && b <= '9') {
h = b-'0';
}
return h;
} | false | false | false | false | false | 0 |
Compute_Head_CRC(FILE *ptx, dword Offset,byte hdr_size)
{
byte CRC = 0, tmp, i;
fseek(ptx,Offset+2,0);
for(i=0;i<hdr_size;i++) {
fread(&tmp,1,1,ptx);
CRC += tmp;
}
return(CRC);
} | false | false | false | false | true | 1 |
btt_data_read(struct arena_info *arena, struct page *page,
unsigned int off, u32 lba, u32 len)
{
int ret;
u64 nsoff = to_namespace_offset(arena, lba);
void *mem = kmap_atomic(page);
ret = arena_read_bytes(arena, nsoff, mem + off, len);
kunmap_atomic(mem);
return ret;
} | false | false | false | false | false | 0 |
vvcopy(vvec *src, vvec *dest)
{
char *newbase;
if(src->base == NULL) {
*dest = *src;
} else {
vvneeds(dest, src->allocated);
newbase = dest->base;
*dest = *src;
dest->base = newbase;
memcpy(dest->base, src->base, dest->allocated * dest->elsize);
}
} | false | true | false | false | false | 1 |
IsEditorBaseOpen(EditorBase* eb)
// ----------------------------------------------------------------------------
{
cbAuiNotebook* m_pNotebook = Manager::Get()->GetEditorManager()->GetNotebook();
for (size_t i = 0; i < m_pNotebook->GetPageCount(); ++i)
{
//wxWindow* winPage = m_pNotebook->GetPage(i);
//#if defined(LOGGING)
//if ( winPage )
// LOGIT( _T("IsEditorBaseOpen[%s]"), ((EditorBase*)winPage)->GetShortName().c_str());
//#endif
if (m_pNotebook->GetPage(i) == eb)
return true;
}
return false;
} | false | false | false | false | false | 0 |
real2complex(int count, Pointer from, Pointer to, int itemsize)
{
int i;
Pointer efrom, eto;
efrom = INC(from, itemsize * (count-1));
eto = INC(to, 2 * itemsize * (count-1));
for (i=count; i>0; i--) {
memset(eto, '\0', itemsize);
eto = DEC(to, itemsize);
memcpy(efrom, eto, itemsize);
efrom = DEC(from, itemsize);
eto = DEC(to, itemsize);
}
return OK;
} | false | true | false | false | false | 1 |
simplify_merge_declarations_of_blocks_in_func(struct stmt *fb)
{
struct stmt *cs;
int retval;
retval = 0;
for (cs = fb->stmt_first; cs; cs = cs->next) {
retval |= simplify_merge_declarations_to_func(fb, cs);
}
return retval;
} | false | false | false | false | false | 0 |
CreateMessageLegacy( void ) const
{
nDescriptor * descriptor = this->DoGetDescriptorLegacy();
if ( descriptor )
{
nMessage* m = tNEW( nMessage )( *descriptor );
this->DoFillToMessageLegacy( *m );
return m;
}
else
{
return 0;
}
} | false | false | false | false | false | 0 |
DruidPassable (float x, float y)
{
finepoint testpos[DIRECTIONS + 1];
int ret = -1;
int i;
/* get 8 Check-Points on the druidsurface */
testpos[OBEN].x = x;
testpos[OBEN].y = y - Droid_Radius;
testpos[RECHTSOBEN].x = x + Droid_Radius;
testpos[RECHTSOBEN].y = y - Droid_Radius;
testpos[RECHTS].x = x + Droid_Radius;
testpos[RECHTS].y = y;
testpos[RECHTSUNTEN].x = x + Droid_Radius;
testpos[RECHTSUNTEN].y = y + Droid_Radius;
testpos[UNTEN].x = x;
testpos[UNTEN].y = y + Droid_Radius;
testpos[LINKSUNTEN].x = x - Droid_Radius;
testpos[LINKSUNTEN].y = y + Droid_Radius;
testpos[LINKS].x = x - Droid_Radius;
testpos[LINKS].y = y;
testpos[LINKSOBEN].x = x - Droid_Radius;
testpos[LINKSOBEN].y = y - Droid_Radius;
for (i = 0; i < DIRECTIONS; i++)
{
ret = IsPassable (testpos[i].x, testpos[i].y, i);
if (ret != CENTER)
break;
} /* for */
return ret;
} | false | false | false | false | false | 0 |
sh_eth_set_ringparam(struct net_device *ndev,
struct ethtool_ringparam *ring)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
int ret;
if (ring->tx_pending > TX_RING_MAX ||
ring->rx_pending > RX_RING_MAX ||
ring->tx_pending < TX_RING_MIN ||
ring->rx_pending < RX_RING_MIN)
return -EINVAL;
if (ring->rx_mini_pending || ring->rx_jumbo_pending)
return -EINVAL;
if (netif_running(ndev)) {
netif_device_detach(ndev);
netif_tx_disable(ndev);
/* Serialise with the interrupt handler and NAPI, then
* disable interrupts. We have to clear the
* irq_enabled flag first to ensure that interrupts
* won't be re-enabled.
*/
mdp->irq_enabled = false;
synchronize_irq(ndev->irq);
napi_synchronize(&mdp->napi);
sh_eth_write(ndev, 0x0000, EESIPR);
sh_eth_dev_exit(ndev);
/* Free all the skbuffs in the Rx queue and the DMA buffers. */
sh_eth_ring_free(ndev);
}
/* Set new parameters */
mdp->num_rx_ring = ring->rx_pending;
mdp->num_tx_ring = ring->tx_pending;
if (netif_running(ndev)) {
ret = sh_eth_ring_init(ndev);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_ring_init failed.\n",
__func__);
return ret;
}
ret = sh_eth_dev_init(ndev, false);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_dev_init failed.\n",
__func__);
return ret;
}
mdp->irq_enabled = true;
sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR);
/* Setting the Rx mode will start the Rx process. */
sh_eth_write(ndev, EDRRR_R, EDRRR);
netif_device_attach(ndev);
}
return 0;
} | false | false | false | false | false | 0 |
register_commands_configure_med(struct cmd_node *configure, struct cmd_node *unconfigure)
{
if (lldpctl_key_get_map(
lldpctl_k_med_policy_type)[0].string == NULL)
return;
struct cmd_node *configure_med = commands_new(
configure,
"med", "MED configuration",
NULL, NULL, NULL);
struct cmd_node *unconfigure_med = commands_new(
unconfigure,
"med", "MED configuration",
NULL, NULL, NULL);
register_commands_medloc(configure_med);
register_commands_medpol(configure_med);
register_commands_medpow(configure_med);
register_commands_medfast(configure_med, unconfigure_med);
} | false | false | false | false | false | 0 |
mkplan(const solver *ego, const problem *p_, planner *plnr)
{
const problem_dft *p;
P *pln;
INT n;
static const plan_adt padt = {
X(dft_solve), awake, print, X(plan_null_destroy)
};
if (!applicable(ego, p_, plnr))
return (plan *)0;
pln = MKPLAN_DFT(P, &padt, apply);
p = (const problem_dft *) p_;
pln->n = n = p->sz->dims[0].n;
pln->is = p->sz->dims[0].is;
pln->os = p->sz->dims[0].os;
pln->td = 0;
pln->super.super.ops.add = (n-1) * 5;
pln->super.super.ops.mul = 0;
pln->super.super.ops.fma = (n-1) * (n-1) ;
#if 0 /* these are nice pipelined sequential loads and should cost nothing */
pln->super.super.ops.other = (n-1)*(4 + 1 + 2 * (n-1)); /* approximate */
#endif
return &(pln->super.super);
} | false | false | false | false | false | 0 |
compute_slopes(GwyDataField *dfield,
gint kernel_size,
GwyDataField *xder,
GwyDataField *yder)
{
gint xres, yres;
gdouble minxd, maxxd, minyd, maxyd;
xres = gwy_data_field_get_xres(dfield);
yres = gwy_data_field_get_yres(dfield);
if (kernel_size) {
GwyPlaneFitQuantity quantites[] = {
GWY_PLANE_FIT_BX, GWY_PLANE_FIT_BY
};
GwyDataField *fields[2];
fields[0] = xder;
fields[1] = yder;
gwy_data_field_fit_local_planes(dfield, kernel_size,
2, quantites, fields);
}
else {
gint col, row;
gdouble *xd, *yd;
const gdouble *data;
gdouble d;
data = gwy_data_field_get_data_const(dfield);
xd = gwy_data_field_get_data(xder);
yd = gwy_data_field_get_data(yder);
for (row = 0; row < yres; row++) {
for (col = 0; col < xres; col++) {
if (!col)
d = data[row*xres + col + 1] - data[row*xres + col];
else if (col == xres-1)
d = data[row*xres + col] - data[row*xres + col - 1];
else
d = (data[row*xres + col + 1]
- data[row*xres + col - 1])/2;
*(xd++) = d;
if (!row)
d = data[row*xres + xres + col] - data[row*xres + col];
else if (row == yres-1)
d = data[row*xres + col] - data[row*xres - xres + col];
else
d = (data[row*xres + xres + col]
- data[row*xres - xres + col])/2;
*(yd++) = d;
}
}
}
gwy_data_field_multiply(xder, xres/gwy_data_field_get_xreal(dfield));
gwy_data_field_get_min_max(xder, &minxd, &maxxd);
maxxd = MAX(fabs(minxd), fabs(maxxd));
gwy_data_field_multiply(yder, yres/gwy_data_field_get_yreal(dfield));
gwy_data_field_get_min_max(yder, &minyd, &maxyd);
maxyd = MAX(fabs(minyd), fabs(maxyd));
return MAX(maxxd, maxyd);
} | false | false | false | false | false | 0 |
MapFirst(const OBMol *queried, Mapping &map, const OBBitVec &mask)
{
class MapFirstFunctor : public Functor
{
private:
Mapping &m_map;
public:
MapFirstFunctor(Mapping &map) : m_map(map)
{
}
bool operator()(Mapping &map)
{
m_map = map;
// stop mapping
return true;
}
};
MapFirstFunctor functor(map);
MapGeneric(functor, queried, mask);
} | false | false | false | false | false | 0 |
kml_wr_init(const char* fname)
{
char u = 's';
waypt_init_bounds(&kml_bounds);
kml_time_min = 0;
kml_time_max = 0;
if (opt_units) {
u = tolower(opt_units[0]);
}
switch (u) {
case 's':
fmt_setunits(units_statute);
break;
case 'm':
fmt_setunits(units_metric);
break;
case 'n':
fmt_setunits(units_nautical);
break;
case 'a':
fmt_setunits(units_aviation);
break;
default:
fatal("Units argument '%s' should be 's' for statute units, 'm' for metric, 'n' for nautical or 'a' for aviation.\n", opt_units);
break;
}
/*
* Reduce race conditions with network read link.
*/
ofd = gbfopen(fname, "w", MYNAME);
} | false | false | false | false | false | 0 |
getCellAtRowColumn(UT_sint32 row, UT_sint32 col) const
{
UT_Point pt;
pt.x = col;
pt.y = row;
if((row >= getNumRows()) || (row <0))
{
return NULL;
}
if((col >= getNumCols()) || (col < 0))
{
return NULL;
}
UT_sint32 u =-1;
u = binarysearchCons(&pt, compareCellPosBinary);
if (u != -1)
{
fp_CellContainer *pSmall = static_cast<fp_CellContainer *>(getNthCon(u));
if((pSmall->getTopAttach() > row) || (pSmall->getBottomAttach() <= row)
|| (pSmall->getLeftAttach() > col) || (pSmall->getRightAttach() <= col))
{
xxx_UT_DEBUGMSG(("No cell found 1 at %d %d \n",row,col));
xxx_UT_DEBUGMSG(("Returned cell left %d right %d top %d bot %d pt.y %d \n",pSmall->getLeftAttach(),pSmall->getRightAttach(),pSmall->getTopAttach(),pSmall->getBottomAttach(),pt.y));
return getCellAtRowColumnLinear(row,col);
}
return pSmall;
}
xxx_UT_DEBUGMSG(("No cell found -2 at %d %d \n",row,col));
return getCellAtRowColumnLinear(row,col);
} | false | false | false | false | false | 0 |
dump()
{
for (unsigned int i=0 ; i<dest.size() ; i++)
{
fputc(dest[i], stdout);
}
} | false | false | false | false | false | 0 |
gth_transform_resize (cairo_matrix_t *matrix,
GthTransformResize resize,
cairo_rectangle_int_t *original,
cairo_rectangle_int_t *boundary)
{
int x1, y1, x2, y2;
x1 = original->x;
y1 = original->y;
x2 = original->x + original->width;
y2 = original->y + original->height;
switch (resize) {
case GTH_TRANSFORM_RESIZE_CLIP:
/* keep the original size */
break;
case GTH_TRANSFORM_RESIZE_BOUNDING_BOX:
case GTH_TRANSFORM_RESIZE_CROP:
{
double dx1, dx2, dx3, dx4;
double dy1, dy2, dy3, dy4;
_cairo_matrix_transform_point (matrix, x1, y1, &dx1, &dy1);
_cairo_matrix_transform_point (matrix, x2, y1, &dx2, &dy2);
_cairo_matrix_transform_point (matrix, x1, y2, &dx3, &dy3);
_cairo_matrix_transform_point (matrix, x2, y2, &dx4, &dy4);
x1 = (int) floor (MIN4 (dx1, dx2, dx3, dx4));
y1 = (int) floor (MIN4 (dy1, dy2, dy3, dy4));
x2 = (int) ceil (MAX4 (dx1, dx2, dx3, dx4));
y2 = (int) ceil (MAX4 (dy1, dy2, dy3, dy4));
break;
}
}
boundary->x = x1;
boundary->y = y1;
boundary->width = x2 - x1;
boundary->height = y2 - y1;
} | false | false | false | false | false | 0 |
ppd_add_size(ppd_file_t *ppd, /* I - PPD file */
const char *name) /* I - Name of size */
{
ppd_size_t *size; /* Size */
if (ppd->num_sizes == 0)
size = malloc(sizeof(ppd_size_t));
else
size = realloc(ppd->sizes, sizeof(ppd_size_t) * (ppd->num_sizes + 1));
if (size == NULL)
return (NULL);
ppd->sizes = size;
size += ppd->num_sizes;
ppd->num_sizes ++;
memset(size, 0, sizeof(ppd_size_t));
strlcpy(size->name, name, sizeof(size->name));
return (size);
} | false | false | false | false | false | 0 |
generateEvalCode(CompileState* comp)
{
// This is basically just a number cast
OpValue curV = expr->generateEvalCode(comp);
if (curV.type != OpType_number) {
OpValue numVal;
CodeGen::emitConvertTo(comp, &curV, OpType_number, &numVal);
curV = numVal;
}
return curV;
} | false | false | false | false | false | 0 |
mar_parse_dqt (PJDEC_INST g)
{
int len, i;
BYTE pt;
long *tbl_p;
len = read_uint(g) - 2;
while (len >= 65) {
len -= 65;
pt = read_byte (g);
if ((pt & 0xfcu) != 0)
longjmp (g->syntax_error, NOT_IMPLEMENTED);
tbl_p = g->quant_tbls[pt & 3];
DUMP (_T("\nDQT marker: table=%d"), pt & 3, 0, 0);
for (i=0; i<64; i++) {
if ((i & 15) == 0) DUMP(_T("\n "), 0,0,0);
tbl_p[i] = read_byte (g);
DUMP (_T("%2d "), tbl_p[i], 0, 0);
}
DUMP (_T("\n"), 0,0,0);
wino_scale_table (tbl_p);
}
if (len != 0)
longjmp (g->syntax_error, BAD_MARKER_DATA);
} | false | false | false | false | false | 0 |
port100_tg_set_rf(struct nfc_digital_dev *ddev, u8 rf)
{
struct port100 *dev = nfc_digital_get_drvdata(ddev);
struct sk_buff *skb;
struct sk_buff *resp;
int rc;
if (rf >= NFC_DIGITAL_RF_TECH_LAST)
return -EINVAL;
skb = port100_alloc_skb(dev, sizeof(struct port100_tg_rf_setting));
if (!skb)
return -ENOMEM;
memcpy(skb_put(skb, sizeof(struct port100_tg_rf_setting)),
&tg_rf_settings[rf],
sizeof(struct port100_tg_rf_setting));
resp = port100_send_cmd_sync(dev, PORT100_CMD_TG_SET_RF, skb);
if (IS_ERR(resp))
return PTR_ERR(resp);
rc = resp->data[0];
dev_kfree_skb(resp);
return rc;
} | false | true | false | false | false | 1 |
checkDatabaseVersion()
{
QSqlDatabase DB = QSqlDatabase::database(Constants::DB_TEMPLATES_NAME);
if (!connectDatabase(DB, __LINE__)) {
return;
}
DB.transaction();
QSqlQuery query(DB);
QString version;
if (query.exec(q->select(Constants::Table_Version, QList<int>() << Constants::VERSION_ACTUAL))) {
if (query.next())
version = query.value(0).toString();
} else {
LOG_QUERY_ERROR_FOR(q, query);
query.finish();
DB.rollback();
return;
}
query.finish();
bool updateVersionNumber = false;
if (version=="0.3.0") {
// Update database schema to 0.4.0
// MySQL server connection starts here, so no update needed for MySQL database
// For SQLite :
// --> USER_UID from int to varchar
// --> Adding GROUP_UID for templates and categories
LOG_FOR(q, "Updating templates database version (0.3.0 to 0.4.0)");
// 1. Rename old tables
QStringList reqs;
reqs
<< "ALTER TABLE `CATEGORIES` RENAME TO `OLD_CATEGORIES`;"
<< "ALTER TABLE `TEMPLATES` RENAME TO `OLD_TEMPLATES`;";
if (!q->executeSQL(reqs, DB))
LOG_ERROR_FOR(q, "Unable to recreate template database during update (0.3.0 to 0.4.0)");
// 2. Recreate the db schema
if (!q->createTables())
LOG_ERROR_FOR(q, "Unable to recreate template database during update (0.3.0 to 0.4.0)");
reqs.clear();
reqs << QString("INSERT INTO `CATEGORIES` (%1) SELECT %1 FROM `OLD_CATEGORIES`;")
.arg("`CATEGORY_ID`,"
"`CATEGORY_UUID`,"
"`USER_UUID`,"
"`PARENT_CATEGORY`,"
"`LABEL`,"
"`SUMMARY`,"
"`MIMETYPES`,"
"`DATE_CREATION`,"
"`DATE_MODIFICATION`,"
"`THEMED_ICON_FILENAME`,"
"`TRANSMISSION_DATE`")
<< "DROP TABLE `OLD_CATEGORIES`;"
<< QString("INSERT INTO `TEMPLATES` (%1) SELECT %1 FROM `OLD_TEMPLATES`;")
.arg("`TEMPLATE_ID`,"
"`TEMPLATE_UUID`,"
"`USER_UUID`,"
"`ID_CATEGORY`,"
"`LABEL`,"
"`SUMMARY`,"
"`CONTENT`,"
"`CONTENT_MIMETYPES`,"
"`DATE_CREATION`,"
"`DATE_MODIFICATION`,"
"`THEMED_ICON_FILENAME`,"
"`TRANSMISSION_DATE`")
<< "DROP TABLE `OLD_TEMPLATES`;";
// Reinsert data to new tables
if (!q->executeSQL(reqs, DB))
LOG_ERROR_FOR(q, "Unable to recreate template database during update (0.3.0 to 0.4.0)");
// Refresh db version
version = "0.4.0";
updateVersionNumber = true;
}
if (updateVersionNumber) {
query.prepare(q->prepareUpdateQuery(Constants::Table_Version, Constants::VERSION_ACTUAL));
query.bindValue(0, Constants::DB_ACTUAL_VERSION);
if (!query.exec()) {
LOG_QUERY_ERROR_FOR(q, query);
query.finish();
DB.rollback();
return;
}
query.finish();
}
query.finish();
DB.commit();
} | false | false | false | false | false | 0 |
acpi_thermal_register_thermal_zone(struct acpi_thermal *tz)
{
int trips = 0;
int result;
acpi_status status;
int i;
if (tz->trips.critical.flags.valid)
trips++;
if (tz->trips.hot.flags.valid)
trips++;
if (tz->trips.passive.flags.valid)
trips++;
for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE &&
tz->trips.active[i].flags.valid; i++, trips++);
if (tz->trips.passive.flags.valid)
tz->thermal_zone =
thermal_zone_device_register("acpitz", trips, 0, tz,
&acpi_thermal_zone_ops, NULL,
tz->trips.passive.tsp*100,
tz->polling_frequency*100);
else
tz->thermal_zone =
thermal_zone_device_register("acpitz", trips, 0, tz,
&acpi_thermal_zone_ops, NULL,
0, tz->polling_frequency*100);
if (IS_ERR(tz->thermal_zone))
return -ENODEV;
result = sysfs_create_link(&tz->device->dev.kobj,
&tz->thermal_zone->device.kobj, "thermal_zone");
if (result)
return result;
result = sysfs_create_link(&tz->thermal_zone->device.kobj,
&tz->device->dev.kobj, "device");
if (result)
return result;
status = acpi_bus_attach_private_data(tz->device->handle,
tz->thermal_zone);
if (ACPI_FAILURE(status))
return -ENODEV;
tz->tz_enabled = 1;
dev_info(&tz->device->dev, "registered as thermal_zone%d\n",
tz->thermal_zone->id);
return 0;
} | false | false | false | false | false | 0 |
jws_verify_init(jws_t* obj, const char* compact, size_t compactlen)
{
char* ptr;
size_t len;
memset(obj, 0, sizeof(jws_t));
obj->mode = JWS_MODE_VERIFY;
// set up pointer and sizes to the parts
obj->compact = compact;
obj->compactlen = compactlen;
ptr = memchr(compact, '.', compactlen);
if (ptr == NULL) {
return 0;
}
obj->header64 = compact;
obj->header64len = ptr - compact;
obj->body64 = ptr + 1;
ptr = memchr(obj->body64, '.', compactlen - obj->header64len);
if (ptr == NULL) {
return 0;
}
obj->body64len = ptr - obj->body64;
obj->sig64 = ptr + 1;
ptr = memchr(obj->sig64, '.',
compactlen - (obj->sig64 - compact));
if (ptr != NULL) {
// there should be no more '.'
return 0;
}
obj->sig64len = compactlen - (obj->sig64 - compact);
// ok, now we have the 3 parts.
// base64url decode the header, and put into jsonkv
// base64url decode the signature, and store raw bytes
// after that, it's up to the caller to process and.or
// decode the body.
obj->headerstr = malloc(b64url_decode_len(obj->header64len));
if (obj->headerstr == NULL) {
return 0;
}
len = b64url_decode(obj->headerstr, obj->header64, obj->header64len);
if (len == (size_t)-1) {
return 0;
}
obj->headerstr_len = len;
if (0 == jsonkv_init(&obj->header, obj->headerstr, obj->headerstr_len)) {
return 0;
}
obj->body = malloc(b64url_decode_len(obj->body64len));
if (obj->body == NULL) {
return 0;
}
len = b64url_decode(obj->body, obj->body64, obj->body64len);
if (len == (size_t)-1) {
return 0;
}
obj->bodylen = len;
obj->sig = malloc(b64url_decode_len(obj->sig64len));
if (obj->sig == NULL) {
return 0;
}
len = b64url_decode(obj->sig, obj->sig64, obj->sig64len);
if (len == (size_t)-1) {
return 0;
}
obj->siglen = len;
return 1;
} | false | false | false | false | false | 0 |
tds_process_cancel(TDSSOCKET * tds)
{
CHECK_TDS_EXTRA(tds);
/* silly cases, nothing to do */
if (!tds->in_cancel)
return TDS_SUCCEED;
/* TODO handle cancellation sending data */
if (tds->state != TDS_PENDING)
return TDS_SUCCEED;
/* TODO support TDS5 cancel, wait for cancel packet first, then wait for done */
for (;;) {
TDS_INT result_type;
switch (tds_process_tokens(tds, &result_type, NULL, 0)) {
case TDS_FAIL:
return TDS_FAIL;
case TDS_CANCELLED:
case TDS_SUCCEED:
case TDS_NO_MORE_RESULTS:
return TDS_SUCCEED;
}
}
} | false | false | false | false | false | 0 |
emit_text(const char *buf, int size)
{
struct token *tok;
int i;
for (i = 0; i < size; i++) {
int c = buf[i];
if (c == '@' || c == '`' || c == '*' || c == '\n' || c == '\\' || c == '\t')
break;
}
tok = new_token(TOK_TEXT);
tok->text = buf;
tok->len = i;
emit_token(tok);
return i;
} | false | false | false | false | false | 0 |
_gcry_mpi_mod_barrett (gcry_mpi_t r, gcry_mpi_t x, mpi_barrett_t ctx)
{
gcry_mpi_t m = ctx->m;
int k = ctx->k;
gcry_mpi_t y = ctx->y;
gcry_mpi_t r1 = ctx->r1;
gcry_mpi_t r2 = ctx->r2;
mpi_normalize (x);
if (mpi_get_nlimbs (x) > 2*k )
{
mpi_mod (r, x, m);
return;
}
/* 1. q1 = floor( x / b^k-1)
* q2 = q1 * y
* q3 = floor( q2 / b^k+1 )
* Actually, we don't need qx, we can work direct on r2
*/
mpi_set ( r2, x );
mpi_rshift_limbs ( r2, k-1 );
mpi_mul ( r2, r2, y );
mpi_rshift_limbs ( r2, k+1 );
/* 2. r1 = x mod b^k+1
* r2 = q3 * m mod b^k+1
* r = r1 - r2
* 3. if r < 0 then r = r + b^k+1
*/
mpi_set ( r1, x );
if ( r1->nlimbs > k+1 ) /* Quick modulo operation. */
r1->nlimbs = k+1;
mpi_mul ( r2, r2, m );
if ( r2->nlimbs > k+1 ) /* Quick modulo operation. */
r2->nlimbs = k+1;
mpi_sub ( r, r1, r2 );
if ( mpi_is_neg( r ) )
{
if (!ctx->r3)
{
ctx->r3 = mpi_alloc ( k + 2 );
mpi_set_ui (ctx->r3, 1);
mpi_lshift_limbs (ctx->r3, k + 1 );
}
mpi_add ( r, r, ctx->r3 );
}
/* 4. while r >= m do r = r - m */
while ( mpi_cmp( r, m ) >= 0 )
mpi_sub ( r, r, m );
} | false | false | false | false | false | 0 |
snd_pcm_hooks_hw_params(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)
{
snd_pcm_hooks_t *h = pcm->private_data;
struct list_head *pos, *next;
int err = snd_pcm_generic_hw_params(pcm, params);
if (err < 0)
return err;
list_for_each_safe(pos, next, &h->hooks[SND_PCM_HOOK_TYPE_HW_PARAMS]) {
snd_pcm_hook_t *hook = list_entry(pos, snd_pcm_hook_t, list);
err = hook->func(hook);
if (err < 0)
return err;
}
return 0;
} | false | false | false | false | false | 0 |
rt2400pci_set_state(struct rt2x00_dev *rt2x00dev,
enum dev_state state)
{
u32 reg, reg2;
unsigned int i;
char put_to_sleep;
char bbp_state;
char rf_state;
put_to_sleep = (state != STATE_AWAKE);
rt2x00mmio_register_read(rt2x00dev, PWRCSR1, ®);
rt2x00_set_field32(®, PWRCSR1_SET_STATE, 1);
rt2x00_set_field32(®, PWRCSR1_BBP_DESIRE_STATE, state);
rt2x00_set_field32(®, PWRCSR1_RF_DESIRE_STATE, state);
rt2x00_set_field32(®, PWRCSR1_PUT_TO_SLEEP, put_to_sleep);
rt2x00mmio_register_write(rt2x00dev, PWRCSR1, reg);
/*
* Device is not guaranteed to be in the requested state yet.
* We must wait until the register indicates that the
* device has entered the correct state.
*/
for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
rt2x00mmio_register_read(rt2x00dev, PWRCSR1, ®2);
bbp_state = rt2x00_get_field32(reg2, PWRCSR1_BBP_CURR_STATE);
rf_state = rt2x00_get_field32(reg2, PWRCSR1_RF_CURR_STATE);
if (bbp_state == state && rf_state == state)
return 0;
rt2x00mmio_register_write(rt2x00dev, PWRCSR1, reg);
msleep(10);
}
return -EBUSY;
} | false | false | false | false | false | 0 |
unpack(const struct optstruct *opts)
{
char name[512], *dbdir;
const char *localdbdir = NULL;
if(optget(opts, "datadir")->active)
localdbdir = optget(opts, "datadir")->strarg;
if(optget(opts, "unpack-current")->enabled) {
dbdir = freshdbdir();
snprintf(name, sizeof(name), "%s"PATHSEP"%s.cvd", localdbdir ? localdbdir : dbdir, optget(opts, "unpack-current")->strarg);
if(access(name, R_OK)) {
snprintf(name, sizeof(name), "%s"PATHSEP"%s.cld", localdbdir ? localdbdir : dbdir, optget(opts, "unpack-current")->strarg);
if(access(name, R_OK)) {
mprintf("!unpack: Couldn't find %s CLD/CVD database in %s\n", optget(opts, "unpack-current")->strarg, localdbdir ? localdbdir : dbdir);
free(dbdir);
return -1;
}
}
free(dbdir);
} else {
strncpy(name, optget(opts, "unpack")->strarg, sizeof(name));
name[sizeof(name)-1]='\0';
}
if(cli_cvdunpack(name, ".") == -1) {
mprintf("!unpack: Can't unpack file %s\n", name);
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
team_nl_team_get(struct genl_info *info)
{
struct net *net = genl_info_net(info);
int ifindex;
struct net_device *dev;
struct team *team;
if (!info->attrs[TEAM_ATTR_TEAM_IFINDEX])
return NULL;
ifindex = nla_get_u32(info->attrs[TEAM_ATTR_TEAM_IFINDEX]);
dev = dev_get_by_index(net, ifindex);
if (!dev || dev->netdev_ops != &team_netdev_ops) {
if (dev)
dev_put(dev);
return NULL;
}
team = netdev_priv(dev);
mutex_lock(&team->lock);
return team;
} | false | false | false | false | false | 0 |
max_version (
char * pathname)
{
char * p;
char * filename;
int pathlen = strlen (pathname);
int version;
p = pathname + pathlen - 1;
while ((p > pathname) && (*p != '/'))
{
p--;
}
if (*p == '/')
{
int dirlen = p - pathname;
char *dirname;
filename = p + 1;
dirname = xmalloc (dirlen + 1);
strncpy (dirname, pathname, (dirlen));
dirname[dirlen] = '\0';
version = highest_version (filename, dirname);
free (dirname);
}
else
{
filename = pathname;
version = highest_version (filename, ".");
}
return version;
} | false | true | false | false | true | 1 |
set_previous_curve_callback(GtkObject *button, gpointer xopt)
{
option_t *opt = (option_t *)xopt;
GtkWidget *gcurve =
GTK_WIDGET(STPUI_GAMMA_CURVE(opt->info.curve.gamma_curve)->curve);
const stp_curve_t *seed = opt->info.curve.current;
if (!seed)
seed = opt->info.curve.deflt;
set_stpui_curve_values(gcurve, seed);
set_stp_curve_values(gcurve, opt);
invalidate_preview_thumbnail();
update_adjusted_thumbnail(TRUE);
return 1;
} | false | false | false | false | false | 0 |
SOCKET_update_timeout(CSOCKET_COMMON *socket)
{
struct timeval timeout;
if (socket->socket < 0)
return TRUE;
timeout.tv_sec = socket->timeout / 1000;
timeout.tv_usec = (socket->timeout % 1000) * 1000;
if (setsockopt(socket->socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0)
{
GB.Error("Cannot set sending timeout");
return TRUE;
}
if (setsockopt(socket->socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0)
{
GB.Error("Cannot set receiving timeout");
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
QTNEq(QTNode *a, QTNode *b)
{
uint32 sign = a->sign & b->sign;
if (!(sign == a->sign && sign == b->sign))
return 0;
return (QTNodeCompare(a, b) == 0) ? true : false;
} | false | false | false | false | false | 0 |
mpir_set_executable_names(const char *executable_name)
{
#if defined HAVE_BG_FILES && !defined HAVE_BG_L_P
/* Use symbols from the runjob.so library provided by IBM.
* Do NOT use debugger symbols local to the srun command */
#else
int i;
for (i = 0; i < MPIR_proctable_size; i++) {
MPIR_proctable[i].executable_name = xstrdup(executable_name);
if (MPIR_proctable[i].executable_name == NULL) {
error("Unable to set MPI_proctable executable_name:"
" %m");
exit(error_exit);
}
}
#endif
} | false | false | false | false | false | 0 |
GetValues( double &x, double &y )
{
if( xTC_->GetValue().empty() )
{
wxMessageDialog *md = new wxMessageDialog( this, wxT("Please enter an x-coordinate value"),
wxT("Error"), wxOK|wxICON_INFORMATION );
md->ShowModal();
return false;
}
if( yTC_->GetValue().empty() )
{
wxMessageDialog *md = new wxMessageDialog( this, wxT("Please enter an y-coordinate value"),
wxT("Error"), wxOK|wxICON_INFORMATION );
md->ShowModal();
return false;
}
if( !xTC_->GetValue().ToDouble(&x) )
{
wxMessageDialog *md = new wxMessageDialog( this, wxT("invalid number entered as x-coordinate"),
wxT("Error"), wxOK|wxICON_INFORMATION );
md->ShowModal();
return false;
}
if( !yTC_->GetValue().ToDouble(&y) )
{
wxMessageDialog *md = new wxMessageDialog( this, wxT("invalid number entered as y-coordinate"),
wxT("Error"), wxOK|wxICON_INFORMATION );
md->ShowModal();
return false;
}
return true;
} | false | false | false | false | false | 0 |
destroyAllTextureTargets()
{
while (!d_pimpl->d_textureTargets.empty())
destroyTextureTarget(*d_pimpl->d_textureTargets.begin());
} | false | false | false | false | false | 0 |
adjuststack (LexState *ls, int n) {
if (n > 0)
code_oparg(ls, POP, 2, n-1, -n);
else if (n < 0)
code_oparg(ls, PUSHNIL, 1, (-n)-1, -n);
} | false | false | false | false | false | 0 |
l1_info4_ind(struct FsmInst *fi, int event, void *arg)
{
struct layer1 *l1 = fi->userdata;
mISDN_FsmChangeState(fi, ST_L1_F7);
l1->dcb(l1->dch, INFO3_P8);
if (test_and_clear_bit(FLG_L1_DEACTTIMER, &l1->Flags))
mISDN_FsmDelTimer(&l1->timerX, 4);
if (!test_bit(FLG_L1_ACTIVATED, &l1->Flags)) {
if (test_and_clear_bit(FLG_L1_T3RUN, &l1->Flags))
mISDN_FsmDelTimer(&l1->timer3, 3);
mISDN_FsmRestartTimer(&l1->timerX, 110, EV_TIMER_ACT, NULL, 2);
test_and_set_bit(FLG_L1_ACTTIMER, &l1->Flags);
}
} | false | false | false | false | false | 0 |
spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
{
int retval;
retval = spi_init_eeprom(chip);
if (retval != STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
retval = spi_eeprom_program_enable(chip);
if (retval != STATUS_SUCCESS) {
rtsx_trace(chip);
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_GPIO_DIR, 0x01, 0);
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_DATA_SOURCE, 0x01, RING_BUFFER);
rtsx_add_cmd(chip, WRITE_REG_CMD, SPI_COMMAND, 0xFF, 0x07);
rtsx_add_cmd(chip, WRITE_REG_CMD, SPI_ADDR0, 0xFF, (u8)addr);
rtsx_add_cmd(chip, WRITE_REG_CMD, SPI_ADDR1, 0xFF, (u8)(addr >> 8));
rtsx_add_cmd(chip, WRITE_REG_CMD, SPI_CA_NUMBER, 0xFF, 0x46);
rtsx_add_cmd(chip, WRITE_REG_CMD, SPI_TRANSFER0, 0xFF,
SPI_TRANSFER0_START | SPI_CA_MODE0);
rtsx_add_cmd(chip, CHECK_REG_CMD, SPI_TRANSFER0, SPI_TRANSFER0_END,
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
rtsx_trace(chip);
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
rtsx_trace(chip);
return retval;
}
return STATUS_SUCCESS;
} | false | false | false | false | false | 0 |
vn_reference_lookup_pieces (tree vuse, alias_set_type set, tree type,
VEC (vn_reference_op_s, heap) *operands,
vn_reference_t *vnresult, vn_lookup_kind kind)
{
struct vn_reference_s vr1;
vn_reference_t tmp;
tree cst;
if (!vnresult)
vnresult = &tmp;
*vnresult = NULL;
vr1.vuse = vuse ? SSA_VAL (vuse) : NULL_TREE;
VEC_truncate (vn_reference_op_s, shared_lookup_references, 0);
VEC_safe_grow (vn_reference_op_s, heap, shared_lookup_references,
VEC_length (vn_reference_op_s, operands));
memcpy (VEC_address (vn_reference_op_s, shared_lookup_references),
VEC_address (vn_reference_op_s, operands),
sizeof (vn_reference_op_s)
* VEC_length (vn_reference_op_s, operands));
vr1.operands = operands = shared_lookup_references
= valueize_refs (shared_lookup_references);
vr1.type = type;
vr1.set = set;
vr1.hashcode = vn_reference_compute_hash (&vr1);
if ((cst = fully_constant_vn_reference_p (&vr1)))
return cst;
vn_reference_lookup_1 (&vr1, vnresult);
if (!*vnresult
&& kind != VN_NOWALK
&& vr1.vuse)
{
ao_ref r;
vn_walk_kind = kind;
if (ao_ref_init_from_vn_reference (&r, set, type, vr1.operands))
*vnresult =
(vn_reference_t)walk_non_aliased_vuses (&r, vr1.vuse,
vn_reference_lookup_2,
vn_reference_lookup_3, &vr1);
if (vr1.operands != operands)
VEC_free (vn_reference_op_s, heap, vr1.operands);
}
if (*vnresult)
return (*vnresult)->result;
return NULL_TREE;
} | false | true | false | false | false | 1 |
print_oid_report(FILE * fp)
{
struct tree *tp;
clear_tree_flags(tree_head);
for (tp = tree_head; tp; tp = tp->next_peer)
print_subtree_oid_report(fp, tp, 0);
} | false | false | false | false | false | 0 |
big5_mbc_enc_len0(const UChar* p, const UChar* e, int tridx, const int tbl[])
{
int firstbyte = *p++;
state_t s = trans[tridx][firstbyte];
#define RETURN(n) \
return s == ACCEPT ? ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND(n) : \
ONIGENC_CONSTRUCT_MBCLEN_INVALID()
if (s < 0) RETURN(1);
if (p == e) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(tbl[firstbyte]-1);
s = trans[s][*p++];
RETURN(2);
#undef RETURN
} | false | false | false | false | false | 0 |
tds_bcp_start(TDSSOCKET *tds, TDSBCPINFO *bcpinfo)
{
tdsdump_log(TDS_DBG_FUNC, "tds_bcp_start(%p, %p)\n", tds, bcpinfo);
tds_submit_query(tds, bcpinfo->insert_stmt);
/*
* In TDS 5 we get the column information as a result set from the "insert bulk" command.
* We're going to ignore it.
*/
if (tds_process_simple_query(tds) != TDS_SUCCEED)
return TDS_FAIL;
/* TODO problem with thread safety */
tds->out_flag = TDS_BULK;
tds_set_state(tds, TDS_QUERYING);
if (IS_TDS7_PLUS(tds))
tds7_bcp_send_colmetadata(tds, bcpinfo);
return TDS_SUCCEED;
} | false | false | false | false | false | 0 |
gretl_strdup (const char *src)
{
char *targ = NULL;
if (src != NULL) {
size_t n = strlen(src) + 1;
targ = malloc(n);
if (targ != NULL) {
memcpy(targ, src, n);
}
}
return targ;
} | false | false | false | false | false | 0 |
ocb_done_encrypt(ocb_state *ocb, const unsigned char *pt, unsigned long ptlen,
unsigned char *ct, unsigned char *tag, unsigned long *taglen)
{
LTC_ARGCHK(ocb != NULL);
LTC_ARGCHK(pt != NULL);
LTC_ARGCHK(ct != NULL);
LTC_ARGCHK(tag != NULL);
LTC_ARGCHK(taglen != NULL);
return s_ocb_done(ocb, pt, ptlen, ct, tag, taglen, 0);
} | false | false | false | false | false | 0 |
__ecereMethod_Documentor_Cycle(struct __ecereNameSpace__ecere__com__Instance * this, unsigned int idle)
{
if(quit)
__ecereMethod___ecereNameSpace__ecere__gui__Window_Destroy(mainForm, 0);
return 0x1;
} | false | false | false | false | false | 0 |
createTypeDIE(const DICompositeType *Ty) {
auto *Context = resolve(Ty->getScope());
DIE *ContextDIE = getOrCreateContextDIE(Context);
if (DIE *TyDIE = getDIE(Ty))
return TyDIE;
// Create new type.
DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);
constructTypeDIE(TyDIE, cast<DICompositeType>(Ty));
if (!Ty->isExternalTypeRef())
updateAcceleratorTables(Context, Ty, TyDIE);
return &TyDIE;
} | false | false | false | false | false | 0 |
xmt_parse_mf_field(GF_XMTParser *parser, GF_FieldInfo *info, GF_Node *n, char *value)
{
u32 res;
GF_FieldInfo sfInfo;
sfInfo.fieldType = gf_sg_vrml_get_sf_type(info->fieldType);
sfInfo.name = info->name;
gf_sg_vrml_mf_reset(info->far_ptr, info->fieldType);
if (!value || !strlen(value)) return;
while (value[0] && !parser->last_error) {
while (value[0] && value[0] == ' ') value++;
if (!value[0]) break;
gf_sg_vrml_mf_append(info->far_ptr, info->fieldType, &sfInfo.far_ptr);
/*special case for MF type based on string (MFString, MFURL and MFScript), we need to take care
of all possible forms of XML multi string encoding*/
if (sfInfo.fieldType == GF_SG_VRML_SFSTRING) {
res = xmt_parse_string(parser, info->name, (SFString*)sfInfo.far_ptr, 1, value);
} else if (sfInfo.fieldType == GF_SG_VRML_SFURL) {
res = xmt_parse_url(parser, info->name, (MFURL *)info->far_ptr, n, 1, value);
} else if (sfInfo.fieldType == GF_SG_VRML_SFSCRIPT) {
res = xmt_parse_script(parser, info->name, (SFScript*)sfInfo.far_ptr, 1, value);
} else {
res = xmt_parse_sf_field(parser, &sfInfo, n, value);
}
if (res) {
value += res;
} else {
break;
}
}
} | false | false | false | false | false | 0 |
Initialize(vtkShaderProgram2* pgm,
vtkShader2Type mode)
{
if (this->Shader != pgm)
{
this->SetShader(pgm);
if (pgm)
{
vtkShader2 *s=vtkShader2::New();
s->SetSourceCode(vtkLightingHelper_s);
s->SetType(mode);
s->SetContext(this->Shader->GetContext());
this->Shader->GetShaders()->AddItem(s);
s->Delete();
}
}
} | false | false | false | false | false | 0 |
setTCPNoDelay(PRFileDesc* fd)
{
PRStatus status = PR_SUCCESS;
PRSocketOptionData opt;
opt.option = PR_SockOpt_NoDelay;
opt.value.no_delay = PR_FALSE;
status = PR_GetSocketOption(fd, &opt);
if (status == PR_FAILURE) {
return;
}
opt.option = PR_SockOpt_NoDelay;
opt.value.no_delay = PR_TRUE;
status = PR_SetSocketOption(fd, &opt);
if (status == PR_FAILURE) {
return;
}
return;
} | false | true | false | false | false | 1 |
poly_float(t_poly *x, t_float f)
{
int i;
t_voice *v;
t_voice *firston, *firstoff;
unsigned int serialon, serialoff, onindex = 0, offindex = 0;
if (x->x_vel > 0)
{
/* note on. Look for a vacant voice */
for (v = x->x_vec, i = 0, firston = firstoff = 0,
serialon = serialoff = 0xffffffff; i < x->x_n; v++, i++)
{
if (v->v_used && v->v_serial < serialon)
firston = v, serialon = v->v_serial, onindex = i;
else if (!v->v_used && v->v_serial < serialoff)
firstoff = v, serialoff = v->v_serial, offindex = i;
}
if (firstoff)
{
outlet_float(x->x_velout, x->x_vel);
outlet_float(x->x_pitchout, firstoff->v_pitch = f);
outlet_float(x->x_obj.ob_outlet, offindex+1);
firstoff->v_used = 1;
firstoff->v_serial = x->x_serial++;
}
/* if none, steal one */
else if (firston && x->x_steal)
{
outlet_float(x->x_velout, 0);
outlet_float(x->x_pitchout, firston->v_pitch);
outlet_float(x->x_obj.ob_outlet, onindex+1);
outlet_float(x->x_velout, x->x_vel);
outlet_float(x->x_pitchout, firston->v_pitch = f);
outlet_float(x->x_obj.ob_outlet, onindex+1);
firston->v_serial = x->x_serial++;
}
}
else /* note off. Turn off oldest match */
{
for (v = x->x_vec, i = 0, firston = 0, serialon = 0xffffffff;
i < x->x_n; v++, i++)
if (v->v_used && v->v_pitch == f && v->v_serial < serialon)
firston = v, serialon = v->v_serial, onindex = i;
if (firston)
{
firston->v_used = 0;
firston->v_serial = x->x_serial++;
outlet_float(x->x_velout, 0);
outlet_float(x->x_pitchout, firston->v_pitch);
outlet_float(x->x_obj.ob_outlet, onindex+1);
}
}
} | false | false | false | false | false | 0 |
H5B2_neighbor_internal(H5B2_hdr_t *hdr, hid_t dxpl_id, unsigned depth,
H5B2_node_ptr_t *curr_node_ptr, void *neighbor_loc, H5B2_compare_t comp,
void *udata, H5B2_found_t op, void *op_data)
{
H5B2_internal_t *internal; /* Pointer to internal node */
unsigned idx; /* Location of record which matches key */
int cmp = 0; /* Comparison value of records */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Check arguments. */
HDassert(hdr);
HDassert(depth > 0);
HDassert(curr_node_ptr);
HDassert(H5F_addr_defined(curr_node_ptr->addr));
HDassert(op);
/* Lock current B-tree node */
if(NULL == (internal = H5B2_protect_internal(hdr, dxpl_id, curr_node_ptr->addr, curr_node_ptr->node_nrec, depth, H5AC_READ)))
HGOTO_ERROR(H5E_BTREE, H5E_CANTPROTECT, FAIL, "unable to protect B-tree internal node")
/* Locate node pointer for child */
if(H5B2_locate_record(hdr->cls, internal->nrec, hdr->nat_off, internal->int_native,
udata, &idx, &cmp) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records")
if(cmp > 0)
idx++;
/* Set the neighbor location, if appropriate */
if(comp == H5B2_COMPARE_LESS) {
if(idx > 0)
neighbor_loc = H5B2_INT_NREC(internal, hdr, idx - 1);
} /* end if */
else {
HDassert(comp == H5B2_COMPARE_GREATER);
if(idx < internal->nrec)
neighbor_loc = H5B2_INT_NREC(internal, hdr, idx);
} /* end else */
/* Attempt to find neighboring record */
if(depth > 1) {
if(H5B2_neighbor_internal(hdr, dxpl_id, depth - 1, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree internal node")
} /* end if */
else {
if(H5B2_neighbor_leaf(hdr, dxpl_id, &internal->node_ptrs[idx], neighbor_loc, comp, udata, op, op_data) < 0)
HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL, "unable to find neighbor record in B-tree leaf node")
} /* end else */
done:
/* Release the B-tree internal node */
if(internal && H5AC_unprotect(hdr->f, dxpl_id, H5AC_BT2_INT, curr_node_ptr->addr, internal, H5AC__NO_FLAGS_SET) < 0)
HDONE_ERROR(H5E_BTREE, H5E_CANTUNPROTECT, FAIL, "unable to release internal B-tree node")
FUNC_LEAVE_NOAPI(ret_value)
} | false | false | false | false | false | 0 |
dcb_settype (DCB_TYPEDEF * d, TYPEDEF * t)
{
int n ;
for (n = 0 ; n < MAX_TYPECHUNKS ; n++)
{
d->BaseType[n] = t->chunk[n].type ;
d->Count [n] = t->chunk[n].count ;
}
if (t->varspace) {
d->Members = dcb_varspace (t->varspace) ;
} else {
d->Members = NO_MEMBERS ;
}
} | false | false | false | false | false | 0 |
__lock_dump_object(lt, mbp, op)
DB_LOCKTAB *lt;
DB_MSGBUF *mbp;
DB_LOCKOBJ *op;
{
struct __db_lock *lp;
SH_TAILQ_FOREACH(lp, &op->holders, links, __db_lock)
__lock_printlock(lt, mbp, lp, 1);
SH_TAILQ_FOREACH(lp, &op->waiters, links, __db_lock)
__lock_printlock(lt, mbp, lp, 1);
return (0);
} | false | false | false | false | false | 0 |
fsl_asrc_dma_pcm_new(struct snd_soc_pcm_runtime *rtd)
{
struct snd_card *card = rtd->card->snd_card;
struct snd_pcm_substream *substream;
struct snd_pcm *pcm = rtd->pcm;
int ret, i;
ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32));
if (ret) {
dev_err(card->dev, "failed to set DMA mask\n");
return ret;
}
for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_LAST; i++) {
substream = pcm->streams[i].substream;
if (!substream)
continue;
ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev,
FSL_ASRC_DMABUF_SIZE, &substream->dma_buffer);
if (ret) {
dev_err(card->dev, "failed to allocate DMA buffer\n");
goto err;
}
}
return 0;
err:
if (--i == 0 && pcm->streams[i].substream)
snd_dma_free_pages(&pcm->streams[i].substream->dma_buffer);
return ret;
} | false | false | false | false | false | 0 |
contains_file(const char * file1, const char * file2) {
int result = 0;
char * ancestor = make_canonical_path(file1);
char * d = make_canonical_path(file2);
char * parent = make_dirname(d);
while (strcmp(d, parent) != 0) {
if (is_same_file(ancestor, parent)) {
result = 1;
break;
}
free(d);
d = parent;
parent = make_dirname(d);
}
free(d);
free(parent);
free(ancestor);
return result;
} | false | false | false | false | false | 0 |
ecryptfs_read_update_atime(struct kiocb *iocb,
struct iov_iter *to)
{
ssize_t rc;
struct path *path;
struct file *file = iocb->ki_filp;
rc = generic_file_read_iter(iocb, to);
if (rc >= 0) {
path = ecryptfs_dentry_to_lower_path(file->f_path.dentry);
touch_atime(path);
}
return rc;
} | false | false | false | false | false | 0 |
tsi721_issue_pending(struct dma_chan *dchan)
{
struct tsi721_bdma_chan *bdma_chan = to_tsi721_chan(dchan);
dev_dbg(dchan->device->dev, "%s: Enter\n", __func__);
if (tsi721_dma_is_idle(bdma_chan) && bdma_chan->active) {
spin_lock_bh(&bdma_chan->lock);
tsi721_advance_work(bdma_chan);
spin_unlock_bh(&bdma_chan->lock);
}
} | false | false | false | false | false | 0 |
enableAccessControls(bool enable) {
d->ownerPermCombo->setEnabled(enable);
d->groupPermCombo->setEnabled(enable);
d->othersPermCombo->setEnabled(enable);
if (d->extraCheckbox)
d->extraCheckbox->setEnabled(enable);
if ( d->cbRecursive )
d->cbRecursive->setEnabled(enable);
} | false | false | false | false | false | 0 |
fmpz_add(fmpz_t coeffs_out, const fmpz_t in1, const fmpz_t in2)
{
fmpz_t coeffs1 = in1;
fmpz_t coeffs2 = in2;
long carry;
unsigned long size1 = ABS(coeffs1[0]);
unsigned long size2 = ABS(coeffs2[0]);
if (size1 < size2)
{
SWAP_PTRS(coeffs1, coeffs2);
size1 = ABS(coeffs1[0]);
size2 = ABS(coeffs2[0]);
}
if (!size1)
{
if (!size2) coeffs_out[0] = 0L;
else
{
if (coeffs_out != coeffs2) F_mpn_copy(coeffs_out, coeffs2, size2+1);
}
} else if (!size2)
{
if (coeffs_out != coeffs1) F_mpn_copy(coeffs_out, coeffs1, size1+1);
} else if ((long) (coeffs1[0] ^ coeffs2[0]) >= 0L)
{
coeffs_out[0] = coeffs1[0];
carry = mpn_add(coeffs_out+1, coeffs1+1, size1, coeffs2+1, size2);
if (carry)
{
coeffs_out[size1+1] = carry;
if ((long) coeffs_out[0] < 0L) coeffs_out[0]--;
else coeffs_out[0]++;
}
} else
{
carry = 0;
if (size1 != size2) carry = 1;
else carry = mpn_cmp(coeffs1+1, coeffs2+1, size1);
if (carry == 0) coeffs_out[0] = 0L;
else if (carry > 0)
{
mpn_sub(coeffs_out+1, coeffs1+1, size1, coeffs2+1, size2);
coeffs_out[0] = coeffs1[0];
NORM(coeffs_out);
}
else
{
mpn_sub_n(coeffs_out+1, coeffs2+1, coeffs1+1, size1);
coeffs_out[0] = -coeffs1[0];
NORM(coeffs_out);
}
}
} | false | false | false | false | false | 0 |
ExecAssignment (
PTreeNode *pt,
ObjStruct *os,
int numInputs,
Pointer *inputs,
Pointer result,
InvalidComponentHandle *invalids,
InvalidComponentHandle outInvalid)
{
if (DefineSymbol(pt->u.s, os, inputs[0], invalids[0]) == ERROR)
return ERROR;
return _dxfComputeCopy(pt,
os,
numInputs,
inputs,
result,
invalids,
outInvalid);
} | false | false | false | false | false | 0 |
power_supply_attr_is_visible(struct kobject *kobj,
struct attribute *attr,
int attrno)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct power_supply *psy = dev_get_drvdata(dev);
umode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
int i;
if (attrno == POWER_SUPPLY_PROP_TYPE)
return mode;
for (i = 0; i < psy->desc->num_properties; i++) {
int property = psy->desc->properties[i];
if (property == attrno) {
if (psy->desc->property_is_writeable &&
psy->desc->property_is_writeable(psy, property) > 0)
mode |= S_IWUSR;
return mode;
}
}
return 0;
} | false | false | false | false | false | 0 |
knh_NameSpace_getcid(CTX ctx, kNameSpace *ns, kbytes_t sname)
{
DBG_ASSERT(IS_NameSpace(ns));
if(knh_bytes_equals(sname, STEXT("Script"))) {
return O_cid(K_GMASCR);
}
L_TAIL:
if(DP(ns)->name2ctDictSetNULL != NULL) {
const knh_ClassTBL_t *ct = (knh_ClassTBL_t*)knh_DictSet_get(ctx, DP(ns)->name2ctDictSetNULL, sname);
if(ct != NULL) return ct->cid;
}
if(ns->parentNULL != NULL) {
ns = ns->parentNULL;
goto L_TAIL;
}
return knh_getcid(ctx, sname);
} | false | false | false | false | false | 0 |
NEGC(UINT32 m, UINT32 n)
{
UINT32 temp;
temp = sh2.r[m];
sh2.r[n] = -temp - (sh2.sr & T);
if (temp || (sh2.sr & T))
sh2.sr |= T;
else
sh2.sr &= ~T;
} | false | false | false | false | false | 0 |
showGLEWebsite() {
QUrl url("http://www.gle-graphics.org/");
QDesktopServices::openUrl(url);
} | false | false | false | false | false | 0 |
xmmsc_result_notifier_set_full (xmmsc_result_t *res, xmmsc_result_notifier_t func,
void *user_data, xmmsc_user_data_free_func_t free_func)
{
xmmsc_result_callback_t *cb;
x_return_if_fail (res);
x_return_if_fail (func);
/* The pending call takes one ref */
xmmsc_result_ref (res);
cb = xmmsc_result_callback_new (func, user_data, free_func);
res->notifiers = x_list_append (res->notifiers, cb);
} | false | false | false | false | false | 0 |
setShellRadii(real *rshell) const
{
static const real facl[] = {
1.0, 1.33, 1.6, 1.83, 2.03, 2.22, 2.39, 2.55, 2.70, 2.84 };
real thlog = std::log(SET_SHELL_RADII_ORBITAL_THR);
int ishela, iprim;
for(ishela=0; ishela <bis.noOfShells; ishela++) {
const ShellSpecStruct& currShell = bis.shellList[ishela];
rshell[ishela] = 0.0;
for(iprim=0; iprim<currShell.noOfContr; iprim++) {
ergo_real absCoeff = std::fabs(currShell.coeffList[iprim]);
if(absCoeff>0) {
real r2 = (std::log(absCoeff)-thlog)/
currShell.exponentList[iprim];
if(rshell[ishela]<r2) rshell[ishela] = r2;
}
}
}
for(ishela=0; ishela <bis.noOfShells; ishela++) {
rshell[ishela] = std::sqrt(rshell[ishela])
*facl[bis.shellList[ishela].shellType];
}
} | false | false | false | false | false | 0 |
toLower(const string& name) {
// Copy string without initial and trailing blanks.
if (name.find_first_not_of(" \n\t\v\b\r\f\a") == string::npos) return "";
int firstChar = name.find_first_not_of(" \n\t\v\b\r\f\a");
int lastChar = name.find_last_not_of(" \n\t\v\b\r\f\a");
string temp = name.substr( firstChar, lastChar + 1 - firstChar);
// Convert to lowercase letter by letter.
for (int i = 0; i < int(temp.length()); ++i) temp[i] = tolower(temp[i]);
return temp;
} | false | false | false | false | false | 0 |
copy_file(int fd, ext2_ino_t newfile)
{
ext2_file_t e2_file;
errcode_t retval;
int got;
unsigned int written;
char buf[8192];
char *ptr;
retval = ext2fs_file_open(current_fs, newfile,
EXT2_FILE_WRITE, &e2_file);
if (retval)
return retval;
while (1) {
got = read(fd, buf, sizeof(buf));
if (got == 0)
break;
if (got < 0) {
retval = errno;
goto fail;
}
ptr = buf;
while (got > 0) {
retval = ext2fs_file_write(e2_file, ptr,
got, &written);
if (retval)
goto fail;
got -= written;
ptr += written;
}
}
retval = ext2fs_file_close(e2_file);
return retval;
fail:
(void) ext2fs_file_close(e2_file);
return retval;
} | 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.