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
|
---|---|---|---|---|---|---|
glmLinearTexture(GLMmodel* model, float h, float w)
{
GLMgroup *group;
GLfloat dimensions[3];
GLfloat x, y, scalefactor;
GLuint i;
if (!(model))return;
if (model->texcoords)
free(model->texcoords);
model->numtexcoords = model->numvertices;
model->texcoords=(GLfloat*)malloc(sizeof(GLfloat)*2*(model->numtexcoords+1));
glmDimensions(model, dimensions);
scalefactor = 2.0f /
_glmAbs(_glmMax(_glmMax(dimensions[0], dimensions[1]), dimensions[2]));
/* do the calculations */
for(i = 1; i <= model->numvertices; i++) {
x = model->vertices[3 * i + 0] * scalefactor;
y = model->vertices[3 * i + 2] * scalefactor;
model->texcoords[2 * i + 0] = ((x + 1.0f) / 2.0f) * w;
model->texcoords[2 * i + 1] = ((y + 1.0f) / 2.0f) * h;
}
/* go through and put texture coordinate indices in all the triangles */
group = model->groups;
while(group) {
for(i = 0; i < group->numtriangles; i++) {
T(group->triangles[i]).tindices[0] = T(group->triangles[i]).vindices[0];
T(group->triangles[i]).tindices[1] = T(group->triangles[i]).vindices[1];
T(group->triangles[i]).tindices[2] = T(group->triangles[i]).vindices[2];
}
group = group->next;
}
verbose(1, "glmLinearTexture(): generated %d linear texture coordinates", model->numtexcoords);
} | false | true | false | false | true | 1 |
rescale(int newsqside) {
float factor;
int i;
factor=((float)newsqside)/((float)orig_sqside);
for(i=0;i<376;i++) {
vec[i].x = (int) ( ( (float) (srcpiece[i].x) ) * factor);
vec[i].y = (int) ( ( (float) (srcpiece[i].y) ) * factor);
}
cur_sqside=newsqside;
} | false | false | false | false | false | 0 |
pickup_by_group(struct ast_channel *chan)
{
struct ast_channel *target;/*!< Potential pickup target */
int res = -1;
/* The found channel is already locked. */
target = ast_pickup_find_by_group(chan);
if (target) {
ast_log(LOG_NOTICE, "pickup %s attempt by %s\n", ast_channel_name(target), ast_channel_name(chan));
res = ast_do_pickup(chan, target);
ast_channel_unlock(target);
target = ast_channel_unref(target);
}
return res;
} | false | false | false | false | false | 0 |
ibus_attr_underline_new (guint underline_type,
guint start_index,
guint end_index)
{
g_return_val_if_fail (
underline_type == IBUS_ATTR_UNDERLINE_NONE ||
underline_type == IBUS_ATTR_UNDERLINE_SINGLE ||
underline_type == IBUS_ATTR_UNDERLINE_DOUBLE ||
underline_type == IBUS_ATTR_UNDERLINE_LOW, NULL);
return ibus_attribute_new (IBUS_ATTR_TYPE_UNDERLINE,
underline_type,
start_index,
end_index);
} | false | false | false | false | false | 0 |
checkListReplaceCurrent()
{
// go back to misspelled word
wlIt--;
QString s = *wlIt;
s.replace(posinline+offset,orig.length(),replacement());
offset += replacement().length()-orig.length();
wordlist->insert (wlIt, s);
wlIt = wordlist->erase (wlIt);
// wlIt now points to the word after the repalced one
} | false | false | false | false | false | 0 |
ndmca_tape_read_partial (struct ndm_session *sess, char *buf, unsigned count, int *read_count)
{
struct ndmconn * conn = sess->plumb.tape;
int rc;
NDMC_WITH(ndmp9_tape_read, NDMP9VER)
request->count = count;
rc = NDMC_CALL(conn);
if (rc == 0) {
*read_count = reply->data_in.data_in_len;
bcopy (reply->data_in.data_in_val, buf, *read_count);
} else {
rc = reply->error;
}
NDMC_FREE_REPLY();
NDMC_ENDWITH
return rc;
} | false | true | false | false | false | 1 |
update(const std::string&) {
if (World::menu())
_sequence = 1;
else if (_sequence == 1)
_sequence = 2;
} | false | false | false | false | false | 0 |
getUncompressedFrame(
DcmItem *dataset,
Uint32 frameNo,
Uint32& startFragment,
void *buffer,
Uint32 bufSize,
OFString& decompressedColorModel,
DcmFileCache *cache)
{
if ((dataset == NULL) || (buffer == NULL)) return EC_IllegalCall;
Sint32 numberOfFrames = 1;
dataset->findAndGetSint32(DCM_NumberOfFrames, numberOfFrames); // don't fail if absent
if (numberOfFrames < 1) numberOfFrames = 1;
Uint32 frameSize;
OFCondition result = getUncompressedFrameSize(dataset, frameSize);
if (result.bad()) return result;
// determine the minimum buffer size, which may be frame size plus one pad byte if frame size is odd.
// We need this extra byte, because the image might be in a different
// endianness than our host cpu. In this case the decoder will swap
// the data to the host byte order which could overflow the buffer.
Uint32 minBufSize = frameSize;
if (minBufSize & 1) ++minBufSize;
if (bufSize < minBufSize) return EC_IllegalCall;
// check frame number
if (frameNo >= OFstatic_cast(Uint32, numberOfFrames)) return EC_IllegalCall;
if (existUnencapsulated)
{
// we already have an uncompressed version of the pixel data
// either in memory or in file. We can directly access this using
// DcmElement::getPartialValue.
result = getPartialValue(buffer, frameNo * frameSize, frameSize, cache);
if (result.good()) result = dataset->findAndGetOFString(DCM_PhotometricInterpretation, decompressedColorModel);
}
else
{
// we only have a compressed version of the pixel data.
// Identify a codec for decompressing the frame.
result = DcmCodecList::decodeFrame(
(*original)->repType, (*original)->repParam, (*original)->pixSeq,
dataset, frameNo, startFragment, buffer, bufSize, decompressedColorModel);
}
return result;
} | false | false | false | false | false | 0 |
soup_cookie_free (SoupCookie *cookie)
{
g_return_if_fail (cookie != NULL);
g_free (cookie->name);
g_free (cookie->value);
g_free (cookie->domain);
g_free (cookie->path);
g_clear_pointer (&cookie->expires, soup_date_free);
g_slice_free (SoupCookie, cookie);
} | false | false | false | false | false | 0 |
HSVtoRGB(HSV hsv)
{
RGB rgb;
float h, f, p, q, t;
int i;
rgb.r = 0.0;
rgb.g = 0.0;
rgb.b = 0.0;
if (hsv.s == 0.0) {
rgb.r = rgb.g = rgb.b = hsv.v;
return (rgb);
}
else {
if (hsv.h == 360.0) {
hsv.h = 0.0;
}
h = hsv.h / 60;
i = floor(h);
f = h - i;
p = hsv.v * (1 - hsv.s);
q = hsv.v * (1 - (hsv.s * f));
t = hsv.v * (1 - (hsv.s * (1 - f)));
switch (i) {
case 0:
rgb.r = hsv.v;
rgb.g = t;
rgb.b = p;
break;
case 1:
rgb.r = q;
rgb.g = hsv.v;
rgb.b = p;
break;
case 2:
rgb.r = p;
rgb.g = hsv.v;
rgb.b = t;
break;
case 3:
rgb.r = p;
rgb.g = q;
rgb.b = hsv.v;
break;
case 4:
rgb.r = t;
rgb.g = p;
rgb.b = hsv.v;
break;
case 5:
rgb.r = hsv.v;
rgb.g = p;
rgb.b = q;
break;
}
return (rgb);
}
} | false | false | false | false | false | 0 |
isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
in_port_t port)
{
memset(sockaddr, 0, sizeof(*sockaddr));
sockaddr->type.sin.sin_family = na->family;
switch (na->family) {
case AF_INET:
sockaddr->length = sizeof(sockaddr->type.sin);
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
#endif
sockaddr->type.sin.sin_addr = na->type.in;
sockaddr->type.sin.sin_port = htons(port);
break;
case AF_INET6:
sockaddr->length = sizeof(sockaddr->type.sin6);
#ifdef ISC_PLATFORM_HAVESALEN
sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
#endif
memcpy(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16);
#ifdef ISC_PLATFORM_HAVESCOPEID
sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na);
#endif
sockaddr->type.sin6.sin6_port = htons(port);
break;
default:
INSIST(0);
}
ISC_LINK_INIT(sockaddr, link);
} | false | true | false | false | false | 1 |
ensMarkermaplocationTrace(const EnsPMarkermaplocation mml,
ajuint level)
{
AjPStr indent = NULL;
if (!mml)
return ajFalse;
indent = ajStrNew();
ajStrAppendCountK(&indent, ' ', level * 2);
ajDebug("%SensMarkermaplocationTrace %p\n"
"%S Markersynonym %p\n"
"%S Mapname '%S'\n"
"%S Chromosomename '%S'\n"
"%S Position '%S'\n"
"%S Lodscore %f\n"
"%S Use %u\n",
indent, mml,
indent, mml->Use,
indent, mml->Markersynonym,
indent, mml->Mapname,
indent, mml->Chromosomename,
indent, mml->Lodscore);
ensMarkersynonymTrace(mml->Markersynonym, level + 1);
ajStrDel(&indent);
return ajTrue;
} | false | false | false | false | false | 0 |
sqlite_update_value(MetaDataType type,const char *key_a,const char *key_b, MetaDataContentType content_type, const char *content)
{
sqlite3_stmt *const stmt = meta_data_sqlite_stmt[META_DATA_SQL_UPDATE];
int ret;
sqlite3_reset(stmt);
ret = sqlite3_bind_int(stmt, 1, content_type);
if (ret != SQLITE_OK) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"sqlite3_bind_int() failed: %s",
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
ret = sqlite3_bind_text(stmt, 2, content,-1, NULL);
if (ret != SQLITE_OK) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"sqlite3_bind_text() failed: %s",
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
ret = sqlite3_bind_int(stmt, 3, type);
if (ret != SQLITE_OK) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"sqlite3_bind_int() failed: %s",
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
ret = sqlite3_bind_text(stmt, 4, key_a,-1, NULL);
if (ret != SQLITE_OK) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"sqlite3_bind_text() failed: %s",
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
ret = sqlite3_bind_text(stmt, 5, key_b,-1, NULL);
if (ret != SQLITE_OK) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"sqlite3_bind_text() failed: %s",
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
do {
ret = sqlite3_step(stmt);
} while (ret == SQLITE_BUSY);
if (ret != SQLITE_DONE) {
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_WARNING,"%s: sqlite3_step() failed: %s",__FUNCTION__,
sqlite3_errmsg(meta_data_sqlite_db));
return FALSE;
}
ret = sqlite3_changes(meta_data_sqlite_db);
sqlite3_reset(stmt);
sqlite3_clear_bindings(stmt);
g_log(MDC_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Updated entry: %i-%s-%s with status: %i", type, key_a, key_b, ret>0);
return ret > 0;
} | false | false | false | false | false | 0 |
update_primary_region_config( CoreLayerContext *context,
CoreLayerRegionConfig *config,
CoreLayerRegionConfigFlags flags )
{
DFBResult ret = DFB_OK;
D_ASSERT( context != NULL );
D_ASSERT( config != NULL );
if (context->primary.region) {
/* Set the new configuration. */
ret = dfb_layer_region_set_configuration( context->primary.region, config, flags );
}
else {
CoreLayer *layer = dfb_layer_at( context->layer_id );
D_ASSERT( layer->funcs != NULL );
D_ASSERT( layer->funcs->TestRegion != NULL );
/* Just test the new configuration. */
ret = layer->funcs->TestRegion( layer, layer->driver_data,
layer->layer_data, config, NULL );
}
if (ret)
return ret;
/* Remember the configuration. */
context->primary.config = *config;
return DFB_OK;
} | false | false | false | false | false | 0 |
setDragMovingEnabled(bool setting)
{
if (d_dragMovable != setting)
{
d_dragMovable = setting;
getTitlebar()->setDraggingEnabled(setting);
}
} | false | false | false | false | false | 0 |
bfa_ablk_pf_create(struct bfa_ablk_s *ablk, u16 *pcifn,
u8 port, enum bfi_pcifn_class personality,
u16 bw_min, u16 bw_max,
bfa_ablk_cbfn_t cbfn, void *cbarg)
{
struct bfi_ablk_h2i_pf_req_s *m;
if (!bfa_ioc_is_operational(ablk->ioc)) {
bfa_trc(ablk->ioc, BFA_STATUS_IOC_FAILURE);
return BFA_STATUS_IOC_FAILURE;
}
if (ablk->busy) {
bfa_trc(ablk->ioc, BFA_STATUS_DEVBUSY);
return BFA_STATUS_DEVBUSY;
}
ablk->pcifn = pcifn;
ablk->cbfn = cbfn;
ablk->cbarg = cbarg;
ablk->busy = BFA_TRUE;
m = (struct bfi_ablk_h2i_pf_req_s *)ablk->mb.msg;
bfi_h2i_set(m->mh, BFI_MC_ABLK, BFI_ABLK_H2I_PF_CREATE,
bfa_ioc_portid(ablk->ioc));
m->pers = cpu_to_be16((u16)personality);
m->bw_min = cpu_to_be16(bw_min);
m->bw_max = cpu_to_be16(bw_max);
m->port = port;
bfa_ioc_mbox_queue(ablk->ioc, &ablk->mb);
return BFA_STATUS_OK;
} | false | false | false | false | false | 0 |
ng_attr_parse_int(struct ng_attribute *attr, char *str)
{
int value,n;
if (0 == sscanf(str,"%d%n",&value,&n))
/* parse error */
return attr->defval;
if (str[n] == '%')
value = ng_attr_percent2int(attr,value);
if (value < attr->min)
value = attr->min;
if (value > attr->max)
value = attr->max;
return value;
} | false | false | false | false | false | 0 |
init_base()
{
DBUG_ASSERT(inited == 0);
inited= 1;
/*
Here we create file log handler. We don't do it for the table log handler
here as it cannot be created so early. The reason is THD initialization,
which depends on the system variables (parsed later).
*/
if (!file_log_handler)
file_log_handler= new Log_to_file_event_handler;
/* by default we use traditional error log */
init_error_log(LOG_FILE);
file_log_handler->init_pthread_objects();
mysql_rwlock_init(key_rwlock_LOCK_logger, &LOCK_logger);
} | false | false | false | false | false | 0 |
atanhf(float x)
{
float t;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if (ix>0x3f800000) /* |x|>1 */
return (x-x)/(x-x);
if(ix==0x3f800000)
return x/zero;
if(ix<0x31800000&&(huge+x)>zero) return x; /* x<2**-28 */
SET_FLOAT_WORD(x,ix);
if(ix<0x3f000000) { /* x < 0.5 */
t = x+x;
t = (float)0.5*log1pf(t+t*x/(one-x));
} else
t = (float)0.5*log1pf((x+x)/(one-x));
if(hx>=0) return t; else return -t;
} | false | false | false | false | false | 0 |
fso_framework_abstract_command_queue_enqueueCommand (FsoFrameworkAbstractCommandQueue* self, FsoFrameworkAbstractCommandHandler* command) {
GeeLinkedList* _tmp0_ = NULL;
FsoFrameworkAbstractCommandHandler* _tmp1_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (command != NULL);
_tmp0_ = self->priv->q;
_tmp1_ = command;
gee_deque_offer_tail ((GeeDeque*) _tmp0_, _tmp1_);
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _fso_framework_abstract_command_queue_checkRestartingQ_gsource_func, g_object_ref (self), g_object_unref);
} | false | false | false | false | false | 0 |
proctrack_p_plugin_get_pids(uint64_t cont_id, pid_t **pids, int *npids)
{
DIR *dir;
struct dirent *de;
char path[PATH_MAX], *endptr, *num, rbuf[1024];
char cmd[1024];
char state;
int fd, rc = SLURM_SUCCESS;
long pid, ppid, pgid, ret_l;
pid_t *pid_array = NULL;
int pid_count = 0;
if ((dir = opendir("/proc")) == NULL) {
error("opendir(/proc): %m");
rc = SLURM_ERROR;
goto fini;
}
while ((de = readdir(dir)) != NULL) {
num = de->d_name;
if ((num[0] < '0') || (num[0] > '9'))
continue;
ret_l = strtol(num, &endptr, 10);
if ((ret_l == LONG_MIN) || (ret_l == LONG_MAX) ||
(errno == ERANGE)) {
error("couldn't do a strtol on str %s(%ld): %m",
num, ret_l);
continue;
}
sprintf(path, "/proc/%s/stat", num);
if ((fd = open(path, O_RDONLY)) < 0) {
continue;
}
if (read(fd, rbuf, 1024) <= 0) {
close(fd);
continue;
}
close(fd);
if (sscanf(rbuf, "%ld %s %c %ld %ld",
&pid, cmd, &state, &ppid, &pgid) != 5) {
continue;
}
if (pgid != (long) cont_id)
continue;
if (state == 'Z') {
debug3("Defunct process skipped: command=%s state=%c "
"pid=%ld ppid=%ld pgid=%ld",
cmd, state, pid, ppid, pgid);
continue; /* Defunct, don't try to kill */
}
xrealloc(pid_array, sizeof(pid_t) * (pid_count + 1));
pid_array[pid_count++] = pid;
}
closedir(dir);
fini: *pids = pid_array;
*npids = pid_count;
return rc;
} | false | false | false | false | false | 0 |
AppendFlags(std::string& flags,
const char* newFlags)
{
if(this->WatcomWMake && newFlags && *newFlags)
{
std::string newf = newFlags;
if(newf.find("\\\"") != newf.npos)
{
cmSystemTools::ReplaceString(newf, "\\\"", "\"");
this->cmLocalGenerator::AppendFlags(flags, newf.c_str());
return;
}
}
this->cmLocalGenerator::AppendFlags(flags, newFlags);
} | false | false | false | false | false | 0 |
proc_lookupfd_common(struct inode *dir,
struct dentry *dentry,
instantiate_t instantiate)
{
struct task_struct *task = get_proc_task(dir);
int result = -ENOENT;
unsigned fd = name_to_int(&dentry->d_name);
if (!task)
goto out_no_task;
if (fd == ~0U)
goto out;
result = instantiate(dir, dentry, task, (void *)(unsigned long)fd);
out:
put_task_struct(task);
out_no_task:
return ERR_PTR(result);
} | false | false | false | false | false | 0 |
__glXBindTexImageEXT(Display * dpy,
GLXDrawable drawable, int buffer, const int *attrib_list)
{
struct glx_context *gc = __glXGetCurrentContext();
if (gc == NULL || gc->vtable->bind_tex_image == NULL)
return;
gc->vtable->bind_tex_image(dpy, drawable, buffer, attrib_list);
} | false | false | false | false | false | 0 |
dewarpaDestroy(L_DEWARPA **pdewa)
{
l_int32 i;
L_DEWARP *dew;
L_DEWARPA *dewa;
PROCNAME("dewarpaDestroy");
if (pdewa == NULL) {
L_WARNING("ptr address is null!\n", procName);
return;
}
if ((dewa = *pdewa) == NULL)
return;
for (i = 0; i < dewa->nalloc; i++) {
if ((dew = dewa->dewarp[i]) != NULL)
dewarpDestroy(&dew);
if ((dew = dewa->dewarpcache[i]) != NULL)
dewarpDestroy(&dew);
}
numaDestroy(&dewa->namodels);
numaDestroy(&dewa->napages);
FREE(dewa->dewarp);
FREE(dewa->dewarpcache);
FREE(dewa);
*pdewa = NULL;
return;
} | false | false | false | false | false | 0 |
create_stack( u_64 thispid, unsigned int thiscpu, u_64 stack_start_time )
{
struct stack_item *stack;
fprintf(stdbug, "create_stack for pid %"PRId64", cpu %u, rel time %"PRIu64"\n",
thispid, thiscpu, stack_start_time);
MALLOC(stack,"stack for pid %"PRId64"", thispid);
stack->pid = thispid;
stack->cpu = thiscpu;
stack->user_cycles = 0LL;
stack->pos = 0;
stack->code[0] = 0;
stack->start_cycle[0] = stack_start_time;
stack->next_fun_index = 0;
stack->fun_index[0] = 0;
stack->next = stack_head; /* push on stack list */
stack_head = stack;
return stack;
} | false | false | false | false | false | 0 |
ctlr_erase(Boolean alt)
{
int newROWS, newCOLS;
kybd_inhibit(False);
ctlr_clear(True);
/* Let a script go. */
sms_host_output();
if (alt) {
newROWS = altROWS;
newCOLS = altCOLS;
} else {
newROWS = defROWS;
newCOLS = defCOLS;
}
if (alt == screen_alt && ROWS == newROWS && COLS == newCOLS)
return;
screen_disp(True);
if (visible_control) {
/* Blank the entire display. */
ctlr_blanks();
ROWS = maxROWS;
COLS = maxCOLS;
screen_disp(False);
}
ROWS = newROWS;
COLS = newCOLS;
if (visible_control) {
/* Fill the active part of the screen with NULLs again. */
ctlr_clear(False);
screen_disp(False);
}
screen_alt = alt;
} | false | false | false | false | false | 0 |
notifyCloudObservers( const QVariantMap &cloudMap ) const
{
foreach( InfoObserver *observer, m_cloudObservers )
observer->infoChanged( cloudMap );
} | false | false | false | false | false | 0 |
execute(CMD_Args *args, CMD_Context context)
{
DBG(0, form("KCemu/CMD/warning",
"*** Warning: CMD without execute() function called!\n"
"*** command is: '%s' [%p]\n"
"*** context is: %d [0x%08x]\n",
get_name(), this, context, context));
} | false | false | false | false | false | 0 |
__clear_close_on_exec(int fd, struct fdtable *fdt)
{
if (test_bit(fd, fdt->close_on_exec))
__clear_bit(fd, fdt->close_on_exec);
} | false | false | false | false | false | 0 |
doinit() {
HardProcessConstructor::doinit();
if(processOption_==2&&outgoing_.size()!=2)
throw InitException()
<< "Exclusive processes require exactly"
<< " two outgoing particles but " << outgoing_.size()
<< "have been inserted in ResonantProcessConstructor::doinit()."
<< Exception::runerror;
} | false | false | false | false | false | 0 |
sizeHint() const
{
return fontMetrics().size(0, d->m_Text);
} | false | false | false | false | false | 0 |
scsi_ioctl_pathinfo (struct path * pp, int mask)
{
if (mask & DI_SERIAL) {
get_serial(pp->serial, SERIAL_SIZE, pp->fd);
condlog(3, "%s: serial = %s", pp->dev, pp->serial);
}
return 0;
} | false | false | false | false | false | 0 |
handleUnencodable(Char c, OutputByteStream *)
{
EncodeOutputCharStream tem(byteStream_, encoder_);
if (escaper_)
(*escaper_)(tem, c);
} | false | false | false | false | false | 0 |
am335x_phy_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct am335x_phy *am_phy = platform_get_drvdata(pdev);
/*
* Enable phy wakeup only if dev->power.can_wakeup is true.
* Make sure to enable wakeup to support remote wakeup in
* standby mode ( same is not supported in OFF(DS0) mode).
* Enable it by doing
* echo enabled > /sys/bus/platform/devices/<usb-phy-id>/power/wakeup
*/
if (device_may_wakeup(dev))
phy_ctrl_wkup(am_phy->phy_ctrl, am_phy->id, true);
phy_ctrl_power(am_phy->phy_ctrl, am_phy->id, false);
return 0;
} | false | false | false | false | false | 0 |
displayVersionInfo( )
{
char cmd[20];
char rcv_status0,rcv_status1;
char rcv_data[2000];
size_t toWrite;
int rcv_dataLength;
if (!checkCOMisOpen()) return false;
printf_debug("[CHokuyoURG::displayVersionInfo] Asking info...");
// Send command:
os::sprintf(cmd,20, "VV\x0A");
toWrite = 3;
m_stream->WriteBuffer(cmd,toWrite);
// Receive response:
if (!receiveResponse( cmd, rcv_status0,rcv_status1, rcv_data, rcv_dataLength ) )
{
std::cerr << "Error waiting for response\n";
return false;
}
// DECODE:
if (rcv_status0!='0')
{
std::cerr << "Error in LIDAR status: "<< (int)rcv_status0 <<"\n";
return false;
}
printf_debug("OK\n");
// PRINT:
for (int i=0;i<rcv_dataLength;i++)
{
if (rcv_data[i]==';')
rcv_data[i]='\n';
}
rcv_data[rcv_dataLength]=0;
printf_debug("\n------------- HOKUYO Scanner: Version Information ------\n");
printf_debug(rcv_data);
printf_debug("-------------------------------------------------------\n\n");
return true;
} | false | false | false | false | false | 0 |
do_cram_md5 (int sock, const char *command, struct query *ctl, const char *strip)
/* authenticate as per RFC2195 */
{
int result;
int len;
char buf1[1024];
char msg_id[768];
unsigned char response[16];
char reply[1024];
char *respdata;
gen_send (sock, "%s CRAM-MD5", command);
/* From RFC2195:
* The data encoded in the first ready response contains an
* presumptively arbitrary string of random digits, a timestamp, and the
* fully-qualified primary host name of the server. The syntax of the
* unencoded form must correspond to that of an RFC 822 'msg-id'
* [RFC822] as described in [POP3].
*/
if ((result = gen_recv (sock, buf1, sizeof (buf1)))) {
return result;
}
/* caller may specify a response prefix we should strip if present */
respdata = buf1;
if (strip && strncmp(buf1, strip, strlen(strip)) == 0)
respdata += strlen(strip);
len = from64tobits (msg_id, respdata, sizeof(msg_id));
if (len < 0) {
report (stderr, GT_("could not decode BASE64 challenge\n"));
return PS_AUTHFAIL;
} else if ((size_t)len < sizeof (msg_id)) {
msg_id[len] = 0;
} else {
msg_id[sizeof (msg_id)-1] = 0;
}
if (outlevel >= O_DEBUG) {
report (stdout, GT_("decoded as %s\n"), msg_id);
}
/* The client makes note of the data and then responds with a string
* consisting of the user name, a space, and a 'digest'. The latter is
* computed by applying the keyed MD5 algorithm from [KEYED-MD5] where
* the key is a shared secret and the digested text is the timestamp
* (including angle-brackets).
*/
hmac_md5((unsigned char *)ctl->password, strlen(ctl->password),
(unsigned char *)msg_id, strlen (msg_id),
response, sizeof (response));
snprintf (reply, sizeof(reply),
"%s %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
ctl->remotename,
response[0], response[1], response[2], response[3],
response[4], response[5], response[6], response[7],
response[8], response[9], response[10], response[11],
response[12], response[13], response[14], response[15]);
to64frombits (buf1, reply, strlen(reply));
/* ship the authentication back, accept the server's responses */
/* PMDF5.2 IMAP has a bug that requires this to be a single write */
suppress_tags = TRUE;
result = gen_transact(sock, "%s", buf1);
suppress_tags = FALSE;
if (result)
return(result);
else
return(PS_SUCCESS);
} | false | false | false | false | false | 0 |
amdlibGetOiTargetFromRawData(amdlibRAW_DATA *rawData,
amdlibOI_TARGET *target)
{
int i;
int cIndex = 0;
char targVal[amdlibKEYW_VAL_LEN];
amdlibLogTrace("amdlibFillOiTargetTableEntry()");
target->element[cIndex].targetId = 1;
/* Retrieve from Configuration Keyword values used for various headers */
for (i=0; i < rawData->insCfg.nbKeywords; i++)
{
if (strstr(rawData->insCfg.keywords[i].name, "ESO OBS TARG NAME") != NULL)
{
strncpy(targVal, rawData->insCfg.keywords[i].value,
amdlibKEYW_VAL_LEN);
amdlibStripQuotes(targVal);
strncpy(target->element[cIndex].targetName, targVal, 16);
}
/*Use strncmp since RA or DEC are not unique in the header*/
if (strncmp(rawData->insCfg.keywords[i].name, "RA ", 8) == 0)
{
sscanf(rawData->insCfg.keywords[i].value, "%lf",
&target->element[cIndex].raEp0);
}
if (strncmp(rawData->insCfg.keywords[i].name, "DEC ", 8) == 0)
{
sscanf(rawData->insCfg.keywords[i].value, "%lf",
&target->element[cIndex].decEp0);
}
if (strncmp(rawData->insCfg.keywords[i].name, "EQUINOX ", 8) == 0)
{
sscanf(rawData->insCfg.keywords[i].value, "%lf",
&target->element[cIndex].equinox);
}
/* the following values are fixed until ESO's VLTICS writes a good
* OI_TARGET by itself!*/
strncpy(target->element[cIndex].velTyp, "UNKNOWN", 8 );
strncpy(target->element[cIndex].velDef, "OPTICAL", 8 );
strncpy(target->element[cIndex].specTyp, "UNKNOWN", 16 );
}
return amdlibSUCCESS;
} | false | false | false | false | false | 0 |
debug(bool calledFromBreakpoint, int line, int fileNumber)
{
saveInfo();
#ifdef HAVE_GLK
glk_set_style(style_Preformatted);
#endif
if (calledFromBreakpoint)
displaySourceLocation(line, fileNumber);
while (TRUE) {
char commandLine[200];
readCommand(commandLine);
char *command = strtok(commandLine, " ");
char commandCode = parseDebugCommand(command);
switch (commandCode) {
case AMBIGUOUS_COMMAND: output("Ambiguous ADBG command abbreviation. ? for help."); break;
case ACTORS_COMMAND: handleActorsCommand(); break;
case BREAK_COMMAND: handleBreakCommand(fileNumber); break;
case CLASSES_COMMAND: handleClassesCommand(); break;
case DELETE_COMMAND: handleDeleteCommand(calledFromBreakpoint, line, fileNumber); break;
case EVENTS_COMMAND: showEvents(); break;
case EXIT_COMMAND: debugOption = FALSE; restoreInfo(); goto exit_debug;
case FILES_COMMAND: listFiles(); break;
case GO_COMMAND: restoreInfo(); goto exit_debug;
case HELP_COMMAND: handleHelpCommand(); break;
case INSTANCES_COMMAND: handleInstancesCommand(); break;
case INSTRUCTION_TRACE_COMMAND: toggleInstructionTrace(); break;
case LOCATIONS_COMMAND: handleLocationsCommand(); break;
case NEXT_COMMAND: handleNextCommand(calledFromBreakpoint); goto exit_debug;
case OBJECTS_COMMAND: handleObjectsCommand(); break;
case QUIT_COMMAND: terminate(0); break;
case SECTION_TRACE_COMMAND: toggleSectionTrace(); break;
default: output("Unknown ADBG command. ? for help."); break;
}
}
exit_debug:
#ifdef HAVE_GLK
glk_set_style(style_Normal);
#endif
;
} | false | false | false | false | false | 0 |
csio_hw_intr_enable(struct csio_hw *hw)
{
uint16_t vec = (uint16_t)csio_get_mb_intr_idx(csio_hw_to_mbm(hw));
uint32_t pf = SOURCEPF_G(csio_rd_reg32(hw, PL_WHOAMI_A));
uint32_t pl = csio_rd_reg32(hw, PL_INT_ENABLE_A);
/*
* Set aivec for MSI/MSIX. PCIE_PF_CFG.INTXType is set up
* by FW, so do nothing for INTX.
*/
if (hw->intr_mode == CSIO_IM_MSIX)
csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A),
AIVEC_V(AIVEC_M), vec);
else if (hw->intr_mode == CSIO_IM_MSI)
csio_set_reg_field(hw, MYPF_REG(PCIE_PF_CFG_A),
AIVEC_V(AIVEC_M), 0);
csio_wr_reg32(hw, PF_INTR_MASK, MYPF_REG(PL_PF_INT_ENABLE_A));
/* Turn on MB interrupts - this will internally flush PIO as well */
csio_mb_intr_enable(hw);
/* These are common registers - only a master can modify them */
if (csio_is_hw_master(hw)) {
/*
* Disable the Serial FLASH interrupt, if enabled!
*/
pl &= (~SF_F);
csio_wr_reg32(hw, pl, PL_INT_ENABLE_A);
csio_wr_reg32(hw, ERR_CPL_EXCEED_IQE_SIZE_F |
EGRESS_SIZE_ERR_F | ERR_INVALID_CIDX_INC_F |
ERR_CPL_OPCODE_0_F | ERR_DROPPED_DB_F |
ERR_DATA_CPL_ON_HIGH_QID1_F |
ERR_DATA_CPL_ON_HIGH_QID0_F | ERR_BAD_DB_PIDX3_F |
ERR_BAD_DB_PIDX2_F | ERR_BAD_DB_PIDX1_F |
ERR_BAD_DB_PIDX0_F | ERR_ING_CTXT_PRIO_F |
ERR_EGR_CTXT_PRIO_F | INGRESS_SIZE_ERR_F,
SGE_INT_ENABLE3_A);
csio_set_reg_field(hw, PL_INT_MAP0_A, 0, 1 << pf);
}
hw->flags |= CSIO_HWF_HW_INTR_ENABLED;
} | false | false | false | false | false | 0 |
hmm_delete_data(hmm_data_t *hd)
{
int i;
if (hd == 0) return;
for (i = 0; i <= hd->L; ++i) {
if (hd->f) free(hd->f[i]);
if (hd->b) free(hd->b[i]);
}
free(hd->f); free(hd->b); free(hd->s); free(hd->v); free(hd->p); free(hd->seq);
free(hd);
} | false | false | false | false | false | 0 |
init(jk_worker_t *pThis,
jk_map_t *props,
jk_worker_env_t *we, jk_logger_t *l)
{
ajp_worker_t *aw;
ajp_endpoint_t *ae;
jk_endpoint_t *je;
int rc;
JK_TRACE_EXIT(l);
if (ajp_init(pThis, props, we, l, AJP14_PROTO) == JK_FALSE) {
JK_TRACE_EXIT(l);
return JK_FALSE;
}
aw = pThis->worker_private;
/* Set Secret Key (used at logon time) */
aw->login->secret_key = jk_get_worker_secret_key(props, aw->name);
if (aw->login->secret_key == NULL) {
jk_log(l, JK_LOG_ERROR, "can't malloc secret_key");
JK_TRACE_EXIT(l);
return JK_FALSE;
}
/* Set WebServerName (used at logon time) */
aw->login->web_server_name = strdup(we->server_name);
if (aw->login->web_server_name == NULL) {
jk_log(l, JK_LOG_ERROR, "can't malloc web_server_name");
JK_TRACE_EXIT(l);
return JK_FALSE;
}
if (get_endpoint(pThis, &je, l) == JK_FALSE) {
JK_TRACE_EXIT(l);
return JK_FALSE;
}
ae = je->endpoint_private;
if (ajp_connect_to_endpoint(ae, l) == JK_TRUE) {
/* connection stage passed - try to get context info
* this is the long awaited autoconf feature :)
*/
rc = discovery(ae, we, l);
ajp_close_endpoint(ae, l);
JK_TRACE_EXIT(l);
return rc;
}
JK_TRACE_EXIT(l);
return JK_TRUE;
} | false | false | false | false | false | 0 |
decompress420NoMMXOV518(unsigned char *pIn,
unsigned char *pOut,
unsigned char *pTmp,
const int w,
const int h,
const int numpix,
struct comp_info *cinfo,
int yvu)
{
unsigned char *pOutU, *pOutV;
int iOutY, iOutU, iOutV, x, y;
int lastYDC = 0;
int lastUDC = 0;
int lastVDC = 0;
if (yvu) {
pOutV = pOut + numpix;
pOutU = pOutV + numpix / 4;
} else {
pOutU = pOut + numpix;
pOutV = pOutU + numpix / 4;
}
/* Start Y loop */
y = 0;
do {
iOutY = w * y;
iOutV = iOutU = iOutY / 4;
x = 0;
do {
decompress8x4(pTmp, pIn, &lastYDC, 0, cinfo);
copyBlock(pTmp, pOut + iOutY, w);
iOutY += 8;
x += 8;
} while (x < w);
iOutY = w * (y + 4);
x = 0;
do {
decompress8x4(pTmp, pIn, &lastUDC, 1, cinfo);
copyBlock(pTmp, pOutU + iOutU, w/2);
iOutU += 8;
decompress8x4(pTmp, pIn, &lastVDC, 1, cinfo);
copyBlock(pTmp, pOutV + iOutV, w/2);
iOutV += 8;
decompress8x4(pTmp, pIn, &lastYDC, 0, cinfo);
copyBlock(pTmp, pOut + iOutY, w);
iOutY += 8;
decompress8x4(pTmp, pIn, &lastYDC, 0, cinfo);
copyBlock(pTmp, pOut + iOutY, w);
iOutY += 8;
x += 16;
} while (x < w);
y += 8;
} while (y < h);
/* Did we decode too much? */
if (cinfo->bytes > cinfo->rawLen + 897)
return 1;
/* Did we decode enough? */
if (cinfo->bytes >= cinfo->rawLen - (897 + 64))
return 0;
else
return 1;
} | false | false | false | false | false | 0 |
spl_fixedarray_it_rewind(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
{
spl_fixedarray_it *iterator = (spl_fixedarray_it *)iter;
spl_fixedarray_object *intern = iterator->object;
if (intern->flags & SPL_FIXEDARRAY_OVERLOADED_REWIND) {
zend_user_it_rewind(iter TSRMLS_CC);
} else {
iterator->object->current = 0;
}
} | false | false | false | false | false | 0 |
gretl_model_set_full_vcv_info (MODEL *pmod, int vmaj, int vmin,
int order, int flags, double bw)
{
VCVInfo *vi;
int prev = 0;
int err = 0;
vi = gretl_model_get_data(pmod, "vcv_info");
if (vi == NULL) {
vi = vcv_info_new();
if (vi == NULL) {
return E_ALLOC;
}
} else {
prev = 1;
}
vi->vmaj = vmaj;
vi->vmin = vmin;
vi->order = order;
vi->flags = flags;
vi->bw = bw;
if (!prev) {
err = gretl_model_set_data(pmod, "vcv_info", vi,
GRETL_TYPE_STRUCT,
sizeof *vi);
}
return err;
} | false | false | false | false | false | 0 |
get_expr_register()
{
char_u *new_line;
new_line = getcmdline('=', 0L, 0);
if (new_line == NULL)
return NUL;
if (*new_line == NUL) /* use previous line */
vim_free(new_line);
else
set_expr_line(new_line);
return '=';
} | false | false | false | false | false | 0 |
null_put_params(gx_device * dev, gs_param_list * plist)
{
/*
* If this is not a page device, we must defeat attempts to reset
* the size; otherwise this is equivalent to gx_forward_put_params.
*/
int code = gx_forward_put_params(dev, plist);
if (code < 0 || dev_proc(dev, get_page_device)(dev) == dev)
return code;
dev->width = dev->height = 0;
return code;
} | false | false | false | false | false | 0 |
marshalReturnedValues(cdrStream& s)
{
pd_result.NP_marshalDataOnly(s);
for( CORBA::ULong j = 0; j < pd_params->count(); j++ ){
CORBA::NamedValue_ptr arg = pd_params->item(j);
if( arg->flags() & CORBA::ARG_OUT )
arg->value()->NP_marshalDataOnly(s);
}
} | false | false | false | false | false | 0 |
ClientTeam (edict_t * ent)
{
char *p;
static char value[128];
value[0] = 0;
if (!ent->client)
return value;
Q_strncpyz(value, Info_ValueForKey (ent->client->pers.userinfo, "skin"), sizeof(value));
p = strchr (value, '/');
if (!p)
return value;
if ((int) (dmflags->value) & DF_MODELTEAMS)
{
*p = 0;
return value;
}
// if ((int)(dmflags->value) & DF_SKINTEAMS)
return ++p;
} | false | false | false | false | false | 0 |
crash_reset_signals(void)
{
unsigned i;
/*
* The signal mask is preserved across execve(), therefore it is
* important to also unblock all the signals we trap in case we
* are about to re-exec() ourselves from a signal handler!
*/
for (i = 0; i < G_N_ELEMENTS(signals); i++) {
signal_set(signals[i], SIG_DFL);
signal_unblock(signals[i]);
}
} | false | false | false | false | false | 0 |
Comb(const BitField &bf)
{
size_t i;
if( !_isempty_sp(bf) && !_isfull() ){
if( _isfull_sp(bf) ){
SetAll();
}else if( _isempty() ){
memcpy(b, bf.b, nbytes);
nset = bf.nset;
}else{
for(i = 0; i < nbytes; i++) b[i] |= bf.b[i];
_recalc();
}
}
} | false | false | false | false | false | 0 |
list_backups(ext2_filsys fs, unsigned int *three,
unsigned int *five, unsigned int *seven)
{
unsigned int *min = three;
int mult = 3;
unsigned int ret;
if (!(fs->super->s_feature_ro_compat &
EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER)) {
ret = *min;
*min += 1;
return ret;
}
if (*five < *min) {
min = five;
mult = 5;
}
if (*seven < *min) {
min = seven;
mult = 7;
}
ret = *min;
*min *= mult;
return ret;
} | false | false | false | false | false | 0 |
glf3_header_write(glfFile fp, const glf3_header_t *h)
{
int32_t x;
bgzf_write(fp, "GLF\3", 4);
x = glf3_is_BE? bam_swap_endian_4(h->l_text) : h->l_text;
bgzf_write(fp, &x, 4);
if (h->l_text) bgzf_write(fp, h->text, h->l_text);
} | false | false | false | false | false | 0 |
make_pass_instance (struct opt_pass *pass, bool track_duplicates)
{
/* A nonzero static_pass_number indicates that the
pass is already in the list. */
if (pass->static_pass_number)
{
struct opt_pass *new_pass;
if (pass->type == GIMPLE_PASS
|| pass->type == RTL_PASS
|| pass->type == SIMPLE_IPA_PASS)
{
new_pass = XNEW (struct opt_pass);
memcpy (new_pass, pass, sizeof (struct opt_pass));
}
else if (pass->type == IPA_PASS)
{
new_pass = (struct opt_pass *)XNEW (struct ipa_opt_pass_d);
memcpy (new_pass, pass, sizeof (struct ipa_opt_pass_d));
}
else
gcc_unreachable ();
new_pass->next = NULL;
new_pass->todo_flags_start &= ~TODO_mark_first_instance;
/* Indicate to register_dump_files that this pass has duplicates,
and so it should rename the dump file. The first instance will
be -1, and be number of duplicates = -static_pass_number - 1.
Subsequent instances will be > 0 and just the duplicate number. */
if ((pass->name && pass->name[0] != '*') || track_duplicates)
{
pass->static_pass_number -= 1;
new_pass->static_pass_number = -pass->static_pass_number;
}
return new_pass;
}
else
{
pass->todo_flags_start |= TODO_mark_first_instance;
pass->static_pass_number = -1;
invoke_plugin_callbacks (PLUGIN_NEW_PASS, pass);
}
return pass;
} | false | false | false | false | false | 0 |
lookup(Table *table, Sym *sym) {
unsigned key;
Entry *entry;
key = symToStamp(sym);
while (table != NULL) {
entry = lookupBintree(table->bintree, key);
if (entry != NULL) {
return entry;
}
table = table->upperLevel;
}
return NULL;
} | false | false | false | false | false | 0 |
initializefixed(struct filter *f, struct initdata *i)
{
struct fixeddata *s = (struct fixeddata *) f->data;
struct palette *palette;
int r, g;
inhermisc(f, i);
if (i->image->palette->type == FIXEDCOLOR
&& !(f->req.supportedmask & FIXEDCOLOR)) {
int red, green, blue;
i->image->palette->alloccolor = myfixedalloccolor;
i->image->palette->allocfinished = myallocfinished;
i->image->palette->data = s->palette;
if (!inherimage
(f, i, TOUCHIMAGE | IMAGEDATA, 0, 0, s->palette, 0, 0))
return 0;
if (s->active == -1) {
palette = clonepalette(f->image->palette);
restorepalette(s->palette, palette);
destroypalette(palette);
}
create_rgb_table(s->table, f->image->palette);
checksizes(s->table, &red, &green, &blue);
for (r = 0; r < MSIZE; r++)
for (g = 0; g < MSIZE; g++) {
s->rmat[r][g] = ((int) matrix[r][g] - 128) * red / 256;
s->gmat[r][g] =
((int) matrix[(r + 3) % MSIZE][(g + 6) % MSIZE] -
128) * green / 256;
s->bmat[r][g] =
((int) matrix[(r + 6) % MSIZE][(g + 3) % MSIZE] -
128) * blue / 256;
}
s->palette->data = &s->palette;
setfractalpalette(f, s->palette);
s->active = 1;
f->queue->saveimage = f->childimage;
f->queue->palettechg = f;
return (f->previous->action->initialize(f->previous, i));
} else {
if (s->active == 1) {
s->fixcolor = 1;
}
s->active = 0;
return (f->previous->action->initialize(f->previous, i));
}
} | false | false | false | false | false | 0 |
omega_query_variable (omega_pb pb, int i, int *lower_bound, int *upper_bound)
{
int n_vars = pb->num_vars;
int e, j;
bool is_simple;
bool coupled = false;
*lower_bound = neg_infinity;
*upper_bound = pos_infinity;
i = pb->forwarding_address[i];
if (i < 0)
{
i = -i - 1;
for (j = 1; j <= n_vars; j++)
if (pb->subs[i].coef[j] != 0)
return true;
*upper_bound = *lower_bound = pb->subs[i].coef[0];
return false;
}
for (e = pb->num_subs - 1; e >= 0; e--)
if (pb->subs[e].coef[i] != 0)
coupled = true;
for (e = pb->num_eqs - 1; e >= 0; e--)
if (pb->eqs[e].coef[i] != 0)
{
is_simple = true;
for (j = 1; j <= n_vars; j++)
if (i != j && pb->eqs[e].coef[j] != 0)
{
is_simple = false;
coupled = true;
break;
}
if (!is_simple)
continue;
else
{
*lower_bound = *upper_bound =
-pb->eqs[e].coef[i] * pb->eqs[e].coef[0];
return false;
}
}
for (e = pb->num_geqs - 1; e >= 0; e--)
if (pb->geqs[e].coef[i] != 0)
{
if (pb->geqs[e].key == i)
*lower_bound = MAX (*lower_bound, -pb->geqs[e].coef[0]);
else if (pb->geqs[e].key == -i)
*upper_bound = MIN (*upper_bound, pb->geqs[e].coef[0]);
else
coupled = true;
}
return coupled;
} | false | false | false | false | false | 0 |
ecore_con_event_client_write(Ecore_Con_Client *cl, int num)
{
Ecore_Con_Event_Client_Write *e;
e = ecore_con_event_client_write_alloc();
EINA_SAFETY_ON_NULL_RETURN(e);
cl->event_count = eina_list_append(cl->event_count, e);
cl->host_server->event_count = eina_list_append(cl->host_server->event_count, e);
e->client = cl;
e->size = num;
ecore_event_add(ECORE_CON_EVENT_CLIENT_WRITE, e,
(Ecore_End_Cb)_ecore_con_event_client_write_free, cl->host_server);
_ecore_con_event_count++;
} | false | false | false | false | false | 0 |
lowestEndPoint(const IntervalInfo &I1,
const IntervalInfo &I2) {
SlotIndex E1 = getEndPoint(I1);
SlotIndex E2 = getEndPoint(I2);
if (E1 < E2)
return true;
if (E1 > E2)
return false;
// If two intervals end at the same point, we need a way to break the tie or
// the set will assume they're actually equal and refuse to insert a
// "duplicate". Just compare the vregs - fast and guaranteed unique.
return std::get<0>(I1)->reg < std::get<0>(I2)->reg;
} | false | false | false | false | false | 0 |
of_match_bus(struct device_node *np)
{
int i;
for (i = 0; i < ARRAY_SIZE(of_busses); i++)
if (!of_busses[i].match || of_busses[i].match(np))
return &of_busses[i];
BUG();
return NULL;
} | false | false | false | false | false | 0 |
StringToMultifield(
void *theEnv,
char *theString)
{
struct token theToken;
struct multifield *theSegment;
struct field *theFields;
unsigned long numberOfFields = 0;
struct expr *topAtom = NULL, *lastAtom = NULL, *theAtom;
/*====================================================*/
/* Open the string as an input source and read in the */
/* list of values to be stored in the multifield. */
/*====================================================*/
OpenStringSource(theEnv,"multifield-str",theString,0);
GetToken(theEnv,"multifield-str",&theToken);
while (theToken.type != STOP)
{
if ((theToken.type == SYMBOL) || (theToken.type == STRING) ||
(theToken.type == FLOAT) || (theToken.type == INTEGER) ||
(theToken.type == INSTANCE_NAME))
{ theAtom = GenConstant(theEnv,theToken.type,theToken.value); }
else
{ theAtom = GenConstant(theEnv,STRING,EnvAddSymbol(theEnv,theToken.printForm)); }
numberOfFields++;
if (topAtom == NULL) topAtom = theAtom;
else lastAtom->nextArg = theAtom;
lastAtom = theAtom;
GetToken(theEnv,"multifield-str",&theToken);
}
CloseStringSource(theEnv,"multifield-str");
/*====================================================================*/
/* Create a multifield of the appropriate size for the values parsed. */
/*====================================================================*/
theSegment = (struct multifield *) EnvCreateMultifield(theEnv,numberOfFields);
theFields = theSegment->theFields;
/*====================================*/
/* Copy the values to the multifield. */
/*====================================*/
theAtom = topAtom;
numberOfFields = 0;
while (theAtom != NULL)
{
theFields[numberOfFields].type = theAtom->type;
theFields[numberOfFields].value = theAtom->value;
numberOfFields++;
theAtom = theAtom->nextArg;
}
/*===========================*/
/* Return the parsed values. */
/*===========================*/
ReturnExpression(theEnv,topAtom);
/*============================*/
/* Return the new multifield. */
/*============================*/
return(theSegment);
} | false | false | false | false | false | 0 |
ipw2100_reset_adapter(struct work_struct *work)
{
struct ipw2100_priv *priv =
container_of(work, struct ipw2100_priv, reset_work.work);
unsigned long flags;
union iwreq_data wrqu = {
.ap_addr = {
.sa_family = ARPHRD_ETHER}
};
int associated = priv->status & STATUS_ASSOCIATED;
spin_lock_irqsave(&priv->low_lock, flags);
IPW_DEBUG_INFO(": %s: Restarting adapter.\n", priv->net_dev->name);
priv->resets++;
priv->status &= ~(STATUS_ASSOCIATED | STATUS_ASSOCIATING);
priv->status |= STATUS_SECURITY_UPDATED;
/* Force a power cycle even if interface hasn't been opened
* yet */
cancel_delayed_work(&priv->reset_work);
priv->status |= STATUS_RESET_PENDING;
spin_unlock_irqrestore(&priv->low_lock, flags);
mutex_lock(&priv->action_mutex);
/* stop timed checks so that they don't interfere with reset */
priv->stop_hang_check = 1;
cancel_delayed_work(&priv->hang_check);
/* We have to signal any supplicant if we are disassociating */
if (associated)
wireless_send_event(priv->net_dev, SIOCGIWAP, &wrqu, NULL);
ipw2100_up(priv, 0);
mutex_unlock(&priv->action_mutex);
} | false | false | false | false | false | 0 |
gee_concurrent_set_sub_iterator_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeConcurrentSetRange* range) {
GeeConcurrentSetSubIterator * self = NULL;
GeeConcurrentSetRange* _tmp0_ = NULL;
GeeConcurrentSetRange* _tmp1_ = NULL;
GeeConcurrentSetRange* _tmp2_ = NULL;
g_return_val_if_fail (range != NULL, NULL);
self = (GeeConcurrentSetSubIterator*) g_object_new (object_type, NULL);
self->priv->g_type = g_type;
self->priv->g_dup_func = g_dup_func;
self->priv->g_destroy_func = g_destroy_func;
_tmp0_ = range;
gee_concurrent_set_range_improve_bookmark (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, _tmp0_, NULL, NULL);
_tmp1_ = range;
_tmp2_ = _gee_concurrent_set_range_ref0 (_tmp1_);
_gee_concurrent_set_range_unref0 (self->priv->_range);
self->priv->_range = _tmp2_;
return self;
} | false | false | false | false | false | 0 |
_gcry_pk_map_name (const char *string)
{
gcry_pk_spec_t *spec;
if (!string)
return 0;
spec = spec_from_name (string);
if (!spec)
return 0;
if (spec->flags.disabled)
return 0;
return spec->algo;
} | false | false | false | false | false | 0 |
ubi_debugfs_init(void)
{
if (!IS_ENABLED(CONFIG_DEBUG_FS))
return 0;
dfs_rootdir = debugfs_create_dir("ubi", NULL);
if (IS_ERR_OR_NULL(dfs_rootdir)) {
int err = dfs_rootdir ? PTR_ERR(dfs_rootdir) : -ENODEV;
pr_err("UBI error: cannot create \"ubi\" debugfs directory, error %d\n",
err);
return err;
}
return 0;
} | false | false | false | false | false | 0 |
findsubquery(QTNode *root, QTNode *ex, QTNode *subs, bool *isfind)
{
bool DidFind = false;
root = dofindsubquery(root, ex, subs, &DidFind);
if (!subs && DidFind)
root = dropvoidsubtree(root);
if (isfind)
*isfind = DidFind;
return root;
} | false | false | false | false | false | 0 |
ProcessTicks(unsigned dequeue_order) {
while (true) {
const TickSampleEventRecord* rec =
reinterpret_cast<TickSampleEventRecord*>(ticks_buffer_.StartDequeue());
if (rec == NULL) return false;
if (rec->order == dequeue_order) {
generator_->RecordTickSample(rec->sample);
ticks_buffer_.FinishDequeue();
} else {
return true;
}
}
} | false | false | false | false | false | 0 |
sk_set(_STACK *st, int i, void *value)
{
if(!st || (i < 0) || (i >= st->num)) return NULL;
return (st->data[i] = value);
} | false | false | false | false | false | 0 |
dht_fsync2 (xlator_t *this, call_frame_t *frame, int op_ret)
{
dht_local_t *local = NULL;
xlator_t *subvol = NULL;
uint64_t tmp_subvol = 0;
int ret = -1;
local = frame->local;
ret = fd_ctx_get (local->fd, this, &tmp_subvol);
if (!ret)
subvol = (xlator_t *)(long)tmp_subvol;
if (!subvol)
subvol = local->cached_subvol;
local->call_cnt = 2; /* This is the second attempt */
STACK_WIND (frame, dht_fsync_cbk, subvol, subvol->fops->fsync,
local->fd, local->rebalance.flags, NULL);
return 0;
} | false | false | false | false | false | 0 |
PyvtkVolumeProperty_GetScalarOpacityMTime_s2(PyObject *self, PyObject *args)
{
vtkPythonArgs ap(self, args, "GetScalarOpacityMTime");
vtkObjectBase *vp = ap.GetSelfPointer(self, args);
vtkVolumeProperty *op = static_cast<vtkVolumeProperty *>(vp);
PyObject *result = NULL;
if (op && ap.CheckArgCount(0))
{
vtkTimeStamp tempr = (ap.IsBound() ?
op->GetScalarOpacityMTime() :
op->vtkVolumeProperty::GetScalarOpacityMTime());
if (!ap.ErrorOccurred())
{
result = ap.BuildSpecialObject(&tempr, "vtkTimeStamp");
}
}
return result;
} | false | false | false | false | false | 0 |
oggpack_look(oggpack_buffer *b, int bits) {
unsigned long ret;
unsigned long m=mask[bits];
bits+=b->endbit;
if (b->endbyte+4>=b->storage) {
if (b->endbyte+(bits-1)/8>=b->storage) return -1;
}
ret=b->ptr[0]>>b->endbit;
if (bits>8) {
ret|=b->ptr[1]<<(8-b->endbit);
if (bits>16) {
ret|=b->ptr[2]<<(16-b->endbit);
if (bits>24) {
ret|=b->ptr[3]<<(24-b->endbit);
if (bits>32 && b->endbit)
ret|=b->ptr[4]<<(32-b->endbit);
}
}
}
return m&ret;
} | false | false | false | false | false | 0 |
ptr_from_index(Py_buffer *view, Py_ssize_t index)
{
char *ptr;
Py_ssize_t nitems; /* items in the first dimension */
assert(view->shape);
assert(view->strides);
nitems = view->shape[0];
if (index < 0) {
index += nitems;
}
if (index < 0 || index >= nitems) {
PyErr_SetString(PyExc_IndexError, "index out of bounds");
return NULL;
}
ptr = (char *)view->buf;
ptr += view->strides[0] * index;
ptr = ADJUST_PTR(ptr, view->suboffsets);
return ptr;
} | false | false | false | false | false | 0 |
ResearchGraph( PG_Widget *parent, const PG_Rect& rect, ContainerBase* container ) : GraphWidget( parent, rect ), cont( container ) {
setRange( cont->maxresearchpoints+1, returnResourcenUseForResearch( cont, cont->maxresearchpoints ).energy );
addCurve( 0x00ff00 );
recalc();
} | false | false | false | false | false | 0 |
scif_fixup_aper_base(struct scif_dev *dev, struct scif_window *window)
{
int j;
struct scif_hw_dev *sdev = dev->sdev;
phys_addr_t apt_base = 0;
/*
* Add the aperture base if the DMA address is not card relative
* since the DMA addresses need to be an offset into the bar
*/
if (!scifdev_self(dev) && window->type == SCIF_WINDOW_PEER &&
sdev->aper && !sdev->card_rel_da)
apt_base = sdev->aper->pa;
else
return;
for (j = 0; j < window->nr_contig_chunks; j++) {
if (window->num_pages[j])
window->dma_addr[j] += apt_base;
else
break;
}
} | false | false | false | false | false | 0 |
dw_mci_pull_part_bytes(struct dw_mci *host, void *buf, int cnt)
{
cnt = min_t(int, cnt, host->part_buf_count);
if (cnt) {
memcpy(buf, (void *)&host->part_buf + host->part_buf_start,
cnt);
host->part_buf_count -= cnt;
host->part_buf_start += cnt;
}
return cnt;
} | false | false | false | false | false | 0 |
dircopy( const KUrl & src, const KUrl & target, QWidget* window )
{
KUrl::List srcList;
srcList.append( src );
return NetAccess::dircopy( srcList, target, window );
} | false | false | false | false | false | 0 |
send_file(socket_struct *ns, const char *file) {
char buf[MAX_BUF];
FILE *fp;
SockList sl;
if (!strcmp(file,"motd"))
snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, settings.motd);
else if (!strcmp(file,"rules"))
snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, settings.rules);
else if (!strcmp(file,"news"))
snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, settings.news);
else {
LOG(llevError,"send_file requested to send unknown file: %s\n", file);
return;
}
fp = fopen(buf, "r");
if (fp == NULL)
return;
SockList_Init(&sl);
SockList_AddString(&sl, "replyinfo ");
SockList_AddString(&sl, file);
SockList_AddString(&sl, "\n");
while (fgets(buf, MAX_BUF, fp) != NULL) {
if (*buf == '#')
continue;
SockList_AddString(&sl, buf);
}
fclose(fp);
SockList_AddChar(&sl, 0); /* Null terminate it */
Send_With_Handling(ns, &sl);
SockList_Term(&sl);
} | false | false | false | false | false | 0 |
git_odb_read_header(size_t *len_p, git_otype *type_p, git_odb *db, const git_oid *id)
{
unsigned int i;
int error = GIT_ENOTFOUND;
git_odb_object *object;
assert(db && id);
if ((object = git_cache_get(&db->cache, id)) != NULL) {
*len_p = object->raw.len;
*type_p = object->raw.type;
git_odb_object_close(object);
return GIT_SUCCESS;
}
for (i = 0; i < db->backends.length && error < 0; ++i) {
backend_internal *internal = git_vector_get(&db->backends, i);
git_odb_backend *b = internal->backend;
if (b->read_header != NULL)
error = b->read_header(len_p, type_p, b, id);
}
/*
* no backend could read only the header.
* try reading the whole object and freeing the contents
*/
if (error < 0) {
if ((error = git_odb_read(&object, db, id)) < GIT_SUCCESS)
return error;
*len_p = object->raw.len;
*type_p = object->raw.type;
git_odb_object_close(object);
}
return GIT_SUCCESS;
} | false | false | false | false | false | 0 |
evhttp_handle_request(struct evhttp_request *req, void *arg)
{
struct evhttp *http = arg;
struct evhttp_cb *cb = NULL;
const char *hostname;
if (req->uri == NULL) {
evhttp_send_error(req, HTTP_BADREQUEST, "Bad Request");
return;
}
/* handle potential virtual hosts */
hostname = evhttp_find_header(req->input_headers, "Host");
if (hostname != NULL) {
struct evhttp *vhost;
TAILQ_FOREACH(vhost, &http->virtualhosts, next) {
if (prefix_suffix_match(vhost->vhost_pattern, hostname,
1 /* ignorecase */)) {
evhttp_handle_request(req, vhost);
return;
}
}
}
if ((cb = evhttp_dispatch_callback(&http->callbacks, req)) != NULL) {
(*cb->cb)(req, cb->cbarg);
return;
}
/* Generic call back */
if (http->gencb) {
(*http->gencb)(req, http->gencbarg);
return;
} else {
/* We need to send a 404 here */
#define ERR_FORMAT "<html><head>" \
"<title>404 Not Found</title>" \
"</head><body>" \
"<h1>Not Found</h1>" \
"<p>The requested URL %s was not found on this server.</p>"\
"</body></html>\n"
char *escaped_html;
struct evbuffer *buf;
if ((escaped_html = evhttp_htmlescape(req->uri)) == NULL) {
evhttp_connection_free(req->evcon);
return;
}
if ((buf = evbuffer_new()) == NULL) {
mm_free(escaped_html);
evhttp_connection_free(req->evcon);
return;
}
evhttp_response_code(req, HTTP_NOTFOUND, "Not Found");
evbuffer_add_printf(buf, ERR_FORMAT, escaped_html);
mm_free(escaped_html);
evhttp_send_page(req, buf);
evbuffer_free(buf);
#undef ERR_FORMAT
}
} | false | false | false | false | false | 0 |
changeActivation(bool activate, QWidget * originator) {
if (!activate) return;
//DebugDialog::debug(QString("change activation %1 %2").arg(activate).arg(originator->metaObject()->className()));
FritzingWindow * fritzingWindow = qobject_cast<FritzingWindow *>(originator);
if (fritzingWindow == NULL) {
fritzingWindow = qobject_cast<FritzingWindow *>(originator->parent());
}
if (fritzingWindow == NULL) return;
m_orderedTopLevelWidgets.removeOne(fritzingWindow);
m_orderedTopLevelWidgets.push_front(fritzingWindow);
m_activationTimer.stop();
m_activationTimer.start();
} | false | false | false | false | false | 0 |
gdl_dock_paned_dock (GdlDockObject *object,
GdlDockObject *requestor,
GdlDockPlacement position,
GValue *other_data)
{
GtkPaned *paned;
GtkWidget *child1, *child2;
gboolean done = FALSE;
gboolean hresize = FALSE;
gboolean wresize = FALSE;
gint temp = 0;
g_return_if_fail (GDL_IS_DOCK_PANED (object));
g_return_if_fail (gdl_dock_item_get_child (GDL_DOCK_ITEM (object)) != NULL);
paned = GTK_PANED (gdl_dock_item_get_child (GDL_DOCK_ITEM (object)));
if (GDL_IS_DOCK_ITEM (requestor)) {
g_object_get (G_OBJECT (requestor), "preferred_height", &temp, NULL);
if (temp == -2)
hresize = TRUE;
temp = 0;
g_object_get (G_OBJECT (requestor), "preferred_width", &temp, NULL);
if (temp == -2)
wresize = TRUE;
}
child1 = gtk_paned_get_child1 (paned);
child2 = gtk_paned_get_child2 (paned);
/* see if we can dock the item in our paned */
switch (gdl_dock_item_get_orientation (GDL_DOCK_ITEM (object))) {
case GTK_ORIENTATION_HORIZONTAL:
if (!child1 && position == GDL_DOCK_LEFT) {
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), TRUE, TRUE);
done = TRUE;
} else if (!child2 && position == GDL_DOCK_RIGHT) {
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), FALSE, FALSE);
done = TRUE;
}
break;
case GTK_ORIENTATION_VERTICAL:
if (!child1 && position == GDL_DOCK_TOP) {
gtk_paned_pack1 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
} else if (!child2 && position == GDL_DOCK_BOTTOM) {
gtk_paned_pack2 (paned, GTK_WIDGET (requestor), hresize, FALSE);
done = TRUE;
}
break;
default:
break;
}
if (!done) {
/* this will create another paned and reparent us there */
GDL_DOCK_OBJECT_CLASS (gdl_dock_paned_parent_class)->dock (object, requestor, position,
other_data);
}
else {
if (gtk_widget_get_visible (GTK_WIDGET (requestor)))
gdl_dock_item_show_grip (GDL_DOCK_ITEM (requestor));
}
} | false | false | false | false | false | 0 |
write(ostream &os) const {
if (m_col >= 0 && m_line > 0) {
os << m_line << ":" << (m_col-1);
} else if (m_line > 0) {
os << "line " << m_line;
} else if (m_col >= 0) {
os << "column " << (m_col-1);
}
return os;
} | false | false | false | false | false | 0 |
AddNextElementInternal(const Element *e)
{
Element::ConstPointer p(e);
this->m_Element.push_back(p);
} | false | false | false | false | false | 0 |
pack_yuv(TiffEncoderContext * s, uint8_t * dst, int lnum)
{
AVFrame *p = &s->picture;
int i, j, k;
int w = (s->width - 1) / s->subsampling[0] + 1;
uint8_t *pu = &p->data[1][lnum / s->subsampling[1] * p->linesize[1]];
uint8_t *pv = &p->data[2][lnum / s->subsampling[1] * p->linesize[2]];
for (i = 0; i < w; i++){
for (j = 0; j < s->subsampling[1]; j++)
for (k = 0; k < s->subsampling[0]; k++)
*dst++ = p->data[0][(lnum + j) * p->linesize[0] +
i * s->subsampling[0] + k];
*dst++ = *pu++;
*dst++ = *pv++;
}
} | false | false | false | false | false | 0 |
update_lineno (const char *l, size_t len)
{
while (len-- > 0)
if (*l++ == '\n')
lexer_line.line++;
} | false | false | false | false | false | 0 |
main(int argc, char **argv)
{
MdbHandle *mdb;
MdbTableDef *table;
gchar name[256];
gchar *propColName;
void *buf;
int col_num;
int found = 0;
if (argc < 3) {
fprintf(stderr,"Usage: %s <file> <object name> [<prop col>]\n",
argv[0]);
return 1;
}
if (argc < 4)
propColName = "LvProp";
else
propColName = argv[3];
mdb_init();
mdb = mdb_open(argv[1], MDB_NOFLAGS);
if (!mdb) {
mdb_exit();
return 1;
}
table = mdb_read_table_by_name(mdb, "MSysObjects", MDB_ANY);
if (!table) {
mdb_close(mdb);
mdb_exit();
return 1;
}
mdb_read_columns(table);
mdb_rewind_table(table);
mdb_bind_column_by_name(table, "Name", name, NULL);
buf = g_malloc(MDB_BIND_SIZE);
col_num = mdb_bind_column_by_name(table, propColName, buf, NULL);
if (col_num < 1) {
g_free(buf);
mdb_free_tabledef(table);
mdb_close(mdb);
mdb_exit();
printf("Column %s not found!\n", argv[3]);
return 1;
}
while(mdb_fetch_row(table)) {
if (!strcmp(name, argv[2])) {
found = 1;
break;
}
}
if (found) {
MdbColumn *col = g_ptr_array_index(table->columns, col_num-1);
size_t size;
void *kkd = mdb_ole_read_full(mdb, col, &size);
dump_kkd(mdb, kkd, size);
free(kkd);
}
g_free(buf);
mdb_free_tabledef(table);
mdb_close(mdb);
mdb_exit();
return 0;
} | false | false | false | false | false | 0 |
isbinarystream(fz_buffer *buf)
{
int i;
for (i = 0; i < buf->len; i++)
if (isbinary(buf->data[i]))
return 1;
return 0;
} | false | false | false | false | false | 0 |
abiword_storage_terminate(librdf_storage* storage)
{
abiwordContext* c = abiwordContext::get( storage );
delete c;
} | false | false | false | false | false | 0 |
adjacent_another_plane(struct xy rc, int alt, bool imjet,
const struct op_courses *opc) {
for ( ; opc; opc = opc->next) {
if (!opc->c || opc->c->at_exit)
continue;
struct xyz pos = opc->c->pos;
if (pos_adjacent(pos, rc, alt)) {
struct blp rv = { opc->c->bearing, pos.alt, opc->isjet };
return rv;
}
if (!imjet && opc->c->next) {
pos = opc->c->next->pos;
if (pos_adjacent(pos, rc, alt)) {
struct blp rv = { opc->c->next->bearing, pos.alt, opc->isjet };
return rv;
}
}
}
struct blp rv = { -1, -1, true };
return rv;
} | false | false | false | false | false | 0 |
read_8bit_data ()
{
// these are sizes for the final image
const unsigned int ncomp = grayscale ? 1 : 3;
const unsigned int line_size = info_header.width * ncomp;
const unsigned int image_size = info_header.height * line_size;
// seek to the data
stream.seekg( file_header.offset, std::ios::beg );
// make room for the pixels
pixels.resize(image_size);
// padding after each line (must end on a 32-bit boundary)
unsigned int pad_size = info_header.width % 4;
if ( pad_size > 0 )
pad_size = 4 - pad_size;
// setup the base pointer at one line after the end
UInt8 * base = pixels.data() + image_size;
UInt8 * mover = base;
// read scanlines from bottom to top
for ( int y = info_header.height - 1; y >= 0; --y ) {
// set the base pointer to the beginning of the line to be read
base -= line_size;
mover = base;
// read the line from left to right
for ( int x = 0; x < info_header.width; ++x ) {
// get the color byte
const int index = stream.get();
// map and assign the pixel
const UInt8 * map_base = map.data() + 3 * index;
for ( unsigned int i = 0; i < ncomp; ++i )
mover[i] = map_base[i];
mover += ncomp;
}
// advance to the next 32 bit boundary
stream.seekg( pad_size, std::ios::cur );
}
} | false | false | false | false | false | 0 |
addLemma(Theorem thm, CNF_Formula& cnf)
{
vector<Theorem> clauses;
d_rules->learnedClauses(thm, clauses, true);
DebugAssert(clauses.size() == 1, "expected single clause");
Lit l = translateExpr(clauses[0], cnf);
cnf.newClause();
cnf.addLiteral(l);
cnf.registerUnit();
// if(concreteLit(l) != clauses[0].getExpr()){
// cout<<"fail addunit 4" << endl;
// }
Theorem newThm = d_rules->CNFAddUnit(clauses[0]);
// d_theorems.insert(d_clauseIdNext, clause);
cnf.getCurrentClause().setClauseTheorem(newThm); //by yeting
/*
cout<<"set clause theorem addlemma" << thm << endl;
cout<<"set clause print" ;
cnf.getCurrentClause().print() ;
cout<<endl;
cout<<"set clause id " << d_clauseIdNext << endl;
*/
return l;
} | false | false | false | false | false | 0 |
usb_stor_bulk_transfer_buf(struct us_data *us, unsigned int pipe,
void *buf, unsigned int length, unsigned int *act_len)
{
int result;
usb_stor_dbg(us, "xfer %u bytes\n", length);
/* fill and submit the URB */
usb_fill_bulk_urb(us->current_urb, us->pusb_dev, pipe, buf, length,
usb_stor_blocking_completion, NULL);
result = usb_stor_msg_common(us, 0);
/* store the actual length of the data transferred */
if (act_len)
*act_len = us->current_urb->actual_length;
return interpret_urb_result(us, pipe, length, result,
us->current_urb->actual_length);
} | false | false | false | false | false | 0 |
w5300_probe(struct platform_device *pdev)
{
struct w5300_priv *priv;
struct net_device *ndev;
int err;
ndev = alloc_etherdev(sizeof(*priv));
if (!ndev)
return -ENOMEM;
SET_NETDEV_DEV(ndev, &pdev->dev);
platform_set_drvdata(pdev, ndev);
priv = netdev_priv(ndev);
priv->ndev = ndev;
ndev->netdev_ops = &w5300_netdev_ops;
ndev->ethtool_ops = &w5300_ethtool_ops;
ndev->watchdog_timeo = HZ;
netif_napi_add(ndev, &priv->napi, w5300_napi_poll, 16);
/* This chip doesn't support VLAN packets with normal MTU,
* so disable VLAN for this device.
*/
ndev->features |= NETIF_F_VLAN_CHALLENGED;
err = register_netdev(ndev);
if (err < 0)
goto err_register;
err = w5300_hw_probe(pdev);
if (err < 0)
goto err_hw_probe;
return 0;
err_hw_probe:
unregister_netdev(ndev);
err_register:
free_netdev(ndev);
return err;
} | false | false | false | false | false | 0 |
gth_contact_sheet_theme_unref (GthContactSheetTheme *theme)
{
if (theme == NULL)
return;
theme->ref--;
if (theme->ref > 0)
return;
_g_object_unref (theme->file);
g_free (theme->display_name);
g_free (theme->header_font_name);
g_free (theme->footer_font_name);
g_free (theme->caption_font_name);
g_free (theme);
} | false | false | false | false | false | 0 |
Mat4AddDiagonal(chfac*sf, double *b,int n){
int i,*invp=sf->invp;
double *diag=sf->diag;
for (i=0; i<n; i++){
diag[invp[i]]+=b[i];
}
return 0;
} | false | false | false | false | false | 0 |
next()
{
m_position++;
if (m_position >= m_buffer.size()) {
m_buffer.resize(8192);
int size = m_device->read(m_buffer.data(), m_buffer.size());
if (size < 1) {
throw tr("Unexpectedly reached end of file.");
}
m_buffer.resize(size);
m_position = 0;
QApplication::processEvents();
}
return m_buffer.at(m_position);
} | false | false | false | false | false | 0 |
prfscore(sint n, sint m)
{
sint ix;
lint score;
score = 0.0;
for (ix = 0; ix <= max_aa; ix++) {
score += (profile1[n][ix] * profile2[m][ix]);
}
score += (profile1[n][gap_pos1] * profile2[m][gap_pos1]);
score += (profile1[n][gap_pos2] * profile2[m][gap_pos2]);
return (score / 10);
} | false | false | false | false | false | 0 |
ATL_drefgemv
(
const enum ATLAS_TRANS TRANS,
const int M,
const int N,
const double ALPHA,
const double * A,
const int LDA,
const double * X,
const int INCX,
const double BETA,
double * Y,
const int INCY
)
{
/*
* Purpose
* =======
*
* ATL_drefgemv performs one of the matrix-vector operations
*
* y := alpha * op( A ) * x + beta * y,
*
* where op( X ) is one of
*
* op( X ) = X or op( X ) = X'.
*
* where alpha and beta are scalars, x and y are vectors and op( A ) is
* an m by n matrix.
*
* Arguments
* =========
*
* TRANS (input) const enum ATLAS_TRANS
* On entry, TRANS specifies the operation to be performed as
* follows:
*
* TRANS = AtlasNoTrans y := alpha*A *x + beta*y,
*
* TRANS = AtlasConj y := alpha*A *x + beta*y,
*
* TRANS = AtlasTrans y := alpha*A'*x + beta*y,
*
* TRANS = AtlasConjTrans y := alpha*A'*x + beta*y.
*
* Unchanged on exit.
*
* M (input) const int
* On entry, M specifies the number of rows of the matrix A
* when TRANS = AtlasNoTrans or TRANS = AtlasConj, and the num-
* ber of columns of the matrix A otherwise. M must be at least
* zero. Unchanged on exit.
*
* N (input) const int
* On entry, N specifies the number of columns of the matrix A
* when TRANS = AtlasNoTrans or TRANS = AtlasConj, and the num-
* ber of rows of the matrix A otherwise. N must be at least ze-
* ro. Unchanged on exit.
*
* ALPHA (input) const double
* On entry, ALPHA specifies the scalar alpha. When ALPHA is
* supplied as zero then A and X need not be set on input. Un-
* changed on exit.
*
* A (input) const double *
* On entry, A points to an array of size equal to or greater
* than LDA * ka * sizeof( double ), where ka is n when
* TRANS = AtlasNotrans or TRANS = AtlasConj, and m otherwise.
* Before entry, when TRANS = AtlasNotrans or TRANS = AtlasConj,
* the leading m by n part of the array A must contain the ma-
* trix coefficients, and otherwise the leading n by m part of
* the array A must contain the matrix coefficients. Unchanged
* on exit.
*
* LDA (input) const int
* On entry, LDA specifies the leading dimension of A as decla-
* red in the calling (sub) program. LDA must be at least
* MAX( 1, m ) when TRANS = AtlasNotrans or TRANS = AtlasConj,
* and MAX( 1, n ) otherwise. Unchanged on exit.
*
* X (input) const double *
* On entry, X points to the first entry to be accessed of an
* incremented array of size equal to or greater than
* ( 1 + ( n - 1 ) * abs( INCX ) ) * sizeof( double ),
* that contains the vector x. Unchanged on exit.
*
* INCX (input) const int
* On entry, INCX specifies the increment for the elements of X.
* INCX must not be zero. Unchanged on exit.
*
* BETA (input) const double
* On entry, BETA specifies the scalar beta. When BETA is
* supplied as zero then Y need not be set on input. Unchanged
* on exit.
*
* Y (input/output) double *
* On entry, Y points to the first entry to be accessed of an
* incremented array of size equal to or greater than
* ( 1 + ( m - 1 ) * abs( INCY ) ) * sizeof( double ),
* that contains the vector y. Before entry with BETA non-zero,
* the incremented array Y must contain the vector y. On exit,
* Y is overwritten by the updated vector y.
*
* INCY (input) const int
* On entry, INCY specifies the increment for the elements of Y.
* INCY must not be zero. Unchanged on exit.
*
* ---------------------------------------------------------------------
*/
/* ..
* .. Executable Statements ..
*
*/
if( ( M == 0 ) || ( N == 0 ) ||
( ( ALPHA == ATL_dZERO ) && ( BETA == ATL_dONE ) ) ) return;
if( ALPHA == ATL_dZERO ) { Mdvscal( M, BETA, Y, INCY ); return; }
if( ( TRANS == AtlasNoTrans ) || ( TRANS == AtlasConj ) )
{ ATL_drefgemvN( M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY ); }
else
{ ATL_drefgemvT( M, N, ALPHA, A, LDA, X, INCX, BETA, Y, INCY ); }
/*
* End of ATL_drefgemv
*/
} | false | false | false | false | false | 0 |
vtkJPEGWriteToMemoryEmpty(j_compress_ptr cinfo)
{
// Even if (cinfo->dest->free_in_buffer != 0) we still need to write on the
// new array and not at (arraySize - nbFree)
vtkJPEGWriter *self = vtkJPEGWriter::SafeDownCast(
static_cast<vtkObject *>(cinfo->client_data));
if (self)
{
vtkUnsignedCharArray *uc = self->GetResult();
// we must grow the array
vtkIdType oldSize = uc->GetSize();
uc->Resize(static_cast<vtkIdType>(oldSize + oldSize/2));
// Resize do grow the array but it is not the size we expect
vtkIdType newSize = uc->GetSize();
cinfo->dest->next_output_byte = uc->GetPointer(oldSize);
cinfo->dest->free_in_buffer = static_cast<size_t>(newSize - oldSize);
}
return TRUE;
} | false | false | false | false | false | 0 |
interpret_date_string(const char *date_opt, time_t * const time_p)
{
FILE *date_child_fp;
char date_resp[100];
const char magic[] = "seconds-into-epoch=";
char date_command[100];
int retcode; /* our eventual return code */
int rc; /* local return code */
if (date_opt == NULL) {
warnx(_("No --date option specified."));
return 14;
}
/* prevent overflow - a security risk */
if (strlen(date_opt) > sizeof(date_command) - 50) {
warnx(_("--date argument too long"));
return 13;
}
/* Quotes in date_opt would ruin the date command we construct. */
if (strchr(date_opt, '"') != NULL) {
warnx(_
("The value of the --date option is not a valid date.\n"
"In particular, it contains quotation marks."));
return 12;
}
sprintf(date_command, "date --date=\"%s\" +seconds-into-epoch=%%s",
date_opt);
if (debug)
printf(_("Issuing date command: %s\n"), date_command);
date_child_fp = popen(date_command, "r");
if (date_child_fp == NULL) {
warn(_("Unable to run 'date' program in /bin/sh shell. "
"popen() failed"));
return 10;
}
if (!fgets(date_resp, sizeof(date_resp), date_child_fp))
date_resp[0] = '\0'; /* in case fgets fails */
if (debug)
printf(_("response from date command = %s\n"), date_resp);
if (strncmp(date_resp, magic, sizeof(magic) - 1) != 0) {
warnx(_("The date command issued by %s returned "
"unexpected results.\n"
"The command was:\n %s\n"
"The response was:\n %s"),
program_invocation_short_name, date_command, date_resp);
retcode = 8;
} else {
long seconds_since_epoch;
rc = sscanf(date_resp + sizeof(magic) - 1, "%ld",
&seconds_since_epoch);
if (rc < 1) {
warnx(_("The date command issued by %s returned "
"something other than an integer where the "
"converted time value was expected.\n"
"The command was:\n %s\n"
"The response was:\n %s\n"),
program_invocation_short_name, date_command,
date_resp);
retcode = 6;
} else {
retcode = 0;
*time_p = seconds_since_epoch;
if (debug)
printf(_("date string %s equates to "
"%ld seconds since 1969.\n"),
date_opt, (long)*time_p);
}
}
pclose(date_child_fp);
return retcode;
} | false | false | false | false | false | 0 |