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 |
|---|---|---|---|---|---|---|
low_start_scan (SANE_Int devnum, SANE_Byte * regs)
{
SANE_Status status;
DBG (2, "low_start_scan: start\n");
/* writes registers to scanner */
regs[0x32] = 0x00;
status = low_write_all_regs (devnum, regs);
if (status != SANE_STATUS_GOOD)
return status;
regs[0x32] = 0x40;
status = low_write_all_regs (devnum, regs);
if (status != SANE_STATUS_GOOD)
return status;
/* Stop scanner - clear reg 0xb3: */
/* status = low_stop_mvmt (devnum);
if (status != SANE_STATUS_GOOD)
return status; */
/* then start */
status = rts88xx_commit (devnum, regs[0x2c]);
DBG (2, "low_start_scan: end.\n");
return status;
} | false | false | false | false | false | 0 |
text_entry_callback(GtkWidget *widget, WrCurveDialog *wcd)
{
if(wcd)
{
if(wcd->filename) g_free(wcd->filename);
wcd->filename = g_strdup(gtk_entry_get_text(GTK_ENTRY(widget)));
}
} | false | false | false | false | false | 0 |
classlibLoaderTable(Object *class_loader) {
void *pntr = INST_DATA(class_loader, void*, ldr_classes_offset);
if(isObject(pntr))
return NULL;
return pntr;
} | false | false | false | false | false | 0 |
bfa_fcs_itnim_sm_online(struct bfa_fcs_itnim_s *itnim,
enum bfa_fcs_itnim_event event)
{
struct bfad_s *bfad = (struct bfad_s *)itnim->fcs->bfad;
char lpwwn_buf[BFA_STRING_32];
char rpwwn_buf[BFA_STRING_32];
bfa_trc(itnim->fcs, itnim->rport->pwwn);
bfa_trc(itnim->fcs, event);
switch (event) {
case BFA_FCS_ITNIM_SM_OFFLINE:
bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_hcb_offline);
bfa_fcb_itnim_offline(itnim->itnim_drv);
bfa_itnim_offline(itnim->bfa_itnim);
wwn2str(lpwwn_buf, bfa_fcs_lport_get_pwwn(itnim->rport->port));
wwn2str(rpwwn_buf, itnim->rport->pwwn);
if (bfa_fcs_lport_is_online(itnim->rport->port) == BFA_TRUE) {
BFA_LOG(KERN_ERR, bfad, bfa_log_level,
"Target (WWN = %s) connectivity lost for "
"initiator (WWN = %s)\n", rpwwn_buf, lpwwn_buf);
bfa_fcs_itnim_aen_post(itnim, BFA_ITNIM_AEN_DISCONNECT);
} else {
BFA_LOG(KERN_INFO, bfad, bfa_log_level,
"Target (WWN = %s) offlined by initiator (WWN = %s)\n",
rpwwn_buf, lpwwn_buf);
bfa_fcs_itnim_aen_post(itnim, BFA_ITNIM_AEN_OFFLINE);
}
break;
case BFA_FCS_ITNIM_SM_DELETE:
bfa_sm_set_state(itnim, bfa_fcs_itnim_sm_offline);
bfa_fcs_itnim_free(itnim);
break;
default:
bfa_sm_fault(itnim->fcs, event);
}
} | true | true | false | false | false | 1 |
folderview_rescan_tree(Folder *folder, gboolean rebuild)
{
GtkWidget *window;
MainWindow *mainwin = mainwindow_get_mainwindow();
FolderView *folderview = NULL;
GtkAdjustment *pos = NULL;
gint height = 0;
cm_return_if_fail(folder != NULL);
if (!folder->klass->scan_tree) return;
if (rebuild &&
alertpanel_full(_("Rebuild folder tree"),
_("Rebuilding the folder tree will remove "
"local caches. Do you want to continue?"),
GTK_STOCK_NO, GTK_STOCK_YES, NULL, FALSE,
NULL, ALERT_WARNING, G_ALERTDEFAULT)
!= G_ALERTALTERNATE) {
return;
}
inc_lock();
if (rebuild)
window = label_window_create(_("Rebuilding folder tree..."));
else
window = label_window_create(_("Scanning folder tree..."));
if (mainwin)
folderview = mainwin->folderview;
if (folderview) {
pos = gtk_scrolled_window_get_vadjustment(
GTK_SCROLLED_WINDOW(folderview->scrolledwin));
height = gtk_adjustment_get_value(pos);
}
folder_set_ui_func(folder, folderview_scan_tree_func, NULL);
folder_scan_tree(folder, rebuild);
folder_set_ui_func(folder, NULL, NULL);
folderview_set_all();
if (folderview) {
pos = gtk_scrolled_window_get_vadjustment(
GTK_SCROLLED_WINDOW(folderview->scrolledwin));
gtk_adjustment_set_value(pos, height);
gtk_adjustment_changed(pos);
}
label_window_destroy(window);
inc_unlock();
} | false | false | false | false | false | 0 |
g_mime_message_set_subject (GMimeMessage *message, const char *subject)
{
char *encoded;
g_return_if_fail (GMIME_IS_MESSAGE (message));
g_return_if_fail (subject != NULL);
g_free (message->subject);
message->subject = g_mime_strdup_trim (subject);
encoded = g_mime_utils_header_encode_text (message->subject);
g_mime_object_set_header (GMIME_OBJECT (message), "Subject", encoded);
g_free (encoded);
if (message->mime_part)
g_mime_header_list_set_stream (message->mime_part->headers, NULL);
} | false | false | false | false | false | 0 |
libera(int m, float ***M)
{
int i;
for (i = 0; i < m; i++) {
free((*M)[i]);
}
free(*M);
} | false | false | false | false | false | 0 |
standard_ExecutorStart(QueryDesc *queryDesc, int eflags, char relOrMat)
{
EState *estate;
MemoryContext oldcontext;
/* sanity checks: queryDesc must not be started already */
Assert(queryDesc != NULL);
Assert(queryDesc->estate == NULL);
/*
* If the transaction is read-only, we need to check if any writes are
* planned to non-temporary tables. EXPLAIN is considered read-only.
*/
if (XactReadOnly && !(eflags & EXEC_FLAG_EXPLAIN_ONLY))
ExecCheckXactReadOnly(queryDesc->plannedstmt);
/*
* Build EState, switch into per-query memory context for startup.
*/
estate = CreateExecutorState();
queryDesc->estate = estate;
oldcontext = MemoryContextSwitchTo(estate->es_query_cxt);
/*
* Fill in external parameters, if any, from queryDesc; and allocate
* workspace for internal parameters
*/
estate->es_param_list_info = queryDesc->params;
if (queryDesc->plannedstmt->nParamExec > 0)
estate->es_param_exec_vals = (ParamExecData *)
palloc0(queryDesc->plannedstmt->nParamExec * sizeof(ParamExecData));
/*
* If non-read-only query, set the command ID to mark output tuples with
*/
switch (queryDesc->operation)
{
case CMD_SELECT:
/*
* SELECT INTO, SELECT FOR UPDATE/SHARE and modifying CTEs need to
* mark tuples
*/
if (queryDesc->plannedstmt->intoClause != NULL ||
queryDesc->plannedstmt->rowMarks != NIL ||
queryDesc->plannedstmt->hasModifyingCTE)
estate->es_output_cid = GetCurrentCommandId(true);
/*
* A SELECT without modifying CTEs can't possibly queue triggers,
* so force skip-triggers mode. This is just a marginal efficiency
* hack, since AfterTriggerBeginQuery/AfterTriggerEndQuery aren't
* all that expensive, but we might as well do it.
*/
if (!queryDesc->plannedstmt->hasModifyingCTE)
eflags |= EXEC_FLAG_SKIP_TRIGGERS;
break;
case CMD_INSERT:
case CMD_DELETE:
case CMD_UPDATE:
estate->es_output_cid = GetCurrentCommandId(true);
break;
default:
elog(ERROR, "unrecognized operation code: %d",
(int) queryDesc->operation);
break;
}
/*
* Copy other important information into the EState
*/
estate->es_snapshot = RegisterSnapshot(queryDesc->snapshot);
estate->es_crosscheck_snapshot = RegisterSnapshot(queryDesc->crosscheck_snapshot);
estate->es_top_eflags = eflags;
estate->es_instrument = queryDesc->instrument_options;
/*
* Initialize the plan state tree
*/
InitPlan(queryDesc, eflags, relOrMat);
/*
* Set up an AFTER-trigger statement context, unless told not to, or
* unless it's EXPLAIN-only mode (when ExecutorFinish won't be called).
*/
if (!(eflags & (EXEC_FLAG_SKIP_TRIGGERS | EXEC_FLAG_EXPLAIN_ONLY)))
AfterTriggerBeginQuery();
MemoryContextSwitchTo(oldcontext);
} | false | false | false | false | false | 0 |
cleanup_pc_files(void)
{
int ret;
int fail_flag;
unsigned int max_id, max_max_id;
#ifdef ENABLE_PLUGINS
GList *plugin_list, *temp_list;
struct plugin_s *plugin;
#endif
int i;
char dbname[][32]={
"DatebookDB",
"AddressDB",
"ToDoDB",
"MemoDB",
""
};
/* Convert to new database names depending on prefs */
rename_dbnames(dbname);
fail_flag = 0;
max_id = max_max_id = 0;
for (i=0; dbname[i][0]; i++) {
jp_logf(JP_LOG_DEBUG, "cleanup_pc_file for %s\n", dbname[i]);
ret = cleanup_pc_file(dbname[i], &max_id);
jp_logf(JP_LOG_DEBUG, "max_id was %d\n", max_id);
if (ret<0) {
fail_flag=1;
} else if (max_id > max_max_id) {
max_max_id = max_id;
}
}
#ifdef ENABLE_PLUGINS
plugin_list = get_plugin_list();
for (temp_list = plugin_list; temp_list; temp_list = temp_list->next) {
plugin = (struct plugin_s *)temp_list->data;
if ((plugin->db_name==NULL) || (plugin->db_name[0]=='\0')) {
jp_logf(JP_LOG_DEBUG, "not calling cleanup_pc_file for: [%s]\n", plugin->db_name);
continue;
}
jp_logf(JP_LOG_DEBUG, "cleanup_pc_file for [%s]\n", plugin->db_name);
ret = cleanup_pc_file(plugin->db_name, &max_id);
jp_logf(JP_LOG_DEBUG, "max_id was %d\n", max_id);
if (ret<0) {
fail_flag=1;
} else if (max_id > max_max_id) {
max_max_id = max_id;
}
}
#endif
if (!fail_flag) {
write_to_next_id(max_max_id);
}
return EXIT_SUCCESS;
} | false | false | false | false | false | 0 |
addchar ( char c )
{
checkcursor();
if ( size + 1 > allocated )
changesize ( size + 1 );
for ( int i = size; i > cursor; i--)
text[i] = text[i-1];
text[cursor] = c;
cursor++;
size++;
if ( reflow() ) {
display();
checkcursorpos();
}
} | false | false | false | false | true | 1 |
SetTries(const int n) {
triesleft = std::max(0, n);
if (triesleft == 0)
location = locations.end();
else if (locations.end() == location)
location = locations.begin();
SetHandle();
} | false | false | false | false | false | 0 |
update_package_if_needed(Node *n, File *f = f_clwrap) {
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "update_package: ENTER... \n");
Printf(stderr, " current_package = '%s'\n", current_package);
Printf(stderr, " node_package = '%s'\n", Getattr(n, "allegrocl:package"));
Printf(stderr, " node(%x) = '%s'\n", n, Getattr(n, "name"));
#endif
String *node_package = Getattr(n, "allegrocl:package");
if (Strcmp(current_package, node_package)) {
String *lispy_package = listify_namespace(node_package);
Delete(current_package);
current_package = Copy(node_package);
Printf(f, "\n(swig-in-package %s)\n", lispy_package);
Delete(lispy_package);
}
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "update_package: EXIT.\n");
#endif
} | false | false | false | false | false | 0 |
Problem_5_test(){
Chapter10 chapter10;
string input[]={"","","abc","","","efg","","hij","lmn","","","","xyz"};
vector<string> strVect(input, input+13);
int result = chapter10.searchStr(strVect, 0, strVect.size(), "");
if(result!=-1)
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "defg");
if(result!=-1)
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "abc");
if(strVect[result]!="abc")
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "efg");
if(strVect[result]!="efg")
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "hij");
if(strVect[result]!="hij")
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "lmn");
if(strVect[result]!="lmn")
return false;
result = chapter10.searchStr(strVect, 0, strVect.size(), "xyz");
if(strVect[result]!="xyz")
return false;
return true;
} | false | false | false | false | false | 0 |
addSequences(SeqArray* seqVector)
{
clearAlignment();
numSeqs = seqVector->size() - 1;
vector<int> emptyVec;
seqArray.push_back(emptyVec); // EMPTY sequence
names.push_back(string(""));
titles.push_back(string(""));
sequenceIds.push_back(0);
cout << "\nThere are " << numSeqs << " in the alignment obj\n";
for(int i = 1; i <= numSeqs; i++)
{
ostringstream name;
seqArray.push_back((*seqVector)[i]);
titles.push_back(string(""));
sequenceIds.push_back(utilityObject->getUniqueSequenceIdentifier());
name << "name" << numSeqs;
names.push_back(name.str());
}
calculateMaxLengths();
seqWeight.resize(numSeqs + 1, 100);
} | false | false | false | false | false | 0 |
mpt3sas_config_get_sas_iounit_pg1(struct MPT3SAS_ADAPTER *ioc,
Mpi2ConfigReply_t *mpi_reply, Mpi2SasIOUnitPage1_t *config_page,
u16 sz)
{
Mpi2ConfigRequest_t mpi_request;
int r;
memset(&mpi_request, 0, sizeof(Mpi2ConfigRequest_t));
mpi_request.Function = MPI2_FUNCTION_CONFIG;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_HEADER;
mpi_request.Header.PageType = MPI2_CONFIG_PAGETYPE_EXTENDED;
mpi_request.ExtPageType = MPI2_CONFIG_EXTPAGETYPE_SAS_IO_UNIT;
mpi_request.Header.PageNumber = 1;
mpi_request.Header.PageVersion = MPI2_SASIOUNITPAGE1_PAGEVERSION;
ioc->build_zero_len_sge_mpi(ioc, &mpi_request.PageBufferSGE);
r = _config_request(ioc, &mpi_request, mpi_reply,
MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, NULL, 0);
if (r)
goto out;
mpi_request.Action = MPI2_CONFIG_ACTION_PAGE_READ_CURRENT;
r = _config_request(ioc, &mpi_request, mpi_reply,
MPT3_CONFIG_PAGE_DEFAULT_TIMEOUT, config_page, sz);
out:
return r;
} | false | false | false | false | false | 0 |
cs_has_ws(const char *cs)
{
int i;
for (i = 0; cs[i] != '\000'; i++)
{
switch (cs[i])
{
case ' ':
case '\r':
case '\n':
case '\t':
case '"':
case '#':
return 1;
}
}
return 0;
} | false | false | false | false | false | 0 |
tds_des_set_odd_parity(des_cblock key)
{
int i;
unsigned char parity;
for (i = 0; i < 8; i++) {
parity = key[i];
parity ^= parity >> 4;
parity ^= parity >> 2;
parity ^= parity >> 1;
key[i] = (key[i] & 0xfe) | (parity & 1);
}
} | true | true | false | false | false | 1 |
il3945_verify_ucode(struct il_priv *il)
{
__le32 *image;
u32 len;
int rc = 0;
/* Try bootstrap */
image = (__le32 *) il->ucode_boot.v_addr;
len = il->ucode_boot.len;
rc = il3945_verify_inst_sparse(il, image, len);
if (rc == 0) {
D_INFO("Bootstrap uCode is good in inst SRAM\n");
return 0;
}
/* Try initialize */
image = (__le32 *) il->ucode_init.v_addr;
len = il->ucode_init.len;
rc = il3945_verify_inst_sparse(il, image, len);
if (rc == 0) {
D_INFO("Initialize uCode is good in inst SRAM\n");
return 0;
}
/* Try runtime/protocol */
image = (__le32 *) il->ucode_code.v_addr;
len = il->ucode_code.len;
rc = il3945_verify_inst_sparse(il, image, len);
if (rc == 0) {
D_INFO("Runtime uCode is good in inst SRAM\n");
return 0;
}
IL_ERR("NO VALID UCODE IMAGE IN INSTRUCTION SRAM!!\n");
/* Since nothing seems to match, show first several data entries in
* instruction SRAM, so maybe visual inspection will give a clue.
* Selection of bootstrap image (vs. other images) is arbitrary. */
image = (__le32 *) il->ucode_boot.v_addr;
len = il->ucode_boot.len;
rc = il3945_verify_inst_full(il, image, len);
return rc;
} | false | false | false | false | false | 0 |
process_ai()
{
//---- think about which technology to research ----//
if( !tech_id )
think_new_research();
//------- recruit workers ---------//
if( info.game_date%15==firm_recno%15 )
{
if( worker_count < MAX_WORKER )
ai_recruit_worker();
}
//----- think about closing down this firm -----//
if( info.game_date%30==firm_recno%30 )
{
if( think_del() )
return;
}
} | false | false | false | false | false | 0 |
pico_get_last_fg_color(void)
{
char *ret = NULL;
if(_last_fg_color){
size_t len;
len = strlen(_last_fg_color);
if((ret = (char *) fs_get((len+1) * sizeof(char))) != NULL){
strncpy(ret, _last_fg_color, len+1);
ret[len] = '\0';
}
}
return(ret);
} | false | true | false | false | false | 1 |
gst_registry_chunks_load_plugin_dep_strv (gchar ** in, gchar * end, guint n)
{
gchar **arr;
if (n == 0)
return NULL;
arr = g_new0 (gchar *, n + 1);
while (n > 0) {
unpack_string (*in, arr[n - 1], end, fail);
--n;
}
return arr;
fail:
GST_INFO ("Reading plugin dependency strings failed");
return NULL;
} | false | false | false | false | false | 0 |
verboselog( int n_level, const char *s_fmt, ... )
{
if( VERBOSE_LEVEL >= n_level )
{
va_list v;
char buf[ 32768 ];
va_start( v, s_fmt );
vsprintf( buf, s_fmt, v );
va_end( v );
logerror( "%08x: %s", activecpu_get_pc(), buf );
}
} | true | true | false | false | true | 1 |
get_file( char *file_name, char **data, long *file_length) {
/* Open input file */
FILE *input = fopen( file_name, "r");
if (!input)
die( 1, "Can't open file \"%s\": %m.", file_name);
/* Get file length */
fseek( input, 0, SEEK_END);
*file_length = ftell( input);
fseek( input, 0, SEEK_SET);
/* Get the buffer */
*data = (char *)malloc( *file_length);
if (!*data)
die( 2, "Out of memoru.");
/* Read the file */
size_t readed = fread( *data, 1, *file_length, input);
if (readed != *file_length)
/* EOF cannot happen */
die( 3, "Error reading file \"%s\": %m.", file_name);
/* Close the file */
if (fclose( input) == EOF)
die( 4, "Can't close file \"%s\": %m.", file_name);
} | false | false | false | false | true | 1 |
option_set_command(int argc, char *argv[])
{
if (argc != 3) {
config_msg = "Wrong number of arguments given to set command";
return ERR;
}
if (strcmp(argv[1], "=")) {
config_msg = "No value assigned";
return ERR;
}
if (!strcmp(argv[0], "show-author")) {
opt_author = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "show-date")) {
opt_date = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "show-rev-graph")) {
opt_rev_graph = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "show-refs")) {
opt_show_refs = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "show-line-numbers")) {
opt_line_number = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "line-graphics")) {
opt_line_graphics = parse_bool(argv[2]);
return OK;
}
if (!strcmp(argv[0], "line-number-interval")) {
opt_num_interval = parse_int(argv[2], opt_num_interval, 1, 1024);
return OK;
}
if (!strcmp(argv[0], "author-width")) {
opt_author_cols = parse_int(argv[2], opt_author_cols, 0, 1024);
return OK;
}
if (!strcmp(argv[0], "tab-size")) {
opt_tab_size = parse_int(argv[2], opt_tab_size, 1, 1024);
return OK;
}
if (!strcmp(argv[0], "commit-encoding")) {
char *arg = argv[2];
int delimiter = *arg;
int i;
switch (delimiter) {
case '"':
case '\'':
for (arg++, i = 0; arg[i]; i++)
if (arg[i] == delimiter) {
arg[i] = 0;
break;
}
default:
string_ncopy(opt_encoding, arg, strlen(arg));
return OK;
}
}
config_msg = "Unknown variable name";
return ERR;
} | false | false | false | false | false | 0 |
get_native_db_data (const char *dbbase, SERIESINFO *sinfo,
double **Z)
{
char numstr[32];
FILE *fp;
dbnumber x;
int v = sinfo->v;
int t, t2, err = 0;
fp = open_binfile(dbbase, GRETL_NATIVE_DB, sinfo->offset, &err);
if (err) {
return err;
}
t2 = (sinfo->t2 > 0)? sinfo->t2 : sinfo->nobs - 1;
for (t=sinfo->t1; t<=t2 && !err; t++) {
if (fread(&x, sizeof x, 1, fp) != 1) {
err = DB_PARSE_ERROR;
} else {
sprintf(numstr, "%.7g", (double) x); /* N.B. converting a float */
Z[v][t] = atof(numstr);
if (Z[v][t] == DBNA) {
Z[v][t] = NADBL;
}
}
}
fclose(fp);
return err;
} | false | false | false | false | true | 1 |
connect(const std::string& addr, unsigned short port)
{
if (_addr != addr || _port != port)
{
_socket.close();
_addr = addr;
_port = port;
}
} | false | false | false | false | false | 0 |
hfi1_read_link_quality(struct hfi1_devdata *dd, u8 *link_quality)
{
u32 frame;
int ret;
*link_quality = 0;
if (dd->pport->host_link_state & HLS_UP) {
ret = read_8051_config(dd, LINK_QUALITY_INFO, GENERAL_CONFIG,
&frame);
if (ret == 0)
*link_quality = (frame >> LINK_QUALITY_SHIFT)
& LINK_QUALITY_MASK;
}
} | false | false | false | false | false | 0 |
globus_l_gfs_ipc_unpack_cred(
globus_i_gfs_ipc_handle_t * ipc,
globus_byte_t * buffer,
globus_size_t len,
gss_cred_id_t * out_cred)
{
OM_uint32 maj_rc;
OM_uint32 min_rc;
OM_uint32 time_rec;
gss_buffer_desc gsi_buffer;
gss_cred_id_t cred;
GlobusGFSName(globus_l_gfs_ipc_unpack_cred);
GlobusGFSDebugEnter();
GFSDecodeUInt32(buffer, len, gsi_buffer.length);
if(gsi_buffer.length > 0)
{
gsi_buffer.value = buffer;
maj_rc = gss_import_cred(
&min_rc, &cred, GSS_C_NO_OID, 0, &gsi_buffer, 0, &time_rec);
if(maj_rc != GSS_S_COMPLETE)
{
goto decode_err;
}
*out_cred = cred;
}
else
{
*out_cred = NULL;
}
GlobusGFSDebugExit();
return 0;
decode_err:
GlobusGFSDebugExitWithError();
return -1;
} | false | false | false | false | false | 0 |
_spellSuggest(AV_View* pAV_View, UT_uint32 ndx)
{
ABIWORD_VIEW;
UT_return_val_if_fail (pView, false);
pView->cmdContextSuggest(ndx);
return true;
} | false | false | false | false | false | 0 |
report_loader_error (MonoAotCompile *acfg, MonoError *error, const char *format, ...)
{
FILE *output;
va_list args;
if (mono_error_ok (error))
return;
if (acfg->logfile)
output = acfg->logfile;
else
output = stderr;
va_start (args, format);
vfprintf (output, format, args);
va_end (args);
mono_error_cleanup (error);
g_error ("FullAOT cannot continue if there are loader errors");
} | false | false | false | false | true | 1 |
mac_bench_one (int algo, struct bench_mac_mode *pmode)
{
struct bench_mac_mode mode = *pmode;
struct bench_obj obj = { 0 };
double result;
mode.algo = algo;
if (mode.name[0] == '\0')
bench_print_algo (-18, gcry_mac_algo_name (algo));
else
bench_print_algo (18, mode.name);
obj.ops = mode.ops;
obj.priv = &mode;
result = do_slope_benchmark (&obj);
bench_print_result (result);
} | false | false | false | false | true | 1 |
GetLevel(int line) const {
if (levels.Length() && (line >= 0) && (line < levels.Length())) {
return levels[line];
} else {
return SC_FOLDLEVELBASE;
}
} | false | false | false | false | false | 0 |
getRecord(const int groupcode,
dimeParam ¶m,
const int index) const
{
switch(groupcode) {
case 10:
case 20:
case 30:
case 11:
case 21:
case 31:
param.double_data = this->coords[groupcode % 10][groupcode / 10 - 1];
return true;
}
return dimeExtrusionEntity::getRecord(groupcode, param, index);
} | false | false | false | false | false | 0 |
gsf_output_gzip_new (GsfOutput *sink, GError **err)
{
GsfOutput *output;
GError const *con_err;
g_return_val_if_fail (GSF_IS_OUTPUT (sink), NULL);
output = g_object_new (GSF_OUTPUT_GZIP_TYPE, "sink", sink, NULL);
con_err = gsf_output_error (output);
if (con_err) {
if (err)
*err = g_error_copy (con_err);
g_object_unref (output);
return NULL;
}
return output;
} | false | false | false | false | false | 0 |
MochaCheckComputeReachableStates( MochaFigure )
mochafig_list *MochaFigure;
{
befig_list *BehFigure;
ctlfig_list *CtlFigure;
btrtransfunc *BtrTransFunc;
bddassoc *BddAssoc;
bddnode *BddNewSet;
bddnode *BddCurrentSet;
bddnode *BddReachedSet;
bddnode *BddNode;
BehFigure = MochaFigure->BEH_FIGURE;
CtlFigure = MochaFigure->CTL_FIGURE;
BtrTransFunc = MochaFigure->BTR_TRANS_FUNC;
BddAssoc = MochaFigure->BDD_ASSOC_REG;
setbddlocalcircuit( MochaFigure->BDD_CIRCUIT );
BddReachedSet = incbddrefext( MochaFigure->BDD_FIRST_STATE );
BddCurrentSet = incbddrefext( MochaFigure->BDD_FIRST_STATE );
do
{
BddCurrentSet = applybddnode( (bddsystem *)0, ABL_AND,
decbddrefext( BddCurrentSet ), MochaFigure->BDD_ASSUME );
BddNewSet = imagebtrtransfunc( BtrTransFunc, BddCurrentSet );
decbddrefext( BddCurrentSet );
BddNode = applybddnodenot( (bddsystem *)0, BddReachedSet );
BddNewSet = applybddnode( (bddsystem *)0, ABL_AND,
decbddrefext( BddNode ), decbddrefext( BddNewSet ) );
BddReachedSet = applybddnode( (bddsystem *)0, ABL_OR,
decbddrefext( BddReachedSet ), BddNewSet );
BddCurrentSet = BddNewSet;
}
while ( BddCurrentSet != BddLocalSystem->ZERO );
MochaFigure->BDD_REACHED_STATE = BddReachedSet;
# ifdef DEBUG
addbddcircuitout( (bddcircuit *)0, "reached", BddReachedSet );
testbddcircuit( (bddcircuit *)0 );
# endif
if ( MochaFigure->FLAG_DEBUG )
{
fprintf( stdout, "First state " );
MochaCheckViewBddNode( MochaFigure->BDD_FIRST_STATE );
fprintf( stdout, "Reachable states " );
MochaCheckViewBddNode( BddReachedSet );
}
} | false | false | false | false | false | 0 |
krb5_get_time_offsets(krb5_context context, krb5_timestamp *seconds, krb5_int32 *microseconds)
{
krb5_os_context os_ctx = &context->os_context;
if (seconds)
*seconds = os_ctx->time_offset;
if (microseconds)
*microseconds = os_ctx->usec_offset;
return 0;
} | false | false | false | false | false | 0 |
bitMap2PlayerName( int p, const GameMap* gamemap ) const
{
ASCString s;
for ( int i = 0; i < gamemap->getPlayerCount(); ++i )
if ( p & ( 1 << i)) {
if ( !s.empty() )
s += ", ";
s += gamemap->getPlayer(i).getName();
}
return s;
} | false | false | false | false | false | 0 |
avi_read_close(AVFormatContext *s)
{
int i;
AVIContext *avi = s->priv_data;
for(i=0;i<s->nb_streams;i++) {
AVStream *st = s->streams[i];
av_free(st->codec->palctrl);
}
if (avi->dv_demux)
av_free(avi->dv_demux);
return 0;
} | false | false | false | false | false | 0 |
is_automorphism(unsigned int* const perm)
{
std::set<unsigned int, std::less<unsigned int> > edges1;
std::set<unsigned int, std::less<unsigned int> > edges2;
#if defined(BLISS_CONSISTENCY_CHECKS)
if(!is_permutation(get_nof_vertices(), perm))
_INTERNAL_ERROR();
#endif
for(unsigned int i = 0; i < get_nof_vertices(); i++)
{
Vertex& v1 = vertices[i];
Vertex& v2 = vertices[perm[i]];
edges1.clear();
for(std::vector<unsigned int>::iterator ei = v1.edges_in.begin();
ei != v1.edges_in.end();
ei++)
edges1.insert(perm[*ei]);
edges2.clear();
for(std::vector<unsigned int>::iterator ei = v2.edges_in.begin();
ei != v2.edges_in.end();
ei++)
edges2.insert(*ei);
if(!(edges1 == edges2))
return false;
edges1.clear();
for(std::vector<unsigned int>::iterator ei = v1.edges_out.begin();
ei != v1.edges_out.end();
ei++)
edges1.insert(perm[*ei]);
edges2.clear();
for(std::vector<unsigned int>::iterator ei = v2.edges_out.begin();
ei != v2.edges_out.end();
ei++)
edges2.insert(*ei);
if(!(edges1 == edges2))
return false;
}
return true;
} | false | false | false | false | false | 0 |
compare_service_types_versioned (const char *searched_service,
const char *current_service)
{
const char *searched_version_ptr, *current_version_ptr;
guint searched_version, current_version, searched_length;
guint current_length;
searched_version_ptr = strrchr (searched_service, ':');
if (searched_version_ptr == NULL)
return FALSE;
current_version_ptr = strrchr (current_service, ':');
if (current_version_ptr == NULL)
return FALSE;
searched_length = (searched_version_ptr - searched_service);
current_length = (current_version_ptr - current_service);
if (searched_length != current_length)
return FALSE;
searched_version = (guint) atol (searched_version_ptr + 1);
if (searched_version == 0)
return FALSE;
current_version = (guint) atol (current_version_ptr + 1);
if (current_version == 0)
return FALSE;
if (current_version < searched_version)
return FALSE;
return strncmp (searched_service,
current_service,
searched_length) == 0;
} | false | false | false | false | false | 0 |
ctf_event_visit(FILE *fd, int depth, struct ctf_node *node,
struct declaration_scope *parent_declaration_scope, struct ctf_trace *trace)
{
int ret = 0;
struct ctf_node *iter;
struct ctf_event_declaration *event;
struct bt_ctf_event_decl *event_decl;
if (node->visited)
return 0;
node->visited = 1;
event_decl = g_new0(struct bt_ctf_event_decl, 1);
event = &event_decl->parent;
event->declaration_scope = bt_new_declaration_scope(parent_declaration_scope);
event->loglevel = -1;
bt_list_for_each_entry(iter, &node->u.event.declaration_list, siblings) {
ret = ctf_event_declaration_visit(fd, depth + 1, iter, event, trace);
if (ret)
goto error;
}
if (!CTF_EVENT_FIELD_IS_SET(event, name)) {
ret = -EPERM;
fprintf(fd, "[error] %s: missing name field in event declaration\n", __func__);
goto error;
}
if (!CTF_EVENT_FIELD_IS_SET(event, stream_id)) {
/* Allow missing stream_id if there is only a single stream */
switch (trace->streams->len) {
case 0: /* Create stream if there was none. */
ret = ctf_stream_visit(fd, depth, NULL, trace->root_declaration_scope, trace);
if (ret)
goto error;
/* Fall-through */
case 1:
event->stream_id = 0;
event->stream = trace_stream_lookup(trace, event->stream_id);
break;
default:
ret = -EPERM;
fprintf(fd, "[error] %s: missing stream_id field in event declaration\n", __func__);
goto error;
}
}
/* Allow only one event without id per stream */
if (!CTF_EVENT_FIELD_IS_SET(event, id)
&& event->stream->events_by_id->len != 0) {
ret = -EPERM;
fprintf(fd, "[error] %s: missing id field in event declaration\n", __func__);
goto error;
}
/* Disallow re-using the same event ID in the same stream */
if (stream_event_lookup(event->stream, event->id)) {
ret = -EPERM;
fprintf(fd, "[error] %s: event ID %" PRIu64 " used more than once in stream %" PRIu64 "\n",
__func__, event->id, event->stream_id);
goto error;
}
if (event->stream->events_by_id->len <= event->id)
g_ptr_array_set_size(event->stream->events_by_id, event->id + 1);
g_ptr_array_index(event->stream->events_by_id, event->id) = event;
g_hash_table_insert(event->stream->event_quark_to_id,
(gpointer) (unsigned long) event->name,
&event->id);
g_ptr_array_add(trace->event_declarations, event_decl);
return 0;
error:
if (event->fields_decl)
bt_declaration_unref(&event->fields_decl->p);
if (event->context_decl)
bt_declaration_unref(&event->context_decl->p);
bt_free_declaration_scope(event->declaration_scope);
g_free(event_decl);
return ret;
} | false | false | false | false | false | 0 |
ims_pcu_resume(struct usb_interface *intf)
{
struct ims_pcu *pcu = usb_get_intfdata(intf);
struct usb_host_interface *alt = intf->cur_altsetting;
int retval = 0;
if (alt->desc.bInterfaceClass == USB_CLASS_COMM) {
retval = ims_pcu_start_io(pcu);
if (retval == 0)
retval = ims_pcu_line_setup(pcu);
}
return retval;
} | false | false | false | false | false | 0 |
_timeout_job(uint32_t jobid, char *comment_ptr,
int *err_code, char **err_msg)
{
int rc = 0;
struct job_record *job_ptr;
/* Write lock on job info */
slurmctld_lock_t job_write_lock = {
NO_LOCK, WRITE_LOCK, NO_LOCK, NO_LOCK };
lock_slurmctld(job_write_lock);
job_ptr = find_job_record(jobid);
if (job_ptr == NULL) {
*err_code = -700;
*err_msg = "No such job";
error("wiki: Failed to find job %u", jobid);
rc = -1;
goto fini;
}
if (comment_ptr) {
char *reserved = strstr(comment_ptr, "RESERVED:");
if (reserved && job_ptr->details) {
reserved += 9;
job_ptr->details->reserved_resources =
strtol(reserved, NULL, 10);
}
xfree(job_ptr->comment);
job_ptr->comment = xstrdup(comment_ptr);
}
job_ptr->end_time = time(NULL);
debug("wiki: set end time for job %u", jobid);
fini: unlock_slurmctld(job_write_lock);
return rc;
} | false | false | false | false | false | 0 |
resize_requested_by_parent( void )
{
// #ifndef NDEBUG
// ED4_base *base = (ED4_base*)this;
// e4_assert(!base->flag.hidden);
// #endif
if (update_info.resize) { // likes to resize?
if (calc_bounding_box()) { // size changed?
parent->resize_requested_by_child(); // tell parent!
}
}
return ED4_R_OK;
} | false | false | false | false | false | 0 |
evrpc_request_done(struct evrpc_req_generic *rpc_state)
{
struct evhttp_request *req = rpc_state->http_req;
struct evrpc *rpc = rpc_state->rpc;
if (rpc->reply_complete(rpc_state->reply) == -1) {
/* the reply was not completely filled in. error out */
goto error;
}
if ((rpc_state->rpc_data = evbuffer_new()) == NULL) {
/* out of memory */
goto error;
}
/* serialize the reply */
rpc->reply_marshal(rpc_state->rpc_data, rpc_state->reply);
if (TAILQ_FIRST(&rpc->base->output_hooks) != NULL) {
int hook_res;
evrpc_hook_associate_meta(&rpc_state->hook_meta, req->evcon);
/* do hook based tweaks to the request */
hook_res = evrpc_process_hooks(&rpc->base->output_hooks,
rpc_state, req, rpc_state->rpc_data);
switch (hook_res) {
case EVRPC_TERMINATE:
goto error;
case EVRPC_PAUSE:
if (evrpc_pause_request(rpc->base, rpc_state,
evrpc_request_done_closure) == -1)
goto error;
return;
case EVRPC_CONTINUE:
break;
default:
EVUTIL_ASSERT(hook_res == EVRPC_TERMINATE ||
hook_res == EVRPC_CONTINUE ||
hook_res == EVRPC_PAUSE);
}
}
evrpc_request_done_closure(rpc_state, EVRPC_CONTINUE);
return;
error:
if (rpc_state != NULL)
evrpc_reqstate_free(rpc_state);
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
return;
} | false | false | false | false | false | 0 |
vmw_pm_freeze(struct device *kdev)
{
struct pci_dev *pdev = to_pci_dev(kdev);
struct drm_device *dev = pci_get_drvdata(pdev);
struct vmw_private *dev_priv = vmw_priv(dev);
dev_priv->suspended = true;
if (dev_priv->enable_fb)
vmw_fifo_resource_dec(dev_priv);
if (atomic_read(&dev_priv->num_fifo_resources) != 0) {
DRM_ERROR("Can't hibernate while 3D resources are active.\n");
if (dev_priv->enable_fb)
vmw_fifo_resource_inc(dev_priv);
WARN_ON(vmw_request_device_late(dev_priv));
dev_priv->suspended = false;
return -EBUSY;
}
if (dev_priv->enable_fb)
__vmw_svga_disable(dev_priv);
vmw_release_device_late(dev_priv);
return 0;
} | false | false | false | false | false | 0 |
get(unsigned char *sector)
{
unsigned char tmp[2048];
UDFtag tag;
dir *d;
int LEA,LAD;
int LIU,LFI;
UDFshortad sad;
UDFlongad icb;
mom->UDFtagCopy(sector,&tag);
if (tag.ident != 257) return NULL;
LFI = sector[19];
LIU = bin2intsle(sector+36);
mom->UDFlongadCopy(sector+20,&icb);
if (mom->pread(icb.location.log_no,tmp,1) < 1) return NULL;
LEA = bin2intle(tmp+168);
LAD = bin2intle(tmp+172);
if (LEA > (2048-(176+8+LAD))) return NULL;
if (LAD < 8) return NULL;
mom->UDFshortadCopy(tmp+176+LEA,&sad);
d = new dir(mom);
if (!d) return NULL;
memcpy(&d->dirext,&sad,sizeof(UDFshortad));
d->dirsz = (d->dirext.len + 2047) >> 1;
return d;
} | false | false | false | false | false | 0 |
mwifiex_update_rxreor_flags(struct mwifiex_adapter *adapter, u8 flags)
{
struct mwifiex_private *priv;
struct mwifiex_rx_reorder_tbl *tbl;
unsigned long lock_flags;
int i;
for (i = 0; i < adapter->priv_num; i++) {
priv = adapter->priv[i];
if (!priv)
continue;
spin_lock_irqsave(&priv->rx_reorder_tbl_lock, lock_flags);
if (list_empty(&priv->rx_reorder_tbl_ptr)) {
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock,
lock_flags);
continue;
}
list_for_each_entry(tbl, &priv->rx_reorder_tbl_ptr, list)
tbl->flags = flags;
spin_unlock_irqrestore(&priv->rx_reorder_tbl_lock, lock_flags);
}
return;
} | false | false | false | false | true | 1 |
merge (Node *nodeA, Node *nodeB, int (*cmp) (Node *a, Node *b))
{
Node *thead, *tnode;
if (!nodeA)
return nodeB;
if (!nodeB)
return nodeA;
/* first move the smallest of the head nodes to our head */
if (cmp (nodeA, nodeB) <= 0) { /* a is smaller than or equal to b */
thead = nodeA;
nodeA = nodeA->down;
thead->down = NULL;
} else { /* b is smaller than or equal to a */
thead = nodeB;
nodeB = nodeB->down;
thead->down = NULL;
}
tnode = thead;
/* merge while we get data from both lists */
while (nodeA && nodeB) {
if (cmp (nodeA, nodeB) <= 0) { /* a is smaller than or equal to b */
tnode->down = nodeA;
nodeA->up = tnode;
tnode = nodeA;
nodeA = nodeA->down;
} else { /* b is smaller than or equal to a */
tnode->down = nodeB;
nodeB->up = tnode;
tnode = nodeB;
nodeB = nodeB->down;
}
}
/* add remainder of remaining list */
if (nodeA) {
tnode->down = nodeA;
nodeA->up = tnode;
} else if (nodeB) {
tnode->down = nodeB;
nodeB->up = tnode;
} else {
tnode->down = NULL;
}
return thead;
} | false | false | false | false | false | 0 |
dispatch(Window win, XEvent &ev, bool parent) {
EventHandler *evhand = 0;
if (parent)
evhand = m_parent[win];
else {
win = getEventWindow(ev);
evhand = m_eventhandlers[win];
}
if (evhand == 0)
return;
switch (ev.type) {
case KeyPress:
evhand->keyPressEvent(ev.xkey);
break;
case KeyRelease:
evhand->keyReleaseEvent(ev.xkey);
break;
case ButtonPress:
evhand->buttonPressEvent(ev.xbutton);
break;
case ButtonRelease:
evhand->buttonReleaseEvent(ev.xbutton);
break;
case MotionNotify:
evhand->motionNotifyEvent(ev.xmotion);
break;
case Expose:
evhand->exposeEvent(ev.xexpose);
break;
case EnterNotify:
evhand->enterNotifyEvent(ev.xcrossing);
break;
case LeaveNotify:
evhand->leaveNotifyEvent(ev.xcrossing);
break;
default:
evhand->handleEvent(ev);
break;
};
// find out which window is the parent and
// dispatch event
Window root, parent_win, *children = 0;
unsigned int num_children;
if (XQueryTree(FbTk::App::instance()->display(), win,
&root, &parent_win, &children, &num_children) != 0) {
if (children != 0)
XFree(children);
if (parent_win != 0 &&
parent_win != root) {
if (m_parent[parent_win] == 0)
return;
// dispatch event to parent
dispatch(parent_win, ev, true);
}
}
} | false | false | false | false | false | 0 |
mkp_project_load_node (MkpProject *project, AnjutaProjectNode *node, GError **error)
{
switch (anjuta_project_node_get_node_type (node))
{
case ANJUTA_PROJECT_ROOT:
project->loading++;
DEBUG_PRINT("*** Loading project: %p root file: %p\n", project, project->root_file);
return mkp_project_load_root (project, node, error);
case ANJUTA_PROJECT_GROUP:
project->loading++;
return project_load_makefile (project, node->file, MKP_GROUP(node), error);
default:
return NULL;
}
} | false | false | false | false | false | 0 |
delete_file() {
char path[1024], buf[1024];
sprintf(path, "%s/data.vda", dir);
ssize_t n = readlink(path, buf, sizeof(buf)-1);
if (n < 0) {
printf("readlink %s failed\n", path);
return ERR_SYMLINK;
}
buf[n] = 0;
int retval = unlink(buf);
if (retval) {
printf("unlink %s failed\n", buf);
return ERR_UNLINK;
}
return 0;
} | false | false | false | false | false | 0 |
cleanup(gpointer id) {
ConfData *cd;
cd = g_hash_table_lookup(id_hash, id);
if (cd) {
gint defx, defy;
gtk_window_get_size(GTK_WINDOW (cd->window), &defx, &defy);
if (cd->scrolled) {
prefs_set_int("size_conf_sw.x", defx);
prefs_set_int("size_conf_sw.y", defy);
}
else {
prefs_set_int("size_conf.x", defx);
prefs_set_int("size_conf.y", defy);
}
gtk_widget_destroy(cd->window);
g_free(cd->option1_key);
g_free(cd->option2_key);
g_free(cd->confirm_again_key);
g_hash_table_remove(id_hash, id);
}
} | false | false | false | false | false | 0 |
editorWidget(const CLAM::DynamicType & object, unsigned attribute)
{
CLAM::DirectoryName & value = *(CLAM::DirectoryName *)object.GetAttributeAsVoidPtr(attribute);
QFileLineEdit * input = new QFileLineEdit;
input->setDirMode(true);
input->setLocation(QString::fromLocal8Bit(value.c_str()));
input->setDialogCaption( QObject::tr("Select a directory"));
return input;
} | false | false | false | false | false | 0 |
ladish_hide_connections(struct ladish_graph * graph_ptr, struct ladish_graph_port * port_ptr)
{
struct list_head * node_ptr;
struct ladish_graph_connection * connection_ptr;
log_info("hidding connections of port %"PRIu64, port_ptr->id);
ASSERT(graph_ptr->opath != NULL);
list_for_each(node_ptr, &graph_ptr->connections)
{
connection_ptr = list_entry(node_ptr, struct ladish_graph_connection, siblings);
if (!connection_ptr->hidden && (connection_ptr->port1_ptr == port_ptr || connection_ptr->port2_ptr == port_ptr))
{
log_info("hidding connection between ports %"PRIu64" and %"PRIu64, connection_ptr->port1_ptr->id, connection_ptr->port2_ptr->id);
ladish_graph_hide_connection_internal(graph_ptr, connection_ptr);
}
}
} | false | false | false | false | false | 0 |
update (void) const
{
// The existence of the object means a read lock is being held.
int result;
ACE_stat statbuf;
if (ACE_OS::stat (this->filename_, &statbuf) == -1)
result = 1;
else
result = ACE_OS::difftime (this->stat_.st_mtime, statbuf.st_mtime) < 0;
return result;
} | false | false | false | false | false | 0 |
SetResolveCoincidentTopologyPolygonOffsetParameters(
double factor, double units)
{
if (factor == vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor &&
units == vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits )
{
return;
}
vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetFactor = factor;
vtkMapperGlobalResolveCoincidentTopologyPolygonOffsetUnits = units;
} | false | false | false | false | false | 0 |
pstdout_set_fanout(unsigned int fanout)
{
int rc, rv = -1;
if (!(fanout >= PSTDOUT_FANOUT_MIN && fanout <= PSTDOUT_FANOUT_MAX))
{
pstdout_errnum = PSTDOUT_ERR_PARAMETERS;
return -1;
}
if ((rc = pthread_mutex_lock(&pstdout_launch_mutex)))
{
if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
fprintf(stderr, "pthread_mutex_lock: %s\n", strerror(rc));
pstdout_errnum = PSTDOUT_ERR_INTERNAL;
goto cleanup;
}
pstdout_fanout = fanout;
pstdout_errnum = PSTDOUT_ERR_SUCCESS;
rv = 0;
cleanup:
if ((rc = pthread_mutex_unlock(&pstdout_launch_mutex)))
{
if (pstdout_debug_flags & PSTDOUT_DEBUG_STANDARD)
fprintf(stderr, "pthread_mutex_unlock: %s\n", strerror(rc));
/* Don't change error code, just move on */
}
pstdout_errnum = PSTDOUT_ERR_SUCCESS;
return rv;
} | false | false | false | false | false | 0 |
go_color_selector_drag_data_get (GOSelector *selector)
{
GOColorSelectorState *state;
GOColor color;
int index;
guint16 *data;
state = go_selector_get_user_data (selector);
data = g_new0 (guint16, 4);
index = go_selector_get_active (selector, NULL);
color = get_color (state->n_swatches, state->color_group, index);
data[0] = GO_COLOR_UINT_R (color) << 8;
data[1] = GO_COLOR_UINT_G (color) << 8;
data[2] = GO_COLOR_UINT_B (color) << 8;
data[3] = GO_COLOR_UINT_A (color) << 8;
return data;
} | false | false | false | false | false | 0 |
extend_table(struct pstore_table *table, int input)
{
unsigned long ndx;
for (ndx = 0; ndx < table->nr_columns; ndx++) {
struct pstore_column *column = table->columns[ndx];
if (pstore_column_matches(column, column_ref)) {
if (extend_column(column, input) < 0)
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
mark_ident (struct cpp_reader *pfile ATTRIBUTE_UNUSED, hashnode h,
const void *v ATTRIBUTE_UNUSED)
{
gt_ggc_m_9tree_node (HT_IDENT_TO_GCC_IDENT (h));
return 1;
} | false | false | false | false | false | 0 |
doRotate()
{
_ofile.clear();
_ofile.close();
// ignore unlink- and rename-errors. In case of failure the
// original file is reopened
std::string newfilename = mkfilename(_maxbackupindex);
::unlink(newfilename.c_str());
for (unsigned idx = _maxbackupindex; idx > 0; --idx)
{
std::string oldfilename = mkfilename(idx - 1);
::rename(oldfilename.c_str(), newfilename.c_str());
newfilename = oldfilename;
}
::rename(_fname.c_str(), newfilename.c_str());
_ofile.open(_fname.c_str(), std::ios::out | std::ios::app);
_fsize = 0;
} | false | false | false | false | false | 0 |
_wi_array_insert_item_at_index(wi_array_t *array, _wi_array_item_t *item, wi_uinteger_t index) {
if(array->data_count >= array->items_count)
_wi_array_grow(array, array->data_count + 1);
memmove(array->items + index + 1,
array->items + index,
(array->data_count - index) * sizeof(_wi_array_item_t *));
array->items[index] = item;
array->data_count++;
} | false | false | false | false | false | 0 |
nand_read_oob_syndrome(struct mtd_info *mtd, struct nand_chip *chip,
int page)
{
int length = mtd->oobsize;
int chunk = chip->ecc.bytes + chip->ecc.prepad + chip->ecc.postpad;
int eccsize = chip->ecc.size;
uint8_t *bufpoi = chip->oob_poi;
int i, toread, sndrnd = 0, pos;
chip->cmdfunc(mtd, NAND_CMD_READ0, chip->ecc.size, page);
for (i = 0; i < chip->ecc.steps; i++) {
if (sndrnd) {
pos = eccsize + i * (eccsize + chunk);
if (mtd->writesize > 512)
chip->cmdfunc(mtd, NAND_CMD_RNDOUT, pos, -1);
else
chip->cmdfunc(mtd, NAND_CMD_READ0, pos, page);
} else
sndrnd = 1;
toread = min_t(int, length, chunk);
chip->read_buf(mtd, bufpoi, toread);
bufpoi += toread;
length -= toread;
}
if (length > 0)
chip->read_buf(mtd, bufpoi, length);
return 0;
} | false | false | false | false | false | 0 |
raw_eject(BlockDriverState *bs, int eject_flag)
{
BDRVRawState *s = bs->opaque;
switch(s->type) {
case FTYPE_CD:
if (eject_flag) {
if (ioctl (s->fd, CDROMEJECT, NULL) < 0)
perror("CDROMEJECT");
} else {
if (ioctl (s->fd, CDROMCLOSETRAY, NULL) < 0)
perror("CDROMEJECT");
}
break;
case FTYPE_FD:
{
int fd;
if (s->fd >= 0) {
close(s->fd);
s->fd = -1;
}
fd = open(bs->filename, s->fd_open_flags | O_NONBLOCK);
if (fd >= 0) {
if (ioctl(fd, FDEJECT, 0) < 0)
perror("FDEJECT");
close(fd);
}
}
break;
default:
return -ENOTSUP;
}
return 0;
} | false | false | false | false | true | 1 |
module_server()
{
int listen_sd; ///< Socket to listen to a client
#if defined(_WIN32) && !defined(__CYGWIN32__)
int sd;
#endif
/* prepare socket to listen */
if ((listen_sd = ready_as_server(module_port)) < 0) {
fprintf(stderr, "Error: failed to bind socket\n");
return;
}
printf ("///////////////////////////////\n");
printf ("/// Module mode ready\n");
printf ("/// waiting client at %5d\n", module_port);
printf ("///////////////////////////////\n");
printf ("/// ");
/* no fork, just wait for one connection and proceed */
if ((module_sd = accept_from(listen_sd)) < 0) {
fprintf(stderr, "Error: failed to accept connection\n");
return;
}
#if defined(_WIN32) && !defined(__CYGWIN32__)
/* call winsock function to make the socket capable of reading/writing */
if ((sd = _open_osfhandle(module_sd, O_RDWR|O_BINARY)) < 0) {
fprintf(stderr, "Error: failed to open_osfhandle\n");
return;
}
if ((module_fp = fdopen(sd, "rb+")) == NULL) {
fprintf(stderr, "Error: failed to fdopen socket\n");
return;
}
#else
if ((module_fp = fdopen(module_sd, "r+")) == NULL) {
fprintf(stderr, "Error; failed to fdopen socket\n");
return;
}
#endif
} | false | false | false | false | false | 0 |
find_free_size(const unsigned int size,
skip_alloc_t *update_p)
{
int level_c, cmp;
skip_alloc_t *slot_p, *found_p = NULL, *next_p;
/* skip_free_max_level */
level_c = MAX_SKIP_LEVEL - 1;
slot_p = skip_free_list;
/* traverse list to smallest entry */
while (1) {
/* next on we are looking for */
next_p = slot_p->sa_next_p[level_c];
/* are we are at the end of a row? */
if (next_p == NULL
|| next_p == found_p) {
/* just go down a level */
}
else {
cmp = next_p->sa_total_size - size;
if (cmp < 0) {
/* next slot is less, go right */
slot_p = next_p;
continue;
}
else if (cmp == 0) {
/*
* we found a match but it may not be the first slot with this
* size and we want the first match
*/
found_p = next_p;
}
}
/* we are lowering the level */
update_p->sa_next_p[level_c] = slot_p;
if (level_c == 0) {
break;
}
level_c--;
}
/* space should be free */
if (found_p != NULL && (! BIT_IS_SET(found_p->sa_flags, ALLOC_FLAG_FREE))) {
/* sanity check */
dmalloc_errno = ERROR_ADDRESS_LIST;
dmalloc_error("find_free_size");
return NULL;
}
return found_p;
} | false | false | false | false | true | 1 |
e_wizard_init(void)
{
E_Manager *man;
Eina_List *l;
EINA_LIST_FOREACH(e_manager_list(), l, man)
{
E_Container *con;
Eina_List *l2;
EINA_LIST_FOREACH(man->containers, l2, con)
{
Eina_List *l3;
E_Zone *zone;
EINA_LIST_FOREACH(con->zones, l3, zone)
{
if (!pop)
pop = _e_wizard_main_new(zone);
else
pops = eina_list_append(pops, _e_wizard_extra_new(zone));
}
}
}
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_DESKTOP_CACHE_BUILD,
_e_wizard_cb_desktops_update, NULL);
E_LIST_HANDLER_APPEND(handlers, EFREET_EVENT_ICON_CACHE_UPDATE,
_e_wizard_cb_icons_update, NULL);
return 1;
} | false | false | false | false | false | 0 |
sysfs_kf_seq_show(struct seq_file *sf, void *v)
{
struct kernfs_open_file *of = sf->private;
struct kobject *kobj = of->kn->parent->priv;
const struct sysfs_ops *ops = sysfs_file_ops(of->kn);
ssize_t count;
char *buf;
/* acquire buffer and ensure that it's >= PAGE_SIZE and clear */
count = seq_get_buf(sf, &buf);
if (count < PAGE_SIZE) {
seq_commit(sf, -1);
return 0;
}
memset(buf, 0, PAGE_SIZE);
/*
* Invoke show(). Control may reach here via seq file lseek even
* if @ops->show() isn't implemented.
*/
if (ops->show) {
count = ops->show(kobj, of->kn->priv, buf);
if (count < 0)
return count;
}
/*
* The code works fine with PAGE_SIZE return but it's likely to
* indicate truncated result or overflow in normal use cases.
*/
if (count >= (ssize_t)PAGE_SIZE) {
print_symbol("fill_read_buffer: %s returned bad count\n",
(unsigned long)ops->show);
/* Try to struggle along */
count = PAGE_SIZE - 1;
}
seq_commit(sf, count);
return 0;
} | false | false | false | false | false | 0 |
mxf_probe(AVProbeData *p) {
uint8_t *bufp = p->buf;
uint8_t *end = p->buf + p->buf_size;
if (p->buf_size < sizeof(mxf_header_partition_pack_key))
return 0;
/* Must skip Run-In Sequence and search for MXF header partition pack key SMPTE 377M 5.5 */
end -= sizeof(mxf_header_partition_pack_key);
for (; bufp < end; bufp++) {
if (IS_KLV_KEY(bufp, mxf_header_partition_pack_key))
return AVPROBE_SCORE_MAX;
}
return 0;
} | false | false | false | false | false | 0 |
to_utf8() const
{
if (!size()) {
return byte_array();
}
MiniIconv ic("UTF-8", "UTF-16");
if (!ic.is_valid()) {
return byte_array();
}
const value_type *me_data = data();
byte_array str(size());
char *str_data = &str[0];
size_t me_len_char = size() * 2;
size_t str_len_left = str.size();
size_t ir = iconv(ic, (ICONV_CONST char **)&me_data, &me_len_char, &str_data, &str_len_left);
if ((ir == (size_t)-1) && (errno == E2BIG)) {
const size_t delta = str_data - &str[0];
str_len_left += str.size();
str.resize(str.size() * 2);
str_data = &str[delta];
ir = iconv(ic, (ICONV_CONST char **)&me_data, &me_len_char, &str_data, &str_len_left);
if (ir == (size_t)-1) {
return byte_array();
}
}
if (str_len_left >= 0) {
str.resize(str.size() - str_len_left);
}
return str;
} | false | false | false | false | false | 0 |
globus_libc_gethostbyname_r(
char * hostname,
struct hostent * result,
char * buffer,
int buflen,
int * h_errnop)
{
struct hostent * hp = GLOBUS_NULL;
# if defined(GLOBUS_HAVE_GETHOSTBYNAME_R_3)
struct hostent_data hp_data;
int rc;
# endif
# if defined(GLOBUS_HAVE_GETHOSTBYNAME_R_6)
int rc;
# endif
globus_libc_lock();
# if !defined(HAVE_GETHOSTBYNAME_R)
{
hp = gethostbyname(hostname);
if(hp != GLOBUS_NULL)
{
memcpy(result, hp, sizeof(struct hostent));
if(globus_l_libc_copy_hostent_data_to_buffer(
result,
buffer,
(size_t) buflen) == -1)
{
hp = GLOBUS_NULL;
}
else
{
hp = result;
}
if (h_errnop != GLOBUS_NULL)
{
*h_errnop = 0;
}
}
else
{
if (h_errnop != GLOBUS_NULL)
{
*h_errnop = h_errno;
}
}
}
# elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_3)
{
rc = gethostbyname_r(hostname,
result,
&hp_data);
if(rc == 0)
{
if(globus_l_libc_copy_hostent_data_to_buffer(
result, buffer, (size_t) buflen) == -1)
{
hp = GLOBUS_NULL;
}
else
{
hp = result;
}
if(h_errnop != GLOBUS_NULL)
{
*h_errnop = h_errno;
}
}
else
{
hp = GLOBUS_NULL;
if(h_errnop != GLOBUS_NULL)
{
*h_errnop = h_errno;
}
}
}
# elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_5)
{
hp = gethostbyname_r(hostname,
result,
buffer,
buflen,
h_errnop);
}
# elif defined(GLOBUS_HAVE_GETHOSTBYNAME_R_6)
{
rc = gethostbyname_r(hostname,
result,
buffer,
buflen,
&hp,
h_errnop);
}
# else
{
GLOBUS_HAVE_GETHOSTBYNAME symbol must be defined!!!;
}
# endif
globus_libc_unlock();
/*
* gethostbyname() on many machines does the right thing for IP addresses
* (e.g., "140.221.7.13"). But on some machines (e.g., SunOS 4.1.x) it
* doesn't. So hack it in this case.
*/
if (hp == GLOBUS_NULL)
{
if(isdigit(hostname[0]))
{
struct in_addr addr;
addr.s_addr = inet_addr(hostname);
if ((int) addr.s_addr != -1)
{
hp = globus_libc_gethostbyaddr_r(
(void *) &addr,
sizeof(addr),
AF_INET,
result,
buffer,
buflen,
h_errnop);
}
}
}
return hp;
} | false | false | false | false | false | 0 |
hx509_ca_tbs_add_crl_dp_uri(hx509_context context,
hx509_ca_tbs tbs,
const char *uri,
hx509_name issuername)
{
DistributionPoint dp;
int ret;
memset(&dp, 0, sizeof(dp));
dp.distributionPoint = ecalloc(1, sizeof(*dp.distributionPoint));
{
DistributionPointName name;
GeneralName gn;
size_t size;
name.element = choice_DistributionPointName_fullName;
name.u.fullName.len = 1;
name.u.fullName.val = &gn;
gn.element = choice_GeneralName_uniformResourceIdentifier;
gn.u.uniformResourceIdentifier.data = rk_UNCONST(uri);
gn.u.uniformResourceIdentifier.length = strlen(uri);
ASN1_MALLOC_ENCODE(DistributionPointName,
dp.distributionPoint->data,
dp.distributionPoint->length,
&name, &size, ret);
if (ret) {
hx509_set_error_string(context, 0, ret,
"Failed to encoded DistributionPointName");
goto out;
}
if (dp.distributionPoint->length != size)
_hx509_abort("internal ASN.1 encoder error");
}
if (issuername) {
#if 1
/**
* issuername not supported
*/
hx509_set_error_string(context, 0, EINVAL,
"CRLDistributionPoints.name.issuername not yet supported");
return EINVAL;
#else
GeneralNames *crlissuer;
GeneralName gn;
Name n;
crlissuer = calloc(1, sizeof(*crlissuer));
if (crlissuer == NULL) {
return ENOMEM;
}
memset(&gn, 0, sizeof(gn));
gn.element = choice_GeneralName_directoryName;
ret = hx509_name_to_Name(issuername, &n);
if (ret) {
hx509_set_error_string(context, 0, ret, "out of memory");
goto out;
}
gn.u.directoryName.element = n.element;
gn.u.directoryName.u.rdnSequence = n.u.rdnSequence;
ret = add_GeneralNames(&crlissuer, &gn);
free_Name(&n);
if (ret) {
hx509_set_error_string(context, 0, ret, "out of memory");
goto out;
}
dp.cRLIssuer = &crlissuer;
#endif
}
ret = add_CRLDistributionPoints(&tbs->crldp, &dp);
if (ret) {
hx509_set_error_string(context, 0, ret, "out of memory");
goto out;
}
out:
free_DistributionPoint(&dp);
return ret;
} | false | false | false | false | false | 0 |
nss_var_lookup_nss_cert_chain(apr_pool_t *p, CERTCertificate *cert, char *var)
{
char *result;
CERTCertificateList *chain = NULL;
int n;
result = NULL;
chain = CERT_CertChainFromCert(cert, certUsageSSLClient, PR_TRUE);
if (!chain)
return NULL;
if (strspn(var, "0123456789") == strlen(var)) {
n = atoi(var);
if (n <= chain->len-1) {
CERTCertificate *c;
c = CERT_FindCertByDERCert(CERT_GetDefaultCertDB(), &chain->certs[n]);
result = nss_var_lookup_nss_cert_PEM(p, c);
CERT_DestroyCertificate(c);
}
}
CERT_DestroyCertificateList(chain);
return result;
} | false | false | false | false | false | 0 |
__ao2_global_obj_release(struct ao2_global_obj *holder, const char *tag, const char *file, int line, const char *func, const char *name)
{
if (!holder) {
/* For sanity */
ast_log(LOG_ERROR, "Must be called with a global object!\n");
return;
}
if (__ast_rwlock_wrlock(file, line, func, &holder->lock, name)) {
/* Could not get the write lock. */
return;
}
/* Release the held ao2 object. */
if (holder->obj) {
if (tag) {
__ao2_ref_debug(holder->obj, -1, tag, file, line, func);
} else {
__ao2_ref(holder->obj, -1);
}
holder->obj = NULL;
}
__ast_rwlock_unlock(file, line, func, &holder->lock, name);
} | false | false | false | false | false | 0 |
jack_controller_add_slave_driver(
struct jack_controller * controller_ptr,
const char * driver_name)
{
jackctl_driver_t * driver;
struct jack_controller_slave_driver * driver_ptr;
size_t len_old;
size_t len_new;
len_old = strlen(controller_ptr->slave_drivers_vparam_value.str);
len_new = strlen(driver_name);
if (len_old + len_new + 2 > sizeof(controller_ptr->slave_drivers_vparam_value.str))
{
jack_error("No more space for slave drivers.");
return false;
}
driver = jack_controller_find_driver(controller_ptr->server, driver_name);
if (driver == NULL)
{
jack_error("Unknown driver \"%s\"", driver_name);
return false;
}
if (jack_controller_check_slave_driver(controller_ptr, driver_name))
{
jack_info("Driver \"%s\" is already slave", driver_name);
return true;
}
driver_ptr = malloc(sizeof(struct jack_controller_slave_driver));
if (driver_ptr == NULL)
{
jack_error("malloc() failed to allocate jack_controller_slave_driver struct");
return false;
}
driver_ptr->name = strdup(driver_name);
if (driver_ptr->name == NULL)
{
jack_error("strdup() failed for slave driver name \"%s\"", driver_name);
free(driver_ptr);
return false;
}
driver_ptr->handle = driver;
driver_ptr->loaded = false;
jack_info("driver \"%s\" set as slave", driver_name);
list_add_tail(&driver_ptr->siblings, &controller_ptr->slave_drivers);
if (len_old != 0)
{
controller_ptr->slave_drivers_vparam_value.str[len_old++] = ',';
}
memcpy(controller_ptr->slave_drivers_vparam_value.str + len_old, driver_name, len_new + 1);
controller_ptr->slave_drivers_set = true;
return true;
} | false | false | false | false | false | 0 |
ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
{
struct ravb_private *priv = netdev_priv(ndev);
unsigned long flags;
int error;
if (!priv->phydev)
return -ENODEV;
spin_lock_irqsave(&priv->lock, flags);
/* Disable TX and RX */
ravb_rcv_snd_disable(ndev);
error = phy_ethtool_sset(priv->phydev, ecmd);
if (error)
goto error_exit;
if (ecmd->duplex == DUPLEX_FULL)
priv->duplex = 1;
else
priv->duplex = 0;
ravb_set_duplex(ndev);
error_exit:
mdelay(1);
/* Enable TX and RX */
ravb_rcv_snd_enable(ndev);
mmiowb();
spin_unlock_irqrestore(&priv->lock, flags);
return error;
} | false | false | false | false | false | 0 |
mlx5_query_port_ptys(struct mlx5_core_dev *dev, u32 *ptys,
int ptys_size, int proto_mask, u8 local_port)
{
u32 in[MLX5_ST_SZ_DW(ptys_reg)];
memset(in, 0, sizeof(in));
MLX5_SET(ptys_reg, in, local_port, local_port);
MLX5_SET(ptys_reg, in, proto_mask, proto_mask);
return mlx5_core_access_reg(dev, in, sizeof(in), ptys,
ptys_size, MLX5_REG_PTYS, 0, 0);
} | false | false | false | false | false | 0 |
serv_slave(int fd, int pid)
{
struct sockaddr_in to_addr, from_addr;
int to_addr_len, from_addr_len;
to_addr_len = sizeof(to_addr);
memset(&to_addr, 0, sizeof(to_addr));
if (getsockname(fd, (struct sockaddr *) &to_addr, &to_addr_len) < 0) {
log(LOG_ERR, pid, "getsockname failed %d:%s\n", errno, strerror(errno));
exit(1);
}
from_addr_len = sizeof(from_addr);
memset(&from_addr, 0, sizeof(from_addr));
if (getpeername(fd, (struct sockaddr *) &from_addr, &from_addr_len) < 0) {
log(LOG_ERR, pid, "getpeername failed %d:%s\n", errno, strerror(errno));
exit(1);
}
print_connect(pid, &from_addr, &to_addr);
if (tpserv_connect)
process_request_connect(fd, pid, &from_addr, &to_addr);
else
process_request_echo(fd, pid, &from_addr, &to_addr);
close(fd);
print_disconnect(pid, &from_addr, &to_addr);
} | false | false | false | false | false | 0 |
minefield_view_render_svg_pattern (MinefieldView* self, cairo_t* cr, const gchar* filename) {
cairo_pattern_t* result = NULL;
cairo_surface_t* surface = NULL;
cairo_t* _tmp0_ = NULL;
cairo_surface_t* _tmp1_ = NULL;
guint _tmp2_ = 0U;
guint _tmp3_ = 0U;
guint _tmp4_ = 0U;
guint _tmp5_ = 0U;
cairo_surface_t* _tmp6_ = NULL;
cairo_t* c = NULL;
cairo_t* _tmp7_ = NULL;
GdkPixbuf* pixbuf = NULL;
gint size = 0;
guint _tmp8_ = 0U;
guint _tmp9_ = 0U;
GdkPixbuf* _tmp14_ = NULL;
cairo_pattern_t* pattern = NULL;
cairo_pattern_t* _tmp15_ = NULL;
GError * _inner_error_ = NULL;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (cr != NULL, NULL);
g_return_val_if_fail (filename != NULL, NULL);
_tmp0_ = cr;
_tmp1_ = cairo_get_target (_tmp0_);
_tmp2_ = minefield_view_get_mine_size (self);
_tmp3_ = _tmp2_;
_tmp4_ = minefield_view_get_mine_size (self);
_tmp5_ = _tmp4_;
_tmp6_ = cairo_surface_create_similar (_tmp1_, CAIRO_CONTENT_COLOR_ALPHA, (gint) _tmp3_, (gint) _tmp5_);
surface = _tmp6_;
_tmp7_ = cairo_create (surface);
c = _tmp7_;
_tmp8_ = minefield_view_get_mine_size (self);
_tmp9_ = _tmp8_;
size = ((gint) _tmp9_) - 2;
{
GdkPixbuf* _tmp10_ = NULL;
const gchar* _tmp11_ = NULL;
GdkPixbuf* _tmp12_ = NULL;
_tmp11_ = filename;
_tmp12_ = rsvg_pixbuf_from_file_at_size (_tmp11_, size, size, &_inner_error_);
_tmp10_ = _tmp12_;
if (_inner_error_ != NULL) {
goto __catch4_g_error;
}
_g_object_unref0 (pixbuf);
pixbuf = _tmp10_;
}
goto __finally4;
__catch4_g_error:
{
GError* e = NULL;
GdkPixbuf* _tmp13_ = NULL;
e = _inner_error_;
_inner_error_ = NULL;
_tmp13_ = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, size, size);
_g_object_unref0 (pixbuf);
pixbuf = _tmp13_;
_g_error_free0 (e);
}
__finally4:
if (_inner_error_ != NULL) {
_g_object_unref0 (pixbuf);
_cairo_destroy0 (c);
_cairo_surface_destroy0 (surface);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return NULL;
}
_tmp14_ = pixbuf;
gdk_cairo_set_source_pixbuf (c, _tmp14_, (gdouble) 1, (gdouble) 1);
cairo_paint (c);
_tmp15_ = cairo_pattern_create_for_surface (surface);
pattern = _tmp15_;
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
result = pattern;
_g_object_unref0 (pixbuf);
_cairo_destroy0 (c);
_cairo_surface_destroy0 (surface);
return result;
} | false | false | false | false | false | 0 |
nrrdAxisInfoGet_va(const Nrrd *nrrd, int axInfo, ...) {
void *buffer[NRRD_DIM_MAX], *ptr;
_nrrdAxisInfoGetPtrs info;
unsigned int ai, si;
va_list ap;
double svec[NRRD_DIM_MAX][NRRD_SPACE_DIM_MAX];
if (!( nrrd
&& AIR_IN_CL(1, nrrd->dim, NRRD_DIM_MAX)
&& AIR_IN_OP(nrrdAxisInfoUnknown, axInfo, nrrdAxisInfoLast) )) {
return;
}
if (nrrdAxisInfoSpaceDirection != axInfo) {
info.P = buffer;
nrrdAxisInfoGet_nva(nrrd, axInfo, info.P);
} else {
nrrdAxisInfoGet_nva(nrrd, axInfo, svec);
}
va_start(ap, axInfo);
for (ai=0; ai<nrrd->dim; ai++) {
ptr = va_arg(ap, void*);
/*
printf("!%s(%d): ptr = %lu\n",
"nrrdAxisInfoGet", d, (unsigned long)ptr);
*/
switch (axInfo) {
case nrrdAxisInfoSize:
*((size_t*)ptr) = info.ST[ai];
break;
case nrrdAxisInfoSpacing:
case nrrdAxisInfoThickness:
case nrrdAxisInfoMin:
case nrrdAxisInfoMax:
*((double*)ptr) = info.D[ai];
/* printf("!%s: got double[%d] = %lg\n", "nrrdAxisInfoGet", d,
*((double*)ptr)); */
break;
case nrrdAxisInfoSpaceDirection:
for (si=0; si<nrrd->spaceDim; si++) {
((double*)ptr)[si] = svec[ai][si];
}
for (si=nrrd->spaceDim; si<NRRD_SPACE_DIM_MAX; si++) {
((double*)ptr)[si] = AIR_NAN;
}
break;
case nrrdAxisInfoCenter:
case nrrdAxisInfoKind:
*((int*)ptr) = info.I[ai];
/* printf("!%s: got int[%d] = %d\n",
"nrrdAxisInfoGet", d, *((int*)ptr)); */
break;
case nrrdAxisInfoLabel:
case nrrdAxisInfoUnits:
/* we DO NOT do the airStrdup() here because this pointer value just
came from nrrdAxisInfoGet_nva(), which already did the airStrdup() */
*((char**)ptr) = info.CP[ai];
/* printf("!%s: got char*[%d] = |%s|\n", "nrrdAxisInfoSet", d,
*((char**)ptr)); */
break;
}
}
va_end(ap);
return;
} | false | false | false | false | true | 1 |
LI2(V5)
object V5;
{ VMB2 VMS2 VMV2
goto TTL;
TTL:;
{object V6;
base[1]= (V5);
vs_top=(vs_base=base+1)+1;
(void) (*Lnk113)();
vs_top=sup;
base[0]= vs_base[0];
vs_top=(vs_base=base+0)+1;
(void) (*Lnk114)();
vs_top=sup;
V6= vs_base[0];
if(!(type_of((V6))==t_cons||((V6))==Cnil)){
goto T35;}
{register object V7;
register object V8;
base[1]= (V5);
vs_top=(vs_base=base+1)+1;
(void) (*Lnk113)();
vs_top=sup;
base[0]= vs_base[0];
vs_top=(vs_base=base+0)+1;
(void) (*Lnk114)();
vs_top=sup;
V9= vs_base[0];
V7= reverse(V9);
V8= car((V7));
goto T43;
T43:;
if(!(endp_prop((V7)))){
goto T44;}
{object V10 = Cnil;
VMR2(V10)}
goto T44;
T44:;
base[0]= symbol_value(((object)VV[1]));
base[1]= ((object)VV[3]);
base[2]= car((V8));
base[3]= cadr((V8));
vs_top=(vs_base=base+0)+4;
Lformat();
vs_top=sup;
V7= cdr((V7));
V8= car((V7));
goto T43;}
goto T35;
T35:;
{object V11 = Cnil;
VMR2(V11)}}
base[0]=base[0];
return Cnil;
} | false | false | false | false | false | 0 |
query_wc2(globus_rls_handle_t *h, char *method, char *pattern,
globus_rls_pattern_t type, int *offset, int reslimit,
globus_list_t **str2_list)
{
globus_result_t r;
BUFFER b;
char buf[BUFLEN*2];
char obuf[50];
char rbuf[50];
int otimeout;
int loffset;
RLSLIST *rlslist;
if ((r = checkhandle(h)) != GLOBUS_SUCCESS)
return r;
if (!pattern || !*pattern)
return mkresult(GLOBUS_RLS_BADARG, "pattern is NULL");
if (type == rls_pattern_unix)
pattern = translatepattern(pattern, buf, BUFLEN*2);
if (!offset) {
loffset = 0;
offset = &loffset;
}
iarg(reslimit, rbuf);
if ((rlslist = rlslist_new(free_str2)) == NULL)
return mkresult(GLOBUS_RLS_NOMEMORY, NULL);
if (otimeout = rrpc_get_timeout()) /* Use large timeout on wildcard*/
rrpc_set_timeout(10 * otimeout); /* queries */
if (offset == &loffset) {
while ((r = rrpc_call(h, &b, method, 3, pattern, iarg(*offset, obuf),
rbuf)) == GLOBUS_SUCCESS) {
r = rrpc_str2(h, &b, rlslist, offset);
if (r != GLOBUS_SUCCESS || *offset == -1)
break;
}
} else
if ((r = rrpc_call(h, &b, method, 3, pattern, iarg(*offset, obuf),
rbuf)) == GLOBUS_SUCCESS)
r = rrpc_str2(h, &b, rlslist, offset);
if (otimeout)
rrpc_set_timeout(otimeout);
if (r == GLOBUS_SUCCESS)
*str2_list = rlslist->list;
else
globus_rls_client_free_list(rlslist->list);
return r;
} | false | false | false | false | false | 0 |
xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) {
int i;
const xmlChar *prefix;
const xmlChar *href;
int has_empty_ns;
if(cur == NULL) {
xmlC14NErrParam("searching namespaces stack (exc c14n)");
return (0);
}
/*
* if the default namespace xmlns="" is not defined yet then
* we do not want to print it out
*/
prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix;
href = ((ns == NULL) || (ns->href == NULL)) ? BAD_CAST "" : ns->href;
has_empty_ns = (xmlC14NStrEqual(prefix, NULL) && xmlC14NStrEqual(href, NULL));
if (cur->nsTab != NULL) {
int start = 0;
for (i = cur->nsCurEnd - 1; i >= start; --i) {
xmlNsPtr ns1 = cur->nsTab[i];
if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) {
if(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL)) {
return(xmlC14NIsVisible(ctx, ns1, cur->nodeTab[i]));
} else {
return(0);
}
}
}
}
return(has_empty_ns);
} | false | false | false | false | false | 0 |
setup_write_iov(const struct Buffer *buffer, struct iovec *iov, size_t len) {
size_t room;
size_t start;
size_t end;
room = buffer->size - buffer->len;
if (room == 0) /* trivial case: no room */
return 0;
/* Allow caller to specify maxium length */
if (len)
room = MIN(room, len);
start = (buffer->head + buffer->len) & (buffer->size - 1);
end = (start + room) & (buffer->size - 1);
if (end > start) { /* simple case */
iov[0].iov_base = &buffer->buffer[start];
iov[0].iov_len = room;
return 1;
} else { /* wrap around case */
iov[0].iov_base = &buffer->buffer[start];
iov[0].iov_len = buffer->size - start;
iov[1].iov_base = buffer->buffer;
iov[1].iov_len = room - iov[0].iov_len;
return 2;
}
} | false | false | false | false | false | 0 |
stp_sequence_get_bounds(const stp_sequence_t *sequence,
double *low, double *high)
{
CHECK_SEQUENCE(sequence);
*low = sequence->blo;
*high = sequence->bhi;
} | false | false | false | false | false | 0 |
s_mp_mul_digs (mp_int * a, mp_int * b, mp_int * c, int digs)
{
mp_int t;
int res, pa, pb, ix, iy;
mp_digit u;
mp_word r;
mp_digit tmpx, *tmpt, *tmpy;
/* can we use the fast multiplier? */
if (((digs) < MP_WARRAY) &&
MIN (a->used, b->used) <
(1 << ((CHAR_BIT * sizeof (mp_word)) - (2 * DIGIT_BIT)))) {
return fast_s_mp_mul_digs (a, b, c, digs);
}
if ((res = mp_init_size (&t, digs)) != MP_OKAY) {
return res;
}
t.used = digs;
/* compute the digits of the product directly */
pa = a->used;
for (ix = 0; ix < pa; ix++) {
/* set the carry to zero */
u = 0;
/* limit ourselves to making digs digits of output */
pb = MIN (b->used, digs - ix);
/* setup some aliases */
/* copy of the digit from a used within the nested loop */
tmpx = a->dp[ix];
/* an alias for the destination shifted ix places */
tmpt = t.dp + ix;
/* an alias for the digits of b */
tmpy = b->dp;
/* compute the columns of the output and propagate the carry */
for (iy = 0; iy < pb; iy++) {
/* compute the column as a mp_word */
r = ((mp_word)*tmpt) +
((mp_word)tmpx) * ((mp_word)*tmpy++) +
((mp_word) u);
/* the new column is the lower part of the result */
*tmpt++ = (mp_digit) (r & ((mp_word) MP_MASK));
/* get the carry word from the result */
u = (mp_digit) (r >> ((mp_word) DIGIT_BIT));
}
/* set carry if it is placed below digs */
if (ix + iy < digs) {
*tmpt = u;
}
}
mp_clamp (&t);
mp_exch (&t, c);
mp_clear (&t);
return MP_OKAY;
} | false | false | false | false | false | 0 |
invalidPointerError(const Token *tok, const std::string &func, const std::string &pointer_name)
{
reportError(tok, Severity::error, "invalidPointer", "Invalid pointer '" + pointer_name + "' after " + func + "().");
} | false | false | false | false | false | 0 |
show_duration(FILE *f, duration_t duration, const char *pre, const char *post)
{
if (duration.seconds)
fprintf(f, "%s%u:%02u min%s", pre, FRACTION(duration.seconds, 60), post);
} | false | false | false | false | false | 0 |
mono_class_setup_basic_field_info (MonoClass *class)
{
MonoClassField *field;
MonoClass *gtd;
MonoImage *image;
int i, top;
if (class->fields)
return;
gtd = class->generic_class ? mono_class_get_generic_type_definition (class) : NULL;
image = class->image;
top = class->field.count;
if (class->generic_class && class->generic_class->container_class->image->dynamic && !class->generic_class->container_class->wastypebuilder) {
/*
* This happens when a generic instance of an unfinished generic typebuilder
* is used as an element type for creating an array type. We can't initialize
* the fields of this class using the fields of gklass, since gklass is not
* finished yet, fields could be added to it later.
*/
return;
}
if (gtd) {
mono_class_setup_basic_field_info (gtd);
top = gtd->field.count;
class->field.first = gtd->field.first;
class->field.count = gtd->field.count;
}
class->fields = mono_class_alloc0 (class, sizeof (MonoClassField) * top);
/*
* Fetch all the field information.
*/
for (i = 0; i < top; i++){
field = &class->fields [i];
field->parent = class;
if (gtd) {
field->name = mono_field_get_name (>d->fields [i]);
} else {
int idx = class->field.first + i;
/* class->field.first and idx points into the fieldptr table */
guint32 name_idx = mono_metadata_decode_table_row_col (image, MONO_TABLE_FIELD, idx, MONO_FIELD_NAME);
/* The name is needed for fieldrefs */
field->name = mono_metadata_string_heap (image, name_idx);
}
}
} | false | false | false | false | false | 0 |
calcul_nbdeport_cyclesface(LST_EQUIPO lst_equipo)
{
int nbdeport = 0;
ptype_list * liste;
while (lst_equipo != NULL) {
liste = lst_equipo->lst_visavis;
while (liste != NULL) {
if (existe_visavis(lst_equipo->index, liste->TYPE, lst_equipo)) {
nbdeport++;
}
liste = liste->NEXT;
}
lst_equipo = lst_equipo->suiv;
}
if (mode_debug)
printf("Nb deports cycles trouves %d\n", nbdeport);
return(nbdeport);
} | false | false | false | false | false | 0 |
nsslowcert_OpenCertDB(NSSLOWCERTCertDBHandle *handle, PRBool readOnly,
const char *appName, const char *prefix,
NSSLOWCERTDBNameFunc namecb, void *cbarg, PRBool openVolatile)
{
int rv;
certdb_InitDBLock(handle);
handle->dbMon = PZ_NewMonitor(nssILockCertDB);
PORT_Assert(handle->dbMon != NULL);
handle->dbVerify = PR_FALSE;
rv = nsslowcert_OpenPermCertDB(handle, readOnly, appName, prefix,
namecb, cbarg);
if ( rv ) {
goto loser;
}
return (SECSuccess);
loser:
if (handle->dbMon) {
PZ_DestroyMonitor(handle->dbMon);
handle->dbMon = NULL;
}
PORT_SetError(SEC_ERROR_BAD_DATABASE);
return(SECFailure);
} | false | false | false | false | false | 0 |
Stat( const char *pszFilename,
VSIStatBufL *pStatBuf, int nFlags )
{
CPLString osInArchiveSubDir;
memset(pStatBuf, 0, sizeof(VSIStatBufL));
char* zipFilename = SplitFilename(pszFilename, osInArchiveSubDir, TRUE);
if (zipFilename == NULL)
return -1;
{
CPLMutexHolder oHolder(&hMutex);
if (oMapZipWriteHandles.find(zipFilename) != oMapZipWriteHandles.end() )
{
CPLError(CE_Failure, CPLE_AppDefined,
"Cannot read a zip file being written");
CPLFree(zipFilename);
return -1;
}
}
CPLFree(zipFilename);
return VSIArchiveFilesystemHandler::Stat(pszFilename, pStatBuf, nFlags);
} | false | false | false | false | false | 0 |
exprInputCollation(Node *expr)
{
Oid coll;
if (!expr)
return InvalidOid;
switch (nodeTag(expr))
{
case T_Aggref:
coll = ((Aggref *) expr)->inputcollid;
break;
case T_WindowFunc:
coll = ((WindowFunc *) expr)->inputcollid;
break;
case T_FuncExpr:
coll = ((FuncExpr *) expr)->inputcollid;
break;
case T_OpExpr:
coll = ((OpExpr *) expr)->inputcollid;
break;
case T_DistinctExpr:
coll = ((DistinctExpr *) expr)->inputcollid;
break;
case T_NullIfExpr:
coll = ((NullIfExpr *) expr)->inputcollid;
break;
case T_ScalarArrayOpExpr:
coll = ((ScalarArrayOpExpr *) expr)->inputcollid;
break;
case T_MinMaxExpr:
coll = ((MinMaxExpr *) expr)->inputcollid;
break;
default:
coll = InvalidOid;
break;
}
return coll;
} | false | false | false | false | false | 0 |
_tp_handle_channels_context_prepare_async (
TpHandleChannelsContext *self,
const GQuark *account_features,
const GQuark *connection_features,
const GQuark *channel_features,
GAsyncReadyCallback callback,
gpointer user_data)
{
g_return_if_fail (TP_IS_HANDLE_CHANNELS_CONTEXT (self));
/* This is only used once, by TpBaseClient, so for simplicity, we only
* allow one asynchronous preparation */
g_return_if_fail (self->priv->result == NULL);
self->priv->result = g_simple_async_result_new (G_OBJECT (self),
callback, user_data, _tp_handle_channels_context_prepare_async);
context_prepare (self, account_features, connection_features,
channel_features);
} | false | false | false | false | false | 0 |
GdipGetImageGraphicsContext (GpImage *image, GpGraphics **graphics)
{
GpGraphics *gfx;
cairo_surface_t *surface;
cairo_pattern_t *filter;
if (!image || !graphics)
return InvalidParameter;
/* This function isn't allowed on metafiles - unless we're recording */
if (image->type == ImageTypeMetafile) {
GpMetafile *mf = (GpMetafile*)image;
if (!mf->recording)
return OutOfMemory;
*graphics = gdip_metafile_graphics_new (mf);
return *graphics ? Ok : OutOfMemory;
}
if (!image->active_bitmap)
return InvalidParameter;
/*
* Microsoft GDI+ only supports these pixel formats Format24bppRGB, Format32bppARGB,
* Format32bppPARGB, Format32bppRGB, Format48bppRGB, Format64bppARGB, Format64bppPARGB
* but we're limited to 24/32 inside libgdiplus
*/
switch (image->active_bitmap->pixel_format) {
case PixelFormat24bppRGB:
case PixelFormat32bppARGB:
case PixelFormat32bppPARGB:
case PixelFormat32bppRGB:
break;
default:
return OutOfMemory;
}
surface = cairo_image_surface_create_for_data ((BYTE*) image->active_bitmap->scan0, image->cairo_format,
image->active_bitmap->width, image->active_bitmap->height, image->active_bitmap->stride);
gfx = gdip_graphics_new (surface);
gfx->dpi_x = image->active_bitmap->dpi_horz <= 0 ? gdip_get_display_dpi () : image->active_bitmap->dpi_horz;
gfx->dpi_y = image->active_bitmap->dpi_vert <= 0 ? gdip_get_display_dpi () : image->active_bitmap->dpi_vert;
cairo_surface_destroy (surface);
gfx->image = image;
gfx->type = gtMemoryBitmap;
filter = cairo_pattern_create_for_surface (image->surface);
cairo_pattern_set_filter (filter, gdip_get_cairo_filter (gfx->interpolation));
cairo_pattern_destroy (filter);
*graphics = gfx;
return Ok;
} | false | false | false | false | false | 0 |
drv2667_init(struct drv2667_data *haptics)
{
int error;
/* Set default haptic frequency to 195Hz on Page 1*/
haptics->frequency = 195;
haptics->page = DRV2667_PAGE_1;
error = regmap_register_patch(haptics->regmap,
drv2667_init_regs,
ARRAY_SIZE(drv2667_init_regs));
if (error) {
dev_err(&haptics->client->dev,
"Failed to write init registers: %d\n",
error);
return error;
}
error = regmap_write(haptics->regmap, DRV2667_PAGE, haptics->page);
if (error) {
dev_err(&haptics->client->dev, "Failed to set page: %d\n",
error);
goto error_out;
}
error = drv2667_set_waveform_freq(haptics);
if (error)
goto error_page;
error = regmap_register_patch(haptics->regmap,
drv2667_page1_init,
ARRAY_SIZE(drv2667_page1_init));
if (error) {
dev_err(&haptics->client->dev,
"Failed to write page registers: %d\n",
error);
return error;
}
error = regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0);
return error;
error_page:
regmap_write(haptics->regmap, DRV2667_PAGE, DRV2667_PAGE_0);
error_out:
return error;
} | false | false | false | false | false | 0 |
coerce_argument_list (PACK_T ** r, NODE_T * p)
{
for (; p != NO_NODE; FORWARD (p)) {
if (IS (p, ARGUMENT_LIST)) {
coerce_argument_list (r, SUB (p));
} else if (IS (p, UNIT)) {
SOID_T s;
make_soid (&s, STRONG, MOID (*r), 0);
coerce_unit (p, &s);
FORWARD (*r);
} else if (IS (p, TRIMMER)) {
FORWARD (*r);
}
}
} | false | false | false | false | false | 0 |
nfsd4_init_pnfs(void)
{
int i;
for (i = 0; i < DEVID_HASH_SIZE; i++)
INIT_LIST_HEAD(&nfsd_devid_hash[i]);
nfs4_layout_cache = kmem_cache_create("nfs4_layout",
sizeof(struct nfs4_layout), 0, 0, NULL);
if (!nfs4_layout_cache)
return -ENOMEM;
nfs4_layout_stateid_cache = kmem_cache_create("nfs4_layout_stateid",
sizeof(struct nfs4_layout_stateid), 0, 0, NULL);
if (!nfs4_layout_stateid_cache) {
kmem_cache_destroy(nfs4_layout_cache);
return -ENOMEM;
}
return 0;
} | false | false | false | false | false | 0 |
get_logfile_name(CMD_DATA *p_cmd, int current_nr, void *p_context)
{
DYN_DNS_CLIENT *p_self = (DYN_DNS_CLIENT *) p_context;
if (p_self == NULL)
return RC_INVALID_POINTER;
if (sizeof(p_self->dbg.p_logfilename) < strlen(p_cmd->argv[current_nr]))
return RC_DYNDNS_BUFFER_TOO_SMALL;
strcpy(p_self->dbg.p_logfilename, p_cmd->argv[current_nr]);
return RC_OK;
} | false | true | false | false | false | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.