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 |
|---|---|---|---|---|---|---|
cafe_smbus_read_data(struct cafe_camera *cam,
u16 addr, u8 command, u8 *value)
{
unsigned int rval;
unsigned long flags;
struct mcam_camera *mcam = &cam->mcam;
spin_lock_irqsave(&mcam->dev_lock, flags);
rval = TWSIC0_EN | ((addr << TWSIC0_SID_SHIFT) & TWSIC0_SID);
rval |= TWSIC0_OVMAGIC; /* Make OV sensors work */
/*
* Marvel sez set clkdiv to all 1's for now.
*/
rval |= TWSIC0_CLKDIV;
mcam_reg_write(mcam, REG_TWSIC0, rval);
(void) mcam_reg_read(mcam, REG_TWSIC1); /* force write */
rval = TWSIC1_READ | ((command << TWSIC1_ADDR_SHIFT) & TWSIC1_ADDR);
mcam_reg_write(mcam, REG_TWSIC1, rval);
spin_unlock_irqrestore(&mcam->dev_lock, flags);
wait_event_timeout(cam->smbus_wait,
cafe_smbus_read_done(mcam), CAFE_SMBUS_TIMEOUT);
spin_lock_irqsave(&mcam->dev_lock, flags);
rval = mcam_reg_read(mcam, REG_TWSIC1);
spin_unlock_irqrestore(&mcam->dev_lock, flags);
if (rval & TWSIC1_ERROR) {
cam_err(cam, "SMBUS read (%02x/%02x) error\n", addr, command);
return -EIO;
}
if (!(rval & TWSIC1_RVALID)) {
cam_err(cam, "SMBUS read (%02x/%02x) timed out\n", addr,
command);
return -EIO;
}
*value = rval & 0xff;
return 0;
} | false | false | false | false | false | 0 |
mask_color_updated_cb(GtkWidget *sel, MaskColorSelectorData *mcsdata)
{
GdkColor gdkcolor;
guint16 gdkalpha;
GwyRGBA rgba;
gwy_debug("mcsdata = %p", mcsdata);
if (gtk_color_selection_is_adjusting(GTK_COLOR_SELECTION(sel)))
return;
gtk_color_selection_get_current_color(GTK_COLOR_SELECTION(sel), &gdkcolor);
gdkalpha = gtk_color_selection_get_current_alpha(GTK_COLOR_SELECTION(sel));
gwy_rgba_from_gdk_color_and_alpha(&rgba, &gdkcolor, gdkalpha);
gwy_rgba_store_to_container(&rgba, mcsdata->container, mcsdata->prefix);
if (mcsdata->color_button)
gwy_color_button_set_color(mcsdata->color_button, &rgba);
} | false | false | false | false | false | 0 |
OnRemoveScript(cb_unused wxCommandEvent& event)
{
wxListCtrl* list = XRCCTRL(*this, "chkStartupScripts", wxListCtrl);
long sel = list->GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
list->DeleteItem(sel);
m_ScriptsVector.erase(m_ScriptsVector.begin() + sel);
if (sel > list->GetItemCount())
--sel;
list->SetItemState(sel, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED, wxLIST_STATE_SELECTED | wxLIST_STATE_FOCUSED);
if (sel >= 0)
LoadItem(sel);
UpdateState();
} | false | false | false | false | false | 0 |
sge_unparse_checkpoint_option(
lListElem *job,
lList **pcmdline,
lList **alpp
) {
lListElem *ep_opt = NULL;
char *cp;
int i;
char str[1024 + 1];
u_long32 ul;
DENTER(TOP_LAYER, "sge_unparse_checkpoint_option");
if ((i = lGetUlong(job, JB_checkpoint_attr))) {
if ((cp = sge_unparse_checkpoint_attr(i, str))) {
ep_opt = sge_add_arg(pcmdline, 0, lIntT, "-c", cp);
lSetInt(ep_opt, SPA_argval_lIntT, i);
}
else {
sprintf(str, MSG_JOB_INVALIDVALUEFORCHECKPOINTATTRIBINJOB_U,
sge_u32c(lGetUlong(job, JB_job_number)));
answer_list_add(alpp, str, STATUS_ESYNTAX, ANSWER_QUALITY_ERROR);
return -1;
}
}
if ((ul = lGetUlong(job, JB_checkpoint_interval))) {
sprintf(str, sge_uu32, ul);
ep_opt = sge_add_arg(pcmdline, c_OPT, lLongT, "-c", str);
lSetLong(ep_opt, SPA_argval_lLongT, (long) ul);
}
DEXIT;
return 0;
} | false | false | false | false | false | 0 |
LEXER_set_next_token( LEXCONTEXT *pc, int init_token_value )
{
if (init_token_value != -1) {
pc->send_init_token = 1;
pc->init_token_value = init_token_value;
}
} | false | false | false | false | false | 0 |
getLayout(int *array)
{
GtkPaned *iter;
int vl, sum, nhandle, shandle;
int n;
gtk_widget_style_get (border,
"handle-size", &shandle,
(void *)NULL);
iter = next(NULL);
if (iter)
{
sum = 0;
nhandle = 0;
n = 0;
for(;;)
{
vl = get_child_width(iter); //gtk_paned_get_position(iter);
iter = next(iter);
if (!iter)
break;
if (vl)
nhandle++;
sum += vl;
array[n++] = vl;
}
if (childCount() > 1 && child(childCount() - 1)->isVisible())
array[n++] = (vertical ? height() : width()) - sum - nhandle * shandle;
else
array[n++] = 0;
}
} | false | false | false | false | true | 1 |
gst_app_sink_set_drop (GstAppSink * appsink, gboolean drop)
{
GstAppSinkPrivate *priv;
g_return_if_fail (GST_IS_APP_SINK (appsink));
priv = appsink->priv;
g_mutex_lock (priv->mutex);
if (priv->drop != drop) {
priv->drop = drop;
/* signal the change */
g_cond_signal (priv->cond);
}
g_mutex_unlock (priv->mutex);
} | false | false | false | false | false | 0 |
_gsasl_digest_md5_server_finish (Gsasl_session * sctx, void *mech_data)
{
_Gsasl_digest_md5_server_state *state = mech_data;
if (!state)
return;
digest_md5_free_challenge (&state->challenge);
digest_md5_free_response (&state->response);
digest_md5_free_finish (&state->finish);
free (state);
} | false | false | false | false | false | 0 |
poppler_document_get_form_field (PopplerDocument *document,
gint id)
{
Page *page;
unsigned pageNum;
unsigned fieldNum;
FormPageWidgets *widgets;
FormWidget *field;
FormWidget::decodeID (id, &pageNum, &fieldNum);
page = document->doc->getPage (pageNum);
if (!page)
return NULL;
widgets = page->getFormWidgets (document->doc->getCatalog ());
if (!widgets)
return NULL;
field = widgets->getWidget (fieldNum);
if (field)
return _poppler_form_field_new (document, field);
return NULL;
} | false | false | false | false | false | 0 |
MultiSolve(bool new_matrix,
const Index* airn,
const Index* ajcn,
Index nrhs,
double* rhs_vals,
bool check_NegEVals,
Index numberOfNegEVals)
{
DBG_START_METH("Ma57TSolverInterface::MultiSolve",dbg_verbosity);
// DBG_ASSERT(!check_NegEVals || ProvidesInertia());
// DBG_ASSERT(initialized_);
// DBG_ASSERT(la_!=0);
if (pivtol_changed_) {
DBG_PRINT((1,"Pivot tolerance has changed.\n"));
pivtol_changed_ = false;
// If the pivot tolerance has been changed but the matrix is not
// new, we have to request the values for the matrix again to do
// the factorization again.
if (!new_matrix) {
DBG_PRINT((1,"Ask caller to call again.\n"));
refactorize_ = true;
return SYMSOLVER_CALL_AGAIN;
}
}
// check if a factorization has to be done
DBG_PRINT((1, "new_matrix = %d\n", new_matrix));
if (new_matrix || refactorize_) {
// perform the factorization
ESymSolverStatus retval;
retval = Factorization(airn, ajcn, check_NegEVals, numberOfNegEVals);
if (retval!=SYMSOLVER_SUCCESS) {
DBG_PRINT((1, "FACTORIZATION FAILED!\n"));
return retval; // Matrix singular or error occurred
}
refactorize_ = false;
}
// do the backsolve
return Backsolve(nrhs, rhs_vals);
} | false | false | false | false | false | 0 |
client_function()
{
Netc client;
client.set_ip("192.168.1.101",true);
client.init_socket();
client.set_port(5300,true);
client.set_server_ip("192.168.1.101",true);
client.set_socket_opt();
while( !client.connect_server() )
{
printf ( "connecting\n" );
usleep(500000);
}
client.close_socket();
} | false | false | false | false | false | 0 |
cl_fd_list_cleanup(cl_raw_list_t **list_p) {
cl_fd_list_elem_t* elem = NULL;
elem = cl_fd_list_get_first_elem(*list_p);
if (elem != NULL) {
CL_LOG(CL_LOG_WARNING, "The list was NOT empty. Unregister all external file descriptors before cleanup next time, please");
}
while(elem){
cl_fd_list_unregister_fd(*list_p, elem, 1);
elem = cl_fd_list_get_next_elem(elem);
}
return cl_raw_list_cleanup(list_p);
} | false | false | false | false | true | 1 |
__talloc_link(const void *context, struct talloc_chunk *tc)
{
if (likely(context)) {
struct talloc_chunk *parent = talloc_chunk_from_ptr(context);
if (parent->child) {
parent->child->parent = NULL;
tc->next = parent->child;
tc->next->prev = tc;
} else {
tc->next = NULL;
}
tc->parent = parent;
tc->prev = NULL;
parent->child = tc;
} else {
tc->next = tc->prev = tc->parent = NULL;
}
} | false | false | false | false | false | 0 |
guessSerial()
{
#ifdef UNIX
DIR *d = opendir(DEVPATH);
char *dev = NULL;
{
struct dirent foo;
dev = malloc(sizeof(foo.d_name));
}
char found = 0;
if(d) {
struct dirent *entry;
while((entry = readdir(d))) {
if(strncmp(entry->d_name, DEVPREFIX, strlen(DEVPREFIX)) == 0) {
found = 1;
strcpy(dev, entry->d_name);
}
}
}
closedir(d);
if(found) {
char *ret = malloc(sizeof(char)*(strlen(dev) + strlen(DEVPATH "/") + 1));
strcpy(ret, DEVPATH);
strcat(ret, "/");
strcat(ret, dev);
free(dev);
return ret;
}
return NULL;
#elif WINDOWS
char *devname = calloc(strlen(DEVPREFIX) + (MAX_SERIAL_GUESSES / 10), sizeof(char));
char *num = calloc(MAX_SERIAL_GUESSES / 10, sizeof(char));
int i;
char exists = 0;
for (i = 0; i < MAX_SERIAL_GUESSES; i++)
{
strcpy(devname, DEVPREFIX);
itoa(i, num, 10);
strcat(devname, num);
HANDLE port = CreateFile(devname, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
if (port == INVALID_HANDLE_VALUE) {
/* DWORD error = GetLastError(); */
/* Check to see if the error was because some other app
* had the port open */
/* Ignore in-use ports. */
/* if (error == ERROR_ACCESS_DENIED) {
exists = 1;
}*/
} else {
/* The port was opened successfully */
exists = 1;
/* Don't forget to close the port, since we are going to
* do nothing with it anyway */
CloseHandle(port);
}
/* Add the port number to the array which will be returned */
if(exists) {
break;
}
}
free(num);
if(exists) {
return devname;
}
free(devname);
return NULL;
#endif
} | false | true | false | false | false | 1 |
mdb_choose_index(MdbTableDef *table, int *choice)
{
unsigned int i;
MdbIndex *idx;
int cost = 0;
int least = 99;
*choice = -1;
for (i=0;i<table->num_idxs;i++) {
idx = g_ptr_array_index (table->indices, i);
cost = mdb_index_compute_cost(table, idx);
//printf("cost for %s is %d\n", idx->name, cost);
if (cost && cost < least) {
least = cost;
*choice = i;
}
}
/* and the winner is: *choice */
if (least==99) return MDB_TABLE_SCAN;
return MDB_INDEX_SCAN;
} | false | false | false | false | false | 0 |
typeChar(int idPDG) {
int type = 0;
if(abs(idPDG) == 1000024) type = 1;
else if (abs(idPDG) == 1000037)type = 2;
return type;
} | false | false | false | false | false | 0 |
gdome_xmlLinkAttr(xmlNode *elem, xmlAttr *attr) {
xmlAttr *cur = NULL;
if (elem == NULL || attr == NULL)
return -1;
gdome_xmlSetParent((xmlNode *)attr, (xmlNode *)elem);
gdome_xmlSetOwner((xmlNode *)attr, gdome_xmlGetOwner(elem));
if(gdome_xmlGetAttrList(elem) == NULL) {
gdome_xmlSetAttrList(elem, attr);
return 0;
} else {
for(cur = gdome_xmlGetAttrList(elem); cur->next != NULL; cur = cur->next);
cur->next = attr;
attr->prev = cur;
return 0;
}
} | false | false | false | false | false | 0 |
mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, unsigned int mode,
unsigned int channel, u8 ato, bool atox,
unsigned int *sample)
{
u32 adc0, adc1, old_adc0;
int i, ret;
struct mc13xxx_adcdone_data adcdone_data = {
.mc13xxx = mc13xxx,
};
init_completion(&adcdone_data.done);
dev_dbg(mc13xxx->dev, "%s\n", __func__);
mc13xxx_lock(mc13xxx);
if (mc13xxx->adcflags & MC13XXX_ADC_WORKING) {
ret = -EBUSY;
goto out;
}
mc13xxx->adcflags |= MC13XXX_ADC_WORKING;
mc13xxx_reg_read(mc13xxx, MC13XXX_ADC0, &old_adc0);
adc0 = MC13XXX_ADC0_ADINC1 | MC13XXX_ADC0_ADINC2;
adc1 = MC13XXX_ADC1_ADEN | MC13XXX_ADC1_ADTRIGIGN | MC13XXX_ADC1_ASC;
if (channel > 7)
adc1 |= MC13XXX_ADC1_ADSEL;
switch (mode) {
case MC13XXX_ADC_MODE_TS:
adc0 |= MC13XXX_ADC0_ADREFEN | MC13XXX_ADC0_TSMOD0 |
MC13XXX_ADC0_TSMOD1;
adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT;
break;
case MC13XXX_ADC_MODE_SINGLE_CHAN:
adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
adc1 |= (channel & 0x7) << MC13XXX_ADC1_CHAN0_SHIFT;
adc1 |= MC13XXX_ADC1_RAND;
break;
case MC13XXX_ADC_MODE_MULT_CHAN:
adc0 |= old_adc0 & MC13XXX_ADC0_CONFIG_MASK;
adc1 |= 4 << MC13XXX_ADC1_CHAN1_SHIFT;
break;
default:
mc13xxx_unlock(mc13xxx);
return -EINVAL;
}
adc1 |= ato << MC13783_ADC1_ATO_SHIFT;
if (atox)
adc1 |= MC13783_ADC1_ATOX;
dev_dbg(mc13xxx->dev, "%s: request irq\n", __func__);
mc13xxx_irq_request(mc13xxx, MC13XXX_IRQ_ADCDONE,
mc13xxx_handler_adcdone, __func__, &adcdone_data);
mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, adc0);
mc13xxx_reg_write(mc13xxx, MC13XXX_ADC1, adc1);
mc13xxx_unlock(mc13xxx);
ret = wait_for_completion_interruptible_timeout(&adcdone_data.done, HZ);
if (!ret)
ret = -ETIMEDOUT;
mc13xxx_lock(mc13xxx);
mc13xxx_irq_free(mc13xxx, MC13XXX_IRQ_ADCDONE, &adcdone_data);
if (ret > 0)
for (i = 0; i < 4; ++i) {
ret = mc13xxx_reg_read(mc13xxx,
MC13XXX_ADC2, &sample[i]);
if (ret)
break;
}
if (mode == MC13XXX_ADC_MODE_TS)
/* restore TSMOD */
mc13xxx_reg_write(mc13xxx, MC13XXX_ADC0, old_adc0);
mc13xxx->adcflags &= ~MC13XXX_ADC_WORKING;
out:
mc13xxx_unlock(mc13xxx);
return ret;
} | false | false | false | false | false | 0 |
async_lcp_peek(struct asyncppp *ap, unsigned char *data,
int len, int inbound)
{
int dlen, fcs, i, code;
u32 val;
data += 2; /* skip protocol bytes */
len -= 2;
if (len < 4) /* 4 = code, ID, length */
return;
code = data[0];
if (code != CONFACK && code != CONFREQ)
return;
dlen = get_unaligned_be16(data + 2);
if (len < dlen)
return; /* packet got truncated or length is bogus */
if (code == (inbound? CONFACK: CONFREQ)) {
/*
* sent confreq or received confack:
* calculate the crc of the data from the ID field on.
*/
fcs = PPP_INITFCS;
for (i = 1; i < dlen; ++i)
fcs = PPP_FCS(fcs, data[i]);
if (!inbound) {
/* outbound confreq - remember the crc for later */
ap->lcp_fcs = fcs;
return;
}
/* received confack, check the crc */
fcs ^= ap->lcp_fcs;
ap->lcp_fcs = -1;
if (fcs != 0)
return;
} else if (inbound)
return; /* not interested in received confreq */
/* process the options in the confack */
data += 4;
dlen -= 4;
/* data[0] is code, data[1] is length */
while (dlen >= 2 && dlen >= data[1] && data[1] >= 2) {
switch (data[0]) {
case LCP_MRU:
val = get_unaligned_be16(data + 2);
if (inbound)
ap->mru = val;
else
ap->chan.mtu = val;
break;
case LCP_ASYNCMAP:
val = get_unaligned_be32(data + 2);
if (inbound)
ap->raccm = val;
else
ap->xaccm[0] = val;
break;
}
dlen -= data[1];
data += data[1];
}
} | false | false | false | false | false | 0 |
postAttack( bool reactionFire )
{
if ( !reactionFire )
attacked = true;
if ( typ->hasFunction( ContainerBaseType::MoveAfterAttack ) )
decreaseMovement ( maxMovement() * attackmovecost / 100 );
else
if ( reactionfire.getStatus() == ReactionFire::off )
setMovement ( 0 );
} | false | false | false | false | false | 0 |
__ibv_close_device(struct ibv_context *context)
{
int async_fd = context->async_fd;
int cmd_fd = context->cmd_fd;
int cq_fd = -1;
if (abi_ver <= 2) {
struct ibv_abi_compat_v2 *t = context->abi_compat;
cq_fd = t->channel.fd;
free(context->abi_compat);
}
context->device->ops.free_context(context);
close(async_fd);
close(cmd_fd);
if (abi_ver <= 2)
close(cq_fd);
return 0;
} | false | false | false | false | false | 0 |
_fmpz_poly_mul_trunc_n(fmpz_poly_t output, const fmpz_poly_t input1,
const fmpz_poly_t input2, const unsigned long trunc)
{
if ((input1->length == 0) || (input2->length == 0))
{
_fmpz_poly_zero(output);
return;
}
if ((input1->length <= 3) && (input2->length <= 3))
{
_fmpz_poly_mul_karatsuba_trunc(output, input1, input2, trunc);
return;
}
unsigned long bits1 = _fmpz_poly_max_bits(input1);
unsigned long bits2 = (input1 == input2) ? bits1 : _fmpz_poly_max_bits(input2);
bits1 = ABS(bits1);
bits2 = ABS(bits2);
if ((bits1 + bits2 >= 64) && (input1->length + input2->length <= 10))
{
_fmpz_poly_mul_karatsuba_trunc(output, input1, input2, trunc);
return;
}
if ((bits1 + bits2 >= 370) && (input1->length + input2->length <= 32))
{
_fmpz_poly_mul_karatsuba_trunc(output, input1, input2, trunc);
return;
}
if (bits1 + bits2 < 512)
{
_fmpz_poly_mul_KS_trunc(output, input1, input2, trunc);
return;
}
if (3*(bits1 + bits2) >= input1->length + input2->length)
{
_fmpz_poly_mul_SS_trunc(output, input1, input2, trunc);
return;
}
_fmpz_poly_mul_KS_trunc(output, input1, input2, trunc);
} | false | false | false | false | false | 0 |
introspect(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
struct generic_data *data = user_data;
DBusMessage *reply;
if (data->introspect == NULL)
generate_introspection_xml(connection, data,
dbus_message_get_path(message));
reply = dbus_message_new_method_return(message);
if (reply == NULL)
return NULL;
dbus_message_append_args(reply, DBUS_TYPE_STRING, &data->introspect,
DBUS_TYPE_INVALID);
return reply;
} | false | false | false | false | false | 0 |
GetNextFeature()
{
while( iNextReadFID < nMaxFeatureCount )
{
OGRFeature *poFeature = papoFeatures[iNextReadFID++];
if( poFeature == NULL )
continue;
if( (m_poFilterGeom == NULL
|| FilterGeometry( poFeature->GetGeometryRef() ) )
&& (m_poAttrQuery == NULL
|| m_poAttrQuery->Evaluate( poFeature ) ) )
{
m_nFeaturesRead++;
return poFeature->Clone();
}
}
return NULL;
} | false | false | false | false | false | 0 |
ib_cache_event(struct ib_event_handler *handler,
struct ib_event *event)
{
struct ib_update_work *work;
if (event->event == IB_EVENT_PORT_ERR ||
event->event == IB_EVENT_PORT_ACTIVE ||
event->event == IB_EVENT_LID_CHANGE ||
event->event == IB_EVENT_PKEY_CHANGE ||
event->event == IB_EVENT_SM_CHANGE ||
event->event == IB_EVENT_CLIENT_REREGISTER ||
event->event == IB_EVENT_GID_CHANGE) {
work = kmalloc(sizeof *work, GFP_ATOMIC);
if (work) {
INIT_WORK(&work->work, ib_cache_task);
work->device = event->device;
work->port_num = event->element.port_num;
queue_work(ib_wq, &work->work);
}
}
} | false | false | false | false | false | 0 |
edge_connection_new(int type, int socket_family)
{
edge_connection_t *edge_conn = tor_malloc_zero(sizeof(edge_connection_t));
tor_assert(type == CONN_TYPE_EXIT);
connection_init(time(NULL), TO_CONN(edge_conn), type, socket_family);
return edge_conn;
} | false | false | false | false | false | 0 |
CL_AddPainPic2(void)
{
double time_difference;
// get current time and stats
paininfo.ct = time(NULL);
paininfo.ch = cl.frame.playerstate.stats[STAT_HEALTH];
paininfo.ca = cl.frame.playerstate.stats[STAT_ARMOR];
// initialize the paininfo struct
if (!paininfo_init)
{
paininfo.lh = paininfo.ch;
paininfo.la = paininfo.ca;
paininfo.lt = paininfo.ct;
paininfo_init = 1;
}
time_difference = difftime(paininfo.ct, paininfo.lt);
// Did we lose health?
if (
(
// Health <= 100 and lost health, OR
(paininfo.lh <= 100 && paininfo.lh > paininfo.ch) ||
// Health > 100, lost health, and health lost is > 1 (to counteract megahealth from registering)
(paininfo.lh > 100 && paininfo.lh > paininfo.ch && (paininfo.lh - paininfo.ch) > 1)
)
// and hlost flag not yet toggled
&& !paininfo.hlost
) {
paininfo.hlost = 1;
}
// Did we lose armor?
if (
// Armor is less than before
paininfo.la > paininfo.ca
// Must have lost some health (hack, to counteract armor/shield 'toggle value')
&& paininfo.hlost
// and alost flag not yet toggled
&& !paininfo.alost
) {
paininfo.alost = 1;
}
if (time_difference >= 1)
{
paininfo.hlost = 0;
paininfo.alost = 0;
paininfo.lh = paininfo.ch;
paininfo.la = paininfo.ca;
paininfo.lt = paininfo.ct;
}
if (paininfo.hlost)
Draw_StretchPic (0, 0, scr_vrect.width, scr_vrect.height, "pain_health", 1);
if (paininfo.alost)
Draw_StretchPic (0, 0, scr_vrect.width, scr_vrect.height, "pain_armor", 1);
} | false | false | false | false | false | 0 |
zend_stack_destroy(zend_stack *stack)
{
int i;
if (stack->elements) {
for (i = 0; i < stack->top; i++) {
efree(stack->elements[i]);
}
efree(stack->elements);
stack->elements = NULL;
}
return SUCCESS;
} | false | false | false | false | false | 0 |
overlapBounds(const float* amin, const float* amax, const float* bmin, const float* bmax)
{
bool overlap = true;
overlap = (amin[0] > bmax[0] || amax[0] < bmin[0]) ? false : overlap;
overlap = (amin[1] > bmax[1] || amax[1] < bmin[1]) ? false : overlap;
overlap = (amin[2] > bmax[2] || amax[2] < bmin[2]) ? false : overlap;
return overlap;
} | false | false | false | false | false | 0 |
torus_display_period_init()
{ int i;
if ( web.torus_display_period ) return;
web.torus_display_period = dmatrix(0,SDIM-1,0,SDIM-1);
web.inverse_display_periods = dmatrix(0,SDIM-1,0,SDIM-1);
for ( i = 0 ; i < SDIM ; i++ )
web.torus_display_period[i][i] = web.inverse_display_periods[i][i] = 1.0;
} | false | false | false | false | false | 0 |
survey_timer_hdl(unsigned long data)
{
struct adapter *padapter = (struct adapter *)data;
struct cmd_obj *ph2c;
struct sitesurvey_parm *psurveyPara;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
/* issue rtw_sitesurvey_cmd */
if (pmlmeext->sitesurvey_res.state > SCAN_START) {
if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS)
pmlmeext->sitesurvey_res.channel_idx++;
if (pmlmeext->scan_abort) {
pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num;
DBG_88E("%s idx:%d\n", __func__
, pmlmeext->sitesurvey_res.channel_idx);
pmlmeext->scan_abort = false;/* reset */
}
ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
if (ph2c == NULL)
goto exit_survey_timer_hdl;
psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC);
if (psurveyPara == NULL) {
kfree(ph2c);
goto exit_survey_timer_hdl;
}
init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey));
rtw_enqueue_cmd(pcmdpriv, ph2c);
}
exit_survey_timer_hdl:
return;
} | false | false | false | false | false | 0 |
getCompleteString() const
{
char buf[100];
char *p = &buf[0];
if (qualifier != EvqTemporary && qualifier != EvqGlobal)
p += sprintf(p, "%s ", getQualifierString());
sprintf(p, "%s", getBasicString());
if (array)
p += sprintf(p, " array");
if (matrix)
p += sprintf(p, "matrix%dX%d", matcols, matrows);
else if (matrows > 1)
p += sprintf(p, "vec%d", matrows);
return TString(buf);
} | false | false | false | false | false | 0 |
ath9k_htc_init_btcoex(struct ath9k_htc_priv *priv, char *product)
{
struct ath_hw *ah = priv->ah;
struct ath_common *common = ath9k_hw_common(ah);
int qnum;
/*
* Check if BTCOEX is globally disabled.
*/
if (!common->btcoex_enabled) {
ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_NONE;
return;
}
if (product && strncmp(product, ATH_HTC_BTCOEX_PRODUCT_ID, 5) == 0) {
ah->btcoex_hw.scheme = ATH_BTCOEX_CFG_3WIRE;
}
switch (ath9k_hw_get_btcoex_scheme(priv->ah)) {
case ATH_BTCOEX_CFG_NONE:
break;
case ATH_BTCOEX_CFG_3WIRE:
priv->ah->btcoex_hw.btactive_gpio = 7;
priv->ah->btcoex_hw.btpriority_gpio = 6;
priv->ah->btcoex_hw.wlanactive_gpio = 8;
priv->btcoex.bt_stomp_type = ATH_BTCOEX_STOMP_LOW;
ath9k_hw_btcoex_init_3wire(priv->ah);
ath_htc_init_btcoex_work(priv);
qnum = priv->hwq_map[IEEE80211_AC_BE];
ath9k_hw_init_btcoex_hw(priv->ah, qnum);
break;
default:
WARN_ON(1);
break;
}
} | false | false | false | false | false | 0 |
ui_main() {
if( data.init_done )
return;
data.init_done = 1;
# if defined(NEKO_WINDOWS)
{
WNDCLASSEX wcl;
HINSTANCE hinst = GetModuleHandle(NULL);
memset(&wcl,0,sizeof(wcl));
wcl.cbSize = sizeof(WNDCLASSEX);
wcl.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wcl.lpfnWndProc = WindowProc;
wcl.cbClsExtra = 0;
wcl.cbWndExtra = 0;
wcl.hInstance = hinst;
wcl.hIcon = NULL;
wcl.hCursor = LoadCursor(NULL, IDC_ARROW);
wcl.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
wcl.lpszMenuName = "";
wcl.lpszClassName = CLASS_NAME;
wcl.hIconSm = 0;
RegisterClassEx(&wcl);
}
data.tid = GetCurrentThreadId();
data.wnd = CreateWindow(CLASS_NAME,"",0,0,0,0,0,NULL,NULL,NULL,NULL);
# elif defined(NEKO_MAC)
MPCreateTask(nothing,NULL,0,0,0,0,0,NULL); // creates a MPTask that will enable Carbon MT
data.tid = pthread_self();
EventTypeSpec ets = { UIEvent, eCall };
InstallEventHandler(GetApplicationEventTarget(),NewEventHandlerUPP(handleEvents),1,&ets,0,0);
# elif defined(NEKO_POSIX)
g_thread_init(NULL);
gdk_threads_init();
gtk_init(NULL,NULL);
setlocale(LC_NUMERIC,"POSIX"); // prevent broking atof()
data.tid = pthread_self();
pthread_mutex_init(&data.lock,NULL);
# endif
} | false | false | false | false | false | 0 |
rmaps_lama_get_mppr_for_key(orte_node_t *node, rmaps_lama_level_type_t lama_key)
{
int i;
for( i = 0; i < lama_mppr_num_levels; ++i ) {
if( lama_key == lama_mppr_levels[i].type ) {
return lama_mppr_levels[i].max_resources;
}
}
return -1;
} | false | false | false | false | false | 0 |
search_gui_magnet_add_source(struct magnet_resource *magnet, record_t *record)
{
struct results_set *rs;
g_return_if_fail(magnet);
g_return_if_fail(record);
record_check(record);
rs = record->results_set;
if (!(ST_FIREWALL & rs->status)) {
magnet_add_sha1_source(magnet, record->sha1, rs->addr, rs->port,
NULL, NULL);
} else {
magnet_add_sha1_source(magnet, record->sha1,
ipv4_unspecified, 0, rs->guid, rs->proxies);
}
if (record->alt_locs) {
gint i, n;
n = gnet_host_vec_count(record->alt_locs);
n = MIN(10, n);
for (i = 0; i < n; i++) {
gnet_host_t host;
host = gnet_host_vec_get(record->alt_locs, i);
magnet_add_sha1_source(magnet, record->sha1,
gnet_host_get_addr(&host), gnet_host_get_port(&host),
NULL, NULL);
}
}
} | false | false | false | false | false | 0 |
print_nofopt(struct filter_util *qu, FILE *f, struct rtattr *opt, __u32 fhandle)
{
if (opt && RTA_PAYLOAD(opt))
fprintf(f, "fh %08x [Unknown filter, optlen=%u] ",
fhandle, (unsigned) RTA_PAYLOAD(opt));
else if (fhandle)
fprintf(f, "fh %08x ", fhandle);
return 0;
} | false | false | false | false | false | 0 |
gretl_regexp_replace (const char *orig,
const char *match,
const char *repl,
int *err)
{
GRegex *regex;
GError *error = NULL;
char *mod = NULL;
regex = g_regex_new(match, 0, 0, &error);
if (error == NULL) {
mod = g_regex_replace(regex, orig, -1, 0, repl, 0, &error);
}
if (error != NULL) {
*err = 1;
gretl_errmsg_set(error->message);
g_error_free(error);
}
if (regex != NULL) {
g_regex_unref(regex);
}
return mod;
} | false | false | false | false | false | 0 |
ir_add_symbol_internal(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line)
{
TIntermSymbol* node = new TIntermSymbol(id, name, info, type);
node->setLine(line);
return node;
} | false | false | false | false | false | 0 |
GetBounds()
{
this->UpdatePaths();
double bounds[6];
bool nobounds = true;
bounds[0] = VTK_DOUBLE_MAX;
bounds[1] = VTK_DOUBLE_MIN;
bounds[2] = VTK_DOUBLE_MAX;
bounds[3] = VTK_DOUBLE_MIN;
bounds[4] = VTK_DOUBLE_MAX;
bounds[5] = VTK_DOUBLE_MIN;
if (!this->IsIdentity)
{
this->PokeMatrices(this->GetMatrix());
}
vtkCollectionSimpleIterator pit;
this->Images->InitTraversal(pit);
vtkImageSlice *image = 0;
while ( (image = this->Images->GetNextImage(pit)) != 0)
{
double *b = image->GetBounds();
if (b)
{
nobounds = false;
bounds[0] = (bounds[0] < b[0] ? bounds[0] : b[0]);
bounds[1] = (bounds[1] > b[1] ? bounds[1] : b[1]);
bounds[2] = (bounds[2] < b[2] ? bounds[2] : b[2]);
bounds[3] = (bounds[3] > b[3] ? bounds[3] : b[3]);
bounds[4] = (bounds[4] < b[4] ? bounds[4] : b[4]);
bounds[5] = (bounds[5] > b[5] ? bounds[5] : b[5]);
}
}
if (!this->IsIdentity)
{
this->PokeMatrices(NULL);
}
if (nobounds)
{
return 0;
}
this->Bounds[0] = bounds[0];
this->Bounds[1] = bounds[1];
this->Bounds[2] = bounds[2];
this->Bounds[3] = bounds[3];
this->Bounds[4] = bounds[4];
this->Bounds[5] = bounds[5];
return this->Bounds;
} | false | false | false | false | false | 0 |
newempty (void)
{
NODE *n = new_node(EMPTY);
if (n != NULL) {
n->v.idnum = 0;
}
return n;
} | false | false | false | false | false | 0 |
vector_transform (pv q, const pv x, const Matrix M)
{
int i, j;
memset (q, 0, sizeof (*q) * MATRIX_DIM);
/* for each column */
for (j = 0; j < MATRIX_DIM; ++j)
{
/* for each row */
for (i = 0; i < MATRIX_DIM; ++i)
q[i] += M[i + MATRIX_DIM * j] * x[j];
}
} | false | false | false | false | false | 0 |
Start(bool bRun, const Player* pPlayer, const Quest* pQuest, bool bInstantRespawn, bool bCanLoopPath)
{
if (m_creature->getVictim())
{
script_error_log("EscortAI attempt to Start while in combat.");
return;
}
if (HasEscortState(STATE_ESCORT_ESCORTING))
{
script_error_log("EscortAI attempt to Start while already escorting.");
return;
}
if (!WaypointList.empty())
{
WaypointList.clear();
}
FillPointMovementListForCreature();
if (WaypointList.empty())
{
error_db_log("SD2: EscortAI Start with 0 waypoints (possible missing entry in script_waypoint).");
return;
}
// set variables
m_bIsRunning = bRun;
m_playerGuid = pPlayer ? pPlayer->GetObjectGuid() : ObjectGuid();
m_pQuestForEscort = pQuest;
m_bCanInstantRespawn = bInstantRespawn;
m_bCanReturnToStart = bCanLoopPath;
if (m_bCanReturnToStart && m_bCanInstantRespawn)
{
debug_log("SD2: EscortAI is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");
}
if (m_creature->GetMotionMaster()->GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
m_creature->GetMotionMaster()->MovementExpired();
m_creature->GetMotionMaster()->MoveIdle();
debug_log("SD2: EscortAI start with WAYPOINT_MOTION_TYPE, changed to MoveIdle.");
}
// disable npcflags
m_creature->SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
debug_log("SD2: EscortAI started with " SIZEFMTD " waypoints. Run = %d, PlayerGuid = %s", WaypointList.size(), m_bIsRunning, m_playerGuid.GetString().c_str());
CurrentWP = WaypointList.begin();
// Set initial speed
m_creature->SetWalk(!m_bIsRunning);
AddEscortState(STATE_ESCORT_ESCORTING);
JustStartedEscort();
} | false | false | false | false | false | 0 |
handle_get_seat_id (GdmDBusDisplay *skeleton,
GDBusMethodInvocation *invocation,
GdmDisplay *display)
{
char *seat_id;
seat_id = NULL;
gdm_display_get_seat_id (display, &seat_id, NULL);
if (seat_id == NULL) {
seat_id = g_strdup ("");
}
gdm_dbus_display_complete_get_seat_id (skeleton, invocation, seat_id);
g_free (seat_id);
return TRUE;
} | false | false | false | false | false | 0 |
std_hash_table_steal(struct std_hashtable *hash_table, const void *key)
{
struct ghashnode **node, *dest;
if (!hash_table)
return 0;
node = std_hash_table_lookup_node(hash_table, key);
if (*node) {
dest = *node;
(*node) = dest->next;
std_hash_node_destroy(dest, NULL, NULL);
hash_table->nnodes--;
G_HASH_TABLE_RESIZE(hash_table);
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
sarrayPadToSameSize(SARRAY *sa1,
SARRAY *sa2,
char *padstring)
{
l_int32 i, n1, n2;
PROCNAME("sarrayPadToSameSize");
if (!sa1 || !sa2)
return ERROR_INT("both sa1 and sa2 not defined", procName, 1);
n1 = sarrayGetCount(sa1);
n2 = sarrayGetCount(sa2);
if (n1 < n2) {
for (i = n1; i < n2; i++)
sarrayAddString(sa1, padstring, L_COPY);
} else if (n1 > n2) {
for (i = n2; i < n1; i++)
sarrayAddString(sa2, padstring, L_COPY);
}
return 0;
} | false | false | false | false | false | 0 |
heightfn(htmldata_t * p, char *v)
{
long u;
if (doInt(v, "HEIGHT", 0, MAX_USHORT, &u))
return 1;
p->height = (unsigned short) u;
return 0;
} | false | false | false | false | false | 0 |
remove_white_space(struct lib_context *lc, char *str, size_t size)
{
int c;
char *in = str, *out = str;
in[size] = 0;
while ((c = *in++)) {
if (!isspace(c))
*out++ = c;
}
*out = 0;
return str;
} | false | false | false | false | false | 0 |
getWeakLearnerName(const string& shypFileName)
{
// open file
ifstream inFile(shypFileName.c_str());
if (!inFile.is_open())
{
cerr << "ERROR: Cannot open strong hypothesis file <" << shypFileName << ">!" << endl;
exit(1);
}
// Declares the stream tokenizer
nor_utils::StreamTokenizer st(inFile, "<>\n\r\t");
// Declares the possible starting tag names for stronglearners
vector<string> tags;
tags.push_back( "multiboost" );
tags.push_back( "cascade" );
// Move until it finds the multiboost tag
//if ( !seekSimpleTag(st, "multiboost") )
if ( !seekSimpleTag(st, tags) )
{
// no multiboost tag found: this is not the correct file!
cerr << "ERROR: Not a valid MultiBoost Strong Hypothesis file!!" << endl;
exit(1);
}
// Move until it finds the algo tag
return seekAndParseEnclosedValue<string>(st, "algo");
} | false | false | false | false | false | 0 |
bond_netpoll_cleanup(struct net_device *bond_dev)
{
struct bonding *bond = netdev_priv(bond_dev);
struct list_head *iter;
struct slave *slave;
bond_for_each_slave(bond, slave, iter)
if (bond_slave_is_up(slave))
slave_disable_netpoll(slave);
} | false | false | false | false | false | 0 |
doinit() {
for(int ix=1;ix<7;++ix) {
addToList(-ix,ix,21,39);
}
FFVTVertex::doinit();
tcHwADDPtr hwADD=dynamic_ptr_cast<tcHwADDPtr>(generator()->standardModel());
if(!hwADD) throw Exception()
<< "Must have ADDModel in ADDModelFFGGRVertex::doinit()"
<< Exception::runerror;
kappa_ = 2./hwADD->MPlanckBar();
r_ = sqr(hwADD->LambdaT())/hwADD->MPlanckBar();
} | false | false | false | false | false | 0 |
iuport_lock (qport, pinfo)
struct uuconf_port *qport;
pointer pinfo;
{
struct spass *q = (struct spass *) pinfo;
q->fmatched = TRUE;
if (! fconn_init (qport, q->qconn, UUCONF_PORTTYPE_UNKNOWN))
return UUCONF_NOT_FOUND;
else if (! fconn_lock (q->qconn, FALSE, FALSE))
{
uconn_free (q->qconn);
return UUCONF_NOT_FOUND;
}
else
{
q->flocked = TRUE;
return UUCONF_SUCCESS;
}
} | false | false | false | false | false | 0 |
autostr_vprintf(struct auto_string *str, unsigned long offset,
const char *fmt, va_list args)
{
unsigned long size;
va_list tmp_args;
int nr, err = 0;
retry:
size = autostr_remaining(str, offset);
va_copy(tmp_args, args);
nr = vsnprintf(str->value + offset, size, fmt, tmp_args);
va_end(tmp_args);
if (nr < 0) {
ErrorMessage(__FUNCTION__, "An error occurred when calling vsnprintf: %s\n", PLEASE_INFORM, IS_WARNING_ONLY, strerror(errno));
return -1;
}
if ((unsigned long)nr >= size) {
err = autostr_resize(str, str->capacity * 2);
if (err)
goto out;
goto retry;
}
str->length = offset + nr;
out:
return err;
} | false | false | false | false | true | 1 |
mbc1_write_6000_7fff(Uint16 adr,Uint8 v) {
if (!v) mbc1_mem_mode=MBC1_16_8_MEM_MODE;
else if (v==1) mbc1_mem_mode=MBC1_4_32_MEM_MODE;
} | false | false | false | false | false | 0 |
disc2_precalc(flam3_xform *xf) {
double add = xf->disc2_twist;
double k;
xf->disc2_timespi = xf->disc2_rot * M_PI;
sincos(add,&xf->disc2_sinadd,&xf->disc2_cosadd);
xf->disc2_cosadd -= 1;
if (add > 2 * M_PI) {
k = (1 + add - 2*M_PI);
xf->disc2_cosadd *= k;
xf->disc2_sinadd *= k;
}
if (add < -2 * M_PI) {
k = (1 + add + 2*M_PI);
xf->disc2_cosadd *= k;
xf->disc2_sinadd *= k;
}
} | false | false | false | false | false | 0 |
destroy_cm_id(struct iw_cm_id *cm_id)
{
struct iwcm_id_private *cm_id_priv;
unsigned long flags;
cm_id_priv = container_of(cm_id, struct iwcm_id_private, id);
/*
* Wait if we're currently in a connect or accept downcall. A
* listening endpoint should never block here.
*/
wait_event(cm_id_priv->connect_wait,
!test_bit(IWCM_F_CONNECT_WAIT, &cm_id_priv->flags));
spin_lock_irqsave(&cm_id_priv->lock, flags);
switch (cm_id_priv->state) {
case IW_CM_STATE_LISTEN:
cm_id_priv->state = IW_CM_STATE_DESTROYING;
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
/* destroy the listening endpoint */
cm_id->device->iwcm->destroy_listen(cm_id);
spin_lock_irqsave(&cm_id_priv->lock, flags);
break;
case IW_CM_STATE_ESTABLISHED:
cm_id_priv->state = IW_CM_STATE_DESTROYING;
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
/* Abrupt close of the connection */
(void)iwcm_modify_qp_err(cm_id_priv->qp);
spin_lock_irqsave(&cm_id_priv->lock, flags);
break;
case IW_CM_STATE_IDLE:
case IW_CM_STATE_CLOSING:
cm_id_priv->state = IW_CM_STATE_DESTROYING;
break;
case IW_CM_STATE_CONN_RECV:
/*
* App called destroy before/without calling accept after
* receiving connection request event notification or
* returned non zero from the event callback function.
* In either case, must tell the provider to reject.
*/
cm_id_priv->state = IW_CM_STATE_DESTROYING;
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
cm_id->device->iwcm->reject(cm_id, NULL, 0);
spin_lock_irqsave(&cm_id_priv->lock, flags);
break;
case IW_CM_STATE_CONN_SENT:
case IW_CM_STATE_DESTROYING:
default:
BUG();
break;
}
if (cm_id_priv->qp) {
cm_id_priv->id.device->iwcm->rem_ref(cm_id_priv->qp);
cm_id_priv->qp = NULL;
}
spin_unlock_irqrestore(&cm_id_priv->lock, flags);
(void)iwcm_deref_id(cm_id_priv);
} | false | false | false | false | false | 0 |
unix_accept(ipc_t* ipc)
{
int fd;
struct sockaddr_un sock_addr;
memset(&sock_addr, 0, sizeof(sock_addr));
// ENOENT means file does not exist
if (unlink(ipc->path) < 0 && errno != ENOENT)
{
local_log_errno(LOG_ERR, "Unlink path failed!");
return -1;
}
if ((ipc->fd = socket(PF_LOCAL, SOCK_STREAM, 0)) == -1)
{
local_log_errno(LOG_ERR, "Creation of unix socket failed!");
return -1;
}
sock_addr.sun_family = PF_LOCAL;
strcpy(sock_addr.sun_path, ipc->path);
if (bind(ipc->fd, (struct sockaddr*) &sock_addr, sizeof(sock_addr)) == -1)
{
local_log_errno(LOG_ERR, "Binding to unix socket failed!");
return -1;
}
if (listen(ipc->fd, 1) == -1)
{
local_log_errno(LOG_ERR, "Listening on unix socket failed!");
return -1;
}
if ((fd = accept(ipc->fd, 0, 0)) == -1)
{
local_log_errno(LOG_ERR, "Accepting new connection on unix socket failed!");
return -1;
}
// close accept fd
close(ipc->fd);
// set ptr->fd from accept fd to actual filedescriptor
ipc->fd = fd;
return fd;
} | false | true | false | false | false | 1 |
SaveString ( Obj string )
{
UInt i, len = GET_LEN_STRING(string);
UInt1 *p = (UInt1*)CHARS_STRING(string);
SaveUInt(len);
for (i=0; i<len; i++)
SAVE_BYTE(p[i]);
} | false | false | false | false | false | 0 |
poll_unregister(pollObject *self, PyObject *o)
{
PyObject *key;
int fd;
fd = PyObject_AsFileDescriptor( o );
if (fd == -1)
return NULL;
/* Check whether the fd is already in the array */
key = PyInt_FromLong(fd);
if (key == NULL)
return NULL;
if (PyDict_DelItem(self->dict, key) == -1) {
Py_DECREF(key);
/* This will simply raise the KeyError set by PyDict_DelItem
if the file descriptor isn't registered. */
return NULL;
}
Py_DECREF(key);
self->ufd_uptodate = 0;
Py_INCREF(Py_None);
return Py_None;
} | false | false | false | false | false | 0 |
SECMOD_FindSlotByID(SECMODModule *module, CK_SLOT_ID slotID)
{
int i;
PK11SlotInfo *slot = NULL;
if (!moduleLock) {
PORT_SetError(SEC_ERROR_NOT_INITIALIZED);
return slot;
}
SECMOD_GetReadLock(moduleLock);
for (i=0; i < module->slotCount; i++) {
PK11SlotInfo *cSlot = module->slots[i];
if (cSlot->slotID == slotID) {
slot = PK11_ReferenceSlot(cSlot);
break;
}
}
SECMOD_ReleaseReadLock(moduleLock);
if (slot == NULL) {
PORT_SetError(SEC_ERROR_NO_SLOT_SELECTED);
}
return slot;
} | false | false | false | false | false | 0 |
fat_get_cluster(struct inode *inode, int cluster, int *fclus, int *dclus)
{
struct super_block *sb = inode->i_sb;
const int limit = sb->s_maxbytes >> MSDOS_SB(sb)->cluster_bits;
struct fat_entry fatent;
struct fat_cache_id cid;
int nr;
BUG_ON(MSDOS_I(inode)->i_start == 0);
*fclus = 0;
*dclus = MSDOS_I(inode)->i_start;
if (cluster == 0)
return 0;
if (fat_cache_lookup(inode, cluster, &cid, fclus, dclus) < 0) {
/*
* dummy, always not contiguous
* This is reinitialized by cache_init(), later.
*/
cache_init(&cid, -1, -1);
}
fatent_init(&fatent);
while (*fclus < cluster) {
/* prevent the infinite loop of cluster chain */
if (*fclus > limit) {
fat_fs_error_ratelimit(sb,
"%s: detected the cluster chain loop"
" (i_pos %lld)", __func__,
MSDOS_I(inode)->i_pos);
nr = -EIO;
goto out;
}
nr = fat_ent_read(inode, &fatent, *dclus);
if (nr < 0)
goto out;
else if (nr == FAT_ENT_FREE) {
fat_fs_error_ratelimit(sb,
"%s: invalid cluster chain (i_pos %lld)",
__func__,
MSDOS_I(inode)->i_pos);
nr = -EIO;
goto out;
} else if (nr == FAT_ENT_EOF) {
fat_cache_add(inode, &cid);
goto out;
}
(*fclus)++;
*dclus = nr;
if (!cache_contiguous(&cid, *dclus))
cache_init(&cid, *fclus, *dclus);
}
nr = 0;
fat_cache_add(inode, &cid);
out:
fatent_brelse(&fatent);
return nr;
} | false | false | false | false | false | 0 |
MountHomeBinServers()
{ struct Mountables *mp;
char host[CF_MAXVARSIZE];
char mountdir[CF_BUFSIZE];
char maketo[CF_BUFSIZE];
struct Item *ip;
/*
* HvB: Bas van der Vlies
*/
char mountmode[CF_BUFSIZE];
if (! GOTMOUNTINFO)
{
CfLog(cfinform,"Incomplete mount info due to RPC failure.\n","");
snprintf(OUTPUT,CF_BUFSIZE*2,"%s will not be modified on this pass!\n\n",VFSTAB[VSYSTEMHARDCLASS]);
CfLog(cfinform,OUTPUT,"");
return;
}
if (!IsPrivileged())
{
CfLog(cferror,"Only root can mount filesystems.\n","");
return;
}
Banner("Checking home and binservers");
Debug("BINSERVER = %s\n",VDEFAULTBINSERVER.name);
for (mp = VMOUNTABLES; mp != NULL; mp=mp->next)
{
sscanf(mp->filesystem,"%[^:]:%s",host,mountdir);
if (mp->done == 'y' || strcmp(mp->scope,CONTEXTID))
{
continue;
}
else
{
mp->done = 'y';
}
Debug("Mount: checking %s\n",mp->filesystem);
strcpy(maketo,mountdir);
if (maketo[strlen(maketo)-1] == '/')
{
strcat(maketo,".");
}
else
{
strcat(maketo,"/.");
}
Debug("I am [%s], you are [%s]\n",host,VDEFAULTBINSERVER.name);
if (strcmp(host,VDEFAULTBINSERVER.name) == 0) /* A host never mounts itself nfs */
{
Debug("Skipping host %s\n",host);
continue;
}
/* HvB: Bas van der Vlies */
if (mp->readonly)
{
strcpy(mountmode, "ro");
}
else
{
strcpy(mountmode, "rw");
}
if (IsHomeDir(mountdir))
{
if (!IsItemIn(VMOUNTED,mp->filesystem) && IsClassedItemIn(VHOMESERVERS,host))
{
MakeDirectoriesFor(maketo,'n');
AddToFstab(host,mountdir,mountdir,mountmode,mp->mountopts,false);
}
else if (IsClassedItemIn(VHOMESERVERS,host))
{
AddToFstab(host,mountdir,mountdir,mountmode,mp->mountopts,true);
}
}
else
{
if (!IsItemIn(VMOUNTED,mp->filesystem) && IsClassedItemIn(VBINSERVERS,host))
{
MakeDirectoriesFor(maketo,'n');
AddToFstab(host,mountdir,mountdir,mountmode,mp->mountopts,false);
AuditLog('y',mp->audit,mp->lineno,"Adding mountpoint, editing filesystem table",CF_CHG);
}
else if (IsClassedItemIn(VBINSERVERS,host))
{
AddToFstab(host,mountdir,mountdir,mountmode,mp->mountopts,true);
AuditLog('y',mp->audit,mp->lineno,"Editing filesystem table",CF_CHG);
}
}
}
} | false | false | false | false | false | 0 |
GetPersonalitiesList()
{
wxArrayString list;
wxDir::GetAllFiles(ConfigManager::GetFolder(sdConfig), &list, _T("*.conf"), wxDIR_FILES);
for(size_t i = 0; i < list.GetCount(); ++i)
list[i] = wxFileName(list[i]).GetName();
return list;
} | false | false | false | false | false | 0 |
write_vm(vm the_vm)
{
unsigned i;
dbio_write_var(the_vm->local);
dbio_printf("%u %d %u %u\n",
the_vm->top_activ_stack, the_vm->root_activ_vector,
the_vm->func_id, the_vm->max_stack_size);
for (i = 0; i <= the_vm->top_activ_stack; i++)
write_activ(the_vm->activ_stack[i]);
} | false | false | false | false | false | 0 |
apply_policy_on_bearers(GSList *policy_bearers, GSList *bearers,
GSList **list)
{
enum connman_service_type bearer;
GSList *it;
int err;
*list = NULL;
for (it = bearers; it != NULL; it = it->next) {
bearer = GPOINTER_TO_INT(it->data);
err = filter_bearer(policy_bearers, bearer, list);
if (err < 0)
return err;
}
return 0;
} | false | false | false | false | false | 0 |
check_twosfx(const char * word, int len,
char in_compound, const FLAG needflag)
{
int tmpl; // length of tmpword
struct hentry * he; // hash entry of root word or NULL
char tmpword[MAXWORDUTF8LEN + 4];
// on entry prefix is 0 length or already matches the beginning of the word.
// So if the remaining root word has positive length
// and if there are enough chars in root word and added back strip chars
// to meet the number of characters conditions, then test it
tmpl = len - appndl;
if ((tmpl > 0 || (tmpl == 0 && pmyMgr->get_fullstrip())) &&
(tmpl + stripl >= numconds)) {
// generate new root word by removing prefix and adding
// back any characters that would have been stripped
if (stripl) strcpy (tmpword, strip);
strcpy ((tmpword + stripl), (word + appndl));
// now make sure all of the conditions on characters
// are met. Please see the appendix at the end of
// this file for more info on exactly what is being
// tested
// if all conditions are met then check if resulting
// root word in the dictionary
if (test_condition(tmpword)) {
tmpl += stripl;
// prefix matched but no root word was found
// if aeXPRODUCT is allowed, try again but now
// cross checked combined with a suffix
if ((opts & aeXPRODUCT) && (in_compound != IN_CPD_BEGIN)) {
he = pmyMgr->suffix_check_twosfx(tmpword, tmpl, aeXPRODUCT, this, needflag);
if (he) return he;
}
}
}
return NULL;
} | false | false | false | false | false | 0 |
gsl_odeiv2_step_free (gsl_odeiv2_step * s)
{
RETURN_IF_NULL (s);
s->type->free (s->state);
free (s);
} | false | false | false | false | false | 0 |
pxe_mangle_name(char *dst, const char *src)
{
size_t len = FILENAME_MAX-1;
while (len-- && not_whitespace(*src))
*dst++ = *src++;
*dst = '\0';
} | false | false | false | false | false | 0 |
lock_torture_writer(void *arg)
{
struct lock_stress_stats *lwsp = arg;
static DEFINE_TORTURE_RANDOM(rand);
VERBOSE_TOROUT_STRING("lock_torture_writer task started");
set_user_nice(current, MAX_NICE);
do {
if ((torture_random(&rand) & 0xfffff) == 0)
schedule_timeout_uninterruptible(1);
cxt.cur_ops->task_boost(&rand);
cxt.cur_ops->writelock();
if (WARN_ON_ONCE(lock_is_write_held))
lwsp->n_lock_fail++;
lock_is_write_held = 1;
if (WARN_ON_ONCE(lock_is_read_held))
lwsp->n_lock_fail++; /* rare, but... */
lwsp->n_lock_acquired++;
cxt.cur_ops->write_delay(&rand);
lock_is_write_held = 0;
cxt.cur_ops->writeunlock();
stutter_wait("lock_torture_writer");
} while (!torture_must_stop());
cxt.cur_ops->task_boost(NULL); /* reset prio */
torture_kthread_stopping("lock_torture_writer");
return 0;
} | false | false | false | false | false | 0 |
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
FraqtiveMainWindow *_t = static_cast<FraqtiveMainWindow *>(_o);
switch (_id) {
case 0: _t->fractalType(); break;
case 1: _t->editGradient(); break;
case 2: _t->fullScreen(); break;
case 3: _t->navigateBack(); break;
case 4: _t->navigateForward(); break;
case 5: _t->defaultPosition(); break;
case 6: _t->loadPreset(); break;
case 7: _t->savePreset(); break;
case 8: _t->loadBookmark(); break;
case 9: _t->saveBookmark(); break;
case 10: _t->saveImage(); break;
case 11: _t->copyImage(); break;
case 12: _t->generateImage(); break;
case 13: _t->generateSeries(); break;
case 14: _t->view2d(); break;
case 15: _t->view3d(); break;
case 16: _t->customContextMenuRequested((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
case 17: _t->positionChanged(); break;
case 18: _t->navigationChanged(); break;
case 19: _t->applyGradient((*reinterpret_cast< const Gradient(*)>(_a[1]))); break;
default: ;
}
}
} | false | false | false | false | false | 0 |
apache2_brigade_limit_set(apreq_handle_t *handle,
apr_size_t bytes)
{
ap_filter_t *f = get_apreq_filter(handle);
struct filter_ctx *ctx;
if (f->ctx == NULL)
apreq_filter_make_context(f);
ctx = f->ctx;
if (ctx->body_status == APR_EINIT || ctx->brigade_limit > bytes) {
ctx->brigade_limit = bytes;
return APR_SUCCESS;
}
return APREQ_ERROR_MISMATCH;
} | false | false | false | false | false | 0 |
Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) {
String *func;
String *nname;
int i = 0;
int comma = 0;
Parm *p = parms;
SwigType *pt;
if (skip_self) {
if (p)
p = nextSibling(p);
i++;
}
nname = SwigType_namestr(name);
func = NewStringEmpty();
Printf(func, "new %s(", nname);
while (p) {
pt = Getattr(p, "type");
if ((SwigType_type(pt) != T_VOID)) {
String *rcaststr = 0;
String *pname = 0;
if (comma)
Append(func, ",");
if (!Getattr(p, "arg:byname")) {
pname = Swig_cparm_name(p, i);
i++;
} else {
pname = Getattr(p, "value");
if (pname)
pname = Copy(pname);
else
pname = Copy(Getattr(p, "name"));
}
rcaststr = SwigType_rcaststr(pt, pname);
Append(func, rcaststr);
Delete(rcaststr);
comma = 1;
Delete(pname);
}
p = nextSibling(p);
}
Append(func, ")");
Delete(nname);
return func;
} | false | false | false | false | false | 0 |
check_security_stage_status(iscsi_session_t *session,
struct iscsi_acl *auth_client)
{
int debug_status = 0;
switch (acl_recv_end(auth_client, session)) {
case AUTH_STATUS_CONTINUE:
/* continue sending PDUs */
break;
case AUTH_STATUS_PASS:
break;
case AUTH_STATUS_NO_ERROR: /* treat this as an error,
* since we should get a
* different code
*/
case AUTH_STATUS_ERROR:
case AUTH_STATUS_FAIL:
default:
if (acl_get_dbg_status(auth_client, &debug_status) !=
AUTH_STATUS_NO_ERROR)
log_error("Login authentication failed "
"with target %s, %s",
session->target_name,
acl_dbg_status_to_text(debug_status));
else
log_error("Login authentication failed "
"with target %s",
session->target_name);
return LOGIN_AUTHENTICATION_FAILED;
}
return LOGIN_OK;
} | false | false | false | false | false | 0 |
AcpiUtUpdateRefCount (
ACPI_OPERAND_OBJECT *Object,
UINT32 Action)
{
UINT16 OriginalCount;
UINT16 NewCount = 0;
ACPI_CPU_FLAGS LockFlags;
ACPI_FUNCTION_NAME (UtUpdateRefCount);
if (!Object)
{
return;
}
/*
* Always get the reference count lock. Note: Interpreter and/or
* Namespace is not always locked when this function is called.
*/
LockFlags = AcpiOsAcquireLock (AcpiGbl_ReferenceCountLock);
OriginalCount = Object->Common.ReferenceCount;
/* Perform the reference count action (increment, decrement) */
switch (Action)
{
case REF_INCREMENT:
NewCount = OriginalCount + 1;
Object->Common.ReferenceCount = NewCount;
AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
/* The current reference count should never be zero here */
if (!OriginalCount)
{
ACPI_WARNING ((AE_INFO,
"Obj %p, Reference Count was zero before increment\n",
Object));
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Type %.2X Refs %.2X [Incremented]\n",
Object, Object->Common.Type, NewCount));
break;
case REF_DECREMENT:
/* The current reference count must be non-zero */
if (OriginalCount)
{
NewCount = OriginalCount - 1;
Object->Common.ReferenceCount = NewCount;
}
AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
if (!OriginalCount)
{
ACPI_WARNING ((AE_INFO,
"Obj %p, Reference Count is already zero, cannot decrement\n",
Object));
}
ACPI_DEBUG_PRINT ((ACPI_DB_ALLOCATIONS,
"Obj %p Type %.2X Refs %.2X [Decremented]\n",
Object, Object->Common.Type, NewCount));
/* Actually delete the object on a reference count of zero */
if (NewCount == 0)
{
AcpiUtDeleteInternalObj (Object);
}
break;
default:
AcpiOsReleaseLock (AcpiGbl_ReferenceCountLock, LockFlags);
ACPI_ERROR ((AE_INFO, "Unknown Reference Count action (0x%X)",
Action));
return;
}
/*
* Sanity check the reference count, for debug purposes only.
* (A deleted object will have a huge reference count)
*/
if (NewCount > ACPI_MAX_REFERENCE_COUNT)
{
ACPI_WARNING ((AE_INFO,
"Large Reference Count (0x%X) in object %p, Type=0x%.2X",
NewCount, Object, Object->Common.Type));
}
} | false | false | false | false | false | 0 |
dav_generic_get_locks(dav_lockdb *lockdb,
const dav_resource *resource,
int calltype,
dav_lock **locks)
{
apr_pool_t *p = lockdb->info->pool;
apr_datum_t key;
dav_error *err;
dav_lock *lock = NULL;
dav_lock *newlock;
dav_lock_discovery *dp;
dav_lock_indirect *ip;
#if DAV_DEBUG
if (calltype == DAV_GETLOCKS_COMPLETE) {
return dav_new_error(lockdb->info->pool,
HTTP_INTERNAL_SERVER_ERROR, 0, 0,
"INTERNAL DESIGN ERROR: DAV_GETLOCKS_COMPLETE "
"is not yet supported");
}
#endif
key = dav_generic_build_key(p, resource);
if ((err = dav_generic_load_lock_record(lockdb, key, DAV_CREATE_LIST,
&dp, &ip)) != NULL) {
/* ### push a higher-level desc? */
return err;
}
/* copy all direct locks to the result list */
for (; dp != NULL; dp = dp->next) {
newlock = dav_generic_alloc_lock(lockdb, key, dp->locktoken);
newlock->is_locknull = !resource->exists;
newlock->scope = dp->f.scope;
newlock->type = dp->f.type;
newlock->depth = dp->f.depth;
newlock->timeout = dp->f.timeout;
newlock->owner = dp->owner;
newlock->auth_user = dp->auth_user;
/* hook into the result list */
newlock->next = lock;
lock = newlock;
}
/* copy all the indirect locks to the result list. resolve as needed. */
for (; ip != NULL; ip = ip->next) {
newlock = dav_generic_alloc_lock(lockdb, ip->key, ip->locktoken);
newlock->is_locknull = !resource->exists;
if (calltype == DAV_GETLOCKS_RESOLVED) {
err = dav_generic_resolve(lockdb, ip, &dp, NULL, NULL);
if (err != NULL) {
/* ### push a higher-level desc? */
return err;
}
newlock->scope = dp->f.scope;
newlock->type = dp->f.type;
newlock->depth = dp->f.depth;
newlock->timeout = dp->f.timeout;
newlock->owner = dp->owner;
newlock->auth_user = dp->auth_user;
}
else {
/* DAV_GETLOCKS_PARTIAL */
newlock->rectype = DAV_LOCKREC_INDIRECT_PARTIAL;
}
/* hook into the result list */
newlock->next = lock;
lock = newlock;
}
*locks = lock;
return NULL;
} | false | false | false | false | false | 0 |
raid_device_added (UDisksLinuxMDRaidObject *object,
UDisksLinuxDevice *device)
{
g_assert (object->sync_action_source == NULL);
g_assert (object->degraded_source == NULL);
/* udisks_debug ("start watching %s", g_udev_device_get_sysfs_path (device->udev_device)); */
object->sync_action_source = watch_attr (device,
"md/sync_action",
(GSourceFunc) attr_changed,
object);
object->degraded_source = watch_attr (device,
"md/degraded",
(GSourceFunc) attr_changed,
object);
} | false | false | false | false | false | 0 |
nvkm_xtensa_new_(const struct nvkm_xtensa_func *func,
struct nvkm_device *device, int index, bool enable,
u32 addr, struct nvkm_engine **pengine)
{
struct nvkm_xtensa *xtensa;
if (!(xtensa = kzalloc(sizeof(*xtensa), GFP_KERNEL)))
return -ENOMEM;
xtensa->func = func;
xtensa->addr = addr;
*pengine = &xtensa->engine;
return nvkm_engine_ctor(&nvkm_xtensa, device, index, func->pmc_enable,
enable, &xtensa->engine);
} | false | false | false | false | false | 0 |
gwy_brick_new_alike(GwyBrick *model,
gboolean nullme)
{
GwyBrick *brick;
GwyBrickPrivate *priv, *new_priv;
g_return_val_if_fail(GWY_IS_BRICK(model), NULL);
brick = g_object_new(GWY_TYPE_BRICK, NULL);
brick->xres = model->xres;
brick->yres = model->yres;
brick->zres = model->zres;
brick->xreal = model->xreal;
brick->yreal = model->yreal;
brick->zreal = model->zreal;
brick->xoff = model->xoff;
brick->yoff = model->yoff;
brick->zoff = model->zoff;
if (nullme)
brick->data = g_new0(gdouble, brick->xres * brick->yres * brick->zres);
else
brick->data = g_new(gdouble, brick->xres * brick->yres * brick->zres);
if (model->si_unit_x)
brick->si_unit_x = gwy_si_unit_duplicate(model->si_unit_x);
if (model->si_unit_y)
brick->si_unit_y = gwy_si_unit_duplicate(model->si_unit_y);
if (model->si_unit_z)
brick->si_unit_z = gwy_si_unit_duplicate(model->si_unit_z);
if (model->si_unit_w)
brick->si_unit_w = gwy_si_unit_duplicate(model->si_unit_w);
priv = model->priv;
new_priv = brick->priv;
if (priv->ZCalibration)
new_priv->ZCalibration
= gwy_data_line_duplicate(priv->ZCalibration);
return brick;
} | false | false | false | false | false | 0 |
finish (ACE_Filecache_Object *&file)
{
if (file == 0)
return file;
ACE_OFF_T loc = ACE::hash_pjw (file->filename_) % this->size_;
ACE_SYNCH_RW_MUTEX &hashlock = this->hash_lock_[loc];
if (file != 0)
switch (file->action_)
{
case ACE_Filecache_Object::ACE_WRITING:
{
ACE_WRITE_GUARD_RETURN (ACE_SYNCH_RW_MUTEX,
ace_mon,
hashlock,
0);
file->release ();
this->remove_i (file->filename_);
#if 0
int result = this->hash_.bind (file->filename (), file);
if (result == 0)
file->acquire ();
#else
// Last one using a stale file is resposible for deleting it.
if (file->stale_)
{
// Try a lock. If it succeds, we can delete it now.
// Otherwise, it will clean itself up later.
if (file->lock_.tryacquire_write () == 0)
{
delete file;
file = 0;
}
}
#endif
}
break;
default:
file->release ();
// Last one using a stale file is resposible for deleting it.
if (file->stale_)
{
// Try a lock. If it succeds, we can delete it now.
// Otherwise, it will clean itself up later.
if (file->lock_.tryacquire_write () == 0)
{
delete file;
file = 0;
}
}
break;
}
return file;
} | false | false | false | false | false | 0 |
jack_read_frame_time (const jack_client_t *client, jack_frame_timer_t *copy)
{
int tries = 0;
long timeout = 1000;
do {
/* throttle the busy wait if we don't get
the answer very quickly.
XXX This is disgusting. on a UP
system, it needs to sleep
if the first try didn't work. on an SMP
system, it should wait for half of
the context switch time before
sleeping.
*/
if (tries > 10) {
usleep (20);
tries = 0;
/* debug code to avoid system hangs... */
if (--timeout == 0) {
jack_error ("hung in loop copying position A");
abort();
}
}
*copy = client->engine->frame_timer;
tries++;
} while (copy->guard1 != copy->guard2);
} | false | false | false | false | false | 0 |
Scm_InitStaticClassWithMeta(ScmClass *klass,
const char *name,
ScmModule *mod,
ScmClass *meta,
ScmObj supers,
ScmClassStaticSlotSpec *specs,
int flags)
{
init_class(klass, name, mod, supers, specs, flags);
if (meta) {
SCM_SET_CLASS(klass, meta);
} else {
int nlen;
char *metaname;
nlen = (int)strlen(name);
metaname = SCM_NEW_ATOMIC2(char *, nlen + 6);
if (name[nlen - 1] == '>') {
strncpy(metaname, name, nlen-1);
strcpy(metaname+nlen-1, "-meta>");
} else {
strcpy(metaname, name);
strcat(metaname, "-meta");
}
SCM_SET_CLASS(klass, make_implicit_meta(metaname, klass->cpa, mod));
}
} | false | true | false | false | false | 1 |
menu_skip_part(p)
char_u *p;
{
while (*p != NUL && *p != '.' && !vim_iswhite(*p))
{
if ((*p == '\\' || *p == Ctrl_V) && p[1] != NUL)
++p;
++p;
}
return p;
} | false | false | false | false | false | 0 |
pmap_is_fragment(const struct pmap *pm, const void *p, size_t npages)
{
struct vm_fragment *vmf;
bool fragment;
g_assert(mutex_is_owned(&pm->lock));
vmf = pmap_lookup(pm, p, NULL);
if (NULL == vmf) {
pmap_log_missing(pm, p, npages * kernel_pagesize);
return FALSE;
}
fragment = p == vmf->start && npages == pagecount_fast(vmf_size(vmf));
return fragment;
} | false | false | false | false | false | 0 |
string_fromCharCode(const fn_call& fn)
{
const int version = getSWFVersion(fn);
if (version == 5)
{
std::string str;
for (unsigned int i = 0; i < fn.nargs; i++)
{
// Maximum 65535, as with all DisplayObject codes.
const boost::uint16_t c =
static_cast<boost::uint16_t>(toInt(fn.arg(i), getVM(fn)));
// If more than 255, push 'overflow' byte.
if (c > 255) {
str.push_back(static_cast<unsigned char>(c >> 8));
}
// 0 terminates the string, but mustn't be pushed or it
// will break concatenation.
if (static_cast<unsigned char>(c) == 0) break;
str.push_back(static_cast<unsigned char>(c));
}
return as_value(str);
}
std::wstring wstr;
for (unsigned int i = 0; i < fn.nargs; i++)
{
const boost::uint16_t c =
static_cast<boost::uint16_t>(toInt(fn.arg(i), getVM(fn)));
if (c == 0) break;
wstr.push_back(c);
}
return as_value(utf8::encodeCanonicalString(wstr, version));
} | false | false | false | false | false | 0 |
enc_read_blob_resp(uint8_t *value, int vlen, uint16_t offset,
uint8_t *pdu, int len)
{
if (pdu == NULL)
return 0;
vlen -= offset;
if (vlen > len - 1)
vlen = len - 1;
pdu[0] = ATT_OP_READ_BLOB_RESP;
memcpy(pdu + 1, &value[offset], vlen);
return vlen + 1;
} | false | true | false | false | false | 1 |
SetAlphaColor(int r, int g, int b, int alpha)
{
CLAMP(r, 0, 255);
CLAMP(g, 0, 255);
CLAMP(b, 0, 255);
CLAMP(alpha, 0, 255);
m_flags |= JN_USE_DISPLAY_COLOR;
gr_init_alphacolor(&m_display_color, r, g, b, alpha);
} | false | false | false | false | false | 0 |
setupChildProcess()
{
Q_D(KPtyProcess);
d->pty->setCTty();
if (d->addUtmp)
d->pty->login(KUser(KUser::UseRealUserID).loginName().toLocal8Bit().data(), qgetenv("DISPLAY"));
if (d->ptyChannels & StdinChannel)
dup2(d->pty->slaveFd(), 0);
if (d->ptyChannels & StdoutChannel)
dup2(d->pty->slaveFd(), 1);
if (d->ptyChannels & StderrChannel)
dup2(d->pty->slaveFd(), 2);
KProcess::setupChildProcess();
} | false | false | false | false | false | 0 |
getAllFieldValues( std::ostream &o ) const
{
o << mrpt::format("%.09f %.09f %02u %02u %02.03f %u",
fields.longitude_degrees,
fields.latitude_degrees,
fields.UTCTime.hour,
fields.UTCTime.minute,
fields.UTCTime.sec,
static_cast<unsigned int>(fields.validity_char=='A' ? 1:0)
);
return true;
} | false | false | false | false | false | 0 |
is_jm(struct lib_context *lc, struct dev_info *di, void *meta)
{
struct jm *jm = meta;
return !strncmp((const char *) jm->signature,
JM_SIGNATURE, JM_SIGNATURE_LEN) &&
checksum(jm);
} | false | false | false | false | false | 0 |
findidx(int z)
{
int j;
for (j = 0; j < dcc_total; j++)
if ((dcc[j].sock == z) && (dcc[j].type->flags & DCT_VALIDIDX))
return j;
return -1;
} | false | false | false | false | false | 0 |
rsync_checksum(unsigned char *buf, UINT4 len, UINT4 blockSize, UINT4 seed,
unsigned char *digest, int md4DigestLen)
{
unsigned char seedBytes[4];
if ( md4DigestLen > 0 && seed ) {
RsyncMD4Encode(seedBytes, &seed, 1);
}
while ( len > 0 ) {
int thisLen = len < blockSize ? len : blockSize;
UINT4 adler32 = adler32_checksum((char*)buf, thisLen);
RsyncMD4Encode(digest, &adler32, 1);
digest += 4;
if ( md4DigestLen ) {
RsyncMD4_CTX md4;
RsyncMD4Init(&md4);
RsyncMD4Update(&md4, buf, thisLen);
if ( seed ) {
RsyncMD4Update(&md4, seedBytes, 4);
}
if ( md4DigestLen < 0 ) {
/*
* Done: just save the state and the partial buffer (no finish)
*/
RsyncMD4Encode(digest, md4.state, 16);
digest += 16;
memcpy(digest, md4.buffer, thisLen % 64);
digest += thisLen % 64;
} else if ( md4DigestLen >= 16 ) {
/*
* Normal finish: save all 16 bytes
*/
RsyncMD4FinalRsync(digest, &md4);
digest += 16;
} else {
unsigned char md4Digest[16];
/*
* Finish and truncate to md4DigestLen bytes
*/
RsyncMD4FinalRsync(md4Digest, &md4);
memcpy(digest, md4Digest, md4DigestLen);
digest += md4DigestLen;
}
}
len -= thisLen;
buf += thisLen;
}
} | true | true | false | false | false | 1 |
incrblobSeek(
ClientData instanceData,
long offset,
int seekMode,
int *errorCodePtr
){
IncrblobChannel *p = (IncrblobChannel *)instanceData;
switch( seekMode ){
case SEEK_SET:
p->iSeek = offset;
break;
case SEEK_CUR:
p->iSeek += offset;
break;
case SEEK_END:
p->iSeek = sqlite3_blob_bytes(p->pBlob) + offset;
break;
default: assert(!"Bad seekMode");
}
return p->iSeek;
} | false | false | false | false | false | 0 |
fprint_response(struct http_response* res) {
u32 i, c_len = 0, in_space = 0;
res->sig.code = res->code;
for (i=0;i<res->pay_len;i++)
if (res->payload[i] <= 0x20 || strchr("<>\"'&:\\", (char)res->payload[i])) {
if (!in_space) {
in_space = 1;
if (c_len && ++c_len <= FP_MAX_LEN)
res->sig.data[c_len % FP_SIZE]++;
c_len = 0;
} else c_len++;
if (res->payload[i] == '&')
do { i++; } while (i < res->pay_len &&
(isalnum(res->payload[i]) || strchr("#;", (char)res->payload[i])));
} else {
if (in_space) {
in_space = 0;
if (c_len && ++c_len <= FP_MAX_LEN)
res->sig.data[c_len % FP_SIZE]++;
c_len = 0;
} else {
res->sig.has_text = 1;
c_len++;
}
}
if (c_len) res->sig.data[c_len % FP_SIZE]++;
} | false | false | false | false | false | 0 |
limit_max_speed(float *v)
{
float h2, h, max = 80;
h2 = v[0]*v[0] + v[1]*v[1];
if (h2 > max*max) {
h = sqrt(h2);
v[0] *= max/h;
v[1] *= max/h;
}
} | false | false | false | false | false | 0 |
sd_rw_multi(struct realtek_pci_sdmmc *host, struct mmc_request *mrq)
{
struct mmc_data *data = mrq->data;
if (host->sg_count < 0) {
data->error = host->sg_count;
dev_dbg(sdmmc_dev(host), "%s: sg_count = %d is invalid\n",
__func__, host->sg_count);
return data->error;
}
if (data->flags & MMC_DATA_READ)
return sd_read_long_data(host, mrq);
return sd_write_long_data(host, mrq);
} | false | false | false | false | false | 0 |
R_RegisterBasePlayerModels( void )
{
char mod_filename[MAX_QPATH];
char scratch[MAX_QPATH];
int i, j;
// int npms = 0; // unused
int nskins = 0;
char **skinnames;
if (is_localhost) {
//then the client is also the server so we have this cvar available
cvar_t *maxclients = Cvar_Get ("maxclients", 0, 0);
if (!maxclients|| maxclients->integer <= 1)
return; //don't bother
}
//precache all player and weapon models(base only, otherwise could take very long loading a map!)
for (i = 0; i < PModelsCount; i++)
{
Com_Printf("Registering models for: %s\n", BasePModels[i].name);
Com_sprintf( mod_filename, sizeof(mod_filename), "players/%s/tris.md2", BasePModels[i].name);
R_RegisterModel(mod_filename);
Com_sprintf( mod_filename, sizeof(mod_filename), "players/%s/lod1.md2", BasePModels[i].name);
R_RegisterModel(mod_filename);
Com_sprintf( mod_filename, sizeof(mod_filename), "players/%s/lod2.md2", BasePModels[i].name);
R_RegisterModel(mod_filename);
//register weapon models
for (j = 0; j < WModelsCount; j++)
{
Com_sprintf( mod_filename, sizeof(mod_filename), "players/%s/%s", BasePModels[i].name, BaseWModels[j]);
R_RegisterModel(mod_filename);
}
//register standard sounds
S_RegisterSoundsForPlayer (BasePModels[i].name);
//register all skins
Com_sprintf( scratch, sizeof(scratch), "players/%s/*.jpg", BasePModels[i].name);
skinnames = FS_ListFilesInFS( scratch, &nskins, 0,
SFF_SUBDIR | SFF_HIDDEN | SFF_SYSTEM );
if(!skinnames)
continue;
for(j = 0; j < nskins; j++)
R_RegisterSkin (skinnames[j]);
if(skinnames)
free(skinnames);
}
} | false | false | false | false | false | 0 |
plugin_init (GstPlugin * plugin)
{
/* initialize gst controller library */
gst_controller_init (NULL, NULL);
return (gst_element_register (plugin, "audiopanorama", GST_RANK_NONE,
GST_TYPE_AUDIO_PANORAMA) &&
gst_element_register (plugin, "audioinvert", GST_RANK_NONE,
GST_TYPE_AUDIO_INVERT) &&
gst_element_register (plugin, "audiokaraoke", GST_RANK_NONE,
GST_TYPE_AUDIO_KARAOKE) &&
gst_element_register (plugin, "audioamplify", GST_RANK_NONE,
GST_TYPE_AUDIO_AMPLIFY) &&
gst_element_register (plugin, "audiodynamic", GST_RANK_NONE,
GST_TYPE_AUDIO_DYNAMIC) &&
gst_element_register (plugin, "audiocheblimit", GST_RANK_NONE,
GST_TYPE_AUDIO_CHEB_LIMIT) &&
gst_element_register (plugin, "audiochebband", GST_RANK_NONE,
GST_TYPE_AUDIO_CHEB_BAND) &&
gst_element_register (plugin, "audioiirfilter", GST_RANK_NONE,
GST_TYPE_AUDIO_IIR_FILTER) &&
gst_element_register (plugin, "audiowsinclimit", GST_RANK_NONE,
GST_TYPE_AUDIO_WSINC_LIMIT) &&
gst_element_register (plugin, "audiowsincband", GST_RANK_NONE,
GST_TYPE_AUDIO_WSINC_BAND) &&
gst_element_register (plugin, "audiofirfilter", GST_RANK_NONE,
GST_TYPE_AUDIO_FIR_FILTER) &&
gst_element_register (plugin, "audioecho", GST_RANK_NONE,
GST_TYPE_AUDIO_ECHO));
} | false | false | false | false | false | 0 |
RunModal() {
if ( setupOK )
return Panel::RunModal();
return 0;
} | false | false | false | false | false | 0 |
stepUp()
{
assert(dict != NULL);
while (hindex <= dict->highestBucket) {
DcmDictEntryList* bucket = dict->hashTab[hindex];
if (bucket == NULL) {
if (hindex == dict->highestBucket)
return; /* We reached the end of the dictionary */
hindex++; // move on to next bucket
iterating = OFFalse;
} else {
if (!iterating) {
iter = bucket->begin();
iterating = OFTrue;
if (iter != bucket->end()) {
return; /* we have found the next one */
}
}
if (iter == bucket->end()) {
if (hindex == dict->highestBucket)
return; /* We reached the end of the dictionary */
iterating = OFFalse;
hindex++;
} else {
++iter;
if (iter != bucket->end()) {
return; /* we have found the next one */
}
}
}
}
} | false | false | false | false | false | 0 |
add_point(const lattice_point& new_point)
{
_vector2<double> line_start(start[0], start[1]);
double nx = double(start[1]) - double(new_point[1]);
double ny = double(new_point[0]) - double(start[0]);
_vector2<double> line_normal(nx,ny);
normalize(line_normal);
for(std::list<lattice_point>::iterator i = points.begin();
i != points.end();
i++)
{
_vector2<double> current_point((*i)[0], (*i)[1]);
double dist_to_line = ((current_point - line_start) * line_normal);
if(dist_to_line < 0) dist_to_line *= -1;
if(dist_to_line > max_error)
{
return false;
}
}
//std::cout << std::endl;
points.push_back(new_point);
end = new_point;
return true;
} | 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.