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 |
|---|---|---|---|---|---|---|
savegame_exists(const char *name)
{
struct dirent **eps = NULL;
int n = find_saved_games(&eps);
int exists = 0;
int i;
for (i = 0; i < n; i++) {
if (strcmp(eps[i]->d_name, name) == 0) {
exists = 1;
break;
}
}
for (i = 0; i <n; i++)
free(eps[i]);
free(eps);
return exists;
} | false | false | false | false | false | 0 |
GetImageTransition( int index )
{
switch( index )
{
case 0:
return new Tweenies();
case 1:
return new GDKImageTransitionAdapter( new ImageTransitionChromaKeyBlue() );
case 2:
return new GDKImageTransitionAdapter( new ImageTransitionChromaKeyGreen() );
}
return NULL;
} | false | false | false | false | false | 0 |
math_setdigits(LEN newdigits)
{
LEN olddigits;
if (newdigits < 0) {
math_error("Setting illegal number of digits");
/*NOTREACHED*/
}
olddigits = conf->outdigits;
conf->outdigits = newdigits;
return olddigits;
} | false | false | false | false | false | 0 |
ixgbe_ndo_set_vf_rss_query_en(struct net_device *netdev, int vf,
bool setting)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
/* This operation is currently supported only for 82599 and x540
* devices.
*/
if (adapter->hw.mac.type < ixgbe_mac_82599EB ||
adapter->hw.mac.type >= ixgbe_mac_X550)
return -EOPNOTSUPP;
if (vf >= adapter->num_vfs)
return -EINVAL;
adapter->vfinfo[vf].rss_query_enabled = setting;
return 0;
} | false | false | false | false | false | 0 |
kona_peri_clk_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct kona_clk *bcm_clk = to_kona_clk(hw);
struct clk_hw *current_parent;
unsigned long parent_rate;
unsigned long best_delta;
unsigned long best_rate;
u32 parent_count;
long rate;
u32 which;
/*
* If there is no other parent to choose, use the current one.
* Note: We don't honor (or use) CLK_SET_RATE_NO_REPARENT.
*/
WARN_ON_ONCE(bcm_clk->init_data.flags & CLK_SET_RATE_NO_REPARENT);
parent_count = (u32)bcm_clk->init_data.num_parents;
if (parent_count < 2) {
rate = kona_peri_clk_round_rate(hw, req->rate,
&req->best_parent_rate);
if (rate < 0)
return rate;
req->rate = rate;
return 0;
}
/* Unless we can do better, stick with current parent */
current_parent = clk_hw_get_parent(hw);
parent_rate = clk_hw_get_rate(current_parent);
best_rate = kona_peri_clk_round_rate(hw, req->rate, &parent_rate);
best_delta = abs(best_rate - req->rate);
/* Check whether any other parent clock can produce a better result */
for (which = 0; which < parent_count; which++) {
struct clk_hw *parent = clk_hw_get_parent_by_index(hw, which);
unsigned long delta;
unsigned long other_rate;
BUG_ON(!parent);
if (parent == current_parent)
continue;
/* We don't support CLK_SET_RATE_PARENT */
parent_rate = clk_hw_get_rate(parent);
other_rate = kona_peri_clk_round_rate(hw, req->rate,
&parent_rate);
delta = abs(other_rate - req->rate);
if (delta < best_delta) {
best_delta = delta;
best_rate = other_rate;
req->best_parent_hw = parent;
req->best_parent_rate = parent_rate;
}
}
req->rate = best_rate;
return 0;
} | false | false | false | false | false | 0 |
StartTransaction()
{
GetLayerDefn();
if (bInTransaction)
{
CPLError(CE_Failure, CPLE_AppDefined, "Already in transaction");
return OGRERR_FAILURE;
}
if (!poDS->IsReadWrite())
{
CPLError(CE_Failure, CPLE_AppDefined,
"Operation not available in read-only mode");
return OGRERR_FAILURE;
}
bInTransaction = TRUE;
return OGRERR_NONE;
} | false | false | false | false | false | 0 |
parse_instruction_file(const char *filename, Signatures &sigs,
ErrorHandler *errh)
{
String text = file_string(filename, errh);
const char *s = text.data();
int pos = 0;
int len = text.length();
while (pos < len) {
int pos1 = pos;
while (pos < len && s[pos] != '\n' && s[pos] != '\r')
pos++;
parse_instruction(text.substring(pos1, pos - pos1), sigs, errh);
while (pos < len && (s[pos] == '\n' || s[pos] == '\r'))
pos++;
}
} | false | false | false | false | false | 0 |
InitVolumeBounds( int NBounds,int N,Geometry_t *RTElements )
{
int i;
VolumeBounds = (VolumeBounds_t *)calloc( 1,sizeof(VolumeBounds_t) );
VolumeBounds->n = N;
VolumeBounds->Elements = (int *)malloc( N*sizeof(int) );
for( i=0;i<N; i++ ) VolumeBounds->Elements[i] = i;
VolumeBBox( VolumeBounds,RTElements );
VolumeDivide( VolumeBounds,NBounds,RTElements,0 );
} | false | true | false | false | false | 1 |
connected (struct board *board, short move)
{
short maxcon = 1;
short px, py, connect;
/* Check vertical */
connect = 1;
px = move;
py = board->stack[move] - 1;
while (py >= 0 && board->square[ELM (px, py)] == board->turn) {
connect++;
py--;
}
maxcon = max (connect, maxcon);
/* Check horizontal */
connect = 1;
px = move - 1;
py = board->stack[move];
while (px >= 0 && board->square[ELM (px, py)] == board->turn) {
connect++;
px--;
}
px = move + 1;
while (px < BOARDX && board->square[ELM (px, py)] == board->turn) {
connect++;
px++;
}
maxcon = max (connect, maxcon);
/* Check NW - SE diagonal */
connect = 1;
px = move - 1;
py = board->stack[move] + 1;
while (px >= 0 && py < BOARDY && board->square[ELM (px, py)] == board->turn) {
connect++;
px--;
py++;
}
px = move + 1;
py = board->stack[move] - 1;
while (px < BOARDX && py >= 0 && board->square[ELM (px, py)] == board->turn) {
connect++;
px++;
py--;
}
maxcon = max (connect, maxcon);
/* Check NE - SW */
connect = 1;
px = move - 1;
py = board->stack[move] - 1;
while (px >= 0 && py >= 0 && board->square[ELM (px, py)] == board->turn) {
connect++;
px--;
py--;
}
px = move + 1;
py = board->stack[move] + 1;
while (px < BOARDX && py < BOARDY
&& board->square[ELM (px, py)] == board->turn) {
connect++;
px++;
py++;
}
maxcon = max (connect, maxcon);
return maxcon;
} | false | false | false | false | false | 0 |
hash_table_find_all (GHashTable *hash_table,
GHRFunc predicate,
gpointer user_data)
{
HashTableFindAllData *data;
GList *list;
data = g_new0 (HashTableFindAllData, 1);
data->predicate = predicate;
data->user_data = user_data;
g_hash_table_foreach (hash_table, (GHFunc) find_all_func, data);
list = data->list;
g_free (data);
return list;
} | false | false | false | false | false | 0 |
rt2400pci_interrupt(int irq, void *dev_instance)
{
struct rt2x00_dev *rt2x00dev = dev_instance;
u32 reg, mask;
/*
* Get the interrupt sources & saved to local variable.
* Write register value back to clear pending interrupts.
*/
rt2x00mmio_register_read(rt2x00dev, CSR7, ®);
rt2x00mmio_register_write(rt2x00dev, CSR7, reg);
if (!reg)
return IRQ_NONE;
if (!test_bit(DEVICE_STATE_ENABLED_RADIO, &rt2x00dev->flags))
return IRQ_HANDLED;
mask = reg;
/*
* Schedule tasklets for interrupt handling.
*/
if (rt2x00_get_field32(reg, CSR7_TBCN_EXPIRE))
tasklet_hi_schedule(&rt2x00dev->tbtt_tasklet);
if (rt2x00_get_field32(reg, CSR7_RXDONE))
tasklet_schedule(&rt2x00dev->rxdone_tasklet);
if (rt2x00_get_field32(reg, CSR7_TXDONE_ATIMRING) ||
rt2x00_get_field32(reg, CSR7_TXDONE_PRIORING) ||
rt2x00_get_field32(reg, CSR7_TXDONE_TXRING)) {
tasklet_schedule(&rt2x00dev->txstatus_tasklet);
/*
* Mask out all txdone interrupts.
*/
rt2x00_set_field32(&mask, CSR8_TXDONE_TXRING, 1);
rt2x00_set_field32(&mask, CSR8_TXDONE_ATIMRING, 1);
rt2x00_set_field32(&mask, CSR8_TXDONE_PRIORING, 1);
}
/*
* Disable all interrupts for which a tasklet was scheduled right now,
* the tasklet will reenable the appropriate interrupts.
*/
spin_lock(&rt2x00dev->irqmask_lock);
rt2x00mmio_register_read(rt2x00dev, CSR8, ®);
reg |= mask;
rt2x00mmio_register_write(rt2x00dev, CSR8, reg);
spin_unlock(&rt2x00dev->irqmask_lock);
return IRQ_HANDLED;
} | false | false | false | false | false | 0 |
addParserHandlers(void)
{
std::list<ArConfigSection *>::const_iterator it;
std::list<ArConfigArg> *params;
std::list<ArConfigArg>::iterator pit;
if (!myParser.addHandlerWithError("section", &mySectionCB)) {
IFDEBUG(ArLog::log(ArLog::Verbose,
"%sCould not add section parser (probably unimportant)",
myLogPrefix.c_str()));
}
for (it = mySections.begin();
it != mySections.end();
it++)
{
params = (*it)->getParams();
if (params == NULL)
continue;
for (pit = params->begin(); pit != params->end(); pit++)
{
if (!myParser.addHandlerWithError((*pit).getName(), &myParserCB)) {
IFDEBUG(ArLog::log(ArLog::Verbose,
"%sCould not add keyword %s (probably unimportant)",
myLogPrefix.c_str(),
(*pit).getName()));
}
}
}
// add our parser for unknown params
if (!myParser.addHandlerWithError(NULL, &myUnknownCB)) {
IFDEBUG(ArLog::log(ArLog::Verbose,
"%sCould not add unknown param parser (probably unimportant)",
myLogPrefix.c_str()));
}
} | false | false | false | false | false | 0 |
__generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
struct address_space * mapping = file->f_mapping;
struct inode *inode = mapping->host;
ssize_t written = 0;
ssize_t err;
ssize_t status;
/* We can write back this queue in page reclaim */
current->backing_dev_info = inode_to_bdi(inode);
err = file_remove_privs(file);
if (err)
goto out;
err = file_update_time(file);
if (err)
goto out;
if (iocb->ki_flags & IOCB_DIRECT) {
loff_t pos, endbyte;
written = generic_file_direct_write(iocb, from, iocb->ki_pos);
/*
* If the write stopped short of completing, fall back to
* buffered writes. Some filesystems do this for writes to
* holes, for example. For DAX files, a buffered write will
* not succeed (even if it did, DAX does not handle dirty
* page-cache pages correctly).
*/
if (written < 0 || !iov_iter_count(from) || IS_DAX(inode))
goto out;
status = generic_perform_write(file, from, pos = iocb->ki_pos);
/*
* If generic_perform_write() returned a synchronous error
* then we want to return the number of bytes which were
* direct-written, or the error code if that was zero. Note
* that this differs from normal direct-io semantics, which
* will return -EFOO even if some bytes were written.
*/
if (unlikely(status < 0)) {
err = status;
goto out;
}
/*
* We need to ensure that the page cache pages are written to
* disk and invalidated to preserve the expected O_DIRECT
* semantics.
*/
endbyte = pos + status - 1;
err = filemap_write_and_wait_range(mapping, pos, endbyte);
if (err == 0) {
iocb->ki_pos = endbyte + 1;
written += status;
invalidate_mapping_pages(mapping,
pos >> PAGE_CACHE_SHIFT,
endbyte >> PAGE_CACHE_SHIFT);
} else {
/*
* We don't know how much we wrote, so just return
* the number of bytes which were direct-written
*/
}
} else {
written = generic_perform_write(file, from, iocb->ki_pos);
if (likely(written > 0))
iocb->ki_pos += written;
}
out:
current->backing_dev_info = NULL;
return written ? written : err;
} | false | false | false | false | false | 0 |
get_site_from_url (const gchar *url)
{
gchar *p;
if (g_str_has_prefix (url, "file://")) {
return NULL;
}
p = strstr (url, "://");
if (!p) {
return NULL;
} else {
p += 3;
}
while (*p != '/') p++;
return g_strndup (url, p - url);
} | false | false | false | false | false | 0 |
crlf_load_attributes(struct crlf_attrs *ca, git_repository *repo, const char *path)
{
#define NUM_CONV_ATTRS 3
static const char *attr_names[NUM_CONV_ATTRS] = {
"crlf", "eol", "text",
};
const char *attr_vals[NUM_CONV_ATTRS];
int error;
error = git_attr_get_many(attr_vals,
repo, 0, path, NUM_CONV_ATTRS, attr_names);
if (error == GIT_ENOTFOUND) {
ca->crlf_action = GIT_CRLF_GUESS;
ca->eol = GIT_EOL_UNSET;
return 0;
}
if (error == 0) {
ca->crlf_action = check_crlf(attr_vals[2]); /* text */
if (ca->crlf_action == GIT_CRLF_GUESS)
ca->crlf_action = check_crlf(attr_vals[0]); /* clrf */
ca->eol = check_eol(attr_vals[1]); /* eol */
return 0;
}
return -1;
} | true | true | false | false | false | 1 |
WriteEffectPassShader(FCDObject* object, xmlNode* parentNode)
{
FCDEffectPassShader* effectPassShader = (FCDEffectPassShader*)object;
xmlNode* shaderNode = AddChild(parentNode, DAE_SHADER_ELEMENT);
// Write out the compiler information and the shader's name/stage
if (!effectPassShader->GetCompilerTarget().empty()) AddChild(shaderNode, DAE_FXCMN_COMPILERTARGET_ELEMENT, effectPassShader->GetCompilerTarget());
if (!effectPassShader->GetCompilerOptions().empty()) AddChild(shaderNode, DAE_FXCMN_COMPILEROPTIONS_ELEMENT, effectPassShader->GetCompilerOptions());
AddAttribute(shaderNode, DAE_STAGE_ATTRIBUTE, effectPassShader->IsFragmentShader() ? DAE_FXCMN_FRAGMENT_SHADER : DAE_FXCMN_VERTEX_SHADER);
if (!effectPassShader->GetName().empty())
{
xmlNode* nameNode = AddChild(shaderNode, DAE_FXCMN_NAME_ELEMENT, effectPassShader->GetName());
if (effectPassShader->GetCode() != NULL) AddAttribute(nameNode, DAE_SOURCE_ATTRIBUTE, effectPassShader->GetCode()->GetSubId());
}
// Write out the bindings
for (size_t i = 0; i < effectPassShader->GetBindingCount(); ++i)
{
const FCDEffectPassBind* b = effectPassShader->GetBinding(i);
if (!b->reference->empty() && !b->symbol->empty())
{
xmlNode* bindNode = AddChild(shaderNode, DAE_BIND_ELEMENT);
AddAttribute(bindNode, DAE_SYMBOL_ATTRIBUTE, b->symbol);
xmlNode* paramNode = AddChild(bindNode, DAE_PARAMETER_ELEMENT);
AddAttribute(paramNode, DAE_REF_ATTRIBUTE, b->reference);
}
}
return shaderNode;
} | false | false | false | false | false | 0 |
dispatch_prescan(clcb_pre_scan cb, cli_ctx *ctx, const char *filetype, bitset_t *old_hook_lsig_matches, void *parent_property, unsigned char *hash, size_t hashed_size, int *run_cleanup)
{
int res=CL_CLEAN;
UNUSEDPARAM(parent_property);
UNUSEDPARAM(hash);
UNUSEDPARAM(hashed_size);
*run_cleanup = 0;
if(cb) {
perf_start(ctx, PERFT_PRECB);
switch(cb(fmap_fd(*ctx->fmap), filetype, ctx->cb_ctx)) {
case CL_BREAK:
cli_dbgmsg("cli_magic_scandesc: file whitelisted by callback\n");
perf_stop(ctx, PERFT_PRECB);
ctx->hook_lsig_matches = old_hook_lsig_matches;
/* returns CL_CLEAN */
*run_cleanup = 1;
break;
case CL_VIRUS:
cli_dbgmsg("cli_magic_scandesc: file blacklisted by callback\n");
cli_append_virus(ctx, "Detected.By.Callback");
perf_stop(ctx, PERFT_PRECB);
ctx->hook_lsig_matches = old_hook_lsig_matches;
*run_cleanup = 1;
res = CL_VIRUS;
break;
case CL_CLEAN:
break;
default:
cli_warnmsg("cli_magic_scandesc: ignoring bad return code from callback\n");
}
perf_stop(ctx, PERFT_PRECB);
}
return res;
} | false | false | false | false | false | 0 |
delPrefix(SPtr<TIPv6Addr> x)
{
SPtr<TAddrPrefix> ptr;
PrefixLst.first();
while (ptr = PrefixLst.get())
{
/// @todo: should we compare prefix length, too?
if (*(ptr->get())==(*x)) {
PrefixLst.del();
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
_k_prevTip()
{
database->prevTip();
tipText->setHtml( QString::fromLatin1( "<html><body>%1</body></html>" )
.arg( i18n( database->tip().toUtf8() ) ) );
} | false | false | false | false | false | 0 |
flickcurl_photos_getCounts(flickcurl* fc,
const char** dates_array,
const char** taken_dates_array)
{
xmlDocPtr doc = NULL;
xmlXPathContextPtr xpathCtx = NULL;
int** counts = NULL;
char* dates = NULL;
char* taken_dates = NULL;
flickcurl_init_params(fc, 0);
/* one must be not empty */
if(!dates_array && !taken_dates_array)
return NULL;
if(dates_array) {
dates = flickcurl_array_join(dates_array, ',');
flickcurl_add_param(fc, "dates", dates);
}
if(taken_dates_array) {
taken_dates = flickcurl_array_join(taken_dates_array, ',');
flickcurl_add_param(fc, "taken_dates", taken_dates);
}
flickcurl_end_params(fc);
if(flickcurl_prepare(fc, "flickr.photos.getCounts"))
goto tidy;
doc = flickcurl_invoke(fc);
if(!doc)
goto tidy;
xpathCtx = xmlXPathNewContext(doc);
if(!xpathCtx) {
flickcurl_error(fc, "Failed to create XPath context for document");
fc->failed = 1;
goto tidy;
}
counts = flickcurl_build_photocounts(fc, xpathCtx,
(const xmlChar*)"/rsp/photocounts/photocount",
NULL);
tidy:
if(xpathCtx)
xmlXPathFreeContext(xpathCtx);
if(fc->failed) {
if(counts)
free(counts);
counts = NULL;
}
if(dates)
free(dates);
if(taken_dates)
free(taken_dates);
return counts;
} | false | false | false | false | false | 0 |
LM_add_test (MODEL *pmod, DATASET *dset, int *list,
gretlopt opt, PRN *prn)
{
MODEL aux;
int err;
err = add_residual_to_dataset(pmod, dset);
if (err) {
gretl_model_init(&aux, dset);
aux.errcode = err;
return aux;
}
list[1] = dset->v - 1;
aux = lsq(list, dset, OLS, OPT_A | OPT_Z);
if (aux.errcode) {
fprintf(stderr, "auxiliary regression failed\n");
} else {
int df = aux.ncoeff - pmod->ncoeff;
if (df <= 0) {
/* couldn't add any regressors */
aux.errcode = E_SINGULAR;
} else {
if (!(opt & (OPT_Q | OPT_I))) {
aux.aux = AUX_ADD;
printmodel(&aux, dset, OPT_S, prn);
}
}
}
return aux;
} | false | false | false | false | false | 0 |
gionbana_scrolly_w(int data)
{
if (gionbana_flipscreen) gionbana_scrolly1 = -2;
else gionbana_scrolly1 = 0;
if (gionbana_flipscreen) gionbana_scrolly2 = (data ^ 0xff) & 0xff;
else gionbana_scrolly2 = (data - 1) & 0xff;
} | false | false | false | false | false | 0 |
alert_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a,
PLCI *plci, APPL *appl, API_PARSE *msg)
{
word Info;
byte ret;
dbug(1, dprintf("alert_req"));
Info = _WRONG_IDENTIFIER;
ret = false;
if (plci) {
Info = _ALERT_IGNORED;
if (plci->State != INC_CON_ALERT) {
Info = _WRONG_STATE;
if (plci->State == INC_CON_PENDING) {
Info = 0;
plci->State = INC_CON_ALERT;
add_ai(plci, &msg[0]);
sig_req(plci, CALL_ALERT, 0);
ret = 1;
}
}
}
sendf(appl,
_ALERT_R | CONFIRM,
Id,
Number,
"w", Info);
return ret;
} | false | false | false | false | false | 0 |
AcpiRsStrcpy (
char *Destination,
char *Source)
{
UINT16 i;
ACPI_FUNCTION_ENTRY ();
for (i = 0; Source[i]; i++)
{
Destination[i] = Source[i];
}
Destination[i] = 0;
/* Return string length including the NULL terminator */
return ((UINT16) (i + 1));
} | false | false | false | false | false | 0 |
writeValue( const Value &value )
{
switch ( value.type() )
{
case nullValue:
pushValue( "null" );
break;
case intValue:
pushValue( valueToString( value.asInt() ) );
break;
case uintValue:
pushValue( valueToString( value.asUInt() ) );
break;
case realValue:
pushValue( valueToString( value.asDouble() ) );
break;
case stringValue:
pushValue( valueToQuotedString( value.asCString() ) );
break;
case booleanValue:
pushValue( valueToString( value.asBool() ) );
break;
case arrayValue:
writeArrayValue( value);
break;
case objectValue:
{
Value::Members members( value.getMemberNames() );
if ( members.empty() )
pushValue( "{}" );
else
{
writeWithIndent( "{" );
indent();
Value::Members::iterator it = members.begin();
while ( true )
{
const std::string &name = *it;
const Value &childValue = value[name];
writeCommentBeforeValue( childValue );
writeWithIndent( valueToQuotedString( name.c_str() ) );
document_ += " : ";
writeValue( childValue );
if ( ++it == members.end() )
{
writeCommentAfterValueOnSameLine( childValue );
break;
}
document_ += ",";
writeCommentAfterValueOnSameLine( childValue );
}
unindent();
writeWithIndent( "}" );
}
}
break;
}
} | false | false | false | false | false | 0 |
create_content_view (NautilusWindowSlot *slot,
const char *view_id,
GError **error_out)
{
NautilusWindow *window;
NautilusView *view;
GList *selection;
gboolean ret = TRUE;
GError *error = NULL;
NautilusDirectory *old_directory, *new_directory;
GFile *old_location;
window = nautilus_window_slot_get_window (slot);
nautilus_profile_start (NULL);
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
* for the desktop window.
*/
if (NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* We force the desktop to use a desktop_icon_view. It's simpler
* to fix it here than trying to make it pick the right view in
* the first place.
*/
view_id = NAUTILUS_DESKTOP_ICON_VIEW_IID;
}
if (nautilus_window_slot_content_view_matches_iid (slot, view_id)) {
/* reuse existing content view */
view = slot->details->content_view;
slot->details->new_content_view = view;
g_object_ref (view);
} else {
/* create a new content view */
view = nautilus_view_new (view_id, slot);
slot->details->new_content_view = view;
nautilus_window_slot_connect_new_content_view (slot);
}
/* Forward search selection and state before loading the new model */
old_location = nautilus_window_slot_get_location (slot);
old_directory = nautilus_directory_get (old_location);
new_directory = nautilus_directory_get (slot->details->pending_location);
if (NAUTILUS_IS_SEARCH_DIRECTORY (new_directory) &&
!NAUTILUS_IS_SEARCH_DIRECTORY (old_directory)) {
nautilus_search_directory_set_base_model (NAUTILUS_SEARCH_DIRECTORY (new_directory), old_directory);
}
if (NAUTILUS_IS_SEARCH_DIRECTORY (old_directory) &&
!NAUTILUS_IS_SEARCH_DIRECTORY (new_directory)) {
/* Reset the search_active state when going out of a search directory,
* before nautilus_window_slot_sync_search_widgets() is called
* if we're not being loaded with search visible.
*/
if (!slot->details->load_with_search) {
slot->details->search_visible = FALSE;
}
slot->details->load_with_search = FALSE;
if (slot->details->pending_selection == NULL) {
slot->details->pending_selection = nautilus_view_get_selection (slot->details->content_view);
}
}
/* Actually load the pending location and selection: */
if (slot->details->pending_location != NULL) {
load_new_location (slot,
slot->details->pending_location,
slot->details->pending_selection,
FALSE,
TRUE);
g_list_free_full (slot->details->pending_selection, g_object_unref);
slot->details->pending_selection = NULL;
} else if (old_location != NULL) {
selection = nautilus_view_get_selection (slot->details->content_view);
load_new_location (slot,
old_location,
selection,
FALSE,
TRUE);
g_list_free_full (selection, g_object_unref);
} else {
/* Something is busted, there was no location to load. */
ret = FALSE;
error = g_error_new (G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
_("Unable to load location"));
}
if (error != NULL) {
g_propagate_error (error_out, error);
}
nautilus_profile_end (NULL);
return ret;
} | false | false | false | false | false | 0 |
reallochook (__ptr_t ptr, size_t size, const __ptr_t caller)
{
if (size == 0)
{
freehook (ptr, caller);
return NULL;
}
struct hdr *hdr;
size_t osize;
if (pedantic)
mcheck_check_all ();
if (size > ~((size_t) 0) - (sizeof (struct hdr) + 1))
{
__set_errno (ENOMEM);
return NULL;
}
if (ptr)
{
hdr = ((struct hdr *) ptr) - 1;
osize = hdr->size;
checkhdr (hdr);
unlink_blk (hdr);
if (size < osize)
flood ((char *) ptr + size, FREEFLOOD, osize - size);
}
else
{
osize = 0;
hdr = NULL;
}
__free_hook = old_free_hook;
__malloc_hook = old_malloc_hook;
__memalign_hook = old_memalign_hook;
__realloc_hook = old_realloc_hook;
if (old_realloc_hook != NULL)
hdr = (struct hdr *) (*old_realloc_hook)((__ptr_t) hdr,
sizeof (struct hdr) + size + 1,
caller);
else
hdr = (struct hdr *) realloc ((__ptr_t) hdr,
sizeof (struct hdr) + size + 1);
__free_hook = freehook;
__malloc_hook = mallochook;
__memalign_hook = memalignhook;
__realloc_hook = reallochook;
if (hdr == NULL)
return NULL;
hdr->size = size;
link_blk (hdr);
hdr->block = hdr;
hdr->magic2 = (uintptr_t) hdr ^ MAGICWORD;
((char *) &hdr[1])[size] = MAGICBYTE;
if (size > osize)
flood ((char *) (hdr + 1) + osize, MALLOCFLOOD, size - osize);
return (__ptr_t) (hdr + 1);
} | false | false | false | false | false | 0 |
_ecore_thread_kill(Ecore_Pthread_Worker *work)
{
if (work->cancel)
{
if (work->func_cancel)
work->func_cancel((void *)work->data, (Ecore_Thread *)work);
}
else
{
if (work->func_end)
work->func_end((void *)work->data, (Ecore_Thread *)work);
}
if (work->feedback_run)
{
if (work->u.feedback_run.direct_worker)
_ecore_thread_worker_free(work->u.feedback_run.direct_worker);
}
if (work->hash)
eina_hash_free(work->hash);
_ecore_thread_worker_free(work);
} | false | false | false | false | false | 0 |
dpm_srv_inc_reqctr(magic, req_data, clienthost, thip)
int magic;
char *req_data;
char *clienthost;
struct dpm_srv_thread_info *thip;
{
int c;
char func[19];
gid_t gid;
gid_t *gids;
char groups[256];
int nbgids;
char *p;
char *rbp;
uid_t uid;
char *user;
strcpy (func, "dpm_srv_inc_reqctr");
rbp = req_data;
unmarshall_LONG (rbp, uid);
unmarshall_LONG (rbp, gid);
get_client_actual_id (thip, &uid, &gid, &nbgids, &gids, &user);
p = Cencode_groups (nbgids, gids, groups, sizeof(groups));
dpmlogit (func, DP092, "inc_reqctr", user, uid, groups, clienthost);
if (! p) {
sendrep (thip->s, MSG_ERR, "Too many FQANs in proxy\n");
RETURN (EINVAL);
}
c = inc_reqctr ();
RETURN (c);
} | false | false | false | false | false | 0 |
runOnMachineFunction(MachineFunction &MF) {
STI = &static_cast<const X86Subtarget &>(MF.getSubtarget());
TII = STI->getInstrInfo();
TRI = STI->getRegisterInfo();
X86FL = STI->getFrameLowering();
bool Modified = false;
for (MachineBasicBlock &MBB : MF)
Modified |= ExpandMBB(MBB);
return Modified;
} | false | false | false | false | false | 0 |
ie31200_init(void)
{
edac_dbg(3, "MC:\n");
/* Ensure that the OPSTATE is set correctly for POLL or NMI */
opstate_init();
return pci_register_driver(&ie31200_driver);
} | false | false | false | false | false | 0 |
sel_netport_insert(struct sel_netport *port)
{
unsigned int idx;
/* we need to impose a limit on the growth of the hash table so check
* this bucket to make sure it is within the specified bounds */
idx = sel_netport_hashfn(port->psec.port);
list_add_rcu(&port->list, &sel_netport_hash[idx].list);
if (sel_netport_hash[idx].size == SEL_NETPORT_HASH_BKT_LIMIT) {
struct sel_netport *tail;
tail = list_entry(
rcu_dereference_protected(
sel_netport_hash[idx].list.prev,
lockdep_is_held(&sel_netport_lock)),
struct sel_netport, list);
list_del_rcu(&tail->list);
kfree_rcu(tail, rcu);
} else
sel_netport_hash[idx].size++;
} | false | false | false | false | false | 0 |
Restart(void)
{
Item *item;
CF.cur_input = NULL;
CF.abs_cursor = CF.rel_cursor = 0;
for (item = root_item_ptr; item != 0;
item = item->header.next) {/* all items */
switch (item->type) {
case I_INPUT:
if (!CF.cur_input)
CF.cur_input = item;
/* save old input values in a recall ring. */
if (item->input.value && item->input.value[0] != 0) { /* ? to save */
if (item->input.value_history_ptr == 0) { /* no history yet */
item->input.value_history_ptr =
(char **)safecalloc(sizeof(char *), 50);
item->input.value_history_ptr[0] = safestrdup(item->input.value);
item->input.value_history_count = 1; /* next insertion point */
myfprintf((stderr,"Initial save of %s in slot 0\n",
item->input.value_history_ptr[0]));
} else { /* we have a history */
int prior;
prior = item->input.value_history_count - 1;
if (prior < 0) {
for (prior = VH_SIZE - 1;
CF.cur_input->input.value_history_ptr[prior] == 0;
--prior); /* find last used slot */
}
myfprintf((stderr,"Prior is %d, compare %s to %s\n",
prior, item->input.value,
item->input.value_history_ptr[prior]));
if ( strcmp(item->input.value, item->input.value_history_ptr[prior])
!= 0) { /* different value */
if (item->input.value_history_ptr[item->input.value_history_count])
{
free(item->input.value_history_ptr[
item->input.value_history_count]);
myfprintf((stderr,"Freeing old item in slot %d\n",
item->input.value_history_count));
}
item->input.value_history_ptr[item->input.value_history_count] =
safestrdup(item->input.value); /* save value ptr in array */
myfprintf((stderr,"Save of %s in slot %d\n",
item->input.value,
item->input.value_history_count));
/* leave count pointing at the next insertion point. */
if (item->input.value_history_count < VH_SIZE - 1) { /* not full */
++item->input.value_history_count; /* next slot */
} else {
item->input.value_history_count = 0; /* wrap around */
}
} /* end something different */
} /* end have a history */
myfprintf((stderr,"New history yankat %d\n",
item->input.value_history_yankat));
} /* end something to save */
item->input.value_history_yankat = item->input.value_history_count;
item->input.n = strlen(item->input.init_value);
strcpy(item->input.value, item->input.init_value);
item->input.left = 0;
break;
case I_CHOICE:
item->choice.on = item->choice.init_on;
break;
}
}
} | false | false | false | false | false | 0 |
fl_mode_capable( int mode,
int warn )
{
int cap;
if ( mode < 0 || mode > 5 )
{
M_err( "fl_mode_capable", "Bad mode = %d", mode );
return 0;
}
cap = fli_depth( mode ) >= FL_MINDEPTH && fli_visual( mode );
if ( ! cap && warn )
M_warn( "fl_mode_capable", "Not capable of %s at depth = %d",
fl_vclass_name( mode ), fli_depth( mode ) );
return cap;
} | false | false | false | false | false | 0 |
pkix_CertSelector_Match_ExtendedKeyUsage(
PKIX_ComCertSelParams *params,
PKIX_PL_Cert *cert,
PKIX_Boolean *pResult,
void *plContext)
{
PKIX_List *extKeyUsageList = NULL;
PKIX_List *certExtKeyUsageList = NULL;
PKIX_PL_OID *ekuOid = NULL;
PKIX_Boolean isContained = PKIX_FALSE;
PKIX_UInt32 numItems = 0;
PKIX_UInt32 i;
PKIX_ENTER(CERTSELECTOR, "pkix_CertSelector_Match_ExtendedKeyUsage");
PKIX_NULLCHECK_THREE(params, cert, pResult);
PKIX_CHECK(PKIX_ComCertSelParams_GetExtendedKeyUsage
(params, &extKeyUsageList, plContext),
PKIX_COMCERTSELPARAMSGETEXTENDEDKEYUSAGEFAILED);
if (extKeyUsageList == NULL) {
goto cleanup;
}
PKIX_CHECK(PKIX_PL_Cert_GetExtendedKeyUsage
(cert, &certExtKeyUsageList, plContext),
PKIX_CERTGETEXTENDEDKEYUSAGEFAILED);
if (certExtKeyUsageList != NULL) {
PKIX_CHECK(PKIX_List_GetLength
(extKeyUsageList, &numItems, plContext),
PKIX_LISTGETLENGTHFAILED);
for (i = 0; i < numItems; i++) {
PKIX_CHECK(PKIX_List_GetItem
(extKeyUsageList, i, (PKIX_PL_Object **)&ekuOid, plContext),
PKIX_LISTGETITEMFAILED);
PKIX_CHECK(pkix_List_Contains
(certExtKeyUsageList,
(PKIX_PL_Object *)ekuOid,
&isContained,
plContext),
PKIX_LISTCONTAINSFAILED);
PKIX_DECREF(ekuOid);
if (isContained != PKIX_TRUE) {
*pResult = PKIX_FALSE;
PKIX_ERROR(PKIX_CERTSELECTORMATCHEXTENDEDKEYUSAGEFAILED);
}
}
}
cleanup:
PKIX_DECREF(ekuOid);
PKIX_DECREF(extKeyUsageList);
PKIX_DECREF(certExtKeyUsageList);
PKIX_RETURN(CERTSELECTOR);
} | false | false | false | false | false | 0 |
phm_set_power_state(struct pp_hwmgr *hwmgr,
const struct pp_hw_power_state *pcurrent_state,
const struct pp_hw_power_state *pnew_power_state)
{
struct phm_set_power_state_input states;
PHM_FUNC_CHECK(hwmgr);
states.pcurrent_state = pcurrent_state;
states.pnew_state = pnew_power_state;
if (phm_cap_enabled(hwmgr->platform_descriptor.platformCaps,
PHM_PlatformCaps_TablelessHardwareInterface)) {
if (NULL != hwmgr->hwmgr_func->power_state_set)
return hwmgr->hwmgr_func->power_state_set(hwmgr, &states);
} else {
return phm_dispatch_table(hwmgr, &(hwmgr->set_power_state), &states, NULL);
}
return 0;
} | false | false | false | false | false | 0 |
heap_fetch(Relation relation,
Snapshot snapshot,
HeapTuple tuple,
Buffer *userbuf,
bool keep_buf,
Relation stats_relation)
{
ItemPointer tid = &(tuple->t_self);
ItemId lp;
Buffer buffer;
Page page;
OffsetNumber offnum;
bool valid;
/*
* Fetch and pin the appropriate page of the relation.
*/
buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
/*
* Need share lock on buffer to examine tuple commit status.
*/
LockBuffer(buffer, BUFFER_LOCK_SHARE);
page = BufferGetPage(buffer);
/*
* We'd better check for out-of-range offnum in case of VACUUM since the
* TID was obtained.
*/
offnum = ItemPointerGetOffsetNumber(tid);
if (offnum < FirstOffsetNumber || offnum > PageGetMaxOffsetNumber(page))
{
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
if (keep_buf)
*userbuf = buffer;
else
{
ReleaseBuffer(buffer);
*userbuf = InvalidBuffer;
}
tuple->t_data = NULL;
return false;
}
/*
* get the item line pointer corresponding to the requested tid
*/
lp = PageGetItemId(page, offnum);
/*
* Must check for deleted tuple.
*/
if (!ItemIdIsNormal(lp))
{
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
if (keep_buf)
*userbuf = buffer;
else
{
ReleaseBuffer(buffer);
*userbuf = InvalidBuffer;
}
tuple->t_data = NULL;
return false;
}
/*
* fill in *tuple fields
*/
tuple->t_data = (HeapTupleHeader) PageGetItem(page, lp);
tuple->t_len = ItemIdGetLength(lp);
tuple->t_tableOid = RelationGetRelid(relation);
/*
* check time qualification of tuple, then release lock
*/
valid = HeapTupleSatisfiesVisibility(tuple, snapshot, buffer);
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
if (valid)
{
/*
* All checks passed, so return the tuple as valid. Caller is now
* responsible for releasing the buffer.
*/
*userbuf = buffer;
/* Count the successful fetch against appropriate rel, if any */
if (stats_relation != NULL)
pgstat_count_heap_fetch(stats_relation);
return true;
}
/* Tuple failed time qual, but maybe caller wants to see it anyway. */
if (keep_buf)
*userbuf = buffer;
else
{
ReleaseBuffer(buffer);
*userbuf = InvalidBuffer;
}
return false;
} | false | false | false | false | false | 0 |
_mx_style_invalidate_cache (MxStylable *stylable)
{
GObject *object = G_OBJECT (stylable);
MxStylableCache *cache = g_object_get_qdata (object, MX_STYLE_CACHE);
/* Reset the cache string */
if (cache)
{
g_free (cache->string);
cache->string = NULL;
}
} | false | false | false | false | false | 0 |
psk_client_callback(SSL *ssl, const char *hint,
char *identity, unsigned int max_identity_len,
unsigned char *psk, unsigned int max_psk_len)
{
struct mosquitto *mosq;
int len;
mosq = SSL_get_ex_data(ssl, tls_ex_index_mosq);
if(!mosq) return 0;
snprintf(identity, max_identity_len, "%s", mosq->tls_psk_identity);
len = _mosquitto_hex2bin(mosq->tls_psk, psk, max_psk_len);
if (len < 0) return 0;
return len;
} | false | false | false | false | false | 0 |
up_daemon_check_hibernate_swap (UpDaemon *daemon)
{
gfloat waterline;
if (daemon->priv->kernel_can_hibernate) {
waterline = up_backend_get_used_swap (daemon->priv->backend);
if (waterline < UP_DAEMON_SWAP_WATERLINE) {
g_debug ("enough swap to for hibernate");
return TRUE;
} else {
g_debug ("not enough swap to hibernate");
return FALSE;
}
}
return FALSE;
} | false | false | false | false | false | 0 |
find_mount_table_base(const char *mounts, struct mount_table *mtab, const char *text)
{
const char *p;
int ret;
p = find_mount_table_item(mounts, text);
if (p == NULL)
{
return NULL;
}
ret = parse_mount_table_simple(p, mtab);
if (ret < 0)
{
return NULL;
}
return p;
} | false | false | false | false | false | 0 |
do_copy (CopyData *copy_data)
{
GVfsJobCopy *job = copy_data->job;
GVfsBackendAfp *afp_backend = G_VFS_BACKEND_AFP (job->backend);
GFileInfo *info;
GError *err = NULL;
gboolean source_is_dir;
gboolean dest_exists;
gboolean dest_is_dir;
info = g_vfs_afp_volume_get_filedir_parms_finish (afp_backend->volume, copy_data->source_parms_res, &err);
if (!info)
{
g_vfs_job_failed_from_error (G_VFS_JOB (job), err);
g_error_free (err);
goto done;
}
/* If the source is a directory, don't fail with WOULD_RECURSE immediately,
* as that is less useful to the app. Better check for errors on the
* target instead.
*/
source_is_dir = g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY ? TRUE : FALSE;
g_object_unref (info);
info = g_vfs_afp_volume_get_filedir_parms_finish (afp_backend->volume, copy_data->dest_parms_res, &err);
if (!info)
{
if (g_error_matches (err, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
{
g_clear_error (&err);
dest_exists = FALSE;
}
else
{
g_vfs_job_failed_from_error (G_VFS_JOB (job), err);
g_error_free (err);
goto done;
}
}
else
{
dest_exists = TRUE;
dest_is_dir = g_file_info_get_file_type (info) == G_FILE_TYPE_DIRECTORY ? TRUE : FALSE;
g_object_unref (info);
}
/* Check target errors */
if (dest_exists)
{
if ((job->flags & G_FILE_COPY_OVERWRITE))
{
/* Always fail on dirs, even with overwrite */
if (dest_is_dir)
{
if (source_is_dir)
g_vfs_job_failed_literal (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_WOULD_MERGE,
_("Can't copy directory over directory"));
else
g_vfs_job_failed_literal (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_IS_DIRECTORY,
_("File is directory"));
goto done;
}
}
else
{
g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_EXISTS,
_("Target file already exists"));
goto done;
}
}
/* Now we fail if the source is a directory */
if (source_is_dir)
{
g_vfs_job_failed (G_VFS_JOB (job), G_IO_ERROR, G_IO_ERROR_WOULD_RECURSE,
_("Can't recursively copy directory"));
goto done;
}
if (dest_exists)
{
g_vfs_afp_volume_delete (afp_backend->volume, job->destination,
G_VFS_JOB (job)->cancellable, copy_delete_cb, job);
}
else
{
g_vfs_afp_volume_copy_file (afp_backend->volume, job->source, job->destination,
G_VFS_JOB (job)->cancellable, copy_copy_file_cb, job);
}
done:
copy_data_free (copy_data);
return;
} | false | false | false | false | false | 0 |
gretl_int_from_string (const char *s, int *err)
{
char *test;
double x;
int n = 0;
if (s == NULL || *s == 0) {
*err = E_DATA;
return 0;
}
errno = 0;
n = strtol(s, &test, 10);
if (errno == ERANGE) {
*err = E_DATA;
errno = 0;
return 0;
}
if (*test == '\0') {
return n;
} else if (gretl_is_scalar(s)) {
x = gretl_scalar_get_value(s, NULL);
if (na(x)) {
*err = E_MISSDATA;
} else if (fabs(x) > INT_MAX) {
*err = E_DATA;
} else {
n = (int) x;
}
} else {
*err = E_DATA;
}
return n;
} | false | false | false | false | false | 0 |
parse_line (guint8 * buffer, GstRTSPMessage * msg)
{
GstRTSPHeaderField field;
gchar *line = (gchar *) buffer;
gchar *value;
if ((value = strchr (line, ':')) == NULL || value == line)
goto parse_error;
/* trim space before the colon */
if (value[-1] == ' ')
value[-1] = '\0';
/* replace the colon with a NUL */
*value++ = '\0';
/* find the header */
field = gst_rtsp_find_header_field (line);
if (field == GST_RTSP_HDR_INVALID)
goto done;
/* split up the value in multiple key:value pairs if it contains comma(s) */
while (*value != '\0') {
gchar *next_value;
gchar *comma = NULL;
gboolean quoted = FALSE;
guint comment = 0;
/* trim leading space */
if (*value == ' ')
value++;
/* for headers which may not appear multiple times, and thus may not
* contain multiple values on the same line, we can short-circuit the loop
* below and the entire value results in just one key:value pair*/
if (!gst_rtsp_header_allow_multiple (field))
next_value = value + strlen (value);
else
next_value = value;
/* find the next value, taking special care of quotes and comments */
while (*next_value != '\0') {
if ((quoted || comment != 0) && *next_value == '\\' &&
next_value[1] != '\0')
next_value++;
else if (comment == 0 && *next_value == '"')
quoted = !quoted;
else if (!quoted && *next_value == '(')
comment++;
else if (comment != 0 && *next_value == ')')
comment--;
else if (!quoted && comment == 0) {
/* To quote RFC 2068: "User agents MUST take special care in parsing
* the WWW-Authenticate field value if it contains more than one
* challenge, or if more than one WWW-Authenticate header field is
* provided, since the contents of a challenge may itself contain a
* comma-separated list of authentication parameters."
*
* What this means is that we cannot just look for an unquoted comma
* when looking for multiple values in Proxy-Authenticate and
* WWW-Authenticate headers. Instead we need to look for the sequence
* "comma [space] token space token" before we can split after the
* comma...
*/
if (field == GST_RTSP_HDR_PROXY_AUTHENTICATE ||
field == GST_RTSP_HDR_WWW_AUTHENTICATE) {
if (*next_value == ',') {
if (next_value[1] == ' ') {
/* skip any space following the comma so we do not mistake it for
* separating between two tokens */
next_value++;
}
comma = next_value;
} else if (*next_value == ' ' && next_value[1] != ',' &&
next_value[1] != '=' && comma != NULL) {
next_value = comma;
comma = NULL;
break;
}
} else if (*next_value == ',')
break;
}
next_value++;
}
/* trim space */
if (value != next_value && next_value[-1] == ' ')
next_value[-1] = '\0';
if (*next_value != '\0')
*next_value++ = '\0';
/* add the key:value pair */
if (*value != '\0')
gst_rtsp_message_add_header (msg, field, value);
value = next_value;
}
done:
return GST_RTSP_OK;
/* ERRORS */
parse_error:
{
return GST_RTSP_EPARSE;
}
} | false | false | false | false | false | 0 |
queue_mwi_event(const char *mbx, const char *ctx, int urgent, int new, int old)
{
struct ast_event *event;
char *mailbox, *context;
mailbox = ast_strdupa(mbx);
context = ast_strdupa(ctx);
if (ast_strlen_zero(context)) {
context = "default";
}
if (!(event = ast_event_new(AST_EVENT_MWI,
AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
AST_EVENT_IE_CONTEXT, AST_EVENT_IE_PLTYPE_STR, context,
AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, (new+urgent),
AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
AST_EVENT_IE_END))) {
return;
}
ast_event_queue_and_cache(event);
} | false | false | false | false | false | 0 |
is_solid(int x,int y)
{
return (!isok(x,y) || IS_STWALL(levl[x][y].typ));
} | false | false | false | false | false | 0 |
brcmf_cfg80211_mgmt_frame_register(struct wiphy *wiphy,
struct wireless_dev *wdev,
u16 frame_type, bool reg)
{
struct brcmf_cfg80211_vif *vif;
u16 mgmt_type;
brcmf_dbg(TRACE, "Enter, frame_type %04x, reg=%d\n", frame_type, reg);
mgmt_type = (frame_type & IEEE80211_FCTL_STYPE) >> 4;
vif = container_of(wdev, struct brcmf_cfg80211_vif, wdev);
if (reg)
vif->mgmt_rx_reg |= BIT(mgmt_type);
else
vif->mgmt_rx_reg &= ~BIT(mgmt_type);
} | false | false | false | false | false | 0 |
calculateSwappingTime(Job *job) {
unsigned int swaptime = job->getMemoryConsumption() *
properties.swapping_time;
if (swaptime % 1024 > 0)
swaptime++;
return swaptime / 1024;
} | false | false | false | false | false | 0 |
fm_tx_set_region(struct fmdev *fmdev, u8 region)
{
u16 payload;
int ret;
if (region != FM_BAND_EUROPE_US && region != FM_BAND_JAPAN) {
fmerr("Invalid band\n");
return -EINVAL;
}
/* Send command to set the band */
payload = (u16)region;
ret = fmc_send_cmd(fmdev, TX_BAND_SET, REG_WR, &payload,
sizeof(payload), NULL, NULL);
if (ret < 0)
return ret;
return 0;
} | false | false | false | false | false | 0 |
gic_iter(kadm5_server_handle_t handle, enum init_type init_type,
krb5_ccache ccache, krb5_principal client, char *pass, char *svcname,
char *realm, char *full_svcname, unsigned int full_svcname_len)
{
kadm5_ret_t code;
krb5_context ctx;
krb5_keytab kt;
krb5_get_init_creds_opt *opt = NULL;
krb5_creds mcreds, outcreds;
int n;
ctx = handle->context;
kt = NULL;
memset(full_svcname, 0, full_svcname_len);
memset(&opt, 0, sizeof(opt));
memset(&mcreds, 0, sizeof(mcreds));
memset(&outcreds, 0, sizeof(outcreds));
code = ENOMEM;
if (realm) {
n = snprintf(full_svcname, full_svcname_len, "%s@%s",
svcname, realm);
if (n < 0 || n >= (int) full_svcname_len)
goto error;
} else {
/* krb5_princ_realm(client) is not null terminated */
n = snprintf(full_svcname, full_svcname_len, "%s@%.*s",
svcname, krb5_princ_realm(ctx, client)->length,
krb5_princ_realm(ctx, client)->data);
if (n < 0 || n >= (int) full_svcname_len)
goto error;
}
/* Credentials for kadmin don't need to be forwardable or proxiable. */
if (init_type != INIT_CREDS) {
code = krb5_get_init_creds_opt_alloc(ctx, &opt);
krb5_get_init_creds_opt_set_forwardable(opt, 0);
krb5_get_init_creds_opt_set_proxiable(opt, 0);
krb5_get_init_creds_opt_set_out_ccache(ctx, opt, ccache);
if (init_type == INIT_ANONYMOUS)
krb5_get_init_creds_opt_set_anonymous(opt, 1);
}
if (init_type == INIT_PASS || init_type == INIT_ANONYMOUS) {
code = krb5_get_init_creds_password(ctx, &outcreds, client, pass,
krb5_prompter_posix,
NULL, 0,
full_svcname, opt);
if (code)
goto error;
} else if (init_type == INIT_SKEY) {
if (pass) {
code = krb5_kt_resolve(ctx, pass, &kt);
if (code)
goto error;
}
code = krb5_get_init_creds_keytab(ctx, &outcreds, client, kt,
0, full_svcname, opt);
if (pass)
krb5_kt_close(ctx, kt);
if (code)
goto error;
} else if (init_type == INIT_CREDS) {
mcreds.client = client;
code = krb5_parse_name(ctx, full_svcname, &mcreds.server);
if (code)
goto error;
code = krb5_cc_retrieve_cred(ctx, ccache, 0,
&mcreds, &outcreds);
krb5_free_principal(ctx, mcreds.server);
if (code)
goto error;
}
error:
krb5_free_cred_contents(ctx, &outcreds);
if (opt)
krb5_get_init_creds_opt_free(ctx, opt);
return code;
} | false | false | false | false | false | 0 |
e_cal_util_parse_ics_string (const gchar *string)
{
GString *comp_str = NULL;
gchar *s;
icalcomponent *icalcomp = NULL;
g_return_val_if_fail (string != NULL, NULL);
/* Split string into separated VCALENDAR's, if more than one */
s = g_strstr_len (string, strlen (string), "BEGIN:VCALENDAR");
if (s == NULL)
return icalparser_parse_string (string);
while (*s != '\0') {
gchar *line = read_line (s);
if (!comp_str)
comp_str = g_string_new (line);
else
comp_str = g_string_append (comp_str, line);
if (strncmp (line, "END:VCALENDAR", 13) == 0) {
icalcomponent *tmp;
tmp = icalparser_parse_string (comp_str->str);
if (tmp && icalcomponent_isa (tmp) == ICAL_VCALENDAR_COMPONENT) {
if (icalcomp)
icalcomponent_merge_component (icalcomp, tmp);
else
icalcomp = tmp;
} else {
g_warning (
"Could not merge the components, "
"the component is either invalid "
"or not a toplevel component \n");
}
g_string_free (comp_str, TRUE);
comp_str = NULL;
}
s += strlen (line);
g_free (line);
}
return icalcomp;
} | false | false | false | false | false | 0 |
toggle_Magic(x)
int x;
{
if (is_Magic(x))
return un_Magic(x);
return Magic(x);
} | false | false | false | false | false | 0 |
deviceSetCurrent()
{
//scan the network using each plugin available (by broadcast for osc, by scan for CopperLan?) to find the devices
std::map<std::string, Plugin*>::iterator itr = netPlugins->begin();
while( itr != netPlugins->end()){
if (itr->second != NULL) {
itr->second->deviceSetCurrent(netDevices);
}
itr++;
}
} | false | false | false | false | false | 0 |
aes_crypt_cbc( aes_context *ctx,
int mode,
int length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output )
{
int i;
unsigned char temp[16];
#if defined(XYSSL_PADLOCK_C) && defined(XYSSL_HAVE_X86)
if( padlock_supports( PADLOCK_ACE ) )
{
if( padlock_xcryptcbc( ctx, mode, length, iv, input, output ) == 0 )
return;
}
#endif
if( mode == AES_DECRYPT )
{
while( length > 0 )
{
memcpy( temp, input, 16 );
aes_crypt_ecb( ctx, mode, input, output );
for( i = 0; i < 16; i++ )
output[i] = (unsigned char)( output[i] ^ iv[i] );
memcpy( iv, temp, 16 );
input += 16;
output += 16;
length -= 16;
}
}
else
{
while( length > 0 )
{
for( i = 0; i < 16; i++ )
output[i] = (unsigned char)( input[i] ^ iv[i] );
aes_crypt_ecb( ctx, mode, output, output );
memcpy( iv, output, 16 );
input += 16;
output += 16;
length -= 16;
}
}
} | true | true | false | false | false | 1 |
data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
QModelIndex source = mapToSource(index);
if (role == Qt::DisplayRole) {
switch (index.column()) {
case PatientName: return d->patientName(source);
case PatientDateOfBirth: return d->patientDob(source);
case FileName:
{
source = d->_fileModel->index(source.row(), 0, source.parent());
return d->_fileModel->fileInfo(source).fileName();
}
case FileDate: return QLocale().toString(d->_fileModel->lastModified(source), QLocale::ShortFormat);
}
}
return QVariant();
// return sourceModel()->data(source, role);
} | false | false | false | false | false | 0 |
GFCDirsSeparateToggle(GWindow gw,struct gmenuitem *mi,GEvent *e) {
GFileChooser *gfc = (GFileChooser *) (mi->ti.userdata);
unichar_t *dir;
if ( dir_placement!=dirs_separate ) {
GGadgetSetVisible(&gfc->subdirs->g,true);
GFCRemetric(gfc);
}
dir_placement = dirs_separate;
dir = GFileChooserGetCurDir(gfc,-1);
GFileChooserScanDir(gfc,dir);
free(dir);
if ( prefs_changed!=NULL )
(prefs_changed)(prefs_changed_data);
} | false | false | false | false | false | 0 |
libssh2_sftp_write(LIBSSH2_SFTP_HANDLE *hnd, const char *buffer,
size_t count)
{
ssize_t rc;
if(!hnd)
return LIBSSH2_ERROR_BAD_USE;
BLOCK_ADJUST(rc, hnd->sftp->channel->session,
sftp_write(hnd, buffer, count));
return rc;
} | false | false | false | false | false | 0 |
cliInitHelp() {
int commandslen = sizeof(commandHelp)/sizeof(struct commandHelp);
int groupslen = sizeof(commandGroups)/sizeof(char*);
int i, len, pos = 0;
helpEntry tmp;
helpEntriesLen = len = commandslen+groupslen;
helpEntries = malloc(sizeof(helpEntry)*len);
for (i = 0; i < groupslen; i++) {
tmp.argc = 1;
tmp.argv = malloc(sizeof(sds));
tmp.argv[0] = sdscatprintf(sdsempty(),"@%s",commandGroups[i]);
tmp.full = tmp.argv[0];
tmp.type = CLI_HELP_GROUP;
tmp.org = NULL;
helpEntries[pos++] = tmp;
}
for (i = 0; i < commandslen; i++) {
tmp.argv = sdssplitargs(commandHelp[i].name,&tmp.argc);
tmp.full = sdsnew(commandHelp[i].name);
tmp.type = CLI_HELP_COMMAND;
tmp.org = &commandHelp[i];
helpEntries[pos++] = tmp;
}
} | false | false | false | false | false | 0 |
add_value(struct hive *hdesc, int nkofs, char *name, int type)
{
struct nk_key *nk;
int oldvlist = 0, newvlist, newvkofs;
struct vk_key *newvkkey;
char *blank="";
if (!name || !*name) return(NULL);
nk = (struct nk_key *)(hdesc->buffer + nkofs);
if (nk->id != 0x6b6e) {
printf("add_value: Key pointer not to 'nk' node!\n");
return(NULL);
}
if (vlist_find(hdesc, nk->ofs_vallist + 0x1004, nk->no_values, name, TPF_EXACT) != -1) {
printf("add_value: value %s already exists\n",name);
return(NULL);
}
if (!strcmp(name,"@")) name = blank;
if (nk->no_values) oldvlist = nk->ofs_vallist;
newvlist = alloc_block(hdesc, nkofs, nk->no_values * 4 + 4);
if (!newvlist) {
printf("add_value: failed to allocate new value list!\n");
return(NULL);
}
nk = (struct nk_key *)(hdesc->buffer + nkofs); /* In case buffer was moved.. */
if (oldvlist) { /* Copy old data if any */
memcpy(hdesc->buffer + newvlist + 4, hdesc->buffer + oldvlist + 0x1004, nk->no_values * 4 + 4);
}
/* Allocate value descriptor including its name */
newvkofs = alloc_block(hdesc, newvlist, sizeof(struct vk_key) + strlen(name));
if (!newvkofs) {
printf("add_value: failed to allocate value descriptor\n");
free_block(hdesc, newvlist);
return(NULL);
}
nk = (struct nk_key *)(hdesc->buffer + nkofs); /* In case buffer was moved.. */
/* Success, now fill in the metadata */
newvkkey = (struct vk_key *)(hdesc->buffer + newvkofs + 4);
/* Add pointer in value list */
*(int *)(hdesc->buffer + newvlist + 4 + (nk->no_values * 4)) = newvkofs - 0x1000;
/* Fill in vk struct */
newvkkey->id = 0x6b76;
newvkkey->len_name = strlen(name);
if (type == REG_DWORD || type == REG_DWORD_BIG_ENDIAN) {
newvkkey->len_data = 0x80000004; /* Prime the DWORD inline stuff */
} else {
newvkkey->len_data = 0x80000000; /* Default inline zero size */
}
newvkkey->ofs_data = 0;
newvkkey->val_type = type;
newvkkey->flag = newvkkey->len_name ? 1 : 0; /* Seems to be 1, but 0 for no name default value */
newvkkey->dummy1 = 0;
memcpy((char *)&newvkkey->keyname, name, newvkkey->len_name); /* And copy name */
/* Finally update the key and free the old valuelist */
nk->no_values++;
nk->ofs_vallist = newvlist - 0x1000;
if (oldvlist) free_block(hdesc,oldvlist + 0x1000);
return(newvkkey);
} | false | false | false | false | false | 0 |
_update_node_filesystem(void)
{
acct_filesystem_data_t *fls;
int rc = SLURM_SUCCESS;
slurm_mutex_lock(&lustre_lock);
rc = _read_lustre_counters();
fls = xmalloc(sizeof(acct_filesystem_data_t));
fls->reads = lustre_se.all_lustre_nb_reads;
fls->writes = lustre_se.all_lustre_nb_writes;
fls->read_size = (double) lustre_se.all_lustre_read_bytes / 1048576;
fls->write_size = (double) lustre_se.all_lustre_write_bytes / 1048576;
acct_gather_profile_g_add_sample_data(ACCT_GATHER_PROFILE_LUSTRE, fls);
debug3("Collection of Lustre counters Finished");
xfree(fls);
if (debug_flags & DEBUG_FLAG_FILESYSTEM) {
info("lustre-thread = %d sec, transmitted %"PRIu64" bytes, "
"received %"PRIu64" bytes",
(int) (lustre_se.update_time - lustre_se.last_update_time),
lustre_se.all_lustre_read_bytes,
lustre_se.all_lustre_write_bytes);
}
slurm_mutex_unlock(&lustre_lock);
return rc;
} | false | false | false | false | false | 0 |
object_read_xml (AmitkObject * object, xmlNodePtr nodes,
FILE *study_file, gchar *error_buf) {
AmitkSpace * space;
xmlNodePtr children_nodes;
GList * children;
AmitkSelection i_selection;
space = amitk_space_read_xml(nodes, "coordinate_space", &error_buf);
amitk_space_copy_in_place(AMITK_SPACE(object), space);
g_object_unref(space);
children_nodes = xml_get_node(nodes, "children");
children = amitk_objects_read_xml(children_nodes->children, study_file, &error_buf);
amitk_object_add_children(object, children);
children = amitk_objects_unref(children);
for (i_selection = 0; i_selection < AMITK_SELECTION_NUM; i_selection++)
object->selected[i_selection] = xml_get_boolean(nodes,
amitk_selection_get_name(i_selection),
&error_buf);
return error_buf;
} | false | false | false | false | false | 0 |
init_config_attrs(ConfigTable *ct) {
int i, code;
for (i=0; ct[i].name; i++ ) {
if ( !ct[i].attribute ) continue;
code = register_at( ct[i].attribute, &ct[i].ad, 1 );
if ( code ) {
fprintf( stderr, "init_config_attrs: register_at failed\n" );
return code;
}
}
return 0;
} | false | false | false | false | false | 0 |
create_window (GsdLocatePointerData *data,
GdkScreen *screen)
{
GdkVisual *visual;
GdkWindowAttr attributes;
gint attributes_mask;
visual = gdk_screen_get_rgba_visual (screen);
if (visual == NULL)
visual = gdk_screen_get_system_visual (screen);
attributes_mask = GDK_WA_X | GDK_WA_Y;
if (visual != NULL)
attributes_mask = attributes_mask | GDK_WA_VISUAL;
attributes.window_type = GDK_WINDOW_TEMP;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = visual;
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK | GDK_EXPOSURE_MASK;
attributes.width = 1;
attributes.height = 1;
data->window = gdk_window_new (gdk_screen_get_root_window (screen),
&attributes,
attributes_mask);
gdk_window_set_user_data (data->window, data->widget);
} | false | false | false | false | false | 0 |
storeurlStats(StoreEntry * sentry)
{
storeAppendPrintf(sentry, "Redirector Statistics:\n");
helperStats(sentry, storeurlors);
if (Config.onoff.storeurl_bypass)
storeAppendPrintf(sentry, "\nNumber of requests bypassed "
"because all store url bypassers were busy: %d\n", n_bypassed);
} | false | false | false | false | false | 0 |
BigDecimal_div2(int argc, VALUE *argv, VALUE self)
{
ENTER(5);
VALUE b,n;
int na = rb_scan_args(argc,argv,"11",&b,&n);
if(na==1) { /* div in Float sense */
Real *div=NULL;
Real *mod;
if(BigDecimal_DoDivmod(self,b,&div,&mod)) {
return BigDecimal_to_i(ToValue(div));
}
return DoSomeOne(self,b,rb_intern("div"));
} else { /* div in BigDecimal sense */
SIGNED_VALUE ix = GetPositiveInt(n);
if (ix == 0) return BigDecimal_div(self, b);
else {
Real *res=NULL;
Real *av=NULL, *bv=NULL, *cv=NULL;
size_t mx = (ix+VpBaseFig()*2);
size_t pl = VpSetPrecLimit(0);
GUARD_OBJ(cv,VpCreateRbObject(mx,"0"));
GUARD_OBJ(av,GetVpValue(self,1));
GUARD_OBJ(bv,GetVpValue(b,1));
mx = av->Prec + bv->Prec + 2;
if(mx <= cv->MaxPrec) mx = cv->MaxPrec+1;
GUARD_OBJ(res,VpCreateRbObject((mx * 2 + 2)*VpBaseFig(), "#0"));
VpDivd(cv,res,av,bv);
VpSetPrecLimit(pl);
VpLeftRound(cv,VpGetRoundMode(),ix);
return ToValue(cv);
}
}
} | false | false | false | false | false | 0 |
do_graft(ir_rvalue **rvalue)
{
if (!*rvalue)
return false;
ir_dereference_variable *deref = (*rvalue)->as_dereference_variable();
if (!deref || deref->var != this->graft_var)
return false;
if (debug) {
printf("GRAFTING:\n");
this->graft_assign->print();
printf("\n");
printf("TO:\n");
(*rvalue)->print();
printf("\n");
}
this->graft_assign->remove();
*rvalue = this->graft_assign->rhs;
this->progress = true;
return true;
} | false | false | false | false | false | 0 |
pasteClipboardUrls(const QMimeData* mimeData, const KUrl& destDir, KIO::JobFlags flags = KIO::DefaultFlags)
{
const KUrl::List urls = KUrl::List::fromMimeData(mimeData, KUrl::List::PreferLocalUrls);
if (!urls.isEmpty()) {
const bool move = decodeIsCutSelection(mimeData);
KIO::Job *job = 0;
if (move) {
job = KIO::move(urls, destDir, flags);
} else {
job = KIO::copy(urls, destDir, flags);
}
return job;
}
return 0;
} | false | false | false | false | false | 0 |
SwLedOff(struct _adapter *padapter, struct LED_871x *pLed)
{
u8 LedCfg;
if (padapter->bSurpriseRemoved || padapter->bDriverStopped)
return;
LedCfg = r8712_read8(padapter, LEDCFG);
switch (pLed->LedPin) {
case LED_PIN_GPIO0:
break;
case LED_PIN_LED0:
LedCfg &= 0xf0; /* Set to software control.*/
r8712_write8(padapter, LEDCFG, (LedCfg | BIT(3)));
break;
case LED_PIN_LED1:
LedCfg &= 0x0f; /* Set to software control.*/
r8712_write8(padapter, LEDCFG, (LedCfg | BIT(7)));
break;
default:
break;
}
pLed->bLedOn = false;
} | false | false | false | false | false | 0 |
fl_table(value_t *args, uint32_t nargs)
{
size_t cnt = (size_t)nargs;
if (cnt & 1)
lerror(ArgError, "table: arguments must come in pairs");
value_t nt;
// prevent small tables from being added to finalizer list
if (cnt <= HT_N_INLINE) {
tabletype->vtable->finalize = NULL;
nt = cvalue(tabletype, sizeof(htable_t));
tabletype->vtable->finalize = free_htable;
}
else {
nt = cvalue(tabletype, 2*sizeof(void*));
}
htable_t *h = (htable_t*)cv_data((cvalue_t*)ptr(nt));
htable_new(h, cnt/2);
uint32_t i;
value_t k=FL_NIL, arg=FL_NIL;
FOR_ARGS(i,0,arg,args) {
if (i&1)
equalhash_put(h, (void*)k, (void*)arg);
else
k = arg;
}
return nt;
} | false | false | false | false | false | 0 |
setVideoSurface(QAbstractVideoSurface *surface)
{
m_surface = surface;
if (m_control)
m_control.data()->setSurface(surface);
} | false | false | false | false | false | 0 |
_vg_commit_file_backup(struct format_instance *fid __attribute__((unused)),
struct volume_group *vg,
struct metadata_area *mda)
{
struct text_context *tc = (struct text_context *) mda->metadata_locn;
if (test_mode()) {
log_verbose("Test mode: Skipping committing %s metadata (%u)",
vg->name, vg->seqno);
if (unlink(tc->path_edit)) {
log_debug("Unlinking %s", tc->path_edit);
log_sys_error("unlink", tc->path_edit);
return 0;
}
} else {
log_debug("Committing %s metadata (%u)", vg->name, vg->seqno);
log_debug("Renaming %s to %s", tc->path_edit, tc->path_live);
if (rename(tc->path_edit, tc->path_live)) {
log_error("%s: rename to %s failed: %s", tc->path_edit,
tc->path_live, strerror(errno));
return 0;
}
}
sync_dir(tc->path_edit);
return 1;
} | false | false | false | false | false | 0 |
camel_mime_parser_from_line (CamelMimeParser *m)
{
struct _header_scan_state *s = _PRIVATE (m);
if (s->parts)
return byte_array_to_string (s->parts->from_line);
return NULL;
} | false | false | false | false | false | 0 |
synaptics_report_ext_buttons(struct psmouse *psmouse,
const struct synaptics_hw_state *hw)
{
struct input_dev *dev = psmouse->dev;
struct synaptics_data *priv = psmouse->private;
int ext_bits = (SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap) + 1) >> 1;
char buf[6] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
int i;
if (!SYN_CAP_MULTI_BUTTON_NO(priv->ext_cap))
return;
/* Bug in FW 8.1 & 8.2, buttons are reported only when ExtBit is 1 */
if ((SYN_ID_FULL(priv->identity) == 0x801 ||
SYN_ID_FULL(priv->identity) == 0x802) &&
!((psmouse->packet[0] ^ psmouse->packet[3]) & 0x02))
return;
if (!SYN_CAP_EXT_BUTTONS_STICK(priv->ext_cap_10)) {
for (i = 0; i < ext_bits; i++) {
input_report_key(dev, BTN_0 + 2 * i,
hw->ext_buttons & (1 << i));
input_report_key(dev, BTN_1 + 2 * i,
hw->ext_buttons & (1 << (i + ext_bits)));
}
return;
}
/*
* This generation of touchpads has the trackstick buttons
* physically wired to the touchpad. Re-route them through
* the pass-through interface.
*/
if (!priv->pt_port)
return;
/* The trackstick expects at most 3 buttons */
priv->pt_buttons = SYN_CAP_EXT_BUTTON_STICK_L(hw->ext_buttons) |
SYN_CAP_EXT_BUTTON_STICK_R(hw->ext_buttons) << 1 |
SYN_CAP_EXT_BUTTON_STICK_M(hw->ext_buttons) << 2;
synaptics_pass_pt_packet(psmouse, priv->pt_port, buf);
} | true | true | false | false | false | 1 |
process(const LookupProcessor *lookupProcessor, le_uint16 lookupType,
GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
{
if (LE_FAILURE(success)) {
return 0;
}
le_uint16 elt = SWAPW(extensionLookupType);
if (elt != lookupType) {
le_uint32 extOffset = READ_LONG(extensionOffset);
LookupSubtable *subtable = (LookupSubtable *) ((char *) this + extOffset);
return lookupProcessor->applySubtable(subtable, elt, glyphIterator, fontInstance, success);
}
return 0;
} | false | false | false | false | false | 0 |
toStringList( const QString &serialized, bool base64Protection )
{
if (!base64Protection)
return serialized.split( Serializer::separator() );
QStringList toReturn;
foreach( const QString &s, serialized.split(Serializer::separator()) ) {
toReturn << QByteArray::fromBase64(s.toUtf8());
}
return toReturn;
} | false | false | false | false | false | 0 |
xmms_vis_read (xmms_xform_t *xform, xmms_sample_t *buf, gint len,
xmms_error_t *error)
{
gint read, chan;
g_return_val_if_fail (xform, -1);
chan = xmms_xform_indata_get_int (xform, XMMS_STREAM_TYPE_FMT_CHANNELS);
/* perhaps rework this later */
if (len > XMMSC_VISUALIZATION_WINDOW_SIZE * chan * sizeof (short)) {
len = XMMSC_VISUALIZATION_WINDOW_SIZE * chan * sizeof (short);
}
read = xmms_xform_read (xform, buf, len, error);
if (read > 0) {
send_data (chan, read / sizeof (short), buf);
}
return read;
} | false | false | false | false | false | 0 |
alarmtimer_nsleep_wakeup(struct alarm *alarm,
ktime_t now)
{
struct task_struct *task = (struct task_struct *)alarm->data;
alarm->data = NULL;
if (task)
wake_up_process(task);
return ALARMTIMER_NORESTART;
} | false | false | false | false | false | 0 |
globus_callback_adjust_oneshot(
globus_callback_handle_t callback_handle,
const globus_reltime_t * new_delay)
{
if (globus_i_am_only_thread())
{
return globus_callback_adjust_oneshot_nothreads(
callback_handle,
new_delay);
}
else
{
return globus_callback_adjust_oneshot_threads(
callback_handle,
new_delay);
}
} | false | false | false | false | false | 0 |
ExecGrant_Namespace(InternalGrant *istmt)
{
Relation relation;
ListCell *cell;
if (istmt->all_privs && istmt->privileges == ACL_NO_RIGHTS)
istmt->privileges = ACL_ALL_RIGHTS_NAMESPACE;
relation = heap_open(NamespaceRelationId, RowExclusiveLock);
foreach(cell, istmt->objects)
{
Oid nspid = lfirst_oid(cell);
Form_pg_namespace pg_namespace_tuple;
Datum aclDatum;
bool isNull;
AclMode avail_goptions;
AclMode this_privileges;
Acl *old_acl;
Acl *new_acl;
Oid grantorId;
Oid ownerId;
HeapTuple tuple;
HeapTuple newtuple;
Datum values[Natts_pg_namespace];
bool nulls[Natts_pg_namespace];
bool replaces[Natts_pg_namespace];
int noldmembers;
int nnewmembers;
Oid *oldmembers;
Oid *newmembers;
tuple = SearchSysCache(NAMESPACEOID,
ObjectIdGetDatum(nspid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for namespace %u", nspid);
pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
/*
* Get owner ID and working copy of existing ACL. If there's no ACL,
* substitute the proper default.
*/
ownerId = pg_namespace_tuple->nspowner;
aclDatum = SysCacheGetAttr(NAMESPACENAME, tuple,
Anum_pg_namespace_nspacl,
&isNull);
if (isNull)
old_acl = acldefault(ACL_OBJECT_NAMESPACE, ownerId);
else
old_acl = DatumGetAclPCopy(aclDatum);
/* Determine ID to do the grant as, and available grant options */
select_best_grantor(GetUserId(), istmt->privileges,
old_acl, ownerId,
&grantorId, &avail_goptions);
/*
* Restrict the privileges to what we can actually grant, and emit the
* standards-mandated warning and error messages.
*/
this_privileges =
restrict_and_check_grant(istmt->is_grant, avail_goptions,
istmt->all_privs, istmt->privileges,
nspid, grantorId, ACL_KIND_NAMESPACE,
NameStr(pg_namespace_tuple->nspname),
0, NULL);
/*
* Generate new ACL.
*
* We need the members of both old and new ACLs so we can correct the
* shared dependency information.
*/
noldmembers = aclmembers(old_acl, &oldmembers);
new_acl = merge_acl_with_grant(old_acl, istmt->is_grant,
istmt->grant_option, istmt->behavior,
istmt->grantees, this_privileges,
grantorId, ownerId);
nnewmembers = aclmembers(new_acl, &newmembers);
/* finished building new ACL value, now insert it */
MemSet(values, 0, sizeof(values));
MemSet(nulls, false, sizeof(nulls));
MemSet(replaces, false, sizeof(replaces));
replaces[Anum_pg_namespace_nspacl - 1] = true;
values[Anum_pg_namespace_nspacl - 1] = PointerGetDatum(new_acl);
newtuple = heap_modify_tuple(tuple, RelationGetDescr(relation), values,
nulls, replaces);
simple_heap_update(relation, &newtuple->t_self, newtuple);
/* keep the catalog indexes up to date */
CatalogUpdateIndexes(relation, newtuple);
/* Update the shared dependency ACL info */
updateAclDependencies(NamespaceRelationId, HeapTupleGetOid(tuple), 0,
ownerId, istmt->is_grant,
noldmembers, oldmembers,
nnewmembers, newmembers);
ReleaseSysCache(tuple);
pfree(new_acl);
/* prevent error when processing duplicate objects */
CommandCounterIncrement();
}
heap_close(relation, RowExclusiveLock);
} | false | false | false | false | false | 0 |
update_recv_order(rdpUpdate* update, STREAM* s)
{
uint8 controlFlags;
stream_read_uint8(s, controlFlags); /* controlFlags (1 byte) */
switch (controlFlags & ORDER_CLASS_MASK)
{
case ORDER_PRIMARY_CLASS:
update_recv_primary_order(update, s, controlFlags);
break;
case ORDER_SECONDARY_CLASS:
update_recv_secondary_order(update, s, controlFlags);
break;
case ORDER_ALTSEC_CLASS:
update_recv_altsec_order(update, s, controlFlags);
break;
}
} | false | false | false | false | false | 0 |
setNonInheritedC(const Identifier *ident, ELObj *obj,
const Location &loc, Interpreter &interp)
{
radical_ = obj->asSosofo();
if (!radical_ || !radical_->isCharacter()) {
interp.setNextLocation(loc);
interp.message(InterpreterMessages::invalidCharacteristicValue,
StringMessageArg(ident->name()));
}
} | false | false | false | false | false | 0 |
blk_mq_hw_queue_to_node(unsigned int *mq_map, unsigned int index)
{
int i;
for_each_possible_cpu(i) {
if (index == mq_map[i])
return cpu_to_node(i);
}
return NUMA_NO_NODE;
} | false | false | false | false | false | 0 |
file_chmodstr_to_mode(const char *modespec, mode_t *newmode) {
mode_t m = 0;
int i = 0, fct = 1;
if(strlen(modespec) != 3)
return 0;
else {
for(i = 2; i >= 0; i--) {
char c = modespec[i];
if(!((c >= '0') && (c <= '7')))
return 0;
else {
m += fct * (c - '0');
}
fct *= 8;
}
}
*newmode = m;
return 1;
} | false | false | false | false | false | 0 |
sdma_send_txlist(struct sdma_engine *sde,
struct iowait *wait,
struct list_head *tx_list)
{
struct sdma_txreq *tx, *tx_next;
int ret = 0;
unsigned long flags;
u16 tail = INVALID_TAIL;
int count = 0;
spin_lock_irqsave(&sde->tail_lock, flags);
retry:
list_for_each_entry_safe(tx, tx_next, tx_list, list) {
tx->wait = wait;
if (unlikely(!__sdma_running(sde)))
goto unlock_noconn;
if (unlikely(tx->num_desc > sde->desc_avail))
goto nodesc;
if (unlikely(tx->tlen)) {
ret = -EINVAL;
goto update_tail;
}
list_del_init(&tx->list);
tail = submit_tx(sde, tx);
count++;
if (tail != INVALID_TAIL &&
(count & SDMA_TAIL_UPDATE_THRESH) == 0) {
sdma_update_tail(sde, tail);
tail = INVALID_TAIL;
}
}
update_tail:
if (wait)
atomic_add(count, &wait->sdma_busy);
if (tail != INVALID_TAIL)
sdma_update_tail(sde, tail);
spin_unlock_irqrestore(&sde->tail_lock, flags);
return ret;
unlock_noconn:
spin_lock(&sde->flushlist_lock);
list_for_each_entry_safe(tx, tx_next, tx_list, list) {
tx->wait = wait;
list_del_init(&tx->list);
if (wait)
atomic_inc(&wait->sdma_busy);
tx->next_descq_idx = 0;
#ifdef CONFIG_HFI1_DEBUG_SDMA_ORDER
tx->sn = sde->tail_sn++;
trace_hfi1_sdma_in_sn(sde, tx->sn);
#endif
list_add_tail(&tx->list, &sde->flushlist);
if (wait) {
wait->tx_count++;
wait->count += tx->num_desc;
}
}
spin_unlock(&sde->flushlist_lock);
schedule_work(&sde->flush_worker);
ret = -ECOMM;
goto update_tail;
nodesc:
ret = sdma_check_progress(sde, wait, tx);
if (ret == -EAGAIN) {
ret = 0;
goto retry;
}
sde->descq_full_count++;
goto update_tail;
} | false | false | false | false | false | 0 |
pack_window_free_all(struct pack_backend *backend, struct pack_file *p)
{
while (p->windows) {
struct pack_window *w = p->windows;
assert(w->inuse_cnt == 0);
backend->mapped -= w->window_map.len;
backend->open_windows--;
gitfo_free_map(&w->window_map);
p->windows = w->next;
free(w);
}
} | false | false | false | false | false | 0 |
serve_thread_func(void *param) {
struct mg_server *server = (struct mg_server *) param;
printf("Listening on port %s\n", mg_get_option(server, "listening_port"));
while (s_received_signal == 0) {
mg_poll_server(server, 1000);
}
mg_destroy_server(&server);
return NULL;
} | false | false | false | false | false | 0 |
execute() {
static int before_symval = symbol_add("before");
ComValue beforev(stack_key(before_symval));
reset_stack();
if (editor()) {
CreateMoveFrameCmd* cmd =
new CreateMoveFrameCmd(editor(), beforev.is_false());
execute_log(cmd);
ComValue retval(cmd->moveframecmd()->actualmotion(), ComValue::IntType);
push_stack(retval);
}
} | false | false | false | false | false | 0 |
StripParams(AVal *src)
{
AVal str;
if (src->av_val)
{
str.av_val = calloc(src->av_len + 1, sizeof (char));
strncpy(str.av_val, src->av_val, src->av_len);
str.av_len = src->av_len;
char *start = str.av_val;
char *end = start + str.av_len;
char *ptr = start;
while (ptr < end)
{
if (*ptr == '?')
{
str.av_len = ptr - start;
break;
}
ptr++;
}
memset(start + str.av_len, 0, 1);
char *dynamic = strstr(start, "[[DYNAMIC]]");
if (dynamic)
{
dynamic -= 1;
memset(dynamic, 0, 1);
str.av_len = dynamic - start;
end = start + str.av_len;
}
char *import = strstr(start, "[[IMPORT]]");
if (import)
{
str.av_val = import + 11;
strcpy(start, "http://");
str.av_val = strcat(start, str.av_val);
str.av_len = strlen(str.av_val);
}
return str;
}
str = *src;
return str;
} | false | false | false | false | false | 0 |
GetFPPos( long *pnPos, long *pnFID )
{
if( poSavedRecord != NULL )
*pnPos = nPreSavedPos;
else
*pnPos = nPostSavedPos;
if( pnFID != NULL )
*pnFID = nSavedFeatureId;
} | false | false | false | false | false | 0 |
spell_cat_line(buf, line, maxlen)
char_u *buf;
char_u *line;
int maxlen;
{
char_u *p;
int n;
p = skipwhite(line);
while (vim_strchr((char_u *)"*#/\"\t", *p) != NULL)
p = skipwhite(p + 1);
if (*p != NUL)
{
/* Only worth concatenating if there is something else than spaces to
* concatenate. */
n = (int)(p - line) + 1;
if (n < maxlen - 1)
{
vim_memset(buf, ' ', n);
vim_strncpy(buf + n, p, maxlen - 1 - n);
}
}
} | false | false | false | false | false | 0 |
area(const Mpoint* const p) const{
Vec v1,v2,vA;
float Tarea;
//calculate
v1=*_vertice[1]-*_vertice[0];
v2=*_vertice[2]-*_vertice[0];
Tarea=0.5*((v1*v2).norm());
//find appriopriate vector
for (int i = 0; i<3; i++){
if (p==_vertice[i]){
vA=(this->centroid())-*_vertice[i];
}
}
vA=vA/vA.norm()*Tarea;
return vA;
} | false | false | false | false | false | 0 |
check_field_access (MonoMethod *caller, MonoClassField *field)
{
/* if get_reflection_caller returns NULL then we assume the caller has NO privilege */
if (caller) {
MonoError error;
MonoClass *klass;
/* this check can occur before the field's type is resolved (and that can fail) */
mono_field_get_type_checked (field, &error);
if (!mono_error_ok (&error)) {
mono_error_cleanup (&error);
return FALSE;
}
klass = (mono_field_get_flags (field) & FIELD_ATTRIBUTE_STATIC) ? NULL : mono_field_get_parent (field);
return mono_method_can_access_field_full (caller, field, klass);
}
return FALSE;
} | false | false | false | false | false | 0 |
cleanup()
{
if (this->any_added_)
{
// If any input files were added, close all the input files.
// This is because the plugin may want to remove them, and on
// Windows you are not allowed to remove an open file.
close_all_descriptors();
}
for (this->current_ = this->plugins_.begin();
this->current_ != this->plugins_.end();
++this->current_)
(*this->current_)->cleanup();
} | false | false | false | false | false | 0 |
VFilter16(uint8_t* p, int stride,
int thresh, int ithresh, int hev_thresh) {
__m128i t1;
__m128i mask;
__m128i p2, p1, p0, q0, q1, q2;
// Load p3, p2, p1, p0
LOAD_H_EDGES4(p - 4 * stride, stride, t1, p2, p1, p0);
MAX_DIFF1(t1, p2, p1, p0, mask);
// Load q0, q1, q2, q3
LOAD_H_EDGES4(p, stride, q0, q1, q2, t1);
MAX_DIFF2(t1, q2, q1, q0, mask);
ComplexMask(&p1, &p0, &q0, &q1, thresh, ithresh, &mask);
DoFilter6(&p2, &p1, &p0, &q0, &q1, &q2, &mask, hev_thresh);
// Store
_mm_storeu_si128((__m128i*)&p[-3 * stride], p2);
_mm_storeu_si128((__m128i*)&p[-2 * stride], p1);
_mm_storeu_si128((__m128i*)&p[-1 * stride], p0);
_mm_storeu_si128((__m128i*)&p[+0 * stride], q0);
_mm_storeu_si128((__m128i*)&p[+1 * stride], q1);
_mm_storeu_si128((__m128i*)&p[+2 * stride], q2);
} | false | false | false | false | false | 0 |
glade_xml_get_property_int (GladeXmlNode * node_in,
const gchar * name, gint _default)
{
xmlNodePtr node = (xmlNodePtr) node_in;
gint retval;
gchar *value;
if ((value = glade_xml_get_property (node, name)) == NULL)
return _default;
retval = g_ascii_strtoll (value, NULL, 10);
g_free (value);
return retval;
} | false | false | false | false | false | 0 |
basic_test_cleanup(const struct testcase_t *testcase, void *ptr)
{
struct basic_test_data *data = ptr;
if (testcase->flags & TT_NO_LOGS)
event_set_log_callback(NULL);
if (testcase->flags & TT_NEED_SOCKETPAIR) {
if (data->pair[0] != -1)
evutil_closesocket(data->pair[0]);
if (data->pair[1] != -1)
evutil_closesocket(data->pair[1]);
}
if (testcase->flags & TT_NEED_DNS) {
evdns_shutdown(0);
}
if (testcase->flags & TT_NEED_BASE) {
if (data->base) {
event_base_assert_ok_(data->base);
event_base_free(data->base);
}
}
if (testcase->flags & TT_FORK)
libevent_global_shutdown();
free(data);
return 1;
} | false | false | false | false | false | 0 |
sequenceValidate(
Syntax *syntax,
struct berval *in )
{
if ( in->bv_len < 2 ) return LDAP_INVALID_SYNTAX;
if ( in->bv_val[0] != LBER_SEQUENCE ) return LDAP_INVALID_SYNTAX;
return LDAP_SUCCESS;
} | false | false | false | false | false | 0 |
check_all(char *str)
{
G_message("\n");
if (start_cell->above != NULL) {
G_fatal_error("Bad Start Cell\n");
}
check(str, start_cell);
return 0;
} | false | false | false | false | false | 0 |
decompress_contents (bfd_byte *compressed_buffer,
bfd_size_type compressed_size,
bfd_byte *uncompressed_buffer,
bfd_size_type uncompressed_size)
{
z_stream strm;
int rc;
/* It is possible the section consists of several compressed
buffers concatenated together, so we uncompress in a loop. */
strm.zalloc = NULL;
strm.zfree = NULL;
strm.opaque = NULL;
strm.avail_in = compressed_size - 12;
strm.next_in = (Bytef*) compressed_buffer + 12;
strm.avail_out = uncompressed_size;
BFD_ASSERT (Z_OK == 0);
rc = inflateInit (&strm);
while (strm.avail_in > 0 && strm.avail_out > 0)
{
if (rc != Z_OK)
break;
strm.next_out = ((Bytef*) uncompressed_buffer
+ (uncompressed_size - strm.avail_out));
rc = inflate (&strm, Z_FINISH);
if (rc != Z_STREAM_END)
break;
rc = inflateReset (&strm);
}
rc |= inflateEnd (&strm);
return rc == Z_OK && strm.avail_out == 0;
} | false | false | false | false | false | 0 |
CanMakeExternal() {
i::Handle<i::String> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
if (IsDeadCheck(isolate, "v8::String::CanMakeExternal()")) return false;
if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
return false;
}
int size = obj->Size(); // Byte size of the original string.
if (size < i::ExternalString::kSize)
return false;
i::StringShape shape(*obj);
return !shape.IsExternal();
} | 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.