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
|
---|---|---|---|---|---|---|
cpumask_create(char *str, size_t len,
cpu_set_t *set, size_t setsize)
{
char *ptr = str;
char *ret = NULL;
int cpu;
for (cpu = cpuset_nbits(setsize) - 4; cpu >= 0; cpu -= 4) {
char val = 0;
if (len == (size_t) (ptr - str))
break;
if (CPU_ISSET_S(cpu, setsize, set))
val |= 1;
if (CPU_ISSET_S(cpu + 1, setsize, set))
val |= 2;
if (CPU_ISSET_S(cpu + 2, setsize, set))
val |= 4;
if (CPU_ISSET_S(cpu + 3, setsize, set))
val |= 8;
if (!ret && val)
ret = ptr;
*ptr++ = val_to_char(val);
}
*ptr = '\0';
return ret ? ret : ptr - 1;
} | false | false | false | false | true | 1 |
add_ip_checksums(unsigned long offset, unsigned long sum, unsigned long new)
{
unsigned long checksum;
sum = ~sum & 0xFFFF;
new = ~new & 0xFFFF;
if (offset & 1) {
/* byte swap the sum if it came from an odd offset
* since the computation is endian independant this
* works.
*/
new = ((new >> 8) & 0xff) | ((new << 8) & 0xff00);
}
checksum = sum + new;
if (checksum > 0xFFFF) {
checksum -= 0xFFFF;
}
return (~checksum) & 0xFFFF;
} | false | false | false | false | false | 0 |
e_bindings_shutdown(void)
{
E_FREE_LIST(mouse_bindings, _e_bindings_mouse_free);
E_FREE_LIST(key_bindings, _e_bindings_key_free);
E_FREE_LIST(edge_bindings, _e_bindings_edge_free);
E_FREE_LIST(signal_bindings, _e_bindings_signal_free);
E_FREE_LIST(wheel_bindings, _e_bindings_wheel_free);
E_FREE_LIST(acpi_bindings, _e_bindings_acpi_free);
if (mapping_handler)
{
ecore_event_handler_del(mapping_handler);
mapping_handler = NULL;
}
return 1;
} | false | false | false | false | false | 0 |
fmt_setup(void)
{
if (!formatstring && !(formatstring = html_inistr("format", (char *) 0)))
formatstring = sdefaultfmt;
} | false | false | false | false | false | 0 |
EvaluateValue(
vtkDataArray *scalars, int comp_no, vtkIdType id, vtkDataArray *lims,
int *AboveCount, int *BelowCount, int *InsideCount)
{
double value = 0.0;
if (comp_no < 0 && scalars)
{
// use magnitude.
int numComps = scalars->GetNumberOfComponents();
const double *tuple = scalars->GetTuple(id);
for (int cc=0; cc < numComps; cc++)
{
value += tuple[cc]*tuple[cc];
}
value = sqrt(value);
}
else
{
value = scalars? scalars->GetComponent(id, comp_no) :
static_cast<double>(id); /// <=== precision loss when using id.
}
int keepCell = 0;
//check the value in the array against all of the thresholds in lims
//if it is inside any, return true
int above = 0;
int below = 0;
int inside = 0;
void* rawLimsPtr = lims->GetVoidPointer(0);
vtkIdType numLims = lims->GetNumberOfComponents() * lims->GetNumberOfTuples();
switch (lims->GetDataType())
{
vtkTemplateMacro(
keepCell = TestItem<VTK_TT>(numLims,
static_cast<VTK_TT*>(rawLimsPtr),
value,
above, below, inside));
}
if (AboveCount) *AboveCount = above;
if (BelowCount) *BelowCount = below;
if (InsideCount) *InsideCount = inside;
return keepCell;
} | false | false | false | false | false | 0 |
xmmsc_ipc_disconnect (xmmsc_ipc_t *ipc)
{
ipc->disconnect = true;
if (ipc->read_msg) {
xmms_ipc_msg_destroy (ipc->read_msg);
ipc->read_msg = NULL;
}
xmmsc_ipc_error_set (ipc, strdup ("Disconnected"));
if (ipc->disconnect_callback) {
ipc->disconnect_callback (ipc->disconnect_data);
}
} | false | false | false | false | false | 0 |
snd_intel8x0_setup_pcm_out(struct intel8x0 *chip,
struct snd_pcm_runtime *runtime)
{
unsigned int cnt;
int dbl = runtime->rate > 48000;
spin_lock_irq(&chip->reg_lock);
switch (chip->device_type) {
case DEVICE_ALI:
cnt = igetdword(chip, ICHREG(ALI_SCR));
cnt &= ~ICH_ALI_SC_PCM_246_MASK;
if (runtime->channels == 4 || dbl)
cnt |= ICH_ALI_SC_PCM_4;
else if (runtime->channels == 6)
cnt |= ICH_ALI_SC_PCM_6;
iputdword(chip, ICHREG(ALI_SCR), cnt);
break;
case DEVICE_SIS:
cnt = igetdword(chip, ICHREG(GLOB_CNT));
cnt &= ~ICH_SIS_PCM_246_MASK;
if (runtime->channels == 4 || dbl)
cnt |= ICH_SIS_PCM_4;
else if (runtime->channels == 6)
cnt |= ICH_SIS_PCM_6;
iputdword(chip, ICHREG(GLOB_CNT), cnt);
break;
default:
cnt = igetdword(chip, ICHREG(GLOB_CNT));
cnt &= ~(ICH_PCM_246_MASK | ICH_PCM_20BIT);
if (runtime->channels == 4 || dbl)
cnt |= ICH_PCM_4;
else if (runtime->channels == 6)
cnt |= ICH_PCM_6;
else if (runtime->channels == 8)
cnt |= ICH_PCM_8;
if (chip->device_type == DEVICE_NFORCE) {
/* reset to 2ch once to keep the 6 channel data in alignment,
* to start from Front Left always
*/
if (cnt & ICH_PCM_246_MASK) {
iputdword(chip, ICHREG(GLOB_CNT), cnt & ~ICH_PCM_246_MASK);
spin_unlock_irq(&chip->reg_lock);
msleep(50); /* grrr... */
spin_lock_irq(&chip->reg_lock);
}
} else if (chip->device_type == DEVICE_INTEL_ICH4) {
if (runtime->sample_bits > 16)
cnt |= ICH_PCM_20BIT;
}
iputdword(chip, ICHREG(GLOB_CNT), cnt);
break;
}
spin_unlock_irq(&chip->reg_lock);
} | false | false | false | false | false | 0 |
reset_found(void)
{
struct frame *frame;
struct table *table;
struct loop *loop;
for (frame = frames; frame; frame = frame->next) {
for (table = frame->tables; table; table = table->next)
table->found_row = NULL;
for (loop = frame->loops; loop; loop = loop->next)
loop->found = -1;
frame->found_ref = NULL;
}
} | false | false | false | false | false | 0 |
show_rev(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct c4iw_dev *c4iw_dev = container_of(dev, struct c4iw_dev,
ibdev.dev);
PDBG("%s dev 0x%p\n", __func__, dev);
return sprintf(buf, "%d\n",
CHELSIO_CHIP_RELEASE(c4iw_dev->rdev.lldi.adapter_type));
} | false | false | false | false | false | 0 |
parse_quota(const char *s, uint64_t * quota)
{
*quota = strtoull(s, NULL, 10);
#ifdef DEBUG_XT_QUOTA
printf("Quota: %llu\n", *quota);
#endif
if (*quota == UINT64_MAX)
xtables_error(PARAMETER_PROBLEM, "quota invalid: '%s'\n", s);
else
return 1;
} | false | false | false | false | false | 0 |
return_value_type_to_string(const struct eci_return_value *retval)
{
if (retval->type == eci_return_value::retval_none)
return "-";
else if (retval->type == eci_return_value::retval_error)
return "e";
else if (retval->type == eci_return_value::retval_string)
return "s";
else if (retval->type == eci_return_value::retval_string_list)
return "S";
else if (retval->type == eci_return_value::retval_integer)
return "i";
else if (retval->type == eci_return_value::retval_long_integer)
return "li";
else if (retval->type == eci_return_value::retval_float)
return "f";
else
DBC_NEVER_REACHED();
return NULL;
} | false | false | false | false | false | 0 |
createPrivateNonConstGlobalForString(Module &M,
StringRef Str) {
Constant *StrConst = ConstantDataArray::getString(M.getContext(), Str);
return new GlobalVariable(M, StrConst->getType(), /*isConstant=*/false,
GlobalValue::PrivateLinkage, StrConst, "");
} | false | false | false | false | false | 0 |
iwl_mvm_add_int_sta_common(struct iwl_mvm *mvm,
struct iwl_mvm_int_sta *sta,
const u8 *addr,
u16 mac_id, u16 color)
{
struct iwl_mvm_add_sta_cmd cmd;
int ret;
u32 status;
lockdep_assert_held(&mvm->mutex);
memset(&cmd, 0, sizeof(cmd));
cmd.sta_id = sta->sta_id;
cmd.mac_id_n_color = cpu_to_le32(FW_CMD_ID_AND_COLOR(mac_id,
color));
cmd.tfd_queue_msk = cpu_to_le32(sta->tfd_queue_msk);
if (addr)
memcpy(cmd.addr, addr, ETH_ALEN);
ret = iwl_mvm_send_cmd_pdu_status(mvm, ADD_STA, sizeof(cmd),
&cmd, &status);
if (ret)
return ret;
switch (status) {
case ADD_STA_SUCCESS:
IWL_DEBUG_INFO(mvm, "Internal station added.\n");
return 0;
default:
ret = -EIO;
IWL_ERR(mvm, "Add internal station failed, status=0x%x\n",
status);
break;
}
return ret;
} | false | true | false | false | false | 1 |
handle_irq_noise(struct b43legacy_wldev *dev)
{
struct b43legacy_phy *phy = &dev->phy;
u16 tmp;
u8 noise[4];
u8 i;
u8 j;
s32 average;
/* Bottom half of Link Quality calculation. */
B43legacy_WARN_ON(!dev->noisecalc.calculation_running);
if (dev->noisecalc.channel_at_start != phy->channel)
goto drop_calculation;
*((__le32 *)noise) = cpu_to_le32(b43legacy_jssi_read(dev));
if (noise[0] == 0x7F || noise[1] == 0x7F ||
noise[2] == 0x7F || noise[3] == 0x7F)
goto generate_new;
/* Get the noise samples. */
B43legacy_WARN_ON(dev->noisecalc.nr_samples >= 8);
i = dev->noisecalc.nr_samples;
noise[0] = clamp_val(noise[0], 0, ARRAY_SIZE(phy->nrssi_lt) - 1);
noise[1] = clamp_val(noise[1], 0, ARRAY_SIZE(phy->nrssi_lt) - 1);
noise[2] = clamp_val(noise[2], 0, ARRAY_SIZE(phy->nrssi_lt) - 1);
noise[3] = clamp_val(noise[3], 0, ARRAY_SIZE(phy->nrssi_lt) - 1);
dev->noisecalc.samples[i][0] = phy->nrssi_lt[noise[0]];
dev->noisecalc.samples[i][1] = phy->nrssi_lt[noise[1]];
dev->noisecalc.samples[i][2] = phy->nrssi_lt[noise[2]];
dev->noisecalc.samples[i][3] = phy->nrssi_lt[noise[3]];
dev->noisecalc.nr_samples++;
if (dev->noisecalc.nr_samples == 8) {
/* Calculate the Link Quality by the noise samples. */
average = 0;
for (i = 0; i < 8; i++) {
for (j = 0; j < 4; j++)
average += dev->noisecalc.samples[i][j];
}
average /= (8 * 4);
average *= 125;
average += 64;
average /= 128;
tmp = b43legacy_shm_read16(dev, B43legacy_SHM_SHARED,
0x40C);
tmp = (tmp / 128) & 0x1F;
if (tmp >= 8)
average += 2;
else
average -= 25;
if (tmp == 8)
average -= 72;
else
average -= 48;
dev->stats.link_noise = average;
drop_calculation:
dev->noisecalc.calculation_running = false;
return;
}
generate_new:
b43legacy_generate_noise_sample(dev);
} | false | false | false | false | false | 0 |
IsAWhitespaceChar(const int ch) {
return (ch == ' ' || ch == '\t' || ch == '\r' ||
ch == '\n' || ch == '\f' || ch == '\0');
} | false | false | false | false | false | 0 |
normalize_dir(char *dir)
{
char *p = NULL;
int l = 0;
if (NULL == dir) {
return;
}
l = strlen(dir);
for (p = dir + l - 1; p && *p && (p > dir); p--) {
if ((' ' != *p) && ('\t' != *p) && ('/' != *p) && ('\\' != *p)) {
break;
}
}
*(p+1) = '\0';
} | false | false | false | false | false | 0 |
gst_chop_my_data_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
{
GstChopMyData *chopmydata;
GstFlowReturn ret;
chopmydata = GST_CHOP_MY_DATA (parent);
GST_DEBUG_OBJECT (chopmydata, "chain");
gst_adapter_push (chopmydata->adapter, buffer);
ret = gst_chop_my_data_process (chopmydata, FALSE);
return ret;
} | false | false | false | false | false | 0 |
item_space(dbp, h, indx)
DB *dbp;
PAGE *h;
int indx;
{
return (B_TYPE(GET_BKEYDATA(dbp, h, indx)->type) == B_KEYDATA ?
BKEYDATA_PSIZE(GET_BKEYDATA(dbp, h, indx)->len) :
BKEYDATA_PSIZE(GET_BOVERFLOW(dbp, h, indx)->tlen));
} | false | false | false | false | false | 0 |
bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
{
u32 leddc_on = 10;
u32 leddc_off = 90;
if (cc->setup_done)
return;
bcma_core_chipcommon_early_init(cc);
if (cc->core->id.rev >= 20) {
u32 pullup = 0, pulldown = 0;
if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
pullup = 0x402e0;
pulldown = 0x20500;
}
bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
}
if (cc->capabilities & BCMA_CC_CAP_PMU)
bcma_pmu_init(cc);
if (cc->capabilities & BCMA_CC_CAP_PCTL)
bcma_err(cc->core->bus, "Power control not implemented!\n");
if (cc->core->id.rev >= 16) {
if (cc->core->bus->sprom.leddc_on_time &&
cc->core->bus->sprom.leddc_off_time) {
leddc_on = cc->core->bus->sprom.leddc_on_time;
leddc_off = cc->core->bus->sprom.leddc_off_time;
}
bcma_cc_write32(cc, BCMA_CC_GPIOTIMER,
((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
(leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
}
cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
cc->setup_done = true;
} | false | false | false | false | false | 0 |
matroska_aac_profile(char *codec_id)
{
static const char * const aac_profiles[] = { "MAIN", "LC", "SSR" };
int profile;
for (profile=0; profile<FF_ARRAY_ELEMS(aac_profiles); profile++)
if (strstr(codec_id, aac_profiles[profile]))
break;
return profile + 1;
} | false | false | false | false | false | 0 |
ds_strcat (struct dstring *s, char *t)
{
size_t len = s->len;
s->len += strlen (t);
if (ds_is_full (s))
ds_grow (s);
strcpy (s->content + len, t);
} | false | true | false | false | false | 1 |
end_line(char *p) // return pointer to NL of cur line
{
if (p < end - 1) {
p = memchr(p, '\n', end - p - 1);
if (!p)
return end - 1;
}
return p;
} | false | false | false | false | false | 0 |
print_inventory(struct fnode *a, const char *to_file, const char *hostname, const char *username, const char *remote_root)/*{{{*/
{
FILE *out;
if (to_file) {
out = fopen(to_file, "w");
} else {
out = NULL;
}
fprintf(out, "H %s\n", hostname);
fprintf(out, "U %s\n", username);
if (remote_root) {
fprintf(out, "R %s\n", remote_root);
}
inner_print_inventory(a, out);
if (out) fclose(out);
} | false | false | false | false | false | 0 |
GetTransform(int i)
{
// we walk through the list in reverse order if InverseFlag is set
if (this->InverseFlag)
{
int j = this->NumberOfTransforms-i-1;
vtkTransformPair *tuple = &this->TransformList[j];
// if inverse is NULL, then get it from the forward transform
if (tuple->InverseTransform == NULL)
{
tuple->InverseTransform = tuple->ForwardTransform->GetInverse();
tuple->InverseTransform->Register(NULL);
}
return tuple->InverseTransform;
}
else
{
vtkTransformPair *tuple = &this->TransformList[i];
// if transform is NULL, then get it from its inverse
if (tuple->ForwardTransform == NULL)
{
tuple->ForwardTransform = tuple->InverseTransform->GetInverse();
tuple->ForwardTransform->Register(NULL);
}
return tuple->ForwardTransform;
}
} | false | false | false | false | false | 0 |
mystrdup(char *s)
{
char *dup;
if (!s)
return 0;
if ((dup = MALLOC(strlen(s) + 1)) == NULL)
syserr("Not enough memory for strdup.");
strcpy(dup, s);
return dup;
} | false | true | false | false | false | 1 |
bytea_substring(Datum str,
int S,
int L,
bool length_not_specified)
{
int S1; /* adjusted start position */
int L1; /* adjusted substring length */
S1 = Max(S, 1);
if (length_not_specified)
{
/*
* Not passed a length - DatumGetByteaPSlice() grabs everything to the
* end of the string if we pass it a negative value for length.
*/
L1 = -1;
}
else
{
/* end position */
int E = S + L;
/*
* A negative value for L is the only way for the end position to be
* before the start. SQL99 says to throw an error.
*/
if (E < S)
ereport(ERROR,
(errcode(ERRCODE_SUBSTRING_ERROR),
errmsg("negative substring length not allowed")));
/*
* A zero or negative value for the end position can happen if the
* start was negative or one. SQL99 says to return a zero-length
* string.
*/
if (E < 1)
return PG_STR_GET_BYTEA("");
L1 = E - S1;
}
/*
* If the start position is past the end of the string, SQL99 says to
* return a zero-length string -- DatumGetByteaPSlice() will do that for
* us. Convert to zero-based starting position
*/
return DatumGetByteaPSlice(str, S1 - 1, L1);
} | false | false | false | false | false | 0 |
gt_template_option_parser_new(void *tool_arguments)
{
TemplateArguments *arguments = tool_arguments;
GtOptionParser *op;
GtOption *option;
gt_assert(arguments);
/* init */
op = gt_option_parser_new("[option ...] [file]", /* XXX */
"DESCRIBE YOUR TOOL IN ONE LINE HERE."); /* XXX */
/* -bool */
option = gt_option_new_bool("bool", "bool option template",
&arguments->bool_option_template, false);
gt_option_parser_add_option(op, option);
/* -str */
option = gt_option_new_string("str", "str option template",
arguments->str_option_template, NULL);
gt_option_parser_add_option(op, option);
return op;
} | false | false | false | false | false | 0 |
gth_catalog_get_icon (GFile *file)
{
char *uri;
GIcon *icon;
uri = g_file_get_uri (file);
if (g_str_has_suffix (uri, ".catalog"))
icon = g_themed_icon_new ("file-catalog");
else
icon = g_themed_icon_new ("file-library");
g_free (uri);
return icon;
} | false | false | false | false | false | 0 |
writeAnimation(const Skeleton* pSkel,
const Animation* anim, SkeletonVersion ver)
{
writeChunkHeader(SKELETON_ANIMATION, calcAnimationSize(pSkel, anim, ver));
// char* name : Name of the animation
writeString(anim->getName());
// float length : Length of the animation in seconds
float len = anim->getLength();
writeFloats(&len, 1);
pushInnerChunk(mStream);
{
if ((int)ver > (int)SKELETON_VERSION_1_0)
{
if (anim->getUseBaseKeyFrame())
{
size_t size = SSTREAM_OVERHEAD_SIZE;
// char* baseAnimationName (including terminator)
size += calcStringSize(anim->getBaseKeyFrameAnimationName());
// float baseKeyFrameTime
size += sizeof(float);
writeChunkHeader(SKELETON_ANIMATION_BASEINFO, size);
// char* baseAnimationName (blank for self)
writeString(anim->getBaseKeyFrameAnimationName());
// float baseKeyFrameTime
float t = (float)anim->getBaseKeyFrameTime();
writeFloats(&t, 1);
}
}
// Write all tracks
Animation::NodeTrackIterator trackIt = anim->getNodeTrackIterator();
while(trackIt.hasMoreElements())
{
writeAnimationTrack(pSkel, trackIt.getNext());
}
}
popInnerChunk(mStream);
} | false | false | false | false | false | 0 |
efx_ef10_sriov_alloc_vf_vswitching(struct efx_nic *efx)
{
struct efx_ef10_nic_data *nic_data = efx->nic_data;
unsigned int i;
int rc;
nic_data->vf = kcalloc(efx->vf_count, sizeof(struct ef10_vf),
GFP_KERNEL);
if (!nic_data->vf)
return -ENOMEM;
for (i = 0; i < efx->vf_count; i++) {
random_ether_addr(nic_data->vf[i].mac);
nic_data->vf[i].efx = NULL;
nic_data->vf[i].vlan = EFX_EF10_NO_VLAN;
rc = efx_ef10_sriov_assign_vf_vport(efx, i);
if (rc)
goto fail;
}
return 0;
fail:
efx_ef10_sriov_free_vf_vports(efx);
kfree(nic_data->vf);
nic_data->vf = NULL;
return rc;
} | false | false | false | false | false | 0 |
daemonize(bool is_chdir, bool wait_sigusr1)
{
struct sigaction new_action;
new_action.sa_handler= sigusr1_handler;
sigemptyset(&new_action.sa_mask);
new_action.sa_flags= 0;
sigaction(SIGUSR1, &new_action, NULL);
parent_pid= getpid();
pid_t child= fork();
switch (child)
{
case -1:
return false;
case 0:
break;
default:
if (wait_sigusr1)
{
/* parent */
int exit_code= EXIT_FAILURE;
int status;
while (waitpid(child, &status, 0) != child)
{ }
if (WIFEXITED(status))
{
exit_code= WEXITSTATUS(status);
}
if (WIFSIGNALED(status))
{
exit_code= EXIT_FAILURE;
}
_exit(exit_code);
}
else
{
_exit(EXIT_SUCCESS);
}
}
/* child */
if (setsid() == -1)
{
perror("setsid");
return false;
}
if (is_chdir)
{
if (chdir("/") < 0)
{
perror("chdir");
return false;
}
}
return true;
} | false | false | false | false | false | 0 |
dfs_file_write(struct file *file, const char __user *user_buf,
size_t count, loff_t *ppos)
{
unsigned long ubi_num = (unsigned long)file->private_data;
struct dentry *dent = file->f_path.dentry;
struct ubi_device *ubi;
struct ubi_debug_info *d;
size_t buf_size;
char buf[8] = {0};
int val;
ubi = ubi_get_device(ubi_num);
if (!ubi)
return -ENODEV;
d = &ubi->dbg;
buf_size = min_t(size_t, count, (sizeof(buf) - 1));
if (copy_from_user(buf, user_buf, buf_size)) {
count = -EFAULT;
goto out;
}
if (dent == d->dfs_power_cut_min) {
if (kstrtouint(buf, 0, &d->power_cut_min) != 0)
count = -EINVAL;
goto out;
} else if (dent == d->dfs_power_cut_max) {
if (kstrtouint(buf, 0, &d->power_cut_max) != 0)
count = -EINVAL;
goto out;
} else if (dent == d->dfs_emulate_power_cut) {
if (kstrtoint(buf, 0, &val) != 0)
count = -EINVAL;
d->emulate_power_cut = val;
goto out;
}
if (buf[0] == '1')
val = 1;
else if (buf[0] == '0')
val = 0;
else {
count = -EINVAL;
goto out;
}
if (dent == d->dfs_chk_gen)
d->chk_gen = val;
else if (dent == d->dfs_chk_io)
d->chk_io = val;
else if (dent == d->dfs_chk_fastmap)
d->chk_fastmap = val;
else if (dent == d->dfs_disable_bgt)
d->disable_bgt = val;
else if (dent == d->dfs_emulate_bitflips)
d->emulate_bitflips = val;
else if (dent == d->dfs_emulate_io_failures)
d->emulate_io_failures = val;
else
count = -EINVAL;
out:
ubi_put_device(ubi);
return count;
} | false | false | false | false | false | 0 |
wind_utf8ucs4(const char *in, uint32_t *out, size_t *out_len)
{
const unsigned char *p;
size_t o = 0;
int ret;
for (p = (const unsigned char *)in; *p != '\0'; ++p) {
uint32_t u;
ret = utf8toutf32(&p, &u);
if (ret)
return ret;
if (out) {
if (o >= *out_len)
return WIND_ERR_OVERRUN;
out[o] = u;
}
o++;
}
*out_len = o;
return 0;
} | false | false | false | false | false | 0 |
set_boxwidth()
{
c_token++;
if (END_OF_COMMAND) {
boxwidth = -1.0;
boxwidth_is_absolute = TRUE;
} else {
boxwidth = real_expression();
}
if (END_OF_COMMAND)
return;
else {
if (almost_equals(c_token, "a$bsolute"))
boxwidth_is_absolute = TRUE;
else if (almost_equals(c_token, "r$elative"))
boxwidth_is_absolute = FALSE;
else
int_error(c_token, "expecting 'absolute' or 'relative' ");
}
c_token++;
} | false | false | false | false | false | 0 |
is_same(t0, t1)
Transform t0, t1;
{
int i, j, same = 1;
if (stringent) {
float factor, fepsilon;
Transform tt1, tt2;
Tm3Invert(t0, tt1);
Tm3Concat(t1,tt1,tt2);
/* is tt2 the identity, or a multiple of the identity? */
factor = tt2[0][0];
fepsilon = ABS(factor * epsilon);
for (i=0; i<4; ++i)
for (j=0; j<4; ++j)
{
/* check against identity matrix */
if ( ABS( tt2[i][j] - factor * ((i == j) ? 1 : 0) ) > fepsilon )
{
same = 0;
goto OUT;
}
}
}
else {
for (i=0; i<4; ++i)
{
for (j=0; j<4; ++j)
if (ABS(t0[i][j] - t1[i][j]) > epsilon)
{
same = 0;
goto OUT;
}
}
}
OUT:
return(same);
} | false | false | false | false | false | 0 |
string_append_dtostr (GString * string, gdouble value, guint precision)
{
gchar dstrbuf[G_ASCII_DTOSTR_BUF_SIZE] = { 0, };
gchar *dot;
guint len;
precision++;
if (value != 0.0)
value += 4.9 * pow (10.0, precision * -1.0);
g_ascii_dtostr (dstrbuf, G_ASCII_DTOSTR_BUF_SIZE, value);
dot = strchr (dstrbuf, '.');
if (dot == NULL)
goto done;
for (; *dot != '.' && *dot != '0'; dot++);
if ((dot - dstrbuf) + precision < G_ASCII_DTOSTR_BUF_SIZE)
dot[precision] = 0;
len = strlen (dstrbuf);
while (dstrbuf[len - 1] == '0')
dstrbuf[--len] = 0;
if (dstrbuf[len - 1] == '.')
dstrbuf[--len] = 0;
done:
g_string_append (string, dstrbuf);
} | false | false | false | false | false | 0 |
av_write_trailer(AVFormatContext *s)
{
int ret, i;
for(;;){
AVPacket pkt;
ret= av_interleave_packet(s, &pkt, NULL, 1);
if(ret<0) //FIXME cleanup needed for ret<0 ?
goto fail;
if(!ret)
break;
ret= s->oformat->write_packet(s, &pkt);
av_free_packet(&pkt);
if(ret<0)
goto fail;
if(url_ferror(s->pb))
goto fail;
}
if(s->oformat->write_trailer)
ret = s->oformat->write_trailer(s);
fail:
if(ret == 0)
ret=url_ferror(s->pb);
for(i=0;i<s->nb_streams;i++)
av_freep(&s->streams[i]->priv_data);
av_freep(&s->priv_data);
return ret;
} | false | false | false | false | false | 0 |
callbackControls (Component *comp, int key)
{
char buf [256];
if (key == MOUSE_BUTTON_LEFT)
{
fplayer->rolleffect = 0;
fplayer->ruddereffect = 0;
fplayer->elevatoreffect = 0;
keyb_elev = 0;
keyb_roll = 0;
keyb_rudder = 0;
controls ++;
if (controls > 2) controls = 0;
if (controls == CONTROLS_JOYSTICK && !joysticks) controls = CONTROLS_KEYBOARD;
#ifdef USE_GLUT
if (controls == CONTROLS_KEYBOARD) controls = CONTROLS_MOUSE;
#endif
}
textControls (buf);
((Label *) optmenu [2]->components [5])->setText (buf);
allmenus.components [11]->setVisible (false);
allmenus.components [12]->setVisible (false);
allmenus.components [13]->setVisible (false);
if (controls == CONTROLS_KEYBOARD) allmenus.components [11]->setVisible (true);
else if (controls == CONTROLS_JOYSTICK) allmenus.components [13]->setVisible (true);
else allmenus.components [12]->setVisible (true);
} | false | false | false | false | false | 0 |
get_filename( char* vfilename, char* filename, char* directive, char* tag, char* val, char* fn, int fnsize )
{
int vl, fl;
char* cp;
/* Used for the various commands that accept a file name.
** These commands accept two tags:
** virtual
** Gives a virtual path to a document on the server.
** file
** Gives a pathname relative to the current directory. ../ cannot
** be used in this pathname, nor can absolute paths be used.
*/
vl = strlen( vfilename );
fl = strlen( filename );
if ( strcmp( tag, "virtual" ) == 0 )
{
if ( strstr( val, "../" ) != (char*) 0 )
{
not_permitted( directive, tag, val );
return -1;
}
/* Figure out root using difference between vfilename and filename. */
if ( vl > fl ||
strcmp( vfilename, &filename[fl - vl] ) != 0 )
return -1;
if ( fl - vl + strlen( val ) >= fnsize )
return -1;
(void) strncpy( fn, filename, fl - vl );
(void) strcpy( &fn[fl - vl], val );
}
else if ( strcmp( tag, "file" ) == 0 )
{
if ( val[0] == '/' || strstr( val, "../" ) != (char*) 0 )
{
not_permitted( directive, tag, val );
return -1;
}
if ( fl + 1 + strlen( val ) >= fnsize )
return -1;
(void) strcpy( fn, filename );
cp = strrchr( fn, '/' );
if ( cp == (char*) 0 )
{
cp = &fn[strlen( fn )];
*cp = '/';
}
(void) strcpy( ++cp, val );
}
else
{
unknown_tag( filename, directive, tag );
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
push_operand (rtx op, enum machine_mode mode)
{
unsigned int rounded_size = GET_MODE_SIZE (mode);
#ifdef PUSH_ROUNDING
rounded_size = PUSH_ROUNDING (rounded_size);
#endif
if (GET_CODE (op) != MEM)
return 0;
if (mode != VOIDmode && GET_MODE (op) != mode)
return 0;
op = XEXP (op, 0);
if (rounded_size == GET_MODE_SIZE (mode))
{
if (GET_CODE (op) != STACK_PUSH_CODE)
return 0;
}
else
{
if (GET_CODE (op) != PRE_MODIFY
|| GET_CODE (XEXP (op, 1)) != PLUS
|| XEXP (XEXP (op, 1), 0) != XEXP (op, 0)
|| GET_CODE (XEXP (XEXP (op, 1), 1)) != CONST_INT
#ifdef STACK_GROWS_DOWNWARD
|| INTVAL (XEXP (XEXP (op, 1), 1)) != - (int) rounded_size
#else
|| INTVAL (XEXP (XEXP (op, 1), 1)) != (int) rounded_size
#endif
)
return 0;
}
return XEXP (op, 0) == stack_pointer_rtx;
} | false | false | false | false | false | 0 |
_fd_writeable(slurm_fd_t fd)
{
struct pollfd ufds;
int write_timeout = 5000;
int rc, time_left;
struct timeval tstart;
char temp[2];
ufds.fd = fd;
ufds.events = POLLOUT;
gettimeofday(&tstart, NULL);
while (agent_shutdown == 0) {
time_left = write_timeout - _tot_wait(&tstart);
rc = poll(&ufds, 1, time_left);
if (rc == -1) {
if ((errno == EINTR) || (errno == EAGAIN))
continue;
error("poll: %m");
return -1;
}
if (rc == 0)
return 0;
/*
* Check here to make sure the socket really is there.
* If not then exit out and notify the sender. This
* is here since a write doesn't always tell you the
* socket is gone, but getting 0 back from a
* nonblocking read means just that.
*/
if (ufds.revents & POLLHUP || (recv(fd, &temp, 1, 0) == 0)) {
debug2("SlurmDBD connection is closed");
if (callbacks_requested)
(callback.dbd_fail)();
return -1;
}
if (ufds.revents & POLLNVAL) {
error("SlurmDBD connection is invalid");
return 0;
}
if (ufds.revents & POLLERR) {
error("SlurmDBD connection experienced an error: %m");
if (callbacks_requested)
(callback.dbd_fail)();
return 0;
}
if ((ufds.revents & POLLOUT) == 0) {
error("SlurmDBD connection %d events %d",
fd, ufds.revents);
return 0;
}
/* revents == POLLOUT */
errno = 0;
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
GetPixelColor(long x,long y, bool bGetAlpha)
{
// RGBQUAD rgb={0,0,0,0};
RGBQUAD rgb=info.nBkgndColor; //<mpwolski>
if ((pDib==NULL)||(x<0)||(y<0)||
(x>=head.biWidth)||(y>=head.biHeight)){
if (info.nBkgndIndex >= 0){
if (head.biBitCount<24) return GetPaletteColor((BYTE)info.nBkgndIndex);
else return info.nBkgndColor;
} else if (pDib) return GetPixelColor(0,0);
return rgb;
}
if (head.biClrUsed){
rgb = GetPaletteColor(BlindGetPixelIndex(x,y));
} else {
BYTE* iDst = info.pImage + y*info.dwEffWidth + x*3;
rgb.rgbBlue = *iDst++;
rgb.rgbGreen= *iDst++;
rgb.rgbRed = *iDst;
}
#if CXIMAGE_SUPPORT_ALPHA
if (pAlpha && bGetAlpha)
rgb.rgbReserved = BlindAlphaGet(x,y);
#else
rgb.rgbReserved = 0;
#endif //CXIMAGE_SUPPORT_ALPHA
return rgb;
} | false | false | false | false | false | 0 |
showEntry(Entry *entry) {
switch (entry->kind) {
case ENTRY_KIND_CLASS:
printf("class:\n");
showClass(entry->u.classEntry.class, 10);
break;
case ENTRY_KIND_METHOD:
printf("method:\n");
indent(10);
printf("isPublic = %s",
entry->u.methodEntry.isPublic ? "yes" : "no");
printf("\n");
indent(10);
printf("isStatic = %s",
entry->u.methodEntry.isStatic ? "yes" : "no");
printf("\n");
indent(10);
printf("retType = ");
showType(entry->u.methodEntry.retType);
printf("\n");
indent(10);
printf("paramTypes = ");
showTypeList(entry->u.methodEntry.paramTypes);
printf("\n");
indent(10);
printf("numLocals = %d",entry->u.methodEntry.numLocals);
printf("\n");
indent(10);
printf("numParams = %d", entry->u.methodEntry.numParams);
printf("\n");
break;
case ENTRY_KIND_VARIABLE:
printf("variable:\n");
indent(10);
printf("isLocal = %s",
entry->u.variableEntry.isLocal ? "yes" : "no");
printf("\n");
indent(10);
printf("isPublic = %s",
entry->u.variableEntry.isPublic ? "yes" : "no");
printf("\n");
indent(10);
printf("isStatic = %s",
entry->u.variableEntry.isStatic ? "yes" : "no");
printf("\n");
indent(10);
printf("type = ");
showType(entry->u.variableEntry.type);
printf("\n");
break;
default:
/* this should never happen */
error("unknown entry kind %d in showEntry", entry->kind);
break;
}
} | false | false | false | false | false | 0 |
C_GetInfo(CK_INFO_PTR p)
{
if( ! initialized ) {
return CKR_CRYPTOKI_NOT_INITIALIZED;
}
log->log("C_GetInfo called\n");
ckInfo.manufacturerID[31] = ' ';
ckInfo.libraryDescription[31] = ' ';
*p = ckInfo;
return CKR_OK;
} | false | false | false | false | false | 0 |
rotate(int count)
{
int oldcode = code;
switch (count & 0x3)
{
case 1:
code ^= (code & SWAPXY) ? MIRRORY : MIRRORX;
code ^= SWAPXY;
break;
case 2:
code ^= (MIRRORX|MIRRORY);
break;
case 3:
code ^= (code & SWAPXY) ? MIRRORX : MIRRORY;
code ^= SWAPXY;
break;
}
if ((oldcode ^ code) & SWAPXY)
{
iswap(rectFrom.xmin, rectFrom.ymin);
iswap(rectFrom.xmax, rectFrom.ymax);
rw = rh = GRatio();
}
} | false | false | false | false | false | 0 |
suspend_nvs_alloc(void)
{
struct nvs_page *entry;
list_for_each_entry(entry, &nvs_list, node) {
entry->data = (void *)__get_free_page(GFP_KERNEL);
if (!entry->data) {
suspend_nvs_free();
return -ENOMEM;
}
}
return 0;
} | false | false | false | false | false | 0 |
slotTabMoved(int from, int to)
{
/* called from Qt slot when Qt has moved the tab, so we only
need to adjust the m_tabNames list */
if (m_automaticResizeTabs) {
QString movedName = m_tabNames.takeAt(from);
m_tabNames.insert(to, movedName);
}
} | false | false | false | false | false | 0 |
netxen_nic_pci_get_crb_addr_2M(struct netxen_adapter *adapter,
ulong off, void __iomem **addr)
{
crb_128M_2M_sub_block_map_t *m;
if ((off >= NETXEN_CRB_MAX) || (off < NETXEN_PCI_CRBSPACE))
return -EINVAL;
off -= NETXEN_PCI_CRBSPACE;
/*
* Try direct map
*/
m = &crb_128M_2M_map[CRB_BLK(off)].sub_block[CRB_SUBBLK(off)];
if (m->valid && (m->start_128M <= off) && (m->end_128M > off)) {
*addr = adapter->ahw.pci_base0 + m->start_2M +
(off - m->start_128M);
return 0;
}
/*
* Not in direct map, use crb window
*/
*addr = adapter->ahw.pci_base0 + CRB_INDIRECT_2M +
(off & MASK(16));
return 1;
} | false | false | false | false | false | 0 |
FindMatch(dir)
int dir;
{
register Bufpos *bp;
register char c = linebuf[curchar];
if (strchr(p_types, c) == NULL || backslashed(linebuf, curchar))
complain((char *)NULL);
if (dir == FORWARD)
f_char(1);
bp = m_paren(c, dir, YES, NO);
if (dir == FORWARD)
b_char(1);
if (bp != NULL)
SetDot(bp);
mp_error(); /* if there is an error the user wants to
know about it */
} | false | false | false | false | false | 0 |
legal_getteximage_target(struct gl_context *ctx, GLenum target)
{
switch (target) {
case GL_TEXTURE_1D:
case GL_TEXTURE_2D:
case GL_TEXTURE_3D:
return GL_TRUE;
case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
return ctx->Extensions.ARB_texture_cube_map;
case GL_TEXTURE_RECTANGLE_NV:
return ctx->Extensions.NV_texture_rectangle;
case GL_TEXTURE_1D_ARRAY_EXT:
case GL_TEXTURE_2D_ARRAY_EXT:
return ctx->Extensions.EXT_texture_array;
case GL_TEXTURE_CUBE_MAP_ARRAY:
return ctx->Extensions.ARB_texture_cube_map_array;
default:
return GL_FALSE;
}
} | false | false | false | false | false | 0 |
startSaving(const QString &fileName, int pages, double widthCm, double heightCm)
{
int err = 0;
m_mediaboxWidth = cm2Pt(widthCm);
m_mediaboxHeight = cm2Pt(heightCm);
if (m_outputFile) {
m_outputFile->close();
delete m_outputFile;
}
m_outputFile = new QFile(fileName, this);
if (!m_outputFile->open(QIODevice::WriteOnly))
return 1;
m_outStream.setDevice(m_outputFile);
m_contentPagesCount = pages;
m_xref.clear();
m_outStream << "%PDF-1.3" LINEFEED
"%\xe2\xe3\xcf\xd3" ;
addOffsetToXref();
m_outStream << QString(
LINEFEED "%1 0 obj" LINEFEED
"<</Creator (PosteRazor)" LINEFEED
"/Producer (PosteRazor.SourceForge.net)" LINEFEED
"/CreationDate (D:%2)" LINEFEED
">>" LINEFEED
"endobj")
.arg(m_pdfObjectCount)
.arg(QDateTime::currentDateTime().toString("yyyyMMddHHmmss"));
return err;
} | false | false | false | false | false | 0 |
call(int code, char *label, char *mnemo, char *oper)
{
char *operand2;
register int cond;
register struct result *r;
cond = searchcond(8,oper,&operand2) << 3;
r=parse(operand2);
checktype(r,L_ABSOLUTE);
if (cond >=0 )
insert8 (0xc4 + cond );
else
insert8 (0xcd );
insert16 (r->value);
return 0;
} | false | false | false | false | false | 0 |
drbd_bm_init(struct drbd_device *device)
{
struct drbd_bitmap *b = device->bitmap;
WARN_ON(b != NULL);
b = kzalloc(sizeof(struct drbd_bitmap), GFP_KERNEL);
if (!b)
return -ENOMEM;
spin_lock_init(&b->bm_lock);
mutex_init(&b->bm_change);
init_waitqueue_head(&b->bm_io_wait);
device->bitmap = b;
return 0;
} | false | false | false | false | false | 0 |
row_get_prebuilt_insert_row(
/*========================*/
row_prebuilt_t* prebuilt) /*!< in: prebuilt struct in MySQL
handle */
{
ins_node_t* node;
dtuple_t* row;
dict_table_t* table = prebuilt->table;
ut_ad(prebuilt && table && prebuilt->trx);
if (prebuilt->ins_node == NULL) {
/* Not called before for this handle: create an insert node
and query graph to the prebuilt struct */
node = ins_node_create(INS_DIRECT, table, prebuilt->heap);
prebuilt->ins_node = node;
if (prebuilt->ins_upd_rec_buff == NULL) {
prebuilt->ins_upd_rec_buff = mem_heap_alloc(
prebuilt->heap, prebuilt->mysql_row_len);
}
row = dtuple_create(prebuilt->heap,
dict_table_get_n_cols(table));
dict_table_copy_types(row, table);
ins_node_set_new_row(node, row);
prebuilt->ins_graph = que_node_get_parent(
pars_complete_graph_for_exec(node,
prebuilt->trx,
prebuilt->heap));
prebuilt->ins_graph->state = QUE_FORK_ACTIVE;
}
return(prebuilt->ins_node->row);
} | false | false | false | false | false | 0 |
Initialize(Handle<Object> target) {
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(WrappedContext::New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("Context"));
target->Set(String::NewSymbol("Context"),
constructor_template->GetFunction());
} | false | false | false | false | false | 0 |
cr_rgb_compute_from_percentage (CRRgb * a_this)
{
g_return_val_if_fail (a_this, CR_BAD_PARAM_ERROR);
if (a_this->is_percentage == FALSE)
return CR_OK;
a_this->red = a_this->red * 255 / 100;
a_this->green = a_this->green * 255 / 100;
a_this->blue = a_this->blue * 255 / 100;
a_this->is_percentage = FALSE;
return CR_OK;
} | false | false | false | false | false | 0 |
utf_off2cells(off, max_off)
unsigned off;
unsigned max_off;
{
return (off + 1 < max_off && ScreenLines[off + 1] == 0) ? 2 : 1;
} | false | false | false | false | false | 0 |
OnListRender( wxTimerEvent& WXUNUSED(event) ) {
if (wxGetApp().GetDocument()->GetStatisticsCount()) {
m_PaintStatistics->m_full_repaint = true;
m_PaintStatistics->Refresh(false);
}
} | false | false | false | false | false | 0 |
GetNextNodeByProp (xmlNodePtr node, char const *Property, char const *Id)
{
char *txt;
while (node) {
txt = (char*) xmlGetProp (node, (xmlChar*) Property);
if (!strcmp (txt, Id))
break;
node = node->next;
}
return node;
} | false | false | false | false | false | 0 |
mcontour (header *hd)
/***** mcontour
contour plot with matrix and vector intput.
*****/
{ header *st=hd,*result,*hd1;
double *m,*mv,x[5];
int r,c,cv,dummy,i,j;
hd=getvalue(hd); if (error) return;
if (hd->type!=s_matrix || dimsof(hd)->c<2 || dimsof(hd)->r<2)
{ output("Contour needs a real matrix!\n"); error=81; return;
}
hd1=next_param(st); if (error) return;
hd1=getvalue(hd1); if (error) return;
if (hd1->type!=s_real)
if (hd1->type!=s_matrix || dimsof(hd1)->r!=1)
{ output("Second parameter of contour must be a vector!\n");
error=82; return;
}
getmatrix(hd,&r,&c,&m); getmatrix(hd1,&dummy,&cv,&mv);
graphic_mode();
if (!holding) gclear();
frame();
for (i=0; i<r-1; i++)
{ for (j=0; j<c-1; j++)
{ x[0]=*mat(m,c,i,j); x[1]=*mat(m,c,i+1,j);
x[2]=*mat(m,c,i+1,j+1); x[3]=*mat(m,c,i,j+1);
x[4]=x[0];
contour(x,i,j,c-1,r-1,mv,cv);
}
if (test_key()==escape)
{ output("User interrupted!\n");
error=1; gflush(); return;
}
}
result=new_real(cv,"");
moveresult(st,result);
gflush();
} | false | false | false | false | false | 0 |
pmdie(SIGNAL_ARGS)
{
int save_errno = errno;
PG_SETMASK(&BlockSig);
ereport(DEBUG2,
(errmsg_internal("postmaster received signal %d",
postgres_signal_arg)));
switch (postgres_signal_arg)
{
case SIGTERM:
/*
* Smart Shutdown:
*
* Wait for children to end their work, then shut down.
*/
if (Shutdown >= SmartShutdown)
break;
Shutdown = SmartShutdown;
ereport(LOG,
(errmsg("received smart shutdown request")));
/*
* We won't wait out an autovacuum iteration ...
*/
if (AutoVacPID != 0)
{
/* Use statement cancel to shut it down */
signal_child(AutoVacPID, SIGINT);
break; /* let reaper() handle this */
}
if (DLGetHead(BackendList))
break; /* let reaper() handle this */
/*
* No children left. Begin shutdown of data base system.
*/
if (StartupPID != 0 || FatalError)
break; /* let reaper() handle this */
/* Start the bgwriter if not running */
if (BgWriterPID == 0)
BgWriterPID = StartBackgroundWriter();
/* And tell it to shut down */
if (BgWriterPID != 0)
signal_child(BgWriterPID, SIGUSR2);
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
signal_child(PgArchPID, SIGQUIT);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
signal_child(PgStatPID, SIGQUIT);
break;
case SIGINT:
/*
* Fast Shutdown:
*
* Abort all children with SIGTERM (rollback active transactions
* and exit) and shut down when they are gone.
*/
if (Shutdown >= FastShutdown)
break;
Shutdown = FastShutdown;
ereport(LOG,
(errmsg("received fast shutdown request")));
if (DLGetHead(BackendList) || AutoVacPID != 0)
{
if (!FatalError)
{
ereport(LOG,
(errmsg("aborting any active transactions")));
SignalChildren(SIGTERM);
if (AutoVacPID != 0)
signal_child(AutoVacPID, SIGTERM);
/* reaper() does the rest */
}
break;
}
/*
* No children left. Begin shutdown of data base system.
*
* Note: if we previously got SIGTERM then we may send SIGUSR2 to
* the bgwriter a second time here. This should be harmless.
*/
if (StartupPID != 0)
{
signal_child(StartupPID, SIGTERM);
break; /* let reaper() do the rest */
}
if (FatalError)
break; /* let reaper() handle this case */
/* Start the bgwriter if not running */
if (BgWriterPID == 0)
BgWriterPID = StartBackgroundWriter();
/* And tell it to shut down */
if (BgWriterPID != 0)
signal_child(BgWriterPID, SIGUSR2);
/* Tell pgarch to shut down too; nothing left for it to do */
if (PgArchPID != 0)
signal_child(PgArchPID, SIGQUIT);
/* Tell pgstat to shut down too; nothing left for it to do */
if (PgStatPID != 0)
signal_child(PgStatPID, SIGQUIT);
break;
case SIGQUIT:
/*
* Immediate Shutdown:
*
* abort all children with SIGQUIT and exit without attempt to
* properly shut down data base system.
*/
ereport(LOG,
(errmsg("received immediate shutdown request")));
if (StartupPID != 0)
signal_child(StartupPID, SIGQUIT);
if (BgWriterPID != 0)
signal_child(BgWriterPID, SIGQUIT);
if (AutoVacPID != 0)
signal_child(AutoVacPID, SIGQUIT);
if (PgArchPID != 0)
signal_child(PgArchPID, SIGQUIT);
if (PgStatPID != 0)
signal_child(PgStatPID, SIGQUIT);
if (DLGetHead(BackendList))
SignalChildren(SIGQUIT);
ExitPostmaster(0);
break;
}
PG_SETMASK(&UnBlockSig);
errno = save_errno;
} | false | false | false | false | false | 0 |
jbig2_decode_generic_template0_unopt(Jbig2Ctx *ctx,
Jbig2Segment *segment,
const Jbig2GenericRegionParams *params,
Jbig2ArithState *as,
Jbig2Image *image,
Jbig2ArithCx *GB_stats)
{
const int GBW = image->width;
const int GBH = image->height;
uint32_t CONTEXT;
int x,y;
bool bit;
/* this version is generic and easy to understand, but very slow */
for (y = 0; y < GBH; y++) {
for (x = 0; x < GBW; x++) {
CONTEXT = 0;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y) << 0;
CONTEXT |= jbig2_image_get_pixel(image, x - 2, y) << 1;
CONTEXT |= jbig2_image_get_pixel(image, x - 3, y) << 2;
CONTEXT |= jbig2_image_get_pixel(image, x - 4, y) << 3;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[0],
y + params->gbat[1]) << 4;
CONTEXT |= jbig2_image_get_pixel(image, x + 2, y - 1) << 5;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 1) << 6;
CONTEXT |= jbig2_image_get_pixel(image, x + 0, y - 1) << 7;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 1) << 8;
CONTEXT |= jbig2_image_get_pixel(image, x - 2, y - 1) << 9;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[2],
y + params->gbat[3]) << 10;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[4],
y + params->gbat[5]) << 11;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 2) << 12;
CONTEXT |= jbig2_image_get_pixel(image, x + 0, y - 2) << 13;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 2) << 14;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[6],
y + params->gbat[7]) << 15;
bit = jbig2_arith_decode(as, &GB_stats[CONTEXT]);
jbig2_image_set_pixel(image, x, y, bit);
}
}
return 0;
} | false | false | false | false | false | 0 |
addAttributes(const DIE &Die) {
DIEAttrs Attrs = {};
collectAttributes(Die, Attrs);
hashAttributes(Attrs, Die.getTag());
} | false | false | false | false | false | 0 |
grain_convex_hull_area(GArray *vertices, gdouble dx, gdouble dy)
{
const GridPoint *a = &g_array_index(vertices, GridPoint, 0),
*b = &g_array_index(vertices, GridPoint, 1),
*c = &g_array_index(vertices, GridPoint, 2);
gdouble s = 0.0;
guint i;
g_return_val_if_fail(vertices->len >= 4, 0.0);
for (i = 2; i < vertices->len; i++) {
gdouble bx = b->j - a->j, by = b->i - a->i,
cx = c->j - a->j, cy = c->i - a->i;
s += 0.5*(bx*cy - by*cx);
b = c;
c++;
}
return dx*dy*s;
} | false | false | false | false | false | 0 |
find_node(struct nes_cm_core *cm_core,
u16 rem_port, nes_addr_t rem_addr, u16 loc_port, nes_addr_t loc_addr)
{
unsigned long flags;
struct list_head *hte;
struct nes_cm_node *cm_node;
/* get a handle on the hte */
hte = &cm_core->connected_nodes;
/* walk list and find cm_node associated with this session ID */
spin_lock_irqsave(&cm_core->ht_lock, flags);
list_for_each_entry(cm_node, hte, list) {
/* compare quad, return node handle if a match */
nes_debug(NES_DBG_CM, "finding node %x:%x =? %x:%x ^ %x:%x =? %x:%x\n",
cm_node->loc_addr, cm_node->loc_port,
loc_addr, loc_port,
cm_node->rem_addr, cm_node->rem_port,
rem_addr, rem_port);
if ((cm_node->mapped_loc_addr == loc_addr) &&
(cm_node->mapped_loc_port == loc_port) &&
(cm_node->mapped_rem_addr == rem_addr) &&
(cm_node->mapped_rem_port == rem_port)) {
add_ref_cm_node(cm_node);
spin_unlock_irqrestore(&cm_core->ht_lock, flags);
return cm_node;
}
}
spin_unlock_irqrestore(&cm_core->ht_lock, flags);
/* no owner node */
return NULL;
} | false | false | false | false | false | 0 |
ShowFlavor(WINDOW *strwin, WINDOW *txtwin, int flavor, int limit)
{
const char *name = "?";
bool limited = FALSE;
bool wins = (txtwin != stdscr);
int result;
switch (flavor) {
case eGetStr:
name = wins ? "wgetstr" : "getstr";
break;
case eGetNStr:
limited = TRUE;
name = wins ? "wgetnstr" : "getnstr";
break;
case eMvGetStr:
name = wins ? "mvwgetstr" : "mvgetstr";
break;
case eMvGetNStr:
limited = TRUE;
name = wins ? "mvwgetnstr" : "mvgetnstr";
break;
case eMaxFlavor:
break;
}
wmove(strwin, 0, 0);
werase(strwin);
if (limited) {
wprintw(strwin, "%s(%d):", name, limit);
} else {
wprintw(strwin, "%s:", name);
}
result = limited ? limit : Remainder(txtwin);
ShowPrompt(txtwin, result);
wnoutrefresh(strwin);
return result;
} | false | false | false | false | false | 0 |
iosf_mbi_pci_write_mdr(u32 mcrx, u32 mcr, u32 mdr)
{
int result;
if (!mbi_pdev)
return -ENODEV;
result = pci_write_config_dword(mbi_pdev, MBI_MDR_OFFSET, mdr);
if (result < 0)
goto fail_write;
if (mcrx) {
result = pci_write_config_dword(mbi_pdev, MBI_MCRX_OFFSET,
mcrx);
if (result < 0)
goto fail_write;
}
result = pci_write_config_dword(mbi_pdev, MBI_MCR_OFFSET, mcr);
if (result < 0)
goto fail_write;
return 0;
fail_write:
dev_err(&mbi_pdev->dev, "PCI config access failed with %d\n", result);
return result;
} | false | false | false | false | false | 0 |
hasSameValue(ARMConstantPoolValue *ACPV) {
if (ACPV->Kind == Kind &&
ACPV->PCAdjust == PCAdjust &&
ACPV->Modifier == Modifier) {
if (ACPV->LabelId == LabelId)
return true;
// Two PC relative constpool entries containing the same GV address or
// external symbols. FIXME: What about blockaddress?
if (Kind == ARMCP::CPValue || Kind == ARMCP::CPExtSymbol)
return true;
}
return false;
} | false | false | false | false | false | 0 |
log_message_level(int level, const char *fmt, ...)
{
int log_level = global.logLevel;
if( (level & log_level) && level != 0)
{
va_list ap;
char buf[1024];
int len;
char *msg;
/* strfcpy (buf + 4, "&LOG opennap ", sizeof(buf) - 4); */
snprintf(buf + 4, sizeof(buf) - 4, "&LOG %s ", global.serverName);
len = strlen(buf + 4);
msg = buf + len + 4;
va_start(ap, fmt);
vsnprintf(buf + 4 + len, sizeof(buf) - 4 - len, fmt, ap);
va_end(ap);
#if LOG_CHANNEL
/* prevent infinite loop */
if(!Logging)
{
len += strlen(buf + 4 + len);
set_tag(buf, MSG_SERVER_PUBLIC);
set_len(buf, len);
Logging = 1;
(void) send_to_channel("&LOG", buf, len + 4);
Logging = 0;
}
#endif
/* display log msg on console */
if(option(ON_LOG_STDOUT))
{
char timebuf[64];
time_t curtime;
struct tm *loctime;
curtime = time(NULL);
loctime = localtime(&curtime);
strftime(timebuf, 64, "%b %d %H:%M:%S ", loctime);
fputs(timebuf, stdout);
fputs(msg, stdout);
fputc('\n', stdout);
fflush(stdout);
}
}
} | true | true | false | false | true | 1 |
popup_split_lines(popup_info *pi, int flags)
{
int nlines, i, body_offset = 0;
int n_chars[POPUP_MAX_LINES];
char *p_str[POPUP_MAX_LINES];
gr_set_font(FONT1);
n_chars[0]=0;
nlines = split_str(pi->raw_text, 1000, n_chars, p_str, POPUP_MAX_LINES);
Assert(nlines >= 0 && nlines <= POPUP_MAX_LINES );
if ( flags & (PF_TITLE | PF_TITLE_BIG) ) {
// get first line out
strncpy(pi->title, p_str[0], n_chars[0]);
pi->title[n_chars[0]] = 0;
body_offset = 1;
}
if ( flags & PF_BODY_BIG ) {
gr_set_font(FONT2);
}
nlines = split_str(pi->raw_text, Popup_text_coords[gr_screen.res][2], n_chars, p_str, POPUP_MAX_LINES);
Assert(nlines >= 0 && nlines <= POPUP_MAX_LINES );
pi->nlines = nlines - body_offset;
for ( i = 0; i < pi->nlines; i++ ) {
Assert(n_chars[i+body_offset] < POPUP_MAX_LINE_CHARS);
strncpy(pi->msg_lines[i], p_str[i+body_offset], n_chars[i+body_offset]);
pi->msg_lines[i][n_chars[i+body_offset]] = 0;
}
gr_set_font(FONT1);
} | false | false | false | false | false | 0 |
save_channel_cache(bgav_input_context_t * ctx)
{
FILE * output = NULL;
char * filename;
char * path = NULL;
const char * language;
dvb_priv_t * priv;
int i, j;
struct stat st;
priv = ctx->priv;
filename = strrchr(priv->device_directory, '/');
filename++;
path = bgav_search_file_write(ctx->opt,
"dvb_linux", filename);
if(!path)
return;
output = fopen(path, "w");
fprintf(output, "<channels num=\"%d\">\n", ctx->tt->num_tracks);
if(stat(priv->channels_conf_file, &st))
goto fail;
fprintf(output, " <conf_time>%ld</conf_time>\n", st.st_mtime);
for(i = 0; i < ctx->tt->num_tracks; i++)
{
fprintf(output, " <channel pcr_pid=\"%04x\" extra_pcr_pid=\"%d\">\n",
priv->channels[i].pcr_pid, priv->channels[i].extra_pcr_pid);
fprintf(output, " <astreams num=\"%d\">\n",
ctx->tt->tracks[i].num_audio_streams);
for(j = 0; j < ctx->tt->tracks[i].num_audio_streams; j++)
{
fprintf(output, " <astream>\n");
fprintf(output, " <pid>%04x</pid>\n",
ctx->tt->tracks[i].audio_streams[j].stream_id);
fprintf(output, " <fourcc>%08x</fourcc>\n",
ctx->tt->tracks[i].audio_streams[j].fourcc);
language = gavl_metadata_get(&ctx->tt->tracks[i].audio_streams[j].m,
GAVL_META_LANGUAGE);
if(language)
fprintf(output, " <language>%3s</language>\n",
language);
fprintf(output, " </astream>\n");
}
fprintf(output, " </astreams>\n");
fprintf(output, " <vstreams num=\"%d\">\n",
ctx->tt->tracks[i].num_video_streams);
for(j = 0; j < ctx->tt->tracks[i].num_video_streams; j++)
{
fprintf(output, " <vstream>\n");
fprintf(output, " <pid>%04x</pid>\n",
ctx->tt->tracks[i].video_streams[j].stream_id);
fprintf(output, " <fourcc>%08x</fourcc>\n",
ctx->tt->tracks[i].video_streams[j].fourcc);
fprintf(output, " </vstream>\n");
}
fprintf(output, " </vstreams>\n");
fprintf(output, " </channel>\n");
}
fprintf(output, "</channels>\n");
fail:
if(path) free(path);
if(output) fclose(output);
return;
} | false | false | false | false | false | 0 |
load_history(struct telnet_client_t *cln)
{
struct buffer_t *b = list_entry(cln->history_pos, typeof(*b), entry);
if (b->size < cln->cmdline_len) {
memset(temp_buf, '\b', cln->cmdline_len - b->size);
memset(temp_buf + cln->cmdline_len - b->size, ' ', cln->cmdline_len - b->size);
if (telnet_send(cln, temp_buf, (cln->cmdline_len - b->size) * 2))
return -1;
}
if (telnet_send(cln, "\r", 1))
return -1;
if (send_prompt(cln))
return -1;
memcpy(cln->cmdline, b->p_buf ? b->p_buf->buf : b->buf, b->size);
cln->cmdline_pos = b->size;
cln->cmdline_len = b->size;
if (telnet_send(cln, b->p_buf ? b->p_buf->buf : b->buf, b->size))
return -1;
return 0;
} | false | false | false | false | false | 0 |
ThouArtDefeated (void)
{
Uint32 now, delay;
SDL_Rect dst;
int h;
Me.status = TERMINATED;
SDL_ShowCursor (SDL_DISABLE);
ExplodeInfluencer ();
now = SDL_GetTicks();
while ( (delay=SDL_GetTicks() - now) < WAIT_AFTER_KILLED)
{
// bit of a dirty hack: get "slow motion effect" by fiddlig with FPoverSover1
FPSover1 *= 2.0;
StartTakingTimeForFPSCalculation();
DisplayBanner (NULL, NULL, 0 );
ExplodeBlasts ();
MoveBullets ();
MoveEnemys ();
Assemble_Combat_Picture ( DO_SCREEN_UPDATE );
ComputeFPSForThisFrame ();
}
#ifdef HAVE_LIBSDL_MIXER
Mix_HaltMusic ();
#endif
// important!!: don't forget to stop fps calculation here (bugfix: enemy piles after gameOver)
Activate_Conservative_Frame_Computation ();
white_noise (ne_screen, &User_Rect, WAIT_AFTER_KILLED);
Assemble_Combat_Picture (DO_SCREEN_UPDATE);
MakeGridOnScreen (&User_Rect);
Set_Rect (dst, UserCenter_x - Portrait_Rect.w/2, UserCenter_y - Portrait_Rect.h/2,
Portrait_Rect.w, Portrait_Rect.h);
SDL_BlitSurface (pic999, NULL, ne_screen, &dst);
ThouArtDefeatedSound ();
SetCurrentFont (Para_BFont);
h = FontHeight (Para_BFont);
DisplayText ("Transmission", dst.x - h, dst.y - h, &User_Rect);
DisplayText ("Terminated", dst.x -h, dst.y + dst.h, &User_Rect);
printf_SDL(ne_screen, -1, -1, "\n");
SDL_Flip (ne_screen);
now = SDL_GetTicks ();
while (SDL_GetTicks() - now < SHOW_WAIT) SDL_Delay(1);
UpdateHighscores ();
GameOver = TRUE;
return;
} | false | false | false | false | false | 0 |
H5Aopen_name(hid_t loc_id, const char *name)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE2("i", "i*s", loc_id, name);
/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
if(H5G_loc(loc_id, &loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
/* Open the attribute on the object header */
if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)))
HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute: '%s'", name)
/* Register the attribute and get an ID for it */
if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
done:
/* Cleanup on failure */
if(ret_value < 0)
if(attr && H5A_close(attr) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
FUNC_LEAVE_API(ret_value)
} | false | false | false | false | false | 0 |
setMM(int N, MatrixT A, MatrixT B)
{
int i, j;
for(i=0;i<N;++i)
for(j=0;j<N;++j)
B[i][j] = A[i][j];
} | false | false | false | false | false | 0 |
gf_af_new(GF_Compositor *compositor, GF_AudioInterface *src, char *filter_name)
{
GF_AudioFilterItem *filter;
if (!src || !filter_name) return NULL;
GF_SAFEALLOC(filter, GF_AudioFilterItem);
filter->src = src;
filter->input.FetchFrame = gf_af_fetch_frame;
filter->input.ReleaseFrame = gf_af_release_frame;
filter->input.GetSpeed = gf_af_get_speed;
filter->input.GetChannelVolume = gf_af_get_channel_volume;
filter->input.IsMuted = gf_af_is_muted;
filter->input.GetConfig = gf_af_get_config;
filter->input.callback = filter;
gf_afc_load(&filter->filter_chain, compositor->user, filter_name);
return filter;
} | false | false | false | true | false | 1 |
parse_text_identification_frame (ID3TagsWorking * work)
{
guchar encoding;
GArray *fields = NULL;
if (work->parse_size < 2)
return NULL;
encoding = work->parse_data[0];
parse_split_strings (encoding, (gchar *) work->parse_data + 1,
work->parse_size - 1, &fields);
if (fields) {
if (fields->len > 0) {
GST_LOG ("Read %d fields from Text ID frame of size %d with encoding %d"
". First is '%s'", fields->len, work->parse_size - 1, encoding,
g_array_index (fields, gchar *, 0));
} else {
GST_LOG ("Read 0 fields from Text ID frame of size %d with encoding %d",
work->parse_size - 1, encoding);
}
}
return fields;
} | false | false | false | false | false | 0 |
InfHostOpenBufferedFile(PHINF InfHandle,
void *Buffer,
ULONG BufferSize,
LANGID LanguageId,
ULONG *ErrorLine)
{
INFSTATUS Status;
PINFCACHE Cache;
WCHAR *FileBuffer;
ULONG FileBufferSize;
*InfHandle = NULL;
*ErrorLine = (ULONG)-1;
/* Allocate file buffer */
FileBufferSize = BufferSize + 2;
FileBuffer = MALLOC(FileBufferSize);
if (FileBuffer == NULL)
{
DPRINT1("MALLOC() failed\n");
return(INF_STATUS_INSUFFICIENT_RESOURCES);
}
MEMCPY(FileBuffer, Buffer, BufferSize);
/* Append string terminator */
FileBuffer[BufferSize] = 0;
FileBuffer[BufferSize + 1] = 0;
/* Allocate infcache header */
Cache = (PINFCACHE)MALLOC(sizeof(INFCACHE));
if (Cache == NULL)
{
DPRINT1("MALLOC() failed\n");
FREE(FileBuffer);
return(INF_STATUS_INSUFFICIENT_RESOURCES);
}
/* Initialize inicache header */
ZEROMEMORY(Cache,
sizeof(INFCACHE));
Cache->LanguageId = LanguageId;
/* Parse the inf buffer */
if (!RtlIsTextUnicode(FileBuffer, (INT)FileBufferSize, NULL))
{
// static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf };
WCHAR *new_buff;
// UINT codepage = CP_ACP;
UINT offset = 0;
// if (BufferSize > sizeof(utf8_bom) && !memcmp(FileBuffer, utf8_bom, sizeof(utf8_bom) ))
// {
// codepage = CP_UTF8;
// offset = sizeof(utf8_bom);
// }
new_buff = MALLOC(FileBufferSize * sizeof(WCHAR));
if (new_buff != NULL)
{
ULONG len;
Status = RtlMultiByteToUnicodeN(new_buff,
FileBufferSize * sizeof(WCHAR),
&len,
(char *)FileBuffer + offset,
FileBufferSize - offset);
Status = InfpParseBuffer(Cache,
new_buff,
new_buff + len / sizeof(WCHAR),
ErrorLine);
FREE(new_buff);
}
else
Status = INF_STATUS_INSUFFICIENT_RESOURCES;
}
else
{
WCHAR *new_buff = (WCHAR *)FileBuffer;
/* UCS-16 files should start with the Unicode BOM; we should skip it */
if (*new_buff == 0xfeff)
{
new_buff++;
FileBufferSize -= sizeof(WCHAR);
}
Status = InfpParseBuffer(Cache,
new_buff,
(WCHAR*)((char*)new_buff + FileBufferSize),
ErrorLine);
}
if (!INF_SUCCESS(Status))
{
FREE(Cache);
Cache = NULL;
}
/* Free file buffer */
FREE(FileBuffer);
*InfHandle = (HINF)Cache;
return INF_SUCCESS(Status) ? 0 : -1;
} | false | false | false | false | false | 0 |
unroll_hindexed(dtype, data, fl_idx, len, elts)
struct trdtype **dtype;
char **data;
int fl_idx;
int *len;
int *elts;
{
int i, j;
int count;
int savaddr;
int disp;
struct trdtype *savbuff;
struct trdtype *idxbuff;
count = (*dtype)->trd_count;
idxbuff = ++(*dtype);
*dtype += count;
savbuff = *dtype;
savaddr = address;
for (i = 0;
(i < count) && (*len > 0) && (*elts != 0);
++i, ++idxbuff) {
disp = idxbuff->trd_disp;
if (fl_idx) disp = HDISP(disp);
address = savaddr + idxbuff->trd_disp;
for (j = 0;
(j < idxbuff->trd_length) && (*len > 0) && (*elts != 0);
++j) {
*dtype = savbuff;
unroll(dtype, data, len, elts);
}
eltcount = 0;
}
} | false | false | false | false | false | 0 |
set_nonblocking(int fd)
{
int flags = fcntl(fd, F_GETFL, 0);
if (flags < 0) return flags;
if (!(flags & O_NONBLOCK)) {
if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0) {
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
restore(const dmtcp::vector<int>& fds,
ConnectionRewirer*)
{
JASSERT (fds.size()>0);
JTRACE ( "RGARG, RGARG, RGARG, RGARG" ) ( fds[0] ) ( id() );
for(size_t i=0; i<fds.size(); ++i)
{
int fd = fds[i];
int tempFd = _real_epoll_create ( _size ) ;
JASSERT ( tempFd >= 0 );
JWARNING ( _real_dup2 ( tempFd, fd ) == fd ) ( tempFd ) ( fd ) ( JASSERT_ERRNO );
}
} | false | false | false | false | false | 0 |
closestPointOnLineSegment(
const Vector3& v0,
const Vector3& v1,
const Vector3& edgeDirection,
const float edgeLength,
const Vector3& point) {
debugAssert((v1 - v0).direction().fuzzyEq(edgeDirection));
debugAssert(fuzzyEq((v1 - v0).magnitude(), edgeLength));
// Vector towards the point
const Vector3& c = point - v0;
// Projected onto the edge itself
float t = edgeDirection.dot(c);
if (t <= 0) {
// Before the start
return v0;
} else if (t >= edgeLength) {
// After the end
return v1;
} else {
// At distance t along the edge
return v0 + edgeDirection * t;
}
} | false | false | false | false | false | 0 |
ExtractInternalReferences(JSObject* js_obj,
HeapEntry* entry) {
int length = js_obj->GetInternalFieldCount();
for (int i = 0; i < length; ++i) {
Object* o = js_obj->GetInternalField(i);
SetInternalReference(
js_obj, entry, i, o, js_obj->GetInternalFieldOffset(i));
}
} | false | false | false | false | false | 0 |
ex_uminus_var(nodeType *p1)
{
nodeType *p;
long ngp, i;
long nlev;
int nmiss;
int gridID, zaxisID;
double missval;
gridID = p1->gridID;
zaxisID = p1->zaxisID;
nmiss = p1->nmiss;
missval = p1->missval;
ngp = gridInqSize(gridID);
nlev = zaxisInqSize(zaxisID);
p = (nodeType *) malloc(sizeof(nodeType));
p->type = typeVar;
p->tmpvar = 1;
p->u.var.nm = strdupx("tmp");
p->gridID = gridID;
p->zaxisID = zaxisID;
p->missval = missval;
p->data = (double *) malloc(ngp*nlev*sizeof(double));
if ( nmiss > 0 )
{
for ( i = 0; i < ngp*nlev; i++ )
p->data[i] = DBL_IS_EQUAL(p1->data[i], missval) ? missval : -(p1->data[i]);
}
else
{
for ( i = 0; i < ngp*nlev; i++ )
p->data[i] = -(p1->data[i]);
}
p->nmiss = nmiss;
return (p);
} | false | false | false | false | false | 0 |
gtk_plot_canvas_ellipse_select(GtkPlotCanvas *canvas, GtkPlotCanvasChild *child, GtkAllocation area)
{
GdkGC *xor_gc = NULL;
GdkGCValues values;
gdk_gc_get_values(GTK_WIDGET(canvas)->style->fg_gc[0], &values);
values.function = GDK_INVERT;
values.foreground = GTK_WIDGET(canvas)->style->white;
values.subwindow_mode = GDK_INCLUDE_INFERIORS;
xor_gc = gdk_gc_new_with_values(GTK_WIDGET(canvas)->window,
&values,
GDK_GC_FOREGROUND |
GDK_GC_FUNCTION |
GDK_GC_SUBWINDOW);
gdk_draw_rectangle (GTK_WIDGET(canvas)->window,
xor_gc,
FALSE,
area.x, area.y,
area.width, area.height);
draw_marker(canvas, xor_gc, area.x, area.y);
draw_marker(canvas, xor_gc, area.x, area.y + area.height);
draw_marker(canvas, xor_gc, area.x + area.width, area.y);
draw_marker(canvas, xor_gc, area.x + area.width, area.y + area.height);
if(area.height > DEFAULT_MARKER_SIZE * 2){
draw_marker(canvas, xor_gc, area.x, area.y + area.height / 2);
draw_marker(canvas, xor_gc, area.x + area.width,
area.y + area.height / 2);
}
if(area.width > DEFAULT_MARKER_SIZE * 2){
draw_marker(canvas, xor_gc, area.x + area.width / 2, area.y);
draw_marker(canvas, xor_gc, area.x + area.width / 2,
area.y + area.height);
}
gdk_gc_set_line_attributes(xor_gc, 1, 1, 0, 0);
gdk_draw_arc (GTK_WIDGET(canvas)->window, xor_gc,
FALSE,
roundint(area.x), roundint(area.y),
roundint(area.width), roundint(area.height), 0, 25000);
if(xor_gc) gdk_gc_unref(xor_gc);
} | false | false | false | false | false | 0 |
joe_iswalnum_(struct charmap *foo,int c)
{
if ((c>=0x30 && c<=0x39) || c==0x5F)
return 1;
else
return joe_iswalpha(foo,c);
} | false | false | false | false | false | 0 |
m88rs6000t_get_if_frequency(struct dvb_frontend *fe, u32 *frequency)
{
struct m88rs6000t_dev *dev = fe->tuner_priv;
dev_dbg(&dev->client->dev, "\n");
*frequency = 0; /* Zero-IF */
return 0;
} | false | false | false | false | false | 0 |
init_vn_nary_op_from_stmt (vn_nary_op_t vno, gimple stmt)
{
unsigned i;
vno->opcode = gimple_assign_rhs_code (stmt);
vno->length = gimple_num_ops (stmt) - 1;
vno->type = gimple_expr_type (stmt);
for (i = 0; i < vno->length; ++i)
vno->op[i] = gimple_op (stmt, i + 1);
if (vno->opcode == REALPART_EXPR
|| vno->opcode == IMAGPART_EXPR
|| vno->opcode == VIEW_CONVERT_EXPR)
vno->op[0] = TREE_OPERAND (vno->op[0], 0);
} | false | false | false | false | false | 0 |
xfs_dir2_block_removename(
xfs_da_args_t *args) /* directory operation args */
{
xfs_dir2_data_hdr_t *hdr; /* block header */
xfs_dir2_leaf_entry_t *blp; /* block leaf pointer */
struct xfs_buf *bp; /* block buffer */
xfs_dir2_block_tail_t *btp; /* block tail */
xfs_dir2_data_entry_t *dep; /* block data entry */
xfs_inode_t *dp; /* incore inode */
int ent; /* block leaf entry index */
int error; /* error return value */
int needlog; /* need to log block header */
int needscan; /* need to fixup bestfree */
xfs_dir2_sf_hdr_t sfh; /* shortform header */
int size; /* shortform size */
xfs_trans_t *tp; /* transaction pointer */
trace_xfs_dir2_block_removename(args);
/*
* Look up the entry in the block. Gets the buffer and entry index.
* It will always be there, the vnodeops level does a lookup first.
*/
if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) {
return error;
}
dp = args->dp;
tp = args->trans;
hdr = bp->b_addr;
btp = xfs_dir2_block_tail_p(args->geo, hdr);
blp = xfs_dir2_block_leaf_p(btp);
/*
* Point to the data entry using the leaf entry.
*/
dep = (xfs_dir2_data_entry_t *)((char *)hdr +
xfs_dir2_dataptr_to_off(args->geo,
be32_to_cpu(blp[ent].address)));
/*
* Mark the data entry's space free.
*/
needlog = needscan = 0;
xfs_dir2_data_make_free(args, bp,
(xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
/*
* Fix up the block tail.
*/
be32_add_cpu(&btp->stale, 1);
xfs_dir2_block_log_tail(tp, bp);
/*
* Remove the leaf entry by marking it stale.
*/
blp[ent].address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
xfs_dir2_block_log_leaf(tp, bp, ent, ent);
/*
* Fix up bestfree, log the header if necessary.
*/
if (needscan)
xfs_dir2_data_freescan(dp, hdr, &needlog);
if (needlog)
xfs_dir2_data_log_header(args, bp);
xfs_dir3_data_check(dp, bp);
/*
* See if the size as a shortform is good enough.
*/
size = xfs_dir2_block_sfsize(dp, hdr, &sfh);
if (size > XFS_IFORK_DSIZE(dp))
return 0;
/*
* If it works, do the conversion.
*/
return xfs_dir2_block_to_sf(args, bp, size, &sfh);
} | false | false | false | false | false | 0 |
enterprise_add_realm (UmAccountDialog *self,
UmRealmObject *realm)
{
GtkTreeModel *model;
GtkTreeIter iter;
UmRealmCommon *common;
const gchar *realm_name;
gboolean match;
gboolean ret;
gchar *name;
common = um_realm_object_get_common (realm);
realm_name = um_realm_common_get_name (common);
/*
* Don't add a second realm if we already have one with this name.
* Sometimes realmd returns to realms for the same name, if it has
* different ways to use that realm. The first one that realmd
* returns is the one it prefers.
*/
model = GTK_TREE_MODEL (self->enterprise_realms);
ret = gtk_tree_model_get_iter_first (model, &iter);
while (ret) {
gtk_tree_model_get (model, &iter, 0, &name, -1);
match = (g_strcmp0 (name, realm_name) == 0);
g_free (name);
if (match) {
g_debug ("ignoring duplicate realm: %s", realm_name);
return;
}
ret = gtk_tree_model_iter_next (model, &iter);
}
gtk_list_store_append (self->enterprise_realms, &iter);
gtk_list_store_set (self->enterprise_realms, &iter,
0, realm_name,
1, realm,
-1);
g_debug ("added realm to drop down: %s %s", realm_name,
g_dbus_object_get_object_path (G_DBUS_OBJECT (realm)));
if (!self->enterprise_domain_chosen && um_realm_is_configured (realm))
gtk_combo_box_set_active_iter (self->enterprise_domain, &iter);
g_object_unref (common);
} | false | false | false | false | false | 0 |
pc_check_skillup(struct map_session_data *sd,int skill_num)
{
int skill_point,up_level;
struct skill_tree_entry *st;
nullpo_retr(0, sd);
st = pc_search_skilltree(&sd->s_class, skill_num);
if(st == NULL)
return 0;
skill_point = pc_calc_skillpoint(sd);
if(skill_point < 9)
up_level = 0;
else if(sd->status.skill_point >= sd->status.job_level && skill_point < 58 && (pc_is2ndclass(sd) || pc_is3rdclass(sd)))
up_level = 1;
else if(pc_is2ndclass(sd))
up_level = 2;
else
up_level = 3;
return (st->class_level <= up_level);
} | false | false | false | false | false | 0 |
argus_change_bg_palette(int color, int data)
{
int r, g, b;
int ir, ig, ib;
r = (data >> 12) & 0x0f;
g = (data >> 8) & 0x0f;
b = (data >> 4) & 0x0f;
ir = (argus_palette_intensity >> 12) & 0x0f;
ig = (argus_palette_intensity >> 8) & 0x0f;
ib = (argus_palette_intensity >> 4) & 0x0f;
r = (r - ir > 0) ? r - ir : 0;
g = (g - ig > 0) ? g - ig : 0;
b = (b - ib > 0) ? b - ib : 0;
if (argus_bg_status & 2) /* Gray / purple scale */
{
r = (r + g + b) / 3;
g = b = r;
if (argus_bg_purple == 2) /* Purple */
g = 0;
}
r = (r << 4) | r;
g = (g << 4) | g;
b = (b << 4) | b;
palette_set_color(color, r, g, b);
} | false | false | false | false | false | 0 |
programsMess (int argc, t_atom*argv) { // FUN
n=0;
delete [] programs;
programs = new GLuint[argc];
while(argc--){
if(argv->a_type == A_FLOAT)programs[n++] = static_cast<GLuint>(atom_getint(argv));
argv++;
}
setModified();
} | false | false | false | false | false | 0 |
ReadHead (istream& in, void* addr1, void* addr2,
void* addr3, void* addr4) {
if (!in.good()) {
cerr << "abnormal exit from ArrowMultiLineScript::ReadHead\n";
return -1;
}
else {
ArrowMultiLine* gs = *(ArrowMultiLine**)addr1;
gs->SetArrows(true, gs->Tail());
return 0;
}
} | false | false | false | false | false | 0 |
get_selected_items() const
{
std::vector<std::string> retval;
std::vector<CL_ListItem *>::const_iterator it;
for(it = items.begin(); it != items.end(); ++it)
if((*it)->selected)
retval.push_back((*it)->str);
return retval;
} | false | false | false | false | false | 0 |
TriggerPostponedEvents()
{
wxASSERT(m_bActive);
if (m_postponedReceive)
{
m_pControlSocket->LogMessage(::Debug_Verbose, _T("Executing postponed receive"));
m_postponedReceive = false;
OnReceive();
if (m_transferEndReason != none)
return;
}
if (m_postponedSend)
{
m_pControlSocket->LogMessage(::Debug_Verbose, _T("Executing postponed send"));
m_postponedSend = false;
OnSend();
if (m_transferEndReason != none)
return;
}
if (m_onCloseCalled)
OnClose(0);
} | false | false | false | false | false | 0 |
stripe_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
dict_t *params)
{
stripe_private_t *priv = NULL;
stripe_local_t *local = NULL;
xlator_list_t *trav = NULL;
int32_t op_errno = 1;
VALIDATE_OR_GOTO (frame, err);
VALIDATE_OR_GOTO (this, err);
VALIDATE_OR_GOTO (loc, err);
VALIDATE_OR_GOTO (loc->path, err);
VALIDATE_OR_GOTO (loc->inode, err);
priv = this->private;
trav = this->children;
if (priv->first_child_down) {
op_errno = ENOTCONN;
goto err;
}
/* Initialization */
local = GF_CALLOC (1, sizeof (stripe_local_t),
gf_stripe_mt_stripe_local_t);
if (!local) {
op_errno = ENOMEM;
goto err;
}
local->op_ret = -1;
local->call_count = priv->child_count;
local->dict = dict_ref (params);
local->mode = mode;
loc_copy (&local->loc, loc);
frame->local = local;
/* Everytime in stripe lookup, all child nodes should be looked up */
STACK_WIND (frame, stripe_first_mkdir_cbk, trav->xlator,
trav->xlator->fops->mkdir, loc, mode, params);
return 0;
err:
STRIPE_STACK_UNWIND (mkdir, frame, -1, op_errno, NULL, NULL, NULL, NULL);
return 0;
} | false | false | false | false | false | 0 |
embBtreeEmblSV(const AjPStr idline, AjPList svlist)
{
AjPStr token = NULL;
AjPStr str = NULL;
AjPStr idstr = NULL;
AjPStr svstr = NULL;
ajStrAssignSubS(&embindexLine, idline, 5, -1);
ajStrTokenAssignC(&embindexHandle,embindexLine," \t\n\r;");
if(!ajStrTokenNextParse(embindexHandle,&idstr))
return;
if(!ajStrTokenNextParse(embindexHandle,&token))
return;
if(!ajStrTokenNextParse(embindexHandle,&svstr))
return;
if(!ajStrMatchC(token, "SV"))
return;
str = ajStrNewRes(MAJSTRGETLEN(idstr)+MAJSTRGETLEN(svstr)+2);
ajFmtPrintS(&str,"%S.%S", idstr, svstr);
ajListstrPush(svlist, str);
str = NULL;
ajStrDel(&idstr);
ajStrDel(&svstr);
ajStrDel(&token);
return;
} | false | false | false | false | false | 0 |
twa_poll_response(TW_Device_Extension *tw_dev, int request_id, int seconds)
{
int retval = 1, found = 0, response_request_id;
TW_Response_Queue response_queue;
TW_Command_Full *full_command_packet = tw_dev->command_packet_virt[request_id];
if (twa_poll_status_gone(tw_dev, TW_STATUS_RESPONSE_QUEUE_EMPTY, seconds) == 0) {
response_queue.value = readl(TW_RESPONSE_QUEUE_REG_ADDR(tw_dev));
response_request_id = TW_RESID_OUT(response_queue.response_id);
if (request_id != response_request_id) {
TW_PRINTK(tw_dev->host, TW_DRIVER, 0x1e, "Found unexpected request id while polling for response");
goto out;
}
if (TW_OP_OUT(full_command_packet->command.newcommand.opcode__reserved) == TW_OP_EXECUTE_SCSI) {
if (full_command_packet->command.newcommand.status != 0) {
/* bad response */
twa_fill_sense(tw_dev, request_id, 0, 0);
goto out;
}
found = 1;
} else {
if (full_command_packet->command.oldcommand.status != 0) {
/* bad response */
twa_fill_sense(tw_dev, request_id, 0, 0);
goto out;
}
found = 1;
}
}
if (found)
retval = 0;
out:
return retval;
} | false | false | false | false | false | 0 |
nfs_iob_get_fh ( struct io_buffer *io_buf, struct nfs_fh *fh ) {
fh->size = oncrpc_iob_get_int ( io_buf );
if ( fh->size > 64 )
return sizeof ( uint32_t );
memcpy (fh->fh, io_buf->data, fh->size );
iob_pull ( io_buf, fh->size );
return fh->size + sizeof ( uint32_t );
} | false | true | false | false | false | 1 |