idx
int64 | func
string | target
int64 |
|---|---|---|
244,003
|
GF_Err st3d_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_Stereo3DBox *ptr = (GF_Stereo3DBox *)s;
ISOM_DECREASE_SIZE(ptr, 1)
ptr->stereo_type = gf_bs_read_u8(bs);
return GF_OK;
}
| 0
|
314,755
|
cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h,
const cdf_sat_t *sat, cdf_secid_t sid, size_t len, cdf_stream_t *scn)
{
size_t ss = CDF_SEC_SIZE(h), i, j;
ssize_t nr;
scn->sst_len = cdf_count_chain(sat, sid, ss);
scn->sst_dirlen = len;
if (scn->sst_len == (size_t)-1)
return -1;
scn->sst_tab = calloc(scn->sst_len, ss);
if (scn->sst_tab == NULL)
return -1;
for (j = i = 0; sid >= 0; i++, j++) {
if (j >= CDF_LOOP_LIMIT) {
DPRINTF(("Read long sector chain loop limit"));
errno = EFTYPE;
goto out;
}
if (i >= scn->sst_len) {
DPRINTF(("Out of bounds reading long sector chain "
"%" SIZE_T_FORMAT "u > %" SIZE_T_FORMAT "u\n", i,
scn->sst_len));
errno = EFTYPE;
goto out;
}
if ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h,
sid)) != (ssize_t)ss) {
if (i == scn->sst_len - 1 && nr > 0) {
/* Last sector might be truncated */
return 0;
}
DPRINTF(("Reading long sector chain %d", sid));
goto out;
}
sid = CDF_TOLE4((uint32_t)sat->sat_tab[sid]);
}
return 0;
out:
free(scn->sst_tab);
return -1;
}
| 0
|
221,164
|
GF_Err gf_odf_write_descriptor_list_filter(GF_BitStream *bs, GF_List *descList, u8 only_tag)
{
GF_Err e;
u32 count, i;
if (! descList) return GF_OK;
count = gf_list_count(descList);
for ( i = 0; i < count; i++ ) {
GF_Descriptor *tmp = (GF_Descriptor*)gf_list_get(descList, i);
if (tmp && (tmp->tag==only_tag) ) {
e = gf_odf_write_descriptor(bs, tmp);
if (e) return e;
}
}
return GF_OK;
}
| 0
|
359,331
|
DEFUN (ip_community_list_expanded,
ip_community_list_expanded_cmd,
"ip community-list <100-500> (deny|permit) .LINE",
IP_STR
COMMUNITY_LIST_STR
"Community list number (expanded)\n"
"Specify community to reject\n"
"Specify community to accept\n"
"An ordered list as a regular-expression\n")
{
return community_list_set_vty (vty, argc, argv, COMMUNITY_LIST_EXPANDED, 0);
}
| 0
|
211,102
|
extract_archive_thread (GSimpleAsyncResult *result,
GObject *object,
GCancellable *cancellable)
{
ExtractData *extract_data;
LoadData *load_data;
GHashTable *checked_folders;
struct archive *a;
struct archive_entry *entry;
int r;
extract_data = g_simple_async_result_get_op_res_gpointer (result);
load_data = LOAD_DATA (extract_data);
checked_folders = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
fr_archive_progress_set_total_files (load_data->archive, extract_data->n_files_to_extract);
a = archive_read_new ();
archive_read_support_filter_all (a);
archive_read_support_format_all (a);
archive_read_open (a, load_data, load_data_open, load_data_read, load_data_close);
while ((r = archive_read_next_header (a, &entry)) == ARCHIVE_OK) {
const char *pathname;
char *fullpath;
GFile *file;
GFile *parent;
GOutputStream *ostream;
const void *buffer;
size_t buffer_size;
int64_t offset;
GError *local_error = NULL;
__LA_MODE_T filetype;
if (g_cancellable_is_cancelled (cancellable))
break;
pathname = archive_entry_pathname (entry);
if (! extract_data_get_extraction_requested (extract_data, pathname)) {
archive_read_data_skip (a);
continue;
}
fullpath = (*pathname == '/') ? g_strdup (pathname) : g_strconcat ("/", pathname, NULL);
file = g_file_get_child (extract_data->destination, _g_path_get_relative_basename (fullpath, extract_data->base_dir, extract_data->junk_paths));
/* honor the skip_older and overwrite options */
if (extract_data->skip_older || ! extract_data->overwrite) {
GFileInfo *info;
info = g_file_query_info (file,
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME "," G_FILE_ATTRIBUTE_TIME_MODIFIED,
G_FILE_QUERY_INFO_NONE,
cancellable,
&local_error);
if (info != NULL) {
gboolean skip = FALSE;
if (! extract_data->overwrite) {
skip = TRUE;
}
else if (extract_data->skip_older) {
GTimeVal modification_time;
g_file_info_get_modification_time (info, &modification_time);
if (archive_entry_mtime (entry) < modification_time.tv_sec)
skip = TRUE;
}
g_object_unref (info);
if (skip) {
g_object_unref (file);
archive_read_data_skip (a);
fr_archive_progress_inc_completed_bytes (load_data->archive, archive_entry_size_is_set (entry) ? archive_entry_size (entry) : 0);
if ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {
r = ARCHIVE_EOF;
break;
}
continue;
}
}
else {
if (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
load_data->error = local_error;
g_object_unref (info);
break;
}
g_error_free (local_error);
}
}
fr_archive_progress_inc_completed_files (load_data->archive, 1);
/* create the file parents */
parent = g_file_get_parent (file);
if ((parent != NULL)
&& (g_hash_table_lookup (checked_folders, parent) == NULL)
&& ! g_file_query_exists (parent, cancellable))
{
if (g_file_make_directory_with_parents (parent, cancellable, &load_data->error)) {
GFile *grandparent;
grandparent = g_object_ref (parent);
while (grandparent != NULL) {
if (g_hash_table_lookup (checked_folders, grandparent) == NULL)
g_hash_table_insert (checked_folders, grandparent, GINT_TO_POINTER (1));
grandparent = g_file_get_parent (grandparent);
}
}
}
g_object_unref (parent);
/* create the file */
filetype = archive_entry_filetype (entry);
if (load_data->error == NULL) {
const char *linkname;
linkname = archive_entry_hardlink (entry);
if (linkname != NULL) {
char *link_fullpath;
GFile *link_file;
char *oldname;
char *newname;
int r;
link_fullpath = (*linkname == '/') ? g_strdup (linkname) : g_strconcat ("/", linkname, NULL);
link_file = g_file_get_child (extract_data->destination, _g_path_get_relative_basename (link_fullpath, extract_data->base_dir, extract_data->junk_paths));
oldname = g_file_get_path (link_file);
newname = g_file_get_path (file);
if ((oldname != NULL) && (newname != NULL))
r = link (oldname, newname);
else
r = -1;
if (r == 0) {
__LA_INT64_T filesize;
if (archive_entry_size_is_set (entry))
filesize = archive_entry_size (entry);
else
filesize = -1;
if (filesize > 0)
filetype = AE_IFREG; /* treat as a regular file to save the data */
}
else {
char *uri;
char *msg;
uri = g_file_get_uri (file);
msg = g_strdup_printf ("Could not create the hard link %s", uri);
load_data->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, msg);
g_free (msg);
g_free (uri);
}
g_free (newname);
g_free (oldname);
g_object_unref (link_file);
g_free (link_fullpath);
}
}
if (load_data->error == NULL) {
switch (filetype) {
case AE_IFDIR:
if (! g_file_make_directory (file, cancellable, &local_error)) {
if (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
load_data->error = g_error_copy (local_error);
g_error_free (local_error);
}
else
_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);
archive_read_data_skip (a);
break;
case AE_IFREG:
ostream = (GOutputStream *) g_file_replace (file, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION, cancellable, &load_data->error);
if (ostream == NULL)
break;
while ((r = archive_read_data_block (a, &buffer, &buffer_size, &offset)) == ARCHIVE_OK) {
if (g_output_stream_write (ostream, buffer, buffer_size, cancellable, &load_data->error) == -1)
break;
fr_archive_progress_inc_completed_bytes (load_data->archive, buffer_size);
}
_g_object_unref (ostream);
if (r != ARCHIVE_EOF)
load_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));
else
_g_file_set_attributes_from_entry (file, entry, extract_data, cancellable);
break;
case AE_IFLNK:
if (! g_file_make_symbolic_link (file, archive_entry_symlink (entry), cancellable, &local_error)) {
if (! g_error_matches (local_error, G_IO_ERROR, G_IO_ERROR_EXISTS))
load_data->error = g_error_copy (local_error);
g_error_free (local_error);
}
archive_read_data_skip (a);
break;
default:
archive_read_data_skip (a);
break;
}
}
g_object_unref (file);
g_free (fullpath);
if (load_data->error != NULL)
break;
if ((extract_data->file_list != NULL) && (--extract_data->n_files_to_extract == 0)) {
r = ARCHIVE_EOF;
break;
}
}
if ((load_data->error == NULL) && (r != ARCHIVE_EOF))
load_data->error = g_error_new_literal (FR_ERROR, FR_ERROR_COMMAND_ERROR, archive_error_string (a));
if (load_data->error == NULL)
g_cancellable_set_error_if_cancelled (cancellable, &load_data->error);
if (load_data->error != NULL)
g_simple_async_result_set_from_error (result, load_data->error);
g_hash_table_unref (checked_folders);
archive_read_free (a);
extract_data_free (extract_data);
}
| 1
|
198,512
|
mrb_vm_exec(mrb_state *mrb, const struct RProc *proc, const mrb_code *pc)
{
/* mrb_assert(MRB_PROC_CFUNC_P(proc)) */
const mrb_irep *irep = proc->body.irep;
const mrb_pool_value *pool = irep->pool;
const mrb_sym *syms = irep->syms;
mrb_code insn;
int ai = mrb_gc_arena_save(mrb);
struct mrb_jmpbuf *prev_jmp = mrb->jmp;
struct mrb_jmpbuf c_jmp;
uint32_t a;
uint16_t b;
uint16_t c;
mrb_sym mid;
const struct mrb_irep_catch_handler *ch;
#ifdef DIRECT_THREADED
static const void * const optable[] = {
#define OPCODE(x,_) &&L_OP_ ## x,
#include "mruby/ops.h"
#undef OPCODE
};
#endif
mrb_bool exc_catched = FALSE;
RETRY_TRY_BLOCK:
MRB_TRY(&c_jmp) {
if (exc_catched) {
exc_catched = FALSE;
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc && mrb->exc->tt == MRB_TT_BREAK)
goto L_BREAK;
goto L_RAISE;
}
mrb->jmp = &c_jmp;
mrb_vm_ci_proc_set(mrb->c->ci, proc);
#define regs (mrb->c->ci->stack)
INIT_DISPATCH {
CASE(OP_NOP, Z) {
/* do nothing */
NEXT;
}
CASE(OP_MOVE, BB) {
regs[a] = regs[b];
NEXT;
}
CASE(OP_LOADL, BB) {
switch (pool[b].tt) { /* number */
case IREP_TT_INT32:
regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i32);
break;
case IREP_TT_INT64:
#if defined(MRB_INT64)
regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);
break;
#else
#if defined(MRB_64BIT)
if (INT32_MIN <= pool[b].u.i64 && pool[b].u.i64 <= INT32_MAX) {
regs[a] = mrb_int_value(mrb, (mrb_int)pool[b].u.i64);
break;
}
#endif
goto L_INT_OVERFLOW;
#endif
case IREP_TT_BIGINT:
goto L_INT_OVERFLOW;
#ifndef MRB_NO_FLOAT
case IREP_TT_FLOAT:
regs[a] = mrb_float_value(mrb, pool[b].u.f);
break;
#endif
default:
/* should not happen (tt:string) */
regs[a] = mrb_nil_value();
break;
}
NEXT;
}
CASE(OP_LOADI, BB) {
SET_FIXNUM_VALUE(regs[a], b);
NEXT;
}
CASE(OP_LOADINEG, BB) {
SET_FIXNUM_VALUE(regs[a], -b);
NEXT;
}
CASE(OP_LOADI__1,B) goto L_LOADI;
CASE(OP_LOADI_0,B) goto L_LOADI;
CASE(OP_LOADI_1,B) goto L_LOADI;
CASE(OP_LOADI_2,B) goto L_LOADI;
CASE(OP_LOADI_3,B) goto L_LOADI;
CASE(OP_LOADI_4,B) goto L_LOADI;
CASE(OP_LOADI_5,B) goto L_LOADI;
CASE(OP_LOADI_6,B) goto L_LOADI;
CASE(OP_LOADI_7, B) {
L_LOADI:
SET_FIXNUM_VALUE(regs[a], (mrb_int)insn - (mrb_int)OP_LOADI_0);
NEXT;
}
CASE(OP_LOADI16, BS) {
SET_FIXNUM_VALUE(regs[a], (mrb_int)(int16_t)b);
NEXT;
}
CASE(OP_LOADI32, BSS) {
SET_INT_VALUE(mrb, regs[a], (int32_t)(((uint32_t)b<<16)+c));
NEXT;
}
CASE(OP_LOADSYM, BB) {
SET_SYM_VALUE(regs[a], syms[b]);
NEXT;
}
CASE(OP_LOADNIL, B) {
SET_NIL_VALUE(regs[a]);
NEXT;
}
CASE(OP_LOADSELF, B) {
regs[a] = regs[0];
NEXT;
}
CASE(OP_LOADT, B) {
SET_TRUE_VALUE(regs[a]);
NEXT;
}
CASE(OP_LOADF, B) {
SET_FALSE_VALUE(regs[a]);
NEXT;
}
CASE(OP_GETGV, BB) {
mrb_value val = mrb_gv_get(mrb, syms[b]);
regs[a] = val;
NEXT;
}
CASE(OP_SETGV, BB) {
mrb_gv_set(mrb, syms[b], regs[a]);
NEXT;
}
CASE(OP_GETSV, BB) {
mrb_value val = mrb_vm_special_get(mrb, syms[b]);
regs[a] = val;
NEXT;
}
CASE(OP_SETSV, BB) {
mrb_vm_special_set(mrb, syms[b], regs[a]);
NEXT;
}
CASE(OP_GETIV, BB) {
regs[a] = mrb_iv_get(mrb, regs[0], syms[b]);
NEXT;
}
CASE(OP_SETIV, BB) {
mrb_iv_set(mrb, regs[0], syms[b], regs[a]);
NEXT;
}
CASE(OP_GETCV, BB) {
mrb_value val;
val = mrb_vm_cv_get(mrb, syms[b]);
regs[a] = val;
NEXT;
}
CASE(OP_SETCV, BB) {
mrb_vm_cv_set(mrb, syms[b], regs[a]);
NEXT;
}
CASE(OP_GETIDX, B) {
mrb_value va = regs[a], vb = regs[a+1];
switch (mrb_type(va)) {
case MRB_TT_ARRAY:
if (!mrb_integer_p(vb)) goto getidx_fallback;
regs[a] = mrb_ary_entry(va, mrb_integer(vb));
break;
case MRB_TT_HASH:
va = mrb_hash_get(mrb, va, vb);
regs[a] = va;
break;
case MRB_TT_STRING:
switch (mrb_type(vb)) {
case MRB_TT_INTEGER:
case MRB_TT_STRING:
case MRB_TT_RANGE:
va = mrb_str_aref(mrb, va, vb, mrb_undef_value());
regs[a] = va;
break;
default:
goto getidx_fallback;
}
break;
default:
getidx_fallback:
mid = MRB_OPSYM(aref);
goto L_SEND_SYM;
}
NEXT;
}
CASE(OP_SETIDX, B) {
c = 2;
mid = MRB_OPSYM(aset);
SET_NIL_VALUE(regs[a+3]);
goto L_SENDB_SYM;
}
CASE(OP_GETCONST, BB) {
mrb_value v = mrb_vm_const_get(mrb, syms[b]);
regs[a] = v;
NEXT;
}
CASE(OP_SETCONST, BB) {
mrb_vm_const_set(mrb, syms[b], regs[a]);
NEXT;
}
CASE(OP_GETMCNST, BB) {
mrb_value v = mrb_const_get(mrb, regs[a], syms[b]);
regs[a] = v;
NEXT;
}
CASE(OP_SETMCNST, BB) {
mrb_const_set(mrb, regs[a+1], syms[b], regs[a]);
NEXT;
}
CASE(OP_GETUPVAR, BBB) {
mrb_value *regs_a = regs + a;
struct REnv *e = uvenv(mrb, c);
if (e && b < MRB_ENV_LEN(e)) {
*regs_a = e->stack[b];
}
else {
*regs_a = mrb_nil_value();
}
NEXT;
}
CASE(OP_SETUPVAR, BBB) {
struct REnv *e = uvenv(mrb, c);
if (e) {
mrb_value *regs_a = regs + a;
if (b < MRB_ENV_LEN(e)) {
e->stack[b] = *regs_a;
mrb_write_barrier(mrb, (struct RBasic*)e);
}
}
NEXT;
}
CASE(OP_JMP, S) {
pc += (int16_t)a;
JUMP;
}
CASE(OP_JMPIF, BS) {
if (mrb_test(regs[a])) {
pc += (int16_t)b;
JUMP;
}
NEXT;
}
CASE(OP_JMPNOT, BS) {
if (!mrb_test(regs[a])) {
pc += (int16_t)b;
JUMP;
}
NEXT;
}
CASE(OP_JMPNIL, BS) {
if (mrb_nil_p(regs[a])) {
pc += (int16_t)b;
JUMP;
}
NEXT;
}
CASE(OP_JMPUW, S) {
a = (uint32_t)((pc - irep->iseq) + (int16_t)a);
CHECKPOINT_RESTORE(RBREAK_TAG_JUMP) {
struct RBreak *brk = (struct RBreak*)mrb->exc;
mrb_value target = mrb_break_value_get(brk);
mrb_assert(mrb_integer_p(target));
a = (uint32_t)mrb_integer(target);
mrb_assert(a >= 0 && a < irep->ilen);
}
CHECKPOINT_MAIN(RBREAK_TAG_JUMP) {
ch = catch_handler_find(mrb, mrb->c->ci, pc, MRB_CATCH_FILTER_ENSURE);
if (ch) {
/* avoiding a jump from a catch handler into the same handler */
if (a < mrb_irep_catch_handler_unpack(ch->begin) || a >= mrb_irep_catch_handler_unpack(ch->end)) {
THROW_TAGGED_BREAK(mrb, RBREAK_TAG_JUMP, proc, mrb_fixnum_value(a));
}
}
}
CHECKPOINT_END(RBREAK_TAG_JUMP);
mrb->exc = NULL; /* clear break object */
pc = irep->iseq + a;
JUMP;
}
CASE(OP_EXCEPT, B) {
mrb_value exc;
if (mrb->exc == NULL) {
exc = mrb_nil_value();
}
else {
switch (mrb->exc->tt) {
case MRB_TT_BREAK:
case MRB_TT_EXCEPTION:
exc = mrb_obj_value(mrb->exc);
break;
default:
mrb_assert(!"bad mrb_type");
exc = mrb_nil_value();
break;
}
mrb->exc = NULL;
}
regs[a] = exc;
NEXT;
}
CASE(OP_RESCUE, BB) {
mrb_value exc = regs[a]; /* exc on stack */
mrb_value e = regs[b];
struct RClass *ec;
switch (mrb_type(e)) {
case MRB_TT_CLASS:
case MRB_TT_MODULE:
break;
default:
{
mrb_value exc;
exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
"class or module required for rescue clause");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
}
ec = mrb_class_ptr(e);
regs[b] = mrb_bool_value(mrb_obj_is_kind_of(mrb, exc, ec));
NEXT;
}
CASE(OP_RAISEIF, B) {
mrb_value exc = regs[a];
if (mrb_break_p(exc)) {
mrb->exc = mrb_obj_ptr(exc);
goto L_BREAK;
}
mrb_exc_set(mrb, exc);
if (mrb->exc) {
goto L_RAISE;
}
NEXT;
}
CASE(OP_SSEND, BBB) {
regs[a] = regs[0];
insn = OP_SEND;
}
goto L_SENDB;
CASE(OP_SSENDB, BBB) {
regs[a] = regs[0];
}
goto L_SENDB;
CASE(OP_SEND, BBB)
goto L_SENDB;
L_SEND_SYM:
c = 1;
/* push nil after arguments */
SET_NIL_VALUE(regs[a+2]);
goto L_SENDB_SYM;
CASE(OP_SENDB, BBB)
L_SENDB:
mid = syms[b];
L_SENDB_SYM:
{
mrb_callinfo *ci = mrb->c->ci;
mrb_method_t m;
struct RClass *cls;
mrb_value recv, blk;
ARGUMENT_NORMALIZE(a, &c, insn);
recv = regs[a];
cls = mrb_class(mrb, recv);
m = mrb_method_search_vm(mrb, &cls, mid);
if (MRB_METHOD_UNDEF_P(m)) {
m = prepare_missing(mrb, recv, mid, &cls, a, &c, blk, 0);
mid = MRB_SYM(method_missing);
}
/* push callinfo */
ci = cipush(mrb, a, 0, cls, NULL, mid, c);
if (MRB_METHOD_CFUNC_P(m)) {
if (MRB_METHOD_PROC_P(m)) {
struct RProc *p = MRB_METHOD_PROC(m);
mrb_vm_ci_proc_set(ci, p);
recv = p->body.func(mrb, recv);
}
else {
if (MRB_METHOD_NOARG_P(m)) {
check_method_noarg(mrb, ci);
}
recv = MRB_METHOD_FUNC(m)(mrb, recv);
}
mrb_gc_arena_shrink(mrb, ai);
if (mrb->exc) goto L_RAISE;
ci = mrb->c->ci;
if (mrb_proc_p(blk)) {
struct RProc *p = mrb_proc_ptr(blk);
if (p && !MRB_PROC_STRICT_P(p) && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {
p->flags |= MRB_PROC_ORPHAN;
}
}
if (!ci->u.target_class) { /* return from context modifying method (resume/yield) */
if (ci->cci == CINFO_RESUMED) {
mrb->jmp = prev_jmp;
return recv;
}
else {
mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));
proc = ci[-1].proc;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
}
}
ci->stack[0] = recv;
/* pop stackpos */
ci = cipop(mrb);
pc = ci->pc;
}
else {
/* setup environment for calling method */
mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);
pc = irep->iseq;
}
}
JUMP;
CASE(OP_CALL, Z) {
mrb_callinfo *ci = mrb->c->ci;
mrb_value recv = ci->stack[0];
struct RProc *m = mrb_proc_ptr(recv);
/* replace callinfo */
ci->u.target_class = MRB_PROC_TARGET_CLASS(m);
mrb_vm_ci_proc_set(ci, m);
if (MRB_PROC_ENV_P(m)) {
ci->mid = MRB_PROC_ENV(m)->mid;
}
/* prepare stack */
if (MRB_PROC_CFUNC_P(m)) {
recv = MRB_PROC_CFUNC(m)(mrb, recv);
mrb_gc_arena_shrink(mrb, ai);
if (mrb->exc) goto L_RAISE;
/* pop stackpos */
ci = cipop(mrb);
pc = ci->pc;
ci[1].stack[0] = recv;
irep = mrb->c->ci->proc->body.irep;
}
else {
/* setup environment for calling method */
proc = m;
irep = m->body.irep;
if (!irep) {
mrb->c->ci->stack[0] = mrb_nil_value();
a = 0;
c = OP_R_NORMAL;
goto L_OP_RETURN_BODY;
}
mrb_int nargs = mrb_ci_bidx(ci)+1;
if (nargs < irep->nregs) {
mrb_stack_extend(mrb, irep->nregs);
stack_clear(regs+nargs, irep->nregs-nargs);
}
if (MRB_PROC_ENV_P(m)) {
regs[0] = MRB_PROC_ENV(m)->stack[0];
}
pc = irep->iseq;
}
pool = irep->pool;
syms = irep->syms;
JUMP;
}
CASE(OP_SUPER, BB) {
mrb_method_t m;
struct RClass *cls;
mrb_callinfo *ci = mrb->c->ci;
mrb_value recv, blk;
const struct RProc *p = ci->proc;
mrb_sym mid = ci->mid;
struct RClass* target_class = MRB_PROC_TARGET_CLASS(p);
if (MRB_PROC_ENV_P(p) && p->e.env->mid && p->e.env->mid != mid) { /* alias support */
mid = p->e.env->mid; /* restore old mid */
}
if (mid == 0 || !target_class) {
mrb_value exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
if (target_class->flags & MRB_FL_CLASS_IS_PREPENDED) {
target_class = mrb_vm_ci_target_class(ci);
}
else if (target_class->tt == MRB_TT_MODULE) {
target_class = mrb_vm_ci_target_class(ci);
if (target_class->tt != MRB_TT_ICLASS) {
goto super_typeerror;
}
}
recv = regs[0];
if (!mrb_obj_is_kind_of(mrb, recv, target_class)) {
super_typeerror: ;
mrb_value exc = mrb_exc_new_lit(mrb, E_TYPE_ERROR,
"self has wrong type to call super in this context");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
ARGUMENT_NORMALIZE(a, &b, OP_SUPER);
cls = target_class->super;
m = mrb_method_search_vm(mrb, &cls, mid);
if (MRB_METHOD_UNDEF_P(m)) {
m = prepare_missing(mrb, recv, mid, &cls, a, &b, blk, 1);
mid = MRB_SYM(method_missing);
}
/* push callinfo */
ci = cipush(mrb, a, 0, cls, NULL, mid, b);
/* prepare stack */
ci->stack[0] = recv;
if (MRB_METHOD_CFUNC_P(m)) {
mrb_value v;
if (MRB_METHOD_PROC_P(m)) {
mrb_vm_ci_proc_set(ci, MRB_METHOD_PROC(m));
}
v = MRB_METHOD_CFUNC(m)(mrb, recv);
mrb_gc_arena_restore(mrb, ai);
if (mrb->exc) goto L_RAISE;
ci = mrb->c->ci;
mrb_assert(!mrb_break_p(v));
if (!mrb_vm_ci_target_class(ci)) { /* return from context modifying method (resume/yield) */
if (ci->cci == CINFO_RESUMED) {
mrb->jmp = prev_jmp;
return v;
}
else {
mrb_assert(!MRB_PROC_CFUNC_P(ci[-1].proc));
proc = ci[-1].proc;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
}
}
mrb->c->ci->stack[0] = v;
ci = cipop(mrb);
pc = ci->pc;
}
else {
/* setup environment for calling method */
mrb_vm_ci_proc_set(ci, (proc = MRB_METHOD_PROC(m)));
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
mrb_stack_extend(mrb, (irep->nregs < 4) ? 4 : irep->nregs);
pc = irep->iseq;
}
JUMP;
}
CASE(OP_ARGARY, BS) {
mrb_int m1 = (b>>11)&0x3f;
mrb_int r = (b>>10)&0x1;
mrb_int m2 = (b>>5)&0x1f;
mrb_int kd = (b>>4)&0x1;
mrb_int lv = (b>>0)&0xf;
mrb_value *stack;
if (mrb->c->ci->mid == 0 || mrb_vm_ci_target_class(mrb->c->ci) == NULL) {
mrb_value exc;
L_NOSUPER:
exc = mrb_exc_new_lit(mrb, E_NOMETHOD_ERROR, "super called outside of method");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
if (lv == 0) stack = regs + 1;
else {
struct REnv *e = uvenv(mrb, lv-1);
if (!e) goto L_NOSUPER;
if (MRB_ENV_LEN(e) <= m1+r+m2+1)
goto L_NOSUPER;
stack = e->stack + 1;
}
if (r == 0) {
regs[a] = mrb_ary_new_from_values(mrb, m1+m2, stack);
}
else {
mrb_value *pp = NULL;
struct RArray *rest;
mrb_int len = 0;
if (mrb_array_p(stack[m1])) {
struct RArray *ary = mrb_ary_ptr(stack[m1]);
pp = ARY_PTR(ary);
len = ARY_LEN(ary);
}
regs[a] = mrb_ary_new_capa(mrb, m1+len+m2);
rest = mrb_ary_ptr(regs[a]);
if (m1 > 0) {
stack_copy(ARY_PTR(rest), stack, m1);
}
if (len > 0) {
stack_copy(ARY_PTR(rest)+m1, pp, len);
}
if (m2 > 0) {
stack_copy(ARY_PTR(rest)+m1+len, stack+m1+1, m2);
}
ARY_SET_LEN(rest, m1+len+m2);
}
if (kd) {
regs[a+1] = stack[m1+r+m2];
regs[a+2] = stack[m1+r+m2+1];
}
else {
regs[a+1] = stack[m1+r+m2];
}
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_ENTER, W) {
mrb_int m1 = MRB_ASPEC_REQ(a);
mrb_int o = MRB_ASPEC_OPT(a);
mrb_int r = MRB_ASPEC_REST(a);
mrb_int m2 = MRB_ASPEC_POST(a);
mrb_int kd = (MRB_ASPEC_KEY(a) > 0 || MRB_ASPEC_KDICT(a))? 1 : 0;
/* unused
int b = MRB_ASPEC_BLOCK(a);
*/
mrb_int const len = m1 + o + r + m2;
mrb_callinfo *ci = mrb->c->ci;
mrb_int argc = ci->n;
mrb_value *argv = regs+1;
mrb_value * const argv0 = argv;
mrb_int const kw_pos = len + kd; /* where kwhash should be */
mrb_int const blk_pos = kw_pos + 1; /* where block should be */
mrb_value blk = regs[mrb_ci_bidx(ci)];
mrb_value kdict = mrb_nil_value();
/* keyword arguments */
if (ci->nk > 0) {
mrb_int kidx = mrb_ci_kidx(ci);
kdict = regs[kidx];
if (!mrb_hash_p(kdict) || mrb_hash_size(mrb, kdict) == 0) {
kdict = mrb_nil_value();
ci->nk = 0;
}
}
if (!kd && !mrb_nil_p(kdict)) {
if (argc < 14) {
ci->n++;
argc++; /* include kdict in normal arguments */
}
else if (argc == 14) {
/* pack arguments and kdict */
regs[1] = mrb_ary_new_from_values(mrb, argc+1, ®s[1]);
argc = ci->n = 15;
}
else {/* argc == 15 */
/* push kdict to packed arguments */
mrb_ary_push(mrb, regs[1], regs[2]);
}
ci->nk = 0;
}
if (kd && MRB_ASPEC_KEY(a) > 0 && mrb_hash_p(kdict)) {
kdict = mrb_hash_dup(mrb, kdict);
}
/* arguments is passed with Array */
if (argc == 15) {
struct RArray *ary = mrb_ary_ptr(regs[1]);
argv = ARY_PTR(ary);
argc = (int)ARY_LEN(ary);
mrb_gc_protect(mrb, regs[1]);
}
/* strict argument check */
if (ci->proc && MRB_PROC_STRICT_P(ci->proc)) {
if (argc < m1 + m2 || (r == 0 && argc > len)) {
argnum_error(mrb, m1+m2);
goto L_RAISE;
}
}
/* extract first argument array to arguments */
else if (len > 1 && argc == 1 && mrb_array_p(argv[0])) {
mrb_gc_protect(mrb, argv[0]);
argc = (int)RARRAY_LEN(argv[0]);
argv = RARRAY_PTR(argv[0]);
}
/* rest arguments */
mrb_value rest = mrb_nil_value();
if (argc < len) {
mrb_int mlen = m2;
if (argc < m1+m2) {
mlen = m1 < argc ? argc - m1 : 0;
}
/* copy mandatory and optional arguments */
if (argv0 != argv && argv) {
value_move(®s[1], argv, argc-mlen); /* m1 + o */
}
if (argc < m1) {
stack_clear(®s[argc+1], m1-argc);
}
/* copy post mandatory arguments */
if (mlen) {
value_move(®s[len-m2+1], &argv[argc-mlen], mlen);
}
if (mlen < m2) {
stack_clear(®s[len-m2+mlen+1], m2-mlen);
}
/* initialize rest arguments with empty Array */
if (r) {
rest = mrb_ary_new_capa(mrb, 0);
regs[m1+o+1] = rest;
}
/* skip initializer of passed arguments */
if (o > 0 && argc > m1+m2)
pc += (argc - m1 - m2)*3;
}
else {
mrb_int rnum = 0;
if (argv0 != argv) {
value_move(®s[1], argv, m1+o);
}
if (r) {
rnum = argc-m1-o-m2;
rest = mrb_ary_new_from_values(mrb, rnum, argv+m1+o);
regs[m1+o+1] = rest;
}
if (m2 > 0 && argc-m2 > m1) {
value_move(®s[m1+o+r+1], &argv[m1+o+rnum], m2);
}
pc += o*3;
}
/* need to be update blk first to protect blk from GC */
regs[blk_pos] = blk; /* move block */
if (kd) {
if (mrb_nil_p(kdict))
kdict = mrb_hash_new_capa(mrb, 0);
regs[kw_pos] = kdict; /* set kwhash */
}
/* format arguments for generated code */
mrb->c->ci->n = len;
/* clear local (but non-argument) variables */
if (irep->nlocals-blk_pos-1 > 0) {
stack_clear(®s[blk_pos+1], irep->nlocals-blk_pos-1);
}
JUMP;
}
CASE(OP_KARG, BB) {
mrb_value k = mrb_symbol_value(syms[b]);
mrb_int kidx = mrb_ci_kidx(mrb->c->ci);
mrb_value kdict, v;
if (kidx < 0 || !mrb_hash_p(kdict=regs[kidx]) || !mrb_hash_key_p(mrb, kdict, k)) {
mrb_value str = mrb_format(mrb, "missing keyword: %v", k);
mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));
goto L_RAISE;
}
v = mrb_hash_get(mrb, kdict, k);
regs[a] = v;
mrb_hash_delete_key(mrb, kdict, k);
NEXT;
}
CASE(OP_KEY_P, BB) {
mrb_value k = mrb_symbol_value(syms[b]);
mrb_int kidx = mrb_ci_kidx(mrb->c->ci);
mrb_value kdict;
mrb_bool key_p = FALSE;
if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx])) {
key_p = mrb_hash_key_p(mrb, kdict, k);
}
regs[a] = mrb_bool_value(key_p);
NEXT;
}
CASE(OP_KEYEND, Z) {
mrb_int kidx = mrb_ci_kidx(mrb->c->ci);
mrb_value kdict;
if (kidx >= 0 && mrb_hash_p(kdict=regs[kidx]) && !mrb_hash_empty_p(mrb, kdict)) {
mrb_value keys = mrb_hash_keys(mrb, kdict);
mrb_value key1 = RARRAY_PTR(keys)[0];
mrb_value str = mrb_format(mrb, "unknown keyword: %v", key1);
mrb_exc_set(mrb, mrb_exc_new_str(mrb, E_ARGUMENT_ERROR, str));
goto L_RAISE;
}
NEXT;
}
CASE(OP_BREAK, B) {
c = OP_R_BREAK;
goto L_RETURN;
}
CASE(OP_RETURN_BLK, B) {
c = OP_R_RETURN;
goto L_RETURN;
}
CASE(OP_RETURN, B)
c = OP_R_NORMAL;
L_RETURN:
{
mrb_callinfo *ci;
ci = mrb->c->ci;
if (ci->mid) {
mrb_value blk = regs[mrb_ci_bidx(ci)];
if (mrb_proc_p(blk)) {
struct RProc *p = mrb_proc_ptr(blk);
if (!MRB_PROC_STRICT_P(p) &&
ci > mrb->c->cibase && MRB_PROC_ENV(p) == mrb_vm_ci_env(&ci[-1])) {
p->flags |= MRB_PROC_ORPHAN;
}
}
}
if (mrb->exc) {
L_RAISE:
ci = mrb->c->ci;
if (ci == mrb->c->cibase) {
ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);
if (ch == NULL) goto L_FTOP;
goto L_CATCH;
}
while ((ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL)) == NULL) {
ci = cipop(mrb);
if (ci[1].cci == CINFO_SKIP && prev_jmp) {
mrb->jmp = prev_jmp;
MRB_THROW(prev_jmp);
}
pc = ci[0].pc;
if (ci == mrb->c->cibase) {
ch = catch_handler_find(mrb, ci, pc, MRB_CATCH_FILTER_ALL);
if (ch == NULL) {
L_FTOP: /* fiber top */
if (mrb->c == mrb->root_c) {
mrb->c->ci->stack = mrb->c->stbase;
goto L_STOP;
}
else {
struct mrb_context *c = mrb->c;
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
c->prev = NULL;
goto L_RAISE;
}
}
break;
}
}
L_CATCH:
if (ch == NULL) goto L_STOP;
if (FALSE) {
L_CATCH_TAGGED_BREAK: /* from THROW_TAGGED_BREAK() or UNWIND_ENSURE() */
ci = mrb->c->ci;
}
proc = ci->proc;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
mrb_stack_extend(mrb, irep->nregs);
pc = irep->iseq + mrb_irep_catch_handler_unpack(ch->target);
}
else {
mrb_int acc;
mrb_value v;
ci = mrb->c->ci;
v = regs[a];
mrb_gc_protect(mrb, v);
switch (c) {
case OP_R_RETURN:
/* Fall through to OP_R_NORMAL otherwise */
if (ci->cci == CINFO_NONE && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {
const struct RProc *dst;
mrb_callinfo *cibase;
cibase = mrb->c->cibase;
dst = top_proc(mrb, proc);
if (MRB_PROC_ENV_P(dst)) {
struct REnv *e = MRB_PROC_ENV(dst);
if (!MRB_ENV_ONSTACK_P(e) || (e->cxt && e->cxt != mrb->c)) {
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
}
/* check jump destination */
while (cibase <= ci && ci->proc != dst) {
if (ci->cci > CINFO_NONE) { /* jump cross C boundary */
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
ci--;
}
if (ci <= cibase) { /* no jump destination */
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
ci = mrb->c->ci;
while (cibase <= ci && ci->proc != dst) {
CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_BLOCK) {
cibase = mrb->c->cibase;
dst = top_proc(mrb, proc);
}
CHECKPOINT_MAIN(RBREAK_TAG_RETURN_BLOCK) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_BLOCK, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_RETURN_BLOCK);
ci = cipop(mrb);
pc = ci->pc;
}
proc = ci->proc;
mrb->exc = NULL; /* clear break object */
break;
}
/* fallthrough */
case OP_R_NORMAL:
NORMAL_RETURN:
if (ci == mrb->c->cibase) {
struct mrb_context *c;
c = mrb->c;
if (!c->prev) { /* toplevel return */
regs[irep->nlocals] = v;
goto CHECKPOINT_LABEL_MAKE(RBREAK_TAG_STOP);
}
if (!c->vmexec && c->prev->ci == c->prev->cibase) {
mrb_value exc = mrb_exc_new_lit(mrb, E_FIBER_ERROR, "double resume");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
CHECKPOINT_RESTORE(RBREAK_TAG_RETURN_TOPLEVEL) {
c = mrb->c;
}
CHECKPOINT_MAIN(RBREAK_TAG_RETURN_TOPLEVEL) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN_TOPLEVEL, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_RETURN_TOPLEVEL);
/* automatic yield at the end */
c->status = MRB_FIBER_TERMINATED;
mrb->c = c->prev;
mrb->c->status = MRB_FIBER_RUNNING;
c->prev = NULL;
if (c->vmexec) {
mrb_gc_arena_restore(mrb, ai);
c->vmexec = FALSE;
mrb->jmp = prev_jmp;
return v;
}
ci = mrb->c->ci;
}
CHECKPOINT_RESTORE(RBREAK_TAG_RETURN) {
/* do nothing */
}
CHECKPOINT_MAIN(RBREAK_TAG_RETURN) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_RETURN, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_RETURN);
mrb->exc = NULL; /* clear break object */
break;
case OP_R_BREAK:
if (MRB_PROC_STRICT_P(proc)) goto NORMAL_RETURN;
if (MRB_PROC_ORPHAN_P(proc)) {
mrb_value exc;
L_BREAK_ERROR:
exc = mrb_exc_new_lit(mrb, E_LOCALJUMP_ERROR,
"break from proc-closure");
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
if (!MRB_PROC_ENV_P(proc) || !MRB_ENV_ONSTACK_P(MRB_PROC_ENV(proc))) {
goto L_BREAK_ERROR;
}
else {
struct REnv *e = MRB_PROC_ENV(proc);
if (e->cxt != mrb->c) {
goto L_BREAK_ERROR;
}
}
CHECKPOINT_RESTORE(RBREAK_TAG_BREAK) {
/* do nothing */
}
CHECKPOINT_MAIN(RBREAK_TAG_BREAK) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_BREAK);
/* break from fiber block */
if (ci == mrb->c->cibase && ci->pc) {
struct mrb_context *c = mrb->c;
mrb->c = c->prev;
c->prev = NULL;
ci = mrb->c->ci;
}
if (ci->cci > CINFO_NONE) {
ci = cipop(mrb);
mrb_gc_arena_restore(mrb, ai);
mrb->c->vmexec = FALSE;
mrb->exc = (struct RObject*)break_new(mrb, RBREAK_TAG_BREAK, proc, v);
mrb->jmp = prev_jmp;
MRB_THROW(prev_jmp);
}
if (FALSE) {
struct RBreak *brk;
L_BREAK:
brk = (struct RBreak*)mrb->exc;
proc = mrb_break_proc_get(brk);
v = mrb_break_value_get(brk);
ci = mrb->c->ci;
switch (mrb_break_tag_get(brk)) {
#define DISPATCH_CHECKPOINTS(n, i) case n: goto CHECKPOINT_LABEL_MAKE(n);
RBREAK_TAG_FOREACH(DISPATCH_CHECKPOINTS)
#undef DISPATCH_CHECKPOINTS
default:
mrb_assert(!"wrong break tag");
}
}
while (mrb->c->cibase < ci && ci[-1].proc != proc->upper) {
if (ci[-1].cci == CINFO_SKIP) {
goto L_BREAK_ERROR;
}
CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_UPPER) {
/* do nothing */
}
CHECKPOINT_MAIN(RBREAK_TAG_BREAK_UPPER) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_UPPER, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_BREAK_UPPER);
ci = cipop(mrb);
pc = ci->pc;
}
CHECKPOINT_RESTORE(RBREAK_TAG_BREAK_INTARGET) {
/* do nothing */
}
CHECKPOINT_MAIN(RBREAK_TAG_BREAK_INTARGET) {
UNWIND_ENSURE(mrb, ci, pc, RBREAK_TAG_BREAK_INTARGET, proc, v);
}
CHECKPOINT_END(RBREAK_TAG_BREAK_INTARGET);
if (ci == mrb->c->cibase) {
goto L_BREAK_ERROR;
}
mrb->exc = NULL; /* clear break object */
break;
default:
/* cannot happen */
break;
}
mrb_assert(ci == mrb->c->ci);
mrb_assert(mrb->exc == NULL);
if (mrb->c->vmexec && !mrb_vm_ci_target_class(ci)) {
mrb_gc_arena_restore(mrb, ai);
mrb->c->vmexec = FALSE;
mrb->jmp = prev_jmp;
return v;
}
acc = ci->cci;
ci = cipop(mrb);
if (acc == CINFO_SKIP || acc == CINFO_DIRECT) {
mrb_gc_arena_restore(mrb, ai);
mrb->jmp = prev_jmp;
return v;
}
pc = ci->pc;
DEBUG(fprintf(stderr, "from :%s\n", mrb_sym_name(mrb, ci->mid)));
proc = ci->proc;
irep = proc->body.irep;
pool = irep->pool;
syms = irep->syms;
ci[1].stack[0] = v;
mrb_gc_arena_restore(mrb, ai);
}
JUMP;
}
CASE(OP_BLKPUSH, BS) {
int m1 = (b>>11)&0x3f;
int r = (b>>10)&0x1;
int m2 = (b>>5)&0x1f;
int kd = (b>>4)&0x1;
int lv = (b>>0)&0xf;
mrb_value *stack;
if (lv == 0) stack = regs + 1;
else {
struct REnv *e = uvenv(mrb, lv-1);
if (!e || (!MRB_ENV_ONSTACK_P(e) && e->mid == 0) ||
MRB_ENV_LEN(e) <= m1+r+m2+1) {
localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
goto L_RAISE;
}
stack = e->stack + 1;
}
if (mrb_nil_p(stack[m1+r+m2+kd])) {
localjump_error(mrb, LOCALJUMP_ERROR_YIELD);
goto L_RAISE;
}
regs[a] = stack[m1+r+m2+kd];
NEXT;
}
L_INT_OVERFLOW:
{
mrb_value exc = mrb_exc_new_lit(mrb, E_RANGE_ERROR, "integer overflow");
mrb_exc_set(mrb, exc);
}
goto L_RAISE;
#define TYPES2(a,b) ((((uint16_t)(a))<<8)|(((uint16_t)(b))&0xff))
#define OP_MATH(op_name) \
/* need to check if op is overridden */ \
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { \
OP_MATH_CASE_INTEGER(op_name); \
OP_MATH_CASE_FLOAT(op_name, integer, float); \
OP_MATH_CASE_FLOAT(op_name, float, integer); \
OP_MATH_CASE_FLOAT(op_name, float, float); \
OP_MATH_CASE_STRING_##op_name(); \
default: \
mid = MRB_OPSYM(op_name); \
goto L_SEND_SYM; \
} \
NEXT;
#define OP_MATH_CASE_INTEGER(op_name) \
case TYPES2(MRB_TT_INTEGER, MRB_TT_INTEGER): \
{ \
mrb_int x = mrb_integer(regs[a]), y = mrb_integer(regs[a+1]), z; \
if (mrb_int_##op_name##_overflow(x, y, &z)) \
OP_MATH_OVERFLOW_INT(); \
else \
SET_INT_VALUE(mrb,regs[a], z); \
} \
break
#ifdef MRB_NO_FLOAT
#define OP_MATH_CASE_FLOAT(op_name, t1, t2) (void)0
#else
#define OP_MATH_CASE_FLOAT(op_name, t1, t2) \
case TYPES2(OP_MATH_TT_##t1, OP_MATH_TT_##t2): \
{ \
mrb_float z = mrb_##t1(regs[a]) OP_MATH_OP_##op_name mrb_##t2(regs[a+1]); \
SET_FLOAT_VALUE(mrb, regs[a], z); \
} \
break
#endif
#define OP_MATH_OVERFLOW_INT() goto L_INT_OVERFLOW
#define OP_MATH_CASE_STRING_add() \
case TYPES2(MRB_TT_STRING, MRB_TT_STRING): \
regs[a] = mrb_str_plus(mrb, regs[a], regs[a+1]); \
mrb_gc_arena_restore(mrb, ai); \
break
#define OP_MATH_CASE_STRING_sub() (void)0
#define OP_MATH_CASE_STRING_mul() (void)0
#define OP_MATH_OP_add +
#define OP_MATH_OP_sub -
#define OP_MATH_OP_mul *
#define OP_MATH_TT_integer MRB_TT_INTEGER
#define OP_MATH_TT_float MRB_TT_FLOAT
CASE(OP_ADD, B) {
OP_MATH(add);
}
CASE(OP_SUB, B) {
OP_MATH(sub);
}
CASE(OP_MUL, B) {
OP_MATH(mul);
}
CASE(OP_DIV, B) {
#ifndef MRB_NO_FLOAT
mrb_float x, y, f;
#endif
/* need to check if op is overridden */
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {
case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):
{
mrb_int x = mrb_integer(regs[a]);
mrb_int y = mrb_integer(regs[a+1]);
mrb_int div = mrb_div_int(mrb, x, y);
SET_INT_VALUE(mrb, regs[a], div);
}
NEXT;
#ifndef MRB_NO_FLOAT
case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):
x = (mrb_float)mrb_integer(regs[a]);
y = mrb_float(regs[a+1]);
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):
x = mrb_float(regs[a]);
y = (mrb_float)mrb_integer(regs[a+1]);
break;
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):
x = mrb_float(regs[a]);
y = mrb_float(regs[a+1]);
break;
#endif
default:
mid = MRB_OPSYM(div);
goto L_SEND_SYM;
}
#ifndef MRB_NO_FLOAT
f = mrb_div_float(x, y);
SET_FLOAT_VALUE(mrb, regs[a], f);
#endif
NEXT;
}
#define OP_MATHI(op_name) \
/* need to check if op is overridden */ \
switch (mrb_type(regs[a])) { \
OP_MATHI_CASE_INTEGER(op_name); \
OP_MATHI_CASE_FLOAT(op_name); \
default: \
SET_INT_VALUE(mrb,regs[a+1], b); \
mid = MRB_OPSYM(op_name); \
goto L_SEND_SYM; \
} \
NEXT;
#define OP_MATHI_CASE_INTEGER(op_name) \
case MRB_TT_INTEGER: \
{ \
mrb_int x = mrb_integer(regs[a]), y = (mrb_int)b, z; \
if (mrb_int_##op_name##_overflow(x, y, &z)) \
OP_MATH_OVERFLOW_INT(); \
else \
SET_INT_VALUE(mrb,regs[a], z); \
} \
break
#ifdef MRB_NO_FLOAT
#define OP_MATHI_CASE_FLOAT(op_name) (void)0
#else
#define OP_MATHI_CASE_FLOAT(op_name) \
case MRB_TT_FLOAT: \
{ \
mrb_float z = mrb_float(regs[a]) OP_MATH_OP_##op_name b; \
SET_FLOAT_VALUE(mrb, regs[a], z); \
} \
break
#endif
CASE(OP_ADDI, BB) {
OP_MATHI(add);
}
CASE(OP_SUBI, BB) {
OP_MATHI(sub);
}
#define OP_CMP_BODY(op,v1,v2) (v1(regs[a]) op v2(regs[a+1]))
#ifdef MRB_NO_FLOAT
#define OP_CMP(op,sym) do {\
int result;\
/* need to check if - is overridden */\
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\
result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\
break;\
default:\
mid = MRB_OPSYM(sym);\
goto L_SEND_SYM;\
}\
if (result) {\
SET_TRUE_VALUE(regs[a]);\
}\
else {\
SET_FALSE_VALUE(regs[a]);\
}\
} while(0)
#else
#define OP_CMP(op, sym) do {\
int result;\
/* need to check if - is overridden */\
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {\
case TYPES2(MRB_TT_INTEGER,MRB_TT_INTEGER):\
result = OP_CMP_BODY(op,mrb_fixnum,mrb_fixnum);\
break;\
case TYPES2(MRB_TT_INTEGER,MRB_TT_FLOAT):\
result = OP_CMP_BODY(op,mrb_fixnum,mrb_float);\
break;\
case TYPES2(MRB_TT_FLOAT,MRB_TT_INTEGER):\
result = OP_CMP_BODY(op,mrb_float,mrb_fixnum);\
break;\
case TYPES2(MRB_TT_FLOAT,MRB_TT_FLOAT):\
result = OP_CMP_BODY(op,mrb_float,mrb_float);\
break;\
default:\
mid = MRB_OPSYM(sym);\
goto L_SEND_SYM;\
}\
if (result) {\
SET_TRUE_VALUE(regs[a]);\
}\
else {\
SET_FALSE_VALUE(regs[a]);\
}\
} while(0)
#endif
CASE(OP_EQ, B) {
if (mrb_obj_eq(mrb, regs[a], regs[a+1])) {
SET_TRUE_VALUE(regs[a]);
}
else {
OP_CMP(==,eq);
}
NEXT;
}
CASE(OP_LT, B) {
OP_CMP(<,lt);
NEXT;
}
CASE(OP_LE, B) {
OP_CMP(<=,le);
NEXT;
}
CASE(OP_GT, B) {
OP_CMP(>,gt);
NEXT;
}
CASE(OP_GE, B) {
OP_CMP(>=,ge);
NEXT;
}
CASE(OP_ARRAY, BB) {
regs[a] = mrb_ary_new_from_values(mrb, b, ®s[a]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_ARRAY2, BBB) {
regs[a] = mrb_ary_new_from_values(mrb, c, ®s[b]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_ARYCAT, B) {
mrb_value splat = mrb_ary_splat(mrb, regs[a+1]);
if (mrb_nil_p(regs[a])) {
regs[a] = splat;
}
else {
mrb_assert(mrb_array_p(regs[a]));
mrb_ary_concat(mrb, regs[a], splat);
}
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_ARYPUSH, BB) {
mrb_assert(mrb_array_p(regs[a]));
for (mrb_int i=0; i<b; i++) {
mrb_ary_push(mrb, regs[a], regs[a+i+1]);
}
NEXT;
}
CASE(OP_ARYDUP, B) {
mrb_value ary = regs[a];
if (mrb_array_p(ary)) {
ary = mrb_ary_new_from_values(mrb, RARRAY_LEN(ary), RARRAY_PTR(ary));
}
else {
ary = mrb_ary_new_from_values(mrb, 1, &ary);
}
regs[a] = ary;
NEXT;
}
CASE(OP_AREF, BBB) {
mrb_value v = regs[b];
if (!mrb_array_p(v)) {
if (c == 0) {
regs[a] = v;
}
else {
SET_NIL_VALUE(regs[a]);
}
}
else {
v = mrb_ary_ref(mrb, v, c);
regs[a] = v;
}
NEXT;
}
CASE(OP_ASET, BBB) {
mrb_assert(mrb_array_p(regs[a]));
mrb_ary_set(mrb, regs[b], c, regs[a]);
NEXT;
}
CASE(OP_APOST, BBB) {
mrb_value v = regs[a];
int pre = b;
int post = c;
struct RArray *ary;
int len, idx;
if (!mrb_array_p(v)) {
v = mrb_ary_new_from_values(mrb, 1, ®s[a]);
}
ary = mrb_ary_ptr(v);
len = (int)ARY_LEN(ary);
if (len > pre + post) {
v = mrb_ary_new_from_values(mrb, len - pre - post, ARY_PTR(ary)+pre);
regs[a++] = v;
while (post--) {
regs[a++] = ARY_PTR(ary)[len-post-1];
}
}
else {
v = mrb_ary_new_capa(mrb, 0);
regs[a++] = v;
for (idx=0; idx+pre<len; idx++) {
regs[a+idx] = ARY_PTR(ary)[pre+idx];
}
while (idx < post) {
SET_NIL_VALUE(regs[a+idx]);
idx++;
}
}
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_INTERN, B) {
mrb_assert(mrb_string_p(regs[a]));
mrb_sym sym = mrb_intern_str(mrb, regs[a]);
regs[a] = mrb_symbol_value(sym);
NEXT;
}
CASE(OP_SYMBOL, BB) {
size_t len;
mrb_sym sym;
mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);
len = pool[b].tt >> 2;
if (pool[b].tt & IREP_TT_SFLAG) {
sym = mrb_intern_static(mrb, pool[b].u.str, len);
}
else {
sym = mrb_intern(mrb, pool[b].u.str, len);
}
regs[a] = mrb_symbol_value(sym);
NEXT;
}
CASE(OP_STRING, BB) {
mrb_int len;
mrb_assert((pool[b].tt&IREP_TT_NFLAG)==0);
len = pool[b].tt >> 2;
if (pool[b].tt & IREP_TT_SFLAG) {
regs[a] = mrb_str_new_static(mrb, pool[b].u.str, len);
}
else {
regs[a] = mrb_str_new(mrb, pool[b].u.str, len);
}
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_STRCAT, B) {
mrb_assert(mrb_string_p(regs[a]));
mrb_str_concat(mrb, regs[a], regs[a+1]);
NEXT;
}
CASE(OP_HASH, BB) {
mrb_value hash = mrb_hash_new_capa(mrb, b);
int i;
int lim = a+b*2;
for (i=a; i<lim; i+=2) {
mrb_hash_set(mrb, hash, regs[i], regs[i+1]);
}
regs[a] = hash;
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_HASHADD, BB) {
mrb_value hash;
int i;
int lim = a+b*2+1;
hash = regs[a];
mrb_ensure_hash_type(mrb, hash);
for (i=a+1; i<lim; i+=2) {
mrb_hash_set(mrb, hash, regs[i], regs[i+1]);
}
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_HASHCAT, B) {
mrb_value hash = regs[a];
mrb_assert(mrb_hash_p(hash));
mrb_hash_merge(mrb, hash, regs[a+1]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_LAMBDA, BB)
c = OP_L_LAMBDA;
L_MAKE_LAMBDA:
{
struct RProc *p;
const mrb_irep *nirep = irep->reps[b];
if (c & OP_L_CAPTURE) {
p = mrb_closure_new(mrb, nirep);
}
else {
p = mrb_proc_new(mrb, nirep);
p->flags |= MRB_PROC_SCOPE;
}
if (c & OP_L_STRICT) p->flags |= MRB_PROC_STRICT;
regs[a] = mrb_obj_value(p);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_BLOCK, BB) {
c = OP_L_BLOCK;
goto L_MAKE_LAMBDA;
}
CASE(OP_METHOD, BB) {
c = OP_L_METHOD;
goto L_MAKE_LAMBDA;
}
CASE(OP_RANGE_INC, B) {
mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], FALSE);
regs[a] = v;
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_RANGE_EXC, B) {
mrb_value v = mrb_range_new(mrb, regs[a], regs[a+1], TRUE);
regs[a] = v;
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_OCLASS, B) {
regs[a] = mrb_obj_value(mrb->object_class);
NEXT;
}
CASE(OP_CLASS, BB) {
struct RClass *c = 0, *baseclass;
mrb_value base, super;
mrb_sym id = syms[b];
base = regs[a];
super = regs[a+1];
if (mrb_nil_p(base)) {
baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
if (!baseclass) baseclass = mrb->object_class;
base = mrb_obj_value(baseclass);
}
c = mrb_vm_define_class(mrb, base, super, id);
regs[a] = mrb_obj_value(c);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_MODULE, BB) {
struct RClass *cls = 0, *baseclass;
mrb_value base;
mrb_sym id = syms[b];
base = regs[a];
if (mrb_nil_p(base)) {
baseclass = MRB_PROC_TARGET_CLASS(mrb->c->ci->proc);
if (!baseclass) baseclass = mrb->object_class;
base = mrb_obj_value(baseclass);
}
cls = mrb_vm_define_module(mrb, base, id);
regs[a] = mrb_obj_value(cls);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_EXEC, BB)
{
mrb_value recv = regs[a];
struct RProc *p;
const mrb_irep *nirep = irep->reps[b];
/* prepare closure */
p = mrb_proc_new(mrb, nirep);
p->c = NULL;
mrb_field_write_barrier(mrb, (struct RBasic*)p, (struct RBasic*)proc);
MRB_PROC_SET_TARGET_CLASS(p, mrb_class_ptr(recv));
p->flags |= MRB_PROC_SCOPE;
/* prepare call stack */
cipush(mrb, a, 0, mrb_class_ptr(recv), p, 0, 0);
irep = p->body.irep;
pool = irep->pool;
syms = irep->syms;
mrb_stack_extend(mrb, irep->nregs);
stack_clear(regs+1, irep->nregs-1);
pc = irep->iseq;
JUMP;
}
CASE(OP_DEF, BB) {
struct RClass *target = mrb_class_ptr(regs[a]);
struct RProc *p = mrb_proc_ptr(regs[a+1]);
mrb_method_t m;
mrb_sym mid = syms[b];
MRB_METHOD_FROM_PROC(m, p);
mrb_define_method_raw(mrb, target, mid, m);
mrb_method_added(mrb, target, mid);
mrb_gc_arena_restore(mrb, ai);
regs[a] = mrb_symbol_value(mid);
NEXT;
}
CASE(OP_SCLASS, B) {
regs[a] = mrb_singleton_class(mrb, regs[a]);
mrb_gc_arena_restore(mrb, ai);
NEXT;
}
CASE(OP_TCLASS, B) {
struct RClass *target = check_target_class(mrb);
if (!target) goto L_RAISE;
regs[a] = mrb_obj_value(target);
NEXT;
}
CASE(OP_ALIAS, BB) {
struct RClass *target = check_target_class(mrb);
if (!target) goto L_RAISE;
mrb_alias_method(mrb, target, syms[a], syms[b]);
mrb_method_added(mrb, target, syms[a]);
NEXT;
}
CASE(OP_UNDEF, B) {
struct RClass *target = check_target_class(mrb);
if (!target) goto L_RAISE;
mrb_undef_method_id(mrb, target, syms[a]);
NEXT;
}
CASE(OP_DEBUG, Z) {
FETCH_BBB();
#ifdef MRB_USE_DEBUG_HOOK
mrb->debug_op_hook(mrb, irep, pc, regs);
#else
#ifndef MRB_NO_STDIO
printf("OP_DEBUG %d %d %d\n", a, b, c);
#else
abort();
#endif
#endif
NEXT;
}
CASE(OP_ERR, B) {
size_t len = pool[a].tt >> 2;
mrb_value exc;
mrb_assert((pool[a].tt&IREP_TT_NFLAG)==0);
exc = mrb_exc_new(mrb, E_LOCALJUMP_ERROR, pool[a].u.str, len);
mrb_exc_set(mrb, exc);
goto L_RAISE;
}
CASE(OP_EXT1, Z) {
insn = READ_B();
switch (insn) {
#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _1(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;
#include "mruby/ops.h"
#undef OPCODE
}
pc--;
NEXT;
}
CASE(OP_EXT2, Z) {
insn = READ_B();
switch (insn) {
#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _2(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;
#include "mruby/ops.h"
#undef OPCODE
}
pc--;
NEXT;
}
CASE(OP_EXT3, Z) {
uint8_t insn = READ_B();
switch (insn) {
#define OPCODE(insn,ops) case OP_ ## insn: FETCH_ ## ops ## _3(); mrb->c->ci->pc = pc; goto L_OP_ ## insn ## _BODY;
#include "mruby/ops.h"
#undef OPCODE
}
pc--;
NEXT;
}
CASE(OP_STOP, Z) {
/* stop VM */
CHECKPOINT_RESTORE(RBREAK_TAG_STOP) {
/* do nothing */
}
CHECKPOINT_MAIN(RBREAK_TAG_STOP) {
UNWIND_ENSURE(mrb, mrb->c->ci, pc, RBREAK_TAG_STOP, proc, mrb_nil_value());
}
CHECKPOINT_END(RBREAK_TAG_STOP);
L_STOP:
mrb->jmp = prev_jmp;
if (mrb->exc) {
mrb_assert(mrb->exc->tt == MRB_TT_EXCEPTION);
return mrb_obj_value(mrb->exc);
}
return regs[irep->nlocals];
}
}
END_DISPATCH;
#undef regs
}
MRB_CATCH(&c_jmp) {
mrb_callinfo *ci = mrb->c->ci;
while (ci > mrb->c->cibase && ci->cci == CINFO_DIRECT) {
ci = cipop(mrb);
}
exc_catched = TRUE;
pc = ci->pc;
goto RETRY_TRY_BLOCK;
}
MRB_END_EXC(&c_jmp);
}
| 1
|
312,391
|
qf_get_nth_below_entry(qfline_T *entry_arg, int n, int linewise, int *errornr)
{
qfline_T *entry = entry_arg;
while (n-- > 0 && !got_int)
{
int first_errornr = *errornr;
if (linewise)
// Treat all the entries on the same line in this file as one
entry = qf_find_last_entry_on_line(entry, errornr);
if (entry->qf_next == NULL
|| entry->qf_next->qf_fnum != entry->qf_fnum)
{
if (linewise)
*errornr = first_errornr;
break;
}
entry = entry->qf_next;
++*errornr;
}
}
| 0
|
317,044
|
static struct smack_known *smack_from_secattr(struct netlbl_lsm_secattr *sap,
struct socket_smack *ssp)
{
struct smack_known *skp;
int found = 0;
int acat;
int kcat;
/*
* Netlabel found it in the cache.
*/
if ((sap->flags & NETLBL_SECATTR_CACHE) != 0)
return (struct smack_known *)sap->cache->data;
if ((sap->flags & NETLBL_SECATTR_SECID) != 0)
/*
* Looks like a fallback, which gives us a secid.
*/
return smack_from_secid(sap->attr.secid);
if ((sap->flags & NETLBL_SECATTR_MLS_LVL) != 0) {
/*
* Looks like a CIPSO packet.
* If there are flags but no level netlabel isn't
* behaving the way we expect it to.
*
* Look it up in the label table
* Without guidance regarding the smack value
* for the packet fall back on the network
* ambient value.
*/
rcu_read_lock();
list_for_each_entry_rcu(skp, &smack_known_list, list) {
if (sap->attr.mls.lvl != skp->smk_netlabel.attr.mls.lvl)
continue;
/*
* Compare the catsets. Use the netlbl APIs.
*/
if ((sap->flags & NETLBL_SECATTR_MLS_CAT) == 0) {
if ((skp->smk_netlabel.flags &
NETLBL_SECATTR_MLS_CAT) == 0)
found = 1;
break;
}
for (acat = -1, kcat = -1; acat == kcat; ) {
acat = netlbl_catmap_walk(sap->attr.mls.cat,
acat + 1);
kcat = netlbl_catmap_walk(
skp->smk_netlabel.attr.mls.cat,
kcat + 1);
if (acat < 0 || kcat < 0)
break;
}
if (acat == kcat) {
found = 1;
break;
}
}
rcu_read_unlock();
if (found)
return skp;
if (ssp != NULL && ssp->smk_in == &smack_known_star)
return &smack_known_web;
return &smack_known_star;
}
/*
* Without guidance regarding the smack value
* for the packet fall back on the network
* ambient value.
*/
return smack_net_ambient;
}
| 0
|
200,895
|
call_qftf_func(qf_list_T *qfl, int qf_winid, long start_idx, long end_idx)
{
callback_T *cb = &qftf_cb;
list_T *qftf_list = NULL;
// If 'quickfixtextfunc' is set, then use the user-supplied function to get
// the text to display. Use the local value of 'quickfixtextfunc' if it is
// set.
if (qfl->qf_qftf_cb.cb_name != NULL)
cb = &qfl->qf_qftf_cb;
if (cb->cb_name != NULL)
{
typval_T args[1];
dict_T *d;
typval_T rettv;
// create the dict argument
if ((d = dict_alloc_lock(VAR_FIXED)) == NULL)
return NULL;
dict_add_number(d, "quickfix", (long)IS_QF_LIST(qfl));
dict_add_number(d, "winid", (long)qf_winid);
dict_add_number(d, "id", (long)qfl->qf_id);
dict_add_number(d, "start_idx", start_idx);
dict_add_number(d, "end_idx", end_idx);
++d->dv_refcount;
args[0].v_type = VAR_DICT;
args[0].vval.v_dict = d;
qftf_list = NULL;
if (call_callback(cb, 0, &rettv, 1, args) != FAIL)
{
if (rettv.v_type == VAR_LIST)
{
qftf_list = rettv.vval.v_list;
qftf_list->lv_refcount++;
}
clear_tv(&rettv);
}
dict_unref(d);
}
return qftf_list;
}
| 1
|
410,078
|
void hid_dump_report(struct hid_device *hid, int type, u8 *data,
int size)
{
struct hid_report_enum *report_enum;
char *buf;
unsigned int i;
buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
if (!buf)
return;
report_enum = hid->report_enum + type;
/* dump the report */
snprintf(buf, HID_DEBUG_BUFSIZE - 1,
"\nreport (size %u) (%snumbered) = ", size,
report_enum->numbered ? "" : "un");
hid_debug_event(hid, buf);
for (i = 0; i < size; i++) {
snprintf(buf, HID_DEBUG_BUFSIZE - 1,
" %02x", data[i]);
hid_debug_event(hid, buf);
}
hid_debug_event(hid, "\n");
kfree(buf);
}
| 0
|
277,667
|
get_text_gray_row (j_compress_ptr cinfo, cjpeg_source_ptr sinfo)
/* This version is for reading text-format PGM files with any maxval */
{
ppm_source_ptr source = (ppm_source_ptr) sinfo;
FILE * infile = source->pub.input_file;
register JSAMPROW ptr;
register JSAMPLE *rescale = source->rescale;
JDIMENSION col;
int maxval = source->maxval;
ptr = source->pub.buffer[0];
for (col = cinfo->image_width; col > 0; col--) {
*ptr++ = rescale[read_pbm_integer(cinfo, infile, maxval)];
}
return 1;
}
| 0
|
226,028
|
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_Err dvcC_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_DOVIConfigurationBox *ptr = (GF_DOVIConfigurationBox *) s;
if (!s) return GF_BAD_PARAM;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
//GF_DOVIDecoderConfigurationRecord
gf_bs_write_u8(bs, ptr->DOVIConfig.dv_version_major);
gf_bs_write_u8(bs, ptr->DOVIConfig.dv_version_minor);
gf_bs_write_int(bs, ptr->DOVIConfig.dv_profile, 7);
gf_bs_write_int(bs, ptr->DOVIConfig.dv_level, 6);
gf_bs_write_int(bs, ptr->DOVIConfig.rpu_present_flag, 1);
gf_bs_write_int(bs, ptr->DOVIConfig.el_present_flag, 1);
gf_bs_write_int(bs, ptr->DOVIConfig.bl_present_flag, 1);
gf_bs_write_int(bs, ptr->DOVIConfig.dv_bl_signal_compatibility_id, 4);
gf_bs_write_int(bs, 0, 28);
gf_bs_write_u32(bs, 0);
gf_bs_write_u32(bs, 0);
gf_bs_write_u32(bs, 0);
gf_bs_write_u32(bs, 0);
return GF_OK;
| 0
|
294,392
|
datetime_s__strptime(int argc, VALUE *argv, VALUE klass)
{
return date_s__strptime_internal(argc, argv, klass, "%FT%T%z");
}
| 0
|
242,574
|
get_section_vma_by_name (char *name, size_t namesz,
char *buffer, size_t bufsz,
PE_COFF_LOADER_IMAGE_CONTEXT *context,
char **basep, size_t *sizep,
EFI_IMAGE_SECTION_HEADER **sectionp)
{
UINTN i;
char namebuf[9];
if (!name || namesz == 0 || !buffer || bufsz < namesz || !context
|| !basep || !sizep || !sectionp)
return EFI_INVALID_PARAMETER;
/*
* This code currently is only used for ".reloc\0\0" and
* ".sbat\0\0\0", and it doesn't know how to look up longer section
* names.
*/
if (namesz > 8)
return EFI_UNSUPPORTED;
SetMem(namebuf, sizeof(namebuf), 0);
CopyMem(namebuf, name, MIN(namesz, 8));
/*
* Copy the executable's sections to their desired offsets
*/
for (i = 0; i < context->NumberOfSections; i++) {
EFI_STATUS status;
EFI_IMAGE_SECTION_HEADER *section = NULL;
char *base = NULL;
size_t size = 0;
status = get_section_vma(i, buffer, bufsz, context, &base, &size, §ion);
if (!EFI_ERROR(status)) {
if (CompareMem(section->Name, namebuf, 8) == 0) {
*basep = base;
*sizep = size;
*sectionp = section;
return EFI_SUCCESS;
}
continue;
}
switch(status) {
case EFI_NOT_FOUND:
break;
}
}
return EFI_NOT_FOUND;
}
| 0
|
353,195
|
void SplashOutputDev::type3D1(GfxState *state, double wx, double wy,
double llx, double lly, double urx, double ury) {
T3FontCache *t3Font;
SplashColor color;
double xt, yt, xMin, xMax, yMin, yMax, x1, y1;
int i, j;
// ignore multiple d0/d1 operators
if (!t3GlyphStack || t3GlyphStack->haveDx) {
return;
}
t3GlyphStack->haveDx = true;
// don't cache if we got a gsave/grestore before the d1
if (t3GlyphStack->doNotCache) {
return;
}
if (unlikely(t3GlyphStack == nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack was null in SplashOutputDev::type3D1");
return;
}
if (unlikely(t3GlyphStack->origBitmap != nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack origBitmap was not null in SplashOutputDev::type3D1");
return;
}
if (unlikely(t3GlyphStack->origSplash != nullptr)) {
error(errSyntaxWarning, -1, "t3GlyphStack origSplash was not null in SplashOutputDev::type3D1");
return;
}
t3Font = t3GlyphStack->cache;
// check for a valid bbox
state->transform(0, 0, &xt, &yt);
state->transform(llx, lly, &x1, &y1);
xMin = xMax = x1;
yMin = yMax = y1;
state->transform(llx, ury, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
state->transform(urx, lly, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
state->transform(urx, ury, &x1, &y1);
if (x1 < xMin) {
xMin = x1;
} else if (x1 > xMax) {
xMax = x1;
}
if (y1 < yMin) {
yMin = y1;
} else if (y1 > yMax) {
yMax = y1;
}
if (xMin - xt < t3Font->glyphX ||
yMin - yt < t3Font->glyphY ||
xMax - xt > t3Font->glyphX + t3Font->glyphW ||
yMax - yt > t3Font->glyphY + t3Font->glyphH) {
if (t3Font->validBBox) {
error(errSyntaxWarning, -1, "Bad bounding box in Type 3 glyph");
}
return;
}
if (t3Font->cacheTags == nullptr)
return;
// allocate a cache entry
i = (t3GlyphStack->code & (t3Font->cacheSets - 1)) * t3Font->cacheAssoc;
for (j = 0; j < t3Font->cacheAssoc; ++j) {
if ((t3Font->cacheTags[i+j].mru & 0x7fff) == t3Font->cacheAssoc - 1) {
t3Font->cacheTags[i+j].mru = 0x8000;
t3Font->cacheTags[i+j].code = t3GlyphStack->code;
t3GlyphStack->cacheTag = &t3Font->cacheTags[i+j];
t3GlyphStack->cacheData = t3Font->cacheData + (i+j) * t3Font->glyphSize;
} else {
++t3Font->cacheTags[i+j].mru;
}
}
// save state
t3GlyphStack->origBitmap = bitmap;
t3GlyphStack->origSplash = splash;
const double *ctm = state->getCTM();
t3GlyphStack->origCTM4 = ctm[4];
t3GlyphStack->origCTM5 = ctm[5];
// create the temporary bitmap
if (colorMode == splashModeMono1) {
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono1, false);
splash = new Splash(bitmap, false,
t3GlyphStack->origSplash->getScreen());
color[0] = 0;
splash->clear(color);
color[0] = 0xff;
} else {
bitmap = new SplashBitmap(t3Font->glyphW, t3Font->glyphH, 1,
splashModeMono8, false);
splash = new Splash(bitmap, vectorAntialias,
t3GlyphStack->origSplash->getScreen());
color[0] = 0x00;
splash->clear(color);
color[0] = 0xff;
}
splash->setMinLineWidth(s_minLineWidth);
splash->setThinLineMode(splashThinLineDefault);
splash->setFillPattern(new SplashSolidColor(color));
splash->setStrokePattern(new SplashSolidColor(color));
//~ this should copy other state from t3GlyphStack->origSplash?
state->setCTM(ctm[0], ctm[1], ctm[2], ctm[3],
-t3Font->glyphX, -t3Font->glyphY);
updateCTM(state, 0, 0, 0, 0, 0, 0);
++nestCount;
}
| 0
|
225,908
|
GF_Err dac3_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s;
if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DEC3;
e = gf_isom_box_write_header(s, bs);
if (ptr->cfg.is_ec3) s->type = GF_ISOM_BOX_TYPE_DAC3;
if (e) return e;
return gf_odf_ac3_cfg_write_bs(&ptr->cfg, bs);
| 0
|
242,972
|
static uint32_t ssl_get_hs_total_len( mbedtls_ssl_context const *ssl )
{
return( ( ssl->in_msg[1] << 16 ) |
( ssl->in_msg[2] << 8 ) |
ssl->in_msg[3] );
}
| 0
|
212,829
|
*/
static void php_wddx_pop_element(void *user_data, const XML_Char *name)
{
st_entry *ent1, *ent2;
wddx_stack *stack = (wddx_stack *)user_data;
HashTable *target_hash;
zend_class_entry **pce;
zval *obj;
zval *tmp;
TSRMLS_FETCH();
/* OBJECTS_FIXME */
if (stack->top == 0) {
return;
}
if (!strcmp(name, EL_STRING) || !strcmp(name, EL_NUMBER) ||
!strcmp(name, EL_BOOLEAN) || !strcmp(name, EL_NULL) ||
!strcmp(name, EL_ARRAY) || !strcmp(name, EL_STRUCT) ||
!strcmp(name, EL_RECORDSET) || !strcmp(name, EL_BINARY) ||
!strcmp(name, EL_DATETIME)) {
wddx_stack_top(stack, (void**)&ent1);
if (!ent1->data) {
if (stack->top > 1) {
stack->top--;
} else {
stack->done = 1;
}
efree(ent1);
return;
}
if (!strcmp(name, EL_BINARY)) {
int new_len=0;
unsigned char *new_str;
new_str = php_base64_decode(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data), &new_len);
STR_FREE(Z_STRVAL_P(ent1->data));
Z_STRVAL_P(ent1->data) = new_str;
Z_STRLEN_P(ent1->data) = new_len;
}
/* Call __wakeup() method on the object. */
if (Z_TYPE_P(ent1->data) == IS_OBJECT) {
zval *fname, *retval = NULL;
MAKE_STD_ZVAL(fname);
ZVAL_STRING(fname, "__wakeup", 1);
call_user_function_ex(NULL, &ent1->data, fname, &retval, 0, 0, 0, NULL TSRMLS_CC);
zval_dtor(fname);
FREE_ZVAL(fname);
if (retval) {
zval_ptr_dtor(&retval);
}
}
if (stack->top > 1) {
stack->top--;
wddx_stack_top(stack, (void**)&ent2);
/* if non-existent field */
if (ent2->type == ST_FIELD && ent2->data == NULL) {
zval_ptr_dtor(&ent1->data);
efree(ent1);
return;
}
if (Z_TYPE_P(ent2->data) == IS_ARRAY || Z_TYPE_P(ent2->data) == IS_OBJECT) {
target_hash = HASH_OF(ent2->data);
if (ent1->varname) {
if (!strcmp(ent1->varname, PHP_CLASS_NAME_VAR) &&
Z_TYPE_P(ent1->data) == IS_STRING && Z_STRLEN_P(ent1->data) &&
ent2->type == ST_STRUCT && Z_TYPE_P(ent2->data) == IS_ARRAY) {
zend_bool incomplete_class = 0;
zend_str_tolower(Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));
if (zend_hash_find(EG(class_table), Z_STRVAL_P(ent1->data),
Z_STRLEN_P(ent1->data)+1, (void **) &pce)==FAILURE) {
incomplete_class = 1;
pce = &PHP_IC_ENTRY;
}
/* Initialize target object */
MAKE_STD_ZVAL(obj);
object_init_ex(obj, *pce);
/* Merge current hashtable with object's default properties */
zend_hash_merge(Z_OBJPROP_P(obj),
Z_ARRVAL_P(ent2->data),
(void (*)(void *)) zval_add_ref,
(void *) &tmp, sizeof(zval *), 0);
if (incomplete_class) {
php_store_class_name(obj, Z_STRVAL_P(ent1->data), Z_STRLEN_P(ent1->data));
}
/* Clean up old array entry */
zval_ptr_dtor(&ent2->data);
/* Set stack entry to point to the newly created object */
ent2->data = obj;
/* Clean up class name var entry */
zval_ptr_dtor(&ent1->data);
} else if (Z_TYPE_P(ent2->data) == IS_OBJECT) {
zend_class_entry *old_scope = EG(scope);
EG(scope) = Z_OBJCE_P(ent2->data);
Z_DELREF_P(ent1->data);
add_property_zval(ent2->data, ent1->varname, ent1->data);
EG(scope) = old_scope;
} else {
zend_symtable_update(target_hash, ent1->varname, strlen(ent1->varname)+1, &ent1->data, sizeof(zval *), NULL);
}
efree(ent1->varname);
} else {
zend_hash_next_index_insert(target_hash, &ent1->data, sizeof(zval *), NULL);
}
}
efree(ent1);
} else {
stack->done = 1;
}
} else if (!strcmp(name, EL_VAR) && stack->varname) {
efree(stack->varname);
stack->varname = NULL;
} else if (!strcmp(name, EL_FIELD)) {
st_entry *ent;
wddx_stack_top(stack, (void **)&ent);
efree(ent);
stack->top--;
}
| 1
|
275,478
|
njs_vm_init(njs_vm_t *vm)
{
njs_int_t ret;
njs_frame_t *frame;
frame = (njs_frame_t *) njs_function_frame_alloc(vm, NJS_FRAME_SIZE);
if (njs_slow_path(frame == NULL)) {
njs_memory_error(vm);
return NJS_ERROR;
}
frame->exception.catch = NULL;
frame->exception.next = NULL;
frame->previous_active_frame = NULL;
vm->active_frame = frame;
ret = njs_regexp_init(vm);
if (njs_slow_path(ret != NJS_OK)) {
return NJS_ERROR;
}
ret = njs_builtin_objects_clone(vm, &vm->global_value);
if (njs_slow_path(ret != NJS_OK)) {
return NJS_ERROR;
}
njs_lvlhsh_init(&vm->values_hash);
njs_lvlhsh_init(&vm->keywords_hash);
njs_lvlhsh_init(&vm->modules_hash);
njs_lvlhsh_init(&vm->events_hash);
njs_queue_init(&vm->posted_events);
njs_queue_init(&vm->promise_events);
return NJS_OK;
}
| 0
|
263,390
|
Status BatchToSpaceShapeHelper(InferenceContext* c, ShapeHandle input_shape,
ShapeHandle block_shape_shape,
const Tensor* block_shape_t,
ShapeHandle crops_shape, const Tensor* crops_t) {
if (c->Rank(block_shape_shape) != 1) {
return errors::InvalidArgument("block_shape must have rank 1.");
}
const DimensionHandle num_block_dims_handle = c->Dim(block_shape_shape, 0);
if (!c->ValueKnown(num_block_dims_handle)) {
return errors::InvalidArgument("block_shape must have known size.");
}
const int64_t num_block_dims = c->Value(num_block_dims_handle);
TF_RETURN_IF_ERROR(
c->WithRankAtLeast(input_shape, num_block_dims + 1, &input_shape));
TF_RETURN_IF_ERROR(
c->Merge(crops_shape, c->Matrix(num_block_dims, 2), &crops_shape));
DimensionHandle batch_size = c->Dim(input_shape, 0);
std::vector<int64_t> block_shape_vec;
if (block_shape_t) {
block_shape_vec = GetFlatInt64(*block_shape_t);
for (int64_t dim = 0; dim < num_block_dims; ++dim) {
const int64_t block_shape_value = block_shape_vec[dim];
if (block_shape_value < 1) {
return errors::InvalidArgument("block_shape must be positive");
}
if (c->ValueKnown(batch_size)) {
TF_RETURN_IF_ERROR(c->Divide(batch_size, block_shape_value,
/*evenly_divisible=*/true, &batch_size));
} else {
batch_size = c->UnknownDim();
}
}
} else if (num_block_dims > 0) {
batch_size = c->UnknownDim();
}
std::vector<DimensionHandle> output_dims{batch_size};
output_dims.resize(num_block_dims + 1, c->UnknownDim());
if (crops_t) {
const std::vector<int64_t> crops_vec = GetFlatInt64(*crops_t);
for (int64_t dim = 0; dim < num_block_dims; ++dim) {
const int64_t crop_start = crops_vec[dim * 2],
crop_end = crops_vec[dim * 2 + 1];
if (crop_start < 0 || crop_end < 0) {
return errors::InvalidArgument("crops cannot be negative");
}
if (block_shape_t) {
DimensionHandle cropped_size;
TF_RETURN_IF_ERROR(c->Multiply(c->Dim(input_shape, dim + 1),
block_shape_vec[dim], &cropped_size));
TF_RETURN_IF_ERROR(
c->Subtract(cropped_size, crop_start, &cropped_size));
TF_RETURN_IF_ERROR(
c->Subtract(cropped_size, crop_end, &output_dims[dim + 1]));
}
}
}
ShapeHandle remaining_input_shape;
TF_RETURN_IF_ERROR(
c->Subshape(input_shape, 1 + num_block_dims, &remaining_input_shape));
ShapeHandle result;
TF_RETURN_IF_ERROR(c->Concatenate(c->MakeShape(output_dims),
remaining_input_shape, &result));
c->set_output(0, result);
return Status::OK();
}
| 0
|
224,169
|
explicit MapUnstageNoKeyOp(OpKernelConstruction* ctx) : OpKernel(ctx) {}
| 0
|
255,101
|
int unit_name_path_escape(const char *f, char **ret) {
_cleanup_free_ char *p = NULL;
char *s;
assert(f);
assert(ret);
p = strdup(f);
if (!p)
return -ENOMEM;
path_simplify(p, false);
if (empty_or_root(p))
s = strdup("-");
else {
if (!path_is_normalized(p))
return -EINVAL;
/* Truncate trailing slashes and skip leading slashes */
delete_trailing_chars(p, "/");
s = unit_name_escape(skip_leading_chars(p, "/"));
}
if (!s)
return -ENOMEM;
*ret = s;
return 0;
}
| 0
|
462,576
|
void controller::set_view(view * vv) {
v = vv;
}
| 0
|
226,067
|
GF_Box *enca_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_MPEGAudioSampleEntryBox, GF_ISOM_BOX_TYPE_ENCA);
gf_isom_audio_sample_entry_init((GF_AudioSampleEntryBox*)tmp);
return (GF_Box *)tmp;
}
| 0
|
200,831
|
set_routerstatus_from_routerinfo(routerstatus_t *rs,
routerinfo_t *ri, time_t now,
int naming, int listbadexits,
int listbaddirs, int vote_on_hsdirs)
{
int unstable_version =
!tor_version_as_new_as(ri->platform,"0.1.1.16-rc-cvs");
memset(rs, 0, sizeof(routerstatus_t));
rs->is_authority =
router_digest_is_trusted_dir(ri->cache_info.identity_digest);
/* Already set by compute_performance_thresholds. */
rs->is_exit = ri->is_exit;
rs->is_stable = ri->is_stable =
router_is_active(ri, now) &&
!dirserv_thinks_router_is_unreliable(now, ri, 1, 0) &&
!unstable_version;
rs->is_fast = ri->is_fast =
router_is_active(ri, now) &&
!dirserv_thinks_router_is_unreliable(now, ri, 0, 1);
rs->is_running = ri->is_running; /* computed above */
if (naming) {
uint32_t name_status = dirserv_get_name_status(
ri->cache_info.identity_digest, ri->nickname);
rs->is_named = (naming && (name_status & FP_NAMED)) ? 1 : 0;
rs->is_unnamed = (naming && (name_status & FP_UNNAMED)) ? 1 : 0;
}
rs->is_valid = ri->is_valid;
if (rs->is_fast &&
(router_get_advertised_bandwidth(ri) >= BANDWIDTH_TO_GUARANTEE_GUARD ||
router_get_advertised_bandwidth(ri) >=
MIN(guard_bandwidth_including_exits,
guard_bandwidth_excluding_exits))) {
long tk = rep_hist_get_weighted_time_known(
ri->cache_info.identity_digest, now);
double wfu = rep_hist_get_weighted_fractional_uptime(
ri->cache_info.identity_digest, now);
rs->is_possible_guard = (wfu >= guard_wfu && tk >= guard_tk) ? 1 : 0;
} else {
rs->is_possible_guard = 0;
}
rs->is_bad_directory = listbaddirs && ri->is_bad_directory;
rs->is_bad_exit = listbadexits && ri->is_bad_exit;
ri->is_hs_dir = dirserv_thinks_router_is_hs_dir(ri, now);
rs->is_hs_dir = vote_on_hsdirs && ri->is_hs_dir;
rs->is_v2_dir = ri->dir_port != 0;
if (!strcasecmp(ri->nickname, UNNAMED_ROUTER_NICKNAME))
rs->is_named = rs->is_unnamed = 0;
rs->published_on = ri->cache_info.published_on;
memcpy(rs->identity_digest, ri->cache_info.identity_digest, DIGEST_LEN);
memcpy(rs->descriptor_digest, ri->cache_info.signed_descriptor_digest,
DIGEST_LEN);
rs->addr = ri->addr;
strlcpy(rs->nickname, ri->nickname, sizeof(rs->nickname));
rs->or_port = ri->or_port;
rs->dir_port = ri->dir_port;
}
| 1
|
264,376
|
int num_files() const { return sss_.size(); }
| 0
|
225,032
|
pqFreeCommandQueue(PGcmdQueueEntry *queue)
{
while (queue != NULL)
{
PGcmdQueueEntry *cur = queue;
queue = cur->next;
if (cur->query)
free(cur->query);
free(cur);
}
}
| 0
|
225,031
|
PQclientEncoding(const PGconn *conn)
{
if (!conn || conn->status != CONNECTION_OK)
return -1;
return conn->client_encoding;
}
| 0
|
234,216
|
debuginfod_fetch_separate_debug_info (struct dwarf_section * section,
char ** filename,
void * file)
{
size_t build_id_len;
unsigned char * build_id;
if (strcmp (section->uncompressed_name, ".gnu_debuglink") == 0)
{
/* Get the build-id of file. */
build_id = get_build_id (file);
build_id_len = 0;
}
else if (strcmp (section->uncompressed_name, ".gnu_debugaltlink") == 0)
{
/* Get the build-id of the debugaltlink file. */
unsigned int filelen;
filelen = strnlen ((const char *)section->start, section->size);
if (filelen == section->size)
/* Corrupt debugaltlink. */
return false;
build_id = section->start + filelen + 1;
build_id_len = section->size - (filelen + 1);
if (build_id_len == 0)
return false;
}
else
return false;
if (build_id)
{
int fd;
debuginfod_client * client;
client = debuginfod_begin ();
if (client == NULL)
return false;
/* Query debuginfod servers for the target file. If found its path
will be stored in filename. */
fd = debuginfod_find_debuginfo (client, build_id, build_id_len, filename);
debuginfod_end (client);
/* Only free build_id if we allocated space for a hex string
in get_build_id (). */
if (build_id_len == 0)
free (build_id);
if (fd >= 0)
{
/* File successfully retrieved. Close fd since we want to
use open_debug_file () on filename instead. */
close (fd);
return true;
}
}
return false;
}
| 0
|
393,526
|
static SQInteger table_getdelegate(HSQUIRRELVM v)
{
return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;
}
| 0
|
445,996
|
encryption_copy_progress_cb (goffset current_num_bytes,
goffset total_num_bytes,
gpointer user_data)
{
EncryptData *edata = user_data;
fr_archive_progress (edata->new_archive, (double) current_num_bytes / total_num_bytes);
}
| 0
|
500,673
|
ssize_t sftp_read(sftp_file handle, void *buf, size_t count) {
sftp_session sftp = handle->sftp;
sftp_message msg = NULL;
sftp_status_message status;
ssh_string datastring;
ssh_buffer buffer;
int id;
if (handle->eof) {
return 0;
}
buffer = ssh_buffer_new();
if (buffer == NULL) {
ssh_set_error_oom(sftp->session);
return -1;
}
id = sftp_get_new_id(handle->sftp);
if (buffer_add_u32(buffer, id) < 0 ||
buffer_add_ssh_string(buffer, handle->handle) < 0 ||
buffer_add_u64(buffer, htonll(handle->offset)) < 0 ||
buffer_add_u32(buffer,htonl(count)) < 0) {
ssh_set_error_oom(sftp->session);
ssh_buffer_free(buffer);
return -1;
}
if (sftp_packet_write(handle->sftp, SSH_FXP_READ, buffer) < 0) {
ssh_buffer_free(buffer);
return -1;
}
ssh_buffer_free(buffer);
while (msg == NULL) {
if (handle->nonblocking) {
if (ssh_channel_poll(handle->sftp->channel, 0) == 0) {
/* we cannot block */
return 0;
}
}
if (sftp_read_and_dispatch(handle->sftp) < 0) {
/* something nasty has happened */
return -1;
}
msg = sftp_dequeue(handle->sftp, id);
}
switch (msg->packet_type) {
case SSH_FXP_STATUS:
status = parse_status_msg(msg);
sftp_message_free(msg);
if (status == NULL) {
return -1;
}
sftp_set_error(sftp, status->status);
switch (status->status) {
case SSH_FX_EOF:
handle->eof = 1;
status_msg_free(status);
return 0;
default:
break;
}
ssh_set_error(sftp->session,SSH_REQUEST_DENIED,
"SFTP server: %s", status->errormsg);
status_msg_free(status);
return -1;
case SSH_FXP_DATA:
datastring = buffer_get_ssh_string(msg->payload);
sftp_message_free(msg);
if (datastring == NULL) {
ssh_set_error(sftp->session, SSH_FATAL,
"Received invalid DATA packet from sftp server");
return -1;
}
if (ssh_string_len(datastring) > count) {
ssh_set_error(sftp->session, SSH_FATAL,
"Received a too big DATA packet from sftp server: "
"%" PRIdS " and asked for %" PRIdS,
ssh_string_len(datastring), count);
ssh_string_free(datastring);
return -1;
}
count = ssh_string_len(datastring);
handle->offset += count;
memcpy(buf, ssh_string_data(datastring), count);
ssh_string_free(datastring);
return count;
default:
ssh_set_error(sftp->session, SSH_FATAL,
"Received message %d during read!", msg->packet_type);
sftp_message_free(msg);
return -1;
}
return -1; /* not reached */
}
| 0
|
443,705
|
utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* end)
{
const UChar* p = *pp;
(*pp) += 4;
if (*(p+1) == 0 && *(p+2) == 0 && *(p+3) == 0) {
int c, v;
if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
return TRUE;
}
c = *p;
v = ONIGENC_IS_UNICODE_ISO_8859_1_BIT_CTYPE(c,
(BIT_CTYPE_UPPER | BIT_CTYPE_LOWER));
if ((v | BIT_CTYPE_LOWER) != 0) {
/* 0xaa, 0xb5, 0xba are lower case letter, but can't convert. */
if (c >= 0xaa && c <= 0xba)
return FALSE;
else
return TRUE;
}
return (v != 0 ? TRUE : FALSE);
}
return FALSE;
}
| 0
|
317,232
|
static int smack_audit_rule_known(struct audit_krule *krule)
{
struct audit_field *f;
int i;
for (i = 0; i < krule->field_count; i++) {
f = &krule->fields[i];
if (f->type == AUDIT_SUBJ_USER || f->type == AUDIT_OBJ_USER)
return 1;
}
return 0;
}
| 0
|
436,151
|
static int io_poll_update(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_ring_ctx *ctx = req->ctx;
struct io_kiocb *preq;
bool completing;
int ret;
spin_lock_irq(&ctx->completion_lock);
preq = io_poll_find(ctx, req->poll_update.old_user_data, true);
if (!preq) {
ret = -ENOENT;
goto err;
}
if (!req->poll_update.update_events && !req->poll_update.update_user_data) {
completing = true;
ret = io_poll_remove_one(preq) ? 0 : -EALREADY;
goto err;
}
/*
* Don't allow racy completion with singleshot, as we cannot safely
* update those. For multishot, if we're racing with completion, just
* let completion re-add it.
*/
completing = !__io_poll_remove_one(preq, &preq->poll, false);
if (completing && (preq->poll.events & EPOLLONESHOT)) {
ret = -EALREADY;
goto err;
}
/* we now have a detached poll request. reissue. */
ret = 0;
err:
if (ret < 0) {
spin_unlock_irq(&ctx->completion_lock);
req_set_fail(req);
io_req_complete(req, ret);
return 0;
}
/* only mask one event flags, keep behavior flags */
if (req->poll_update.update_events) {
preq->poll.events &= ~0xffff;
preq->poll.events |= req->poll_update.events & 0xffff;
preq->poll.events |= IO_POLL_UNMASK;
}
if (req->poll_update.update_user_data)
preq->user_data = req->poll_update.new_user_data;
spin_unlock_irq(&ctx->completion_lock);
/* complete update request, we're done with it */
io_req_complete(req, ret);
if (!completing) {
ret = io_poll_add(preq, issue_flags);
if (ret < 0) {
req_set_fail(preq);
io_req_complete(preq, ret);
}
}
return 0;
| 0
|
95,901
|
void AddProductSpecificWorkItems(const InstallationState& original_state,
const InstallerState& installer_state,
const FilePath& setup_path,
const Version& new_version,
WorkItemList* list) {
const Products& products = installer_state.products();
for (size_t i = 0; i < products.size(); ++i) {
const Product& p = *products[i];
if (p.is_chrome_frame()) {
AddChromeFrameWorkItems(original_state, installer_state, setup_path,
new_version, p, list);
}
}
}
| 0
|
261,766
|
void RtmpProtocol::sendPingResponse(uint32_t time_stamp) {
sendUserControl(CONTROL_PING_RESPONSE, time_stamp);
}
| 0
|
468,376
|
g_socket_client_connect_to_host_finish (GSocketClient *client,
GAsyncResult *result,
GError **error)
{
return g_socket_client_connect_finish (client, result, error);
}
| 0
|
373,543
|
ipf_v6_key_extract(struct dp_packet *pkt, ovs_be16 dl_type, uint16_t zone,
struct ipf_list_key *key, uint16_t *start_data_byte,
uint16_t *end_data_byte, bool *ff, bool *lf)
{
const struct ovs_16aligned_ip6_hdr *l3 = dp_packet_l3(pkt);
uint8_t nw_frag = 0;
uint8_t nw_proto = l3->ip6_nxt;
const void *data = l3 + 1;
size_t datasize = dp_packet_l3_size(pkt) - sizeof *l3;
const struct ovs_16aligned_ip6_frag *frag_hdr = NULL;
parse_ipv6_ext_hdrs(&data, &datasize, &nw_proto, &nw_frag, &frag_hdr);
ovs_assert(nw_frag && frag_hdr);
ovs_be16 ip6f_offlg = frag_hdr->ip6f_offlg;
*start_data_byte = ntohs(ip6f_offlg & IP6F_OFF_MASK) +
sizeof (struct ovs_16aligned_ip6_frag);
*end_data_byte = *start_data_byte + dp_packet_l4_size(pkt) - 1;
*ff = ipf_is_first_v6_frag(ip6f_offlg);
*lf = ipf_is_last_v6_frag(ip6f_offlg);
memset(key, 0, sizeof *key);
key->ip_id = get_16aligned_be32(&frag_hdr->ip6f_ident);
key->dl_type = dl_type;
memcpy(&key->src_addr.ipv6, &l3->ip6_src, sizeof key->src_addr.ipv6);
/* We are not supporting parsing of the routing header to use as the
* dst address part of the key. */
memcpy(&key->dst_addr.ipv6, &l3->ip6_dst, sizeof key->dst_addr.ipv6);
key->nw_proto = 0; /* Not used for key for V6. */
key->zone = zone;
key->recirc_id = pkt->md.recirc_id;
}
| 0
|
477,382
|
R_API char *r_bin_java_print_methodhandle_cp_stringify(RBinJavaCPTypeObj *obj) {
ut32 size = 255, consumed = 0;
char *value = malloc (size);
ut8 ref_kind = obj->info.cp_method_handle.reference_kind;
if (value) {
memset (value, 0, size);
consumed = snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%s.%d",
obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,
R_BIN_JAVA_REF_METAS[ref_kind].name, obj->info.cp_method_handle.reference_index);
if (consumed >= size - 1) {
free (value);
size += size >> 1;
value = malloc (size);
if (value) {
memset (value, 0, size);
(void)snprintf (value, size, "%d.0x%04"PFMT64x ".%s.%s.%d",
obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name,
R_BIN_JAVA_REF_METAS[ref_kind].name, obj->info.cp_method_handle.reference_index);
}
}
}
return value;
}
| 0
|
225,561
|
explicit FractionalMaxPoolGradOp(OpKernelConstruction* context)
: OpKernel(context) {
OP_REQUIRES_OK(context, context->GetAttr("overlapping", &overlapping_));
}
| 0
|
292,608
|
int puma_parser_finish(puma_parser *parser)
{
if (puma_parser_has_error(parser) ) {
return -1;
} else if (puma_parser_is_finished(parser) ) {
return 1;
} else {
return 0;
}
}
| 0
|
247,356
|
static void pgpPrtVal(const char * pre, pgpValTbl vs, uint8_t val)
{
if (!_print) return;
if (pre && *pre)
fprintf(stderr, "%s", pre);
fprintf(stderr, "%s(%u)", pgpValStr(vs, val), (unsigned)val);
}
| 0
|
437,336
|
set_sunday_quick_search_skip_table(UChar* s, UChar* end, OnigEncoding enc,
UChar skip[], int* roffset)
{
int i, len, offset;
offset = 1;
if (ONIGENC_MBC_MINLEN(enc) > 1) {
UChar* p = s;
while (1) {
len = enclen(enc, p);
if (p + len >= end) {
UChar* q = p + (ONIGENC_MBC_MINLEN(enc) - 1);
while (q > p) {
if (*q != '\0') {
offset = q - p + 1;
break;
}
q--;
}
break;
}
p += len;
}
}
len = (int )(end - s);
if (len + offset >= ONIG_CHAR_TABLE_SIZE)
return ONIGERR_PARSER_BUG;
*roffset = offset;
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) skip[i] = (UChar )(len + offset);
for (i = 0; i < len; i++)
skip[s[i]] = len - i + (offset - 1);
return 0;
}
| 0
|
225,083
|
parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
{
const char *service = conninfo_getval(options, "service");
char serviceFile[MAXPGPATH];
char *env;
bool group_found = false;
int status;
struct stat stat_buf;
/*
* We have to special-case the environment variable PGSERVICE here, since
* this is and should be called before inserting environment defaults for
* other connection options.
*/
if (service == NULL)
service = getenv("PGSERVICE");
/* If no service name given, nothing to do */
if (service == NULL)
return 0;
/*
* Try PGSERVICEFILE if specified, else try ~/.pg_service.conf (if that
* exists).
*/
if ((env = getenv("PGSERVICEFILE")) != NULL)
strlcpy(serviceFile, env, sizeof(serviceFile));
else
{
char homedir[MAXPGPATH];
if (!pqGetHomeDirectory(homedir, sizeof(homedir)))
goto next_file;
snprintf(serviceFile, MAXPGPATH, "%s/%s", homedir, ".pg_service.conf");
if (stat(serviceFile, &stat_buf) != 0)
goto next_file;
}
status = parseServiceFile(serviceFile, service, options, errorMessage, &group_found);
if (group_found || status != 0)
return status;
next_file:
/*
* This could be used by any application so we can't use the binary
* location to find our config files.
*/
snprintf(serviceFile, MAXPGPATH, "%s/pg_service.conf",
getenv("PGSYSCONFDIR") ? getenv("PGSYSCONFDIR") : SYSCONFDIR);
if (stat(serviceFile, &stat_buf) != 0)
goto last_file;
status = parseServiceFile(serviceFile, service, options, errorMessage, &group_found);
if (status != 0)
return status;
last_file:
if (!group_found)
{
appendPQExpBuffer(errorMessage,
libpq_gettext("definition of service \"%s\" not found\n"), service);
return 3;
}
return 0;
}
| 0
|
279,952
|
getfile(
int fnum,
char_u *ffname_arg,
char_u *sfname_arg,
int setpm,
linenr_T lnum,
int forceit)
{
char_u *ffname = ffname_arg;
char_u *sfname = sfname_arg;
int other;
int retval;
char_u *free_me = NULL;
if (text_locked())
return GETFILE_ERROR;
if (curbuf_locked())
return GETFILE_ERROR;
if (fnum == 0)
{
// make ffname full path, set sfname
fname_expand(curbuf, &ffname, &sfname);
other = otherfile(ffname);
free_me = ffname; // has been allocated, free() later
}
else
other = (fnum != curbuf->b_fnum);
if (other)
++no_wait_return; // don't wait for autowrite message
if (other && !forceit && curbuf->b_nwindows == 1 && !buf_hide(curbuf)
&& curbufIsChanged() && autowrite(curbuf, forceit) == FAIL)
{
#if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
if (p_confirm && p_write)
dialog_changed(curbuf, FALSE);
if (curbufIsChanged())
#endif
{
if (other)
--no_wait_return;
no_write_message();
retval = GETFILE_NOT_WRITTEN; // file has been changed
goto theend;
}
}
if (other)
--no_wait_return;
if (setpm)
setpcmark();
if (!other)
{
if (lnum != 0)
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
retval = GETFILE_SAME_FILE; // it's in the same file
}
else if (do_ecmd(fnum, ffname, sfname, NULL, lnum,
(buf_hide(curbuf) ? ECMD_HIDE : 0) + (forceit ? ECMD_FORCEIT : 0),
curwin) == OK)
retval = GETFILE_OPEN_OTHER; // opened another file
else
retval = GETFILE_ERROR; // error encountered
theend:
vim_free(free_me);
return retval;
}
| 0
|
317,030
|
static int selinux_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode)
{
return may_create(dir, dentry, SECCLASS_FILE);
}
| 0
|
445,871
|
_window_started_loading_file (FrWindow *window,
GFile *file)
{
char *description;
description = get_action_description (window, FR_ACTION_LOADING_ARCHIVE, file);
fr_archive_message_cb (NULL, description, window);
g_free (description);
}
| 0
|
234,795
|
static int chunk_devid_filter(struct extent_buffer *leaf,
struct btrfs_chunk *chunk,
struct btrfs_balance_args *bargs)
{
struct btrfs_stripe *stripe;
int num_stripes = btrfs_chunk_num_stripes(leaf, chunk);
int i;
for (i = 0; i < num_stripes; i++) {
stripe = btrfs_stripe_nr(chunk, i);
if (btrfs_stripe_devid(leaf, stripe) == bargs->devid)
return 0;
}
return 1;
}
| 0
|
197,760
|
TfLiteStatus EvalGatherNd(TfLiteContext* context, const TfLiteTensor* params,
const TfLiteTensor* indices, TfLiteTensor* output) {
switch (params->type) {
case kTfLiteFloat32:
return GatherNd<float, IndicesT>(params, indices, output);
case kTfLiteUInt8:
return GatherNd<uint8_t, IndicesT>(params, indices, output);
case kTfLiteInt8:
return GatherNd<int8_t, IndicesT>(params, indices, output);
case kTfLiteInt16:
return GatherNd<int16_t, IndicesT>(params, indices, output);
case kTfLiteInt32:
return GatherNd<int32_t, IndicesT>(params, indices, output);
case kTfLiteInt64:
return GatherNd<int64_t, IndicesT>(params, indices, output);
case kTfLiteString:
return GatherNdString<IndicesT>(params, indices, output);
default:
context->ReportError(context,
"Params type '%s' are not supported by gather_nd.",
TfLiteTypeGetName(params->type));
return kTfLiteError;
}
}
| 1
|
317,200
|
static int __net_init selinux_nf_register(struct net *net)
{
return nf_register_net_hooks(net, selinux_nf_ops,
ARRAY_SIZE(selinux_nf_ops));
}
| 0
|
373,638
|
estack_sfile(estack_arg_T which UNUSED)
{
estack_T *entry;
#ifdef FEAT_EVAL
garray_T ga;
size_t len;
int idx;
etype_T last_type = ETYPE_SCRIPT;
char *type_name;
#endif
entry = ((estack_T *)exestack.ga_data) + exestack.ga_len - 1;
#ifdef FEAT_EVAL
if (which == ESTACK_SFILE && entry->es_type != ETYPE_UFUNC)
#endif
{
if (entry->es_name == NULL)
return NULL;
return vim_strsave(entry->es_name);
}
#ifdef FEAT_EVAL
// expand('<sfile>') works in a function for backwards compatibility, but
// may give an unexpected result. Disallow it in Vim 9 script.
if (which == ESTACK_SFILE && in_vim9script())
{
int save_emsg_off = emsg_off;
if (emsg_off == 1)
// f_expand() silences errors but we do want this one
emsg_off = 0;
emsg(_(e_cannot_expand_sfile_in_vim9_function));
emsg_off = save_emsg_off;
return NULL;
}
// Give information about each stack entry up to the root.
// For a function we compose the call stack, as it was done in the past:
// "function One[123]..Two[456]..Three"
ga_init2(&ga, sizeof(char), 100);
for (idx = 0; idx < exestack.ga_len; ++idx)
{
entry = ((estack_T *)exestack.ga_data) + idx;
if (entry->es_name != NULL)
{
long lnum = 0;
char *dots;
len = STRLEN(entry->es_name) + 15;
type_name = "";
if (entry->es_type != last_type)
{
switch (entry->es_type)
{
case ETYPE_SCRIPT: type_name = "script "; break;
case ETYPE_UFUNC: type_name = "function "; break;
default: type_name = ""; break;
}
last_type = entry->es_type;
}
len += STRLEN(type_name);
if (ga_grow(&ga, (int)len) == FAIL)
break;
if (idx == exestack.ga_len - 1)
lnum = which == ESTACK_STACK ? SOURCING_LNUM : 0;
else
lnum = entry->es_lnum;
dots = idx == exestack.ga_len - 1 ? "" : "..";
if (lnum == 0)
// For the bottom entry of <sfile>: do not add the line number,
// it is used in <slnum>. Also leave it out when the number is
// not set.
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s%s",
type_name, entry->es_name, dots);
else
vim_snprintf((char *)ga.ga_data + ga.ga_len, len, "%s%s[%ld]%s",
type_name, entry->es_name, lnum, dots);
ga.ga_len += (int)STRLEN((char *)ga.ga_data + ga.ga_len);
}
}
return (char_u *)ga.ga_data;
#endif
}
| 0
|
244,147
|
GF_Err vmhd_box_size(GF_Box *s)
{
GF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;
ptr->size += 8;
return GF_OK;
}
| 0
|
404,731
|
void put_files_struct(struct files_struct *files)
{
if (atomic_dec_and_test(&files->count)) {
struct fdtable *fdt = close_files(files);
/* free the arrays if they are not embedded */
if (fdt != &files->fdtab)
__free_fdtable(fdt);
kmem_cache_free(files_cachep, files);
}
}
| 0
|
221,468
|
flatpak_run_get_minimal_env (gboolean devel, gboolean use_ld_so_cache)
{
GPtrArray *env_array;
static const char * const copy[] = {
"PWD",
"GDMSESSION",
"XDG_CURRENT_DESKTOP",
"XDG_SESSION_DESKTOP",
"DESKTOP_SESSION",
"EMAIL_ADDRESS",
"HOME",
"HOSTNAME",
"LOGNAME",
"REAL_NAME",
"TERM",
"USER",
"USERNAME",
};
static const char * const copy_nodevel[] = {
"LANG",
"LANGUAGE",
"LC_ALL",
"LC_ADDRESS",
"LC_COLLATE",
"LC_CTYPE",
"LC_IDENTIFICATION",
"LC_MEASUREMENT",
"LC_MESSAGES",
"LC_MONETARY",
"LC_NAME",
"LC_NUMERIC",
"LC_PAPER",
"LC_TELEPHONE",
"LC_TIME",
};
int i;
env_array = g_ptr_array_new_with_free_func (g_free);
add_exports (env_array, default_exports, G_N_ELEMENTS (default_exports));
if (!use_ld_so_cache)
add_exports (env_array, no_ld_so_cache_exports, G_N_ELEMENTS (no_ld_so_cache_exports));
if (devel)
add_exports (env_array, devel_exports, G_N_ELEMENTS (devel_exports));
for (i = 0; i < G_N_ELEMENTS (copy); i++)
{
const char *current = g_getenv (copy[i]);
if (current)
g_ptr_array_add (env_array, g_strdup_printf ("%s=%s", copy[i], current));
}
if (!devel)
{
for (i = 0; i < G_N_ELEMENTS (copy_nodevel); i++)
{
const char *current = g_getenv (copy_nodevel[i]);
if (current)
g_ptr_array_add (env_array, g_strdup_printf ("%s=%s", copy_nodevel[i], current));
}
}
g_ptr_array_add (env_array, NULL);
return (char **) g_ptr_array_free (env_array, FALSE);
}
| 0
|
309,884
|
_nc_screen_resume(void)
{
NCURSES_SP_NAME(_nc_screen_resume) (CURRENT_SCREEN);
}
| 0
|
90,862
|
void NotifyOriginInUse(const GURL& origin) {
quota_manager_->NotifyOriginInUse(origin);
}
| 0
|
481,280
|
static int mlx5_fpga_conn_create_wq(struct mlx5_fpga_conn *conn, void *qpc)
{
struct mlx5_fpga_device *fdev = conn->fdev;
struct mlx5_core_dev *mdev = fdev->mdev;
struct mlx5_wq_param wqp;
wqp.buf_numa_node = mdev->priv.numa_node;
wqp.db_numa_node = mdev->priv.numa_node;
return mlx5_wq_qp_create(mdev, &wqp, qpc, &conn->qp.wq,
&conn->qp.wq_ctrl);
}
| 0
|
362,313
|
static void usb_audio_make_shortname(struct usb_device *dev,
struct snd_usb_audio *chip,
const struct snd_usb_audio_quirk *quirk)
{
struct snd_card *card = chip->card;
if (quirk && quirk->product_name && *quirk->product_name) {
strlcpy(card->shortname, quirk->product_name,
sizeof(card->shortname));
return;
}
/* retrieve the device string as shortname */
if (!dev->descriptor.iProduct ||
usb_string(dev, dev->descriptor.iProduct,
card->shortname, sizeof(card->shortname)) <= 0) {
/* no name available from anywhere, so use ID */
sprintf(card->shortname, "USB Device %#04x:%#04x",
USB_ID_VENDOR(chip->usb_id),
USB_ID_PRODUCT(chip->usb_id));
}
strim(card->shortname);
}
| 0
|
90,154
|
const std::string& IPAddress() const {
const Network* active = active_network();
if (active != NULL)
return active->ip_address();
if (ethernet_)
return ethernet_->ip_address();
static std::string null_address("0.0.0.0");
return null_address;
}
| 0
|
468,384
|
connection_attempt_ref (ConnectionAttempt *attempt)
{
g_ref_count_inc (&attempt->ref);
return attempt;
}
| 0
|
513,313
|
make_cond_for_table_from_pred(THD *thd, Item *root_cond, Item *cond,
table_map tables, table_map used_table,
int join_tab_idx_arg,
bool exclude_expensive_cond __attribute__
((unused)),
bool retain_ref_cond,
bool is_top_and_level)
{
table_map rand_table_bit= (table_map) RAND_TABLE_BIT;
if (used_table && !(cond->used_tables() & used_table))
return (COND*) 0; // Already checked
if (cond->type() == Item::COND_ITEM)
{
if (((Item_cond*) cond)->functype() == Item_func::COND_AND_FUNC)
{
/* Create new top level AND item */
Item_cond_and *new_cond=new (thd->mem_root) Item_cond_and(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
{
/*
Special handling of top level conjuncts with RAND_TABLE_BIT:
if such a conjunct contains a reference to a field that is not
an outer field then it is pushed to the corresponding table by
the same rule as all other conjuncts. Otherwise, if the conjunct
is used in WHERE is is pushed to the last joined table, if is it
is used in ON condition of an outer join it is pushed into the
last inner table of the outer join. Such conjuncts are pushed in
a call of make_cond_for_table_from_pred() with the
parameter 'used_table' equal to PSEUDO_TABLE_BITS.
*/
if (is_top_and_level && used_table == rand_table_bit &&
(item->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)
{
/* The conjunct with RAND_TABLE_BIT has been allready pushed */
continue;
}
Item *fix=make_cond_for_table_from_pred(thd, root_cond, item,
tables, used_table,
join_tab_idx_arg,
exclude_expensive_cond,
retain_ref_cond, false);
if (fix)
new_cond->argument_list()->push_back(fix, thd->mem_root);
}
switch (new_cond->argument_list()->elements) {
case 0:
return (COND*) 0; // Always true
case 1:
return new_cond->argument_list()->head();
default:
/*
Call fix_fields to propagate all properties of the children to
the new parent Item. This should not be expensive because all
children of Item_cond_and should be fixed by now.
*/
if (new_cond->fix_fields(thd, 0))
return (COND*) 0;
new_cond->used_tables_cache=
((Item_cond_and*) cond)->used_tables_cache &
tables;
return new_cond;
}
}
else
{ // Or list
if (is_top_and_level && used_table == rand_table_bit &&
(cond->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)
{
/* This top level formula with RAND_TABLE_BIT has been already pushed */
return (COND*) 0;
}
Item_cond_or *new_cond=new (thd->mem_root) Item_cond_or(thd);
if (!new_cond)
return (COND*) 0; // OOM /* purecov: inspected */
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
{
Item *fix=make_cond_for_table_from_pred(thd, root_cond, item,
tables, 0L,
join_tab_idx_arg,
exclude_expensive_cond,
retain_ref_cond, false);
if (!fix)
return (COND*) 0; // Always true
new_cond->argument_list()->push_back(fix, thd->mem_root);
}
/*
Call fix_fields to propagate all properties of the children to
the new parent Item. This should not be expensive because all
children of Item_cond_and should be fixed by now.
*/
new_cond->fix_fields(thd, 0);
new_cond->used_tables_cache= ((Item_cond_or*) cond)->used_tables_cache;
new_cond->top_level_item();
return new_cond;
}
}
if (is_top_and_level && used_table == rand_table_bit &&
(cond->used_tables() & ~OUTER_REF_TABLE_BIT) != rand_table_bit)
{
/* This top level formula with RAND_TABLE_BIT has been already pushed */
return (COND*) 0;
}
/*
Because the following test takes a while and it can be done
table_count times, we mark each item that we have examined with the result
of the test
*/
if ((cond->marker == 3 && !retain_ref_cond) ||
(cond->used_tables() & ~tables))
return (COND*) 0; // Can't check this yet
if (cond->marker == 2 || cond->eq_cmp_result() == Item::COND_OK)
{
cond->set_join_tab_idx(join_tab_idx_arg);
return cond; // Not boolean op
}
if (cond->type() == Item::FUNC_ITEM &&
((Item_func*) cond)->functype() == Item_func::EQ_FUNC)
{
Item *left_item= ((Item_func*) cond)->arguments()[0]->real_item();
Item *right_item= ((Item_func*) cond)->arguments()[1]->real_item();
if (left_item->type() == Item::FIELD_ITEM && !retain_ref_cond &&
test_if_ref(root_cond, (Item_field*) left_item,right_item))
{
cond->marker=3; // Checked when read
return (COND*) 0;
}
if (right_item->type() == Item::FIELD_ITEM && !retain_ref_cond &&
test_if_ref(root_cond, (Item_field*) right_item,left_item))
{
cond->marker=3; // Checked when read
return (COND*) 0;
}
}
cond->marker=2;
cond->set_join_tab_idx(join_tab_idx_arg);
return cond;
}
| 0
|
244,278
|
GF_Err tsro_box_size(GF_Box *s)
{
s->size += 4;
return GF_OK;
}
| 0
|
281,614
|
void CLASS apply_tiff()
{
int max_samp=0, raw=-1, thm=-1, i;
struct jhead jh;
thumb_misc = 16;
if (thumb_offset) {
fseek (ifp, thumb_offset, SEEK_SET);
if (ljpeg_start (&jh, 1)) {
if((unsigned)jh.bits<17 && (unsigned)jh.wide < 0x10000 && (unsigned)jh.high < 0x10000)
{
thumb_misc = jh.bits;
thumb_width = jh.wide;
thumb_height = jh.high;
}
}
}
for (i=0; i < tiff_nifds; i++) {
if (max_samp < tiff_ifd[i].samples)
max_samp = tiff_ifd[i].samples;
if (max_samp > 3) max_samp = 3;
if ((tiff_ifd[i].comp != 6 || tiff_ifd[i].samples != 3) &&
unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 &&
(unsigned)tiff_ifd[i].bps < 33 && (unsigned)tiff_ifd[i].samples < 13 &&
tiff_ifd[i].t_width*tiff_ifd[i].t_height > raw_width*raw_height) {
raw_width = tiff_ifd[i].t_width;
raw_height = tiff_ifd[i].t_height;
tiff_bps = tiff_ifd[i].bps;
tiff_compress = tiff_ifd[i].comp;
data_offset = tiff_ifd[i].offset;
tiff_flip = tiff_ifd[i].t_flip;
tiff_samples = tiff_ifd[i].samples;
tile_width = tiff_ifd[i].t_tile_width;
tile_length = tiff_ifd[i].t_tile_length;
#ifdef LIBRAW_LIBRARY_BUILD
data_size = tile_length < INT_MAX && tile_length>0 ? tiff_ifd[i].tile_maxbytes: tiff_ifd[i].bytes;
#endif
raw = i;
}
}
if (!tile_width ) tile_width = INT_MAX;
if (!tile_length) tile_length = INT_MAX;
for (i=tiff_nifds; i--; )
if (tiff_ifd[i].t_flip) tiff_flip = tiff_ifd[i].t_flip;
if (raw >= 0 && !load_raw)
switch (tiff_compress) {
case 32767:
if (tiff_ifd[raw].bytes == raw_width*raw_height) {
tiff_bps = 12;
load_raw = &CLASS sony_arw2_load_raw; break;
}
if (tiff_ifd[raw].bytes*8 != raw_width*raw_height*tiff_bps) {
raw_height += 8;
load_raw = &CLASS sony_arw_load_raw; break;
}
load_flags = 79;
case 32769:
load_flags++;
case 32770:
case 32773: goto slr;
case 0: case 1:
if (!strncmp(make,"OLYMPUS",7) &&
tiff_ifd[raw].bytes*2 == raw_width*raw_height*3)
load_flags = 24;
if (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) {
load_flags = 81;
tiff_bps = 12;
} slr:
switch (tiff_bps) {
case 8: load_raw = &CLASS eight_bit_load_raw; break;
case 12: if (tiff_ifd[raw].phint == 2)
load_flags = 6;
load_raw = &CLASS packed_load_raw; break;
case 14: load_flags = 0;
case 16: load_raw = &CLASS unpacked_load_raw;
if (!strncmp(make,"OLYMPUS",7) &&
tiff_ifd[raw].bytes*7 > raw_width*raw_height)
load_raw = &CLASS olympus_load_raw;
}
break;
case 6: case 7: case 99:
load_raw = &CLASS lossless_jpeg_load_raw; break;
case 262:
load_raw = &CLASS kodak_262_load_raw; break;
case 34713:
if ((raw_width+9)/10*16*raw_height == tiff_ifd[raw].bytes) {
load_raw = &CLASS packed_load_raw;
load_flags = 1;
} else if (raw_width*raw_height*2 == tiff_ifd[raw].bytes) {
load_raw = &CLASS unpacked_load_raw;
load_flags = 4;
order = 0x4d4d;
} else
load_raw = &CLASS nikon_load_raw; break;
case 65535:
load_raw = &CLASS pentax_load_raw; break;
case 65000:
switch (tiff_ifd[raw].phint) {
case 2: load_raw = &CLASS kodak_rgb_load_raw; filters = 0; break;
case 6: load_raw = &CLASS kodak_ycbcr_load_raw; filters = 0; break;
case 32803: load_raw = &CLASS kodak_65000_load_raw;
}
case 32867: case 34892: break;
default: is_raw = 0;
}
if (!dng_version)
if ( (tiff_samples == 3 && tiff_ifd[raw].bytes && tiff_bps != 14 &&
tiff_compress != 32769 && tiff_compress != 32770)
|| (tiff_bps == 8 && !strcasestr(make,"Kodak") &&
!strstr(model2,"DEBUG RAW")))
is_raw = 0;
for (i=0; i < tiff_nifds; i++)
if (i != raw && tiff_ifd[i].samples == max_samp &&
tiff_ifd[i].bps>0 && tiff_ifd[i].bps < 33 &&
unsigned(tiff_ifd[i].t_width | tiff_ifd[i].t_height) < 0x10000 &&
tiff_ifd[i].t_width * tiff_ifd[i].t_height / (SQR(tiff_ifd[i].bps)+1) >
thumb_width * thumb_height / (SQR(thumb_misc)+1)
&& tiff_ifd[i].comp != 34892) {
thumb_width = tiff_ifd[i].t_width;
thumb_height = tiff_ifd[i].t_height;
thumb_offset = tiff_ifd[i].offset;
thumb_length = tiff_ifd[i].bytes;
thumb_misc = tiff_ifd[i].bps;
thm = i;
}
if (thm >= 0) {
thumb_misc |= tiff_ifd[thm].samples << 5;
switch (tiff_ifd[thm].comp) {
case 0:
write_thumb = &CLASS layer_thumb;
break;
case 1:
if (tiff_ifd[thm].bps <= 8)
write_thumb = &CLASS ppm_thumb;
else if (!strcmp(make,"Imacon"))
write_thumb = &CLASS ppm16_thumb;
else
thumb_load_raw = &CLASS kodak_thumb_load_raw;
break;
case 65000:
thumb_load_raw = tiff_ifd[thm].phint == 6 ?
&CLASS kodak_ycbcr_load_raw : &CLASS kodak_rgb_load_raw;
}
}
}
| 0
|
310,152
|
has_mouse(void)
{
return _nc_has_mouse(CURRENT_SCREEN);
}
| 0
|
301,383
|
static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
const char *name,
uint32 security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
{
NTSTATUS result;
START_PROFILE(get_nt_acl);
result = posix_get_nt_acl(handle->conn, name, security_info,
mem_ctx, ppdesc);
END_PROFILE(get_nt_acl);
return result;
}
| 0
|
384,841
|
trans_characters(
char_u *buf,
int bufsize)
{
int len; // length of string needing translation
int room; // room in buffer after string
char_u *trs; // translated character
int trs_len; // length of trs[]
len = (int)STRLEN(buf);
room = bufsize - len;
while (*buf != 0)
{
// Assume a multi-byte character doesn't need translation.
if (has_mbyte && (trs_len = (*mb_ptr2len)(buf)) > 1)
len -= trs_len;
else
{
trs = transchar_byte(*buf);
trs_len = (int)STRLEN(trs);
if (trs_len > 1)
{
room -= trs_len - 1;
if (room <= 0)
return;
mch_memmove(buf + trs_len, buf + 1, (size_t)len);
}
mch_memmove(buf, trs, (size_t)trs_len);
--len;
}
buf += trs_len;
}
}
| 0
|
326,617
|
create_dir(struct archive_write_disk *a, char *path)
{
struct stat st;
struct fixup_entry *le;
char *slash, *base;
mode_t mode_final, mode;
int r;
/* Check for special names and just skip them. */
slash = strrchr(path, '/');
if (slash == NULL)
base = path;
else
base = slash + 1;
if (base[0] == '\0' ||
(base[0] == '.' && base[1] == '\0') ||
(base[0] == '.' && base[1] == '.' && base[2] == '\0')) {
/* Don't bother trying to create null path, '.', or '..'. */
if (slash != NULL) {
*slash = '\0';
r = create_dir(a, path);
*slash = '/';
return (r);
}
return (ARCHIVE_OK);
}
/*
* Yes, this should be stat() and not lstat(). Using lstat()
* here loses the ability to extract through symlinks. Also note
* that this should not use the a->st cache.
*/
if (la_stat(path, &st) == 0) {
if (S_ISDIR(st.st_mode))
return (ARCHIVE_OK);
if ((a->flags & ARCHIVE_EXTRACT_NO_OVERWRITE)) {
archive_set_error(&a->archive, EEXIST,
"Can't create directory '%s'", path);
return (ARCHIVE_FAILED);
}
if (unlink(path) != 0) {
archive_set_error(&a->archive, errno,
"Can't create directory '%s': "
"Conflicting file cannot be removed",
path);
return (ARCHIVE_FAILED);
}
} else if (errno != ENOENT && errno != ENOTDIR) {
/* Stat failed? */
archive_set_error(&a->archive, errno,
"Can't test directory '%s'", path);
return (ARCHIVE_FAILED);
} else if (slash != NULL) {
*slash = '\0';
r = create_dir(a, path);
*slash = '/';
if (r != ARCHIVE_OK)
return (r);
}
/*
* Mode we want for the final restored directory. Per POSIX,
* implicitly-created dirs must be created obeying the umask.
* There's no mention whether this is different for privileged
* restores (which the rest of this code handles by pretending
* umask=0). I've chosen here to always obey the user's umask for
* implicit dirs, even if _EXTRACT_PERM was specified.
*/
mode_final = DEFAULT_DIR_MODE & ~a->user_umask;
/* Mode we want on disk during the restore process. */
mode = mode_final;
mode |= MINIMUM_DIR_MODE;
mode &= MAXIMUM_DIR_MODE;
if (mkdir(path, mode) == 0) {
if (mode != mode_final) {
le = new_fixup(a, path);
if (le == NULL)
return (ARCHIVE_FATAL);
le->fixup |=TODO_MODE_BASE;
le->mode = mode_final;
}
return (ARCHIVE_OK);
}
/*
* Without the following check, a/b/../b/c/d fails at the
* second visit to 'b', so 'd' can't be created. Note that we
* don't add it to the fixup list here, as it's already been
* added.
*/
if (la_stat(path, &st) == 0 && S_ISDIR(st.st_mode))
return (ARCHIVE_OK);
archive_set_error(&a->archive, errno, "Failed to create dir '%s'",
path);
return (ARCHIVE_FAILED);
}
| 0
|
512,781
|
Item_cache(THD *thd, const Type_handler *handler):
Item(thd),
Type_handler_hybrid_field_type(handler),
example(0), cached_field(0),
value_cached(0),
used_table_map(0)
{
maybe_null= 1;
null_value= 1;
null_value_inside= true;
}
| 0
|
225,827
|
GF_Err tims_box_size(GF_Box *s)
{
s->size += 4;
return GF_OK;
}
| 0
|
261,241
|
static int SN_WillMessage(MqttClient *client, SN_Will *will)
{
int rc, len;
/* Validate required arguments */
if (client == NULL) {
return MQTT_CODE_ERROR_BAD_ARG;
}
#ifdef WOLFMQTT_MULTITHREAD
rc = wm_SemLock(&client->lockClient);
if (rc == 0) {
/* inform other threads of expected response */
rc = MqttClient_RespList_Add(client,
(MqttPacketType)SN_MSG_TYPE_WILLMSGREQ, 0,
&will->pendResp, &will->resp.msgResp);
wm_SemUnlock(&client->lockClient);
}
if (rc != 0) {
return rc; /* Error locking client */
}
#endif
/* Wait for Will Message Request */
rc = SN_Client_WaitType(client, &will->resp.msgResp,
SN_MSG_TYPE_WILLMSGREQ, 0, client->cmd_timeout_ms);
#ifdef WOLFMQTT_NONBLOCK
if (rc == MQTT_CODE_CONTINUE)
return rc;
#endif
#ifdef WOLFMQTT_MULTITHREAD
if (wm_SemLock(&client->lockClient) == 0) {
MqttClient_RespList_Remove(client, &will->pendResp);
wm_SemUnlock(&client->lockClient);
}
#endif
if (rc == 0) {
#ifdef WOLFMQTT_MULTITHREAD
/* Lock send socket mutex */
rc = wm_SemLock(&client->lockSend);
if (rc != 0) {
return rc;
}
#endif
/* Encode Will Message */
len = rc = SN_Encode_WillMsg(client->tx_buf,
client->tx_buf_len, will);
#ifdef WOLFMQTT_DEBUG_CLIENT
PRINTF("EncodePacket: Len %d, Type %s (%d)",
rc, SN_Packet_TypeDesc(SN_MSG_TYPE_WILLMSG),
SN_MSG_TYPE_WILLMSG);
#endif
if (rc > 0) {
/* Send Will Topic packet */
rc = MqttPacket_Write(client, client->tx_buf, len);
if (rc == len) {
rc = 0;
}
}
#ifdef WOLFMQTT_MULTITHREAD
wm_SemUnlock(&client->lockSend);
#endif
}
return rc;
}
| 0
|
427,158
|
static void localfunc (LexState *ls) {
expdesc b;
FuncState *fs = ls->fs;
int fvar = fs->nactvar; /* function's variable index */
new_localvar(ls, str_checkname(ls)); /* new local variable */
adjustlocalvars(ls, 1); /* enter its scope */
body(ls, &b, 0, ls->linenumber); /* function created in next register */
/* debug information will only see the variable after this point! */
localdebuginfo(fs, fvar)->startpc = fs->pc;
}
| 0
|
512,448
|
void Item_func_decode_oracle::print(String *str, enum_query_type query_type)
{
str->append(func_name());
str->append('(');
args[0]->print(str, query_type);
for (uint i= 1, count= when_count() ; i <= count; i++)
{
str->append(',');
args[i]->print(str, query_type);
str->append(',');
args[i+count]->print(str, query_type);
}
Item **else_expr= Item_func_case_simple::else_expr_addr();
if (else_expr)
{
str->append(',');
(*else_expr)->print(str, query_type);
}
str->append(')');
}
| 0
|
402,663
|
handle_kill_daemon(context *ctx UNUSED,
struct pollfd *pollfd UNUSED,
socklen_t size UNUSED)
{
should_exit = 1;
}
| 0
|
376,676
|
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 of the file to load" }
};
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 save" },
{ GIMP_PDB_STRING, "filename", "The name of the file to save the image in" },
{ GIMP_PDB_STRING, "raw-filename", "The name of the file to save the image in" },
{ GIMP_PDB_INT32, "spacing", "Spacing of the brush" },
{ GIMP_PDB_STRING, "description", "Short description of the brush" }
};
gimp_install_procedure (LOAD_PROC,
"Loads GIMP brushes",
"Loads GIMP brushes (1 or 4 bpp and old .gpb format)",
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
"1997-2005",
N_("GIMP brush"),
NULL,
GIMP_PLUGIN,
G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
load_args, load_return_vals);
gimp_plugin_icon_register (LOAD_PROC, GIMP_ICON_TYPE_STOCK_ID,
(const guint8 *) GIMP_STOCK_BRUSH);
gimp_register_file_handler_mime (LOAD_PROC, "image/x-gimp-gbr");
gimp_register_magic_load_handler (LOAD_PROC,
"gbr, gpb",
"",
"20, string, GIMP");
gimp_install_procedure (SAVE_PROC,
"Saves files in the GIMP brush file format",
"Saves files in the GIMP brush file format",
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
"Tim Newsome, Jens Lautenbacher, Sven Neumann",
"1997-2000",
N_("GIMP brush"),
"RGB*, GRAY*",
GIMP_PLUGIN,
G_N_ELEMENTS (save_args), 0,
save_args, NULL);
gimp_plugin_icon_register (SAVE_PROC, GIMP_ICON_TYPE_STOCK_ID,
(const guint8 *) GIMP_STOCK_BRUSH);
gimp_register_file_handler_mime (SAVE_PROC, "image/x-gimp-gbr");
gimp_register_save_handler (SAVE_PROC, "gbr", "");
}
| 0
|
424,973
|
static int iwl_pcie_load_firmware_chunk(struct iwl_trans *trans,
u32 dst_addr, dma_addr_t phy_addr,
u32 byte_cnt)
{
struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans);
unsigned long flags;
int ret;
trans_pcie->ucode_write_complete = false;
if (!iwl_trans_grab_nic_access(trans, &flags))
return -EIO;
iwl_pcie_load_firmware_chunk_fh(trans, dst_addr, phy_addr,
byte_cnt);
iwl_trans_release_nic_access(trans, &flags);
ret = wait_event_timeout(trans_pcie->ucode_write_waitq,
trans_pcie->ucode_write_complete, 5 * HZ);
if (!ret) {
IWL_ERR(trans, "Failed to load firmware chunk!\n");
iwl_trans_pcie_dump_regs(trans);
return -ETIMEDOUT;
}
return 0;
}
| 0
|
338,060
|
BinaryConsts::ASTNodes WasmBinaryBuilder::readExpression(Expression*& curr) {
if (pos == endOfFunction) {
throwError("Reached function end without seeing End opcode");
}
BYN_TRACE("zz recurse into " << ++depth << " at " << pos << std::endl);
readNextDebugLocation();
std::set<Function::DebugLocation> currDebugLocation;
if (debugLocation.size()) {
currDebugLocation.insert(*debugLocation.begin());
}
size_t startPos = pos;
uint8_t code = getInt8();
BYN_TRACE("readExpression seeing " << (int)code << std::endl);
switch (code) {
case BinaryConsts::Block:
visitBlock((curr = allocator.alloc<Block>())->cast<Block>());
break;
case BinaryConsts::If:
visitIf((curr = allocator.alloc<If>())->cast<If>());
break;
case BinaryConsts::Loop:
visitLoop((curr = allocator.alloc<Loop>())->cast<Loop>());
break;
case BinaryConsts::Br:
case BinaryConsts::BrIf:
visitBreak((curr = allocator.alloc<Break>())->cast<Break>(), code);
break; // code distinguishes br from br_if
case BinaryConsts::BrTable:
visitSwitch((curr = allocator.alloc<Switch>())->cast<Switch>());
break;
case BinaryConsts::CallFunction:
visitCall((curr = allocator.alloc<Call>())->cast<Call>());
break;
case BinaryConsts::CallIndirect:
visitCallIndirect(
(curr = allocator.alloc<CallIndirect>())->cast<CallIndirect>());
break;
case BinaryConsts::RetCallFunction: {
auto call = allocator.alloc<Call>();
call->isReturn = true;
curr = call;
visitCall(call);
break;
}
case BinaryConsts::RetCallIndirect: {
auto call = allocator.alloc<CallIndirect>();
call->isReturn = true;
curr = call;
visitCallIndirect(call);
break;
}
case BinaryConsts::LocalGet:
visitLocalGet((curr = allocator.alloc<LocalGet>())->cast<LocalGet>());
break;
case BinaryConsts::LocalTee:
case BinaryConsts::LocalSet:
visitLocalSet((curr = allocator.alloc<LocalSet>())->cast<LocalSet>(),
code);
break;
case BinaryConsts::GlobalGet:
visitGlobalGet((curr = allocator.alloc<GlobalGet>())->cast<GlobalGet>());
break;
case BinaryConsts::GlobalSet:
visitGlobalSet((curr = allocator.alloc<GlobalSet>())->cast<GlobalSet>());
break;
case BinaryConsts::Select:
case BinaryConsts::SelectWithType:
visitSelect((curr = allocator.alloc<Select>())->cast<Select>(), code);
break;
case BinaryConsts::Return:
visitReturn((curr = allocator.alloc<Return>())->cast<Return>());
break;
case BinaryConsts::Nop:
visitNop((curr = allocator.alloc<Nop>())->cast<Nop>());
break;
case BinaryConsts::Unreachable:
visitUnreachable(
(curr = allocator.alloc<Unreachable>())->cast<Unreachable>());
break;
case BinaryConsts::Drop:
visitDrop((curr = allocator.alloc<Drop>())->cast<Drop>());
break;
case BinaryConsts::End:
curr = nullptr;
// Pop the current control flow structure off the stack. If there is none
// then this is the "end" of the function itself, which also emits an
// "end" byte.
if (!controlFlowStack.empty()) {
controlFlowStack.pop_back();
}
break;
case BinaryConsts::Else:
case BinaryConsts::Catch:
case BinaryConsts::CatchAll: {
curr = nullptr;
if (DWARF && currFunction) {
assert(!controlFlowStack.empty());
auto currControlFlow = controlFlowStack.back();
BinaryLocation delimiterId;
if (currControlFlow->is<If>()) {
delimiterId = BinaryLocations::Else;
} else {
// Both Catch and CatchAll can simply append to the list as we go, as
// we visit them in the right order in the binary, and like the binary
// we store the CatchAll at the end.
delimiterId =
currFunction->delimiterLocations[currControlFlow].size();
}
currFunction->delimiterLocations[currControlFlow][delimiterId] =
startPos - codeSectionLocation;
}
break;
}
case BinaryConsts::Delegate: {
curr = nullptr;
if (DWARF && currFunction) {
assert(!controlFlowStack.empty());
controlFlowStack.pop_back();
}
break;
}
case BinaryConsts::RefNull:
visitRefNull((curr = allocator.alloc<RefNull>())->cast<RefNull>());
break;
case BinaryConsts::RefIsNull:
visitRefIs((curr = allocator.alloc<RefIs>())->cast<RefIs>(), code);
break;
case BinaryConsts::RefFunc:
visitRefFunc((curr = allocator.alloc<RefFunc>())->cast<RefFunc>());
break;
case BinaryConsts::RefEq:
visitRefEq((curr = allocator.alloc<RefEq>())->cast<RefEq>());
break;
case BinaryConsts::RefAsNonNull:
visitRefAs((curr = allocator.alloc<RefAs>())->cast<RefAs>(), code);
break;
case BinaryConsts::BrOnNull:
maybeVisitBrOn(curr, code);
break;
case BinaryConsts::BrOnNonNull:
maybeVisitBrOn(curr, code);
break;
case BinaryConsts::TableGet:
visitTableGet((curr = allocator.alloc<TableGet>())->cast<TableGet>());
break;
case BinaryConsts::TableSet:
visitTableSet((curr = allocator.alloc<TableSet>())->cast<TableSet>());
break;
case BinaryConsts::Try:
visitTryOrTryInBlock(curr);
break;
case BinaryConsts::Throw:
visitThrow((curr = allocator.alloc<Throw>())->cast<Throw>());
break;
case BinaryConsts::Rethrow:
visitRethrow((curr = allocator.alloc<Rethrow>())->cast<Rethrow>());
break;
case BinaryConsts::MemorySize: {
auto size = allocator.alloc<MemorySize>();
if (wasm.memory.is64()) {
size->make64();
}
curr = size;
visitMemorySize(size);
break;
}
case BinaryConsts::MemoryGrow: {
auto grow = allocator.alloc<MemoryGrow>();
if (wasm.memory.is64()) {
grow->make64();
}
curr = grow;
visitMemoryGrow(grow);
break;
}
case BinaryConsts::CallRef:
visitCallRef((curr = allocator.alloc<CallRef>())->cast<CallRef>());
break;
case BinaryConsts::RetCallRef: {
auto call = allocator.alloc<CallRef>();
call->isReturn = true;
curr = call;
visitCallRef(call);
break;
}
case BinaryConsts::Let: {
visitLet((curr = allocator.alloc<Block>())->cast<Block>());
break;
}
case BinaryConsts::AtomicPrefix: {
code = static_cast<uint8_t>(getU32LEB());
if (maybeVisitLoad(curr, code, /*isAtomic=*/true)) {
break;
}
if (maybeVisitStore(curr, code, /*isAtomic=*/true)) {
break;
}
if (maybeVisitAtomicRMW(curr, code)) {
break;
}
if (maybeVisitAtomicCmpxchg(curr, code)) {
break;
}
if (maybeVisitAtomicWait(curr, code)) {
break;
}
if (maybeVisitAtomicNotify(curr, code)) {
break;
}
if (maybeVisitAtomicFence(curr, code)) {
break;
}
throwError("invalid code after atomic prefix: " + std::to_string(code));
break;
}
case BinaryConsts::MiscPrefix: {
auto opcode = getU32LEB();
if (maybeVisitTruncSat(curr, opcode)) {
break;
}
if (maybeVisitMemoryInit(curr, opcode)) {
break;
}
if (maybeVisitDataDrop(curr, opcode)) {
break;
}
if (maybeVisitMemoryCopy(curr, opcode)) {
break;
}
if (maybeVisitMemoryFill(curr, opcode)) {
break;
}
if (maybeVisitTableSize(curr, opcode)) {
break;
}
if (maybeVisitTableGrow(curr, opcode)) {
break;
}
throwError("invalid code after misc prefix: " + std::to_string(opcode));
break;
}
case BinaryConsts::SIMDPrefix: {
auto opcode = getU32LEB();
if (maybeVisitSIMDBinary(curr, opcode)) {
break;
}
if (maybeVisitSIMDUnary(curr, opcode)) {
break;
}
if (maybeVisitSIMDConst(curr, opcode)) {
break;
}
if (maybeVisitSIMDStore(curr, opcode)) {
break;
}
if (maybeVisitSIMDExtract(curr, opcode)) {
break;
}
if (maybeVisitSIMDReplace(curr, opcode)) {
break;
}
if (maybeVisitSIMDShuffle(curr, opcode)) {
break;
}
if (maybeVisitSIMDTernary(curr, opcode)) {
break;
}
if (maybeVisitSIMDShift(curr, opcode)) {
break;
}
if (maybeVisitSIMDLoad(curr, opcode)) {
break;
}
if (maybeVisitSIMDLoadStoreLane(curr, opcode)) {
break;
}
throwError("invalid code after SIMD prefix: " + std::to_string(opcode));
break;
}
case BinaryConsts::GCPrefix: {
auto opcode = getU32LEB();
if (maybeVisitI31New(curr, opcode)) {
break;
}
if (maybeVisitI31Get(curr, opcode)) {
break;
}
if (maybeVisitRefTest(curr, opcode)) {
break;
}
if (maybeVisitRefCast(curr, opcode)) {
break;
}
if (maybeVisitBrOn(curr, opcode)) {
break;
}
if (maybeVisitRttCanon(curr, opcode)) {
break;
}
if (maybeVisitRttSub(curr, opcode)) {
break;
}
if (maybeVisitStructNew(curr, opcode)) {
break;
}
if (maybeVisitStructGet(curr, opcode)) {
break;
}
if (maybeVisitStructSet(curr, opcode)) {
break;
}
if (maybeVisitArrayNew(curr, opcode)) {
break;
}
if (maybeVisitArrayInit(curr, opcode)) {
break;
}
if (maybeVisitArrayGet(curr, opcode)) {
break;
}
if (maybeVisitArraySet(curr, opcode)) {
break;
}
if (maybeVisitArrayLen(curr, opcode)) {
break;
}
if (maybeVisitArrayCopy(curr, opcode)) {
break;
}
if (opcode == BinaryConsts::RefIsFunc ||
opcode == BinaryConsts::RefIsData ||
opcode == BinaryConsts::RefIsI31) {
visitRefIs((curr = allocator.alloc<RefIs>())->cast<RefIs>(), opcode);
break;
}
if (opcode == BinaryConsts::RefAsFunc ||
opcode == BinaryConsts::RefAsData ||
opcode == BinaryConsts::RefAsI31) {
visitRefAs((curr = allocator.alloc<RefAs>())->cast<RefAs>(), opcode);
break;
}
throwError("invalid code after GC prefix: " + std::to_string(opcode));
break;
}
default: {
// otherwise, the code is a subcode TODO: optimize
if (maybeVisitBinary(curr, code)) {
break;
}
if (maybeVisitUnary(curr, code)) {
break;
}
if (maybeVisitConst(curr, code)) {
break;
}
if (maybeVisitLoad(curr, code, /*isAtomic=*/false)) {
break;
}
if (maybeVisitStore(curr, code, /*isAtomic=*/false)) {
break;
}
throwError("bad node code " + std::to_string(code));
break;
}
}
if (curr) {
if (currDebugLocation.size()) {
requireFunctionContext("debugLocation");
currFunction->debugLocations[curr] = *currDebugLocation.begin();
}
if (DWARF && currFunction) {
currFunction->expressionLocations[curr] =
BinaryLocations::Span{BinaryLocation(startPos - codeSectionLocation),
BinaryLocation(pos - codeSectionLocation)};
}
}
BYN_TRACE("zz recurse from " << depth-- << " at " << pos << std::endl);
return BinaryConsts::ASTNodes(code);
}
| 0
|
221,398
|
int svm_allocate_nested(struct vcpu_svm *svm)
{
struct page *vmcb02_page;
if (svm->nested.initialized)
return 0;
vmcb02_page = alloc_page(GFP_KERNEL_ACCOUNT | __GFP_ZERO);
if (!vmcb02_page)
return -ENOMEM;
svm->nested.vmcb02.ptr = page_address(vmcb02_page);
svm->nested.vmcb02.pa = __sme_set(page_to_pfn(vmcb02_page) << PAGE_SHIFT);
svm->nested.msrpm = svm_vcpu_alloc_msrpm();
if (!svm->nested.msrpm)
goto err_free_vmcb02;
svm_vcpu_init_msrpm(&svm->vcpu, svm->nested.msrpm);
svm->nested.initialized = true;
return 0;
err_free_vmcb02:
__free_page(vmcb02_page);
return -ENOMEM;
}
| 0
|
409,509
|
starttermcap(void)
{
if (full_screen && !termcap_active)
{
MAY_WANT_TO_LOG_THIS;
out_str(T_TI); // start termcap mode
out_str(T_CTI); // start "raw" mode
out_str(T_KS); // start "keypad transmit" mode
out_str(T_BE); // enable bracketed paste mode
#if defined(UNIX) || defined(VMS)
// Enable xterm's focus reporting mode when 'esckeys' is set.
if (p_ek && *T_FE != NUL)
out_str(T_FE);
#endif
out_flush();
termcap_active = TRUE;
screen_start(); // don't know where cursor is now
#ifdef FEAT_TERMRESPONSE
# ifdef FEAT_GUI
if (!gui.in_use && !gui.starting)
# endif
{
may_req_termresponse();
// Immediately check for a response. If t_Co changes, we don't
// want to redraw with wrong colors first.
if (crv_status.tr_progress == STATUS_SENT)
check_for_codes_from_term();
}
#endif
}
}
| 0
|
512,688
|
int Arg_comparator::compare_time()
{
THD *thd= current_thd;
longlong val1= (*a)->val_time_packed(thd);
if (!(*a)->null_value)
{
longlong val2= (*b)->val_time_packed(thd);
if (!(*b)->null_value)
return compare_not_null_values(val1, val2);
}
if (set_null)
owner->null_value= true;
return -1;
}
| 0
|
291,813
|
static int create_con_cq_qp(struct rtrs_clt_con *con)
{
struct rtrs_clt_path *clt_path = to_clt_path(con->c.path);
u32 max_send_wr, max_recv_wr, cq_num, max_send_sge, wr_limit;
int err, cq_vector;
struct rtrs_msg_rkey_rsp *rsp;
lockdep_assert_held(&con->con_mutex);
if (con->c.cid == 0) {
max_send_sge = 1;
/* We must be the first here */
if (WARN_ON(clt_path->s.dev))
return -EINVAL;
/*
* The whole session uses device from user connection.
* Be careful not to close user connection before ib dev
* is gracefully put.
*/
clt_path->s.dev = rtrs_ib_dev_find_or_add(con->c.cm_id->device,
&dev_pd);
if (!clt_path->s.dev) {
rtrs_wrn(clt_path->clt,
"rtrs_ib_dev_find_get_or_add(): no memory\n");
return -ENOMEM;
}
clt_path->s.dev_ref = 1;
query_fast_reg_mode(clt_path);
wr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;
/*
* Two (request + registration) completion for send
* Two for recv if always_invalidate is set on server
* or one for recv.
* + 2 for drain and heartbeat
* in case qp gets into error state.
*/
max_send_wr =
min_t(int, wr_limit, SERVICE_CON_QUEUE_DEPTH * 2 + 2);
max_recv_wr = max_send_wr;
} else {
/*
* Here we assume that session members are correctly set.
* This is always true if user connection (cid == 0) is
* established first.
*/
if (WARN_ON(!clt_path->s.dev))
return -EINVAL;
if (WARN_ON(!clt_path->queue_depth))
return -EINVAL;
wr_limit = clt_path->s.dev->ib_dev->attrs.max_qp_wr;
/* Shared between connections */
clt_path->s.dev_ref++;
max_send_wr = min_t(int, wr_limit,
/* QD * (REQ + RSP + FR REGS or INVS) + drain */
clt_path->queue_depth * 3 + 1);
max_recv_wr = min_t(int, wr_limit,
clt_path->queue_depth * 3 + 1);
max_send_sge = 2;
}
atomic_set(&con->c.sq_wr_avail, max_send_wr);
cq_num = max_send_wr + max_recv_wr;
/* alloc iu to recv new rkey reply when server reports flags set */
if (clt_path->flags & RTRS_MSG_NEW_RKEY_F || con->c.cid == 0) {
con->rsp_ius = rtrs_iu_alloc(cq_num, sizeof(*rsp),
GFP_KERNEL,
clt_path->s.dev->ib_dev,
DMA_FROM_DEVICE,
rtrs_clt_rdma_done);
if (!con->rsp_ius)
return -ENOMEM;
con->queue_num = cq_num;
}
cq_num = max_send_wr + max_recv_wr;
cq_vector = con->cpu % clt_path->s.dev->ib_dev->num_comp_vectors;
if (con->c.cid >= clt_path->s.irq_con_num)
err = rtrs_cq_qp_create(&clt_path->s, &con->c, max_send_sge,
cq_vector, cq_num, max_send_wr,
max_recv_wr, IB_POLL_DIRECT);
else
err = rtrs_cq_qp_create(&clt_path->s, &con->c, max_send_sge,
cq_vector, cq_num, max_send_wr,
max_recv_wr, IB_POLL_SOFTIRQ);
/*
* In case of error we do not bother to clean previous allocations,
* since destroy_con_cq_qp() must be called.
*/
return err;
}
| 0
|
338,038
|
uint32_t WasmBinaryBuilder::getInt32() {
BYN_TRACE("<==\n");
auto ret = uint32_t(getInt16());
ret |= uint32_t(getInt16()) << 16;
BYN_TRACE("getInt32: " << ret << "/0x" << std::hex << ret << std::dec
<< " ==>\n");
return ret;
}
| 0
|
244,274
|
GF_Box *fecr_box_new()
{
ISOM_DECL_BOX_ALLOC(FECReservoirBox, GF_ISOM_BOX_TYPE_FECR);
return (GF_Box *)tmp;
}
| 0
|
436,034
|
static int io_remove_buffers(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_provide_buf *p = &req->pbuf;
struct io_ring_ctx *ctx = req->ctx;
struct io_buffer *head;
int ret = 0;
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
io_ring_submit_lock(ctx, !force_nonblock);
lockdep_assert_held(&ctx->uring_lock);
ret = -ENOENT;
head = xa_load(&ctx->io_buffers, p->bgid);
if (head)
ret = __io_remove_buffers(ctx, head, p->bgid, p->nbufs);
if (ret < 0)
req_set_fail(req);
/* complete before unlock, IOPOLL may need the lock */
__io_req_complete(req, issue_flags, ret, 0);
io_ring_submit_unlock(ctx, !force_nonblock);
return 0;
}
| 0
|
462,245
|
PJ_DEF(pj_status_t) pj_stun_msg_init( pj_stun_msg *msg,
unsigned msg_type,
pj_uint32_t magic,
const pj_uint8_t tsx_id[12])
{
PJ_ASSERT_RETURN(msg && msg_type, PJ_EINVAL);
msg->hdr.type = (pj_uint16_t) msg_type;
msg->hdr.length = 0;
msg->hdr.magic = magic;
msg->attr_count = 0;
if (tsx_id) {
pj_memcpy(&msg->hdr.tsx_id, tsx_id, sizeof(msg->hdr.tsx_id));
} else {
struct transaction_id
{
pj_uint32_t proc_id;
pj_uint32_t random;
pj_uint32_t counter;
} id;
static pj_uint32_t pj_stun_tsx_id_counter;
if (!pj_stun_tsx_id_counter)
pj_stun_tsx_id_counter = pj_rand();
id.proc_id = pj_getpid();
id.random = pj_rand();
id.counter = pj_stun_tsx_id_counter++;
pj_memcpy(&msg->hdr.tsx_id, &id, sizeof(msg->hdr.tsx_id));
}
return PJ_SUCCESS;
}
| 0
|
316,963
|
static int selinux_inode_getxattr(struct dentry *dentry, const char *name)
{
const struct cred *cred = current_cred();
return dentry_has_perm(cred, dentry, FILE__GETATTR);
}
| 0
|
415,199
|
cmd_writecert (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
char *certid;
unsigned char *certdata;
size_t certdatalen;
if ( IS_LOCKED (ctrl) )
return gpg_error (GPG_ERR_LOCKED);
line = skip_options (line);
if (!*line)
return set_error (GPG_ERR_ASS_PARAMETER, "no certid given");
certid = line;
while (*line && !spacep (line))
line++;
*line = 0;
if ((rc = open_card (ctrl, NULL)))
return rc;
if (!ctrl->app_ctx)
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
certid = xtrystrdup (certid);
if (!certid)
return out_of_core ();
/* Now get the actual keydata. */
rc = assuan_inquire (ctx, "CERTDATA",
&certdata, &certdatalen, MAXLEN_CERTDATA);
if (rc)
{
xfree (certid);
return rc;
}
/* Write the certificate to the card. */
rc = app_writecert (ctrl->app_ctx, ctrl, certid,
pin_cb, ctx, certdata, certdatalen);
xfree (certid);
xfree (certdata);
TEST_CARD_REMOVAL (ctrl, rc);
return rc;
}
| 0
|
502,717
|
int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509,
EVP_PKEY **pkey) {
return ctx->client_cert_cb;
}
| 0
|
312,417
|
qf_get_next_str_line(qfstate_T *state)
{
// Get the next line from the supplied string
char_u *p_str = state->p_str;
char_u *p;
int len;
if (*p_str == NUL) // Reached the end of the string
return QF_END_OF_INPUT;
p = vim_strchr(p_str, '\n');
if (p != NULL)
len = (int)(p - p_str) + 1;
else
len = (int)STRLEN(p_str);
if (len > IOSIZE - 2)
{
state->linebuf = qf_grow_linebuf(state, len);
if (state->linebuf == NULL)
return QF_NOMEM;
}
else
{
state->linebuf = IObuff;
state->linelen = len;
}
vim_strncpy(state->linebuf, p_str, state->linelen);
// Increment using len in order to discard the rest of the
// line if it exceeds LINE_MAXLEN.
p_str += len;
state->p_str = p_str;
return QF_OK;
}
| 0
|
253,530
|
smb2_adjust_credits(struct TCP_Server_Info *server,
struct cifs_credits *credits,
const unsigned int payload_size)
{
int new_val = DIV_ROUND_UP(payload_size, SMB2_MAX_BUFFER_SIZE);
int scredits, in_flight;
if (!credits->value || credits->value == new_val)
return 0;
if (credits->value < new_val) {
trace_smb3_too_many_credits(server->CurrentMid,
server->conn_id, server->hostname, 0, credits->value - new_val, 0);
cifs_server_dbg(VFS, "request has less credits (%d) than required (%d)",
credits->value, new_val);
return -ENOTSUPP;
}
spin_lock(&server->req_lock);
if (server->reconnect_instance != credits->instance) {
scredits = server->credits;
in_flight = server->in_flight;
spin_unlock(&server->req_lock);
trace_smb3_reconnect_detected(server->CurrentMid,
server->conn_id, server->hostname, scredits,
credits->value - new_val, in_flight);
cifs_server_dbg(VFS, "trying to return %d credits to old session\n",
credits->value - new_val);
return -EAGAIN;
}
server->credits += credits->value - new_val;
scredits = server->credits;
in_flight = server->in_flight;
spin_unlock(&server->req_lock);
wake_up(&server->request_q);
trace_smb3_add_credits(server->CurrentMid,
server->conn_id, server->hostname, scredits,
credits->value - new_val, in_flight);
cifs_dbg(FYI, "%s: adjust added %u credits total=%d\n",
__func__, credits->value - new_val, scredits);
credits->value = new_val;
return 0;
}
| 0
|
226,277
|
#ifdef GF_ENABLE_CTRN
static void ctrn_write_sample_flags(GF_BitStream *bs, u32 flags, u32 field_size)
{
if (!field_size) return;
if (field_size==8) flags = flags>>24;
else if (field_size==16) flags = flags>>16;
gf_bs_write_int(bs, flags, field_size);
| 0
|
353,138
|
void SplashOutputDev::fill(GfxState *state) {
if (state->getFillColorSpace()->isNonMarking()) {
return;
}
setOverprintMask(state->getFillColorSpace(), state->getFillOverprint(),
state->getOverprintMode(), state->getFillColor());
SplashPath path = convertPath(state, state->getPath(), true);
splash->fill(&path, false);
}
| 0
|
512,691
|
bool cmp_item_row::alloc_comparators(THD *thd, uint cols)
{
if (comparators)
{
DBUG_ASSERT(cols == n);
return false;
}
return
!(comparators= (cmp_item **) thd->calloc(sizeof(cmp_item *) * (n= cols)));
}
| 0
|
230,969
|
mrb_env_unshare(mrb_state *mrb, struct REnv *e)
{
if (e == NULL) return;
else {
size_t len = (size_t)MRB_ENV_LEN(e);
mrb_value *p;
if (!MRB_ENV_ONSTACK_P(e)) return;
if (e->cxt != mrb->c) return;
if (e == mrb_vm_ci_env(mrb->c->cibase)) return; /* for mirb */
p = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*len);
if (len > 0) {
stack_copy(p, e->stack, len);
}
e->stack = p;
MRB_ENV_CLOSE(e);
mrb_write_barrier(mrb, (struct RBasic *)e);
}
}
| 0
|
261,989
|
static void conncache_remove_bundle(struct conncache *connc,
struct connectbundle *bundle)
{
struct Curl_hash_iterator iter;
struct Curl_hash_element *he;
if(!connc)
return;
Curl_hash_start_iterate(&connc->hash, &iter);
he = Curl_hash_next_element(&iter);
while(he) {
if(he->ptr == bundle) {
/* The bundle is destroyed by the hash destructor function,
free_bundle_hash_entry() */
Curl_hash_delete(&connc->hash, he->key, he->key_len);
return;
}
he = Curl_hash_next_element(&iter);
}
}
| 0
|
236,183
|
GF_Err hclr_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_TextHighlightColorBox*ptr = (GF_TextHighlightColorBox*)s;
ISOM_DECREASE_SIZE(ptr, 4)
ptr->hil_color = gpp_read_rgba(bs);
return GF_OK;
}
| 0
|
224,985
|
parse_int_param(const char *value, int *result, PGconn *conn,
const char *context)
{
char *end;
long numval;
Assert(value != NULL);
*result = 0;
/* strtol(3) skips leading whitespaces */
errno = 0;
numval = strtol(value, &end, 10);
/*
* If no progress was done during the parsing or an error happened, fail.
* This tests properly for overflows of the result.
*/
if (value == end || errno != 0 || numval != (int) numval)
goto error;
/*
* Skip any trailing whitespace; if anything but whitespace remains before
* the terminating character, fail
*/
while (*end != '\0' && isspace((unsigned char) *end))
end++;
if (*end != '\0')
goto error;
*result = numval;
return true;
error:
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("invalid integer value \"%s\" for connection option \"%s\"\n"),
value, context);
return false;
}
| 0
|
272,337
|
generate_common_name(cms_context *cms, SECItem *der, char *cn_str)
{
CommonName cn;
SECItem cn_item;
int rc;
rc = generate_object_id(cms, &cn.oid, SEC_OID_AVA_COMMON_NAME);
if (rc < 0)
return rc;
rc = generate_string(cms, &cn.string, cn_str);
if (rc < 0)
return rc;
void *ret;
ret = SEC_ASN1EncodeItem(cms->arena, &cn_item, &cn, CommonNameTemplate);
if (ret == NULL)
cnreterr(-1, cms, "could not encode common name");
SECItem cn_set;
SECItem *items[2] = {&cn_item, NULL};
rc = wrap_in_set(cms, &cn_set, items);
if (rc < 0)
return rc;
rc = wrap_in_seq(cms, der, &cn_set, 1);
if (rc < 0)
return rc;
return 0;
}
| 0
|
234,181
|
display_gdb_index (struct dwarf_section *section,
void *file ATTRIBUTE_UNUSED)
{
unsigned char *start = section->start;
uint32_t version;
uint32_t cu_list_offset, tu_list_offset;
uint32_t address_table_offset, symbol_table_offset, constant_pool_offset;
unsigned int cu_list_elements, tu_list_elements;
unsigned int address_table_elements, symbol_table_slots;
unsigned char *cu_list, *tu_list;
unsigned char *address_table, *symbol_table, *constant_pool;
unsigned int i;
/* The documentation for the format of this file is in gdb/dwarf2read.c. */
introduce (section, false);
if (section->size < 6 * sizeof (uint32_t))
{
warn (_("Truncated header in the %s section.\n"), section->name);
return 0;
}
version = byte_get_little_endian (start, 4);
printf (_("Version %ld\n"), (long) version);
/* Prior versions are obsolete, and future versions may not be
backwards compatible. */
if (version < 3 || version > 8)
{
warn (_("Unsupported version %lu.\n"), (unsigned long) version);
return 0;
}
if (version < 4)
warn (_("The address table data in version 3 may be wrong.\n"));
if (version < 5)
warn (_("Version 4 does not support case insensitive lookups.\n"));
if (version < 6)
warn (_("Version 5 does not include inlined functions.\n"));
if (version < 7)
warn (_("Version 6 does not include symbol attributes.\n"));
/* Version 7 indices generated by Gold have bad type unit references,
PR binutils/15021. But we don't know if the index was generated by
Gold or not, so to avoid worrying users with gdb-generated indices
we say nothing for version 7 here. */
cu_list_offset = byte_get_little_endian (start + 4, 4);
tu_list_offset = byte_get_little_endian (start + 8, 4);
address_table_offset = byte_get_little_endian (start + 12, 4);
symbol_table_offset = byte_get_little_endian (start + 16, 4);
constant_pool_offset = byte_get_little_endian (start + 20, 4);
if (cu_list_offset > section->size
|| tu_list_offset > section->size
|| address_table_offset > section->size
|| symbol_table_offset > section->size
|| constant_pool_offset > section->size
|| tu_list_offset < cu_list_offset
|| address_table_offset < tu_list_offset
|| symbol_table_offset < address_table_offset
|| constant_pool_offset < symbol_table_offset)
{
warn (_("Corrupt header in the %s section.\n"), section->name);
return 0;
}
cu_list_elements = (tu_list_offset - cu_list_offset) / 16;
tu_list_elements = (address_table_offset - tu_list_offset) / 24;
address_table_elements = (symbol_table_offset - address_table_offset) / 20;
symbol_table_slots = (constant_pool_offset - symbol_table_offset) / 8;
cu_list = start + cu_list_offset;
tu_list = start + tu_list_offset;
address_table = start + address_table_offset;
symbol_table = start + symbol_table_offset;
constant_pool = start + constant_pool_offset;
printf (_("\nCU table:\n"));
for (i = 0; i < cu_list_elements; i++)
{
uint64_t cu_offset = byte_get_little_endian (cu_list + i * 16, 8);
uint64_t cu_length = byte_get_little_endian (cu_list + i * 16 + 8, 8);
printf (_("[%3u] 0x%lx - 0x%lx\n"), i,
(unsigned long) cu_offset,
(unsigned long) (cu_offset + cu_length - 1));
}
printf (_("\nTU table:\n"));
for (i = 0; i < tu_list_elements; i++)
{
uint64_t tu_offset = byte_get_little_endian (tu_list + i * 24, 8);
uint64_t type_offset = byte_get_little_endian (tu_list + i * 24 + 8, 8);
uint64_t signature = byte_get_little_endian (tu_list + i * 24 + 16, 8);
printf (_("[%3u] 0x%lx 0x%lx "), i,
(unsigned long) tu_offset,
(unsigned long) type_offset);
print_dwarf_vma (signature, 8);
printf ("\n");
}
printf (_("\nAddress table:\n"));
for (i = 0; i < address_table_elements; i++)
{
uint64_t low = byte_get_little_endian (address_table + i * 20, 8);
uint64_t high = byte_get_little_endian (address_table + i * 20 + 8, 8);
uint32_t cu_index = byte_get_little_endian (address_table + i + 20 + 16, 4);
print_dwarf_vma (low, 8);
print_dwarf_vma (high, 8);
printf (_("%lu\n"), (unsigned long) cu_index);
}
printf (_("\nSymbol table:\n"));
for (i = 0; i < symbol_table_slots; ++i)
{
uint32_t name_offset = byte_get_little_endian (symbol_table + i * 8, 4);
uint32_t cu_vector_offset = byte_get_little_endian (symbol_table + i * 8 + 4, 4);
uint32_t num_cus, cu;
if (name_offset != 0
|| cu_vector_offset != 0)
{
unsigned int j;
/* PR 17531: file: 5b7b07ad. */
if (name_offset >= section->size - constant_pool_offset)
{
printf (_("[%3u] <corrupt offset: %x>"), i, name_offset);
warn (_("Corrupt name offset of 0x%x found for symbol table slot %d\n"),
name_offset, i);
}
else
printf ("[%3u] %.*s:", i,
(int) (section->size - (constant_pool_offset + name_offset)),
constant_pool + name_offset);
if (section->size - constant_pool_offset < 4
|| cu_vector_offset > section->size - constant_pool_offset - 4)
{
printf (_("<invalid CU vector offset: %x>\n"), cu_vector_offset);
warn (_("Corrupt CU vector offset of 0x%x found for symbol table slot %d\n"),
cu_vector_offset, i);
continue;
}
num_cus = byte_get_little_endian (constant_pool + cu_vector_offset, 4);
if ((uint64_t) num_cus * 4 > section->size - (constant_pool_offset
+ cu_vector_offset + 4))
{
printf ("<invalid number of CUs: %d>\n", num_cus);
warn (_("Invalid number of CUs (0x%x) for symbol table slot %d\n"),
num_cus, i);
continue;
}
if (num_cus > 1)
printf ("\n");
for (j = 0; j < num_cus; ++j)
{
int is_static;
gdb_index_symbol_kind kind;
cu = byte_get_little_endian (constant_pool + cu_vector_offset + 4 + j * 4, 4);
is_static = GDB_INDEX_SYMBOL_STATIC_VALUE (cu);
kind = GDB_INDEX_SYMBOL_KIND_VALUE (cu);
cu = GDB_INDEX_CU_VALUE (cu);
/* Convert to TU number if it's for a type unit. */
if (cu >= cu_list_elements / 2)
printf ("%cT%lu", num_cus > 1 ? '\t' : ' ',
(unsigned long) (cu - cu_list_elements / 2));
else
printf ("%c%lu", num_cus > 1 ? '\t' : ' ', (unsigned long) cu);
printf (" [%s, %s]",
is_static ? _("static") : _("global"),
get_gdb_index_symbol_kind_name (kind));
if (num_cus > 1)
printf ("\n");
}
if (num_cus <= 1)
printf ("\n");
}
}
return 1;
}
| 0
|
448,583
|
next_int (FILE *fstream)
{
int ch;
int value = 0;
int gotone = 0;
int done = 0;
/* loop, accumulate hex value until find delimiter
skip any initial delimiters found in read stream */
while (!done) {
ch = getc (fstream);
if (ch == EOF) {
value = -1;
done++;
} else {
/* trim high bits, check type and accumulate */
ch &= 0xff;
if (g_ascii_isxdigit (ch)) {
value = (value << 4) + g_ascii_xdigit_value (ch);
gotone++;
} else if ((hex_table[ch]) < 0 && gotone) {
done++;
}
}
}
return value;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.