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 |
|---|---|---|---|---|---|---|
add_child(struct cross_elem *word, struct strie_pair *new_child)
{
struct strie_pair *cur_child = NULL;
if (!word)
return 1;
if (!word->firstchild)
{
word->firstchild = new_child;
return 0;
}
cur_child = word->firstchild;
while (cur_child->brother)
{
cur_child = cur_child->brother;
}
cur_child->brother = new_child;
return 0;
} | false | false | false | false | false | 0 |
main(int argc, char ** argv) {
if (argc < 2 || strcmp(argv[1], "--help") == 0) {
printHelp();
return 0;
}
rollYourOwn(argc-1, argv+1);
return 0;
} | false | false | false | false | false | 0 |
psb_lid_timer_func(unsigned long data)
{
struct drm_psb_private * dev_priv = (struct drm_psb_private *)data;
struct drm_device *dev = (struct drm_device *)dev_priv->dev;
struct timer_list *lid_timer = &dev_priv->lid_timer;
unsigned long irq_flags;
u32 __iomem *lid_state = dev_priv->opregion.lid_state;
u32 pp_status;
if (readl(lid_state) == dev_priv->lid_last_state)
goto lid_timer_schedule;
if ((readl(lid_state)) & 0x01) {
/*lid state is open*/
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) | POWER_TARGET_ON);
do {
pp_status = REG_READ(PP_STATUS);
} while ((pp_status & PP_ON) == 0 &&
(pp_status & PP_SEQUENCE_MASK) != 0);
if (REG_READ(PP_STATUS) & PP_ON) {
/*FIXME: should be backlight level before*/
psb_intel_lvds_set_brightness(dev, 100);
} else {
DRM_DEBUG("LVDS panel never powered up");
return;
}
} else {
psb_intel_lvds_set_brightness(dev, 0);
REG_WRITE(PP_CONTROL, REG_READ(PP_CONTROL) & ~POWER_TARGET_ON);
do {
pp_status = REG_READ(PP_STATUS);
} while ((pp_status & PP_ON) == 0);
}
dev_priv->lid_last_state = readl(lid_state);
lid_timer_schedule:
spin_lock_irqsave(&dev_priv->lid_lock, irq_flags);
if (!timer_pending(lid_timer)) {
lid_timer->expires = jiffies + PSB_LID_DELAY;
add_timer(lid_timer);
}
spin_unlock_irqrestore(&dev_priv->lid_lock, irq_flags);
} | false | false | false | false | false | 0 |
setCfCaption(const char * s)
{
mutexLock(M_STATE);
if (_state.cf.caption == NULL) {
_state.cf.caption = stringNew(s);
} else {
stringAssign(_state.cf.caption,s);
}
mutexUnlock(M_STATE);
} | false | false | false | false | false | 0 |
utf8_len(char *s)
{
int l=0;
while(*s)
if ((*s++&0xc0)!=0x80)
l++;
return l;
} | false | false | false | false | false | 0 |
note_off(long cycles, int channel, int note)
{
uint8_t event[3];
//event[0] = 0x80 | channel;
event[0] = 0x80;
event[1] = note;
event[2] = 0;
if (midi_write_event(cycles, event, 3))
return 1;
return 0;
} | false | false | false | false | false | 0 |
handlemenu(int value)
{
switch (value) {
case MENU_QUIT:
exit(0);
break;
case MENU_RAND:
NewFractals();
Rebuild = 1;
glutPostRedisplay();
break;
case MENU_AXES:
DrawAxes = !DrawAxes;
glutPostRedisplay();
break;
}
} | false | false | false | false | false | 0 |
createmultipartmime(struct mimestruct *m)
{
const char *b=mkboundary(m, m->inputfp1);
struct arg_list *a;
int c;
if (m->mimeencoding == 0)
m->mimeencoding="8bit";
for (a=m->a_first; a; a=a->next)
fprintf(m->outputfp, "%s\n", a->arg);
fprintf(m->outputfp, "Content-Type: %s; boundary=\"%s\"\n"
"Content-Transfer-Encoding: %s\n\n"
RFC2045MIMEMSG
"\n--%s\n",
m->mimetype, b,
m->mimeencoding,
b);
while ((c=getc(m->inputfp1)) != EOF)
putc(c, m->outputfp);
fprintf(m->outputfp, "\n--%s--\n", b);
} | false | false | false | false | false | 0 |
uwb_drp_process_owner(struct uwb_rc *rc, struct uwb_rsv *rsv,
struct uwb_dev *src, struct uwb_ie_drp *drp_ie,
struct uwb_rc_evt_drp *drp_evt)
{
struct device *dev = &rc->uwb_dev.dev;
int status;
enum uwb_drp_reason reason_code;
struct uwb_mas_bm mas;
status = uwb_ie_drp_status(drp_ie);
reason_code = uwb_ie_drp_reason_code(drp_ie);
uwb_drp_ie_to_bm(&mas, drp_ie);
if (status) {
switch (reason_code) {
case UWB_DRP_REASON_ACCEPTED:
uwb_drp_process_owner_accepted(rsv, &mas);
break;
default:
dev_warn(dev, "ignoring invalid DRP IE state (%d/%d)\n",
reason_code, status);
}
} else {
switch (reason_code) {
case UWB_DRP_REASON_PENDING:
uwb_rsv_set_state(rsv, UWB_RSV_STATE_O_PENDING);
break;
case UWB_DRP_REASON_DENIED:
uwb_rsv_set_state(rsv, UWB_RSV_STATE_NONE);
break;
case UWB_DRP_REASON_CONFLICT:
/* resolve the conflict */
bitmap_complement(mas.bm, src->last_availability_bm,
UWB_NUM_MAS);
uwb_drp_handle_conflict_rsv(rc, rsv, drp_evt, drp_ie, &mas);
break;
default:
dev_warn(dev, "ignoring invalid DRP IE state (%d/%d)\n",
reason_code, status);
}
}
} | false | false | false | false | false | 0 |
ReplaceAt(Dlist *l,size_t position,const void *data)
{
DlistElement *rvp;
if (l == NULL || data == NULL) {
if (l)
l->RaiseError("iDlist.ReplaceAt",CONTAINER_ERROR_BADARG);
else
iError.NullPtrError("iDlist.ReplaceAt");
return CONTAINER_ERROR_BADARG;
}
/* Error checking */
if (position >= l->count) {
l->RaiseError("iDlist.ReplaceAt",CONTAINER_ERROR_INDEX,l,position);
return CONTAINER_ERROR_INDEX;
}
if (l->Flags &CONTAINER_READONLY) {
l->RaiseError("iDlist.ReplaceAt",CONTAINER_ERROR_READONLY,l);
return CONTAINER_ERROR_READONLY;
}
/* Position at the right data item */
if (position == l->count-1)
rvp = l->Last;
else {
rvp = l->First;
while (position) {
rvp = rvp->Next;
position--;
}
}
if (l->DestructorFn)
l->DestructorFn(&rvp->Data);
/* Replace the data there */
memcpy(&rvp->Data , data,l->ElementSize);
l->timestamp++;
return 1;
} | false | false | false | false | false | 0 |
luaQ_call(lua_State *L, int na, int nr, QObject *obj)
{
int base = lua_gettop(L) - na;
Q_ASSERT(base > 0);
lua_pushcfunction(L, lua_error_handler);
lua_insert(L, base);
int status = luaQ_pcall(L, na, nr, base, obj);
lua_remove(L, base);
if (status)
lua_error(L);
} | false | false | false | false | false | 0 |
r_realloc(void *dp, size_t size)
{
void *result;
if (size > BIG)
{
errno = EINVAL;
return 0;
}
errno = 0;
result = realloc(dp, (unsigned int) size);
if (!result && !errno)
errno = ENOMEM;
return result;
} | false | false | false | false | false | 0 |
cavan_net_bridge_deinit(struct cavan_net_bridge *bridge)
{
struct cavan_net_bridge_port *port, *head;
head = bridge->head;
if (head)
{
port = head;
while (1)
{
struct cavan_net_bridge_port *next = port->next;
free(port);
if (next == head)
{
break;
}
port = next;
}
}
cavan_thread_deinit(&bridge->thread);
pthread_mutex_destroy(&bridge->lock);
} | false | false | false | false | false | 0 |
explosion (CONST int x, CONST int y, CONST int type, CONST int letter, CONST int n)
{
float i;
int speed;
int color1;
int radius1 = radius (type);
#ifdef NETSUPPORT
if (server)
{
Explosion (x, y, type, letter, n);
return;
}
#endif
for (i = 0; i < RAD (360); i += RAD (360.0) * DIV * DIV / radius1 / radius1 / M_PI)
{
speed = rand () % 3096 + 10;
if (DIV == 1)
color1 = color (type, n, letter) + (rand () % 16);
else
color1 = color (type, n, letter) + (rand () % 32);
addpoint (x * 256, y * 256,
sin (i) * (speed),
cos (i) * (speed),
color1,
rand () % 100 + 10);
}
} | false | false | false | false | false | 0 |
gretl_VAR_plot_impulse_response (GRETL_VAR *var,
int targ, int shock,
int periods, double alpha,
const DATASET *dset,
gretlopt opt)
{
int use_fill = !(opt & OPT_E);
gretl_matrix *resp;
int err = 0;
if (alpha != 0 && (alpha < 0.01 || alpha > 0.5)) {
return E_DATA;
}
resp = gretl_VAR_get_impulse_response(var, targ, shock, periods,
alpha, dset, &err);
if (!err) {
int vtarg = gretl_VAR_get_variable_number(var, targ);
int vshock = gretl_VAR_get_variable_number(var, shock);
int confint = (resp->cols > 1);
FILE *fp;
fp = open_plot_input_file((confint)? PLOT_IRFBOOT : PLOT_REGULAR, &err);
if (!err) {
real_irf_print_plot(resp, dset->varname[vtarg],
dset->varname[vshock],
dataset_period_label(dset),
alpha, confint, use_fill,
fp);
err = finalize_plot_input_file(fp);
}
gretl_matrix_free(resp);
}
return err;
} | false | false | false | false | false | 0 |
set_sample_rate_( long sample_rate )
{
blip_eq_t eq( -32, 8000, sample_rate );
apu.treble_eq( eq );
dac_synth.treble_eq( eq );
apu.volume( 0.135 * fm_gain * gain() );
dac_synth.volume( 0.125 / 256 * fm_gain * gain() );
double factor = Dual_Resampler::setup( oversample_factor, 0.990, fm_gain * gain() );
fm_sample_rate = sample_rate * factor;
RETURN_ERR( blip_buf.set_sample_rate( sample_rate, int (1000 / 60.0 / min_tempo) ) );
blip_buf.clock_rate( clock_rate );
RETURN_ERR( fm.set_rate( fm_sample_rate, base_clock / 7.0 ) );
RETURN_ERR( Dual_Resampler::reset( long (1.0 / 60 / min_tempo * sample_rate) ) );
return 0;
} | false | false | false | false | false | 0 |
bug20080721 (void)
{
mpfr_t x, y, z, t[2];
int inex;
int rnd;
int err = 0;
/* Note: input values have been chosen in a way to select the
* general case. If mpfr_pow is modified, in particular line
* if (y_is_integer && (MPFR_GET_EXP (y) <= 256))
* make sure that this test still does what we want.
*/
mpfr_inits2 (4913, x, y, (mpfr_ptr) 0);
mpfr_inits2 (8, z, t[0], t[1], (mpfr_ptr) 0);
mpfr_set_si (x, -1, MPFR_RNDN);
mpfr_nextbelow (x);
mpfr_set_ui_2exp (y, 1, mpfr_get_prec (y) - 1, MPFR_RNDN);
inex = mpfr_add_ui (y, y, 1, MPFR_RNDN);
MPFR_ASSERTN (inex == 0);
mpfr_set_str_binary (t[0], "-0.10101101e2");
mpfr_set_str_binary (t[1], "-0.10101110e2");
RND_LOOP (rnd)
{
int i, inex0;
i = (rnd == MPFR_RNDN || rnd == MPFR_RNDD || rnd == MPFR_RNDA);
inex0 = i ? -1 : 1;
mpfr_clear_flags ();
inex = mpfr_pow (z, x, y, (mpfr_rnd_t) rnd);
if (__gmpfr_flags != MPFR_FLAGS_INEXACT || ! SAME_SIGN (inex, inex0)
|| MPFR_IS_NAN (z) || mpfr_cmp (z, t[i]) != 0)
{
unsigned int flags = __gmpfr_flags;
printf ("Error in bug20080721 with %s\n",
mpfr_print_rnd_mode ((mpfr_rnd_t) rnd));
printf ("expected ");
mpfr_out_str (stdout, 2, 0, t[i], MPFR_RNDN);
printf (", inex = %d, flags = %u\n", inex0,
(unsigned int) MPFR_FLAGS_INEXACT);
printf ("got ");
mpfr_out_str (stdout, 2, 0, z, MPFR_RNDN);
printf (", inex = %d, flags = %u\n", inex, flags);
err = 1;
}
}
mpfr_clears (x, y, z, t[0], t[1], (mpfr_ptr) 0);
if (err)
exit (1);
} | false | false | false | false | false | 0 |
mca_coll_basic_alltoallw_inter(void *sbuf, int *scounts, int *sdisps,
struct ompi_datatype_t **sdtypes,
void *rbuf, int *rcounts, int *rdisps,
struct ompi_datatype_t **rdtypes,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
int i;
int size;
int err;
char *psnd;
char *prcv;
int nreqs;
MPI_Request *preq;
mca_coll_basic_module_t *basic_module = (mca_coll_basic_module_t*) module;
/* Initialize. */
size = ompi_comm_remote_size(comm);
/* Initiate all send/recv to/from others. */
nreqs = size * 2;
preq = basic_module->mccb_reqs;
/* Post all receives first -- a simple optimization */
for (i = 0; i < size; ++i) {
prcv = ((char *) rbuf) + rdisps[i];
err = MCA_PML_CALL(irecv_init(prcv, rcounts[i], rdtypes[i],
i, MCA_COLL_BASE_TAG_ALLTOALLW,
comm, preq++));
if (OMPI_SUCCESS != err) {
mca_coll_basic_free_reqs(basic_module->mccb_reqs,
nreqs);
return err;
}
}
/* Now post all sends */
for (i = 0; i < size; ++i) {
psnd = ((char *) sbuf) + sdisps[i];
err = MCA_PML_CALL(isend_init(psnd, scounts[i], sdtypes[i],
i, MCA_COLL_BASE_TAG_ALLTOALLW,
MCA_PML_BASE_SEND_STANDARD, comm,
preq++));
if (OMPI_SUCCESS != err) {
mca_coll_basic_free_reqs(basic_module->mccb_reqs,
nreqs);
return err;
}
}
/* Start your engines. This will never return an error. */
MCA_PML_CALL(start(nreqs, basic_module->mccb_reqs));
/* Wait for them all. If there's an error, note that we don't care
* what the error was -- just that there *was* an error. The PML
* will finish all requests, even if one or more of them fail.
* i.e., by the end of this call, all the requests are free-able.
* So free them anyway -- even if there was an error, and return the
* error after we free everything. */
err = ompi_request_wait_all(nreqs, basic_module->mccb_reqs,
MPI_STATUSES_IGNORE);
/* Free the requests. */
mca_coll_basic_free_reqs(basic_module->mccb_reqs, nreqs);
/* All done */
return err;
} | false | false | false | false | false | 0 |
copystr(s)
const char *s;
{
char *str;
str = malloc((size_t) (strlen(s) + 1));
if (str == NULL) {
fprintf(stderr, "recover: cannot malloc for copystr.\n");
exit(-1);
}
strcpy(str, s);
return str;
} | false | false | false | false | false | 0 |
rtl8139_set_mac_address(struct net_device *dev, void *p)
{
struct rtl8139_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
struct sockaddr *addr = p;
if (!is_valid_ether_addr(addr->sa_data))
return -EADDRNOTAVAIL;
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
spin_lock_irq(&tp->lock);
RTL_W8_F(Cfg9346, Cfg9346_Unlock);
RTL_W32_F(MAC0 + 0, cpu_to_le32 (*(u32 *) (dev->dev_addr + 0)));
RTL_W32_F(MAC0 + 4, cpu_to_le32 (*(u32 *) (dev->dev_addr + 4)));
RTL_W8_F(Cfg9346, Cfg9346_Lock);
spin_unlock_irq(&tp->lock);
return 0;
} | false | true | false | false | false | 1 |
DumpHist( fname )
char *fname;
{
FILE *fp;
if( (fp = fopen( fname, "w" )) == NULL )
{
lprintf( stderr, "can not open file '%s'\n", fname );
return;
}
if( WriteHistHeader( fp ) )
{
lprintf( stderr, "can't write to file '%s'\n", fname );
(void) fclose( fp );
return;
}
walk_net_index( DumpNodeHist, fp );
(void) fclose( fp );
} | false | false | false | false | false | 0 |
generate_session_for_leader (CkManager *manager,
CkSessionLeader *leader,
DBusGMethodInvocation *context)
{
gboolean res;
res = ck_session_leader_collect_parameters (leader,
context,
(CkSessionLeaderDoneFunc)collect_parameters_cb,
manager);
if (! res) {
GError *error;
error = g_error_new (CK_MANAGER_ERROR,
CK_MANAGER_ERROR_GENERAL,
"Unable to get information about the calling process");
dbus_g_method_return_error (context, error);
g_error_free (error);
}
} | false | false | false | false | false | 0 |
_mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
{
_mesa_glsl_initialize_variables(instructions, state);
_mesa_glsl_initialize_functions(state);
state->symbols->language_version = state->language_version;
state->current_function = NULL;
state->toplevel_ir = instructions;
/* Section 4.2 of the GLSL 1.20 specification states:
* "The built-in functions are scoped in a scope outside the global scope
* users declare global variables in. That is, a shader's global scope,
* available for user-defined functions and global variables, is nested
* inside the scope containing the built-in functions."
*
* Since built-in functions like ftransform() access built-in variables,
* it follows that those must be in the outer scope as well.
*
* We push scope here to create this nesting effect...but don't pop.
* This way, a shader's globals are still in the symbol table for use
* by the linker.
*/
state->symbols->push_scope();
foreach_list_typed (ast_node, ast, link, & state->translation_unit)
ast->hir(instructions, state);
detect_recursion_unlinked(state, instructions);
state->toplevel_ir = NULL;
} | false | false | false | false | false | 0 |
tpdu_read_header(STREAM* s, uint8* code)
{
uint8 li;
stream_read_uint8(s, li); /* LI */
stream_read_uint8(s, *code); /* Code */
if (*code == X224_TPDU_DATA)
{
/* EOT (1 byte) */
stream_seek(s, 1);
}
else
{
/* DST-REF (2 bytes) */
/* SRC-REF (2 bytes) */
/* Class 0 (1 byte) */
stream_seek(s, 5);
}
return li;
} | false | false | false | false | false | 0 |
gdk_pixbuf_loader_init (GdkPixbufLoader *loader)
{
GdkPixbufLoaderPrivate *priv;
priv = g_new0 (GdkPixbufLoaderPrivate, 1);
priv->width = -1;
priv->height = -1;
loader->priv = priv;
} | false | false | false | false | false | 0 |
test_secret_for_path_sync (Test *test,
gconstpointer used)
{
SecretValue *value;
GError *error = NULL;
const gchar *path;
const gchar *password;
gsize length;
path = "/org/freedesktop/secrets/collection/english/1";
value = secret_service_get_secret_for_dbus_path_sync (test->service, path, NULL, &error);
g_assert_no_error (error);
g_assert (value != NULL);
password = secret_value_get (value, &length);
g_assert_cmpuint (length, ==, 3);
g_assert_cmpstr (password, ==, "111");
password = secret_value_get (value, NULL);
g_assert_cmpstr (password, ==, "111");
secret_value_unref (value);
} | false | false | false | false | false | 0 |
drawText(const FbDrawable &w, int screen, GC gc,
const char* text, size_t len, int x, int y,
Orientation orient) const {
if (!text || !*text || len == 0)
return;
// draw "effects" first
if (m_shadow) {
FbTk::GContext shadow_gc(w);
shadow_gc.setForeground(m_shadow_color);
m_fontimp->drawText(w, screen, shadow_gc.gc(), text, len,
x + m_shadow_offx, y + m_shadow_offy, orient);
} else if (m_halo) {
FbTk::GContext halo_gc(w);
halo_gc.setForeground(m_halo_color);
m_fontimp->drawText(w, screen, halo_gc.gc(), text, len, x + 1, y + 1, orient);
m_fontimp->drawText(w, screen, halo_gc.gc(), text, len, x - 1, y + 1, orient);
m_fontimp->drawText(w, screen, halo_gc.gc(), text, len, x - 1, y - 1, orient);
m_fontimp->drawText(w, screen, halo_gc.gc(), text, len, x + 1, y - 1, orient);
}
m_fontimp->drawText(w, screen, gc, text, len, x, y, orient);
}
} | false | false | false | false | false | 0 |
ssdv_out_headers(ssdv_t *s)
{
uint8_t *b = &s->stbls[s->stbl_len];
ssdv_write_marker(s, J_SOI, 0, 0);
ssdv_write_marker(s, J_APP0, 14, app0);
ssdv_write_marker(s, J_DQT, 65, std_dqt0); /* DQT Luminance */
ssdv_write_marker(s, J_DQT, 65, std_dqt1); /* DQT Chrominance */
/* Build SOF0 header */
b[0] = 8; /* Precision */
b[1] = s->height >> 8;
b[2] = s->height & 0xFF;
b[3] = s->width >> 8;
b[4] = s->width & 0xFF;
b[5] = 3; /* Components (Y'Cb'Cr) */
b[6] = 1; /* Y */
switch(s->mcu_mode)
{
case 0: b[7] = 0x22; break;
case 1: b[7] = 0x12; break;
case 2: b[7] = 0x21; break;
case 3: b[7] = 0x11; break;
}
b[8] = 0x00;
b[9] = 2; /* Cb */
b[10] = 0x11;
b[11] = 0x01;
b[12] = 3; /* Cr */
b[13] = 0x11;
b[14] = 0x01;
ssdv_write_marker(s, J_SOF0, 15, b); /* SOF0 (Baseline DCT) */
ssdv_write_marker(s, J_DHT, 29, std_dht00); /* DHT (DC Luminance) */
ssdv_write_marker(s, J_DHT, 179, std_dht10); /* DHT (AC Luminance) */
ssdv_write_marker(s, J_DHT, 29, std_dht01); /* DHT (DC Chrominance */
ssdv_write_marker(s, J_DHT, 179, std_dht11); /* DHT (AC Chrominance */
ssdv_write_marker(s, J_SOS, 10, sos);
} | false | false | false | false | false | 0 |
xstrappend(char *src, const char *newd)
#endif
{
size_t newsz;
if (!src) {
return xxstrdup(newd, file, line);
}
if (!newd) {
return xxstrdup(src, file, line);
}
newsz = strlen(src) + strlen(newd) + 1;
src = (char *) xxrealloc(src, newsz, file, line);
strcat(src, newd);
return src;
} | false | false | false | false | false | 0 |
glusterd_op_ac_rcvd_commit_op_acc (glusterd_op_sm_event_t *event, void *ctx)
{
dict_t *dict = NULL;
int ret = 0;
gf_boolean_t commit_ack_inject = _gf_true;
glusterd_op_t op = GD_OP_NONE;
op = glusterd_op_get_op ();
GF_ASSERT (event);
if (opinfo.pending_count > 0)
opinfo.pending_count--;
if (opinfo.pending_count > 0)
goto out;
if (op == GD_OP_REPLACE_BRICK) {
dict = glusterd_op_get_ctx ();
if (!dict) {
gf_log (THIS->name, GF_LOG_CRITICAL, "Operation "
"context is not present.");
ret = -1;
goto out;
}
ret = glusterd_op_start_rb_timer (dict);
if (ret) {
gf_log (THIS->name, GF_LOG_ERROR, "Couldn't start "
"replace-brick operation.");
goto out;
}
commit_ack_inject = _gf_false;
goto out;
}
out:
if (commit_ack_inject) {
if (ret)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_RCVD_RJT, NULL);
else if (!opinfo.pending_count)
ret = glusterd_op_sm_inject_event (GD_OP_EVENT_COMMIT_ACC, NULL);
/*else do nothing*/
}
return ret;
} | false | false | false | false | false | 0 |
Remove(unsigned int pos)
{
plist_array_remove_item(_node, pos);
std::vector<Node*>::iterator it = _array.begin();
it += pos;
delete _array.at(pos);
_array.erase(it);
} | false | false | false | false | false | 0 |
operator<<(ostream &o, const ACE_Time_Value &v)
{
char oldFiller = o.fill ();
o.fill ('0');
const timeval *tv = v;
if (tv->tv_sec)
{
o << tv->tv_sec;
if (tv->tv_usec)
o << '.' << std::setw (6) << ACE_STD_NAMESPACE::abs (tv->tv_usec);
}
else if (tv->tv_usec < 0)
o << "-0." << std::setw (6) << - tv->tv_usec;
else
{
o << '0';
if (tv->tv_usec > 0)
o << '.'<< std::setw (6) << tv->tv_usec;
}
o.fill (oldFiller);
return o;
} | false | false | false | false | false | 0 |
_wrap_svn_client_get_changelists(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
char *arg1 = (char *) 0 ;
apr_array_header_t *arg2 = (apr_array_header_t *) 0 ;
svn_depth_t arg3 ;
svn_changelist_receiver_t arg4 = (svn_changelist_receiver_t) 0 ;
void *arg5 = (void *) 0 ;
svn_client_ctx_t *arg6 = (svn_client_ctx_t *) 0 ;
apr_pool_t *arg7 = (apr_pool_t *) 0 ;
apr_pool_t *_global_pool = NULL ;
PyObject *_global_py_pool = NULL ;
PyObject * obj1 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
PyObject * obj4 = 0 ;
PyObject * obj5 = 0 ;
svn_error_t *result = 0 ;
if (svn_swig_py_get_pool_arg(args, SWIGTYPE_p_apr_pool_t,
&_global_py_pool, &_global_pool))
SWIG_fail;
arg7 = _global_pool;
if (!PyArg_ParseTuple(args,(char *)"sOOOO|O:svn_client_get_changelists",&arg1,&obj1,&obj2,&obj3,&obj4,&obj5)) SWIG_fail;
{
arg2 = (apr_array_header_t *) svn_swig_py_seq_to_array(obj1,
sizeof(const char *),
svn_swig_py_unwrap_string,
NULL,
_global_pool);
if (PyErr_Occurred())
SWIG_fail;
}
{
arg3 = (svn_depth_t)SWIG_As_long (obj2);
if (SWIG_arg_fail(svn_argnum_obj2)) {
SWIG_fail;
}
}
{
arg4 = svn_swig_py_changelist_receiver_func;
arg5 = obj3;
}
{
arg6 = (svn_client_ctx_t *)svn_swig_MustGetPtr(obj4, SWIGTYPE_p_svn_client_ctx_t, svn_argnum_obj4);
if (PyErr_Occurred()) {
SWIG_fail;
}
}
if (obj5) {
/* Verify that the user supplied a valid pool */
if (obj5 != Py_None && obj5 != _global_py_pool) {
SWIG_Python_TypeError(SWIG_TypePrettyName(SWIGTYPE_p_apr_pool_t), obj5);
SWIG_arg_fail(svn_argnum_obj5);
SWIG_fail;
}
}
{
svn_swig_py_release_py_lock();
result = (svn_error_t *)svn_client_get_changelists((char const *)arg1,(apr_array_header_t const *)arg2,arg3,arg4,arg5,arg6,arg7);
svn_swig_py_acquire_py_lock();
}
{
if (result != NULL) {
if (result->apr_err != SVN_ERR_SWIG_PY_EXCEPTION_SET)
svn_swig_py_svn_exception(result);
else
svn_error_clear(result);
SWIG_fail;
}
Py_INCREF(Py_None);
resultobj = Py_None;
}
{
Py_XDECREF(_global_py_pool);
}
return resultobj;
fail:
{
Py_XDECREF(_global_py_pool);
}
return NULL;
} | false | false | false | false | false | 0 |
process_line (char *line,
gpointer data)
{
FileData *fdata;
FrCommand *comm = FR_COMMAND (data);
char **fields;
int date_idx;
char *field_month, *field_day, *field_time, *field_year;
char *field_size, *field_name;
g_return_if_fail (line != NULL);
fdata = file_data_new ();
date_idx = _g_line_get_index_from_pattern (line, "%c%c%c %a%n %n%n:%n%n %n%n%n%n");
field_size = _g_line_get_prev_field (line, date_idx, 1);
fdata->size = g_ascii_strtoull (field_size, NULL, 10);
g_free (field_size);
field_month = _g_line_get_next_field (line, date_idx, 1);
field_day = _g_line_get_next_field (line, date_idx, 2);
field_time = _g_line_get_next_field (line, date_idx, 3);
field_year = _g_line_get_next_field (line, date_idx, 4);
fdata->modified = mktime_from_string (field_time, field_day, field_month, field_year);
g_free (field_day);
g_free (field_month);
g_free (field_year);
g_free (field_time);
/* Full path */
field_name = ar_get_last_field (line, date_idx, 5);
fields = g_strsplit (field_name, " -> ", 2);
if (fields[0] == NULL) {
g_strfreev (fields);
g_free (field_name);
file_data_free (fdata);
return;
}
if (fields[1] == NULL) {
g_strfreev (fields);
fields = g_strsplit (field_name, " link to ", 2);
}
if (*(fields[0]) == '/') {
fdata->full_path = g_strdup (fields[0]);
fdata->original_path = fdata->full_path;
} else {
fdata->full_path = g_strconcat ("/", fields[0], NULL);
fdata->original_path = fdata->full_path + 1;
}
if (fields[1] != NULL)
fdata->link = g_strdup (fields[1]);
g_strfreev (fields);
g_free (field_name);
fdata->name = g_strdup (_g_path_get_basename (fdata->full_path));
fdata->path = _g_path_remove_level (fdata->full_path);
if (*fdata->name == 0)
file_data_free (fdata);
else
fr_archive_add_file (FR_ARCHIVE (comm), fdata);
} | false | false | false | false | false | 0 |
ptrarray_remove_index()
{
GPtrArray *array;
guint i;
array = ptrarray_alloc_and_fill(&i);
g_ptr_array_remove_index(array, 0);
if(array->pdata[0] != items[1]) {
return FAILED("First item is not %s, it is %s", items[1],
array->pdata[0]);
}
g_ptr_array_remove_index(array, array->len - 1);
if(array->pdata[array->len - 1] != items[array->len]) {
return FAILED("Last item is not %s, it is %s",
items[array->len - 2], array->pdata[array->len - 1]);
}
g_ptr_array_free(array, TRUE);
return OK;
} | false | false | false | false | false | 0 |
generate_15(DSRDocument *doc)
{
doc->createNewDocument(DSRTypes::DT_BasicTextSR);
doc->createNewSeriesInStudy("1.3.12.2.1107.5.8.1.123456789.199507271758050705910");
doc->setStudyDescription("OFFIS Structured Reporting Samples");
doc->setSeriesDescription("RSNA '95, Siemens, MR");
doc->setPatientName("Neubauer^Anna");
doc->setPatientSex("F");
doc->setPatientBirthDate("19511104");
doc->setPatientID("SMS511104");
doc->getTree().addContentItem(DSRTypes::RT_isRoot, DSRTypes::VT_Container);
doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("DT.05", OFFIS_CODING_SCHEME_DESIGNATOR, "MR Report"));
doc->getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Text, DSRTypes::AM_belowCurrent);
doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("RE.02", OFFIS_CODING_SCHEME_DESIGNATOR, "Request"));
doc->getTree().getCurrentContentItem().setStringValue("MRI: Pelvis");
doc->getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Text);
doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("RE.05", OFFIS_CODING_SCHEME_DESIGNATOR, "Finding"));
doc->getTree().getCurrentContentItem().setStringValue("Visualization of a cervix carcinoma, almost completely permeating into the anterior and posterior labia and extending into the parametrium on the right side. No indication of bladder or rectal involvement. The pelvic wall is free. The tumor does not extend caudally to the vagina. In the vicinity of the left iliac vessel an approximately 1.5 cm round structure can be seen in today's examination, most probably representing the left ovary. If this has been removed because of the ectopic pregnancy, then it is a pathologically enlarged lymph node. There is an ovarian cyst on the right with individual solid contents. Cervical carcinoma permeating into the anterior and posterior labia and extending into the parametrium on the right side.");
doc->getTree().addContentItem(DSRTypes::RT_contains, DSRTypes::VT_Image);
doc->getTree().getCurrentContentItem().setConceptName(DSRCodedEntryValue("IR.02", OFFIS_CODING_SCHEME_DESIGNATOR, "Best illustration of finding"));
doc->getTree().getCurrentContentItem().setImageReference(DSRImageReferenceValue(UID_MRImageStorage, "1.3.12.2.1107.5.8.1.123456789.199507271758050707765"));
doc->getCurrentRequestedProcedureEvidence().addItem("1.3.12.2.1107.5.8.1.123456789.199507271758050705910", "1.3.12.2.1107.5.8.1.123456789.199507271758050706635", UID_MRImageStorage, "1.3.12.2.1107.5.8.1.123456789.199507271758050707765");
} | false | false | false | false | false | 0 |
bmc150_magn_compensate_y(struct bmc150_magn_trim_regs *tregs, s16 y,
u16 rhall)
{
s16 val;
u16 xyz1 = le16_to_cpu(tregs->xyz1);
if (y == BMC150_MAGN_XY_OVERFLOW_VAL)
return S32_MIN;
if (!rhall)
rhall = xyz1;
val = ((s16)(((u16)((((s32)xyz1) << 14) / rhall)) - ((u16)0x4000)));
val = ((s16)((((s32)y) * ((((((((s32)tregs->xy2) * ((((s32)val) *
((s32)val)) >> 7)) + (((s32)val) *
((s32)(((s16)tregs->xy1) << 7)))) >> 9) + ((s32)0x100000)) *
((s32)(((s16)tregs->y2) + ((s16)0xA0)))) >> 12)) >> 13)) +
(((s16)tregs->y1) << 3);
return (s32)val;
} | false | false | false | false | false | 0 |
H5FD_flush(H5FD_t *file, hid_t dxpl_id, unsigned closing)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
HDassert(file && file->cls);
if(file->cls->flush && (file->cls->flush)(file, dxpl_id, closing) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver flush request failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} | false | false | false | false | false | 0 |
it821x_passthru_bmdma_stop(struct ata_queued_cmd *qc)
{
struct ata_port *ap = qc->ap;
struct ata_device *adev = qc->dev;
struct it821x_dev *itdev = ap->private_data;
int unit = adev->devno;
ata_bmdma_stop(qc);
if (itdev->mwdma[unit] != MWDMA_OFF)
it821x_program(ap, adev, itdev->pio[unit]);
} | false | false | false | false | false | 0 |
deleteNextChar() {
int textLen = fText.length();
if (curPos < textLen) {
markPos = curPos + 1;
deleteSelection();
return true;
}
return false;
} | false | false | false | false | false | 0 |
Retrieve(int lineNumber, int lineCaret, int maxChars, int styleClock_,
int linesOnScreen, int linesInDoc) {
AllocateForLevel(linesOnScreen, linesInDoc);
if (styleClock != styleClock_) {
Invalidate(LineLayout::llCheckTextAndStyle);
styleClock = styleClock_;
}
allInvalidated = false;
int pos = -1;
LineLayout *ret = 0;
if (level == llcCaret) {
pos = 0;
} else if (level == llcPage) {
if (lineNumber == lineCaret) {
pos = 0;
} else if (length > 1) {
pos = 1 + (lineNumber % (length - 1));
}
} else if (level == llcDocument) {
pos = lineNumber;
}
if (pos >= 0) {
PLATFORM_ASSERT(useCount == 0);
if (cache && (pos < length)) {
if (cache[pos]) {
if ((cache[pos]->lineNumber != lineNumber) ||
(cache[pos]->maxLineLength < maxChars)) {
delete cache[pos];
cache[pos] = 0;
}
}
if (!cache[pos]) {
cache[pos] = new LineLayout(maxChars);
}
if (cache[pos]) {
cache[pos]->lineNumber = lineNumber;
cache[pos]->inCache = true;
ret = cache[pos];
useCount++;
}
}
}
if (!ret) {
ret = new LineLayout(maxChars);
ret->lineNumber = lineNumber;
}
return ret;
} | false | false | false | false | false | 0 |
_get_config_disk_area(struct cmd_context *cmd,
const struct dm_config_node *cn, struct dm_list *raw_list)
{
struct device_area dev_area;
const char *id_str;
struct id id;
if (!(cn = cn->child)) {
log_error("Empty metadata disk_area section of config file");
return 0;
}
if (!dm_config_get_uint64(cn, "start_sector", &dev_area.start)) {
log_error("Missing start_sector in metadata disk_area section "
"of config file");
return 0;
}
dev_area.start <<= SECTOR_SHIFT;
if (!dm_config_get_uint64(cn, "size", &dev_area.size)) {
log_error("Missing size in metadata disk_area section "
"of config file");
return 0;
}
dev_area.size <<= SECTOR_SHIFT;
if (!dm_config_get_str(cn, "id", &id_str)) {
log_error("Missing uuid in metadata disk_area section "
"of config file");
return 0;
}
if (!id_read_format(&id, id_str)) {
log_error("Invalid uuid in metadata disk_area section "
"of config file: %s", id_str);
return 0;
}
if (!(dev_area.dev = lvmcache_device_from_pvid(cmd, &id, NULL, NULL))) {
char buffer[64] __attribute__((aligned(8)));
if (!id_write_format(&id, buffer, sizeof(buffer)))
log_error("Couldn't find device.");
else
log_error("Couldn't find device with uuid '%s'.",
buffer);
return 0;
}
return _add_raw(raw_list, &dev_area);
} | true | true | false | false | false | 1 |
blk_rq_count_integrity_sg(struct request_queue *q, struct bio *bio)
{
struct bio_vec iv, ivprv = { NULL };
unsigned int segments = 0;
unsigned int seg_size = 0;
struct bvec_iter iter;
int prev = 0;
bio_for_each_integrity_vec(iv, bio, iter) {
if (prev) {
if (!BIOVEC_PHYS_MERGEABLE(&ivprv, &iv))
goto new_segment;
if (!BIOVEC_SEG_BOUNDARY(q, &ivprv, &iv))
goto new_segment;
if (seg_size + iv.bv_len > queue_max_segment_size(q))
goto new_segment;
seg_size += iv.bv_len;
} else {
new_segment:
segments++;
seg_size = iv.bv_len;
}
prev = 1;
ivprv = iv;
}
return segments;
} | false | false | false | false | false | 0 |
cobc_malloc (const size_t size)
{
void *mptr;
mptr = calloc (1, size);
if (!mptr) {
fprintf (stderr, "Cannot allocate %d bytes of memory - Aborting\n", (int)size);
fflush (stderr);
(void)longjmp (cob_jmpbuf, 1);
}
return mptr;
} | false | false | false | false | false | 0 |
kvm_vcpu_yield_to(struct kvm_vcpu *target)
{
struct pid *pid;
struct task_struct *task = NULL;
int ret = 0;
rcu_read_lock();
pid = rcu_dereference(target->pid);
if (pid)
task = get_pid_task(pid, PIDTYPE_PID);
rcu_read_unlock();
if (!task)
return ret;
ret = yield_to(task, 1);
put_task_struct(task);
return ret;
} | false | false | false | false | false | 0 |
process_all_all_constraints (vec<ce_s> lhsc,
vec<ce_s> rhsc)
{
struct constraint_expr *lhsp, *rhsp;
unsigned i, j;
if (lhsc.length () <= 1 || rhsc.length () <= 1)
{
FOR_EACH_VEC_ELT (lhsc, i, lhsp)
FOR_EACH_VEC_ELT (rhsc, j, rhsp)
process_constraint (new_constraint (*lhsp, *rhsp));
}
else
{
struct constraint_expr tmp;
tmp = new_scalar_tmp_constraint_exp ("allalltmp");
FOR_EACH_VEC_ELT (rhsc, i, rhsp)
process_constraint (new_constraint (tmp, *rhsp));
FOR_EACH_VEC_ELT (lhsc, i, lhsp)
process_constraint (new_constraint (*lhsp, tmp));
}
} | false | false | false | false | false | 0 |
genRedisInfoString(void) {
sds info;
time_t uptime = time(NULL)-server.stat_starttime;
int j;
info = sdscatprintf(sdsempty(),
"redis_version:%s\r\n"
"arch_bits:%s\r\n"
"multiplexing_api:%s\r\n"
"uptime_in_seconds:%ld\r\n"
"uptime_in_days:%ld\r\n"
"connected_clients:%d\r\n"
"connected_slaves:%d\r\n"
"used_memory:%zu\r\n"
"changes_since_last_save:%lld\r\n"
"bgsave_in_progress:%d\r\n"
"last_save_time:%ld\r\n"
"bgrewriteaof_in_progress:%d\r\n"
"total_connections_received:%lld\r\n"
"total_commands_processed:%lld\r\n"
"role:%s\r\n"
,REDIS_VERSION,
(sizeof(long) == 8) ? "64" : "32",
aeGetApiName(),
uptime,
uptime/(3600*24),
listLength(server.clients)-listLength(server.slaves),
listLength(server.slaves),
server.usedmemory,
server.dirty,
server.bgsavechildpid != -1,
server.lastsave,
server.bgrewritechildpid != -1,
server.stat_numconnections,
server.stat_numcommands,
server.masterhost == NULL ? "master" : "slave"
);
if (server.masterhost) {
info = sdscatprintf(info,
"master_host:%s\r\n"
"master_port:%d\r\n"
"master_link_status:%s\r\n"
"master_last_io_seconds_ago:%d\r\n"
,server.masterhost,
server.masterport,
(server.replstate == REDIS_REPL_CONNECTED) ?
"up" : "down",
server.master ? ((int)(time(NULL)-server.master->lastinteraction)) : -1
);
}
for (j = 0; j < server.dbnum; j++) {
long long keys, vkeys;
keys = dictSize(server.db[j].dict);
vkeys = dictSize(server.db[j].expires);
if (keys || vkeys) {
info = sdscatprintf(info, "db%d:keys=%lld,expires=%lld\r\n",
j, keys, vkeys);
}
}
return info;
} | false | false | false | false | false | 0 |
vac_truncate_clog(TransactionId frozenXID)
{
TransactionId myXID = GetCurrentTransactionId();
Relation relation;
HeapScanDesc scan;
HeapTuple tuple;
NameData oldest_datname;
bool frozenAlreadyWrapped = false;
/* init oldest_datname to sync with my frozenXID */
namestrcpy(&oldest_datname, get_database_name(MyDatabaseId));
/*
* Scan pg_database to compute the minimum datfrozenxid
*
* Note: we need not worry about a race condition with new entries being
* inserted by CREATE DATABASE. Any such entry will have a copy of some
* existing DB's datfrozenxid, and that source DB cannot be ours because
* of the interlock against copying a DB containing an active backend.
* Hence the new entry will not reduce the minimum. Also, if two
* VACUUMs concurrently modify the datfrozenxid's of different databases,
* the worst possible outcome is that pg_clog is not truncated as
* aggressively as it could be.
*/
relation = heap_open(DatabaseRelationId, AccessShareLock);
scan = heap_beginscan(relation, SnapshotNow, 0, NULL);
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
{
Form_pg_database dbform = (Form_pg_database) GETSTRUCT(tuple);
Assert(TransactionIdIsNormal(dbform->datfrozenxid));
if (TransactionIdPrecedes(myXID, dbform->datfrozenxid))
frozenAlreadyWrapped = true;
else if (TransactionIdPrecedes(dbform->datfrozenxid, frozenXID))
{
frozenXID = dbform->datfrozenxid;
namecpy(&oldest_datname, &dbform->datname);
}
}
heap_endscan(scan);
heap_close(relation, AccessShareLock);
/*
* Do not truncate CLOG if we seem to have suffered wraparound already;
* the computed minimum XID might be bogus. This case should now be
* impossible due to the defenses in GetNewTransactionId, but we keep the
* test anyway.
*/
if (frozenAlreadyWrapped)
{
ereport(WARNING,
(errmsg("some databases have not been vacuumed in over 2 billion transactions"),
errdetail("You may have already suffered transaction-wraparound data loss.")));
return;
}
/* Truncate CLOG to the oldest frozenxid */
TruncateCLOG(frozenXID);
/*
* Update the wrap limit for GetNewTransactionId. Note: this function
* will also signal the postmaster for an(other) autovac cycle if needed.
*/
SetTransactionIdLimit(frozenXID, &oldest_datname);
} | false | false | false | false | false | 0 |
findDefsUsedOutsideOfLoop(Loop *L) {
SmallVector<Instruction *, 8> UsedOutside;
for (auto *Block : L->getBlocks())
// FIXME: I believe that this could use copy_if if the Inst reference could
// be adapted into a pointer.
for (auto &Inst : *Block) {
auto Users = Inst.users();
if (std::any_of(Users.begin(), Users.end(), [&](User *U) {
auto *Use = cast<Instruction>(U);
return !L->contains(Use->getParent());
}))
UsedOutside.push_back(&Inst);
}
return UsedOutside;
} | false | false | false | false | false | 0 |
mxf_primer_pack_add_mapping (MXFPrimerPack * primer, guint16 local_tag,
const MXFUL * ul)
{
MXFUL *uid;
#ifndef GST_DISABLE_GST_DEBUG
gchar str[48];
#endif
guint ltag_tmp = local_tag;
if (primer->mappings == NULL) {
primer->mappings = g_hash_table_new_full (g_direct_hash, g_direct_equal,
(GDestroyNotify) NULL, (GDestroyNotify) _mxf_mapping_ul_free);
}
if (primer->reverse_mappings == NULL) {
primer->reverse_mappings = g_hash_table_new_full ((GHashFunc) mxf_ul_hash,
(GEqualFunc) mxf_ul_is_equal, (GDestroyNotify) _mxf_mapping_ul_free,
(GDestroyNotify) NULL);
}
if (primer->next_free_tag == 0xffff && ltag_tmp == 0) {
GST_ERROR ("Used too many dynamic tags");
return 0;
}
if (ltag_tmp == 0) {
guint tmp;
tmp = GPOINTER_TO_UINT (g_hash_table_lookup (primer->reverse_mappings, ul));
if (tmp == 0) {
ltag_tmp = primer->next_free_tag;
primer->next_free_tag++;
}
} else {
if (g_hash_table_lookup (primer->mappings, GUINT_TO_POINTER (ltag_tmp)))
return ltag_tmp;
}
g_assert (ltag_tmp != 0);
uid = g_slice_new (MXFUL);
memcpy (uid, ul, 16);
GST_DEBUG ("Adding mapping = 0x%04x -> %s", ltag_tmp,
mxf_ul_to_string (uid, str));
g_hash_table_insert (primer->mappings, GUINT_TO_POINTER (ltag_tmp), uid);
uid = g_slice_dup (MXFUL, uid);
g_hash_table_insert (primer->reverse_mappings, uid,
GUINT_TO_POINTER (ltag_tmp));
return ltag_tmp;
} | false | true | false | false | false | 1 |
laggenr (int v, int lag, DATASET *dset)
{
int lno;
if (lag > dset->n || -lag > dset->n) {
gretl_errmsg_sprintf(_("Invalid lag order %d"), lag);
lno = -1;
} else if (lag == 0) {
lno = v;
} else {
lno = get_transform(LAGS, v, lag, 0.0, dset,
VNAMELEN - 3, dset->v);
}
return lno;
} | false | false | false | false | false | 0 |
rndis_reset_response(struct rndis_params *params,
rndis_reset_msg_type *buf)
{
rndis_reset_cmplt_type *resp;
rndis_resp_t *r;
r = rndis_add_response(params, sizeof(rndis_reset_cmplt_type));
if (!r)
return -ENOMEM;
resp = (rndis_reset_cmplt_type *)r->buf;
resp->MessageType = cpu_to_le32(RNDIS_MSG_RESET_C);
resp->MessageLength = cpu_to_le32(16);
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
/* resent information */
resp->AddressingReset = cpu_to_le32(1);
params->resp_avail(params->v);
return 0;
} | false | false | false | false | false | 0 |
hexium_set_input(struct hexium *hexium, int input)
{
union i2c_smbus_data data;
int i = 0;
DEB_D("\n");
for (i = 0; i < 8; i++) {
int adr = hexium_input_select[input].data[i].adr;
data.byte = hexium_input_select[input].data[i].byte;
if (0 != i2c_smbus_xfer(&hexium->i2c_adapter, 0x4e, 0, I2C_SMBUS_WRITE, adr, I2C_SMBUS_BYTE_DATA, &data)) {
return -1;
}
pr_debug("%d: 0x%02x => 0x%02x\n", input, adr, data.byte);
}
return 0;
} | false | false | false | false | false | 0 |
volgen_graph_add_as (volgen_graph_t *graph, const char *type,
const char *format, ...)
{
va_list arg;
xlator_t *xl = NULL;
va_start (arg, format);
xl = xlator_instantiate_va (type, format, arg);
va_end (arg);
if (!xl)
return NULL;
if (volgen_graph_link (graph, xl)) {
xlator_destroy (xl);
return NULL;
} else
glusterfs_graph_set_first (&graph->graph, xl);
return xl;
} | false | false | false | false | false | 0 |
walk_references (GCObject *start, size_t size, void *data)
{
HeapWalkInfo *hwi = (HeapWalkInfo *)data;
hwi->called = 0;
hwi->count = 0;
collect_references (hwi, start, size);
if (hwi->count || !hwi->called)
hwi->callback (start, mono_object_class (start), hwi->called? 0: size, hwi->count, hwi->refs, hwi->offsets, hwi->data);
} | false | false | false | false | false | 0 |
hard_to_d() const {
switch (u_.x.type) {
case j_array:
case j_object:
return size();
case j_bool:
case j_int:
return u_.i.x;
case j_unsigned:
return u_.u.x;
case j_double:
return u_.d.x;
case j_null:
case j_string:
default:
if (!u_.x.x)
return 0;
else
return strtod(reinterpret_cast<const String&>(u_.str).c_str(), 0);
}
} | false | false | false | false | false | 0 |
nemo_file_is_launchable (NemoFile *file)
{
gboolean type_can_be_executable;
type_can_be_executable = FALSE;
if (file->details->mime_type != NULL) {
type_can_be_executable =
g_content_type_can_be_executable (eel_ref_str_peek (file->details->mime_type));
}
return type_can_be_executable &&
nemo_file_can_get_permissions (file) &&
nemo_file_can_execute (file) &&
nemo_file_is_executable (file) &&
!nemo_file_is_directory (file);
} | false | false | false | false | false | 0 |
dock_startup(gboolean reconfig)
{
XSetWindowAttributes attrib;
if (reconfig) {
GList *it;
XSetWindowBorder(obt_display, dock->frame,
RrColorPixel(ob_rr_theme->osd_border_color));
XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth);
RrAppearanceFree(dock->a_frame);
dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_bg);
stacking_add(DOCK_AS_WINDOW(dock));
dock_configure();
dock_hide(TRUE);
for (it = dock->dock_apps; it; it = g_list_next(it))
dock_app_grab_button(it->data, TRUE);
return;
}
STRUT_PARTIAL_SET(dock_strut, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0);
dock = g_slice_new0(ObDock);
dock->obwin.type = OB_WINDOW_CLASS_DOCK;
dock->hidden = TRUE;
dock->dock_map = g_hash_table_new((GHashFunc)window_hash,
(GEqualFunc)window_comp);
attrib.event_mask = DOCK_EVENT_MASK;
attrib.override_redirect = True;
attrib.do_not_propagate_mask = DOCK_NOPROPAGATEMASK;
dock->frame = XCreateWindow(obt_display, obt_root(ob_screen),
0, 0, 1, 1, 0,
RrDepth(ob_rr_inst), InputOutput,
RrVisual(ob_rr_inst),
CWOverrideRedirect | CWEventMask |
CWDontPropagate,
&attrib);
dock->a_frame = RrAppearanceCopy(ob_rr_theme->osd_bg);
XSetWindowBorder(obt_display, dock->frame,
RrColorPixel(ob_rr_theme->osd_border_color));
XSetWindowBorderWidth(obt_display, dock->frame, ob_rr_theme->obwidth);
/* Setting the window type so xcompmgr can tell what it is */
OBT_PROP_SET32(dock->frame, NET_WM_WINDOW_TYPE, ATOM,
OBT_PROP_ATOM(NET_WM_WINDOW_TYPE_DOCK));
window_add(&dock->frame, DOCK_AS_WINDOW(dock));
stacking_add(DOCK_AS_WINDOW(dock));
} | false | false | false | false | false | 0 |
show_pack_info(struct packed_git *p)
{
uint32_t nr_objects, i, chain_histogram[MAX_CHAIN+1];
nr_objects = p->num_objects;
memset(chain_histogram, 0, sizeof(chain_histogram));
for (i = 0; i < nr_objects; i++) {
const unsigned char *sha1;
unsigned char base_sha1[20];
const char *type;
unsigned long size;
unsigned long store_size;
off_t offset;
unsigned int delta_chain_length;
sha1 = nth_packed_object_sha1(p, i);
if (!sha1)
die("internal error pack-check nth-packed-object");
offset = find_pack_entry_one(sha1, p);
if (!offset)
die("internal error pack-check find-pack-entry-one");
type = packed_object_info_detail(p, offset, &size, &store_size,
&delta_chain_length,
base_sha1);
printf("%s ", sha1_to_hex(sha1));
if (!delta_chain_length)
printf("%-6s %lu %"PRIuMAX"\n",
type, size, (uintmax_t)offset);
else {
printf("%-6s %lu %"PRIuMAX" %u %s\n",
type, size, (uintmax_t)offset,
delta_chain_length, sha1_to_hex(base_sha1));
if (delta_chain_length <= MAX_CHAIN)
chain_histogram[delta_chain_length]++;
else
chain_histogram[0]++;
}
}
for (i = 0; i <= MAX_CHAIN; i++) {
if (!chain_histogram[i])
continue;
printf("chain length = %d: %d object%s\n", i,
chain_histogram[i], chain_histogram[i] > 1 ? "s" : "");
}
if (chain_histogram[0])
printf("chain length > %d: %d object%s\n", MAX_CHAIN,
chain_histogram[0], chain_histogram[0] > 1 ? "s" : "");
} | false | false | false | false | false | 0 |
stickynotes_applet_update_icon(StickyNotesApplet *applet)
{
GdkPixbuf *pixbuf1, *pixbuf2;
gint size = applet->panel_size;
if (size > 3)
size = size -3;
/* Choose appropriate icon and size it */
if (applet->prelighted)
pixbuf1 = gdk_pixbuf_scale_simple(stickynotes->icon_prelight, size, size, GDK_INTERP_BILINEAR);
else
pixbuf1 = gdk_pixbuf_scale_simple(stickynotes->icon_normal, size, size, GDK_INTERP_BILINEAR);
/* Shift the icon if pressed */
pixbuf2 = gdk_pixbuf_copy(pixbuf1);
if (applet->pressed)
gdk_pixbuf_scale(pixbuf1, pixbuf2, 0, 0, size, size, 1, 1, 1, 1, GDK_INTERP_BILINEAR);
/* Apply the finished pixbuf to the applet image */
gtk_image_set_from_pixbuf(GTK_IMAGE(applet->w_image), pixbuf2);
g_object_unref(pixbuf1);
g_object_unref(pixbuf2);
} | false | false | false | false | false | 0 |
write_authority_file (XServerLocal *server)
{
XAuthority *authority;
GError *error = NULL;
authority = x_server_get_authority (X_SERVER (server));
if (!authority)
return;
/* Get file to write to if have authority */
if (!server->priv->authority_file)
{
gchar *run_dir, *dir;
run_dir = config_get_string (config_get_instance (), "LightDM", "run-directory");
dir = g_build_filename (run_dir, "root", NULL);
g_free (run_dir);
if (g_mkdir_with_parents (dir, S_IRWXU) < 0)
l_warning (server, "Failed to make authority directory %s: %s", dir, strerror (errno));
server->priv->authority_file = g_build_filename (dir, x_server_get_address (X_SERVER (server)), NULL);
g_free (dir);
}
l_debug (server, "Writing X server authority to %s", server->priv->authority_file);
x_authority_write (authority, XAUTH_WRITE_MODE_REPLACE, server->priv->authority_file, &error);
if (error)
l_warning (server, "Failed to write authority: %s", error->message);
g_clear_error (&error);
} | false | false | false | false | false | 0 |
wait_connectable(int fd)
{
int sockerr;
socklen_t sockerrlen;
int revents;
int ret;
for (;;) {
/*
* Stevens book says, succuessful finish turn on RB_WAITFD_OUT and
* failure finish turn on both RB_WAITFD_IN and RB_WAITFD_OUT.
*/
revents = rb_wait_for_single_fd(fd, RB_WAITFD_IN|RB_WAITFD_OUT, NULL);
if (revents & (RB_WAITFD_IN|RB_WAITFD_OUT)) {
sockerrlen = (socklen_t)sizeof(sockerr);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&sockerr, &sockerrlen);
/*
* Solaris getsockopt(SO_ERROR) return -1 and set errno
* in getsockopt(). Let's return immediately.
*/
if (ret < 0)
break;
if (sockerr == 0) {
if (revents & RB_WAITFD_OUT)
break;
else
continue; /* workaround for winsock */
}
/* BSD and Linux use sockerr. */
errno = sockerr;
ret = -1;
break;
}
if ((revents & (RB_WAITFD_IN|RB_WAITFD_OUT)) == RB_WAITFD_OUT) {
ret = 0;
break;
}
}
return ret;
} | false | false | false | false | false | 0 |
hslider_size(t_hslider *x, t_symbol *s, int ac, t_atom *av)
{
hslider_check_width(x, (int)atom_getintarg(0, ac, av));
if(ac > 1)
x->x_gui.x_h = iemgui_clip_size((int)atom_getintarg(1, ac, av));
iemgui_size((void *)x, &x->x_gui);
} | false | false | false | false | false | 0 |
bld_stmt_evxlst(struct st_t *stp)
{
switch ((byte) stp->stmttyp) {
case S_NULL: case S_STNONE: break;
case S_PROCA: case S_FORASSGN: case S_RHSDEPROCA: case S_NBPROCA:
/* know if lhs IS form bit or array select - will be split */
bld_lhs_impl_evxlst(stp->st.spra.lhsx);
bld_rhs_impl_evxlst(stp->st.spra.rhsx);
break;
case S_IF:
bld_rhs_impl_evxlst(stp->st.sif.condx);
bld_stlst_evxlst(stp->st.sif.thenst);
if (stp->st.sif.elsest != NULL) bld_stmt_evxlst(stp->st.sif.elsest);
break;
case S_CASE:
/* case is special case because selection and case item expressions */
/* need to be added to list */
bld_case_evxlst(stp);
break;
case S_WAIT:
bld_stlst_evxlst(stp->st.swait.lpst);
break;
case S_FOREVER:
bld_stlst_evxlst(stp->st.swh.lpst);
break;
case S_REPEAT:
if (stp->st.srpt.repx != NULL)
{
bld_rhs_impl_evxlst(stp->st.srpt.repx);
}
bld_stlst_evxlst(stp->st.srpt.repst);
break;
case S_WHILE:
if (stp->st.swh.lpx != NULL)
{
bld_rhs_impl_evxlst(stp->st.swh.lpx);
}
bld_stlst_evxlst(stp->st.swh.lpst);
break;
case S_FOR:
{
struct for_t *frs;
/* notice for statement must use temporaries of right width */
frs = stp->st.sfor;
bld_stmt_evxlst(frs->forassgn);
if (frs->fortermx != NULL) bld_rhs_impl_evxlst(frs->fortermx);
bld_stmt_evxlst(frs->forinc);
bld_stlst_evxlst(frs->forbody);
}
break;
case S_DELCTRL:
/* notice if implicit @(*) form event ctrl - implicit expr list */
/* already built - but this needs to also add to any containing */
/* list is union of all contained implicit dctrl lists */
if (stp->st.sdc->actionst != NULL)
{
bld_stlst_evxlst(stp->st.sdc->actionst);
}
break;
case S_NAMBLK:
bld_stlst_evxlst(stp->st.snbtsk->tskst);
break;
case S_UNBLK:
bld_stlst_evxlst(stp->st.sbsts);
break;
case S_UNFJ:
{
register int32 fji;
struct st_t *fjstp;
/* 1 sub stmt only, for unnamed begin-end will be unnamed block */
for (fji = 0;; fji++)
{
if ((fjstp = stp->st.fj.fjstps[fji]) == NULL) break;
/* SJM 09/24/01 - this can be 2 stmts for for (for assgn then for) */
bld_stlst_evxlst(fjstp);
}
}
break;
case S_TSKCALL:
/* task enable out ports are lhs exprs (but sel ndx needs to go in list) */
/* does nothing for system tasks */
bld_tskenable_evxlst(stp);
break;
case S_QCONTA: case S_QCONTDEA:
/* SJM 06/01/04 - LOOKATME - think quasi-cont stmts can't cause triggers */
/* because rhs changes outside of proc time */
break;
case S_DSABLE: case S_CAUSE:
/* SJM 06/01/04 - LOOKATME - think cause is lhs expr here */
break;
default: __case_terr(__FILE__, __LINE__);
}
} | false | false | false | false | false | 0 |
InitializeGUCOptionsFromEnvironment(void)
{
char *env;
long stack_rlimit;
env = getenv("PGPORT");
if (env != NULL)
SetConfigOption("port", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
env = getenv("PGDATESTYLE");
if (env != NULL)
SetConfigOption("datestyle", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
env = getenv("PGCLIENTENCODING");
if (env != NULL)
SetConfigOption("client_encoding", env, PGC_POSTMASTER, PGC_S_ENV_VAR);
/*
* rlimit isn't exactly an "environment variable", but it behaves about
* the same. If we can identify the platform stack depth rlimit, increase
* default stack depth setting up to whatever is safe (but at most 2MB).
*/
stack_rlimit = get_stack_depth_rlimit();
if (stack_rlimit > 0)
{
long new_limit = (stack_rlimit - STACK_DEPTH_SLOP) / 1024L;
if (new_limit > 100)
{
char limbuf[16];
new_limit = Min(new_limit, 2048);
sprintf(limbuf, "%ld", new_limit);
SetConfigOption("max_stack_depth", limbuf,
PGC_POSTMASTER, PGC_S_ENV_VAR);
}
}
} | true | true | false | false | true | 1 |
glf3_view(glfFile fp)
{
glf3_header_t *h;
char *name;
glf3_t *g3;
int len;
h = glf3_header_read(fp);
g3 = glf3_init1();
while ((name = glf3_ref_read(fp, &len)) != 0) {
int pos = 0;
while (glf3_read1(fp, g3) && g3->rtype != GLF3_RTYPE_END) {
pos += g3->offset;
glf3_view1(name, g3, pos);
}
free(name);
}
glf3_header_destroy(h);
glf3_destroy1(g3);
} | false | false | false | false | false | 0 |
_narrow(CORBA::Object_ptr obj)
{
if( !obj || obj->_NP_is_nil() ) return _nil();
if( obj->_NP_is_pseudo() ) {
_ptr_type e = (_ptr_type) obj->_ptrToObjRef(_PD_repoId);
if (e) {
e->_NP_incrRefCount();
return e;
}
else {
return _nil();
}
}
else {
_ptr_type e = (_ptr_type) obj->_PR_getobj()->_realNarrow(_PD_repoId);
return e ? e : _nil();
}
} | false | false | false | false | false | 0 |
wait_block_group_cache_done(struct btrfs_block_group_cache *cache)
{
struct btrfs_caching_control *caching_ctl;
int ret = 0;
caching_ctl = get_caching_control(cache);
if (!caching_ctl)
return (cache->cached == BTRFS_CACHE_ERROR) ? -EIO : 0;
wait_event(caching_ctl->wait, block_group_cache_done(cache));
if (cache->cached == BTRFS_CACHE_ERROR)
ret = -EIO;
put_caching_control(caching_ctl);
return ret;
} | false | false | false | false | false | 0 |
globus_gss_assist_will_handle_restrictions(
OM_uint32 * minor_status,
gss_ctx_id_t * context_handle)
{
OM_uint32 maj_stat;
gss_buffer_desc oid_buffer;
gss_OID_set_desc oid_set;
static char * _function_name_ =
"globus_gss_assist_will_handle_restrictions";
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_ENTER;
oid_set.count = 1;
oid_set.elements = (gss_OID) gss_proxycertinfo_extension;
oid_buffer.value = (void *) &oid_set;
oid_buffer.length = 1;
maj_stat = gss_set_sec_context_option(
minor_status,
context_handle,
(gss_OID) GSS_APPLICATION_WILL_HANDLE_EXTENSIONS,
&oid_buffer);
GLOBUS_I_GSI_GSS_ASSIST_DEBUG_EXIT;
return maj_stat;
} | false | false | false | false | false | 0 |
gwy_data_field_duplicate_real(GObject *object)
{
GwyDataField *data_field, *duplicate;
g_return_val_if_fail(GWY_IS_DATA_FIELD(object), NULL);
data_field = GWY_DATA_FIELD(object);
duplicate = gwy_data_field_new_alike(data_field, FALSE);
memcpy(duplicate->data, data_field->data,
data_field->xres*data_field->yres*sizeof(gdouble));
duplicate->cached = data_field->cached;
memcpy(duplicate->cache, data_field->cache,
GWY_DATA_FIELD_CACHE_SIZE*sizeof(gdouble));
return (GObject*)duplicate;
} | false | true | false | false | false | 1 |
dpm_sysfs_add(struct device *dev)
{
int rc;
rc = sysfs_create_group(&dev->kobj, &pm_attr_group);
if (rc)
return rc;
if (pm_runtime_callbacks_present(dev)) {
rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group);
if (rc)
goto err_out;
}
if (device_can_wakeup(dev)) {
rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group);
if (rc)
goto err_runtime;
}
if (dev->power.set_latency_tolerance) {
rc = sysfs_merge_group(&dev->kobj,
&pm_qos_latency_tolerance_attr_group);
if (rc)
goto err_wakeup;
}
return 0;
err_wakeup:
sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group);
err_runtime:
sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group);
err_out:
sysfs_remove_group(&dev->kobj, &pm_attr_group);
return rc;
} | false | false | false | false | false | 0 |
image_loader_delay_area_ready(ImageLoader *il, gboolean enable)
{
g_mutex_lock(il->data_mutex);
il->delay_area_ready = enable;
if (!enable)
{
/* send delayed */
GList *list, *work;
list = g_list_reverse(il->area_param_delayed_list);
il->area_param_delayed_list = NULL;
g_mutex_unlock(il->data_mutex);
work = list;
while (work)
{
ImageLoaderAreaParam *par = work->data;
work = work->next;
g_signal_emit(il, signals[SIGNAL_AREA_READY], 0, par->x, par->y, par->w, par->h);
g_free(par);
}
g_list_free(list);
}
else
{
/* just unlock */
g_mutex_unlock(il->data_mutex);
}
} | false | false | false | false | false | 0 |
FetchDuff(uint32 P, uint32 envelope) {
uint32 duff;
duff = IRAM[((IRAM[0x46 + (P << 3)] + (PlayIndex[P] >> TOINDEX)) & 0xFF) >> 1];
if ((IRAM[0x46 + (P << 3)] + (PlayIndex[P] >> TOINDEX)) & 1)
duff >>= 4;
duff &= 0xF;
duff = (duff * envelope) >> 16;
return(duff);
} | false | false | false | false | false | 0 |
bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx)
{
struct bgx *bgx;
bgx = bgx_vnic[(node * MAX_BGX_PER_CN88XX) + bgx_idx];
if (!bgx)
return 0;
if (idx > 8)
lmac = 0;
return bgx_reg_read(bgx, lmac, BGX_CMRX_RX_STAT0 + (idx * 8));
} | false | false | false | false | false | 0 |
main(int argc, char *argv[])
{
string name = argv[0];
if(argc != 4)
{
cout << "Try to type :"<< endl
<< " ./decypher <cypherText> <key> <mode>" << endl
<< " Mode = ('-sub') | ('-tran') | ('-all')"<<endl;
exit(-1);
}
Decryption decryption;
string cypherText, key, plainText;
cypherText = readFile(argv[1]);
cout << cypherText << endl;
key = readFile(argv[2]);
cout << key << endl;
string mode = argv[3];
if(mode == "-sub")
plainText = decryption.decrypt(cypherText, key, SUBSTITUTION);
else if(mode == "-tran")
plainText= decryption.decrypt(cypherText ,key, TRANSPOSITION);
else if(mode == "-all")
{
plainText= decryption.decrypt(cypherText ,key, PRODUCT);
}
else
{
cout << "invalid comand" << endl;
exit(-1);
}
cout <<"["<<plainText<<"]"<< endl;
writeToFile(plainText);
return 0;
} | false | false | false | false | false | 0 |
get_ticks(__u32 *ticks, const char *str)
{
unsigned t;
if(get_time(&t, str))
return -1;
if (tc_core_time2big(t)) {
fprintf(stderr, "Illegal %u time (too large)\n", t);
return -1;
}
*ticks = tc_core_time2tick(t);
return 0;
} | false | false | false | false | false | 0 |
max77802_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm)
{
struct max77802_rtc_info *info = dev_get_drvdata(dev);
u8 data[RTC_NR_TIME];
unsigned int val;
int ret;
mutex_lock(&info->lock);
ret = max77802_rtc_update(info, MAX77802_RTC_READ);
if (ret < 0)
goto out;
ret = regmap_bulk_read(info->max77802->regmap,
MAX77802_ALARM1_SEC, data, RTC_NR_TIME);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read alarm reg(%d)\n",
__func__, __LINE__, ret);
goto out;
}
max77802_rtc_data_to_tm(data, &alrm->time, info->rtc_24hr_mode);
alrm->enabled = 0;
ret = regmap_read(info->max77802->regmap,
MAX77802_RTC_AE1, &val);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read alarm enable(%d)\n",
__func__, __LINE__, ret);
goto out;
}
if (val)
alrm->enabled = 1;
alrm->pending = 0;
ret = regmap_read(info->max77802->regmap, MAX77802_REG_STATUS2, &val);
if (ret < 0) {
dev_err(info->dev, "%s:%d fail to read status2 reg(%d)\n",
__func__, __LINE__, ret);
goto out;
}
if (val & (1 << 2)) /* RTCA1 */
alrm->pending = 1;
out:
mutex_unlock(&info->lock);
return 0;
} | false | false | false | false | false | 0 |
genie_int_case_unit (NODE_T * p, int k, int *count)
{
if (p == NO_NODE) {
return (A68_FALSE);
} else {
if (IS (p, UNIT)) {
if (k == *count) {
EXECUTE_UNIT_TRACE (p);
return (A68_TRUE);
} else {
(*count)++;
return (A68_FALSE);
}
} else {
if (genie_int_case_unit (SUB (p), k, count)) {
return (A68_TRUE);
} else {
return (genie_int_case_unit (NEXT (p), k, count));
}
}
}
} | false | false | false | false | false | 0 |
acdInFileSave(const AjPStr infname, const AjPStr objname,
AjBool reset)
{
static AjBool usefile = AJFALSE;
static ajint called = 0;
AjBool useobj = ajTrue;
if(!called)
{
if(ajNamGetValueC("acdfilename", &acdTmpStr))
ajStrToBool(acdTmpStr, &usefile);
called = 1;
}
if(acdInFileSet) /* already have a name */
return ajFalse;
if(!reset && ajStrGetLen(acdInFName)) /* have a name, no reset forced */
return ajFalse;
if(usefile)
{
useobj = ajFalse;
if(ajStrMatchC(infname, "stdin"))
useobj = ajTrue;
}
acdLog("acdInFileSave (%S,%S) reset: %B usefile: %B, saved name '%S'\n",
infname, objname, reset, usefile, acdInFName);
if(useobj && ajStrGetLen(objname))
{
if(!ajStrGetLen(objname))
return ajFalse;
ajStrAssignS(&acdInFName, objname);
ajFilenameTrimAll(&acdInFName);
ajStrFmtLower(&acdInFName);
}
else
{
if(!ajStrGetLen(infname))
return ajFalse;
ajStrAssignS(&acdInFName, infname);
ajFilenameTrimAll(&acdInFName);
if(useobj)
ajStrFmtLower(&acdInFName);
}
if(reset)
acdInFileSet = ajTrue;
acdLog("acdInFileSave (%S, %S) input file set to '%S'\n",
infname, objname, acdInFName);
return ajTrue;
} | false | false | false | false | false | 0 |
distribute_remainder(sLad *lad, SymRegion *lr_region_head)
{
int order;
SemTree *div_order;
SemTree *tmp;
SymRegion *region;
SemTree *rem;
SemTree *n1;
SemTree *alpha;
SemTree *beta;
SemTree *db;
SemTree *de;
const SemTree *const_one = lad->sym_const_one;
SemTree *new_begin;
SemTree *new_end;
/* rem = gsrng - gsrngd * div_num */
tmp = make_semtree(OPE_MUL, lad->sym_gsrngd, lad->sym_div_num);
rem = make_semtree(OPE_SUB, lad->sym_gsrng, tmp);
n1 = make_semtree(OPE_SUB, lad->sym_div_num, rem);
#ifdef DEBUG_SYM_LAD
fprintf(stderr, "rem = ");
fput_semtree(stderr, semtree_process_divide(semtree_dup(rem)));
fprintf(stderr, "\n");
fprintf(stderr, "n1 = ");
fput_semtree(stderr, semtree_process_divide(semtree_dup(rem)));
fprintf(stderr, "\n");
#endif
region = lr_region_head;
for(order = 0; order < lad->div_num; order++) {
if (region == NULL) {
continue;
}
div_order = make_semtree_const_int(order);
/* alpha = (div_order + rem) / div_num */
tmp = make_semtree(OPE_ADD, div_order, rem);
alpha = make_semtree(OPE_DIV, tmp, lad->sym_div_num);
/* beta = div_order - n1 */
beta = make_semtree(OPE_SUB, div_order, n1);
db = make_semtree(OPE_MUL, alpha, beta);
tmp = make_semtree(OPE_ADD, beta, const_one);
de = make_semtree(OPE_MUL, alpha, tmp);
#ifdef DEBUG_SYM_LAD
fprintf(stderr, "[order=%d] ", order);
semtree_process_divide(alpha);
fprintf(stderr, "alpha = ");
fput_semtree(stderr, alpha);
fprintf(stderr, ", ");
semtree_process_divide(beta);
fprintf(stderr, "beta = ");
fput_semtree(stderr, beta);
fprintf(stderr, ", ");
semtree_process_divide(db);
fprintf(stderr, "db = ");
fput_semtree(stderr, db);
fprintf(stderr, ", ");
semtree_process_divide(de);
fprintf(stderr, "de = ");
fput_semtree(stderr, de);
fprintf(stderr, "\n");
#endif
new_begin = make_semtree(OPE_ADD, region->begin, db);
semtree_process_divide(new_begin);
region->begin = new_begin;
if (order != lad->div_num - 1) {
new_end = make_semtree(OPE_ADD, region->end, de);
semtree_process_divide(new_end);
region->end = new_end;
}
region = region->next;
}
} | false | false | false | false | false | 0 |
weather_source_find_location_by_coords (GWeatherLocation *start,
gdouble latitude,
gdouble longitude)
{
GWeatherLocation *location, **children;
gint ii;
if (!start)
return NULL;
location = start;
if (gweather_location_has_coords (location)) {
gdouble lat, lon;
gweather_location_get_coords (location, &lat, &lon);
if (lat == latitude && lon == longitude)
return location;
}
children = gweather_location_get_children (location);
for (ii = 0; children[ii]; ii++) {
location = weather_source_find_location_by_coords (children[ii], latitude, longitude);
if (location)
return location;
}
return NULL;
} | false | false | false | false | false | 0 |
s2b(const char *s, int nd0, int nd, ULong y9)
{
Bigint *b;
int i, k;
Long x, y;
x = (nd + 8) / 9;
for(k = 0, y = 1; x > y; y <<= 1, k++) ;
b = Balloc(k);
if (b == NULL)
return NULL;
b->x[0] = y9;
b->wds = 1;
if (nd <= 9)
return b;
s += 9;
for (i = 9; i < nd0; i++) {
b = multadd(b, 10, *s++ - '0');
if (b == NULL)
return NULL;
}
s++;
for(; i < nd; i++) {
b = multadd(b, 10, *s++ - '0');
if (b == NULL)
return NULL;
}
return b;
} | false | false | false | false | false | 0 |
check_options(diff_opt_t* options)
{
/*--------------------------------------------------------------
* check for mutually exclusive options
*--------------------------------------------------------------*/
/* check between -d , -p, --use-system-epsilon.
* These options are mutually exclusive.
*/
if ((options->d + options->p + options->use_system_epsilon) > 1)
{
printf("%s error: -d, -p and --use-system-epsilon options are mutually-exclusive;\n", PROGRAMNAME);
printf("use no more than one.\n");
printf("Try '-h' or '--help' option for more information or see the %s entry in the 'HDF5 Reference Manual'.\n", PROGRAMNAME);
h5diff_exit(EXIT_FAILURE);
}
} | false | false | false | false | false | 0 |
projid_m_show(struct seq_file *seq, void *v)
{
struct user_namespace *ns = seq->private;
struct uid_gid_extent *extent = v;
struct user_namespace *lower_ns;
projid_t lower;
lower_ns = seq_user_ns(seq);
if ((lower_ns == ns) && lower_ns->parent)
lower_ns = lower_ns->parent;
lower = from_kprojid(lower_ns, KPROJIDT_INIT(extent->lower_first));
seq_printf(seq, "%10u %10u %10u\n",
extent->first,
lower,
extent->count);
return 0;
} | false | false | false | false | false | 0 |
format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2)
{
std::vector<Any> args;
args.push_back(value1);
args.push_back(value2);
format(result, fmt, args);
} | false | false | false | false | false | 0 |
vector_linear_float (float* v,const float* v1,const float alpha,const float* v2,size_t n)
{
size_t i;
for (i=0;i<n;i++)
v[i] = v1[i]+alpha*v2[i];
} | false | false | false | false | false | 0 |
agp_amd64_mod_init(void)
{
#ifndef MODULE
if (gart_iommu_aperture)
return agp_bridges_found ? 0 : -ENODEV;
#endif
return agp_amd64_init();
} | false | false | false | false | false | 0 |
SendArrayInfoRequests()
{
for(int i=fileset_for_info->curr_index(); i<fileset_for_info->count(); i++)
{
FileInfo *fi=(*fileset_for_info)[i];
bool sent=false;
if((fi->need&fi->DATE) && conn->mdtm_supported && use_mdtm)
{
conn->SendCmd2("MDTM",ExpandTildeStatic(fi->name));
expect->Push(Expect::MDTM);
sent=true;
}
if((fi->need&fi->SIZE) && conn->size_supported && use_size)
{
conn->SendCmd2("SIZE",ExpandTildeStatic(fi->name));
expect->Push(Expect::SIZE);
sent=true;
}
if(!sent)
{
if(i==fileset_for_info->curr_index())
fileset_for_info->next(); // if it is the first one, just skip it.
else
break; // otherwise, wait until it is the first.
}
else
{
if(GetFlag(SYNC_MODE))
break; // don't flood the queues.
}
}
} | false | false | false | false | false | 0 |
db_load_from_stream(dns_db_t *db, FILE *fp) {
isc_result_t result;
dns_rdatacallbacks_t callbacks;
dns_rdatacallbacks_init(&callbacks);
result = dns_db_beginload(db, &callbacks);
if (result != ISC_R_SUCCESS)
fatal("dns_db_beginload failed: %s", isc_result_totext(result));
result = dns_master_loadstream(fp, name, name, rdclass, 0,
&callbacks, mctx);
if (result != ISC_R_SUCCESS)
fatal("can't load from input: %s", isc_result_totext(result));
result = dns_db_endload(db, &callbacks);
if (result != ISC_R_SUCCESS)
fatal("dns_db_endload failed: %s", isc_result_totext(result));
} | false | false | false | false | false | 0 |
tp_tests_backend_remove_account (TpTestsBackend *self,
gpointer handle)
{
TpTestsBackendPrivate *priv = self->priv;
AccountData *data;
if (g_list_find (priv->accounts, handle) == NULL)
{
return;
}
/* Remove the account from the list of accounts */
priv->accounts = g_list_remove (priv->accounts, handle);
data = (AccountData *) handle;
/* Make sure all dbus trafic with account's connection is done */
tp_tests_proxy_run_until_dbus_queue_processed (data->client_conn);
/* Remove the account from the account manager */
tp_tests_simple_account_manager_remove_account (priv->account_manager,
data->object_path);
tp_tests_simple_account_removed (data->account);
/* Disconnect it */
tp_base_connection_change_status (data->base_connection,
TP_CONNECTION_STATUS_DISCONNECTED, TP_CONNECTION_STATUS_REASON_REQUESTED);
tp_dbus_daemon_unregister_object (priv->daemon, data->account);
tp_clear_object (&data->account);
tp_clear_object (&data->base_connection);
tp_clear_object (&data->client_conn);
g_free (data->object_path);
} | false | false | false | false | false | 0 |
image_load_done_cb(ImageLoader *il, gpointer data)
{
ImageWindow *imd = data;
DEBUG_1("%s image done", get_exec_time());
if (options->image.enable_read_ahead && imd->image_fd && !imd->image_fd->pixbuf && image_loader_get_pixbuf(imd->il))
{
imd->image_fd->pixbuf = g_object_ref(image_loader_get_pixbuf(imd->il));
image_cache_set(imd, imd->image_fd);
}
/* call the callback triggered by image_state after fd->pixbuf is set */
g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
image_state_unset(imd, IMAGE_STATE_LOADING);
if (!image_loader_get_pixbuf(imd->il))
{
GdkPixbuf *pixbuf;
pixbuf = pixbuf_inline(PIXBUF_INLINE_BROKEN);
image_change_pixbuf(imd, pixbuf, image_zoom_get(imd), FALSE);
g_object_unref(pixbuf);
imd->unknown = TRUE;
}
else if (imd->delay_flip &&
image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il))
{
g_object_set(G_OBJECT(imd->pr), "complete", FALSE, NULL);
image_change_pixbuf(imd, image_loader_get_pixbuf(imd->il), image_zoom_get(imd), FALSE);
}
image_loader_free(imd->il);
imd->il = NULL;
// image_post_process(imd, TRUE);
image_read_ahead_start(imd);
} | false | false | false | false | false | 0 |
v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
{
int retval = 0;
struct posix_acl *pacl, *dacl;
struct v9fs_session_info *v9ses;
v9ses = v9fs_inode2v9ses(inode);
if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
set_cached_acl(inode, ACL_TYPE_DEFAULT, NULL);
set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
return 0;
}
/* get the default/access acl values and cache them */
dacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_DEFAULT);
pacl = __v9fs_get_acl(fid, POSIX_ACL_XATTR_ACCESS);
if (!IS_ERR(dacl) && !IS_ERR(pacl)) {
set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl);
set_cached_acl(inode, ACL_TYPE_ACCESS, pacl);
} else
retval = -EIO;
if (!IS_ERR(dacl))
posix_acl_release(dacl);
if (!IS_ERR(pacl))
posix_acl_release(pacl);
return retval;
} | false | false | false | false | false | 0 |
isNullAction(char *s)
#else
int isNullAction(s)
char *s;
#endif
{
char *p;
for (p=s; *p != '\0' ; p++) {
if (*p != ';' && *p !=' ') return 0;
};
return 1;
} | false | false | false | false | false | 0 |
GetCalling() {
if (IsDeadCheck("v8::Context::GetCalling()")) return Local<Context>();
i::Handle<i::Object> calling = i::Top::GetCallingGlobalContext();
if (calling.is_null()) return Local<Context>();
i::Handle<i::Context> context = i::Handle<i::Context>::cast(calling);
return Utils::ToLocal(context);
} | false | false | false | false | false | 0 |
saved_date(char *date, char *header)
{
char *d, *p, c;
MESSAGECACHE elt;
*date = '\0';
if((toupper((unsigned char)(*(d = header)))
== 'D' && !strncmp(d, "date:", 5))
|| (d = srchstr(header, "\015\012date:"))){
for(d += 7; *d == ' '; d++)
; /* skip white space */
if((p = strstr(d, "\015\012")) != NULL){
for(; p > d && *p == ' '; p--)
; /* skip white space */
c = *p;
*p = '\0'; /* tie off internal date */
}
if(mail_parse_date(&elt, (unsigned char *) d)) /* normalize it */
mail_date(date, &elt);
if(p) /* restore header */
*p = c;
}
} | false | false | false | false | true | 1 |
ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
int type, __u64 start, __u64 end,
__u64 real_end,
const char *descr,
ext2fs_generic_bitmap *ret)
{
ext2fs_generic_bitmap bitmap;
struct ext2_bitmap_ops *ops;
ext2_ino_t num_dirs;
errcode_t retval;
if (!type)
type = EXT2FS_BMAP64_BITARRAY;
switch (type) {
case EXT2FS_BMAP64_BITARRAY:
ops = &ext2fs_blkmap64_bitarray;
break;
case EXT2FS_BMAP64_RBTREE:
ops = &ext2fs_blkmap64_rbtree;
break;
case EXT2FS_BMAP64_AUTODIR:
retval = ext2fs_get_num_dirs(fs, &num_dirs);
if (retval || num_dirs > (fs->super->s_inodes_count / 320))
ops = &ext2fs_blkmap64_bitarray;
else
ops = &ext2fs_blkmap64_rbtree;
break;
default:
return EINVAL;
}
retval = ext2fs_get_memzero(sizeof(struct ext2fs_struct_generic_bitmap),
&bitmap);
if (retval)
return retval;
#ifdef BMAP_STATS
if (gettimeofday(&bitmap->stats.created,
(struct timezone *) NULL) == -1) {
perror("gettimeofday");
ext2fs_free_mem(&bitmap);
return 1;
}
bitmap->stats.type = type;
#endif
/* XXX factor out, repeated in copy_bmap */
bitmap->magic = magic;
bitmap->fs = fs;
bitmap->start = start;
bitmap->end = end;
bitmap->real_end = real_end;
bitmap->bitmap_ops = ops;
bitmap->cluster_bits = 0;
switch (magic) {
case EXT2_ET_MAGIC_INODE_BITMAP64:
bitmap->base_error_code = EXT2_ET_BAD_INODE_MARK;
break;
case EXT2_ET_MAGIC_BLOCK_BITMAP64:
bitmap->base_error_code = EXT2_ET_BAD_BLOCK_MARK;
bitmap->cluster_bits = fs->cluster_ratio_bits;
break;
default:
bitmap->base_error_code = EXT2_ET_BAD_GENERIC_MARK;
}
if (descr) {
retval = ext2fs_get_mem(strlen(descr)+1, &bitmap->description);
if (retval) {
ext2fs_free_mem(&bitmap);
return retval;
}
strcpy(bitmap->description, descr);
} else
bitmap->description = 0;
retval = bitmap->bitmap_ops->new_bmap(fs, bitmap);
if (retval) {
ext2fs_free_mem(&bitmap->description);
ext2fs_free_mem(&bitmap);
return retval;
}
*ret = bitmap;
return 0;
} | false | false | false | false | false | 0 |
load_actions_file(const gchar * filename)
{
FILE *file;
gchar *line = NULL;
size_t nb = 0;
if (filename == NULL)
return;
file = fopen(filename, "r");
if (file == NULL) {
perror(filename);
return;
}
/* Search the actions separator. */
while (getdelim(&line, &nb, '\n', file) != -1 &&
g_str_equal(line, SEPARATOR_ACTIONS) == FALSE);
if (g_str_equal(line, SEPARATOR_ACTIONS) == FALSE) {
g_free(line);
fclose(file);
return;
}
while (getdelim(&line, &nb, '\n', file) >= 0) {
if (g_str_equal(line, SEPARATOR_ACCELERATORS) ||
g_str_equal(line, SEPARATOR_ACTIONS))
break;
process_action_line(line);
}
g_free(line);
fclose(file);
} | false | false | false | false | true | 1 |
pixCloseBrick(PIX *pixd,
PIX *pixs,
l_int32 hsize,
l_int32 vsize)
{
PIX *pixt;
SEL *sel, *selh, *selv;
PROCNAME("pixCloseBrick");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, pixd);
if (pixGetDepth(pixs) != 1)
return (PIX *)ERROR_PTR("pixs not 1 bpp", procName, pixd);
if (hsize < 1 || vsize < 1)
return (PIX *)ERROR_PTR("hsize and vsize not >= 1", procName, pixd);
if (hsize == 1 && vsize == 1)
return pixCopy(pixd, pixs);
if (hsize == 1 || vsize == 1) { /* no intermediate result */
sel = selCreateBrick(vsize, hsize, vsize / 2, hsize / 2, SEL_HIT);
pixd = pixClose(pixd, pixs, sel);
selDestroy(&sel);
}
else { /* do separably */
selh = selCreateBrick(1, hsize, 0, hsize / 2, SEL_HIT);
selv = selCreateBrick(vsize, 1, vsize / 2, 0, SEL_HIT);
pixt = pixDilate(NULL, pixs, selh);
pixd = pixDilate(pixd, pixt, selv);
pixErode(pixt, pixd, selh);
pixErode(pixd, pixt, selv);
pixDestroy(&pixt);
selDestroy(&selh);
selDestroy(&selv);
}
return pixd;
} | false | false | false | false | false | 0 |
Java_ncsa_hdf_hdf5lib_H5_H5Eget_1class_1name
(JNIEnv *env, jclass cls, jint cls_id)
{
char *namePtr;
jstring str;
ssize_t buf_size;
if (cls_id < 0) {
h5badArgument(env, "H5Eget_class_name: invalid argument");
return NULL;
}
/* get the length of the name */
buf_size = H5Eget_class_name(cls_id, NULL, 0);
if (buf_size < 0) {
h5badArgument( env, "H5Eget_class_name: buf_size < 0");
return NULL;
}
if (buf_size == 0) {
h5badArgument( env, "H5Eget_class_name: No class name");
return NULL;
}
buf_size++; /* add extra space for the null terminator */
namePtr = (char*)malloc(sizeof(char)*buf_size);
if (namePtr == NULL) {
h5outOfMemory( env, "H5Eget_class_name: malloc failed");
return NULL;
}
buf_size = H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size);
if (buf_size < 0) {
free(namePtr);
h5libraryError(env);
return NULL;
}
str = ENVPTR->NewStringUTF(ENVPAR namePtr);
free(namePtr);
return str;
} | false | false | false | false | false | 0 |
Scan_Process_Fields_Keep_One_Space (gchar *string)
{
gchar *tmp, *tmp1;
tmp = tmp1 = string;
// Remove multiple consecutive underscores and spaces.
while (*tmp1)
{
while (*tmp1 && *tmp1 != ' ' && *tmp1 != '_')
*(tmp++) = *(tmp1++);
if (!*tmp1)
break;
*(tmp++) = *(tmp1++);
while (*tmp1 == ' ' || *tmp1 == '_')
tmp1++;
}
*tmp = '\0';
} | 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.