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 |
|---|---|---|---|---|---|---|
_ib_cache_gid_table_find(struct ib_device *ib_dev,
const union ib_gid *gid,
const struct ib_gid_attr *val,
unsigned long mask,
u8 *port, u16 *index)
{
struct ib_gid_table **ports_table = ib_dev->cache.gid_cache;
struct ib_gid_table *table;
u8 p;
int local_index;
for (p = 0; p < ib_dev->phys_port_cnt; p++) {
table = ports_table[p];
local_index = find_gid(table, gid, val, false, mask);
if (local_index >= 0) {
if (index)
*index = local_index;
if (port)
*port = p + rdma_start_port(ib_dev);
return 0;
}
}
return -ENOENT;
} | false | false | false | false | false | 0 |
handle_missing_table(struct realtime_sqlite3_db *db, const char *table, va_list ap)
{
const char *column;
int type, first = 1, res;
size_t sz;
struct ast_str *sql;
if (!(sql = ast_str_create(128))) {
return -1;
}
while ((column = va_arg(ap, typeof(column))) && (type = va_arg(ap, typeof(type))) && (sz = va_arg(ap, typeof(sz)))) {
if (first) {
ast_str_set(&sql, 0, "CREATE TABLE IF NOT EXISTS %s (%s %s", sqlite3_escape_table(table),
sqlite3_escape_column(column), get_sqlite_column_type(type));
first = 0;
} else {
ast_str_append(&sql, 0, ", %s %s", sqlite3_escape_column(column), get_sqlite_column_type(type));
}
}
ast_str_append(&sql, 0, ")");
res = realtime_sqlite3_execute_handle(db, ast_str_buffer(sql), NULL, NULL, 1) < 0 ? -1 : 0;
ast_free(sql);
return res;
} | false | false | false | false | false | 0 |
list_model_iterate (TestConformSimpleFixture *fixture,
gconstpointer data)
{
ModelData test_data = { NULL, 0 };
ClutterModelIter *iter;
gint i;
test_data.model = clutter_list_model_new (N_COLUMNS,
G_TYPE_STRING, "Foo",
G_TYPE_INT, "Bar");
test_data.n_row = 0;
g_signal_connect (test_data.model, "row-added",
G_CALLBACK (on_row_added),
&test_data);
for (i = 1; i < 10; i++)
{
gchar *foo = g_strdup_printf ("String %d", i);
clutter_model_append (test_data.model,
COLUMN_FOO, foo,
COLUMN_BAR, i,
-1);
g_free (foo);
}
if (g_test_verbose ())
g_print ("Forward iteration...\n");
iter = clutter_model_get_first_iter (test_data.model);
g_assert (iter != NULL);
i = 0;
while (!clutter_model_iter_is_last (iter))
{
compare_iter (iter, i,
forward_base[i].expected_foo,
forward_base[i].expected_bar);
iter = clutter_model_iter_next (iter);
i += 1;
}
g_object_unref (iter);
if (g_test_verbose ())
g_print ("Backward iteration...\n");
iter = clutter_model_get_last_iter (test_data.model);
g_assert (iter != NULL);
i = 0;
do
{
compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1,
backward_base[i].expected_foo,
backward_base[i].expected_bar);
iter = clutter_model_iter_prev (iter);
i += 1;
}
while (!clutter_model_iter_is_first (iter));
compare_iter (iter, G_N_ELEMENTS (backward_base) - i - 1,
backward_base[i].expected_foo,
backward_base[i].expected_bar);
g_object_unref (iter);
g_object_unref (test_data.model);
} | false | false | false | false | false | 0 |
keyspan_pda_open(struct tty_struct *tty,
struct usb_serial_port *port)
{
struct usb_serial *serial = port->serial;
u8 *room;
int rc = 0;
struct keyspan_pda_private *priv;
/* find out how much room is in the Tx ring */
room = kmalloc(1, GFP_KERNEL);
if (!room)
return -ENOMEM;
rc = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0),
6, /* write_room */
USB_TYPE_VENDOR | USB_RECIP_INTERFACE
| USB_DIR_IN,
0, /* value */
0, /* index */
room,
1,
2000);
if (rc < 0) {
dev_dbg(&port->dev, "%s - roomquery failed\n", __func__);
goto error;
}
if (rc == 0) {
dev_dbg(&port->dev, "%s - roomquery returned 0 bytes\n", __func__);
rc = -EIO;
goto error;
}
priv = usb_get_serial_port_data(port);
priv->tx_room = *room;
priv->tx_throttled = *room ? 0 : 1;
/*Start reading from the device*/
rc = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);
if (rc) {
dev_dbg(&port->dev, "%s - usb_submit_urb(read int) failed\n", __func__);
goto error;
}
error:
kfree(room);
return rc;
} | false | false | false | false | false | 0 |
pw_encodevals_ext( Slapi_PBlock *pb, const Slapi_DN *sdn, Slapi_Value **vals )
{
int i;
passwdPolicy *pwpolicy=NULL;
char *(*pws_enc) ( char *pwd ) = NULL;
if ( (NULL == pb) || (NULL == vals) ) {
return( 0 );
}
/* new_passwdPolicy gives us a local policy if sdn and pb are set and
can be used to find a local policy, else we get the global policy */
pwpolicy = new_passwdPolicy(pb, sdn ? (char*)slapi_sdn_get_ndn(sdn) : NULL);
if (pwpolicy) {
if (pwpolicy->pw_storagescheme) {
pws_enc = pwpolicy->pw_storagescheme->pws_enc;
}
}
/* Password scheme encryption function was not found */
if ( pws_enc == NULL ) {
return( 0 );
}
for ( i = 0; vals[ i ] != NULL; ++i ) {
struct pw_scheme *pwsp = NULL;
char *enc = NULL;
if ( (pwsp=pw_val2scheme( (char*)slapi_value_get_string(vals[ i ]), NULL, 0)) != NULL ) { /* JCM Innards */
/* If the value already specifies clear storage, call the
* clear storage plug-in */
if (strcasecmp( pwsp->pws_name, "clear" ) == 0) {
enc = (*pwsp->pws_enc)( (char*)slapi_value_get_string(vals[ i ]) );
} else {
free_pw_scheme( pwsp );
continue; /* don't touch pre-encoded values */
}
}
free_pw_scheme( pwsp );
if ((!enc) && (( enc = (*pws_enc)( (char*)slapi_value_get_string(vals[ i ]) )) == NULL )) {
return( -1 );
}
slapi_value_free(&vals[ i ]);
vals[ i ] = slapi_value_new_string_passin(enc);
}
return( 0 );
} | false | false | false | false | false | 0 |
extDefDatatype(int datatype, int *prec, int *number)
{
if ( datatype != DATATYPE_FLT32 && datatype != DATATYPE_FLT64 &&
datatype != DATATYPE_CPX32 && datatype != DATATYPE_CPX64 )
datatype = DATATYPE_FLT32;
if ( datatype == DATATYPE_CPX32 || datatype == DATATYPE_CPX64 )
*number = 2;
else
*number = 1;
if ( datatype == DATATYPE_FLT64 || datatype == DATATYPE_CPX64 )
*prec = DOUBLE_PRECISION;
else
*prec = SINGLE_PRECISION;
} | false | false | false | false | false | 0 |
value_adjust(char *adjust_str, long base, long page_size)
{
long long adjust;
char *iter;
/* Convert and validate the adjust. */
errno = 0;
adjust = strtol(adjust_str, &iter, 0);
/* Catch strtol errors and sizes that overflow the native word size */
if (errno || adjust_str == iter) {
if (errno == ERANGE)
errno = EOVERFLOW;
else
errno = EINVAL;
ERROR("%s: invalid adjustment\n", adjust_str);
exit(EXIT_FAILURE);
}
switch (*iter) {
case 'G':
case 'g':
adjust = size_to_smaller_unit(adjust);
case 'M':
case 'm':
adjust = size_to_smaller_unit(adjust);
case 'K':
case 'k':
adjust = size_to_smaller_unit(adjust);
adjust = adjust / page_size;
}
if (adjust_str[0] != '+' && adjust_str[0] != '-')
base = 0;
/* Ensure we neither go negative nor exceed LONG_MAX. */
if (adjust < 0 && -adjust > base) {
adjust = -base;
}
if (adjust > 0 && (base + adjust) < base) {
adjust = LONG_MAX - base;
}
base += adjust;
DEBUG("Returning page count of %ld\n", base);
return base;
} | false | false | false | false | false | 0 |
inf_communication_method_remove_member(InfCommunicationMethod* method,
InfXmlConnection* connection)
{
g_return_if_fail(INF_COMMUNICATION_IS_METHOD(method));
g_return_if_fail(INF_IS_XML_CONNECTION(connection));
g_return_if_fail(inf_communication_method_is_member(method, connection));
g_signal_emit(
G_OBJECT(method),
method_signals[REMOVE_MEMBER],
0,
connection
);
} | false | false | false | false | false | 0 |
InvalidateCurrentWorkingDir(const CServerPath& path)
{
wxASSERT(!path.IsEmpty());
if (m_CurrentPath.IsEmpty())
return;
if (m_CurrentPath == path || path.IsParentOf(m_CurrentPath, false))
{
if (m_pCurOpData)
m_invalidateCurrentPath = true;
else
m_CurrentPath.Clear();
}
} | false | false | false | false | false | 0 |
select_view_line(struct view *view, unsigned long lineno)
{
if (lineno - view->offset >= view->height) {
view->offset = lineno;
view->lineno = lineno;
if (view_is_displayed(view))
redraw_view(view);
} else {
unsigned long old_lineno = view->lineno - view->offset;
view->lineno = lineno;
if (view_is_displayed(view)) {
draw_view_line(view, old_lineno);
draw_view_line(view, view->lineno - view->offset);
wnoutrefresh(view->win);
} else {
view->ops->select(view, &view->line[view->lineno]);
}
}
} | false | false | false | false | false | 0 |
can_submit() {
if (getService()==SERVICE_LASTFM)
return !( (flags&FLAG_DISABLED) || (flags&FLAG_BANNED) || (flags&FLAG_BADAUTH) || (flags&FLAG_BADTIME));
else
return !( (flags&FLAG_DISABLED) || (flags&FLAG_BANNED) || (flags&FLAG_BADAUTH) || (flags&FLAG_BADTIME) || username.empty() || password.empty() );
} | false | false | false | false | false | 0 |
_dmalloc_strpbrk(const char *file, const int line,
const char *str, const char *list)
{
if (BIT_IS_SET(_dmalloc_flags, DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strpbrk", str,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strpbrk", list,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strpbrk");
}
}
return (char *)strpbrk(str, list);
} | false | false | false | false | false | 0 |
SortByError()
{
// TODO: Is a bubble sort, not so eficient O(N^2)
// TODO: Enhancement 1: Do a Quick Sort
// TODO: Engancement 2: Sort an index array
DataArray & errors = GetCandidatesErr();
DataArray & freqs = GetCandidatesFreq();
const int nCandidates = GetnCandidates();
for (int i=0; i<nCandidates; i++) // Ordering
for (int j=i+1; j<nCandidates; j++)
{
if (errors[i] <= errors[j]) continue;
std::swap(errors[i],errors[j]);
std::swap(freqs[i],freqs[j]);
}
} | false | false | false | false | false | 0 |
file_info_cmp (const void *p1, const void *p2)
{
const struct file_info *const s1 = (const struct file_info *) p1;
const struct file_info *const s2 = (const struct file_info *) p2;
const unsigned char *cp1;
const unsigned char *cp2;
/* Take care of file names without directories. We need to make sure that
we return consistent values to qsort since some will get confused if
we return the same value when identical operands are passed in opposite
orders. So if neither has a directory, return 0 and otherwise return
1 or -1 depending on which one has the directory. */
if ((s1->path == s1->fname || s2->path == s2->fname))
return (s2->path == s2->fname) - (s1->path == s1->fname);
cp1 = (const unsigned char *) s1->path;
cp2 = (const unsigned char *) s2->path;
while (1)
{
++cp1;
++cp2;
/* Reached the end of the first path? If so, handle like above. */
if ((cp1 == (const unsigned char *) s1->fname)
|| (cp2 == (const unsigned char *) s2->fname))
return ((cp2 == (const unsigned char *) s2->fname)
- (cp1 == (const unsigned char *) s1->fname));
/* Character of current path component the same? */
else if (*cp1 != *cp2)
return *cp1 - *cp2;
}
} | false | false | false | false | false | 0 |
write_image_square (FttCell * cell, gpointer * data)
{
Colormap * colormap = data[0];
gdouble * min = data[1];
gdouble * max = data[2];
GfsVariable * v = data[3];
Image * image = data[4];
FttVector * lambda = data[5];
FttVector p;
GtsColor fc = { 0., 0., 0. }; /* nodata = black */
if (GFS_HAS_DATA (cell, v))
fc = colormap_color (colormap, (GFS_VALUE (cell, v) - *min)/(*max - *min));
Color c;
gdouble size = ftt_cell_size (cell)/2.;
FttVector p1, p2;
ftt_cell_pos (cell, &p);
c.r = fc.r*255;
c.g = fc.g*255;
c.b = fc.b*255;
p1.x = (p.x - size)/lambda->x + 1e-9;
p1.y = (p.y - size)/lambda->y + 1e-9;
p2.x = (p.x + size)/lambda->x - 1e-9;
p2.y = (p.y + size)/lambda->y - 1e-9;
image_draw_square (image, &p1, &p2, c);
} | false | false | false | false | false | 0 |
off_to_str (off_t off)
{
static char bufs[NUM_SIMUL_OFF_TO_STRS][80];
static char (*next_buf)[80] = bufs;
if (next_buf >= (bufs + NUM_SIMUL_OFF_TO_STRS))
next_buf = bufs;
if (sizeof (off) > sizeof (long))
sprintf (*next_buf, "%lld", (long long int) off);
else if (sizeof (off) == sizeof (long))
sprintf (*next_buf, "%ld", (long) off);
else
sprintf (*next_buf, "%d", (int) off);
return *next_buf++;
} | false | false | false | false | false | 0 |
send_file(struct mg_connection *conn, const char *path) {
char buf[1024];
struct stat st;
int n;
FILE *fp;
if (stat(path, &st) == 0 && (fp = fopen(path, "rb")) != NULL) {
mg_printf(conn, "--w00t\r\nContent-Type: image/jpeg\r\n"
"Content-Length: %lu\r\n\r\n", (unsigned long) st.st_size);
while ((n = fread(buf, 1, sizeof(buf), fp)) > 0) {
mg_write(conn, buf, n);
}
fclose(fp);
mg_write(conn, "\r\n", 2);
}
} | true | true | false | false | true | 1 |
div_normalization_factor(u_long w)
{
u_long b = (1L<<(WORD_BITS-1)), c = 0;
for (; b > 0; b>>=1, c++) {
if (w & b) return c;
}
/* something got wrong here */
Scm_Panic("bignum.c: div_normalization_factor: can't be here");
return 0; /* dummy */
} | false | false | false | false | false | 0 |
mailimf_header_string_write_driver(int (* do_write)(void *, const char *, size_t), void * data, int * col,
const char * str, size_t length)
{
int state;
const char * p;
const char * word_begin;
const char * word_end;
const char * next_word;
int first;
state = STATE_BEGIN;
p = str;
word_begin = p;
word_end = p;
next_word = p;
first = 1;
while (length > 0) {
switch (state) {
case STATE_BEGIN:
switch (* p) {
case '\r':
case '\n':
case ' ':
case '\t':
p ++;
length --;
break;
default:
word_begin = p;
state = STATE_WORD;
break;
}
break;
case STATE_SPACE:
switch (* p) {
case '\r':
case '\n':
case ' ':
case '\t':
p ++;
length --;
break;
default:
word_begin = p;
state = STATE_WORD;
break;
}
break;
case STATE_WORD:
switch (* p) {
case '\r':
case '\n':
case ' ':
case '\t':
if (p - word_begin + (* col) + 1 > MAX_MAIL_COL)
mailimf_string_write_driver(do_write, data, col, HEADER_FOLD,
sizeof(HEADER_FOLD) - 1);
else {
if (!first)
mailimf_string_write_driver(do_write, data, col, " ", 1);
}
first = 0;
mailimf_string_write_driver(do_write, data, col, word_begin, p - word_begin);
state = STATE_SPACE;
break;
default:
if (p - word_begin + (* col) >= MAX_VALID_IMF_LINE) {
mailimf_string_write_driver(do_write, data, col, word_begin, p - word_begin);
mailimf_string_write_driver(do_write, data, col, HEADER_FOLD,
sizeof(HEADER_FOLD) - 1);
word_begin = p;
}
p ++;
length --;
break;
}
break;
}
}
if (state == STATE_WORD) {
if (p - word_begin + (* col) >= MAX_MAIL_COL)
mailimf_string_write_driver(do_write, data, col, HEADER_FOLD,
sizeof(HEADER_FOLD) - 1);
else {
if (!first)
mailimf_string_write_driver(do_write, data, col, " ", 1);
}
first = 0;
mailimf_string_write_driver(do_write, data, col, word_begin, p - word_begin);
}
return MAILIMF_NO_ERROR;
} | false | false | false | false | false | 0 |
orinoco_nortel_hw_init(struct orinoco_pci_card *card)
{
int i;
u32 reg;
/* Setup bridge */
if (ioread16(card->bridge_io) & 1) {
printk(KERN_ERR PFX "brg1 answer1 wrong\n");
return -EBUSY;
}
iowrite16(0x118, card->bridge_io + 2);
iowrite16(0x108, card->bridge_io + 2);
mdelay(30);
iowrite16(0x8, card->bridge_io + 2);
for (i = 0; i < 30; i++) {
mdelay(30);
if (ioread16(card->bridge_io) & 0x10)
break;
}
if (i == 30) {
printk(KERN_ERR PFX "brg1 timed out\n");
return -EBUSY;
}
if (ioread16(card->attr_io + COR_OFFSET) & 1) {
printk(KERN_ERR PFX "brg2 answer1 wrong\n");
return -EBUSY;
}
if (ioread16(card->attr_io + COR_OFFSET + 2) & 1) {
printk(KERN_ERR PFX "brg2 answer2 wrong\n");
return -EBUSY;
}
if (ioread16(card->attr_io + COR_OFFSET + 4) & 1) {
printk(KERN_ERR PFX "brg2 answer3 wrong\n");
return -EBUSY;
}
/* Set the PCMCIA COR register */
iowrite16(COR_VALUE, card->attr_io + COR_OFFSET);
mdelay(1);
reg = ioread16(card->attr_io + COR_OFFSET);
if (reg != COR_VALUE) {
printk(KERN_ERR PFX "Error setting COR value (reg=%x)\n",
reg);
return -EBUSY;
}
/* Set LEDs */
iowrite16(1, card->bridge_io + 10);
return 0;
} | false | false | false | false | false | 0 |
eet_clearcache(void)
{
int num = 0;
int i;
/*
* We need to compute the list of eet file to close separately from the cache,
* due to eet_close removing them from the cache after each call.
*/
LOCK_CACHE;
for (i = 0; i < eet_writers_num; i++)
{
if (eet_writers[i]->references <= 0)
num++;
}
for (i = 0; i < eet_readers_num; i++)
{
if (eet_readers[i]->references <= 0)
num++;
}
if (num > 0)
{
Eet_File **closelist = NULL;
closelist = alloca(num * sizeof(Eet_File *));
num = 0;
for (i = 0; i < eet_writers_num; i++)
{
if (eet_writers[i]->references <= 0)
{
closelist[num] = eet_writers[i];
eet_writers[i]->delete_me_now = 1;
num++;
}
}
for (i = 0; i < eet_readers_num; i++)
{
if (eet_readers[i]->references <= 0)
{
closelist[num] = eet_readers[i];
eet_readers[i]->delete_me_now = 1;
num++;
}
}
for (i = 0; i < num; i++)
{
eet_internal_close(closelist[i], EINA_TRUE);
}
}
UNLOCK_CACHE;
} | false | true | false | false | false | 1 |
srpdev_close ( struct srp_device *srpdev, int rc ) {
struct srp_command *srpcmd;
struct srp_command *tmp;
if ( rc != 0 ) {
DBGC ( srpdev, "SRP %p closed: %s\n",
srpdev, strerror ( rc ) );
}
/* Shut down interfaces */
intf_shutdown ( &srpdev->socket, rc );
intf_shutdown ( &srpdev->scsi, rc );
/* Shut down any active commands */
list_for_each_entry_safe ( srpcmd, tmp, &srpdev->commands, list ) {
srpcmd_get ( srpcmd );
srpcmd_close ( srpcmd, rc );
srpcmd_put ( srpcmd );
}
} | false | false | false | false | false | 0 |
dfb_window_repaint( CoreWindow *window,
const DFBRegion *region,
DFBSurfaceFlipFlags flags )
{
DFBResult ret;
CoreWindowStack *stack = window->stack;
D_ASSERT( window != NULL );
D_ASSERT( window->stack != NULL );
DFB_REGION_ASSERT_IF( region );
/* Lock the window stack. */
if (dfb_windowstack_lock( stack ))
return DFB_FUSION;
/* Never call WM after destroying the window. */
if (DFB_WINDOW_DESTROYED( window )) {
dfb_windowstack_unlock( stack );
return DFB_DESTROYED;
}
ret = dfb_wm_update_window( window, region, flags );
/* Unlock the window stack. */
dfb_windowstack_unlock( stack );
return ret;
} | false | false | false | false | false | 0 |
w5100_write_socket_port( nic_w5100_t *self, nic_w5100_socket_t *socket, int which, libspectrum_byte b )
{
nic_w5100_debug( "w5100: writing 0x%02x to S%d_PORT%d\n", b, socket->id, which );
socket->port[which] = b;
if( ++socket->bind_count == 2 ) {
if( socket->state == W5100_SOCKET_STATE_UDP && !socket->socket_bound ) {
if( w5100_socket_bind_port( self, socket ) ) {
socket->bind_count = 0;
return;
}
compat_socket_selfpipe_wake( self->selfpipe );
}
socket->bind_count = 0;
}
} | false | false | false | false | false | 0 |
insert_freq(GHashTable *h, fs_quad_freq *f)
{
fs_quad_freq *old = (fs_quad_freq *)g_hash_table_lookup(h, f);
if (old) {
old->freq += f->freq;
} else {
g_hash_table_insert(h, f, f);
}
fs_quad_freq ponly = *f;
ponly.sec = FS_RID_NULL;
old = (fs_quad_freq *)g_hash_table_lookup(h, &ponly);
if (!old) {
old = calloc(1, sizeof(fs_quad_freq));
old->pri = ponly.pri;
old->sec = ponly.sec;
g_hash_table_insert(h, old, old);
}
old->freq += ponly.freq;
} | false | false | false | false | false | 0 |
insert_type (char **argv, int *arg_ptr,
const struct parser_table *entry,
PRED_FUNC which_pred)
{
mode_t type_cell;
struct predicate *our_pred;
float rate = 0.5;
const char *typeletter;
if (collect_arg(argv, arg_ptr, &typeletter))
{
if (strlen(typeletter) != 1u)
{
error(1, 0, _("Arguments to -type should contain only one letter"));
return false;
}
switch (typeletter[0])
{
case 'b': /* block special */
type_cell = S_IFBLK;
rate = 0.01f;
break;
case 'c': /* character special */
type_cell = S_IFCHR;
rate = 0.01f;
break;
case 'd': /* directory */
type_cell = S_IFDIR;
rate = 0.4f;
break;
case 'f': /* regular file */
type_cell = S_IFREG;
rate = 0.95f;
break;
#ifdef S_IFLNK
case 'l': /* symbolic link */
type_cell = S_IFLNK;
rate = 0.1f;
break;
#endif
#ifdef S_IFIFO
case 'p': /* pipe */
type_cell = S_IFIFO;
rate = 0.01f;
break;
#endif
#ifdef S_IFSOCK
case 's': /* socket */
type_cell = S_IFSOCK;
rate = 0.01f;
break;
#endif
#ifdef S_IFDOOR
case 'D': /* Solaris door */
type_cell = S_IFDOOR;
rate = 0.01f;
break;
#endif
default: /* None of the above ... nuke 'em. */
error(1, 0, _("Unknown argument to -type: %c"), (*typeletter));
return false;
}
our_pred = insert_primary_withpred (entry, which_pred);
our_pred->est_success_rate = rate;
/* Figure out if we will need to stat the file, because if we don't
* need to follow symlinks, we can avoid a stat call by using
* struct dirent.d_type.
*/
if (which_pred == pred_xtype)
{
our_pred->need_stat = true;
our_pred->need_type = false;
}
else
{
our_pred->need_stat = false; /* struct dirent is enough */
our_pred->need_type = true;
}
our_pred->args.type = type_cell;
return true;
}
return false;
} | false | false | false | false | false | 0 |
gtkaml_ast_markup_attribute_real_resolve (GtkamlAstMarkupAttribute* self, GtkamlMarkupResolver* resolver, GtkamlAstMarkupTag* markup_tag, GError** error) {
GtkamlAstMarkupTag* _tmp0_;
ValaDataType* _tmp1_;
ValaDataType* _tmp2_;
GtkamlAstMarkupTag* _tmp3_;
ValaDataType* _tmp4_;
ValaDataType* _tmp5_;
ValaObjectTypeSymbol* _tmp6_;
ValaObjectTypeSymbol* _tmp7_;
ValaObjectTypeSymbol* _tmp8_;
ValaObjectTypeSymbol* cl;
GtkamlMarkupResolver* _tmp9_;
ValaObjectTypeSymbol* _tmp10_;
const gchar* _tmp11_;
const gchar* _tmp12_;
ValaSymbol* _tmp13_ = NULL;
ValaSymbol* resolved_attribute;
ValaSymbol* _tmp14_;
g_return_if_fail (resolver != NULL);
g_return_if_fail (markup_tag != NULL);
_tmp0_ = markup_tag;
_tmp1_ = gtkaml_ast_markup_tag_get_resolved_type (_tmp0_);
_tmp2_ = _tmp1_;
g_assert (VALA_IS_OBJECT_TYPE (_tmp2_));
_tmp3_ = markup_tag;
_tmp4_ = gtkaml_ast_markup_tag_get_resolved_type (_tmp3_);
_tmp5_ = _tmp4_;
_tmp6_ = vala_object_type_get_type_symbol (VALA_OBJECT_TYPE (_tmp5_));
_tmp7_ = _tmp6_;
_tmp8_ = _vala_code_node_ref0 (_tmp7_);
cl = _tmp8_;
_tmp9_ = resolver;
_tmp10_ = cl;
_tmp11_ = gtkaml_ast_markup_attribute_get_attribute_name (self);
_tmp12_ = _tmp11_;
_tmp13_ = gtkaml_markup_resolver_search_symbol (_tmp9_, _tmp10_, _tmp12_);
resolved_attribute = _tmp13_;
_tmp14_ = resolved_attribute;
if (VALA_IS_PROPERTY (_tmp14_)) {
ValaSymbol* _tmp15_;
ValaDataType* _tmp16_;
ValaDataType* _tmp17_;
ValaDataType* _tmp18_ = NULL;
ValaDataType* _tmp19_;
_tmp15_ = resolved_attribute;
_tmp16_ = vala_property_get_property_type (VALA_PROPERTY (_tmp15_));
_tmp17_ = _tmp16_;
_tmp18_ = vala_data_type_copy (_tmp17_);
_tmp19_ = _tmp18_;
gtkaml_ast_markup_attribute_set_target_type (self, _tmp19_);
_vala_code_node_unref0 (_tmp19_);
} else {
ValaSymbol* _tmp20_;
_tmp20_ = resolved_attribute;
if (VALA_IS_FIELD (_tmp20_)) {
ValaSymbol* _tmp21_;
ValaDataType* _tmp22_;
ValaDataType* _tmp23_;
ValaDataType* _tmp24_ = NULL;
ValaDataType* _tmp25_;
_tmp21_ = resolved_attribute;
_tmp22_ = vala_variable_get_variable_type ((ValaVariable*) VALA_FIELD (_tmp21_));
_tmp23_ = _tmp22_;
_tmp24_ = vala_data_type_copy (_tmp23_);
_tmp25_ = _tmp24_;
gtkaml_ast_markup_attribute_set_target_type (self, _tmp25_);
_vala_code_node_unref0 (_tmp25_);
} else {
ValaSymbol* _tmp26_;
_tmp26_ = resolved_attribute;
if (VALA_IS_SIGNAL (_tmp26_)) {
ValaSymbol* _tmp27_;
ValaSignal* _tmp28_;
_tmp27_ = resolved_attribute;
_tmp28_ = _vala_code_node_ref0 (VALA_SIGNAL (_tmp27_));
_vala_code_node_unref0 (self->signal);
self->signal = _tmp28_;
} else {
}
}
}
_vala_code_node_unref0 (resolved_attribute);
_vala_code_node_unref0 (cl);
} | false | false | false | false | false | 0 |
mc13xxx_rtc_irq_enable_unlocked(struct device *dev,
unsigned int enabled, int irq)
{
struct mc13xxx_rtc *priv = dev_get_drvdata(dev);
int (*func)(struct mc13xxx *mc13xxx, int irq);
if (!priv->valid)
return -ENODATA;
func = enabled ? mc13xxx_irq_unmask : mc13xxx_irq_mask;
return func(priv->mc13xxx, irq);
} | false | false | false | false | false | 0 |
hash_memory_multi(int hash, unsigned char *out, unsigned long *outlen,
const unsigned char *in, unsigned long inlen, ...)
{
hash_state *md;
int err;
va_list args;
const unsigned char *curptr;
unsigned long curlen;
LTC_ARGCHK(in != NULL);
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
if ((err = hash_is_valid(hash)) != CRYPT_OK) {
return err;
}
if (*outlen < hash_descriptor[hash].hashsize) {
*outlen = hash_descriptor[hash].hashsize;
return CRYPT_BUFFER_OVERFLOW;
}
md = XMALLOC(sizeof(hash_state));
if (md == NULL) {
return CRYPT_MEM;
}
if ((err = hash_descriptor[hash].init(md)) != CRYPT_OK) {
goto LBL_ERR;
}
va_start(args, inlen);
curptr = in;
curlen = inlen;
for (;;) {
/* process buf */
if ((err = hash_descriptor[hash].process(md, curptr, curlen)) != CRYPT_OK) {
goto LBL_ERR;
}
/* step to next */
curptr = va_arg(args, const unsigned char*);
if (curptr == NULL) {
break;
}
curlen = va_arg(args, unsigned long);
}
err = hash_descriptor[hash].done(md, out);
*outlen = hash_descriptor[hash].hashsize;
LBL_ERR:
#ifdef LTC_CLEAN_STACK
zeromem(md, sizeof(hash_state));
#endif
XFREE(md);
va_end(args);
return err;
} | false | false | false | true | false | 1 |
read_data_sectors_image ( void *p_user_data, void *p_buf,
lsn_t i_lsn, uint16_t i_blocksize,
uint32_t i_blocks )
{
const _img_private_t *p_env = p_user_data;
if (!p_env || !p_env->gen.cdio) return DRIVER_OP_UNINIT;
{
CdIo_t *p_cdio = p_env->gen.cdio;
track_t i_track = cdio_get_track(p_cdio, i_lsn);
track_format_t e_track_format = cdio_get_track_format(p_cdio, i_track);
switch(e_track_format) {
case TRACK_FORMAT_PSX:
case TRACK_FORMAT_AUDIO:
case TRACK_FORMAT_ERROR:
return DRIVER_OP_ERROR;
case TRACK_FORMAT_DATA:
return cdio_read_mode1_sectors (p_cdio, p_buf, i_lsn, false, i_blocks);
case TRACK_FORMAT_CDI:
case TRACK_FORMAT_XA:
return cdio_read_mode2_sectors (p_cdio, p_buf, i_lsn, false, i_blocks);
}
}
return DRIVER_OP_ERROR;
} | false | false | false | false | false | 0 |
withinDrawBinned (splotd * sp, gint m, GdkDrawable * drawable, GdkGC * gc)
{
displayd *display = sp->displayptr;
GGobiData *d = display->d;
ggobid *gg = GGobiFromSPlot (sp);
gint n, lwidth, ltype, gtype;
if (!gg || !display)
return;
if (display->options.whiskers_show_p) {
n = 2 * m;
lwidth = lwidth_from_gsize (d->glyph_now.els[m].size);
gtype = d->glyph_now.els[m].type;
ltype = set_lattribute_from_ltype (ltype_from_gtype (gtype), gg);
gdk_gc_set_line_attributes (gg->plot_GC, lwidth,
ltype, GDK_CAP_BUTT, GDK_JOIN_ROUND);
gdk_draw_line (drawable, gc,
sp->whiskers[n].x1, sp->whiskers[n].y1,
sp->whiskers[n].x2, sp->whiskers[n].y2);
n++;
gdk_draw_line (drawable, gc,
sp->whiskers[n].x1, sp->whiskers[n].y1,
sp->whiskers[n].x2, sp->whiskers[n].y2);
}
gdk_gc_set_line_attributes (gg->plot_GC,
0, GDK_LINE_SOLID, GDK_CAP_ROUND,
GDK_JOIN_ROUND);
} | false | false | false | false | false | 0 |
setcmd( /* returns length or -1 (error) */
int ident, /* radio ID */
int cmmd, /* command */
int subcmd /* subcommand */
)
{
u_char cmd[] = {FI, FI, FI, FI};
u_char rsp[BMAX];
cmd[0] = cmmd;
cmd[1] = subcmd;
if (subcmd & 0x8000)
cmd[2] = (subcmd >> 8) & 0x7f;
return (setcmda(ident, cmd, rsp));
} | false | false | false | false | false | 0 |
Find(const std::string& name, bool recursive ) {
for(PG_Widget* i = first(); i != NULL; i = i->next()) {
if(i->GetName() == name) {
return i;
}
}
if ( recursive )
for(PG_Widget* i = first(); i != NULL; i = i->next()) {
PG_Widget* w = i->FindChild(name, recursive );
if( w ) {
return w;
}
}
return NULL;
} | false | false | false | false | false | 0 |
create_hdmi(struct platform_device *dev)
{
int ret;
ret = sysfs_create_group(&dev->dev.kobj, &hdmi_attribute_group);
if (ret)
goto error_create_hdmi;
return 0;
error_create_hdmi:
remove_hdmi(dev);
return ret;
} | false | false | false | false | false | 0 |
ecc_export(unsigned char *out, unsigned long *outlen, int type, ecc_key *key)
{
int err;
unsigned char flags[1];
unsigned long key_size;
LTC_ARGCHK(out != NULL);
LTC_ARGCHK(outlen != NULL);
LTC_ARGCHK(key != NULL);
/* type valid? */
if (key->type != PK_PRIVATE && type == PK_PRIVATE) {
return CRYPT_PK_TYPE_MISMATCH;
}
if (ltc_ecc_is_valid_idx(key->idx) == 0) {
return CRYPT_INVALID_ARG;
}
/* we store the NIST byte size */
key_size = key->dp->size;
if (type == PK_PRIVATE) {
flags[0] = 1;
err = der_encode_sequence_multi(out, outlen,
LTC_ASN1_BIT_STRING, 1UL, flags,
LTC_ASN1_SHORT_INTEGER, 1UL, &key_size,
LTC_ASN1_INTEGER, 1UL, key->pubkey.x,
LTC_ASN1_INTEGER, 1UL, key->pubkey.y,
LTC_ASN1_INTEGER, 1UL, key->k,
LTC_ASN1_EOL, 0UL, NULL);
} else {
flags[0] = 0;
err = der_encode_sequence_multi(out, outlen,
LTC_ASN1_BIT_STRING, 1UL, flags,
LTC_ASN1_SHORT_INTEGER, 1UL, &key_size,
LTC_ASN1_INTEGER, 1UL, key->pubkey.x,
LTC_ASN1_INTEGER, 1UL, key->pubkey.y,
LTC_ASN1_EOL, 0UL, NULL);
}
return err;
} | true | true | false | true | false | 1 |
gle_int_to_string_bin(int value, string* binary) {
vector<unsigned char> values;
while (value > 0) {
values.push_back((unsigned char)(value % 2));
value /= 2;
}
stringstream out;
for (int i = values.size()-1; i >= 0; i--) {
out << (int)values[i];
}
*binary = out.str();
} | false | false | false | false | false | 0 |
RegExpFlagsToString(RegExp::Flags flags) {
char flags_buf[3];
int num_flags = 0;
if ((flags & RegExp::kGlobal) != 0) flags_buf[num_flags++] = 'g';
if ((flags & RegExp::kMultiline) != 0) flags_buf[num_flags++] = 'm';
if ((flags & RegExp::kIgnoreCase) != 0) flags_buf[num_flags++] = 'i';
ASSERT(num_flags <= static_cast<int>(ARRAY_SIZE(flags_buf)));
return i::Factory::LookupSymbol(
i::Vector<const char>(flags_buf, num_flags));
} | false | false | false | false | true | 1 |
compare_nodes (void const *a, void const *b)
{
struct merge_node const *nodea = a;
struct merge_node const *nodeb = b;
if (nodea->level == nodeb->level)
return (nodea->nlo + nodea->nhi) < (nodeb->nlo + nodeb->nhi);
return nodea->level < nodeb->level;
} | false | false | false | false | false | 0 |
load_module(void)
{
int res = ast_custom_function_register(&srv_query_function);
if (res < 0) {
return AST_MODULE_LOAD_DECLINE;
}
res = ast_custom_function_register(&srv_result_function);
if (res < 0) {
return AST_MODULE_LOAD_DECLINE;
}
return AST_MODULE_LOAD_SUCCESS;;
} | false | false | false | false | false | 0 |
vl_hikm_push (VlHIKMTree *f, vl_uint32 *asgn, vl_uint8 const *data, vl_size N)
{
vl_uindex i, d ;
vl_size M = vl_hikm_get_ndims (f) ;
vl_size depth = vl_hikm_get_depth (f) ;
/* for each datum */
for(i = 0 ; i < N ; i++) {
VlHIKMNode *node = f->root ;
d = 0 ;
while (node) {
vl_uint32 best ;
vl_ikm_push (node->filter,
&best,
data + i * M, 1) ;
asgn[i * depth + d] = best ;
++ d ;
if (!node->children) break ;
node = node->children [best] ;
}
}
} | false | false | false | false | false | 0 |
enic_grxclsrlall(struct enic *enic, struct ethtool_rxnfc *cmd,
u32 *rule_locs)
{
int j, ret = 0, cnt = 0;
cmd->data = enic->rfs_h.max - enic->rfs_h.free;
for (j = 0; j < (1 << ENIC_RFS_FLW_BITSHIFT); j++) {
struct hlist_head *hhead;
struct hlist_node *tmp;
struct enic_rfs_fltr_node *n;
hhead = &enic->rfs_h.ht_head[j];
hlist_for_each_entry_safe(n, tmp, hhead, node) {
if (cnt == cmd->rule_cnt)
return -EMSGSIZE;
rule_locs[cnt] = n->fltr_id;
cnt++;
}
}
cmd->rule_cnt = cnt;
return ret;
} | false | false | false | false | false | 0 |
check_markers (ClutterTimeline *timeline,
gint delta)
{
ClutterTimelinePrivate *priv = timeline->priv;
struct CheckIfMarkerHitClosure data;
/* shortcircuit here if we don't have any marker installed */
if (priv->markers_by_name == NULL)
return;
/* store the details of the timeline so that changing them in a
marker signal handler won't affect which markers are hit */
data.timeline = timeline;
data.direction = priv->direction;
data.new_time = priv->elapsed_time;
data.duration = priv->duration;
data.delta = delta;
g_hash_table_foreach (priv->markers_by_name,
(GHFunc) check_if_marker_hit,
&data);
} | false | false | false | false | false | 0 |
log2withScale_128(guint64 alo, guint64 ahi, int scale)
{
int tlog2 = log2_128(alo, ahi);
if (tlog2 < 0) tlog2 = 0;
return tlog2 - (scale * 33219) / 10000;
} | false | false | false | false | false | 0 |
str() const
{
char ss[6];
snprintf(ss, sizeof(ss), "%s%s%c",
square_str[from()],
square_str[to()],
(flags() & MOVE_PROMOTION) ?
tolower(piece_char[promote_to()])
: '\0' );
return std::string(ss);
} | false | false | false | false | false | 0 |
setTextEngine( QwtText::TextFormat format,
QwtTextEngine *engine )
{
if ( format == QwtText::AutoText )
return;
if ( format == QwtText::PlainText && engine == NULL )
return;
EngineMap::const_iterator it = d_map.find( format );
if ( it != d_map.end() )
{
const QwtTextEngine *e = this->engine( it );
if ( e )
delete e;
d_map.remove( format );
}
if ( engine != NULL )
d_map.insert( format, engine );
} | false | false | false | false | false | 0 |
possibly_as_a_result_of_a_preceding(explain_string_buffer_t *sb, int fildes)
{
int flags;
flags = fcntl(fildes, F_GETFL);
if (flags < 0)
flags = O_RDWR;
explain_string_buffer_puts(sb, ", ");
switch (flags & O_ACCMODE)
{
case O_RDONLY:
explain_buffer_gettext
(
sb,
/*
* xgettext: This message is used when explaining an EIO
* error, for a file open only for reading.
*/
i18n("possibly as a result of a preceding read(2) system call")
);
break;
case O_WRONLY:
explain_buffer_gettext
(
sb,
/*
* xgettext: This message is used when explaining an EIO
* error, for a file open only for writing.
*/
i18n("possibly as a result of a preceding write(2) system call")
);
break;
default:
explain_buffer_gettext
(
sb,
/*
* xgettext: This message is used when explaining an EIO
* error, for a file open for both reading and writing.
*/
i18n("possibly as a result of a preceding read(2) or "
"write(2) system call")
);
break;
}
} | false | false | false | false | false | 0 |
load (string fname)
{
igzstream file;
s_int8 retvalue = -1;
string fdef (MAPS_DIR);
fdef += fname;
file.open (fdef);
if (!file.is_open ())
return -1;
if (fileops::get_version (file, 1, 1, fdef))
retvalue = get (file);
file.close ();
filename_ = fname;
return retvalue;
} | false | false | false | false | false | 0 |
variable_cb_2(p_cb_data cause)
{
struct vcd_info* info = vcd_dmp_list;
PLI_UINT64 now = timerec_to_time64(cause->time);
if (now != vcd_cur_time) {
fstWriterEmitTimeChange(dump_file, now);
vcd_cur_time = now;
}
do {
show_this_item(info);
info->scheduled = 0;
} while ((info = info->dmp_next) != 0);
vcd_dmp_list = 0;
return 0;
} | false | false | false | false | false | 0 |
main(int argc, char *argv[])
{
if(argc > 1) {
run_from_file(argv[1]);
} else {
fprintf(stderr, "Error: Please specify a .svm compiled bytecode file.\n");
return -1;
}
/* for debugging purposes */
/* print_memory(30); */
return 0;
} | false | false | false | false | false | 0 |
gst_multipart_demux_class_init (GstMultipartDemuxClass * klass)
{
int i;
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
gobject_class->finalize = gst_multipart_demux_finalize;
gobject_class->set_property = gst_multipart_set_property;
gobject_class->get_property = gst_multipart_get_property;
g_object_class_install_property (gobject_class, PROP_BOUNDARY,
g_param_spec_string ("boundary", "Boundary",
"The boundary string separating data, automatic if NULL",
DEFAULT_BOUNDARY,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_AUTOSCAN,
g_param_spec_boolean ("autoscan", "autoscan",
"Try to autofind the prefix (deprecated unused, see boundary)",
DEFAULT_AUTOSCAN, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
* GstMultipartDemux::single-stream:
*
* Assume that there is only one stream whose content-type will
* not change and emit no-more-pads as soon as the first boundary
* content is parsed, decoded, and pads are linked.
*
* Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_SINGLE_STREAM,
g_param_spec_boolean ("single-stream", "Single Stream",
"Assume that there is only one stream whose content-type will not change and emit no-more-pads as soon as the first boundary content is parsed, decoded, and pads are linked",
DEFAULT_SINGLE_STREAM, G_PARAM_READWRITE));
/* populate gst names and mime types pairs */
klass->gstnames = g_hash_table_new (g_str_hash, g_str_equal);
for (i = 0; gstnames[i].key; i++) {
g_hash_table_insert (klass->gstnames, (gpointer) gstnames[i].key,
(gpointer) gstnames[i].val);
}
gstelement_class->change_state = gst_multipart_demux_change_state;
} | false | false | false | false | false | 0 |
calc_gaussgrid(double *yvals, int ysize, double yfirst, double ylast)
{
double *yw;
long yhsize;
long i;
yw = (double *) malloc(ysize*sizeof(double));
gaussaw(yvals, yw, ysize);
free(yw);
for ( i = 0; i < ysize; i++ )
yvals[i] = asin(yvals[i])/M_PI*180.0;
if ( yfirst < ylast && yfirst > -90.0 && ylast < 90.0 )
{
double ytmp;
yhsize = ysize/2;
for ( i = 0; i < yhsize; i++ )
{
ytmp = yvals[i];
yvals[i] = yvals[ysize-i-1];
yvals[ysize-i-1] = ytmp;
}
}
} | false | false | false | false | false | 0 |
can_remove_node_now_p_1 (struct cgraph_node *node)
{
/* FIXME: When address is taken of DECL_EXTERNAL function we still
can remove its offline copy, but we would need to keep unanalyzed node in
the callgraph so references can point to it. */
return (!node->symbol.address_taken
&& !ipa_ref_has_aliases_p (&node->symbol.ref_list)
&& cgraph_can_remove_if_no_direct_calls_p (node)
/* Inlining might enable more devirtualizing, so we want to remove
those only after all devirtualizable virtual calls are processed.
Lacking may edges in callgraph we just preserve them post
inlining. */
&& !DECL_VIRTUAL_P (node->symbol.decl)
/* During early inlining some unanalyzed cgraph nodes might be in the
callgraph and they might reffer the function in question. */
&& !cgraph_new_nodes);
} | false | false | false | false | false | 0 |
merge_clusters(cluster_t *cluster)
{
int first, second;
while (cluster->num_clusters > 1) {
if (find_clusters_to_merge(cluster, &first, &second) != -1)
merge(cluster, first, second);
}
return cluster;
} | false | false | false | false | false | 0 |
gzfile_close(struct gzfile *gz, int closeflag)
{
VALUE io = gz->io;
gz->end(gz);
gz->io = Qnil;
gz->orig_name = Qnil;
gz->comment = Qnil;
if (closeflag && rb_respond_to(io, id_close)) {
rb_funcall(io, id_close, 0);
}
} | false | false | false | false | false | 0 |
common_vh_start(int num_pixmaps)
{
int i;
total_pixmaps = num_pixmaps;
for (i = 0;i < 8;i++)
{
if (i < total_pixmaps)
{
if (!(pixmap[i] = auto_malloc(256*256))) return 1;
}
else
pixmap[i] = NULL;
}
return 0;
} | false | false | false | false | false | 0 |
docloseopen(void)
{
int ret;
if (testcalls <= simulatedopcount)
return;
if (debug)
prt("%lu close/open\n", testcalls);
if ((ret = rbd_close(image)) < 0) {
prterrcode("docloseopen: close", ret);
report_failure(180);
}
ret = rbd_open(ioctx, iname, &image, NULL);
if (ret < 0) {
prterrcode("docloseopen: open", ret);
report_failure(181);
}
} | false | false | false | false | false | 0 |
wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id,
void *buf, size_t buf_len)
{
struct wl1251_cmd_packet_template *cmd;
size_t cmd_len;
int ret = 0;
wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id);
WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE);
buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE);
cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4);
cmd = kzalloc(cmd_len, GFP_KERNEL);
if (!cmd) {
ret = -ENOMEM;
goto out;
}
cmd->size = cpu_to_le16(buf_len);
if (buf)
memcpy(cmd->data, buf, buf_len);
ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len);
if (ret < 0) {
wl1251_warning("cmd set_template failed: %d", ret);
goto out;
}
out:
kfree(cmd);
return ret;
} | false | false | false | false | false | 0 |
printf_frames(const uint8_t* bits, int max_frames,
int row, int major, int minor, int print_empty, int no_clock)
{
int i, i_without_clk;
char prefix[128], suffix[128];
if (row < 0)
sprintf(prefix, "f%i ", abs(row));
else
sprintf(prefix, "r%i ma%i mi%i ", row, major, minor);
if (is_empty(bits, 130)) {
for (i = 1; i < max_frames; i++) {
if (!is_empty(&bits[i*130], 130))
break;
}
if (print_empty) {
if (i > 1)
printf("%s- *%i\n", prefix, i);
else
printf("%s-\n", prefix);
}
return i;
}
// value 128 chosen randomly for readability to decide
// between printing individual bits or a hex block.
if (count_bits(bits, 130) <= 128) {
for (i = 0; i < FRAME_SIZE*8; i++) {
if (!frame_get_bit(bits, i)) continue;
if (i >= 512 && i < 528) { // hclk
if (!no_clock)
printf("%sbit %i\n", prefix, i);
continue;
}
i_without_clk = i;
if (i_without_clk >= 528)
i_without_clk -= 16;
snprintf(suffix, sizeof(suffix), "64*%i+%i 256*%i+%i pin %i",
i_without_clk/64, i_without_clk%64,
i_without_clk/256, i_without_clk%256,
xc6_bit2pin(i_without_clk));
printf("%sbit %i %s\n", prefix, i, suffix);
}
return 1;
}
printf("%shex\n", prefix);
printf("{\n");
hexdump(1, bits, 130);
printf("}\n");
return 1;
} | true | true | false | false | false | 1 |
divided_max_mean(data_t *dataseries_i, int datalength, int length, int *offset)
{
int shift=length;
//if sorting data the following is an important speedup hack
if (shift>180) shift=180;
int window_length=length+shift;
if (window_length>datalength) window_length=datalength;
// put down as many windows as will fit without overrunning data
int start=0;
int end=0;
data_t energy=0;
data_t candidate=0;
int this_offset=0;
for (start=0; start+window_length<=datalength; start+=shift) {
end=start+window_length;
energy=dataseries_i[end]-dataseries_i[start];
if (energy < candidate) {
continue;
}
data_t window_mm=partial_max_mean(dataseries_i, start, end, length, &this_offset);
if (window_mm>candidate) {
candidate=window_mm;
if (offset) *offset=this_offset;
}
}
// if the overlapping windows don't extend to the end of the data,
// let's tack another one on at the end
if (end<datalength) {
start=datalength-window_length;
end=datalength;
energy=dataseries_i[end]-dataseries_i[start];
if (energy >= candidate) {
data_t window_mm=partial_max_mean(dataseries_i, start, end, length, &this_offset);
if (window_mm>candidate) {
candidate=window_mm;
if (offset) *offset=this_offset;
}
}
}
return candidate;
} | false | false | false | false | false | 0 |
getNamespaceId(const KEYXMLReader::AttributeIterator &attribute)
{
return attribute.getToken(attribute.getNamespace() ? attribute.getNamespace() : "");
} | false | false | false | false | false | 0 |
ppolicy_initialize()
{
int i, code;
for (i=0; pwd_OpSchema[i].def; i++) {
code = register_at( pwd_OpSchema[i].def, pwd_OpSchema[i].ad, 0 );
if ( code ) {
Debug( LDAP_DEBUG_ANY,
"ppolicy_initialize: register_at failed\n", 0, 0, 0 );
return code;
}
/* Allow Manager to set these as needed */
if ( is_at_no_user_mod( (*pwd_OpSchema[i].ad)->ad_type )) {
(*pwd_OpSchema[i].ad)->ad_type->sat_flags |=
SLAP_AT_MANAGEABLE;
}
}
code = register_supported_control( LDAP_CONTROL_PASSWORDPOLICYREQUEST,
SLAP_CTRL_ADD|SLAP_CTRL_BIND|SLAP_CTRL_MODIFY|SLAP_CTRL_HIDE, extops,
ppolicy_parseCtrl, &ppolicy_cid );
if ( code != LDAP_SUCCESS ) {
Debug( LDAP_DEBUG_ANY, "Failed to register control %d\n", code, 0, 0 );
return code;
}
ldap_pvt_thread_mutex_init( &chk_syntax_mutex );
ppolicy.on_bi.bi_type = "ppolicy";
ppolicy.on_bi.bi_db_init = ppolicy_db_init;
ppolicy.on_bi.bi_db_open = ppolicy_db_open;
ppolicy.on_bi.bi_db_close = ppolicy_close;
ppolicy.on_bi.bi_op_add = ppolicy_add;
ppolicy.on_bi.bi_op_bind = ppolicy_bind;
ppolicy.on_bi.bi_op_compare = ppolicy_compare;
ppolicy.on_bi.bi_op_delete = ppolicy_restrict;
ppolicy.on_bi.bi_op_modify = ppolicy_modify;
ppolicy.on_bi.bi_op_search = ppolicy_restrict;
ppolicy.on_bi.bi_connection_destroy = ppolicy_connection_destroy;
ppolicy.on_bi.bi_cf_ocs = ppolicyocs;
code = config_register_schema( ppolicycfg, ppolicyocs );
if ( code ) return code;
return overlay_register( &ppolicy );
} | false | false | false | false | false | 0 |
bcm3510_attach(const struct bcm3510_config *config,
struct i2c_adapter *i2c)
{
struct bcm3510_state* state = NULL;
int ret;
bcm3510_register_value v;
/* allocate memory for the internal state */
state = kzalloc(sizeof(struct bcm3510_state), GFP_KERNEL);
if (state == NULL)
goto error;
/* setup the state */
state->config = config;
state->i2c = i2c;
/* create dvb_frontend */
memcpy(&state->frontend.ops, &bcm3510_ops, sizeof(struct dvb_frontend_ops));
state->frontend.demodulator_priv = state;
mutex_init(&state->hab_mutex);
if ((ret = bcm3510_readB(state,0xe0,&v)) < 0)
goto error;
deb_info("Revision: 0x%1x, Layer: 0x%1x.\n",v.REVID_e0.REV,v.REVID_e0.LAYER);
if ((v.REVID_e0.REV != 0x1 && v.REVID_e0.LAYER != 0xb) && /* cold */
(v.REVID_e0.REV != 0x8 && v.REVID_e0.LAYER != 0x0)) /* warm */
goto error;
info("Revision: 0x%1x, Layer: 0x%1x.",v.REVID_e0.REV,v.REVID_e0.LAYER);
bcm3510_reset(state);
return &state->frontend;
error:
kfree(state);
return NULL;
} | false | false | false | false | false | 0 |
ReleaseCurrentLock()
{
if (IGNORELOCK)
{
return;
}
Debug("ReleaseCurrentLock(%s)\n",CFLOCK);
if (strlen(CFLAST) == 0)
{
return;
}
if (DeleteLock(CFLOCK) == -1)
{
Debug("Unable to remove lock %s\n",CFLOCK);
return;
}
if (PutLock(CFLAST) == -1)
{
snprintf(OUTPUT,CF_BUFSIZE*2,"Unable to create %s\n",CFLAST);
CfLog(cferror,OUTPUT,"creat");
return;
}
LockLog(getpid(),"Lock removed normally ",CFLOCK,"");
strcpy(CFLOCK,"no_active_lock");
} | false | false | false | false | false | 0 |
cc_on_dialog_remove_clicked(GtkButton *button, struct cc_dialog *cc)
{
GtkTreeIter iter;
if (gtk_tree_selection_get_selected(cc->selection, NULL, &iter))
gtk_list_store_remove(cc->store, &iter);
} | false | false | false | false | false | 0 |
test(char *URL)
{
CURL *curl;
CURLcode res=CURLE_OK;
struct curl_slist *slist = NULL;
struct WriteThis pooh;
pooh.counter = 0;
if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
fprintf(stderr, "curl_global_init() failed\n");
return TEST_ERR_MAJOR_BAD;
}
if ((curl = curl_easy_init()) == NULL) {
fprintf(stderr, "curl_easy_init() failed\n");
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
slist = curl_slist_append(slist, "Transfer-Encoding: chunked");
if (slist == NULL) {
fprintf(stderr, "curl_slist_append() failed\n");
curl_easy_cleanup(curl);
curl_global_cleanup();
return TEST_ERR_MAJOR_BAD;
}
/* First set the URL that is about to receive our POST. */
test_setopt(curl, CURLOPT_URL, URL);
/* Now specify we want to POST data */
test_setopt(curl, CURLOPT_POST, 1L);
#ifdef CURL_DOES_CONVERSIONS
/* Convert the POST data to ASCII */
test_setopt(curl, CURLOPT_TRANSFERTEXT, 1L);
#endif
/* we want to use our own read function */
test_setopt(curl, CURLOPT_READFUNCTION, read_callback);
/* pointer to pass to our read function */
test_setopt(curl, CURLOPT_READDATA, &pooh);
/* get verbose debug output please */
test_setopt(curl, CURLOPT_VERBOSE, 1L);
/* include headers in the output */
test_setopt(curl, CURLOPT_HEADER, 1L);
/* enforce chunked transfer by setting the header */
test_setopt(curl, CURLOPT_HTTPHEADER, slist);
#ifdef LIB565
test_setopt(curl, CURLOPT_HTTPAUTH, (long)CURLAUTH_DIGEST);
test_setopt(curl, CURLOPT_USERPWD, "foo:bar");
#endif
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
test_cleanup:
/* clean up the headers list */
if(slist)
curl_slist_free_all(slist);
/* always cleanup */
curl_easy_cleanup(curl);
curl_global_cleanup();
return res;
} | false | false | false | false | false | 0 |
moveResizeForClient(int new_x, int new_y,
unsigned int new_width, unsigned int new_height, int gravity, unsigned int client_bw) {
m_placed = true;
frame().moveResizeForClient(new_x, new_y, new_width, new_height, gravity, client_bw);
setFocusFlag(m_focused);
m_state.shaded = false;
sendConfigureNotify();
if (!moving) {
m_last_resize_x = new_x;
m_last_resize_y = new_y;
}
} | false | false | false | false | false | 0 |
relpath(RelFileNode rnode, ForkNumber forknum)
{
int pathlen;
char *path;
if (rnode.spcNode == GLOBALTABLESPACE_OID)
{
/* Shared system relations live in {datadir}/global */
Assert(rnode.dbNode == 0);
pathlen = 7 + OIDCHARS + 1 + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "global/%u_%s",
rnode.relNode, forkNames[forknum]);
else
snprintf(path, pathlen, "global/%u", rnode.relNode);
}
else if (rnode.spcNode == DEFAULTTABLESPACE_OID)
{
/* The default tablespace is {datadir}/base */
pathlen = 5 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "base/%u/%u_%s",
rnode.dbNode, rnode.relNode, forkNames[forknum]);
else
snprintf(path, pathlen, "base/%u/%u",
rnode.dbNode, rnode.relNode);
}
else
{
/* All other tablespaces are accessed via symlinks */
pathlen = 9 + 1 + OIDCHARS + 1 + strlen(TABLESPACE_VERSION_DIRECTORY) +
1 + OIDCHARS + 1 + OIDCHARS + 1 + FORKNAMECHARS + 1;
path = (char *) palloc(pathlen);
if (forknum != MAIN_FORKNUM)
snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u_%s",
rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
rnode.dbNode, rnode.relNode, forkNames[forknum]);
else
snprintf(path, pathlen, "pg_tblspc/%u/%s/%u/%u",
rnode.spcNode, TABLESPACE_VERSION_DIRECTORY,
rnode.dbNode, rnode.relNode);
}
return path;
} | false | false | false | false | false | 0 |
GammaBuilder_reftrace(CTX ctx, kRawPtr *o FTRARG)
{
size_t i;
knh_GammaBuilderEX_t *b = DP((kGammaBuilder*)o);
KNH_ENSUREREF(ctx, b->gcapacity * 3);
for(i = 0; i < b->gcapacity; i++) {
KNH_ADDREF(ctx, b->gf[i].tkIDX);
KNH_ADDREF(ctx, b->gf[i].tk);
}
KNH_ADDREF(ctx, (b->mtd));
KNH_ADDREF(ctx, (b->stmt));
KNH_ADDREF(ctx, (b->lstacks));
KNH_ADDREF(ctx, (b->insts));
KNH_ADDREF(ctx, (b->errmsgs));
KNH_ADDREF(ctx, (b->finallyStmt));
KNH_ADDREF(ctx, ((kGammaBuilder*)o)->scr);
KNH_SIZEREF(ctx);
} | false | false | false | false | false | 0 |
EmitNonLocalJumpFixup(JSContext *cx, JSCodeGenerator *cg, JSStmtInfo *toStmt)
{
intN depth, npops;
JSStmtInfo *stmt;
/*
* The non-local jump fixup we emit will unbalance cg->stackDepth, because
* the fixup replicates balanced code such as JSOP_LEAVEWITH emitted at the
* end of a with statement, so we save cg->stackDepth here and restore it
* just before a successful return.
*/
depth = cg->stackDepth;
npops = 0;
#define FLUSH_POPS() if (npops && !FlushPops(cx, cg, &npops)) return JS_FALSE
for (stmt = cg->topStmt; stmt != toStmt; stmt = stmt->down) {
switch (stmt->type) {
case STMT_FINALLY:
FLUSH_POPS();
if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
return JS_FALSE;
if (EmitBackPatchOp(cx, cg, JSOP_BACKPATCH, &GOSUBS(*stmt)) < 0)
return JS_FALSE;
break;
case STMT_WITH:
/* There's a With object on the stack that we need to pop. */
FLUSH_POPS();
if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
return JS_FALSE;
if (js_Emit1(cx, cg, JSOP_LEAVEWITH) < 0)
return JS_FALSE;
break;
case STMT_FOR_IN_LOOP:
/*
* The iterator and the object being iterated need to be popped.
*/
FLUSH_POPS();
if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
return JS_FALSE;
if (js_Emit1(cx, cg, JSOP_ENDITER) < 0)
return JS_FALSE;
break;
case STMT_SUBROUTINE:
/*
* There's a [exception or hole, retsub pc-index] pair on the
* stack that we need to pop.
*/
npops += 2;
break;
default:;
}
if (stmt->flags & SIF_SCOPE) {
uintN i;
/* There is a Block object with locals on the stack to pop. */
FLUSH_POPS();
if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
return JS_FALSE;
i = OBJ_BLOCK_COUNT(cx, stmt->blockObj);
EMIT_UINT16_IMM_OP(JSOP_LEAVEBLOCK, i);
}
}
FLUSH_POPS();
cg->stackDepth = depth;
return JS_TRUE;
#undef FLUSH_POPS
} | false | false | false | false | false | 0 |
unregister_slave_subprocess (pid_t child)
{
/* The easiest way to remove an entry from a list that can be used by
an asynchronous signal handler is just to mark it as unused. For this,
we rely on sig_atomic_t. */
slaves_entry_t *s = slaves;
slaves_entry_t *s_end = s + slaves_count;
for (; s < s_end; s++)
if (s->used && s->child == child)
s->used = 0;
} | false | false | false | false | false | 0 |
sis_malloc(struct sis_memreq *req)
{
struct sis_video_info *ivideo = sisfb_heap->vinfo;
if(&ivideo->sisfb_heap == sisfb_heap)
sis_int_malloc(ivideo, req);
else
req->offset = req->size = 0;
} | false | false | false | false | false | 0 |
lgs8gxx_write_reg(struct lgs8gxx_state *priv, u8 reg, u8 data)
{
int ret;
u8 buf[] = { reg, data };
struct i2c_msg msg = { .flags = 0, .buf = buf, .len = 2 };
msg.addr = priv->config->demod_address;
if (priv->config->prod != LGS8GXX_PROD_LGS8G75 && reg >= 0xC0)
msg.addr += 0x02;
if (debug >= 2)
dprintk("%s: reg=0x%02X, data=0x%02X\n", __func__, reg, data);
ret = i2c_transfer(priv->i2c, &msg, 1);
if (ret != 1)
dprintk("%s: error reg=0x%x, data=0x%x, ret=%i\n",
__func__, reg, data, ret);
return (ret != 1) ? -1 : 0;
} | false | false | false | false | false | 0 |
xtra_tcl_get(Tcl_Interp * irp, struct userrec *u,
struct user_entry *e, int argc, char **argv)
{
struct xtra_key *x;
BADARGS(3, 4, " handle XTRA ?key?");
if (argc == 4) {
for (x = e->u.extra; x; x = x->next)
if (!egg_strcasecmp(argv[3], x->key)) {
Tcl_AppendResult(irp, x->data, NULL);
return TCL_OK;
}
return TCL_OK;
}
for (x = e->u.extra; x; x = x->next) {
char *p;
EGG_CONST char *list[2];
list[0] = x->key;
list[1] = x->data;
p = Tcl_Merge(2, list);
Tcl_AppendElement(irp, p);
Tcl_Free((char *) p);
}
return TCL_OK;
} | false | false | false | false | false | 0 |
index_iterator__index_entry(index_iterator *ii)
{
const git_index_entry *ie = git_index_get_byindex(ii->index, ii->current);
if (ie != NULL && iterator__past_end(ii, ie->path)) {
ii->current = git_index_entrycount(ii->index);
ie = NULL;
}
return ie;
} | false | false | false | false | false | 0 |
get_length_mbs_utf8_compose( int flags, const char *src, int srclen )
{
int ret = 0;
unsigned int res;
WCHAR composed[2];
const char *srcend = src + srclen;
composed[0] = 0;
while (src < srcend)
{
unsigned char ch = *src++;
if (ch < 0x80) /* special fast case for 7-bit ASCII */
{
composed[0] = ch;
ret++;
continue;
}
if ((res = decode_utf8_char( ch, &src, srcend )) <= 0xffff)
{
if (composed[0])
{
composed[1] = res;
if ((composed[0] = compose( composed ))) continue;
}
composed[0] = res;
ret++;
}
else if (res <= 0x10ffff)
{
ret += 2;
composed[0] = 0; /* no composition for surrogates */
}
else if (flags & MB_ERR_INVALID_CHARS) return -2; /* bad char */
/* otherwise ignore it */
}
return ret;
} | false | false | false | false | false | 0 |
currentIsoCountry() const
{
bool ok;
int country = itemData(currentIndex()).toInt(&ok);
return ok? Utils::countryToIso(QLocale::Country(country)).toUpper() : QString();
} | false | false | false | false | false | 0 |
_show_add_to_group_dialog_on_idle (GSList *pictures)
{
FrogrController *controller = NULL;
FrogrControllerPrivate *priv = NULL;
FrogrModel *model = NULL;
GSList *groups = NULL;
controller = frogr_controller_get_instance ();
priv = FROGR_CONTROLLER_GET_PRIVATE (controller);
/* Keep the source while internally busy */
if (priv->fetching_groups)
return G_SOURCE_CONTINUE;
model = frogr_main_view_get_model (priv->mainview);
groups = frogr_model_get_groups (model);
if (frogr_model_n_groups (model) > 0)
frogr_add_to_group_dialog_show (GTK_WINDOW (priv->mainview), pictures, groups);
else if (priv->groups_fetched)
frogr_util_show_info_dialog (GTK_WINDOW (priv->mainview), _("No groups found"));
priv->show_add_to_group_dialog_source_id = 0;
return G_SOURCE_REMOVE;
} | false | false | false | false | false | 0 |
doDuties()
{
if (!OriginalMsg) {
Log(Error) << "Internal error. Unable to set prefixes: setContext() not called." << LogEnd;
return false;
}
switch(OriginalMsg->getType()) {
case REQUEST_MSG:
case SOLICIT_MSG:
return addPrefixes();
case RELEASE_MSG:
return delPrefixes();
case RENEW_MSG:
case REBIND_MSG:
return updatePrefixes();
default:
break;
}
return true;
} | false | false | false | false | false | 0 |
js_DoubleToECMAUint32(jsdouble d)
{
int32 i;
JSBool neg;
jsdouble two32;
if (!JSDOUBLE_IS_FINITE(d))
return 0;
/*
* We check whether d fits int32, not uint32, as all but the ">>>" bit
* manipulation bytecode stores the result as int, not uint. When the
* result does not fit int jsval, it will be stored as a negative double.
*/
i = (int32) d;
if ((jsdouble) i == d)
return (int32)i;
neg = (d < 0);
d = floor(neg ? -d : d);
d = neg ? -d : d;
two32 = 4294967296.0;
d = fmod(d, two32);
return (uint32) (d >= 0 ? d : d + two32);
} | false | false | false | false | false | 0 |
GH5_FetchAttribute( hid_t loc_id, const char *pszAttrName,
double &dfResult, bool bReportError )
{
hid_t hAttr = H5Aopen_name( loc_id, pszAttrName );
dfResult = 0.0;
if( hAttr < 0 )
{
if( bReportError )
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to read attribute %s failed, not found.",
pszAttrName );
return false;
}
hid_t hAttrTypeID = H5Aget_type( hAttr );
hid_t hAttrNativeType = H5Tget_native_type( hAttrTypeID, H5T_DIR_DEFAULT );
/* -------------------------------------------------------------------- */
/* Confirm that we have a single element value. */
/* -------------------------------------------------------------------- */
hid_t hAttrSpace = H5Aget_space( hAttr );
hsize_t anSize[64];
int nAttrDims = H5Sget_simple_extent_dims( hAttrSpace, anSize, NULL );
int i, nAttrElements = 1;
for( i=0; i < nAttrDims; i++ ) {
nAttrElements *= (int) anSize[i];
}
if( nAttrElements != 1 )
{
if( bReportError )
CPLError( CE_Failure, CPLE_AppDefined,
"Attempt to read attribute %s failed, count=%d, not 1.",
pszAttrName, nAttrElements );
H5Sclose( hAttrSpace );
H5Tclose( hAttrNativeType );
H5Tclose( hAttrTypeID );
H5Aclose( hAttr );
return false;
}
/* -------------------------------------------------------------------- */
/* Read the value. */
/* -------------------------------------------------------------------- */
void *buf = (void *)CPLMalloc( H5Tget_size( hAttrNativeType ));
H5Aread( hAttr, hAttrNativeType, buf );
/* -------------------------------------------------------------------- */
/* Translate to double. */
/* -------------------------------------------------------------------- */
if( H5Tequal( H5T_NATIVE_INT, hAttrNativeType ) )
dfResult = *((int *) buf);
else if( H5Tequal( H5T_NATIVE_FLOAT, hAttrNativeType ) )
dfResult = *((float *) buf);
else if( H5Tequal( H5T_NATIVE_DOUBLE, hAttrNativeType ) )
dfResult = *((double *) buf);
else
{
if( bReportError )
CPLError( CE_Failure, CPLE_AppDefined,
"Attribute %s of unsupported type for conversion to double.",
pszAttrName );
CPLFree( buf );
H5Sclose( hAttrSpace );
H5Tclose( hAttrNativeType );
H5Tclose( hAttrTypeID );
H5Aclose( hAttr );
return false;
}
CPLFree( buf );
H5Sclose( hAttrSpace );
H5Tclose( hAttrNativeType );
H5Tclose( hAttrTypeID );
H5Aclose( hAttr );
return true;
} | false | false | false | false | false | 0 |
do_grxclass(struct cmd_context *ctx)
{
struct ethtool_rxnfc nfccmd;
int err;
if (ctx->argc == 2 && !strcmp(ctx->argp[0], "rx-flow-hash")) {
int rx_fhash_get;
rx_fhash_get = rxflow_str_to_type(ctx->argp[1]);
if (!rx_fhash_get)
exit_bad_args();
nfccmd.cmd = ETHTOOL_GRXFH;
nfccmd.flow_type = rx_fhash_get;
err = send_ioctl(ctx, &nfccmd);
if (err < 0)
perror("Cannot get RX network flow hashing options");
else
dump_rxfhash(rx_fhash_get, nfccmd.data);
} else if (ctx->argc == 2 && !strcmp(ctx->argp[0], "rule")) {
int rx_class_rule_get =
get_uint_range(ctx->argp[1], 0, INT_MAX);
err = rxclass_rule_get(ctx, rx_class_rule_get);
if (err < 0)
fprintf(stderr, "Cannot get RX classification rule\n");
} else if (ctx->argc == 0) {
nfccmd.cmd = ETHTOOL_GRXRINGS;
err = send_ioctl(ctx, &nfccmd);
if (err < 0)
perror("Cannot get RX rings");
else
fprintf(stdout, "%d RX rings available\n",
(int)nfccmd.data);
err = rxclass_rule_getall(ctx);
if (err < 0)
fprintf(stderr, "RX classification rule retrieval failed\n");
} else {
exit_bad_args();
}
return err ? 1 : 0;
} | false | false | false | false | false | 0 |
H5Pget_nlinks(hid_t plist_id, size_t *nlinks)
{
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*z", plist_id, nlinks);
if(!nlinks)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pointer passed in");
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id, H5P_LINK_ACCESS)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* Get the current number of links */
if(H5P_get(plist, H5L_ACS_NLINKS_NAME, nlinks) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of links")
done:
FUNC_LEAVE_API(ret_value)
} | false | false | false | false | false | 0 |
create_handshake_request(FXString & request) {
FXMutexLock lock(mutex_data);
FXTRACE((60,"GMAudioScrobbler::create_handshake_request\n"));
if (mode==SERVICE_LASTFM) {
FXString signature=GMStringFormat("api_key%smethodauth.getSessiontoken%s%s",CLIENT_KEY,token.text(),CLIENT_SECRET);
checksum(signature);
request=GMStringFormat("method=auth.getSession&api_key=%s&api_sig=%s&token=%s",CLIENT_KEY,signature.text(),token.text());
}
else {
FXlong timestamp = FXThread::time()/1000000000;
FXString timestamp_text = GMStringVal(timestamp);
FXString tk = password + timestamp_text;
checksum(tk);
request=GMStringFormat("/?hs=true&p=1.2&c="CLIENT_ID"&v="CLIENT_VERSION"&u=%s&t=%s&a=%s",username.text(),timestamp_text.text(),tk.text());
}
flags&=~(FLAG_LOGIN_CHANGED);
return mode;
} | false | false | false | false | false | 0 |
probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd,
const BIGNUM *rem, BN_CTX *ctx)
{
int i,ret=0;
BIGNUM *t1,*qadd,*q;
bits--;
BN_CTX_start(ctx);
t1 = BN_CTX_get(ctx);
q = BN_CTX_get(ctx);
qadd = BN_CTX_get(ctx);
if (qadd == NULL) goto err;
if (!BN_rshift1(qadd,padd)) goto err;
if (!BN_rand(q,bits,0,1)) goto err;
/* we need ((rnd-rem) % add) == 0 */
if (!BN_mod(t1,q,qadd,ctx)) goto err;
if (!BN_sub(q,q,t1)) goto err;
if (rem == NULL)
{ if (!BN_add_word(q,1)) goto err; }
else
{
if (!BN_rshift1(t1,rem)) goto err;
if (!BN_add(q,q,t1)) goto err;
}
/* we now have a random number 'rand' to test. */
if (!BN_lshift1(p,q)) goto err;
if (!BN_add_word(p,1)) goto err;
loop: for (i=1; i<NUMPRIMES; i++)
{
/* check that p and q are prime */
/* check that for p and q
* gcd(p-1,primes) == 1 (except for 2) */
if ( (BN_mod_word(p,(BN_ULONG)primes[i]) == 0) ||
(BN_mod_word(q,(BN_ULONG)primes[i]) == 0))
{
if (!BN_add(p,p,padd)) goto err;
if (!BN_add(q,q,qadd)) goto err;
goto loop;
}
}
ret=1;
err:
BN_CTX_end(ctx);
bn_check_top(p);
return(ret);
} | false | false | false | false | false | 0 |
do_cmd_wiz_zap(int d)
{
int i;
/* Banish everyone nearby */
for (i = 1; i < mon_max; i++)
{
monster_type *m_ptr = &mon_list[i];
/* Skip dead monsters */
if (!m_ptr->r_idx) continue;
/* Skip distant monsters */
if (m_ptr->cdis > d) continue;
/* Delete the monster */
delete_monster_idx(i);
}
/* Update monster list window */
p_ptr->redraw |= PR_MONLIST;
} | false | false | false | false | false | 0 |
getuser(void)
{
static char user[64];
if(user[0] == 0){
struct passwd *pw = getpwuid(getuid());
strcpy(user, pw ? pw->pw_name : "nobody");
}
return user;
} | false | false | false | false | false | 0 |
watchUpdated()
{
statusBar->clearstatus();
statusBar->status(_("Updating watch list..."));
statusBar->flush();
getServer()->saveFolderIndex(this);
statusBar->status(_("... done"));
} | false | false | false | false | false | 0 |
vpsmemMuckOut( CoreSurfacePool *pool,
void *pool_data,
void *pool_local,
CoreSurfaceBuffer *buffer )
{
CoreSurface *surface;
VPSMemPoolData *data = pool_data;
VPSMemPoolLocalData *local = pool_local;
D_DEBUG_AT( VPSMem_Surfaces, "%s( %p )\n", __FUNCTION__, buffer );
D_MAGIC_ASSERT( pool, CoreSurfacePool );
D_MAGIC_ASSERT( data, VPSMemPoolData );
D_MAGIC_ASSERT( local, VPSMemPoolLocalData );
D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer );
surface = buffer->surface;
D_MAGIC_ASSERT( surface, CoreSurface );
return dfb_surfacemanager_displace( local->core, data->manager, buffer );
} | false | false | false | false | false | 0 |
vmx_get_nmi_mask(struct kvm_vcpu *vcpu)
{
if (!cpu_has_virtual_nmis())
return to_vmx(vcpu)->soft_vnmi_blocked;
if (to_vmx(vcpu)->nmi_known_unmasked)
return false;
return vmcs_read32(GUEST_INTERRUPTIBILITY_INFO) & GUEST_INTR_STATE_NMI;
} | false | false | false | false | false | 0 |
mode_check_assertion (NODE_T * p)
{
SOID_T w, y;
make_soid (&w, STRONG, MODE (BOOL), 0);
mode_check_enclosed (SUB_NEXT (p), &w, &y);
SORT (&y) = SORT (&w); /* Patch */
if (!is_coercible_in_context (&y, &w, NO_DEFLEXING)) {
cannot_coerce (NEXT (p), MOID (&y), MOID (&w), MEEK, NO_DEFLEXING, ENCLOSED_CLAUSE);
}
} | false | false | false | false | false | 0 |
state_new(HTK_HMM_INFO *hmm)
{
HTK_HMM_State *new;
int i;
new = (HTK_HMM_State *)mybmalloc2(sizeof(HTK_HMM_State), &(hmm->mroot));
new->name = NULL;
new->nstream = hmm->opt.stream_info.num;
new->w = NULL;
new->pdf = (HTK_HMM_PDF **)mybmalloc2(sizeof(HTK_HMM_PDF *) * new->nstream, &(hmm->mroot));
for(i=0;i<new->nstream;i++) {
new->pdf[i] = NULL;
}
new->id = 0;
new->next = NULL;
return(new);
} | false | false | false | false | false | 0 |
auth() const
{
Auth ret;
const char* sp = getHeader("Authorization");
if (!sp)
return ret;
std::string s = sp;
std::string::size_type p = s.find(' ');
if (p == std::string::npos)
return ret;
std::istringstream in(s);
in.ignore(p + 1);
cxxtools::BasicTextIStream<char, char> b(in, new cxxtools::Base64Codec());
std::getline(b, ret.user, ':');
std::getline(b, ret.password);
return ret;
} | false | false | false | false | false | 0 |
readTriMesh(const std::string& meshfilename)
{
console.XDebug() << "CLatticeMaster::readTriMesh(" << meshfilename << ")\n";
// buffers
MeshNodeDataVector node_send_buffer;
MeshTriDataVector tri_send_buffer;
// mesh reader
MeshReader reader(meshfilename);
// --- Nodes ---
MeshReader::NodeIterator &niter=reader.getNodeIterator();
// read nodes into vector
while(niter.hasNext()){
node_send_buffer.push_back(niter.next());
}
// --- Triangles ---
MeshReader::TriIterator &titer=reader.getTriIterator();
// read triangles into vector
while(titer.hasNext()){
tri_send_buffer.push_back(titer.next());
}
return TriMeshDataPair(node_send_buffer, tri_send_buffer);
} | false | false | false | false | false | 0 |
imx_pcm_dma_init(struct platform_device *pdev, size_t size)
{
struct snd_dmaengine_pcm_config *config;
struct snd_pcm_hardware *pcm_hardware;
config = devm_kzalloc(&pdev->dev,
sizeof(struct snd_dmaengine_pcm_config), GFP_KERNEL);
*config = imx_dmaengine_pcm_config;
if (size)
config->prealloc_buffer_size = size;
pcm_hardware = devm_kzalloc(&pdev->dev,
sizeof(struct snd_pcm_hardware), GFP_KERNEL);
*pcm_hardware = imx_pcm_hardware;
if (size)
pcm_hardware->buffer_bytes_max = size;
config->pcm_hardware = pcm_hardware;
return devm_snd_dmaengine_pcm_register(&pdev->dev,
config,
SND_DMAENGINE_PCM_FLAG_COMPAT);
} | false | false | false | false | false | 0 |
globus_l_gfs_remote_node_request(
globus_l_gfs_remote_handle_t * my_handle,
int num_nodes,
char * repo_name,
globus_l_gfs_remote_node_cb callback,
void * user_arg)
{
int nodes_created = 0;
int ndx_offset = 0;
globus_result_t result = GLOBUS_SUCCESS;
globus_l_gfs_remote_control_node_bounce_t * bounce;
GlobusGFSName(globus_l_gfs_remote_node_request);
GlobusGFSRemoteDebugEnter();
if(!callback)
{
goto error;
}
if(my_handle->control_node)
{
bounce = (globus_l_gfs_remote_control_node_bounce_t *) globus_calloc(
1, sizeof(globus_l_gfs_remote_control_node_bounce_t));
bounce->my_handle = my_handle;
bounce->callback = callback;
bounce->user_arg = user_arg;
nodes_created = 1;
ndx_offset = 1;
result = globus_callback_register_oneshot(
NULL,
NULL,
globus_l_gfs_remote_node_request_fake_kickout,
bounce);
if(result != GLOBUS_SUCCESS)
{
globus_free(bounce);
goto error;
}
}
num_nodes -= nodes_created;
if(num_nodes > 0 || nodes_created == 0)
{
bounce = (globus_l_gfs_remote_control_node_bounce_t *) globus_calloc(
1, sizeof(globus_l_gfs_remote_control_node_bounce_t));
bounce->my_handle = my_handle;
bounce->callback = callback;
bounce->user_arg = user_arg;
bounce->num_nodes = num_nodes;
bounce->ndx_offset = ndx_offset;
bounce->repo = NULL; /* maybe some day */
GlobusTimeReltimeSet(bounce->retry_time, 1, 0);
globus_l_gfs_remote_select_nodes(bounce);
}
GlobusGFSRemoteDebugExit();
return GLOBUS_SUCCESS;
error:
GlobusGFSRemoteDebugExitWithError();
return result;
} | false | false | false | false | false | 0 |
trigger_key_use (edict_t * self, edict_t * other, edict_t * activator)
{
int index;
if (!self->item)
return;
if (!activator->client)
return;
index = ITEM_INDEX (self->item);
if (!activator->client->pers.inventory[index])
{
if (level.time < self->touch_debounce_time)
return;
self->touch_debounce_time = level.time + 5.0;
gi.centerprintf (activator, "You need the %s", self->item->pickup_name);
gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keytry.wav"), 1,
ATTN_NORM, 0);
return;
}
gi.sound (activator, CHAN_AUTO, gi.soundindex ("misc/keyuse.wav"), 1,
ATTN_NORM, 0);
if (coop->value)
{
int player;
edict_t *ent;
if (strcmp (self->item->classname, "key_power_cube") == 0)
{
int cube;
for (cube = 0; cube < 8; cube++)
if (activator->client->pers.power_cubes & (1 << cube))
break;
for (player = 1; player <= game.maxclients; player++)
{
ent = &g_edicts[player];
if (!ent->inuse)
continue;
if (!ent->client)
continue;
if (ent->client->pers.power_cubes & (1 << cube))
{
ent->client->pers.inventory[index]--;
ent->client->pers.power_cubes &= ~(1 << cube);
}
}
}
else
{
for (player = 1; player <= game.maxclients; player++)
{
ent = &g_edicts[player];
if (!ent->inuse)
continue;
if (!ent->client)
continue;
ent->client->pers.inventory[index] = 0;
}
}
}
else
{
activator->client->pers.inventory[index]--;
}
G_UseTargets (self, activator);
self->use = NULL;
} | false | false | false | false | false | 0 |
trace_distinct_msg(char *prefix, FILE *f, char *s, va_list args)
{
GSList *list=trace_buffer;
gchar *str=g_strdup_vprintf((gchar *)s, args);
int cksum=trace_cksum((const char *)str);
int *pcksum;
gboolean ignore=FALSE;
while (list) {
if ((*(int *)(list->data))==cksum) {
ignore=TRUE;
break;
}
list=list->next;
}
if (!ignore) {
pcksum=g_malloc(sizeof(int));
*pcksum=cksum;
trace_buffer=g_slist_append(trace_buffer, pcksum);
g_fprintf(f, "%s%s%s", trace_indent, prefix, str);
g_fprintf(f, "\n");
}
g_free(str);
} | false | false | false | false | false | 0 |
ipv6_scan(const char* s, ipv6addr* addr)
{
uint16 bits[8];
unsigned len1;
unsigned len2;
unsigned i;
len1 = len2 = 0;
if (s[0] == ':' && s[1] == ':')
++s;
else {
while (len1 < 8) {
const char* news;
if ((news = parse_hexpart(s, &bits[len1])) == 0 ||
(news == s && *news != ':'))
return 0;
s = news + (*news == ':');
++len1;
if (*s == ':')
break;
}
for (i = 0; i < len1; ++i)
set(addr, i, bits[i]);
}
if (len1 < 8) {
++s;
while (len2 < 8-len1) {
const char* news;
if ((news = parse_hexpart(s, &bits[len2])) == 0)
return 0;
if (news == s) break;
s = news;
++len2;
if (*s != ':') break;
++s;
}
for (i = len1; i < 8-len2; ++i)
set(addr, i, 0);
for (i = 0; i < len2; ++i)
set(addr, i+8-len2, bits[i]);
}
/* handle IPv4 convenience addresses */
if (len1+len2 <= 6 && *s == '.') {
ipv4addr i4;
while (*--s != ':') ;
++s;
--len2;
for (i = len1; i < 6-len2; ++i)
set(addr, i, 0);
for (i = 0; i < len2; ++i)
set(addr, i+6-len2, bits[i]);
// Parse IPv4 address here
if ((s = ipv4_scan(s, &i4)) == 0)
return 0;
addr->addr[12] = i4.addr[0];
addr->addr[13] = i4.addr[1];
addr->addr[14] = i4.addr[2];
addr->addr[15] = i4.addr[3];
}
return s;
} | false | false | false | false | true | 1 |
devres_remove_group(struct device *dev, void *id)
{
struct devres_group *grp;
unsigned long flags;
spin_lock_irqsave(&dev->devres_lock, flags);
grp = find_group(dev, id);
if (grp) {
list_del_init(&grp->node[0].entry);
list_del_init(&grp->node[1].entry);
devres_log(dev, &grp->node[0], "REM");
} else
WARN_ON(1);
spin_unlock_irqrestore(&dev->devres_lock, flags);
kfree(grp);
} | false | false | false | false | false | 0 |
prescriptionHasAllergies()
{
if (!d->m_AllergyEngine)
return false;
foreach(const IDrug *drug, d->m_DrugsList) {
d->m_AllergyEngine->check(DrugsDB::IDrugAllergyEngine::Allergy, drug->drugId().toString());
if (d->m_AllergyEngine->has(DrugsDB::IDrugAllergyEngine::Allergy, drug->drugId().toString())) {
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.