idx
int64 | func
string | target
int64 |
|---|---|---|
329,879
|
_fill32_spans (void *abstract_renderer, int y, int h,
const cairo_half_open_span_t *spans, unsigned num_spans)
{
cairo_image_span_renderer_t *r = abstract_renderer;
if (num_spans == 0)
return CAIRO_STATUS_SUCCESS;
if (likely(h == 1)) {
do {
if (spans[0].coverage) {
int len = spans[1].x - spans[0].x;
if (len > 32) {
pixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride / sizeof(uint32_t), r->bpp,
spans[0].x, y, len, 1, r->u.fill.pixel);
} else {
uint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*y + spans[0].x*4);
while (len-- > 0)
*d++ = r->u.fill.pixel;
}
}
spans++;
} while (--num_spans > 1);
} else {
do {
if (spans[0].coverage) {
if (spans[1].x - spans[0].x > 16) {
pixman_fill ((uint32_t *)r->u.fill.data, r->u.fill.stride / sizeof(uint32_t), r->bpp,
spans[0].x, y, spans[1].x - spans[0].x, h,
r->u.fill.pixel);
} else {
int yy = y, hh = h;
do {
int len = spans[1].x - spans[0].x;
uint32_t *d = (uint32_t*)(r->u.fill.data + r->u.fill.stride*yy + spans[0].x*4);
while (len-- > 0)
*d++ = r->u.fill.pixel;
yy++;
} while (--hh);
}
}
spans++;
} while (--num_spans > 1);
}
return CAIRO_STATUS_SUCCESS;
}
| 0
|
397,645
|
static long ToL(unsigned char *puffer)
{
return (puffer[0] | puffer[1] << 8 | puffer[2] << 16 | puffer[3] << 24);
}
| 0
|
301,377
|
static void vfswrap_rewinddir(vfs_handle_struct *handle, DIR *dirp)
{
START_PROFILE(syscall_rewinddir);
rewinddir(dirp);
END_PROFILE(syscall_rewinddir);
}
| 0
|
212,403
|
find_start_brace(void) // XXX
{
pos_T cursor_save;
pos_T *trypos;
pos_T *pos;
static pos_T pos_copy;
cursor_save = curwin->w_cursor;
while ((trypos = findmatchlimit(NULL, '{', FM_BLOCKSTOP, 0)) != NULL)
{
pos_copy = *trypos; // copy pos_T, next findmatch will change it
trypos = &pos_copy;
curwin->w_cursor = *trypos;
pos = NULL;
// ignore the { if it's in a // or / * * / comment
if ((colnr_T)cin_skip2pos(trypos) == trypos->col
&& (pos = ind_find_start_CORS(NULL)) == NULL) // XXX
break;
if (pos != NULL)
curwin->w_cursor.lnum = pos->lnum;
}
curwin->w_cursor = cursor_save;
return trypos;
}
| 1
|
220,840
|
inline void CopyDimsToDesc(const RuntimeShape& input_shape,
NdArrayDesc<N>* desc_out) {
int desc_stride = 1;
for (int i = N - 1; i >= 0; --i) {
desc_out->extents[i] = input_shape.Dims(i);
desc_out->strides[i] = desc_stride;
desc_stride *= input_shape.Dims(i);
}
}
| 0
|
328,853
|
R_API void r_bin_java_print_double_cp_summary(RBinJavaCPTypeObj *obj) {
ut8 *b = NULL;
if (!obj) {
eprintf ("Attempting to print an invalid RBinJavaCPTypeObj* Double.\n");
return;
}
b = obj->info.cp_double.bytes.raw;
printf ("Double ConstantPool Type (%d) ", obj->metas->ord);
printf (" Offset: 0x%08"PFMT64x "", obj->file_offset);
printf (" High-Bytes = %02x %02x %02x %02x\n", b[0], b[1], b[2], b[3]);
printf (" Low-Bytes = %02x %02x %02x %02x\n", b[4], b[5], b[6], b[7]);
printf (" Double = %f\n", r_bin_java_raw_to_double (obj->info.cp_double.bytes.raw, 0));
}
| 0
|
317,339
|
static int selinux_inode_copy_up(struct dentry *src, struct cred **new)
{
u32 sid;
struct task_security_struct *tsec;
struct cred *new_creds = *new;
if (new_creds == NULL) {
new_creds = prepare_creds();
if (!new_creds)
return -ENOMEM;
}
tsec = selinux_cred(new_creds);
/* Get label from overlay inode and set it in create_sid */
selinux_inode_getsecid(d_inode(src), &sid);
tsec->create_sid = sid;
*new = new_creds;
return 0;
}
| 0
|
402,596
|
handle_is_token_unlocked(context *ctx, struct pollfd *pollfd, socklen_t size)
{
struct msghdr msg;
struct iovec iov;
ssize_t n;
int rc = cms_context_alloc(&ctx->cms);
if (rc < 0) {
send_response(ctx, ctx->backup_cms, pollfd, rc);
return;
}
steal_from_cms(ctx->backup_cms, ctx->cms);
char *buffer = malloc(size);
if (!buffer) {
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"unable to allocate memory: %m");
exit(1);
}
memset(&msg, '\0', sizeof(msg));
iov.iov_base = buffer;
iov.iov_len = size;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
n = recvmsg(pollfd->fd, &msg, MSG_WAITALL);
pesignd_string *tn = (pesignd_string *)buffer;
if (n < (long long)sizeof(tn->size)) {
malformed:
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"unlock-token: invalid data");
ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR,
"possible exploit attempt. closing.");
close(pollfd->fd);
return;
}
n -= sizeof(tn->size);
if ((size_t)n < tn->size)
goto malformed;
n -= tn->size;
if (tn->value[tn->size - 1] != '\0')
goto malformed;
if (n != 0)
goto malformed;
ctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,
"querying token \"%s\"", tn->value);
char *key = (char *)tn->value;
char *tokenname;
tokenname = bsearch(&key, ctx->tokennames, ctx->ntokennames,
sizeof (char *), cmpstringp);
send_response(ctx, ctx->cms, pollfd, tokenname == NULL ? 1 : 0);
ctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE,
"token \"%s\" is %sunlocked", tn->value,
tokenname == NULL ? "not " : "");
free(buffer);
hide_stolen_goods_from_cms(ctx->cms, ctx->backup_cms);
cms_context_fini(ctx->cms);
}
| 0
|
267,845
|
vm_construct_literal_object (vm_frame_ctx_t *frame_ctx_p, /**< frame context */
ecma_value_t lit_value) /**< literal */
{
ecma_compiled_code_t *bytecode_p;
#if JERRY_SNAPSHOT_EXEC
if (JERRY_LIKELY (!(frame_ctx_p->shared_p->bytecode_header_p->status_flags & CBC_CODE_FLAGS_STATIC_FUNCTION)))
{
#endif /* JERRY_SNAPSHOT_EXEC */
bytecode_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_compiled_code_t,
lit_value);
#if JERRY_SNAPSHOT_EXEC
}
else
{
uint8_t *byte_p = ((uint8_t *) frame_ctx_p->shared_p->bytecode_header_p) + lit_value;
bytecode_p = (ecma_compiled_code_t *) byte_p;
}
#endif /* JERRY_SNAPSHOT_EXEC */
#if JERRY_BUILTIN_REGEXP
if (JERRY_UNLIKELY (!CBC_IS_FUNCTION (bytecode_p->status_flags)))
{
ecma_object_t *regexp_obj_p = ecma_op_regexp_alloc (NULL);
if (JERRY_UNLIKELY (regexp_obj_p == NULL))
{
return ECMA_VALUE_ERROR;
}
return ecma_op_create_regexp_from_bytecode (regexp_obj_p, (re_compiled_code_t *) bytecode_p);
}
#else /* !JERRY_BUILTIN_REGEXP */
JERRY_ASSERT (CBC_IS_FUNCTION (bytecode_p->status_flags));
#endif /* JERRY_BUILTIN_REGEXP */
ecma_object_t *func_obj_p;
#if JERRY_ESNEXT
if (JERRY_UNLIKELY (CBC_FUNCTION_IS_ARROW (bytecode_p->status_flags)))
{
func_obj_p = ecma_op_create_arrow_function_object (frame_ctx_p->lex_env_p,
bytecode_p,
frame_ctx_p->this_binding);
}
else
{
func_obj_p = ecma_op_create_any_function_object (frame_ctx_p->lex_env_p, bytecode_p);
}
#else /* !JERRY_ESNEXT */
func_obj_p = ecma_op_create_simple_function_object (frame_ctx_p->lex_env_p, bytecode_p);
#endif /* JERRY_ESNEXT */
return ecma_make_object_value (func_obj_p);
} /* vm_construct_literal_object */
| 0
|
272,350
|
generate_ava(cms_context *cms, SECItem *der, CERTAVA *certava)
{
ava ava;
SECOidData *oid;
void *arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);
if (arena == NULL)
cnreterr(-1, cms, "could not create arena");
void *real_arena = cms->arena;
cms->arena = arena;
oid = SECOID_FindOID(&certava->type);
if (!oid) {
save_port_err() {
PORT_FreeArena(arena, PR_TRUE);
}
cms->arena = real_arena;
cnreterr(-1, cms, "could not find OID");
}
int rc = generate_object_id(cms, &ava.type, oid->offset);
if (rc < 0) {
PORT_FreeArena(arena, PR_TRUE);
cms->arena = real_arena;
return -1;
}
memcpy(&ava.value, &certava->value, sizeof (ava.value));
void *ret;
SECItem tmp;
ret = SEC_ASN1EncodeItem(arena, &tmp, &ava, AVATemplate);
if (ret == NULL) {
save_port_err() {
PORT_FreeArena(arena, PR_TRUE);
}
cms->arena = real_arena;
cnreterr(-1, cms, "could not encode AVA");
}
der->type = tmp.type;
der->len = tmp.len;
der->data = PORT_ArenaAlloc(real_arena, tmp.len);
if (!der->data) {
save_port_err() {
PORT_FreeArena(arena, PR_TRUE);
}
cms->arena = real_arena;
cnreterr(-1, cms, "could not allocate AVA");
}
memcpy(der->data, tmp.data, tmp.len);
PORT_FreeArena(arena, PR_TRUE);
cms->arena = real_arena;
return 0;
}
| 0
|
356,703
|
void Statement::Work_Run(napi_env e, void* data) {
STATEMENT_INIT(RunBaton);
STATEMENT_MUTEX(mtx);
sqlite3_mutex_enter(mtx);
// Make sure that we also reset when there are no parameters.
if (!baton->parameters.size()) {
sqlite3_reset(stmt->_handle);
}
if (stmt->Bind(baton->parameters)) {
stmt->status = sqlite3_step(stmt->_handle);
if (!(stmt->status == SQLITE_ROW || stmt->status == SQLITE_DONE)) {
stmt->message = std::string(sqlite3_errmsg(stmt->db->_handle));
}
else {
baton->inserted_id = sqlite3_last_insert_rowid(stmt->db->_handle);
baton->changes = sqlite3_changes(stmt->db->_handle);
}
}
sqlite3_mutex_leave(mtx);
}
| 0
|
404,720
|
static struct fdtable * alloc_fdtable(unsigned int nr)
{
struct fdtable *fdt;
void *data;
/*
* Figure out how many fds we actually want to support in this fdtable.
* Allocation steps are keyed to the size of the fdarray, since it
* grows far faster than any of the other dynamic data. We try to fit
* the fdarray into comfortable page-tuned chunks: starting at 1024B
* and growing in powers of two from there on.
*/
nr /= (1024 / sizeof(struct file *));
nr = roundup_pow_of_two(nr + 1);
nr *= (1024 / sizeof(struct file *));
/*
* Note that this can drive nr *below* what we had passed if sysctl_nr_open
* had been set lower between the check in expand_files() and here. Deal
* with that in caller, it's cheaper that way.
*
* We make sure that nr remains a multiple of BITS_PER_LONG - otherwise
* bitmaps handling below becomes unpleasant, to put it mildly...
*/
if (unlikely(nr > sysctl_nr_open))
nr = ((sysctl_nr_open - 1) | (BITS_PER_LONG - 1)) + 1;
fdt = kmalloc(sizeof(struct fdtable), GFP_KERNEL_ACCOUNT);
if (!fdt)
goto out;
fdt->max_fds = nr;
data = kvmalloc_array(nr, sizeof(struct file *), GFP_KERNEL_ACCOUNT);
if (!data)
goto out_fdt;
fdt->fd = data;
data = kvmalloc(max_t(size_t,
2 * nr / BITS_PER_BYTE + BITBIT_SIZE(nr), L1_CACHE_BYTES),
GFP_KERNEL_ACCOUNT);
if (!data)
goto out_arr;
fdt->open_fds = data;
data += nr / BITS_PER_BYTE;
fdt->close_on_exec = data;
data += nr / BITS_PER_BYTE;
fdt->full_fds_bits = data;
return fdt;
out_arr:
kvfree(fdt->fd);
out_fdt:
kfree(fdt);
out:
return NULL;
}
| 0
|
255,936
|
Status ShapeRefiner::EvaluateConstantTensorForEdge(
const Node* node, int dst_idx, bool* evaluated, Tensor* result,
InferenceContext* outer_context) {
*evaluated = false;
const Edge* input_edge;
TF_RETURN_IF_ERROR(node->input_edge(dst_idx, &input_edge));
OutputTensor tensor(input_edge->src(), input_edge->src_output());
return EvaluateConstantTensor(
tensor, *this, *ops_registry_, graph_def_version_, evaluated, result,
&graph_runner_, &const_tensor_map_, kMaxTensorSize,
disable_constant_propagation_, outer_context);
}
| 0
|
256,442
|
JANET_CORE_FN(cfun_array_new_filled,
"(array/new-filled count &opt value)",
"Creates a new array of `count` elements, all set to `value`, which defaults to nil. Returns the new array.") {
janet_arity(argc, 1, 2);
int32_t count = janet_getinteger(argv, 0);
if (count < 0) janet_panic("expected positive integer");
Janet x = (argc == 2) ? argv[1] : janet_wrap_nil();
JanetArray *array = janet_array(count);
for (int32_t i = 0; i < count; i++) {
array->data[i] = x;
}
array->count = count;
return janet_wrap_array(array);
}
| 0
|
223,090
|
static size_t PCLPackbitsCompressImage(const size_t length,
const unsigned char *pixels,unsigned char *compress_pixels)
{
int
count;
ssize_t
x;
unsigned char
*q;
ssize_t
j;
unsigned char
packbits[128];
/*
Compress pixels with Packbits encoding.
*/
q=compress_pixels;
for (x=(ssize_t) length; x != 0; )
{
switch (x)
{
case 1:
{
x--;
*q++=0;
*q++=(*pixels);
break;
}
case 2:
{
x-=2;
*q++=1;
*q++=(*pixels);
*q++=pixels[1];
break;
}
case 3:
{
x-=3;
if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
{
*q++=(unsigned char) ((256-3)+1);
*q++=(*pixels);
break;
}
*q++=2;
*q++=(*pixels);
*q++=pixels[1];
*q++=pixels[2];
break;
}
default:
{
if ((*pixels == *(pixels+1)) && (*(pixels+1) == *(pixels+2)))
{
/*
Packed run.
*/
count=3;
while (((ssize_t) count < x) && (*pixels == *(pixels+count)))
{
count++;
if (count >= 127)
break;
}
x-=count;
*q++=(unsigned char) ((256-count)+1);
*q++=(*pixels);
pixels+=count;
break;
}
/*
Literal run.
*/
count=0;
while ((*(pixels+count) != *(pixels+count+1)) ||
(*(pixels+count+1) != *(pixels+count+2)))
{
packbits[count+1]=pixels[count];
count++;
if (((ssize_t) count >= (x-3)) || (count >= 127))
break;
}
x-=count;
*packbits=(unsigned char) (count-1);
for (j=0; j <= (ssize_t) count; j++)
*q++=packbits[j];
pixels+=count;
break;
}
}
}
*q++=128; /* EOD marker */
return((size_t) (q-compress_pixels));
}
| 0
|
455,328
|
glob_testdir (dir, flags)
char *dir;
int flags;
{
struct stat finfo;
int r;
/*itrace("glob_testdir: testing %s" flags = %d, dir, flags);*/
#if defined (HAVE_LSTAT)
r = (flags & GX_ALLDIRS) ? lstat (dir, &finfo) : stat (dir, &finfo);
#else
r = stat (dir, &finfo);
#endif
if (r < 0)
return (-1);
#if defined (S_ISLNK)
if (S_ISLNK (finfo.st_mode))
return (-2);
#endif
if (S_ISDIR (finfo.st_mode) == 0)
return (-1);
return (0);
}
| 0
|
404,725
|
void fd_install(unsigned int fd, struct file *file)
{
struct files_struct *files = current->files;
struct fdtable *fdt;
rcu_read_lock_sched();
if (unlikely(files->resize_in_progress)) {
rcu_read_unlock_sched();
spin_lock(&files->file_lock);
fdt = files_fdtable(files);
BUG_ON(fdt->fd[fd] != NULL);
rcu_assign_pointer(fdt->fd[fd], file);
spin_unlock(&files->file_lock);
return;
}
/* coupled with smp_wmb() in expand_fdtable() */
smp_rmb();
fdt = rcu_dereference_sched(files->fdt);
BUG_ON(fdt->fd[fd] != NULL);
rcu_assign_pointer(fdt->fd[fd], file);
rcu_read_unlock_sched();
}
| 0
|
366,268
|
struct ns_common *from_mnt_ns(struct mnt_namespace *mnt)
{
return &mnt->ns;
}
| 0
|
247,136
|
struct _gf_ft_mgr *gf_filter_get_font_manager(GF_Filter *filter)
{
if (!filter) return NULL;
return gf_fs_get_font_manager(filter->session);
}
| 0
|
454,756
|
static void ismt_mstr_reg_dump(struct ismt_priv *priv)
{
struct device *dev = &priv->pci_dev->dev;
dev_dbg(dev, "Dump of the iSMT Master Registers\n");
dev_dbg(dev, " MDBA..... : (0x%p)=0x%016llX\n",
priv->smba + ISMT_MSTR_MDBA,
(long long unsigned int)readq(priv->smba + ISMT_MSTR_MDBA));
dev_dbg(dev, " MCTRL.... : (0x%p)=0x%X\n",
priv->smba + ISMT_MSTR_MCTRL,
readl(priv->smba + ISMT_MSTR_MCTRL));
dev_dbg(dev, " MSTS..... : (0x%p)=0x%X\n",
priv->smba + ISMT_MSTR_MSTS,
readl(priv->smba + ISMT_MSTR_MSTS));
dev_dbg(dev, " MDS...... : (0x%p)=0x%X\n",
priv->smba + ISMT_MSTR_MDS,
readl(priv->smba + ISMT_MSTR_MDS));
dev_dbg(dev, " RPOLICY.. : (0x%p)=0x%X\n",
priv->smba + ISMT_MSTR_RPOLICY,
readl(priv->smba + ISMT_MSTR_RPOLICY));
dev_dbg(dev, " SPGT..... : (0x%p)=0x%X\n",
priv->smba + ISMT_SPGT,
readl(priv->smba + ISMT_SPGT));
}
| 0
|
369,425
|
static void io_eventfd_signal(struct io_ring_ctx *ctx)
{
struct io_ev_fd *ev_fd;
rcu_read_lock();
/*
* rcu_dereference ctx->io_ev_fd once and use it for both for checking
* and eventfd_signal
*/
ev_fd = rcu_dereference(ctx->io_ev_fd);
/*
* Check again if ev_fd exists incase an io_eventfd_unregister call
* completed between the NULL check of ctx->io_ev_fd at the start of
* the function and rcu_read_lock.
*/
if (unlikely(!ev_fd))
goto out;
if (READ_ONCE(ctx->rings->cq_flags) & IORING_CQ_EVENTFD_DISABLED)
goto out;
if (!ev_fd->eventfd_async || io_wq_current_is_worker())
eventfd_signal(ev_fd->cq_ev_fd, 1);
out:
rcu_read_unlock();
}
| 0
|
139,242
|
void OverlayWindowViews::SetPictureInPictureCustomControls(
const std::vector<blink::PictureInPictureControlInfo>& controls) {
first_custom_controls_view_.reset();
second_custom_controls_view_.reset();
if (controls.size() > 0)
CreateCustomControl(first_custom_controls_view_, controls[0],
ControlPosition::kLeft);
if (controls.size() > 1)
CreateCustomControl(second_custom_controls_view_, controls[1],
ControlPosition::kRight);
}
| 0
|
436,159
|
static int io_uring_alloc_task_context(struct task_struct *task,
struct io_ring_ctx *ctx)
{
struct io_uring_task *tctx;
int ret;
tctx = kzalloc(sizeof(*tctx), GFP_KERNEL);
if (unlikely(!tctx))
return -ENOMEM;
ret = percpu_counter_init(&tctx->inflight, 0, GFP_KERNEL);
if (unlikely(ret)) {
kfree(tctx);
return ret;
}
tctx->io_wq = io_init_wq_offload(ctx, task);
if (IS_ERR(tctx->io_wq)) {
ret = PTR_ERR(tctx->io_wq);
percpu_counter_destroy(&tctx->inflight);
kfree(tctx);
return ret;
}
xa_init(&tctx->xa);
init_waitqueue_head(&tctx->wait);
atomic_set(&tctx->in_idle, 0);
atomic_set(&tctx->inflight_tracked, 0);
task->io_uring = tctx;
spin_lock_init(&tctx->task_lock);
INIT_WQ_LIST(&tctx->task_list);
init_task_work(&tctx->task_work, tctx_task_work);
return 0;
| 0
|
245,720
|
static int strip_return_port (char *host)
{
char *ptr1;
char *ptr2;
int port;
ptr1 = strrchr (host, ':');
if (ptr1 == NULL)
return 0;
/* Check for IPv6 style literals */
ptr2 = strchr (ptr1, ']');
if (ptr2 != NULL)
return 0;
*ptr1++ = '\0';
if (sscanf (ptr1, "%d", &port) != 1) /* one conversion required */
return 0;
return port;
}
| 0
|
282,976
|
LJ_NOINLINE void lj_err_callermsg(lua_State *L, const char *msg)
{
TValue *frame = L->base-1;
TValue *pframe = NULL;
if (frame_islua(frame)) {
pframe = frame_prevl(frame);
} else if (frame_iscont(frame)) {
#if LJ_HASFFI
if ((frame-1)->u32.lo == LJ_CONT_FFI_CALLBACK) {
pframe = frame;
frame = NULL;
} else
#endif
{
pframe = frame_prevd(frame);
#if LJ_HASFFI
/* Remove frame for FFI metamethods. */
if (frame_func(frame)->c.ffid >= FF_ffi_meta___index &&
frame_func(frame)->c.ffid <= FF_ffi_meta___tostring) {
L->base = pframe+1;
L->top = frame;
setcframe_pc(cframe_raw(L->cframe), frame_contpc(frame));
}
#endif
}
}
lj_debug_addloc(L, msg, pframe, frame);
lj_err_run(L);
}
| 0
|
195,067
|
StatusOr<FullTypeDef> SpecializeType(const AttrSlice& attrs,
const OpDef& op_def) {
FullTypeDef ft;
ft.set_type_id(TFT_PRODUCT);
for (int i = 0; i < op_def.output_arg_size(); i++) {
auto* t = ft.add_args();
*t = op_def.output_arg(i).experimental_full_type();
// Resolve dependent types. The convention for op registrations is to use
// attributes as type variables.
// See https://www.tensorflow.org/guide/create_op#type_polymorphism.
// Once the op signature can be defined entirely in FullType, this
// convention can be deprecated.
//
// Note: While this code performs some basic verifications, it generally
// assumes consistent op defs and attributes. If more complete
// verifications are needed, they should be done by separately, and in a
// way that can be reused for type inference.
for (int j = 0; j < t->args_size(); j++) {
auto* arg = t->mutable_args(i);
if (arg->type_id() == TFT_VAR) {
const auto* attr = attrs.Find(arg->s());
DCHECK(attr != nullptr);
if (attr->value_case() == AttrValue::kList) {
const auto& attr_list = attr->list();
arg->set_type_id(TFT_PRODUCT);
for (int i = 0; i < attr_list.type_size(); i++) {
map_dtype_to_tensor(attr_list.type(i), arg->add_args());
}
} else if (attr->value_case() == AttrValue::kType) {
map_dtype_to_tensor(attr->type(), arg);
} else {
return Status(error::UNIMPLEMENTED,
absl::StrCat("unknown attribute type",
attrs.DebugString(), " key=", arg->s()));
}
arg->clear_s();
}
}
}
return ft;
}
| 1
|
312,508
|
vgr_qflist_valid(
win_T *wp,
qf_info_T *qi,
int_u qfid,
char_u *title)
{
// Verify that the quickfix/location list was not freed by an autocmd
if (!qflist_valid(wp, qfid))
{
if (wp != NULL)
{
// An autocmd has freed the location list.
emsg(_(e_current_location_list_was_changed));
return FALSE;
}
else
{
// Quickfix list is not found, create a new one.
qf_new_list(qi, title);
return TRUE;
}
}
if (qf_restore_list(qi, qfid) == FAIL)
return FALSE;
return TRUE;
}
| 0
|
244,041
|
GF_Err saio_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_SampleAuxiliaryInfoOffsetBox *ptr = (GF_SampleAuxiliaryInfoOffsetBox *)s;
if (ptr->flags & 1) {
ISOM_DECREASE_SIZE(ptr, 8);
ptr->aux_info_type = gf_bs_read_u32(bs);
ptr->aux_info_type_parameter = gf_bs_read_u32(bs);
}
ISOM_DECREASE_SIZE(ptr, 4);
ptr->entry_count = gf_bs_read_u32(bs);
if (ptr->entry_count) {
u32 i;
if (ptr->size / (ptr->version == 0 ? 4 : 8) < ptr->entry_count || (u64)ptr->entry_count > (u64)SIZE_MAX/sizeof(u64))
return GF_ISOM_INVALID_FILE;
ptr->offsets = gf_malloc(sizeof(u64)*ptr->entry_count);
if (!ptr->offsets)
return GF_OUT_OF_MEM;
ptr->entry_alloc = ptr->entry_count;
if (ptr->version==0) {
ISOM_DECREASE_SIZE(ptr, 4*ptr->entry_count);
for (i=0; i<ptr->entry_count; i++)
ptr->offsets[i] = gf_bs_read_u32(bs);
} else {
ISOM_DECREASE_SIZE(ptr, 8*ptr->entry_count);
for (i=0; i<ptr->entry_count; i++)
ptr->offsets[i] = gf_bs_read_u64(bs);
}
}
return GF_OK;
}
| 0
|
442,805
|
static void main_free(void)
{
curl_global_cleanup();
#if defined(CURL_DOES_CONVERSIONS) && defined(HAVE_ICONV)
/* close iconv conversion descriptor */
if(inbound_cd != (iconv_t)-1)
iconv_close(inbound_cd);
if(outbound_cd != (iconv_t)-1)
iconv_close(outbound_cd);
#endif /* CURL_DOES_CONVERSIONS && HAVE_ICONV */
}
| 0
|
512,349
|
Field *create_table_field_from_handler(TABLE *table)
{
const Type_handler *h= type_handler();
return h->make_and_init_table_field(&name, Record_addr(maybe_null),
*this, table);
}
| 0
|
329,938
|
composite_traps (void *_dst,
cairo_operator_t op,
cairo_surface_t *abstract_src,
int src_x,
int src_y,
int dst_x,
int dst_y,
const cairo_rectangle_int_t *extents,
cairo_antialias_t antialias,
cairo_traps_t *traps)
{
cairo_image_surface_t *dst = (cairo_image_surface_t *) _dst;
cairo_image_source_t *src = (cairo_image_source_t *) abstract_src;
cairo_int_status_t status;
pixman_image_t *mask;
pixman_format_code_t format;
TRACE ((stderr, "%s\n", __FUNCTION__));
/* pixman doesn't eliminate self-intersecting trapezoids/edges */
status = _cairo_bentley_ottmann_tessellate_traps (traps,
CAIRO_FILL_RULE_WINDING);
if (status != CAIRO_INT_STATUS_SUCCESS)
return status;
/* Special case adding trapezoids onto a mask surface; we want to avoid
* creating an intermediate temporary mask unnecessarily.
*
* We make the assumption here that the portion of the trapezoids
* contained within the surface is bounded by [dst_x,dst_y,width,height];
* the Cairo core code passes bounds based on the trapezoid extents.
*/
format = antialias == CAIRO_ANTIALIAS_NONE ? PIXMAN_a1 : PIXMAN_a8;
if (dst->pixman_format == format &&
(abstract_src == NULL ||
(op == CAIRO_OPERATOR_ADD && src->is_opaque_solid)))
{
_pixman_image_add_traps (dst->pixman_image, dst_x, dst_y, traps);
return CAIRO_STATUS_SUCCESS;
}
mask = pixman_image_create_bits (format,
extents->width, extents->height,
NULL, 0);
if (unlikely (mask == NULL))
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
_pixman_image_add_traps (mask, extents->x, extents->y, traps);
pixman_image_composite32 (_pixman_operator (op),
src->pixman_image, mask, dst->pixman_image,
extents->x + src_x, extents->y + src_y,
0, 0,
extents->x - dst_x, extents->y - dst_y,
extents->width, extents->height);
pixman_image_unref (mask);
return CAIRO_STATUS_SUCCESS;
}
| 0
|
405,326
|
static unsigned int xfrm_mtu(const struct dst_entry *dst)
{
unsigned int mtu = dst_metric_raw(dst, RTAX_MTU);
return mtu ? : dst_mtu(xfrm_dst_path(dst));
}
| 0
|
462,273
|
PJ_DEF(pj_status_t) pj_stun_sockaddr_attr_init( pj_stun_sockaddr_attr *attr,
int attr_type,
pj_bool_t xor_ed,
const pj_sockaddr_t *addr,
unsigned addr_len)
{
unsigned attr_len;
PJ_ASSERT_RETURN(attr && addr_len && addr, PJ_EINVAL);
PJ_ASSERT_RETURN(addr_len == sizeof(pj_sockaddr_in) ||
addr_len == sizeof(pj_sockaddr_in6), PJ_EINVAL);
attr_len = pj_sockaddr_get_addr_len(addr) + 4;
INIT_ATTR(attr, attr_type, attr_len);
pj_memcpy(&attr->sockaddr, addr, addr_len);
attr->xor_ed = xor_ed;
return PJ_SUCCESS;
}
| 0
|
289,288
|
static int snd_pcm_oss_period_size(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *oss_params,
struct snd_pcm_hw_params *slave_params)
{
ssize_t s;
ssize_t oss_buffer_size;
ssize_t oss_period_size, oss_periods;
ssize_t min_period_size, max_period_size;
struct snd_pcm_runtime *runtime = substream->runtime;
size_t oss_frame_size;
oss_frame_size = snd_pcm_format_physical_width(params_format(oss_params)) *
params_channels(oss_params) / 8;
oss_buffer_size = snd_pcm_hw_param_value_max(slave_params,
SNDRV_PCM_HW_PARAM_BUFFER_SIZE,
NULL);
if (oss_buffer_size <= 0)
return -EINVAL;
oss_buffer_size = snd_pcm_plug_client_size(substream,
oss_buffer_size * oss_frame_size);
if (oss_buffer_size <= 0)
return -EINVAL;
oss_buffer_size = rounddown_pow_of_two(oss_buffer_size);
if (atomic_read(&substream->mmap_count)) {
if (oss_buffer_size > runtime->oss.mmap_bytes)
oss_buffer_size = runtime->oss.mmap_bytes;
}
if (substream->oss.setup.period_size > 16)
oss_period_size = substream->oss.setup.period_size;
else if (runtime->oss.fragshift) {
oss_period_size = 1 << runtime->oss.fragshift;
if (oss_period_size > oss_buffer_size / 2)
oss_period_size = oss_buffer_size / 2;
} else {
int sd;
size_t bytes_per_sec = params_rate(oss_params) * snd_pcm_format_physical_width(params_format(oss_params)) * params_channels(oss_params) / 8;
oss_period_size = oss_buffer_size;
do {
oss_period_size /= 2;
} while (oss_period_size > bytes_per_sec);
if (runtime->oss.subdivision == 0) {
sd = 4;
if (oss_period_size / sd > 4096)
sd *= 2;
if (oss_period_size / sd < 4096)
sd = 1;
} else
sd = runtime->oss.subdivision;
oss_period_size /= sd;
if (oss_period_size < 16)
oss_period_size = 16;
}
min_period_size = snd_pcm_plug_client_size(substream,
snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
if (min_period_size > 0) {
min_period_size *= oss_frame_size;
min_period_size = roundup_pow_of_two(min_period_size);
if (oss_period_size < min_period_size)
oss_period_size = min_period_size;
}
max_period_size = snd_pcm_plug_client_size(substream,
snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, NULL));
if (max_period_size > 0) {
max_period_size *= oss_frame_size;
max_period_size = rounddown_pow_of_two(max_period_size);
if (oss_period_size > max_period_size)
oss_period_size = max_period_size;
}
oss_periods = oss_buffer_size / oss_period_size;
if (substream->oss.setup.periods > 1)
oss_periods = substream->oss.setup.periods;
s = snd_pcm_hw_param_value_max(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL);
if (s > 0 && runtime->oss.maxfrags && s > runtime->oss.maxfrags)
s = runtime->oss.maxfrags;
if (oss_periods > s)
oss_periods = s;
s = snd_pcm_hw_param_value_min(slave_params, SNDRV_PCM_HW_PARAM_PERIODS, NULL);
if (s < 2)
s = 2;
if (oss_periods < s)
oss_periods = s;
while (oss_period_size * oss_periods > oss_buffer_size)
oss_period_size /= 2;
if (oss_period_size < 16)
return -EINVAL;
/* don't allocate too large period; 1MB period must be enough */
if (oss_period_size > 1024 * 1024)
return -ENOMEM;
runtime->oss.period_bytes = oss_period_size;
runtime->oss.period_frames = 1;
runtime->oss.periods = oss_periods;
return 0;
}
| 0
|
417,480
|
virNodeDeviceDefFormat(const virNodeDeviceDef *def)
{
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
virNodeDevCapsDefPtr caps;
size_t i = 0;
virBufferAddLit(&buf, "<device>\n");
virBufferAdjustIndent(&buf, 2);
virBufferEscapeString(&buf, "<name>%s</name>\n", def->name);
virBufferEscapeString(&buf, "<path>%s</path>\n", def->sysfs_path);
if (def->devnode)
virBufferEscapeString(&buf, "<devnode type='dev'>%s</devnode>\n",
def->devnode);
if (def->devlinks) {
for (i = 0; def->devlinks[i]; i++)
virBufferEscapeString(&buf, "<devnode type='link'>%s</devnode>\n",
def->devlinks[i]);
}
if (def->parent)
virBufferEscapeString(&buf, "<parent>%s</parent>\n", def->parent);
if (def->driver) {
virBufferAddLit(&buf, "<driver>\n");
virBufferAdjustIndent(&buf, 2);
virBufferEscapeString(&buf, "<name>%s</name>\n", def->driver);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</driver>\n");
}
for (caps = def->caps; caps; caps = caps->next) {
virNodeDevCapDataPtr data = &caps->data;
virBufferAsprintf(&buf, "<capability type='%s'>\n",
virNodeDevCapTypeToString(caps->data.type));
virBufferAdjustIndent(&buf, 2);
switch (caps->data.type) {
case VIR_NODE_DEV_CAP_SYSTEM:
virNodeDeviceCapSystemDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_PCI_DEV:
virNodeDeviceCapPCIDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_USB_DEV:
virNodeDeviceCapUSBDevDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_USB_INTERFACE:
virNodeDeviceCapUSBInterfaceDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_NET:
virNodeDeviceCapNetDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_SCSI_HOST:
virNodeDeviceCapSCSIHostDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_SCSI_TARGET:
virBufferEscapeString(&buf, "<target>%s</target>\n",
data->scsi_target.name);
if (data->scsi_target.flags & VIR_NODE_DEV_CAP_FLAG_FC_RPORT) {
virBufferAddLit(&buf, "<capability type='fc_remote_port'>\n");
virBufferAdjustIndent(&buf, 2);
virBufferAsprintf(&buf, "<rport>%s</rport>\n",
data->scsi_target.rport);
virBufferAsprintf(&buf, "<wwpn>%s</wwpn>\n",
data->scsi_target.wwpn);
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</capability>\n");
}
break;
case VIR_NODE_DEV_CAP_SCSI:
virNodeDeviceCapSCSIDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_STORAGE:
virNodeDeviceCapStorageDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_SCSI_GENERIC:
virBufferEscapeString(&buf, "<char>%s</char>\n",
data->sg.path);
break;
case VIR_NODE_DEV_CAP_DRM:
virBufferEscapeString(&buf, "<type>%s</type>\n", virNodeDevDRMTypeToString(data->drm.type));
break;
case VIR_NODE_DEV_CAP_MDEV:
virNodeDeviceCapMdevDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_CCW_DEV:
case VIR_NODE_DEV_CAP_CSS_DEV:
virNodeDeviceCapCCWDefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_VDPA:
virNodeDeviceCapVDPADefFormat(&buf, data);
break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST:
break;
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</capability>\n");
}
virBufferAdjustIndent(&buf, -2);
virBufferAddLit(&buf, "</device>\n");
return virBufferContentAndReset(&buf);
}
| 0
|
200,320
|
static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
struct files_struct *fsp,
TALLOC_CTX *ctx,
uint32_t function,
uint16_t req_flags, /* Needed for UNICODE ... */
const uint8_t *_in_data,
uint32_t in_len,
uint8_t **_out_data,
uint32_t max_out_len,
uint32_t *out_len)
{
const char *in_data = (const char *)_in_data;
char **out_data = (char **)_out_data;
switch (function) {
case FSCTL_SET_SPARSE:
{
bool set_sparse = true;
NTSTATUS status;
if (in_len >= 1 && in_data[0] == 0) {
set_sparse = false;
}
status = file_set_sparse(handle->conn, fsp, set_sparse);
DEBUG(NT_STATUS_IS_OK(status) ? 10 : 9,
("FSCTL_SET_SPARSE: fname[%s] set[%u] - %s\n",
smb_fname_str_dbg(fsp->fsp_name), set_sparse,
nt_errstr(status)));
return status;
}
case FSCTL_CREATE_OR_GET_OBJECT_ID:
{
unsigned char objid[16];
char *return_data = NULL;
/* This should return the object-id on this file.
* I think I'll make this be the inode+dev. JRA.
*/
DEBUG(10,("FSCTL_CREATE_OR_GET_OBJECT_ID: called on %s\n",
fsp_fnum_dbg(fsp)));
*out_len = (max_out_len >= 64) ? 64 : max_out_len;
/* Hmmm, will this cause problems if less data asked for? */
return_data = talloc_array(ctx, char, 64);
if (return_data == NULL) {
return NT_STATUS_NO_MEMORY;
}
/* For backwards compatibility only store the dev/inode. */
push_file_id_16(return_data, &fsp->file_id);
memcpy(return_data+16,create_volume_objectid(fsp->conn,objid),16);
push_file_id_16(return_data+32, &fsp->file_id);
*out_data = return_data;
return NT_STATUS_OK;
}
case FSCTL_GET_REPARSE_POINT:
{
/* Fail it with STATUS_NOT_A_REPARSE_POINT */
DEBUG(10, ("FSCTL_GET_REPARSE_POINT: called on %s. "
"Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
return NT_STATUS_NOT_A_REPARSE_POINT;
}
case FSCTL_SET_REPARSE_POINT:
{
/* Fail it with STATUS_NOT_A_REPARSE_POINT */
DEBUG(10, ("FSCTL_SET_REPARSE_POINT: called on %s. "
"Status: NOT_IMPLEMENTED\n", fsp_fnum_dbg(fsp)));
return NT_STATUS_NOT_A_REPARSE_POINT;
}
case FSCTL_GET_SHADOW_COPY_DATA:
{
/*
* This is called to retrieve the number of Shadow Copies (a.k.a. snapshots)
* and return their volume names. If max_data_count is 16, then it is just
* asking for the number of volumes and length of the combined names.
*
* pdata is the data allocated by our caller, but that uses
* total_data_count (which is 0 in our case) rather than max_data_count.
* Allocate the correct amount and return the pointer to let
* it be deallocated when we return.
*/
struct shadow_copy_data *shadow_data = NULL;
bool labels = False;
uint32 labels_data_count = 0;
uint32 i;
char *cur_pdata = NULL;
if (max_out_len < 16) {
DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) < 16 is invalid!\n",
max_out_len));
return NT_STATUS_INVALID_PARAMETER;
}
if (max_out_len > 16) {
labels = True;
}
shadow_data = talloc_zero(ctx, struct shadow_copy_data);
if (shadow_data == NULL) {
DEBUG(0,("TALLOC_ZERO() failed!\n"));
return NT_STATUS_NO_MEMORY;
}
/*
* Call the VFS routine to actually do the work.
*/
if (SMB_VFS_GET_SHADOW_COPY_DATA(fsp, shadow_data, labels)!=0) {
TALLOC_FREE(shadow_data);
if (errno == ENOSYS) {
DEBUG(5,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, not supported.\n",
fsp->conn->connectpath));
return NT_STATUS_NOT_SUPPORTED;
} else {
DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: connectpath %s, failed.\n",
fsp->conn->connectpath));
return NT_STATUS_UNSUCCESSFUL;
}
}
labels_data_count = (shadow_data->num_volumes * 2 *
sizeof(SHADOW_COPY_LABEL)) + 2;
if (!labels) {
*out_len = 16;
} else {
*out_len = 12 + labels_data_count + 4;
}
if (max_out_len < *out_len) {
DEBUG(0,("FSCTL_GET_SHADOW_COPY_DATA: max_data_count(%u) too small (%u) bytes needed!\n",
max_out_len, *out_len));
TALLOC_FREE(shadow_data);
return NT_STATUS_BUFFER_TOO_SMALL;
}
cur_pdata = talloc_zero_array(ctx, char, *out_len);
if (cur_pdata == NULL) {
TALLOC_FREE(shadow_data);
return NT_STATUS_NO_MEMORY;
}
*out_data = cur_pdata;
/* num_volumes 4 bytes */
SIVAL(cur_pdata, 0, shadow_data->num_volumes);
if (labels) {
/* num_labels 4 bytes */
SIVAL(cur_pdata, 4, shadow_data->num_volumes);
}
/* needed_data_count 4 bytes */
SIVAL(cur_pdata, 8, labels_data_count + 4);
cur_pdata += 12;
DEBUG(10,("FSCTL_GET_SHADOW_COPY_DATA: %u volumes for path[%s].\n",
shadow_data->num_volumes, fsp_str_dbg(fsp)));
if (labels && shadow_data->labels) {
for (i=0; i<shadow_data->num_volumes; i++) {
srvstr_push(cur_pdata, req_flags,
cur_pdata, shadow_data->labels[i],
2 * sizeof(SHADOW_COPY_LABEL),
STR_UNICODE|STR_TERMINATE);
cur_pdata += 2 * sizeof(SHADOW_COPY_LABEL);
DEBUGADD(10,("Label[%u]: '%s'\n",i,shadow_data->labels[i]));
}
}
TALLOC_FREE(shadow_data);
return NT_STATUS_OK;
}
case FSCTL_FIND_FILES_BY_SID:
{
/* pretend this succeeded -
*
* we have to send back a list with all files owned by this SID
*
* but I have to check that --metze
*/
struct dom_sid sid;
uid_t uid;
size_t sid_len;
DEBUG(10, ("FSCTL_FIND_FILES_BY_SID: called on %s\n",
fsp_fnum_dbg(fsp)));
if (in_len < 8) {
/* NT_STATUS_BUFFER_TOO_SMALL maybe? */
return NT_STATUS_INVALID_PARAMETER;
}
sid_len = MIN(in_len - 4,SID_MAX_SIZE);
/* unknown 4 bytes: this is not the length of the sid :-( */
/*unknown = IVAL(pdata,0);*/
if (!sid_parse(in_data + 4, sid_len, &sid)) {
return NT_STATUS_INVALID_PARAMETER;
}
DEBUGADD(10, ("for SID: %s\n", sid_string_dbg(&sid)));
if (!sid_to_uid(&sid, &uid)) {
DEBUG(0,("sid_to_uid: failed, sid[%s] sid_len[%lu]\n",
sid_string_dbg(&sid),
(unsigned long)sid_len));
uid = (-1);
}
/* we can take a look at the find source :-)
*
* find ./ -uid $uid -name '*' is what we need here
*
*
* and send 4bytes len and then NULL terminated unicode strings
* for each file
*
* but I don't know how to deal with the paged results
* (maybe we can hang the result anywhere in the fsp struct)
*
* but I don't know how to deal with the paged results
* (maybe we can hang the result anywhere in the fsp struct)
*
* we don't send all files at once
* and at the next we should *not* start from the beginning,
* so we have to cache the result
*
* --metze
*/
/* this works for now... */
return NT_STATUS_OK;
}
case FSCTL_QUERY_ALLOCATED_RANGES:
{
/* FIXME: This is just a dummy reply, telling that all of the
* file is allocated. MKS cp needs that.
* Adding the real allocated ranges via FIEMAP on Linux
* and SEEK_DATA/SEEK_HOLE on Solaris is needed to make
* this FSCTL correct for sparse files.
*/
NTSTATUS status;
uint64_t offset, length;
char *out_data_tmp = NULL;
if (in_len != 16) {
DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: data_count(%u) != 16 is invalid!\n",
in_len));
return NT_STATUS_INVALID_PARAMETER;
}
if (max_out_len < 16) {
DEBUG(0,("FSCTL_QUERY_ALLOCATED_RANGES: max_out_len (%u) < 16 is invalid!\n",
max_out_len));
return NT_STATUS_INVALID_PARAMETER;
}
offset = BVAL(in_data,0);
length = BVAL(in_data,8);
if (offset + length < offset) {
/* No 64-bit integer wrap. */
return NT_STATUS_INVALID_PARAMETER;
}
/* Shouldn't this be SMB_VFS_STAT ... ? */
status = vfs_stat_fsp(fsp);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
*out_len = 16;
out_data_tmp = talloc_array(ctx, char, *out_len);
if (out_data_tmp == NULL) {
DEBUG(10, ("unable to allocate memory for response\n"));
return NT_STATUS_NO_MEMORY;
}
if (offset > fsp->fsp_name->st.st_ex_size ||
fsp->fsp_name->st.st_ex_size == 0 ||
length == 0) {
memset(out_data_tmp, 0, *out_len);
} else {
uint64_t end = offset + length;
end = MIN(end, fsp->fsp_name->st.st_ex_size);
SBVAL(out_data_tmp, 0, 0);
SBVAL(out_data_tmp, 8, end);
}
*out_data = out_data_tmp;
return NT_STATUS_OK;
}
case FSCTL_IS_VOLUME_DIRTY:
{
DEBUG(10,("FSCTL_IS_VOLUME_DIRTY: called on %s "
"(but remotely not supported)\n", fsp_fnum_dbg(fsp)));
/*
* http://msdn.microsoft.com/en-us/library/cc232128%28PROT.10%29.aspx
* says we have to respond with NT_STATUS_INVALID_PARAMETER
*/
return NT_STATUS_INVALID_PARAMETER;
}
default:
/*
* Only print once ... unfortunately there could be lots of
* different FSCTLs that are called.
*/
if (!vfswrap_logged_ioctl_message) {
vfswrap_logged_ioctl_message = true;
DEBUG(2, ("%s (0x%x): Currently not implemented.\n",
__func__, function));
}
}
return NT_STATUS_NOT_SUPPORTED;
}
| 1
|
225,544
|
void TfLiteFloatArrayFree(TfLiteFloatArray* a) { free(a); }
| 0
|
472,121
|
int cgroup1_get_tree(struct fs_context *fc)
{
struct cgroup_fs_context *ctx = cgroup_fc2context(fc);
int ret;
/* Check if the caller has permission to mount. */
if (!ns_capable(ctx->ns->user_ns, CAP_SYS_ADMIN))
return -EPERM;
cgroup_lock_and_drain_offline(&cgrp_dfl_root.cgrp);
ret = cgroup1_root_to_use(fc);
if (!ret && !percpu_ref_tryget_live(&ctx->root->cgrp.self.refcnt))
ret = 1; /* restart */
mutex_unlock(&cgroup_mutex);
if (!ret)
ret = cgroup_do_get_tree(fc);
if (!ret && percpu_ref_is_dying(&ctx->root->cgrp.self.refcnt)) {
struct super_block *sb = fc->root->d_sb;
dput(fc->root);
deactivate_locked_super(sb);
ret = 1;
}
if (unlikely(ret > 0)) {
msleep(10);
return restart_syscall();
}
return ret;
}
| 0
|
369,859
|
static int proc_exe_link(struct dentry *dentry, struct path *exe_path)
{
struct task_struct *task;
struct mm_struct *mm;
struct file *exe_file;
task = get_proc_task(dentry->d_inode);
if (!task)
return -ENOENT;
mm = get_task_mm(task);
put_task_struct(task);
if (!mm)
return -ENOENT;
exe_file = get_mm_exe_file(mm);
mmput(mm);
if (exe_file) {
*exe_path = exe_file->f_path;
path_get(&exe_file->f_path);
fput(exe_file);
return 0;
} else
return -ENOENT;
}
| 0
|
281,067
|
static struct xfrm_policy *clone_policy(const struct xfrm_policy *old, int dir)
{
struct xfrm_policy *newp = xfrm_policy_alloc(xp_net(old), GFP_ATOMIC);
struct net *net = xp_net(old);
if (newp) {
newp->selector = old->selector;
if (security_xfrm_policy_clone(old->security,
&newp->security)) {
kfree(newp);
return NULL; /* ENOMEM */
}
newp->lft = old->lft;
newp->curlft = old->curlft;
newp->mark = old->mark;
newp->action = old->action;
newp->flags = old->flags;
newp->xfrm_nr = old->xfrm_nr;
newp->index = old->index;
newp->type = old->type;
memcpy(newp->xfrm_vec, old->xfrm_vec,
newp->xfrm_nr*sizeof(struct xfrm_tmpl));
spin_lock_bh(&net->xfrm.xfrm_policy_lock);
xfrm_sk_policy_link(newp, dir);
spin_unlock_bh(&net->xfrm.xfrm_policy_lock);
xfrm_pol_put(newp);
}
return newp;
}
| 0
|
437,678
|
static u32 txclk_tx_s_max_pulse_width(struct cx23885_dev *dev, u32 ns,
u16 *divider)
{
u64 pulse_clocks;
if (ns > IR_MAX_DURATION)
ns = IR_MAX_DURATION;
pulse_clocks = ns_to_pulse_clocks(ns);
*divider = pulse_clocks_to_clock_divider(pulse_clocks);
cx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, *divider);
return (u32) pulse_width_count_to_ns(FIFO_RXTX, *divider);
}
| 0
|
450,322
|
void vnc_zlib_clear(VncState *vs)
{
if (vs->zlib.stream.opaque) {
deflateEnd(&vs->zlib.stream);
}
buffer_free(&vs->zlib.zlib);
}
| 0
|
309,961
|
parse_ti_delay(const char *ti, double *delays)
{
*delays = 0.0;
while (*ti != '\0') {
if (*ti == '\\') {
++ti;
}
if (ti[0] == '$'
&& ti[1] == '<'
&& IsDelay(UChar(ti[2]))) {
int ignored;
const char *last = parse_delay_value(ti + 2, delays, &ignored);
if (*last == '>') {
ti = last;
}
} else {
++ti;
}
}
return ti;
}
| 0
|
299,986
|
static void elo_remove(struct hid_device *hdev)
{
struct elo_priv *priv = hid_get_drvdata(hdev);
usb_put_dev(priv->usbdev);
hid_hw_stop(hdev);
cancel_delayed_work_sync(&priv->work);
kfree(priv);
}
| 0
|
452,387
|
static MagickBooleanType ReadProfile(Image *image,const char *name,
const unsigned char *datum,ssize_t length)
{
MagickBooleanType
status;
StringInfo
*profile;
if (length < 4)
return(MagickFalse);
profile=BlobToStringInfo(datum,(size_t) length);
if (profile == (StringInfo *) NULL)
ThrowBinaryImageException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
status=SetImageProfile(image,name,profile);
profile=DestroyStringInfo(profile);
return(status);
}
| 0
|
256,955
|
static void MapToLabels(const string& subscript, Labels* labels,
absl::flat_hash_map<char, int>* label_mapping) {
for (int i = 0; i < subscript.size(); ++i) {
const char label_char = subscript[i];
if (label_char == '.') {
labels->push_back(kEllipsisLabel);
i += 2; // Skip next 2 characters as well.
continue;
}
if (!label_mapping->contains(label_char)) {
const int next_label = label_mapping->size();
(*label_mapping)[label_char] = next_label;
}
const int mapped_label = (*label_mapping)[label_char];
labels->push_back(mapped_label);
}
}
| 0
|
473,835
|
st_copy(st_table *old_table)
{
st_table *new_table;
st_table_entry *ptr, *entry, *prev, **tail;
st_index_t num_bins = old_table->num_bins;
st_index_t hash_val;
new_table = alloc(st_table);
if (new_table == 0) {
return 0;
}
*new_table = *old_table;
new_table->bins = (st_table_entry**)
Calloc((unsigned)num_bins, sizeof(st_table_entry*));
if (new_table->bins == 0) {
free(new_table);
return 0;
}
if (old_table->entries_packed) {
memcpy(new_table->bins, old_table->bins, sizeof(struct st_table_entry *) * old_table->num_bins);
return new_table;
}
if ((ptr = old_table->head) != 0) {
prev = 0;
tail = &new_table->head;
do {
entry = alloc(st_table_entry);
if (entry == 0) {
st_free_table(new_table);
return 0;
}
*entry = *ptr;
hash_val = entry->hash % num_bins;
entry->next = new_table->bins[hash_val];
new_table->bins[hash_val] = entry;
entry->back = prev;
*tail = prev = entry;
tail = &entry->fore;
} while ((ptr = ptr->fore) != 0);
new_table->tail = prev;
}
return new_table;
}
| 0
|
437,333
|
swap_node(Node* a, Node* b)
{
Node c;
c = *a; *a = *b; *b = c;
if (NODE_TYPE(a) == NODE_STRING) {
StrNode* sn = STR_(a);
if (sn->capa == 0) {
int len = (int )(sn->end - sn->s);
sn->s = sn->buf;
sn->end = sn->s + len;
}
}
if (NODE_TYPE(b) == NODE_STRING) {
StrNode* sn = STR_(b);
if (sn->capa == 0) {
int len = (int )(sn->end - sn->s);
sn->s = sn->buf;
sn->end = sn->s + len;
}
}
}
| 0
|
225,392
|
static char *fourcc2str(unsigned int fourcc, char buf[4])
{
buf[0] = (fourcc >> 0) & 0xFF;
buf[1] = (fourcc >> 8) & 0xFF;
buf[2] = (fourcc >> 16) & 0xFF;
buf[3] = (fourcc >> 24) & 0xFF;
return buf;
}
| 0
|
326,631
|
set_times(struct archive_write_disk *a,
int fd, int mode, const char *name,
time_t atime, long atime_nanos,
time_t birthtime, long birthtime_nanos,
time_t mtime, long mtime_nanos,
time_t cctime, long ctime_nanos)
{
/* Note: set_time doesn't use libarchive return conventions!
* It uses syscall conventions. So 0 here instead of ARCHIVE_OK. */
int r1 = 0, r2 = 0;
#ifdef F_SETTIMES
/*
* on Tru64 try own fcntl first which can restore even the
* ctime, fall back to default code path below if it fails
* or if we are not running as root
*/
if (a->user_uid == 0 &&
set_time_tru64(fd, mode, name,
atime, atime_nanos, mtime,
mtime_nanos, cctime, ctime_nanos) == 0) {
return (ARCHIVE_OK);
}
#else /* Tru64 */
(void)cctime; /* UNUSED */
(void)ctime_nanos; /* UNUSED */
#endif /* Tru64 */
#ifdef HAVE_STRUCT_STAT_ST_BIRTHTIME
/*
* If you have struct stat.st_birthtime, we assume BSD
* birthtime semantics, in which {f,l,}utimes() updates
* birthtime to earliest mtime. So we set the time twice,
* first using the birthtime, then using the mtime. If
* birthtime == mtime, this isn't necessary, so we skip it.
* If birthtime > mtime, then this won't work, so we skip it.
*/
if (birthtime < mtime
|| (birthtime == mtime && birthtime_nanos < mtime_nanos))
r1 = set_time(fd, mode, name,
atime, atime_nanos,
birthtime, birthtime_nanos);
#else
(void)birthtime; /* UNUSED */
(void)birthtime_nanos; /* UNUSED */
#endif
r2 = set_time(fd, mode, name,
atime, atime_nanos,
mtime, mtime_nanos);
if (r1 != 0 || r2 != 0) {
archive_set_error(&a->archive, errno,
"Can't restore time");
return (ARCHIVE_WARN);
}
return (ARCHIVE_OK);
}
| 0
|
369,895
|
static struct dentry *proc_pident_instantiate(struct inode *dir,
struct dentry *dentry, struct task_struct *task, const void *ptr)
{
const struct pid_entry *p = ptr;
struct inode *inode;
struct proc_inode *ei;
struct dentry *error = ERR_PTR(-ENOENT);
inode = proc_pid_make_inode(dir->i_sb, task);
if (!inode)
goto out;
ei = PROC_I(inode);
inode->i_mode = p->mode;
if (S_ISDIR(inode->i_mode))
set_nlink(inode, 2); /* Use getattr to fix if necessary */
if (p->iop)
inode->i_op = p->iop;
if (p->fop)
inode->i_fop = p->fop;
ei->op = p->op;
d_set_d_op(dentry, &pid_dentry_operations);
d_add(dentry, inode);
/* Close the race of the process dying before we return the dentry */
if (pid_revalidate(dentry, NULL))
error = NULL;
out:
return error;
}
| 0
|
261,949
|
njs_string_prototype_substring(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused)
{
int64_t start, end, length;
njs_int_t ret;
njs_value_t *value;
njs_slice_prop_t slice;
njs_string_prop_t string;
ret = njs_string_object_validate(vm, njs_argument(args, 0));
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
length = njs_string_prop(&string, njs_argument(args, 0));
slice.string_length = length;
start = 0;
if (nargs > 1) {
value = njs_argument(args, 1);
if (njs_slow_path(!njs_is_number(value))) {
ret = njs_value_to_integer(vm, value, &start);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
} else {
start = njs_number_to_integer(njs_number(value));
}
if (start < 0) {
start = 0;
} else if (start > length) {
start = length;
}
end = length;
if (nargs > 2) {
value = njs_arg(args, nargs, 2);
if (njs_slow_path(!njs_is_number(value))) {
ret = njs_value_to_integer(vm, value, &end);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
} else {
end = njs_number_to_integer(njs_number(value));
}
if (end < 0) {
end = 0;
} else if (end >= length) {
end = length;
}
}
length = end - start;
if (length < 0) {
length = -length;
start = end;
}
}
slice.start = start;
slice.length = length;
return njs_string_slice(vm, &vm->retval, &string, &slice);
}
| 0
|
224,227
|
static void _delete_submaps_from_bank_tree(RIO *io, RIOBank *bank, RListIter *prio, RIOMap *map) {
RIOSubMap fake_sm;
fake_sm.itv = map->itv;
fake_sm.mapref.id = map->id;
RRBNode *entry = _find_entry_submap_node (bank, &fake_sm);
if (!entry) {
return;
}
RIOSubMap *bd = (RIOSubMap *)entry->data;
while (bd && r_io_submap_overlap (bd, (&fake_sm))) {
// this loop deletes all affected submaps from the rbtree
// and also enqueues them in bank->todo
RRBNode *next = r_rbnode_next (entry);
if (bd->mapref.id == fake_sm.mapref.id) {
r_queue_enqueue (bank->todo, R_NEWCOPY (RIOSubMap, bd));
r_crbtree_delete (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);
}
entry = next;
bd = entry ? (RIOSubMap *)entry->data : NULL;
}
RListIter *iter = prio;
while (!r_queue_is_empty (bank->todo)) {
// now check for each deleted submap if a lower map intersects with it
// and create new submaps accordingly, and fill the gaps
RIOSubMap *sm = r_queue_dequeue (bank->todo);
RListIter *ator = r_list_iter_get_prev (iter);
while (ator) {
map = r_io_map_get_by_ref (io, (RIOMapRef *)ator->data);
ator = r_list_iter_get_prev (ator);
if (!map) {
// if this happens, something is fucked up, and no submap should be inserted
continue;
}
// if the map and sm intersect, the intersecting submap needs to be inserted in the tree
// there are 5 cases to consider here
// 1. no intersection: just continue to the next iteration
// 2. map overlaps sm on both ends: insert submap for map with boundaries of sm
// 3. map overlaps sm on the upper end: insert submap for map accordingly and adjust sm boundaries
// 4. map overlaps sm on the lower end: insert submap for map accordingly and adjust sm boundaries
// 5. sm overlaps sm on both ends: split sm into 2 submaps and enqueue new one in banks->todo; insert submap for map; adjust sm boundaries
if (r_io_submap_to (sm) < r_io_map_from (map) || r_io_submap_from (sm) > r_io_map_to (map)) {
// case 1
continue;
}
RIOMapRef *mapref = _mapref_from_map (map);
bd = r_io_submap_new (io, mapref);
free (mapref);
if (!bd) {
continue;
}
if (r_io_submap_from (sm) >= r_io_map_from (map)) {
// case 4 and 2
r_io_submap_set_from (bd, r_io_submap_from (sm));
r_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);
if (r_io_submap_to (sm) <= r_io_map_to (map)) {
// case 2
r_io_submap_set_to (bd, r_io_submap_to (sm));
break;
}
// case 4
r_io_submap_set_from (sm, r_io_submap_to (bd) + 1);
continue;
}
if (r_io_submap_to (sm) <= r_io_map_to (map)) {
// case 3
// adjust bd upper boundary to avoid overlap with existing submaps
r_io_submap_set_to (bd, r_io_submap_to (sm));
// adjust sm upper boundary to avoid hitting again on sm in further iterations
r_io_submap_set_to (sm, r_io_submap_from (bd) - 1);
r_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);
continue;
}
// case 5 because all other cases are already handled
RIOSubMap *bdsm = R_NEWCOPY (RIOSubMap, sm);
r_io_submap_set_to (sm, r_io_submap_from (bd) - 1);
r_io_submap_set_from (bdsm, r_io_submap_to (bd) + 1);
r_crbtree_insert (bank->submaps, bd, _find_sm_by_from_vaddr_cb, NULL);
r_queue_enqueue (bank->todo, bdsm);
}
free (sm);
}
}
| 0
|
517,454
|
static void do_home_program(HttpResponse res) {
char buf[STRLEN];
boolean_t on = true;
boolean_t header = true;
for (Service_T s = servicelist_conf; s; s = s->next_conf) {
if (s->type != Service_Program)
continue;
if (header) {
StringBuffer_append(res->outputbuffer,
"<table id='header-row'>"
"<tr>"
"<th class='left' class='first'>Program</th>"
"<th class='left'>Status</th>"
"<th class='left'>Output</th>"
"<th class='right'>Last started</th>"
"<th class='right'>Exit value</th>"
"</tr>");
header = false;
}
StringBuffer_append(res->outputbuffer,
"<tr %s>"
"<td class='left'><a href='%s'>%s</a></td>"
"<td class='left'>%s</td>",
on ? "class='stripe'" : "",
s->name, s->name,
get_service_status(HTML, s, buf, sizeof(buf)));
if (! Util_hasServiceStatus(s)) {
StringBuffer_append(res->outputbuffer, "<td class='left'>-</td>");
StringBuffer_append(res->outputbuffer, "<td class='right'>-</td>");
StringBuffer_append(res->outputbuffer, "<td class='right'>-</td>");
} else {
if (s->program->started) {
StringBuffer_append(res->outputbuffer, "<td class='left short'>");
if (StringBuffer_length(s->program->lastOutput)) {
// Print first line only (escape HTML characters if any)
const char *output = StringBuffer_toString(s->program->lastOutput);
for (int i = 0; output[i]; i++) {
if (output[i] == '<')
StringBuffer_append(res->outputbuffer, "<");
else if (output[i] == '>')
StringBuffer_append(res->outputbuffer, ">");
else if (output[i] == '&')
StringBuffer_append(res->outputbuffer, "&");
else if (output[i] == '\r' || output[i] == '\n')
break;
else
StringBuffer_append(res->outputbuffer, "%c", output[i]);
}
} else {
StringBuffer_append(res->outputbuffer, "no output");
}
StringBuffer_append(res->outputbuffer, "</td>");
StringBuffer_append(res->outputbuffer, "<td class='right'>%s</td>", Time_fmt((char[32]){}, 32, "%d %b %Y %H:%M:%S", s->program->started));
StringBuffer_append(res->outputbuffer, "<td class='right'>%d</td>", s->program->exitStatus);
} else {
StringBuffer_append(res->outputbuffer, "<td class='right'>-</td>");
StringBuffer_append(res->outputbuffer, "<td class='right'>Not yet started</td>");
StringBuffer_append(res->outputbuffer, "<td class='right'>-</td>");
}
}
StringBuffer_append(res->outputbuffer, "</tr>");
on = ! on;
}
if (! header)
StringBuffer_append(res->outputbuffer, "</table>");
}
| 0
|
314,758
|
cdf_swap_dir(cdf_directory_t *d)
{
d->d_namelen = CDF_TOLE2(d->d_namelen);
d->d_left_child = CDF_TOLE4((uint32_t)d->d_left_child);
d->d_right_child = CDF_TOLE4((uint32_t)d->d_right_child);
d->d_storage = CDF_TOLE4((uint32_t)d->d_storage);
d->d_storage_uuid[0] = CDF_TOLE8(d->d_storage_uuid[0]);
d->d_storage_uuid[1] = CDF_TOLE8(d->d_storage_uuid[1]);
d->d_flags = CDF_TOLE4(d->d_flags);
d->d_created = CDF_TOLE8((uint64_t)d->d_created);
d->d_modified = CDF_TOLE8((uint64_t)d->d_modified);
d->d_stream_first_sector = CDF_TOLE4((uint32_t)d->d_stream_first_sector);
d->d_size = CDF_TOLE4(d->d_size);
}
| 0
|
301,503
|
spell_suggest_list(
garray_T *gap,
char_u *word,
int maxcount, // maximum nr of suggestions
int need_cap, // 'spellcapcheck' matched
int interactive)
{
suginfo_T sug;
int i;
suggest_T *stp;
char_u *wcopy;
spell_find_suggest(word, 0, &sug, maxcount, FALSE, need_cap, interactive);
// Make room in "gap".
ga_init2(gap, sizeof(char_u *), sug.su_ga.ga_len + 1);
if (ga_grow(gap, sug.su_ga.ga_len) == OK)
{
for (i = 0; i < sug.su_ga.ga_len; ++i)
{
stp = &SUG(sug.su_ga, i);
// The suggested word may replace only part of "word", add the not
// replaced part.
wcopy = alloc(stp->st_wordlen
+ (unsigned)STRLEN(sug.su_badptr + stp->st_orglen) + 1);
if (wcopy == NULL)
break;
STRCPY(wcopy, stp->st_word);
STRCPY(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen);
((char_u **)gap->ga_data)[gap->ga_len++] = wcopy;
}
}
spell_find_cleanup(&sug);
}
| 0
|
508,373
|
find_field_in_view(THD *thd, TABLE_LIST *table_list,
const char *name, uint length,
const char *item_name, Item **ref,
bool register_tree_change)
{
DBUG_ENTER("find_field_in_view");
DBUG_PRINT("enter",
("view: '%s', field name: '%s', item name: '%s', ref %p",
table_list->alias, name, item_name, ref));
Field_iterator_view field_it;
field_it.set(table_list);
Query_arena *arena= 0, backup;
for (; !field_it.end_of_fields(); field_it.next())
{
if (!my_strcasecmp(system_charset_info, field_it.name(), name))
{
// in PS use own arena or data will be freed after prepare
if (register_tree_change &&
thd->stmt_arena->is_stmt_prepare_or_first_stmt_execute())
arena= thd->activate_stmt_arena_if_needed(&backup);
/*
create_item() may, or may not create a new Item, depending on
the column reference. See create_view_field() for details.
*/
Item *item= field_it.create_item(thd);
if (arena)
thd->restore_active_arena(arena, &backup);
if (!item)
DBUG_RETURN(0);
if (!ref)
DBUG_RETURN((Field*) view_ref_found);
/*
*ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to
the replacing item.
We need to set alias on both ref itself and on ref real item.
*/
if (*ref && !(*ref)->is_autogenerated_name)
{
if (register_tree_change)
{
item->set_name_for_rollback(thd, (*ref)->name,
(*ref)->name_length,
system_charset_info);
item->real_item()->set_name_for_rollback(thd, (*ref)->name,
(*ref)->name_length,
system_charset_info);
}
else
{
item->set_name(thd, (*ref)->name, (*ref)->name_length,
system_charset_info);
item->real_item()->set_name(thd, (*ref)->name, (*ref)->name_length,
system_charset_info);
}
}
if (register_tree_change)
thd->change_item_tree(ref, item);
else
*ref= item;
DBUG_RETURN((Field*) view_ref_found);
}
}
DBUG_RETURN(0);
}
| 0
|
500,687
|
static sftp_status_message parse_status_msg(sftp_message msg){
sftp_status_message status;
if (msg->packet_type != SSH_FXP_STATUS) {
ssh_set_error(msg->sftp->session, SSH_FATAL,
"Not a ssh_fxp_status message passed in!");
return NULL;
}
status = malloc(sizeof(struct sftp_status_message_struct));
if (status == NULL) {
ssh_set_error_oom(msg->sftp->session);
return NULL;
}
ZERO_STRUCTP(status);
status->id = msg->id;
if (buffer_get_u32(msg->payload,&status->status) != 4){
SAFE_FREE(status);
ssh_set_error(msg->sftp->session, SSH_FATAL,
"Invalid SSH_FXP_STATUS message");
return NULL;
}
status->error = buffer_get_ssh_string(msg->payload);
status->lang = buffer_get_ssh_string(msg->payload);
if(status->error == NULL || status->lang == NULL){
if(msg->sftp->version >=3){
/* These are mandatory from version 3 */
ssh_string_free(status->error);
/* status->lang never get allocated if something failed */
SAFE_FREE(status);
ssh_set_error(msg->sftp->session, SSH_FATAL,
"Invalid SSH_FXP_STATUS message");
return NULL;
}
}
status->status = ntohl(status->status);
if(status->error)
status->errormsg = ssh_string_to_char(status->error);
else
status->errormsg = strdup("No error message in packet");
if(status->lang)
status->langmsg = ssh_string_to_char(status->lang);
else
status->langmsg = strdup("");
if (status->errormsg == NULL || status->langmsg == NULL) {
ssh_set_error_oom(msg->sftp->session);
status_msg_free(status);
return NULL;
}
return status;
}
| 0
|
432,267
|
void cpu_flush_icache_range(AddressSpace *as, hwaddr start, hwaddr len)
{
}
| 0
|
212,433
|
do_tag(
char_u *tag, // tag (pattern) to jump to
int type,
int count,
int forceit, // :ta with !
int verbose) // print "tag not found" message
{
taggy_T *tagstack = curwin->w_tagstack;
int tagstackidx = curwin->w_tagstackidx;
int tagstacklen = curwin->w_tagstacklen;
int cur_match = 0;
int cur_fnum = curbuf->b_fnum;
int oldtagstackidx = tagstackidx;
int prevtagstackidx = tagstackidx;
int prev_num_matches;
int new_tag = FALSE;
int i;
int ic;
int no_regexp = FALSE;
int error_cur_match = 0;
int save_pos = FALSE;
fmark_T saved_fmark;
#ifdef FEAT_CSCOPE
int jumped_to_tag = FALSE;
#endif
int new_num_matches;
char_u **new_matches;
int use_tagstack;
int skip_msg = FALSE;
char_u *buf_ffname = curbuf->b_ffname; // name to use for
// priority computation
int use_tfu = 1;
char_u *tofree = NULL;
// remember the matches for the last used tag
static int num_matches = 0;
static int max_num_matches = 0; // limit used for match search
static char_u **matches = NULL;
static int flags;
#ifdef FEAT_EVAL
if (tfu_in_use)
{
emsg(_(e_cannot_modify_tag_stack_within_tagfunc));
return FALSE;
}
#endif
#ifdef EXITFREE
if (type == DT_FREE)
{
// remove the list of matches
FreeWild(num_matches, matches);
# ifdef FEAT_CSCOPE
cs_free_tags();
# endif
num_matches = 0;
return FALSE;
}
#endif
if (type == DT_HELP)
{
type = DT_TAG;
no_regexp = TRUE;
use_tfu = 0;
}
prev_num_matches = num_matches;
free_string_option(nofile_fname);
nofile_fname = NULL;
CLEAR_POS(&saved_fmark.mark); // shutup gcc 4.0
saved_fmark.fnum = 0;
/*
* Don't add a tag to the tagstack if 'tagstack' has been reset.
*/
if ((!p_tgst && *tag != NUL))
{
use_tagstack = FALSE;
new_tag = TRUE;
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
tagstack_clear_entry(&ptag_entry);
if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)
goto end_do_tag;
}
#endif
}
else
{
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
use_tagstack = FALSE;
else
#endif
use_tagstack = TRUE;
// new pattern, add to the tag stack
if (*tag != NUL
&& (type == DT_TAG || type == DT_SELECT || type == DT_JUMP
#ifdef FEAT_QUICKFIX
|| type == DT_LTAG
#endif
#ifdef FEAT_CSCOPE
|| type == DT_CSCOPE
#endif
))
{
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
if (ptag_entry.tagname != NULL
&& STRCMP(ptag_entry.tagname, tag) == 0)
{
// Jumping to same tag: keep the current match, so that
// the CursorHold autocommand example works.
cur_match = ptag_entry.cur_match;
cur_fnum = ptag_entry.cur_fnum;
}
else
{
tagstack_clear_entry(&ptag_entry);
if ((ptag_entry.tagname = vim_strsave(tag)) == NULL)
goto end_do_tag;
}
}
else
#endif
{
/*
* If the last used entry is not at the top, delete all tag
* stack entries above it.
*/
while (tagstackidx < tagstacklen)
tagstack_clear_entry(&tagstack[--tagstacklen]);
// if the tagstack is full: remove oldest entry
if (++tagstacklen > TAGSTACKSIZE)
{
tagstacklen = TAGSTACKSIZE;
tagstack_clear_entry(&tagstack[0]);
for (i = 1; i < tagstacklen; ++i)
tagstack[i - 1] = tagstack[i];
--tagstackidx;
}
/*
* put the tag name in the tag stack
*/
if ((tagstack[tagstackidx].tagname = vim_strsave(tag)) == NULL)
{
curwin->w_tagstacklen = tagstacklen - 1;
goto end_do_tag;
}
curwin->w_tagstacklen = tagstacklen;
save_pos = TRUE; // save the cursor position below
}
new_tag = TRUE;
}
else
{
if (
#if defined(FEAT_QUICKFIX)
g_do_tagpreview != 0 ? ptag_entry.tagname == NULL :
#endif
tagstacklen == 0)
{
// empty stack
emsg(_(e_tag_stack_empty));
goto end_do_tag;
}
if (type == DT_POP) // go to older position
{
#ifdef FEAT_FOLDING
int old_KeyTyped = KeyTyped;
#endif
if ((tagstackidx -= count) < 0)
{
emsg(_(e_at_bottom_of_tag_stack));
if (tagstackidx + count == 0)
{
// We did [num]^T from the bottom of the stack
tagstackidx = 0;
goto end_do_tag;
}
// We weren't at the bottom of the stack, so jump all the
// way to the bottom now.
tagstackidx = 0;
}
else if (tagstackidx >= tagstacklen) // count == 0?
{
emsg(_(e_at_top_of_tag_stack));
goto end_do_tag;
}
// Make a copy of the fmark, autocommands may invalidate the
// tagstack before it's used.
saved_fmark = tagstack[tagstackidx].fmark;
if (saved_fmark.fnum != curbuf->b_fnum)
{
/*
* Jump to other file. If this fails (e.g. because the
* file was changed) keep original position in tag stack.
*/
if (buflist_getfile(saved_fmark.fnum, saved_fmark.mark.lnum,
GETF_SETMARK, forceit) == FAIL)
{
tagstackidx = oldtagstackidx; // back to old posn
goto end_do_tag;
}
// An BufReadPost autocommand may jump to the '" mark, but
// we don't what that here.
curwin->w_cursor.lnum = saved_fmark.mark.lnum;
}
else
{
setpcmark();
curwin->w_cursor.lnum = saved_fmark.mark.lnum;
}
curwin->w_cursor.col = saved_fmark.mark.col;
curwin->w_set_curswant = TRUE;
check_cursor();
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_TAG) && old_KeyTyped)
foldOpenCursor();
#endif
// remove the old list of matches
FreeWild(num_matches, matches);
#ifdef FEAT_CSCOPE
cs_free_tags();
#endif
num_matches = 0;
tag_freematch();
goto end_do_tag;
}
if (type == DT_TAG
#if defined(FEAT_QUICKFIX)
|| type == DT_LTAG
#endif
)
{
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
cur_match = ptag_entry.cur_match;
cur_fnum = ptag_entry.cur_fnum;
}
else
#endif
{
// ":tag" (no argument): go to newer pattern
save_pos = TRUE; // save the cursor position below
if ((tagstackidx += count - 1) >= tagstacklen)
{
/*
* Beyond the last one, just give an error message and
* go to the last one. Don't store the cursor
* position.
*/
tagstackidx = tagstacklen - 1;
emsg(_(e_at_top_of_tag_stack));
save_pos = FALSE;
}
else if (tagstackidx < 0) // must have been count == 0
{
emsg(_(e_at_bottom_of_tag_stack));
tagstackidx = 0;
goto end_do_tag;
}
cur_match = tagstack[tagstackidx].cur_match;
cur_fnum = tagstack[tagstackidx].cur_fnum;
}
new_tag = TRUE;
}
else // go to other matching tag
{
// Save index for when selection is cancelled.
prevtagstackidx = tagstackidx;
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
cur_match = ptag_entry.cur_match;
cur_fnum = ptag_entry.cur_fnum;
}
else
#endif
{
if (--tagstackidx < 0)
tagstackidx = 0;
cur_match = tagstack[tagstackidx].cur_match;
cur_fnum = tagstack[tagstackidx].cur_fnum;
}
switch (type)
{
case DT_FIRST: cur_match = count - 1; break;
case DT_SELECT:
case DT_JUMP:
#ifdef FEAT_CSCOPE
case DT_CSCOPE:
#endif
case DT_LAST: cur_match = MAXCOL - 1; break;
case DT_NEXT: cur_match += count; break;
case DT_PREV: cur_match -= count; break;
}
if (cur_match >= MAXCOL)
cur_match = MAXCOL - 1;
else if (cur_match < 0)
{
emsg(_(e_cannot_go_before_first_matching_tag));
skip_msg = TRUE;
cur_match = 0;
cur_fnum = curbuf->b_fnum;
}
}
}
#if defined(FEAT_QUICKFIX)
if (g_do_tagpreview != 0)
{
if (type != DT_SELECT && type != DT_JUMP)
{
ptag_entry.cur_match = cur_match;
ptag_entry.cur_fnum = cur_fnum;
}
}
else
#endif
{
/*
* For ":tag [arg]" or ":tselect" remember position before the jump.
*/
saved_fmark = tagstack[tagstackidx].fmark;
if (save_pos)
{
tagstack[tagstackidx].fmark.mark = curwin->w_cursor;
tagstack[tagstackidx].fmark.fnum = curbuf->b_fnum;
}
// Curwin will change in the call to jumpto_tag() if ":stag" was
// used or an autocommand jumps to another window; store value of
// tagstackidx now.
curwin->w_tagstackidx = tagstackidx;
if (type != DT_SELECT && type != DT_JUMP)
{
curwin->w_tagstack[tagstackidx].cur_match = cur_match;
curwin->w_tagstack[tagstackidx].cur_fnum = cur_fnum;
}
}
}
// When not using the current buffer get the name of buffer "cur_fnum".
// Makes sure that the tag order doesn't change when using a remembered
// position for "cur_match".
if (cur_fnum != curbuf->b_fnum)
{
buf_T *buf = buflist_findnr(cur_fnum);
if (buf != NULL)
buf_ffname = buf->b_ffname;
}
/*
* Repeat searching for tags, when a file has not been found.
*/
for (;;)
{
int other_name;
char_u *name;
/*
* When desired match not found yet, try to find it (and others).
*/
if (use_tagstack)
{
// make a copy, the tagstack may change in 'tagfunc'
name = vim_strsave(tagstack[tagstackidx].tagname);
vim_free(tofree);
tofree = name;
}
#if defined(FEAT_QUICKFIX)
else if (g_do_tagpreview != 0)
name = ptag_entry.tagname;
#endif
else
name = tag;
other_name = (tagmatchname == NULL || STRCMP(tagmatchname, name) != 0);
if (new_tag
|| (cur_match >= num_matches && max_num_matches != MAXCOL)
|| other_name)
{
if (other_name)
{
vim_free(tagmatchname);
tagmatchname = vim_strsave(name);
}
if (type == DT_SELECT || type == DT_JUMP
#if defined(FEAT_QUICKFIX)
|| type == DT_LTAG
#endif
)
cur_match = MAXCOL - 1;
if (type == DT_TAG)
max_num_matches = MAXCOL;
else
max_num_matches = cur_match + 1;
// when the argument starts with '/', use it as a regexp
if (!no_regexp && *name == '/')
{
flags = TAG_REGEXP;
++name;
}
else
flags = TAG_NOIC;
#ifdef FEAT_CSCOPE
if (type == DT_CSCOPE)
flags = TAG_CSCOPE;
#endif
if (verbose)
flags |= TAG_VERBOSE;
if (!use_tfu)
flags |= TAG_NO_TAGFUNC;
if (find_tags(name, &new_num_matches, &new_matches, flags,
max_num_matches, buf_ffname) == OK
&& new_num_matches < max_num_matches)
max_num_matches = MAXCOL; // If less than max_num_matches
// found: all matches found.
// If there already were some matches for the same name, move them
// to the start. Avoids that the order changes when using
// ":tnext" and jumping to another file.
if (!new_tag && !other_name)
{
int j, k;
int idx = 0;
tagptrs_T tagp, tagp2;
// Find the position of each old match in the new list. Need
// to use parse_match() to find the tag line.
for (j = 0; j < num_matches; ++j)
{
parse_match(matches[j], &tagp);
for (i = idx; i < new_num_matches; ++i)
{
parse_match(new_matches[i], &tagp2);
if (STRCMP(tagp.tagname, tagp2.tagname) == 0)
{
char_u *p = new_matches[i];
for (k = i; k > idx; --k)
new_matches[k] = new_matches[k - 1];
new_matches[idx++] = p;
break;
}
}
}
}
FreeWild(num_matches, matches);
num_matches = new_num_matches;
matches = new_matches;
}
if (num_matches <= 0)
{
if (verbose)
semsg(_(e_tag_not_found_str), name);
#if defined(FEAT_QUICKFIX)
g_do_tagpreview = 0;
#endif
}
else
{
int ask_for_selection = FALSE;
#ifdef FEAT_CSCOPE
if (type == DT_CSCOPE && num_matches > 1)
{
cs_print_tags();
ask_for_selection = TRUE;
}
else
#endif
if (type == DT_TAG && *tag != NUL)
// If a count is supplied to the ":tag <name>" command, then
// jump to count'th matching tag.
cur_match = count > 0 ? count - 1 : 0;
else if (type == DT_SELECT || (type == DT_JUMP && num_matches > 1))
{
print_tag_list(new_tag, use_tagstack, num_matches, matches);
ask_for_selection = TRUE;
}
#if defined(FEAT_QUICKFIX) && defined(FEAT_EVAL)
else if (type == DT_LTAG)
{
if (add_llist_tags(tag, num_matches, matches) == FAIL)
goto end_do_tag;
cur_match = 0; // Jump to the first tag
}
#endif
if (ask_for_selection == TRUE)
{
/*
* Ask to select a tag from the list.
*/
i = prompt_for_number(NULL);
if (i <= 0 || i > num_matches || got_int)
{
// no valid choice: don't change anything
if (use_tagstack)
{
tagstack[tagstackidx].fmark = saved_fmark;
tagstackidx = prevtagstackidx;
}
#ifdef FEAT_CSCOPE
cs_free_tags();
jumped_to_tag = TRUE;
#endif
break;
}
cur_match = i - 1;
}
if (cur_match >= num_matches)
{
// Avoid giving this error when a file wasn't found and we're
// looking for a match in another file, which wasn't found.
// There will be an emsg("file doesn't exist") below then.
if ((type == DT_NEXT || type == DT_FIRST)
&& nofile_fname == NULL)
{
if (num_matches == 1)
emsg(_(e_there_is_only_one_matching_tag));
else
emsg(_(e_cannot_go_beyond_last_matching_tag));
skip_msg = TRUE;
}
cur_match = num_matches - 1;
}
if (use_tagstack)
{
tagptrs_T tagp;
tagstack[tagstackidx].cur_match = cur_match;
tagstack[tagstackidx].cur_fnum = cur_fnum;
// store user-provided data originating from tagfunc
if (use_tfu && parse_match(matches[cur_match], &tagp) == OK
&& tagp.user_data)
{
VIM_CLEAR(tagstack[tagstackidx].user_data);
tagstack[tagstackidx].user_data = vim_strnsave(
tagp.user_data, tagp.user_data_end - tagp.user_data);
}
++tagstackidx;
}
#if defined(FEAT_QUICKFIX)
else if (g_do_tagpreview != 0)
{
ptag_entry.cur_match = cur_match;
ptag_entry.cur_fnum = cur_fnum;
}
#endif
/*
* Only when going to try the next match, report that the previous
* file didn't exist. Otherwise an emsg() is given below.
*/
if (nofile_fname != NULL && error_cur_match != cur_match)
smsg(_("File \"%s\" does not exist"), nofile_fname);
ic = (matches[cur_match][0] & MT_IC_OFF);
if (type != DT_TAG && type != DT_SELECT && type != DT_JUMP
#ifdef FEAT_CSCOPE
&& type != DT_CSCOPE
#endif
&& (num_matches > 1 || ic)
&& !skip_msg)
{
// Give an indication of the number of matching tags
sprintf((char *)IObuff, _("tag %d of %d%s"),
cur_match + 1,
num_matches,
max_num_matches != MAXCOL ? _(" or more") : "");
if (ic)
STRCAT(IObuff, _(" Using tag with different case!"));
if ((num_matches > prev_num_matches || new_tag)
&& num_matches > 1)
{
if (ic)
msg_attr((char *)IObuff, HL_ATTR(HLF_W));
else
msg((char *)IObuff);
msg_scroll = TRUE; // don't overwrite this message
}
else
give_warning(IObuff, ic);
if (ic && !msg_scrolled && msg_silent == 0)
{
out_flush();
ui_delay(1007L, TRUE);
}
}
#if defined(FEAT_EVAL)
// Let the SwapExists event know what tag we are jumping to.
vim_snprintf((char *)IObuff, IOSIZE, ":ta %s\r", name);
set_vim_var_string(VV_SWAPCOMMAND, IObuff, -1);
#endif
/*
* Jump to the desired match.
*/
i = jumpto_tag(matches[cur_match], forceit, type != DT_CSCOPE);
#if defined(FEAT_EVAL)
set_vim_var_string(VV_SWAPCOMMAND, NULL, -1);
#endif
if (i == NOTAGFILE)
{
// File not found: try again with another matching tag
if ((type == DT_PREV && cur_match > 0)
|| ((type == DT_TAG || type == DT_NEXT
|| type == DT_FIRST)
&& (max_num_matches != MAXCOL
|| cur_match < num_matches - 1)))
{
error_cur_match = cur_match;
if (use_tagstack)
--tagstackidx;
if (type == DT_PREV)
--cur_match;
else
{
type = DT_NEXT;
++cur_match;
}
continue;
}
semsg(_(e_file_str_does_not_exist), nofile_fname);
}
else
{
// We may have jumped to another window, check that
// tagstackidx is still valid.
if (use_tagstack && tagstackidx > curwin->w_tagstacklen)
tagstackidx = curwin->w_tagstackidx;
#ifdef FEAT_CSCOPE
jumped_to_tag = TRUE;
#endif
}
}
break;
}
end_do_tag:
// Only store the new index when using the tagstack and it's valid.
if (use_tagstack && tagstackidx <= curwin->w_tagstacklen)
curwin->w_tagstackidx = tagstackidx;
postponed_split = 0; // don't split next time
# ifdef FEAT_QUICKFIX
g_do_tagpreview = 0; // don't do tag preview next time
# endif
vim_free(tofree);
#ifdef FEAT_CSCOPE
return jumped_to_tag;
#else
return FALSE;
#endif
}
| 1
|
437,317
|
check_type_tree(Node* node, int type_mask, int enclosure_mask, int anchor_mask)
{
NodeType type;
int r = 0;
type = NODE_TYPE(node);
if ((NODE_TYPE2BIT(type) & type_mask) == 0)
return 1;
switch (type) {
case NODE_LIST:
case NODE_ALT:
do {
r = check_type_tree(NODE_CAR(node), type_mask, enclosure_mask,
anchor_mask);
} while (r == 0 && IS_NOT_NULL(node = NODE_CDR(node)));
break;
case NODE_QUANT:
r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);
break;
case NODE_ENCLOSURE:
{
EnclosureNode* en = ENCLOSURE_(node);
if (((1<<en->type) & enclosure_mask) == 0)
return 1;
r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);
if (r == 0 && en->type == ENCLOSURE_IF_ELSE) {
if (IS_NOT_NULL(en->te.Then)) {
r = check_type_tree(en->te.Then, type_mask, enclosure_mask, anchor_mask);
if (r != 0) break;
}
if (IS_NOT_NULL(en->te.Else)) {
r = check_type_tree(en->te.Else, type_mask, enclosure_mask, anchor_mask);
}
}
}
break;
case NODE_ANCHOR:
type = ANCHOR_(node)->type;
if ((type & anchor_mask) == 0)
return 1;
if (IS_NOT_NULL(NODE_BODY(node)))
r = check_type_tree(NODE_BODY(node), type_mask, enclosure_mask, anchor_mask);
break;
case NODE_GIMMICK:
default:
break;
}
return r;
}
| 0
|
386,522
|
bool DL_Dxf::stripWhiteSpace(char** s, bool stripSpace) {
// last non-NULL char:
int lastChar = strlen(*s) - 1;
// Is last character CR or LF?
while ( (lastChar >= 0) &&
(((*s)[lastChar] == 10) || ((*s)[lastChar] == 13) ||
(stripSpace && ((*s)[lastChar] == ' ' || ((*s)[lastChar] == '\t')))) ) {
(*s)[lastChar] = '\0';
lastChar--;
}
// Skip whitespace, excluding \n, at beginning of line
if (stripSpace) {
while ((*s)[0]==' ' || (*s)[0]=='\t') {
++(*s);
}
}
return ((*s) ? true : false);
}
| 0
|
384,879
|
vim_tolower(int c)
{
if (c <= '@')
return c;
if (c >= 0x80 || !(cmp_flags & CMP_KEEPASCII))
{
if (enc_utf8)
return utf_tolower(c);
if (c >= 0x100)
{
#ifdef HAVE_TOWLOWER
if (has_mbyte)
return towlower(c);
#endif
// tolower() can't handle these chars and may crash
return c;
}
if (enc_latin1like)
return latin1lower[c];
}
if (c < 0x80 && (cmp_flags & CMP_KEEPASCII))
return TOLOWER_ASC(c);
return TOLOWER_LOC(c);
}
| 0
|
197,796
|
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)
{
int i;
uint16_t limit;
VncDisplay *vd = vs->vd;
if (data[0] > 3) {
update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE);
}
switch (data[0]) {
case VNC_MSG_CLIENT_SET_PIXEL_FORMAT:
if (len == 1)
return 20;
set_pixel_format(vs, read_u8(data, 4), read_u8(data, 5),
read_u8(data, 6), read_u8(data, 7),
read_u16(data, 8), read_u16(data, 10),
read_u16(data, 12), read_u8(data, 14),
read_u8(data, 15), read_u8(data, 16));
break;
case VNC_MSG_CLIENT_SET_ENCODINGS:
if (len == 1)
return 4;
if (len == 4) {
limit = read_u16(data, 2);
if (limit > 0)
return 4 + (limit * 4);
} else
limit = read_u16(data, 2);
for (i = 0; i < limit; i++) {
int32_t val = read_s32(data, 4 + (i * 4));
memcpy(data + 4 + (i * 4), &val, sizeof(val));
}
set_encodings(vs, (int32_t *)(data + 4), limit);
break;
case VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST:
if (len == 1)
return 10;
framebuffer_update_request(vs,
read_u8(data, 1), read_u16(data, 2), read_u16(data, 4),
read_u16(data, 6), read_u16(data, 8));
break;
case VNC_MSG_CLIENT_KEY_EVENT:
if (len == 1)
return 8;
key_event(vs, read_u8(data, 1), read_u32(data, 4));
break;
case VNC_MSG_CLIENT_POINTER_EVENT:
if (len == 1)
return 6;
pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4));
break;
case VNC_MSG_CLIENT_CUT_TEXT:
if (len == 1)
return 8;
if (len == 8) {
uint32_t dlen = read_u32(data, 4);
if (dlen > 0)
return 8 + dlen;
}
client_cut_text(vs, read_u32(data, 4), data + 8);
break;
case VNC_MSG_CLIENT_QEMU:
if (len == 1)
return 2;
switch (read_u8(data, 1)) {
case VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT:
if (len == 2)
return 12;
ext_key_event(vs, read_u16(data, 2),
read_u32(data, 4), read_u32(data, 8));
break;
case VNC_MSG_CLIENT_QEMU_AUDIO:
if (len == 2)
return 4;
switch (read_u16 (data, 2)) {
case VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE:
audio_add(vs);
break;
case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE:
audio_del(vs);
break;
case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT:
if (len == 4)
return 10;
switch (read_u8(data, 4)) {
case 0: vs->as.fmt = AUD_FMT_U8; break;
case 1: vs->as.fmt = AUD_FMT_S8; break;
case 2: vs->as.fmt = AUD_FMT_U16; break;
case 3: vs->as.fmt = AUD_FMT_S16; break;
case 4: vs->as.fmt = AUD_FMT_U32; break;
case 5: vs->as.fmt = AUD_FMT_S32; break;
default:
printf("Invalid audio format %d\n", read_u8(data, 4));
vnc_client_error(vs);
break;
}
vs->as.nchannels = read_u8(data, 5);
if (vs->as.nchannels != 1 && vs->as.nchannels != 2) {
printf("Invalid audio channel coount %d\n",
read_u8(data, 5));
vnc_client_error(vs);
break;
}
vs->as.freq = read_u32(data, 6);
break;
default:
printf ("Invalid audio message %d\n", read_u8(data, 4));
vnc_client_error(vs);
break;
}
break;
default:
printf("Msg: %d\n", read_u16(data, 0));
vnc_client_error(vs);
break;
}
break;
default:
printf("Msg: %d\n", data[0]);
vnc_client_error(vs);
break;
}
vnc_read_when(vs, protocol_client_msg, 1);
return 0;
}
| 1
|
289,270
|
static int snd_pcm_oss_set_subdivide(struct snd_pcm_oss_file *pcm_oss_file, int subdivide)
{
int err = -EINVAL, idx;
for (idx = 1; idx >= 0; --idx) {
struct snd_pcm_substream *substream = pcm_oss_file->streams[idx];
struct snd_pcm_runtime *runtime;
if (substream == NULL)
continue;
runtime = substream->runtime;
err = lock_params(runtime);
if (err < 0)
return err;
err = snd_pcm_oss_set_subdivide1(substream, subdivide);
unlock_params(runtime);
if (err < 0)
return err;
}
return err;
}
| 0
|
225,489
|
Status MutableGraphView::UpdateAllRegularFaninsToControlling(
absl::string_view node_name) {
auto error_status = [node_name](absl::string_view msg) {
string params = absl::Substitute("node_name='$0'", node_name);
return MutationError("UpdateAllRegularFaninsToControlling", params, msg);
};
NodeDef* node = GetNode(node_name);
TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));
const int num_regular_fanins =
NumFanins(*node, /*include_controlling_nodes=*/false);
std::vector<OutputPort> regular_fanins;
regular_fanins.reserve(num_regular_fanins);
std::vector<NodeDef*> controlling_fanins;
controlling_fanins.reserve(num_regular_fanins);
// Get all regular fanins and derive controlling fanins.
for (int i = 0; i < num_regular_fanins; ++i) {
TensorId tensor_id = ParseTensorName(node->input(i));
OutputPort fanin_port(nodes()[tensor_id.node()], tensor_id.index());
string error_msg = "";
NodeDef* control_node =
GetControllingFaninToAdd(node_name, fanin_port, &error_msg);
if (!error_msg.empty()) {
return error_status(error_msg);
}
regular_fanins.push_back(fanin_port);
controlling_fanins.push_back(control_node);
}
// Replace regular fanins with controlling fanins and dedup.
int pos = 0;
InputPort input_port(node, Graph::kControlSlot);
absl::flat_hash_set<absl::string_view> controls;
for (int i = 0; i < num_regular_fanins; ++i) {
OutputPort fanin_port = regular_fanins[i];
NodeDef* control = controlling_fanins[i];
if (control == nullptr) {
control = GetOrCreateIdentityConsumingSwitch(fanin_port);
}
fanouts()[fanin_port].erase({node, i});
if (controls.contains(control->name())) {
continue;
}
controls.insert(control->name());
node->set_input(pos, AsControlDependency(control->name()));
fanouts()[{control, Graph::kControlSlot}].insert(input_port);
++pos;
}
// Shift existing controlling fanins and dedup.
for (int i = num_regular_fanins; i < node->input_size(); ++i) {
TensorId tensor_id = ParseTensorName(node->input(i));
if (controls.contains(tensor_id.node())) {
continue;
}
controls.insert(tensor_id.node());
node->mutable_input()->SwapElements(pos, i);
++pos;
}
// Remove duplicate controls and leftover regular fanins.
node->mutable_input()->DeleteSubrange(pos, node->input_size() - pos);
max_regular_input_port().erase(node);
return Status::OK();
}
| 0
|
221,689
|
int Socket::bind(const std::string &ip, int port) {
int len = sizeof my_adr;
int i = 1;
setsockopt(sck, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(i));
my_adr.sin_port = htons(port);
my_adr.sin_addr.s_addr = inet_addr(ip.c_str());
my_port = port;
return ::bind(sck, (struct sockaddr *) &my_adr, len);
}
| 0
|
198,452
|
void ComparisonQuantized(const TfLiteTensor* input1, const TfLiteTensor* input2,
TfLiteTensor* output, bool requires_broadcast) {
if (input1->type == kTfLiteUInt8 || input1->type == kTfLiteInt8) {
auto input1_offset = -input1->params.zero_point;
auto input2_offset = -input2->params.zero_point;
const int left_shift = 8;
int32 input1_multiplier;
int input1_shift;
QuantizeMultiplierSmallerThanOneExp(input1->params.scale,
&input1_multiplier, &input1_shift);
int32 input2_multiplier;
int input2_shift;
QuantizeMultiplierSmallerThanOneExp(input2->params.scale,
&input2_multiplier, &input2_shift);
ComparisonParams op_params;
op_params.left_shift = left_shift;
op_params.input1_offset = input1_offset;
op_params.input1_multiplier = input1_multiplier;
op_params.input1_shift = input1_shift;
op_params.input2_offset = input2_offset;
op_params.input2_multiplier = input2_multiplier;
op_params.input2_shift = input2_shift;
if (requires_broadcast) {
reference_ops::BroadcastComparison4DSlowWithScaling<input_dtype, opname>(
op_params, GetTensorShape(input1), GetTensorData<input_dtype>(input1),
GetTensorShape(input2), GetTensorData<input_dtype>(input2),
GetTensorShape(output), GetTensorData<bool>(output));
} else {
reference_ops::ComparisonWithScaling<input_dtype, opname>(
op_params, GetTensorShape(input1), GetTensorData<input_dtype>(input1),
GetTensorShape(input2), GetTensorData<input_dtype>(input2),
GetTensorShape(output), GetTensorData<bool>(output));
}
}
}
| 1
|
254,728
|
njs_typed_array_prototype_reverse(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused)
{
double *f64;
uint8_t *u8;
int64_t i, length;
uint16_t *u16;
uint32_t *u32;
njs_value_t *this;
njs_typed_array_t *array;
njs_array_buffer_t *buffer;
this = njs_argument(args, 0);
if (njs_slow_path(!njs_is_typed_array(this))) {
njs_type_error(vm, "this is not a typed array");
return NJS_ERROR;
}
array = njs_typed_array(this);
length = njs_typed_array_length(array);
buffer = njs_typed_array_writable(vm, array);
if (njs_slow_path(buffer == NULL)) {
return NJS_ERROR;
}
switch (array->type) {
case NJS_OBJ_TYPE_UINT8_ARRAY:
case NJS_OBJ_TYPE_UINT8_CLAMPED_ARRAY:
case NJS_OBJ_TYPE_INT8_ARRAY:
u8 = &buffer->u.u8[array->offset];
for (i = 0; i < length / 2; i++) {
njs_swap_u8(&u8[i], &u8[length - i - 1], 0);
}
break;
case NJS_OBJ_TYPE_INT16_ARRAY:
case NJS_OBJ_TYPE_UINT16_ARRAY:
u16 = &buffer->u.u16[array->offset];
for (i = 0; i < length / 2; i++) {
njs_swap_u16(&u16[i], &u16[length - i - 1], 0);
}
break;
case NJS_OBJ_TYPE_INT32_ARRAY:
case NJS_OBJ_TYPE_UINT32_ARRAY:
case NJS_OBJ_TYPE_FLOAT32_ARRAY:
u32 = &buffer->u.u32[array->offset];
for (i = 0; i < length / 2; i++) {
njs_swap_u32(&u32[i], &u32[length - i - 1], 0);
}
break;
default:
/* NJS_OBJ_TYPE_FLOAT64_ARRAY. */
f64 = &buffer->u.f64[array->offset];
for (i = 0; i < length / 2; i++) {
njs_swap_u64(&f64[i], &f64[length - i - 1], 0);
}
}
njs_set_typed_array(&vm->retval, array);
return NJS_OK;
}
| 0
|
291,846
|
int rtrs_clt_remove_path_from_sysfs(struct rtrs_clt_path *clt_path,
const struct attribute *sysfs_self)
{
enum rtrs_clt_state old_state;
bool changed;
/*
* Continue stopping path till state was changed to DEAD or
* state was observed as DEAD:
* 1. State was changed to DEAD - we were fast and nobody
* invoked rtrs_clt_reconnect(), which can again start
* reconnecting.
* 2. State was observed as DEAD - we have someone in parallel
* removing the path.
*/
do {
rtrs_clt_close_conns(clt_path, true);
changed = rtrs_clt_change_state_get_old(clt_path,
RTRS_CLT_DEAD,
&old_state);
} while (!changed && old_state != RTRS_CLT_DEAD);
if (changed) {
rtrs_clt_remove_path_from_arr(clt_path);
rtrs_clt_destroy_path_files(clt_path, sysfs_self);
kobject_put(&clt_path->kobj);
}
return 0;
}
| 0
|
90,842
|
void DidGetHostQuota(QuotaStatusCode status,
const std::string& host,
StorageType type,
int64 quota) {
quota_status_ = status;
host_ = host;
type_ = type;
quota_ = quota;
}
| 0
|
210,520
|
get_lisp_indent(void)
{
pos_T *pos, realpos, paren;
int amount;
char_u *that;
colnr_T col;
colnr_T firsttry;
int parencount, quotecount;
int vi_lisp;
// Set vi_lisp to use the vi-compatible method
vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);
realpos = curwin->w_cursor;
curwin->w_cursor.col = 0;
if ((pos = findmatch(NULL, '(')) == NULL)
pos = findmatch(NULL, '[');
else
{
paren = *pos;
pos = findmatch(NULL, '[');
if (pos == NULL || LT_POSP(pos, &paren))
pos = &paren;
}
if (pos != NULL)
{
// Extra trick: Take the indent of the first previous non-white
// line that is at the same () level.
amount = -1;
parencount = 0;
while (--curwin->w_cursor.lnum >= pos->lnum)
{
if (linewhite(curwin->w_cursor.lnum))
continue;
for (that = ml_get_curline(); *that != NUL; ++that)
{
if (*that == ';')
{
while (*(that + 1) != NUL)
++that;
continue;
}
if (*that == '\\')
{
if (*(that + 1) != NUL)
++that;
continue;
}
if (*that == '"' && *(that + 1) != NUL)
{
while (*++that && *that != '"')
{
// skipping escaped characters in the string
if (*that == '\\')
{
if (*++that == NUL)
break;
if (that[1] == NUL)
{
++that;
break;
}
}
}
if (*that == NUL)
break;
}
if (*that == '(' || *that == '[')
++parencount;
else if (*that == ')' || *that == ']')
--parencount;
}
if (parencount == 0)
{
amount = get_indent();
break;
}
}
if (amount == -1)
{
curwin->w_cursor.lnum = pos->lnum;
curwin->w_cursor.col = pos->col;
col = pos->col;
that = ml_get_curline();
if (vi_lisp && get_indent() == 0)
amount = 2;
else
{
char_u *line = that;
amount = 0;
while (*that && col)
{
amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);
col--;
}
// Some keywords require "body" indenting rules (the
// non-standard-lisp ones are Scheme special forms):
//
// (let ((a 1)) instead (let ((a 1))
// (...)) of (...))
if (!vi_lisp && (*that == '(' || *that == '[')
&& lisp_match(that + 1))
amount += 2;
else
{
that++;
amount++;
firsttry = amount;
while (VIM_ISWHITE(*that))
{
amount += lbr_chartabsize(line, that, (colnr_T)amount);
++that;
}
if (*that && *that != ';') // not a comment line
{
// test *that != '(' to accommodate first let/do
// argument if it is more than one line
if (!vi_lisp && *that != '(' && *that != '[')
firsttry++;
parencount = 0;
quotecount = 0;
if (vi_lisp
|| (*that != '"'
&& *that != '\''
&& *that != '#'
&& (*that < '0' || *that > '9')))
{
while (*that
&& (!VIM_ISWHITE(*that)
|| quotecount
|| parencount)
&& (!((*that == '(' || *that == '[')
&& !quotecount
&& !parencount
&& vi_lisp)))
{
if (*that == '"')
quotecount = !quotecount;
if ((*that == '(' || *that == '[')
&& !quotecount)
++parencount;
if ((*that == ')' || *that == ']')
&& !quotecount)
--parencount;
if (*that == '\\' && *(that+1) != NUL)
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
}
}
while (VIM_ISWHITE(*that))
{
amount += lbr_chartabsize(
line, that, (colnr_T)amount);
that++;
}
if (!*that || *that == ';')
amount = firsttry;
}
}
}
}
}
else
amount = 0; // no matching '(' or '[' found, use zero indent
curwin->w_cursor = realpos;
return amount;
}
| 1
|
313,735
|
normal_cmd_get_count(
cmdarg_T *cap,
int c,
int toplevel UNUSED,
int set_prevcount UNUSED,
int *ctrl_w,
int *need_flushbuf UNUSED)
{
getcount:
if (!(VIsual_active && VIsual_select))
{
// Handle a count before a command and compute ca.count0.
// Note that '0' is a command and not the start of a count, but it's
// part of a count after other digits.
while ((c >= '1' && c <= '9')
|| (cap->count0 != 0 && (c == K_DEL || c == K_KDEL
|| c == '0')))
{
if (c == K_DEL || c == K_KDEL)
{
cap->count0 /= 10;
#ifdef FEAT_CMDL_INFO
del_from_showcmd(4); // delete the digit and ~@%
#endif
}
else if (cap->count0 > 99999999L)
{
cap->count0 = 999999999L;
}
else
{
cap->count0 = cap->count0 * 10 + (c - '0');
}
#ifdef FEAT_EVAL
// Set v:count here, when called from main() and not a stuffed
// command, so that v:count can be used in an expression mapping
// right after the count. Do set it for redo.
if (toplevel && readbuf1_empty())
set_vcount_ca(cap, &set_prevcount);
#endif
if (*ctrl_w)
{
++no_mapping;
++allow_keys; // no mapping for nchar, but keys
}
++no_zero_mapping; // don't map zero here
c = plain_vgetc();
LANGMAP_ADJUST(c, TRUE);
--no_zero_mapping;
if (*ctrl_w)
{
--no_mapping;
--allow_keys;
}
#ifdef FEAT_CMDL_INFO
*need_flushbuf |= add_to_showcmd(c);
#endif
}
// If we got CTRL-W there may be a/another count
if (c == Ctrl_W && !*ctrl_w && cap->oap->op_type == OP_NOP)
{
*ctrl_w = TRUE;
cap->opcount = cap->count0; // remember first count
cap->count0 = 0;
++no_mapping;
++allow_keys; // no mapping for nchar, but keys
c = plain_vgetc(); // get next character
LANGMAP_ADJUST(c, TRUE);
--no_mapping;
--allow_keys;
#ifdef FEAT_CMDL_INFO
*need_flushbuf |= add_to_showcmd(c);
#endif
goto getcount; // jump back
}
}
if (c == K_CURSORHOLD)
{
// Save the count values so that ca.opcount and ca.count0 are exactly
// the same when coming back here after handling K_CURSORHOLD.
cap->oap->prev_opcount = cap->opcount;
cap->oap->prev_count0 = cap->count0;
}
else if (cap->opcount != 0)
{
// If we're in the middle of an operator (including after entering a
// yank buffer with '"') AND we had a count before the operator, then
// that count overrides the current value of ca.count0.
// What this means effectively, is that commands like "3dw" get turned
// into "d3w" which makes things fall into place pretty neatly.
// If you give a count before AND after the operator, they are
// multiplied.
if (cap->count0)
{
if (cap->opcount >= 999999999L / cap->count0)
cap->count0 = 999999999L;
else
cap->count0 *= cap->opcount;
}
else
cap->count0 = cap->opcount;
}
// Always remember the count. It will be set to zero (on the next call,
// above) when there is no pending operator.
// When called from main(), save the count for use by the "count" built-in
// variable.
cap->opcount = cap->count0;
cap->count1 = (cap->count0 == 0 ? 1 : cap->count0);
#ifdef FEAT_EVAL
// Only set v:count when called from main() and not a stuffed command.
// Do set it for redo.
if (toplevel && readbuf1_empty())
set_vcount(cap->count0, cap->count1, set_prevcount);
#endif
return c;
}
| 0
|
242,116
|
int LuaSettings::gc_object(lua_State* L)
{
LuaSettings* o = *(LuaSettings **)(lua_touserdata(L, 1));
delete o;
return 0;
}
| 0
|
463,167
|
static void annotate_state_finish(annotate_state_t *state)
{
/* Free the entry list */
while (state->entry_list) {
struct annotate_entry_list *ee = state->entry_list;
state->entry_list = ee->next;
buf_free(&ee->shared);
buf_free(&ee->priv);
free(ee->name);
free(ee);
}
free_hash_table(&state->entry_table, NULL);
free_hash_table(&state->server_table, NULL);
}
| 0
|
220,452
|
static bool Run(OpKernelContext* ctx, const Tensor& input,
const Tensor& filter, int batch, int input_rows,
int input_cols, int in_depth, int filter_rows,
int filter_cols, int pad_rows, int pad_cols, int out_rows,
int out_cols, int out_depth, int dilation_rows,
int dilation_cols, int stride_rows, int stride_cols,
Tensor* output, TensorFormat data_format) {
if (data_format != FORMAT_NHWC || dilation_rows != 1 ||
dilation_cols != 1 ||
!CanUseDeepConv2D(stride_rows, stride_cols, filter_rows, filter_cols,
in_depth, out_depth, out_rows, out_cols)) {
return false;
}
Conv2DArgs args;
args.batch = batch;
args.in_rows = input_rows;
args.in_cols = input_cols;
args.in_depth = in_depth;
args.filter_rows = filter_rows;
args.filter_cols = filter_cols;
args.pad_rows = pad_rows;
args.pad_cols = pad_cols;
args.out_rows = out_rows;
args.out_cols = out_cols;
args.out_depth = out_depth;
auto input_ptr = input.template flat<float>().data();
auto filter_ptr = filter.template flat<float>().data();
auto output_ptr = output->template flat<float>().data();
functor::DeepConv2D<CPUDevice, float>()(ctx, args, input_ptr, filter_ptr,
output_ptr);
return true;
}
| 0
|
393,521
|
static SQInteger class_instance(HSQUIRRELVM v)
{
return SQ_SUCCEEDED(sq_createinstance(v,-1))?1:SQ_ERROR;
}
| 0
|
455,177
|
MOBI_RET mobi_parse_huffdic(const MOBIData *m, MOBIHuffCdic *huffcdic) {
MOBI_RET ret;
const size_t offset = mobi_get_kf8offset(m);
if (m->mh == NULL || m->mh->huff_rec_index == NULL || m->mh->huff_rec_count == NULL) {
debug_print("%s", "HUFF/CDIC records metadata not found in MOBI header\n");
return MOBI_DATA_CORRUPT;
}
const size_t huff_rec_index = *m->mh->huff_rec_index + offset;
const size_t huff_rec_count = *m->mh->huff_rec_count;
if (huff_rec_count > HUFF_RECORD_MAXCNT) {
debug_print("Too many HUFF record (%zu)\n", huff_rec_count);
return MOBI_DATA_CORRUPT;
}
const MOBIPdbRecord *curr = mobi_get_record_by_seqnumber(m, huff_rec_index);
if (curr == NULL || huff_rec_count < 2) {
debug_print("%s", "HUFF/CDIC record not found\n");
return MOBI_DATA_CORRUPT;
}
if (curr->size < HUFF_RECORD_MINSIZE) {
debug_print("HUFF record too short (%zu b)\n", curr->size);
return MOBI_DATA_CORRUPT;
}
ret = mobi_parse_huff(huffcdic, curr);
if (ret != MOBI_SUCCESS) {
debug_print("%s", "HUFF parsing failed\n");
return ret;
}
curr = curr->next;
/* allocate memory for symbols data in each CDIC record */
huffcdic->symbols = malloc((huff_rec_count - 1) * sizeof(*huffcdic->symbols));
if (huffcdic->symbols == NULL) {
debug_print("%s\n", "Memory allocation failed");
return MOBI_MALLOC_FAILED;
}
/* get following CDIC records */
size_t i = 0;
while (i < huff_rec_count - 1) {
if (curr == NULL) {
debug_print("%s\n", "CDIC record not found");
return MOBI_DATA_CORRUPT;
}
ret = mobi_parse_cdic(huffcdic, curr, i++);
if (ret != MOBI_SUCCESS) {
debug_print("%s", "CDIC parsing failed\n");
return ret;
}
curr = curr->next;
}
if (huffcdic->index_count != huffcdic->index_read) {
debug_print("CDIC: wrong read index count: %zu, total: %zu\n", huffcdic->index_read, huffcdic->index_count);
return MOBI_DATA_CORRUPT;
}
return MOBI_SUCCESS;
}
| 0
|
252,430
|
static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip,
const char *pFilename) {
mz_zip_internal_state *pState = pZip->m_pState;
const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
const mz_zip_array *pCentral_dir = &pState->m_central_dir;
mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(
&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
const int size = pZip->m_total_files;
const mz_uint filename_len = (mz_uint)strlen(pFilename);
int l = 0, h = size - 1;
while (l <= h) {
int m = (l + h) >> 1, file_index = pIndices[m],
comp =
mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets,
file_index, pFilename, filename_len);
if (!comp)
return file_index;
else if (comp < 0)
l = m + 1;
else
h = m - 1;
}
return -1;
}
| 0
|
221,475
|
check_sudo (GError **error)
{
const char *sudo_command_env = g_getenv ("SUDO_COMMAND");
g_auto(GStrv) split_command = NULL;
/* This check exists to stop accidental usage of `sudo flatpak run`
and is not to prevent running as root.
*/
if (!sudo_command_env)
return TRUE;
/* SUDO_COMMAND could be a value like `/usr/bin/flatpak run foo` */
split_command = g_strsplit (sudo_command_env, " ", 2);
if (g_str_has_suffix (split_command[0], "flatpak"))
return flatpak_fail_error (error, FLATPAK_ERROR, _("\"flatpak run\" is not intended to be run as `sudo flatpak run`, use `sudo -i` or `su -l` instead and invoke \"flatpak run\" from inside the new shell"));
return TRUE;
}
| 0
|
445,872
|
name_column_sort_func (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer user_data)
{
FileData *fdata1;
FileData *fdata2;
GtkSortType sort_order;
int result;
gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (model), NULL, &sort_order);
gtk_tree_model_get (model, a, COLUMN_FILE_DATA, &fdata1, -1);
gtk_tree_model_get (model, b, COLUMN_FILE_DATA, &fdata2, -1);
if (file_data_is_dir (fdata1) == file_data_is_dir (fdata2)) {
result = strcmp (fdata1->sort_key, fdata2->sort_key);
}
else {
result = file_data_is_dir (fdata1) ? -1 : 1;
if (sort_order == GTK_SORT_DESCENDING)
result = -1 * result;
}
return result;
}
| 0
|
309,960
|
_nc_outch(int ch)
{
putc(ch, stdout);
return OK;
}
| 0
|
233,822
|
void fmtutil_read_boxes_format(deark *c, struct de_boxesctx *bctx)
{
if(!bctx->f || !bctx->handle_box_fn) return; // Internal error
if(bctx->curbox) return; // Internal error
do_box_sequence(c, bctx, 0, bctx->f->len, -1, 0);
}
| 0
|
195,343
|
void Compute(OpKernelContext* context) override {
// Here's the basic idea:
// Batch and depth dimension are independent from row and col dimension. And
// because FractionalAvgPool currently only support pooling along row and
// col, we can basically think of this 4D tensor backpropagation as
// operation of a series of 2D planes.
//
// For each element of a 'slice' (2D plane) of output_backprop, we need to
// figure out its contributors when doing FractionalAvgPool operation. This
// can be done based on row_pooling_sequence, col_pooling_seq and
// overlapping.
// Once we figure out the original contributors, we just need to evenly
// divide the value of this element among these contributors.
//
// Internally, we divide the out_backprop tensor and store it in a temporary
// tensor of double type. And cast it to the corresponding type.
typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>
ConstEigenMatrixMap;
typedef Eigen::Map<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>
EigenDoubleMatrixMap;
// Grab the inputs.
const Tensor& orig_input_tensor_shape = context->input(0);
OP_REQUIRES(context,
orig_input_tensor_shape.dims() == 1 &&
orig_input_tensor_shape.NumElements() == 4,
errors::InvalidArgument("original input tensor shape must be"
"1-dimensional and 4 elements"));
const Tensor& out_backprop = context->input(1);
const Tensor& row_seq_tensor = context->input(2);
const Tensor& col_seq_tensor = context->input(3);
const int64_t out_batch = out_backprop.dim_size(0);
const int64_t out_rows = out_backprop.dim_size(1);
const int64_t out_cols = out_backprop.dim_size(2);
const int64_t out_depth = out_backprop.dim_size(3);
OP_REQUIRES(context, row_seq_tensor.NumElements() > out_rows,
errors::InvalidArgument("Given out_backprop shape ",
out_backprop.shape().DebugString(),
", row_seq_tensor must have at least ",
out_rows + 1, " elements, but got ",
row_seq_tensor.NumElements()));
OP_REQUIRES(context, col_seq_tensor.NumElements() > out_cols,
errors::InvalidArgument("Given out_backprop shape ",
out_backprop.shape().DebugString(),
", col_seq_tensor must have at least ",
out_cols + 1, " elements, but got ",
col_seq_tensor.NumElements()));
auto row_seq_tensor_flat = row_seq_tensor.flat<int64_t>();
auto col_seq_tensor_flat = col_seq_tensor.flat<int64_t>();
auto orig_input_tensor_shape_flat = orig_input_tensor_shape.flat<int64_t>();
const int64_t in_batch = orig_input_tensor_shape_flat(0);
const int64_t in_rows = orig_input_tensor_shape_flat(1);
const int64_t in_cols = orig_input_tensor_shape_flat(2);
const int64_t in_depth = orig_input_tensor_shape_flat(3);
OP_REQUIRES(
context, in_batch != 0,
errors::InvalidArgument("Batch dimension of input must not be 0"));
OP_REQUIRES(
context, in_rows != 0,
errors::InvalidArgument("Rows dimension of input must not be 0"));
OP_REQUIRES(
context, in_cols != 0,
errors::InvalidArgument("Columns dimension of input must not be 0"));
OP_REQUIRES(
context, in_depth != 0,
errors::InvalidArgument("Depth dimension of input must not be 0"));
constexpr int tensor_in_and_out_dims = 4;
// Transform orig_input_tensor_shape into TensorShape
TensorShape in_shape;
for (auto i = 0; i < tensor_in_and_out_dims; ++i) {
in_shape.AddDim(orig_input_tensor_shape_flat(i));
}
// Create intermediate in_backprop.
Tensor in_backprop_tensor_temp;
OP_REQUIRES_OK(context, context->forward_input_or_allocate_temp(
{0}, DataTypeToEnum<double>::v(), in_shape,
&in_backprop_tensor_temp));
in_backprop_tensor_temp.flat<double>().setZero();
// Transform 4D tensor to 2D matrix.
EigenDoubleMatrixMap in_backprop_tensor_temp_mat(
in_backprop_tensor_temp.flat<double>().data(), in_depth,
in_cols * in_rows * in_batch);
ConstEigenMatrixMap out_backprop_mat(out_backprop.flat<T>().data(),
out_depth,
out_cols * out_rows * out_batch);
// Loop through each element of out_backprop and evenly distribute the
// element to the corresponding pooling cell.
const int64_t in_max_row_index = in_rows - 1;
const int64_t in_max_col_index = in_cols - 1;
for (int64_t b = 0; b < out_batch; ++b) {
for (int64_t r = 0; r < out_rows; ++r) {
const int64_t in_row_start = row_seq_tensor_flat(r);
int64_t in_row_end = overlapping_ ? row_seq_tensor_flat(r + 1)
: row_seq_tensor_flat(r + 1) - 1;
in_row_end = std::min(in_row_end, in_max_row_index);
for (int64_t c = 0; c < out_cols; ++c) {
const int64_t in_col_start = col_seq_tensor_flat(c);
int64_t in_col_end = overlapping_ ? col_seq_tensor_flat(c + 1)
: col_seq_tensor_flat(c + 1) - 1;
in_col_end = std::min(in_col_end, in_max_col_index);
const int64_t num_elements_in_pooling_cell =
(in_row_end - in_row_start + 1) * (in_col_end - in_col_start + 1);
const int64_t out_index = (b * out_rows + r) * out_cols + c;
// Now we can evenly distribute out_backprop(b, h, w, *) to
// in_backprop(b, hs:he, ws:we, *).
for (int64_t in_r = in_row_start; in_r <= in_row_end; ++in_r) {
for (int64_t in_c = in_col_start; in_c <= in_col_end; ++in_c) {
const int64_t in_index = (b * in_rows + in_r) * in_cols + in_c;
// Walk through each channel (depth).
for (int64_t d = 0; d < out_depth; ++d) {
const double out_backprop_element = static_cast<double>(
out_backprop_mat.coeffRef(d, out_index));
double& in_backprop_ref =
in_backprop_tensor_temp_mat.coeffRef(d, in_index);
in_backprop_ref +=
out_backprop_element / num_elements_in_pooling_cell;
}
}
}
}
}
}
// Depending on the type, cast double to type T.
Tensor* in_backprop_tensor = nullptr;
OP_REQUIRES_OK(context, context->forward_input_or_allocate_output(
{0}, 0, in_shape, &in_backprop_tensor));
auto in_backprop_tensor_flat = in_backprop_tensor->flat<T>();
auto in_backprop_tensor_temp_flat = in_backprop_tensor_temp.flat<double>();
for (int64_t i = 0; i < in_backprop_tensor_flat.size(); ++i) {
in_backprop_tensor_flat(i) =
static_cast<T>(in_backprop_tensor_temp_flat(i));
}
}
| 1
|
262,021
|
ServiceProtoHandleSessionRequest(ServiceConnection *conn,
ProtoRequest *req)
{
VGAuthError err;
gchar *packet;
gchar *pipeName = NULL;
/*
* Do any argument checking. For now, the version number must
* match.
*/
if (req->reqData.sessionReq.version != atoi(VGAUTH_PROTOCOL_VERSION)) {
err = VGAUTH_E_VERSION_MISMATCH;
Warning("%s: version mismatch. Client is %d, want %d\n",
__FUNCTION__, req->reqData.sessionReq.version,
atoi(VGAUTH_PROTOCOL_VERSION));
packet = Proto_MakeErrorReply(conn, req, err,
"sessionRequest failed; version mismatch");
goto send_err;
}
err = ServiceStartUserConnection(req->reqData.sessionReq.userName,
&pipeName);
if (err != VGAUTH_E_OK) {
packet = Proto_MakeErrorReply(conn, req, err, "sessionRequest failed");
} else {
packet = g_markup_printf_escaped(VGAUTH_SESSION_REPLY_FORMAT,
req->sequenceNumber,
pipeName);
}
send_err:
err = ServiceNetworkWriteData(conn, strlen(packet), packet);
if (err != VGAUTH_E_OK) {
Warning("%s: failed to send SessionReq reply\n", __FUNCTION__);
}
g_free(pipeName);
g_free(packet);
return err;
}
| 0
|
338,070
|
void WasmBinaryWriter::initializeDebugInfo() {
lastDebugLocation = {0, /* lineNumber = */ 1, 0};
}
| 0
|
369,147
|
static inline bool io_alloc_req_refill(struct io_ring_ctx *ctx)
{
if (unlikely(!ctx->submit_state.free_list.next))
return __io_alloc_req_refill(ctx);
return true;
}
| 0
|
400,123
|
PortForwardHandler::PortForwardHandler(
shared_ptr<SocketHandler> _networkSocketHandler,
shared_ptr<SocketHandler> _pipeSocketHandler)
: networkSocketHandler(_networkSocketHandler),
pipeSocketHandler(_pipeSocketHandler) {}
| 0
|
498,084
|
void cgit_diff_link(const char *name, const char *title, const char *class,
const char *head, const char *new_rev, const char *old_rev,
const char *path)
{
char *delim;
delim = repolink(title, class, "diff", head, path);
if (new_rev && ctx.qry.head != NULL && strcmp(new_rev, ctx.qry.head)) {
html(delim);
html("id=");
html_url_arg(new_rev);
delim = "&";
}
if (old_rev) {
html(delim);
html("id2=");
html_url_arg(old_rev);
delim = "&";
}
if (ctx.qry.difftype) {
html(delim);
htmlf("dt=%d", ctx.qry.difftype);
delim = "&";
}
if (ctx.qry.context > 0 && ctx.qry.context != 3) {
html(delim);
html("context=");
htmlf("%d", ctx.qry.context);
delim = "&";
}
if (ctx.qry.ignorews) {
html(delim);
html("ignorews=1");
delim = "&";
}
if (ctx.qry.follow) {
html(delim);
html("follow=1");
}
html("'>");
html_txt(name);
html("</a>");
}
| 0
|
261,994
|
static void bundle_add_conn(struct connectbundle *bundle,
struct connectdata *conn)
{
Curl_llist_insert_next(&bundle->conn_list, bundle->conn_list.tail, conn,
&conn->bundle_node);
conn->bundle = bundle;
bundle->num_connections++;
}
| 0
|
413,583
|
R_API void r_core_recover_vars(RCore *core, RAnalFunction *fcn, bool argonly) {
r_return_if_fail (core && core->anal && fcn);
if (core->anal->opt.bb_max_size < 1) {
return;
}
BlockRecurseCtx ctx = { 0, {{ 0 }}, argonly, fcn, core };
r_pvector_init (&ctx.reg_set, free);
int *reg_set = R_NEWS0 (int, REG_SET_SIZE);
r_pvector_push (&ctx.reg_set, reg_set);
int saved_stack = fcn->stack;
RAnalBlock *first_bb = r_anal_get_block_at (fcn->anal, fcn->addr);
r_anal_block_recurse_depth_first (first_bb, (RAnalBlockCb)anal_block_cb, (RAnalBlockCb)anal_block_on_exit, &ctx);
r_pvector_fini (&ctx.reg_set);
fcn->stack = saved_stack;
}
| 0
|
468,359
|
on_timer (GCancellable *cancel)
{
g_cancellable_cancel (cancel);
return G_SOURCE_REMOVE;
}
| 0
|
247,132
|
Bool gf_fs_is_supported_mime(GF_FilterSession *fsess, const char *mime)
{
u32 i, count;
//first pass on explicit mimes
count = gf_list_count(fsess->registry);
for (i=0; i<count; i++) {
u32 j;
const GF_FilterRegister *freg = gf_list_get(fsess->registry, i);
for (j=0; j<freg->nb_caps; j++) {
const GF_FilterCapability *acap = &freg->caps[j];
if (!(acap->flags & GF_CAPFLAG_INPUT)) continue;
if (acap->code == GF_PROP_PID_MIME) {
if (acap->val.value.string && strstr(acap->val.value.string, mime)) return GF_TRUE;
}
}
}
return GF_FALSE;
}
| 0
|
430,399
|
static bool actions_may_change_flow(const struct nlattr *actions)
{
struct nlattr *nla;
int rem;
nla_for_each_nested(nla, actions, rem) {
u16 action = nla_type(nla);
switch (action) {
case OVS_ACTION_ATTR_OUTPUT:
case OVS_ACTION_ATTR_RECIRC:
case OVS_ACTION_ATTR_TRUNC:
case OVS_ACTION_ATTR_USERSPACE:
break;
case OVS_ACTION_ATTR_CT:
case OVS_ACTION_ATTR_CT_CLEAR:
case OVS_ACTION_ATTR_HASH:
case OVS_ACTION_ATTR_POP_ETH:
case OVS_ACTION_ATTR_POP_MPLS:
case OVS_ACTION_ATTR_POP_NSH:
case OVS_ACTION_ATTR_POP_VLAN:
case OVS_ACTION_ATTR_PUSH_ETH:
case OVS_ACTION_ATTR_PUSH_MPLS:
case OVS_ACTION_ATTR_PUSH_NSH:
case OVS_ACTION_ATTR_PUSH_VLAN:
case OVS_ACTION_ATTR_SAMPLE:
case OVS_ACTION_ATTR_SET:
case OVS_ACTION_ATTR_SET_MASKED:
case OVS_ACTION_ATTR_METER:
case OVS_ACTION_ATTR_CHECK_PKT_LEN:
case OVS_ACTION_ATTR_ADD_MPLS:
case OVS_ACTION_ATTR_DEC_TTL:
default:
return true;
}
}
return false;
}
| 0
|
333,088
|
list1(
nfa_state_T **outp)
{
Ptrlist *l;
l = (Ptrlist *)outp;
l->next = NULL;
return l;
}
| 0
|
468,339
|
g_socket_client_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GSocketClient *client = G_SOCKET_CLIENT (object);
switch (prop_id)
{
case PROP_FAMILY:
g_value_set_enum (value, client->priv->family);
break;
case PROP_TYPE:
g_value_set_enum (value, client->priv->type);
break;
case PROP_PROTOCOL:
g_value_set_enum (value, client->priv->protocol);
break;
case PROP_LOCAL_ADDRESS:
g_value_set_object (value, client->priv->local_address);
break;
case PROP_TIMEOUT:
g_value_set_uint (value, client->priv->timeout);
break;
case PROP_ENABLE_PROXY:
g_value_set_boolean (value, client->priv->enable_proxy);
break;
case PROP_TLS:
g_value_set_boolean (value, g_socket_client_get_tls (client));
break;
case PROP_TLS_VALIDATION_FLAGS:
g_value_set_flags (value, g_socket_client_get_tls_validation_flags (client));
break;
case PROP_PROXY_RESOLVER:
g_value_set_object (value, g_socket_client_get_proxy_resolver (client));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
| 0
|
292,193
|
inbound_open_dialog (server *serv, char *from,
const message_tags_data *tags_data)
{
session *sess;
sess = new_ircwindow (serv, from, SESS_DIALOG, 0);
/* for playing sounds */
EMIT_SIGNAL_TIMESTAMP (XP_TE_OPENDIALOG, sess, NULL, NULL, NULL, NULL, 0,
tags_data->timestamp);
return sess;
}
| 0
|
222,671
|
static int check_owned_directory_mode(const char *path, mode_t expected_mode)
{
struct stat stat;
if (lstat(path, &stat))
return -1;
if (!S_ISDIR(stat.st_mode))
return -1;
if (stat.st_uid != getuid())
return -1;
if ((stat.st_mode & 07777) != expected_mode)
return -1;
return 0;
}
| 0
|
498,628
|
query (void)
{
static const GimpParamDef load_args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_STRING, "filename", "The name of the file to load" },
{ GIMP_PDB_STRING, "raw-filename", "The name entered" }
};
static const GimpParamDef load_return_vals[] =
{
{ GIMP_PDB_IMAGE, "image", "Output image" }
};
static const GimpParamDef save_args[] =
{
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
{ GIMP_PDB_IMAGE, "image", "Input image" },
{ GIMP_PDB_DRAWABLE, "drawable", "Drawable to export" },
{ GIMP_PDB_STRING, "filename", "The name of the file to export the image in" },
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to export the image in" },
{ GIMP_PDB_INT32, "rle", "Use RLE compression" },
{ GIMP_PDB_INT32, "origin", "Image origin (0 = top-left, 1 = bottom-left)"}
} ;
gimp_install_procedure (LOAD_PROC,
"Loads files of Targa file format",
"FIXME: write help for tga_load",
"Raphael FRANCOIS, Gordon Matzigkeit",
"Raphael FRANCOIS, Gordon Matzigkeit",
"1997,2000,2007",
N_("TarGA image"),
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
load_args, load_return_vals);
gimp_register_file_handler_mime (LOAD_PROC, "image/x-tga");
gimp_register_magic_load_handler (LOAD_PROC,
"tga,vda,icb,vst",
"",
"-18&,string,TRUEVISION-XFILE.,-1,byte,0");
gimp_install_procedure (SAVE_PROC,
"exports files in the Targa file format",
"FIXME: write help for tga_save",
"Raphael FRANCOIS, Gordon Matzigkeit",
"Raphael FRANCOIS, Gordon Matzigkeit",
"1997,2000",
N_("TarGA image"),
"RGB*, GRAY*, INDEXED*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_register_file_handler_mime (SAVE_PROC, "image/x-tga");
gimp_register_save_handler (SAVE_PROC, "tga", "");
}
| 0
|
261,391
|
bool read_pred_weight_table(bitreader* br, slice_segment_header* shdr, decoder_context* ctx)
{
int vlc;
pic_parameter_set* pps = ctx->get_pps((int)shdr->slice_pic_parameter_set_id);
assert(pps);
seq_parameter_set* sps = ctx->get_sps((int)pps->seq_parameter_set_id);
assert(sps);
shdr->luma_log2_weight_denom = vlc = get_uvlc(br);
if (vlc<0 || vlc>7) return false;
if (sps->chroma_format_idc != 0) {
vlc = get_svlc(br);
vlc += shdr->luma_log2_weight_denom;
if (vlc<0 || vlc>7) return false;
shdr->ChromaLog2WeightDenom = vlc;
}
int sumWeightFlags = 0;
for (int l=0;l<=1;l++)
if (l==0 || (l==1 && shdr->slice_type == SLICE_TYPE_B))
{
int num_ref = (l==0 ? shdr->num_ref_idx_l0_active-1 : shdr->num_ref_idx_l1_active-1);
for (int i=0;i<=num_ref;i++) {
shdr->luma_weight_flag[l][i] = get_bits(br,1);
if (shdr->luma_weight_flag[l][i]) sumWeightFlags++;
}
if (sps->chroma_format_idc != 0) {
for (int i=0;i<=num_ref;i++) {
shdr->chroma_weight_flag[l][i] = get_bits(br,1);
if (shdr->chroma_weight_flag[l][i]) sumWeightFlags+=2;
}
}
for (int i=0;i<=num_ref;i++) {
if (shdr->luma_weight_flag[l][i]) {
// delta_luma_weight
vlc = get_svlc(br);
if (vlc < -128 || vlc > 127) return false;
shdr->LumaWeight[l][i] = (1<<shdr->luma_log2_weight_denom) + vlc;
// luma_offset
vlc = get_svlc(br);
if (vlc < -sps->WpOffsetHalfRangeY || vlc > sps->WpOffsetHalfRangeY-1) return false;
shdr->luma_offset[l][i] = vlc;
}
else {
shdr->LumaWeight[l][i] = 1<<shdr->luma_log2_weight_denom;
shdr->luma_offset[l][i] = 0;
}
if (shdr->chroma_weight_flag[l][i])
for (int j=0;j<2;j++) {
// delta_chroma_weight
vlc = get_svlc(br);
if (vlc < -128 || vlc > 127) return false;
shdr->ChromaWeight[l][i][j] = (1<<shdr->ChromaLog2WeightDenom) + vlc;
// delta_chroma_offset
vlc = get_svlc(br);
if (vlc < -4*sps->WpOffsetHalfRangeC ||
vlc > 4*sps->WpOffsetHalfRangeC-1) return false;
vlc = Clip3(-sps->WpOffsetHalfRangeC,
sps->WpOffsetHalfRangeC-1,
(sps->WpOffsetHalfRangeC
+vlc
-((sps->WpOffsetHalfRangeC*shdr->ChromaWeight[l][i][j])
>> shdr->ChromaLog2WeightDenom)));
shdr->ChromaOffset[l][i][j] = vlc;
}
else {
for (int j=0;j<2;j++) {
shdr->ChromaWeight[l][i][j] = 1<<shdr->ChromaLog2WeightDenom;
shdr->ChromaOffset[l][i][j] = 0;
}
}
}
}
// TODO: bitstream conformance requires that 'sumWeightFlags<=24'
return true;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.