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 |
|---|---|---|---|---|---|---|
afr_sh_find_fresh_parents (call_frame_t *frame, xlator_t *this,
int32_t op_ret, int32_t op_errno)
{
afr_self_heal_t *sh = NULL;
afr_private_t *priv = NULL;
afr_local_t *local = NULL;
int enoent_count = 0;
int nsources = 0;
int source = -1;
local = frame->local;
sh = &local->self_heal;
priv = this->private;
/* If We can't find a fresh parent directory here,
* we wont know which subvol is correct without finding a parent dir
* upwards which has correct xattrs, for that we may have to
* do lookups till root, we dont wanna do that,
* instead make sure that if there are conflicting gfid
* parent dirs, self-heal thus lookup is failed with EIO.
* if there are missing entries we dont know whether to delete or
* create so fail with EIO,
* If there are conflicting xattr fail with EIO.
*/
if (op_ret < 0)
goto out;
enoent_count = afr_errno_count (NULL, sh->child_errno,
priv->child_count, ENOENT);
if (enoent_count > 0) {
gf_log (this->name, GF_LOG_ERROR, "Parent dir missing for %s,"
" in missing entry self-heal, aborting self-heal",
local->loc.path);
goto out;
}
nsources = afr_build_sources (this, sh->xattr, sh->buf,
sh->pending_matrix, sh->sources,
sh->success_children,
AFR_ENTRY_TRANSACTION);
if (nsources < 0) {
gf_log (this->name, GF_LOG_ERROR, "No sources for dir of %s,"
" in missing entry self-heal, aborting self-heal",
local->loc.path);
goto out;
}
source = afr_sh_select_source (sh->sources, priv->child_count);
if (source == -1) {
GF_ASSERT (0);
gf_log (this->name, GF_LOG_DEBUG, "No active sources found.");
goto out;
}
afr_get_fresh_children (sh->success_children, sh->sources,
sh->fresh_parent_dirs, priv->child_count);
afr_sh_common_lookup (frame, this, &local->loc,
afr_sh_children_lookup_done, NULL, 0);
return;
out:
afr_sh_set_error (sh, EIO);
sh->op_failed = 1;
afr_sh_missing_entries_finish (frame, this);
return;
} | false | false | false | false | false | 0 |
show_ce_entry(const char *tag, struct cache_entry *ce)
{
int len = prefix_len;
int offset = prefix_offset;
if (len >= ce_namelen(ce))
die("git-ls-files: internal error - cache entry not superset of prefix");
if (pathspec && !match(pathspec, ps_matched, ce->name, len))
return;
if (tag && *tag && show_valid_bit &&
(ce->ce_flags & htons(CE_VALID))) {
static char alttag[4];
memcpy(alttag, tag, 3);
if (isalpha(tag[0]))
alttag[0] = tolower(tag[0]);
else if (tag[0] == '?')
alttag[0] = '!';
else {
alttag[0] = 'v';
alttag[1] = tag[0];
alttag[2] = ' ';
alttag[3] = 0;
}
tag = alttag;
}
if (!show_stage) {
fputs(tag, stdout);
write_name_quoted("", 0, ce->name + offset,
line_terminator, stdout);
putchar(line_terminator);
}
else {
printf("%s%06o %s %d\t",
tag,
ntohl(ce->ce_mode),
abbrev ? find_unique_abbrev(ce->sha1,abbrev)
: sha1_to_hex(ce->sha1),
ce_stage(ce));
write_name_quoted("", 0, ce->name + offset,
line_terminator, stdout);
putchar(line_terminator);
}
} | false | false | false | false | false | 0 |
crypto_cipher_encrypt_init_cipher(crypto_cipher_t *env)
{
tor_assert(env);
aes_set_key(env->cipher, env->key, CIPHER_KEY_LEN*8);
return 0;
} | false | false | false | false | false | 0 |
CVectorRemoveElement(const CVectorHandle vectorhandle, const size_t index) {
if ((vectorhandle==NULL)) { return CVECTOR_BAD_ARGUMENT; }
if ((vectorhandle->flags&CVECTOR_FLAGS_NO_RELOCATION)) { return CVECTOR_NO_RELOCATION; }
if (index >= vectorhandle->size || index < 0 ) { return CVECTOR_NOT_FOUND; }
if (index == vectorhandle->size-1) {
vectorhandle->size--;
return 0;
}
CVECTOR_MEMMOVE((char *)vectorhandle->array+index*(vectorhandle->elementsize),
(char *)vectorhandle->array+(index+1)*(vectorhandle->elementsize),
(vectorhandle->size-1-index)*(vectorhandle->elementsize));
vectorhandle->size--;
return 0;
} | false | false | false | false | false | 0 |
test_empty_SDSs()
{
int32 sd_id, sds_id, sds_index;
int32 dimsizes[RANK];
HDF_CHUNK_DEF c_def; /* Chunking definitions */
int32 flag;
uintn info_count = 0;
comp_coder_t comp_type; /* Compression flag */
comp_info c_info; /* Compression structure */
int ii, jj;
intn status;
int num_errs = 0; /* number of errors so far */
/* Use the same file as in test_compressed_SDSs */
sd_id = SDstart(NODATA_FILE, DFACC_CREATE);
CHECK(sd_id, FAIL, "test_empty_SDSs: SDstart");
/*
* Create compressed, chunked, chunked/compressed, and expandible SDSs
* without writing data to any of them
*/
dimsizes[0] = Y_LENGTH2;
dimsizes[1] = X_LENGTH2;
/* Contiguous-No-Data */
sds_id = SDcreate(sd_id, "Contiguous-No-Data", DFNT_INT16, RANK, dimsizes);
CHECK(sds_id, FAIL, "test_empty_SDSs: SDcreate 'Contiguous-No-Data'");
status = SDendaccess(sds_id);
CHECK(status, FAIL, "test_empty_SDSs: SDendaccess 'Contiguous-No-Data'");
/* Compressed-No-Data */
sds_id = SDcreate(sd_id, "Compressed-No-Data", DFNT_INT16, RANK, dimsizes);
CHECK(sds_id, FAIL, "test_empty_SDSs: SDcreate 'Compressed-No-Data'");
HDmemset(&c_info, 0, sizeof(c_info));
comp_type = COMP_CODE_SKPHUFF;
c_info.skphuff.skp_size = 4;
status = SDsetcompress(sds_id, comp_type, &c_info);
CHECK(status, FAIL, "test_empty_SDSs: SDsetcompress 'Compressed-No-Data'");
status = SDendaccess(sds_id);
CHECK(status, FAIL, "test_empty_SDSs: SDendaccess 'Compressed-No-Data'");
/* Extend-No-Data */
dimsizes[0] = SD_UNLIMITED;
sds_id = SDcreate(sd_id, "Extend-No-Data", DFNT_INT16, RANK, dimsizes);
CHECK(sds_id, FAIL, "test_empty_SDSs: SDcreate 'Extend-No-Data'");
status = SDendaccess(sds_id);
CHECK(status, FAIL, "test_empty_SDSs: SDendaccess 'Extend-No-Data'");
/* Verify that the number of data block is 0 for all data sets */
for (ii = 0; ii < NUM_SDS; ii++)
{
sds_id = SDselect(sd_id, ii);
CHECK_IND(sds_id, FAIL, "test_empty_SDSs: SDselect", ii);
info_count = SDgetdatainfo(sds_id, NULL, 0, 0, NULL, NULL);
CHECK_IND(info_count, FAIL, "test_empty_SDSs: SDgetdatainfo", ii);
VERIFY(info_count, 0, "test_empty_SDSs: SDgetdatainfo");
status = SDendaccess(sds_id);
CHECK_IND(status, FAIL, "test_empty_SDSs: SDendaccess", ii);
}
/* Close the file */
status = SDend(sd_id);
CHECK(status, FAIL, "test_empty_SDSs: SDend");
/* Reopen the file and check again to make sure that it is still correct
after flushing the metadata */
sd_id = SDstart(NODATA_FILE, DFACC_READ);
CHECK(sd_id, FAIL, "test_empty_SDSs: SDstart");
/* Verify that the number of data block is 0 for all data sets */
for (ii = 0; ii < NUM_SDS; ii++) {
sds_id = SDselect(sd_id, ii);
CHECK_IND(sds_id, FAIL, "test_empty_SDSs: SDselect", ii);
info_count = SDgetdatainfo(sds_id, NULL, 0, 0, NULL, NULL);
CHECK_IND(info_count, FAIL, "test_empty_SDSs: SDgetdatainfo", ii);
VERIFY(info_count, 0, "test_empty_SDSs: SDgetdatainfo");
status = SDendaccess(sds_id);
CHECK_IND(status, FAIL, "test_empty_SDSs: SDendaccess", ii);
}
/* Close the file */
status = SDend(sd_id);
CHECK(status, FAIL, "test_empty_SDSs: SDend");
/* Return the number of errors that's been kept track of so far */
return num_errs;
} | false | false | false | false | false | 0 |
ad2s1200_probe(struct spi_device *spi)
{
struct ad2s1200_state *st;
struct iio_dev *indio_dev;
int pn, ret = 0;
unsigned short *pins = spi->dev.platform_data;
for (pn = 0; pn < AD2S1200_PN; pn++) {
ret = devm_gpio_request_one(&spi->dev, pins[pn], GPIOF_DIR_OUT,
DRV_NAME);
if (ret) {
dev_err(&spi->dev, "request gpio pin %d failed\n",
pins[pn]);
return ret;
}
}
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
return -ENOMEM;
spi_set_drvdata(spi, indio_dev);
st = iio_priv(indio_dev);
mutex_init(&st->lock);
st->sdev = spi;
st->sample = pins[0];
st->rdvel = pins[1];
indio_dev->dev.parent = &spi->dev;
indio_dev->info = &ad2s1200_info;
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->channels = ad2s1200_channels;
indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels);
indio_dev->name = spi_get_device_id(spi)->name;
ret = devm_iio_device_register(&spi->dev, indio_dev);
if (ret)
return ret;
spi->max_speed_hz = AD2S1200_HZ;
spi->mode = SPI_MODE_3;
spi_setup(spi);
return 0;
} | false | false | false | false | false | 0 |
poppler_document_new_from_file (const char *uri,
const char *password,
GError **error)
{
PDFDoc *newDoc;
GooString *filename_g;
GooString *password_g;
char *filename;
if (!globalParams) {
globalParams = new GlobalParams();
}
filename = g_filename_from_uri (uri, NULL, error);
if (!filename)
return NULL;
password_g = NULL;
if (password != NULL) {
if (g_utf8_validate (password, -1, NULL)) {
gchar *password_latin;
password_latin = g_convert (password, -1,
"ISO-8859-1",
"UTF-8",
NULL, NULL, NULL);
password_g = new GooString (password_latin);
g_free (password_latin);
} else {
password_g = new GooString (password);
}
}
#ifdef G_OS_WIN32
wchar_t *filenameW;
int length;
length = MultiByteToWideChar(CP_UTF8, 0, filename, -1, NULL, 0);
filenameW = new WCHAR[length];
if (!filenameW)
return NULL;
length = MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, length);
newDoc = new PDFDoc(filenameW, length, password_g, password_g);
delete filenameW;
#else
filename_g = new GooString (filename);
newDoc = new PDFDoc(filename_g, password_g, password_g);
#endif
g_free (filename);
delete password_g;
return _poppler_document_new_from_pdfdoc (newDoc, error);
} | false | false | false | false | false | 0 |
isValid() const
{
return d->status != Invalid && !d->area.isValid();
} | false | false | false | false | false | 0 |
cx88_reset(struct cx88_core *core)
{
dprintk(1,"%s\n",__func__);
cx88_shutdown(core);
/* clear irq status */
cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int
/* wait a bit */
msleep(100);
/* init sram */
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH21], 720*4, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH22], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH23], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH24], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH25], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH26], 128, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH28], 188*4, 0);
cx88_sram_channel_setup(core, &cx88_sram_channels[SRAM_CH27], 128, 0);
/* misc init ... */
cx_write(MO_INPUT_FORMAT, ((1 << 13) | // agc enable
(1 << 12) | // agc gain
(1 << 11) | // adaptibe agc
(0 << 10) | // chroma agc
(0 << 9) | // ckillen
(7)));
/* setup image format */
cx_andor(MO_COLOR_CTRL, 0x4000, 0x4000);
/* setup FIFO Thresholds */
cx_write(MO_PDMA_STHRSH, 0x0807);
cx_write(MO_PDMA_DTHRSH, 0x0807);
/* fixes flashing of image */
cx_write(MO_AGC_SYNC_TIP1, 0x0380000F);
cx_write(MO_AGC_BACK_VBI, 0x00E00555);
cx_write(MO_VID_INTSTAT, 0xFFFFFFFF); // Clear PIV int
cx_write(MO_PCI_INTSTAT, 0xFFFFFFFF); // Clear PCI int
cx_write(MO_INT1_STAT, 0xFFFFFFFF); // Clear RISC int
/* Reset on-board parts */
cx_write(MO_SRST_IO, 0);
msleep(10);
cx_write(MO_SRST_IO, 1);
return 0;
} | false | false | false | false | false | 0 |
Get_Prio ()
{
const char *data;
long length;
Atom atom, type;
thunk *thunks;
int size, fsize;
const char *prop="_NET_WM_PID";
const char *format = NULL;
const char *dformat = NULL;
atom = XInternAtom(dpy, prop, True);
if (atom == None) {
printf(": no such atom on any window.\n");
return;
}
data = Get_Window_Property_Data_And_Type(atom, &length, &type, &size);
if (!size) {
puts(": not found.");
return;
}
Lookup_Formats(atom, &format, &dformat);
if (type != None)
Lookup_Formats(type, &format, &dformat);
Apply_Default_Formats(&format, &dformat);
fsize = Get_Format_Size(format);
if (fsize != size && fsize != 0) {
printf(": Type mismatch: assumed size %d bits, actual size %d bits.\n",
fsize, size);
return;
}
thunks = Break_Down_Property(data, (int)length, type, format, size);
Display_Priority(thunks, dformat, format);
} | false | false | false | false | false | 0 |
is_proc(void)
{
PATTERN pattern;
int i;
if (!EVAL->pattern)
return FALSE;
for (i = 0;; i++)
{
pattern = EVAL->pattern[i];
if (PATTERN_is_end(pattern))
return FALSE;
if (PATTERN_is(pattern, RS_PRIVATE) || PATTERN_is(pattern, RS_PUBLIC) || PATTERN_is(pattern, RS_STATIC))
continue;
return (PATTERN_is(pattern, RS_SUB) || PATTERN_is(pattern, RS_PROCEDURE) || PATTERN_is(pattern, RS_FUNCTION));
}
} | false | false | false | false | false | 0 |
bad_zone(int i) {
char buffer[1024];
if (MINIX_BLOCK_SIZE*i != lseek(IN, MINIX_BLOCK_SIZE*i, SEEK_SET))
die(_("seek failed in bad_zone"));
return (MINIX_BLOCK_SIZE != read(IN, buffer, MINIX_BLOCK_SIZE));
} | false | false | false | false | false | 0 |
pt_config(struct perf_event *event)
{
u64 reg;
if (!event->hw.itrace_started) {
event->hw.itrace_started = 1;
wrmsrl(MSR_IA32_RTIT_STATUS, 0);
}
reg = RTIT_CTL_TOPA | RTIT_CTL_BRANCH_EN | RTIT_CTL_TRACEEN;
if (!event->attr.exclude_kernel)
reg |= RTIT_CTL_OS;
if (!event->attr.exclude_user)
reg |= RTIT_CTL_USR;
reg |= (event->attr.config & PT_CONFIG_MASK);
wrmsrl(MSR_IA32_RTIT_CTL, reg);
} | false | false | false | false | false | 0 |
new_queue_mem (guint size, gint pos)
{
GstAQueueMem *mem;
mem = g_new (GstAQueueMem, 1);
/* we keep the size as a mask for performance */
mem->size = clp2 (MAX (size, 16)) - 1;
mem->array = g_new0 (gpointer, mem->size + 1);
mem->head = pos;
mem->tail_write = pos;
mem->tail_read = pos;
mem->next = NULL;
mem->free = NULL;
return mem;
} | false | false | false | false | false | 0 |
loadTwoImagesAsRGBA(DataStreamPtr& rgbStream, DataStreamPtr& alphaStream,
PixelFormat fmt, const String& rgbType, const String& alphaType)
{
Image rgb, alpha;
rgb.load(rgbStream, rgbType);
alpha.load(alphaStream, alphaType);
return combineTwoImagesAsRGBA(rgb, alpha, fmt);
} | false | false | false | false | false | 0 |
decode_prefix6(const u_char *pd, u_int itemlen, char *buf, u_int buflen)
{
struct in6_addr addr;
u_int plen, plenbytes;
TCHECK(pd[0]);
ITEMCHECK(1);
plen = pd[0];
if (128 < plen)
return -1;
itemlen -= 1;
memset(&addr, 0, sizeof(addr));
plenbytes = (plen + 7) / 8;
TCHECK2(pd[1], plenbytes);
ITEMCHECK(plenbytes);
memcpy(&addr, &pd[1], plenbytes);
if (plen % 8) {
addr.s6_addr[plenbytes - 1] &=
((0xff00 >> (plen % 8)) & 0xff);
}
snprintf(buf, buflen, "%s/%d", getname6((u_char *)&addr), plen);
return 1 + plenbytes;
trunc:
return -2;
badtlv:
return -3;
} | false | false | false | false | false | 0 |
save_cc_config_out_data(krb5_context context, krb5_ccache ccache,
krb5_init_creds_context ctx)
{
krb5_data config;
char *encoded;
krb5_error_code code;
if (ctx->cc_config_out == NULL ||
k5_json_object_count(ctx->cc_config_out) == 0)
return 0;
code = k5_json_encode(ctx->cc_config_out, &encoded);
if (code)
return code;
config = string2data(encoded);
code = krb5_cc_set_config(context, ccache, ctx->cred.server,
KRB5_CC_CONF_PA_CONFIG_DATA, &config);
free(encoded);
return code;
} | false | false | false | false | false | 0 |
initialize(void)
{
int i, j;
natb = 0;
for (i = 0; i < window.rows; i++) {
for (j = 0; j < window.cols; j++) {
av(i, j) = window.ns_res * window.ew_res;
if (IScvNULL(i, j)) {
natb++;
G_set_d_null_value(&atbv(i, j), 1);
}
else {
atbv(i, j) = -10.0;
}
}
}
} | false | false | false | false | false | 0 |
r100_cs_packet_parse_vline(struct radeon_cs_parser *p)
{
struct drm_crtc *crtc;
struct radeon_crtc *radeon_crtc;
struct radeon_cs_packet p3reloc, waitreloc;
int crtc_id;
int r;
uint32_t header, h_idx, reg;
volatile uint32_t *ib;
ib = p->ib.ptr;
/* parse the wait until */
r = radeon_cs_packet_parse(p, &waitreloc, p->idx);
if (r)
return r;
/* check its a wait until and only 1 count */
if (waitreloc.reg != RADEON_WAIT_UNTIL ||
waitreloc.count != 0) {
DRM_ERROR("vline wait had illegal wait until segment\n");
return -EINVAL;
}
if (radeon_get_ib_value(p, waitreloc.idx + 1) != RADEON_WAIT_CRTC_VLINE) {
DRM_ERROR("vline wait had illegal wait until\n");
return -EINVAL;
}
/* jump over the NOP */
r = radeon_cs_packet_parse(p, &p3reloc, p->idx + waitreloc.count + 2);
if (r)
return r;
h_idx = p->idx - 2;
p->idx += waitreloc.count + 2;
p->idx += p3reloc.count + 2;
header = radeon_get_ib_value(p, h_idx);
crtc_id = radeon_get_ib_value(p, h_idx + 5);
reg = R100_CP_PACKET0_GET_REG(header);
crtc = drm_crtc_find(p->rdev->ddev, crtc_id);
if (!crtc) {
DRM_ERROR("cannot find crtc %d\n", crtc_id);
return -ENOENT;
}
radeon_crtc = to_radeon_crtc(crtc);
crtc_id = radeon_crtc->crtc_id;
if (!crtc->enabled) {
/* if the CRTC isn't enabled - we need to nop out the wait until */
ib[h_idx + 2] = PACKET2(0);
ib[h_idx + 3] = PACKET2(0);
} else if (crtc_id == 1) {
switch (reg) {
case AVIVO_D1MODE_VLINE_START_END:
header &= ~R300_CP_PACKET0_REG_MASK;
header |= AVIVO_D2MODE_VLINE_START_END >> 2;
break;
case RADEON_CRTC_GUI_TRIG_VLINE:
header &= ~R300_CP_PACKET0_REG_MASK;
header |= RADEON_CRTC2_GUI_TRIG_VLINE >> 2;
break;
default:
DRM_ERROR("unknown crtc reloc\n");
return -EINVAL;
}
ib[h_idx] = header;
ib[h_idx + 3] |= RADEON_ENG_DISPLAY_SELECT_CRTC1;
}
return 0;
} | false | false | false | false | false | 0 |
seedrandom() {
unsigned char readbuf[INIT_SEED_SIZE];
hash_state hs;
/* initialise so that things won't warn about
* hashing an undefined buffer */
if (!donerandinit) {
m_burn(hashpool, sizeof(hashpool));
}
/* get the seed data */
readrand(readbuf, sizeof(readbuf));
/* hash in the new seed data */
sha1_init(&hs);
sha1_process(&hs, (void*)hashpool, sizeof(hashpool));
sha1_process(&hs, (void*)readbuf, sizeof(readbuf));
sha1_done(&hs, hashpool);
counter = 0;
donerandinit = 1;
} | true | true | false | false | false | 1 |
do_make_slave(struct mount *mnt)
{
struct mount *peer_mnt = mnt, *master = mnt->mnt_master;
struct mount *slave_mnt;
/*
* slave 'mnt' to a peer mount that has the
* same root dentry. If none is available then
* slave it to anything that is available.
*/
while ((peer_mnt = next_peer(peer_mnt)) != mnt &&
peer_mnt->mnt.mnt_root != mnt->mnt.mnt_root) ;
if (peer_mnt == mnt) {
peer_mnt = next_peer(mnt);
if (peer_mnt == mnt)
peer_mnt = NULL;
}
if (mnt->mnt_group_id && IS_MNT_SHARED(mnt) &&
list_empty(&mnt->mnt_share))
mnt_release_group_id(mnt);
list_del_init(&mnt->mnt_share);
mnt->mnt_group_id = 0;
if (peer_mnt)
master = peer_mnt;
if (master) {
list_for_each_entry(slave_mnt, &mnt->mnt_slave_list, mnt_slave)
slave_mnt->mnt_master = master;
list_move(&mnt->mnt_slave, &master->mnt_slave_list);
list_splice(&mnt->mnt_slave_list, master->mnt_slave_list.prev);
INIT_LIST_HEAD(&mnt->mnt_slave_list);
} else {
struct list_head *p = &mnt->mnt_slave_list;
while (!list_empty(p)) {
slave_mnt = list_first_entry(p,
struct mount, mnt_slave);
list_del_init(&slave_mnt->mnt_slave);
slave_mnt->mnt_master = NULL;
}
}
mnt->mnt_master = master;
CLEAR_MNT_SHARED(mnt);
return 0;
} | false | false | false | false | false | 0 |
zend_replace_error_handling(zend_error_handling_t error_handling, zend_class_entry *exception_class, zend_error_handling *current TSRMLS_DC) /* {{{ */
{
if (current) {
zend_save_error_handling(current TSRMLS_CC);
if (error_handling != EH_NORMAL && EG(user_error_handler)) {
zval_ptr_dtor(&EG(user_error_handler));
EG(user_error_handler) = NULL;
}
}
EG(error_handling) = error_handling;
EG(exception_class) = error_handling == EH_THROW ? exception_class : NULL;
} | false | false | false | false | false | 0 |
write(hsStream* S, plResManager* mgr) {
plSwimRegionInterface::write(S, mgr);
S->writeFloat(fNearDist);
S->writeFloat(fNearVel);
S->writeFloat(fFarDist);
S->writeFloat(fFarVel);
mgr->writeKey(S, fCurrentObj);
} | false | false | false | false | false | 0 |
gs_pop_string(gs_main_instance * minst, gs_string * result)
{
i_ctx_t *i_ctx_p = minst->i_ctx_p;
ref vref;
int code = pop_value(i_ctx_p, &vref);
if (code < 0)
return code;
switch (r_type(&vref)) {
case t_name:
name_string_ref(minst->heap, &vref, &vref);
code = 1;
goto rstr;
case t_string:
code = (r_has_attr(&vref, a_write) ? 0 : 1);
rstr:result->data = vref.value.bytes;
result->size = r_size(&vref);
break;
default:
return_error(e_typecheck);
}
ref_stack_pop(&o_stack, 1);
return code;
} | false | false | false | false | false | 0 |
IoObject_become(IoObject *self, IoObject *locals, IoMessage *m)
{
IoObject *v = IoMessage_locals_valueArgAt_(m, locals, 0);
if(self == v || IoObject_deref(v) == IoObject_deref(self)) return self;
//IOASSERT(!IoObject_isSymbol(self), "Symbols cannot become new values");
IOASSERT(ISOBJECT(self), "Primitives cannot become new values");
//printf("IoObject_become(%p, %p) data %p\n", (void *)self, (void *)v, (void *)IoObject_deref(v));
IoObject_incrementMarkerCount(v);
IoObject_dealloc(self);
CollectorMarker_setObject_(self, IoObject_deref(v));
return self;
} | false | false | false | false | false | 0 |
nm_settings_add_connection (NMSettings *self,
NMConnection *connection,
DBusGMethodInvocation *context,
NMSettingsAddCallback callback,
gpointer user_data)
{
NMSettingsPrivate *priv = NM_SETTINGS_GET_PRIVATE (self);
NMSettingConnection *s_con;
NMAuthChain *chain;
GError *error = NULL, *tmp_error = NULL;
gulong caller_uid = G_MAXULONG;
char *error_desc = NULL;
const char *perm;
/* Connection must be valid, of course */
if (!nm_connection_verify (connection, &tmp_error)) {
error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_INVALID_CONNECTION,
"The connection was invalid: %s",
tmp_error ? tmp_error->message : "(unknown)");
g_error_free (tmp_error);
callback (self, NULL, error, context, user_data);
g_error_free (error);
return;
}
/* Do any of the plugins support adding? */
if (!get_plugin (self, NM_SYSTEM_CONFIG_INTERFACE_CAP_MODIFY_CONNECTIONS)) {
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_ADD_NOT_SUPPORTED,
"None of the registered plugins support add.");
callback (self, NULL, error, context, user_data);
g_error_free (error);
return;
}
/* Get the caller's UID */
if (!nm_auth_get_caller_uid (context, priv->dbus_mgr, &caller_uid, &error_desc)) {
error = g_error_new (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_NOT_PRIVILEGED,
"Unable to determine UID of request: %s.",
error_desc ? error_desc : "(unknown)");
g_free (error_desc);
callback (self, NULL, error, context, user_data);
g_error_free (error);
return;
}
/* Ensure the caller's username exists in the connection's permissions,
* or that the permissions is empty (ie, visible by everyone).
*/
if (!nm_auth_uid_in_acl (connection, priv->session_monitor, caller_uid, &error_desc)) {
error = g_error_new_literal (NM_SETTINGS_ERROR,
NM_SETTINGS_ERROR_PERMISSION_DENIED,
error_desc);
g_free (error_desc);
callback (self, NULL, error, context, user_data);
g_error_free (error);
return;
}
/* If the caller is the only user in the connection's permissions, then
* we use the 'modify.own' permission instead of 'modify.system'. If the
* request affects more than just the caller, require 'modify.system'.
*/
s_con = nm_connection_get_setting_connection (connection);
g_assert (s_con);
if (nm_setting_connection_get_num_permissions (s_con) == 1)
perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_OWN;
else
perm = NM_AUTH_PERMISSION_SETTINGS_MODIFY_SYSTEM;
/* Otherwise validate the user request */
chain = nm_auth_chain_new (context, NULL, pk_add_cb, self);
g_assert (chain);
priv->auths = g_slist_append (priv->auths, chain);
nm_auth_chain_add_call (chain, perm, TRUE);
nm_auth_chain_set_data (chain, "perm", (gpointer) perm, NULL);
nm_auth_chain_set_data (chain, "connection", g_object_ref (connection), g_object_unref);
nm_auth_chain_set_data (chain, "callback", callback, NULL);
nm_auth_chain_set_data (chain, "callback-data", user_data, NULL);
nm_auth_chain_set_data_ulong (chain, "caller-uid", caller_uid);
} | false | false | false | false | false | 0 |
cloud_on() const
{
string value;
if (file_.get_value("cloud", value))
{
return value == "on";
}
// default value is true
return true;
} | false | false | false | false | false | 0 |
CanTurnIntoImplicitDef(MachineInstr *MI,
unsigned Reg, unsigned OpIdx,
SmallSet<unsigned, 8> &ImpDefRegs) {
switch(OpIdx) {
case 1:
return MI->isCopy() && (MI->getOperand(0).getSubReg() == 0 ||
ImpDefRegs.count(MI->getOperand(0).getReg()));
case 2:
return MI->isSubregToReg() && (MI->getOperand(0).getSubReg() == 0 ||
ImpDefRegs.count(MI->getOperand(0).getReg()));
default: return false;
}
} | false | false | false | false | false | 0 |
output_asm_label (x)
rtx x;
{
char buf[256];
if (GET_CODE (x) == LABEL_REF)
x = XEXP (x, 0);
if (GET_CODE (x) == CODE_LABEL
|| (GET_CODE (x) == NOTE
&& NOTE_LINE_NUMBER (x) == NOTE_INSN_DELETED_LABEL))
ASM_GENERATE_INTERNAL_LABEL (buf, "L", CODE_LABEL_NUMBER (x));
else
output_operand_lossage ("`%%l' operand isn't a label");
assemble_name (asm_out_file, buf);
} | false | false | false | false | true | 1 |
threadDone() {
modified = true;
QGLE::setEnabled(rootButton, true);
QGLE::setEnabled(searchButton, true);
QGLE::setEnabled(locButton, true);
QGLE::setEnabled(abortButton, true);
if (mainWin != NULL) {
string gsloc = getGLEInterface()->getGhostScriptLocation();
QString loc = QString::fromUtf8(gsloc.c_str());
tryGhostScriptLocation(loc);
} else {
okButton->setEnabled(true);
}
} | false | false | false | false | false | 0 |
gtt_interval_split (GttInterval *ivl, GttTask *newtask)
{
int is_running = 0;
gint idx;
GttProject *prj;
GttTask *prnt;
GList *node;
GttInterval *first_ivl;
if (!ivl || !newtask) return;
prnt = ivl->parent;
if (!prnt) return;
prj = prnt->parent;
if (!prj) return;
node = g_list_find (prnt->interval_list, ivl);
if (!node) return;
gtt_task_remove (newtask);
/* avoid misplaced running intervals, stop the task */
first_ivl = (GttInterval *) (prnt->interval_list->data);
is_running = first_ivl -> running;
if (is_running)
{
/* don't call stop here, avoid dispatching redraw events */
gtt_project_timer_update (prj);
first_ivl->running = FALSE;
}
/* chain the new task into proper order in the parent project */
idx = g_list_index (prj->task_list, prnt);
idx ++;
prj->task_list = g_list_insert (prj->task_list, newtask, idx);
newtask->parent = prj;
/* Rechain the intervals. We do this by hand, since it
* seems that glib doesn't provide this function. */
if (node->prev)
{
node->prev->next = NULL;
node->prev = NULL;
}
else
{
prnt->interval_list = NULL;
}
newtask->interval_list = node;
for (; node; node=node->next)
{
GttInterval *nivl = node->data;
nivl->parent = newtask;
}
if (is_running) gtt_project_timer_start (prj);
proj_refresh_time (prnt->parent);
} | false | false | false | false | false | 0 |
quicksearch_show(QuickSearch *quicksearch)
{
MainWindow *mainwin = mainwindow_get_mainwindow();
GtkWidget *ctree = NULL;
gtk_widget_show(quicksearch->hbox_search);
update_extended_buttons(quicksearch);
gtk_widget_grab_focus(
GTK_WIDGET(gtk_bin_get_child(GTK_BIN((quicksearch->search_string_entry)))));
if (!mainwin || !mainwin->summaryview) {
return;
}
ctree = summary_get_main_widget(mainwin->summaryview);
if (ctree && mainwin->summaryview->selected)
gtk_cmctree_node_moveto(GTK_CMCTREE(ctree),
mainwin->summaryview->selected,
0, 0.5, 0);
} | false | false | false | false | false | 0 |
unindex_hint(Topform c)
{
if (clist_member(c, Redundant_hints)) {
clist_remove(c, Redundant_hints);
Redundant_hints_count--;
}
else {
lindex_update(Hints_idx, c, DELETE);
if (Back_demod_hints)
index_clause_back_demod(c, Back_demod_idx, DELETE);
Active_hints_count--;
}
} | false | false | false | false | false | 0 |
think_use_cash_to_capture()
{
if( !nation_array[nation_recno]->should_use_cash_to_capture() )
return 0;
//-------------------------------------//
Town* townPtr;
for( int i=0 ; i<linked_town_count ; i++ )
{
townPtr = town_array[ linked_town_array[i] ];
if( townPtr->nation_recno == nation_recno )
continue;
if( townPtr->accumulated_enemy_grant_penalty > 0 )
continue;
if( townPtr->can_grant_to_non_own_town(nation_recno) )
townPtr->grant_to_non_own_town(nation_recno, COMMAND_AI);
}
return 1;
} | false | false | false | false | false | 0 |
state_cl_httpresult0(char ch)
{
if (ch == ' ' || ch == '\t')
{
return;
}
else if (std::isdigit(ch))
{
value = (ch - '0');
state = &HeaderParser::state_cl_httpresult;
return;
}
else
{
log_warn("invalid character " << chartoprint(ch) << " in http result");
state = &HeaderParser::state_error;
return;
}
} | false | false | false | false | false | 0 |
_wapi_handle_timedwait_signal_handle (gpointer handle,
struct timespec *timeout, gboolean alertable, gboolean poll)
{
DEBUG ("%s: waiting for %p (type %s)", __func__, handle,
_wapi_handle_typename[_wapi_handle_type (handle)]);
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
if (WAPI_SHARED_HANDLE_DATA(handle).signalled == TRUE) {
return (0);
}
if (timeout != NULL) {
struct timespec fake_timeout;
_wapi_calc_timeout (&fake_timeout, 100);
if ((fake_timeout.tv_sec > timeout->tv_sec) ||
(fake_timeout.tv_sec == timeout->tv_sec &&
fake_timeout.tv_nsec > timeout->tv_nsec)) {
/* FIXME: Real timeout is less than
* 100ms time, but is it really worth
* calculating to the exact ms?
*/
_wapi_handle_spin (100);
if (WAPI_SHARED_HANDLE_DATA(handle).signalled == TRUE) {
return (0);
} else {
return (ETIMEDOUT);
}
}
}
_wapi_handle_spin (100);
return (0);
} else {
guint32 idx = GPOINTER_TO_UINT(handle);
int res;
pthread_cond_t *cond;
mono_mutex_t *mutex;
if (alertable && !wapi_thread_set_wait_handle (handle))
return 0;
cond = &_WAPI_PRIVATE_HANDLES (idx).signal_cond;
mutex = &_WAPI_PRIVATE_HANDLES (idx).signal_mutex;
if (poll) {
/* This is needed when waiting for process handles */
res = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);
} else {
if (timeout)
res = mono_cond_timedwait (cond, mutex, timeout);
else
res = mono_cond_wait (cond, mutex);
}
if (alertable)
wapi_thread_clear_wait_handle (handle);
return res;
}
} | false | false | false | false | false | 0 |
propdict_foreach( const char* key, xmmsv_t *pair, void* userdata )
{
Xmms::PropDict::ForEachFunc* func =
static_cast< Xmms::PropDict::ForEachFunc* >( userdata );
Xmms::PropDict::ForEachData fedata( key, func );
xmmsv_dict_foreach( pair, &propdict_foreach_inner,
static_cast< void* >( &fedata ) );
} | false | false | false | false | false | 0 |
acpi_ex_truncate_for32bit_table(union acpi_operand_object *obj_desc)
{
ACPI_FUNCTION_ENTRY();
/*
* Object must be a valid number and we must be executing
* a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
*/
if ((!obj_desc) ||
(ACPI_GET_DESCRIPTOR_TYPE(obj_desc) != ACPI_DESC_TYPE_OPERAND) ||
(obj_desc->common.type != ACPI_TYPE_INTEGER)) {
return (FALSE);
}
if ((acpi_gbl_integer_byte_width == 4) &&
(obj_desc->integer.value > (u64)ACPI_UINT32_MAX)) {
/*
* We are executing in a 32-bit ACPI table.
* Truncate the value to 32 bits by zeroing out the upper 32-bit field
*/
obj_desc->integer.value &= (u64)ACPI_UINT32_MAX;
return (TRUE);
}
return (FALSE);
} | false | false | false | false | false | 0 |
read_line(int fd, size_t res_len, char *buf) {
size_t i = 0;
char c = 0;
do {
if(read(fd, &c, sizeof(char)) != sizeof(char))
return -1;
buf[i++] = c;
}
while(c != '\n' && i < res_len);
buf[i - 1] = 0; /* eliminates '\n' */
return 0;
} | false | false | false | false | false | 0 |
cleanup_mapped_device(struct mapped_device *md)
{
if (md->wq)
destroy_workqueue(md->wq);
if (md->kworker_task)
kthread_stop(md->kworker_task);
mempool_destroy(md->io_pool);
mempool_destroy(md->rq_pool);
if (md->bs)
bioset_free(md->bs);
if (md->disk) {
spin_lock(&_minor_lock);
md->disk->private_data = NULL;
spin_unlock(&_minor_lock);
del_gendisk(md->disk);
put_disk(md->disk);
}
if (md->queue)
blk_cleanup_queue(md->queue);
cleanup_srcu_struct(&md->io_barrier);
if (md->bdev) {
bdput(md->bdev);
md->bdev = NULL;
}
} | false | true | false | false | false | 1 |
GetLevel(Slice* input, int* level) {
uint32_t v;
if (GetVarint32(input, &v) &&
v < config::kNumLevels) {
*level = v;
return true;
} else {
return false;
}
} | false | false | false | false | false | 0 |
training_mission_page_in()
{
int i;
for ( i = 0; i < NUM_DIRECTIVE_GAUGES; i++ ) {
bm_page_in_aabitmap( Directive_gauge[i].first_frame, Directive_gauge[i].num_frames );
}
} | false | false | false | false | false | 0 |
ex_diffoff(eap)
exarg_T *eap;
{
win_T *wp;
win_T *old_curwin = curwin;
#ifdef FEAT_SCROLLBIND
int diffwin = FALSE;
#endif
for (wp = firstwin; wp != NULL; wp = wp->w_next)
{
if (wp == curwin || eap->forceit)
{
/* Set 'diff', 'scrollbind' off and 'wrap' on. */
wp->w_p_diff = FALSE;
wp->w_p_scb = FALSE;
wp->w_p_wrap = TRUE;
#ifdef FEAT_FOLDING
curwin = wp;
curbuf = curwin->w_buffer;
set_string_option_direct((char_u *)"fdm", -1,
(char_u *)"manual", OPT_LOCAL|OPT_FREE, 0);
curwin = old_curwin;
curbuf = curwin->w_buffer;
wp->w_p_fdc = 0;
wp->w_p_fen = FALSE;
wp->w_p_fdl = 0;
foldUpdateAll(wp);
/* make sure topline is not halfway a fold */
changed_window_setting_win(wp);
#endif
diff_buf_adjust(wp);
}
#ifdef FEAT_SCROLLBIND
diffwin |= wp->w_p_diff;
#endif
}
#ifdef FEAT_SCROLLBIND
/* Remove "hor" from from 'scrollopt' if there are no diff windows left. */
if (!diffwin && vim_strchr(p_sbo, 'h') != NULL)
do_cmdline_cmd((char_u *)"set sbo-=hor");
#endif
} | false | false | false | false | false | 0 |
generic_make_request_checks(struct bio *bio)
{
struct request_queue *q;
int nr_sectors = bio_sectors(bio);
int err = -EIO;
char b[BDEVNAME_SIZE];
struct hd_struct *part;
might_sleep();
if (bio_check_eod(bio, nr_sectors))
goto end_io;
q = bdev_get_queue(bio->bi_bdev);
if (unlikely(!q)) {
printk(KERN_ERR
"generic_make_request: Trying to access "
"nonexistent block-device %s (%Lu)\n",
bdevname(bio->bi_bdev, b),
(long long) bio->bi_iter.bi_sector);
goto end_io;
}
part = bio->bi_bdev->bd_part;
if (should_fail_request(part, bio->bi_iter.bi_size) ||
should_fail_request(&part_to_disk(part)->part0,
bio->bi_iter.bi_size))
goto end_io;
/*
* If this device has partitions, remap block n
* of partition p to block n+start(p) of the disk.
*/
blk_partition_remap(bio);
if (bio_check_eod(bio, nr_sectors))
goto end_io;
/*
* Filter flush bio's early so that make_request based
* drivers without flush support don't have to worry
* about them.
*/
if ((bio->bi_rw & (REQ_FLUSH | REQ_FUA)) && !q->flush_flags) {
bio->bi_rw &= ~(REQ_FLUSH | REQ_FUA);
if (!nr_sectors) {
err = 0;
goto end_io;
}
}
if ((bio->bi_rw & REQ_DISCARD) &&
(!blk_queue_discard(q) ||
((bio->bi_rw & REQ_SECURE) && !blk_queue_secdiscard(q)))) {
err = -EOPNOTSUPP;
goto end_io;
}
if (bio->bi_rw & REQ_WRITE_SAME && !bdev_write_same(bio->bi_bdev)) {
err = -EOPNOTSUPP;
goto end_io;
}
/*
* Various block parts want %current->io_context and lazy ioc
* allocation ends up trading a lot of pain for a small amount of
* memory. Just allocate it upfront. This may fail and block
* layer knows how to live with it.
*/
create_io_context(GFP_ATOMIC, q->node);
if (!blkcg_bio_issue_check(q, bio))
return false;
trace_block_bio_queue(q, bio);
return true;
end_io:
bio->bi_error = err;
bio_endio(bio);
return false;
} | false | false | false | false | false | 0 |
safelist_sendq_exceeded(struct Client *client_p)
{
if (rb_linebuf_len(&client_p->localClient->buf_sendq) > (get_sendq(client_p) / 2))
return YES;
else
return NO;
} | false | false | false | false | false | 0 |
compute_argument_block_size (int reg_parm_stack_space,
struct args_size *args_size,
int preferred_stack_boundary ATTRIBUTE_UNUSED)
{
int unadjusted_args_size = args_size->constant;
/* For accumulate outgoing args mode we don't need to align, since the frame
will be already aligned. Align to STACK_BOUNDARY in order to prevent
backends from generating misaligned frame sizes. */
if (ACCUMULATE_OUTGOING_ARGS && preferred_stack_boundary > STACK_BOUNDARY)
preferred_stack_boundary = STACK_BOUNDARY;
/* Compute the actual size of the argument block required. The variable
and constant sizes must be combined, the size may have to be rounded,
and there may be a minimum required size. */
if (args_size->var)
{
args_size->var = ARGS_SIZE_TREE (*args_size);
args_size->constant = 0;
preferred_stack_boundary /= BITS_PER_UNIT;
if (preferred_stack_boundary > 1)
{
/* We don't handle this case yet. To handle it correctly we have
to add the delta, round and subtract the delta.
Currently no machine description requires this support. */
if (stack_pointer_delta & (preferred_stack_boundary - 1))
abort ();
args_size->var = round_up (args_size->var, preferred_stack_boundary);
}
if (reg_parm_stack_space > 0)
{
args_size->var
= size_binop (MAX_EXPR, args_size->var,
ssize_int (reg_parm_stack_space));
#ifndef OUTGOING_REG_PARM_STACK_SPACE
/* The area corresponding to register parameters is not to count in
the size of the block we need. So make the adjustment. */
args_size->var
= size_binop (MINUS_EXPR, args_size->var,
ssize_int (reg_parm_stack_space));
#endif
}
}
else
{
preferred_stack_boundary /= BITS_PER_UNIT;
if (preferred_stack_boundary < 1)
preferred_stack_boundary = 1;
args_size->constant = (((args_size->constant
+ stack_pointer_delta
+ preferred_stack_boundary - 1)
/ preferred_stack_boundary
* preferred_stack_boundary)
- stack_pointer_delta);
args_size->constant = MAX (args_size->constant,
reg_parm_stack_space);
#ifdef MAYBE_REG_PARM_STACK_SPACE
if (reg_parm_stack_space == 0)
args_size->constant = 0;
#endif
#ifndef OUTGOING_REG_PARM_STACK_SPACE
args_size->constant -= reg_parm_stack_space;
#endif
}
return unadjusted_args_size;
} | false | false | false | false | false | 0 |
standard_options(struct transport *t)
{
char buf[16];
int n;
int v = t->verbose;
set_helper_option(t, "progress", t->progress ? "true" : "false");
n = snprintf(buf, sizeof(buf), "%d", v + 1);
if (n >= sizeof(buf))
die("impossibly large verbosity value");
set_helper_option(t, "verbosity", buf);
} | false | false | false | false | false | 0 |
tour_realloc_up (GGobiData *d, gint nc)
{
g_return_if_fail(GGOBI_IS_GGOBI(d->gg));
ggobid *gg = d->gg;
displayd *dsp;
GList *l;
for (l=gg->displays; l; l=l->next) {
GGobiExtendedDisplayClass *klass;
dsp = (displayd *) l->data;
if(!GGOBI_IS_EXTENDED_DISPLAY(dsp))
continue;
klass = GGOBI_EXTENDED_DISPLAY_GET_CLASS(dsp);
if(klass->tourcorr_realloc)
klass->tourcorr_realloc(dsp, nc, d);
if(klass->tour2d3_realloc)
klass->tour2d3_realloc(dsp, nc, d);
if(klass->tour2d_realloc)
klass->tour2d_realloc(dsp, nc, d);
if(klass->tour1d_realloc)
klass->tour1d_realloc(dsp, nc, d);
}
} | false | false | false | true | false | 1 |
_pvmove_is_exclusive(struct cmd_context *cmd,
struct volume_group *vg)
{
if (vg_is_clustered(vg))
if (!_pvmove_target_present(cmd, 1))
return 1;
return 0;
} | false | false | false | false | false | 0 |
main(int argc, char** argv){
char* boot_file = BOOTFILE;
if (((argc >= 2) && (strcmp(argv[1], "-h") == 0)) ||
((argc == 2) && (strcmp(argv[1], "-b") == 0))) {
ikarus_usage();
exit(0);
}
if ((argc >= 3) && (strcmp(argv[1], "-b") == 0)){
boot_file = argv[2];
int i;
for(i=3; i<=argc; i++){
argv[i-2] = argv[i];
}
argc -= 2;
}
return ikarus_main(argc, argv, boot_file);
} | false | false | false | false | false | 0 |
cs_sprealloc (cs *A, int nzmax)
{
int ok, oki, okj = 1, okx = 1 ;
if (!A) return (0) ;
if (nzmax <= 0) nzmax = (CS_CSC (A)) ? (A->p [A->n]) : A->nz ;
A->i = cs_realloc (A->i, nzmax, sizeof (int), &oki) ;
if (CS_TRIPLET (A)) A->p = cs_realloc (A->p, nzmax, sizeof (int), &okj) ;
if (A->x) A->x = cs_realloc (A->x, nzmax, sizeof (double), &okx) ;
ok = (oki && okj && okx) ;
if (ok) A->nzmax = nzmax ;
return (ok) ;
} | false | false | false | false | false | 0 |
stmmac_config_sub_second_increment(void __iomem *ioaddr)
{
u32 value = readl(ioaddr + PTP_TCR);
unsigned long data;
/* Convert the ptp_clock to nano second
* formula = (1/ptp_clock) * 1000000000
* where, ptp_clock = 50MHz.
*/
data = (1000000000ULL / 50000000);
/* 0.465ns accuracy */
if (!(value & PTP_TCR_TSCTRLSSR))
data = (data * 1000) / 465;
writel(data, ioaddr + PTP_SSIR);
} | false | false | false | false | false | 0 |
pixMultiplyByColor(PIX *pixd,
PIX *pixs,
BOX *box,
l_uint32 color)
{
l_int32 i, j, bx, by, w, h, wpl;
l_int32 red, green, blue, rval, gval, bval, nrval, ngval, nbval;
l_float32 frval, fgval, fbval;
l_uint32 *data, *line;
PIX *pixt;
PROCNAME("pixMultiplyByColor");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, pixd);
if (pixGetDepth(pixs) != 32)
return (PIX *)ERROR_PTR("pixs not 32 bpp", procName, pixd);
if (pixd && (pixd != pixs))
return (PIX *)ERROR_PTR("pixd neither null nor pixs", procName, pixd);
if (!pixd)
pixd = pixCopy(NULL, pixs);
if (box) {
boxGetGeometry(box, &bx, &by, NULL, NULL);
pixt = pixClipRectangle(pixd, box, NULL);
} else {
pixt = pixClone(pixd);
}
/* Multiply each pixel in pixt by the color */
extractRGBValues(color, &red, &green, &blue);
frval = (1. / 255.) * red;
fgval = (1. / 255.) * green;
fbval = (1. / 255.) * blue;
data = pixGetData(pixt);
wpl = pixGetWpl(pixt);
pixGetDimensions(pixt, &w, &h, NULL);
for (i = 0; i < h; i++) {
line = data + i * wpl;
for (j = 0; j < w; j++) {
extractRGBValues(line[j], &rval, &gval, &bval);
nrval = (l_int32)(frval * rval + 0.5);
ngval = (l_int32)(fgval * gval + 0.5);
nbval = (l_int32)(fbval * bval + 0.5);
composeRGBPixel(nrval, ngval, nbval, line + j);
}
}
/* Replace */
if (box)
pixRasterop(pixd, bx, by, w, h, PIX_SRC, pixt, 0, 0);
pixDestroy(&pixt);
return pixd;
} | false | false | false | false | false | 0 |
cmsPipelineGetPtrToLastStage(const cmsPipeline* lut)
{
cmsStage *mpe, *Anterior = NULL;
for (mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next)
Anterior = mpe;
return Anterior;
} | false | false | false | false | false | 0 |
get_boot_info(struct boot_context *context, char *rootdir,
char *subsys)
{
char initiator_dir[FILENAMESZ];
int rc = ENODEV;
int nic_idx = -1, tgt_idx = -1;
memset(&initiator_dir, 0 , FILENAMESZ);
snprintf(initiator_dir, FILENAMESZ, "%sinitiator", rootdir);
nic_cnt = 0;
tgt_cnt = 0;
if (file_exist(initiator_dir)) {
/* Find the target's and the ethernet's */
rc = nftw(rootdir, find_sysfs_dirs, 20, 1);
/* Find wihch target and which ethernet have
the boot flag set. */
rc = find_boot_flag(subsys, nic_list, nic_cnt, &nic_idx);
if (rc)
goto free;
rc = find_boot_flag(subsys, target_list, tgt_cnt, &tgt_idx);
if (rc)
goto free;
/* Fill in the context values */
rc = fill_nic_context(subsys, nic_list[nic_idx], context);
rc |= fill_tgt_context(subsys, target_list[tgt_idx], context);
fill_initiator_context(subsys, context);
}
free:
deallocate_lists();
return rc;
} | false | false | false | false | false | 0 |
ensAssemblymapperMapToSeqregion(
EnsPAssemblymapper am,
const EnsPSeqregion sr,
ajint srstart,
ajint srend,
ajint srstrand,
const EnsPSeqregion optsr,
AjBool fastmap,
AjPList mrs)
{
if (!am)
return ajFalse;
if (!sr)
return ajFalse;
if (!mrs)
return ajFalse;
if (am->Generic)
ensGenericassemblymapperMap(am->Generic,
sr,
srstart,
srend,
srstrand,
fastmap,
mrs);
if (am->Chained)
ensChainedassemblymapperMap(am->Chained,
sr,
srstart,
srend,
srstrand,
optsr,
fastmap,
mrs);
if (am->Toplevel)
ensToplevelassemblymapperMap(am->Toplevel,
sr,
srstart,
srend,
srstrand,
fastmap,
mrs);
return ajTrue;
} | false | false | false | false | false | 0 |
read_offset_tree(LHAPM2Decoder *decoder,
unsigned int num_offsets)
{
uint8_t offset_lengths[8];
unsigned int off;
unsigned int single_offset, num_codes;
int len;
if (!decoder->need_offset_tree) {
return 1;
}
// Read 'num_offsets' 3-bit length values. For each offset
// value 'off', offset_lengths[off] is the length of the
// code that will represent 'off', or 0 if it will not
// appear within the tree.
num_codes = 0;
single_offset = 0;
for (off = 0; off < num_offsets; ++off) {
len = read_bits(&decoder->bit_stream_reader, 3);
if (len < 0) {
return 0;
}
offset_lengths[off] = (uint8_t) len;
// Track how many actual codes were in the tree.
if (len != 0) {
single_offset = off;
++num_codes;
}
}
// If there was a single code, this is a single node tree.
if (num_codes == 1) {
set_tree_single(decoder->offset_tree, single_offset);
return 1;
}
// Build the tree.
build_tree(decoder->offset_tree, sizeof(decoder->offset_tree),
offset_lengths, num_offsets);
return 1;
} | false | false | false | false | false | 0 |
ooh323c_stop_stack_thread(void)
{
if(ooh323c_thread != AST_PTHREADT_NULL)
{
ooStopMonitor();
pthread_join(ooh323c_thread, NULL);
ooh323c_thread = AST_PTHREADT_NULL;
pthread_join(ooh323cmd_thread, NULL);
ooh323cmd_thread = AST_PTHREADT_NULL;
}
return 0;
} | false | false | false | false | false | 0 |
freeRotationAllowed(Qt::KeyboardModifiers modifiers) {
if ((modifiers & altOrMetaModifier()) == 0) return false;
if (!isSelected()) return false;
return true;
} | false | false | false | false | false | 0 |
acpi_db_match_argument(char *user_argument,
struct acpi_db_argument_info *arguments)
{
u32 i;
if (!user_argument || user_argument[0] == 0) {
return (ACPI_TYPE_NOT_FOUND);
}
for (i = 0; arguments[i].name; i++) {
if (strstr(arguments[i].name, user_argument) ==
arguments[i].name) {
return (i);
}
}
/* Argument not recognized */
return (ACPI_TYPE_NOT_FOUND);
} | false | false | false | false | false | 0 |
_no_gres_conf(uint32_t cpu_cnt)
{
int i, rc = SLURM_SUCCESS;
gres_slurmd_conf_t *p;
slurm_mutex_lock(&gres_context_lock);
FREE_NULL_LIST(gres_conf_list);
gres_conf_list = list_create(_destroy_gres_slurmd_conf);
for (i = 0; ((i < gres_context_cnt) && (rc == SLURM_SUCCESS)); i++) {
p = xmalloc(sizeof(gres_slurmd_conf_t));
p->cpu_cnt = cpu_cnt;
p->name = xstrdup(gres_context[i].gres_name);
p->plugin_id = gres_context[i].plugin_id;
list_append(gres_conf_list, p);
/* If there is no plugin specific shared
* library the exported methods are NULL.
*/
if (gres_context[i].ops.node_config_load) {
rc = (*(gres_context[i].ops.node_config_load))
(gres_conf_list);
}
}
slurm_mutex_unlock(&gres_context_lock);
return rc;
} | false | false | false | false | false | 0 |
remove_active_transaction(GtkTreeView *treeview)
{
GtkTreeModel *model;
GList *list;
model = gtk_tree_view_get_model(treeview);
list = gtk_tree_selection_get_selected_rows(gtk_tree_view_get_selection(treeview), &model);
if(list != NULL)
{
GtkTreeIter iter;
gtk_tree_model_get_iter(model, &iter, list->data);
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
}
g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
g_list_free(list);
} | false | false | false | false | false | 0 |
Shell_Init(void)
{
int i;
struct Shell *sh;
Boolean fullSpec;
for (i = 0; shells_init[i] != NULL; i++) {
sh = ShellParseSpec(shells_init[i], &fullSpec);
TAILQ_INSERT_TAIL(&shells, sh, link);
if (strcmp(sh->name, DEFSHELLNAME) == 0)
commandShell = sh;
}
} | false | false | false | false | false | 0 |
PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "AutoCenter: (" << this->AutoCenter << ")\n";
os << indent << "EnableDistanceLOD: (" << this->EnableDistanceLOD << ")\n";
os << indent << "DistanceLODThreshold: (" << this->DistanceLODThreshold << ")\n";
os << indent << "EnableViewAngleLOD: (" << this->EnableViewAngleLOD << ")\n";
os << indent << "ViewAngleLODThreshold: (" << this->ViewAngleLODThreshold << ")\n";
os << indent << "ScreenOffset: ("<< this->ScreenOffset << ")\n";
if ( this->Axis )
{
os << indent << "Axis: (" << this->Axis << ")\n";
}
else
{
os << indent << "Axis: (none)\n";
}
} | false | false | false | false | false | 0 |
key_or_joy_ready (void)
{
int i;
int ct = read_htimer (demo_trigger_htimer);
if ((in_jokebox == 0)) {
if (ct >= 30 || check_what == check_demo)
demo_ready = 1;
else
demo_ready = 0;
if (ct >= 60) {
if (in_menu)
event_sfx (118 + (rand () & 1));
reset_htimer (demo_trigger_htimer);
}
}
if (key_ready ()) {
reset_htimer (demo_trigger_htimer);
return 1;
}
if ((joystick_detected & 1) && (opt.ctrl_one == 1 || opt.ctrl_two == 1)) {
for (i = 0; i < 6; i++)
kbjoyold[i] = kbjoy[i];
get_joystick_state ();
kbjoy[0] = is_joystick_up (0);
kbjoy[1] = is_joystick_right (0);
kbjoy[2] = is_joystick_down (0);
kbjoy[3] = is_joystick_left (0);
kbjoy[4] = is_joystick_button_a (0);
kbjoy[5] = is_joystick_button_b (0);
if ((kbjoy[0] && !kbjoyold[0])
|| (kbjoy[1] && !kbjoyold[1])
|| (kbjoy[2] && !kbjoyold[2])
|| (kbjoy[3] && !kbjoyold[3])
|| (kbjoy[4] && !kbjoyold[4])
|| (kbjoy[5] && !kbjoyold[5])) {
reset_htimer (demo_trigger_htimer);
return 1;
}
}
return 0;
} | false | false | false | false | false | 0 |
f_filereadable(argvars, rettv)
typval_T *argvars;
typval_T *rettv;
{
int fd;
char_u *p;
int n;
#ifndef O_NONBLOCK
# define O_NONBLOCK 0
#endif
p = get_tv_string(&argvars[0]);
if (*p && !mch_isdir(p) && (fd = mch_open((char *)p,
O_RDONLY | O_NONBLOCK, 0)) >= 0)
{
n = TRUE;
close(fd);
}
else
n = FALSE;
rettv->vval.v_number = n;
} | false | false | false | false | false | 0 |
_ssll_it2cont(ssll_iterator *it)
{
if(NULL == it) {
netsnmp_assert(NULL != it);
return NULL;
}
if(NULL == it->base.container) {
netsnmp_assert(NULL != it->base.container);
return NULL;
}
if(it->base.container->sync != it->base.sync) {
DEBUGMSGTL(("container:iterator", "out of sync\n"));
return NULL;
}
return (sl_container *)it->base.container;
} | false | false | false | false | false | 0 |
construct_virtual_base (tree vbase, tree arguments)
{
tree inner_if_stmt;
tree compound_stmt;
tree exp;
tree flag;
/* If there are virtual base classes with destructors, we need to
emit cleanups to destroy them if an exception is thrown during
the construction process. These exception regions (i.e., the
period during which the cleanups must occur) begin from the time
the construction is complete to the end of the function. If we
create a conditional block in which to initialize the
base-classes, then the cleanup region for the virtual base begins
inside a block, and ends outside of that block. This situation
confuses the sjlj exception-handling code. Therefore, we do not
create a single conditional block, but one for each
initialization. (That way the cleanup regions always begin
in the outer block.) We trust the back-end to figure out
that the FLAG will not change across initializations, and
avoid doing multiple tests. */
flag = TREE_CHAIN (DECL_ARGUMENTS (current_function_decl));
inner_if_stmt = begin_if_stmt ();
finish_if_stmt_cond (flag, inner_if_stmt);
compound_stmt = begin_compound_stmt (/*has_no_scope=*/true);
/* Compute the location of the virtual base. If we're
constructing virtual bases, then we must be the most derived
class. Therefore, we don't have to look up the virtual base;
we already know where it is. */
exp = convert_to_base_statically (current_class_ref, vbase);
expand_aggr_init_1 (vbase, current_class_ref, exp, arguments,
LOOKUP_COMPLAIN);
finish_compound_stmt (compound_stmt);
finish_then_clause (inner_if_stmt);
finish_if_stmt ();
expand_cleanup_for_base (vbase, flag);
} | false | false | false | false | false | 0 |
initialize(const QStringList &arguments, QString *errorString)
{
if (Utils::Log::warnPluginsCreation())
qWarning() << "GirPlugin::initialize";
Q_UNUSED(arguments);
Q_UNUSED(errorString);
m_Factory = new GirWidgetFactory(this);
addObject(m_Factory);
return true;
} | false | false | false | false | false | 0 |
Key_StringToKeynum (char *str)
{
keyname_t *kn;
if (!str || !str[0])
return -1;
if (!str[1])
return str[0];
for (kn=keynames ; kn->name ; kn++)
{
if (!Q_strcasecmp(str,kn->name))
return kn->keynum;
}
return -1;
} | false | false | false | false | false | 0 |
deletefile (char *filename, int fh)
{
if (fh >= 0) close(fh);
if( remove( (const char* )filename) == -1 )
{
printf("Error in deleting %s, errno value is %d\n", filename, errno);
}
} | false | false | false | false | false | 0 |
collectPropsMap(QString & family, QMap<QString, QString> & propsMap) {
QHash<QString, QString> properties;
properties = m_modelPart->properties();
family = properties.value("family", "");
foreach (QString key, properties.keys()) {
if (key.compare("family") == 0) continue;
if (key.compare("id") == 0) continue;
QString value = properties.value(key,"");
QString tempValue = value;
QStringList values = collectValues(family, key, tempValue);
propsMap.insert(key, tempValue);
DebugDialog::debug(QString("props map %1 %2").arg(key).arg(tempValue));
}
} | false | false | false | false | false | 0 |
obj_delfamily_find_by_familyid(TSS_HOBJECT hObject, UINT32 familyID, TSS_HDELFAMILY *hFamily)
{
TSS_HCONTEXT hContext;
struct tsp_object *obj;
struct obj_list *list = &delfamily_list;
struct tr_delfamily_obj *delfamily;
pthread_mutex_lock(&list->lock);
*hFamily = NULL_HDELFAMILY;
if (obj_is_tpm(hObject)) {
if (obj_tpm_get_tsp_context((TSS_HTPM)hObject, &hContext))
return;
} else
hContext = (TSS_HCONTEXT)hObject;
for (obj = list->head; obj; obj = obj->next) {
if (obj->tspContext != hContext)
continue;
delfamily = (struct tr_delfamily_obj *)obj->data;
if (delfamily->familyID == familyID) {
*hFamily = obj->handle;
break;
}
}
pthread_mutex_unlock(&list->lock);
} | false | false | false | false | false | 0 |
FcStrBufDone (FcStrBuf *buf)
{
FcChar8 *ret;
if (buf->failed)
ret = NULL;
else
ret = malloc (buf->len + 1);
if (ret)
{
memcpy (ret, buf->buf, buf->len);
ret[buf->len] = '\0';
}
FcStrBufDestroy (buf);
return ret;
} | false | false | false | false | false | 0 |
lock_front_buffer(struct gbm_surface *_surf)
{
struct gbm_dri_surface *surf = (struct gbm_dri_surface *) _surf;
struct dri2_egl_surface *dri2_surf = surf->dri_private;
struct gbm_bo *bo;
if (dri2_surf->current == NULL) {
_eglError(EGL_BAD_SURFACE, "no front buffer");
return NULL;
}
bo = dri2_surf->current->bo;
dri2_surf->current->locked = 1;
dri2_surf->current = NULL;
return bo;
} | false | false | false | false | false | 0 |
igb_init_hw_82575(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
s32 ret_val;
u16 i, rar_count = mac->rar_entry_count;
DEBUGFUNC("igb_init_hw_82575");
/* Initialize identification LED */
ret_val = mac->ops.id_led_init(hw);
if (ret_val) {
DEBUGOUT("Error initializing identification LED\n");
/* This is not fatal and we should not stop init due to this */
}
/* Disabling VLAN filtering */
DEBUGOUT("Initializing the IEEE VLAN\n");
mac->ops.clear_vfta(hw);
/* Setup the receive address */
igb_init_rx_addrs_generic(hw, rar_count);
/* Zero out the Multicast HASH table */
DEBUGOUT("Zeroing the MTA\n");
for (i = 0; i < mac->mta_reg_count; i++)
E1000_WRITE_REG_ARRAY(hw, E1000_MTA, i, 0);
/* Zero out the Unicast HASH table */
DEBUGOUT("Zeroing the UTA\n");
for (i = 0; i < mac->uta_reg_count; i++)
E1000_WRITE_REG_ARRAY(hw, E1000_UTA, i, 0);
/* Setup link and flow control */
ret_val = mac->ops.setup_link(hw);
/*
* Clear all of the statistics registers (clear on read). It is
* important that we do this after we have tried to establish link
* because the symbol error count will increment wildly if there
* is no link.
*/
igb_clear_hw_cntrs_82575(hw);
return ret_val;
} | false | false | false | false | false | 0 |
af9015_download_firmware(struct dvb_usb_device *d,
const struct firmware *fw)
{
struct af9015_state *state = d_to_priv(d);
int i, len, remaining, ret;
struct req_t req = {DOWNLOAD_FIRMWARE, 0, 0, 0, 0, 0, NULL};
u16 checksum = 0;
dev_dbg(&d->udev->dev, "%s:\n", __func__);
/* calc checksum */
for (i = 0; i < fw->size; i++)
checksum += fw->data[i];
state->firmware_size = fw->size;
state->firmware_checksum = checksum;
#define FW_ADDR 0x5100 /* firmware start address */
#define LEN_MAX 55 /* max packet size */
for (remaining = fw->size; remaining > 0; remaining -= LEN_MAX) {
len = remaining;
if (len > LEN_MAX)
len = LEN_MAX;
req.data_len = len;
req.data = (u8 *) &fw->data[fw->size - remaining];
req.addr = FW_ADDR + fw->size - remaining;
ret = af9015_ctrl_msg(d, &req);
if (ret) {
dev_err(&d->udev->dev,
"%s: firmware download failed=%d\n",
KBUILD_MODNAME, ret);
goto error;
}
}
/* firmware loaded, request boot */
req.cmd = BOOT;
req.data_len = 0;
ret = af9015_ctrl_msg(d, &req);
if (ret) {
dev_err(&d->udev->dev, "%s: firmware boot failed=%d\n",
KBUILD_MODNAME, ret);
goto error;
}
error:
return ret;
} | false | false | false | false | false | 0 |
Init()
{
// already done ?
if (m_IsInit) {
return;
}
m_IsInit = true;
// init image(s)
wxImageList* images = new wxImageList(16, 16);
images->Add(wxBitmap(amuleSpecial(1)));
images->Add(wxBitmap(amuleSpecial(2)));
// Gives wxTreeCtrl ownership of the list
AssignImageList(images);
// Create an empty root item, which we can
// safely append when creating a full path.
m_root = AddRoot(wxEmptyString, IMAGE_FOLDER, -1,
new CItemData(CPath()));
if (!m_IsRemote) {
#ifndef __WXMSW__
AddChildItem(m_root, CPath(wxT("/")));
#else
// this might take awhile, so change the cursor
::wxSetCursor(*wxHOURGLASS_CURSOR);
// retrieve bitmask of all drives available
uint32 drives = GetLogicalDrives();
drives >>= 1;
for (char drive = 'C'; drive <= 'Z'; drive++) {
drives >>= 1;
if (! (drives & 1)) { // skip non existant drives
continue;
}
wxString driveStr = CFormat(wxT("%c:")) % drive;
uint32 type = GetDriveType(driveStr + wxT("\\"));
// skip removable/undefined drives, share only fixed or remote drives
if ((type == 3 || type == 4) // fixed drive / remote drive
&& CPath::DirExists(driveStr)) {
AddChildItem(m_root, CPath(driveStr));
}
}
::wxSetCursor(*wxSTANDARD_CURSOR);
#endif
}
HasChanged = false;
UpdateSharedDirectories();
} | false | false | false | false | false | 0 |
do_host_cloak_ip(const char *inbuf, char *outbuf)
{
char *tptr;
unsigned int accum = get_string_weighted_entropy(inbuf);
char buf[HOSTLEN];
int ipv6 = 0;
strncpy(buf, inbuf, HOSTLEN);
tptr = strrchr(buf, '.');
if (tptr == NULL)
{
tptr = strrchr(buf, ':');
ipv6 = 1;
}
if (tptr == NULL)
{
strncpy(outbuf, inbuf, HOSTLEN);
return;
}
*tptr++ = '\0';
if(ipv6)
{
rb_snprintf(outbuf, HOSTLEN, "%s:%x", buf, accum);
}
else
{
rb_snprintf(outbuf, HOSTLEN, "%s.%x", buf, accum);
}
} | true | true | false | false | false | 1 |
z_get_prop( zword_t obj, zword_t prop )
{
zword_t prop_addr;
zword_t wprop_val;
zbyte_t bprop_val;
zbyte_t value;
#ifdef STRICTZ
if ( obj == 0 )
{
report_strictz_error( STRZERR_GET_PROP, "@get_prop called with object 0" );
store_operand( 0 );
return;
}
#endif
/* Load address of first property */
prop_addr = get_property_addr( obj );
/* Scan down the property list */
for ( ;; )
{
value = get_byte( prop_addr );
if ( ( zbyte_t ) ( value & property_mask ) <= ( zbyte_t ) prop )
break;
prop_addr = get_next_property( prop_addr );
}
/* If the property ids match then load the first property */
if ( ( zbyte_t ) ( value & property_mask ) == ( zbyte_t ) prop ) /* property found */
{
prop_addr++;
/* Only load first property if it is a byte sized property */
if ( ( h_type <= V3 && !( value & 0xe0 )) || (h_type >= V4 && !( value & 0xc0 )) )
{
bprop_val = get_byte( prop_addr );
wprop_val = bprop_val;
}
else
{
wprop_val = get_word( prop_addr );
}
}
else /* property not found */
{
/* Calculate the address of the default property */
prop_addr = h_objects_offset + ( ( prop - 1 ) * 2 );
wprop_val = get_word( prop_addr );
}
/* store the property value */
store_operand( wprop_val );
} | false | false | false | false | false | 0 |
count_dir( const char * dirname ) {
DIR * d = NULL;
struct dirent * f = NULL;
int ctotal = 0;
if ( (d = opendir(dirname)) == NULL ) {
return(-1);
}
while ( (f = readdir(d)) ) {
if ( f->d_name[0] != '.' )
++ctotal;
}
closedir(d);
return(ctotal);
} | false | false | false | false | false | 0 |
read_router_string(String text, const String &landmark, bool empty_ok,
ErrorHandler *errh)
{
// check for archive
Vector<ArchiveElement> archive;
if (text.length() && text[0] == '!') {
ArchiveElement::parse(text, archive, errh);
if (ArchiveElement *ae = ArchiveElement::find(archive, "config"))
text = ae->data;
else {
errh->lerror(landmark, "archive has no %<config%> section");
text = String();
}
}
// read router
if (!text.length() && !empty_ok)
errh->lwarning(landmark, "empty configuration");
LexerT lexer(errh, ignore_line_directives);
lexer.reset(text, archive, landmark);
// read statements
while (lexer.ystatement())
/* nada */;
// done
return lexer.finish(global_scope);
} | false | false | false | false | false | 0 |
main()
{ struct soap *soap = soap_new();
struct methodCall m;
struct methodResponse r;
struct param p[2];
/* Set up method call */
m.methodName = "weblogUpdates.ping";
/* two parameters with string content */
m.params.__size = 2;
m.params.param = p;
memset(p, 0, sizeof(p));
p[0].value.__type = SOAP_TYPE__string;
p[0].value.ref = "Scripting News";
p[1].value.__type = SOAP_TYPE__string;
p[1].value.ref = "http://www.scripting.com/";
/* connect, send request, and receive response */
if (methodCall(soap, "http://rpc.weblogs.com/RPC2", &m, &r))
{ soap_print_fault(soap, stderr);
exit(soap->error);
}
if (r.fault)
{ /* print fault on stdout */
soap_begin_send(soap);
soap_put_fault(soap, r.fault, "fault", NULL);
soap_end_send(soap);
}
else if (r.params && r.params->__size == 1)
{ /* print response parameter, check if first is a struct */
if (r.params->param[0].value.__type == SOAP_TYPE__struct)
{ /* it is a struct with two members */
struct _struct *s = r.params->param[0].value.ref;
if (s->__size >= 2)
{ int i;
for (i = 0; i < s->__size; i++)
{ if (!strcmp(s->member[i].name, "flerror"))
{ if (s->member[i].value.__type == SOAP_TYPE__boolean)
{ if ((*(_boolean*)s->member[i].value.ref) == 0)
printf("Weblog ping successful\n");
else
printf("Weblog ping failed\n");
}
else
printf("XML-RPC response message format error: boolean value expected\n");
}
if (!strcmp(s->member[i].name, "message"))
{ if (s->member[i].value.__any)
printf("%s\n", s->member[i].value.__any);
else
printf("XML-RPC response message format error: string value expected\n");
}
}
}
else
printf("XML-RPC response message format error: struct with two members expected\n");
}
else
printf("XML-RPC response message format error: struct expected\n");
}
soap_end(soap);
soap_done(soap);
free(soap);
return 0;
} | false | false | false | false | false | 0 |
xsh_model_first_anneal_save(
const cpl_table* out_table,
xsh_instrument* instr,
cpl_parameterlist* parlist,
cpl_frameset* set)
{
char name_o[512] ;
cpl_propertylist* plist=NULL ;
cpl_frame* product_frame=NULL ;
cpl_frameset* raws=NULL;
cpl_frame* ref_frame=NULL;
const char* pro_catg=xsh_get_tag_from_arm(XSH_MOD_CFG_FAN,instr);
/* Get the reference frame */
raws=cpl_frameset_new();
check(xsh_dfs_extract_raw_frames(set,raws));
check(ref_frame=cpl_frameset_get_first(raws));
check(plist=cpl_propertylist_load(cpl_frame_get_filename(ref_frame),0));
xsh_free_frameset(&raws);
/* Set the file name */
sprintf(name_o,"%s%s",
xsh_get_tag_from_arm(XSH_MOD_CFG_FAN,instr),".fits") ;
cpl_msg_info(__func__, "Writing %s" , name_o) ;
/* Get FITS header from reference file */
cpl_propertylist_append_int(plist,"Num_pinh",9);
/* Create product frame */
check(product_frame=xsh_frame_product(name_o,pro_catg,CPL_FRAME_TYPE_TABLE,
CPL_FRAME_GROUP_PRODUCT,
CPL_FRAME_LEVEL_FINAL));
if (cpl_table_save(out_table, plist, NULL, name_o,
CPL_IO_DEFAULT) != CPL_ERROR_NONE) {
cpl_msg_error(__func__, "Cannot save the product");
xsh_free_frame(&product_frame) ;
xsh_free_propertylist(&plist) ;
return -1 ;
}
check(xsh_add_product_table(product_frame,set,parlist,"xsh_startup",
instr,NULL));
cleanup:
xsh_free_propertylist(&plist) ;
/* Return */
if (cpl_error_get_code())
return -1 ;
else
return 0 ;
} | false | false | false | false | false | 0 |
gst_amr_parse_parse_header (GstAmrParse * amrparse,
const guint8 * data, gint * skipsize)
{
GST_DEBUG_OBJECT (amrparse, "Parsing header data");
if (!memcmp (data, "#!AMR-WB\n", 9)) {
GST_DEBUG_OBJECT (amrparse, "AMR-WB detected");
amrparse->block_size = block_size_wb;
amrparse->wide = TRUE;
*skipsize = amrparse->header = 9;
} else if (!memcmp (data, "#!AMR\n", 6)) {
GST_DEBUG_OBJECT (amrparse, "AMR-NB detected");
amrparse->block_size = block_size_nb;
amrparse->wide = FALSE;
*skipsize = amrparse->header = 6;
} else
return FALSE;
gst_amr_parse_set_src_caps (amrparse);
return TRUE;
} | false | false | false | false | false | 0 |
gst_disparity_chain_left (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstDisparity *fs;
GstMapInfo info;
fs = GST_DISPARITY (parent);
GST_DEBUG_OBJECT (pad, "processing frame from left");
g_mutex_lock (&fs->lock);
if (fs->flushing) {
g_mutex_unlock (&fs->lock);
return GST_FLOW_FLUSHING;
}
if (fs->buffer_left) {
GST_DEBUG_OBJECT (pad, " right is busy, wait and hold");
g_cond_wait (&fs->cond, &fs->lock);
GST_DEBUG_OBJECT (pad, " right is free, continuing");
if (fs->flushing) {
g_mutex_unlock (&fs->lock);
return GST_FLOW_FLUSHING;
}
}
fs->buffer_left = buffer;
if (!gst_buffer_map (buffer, &info, (GstMapFlags) GST_MAP_READWRITE)) {
return GST_FLOW_ERROR;
}
if (fs->cvRGB_left)
fs->cvRGB_left->imageData = (char *) info.data;
GST_DEBUG_OBJECT (pad, "signalled right");
g_cond_signal (&fs->cond);
g_mutex_unlock (&fs->lock);
return GST_FLOW_OK;
} | false | false | false | false | false | 0 |
acpi_ex_release_all_mutexes(struct acpi_thread_state *thread)
{
union acpi_operand_object *next = thread->acquired_mutex_list;
union acpi_operand_object *obj_desc;
ACPI_FUNCTION_NAME(ex_release_all_mutexes);
/* Traverse the list of owned mutexes, releasing each one */
while (next) {
obj_desc = next;
next = obj_desc->mutex.next;
obj_desc->mutex.prev = NULL;
obj_desc->mutex.next = NULL;
obj_desc->mutex.acquisition_depth = 0;
ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
"Force-releasing held mutex: %p\n",
obj_desc));
/* Release the mutex, special case for Global Lock */
if (obj_desc == acpi_gbl_global_lock_mutex) {
/* Ignore errors */
(void)acpi_ev_release_global_lock();
} else {
acpi_os_release_mutex(obj_desc->mutex.os_mutex);
}
/* Mark mutex unowned */
obj_desc->mutex.owner_thread = NULL;
obj_desc->mutex.thread_id = 0;
/* Update Thread sync_level (Last mutex is the important one) */
thread->current_sync_level =
obj_desc->mutex.original_sync_level;
}
} | false | false | false | false | false | 0 |
unity_protocol_scope_service_proxy_open_channel_async (UnityProtocolScopeService* self, guint channel_type, GHashTable* hints, GCancellable* cancellable, const char* sender, GAsyncReadyCallback _callback_, gpointer _user_data_) {
GDBusMessage *_message;
GVariant *_arguments;
GVariantBuilder _arguments_builder;
GVariantBuilder _tmp33_;
GHashTableIter _tmp34_;
gpointer _tmp35_;
gpointer _tmp36_;
G_IO_ERROR;
_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "com.canonical.Unity.Scope", "OpenChannel");
g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (channel_type));
g_hash_table_iter_init (&_tmp34_, hints);
g_variant_builder_init (&_tmp33_, G_VARIANT_TYPE ("a{sv}"));
while (g_hash_table_iter_next (&_tmp34_, &_tmp35_, &_tmp36_)) {
gchar* _key;
GVariant* _value;
_key = (gchar*) _tmp35_;
_value = (GVariant*) _tmp36_;
g_variant_builder_add (&_tmp33_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
}
g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp33_));
_arguments = g_variant_builder_end (&_arguments_builder);
g_dbus_message_set_body (_message, _arguments);
g_dbus_connection_send_message_with_reply (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, cancellable, _vala_g_async_ready_callback, g_simple_async_result_new ((GObject *) self, _callback_, _user_data_, NULL));
g_object_unref (_message);
} | false | false | false | false | false | 0 |
operator+=(int delta)
{
if (_modulus > 1) {
if (delta < 0)
delta += ((-delta)/_modulus + 1) * _modulus;
_offset = (_offset + delta) % _modulus;
}
return *this;
} | false | false | false | false | false | 0 |
fl_push_matrix() {
if (sptr==32)
Fl::error("fl_push_matrix(): matrix stack overflow.");
else
stack[sptr++] = m;
} | false | false | false | false | false | 0 |
keyPressEvent ( QKeyEvent * event )
{
if (mIsStorageModeOn)
return;
int key = event->key();
if ( ( key == Qt::Key_Left ) || ( key == Qt::Key_Right ) || ( key == Qt::Key_Down ) || ( key == Qt::Key_Up ) )
{
int dx = 0 , dy = 0;
switch (key)
{
case Qt::Key_Left: dx = -KEY_ITEM_MOVE; dy = 0; break;
case Qt::Key_Right: dx = KEY_ITEM_MOVE; dy = 0; break;
case Qt::Key_Up: dy = -KEY_ITEM_MOVE; dx = 0; break;
case Qt::Key_Down: dy = KEY_ITEM_MOVE; dx = 0; break;
}
moveBy( dx , dy );
event->accept();
return;
}
else
{
event->ignore();
}
} | false | false | false | false | false | 0 |
read_values (t_algo_state& state) {
int nb_values = 0;
std::cin >> nb_values;
for (t_activity_id id = 0; id < nb_values; ++id) {
// Read the name.
std::string name;
char c;
std::cin >> c;
while (c != ' ') {
if (c != '\n' || c != '\r')
name += c;
std::cin >> c;
}
// Read the value.
t_cvalue cvalue;
std::cin >> cvalue;
add_to_state(state, id, name, cvalue);
}
} | false | false | false | false | false | 0 |
git_stash_list_command_init (GitStashListCommand *self)
{
self->priv = g_new0 (GitStashListCommandPriv, 1);
self->priv->stash_regex = g_regex_new (STASH_REGEX, 0, 0, NULL);
self->priv->output = g_queue_new ();
} | false | false | false | false | false | 0 |
cmsMLUsetASCII(cmsMLU* mlu, const char LanguageCode[3], const char CountryCode[3], const char* ASCIIString)
{
cmsUInt32Number i, len = (cmsUInt32Number) strlen(ASCIIString)+1;
wchar_t* WStr;
cmsBool rc;
cmsUInt16Number Lang = _cmsAdjustEndianess16(*(cmsUInt16Number*) LanguageCode);
cmsUInt16Number Cntry = _cmsAdjustEndianess16(*(cmsUInt16Number*) CountryCode);
if (mlu == NULL) return FALSE;
WStr = (wchar_t*) _cmsCalloc(mlu ->ContextID, len, sizeof(wchar_t));
if (WStr == NULL) return FALSE;
for (i=0; i < len; i++)
WStr[i] = (wchar_t) ASCIIString[i];
rc = AddMLUBlock(mlu, len * sizeof(wchar_t), WStr, Lang, Cntry);
_cmsFree(mlu ->ContextID, WStr);
return rc;
} | false | false | false | false | false | 0 |
conf_reinit(void)
{
struct conf_binding *cb = 0;
int fd, trans;
unsigned int i;
size_t sz;
char *new_conf_addr = 0;
if ((fd = monitor_open(conf_path, O_RDONLY, 0)) != -1) {
if (check_file_secrecy_fd(fd, conf_path, &sz))
goto fail;
new_conf_addr = malloc(sz);
if (!new_conf_addr) {
log_error("conf_reinit: malloc (%lu) failed",
(unsigned long)sz);
goto fail;
}
/* XXX I assume short reads won't happen here. */
if (read(fd, new_conf_addr, sz) != (int)sz) {
log_error("conf_reinit: read (%d, %p, %lu) failed",
fd, new_conf_addr, (unsigned long)sz);
goto fail;
}
close(fd);
trans = conf_begin();
/* XXX Should we not care about errors and rollback? */
conf_parse(trans, new_conf_addr, sz);
} else {
if (errno != ENOENT)
log_error("conf_reinit: open(\"%s\", O_RDONLY, 0) "
"failed", conf_path);
trans = conf_begin();
}
/* Load default configuration values. */
conf_load_defaults(trans);
/* Free potential existing configuration. */
if (conf_addr) {
for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0];
i++)
for (cb = LIST_FIRST(&conf_bindings[i]); cb;
cb = LIST_FIRST(&conf_bindings[i]))
conf_remove_now(cb->section, cb->tag);
free(conf_addr);
}
conf_end(trans, 1);
conf_addr = new_conf_addr;
return;
fail:
if (new_conf_addr)
free(new_conf_addr);
close(fd);
} | false | true | false | false | true | 1 |
sigint_restore(void)
{
if (!_handler_installed)
return;
if (_handler_installed > 1) {
_handler_installed--;
return;
}
/* Nesting count went down to 0. */
_handler_installed = 0;
if (_oldmasked) {
sigset_t sigs;
sigprocmask(0, NULL, &sigs);
sigaddset(&sigs, SIGINT);
sigprocmask(SIG_SETMASK, &sigs, NULL);
}
sigaction(SIGINT, &_oldhandler, NULL);
} | false | false | false | false | false | 0 |
RecordRegionAddition(const void* start, size_t size) {
// Record start/end info about this memory acquisition call in a new region:
Region region;
region.Create(start, size);
// First get the call stack info into the local varible 'region':
const int depth =
max_stack_depth_ > 0
? MallocHook::GetCallerStackTrace(const_cast<void**>(region.call_stack),
max_stack_depth_, kStripFrames + 1)
: 0;
region.set_call_stack_depth(depth); // record stack info fully
RAW_VLOG(10, "New global region %p..%p from %p",
reinterpret_cast<void*>(region.start_addr),
reinterpret_cast<void*>(region.end_addr),
reinterpret_cast<void*>(region.caller()));
// Note: none of the above allocates memory.
Lock(); // recursively lock
map_size_ += size;
InsertRegionLocked(region);
// This will (eventually) allocate storage for and copy over the stack data
// from region.call_stack_data_ that is pointed by region.call_stack().
Unlock();
} | false | false | false | false | false | 0 |
net80211_set_rate_idx ( struct net80211_device *dev, int rate )
{
assert ( dev->netdev->state & NETDEV_OPEN );
if ( rate >= 0 && rate < dev->nr_rates && rate != dev->rate ) {
DBGC2 ( dev, "802.11 %p changing rate from %d->%d Mbps\n",
dev, dev->rates[dev->rate] / 10,
dev->rates[rate] / 10 );
dev->rate = rate;
net80211_set_rtscts_rate ( dev );
dev->op->config ( dev, NET80211_CFG_RATE );
}
} | false | false | false | false | false | 0 |
main(argc, argv)
char **argv;
{
int n;
char *p;
char *name;
int pagf;
progname = argv[0];
if (p = argv[1]) {
name = (char *) malloc((n = strlen(p)) + 5);
strcpy(name, p);
strcpy(name + n, ".pag");
if ((pagf = open(name, O_RDONLY)) < 0)
oops("cannot open %s.", name);
sdump(pagf);
}
else
oops("usage: %s dbname", progname);
return 0;
} | false | false | false | false | false | 0 |
_parse_ep_map_stream(BITSTREAM *bits, CLPI_EP_MAP_ENTRY *ee)
{
uint32_t fine_start;
int ii;
CLPI_EP_COARSE * coarse;
CLPI_EP_FINE * fine;
bs_seek_byte(bits, ee->ep_map_stream_start_addr);
fine_start = bs_read(bits, 32);
coarse = malloc(ee->num_ep_coarse * sizeof(CLPI_EP_COARSE));
ee->coarse = coarse;
for (ii = 0; ii < ee->num_ep_coarse; ii++) {
coarse[ii].ref_ep_fine_id = bs_read(bits, 18);
coarse[ii].pts_ep = bs_read(bits, 14);
coarse[ii].spn_ep = bs_read(bits, 32);
}
bs_seek_byte(bits, ee->ep_map_stream_start_addr+fine_start);
fine = malloc(ee->num_ep_fine * sizeof(CLPI_EP_FINE));
ee->fine = fine;
for (ii = 0; ii < ee->num_ep_fine; ii++) {
fine[ii].is_angle_change_point = bs_read(bits, 1);
fine[ii].i_end_position_offset = bs_read(bits, 3);
fine[ii].pts_ep = bs_read(bits, 11);
fine[ii].spn_ep = bs_read(bits, 17);
}
return 1;
} | 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.