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 |
|---|---|---|---|---|---|---|
player_can_study(void)
{
if (!player_can_cast())
return FALSE;
if (!p_ptr->new_spells)
{
cptr p = ((cp_ptr->spell_book == TV_MAGIC_BOOK) ? "spell" : "prayer");
msg_format("You cannot learn any new %ss!", p);
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
SyncSend()
{
// tx header
if (fParams.fSlaveSyncMode) {
fTxHeader.fCycle = fRxHeader.fCycle;
} else {
fTxHeader.fCycle++;
}
fTxHeader.fSubCycle = 0;
fTxHeader.fDataType = 's';
fTxHeader.fIsLastPckt = (fParams.fReturnMidiChannels == 0 && fParams.fReturnAudioChannels == 0) ? 1 : 0;
fTxHeader.fPacketSize = fParams.fMtu;
memcpy(fTxBuffer, &fTxHeader, HEADER_SIZE);
// PacketHeaderDisplay(&fTxHeader);
return Send(fTxHeader.fPacketSize, 0);
} | false | false | false | false | false | 0 |
vnl_bignum_from_string(vnl_bignum& b, const vcl_string& s)
{
// decimal: "^ *[-+]?[1-9][0-9]*$"
// Infinity: "^ *[-+]?Inf(inity)?$"
if (is_plus_inf(s.c_str()))
b=vnl_bignum("+Inf");
else if (is_minus_inf(s.c_str()))
b=vnl_bignum("-Inf");
else
b.dtoBigNum(s.c_str()); // convert decimal to vnl_bignum
return b;
} | false | false | false | false | false | 0 |
floppy_gen_floppydrive_process(struct cpssp *cpssp)
{
unsigned int blk;
unsigned int out;
uint8_t track;
uint8_t sector;
if (DEBUG_CONTROL_FLOW) {
fprintf(stderr, "%s: track=%u, hds=%u, sectors=%u, angle=%u, bufsize=%u\n",
__FUNCTION__,
cpssp->track, cpssp->hds, cpssp->sectors,
cpssp->angle, cpssp->bufsize);
}
blk = ((cpssp->track * 2) + cpssp->hds) * cpssp->sectors + cpssp->angle / 2;
switch (cpssp->op) {
case DRIVE_READ:
if (COMP_(media_read)(cpssp, blk, cpssp->buffer,
&track, §or) == 1) {
out = cpssp->bufsize;
} else {
out = 0;
}
break;
case DRIVE_WRITE:
if (cpssp->wp) {
out = cpssp->bufsize;
} else {
COMP_(media_write)(cpssp, blk, cpssp->buffer,
cpssp->track, cpssp->angle / 2);
out = cpssp->bufsize;
}
break;
default:
assert(0);
}
floppy_gen_floppydrive_interrupt(cpssp, out);
} | false | false | false | false | false | 0 |
semiLogSpectrum( float *p )
{
float e;
power2( p );
for( int i = 0; i < ( m_num / 2 ); i++, p++ )
{
e = 10.0 * log10( sqrt( *p * .5 ) );
*p = e < 0 ? 0 : e;
}
} | false | false | false | false | false | 0 |
getPipelinedCap(
kj::ArrayPtr<const PipelineOp> ops) const {
_::PointerReader pointer = reader;
for (auto& op: ops) {
switch (op.type) {
case PipelineOp::Type::NOOP:
break;
case PipelineOp::Type::GET_POINTER_FIELD:
pointer = pointer.getStruct(nullptr).getPointerField(op.pointerIndex * POINTERS);
break;
}
}
return pointer.getCapability();
} | false | false | false | false | false | 0 |
VBE_Nuke(struct backend *b)
{
ASSERT_CLI();
VTAILQ_REMOVE(&backends, b, list);
free(b->ipv4);
free(b->ipv4_addr);
free(b->ipv6);
free(b->ipv6_addr);
free(b->port);
VSM_Free(b->vsc);
FREE_OBJ(b);
VSC_C_main->n_backend--;
} | false | false | false | false | false | 0 |
cxnWait (Connection cxn)
{
ASSERT (cxn->state == cxnStartingS ||
cxn->state == cxnSleepingS ||
cxn->state == cxnConnectingS ||
cxn->state == cxnFeedingS ||
cxn->state == cxnFlushingS) ;
VALIDATE_CONNECTION (cxn) ;
abortConnection (cxn) ;
cxn->state = cxnWaitingS ;
hostCxnWaiting (cxn->myHost,cxn) ; /* tell our Host we're waiting */
} | false | false | false | false | false | 0 |
move_possible (GtkCTree *ctree, GtkCTreeNode *child, GtkCTreeNode *parent,
GtkCTreeNode *sibling)
{
return (parent != NULL && sibling != NULL);
} | false | false | false | false | false | 0 |
CopyStringUntilChar(
char *text, unsigned out_len, int c, char *out) {
char *endptr;
if (!ExtractUntilChar(text, c, &endptr))
return NULL;
strncpy(out, text, out_len);
out[out_len-1] = '\0';
*endptr = c;
SkipWhileWhitespace(&endptr, c);
return endptr;
} | false | false | false | false | false | 0 |
SetRenderWindow(vtkRenderWindow *renwin)
{
vtkProp *aProp;
if (renwin != this->RenderWindow)
{
// This renderer is be dis-associated with its previous render window.
// this information needs to be passed to the renderer's actors and
// volumes so they can release and render window specific (or graphics
// context specific) information (such as display lists and texture ids)
vtkCollectionSimpleIterator pit;
this->Props->InitTraversal(pit);
for ( aProp = this->Props->GetNextProp(pit);
aProp != NULL;
aProp = this->Props->GetNextProp(pit) )
{
aProp->ReleaseGraphicsResources(this->RenderWindow);
}
// what about lights?
// what about cullers?
if(this->Pass!=0 && this->RenderWindow!=0)
{
this->Pass->ReleaseGraphicsResources(this->RenderWindow);
}
if(this->BackgroundTexture != 0 && this->RenderWindow!=0)
{
this->BackgroundTexture->ReleaseGraphicsResources(this->RenderWindow);
}
this->VTKWindow = renwin;
this->RenderWindow = renwin;
}
} | false | false | false | false | false | 0 |
img_get_field (img_handle img, const char *tag)
{
int x;
if (!img || !tag)
return NULL;
/* Find the entry with the given tag */
for (x = img->tags - 1; x >= 0; x--)
if (img->tag [x].tag)
if (strcmp (img->tag [x].tag, tag) == 0)
return img->tag [x].data;
return NULL;
} | false | false | false | false | false | 0 |
musb_suspend(struct device *dev)
{
struct musb *musb = dev_to_musb(dev);
unsigned long flags;
musb_platform_disable(musb);
musb_generic_disable(musb);
spin_lock_irqsave(&musb->lock, flags);
if (is_peripheral_active(musb)) {
/* FIXME force disconnect unless we know USB will wake
* the system up quickly enough to respond ...
*/
} else if (is_host_active(musb)) {
/* we know all the children are suspended; sometimes
* they will even be wakeup-enabled.
*/
}
musb_save_context(musb);
spin_unlock_irqrestore(&musb->lock, flags);
return 0;
} | false | false | false | false | false | 0 |
gfork_l_opts_port(
globus_options_handle_t opts_handle,
char * cmd,
char ** opt,
void * arg,
int * out_parms_used)
{
int sc;
int port;
gfork_i_options_t * gfork_h;
globus_result_t result;
GForkFuncName(gfork_l_opts_port);
gfork_h = (gfork_i_options_t *) arg;
sc = sscanf(opt[0], "%d", &port);
if(sc != 1)
{
result = GForkErrorStr("Port must be an integer");
goto error_format;
}
gfork_h->port = port;
*out_parms_used = 1;
return GLOBUS_SUCCESS;
error_format:
*out_parms_used = 0;
return result;
} | false | false | false | false | false | 0 |
is_merged_page(struct f2fs_sb_info *sbi,
struct page *page, enum page_type type)
{
enum page_type btype = PAGE_TYPE_OF_BIO(type);
struct f2fs_bio_info *io = &sbi->write_io[btype];
struct bio_vec *bvec;
struct page *target;
int i;
down_read(&io->io_rwsem);
if (!io->bio) {
up_read(&io->io_rwsem);
return false;
}
bio_for_each_segment_all(bvec, io->bio, i) {
if (bvec->bv_page->mapping) {
target = bvec->bv_page;
} else {
struct f2fs_crypto_ctx *ctx;
/* encrypted page */
ctx = (struct f2fs_crypto_ctx *)page_private(
bvec->bv_page);
target = ctx->w.control_page;
}
if (page == target) {
up_read(&io->io_rwsem);
return true;
}
}
up_read(&io->io_rwsem);
return false;
} | false | false | false | false | false | 0 |
initLegInfoAux(QDomElement & element, const LoadInfo & loadInfo, bool & gotOne)
{
QString id = element.attribute("id");
if (!id.isEmpty()) {
int ix = loadInfo.legIDs.indexOf(id);
if (ix >= 0) {
//DebugDialog::debug("init leg info " + id);
//foreach (QString lid, legIDs) {
// DebugDialog::debug("\tleg id:" + lid);
//}
element.setTagName("g"); // don't want this element to actually be drawn
gotOne = true;
ConnectorInfo * connectorInfo = m_connectorInfoHash.value(loadInfo.connectorIDs.at(ix), NULL);
if (connectorInfo) {
//QString temp;
//QTextStream stream(&temp);
//element.save(stream, 0);
//DebugDialog::debug("\t matched " + connectorIDs.at(ix) + " " + temp);
connectorInfo->legMatrix = TextUtils::elementToMatrix(element);
connectorInfo->legColor = element.attribute("stroke");
connectorInfo->legLine = QLineF();
connectorInfo->legStrokeWidth = 0;
initLegInfoAux(element, connectorInfo);
}
// don't return here, might miss other legs
}
}
QDomElement child = element.firstChildElement();
while (!child.isNull()) {
initLegInfoAux(child, loadInfo, gotOne);
child = child.nextSiblingElement();
}
} | false | false | false | false | false | 0 |
finished(struct common *common)
{
DXlock(&common->DXlock, 0);
if (--(common->count)==0)
DXunlock(&common->done, 0);
DXunlock(&common->DXlock, 0);
} | false | false | false | false | false | 0 |
ecore_con_event_server_add(Ecore_Con_Server *svr)
{
/* we got our server! */
Ecore_Con_Event_Server_Add *e;
int ev = ECORE_CON_EVENT_SERVER_ADD;
e = ecore_con_event_server_add_alloc();
EINA_SAFETY_ON_NULL_RETURN(e);
svr->connecting = EINA_FALSE;
svr->start_time = ecore_time_get();
svr->event_count = eina_list_append(svr->event_count, e);
_ecore_con_server_timer_update(svr);
e->server = svr;
if (svr->upgrade) ev = ECORE_CON_EVENT_SERVER_UPGRADE;
ecore_event_add(ev, e,
_ecore_con_event_server_add_free, NULL);
_ecore_con_event_count++;
} | false | false | false | false | false | 0 |
parseDWOTypeUnits() {
if (!DWOTUs.empty())
return;
for (const auto &I : getTypesDWOSections()) {
DWOTUs.emplace_back();
DWOTUs.back().parseDWO(*this, I.second);
}
} | false | false | false | false | false | 0 |
mma8452_read_hp_filter(struct mma8452_data *data, int *hz, int *uHz)
{
int i, ret;
ret = i2c_smbus_read_byte_data(data->client, MMA8452_HP_FILTER_CUTOFF);
if (ret < 0)
return ret;
i = mma8452_get_odr_index(data);
ret &= MMA8452_HP_FILTER_CUTOFF_SEL_MASK;
*hz = mma8452_hp_filter_cutoff[i][ret][0];
*uHz = mma8452_hp_filter_cutoff[i][ret][1];
return 0;
} | false | false | false | false | false | 0 |
slotDialogAccepted()
{
AmarokConfig::setOrganizeDirectory( ui->folderCombo->currentText() );
AmarokConfig::setIgnoreThe( m_optionsWidget->postfixThe() );
AmarokConfig::setReplaceSpace( m_optionsWidget->replaceSpaces() );
AmarokConfig::setVfatCompatible( m_optionsWidget->vfatCompatible() );
AmarokConfig::setAsciiOnly( m_optionsWidget->asciiOnly() );
AmarokConfig::setReplacementRegexp( m_optionsWidget->regexpText() );
AmarokConfig::setReplacementString( m_optionsWidget->replaceText() );
m_organizeCollectionWidget->onAccept();
} | false | false | false | false | false | 0 |
dwc2_get_actual_xfer_length(struct dwc2_hsotg *hsotg,
struct dwc2_host_chan *chan, int chnum,
struct dwc2_qtd *qtd,
enum dwc2_halt_status halt_status,
int *short_read)
{
u32 hctsiz, count, length;
hctsiz = dwc2_readl(hsotg->regs + HCTSIZ(chnum));
if (halt_status == DWC2_HC_XFER_COMPLETE) {
if (chan->ep_is_in) {
count = (hctsiz & TSIZ_XFERSIZE_MASK) >>
TSIZ_XFERSIZE_SHIFT;
length = chan->xfer_len - count;
if (short_read != NULL)
*short_read = (count != 0);
} else if (chan->qh->do_split) {
length = qtd->ssplit_out_xfer_count;
} else {
length = chan->xfer_len;
}
} else {
/*
* Must use the hctsiz.pktcnt field to determine how much data
* has been transferred. This field reflects the number of
* packets that have been transferred via the USB. This is
* always an integral number of packets if the transfer was
* halted before its normal completion. (Can't use the
* hctsiz.xfersize field because that reflects the number of
* bytes transferred via the AHB, not the USB).
*/
count = (hctsiz & TSIZ_PKTCNT_MASK) >> TSIZ_PKTCNT_SHIFT;
length = (chan->start_pkt_count - count) * chan->max_packet;
}
return length;
} | false | false | false | false | false | 0 |
OGR_G_Equals( OGRGeometryH hGeom, OGRGeometryH hOther )
{
VALIDATE_POINTER1( hGeom, "OGR_G_Equals", FALSE );
if (hGeom == NULL) {
CPLError ( CE_Failure, CPLE_ObjectNull, "hGeom was NULL in OGR_G_Equals");
return 0;
}
if (hOther == NULL) {
CPLError ( CE_Failure, CPLE_ObjectNull, "hOther was NULL in OGR_G_Equals");
return 0;
}
return ((OGRGeometry *) hGeom)->Equals( (OGRGeometry *) hOther );
} | false | false | false | false | false | 0 |
_list_item_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Object_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
ITEM_NEW(ctxpopup, "Go to home folder", "home");
ITEM_NEW(ctxpopup, "Save file", "file");
ITEM_NEW(ctxpopup, "Delete file", "delete");
ITEM_NEW(ctxpopup, "Navigate to folder", "folder");
elm_object_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, "Edit entry", "edit");
ITEM_NEW(ctxpopup, "Set date and time", "clock");
elm_object_item_disabled_set(it, EINA_TRUE);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
} | false | false | false | false | false | 0 |
ath5k_txq_release(struct ath5k_softc *sc)
{
if (sc->txq.setup) {
ath5k_hw_release_tx_queue(sc->ah);
sc->txq.setup = 0;
}
} | false | false | false | false | false | 0 |
dpcm_fe_dai_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
struct snd_soc_pcm_runtime *fe = substream->private_data;
int ret, stream = substream->stream;
mutex_lock_nested(&fe->card->mutex, SND_SOC_CARD_CLASS_RUNTIME);
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_FE);
memcpy(&fe->dpcm[substream->stream].hw_params, params,
sizeof(struct snd_pcm_hw_params));
ret = dpcm_be_dai_hw_params(fe, substream->stream);
if (ret < 0) {
dev_err(fe->dev,"ASoC: hw_params BE failed %d\n", ret);
goto out;
}
dev_dbg(fe->dev, "ASoC: hw_params FE %s rate %d chan %x fmt %d\n",
fe->dai_link->name, params_rate(params),
params_channels(params), params_format(params));
/* call hw_params on the frontend */
ret = soc_pcm_hw_params(substream, params);
if (ret < 0) {
dev_err(fe->dev,"ASoC: hw_params FE failed %d\n", ret);
dpcm_be_dai_hw_free(fe, stream);
} else
fe->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_PARAMS;
out:
dpcm_set_fe_update_state(fe, stream, SND_SOC_DPCM_UPDATE_NO);
mutex_unlock(&fe->card->mutex);
return ret;
} | false | true | false | false | false | 1 |
GrantRole(GrantRoleStmt *stmt)
{
Relation pg_authid_rel;
Oid grantor;
List *grantee_ids;
ListCell *item;
if (stmt->grantor)
grantor = get_roleid_checked(stmt->grantor);
else
grantor = GetUserId();
grantee_ids = roleNamesToIds(stmt->grantee_roles);
/* AccessShareLock is enough since we aren't modifying pg_authid */
pg_authid_rel = heap_open(AuthIdRelationId, AccessShareLock);
/*
* Step through all of the granted roles and add/remove entries for the
* grantees, or, if admin_opt is set, then just add/remove the admin
* option.
*
* Note: Permissions checking is done by AddRoleMems/DelRoleMems
*/
foreach(item, stmt->granted_roles)
{
char *rolename = strVal(lfirst(item));
Oid roleid = get_roleid_checked(rolename);
if (stmt->is_grant)
AddRoleMems(rolename, roleid,
stmt->grantee_roles, grantee_ids,
grantor, stmt->admin_opt);
else
DelRoleMems(rolename, roleid,
stmt->grantee_roles, grantee_ids,
stmt->admin_opt);
}
/*
* Close pg_authid, but keep lock till commit (this is important to
* prevent any risk of deadlock failure while updating flat file)
*/
heap_close(pg_authid_rel, NoLock);
/*
* Set flag to update flat auth file at commit.
*/
auth_file_update_needed();
} | false | false | false | false | false | 0 |
check_learn_consistency(const Ngram& ngram) const
{
// no need to begin a new transaction, as we'll be called from
// within an existing transaction from learn()
// BEWARE: if the previous sentence is not true, then performance
// WILL suffer!
size_t size = ngram.size();
for (size_t i = 0; i < size; i++) {
if (count(ngram, -i, size - i) > count(ngram, -(i + 1), size - (i + 1))) {
logger << INFO << "consistency adjustment needed!" << endl;
int offset = -(i + 1);
int sub_ngram_size = size - (i + 1);
logger << DEBUG << "i: " << i << " | offset: " << offset << " | sub_ngram_size: " << sub_ngram_size << endl;
Ngram sub_ngram(sub_ngram_size); // need to init to right size for sub_ngram
copy(ngram.end() - sub_ngram_size + offset, ngram.end() + offset, sub_ngram.begin());
if (logger.shouldLog()) {
logger << "ngram to be count adjusted is: ";
for (size_t i = 0; i < sub_ngram.size(); i++) {
logger << sub_ngram[i] << ' ';
}
logger << endl;
}
db->incrementNgramCount(sub_ngram);
logger << DEBUG << "consistency adjusted" << endl;
}
}
} | false | false | false | false | false | 0 |
pdf_open_inline_stream(pdf_document *xref, pdf_obj *stmobj, int length, fz_stream *chain, fz_compression_params *imparams)
{
pdf_obj *filters;
pdf_obj *params;
filters = pdf_dict_getsa(stmobj, "Filter", "F");
params = pdf_dict_getsa(stmobj, "DecodeParms", "DP");
/* don't close chain when we close this filter */
fz_keep_stream(chain);
if (pdf_is_name(filters))
return build_filter(chain, xref, filters, params, 0, 0, imparams);
if (pdf_array_len(filters) > 0)
return build_filter_chain(chain, xref, filters, params, 0, 0, imparams);
return fz_open_null(chain, length, fz_tell(chain));
} | false | false | false | false | false | 0 |
fillencseqmapspecstartptr(GtEncseq *encseq,
const char *indexname,
GtLogger *logger,
GtError *err)
{
bool haserr = false;
GtStr *tmpfilename;
char *nextstart;
unsigned long idx;
gt_error_check(err);
tmpfilename = gt_str_new_cstr(indexname);
gt_str_append_cstr(tmpfilename,GT_ENCSEQFILESUFFIX);
if (gt_mapspec_read(gt_encseq_assign_mapspec,
encseq,
tmpfilename,
encseq->sizeofrep,
&encseq->mappedptr,
err) != 0)
{
haserr = true;
}
if (!haserr)
{
encseq->totallength = *encseq->headerptr.totallengthptr;
encseq->logicaltotallength = encseq->totallength;
encseq->numofdbsequences = *encseq->headerptr.numofdbsequencesptr;
encseq->logicalnumofdbsequences = encseq->numofdbsequences;
encseq->numofdbfiles = *encseq->headerptr.numofdbfilesptr;
encseq->lengthofdbfilenames = *encseq->headerptr.lengthofdbfilenamesptr;
encseq->specialcharinfo = *encseq->headerptr.specialcharinfoptr;
encseq->minseqlen = *encseq->headerptr.minseqlenptr;
encseq->maxseqlen = *encseq->headerptr.maxseqlenptr;
encseq->maxsubalphasize = (unsigned char)
*encseq->headerptr.maxsubalphasizeptr;
encseq->numofallchars = *encseq->headerptr.numofallcharsptr;
encseq->version = *encseq->headerptr.versionptr;
encseq->is64bit = *encseq->headerptr.is64bitptr;
encseq->filenametab = gt_str_array_new();
nextstart = encseq->headerptr.firstfilename;
for (idx = 0; idx < encseq->numofdbfiles; idx++)
{
gt_str_array_add_cstr(encseq->filenametab,nextstart);
nextstart = strchr(nextstart,(int) '\0');
gt_assert(nextstart != NULL);
nextstart++;
}
gt_assert(encseq->headerptr.characterdistribution != NULL);
gt_logger_log(logger,"sat=%s",gt_encseq_accessname(encseq));
}
gt_str_delete(tmpfilename);
return haserr ? -1 : 0;
} | false | false | false | false | false | 0 |
base_name(const char *pathname)
{
const char *base, *pch;
char ch;
for (pch = base = pathname; (ch = *pch++) != '\0'; )
if (ch == '/')
base = pch;
return base;
} | false | false | false | false | false | 0 |
free_odb_object(void *o)
{
git_odb_object *object = (git_odb_object *)o;
if (object != NULL) {
free(object->raw.data);
free(object);
}
} | false | false | false | false | false | 0 |
agrcount(Aword whr)
#else
Aint agrcount(whr)
Aword whr;
#endif
{
Aword i;
Aword count = 0;
for (i = OBJMIN; i <= OBJMAX; i++) {
if (isLoc(whr)) {
if (where(i) == whr)
count++;
} else if (objs[i-OBJMIN].loc == whr)
count++;
}
return(count);
} | false | false | false | false | false | 0 |
set_program_name (const char *argv0)
{
/* libtool creates a temporary executable whose name is sometimes prefixed
with "lt-" (depends on the platform). It also makes argv[0] absolute.
But the name of the temporary executable is a detail that should not be
visible to the end user and to the test suite.
Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
const char *slash;
const char *base;
/* Sanity check. POSIX requires the invoking process to pass a non-NULL
argv[0]. */
if (argv0 == NULL)
{
/* It's a bug in the invoking program. Help diagnosing it. */
fputs ("A NULL argv[0] was passed through an exec system call.\n",
stderr);
abort ();
}
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
{
argv0 = base;
if (strncmp (base, "lt-", 3) == 0)
{
argv0 = base + 3;
/* On glibc systems, remove the "lt-" prefix from the variable
program_invocation_short_name. */
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
program_invocation_short_name = (char *) argv0;
#endif
}
}
/* But don't strip off a leading <dirname>/ in general, because when the user
runs
/some/hidden/place/bin/cp foo foo
he should get the error message
/some/hidden/place/bin/cp: `foo' and `foo' are the same file
not
cp: `foo' and `foo' are the same file
*/
program_name = argv0;
/* On glibc systems, the error() function comes from libc and uses the
variable program_invocation_name, not program_name. So set this variable
as well. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = (char *) argv0;
#endif
} | false | false | false | false | false | 0 |
EffectStr(char const *effect)
{
AString temp, temp2;
int comma = 0;
int i;
EffectType *ep = FindEffect(effect);
temp += ep->name;
if(ep->attackVal) {
temp2 += AString(ep->attackVal) + " to attack";
comma = 1;
}
for(i = 0; i < 4; i++) {
if(ep->defMods[i].type == -1) continue;
if(comma) temp2 += ", ";
temp2 += AString(ep->defMods[i].val) + " versus " +
DefType(ep->defMods[i].type) + " attacks";
comma = 1;
}
if(comma) {
temp += AString(" (") + temp2 + ")";
}
if(comma) {
if(ep->flags & EffectType::EFF_ONESHOT) {
temp += " for their next attack";
} else {
temp += " for the rest of the battle";
}
}
temp += ".";
if(ep->cancelEffect != NULL) {
if(comma) temp += " ";
EffectType *up = FindEffect(ep->cancelEffect);
temp += AString("This effect cancels out the effects of ") +
up->name + ".";
}
return temp;
} | false | false | false | false | false | 0 |
Jim_StackPush(Jim_Stack *stack, void *element)
{
int neededLen = stack->len + 1;
if (neededLen > stack->maxlen) {
stack->maxlen = neededLen < 20 ? 20 : neededLen * 2;
stack->vector = Jim_Realloc(stack->vector, sizeof(void *) * stack->maxlen);
}
stack->vector[stack->len] = element;
stack->len++;
} | false | false | false | false | false | 0 |
phy_ethtool_sset(struct phy_device *phydev, struct ethtool_cmd *cmd)
{
u32 speed = ethtool_cmd_speed(cmd);
if (cmd->phy_address != phydev->addr)
return -EINVAL;
/* We make sure that we don't pass unsupported values in to the PHY */
cmd->advertising &= phydev->supported;
/* Verify the settings we care about. */
if (cmd->autoneg != AUTONEG_ENABLE && cmd->autoneg != AUTONEG_DISABLE)
return -EINVAL;
if (cmd->autoneg == AUTONEG_ENABLE && cmd->advertising == 0)
return -EINVAL;
if (cmd->autoneg == AUTONEG_DISABLE &&
((speed != SPEED_1000 &&
speed != SPEED_100 &&
speed != SPEED_10) ||
(cmd->duplex != DUPLEX_HALF &&
cmd->duplex != DUPLEX_FULL)))
return -EINVAL;
phydev->autoneg = cmd->autoneg;
phydev->speed = speed;
phydev->advertising = cmd->advertising;
if (AUTONEG_ENABLE == cmd->autoneg)
phydev->advertising |= ADVERTISED_Autoneg;
else
phydev->advertising &= ~ADVERTISED_Autoneg;
phydev->duplex = cmd->duplex;
phydev->mdix = cmd->eth_tp_mdix_ctrl;
/* Restart the PHY */
phy_start_aneg(phydev);
return 0;
} | false | false | false | false | false | 0 |
vxml_parser_handle_attrval(vxml_parser_t *vp, struct vxml_output *vo)
{
uint32 quote;
uint32 uc;
unsigned generation;
vxml_output_check(vo);
g_assert(0 == vxml_output_size(vo));
/*
* AttValue ::= '"' ([^<&"] | Reference)* '"'
* | "'" ([^<&'] | Reference)* "'"
*/
quote = vxml_next_char(vp);
generation = vp->last_uc_generation;
if (VXC_QUOT != quote && VXC_APOS != quote) {
vxml_fatal_error_uc(vp, VXML_E_EXPECTED_QUOTE, quote);
return FALSE;
}
/*
* See comment in vxml_parser_handle_quoted_string() for the usage
* of vp->last_uc_generation in the loop below.
*/
while (0 != (uc = vxml_next_char(vp))) {
if (quote == uc && vp->last_uc_generation <= generation) {
vxml_output_append(vo, VXC_NUL);
return TRUE;
} else if (VXC_AMP == uc) {
if (!vxml_expand_reference(vp, FALSE))
return FALSE;
} else if (VXC_LT == uc) {
vxml_fatal_error_out(vp, VXML_E_UNEXPECTED_LT);
return FALSE;
} else {
vxml_output_append(vo, uc);
}
}
vxml_fatal_error(vp, VXML_E_TRUNCATED_INPUT);
return FALSE;
} | false | false | false | false | false | 0 |
flickcurl_free_tag_cluster(flickcurl_tag_cluster *tc)
{
FLICKCURL_ASSERT_OBJECT_POINTER_RETURN(tc, flickcurl_tag_cluster);
if(tc->tags) {
int i;
for(i = 0; tc->tags[i]; i++)
free(tc->tags[i]);
free(tc->tags);
}
free(tc);
} | false | false | false | false | false | 0 |
MyAddEventHandler(dpy, window, type, mask, func, data)
Display *dpy;
Window window;
int type;
unsigned long mask;
void (*func)();
XtPointer data;
{
WindowRec *wp;
HandlerRec *hp;
caddr_t cdata;
TRACE(("MyAddEventHandler(window=%08lx,type=%d)\n", window, type));
if (!Initialized) initialize();
hp = XtNew(HandlerRec);
hp->type = type;
hp->mask = mask;
hp->handler = func;
hp->data = data;
hp->next = NULL;
if (!XFindContext(dpy, window, Context, &cdata)) {
wp = (WindowRec *)cdata;
hp->next = wp->handlers;
wp->handlers = hp;
} else {
wp = XtNew(WindowRec);
wp->mask = 0L;
wp->dispatching = False;
wp->handlers = hp;
(void)XSaveContext(dpy, window, Context, (caddr_t)wp);
}
resetEventMask(dpy, window, wp);
} | false | false | false | false | false | 0 |
uv__handle_init(uv_loop_t* loop, uv_handle_t* handle,
uv_handle_type type) {
loop->counters.handle_init++;
handle->loop = loop;
handle->type = type;
handle->flags = 0;
ev_init(&handle->next_watcher, uv__next);
handle->next_watcher.data = handle;
/* Ref the loop until this handle is closed. See uv__finish_close. */
ev_ref(loop->ev);
} | false | false | false | false | false | 0 |
udisks_linux_drive_object_should_include_device (GUdevClient *client,
UDisksLinuxDevice *device,
gchar **out_vpd)
{
gboolean ret;
gchar *vpd;
ret = FALSE;
vpd = NULL;
/* The 'block' subsystem encompasses several objects with varying
* DEVTYPE including
*
* - disk
* - partition
*
* and we are only interested in the first.
*/
if (g_strcmp0 (g_udev_device_get_devtype (device->udev_device), "disk") != 0)
goto out;
vpd = check_for_vpd (device->udev_device);
if (vpd == NULL)
{
const gchar *name;
const gchar *vendor;
const gchar *model;
const gchar *dm_name;
GUdevDevice *parent;
name = g_udev_device_get_name (device->udev_device);
/* workaround for floppy devices */
if (g_str_has_prefix (name, "fd"))
{
vpd = g_strdup_printf ("pcfloppy_%s", name);
goto found;
}
/* workaround for missing serial/wwn on virtio-blk */
if (g_str_has_prefix (name, "vd"))
{
vpd = g_strdup (name);
goto found;
}
/* workaround for missing serial/wwn on VMware */
vendor = g_udev_device_get_property (device->udev_device, "ID_VENDOR");
model = g_udev_device_get_property (device->udev_device, "ID_MODEL");
if (g_str_has_prefix (name, "sd") &&
vendor != NULL && g_strcmp0 (vendor, "VMware") == 0 &&
model != NULL && g_str_has_prefix (model, "Virtual"))
{
vpd = g_strdup (name);
goto found;
}
/* workaround for missing serial/wwn on firewire devices */
parent = g_udev_device_get_parent_with_subsystem (device->udev_device, "firewire", NULL);
if (parent != NULL)
{
vpd = g_strdup (name);
g_object_unref (parent);
goto found;
}
/* dm-multipath */
dm_name = g_udev_device_get_sysfs_attr (device->udev_device, "dm/name");
if (dm_name != NULL && g_str_has_prefix (dm_name, "mpath"))
{
gchar **slaves;
guint n;
slaves = udisks_daemon_util_resolve_links (g_udev_device_get_sysfs_path (device->udev_device), "slaves");
for (n = 0; slaves[n] != NULL; n++)
{
GUdevDevice *slave;
slave = g_udev_client_query_by_sysfs_path (client, slaves[n]);
if (slave != NULL)
{
vpd = check_for_vpd (slave);
if (vpd != NULL)
{
g_object_unref (slave);
g_strfreev (slaves);
goto found;
}
g_object_unref (slave);
}
}
g_strfreev (slaves);
}
}
found:
if (vpd != NULL)
{
if (out_vpd != NULL)
{
*out_vpd = vpd;
vpd = NULL;
}
ret = TRUE;
}
out:
g_free (vpd);
return ret;
} | false | false | false | false | false | 0 |
SetMetadata( char ** papszMetadata,
const char * pszDomain )
{
if( !SupportsInstr(INSTR_Band_SetMetadata) )
return GDALPamRasterBand::SetMetadata(papszMetadata, pszDomain);
CLIENT_ENTER();
if( !WriteInstr(INSTR_Band_SetMetadata) ||
!GDALPipeWrite(p, papszMetadata) ||
!GDALPipeWrite(p, pszDomain) )
return CE_Failure;
return CPLErrOnlyRet(p);
} | false | false | false | false | false | 0 |
glare(game *g)
{
if (g->is_in_sunlight(g->u.posx, g->u.posy))
g->u.infect(DI_GLARE, bp_eyes, 1, 2, g);
} | false | false | false | false | false | 0 |
dialog_destroyed (GtkWidget *dialog, gpointer data)
{
dialogs --;
if (dialogs <= 0)
gtk_main_quit ();
} | false | false | false | false | false | 0 |
error(std::error_code ec) {
if (!ec)
return false;
outs() << ToolName << ": error reading file: " << ec.message() << ".\n";
outs().flush();
return true;
} | false | false | false | false | false | 0 |
get_program_memory_at_address(unsigned int address)
{
unsigned int uIndex = map_pm_address2index(address);
return (uIndex < program_memory_size() && program_memory[uIndex])
? program_memory[uIndex]->get_opcode()
: 0xffffffff;
} | false | false | false | false | false | 0 |
sanei_genesys_read_register (Genesys_Device * dev, uint16_t reg, uint8_t * val)
{
SANE_Status status;
SANE_Byte reg8;
#ifdef UNIT_TESTING
if(dev->usb_mode<0)
{
*val=0;
return SANE_STATUS_GOOD;
}
#endif
/* 16 bit register address space */
if(reg>255)
{
return sanei_genesys_read_hregister(dev, reg, val);
}
/* route to gl847 function if needed */
if(dev->model->asic_type==GENESYS_GL847
|| dev->model->asic_type==GENESYS_GL845
|| dev->model->asic_type==GENESYS_GL846
|| dev->model->asic_type==GENESYS_GL124)
return sanei_genesys_read_gl847_register(dev, reg, val);
/* 8 bit register address space */
reg8=(SANE_Byte)(reg& 0Xff);
status =
sanei_usb_control_msg (dev->dn, REQUEST_TYPE_OUT, REQUEST_REGISTER,
VALUE_SET_REGISTER, INDEX, 1, ®8);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"sanei_genesys_read_register (0x%02x, 0x%02x): failed while setting register: %s\n",
reg, *val, sane_strstatus (status));
return status;
}
*val = 0;
status =
sanei_usb_control_msg (dev->dn, REQUEST_TYPE_IN, REQUEST_REGISTER,
VALUE_READ_REGISTER, INDEX, 1, val);
if (status != SANE_STATUS_GOOD)
{
DBG (DBG_error,
"sanei_genesys_read_register (0x%02x, 0x%02x): failed while reading register value: %s\n",
reg, *val, sane_strstatus (status));
return status;
}
DBG (DBG_io, "sanei_genesys_read_register (0x%02x, 0x%02x) completed\n",
reg, *val);
return status;
} | false | false | false | false | false | 0 |
parse_block(char *buffer, unsigned len) {
size_t i = next_dark(buffer, len, 0);
if(i == len) {
return NULL;
}
gcblock *block = malloc(sizeof(gcblock));
block->next = NULL;
block->line = 0;
block->optdelete = 0;
block->words = NULL;
block->wordcnt = 0;
/* We can't fill these in here */
block->index = 0;
block->real_line = 0;
/* Check for optional delete */
if(buffer[i] == '/') {
block->optdelete = 1;
i = next_dark(buffer, len, i + 1);
}
/* Check for line number */
if((buffer[i] == 'N' || buffer[i] == 'n') && (i + 1) < len) {
i = next_dark(buffer, len, len);
char* endptr;
block->line = strtol(buffer + i, &endptr, 10);
i = next_dark(buffer, len, endptr - buffer);
}
/* Parse words */
unsigned allocsize = 0;
while(i < len) {
/* Skip comments */
while(buffer[i] == '(') {
for(; i < len && buffer[i] != ')'; ++i);
i = next_dark(buffer, len, i + 1);
if(i >= len) {
return block;
}
}
if(buffer[i] == ';') {
return block;
}
if(block->wordcnt == allocsize) {
allocsize = 2*(allocsize ? allocsize : 2);
block->words = realloc(block->words, allocsize * sizeof(gcword));
}
block->words[block->wordcnt].letter = toupper(buffer[i]);
i = next_dark(buffer, len, i + 1);
if(i == len) {
free(block->words);
free(block);
return NULL;
}
/* TODO: Spaces in numbers */
/* TODO: Gn.m support */
{
char *endptr;
block->words[block->wordcnt].num = strtof(buffer + i, &endptr);
if(endptr == buffer + i) {
free(block->words);
free(block);
return NULL;
}
i = next_dark(buffer, len, endptr - buffer);
}
++(block->wordcnt);
}
return block;
} | false | false | false | false | false | 0 |
endswith(const char *suffix) {
lenpos_t lenSuffix = strlen(suffix);
if (lenSuffix > sLen) {
return false;
}
return strncmp(s + sLen - lenSuffix, suffix, lenSuffix) == 0;
} | false | false | false | false | false | 0 |
report_error(MPI_Comm comm, int errcode, char *errmsg, char *type)
{
char mpierrmsg[MPI_MAX_ERROR_STRING];
char name[MPI_MAX_OBJECT_NAME+1];
int rank;
int cid;
int len;
MPI_Error_string(errcode, mpierrmsg, &len);
if (comm != MPI_COMM_NULL) {
MPI_Comm_rank(comm, &rank);
if (comm->c_name[0]) {
lam_strncpy(name, comm->c_name, MPI_MAX_OBJECT_NAME);
} else {
MPIL_Comm_id(comm, &cid);
cid = lam_mpi_coll2pt(cid);
sprintf(name, "%s %d", type, cid);
}
if (_kio.ki_rtf & RTF_IO) {
if (*errmsg) {
printf("%s: %s (rank %d, %s)\n",
mpierrmsg, errmsg, rank, name);
} else {
printf("%s (rank %d, %s)\n",
mpierrmsg, rank, name);
}
fflush(stdout);
} else {
if (*errmsg) {
tprintf("%s: %s (rank %d, %s)\n",
mpierrmsg, errmsg, rank, name);
} else {
tprintf("%s (rank %d, %s)\n",
mpierrmsg, rank, name);
}
}
}
else {
if (_kio.ki_rtf & RTF_IO) {
if (*errmsg) {
printf("%s: %s (node %d, pid %d)\n", mpierrmsg,
errmsg, getnodeid(), (int) lam_getpid());
} else {
printf("%s (node %d, pid %d)\n",
mpierrmsg, getnodeid(), (int) lam_getpid());
}
fflush(stdout);
} else {
if (*errmsg) {
tprintf("%s: %s (node %d, pid %d)\n", mpierrmsg,
errmsg, getnodeid(), (int) lam_getpid());
} else {
tprintf("%s (node %d, pid %d)\n",
mpierrmsg, getnodeid(), (int) lam_getpid());
}
}
}
/*
* print out the LAM/MPI call stack
*/
lam_printfunc();
} | true | true | false | false | false | 1 |
fp_value_constructor5(fp_value_ty *this, time_t a1, time_t a2, time_t a3,
string_ty *a4, string_ty *a5)
{
trace(("fp_value_constructor5(this = %p, oldest = %ld, youngest = %ld, "
"stat_mod_time = %ld, cfp = \"%s\", ifp = \"%s\")\n{\n", this, a1, a2,
a3, (a4 ? a4->str_text : ""), (a5 ? a5->str_text : "")));
if (a1 > a2)
a1 = a2;
this->oldest = a1;
this->newest = a2;
this->stat_mod_time = a3;
this->contents_fingerprint = (a4 ? str_copy(a4) : 0);
this->ingredients_fingerprint = (a5 ? str_copy(a5) : 0);
trace(("}\n"));
} | false | false | false | false | false | 0 |
aiReleaseImport( const aiScene* pScene)
{
if (!pScene) {
return;
}
ASSIMP_BEGIN_EXCEPTION_REGION();
// find the importer associated with this data
const ScenePrivateData* priv = ScenePriv(pScene);
if( !priv || !priv->mOrigImporter) {
delete pScene;
}
else {
// deleting the Importer also deletes the scene
// Note: the reason that this is not written as 'delete priv->mOrigImporter'
// is a suspected bug in gcc 4.4+ (http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52339)
Importer* importer = priv->mOrigImporter;
delete importer;
}
ASSIMP_END_EXCEPTION_REGION(void);
} | false | false | false | false | false | 0 |
gvattributeadaptorCacheInsert(EnsPGvattributeadaptor gvaa,
EnsPGvattribute *Pgva)
{
ajuint *Pidentifier = NULL;
EnsPGvattribute gva = NULL;
if (!gvaa)
return ajFalse;
if (!gvaa->CacheByIdentifier)
return ajFalse;
if (!Pgva)
return ajFalse;
if (!*Pgva)
return ajFalse;
/* Search the identifer cache. */
gva = (EnsPGvattribute) ajTableFetchmodV(
gvaa->CacheByIdentifier,
(const void *) &((*Pgva)->Identifier));
if (!gva)
{
/* Insert into the identifier cache. */
AJNEW0(Pidentifier);
*Pidentifier = (*Pgva)->Identifier;
ajTablePut(gvaa->CacheByIdentifier,
(void *) Pidentifier,
(void *) ensGvattributeNewRef(*Pgva));
}
ajDebug("gvattributeadaptoradaptorCacheInsert replaced "
"Ensembl Genetic Variation Attribute %p with one "
"already cached %p.\n",
*Pgva, gva);
ensGvattributeDel(Pgva);
ensGvattributeNewRef(gva);
Pgva = &gva;
return ajTrue;
} | false | false | false | false | false | 0 |
_gcry_ecc_get_param_sexp (const char *name)
{
unsigned int nbits;
elliptic_curve_t E;
mpi_ec_t ctx;
gcry_mpi_t g_x, g_y;
gcry_mpi_t pkey[6];
gcry_sexp_t result;
int i;
memset (&E, 0, sizeof E);
if (_gcry_ecc_fill_in_curve (0, name, &E, &nbits))
return NULL;
g_x = mpi_new (0);
g_y = mpi_new (0);
ctx = _gcry_mpi_ec_p_internal_new (MPI_EC_WEIERSTRASS,
ECC_DIALECT_STANDARD,
0,
E.p, E.a, NULL);
if (_gcry_mpi_ec_get_affine (g_x, g_y, &E.G, ctx))
log_fatal ("ecc get param: Failed to get affine coordinates\n");
_gcry_mpi_ec_free (ctx);
_gcry_mpi_point_free_parts (&E.G);
pkey[0] = E.p;
pkey[1] = E.a;
pkey[2] = E.b;
pkey[3] = _gcry_ecc_ec2os (g_x, g_y, E.p);
pkey[4] = E.n;
pkey[5] = NULL;
mpi_free (g_x);
mpi_free (g_y);
if (sexp_build (&result, NULL,
"(public-key(ecc(p%m)(a%m)(b%m)(g%m)(n%m)))",
pkey[0], pkey[1], pkey[2], pkey[3], pkey[4]))
result = NULL;
for (i=0; pkey[i]; i++)
_gcry_mpi_release (pkey[i]);
return result;
} | false | false | false | false | false | 0 |
uvd_v4_2_enable_mgcg(struct amdgpu_device *adev,
bool enable)
{
u32 orig, data;
if (enable && (adev->cg_flags & AMD_CG_SUPPORT_UVD_MGCG)) {
data = RREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL);
data = 0xfff;
WREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL, data);
orig = data = RREG32(mmUVD_CGC_CTRL);
data |= UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK;
if (orig != data)
WREG32(mmUVD_CGC_CTRL, data);
} else {
data = RREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL);
data &= ~0xfff;
WREG32_UVD_CTX(ixUVD_CGC_MEM_CTRL, data);
orig = data = RREG32(mmUVD_CGC_CTRL);
data &= ~UVD_CGC_CTRL__DYN_CLOCK_MODE_MASK;
if (orig != data)
WREG32(mmUVD_CGC_CTRL, data);
}
} | false | false | false | false | false | 0 |
IMAP_Literal_Read( ITD_Struct *ITD )
{
char *fn = "IMAP_Literal_Read()";
int Status;
unsigned int i, j;
struct pollfd fds[2];
nfds_t nfds;
int pollstatus;
/*
* If there aren't any LiteralBytesRemaining, just return 0.
*/
if ( ! ITD->LiteralBytesRemaining )
return( 0 );
/* scoot the buffer */
for ( i = ITD->ReadBytesProcessed, j = 0;
i <= ITD->BytesInReadBuffer;
i++, j++ )
{
ITD->ReadBuf[j] = ITD->ReadBuf[i];
}
ITD->BytesInReadBuffer -= ITD->ReadBytesProcessed;
ITD->ReadBytesProcessed = 0;
/*
* If we have any data in our buffer, return what we have.
*/
if ( ITD->BytesInReadBuffer > 0 )
{
if ( ITD->BytesInReadBuffer >= ITD->LiteralBytesRemaining )
{
ITD->ReadBytesProcessed = ITD->LiteralBytesRemaining;
ITD->LiteralBytesRemaining = 0;
return( ITD->ReadBytesProcessed );
}
else
{
ITD->ReadBytesProcessed += ITD->BytesInReadBuffer;
ITD->LiteralBytesRemaining -= ITD->BytesInReadBuffer;
return( ITD->ReadBytesProcessed );
}
}
/*
* No data left in the buffer. Have to call read. Read either
* the number of literal bytes left, or the rest of our buffer --
* whichever is smaller.
*
*/
nfds = 1;
fds[0].fd = ITD->conn->sd;
fds[0].events = POLLIN;
fds[0].revents = 0;
pollstatus = poll( fds, nfds, POLL_TIMEOUT );
if ( !pollstatus )
{
syslog( LOG_ERR, "%s: poll() for data on sd [%d] timed out.", fn, ITD->conn->sd );
return( -1 );
}
if ( pollstatus < 0 )
{
syslog( LOG_ERR, "%s: poll() for data on sd [%d] failed: %s.", fn, ITD->conn->sd, strerror( errno ) );
return( -1 );
}
if ( !( fds[0].revents & POLLIN ) )
{
syslog( LOG_ERR, "%s: poll() for data on sd [%d] returned nothing.", fn, ITD->conn->sd );
return( -1 );
}
Status = IMAP_Read(ITD->conn, &ITD->ReadBuf[ITD->BytesInReadBuffer],
(sizeof ITD->ReadBuf - ITD->BytesInReadBuffer ) );
if ( Status == 0 )
{
syslog(LOG_WARNING, "%s: connection closed prematurely.", fn);
return(-1);
}
else if ( Status == -1 )
{
syslog(LOG_ERR, "%s: IMAP_Read() failed: %s", fn, strerror(errno) );
return(-1);
}
/*
* update the bytes remaining and return the byte count read.
*/
ITD->BytesInReadBuffer += Status;
if ( ITD->BytesInReadBuffer >= ITD->LiteralBytesRemaining )
{
ITD->ReadBytesProcessed = ITD->LiteralBytesRemaining;
ITD->LiteralBytesRemaining = 0;
return( ITD->ReadBytesProcessed );
}
else
{
ITD->ReadBytesProcessed += ITD->BytesInReadBuffer;
ITD->LiteralBytesRemaining -= ITD->BytesInReadBuffer;
return( ITD->ReadBytesProcessed );
}
} | false | false | false | false | false | 0 |
evemu_device(FILE *fp)
{
struct evemu_device *dev;
int ret = -ENOMEM;
int fd;
dev = evemu_new(NULL);
if (!dev)
goto out;
ret = evemu_read(dev, fp);
if (ret <= 0)
goto out;
if (strlen(evemu_get_name(dev)) == 0) {
char name[64];
sprintf(name, "evemu-%d", getpid());
evemu_set_name(dev, name);
}
ret = fd = open(UINPUT_NODE, O_WRONLY);
if (ret < 0)
goto out;
ret = evemu_create(dev, fd);
if (ret < 0)
goto out_close;
hold_device(dev);
evemu_destroy(fd);
out_close:
close(fd);
out:
evemu_delete(dev);
return ret;
} | false | false | false | false | false | 0 |
fixup_eh_region_note (rtx insn, rtx prev, rtx next)
{
rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
if (note == NULL)
return;
if (!insn_could_throw_p (insn))
remove_note (insn, note);
copy_reg_eh_region_note_forward (note, NEXT_INSN (prev), next);
} | false | false | false | false | false | 0 |
saa7164_dump_hwdesc(struct saa7164_dev *dev)
{
dprintk(1, "@0x%p hwdesc sizeof(struct tmComResHWDescr) = %d bytes\n",
&dev->hwdesc, (u32)sizeof(struct tmComResHWDescr));
dprintk(1, " .bLength = 0x%x\n", dev->hwdesc.bLength);
dprintk(1, " .bDescriptorType = 0x%x\n", dev->hwdesc.bDescriptorType);
dprintk(1, " .bDescriptorSubtype = 0x%x\n",
dev->hwdesc.bDescriptorSubtype);
dprintk(1, " .bcdSpecVersion = 0x%x\n", dev->hwdesc.bcdSpecVersion);
dprintk(1, " .dwClockFrequency = 0x%x\n", dev->hwdesc.dwClockFrequency);
dprintk(1, " .dwClockUpdateRes = 0x%x\n", dev->hwdesc.dwClockUpdateRes);
dprintk(1, " .bCapabilities = 0x%x\n", dev->hwdesc.bCapabilities);
dprintk(1, " .dwDeviceRegistersLocation = 0x%x\n",
dev->hwdesc.dwDeviceRegistersLocation);
dprintk(1, " .dwHostMemoryRegion = 0x%x\n",
dev->hwdesc.dwHostMemoryRegion);
dprintk(1, " .dwHostMemoryRegionSize = 0x%x\n",
dev->hwdesc.dwHostMemoryRegionSize);
dprintk(1, " .dwHostHibernatMemRegion = 0x%x\n",
dev->hwdesc.dwHostHibernatMemRegion);
dprintk(1, " .dwHostHibernatMemRegionSize = 0x%x\n",
dev->hwdesc.dwHostHibernatMemRegionSize);
} | false | false | false | false | false | 0 |
output_arxiv( FILE *fp, fields *info )
{
newstr arxiv_url;
int i;
newstr_init( &arxiv_url );
for ( i=0; i<info->nfields; ++i ) {
if ( strcmp( info->tag[i].data, "ARXIV" ) ) continue;
arxiv_to_url( info, i, "URL", &arxiv_url );
if ( arxiv_url.len )
fprintf( fp, "%%U %s\n", arxiv_url.data );
}
newstr_free( &arxiv_url );
} | false | false | false | false | false | 0 |
SetOutputScalarType(int type)
{
double scalarMax;
vtkDebugMacro(<< this->GetClassName() << " (" << this <<
"): setting OutputScalarType to " << type);
scalarMax = this->GetScalarTypeMax(type);
if (scalarMax) // legal type
{
int modified = 0;
if (this->CapValue != scalarMax)
{
this->CapValue = scalarMax;
modified = 1;
}
if (this->OutputScalarType != type)
{
this->OutputScalarType = type;
modified = 1;
}
if (modified)
{
this->Modified();
}
}
} | false | false | false | false | false | 0 |
queue_destroy(struct queue *q) {
int n;
if(q) {
ferrcheck(pthread_mutex_lock(&q->m));
q->join = 1;
ferrcheck(pthread_cond_broadcast(&q->c)); /* all threads */
ferrcheck(pthread_mutex_unlock(&q->m));
for(n = 0; n < q->nthreads; ++n)
ferrcheck(pthread_join(q->threads[n], 0));
free(q->threads);
free(q);
}
} | false | false | false | false | false | 0 |
get_pos_bfd (bfd **contents, enum pos default_pos, const char *default_posname)
{
bfd **after_bfd = contents;
enum pos realpos;
const char *realposname;
if (postype == pos_default)
{
realpos = default_pos;
realposname = default_posname;
}
else
{
realpos = postype;
realposname = posname;
}
if (realpos == pos_end)
{
while (*after_bfd)
after_bfd = &((*after_bfd)->archive_next);
}
else
{
for (; *after_bfd; after_bfd = &(*after_bfd)->archive_next)
if (FILENAME_CMP ((*after_bfd)->filename, realposname) == 0)
{
if (realpos == pos_after)
after_bfd = &(*after_bfd)->archive_next;
break;
}
}
return after_bfd;
} | false | false | false | false | false | 0 |
SetHintBits(HeapTupleHeader tuple, Buffer buffer,
uint16 infomask, TransactionId xid)
{
if (TransactionIdIsValid(xid))
{
/* NB: xid must be known committed here! */
XLogRecPtr commitLSN = TransactionIdGetCommitLSN(xid);
if (XLogNeedsFlush(commitLSN))
return; /* not flushed yet, so don't set hint */
}
tuple->t_infomask |= infomask;
SetBufferCommitInfoNeedsSave(buffer);
} | false | false | false | false | false | 0 |
runOnFunction(Function &F) {
DEBUG(dbgs() << "[SafeStack] Function: " << F.getName() << "\n");
if (!F.hasFnAttribute(Attribute::SafeStack)) {
DEBUG(dbgs() << "[SafeStack] safestack is not requested"
" for this function\n");
return false;
}
if (F.isDeclaration()) {
DEBUG(dbgs() << "[SafeStack] function definition"
" is not available\n");
return false;
}
auto AA = &getAnalysis<AAResultsWrapperPass>().getAAResults();
TLI = TM ? TM->getSubtargetImpl(F)->getTargetLowering() : nullptr;
{
// Make sure the regular stack protector won't run on this function
// (safestack attribute takes precedence).
AttrBuilder B;
B.addAttribute(Attribute::StackProtect)
.addAttribute(Attribute::StackProtectReq)
.addAttribute(Attribute::StackProtectStrong);
F.removeAttributes(
AttributeSet::FunctionIndex,
AttributeSet::get(F.getContext(), AttributeSet::FunctionIndex, B));
}
if (AA->onlyReadsMemory(&F)) {
// XXX: we don't protect against information leak attacks for now.
DEBUG(dbgs() << "[SafeStack] function only reads memory\n");
return false;
}
++NumFunctions;
SmallVector<AllocaInst *, 16> StaticAllocas;
SmallVector<AllocaInst *, 4> DynamicAllocas;
SmallVector<ReturnInst *, 4> Returns;
// Collect all points where stack gets unwound and needs to be restored
// This is only necessary because the runtime (setjmp and unwind code) is
// not aware of the unsafe stack and won't unwind/restore it prorerly.
// To work around this problem without changing the runtime, we insert
// instrumentation to restore the unsafe stack pointer when necessary.
SmallVector<Instruction *, 4> StackRestorePoints;
// Find all static and dynamic alloca instructions that must be moved to the
// unsafe stack, all return instructions and stack restore points.
findInsts(F, StaticAllocas, DynamicAllocas, Returns, StackRestorePoints);
if (StaticAllocas.empty() && DynamicAllocas.empty() &&
StackRestorePoints.empty())
return false; // Nothing to do in this function.
if (!StaticAllocas.empty() || !DynamicAllocas.empty())
++NumUnsafeStackFunctions; // This function has the unsafe stack.
if (!StackRestorePoints.empty())
++NumUnsafeStackRestorePointsFunctions;
IRBuilder<> IRB(&F.front(), F.begin()->getFirstInsertionPt());
UnsafeStackPtr = getOrCreateUnsafeStackPtr(IRB, F);
// The top of the unsafe stack after all unsafe static allocas are allocated.
Value *StaticTop = moveStaticAllocasToUnsafeStack(IRB, F, StaticAllocas, Returns);
// Safe stack object that stores the current unsafe stack top. It is updated
// as unsafe dynamic (non-constant-sized) allocas are allocated and freed.
// This is only needed if we need to restore stack pointer after longjmp
// or exceptions, and we have dynamic allocations.
// FIXME: a better alternative might be to store the unsafe stack pointer
// before setjmp / invoke instructions.
AllocaInst *DynamicTop = createStackRestorePoints(
IRB, F, StackRestorePoints, StaticTop, !DynamicAllocas.empty());
// Handle dynamic allocas.
moveDynamicAllocasToUnsafeStack(F, UnsafeStackPtr, DynamicTop,
DynamicAllocas);
DEBUG(dbgs() << "[SafeStack] safestack applied\n");
return true;
} | false | false | false | false | false | 0 |
start()
{
//FIXME: QHASH
QMap<QString, QVariant> params = parameters();
QString valueGroup = params["group"].toString();
if (valueGroup.isEmpty()) {
valueGroup = "default";
}
QWeakPointer<StorageJob> me(this);
if (operationName() == "save") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "save", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else if (operationName() == "retrieve") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else if (operationName() == "delete") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else if (operationName() == "expire") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else {
setError(true);
setResult(false);
}
} | false | false | false | false | false | 0 |
autohelperowl_defendpat282(int trans, int move, int color, int action)
{
int c, d, A, B;
UNUSED(color);
UNUSED(action);
c = AFFINE_TRANSFORM(720, trans, move);
d = AFFINE_TRANSFORM(722, trans, move);
A = AFFINE_TRANSFORM(683, trans, move);
B = AFFINE_TRANSFORM(685, trans, move);
return (countlib(A)<=3 && accuratelib(c, color, MAX_LIBERTIES, NULL)>2) || (countlib(B)<=3 && accuratelib(d, color, MAX_LIBERTIES, NULL)>2);
} | false | false | false | false | false | 0 |
soc_probe(struct platform_device *pdev)
{
struct snd_soc_card *card = platform_get_drvdata(pdev);
/*
* no card, so machine driver should be registering card
* we should not be here in that case so ret error
*/
if (!card)
return -EINVAL;
dev_warn(&pdev->dev,
"ASoC: machine %s should use snd_soc_register_card()\n",
card->name);
/* Bodge while we unpick instantiation */
card->dev = &pdev->dev;
return snd_soc_register_card(card);
} | false | false | false | false | false | 0 |
yy_setstream(FILE *stream)
{
int i;
#define MAX_STREAMS 16
static struct {
FILE *stream;
YY_BUFFER_STATE buffer;
} streams[MAX_STREAMS] = { {NULL, NULL}, };
static int num_streams = 0;
static FILE *last_stream = NULL;
/* same stream? */
if (stream == last_stream)
return;
/* else, switch to new stream */
for (i=0; i < num_streams; i++)
{
if (streams[i].stream == stream)
{
yy_switch_to_buffer(streams[i].buffer);
return;
}
}
/* hrmmm... not found, create a new buffer for this stream */
if (num_streams == MAX_STREAMS)
fatal("out of lex buffer streams, increase MAX_STREAMS");
streams[num_streams].stream = stream;
streams[num_streams].buffer = yy_create_buffer(stream, YY_BUF_SIZE);
yy_switch_to_buffer(streams[num_streams].buffer);
num_streams++;
} | false | false | false | false | false | 0 |
iwl_mvm_tof_range_abort_cmd(struct iwl_mvm *mvm, u8 id)
{
struct iwl_tof_range_abort_cmd cmd = {
.sub_grp_cmd_id = cpu_to_le32(TOF_RANGE_ABORT_CMD),
.request_id = id,
};
lockdep_assert_held(&mvm->mutex);
if (!fw_has_capa(&mvm->fw->ucode_capa, IWL_UCODE_TLV_CAPA_TOF_SUPPORT))
return -EINVAL;
if (id != mvm->tof_data.active_range_request) {
IWL_ERR(mvm, "Invalid range request id %d (active %d)\n",
id, mvm->tof_data.active_range_request);
return -EINVAL;
}
/* after abort is sent there's no active request anymore */
mvm->tof_data.active_range_request = IWL_MVM_TOF_RANGE_REQ_MAX_ID;
return iwl_mvm_send_cmd_pdu(mvm, iwl_cmd_id(TOF_CMD,
IWL_ALWAYS_LONG_GROUP, 0),
0, sizeof(cmd), &cmd);
} | false | false | false | false | false | 0 |
linkGlobalProto(GlobalVariable *SGV) {
GlobalValue *DGV = getLinkedToGlobal(SGV);
if (DGV) {
// Concatenation of appending linkage variables is magic and handled later.
if (DGV->hasAppendingLinkage() || SGV->hasAppendingLinkage())
return linkAppendingVarProto(cast<GlobalVariable>(DGV), SGV);
// Determine whether linkage of these two globals follows the source
// module's definition or the destination module's definition.
GlobalValue::LinkageTypes NewLinkage = GlobalValue::InternalLinkage;
bool LinkFromSrc = false;
if (getLinkageResult(DGV, SGV, NewLinkage, LinkFromSrc))
return true;
// If we're not linking from the source, then keep the definition that we
// have.
if (!LinkFromSrc) {
// Special case for const propagation.
if (GlobalVariable *DGVar = dyn_cast<GlobalVariable>(DGV))
if (DGVar->isDeclaration() && SGV->isConstant() && !DGVar->isConstant())
DGVar->setConstant(true);
// Set calculated linkage.
DGV->setLinkage(NewLinkage);
// Make sure to remember this mapping.
ValueMap[SGV] = ConstantExpr::getBitCast(DGV,TypeMap.get(SGV->getType()));
// Track the source global so that we don't attempt to copy it over when
// processing global initializers.
DoNotLinkFromSource.insert(SGV);
return false;
}
}
// No linking to be performed or linking from the source: simply create an
// identical version of the symbol over in the dest module... the
// initializer will be filled in later by LinkGlobalInits.
GlobalVariable *NewDGV =
new GlobalVariable(*DstM, TypeMap.get(SGV->getType()->getElementType()),
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
SGV->getName(), /*insertbefore*/0,
SGV->isThreadLocal(),
SGV->getType()->getAddressSpace());
// Propagate alignment, visibility and section info.
CopyGVAttributes(NewDGV, SGV);
if (DGV) {
DGV->replaceAllUsesWith(ConstantExpr::getBitCast(NewDGV, DGV->getType()));
DGV->eraseFromParent();
}
// Make sure to remember this mapping.
ValueMap[SGV] = NewDGV;
return false;
} | false | false | false | false | false | 0 |
set_hmdf_info( Hmdf_information *hmdf_info, int pc_num, int pe_num )
{
if( pc_num > 1 ){
hmdf_info->kind = TYPE_MDF;
hmdf_info->pe_num = pe_num;
hmdf_info->pc_num = pc_num;
}else if( pe_num > 1 ){
hmdf_info->kind = TYPE_INNER;
hmdf_info->pe_num = pe_num;
hmdf_info->pc_num = pc_num;
}else{
hmdf_info->kind = TYPE_NON;
hmdf_info->pe_num = pe_num;
hmdf_info->pc_num = pc_num;
}
} | false | false | false | false | false | 0 |
isocs7planes (void)
{
return !(currprefs.chipset_mask & CSMASK_AGA) && bplcon0_res == 0 && bplcon0_planes == 7;
} | false | false | false | false | false | 0 |
draw_cal(void)
{
gchar *utf8, *cal_string;
gint w, h;
if (!cal_enable)
return;
cal_string = strftime_format(cal_format, cal_alt_color_string);
if (!g_utf8_validate(cal_string, -1, NULL))
{
if ((utf8 = g_locale_to_utf8(cal_string, -1, NULL, NULL, NULL))
!= NULL)
{
g_free(cal_string);
cal_string = utf8;
}
}
/* Get string extents in case a string change => need to resize the
| panel. A string change can also change the decal y_ink (possibly
| without changing decal size).
*/
gkrellm_text_markup_extents(d_cal->text_style.font,
cal_string, strlen(cal_string), &w, &h, NULL, &d_cal->y_ink);
w += d_cal->text_style.effect;
if (h + d_cal->text_style.effect != d_cal->h)
{
gkrellm_panel_destroy(pcal);
create_calendar_panel(cal_vbox, TRUE);
}
gkrellm_draw_decal_markup(pcal, d_cal, cal_string);
gkrellm_decal_text_set_offset(d_cal, (d_cal->w - w) / 2, 0);
gkrellm_draw_panel_layers(pcal);
g_free(cal_string);
} | false | false | false | false | false | 0 |
NewFunctionFromSharedFunctionInfo(
Handle<SharedFunctionInfo> function_info,
Handle<Context> context,
PretenureFlag pretenure) {
Handle<JSFunction> result = BaseNewFunctionFromSharedFunctionInfo(
function_info, Top::function_map(), pretenure);
result->set_context(*context);
int number_of_literals = function_info->num_literals();
Handle<FixedArray> literals =
Factory::NewFixedArray(number_of_literals, pretenure);
if (number_of_literals > 0) {
// Store the object, regexp and array functions in the literals
// array prefix. These functions will be used when creating
// object, regexp and array literals in this function.
literals->set(JSFunction::kLiteralGlobalContextIndex,
context->global_context());
}
result->set_literals(*literals);
ASSERT(!result->IsBoilerplate());
return result;
} | false | false | false | false | false | 0 |
output_13 (rtx *operands ATTRIBUTE_UNUSED, rtx insn ATTRIBUTE_UNUSED)
{
{
switch (which_alternative)
{
case 0:
return "sub.l %S0,%S0";
case 7:
return "clrmac";
case 8:
return "clrmac\n\tldmac %1,macl";
case 9:
return "stmac macl,%0";
default:
if (GET_CODE (operands[1]) == CONST_INT)
{
int val = INTVAL (operands[1]);
/* Look for constants which can be made by adding an 8-bit
number to zero in one of the two low bytes. */
if (val == (val & 0xff))
{
operands[1] = GEN_INT ((char) val & 0xff);
return "sub.l\t%S0,%S0\n\tadd.b\t%1,%w0";
}
if (val == (val & 0xff00))
{
operands[1] = GEN_INT ((char) (val >> 8) & 0xff);
return "sub.l\t%S0,%S0\n\tadd.b\t%1,%x0";
}
/* Look for constants that can be obtained by subs, inc, and
dec to 0. */
switch (val & 0xffffffff)
{
case 0xffffffff:
return "sub.l\t%S0,%S0\n\tsubs\t#1,%S0";
case 0xfffffffe:
return "sub.l\t%S0,%S0\n\tsubs\t#2,%S0";
case 0xfffffffc:
return "sub.l\t%S0,%S0\n\tsubs\t#4,%S0";
case 0x0000ffff:
return "sub.l\t%S0,%S0\n\tdec.w\t#1,%f0";
case 0x0000fffe:
return "sub.l\t%S0,%S0\n\tdec.w\t#2,%f0";
case 0xffff0000:
return "sub.l\t%S0,%S0\n\tdec.w\t#1,%e0";
case 0xfffe0000:
return "sub.l\t%S0,%S0\n\tdec.w\t#2,%e0";
case 0x00010000:
return "sub.l\t%S0,%S0\n\tinc.w\t#1,%e0";
case 0x00020000:
return "sub.l\t%S0,%S0\n\tinc.w\t#2,%e0";
}
}
}
return "mov.l %S1,%S0";
}
} | false | false | false | false | false | 0 |
add_vars_to_targetlist(PlannerInfo *root, List *vars,
Relids where_needed, bool create_new_ph)
{
ListCell *temp;
Assert(!bms_is_empty(where_needed));
foreach(temp, vars)
{
Node *node = (Node *) lfirst(temp);
if (IsA(node, Var))
{
Var *var = (Var *) node;
RelOptInfo *rel = find_base_rel(root, var->varno);
int attno = var->varattno;
Assert(attno >= rel->min_attr && attno <= rel->max_attr);
attno -= rel->min_attr;
if (rel->attr_needed[attno] == NULL)
{
/* Variable not yet requested, so add to reltargetlist */
/* XXX is copyObject necessary here? */
rel->reltargetlist = lappend(rel->reltargetlist,
copyObject(var));
}
rel->attr_needed[attno] = bms_add_members(rel->attr_needed[attno],
where_needed);
}
else if (IsA(node, PlaceHolderVar))
{
PlaceHolderVar *phv = (PlaceHolderVar *) node;
PlaceHolderInfo *phinfo = find_placeholder_info(root, phv,
create_new_ph);
/* Always adjust ph_needed */
phinfo->ph_needed = bms_add_members(phinfo->ph_needed,
where_needed);
/*
* If we are creating PlaceHolderInfos, mark them with the
* correct maybe-needed locations. Otherwise, it's too late to
* change that.
*/
if (create_new_ph)
mark_placeholder_maybe_needed(root, phinfo, where_needed);
}
else
elog(ERROR, "unrecognized node type: %d", (int) nodeTag(node));
}
} | false | false | false | false | false | 0 |
NonNullIdentSeqs(register e_type E1, register e_type E2)
/** If E1 has the same sequence as E2 return TRUE; else return FALSE **/
{
register long s,r1,r2;
if(E1->n != E2->n) return FALSE;
for(s=1; s<= (long) E1->n; s++){
r1 = E1->X[s]; r2 = E2->X[s];
if(r1 != 0 && r2 != 0 && r1 != r2) return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
ZB_fillTriangleFlat(ZBuffer *zb, ZBufferPoint *p0, ZBufferPoint *p1, ZBufferPoint *p2) {
int color;
#define INTERP_Z
#define DRAW_INIT() \
{ \
color = RGB_TO_PIXEL(p2->r, p2->g, p2->b); \
}
#define PUT_PIXEL(_a) \
{ \
zz = z >> ZB_POINT_Z_FRAC_BITS; \
if (ZCMP(zz, pz[_a])) { \
pp[_a] = color; \
pz[_a] = zz; \
} \
z += dzdx; \
}
#include "ztriangle.h"
} | false | false | false | false | false | 0 |
safe_setter(val)
VALUE val;
{
int level = NUM2INT(val);
if (level < ruby_safe_level) {
rb_raise(rb_eSecurityError, "tried to downgrade safe level from %d to %d",
ruby_safe_level, level);
}
if (level > SAFE_LEVEL_MAX) level = SAFE_LEVEL_MAX;
ruby_safe_level = level;
curr_thread->safe = level;
} | false | false | false | false | false | 0 |
antlr3BitsetLoad(pANTLR3_BITSET_LIST inBits)
{
pANTLR3_BITSET bitset;
ANTLR3_UINT32 count;
// Allocate memory for the bitset structure itself
// the input parameter is the bit number (0 based)
// to include in the bitset, so we need at at least
// bit + 1 bits. If any arguments indicate a
// a bit higher than the default number of bits (0 means default size)
// then Add() will take care
// of it.
//
bitset = antlr3BitsetNew(0);
if (bitset == NULL)
{
return NULL;
}
if (inBits != NULL)
{
// Now we can add the element bits into the set
//
count=0;
while (count < inBits->length)
{
if (bitset->blist.length <= count)
{
bitset->grow(bitset, count+1);
}
bitset->blist.bits[count] = *((inBits->bits)+count);
count++;
}
}
// return the new bitset
//
return bitset;
} | false | false | false | false | false | 0 |
denotation_mode (MOID_T * m)
{
if (primitive_mode (m)) {
return (A68_TRUE);
} else if (LONG_MODE (m) && long_mode_allowed) {
return (A68_TRUE);
} else {
return (A68_FALSE);
}
} | false | false | false | false | false | 0 |
append (const OFString& str, size_t pos, size_t n)
{
OFString b(str, pos, n);
this->reserve(this->size() + b.size());
// We can't use strcat() because some string could contain NULL bytes
// We need size() + 1 so that the EOS mark is copied over, too
OFBitmanipTemplate<char>::copyMem(b.theCString, this->theCString + this->size(), b.size() + 1);
this->theSize += b.size();
return *this;
} | false | false | false | false | false | 0 |
setControllerRect(const QString &controllerName, const QRectF &rect)
{
if (d->mControllerMap[controllerName]) {
d->mControllerMap[controllerName]->setViewRect(rect);
}
QDomElement widget = d->mSessionTree->createElement("widget");
widget.setAttribute("controller", controllerName);
QDomElement geometry = d->mSessionTree->createElement("geometry");
geometry.setAttribute("x", rect.x());
geometry.setAttribute("y", rect.y());
geometry.setAttribute("width", rect.width());
geometry.setAttribute("height", rect.height());
widget.appendChild(geometry);
d->mRootElement.appendChild(widget);
Q_EMIT sessionUpdated(d->mSessionTree->toString());
} | false | false | false | false | false | 0 |
mainwin_destroy_cb(GtkObject *object UNUSED, gpointer data UNUSED)
{
/* Don't write messages to the GUI anymore */
full_screen = FALSE;
gui.mainwin = NULL;
gui.drawarea = NULL;
if (!exiting) /* only do anything if the destroy was unexpected */
{
vim_strncpy(IObuff,
(char_u *)_("Vim: Main window unexpectedly destroyed\n"),
IOSIZE - 1);
preserve_exit();
}
} | false | false | false | false | false | 0 |
blkid_probe_is_wholedisk(blkid_probe pr)
{
dev_t devno, disk_devno;
devno = blkid_probe_get_devno(pr);
if (!devno)
return 0;
disk_devno = blkid_probe_get_wholedisk_devno(pr);
if (!disk_devno)
return 0;
return devno == disk_devno;
} | false | false | false | false | false | 0 |
setMasterClock(unsigned int frequency)
{
unsigned int ulReg, divisor;
/* Cheok_0509: For SM750LE, the memory clock is fixed. Nothing to set. */
if (getChipType() == SM750LE)
return;
if (frequency) {
/* Set the frequency to the maximum frequency that the SM750 engine can
run, which is about 190 MHz. */
if (frequency > MHz(190))
frequency = MHz(190);
/* Calculate the divisor */
divisor = roundedDiv(get_mxclk_freq(), frequency);
/* Set the corresponding divisor in the register. */
ulReg = PEEK32(CURRENT_GATE);
switch (divisor) {
default:
case 3:
ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_3);
break;
case 4:
ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_4);
break;
case 6:
ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_6);
break;
case 8:
ulReg = FIELD_SET(ulReg, CURRENT_GATE, MCLK, DIV_8);
break;
}
setCurrentGate(ulReg);
}
} | false | false | false | false | false | 0 |
_glewInit_GL_EXT_fragment_lighting (GLEW_CONTEXT_ARG_DEF_INIT)
{
GLboolean r = GL_FALSE;
r = ((glFragmentColorMaterialEXT = (PFNGLFRAGMENTCOLORMATERIALEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentColorMaterialEXT")) == NULL) || r;
r = ((glFragmentLightModelfEXT = (PFNGLFRAGMENTLIGHTMODELFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfEXT")) == NULL) || r;
r = ((glFragmentLightModelfvEXT = (PFNGLFRAGMENTLIGHTMODELFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelfvEXT")) == NULL) || r;
r = ((glFragmentLightModeliEXT = (PFNGLFRAGMENTLIGHTMODELIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModeliEXT")) == NULL) || r;
r = ((glFragmentLightModelivEXT = (PFNGLFRAGMENTLIGHTMODELIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightModelivEXT")) == NULL) || r;
r = ((glFragmentLightfEXT = (PFNGLFRAGMENTLIGHTFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfEXT")) == NULL) || r;
r = ((glFragmentLightfvEXT = (PFNGLFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightfvEXT")) == NULL) || r;
r = ((glFragmentLightiEXT = (PFNGLFRAGMENTLIGHTIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightiEXT")) == NULL) || r;
r = ((glFragmentLightivEXT = (PFNGLFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentLightivEXT")) == NULL) || r;
r = ((glFragmentMaterialfEXT = (PFNGLFRAGMENTMATERIALFEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfEXT")) == NULL) || r;
r = ((glFragmentMaterialfvEXT = (PFNGLFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialfvEXT")) == NULL) || r;
r = ((glFragmentMaterialiEXT = (PFNGLFRAGMENTMATERIALIEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialiEXT")) == NULL) || r;
r = ((glFragmentMaterialivEXT = (PFNGLFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glFragmentMaterialivEXT")) == NULL) || r;
r = ((glGetFragmentLightfvEXT = (PFNGLGETFRAGMENTLIGHTFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightfvEXT")) == NULL) || r;
r = ((glGetFragmentLightivEXT = (PFNGLGETFRAGMENTLIGHTIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentLightivEXT")) == NULL) || r;
r = ((glGetFragmentMaterialfvEXT = (PFNGLGETFRAGMENTMATERIALFVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialfvEXT")) == NULL) || r;
r = ((glGetFragmentMaterialivEXT = (PFNGLGETFRAGMENTMATERIALIVEXTPROC)glewGetProcAddress((const GLubyte*)"glGetFragmentMaterialivEXT")) == NULL) || r;
r = ((glLightEnviEXT = (PFNGLLIGHTENVIEXTPROC)glewGetProcAddress((const GLubyte*)"glLightEnviEXT")) == NULL) || r;
return r;
} | false | false | false | false | false | 0 |
GWEN_Directory_FindPathForFile(const GWEN_STRINGLIST *paths,
const char *filePath,
GWEN_BUFFER *fbuf) {
GWEN_STRINGLISTENTRY *se;
se=GWEN_StringList_FirstEntry(paths);
while(se) {
GWEN_BUFFER *tbuf;
FILE *f;
tbuf=GWEN_Buffer_new(0, 256, 0, 1);
GWEN_Buffer_AppendString(tbuf, GWEN_StringListEntry_Data(se));
GWEN_Buffer_AppendString(tbuf, DIRSEP);
GWEN_Buffer_AppendString(tbuf, filePath);
DBG_VERBOUS(GWEN_LOGDOMAIN, "Trying \"%s\"",
GWEN_Buffer_GetStart(tbuf));
f=fopen(GWEN_Buffer_GetStart(tbuf), "r");
if (f) {
fclose(f);
DBG_INFO(GWEN_LOGDOMAIN,
"File \"%s\" found in folder \"%s\"",
filePath,
GWEN_StringListEntry_Data(se));
GWEN_Buffer_AppendString(fbuf, GWEN_StringListEntry_Data(se));
GWEN_Buffer_free(tbuf);
return 0;
}
GWEN_Buffer_free(tbuf);
se=GWEN_StringListEntry_Next(se);
}
DBG_INFO(GWEN_LOGDOMAIN, "File \"%s\" not found", filePath);
return GWEN_ERROR_NOT_FOUND;
} | false | false | false | false | true | 1 |
test_round_near_x (void)
{
mpfr_t x, y, z, eps;
mpfr_exp_t e;
int failures = 0, mx, neg, err, dir, r, inex, inex2;
char buffer[7], *p;
mpfr_inits (x, y, z, eps, (mpfr_ptr) 0);
mpfr_set_prec (x, 5);
mpfr_set_prec (y, 3);
mpfr_set_prec (z, 3);
mpfr_set_prec (eps, 2);
mpfr_set_ui_2exp (eps, 1, -32, MPFR_RNDN);
for (mx = 16; mx < 32; mx++)
{
mpfr_set_ui_2exp (x, mx, -2, MPFR_RNDN);
for (p = buffer, neg = 0;
neg <= 1;
mpfr_neg (x, x, MPFR_RNDN), p++, neg++)
for (err = 2; err <= 6; err++)
for (dir = 0; dir <= 1; dir++)
RND_LOOP(r)
{
inex = mpfr_round_near_x (y, x, err, dir, (mpfr_rnd_t) r);
if (inex == 0 && err < 6)
{
/* The test is more restrictive than necessary.
So, no failure in this case. */
continue;
}
inex2 = ((dir ^ neg) ? mpfr_add : mpfr_sub)
(z, x, eps, (mpfr_rnd_t) r);
if (inex * inex2 <= 0)
printf ("Bad return value (%d instead of %d) for:\n",
inex, inex2);
else if (mpfr_equal_p (y, z))
continue; /* correct inex and y */
else
{
printf ("Bad MPFR value (should have got ");
mpfr_out_str (stdout, 2, 3, z, MPFR_RNDZ);
printf (") for:\n");
}
if (!mpfr_get_str (buffer, &e, 2, 5, x, MPFR_RNDZ) || e != 3)
{
printf ("mpfr_get_str failed in test_round_near_x\n");
exit (1);
}
printf ("x = %c%c%c%c.%c%c, ", neg ? '-' : '+',
p[0], p[1], p[2], p[3], p[4]);
printf ("err = %d, dir = %d, r = %s --> inex = %2d",
err, dir, mpfr_print_rnd_mode ((mpfr_rnd_t) r), inex);
if (inex != 0)
{
printf (", y = ");
mpfr_out_str (stdout, 2, 3, y, MPFR_RNDZ);
}
printf ("\n");
if (inex == 0)
printf ("Rounding was possible!\n");
if (++failures == 10) /* show at most 10 failures */
exit (1);
}
}
if (failures)
exit (1);
mpfr_clears (x, y, z, eps, (mpfr_ptr) 0);
} | true | true | false | false | false | 1 |
requestFinished(int id, bool error)
{
if (id == requestID)
{
requestID = -1;
buffer->seek(0);
QString result_txt = buffer->readAll();
delete buffer;
QRegExp redir("%%\\s+GLE-Redirect:\\s+(\\S+)\\s+(\\S+)");
if (!error && redir.indexIn(result_txt) != -1)
{
QString url = redir.capturedTexts()[1];
QString script = redir.capturedTexts()[2];
performRequest(url, script);
}
else
{
QString err_s = http->errorString();
QDialog mydial(this);
mydial.setWindowTitle("GLE Internal Error");
QVBoxLayout *layout = new QVBoxLayout();
layout->addWidget(new QLabel(tr("Result of sending report:")));
QTextBrowser* txt = new QTextBrowser();
txt->setOpenLinks(false);
txt->setReadOnly(TRUE);
if (error) txt->insertPlainText(err_s);
else txt->setPlainText(result_txt);
layout->addWidget(txt);
QPushButton *okButton = new QPushButton(tr("Close"));
connect(okButton, SIGNAL(clicked()), &mydial, SLOT(close()));
QHBoxLayout *buttonLayout = new QHBoxLayout();
buttonLayout->addStretch(1);
buttonLayout->addWidget(okButton);
layout->addLayout(buttonLayout);
mydial.setLayout(layout);
QRect size = QApplication::desktop()->screenGeometry(&mydial);
mydial.resize(size.width()/3, size.height()/3);
mydial.exec();
close();
}
}
} | false | false | false | false | false | 0 |
report_flush(FILE *errfp)
{
if (partial_message_size_used != 0)
{
partial_message_size_used = 0;
report(errfp, "%s", partial_message);
partial_suppress_tag = 1;
}
} | false | false | false | false | true | 1 |
OnEditorActivatedTimer(cb_unused wxTimerEvent& event)
{
// the m_LastEditor variable was updated in CodeCompletion::OnEditorActivated, after that,
// the editor-activated-timer was started. So, here in the timer handler, we need to check
// whether the saved editor and the current editor are the same, otherwise, no need to update
// the toolbar, because there must be another editor activated before the timer hits.
// Note: only the builtin editor was considered.
EditorBase* editor = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
if (!editor || editor != m_LastEditor)
{
TRACE(_T("CodeCompletion::OnEditorActivatedTimer(): Not a builtin editor."));
//m_LastEditor = nullptr;
EnableToolbarTools(false);
return;
}
const wxString& curFile = editor->GetFilename();
// if the same file was activated, no need to update the toolbar
if ( !m_LastFile.IsEmpty() && m_LastFile == curFile )
{
TRACE(_T("CodeCompletion::OnEditorActivatedTimer(): Same as the last activated file(%s)."), curFile.wx_str());
return;
}
TRACE(_T("CodeCompletion::OnEditorActivatedTimer(): Need to notify NativeParser and Refresh toolbar."));
m_NativeParser.OnEditorActivated(editor);
TRACE(_T("CodeCompletion::OnEditorActivatedTimer: Starting m_TimerToolbar."));
m_TimerToolbar.Start(TOOLBAR_REFRESH_DELAY, wxTIMER_ONE_SHOT);
TRACE(_T("CodeCompletion::OnEditorActivatedTimer(): Current activated file is %s"), curFile.wx_str());
UpdateEditorSyntax();
} | false | false | false | false | false | 0 |
v9fs_cache_inode_get_cookie(struct inode *inode)
{
struct v9fs_inode *v9inode;
struct v9fs_session_info *v9ses;
if (!S_ISREG(inode->i_mode))
return;
v9inode = V9FS_I(inode);
if (v9inode->fscache)
return;
v9ses = v9fs_inode2v9ses(inode);
v9inode->fscache = fscache_acquire_cookie(v9ses->fscache,
&v9fs_cache_inode_index_def,
v9inode, true);
p9_debug(P9_DEBUG_FSC, "inode %p get cookie %p\n",
inode, v9inode->fscache);
} | false | false | false | false | false | 0 |
VisitCodeTarget(RelocInfo* rinfo) {
CHECK(RelocInfo::IsCodeTarget(rinfo->rmode()));
Address target_start = rinfo->target_address_address();
OutputRawData(target_start);
Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
serializer_->SerializeObject(target, kFromCode, kFirstInstruction);
bytes_processed_so_far_ += rinfo->target_address_size();
} | false | false | false | false | false | 0 |
nm_vpn_manager_activate_connection (NMVPNManager *manager,
NMConnection *connection,
NMDevice *device,
const char *specific_object,
gboolean user_requested,
gulong user_uid,
GError **error)
{
NMSettingVPN *vpn_setting;
NMVPNService *service;
NMVPNConnection *vpn = NULL;
const char *service_name;
g_return_val_if_fail (NM_IS_VPN_MANAGER (manager), NULL);
g_return_val_if_fail (NM_IS_CONNECTION (connection), NULL);
g_return_val_if_fail (NM_IS_DEVICE (device), NULL);
g_return_val_if_fail (error != NULL, NULL);
g_return_val_if_fail (*error == NULL, NULL);
if ( nm_device_get_state (device) != NM_DEVICE_STATE_ACTIVATED
&& nm_device_get_state (device) != NM_DEVICE_STATE_SECONDARIES) {
g_set_error (error,
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_DEVICE_NOT_ACTIVE,
"%s", "The base device for the VPN connection was not active.");
return NULL;
}
vpn_setting = nm_connection_get_setting_vpn (connection);
if (!vpn_setting) {
g_set_error (error,
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_CONNECTION_INVALID,
"%s", "The connection was not a VPN connection.");
return NULL;
}
vpn = find_active_vpn_connection_by_connection (manager, connection);
if (vpn) {
nm_vpn_connection_disconnect (vpn, NM_VPN_CONNECTION_STATE_REASON_USER_DISCONNECTED);
vpn = NULL;
}
service_name = nm_setting_vpn_get_service_type (vpn_setting);
g_assert (service_name);
service = g_hash_table_lookup (NM_VPN_MANAGER_GET_PRIVATE (manager)->services, service_name);
if (!service) {
g_set_error (error,
NM_VPN_MANAGER_ERROR, NM_VPN_MANAGER_ERROR_SERVICE_INVALID,
"The VPN service '%s' was not installed.",
service_name);
return NULL;
}
return (NMActiveConnection *) nm_vpn_service_activate (service,
connection,
device,
specific_object,
user_requested,
user_uid,
error);
} | false | false | false | false | false | 0 |
named_datatype_free(named_dt_t **named_dt_head_p, int ignore_err)
{
named_dt_t *dt = *named_dt_head_p;
while(dt)
{
/* Pop the datatype off the stack and free it */
if(H5Tclose(dt->id_out) < 0 && !ignore_err)
goto error;
dt = dt->next;
HDfree(*named_dt_head_p);
*named_dt_head_p = dt;
} /* end while */
return 0;
error:
return -1;
} | false | false | false | false | false | 0 |
FindIndex(pkgCache::PkgFileIterator File,
pkgIndexFile *&Found) const
{
for (const_iterator I = SrcList.begin(); I != SrcList.end(); ++I)
{
vector<pkgIndexFile *> *Indexes = (*I)->GetIndexFiles();
for (vector<pkgIndexFile *>::const_iterator J = Indexes->begin();
J != Indexes->end(); ++J)
{
if ((*J)->FindInCache(*File.Cache()) == File)
{
Found = (*J);
return true;
}
}
}
return false;
} | false | false | false | false | false | 0 |
AddUnfiltered(const CUInt128& id, uint32_t ip, uint16_t port, uint16_t tport, uint8_t version, const CKadUDPKey& key, bool& ipVerified, bool update, bool fromHello, bool fromNodesDat /* = false */)
#endif
// ADUNANZA END
{
if (id != me) {
CContact *contact = new CContact(id, ip, port, tport, version, key, ipVerified);
// ADUNANZA BEGIN
// per mantenimento KAD1
if (fromNodesDat) {
contact->CheckIfKad2();
}
else
// ADUNANZA END
if (fromHello) {
contact->SetReceivedHelloPacket();
}
if (Add(contact, update, ipVerified)) {
wxASSERT(!update);
return true;
} else {
delete contact;
return update;
}
}
return false;
} | 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.