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
|
---|---|---|---|---|---|---|
Is_Printable_String(const char *s)
{
int result = TRUE;
#if USE_WIDEC_SUPPORT
int count = mbstowcs(0, s, 0);
wchar_t *temp = 0;
assert(s);
if (count > 0
&& (temp = typeCalloc(wchar_t, (2 + (unsigned)count))) != 0)
{
int n;
mbstowcs(temp, s, (unsigned)count);
for (n = 0; n < count; ++n)
if (!iswprint((wint_t) temp[n]))
{
result = FALSE;
break;
}
free(temp);
}
#else
assert(s);
while (*s)
{
if (!isprint(UChar(*s)))
{
result = FALSE;
break;
}
s++;
}
#endif
return result;
}
| false | true | false | false | false | 1 |
extract_nobj(struct obj *obj, struct obj **head_ptr)
{
struct obj *curr, *prev;
curr = *head_ptr;
for (prev = (struct obj *) 0; curr; prev = curr, curr = curr->nobj) {
if (curr == obj) {
if (prev)
prev->nobj = curr->nobj;
else
*head_ptr = curr->nobj;
break;
}
}
if (!curr) panic("extract_nobj: object lost");
obj->where = OBJ_FREE;
}
| false | false | false | false | false | 0 |
lua_load (lua_State *L, lua_Reader reader, void *data,
const char *chunkname) {
ZIO z;
int status;
lua_lock(L);
if (!chunkname) chunkname = "?";
luaZ_init(L, &z, reader, data);
status = luaD_protectedparser(L, &z, chunkname);
lua_unlock(L);
return status;
}
| false | false | false | false | false | 0 |
thrmgr_dispatch_internal(threadpool_t *threadpool, void *user_data, int bulk)
{
int ret = TRUE;
pthread_t thr_id;
if (!threadpool) {
return FALSE;
}
/* Lock the threadpool */
if (pthread_mutex_lock(&(threadpool->pool_mutex)) != 0) {
logg("!Mutex lock failed\n");
return FALSE;
}
do {
work_queue_t *queue;
pthread_cond_t *queueable_cond;
int items;
if (threadpool->state != POOL_VALID) {
ret = FALSE;
break;
}
if (bulk) {
queue = threadpool->bulk_queue;
queueable_cond = &threadpool->queueable_bulk_cond;
} else {
queue = threadpool->single_queue;
queueable_cond = &threadpool->queueable_single_cond;
}
while (thrmgr_contended(threadpool, bulk)) {
logg("$THRMGR: contended, sleeping\n");
pthread_cond_wait(queueable_cond, &threadpool->pool_mutex);
logg("$THRMGR: contended, woken\n");
}
if (!work_queue_add(queue, user_data)) {
ret = FALSE;
break;
}
items = threadpool->single_queue->item_count + threadpool->bulk_queue->item_count;
if ((threadpool->thr_idle < items) &&
(threadpool->thr_alive < threadpool->thr_max)) {
/* Start a new thread */
if (pthread_create(&thr_id, &(threadpool->pool_attr),
thrmgr_worker, threadpool) != 0) {
logg("!pthread_create failed\n");
} else {
threadpool->thr_alive++;
}
}
pthread_cond_signal(&(threadpool->pool_cond));
} while (0);
if (pthread_mutex_unlock(&(threadpool->pool_mutex)) != 0) {
logg("!Mutex unlock failed\n");
return FALSE;
}
return ret;
}
| false | false | false | false | false | 0 |
HandleChDir(char *value)
{
if (!IsAbsoluteFileName(value))
{
yyerror("chdir is not an absolute directory name");
}
strcpy(CHDIR,value);
}
| false | false | false | false | false | 0 |
__eft_release ( CMPIEnumeration * enumeration )
{
struct native_enum * e = (struct native_enum *) enumeration;
CMPIStatus st= { CMPI_RC_OK, NULL };
if (e) {
if (e->data)
st = CMRelease(e->data);
free ( enumeration );
return st;
}
CMReturn ( CMPI_RC_ERR_FAILED );
}
| false | false | false | false | false | 0 |
format(int64_t number,
const UnicodeString& ruleSetName,
UnicodeString& toAppendTo,
FieldPosition& /* pos */,
UErrorCode& status) const
{
if (U_SUCCESS(status)) {
if (ruleSetName.indexOf(gPercentPercent) == 0) {
// throw new IllegalArgumentException("Can't use internal rule set");
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
NFRuleSet *rs = findRuleSet(ruleSetName, status);
if (rs) {
rs->format(number, toAppendTo, toAppendTo.length());
}
}
}
return toAppendTo;
}
| false | false | false | false | false | 0 |
setCurrentOption ( const std::string value )
{
int action = parameterOption(value);
if (action >= 0)
currentKeyWord_ = action;
}
| false | false | false | false | false | 0 |
NewStream(NPMIMEType /*type*/, NPStream* stream,
NPBool /*seekable*/, uint16_t* /*stype*/)
{
// gnash::log_debug("%s: %x", __PRETTY_FUNCTION__, (void *)this);
if (_childpid) {
// Apparently the child process has already been started for this
// plugin instance. It is puzzling that this method gets called
// again. Starting a new process for the same movie will cause
// problems later, so we'll stop here.
return NPERR_GENERIC_ERROR;
}
_swf_url = stream->url;
if (!_swf_url.empty() && _window) {
return startProc();
}
return NPERR_NO_ERROR;
}
| false | false | false | false | false | 0 |
mei_cl_bus_dev_setup(struct mei_device *bus,
struct mei_cl_device *cldev)
{
cldev->do_match = 1;
mei_cl_bus_dev_fixup(cldev);
/* the device name can change during fix up */
if (cldev->do_match)
mei_cl_bus_set_name(cldev);
return cldev->do_match == 1;
}
| false | false | false | false | false | 0 |
move_thread(int new_thread_id)
{
if (likely(_thread != 0)) {
RouterThread *new_thread = master()->thread(new_thread_id);
// (new_thread->thread_id() might != new_thread_id)
_status.home_thread_id = new_thread->thread_id();
if (_status.home_thread_id != _thread->thread_id())
move_thread_second_half();
}
}
| false | false | false | false | false | 0 |
xmms_html_browse (xmms_xform_t *xform, const gchar *url,
xmms_error_t *error)
{
gchar buffer[XMMS_XFORM_MAX_LINE_SIZE];
const gchar *plsurl;
gchar *tagbeg, *aurl, *full;
xmms_error_reset (error);
plsurl = xmms_xform_get_url (xform);
while (xmms_xform_read_line (xform, buffer, error)) {
tagbeg = buffer;
while ((tagbeg = strchr (tagbeg, '<'))) {
if ((aurl = parse_tag (++tagbeg, plsurl))) {
full = xmms_build_playlist_url (plsurl,
aurl);
xmms_xform_browse_add_symlink (xform,
NULL, full);
g_free (full);
g_free (aurl);
}
}
}
return TRUE;
}
| false | false | false | false | false | 0 |
bnx2x_get_credit_vlan(struct bnx2x_vlan_mac_obj *o)
{
struct bnx2x_credit_pool_obj *vp = o->vlans_pool;
WARN_ON(!vp);
return vp->get(vp, 1);
}
| false | false | false | false | false | 0 |
send_notify_response(private_task_manager_t *this,
message_t *request, notify_type_t type,
chunk_t data)
{
message_t *response;
packet_t *packet;
host_t *me, *other;
response = message_create(IKEV2_MAJOR_VERSION, IKEV2_MINOR_VERSION);
response->set_exchange_type(response, request->get_exchange_type(request));
response->set_request(response, FALSE);
response->set_message_id(response, request->get_message_id(request));
response->add_notify(response, FALSE, type, data);
me = this->ike_sa->get_my_host(this->ike_sa);
if (me->is_anyaddr(me))
{
me = request->get_destination(request);
this->ike_sa->set_my_host(this->ike_sa, me->clone(me));
}
other = this->ike_sa->get_other_host(this->ike_sa);
if (other->is_anyaddr(other))
{
other = request->get_source(request);
this->ike_sa->set_other_host(this->ike_sa, other->clone(other));
}
response->set_source(response, me->clone(me));
response->set_destination(response, other->clone(other));
if (this->ike_sa->generate_message(this->ike_sa, response,
&packet) == SUCCESS)
{
charon->sender->send(charon->sender, packet);
}
response->destroy(response);
}
| false | false | false | false | false | 0 |
glp_netgen_prob(int nprob, int parm[1+15])
{ int k;
if (!(101 <= nprob && nprob <= 150))
xerror("glp_netgen_prob: nprob = %d; invalid problem instance "
"number\n", nprob);
for (k = 1; k <= 15; k++)
parm[k] = data[nprob-101][k];
return;
}
| false | false | false | false | false | 0 |
kirk_CMD4(u8* outbuff, u8* inbuff, int size)
{
KIRK_AES128CBC_HEADER *header = (KIRK_AES128CBC_HEADER*)inbuff;
u8* key;
AES_ctx aesKey;
if (is_kirk_initialized == 0) return KIRK_NOT_INITIALIZED;
if (header->mode != KIRK_MODE_ENCRYPT_CBC) return KIRK_INVALID_MODE;
if (header->data_size == 0) return KIRK_DATA_SIZE_ZERO;
key = kirk_4_7_get_key(header->keyseed);
if (key == (u8*)KIRK_INVALID_SIZE) return KIRK_INVALID_SIZE;
// Set the key
AES_set_key(&aesKey, key, 128);
AES_cbc_encrypt(&aesKey, inbuff+sizeof(KIRK_AES128CBC_HEADER), outbuff+sizeof(KIRK_AES128CBC_HEADER), size);
return KIRK_OPERATION_SUCCESS;
}
| false | false | false | false | false | 0 |
mode_for_size (unsigned int size, enum mode_class mclass, int limit)
{
enum machine_mode mode;
if (limit && size > MAX_FIXED_MODE_SIZE)
return BLKmode;
/* Get the first mode which has this size, in the specified class. */
for (mode = GET_CLASS_NARROWEST_MODE (mclass); mode != VOIDmode;
mode = GET_MODE_WIDER_MODE (mode))
if (GET_MODE_PRECISION (mode) == size)
return mode;
return BLKmode;
}
| false | false | false | false | false | 0 |
_file_selector_hook(void *data __UNUSED__, Evas_Object *obj __UNUSED__, Eina_Bool allow_multiple __UNUSED__, Eina_List *accept_types __UNUSED__, Eina_List **selected_files, Eina_Bool *response)
{
*selected_files = eina_list_append(NULL,
strdup("/path/to/non_existing_file"));
*response = EINA_TRUE;
return NULL;
}
| false | false | false | false | false | 0 |
devicedef_revuser_agent(const void* item) {
devicedef_t* device = (devicedef_t*)item;
char* revuser_agent = NULL;
if(device->user_agent!=NULL) {
char* reverse_ua = malloc(sizeof(char) * (strlen(device->user_agent) + 1));
if(!reverse_ua) {
error(1, errno, "error allocating memory for reverse user-agent");
}
revuser_agent = strrev(reverse_ua, device->user_agent);
}
return revuser_agent;
}
| false | false | false | false | false | 0 |
cxd2841er_chip_id(struct cxd2841er_priv *priv)
{
u8 chip_id;
dev_dbg(&priv->i2c->dev, "%s()\n", __func__);
cxd2841er_write_reg(priv, I2C_SLVT, 0, 0);
cxd2841er_read_reg(priv, I2C_SLVT, 0xfd, &chip_id);
return chip_id;
}
| false | false | false | false | false | 0 |
value_added_current_editor (AnjutaPlugin *plugin, const char *name,
const GValue *value, gpointer data)
{
GObject *editor;
editor = g_value_get_object (value);
if (!IANJUTA_IS_EDITOR(editor))
return;
BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);
ba_plugin->current_editor = IANJUTA_EDITOR (editor);
if (g_hash_table_lookup (ba_plugin->editors_created,
ba_plugin->current_editor) == NULL)
{
g_hash_table_insert (ba_plugin->editors_created,
ba_plugin->current_editor,
ba_plugin->current_editor);
g_signal_connect (ba_plugin->current_editor, "destroy",
G_CALLBACK (on_editor_destroy), plugin);
g_signal_connect (ba_plugin->current_editor, "changed",
G_CALLBACK (on_editor_changed), plugin);
}
if (ba_plugin->current_editor_file != NULL) g_object_unref (ba_plugin->current_editor_file);
ba_plugin->current_editor_file = ianjuta_file_get_file (IANJUTA_FILE (editor), NULL);
update_module_ui (ba_plugin);
ba_plugin->update_indicators_idle = g_idle_add (on_update_indicators_idle, plugin);
}
| false | false | false | false | false | 0 |
recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
{
char hex_rs[IPMI_SERIAL_MAX_RESPONSE * 3];
int i, j, resp_len = 0;
unsigned long rv;
char *p, *pp;
char ch, str_hex[3];
p = hex_rs;
while (1) {
if ((rv = serial_read_line(intf, p, sizeof(hex_rs) - resp_len)) < 0) {
/* error */
return -1;
}
p += rv;
resp_len += rv;
if (*(p - 2) == ']' && (*(p - 1) == '\n' || *(p - 1) == '\r')) {
*p = 0;
break;
}
}
p = strrchr(hex_rs, '[');
if (!p) {
lprintf(LOG_ERR, "Serial response is invalid");
return -1;
}
p++;
pp = strchr(p, ']');
if (!pp) {
lprintf(LOG_ERR, "Serial response is invalid");
return -1;
}
*pp = 0;
/* was it an error? */
if (strncmp(p, "ERR ", 4) == 0) {
serial_write_line(intf, "\r\r\r\r");
sleep(1);
serial_flush(intf);
errno = 0;
rv = strtoul(p + 4, &p, 16);
if ((rv && rv < 0x100 && *p == '\0')
|| (rv == 0 && !errno)) {
/* The message didn't get it through. The upper
level will have to re-send */
return 0;
} else {
lprintf(LOG_ERR, "Serial response is invalid");
return -1;
}
}
/* this is needed for correct string to long conversion */
str_hex[2] = 0;
/* parse the response */
i = 0;
j = 0;
while (*p) {
if (i >= len) {
lprintf(LOG_ERR, "Serial response is too long(%d, %d)", i, len);
return -1;
}
ch = *(p++);
if (isxdigit(ch)) {
str_hex[j++] = ch;
} else {
if (j == 1 || !isspace(ch)) {
lprintf(LOG_ERR, "Serial response is invalid");
return -1;
}
}
if (j == 2) {
unsigned long tmp;
errno = 0;
/* parse the hex number */
tmp = strtoul(str_hex, NULL, 16);
if ( tmp > 0xFF || ( !tmp && errno ) ) {
lprintf(LOG_ERR, "Serial response is invalid");
return -1;
}
data[i++] = tmp;
j = 0;
}
}
return i;
}
| true | true | false | false | false | 1 |
img_copy_merge(img, img_dest, dx, dy, sx, sy, w, h, pct)
VALUE img, img_dest, dx, dy, sx, sy, w, h, pct;
{
gdImagePtr im, im_dest;
Data_Get_Struct(img, gdImage, im);
image_req(img_dest);
Data_Get_Struct(img_dest, gdImage, im_dest);
#ifdef ENABLE_GD_2_0
if (is_truecolor(im) && (!is_truecolor(im_dest))){
rb_raise(rb_eRuntimeError,
"Copying truecolor image to palette image is not permitted");
}
#endif
gdImageCopyMerge(im_dest,im,NUM2INT(dx),NUM2INT(dy),NUM2INT(sx),NUM2INT(sy),NUM2INT(w),NUM2INT(h), NUM2INT(pct));
return img;
}
| false | false | false | false | false | 0 |
value_to_symstr(ulong value, char *buf, ulong radix)
{
struct syment *sp;
ulong offset;
char *p1, locbuf[BUFSIZE];
struct load_module *lm;
sp = NULL;
offset = 0;
buf[0] = NULLCHAR;
if (!radix)
radix = *gdb_output_radix;
if ((radix != 10) && (radix != 16))
radix = 16;
if ((sp = value_search(value, &offset))) {
if (offset)
sprintf(buf, radix == 16 ? "%s+0x%lx" : "%s+%ld",
sp->name, offset);
else
sprintf(buf, "%s", sp->name);
}
if (module_symbol(value, NULL, NULL, locbuf, *gdb_output_radix)) {
if (sp) {
if (STRNEQ(locbuf, "_MODULE_START_"))
shift_string_left(locbuf,
strlen("_MODULE_START_"));
if ((p1 = strstr(locbuf, "+")))
*p1 = NULLCHAR;
if (offset) {
if (is_module_name(locbuf, NULL, &lm) &&
(value < lm->mod_text_start))
sprintf(buf, radix == 16 ?
"(%s module)+0x%lx" :
"(%s module)+%ld",
locbuf, offset);
else
sprintf(buf, radix == 16 ?
"%s+0x%lx" : "%s+%ld",
locbuf, offset);
} else {
if (is_module_name(locbuf, NULL, &lm) &&
(value < lm->mod_text_start))
sprintf(buf, "(%s)", locbuf);
else
sprintf(buf, "%s", locbuf);
}
} else
sprintf(buf, "%s", locbuf);
}
return(buf);
}
| false | false | false | false | false | 0 |
ocfs2_get_refcount_cpos_end(struct ocfs2_caching_info *ci,
struct buffer_head *ref_root_bh,
struct ocfs2_extent_block *eb,
struct ocfs2_extent_list *el,
int index, u32 *cpos_end)
{
int ret, i, subtree_root;
u32 cpos;
u64 blkno;
struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
struct ocfs2_path *left_path = NULL, *right_path = NULL;
struct ocfs2_extent_tree et;
struct ocfs2_extent_list *tmp_el;
if (index < le16_to_cpu(el->l_next_free_rec) - 1) {
/*
* We have a extent rec after index, so just use the e_cpos
* of the next extent rec.
*/
*cpos_end = le32_to_cpu(el->l_recs[index+1].e_cpos);
return 0;
}
if (!eb || (eb && !eb->h_next_leaf_blk)) {
/*
* We are the last extent rec, so any high cpos should
* be stored in this leaf refcount block.
*/
*cpos_end = UINT_MAX;
return 0;
}
/*
* If the extent block isn't the last one, we have to find
* the subtree root between this extent block and the next
* leaf extent block and get the corresponding e_cpos from
* the subroot. Otherwise we may corrupt the b-tree.
*/
ocfs2_init_refcount_extent_tree(&et, ci, ref_root_bh);
left_path = ocfs2_new_path_from_et(&et);
if (!left_path) {
ret = -ENOMEM;
mlog_errno(ret);
goto out;
}
cpos = le32_to_cpu(eb->h_list.l_recs[index].e_cpos);
ret = ocfs2_find_path(ci, left_path, cpos);
if (ret) {
mlog_errno(ret);
goto out;
}
right_path = ocfs2_new_path_from_path(left_path);
if (!right_path) {
ret = -ENOMEM;
mlog_errno(ret);
goto out;
}
ret = ocfs2_find_cpos_for_right_leaf(sb, left_path, &cpos);
if (ret) {
mlog_errno(ret);
goto out;
}
ret = ocfs2_find_path(ci, right_path, cpos);
if (ret) {
mlog_errno(ret);
goto out;
}
subtree_root = ocfs2_find_subtree_root(&et, left_path,
right_path);
tmp_el = left_path->p_node[subtree_root].el;
blkno = left_path->p_node[subtree_root+1].bh->b_blocknr;
for (i = 0; i < le16_to_cpu(tmp_el->l_next_free_rec); i++) {
if (le64_to_cpu(tmp_el->l_recs[i].e_blkno) == blkno) {
*cpos_end = le32_to_cpu(tmp_el->l_recs[i+1].e_cpos);
break;
}
}
BUG_ON(i == le16_to_cpu(tmp_el->l_next_free_rec));
out:
ocfs2_free_path(left_path);
ocfs2_free_path(right_path);
return ret;
}
| false | false | false | false | false | 0 |
bpcharle(PG_FUNCTION_ARGS)
{
BpChar *arg1 = PG_GETARG_BPCHAR_PP(0);
BpChar *arg2 = PG_GETARG_BPCHAR_PP(1);
int len1,
len2;
int cmp;
len1 = bcTruelen(arg1);
len2 = bcTruelen(arg2);
cmp = varstr_cmp(VARDATA_ANY(arg1), len1, VARDATA_ANY(arg2), len2);
PG_FREE_IF_COPY(arg1, 0);
PG_FREE_IF_COPY(arg2, 1);
PG_RETURN_BOOL(cmp <= 0);
}
| false | false | false | false | false | 0 |
setProperty(QWidget *w, const QVariant &v)
{
/* QButtonGroup *bg = qobject_cast<QButtonGroup *>(w);
if (bg)
{
QAbstractButton *b = bg->button(v.toInt());
if (b)
b->setDown(true);
return;
}*/
QByteArray userproperty = getCustomProperty(w);
if (userproperty.isEmpty()) {
userproperty = getUserProperty(w);
}
if (userproperty.isEmpty()) {
QComboBox *cb = qobject_cast<QComboBox *>(w);
if (cb) {
if (cb->isEditable()) {
int i = cb->findText(v.toString());
if (i != -1) {
cb->setCurrentIndex(i);
} else {
cb->setEditText(v.toString());
}
} else {
cb->setCurrentIndex(v.toInt());
}
return;
}
}
if (userproperty.isEmpty()) {
kWarning(d->debugArea()) << w->metaObject()->className() << " widget not handled!";
return;
}
w->setProperty(userproperty, v);
}
| false | false | false | false | false | 0 |
tar_extract_glob(TAR *t, char *globname, char *prefix)
{
char *filename;
char buf[TAR_MAXPATHLEN];
int i;
char *pathname;
while ((i = th_read(t)) == 0)
{
pathname = th_get_pathname(t);
filename = pathname;
if (fnmatch(globname, filename, FNM_PATHNAME | FNM_PERIOD))
{
if (pathname)
{
free(pathname);
}
if (TH_ISREG(t) && tar_skip_regfile(t))
return -1;
continue;
}
if (t->options & TAR_VERBOSE)
th_print_long_ls(t);
if (prefix != NULL)
snprintf(buf, sizeof(buf), "%s/%s", prefix, filename);
else
strlcpy(buf, filename, sizeof(buf));
if (tar_extract_file(t, filename) != 0)
{
if (pathname)
{
free(pathname);
}
return -1;
}
if (pathname)
{
free(pathname);
}
}
return (i == 1 ? 0 : -1);
}
| true | true | false | false | false | 1 |
safe_getenv(const struct tls_info *info, const char *n)
{
const char *v=(*info->getconfigvar)(n, info->app_data);
if (!v) v="";
return (v);
}
| false | false | false | false | false | 0 |
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
{
PyObject *tmp;
if (value == NULL) {
PyErr_SetString(PyExc_TypeError,
"function's dictionary may not be deleted");
return -1;
}
if (!PyDict_Check(value)) {
PyErr_SetString(PyExc_TypeError,
"setting function's dictionary to a non-dict");
return -1;
}
tmp = op->func_dict;
Py_INCREF(value);
op->func_dict = value;
Py_XDECREF(tmp);
return 0;
}
| false | false | false | false | false | 0 |
krb5_pac_get_types(krb5_context context,
krb5_pac pac,
size_t *len,
krb5_ui_4 **types)
{
size_t i;
*types = (krb5_ui_4 *)malloc(pac->pac->cBuffers * sizeof(krb5_ui_4));
if (*types == NULL)
return ENOMEM;
*len = pac->pac->cBuffers;
for (i = 0; i < pac->pac->cBuffers; i++)
(*types)[i] = pac->pac->Buffers[i].ulType;
return 0;
}
| false | true | false | false | false | 1 |
get()
{
RegisterValue rv = m_cpu->registers[m_addr]->getRV();
rv.data = (rv.data+2) & 0xffff;
m_cpu->registers[m_addr]->putRV(rv);
RegisterValue retRV = rv.init ? m_unknown : m_cpu->registers[rv.data]->getRV();
return retRV;
}
| false | false | false | false | false | 0 |
detect_stride(__isl_take isl_constraint *c, void *user)
{
struct isl_detect_stride_data *data = user;
int i, n_div;
isl_ctx *ctx;
isl_val *v, *stride, *m;
if (!isl_constraint_is_equality(c) ||
!isl_constraint_involves_dims(c, isl_dim_set, data->pos, 1)) {
isl_constraint_free(c);
return 0;
}
ctx = isl_constraint_get_ctx(c);
stride = isl_val_zero(ctx);
n_div = isl_constraint_dim(c, isl_dim_div);
for (i = 0; i < n_div; ++i) {
v = isl_constraint_get_coefficient_val(c, isl_dim_div, i);
stride = isl_val_gcd(stride, v);
}
v = isl_constraint_get_coefficient_val(c, isl_dim_set, data->pos);
m = isl_val_gcd(isl_val_copy(stride), isl_val_copy(v));
stride = isl_val_div(stride, isl_val_copy(m));
v = isl_val_div(v, isl_val_copy(m));
if (!isl_val_is_zero(stride) && !isl_val_is_one(stride)) {
isl_aff *aff;
isl_val *gcd, *a, *b;
gcd = isl_val_gcdext(v, isl_val_copy(stride), &a, &b);
isl_val_free(gcd);
isl_val_free(b);
aff = isl_constraint_get_aff(c);
for (i = 0; i < n_div; ++i)
aff = isl_aff_set_coefficient_si(aff,
isl_dim_div, i, 0);
aff = isl_aff_set_coefficient_si(aff, isl_dim_in, data->pos, 0);
a = isl_val_neg(a);
aff = isl_aff_scale_val(aff, a);
aff = isl_aff_scale_down_val(aff, m);
data->build = set_stride(data->build, stride, aff);
} else {
isl_val_free(stride);
isl_val_free(m);
isl_val_free(v);
}
isl_constraint_free(c);
return 0;
}
| false | false | false | false | false | 0 |
SetFeatureDefn(OGRFeatureDefn *poFeatureDefn,
TABFieldType *paeMapInfoNativeFieldTypes /* =NULL */)
{
if (m_poRelation)
return m_poRelation->SetFeatureDefn(poFeatureDefn);
return -1;
}
| false | false | false | false | false | 0 |
pollForModemLock(Modem& modem)
{
if (modem.lock->lock()) {
modem.release();
traceModem(modem, "READY (end polling)");
pokeScheduler();
} else
modem.startLockPolling(pollLockWait);
}
| false | false | false | false | false | 0 |
can_blnd(magr, mdef, aatyp, obj)
struct monst *magr; /* NULL == no specific aggressor */
struct monst *mdef;
uchar aatyp;
struct obj *obj; /* aatyp == AT_WEAP, AT_SPIT */
{
boolean is_you = (mdef == &youmonst);
boolean check_visor = FALSE;
struct obj *o;
const char *s;
/* no eyes protect against all attacks for now */
if (!haseyes(mdef->data))
return FALSE;
switch(aatyp) {
case AT_EXPL: case AT_BOOM: case AT_GAZE: case AT_MAGC:
case AT_BREA: /* assumed to be lightning */
/* light-based attacks may be cancelled or resisted */
if (magr && magr->mcan)
return FALSE;
return !resists_blnd(mdef);
case AT_WEAP: case AT_SPIT: case AT_NONE:
/* an object is used (thrown/spit/other) */
if (obj && (obj->otyp == CREAM_PIE || obj->otyp == GOOSE_POOP)) {
if (is_you && Blindfolded)
return FALSE;
} else if (obj && (obj->otyp == BLINDING_VENOM)) {
/* all ublindf, including LENSES, protect, cream-pies too */
if (is_you && (ublindf || u.ucreamed))
return FALSE;
check_visor = TRUE;
} else if (obj && (obj->otyp == POT_BLINDNESS)) {
return TRUE; /* no defense */
} else
return FALSE; /* other objects cannot cause blindness yet */
if ((magr == &youmonst) && u.uswallow)
return FALSE; /* can't affect eyes while inside monster */
break;
case AT_ENGL:
if (is_you && (Blindfolded || u.usleep || u.ucreamed))
return FALSE;
if (!is_you && mdef->msleeping)
return FALSE;
break;
case AT_CLAW:
/* e.g. raven: all ublindf, including LENSES, protect */
if (is_you && ublindf)
return FALSE;
if ((magr == &youmonst) && u.uswallow)
return FALSE; /* can't affect eyes while inside monster */
check_visor = TRUE;
break;
case AT_TUCH: case AT_STNG:
/* some physical, blind-inducing attacks can be cancelled */
if (magr && magr->mcan)
return FALSE;
break;
default:
break;
}
/* check if wearing a visor (only checked if visor might help) */
if (check_visor) {
o = (mdef == &youmonst) ? invent : mdef->minvent;
for ( ; o; o = o->nobj)
if ((o->owornmask & W_ARMH) &&
(s = OBJ_DESCR(objects[o->otyp])) != (char *)0 &&
!strcmp(s, "visored helmet"))
return FALSE;
}
return TRUE;
}
| false | false | false | false | false | 0 |
min_range(int* A, int l, int r){
if(r>l)return 0;
printf("[l, r] = [%d, %d]\n", l, r);
int min = INT_MAX;
int i;
for(i=l; i<=l; i++)
min = (A[i]<min?A[i]:min);
printf("min = %d\n", min);
return min;
}
| false | false | false | false | false | 0 |
check_and_set_new_selection (GthImageSelector *self,
cairo_rectangle_int_t new_selection)
{
new_selection.width = MAX (0, new_selection.width);
new_selection.height = MAX (0, new_selection.height);
if (self->priv->bind_dimensions && (self->priv->bind_factor > 1)) {
new_selection.width = bind_dimension (new_selection.width, self->priv->bind_factor);
new_selection.height = bind_dimension (new_selection.height, self->priv->bind_factor);
}
if (((self->priv->current_area == NULL)
|| (self->priv->current_area->id != C_SELECTION_AREA))
&& self->priv->use_ratio)
{
if (! rectangle_in_rectangle (new_selection, self->priv->surface_area))
return FALSE;
set_selection (self, new_selection, FALSE);
return TRUE;
}
/* self->priv->current_area->id == C_SELECTION_AREA */
if (new_selection.x < 0)
new_selection.x = 0;
if (new_selection.y < 0)
new_selection.y = 0;
if (new_selection.width > self->priv->surface_area.width)
new_selection.width = self->priv->surface_area.width;
if (new_selection.height > self->priv->surface_area.height)
new_selection.height = self->priv->surface_area.height;
if (new_selection.x + new_selection.width > self->priv->surface_area.width)
new_selection.x = self->priv->surface_area.width - new_selection.width;
if (new_selection.y + new_selection.height > self->priv->surface_area.height)
new_selection.y = self->priv->surface_area.height - new_selection.height;
set_selection (self, new_selection, FALSE);
return TRUE;
}
| false | false | false | false | false | 0 |
jfs_ioc_trim(struct inode *ip, struct fstrim_range *range)
{
struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap;
struct bmap *bmp = JFS_SBI(ip->i_sb)->bmap;
struct super_block *sb = ipbmap->i_sb;
int agno, agno_end;
u64 start, end, minlen;
u64 trimmed = 0;
/**
* convert byte values to block size of filesystem:
* start: First Byte to trim
* len: number of Bytes to trim from start
* minlen: minimum extent length in Bytes
*/
start = range->start >> sb->s_blocksize_bits;
end = start + (range->len >> sb->s_blocksize_bits) - 1;
minlen = range->minlen >> sb->s_blocksize_bits;
if (minlen == 0)
minlen = 1;
if (minlen > bmp->db_agsize ||
start >= bmp->db_mapsize ||
range->len < sb->s_blocksize)
return -EINVAL;
if (end >= bmp->db_mapsize)
end = bmp->db_mapsize - 1;
/**
* we trim all ag's within the range
*/
agno = BLKTOAG(start, JFS_SBI(ip->i_sb));
agno_end = BLKTOAG(end, JFS_SBI(ip->i_sb));
while (agno <= agno_end) {
trimmed += dbDiscardAG(ip, agno, minlen);
agno++;
}
range->len = trimmed << sb->s_blocksize_bits;
return 0;
}
| false | false | false | false | false | 0 |
setData(const QModelIndex &index, const QVariant &value, int role)
{
Q_UNUSED(value);
if( ! index.isValid() /*|| ! (d->mode & UserCheckable)*/ )
return false;
Action *act = action( index );
if ( act ) {
switch( role ) {
//case Qt::EditRole: act->setText( value.toString() ); break;
case Qt::CheckStateRole: act->setEnabled( ! act->isEnabled() ); break;
default: return false;
}
return false;
}
ActionCollection *coll = collection( index );
if ( coll ) {
switch( role ) {
//case Qt::EditRole: item->coll->setText( value.toString() ); break;
case Qt::CheckStateRole: coll->setEnabled( ! coll->isEnabled() ); break;
default: return false;
}
return false;
}
//emit dataChanged(index, index);
return true;
}
| false | false | false | false | false | 0 |
OnMenuWatchDereference(cb_unused wxCommandEvent& event)
{
cbWatchesDlg *watches = Manager::Get()->GetDebuggerManager()->GetWatchesDialog();
if (!watches)
return;
watches->RenameWatch(m_watchToDereferenceProperty, wxT("*") + m_watchToDereferenceSymbol);
m_watchToDereferenceProperty = NULL;
m_watchToDereferenceSymbol = wxEmptyString;
}
| false | false | false | false | false | 0 |
kwbimage_check_params(struct image_tool_params *params)
{
if (!strlen(params->imagename)) {
fprintf(stderr, "Error:%s - Configuration file not specified, "
"it is needed for kwbimage generation\n",
params->cmdname);
return CFG_INVALID;
}
return (params->dflag && (params->fflag || params->lflag)) ||
(params->fflag && (params->dflag || params->lflag)) ||
(params->lflag && (params->dflag || params->fflag)) ||
(params->xflag) || !(strlen(params->imagename));
}
| false | false | false | false | false | 0 |
qSafeXDestroyImage( XImage *x )
{
if ( x->data ) {
free( x->data );
x->data = 0;
}
XDestroyImage( x );
}
| false | false | false | false | false | 0 |
px_put_a(stream * s, px_attribute_t a)
{
sputc(s, pxt_attr_ubyte);
sputc(s, (byte)a);
}
| false | false | false | false | false | 0 |
store( QDomNode & node, QDomDocument & document ) const
{
// store base annotation properties
storeBaseAnnotationProperties( node, document );
// create [line] element
QDomElement lineElement = document.createElement( "line" );
node.appendChild( lineElement );
// store the attributes
if ( lineStartStyle() != None )
lineElement.setAttribute( "startStyle", (int)lineStartStyle() );
if ( lineEndStyle() != None )
lineElement.setAttribute( "endStyle", (int)lineEndStyle() );
if ( isLineClosed() )
lineElement.setAttribute( "closed", isLineClosed() );
if ( lineInnerColor().isValid() )
lineElement.setAttribute( "innerColor", lineInnerColor().name() );
if ( lineLeadingForwardPoint() != 0.0 )
lineElement.setAttribute( "leadFwd", QString::number( lineLeadingForwardPoint() ) );
if ( lineLeadingBackPoint() != 0.0 )
lineElement.setAttribute( "leadBack", QString::number( lineLeadingBackPoint() ) );
if ( lineShowCaption() )
lineElement.setAttribute( "showCaption", lineShowCaption() );
if ( lineIntent() != Unknown )
lineElement.setAttribute( "intent", lineIntent() );
// append the list of points
const QLinkedList<QPointF> points = linePoints();
if ( points.count() > 1 )
{
QLinkedList<QPointF>::const_iterator it = points.begin(), end = points.end();
while ( it != end )
{
const QPointF & p = *it;
QDomElement pElement = document.createElement( "point" );
lineElement.appendChild( pElement );
pElement.setAttribute( "x", QString::number( p.x() ) );
pElement.setAttribute( "y", QString::number( p.y() ) );
++it;
}
}
}
| false | false | false | false | false | 0 |
trydecpoint (LexState *ls, TValue *o) {
char old = ls->decpoint;
ls->decpoint = l_getlocaledecpoint();
buffreplace(ls, old, ls->decpoint); /* try new decimal separator */
if (!buff2num(ls->buff, o)) {
/* format error with correct decimal point: no more options */
buffreplace(ls, ls->decpoint, '.'); /* undo change (for error message) */
lexerror(ls, "malformed number", TK_FLT);
}
}
| false | false | false | false | false | 0 |
enchant_get_registry_value (const char * const prefix, const char * const key)
{
char *val;
g_return_val_if_fail (prefix, NULL);
g_return_val_if_fail (key, NULL);
val = enchant_get_registry_value_ex(1, prefix, key);
if(val == NULL) {
val = enchant_get_registry_value_ex (0, prefix, key);
}
return val;
}
| false | false | false | false | false | 0 |
ResetSequenceProgress(Sequence NewSeq) {
DEBUG(dbgs() << " Resetting sequence progress.\n");
SetSeq(NewSeq);
Partial = false;
RRI.clear();
}
| false | false | false | false | false | 0 |
set_nonzero_bits_and_sign_copies (x, set, data)
rtx x;
rtx set;
void *data ATTRIBUTE_UNUSED;
{
unsigned int num;
if (GET_CODE (x) == REG
&& REGNO (x) >= FIRST_PSEUDO_REGISTER
/* If this register is undefined at the start of the file, we can't
say what its contents were. */
&& ! REGNO_REG_SET_P (ENTRY_BLOCK_PTR->next_bb->global_live_at_start, REGNO (x))
&& GET_MODE_BITSIZE (GET_MODE (x)) <= HOST_BITS_PER_WIDE_INT)
{
if (set == 0 || GET_CODE (set) == CLOBBER)
{
reg_nonzero_bits[REGNO (x)] = GET_MODE_MASK (GET_MODE (x));
reg_sign_bit_copies[REGNO (x)] = 1;
return;
}
/* If this is a complex assignment, see if we can convert it into a
simple assignment. */
set = expand_field_assignment (set);
/* If this is a simple assignment, or we have a paradoxical SUBREG,
set what we know about X. */
if (SET_DEST (set) == x
|| (GET_CODE (SET_DEST (set)) == SUBREG
&& (GET_MODE_SIZE (GET_MODE (SET_DEST (set)))
> GET_MODE_SIZE (GET_MODE (SUBREG_REG (SET_DEST (set)))))
&& SUBREG_REG (SET_DEST (set)) == x))
{
rtx src = SET_SRC (set);
#ifdef SHORT_IMMEDIATES_SIGN_EXTEND
/* If X is narrower than a word and SRC is a non-negative
constant that would appear negative in the mode of X,
sign-extend it for use in reg_nonzero_bits because some
machines (maybe most) will actually do the sign-extension
and this is the conservative approach.
??? For 2.5, try to tighten up the MD files in this regard
instead of this kludge. */
if (GET_MODE_BITSIZE (GET_MODE (x)) < BITS_PER_WORD
&& GET_CODE (src) == CONST_INT
&& INTVAL (src) > 0
&& 0 != (INTVAL (src)
& ((HOST_WIDE_INT) 1
<< (GET_MODE_BITSIZE (GET_MODE (x)) - 1))))
src = GEN_INT (INTVAL (src)
| ((HOST_WIDE_INT) (-1)
<< GET_MODE_BITSIZE (GET_MODE (x))));
#endif
/* Don't call nonzero_bits if it cannot change anything. */
if (reg_nonzero_bits[REGNO (x)] != ~(unsigned HOST_WIDE_INT) 0)
reg_nonzero_bits[REGNO (x)]
|= nonzero_bits (src, nonzero_bits_mode);
num = num_sign_bit_copies (SET_SRC (set), GET_MODE (x));
if (reg_sign_bit_copies[REGNO (x)] == 0
|| reg_sign_bit_copies[REGNO (x)] > num)
reg_sign_bit_copies[REGNO (x)] = num;
}
else
{
reg_nonzero_bits[REGNO (x)] = GET_MODE_MASK (GET_MODE (x));
reg_sign_bit_copies[REGNO (x)] = 1;
}
}
}
| false | false | false | false | false | 0 |
plugin_get_ir_dummy_bfd (const char *name, bfd *srctemplate)
{
bfd *abfd;
bfd_use_reserved_id = 1;
abfd = bfd_create (concat (name, IRONLY_SUFFIX, (const char *) NULL),
srctemplate);
if (abfd != NULL)
{
abfd->flags |= BFD_LINKER_CREATED | BFD_PLUGIN;
bfd_set_arch_info (abfd, bfd_get_arch_info (srctemplate));
bfd_set_gp_size (abfd, bfd_get_gp_size (srctemplate));
if (bfd_make_writable (abfd)
&& bfd_copy_private_bfd_data (srctemplate, abfd))
{
flagword flags;
/* Create section to own the symbols. */
flags = (SEC_CODE | SEC_HAS_CONTENTS | SEC_READONLY
| SEC_ALLOC | SEC_LOAD | SEC_KEEP | SEC_EXCLUDE);
if (bfd_make_section_anyway_with_flags (abfd, ".text", flags))
return abfd;
}
}
einfo (_("could not create dummy IR bfd: %F%E\n"));
return NULL;
}
| false | false | false | false | false | 0 |
build_hint_from_stack (MonoDomain *domain, void **stack, gint stack_entries)
{
gchar *hint;
MonoMethod *method, *selectedMethod;
MonoAssembly *assembly;
MonoImage *image;
MonoDebugSourceLocation *location;
MonoStackBacktraceInfo *info;
gboolean use_full_trace;
char *methodName;
gint i, native_offset, firstAvailable;
selectedMethod = NULL;
firstAvailable = -1;
use_full_trace = FALSE;
native_offset = -1;
for (i = 0; i < stack_entries; i++) {
info = (MonoStackBacktraceInfo*) stack [i];
method = info ? info->method : NULL;
if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
continue;
if (firstAvailable == -1)
firstAvailable = i;
image = method->klass->image;
assembly = image->assembly;
if ((assembly && assembly->in_gac) || ignore_frame (method))
continue;
selectedMethod = method;
native_offset = info->native_offset;
break;
}
if (!selectedMethod) {
/* All the frames were from assemblies installed in GAC. Find first frame that is
* not in the ignore list */
for (i = 0; i < stack_entries; i++) {
info = (MonoStackBacktraceInfo*) stack [i];
method = info ? info->method : NULL;
if (!method || ignore_frame (method))
continue;
selectedMethod = method;
native_offset = info->native_offset;
break;
}
if (!selectedMethod)
use_full_trace = TRUE;
}
hint = NULL;
if (use_full_trace) {
GString *trace = g_string_new ("Full trace:\n");
for (i = firstAvailable; i < stack_entries; i++) {
info = (MonoStackBacktraceInfo*) stack [i];
method = info ? info->method : NULL;
if (!method || method->wrapper_type != MONO_WRAPPER_NONE)
continue;
location = mono_debug_lookup_source_location (method, info->native_offset, domain);
methodName = mono_method_full_name (method, TRUE);
if (location) {
append_report (&trace, LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
mono_debug_free_source_location (location);
} else
append_report (&trace, LOCATION_INDENT "%s\n", methodName);
g_free (methodName);
}
if (trace) {
if (trace->len)
hint = g_string_free (trace, FALSE);
else
g_string_free (trace, TRUE);
}
} else {
location = mono_debug_lookup_source_location (selectedMethod, native_offset, domain);
methodName = mono_method_full_name (selectedMethod, TRUE);
if (location) {
hint = g_strdup_printf (LOCATION_INDENT "%s in %s:%u\n", methodName, location->source_file, location->row);
mono_debug_free_source_location (location);
} else
hint = g_strdup_printf (LOCATION_INDENT "%s\n", methodName);
g_free (methodName);
}
return hint;
}
| false | false | false | false | false | 0 |
ldapu_propval_alloc (const char *prop, const char *val,
LDAPUPropVal_t **propval)
{
*propval = (LDAPUPropVal_t *)malloc(sizeof(LDAPUPropVal_t));
if (!*propval) return LDAPU_ERR_OUT_OF_MEMORY;
(*propval)->prop = prop ? strdup(prop) : 0;
(*propval)->val = val ? strdup(val) : 0;
if ((!prop || (*propval)->prop) && (!val || (*propval)->val)) {
/* strdup worked */
return LDAPU_SUCCESS;
}
else {
return LDAPU_ERR_OUT_OF_MEMORY;
}
}
| false | false | false | false | false | 0 |
add_handlers()
{
add_read_handler("config", read_handler, h_config);
add_data_handlers("src", Handler::h_read | Handler::h_write, reinterpret_cast<EtherAddress *>(&_ethh.ether_shost));
add_data_handlers("dst", Handler::h_read | Handler::h_write, reinterpret_cast<EtherAddress *>(&_ethh.ether_dhost));
add_net_order_data_handlers("ethertype", Handler::h_read | Handler::h_write, &_ethh.ether_vlan_encap_proto);
add_read_handler("vlan_tci", read_handler, h_vlan_tci);
add_write_handler("vlan_tci", reconfigure_keyword_handler, "3 VLAN_TCI");
add_read_handler("vlan_id", read_keyword_handler, "VLAN_ID");
add_write_handler("vlan_id", reconfigure_keyword_handler, "VLAN_ID");
add_read_handler("vlan_pcp", read_keyword_handler, "VLAN_PCP");
add_write_handler("vlan_pcp", reconfigure_keyword_handler, "VLAN_PCP");
add_read_handler("native_vlan", read_keyword_handler, "NATIVE_VLAN");
add_write_handler("native_vlan", reconfigure_keyword_handler, "NATIVE_VLAN");
}
| false | false | false | false | false | 0 |
isl_tab_save_samples(struct isl_tab *tab)
{
union isl_tab_undo_val u;
if (!tab)
return -1;
u.n = tab->n_sample;
return push_union(tab, isl_tab_undo_saved_samples, u);
}
| false | false | false | false | false | 0 |
initProc() {
// Properties specific to Higgs state.
if (higgsType == 0) {
nameSave = "f_1 f_2 -> H0 f_3 f_4 (W+ W- fusion) (SM)";
codeSave = 907;
idRes = 25;
coup2W = 1.;
}
else if (higgsType == 1) {
nameSave = "f_1 f_2 -> h0(H1) f_3 f_4 (W+ W- fusion)";
codeSave = 1007;
idRes = 25;
coup2W = settingsPtr->parm("HiggsH1:coup2W");
}
else if (higgsType == 2) {
nameSave = "f_1 f_2 -> H0(H2) f_3 f_4 (W+ W- fusion)";
codeSave = 1027;
idRes = 35;
coup2W = settingsPtr->parm("HiggsH2:coup2W");
}
else if (higgsType == 3) {
nameSave = "f_1 f_2 -> A0(A3) f_3 f_4 (W+ W- fusion)";
codeSave = 1047;
idRes = 36;
coup2W = settingsPtr->parm("HiggsA3:coup2W");
}
// Common fixed mass and coupling factor.
mWS = pow2( particleDataPtr->m0(24) );
prefac = mWS * pow3( 4. * M_PI / couplingsPtr->sin2thetaW() );
// Secondary open width fraction.
openFrac = particleDataPtr->resOpenFrac(idRes);
}
| false | false | false | false | false | 0 |
Mono_Posix_ToMountFlags (guint64 x, guint64 *r)
{
*r = 0;
if (x == 0)
return 0;
#ifdef ST_APPEND
if ((x & ST_APPEND) == ST_APPEND)
*r |= Mono_Posix_MountFlags_ST_APPEND;
#endif /* ndef ST_APPEND */
#ifdef ST_BIND
if ((x & ST_BIND) == ST_BIND)
*r |= Mono_Posix_MountFlags_ST_BIND;
#endif /* ndef ST_BIND */
#ifdef ST_IMMUTABLE
if ((x & ST_IMMUTABLE) == ST_IMMUTABLE)
*r |= Mono_Posix_MountFlags_ST_IMMUTABLE;
#endif /* ndef ST_IMMUTABLE */
#ifdef ST_MANDLOCK
if ((x & ST_MANDLOCK) == ST_MANDLOCK)
*r |= Mono_Posix_MountFlags_ST_MANDLOCK;
#endif /* ndef ST_MANDLOCK */
#ifdef ST_NOATIME
if ((x & ST_NOATIME) == ST_NOATIME)
*r |= Mono_Posix_MountFlags_ST_NOATIME;
#endif /* ndef ST_NOATIME */
#ifdef ST_NODEV
if ((x & ST_NODEV) == ST_NODEV)
*r |= Mono_Posix_MountFlags_ST_NODEV;
#endif /* ndef ST_NODEV */
#ifdef ST_NODIRATIME
if ((x & ST_NODIRATIME) == ST_NODIRATIME)
*r |= Mono_Posix_MountFlags_ST_NODIRATIME;
#endif /* ndef ST_NODIRATIME */
#ifdef ST_NOEXEC
if ((x & ST_NOEXEC) == ST_NOEXEC)
*r |= Mono_Posix_MountFlags_ST_NOEXEC;
#endif /* ndef ST_NOEXEC */
#ifdef ST_NOSUID
if ((x & ST_NOSUID) == ST_NOSUID)
*r |= Mono_Posix_MountFlags_ST_NOSUID;
#endif /* ndef ST_NOSUID */
#ifdef ST_RDONLY
if ((x & ST_RDONLY) == ST_RDONLY)
*r |= Mono_Posix_MountFlags_ST_RDONLY;
#endif /* ndef ST_RDONLY */
#ifdef ST_REMOUNT
if ((x & ST_REMOUNT) == ST_REMOUNT)
*r |= Mono_Posix_MountFlags_ST_REMOUNT;
#endif /* ndef ST_REMOUNT */
#ifdef ST_SYNCHRONOUS
if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS)
*r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS;
#endif /* ndef ST_SYNCHRONOUS */
#ifdef ST_WRITE
if ((x & ST_WRITE) == ST_WRITE)
*r |= Mono_Posix_MountFlags_ST_WRITE;
#endif /* ndef ST_WRITE */
return 0;
}
| false | false | false | false | false | 0 |
nscBlit(void *drv, void *dev, DFBRectangle * rect, int dx, int dy)
{
NSCDeviceData *nscdev = (NSCDeviceData *) dev;
unsigned long soffset = (rect->x * nscdev->src_pitch) + (rect->y * 2);
unsigned long doffset = (dy * nscdev->dst_pitch) + (dx * 2);
Gal_set_solid_pattern(nscdev->Color);
if (nscdev->v_srcColorkey) {
Gal2_set_source_transparency(nscdev->src_colorkey, 0xFFFF);
}
Gal_set_raster_operation(0xCC);
Gal2_set_source_stride((unsigned short)nscdev->src_pitch);
Gal2_set_destination_stride(nscdev->dst_pitch);
Gal2_screen_to_screen_blt(nscdev->src_offset + soffset,
nscdev->dst_offset + doffset,
(unsigned short)rect->w,
(unsigned short)rect->h, 1);
return true;
}
| false | false | false | false | false | 0 |
register_isdn(isdn_if *i)
{
isdn_driver_t *d;
int j;
ulong flags;
int drvidx;
if (dev->drivers >= ISDN_MAX_DRIVERS) {
printk(KERN_WARNING "register_isdn: Max. %d drivers supported\n",
ISDN_MAX_DRIVERS);
return 0;
}
if (!i->writebuf_skb) {
printk(KERN_WARNING "register_isdn: No write routine given.\n");
return 0;
}
if (!(d = kzalloc(sizeof(isdn_driver_t), GFP_KERNEL))) {
printk(KERN_WARNING "register_isdn: Could not alloc driver-struct\n");
return 0;
}
d->maxbufsize = i->maxbufsize;
d->pktcount = 0;
d->stavail = 0;
d->flags = DRV_FLAG_LOADED;
d->online = 0;
d->interface = i;
d->channels = 0;
spin_lock_irqsave(&dev->lock, flags);
for (drvidx = 0; drvidx < ISDN_MAX_DRIVERS; drvidx++)
if (!dev->drv[drvidx])
break;
if (isdn_add_channels(d, drvidx, i->channels, 0)) {
spin_unlock_irqrestore(&dev->lock, flags);
kfree(d);
return 0;
}
i->channels = drvidx;
i->rcvcallb_skb = isdn_receive_skb_callback;
i->statcallb = isdn_status_callback;
if (!strlen(i->id))
sprintf(i->id, "line%d", drvidx);
for (j = 0; j < drvidx; j++)
if (!strcmp(i->id, dev->drvid[j]))
sprintf(i->id, "line%d", drvidx);
dev->drv[drvidx] = d;
strcpy(dev->drvid[drvidx], i->id);
isdn_info_update();
dev->drivers++;
set_global_features();
spin_unlock_irqrestore(&dev->lock, flags);
return 1;
}
| true | true | false | false | false | 1 |
dragMoveEvent(QDragMoveEvent* event)
{
QRect rect = event->answerRect();
if (isAboveArrow(rect.center().x())) {
m_hoverArrow = true;
update();
if (m_subDirsMenu == 0) {
requestSubDirs();
} else if (m_subDirsMenu->parent() != this) {
m_subDirsMenu->close();
m_subDirsMenu->deleteLater();
m_subDirsMenu = 0;
requestSubDirs();
}
} else {
if (m_openSubDirsTimer->isActive()) {
cancelSubDirsRequest();
}
delete m_subDirsMenu;
m_subDirsMenu = 0;
m_hoverArrow = false;
update();
}
}
| false | false | false | false | false | 0 |
modem_check_result(char *have, char *need)
{
char line[MODEM_BUFFER_LEN + 1];
char *word;
char *more;
int nr;
log_line(L_DEBUG, "Waiting for \"");
log_code(L_DEBUG, need);
log_text(L_DEBUG, "\"... ");
xstrncpy(line, need, MODEM_BUFFER_LEN);
more = strchr(line, '|');
word = strtok(line, "|");
nr = 0;
while (word)
{
nr++;
if (strncmp(have, word, strlen(word)) == 0)
{
if (more)
{
log_text(L_DEBUG, "Got \"");
log_code(L_DEBUG, word);
log_text(L_DEBUG, "\" (%d).\n", nr);
}
else log_text(L_DEBUG, "Got it.\n");
return(nr);
}
word = strtok(NULL, "|");
}
log_text(L_DEBUG, "Oops!\n");
return(0);
}
| true | true | false | false | false | 1 |
substExprQuant(const ExprHashMap<Expr>& oldToNew) const
{
ExprHashMap<Expr> visited(oldToNew);
return recursiveQuantSubst(oldToNew,visited);
}
| false | false | false | false | false | 0 |
rl_vi_bword (count, ignore)
int count, ignore;
{
while (count-- && rl_point > 0)
{
int last_is_ident;
/* If we are at the start of a word, move back to whitespace
so we will go back to the start of the previous word. */
if (!whitespace (rl_line_buffer[rl_point]) &&
whitespace (rl_line_buffer[rl_point - 1]))
rl_point--;
/* If this character and the previous character are `opposite', move
back so we don't get messed up by the rl_point++ down there in
the while loop. Without this code, words like `l;' screw up the
function. */
last_is_ident = _rl_isident (rl_line_buffer[rl_point - 1]);
if ((_rl_isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
(!_rl_isident (rl_line_buffer[rl_point]) && last_is_ident))
rl_point--;
while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
rl_point--;
if (rl_point > 0)
{
if (_rl_isident (rl_line_buffer[rl_point]))
while (--rl_point >= 0 && _rl_isident (rl_line_buffer[rl_point]));
else
while (--rl_point >= 0 && !_rl_isident (rl_line_buffer[rl_point]) &&
!whitespace (rl_line_buffer[rl_point]));
rl_point++;
}
}
return (0);
}
| false | false | false | false | false | 0 |
count_fields (tree fields)
{
tree x;
int n_fields = 0;
for (x = fields; x; x = DECL_CHAIN (x))
{
if (TREE_CODE (x) == FIELD_DECL && ANON_AGGR_TYPE_P (TREE_TYPE (x)))
n_fields += count_fields (TYPE_FIELDS (TREE_TYPE (x)));
else
n_fields += 1;
}
return n_fields;
}
| false | false | false | false | false | 0 |
fsl_asrc_dai_hw_free(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct fsl_asrc_pair *pair = runtime->private_data;
if (pair)
fsl_asrc_release_pair(pair);
return 0;
}
| false | false | false | false | false | 0 |
ConstantFoldSelectInstruction(Constant *Cond,
Constant *V1, Constant *V2) {
if (ConstantInt *CB = dyn_cast<ConstantInt>(Cond))
return CB->getZExtValue() ? V1 : V2;
if (isa<UndefValue>(V1)) return V2;
if (isa<UndefValue>(V2)) return V1;
if (isa<UndefValue>(Cond)) return V1;
if (V1 == V2) return V1;
return 0;
}
| false | false | false | false | false | 0 |
sha1_array_append(struct sha1_array *array, const unsigned char *sha1)
{
ALLOC_GROW(array->sha1, array->nr + 1, array->alloc);
hashcpy(array->sha1[array->nr++], sha1);
array->sorted = 0;
}
| false | false | false | false | false | 0 |
port_parser(struct nv_pair *nv, int line, plugin_conf_t * c)
{
const char *ptr = nv->value;
unsigned long i;
/* check that all chars are numbers */
for (i = 0; ptr[i]; i++) {
if (!isdigit(ptr[i])) {
log_err("Value %s should only be numbers - line %d", nv->value, line);
return 1;
}
}
/* convert to unsigned long */
errno = 0;
i = strtoul(nv->value, NULL, 10);
if (errno) {
log_err("Error converting string to a number (%s) - line %d", strerror(errno), line);
return 1;
}
c->port = i;
return 0;
}
| false | false | false | false | false | 0 |
PolygonArea_old(int np, double *xp, double *yp)
{
int i, j;
double area = 0;
for ( i = 0; i < np; i++ )
{
j = (i + 1) % np;
area += xp[i] * yp[j];
area -= yp[i] * xp[j];
}
area /= 2;
/* return(area < 0 ? -area : area); */
return (area);
}
| false | false | false | false | false | 0 |
rewriteAppendOnlyFileBackground(void) {
pid_t childpid;
long long start;
if (server.aof_child_pid != -1) return REDIS_ERR;
start = ustime();
if ((childpid = fork()) == 0) {
char tmpfile[256];
/* Child */
if (server.ipfd > 0) close(server.ipfd);
if (server.sofd > 0) close(server.sofd);
snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) getpid());
if (rewriteAppendOnlyFile(tmpfile) == REDIS_OK) {
size_t private_dirty = zmalloc_get_private_dirty();
if (private_dirty) {
redisLog(REDIS_NOTICE,
"AOF rewrite: %lu MB of memory used by copy-on-write",
private_dirty/(1024*1024));
}
exitFromChild(0);
} else {
exitFromChild(1);
}
} else {
/* Parent */
server.stat_fork_time = ustime()-start;
if (childpid == -1) {
redisLog(REDIS_WARNING,
"Can't rewrite append only file in background: fork: %s",
strerror(errno));
return REDIS_ERR;
}
redisLog(REDIS_NOTICE,
"Background append only file rewriting started by pid %d",childpid);
server.aof_rewrite_scheduled = 0;
server.aof_rewrite_time_start = time(NULL);
server.aof_child_pid = childpid;
updateDictResizePolicy();
/* We set appendseldb to -1 in order to force the next call to the
* feedAppendOnlyFile() to issue a SELECT command, so the differences
* accumulated by the parent into server.aof_rewrite_buf will start
* with a SELECT statement and it will be safe to merge. */
server.aof_selected_db = -1;
return REDIS_OK;
}
return REDIS_OK; /* unreached */
}
| false | false | false | false | false | 0 |
put ( std::ostream & os ) const {
int pr=os.precision(20);
std::vector<unsigned long> t(2);
os << " " << name() << "\n";
os << "Uvec" << "\n";
os << randomInt << " " << firstUnusedBit << "\n";
t = DoubConv::dto2longs(defaultWidth);
os << defaultWidth << " " << t[0] << " " << t[1] << "\n";
t = DoubConv::dto2longs(defaultA);
os << defaultA << " " << t[0] << " " << t[1] << "\n";
t = DoubConv::dto2longs(defaultB);
os << defaultB << " " << t[0] << " " << t[1] << "\n";
#ifdef TRACE_IO
std::cout << "RandFlat::put(): randomInt = " << randomInt
<< " firstUnusedBit = " << firstUnusedBit
<< "\ndefaultWidth = " << defaultWidth
<< " defaultA = " << defaultA
<< " defaultB = " << defaultB << "\n";
#endif
os.precision(pr);
return os;
#ifdef REMOVED
int pr=os.precision(20);
os << " " << name() << "\n";
os << randomInt << " " << firstUnusedBit << "\n";
os << defaultWidth << " " << defaultA << " " << defaultB << "\n";
os.precision(pr);
return os;
#endif
}
| false | false | false | false | false | 0 |
free_isakmp_payload(struct isakmp_payload *p)
{
struct isakmp_payload *nxt;
if (p == NULL)
return;
switch (p->type) {
case ISAKMP_PAYLOAD_SA:
free_isakmp_payload(p->u.sa.proposals);
break;
case ISAKMP_PAYLOAD_P:
free(p->u.p.spi);
free_isakmp_payload(p->u.p.transforms);
break;
case ISAKMP_PAYLOAD_T:
free_isakmp_attributes(p->u.t.attributes);
break;
case ISAKMP_PAYLOAD_KE:
case ISAKMP_PAYLOAD_HASH:
case ISAKMP_PAYLOAD_SIG:
case ISAKMP_PAYLOAD_NONCE:
case ISAKMP_PAYLOAD_VID:
case ISAKMP_PAYLOAD_NAT_D:
case ISAKMP_PAYLOAD_NAT_D_OLD:
free(p->u.ke.data);
break;
case ISAKMP_PAYLOAD_ID:
free(p->u.id.data);
break;
case ISAKMP_PAYLOAD_CERT:
case ISAKMP_PAYLOAD_CR:
free(p->u.cert.data);
break;
case ISAKMP_PAYLOAD_N:
free(p->u.n.spi);
free(p->u.n.data);
free_isakmp_attributes(p->u.n.attributes);
break;
case ISAKMP_PAYLOAD_D:
if (p->u.d.spi) {
int i;
for (i = 0; i < p->u.d.num_spi; i++)
free(p->u.d.spi[i]);
free(p->u.d.spi);
}
break;
case ISAKMP_PAYLOAD_MODECFG_ATTR:
free_isakmp_attributes(p->u.modecfg.attributes);
break;
default:
abort();
}
nxt = p->next;
free(p);
free_isakmp_payload(nxt);
}
| false | false | false | false | false | 0 |
ValidateDate(const byte* date, byte format, int dateType)
{
time_t ltime;
struct tm certTime;
struct tm* localTime;
int i = 0;
ltime = XTIME(0);
XMEMSET(&certTime, 0, sizeof(certTime));
if (format == ASN_UTC_TIME) {
if (btoi(date[0]) >= 5)
certTime.tm_year = 1900;
else
certTime.tm_year = 2000;
}
else { /* format == GENERALIZED_TIME */
certTime.tm_year += btoi(date[i++]) * 1000;
certTime.tm_year += btoi(date[i++]) * 100;
}
GetTime(&certTime.tm_year, date, &i); certTime.tm_year -= 1900; /* adjust */
GetTime(&certTime.tm_mon, date, &i); certTime.tm_mon -= 1; /* adjust */
GetTime(&certTime.tm_mday, date, &i);
GetTime(&certTime.tm_hour, date, &i);
GetTime(&certTime.tm_min, date, &i);
GetTime(&certTime.tm_sec, date, &i);
if (date[i] != 'Z') { /* only Zulu supported for this profile */
CYASSL_MSG("Only Zulu time supported for this profile");
return 0;
}
localTime = XGMTIME(<ime);
if (dateType == BEFORE) {
if (DateLessThan(localTime, &certTime))
return 0;
}
else
if (DateGreaterThan(localTime, &certTime))
return 0;
return 1;
}
| false | false | false | false | false | 0 |
gwy_combo_box_metric_unit_make_enum(gint from,
gint to,
GwySIUnit *unit,
gint *nentries)
{
GwyEnum *entries;
GwySIValueFormat *format = NULL;
gint i, n;
from = from/3;
to = (to + 2)/3;
if (to < from)
GWY_SWAP(gint, from, to);
n = (to - from) + 1;
entries = g_new(GwyEnum, n + 1);
for (i = from; i <= to; i++) {
format = gwy_si_unit_get_format_for_power10(unit,
GWY_SI_UNIT_FORMAT_MARKUP,
3*i, format);
if (*format->units)
entries[i - from].name = g_strdup(format->units);
else
entries[i - from].name = g_strdup("1");
entries[i - from].value = 3*i;
}
entries[n].name = NULL;
gwy_si_unit_value_format_free(format);
if (nentries)
*nentries = n;
return entries;
}
| false | false | false | false | false | 0 |
write_attr_value (struct attr_desc *attr, rtx value)
{
int op;
switch (GET_CODE (value))
{
case CONST_STRING:
write_attr_valueq (attr, XSTR (value, 0));
break;
case CONST_INT:
printf (HOST_WIDE_INT_PRINT_DEC, INTVAL (value));
break;
case SYMBOL_REF:
fputs (XSTR (value, 0), stdout);
break;
case ATTR:
{
struct attr_desc *attr2 = find_attr (&XSTR (value, 0), 0);
printf ("get_attr_%s (%s)", attr2->name,
(attr2->is_const ? "" : "insn"));
}
break;
case PLUS:
op = '+';
goto do_operator;
case MINUS:
op = '-';
goto do_operator;
case MULT:
op = '*';
goto do_operator;
case DIV:
op = '/';
goto do_operator;
case MOD:
op = '%';
goto do_operator;
do_operator:
write_attr_value (attr, XEXP (value, 0));
putchar (' ');
putchar (op);
putchar (' ');
write_attr_value (attr, XEXP (value, 1));
break;
default:
abort ();
}
}
| false | false | false | false | false | 0 |
xhci_calculate_u2_timeout(struct xhci_hcd *xhci,
struct usb_device *udev,
struct usb_endpoint_descriptor *desc)
{
unsigned long long timeout_ns;
if (xhci->quirks & XHCI_INTEL_HOST)
timeout_ns = xhci_calculate_intel_u2_timeout(udev, desc);
else
timeout_ns = udev->u2_params.sel;
/* The U2 timeout is encoded in 256us intervals */
timeout_ns = DIV_ROUND_UP_ULL(timeout_ns, 256 * 1000);
/* If the necessary timeout value is bigger than what we can set in the
* USB 3.0 hub, we have to disable hub-initiated U2.
*/
if (timeout_ns <= USB3_LPM_U2_MAX_TIMEOUT)
return timeout_ns;
dev_dbg(&udev->dev, "Hub-initiated U2 disabled "
"due to long timeout %llu ms\n", timeout_ns);
return xhci_get_timeout_no_hub_lpm(udev, USB3_LPM_U2);
}
| false | false | false | false | false | 0 |
unpack16_array(uint16_t ** valp, uint32_t * size_val, Buf buffer)
{
uint32_t i = 0;
if (unpack32(size_val, buffer))
return SLURM_ERROR;
if (*size_val > 4000000) abort();
*valp = xmalloc((*size_val) * sizeof(uint16_t));
for (i = 0; i < *size_val; i++) {
if (unpack16((*valp) + i, buffer))
return SLURM_ERROR;
}
return SLURM_SUCCESS;
}
| false | false | false | false | false | 0 |
mono_profiler_iomap (char *report, const char *pathname, const char *new_pathname)
{
ProfilerDesc *prof;
for (prof = prof_list; prof; prof = prof->next) {
if ((prof->events & MONO_PROFILE_IOMAP_EVENTS) && prof->iomap_cb)
prof->iomap_cb (prof->profiler, report, pathname, new_pathname);
}
}
| false | false | false | false | false | 0 |
optional_string_either(char *str1, char *str2)
{
ignore_white_space();
if ( !strnicmp(str1, Mp, strlen(str1)) ) {
Mp += strlen(str1);
return 0;
} else if ( !strnicmp(str2, Mp, strlen(str2)) ) {
Mp += strlen(str2);
return 1;
}
return -1;
}
| false | false | false | false | false | 0 |
randomize(VMG_ uint argc)
{
int i;
long seed;
/* check arguments */
check_argc(vmg_ argc, 0);
/* seed the generator */
os_rand(&seed);
/*
* Fill in rsl[] with the seed. It doesn't do a lot of good to call
* os_rand() repeatedly, since this function might simply return the
* real-time clock value. So, use the os_rand() seed value as the
* first rsl[] value, then use a simple linear congruential
* generator to fill in the rest of rsl[].
*/
for (i = 0 ; i < ISAAC_RANDSIZ ; ++i)
{
const ulong a = 1664525L;
/* fill in this value from the previous seed value */
G_bif_tads_globals->isaac_ctx->rsl[i] = (ulong)seed;
/* generate the next lcg value */
seed = (long)(((a * (ulong)seed) + 1) & 0xFFFFFFFF);
}
/* initialize with this rsl[] array */
isaac_init(G_bif_tads_globals->isaac_ctx, TRUE);
}
| false | false | false | false | false | 0 |
bus_add_match(DBusConnection *conn, char *match)
{
dbus_bus_add_match(conn, match, err);
dbus_connection_flush(conn);
if (dbus_error_is_set(err))
{
printf("Match error: %s\n", err->message);
return -1;
}
return 0;
}
| false | false | false | false | false | 0 |
ec_GFp_mont_field_mul(const EC_GROUP *group, BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
if (group->field_data1 == NULL)
{
ECerr(EC_F_EC_GFP_MONT_FIELD_MUL, EC_R_NOT_INITIALIZED);
return 0;
}
return BN_mod_mul_montgomery(r, a, b, group->field_data1, ctx);
}
| false | false | false | false | false | 0 |
Write_half3(std::ostream & os, const float * v3, GpuLanguage lang)
{
if(lang == GPU_LANGUAGE_CG)
{
os << "half3(";
for(int i=0; i<3; i++)
{
if(i!=0) os << ", ";
os << ClampToNormHalf(v3[i]);
}
os << ")";
}
else if(lang == GPU_LANGUAGE_GLSL_1_0 || lang == GPU_LANGUAGE_GLSL_1_3)
{
os << "vec3(";
for(int i=0; i<3; i++)
{
if(i!=0) os << ", ";
os << v3[i]; // Clamping to half is not necessary
}
os << ")";
}
else
{
throw Exception("Unsupported shader language.");
}
}
| false | false | false | false | false | 0 |
get_ethernet_iface_by_name (const gchar *name)
{
OobsIfacesConfig *config;
OobsList *list;
OobsListIter iter;
OobsIface *iface;
gboolean valid;
config = OOBS_IFACES_CONFIG (oobs_ifaces_config_get ());
list = oobs_ifaces_config_get_ifaces (config, OOBS_IFACE_TYPE_ETHERNET);
valid = oobs_list_get_iter_first (list, &iter);
while (valid)
{
iface = OOBS_IFACE (oobs_list_get (list, &iter));
if (compare_string (name, oobs_iface_get_device_name (iface)))
return iface;
g_object_unref (iface);
valid = oobs_list_iter_next (list, &iter);
}
return NULL;
}
| false | false | false | false | false | 0 |
snp_new(const char *p)
{
snp_t *snp = alloc(sizeof(snp_t));
p = match_literal(p, "PBRSNP,");
p = match_string_until(p, ',', 1, &snp->instrument_id);
p = match_string_until(p, ',', 1, &snp->pilot_name);
p = match_unsigned(p, &snp->serial_number);
p = match_char(p, ',');
p = match_string_until(p, '\0', 0, &snp->software_version);
p = match_eos(p);
if (!p) {
snp_delete(snp);
return 0;
}
return snp;
}
| false | false | false | false | false | 0 |
ConScroll(int Way, int X, int Y, int W, int H, TAttr Fill, int Count) {
int l;
TCell Cell(' ', Fill);
DrawCursor(0);
if (Way == csUp) {
DebugShowArea(X, (Y + Count), W, (H - Count), 14);
XCopyArea(display, win, win, colorXGC->GetGC(0),
X * FontCX, (Y + Count) * FontCY,
W * FontCX, (H - Count) * FontCY,
X * FontCX, Y * FontCY);
for (l = 0; l < H - Count; ++l)
memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l + Count), W * sizeof(TCell));
//l = H - Count;
//fprintf(stderr, "X:%d Y:%d W:%d H:%d c:%d\n", X, Y, W, H, Count);
//ConGetBox(0, Y + Count, ScreenCols, H - Count, CursorXYPos(0, Y));
//if (Count > 1 && ConSetBox(X, Y + l, W, Count, Cell) == -1)
// return -1;
} else if (Way == csDown) {
DebugShowArea(X, Y, W, (H - Count), 15);
XCopyArea(display, win, win, colorXGC->GetGC(0),
X * FontCX, Y * FontCY,
W * FontCX, (H - Count) * FontCY,
X * FontCX, (Y + Count) * FontCY);
for (l = H - 1; l >= Count; --l)
memcpy(CursorXYPos(X, Y + l), CursorXYPos(X, Y + l - Count), W * sizeof(TCell));
//if (Count > 1 && ConSetBox(X, Y, W, Count, Cell) == -1)
// return -1;
}
DrawCursor(1);
return 1;
}
| false | false | false | false | false | 0 |
Problem_7_test(){
int rowOne[] = {0,1,0,0};
int rowTwo[] = {1,0,1,1};
int rowThree[] = {1,0,0,0};
int rowFour[] = {0,1,1,1};
vector<vector<int> > screen;
screen.push_back(vector<int>(rowOne, rowOne+4));
screen.push_back(vector<int>(rowTwo, rowTwo+4));
screen.push_back(vector<int>(rowThree, rowThree+4));
screen.push_back(vector<int>(rowFour, rowFour+4));
vector<vector<int> > correctScreen;
for(size_t i=0; i<screen.size(); ++i){
correctScreen.push_back(vector<int>(screen[i].begin(), screen[i].end()));
}
correctScreen[1][1]=2;
correctScreen[2][1]=2;
correctScreen[2][2]=2;
correctScreen[2][3]=2;
Chapter9 chapter9;
chapter9.Problem_7(screen, 1, 2, 2);
for(size_t i=0; i<screen.size(); ++i){
for(size_t j=0; j<screen[0].size(); ++j){
if(screen[i][j]!=correctScreen[i][j]){
return false;
}
}
}
return true;
}
| false | false | false | false | false | 0 |
slapi_build_control( char *oid, BerElement *ber,
char iscritical, LDAPControl **ctrlp )
{
int rc = 0;
int return_value = LDAP_SUCCESS;
struct berval *bvp = NULL;
PR_ASSERT( NULL != oid && NULL != ctrlp );
if ( NULL == ber ) {
bvp = NULL;
} else {
/* allocate struct berval with contents of the BER encoding */
rc = ber_flatten( ber, &bvp );
if ( -1 == rc ) {
return_value = LDAP_NO_MEMORY;
goto loser;
}
}
/* allocate the new control structure */
*ctrlp = (LDAPControl *)slapi_ch_calloc( 1, sizeof(LDAPControl));
/* fill in the fields of this new control */
(*ctrlp)->ldctl_iscritical = iscritical;
(*ctrlp)->ldctl_oid = slapi_ch_strdup( oid );
if ( NULL == bvp ) {
(*ctrlp)->ldctl_value.bv_len = 0;
(*ctrlp)->ldctl_value.bv_val = NULL;
} else {
(*ctrlp)->ldctl_value = *bvp; /* struct copy */
ldap_memfree(bvp); /* free container, but not contents */
bvp = NULL;
}
loser:
return return_value;
}
| false | false | false | false | false | 0 |
param_extract(Table *tb, char *line)
{
//tb->theta0 = 180.0; <- equilibrium angles not supported
tb->ninput = 0;
tb->f_unspecified = false; //default
tb->use_degrees = true; //default
char *word = strtok(line," \t\n\r\f");
while (word) {
if (strcmp(word,"N") == 0) {
word = strtok(NULL," \t\n\r\f");
tb->ninput = atoi(word);
}
else if (strcmp(word,"NOF") == 0) {
tb->f_unspecified = true;
}
else if ((strcmp(word,"DEGREES") == 0) || (strcmp(word,"degrees") == 0)) {
tb->use_degrees = true;
}
else if ((strcmp(word,"RADIANS") == 0) || (strcmp(word,"radians") == 0)) {
tb->use_degrees = false;
}
else if (strcmp(word,"CHECKU") == 0) {
word = strtok(NULL," \t\n\r\f");
memory->sfree(checkU_fname);
memory->create(checkU_fname,strlen(word),"dihedral_table:checkU");
strcpy(checkU_fname, word);
}
else if (strcmp(word,"CHECKF") == 0) {
word = strtok(NULL," \t\n\r\f");
memory->sfree(checkF_fname);
memory->create(checkF_fname,strlen(word),"dihedral_table:checkF");
strcpy(checkF_fname, word);
}
// COMMENTING OUT: equilibrium angles are not supported
//else if (strcmp(word,"EQ") == 0) {
// word = strtok(NULL," \t\n\r\f");
// tb->theta0 = atof(word);
//}
else {
string err_msg("Invalid keyword in dihedral angle table parameters");
err_msg += string(" (") + string(word) + string(")");
error->one(FLERR,err_msg.c_str());
}
word = strtok(NULL," \t\n\r\f");
}
if (tb->ninput == 0)
error->one(FLERR,"Dihedral table parameters did not set N");
}
| false | false | false | false | false | 0 |
toStr() const
{
return QwtMmlNode::toStr() + QString( " form=%1" ).arg( ( int )form() );
}
| false | false | false | false | false | 0 |
nv10_emit_light_enable(struct gl_context *ctx, int emit)
{
struct nouveau_context *nctx = to_nouveau_context(ctx);
struct nouveau_pushbuf *push = context_push(ctx);
uint32_t en_lights = 0;
int i;
if (nctx->fallback != HWTNL) {
BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1);
PUSH_DATA (push, 0);
return;
}
for (i = 0; i < MAX_LIGHTS; i++)
en_lights |= get_light_mode(&ctx->Light.Light[i]) << 2 * i;
BEGIN_NV04(push, NV10_3D(ENABLED_LIGHTS), 1);
PUSH_DATA (push, en_lights);
BEGIN_NV04(push, NV10_3D(LIGHTING_ENABLE), 1);
PUSH_DATAb(push, ctx->Light.Enabled);
BEGIN_NV04(push, NV10_3D(NORMALIZE_ENABLE), 1);
PUSH_DATAb(push, ctx->Transform.Normalize);
}
| false | false | false | false | false | 0 |
unix_time(int64_t date) {
if (date<=0) return -1;
static const int days[12]={0,31,59,90,120,151,181,212,243,273,304,334};
const int year=date/10000000000LL%10000;
const int month=(date/100000000%100-1)%12;
const int day=date/1000000%100;
const int hour=date/10000%100;
const int min=date/100%100;
const int sec=date%100;
return (day-1+days[month]+(year%4==0 && month>1)+((year-1970)*1461+1)/4)
*86400+hour*3600+min*60+sec;
}
| false | false | false | false | false | 0 |
gst_flac_calculate_crc16 (const guint8 * data, guint length)
{
guint16 crc = 0;
while (length--) {
crc = ((crc << 8) ^ crc16_table[(crc >> 8) ^ *data]) & 0xffff;
data++;
}
return crc;
}
| false | false | false | false | false | 0 |
current_setting( calib_yyparse_private_t *priv )
{
int retval;
while( priv->cal_index >= priv->parsed_file->num_settings )
{
retval = add_calibration_setting( priv->parsed_file );
if( retval < 0 ) return NULL;
}
return &priv->parsed_file->settings[ priv->cal_index ];
}
| false | false | false | false | false | 0 |
ar5008_hw_attach_phy_ops(struct ath_hw *ah)
{
struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
static const u32 ar5416_cca_regs[6] = {
AR_PHY_CCA,
AR_PHY_CH1_CCA,
AR_PHY_CH2_CCA,
AR_PHY_EXT_CCA,
AR_PHY_CH1_EXT_CCA,
AR_PHY_CH2_EXT_CCA
};
priv_ops->rf_set_freq = ar5008_hw_set_channel;
priv_ops->spur_mitigate_freq = ar5008_hw_spur_mitigate;
priv_ops->rf_alloc_ext_banks = ar5008_hw_rf_alloc_ext_banks;
priv_ops->rf_free_ext_banks = ar5008_hw_rf_free_ext_banks;
priv_ops->set_rf_regs = ar5008_hw_set_rf_regs;
priv_ops->set_channel_regs = ar5008_hw_set_channel_regs;
priv_ops->init_bb = ar5008_hw_init_bb;
priv_ops->process_ini = ar5008_hw_process_ini;
priv_ops->set_rfmode = ar5008_hw_set_rfmode;
priv_ops->mark_phy_inactive = ar5008_hw_mark_phy_inactive;
priv_ops->set_delta_slope = ar5008_hw_set_delta_slope;
priv_ops->rfbus_req = ar5008_hw_rfbus_req;
priv_ops->rfbus_done = ar5008_hw_rfbus_done;
priv_ops->restore_chainmask = ar5008_restore_chainmask;
priv_ops->set_diversity = ar5008_set_diversity;
priv_ops->do_getnf = ar5008_hw_do_getnf;
priv_ops->set_radar_params = ar5008_hw_set_radar_params;
if (modparam_force_new_ani) {
priv_ops->ani_control = ar5008_hw_ani_control_new;
priv_ops->ani_cache_ini_regs = ar5008_hw_ani_cache_ini_regs;
} else
priv_ops->ani_control = ar5008_hw_ani_control_old;
if (AR_SREV_9100(ah))
priv_ops->compute_pll_control = ar9100_hw_compute_pll_control;
else if (AR_SREV_9160_10_OR_LATER(ah))
priv_ops->compute_pll_control = ar9160_hw_compute_pll_control;
else
priv_ops->compute_pll_control = ar5008_hw_compute_pll_control;
ar5008_hw_set_nf_limits(ah);
ar5008_hw_set_radar_conf(ah);
memcpy(ah->nf_regs, ar5416_cca_regs, sizeof(ah->nf_regs));
}
| false | false | false | false | false | 0 |
map_get_key(struct battery_property_map *map, int value,
const char *def_key)
{
while (map->key) {
if (map->value == value)
return map->key;
map++;
}
return def_key;
}
| false | false | false | false | false | 0 |
sx9500_read_samp_freq(struct sx9500_data *data,
int *val, int *val2)
{
int ret;
unsigned int regval;
mutex_lock(&data->mutex);
ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0, ®val);
mutex_unlock(&data->mutex);
if (ret < 0)
return ret;
regval = (regval & SX9500_SCAN_PERIOD_MASK) >> SX9500_SCAN_PERIOD_SHIFT;
*val = sx9500_samp_freq_table[regval].val;
*val2 = sx9500_samp_freq_table[regval].val2;
return IIO_VAL_INT_PLUS_MICRO;
}
| false | false | false | false | false | 0 |
CopyInformationFromPipeline(vtkInformation* request)
{
// Let the superclass copy whatever it wants.
this->Superclass::CopyInformationFromPipeline(request);
// Copy pipeline information to data information before the producer
// executes.
if(request->Has(vtkDemandDrivenPipeline::REQUEST_DATA()))
{
this->CopyOriginAndSpacingFromPipeline();
}
}
| false | false | false | false | false | 0 |
upd_signal_handler(int sig)
{
if(sigupd) sigupd->flags |= B_ABORT;
}
| false | false | false | false | false | 0 |
Write(std::ostream &os) const
{
assert( (size_t)ItemLength + 4 == Size() );
os.write( (char*)&ItemType, sizeof(ItemType) );
os.write( (char*)&Reserved2, sizeof(Reserved2) );
uint16_t copy = ItemLength;
SwapperDoOp::SwapArray(©,1);
os.write( (char*)©, sizeof(ItemLength) );
os.write( (char*)&ID, sizeof(ID) );
os.write( (char*)&Reserved6, sizeof(Reserved6) );
os.write( (char*)&Reserved7, sizeof(Reserved7) );
os.write( (char*)&Reserved8, sizeof(Reserved8) );
SubItems.Write(os);
std::vector<TransferSyntaxSub>::const_iterator it = TransferSyntaxes.begin();
for( ; it != TransferSyntaxes.end(); ++it )
{
it->Write( os );
}
return os;
}
| false | false | false | false | false | 0 |
walk_pud_range(pgd_t *pgd, unsigned long addr, unsigned long end,
struct mm_walk *walk)
{
pud_t *pud;
unsigned long next;
int err = 0;
pud = pud_offset(pgd, addr);
do {
next = pud_addr_end(addr, end);
if (pud_none_or_clear_bad(pud)) {
if (walk->pte_hole)
err = walk->pte_hole(addr, next, walk);
if (err)
break;
continue;
}
if (walk->pmd_entry || walk->pte_entry)
err = walk_pmd_range(pud, addr, next, walk);
if (err)
break;
} while (pud++, addr = next, addr != end);
return err;
}
| 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.