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
|
---|---|---|---|---|---|---|
HandleMacroExit() {
// Jump to the EndOfStatement we should return to, and consume it.
JumpToLoc(ActiveMacros.back()->ExitLoc);
Lex();
// Pop the instantiation entry.
delete ActiveMacros.back();
ActiveMacros.pop_back();
}
| false | false | false | false | false | 0 |
mca_topo_base_cart_map(ompi_communicator_t* comm,
int ndims,
int *dims, int *periods, int *newrank)
{
int nprocs, rank, size, i, *p;
/*
* Compute the # of processes in the grid.
*/
nprocs = 1;
for (i = 0, p = dims; i < ndims; ++i, ++p) {
if (*p <= 0) {
return MPI_ERR_DIMS;
}
nprocs *= *p;
}
/*
* Check that number of processes <= size of communicator.
*/
size = ompi_comm_size(comm);
if (nprocs > size) {
return MPI_ERR_DIMS;
}
/*
* Compute my new rank.
*/
rank = ompi_comm_rank(comm);
*newrank = ((rank < 0) || (rank >= nprocs)) ? MPI_UNDEFINED : rank;
return MPI_SUCCESS;
}
| false | false | false | false | false | 0 |
UpdatePlayerScore(Player* Source, uint32 type, uint32 value)
{
// this procedure is called from virtual function implemented in bg subclass
BattleGroundScoreMap::const_iterator itr = m_PlayerScores.find(Source->GetObjectGuid());
if (itr == m_PlayerScores.end()) // player not found...
return;
switch (type)
{
case SCORE_KILLING_BLOWS: // Killing blows
itr->second->KillingBlows += value;
break;
case SCORE_DEATHS: // Deaths
itr->second->Deaths += value;
break;
case SCORE_HONORABLE_KILLS: // Honorable kills
itr->second->HonorableKills += value;
break;
case SCORE_BONUS_HONOR: // Honor bonus
// do not add honor in arenas
if (isBattleGround())
{
// reward honor instantly
if (Source->RewardHonor(NULL, 1, (float)value))
itr->second->BonusHonor += value;
}
break;
// used only in EY, but in MSG_PVP_LOG_DATA opcode
case SCORE_DAMAGE_DONE: // Damage Done
itr->second->DamageDone += value;
break;
case SCORE_HEALING_DONE: // Healing Done
itr->second->HealingDone += value;
break;
default:
sLog.outError("BattleGround: Unknown player score type %u", type);
break;
}
}
| false | false | false | false | false | 0 |
print_selected_keywords_grep_friendly (void *cls,
const char *plugin_name,
enum EXTRACTOR_MetaType type,
enum EXTRACTOR_MetaFormat format,
const char *data_mime_type,
const char *data,
size_t data_len)
{
char *keyword;
#if HAVE_ICONV
iconv_t cd;
#endif
const char *mt;
if (YES != print[type])
return 0;
mt = EXTRACTOR_metatype_to_string (type);
if (NULL == mt)
mt = gettext_noop ("unknown");
switch (format)
{
case EXTRACTOR_METAFORMAT_UNKNOWN:
break;
case EXTRACTOR_METAFORMAT_UTF8:
if (verbose > 1)
FPRINTF (stdout,
"%s: ",
gettext(mt));
#if HAVE_ICONV
cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
if (((iconv_t) -1) != cd)
keyword = iconv_helper (cd,
data,
data_len);
else
#endif
keyword = strdup (data);
if (NULL != keyword)
{
FPRINTF (stdout,
"`%s' ",
keyword);
free (keyword);
}
#if HAVE_ICONV
if (((iconv_t) -1) != cd)
iconv_close (cd);
#endif
break;
case EXTRACTOR_METAFORMAT_BINARY:
break;
case EXTRACTOR_METAFORMAT_C_STRING:
if (verbose > 1)
FPRINTF (stdout,
"%s ",
gettext(mt));
FPRINTF (stdout,
"`%s'",
data);
break;
default:
break;
}
return 0;
}
| false | false | false | false | false | 0 |
xdico_assoc_append(dico_assoc_list_t assoc, const char *key, const char *value)
{
if (dico_assoc_append(assoc, key, value) && errno == ENOMEM)
xalloc_die();
}
| false | false | false | false | false | 0 |
si21xx_init(struct dvb_frontend *fe)
{
struct si21xx_state *state = fe->demodulator_priv;
int i;
int status = 0;
u8 reg1;
u8 val;
u8 reg2[2];
dprintk("%s\n", __func__);
for (i = 0; ; i += 2) {
reg1 = serit_sp1511lhb_inittab[i];
val = serit_sp1511lhb_inittab[i+1];
if (reg1 == 0xff && val == 0xff)
break;
si21_writeregs(state, reg1, &val, 1);
}
/*DVB QPSK SYSTEM MODE REG*/
reg1 = 0x08;
si21_writeregs(state, SYSTEM_MODE_REG, ®1, 0x01);
/*transport stream config*/
/*
mode = PARALLEL;
sdata_form = LSB_FIRST;
clk_edge = FALLING_EDGE;
clk_mode = CLK_GAPPED_MODE;
strt_len = BYTE_WIDE;
sync_pol = ACTIVE_HIGH;
val_pol = ACTIVE_HIGH;
err_pol = ACTIVE_HIGH;
sclk_rate = 0x00;
parity = 0x00 ;
data_delay = 0x00;
clk_delay = 0x00;
pclk_smooth = 0x00;
*/
reg2[0] =
PARALLEL + (LSB_FIRST << 1)
+ (FALLING_EDGE << 2) + (CLK_GAPPED_MODE << 3)
+ (BYTE_WIDE << 4) + (ACTIVE_HIGH << 5)
+ (ACTIVE_HIGH << 6) + (ACTIVE_HIGH << 7);
reg2[1] = 0;
/* sclk_rate + (parity << 2)
+ (data_delay << 3) + (clk_delay << 4)
+ (pclk_smooth << 5);
*/
status |= si21_writeregs(state, TS_CTRL_REG_1, reg2, 0x02);
if (status != 0)
dprintk(" %s : TS Set Error\n", __func__);
return 0;
}
| false | false | false | false | false | 0 |
opt3001_irq(int irq, void *_iio)
{
struct iio_dev *iio = _iio;
struct opt3001 *opt = iio_priv(iio);
int ret;
if (!opt->ok_to_ignore_lock)
mutex_lock(&opt->lock);
ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION);
if (ret < 0) {
dev_err(opt->dev, "failed to read register %02x\n",
OPT3001_CONFIGURATION);
goto out;
}
if ((ret & OPT3001_CONFIGURATION_M_MASK) ==
OPT3001_CONFIGURATION_M_CONTINUOUS) {
if (ret & OPT3001_CONFIGURATION_FH)
iio_push_event(iio,
IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
iio_get_time_ns());
if (ret & OPT3001_CONFIGURATION_FL)
iio_push_event(iio,
IIO_UNMOD_EVENT_CODE(IIO_LIGHT, 0,
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING),
iio_get_time_ns());
} else if (ret & OPT3001_CONFIGURATION_CRF) {
ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_RESULT);
if (ret < 0) {
dev_err(opt->dev, "failed to read register %02x\n",
OPT3001_RESULT);
goto out;
}
opt->result = ret;
opt->result_ready = true;
wake_up(&opt->result_ready_queue);
}
out:
if (!opt->ok_to_ignore_lock)
mutex_unlock(&opt->lock);
return IRQ_HANDLED;
}
| false | false | false | false | false | 0 |
end_ebml_master(ByteIOContext *pb, ebml_master master)
{
int64_t pos = url_ftell(pb);
// leave the unknown size for masters when streaming
if (url_is_streamed(pb))
return;
url_fseek(pb, master.pos - master.sizebytes, SEEK_SET);
put_ebml_num(pb, pos - master.pos, master.sizebytes);
url_fseek(pb, pos, SEEK_SET);
}
| false | false | false | false | false | 0 |
__repmgr_send_own_msg(env, conn, type, buf, len)
ENV *env;
REPMGR_CONNECTION *conn;
u_int8_t *buf;
u_int32_t len, type;
{
REPMGR_IOVECS iovecs;
struct sending_msg msg;
__repmgr_msg_hdr_args msg_hdr;
u_int8_t hdr_buf[__REPMGR_MSG_HDR_SIZE];
if (conn->version < OWN_MIN_VERSION)
return (0);
msg_hdr.type = REPMGR_OWN_MSG;
REPMGR_OWN_BUF_SIZE(msg_hdr) = len;
REPMGR_OWN_MSG_TYPE(msg_hdr) = type;
__repmgr_msg_hdr_marshal(env, &msg_hdr, hdr_buf);
__repmgr_iovec_init(&iovecs);
__repmgr_add_buffer(&iovecs, hdr_buf, __REPMGR_MSG_HDR_SIZE);
if (len > 0)
__repmgr_add_buffer(&iovecs, buf, len);
msg.iovecs = &iovecs;
msg.fmsg = NULL;
return (__repmgr_send_internal(env, conn, &msg, 0));
}
| false | false | false | false | false | 0 |
explain_buffer_pollfd(explain_string_buffer_t *sb,
const struct pollfd *data, int include_revents)
{
#ifdef HAVE_POLL_H
if (explain_is_efault_pointer(data, sizeof(*data)))
{
explain_buffer_pointer(sb, data);
return;
}
explain_string_buffer_puts(sb, "{ fd = ");
explain_buffer_fildes(sb, data->fd);
explain_string_buffer_puts(sb, ", events = ");
explain_buffer_pollfd_events(sb, data->events);
if (include_revents)
{
explain_string_buffer_puts(sb, ", revents = ");
explain_buffer_pollfd_events(sb, data->revents);
}
explain_string_buffer_puts(sb, " }");
#else
(void)include_revents;
explain_buffer_pointer(sb, data);
#endif
}
| false | false | false | false | false | 0 |
binfo_ctor_vtable (tree binfo)
{
tree vt;
while (1)
{
vt = BINFO_VTABLE (binfo);
if (TREE_CODE (vt) == TREE_LIST)
vt = TREE_VALUE (vt);
if (TREE_CODE (vt) == TREE_BINFO)
binfo = vt;
else
break;
}
return vt;
}
| false | false | false | false | false | 0 |
ath6kl_cfg80211_deepsleep_suspend(struct ath6kl *ar)
{
struct ath6kl_vif *vif;
int ret;
vif = ath6kl_vif_first(ar);
if (!vif)
return -EIO;
if (!test_bit(WMI_READY, &ar->flag)) {
ath6kl_err("deepsleep failed as wmi is not ready\n");
return -EIO;
}
ath6kl_cfg80211_stop_all(ar);
/* Save the current power mode before enabling power save */
ar->wmi->saved_pwr_mode = ar->wmi->pwr_mode;
ret = ath6kl_wmi_powermode_cmd(ar->wmi, 0, REC_POWER);
if (ret)
return ret;
/* Disable WOW mode */
ret = ath6kl_wmi_set_wow_mode_cmd(ar->wmi, vif->fw_vif_idx,
ATH6KL_WOW_MODE_DISABLE,
0, 0);
if (ret)
return ret;
/* Flush all non control pkts in TX path */
ath6kl_tx_data_cleanup(ar);
ret = ath6kl_cfg80211_host_sleep(ar, vif);
if (ret)
return ret;
return 0;
}
| false | false | false | false | false | 0 |
SetField(int attributeID, const int* values, size_t size, bool image)
{
*this->OutputStream << " " << x3dAttributeString[attributeID] << "=\"" << this->GetNewline() << this->ActTab;
unsigned int i = 0;
if (image)
{
assert(size > 2);
char buffer[20];
*this->OutputStream << values[0] << " "; // width
*this->OutputStream << values[1] << " "; // height
int bpp = values[2]; *this->OutputStream << bpp << "\n"; // bpp
i = 3;
unsigned int j = 0;
while (i < size)
{
sprintf(buffer,"0x%.8x",values[i]);
*this->OutputStream << buffer;
if (j%(8*bpp))
{
*this->OutputStream << " ";
}
else
{
*this->OutputStream << this->GetNewline();// << this->ActTab;
}
i++; j+=bpp;
}
*this->OutputStream << dec;
}
else
while (i < size)
{
*this->OutputStream << values[i] << " ";
if (values[i] == -1)
{
*this->OutputStream << this->GetNewline() << this->ActTab;
}
i++;
}
*this->OutputStream << "\"";
}
| false | false | false | false | false | 0 |
ReadHashItem_bin( const char *srcbuf, HASH_ITEM *pItem, int item_index )
{
int len, i;
const char *pc;
memset( pItem, 0, sizeof(HASH_ITEM) );
/* freq info */
pItem->data.userfreq = GetInt32(&srcbuf[ 0 ]);
pItem->data.recentTime = GetInt32(&srcbuf[ 4 ]);
pItem->data.maxfreq = GetInt32(&srcbuf[ 8 ]);
pItem->data.origfreq = GetInt32(&srcbuf[ 12 ]);
/* phone seq, length in num of chi words */
len = (int) srcbuf[ 16 ];
pItem->data.phoneSeq = ALC( uint16_t, len + 1 );
pc = &srcbuf[ 17 ];
for ( i = 0; i < len; i++ ) {
pItem->data.phoneSeq[ i ] = GetUint16( pc );
pc += 2;
}
pItem->data.phoneSeq[ i ] = 0;
/* phrase, length in num of bytes */
pItem->data.wordSeq = ALC( char, (*pc) + 1 );
strcpy( pItem->data.wordSeq, (char *) (pc + 1) );
pItem->data.wordSeq[ (unsigned int) *pc ] = '\0';
/* Invalid UTF-8 Chinese characters found */
if ( ! isValidChineseString( pItem->data.wordSeq ) ) {
goto ignore_corrupted_record;
}
/* set item_index */
pItem->item_index = item_index;
return 1; /* continue */
ignore_corrupted_record:
if ( pItem->data.phoneSeq != NULL ) {
free( pItem->data.phoneSeq );
pItem->data.phoneSeq = NULL;
}
if ( pItem->data.wordSeq != NULL ) {
free( pItem->data.wordSeq );
pItem->data.wordSeq = NULL;
}
return -1; /* ignore */
}
| false | false | false | false | false | 0 |
push( int fd, SP_Handler * handler, int needStart )
{
SP_IOChannel * ioChannel = new SP_DefaultIOChannel();
return push( fd, handler, ioChannel, needStart );
}
| false | false | false | false | false | 0 |
obuf_close(obuf* out)
{
int result;
result = obuf_flush(out);
return iobuf_close(&out->io) && result;
}
| false | false | false | false | false | 0 |
p_tabw_destroy_attw_dlg (GapStbTabWidgets *tabw, gboolean destroy_all)
{
GapStbAttrWidget *attw;
GapStbAttrWidget *attw_prev;
GapStbAttrWidget *attw_next;
GapStoryBoard *stb;
if(tabw==NULL) { return; }
stb = p_tabw_get_stb_ptr(tabw);
if(stb==NULL) { return; }
attw_prev = NULL;
for(attw = tabw->attw; attw != NULL; attw = attw_next)
{
attw_next = (GapStbAttrWidget *)attw->next;
if(attw->stb_elem_refptr)
{
gboolean destroy_elem;
destroy_elem = TRUE;
if(!destroy_all)
{
GapStoryElem *stb_elem;
GapStorySection *active_section;
active_section = stb->active_section;
if (active_section != NULL)
{
for(stb_elem = active_section->stb_elem; stb_elem != NULL; stb_elem = stb_elem->next)
{
if(stb_elem == attw->stb_elem_refptr)
{
destroy_elem = FALSE;
break;
}
}
}
}
if(destroy_elem)
{
if(attw->stb_elem_bck)
{
gap_story_elem_free(&attw->stb_elem_bck);
}
if(attw->attw_prop_dialog)
{
gtk_widget_destroy(attw->attw_prop_dialog);
}
if(attw_prev)
{
attw_prev->next = attw_next;
}
else
{
tabw->attw = attw_next;
}
g_free(attw);
}
else
{
attw_prev = attw;
}
}
}
}
| false | false | false | false | false | 0 |
gate_handle_reorder_blocks (void)
{
if (targetm.cannot_modify_jumps_p ())
return false;
/* Don't reorder blocks when optimizing for size because extra jump insns may
be created; also barrier may create extra padding.
More correctly we should have a block reordering mode that tried to
minimize the combined size of all the jumps. This would more or less
automatically remove extra jumps, but would also try to use more short
jumps instead of long jumps. */
if (!optimize_function_for_speed_p (cfun))
return false;
return (optimize > 0
&& (flag_reorder_blocks || flag_reorder_blocks_and_partition));
}
| false | false | false | false | false | 0 |
add_frame_hooker(const char *arg)
{
int argc = 0;
char *argv[64];
int i;
char *args = av_strdup(arg);
using_vhook = 1;
argv[0] = strtok(args, " ");
while (argc < 62 && (argv[++argc] = strtok(NULL, " "))) {
}
i = frame_hook_add(argc, argv);
if (i != 0) {
fprintf(stderr, "Failed to add video hook function: %s\n", arg);
av_exit(1);
}
}
| true | true | false | false | false | 1 |
createTargets(ApplyMultiplexerData * data) {
int length;
int total_buffers = 0;
if (data->regions->finish - data->regions->start >= MAX_BUFFER) {
addTarget(data, createTarget(data));
pop(data->regions);
} else {
while(!data->regions->done
&& (length = data->regions->finish - data->regions->start) < MAX_BUFFER
&& (!data->head
|| ((total_buffers += length) < MAX_BUFFER_SUM && data->regions->finish <= data->head->start + MAX_SEEK && !strcmp(data->regions->chrom, data->tail->chrom))
)
)
{
addTarget(data, createTarget(data));
pop(data->regions);
}
seek(data->input, data->head->chrom, data->head->start, data->tail->finish);
}
}
| false | false | false | false | false | 0 |
vbox_get_nr_new_messages(ClientData cd, Tcl_Interp *ip, int argc, char *argv[])
{
int n;
if (argc != 2)
{
log(L_ERROR, "[vbox_get_nr_new_messages] usage: vbox_get_nr_new_messages <path>\n");
printstring(ip->result, "0");
}
else
{
log(L_JUNK, "[vbox_get_nr_new_messages] counting new messages in \"%s\"...\n", argv[1]);
n = get_nr_messages(argv[1], TRUE);
log(L_DEBUG, "[vbox_get_nr_new_messages] result \"%d\".\n", n);
printstring(ip->result, "%d", n);
}
return(TCL_OK);
}
| false | false | false | false | false | 0 |
properties_update_history (GtkTreeModel *model,
GtkTreeIter *iter)
{
#ifdef HISTORY_FILE
GtkTextView *view;
GtkTextBuffer *buffer;
gchar *history;
gchar *name;
gchar *cloneof;
GError *error = NULL;
view = GTK_TEXT_VIEW (GVA_WIDGET_PROPERTIES_HISTORY_TEXT_VIEW);
buffer = gtk_text_view_get_buffer (view);
gtk_tree_model_get (
model, iter, GVA_GAME_STORE_COLUMN_NAME, &name,
GVA_GAME_STORE_COLUMN_CLONEOF, &cloneof, -1);
history = gva_history_lookup (name, &error);
if (history == NULL && error == NULL && cloneof != NULL)
history = gva_history_lookup (cloneof, &error);
if (history == NULL)
{
if (error != NULL)
{
history = g_strdup_printf (
_("Error while fetching history:\n%s"),
error->message);
g_clear_error (&error);
}
else
history = g_strdup (_("History not available"));
}
gtk_text_buffer_set_text (buffer, history, -1);
g_free (history);
g_free (cloneof);
g_free (name);
#endif
}
| false | false | false | false | false | 0 |
pci_quatech_init(struct pci_dev *dev)
{
if (pci_quatech_amcc(dev->device)) {
unsigned long base = pci_resource_start(dev, 0);
if (base) {
u32 tmp;
outl(inl(base + 0x38) | 0x00002000, base + 0x38);
tmp = inl(base + 0x3c);
outl(tmp | 0x01000000, base + 0x3c);
outl(tmp &= ~0x01000000, base + 0x3c);
}
}
return 0;
}
| false | false | false | false | false | 0 |
klp_write_module_reloc(struct module *mod, unsigned long type,
unsigned long loc, unsigned long value)
{
size_t size = 4;
unsigned long val;
unsigned long core = (unsigned long)mod->core_layout.base;
unsigned long core_size = mod->core_layout.size;
switch (type) {
case R_X86_64_NONE:
return 0;
case R_X86_64_64:
val = value;
size = 8;
break;
case R_X86_64_32:
val = (u32)value;
break;
case R_X86_64_32S:
val = (s32)value;
break;
case R_X86_64_PC32:
val = (u32)(value - loc);
break;
default:
/* unsupported relocation type */
return -EINVAL;
}
if (loc < core || loc >= core + core_size)
/* loc does not point to any symbol inside the module */
return -EINVAL;
return probe_kernel_write((void *)loc, &val, size);
}
| false | false | false | false | false | 0 |
trace() const
{
REPORT
int i = nrows_val; int w = lower_val+upper_val+1;
Real sum = 0.0; Real* s = store+lower_val;
// while (i--) { sum += *s; s += w; }
if (i) for (;;) { sum += *s; if (!(--i)) break; s += w; }
((GeneralMatrix&)*this).tDelete(); return sum;
}
| false | false | false | false | false | 0 |
lwline_serialize_buf(LWLINE *line, uchar *buf, size_t *retsize)
{
char hasSRID;
uchar *loc;
int ptsize;
size_t size;
LWDEBUGF(2, "lwline_serialize_buf(%p, %p, %p) called",
line, buf, retsize);
if (line == NULL)
lwerror("lwline_serialize:: given null line");
if ( TYPE_GETZM(line->type) != TYPE_GETZM(line->points->dims) )
lwerror("Dimensions mismatch in lwline");
ptsize = pointArray_ptsize(line->points);
hasSRID = (line->SRID != -1);
buf[0] = (uchar) lwgeom_makeType_full(
TYPE_HASZ(line->type), TYPE_HASM(line->type),
hasSRID, LINETYPE, line->bbox ? 1 : 0);
loc = buf+1;
LWDEBUGF(3, "lwline_serialize_buf added type (%d)", line->type);
if (line->bbox)
{
memcpy(loc, line->bbox, sizeof(BOX2DFLOAT4));
loc += sizeof(BOX2DFLOAT4);
LWDEBUG(3, "lwline_serialize_buf added BBOX");
}
if (hasSRID)
{
memcpy(loc, &line->SRID, sizeof(int32));
loc += sizeof(int32);
LWDEBUG(3, "lwline_serialize_buf added SRID");
}
memcpy(loc, &line->points->npoints, sizeof(uint32));
loc += sizeof(uint32);
LWDEBUGF(3, "lwline_serialize_buf added npoints (%d)",
line->points->npoints);
/*copy in points */
size = line->points->npoints*ptsize;
memcpy(loc, getPoint_internal(line->points, 0), size);
loc += size;
LWDEBUGF(3, "lwline_serialize_buf copied serialized_pointlist (%d bytes)",
ptsize * line->points->npoints);
if (retsize) *retsize = loc-buf;
/*printBYTES((uchar *)result, loc-buf); */
LWDEBUGF(3, "lwline_serialize_buf returning (loc: %p, size: %d)",
loc, loc-buf);
}
| false | false | false | true | false | 1 |
gearman_client_set_status_fn(gearman_client_st *client,
gearman_universal_status_fn *function)
{
if (client)
{
client->actions.status_fn= function;
}
}
| false | false | false | false | false | 0 |
show_switch(ivl_switch_t net)
{
const char*name = ivl_switch_basename(net);
int has_enable = 0;
ivl_nexus_t nexa, nexb;
ivl_variable_type_t nex_type_a, nex_type_b;
switch (ivl_switch_type(net)) {
case IVL_SW_TRAN:
fprintf(out, " tran %s", name);
break;
case IVL_SW_RTRAN:
fprintf(out, " rtran %s", name);
break;
case IVL_SW_TRANIF0:
fprintf(out, " tranif0 %s", name);
has_enable = 1;
break;
case IVL_SW_RTRANIF0:
fprintf(out, " rtranif0 %s", name);
has_enable = 1;
break;
case IVL_SW_TRANIF1:
fprintf(out, " tranif1 %s", name);
has_enable = 1;
break;
case IVL_SW_RTRANIF1:
fprintf(out, " rtranif1 %s", name);
has_enable = 1;
break;
case IVL_SW_TRAN_VP:
fprintf(out, " tran(VP wid=%u, part=%u, off=%u) %s",
ivl_switch_width(net), ivl_switch_part(net),
ivl_switch_offset(net), name);
break;
}
fprintf(out, " island=%p\n", ivl_switch_island(net));
nexa = ivl_switch_a(net);
nex_type_a = nexa? type_of_nexus(nexa) : IVL_VT_NO_TYPE;
fprintf(out, " A: %p <type=%s>\n", nexa, data_type_string(nex_type_a));
nexb = ivl_switch_b(net);
nex_type_b = nexb? type_of_nexus(nexb) : IVL_VT_NO_TYPE;
fprintf(out, " B: %p <type=%s>\n", nexb, data_type_string(nex_type_b));
/* The A/B pins of the switch must be present, and must match. */
if (nex_type_a == IVL_VT_NO_TYPE) {
fprintf(out, " A: ERROR: Type missing for pin A\n");
stub_errors += 1;
}
if (nex_type_b == IVL_VT_NO_TYPE) {
fprintf(out, " B: ERROR: Type missing for pin B\n");
stub_errors += 1;
}
if (nex_type_a != nex_type_b) {
fprintf(out, " A/B: ERROR: Type mismatch between pins A and B\n");
stub_errors += 1;
}
if (ivl_switch_type(net) == IVL_SW_TRAN_VP) {
/* The TRAN_VP nodes are special in that the specific
width matters for each port and should be exactly
right for both. */
if (width_of_nexus(nexa) != ivl_switch_width(net)) {
fprintf(out, " A: ERROR: part vector nexus "
"width=%u, expecting width=%u\n",
width_of_nexus(nexa), ivl_switch_width(net));
stub_errors += 1;
}
if (width_of_nexus(nexb) != ivl_switch_part(net)) {
fprintf(out, " B: ERROR: part select nexus "
"width=%u, expecting width=%u\n",
width_of_nexus(nexb), ivl_switch_part(net));
stub_errors += 1;
}
} else {
/* All other TRAN nodes will have matching vector
widths, but the actual value doesn't matter. */
if (width_of_nexus(nexa) != width_of_nexus(nexb)) {
fprintf(out, " A/B: ERROR: Width of ports don't match"
": A=%u, B=%u\n",
width_of_nexus(nexa), width_of_nexus(nexb));
stub_errors += 1;
}
}
if (has_enable) {
ivl_nexus_t nexe = ivl_switch_enable(net);
fprintf(out, " E: %p\n", nexe);
if (width_of_nexus(nexe) != 1) {
fprintf(out, " E: ERROR: Nexus width is %u\n",
width_of_nexus(nexe));
}
}
}
| false | false | false | false | false | 0 |
m68hc11_notice_update_cc (exp, insn)
rtx exp;
rtx insn ATTRIBUTE_UNUSED;
{
/* recognize SET insn's. */
if (GET_CODE (exp) == SET)
{
/* Jumps do not alter the cc's. */
if (SET_DEST (exp) == pc_rtx)
;
/* NOTE: most instructions don't affect the carry bit, but the
bhi/bls/bhs/blo instructions use it. This isn't mentioned in
the conditions.h header. */
/* Function calls clobber the cc's. */
else if (GET_CODE (SET_SRC (exp)) == CALL)
{
CC_STATUS_INIT;
}
/* Tests and compares set the cc's in predictable ways. */
else if (SET_DEST (exp) == cc0_rtx)
{
cc_status.flags = 0;
cc_status.value1 = XEXP (exp, 0);
cc_status.value2 = XEXP (exp, 1);
}
else
{
/* All other instructions affect the condition codes. */
cc_status.flags = 0;
cc_status.value1 = XEXP (exp, 0);
cc_status.value2 = XEXP (exp, 1);
}
}
else
{
/* Default action if we haven't recognized something
and returned earlier. */
CC_STATUS_INIT;
}
if (cc_status.value2 != 0)
switch (GET_CODE (cc_status.value2))
{
/* These logical operations can generate several insns.
The flags are setup according to what is generated. */
case IOR:
case XOR:
case AND:
break;
/* The (not ...) generates several 'com' instructions for
non QImode. We have to invalidate the flags. */
case NOT:
if (GET_MODE (cc_status.value2) != QImode)
CC_STATUS_INIT;
break;
case PLUS:
case MINUS:
case MULT:
case DIV:
case UDIV:
case MOD:
case UMOD:
case NEG:
if (GET_MODE (cc_status.value2) != VOIDmode)
cc_status.flags |= CC_NO_OVERFLOW;
break;
/* The asl sets the overflow bit in such a way that this
makes the flags unusable for a next compare insn. */
case ASHIFT:
case ROTATE:
case ROTATERT:
if (GET_MODE (cc_status.value2) != VOIDmode)
cc_status.flags |= CC_NO_OVERFLOW;
break;
/* A load/store instruction does not affect the carry. */
case MEM:
case SYMBOL_REF:
case REG:
case CONST_INT:
cc_status.flags |= CC_NO_OVERFLOW;
break;
default:
break;
}
if (cc_status.value1 && GET_CODE (cc_status.value1) == REG
&& cc_status.value2
&& reg_overlap_mentioned_p (cc_status.value1, cc_status.value2))
cc_status.value2 = 0;
else if (cc_status.value1 && side_effects_p (cc_status.value1))
cc_status.value1 = 0;
else if (cc_status.value2 && side_effects_p (cc_status.value2))
cc_status.value2 = 0;
}
| false | false | false | false | false | 0 |
fuse_main_common(int argc, char *argv[],
const struct fuse_operations *op, size_t op_size,
void *user_data, int compat)
{
struct fuse *fuse;
char *mountpoint;
int multithreaded;
int res;
fuse = fuse_setup_common(argc, argv, op, op_size, &mountpoint,
&multithreaded, NULL, user_data, compat);
if (fuse == NULL)
return 1;
if (multithreaded)
res = fuse_loop_mt(fuse);
else
res = fuse_loop(fuse);
fuse_teardown_common(fuse, mountpoint);
if (res == -1)
return 1;
return 0;
}
| false | false | false | false | false | 0 |
arena_malloc_small(arena_t *arena, size_t size, bool zero)
{
void *ret;
arena_bin_t *bin;
arena_run_t *run;
size_t binind;
binind = SMALL_SIZE2BIN(size);
assert(binind < nbins);
bin = &arena->bins[binind];
size = arena_bin_info[binind].reg_size;
malloc_mutex_lock(&bin->lock);
if ((run = bin->runcur) != NULL && run->nfree > 0)
ret = arena_run_reg_alloc(run, &arena_bin_info[binind]);
else
ret = arena_bin_malloc_hard(arena, bin);
if (ret == NULL) {
malloc_mutex_unlock(&bin->lock);
return (NULL);
}
#ifdef JEMALLOC_STATS
bin->stats.allocated += size;
bin->stats.nmalloc++;
bin->stats.nrequests++;
#endif
malloc_mutex_unlock(&bin->lock);
#ifdef JEMALLOC_PROF
if (isthreaded == false) {
malloc_mutex_lock(&arena->lock);
arena_prof_accum(arena, size);
malloc_mutex_unlock(&arena->lock);
}
#endif
if (zero == false) {
#ifdef JEMALLOC_FILL
if (opt_junk)
memset(ret, 0xa5, size);
else if (opt_zero)
memset(ret, 0, size);
#endif
} else
memset(ret, 0, size);
return (ret);
}
| false | false | false | false | false | 0 |
get_activity_nr(struct activity *act[], unsigned int option, int count_outputs)
{
int i, n = 0;
unsigned int msk;
for (i = 0; i < NR_ACT; i++) {
if ((act[i]->options & option) == option) {
if (HAS_MULTIPLE_OUTPUTS(act[i]->options) && count_outputs) {
for (msk = 1; msk < 0x10; msk <<= 1) {
if (act[i]->opt_flags & msk) {
n++;
}
}
}
else {
n++;
}
}
}
return n;
}
| false | false | false | false | false | 0 |
HasCategoryCooldown(uint32 spell_id) const
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if (!spellInfo)
return false;
CreatureSpellCooldowns::const_iterator itr = m_CreatureCategoryCooldowns.find(spellInfo->Category);
return (itr != m_CreatureCategoryCooldowns.end() && time_t(itr->second + (spellInfo->CategoryRecoveryTime / IN_MILLISECONDS)) > time(NULL));
}
| false | false | false | false | false | 0 |
answer_is_yes_no_quit( const char *s )
{
/* TRANSLATORS: See doc/TRANSLATE about this string. */
const char *long_yes = _("yes");
/* TRANSLATORS: See doc/TRANSLATE about this string. */
const char *long_no = _("no");
/* TRANSLATORS: See doc/TRANSLATE about this string. */
const char *long_quit = _("quit");
const char *short_yes = _("yY");
const char *short_no = _("nN");
const char *short_quit = _("qQ");
if( match_multistr(long_no,s) )
return 0;
if( match_multistr(long_yes,s) )
return 1;
if( match_multistr(long_quit,s) )
return -1;
if( *s && strchr( short_no, *s ) && !s[1] )
return 0;
if( *s && strchr( short_yes, *s ) && !s[1] )
return 1;
if( *s && strchr( short_quit, *s ) && !s[1] )
return -1;
/* but not here */
if( !ascii_strcasecmp(s, "yes" ) )
return 1;
if( !ascii_strcasecmp(s, "quit" ) )
return -1;
if( *s && strchr( "yY", *s ) && !s[1] )
return 1;
if( *s && strchr( "qQ", *s ) && !s[1] )
return -1;
return 0;
}
| false | false | false | false | false | 0 |
doubleAverage(double cur, double new, int N, int max)
{
if (N > max)
N = max;
return (cur * (N - 1.0) + new) / N;
}
| false | false | false | false | false | 0 |
typ_type_move(GList *list, FType *type, gint delta)
{
gint pos, np;
if(delta != -1 && delta != 1)
return list;
pos = g_list_index(list, type);
list = g_list_remove(list, type);
np = pos + delta;
if(np < 0)
np = 0;
else if(np > (gint) g_list_length(list) - 1)
np = (gint) g_list_length(list) - 1;
return g_list_insert(list, type, np);
}
| false | false | false | false | false | 0 |
paint( QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index ) const
{
qint64 field = index.data( CommonModel::FieldRole ).value<qint64>();
QVariant data = index.data();
// display the icon even for label conflicts:
if( ( field == Meta::valRating || field == Meta::valLabel ) &&
data.type() == QVariant::Int )
{
// following is largely inspired by QStyledItemDelegate::paint()
QStyleOptionViewItemV4 opt = option;
initStyleOption( &opt, index );
QPixmap starsPixmap( CommonModel::s_ratingSize );
starsPixmap.fill( Qt::transparent );
{
KRatingPainter ratingPainter;
int rating = data.toInt();
int hoverRating = -1;
if( rating < 0 ) // unresolved conflict
{
rating = 0;
ratingPainter.setIcon( KIcon( "status_unknown" ) );
ratingPainter.setEnabled( false );
ratingPainter.setMaxRating( 2 );
}
QPainter starsPainter( &starsPixmap );
ratingPainter.paint( &starsPainter, QRect( QPoint( 0, 0 ),
CommonModel::s_ratingSize ), rating, hoverRating );
}
opt.text.clear();
opt.features |= QStyleOptionViewItemV2::HasDecoration;
opt.decorationSize = CommonModel::s_ratingSize;
opt.decorationAlignment = Qt::AlignRight | Qt::AlignVCenter;
opt.decorationPosition = QStyleOptionViewItem::Right;
opt.icon = QIcon( starsPixmap );
const QWidget *widget = opt.widget;
QStyle *style = widget ? widget->style() : QApplication::style();
style->drawControl( QStyle::CE_ItemViewItem, &opt, painter, widget );
}
else
QStyledItemDelegate::paint( painter, option, index );
}
| false | false | false | false | false | 0 |
archive_acl_add_entry(struct archive_acl *acl,
int type, int permset, int tag, int id, const char *name)
{
struct archive_acl_entry *ap;
if (acl_special(acl, type, permset, tag) == 0)
return ARCHIVE_OK;
ap = acl_new_entry(acl, type, permset, tag, id);
if (ap == NULL) {
/* XXX Error XXX */
return ARCHIVE_FAILED;
}
if (name != NULL && *name != '\0')
archive_mstring_copy_mbs(&ap->name, name);
else
archive_mstring_clean(&ap->name);
return ARCHIVE_OK;
}
| false | false | false | false | false | 0 |
updateFontAttr( QwtMmlAttributeMap &font_attr, const QwtMmlNode *n,
const QString &name, const QString &preferred_name = QString::null )
{
if ( font_attr.contains( preferred_name ) || font_attr.contains( name ) )
return;
QString value = n->explicitAttribute( name );
if ( !value.isNull() )
font_attr[name] = value;
}
| false | false | false | false | false | 0 |
accept(ir_hierarchical_visitor *v)
{
ir_visitor_status s = v->visit_enter(this);
if (s != visit_continue)
return (s == visit_continue_with_parent) ? visit_continue : s;
s = this->val->accept(v);
return (s == visit_stop) ? s : v->visit_leave(this);
}
| false | false | false | false | false | 0 |
isns_bitvector_free(isns_bitvector_t *bv)
{
if (bv) {
isns_free(bv->ib_words);
memset(bv, 0xa5, sizeof(*bv));
isns_free(bv);
}
}
| false | false | false | false | false | 0 |
xmms_medialib_client_get_info (xmms_medialib_t *medialib, gint32 id,
xmms_error_t *err)
{
xmms_medialib_session_t *session;
GTree *ret = NULL;
if (!id) {
xmms_error_set (err, XMMS_ERROR_NOENT, "No such entry, 0");
} else {
session = xmms_medialib_begin ();
ret = xmms_medialib_entry_to_tree (session, id);
xmms_medialib_end (session);
if (!ret) {
xmms_error_set (err, XMMS_ERROR_NOENT,
"Could not retrieve info for that entry!");
}
}
return ret;
}
| false | false | false | false | false | 0 |
hfsplus_removexattr(struct inode *inode, const char *name)
{
int err = 0;
struct hfs_find_data cat_fd;
u16 flags;
u16 cat_entry_type;
int is_xattr_acl_deleted = 0;
int is_all_xattrs_deleted = 0;
if (!HFSPLUS_SB(inode->i_sb)->attr_tree)
return -EOPNOTSUPP;
if (!strcmp_xattr_finder_info(name))
return -EOPNOTSUPP;
err = hfs_find_init(HFSPLUS_SB(inode->i_sb)->cat_tree, &cat_fd);
if (err) {
pr_err("can't init xattr find struct\n");
return err;
}
err = hfsplus_find_cat(inode->i_sb, inode->i_ino, &cat_fd);
if (err) {
pr_err("catalog searching failed\n");
goto end_removexattr;
}
err = hfsplus_delete_attr(inode, name);
if (err)
goto end_removexattr;
is_xattr_acl_deleted = !strcmp_xattr_acl(name);
is_all_xattrs_deleted = !hfsplus_attr_exists(inode, NULL);
if (!is_xattr_acl_deleted && !is_all_xattrs_deleted)
goto end_removexattr;
cat_entry_type = hfs_bnode_read_u16(cat_fd.bnode, cat_fd.entryoffset);
if (cat_entry_type == HFSPLUS_FOLDER) {
flags = hfs_bnode_read_u16(cat_fd.bnode, cat_fd.entryoffset +
offsetof(struct hfsplus_cat_folder, flags));
if (is_xattr_acl_deleted)
flags &= ~HFSPLUS_ACL_EXISTS;
if (is_all_xattrs_deleted)
flags &= ~HFSPLUS_XATTR_EXISTS;
hfs_bnode_write_u16(cat_fd.bnode, cat_fd.entryoffset +
offsetof(struct hfsplus_cat_folder, flags),
flags);
hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
} else if (cat_entry_type == HFSPLUS_FILE) {
flags = hfs_bnode_read_u16(cat_fd.bnode, cat_fd.entryoffset +
offsetof(struct hfsplus_cat_file, flags));
if (is_xattr_acl_deleted)
flags &= ~HFSPLUS_ACL_EXISTS;
if (is_all_xattrs_deleted)
flags &= ~HFSPLUS_XATTR_EXISTS;
hfs_bnode_write_u16(cat_fd.bnode, cat_fd.entryoffset +
offsetof(struct hfsplus_cat_file, flags),
flags);
hfsplus_mark_inode_dirty(inode, HFSPLUS_I_CAT_DIRTY);
} else {
pr_err("invalid catalog entry type\n");
err = -EIO;
goto end_removexattr;
}
end_removexattr:
hfs_find_exit(&cat_fd);
return err;
}
| false | false | false | false | false | 0 |
_rl_isearch_callback (cxt)
_rl_search_cxt *cxt;
{
int c, r;
c = _rl_search_getchar (cxt);
/* We might want to handle EOF here */
r = _rl_isearch_dispatch (cxt, cxt->lastc);
return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
}
| false | false | false | false | false | 0 |
mxf_ul_to_string (const MXFUL * ul, gchar str[48])
{
gchar *ret = str;
g_return_val_if_fail (ul != NULL, NULL);
if (ret == NULL)
ret = g_malloc (48);
g_snprintf (ret, 48,
"%02x.%02x.%02x.%02x."
"%02x.%02x.%02x.%02x."
"%02x.%02x.%02x.%02x."
"%02x.%02x.%02x.%02x",
ul->u[0], ul->u[1], ul->u[2], ul->u[3],
ul->u[4], ul->u[5], ul->u[6], ul->u[7],
ul->u[8], ul->u[9], ul->u[10], ul->u[11],
ul->u[12], ul->u[13], ul->u[14], ul->u[15]);
return ret;
}
| false | false | false | false | false | 0 |
snd_pcm_rate_mask_sanitize(unsigned int rates)
{
if (rates & SNDRV_PCM_RATE_CONTINUOUS)
return SNDRV_PCM_RATE_CONTINUOUS;
else if (rates & SNDRV_PCM_RATE_KNOT)
return SNDRV_PCM_RATE_KNOT;
return rates;
}
| false | false | false | false | false | 0 |
cheaderwrite(struct cheader *ch, FILE *fpout)
{
int error=0;
if(!fwrite((char *) &ch->sig, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->res1, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->size, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->res2, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->offsetfiles, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->res3, 4, 1, fpout)) error=1;
if(!fwrite((char *) &ch->versionMIN, 1, 1, fpout)) error=1;
if(!fwrite((char *) &ch->versionMAJ, 1, 1, fpout)) error=1;
if(!fwrite((char *) &ch->nfolders, 2, 1, fpout)) error=1;
if(!fwrite((char *) &ch->nfiles, 2, 1, fpout)) error=1;
if(!fwrite((char *) &ch->flags, 2, 1, fpout)) error=1;
if(!fwrite((char *) &ch->setID, 2, 1, fpout)) error=1;
if(!fwrite((char *) &ch->cabID, 2, 1, fpout)) error=1;
return !error;
}
| false | false | false | false | false | 0 |
gigolo_settings_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
{
GigoloSettingsPrivate *priv = GIGOLO_SETTINGS_GET_PRIVATE(object);
switch (prop_id)
{
case PROP_SAVE_GEOMETRY:
priv->save_geometry = g_value_get_boolean(value);
break;
case PROP_SHOW_IN_SYSTRAY:
priv->show_in_systray = g_value_get_boolean(value);
break;
case PROP_START_IN_SYSTRAY:
priv->start_in_systray = g_value_get_boolean(value);
break;
case PROP_SHOW_TOOLBAR:
priv->show_toolbar = g_value_get_boolean(value);
break;
case PROP_TOOLBAR_STYLE:
priv->toolbar_style = g_value_get_int(value);
break;
case PROP_TOOLBAR_ORIENTATION:
priv->toolbar_orientation = g_value_get_int(value);
break;
case PROP_VIEW_MODE:
priv->view_mode = g_value_get_int(value);
break;
case PROP_FILE_MANAGER:
g_free(priv->file_manager);
priv->file_manager = g_value_dup_string(value);
break;
case PROP_TERMINAL:
g_free(priv->terminal);
priv->terminal = g_value_dup_string(value);
break;
case PROP_AUTOCONNECT_INTERVAL:
priv->autoconnect_interval = g_value_get_int(value);
break;
case PROP_SHOW_PANEL:
priv->show_panel = g_value_get_boolean(value);
break;
case PROP_LAST_PANEL_PAGE:
priv->last_panel_page = g_value_get_uint(value);
break;
case PROP_PANEL_POSITION:
priv->panel_position = g_value_get_uint(value);
break;
case PROP_SHOW_AUTOCONNECT_ERRORS:
priv->show_autoconnect_errors = g_value_get_boolean(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
break;
}
}
| false | false | false | false | false | 0 |
P_Lseek(Object fd, Object off, Object whence) {
off_t ret;
if ((ret = lseek(Get_Integer(fd), (off_t)Get_Long(off),
(int)Symbols_To_Bits(whence, 0, Lseek_Syms))) == (off_t)-1)
Raise_System_Error("~E");
return Make_Unsigned_Long((unsigned long)ret);
}
| false | false | false | false | false | 0 |
qlcnic_reset_rx_buffers_list(struct qlcnic_adapter *adapter)
{
struct qlcnic_recv_context *recv_ctx;
struct qlcnic_host_rds_ring *rds_ring;
struct qlcnic_rx_buffer *rx_buf;
int i, ring;
recv_ctx = adapter->recv_ctx;
for (ring = 0; ring < adapter->max_rds_rings; ring++) {
rds_ring = &recv_ctx->rds_rings[ring];
INIT_LIST_HEAD(&rds_ring->free_list);
rx_buf = rds_ring->rx_buf_arr;
for (i = 0; i < rds_ring->num_desc; i++) {
list_add_tail(&rx_buf->list,
&rds_ring->free_list);
rx_buf++;
}
}
}
| false | false | false | false | false | 0 |
clntSupported(SPtr<TDUID> duid,SPtr<TIPv6Addr> clntAddr, SPtr<TSrvMsg> msg)
{
// is client on denied client class
SPtr<TSrvCfgClientClass> clntClass;
denyClientClassLst.first();
while(clntClass = denyClientClassLst.get())
{
if (clntClass->isStatisfy(msg))
return false;
}
// is client on accepted client class
allowClientClassLst.first();
while(clntClass = allowClientClassLst.get())
{
if (clntClass->isStatisfy(msg))
return true;
}
SPtr<TStationRange> range;
RejedClnt.first();
// is client on black list?
while(range=RejedClnt.get())
if (range->in(duid,clntAddr))
return false;
if (AcceptClnt.count()) {
AcceptClnt.first();
// there's white list
while(range=AcceptClnt.get()) {
// is client on this white list?
if (range->in(duid,clntAddr))
return true;
}
return false;
}
if (allowClientClassLst.count())
return false ;
return true;
}
| false | false | false | false | false | 0 |
GetClassCount( )
{
int iCount = 0;
GFSTemplateItem *pItem;
pItem = pFirst;
while( pItem != NULL )
{
iCount++;
pItem = pItem->GetNext();
}
return iCount;
}
| false | false | false | false | false | 0 |
opr_tbl_optype(unsigned opnum)
/*!
Return Value: type of operator if OK, -1 if Error
Parameters:
Type Name IO Description
------------ ----------- -- ----------- */
#ifdef DOC
unsigned opnum ;/* I Number of operator in table. */
#endif
/*!
Description:
`opr_tbl_optype` returns the type of an operator in the operator table:
OPTYPE_BINARY, OPTYPE_UNARY_PREFIX, OPTYPE_UNARY_POSTFIX (defined in
"ComUtil/comterp.h").
!*/
{
if( opnum < NumOperators )
return OperatorTable[opnum].optype;
else
return -1;
}
| false | false | false | false | false | 0 |
l3dss1_resume_ack(struct l3_process *pc, u_char pr, void *arg)
{
struct sk_buff *skb = arg;
int id, ret;
if ((id = l3dss1_get_channel_id(pc, skb)) > 0) {
if ((0 == id) || ((3 == id) && (0x10 == pc->para.moderate))) {
if (pc->debug & L3_DEB_WARN)
l3_debug(pc->st, "resume ack with wrong chid %x", id);
pc->para.cause = 100;
l3dss1_status_send(pc, pr, NULL);
return;
}
pc->para.bchannel = id;
} else if (1 == pc->state) {
if (pc->debug & L3_DEB_WARN)
l3_debug(pc->st, "resume ack without chid (ret %d)", id);
pc->para.cause = 96;
l3dss1_status_send(pc, pr, NULL);
return;
}
ret = check_infoelements(pc, skb, ie_RESUME_ACKNOWLEDGE);
if (ERR_IE_COMPREHENSION == ret) {
l3dss1_std_ie_err(pc, ret);
return;
}
L3DelTimer(&pc->timer);
pc->st->l3.l3l4(pc->st, CC_RESUME | CONFIRM, pc);
newl3state(pc, 10);
if (ret) /* STATUS for none mandatory IE errors after actions are taken */
l3dss1_std_ie_err(pc, ret);
}
| false | false | false | false | false | 0 |
dsgw_savelines_next( savedlines *svlp )
{
char *p;
if ( svlp->svl_current >= svlp->svl_count ) {
return( NULL );
}
p = svlp->svl_line[ svlp->svl_current ];
++svlp->svl_current;
return( p );
}
| false | false | false | false | false | 0 |
hash_pragma(expr_list_ty *elp)
{
static expr_ty *once;
trace(("hash_pragma(elp = %p)\n{\n", elp));
if (stack && !stack->pass)
goto ret;
/*
* see if it was "#pragma once"
*/
if (!once)
{
string_ty *s;
s = str_from_c("once");
once = expr_constant_new(s, curpos());
str_free(s);
}
if (elp->el_nexprs == 1 && expr_equal(elp->el_expr[0], once))
{
string_list_append_unique(&done_once, lex_cur_file());
goto ret;
}
/*
* add more pragmas here
*/
ret:
trace(("}\n"));
}
| false | false | false | false | true | 1 |
pr_parallel_section(FILE *fp, Parallel_section *pr)
{
mfprintf(fp, "%B : ", pr->layer_block);
switch (pr->para_grain) {
case COARSE_GRAIN_TASK:
fprintf(fp, " COARSE ");
put_IntSet(pr->mt_set, fp);
break;
case TARGET_LOOP_GROUP:
fprintf(fp, " TLG ");
put_IntSet(pr->mt_set, fp);
break;
case LOOP_LEVEL:
fprintf(fp, " LOOP ");
break;
case NEAR_FINE_GRAIN:
fprintf(fp, " FINE ");
break;
default:
fprintf(fp, " %d ", pr->para_grain);
break;
}
fprintf(fp, "\n");
}
| false | false | false | false | false | 0 |
_text_can_handle(struct labeller *l __attribute__((unused)),
void *buf,
uint64_t sector __attribute__((unused)))
{
struct label_header *lh = (struct label_header *) buf;
if (!strncmp((char *)lh->type, LVM2_LABEL, sizeof(lh->type)))
return 1;
return 0;
}
| false | false | false | false | false | 0 |
solve() {
#ifdef RECTANGLE_OVERLAP_LOGGING
ofstream f(LOGFILE,ios::app);
f<<"solve_inc()..."<<endl;
#endif
double lastcost,cost = bs->cost();
do {
lastcost=cost;
satisfy();
splitBlocks();
cost = bs->cost();
#ifdef RECTANGLE_OVERLAP_LOGGING
f<<" cost="<<cost<<endl;
#endif
} while(fabs(lastcost-cost)>0.0001);
}
| false | false | false | false | false | 0 |
enum_netdev_ipv6_ips(struct ib_device *ib_dev,
u8 port, struct net_device *ndev)
{
struct inet6_ifaddr *ifp;
struct inet6_dev *in6_dev;
struct sin6_list {
struct list_head list;
struct sockaddr_in6 sin6;
};
struct sin6_list *sin6_iter;
struct sin6_list *sin6_temp;
struct ib_gid_attr gid_attr = {.ndev = ndev};
LIST_HEAD(sin6_list);
if (ndev->reg_state >= NETREG_UNREGISTERING)
return;
in6_dev = in6_dev_get(ndev);
if (!in6_dev)
return;
read_lock_bh(&in6_dev->lock);
list_for_each_entry(ifp, &in6_dev->addr_list, if_list) {
struct sin6_list *entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
if (!entry) {
pr_warn("roce_gid_mgmt: couldn't allocate entry for IPv6 update\n");
continue;
}
entry->sin6.sin6_family = AF_INET6;
entry->sin6.sin6_addr = ifp->addr;
list_add_tail(&entry->list, &sin6_list);
}
read_unlock_bh(&in6_dev->lock);
in6_dev_put(in6_dev);
list_for_each_entry_safe(sin6_iter, sin6_temp, &sin6_list, list) {
union ib_gid gid;
rdma_ip2gid((struct sockaddr *)&sin6_iter->sin6, &gid);
update_gid(GID_ADD, ib_dev, port, &gid, &gid_attr);
list_del(&sin6_iter->list);
kfree(sin6_iter);
}
}
| false | false | false | false | false | 0 |
__Pyx_GetModuleGlobalName(PyObject *name) {
PyObject *result;
#if CYTHON_COMPILING_IN_CPYTHON
result = PyDict_GetItem(__pyx_d, name);
if (result) {
Py_INCREF(result);
} else {
#else
result = PyObject_GetItem(__pyx_d, name);
if (!result) {
PyErr_Clear();
#endif
result = __Pyx_GetBuiltinName(name);
}
return result;
}
| false | false | false | false | false | 0 |
mrev4(void *array, int num)
{
uint4 old;
uint4 *d;
d = (uint4 *) array;
for ( ; num > 0; --num, ++d) {
old = *d;
*d = (old & 0x000000FF) << 16;
*d = (*d | (old & 0x0000FF00)) << 8;
old >>= 8;
*d |= (old & 0x0000FF00);
old >>= 16;
*d |= (old & 0x000000FF);
}
}
| false | false | false | false | false | 0 |
cli_print_ip_range_list(struct cli_session* cs, ip_range_list_t *value, const char* name, int changeable)
{
if(cs && cs->ts && name && value && value->ranges_number && value->rs) {
const char *sc="";
if(changeable==1)
sc=" (*)";
else if(changeable==2)
sc=" (**)";
size_t i;
for(i=0;i<value->ranges_number;++i) {
if(value->rs[i].realm[0]) {
if(cs->realm[0] && strcmp(cs->realm,value->rs[i].realm)) {
continue;
} else {
myprintf(cs," %s: %s (%s)%s\n",name,value->rs[i].str,value->rs[i].realm,sc);
}
} else {
myprintf(cs," %s: %s%s\n",name,value->rs[i].str,sc);
}
}
}
}
| false | false | false | false | false | 0 |
parse_for_iter(LexState *ls, GCstr *indexname)
{
FuncState *fs = ls->fs;
ExpDesc e;
BCReg nvars = 0;
BCLine line;
BCReg base = fs->freereg + 3;
BCPos loop, loopend, exprpc = fs->pc;
FuncScope bl;
int isnext;
/* Hidden control variables. */
var_new_fixed(ls, nvars++, VARNAME_FOR_GEN);
var_new_fixed(ls, nvars++, VARNAME_FOR_STATE);
var_new_fixed(ls, nvars++, VARNAME_FOR_CTL);
/* Visible variables returned from iterator. */
var_new(ls, nvars++, indexname);
while (lex_opt(ls, ','))
var_new(ls, nvars++, lex_str(ls));
lex_check(ls, TK_in);
line = ls->linenumber;
assign_adjust(ls, 3, expr_list(ls, &e), &e);
bcreg_bump(fs, 3); /* The iterator needs another 3 slots (func + 2 args). */
isnext = (nvars <= 5 && predict_next(ls, fs, exprpc));
var_add(ls, 3); /* Hidden control variables. */
lex_check(ls, TK_do);
loop = bcemit_AJ(fs, isnext ? BC_ISNEXT : BC_JMP, base, NO_JMP);
fscope_begin(fs, &bl, 0); /* Scope for visible variables. */
var_add(ls, nvars-3);
bcreg_reserve(fs, nvars-3);
parse_block(ls);
fscope_end(fs);
/* Perform loop inversion. Loop control instructions are at the end. */
jmp_patchins(fs, loop, fs->pc);
bcemit_ABC(fs, isnext ? BC_ITERN : BC_ITERC, base, nvars-3+1, 2+1);
loopend = bcemit_AJ(fs, BC_ITERL, base, NO_JMP);
fs->bcbase[loopend-1].line = line; /* Fix line for control ins. */
fs->bcbase[loopend].line = line;
jmp_patchins(fs, loopend, loop+1);
}
| false | false | false | false | false | 0 |
get_member_status(struct call_queue *q, int max_penalty, int min_penalty, enum empty_conditions conditions)
{
struct member *member;
struct ao2_iterator mem_iter;
ao2_lock(q);
mem_iter = ao2_iterator_init(q->members, 0);
for (; (member = ao2_iterator_next(&mem_iter)); ao2_ref(member, -1)) {
if ((max_penalty && (member->penalty > max_penalty)) || (min_penalty && (member->penalty < min_penalty))) {
if (conditions & QUEUE_EMPTY_PENALTY) {
ast_debug(4, "%s is unavailable because his penalty is not between %d and %d\n", member->membername, min_penalty, max_penalty);
continue;
}
}
switch (member->status) {
case AST_DEVICE_INVALID:
if (conditions & QUEUE_EMPTY_INVALID) {
ast_debug(4, "%s is unavailable because his device state is 'invalid'\n", member->membername);
break;
}
goto default_case;
case AST_DEVICE_UNAVAILABLE:
if (conditions & QUEUE_EMPTY_UNAVAILABLE) {
ast_debug(4, "%s is unavailable because his device state is 'unavailable'\n", member->membername);
break;
}
goto default_case;
case AST_DEVICE_INUSE:
if (conditions & QUEUE_EMPTY_INUSE) {
ast_debug(4, "%s is unavailable because his device state is 'inuse'\n", member->membername);
break;
}
goto default_case;
case AST_DEVICE_RINGING:
if (conditions & QUEUE_EMPTY_RINGING) {
ast_debug(4, "%s is unavailable because his device state is 'ringing'\n", member->membername);
break;
}
goto default_case;
case AST_DEVICE_UNKNOWN:
if (conditions & QUEUE_EMPTY_UNKNOWN) {
ast_debug(4, "%s is unavailable because his device state is 'unknown'\n", member->membername);
break;
}
/* Fall-through */
default:
default_case:
if (member->paused && (conditions & QUEUE_EMPTY_PAUSED)) {
ast_debug(4, "%s is unavailable because he is paused'\n", member->membername);
break;
} else if ((conditions & QUEUE_EMPTY_WRAPUP) && member->lastcall && q->wrapuptime && (time(NULL) - q->wrapuptime < member->lastcall)) {
ast_debug(4, "%s is unavailable because it has only been %d seconds since his last call (wrapup time is %d)\n", member->membername, (int) (time(NULL) - member->lastcall), q->wrapuptime);
break;
} else {
ao2_ref(member, -1);
ao2_iterator_destroy(&mem_iter);
ao2_unlock(q);
ast_debug(4, "%s is available.\n", member->membername);
return 0;
}
break;
}
}
ao2_iterator_destroy(&mem_iter);
ao2_unlock(q);
return -1;
}
| true | true | false | false | false | 1 |
diodon_clipboard_menu_remove_clipboard_item (DiodonClipboardMenu* self, DiodonIClipboardItem* item) {
DiodonClipboardMenuItem* menu_item = NULL;
GeeMap* _tmp0_ = NULL;
DiodonIClipboardItem* _tmp1_ = NULL;
gpointer _tmp2_ = NULL;
DiodonClipboardMenuItem* _tmp3_ = NULL;
DiodonClipboardMenuItem* _tmp4_ = NULL;
menu_item = NULL;
_tmp0_ = self->priv->clipboard_menu_items;
_tmp1_ = item;
gee_map_unset (_tmp0_, _tmp1_, &_tmp2_);
_g_object_unref0 (menu_item);
menu_item = _tmp2_;
_tmp3_ = menu_item;
gtk_container_remove ((GtkContainer*) self, (GtkWidget*) _tmp3_);
_tmp4_ = menu_item;
gtk_widget_destroy ((GtkWidget*) _tmp4_);
_g_object_unref0 (menu_item);
}
| false | false | false | false | false | 0 |
i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver)
{
const unsigned short *address_list;
struct i2c_client *temp_client;
int i, err = 0;
int adap_id = i2c_adapter_id(adapter);
address_list = driver->address_list;
if (!driver->detect || !address_list)
return 0;
/* Warn that the adapter lost class based instantiation */
if (adapter->class == I2C_CLASS_DEPRECATED) {
dev_dbg(&adapter->dev,
"This adapter dropped support for I2C classes and "
"won't auto-detect %s devices anymore. If you need it, check "
"'Documentation/i2c/instantiating-devices' for alternatives.\n",
driver->driver.name);
return 0;
}
/* Stop here if the classes do not match */
if (!(adapter->class & driver->class))
return 0;
/* Set up a temporary client to help detect callback */
temp_client = kzalloc(sizeof(struct i2c_client), GFP_KERNEL);
if (!temp_client)
return -ENOMEM;
temp_client->adapter = adapter;
for (i = 0; address_list[i] != I2C_CLIENT_END; i += 1) {
dev_dbg(&adapter->dev, "found normal entry for adapter %d, "
"addr 0x%02x\n", adap_id, address_list[i]);
temp_client->addr = address_list[i];
err = i2c_detect_address(temp_client, driver);
if (unlikely(err))
break;
}
kfree(temp_client);
return err;
}
| false | false | false | false | false | 0 |
inf_text_gtk_view_user_line_position_cmp(gconstpointer first,
gconstpointer second)
{
const InfTextGtkViewUser* first_user;
const InfTextGtkViewUser* second_user;
first_user = (const InfTextGtkViewUser*)first;
second_user = (const InfTextGtkViewUser*)second;
if(second_user->line_y < first_user->line_y)
return 1;
else if(second_user->line_y > first_user->line_y)
return -1;
return 0;
}
| false | false | false | false | false | 0 |
open_tcp_socket(ares_channel channel, struct server_state *server)
{
ares_socket_t s;
int opt;
ares_socklen_t salen;
union {
struct sockaddr_in sa4;
struct sockaddr_in6 sa6;
} saddr;
struct sockaddr *sa;
switch (server->addr.family)
{
case AF_INET:
sa = (void *)&saddr.sa4;
salen = sizeof(saddr.sa4);
memset(sa, 0, salen);
saddr.sa4.sin_family = AF_INET;
saddr.sa4.sin_port = (unsigned short)(channel->tcp_port & 0xffff);
memcpy(&saddr.sa4.sin_addr, &server->addr.addrV4,
sizeof(server->addr.addrV4));
break;
case AF_INET6:
sa = (void *)&saddr.sa6;
salen = sizeof(saddr.sa6);
memset(sa, 0, salen);
saddr.sa6.sin6_family = AF_INET6;
saddr.sa6.sin6_port = (unsigned short)(channel->tcp_port & 0xffff);
memcpy(&saddr.sa6.sin6_addr, &server->addr.addrV6,
sizeof(server->addr.addrV6));
break;
default:
return -1;
}
/* Acquire a socket. */
s = socket(server->addr.family, SOCK_STREAM, 0);
if (s == ARES_SOCKET_BAD)
return -1;
/* Configure it. */
if (configure_socket(s, channel) < 0)
{
sclose(s);
return -1;
}
#ifdef TCP_NODELAY
/*
* Disable the Nagle algorithm (only relevant for TCP sockets, and thus not
* in configure_socket). In general, in DNS lookups we're pretty much
* interested in firing off a single request and then waiting for a reply,
* so batching isn't very interesting in general.
*/
opt = 1;
if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
(void *)&opt, sizeof(opt)) == -1)
{
sclose(s);
return -1;
}
#endif
/* Connect to the server. */
if (connect(s, sa, salen) == -1)
{
int err = SOCKERRNO;
if (err != EINPROGRESS && err != EWOULDBLOCK)
{
sclose(s);
return -1;
}
}
if (channel->sock_create_cb)
{
int err = channel->sock_create_cb(s, SOCK_STREAM,
channel->sock_create_cb_data);
if (err < 0)
{
sclose(s);
return err;
}
}
SOCK_STATE_CALLBACK(channel, s, 1, 0);
server->tcp_buffer_pos = 0;
server->tcp_socket = s;
server->tcp_connection_generation = ++channel->tcp_connection_generation;
return 0;
}
| false | false | false | false | false | 0 |
totem_pl_parser_read_ini_line_string_with_sep (char **lines, const char *key,
const char *sep)
{
char *retval = NULL;
int i;
if (lines == NULL || key == NULL)
return NULL;
for (i = 0; (lines[i] != NULL && retval == NULL); i++) {
char *line = lines[i];
while (*line == '\t' || *line == ' ')
line++;
if (g_ascii_strncasecmp (line, key, strlen (key)) == 0) {
char **bits;
bits = g_strsplit (line, sep, 2);
if (bits[0] == NULL || bits [1] == NULL) {
g_strfreev (bits);
return NULL;
}
retval = g_strdup (bits[1]);
g_strfreev (bits);
}
}
return retval;
}
| false | false | false | false | false | 0 |
strncpy(char* dest, const char* src, size_t n) {
unsigned int len = strlen(src);
char * ret = memcpy(dest, src, len);
if(n > len) {
memcpy(dest + len, 0, n - len);
}
return ret;
}
| false | false | false | false | true | 1 |
test_gvariant (const void *_subject)
{
const gchar *subject = (const gchar *) _subject;
PolkitIdentity *identity, *new_identity;
GError *error = NULL;
GVariant *value;
/* Create the subject from a string */
identity = polkit_identity_from_string (subject, &error);
g_assert_no_error (error);
g_assert (identity);
/* Create a GVariant for the subject */
value = polkit_identity_to_gvariant (identity);
g_assert (value);
/* Unserialize the subject */
new_identity = polkit_identity_new_for_gvariant (value, &error);
g_assert_no_error (error);
g_assert (new_identity);
g_variant_unref (value);
/* Make sure the two identities are equal */
g_assert (new_identity);
g_assert (polkit_identity_equal (identity, new_identity));
g_object_unref (identity);
g_object_unref (new_identity);
}
| false | false | false | false | false | 0 |
standingOrdersClicked() {
m_shipCountEdit->setFocus();
if(m_standingOrder->checkState() == Qt::Checked)
m_shipValidator->setTop(INT_MAX);
else
m_shipValidator->setTop(sourcePlanet->fleet().shipCount());
}
| false | false | false | false | false | 0 |
inline_filter_reset (CamelMimeFilter *filter)
{
EMailInlineFilter *emif = E_MAIL_INLINE_FILTER (filter);
GSList *l;
l = emif->parts;
while (l) {
GSList *n = l->next;
g_object_unref (l->data);
g_slist_free_1 (l);
l = n;
}
emif->parts = NULL;
g_byte_array_set_size (emif->data, 0);
emif->found_any = FALSE;
}
| false | false | false | false | false | 0 |
RP_CanHandleURL(GF_InputService *plug, const char *url)
{
char *sExt;
if (!plug || !url)
return 0;
sExt = strrchr(url, '.');
if (sExt && gf_term_check_extension(plug, sdp_mime, sdp_exts, sdp_desc, sExt)) return 1;
/*local */
if (strstr(url, "data:application/sdp")) return 1;
/*embedded data*/
if (strstr(url, "data:application/mpeg4-od-au;base64") ||
strstr(url, "data:application/mpeg4-bifs-au;base64") ||
strstr(url, "data:application/mpeg4-es-au;base64")) return 1;
/*we need rtsp/tcp , rtsp/udp or direct RTP sender (no control)*/
if (!strnicmp(url, "rtsp://", 7) || !strnicmp(url, "rtspu://", 8) || !strnicmp(url, "rtp://", 6)) return 1;
/*we don't check extensions*/
return 0;
}
| false | false | false | false | false | 0 |
tomoyo_encode2(const char *str, int str_len)
{
int i;
int len = 0;
const char *p = str;
char *cp;
char *cp0;
if (!p)
return NULL;
for (i = 0; i < str_len; i++) {
const unsigned char c = p[i];
if (c == '\\')
len += 2;
else if (c > ' ' && c < 127)
len++;
else
len += 4;
}
len++;
/* Reserve space for appending "/". */
cp = kzalloc(len + 10, GFP_NOFS);
if (!cp)
return NULL;
cp0 = cp;
p = str;
for (i = 0; i < str_len; i++) {
const unsigned char c = p[i];
if (c == '\\') {
*cp++ = '\\';
*cp++ = '\\';
} else if (c > ' ' && c < 127) {
*cp++ = c;
} else {
*cp++ = '\\';
*cp++ = (c >> 6) + '0';
*cp++ = ((c >> 3) & 7) + '0';
*cp++ = (c & 7) + '0';
}
}
return cp0;
}
| false | false | false | false | false | 0 |
finishGreet()
{
int ret;
if (grtproc.pid > 0) {
gSet(&grttalk);
gSendInt(V_OK);
if ((ret = closeGreeter(False)) != EX_NORMAL) {
logError("Abnormal greeter termination, code %d, sig %d\n",
wcCode(ret), wcSig(ret));
sessionExit(EX_RESERVER_DPY);
}
}
}
| false | false | false | false | false | 0 |
ui_common_init_dialog_response_cb (GtkDialog * dialog, gint response_id, gpointer data) {
gint return_val;
switch(response_id) {
case AMITK_RESPONSE_EXECUTE:
case GTK_RESPONSE_CLOSE:
g_signal_emit_by_name(G_OBJECT(dialog), "delete_event", NULL, &return_val);
if (!return_val) gtk_widget_destroy(GTK_WIDGET(dialog));
break;
default:
break;
}
return;
}
| false | false | false | false | false | 0 |
copy_all_sub_arg_operand(Operand *opt)
{
Operand *npt = NULL, *opt_head = NULL;
int i;
opt_head = opt;
while (opt != NULL) {
if(npt == NULL) {
npt = alloc_operand();
opt_head = npt;
}
npt->kind = opt->kind;
npt->entry = opt->entry;
npt->nsub = opt->nsub;
if ((npt->sub = calloc(opt->nsub, sizeof(Sub_data*))) == NULL) {
fatal("No room for Sub_data.\n");
}
switch (opt->kind) {
case KIND_VAR:
npt->tbl.v = opt->tbl.v;
break;
case KIND_ARRAY:
npt->tbl.a = copy_partial_array_table(opt->tbl.a,opt->entry);
break;
case KIND_CONST:
npt->tbl.c = opt->tbl.c;
break;
default:
npt->tbl.v = NULL;
}
for (i = 0; i < opt->nsub; i++) {
if (opt->sub[i] != NULL)
npt->sub[i] = copy_all_sub_data(opt->sub[i]);
}
npt->inner = copy_operand_list(opt->inner);
if(opt->next != NULL) {
npt->next = alloc_operand();
npt = npt->next;
}
opt = opt->next;
}
npt = opt_head;
return npt;
}
| false | false | false | false | false | 0 |
interval_tree_delete_fixup(GtIntervalTree *it,
GtIntervalTreeNode *x)
{
GtIntervalTreeNode *w;
while ((x->color == BLACK) && (it->root != x)) {
if (x == x->parent->left) {
w = x->parent->right;
if (w->color == RED) {
w->color = BLACK;
x->parent->color = RED;
interval_tree_left_rotate(it, &it->root, x->parent);
w = x->parent->right;
}
if ( (w->right->color == BLACK) && (w->left->color == BLACK) ) {
w->color = RED;
x = x->parent;
} else {
if (w->right->color == BLACK) {
w->left->color = BLACK;
w->color = RED;
interval_tree_right_rotate(it, &it->root, w);
w = x->parent->right;
}
w->color = x->parent->color;
x->parent->color = BLACK;
w->right->color = BLACK;
interval_tree_left_rotate(it, &it->root, x->parent);
x = it->root;
}
} else {
w = x->parent->left;
if (w->color == RED) {
w->color = BLACK;
x->parent->color = RED;
interval_tree_right_rotate(it, &it->root, x->parent);
w=x->parent->left;
}
if ( (w->right->color == BLACK) && (w->left->color == BLACK) ) {
w->color = RED;
x = x->parent;
} else {
if (w->left->color == BLACK) {
w->right->color = BLACK;
w->color = RED;
interval_tree_left_rotate(it, &it->root, w);
w=x->parent->left;
}
w->color = x->parent->color;
x->parent->color = BLACK;
w->left->color = BLACK;
interval_tree_right_rotate(it, &it->root, x->parent);
x = it->root;
}
}
}
x->color = BLACK;
}
| false | false | false | false | false | 0 |
delete_symbols(symbol * root, int level, int delete_labels,
int delete_functions)
{
symbol *sym;
/* erase only the symbols with a deeper nesting level than the
* specified nesting level */
while (root->next)
{
sym = root->next;
if (sym->compound < level)
break;
if ((delete_labels || sym->ident != iLABEL)
&& (delete_functions || sym->ident != iFUNCTN
|| (sym->usage & uNATIVE) != 0) && (delete_functions
|| sym->ident != iCONSTEXPR
|| (sym->usage & uPREDEF) ==
0) && (delete_functions
|| (sym->ident !=
iVARIABLE
&& sym->ident !=
iARRAY)))
{
root->next = sym->next;
free_symbol(sym);
}
else
{
/* if the function was prototyped, but not implemented in this source,
* mark it as such, so that its use can be flagged
*/
if (sym->ident == iFUNCTN && (sym->usage & uDEFINE) == 0)
sym->usage |= uMISSING;
if (sym->ident == iFUNCTN || sym->ident == iVARIABLE
|| sym->ident == iARRAY)
sym->usage &= ~uDEFINE; /* clear "defined" flag */
/* for user defined operators, also remove the "prototyped" flag, as
* user-defined operators *must* be declared before use
*/
if (sym->ident == iFUNCTN && !sc_isalpha(*sym->name)
&& *sym->name != '_' && *sym->name != PUBLIC_CHAR)
sym->usage &= ~uPROTOTYPED;
root = sym; /* skip the symbol */
} /* if */
} /* if */
}
| false | false | false | false | false | 0 |
pre_task_out_intr(ide_drive_t *drive,
struct ide_cmd *cmd)
{
ide_startstop_t startstop;
if (ide_wait_stat(&startstop, drive, ATA_DRQ,
drive->bad_wstat, WAIT_DRQ)) {
pr_err("%s: no DRQ after issuing %sWRITE%s\n", drive->name,
(cmd->tf_flags & IDE_TFLAG_MULTI_PIO) ? "MULT" : "",
(drive->dev_flags & IDE_DFLAG_LBA48) ? "_EXT" : "");
return startstop;
}
if ((drive->dev_flags & IDE_DFLAG_UNMASK) == 0)
local_irq_disable();
ide_set_handler(drive, &task_pio_intr, WAIT_WORSTCASE);
ide_pio_datablock(drive, cmd, 1);
return ide_started;
}
| false | false | false | false | false | 0 |
main(int argc,
char **argv)
{
l_int32 d;
PIX *pixs, *pixc, *pixr, *pixg, *pixb, *pixsg, *pixsm, *pixd;
PIXA *pixa;
static char mainName[] = "livre_adapt";
if (argc != 1)
return ERROR_INT(" Syntax: livre_adapt", mainName, 1);
/* Read the image in at 150 ppi. */
pixDisplayWrite(NULL, -1);
if ((pixs = pixRead("brothers.150.jpg")) == NULL)
return ERROR_INT("pix not made", mainName, 1);
pixDisplayWriteFormat(pixs, 2, IFF_JFIF_JPEG);
/* Normalize for uneven illumination on RGB image */
pixBackgroundNormRGBArraysMorph(pixs, NULL, 4, 5, 200,
&pixr, &pixg, &pixb);
pixd = pixApplyInvBackgroundRGBMap(pixs, pixr, pixg, pixb, 4, 4);
pixDisplayWriteFormat(pixd, 2, IFF_JFIF_JPEG);
pixDestroy(&pixr);
pixDestroy(&pixg);
pixDestroy(&pixb);
pixDestroy(&pixd);
/* Convert the RGB image to grayscale. */
pixsg = pixConvertRGBToLuminance(pixs);
pixDisplayWriteFormat(pixsg, 2, IFF_JFIF_JPEG);
/* Remove the text in the fg. */
pixc = pixCloseGray(pixsg, 25, 25);
pixDisplayWriteFormat(pixc, 2, IFF_JFIF_JPEG);
/* Smooth the bg with a convolution. */
pixsm = pixBlockconv(pixc, 15, 15);
pixDisplayWriteFormat(pixsm, 2, IFF_JFIF_JPEG);
pixDestroy(&pixc);
/* Normalize for uneven illumination on gray image. */
pixBackgroundNormGrayArrayMorph(pixsg, NULL, 4, 5, 200, &pixg);
pixc = pixApplyInvBackgroundGrayMap(pixsg, pixg, 4, 4);
pixDisplayWriteFormat(pixc, 2, IFF_JFIF_JPEG);
pixDestroy(&pixg);
/* Increase the dynamic range. */
pixd = pixGammaTRC(NULL, pixc, 1.0, 30, 180);
pixDisplayWriteFormat(pixd, 2, IFF_JFIF_JPEG);
pixDestroy(&pixc);
/* Threshold to 1 bpp. */
pixb = pixThresholdToBinary(pixd, 120);
pixDisplayWriteFormat(pixb, 2, IFF_PNG);
pixDestroy(&pixd);
pixDestroy(&pixb);
/* Generate the output image */
pixa = pixaReadFiles("/tmp/display", "file");
pixd = pixaDisplayTiledAndScaled(pixa, 8, 350, 4, 0, 25, 2);
pixWrite("/tmp/adapt.jpg", pixd, IFF_JFIF_JPEG);
pixDisplayWithTitle(pixd, 100, 100, NULL, 1);
pixDestroy(&pixd);
pixDestroy(&pixs);
pixDestroy(&pixsg);
return 0;
}
| false | false | false | false | false | 0 |
EnterScope(MachineBasicBlock *MBB) {
DEBUG(dbgs() << "Entering: " << MBB->getName() << '\n');
ScopeType *Scope = new ScopeType(VNT);
ScopeMap[MBB] = Scope;
}
| false | false | false | false | false | 0 |
handle_vendor_event(struct xhci_hcd *xhci,
union xhci_trb *event)
{
u32 trb_type;
trb_type = TRB_FIELD_TO_TYPE(le32_to_cpu(event->generic.field[3]));
xhci_dbg(xhci, "Vendor specific event TRB type = %u\n", trb_type);
if (trb_type == TRB_NEC_CMD_COMP && (xhci->quirks & XHCI_NEC_HOST))
handle_cmd_completion(xhci, &event->event_cmd);
}
| false | false | false | false | false | 0 |
findMatchingBlock(fl_BlockLayout * pBlock)
{
TOCEntry * pThisEntry = NULL;
fl_BlockLayout * pThisBL = NULL;
UT_sint32 i = 0;
bool bFound = false;
for(i=0; i< m_vecEntries.getItemCount(); i++)
{
pThisEntry = m_vecEntries.getNthItem(i);
pThisBL = pThisEntry->getBlock();
if(pThisBL->getStruxDocHandle() == pBlock->getStruxDocHandle())
{
bFound = true;
break;
}
}
if(bFound)
{
return pThisBL;
}
return NULL;
}
| false | false | false | false | false | 0 |
numbits(uchar *buf)
{
int byte,ct;
uchar bit;
for(ct=byte=0;byte<len;byte++)
for(bit=1;bit;bit=bit<<1)
ct+=(buf[byte]&bit?1:0);
return(ct);
}
| false | false | false | false | false | 0 |
i915_gem_obj_bound_any(struct drm_i915_gem_object *o)
{
struct i915_vma *vma;
list_for_each_entry(vma, &o->vma_list, obj_link)
if (drm_mm_node_allocated(&vma->node))
return true;
return false;
}
| false | false | false | false | false | 0 |
WaitOnLock(LOCALLOCK *locallock, ResourceOwner owner)
{
LOCKMETHODID lockmethodid = LOCALLOCK_LOCKMETHOD(*locallock);
LockMethod lockMethodTable = LockMethods[lockmethodid];
char *volatile new_status = NULL;
LOCK_PRINT("WaitOnLock: sleeping on lock",
locallock->lock, locallock->tag.mode);
/* Report change to waiting status */
if (update_process_title)
{
const char *old_status;
int len;
old_status = get_ps_display(&len);
new_status = (char *) palloc(len + 8 + 1);
memcpy(new_status, old_status, len);
strcpy(new_status + len, " waiting");
set_ps_display(new_status, false);
new_status[len] = '\0'; /* truncate off " waiting" */
}
pgstat_report_waiting(true);
awaitedLock = locallock;
awaitedOwner = owner;
/*
* NOTE: Think not to put any shared-state cleanup after the call to
* ProcSleep, in either the normal or failure path. The lock state must
* be fully set by the lock grantor, or by CheckDeadLock if we give up
* waiting for the lock. This is necessary because of the possibility
* that a cancel/die interrupt will interrupt ProcSleep after someone else
* grants us the lock, but before we've noticed it. Hence, after granting,
* the locktable state must fully reflect the fact that we own the lock;
* we can't do additional work on return.
*
* We can and do use a PG_TRY block to try to clean up after failure, but
* this still has a major limitation: elog(FATAL) can occur while waiting
* (eg, a "die" interrupt), and then control won't come back here. So all
* cleanup of essential state should happen in LockWaitCancel, not here.
* We can use PG_TRY to clear the "waiting" status flags, since doing that
* is unimportant if the process exits.
*/
PG_TRY();
{
if (ProcSleep(locallock, lockMethodTable) != STATUS_OK)
{
/*
* We failed as a result of a deadlock, see CheckDeadLock(). Quit
* now.
*/
awaitedLock = NULL;
LOCK_PRINT("WaitOnLock: aborting on lock",
locallock->lock, locallock->tag.mode);
LWLockRelease(LockHashPartitionLock(locallock->hashcode));
/*
* Now that we aren't holding the partition lock, we can give an
* error report including details about the detected deadlock.
*/
DeadLockReport();
/* not reached */
}
}
PG_CATCH();
{
/* In this path, awaitedLock remains set until LockWaitCancel */
/* Report change to non-waiting status */
pgstat_report_waiting(false);
if (update_process_title)
{
set_ps_display(new_status, false);
pfree(new_status);
}
/* and propagate the error */
PG_RE_THROW();
}
PG_END_TRY();
awaitedLock = NULL;
/* Report change to non-waiting status */
pgstat_report_waiting(false);
if (update_process_title)
{
set_ps_display(new_status, false);
pfree(new_status);
}
LOCK_PRINT("WaitOnLock: wakeup on lock",
locallock->lock, locallock->tag.mode);
}
| false | true | false | false | false | 1 |
________lambda7_ (Block2Data* _data2_, GObject* obj, GAsyncResult* res) {
Example * self;
FILE* _tmp5_;
const gchar* _tmp6_;
GError * _inner_error_ = NULL;
self = _data2_->self;
g_return_if_fail (res != NULL);
{
FriendsDispatcher* _tmp0_;
GAsyncResult* _tmp1_;
gchar* _tmp2_ = NULL;
_tmp0_ = self->dispatcher;
_tmp1_ = res;
friends_dispatcher_send_message_finish (_tmp0_, _tmp1_, &_tmp2_, &_inner_error_);
_g_free0 (_data2_->_result_);
_data2_->_result_ = _tmp2_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_IO_ERROR) {
goto __catch8_g_io_error;
}
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
goto __finally8;
__catch8_g_io_error:
{
GError* e = NULL;
GError* _tmp3_;
const gchar* _tmp4_;
e = _inner_error_;
_inner_error_ = NULL;
_tmp3_ = e;
_tmp4_ = _tmp3_->message;
g_warning ("example-vala.vala:217: %s", _tmp4_);
_g_error_free0 (e);
}
__finally8:
if (_inner_error_ != NULL) {
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
_tmp5_ = stdout;
_tmp6_ = _data2_->_result_;
fprintf (_tmp5_, "Sent: %s\n", _tmp6_);
self->waiting = FALSE;
}
| false | false | false | false | false | 0 |
update_theme_from_controls (GthContactSheetThemeDialog *self)
{
self->priv->theme->display_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("name_entry"))));
/* background */
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("solid_color_radiobutton")))) {
self->priv->theme->background_type = GTH_CONTACT_SHEET_BACKGROUND_TYPE_SOLID;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("solid_color_colorpicker")), &self->priv->theme->background_color1);
}
else {
gboolean h_gradient_active = FALSE;
gboolean v_gradient_active = FALSE;
h_gradient_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("h_gradient_checkbutton")));
v_gradient_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("v_gradient_checkbutton")));
if (h_gradient_active && v_gradient_active) {
self->priv->theme->background_type = GTH_CONTACT_SHEET_BACKGROUND_TYPE_FULL;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_1_colorpicker")), &self->priv->theme->background_color1);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_2_colorpicker")), &self->priv->theme->background_color2);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &self->priv->theme->background_color3);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &self->priv->theme->background_color4);
}
else if (h_gradient_active) {
self->priv->theme->background_type = GTH_CONTACT_SHEET_BACKGROUND_TYPE_HORIZONTAL;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_1_colorpicker")), &self->priv->theme->background_color1);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("h_gradient_2_colorpicker")), &self->priv->theme->background_color2);
}
else if (v_gradient_active) {
self->priv->theme->background_type = GTH_CONTACT_SHEET_BACKGROUND_TYPE_VERTICAL;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_1_colorpicker")), &self->priv->theme->background_color1);
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("v_gradient_2_colorpicker")), &self->priv->theme->background_color2);
}
}
/* frame */
self->priv->theme->frame_style = gtk_combo_box_get_active (GTK_COMBO_BOX (GET_WIDGET ("frame_style_combobox")));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("frame_colorpicker")), &self->priv->theme->frame_color);
/* header */
self->priv->theme->header_font_name = g_strdup (gtk_font_button_get_font_name (GTK_FONT_BUTTON (GET_WIDGET ("header_fontpicker"))));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("header_colorpicker")), &self->priv->theme->header_color);
/* footer */
self->priv->theme->footer_font_name = g_strdup (gtk_font_button_get_font_name (GTK_FONT_BUTTON (GET_WIDGET ("footer_fontpicker"))));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("footer_colorpicker")), &self->priv->theme->footer_color);
/* caption */
self->priv->theme->caption_font_name = g_strdup (gtk_font_button_get_font_name (GTK_FONT_BUTTON (GET_WIDGET ("caption_fontpicker"))));
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (GET_WIDGET ("caption_colorpicker")), &self->priv->theme->caption_color);
}
| false | false | false | false | false | 0 |
AWTC_baseMatch(char c1, char c2) // c1,c2 == ACGUTRS...
// returns 0 for equal
// 1 for probably mutations
// 2 for improbably mutations
// -1 if one char is illegal
{
const char *p1 = strchr(nucleic_acid_order, c1);
const char *p2 = strchr(nucleic_acid_order, c2);
awtc_assert(c1);
awtc_assert(c2);
if (p1 && p2) return baseCmp(p1-nucleic_acid_order, p2-nucleic_acid_order);
return -1;
}
| false | false | false | false | false | 0 |
virt_rename(const char *path, const char *newpath)
{
int res;
ventry *ve;
ventry *newve;
int errno_save = errno;
res = av_get_ventry(path, 0, &ve);
if(res == 0) {
res = av_get_ventry(newpath, 0, &newve);
if(res == 0) {
res = av_rename(ve, newve);
av_free_ventry(newve);
}
av_free_ventry(ve);
}
if(res < 0) {
errno = -res;
return -1;
}
errno = errno_save;
return 0;
}
| false | false | false | false | false | 0 |
sh_vou_set_fmt_vid_out(struct sh_vou_device *vou_dev,
struct v4l2_pix_format *pix)
{
unsigned int img_height_max;
struct sh_vou_geometry geo;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
/* Revisit: is this the correct code? */
.format.code = MEDIA_BUS_FMT_YUYV8_2X8,
.format.field = V4L2_FIELD_INTERLACED,
.format.colorspace = V4L2_COLORSPACE_SMPTE170M,
};
struct v4l2_mbus_framefmt *mbfmt = &format.format;
int pix_idx;
int ret;
if (vb2_is_busy(&vou_dev->queue))
return -EBUSY;
for (pix_idx = 0; pix_idx < ARRAY_SIZE(vou_fmt); pix_idx++)
if (vou_fmt[pix_idx].pfmt == pix->pixelformat)
break;
geo.in_width = pix->width;
geo.in_height = pix->height;
geo.output = vou_dev->rect;
vou_adjust_output(&geo, vou_dev->std);
mbfmt->width = geo.output.width;
mbfmt->height = geo.output.height;
ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, pad,
set_fmt, NULL, &format);
/* Must be implemented, so, don't check for -ENOIOCTLCMD */
if (ret < 0)
return ret;
dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__,
geo.output.width, geo.output.height, mbfmt->width, mbfmt->height);
if (vou_dev->std & V4L2_STD_525_60)
img_height_max = 480;
else
img_height_max = 576;
/* Sanity checks */
if ((unsigned)mbfmt->width > VOU_MAX_IMAGE_WIDTH ||
(unsigned)mbfmt->height > img_height_max ||
mbfmt->code != MEDIA_BUS_FMT_YUYV8_2X8)
return -EIO;
if (mbfmt->width != geo.output.width ||
mbfmt->height != geo.output.height) {
geo.output.width = mbfmt->width;
geo.output.height = mbfmt->height;
vou_adjust_input(&geo, vou_dev->std);
}
/* We tried to preserve output rectangle, but it could have changed */
vou_dev->rect = geo.output;
pix->width = geo.in_width;
pix->height = geo.in_height;
dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u\n", __func__,
pix->width, pix->height);
vou_dev->pix_idx = pix_idx;
vou_dev->pix = *pix;
sh_vou_configure_geometry(vou_dev, pix_idx,
geo.scale_idx_h, geo.scale_idx_v);
return 0;
}
| false | false | false | false | false | 0 |
find_type_valid (GnmValue const *find)
{
/* Excel does not lookup errors or blanks */
if (VALUE_IS_EMPTY (find))
return FALSE;
return VALUE_IS_NUMBER (find) || VALUE_IS_STRING (find);
}
| false | false | false | false | false | 0 |
P_Getenv(Object e) {
extern char *getenv();
char *s;
return (s = getenv(Get_String(e))) ? Make_String(s, strlen(s)) : False;
}
| false | false | false | false | false | 0 |
cache_enumerate(struct mapent_cache *mc, struct mapent *me)
{
if (!me)
return cache_lookup_first(mc);
return cache_lookup_next(mc, me);
}
| false | false | false | false | false | 0 |
vector_bitwise_and_op(
vector* tgt, /*!< Target vector for operation results to be stored */
vector* src1, /*!< Source vector 1 to perform operation on */
vector* src2 /*!< Source vector 2 to perform operation on */
) { PROFILE(VECTOR_BITWISE_AND_OP);
bool retval; /* Return value for this function */
switch( tgt->suppl.part.data_type ) {
case VDATA_UL :
{
ulong scratchl[UL_DIV(MAX_BIT_WIDTH)];
ulong scratchh[UL_DIV(MAX_BIT_WIDTH)];
unsigned int src1_size = UL_SIZE(src1->width);
unsigned int src2_size = UL_SIZE(src2->width);
unsigned int i;
for( i=0; i<UL_SIZE(tgt->width); i++ ) {
ulong* entry1 = src1->value.ul[i];
ulong* entry2 = src2->value.ul[i];
ulong val1_l = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALL] : 0;
ulong val1_h = (i<src1_size) ? entry1[VTYPE_INDEX_VAL_VALH] : 0;
ulong val2_l = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALL] : 0;
ulong val2_h = (i<src2_size) ? entry2[VTYPE_INDEX_VAL_VALH] : 0;
scratchl[i] = ~(val1_h | val2_h) & (val1_l & val2_l);
scratchh[i] = (val1_h & val2_h) | (val1_h & val2_l) | (val2_h & val1_l);
}
retval = vector_set_coverage_and_assign_ulong( tgt, scratchl, scratchh, 0, (tgt->width - 1) );
}
break;
default : assert( 0 ); break;
}
PROFILE_END;
return( retval );
}
| false | false | false | false | true | 1 |
ns_socketpair(sock_t sp[2]) {
struct sockaddr_in sa;
sock_t sock;
socklen_t len = sizeof(sa);
int ret = 0;
sp[0] = sp[1] = INVALID_SOCKET;
(void) memset(&sa, 0, sizeof(sa));
sa.sin_family = AF_INET;
sa.sin_port = htons(0);
sa.sin_addr.s_addr = htonl(0x7f000001);
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) != INVALID_SOCKET &&
!bind(sock, (struct sockaddr *) &sa, len) &&
!listen(sock, 1) &&
!getsockname(sock, (struct sockaddr *) &sa, &len) &&
(sp[0] = socket(AF_INET, SOCK_STREAM, 6)) != -1 &&
!connect(sp[0], (struct sockaddr *) &sa, len) &&
(sp[1] = accept(sock,(struct sockaddr *) &sa, &len)) != INVALID_SOCKET) {
ns_set_close_on_exec(sp[0]);
ns_set_close_on_exec(sp[1]);
ret = 1;
} else {
if (sp[0] != INVALID_SOCKET) closesocket(sp[0]);
if (sp[1] != INVALID_SOCKET) closesocket(sp[1]);
sp[0] = sp[1] = INVALID_SOCKET;
}
closesocket(sock);
return ret;
}
| false | false | false | false | false | 0 |
ct_timer_interrupt(void *data, unsigned int status)
{
struct ct_timer *timer = data;
/* Interval timer interrupt */
if ((status & IT_INT) && timer->ops->interrupt)
timer->ops->interrupt(timer);
}
| 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.