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 |
|---|---|---|---|---|---|---|
rcBuildDistanceField(rcContext* ctx, rcCompactHeightfield& chf)
{
rcAssert(ctx);
ctx->startTimer(RC_TIMER_BUILD_DISTANCEFIELD);
if (chf.dist)
{
rcFree(chf.dist);
chf.dist = 0;
}
unsigned short* src = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
if (!src)
{
ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'src' (%d).", chf.spanCount);
return false;
}
unsigned short* dst = (unsigned short*)rcAlloc(sizeof(unsigned short)*chf.spanCount, RC_ALLOC_TEMP);
if (!dst)
{
ctx->log(RC_LOG_ERROR, "rcBuildDistanceField: Out of memory 'dst' (%d).", chf.spanCount);
rcFree(src);
return false;
}
unsigned short maxDist = 0;
ctx->startTimer(RC_TIMER_BUILD_DISTANCEFIELD_DIST);
calculateDistanceField(chf, src, maxDist);
chf.maxDistance = maxDist;
ctx->stopTimer(RC_TIMER_BUILD_DISTANCEFIELD_DIST);
ctx->startTimer(RC_TIMER_BUILD_DISTANCEFIELD_BLUR);
// Blur
if (boxBlur(chf, 1, src, dst) != src)
rcSwap(src, dst);
// Store distance.
chf.dist = src;
ctx->stopTimer(RC_TIMER_BUILD_DISTANCEFIELD_BLUR);
ctx->stopTimer(RC_TIMER_BUILD_DISTANCEFIELD);
rcFree(dst);
return true;
} | false | false | false | false | true | 1 |
WriteMolecule(OBBase* pOb, OBConversion* pConv)
{
OBMol* pmol = dynamic_cast<OBMol*>(pOb);
if(pmol==NULL)
return false;
//Define some references so we can use the old parameter names
ostream &ofs = *pConv->GetOutStream();
OBMol &mol = *pmol;
char buffer[BUFF_SIZE];
snprintf(buffer, BUFF_SIZE, "%d\n", mol.NumAtoms());
ofs << buffer;
if (fabs(mol.GetEnergy()) > 1.0e-3) // nonzero energy field
snprintf(buffer, BUFF_SIZE, "%s\tEnergy: %15.7f\n",
mol.GetTitle(), mol.GetEnergy());
else
snprintf(buffer, BUFF_SIZE, "%s\n", mol.GetTitle());
ofs << buffer;
FOR_ATOMS_OF_MOL(atom, mol)
{
snprintf(buffer, BUFF_SIZE, "%-3s%15.5f%15.5f%15.5f\n",
etab.GetSymbol(atom->GetAtomicNum()),
atom->GetX(),
atom->GetY(),
atom->GetZ());
ofs << buffer;
}
return(true);
} | false | false | false | false | false | 0 |
make_row_distinct_op(ParseState *pstate, List *opname,
RowExpr *lrow, RowExpr *rrow,
int location)
{
Node *result = NULL;
List *largs = lrow->args;
List *rargs = rrow->args;
ListCell *l,
*r;
if (list_length(largs) != list_length(rargs))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unequal number of entries in row expressions"),
parser_errposition(pstate, location)));
forboth(l, largs, r, rargs)
{
Node *larg = (Node *) lfirst(l);
Node *rarg = (Node *) lfirst(r);
Node *cmp;
cmp = (Node *) make_distinct_op(pstate, opname, larg, rarg, location);
if (result == NULL)
result = cmp;
else
result = (Node *) makeBoolExpr(OR_EXPR,
list_make2(result, cmp),
location);
}
if (result == NULL)
{
/* zero-length rows? Generate constant FALSE */
result = makeBoolConst(false, false);
}
return result;
} | false | false | false | false | false | 0 |
get_device_status(int fd)
{
struct termios t;
if (fd < 0)
return 0;
return !tcgetattr(fd, &t);
} | false | false | false | false | false | 0 |
printFunctionSummary(raw_ostream &OS,
const FunctionVector &Funcs) const {
for (const GCOVFunction *Func : Funcs) {
uint64_t EntryCount = Func->getEntryCount();
uint32_t BlocksExec = 0;
for (const GCOVBlock &Block : Func->blocks())
if (Block.getNumDstEdges() && Block.getCount())
++BlocksExec;
OS << "function " << Func->getName() << " called " << EntryCount
<< " returned " << safeDiv(Func->getExitCount() * 100, EntryCount)
<< "% blocks executed "
<< safeDiv(BlocksExec * 100, Func->getNumBlocks() - 1) << "%\n";
}
} | false | false | false | false | false | 0 |
soap_write_date(time_t date)
{
struct tm date_parts;
Octstr* out;
if (date < 0)
/* sanity check - I don't think it should ever happen, but I don't want to get
support calls at 2am because some gateway in the UK went bananas. */
return octstr_create("ERROR");
/* split up epoch time to elements */
gmtime_r(&date, &date_parts);
out = octstr_format("%d/%02d/%02d:%02d:%02d",
date_parts.tm_year + 1900, date_parts.tm_mon + 1, date_parts.tm_mday, date_parts.tm_hour, date_parts.tm_min);
/* again */
if (out)
return out;
else
return octstr_create("ERROR");
/* assuming octstr_create never fails, unlike octstr_format. this is not the case currently (both cannot fail), but it may change */
} | false | false | false | false | false | 0 |
get_base_info(struct file *fp, void __user *ubase, __u32 len)
{
struct hfi1_base_info binfo;
struct hfi1_ctxtdata *uctxt = ctxt_fp(fp);
struct hfi1_devdata *dd = uctxt->dd;
ssize_t sz;
unsigned offset;
int ret = 0;
trace_hfi1_uctxtdata(uctxt->dd, uctxt);
memset(&binfo, 0, sizeof(binfo));
binfo.hw_version = dd->revision;
binfo.sw_version = HFI1_KERN_SWVERSION;
binfo.bthqp = kdeth_qp;
binfo.jkey = uctxt->jkey;
/*
* If more than 64 contexts are enabled the allocated credit
* return will span two or three contiguous pages. Since we only
* map the page containing the context's credit return address,
* we need to calculate the offset in the proper page.
*/
offset = ((u64)uctxt->sc->hw_free -
(u64)dd->cr_base[uctxt->numa_id].va) % PAGE_SIZE;
binfo.sc_credits_addr = HFI1_MMAP_TOKEN(PIO_CRED, uctxt->ctxt,
subctxt_fp(fp), offset);
binfo.pio_bufbase = HFI1_MMAP_TOKEN(PIO_BUFS, uctxt->ctxt,
subctxt_fp(fp),
uctxt->sc->base_addr);
binfo.pio_bufbase_sop = HFI1_MMAP_TOKEN(PIO_BUFS_SOP,
uctxt->ctxt,
subctxt_fp(fp),
uctxt->sc->base_addr);
binfo.rcvhdr_bufbase = HFI1_MMAP_TOKEN(RCV_HDRQ, uctxt->ctxt,
subctxt_fp(fp),
uctxt->rcvhdrq);
binfo.rcvegr_bufbase = HFI1_MMAP_TOKEN(RCV_EGRBUF, uctxt->ctxt,
subctxt_fp(fp),
uctxt->egrbufs.rcvtids[0].phys);
binfo.sdma_comp_bufbase = HFI1_MMAP_TOKEN(SDMA_COMP, uctxt->ctxt,
subctxt_fp(fp), 0);
/*
* user regs are at
* (RXE_PER_CONTEXT_USER + (ctxt * RXE_PER_CONTEXT_SIZE))
*/
binfo.user_regbase = HFI1_MMAP_TOKEN(UREGS, uctxt->ctxt,
subctxt_fp(fp), 0);
offset = offset_in_page((((uctxt->ctxt - dd->first_user_ctxt) *
HFI1_MAX_SHARED_CTXTS) + subctxt_fp(fp)) *
sizeof(*dd->events));
binfo.events_bufbase = HFI1_MMAP_TOKEN(EVENTS, uctxt->ctxt,
subctxt_fp(fp),
offset);
binfo.status_bufbase = HFI1_MMAP_TOKEN(STATUS, uctxt->ctxt,
subctxt_fp(fp),
dd->status);
if (HFI1_CAP_IS_USET(DMA_RTAIL))
binfo.rcvhdrtail_base = HFI1_MMAP_TOKEN(RTAIL, uctxt->ctxt,
subctxt_fp(fp), 0);
if (uctxt->subctxt_cnt) {
binfo.subctxt_uregbase = HFI1_MMAP_TOKEN(SUBCTXT_UREGS,
uctxt->ctxt,
subctxt_fp(fp), 0);
binfo.subctxt_rcvhdrbuf = HFI1_MMAP_TOKEN(SUBCTXT_RCV_HDRQ,
uctxt->ctxt,
subctxt_fp(fp), 0);
binfo.subctxt_rcvegrbuf = HFI1_MMAP_TOKEN(SUBCTXT_EGRBUF,
uctxt->ctxt,
subctxt_fp(fp), 0);
}
sz = (len < sizeof(binfo)) ? len : sizeof(binfo);
if (copy_to_user(ubase, &binfo, sz))
ret = -EFAULT;
return ret;
} | false | false | false | false | false | 0 |
mono_load_remote_field_new (MonoObject *this_obj, MonoClass *klass, MonoClassField *field)
{
MONO_REQ_GC_UNSAFE_MODE;
static MonoMethod *getter = NULL;
MonoDomain *domain = mono_domain_get ();
MonoTransparentProxy *tp = (MonoTransparentProxy *) this_obj;
MonoClass *field_class;
MonoMethodMessage *msg;
MonoArray *out_args;
MonoObject *exc, *res;
char* full_name;
g_assert (mono_object_is_transparent_proxy (this_obj));
field_class = mono_class_from_mono_type (field->type);
if (mono_class_is_contextbound (tp->remote_class->proxy_class) && tp->rp->context == (MonoObject *) mono_context_get ()) {
gpointer val;
if (field_class->valuetype) {
res = mono_object_new (domain, field_class);
val = ((gchar *) res) + sizeof (MonoObject);
} else {
val = &res;
}
mono_field_get_value (tp->rp->unwrapped_server, field, val);
return res;
}
if (!getter) {
getter = mono_class_get_method_from_name (mono_defaults.object_class, "FieldGetter", -1);
if (!getter)
mono_raise_exception (mono_get_exception_not_supported ("Linked away."));
}
msg = (MonoMethodMessage *)mono_object_new (domain, mono_defaults.mono_method_message_class);
out_args = mono_array_new (domain, mono_defaults.object_class, 1);
mono_message_init (domain, msg, mono_method_get_object (domain, getter, NULL), out_args);
full_name = mono_type_get_full_name (klass);
mono_array_setref (msg->args, 0, mono_string_new (domain, full_name));
mono_array_setref (msg->args, 1, mono_string_new (domain, mono_field_get_name (field)));
g_free (full_name);
mono_remoting_invoke ((MonoObject *)(tp->rp), msg, &exc, &out_args);
if (exc) mono_raise_exception ((MonoException *)exc);
if (mono_array_length (out_args) == 0)
res = NULL;
else
res = mono_array_get (out_args, MonoObject *, 0);
return res;
} | false | false | false | false | true | 1 |
multiply_parameters( int curr_parameter )
{
ActionTemplate *tmp;
int i, j, t, n;
if ( curr_parameter == lnum_multiply_parameters ) {
tmp = new_ActionTemplate( lo_num );
for ( i = 0; i < lo->num_vars; i++ ) {
tmp->inst_table[i] = lo->inst_table[i];
}
tmp->next = gtemplates;
gtemplates = tmp;
gnum_templates++;
return;
}
if ( curr_parameter == lnum_multiply_parameters - 1 ) {
t = lo->var_types[lmultiply_parameters[curr_parameter]];
n = gtype_size[t];
for ( i = 0; i < n; i++ ) {
if ( 0 && lused_constant[gtype_consts[t][i]] ) {
continue;
}
lo->inst_table[lmultiply_parameters[curr_parameter]] = gtype_consts[t][i];
tmp = new_ActionTemplate( lo_num );
for ( j = 0; j < lo->num_vars; j++ ) {
tmp->inst_table[j] = lo->inst_table[j];
}
tmp->next = gtemplates;
gtemplates = tmp;
gnum_templates++;
}
lo->inst_table[lmultiply_parameters[curr_parameter]] = -1;
return;
}
t = lo->var_types[lmultiply_parameters[curr_parameter]];
n = gtype_size[t];
for ( i = 0; i < n; i++ ) {
if ( 0 && lused_constant[gtype_consts[t][i]] ) {
continue;
}
lo->inst_table[lmultiply_parameters[curr_parameter]] = gtype_consts[t][i];
lused_constant[gtype_consts[t][i]] = TRUE;
multiply_parameters( curr_parameter + 1 );
lused_constant[gtype_consts[t][i]] = FALSE;
}
lo->inst_table[lmultiply_parameters[curr_parameter]] = -1;
} | false | false | false | false | false | 0 |
demodulate(Term t, Mindex demods, Ilist *just_head, BOOL lex_order_vars)
{
int flag = claim_term_flag();
Term result;
if (demods->unif_type == ORDINARY_UNIF)
result = demod(t, demods, flag, just_head, lex_order_vars);
else
result = demod_bt(t, demods, -1, flag, just_head);
term_flag_clear_recursively(result, flag);
release_term_flag(flag);
return result;
} | false | false | false | false | false | 0 |
fsbe_get_operand_unit_size(Operand *op)
{
switch(op->kind){
case KIND_VAR:
return(op->tbl.v->size);
case KIND_ARRAY:
return(op->tbl.a->size / op->tbl.a->total);
default:
fprintf(stderr,
"ERROR(fsbe_get_operand_unit_size): not implemented kind: %s\n",
str_kind[op->kind]);
exit(1);
}
} | false | false | false | false | false | 0 |
hash_delete(char *name, hashtable *ht)
#else
hash_delete(name, ht)
char *name;
hashtable *ht;
#endif
{
hashnode *hp;
hp = hash_bucket(name, ht);
if (*hp) {
free((char *) *hp);
*hp = 0;
}
} | false | false | false | false | false | 0 |
data_write_file( disk_t *d, FILE *file, int seclen )
{
int len = 0x80 << seclen;
if( fwrite( &d->track[ d->i ], len, 1, file ) != 1 )
return 1;
return 0;
} | false | false | false | false | false | 0 |
gv_set_defaults(geovect * gv)
{
int i;
if (!gv) {
return (-1);
}
G_debug(5, "gv_set_defaults() id=%d", gv->gvect_id);
gv->filename = NULL;
gv->n_lines = gv->n_surfs = gv->use_mem = 0;
gv->x_trans = gv->y_trans = gv->z_trans = 0.0;
gv->lines = NULL;
gv->fastlines = NULL;
gv->width = 1;
gv->color = 0xFFFFFF;
gv->flat_val = 0;
for (i = 0; i < MAX_SURFS; i++) {
gv->drape_surf_id[i] = 0;
}
return (0);
} | false | false | false | false | false | 0 |
gtk_knob_set_animation (GtkKnob *knob, GtkKnobAnim *anim) {
g_return_if_fail (knob != NULL);
g_return_if_fail (anim != NULL);
g_return_if_fail (GTK_IS_KNOB (knob));
knob->anim = (GtkKnobAnim *)anim;
knob->width = anim->frame_width;
knob->height = anim->height;
if (gtk_widget_get_realized (GTK_WIDGET(knob))) {
gtk_widget_queue_resize (GTK_WIDGET (knob));
}
} | false | false | false | false | false | 0 |
testDebugContext(void )
{
SVUT_SET_CONTEXT("test","value");
SVUT_ASSERT_EQUAL(2,3);
} | false | false | false | false | false | 0 |
parseCommonRSP(DcmDataset *obj, Uint16 *command,
Uint16 *messageIDBeingRespondedTo,
Uint16 *dataSetType, Uint16 *status)
{
OFCondition cond = getAndDeleteUS(obj, DCM_CommandField, command); RET(cond);
cond = getAndDeleteUS(obj, DCM_MessageIDBeingRespondedTo,
messageIDBeingRespondedTo); RET(cond);
cond = getAndDeleteUS(obj, DCM_DataSetType, dataSetType); RET(cond);
cond = getAndDeleteUS(obj, DCM_Status, status); RET(cond);
return EC_Normal;
} | false | false | false | false | false | 0 |
icpHandleUdp(int sock, void *data)
{
int *N = &incoming_sockets_accepted;
struct sockaddr_in from;
socklen_t from_len;
LOCAL_ARRAY(char, buf, SQUID_UDP_SO_RCVBUF);
int len;
int icp_version;
int max = INCOMING_ICP_MAX;
commSetSelect(sock, COMM_SELECT_READ, icpHandleUdp, NULL, 0);
while (max--) {
from_len = sizeof(from);
memset(&from, '\0', from_len);
statCounter.syscalls.sock.recvfroms++;
len = recvfrom(sock,
buf,
SQUID_UDP_SO_RCVBUF - 1,
0,
(struct sockaddr *) &from,
&from_len);
if (len == 0)
break;
if (len < 0) {
if (ignoreErrno(errno))
break;
#ifdef _SQUID_LINUX_
/* Some Linux systems seem to set the FD for reading and then
* return ECONNREFUSED when sendto() fails and generates an ICMP
* port unreachable message. */
/* or maybe an EHOSTUNREACH "No route to host" message */
if (errno != ECONNREFUSED && errno != EHOSTUNREACH)
#endif
debug(12, 1) ("icpHandleUdp: FD %d recvfrom: %s\n",
sock, xstrerror());
break;
}
(*N)++;
icpCount(buf, RECV, (size_t) len, 0);
buf[len] = '\0';
debug(12, 4) ("icpHandleUdp: FD %d: received %d bytes from %s.\n",
sock,
len,
inet_ntoa(from.sin_addr));
#ifdef ICP_PACKET_DUMP
icpPktDump(buf);
#endif
if (len < sizeof(icp_common_t)) {
debug(12, 4) ("icpHandleUdp: Ignoring too-small UDP packet\n");
break;
}
icp_version = (int) buf[1]; /* cheat! */
if (icp_version == ICP_VERSION_2)
icpHandleIcpV2(sock, from, buf, len);
else if (icp_version == ICP_VERSION_3)
icpHandleIcpV3(sock, from, buf, len);
else
debug(12, 1) ("WARNING: Unused ICP version %d received from %s:%d\n",
icp_version,
inet_ntoa(from.sin_addr),
ntohs(from.sin_port));
}
} | false | false | false | false | false | 0 |
rad_recv_header(int sockfd, fr_ipaddr_t *src_ipaddr, int *src_port,
int *code)
{
ssize_t data_len, packet_len;
uint8_t header[4];
struct sockaddr_storage src;
socklen_t sizeof_src = sizeof(src);
data_len = recvfrom(sockfd, header, sizeof(header), MSG_PEEK,
(struct sockaddr *)&src, &sizeof_src);
if (data_len < 0) {
if ((errno == EAGAIN) || (errno == EINTR)) return 0;
return -1;
}
/*
* Too little data is available, discard the packet.
*/
if (data_len < 4) {
recvfrom(sockfd, header, sizeof(header), 0,
(struct sockaddr *)&src, &sizeof_src);
return 1;
} else { /* we got 4 bytes of data. */
/*
* See how long the packet says it is.
*/
packet_len = (header[2] * 256) + header[3];
/*
* The length in the packet says it's less than
* a RADIUS header length: discard it.
*/
if (packet_len < AUTH_HDR_LEN) {
recvfrom(sockfd, header, sizeof(header), 0,
(struct sockaddr *)&src, &sizeof_src);
return 1;
/*
* Enforce RFC requirements, for sanity.
* Anything after 4k will be discarded.
*/
} else if (packet_len > MAX_PACKET_LEN) {
recvfrom(sockfd, header, sizeof(header), 0,
(struct sockaddr *)&src, &sizeof_src);
return 1;
}
}
/*
* Convert AF. If unknown, discard packet.
*/
if (!fr_sockaddr2ipaddr(&src, sizeof_src, src_ipaddr, src_port)) {
recvfrom(sockfd, header, sizeof(header), 0,
(struct sockaddr *)&src, &sizeof_src);
return 1;
}
*code = header[0];
/*
* The packet says it's this long, but the actual UDP
* size could still be smaller.
*/
return packet_len;
} | false | false | false | false | false | 0 |
writeRegistry(){
if (shown()) {
getApp()->reg().writeIntEntry("window","remote-x",getX());
getApp()->reg().writeIntEntry("window","remote-y",getY());
getApp()->reg().writeIntEntry("window","remote-width",getWidth());
getApp()->reg().writeIntEntry("window","remote-height",getHeight());
}
} | false | false | false | false | false | 0 |
ResetAfterSkip(VP8EncIterator* const it) {
if (it->mb_->type_ == 1) {
*it->nz_ = 0; // reset all predictors
it->left_nz_[8] = 0;
} else {
*it->nz_ &= (1 << 24); // preserve the dc_nz bit
}
} | false | false | false | false | false | 0 |
DrealEraseRecWin( Rectangle )
rdsrec_list *Rectangle;
{
drealrecwin *ScanRecWin;
drealrecwin *DelRecWin;
rdsbegin();
if ( ! IsDrealOneWindow( Rectangle ) )
{
ScanRecWin = DREAL_WINDOW( Rectangle );
do
{
DelRecWin = ScanRecWin;
ScanRecWin = ScanRecWin->NEXT;
DrealFreeRecWin( DelRecWin );
}
while ( ScanRecWin != (drealrecwin *)NULL );
}
DREAL_WINDOW( Rectangle ) = (drealrecwin *)NULL;
rdsend();
} | false | false | false | false | false | 0 |
glade_widget_create_packing_properties (GladeWidget *container, GladeWidget *widget)
{
GladePropertyClass *property_class;
GladeProperty *property;
GList *list, *packing_props = NULL;
/* XXX TODO: by checking with some GladePropertyClass metadata, decide
* which packing properties go on which type of children.
*/
for (list = container->adaptor->packing_props;
list && list->data; list = list->next)
{
property_class = list->data;
property = glade_property_new (property_class, widget, NULL);
packing_props = g_list_prepend (packing_props, property);
}
return g_list_reverse (packing_props);
} | false | false | false | false | false | 0 |
matrix_assign_variable(pk_internal_t* pk,
bool destructive,
matrix_t* mat,
ap_dim_t dim, numint_t* tab)
{
size_t i,j,var;
bool den;
matrix_t* nmat;
var = pk->dec + dim;
den = numint_cmp_int(tab[0],1)>0;
nmat =
destructive ?
mat :
_matrix_alloc_int(mat->nbrows,mat->nbcolumns,false);
nmat->_sorted = false;
for (i=0; i<mat->nbrows; i++){
/* product for var column */
vector_product(pk,pk->matrix_prod,
mat->p[i],
tab,mat->nbcolumns);
/* columns != var */
if (!destructive){
/* Functional */
numint_init_set(nmat->p[i][0],mat->p[i][0]);
for (j=1; j<mat->nbcolumns; j++){
if (j!=var){
numint_init_set(nmat->p[i][j],mat->p[i][j]);
if (den){
numint_mul(nmat->p[i][j],mat->p[i][j],tab[0]);
}
}
}
}
else {
/* Side-effect */
for (j=0; j<mat->nbcolumns; j++){
if (j!=var){
if (den)
numint_mul(nmat->p[i][j],mat->p[i][j],tab[0]);
else
numint_set(nmat->p[i][j],mat->p[i][j]);
}
}
}
/* var column */
if (!destructive)
numint_init_set(nmat->p[i][var],pk->matrix_prod);
else
numint_set(nmat->p[i][var],pk->matrix_prod);
matrix_normalize_row(pk,nmat,i);
}
return nmat;
} | false | false | false | false | false | 0 |
curl_easy_getinfo(CURL *curl, CURLINFO info, ... )
{
va_list ap;
long *var;
va_start(ap,info);
switch(info)
{
case CURLINFO_RESPONSE_CODE:
var=va_arg(ap,long *);
*var=curl->status;
break;
default:
break;
}
return handle_error(curl,CURLE_OK,NULL);
} | false | false | false | false | false | 0 |
save_VertexAttrib3fvARB(GLuint index, const GLfloat * v)
{
if (index < MAX_VERTEX_GENERIC_ATTRIBS)
save_Attr3fARB(index, v[0], v[1], v[2]);
else
index_error();
} | false | false | false | false | false | 0 |
SerialOpen(void){
// open the port
// O_RDWR = read/write
// O_NOCTTY = not controlling
// O_NDELAY = don't wait for other port to open
if((fd = open(SERIALPORT, (O_RDWR | O_NOCTTY | O_NDELAY))) == -1){
// could not open the port
printf("Could not open serial communications - %s Error number: %d\n", SERIALPORT,errno);
}
else{
fcntl(fd,F_SETFL, 0);
printf("Opened serial port %s\n", SERIALPORT);
}
return(fd);
} | false | false | false | false | false | 0 |
visitSREM(SDNode *N) {
SDValue N0 = N->getOperand(0);
SDValue N1 = N->getOperand(1);
ConstantSDNode *N0C = dyn_cast<ConstantSDNode>(N0);
ConstantSDNode *N1C = dyn_cast<ConstantSDNode>(N1);
EVT VT = N->getValueType(0);
// fold (srem c1, c2) -> c1%c2
if (N0C && N1C && !N1C->isNullValue())
return DAG.FoldConstantArithmetic(ISD::SREM, VT, N0C, N1C);
// If we know the sign bits of both operands are zero, strength reduce to a
// urem instead. Handles (X & 0x0FFFFFFF) %s 16 -> X&15
if (!VT.isVector()) {
if (DAG.SignBitIsZero(N1) && DAG.SignBitIsZero(N0))
return DAG.getNode(ISD::UREM, N->getDebugLoc(), VT, N0, N1);
}
// If X/C can be simplified by the division-by-constant logic, lower
// X%C to the equivalent of X-X/C*C.
if (N1C && !N1C->isNullValue()) {
SDValue Div = DAG.getNode(ISD::SDIV, N->getDebugLoc(), VT, N0, N1);
AddToWorkList(Div.getNode());
SDValue OptimizedDiv = combine(Div.getNode());
if (OptimizedDiv.getNode() && OptimizedDiv.getNode() != Div.getNode()) {
SDValue Mul = DAG.getNode(ISD::MUL, N->getDebugLoc(), VT,
OptimizedDiv, N1);
SDValue Sub = DAG.getNode(ISD::SUB, N->getDebugLoc(), VT, N0, Mul);
AddToWorkList(Mul.getNode());
return Sub;
}
}
// undef % X -> 0
if (N0.getOpcode() == ISD::UNDEF)
return DAG.getConstant(0, VT);
// X % undef -> undef
if (N1.getOpcode() == ISD::UNDEF)
return N1;
return SDValue();
} | false | false | false | false | false | 0 |
nfs4_init_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms,
const char *ip_addr)
{
char buf[INET6_ADDRSTRLEN + 1];
struct nfs_client *old;
int error;
if (clp->cl_cons_state == NFS_CS_READY) {
/* the client is initialised already */
dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp);
return clp;
}
/* Check NFS protocol revision and initialize RPC op vector */
clp->rpc_ops = &nfs_v4_clientops;
if (clp->cl_minorversion != 0)
__set_bit(NFS_CS_INFINITE_SLOTS, &clp->cl_flags);
__set_bit(NFS_CS_DISCRTRY, &clp->cl_flags);
__set_bit(NFS_CS_NO_RETRANS_TIMEOUT, &clp->cl_flags);
error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_GSS_KRB5I);
if (error == -EINVAL)
error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX);
if (error < 0)
goto error;
/* If no clientaddr= option was specified, find a usable cb address */
if (ip_addr == NULL) {
struct sockaddr_storage cb_addr;
struct sockaddr *sap = (struct sockaddr *)&cb_addr;
error = rpc_localaddr(clp->cl_rpcclient, sap, sizeof(cb_addr));
if (error < 0)
goto error;
error = rpc_ntop(sap, buf, sizeof(buf));
if (error < 0)
goto error;
ip_addr = (const char *)buf;
}
strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
error = nfs_idmap_new(clp);
if (error < 0) {
dprintk("%s: failed to create idmapper. Error = %d\n",
__func__, error);
goto error;
}
__set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
error = nfs4_init_client_minor_version(clp);
if (error < 0)
goto error;
if (!nfs4_has_session(clp))
nfs_mark_client_ready(clp, NFS_CS_READY);
error = nfs4_discover_server_trunking(clp, &old);
if (error < 0)
goto error;
if (clp != old)
clp->cl_preserve_clid = true;
nfs_put_client(clp);
return old;
error:
nfs_mark_client_ready(clp, error);
nfs_put_client(clp);
dprintk("<-- nfs4_init_client() = xerror %d\n", error);
return ERR_PTR(error);
} | false | false | false | false | false | 0 |
theorem_weapon_shot_act(tenm_object *my, const tenm_object *player)
{
/* sanity check */
if (my == NULL)
{
fprintf(stderr, "normal_shot_act: my is NULL\n");
return 0;
}
if (player == NULL)
return 0;
my->count[2] = theorem_weapon_shot_seek(my->x, my->y,
player->x, player->y,
my->count_d[0], my->count_d[1],
my->count[1]);
return 0;
} | false | false | false | false | false | 0 |
rtl8180_conf_tx(struct ieee80211_hw *dev,
struct ieee80211_vif *vif, u16 queue,
const struct ieee80211_tx_queue_params *params)
{
struct rtl8180_priv *priv = dev->priv;
u8 cw_min, cw_max;
/* nothing to do ? */
if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8180)
return 0;
cw_min = fls(params->cw_min);
cw_max = fls(params->cw_max);
if (priv->chip_family == RTL818X_CHIP_FAMILY_RTL8187SE) {
priv->queue_param[queue] = *params;
rtl8187se_conf_ac_parm(dev, queue);
} else
rtl818x_iowrite8(priv, &priv->map->CW_VAL,
(cw_max << 4) | cw_min);
return 0;
} | false | false | false | false | false | 0 |
init_s3_values(FLOAT ** p, int (*s3ind)[2], int npart,
FLOAT const *bval, FLOAT const *bval_width, FLOAT const *norm)
{
FLOAT s3[CBANDS][CBANDS];
/* The s3 array is not linear in the bark scale.
* bval[x] should be used to get the bark value.
*/
int i, j, k;
int numberOfNoneZero = 0;
memset(&s3[0][0], 0, sizeof(s3));
/* s[i][j], the value of the spreading function,
* centered at band j (masker), for band i (maskee)
*
* i.e.: sum over j to spread into signal barkval=i
* NOTE: i and j are used opposite as in the ISO docs
*/
for (i = 0; i < npart; i++) {
for (j = 0; j < npart; j++) {
FLOAT v = s3_func(bval[i] - bval[j]) * bval_width[j];
s3[i][j] = v * norm[i];
}
}
for (i = 0; i < npart; i++) {
for (j = 0; j < npart; j++) {
if (s3[i][j] > 0.0f)
break;
}
s3ind[i][0] = j;
for (j = npart - 1; j > 0; j--) {
if (s3[i][j] > 0.0f)
break;
}
s3ind[i][1] = j;
numberOfNoneZero += (s3ind[i][1] - s3ind[i][0] + 1);
}
*p = malloc(sizeof(FLOAT) * numberOfNoneZero);
if (!*p)
return -1;
k = 0;
for (i = 0; i < npart; i++)
for (j = s3ind[i][0]; j <= s3ind[i][1]; j++)
(*p)[k++] = s3[i][j];
return 0;
} | false | false | false | false | true | 1 |
InvokeByIndex (int aIndex,
const NPVariant *argv,
uint32_t argc,
NPVariant *_result)
{
TOTEM_LOG_INVOKE (aIndex, totemGMPControls);
switch (Methods (aIndex)) {
case ePause:
/* void pause (); */
Plugin()->Command (TOTEM_COMMAND_PAUSE);
return VoidVariant (_result);
case ePlay:
/* void play (); */
Plugin()->Command (TOTEM_COMMAND_PLAY);
return VoidVariant (_result);
case eStop:
/* void stop (); */
Plugin()->Command (TOTEM_COMMAND_PAUSE);
return VoidVariant (_result);
case eGetAudioLanguageDescription:
/* AUTF8String getAudioLanguageDescription (in long index); */
TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
return StringVariant (_result, "English");
case eGetLanguageName:
/* AUTF8String getLanguageName (in long LCID); */
TOTEM_WARN_1_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
return StringVariant (_result, "English");
case eIsAvailable:
/* boolean isAvailable (in ACString name); */
NPString name;
if (!GetNPStringFromArguments (argv, argc, 0, name))
return false;
if (g_ascii_strncasecmp (name.UTF8Characters, "currentItem", name.UTF8Length) == 0
|| g_ascii_strncasecmp (name.UTF8Characters, "next", name.UTF8Length) == 0
|| g_ascii_strncasecmp (name.UTF8Characters, "pause", name.UTF8Length) == 0
|| g_ascii_strncasecmp (name.UTF8Characters, "play", name.UTF8Length) == 0
|| g_ascii_strncasecmp (name.UTF8Characters, "previous", name.UTF8Length) == 0
|| g_ascii_strncasecmp (name.UTF8Characters, "stop", name.UTF8Length) == 0)
return BoolVariant (_result, true);
return BoolVariant (_result, false);
case eFastForward:
/* void fastForward (); */
case eFastReverse:
/* void fastReverse (); */
case eGetAudioLanguageID:
/* long getAudioLanguageID (in long index); */
case eNext:
/* void next (); */
case ePlayItem:
/* void playItem (in totemIGMPMedia theMediaItem); */
case ePrevious:
/* void previous (); */
case eStep:
/* void step (in long frameCount); */
TOTEM_WARN_INVOKE_UNIMPLEMENTED (aIndex,totemGMPControls);
return VoidVariant (_result);
}
return false;
} | false | false | false | false | false | 0 |
baseURL()
{
// try to find the style sheet. If found look for its url.
// If it has none, look for the parentsheet, or the parentNode and
// try to find out about their url
StyleSheetImpl *sheet = stylesheet();
if(!sheet) return KUrl();
if(!sheet->href().isNull())
return KUrl( sheet->href().string() );
// find parent
if(sheet->parent()) return sheet->parent()->baseURL();
if(!sheet->ownerNode()) return KUrl();
return sheet->ownerNode()->document()->baseURL();
} | false | false | false | false | false | 0 |
dParseFloatFormat(char *buf, int *num, int *size)
{
char *tmp, *period;
tmp = buf;
while (*tmp++ != '(') ;
*num = atoi(tmp); /*sscanf(tmp, "%d", num);*/
while (*tmp != 'E' && *tmp != 'e' && *tmp != 'D' && *tmp != 'd'
&& *tmp != 'F' && *tmp != 'f') {
/* May find kP before nE/nD/nF, like (1P6F13.6). In this case the
num picked up refers to P, which should be skipped. */
if (*tmp=='p' || *tmp=='P') {
++tmp;
*num = atoi(tmp); /*sscanf(tmp, "%d", num);*/
} else {
++tmp;
}
}
++tmp;
period = tmp;
while (*period != '.' && *period != ')') ++period ;
*period = '\0';
*size = atoi(tmp); /*sscanf(tmp, "%2d", size);*/
return 0;
} | false | false | false | false | false | 0 |
pvr2_ioread_start(struct pvr2_ioread *cp)
{
int stat;
struct pvr2_buffer *bp;
if (cp->enabled) return 0;
if (!(cp->stream)) return 0;
pvr2_trace(PVR2_TRACE_START_STOP,
"/*---TRACE_READ---*/ pvr2_ioread_start id=%p",cp);
while ((bp = pvr2_stream_get_idle_buffer(cp->stream)) != NULL) {
stat = pvr2_buffer_queue(bp);
if (stat < 0) {
pvr2_trace(PVR2_TRACE_DATA_FLOW,
"/*---TRACE_READ---*/"
" pvr2_ioread_start id=%p"
" error=%d",
cp,stat);
pvr2_ioread_stop(cp);
return stat;
}
}
cp->enabled = !0;
cp->c_buf = NULL;
cp->c_data_ptr = NULL;
cp->c_data_len = 0;
cp->c_data_offs = 0;
cp->stream_running = 0;
if (cp->sync_key_len) {
pvr2_trace(PVR2_TRACE_DATA_FLOW,
"/*---TRACE_READ---*/ sync_state <== 1");
cp->sync_state = 1;
cp->sync_trashed_count = 0;
cp->sync_buf_offs = 0;
}
cp->spigot_open = 0;
return 0;
} | false | false | false | false | false | 0 |
P_maxpos(f)
FILE *f;
{
long savepos = ftell(f);
long val;
if (fseek(f, 0L, SEEK_END))
return -1;
val = ftell(f);
if (fseek(f, savepos, SEEK_SET))
return -1;
return val;
} | false | false | false | false | false | 0 |
isTree (const Tree& t, const Node& n, Tree& a)
{
if ((t->node() == n) && (t->arity() == 1)) {
a=t->branch(0);
return true;
} else {
return false;
}
} | false | false | false | false | false | 0 |
afr_fd_ctx_get (fd_t *fd, xlator_t *this)
{
uint64_t ctx = 0;
afr_fd_ctx_t *fd_ctx = NULL;
int ret = 0;
ret = fd_ctx_get (fd, this, &ctx);
if (ret < 0)
goto out;
fd_ctx = (afr_fd_ctx_t *)(long) ctx;
out:
return fd_ctx;
} | false | false | false | false | false | 0 |
THX_ck_entersub_pad_scalar(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
{
OP *pushop, *argop;
PADOFFSET padoff = NOT_IN_PAD;
SV *a0, *a1;
ck_entersub_args_proto(entersubop, namegv, ckobj);
pushop = cUNOPx(entersubop)->op_first;
if(!pushop->op_sibling) pushop = cUNOPx(pushop)->op_first;
argop = pushop->op_sibling;
if(argop->op_type != OP_CONST || argop->op_sibling->op_type != OP_CONST)
croak("bad argument expression type for pad_scalar()");
a0 = cSVOPx_sv(argop);
a1 = cSVOPx_sv(argop->op_sibling);
switch(SvIV(a0)) {
case 1: {
SV *namesv = sv_2mortal(newSVpvs("$"));
sv_catsv(namesv, a1);
padoff = pad_findmy_sv(namesv, 0);
} break;
case 2: {
char *namepv;
STRLEN namelen;
SV *namesv = sv_2mortal(newSVpvs("$"));
sv_catsv(namesv, a1);
namepv = SvPV(namesv, namelen);
padoff = pad_findmy_pvn(namepv, namelen, SvUTF8(namesv));
} break;
case 3: {
char *namepv;
SV *namesv = sv_2mortal(newSVpvs("$"));
sv_catsv(namesv, a1);
namepv = SvPV_nolen(namesv);
padoff = pad_findmy_pv(namepv, SvUTF8(namesv));
} break;
case 4: {
padoff = pad_findmy_pvs("$foo", 0);
} break;
default: croak("bad type value for pad_scalar()");
}
op_free(entersubop);
if(padoff == NOT_IN_PAD) {
return newSVOP(OP_CONST, 0, newSVpvs("NOT_IN_PAD"));
} else if(PAD_COMPNAME_FLAGS_isOUR(padoff)) {
return newSVOP(OP_CONST, 0, newSVpvs("NOT_MY"));
} else {
OP *padop = newOP(OP_PADSV, 0);
padop->op_targ = padoff;
return padop;
}
} | false | false | false | false | false | 0 |
Change()
{
if( PlanarConfiguration != 0 && PlanarConfiguration != 1 ) return false; // seriously
Output = Input;
if( Input->GetPixelFormat().GetSamplesPerPixel() != 3 )
{
return true;
}
assert( Input->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_FULL
|| Input->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_FULL_422
|| Input->GetPhotometricInterpretation() == PhotometricInterpretation::YBR_RCT
|| Input->GetPhotometricInterpretation() == PhotometricInterpretation::RGB );
if( Input->GetPlanarConfiguration() == PlanarConfiguration )
{
return true;
}
const Pixmap &image = *Input;
const unsigned int *dims = image.GetDimensions();
uint32_t len = image.GetBufferLength();
char *p = new char[len];
image.GetBuffer( p );
assert( len % 3 == 0 );
size_t framesize = dims[0] * dims[1] * 3;
assert( framesize * dims[2] == len );
char *copy = new char[len];
size_t size = framesize / 3;
if( PlanarConfiguration == 0 )
{
for(unsigned int z = 0; z < dims[2]; ++z)
{
const char *frame = p + z * framesize;
const char *r = frame + 0;
const char *g = frame + size;
const char *b = frame + size + size;
char *framecopy = copy + z * framesize;
ImageChangePlanarConfiguration::RGBPlanesToRGBPixels(framecopy, r, g, b, size);
}
}
else // User requested to do PlanarConfiguration == 1
{
assert( PlanarConfiguration == 1 );
for(unsigned int z = 0; z < dims[2]; ++z)
{
const char *frame = p + z * framesize;
char *framecopy = copy + z * framesize;
char *r = framecopy + 0;
char *g = framecopy + size;
char *b = framecopy + size + size;
ImageChangePlanarConfiguration::RGBPixelsToRGBPlanes(r, g, b, frame, size);
}
}
delete[] p;
DataElement &de = Output->GetDataElement();
de.SetByteValue( copy, len );
delete[] copy;
Output->SetPlanarConfiguration( PlanarConfiguration );
if( Input->GetTransferSyntax().IsImplicit() )
{
assert( Output->GetTransferSyntax().IsImplicit() );
}
else if( Input->GetTransferSyntax() == TransferSyntax::ExplicitVRBigEndian )
{
Output->SetTransferSyntax( TransferSyntax::ExplicitVRBigEndian );
}
else
{
Output->SetTransferSyntax( TransferSyntax::ExplicitVRLittleEndian );
}
//assert( Output->GetTransferSyntax().IsRaw() );
assert( Output->GetPhotometricInterpretation() == Input->GetPhotometricInterpretation() );
return true;
} | false | false | false | false | false | 0 |
cue_print (FILE *fp, Cd *cd)
{
Cdtext *cdtext = cd_get_cdtext(cd);
int i; /* track */
Track *track = NULL;
/* print global information */
if (NULL != cd_get_catalog(cd)) {
fprintf(fp, "CATALOG %s\n", cd_get_catalog(cd));
}
cue_print_cdtext(cdtext, fp, 0);
/* print track information */
for (i = 1; i <= cd_get_ntrack(cd); i++) {
track = cd_get_track(cd, i);
fprintf(fp, "\n");
cue_print_track(fp, track, i);
}
} | false | false | false | false | false | 0 |
gwy_plain_tool_data_switched(GwyTool *tool,
GwyDataView *data_view)
{
GwyPlainTool *plain_tool;
gwy_debug("%s %p", GWY_TOOL_GET_CLASS(tool)->title, data_view);
if (GWY_TOOL_CLASS(gwy_plain_tool_parent_class)->data_switched)
GWY_TOOL_CLASS(gwy_plain_tool_parent_class)->data_switched(tool,
data_view);
plain_tool = GWY_PLAIN_TOOL(tool);
if (data_view == plain_tool->data_view)
return;
gwy_plain_tool_selection_disconnect(plain_tool);
gwy_plain_tool_reconnect_container(plain_tool, data_view);
gwy_plain_tool_update_units(plain_tool);
if (data_view && plain_tool->layer_type) {
gwy_plain_tool_ensure_layer(plain_tool, plain_tool->layer_type);
gwy_plain_tool_selection_reconnect(plain_tool);
}
else {
gwy_object_unref(plain_tool->layer);
gwy_plain_tool_selection_changed(NULL, -1, plain_tool);
}
} | false | false | false | false | false | 0 |
bfa_ioc_debug_save_ftrc(struct bfa_ioc_s *ioc)
{
int tlen;
if (ioc->dbg_fwsave_once) {
ioc->dbg_fwsave_once = BFA_FALSE;
if (ioc->dbg_fwsave_len) {
tlen = ioc->dbg_fwsave_len;
bfa_ioc_debug_fwtrc(ioc, ioc->dbg_fwsave, &tlen);
}
}
} | false | false | false | false | false | 0 |
kmod_list_prev(const struct kmod_list *list,
const struct kmod_list *curr)
{
if (list == NULL || curr == NULL)
return NULL;
if (list == curr)
return NULL;
return container_of(curr->node.prev, struct kmod_list, node);
} | false | false | false | false | false | 0 |
netxen_issue_cmd(struct netxen_adapter *adapter, struct netxen_cmd_args *cmd)
{
u32 rsp;
u32 signature = 0;
u32 rcode = NX_RCODE_SUCCESS;
signature = NX_CDRP_SIGNATURE_MAKE(adapter->ahw.pci_func,
NXHAL_VERSION);
/* Acquire semaphore before accessing CRB */
if (netxen_api_lock(adapter))
return NX_RCODE_TIMEOUT;
NXWR32(adapter, NX_SIGN_CRB_OFFSET, signature);
NXWR32(adapter, NX_ARG1_CRB_OFFSET, cmd->req.arg1);
NXWR32(adapter, NX_ARG2_CRB_OFFSET, cmd->req.arg2);
NXWR32(adapter, NX_ARG3_CRB_OFFSET, cmd->req.arg3);
NXWR32(adapter, NX_CDRP_CRB_OFFSET, NX_CDRP_FORM_CMD(cmd->req.cmd));
rsp = netxen_poll_rsp(adapter);
if (rsp == NX_CDRP_RSP_TIMEOUT) {
printk(KERN_ERR "%s: card response timeout.\n",
netxen_nic_driver_name);
rcode = NX_RCODE_TIMEOUT;
} else if (rsp == NX_CDRP_RSP_FAIL) {
rcode = NXRD32(adapter, NX_ARG1_CRB_OFFSET);
printk(KERN_ERR "%s: failed card response code:0x%x\n",
netxen_nic_driver_name, rcode);
} else if (rsp == NX_CDRP_RSP_OK) {
cmd->rsp.cmd = NX_RCODE_SUCCESS;
if (cmd->rsp.arg2)
cmd->rsp.arg2 = NXRD32(adapter, NX_ARG2_CRB_OFFSET);
if (cmd->rsp.arg3)
cmd->rsp.arg3 = NXRD32(adapter, NX_ARG3_CRB_OFFSET);
}
if (cmd->rsp.arg1)
cmd->rsp.arg1 = NXRD32(adapter, NX_ARG1_CRB_OFFSET);
/* Release semaphore */
netxen_api_unlock(adapter);
return rcode;
} | false | false | false | false | false | 0 |
ok()
{
double weight;
QString tmp=weightLineEdit->text();
weight_sscanf(tmp, "%lf", &weight);
if(weight<0.0 || weight>100){
QMessageBox::warning(this, tr("FET information"),
tr("Invalid weight"));
return;
}
if(selectedRoomsListWidget->count()==0){
QMessageBox::warning(this, tr("FET information"),
tr("Empty list of selected rooms"));
return;
}
if(selectedRoomsListWidget->count()==1){
QMessageBox::warning(this, tr("FET information"),
tr("Only one selected room - please use constraint activity preferred room if you want a single room"));
return;
}
if(activitiesComboBox->currentIndex()<0){
QMessageBox::warning(this, tr("FET information"),
tr("Invalid selected activity"));
return;
}
int id=gt.rules.activitiesList.at(activitiesComboBox->currentIndex())->id;
QStringList roomsList;
for(int i=0; i<selectedRoomsListWidget->count(); i++)
roomsList.append(selectedRoomsListWidget->item(i)->text());
this->_ctr->weightPercentage=weight;
this->_ctr->activityId=id;
this->_ctr->roomsNames=roomsList;
gt.rules.internalStructureComputed=false;
setRulesModifiedAndOtherThings(>.rules);
this->close();
} | false | false | false | false | false | 0 |
fcgi_kill(ServerProcess *process, int sig)
{
FCGIDBG3("fcgi_kill(%ld, %d)", (long) process->pid, sig);
process->state = FCGI_VICTIM_STATE;
#ifdef WIN32
if (sig == SIGTERM)
{
SetEvent(process->terminationEvent);
}
else if (sig == SIGKILL)
{
TerminateProcess(process->handle, 1);
}
else
{
ap_assert(0);
}
#else /* !WIN32 */
if (fcgi_wrapper)
{
seteuid_root();
}
kill(process->pid, sig);
if (fcgi_wrapper)
{
seteuid_user();
}
#endif /* !WIN32 */
} | false | false | false | false | false | 0 |
remove_env(const char *str)
{
char **envp;
envp = find_env(str);
FREE(*envp);
do *envp = *(envp + 1); while (*++envp);
envsize--;
} | false | false | false | false | false | 0 |
mono_metadata_field_info_full (MonoImage *meta, guint32 index, guint32 *offset, guint32 *rva,
MonoMarshalSpec **marshal_spec, gboolean alloc_from_image)
{
MonoTableInfo *tdef;
locator_t loc;
loc.idx = index + 1;
if (meta->uncompressed_metadata)
loc.idx = search_ptr_table (meta, MONO_TABLE_FIELD_POINTER, loc.idx);
if (offset) {
tdef = &meta->tables [MONO_TABLE_FIELDLAYOUT];
loc.col_idx = MONO_FIELD_LAYOUT_FIELD;
loc.t = tdef;
if (tdef->base && mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
*offset = mono_metadata_decode_row_col (tdef, loc.result, MONO_FIELD_LAYOUT_OFFSET);
} else {
*offset = (guint32)-1;
}
}
if (rva) {
tdef = &meta->tables [MONO_TABLE_FIELDRVA];
loc.col_idx = MONO_FIELD_RVA_FIELD;
loc.t = tdef;
if (tdef->base && mono_binary_search (&loc, tdef->base, tdef->rows, tdef->row_size, table_locator)) {
/*
* LAMESPEC: There is no signature, no nothing, just the raw data.
*/
*rva = mono_metadata_decode_row_col (tdef, loc.result, MONO_FIELD_RVA_RVA);
} else {
*rva = 0;
}
}
if (marshal_spec) {
const char *p;
if ((p = mono_metadata_get_marshal_info (meta, index, TRUE))) {
*marshal_spec = mono_metadata_parse_marshal_spec_full (alloc_from_image ? meta : NULL, meta, p);
}
}
} | false | false | false | false | false | 0 |
e_preferences_window_new (gpointer shell)
{
EPreferencesWindow *window;
window = g_object_new (E_TYPE_PREFERENCES_WINDOW, NULL);
/* ideally should be an object property */
window->priv->shell = shell;
if (shell)
g_object_add_weak_pointer (shell, &window->priv->shell);
return GTK_WIDGET (window);
} | false | false | false | false | false | 0 |
check_correct_version(const string name, bool has_top, bool has_config, const vector<string>& triedLocations, ConfigCollection& coll) {
if (has_config) {
const string& val = coll.getStringValue(GLE_CONFIG_GLE, GLE_CONFIG_GLE_VERSION);
if (!str_i_equals(val.c_str(), GLEVN)) {
ostringstream out;
out << "Error: GLE's configuration file:" << endl;
out << " '" << name << "'" << endl;
out << "Is from GLE version '";
if (val == "") { out << "unknown"; } else { out << val; }
out << "' (and not '" << GLEVN << "' as espected)." << endl;
complain_about_gletop(has_top, out);
g_message(out.str().c_str());
return false;
}
} else {
ostringstream out;
out << "Error: GLE is unable to locate its configuration file." << endl;
out << " GLE searched these locations:" << endl;
for (size_t i = 0; i < triedLocations.size(); i++) {
out << " '" << triedLocations[i] << "'" << endl;
}
complain_about_gletop(has_top, out);
g_message(out.str().c_str());
return false;
}
coll.setStringValue(GLE_CONFIG_GLE, GLE_CONFIG_GLE_VERSION, GLEVN);
return true;
} | false | false | false | false | false | 0 |
AddLink( const wxString& link, uint8 category )
{
wxString uri(link);
if (link.compare(0, 7, wxT("magnet:")) == 0) {
uri = CMagnetED2KConverter(link);
if (uri.empty()) {
AddLogLineC(CFormat(_("Cannot convert magnet link to eD2k: %s")) % link);
return false;
}
}
if (uri.compare(0, 7, wxT("ed2k://")) == 0) {
return AddED2KLink(uri, category);
} else {
AddLogLineC(CFormat(_("Unknown protocol of link: %s")) % link);
return false;
}
} | false | false | false | false | false | 0 |
main(int argc, char * argv[])
{
double start = get_seconds();
printf("start: %lgs\n",start);
double lap = start;
double now;
do
{
now = get_seconds();
if((now-lap)>=1.0)
{
printf("%lgs - %lgs = %lgs\n",now,start,now-start);
lap = now-((now-start)-floor(now-start));
}
}while((now - start)<10.0);
printf("end: %lgs\n",now);
return 0;
} | false | false | false | false | false | 0 |
visitOperation(const OperationPtr& p)
{
DefinitionContextPtr dc = p->definitionContext();
assert(dc);
TypePtr ret = p->returnType();
if(ret)
{
validateSequence(dc, p->line(), ret, p->getMetaData());
}
ParamDeclList params = p->parameters();
for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
{
validateSequence(dc, (*q)->line(), (*q)->type(), (*q)->getMetaData());
}
} | false | false | false | false | false | 0 |
autoload_name(name)
char_u *name;
{
char_u *p;
char_u *scriptname;
/* Get the script file name: replace '#' with '/', append ".vim". */
scriptname = alloc((unsigned)(STRLEN(name) + 14));
if (scriptname == NULL)
return FALSE;
STRCPY(scriptname, "autoload/");
STRCAT(scriptname, name);
*vim_strrchr(scriptname, AUTOLOAD_CHAR) = NUL;
STRCAT(scriptname, ".vim");
while ((p = vim_strchr(scriptname, AUTOLOAD_CHAR)) != NULL)
*p = '/';
return scriptname;
} | false | false | false | false | false | 0 |
dir_t_extract_regular_files(dir_t *d)
{
dir_t * dd;
int i;
if (NULL == d) return(NULL);
dd = dir_t_create();
memcpy(dd->dir, d->dir, FILENAME_MAX);
for (i = 0 ; i < d->amount ; i++)
{
if (strstr(d->entry[i].name, "_rec"))
{
memcpy( (dd->entry + dd->amount), (d->entry + i), sizeof(entry_t) );
dd->amount++;
}
}
return dd;
} | false | true | false | false | false | 1 |
minimize_path(path)
char *path;
{
char *cpath = path;
char *opath = path;
if (*opath == '/')
*cpath++ = *opath++;
else
fatal("relative path encountered");
while (*opath)
{
while (*opath == '/' ||
(*opath == '.' &&
(*(opath + 1) == '/' || *(opath + 1) == '\0')))
opath++;
if (*opath == '.' && *(opath + 1) == '.' &&
(*(opath + 2) == '/' || *(opath + 2) == '\0'))
{
/* This is something like /usr/local/bin/.. and we are
going to remove the trailing .. along with the
directory that no longer meakes sense: bin. */
/* Check for /.. and do nothing if this is the case. */
if (cpath - 1 != path)
{
for (cpath -= 2; *cpath != '/'; cpath--);
cpath++;
}
opath += 2;
continue;
}
while (*opath && *opath != '/')
*cpath++ = *opath++;
if (*opath)
*cpath++ = '/';
}
if (*(cpath - 1) == '/' && cpath - path > 1)
cpath--;
*cpath = '\0';
return path;
} | false | false | false | false | true | 1 |
i40e_disable_vf_mappings(struct i40e_vf *vf)
{
struct i40e_pf *pf = vf->pf;
struct i40e_hw *hw = &pf->hw;
int i;
/* disable qp mappings */
wr32(hw, I40E_VPLAN_MAPENA(vf->vf_id), 0);
for (i = 0; i < I40E_MAX_VSI_QP; i++)
wr32(hw, I40E_VPLAN_QTABLE(i, vf->vf_id),
I40E_QUEUE_END_OF_LIST);
i40e_flush(hw);
} | false | false | false | false | false | 0 |
gimple_divmod_values_to_profile (gimple stmt, histogram_values *values)
{
tree lhs, divisor, op0, type;
histogram_value hist;
if (gimple_code (stmt) != GIMPLE_ASSIGN)
return;
lhs = gimple_assign_lhs (stmt);
type = TREE_TYPE (lhs);
if (!INTEGRAL_TYPE_P (type))
return;
switch (gimple_assign_rhs_code (stmt))
{
case TRUNC_DIV_EXPR:
case TRUNC_MOD_EXPR:
divisor = gimple_assign_rhs2 (stmt);
op0 = gimple_assign_rhs1 (stmt);
VEC_reserve (histogram_value, heap, *values, 3);
if (is_gimple_reg (divisor))
/* Check for the case where the divisor is the same value most
of the time. */
VEC_quick_push (histogram_value, *values,
gimple_alloc_histogram_value (cfun,
HIST_TYPE_SINGLE_VALUE,
stmt, divisor));
/* For mod, check whether it is not often a noop (or replaceable by
a few subtractions). */
if (gimple_assign_rhs_code (stmt) == TRUNC_MOD_EXPR
&& TYPE_UNSIGNED (type))
{
tree val;
/* Check for a special case where the divisor is power of 2. */
VEC_quick_push (histogram_value, *values,
gimple_alloc_histogram_value (cfun, HIST_TYPE_POW2,
stmt, divisor));
val = build2 (TRUNC_DIV_EXPR, type, op0, divisor);
hist = gimple_alloc_histogram_value (cfun, HIST_TYPE_INTERVAL,
stmt, val);
hist->hdata.intvl.int_start = 0;
hist->hdata.intvl.steps = 2;
VEC_quick_push (histogram_value, *values, hist);
}
return;
default:
return;
}
} | false | false | false | false | false | 0 |
fwrr_get_srv(struct server *s)
{
struct proxy *p = s->proxy;
struct fwrr_group *grp = (s->flags & SRV_F_BACKUP) ?
&p->lbprm.fwrr.bck :
&p->lbprm.fwrr.act;
if (s->lb_tree == grp->init) {
fwrr_get_srv_init(s);
}
else if (s->lb_tree == grp->next) {
fwrr_get_srv_next(s);
}
else if (s->lb_tree == NULL) {
fwrr_get_srv_down(s);
}
} | false | false | false | false | false | 0 |
add_revision_panel (GitgWindow *window,
GType panel_type)
{
GitgRevisionPanel *panel;
gchar *label;
GtkWidget *label_widget;
GtkWidget *page;
g_return_if_fail (g_type_is_a (panel_type, GITG_TYPE_REVISION_PANEL));
panel = g_object_new (panel_type, NULL);
gitg_revision_panel_initialize (panel, window);
window->priv->revision_panels = g_slist_append (window->priv->revision_panels,
panel);
if (GITG_IS_ACTIVATABLE (panel))
{
window->priv->activatables = g_slist_append (window->priv->activatables,
g_object_ref (panel));
}
label = gitg_revision_panel_get_label (panel);
label_widget = gtk_label_new (label);
gtk_widget_show (label_widget);
g_free (label);
page = gitg_revision_panel_get_panel (panel);
gtk_widget_show (page);
g_signal_connect (page,
"map",
G_CALLBACK (on_revision_panel_mapped),
window);
gtk_notebook_append_page (window->priv->notebook_revision,
page,
label_widget);
} | false | false | false | false | false | 0 |
handleRecord(const int groupcode,
const dimeParam ¶m,
dimeMemHandler * const memhandler)
{
switch(groupcode) {
case 210:
case 220:
case 230:
this->extrusionDir[(groupcode-210)/10] = param.double_data;
return true;
case 39:
this->thickness = param.double_data;
return true;
}
return dimeFaceEntity::handleRecord(groupcode, param, memhandler);
} | false | false | false | false | false | 0 |
editarch(no)
int no;
{
archive_t list;
char *cp;
int n;
if (no < maxarchive) {
list.ext = Xstrdup(archivelist[no].ext);
list.flags = archivelist[no].flags;
}
else {
if (!(cp = inputcuststr(EXTAR_K, 1, NULL, -1))) return(0);
list.ext = getext(cp, &(list.flags));
Xfree(cp);
if (!(list.ext[0]) || !(list.ext[1])) {
Xfree(list.ext);
return(0);
}
for (no = 0; no < maxarchive; no++) {
n = extcmp(list.ext, list.flags,
archivelist[no].ext, archivelist[no].flags, 1);
if (!n) break;
}
# ifndef DEP_DYNAMICLIST
if (no >= MAXARCHIVETABLE) {
warning(0, OVERF_K);
return(0);
}
# endif
}
for (;;) {
if (no < maxarchive) {
list.p_comm = archivelist[no].p_comm;
list.u_comm = archivelist[no].u_comm;
}
else {
list.p_comm = list.u_comm = NULL;
}
list.p_comm = inputcuststr(PACKC_K, 0, list.p_comm, HST_COMM);
if (!(list.p_comm)) {
Xfree(list.ext);
return(0);
}
else if (!*(list.p_comm)) {
Xfree(list.p_comm);
list.p_comm = NULL;
}
list.u_comm = inputcuststr(UPCKC_K, 0, list.u_comm, HST_COMM);
if (!(list.u_comm)) {
Xfree(list.p_comm);
continue;
}
else if (!*(list.u_comm)) {
Xfree(list.u_comm);
list.u_comm = NULL;
}
break;
}
if (!(list.p_comm) && !(list.u_comm)) {
Xfree(list.ext);
if (no >= maxarchive) return(0);
if (!yesno(DLAOK_K, archivelist[no].ext)) return(0);
deletearch(no);
return(1);
}
addarch(no, &list);
return(1);
} | false | false | false | false | false | 0 |
evas_debug_generic(const char *str)
{
if (!_evas_debug_init)
{
_evas_debug_init_from_env();
}
if ((_evas_debug_show == _EVAS_DEBUG_SHOW) ||
(_evas_debug_show == _EVAS_DEBUG_DEFAULT))
CRIT("%s", str);
if (_evas_debug_abort) abort();
} | false | false | false | false | false | 0 |
_wrap_svn_fs_change_txn_prop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
PyObject *resultobj = 0;
svn_fs_txn_t *arg1 = (svn_fs_txn_t *) 0 ;
char *arg2 = (char *) 0 ;
svn_string_t *arg3 = (svn_string_t *) 0 ;
apr_pool_t *arg4 = (apr_pool_t *) 0 ;
apr_pool_t *_global_pool = NULL ;
PyObject *_global_py_pool = NULL ;
svn_string_t value3 ;
PyObject * obj0 = 0 ;
PyObject * obj2 = 0 ;
PyObject * obj3 = 0 ;
svn_error_t *result = 0 ;
if (svn_swig_py_get_pool_arg(args, SWIGTYPE_p_apr_pool_t,
&_global_py_pool, &_global_pool))
SWIG_fail;
arg4 = _global_pool;
if (!PyArg_ParseTuple(args,(char *)"OsO|O:svn_fs_change_txn_prop",&obj0,&arg2,&obj2,&obj3)) SWIG_fail;
{
arg1 = (svn_fs_txn_t *)svn_swig_MustGetPtr(obj0, SWIGTYPE_p_svn_fs_txn_t, svn_argnum_obj0);
if (PyErr_Occurred()) {
SWIG_fail;
}
}
{
if (obj2 == Py_None)
arg3 = NULL;
else {
if (!PyString_Check(obj2)) {
PyErr_SetString(PyExc_TypeError, "not a string");
SWIG_fail;
}
value3.data = PyString_AS_STRING(obj2);
value3.len = PyString_GET_SIZE(obj2);
arg3 = &value3;
}
}
if (obj3) {
/* Verify that the user supplied a valid pool */
if (obj3 != Py_None && obj3 != _global_py_pool) {
SWIG_Python_TypeError(SWIG_TypePrettyName(SWIGTYPE_p_apr_pool_t), obj3);
SWIG_arg_fail(svn_argnum_obj3);
SWIG_fail;
}
}
{
svn_swig_py_release_py_lock();
result = (svn_error_t *)svn_fs_change_txn_prop(arg1,(char const *)arg2,(struct svn_string_t const *)arg3,arg4);
svn_swig_py_acquire_py_lock();
}
{
if (result != NULL) {
if (result->apr_err != SVN_ERR_SWIG_PY_EXCEPTION_SET)
svn_swig_py_svn_exception(result);
else
svn_error_clear(result);
SWIG_fail;
}
Py_INCREF(Py_None);
resultobj = Py_None;
}
{
Py_XDECREF(_global_py_pool);
}
return resultobj;
fail:
{
Py_XDECREF(_global_py_pool);
}
return NULL;
} | false | false | false | false | false | 0 |
mx_dialog_new_frame_cb (ClutterTimeline *timeline,
gint msecs,
ClutterActor *self)
{
MxDialog *frame = MX_DIALOG (self);
MxDialogPrivate *priv = frame->priv;
ClutterActor *parent = clutter_actor_get_parent (self);
gfloat opacity = clutter_alpha_get_alpha (priv->alpha);
priv->zoom = 1.0f + (1.f - opacity) / 2.f;
clutter_actor_set_opacity (self, (guint8)(opacity * 255.f));
/* Queue a redraw on the parent, as having our hidden flag set will
* short-circuit the redraw queued on ourselves via set_opacity.
*/
if (parent)
clutter_actor_queue_redraw (parent);
} | false | false | false | false | false | 0 |
sumWeights() const {
return !extended()
? (weight_t)size()
: std::max(extra_.ext->sumWeights, weight_t(0));
} | false | false | false | false | false | 0 |
smart_socket_close(asocket *s)
{
D("SS(%d): closed\n", s->id);
if(s->pkt_first){
put_apacket(s->pkt_first);
}
if(s->peer) {
s->peer->peer = 0;
s->peer->close(s->peer);
s->peer = 0;
}
free(s);
} | false | false | false | false | false | 0 |
file_field_callback(Widget gw,
XtPointer client_data,
XtPointer call_data)
{
FileSelWidget w = (FileSelWidget)client_data;
char *buffer = (char *)call_data;
long n = ScrollableGetVSize(w->filesel.list);
if (buffer) {
long i;
for (i = 0 ; i < n ; i++) {
char *item = ScrListGetString(w->filesel.list, i);
if (!item)
break;
if (strcmp(item, buffer) == 0) {
Pixmap pixmap = ScrListGetPixmap(w->filesel.list, i);
if (pixmap == w->filesel.pixmap[FileTypeDirectory]) {
if (change_dir(w, buffer) < 0)
XBell(XtDisplay(w), 0);
} else if (pixmap == w->filesel.pixmap[FileTypeDotdot]) {
if (change_dir(w, NULL) < 0)
XBell(XtDisplay(w), 0);
} else
call_callbacks(w, i);
return;
}
}
}
call_callbacks(w, -1);
} | false | false | false | false | false | 0 |
cdrom_mmc3_profile(struct cdrom_device_info *cdi)
{
struct packet_command cgc;
char buffer[32];
int ret, mmc3_profile;
init_cdrom_command(&cgc, buffer, sizeof(buffer), CGC_DATA_READ);
cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
cgc.cmd[1] = 0;
cgc.cmd[2] = cgc.cmd[3] = 0; /* Starting Feature Number */
cgc.cmd[8] = sizeof(buffer); /* Allocation Length */
cgc.quiet = 1;
if ((ret = cdi->ops->generic_packet(cdi, &cgc)))
mmc3_profile = 0xffff;
else
mmc3_profile = (buffer[6] << 8) | buffer[7];
cdi->mmc3_profile = mmc3_profile;
} | true | true | false | false | false | 1 |
match_esc(const char *mask, const char *name)
{
const unsigned char *m = (const unsigned char *) mask;
const unsigned char *n = (const unsigned char *) name;
const unsigned char *ma = NULL;
const unsigned char *na = (const unsigned char *) name;
assert(mask != NULL);
assert(name != NULL);
while (1)
{
if (*m == '*')
{
/*
* XXX - shouldn't need to spin here, the mask should have been
* collapsed before match is called
*/
while (*m == '*')
m++;
ma = m;
na = n;
}
if (!*m)
{
if (!*n)
return 1;
if (!ma)
return 0;
for (m--; (m > (const unsigned char*) mask) && (*m == '?'); m--)
;
if (*m == '*')
return 1;
m = ma;
n = ++na;
}
else if (!*n)
{
/*
* XXX - shouldn't need to spin here, the mask should have been
* collapsed before match is called
*/
while (*m == '*')
m++;
return (*m == 0);
}
if (*m != '?' && (*m != '#' || IsDigit(*n)))
{
if (*m == '\\')
if (!*++m)
return 0;
if (ToLower(*m) != ToLower(*n))
{
if (!ma)
return 0;
m = ma;
n = ++na;
}
else
m++, n++;
}
else
m++, n++;
}
return 0;
} | false | false | false | false | false | 0 |
cmds_pasv(CONTEXT *ctx, char *arg)
{
u_int32_t addr;
u_int16_t port;
char str[1024], *p, *q;
FILE *fp;
int incr;
if (ctx == NULL) /* Basic sanity check */
misc_die(FL, "cmds_pasv: ?ctx?");
arg = arg; /* Calm down picky compilers */
/*
** If we already have a listening socket, kill it
*/
if (ctx->cli_data != NULL) {
syslog_write(U_WRN, "killing old PASV socket for %s",
ctx->cli_ctrl->peer);
socket_kill(ctx->cli_data);
ctx->cli_data = NULL;
}
/*
** should we bind a rand(port-range) or increment?
*/
incr = !config_bool(NULL,"SockBindRand", 0);
/*
** Open a socket that is good for listening
**
** TransProxy mode: check if we can use our real
** ip instead of the server's one as our local ip,
** we bind the socket/ports to.
*/
addr = INADDR_ANY;
if(config_bool(NULL, "AllowTransProxy", 0)) {
addr = config_addr(NULL, "Listen", (u_int32_t)INADDR_ANY);
}
if(INADDR_ANY == addr) {
addr = socket_sck2addr(ctx->cli_ctrl->sock, LOC_END, NULL);
}
if ((port = socket_d_listen(addr, ctx->pas_lrng, ctx->pas_urng,
&(ctx->cli_data), "Cli-Data", incr)) == 0)
{
syslog_error("Cli-Data: can't bind to %s:%d-%d for %s",
socket_addr2str(addr), (int) ctx->pas_lrng,
(int) ctx->pas_urng, ctx->cli_ctrl->peer);
client_respond(425, NULL, "Can't open data connection");
return;
}
/*
** Consider address "masquerading" (e.g. within a
** Cisco LocalDirector environment). In this case
** we have to present a different logical address
** to the client. The router will re-translate.
*/
p = config_str(NULL, "TranslatedAddress", NULL);
if (p != NULL) {
if (*p == '/') {
if ((fp = fopen(p, "r")) != NULL) {
while (fgets(str, sizeof(str),
fp) != NULL) {
q = misc_strtrim(str);
if (q == NULL || *q == '#' ||
*q == '\0')
continue;
addr = socket_str2addr(q, addr);
break;
}
fclose(fp);
} else {
syslog_write(U_WRN,
"can't open NAT file '%*s'",
MAX_PATH_SIZE, p);
}
} else
addr = socket_str2addr(p, addr);
}
/*
** Tell the user where we are listening
*/
client_respond(227, NULL,
"Entering Passive Mode (%d,%d,%d,%d,%d,%d)",
(int) ((addr >> 24) & 0xff),
(int) ((addr >> 16) & 0xff),
(int) ((addr >> 8) & 0xff),
(int) ( addr & 0xff),
(int) ((port >> 8) & 0xff),
(int) ( port & 0xff));
syslog_write(U_INF, "PASV set to %s:%d for %s",
socket_addr2str(addr), (int) port,
ctx->cli_ctrl->peer);
ctx->cli_mode = MOD_PAS_FTP;
} | false | false | false | false | false | 0 |
_k_resolveSymLink(const QString &filename)
{
QString resolved = filename;
QString tmp = QFile::symLinkTarget(filename);
while (!tmp.isEmpty()) {
resolved = tmp;
tmp = QFile::symLinkTarget(resolved);
}
return resolved;
} | false | false | false | false | false | 0 |
read_buffer(const string & buffer)
{
xmlDocPtr doc;
_filename = "";
if (_root) {
delete _root;
_root = 0;
}
doc = xmlParseMemory((char *) buffer.c_str(), buffer.length());
if (!doc) {
return false;
}
_root = readnode(xmlDocGetRootElement(doc));
xmlFreeDoc(doc);
return true;
} | false | false | false | false | false | 0 |
ql_process_chip_ae_intr(struct ql_adapter *qdev,
struct ib_ae_iocb_rsp *ib_ae_rsp)
{
switch (ib_ae_rsp->event) {
case MGMT_ERR_EVENT:
netif_err(qdev, rx_err, qdev->ndev,
"Management Processor Fatal Error.\n");
ql_queue_fw_error(qdev);
return;
case CAM_LOOKUP_ERR_EVENT:
netdev_err(qdev->ndev, "Multiple CAM hits lookup occurred.\n");
netdev_err(qdev->ndev, "This event shouldn't occur.\n");
ql_queue_asic_error(qdev);
return;
case SOFT_ECC_ERROR_EVENT:
netdev_err(qdev->ndev, "Soft ECC error detected.\n");
ql_queue_asic_error(qdev);
break;
case PCI_ERR_ANON_BUF_RD:
netdev_err(qdev->ndev, "PCI error occurred when reading "
"anonymous buffers from rx_ring %d.\n",
ib_ae_rsp->q_id);
ql_queue_asic_error(qdev);
break;
default:
netif_err(qdev, drv, qdev->ndev, "Unexpected event %d.\n",
ib_ae_rsp->event);
ql_queue_asic_error(qdev);
break;
}
} | false | false | false | false | false | 0 |
gda_attributes_manager_foreach (GdaAttributesManager *mgr, gpointer ptr,
GdaAttributesManagerFunc func, gpointer data)
{
ObjAttrs *objattrs;
g_return_if_fail (func);
g_return_if_fail (ptr);
gda_mutex_lock (mgr->mutex);
objattrs = g_hash_table_lookup (mgr->obj_hash, ptr);
if (objattrs) {
FData fdata;
fdata.func = func;
fdata.data = data;
g_hash_table_foreach (objattrs->values_hash, (GHFunc) foreach_foreach_func, &fdata);
}
gda_mutex_unlock (mgr->mutex);
} | false | false | false | false | false | 0 |
ncEqualPartial(char* str1, char* str2)
{
int i;
int len1 = strlen(str1);
int len2 = strlen(str2);
if (len1 < len2)
return false;
for (i = 0; i < len2; i++)
if ( toupper(str1[i]) != toupper(str2[i]) )
return false;
return true;
} | false | false | false | false | false | 0 |
say_enumeration_full(struct ast_channel *chan, int num, const char *ints, const char *language, const char *options, int audiofd, int ctrlfd)
{
if (!strncasecmp(language, "en", 2)) { /* English syntax */
return ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd);
} else if (!strncasecmp(language, "da", 2)) { /* Danish syntax */
return ast_say_enumeration_full_da(chan, num, ints, language, options, audiofd, ctrlfd);
} else if (!strncasecmp(language, "de", 2)) { /* German syntax */
return ast_say_enumeration_full_de(chan, num, ints, language, options, audiofd, ctrlfd);
} else if (!strncasecmp(language, "he", 2)) { /* Hebrew syntax */
return ast_say_enumeration_full_he(chan, num, ints, language, options, audiofd, ctrlfd);
} else if (!strncasecmp(language, "vi", 2)) { /* Vietnamese syntax */
return ast_say_enumeration_full_vi(chan, num, ints, language, audiofd, ctrlfd);
}
/* Default to english */
return ast_say_enumeration_full_en(chan, num, ints, language, audiofd, ctrlfd);
} | false | false | false | false | false | 0 |
moveResize(int x, int y,
unsigned int width, unsigned int height) {
if (width != m_window.width() ||
height != m_window.height()) {
m_window.moveResize(x, y, width, height);
if (m_num_visible_clients)
rearrangeClients();
resizeSig().emit();
} else {
move(x, y);
}
} | false | false | false | false | false | 0 |
smack_inode_alloc_security(struct inode *inode)
{
struct smack_known *skp = smk_of_current();
inode->i_security = new_inode_smack(skp);
if (inode->i_security == NULL)
return -ENOMEM;
return 0;
} | false | false | false | false | false | 0 |
_mpd_apply_round_excess(mpd_t *dec, mpd_uint_t rnd, const mpd_context_t *ctx,
uint32_t *status)
{
if (_mpd_rnd_incr(dec, rnd, ctx)) {
mpd_uint_t carry = _mpd_baseincr(dec->data, dec->len);
if (carry) {
if (!mpd_qresize(dec, dec->len+1, status)) {
return;
}
dec->data[dec->len] = 1;
dec->len += 1;
}
mpd_setdigits(dec);
}
} | false | false | false | false | false | 0 |
ParseGetElementPtr(Instruction *&Inst, PerFunctionState &PFS) {
Value *Ptr, *Val; LocTy Loc, EltLoc;
bool InBounds = EatIfPresent(lltok::kw_inbounds);
if (ParseTypeAndValue(Ptr, Loc, PFS)) return true;
if (!Ptr->getType()->isPointerTy())
return Error(Loc, "base of getelementptr must be a pointer");
SmallVector<Value*, 16> Indices;
bool AteExtraComma = false;
while (EatIfPresent(lltok::comma)) {
if (Lex.getKind() == lltok::MetadataVar) {
AteExtraComma = true;
break;
}
if (ParseTypeAndValue(Val, EltLoc, PFS)) return true;
if (!Val->getType()->isIntegerTy())
return Error(EltLoc, "getelementptr index must be an integer");
Indices.push_back(Val);
}
if (!GetElementPtrInst::getIndexedType(Ptr->getType(), Indices))
return Error(Loc, "invalid getelementptr indices");
Inst = GetElementPtrInst::Create(Ptr, Indices);
if (InBounds)
cast<GetElementPtrInst>(Inst)->setIsInBounds(true);
return AteExtraComma ? InstExtraComma : InstNormal;
} | false | false | false | false | false | 0 |
SetMediaSource(MediaSource msource)
// Sets value of PCL::mediasource and associated counter msrccount
{
#if defined(DEBUG) && (DBG_MASK & DBG_LVL1)
DBG1("Setting MediaSource to ");
switch(msource)
{
case sourceTray1: DBG1("Tray1\n"); break;
case sourceTray2: DBG1("Tray2\n"); break;
case sourceManual: DBG1("Manual\n"); break;
case sourceManualEnv: DBG1("ManualEnv\n"); break;
case sourceTrayAuto: DBG1("AutoTray\n"); break;
case sourceDuplexerNHagakiFeed: DBG1("HagakiTray\n"); break;
case sourceBanner: DBG1("Bannerpaper\n"); break;
case sourceTrayCDDVD: DBG1("CD/DVD Tray\n"); break;
default: DBG1("<out of range, using> Tray1\n"); break;
}
#endif
ASSERT( (msource==sourceTray1) || (msource==sourceManual) ||
(msource==sourceTray2) || (msource==sourceDuplexerNHagakiFeed) ||
(msource==sourceManualEnv) || (msource==sourceTrayAuto) ||
(msource == sourceOptionalEnv) || (msource == sourceBanner) ||
(msource == sourceTrayCDDVD));
if( (msource!=sourceTray1) && (msource!=sourceManual) &&
(msource!=sourceTray2) && (msource!=sourceDuplexerNHagakiFeed) &&
(msource!=sourceManualEnv) && (msource!=sourceTrayAuto) &&
(msource != sourceOptionalEnv) && (msource != sourceBanner) &&
(msource != sourceTrayCDDVD))
msource=sourceTray1;
if (thePrinter != NULL)
{
if (msource==sourceDuplexerNHagakiFeed && !thePrinter->HagakiFeedPresent(TRUE))
{
msource=sourceTray1;
}
}
msrccount=EscAmplCopy((BYTE*)mediasource,msource,'H');
} | false | false | false | false | false | 0 |
removeFromIndex(Archive* arch)
{
// Delete indexes
ResourceLocationIndex::iterator rit, ritend;
ritend = this->resourceIndexCaseInsensitive.end();
for (rit = this->resourceIndexCaseInsensitive.begin(); rit != ritend;)
{
if (rit->second == arch)
{
ResourceLocationIndex::iterator del = rit++;
this->resourceIndexCaseInsensitive.erase(del);
}
else
{
++rit;
}
}
ritend = this->resourceIndexCaseSensitive.end();
for (rit = this->resourceIndexCaseSensitive.begin(); rit != ritend;)
{
if (rit->second == arch)
{
ResourceLocationIndex::iterator del = rit++;
this->resourceIndexCaseSensitive.erase(del);
}
else
{
++rit;
}
}
} | false | false | false | false | false | 0 |
read_the_file()
{
const char *filename = m_filename.c_str();
ifstream f(filename);
if (!f) return;
string line_text;
while (!f.eof()) {
string line_str;
getline(f,line_text);
line_str = line_text;
history.push_back(line_str);
}
m_file_entries = history.size();
m_current = m_file_entries;
} | false | false | false | false | false | 0 |
new_line(size_t **line_starts, size_t **line_lengths,
size_t *n_lines, size_t *cur_line,
size_t start, size_t len)
{
if (*cur_line == *n_lines) {
/* this number is not arbitrary: it's the height of a "standard" term */
(*n_lines) += 24;
*line_starts = mem_realloc(*line_starts,
*n_lines * sizeof **line_starts);
*line_lengths = mem_realloc(*line_lengths,
*n_lines * sizeof **line_lengths);
}
(*line_starts)[*cur_line] = start;
(*line_lengths)[*cur_line] = len;
(*cur_line)++;
} | false | false | false | false | false | 0 |
optval_default(p, varp)
struct vimoption *p;
char_u *varp;
{
int dvi;
if (varp == NULL)
return TRUE; /* hidden option is always at default */
dvi = ((p->flags & P_VI_DEF) || p_cp) ? VI_DEFAULT : VIM_DEFAULT;
if (p->flags & P_NUM)
return (*(long *)varp == (long)(long_i)p->def_val[dvi]);
if (p->flags & P_BOOL)
/* the cast to long is required for Manx C, long_i is
* needed for MSVC */
return (*(int *)varp == (int)(long)(long_i)p->def_val[dvi]);
/* P_STRING */
return (STRCMP(*(char_u **)varp, p->def_val[dvi]) == 0);
} | false | false | false | false | false | 0 |
new_pixbuf_from_widget (GtkWidget *widget)
{
GtkWidget *window;
GdkPixbuf *pixbuf;
GtkRequisition requisition;
GtkAllocation allocation;
GdkPixmap *pixmap;
GdkVisual *visual;
gint icon_width;
gint icon_height;
icon_width = DEFAULT_ICON_WIDTH;
if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_default (),
GTK_ICON_SIZE_LARGE_TOOLBAR,
NULL,
&icon_height))
{
icon_height = DEFAULT_ICON_HEIGHT;
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_add (GTK_CONTAINER (window), widget);
gtk_widget_realize (window);
gtk_widget_show (widget);
gtk_widget_realize (widget);
gtk_widget_map (widget);
/* Gtk will never set the width or height of a window to 0. So setting the width to
* 0 and than getting it will provide us with the minimum width needed to render
* the icon correctly, without any additional window background noise.
* This is needed mostly for pixmap based themes.
*/
gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
gtk_widget_size_request (window, &requisition);
allocation.x = 0;
allocation.y = 0;
allocation.width = icon_width;
allocation.height = icon_height;
gtk_widget_size_allocate (window, &allocation);
gtk_widget_size_request (window, &requisition);
/* Create a pixmap */
visual = gtk_widget_get_visual (window);
pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, gdk_visual_get_best_depth());
gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
/* Draw the window */
gtk_widget_ensure_style (window);
g_assert (window->style);
g_assert (window->style->font_desc);
fake_expose_widget (window, pixmap);
fake_expose_widget (widget, pixmap);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
return pixbuf;
} | false | false | false | false | false | 0 |
AssembleNthVolume ( int n )
{
this->FileNames.resize( 0 );
// int nFiles = this->AllFileNames.size(); UNUSED
unsigned int nSlices = this->GetNumberOfSliceLocation();
for (unsigned int k = 0; k < nSlices; k++)
{
const char* name = GetNthFileName( 0, -1, -1, -1, 0, k, 0, n );
if (name == NULL)
{
continue;
}
std::string nameInString (name);
this->FileNames.push_back(nameInString);
}
} | false | false | false | false | false | 0 |
newSpace(int32 size)
{
static int32 oldSize = 0; /* must be static */
static char *oldSpace = NULL; /* must be static */
if (size >= oldSize)
{
if (oldSpace != NULL)
HDfree(oldSpace);
if ((oldSpace = (char *) HDmalloc((uint32) size)) == NULL)
{
puts("Out of memory. Abort.");
exit(1);
}
oldSize = size;
}
return oldSpace;
} | true | true | false | false | true | 1 |
apply_ekiga_out_page (EkigaAssistant *assistant)
{
/* Some specific Opal stuff for the Ekiga.net account */
Opal::AccountPtr account = assistant->priv->bank->find_account ("sip.diamondcard.us");
bool new_account = !account;
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (assistant->priv->skip_ekiga_out))) {
if (new_account)
assistant->priv->bank->new_account (Opal::Account::DiamondCard,
gtk_entry_get_text (GTK_ENTRY (assistant->priv->dusername)),
gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
else
account->set_authentication_settings (gtk_entry_get_text (GTK_ENTRY (assistant->priv->dusername)),
gtk_entry_get_text (GTK_ENTRY (assistant->priv->dpassword)));
}
} | false | false | false | false | false | 0 |
getNextLine(std::string& line) {
//try and fix the stream
if(isFinished()) stream->clear();
std::getline(*stream, line);
//remove carriage returns
if (line.size() > 0 && line[line.size()-1] == '\r') {
line.resize(line.size() - 1);
}
if(stream->fail()) {
return false;
}
current_percent = (float) stream->tellg() / file_size;
//debugLog("current_percent = %.2f\n", current_percent);
return true;
} | false | false | false | false | false | 0 |
get_const_charge_current(struct smb347_charger *smb)
{
int ret, intval;
unsigned int v;
if (!smb347_is_ps_online(smb))
return -ENODATA;
ret = regmap_read(smb->regmap, STAT_B, &v);
if (ret < 0)
return ret;
/*
* The current value is composition of FCC and PCC values
* and we can detect which table to use from bit 5.
*/
if (v & 0x20) {
intval = hw_to_current(fcc_tbl, ARRAY_SIZE(fcc_tbl), v & 7);
} else {
v >>= 3;
intval = hw_to_current(pcc_tbl, ARRAY_SIZE(pcc_tbl), v & 7);
}
return intval;
} | false | false | false | false | false | 0 |
SetNumberOfContours(const int number)
{
int currentNumber = this->Contours->GetMaxId()+1;
int n = ( number < 0 ? 0 : number);
int i;
double *oldValues = NULL;
if ( n != currentNumber )
{
this->Modified();
// Keep a copy of the old values
if ( currentNumber > 0 )
{
oldValues = new double[currentNumber];
for ( i = 0; i < currentNumber; i++ )
{
oldValues[i] = this->Contours->GetValue(i);
}
}
this->Contours->SetNumberOfValues(n);
// Copy them back in since the array may have been re-allocated
if ( currentNumber > 0 )
{
int limit = (currentNumber < n)?(currentNumber):(n);
for ( i = 0; i < limit; i++ )
{
this->Contours->SetValue( i, oldValues[i] );
}
delete [] oldValues;
}
}
// Set the new contour values to 0.0
if (n > currentNumber)
{
for ( i = currentNumber; i < n; i++ )
{
this->Contours->SetValue (i, 0.0);
}
}
} | false | false | false | false | false | 0 |
libbfio_handle_free(
libbfio_handle_t **handle,
libcerror_error_t **error )
{
libbfio_internal_handle_t *internal_handle = NULL;
static char *function = "libbfio_handle_free";
int is_open = 0;
int result = 1;
if( handle == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid handle.",
function );
return( -1 );
}
if( *handle != NULL )
{
internal_handle = (libbfio_internal_handle_t *) *handle;
*handle = NULL;
is_open = internal_handle->is_open(
internal_handle->io_handle,
error );
if( is_open == -1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_IO,
LIBCERROR_IO_ERROR_OPEN_FAILED,
"%s: unable to determine if handle is open.",
function );
result = -1;
}
else if( is_open != 0 )
{
if( internal_handle->close(
internal_handle->io_handle,
error ) != 0 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_IO,
LIBCERROR_IO_ERROR_CLOSE_FAILED,
"%s: unable to close handle.",
function );
result = -1;
}
}
if( ( internal_handle->flags & LIBBFIO_FLAG_IO_HANDLE_MANAGED ) != 0 )
{
if( internal_handle->io_handle != NULL )
{
if( internal_handle->free_io_handle == NULL )
{
memory_free(
internal_handle->io_handle );
}
else if( internal_handle->free_io_handle(
&( internal_handle->io_handle ),
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
"%s: unable to free IO handle.",
function );
result = -1;
}
}
}
if( internal_handle->offsets_read != NULL )
{
if( libcdata_range_list_free(
&( internal_handle->offsets_read ),
NULL,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_FINALIZE_FAILED,
"%s: unable to free read offsets list.",
function );
result = -1;
}
}
memory_free(
internal_handle );
}
return( result );
} | false | false | false | false | false | 0 |
build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
struct ib_recv_wr *wr)
{
int i;
u32 pbl_addr;
u32 pbl_offset;
/*
* The T3 HW requires the PBL in the HW recv descriptor to reference
* a PBL entry. So we allocate the max needed PBL memory here and pass
* it to the uP in the recv WR. The uP will build the PBL and setup
* the HW recv descriptor.
*/
pbl_addr = cxio_hal_pblpool_alloc(&qhp->rhp->rdev, T3_STAG0_PBL_SIZE);
if (!pbl_addr)
return -ENOMEM;
/*
* Compute the 8B aligned offset.
*/
pbl_offset = (pbl_addr - qhp->rhp->rdev.rnic_info.pbl_base) >> 3;
wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
for (i = 0; i < wr->num_sge; i++) {
/*
* Use a 128MB page size. This and an imposed 128MB
* sge length limit allows us to require only a 2-entry HW
* PBL for each SGE. This restriction is acceptable since
* since it is not possible to allocate 128MB of contiguous
* DMA coherent memory!
*/
if (wr->sg_list[i].length > T3_STAG0_MAX_PBE_LEN)
return -EINVAL;
wqe->recv.pagesz[i] = T3_STAG0_PAGE_SHIFT;
/*
* T3 restricts a recv to all zero-stag or all non-zero-stag.
*/
if (wr->sg_list[i].lkey != 0)
return -EINVAL;
wqe->recv.sgl[i].stag = 0;
wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_offset);
pbl_offset += 2;
}
for (; i < T3_MAX_SGE; i++) {
wqe->recv.pagesz[i] = 0;
wqe->recv.sgl[i].stag = 0;
wqe->recv.sgl[i].len = 0;
wqe->recv.sgl[i].to = 0;
wqe->recv.pbl_addr[i] = 0;
}
qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
qhp->wq.rq_size_log2)].wr_id = wr->wr_id;
qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
qhp->wq.rq_size_log2)].pbl_addr = pbl_addr;
return 0;
} | false | false | false | false | false | 0 |
pixbuf_flip_row (GdkPixbuf *pixbuf, guchar *ph)
{
guchar *p, *s;
guchar tmp;
gint count;
p = ph;
s = p + pixbuf->n_channels * (pixbuf->width - 1);
while (p < s) {
for (count = pixbuf->n_channels; count > 0; count--, p++, s++) {
tmp = *p;
*p = *s;
*s = tmp;
}
s -= 2 * pixbuf->n_channels;
}
} | false | false | false | false | false | 0 |
likely_spilled_retval_p (rtx insn)
{
rtx use = BB_END (this_basic_block);
rtx reg, p;
unsigned regno, nregs;
/* We assume here that no machine mode needs more than
32 hard registers when the value overlaps with a register
for which TARGET_FUNCTION_VALUE_REGNO_P is true. */
unsigned mask;
struct likely_spilled_retval_info info;
if (!NONJUMP_INSN_P (use) || GET_CODE (PATTERN (use)) != USE || insn == use)
return 0;
reg = XEXP (PATTERN (use), 0);
if (!REG_P (reg) || !targetm.calls.function_value_regno_p (REGNO (reg)))
return 0;
regno = REGNO (reg);
nregs = hard_regno_nregs[regno][GET_MODE (reg)];
if (nregs == 1)
return 0;
mask = (2U << (nregs - 1)) - 1;
/* Disregard parts of the return value that are set later. */
info.regno = regno;
info.nregs = nregs;
info.mask = mask;
for (p = PREV_INSN (use); info.mask && p != insn; p = PREV_INSN (p))
if (INSN_P (p))
note_stores (PATTERN (p), likely_spilled_retval_1, &info);
mask = info.mask;
/* Check if any of the (probably) live return value registers is
likely spilled. */
nregs --;
do
{
if ((mask & 1 << nregs)
&& targetm.class_likely_spilled_p (REGNO_REG_CLASS (regno + nregs)))
return 1;
} while (nregs--);
return 0;
} | false | false | false | false | false | 0 |
galleyHeight(FXWindow *begin,FXWindow*& end,FXint space,FXint& require,FXint& expand) const {
register FXint galley,any,w,h;
register FXWindow *child;
register FXuint hints;
require=expand=galley=any=0;
for(child=end=begin; child; end=child,child=child->getNext()){
if(child->shown()){
// Get size
hints=child->getLayoutHints();
w=(hints&LAYOUT_FIX_WIDTH)?child->getWidth():child->getDefaultWidth();
h=(hints&LAYOUT_FIX_HEIGHT)?child->getHeight():child->getDefaultHeight();
// Break for new galley?
if(any && ((hints&LAYOUT_DOCK_NEXT) || ((require+w>space) && wrapGalleys()))) break;
// Expanding widgets
if(hints&LAYOUT_FILL_X) expand+=w;
// Figure galley size
require+=w+hspacing;
if(h>galley) galley=h;
any=1;
}
}
require-=hspacing;
return galley;
} | 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.