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 |
|---|---|---|---|---|---|---|
cavan_gsensor_event_handler(struct cavan_input_device *dev, struct input_event *event, void *data)
{
cavan_input_message_t *message;
struct cavan_input_service *service = data;
struct cavan_gsensor_device *sensor = (struct cavan_gsensor_device *) dev;
switch (event->type)
{
case EV_ABS:
switch (event->code)
{
case ABS_X:
sensor->vector.x = event->value;
break;
case ABS_Y:
sensor->vector.y = event->value;
break;
case ABS_Z:
sensor->vector.z = event->value;
break;
default:
return false;
}
break;
case EV_SYN:
message = cavan_data_queue_get_node(&service->queue);
if (message)
{
message->type = CAVAN_INPUT_MESSAGE_ACCELEROMETER;
message->vector = sensor->vector;
cavan_data_queue_append(&service->queue, &message->node);
}
break;
default:
return false;
}
return true;
} | false | false | false | false | false | 0 |
readKeyword(istrstream* strm, char* buffer, int buffer_len)
{
if ( strm->eof() )
return false;
strm->getline(buffer, buffer_len, ',');
// Trim trailing blanks
int len = strlen(buffer);
int pos = len - 1;
while ( pos >= 0 && buffer[pos] == ' ' )
pos--;
buffer[1 + pos] = '\0';
return true;
} | false | false | false | false | false | 0 |
addme(const netid_t mid)
{
unsigned nhval = calcnhash(mid);
struct hhash *hp;
time_t now = time((time_t *) 0);
if (!(hp = (struct hhash *) malloc(sizeof(struct hhash))))
nomem();
BLOCK_ZERO(hp, sizeof(struct hhash));
hp->hn_next = nhashtab[nhval];
nhashtab[nhval] = hp;
hp->rem.hostid = mid;
hp->rem.ht_flags = HT_MANUAL|HT_PROBEFIRST|HT_TRUSTED;
hp->timeout = hp->rem.ht_timeout = 0x7fff;
hp->lastaction = hp->rem.lastwrite = now;
hp->flags = UAL_OK;
} | false | false | false | false | false | 0 |
sdp_set_uuidseq_attr(sdp_record_t *rec, uint16_t aid, sdp_list_t *seq)
{
int status = 0, i, len;
void **dtds, **values;
uint8_t uuid16 = SDP_UUID16;
uint8_t uuid32 = SDP_UUID32;
uint8_t uuid128 = SDP_UUID128;
sdp_list_t *p;
len = sdp_list_len(seq);
if (!seq || len == 0)
return -1;
dtds = malloc(len * sizeof(void *));
if (!dtds)
return -1;
values = malloc(len * sizeof(void *));
if (!values) {
free(dtds);
return -1;
}
for (p = seq, i = 0; i < len; i++, p = p->next) {
uuid_t *uuid = p->data;
if (uuid)
switch (uuid->type) {
case SDP_UUID16:
dtds[i] = &uuid16;
values[i] = &uuid->value.uuid16;
break;
case SDP_UUID32:
dtds[i] = &uuid32;
values[i] = &uuid->value.uuid32;
break;
case SDP_UUID128:
dtds[i] = &uuid128;
values[i] = &uuid->value.uuid128;
break;
default:
status = -1;
break;
}
else {
status = -1;
break;
}
}
if (status == 0) {
sdp_data_t *data = sdp_seq_alloc(dtds, values, len);
sdp_attr_replace(rec, aid, data);
sdp_pattern_add_uuidseq(rec, seq);
}
free(dtds);
free(values);
return status;
} | false | true | false | false | false | 1 |
rb_setselect_epoll(rb_fde_t *F, unsigned int type, PF * handler, void *client_data)
{
struct epoll_event ep_event;
int old_flags = F->pflags;
int op = -1;
lrb_assert(IsFDOpen(F));
/* Update the list, even though we're not using it .. */
if(type & RB_SELECT_READ)
{
if(handler != NULL)
F->pflags |= EPOLLIN;
else
F->pflags &= ~EPOLLIN;
F->read_handler = handler;
F->read_data = client_data;
}
if(type & RB_SELECT_WRITE)
{
if(handler != NULL)
F->pflags |= EPOLLOUT;
else
F->pflags &= ~EPOLLOUT;
F->write_handler = handler;
F->write_data = client_data;
}
if(old_flags == 0 && F->pflags == 0)
return;
else if(F->pflags <= 0)
op = EPOLL_CTL_DEL;
else if(old_flags == 0 && F->pflags > 0)
op = EPOLL_CTL_ADD;
else if(F->pflags != old_flags)
op = EPOLL_CTL_MOD;
if(op == -1)
return;
ep_event.events = F->pflags;
ep_event.data.ptr = F;
if(op == EPOLL_CTL_ADD || op == EPOLL_CTL_MOD)
ep_event.events |= EPOLLET;
if(epoll_ctl(ep_info->ep, op, F->fd, &ep_event) != 0)
{
rb_lib_log("rb_setselect_epoll(): epoll_ctl failed: %s", strerror(errno));
abort();
}
} | false | false | false | false | false | 0 |
free_xd_data(gxml_data * xd)
{
if( xd->da_list ){ free(xd->da_list); xd->da_list = NULL; }
if( xd->xdata ){ free(xd->xdata); xd->xdata = NULL; } /* xform matrix */
if( xd->zdata) { free(xd->zdata); xd->zdata = NULL; } /* compress buff */
if( xd->ddata ){ free(xd->ddata); xd->ddata = NULL; } /* Data buffer */
return 0;
} | false | false | false | false | false | 0 |
newJob( const KUrl & directory )
{
DirectorySizeJobPrivate *d = new DirectorySizeJobPrivate;
DirectorySizeJob *job = new DirectorySizeJob(*d);
job->setUiDelegate(new JobUiDelegate);
d->startNextJob(directory);
return job;
} | false | false | false | false | false | 0 |
str_copy(char *out,const char *in) {
register char* s=out;
register const char* t=in;
for (;;) {
if (!(*s=*t)) break; ++s; ++t;
if (!(*s=*t)) break; ++s; ++t;
if (!(*s=*t)) break; ++s; ++t;
if (!(*s=*t)) break; ++s; ++t;
}
return s-out;
} | false | false | false | false | false | 0 |
sol_codec_type(int magic, int type)
{
if (magic == 0x0B8D) return 1;//SOL_DPCM_OLD;
if (type & SOL_DPCM)
{
if (type & SOL_16BIT) return 3;//SOL_DPCM_NEW16;
else if (magic == 0x0C8D) return 1;//SOL_DPCM_OLD;
else return 2;//SOL_DPCM_NEW8;
}
return -1;
} | false | false | false | false | false | 0 |
coop_cut(std::vector<unsigned int>& cut, std::vector<bool>& node_labels,
ImageGraph* im_graph, double lambda, double theta, int max_iter) {
// Create a cost function and set the edge regularization weight lambda.
// Set the potentials from the unaries, edge weights, and edge classes.
Costfun* cost = new Costfun();
cost->setLambda(lambda);
cost->setPotentials(im_graph, theta);
// Configure the optimization, minimize.
ItBM* algo = new ItBM(cost, max_iter);
double cut_cost = algo->minimize(cut);
node_labels = algo->get_node_labels();
delete algo;
delete cost;
return cut_cost;
} | false | false | false | false | false | 0 |
pkcs11_export_chain(FILE * outfile, const char *url, unsigned int login_flags,
common_info_st * info)
{
gnutls_pkcs11_obj_t obj;
gnutls_x509_crt_t xcrt;
gnutls_datum_t t;
int ret;
unsigned int obj_flags = 0;
if (login_flags) obj_flags = login_flags;
pkcs11_common();
FIX(url);
ret = gnutls_pkcs11_obj_init(&obj);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__,
gnutls_strerror(ret));
exit(1);
}
ret = gnutls_pkcs11_obj_import_url(obj, url, obj_flags);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__,
gnutls_strerror(ret));
exit(1);
}
/* make a crt */
ret = gnutls_x509_crt_init(&xcrt);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__,
gnutls_strerror(ret));
exit(1);
}
ret = gnutls_x509_crt_import_pkcs11(xcrt, obj);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__,
__LINE__, gnutls_strerror(ret));
exit(1);
}
ret = gnutls_pkcs11_obj_export3(obj, GNUTLS_X509_FMT_PEM, &t);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__,
__LINE__, gnutls_strerror(ret));
exit(1);
}
fwrite(t.data, 1, t.size, outfile);
fputs("\n\n", outfile);
gnutls_free(t.data);
gnutls_pkcs11_obj_deinit(obj);
do {
ret = gnutls_pkcs11_get_raw_issuer(url, xcrt, &t, GNUTLS_X509_FMT_PEM, 0);
if (ret == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE)
break;
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__,
__LINE__, gnutls_strerror(ret));
exit(1);
}
fwrite(t.data, 1, t.size, outfile);
fputs("\n\n", outfile);
gnutls_x509_crt_deinit(xcrt);
ret = gnutls_x509_crt_init(&xcrt);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__,
__LINE__, gnutls_strerror(ret));
exit(1);
}
ret = gnutls_x509_crt_import(xcrt, &t, GNUTLS_X509_FMT_PEM);
if (ret < 0) {
fprintf(stderr, "Error in %s:%d: %s\n", __func__,
__LINE__, gnutls_strerror(ret));
exit(1);
}
gnutls_free(t.data);
ret = gnutls_x509_crt_check_issuer(xcrt, xcrt);
if (ret != 0) {
/* self signed */
break;
}
} while(1);
return;
} | false | false | false | false | false | 0 |
test_qof_session_load (Fixture *fixture, gconstpointer pData)
{
/* Method initializes a new book and loads data into it
* if load fails old books are restored
*/
QofBackend *be = NULL;
QofBook *newbook = NULL;
/* init */
fixture->session->book_id = g_strdup ("my book");
be = g_new0 (QofBackend, 1);
g_assert (be);
fixture->session->backend = be;
be->load = mock_load;
g_test_message ("Test when no error is produced");
g_assert (be->percentage == NULL);
load_session_struct.be = be;
load_session_struct.oldbook = qof_session_get_book (fixture->session);
g_assert (fixture->session->book);
load_session_struct.error = FALSE;
load_session_struct.load_called = FALSE;
qof_session_load (fixture->session, percentage_fn);
newbook = qof_session_get_book (fixture->session);
g_assert (newbook);
g_assert (load_session_struct.oldbook != newbook);
g_assert (fixture->session->book);
g_assert (load_session_struct.load_called);
g_test_message ("Test when no is produced");
load_session_struct.oldbook = qof_session_get_book (fixture->session);
g_assert (fixture->session->book);
load_session_struct.error = TRUE;
load_session_struct.load_called = FALSE;
qof_session_load (fixture->session, percentage_fn);
newbook = qof_session_get_book (fixture->session);
g_assert (newbook);
g_assert (load_session_struct.oldbook == newbook);
g_assert (fixture->session->book);
g_assert (load_session_struct.load_called);
} | false | false | false | false | false | 0 |
dwc2_driver_remove(struct platform_device *dev)
{
struct dwc2_hsotg *hsotg = platform_get_drvdata(dev);
dwc2_debugfs_exit(hsotg);
if (hsotg->hcd_enabled)
dwc2_hcd_remove(hsotg);
if (hsotg->gadget_enabled)
dwc2_hsotg_remove(hsotg);
if (hsotg->ll_hw_enabled)
dwc2_lowlevel_hw_disable(hsotg);
return 0;
} | false | false | false | false | false | 0 |
check_xrandr_event(char *msg) {
XEvent xev;
RAWFB_RET(0)
/* it is assumed that X_LOCK is on at this point. */
if (subwin) {
return handle_subwin_resize(msg);
}
#if LIBVNCSERVER_HAVE_LIBXRANDR
if (! xrandr_present) {
return 0;
}
if (! xrandr && ! xrandr_maybe) {
return 0;
}
if (xrandr_base_event_type && XCheckTypedEvent(dpy,
xrandr_base_event_type + RRScreenChangeNotify, &xev)) {
int do_change, qout = 0;
static int first = 1;
XRRScreenChangeNotifyEvent *rev;
rev = (XRRScreenChangeNotifyEvent *) &xev;
if (first && ! xrandr) {
fprintf(stderr, "\n");
if (getenv("X11VNC_DEBUG_XRANDR") == NULL) {
qout = 1;
}
}
first = 0;
rfbLog("check_xrandr_event():\n");
rfbLog("Detected XRANDR event at location '%s':\n", msg);
if (qout) {
;
} else {
rfbLog(" serial: %d\n", (int) rev->serial);
rfbLog(" timestamp: %d\n", (int) rev->timestamp);
rfbLog(" cfg_timestamp: %d\n", (int) rev->config_timestamp);
rfbLog(" size_id: %d\n", (int) rev->size_index);
rfbLog(" sub_pixel: %d\n", (int) rev->subpixel_order);
rfbLog(" rotation: %d\n", (int) rev->rotation);
rfbLog(" width: %d\n", (int) rev->width);
rfbLog(" height: %d\n", (int) rev->height);
rfbLog(" mwidth: %d mm\n", (int) rev->mwidth);
rfbLog(" mheight: %d mm\n", (int) rev->mheight);
rfbLog("\n");
rfbLog("check_xrandr_event: previous WxH: %dx%d\n",
wdpy_x, wdpy_y);
}
if (wdpy_x == rev->width && wdpy_y == rev->height &&
xrandr_rotation == (int) rev->rotation) {
rfbLog("check_xrandr_event: no change detected.\n");
do_change = 0;
if (! xrandr) {
rfbLog("check_xrandr_event: "
"enabling full XRANDR trapping anyway.\n");
xrandr = 1;
}
} else {
do_change = 1;
if (! xrandr) {
rfbLog("check_xrandr_event: Resize; "
"enabling full XRANDR trapping.\n");
xrandr = 1;
}
}
xrandr_width = rev->width;
xrandr_height = rev->height;
xrandr_timestamp = rev->timestamp;
xrandr_cfg_time = rev->config_timestamp;
xrandr_rotation = (int) rev->rotation;
if (! qout) rfbLog("check_xrandr_event: updating config...\n");
XRRUpdateConfiguration(&xev);
if (do_change) {
/* under do_change caller normally returns before its X_UNLOCK */
X_UNLOCK;
handle_xrandr_change(rev->width, rev->height);
}
if (qout) {
return do_change;
}
rfbLog("check_xrandr_event: current WxH: %dx%d\n",
XDisplayWidth(dpy, scr), XDisplayHeight(dpy, scr));
rfbLog("check_xrandr_event(): returning control to"
" caller...\n");
return do_change;
}
#else
xev.type = 0;
#endif
return 0;
} | false | false | false | false | true | 1 |
copyout (cc, cnt)
unsigned char ** cc; /* Char in filteredbuf to start at */
register int cnt; /* Number of chars to copy */
{
register char * cp; /* Char in contextbufs[0] to copy */
cp = (char *) &contextbufs[0][*cc - filteredbuf];
*cc += cnt;
while (--cnt >= 0)
{
if (*cp == '\0')
{
*cc -= cnt + 1; /* Compensate for short copy */
break;
}
if (!aflag && !lflag)
(void) putc (*cp, outfile);
cp++;
}
} | false | false | false | false | false | 0 |
hud_squadmsg_ship_order_valid( int shipnum, int order )
{
// Goober5000
Assert( shipnum >= 0 && shipnum < MAX_SHIPS );
switch ( order )
{
case DEPART_ITEM:
// disabled ships can't depart.
if (Ships[shipnum].flags & SF_DISABLED)
return 0;
// Goober5000: also can't depart if no subspace drives and no capships in the area
if (Ships[shipnum].flags2 & SF2_NO_SUBSPACE_DRIVE)
{
// locate a capital ship on the same team:
if (ship_get_ship_with_dock_bay(Ships[shipnum].team) < 0)
return 0;
}
break;
}
return 1;
} | false | false | false | false | false | 0 |
__vval_is1(register word32 *wp, int32 blen)
{
register int32 i;
register word32 mask;
int32 wlen;
wlen = wlen_(blen);
for (i = 0; i < wlen - 1; i++) if (wp[i] != ALL1W) return(FALSE);
mask = __masktab[ubits_(blen)];
if ((wp[wlen - 1] & mask) != mask) return(FALSE);
return(TRUE);
} | false | false | false | false | false | 0 |
jinit_c_coef_controller (oe_j_compress_ptr cinfo, boolean need_full_buffer)
{
my_coef_ptr coef;
coef = (my_coef_ptr)
(*cinfo->mem->alloc_small) ((oe_j_common_ptr) cinfo, OE_JPOOL_IMAGE,
SIZEOF(my_coef_controller));
cinfo->coef = (struct openexif_jpeg_c_coef_controller *) coef;
coef->pub.start_pass = start_pass_coef;
/* Create the coefficient buffer. */
if (need_full_buffer) {
#ifdef FULL_COEF_BUFFER_SUPPORTED
/* Allocate a full-image virtual array for each component, */
/* padded to a multiple of samp_factor DCT blocks in each direction. */
int ci;
openexif_jpeg_component_info *compptr;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
((oe_j_common_ptr) cinfo, OE_JPOOL_IMAGE, FALSE,
(OE_JDIMENSION) openexif_jround_up((long) compptr->width_in_blocks,
(long) compptr->h_samp_factor),
(OE_JDIMENSION) openexif_jround_up((long) compptr->height_in_blocks,
(long) compptr->v_samp_factor),
(OE_JDIMENSION) compptr->v_samp_factor);
}
#else
ERREXIT(cinfo, OE_JERR_BAD_BUFFER_MODE);
#endif
} else {
/* We only need a single-MCU buffer. */
OE_JBLOCKROW buffer;
int i;
buffer = (OE_JBLOCKROW)
(*cinfo->mem->alloc_large) ((oe_j_common_ptr) cinfo, OE_JPOOL_IMAGE,
C_MAX_BLOCKS_IN_MCU * SIZEOF(OE_JBLOCK));
for (i = 0; i < C_MAX_BLOCKS_IN_MCU; i++) {
coef->MCU_buffer[i] = buffer + i;
}
coef->whole_image[0] = NULL; /* flag for no virtual arrays */
}
} | false | false | false | false | false | 0 |
prd_psort(const struct ltab *lt)
{
mvaddstr(lt->row, lt->col, Displayopts.opt_sortptrs != SORTP_NONE? lt->prompts[1]: lt->prompts[0]);
} | false | false | false | false | false | 0 |
_k_insert_after(K_LIST *list, K_ITEM *item, K_ITEM *after, KLIST_FFL_ARGS)
{
if (item->name != list->name) {
quithere(1, "List %s can't %s() a %s item" KLIST_FFL,
list->name, __func__, item->name, KLIST_FFL_PASS);
}
if (!after) {
quithere(1, "%s() (%s) can't after a null item" KLIST_FFL,
__func__, list->name, KLIST_FFL_PASS);
}
item->prev = after;
item->next = after->next;
if (after->next)
after->next->prev = item;
else {
if (list->do_tail)
list->tail = item;
}
after->next = item;
list->count++;
list->count_up++;
} | false | false | false | true | false | 1 |
compute_attributes_sql_style(List *options,
List **as,
char **language,
char *volatility_p,
bool *strict_p,
bool *security_definer)
{
ListCell *option;
DefElem *as_item = NULL;
DefElem *language_item = NULL;
DefElem *volatility_item = NULL;
DefElem *strict_item = NULL;
DefElem *security_item = NULL;
foreach(option, options)
{
DefElem *defel = (DefElem *) lfirst(option);
if (strcmp(defel->defname, "as") == 0)
{
if (as_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
as_item = defel;
}
else if (strcmp(defel->defname, "language") == 0)
{
if (language_item)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("conflicting or redundant options")));
language_item = defel;
}
else if (compute_common_attribute(defel,
&volatility_item,
&strict_item,
&security_item))
{
/* recognized common option */
continue;
}
else
elog(ERROR, "option \"%s\" not recognized",
defel->defname);
}
/* process required items */
if (as_item)
*as = (List *) as_item->arg;
else
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("no function body specified")));
*as = NIL; /* keep compiler quiet */
}
if (language_item)
*language = strVal(language_item->arg);
else
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_FUNCTION_DEFINITION),
errmsg("no language specified")));
*language = NULL; /* keep compiler quiet */
}
/* process optional items */
if (volatility_item)
*volatility_p = interpret_func_volatility(volatility_item);
if (strict_item)
*strict_p = intVal(strict_item->arg);
if (security_item)
*security_definer = intVal(security_item->arg);
} | false | false | false | false | false | 0 |
circuit_free_all(void)
{
circuit_t *next;
while (global_circuitlist) {
next = global_circuitlist->next;
if (! CIRCUIT_IS_ORIGIN(global_circuitlist)) {
or_circuit_t *or_circ = TO_OR_CIRCUIT(global_circuitlist);
while (or_circ->resolving_streams) {
edge_connection_t *next_conn;
next_conn = or_circ->resolving_streams->next_stream;
connection_free(TO_CONN(or_circ->resolving_streams));
or_circ->resolving_streams = next_conn;
}
}
circuit_free(global_circuitlist);
global_circuitlist = next;
}
smartlist_free(circuits_pending_or_conns);
circuits_pending_or_conns = NULL;
HT_CLEAR(orconn_circid_map, &orconn_circid_circuit_map);
} | false | false | false | false | false | 0 |
compact_multitext_string(char *str)
{
unsigned int i;
unsigned int len = strlen(str);
int num_cr = 0;
for (i=0; i<len; i++)
{
// skip CR
// convert LF to space
// copy characters backwards if any CRs previously encountered
if (str[i] == '\r')
num_cr++;
else if (str[i] == '\n')
str[i-num_cr] = ' ';
else if (num_cr > 0)
str[i-num_cr] = str[i];
}
if (num_cr > 0)
str[len-num_cr] = 0;
} | false | false | false | false | false | 0 |
double2icS15Fixed16Number(float number_in)
{
short s;
unsigned short m;
icS15Fixed16Number temp;
float number;
if (number_in < 0) {
number = -number_in;
s = (short) number;
m = (unsigned short) ((number - s) * 65536.0);
temp = (icS15Fixed16Number) ((s << 16) | m);
temp = -temp;
return(temp);
} else {
s = (short) number_in;
m = (unsigned short) ((number_in - s) * 65536.0);
return((icS15Fixed16Number) ((s << 16) | m) );
}
} | false | false | false | false | false | 0 |
tyan_lcdm_set_char (Driver *drvthis, int n, unsigned char *dat)
{
PrivateData *p = drvthis->private_data;
unsigned char mask = (1 << p->cellwidth) - 1;
unsigned char out[p->cellheight + 1];
int row;
if ((n < 0) || (n >= NUM_CCs))
return;
if (dat == NULL)
return;
for (row = 0; row < p->cellheight; row++) {
int letter = dat[row] & mask;
if (p->cc[n].cache[row] != letter)
p->cc[n].clean = 0; /* only mark dirty if really different */
p->cc[n].cache[row] = letter;
out[row+1] = letter;
}
tyan_lcdm_write_str(p->fd, out, (unsigned char) (0x40 + n * 8), 8);
} | true | true | false | false | false | 1 |
MoveForInsertDelete(bool insertion, int startChange, int length) {
if (insertion) {
if (position > startChange) {
position += length;
}
} else {
if (position > startChange) {
int endDeletion = startChange + length;
if (position > endDeletion) {
position -= length;
} else {
position = startChange;
}
}
}
} | false | false | false | false | false | 0 |
platform_get_runlevel()
{
char runlevel;
struct utmp ut, save, *next = NULL;
struct timeval tv;
int flag = 0, counter = 0;
MUTEX_LOCK(utmp_lock);
memset(&ut, 0, sizeof(struct utmp));
memset(&save, 0, sizeof(struct utmp));
memset(&tv, 0, sizeof(struct timeval));
ut.ut_type = RUN_LVL;
setutent();
next = getutid(&ut);
while (next != NULL) {
if (next->ut_tv.tv_sec > tv.tv_sec) {
memcpy(&save, next, sizeof(*next));
flag = 1;
} else if (next->ut_tv.tv_sec == tv.tv_sec) {
if (next->ut_tv.tv_usec > tv.tv_usec) {
memcpy(&save, next, sizeof(*next));
flag = 1;
}
}
counter++;
next = getutid(&ut);
}
if (flag) {
#if 0
printf("prev_runlevel=%c, runlevel=%c\n", (save.ut_pid / 256),
(save.ut_pid % 256));
#endif /* 0 */
runlevel = save.ut_pid % 256;
} else {
#if 0
printf("unknown\n");
#endif /* 0 */
runlevel = 'u';
}
MUTEX_UNLOCK(utmp_lock);
return runlevel;
} | false | false | false | false | false | 0 |
_xmmsv_utf8_charlen (unsigned char c)
{
if ((c & 0x80) == 0) {
return 1;
} else if ((c & 0x60) == 0x40) {
return 2;
} else if ((c & 0x70) == 0x60) {
return 3;
} else if ((c & 0x78) == 0x70) {
return 4;
}
return 0;
} | false | false | false | false | false | 0 |
rtl8188ee_bt_var_init(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
rtlpriv->btcoexist.bt_coexistence =
rtlpriv->btcoexist.eeprom_bt_coexist;
rtlpriv->btcoexist.bt_ant_num = rtlpriv->btcoexist.eeprom_bt_ant_num;
rtlpriv->btcoexist.bt_coexist_type = rtlpriv->btcoexist.eeprom_bt_type;
if (rtlpriv->btcoexist.reg_bt_iso == 2)
rtlpriv->btcoexist.bt_ant_isolation =
rtlpriv->btcoexist.eeprom_bt_ant_isol;
else
rtlpriv->btcoexist.bt_ant_isolation =
rtlpriv->btcoexist.reg_bt_iso;
rtlpriv->btcoexist.bt_radio_shared_type =
rtlpriv->btcoexist.eeprom_bt_radio_shared;
if (rtlpriv->btcoexist.bt_coexistence) {
if (rtlpriv->btcoexist.reg_bt_sco == 1)
rtlpriv->btcoexist.bt_service = BT_OTHER_ACTION;
else if (rtlpriv->btcoexist.reg_bt_sco == 2)
rtlpriv->btcoexist.bt_service = BT_SCO;
else if (rtlpriv->btcoexist.reg_bt_sco == 4)
rtlpriv->btcoexist.bt_service = BT_BUSY;
else if (rtlpriv->btcoexist.reg_bt_sco == 5)
rtlpriv->btcoexist.bt_service = BT_OTHERBUSY;
else
rtlpriv->btcoexist.bt_service = BT_IDLE;
rtlpriv->btcoexist.bt_edca_ul = 0;
rtlpriv->btcoexist.bt_edca_dl = 0;
rtlpriv->btcoexist.bt_rssi_state = 0xff;
}
} | false | false | false | false | false | 0 |
nodes_gui_node_flags_changed(const struct nid *node_id)
{
if (!hset_contains(ht_node_flags_changed, node_id)) {
const struct nid *key = nid_ref(node_id);
hset_insert(ht_node_flags_changed, key);
}
} | false | false | false | false | false | 0 |
Coding2Coding_Data_init(Coding2Coding_Data *c2cd,
Sequence *query, Sequence *target){
g_assert(query->alphabet->type == Alphabet_Type_DNA);
g_assert(target->alphabet->type == Alphabet_Type_DNA);
Affine_Data_init(&c2cd->ad, query, target, TRUE);
if(!Coding2Coding_Data_get_Frameshift_Data(c2cd))
Coding2Coding_Data_get_Frameshift_Data(c2cd)
= Frameshift_Data_create();
return;
} | false | false | false | false | false | 0 |
modem_added (DBusGProxy *proxy, const char *path, gpointer user_data)
{
NmaBtDevice *self = NMA_BT_DEVICE (user_data);
NmaBtDevicePrivate *priv = NMA_BT_DEVICE_GET_PRIVATE (self);
DBusGProxy *props_proxy;
g_return_if_fail (path != NULL);
g_message ("%s: (%s) modem found", __func__, path);
/* Create a proxy for the modem and get its properties */
props_proxy = dbus_g_proxy_new_for_name (priv->bus,
MM_SERVICE,
path,
"org.freedesktop.DBus.Properties");
g_assert (proxy);
priv->modem_proxies = g_slist_append (priv->modem_proxies, props_proxy);
g_message ("%s: (%s) calling GetAll...", __func__, path);
dbus_g_proxy_begin_call (props_proxy, "GetAll",
modem_get_all_cb,
self,
NULL,
G_TYPE_STRING, MM_MODEM_INTERFACE,
G_TYPE_INVALID);
} | false | false | false | false | false | 0 |
vn_reference_lookup_or_insert_for_pieces (tree vuse,
alias_set_type set,
tree type,
VEC (vn_reference_op_s,
heap) *operands,
tree value)
{
struct vn_reference_s vr1;
vn_reference_t result;
unsigned value_id;
vr1.vuse = vuse;
vr1.operands = operands;
vr1.type = type;
vr1.set = set;
vr1.hashcode = vn_reference_compute_hash (&vr1);
if (vn_reference_lookup_1 (&vr1, &result))
return result;
if (TREE_CODE (value) == SSA_NAME)
value_id = VN_INFO (value)->value_id;
else
value_id = get_or_alloc_constant_value_id (value);
return vn_reference_insert_pieces (vuse, set, type,
VEC_copy (vn_reference_op_s, heap,
operands), value, value_id);
} | true | true | false | false | false | 1 |
next_conversion (conversion *conv)
{
if (conv == NULL
|| conv->kind == ck_identity
|| conv->kind == ck_ambig
|| conv->kind == ck_list)
return NULL;
return conv->u.next;
} | false | false | false | false | false | 0 |
mcam_vb_start_streaming(struct vb2_queue *vq, unsigned int count)
{
struct mcam_camera *cam = vb2_get_drv_priv(vq);
unsigned int frame;
int ret;
if (cam->state != S_IDLE) {
mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
return -EINVAL;
}
cam->frame_state.frames = 0;
cam->frame_state.singles = 0;
cam->frame_state.delivered = 0;
cam->sequence = 0;
/*
* Videobuf2 sneakily hoards all the buffers and won't
* give them to us until *after* streaming starts. But
* we can't actually start streaming until we have a
* destination. So go into a wait state and hope they
* give us buffers soon.
*/
if (cam->buffer_mode != B_vmalloc && list_empty(&cam->buffers)) {
cam->state = S_BUFWAIT;
return 0;
}
/*
* Ensure clear the left over frame flags
* before every really start streaming
*/
for (frame = 0; frame < cam->nbufs; frame++)
clear_bit(CF_FRAME_SOF0 + frame, &cam->flags);
ret = mcam_read_setup(cam);
if (ret)
mcam_vb_requeue_bufs(vq, VB2_BUF_STATE_QUEUED);
return ret;
} | false | false | false | false | false | 0 |
avision_close (Avision_Connection* av_con)
{
if (av_con->connection_type == AV_SCSI) {
sanei_scsi_close (av_con->scsi_fd);
av_con->scsi_fd = -1;
}
else {
sanei_usb_close (av_con->usb_dn);
av_con->usb_dn = -1;
}
} | false | false | false | false | false | 0 |
c_snk(state_t *s)
{
int callk_index;
char *endptr;
if (!_debugstate_valid) {
sciprintf("Not in debug state\n");
return 1;
}
if (cmd_paramlength > 0) {
/* Try to convert the parameter to a number. If the conversion stops
before end of string, assume that the parameter is a function name
and scan the function table to find out the index. */
callk_index = strtoul (cmd_params [0].str, &endptr, 0);
if (*endptr != '\0')
{
int i;
callk_index = -1;
for (i = 0; i < s->kernel_names_nr; i++)
if (!strcmp (cmd_params [0].str, s->kernel_names [i]))
{
callk_index = i;
break;
}
if (callk_index == -1)
{
sciprintf ("Unknown kernel function '%s'\n", cmd_params [0].str);
return 1;
}
}
_debug_seeking = _DEBUG_SEEK_SPECIAL_CALLK;
_debug_seek_special = callk_index;
_debugstate_valid = 0;
} else {
_debug_seeking = _DEBUG_SEEK_CALLK;
_debugstate_valid = 0;
}
return 0;
} | false | false | false | false | false | 0 |
CompareVersions(const int version1[],
const int version2[],
int num_segments) {
for (int i = 0; i < num_segments; ++i) {
int diff = version1[i] - version2[i];
if (diff != 0) {
return diff;
}
}
return 0;
} | false | false | false | false | false | 0 |
sysfs_write_string(struct sysfs_cxt *cxt, const char *attr, const char *str)
{
int fd = sysfs_open(cxt, attr, O_WRONLY|O_CLOEXEC);
int rc, errsv;
if (fd < 0)
return -errno;
rc = write_all(fd, str, strlen(str));
errsv = errno;
close(fd);
errno = errsv;
return rc;
} | false | false | false | false | false | 0 |
jffs2_stop_garbage_collect_thread(struct jffs2_sb_info *c)
{
int wait = 0;
spin_lock(&c->erase_completion_lock);
if (c->gc_task) {
jffs2_dbg(1, "Killing GC task %d\n", c->gc_task->pid);
send_sig(SIGKILL, c->gc_task, 1);
wait = 1;
}
spin_unlock(&c->erase_completion_lock);
if (wait)
wait_for_completion(&c->gc_thread_exit);
} | false | false | false | false | false | 0 |
circoLayout(Agraph_t * g)
{
Agraph_t **ccs;
Agraph_t *sg;
int ncc;
int i;
if (agnnodes(g)) {
ccs = circomps(g, &ncc);
if (ncc == 1) {
circularLayout(ccs[0], g);
copyPosns(ccs[0]);
adjustNodes(g);
} else {
Agraph_t *dg = ccs[0]->root;
pack_info pinfo;
getPackInfo(g, l_node, CL_OFFSET, &pinfo);
for (i = 0; i < ncc; i++) {
sg = ccs[i];
circularLayout(sg, g);
adjustNodes(sg);
}
/* FIX: splines have not been calculated for dg
* To use, either do splines in dg and copy to g, or
* construct components of g from ccs and use that in packing.
*/
packSubgraphs(ncc, ccs, dg, &pinfo);
for (i = 0; i < ncc; i++)
copyPosns(ccs[i]);
}
free(ccs);
}
} | false | false | false | false | false | 0 |
GC_signal_mark_stack_overflow(mse *msp)
{
GC_mark_state = MS_INVALID;
GC_mark_stack_too_small = TRUE;
GC_COND_LOG_PRINTF("Mark stack overflow; current size = %lu entries\n",
(unsigned long)GC_mark_stack_size);
return(msp - GC_MARK_STACK_DISCARDS);
} | false | false | false | false | false | 0 |
main(int argc, char **argv)
{
int fd;
struct stat stat;
__u8 *db;
struct regdb_file_header *header;
struct regdb_file_reg_country *countries;
int dblen, siglen, num_countries, i, r = 0;
struct ieee80211_regdomain *rd = NULL;
if (argc != 2) {
fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
return 2;
}
fd = open(argv[1], O_RDONLY);
if (fd < 0) {
perror("failed to open db file");
return 2;
}
if (fstat(fd, &stat)) {
perror("failed to fstat db file");
return 2;
}
dblen = stat.st_size;
db = mmap(NULL, dblen, PROT_READ, MAP_PRIVATE, fd, 0);
if (db == MAP_FAILED) {
perror("failed to mmap db file");
return 2;
}
header = crda_get_file_ptr(db, dblen, sizeof(*header), 0);
if (ntohl(header->magic) != REGDB_MAGIC) {
fprintf(stderr, "Invalid database magic\n");
return 2;
}
if (ntohl(header->version) != REGDB_VERSION) {
fprintf(stderr, "Invalid database version\n");
return 2;
}
siglen = ntohl(header->signature_length);
/* adjust dblen so later sanity checks don't run into the signature */
dblen -= siglen;
if (dblen <= (int)sizeof(*header)) {
fprintf(stderr, "Invalid signature length %d\n", siglen);
return 2;
}
/* verify signature */
if (!crda_verify_db_signature(db, dblen, siglen))
return -EINVAL;
num_countries = ntohl(header->reg_country_num);
countries = crda_get_file_ptr(db, dblen,
sizeof(struct regdb_file_reg_country) * num_countries,
header->reg_country_ptr);
for (i = 0; i < num_countries; i++) {
struct regdb_file_reg_country *country = countries + i;
rd = country2rd(db, dblen, country);
if (!rd) {
r = -ENOMEM;
fprintf(stderr, "Could not covert country "
"(%.2s) to rd\n", country->alpha2);
goto out;
}
print_regdom(rd);
free(rd);
rd = NULL;
}
out:
return r;
} | false | false | false | false | false | 0 |
binprint (const char *str, size_t len)
{
size_t i;
printf ("\t;; ");
for (i = 0; i < len; i++)
{
printf ("%d%d%d%d%d%d%d%d ",
(str[i] & 0xFF) & 0x80 ? 1 : 0,
(str[i] & 0xFF) & 0x40 ? 1 : 0,
(str[i] & 0xFF) & 0x20 ? 1 : 0,
(str[i] & 0xFF) & 0x10 ? 1 : 0,
(str[i] & 0xFF) & 0x08 ? 1 : 0,
(str[i] & 0xFF) & 0x04 ? 1 : 0,
(str[i] & 0xFF) & 0x02 ? 1 : 0, (str[i] & 0xFF) & 0x01 ? 1 : 0);
if ((i + 1) % 3 == 0)
printf (" ");
if ((i + 1) % 6 == 0 && i + 1 < len)
printf ("\n\t;; ");
}
printf ("\n");
} | false | false | false | false | false | 0 |
expandToCol(int col) {
while ((int)m_ColInfo.size() <= col) {
m_ColInfo.push_back(KeyRCInfo());
}
return &m_ColInfo[col];
} | false | false | false | false | false | 0 |
hasActionGroup(const QString &group) const
{
return hasGroup(QString(QLatin1String("Desktop Action ") + group).toUtf8().constData());
} | false | false | false | false | false | 0 |
efi_snp_hii_package_list ( struct efi_snp_device *snpdev ) {
struct net_device *netdev = snpdev->netdev;
struct device *dev = netdev->dev;
struct efi_ifr_builder ifr;
EFI_HII_PACKAGE_LIST_HEADER *package;
const char *product_name;
EFI_GUID package_guid;
EFI_GUID formset_guid;
EFI_GUID varstore_guid;
unsigned int title_id;
unsigned int varstore_id;
/* Initialise IFR builder */
efi_ifr_init ( &ifr );
/* Determine product name */
product_name = ( PRODUCT_NAME[0] ? PRODUCT_NAME : PRODUCT_SHORT_NAME );
/* Generate GUIDs */
efi_snp_hii_random_guid ( &package_guid );
efi_snp_hii_random_guid ( &formset_guid );
efi_snp_hii_random_guid ( &varstore_guid );
/* Generate title string (used more than once) */
title_id = efi_ifr_string ( &ifr, "%s (%s)", product_name,
netdev_addr ( netdev ) );
/* Generate opcodes */
efi_ifr_form_set_op ( &ifr, &formset_guid, title_id,
efi_ifr_string ( &ifr,
"Configure " PRODUCT_SHORT_NAME),
&efi_hii_platform_setup_formset_guid,
&efi_hii_ibm_ucm_compliant_formset_guid, NULL );
efi_ifr_guid_class_op ( &ifr, EFI_NETWORK_DEVICE_CLASS );
efi_ifr_guid_subclass_op ( &ifr, 0x03 );
varstore_id = efi_ifr_varstore_name_value_op ( &ifr, &varstore_guid );
efi_ifr_form_op ( &ifr, title_id );
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Name" ),
efi_ifr_string ( &ifr, "Firmware product name" ),
efi_ifr_string ( &ifr, "%s", product_name ) );
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Version" ),
efi_ifr_string ( &ifr, "Firmware version" ),
efi_ifr_string ( &ifr, "%s", product_version ) );
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Driver" ),
efi_ifr_string ( &ifr, "Firmware driver" ),
efi_ifr_string ( &ifr, "%s", dev->driver_name ) );
efi_ifr_text_op ( &ifr,
efi_ifr_string ( &ifr, "Device" ),
efi_ifr_string ( &ifr, "Hardware device" ),
efi_ifr_string ( &ifr, "%s", dev->name ) );
efi_snp_hii_questions ( snpdev, &ifr, varstore_id );
efi_ifr_end_op ( &ifr );
efi_ifr_end_op ( &ifr );
/* Build package */
package = efi_ifr_package ( &ifr, &package_guid, "en-us",
efi_ifr_string ( &ifr, "English" ) );
if ( ! package ) {
DBGC ( snpdev, "SNPDEV %p could not build IFR package\n",
snpdev );
efi_ifr_free ( &ifr );
return NULL;
}
/* Free temporary storage */
efi_ifr_free ( &ifr );
return package;
} | false | false | false | false | false | 0 |
ipath_lkey_ok(struct ipath_qp *qp, struct ipath_sge *isge,
struct ib_sge *sge, int acc)
{
struct ipath_lkey_table *rkt = &to_idev(qp->ibqp.device)->lk_table;
struct ipath_mregion *mr;
unsigned n, m;
size_t off;
int ret;
/*
* We use LKEY == zero for kernel virtual addresses
* (see ipath_get_dma_mr and ipath_dma.c).
*/
if (sge->lkey == 0) {
/* always a kernel port, no locking needed */
struct ipath_pd *pd = to_ipd(qp->ibqp.pd);
if (pd->user) {
ret = 0;
goto bail;
}
isge->mr = NULL;
isge->vaddr = (void *) sge->addr;
isge->length = sge->length;
isge->sge_length = sge->length;
ret = 1;
goto bail;
}
mr = rkt->table[(sge->lkey >> (32 - ib_ipath_lkey_table_size))];
if (unlikely(mr == NULL || mr->lkey != sge->lkey ||
qp->ibqp.pd != mr->pd)) {
ret = 0;
goto bail;
}
off = sge->addr - mr->user_base;
if (unlikely(sge->addr < mr->user_base ||
off + sge->length > mr->length ||
(mr->access_flags & acc) != acc)) {
ret = 0;
goto bail;
}
off += mr->offset;
m = 0;
n = 0;
while (off >= mr->map[m]->segs[n].length) {
off -= mr->map[m]->segs[n].length;
n++;
if (n >= IPATH_SEGSZ) {
m++;
n = 0;
}
}
isge->mr = mr;
isge->vaddr = mr->map[m]->segs[n].vaddr + off;
isge->length = mr->map[m]->segs[n].length - off;
isge->sge_length = sge->length;
isge->m = m;
isge->n = n;
ret = 1;
bail:
return ret;
} | false | false | false | false | false | 0 |
nautilus_canvas_view_can_rename_file (NautilusView *view, NautilusFile *file)
{
if (!(nautilus_canvas_view_get_zoom_level (view) > NAUTILUS_ZOOM_LEVEL_SMALLEST)) {
return FALSE;
}
return NAUTILUS_VIEW_CLASS(nautilus_canvas_view_parent_class)->can_rename_file (view, file);
} | false | false | false | false | false | 0 |
matches(str, relation, cond)
char *str;
int relation;
struct condition_rec *cond;
{
switch(relation){
case RE:
if (cond->regex == NULL)
cond->regex = regcomp(cond->argument1);
if (regexec(cond->regex, str)) {
last_regexp = cond->regex;
return TRUE;
} else {
return FALSE;
}
case EQ:
return contains(str, cond->argument1);
case NE:
return (!contains(str, cond->argument1));
default:
fprintf(stderr,"filter:matches(): CANNOTHAPPEN\n");
return FALSE;
}
} | false | false | false | false | false | 0 |
rescale(void)
{
vwtp = vwtp*dt_lb/dx_lb;
vwbt = vwbt*dt_lb/dx_lb;
bodyforcex = bodyforcex*dt_lb*dt_lb/dx_lb;
bodyforcey = bodyforcey*dt_lb*dt_lb/dx_lb;
bodyforcez = bodyforcez*dt_lb*dt_lb/dx_lb;
tau=(3.0*viscosity/densityinit_real)*dt_lb*dt_lb/dx_lb/dx_lb;
tau /= dt_lb;
if(typeLB==1)
tau = tau + 0.5;
if(setGamma == 0){
for(int i=0; i<= atom->ntypes; i++){
NodeArea[i] = NodeArea[i]/dx_lb/dx_lb;
}
}else{
for(int i=0; i<= atom->ntypes; i++){
Gamma[i] = Gamma[i]*dt_lb/dm_lb;
}
}
densityinit = densityinit_real*dx_lb*dx_lb*dx_lb/dm_lb;
a_0 = a_0_real*dt_lb*dt_lb/(dx_lb*dx_lb);
// Warn if using the D3Q19 model with noise, and a0 is too small.
if(numvel==19 && noisestress==1 && a_0 < 0.2){
error->warning(FLERR,"Fix lb/fluid WARNING: Chosen value for a0 may be too small. \
Check temperature reproduction.\n");
}
if(noisestress==1){
if(a_0>0.5555555){
error->all(FLERR,"Fix lb/fluid ERROR: the Lattice Boltzmann dx and dt need \
to be chosen such that the scaled a_0 < 5/9\n");
}
}
// Courant Condition:
if(a_0 >= 1.0){
error->all(FLERR,"Fix lb/fluid ERROR: the lattice Boltzmann dx and dt do not \
satisfy the Courant condition.\n");
}
kB = (force->boltz/force->mvv2e)*dt_lb*dt_lb/dx_lb/dx_lb/dm_lb;
if(typeLB==1){
expminusdtovertau = 0.0;
Dcoeff = 0.0;
namp = 2.0*kB*T*(tau-0.5)/3.0;
noisefactor = 1.0;
if(a_0 <= 0.333333333333333){
K_0 = 5.17*(0.333333333333333 - a_0);
}else{
K_0 = 2.57*(a_0 - 0.333333333333333);
}
dtoverdtcollision = dt_lb*6.0*viscosity/densityinit_real/dx_lb/dx_lb;
}else if(typeLB==2){
expminusdtovertau=exp(-1.0/tau);
Dcoeff=(1.0-(1.0-expminusdtovertau)*tau);
namp = 2.0*kB*T/3.;
noisefactor=sqrt((1.0-expminusdtovertau*expminusdtovertau)/
(2.0))/(1.0-expminusdtovertau);
K_0 = 4.5*(1.0/3.0-a_0);
dtoverdtcollision = dt_lb*3.0*viscosity/densityinit_real/dx_lb/dx_lb;
}
} | false | false | false | false | false | 0 |
call_maybe(PyObject *o, _Py_Identifier *nameid, char *format, ...)
{
va_list va;
PyObject *args, *func = 0, *retval;
va_start(va, format);
func = lookup_maybe(o, nameid);
if (func == NULL) {
va_end(va);
if (!PyErr_Occurred())
Py_RETURN_NOTIMPLEMENTED;
return NULL;
}
if (format && *format)
args = Py_VaBuildValue(format, va);
else
args = PyTuple_New(0);
va_end(va);
if (args == NULL)
return NULL;
assert(PyTuple_Check(args));
retval = PyObject_Call(func, args, NULL);
Py_DECREF(args);
Py_DECREF(func);
return retval;
} | false | false | false | false | false | 0 |
Set(const int index, const bool value)
{
if (value){
Data[(index>>3)] |= (1 << (index&7));
} else {
unsigned char mask = 0xFF;
mask ^= (1 << (index&7));
Data[(index>>3)] &= mask;
}
} | false | false | false | false | false | 0 |
faxEncode_closeXform (IP_XFORM_HANDLE hXform)
{
PENC_INST g;
HANDLE_TO_PTR (hXform, g);
if (g->prior_p != NULL)
IP_MEM_FREE (g->prior_p);
g->dwValidChk = 0;
IP_MEM_FREE (g); /* free memory for the instance */
return IP_DONE;
fatal_error:
return IP_FATAL_ERROR;
} | false | false | false | false | false | 0 |
WriteMoveTo(FILE* fdes, at_real_coord *pt)
{
int recsize = sizeof(UI32) * 4;
if(fdes != NULL)
{
write32(fdes, ENMT_MOVETO);
write32(fdes, (UI32) recsize);
write32(fdes, (UI32) X_FLOAT_TO_UI32(pt->x));
write32(fdes, (UI32) Y_FLOAT_TO_UI32(pt->y));
}
return recsize;
} | false | false | false | false | false | 0 |
char1 (uaecptr addr)
{
static uae_char buf[1024];
static TCHAR bufx[1024];
unsigned int i = 0;
do {
buf[i] = get_byte (addr);
addr++;
} while (buf[i++] && i < sizeof (buf));
return au_fs_copy (bufx, sizeof (bufx) / sizeof (TCHAR), buf);
} | false | false | false | false | false | 0 |
phy_set_bw_mode_callback(struct adapter *adapt)
{
struct hal_data_8188e *hal_data = GET_HAL_DATA(adapt);
u8 reg_bw_opmode;
u8 reg_prsr_rsc;
if (hal_data->rf_chip == RF_PSEUDO_11N)
return;
/* There is no 40MHz mode in RF_8225. */
if (hal_data->rf_chip == RF_8225)
return;
if (adapt->bDriverStopped)
return;
/* Set MAC register */
reg_bw_opmode = usb_read8(adapt, REG_BWOPMODE);
reg_prsr_rsc = usb_read8(adapt, REG_RRSR+2);
switch (hal_data->CurrentChannelBW) {
case HT_CHANNEL_WIDTH_20:
reg_bw_opmode |= BW_OPMODE_20MHZ;
usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode);
break;
case HT_CHANNEL_WIDTH_40:
reg_bw_opmode &= ~BW_OPMODE_20MHZ;
usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode);
reg_prsr_rsc = (reg_prsr_rsc&0x90) |
(hal_data->nCur40MhzPrimeSC<<5);
usb_write8(adapt, REG_RRSR+2, reg_prsr_rsc);
break;
default:
break;
}
/* Set PHY related register */
switch (hal_data->CurrentChannelBW) {
case HT_CHANNEL_WIDTH_20:
phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x0);
phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x0);
break;
case HT_CHANNEL_WIDTH_40:
phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x1);
phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x1);
/* Set Control channel to upper or lower.
* These settings are required only for 40MHz
*/
phy_set_bb_reg(adapt, rCCK0_System, bCCKSideBand,
(hal_data->nCur40MhzPrimeSC>>1));
phy_set_bb_reg(adapt, rOFDM1_LSTF, 0xC00,
hal_data->nCur40MhzPrimeSC);
phy_set_bb_reg(adapt, 0x818, (BIT(26) | BIT(27)),
(hal_data->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1);
break;
default:
break;
}
/* Set RF related register */
if (hal_data->rf_chip == RF_6052)
rtl88eu_phy_rf6052_set_bandwidth(adapt, hal_data->CurrentChannelBW);
} | false | false | false | false | false | 0 |
yp_add (const char *mount)
{
struct yp_server *server;
/* make sure YP thread is not modifying the lists */
thread_rwlock_rlock (&yp_lock);
/* make sure we don't race against another yp_add */
thread_mutex_lock (&yp_pending_lock);
server = (struct yp_server *)active_yps;
while (server)
{
ypdata_t *yp;
/* on-demand relays may already have a YP entry */
yp = find_yp_mount (server->mounts, mount);
if (yp == NULL)
{
/* add new ypdata to each servers pending yp */
yp = create_yp_entry (mount);
if (yp)
{
DEBUG2 ("Adding %s to %s", mount, server->url);
yp->server = server;
yp->touch_interval = server->touch_interval;
yp->next = server->pending_mounts;
yp->next_update = time(NULL) + 60;
server->pending_mounts = yp;
yp_update = 1;
}
}
else
DEBUG1 ("YP entry %s already exists", mount);
server = server->next;
}
thread_mutex_unlock (&yp_pending_lock);
thread_rwlock_unlock (&yp_lock);
} | false | false | false | false | false | 0 |
slapi_has8thBit(unsigned char *s)
{
#define MY8THBITWIDTH 4 /* sizeof(PRUint32) */
#define MY8THBITFILTER 0x80808080
unsigned char *p, *stail, *ltail;
PRUint32 *uip;
size_t len = strlen((const char *)s);
ltail = s + len;
stail = ltail - (len % MY8THBITWIDTH);
for (p = s; p < stail; p += MY8THBITWIDTH) {
uip = (PRUint32 *)p;
if (MY8THBITFILTER & *uip) {
return 1;
}
}
for (; p < ltail; p++) {
if (0x80 & *p) {
return 1;
}
}
return 0;
#undef MY8THBITWIDTH
#undef MY8THBITFILTER
} | false | false | false | false | false | 0 |
MatchCallback(JSContext *cx, size_t count, void *p)
{
JS_ASSERT(count <= JSVAL_INT_MAX); /* by max string length */
jsval &arrayval = *static_cast<jsval *>(p);
JSObject *arrayobj = JSVAL_TO_OBJECT(arrayval);
if (!arrayobj) {
arrayobj = js_NewArrayObject(cx, 0, NULL);
if (!arrayobj)
return false;
arrayval = OBJECT_TO_JSVAL(arrayobj);
}
JSString *str = cx->regExpStatics.input;
JSSubString &match = cx->regExpStatics.lastMatch;
ptrdiff_t off = match.chars - str->chars();
JS_ASSERT(off >= 0 && size_t(off) <= str->length());
JSString *matchstr = js_NewDependentString(cx, str, off, match.length);
if (!matchstr)
return false;
jsval v = STRING_TO_JSVAL(matchstr);
JSAutoResolveFlags rf(cx, JSRESOLVE_QUALIFIED | JSRESOLVE_ASSIGNING);
return arrayobj->setProperty(cx, INT_TO_JSID(count), &v);
} | false | false | false | false | false | 0 |
parse_daemon2(const lnode *n, search_items *s)
{
char *str, saved, *term = n->message;
if (event_hostname) {
str = strstr(term, "addr=");
if (str) {
str += 5;
term = strchr(str, ':');
if (term == NULL) {
term = strchr(str, ' ');
if (term == NULL)
return 1;
}
saved = *term;
*term = 0;
free(s->hostname);
s->hostname = strdup(str);
*term = saved;
}
}
if (event_success != S_UNSET) {
char *str = strstr(term, "res=");
if (str) {
char *ptr, *term, saved;
ptr = term = str + 4;
while (isalpha(*term))
term++;
if (term == ptr)
return 2;
saved = *term;
*term = 0;
if (strncmp(ptr, "failed", 6) == 0)
s->success = S_FAILED;
else
s->success = S_SUCCESS;
*term = saved;
}
}
return 0;
} | false | false | false | false | false | 0 |
__mm_rotate_right(struct ibv_mem_node *node)
{
struct ibv_mem_node *tmp;
tmp = node->left;
node->left = tmp->right;
if (node->left)
node->left->parent = node;
if (node->parent) {
if (node->parent->right == node)
node->parent->right = tmp;
else
node->parent->left = tmp;
} else
mm_root = tmp;
tmp->parent = node->parent;
tmp->right = node;
node->parent = tmp;
} | false | false | false | false | false | 0 |
getData(const PosChunkIdx& ci)
{
int e = getEntryNum(ci);
int state = chunktable.getDiskState(ci);
if (state == ChunkSet::CHUNK_UNKNOWN)
stats.misses++;
else
stats.hits++;
// if we've already tried and failed to read the chunk, don't try again
if (state == ChunkSet::CHUNK_CORRUPTED || state == ChunkSet::CHUNK_MISSING)
return &blankdata;
// if the chunk is in the cache, return it
if (state == ChunkSet::CHUNK_CACHED)
{
if (entries[e].ci != ci)
{
cerr << "grievous cache failure!" << endl;
cerr << "[" << ci.x << "," << ci.z << "] [" << entries[e].ci.x << "," << entries[e].ci.z << "]" << endl;
exit(-1);
}
return &entries[e].data;
}
// if this is a full render and the chunk is not required, we already know it doesn't exist
bool req = chunktable.isRequired(ci);
if (fullrender && !req)
{
stats.skipped++;
chunktable.setDiskState(ci, ChunkSet::CHUNK_MISSING);
return &blankdata;
}
// okay, we actually have to read the chunk from disk
if (regionformat)
readRegionFile(ci.toChunkIdx().getRegionIdx());
else
readChunkFile(ci);
// check whether the read succeeded; return the data if so
state = chunktable.getDiskState(ci);
if (state == ChunkSet::CHUNK_CORRUPTED)
{
stats.corrupt++;
return &blankdata;
}
if (state == ChunkSet::CHUNK_MISSING)
{
if (req)
stats.reqmissing++;
else
stats.missing++;
return &blankdata;
}
if (state != ChunkSet::CHUNK_CACHED || entries[e].ci != ci)
{
cerr << "grievous cache failure!" << endl;
cerr << "[" << ci.x << "," << ci.z << "] [" << entries[e].ci.x << "," << entries[e].ci.z << "]" << endl;
exit(-1);
}
stats.read++;
return &entries[e].data;
} | false | false | false | false | false | 0 |
autohelperowl_attackpat179(int trans, int move, int color, int action)
{
int b, c, d, e, A;
UNUSED(color);
UNUSED(action);
b = AFFINE_TRANSFORM(722, trans, move);
c = AFFINE_TRANSFORM(721, trans, move);
d = AFFINE_TRANSFORM(647, trans, move);
e = AFFINE_TRANSFORM(720, trans, move);
A = AFFINE_TRANSFORM(648, trans, move);
return countlib(A) == 3 && !obvious_false_eye(d, OTHER_COLOR(color))&& play_attack_defend_n(color, 0, 3, move, b, c, move) && play_attack_defend_n(color, 0, 3, move, e, c, move)&& play_attack_defend2_n(color, 0, 5, move, c, b, d, e, b, e);
} | false | false | false | false | false | 0 |
ncx_get_int_schar(const void *xp, schar *ip)
{
ix_int xx;
get_ix_int(xp, &xx);
*ip = xx;
if(xx > SCHAR_MAX || xx < SCHAR_MIN)
return NC_ERANGE;
return ENOERR;
} | false | false | false | false | false | 0 |
mlx4_en_fill_hwtstamps(struct mlx4_en_dev *mdev,
struct skb_shared_hwtstamps *hwts,
u64 timestamp)
{
unsigned long flags;
u64 nsec;
read_lock_irqsave(&mdev->clock_lock, flags);
nsec = timecounter_cyc2time(&mdev->clock, timestamp);
read_unlock_irqrestore(&mdev->clock_lock, flags);
memset(hwts, 0, sizeof(struct skb_shared_hwtstamps));
hwts->hwtstamp = ns_to_ktime(nsec);
} | false | false | false | false | false | 0 |
changedEntriesVariable(GtkWidget *entry, gpointer data)
{
G_CONST_RETURN gchar* entrytext = NULL;
MolcasTypeVariable* type;
if(!GTK_IS_WIDGET(entry)) return;
type = g_object_get_data(G_OBJECT (entry), "Type");
if(type == NULL) return ;
entrytext = gtk_entry_get_text(GTK_ENTRY(entry));
if(strlen(entrytext)<1)return;
switch(*type)
{
case MOLCAS_TYPE_VARIABLE_MEM :
if(strstr(entrytext,_("Default")) || strstr(entrytext,_("largest possible")) )
{
gtk_widget_set_sensitive(entry, FALSE);
}
else
{
gtk_widget_set_sensitive(entry, TRUE);
}
if(strstr(entrytext,_("Default")) || strstr(entrytext,_("largest possible")) || atof(entrytext) != 0)
sprintf(molcasSystemVariablesTmp.mem,"%s",entrytext);
break;
case MOLCAS_TYPE_VARIABLE_DISK :
if(strstr(entrytext,_("Default")) || strstr(entrytext,_("Limited to 2 GBytes")) )
{
gtk_widget_set_sensitive(entry, FALSE);
}
else
{
gtk_widget_set_sensitive(entry, TRUE);
}
if(strstr(entrytext,_("Default")) || strstr(entrytext,_("Limited to 2 GBytes")) || atof(entrytext) != 0)
sprintf(molcasSystemVariablesTmp.disk, "%s", entrytext);
break;
case MOLCAS_TYPE_VARIABLE_RAMD :
if(strstr(entrytext,_("Default")))
{
gtk_widget_set_sensitive(entry, FALSE);
}
else
{
gtk_widget_set_sensitive(entry, TRUE);
}
if(strstr(entrytext,_("Default")) || atof(entrytext) != 0)
sprintf(molcasSystemVariablesTmp.ramd, "%s",entrytext);
break;
case MOLCAS_TYPE_VARIABLE_TRAP :
gtk_widget_set_sensitive(entry, FALSE);
sprintf(molcasSystemVariablesTmp.trap, "%s",entrytext);
break;
case MOLCAS_TYPE_VARIABLE_WORKDIR :
if(strstr(entrytext,_("Default")))
{
gtk_widget_set_sensitive(entry, FALSE);
}
else
{
gtk_widget_set_sensitive(entry, TRUE);
}
sprintf(molcasSystemVariablesTmp.workDir, "%s",entrytext);
break;
}
} | false | true | false | false | false | 1 |
enableDisableSelectionClicked(bool isEnable)
{
const bool prevBlockItemChanged = m_blockItemChanged;
m_blockItemChanged = true;
foreach(QTreeWidgetItem *twItem, m_ui.treeWidget->selectedItems()) {
CaCertificateItem *item = dynamic_cast<CaCertificateItem *>(twItem);
Q_ASSERT(item);
if (item) {
item->setEnabled(isEnable);
}
}
emit changed(true);
m_blockItemChanged = prevBlockItemChanged;
// now make sure that the buttons are enabled as appropriate
itemSelectionChanged();
} | false | false | false | false | false | 0 |
ffi_checkctype(lua_State *L, CTState *cts, TValue *param)
{
TValue *o = L->base;
if (!(o < L->top)) {
err_argtype:
lj_err_argtype(L, 1, "C type");
}
if (tvisstr(o)) { /* Parse an abstract C type declaration. */
GCstr *s = strV(o);
CPState cp;
int errcode;
cp.L = L;
cp.cts = cts;
cp.srcname = strdata(s);
cp.p = strdata(s);
cp.param = param;
cp.mode = CPARSE_MODE_ABSTRACT|CPARSE_MODE_NOIMPLICIT;
errcode = lj_cparse(&cp);
if (errcode) lj_err_throw(L, errcode); /* Propagate errors. */
return cp.val.id;
} else {
GCcdata *cd;
if (!tviscdata(o)) goto err_argtype;
if (param && param < L->top) lj_err_arg(L, 1, LJ_ERR_FFI_NUMPARAM);
cd = cdataV(o);
return cd->ctypeid == CTID_CTYPEID ? *(CTypeID *)cdataptr(cd) : cd->ctypeid;
}
} | false | false | false | false | false | 0 |
verbose_updatetags(char *path, int seqno, int skip)
{
if (total)
fprintf(stderr, " [%d/%d]", seqno, total);
else
fprintf(stderr, " [%d]", seqno);
fprintf(stderr, " adding tags of %s", path);
if (skip)
fprintf(stderr, " (skipped)");
fputc('\n', stderr);
} | false | false | false | false | false | 0 |
compare_decls_by_uid (const void *pa, const void *pb)
{
const numbered_tree *nt_a = ((const numbered_tree *)pa);
const numbered_tree *nt_b = ((const numbered_tree *)pb);
if (DECL_UID (nt_a->t) != DECL_UID (nt_b->t))
return DECL_UID (nt_a->t) - DECL_UID (nt_b->t);
return nt_a->num - nt_b->num;
} | false | false | false | false | false | 0 |
FetchData( IDirectFBDataBuffer *buffer, void *data, unsigned int len )
{
DFBResult ret = DFB_OK;
do {
unsigned int read = 0;
ret = buffer->WaitForData( buffer, len );
if (ret == DFB_OK)
ret = buffer->GetData( buffer, len, data, &read );
if (ret)
break;
data += read;
len -= read;
} while (len);
return ret;
} | false | true | false | false | true | 1 |
snd_err_msg_default(const char *file, int line, const char *function, int err, const char *fmt, ...)
{
va_list arg;
const char *verbose;
verbose = getenv("LIBASOUND_DEBUG");
if (! verbose || ! *verbose)
return;
va_start(arg, fmt);
fprintf(stderr, "ALSA lib %s:%i:(%s) ", file, line, function);
vfprintf(stderr, fmt, arg);
if (err)
fprintf(stderr, ": %s", snd_strerror(err));
putc('\n', stderr);
va_end(arg);
#ifdef ALSA_DEBUG_ASSERT
verbose = getenv("LIBASOUND_DEBUG_ASSERT");
if (verbose && *verbose)
assert(0);
#endif
} | false | false | false | false | true | 1 |
_cmd_cipher_suite_id (char **argv)
{
assert (argv);
if (argv[1])
{
char *endptr;
int tmp;
errno = 0;
tmp = strtol (argv[1], &endptr, 10);
if (errno
|| endptr[0] != '\0'
|| tmp < IPMI_CIPHER_SUITE_ID_MIN
|| tmp > IPMI_CIPHER_SUITE_ID_MAX)
ipmipower_cbuf_printf (ttyout,
"%s invalid cipher suite id\n",
argv[1]);
else if (!IPMI_CIPHER_SUITE_ID_SUPPORTED (tmp))
ipmipower_cbuf_printf (ttyout,
"%s unsupported cipher suite id\n",
argv[1]);
else
{
cmd_args.common.cipher_suite_id = tmp;
ipmipower_cbuf_printf (ttyout,
"cipher suite id is now %s\n",
argv[1]);
}
}
else
ipmipower_cbuf_printf (ttyout,
"cipher_suite_id must be specified: 0, 1, 2, 3, 6, 7, 8, 11, 12\n");
} | false | false | false | false | false | 0 |
fill_buffer_with_pattern(XferSourcePattern *self, char *buf,
size_t len)
{
char *src = self->pattern, *dst = buf;
size_t plen = self->pattern_buffer_length, offset = self->current_offset;
size_t pos = 0;
src += offset;
while (pos < len) {
*dst++ = *src++;
pos++, offset++;
if (G_LIKELY(offset < plen))
continue;
offset = 0;
src = self->pattern;
}
self->current_offset = offset;
} | false | false | false | false | false | 0 |
ReadNeededConstraints(
void *theEnv)
{
GenReadBinary(theEnv,(void *) &ConstraintData(theEnv)->NumberOfConstraints,(unsigned long)
sizeof(unsigned long int));
if (ConstraintData(theEnv)->NumberOfConstraints == 0) return;
ConstraintData(theEnv)->ConstraintArray = (CONSTRAINT_RECORD *)
genlongalloc(theEnv,(unsigned long) (sizeof(CONSTRAINT_RECORD) *
ConstraintData(theEnv)->NumberOfConstraints));
BloadandRefresh(theEnv,ConstraintData(theEnv)->NumberOfConstraints,sizeof(BSAVE_CONSTRAINT_RECORD),
CopyFromBsaveConstraintRecord);
} | false | false | false | false | false | 0 |
CControlStartConversion(w, clientwindow, valuemask, value)
Widget w;
Window clientwindow;
unsigned long valuemask;
ConversionAttributes *value;
{
ConversionControlWidget ccw = (ConversionControlWidget)w;
ConversionControlWidgetClass class = (ConversionControlWidgetClass)w->core.widget_class;
TRACE(("CControlStartConversion(clientwindow=%lx)\n", clientwindow));
if (ccw->ccontrol.active) {
WidgetWarning(w, "busyError", "CControlStartConversion",
"is busy. can't start conversion");
return;
}
if (clientwindow == None) {
/* ouch */
WidgetWarning(w, "dataError", "cControlStartConversion",
"clientWindow not specified. can't start conversion.");
return;
}
/* check clientWindow's existance */
if (!SafeGetWindowAttributes(XtDisplay(w), clientwindow,
&(ccw->ccontrol.client_attr))) {
WidgetWarning(w, "badWindowError", "clientWindow",
"clientWindow does not exist. can't start conversion.");
return;
}
ICClearConversion(ccw->ccontrol.inputobj);
ccw->ccontrol.notext = ICNumSegments(ccw->ccontrol.inputobj) == 0;
ccw->ccontrol.active = True;
ccw->ccontrol.clientwindow = clientwindow;
/* check given attributes */
CheckAttributes(ccw, &valuemask, value);
if (valuemask & CAFocusWindow) {
ccw->ccontrol.focuswindow = value->focuswindow;
} else {
ccw->ccontrol.focuswindow = clientwindow;
ccw->ccontrol.focus_attr = ccw->ccontrol.client_attr;
}
if (ccw->ccontrol.eventselectmethod == ESMethodInputOnly) {
InterceptClientKeyEvent(ccw);
} else if (ccw->ccontrol.eventselectmethod == ESMethodSelectFocus) {
SelectFocusKeyEvent(ccw);
}
CheckCoordinates(ccw, &valuemask, value, 1);
GetClientCoordinates(ccw);
CaptureClientDead(ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNfixNotify, FixCallback, (XtPointer)ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNendNotify, ConversionEndCallback, (XtPointer)ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNtextChangeNotify, TextChangeCallback, (XtPointer)ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNmodeChangeNotify, ModeChangeCallback, (XtPointer)ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNselectionControl, SelectionControlCallback,
(XtPointer)ccw);
XtAddCallback(ccw->ccontrol.inputobj,
XtNauxControl, AuxControlCallback,
(XtPointer)ccw);
/* call input style dependent startup */
(*class->conversionControl_class.Startup)(w, valuemask, value);
} | false | false | false | false | false | 0 |
thermal_init(struct ibm_init_struct *iibm)
{
u8 t, ta1, ta2;
int i;
int acpi_tmp7;
int res;
vdbg_printk(TPACPI_DBG_INIT, "initializing thermal subdriver\n");
acpi_tmp7 = acpi_evalf(ec_handle, NULL, "TMP7", "qv");
if (thinkpad_id.ec_model) {
/*
* Direct EC access mode: sensors at registers
* 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for
* non-implemented, thermal sensors return 0x80 when
* not available
*/
ta1 = ta2 = 0;
for (i = 0; i < 8; i++) {
if (acpi_ec_read(TP_EC_THERMAL_TMP0 + i, &t)) {
ta1 |= t;
} else {
ta1 = 0;
break;
}
if (acpi_ec_read(TP_EC_THERMAL_TMP8 + i, &t)) {
ta2 |= t;
} else {
ta1 = 0;
break;
}
}
if (ta1 == 0) {
/* This is sheer paranoia, but we handle it anyway */
if (acpi_tmp7) {
pr_err("ThinkPad ACPI EC access misbehaving, "
"falling back to ACPI TMPx access "
"mode\n");
thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
} else {
pr_err("ThinkPad ACPI EC access misbehaving, "
"disabling thermal sensors access\n");
thermal_read_mode = TPACPI_THERMAL_NONE;
}
} else {
thermal_read_mode =
(ta2 != 0) ?
TPACPI_THERMAL_TPEC_16 : TPACPI_THERMAL_TPEC_8;
}
} else if (acpi_tmp7) {
if (tpacpi_is_ibm() &&
acpi_evalf(ec_handle, NULL, "UPDT", "qv")) {
/* 600e/x, 770e, 770x */
thermal_read_mode = TPACPI_THERMAL_ACPI_UPDT;
} else {
/* IBM/LENOVO DSDT EC.TMPx access, max 8 sensors */
thermal_read_mode = TPACPI_THERMAL_ACPI_TMP07;
}
} else {
/* temperatures not supported on 570, G4x, R30, R31, R32 */
thermal_read_mode = TPACPI_THERMAL_NONE;
}
vdbg_printk(TPACPI_DBG_INIT, "thermal is %s, mode %d\n",
str_supported(thermal_read_mode != TPACPI_THERMAL_NONE),
thermal_read_mode);
switch (thermal_read_mode) {
case TPACPI_THERMAL_TPEC_16:
res = sysfs_create_group(&tpacpi_sensors_pdev->dev.kobj,
&thermal_temp_input16_group);
if (res)
return res;
break;
case TPACPI_THERMAL_TPEC_8:
case TPACPI_THERMAL_ACPI_TMP07:
case TPACPI_THERMAL_ACPI_UPDT:
res = sysfs_create_group(&tpacpi_sensors_pdev->dev.kobj,
&thermal_temp_input8_group);
if (res)
return res;
break;
case TPACPI_THERMAL_NONE:
default:
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
RFG_Filter_getRegionRules( RFG_Filter* filter, const char* regionName,
const char* groupName, int32_t* r_callLimit,
uint32_t* r_stackBounds, uint8_t* r_flags )
{
uint32_t i;
if( !filter )
return 0;
if( !regionName && !groupName )
{
fprintf( stderr,
"RFG_Filter_getRegionRules(): Error: Empty region and group name\n" );
return 0;
}
/* initialize return parameters by defaults */
if( r_callLimit )
{
*r_callLimit = -1;
}
if( r_stackBounds )
{
r_stackBounds[0] = 1;
r_stackBounds[1] = (uint32_t)-1;
}
if( r_flags )
{
*r_flags = 0;
}
/* search for matching filter rule either by ... */
for( i = 0; i < filter->num_region_rules; i++ )
{
const uint8_t is_group_rule =
(filter->region_rules[i].flags & RFG_FILTER_FLAG_GROUP) != 0;
if( /* ... region group name */
( is_group_rule && groupName &&
fnmatch( filter->region_rules[i].pattern, groupName, 0 ) == 0 ) ||
/* ... or by region name */
( !is_group_rule && regionName &&
fnmatch( filter->region_rules[i].pattern, regionName, 0 ) == 0 ) )
{
/* set return parameters regarding to found filter rules */
if( r_callLimit )
{
*r_callLimit = filter->region_rules[i].call_limit;
}
if( r_stackBounds )
{
r_stackBounds[0] = filter->region_rules[i].stack_bounds[0];
r_stackBounds[1] = filter->region_rules[i].stack_bounds[1];
}
if( r_flags )
{
*r_flags = filter->region_rules[i].flags;
}
/* abort searching on first matching filter rule */
break;
}
}
return 1;
} | false | false | false | false | false | 0 |
skip_idletters(srcPosn pos)
{
int c;
#ifdef DEBUG_IS_KEYWORD
if(debug_lexer && getenv("VERBOSE"))
(void)fprintf(list_fd,": skipping letters...");
#endif
while(c=pos.Line->line[pos.idx],
(isidletter(c) || isadigit(c) || isspace(c)))
stepPosn(&pos);
return pos;
} | false | false | false | false | true | 1 |
capacity() const
{
if (_fromFile)
return _sortedPhonebook.max_size();
else
return _mePhonebook->capacity();
} | false | false | false | false | false | 0 |
pfind(C *v,C *d,C *f,I m)
{
Z C s[MAXPATHLEN];
if(*f=='/')R unloadable(f,m)?0:f;
for((v&&(v=getenv(v)))?d=v:0;d;) {
if(v=(C *)strchr(d,':'))*s=0,strncat(s,d,v-d),d=v+1;
else strcpy(s,d),d=0;
strcat(s,"/"),strcat(s,f);
if(!unloadable(s,m))R s;
}
R 0;
} | false | false | false | false | false | 0 |
bcma_pcicore_serdes_workaround(struct bcma_drv_pci *pc)
{
u16 tmp;
bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_RX,
BCMA_CORE_PCI_SERDES_RX_CTRL,
bcma_pcicore_polarity_workaround(pc));
tmp = bcma_pcie_mdio_read(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
BCMA_CORE_PCI_SERDES_PLL_CTRL);
if (tmp & BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN)
bcma_pcie_mdio_write(pc, BCMA_CORE_PCI_MDIODATA_DEV_PLL,
BCMA_CORE_PCI_SERDES_PLL_CTRL,
tmp & ~BCMA_CORE_PCI_PLL_CTRL_FREQDET_EN);
} | false | false | false | false | false | 0 |
client3_getspec_cbk (struct rpc_req *req, struct iovec *iov, int count,
void *myframe)
{
gf_getspec_rsp rsp = {0,};
call_frame_t *frame = NULL;
int ret = 0;
frame = myframe;
if (!frame || !frame->this) {
gf_log (THIS->name, GF_LOG_ERROR, "frame not found with the request, "
"returning EINVAL");
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (-1 == req->rpc_status) {
gf_log (frame->this->name, GF_LOG_WARNING,
"received RPC status error, returning ENOTCONN");
rsp.op_ret = -1;
rsp.op_errno = ENOTCONN;
goto out;
}
ret = xdr_to_generic (*iov, &rsp, (xdrproc_t)xdr_gf_getspec_rsp);
if (ret < 0) {
gf_log (frame->this->name, GF_LOG_ERROR,
"XDR decoding failed, returning EINVAL");
rsp.op_ret = -1;
rsp.op_errno = EINVAL;
goto out;
}
if (-1 == rsp.op_ret) {
gf_log (frame->this->name, GF_LOG_WARNING,
"failed to get the 'volume file' from server");
goto out;
}
out:
CLIENT_STACK_UNWIND (getspec, frame, rsp.op_ret, rsp.op_errno,
rsp.spec);
/* Don't use 'GF_FREE', this is allocated by libc */
free (rsp.spec);
return 0;
} | false | false | false | true | false | 1 |
rand_gauss()
{
static bool is_saved = false;
static double saved;
if (!is_saved) {
double rsq, x1, x2;
while(1) {
x1 = rand_1_1();
x2 = rand_1_1();
rsq = x1 * x1 + x2 * x2;
if (rsq >= TINY && rsq < 1)
break;
}
double f = sqrt(-2. * log(rsq) / rsq);
saved = x1 * f;
is_saved = true;
return x2 * f;
}
else {
is_saved = false;
return saved;
}
} | false | false | false | false | false | 0 |
removeGridlines(char *pixels, int width, int height,
const Transform *transform, CoordSettings coordSettings,
GridRemovalSettings gridSettings, PixelState pixelStateRemoved)
{
ASSERT_ENGAUGE(transform != 0);
if (transform->validAxes())
{
// get removal gridlines
GridMesh gridMesh;
GridlinesScreen gridlines;
gridlines = gridMesh.makeGridLines(transform, coordSettings, gridSettings.gridMesh);
GridlinesScreen::iterator itr;
for (itr = gridlines.begin(); itr != gridlines.end(); ++itr)
{
int xStart = (*itr).start.x();
int yStart = (*itr).start.y();
int xStop = (*itr).stop.x();
int yStop = (*itr).stop.y();
if (dabs(xStop - xStart) < dabs(yStop - yStart))
removeGridlineVertical(pixels, width, height, xStart, yStart, xStop, yStop,
gridSettings, pixelStateRemoved);
else
removeGridlineHorizontal(pixels, width, height, xStart, yStart, xStop, yStop,
gridSettings, pixelStateRemoved);
}
}
} | false | false | false | true | false | 1 |
message_add_redirect_header (SoupMessage *msg,
GFileQueryInfoFlags flags)
{
const char *header_redirect;
/* RFC 4437 */
if (flags & G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS)
header_redirect = "F";
else
header_redirect = "T";
soup_message_headers_append (msg->request_headers,
"Apply-To-Redirect-Ref",
header_redirect);
} | false | false | false | false | false | 0 |
create_dll_header()
{
dll_header *THIS = (dll_header *)calloc(sizeof(dll_header), 1);
if(!THIS){ aisc_server_error = "Malloc error in create_dll_header !"; return 0;}
return THIS; } | false | false | false | false | false | 0 |
Normalize(R3Grid *grid, int normalization_type)
{
// Check normalization type
if (normalization_type == 0) return;
// Start statistics
RNTime start_time;
start_time.Read();
// Compute statistics of non-zero entries
int count = 0;
RNScalar sum = 0;
RNScalar mean = 0;
RNScalar variance = 0;
RNScalar stddev = 0;
RNScalar minimum = FLT_MAX;
for (int i = 0; i < grid->NEntries(); i++) {
RNScalar value = grid->GridValue(i);
if (value != 0) {
if (value < minimum) minimum = value;
sum += value;
count++;
}
}
if (count > 0) {
mean = sum / (RNScalar) count;
RNScalar ssd = 0;
for (int i = 0; i < grid->NEntries(); i++) {
RNScalar value = grid->GridValue(i);
if (value != 0) {
RNScalar residual = value - mean;
ssd += residual * residual;
}
}
variance = ssd / (RNScalar) count;
stddev = sqrt(variance);
}
// Normalize the grid
if (normalization_type == 1) {
// Divide by L1Norm
RNScalar l1norm = grid->L1Norm();
if (l1norm > 0) grid->Divide(l1norm);
}
else if (normalization_type == 2) {
// Scale by L2 norm
if (mean != 0) grid->Normalize();
}
else if (normalization_type == 3) {
// Shift mean to zero, and scale by stddev
if (mean != 0) grid->Subtract(mean);
if (stddev != 0) grid->Divide(stddev);
}
else if (normalization_type == 4) {
// Make everything positive starting at zero and scale by mean
RNScalar scale = mean - minimum;
if (scale != 0) {
for (int i = 0; i < grid->NEntries(); i++) {
RNScalar value = grid->GridValue(i);
if (value != 0) {
grid->SetGridValue(i, (value - minimum) / scale);
}
}
}
}
// Print statistics
if (print_verbose) {
printf("Normalized grid .. \n");
printf(" Time = %.2f seconds\n", start_time.Elapsed());
printf(" Normalization type = %d\n", normalization_type);
printf(" Mean = %g\n", mean);
printf(" Variance = %g\n", variance);
printf(" Standard deviation = %g\n", stddev);
printf(" Cardinality = %d\n", grid->Cardinality());
printf(" Volume = %g\n", grid->Volume());
RNInterval grid_range = grid->Range();
printf(" Minimum = %g\n", grid_range.Min());
printf(" Maximum = %g\n", grid_range.Max());
printf(" L1Norm = %g\n", grid->L1Norm());
printf(" L2Norm = %g\n", grid->L2Norm());
fflush(stdout);
}
} | false | false | false | false | false | 0 |
set_temp(struct device *dev, struct device_attribute *devattr,
const char *buf, size_t count)
{
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
struct jc42_data *data = dev_get_drvdata(dev);
int err, ret = count;
int nr = attr->index;
long val;
if (kstrtol(buf, 10, &val) < 0)
return -EINVAL;
mutex_lock(&data->update_lock);
data->temp[nr] = jc42_temp_to_reg(val, data->extended);
err = i2c_smbus_write_word_swapped(data->client, temp_regs[nr],
data->temp[nr]);
if (err < 0)
ret = err;
mutex_unlock(&data->update_lock);
return ret;
} | false | false | false | false | false | 0 |
textiowrapper_read(textio *self, PyObject *args)
{
Py_ssize_t n = -1;
PyObject *result = NULL, *chunks = NULL;
CHECK_INITIALIZED(self);
if (!PyArg_ParseTuple(args, "|O&:read", &_PyIO_ConvertSsize_t, &n))
return NULL;
CHECK_CLOSED(self);
if (self->decoder == NULL)
return _unsupported("not readable");
if (_textiowrapper_writeflush(self) < 0)
return NULL;
if (n < 0) {
/* Read everything */
PyObject *bytes = _PyObject_CallMethodId(self->buffer, &PyId_read, NULL);
PyObject *decoded;
if (bytes == NULL)
goto fail;
if (Py_TYPE(self->decoder) == &PyIncrementalNewlineDecoder_Type)
decoded = _PyIncrementalNewlineDecoder_decode(self->decoder,
bytes, 1);
else
decoded = PyObject_CallMethodObjArgs(
self->decoder, _PyIO_str_decode, bytes, Py_True, NULL);
Py_DECREF(bytes);
if (decoded == NULL)
goto fail;
result = textiowrapper_get_decoded_chars(self, -1);
if (result == NULL) {
Py_DECREF(decoded);
return NULL;
}
PyUnicode_AppendAndDel(&result, decoded);
if (result == NULL)
goto fail;
Py_CLEAR(self->snapshot);
return result;
}
else {
int res = 1;
Py_ssize_t remaining = n;
result = textiowrapper_get_decoded_chars(self, n);
if (result == NULL)
goto fail;
if (PyUnicode_READY(result) == -1)
goto fail;
remaining -= PyUnicode_GET_LENGTH(result);
/* Keep reading chunks until we have n characters to return */
while (remaining > 0) {
res = textiowrapper_read_chunk(self, remaining);
if (res < 0)
goto fail;
if (res == 0) /* EOF */
break;
if (chunks == NULL) {
chunks = PyList_New(0);
if (chunks == NULL)
goto fail;
}
if (PyUnicode_GET_LENGTH(result) > 0 &&
PyList_Append(chunks, result) < 0)
goto fail;
Py_DECREF(result);
result = textiowrapper_get_decoded_chars(self, remaining);
if (result == NULL)
goto fail;
remaining -= PyUnicode_GET_LENGTH(result);
}
if (chunks != NULL) {
if (result != NULL && PyList_Append(chunks, result) < 0)
goto fail;
Py_CLEAR(result);
result = PyUnicode_Join(_PyIO_empty_str, chunks);
if (result == NULL)
goto fail;
Py_CLEAR(chunks);
}
return result;
}
fail:
Py_XDECREF(result);
Py_XDECREF(chunks);
return NULL;
} | false | false | false | false | false | 0 |
_loadMap(unsigned int pMapId, const std::string& basePath, uint32 tileX, uint32 tileY)
{
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(pMapId);
if (instanceTree == iInstanceMapTrees.end())
{
std::string mapFileName = getMapFileName(pMapId);
StaticMapTree* newTree = new StaticMapTree(pMapId, basePath);
if (!newTree->InitMap(mapFileName, this))
return false;
instanceTree = iInstanceMapTrees.insert(InstanceTreeMap::value_type(pMapId, newTree)).first;
}
return instanceTree->second->LoadMapTile(tileX, tileY, this);
} | false | false | false | false | false | 0 |
UndominateInitializers(JSParseNode *left, JSParseNode *right, JSTreeContext *tc)
{
FindPropValData fpvd;
JSParseNode *lhs, *rhs;
JS_ASSERT(left->pn_type != TOK_ARRAYCOMP);
JS_ASSERT(right);
#if JS_HAS_DESTRUCTURING_SHORTHAND
if (right->pn_arity == PN_LIST && (right->pn_xflags & PNX_DESTRUCT)) {
js_ReportCompileErrorNumber(tc->compiler->context, TS(tc->compiler), right,
JSREPORT_ERROR, JSMSG_BAD_OBJECT_INIT);
return JS_FALSE;
}
#endif
if (right->pn_type != left->pn_type)
return JS_TRUE;
fpvd.table.ops = NULL;
lhs = left->pn_head;
if (left->pn_type == TOK_RB) {
rhs = right->pn_head;
while (lhs && rhs) {
/* Nullary comma is an elision; binary comma is an expression.*/
if (lhs->pn_type != TOK_COMMA || lhs->pn_arity != PN_NULLARY) {
if (lhs->pn_type == TOK_RB || lhs->pn_type == TOK_RC) {
if (!UndominateInitializers(lhs, rhs, tc))
return JS_FALSE;
} else {
lhs->pn_pos.end = rhs->pn_pos.end;
}
}
lhs = lhs->pn_next;
rhs = rhs->pn_next;
}
} else {
JS_ASSERT(left->pn_type == TOK_RC);
fpvd.numvars = left->pn_count;
fpvd.maxstep = 0;
while (lhs) {
JS_ASSERT(lhs->pn_type == TOK_COLON);
JSParseNode *pn = lhs->pn_right;
rhs = FindPropertyValue(right, lhs->pn_left, &fpvd);
if (pn->pn_type == TOK_RB || pn->pn_type == TOK_RC) {
if (rhs && !UndominateInitializers(pn, rhs, tc))
return JS_FALSE;
} else {
if (rhs)
pn->pn_pos.end = rhs->pn_pos.end;
}
lhs = lhs->pn_next;
}
}
return JS_TRUE;
} | false | false | false | false | false | 0 |
__ecereProp___ecereNameSpace__ecere__gui__controls__MenuItem_Set_bitmap(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * value)
{
struct __ecereNameSpace__ecere__gui__controls__MenuItem * __ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem = (struct __ecereNameSpace__ecere__gui__controls__MenuItem *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__MenuItem->offset) : 0);
(__ecereNameSpace__ecere__com__eInstance_DecRef(__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[0]), __ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[0] = 0);
(__ecereNameSpace__ecere__com__eInstance_DecRef(__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[1]), __ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[1] = 0);
(__ecereNameSpace__ecere__com__eInstance_DecRef(__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[2]), __ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[2] = 0);
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[0] = value;
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[1] = value ? (__ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Get_alphaBlend(value) ? value : __extension__ ({
struct __ecereNameSpace__ecere__com__Instance * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__gfx__BitmapResource);
__ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Set_fileName(__ecereInstance1, __ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Get_fileName(value)), __ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Set_monochrome(__ecereInstance1, 0x1), __ecereInstance1;
})) : (((void *)0));
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[2] = value ? __extension__ ({
struct __ecereNameSpace__ecere__com__Instance * __ecereInstance1 = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__gfx__BitmapResource);
__ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Set_fileName(__ecereInstance1, __ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Get_fileName(value)), __ecereProp___ecereNameSpace__ecere__gfx__BitmapResource_Set_grayed(__ecereInstance1, 0x1), __ecereInstance1;
}) : (((void *)0));
if(value)
{
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[0]->_refCount++;
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[1]->_refCount++;
__ecerePointer___ecereNameSpace__ecere__gui__controls__MenuItem->bitmaps[2]->_refCount++;
}
__ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(this, __ecereProp___ecereNameSpace__ecere__gui__controls__MenuItem_bitmap), __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(this, __ecerePropM___ecereNameSpace__ecere__gui__controls__MenuItem_bitmap);
} | false | false | false | false | false | 0 |
R_PointOnSegSide
( fixed_t x,
fixed_t y,
seg_t* line )
{
fixed_t lx;
fixed_t ly;
fixed_t ldx;
fixed_t ldy;
fixed_t dx;
fixed_t dy;
fixed_t left;
fixed_t right;
lx = line->v1->x;
ly = line->v1->y;
ldx = line->v2->x - lx;
ldy = line->v2->y - ly;
if (!ldx)
{
if (x <= lx)
return ldy > 0;
return ldy < 0;
}
if (!ldy)
{
if (y <= ly)
return ldx < 0;
return ldx > 0;
}
dx = (x - lx);
dy = (y - ly);
// Try to quickly decide by looking at sign bits.
if ( (ldy ^ ldx ^ dx ^ dy)&0x80000000 )
{
if ( (ldy ^ dx) & 0x80000000 )
{
// (left is negative)
return 1;
}
return 0;
}
left = FixedMul ( ldy>>FRACBITS , dx );
right = FixedMul ( dy , ldx>>FRACBITS );
if (right < left)
{
// front side
return 0;
}
// back side
return 1;
} | false | false | false | false | false | 0 |
free_list(cfg_parser_t *pctx, cfg_obj_t *obj) {
cfg_listelt_t *elt, *next;
for (elt = ISC_LIST_HEAD(obj->value.list);
elt != NULL;
elt = next)
{
next = ISC_LIST_NEXT(elt, link);
free_list_elt(pctx, elt);
}
} | false | false | false | false | false | 0 |
pkey_hmac_copy(EVP_PKEY_CTX *dst, EVP_PKEY_CTX *src)
{
HMAC_PKEY_CTX *sctx, *dctx;
if (!pkey_hmac_init(dst))
return 0;
sctx = src->data;
dctx = dst->data;
dctx->md = sctx->md;
HMAC_CTX_init(&dctx->ctx);
if (!HMAC_CTX_copy(&dctx->ctx, &sctx->ctx))
return 0;
if (sctx->ktmp.data)
{
if (!ASN1_OCTET_STRING_set(&dctx->ktmp,
sctx->ktmp.data, sctx->ktmp.length))
return 0;
}
return 1;
} | false | false | false | false | false | 0 |
create_account_list ( GtkTreeModel * model )
{
GSList *list_tmp;
GtkTreeIter parent, child;
GtkTreePath * path;
gtk_tree_model_get_iter_first ( GTK_TREE_MODEL(navigation_model), &parent );
/* Remove childs if any. */
while ( gtk_tree_model_iter_children ( model, &child, &parent ) )
{
gtk_tree_store_remove ( GTK_TREE_STORE(model), &child );
}
/* Fill in with accounts. */
list_tmp = gsb_data_account_get_list_accounts ();
while ( list_tmp )
{
gint i = gsb_data_account_get_no_account ( list_tmp -> data );
if ( etat.show_closed_accounts ||
! gsb_data_account_get_closed_account ( i ) )
{
gsb_gui_navigation_add_account ( i, FALSE );
}
list_tmp = list_tmp -> next;
}
/* Expand stuff */
path = gtk_tree_model_get_path ( GTK_TREE_MODEL(navigation_model), &parent );
gtk_tree_view_expand_to_path ( GTK_TREE_VIEW(navigation_tree_view), path );
gtk_tree_path_free ( path );
} | false | false | false | false | false | 0 |
rc_sys_v1(void)
{
#ifdef PREFIX
return RC_SYS_PREFIX;
#else
#ifdef __FreeBSD__
int jailed = 0;
size_t len = sizeof(jailed);
if (sysctlbyname("security.jail.jailed", &jailed, &len, NULL, 0) == 0)
if (jailed == 1)
return RC_SYS_JAIL;
#endif
#ifdef __NetBSD__
if (exists("/kern/xen/privcmd"))
return RC_SYS_XEN0;
if (exists("/kern/xen"))
return RC_SYS_XENU;
#endif
#ifdef __linux__
if (exists("/proc/xen")) {
if (file_regex("/proc/xen/capabilities", "control_d"))
return RC_SYS_XEN0;
return RC_SYS_XENU;
} else if (file_regex("/proc/cpuinfo", "UML"))
return RC_SYS_UML;
else if (file_regex("/proc/self/status",
"(s_context|VxID):[[:space:]]*[1-9]"))
return RC_SYS_VSERVER;
else if (exists("/proc/vz/veinfo") && !exists("/proc/vz/version"))
return RC_SYS_OPENVZ;
else if (file_regex("/proc/self/status",
"envID:[[:space:]]*[1-9]"))
return RC_SYS_OPENVZ; /* old test */
#endif
return NULL;
#endif /* PREFIX */
} | false | false | false | false | false | 0 |
expWriteBytesAndLogIfTtyU(esPtr,buf,lenChars)
ExpState *esPtr;
Tcl_UniChar *buf;
int lenChars;
{
int wc;
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
if (esPtr->valid)
wc = expWriteCharsUni(esPtr,buf,lenChars);
if (tsdPtr->logChannel && ((esPtr->fdout == 1) || expDevttyIs(esPtr))) {
Tcl_DString ds;
Tcl_DStringInit (&ds);
Tcl_UniCharToUtfDString (buf,lenChars,&ds);
Tcl_WriteChars(tsdPtr->logChannel,Tcl_DStringValue (&ds), Tcl_DStringLength (&ds));
Tcl_DStringFree (&ds);
}
return wc;
} | false | false | false | false | true | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.