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 |
|---|---|---|---|---|---|---|
test_ensure_async_plain (Test *test,
gconstpointer unused)
{
GAsyncResult *result = NULL;
GError *error = NULL;
gboolean ret;
secret_service_ensure_session (test->service, NULL, on_complete_get_result, &result);
egg_test_wait ();
g_assert (G_IS_ASYNC_RESULT (result));
ret = secret_service_ensure_session_finish (test->service, result, &error);
g_assert_no_error (error);
g_assert (ret == TRUE);
g_assert_cmpstr (secret_service_get_session_dbus_path (test->service), !=, NULL);
g_assert_cmpstr (secret_service_get_session_algorithms (test->service), ==, "plain");
g_object_unref (result);
} | false | false | false | false | false | 0 |
computeAutoMode()
{
QString suffix = QFileInfo(fileName).suffix();
QString firstLine = e->document()->begin().text();
QRegExp re("-\\*-\\s(\\S+)\\s+-\\*-");
bool ok = false;
if (! ok && re.indexIn(firstLine) >= 0)
ok = e->setEditorMode(re.cap(1));
if (! ok && ! suffix.isEmpty())
ok = e->setEditorMode(suffix);
if (! ok)
ok = e->setEditorMode(0);
q->updateActionsLater();
} | false | false | false | false | false | 0 |
_set_inpoint (GESTimelineElement * element, GstClockTime inpoint)
{
GList *tmp;
GESContainer *container = GES_CONTAINER (element);
for (tmp = container->children; tmp; tmp = g_list_next (tmp)) {
GESTimelineElement *child = (GESTimelineElement *) tmp->data;
ChildMapping *map = g_hash_table_lookup (container->priv->mappings, child);
map->inpoint_offset = inpoint - _INPOINT (child);
}
return TRUE;
} | false | false | false | false | false | 0 |
decoder_query_position_fold (const GValue * item, GValue * ret,
QueryFold * fold)
{
GstPad *pad = g_value_get_object (item);
if (gst_pad_query (pad, fold->query)) {
gint64 position;
g_value_set_boolean (ret, TRUE);
gst_query_parse_position (fold->query, NULL, &position);
GST_DEBUG_OBJECT (item, "got position %" G_GINT64_FORMAT, position);
if (position > fold->max)
fold->max = position;
}
return TRUE;
} | false | false | false | false | false | 0 |
filesystem_is_query_match(sefs_filesystem * fs, const sefs_query * query, const char *path, const char *dev,
const struct stat64 * sb, apol_vector_t * type_list,
apol_mls_range_t * range)throw(std::runtime_error)
{
return fs->isQueryMatch(query, path, dev, sb, type_list, range);
} | false | false | false | false | false | 0 |
pkix_pl_Cert_DecodeInhibitAnyPolicy(
CERTCertificate *nssCert,
PKIX_Int32 *pSkipCerts,
void *plContext)
{
CERTCertificateInhibitAny inhibitAny;
SECStatus rv;
SECItem encodedCertInhibitAny;
PKIX_Int32 skipCerts = -1;
PKIX_ENTER(CERT, "pkix_pl_Cert_DecodeInhibitAnyPolicy");
PKIX_NULLCHECK_TWO(nssCert, pSkipCerts);
/* get InhibitAny as a SECItem */
PKIX_CERT_DEBUG("\t\tCalling CERT_FindCertExtension).\n");
rv = CERT_FindCertExtension
(nssCert, SEC_OID_X509_INHIBIT_ANY_POLICY, &encodedCertInhibitAny);
if (rv == SECSuccess) {
inhibitAny.inhibitAnySkipCerts.data =
(unsigned char *)&skipCerts;
/* translate DER to CERTCertificateInhibitAny */
rv = CERT_DecodeInhibitAnyExtension
(&inhibitAny, &encodedCertInhibitAny);
PORT_Free(encodedCertInhibitAny.data);
if (rv != SECSuccess) {
PKIX_ERROR(PKIX_CERTDECODEINHIBITANYEXTENSIONFAILED);
}
}
*pSkipCerts = skipCerts;
cleanup:
PKIX_RETURN(CERT);
} | false | false | false | false | false | 0 |
check_if_ca (gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer,
unsigned int flags)
{
gnutls_datum_t cert_signed_data = { NULL, 0 };
gnutls_datum_t issuer_signed_data = { NULL, 0 };
gnutls_datum_t cert_signature = { NULL, 0 };
gnutls_datum_t issuer_signature = { NULL, 0 };
int result;
/* Check if the issuer is the same with the
* certificate. This is added in order for trusted
* certificates to be able to verify themselves.
*/
result =
_gnutls_x509_get_signed_data (issuer->cert, "tbsCertificate",
&issuer_signed_data);
if (result < 0)
{
gnutls_assert ();
goto fail;
}
result =
_gnutls_x509_get_signed_data (cert->cert, "tbsCertificate",
&cert_signed_data);
if (result < 0)
{
gnutls_assert ();
goto fail;
}
result =
_gnutls_x509_get_signature (issuer->cert, "signature", &issuer_signature);
if (result < 0)
{
gnutls_assert ();
goto fail;
}
result =
_gnutls_x509_get_signature (cert->cert, "signature", &cert_signature);
if (result < 0)
{
gnutls_assert ();
goto fail;
}
/* If the subject certificate is the same as the issuer
* return true.
*/
if (!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_SAME))
if (cert_signed_data.size == issuer_signed_data.size)
{
if ((memcmp (cert_signed_data.data, issuer_signed_data.data,
cert_signed_data.size) == 0) &&
(cert_signature.size == issuer_signature.size) &&
(memcmp (cert_signature.data, issuer_signature.data,
cert_signature.size) == 0))
{
result = 1;
goto cleanup;
}
}
result = gnutls_x509_crt_get_ca_status (issuer, NULL);
if (result == 1)
{
result = 1;
goto cleanup;
}
/* Handle V1 CAs that do not have a basicConstraint, but accept
these certs only if the appropriate flags are set. */
else if ((result == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) &&
((flags & GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT) ||
(!(flags & GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT) &&
(gnutls_x509_crt_check_issuer (issuer, issuer) == 1))))
{
gnutls_assert ();
result = 1;
goto cleanup;
}
else
gnutls_assert ();
fail:
result = 0;
cleanup:
_gnutls_free_datum (&cert_signed_data);
_gnutls_free_datum (&issuer_signed_data);
_gnutls_free_datum (&cert_signature);
_gnutls_free_datum (&issuer_signature);
return result;
} | false | false | false | false | false | 0 |
bus_connection_get_loginfo (DBusConnection *connection)
{
BusConnectionData *d;
d = BUS_CONNECTION_DATA (connection);
if (!bus_connection_is_active (connection))
return "inactive";
return d->cached_loginfo_string;
} | false | false | false | false | false | 0 |
wb_ffr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno)
{
wb_local_t *local = NULL;
wb_file_t *file = NULL;
GF_ASSERT (frame);
local = frame->local;
file = local->file;
if (file != NULL) {
LOCK (&file->lock);
{
if (file->op_ret == -1) {
op_ret = file->op_ret;
op_errno = file->op_errno;
file->op_ret = 0;
}
}
UNLOCK (&file->lock);
}
STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno);
return 0;
} | false | false | false | true | false | 1 |
simBranching(long N, BranchingInfo den) {
return den.actualCount>0 ?
double(actualCount) / double(den.actualCount) :
double(actualCount) / double(N) ;
} | false | false | false | false | false | 0 |
image_create( SDL_Surface *img, int buf_w, int buf_h, SDL_Surface *surf, int x, int y )
{
Image *image;
if ( img == 0 ) {
fprintf( stderr, "image_create: passed graphic is NULL: %s\n", SDL_GetError() );
return 0;
}
image = calloc( 1, sizeof( Image ) );
image->img = img;
if ( buf_w == 0 || buf_h == 0 ) {
buf_w = image->img->w;
buf_h = image->img->h;
}
image->img_rect.w = buf_w;
image->img_rect.h = buf_h;
image->img_rect.x = image->img_rect.y = 0;
if ( ( image->bkgnd = buffer_create( buf_w, buf_h, surf, x, y ) ) == 0 ) {
SDL_FreeSurface( img );
free( image );
return 0;
}
SDL_SetColorKey( image->img, SDL_SRCCOLORKEY, 0x0 );
return image;
} | false | false | false | false | false | 0 |
OnDrawPolygon( wxCommandEvent &WXUNUSED(event) )
{
dynamic_cast<GraphicsPage*>(ExGlobals::GetVisualizationWindow()->GetPage())->SetPolygonPlacementMode();
std::vector<wxString> lines;
switch( polygonType_ )
{
case 1:
lines.push_back( wxString(wxT("Left click in the visualization window to choose a corner of the rectangle,")) );
lines.push_back( wxString(wxT("then left click again to choose the diagonally opposite corner")) );
break;
case 2:
lines.push_back( wxString(wxT("Left click in the visualization window to choose the centre of the polygon,")) );
lines.push_back( wxString(wxT("then left click again to choose the radius of the circumscribed circle")) );
break;
case 3:
lines.push_back( wxString(wxT("Left click in the visualization window to choose the centre of the star,")) );
lines.push_back( wxString(wxT("then left click again to choose the radius of the circumscribed circle")) );
break;
}
ExGlobals::ShowHint( lines );
} | false | false | false | false | false | 0 |
nickpad_string_create(channel_t *chan)
{
int i;
chan->nickpad_len = (chan->longest_nick + 1) * fillchars_len;
xfree (chan->nickpad_str);
chan->nickpad_str = (char *)xmalloc(chan->nickpad_len);
/* fill string */
for (i = 0; i < chan->nickpad_len; i++)
chan->nickpad_str[i] = fillchars[ i % fillchars_len ];
debug("created NICKPAD with len: %d\n", chan->nickpad_len);
return chan->nickpad_str;
} | false | false | false | false | false | 0 |
ipmi_wdog_pretimeout_handler(void *handler_data)
{
if (preaction_val != WDOG_PRETIMEOUT_NONE) {
if (preop_val == WDOG_PREOP_PANIC) {
if (atomic_inc_and_test(&preop_panic_excl))
panic("Watchdog pre-timeout");
} else if (preop_val == WDOG_PREOP_GIVE_DATA) {
spin_lock(&ipmi_read_lock);
data_to_read = 1;
wake_up_interruptible(&read_q);
kill_fasync(&fasync_q, SIGIO, POLL_IN);
spin_unlock(&ipmi_read_lock);
}
}
/*
* On some machines, the heartbeat will give an error and not
* work unless we re-enable the timer. So do so.
*/
pretimeout_since_last_heartbeat = 1;
} | false | false | false | false | false | 0 |
right_mult_with_vector(vtx_data * matrix, int n, double *vector,
double *result)
{
int i, j;
double res;
for (i = 0; i < n; i++) {
res = 0;
for (j = 0; j < matrix[i].nedges; j++)
res += matrix[i].ewgts[j] * vector[matrix[i].edges[j]];
result[i] = res;
}
/* orthog1(n,vector); */
} | false | false | false | false | false | 0 |
VSNPrintF(Vector<char> str,
const char* format,
va_list args) {
int n = vsnprintf(str.start(), str.length(), format, args);
if (n < 0 || n >= str.length()) {
// If the length is zero, the assignment fails.
if (str.length() > 0)
str[str.length() - 1] = '\0';
return -1;
} else {
return n;
}
} | false | false | false | false | false | 0 |
cdio_generic_free (void *p_user_data)
{
generic_img_private_t *p_env = p_user_data;
track_t i_track;
if (NULL == p_env) return;
if (p_env->source_name) free (p_env->source_name);
if (p_env->b_cdtext_init) {
for (i_track=0; i_track < p_env->i_tracks; i_track++) {
cdtext_destroy(&(p_env->cdtext_track[i_track]));
}
}
if (p_env->fd >= 0)
close (p_env->fd);
if (p_env->scsi_tuple != NULL)
free (p_env->scsi_tuple);
free (p_env);
} | false | false | false | false | false | 0 |
strpcmp(char const * str, char const * pfx, char const * delim) {
if(str == NULL || pfx == NULL) return -1;
while(*pfx == *str && *pfx != '\0') ++str, ++pfx;
return (*pfx == '\0' && strchr(delim, *str) ? 0 : *str - *pfx);
} | false | false | false | false | false | 0 |
init_mparams(void) {
#ifdef NEED_GLOBAL_LOCK_INIT
if (malloc_global_mutex_status <= 0)
init_malloc_global_mutex();
#endif
ACQUIRE_MALLOC_GLOBAL_LOCK();
if (mparams.magic == 0) {
size_t magic;
size_t psize;
size_t gsize;
#ifndef WIN32
psize = malloc_getpagesize;
gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize);
#else /* WIN32 */
{
SYSTEM_INFO system_info;
GetSystemInfo(&system_info);
psize = system_info.dwPageSize;
gsize = ((DEFAULT_GRANULARITY != 0)?
DEFAULT_GRANULARITY : system_info.dwAllocationGranularity);
}
#endif /* WIN32 */
/* Sanity-check configuration:
size_t must be unsigned and as wide as pointer type.
ints must be at least 4 bytes.
alignment must be at least 8.
Alignment, min chunk size, and page size must all be powers of 2.
*/
if ((sizeof(size_t) != sizeof(char*)) ||
(MAX_SIZE_T < MIN_CHUNK_SIZE) ||
(sizeof(int) < 4) ||
(MALLOC_ALIGNMENT < (size_t)8U) ||
((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) ||
((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) ||
((gsize & (gsize-SIZE_T_ONE)) != 0) ||
((psize & (psize-SIZE_T_ONE)) != 0))
ABORT;
mparams.granularity = gsize;
mparams.page_size = psize;
mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD;
mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD;
#if MORECORE_CONTIGUOUS
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT;
#else /* MORECORE_CONTIGUOUS */
mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT;
#endif /* MORECORE_CONTIGUOUS */
#if !ONLY_MSPACES
/* Set up lock for main malloc area */
gm->mflags = mparams.default_mflags;
(void)INITIAL_LOCK(&gm->mutex);
#endif
{
#if USE_DEV_RANDOM
int fd;
unsigned char buf[sizeof(size_t)];
/* Try to use /dev/urandom, else fall back on using time */
if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 &&
read(fd, buf, sizeof(buf)) == sizeof(buf)) {
magic = *((size_t *) buf);
close(fd);
}
else
#endif /* USE_DEV_RANDOM */
#ifdef WIN32
magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U);
#elif defined(LACKS_TIME_H)
magic = (size_t)&magic ^ (size_t)0x55555555U;
#else
magic = (size_t)(time(0) ^ (size_t)0x55555555U);
#endif
magic |= (size_t)8U; /* ensure nonzero */
magic &= ~(size_t)7U; /* improve chances of fault for bad values */
/* Until memory modes commonly available, use volatile-write */
(*(volatile size_t *)(&(mparams.magic))) = magic;
}
}
RELEASE_MALLOC_GLOBAL_LOCK();
return 1;
} | false | false | false | false | false | 0 |
_rtl92d_phy_restore_rf_env(struct ieee80211_hw *hw, u8 rfpath,
u32 *pu4_regval)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_phy *rtlphy = &(rtlpriv->phy);
struct bb_reg_def *pphyreg = &rtlphy->phyreg_def[rfpath];
RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "=====>\n");
/*----Restore RFENV control type----*/
switch (rfpath) {
case RF90_PATH_A:
case RF90_PATH_C:
rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV, *pu4_regval);
break;
case RF90_PATH_B:
case RF90_PATH_D:
rtl_set_bbreg(hw, pphyreg->rfintfs, BRFSI_RFENV << 16,
*pu4_regval);
break;
}
RT_TRACE(rtlpriv, COMP_RF, DBG_LOUD, "<=====\n");
} | false | false | false | false | false | 0 |
expand_epilogue ()
{
int size;
register int regno;
int return_size;
rtx scratch;
if (reload_completed != 1)
abort ();
size = get_frame_size ();
/* If we are returning a value in two registers, we have to preserve the
X register and use the Y register to restore the stack and the saved
registers. Otherwise, use X because it's faster (and smaller). */
if (current_function_return_rtx == 0)
return_size = 0;
else if (GET_CODE (current_function_return_rtx) == MEM)
return_size = HARD_REG_SIZE;
else
return_size = GET_MODE_SIZE (GET_MODE (current_function_return_rtx));
if (return_size > HARD_REG_SIZE && return_size <= 2 * HARD_REG_SIZE)
scratch = iy_reg;
else
scratch = ix_reg;
/* Pop any 2 byte pseudo hard registers that we saved. */
for (regno = SOFT_REG_LAST; regno >= SOFT_REG_FIRST; regno--)
{
if (regs_ever_live[regno] && !call_used_regs[regno])
{
emit_move_after_reload (gen_rtx (REG, HImode, regno),
stack_pop_word, scratch);
}
}
/* de-allocate auto variables */
if (TARGET_M6812 && (size > 4 || size == 3))
{
emit_insn (gen_addhi3 (stack_pointer_rtx,
stack_pointer_rtx, GEN_INT (size)));
}
else if ((!optimize_size && size > 8) || (optimize_size && size > 10))
{
rtx insn;
insn = gen_rtx_PARALLEL
(VOIDmode,
gen_rtvec (2,
gen_rtx_SET (VOIDmode,
stack_pointer_rtx,
gen_rtx_PLUS (HImode,
stack_pointer_rtx,
GEN_INT (size))),
gen_rtx_CLOBBER (VOIDmode, scratch)));
emit_insn (insn);
}
else
{
int i;
for (i = 2; i <= size; i += 2)
emit_move_after_reload (scratch, stack_pop_word, scratch);
if (size & 1)
emit_insn (gen_addhi3 (stack_pointer_rtx,
stack_pointer_rtx, GEN_INT (1)));
}
/* For an interrupt handler, restore ZTMP, ZREG and XYREG. */
if (current_function_interrupt)
{
emit_move_after_reload (gen_rtx (REG, HImode, SOFT_SAVED_XY_REGNUM),
stack_pop_word, scratch);
emit_move_after_reload (gen_rtx (REG, HImode, SOFT_Z_REGNUM),
stack_pop_word, scratch);
emit_move_after_reload (m68hc11_soft_tmp_reg, stack_pop_word, scratch);
}
/* Restore previous frame pointer. */
if (frame_pointer_needed)
emit_move_after_reload (hard_frame_pointer_rtx, stack_pop_word, scratch);
/* If the trap handler returns some value, copy the value
in D, X onto the stack so that the rti will pop the return value
correctly. */
else if (current_function_trap && return_size != 0)
{
rtx addr_reg = stack_pointer_rtx;
if (!TARGET_M6812)
{
emit_move_after_reload (scratch, stack_pointer_rtx, 0);
addr_reg = scratch;
}
emit_move_after_reload (gen_rtx (MEM, HImode,
gen_rtx (PLUS, HImode, addr_reg,
GEN_INT (1))), d_reg, 0);
if (return_size > HARD_REG_SIZE)
emit_move_after_reload (gen_rtx (MEM, HImode,
gen_rtx (PLUS, HImode, addr_reg,
GEN_INT (3))), ix_reg, 0);
}
emit_jump_insn (gen_return ());
} | true | true | false | false | true | 1 |
get_mp_bits (void)
{
if (user_mp_bits >= DEFAULT_MP_BITS) {
return user_mp_bits;
} else {
char *s = getenv("GRETL_MP_BITS");
int b;
if (s != NULL) {
b = atoi(s);
if (mp_bits_ok(b)) {
return b;
}
}
return DEFAULT_MP_BITS;
}
} | false | false | false | false | true | 1 |
getConfiguration(CmtDeviceConfiguration& configuration)
{
CMT3LOG("L3: getConfiguration\n");
CMT3EXITLOG;
if (!(m_serial.isOpen() || m_logFile.isOpen()))
return m_lastResult = XRV_INVALIDOPERATION;
memcpy(&configuration,&m_config,sizeof(CmtDeviceConfiguration));
if (m_logging)
{
// fake the message receipt
Message msg(CMT_MID_CONFIGURATION,98 + CMT_CONF_BLOCKLEN*m_config.m_numberOfDevices);
msg.setBusId(CMT_BID_MASTER);
msg.setDataLong(m_config.m_masterDeviceId, 0);
msg.setDataShort(m_config.m_samplingPeriod, 4);
msg.setDataShort(m_config.m_outputSkipFactor, 6);
msg.setDataShort(m_config.m_syncinMode, 8);
msg.setDataShort(m_config.m_syncinSkipFactor, 10);
msg.setDataLong(m_config.m_syncinOffset, 12);
memcpy(msg.getDataBuffer(16), m_config.m_date,8);
memcpy(msg.getDataBuffer(24), m_config.m_time, 8);
memcpy(msg.getDataBuffer(32), m_config.m_reservedForHost,32);
memcpy(msg.getDataBuffer(64), m_config.m_reservedForClient,32);
msg.setDataShort(m_config.m_numberOfDevices, 96);
for (uint16_t i = 0; i < m_config.m_numberOfDevices; ++i)
{
msg.setDataLong(m_config.m_deviceInfo[i].m_deviceId, 98+i*20);
msg.setDataShort(m_config.m_deviceInfo[i].m_dataLength, 102+i*20);
msg.setDataShort(m_config.m_deviceInfo[i].m_outputMode, 104+i*20);
msg.setDataLong(m_config.m_deviceInfo[i].m_outputSettings, 106+i*20);
memcpy(msg.getDataBuffer(110+i*20), m_config.m_deviceInfo[i].m_reserved,8);
}
msg.recomputeChecksum();
writeMessageToLogFile(msg);
}
return m_lastResult = XRV_OK;
} | false | false | false | false | false | 0 |
e_source_viewer_set_selected_source (ESourceViewer *viewer,
ESource *source)
{
GHashTable *source_index;
GtkTreeRowReference *reference;
GtkTreePath *path;
gboolean success;
g_return_val_if_fail (E_IS_SOURCE_VIEWER (viewer), FALSE);
g_return_val_if_fail (E_IS_SOURCE (source), FALSE);
source_index = viewer->source_index;
reference = g_hash_table_lookup (source_index, source);
if (!gtk_tree_row_reference_valid (reference))
return FALSE;
path = gtk_tree_row_reference_get_path (reference);
success = e_source_viewer_set_selected_path (viewer, path);
gtk_tree_path_free (path);
return success;
} | false | false | false | false | false | 0 |
netflush (void)
{
register int n, n1;
#ifdef ENCRYPTION
if (encrypt_output)
ring_encrypt (&netoring, encrypt_output);
#endif /* ENCRYPTION */
if ((n1 = n = ring_full_consecutive (&netoring)) > 0)
{
if (!ring_at_mark (&netoring))
{
n = send (net, (char *) netoring.consume, n, 0); /* normal write */
}
else
{
/*
* In 4.2 (and 4.3) systems, there is some question about
* what byte in a sendOOB operation is the "OOB" data.
* To make ourselves compatible, we only send ONE byte
* out of band, the one WE THINK should be OOB (though
* we really have more the TCP philosophy of urgent data
* rather than the Unix philosophy of OOB data).
*/
n = send (net, (char *) netoring.consume, 1, MSG_OOB); /* URGENT data */
}
}
if (n < 0)
{
if (errno != ENOBUFS && errno != EWOULDBLOCK)
{
setcommandmode ();
perror (hostname);
(void) NetClose (net);
ring_clear_mark (&netoring);
longjmp (peerdied, -1);
}
n = 0;
}
if (netdata && n)
{
Dump ('>', netoring.consume, n);
}
if (n)
{
ring_consumed (&netoring, n);
/*
* If we sent all, and more to send, then recurse to pick
* up the other half.
*/
if ((n1 == n) && ring_full_consecutive (&netoring))
{
(void) netflush ();
}
return 1;
}
else
{
return 0;
}
} | false | false | false | false | false | 0 |
new_trule_node(Fsa fsa, int n)
{
Trule *t, *tnew;
/* Allocate and initialize the node */
tnew = OOGLNewE(Trule, "Trule *");
if (tnew == NULL) return(NULL);
tnew->c = '\1';
tnew->ns = REJECT;
tnew->next = NULL;
/* Install it in tlist of state n */
if (fsa->state[n]->tlist == NULL) {
/* List is empty: */
fsa->state[n]->tlist = tnew;
}
else {
/* List is not empty; set t = last node in list, then add tnew to end */
t = fsa->state[n]->tlist;
while (t->next != NULL) t = t->next;
t->next = tnew;
}
/* Return ptr to the new trule node */
return(tnew);
} | false | false | false | false | false | 0 |
vxml_handle_tag(vxml_parser_t *vp, const struct vxml_uctx *ctx)
{
uint32 uc;
bool seen_space;
bool need_space;
bool empty, error;
/*
* Starting a new tag, cleanup context.
*/
vp->tags++;
vxml_output_discard(&vp->out);
xattr_table_free_null(&vp->attrs);
/*
* If we haven't seen the leading "<?xml ...?>" and we're at the second
* tag already, then it's necessarily an XML 1.0 document.
*/
if (!(vp->flags & VXML_F_XML_DECL) && vp->tags > 1) {
vp->major = 1;
vp->minor = 0;
vp->versource = VXML_VERSRC_IMPLIED;
vp->flags |= VXML_F_XML_DECL;
}
uc = vxml_next_char(vp);
if (VXC_NUL == uc) {
vxml_fatal_error(vp, VXML_E_TRUNCATED_INPUT);
return FALSE;
}
if (vxml_debugging(18))
vxml_parser_debug(vp, "vxml_handle_tag: next char is U+%X '%c'",
uc, is_ascii_print(uc) ? uc & 0xff : ' ');
/*
* If we're not starting an element tag, re-route.
*/
if (VXC_QM == uc) /* '?' introduces processing instructions */
return vxml_handle_pi(vp);
else if (VXC_BANG == uc) /* '!' introduces declarations */
return vxml_handle_decl(vp, TRUE);
else if (VXC_SLASH == uc) /* '/' marks the end tag */
return vxml_handle_tag_end(vp, ctx);
/*
* Count real (content-holding) tags, as opposed to processing instructions,
* comments or DTD-related tags.
*
* This matters when sub-parsing, because we don't want to stop parsing
* until we've seen at least one content-holding tag: the sub-root of the
* fragment we're parsing.
*/
vp->loc.tag_start++;
vp->glob.tag_start++;
/*
* This is a tag start, collect its name in the output buffer.
*
* STag ::= '<' Name (S Attribute)* S? '>'
* EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* Note that there is no space allowed in the grammar between '<' and the
* start of the element name.
*/
if (!vxml_parser_handle_name(vp, &vp->out, uc))
return FALSE;
seen_space = FALSE;
/*
* Handle attributes until we reach the end of the tag.
*/
need_space = TRUE;
for (;;) {
/*
* We are right after the tag name, or after an attribute.
*/
uc = vxml_next_char(vp);
if (vxml_parser_tag_has_ended(vp, uc, &error, &empty)) {
vp->elem_no_content = empty;
break;
} else if (error) {
return FALSE;
}
if (need_space) {
if (vxml_parser_swallow_spaces(vp, uc)) {
if (!seen_space) {
vxml_parser_new_element(vp);
seen_space = TRUE; /* Flags that element was created */
}
need_space = FALSE;
continue;
} else {
vxml_fatal_error_last(vp, VXML_E_UNEXPECTED_CHARACTER);
return FALSE;
}
} else {
vxml_unread_char(vp, uc);
}
/*
* Since we have seen some white space already, then any non-space
* means we have additional attributes to process.
*
* We're not at the end of the tag because "/>" or '>' are handled
* at the top of the loop.
*/
g_assert(seen_space);
if (!vxml_handle_attribute(vp, TRUE))
return FALSE;
need_space = TRUE;
}
/*
* Output buffer contains the name of the current element, in UTF-8.
* If we saw spaces earlier, we already created the element.
*/
if (!seen_space)
vxml_parser_new_element(vp);
vxml_parser_begin_element(vp, ctx);
return TRUE;
} | false | false | false | false | false | 0 |
camel_toupper (gchar c)
{
if (c >= 'a' && c <= 'z')
c &= ~0x20;
return c;
} | false | false | false | false | false | 0 |
ide_cdrom_update_speed(ide_drive_t *drive, u8 *buf)
{
struct cdrom_info *cd = drive->driver_data;
u16 curspeed, maxspeed;
ide_debug_log(IDE_DBG_FUNC, "enter");
if (drive->atapi_flags & IDE_AFLAG_LE_SPEED_FIELDS) {
curspeed = le16_to_cpup((__le16 *)&buf[8 + 14]);
maxspeed = le16_to_cpup((__le16 *)&buf[8 + 8]);
} else {
curspeed = be16_to_cpup((__be16 *)&buf[8 + 14]);
maxspeed = be16_to_cpup((__be16 *)&buf[8 + 8]);
}
ide_debug_log(IDE_DBG_PROBE, "curspeed: %u, maxspeed: %u",
curspeed, maxspeed);
cd->current_speed = DIV_ROUND_CLOSEST(curspeed, 176);
cd->max_speed = DIV_ROUND_CLOSEST(maxspeed, 176);
} | false | false | false | false | false | 0 |
brasero_io_job_progress_report_stop (BraseroIO *self,
BraseroIOJob *job)
{
BraseroIOPrivate *priv;
GSList *iter;
priv = BRASERO_IO_PRIVATE (self);
g_mutex_lock (priv->lock);
for (iter = priv->progress; iter; iter = iter->next) {
BraseroIOJobProgress *progress;
progress = iter->data;
if (progress->job == job) {
priv->progress = g_slist_remove (priv->progress, progress);
if (progress->current)
g_free (progress->current);
g_free (progress);
break;
}
}
if (!priv->progress) {
if (priv->progress_id) {
g_source_remove (priv->progress_id);
priv->progress_id = 0;
}
}
g_mutex_unlock (priv->lock);
} | false | false | false | false | false | 0 |
send_result(
Operation *op,
SlapReply *rs,
sort_op *so)
{
LDAPControl *ctrls[3];
int rc, i = 0;
rc = pack_sss_response_control( op, rs, ctrls );
if ( rc == LDAP_SUCCESS ) {
i++;
rc = -1;
if ( so->so_paged > SLAP_CONTROL_IGNORED ) {
rc = pack_pagedresult_response_control( op, rs, so, ctrls+1 );
} else if ( so->so_vlv > SLAP_CONTROL_IGNORED ) {
rc = pack_vlv_response_control( op, rs, so, ctrls+1 );
}
if ( rc == LDAP_SUCCESS )
i++;
}
ctrls[i] = NULL;
if ( ctrls[0] != NULL )
slap_add_ctrls( op, rs, ctrls );
send_ldap_result( op, rs );
if ( so->so_tree == NULL ) {
/* Search finished, so clean up */
free_sort_op( op->o_conn, so );
}
} | false | false | false | false | false | 0 |
jas_image_encode(jas_image_t *image, jas_stream_t *out, int fmt, char *optstr)
{
jas_image_fmtinfo_t *fmtinfo;
if (!(fmtinfo = jas_image_lookupfmtbyid(fmt))) {
return -1;
}
return (fmtinfo->ops.encode) ? (*fmtinfo->ops.encode)(image, out,
optstr) : (-1);
} | false | false | false | false | false | 0 |
DecMul10(MonoDecimal* value)
{
MonoDecimal d = *value;
g_assert (value != NULL);
DecShiftLeft(value);
DecShiftLeft(value);
DecAdd(value, &d);
DecShiftLeft(value);
} | false | false | false | false | false | 0 |
tifftag_write_dword(fp, id, val)
FILE *fp;
int id;
unsigned long val;
{
if (EOF == tiff_put_word(fp, id))
return EOF;
if (EOF == tiff_put_word(fp, 4)) /* TIFF_LONG */
return EOF;
if (EOF == tiff_put_dword(fp, 1)) /* length */
return EOF;
return tiff_put_dword(fp, val);
} | false | false | false | false | false | 0 |
is_header_regex(apr_pool_t *p, const char* name)
{
/* If a Header name contains characters other than:
* -,_,[A-Z\, [a-z] and [0-9].
* assume the header name is a regular expression.
*/
if (ap_regexec(is_header_regex_regex, name, 0, NULL, 0)) {
return 1;
}
return 0;
} | false | false | false | false | false | 0 |
skge_board_name(const struct skge_hw *hw)
{
int i;
static char buf[16];
for (i = 0; i < ARRAY_SIZE(skge_chips); i++)
if (skge_chips[i].id == hw->chip_id)
return skge_chips[i].name;
snprintf(buf, sizeof buf, "chipid 0x%x", hw->chip_id);
return buf;
} | false | false | false | false | false | 0 |
xmlrpc_get_element(XMLRPCValue *xrarray, int i)
{
if (xrarray == NULL || xrarray->v_type != xr_array || i < 0)
return NULL;
return gwlist_get(xrarray->v_array, i);
} | false | false | false | false | false | 0 |
ResourceManager_addEntry( u32 pHash, u32 pHandle ) {
if( rm )
if( u32Array_checkSize( &rm->mHashes ) && u32Array_checkSize( &rm->mHandles ) ) {
u32 index = rm->mHashes.cpt++;
if( index != (rm->mHandles.cpt++) ) {
log_err( "Error in Resource Manager, arrays are not parallel anymore!\n" );
} else {
rm->mHashes.data[index] = pHash;
rm->mHandles.data[index] = pHandle;
u32 tmp1, tmp2;
// sort array after 2nd insertion, in increasing order
if( 1 < rm->mHashes.cpt )
for( int i = rm->mHashes.cpt-2; i >= 0; --i )
if( rm->mHashes.data[i] > rm->mHashes.data[i+1] ) {
// switch two instances
tmp1 = rm->mHashes.data[i];
tmp2 = rm->mHandles.data[i];
rm->mHashes.data[i] = rm->mHashes.data[i+1];
rm->mHandles.data[i] = rm->mHandles.data[i+1];
rm->mHashes.data[i+1] = tmp1;
rm->mHandles.data[i+1] = tmp2;
} else
break;
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
rendering_render(rendering_t * rendering)
{
#ifdef AMIDE_COMMENT_OUT
struct timeval tv1;
struct timeval tv2;
gdouble time1;
gdouble time2;
/* let's do some timing */
gettimeofday(&tv1, NULL);
#endif
if (rendering->need_rerender) {
if (rendering->vpc != NULL) {
if (rendering->optimize_rendering) {
if (rendering->need_reclassify) {
#if AMIDE_DEBUG
g_print("\tClassifying\n");
#endif
if (vpClassifyVolume(rendering->vpc) != VP_OK) {
g_warning(_("Error Classifying the Volume (%s): %s"),
rendering->name,vpGetErrorString(vpGetError(rendering->vpc)));
return;
}
}
if (vpRenderClassifiedVolume(rendering->vpc) != VP_OK) {
g_warning(_("Error Rendering the Classified Volume (%s): %s"),
rendering->name, vpGetErrorString(vpGetError(rendering->vpc)));
return;
}
} else {
if (vpRenderRawVolume(rendering->vpc) != VP_OK) {
g_warning(_("Error Rendering the Volume (%s): %s"),
rendering->name, vpGetErrorString(vpGetError(rendering->vpc)));
return;
}
}
}
}
#ifdef AMIDE_COMMENT_OUT
/* and wrapup our timing */
gettimeofday(&tv2, NULL);
time1 = ((double) tv1.tv_sec) + ((double) tv1.tv_usec)/1000000.0;
time2 = ((double) tv2.tv_sec) + ((double) tv2.tv_usec)/1000000.0;
g_print("######## Rendering object %s took %5.3f (s) #########\n",
AMITK_OBJECT_NAME(rendering->object), time2-time1);
#endif
rendering->need_rerender = FALSE;
rendering->need_reclassify = FALSE;
return;
} | false | false | false | false | false | 0 |
xchklog_initial_processing(struct fscklog_record *local_recptr)
{
int pi_rc = 0;
/*
* Initialize the fscklog control block
*/
local_recptr->infile_buf_length = FSCKLOG_BUFSIZE;
local_recptr->infile_buf_ptr = fscklog_buffer;
local_recptr->outfile_buf_length = XCHKLOG_BUFSIZE;
local_recptr->outfile_buf_ptr = xchklog_buffer;
/*
* Open the device and verify that it contains a valid JFS aggregate
* If it does, check/repair the superblock.
*/
pi_rc = open_device_read(Vol_Label);
if (pi_rc != 0) {
/*device open failed */
send_msg(fsck_CNTRESUPB);
} else {
/* device is open */
local_recptr->device_is_open = 1;
pi_rc = validate_superblock();
if (pi_rc == 0) {
/* a valid superblock */
/*
* add some stuff to the local record which is based on
* superblock fields
*/
/* length of the on-device fsck service log */
local_recptr->ondev_fscklog_byte_length =
sb_ptr->s_fsckloglen * sb_ptr->s_bsize;
/* length of the on-device fsck service log */
local_recptr->ondev_fscklog_fsblk_length =
sb_ptr->s_fsckloglen;
/* length of the on-device fsck workspace */
local_recptr->ondev_wsp_fsblk_length =
lengthPXD(&(sb_ptr->s_fsckpxd)) -
local_recptr->ondev_fscklog_fsblk_length;
/* length of the on-device fsck workspace */
local_recptr->ondev_wsp_byte_length =
local_recptr->ondev_wsp_fsblk_length *
sb_ptr->s_bsize;
/* aggregate block offset of the on-device fsck workspace */
local_recptr->ondev_wsp_fsblk_offset =
addressPXD(&(sb_ptr->s_fsckpxd));
/* byte offset of the on-device fsck workspace */
local_recptr->ondev_wsp_byte_offset =
local_recptr->ondev_wsp_fsblk_offset *
sb_ptr->s_bsize;
/* aggregate block offset of the on-device fsck workspace */
local_recptr->ondev_fscklog_fsblk_offset =
local_recptr->ondev_wsp_fsblk_offset +
local_recptr->ondev_wsp_fsblk_length;
/* byte offset of the on-device fsck workspace */
local_recptr->ondev_fscklog_byte_offset =
local_recptr->ondev_wsp_byte_offset +
local_recptr->ondev_wsp_byte_length;
/*
* The offsets now assume the most recent log is 1st in the
* aggregate fsck service log space. Adjust if needed.
*/
if (local_recptr->which_log == NEWLOG) {
/* most recent wanted */
if (sb_ptr->s_fscklog == 2) {
/* the 2nd is most recent */
local_recptr->
ondev_fscklog_fsblk_offset +=
local_recptr->
ondev_fscklog_fsblk_length / 2;
local_recptr->
ondev_fscklog_byte_offset +=
local_recptr->
ondev_fscklog_byte_length / 2;
}
} else {
/* previous log wanted */
if (sb_ptr->s_fscklog != 2) {
/* the 2nd is not most recent */
local_recptr->
ondev_fscklog_fsblk_offset +=
local_recptr->
ondev_fscklog_fsblk_length / 2;
local_recptr->
ondev_fscklog_byte_offset +=
local_recptr->
ondev_fscklog_byte_length / 2;
}
}
local_recptr->infile_agg_offset =
local_recptr->ondev_fscklog_byte_offset;
pi_rc = open_outfile();
}
}
if (local_recptr->which_log == NEWLOG) {
send_msg(fsck_CHKLOGNEW);
} else {
send_msg(fsck_CHKLOGOLD);
}
return (pi_rc);
} | false | false | false | false | false | 0 |
e132xs_bgt(void)
{
if( !GET_N && !GET_Z )
execute_br(get_pcrel());
else
e132xs_ICount -= 1;
} | false | false | false | false | false | 0 |
ipv6addrstruct_to_uncompaddrsuffix(const ipv6calc_ipv6addr *ipv6addrp, char *resultstring, const uint32_t formatoptions) {
int retval = 1;
unsigned int max, i;
char tempstring1[NI_MAXHOST], tempstring2[NI_MAXHOST];
if ( (ipv6calc_debug & DEBUG_libipv6addr) != 0 ) {
fprintf(stderr, "%s: called\n", DEBUG_function_name);
};
/* test for misuse */
if ( ( (ipv6addrp->scope & (IPV6_ADDR_COMPATv4 | IPV6_ADDR_MAPPED)) != 0) && ( ipv6addrp->prefixlength > 96 ) ) {
snprintf(resultstring, NI_MAXHOST - 1, "Error, cannot print suffix of a compatv4/mapped address with prefix length bigger than 96!");
retval = 1;
return (retval);
};
if ( ipv6addrp->prefixlength == 128 ) {
snprintf(resultstring, NI_MAXHOST - 1, "Error, cannot print suffix of a address with prefix length 128!");
retval = 1;
return (retval);
};
max = 7;
i = (unsigned int) ipv6addrp->prefixlength / 16u;
tempstring1[0] = '\0';
while (i <= max ) {
if ( ( ( ipv6addrp->scope & (IPV6_ADDR_COMPATv4 | IPV6_ADDR_MAPPED)) != 0 ) && ( i == 6 ) ) {
snprintf(tempstring2, sizeof(tempstring2) - 1, "%s%u.%u.%u.%u", tempstring1, \
(unsigned int) ipv6addrp->in6_addr.s6_addr[12], \
(unsigned int) ipv6addrp->in6_addr.s6_addr[13], \
(unsigned int) ipv6addrp->in6_addr.s6_addr[14], \
(unsigned int) ipv6addrp->in6_addr.s6_addr[15] \
);
i = max;
} else if ( i < max ) {
if ( (formatoptions & FORMATOPTION_printfulluncompressed) != 0 ) {
snprintf(tempstring2, sizeof(tempstring2) - 1, "%s%04x:", tempstring1, (unsigned int) ipv6addr_getword(ipv6addrp, i));
} else {
snprintf(tempstring2, sizeof(tempstring2) - 1, "%s%x:", tempstring1, (unsigned int) ipv6addr_getword(ipv6addrp, i));
};
} else {
if ( (formatoptions & FORMATOPTION_printfulluncompressed) != 0 ) {
snprintf(tempstring2, sizeof(tempstring2) - 1, "%s%04x", tempstring1, (unsigned int) ipv6addr_getword(ipv6addrp, i));
} else {
snprintf(tempstring2, sizeof(tempstring2) - 1, "%s%x", tempstring1, (unsigned int) ipv6addr_getword(ipv6addrp, i));
};
};
i++;
snprintf(tempstring1, sizeof(tempstring1) - 1, "%s", tempstring2);
};
snprintf(resultstring, NI_MAXHOST - 1, "%s", tempstring1);
if ( (ipv6calc_debug & DEBUG_libipv6addr) != 0 ) {
fprintf(stderr, "%s: result string: %s\n", DEBUG_function_name, resultstring);
};
retval = 0;
return (retval);
} | false | false | false | false | false | 0 |
get_mime_type(char *filename) {
char *ext;
int i;
for (ext = &filename[strlen(filename) - 1]; ext != filename; ext--) {
if (*(ext - 1) == '.') {
break;
}
}
for (i = 0; i < sizeof(MIME_TYPES)/sizeof(MIME_TYPES[0]); i++) {
if (strcmp(ext, MIME_TYPES[i]) == 0) {
return (char *) &MIME_TYPES[i][strlen(ext) + 1];
}
}
return "application/octet";
} | false | false | false | false | false | 0 |
copy_argument (Argument * self)
{
Argument * new;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (self->type == ARGUMENT_NODE, NULL);
new = g_new0(Argument, 1);
new->type = ARGUMENT_NODE;
new->gtktype = g_strdup (self->gtktype);
new->atype = copy_type (self->atype);
new->flags = g_list_copy (self->flags); COPY_LIST_VALS(new->flags, g_strdup);
new->name = g_strdup (self->name);
new->get = g_strdup (self->get);
new->get_line = self->get_line;
new->set = g_strdup (self->set);
new->set_line = self->set_line;
new->line_no = self->line_no;
return new;
} | false | false | false | false | false | 0 |
ByteSize() const {
int total_size = 0;
if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) {
// optional string java_package = 1;
if (has_java_package()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->java_package());
}
// optional string java_outer_classname = 8;
if (has_java_outer_classname()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::StringSize(
this->java_outer_classname());
}
// optional bool java_multiple_files = 10 [default = false];
if (has_java_multiple_files()) {
total_size += 1 + 1;
}
// optional bool java_generate_equals_and_hash = 20 [default = false];
if (has_java_generate_equals_and_hash()) {
total_size += 2 + 1;
}
// optional .google.protobuf.FileOptions.OptimizeMode optimize_for = 9 [default = SPEED];
if (has_optimize_for()) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::EnumSize(this->optimize_for());
}
// optional bool cc_generic_services = 16 [default = false];
if (has_cc_generic_services()) {
total_size += 2 + 1;
}
// optional bool java_generic_services = 17 [default = false];
if (has_java_generic_services()) {
total_size += 2 + 1;
}
// optional bool py_generic_services = 18 [default = false];
if (has_py_generic_services()) {
total_size += 2 + 1;
}
}
// repeated .google.protobuf.UninterpretedOption uninterpreted_option = 999;
total_size += 2 * this->uninterpreted_option_size();
for (int i = 0; i < this->uninterpreted_option_size(); i++) {
total_size +=
::google::protobuf::internal::WireFormatLite::MessageSizeNoVirtual(
this->uninterpreted_option(i));
}
total_size += _extensions_.ByteSize();
if (!unknown_fields().empty()) {
total_size +=
::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize(
unknown_fields());
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
return total_size;
} | false | false | false | false | false | 0 |
_rtl92ee_get_txpower_index(struct ieee80211_hw *hw,
enum radio_path rfpath, u8 rate,
u8 bw, u8 channel)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_efuse *rtlefuse = rtl_efuse(rtlpriv);
u8 index = (channel - 1);
u8 tx_power = 0;
u8 diff = 0;
if (channel < 1 || channel > 14) {
index = 0;
RT_TRACE(rtlpriv, COMP_POWER_TRACKING, DBG_DMESG,
"Illegal channel!!\n");
}
if (IS_CCK_RATE(rate))
tx_power = rtlefuse->txpwrlevel_cck[rfpath][index];
else if (DESC92C_RATE6M <= rate)
tx_power = rtlefuse->txpwrlevel_ht40_1s[rfpath][index];
/* OFDM-1T*/
if (DESC92C_RATE6M <= rate && rate <= DESC92C_RATE54M &&
!IS_CCK_RATE(rate))
tx_power += rtlefuse->txpwr_legacyhtdiff[rfpath][TX_1S];
/* BW20-1S, BW20-2S */
if (bw == HT_CHANNEL_WIDTH_20) {
if (DESC92C_RATEMCS0 <= rate && rate <= DESC92C_RATEMCS15)
tx_power += rtlefuse->txpwr_ht20diff[rfpath][TX_1S];
if (DESC92C_RATEMCS8 <= rate && rate <= DESC92C_RATEMCS15)
tx_power += rtlefuse->txpwr_ht20diff[rfpath][TX_2S];
} else if (bw == HT_CHANNEL_WIDTH_20_40) {/* BW40-1S, BW40-2S */
if (DESC92C_RATEMCS0 <= rate && rate <= DESC92C_RATEMCS15)
tx_power += rtlefuse->txpwr_ht40diff[rfpath][TX_1S];
if (DESC92C_RATEMCS8 <= rate && rate <= DESC92C_RATEMCS15)
tx_power += rtlefuse->txpwr_ht40diff[rfpath][TX_2S];
}
if (rtlefuse->eeprom_regulatory != 2)
diff = _rtl92ee_get_txpower_by_rate(hw, BAND_ON_2_4G,
rfpath, rate);
tx_power += diff;
if (tx_power > MAX_POWER_INDEX)
tx_power = MAX_POWER_INDEX;
return tx_power;
} | false | false | false | false | false | 0 |
print_element_info (GstElementFactory * factory, gboolean print_names)
{
GstElement *element;
gint maxlevel = 0;
factory =
GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory)));
if (!factory) {
g_print ("element plugin couldn't be loaded\n");
return -1;
}
element = gst_element_factory_create (factory, NULL);
if (!element) {
g_print ("couldn't construct element for some reason\n");
return -1;
}
if (print_names)
_name = g_strdup_printf ("%s: ", GST_PLUGIN_FEATURE (factory)->name);
else
_name = NULL;
print_factory_details_info (factory);
if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
GstPlugin *plugin;
plugin = gst_registry_find_plugin (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory)->plugin_name);
if (plugin) {
print_plugin_info (plugin);
}
}
print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
print_interfaces (G_OBJECT_TYPE (element));
print_pad_templates_info (element, factory);
print_element_flag_info (element);
print_implementation_info (element);
print_clocking_info (element);
print_index_info (element);
print_uri_handler_info (element);
print_pad_info (element);
print_element_properties_info (element);
print_signal_info (element);
print_children_info (element);
gst_object_unref (element);
gst_object_unref (factory);
g_free (_name);
return 0;
} | false | false | false | false | false | 0 |
cycle_setstate(cycleobject *lz, PyObject *state)
{
PyObject *saved=NULL;
int firstpass;
if (!PyArg_ParseTuple(state, "Oi", &saved, &firstpass))
return NULL;
Py_CLEAR(lz->saved);
lz->saved = saved;
Py_XINCREF(lz->saved);
lz->firstpass = firstpass != 0;
Py_RETURN_NONE;
} | false | false | false | false | false | 0 |
init_patch_fill_state(patch_fill_state_t *pfs)
{
/* Warning : pfs->Function must be set in advance. */
const gs_color_space *pcs = pfs->direct_space;
gs_client_color fcc0, fcc1;
int i;
for (i = 0; i < pfs->num_components; i++) {
fcc0.paint.values[i] = -1000000;
fcc1.paint.values[i] = 1000000;
}
pcs->type->restrict_color(&fcc0, pcs);
pcs->type->restrict_color(&fcc1, pcs);
for (i = 0; i < pfs->num_components; i++)
pfs->color_domain.paint.values[i] = max(fcc1.paint.values[i] - fcc0.paint.values[i], 1);
pfs->vectorization = false; /* A stub for a while. Will use with pclwrite. */
pfs->maybe_self_intersecting = true;
pfs->monotonic_color = (pfs->Function == NULL);
pfs->function_arg_shift = 0;
pfs->linear_color = false;
pfs->inside = false;
pfs->n_color_args = 1;
#ifdef MAX_SHADING_RESOLUTION
pfs->decomposition_limit = float2fixed(min(pfs->dev->HWResolution[0],
pfs->dev->HWResolution[1]) / MAX_SHADING_RESOLUTION);
pfs->decomposition_limit = max(pfs->decomposition_limit, fixed_1);
#else
pfs->decomposition_limit = fixed_1;
#endif
pfs->fixed_flat = float2fixed(pfs->pis->flatness);
/* Restrict the pfs->smoothness with 1/min_linear_grades, because cs_is_linear
can't provide a better precision due to the color
representation with integers.
*/
pfs->smoothness = max(pfs->pis->smoothness, 1.0 / min_linear_grades);
pfs->color_stack_size = 0;
pfs->color_stack_step = 0;
pfs->color_stack_ptr = NULL;
pfs->color_stack = NULL;
pfs->color_stack_limit = NULL;
pfs->unlinear = !is_linear_color_applicable(pfs);
return alloc_patch_fill_memory(pfs, pfs->pis->memory, pcs);
} | false | false | false | false | false | 0 |
print_constrained(ostream &out)
{
out << "Dataset {\n" ;
for (Vars_citer i = vars.begin(); i != vars.end(); i++) {
// for each variable, indent with four spaces, print a trailing
// semicolon, do not print debugging information, print only
// variables in the current projection.
(*i)->print_decl(out, " ", true, false, true) ;
}
out << "} " << id2www(d_name) << ";\n" ;
return;
} | false | false | false | false | false | 0 |
CreateDvechmatWdata(int n, double alpha, double vv[], dvechmat **A){
int info,nn=(n*n+n)/2;
dvechmat* V;
DSDPCALLOC1(&V,dvechmat,&info);DSDPCHKERR(info);
info=DTPUMatCreateWData(n,vv,nn,&V->AA); DSDPCHKERR(info);
V->Eig.neigs=-1;
V->Eig.eigval=0;
V->Eig.an=0;
V->alpha=alpha;
*A=V;
return 0;
} | false | false | false | false | false | 0 |
print_hostname(FILE *f, const char *p)
{
for ( ; *p; p++)
{
if (*p < ' ' || *p >= 127)
{
fprintf(f, "\\%03o", (int)(unsigned char)*p);
continue;
}
if (*p == '\\')
{
fprintf(f, "\\\\");
continue;
}
putc(*p, f);
}
} | false | false | false | false | false | 0 |
parsePacket(GmpEngine *ge) {
int seq, ack, val;
Command command;
ButOut result = 0;
seq = ge->recvData[0] & 1;
ack = (ge->recvData[0] & 2) >> 1;
if (ge->recvData[2] & 0x08) /* Not-understood command. */
return(0);
command = (ge->recvData[2] >> 4) & 7;
#if DEBUG
if (showTransfers) {
fprintf(stderr, "GMP: Command %s received from port %d:%d.\n",
cmdNames[command], ge->inFile, ge->outFile);
}
#endif
if ((command != cmd_deny) && (command != cmd_reset) &&
!ge->iAmWhite && !ge->gameStarted) {
ge->gameStarted = TRUE;
if (ge->actions->newGame != NULL)
ge->actions->newGame(ge, ge->packet, ge->boardSize, ge->handicap,
ge->komi, ge->chineseRules, ge->iAmWhite);
}
val = ((ge->recvData[2] & 7) << 7) | (ge->recvData[3] & 0x7f);
if (!ge->waitingHighAck) {
if ((command == cmd_ack) || /* An ack. We don't need an ack now. */
(ack != ge->myLastSeq)) { /* He missed my last message. */
#if DEBUG
if (showTransfers) {
fprintf(stderr, "GMP: ACK does not match myLastSeq.\n");
}
#endif
return(0);
} else if (seq == ge->hisLastSeq) { /* Seen this one before. */
#if DEBUG
if (showTransfers) {
fprintf(stderr, "GMP: Repeated packet.\n");
}
#endif
putCommand(ge, cmd_ack, ~0);
} else {
ge->hisLastSeq = seq;
ge->sendFailures = 0;
result = processCommand(ge, command, val);
}
} else {
/* Waiting for OK. */
if (command == cmd_ack) {
if ((ack != ge->myLastSeq) || (seq != ge->hisLastSeq)) {
/* Sequence error. */
return(result);
}
ge->sendFailures = 0;
ge->waitingHighAck = FALSE;
processQ(ge);
} else if (seq == ge->hisLastSeq) {
/* His command is old. */
} else if (ack == ge->myLastSeq) {
ge->sendFailures = 0;
ge->waitingHighAck = FALSE;
ge->hisLastSeq = seq;
result = processCommand(ge, command, val);
processQ(ge);
} else {
/* Conflict with opponent. */
#if DEBUG
if (showTransfers) {
fprintf(stderr, "GMP: Received a packet, expected an ACK.\n");
}
#endif
/*
* This code seems wrong.
*
* ge->myLastSeq = 1 - ge->myLastSeq;
* ge->waitingHighAck = FALSE;
* processQ(ge);
*/
}
}
return(result);
} | false | false | false | false | false | 0 |
SwallowedWindow(button_info *b)
{
return (b->flags.b_Panel) ? b->PanelWin : b->IconWin;
} | false | false | false | false | false | 0 |
nextItemChooseDonorList()
{
DEBUG_BLOCK
if ( !m_queue.isEmpty() ) // User-specified queue has highest priority.
return &m_queue;
else if ( !m_replayedItems.isEmpty() ) // If the user pressed "previous" once or more, first re-play those items again when we go forward again.
return &m_replayedItems;
else
{
if ( m_plannedItems.isEmpty() )
planOne();
if ( !m_plannedItems.isEmpty() ) // The normal case.
return &m_plannedItems;
else
debug() << "planOne() didn't plan a next item.";
}
return 0;
} | false | false | false | false | false | 0 |
bnad_debugfs_open_fwsave(struct inode *inode, struct file *file)
{
struct bnad *bnad = inode->i_private;
struct bnad_debug_info *fw_debug;
unsigned long flags;
int rc;
fw_debug = kzalloc(sizeof(struct bnad_debug_info), GFP_KERNEL);
if (!fw_debug)
return -ENOMEM;
fw_debug->buffer_len = BNA_DBG_FWTRC_LEN;
fw_debug->debug_buffer = kzalloc(fw_debug->buffer_len, GFP_KERNEL);
if (!fw_debug->debug_buffer) {
kfree(fw_debug);
fw_debug = NULL;
return -ENOMEM;
}
spin_lock_irqsave(&bnad->bna_lock, flags);
rc = bfa_nw_ioc_debug_fwsave(&bnad->bna.ioceth.ioc,
fw_debug->debug_buffer,
&fw_debug->buffer_len);
spin_unlock_irqrestore(&bnad->bna_lock, flags);
if (rc != BFA_STATUS_OK && rc != BFA_STATUS_ENOFSAVE) {
kfree(fw_debug->debug_buffer);
fw_debug->debug_buffer = NULL;
kfree(fw_debug);
fw_debug = NULL;
netdev_warn(bnad->netdev, "failed to collect fwsave\n");
return -ENOMEM;
}
file->private_data = fw_debug;
return 0;
} | false | false | false | false | false | 0 |
setline(t)
enum linestattype t;
/* generates newline, or continuation, or nothing at all */
/* part of new linebreak option (-n) */
{
if ((t == fresh) && ((linestat == postfield) || (linestat == endmusicline))) {
printf("\n");
};
if ((t == fresh) && (linestat == midmusic)) {
printf("\\\n");
};
linestat = t;
} | false | false | false | false | false | 0 |
snprint_hw_fast_io_fail(char * buff, int len, void * data)
{
struct hwentry * hwe = (struct hwentry *)data;
if (!hwe->fast_io_fail)
return 0;
if (hwe->fast_io_fail == -1)
return snprintf(buff, len, "off");
return snprintf(buff, len, "%d", hwe->fast_io_fail);
} | false | false | false | false | false | 0 |
__ext4_journal_get_create_access(const char *where, unsigned int line,
handle_t *handle, struct buffer_head *bh)
{
int err = 0;
if (ext4_handle_valid(handle)) {
err = jbd2_journal_get_create_access(handle, bh);
if (err)
ext4_journal_abort_handle(where, line, __func__,
bh, handle, err);
}
return err;
} | false | false | false | false | false | 0 |
compat_protect_strdup(const char *s)
{
size_t size;
size = strlen(s) + 1;
RUNTIME_ASSERT(size > 0 && size <= INT_MAX);
return compat_protect_memdup(s, size);
} | false | false | false | false | false | 0 |
stats_reshape ()
{
glViewport(0, 0, (GLint) width, (GLint) height);
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
float v = getView ();
if (camera == 50) v = 100000.0;
gluPerspective (visibleangle, 1.0, nearclippingplane * GLOBALSCALE, v * GLOBALSCALE);
glPolygonMode (GL_FRONT_AND_BACK, polygonMode);
#ifndef USE_GLUT
SDL_ShowCursor (0);
#endif
} | false | false | false | false | false | 0 |
write_class_DS_s( class_DS *classes, int n_classes, FILE *stream)
{
int i, j;
char caller[] = "write_class_DS_s";
for (i=0; i < n_classes; i++) {
safe_fprintf(stream, caller, "class_DS %d\n", i);
safe_fprintf(stream, caller, "w_j, pi_j\n");
safe_fprintf(stream, caller, "%.7e %.7e\n", classes[i]->w_j, classes[i]->pi_j);
safe_fprintf(stream, caller, "log_pi_j, log_a_w_s_h_pi_theta, log_a_w_s_h_j\n");
safe_fprintf(stream, caller, "%.7e %.7e %.7e\n", classes[i]->log_pi_j,
classes[i]->log_a_w_s_h_pi_theta, classes[i]->log_a_w_s_h_j);
safe_fprintf(stream, caller, "known_parms_p, num_tparms\n");
safe_fprintf(stream, caller, "%d %d\n", classes[i]->known_parms_p,
classes[i]->num_tparms);
for (j=0; j<classes[i]->num_tparms; j++)
write_tparm_DS( classes[i]->tparms[j], j, stream);
/* num_i_values, i_values, i_sum, & max_i_value used only in reports -
do not output */
safe_fprintf(stream, caller, "num_wts\n%d\n", classes[i]->num_wts);
safe_fprintf(stream, caller, "model_DS_ptr %d\n", classes[i]->model->file_index);
}
} | false | false | false | false | false | 0 |
sdio_uart_update_mctrl(struct sdio_uart_port *port,
unsigned int set, unsigned int clear)
{
unsigned int old;
old = port->mctrl;
port->mctrl = (old & ~clear) | set;
if (old != port->mctrl)
sdio_uart_write_mctrl(port, port->mctrl);
} | false | false | false | false | false | 0 |
lt_list_find_custom(lt_list_t *list,
const lt_pointer_t data,
lt_compare_func_t func)
{
lt_return_val_if_fail (func != NULL, NULL);
while (list) {
if (!func(list->value, data))
break;
list = list->next;
}
return list;
} | false | false | false | false | false | 0 |
hmdf_this_pe_is_cp(const Hmdf_table *hmdf_ptr, int __pe_number)
{
int i;
Boolean hmdf_pe_is_cp = FALSE;
if (hmdf_ptr == NULL) {
ERROR_EHMDF;
}
if (__pe_number != -1) {
for (i = 0; (i < hmdf_ptr->clustering_num) && !hmdf_pe_is_cp; i++) {
if (hmdf_ptr->clustering[i].peofcp == __pe_number) {
hmdf_pe_is_cp = TRUE;
}
}
}
return hmdf_pe_is_cp;
} | false | false | false | false | false | 0 |
_pager_popup_cb_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Event_Mouse_Wheel *ev = event;
Pager_Popup *pp = act_popup;
int max_x;
e_zone_desk_count_get(pp->pager->zone, &max_x, NULL);
if (current_desk->x + ev->z >= max_x)
_pager_popup_desk_switch(1, 1);
else if (current_desk->x + ev->z < 0)
_pager_popup_desk_switch(-1, -1);
else
_pager_popup_desk_switch(ev->z, 0);
return ECORE_CALLBACK_PASS_ON;
} | false | false | false | false | false | 0 |
imapx_job_append_message_start (CamelIMAPXJob *job,
CamelIMAPXServer *is,
GCancellable *cancellable,
GError **error)
{
CamelFolder *folder;
CamelIMAPXCommand *ic;
AppendMessageData *data;
data = camel_imapx_job_get_data (job);
g_return_val_if_fail (data != NULL, FALSE);
folder = camel_imapx_job_ref_folder (job);
g_return_val_if_fail (folder != NULL, FALSE);
/* TODO: we could supply the original append date from the file timestamp */
ic = camel_imapx_command_new (
is, "APPEND", NULL,
"APPEND %f %F %P", folder,
((CamelMessageInfoBase *) data->info)->flags,
((CamelMessageInfoBase *) data->info)->user_flags,
data->path);
ic->complete = imapx_command_append_message_done;
camel_imapx_command_set_job (ic, job);
ic->pri = job->pri;
job->commands++;
imapx_command_queue (is, ic);
camel_imapx_command_unref (ic);
g_object_unref (folder);
return TRUE;
} | false | false | false | false | false | 0 |
buttonPress(const XEvent *event_)
{
if (grabber()==this)
{
lastShowTime(0);
}
else
{
lastShowTime(event_->xbutton.time);
}
MSMenu::buttonPress(event_);
} | false | false | false | false | false | 0 |
lv_get_selected_split (GNCLotViewer *lv, GtkTreeView *view)
{
Split *split = NULL;
GtkTreeModel *model;
GtkTreeSelection *selection;
GtkTreeIter iter;
selection = gtk_tree_view_get_selection(view);
if (gtk_tree_selection_get_selected (selection, &model, &iter))
{
gtk_tree_model_get(model, &iter, SPLIT_COL_PNTR, &split, -1);
}
return split;
} | false | false | false | false | false | 0 |
sm_put(StrMap *map, const char *key, const char *value)
{
unsigned int key_len, value_len, index;
Bucket *bucket;
Pair *tmp_pairs, *pair;
char *tmp_value;
char *new_key, *new_value;
if (map == NULL) {
return 0;
}
if (key == NULL || value == NULL) {
return 0;
}
key_len = strlen(key);
value_len = strlen(value);
/* Get a pointer to the bucket the key string hashes to */
index = hash(key) % map->count;
bucket = &(map->buckets[index]);
/* Check if we can handle insertion by simply replacing
* an existing value in a key-value pair in the bucket.
*/
if ((pair = get_pair(bucket, key)) != NULL) {
/* The bucket contains a pair that matches the provided key,
* change the value for that pair to the new value.
*/
if (strlen(pair->value) < value_len) {
/* If the new value is larger than the old value, re-allocate
* space for the new larger value.
*/
tmp_value = realloc(pair->value, (value_len + 1) * sizeof(char));
if (tmp_value == NULL) {
return 0;
}
pair->value = tmp_value;
}
/* Copy the new value into the pair that matches the key */
strcpy(pair->value, value);
return 1;
}
/* Allocate space for a new key and value */
new_key = malloc((key_len + 1) * sizeof(char));
if (new_key == NULL) {
return 0;
}
new_value = malloc((value_len + 1) * sizeof(char));
if (new_value == NULL) {
free(new_key);
return 0;
}
/* Create a key-value pair */
if (bucket->count == 0) {
/* The bucket is empty, lazily allocate space for a single
* key-value pair.
*/
bucket->pairs = malloc(sizeof(Pair));
if (bucket->pairs == NULL) {
free(new_key);
free(new_value);
return 0;
}
bucket->count = 1;
}
else {
/* The bucket wasn't empty but no pair existed that matches the provided
* key, so create a new key-value pair.
*/
tmp_pairs = realloc(bucket->pairs, (bucket->count + 1) * sizeof(Pair));
if (tmp_pairs == NULL) {
free(new_key);
free(new_value);
return 0;
}
bucket->pairs = tmp_pairs;
bucket->count++;
}
/* Get the last pair in the chain for the bucket */
pair = &(bucket->pairs[bucket->count - 1]);
pair->key = new_key;
pair->value = new_value;
/* Copy the key and its value into the key-value pair */
strcpy(pair->key, key);
strcpy(pair->value, value);
return 1;
} | false | true | false | false | false | 1 |
at86rf230_irq_status(void *context)
{
struct at86rf230_state_change *ctx = context;
struct at86rf230_local *lp = ctx->lp;
const u8 *buf = ctx->buf;
u8 irq = buf[1];
enable_irq(lp->spi->irq);
if (irq & IRQ_TRX_END) {
at86rf230_irq_trx_end(ctx);
} else {
dev_err(&lp->spi->dev, "not supported irq %02x received\n",
irq);
kfree(ctx);
}
} | false | false | false | false | false | 0 |
nrf_rcv_pkt_poll_dec(int maxsize, uint8_t * pkt, uint32_t const key[4]){
int len;
uint16_t cmpcrc;
len=nrf_rcv_pkt_poll(maxsize,pkt);
if(len <=0)
return len;
// if(key==NULL) return len;
if(key!=NULL)
xxtea_decode_words((uint32_t*)pkt,len/4,key);
cmpcrc=crc16(pkt,len-2);
if(cmpcrc != (pkt[len-2] <<8 | pkt[len-1])) {
return -3; // CRC failed
};
return len;
} | false | false | false | false | true | 1 |
__write_ports_names(char *buf, struct net *net)
{
struct nfsd_net *nn = net_generic(net, nfsd_net_id);
if (nn->nfsd_serv == NULL)
return 0;
return svc_xprt_names(nn->nfsd_serv, buf, SIMPLE_TRANSACTION_LIMIT);
} | false | false | false | false | false | 0 |
CreateInitC( void )
{
wxPanel * poPnl;
if( bIsCreated( eCTLGRP_INITC ) ) return;
// Create and add the initial conditions radio buttons
poPnl = (wxPanel *) m_oPnlStart.GetParent( );
wxString osInitC[ 3 ] = { wxT("Warm "), wxT("Use ICs"), wxT("Cold ") };
m_oRbxInitC.Create( poPnl, ID_UNUSED, wxT(" Initial Conditions "),
wxPoint( 13, 123 ), wxDefaultSize, 3, osInitC, 3 );
m_oRbxInitC.SetSelection( eINITC_WARM );
} | false | false | false | false | false | 0 |
load(ifstream & fp) {
uint rd = loadValue<uint>(fp);
if(rd!=WVTREE_NOPTRS_HDR) return NULL;
WaveletTreeNoptrs * ret = new WaveletTreeNoptrs();
ret->n = loadValue<size_t>(fp);
ret->max_v = loadValue<uint>(fp);
ret->height = loadValue<uint>(fp);
ret->am = Mapper::load(fp);
if(ret->am==NULL) {
delete ret;
return NULL;
}
ret->am->use();
ret->bitstring = new BitSequence*[ret->height];
for(uint i=0;i<ret->height;i++)
ret->bitstring[i] = NULL;
for(uint i=0;i<ret->height;i++) {
ret->bitstring[i] = BitSequence::load(fp);
if(ret->bitstring[i]==NULL) {
cout << "damn" << i << " " << ret->height << endl;
delete ret;
return NULL;
}
}
ret->occ = BitSequence::load(fp);
if(ret->occ==NULL) {
delete ret;
return NULL;
}
return ret;
} | false | false | false | false | false | 0 |
_animator(void *data)
{
Smart_Data *sd = evas_object_smart_data_get(data);
if (!sd) return ECORE_CALLBACK_CANCEL;
double da;
double spd = ((25.0 / (double)e_config->framerate) /
(double)(1 + sd->view->zoom));
if (spd > 0.9) spd = 0.9;
int wait = 0;
if (sd->scroll_align != sd->scroll_align_to)
{
sd->scroll_align = ((sd->scroll_align * (1.0 - spd)) +
(sd->scroll_align_to * spd));
da = sd->scroll_align - sd->scroll_align_to;
if (da < 0.0) da = -da;
if (da < 0.02)
sd->scroll_align = sd->scroll_align_to;
else
wait++;
e_scrollframe_child_pos_set(sd->view->sframe,
0, sd->scroll_align);
}
sd->place = EINA_TRUE;
if (wait)
return ECORE_CALLBACK_RENEW;
_animator_del(data);
return ECORE_CALLBACK_CANCEL;
} | false | false | false | false | false | 0 |
liblo10k1_debug(liblo10k1_connection_t *conn, int deb, void (*prn_fnc)(char *))
{
int err;
ld10k1_fnc_debug_t debug_info;
char debug_line[1000];
int opr, sizer;
/* add */
debug_info.what = deb;
if ((err = send_request(*conn, FNC_DEBUG, &debug_info, sizeof(ld10k1_fnc_debug_t))) < 0)
return err;
while (1) {
if ((err = receive_response(*conn, &opr, &sizer)) < 0)
return err;
if (opr != FNC_CONTINUE)
break;
if (sizer < (int)sizeof(debug_line)) {
if ((err = receive_msg_data(*conn, &debug_line, sizer)) < 0)
return err;
} else
return LIBLO10K1_ERR_DEBUG;
(*prn_fnc)(debug_line);
}
/* not checked */
return receive_response(*conn, &opr, &sizer);
} | false | false | false | false | false | 0 |
initializeExternalFunctions() {
sys::ScopedLock Writer(*FunctionsLock);
(*FuncNames)["lle_X_atexit"] = lle_X_atexit;
(*FuncNames)["lle_X_exit"] = lle_X_exit;
(*FuncNames)["lle_X_abort"] = lle_X_abort;
(*FuncNames)["lle_X_printf"] = lle_X_printf;
(*FuncNames)["lle_X_sprintf"] = lle_X_sprintf;
(*FuncNames)["lle_X_sscanf"] = lle_X_sscanf;
(*FuncNames)["lle_X_scanf"] = lle_X_scanf;
(*FuncNames)["lle_X_fprintf"] = lle_X_fprintf;
(*FuncNames)["lle_X_memset"] = lle_X_memset;
(*FuncNames)["lle_X_memcpy"] = lle_X_memcpy;
} | false | false | false | false | false | 0 |
gtv_wire_plugins_video (gtk_video_private_t *priv)
{
/* note: assumes default wiring */
GList *list = priv->post_video.enable
? g_list_copy (priv->post_video.list) : NULL;
GList *item, *next = NULL;
if (priv->post_deinterlace.list && priv->post_deinterlace.enable)
list = g_list_concat (g_list_copy (priv->post_deinterlace.list), list);
xine_post_wire_video_port (xine_get_video_source (priv->stream),
priv->video_port);
item = g_list_last (list);
while (item)
{
xine_post_out_t *out = gtv_post_output_video (item->data);
if (next)
xine_post_wire (out, gtv_post_input_video (next->data));
else
xine_post_wire_video_port (out, priv->video_port);
next = item;
item = g_list_previous (item);
}
if (next)
xine_post_wire (xine_get_video_source (priv->stream),
gtv_post_input_video (next->data));
g_list_free (list);
xine_set_param (priv->stream, XINE_PARAM_VO_DEINTERLACE,
priv->post_deinterlace.enable &&
!priv->post_deinterlace.list);
} | false | false | false | false | false | 0 |
flush()
{
const UHashElement *element;
int32_t pos = -1;
umtx_lock(&lock);
while ((element = uhash_nextElement(cache, &pos)) != NULL) {
CollDataCacheEntry *entry = (CollDataCacheEntry *) element->value.pointer;
if (entry->refCount <= 0) {
uhash_removeElement(cache, element);
}
}
umtx_unlock(&lock);
} | false | false | false | false | false | 0 |
pipe_context_callback(void *data, int status, char *stderr_buf)
{
char message[128];
char *cmd = data;
int ok = False;
if (strlen(cmd) > 100)
cmd[100] = '\0';
if (WIFEXITED(status))
switch (WEXITSTATUS(status)) {
case 0:
sprintf(message, "'%s' exited ok.", cmd);
ok = True;
break;
case 127:
sprintf(message, "Failed to start '%s'!", cmd);
break;
default:
sprintf(message, "'%s' exited abnormally!", cmd);
break;
}
else if (WIFSIGNALED(status))
sprintf(message, "'%s' caught %s!", cmd,
signal_string(WTERMSIG(status)));
else
sprintf(message, "Unknown problem with '%s'!", cmd);
if (!ok)
stderr_popup(stderr_buf, -1);
set_message(message, !ok);
XtFree(cmd);
} | false | false | false | false | false | 0 |
proc_kcore_init_64(FILE *fp)
{
Elf64_Ehdr *elf64;
Elf64_Phdr *load64;
char eheader[MAX_KCORE_ELF_HEADER_SIZE];
char buf[BUFSIZE];
size_t size;
size = MAX_KCORE_ELF_HEADER_SIZE;
if (read(pc->mfd, eheader, size) != size) {
sprintf(buf, "/proc/kcore: read");
perror(buf);
goto bailout;
}
if (lseek(pc->mfd, 0, SEEK_SET) != 0) {
sprintf(buf, "/proc/kcore: lseek");
perror(buf);
goto bailout;
}
elf64 = (Elf64_Ehdr *)&eheader[0];
load64 = (Elf64_Phdr *)&eheader[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
pkd->segments = elf64->e_phnum - 1;
size = (ulong)(load64+(elf64->e_phnum)) - (ulong)elf64;
if ((pkd->elf_header = (char *)malloc(size)) == NULL) {
error(INFO, "/proc/kcore: cannot malloc ELF header buffer\n");
clean_exit(1);
}
BCOPY(&eheader[0], &pkd->elf_header[0], size);
pkd->elf64 = (Elf64_Ehdr *)pkd->elf_header;
pkd->load64 = (Elf64_Phdr *)
&pkd->elf_header[sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)];
pkd->flags |= KCORE_ELF64;
if (CRASHDEBUG(1))
kcore_memory_dump(fp);
return TRUE;
bailout:
return FALSE;
} | true | true | false | false | true | 1 |
gd_main_toolbar_set_labels_menu (GdMainToolbar *self,
GMenuModel *menu)
{
GtkWidget *button, *grid, *w;
if (menu == NULL &&
((gtk_widget_get_parent (self->priv->labels_grid) == self->priv->center_grid) ||
self->priv->center_menu_child == NULL))
return;
if (menu != NULL)
{
g_object_ref (self->priv->labels_grid);
gtk_container_remove (GTK_CONTAINER (self->priv->center_grid),
self->priv->labels_grid);
self->priv->center_menu_child = grid = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
gtk_container_add (GTK_CONTAINER (grid), self->priv->labels_grid);
g_object_unref (self->priv->labels_grid);
w = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (grid), w);
self->priv->center_menu = button = gtk_menu_button_new ();
gtk_style_context_add_class (gtk_widget_get_style_context (self->priv->center_menu),
"selection-menu");
gtk_widget_destroy (gtk_bin_get_child (GTK_BIN (button)));
gtk_widget_set_halign (button, GTK_ALIGN_CENTER);
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), menu);
gtk_container_add (GTK_CONTAINER (self->priv->center_menu), grid);
gtk_container_add (GTK_CONTAINER (self->priv->center_grid), button);
}
else
{
g_object_ref (self->priv->labels_grid);
gtk_container_remove (GTK_CONTAINER (self->priv->center_menu_child),
self->priv->labels_grid);
gtk_widget_destroy (self->priv->center_menu);
self->priv->center_menu = NULL;
self->priv->center_menu_child = NULL;
gtk_container_add (GTK_CONTAINER (self->priv->center_grid),
self->priv->labels_grid);
g_object_unref (self->priv->labels_grid);
}
gtk_widget_show_all (self->priv->center_grid);
} | false | false | false | false | false | 0 |
cavan_sha_update(struct cavan_sha_context *context, const void *buff, size_t size)
{
size_t remain;
const void *buff_end = ADDR_ADD(buff, size);
if (context->remain > 0)
{
size_t padding;
padding = sizeof(context->buff) - context->remain;
if (padding <= size)
{
mem_copy(context->buff + context->remain, buff, padding);
context->transform(context->digest, context->dwbuff);
buff = ADDR_ADD(buff, padding);
context->remain = 0;
}
}
while (1)
{
remain = ADDR_SUB2(buff_end, buff);
if (remain < sizeof(context->buff))
{
break;
}
context->transform(context->digest, buff);
buff = ADDR_ADD(buff, sizeof(context->buff));
}
if (remain)
{
mem_copy(context->buff + context->remain, buff, remain);
context->remain += remain;
}
context->count += size;
} | false | false | false | false | false | 0 |
apply_remote_node_ordering(pe_working_set_t *data_set)
{
GListPtr gIter = data_set->actions;
if (is_set(data_set->flags, pe_flag_have_remote_nodes) == FALSE) {
return;
}
for (; gIter != NULL; gIter = gIter->next) {
action_t *action = (action_t *) gIter->data;
resource_t *remote_rsc = NULL;
resource_t *container = NULL;
if (!action->node ||
!action->node->details->remote_rsc ||
!action->rsc ||
is_set(action->flags, pe_action_pseudo)) {
continue;
}
remote_rsc = action->node->details->remote_rsc;
container = remote_rsc->container;
if (safe_str_eq(action->task, "monitor") ||
safe_str_eq(action->task, "start") ||
safe_str_eq(action->task, CRM_OP_LRM_REFRESH) ||
safe_str_eq(action->task, CRM_OP_CLEAR_FAILCOUNT) ||
safe_str_eq(action->task, "delete")) {
custom_action_order(remote_rsc,
generate_op_key(remote_rsc->id, RSC_START, 0),
NULL,
action->rsc,
NULL,
action,
pe_order_implies_then | pe_order_runnable_left,
data_set);
} else if (safe_str_eq(action->task, "stop") &&
container &&
is_set(container->flags, pe_rsc_failed)) {
/* when the container representing a remote node fails, the stop
* action for all the resources living in that container is implied
* by the container stopping. This is similar to how fencing operations
* work for cluster nodes. */
pe_set_action_bit(action, pe_action_pseudo);
custom_action_order(container,
generate_op_key(container->id, RSC_STOP, 0),
NULL,
action->rsc,
NULL,
action,
pe_order_implies_then | pe_order_runnable_left,
data_set);
} else if (safe_str_eq(action->task, "stop")) {
custom_action_order(action->rsc,
NULL,
action,
remote_rsc,
generate_op_key(remote_rsc->id, RSC_STOP, 0),
NULL,
pe_order_implies_first,
data_set);
}
}
} | false | false | false | false | false | 0 |
lpfc_sli4_async_dcbx_evt(struct lpfc_hba *phba,
struct lpfc_acqe_dcbx *acqe_dcbx)
{
phba->fc_eventTag = acqe_dcbx->event_tag;
lpfc_printf_log(phba, KERN_ERR, LOG_SLI,
"0290 The SLI4 DCBX asynchronous event is not "
"handled yet\n");
} | false | false | false | false | false | 0 |
getport(const char *name)
{
struct servent *svp;
svp = getservbyname (name, "udp");
if (!svp) {
return 0;
}
return ntohs(svp->s_port);
} | false | false | false | false | false | 0 |
mcb_request_mem(struct mcb_device *dev, const char *name)
{
struct resource *mem;
u32 size;
if (!name)
name = dev->dev.driver->name;
size = resource_size(&dev->mem);
mem = request_mem_region(dev->mem.start, size, name);
if (!mem)
return ERR_PTR(-EBUSY);
return mem;
} | false | false | false | false | false | 0 |
GetNextFeature()
{
if (bWriteMode)
{
CPLError(CE_Failure, CPLE_NotSupported,
"Cannot read features when writing a GPX file");
return NULL;
}
if (fpGPX == NULL)
return NULL;
if (bStopParsing)
return NULL;
#ifdef HAVE_EXPAT
if (nFeatureTabIndex < nFeatureTabLength)
{
return ppoFeatureTab[nFeatureTabIndex++];
}
if (VSIFEofL(fpGPX))
return NULL;
char aBuf[BUFSIZ];
CPLFree(ppoFeatureTab);
ppoFeatureTab = NULL;
nFeatureTabLength = 0;
nFeatureTabIndex = 0;
nWithoutEventCounter = 0;
int nDone;
do
{
nDataHandlerCounter = 0;
unsigned int nLen = (unsigned int)VSIFReadL( aBuf, 1, sizeof(aBuf), fpGPX );
nDone = VSIFEofL(fpGPX);
if (XML_Parse(oParser, aBuf, nLen, nDone) == XML_STATUS_ERROR)
{
CPLError(CE_Failure, CPLE_AppDefined,
"XML parsing of GPX file failed : %s at line %d, column %d",
XML_ErrorString(XML_GetErrorCode(oParser)),
(int)XML_GetCurrentLineNumber(oParser),
(int)XML_GetCurrentColumnNumber(oParser));
bStopParsing = TRUE;
break;
}
nWithoutEventCounter ++;
} while (!nDone && nFeatureTabLength == 0 && !bStopParsing && nWithoutEventCounter < 10);
if (nWithoutEventCounter == 10)
{
CPLError(CE_Failure, CPLE_AppDefined,
"Too much data inside one element. File probably corrupted");
bStopParsing = TRUE;
}
return (nFeatureTabLength) ? ppoFeatureTab[nFeatureTabIndex++] : NULL;
#else
return NULL;
#endif
} | false | false | false | false | false | 0 |
reload_cse_noop_set_p (rtx set)
{
if (cselib_reg_set_mode (SET_DEST (set)) != GET_MODE (SET_DEST (set)))
return 0;
return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set));
} | false | false | false | false | false | 0 |
hir(exec_list *instructions,
struct _mesa_glsl_parse_state *state)
{
labels->hir(instructions, state);
/* Conditionally set fallthru state based on break state. */
ir_constant *const false_val = new(state) ir_constant(false);
ir_dereference_variable *const deref_is_fallthru_var =
new(state) ir_dereference_variable(state->switch_state.is_fallthru_var);
ir_dereference_variable *const deref_is_break_var =
new(state) ir_dereference_variable(state->switch_state.is_break_var);
ir_assignment *const reset_fallthru_on_break =
new(state) ir_assignment(deref_is_fallthru_var,
false_val,
deref_is_break_var);
instructions->push_tail(reset_fallthru_on_break);
/* Guard case statements depending on fallthru state. */
ir_dereference_variable *const deref_fallthru_guard =
new(state) ir_dereference_variable(state->switch_state.is_fallthru_var);
ir_if *const test_fallthru = new(state) ir_if(deref_fallthru_guard);
foreach_list_typed (ast_node, stmt, link, & this->stmts)
stmt->hir(& test_fallthru->then_instructions, state);
instructions->push_tail(test_fallthru);
/* Case statements do not have r-values. */
return NULL;
} | false | false | false | false | false | 0 |
setPin(const unsigned char* pcOldPin, unsigned long ulOldPinLen, const unsigned char* pcPin, unsigned long ulPinLen) const
{
const CK_RV rv(m_p11->C_SetPIN(m_ulSessionHandle, const_cast<unsigned char*>(pcOldPin), ulOldPinLen, const_cast<unsigned char*>(pcPin), ulPinLen));
if (rv != CKR_OK)
pk11error("C_SetPIN", rv);
} | false | false | false | false | false | 0 |
rsh_file_stat2(file_t* file, int use_lstat)
{
#ifdef _WIN32
int i;
(void)use_lstat; /* ignore on windows */
file->mtime = 0;
if(file->wpath) {
free(file->wpath);
file->wpath = NULL;
}
for(i = 0; i < 2; i++) {
file->wpath = c2w(file->path, i);
if(file->wpath == NULL) continue;
/* return on success */
if (rsh_file_statw(file) == 0) return 0;
free(file->wpath);
file->wpath = NULL;
}
/* NB: usually errno is set by the rsh_file_statw() call */
if (!errno) errno = EINVAL;
return -1;
#else
struct rsh_stat_struct st;
int res = 0;
file->mode = 0;
do {
if(use_lstat) {
/* check for symlink */
if(lstat(file->path, &st) < 0) return -1;
if(!S_ISLNK(st.st_mode)) break;
/* it's a symlink */
file->mode |= FILE_IFLNK;
}
res = rsh_stat(file->path, &st);
} while(0);
file->size = st.st_size;
file->mtime = st.st_mtime;
if(S_ISDIR(st.st_mode)) {
file->mode |= FILE_IFDIR;
} else if(S_ISREG(st.st_mode)) {
/* it's a regular file or a symlink pointing to a regular file */
file->mode |= FILE_IFREG;
}
return res;
#endif /* _WIN32 */
} | false | false | false | false | false | 0 |
pci_free_cap_save_buffers(struct pci_dev *dev)
{
struct pci_cap_saved_state *tmp;
struct hlist_node *n;
hlist_for_each_entry_safe(tmp, n, &dev->saved_cap_space, next)
kfree(tmp);
} | false | false | false | false | false | 0 |
get_chip_set_event_data2_message (unsigned int offset, uint8_t event_data2, char *buf, unsigned int buflen)
{
assert (buf && buflen);
if (offset == IPMI_SENSOR_TYPE_CHIP_SET_SOFT_POWER_CONTROL_FAILURE
&& event_data2 <= ipmi_sensor_type_chip_set_event_data2_offset_soft_power_control_failure_max_index)
return (_snprintf (buf, buflen, ipmi_sensor_type_chip_set_event_data2_offset_soft_power_control_failure[event_data2]));
SET_ERRNO (EINVAL);
return (-1);
} | false | false | false | false | true | 1 |
createCurvedPlane( const String& name, const String& groupName,
const Plane& plane, Real width, Real height, Real bow, int xsegments, int ysegments,
bool normals, unsigned short numTexCoordSets, Real xTile, Real yTile, const Vector3& upVector,
HardwareBuffer::Usage vertexBufferUsage, HardwareBuffer::Usage indexBufferUsage,
bool vertexShadowBuffer, bool indexShadowBuffer)
{
// Create manual mesh which calls back self to load
MeshPtr pMesh = createManual(name, groupName, this);
// Planes can never be manifold
pMesh->setAutoBuildEdgeLists(false);
// store parameters
MeshBuildParams params;
params.type = MBT_CURVED_PLANE;
params.plane = plane;
params.width = width;
params.height = height;
params.curvature = bow;
params.xsegments = xsegments;
params.ysegments = ysegments;
params.normals = normals;
params.numTexCoordSets = numTexCoordSets;
params.xTile = xTile;
params.yTile = yTile;
params.upVector = upVector;
params.vertexBufferUsage = vertexBufferUsage;
params.indexBufferUsage = indexBufferUsage;
params.vertexShadowBuffer = vertexShadowBuffer;
params.indexShadowBuffer = indexShadowBuffer;
mMeshBuildParams[pMesh.getPointer()] = params;
// to preserve previous behaviour, load immediately
pMesh->load();
return pMesh;
} | false | false | false | false | false | 0 |
Hxeqb(double *b) const
{
double *rhs=b;
int row, rowBeg, *ind, *indEnd;
double xr, *eta;
// now solve
for ( int k=0; k <= lastEtaRow_; ++k ){
row=EtaPosition_[k];
rowBeg=EtaStarts_[k];
xr=0.0;
ind=EtaInd_+rowBeg;
indEnd=ind+EtaLengths_[k];
eta=Eta_+rowBeg;
for ( ; ind!=indEnd; ++ind ){
xr += rhs[ *ind ] * (*eta);
++eta;
}
rhs[row]-=xr;
}
} | false | false | false | false | false | 0 |
intel_init_bsd_ring_buffer(struct drm_device *dev)
{
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_engine_cs *ring = &dev_priv->ring[VCS];
ring->name = "bsd ring";
ring->id = VCS;
ring->write_tail = ring_write_tail;
if (INTEL_INFO(dev)->gen >= 6) {
ring->mmio_base = GEN6_BSD_RING_BASE;
/* gen6 bsd needs a special wa for tail updates */
if (IS_GEN6(dev))
ring->write_tail = gen6_bsd_ring_write_tail;
ring->flush = gen6_bsd_ring_flush;
ring->add_request = gen6_add_request;
ring->get_seqno = gen6_ring_get_seqno;
ring->set_seqno = ring_set_seqno;
if (INTEL_INFO(dev)->gen >= 8) {
ring->irq_enable_mask =
GT_RENDER_USER_INTERRUPT << GEN8_VCS1_IRQ_SHIFT;
ring->irq_get = gen8_ring_get_irq;
ring->irq_put = gen8_ring_put_irq;
ring->dispatch_execbuffer =
gen8_ring_dispatch_execbuffer;
if (i915_semaphore_is_enabled(dev)) {
ring->semaphore.sync_to = gen8_ring_sync;
ring->semaphore.signal = gen8_xcs_signal;
GEN8_RING_SEMAPHORE_INIT;
}
} else {
ring->irq_enable_mask = GT_BSD_USER_INTERRUPT;
ring->irq_get = gen6_ring_get_irq;
ring->irq_put = gen6_ring_put_irq;
ring->dispatch_execbuffer =
gen6_ring_dispatch_execbuffer;
if (i915_semaphore_is_enabled(dev)) {
ring->semaphore.sync_to = gen6_ring_sync;
ring->semaphore.signal = gen6_signal;
ring->semaphore.mbox.wait[RCS] = MI_SEMAPHORE_SYNC_VR;
ring->semaphore.mbox.wait[VCS] = MI_SEMAPHORE_SYNC_INVALID;
ring->semaphore.mbox.wait[BCS] = MI_SEMAPHORE_SYNC_VB;
ring->semaphore.mbox.wait[VECS] = MI_SEMAPHORE_SYNC_VVE;
ring->semaphore.mbox.wait[VCS2] = MI_SEMAPHORE_SYNC_INVALID;
ring->semaphore.mbox.signal[RCS] = GEN6_RVSYNC;
ring->semaphore.mbox.signal[VCS] = GEN6_NOSYNC;
ring->semaphore.mbox.signal[BCS] = GEN6_BVSYNC;
ring->semaphore.mbox.signal[VECS] = GEN6_VEVSYNC;
ring->semaphore.mbox.signal[VCS2] = GEN6_NOSYNC;
}
}
} else {
ring->mmio_base = BSD_RING_BASE;
ring->flush = bsd_ring_flush;
ring->add_request = i9xx_add_request;
ring->get_seqno = ring_get_seqno;
ring->set_seqno = ring_set_seqno;
if (IS_GEN5(dev)) {
ring->irq_enable_mask = ILK_BSD_USER_INTERRUPT;
ring->irq_get = gen5_ring_get_irq;
ring->irq_put = gen5_ring_put_irq;
} else {
ring->irq_enable_mask = I915_BSD_USER_INTERRUPT;
ring->irq_get = i9xx_ring_get_irq;
ring->irq_put = i9xx_ring_put_irq;
}
ring->dispatch_execbuffer = i965_dispatch_execbuffer;
}
ring->init_hw = init_ring_common;
return intel_init_ring_buffer(dev, ring);
} | false | false | false | false | false | 0 |
info (ACE_TCHAR **strp,
size_t length) const
{
ACE_TRACE ("ACE_Naming_Context::info");
ACE_TCHAR buf[BUFSIZ];
ACE_OS::sprintf (buf,
ACE_TEXT ("%s\t#%s\n"),
ACE_TEXT ("ACE_Naming_Context"),
ACE_TEXT ("Proxy for making calls to a Name Server"));
if (*strp == 0 && (*strp = ACE_OS::strdup (buf)) == 0)
return -1;
else
ACE_OS::strsncpy (*strp, buf, length);
return static_cast<int> (ACE_OS::strlen (buf));
} | false | false | false | false | false | 0 |
alists_hidden(alists_t * alists, const board_t * board, int from, int to) {
int inc;
int sq, piece;
ASSERT(alists!=NULL);
ASSERT(board!=NULL);
ASSERT(SQUARE_IS_OK(from));
ASSERT(SQUARE_IS_OK(to));
inc = DELTA_INC_LINE(to-from);
if (inc != IncNone) { // line
sq = from;
do sq -= inc; while ((piece=board->square[sq]) == Empty);
if (SLIDER_ATTACK(piece,inc)) {
ASSERT(piece_is_ok(piece));
ASSERT(PIECE_IS_SLIDER(piece));
alist_add(alists->alist[PIECE_COLOUR(piece)],sq,board);
}
}
} | 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.