id
int32
0
27.3k
func
stringlengths
26
142k
target
bool
2 classes
project
stringclasses
2 values
commit_id
stringlengths
40
40
func_clean
stringlengths
26
131k
vul_lines
dict
normalized_func
stringlengths
24
132k
lines
listlengths
1
2.8k
label
listlengths
1
2.8k
line_no
listlengths
1
2.8k
16,692
static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path, const struct timespec *buf) { int ret; #ifdef CONFIG_UTIMENSAT int fd; struct handle_data *data = (struct handle_data *)ctx->private; fd = open_by_handle(data->mountfd, fs_path->data, O_NONBLOCK); if (fd < 0) { return fd; } ret = futimens(fd, buf); close(fd); #else ret = -1; errno = ENOSYS; #endif return ret; }
true
qemu
24df3371d97a7516605aef8abbc253a8c162b211
static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path, const struct timespec *buf) { int ret; #ifdef CONFIG_UTIMENSAT int fd; struct handle_data *data = (struct handle_data *)ctx->private; fd = open_by_handle(data->mountfd, fs_path->data, O_NONBLOCK); if (fd < 0) { return fd; } ret = futimens(fd, buf); close(fd); #else ret = -1; errno = ENOSYS; #endif return ret; }
{ "code": [ "#ifdef CONFIG_UTIMENSAT", "#else", " ret = -1;", " errno = ENOSYS;", "#endif" ], "line_no": [ 9, 29, 31, 33, 35 ] }
static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1, const struct timespec *VAR_2) { int VAR_3; #ifdef CONFIG_UTIMENSAT int fd; struct handle_data *data = (struct handle_data *)VAR_0->private; fd = open_by_handle(data->mountfd, VAR_1->data, O_NONBLOCK); if (fd < 0) { return fd; } VAR_3 = futimens(fd, VAR_2); close(fd); #else VAR_3 = -1; errno = ENOSYS; #endif return VAR_3; }
[ "static int FUNC_0(FsContext *VAR_0, V9fsPath *VAR_1,\nconst struct timespec *VAR_2)\n{", "int VAR_3;", "#ifdef CONFIG_UTIMENSAT\nint fd;", "struct handle_data *data = (struct handle_data *)VAR_0->private;", "fd = open_by_handle(data->mountfd, VAR_1->data, O_NONBLOCK);", "if (fd < 0) {", "return fd;", "}", "VAR_3 = futimens(fd, VAR_2);", "close(fd);", "#else\nVAR_3 = -1;", "errno = ENOSYS;", "#endif\nreturn VAR_3;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35, 37 ], [ 39 ] ]
16,694
void object_property_add_str(Object *obj, const char *name, char *(*get)(Object *, Error **), void (*set)(Object *, const char *, Error **), Error **errp) { StringProperty *prop = g_malloc0(sizeof(*prop)); prop->get = get; prop->set = set; object_property_add(obj, name, "string", get ? property_get_str : NULL, set ? property_set_str : NULL, property_release_str, prop, errp); }
true
qemu
a01aedc8d32e6f5b08a4041b62be3c5fab7a3382
void object_property_add_str(Object *obj, const char *name, char *(*get)(Object *, Error **), void (*set)(Object *, const char *, Error **), Error **errp) { StringProperty *prop = g_malloc0(sizeof(*prop)); prop->get = get; prop->set = set; object_property_add(obj, name, "string", get ? property_get_str : NULL, set ? property_set_str : NULL, property_release_str, prop, errp); }
{ "code": [ " prop, errp);", " prop, errp);" ], "line_no": [ 29, 29 ] }
VAR_5voidVAR_5 VAR_5object_property_add_strVAR_5(VAR_5ObjectVAR_5 *VAR_5VAR_0VAR_5, VAR_5constVAR_5 VAR_5charVAR_5 *VAR_5VAR_1VAR_5, VAR_5charVAR_5 *(*VAR_5VAR_2VAR_5)(VAR_5ObjectVAR_5 *, VAR_5ErrorVAR_5 **), VAR_5voidVAR_5 (*VAR_5setVAR_5)(VAR_5ObjectVAR_5 *, VAR_5constVAR_5 VAR_5charVAR_5 *, VAR_5ErrorVAR_5 **), VAR_5ErrorVAR_5 **VAR_5errpVAR_5) { VAR_5StringPropertyVAR_5 *VAR_5propVAR_5 = VAR_5g_malloc0VAR_5(VAR_5sizeofVAR_5(*VAR_5propVAR_5)); VAR_5propVAR_5->VAR_5VAR_2VAR_5 = VAR_5VAR_2VAR_5; VAR_5propVAR_5->VAR_5setVAR_5 = VAR_5setVAR_5; VAR_5object_property_addVAR_5(VAR_5VAR_0VAR_5, VAR_5VAR_1VAR_5, "VAR_5stringVAR_5", VAR_5VAR_2VAR_5 ? VAR_5property_get_strVAR_5 : VAR_5NULLVAR_5, VAR_5setVAR_5 ? VAR_5property_set_strVAR_5 : VAR_5NULLVAR_5, VAR_5property_release_strVAR_5, VAR_5propVAR_5, VAR_5errpVAR_5); }
[ "VAR_5voidVAR_5 VAR_5object_property_add_strVAR_5(VAR_5ObjectVAR_5 *VAR_5VAR_0VAR_5, VAR_5constVAR_5 VAR_5charVAR_5 *VAR_5VAR_1VAR_5,\nVAR_5charVAR_5 *(*VAR_5VAR_2VAR_5)(VAR_5ObjectVAR_5 *, VAR_5ErrorVAR_5 **),\nVAR_5voidVAR_5 (*VAR_5setVAR_5)(VAR_5ObjectVAR_5 *, VAR_5constVAR_5 VAR_5charVAR_5 *, VAR_5ErrorVAR_5 **),\nVAR_5ErrorVAR_5 **VAR_5errpVAR_5)\n{", "VAR_5StringPropertyVAR_5 *VAR_5propVAR_5 = VAR_5g_malloc0VAR_5(VAR_5sizeofVAR_5(*VAR_5propVAR_5));", "VAR_5propVAR_5->VAR_5VAR_2VAR_5 = VAR_5VAR_2VAR_5;", "VAR_5propVAR_5->VAR_5setVAR_5 = VAR_5setVAR_5;", "VAR_5object_property_addVAR_5(VAR_5VAR_0VAR_5, VAR_5VAR_1VAR_5, \"VAR_5stringVAR_5\",\nVAR_5VAR_2VAR_5 ? VAR_5property_get_strVAR_5 : VAR_5NULLVAR_5,\nVAR_5setVAR_5 ? VAR_5property_set_strVAR_5 : VAR_5NULLVAR_5,\nVAR_5property_release_strVAR_5,\nVAR_5propVAR_5, VAR_5errpVAR_5);", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21, 23, 25, 27, 29 ], [ 31 ] ]
16,695
static int disas_cp14_write(CPUState * env, DisasContext *s, uint32_t insn) { int crn = (insn >> 16) & 0xf; int crm = insn & 0xf; int op1 = (insn >> 21) & 7; int op2 = (insn >> 5) & 7; int rt = (insn >> 12) & 0xf; TCGv tmp; if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { if (op1 == 6 && crn == 0 && crm == 0 && op2 == 0) { /* TEECR */ if (IS_USER(s)) return 1; tmp = load_reg(s, rt); gen_helper_set_teecr(cpu_env, tmp); dead_tmp(tmp); return 0; } if (op1 == 6 && crn == 1 && crm == 0 && op2 == 0) { /* TEEHBR */ if (IS_USER(s) && (env->teecr & 1)) return 1; tmp = load_reg(s, rt); store_cpu_field(tmp, teehbr); return 0; } } fprintf(stderr, "Unknown cp14 write op1:%d crn:%d crm:%d op2:%d\n", op1, crn, crm, op2); return 1; }
true
qemu
7d1b0095bff7157e856d1d0e6c4295641ced2752
static int disas_cp14_write(CPUState * env, DisasContext *s, uint32_t insn) { int crn = (insn >> 16) & 0xf; int crm = insn & 0xf; int op1 = (insn >> 21) & 7; int op2 = (insn >> 5) & 7; int rt = (insn >> 12) & 0xf; TCGv tmp; if (arm_feature(env, ARM_FEATURE_THUMB2EE)) { if (op1 == 6 && crn == 0 && crm == 0 && op2 == 0) { if (IS_USER(s)) return 1; tmp = load_reg(s, rt); gen_helper_set_teecr(cpu_env, tmp); dead_tmp(tmp); return 0; } if (op1 == 6 && crn == 1 && crm == 0 && op2 == 0) { if (IS_USER(s) && (env->teecr & 1)) return 1; tmp = load_reg(s, rt); store_cpu_field(tmp, teehbr); return 0; } } fprintf(stderr, "Unknown cp14 write op1:%d crn:%d crm:%d op2:%d\n", op1, crn, crm, op2); return 1; }
{ "code": [ " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);", " dead_tmp(tmp);" ], "line_no": [ 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33 ] }
static int FUNC_0(CPUState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2) { int VAR_3 = (VAR_2 >> 16) & 0xf; int VAR_4 = VAR_2 & 0xf; int VAR_5 = (VAR_2 >> 21) & 7; int VAR_6 = (VAR_2 >> 5) & 7; int VAR_7 = (VAR_2 >> 12) & 0xf; TCGv tmp; if (arm_feature(VAR_0, ARM_FEATURE_THUMB2EE)) { if (VAR_5 == 6 && VAR_3 == 0 && VAR_4 == 0 && VAR_6 == 0) { if (IS_USER(VAR_1)) return 1; tmp = load_reg(VAR_1, VAR_7); gen_helper_set_teecr(cpu_env, tmp); dead_tmp(tmp); return 0; } if (VAR_5 == 6 && VAR_3 == 1 && VAR_4 == 0 && VAR_6 == 0) { if (IS_USER(VAR_1) && (VAR_0->teecr & 1)) return 1; tmp = load_reg(VAR_1, VAR_7); store_cpu_field(tmp, teehbr); return 0; } } fprintf(stderr, "Unknown cp14 write VAR_5:%d VAR_3:%d VAR_4:%d VAR_6:%d\n", VAR_5, VAR_3, VAR_4, VAR_6); return 1; }
[ "static int FUNC_0(CPUState * VAR_0, DisasContext *VAR_1, uint32_t VAR_2)\n{", "int VAR_3 = (VAR_2 >> 16) & 0xf;", "int VAR_4 = VAR_2 & 0xf;", "int VAR_5 = (VAR_2 >> 21) & 7;", "int VAR_6 = (VAR_2 >> 5) & 7;", "int VAR_7 = (VAR_2 >> 12) & 0xf;", "TCGv tmp;", "if (arm_feature(VAR_0, ARM_FEATURE_THUMB2EE)) {", "if (VAR_5 == 6 && VAR_3 == 0 && VAR_4 == 0 && VAR_6 == 0) {", "if (IS_USER(VAR_1))\nreturn 1;", "tmp = load_reg(VAR_1, VAR_7);", "gen_helper_set_teecr(cpu_env, tmp);", "dead_tmp(tmp);", "return 0;", "}", "if (VAR_5 == 6 && VAR_3 == 1 && VAR_4 == 0 && VAR_6 == 0) {", "if (IS_USER(VAR_1) && (VAR_0->teecr & 1))\nreturn 1;", "tmp = load_reg(VAR_1, VAR_7);", "store_cpu_field(tmp, teehbr);", "return 0;", "}", "}", "fprintf(stderr, \"Unknown cp14 write VAR_5:%d VAR_3:%d VAR_4:%d VAR_6:%d\\n\",\nVAR_5, VAR_3, VAR_4, VAR_6);", "return 1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ] ]
16,696
static void tcp_wait_for_connect(int fd, Error *err, void *opaque) { MigrationState *s = opaque; if (fd < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(err)); s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); s->to_dst_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } }
true
qemu
d59ce6f34434bf47a9b26138c908650bf9a24be1
static void tcp_wait_for_connect(int fd, Error *err, void *opaque) { MigrationState *s = opaque; if (fd < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(err)); s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); s->to_dst_file = qemu_fopen_socket(fd, "wb"); migrate_fd_connect(s); } }
{ "code": [ " migrate_fd_error(s);", " migrate_fd_error(s);", " migrate_fd_error(s);" ], "line_no": [ 15, 15, 15 ] }
static void FUNC_0(int VAR_0, Error *VAR_1, void *VAR_2) { MigrationState *s = VAR_2; if (VAR_0 < 0) { DPRINTF("migrate connect error: %s\n", error_get_pretty(VAR_1)); s->to_dst_file = NULL; migrate_fd_error(s); } else { DPRINTF("migrate connect success\n"); s->to_dst_file = qemu_fopen_socket(VAR_0, "wb"); migrate_fd_connect(s); } }
[ "static void FUNC_0(int VAR_0, Error *VAR_1, void *VAR_2)\n{", "MigrationState *s = VAR_2;", "if (VAR_0 < 0) {", "DPRINTF(\"migrate connect error: %s\\n\", error_get_pretty(VAR_1));", "s->to_dst_file = NULL;", "migrate_fd_error(s);", "} else {", "DPRINTF(\"migrate connect success\\n\");", "s->to_dst_file = qemu_fopen_socket(VAR_0, \"wb\");", "migrate_fd_connect(s);", "}", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
16,697
static FlatView generate_memory_topology(MemoryRegion *mr) { FlatView view; flatview_init(&view); render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX)); flatview_simplify(&view); return view; }
true
qemu
8417cebfda193c7f9ca70be5e308eaa92cf84b94
static FlatView generate_memory_topology(MemoryRegion *mr) { FlatView view; flatview_init(&view); render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX)); flatview_simplify(&view); return view; }
{ "code": [ " render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX));" ], "line_no": [ 13 ] }
static FlatView FUNC_0(MemoryRegion *mr) { FlatView view; flatview_init(&view); render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX)); flatview_simplify(&view); return view; }
[ "static FlatView FUNC_0(MemoryRegion *mr)\n{", "FlatView view;", "flatview_init(&view);", "render_memory_region(&view, mr, 0, addrrange_make(0, UINT64_MAX));", "flatview_simplify(&view);", "return view;", "}" ]
[ 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ] ]
16,699
static void visit_type_int32(Visitor *v, int *value, const char *name, Error **errp) { int64_t val = *value; visit_type_int(v, &val, name, errp); }
true
qemu
4e27e819bea0ea6c8108dc7e9fa48afd6ec13c46
static void visit_type_int32(Visitor *v, int *value, const char *name, Error **errp) { int64_t val = *value; visit_type_int(v, &val, name, errp); }
{ "code": [ "static void visit_type_int32(Visitor *v, int *value, const char *name, Error **errp)", " int64_t val = *value;", " visit_type_int(v, &val, name, errp);" ], "line_no": [ 1, 5, 7 ] }
static void FUNC_0(Visitor *VAR_0, int *VAR_1, const char *VAR_2, Error **VAR_3) { int64_t val = *VAR_1; visit_type_int(VAR_0, &val, VAR_2, VAR_3); }
[ "static void FUNC_0(Visitor *VAR_0, int *VAR_1, const char *VAR_2, Error **VAR_3)\n{", "int64_t val = *VAR_1;", "visit_type_int(VAR_0, &val, VAR_2, VAR_3);", "}" ]
[ 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
16,701
static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, int do_search_pc, const uint8_t *searched_pc) { int opc, op_index, macro_op_index; const TCGOpDef *def; unsigned int dead_iargs; const TCGArg *args; #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP)) { fprintf(logfile, "OP:\n"); tcg_dump_ops(s, logfile); fprintf(logfile, "\n"); } #endif tcg_liveness_analysis(s); #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) { fprintf(logfile, "OP after la:\n"); tcg_dump_ops(s, logfile); fprintf(logfile, "\n"); } #endif tcg_reg_alloc_start(s); s->code_buf = gen_code_buf; s->code_ptr = gen_code_buf; macro_op_index = -1; args = gen_opparam_buf; op_index = 0; for(;;) { opc = gen_opc_buf[op_index]; #ifdef CONFIG_PROFILER dyngen_table_op_count[opc]++; #endif def = &tcg_op_defs[opc]; #if 0 printf("%s: %d %d %d\n", def->name, def->nb_oargs, def->nb_iargs, def->nb_cargs); // dump_regs(s); #endif switch(opc) { case INDEX_op_mov_i32: #if TCG_TARGET_REG_BITS == 64 case INDEX_op_mov_i64: #endif dead_iargs = s->op_dead_iargs[op_index]; tcg_reg_alloc_mov(s, def, args, dead_iargs); break; case INDEX_op_nop: case INDEX_op_nop1: case INDEX_op_nop2: case INDEX_op_nop3: break; case INDEX_op_nopn: args += args[0]; goto next; case INDEX_op_discard: { TCGTemp *ts; ts = &s->temps[args[0]]; /* mark the temporary as dead */ if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) s->reg_to_temp[ts->reg] = -1; ts->val_type = TEMP_VAL_DEAD; } } break; case INDEX_op_macro_goto: macro_op_index = op_index; /* only used for exceptions */ op_index = args[0] - 1; args = gen_opparam_buf + args[1]; goto next; case INDEX_op_macro_end: macro_op_index = -1; /* only used for exceptions */ op_index = args[0] - 1; args = gen_opparam_buf + args[1]; goto next; case INDEX_op_macro_start: /* must never happen here */ tcg_abort(); case INDEX_op_set_label: tcg_reg_alloc_bb_end(s); tcg_out_label(s, args[0], (long)s->code_ptr); break; case INDEX_op_call: dead_iargs = s->op_dead_iargs[op_index]; args += tcg_reg_alloc_call(s, def, opc, args, dead_iargs); goto next; case INDEX_op_end: goto the_end; case 0 ... INDEX_op_end - 1: /* legacy dyngen ops */ #ifdef CONFIG_PROFILER { extern int64_t dyngen_old_op_count; dyngen_old_op_count++; } #endif tcg_reg_alloc_bb_end(s); if (do_search_pc) { s->code_ptr += def->copy_size; args += def->nb_args; } else { args = dyngen_op(s, opc, args); } goto next; default: /* Note: in order to speed up the code, it would be much faster to have specialized register allocator functions for some common argument patterns */ dead_iargs = s->op_dead_iargs[op_index]; tcg_reg_alloc_op(s, def, opc, args, dead_iargs); break; } args += def->nb_args; next: ; if (do_search_pc) { if (searched_pc < s->code_ptr) { if (macro_op_index >= 0) return macro_op_index; else return op_index; } } op_index++; #ifndef NDEBUG check_regs(s); #endif } the_end: return -1; }
true
qemu
2ba1eeb62c29d23238b95dc7e9ade3444b49f0a1
static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, int do_search_pc, const uint8_t *searched_pc) { int opc, op_index, macro_op_index; const TCGOpDef *def; unsigned int dead_iargs; const TCGArg *args; #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP)) { fprintf(logfile, "OP:\n"); tcg_dump_ops(s, logfile); fprintf(logfile, "\n"); } #endif tcg_liveness_analysis(s); #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) { fprintf(logfile, "OP after la:\n"); tcg_dump_ops(s, logfile); fprintf(logfile, "\n"); } #endif tcg_reg_alloc_start(s); s->code_buf = gen_code_buf; s->code_ptr = gen_code_buf; macro_op_index = -1; args = gen_opparam_buf; op_index = 0; for(;;) { opc = gen_opc_buf[op_index]; #ifdef CONFIG_PROFILER dyngen_table_op_count[opc]++; #endif def = &tcg_op_defs[opc]; #if 0 printf("%s: %d %d %d\n", def->name, def->nb_oargs, def->nb_iargs, def->nb_cargs); #endif switch(opc) { case INDEX_op_mov_i32: #if TCG_TARGET_REG_BITS == 64 case INDEX_op_mov_i64: #endif dead_iargs = s->op_dead_iargs[op_index]; tcg_reg_alloc_mov(s, def, args, dead_iargs); break; case INDEX_op_nop: case INDEX_op_nop1: case INDEX_op_nop2: case INDEX_op_nop3: break; case INDEX_op_nopn: args += args[0]; goto next; case INDEX_op_discard: { TCGTemp *ts; ts = &s->temps[args[0]]; if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) s->reg_to_temp[ts->reg] = -1; ts->val_type = TEMP_VAL_DEAD; } } break; case INDEX_op_macro_goto: macro_op_index = op_index; op_index = args[0] - 1; args = gen_opparam_buf + args[1]; goto next; case INDEX_op_macro_end: macro_op_index = -1; op_index = args[0] - 1; args = gen_opparam_buf + args[1]; goto next; case INDEX_op_macro_start: tcg_abort(); case INDEX_op_set_label: tcg_reg_alloc_bb_end(s); tcg_out_label(s, args[0], (long)s->code_ptr); break; case INDEX_op_call: dead_iargs = s->op_dead_iargs[op_index]; args += tcg_reg_alloc_call(s, def, opc, args, dead_iargs); goto next; case INDEX_op_end: goto the_end; case 0 ... INDEX_op_end - 1: #ifdef CONFIG_PROFILER { extern int64_t dyngen_old_op_count; dyngen_old_op_count++; } #endif tcg_reg_alloc_bb_end(s); if (do_search_pc) { s->code_ptr += def->copy_size; args += def->nb_args; } else { args = dyngen_op(s, opc, args); } goto next; default: dead_iargs = s->op_dead_iargs[op_index]; tcg_reg_alloc_op(s, def, opc, args, dead_iargs); break; } args += def->nb_args; next: ; if (do_search_pc) { if (searched_pc < s->code_ptr) { if (macro_op_index >= 0) return macro_op_index; else return op_index; } } op_index++; #ifndef NDEBUG check_regs(s); #endif } the_end: return -1; }
{ "code": [ " int do_search_pc,", " const uint8_t *searched_pc)", " if (do_search_pc) {", " if (do_search_pc) {", " if (searched_pc < s->code_ptr) {", " if (macro_op_index >= 0)", " return macro_op_index;", " return op_index;" ], "line_no": [ 3, 5, 213, 247, 249, 251, 253, 257 ] }
static inline int FUNC_0(TCGContext *VAR_0, uint8_t *VAR_1, int VAR_2, const uint8_t *VAR_3) { int VAR_4, VAR_5, VAR_6; const TCGOpDef *VAR_7; unsigned int VAR_8; const TCGArg *VAR_9; #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP)) { fprintf(logfile, "OP:\n"); tcg_dump_ops(VAR_0, logfile); fprintf(logfile, "\n"); } #endif tcg_liveness_analysis(VAR_0); #ifdef DEBUG_DISAS if (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) { fprintf(logfile, "OP after la:\n"); tcg_dump_ops(VAR_0, logfile); fprintf(logfile, "\n"); } #endif tcg_reg_alloc_start(VAR_0); VAR_0->code_buf = VAR_1; VAR_0->code_ptr = VAR_1; VAR_6 = -1; VAR_9 = gen_opparam_buf; VAR_5 = 0; for(;;) { VAR_4 = gen_opc_buf[VAR_5]; #ifdef CONFIG_PROFILER dyngen_table_op_count[VAR_4]++; #endif VAR_7 = &tcg_op_defs[VAR_4]; #if 0 printf("%VAR_0: %d %d %d\n", VAR_7->name, VAR_7->nb_oargs, VAR_7->nb_iargs, VAR_7->nb_cargs); #endif switch(VAR_4) { case INDEX_op_mov_i32: #if TCG_TARGET_REG_BITS == 64 case INDEX_op_mov_i64: #endif VAR_8 = VAR_0->op_dead_iargs[VAR_5]; tcg_reg_alloc_mov(VAR_0, VAR_7, VAR_9, VAR_8); break; case INDEX_op_nop: case INDEX_op_nop1: case INDEX_op_nop2: case INDEX_op_nop3: break; case INDEX_op_nopn: VAR_9 += VAR_9[0]; goto next; case INDEX_op_discard: { TCGTemp *ts; ts = &VAR_0->temps[VAR_9[0]]; if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) { if (ts->val_type == TEMP_VAL_REG) VAR_0->reg_to_temp[ts->reg] = -1; ts->val_type = TEMP_VAL_DEAD; } } break; case INDEX_op_macro_goto: VAR_6 = VAR_5; VAR_5 = VAR_9[0] - 1; VAR_9 = gen_opparam_buf + VAR_9[1]; goto next; case INDEX_op_macro_end: VAR_6 = -1; VAR_5 = VAR_9[0] - 1; VAR_9 = gen_opparam_buf + VAR_9[1]; goto next; case INDEX_op_macro_start: tcg_abort(); case INDEX_op_set_label: tcg_reg_alloc_bb_end(VAR_0); tcg_out_label(VAR_0, VAR_9[0], (long)VAR_0->code_ptr); break; case INDEX_op_call: VAR_8 = VAR_0->op_dead_iargs[VAR_5]; VAR_9 += tcg_reg_alloc_call(VAR_0, VAR_7, VAR_4, VAR_9, VAR_8); goto next; case INDEX_op_end: goto the_end; case 0 ... INDEX_op_end - 1: #ifdef CONFIG_PROFILER { extern int64_t dyngen_old_op_count; dyngen_old_op_count++; } #endif tcg_reg_alloc_bb_end(VAR_0); if (VAR_2) { VAR_0->code_ptr += VAR_7->copy_size; VAR_9 += VAR_7->nb_args; } else { VAR_9 = dyngen_op(VAR_0, VAR_4, VAR_9); } goto next; default: VAR_8 = VAR_0->op_dead_iargs[VAR_5]; tcg_reg_alloc_op(VAR_0, VAR_7, VAR_4, VAR_9, VAR_8); break; } VAR_9 += VAR_7->nb_args; next: ; if (VAR_2) { if (VAR_3 < VAR_0->code_ptr) { if (VAR_6 >= 0) return VAR_6; else return VAR_5; } } VAR_5++; #ifndef NDEBUG check_regs(VAR_0); #endif } the_end: return -1; }
[ "static inline int FUNC_0(TCGContext *VAR_0, uint8_t *VAR_1,\nint VAR_2,\nconst uint8_t *VAR_3)\n{", "int VAR_4, VAR_5, VAR_6;", "const TCGOpDef *VAR_7;", "unsigned int VAR_8;", "const TCGArg *VAR_9;", "#ifdef DEBUG_DISAS\nif (unlikely(loglevel & CPU_LOG_TB_OP)) {", "fprintf(logfile, \"OP:\\n\");", "tcg_dump_ops(VAR_0, logfile);", "fprintf(logfile, \"\\n\");", "}", "#endif\ntcg_liveness_analysis(VAR_0);", "#ifdef DEBUG_DISAS\nif (unlikely(loglevel & CPU_LOG_TB_OP_OPT)) {", "fprintf(logfile, \"OP after la:\\n\");", "tcg_dump_ops(VAR_0, logfile);", "fprintf(logfile, \"\\n\");", "}", "#endif\ntcg_reg_alloc_start(VAR_0);", "VAR_0->code_buf = VAR_1;", "VAR_0->code_ptr = VAR_1;", "VAR_6 = -1;", "VAR_9 = gen_opparam_buf;", "VAR_5 = 0;", "for(;;) {", "VAR_4 = gen_opc_buf[VAR_5];", "#ifdef CONFIG_PROFILER\ndyngen_table_op_count[VAR_4]++;", "#endif\nVAR_7 = &tcg_op_defs[VAR_4];", "#if 0\nprintf(\"%VAR_0: %d %d %d\\n\", VAR_7->name,\nVAR_7->nb_oargs, VAR_7->nb_iargs, VAR_7->nb_cargs);", "#endif\nswitch(VAR_4) {", "case INDEX_op_mov_i32:\n#if TCG_TARGET_REG_BITS == 64\ncase INDEX_op_mov_i64:\n#endif\nVAR_8 = VAR_0->op_dead_iargs[VAR_5];", "tcg_reg_alloc_mov(VAR_0, VAR_7, VAR_9, VAR_8);", "break;", "case INDEX_op_nop:\ncase INDEX_op_nop1:\ncase INDEX_op_nop2:\ncase INDEX_op_nop3:\nbreak;", "case INDEX_op_nopn:\nVAR_9 += VAR_9[0];", "goto next;", "case INDEX_op_discard:\n{", "TCGTemp *ts;", "ts = &VAR_0->temps[VAR_9[0]];", "if (ts->val_type != TEMP_VAL_CONST && !ts->fixed_reg) {", "if (ts->val_type == TEMP_VAL_REG)\nVAR_0->reg_to_temp[ts->reg] = -1;", "ts->val_type = TEMP_VAL_DEAD;", "}", "}", "break;", "case INDEX_op_macro_goto:\nVAR_6 = VAR_5;", "VAR_5 = VAR_9[0] - 1;", "VAR_9 = gen_opparam_buf + VAR_9[1];", "goto next;", "case INDEX_op_macro_end:\nVAR_6 = -1;", "VAR_5 = VAR_9[0] - 1;", "VAR_9 = gen_opparam_buf + VAR_9[1];", "goto next;", "case INDEX_op_macro_start:\ntcg_abort();", "case INDEX_op_set_label:\ntcg_reg_alloc_bb_end(VAR_0);", "tcg_out_label(VAR_0, VAR_9[0], (long)VAR_0->code_ptr);", "break;", "case INDEX_op_call:\nVAR_8 = VAR_0->op_dead_iargs[VAR_5];", "VAR_9 += tcg_reg_alloc_call(VAR_0, VAR_7, VAR_4, VAR_9, VAR_8);", "goto next;", "case INDEX_op_end:\ngoto the_end;", "case 0 ... INDEX_op_end - 1:\n#ifdef CONFIG_PROFILER\n{", "extern int64_t dyngen_old_op_count;", "dyngen_old_op_count++;", "}", "#endif\ntcg_reg_alloc_bb_end(VAR_0);", "if (VAR_2) {", "VAR_0->code_ptr += VAR_7->copy_size;", "VAR_9 += VAR_7->nb_args;", "} else {", "VAR_9 = dyngen_op(VAR_0, VAR_4, VAR_9);", "}", "goto next;", "default:\nVAR_8 = VAR_0->op_dead_iargs[VAR_5];", "tcg_reg_alloc_op(VAR_0, VAR_7, VAR_4, VAR_9, VAR_8);", "break;", "}", "VAR_9 += VAR_7->nb_args;", "next: ;", "if (VAR_2) {", "if (VAR_3 < VAR_0->code_ptr) {", "if (VAR_6 >= 0)\nreturn VAR_6;", "else\nreturn VAR_5;", "}", "}", "VAR_5++;", "#ifndef NDEBUG\ncheck_regs(VAR_0);", "#endif\n}", "the_end:\nreturn -1;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31, 35 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51, 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 83, 85, 87 ], [ 91, 93 ], [ 95, 97, 99, 101, 103 ], [ 105 ], [ 107 ], [ 109, 111, 113, 115, 117 ], [ 119, 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159, 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169, 173 ], [ 175, 177 ], [ 179 ], [ 181 ], [ 183, 185 ], [ 187 ], [ 189 ], [ 191, 193 ], [ 195, 199, 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251, 253 ], [ 255, 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265, 267 ], [ 269, 271 ], [ 273, 275 ], [ 277 ] ]
16,702
static int setup_hwaccel(AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name) { AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt); int ret = 0; if (!hwa) { "Could not find an AVHWAccel for the pixel format: %s", name); return AVERROR(ENOENT); if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n", hwa->name); return AVERROR_PATCHWELCOME; if (hwa->priv_data_size) { avctx->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size); if (!avctx->internal->hwaccel_priv_data) return AVERROR(ENOMEM); if (hwa->init) { ret = hwa->init(avctx); if (ret < 0) { av_freep(&avctx->internal->hwaccel_priv_data); return ret; avctx->hwaccel = hwa; return 0;
true
FFmpeg
31741aecbf9938194b25f14de434104be33f5809
static int setup_hwaccel(AVCodecContext *avctx, const enum AVPixelFormat fmt, const char *name) { AVHWAccel *hwa = find_hwaccel(avctx->codec_id, fmt); int ret = 0; if (!hwa) { "Could not find an AVHWAccel for the pixel format: %s", name); return AVERROR(ENOENT); if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL && avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(avctx, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n", hwa->name); return AVERROR_PATCHWELCOME; if (hwa->priv_data_size) { avctx->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size); if (!avctx->internal->hwaccel_priv_data) return AVERROR(ENOMEM); if (hwa->init) { ret = hwa->init(avctx); if (ret < 0) { av_freep(&avctx->internal->hwaccel_priv_data); return ret; avctx->hwaccel = hwa; return 0;
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, const enum AVPixelFormat VAR_1, const char *VAR_2) { AVHWAccel *hwa = find_hwaccel(VAR_0->codec_id, VAR_1); int VAR_3 = 0; if (!hwa) { "Could not find an AVHWAccel for the pixel format: %s", VAR_2); return AVERROR(ENOENT); if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL && VAR_0->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) { av_log(VAR_0, AV_LOG_WARNING, "Ignoring experimental hwaccel: %s\n", hwa->VAR_2); return AVERROR_PATCHWELCOME; if (hwa->priv_data_size) { VAR_0->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size); if (!VAR_0->internal->hwaccel_priv_data) return AVERROR(ENOMEM); if (hwa->init) { VAR_3 = hwa->init(VAR_0); if (VAR_3 < 0) { av_freep(&VAR_0->internal->hwaccel_priv_data); return VAR_3; VAR_0->hwaccel = hwa; return 0;
[ "static int FUNC_0(AVCodecContext *VAR_0,\nconst enum AVPixelFormat VAR_1,\nconst char *VAR_2)\n{", "AVHWAccel *hwa = find_hwaccel(VAR_0->codec_id, VAR_1);", "int VAR_3 = 0;", "if (!hwa) {", "\"Could not find an AVHWAccel for the pixel format: %s\",\nVAR_2);", "return AVERROR(ENOENT);", "if (hwa->capabilities & HWACCEL_CODEC_CAP_EXPERIMENTAL &&\nVAR_0->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {", "av_log(VAR_0, AV_LOG_WARNING, \"Ignoring experimental hwaccel: %s\\n\",\nhwa->VAR_2);", "return AVERROR_PATCHWELCOME;", "if (hwa->priv_data_size) {", "VAR_0->internal->hwaccel_priv_data = av_mallocz(hwa->priv_data_size);", "if (!VAR_0->internal->hwaccel_priv_data)\nreturn AVERROR(ENOMEM);", "if (hwa->init) {", "VAR_3 = hwa->init(VAR_0);", "if (VAR_3 < 0) {", "av_freep(&VAR_0->internal->hwaccel_priv_data);", "return VAR_3;", "VAR_0->hwaccel = hwa;", "return 0;" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 2, 3, 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8, 9 ], [ 10 ], [ 11, 12 ], [ 13, 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18, 19 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ] ]
16,703
static void rpza_decode_stream(RpzaContext *s) { int width = s->avctx->width; int stride = s->frame.linesize[0] / 2; int row_inc = stride - 4; int stream_ptr = 0; int chunk_size; unsigned char opcode; int n_blocks; unsigned short colorA = 0, colorB; unsigned short color4[4]; unsigned char index, idx; unsigned short ta, tb; unsigned short *pixels = (unsigned short *)s->frame.data[0]; int row_ptr = 0; int pixel_ptr = 0; int block_ptr; int pixel_x, pixel_y; int total_blocks; /* First byte is always 0xe1. Warn if it's different */ if (s->buf[stream_ptr] != 0xe1) av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n", s->buf[stream_ptr]); /* Get chunk size, ingnoring first byte */ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF; stream_ptr += 4; /* If length mismatch use size from MOV file and try to decode anyway */ if (chunk_size != s->size) av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n"); chunk_size = s->size; /* Number of 4x4 blocks in frame. */ total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4); /* Process chunk data */ while (stream_ptr < chunk_size) { opcode = s->buf[stream_ptr++]; /* Get opcode */ n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode */ /* If opcode MSbit is 0, we need more data to decide what to do */ if ((opcode & 0x80) == 0) { colorA = (opcode << 8) | (s->buf[stream_ptr++]); opcode = 0; if ((s->buf[stream_ptr] & 0x80) != 0) { /* Must behave as opcode 110xxxxx, using colorA computed * above. Use fake opcode 0x20 to enter switch block at * the right place */ opcode = 0x20; n_blocks = 1; } } switch (opcode & 0xe0) { /* Skip blocks */ case 0x80: while (n_blocks--) { ADVANCE_BLOCK(); } break; /* Fill blocks with one color */ case 0xa0: colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ pixels[block_ptr] = colorA; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* Fill blocks with 4 colors */ case 0xc0: colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; case 0x20: colorB = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; /* sort out the colors */ color4[0] = colorB; color4[1] = 0; color4[2] = 0; color4[3] = colorA; /* red components */ ta = (colorA >> 10) & 0x1F; tb = (colorB >> 10) & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10; color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10; /* green components */ ta = (colorA >> 5) & 0x1F; tb = (colorB >> 5) & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5; color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5; /* blue components */ ta = colorA & 0x1F; tb = colorB & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5); color4[2] |= ((21 * ta + 11 * tb) >> 5); while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { index = s->buf[stream_ptr++]; for (pixel_x = 0; pixel_x < 4; pixel_x++){ idx = (index >> (2 * (3 - pixel_x))) & 0x03; pixels[block_ptr] = color4[idx]; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; /* Fill block with 16 colors */ case 0x00: if (s->size - stream_ptr < 16) block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ /* We already have color of upper left pixel */ if ((pixel_y != 0) || (pixel_x !=0)) { colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; } pixels[block_ptr] = colorA; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); break; /* Unknown opcode */ default: av_log(s->avctx, AV_LOG_ERROR, "Unknown opcode %d in rpza chunk." " Skip remaining %d bytes of chunk data.\n", opcode, chunk_size - stream_ptr); } /* Opcode switch */ } }
true
FFmpeg
78e9852a2e3b198ecd69ffa0deab3fa22a8e5378
static void rpza_decode_stream(RpzaContext *s) { int width = s->avctx->width; int stride = s->frame.linesize[0] / 2; int row_inc = stride - 4; int stream_ptr = 0; int chunk_size; unsigned char opcode; int n_blocks; unsigned short colorA = 0, colorB; unsigned short color4[4]; unsigned char index, idx; unsigned short ta, tb; unsigned short *pixels = (unsigned short *)s->frame.data[0]; int row_ptr = 0; int pixel_ptr = 0; int block_ptr; int pixel_x, pixel_y; int total_blocks; if (s->buf[stream_ptr] != 0xe1) av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n", s->buf[stream_ptr]); chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF; stream_ptr += 4; if (chunk_size != s->size) av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n"); chunk_size = s->size; total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4); while (stream_ptr < chunk_size) { opcode = s->buf[stream_ptr++]; n_blocks = (opcode & 0x1f) + 1; if ((opcode & 0x80) == 0) { colorA = (opcode << 8) | (s->buf[stream_ptr++]); opcode = 0; if ((s->buf[stream_ptr] & 0x80) != 0) { opcode = 0x20; n_blocks = 1; } } switch (opcode & 0xe0) { case 0x80: while (n_blocks--) { ADVANCE_BLOCK(); } break; case 0xa0: colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ pixels[block_ptr] = colorA; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; case 0xc0: colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; case 0x20: colorB = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; color4[0] = colorB; color4[1] = 0; color4[2] = 0; color4[3] = colorA; ta = (colorA >> 10) & 0x1F; tb = (colorB >> 10) & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5) << 10; color4[2] |= ((21 * ta + 11 * tb) >> 5) << 10; ta = (colorA >> 5) & 0x1F; tb = (colorB >> 5) & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5) << 5; color4[2] |= ((21 * ta + 11 * tb) >> 5) << 5; ta = colorA & 0x1F; tb = colorB & 0x1F; color4[1] |= ((11 * ta + 21 * tb) >> 5); color4[2] |= ((21 * ta + 11 * tb) >> 5); while (n_blocks--) { block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { index = s->buf[stream_ptr++]; for (pixel_x = 0; pixel_x < 4; pixel_x++){ idx = (index >> (2 * (3 - pixel_x))) & 0x03; pixels[block_ptr] = color4[idx]; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); } break; case 0x00: if (s->size - stream_ptr < 16) block_ptr = row_ptr + pixel_ptr; for (pixel_y = 0; pixel_y < 4; pixel_y++) { for (pixel_x = 0; pixel_x < 4; pixel_x++){ if ((pixel_y != 0) || (pixel_x !=0)) { colorA = AV_RB16 (&s->buf[stream_ptr]); stream_ptr += 2; } pixels[block_ptr] = colorA; block_ptr++; } block_ptr += row_inc; } ADVANCE_BLOCK(); break; default: av_log(s->avctx, AV_LOG_ERROR, "Unknown opcode %d in rpza chunk." " Skip remaining %d bytes of chunk data.\n", opcode, chunk_size - stream_ptr); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(RpzaContext *VAR_0) { int VAR_1 = VAR_0->avctx->VAR_1; int VAR_2 = VAR_0->frame.linesize[0] / 2; int VAR_3 = VAR_2 - 4; int VAR_4 = 0; int VAR_5; unsigned char VAR_6; int VAR_7; unsigned short VAR_8 = 0, VAR_9; unsigned short VAR_10[4]; unsigned char VAR_11, VAR_12; unsigned short VAR_13, VAR_14; unsigned short *VAR_15 = (unsigned short *)VAR_0->frame.data[0]; int VAR_16 = 0; int VAR_17 = 0; int VAR_18; int VAR_19, VAR_20; int VAR_21; if (VAR_0->buf[VAR_4] != 0xe1) av_log(VAR_0->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n", VAR_0->buf[VAR_4]); VAR_5 = AV_RB32(&VAR_0->buf[VAR_4]) & 0x00FFFFFF; VAR_4 += 4; if (VAR_5 != VAR_0->size) av_log(VAR_0->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk size; using MOV chunk size\n"); VAR_5 = VAR_0->size; VAR_21 = ((VAR_0->avctx->VAR_1 + 3) / 4) * ((VAR_0->avctx->height + 3) / 4); while (VAR_4 < VAR_5) { VAR_6 = VAR_0->buf[VAR_4++]; VAR_7 = (VAR_6 & 0x1f) + 1; if ((VAR_6 & 0x80) == 0) { VAR_8 = (VAR_6 << 8) | (VAR_0->buf[VAR_4++]); VAR_6 = 0; if ((VAR_0->buf[VAR_4] & 0x80) != 0) { VAR_6 = 0x20; VAR_7 = 1; } } switch (VAR_6 & 0xe0) { case 0x80: while (VAR_7--) { ADVANCE_BLOCK(); } break; case 0xa0: VAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]); VAR_4 += 2; while (VAR_7--) { VAR_18 = VAR_16 + VAR_17; for (VAR_20 = 0; VAR_20 < 4; VAR_20++) { for (VAR_19 = 0; VAR_19 < 4; VAR_19++){ VAR_15[VAR_18] = VAR_8; VAR_18++; } VAR_18 += VAR_3; } ADVANCE_BLOCK(); } break; case 0xc0: VAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]); VAR_4 += 2; case 0x20: VAR_9 = AV_RB16 (&VAR_0->buf[VAR_4]); VAR_4 += 2; VAR_10[0] = VAR_9; VAR_10[1] = 0; VAR_10[2] = 0; VAR_10[3] = VAR_8; VAR_13 = (VAR_8 >> 10) & 0x1F; VAR_14 = (VAR_9 >> 10) & 0x1F; VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5) << 10; VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5) << 10; VAR_13 = (VAR_8 >> 5) & 0x1F; VAR_14 = (VAR_9 >> 5) & 0x1F; VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5) << 5; VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5) << 5; VAR_13 = VAR_8 & 0x1F; VAR_14 = VAR_9 & 0x1F; VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5); VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5); while (VAR_7--) { VAR_18 = VAR_16 + VAR_17; for (VAR_20 = 0; VAR_20 < 4; VAR_20++) { VAR_11 = VAR_0->buf[VAR_4++]; for (VAR_19 = 0; VAR_19 < 4; VAR_19++){ VAR_12 = (VAR_11 >> (2 * (3 - VAR_19))) & 0x03; VAR_15[VAR_18] = VAR_10[VAR_12]; VAR_18++; } VAR_18 += VAR_3; } ADVANCE_BLOCK(); } break; case 0x00: if (VAR_0->size - VAR_4 < 16) VAR_18 = VAR_16 + VAR_17; for (VAR_20 = 0; VAR_20 < 4; VAR_20++) { for (VAR_19 = 0; VAR_19 < 4; VAR_19++){ if ((VAR_20 != 0) || (VAR_19 !=0)) { VAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]); VAR_4 += 2; } VAR_15[VAR_18] = VAR_8; VAR_18++; } VAR_18 += VAR_3; } ADVANCE_BLOCK(); break; default: av_log(VAR_0->avctx, AV_LOG_ERROR, "Unknown VAR_6 %d in rpza chunk." " Skip remaining %d bytes of chunk data.\n", VAR_6, VAR_5 - VAR_4); } } }
[ "static void FUNC_0(RpzaContext *VAR_0)\n{", "int VAR_1 = VAR_0->avctx->VAR_1;", "int VAR_2 = VAR_0->frame.linesize[0] / 2;", "int VAR_3 = VAR_2 - 4;", "int VAR_4 = 0;", "int VAR_5;", "unsigned char VAR_6;", "int VAR_7;", "unsigned short VAR_8 = 0, VAR_9;", "unsigned short VAR_10[4];", "unsigned char VAR_11, VAR_12;", "unsigned short VAR_13, VAR_14;", "unsigned short *VAR_15 = (unsigned short *)VAR_0->frame.data[0];", "int VAR_16 = 0;", "int VAR_17 = 0;", "int VAR_18;", "int VAR_19, VAR_20;", "int VAR_21;", "if (VAR_0->buf[VAR_4] != 0xe1)\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"First chunk byte is 0x%02x instead of 0xe1\\n\",\nVAR_0->buf[VAR_4]);", "VAR_5 = AV_RB32(&VAR_0->buf[VAR_4]) & 0x00FFFFFF;", "VAR_4 += 4;", "if (VAR_5 != VAR_0->size)\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"MOV chunk size != encoded chunk size; using MOV chunk size\\n\");", "VAR_5 = VAR_0->size;", "VAR_21 = ((VAR_0->avctx->VAR_1 + 3) / 4) * ((VAR_0->avctx->height + 3) / 4);", "while (VAR_4 < VAR_5) {", "VAR_6 = VAR_0->buf[VAR_4++];", "VAR_7 = (VAR_6 & 0x1f) + 1;", "if ((VAR_6 & 0x80) == 0) {", "VAR_8 = (VAR_6 << 8) | (VAR_0->buf[VAR_4++]);", "VAR_6 = 0;", "if ((VAR_0->buf[VAR_4] & 0x80) != 0) {", "VAR_6 = 0x20;", "VAR_7 = 1;", "}", "}", "switch (VAR_6 & 0xe0) {", "case 0x80:\nwhile (VAR_7--) {", "ADVANCE_BLOCK();", "}", "break;", "case 0xa0:\nVAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]);", "VAR_4 += 2;", "while (VAR_7--) {", "VAR_18 = VAR_16 + VAR_17;", "for (VAR_20 = 0; VAR_20 < 4; VAR_20++) {", "for (VAR_19 = 0; VAR_19 < 4; VAR_19++){", "VAR_15[VAR_18] = VAR_8;", "VAR_18++;", "}", "VAR_18 += VAR_3;", "}", "ADVANCE_BLOCK();", "}", "break;", "case 0xc0:\nVAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]);", "VAR_4 += 2;", "case 0x20:\nVAR_9 = AV_RB16 (&VAR_0->buf[VAR_4]);", "VAR_4 += 2;", "VAR_10[0] = VAR_9;", "VAR_10[1] = 0;", "VAR_10[2] = 0;", "VAR_10[3] = VAR_8;", "VAR_13 = (VAR_8 >> 10) & 0x1F;", "VAR_14 = (VAR_9 >> 10) & 0x1F;", "VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5) << 10;", "VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5) << 10;", "VAR_13 = (VAR_8 >> 5) & 0x1F;", "VAR_14 = (VAR_9 >> 5) & 0x1F;", "VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5) << 5;", "VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5) << 5;", "VAR_13 = VAR_8 & 0x1F;", "VAR_14 = VAR_9 & 0x1F;", "VAR_10[1] |= ((11 * VAR_13 + 21 * VAR_14) >> 5);", "VAR_10[2] |= ((21 * VAR_13 + 11 * VAR_14) >> 5);", "while (VAR_7--) {", "VAR_18 = VAR_16 + VAR_17;", "for (VAR_20 = 0; VAR_20 < 4; VAR_20++) {", "VAR_11 = VAR_0->buf[VAR_4++];", "for (VAR_19 = 0; VAR_19 < 4; VAR_19++){", "VAR_12 = (VAR_11 >> (2 * (3 - VAR_19))) & 0x03;", "VAR_15[VAR_18] = VAR_10[VAR_12];", "VAR_18++;", "}", "VAR_18 += VAR_3;", "}", "ADVANCE_BLOCK();", "}", "break;", "case 0x00:\nif (VAR_0->size - VAR_4 < 16)\nVAR_18 = VAR_16 + VAR_17;", "for (VAR_20 = 0; VAR_20 < 4; VAR_20++) {", "for (VAR_19 = 0; VAR_19 < 4; VAR_19++){", "if ((VAR_20 != 0) || (VAR_19 !=0)) {", "VAR_8 = AV_RB16 (&VAR_0->buf[VAR_4]);", "VAR_4 += 2;", "}", "VAR_15[VAR_18] = VAR_8;", "VAR_18++;", "}", "VAR_18 += VAR_3;", "}", "ADVANCE_BLOCK();", "break;", "default:\nav_log(VAR_0->avctx, AV_LOG_ERROR, \"Unknown VAR_6 %d in rpza chunk.\"\n\" Skip remaining %d bytes of chunk data.\\n\", VAR_6,\nVAR_5 - VAR_4);", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 45, 47, 49 ], [ 55 ], [ 57 ], [ 63, 65 ], [ 69 ], [ 75 ], [ 81 ], [ 83 ], [ 87 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 171, 173 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 267, 269, 272 ], [ 274 ], [ 276 ], [ 280 ], [ 282 ], [ 284 ], [ 286 ], [ 288 ], [ 290 ], [ 292 ], [ 294 ], [ 296 ], [ 298 ], [ 300 ], [ 306, 308, 310, 312 ], [ 315 ], [ 317 ], [ 319 ] ]
16,705
static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } assert(srcStride[1] == srcStride[2]); mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW, srcSliceH, dstStride[0], srcStride[0], srcStride[1]); return srcSliceH; }
true
FFmpeg
428098165de4c3edfe42c1b7f00627d287015863
static int mlib_YUV2RGB420_24(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } assert(srcStride[1] == srcStride[2]); mlib_VideoColorYUV2RGB420(dst[0]+srcSliceY*dstStride[0], src[0], src[1], src[2], c->dstW, srcSliceH, dstStride[0], srcStride[0], srcStride[1]); return srcSliceH; }
{ "code": [ " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\t\t\t srcSliceH, dstStride[0], srcStride[0], srcStride[1]);", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\t\t\t srcSliceH, dstStride[0], srcStride[0], srcStride[1]);", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\t\t\t srcSliceH, dstStride[0], srcStride[0], srcStride[1]);", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;" ], "line_no": [ 3, 7, 9, 21, 3, 7, 9, 21, 3, 7, 9, 21, 3, 7, 9, 3, 7, 9, 3, 7, 9, 3, 7, 9 ] }
static int FUNC_0(SwsContext *VAR_0, uint8_t* VAR_1[], int VAR_2[], int VAR_3, int VAR_4, uint8_t* VAR_5[], int VAR_6[]){ if(VAR_0->srcFormat == PIX_FMT_YUV422P){ VAR_2[1] *= 2; VAR_2[2] *= 2; } assert(VAR_2[1] == VAR_2[2]); mlib_VideoColorYUV2RGB420(VAR_5[0]+VAR_3*VAR_6[0], VAR_1[0], VAR_1[1], VAR_1[2], VAR_0->dstW, VAR_4, VAR_6[0], VAR_2[0], VAR_2[1]); return VAR_4; }
[ "static int FUNC_0(SwsContext *VAR_0, uint8_t* VAR_1[], int VAR_2[], int VAR_3,\nint VAR_4, uint8_t* VAR_5[], int VAR_6[]){", "if(VAR_0->srcFormat == PIX_FMT_YUV422P){", "VAR_2[1] *= 2;", "VAR_2[2] *= 2;", "}", "assert(VAR_2[1] == VAR_2[2]);", "mlib_VideoColorYUV2RGB420(VAR_5[0]+VAR_3*VAR_6[0], VAR_1[0], VAR_1[1], VAR_1[2], VAR_0->dstW,\nVAR_4, VAR_6[0], VAR_2[0], VAR_2[1]);", "return VAR_4;", "}" ]
[ 1, 0, 1, 1, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 19, 21 ], [ 23 ], [ 25 ] ]
16,706
uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr) { uint64_t val; spapr_tce_dma_read(dev, taddr, &val, sizeof(val)); return tswap64(val); }
true
qemu
ad0ebb91cd8b5fdc4a583b03645677771f420a46
uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr) { uint64_t val; spapr_tce_dma_read(dev, taddr, &val, sizeof(val)); return tswap64(val); }
{ "code": [ "uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr)", " uint64_t val;", " spapr_tce_dma_read(dev, taddr, &val, sizeof(val));", " return tswap64(val);" ], "line_no": [ 1, 5, 9, 11 ] }
uint64_t FUNC_0(VIOsPAPRDevice *dev, uint64_t taddr) { uint64_t val; spapr_tce_dma_read(dev, taddr, &val, sizeof(val)); return tswap64(val); }
[ "uint64_t FUNC_0(VIOsPAPRDevice *dev, uint64_t taddr)\n{", "uint64_t val;", "spapr_tce_dma_read(dev, taddr, &val, sizeof(val));", "return tswap64(val);", "}" ]
[ 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ] ]
16,707
static int raw_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { BDRVRawState *s; BDRVRawReopenState *raw_s; int ret = 0; Error *local_err = NULL; assert(state != NULL); assert(state->bs != NULL); s = state->bs->opaque; state->opaque = g_malloc0(sizeof(BDRVRawReopenState)); raw_s = state->opaque; #ifdef CONFIG_LINUX_AIO raw_s->use_aio = s->use_aio; /* we can use s->aio_ctx instead of a copy, because the use_aio flag is * valid in the 'false' condition even if aio_ctx is set, and raw_set_aio() * won't override aio_ctx if aio_ctx is non-NULL */ if (raw_set_aio(&s->aio_ctx, &raw_s->use_aio, state->flags)) { error_setg(errp, "Could not set AIO state"); return -1; } #endif if (s->type == FTYPE_FD || s->type == FTYPE_CD) { raw_s->open_flags |= O_NONBLOCK; } raw_parse_flags(state->flags, &raw_s->open_flags); raw_s->fd = -1; int fcntl_flags = O_APPEND | O_NONBLOCK; #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif #ifdef O_ASYNC /* Not all operating systems have O_ASYNC, and those that don't * will not let us track the state into raw_s->open_flags (typically * you achieve the same effect with an ioctl, for example I_SETSIG * on Solaris). But we do not use O_ASYNC, so that's fine. */ assert((s->open_flags & O_ASYNC) == 0); #endif if ((raw_s->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) { /* dup the original fd */ /* TODO: use qemu fcntl wrapper */ #ifdef F_DUPFD_CLOEXEC raw_s->fd = fcntl(s->fd, F_DUPFD_CLOEXEC, 0); #else raw_s->fd = dup(s->fd); if (raw_s->fd != -1) { qemu_set_cloexec(raw_s->fd); } #endif if (raw_s->fd >= 0) { ret = fcntl_setfl(raw_s->fd, raw_s->open_flags); if (ret) { qemu_close(raw_s->fd); raw_s->fd = -1; } } } /* If we cannot use fcntl, or fcntl failed, fall back to qemu_open() */ if (raw_s->fd == -1) { assert(!(raw_s->open_flags & O_CREAT)); raw_s->fd = qemu_open(state->bs->filename, raw_s->open_flags); if (raw_s->fd == -1) { error_setg_errno(errp, errno, "Could not reopen file"); ret = -1; } } /* Fail already reopen_prepare() if we can't get a working O_DIRECT * alignment with the new fd. */ if (raw_s->fd != -1) { raw_probe_alignment(state->bs, raw_s->fd, &local_err); if (local_err) { qemu_close(raw_s->fd); raw_s->fd = -1; error_propagate(errp, local_err); ret = -EINVAL; } } return ret; }
true
qemu
5839e53bbc0fec56021d758aab7610df421ed8c8
static int raw_reopen_prepare(BDRVReopenState *state, BlockReopenQueue *queue, Error **errp) { BDRVRawState *s; BDRVRawReopenState *raw_s; int ret = 0; Error *local_err = NULL; assert(state != NULL); assert(state->bs != NULL); s = state->bs->opaque; state->opaque = g_malloc0(sizeof(BDRVRawReopenState)); raw_s = state->opaque; #ifdef CONFIG_LINUX_AIO raw_s->use_aio = s->use_aio; if (raw_set_aio(&s->aio_ctx, &raw_s->use_aio, state->flags)) { error_setg(errp, "Could not set AIO state"); return -1; } #endif if (s->type == FTYPE_FD || s->type == FTYPE_CD) { raw_s->open_flags |= O_NONBLOCK; } raw_parse_flags(state->flags, &raw_s->open_flags); raw_s->fd = -1; int fcntl_flags = O_APPEND | O_NONBLOCK; #ifdef O_NOATIME fcntl_flags |= O_NOATIME; #endif #ifdef O_ASYNC assert((s->open_flags & O_ASYNC) == 0); #endif if ((raw_s->open_flags & ~fcntl_flags) == (s->open_flags & ~fcntl_flags)) { #ifdef F_DUPFD_CLOEXEC raw_s->fd = fcntl(s->fd, F_DUPFD_CLOEXEC, 0); #else raw_s->fd = dup(s->fd); if (raw_s->fd != -1) { qemu_set_cloexec(raw_s->fd); } #endif if (raw_s->fd >= 0) { ret = fcntl_setfl(raw_s->fd, raw_s->open_flags); if (ret) { qemu_close(raw_s->fd); raw_s->fd = -1; } } } if (raw_s->fd == -1) { assert(!(raw_s->open_flags & O_CREAT)); raw_s->fd = qemu_open(state->bs->filename, raw_s->open_flags); if (raw_s->fd == -1) { error_setg_errno(errp, errno, "Could not reopen file"); ret = -1; } } if (raw_s->fd != -1) { raw_probe_alignment(state->bs, raw_s->fd, &local_err); if (local_err) { qemu_close(raw_s->fd); raw_s->fd = -1; error_propagate(errp, local_err); ret = -EINVAL; } } return ret; }
{ "code": [ " state->opaque = g_malloc0(sizeof(BDRVRawReopenState));" ], "line_no": [ 27 ] }
static int FUNC_0(BDRVReopenState *VAR_0, BlockReopenQueue *VAR_1, Error **VAR_2) { BDRVRawState *s; BDRVRawReopenState *raw_s; int VAR_3 = 0; Error *local_err = NULL; assert(VAR_0 != NULL); assert(VAR_0->bs != NULL); s = VAR_0->bs->opaque; VAR_0->opaque = g_malloc0(sizeof(BDRVRawReopenState)); raw_s = VAR_0->opaque; #ifdef CONFIG_LINUX_AIO raw_s->use_aio = s->use_aio; if (raw_set_aio(&s->aio_ctx, &raw_s->use_aio, VAR_0->flags)) { error_setg(VAR_2, "Could not set AIO VAR_0"); return -1; } #endif if (s->type == FTYPE_FD || s->type == FTYPE_CD) { raw_s->open_flags |= O_NONBLOCK; } raw_parse_flags(VAR_0->flags, &raw_s->open_flags); raw_s->fd = -1; int VAR_4 = O_APPEND | O_NONBLOCK; #ifdef O_NOATIME VAR_4 |= O_NOATIME; #endif #ifdef O_ASYNC assert((s->open_flags & O_ASYNC) == 0); #endif if ((raw_s->open_flags & ~VAR_4) == (s->open_flags & ~VAR_4)) { #ifdef F_DUPFD_CLOEXEC raw_s->fd = fcntl(s->fd, F_DUPFD_CLOEXEC, 0); #else raw_s->fd = dup(s->fd); if (raw_s->fd != -1) { qemu_set_cloexec(raw_s->fd); } #endif if (raw_s->fd >= 0) { VAR_3 = fcntl_setfl(raw_s->fd, raw_s->open_flags); if (VAR_3) { qemu_close(raw_s->fd); raw_s->fd = -1; } } } if (raw_s->fd == -1) { assert(!(raw_s->open_flags & O_CREAT)); raw_s->fd = qemu_open(VAR_0->bs->filename, raw_s->open_flags); if (raw_s->fd == -1) { error_setg_errno(VAR_2, errno, "Could not reopen file"); VAR_3 = -1; } } if (raw_s->fd != -1) { raw_probe_alignment(VAR_0->bs, raw_s->fd, &local_err); if (local_err) { qemu_close(raw_s->fd); raw_s->fd = -1; error_propagate(VAR_2, local_err); VAR_3 = -EINVAL; } } return VAR_3; }
[ "static int FUNC_0(BDRVReopenState *VAR_0,\nBlockReopenQueue *VAR_1, Error **VAR_2)\n{", "BDRVRawState *s;", "BDRVRawReopenState *raw_s;", "int VAR_3 = 0;", "Error *local_err = NULL;", "assert(VAR_0 != NULL);", "assert(VAR_0->bs != NULL);", "s = VAR_0->bs->opaque;", "VAR_0->opaque = g_malloc0(sizeof(BDRVRawReopenState));", "raw_s = VAR_0->opaque;", "#ifdef CONFIG_LINUX_AIO\nraw_s->use_aio = s->use_aio;", "if (raw_set_aio(&s->aio_ctx, &raw_s->use_aio, VAR_0->flags)) {", "error_setg(VAR_2, \"Could not set AIO VAR_0\");", "return -1;", "}", "#endif\nif (s->type == FTYPE_FD || s->type == FTYPE_CD) {", "raw_s->open_flags |= O_NONBLOCK;", "}", "raw_parse_flags(VAR_0->flags, &raw_s->open_flags);", "raw_s->fd = -1;", "int VAR_4 = O_APPEND | O_NONBLOCK;", "#ifdef O_NOATIME\nVAR_4 |= O_NOATIME;", "#endif\n#ifdef O_ASYNC\nassert((s->open_flags & O_ASYNC) == 0);", "#endif\nif ((raw_s->open_flags & ~VAR_4) == (s->open_flags & ~VAR_4)) {", "#ifdef F_DUPFD_CLOEXEC\nraw_s->fd = fcntl(s->fd, F_DUPFD_CLOEXEC, 0);", "#else\nraw_s->fd = dup(s->fd);", "if (raw_s->fd != -1) {", "qemu_set_cloexec(raw_s->fd);", "}", "#endif\nif (raw_s->fd >= 0) {", "VAR_3 = fcntl_setfl(raw_s->fd, raw_s->open_flags);", "if (VAR_3) {", "qemu_close(raw_s->fd);", "raw_s->fd = -1;", "}", "}", "}", "if (raw_s->fd == -1) {", "assert(!(raw_s->open_flags & O_CREAT));", "raw_s->fd = qemu_open(VAR_0->bs->filename, raw_s->open_flags);", "if (raw_s->fd == -1) {", "error_setg_errno(VAR_2, errno, \"Could not reopen file\");", "VAR_3 = -1;", "}", "}", "if (raw_s->fd != -1) {", "raw_probe_alignment(VAR_0->bs, raw_s->fd, &local_err);", "if (local_err) {", "qemu_close(raw_s->fd);", "raw_s->fd = -1;", "error_propagate(VAR_2, local_err);", "VAR_3 = -EINVAL;", "}", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53, 57 ], [ 59 ], [ 61 ], [ 65 ], [ 69 ], [ 73 ], [ 75, 77 ], [ 79, 83, 95 ], [ 97, 101 ], [ 107, 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ] ]
16,710
int net_init_dump(QemuOpts *opts, const char *name, VLANState *vlan) { int len; const char *file; char def_file[128]; assert(vlan); file = qemu_opt_get(opts, "file"); if (!file) { snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id); file = def_file; } len = qemu_opt_get_size(opts, "len", 65536); return net_dump_init(vlan, "dump", name, file, len); }
true
qemu
6687b79d636cd60ed9adb1177d0d946b58fa7717
int net_init_dump(QemuOpts *opts, const char *name, VLANState *vlan) { int len; const char *file; char def_file[128]; assert(vlan); file = qemu_opt_get(opts, "file"); if (!file) { snprintf(def_file, sizeof(def_file), "qemu-vlan%d.pcap", vlan->id); file = def_file; } len = qemu_opt_get_size(opts, "len", 65536); return net_dump_init(vlan, "dump", name, file, len); }
{ "code": [ "int net_init_dump(QemuOpts *opts, const char *name, VLANState *vlan)" ], "line_no": [ 1 ] }
int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2) { int VAR_3; const char *VAR_4; char VAR_5[128]; assert(VAR_2); VAR_4 = qemu_opt_get(VAR_0, "VAR_4"); if (!VAR_4) { snprintf(VAR_5, sizeof(VAR_5), "qemu-VAR_2%d.pcap", VAR_2->id); VAR_4 = VAR_5; } VAR_3 = qemu_opt_get_size(VAR_0, "VAR_3", 65536); return net_dump_init(VAR_2, "dump", VAR_1, VAR_4, VAR_3); }
[ "int FUNC_0(QemuOpts *VAR_0, const char *VAR_1, VLANState *VAR_2)\n{", "int VAR_3;", "const char *VAR_4;", "char VAR_5[128];", "assert(VAR_2);", "VAR_4 = qemu_opt_get(VAR_0, \"VAR_4\");", "if (!VAR_4) {", "snprintf(VAR_5, sizeof(VAR_5), \"qemu-VAR_2%d.pcap\", VAR_2->id);", "VAR_4 = VAR_5;", "}", "VAR_3 = qemu_opt_get_size(VAR_0, \"VAR_3\", 65536);", "return net_dump_init(VAR_2, \"dump\", VAR_1, VAR_4, VAR_3);", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 33 ], [ 35 ] ]
16,711
static int blk_free(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct ioreq *ioreq; if (blkdev->blk || blkdev->sring) { blk_disconnect(xendev); } /* Free persistent grants */ if (blkdev->feature_persistent) { g_tree_destroy(blkdev->persistent_gnts); } while (!QLIST_EMPTY(&blkdev->freelist)) { ioreq = QLIST_FIRST(&blkdev->freelist); QLIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); g_free(ioreq); } g_free(blkdev->params); g_free(blkdev->mode); g_free(blkdev->type); g_free(blkdev->dev); g_free(blkdev->devtype); qemu_bh_delete(blkdev->bh); return 0; }
true
qemu
2f01dfacb56bc7a0d4639adc9dff9aae131e6216
static int blk_free(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct ioreq *ioreq; if (blkdev->blk || blkdev->sring) { blk_disconnect(xendev); } if (blkdev->feature_persistent) { g_tree_destroy(blkdev->persistent_gnts); } while (!QLIST_EMPTY(&blkdev->freelist)) { ioreq = QLIST_FIRST(&blkdev->freelist); QLIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); g_free(ioreq); } g_free(blkdev->params); g_free(blkdev->mode); g_free(blkdev->type); g_free(blkdev->dev); g_free(blkdev->devtype); qemu_bh_delete(blkdev->bh); return 0; }
{ "code": [ " if (blkdev->feature_persistent) {", " g_tree_destroy(blkdev->persistent_gnts);" ], "line_no": [ 21, 23 ] }
static int FUNC_0(struct XenDevice *VAR_0) { struct XenBlkDev *VAR_1 = container_of(VAR_0, struct XenBlkDev, VAR_0); struct VAR_2 *VAR_2; if (VAR_1->blk || VAR_1->sring) { blk_disconnect(VAR_0); } if (VAR_1->feature_persistent) { g_tree_destroy(VAR_1->persistent_gnts); } while (!QLIST_EMPTY(&VAR_1->freelist)) { VAR_2 = QLIST_FIRST(&VAR_1->freelist); QLIST_REMOVE(VAR_2, list); qemu_iovec_destroy(&VAR_2->v); g_free(VAR_2); } g_free(VAR_1->params); g_free(VAR_1->mode); g_free(VAR_1->type); g_free(VAR_1->dev); g_free(VAR_1->devtype); qemu_bh_delete(VAR_1->bh); return 0; }
[ "static int FUNC_0(struct XenDevice *VAR_0)\n{", "struct XenBlkDev *VAR_1 = container_of(VAR_0, struct XenBlkDev, VAR_0);", "struct VAR_2 *VAR_2;", "if (VAR_1->blk || VAR_1->sring) {", "blk_disconnect(VAR_0);", "}", "if (VAR_1->feature_persistent) {", "g_tree_destroy(VAR_1->persistent_gnts);", "}", "while (!QLIST_EMPTY(&VAR_1->freelist)) {", "VAR_2 = QLIST_FIRST(&VAR_1->freelist);", "QLIST_REMOVE(VAR_2, list);", "qemu_iovec_destroy(&VAR_2->v);", "g_free(VAR_2);", "}", "g_free(VAR_1->params);", "g_free(VAR_1->mode);", "g_free(VAR_1->type);", "g_free(VAR_1->dev);", "g_free(VAR_1->devtype);", "qemu_bh_delete(VAR_1->bh);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
16,712
static void r2d_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; struct SH7750State *s; ram_addr_t sdram_addr, sm501_vga_ram_addr; qemu_irq *irq; PCIBus *pci; int i; if (!cpu_model) cpu_model = "SH7751R"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } /* Allocate memory space */ sdram_addr = qemu_ram_alloc(SDRAM_SIZE); cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr); /* Register peripherals */ s = sh7750_init(env); irq = r2d_fpga_init(0x04000000, sh7750_irl(s)); pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4); sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE); sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE, serial_hds[2]); /* onboard CF (True IDE mode, Master only). */ mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL); /* NIC: rtl8139 on-board, and 2 slots. */ pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139"); for (i = 1; i < nb_nics; i++) pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci"); /* Todo: register on board registers */ { int kernel_size; /* initialization which should be done by firmware */ stl_phys(SH7750_BCR1, 1<<3); /* cs3 SDRAM */ stw_phys(SH7750_BCR2, 3<<(3*2)); /* cs3 32bit */ kernel_size = load_image(kernel_filename, phys_ram_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->pc = SDRAM_BASE | 0xa0000000; /* Start from P2 area */ } }
true
qemu
ab2da564d7f8f2a0e4e31875e1cdf87db14500e2
static void r2d_init(ram_addr_t ram_size, int vga_ram_size, const char *boot_device, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model) { CPUState *env; struct SH7750State *s; ram_addr_t sdram_addr, sm501_vga_ram_addr; qemu_irq *irq; PCIBus *pci; int i; if (!cpu_model) cpu_model = "SH7751R"; env = cpu_init(cpu_model); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } sdram_addr = qemu_ram_alloc(SDRAM_SIZE); cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr); s = sh7750_init(env); irq = r2d_fpga_init(0x04000000, sh7750_irl(s)); pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4); sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE); sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE, serial_hds[2]); mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL); pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139"); for (i = 1; i < nb_nics; i++) pci_nic_init(pci, &nd_table[i], -1, "ne2k_pci"); { int kernel_size; stl_phys(SH7750_BCR1, 1<<3); stw_phys(SH7750_BCR2, 3<<(3*2)); kernel_size = load_image(kernel_filename, phys_ram_base); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); exit(1); } env->pc = SDRAM_BASE | 0xa0000000; } }
{ "code": [ " mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1,", " drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);", " pci_nic_init(pci, &nd_table[0], 2 << 3, \"rtl8139\");", " for (i = 1; i < nb_nics; i++)", " pci_nic_init(pci, &nd_table[i], -1, \"ne2k_pci\");" ], "line_no": [ 69, 71, 77, 79, 81 ] }
static void FUNC_0(ram_addr_t VAR_0, int VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5, const char *VAR_6) { CPUState *env; struct SH7750State *VAR_7; ram_addr_t sdram_addr, sm501_vga_ram_addr; qemu_irq *irq; PCIBus *pci; int VAR_8; if (!VAR_6) VAR_6 = "SH7751R"; env = cpu_init(VAR_6); if (!env) { fprintf(stderr, "Unable to find CPU definition\n"); exit(1); } sdram_addr = qemu_ram_alloc(SDRAM_SIZE); cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr); VAR_7 = sh7750_init(env); irq = r2d_fpga_init(0x04000000, sh7750_irl(VAR_7)); pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4); sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE); sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE, serial_hds[2]); mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1, drives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL); pci_nic_init(pci, &nd_table[0], 2 << 3, "rtl8139"); for (VAR_8 = 1; VAR_8 < nb_nics; VAR_8++) pci_nic_init(pci, &nd_table[VAR_8], -1, "ne2k_pci"); { int VAR_9; stl_phys(SH7750_BCR1, 1<<3); stw_phys(SH7750_BCR2, 3<<(3*2)); VAR_9 = load_image(VAR_3, phys_ram_base); if (VAR_9 < 0) { fprintf(stderr, "qemu: could not load kernel '%VAR_7'\n", VAR_3); exit(1); } env->pc = SDRAM_BASE | 0xa0000000; } }
[ "static void FUNC_0(ram_addr_t VAR_0, int VAR_1,\nconst char *VAR_2,\nconst char *VAR_3, const char *VAR_4,\nconst char *VAR_5, const char *VAR_6)\n{", "CPUState *env;", "struct SH7750State *VAR_7;", "ram_addr_t sdram_addr, sm501_vga_ram_addr;", "qemu_irq *irq;", "PCIBus *pci;", "int VAR_8;", "if (!VAR_6)\nVAR_6 = \"SH7751R\";", "env = cpu_init(VAR_6);", "if (!env) {", "fprintf(stderr, \"Unable to find CPU definition\\n\");", "exit(1);", "}", "sdram_addr = qemu_ram_alloc(SDRAM_SIZE);", "cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, sdram_addr);", "VAR_7 = sh7750_init(env);", "irq = r2d_fpga_init(0x04000000, sh7750_irl(VAR_7));", "pci = sh_pci_register_bus(r2d_pci_set_irq, r2d_pci_map_irq, irq, 0, 4);", "sm501_vga_ram_addr = qemu_ram_alloc(SM501_VRAM_SIZE);", "sm501_init(0x10000000, sm501_vga_ram_addr, SM501_VRAM_SIZE,\nserial_hds[2]);", "mmio_ide_init(0x14001000, 0x1400080c, irq[CF_IDE], 1,\ndrives_table[drive_get_index(IF_IDE, 0, 0)].bdrv, NULL);", "pci_nic_init(pci, &nd_table[0], 2 << 3, \"rtl8139\");", "for (VAR_8 = 1; VAR_8 < nb_nics; VAR_8++)", "pci_nic_init(pci, &nd_table[VAR_8], -1, \"ne2k_pci\");", "{", "int VAR_9;", "stl_phys(SH7750_BCR1, 1<<3);", "stw_phys(SH7750_BCR2, 3<<(3*2));", "VAR_9 = load_image(VAR_3, phys_ram_base);", "if (VAR_9 < 0) {", "fprintf(stderr, \"qemu: could not load kernel '%VAR_7'\\n\", VAR_3);", "exit(1);", "}", "env->pc = SDRAM_BASE | 0xa0000000;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61, 63 ], [ 69, 71 ], [ 77 ], [ 79 ], [ 81 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ] ]
16,713
MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) { mis_current = g_malloc0(sizeof(MigrationIncomingState)); mis_current->file = f; QLIST_INIT(&mis_current->loadvm_handlers); return mis_current; }
true
qemu
97f3ad35517e0d02c0149637d1bb10713c52b057
MigrationIncomingState *migration_incoming_state_new(QEMUFile* f) { mis_current = g_malloc0(sizeof(MigrationIncomingState)); mis_current->file = f; QLIST_INIT(&mis_current->loadvm_handlers); return mis_current; }
{ "code": [ " mis_current = g_malloc0(sizeof(MigrationIncomingState));" ], "line_no": [ 5 ] }
MigrationIncomingState *FUNC_0(QEMUFile* f) { mis_current = g_malloc0(sizeof(MigrationIncomingState)); mis_current->file = f; QLIST_INIT(&mis_current->loadvm_handlers); return mis_current; }
[ "MigrationIncomingState *FUNC_0(QEMUFile* f)\n{", "mis_current = g_malloc0(sizeof(MigrationIncomingState));", "mis_current->file = f;", "QLIST_INIT(&mis_current->loadvm_handlers);", "return mis_current;", "}" ]
[ 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ] ]
16,714
double av_get_double(void *obj, const char *name, const AVOption **o_out) { int64_t intnum=1; double num=1; int den=1; av_get_number(obj, name, o_out, &num, &den, &intnum); return num*intnum/den; }
true
FFmpeg
8089b7fa8c5b5a48cc7101daa4be891d0ead5a5e
double av_get_double(void *obj, const char *name, const AVOption **o_out) { int64_t intnum=1; double num=1; int den=1; av_get_number(obj, name, o_out, &num, &den, &intnum); return num*intnum/den; }
{ "code": [ " av_get_number(obj, name, o_out, &num, &den, &intnum);", " av_get_number(obj, name, o_out, &num, &den, &intnum);", " av_get_number(obj, name, o_out, &num, &den, &intnum);" ], "line_no": [ 13, 13, 13 ] }
double FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2) { int64_t intnum=1; double VAR_3=1; int VAR_4=1; av_get_number(VAR_0, VAR_1, VAR_2, &VAR_3, &VAR_4, &intnum); return VAR_3*intnum/VAR_4; }
[ "double FUNC_0(void *VAR_0, const char *VAR_1, const AVOption **VAR_2)\n{", "int64_t intnum=1;", "double VAR_3=1;", "int VAR_4=1;", "av_get_number(VAR_0, VAR_1, VAR_2, &VAR_3, &VAR_4, &intnum);", "return VAR_3*intnum/VAR_4;", "}" ]
[ 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ] ]
16,715
static void laio_cancel(BlockDriverAIOCB *blockacb) { struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; struct io_event event; int ret; if (laiocb->ret != -EINPROGRESS) return; /* * Note that as of Linux 2.6.31 neither the block device code nor any * filesystem implements cancellation of AIO request. * Thus the polling loop below is the normal code path. */ ret = io_cancel(laiocb->ctx->ctx, &laiocb->iocb, &event); if (ret == 0) { laiocb->ret = -ECANCELED; return; } /* * We have to wait for the iocb to finish. * * The only way to get the iocb status update is by polling the io context. * We might be able to do this slightly more optimal by removing the * O_NONBLOCK flag. */ while (laiocb->ret == -EINPROGRESS) { qemu_laio_completion_cb(&laiocb->ctx->e); } }
true
qemu
771b64daf9c73be98d223d3ab101a61f02cac277
static void laio_cancel(BlockDriverAIOCB *blockacb) { struct qemu_laiocb *laiocb = (struct qemu_laiocb *)blockacb; struct io_event event; int ret; if (laiocb->ret != -EINPROGRESS) return; ret = io_cancel(laiocb->ctx->ctx, &laiocb->iocb, &event); if (ret == 0) { laiocb->ret = -ECANCELED; return; } while (laiocb->ret == -EINPROGRESS) { qemu_laio_completion_cb(&laiocb->ctx->e); } }
{ "code": [ " if (laiocb->ret != -EINPROGRESS)", " if (ret == 0) {", " laiocb->ret = -ECANCELED;", " while (laiocb->ret == -EINPROGRESS) {", " qemu_laio_completion_cb(&laiocb->ctx->e);" ], "line_no": [ 13, 31, 33, 55, 57 ] }
static void FUNC_0(BlockDriverAIOCB *VAR_0) { struct qemu_laiocb *VAR_1 = (struct qemu_laiocb *)VAR_0; struct io_event VAR_2; int VAR_3; if (VAR_1->VAR_3 != -EINPROGRESS) return; VAR_3 = io_cancel(VAR_1->ctx->ctx, &VAR_1->iocb, &VAR_2); if (VAR_3 == 0) { VAR_1->VAR_3 = -ECANCELED; return; } while (VAR_1->VAR_3 == -EINPROGRESS) { qemu_laio_completion_cb(&VAR_1->ctx->e); } }
[ "static void FUNC_0(BlockDriverAIOCB *VAR_0)\n{", "struct qemu_laiocb *VAR_1 = (struct qemu_laiocb *)VAR_0;", "struct io_event VAR_2;", "int VAR_3;", "if (VAR_1->VAR_3 != -EINPROGRESS)\nreturn;", "VAR_3 = io_cancel(VAR_1->ctx->ctx, &VAR_1->iocb, &VAR_2);", "if (VAR_3 == 0) {", "VAR_1->VAR_3 = -ECANCELED;", "return;", "}", "while (VAR_1->VAR_3 == -EINPROGRESS) {", "qemu_laio_completion_cb(&VAR_1->ctx->e);", "}", "}" ]
[ 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ] ]
16,716
static inline void RENAME(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { x86_reg uv_off = c->uv_off << 1; const uint16_t *buf1= buf0; //FIXME needed for RGB1/BGR1 if (uvalpha < 2048) { // note this is not correct (shifts chrominance by 0.5 pixels) but it is a bit faster __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } }
true
FFmpeg
009f829dde811af654af7110326aea3a72c05d5e
static inline void RENAME(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { x86_reg uv_off = c->uv_off << 1; const uint16_t *buf1= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (buf1), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } }
{ "code": [ " x86_reg uv_off = c->uv_off << 1;", " \"a\" (&c->redDither), \"m\"(uv_off)", " \"a\" (&c->redDither), \"m\"(uv_off)", " x86_reg uv_off = c->uv_off << 1;", " x86_reg uv_off = c->uv_off << 1;", " x86_reg uv_off = c->uv_off << 1;", " x86_reg uv_off = c->uv_off << 1;", " x86_reg uv_off = c->uv_off << 1;", " x86_reg uv_off = c->uv_off << 1;", " YSCALEYUV2RGB1(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " YSCALEYUV2RGB1b(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " x86_reg uv_off = c->uv_off << 1;", " YSCALEYUV2RGB1(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " YSCALEYUV2RGB1b(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " x86_reg uv_off = c->uv_off << 1;", " YSCALEYUV2RGB1(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " YSCALEYUV2RGB1b(%%REGBP, %5, %6)", " \"a\" (&c->redDither), \"m\"(uv_off)", " x86_reg uv_off = c->uv_off << 1;", " \"a\" (&c->redDither), \"m\"(uv_off)", " \"a\" (&c->redDither), \"m\"(uv_off)" ], "line_no": [ 15, 43, 43, 15, 15, 15, 15, 15, 15, 31, 43, 57, 43, 15, 31, 43, 57, 43, 15, 31, 43, 57, 43, 15, 43, 43 ] }
static inline void FUNC_0(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0, const uint16_t *ubuf0, const uint16_t *ubuf1, const uint16_t *vbuf0, const uint16_t *vbuf1, const uint16_t *abuf0, uint8_t *dest, int dstW, int uvalpha, enum PixelFormat dstFormat, int flags, int y) { x86_reg uv_off = c->uv_off << 1; const uint16_t *VAR_0= buf0; if (uvalpha < 2048) { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } else { __asm__ volatile( "mov %%"REG_b", "ESP_OFFSET"(%5) \n\t" "mov %4, %%"REG_b" \n\t" "push %%"REG_BP" \n\t" YSCALEYUV2RGB1b(%%REGBP, %5, %6) "pxor %%mm7, %%mm7 \n\t" WRITEBGR24(%%REGb, 8280(%5), %%REGBP) "pop %%"REG_BP" \n\t" "mov "ESP_OFFSET"(%5), %%"REG_b" \n\t" :: "c" (buf0), "d" (VAR_0), "S" (ubuf0), "D" (ubuf1), "m" (dest), "a" (&c->redDither), "m"(uv_off) ); } }
[ "static inline void FUNC_0(yuv2bgr24_1)(SwsContext *c, const uint16_t *buf0,\nconst uint16_t *ubuf0, const uint16_t *ubuf1,\nconst uint16_t *vbuf0, const uint16_t *vbuf1,\nconst uint16_t *abuf0, uint8_t *dest,\nint dstW, int uvalpha, enum PixelFormat dstFormat,\nint flags, int y)\n{", "x86_reg uv_off = c->uv_off << 1;", "const uint16_t *VAR_0= buf0;", "if (uvalpha < 2048) {", "__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1(%%REGBP, %5, %6)\n\"pxor %%mm7, %%mm7 \\n\\t\"\nWRITEBGR24(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither), \"m\"(uv_off)\n);", "} else {", "__asm__ volatile(\n\"mov %%\"REG_b\", \"ESP_OFFSET\"(%5) \\n\\t\"\n\"mov %4, %%\"REG_b\" \\n\\t\"\n\"push %%\"REG_BP\" \\n\\t\"\nYSCALEYUV2RGB1b(%%REGBP, %5, %6)\n\"pxor %%mm7, %%mm7 \\n\\t\"\nWRITEBGR24(%%REGb, 8280(%5), %%REGBP)\n\"pop %%\"REG_BP\" \\n\\t\"\n\"mov \"ESP_OFFSET\"(%5), %%\"REG_b\" \\n\\t\"\n:: \"c\" (buf0), \"d\" (VAR_0), \"S\" (ubuf0), \"D\" (ubuf1), \"m\" (dest),\n\"a\" (&c->redDither), \"m\"(uv_off)\n);", "}", "}" ]
[ 0, 1, 0, 0, 1, 0, 1, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45 ], [ 47 ], [ 49, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71 ], [ 73 ], [ 75 ] ]
16,718
static int avi_read_idx1(AVFormatContext *s, int size) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int nb_index_entries, i; AVStream *st; AVIStream *ast; unsigned int index, tag, flags, pos, len, first_packet = 1; unsigned last_pos= -1; int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; nb_index_entries = size / 16; if (nb_index_entries <= 0) return -1; idx1_pos = avio_tell(pb); avio_seek(pb, avi->movi_list+4, SEEK_SET); if (avi_sync(s, 1) == 0) { first_packet_pos = avio_tell(pb) - 8; } avi->stream_index = -1; avio_seek(pb, idx1_pos, SEEK_SET); /* Read the entries and sort them in each stream component. */ for(i = 0; i < nb_index_entries; i++) { tag = avio_rl32(pb); flags = avio_rl32(pb); pos = avio_rl32(pb); len = avio_rl32(pb); av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", i, tag, flags, pos, len); index = ((tag & 0xff) - '0') * 10; index += ((tag >> 8) & 0xff) - '0'; if (index >= s->nb_streams) continue; st = s->streams[index]; ast = st->priv_data; if(first_packet && first_packet_pos && len) { data_offset = first_packet_pos - pos; first_packet = 0; } pos += data_offset; av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); if(url_feof(pb)) return -1; if(last_pos == pos) avi->non_interleaved= 1; else if(len || !ast->sample_size) av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); ast->cum_len += get_duration(ast, len); last_pos= pos; } return 0; }
true
FFmpeg
3c7f75bd84b4c30a0f86a491a37f759dfaaab86d
static int avi_read_idx1(AVFormatContext *s, int size) { AVIContext *avi = s->priv_data; AVIOContext *pb = s->pb; int nb_index_entries, i; AVStream *st; AVIStream *ast; unsigned int index, tag, flags, pos, len, first_packet = 1; unsigned last_pos= -1; int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; nb_index_entries = size / 16; if (nb_index_entries <= 0) return -1; idx1_pos = avio_tell(pb); avio_seek(pb, avi->movi_list+4, SEEK_SET); if (avi_sync(s, 1) == 0) { first_packet_pos = avio_tell(pb) - 8; } avi->stream_index = -1; avio_seek(pb, idx1_pos, SEEK_SET); for(i = 0; i < nb_index_entries; i++) { tag = avio_rl32(pb); flags = avio_rl32(pb); pos = avio_rl32(pb); len = avio_rl32(pb); av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", i, tag, flags, pos, len); index = ((tag & 0xff) - '0') * 10; index += ((tag >> 8) & 0xff) - '0'; if (index >= s->nb_streams) continue; st = s->streams[index]; ast = st->priv_data; if(first_packet && first_packet_pos && len) { data_offset = first_packet_pos - pos; first_packet = 0; } pos += data_offset; av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); if(url_feof(pb)) return -1; if(last_pos == pos) avi->non_interleaved= 1; else if(len || !ast->sample_size) av_add_index_entry(st, pos, ast->cum_len, len, 0, (flags&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); ast->cum_len += get_duration(ast, len); last_pos= pos; } return 0; }
{ "code": [ " if(url_feof(pb))", " return -1;" ], "line_no": [ 95, 97 ] }
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1) { AVIContext *avi = VAR_0->priv_data; AVIOContext *pb = VAR_0->pb; int VAR_2, VAR_3; AVStream *st; AVIStream *ast; unsigned int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 1; unsigned VAR_10= -1; int64_t idx1_pos, first_packet_pos = 0, data_offset = 0; VAR_2 = VAR_1 / 16; if (VAR_2 <= 0) return -1; idx1_pos = avio_tell(pb); avio_seek(pb, avi->movi_list+4, SEEK_SET); if (avi_sync(VAR_0, 1) == 0) { first_packet_pos = avio_tell(pb) - 8; } avi->stream_index = -1; avio_seek(pb, idx1_pos, SEEK_SET); for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) { VAR_5 = avio_rl32(pb); VAR_6 = avio_rl32(pb); VAR_7 = avio_rl32(pb); VAR_8 = avio_rl32(pb); av_dlog(VAR_0, "%d: VAR_5=0x%x VAR_6=0x%x VAR_7=0x%x VAR_8=%d/", VAR_3, VAR_5, VAR_6, VAR_7, VAR_8); VAR_4 = ((VAR_5 & 0xff) - '0') * 10; VAR_4 += ((VAR_5 >> 8) & 0xff) - '0'; if (VAR_4 >= VAR_0->nb_streams) continue; st = VAR_0->streams[VAR_4]; ast = st->priv_data; if(VAR_9 && first_packet_pos && VAR_8) { data_offset = first_packet_pos - VAR_7; VAR_9 = 0; } VAR_7 += data_offset; av_dlog(VAR_0, "%d cum_len=%"PRId64"\n", VAR_8, ast->cum_len); if(url_feof(pb)) return -1; if(VAR_10 == VAR_7) avi->non_interleaved= 1; else if(VAR_8 || !ast->sample_size) av_add_index_entry(st, VAR_7, ast->cum_len, VAR_8, 0, (VAR_6&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0); ast->cum_len += get_duration(ast, VAR_8); VAR_10= VAR_7; } return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0, int VAR_1)\n{", "AVIContext *avi = VAR_0->priv_data;", "AVIOContext *pb = VAR_0->pb;", "int VAR_2, VAR_3;", "AVStream *st;", "AVIStream *ast;", "unsigned int VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9 = 1;", "unsigned VAR_10= -1;", "int64_t idx1_pos, first_packet_pos = 0, data_offset = 0;", "VAR_2 = VAR_1 / 16;", "if (VAR_2 <= 0)\nreturn -1;", "idx1_pos = avio_tell(pb);", "avio_seek(pb, avi->movi_list+4, SEEK_SET);", "if (avi_sync(VAR_0, 1) == 0) {", "first_packet_pos = avio_tell(pb) - 8;", "}", "avi->stream_index = -1;", "avio_seek(pb, idx1_pos, SEEK_SET);", "for(VAR_3 = 0; VAR_3 < VAR_2; VAR_3++) {", "VAR_5 = avio_rl32(pb);", "VAR_6 = avio_rl32(pb);", "VAR_7 = avio_rl32(pb);", "VAR_8 = avio_rl32(pb);", "av_dlog(VAR_0, \"%d: VAR_5=0x%x VAR_6=0x%x VAR_7=0x%x VAR_8=%d/\",\nVAR_3, VAR_5, VAR_6, VAR_7, VAR_8);", "VAR_4 = ((VAR_5 & 0xff) - '0') * 10;", "VAR_4 += ((VAR_5 >> 8) & 0xff) - '0';", "if (VAR_4 >= VAR_0->nb_streams)\ncontinue;", "st = VAR_0->streams[VAR_4];", "ast = st->priv_data;", "if(VAR_9 && first_packet_pos && VAR_8) {", "data_offset = first_packet_pos - VAR_7;", "VAR_9 = 0;", "}", "VAR_7 += data_offset;", "av_dlog(VAR_0, \"%d cum_len=%\"PRId64\"\\n\", VAR_8, ast->cum_len);", "if(url_feof(pb))\nreturn -1;", "if(VAR_10 == VAR_7)\navi->non_interleaved= 1;", "else if(VAR_8 || !ast->sample_size)\nav_add_index_entry(st, VAR_7, ast->cum_len, VAR_8, 0, (VAR_6&AVIIF_INDEX) ? AVINDEX_KEYFRAME : 0);", "ast->cum_len += get_duration(ast, VAR_8);", "VAR_10= VAR_7;", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 65 ], [ 67 ], [ 69, 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95, 97 ], [ 101, 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ] ]
16,719
static float quantize_band_cost_bits(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, int rtz) { return get_band_numbits(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits); }
true
FFmpeg
01ecb7172b684f1c4b3e748f95c5a9a494ca36ec
static float quantize_band_cost_bits(struct AACEncContext *s, const float *in, const float *scaled, int size, int scale_idx, int cb, const float lambda, const float uplim, int *bits, int rtz) { return get_band_numbits(s, NULL, in, scaled, size, scale_idx, cb, lambda, uplim, bits); }
{ "code": [ " int *bits, int rtz)" ], "line_no": [ 7 ] }
static float FUNC_0(struct AACEncContext *VAR_0, const float *VAR_1, const float *VAR_2, int VAR_3, int VAR_4, int VAR_5, const float VAR_6, const float VAR_7, int *VAR_8, int VAR_9) { return get_band_numbits(VAR_0, NULL, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8); }
[ "static float FUNC_0(struct AACEncContext *VAR_0, const float *VAR_1,\nconst float *VAR_2, int VAR_3, int VAR_4,\nint VAR_5, const float VAR_6, const float VAR_7,\nint *VAR_8, int VAR_9)\n{", "return get_band_numbits(VAR_0, NULL, VAR_1, VAR_2, VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8);", "}" ]
[ 1, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ] ]
16,720
static void coroutine_fn stream_run(void *opaque) { StreamBlockJob *s = opaque; BlockDriverState *bs = s->common.bs; BlockDriverState *base = s->base; int64_t sector_num, end; int error = 0; int ret = 0; int n = 0; void *buf; s->common.len = bdrv_getlength(bs); if (s->common.len < 0) { block_job_completed(&s->common, s->common.len); return; } end = s->common.len >> BDRV_SECTOR_BITS; buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE); /* Turn on copy-on-read for the whole block device so that guest read * requests help us make progress. Only do this when copying the entire * backing chain since the copy-on-read operation does not take base into * account. */ if (!base) { bdrv_enable_copy_on_read(bs); } for (sector_num = 0; sector_num < end; sector_num += n) { uint64_t delay_ns = 0; bool copy; wait: /* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. */ block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } ret = bdrv_is_allocated(bs, sector_num, STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n); if (ret == 1) { /* Allocated in the top, no need to copy. */ copy = false; } else if (ret >= 0) { /* Copy if allocated in the intermediate images. Limit to the * known-unallocated area [sector_num, sector_num+n). */ ret = bdrv_is_allocated_above(bs->backing_hd, base, sector_num, n, &n); /* Finish early if end of backing file has been reached */ if (ret == 0 && n == 0) { n = end - sector_num; } copy = (ret == 1); } trace_stream_one_iteration(s, sector_num, n, ret); if (ret >= 0 && copy) { if (s->common.speed) { delay_ns = ratelimit_calculate_delay(&s->limit, n); if (delay_ns > 0) { goto wait; } } ret = stream_populate(bs, sector_num, n, buf); } if (ret < 0) { BlockErrorAction action = block_job_error_action(&s->common, s->common.bs, s->on_error, true, -ret); if (action == BDRV_ACTION_STOP) { n = 0; continue; } if (error == 0) { error = ret; } if (action == BDRV_ACTION_REPORT) { break; } } ret = 0; /* Publish progress */ s->common.offset += n * BDRV_SECTOR_SIZE; } if (!base) { bdrv_disable_copy_on_read(bs); } /* Do not remove the backing file if an error was there but ignored. */ ret = error; if (!block_job_is_cancelled(&s->common) && sector_num == end && ret == 0) { const char *base_id = NULL, *base_fmt = NULL; if (base) { base_id = s->backing_file_id; if (base->drv) { base_fmt = base->drv->format_name; } } ret = bdrv_change_backing_file(bs, base_id, base_fmt); close_unused_images(bs, base, base_id); } qemu_vfree(buf); block_job_completed(&s->common, ret); }
true
qemu
c3e4f43a99549daa6e9b87350922e8339341c2ab
static void coroutine_fn stream_run(void *opaque) { StreamBlockJob *s = opaque; BlockDriverState *bs = s->common.bs; BlockDriverState *base = s->base; int64_t sector_num, end; int error = 0; int ret = 0; int n = 0; void *buf; s->common.len = bdrv_getlength(bs); if (s->common.len < 0) { block_job_completed(&s->common, s->common.len); return; } end = s->common.len >> BDRV_SECTOR_BITS; buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE); if (!base) { bdrv_enable_copy_on_read(bs); } for (sector_num = 0; sector_num < end; sector_num += n) { uint64_t delay_ns = 0; bool copy; wait: block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } ret = bdrv_is_allocated(bs, sector_num, STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n); if (ret == 1) { copy = false; } else if (ret >= 0) { ret = bdrv_is_allocated_above(bs->backing_hd, base, sector_num, n, &n); if (ret == 0 && n == 0) { n = end - sector_num; } copy = (ret == 1); } trace_stream_one_iteration(s, sector_num, n, ret); if (ret >= 0 && copy) { if (s->common.speed) { delay_ns = ratelimit_calculate_delay(&s->limit, n); if (delay_ns > 0) { goto wait; } } ret = stream_populate(bs, sector_num, n, buf); } if (ret < 0) { BlockErrorAction action = block_job_error_action(&s->common, s->common.bs, s->on_error, true, -ret); if (action == BDRV_ACTION_STOP) { n = 0; continue; } if (error == 0) { error = ret; } if (action == BDRV_ACTION_REPORT) { break; } } ret = 0; s->common.offset += n * BDRV_SECTOR_SIZE; } if (!base) { bdrv_disable_copy_on_read(bs); } ret = error; if (!block_job_is_cancelled(&s->common) && sector_num == end && ret == 0) { const char *base_id = NULL, *base_fmt = NULL; if (base) { base_id = s->backing_file_id; if (base->drv) { base_fmt = base->drv->format_name; } } ret = bdrv_change_backing_file(bs, base_id, base_fmt); close_unused_images(bs, base, base_id); } qemu_vfree(buf); block_job_completed(&s->common, ret); }
{ "code": [ " copy = false;", " if (ret >= 0 && copy) {" ], "line_no": [ 93, 123 ] }
static void VAR_0 stream_run(void *opaque) { StreamBlockJob *s = opaque; BlockDriverState *bs = s->common.bs; BlockDriverState *base = s->base; int64_t sector_num, end; int error = 0; int ret = 0; int n = 0; void *buf; s->common.len = bdrv_getlength(bs); if (s->common.len < 0) { block_job_completed(&s->common, s->common.len); return; } end = s->common.len >> BDRV_SECTOR_BITS; buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE); if (!base) { bdrv_enable_copy_on_read(bs); } for (sector_num = 0; sector_num < end; sector_num += n) { uint64_t delay_ns = 0; bool copy; wait: block_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns); if (block_job_is_cancelled(&s->common)) { break; } ret = bdrv_is_allocated(bs, sector_num, STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n); if (ret == 1) { copy = false; } else if (ret >= 0) { ret = bdrv_is_allocated_above(bs->backing_hd, base, sector_num, n, &n); if (ret == 0 && n == 0) { n = end - sector_num; } copy = (ret == 1); } trace_stream_one_iteration(s, sector_num, n, ret); if (ret >= 0 && copy) { if (s->common.speed) { delay_ns = ratelimit_calculate_delay(&s->limit, n); if (delay_ns > 0) { goto wait; } } ret = stream_populate(bs, sector_num, n, buf); } if (ret < 0) { BlockErrorAction action = block_job_error_action(&s->common, s->common.bs, s->on_error, true, -ret); if (action == BDRV_ACTION_STOP) { n = 0; continue; } if (error == 0) { error = ret; } if (action == BDRV_ACTION_REPORT) { break; } } ret = 0; s->common.offset += n * BDRV_SECTOR_SIZE; } if (!base) { bdrv_disable_copy_on_read(bs); } ret = error; if (!block_job_is_cancelled(&s->common) && sector_num == end && ret == 0) { const char *base_id = NULL, *base_fmt = NULL; if (base) { base_id = s->backing_file_id; if (base->drv) { base_fmt = base->drv->format_name; } } ret = bdrv_change_backing_file(bs, base_id, base_fmt); close_unused_images(bs, base, base_id); } qemu_vfree(buf); block_job_completed(&s->common, ret); }
[ "static void VAR_0 stream_run(void *opaque)\n{", "StreamBlockJob *s = opaque;", "BlockDriverState *bs = s->common.bs;", "BlockDriverState *base = s->base;", "int64_t sector_num, end;", "int error = 0;", "int ret = 0;", "int n = 0;", "void *buf;", "s->common.len = bdrv_getlength(bs);", "if (s->common.len < 0) {", "block_job_completed(&s->common, s->common.len);", "return;", "}", "end = s->common.len >> BDRV_SECTOR_BITS;", "buf = qemu_blockalign(bs, STREAM_BUFFER_SIZE);", "if (!base) {", "bdrv_enable_copy_on_read(bs);", "}", "for (sector_num = 0; sector_num < end; sector_num += n) {", "uint64_t delay_ns = 0;", "bool copy;", "wait:\nblock_job_sleep_ns(&s->common, QEMU_CLOCK_REALTIME, delay_ns);", "if (block_job_is_cancelled(&s->common)) {", "break;", "}", "ret = bdrv_is_allocated(bs, sector_num,\nSTREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);", "if (ret == 1) {", "copy = false;", "} else if (ret >= 0) {", "ret = bdrv_is_allocated_above(bs->backing_hd, base,\nsector_num, n, &n);", "if (ret == 0 && n == 0) {", "n = end - sector_num;", "}", "copy = (ret == 1);", "}", "trace_stream_one_iteration(s, sector_num, n, ret);", "if (ret >= 0 && copy) {", "if (s->common.speed) {", "delay_ns = ratelimit_calculate_delay(&s->limit, n);", "if (delay_ns > 0) {", "goto wait;", "}", "}", "ret = stream_populate(bs, sector_num, n, buf);", "}", "if (ret < 0) {", "BlockErrorAction action =\nblock_job_error_action(&s->common, s->common.bs, s->on_error,\ntrue, -ret);", "if (action == BDRV_ACTION_STOP) {", "n = 0;", "continue;", "}", "if (error == 0) {", "error = ret;", "}", "if (action == BDRV_ACTION_REPORT) {", "break;", "}", "}", "ret = 0;", "s->common.offset += n * BDRV_SECTOR_SIZE;", "}", "if (!base) {", "bdrv_disable_copy_on_read(bs);", "}", "ret = error;", "if (!block_job_is_cancelled(&s->common) && sector_num == end && ret == 0) {", "const char *base_id = NULL, *base_fmt = NULL;", "if (base) {", "base_id = s->backing_file_id;", "if (base->drv) {", "base_fmt = base->drv->format_name;", "}", "}", "ret = bdrv_change_backing_file(bs, base_id, base_fmt);", "close_unused_images(bs, base, base_id);", "}", "qemu_vfree(buf);", "block_job_completed(&s->common, ret);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 67, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85, 87 ], [ 89 ], [ 93 ], [ 95 ], [ 101, 103 ], [ 109 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143, 145, 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 177 ], [ 179 ], [ 183 ], [ 185 ], [ 187 ], [ 193 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 221 ], [ 223 ], [ 225 ] ]
16,722
PCIBus *pci_apb_init(hwaddr special_base, hwaddr mem_base, qemu_irq *ivec_irqs, PCIBus **busA, PCIBus **busB, qemu_irq **pbm_irqs) { DeviceState *dev; SysBusDevice *s; PCIHostState *phb; APBState *d; IOMMUState *is; PCIDevice *pci_dev; PCIBridge *br; /* Ultrasparc PBM main bus */ dev = qdev_create(NULL, TYPE_APB); d = APB_DEVICE(dev); phb = PCI_HOST_BRIDGE(dev); phb->bus = pci_register_bus(DEVICE(phb), "pci", pci_apb_set_irq, pci_pbm_map_irq, d, &d->pci_mmio, get_system_io(), 0, 32, TYPE_PCI_BUS); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); /* apb_config */ sysbus_mmio_map(s, 0, special_base); /* PCI configuration space */ sysbus_mmio_map(s, 1, special_base + 0x1000000ULL); /* pci_ioport */ sysbus_mmio_map(s, 2, special_base + 0x2000000ULL); memory_region_init(&d->pci_mmio, OBJECT(s), "pci-mmio", 0x100000000ULL); memory_region_add_subregion(get_system_memory(), mem_base, &d->pci_mmio); *pbm_irqs = d->pbm_irqs; d->ivec_irqs = ivec_irqs; pci_create_simple(phb->bus, 0, "pbm-pci"); /* APB IOMMU */ is = &d->iommu; memset(is, 0, sizeof(IOMMUState)); memory_region_init_iommu(&is->iommu, sizeof(is->iommu), TYPE_APB_IOMMU_MEMORY_REGION, OBJECT(dev), "iommu-apb", UINT64_MAX); address_space_init(&is->iommu_as, MEMORY_REGION(&is->iommu), "pbm-as"); pci_setup_iommu(phb->bus, pbm_pci_dma_iommu, is); /* APB secondary busses */ pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciB", pci_apb_map_irq); qdev_init_nofail(&pci_dev->qdev); *busB = pci_bridge_get_sec_bus(br); pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciA", pci_apb_map_irq); qdev_prop_set_bit(DEVICE(pci_dev), "busA", true); qdev_init_nofail(&pci_dev->qdev); *busA = pci_bridge_get_sec_bus(br); return phb->bus; }
false
qemu
6864fa38972081833f79b39df74b9c08cc94f6cc
PCIBus *pci_apb_init(hwaddr special_base, hwaddr mem_base, qemu_irq *ivec_irqs, PCIBus **busA, PCIBus **busB, qemu_irq **pbm_irqs) { DeviceState *dev; SysBusDevice *s; PCIHostState *phb; APBState *d; IOMMUState *is; PCIDevice *pci_dev; PCIBridge *br; dev = qdev_create(NULL, TYPE_APB); d = APB_DEVICE(dev); phb = PCI_HOST_BRIDGE(dev); phb->bus = pci_register_bus(DEVICE(phb), "pci", pci_apb_set_irq, pci_pbm_map_irq, d, &d->pci_mmio, get_system_io(), 0, 32, TYPE_PCI_BUS); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, special_base); sysbus_mmio_map(s, 1, special_base + 0x1000000ULL); sysbus_mmio_map(s, 2, special_base + 0x2000000ULL); memory_region_init(&d->pci_mmio, OBJECT(s), "pci-mmio", 0x100000000ULL); memory_region_add_subregion(get_system_memory(), mem_base, &d->pci_mmio); *pbm_irqs = d->pbm_irqs; d->ivec_irqs = ivec_irqs; pci_create_simple(phb->bus, 0, "pbm-pci"); is = &d->iommu; memset(is, 0, sizeof(IOMMUState)); memory_region_init_iommu(&is->iommu, sizeof(is->iommu), TYPE_APB_IOMMU_MEMORY_REGION, OBJECT(dev), "iommu-apb", UINT64_MAX); address_space_init(&is->iommu_as, MEMORY_REGION(&is->iommu), "pbm-as"); pci_setup_iommu(phb->bus, pbm_pci_dma_iommu, is); pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciB", pci_apb_map_irq); qdev_init_nofail(&pci_dev->qdev); *busB = pci_bridge_get_sec_bus(br); pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciA", pci_apb_map_irq); qdev_prop_set_bit(DEVICE(pci_dev), "busA", true); qdev_init_nofail(&pci_dev->qdev); *busA = pci_bridge_get_sec_bus(br); return phb->bus; }
{ "code": [], "line_no": [] }
PCIBus *FUNC_0(hwaddr special_base, hwaddr mem_base, qemu_irq *ivec_irqs, PCIBus **busA, PCIBus **busB, qemu_irq **pbm_irqs) { DeviceState *dev; SysBusDevice *s; PCIHostState *phb; APBState *d; IOMMUState *is; PCIDevice *pci_dev; PCIBridge *br; dev = qdev_create(NULL, TYPE_APB); d = APB_DEVICE(dev); phb = PCI_HOST_BRIDGE(dev); phb->bus = pci_register_bus(DEVICE(phb), "pci", pci_apb_set_irq, pci_pbm_map_irq, d, &d->pci_mmio, get_system_io(), 0, 32, TYPE_PCI_BUS); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); sysbus_mmio_map(s, 0, special_base); sysbus_mmio_map(s, 1, special_base + 0x1000000ULL); sysbus_mmio_map(s, 2, special_base + 0x2000000ULL); memory_region_init(&d->pci_mmio, OBJECT(s), "pci-mmio", 0x100000000ULL); memory_region_add_subregion(get_system_memory(), mem_base, &d->pci_mmio); *pbm_irqs = d->pbm_irqs; d->ivec_irqs = ivec_irqs; pci_create_simple(phb->bus, 0, "pbm-pci"); is = &d->iommu; memset(is, 0, sizeof(IOMMUState)); memory_region_init_iommu(&is->iommu, sizeof(is->iommu), TYPE_APB_IOMMU_MEMORY_REGION, OBJECT(dev), "iommu-apb", UINT64_MAX); address_space_init(&is->iommu_as, MEMORY_REGION(&is->iommu), "pbm-as"); pci_setup_iommu(phb->bus, pbm_pci_dma_iommu, is); pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciB", pci_apb_map_irq); qdev_init_nofail(&pci_dev->qdev); *busB = pci_bridge_get_sec_bus(br); pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true, TYPE_PBM_PCI_BRIDGE); br = PCI_BRIDGE(pci_dev); pci_bridge_map_irq(br, "pciA", pci_apb_map_irq); qdev_prop_set_bit(DEVICE(pci_dev), "busA", true); qdev_init_nofail(&pci_dev->qdev); *busA = pci_bridge_get_sec_bus(br); return phb->bus; }
[ "PCIBus *FUNC_0(hwaddr special_base,\nhwaddr mem_base,\nqemu_irq *ivec_irqs, PCIBus **busA, PCIBus **busB,\nqemu_irq **pbm_irqs)\n{", "DeviceState *dev;", "SysBusDevice *s;", "PCIHostState *phb;", "APBState *d;", "IOMMUState *is;", "PCIDevice *pci_dev;", "PCIBridge *br;", "dev = qdev_create(NULL, TYPE_APB);", "d = APB_DEVICE(dev);", "phb = PCI_HOST_BRIDGE(dev);", "phb->bus = pci_register_bus(DEVICE(phb), \"pci\",\npci_apb_set_irq, pci_pbm_map_irq, d,\n&d->pci_mmio,\nget_system_io(),\n0, 32, TYPE_PCI_BUS);", "qdev_init_nofail(dev);", "s = SYS_BUS_DEVICE(dev);", "sysbus_mmio_map(s, 0, special_base);", "sysbus_mmio_map(s, 1, special_base + 0x1000000ULL);", "sysbus_mmio_map(s, 2, special_base + 0x2000000ULL);", "memory_region_init(&d->pci_mmio, OBJECT(s), \"pci-mmio\", 0x100000000ULL);", "memory_region_add_subregion(get_system_memory(), mem_base, &d->pci_mmio);", "*pbm_irqs = d->pbm_irqs;", "d->ivec_irqs = ivec_irqs;", "pci_create_simple(phb->bus, 0, \"pbm-pci\");", "is = &d->iommu;", "memset(is, 0, sizeof(IOMMUState));", "memory_region_init_iommu(&is->iommu, sizeof(is->iommu),\nTYPE_APB_IOMMU_MEMORY_REGION, OBJECT(dev),\n\"iommu-apb\", UINT64_MAX);", "address_space_init(&is->iommu_as, MEMORY_REGION(&is->iommu), \"pbm-as\");", "pci_setup_iommu(phb->bus, pbm_pci_dma_iommu, is);", "pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 0), true,\nTYPE_PBM_PCI_BRIDGE);", "br = PCI_BRIDGE(pci_dev);", "pci_bridge_map_irq(br, \"pciB\", pci_apb_map_irq);", "qdev_init_nofail(&pci_dev->qdev);", "*busB = pci_bridge_get_sec_bus(br);", "pci_dev = pci_create_multifunction(phb->bus, PCI_DEVFN(1, 1), true,\nTYPE_PBM_PCI_BRIDGE);", "br = PCI_BRIDGE(pci_dev);", "pci_bridge_map_irq(br, \"pciA\", pci_apb_map_irq);", "qdev_prop_set_bit(DEVICE(pci_dev), \"busA\", true);", "qdev_init_nofail(&pci_dev->qdev);", "*busA = pci_bridge_get_sec_bus(br);", "return phb->bus;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 35, 37, 39, 41, 43 ], [ 45 ], [ 47 ], [ 51 ], [ 55 ], [ 59 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 75 ], [ 81 ], [ 83 ], [ 87, 89, 91 ], [ 93 ], [ 95 ], [ 101, 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ] ]
16,725
void register_module_init(void (*fn)(void), module_init_type type) { ModuleEntry *e; ModuleTypeList *l; e = qemu_mallocz(sizeof(*e)); e->init = fn; l = find_type(type); TAILQ_INSERT_TAIL(l, e, node); }
false
qemu
72cf2d4f0e181d0d3a3122e04129c58a95da713e
void register_module_init(void (*fn)(void), module_init_type type) { ModuleEntry *e; ModuleTypeList *l; e = qemu_mallocz(sizeof(*e)); e->init = fn; l = find_type(type); TAILQ_INSERT_TAIL(l, e, node); }
{ "code": [], "line_no": [] }
void FUNC_0(void (*VAR_0)(void), module_init_type VAR_1) { ModuleEntry *e; ModuleTypeList *l; e = qemu_mallocz(sizeof(*e)); e->init = VAR_0; l = find_type(VAR_1); TAILQ_INSERT_TAIL(l, e, node); }
[ "void FUNC_0(void (*VAR_0)(void), module_init_type VAR_1)\n{", "ModuleEntry *e;", "ModuleTypeList *l;", "e = qemu_mallocz(sizeof(*e));", "e->init = VAR_0;", "l = find_type(VAR_1);", "TAILQ_INSERT_TAIL(l, e, node);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ] ]
16,726
static void spitz_common_init(ram_addr_t ram_size, int vga_ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum spitz_model_e model, int arm_id) { struct pxa2xx_state_s *cpu; struct scoop_info_s *scp0, *scp1 = NULL; if (!cpu_model) cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0"; /* Setup CPU & memory */ if (ram_size < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) { fprintf(stderr, "This platform requires %i bytes of memory\n", SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE); exit(1); } cpu = pxa270_init(spitz_binfo.ram_size, cpu_model); sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M); cpu_register_physical_memory(0, SPITZ_ROM, qemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM); /* Setup peripherals */ spitz_keyboard_register(cpu); spitz_ssp_attach(cpu); scp0 = scoop_init(cpu, 0, 0x10800000); if (model != akita) { scp1 = scoop_init(cpu, 1, 0x08800040); } spitz_scoop_gpio_setup(cpu, scp0, scp1); spitz_gpio_setup(cpu, (model == akita) ? 1 : 2); spitz_i2c_setup(cpu); if (model == akita) spitz_akita_i2c_setup(cpu); if (model == terrier) /* A 6.0 GB microdrive is permanently sitting in CF slot 1. */ spitz_microdrive_attach(cpu, 1); else if (model != akita) /* A 4.0 GB microdrive is permanently sitting in CF slot 0. */ spitz_microdrive_attach(cpu, 0); /* Setup initial (reset) machine state */ cpu->env->regs[15] = spitz_binfo.loader_start; spitz_binfo.kernel_filename = kernel_filename; spitz_binfo.kernel_cmdline = kernel_cmdline; spitz_binfo.initrd_filename = initrd_filename; spitz_binfo.board_id = arm_id; arm_load_kernel(cpu->env, &spitz_binfo); sl_bootparam_write(SL_PXA_PARAM_BASE); }
false
qemu
a0b753dfd3920df146a5f4d05e442e3c522900c7
static void spitz_common_init(ram_addr_t ram_size, int vga_ram_size, const char *kernel_filename, const char *kernel_cmdline, const char *initrd_filename, const char *cpu_model, enum spitz_model_e model, int arm_id) { struct pxa2xx_state_s *cpu; struct scoop_info_s *scp0, *scp1 = NULL; if (!cpu_model) cpu_model = (model == terrier) ? "pxa270-c5" : "pxa270-c0"; if (ram_size < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) { fprintf(stderr, "This platform requires %i bytes of memory\n", SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE); exit(1); } cpu = pxa270_init(spitz_binfo.ram_size, cpu_model); sl_flash_register(cpu, (model == spitz) ? FLASH_128M : FLASH_1024M); cpu_register_physical_memory(0, SPITZ_ROM, qemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM); spitz_keyboard_register(cpu); spitz_ssp_attach(cpu); scp0 = scoop_init(cpu, 0, 0x10800000); if (model != akita) { scp1 = scoop_init(cpu, 1, 0x08800040); } spitz_scoop_gpio_setup(cpu, scp0, scp1); spitz_gpio_setup(cpu, (model == akita) ? 1 : 2); spitz_i2c_setup(cpu); if (model == akita) spitz_akita_i2c_setup(cpu); if (model == terrier) spitz_microdrive_attach(cpu, 1); else if (model != akita) spitz_microdrive_attach(cpu, 0); cpu->env->regs[15] = spitz_binfo.loader_start; spitz_binfo.kernel_filename = kernel_filename; spitz_binfo.kernel_cmdline = kernel_cmdline; spitz_binfo.initrd_filename = initrd_filename; spitz_binfo.board_id = arm_id; arm_load_kernel(cpu->env, &spitz_binfo); sl_bootparam_write(SL_PXA_PARAM_BASE); }
{ "code": [], "line_no": [] }
static void FUNC_0(ram_addr_t VAR_0, int VAR_1, const char *VAR_2, const char *VAR_3, const char *VAR_4, const char *VAR_5, enum spitz_model_e VAR_6, int VAR_7) { struct pxa2xx_state_s *VAR_8; struct scoop_info_s *VAR_9, *VAR_10 = NULL; if (!VAR_5) VAR_5 = (VAR_6 == terrier) ? "pxa270-c5" : "pxa270-c0"; if (VAR_0 < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) { fprintf(stderr, "This platform requires %i bytes of memory\n", SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE); exit(1); } VAR_8 = pxa270_init(spitz_binfo.VAR_0, VAR_5); sl_flash_register(VAR_8, (VAR_6 == spitz) ? FLASH_128M : FLASH_1024M); cpu_register_physical_memory(0, SPITZ_ROM, qemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM); spitz_keyboard_register(VAR_8); spitz_ssp_attach(VAR_8); VAR_9 = scoop_init(VAR_8, 0, 0x10800000); if (VAR_6 != akita) { VAR_10 = scoop_init(VAR_8, 1, 0x08800040); } spitz_scoop_gpio_setup(VAR_8, VAR_9, VAR_10); spitz_gpio_setup(VAR_8, (VAR_6 == akita) ? 1 : 2); spitz_i2c_setup(VAR_8); if (VAR_6 == akita) spitz_akita_i2c_setup(VAR_8); if (VAR_6 == terrier) spitz_microdrive_attach(VAR_8, 1); else if (VAR_6 != akita) spitz_microdrive_attach(VAR_8, 0); VAR_8->env->regs[15] = spitz_binfo.loader_start; spitz_binfo.VAR_2 = VAR_2; spitz_binfo.VAR_3 = VAR_3; spitz_binfo.VAR_4 = VAR_4; spitz_binfo.board_id = VAR_7; arm_load_kernel(VAR_8->env, &spitz_binfo); sl_bootparam_write(SL_PXA_PARAM_BASE); }
[ "static void FUNC_0(ram_addr_t VAR_0, int VAR_1,\nconst char *VAR_2,\nconst char *VAR_3, const char *VAR_4,\nconst char *VAR_5, enum spitz_model_e VAR_6, int VAR_7)\n{", "struct pxa2xx_state_s *VAR_8;", "struct scoop_info_s *VAR_9, *VAR_10 = NULL;", "if (!VAR_5)\nVAR_5 = (VAR_6 == terrier) ? \"pxa270-c5\" : \"pxa270-c0\";", "if (VAR_0 < SPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE) {", "fprintf(stderr, \"This platform requires %i bytes of memory\\n\",\nSPITZ_RAM + SPITZ_ROM + PXA2XX_INTERNAL_SIZE);", "exit(1);", "}", "VAR_8 = pxa270_init(spitz_binfo.VAR_0, VAR_5);", "sl_flash_register(VAR_8, (VAR_6 == spitz) ? FLASH_128M : FLASH_1024M);", "cpu_register_physical_memory(0, SPITZ_ROM,\nqemu_ram_alloc(SPITZ_ROM) | IO_MEM_ROM);", "spitz_keyboard_register(VAR_8);", "spitz_ssp_attach(VAR_8);", "VAR_9 = scoop_init(VAR_8, 0, 0x10800000);", "if (VAR_6 != akita) {", "VAR_10 = scoop_init(VAR_8, 1, 0x08800040);", "}", "spitz_scoop_gpio_setup(VAR_8, VAR_9, VAR_10);", "spitz_gpio_setup(VAR_8, (VAR_6 == akita) ? 1 : 2);", "spitz_i2c_setup(VAR_8);", "if (VAR_6 == akita)\nspitz_akita_i2c_setup(VAR_8);", "if (VAR_6 == terrier)\nspitz_microdrive_attach(VAR_8, 1);", "else if (VAR_6 != akita)\nspitz_microdrive_attach(VAR_8, 0);", "VAR_8->env->regs[15] = spitz_binfo.loader_start;", "spitz_binfo.VAR_2 = VAR_2;", "spitz_binfo.VAR_3 = VAR_3;", "spitz_binfo.VAR_4 = VAR_4;", "spitz_binfo.board_id = VAR_7;", "arm_load_kernel(VAR_8->env, &spitz_binfo);", "sl_bootparam_write(SL_PXA_PARAM_BASE);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 17, 19 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 43, 45 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 73 ], [ 77 ], [ 81, 83 ], [ 87, 91 ], [ 93, 97 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ] ]
16,729
uint32_t cpu_inl(pio_addr_t addr) { uint32_t val; val = ioport_read(2, addr); trace_cpu_in(addr, val); LOG_IOPORT("inl : %04"FMT_pioaddr" %08"PRIx32"\n", addr, val); return val; }
false
qemu
b40acf99bef69fa8ab0f9092ff162fde945eec12
uint32_t cpu_inl(pio_addr_t addr) { uint32_t val; val = ioport_read(2, addr); trace_cpu_in(addr, val); LOG_IOPORT("inl : %04"FMT_pioaddr" %08"PRIx32"\n", addr, val); return val; }
{ "code": [], "line_no": [] }
uint32_t FUNC_0(pio_addr_t addr) { uint32_t val; val = ioport_read(2, addr); trace_cpu_in(addr, val); LOG_IOPORT("inl : %04"FMT_pioaddr" %08"PRIx32"\n", addr, val); return val; }
[ "uint32_t FUNC_0(pio_addr_t addr)\n{", "uint32_t val;", "val = ioport_read(2, addr);", "trace_cpu_in(addr, val);", "LOG_IOPORT(\"inl : %04\"FMT_pioaddr\" %08\"PRIx32\"\\n\", addr, val);", "return val;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
16,730
static int nbd_co_request(BlockDriverState *bs, NBDRequest *request, QEMUIOVector *qiov) { NBDClientSession *client = nbd_get_client_session(bs); int ret; assert(!qiov || request->type == NBD_CMD_WRITE || request->type == NBD_CMD_READ); ret = nbd_co_send_request(bs, request, request->type == NBD_CMD_WRITE ? qiov : NULL); if (ret < 0) { return ret; } return nbd_co_receive_reply(client, request, request->type == NBD_CMD_READ ? qiov : NULL); }
false
qemu
4bfe4478d17679464a2aaa91ed703522ed9af8a0
static int nbd_co_request(BlockDriverState *bs, NBDRequest *request, QEMUIOVector *qiov) { NBDClientSession *client = nbd_get_client_session(bs); int ret; assert(!qiov || request->type == NBD_CMD_WRITE || request->type == NBD_CMD_READ); ret = nbd_co_send_request(bs, request, request->type == NBD_CMD_WRITE ? qiov : NULL); if (ret < 0) { return ret; } return nbd_co_receive_reply(client, request, request->type == NBD_CMD_READ ? qiov : NULL); }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, NBDRequest *VAR_1, QEMUIOVector *VAR_2) { NBDClientSession *client = nbd_get_client_session(VAR_0); int VAR_3; assert(!VAR_2 || VAR_1->type == NBD_CMD_WRITE || VAR_1->type == NBD_CMD_READ); VAR_3 = nbd_co_send_request(VAR_0, VAR_1, VAR_1->type == NBD_CMD_WRITE ? VAR_2 : NULL); if (VAR_3 < 0) { return VAR_3; } return nbd_co_receive_reply(client, VAR_1, VAR_1->type == NBD_CMD_READ ? VAR_2 : NULL); }
[ "static int FUNC_0(BlockDriverState *VAR_0,\nNBDRequest *VAR_1,\nQEMUIOVector *VAR_2)\n{", "NBDClientSession *client = nbd_get_client_session(VAR_0);", "int VAR_3;", "assert(!VAR_2 || VAR_1->type == NBD_CMD_WRITE ||\nVAR_1->type == NBD_CMD_READ);", "VAR_3 = nbd_co_send_request(VAR_0, VAR_1,\nVAR_1->type == NBD_CMD_WRITE ? VAR_2 : NULL);", "if (VAR_3 < 0) {", "return VAR_3;", "}", "return nbd_co_receive_reply(client, VAR_1,\nVAR_1->type == NBD_CMD_READ ? VAR_2 : NULL);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 15, 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 35 ] ]
16,732
static int posix_aio_process_queue(void *opaque) { PosixAioState *s = opaque; struct qemu_paiocb *acb, **pacb; int ret; int result = 0; int async_context_id = get_async_context_id(); for(;;) { pacb = &s->first_aio; for(;;) { acb = *pacb; if (!acb) return result; /* we're only interested in requests in the right context */ if (acb->async_context_id != async_context_id) { pacb = &acb->next; continue; } ret = qemu_paio_error(acb); if (ret == ECANCELED) { /* remove the request */ *pacb = acb->next; qemu_aio_release(acb); result = 1; } else if (ret != EINPROGRESS) { /* end of aio */ if (ret == 0) { ret = qemu_paio_return(acb); if (ret == acb->aio_nbytes) ret = 0; else ret = -EINVAL; } else { ret = -ret; } trace_paio_complete(acb, acb->common.opaque, ret); /* remove the request */ *pacb = acb->next; /* call the callback */ acb->common.cb(acb->common.opaque, ret); qemu_aio_release(acb); result = 1; break; } else { pacb = &acb->next; } } } return result; }
false
qemu
384acbf46b70edf0d2c1648aa1a92a90bcf7057d
static int posix_aio_process_queue(void *opaque) { PosixAioState *s = opaque; struct qemu_paiocb *acb, **pacb; int ret; int result = 0; int async_context_id = get_async_context_id(); for(;;) { pacb = &s->first_aio; for(;;) { acb = *pacb; if (!acb) return result; if (acb->async_context_id != async_context_id) { pacb = &acb->next; continue; } ret = qemu_paio_error(acb); if (ret == ECANCELED) { *pacb = acb->next; qemu_aio_release(acb); result = 1; } else if (ret != EINPROGRESS) { if (ret == 0) { ret = qemu_paio_return(acb); if (ret == acb->aio_nbytes) ret = 0; else ret = -EINVAL; } else { ret = -ret; } trace_paio_complete(acb, acb->common.opaque, ret); *pacb = acb->next; acb->common.cb(acb->common.opaque, ret); qemu_aio_release(acb); result = 1; break; } else { pacb = &acb->next; } } } return result; }
{ "code": [], "line_no": [] }
static int FUNC_0(void *VAR_0) { PosixAioState *s = VAR_0; struct qemu_paiocb *VAR_1, **VAR_2; int VAR_3; int VAR_4 = 0; int VAR_5 = get_async_context_id(); for(;;) { VAR_2 = &s->first_aio; for(;;) { VAR_1 = *VAR_2; if (!VAR_1) return VAR_4; if (VAR_1->VAR_5 != VAR_5) { VAR_2 = &VAR_1->next; continue; } VAR_3 = qemu_paio_error(VAR_1); if (VAR_3 == ECANCELED) { *VAR_2 = VAR_1->next; qemu_aio_release(VAR_1); VAR_4 = 1; } else if (VAR_3 != EINPROGRESS) { if (VAR_3 == 0) { VAR_3 = qemu_paio_return(VAR_1); if (VAR_3 == VAR_1->aio_nbytes) VAR_3 = 0; else VAR_3 = -EINVAL; } else { VAR_3 = -VAR_3; } trace_paio_complete(VAR_1, VAR_1->common.VAR_0, VAR_3); *VAR_2 = VAR_1->next; VAR_1->common.cb(VAR_1->common.VAR_0, VAR_3); qemu_aio_release(VAR_1); VAR_4 = 1; break; } else { VAR_2 = &VAR_1->next; } } } return VAR_4; }
[ "static int FUNC_0(void *VAR_0)\n{", "PosixAioState *s = VAR_0;", "struct qemu_paiocb *VAR_1, **VAR_2;", "int VAR_3;", "int VAR_4 = 0;", "int VAR_5 = get_async_context_id();", "for(;;) {", "VAR_2 = &s->first_aio;", "for(;;) {", "VAR_1 = *VAR_2;", "if (!VAR_1)\nreturn VAR_4;", "if (VAR_1->VAR_5 != VAR_5) {", "VAR_2 = &VAR_1->next;", "continue;", "}", "VAR_3 = qemu_paio_error(VAR_1);", "if (VAR_3 == ECANCELED) {", "*VAR_2 = VAR_1->next;", "qemu_aio_release(VAR_1);", "VAR_4 = 1;", "} else if (VAR_3 != EINPROGRESS) {", "if (VAR_3 == 0) {", "VAR_3 = qemu_paio_return(VAR_1);", "if (VAR_3 == VAR_1->aio_nbytes)\nVAR_3 = 0;", "else\nVAR_3 = -EINVAL;", "} else {", "VAR_3 = -VAR_3;", "}", "trace_paio_complete(VAR_1, VAR_1->common.VAR_0, VAR_3);", "*VAR_2 = VAR_1->next;", "VAR_1->common.cb(VAR_1->common.VAR_0, VAR_3);", "qemu_aio_release(VAR_1);", "VAR_4 = 1;", "break;", "} else {", "VAR_2 = &VAR_1->next;", "}", "}", "}", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63, 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ] ]
16,733
static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr) { return cpu_inb(addr & IOPORTS_MASK); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint32_t isa_mmio_readb (void *opaque, target_phys_addr_t addr) { return cpu_inb(addr & IOPORTS_MASK); }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr) { return cpu_inb(addr & IOPORTS_MASK); }
[ "static uint32_t FUNC_0 (void *opaque, target_phys_addr_t addr)\n{", "return cpu_inb(addr & IOPORTS_MASK);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
16,734
static int vpc_create(const char *filename, int64_t total_sectors, const char *backing_file, int flags) { uint8_t buf[1024]; struct vhd_footer* footer = (struct vhd_footer*) buf; struct vhd_dyndisk_header* dyndisk_header = (struct vhd_dyndisk_header*) buf; int fd, i; uint16_t cyls; uint8_t heads; uint8_t secs_per_cyl; size_t block_size, num_bat_entries; if (backing_file != NULL) return -ENOTSUP; fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; // Calculate matching total_size and geometry calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl); total_sectors = (int64_t) cyls * heads * secs_per_cyl; // Prepare the Hard Disk Footer memset(buf, 0, 1024); strncpy(footer->creator, "conectix", 8); // TODO Check if "qemu" creator_app is ok for VPC strncpy(footer->creator_app, "qemu", 4); strncpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); footer->data_offset = be64_to_cpu(HEADER_SIZE); footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); // Version of Virtual PC 2007 footer->major = be16_to_cpu(0x0005); footer->minor =be16_to_cpu(0x0003); footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(VHD_DYNAMIC); // TODO uuid is missing footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); // Write the footer (twice: at the beginning and at the end) block_size = 0x200000; num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512); if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) return -EIO; if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; // Write the initial BAT if (lseek(fd, 3 * 512, SEEK_SET) < 0) return -EIO; memset(buf, 0xFF, 512); for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) if (write(fd, buf, 512) != 512) return -EIO; // Prepare the Dynamic Disk Header memset(buf, 0, 1024); strncpy(dyndisk_header->magic, "cxsparse", 8); dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF); dyndisk_header->table_offset = be64_to_cpu(3 * 512); dyndisk_header->version = be32_to_cpu(0x00010000); dyndisk_header->block_size = be32_to_cpu(block_size); dyndisk_header->max_table_entries = be32_to_cpu(num_bat_entries); dyndisk_header->checksum = be32_to_cpu(vpc_checksum(buf, 1024)); // Write the header if (lseek(fd, 512, SEEK_SET) < 0) return -EIO; if (write(fd, buf, 1024) != 1024) return -EIO; close(fd); return 0; }
false
qemu
6e9ea0c0629fe25723494a19498bedf4b781cbfa
static int vpc_create(const char *filename, int64_t total_sectors, const char *backing_file, int flags) { uint8_t buf[1024]; struct vhd_footer* footer = (struct vhd_footer*) buf; struct vhd_dyndisk_header* dyndisk_header = (struct vhd_dyndisk_header*) buf; int fd, i; uint16_t cyls; uint8_t heads; uint8_t secs_per_cyl; size_t block_size, num_bat_entries; if (backing_file != NULL) return -ENOTSUP; fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (fd < 0) return -EIO; calculate_geometry(total_sectors, &cyls, &heads, &secs_per_cyl); total_sectors = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); strncpy(footer->creator, "conectix", 8); strncpy(footer->creator_app, "qemu", 4); strncpy(footer->creator_os, "Wi2k", 4); footer->features = be32_to_cpu(0x02); footer->version = be32_to_cpu(0x00010000); footer->data_offset = be64_to_cpu(HEADER_SIZE); footer->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); footer->major = be16_to_cpu(0x0005); footer->minor =be16_to_cpu(0x0003); footer->orig_size = be64_to_cpu(total_sectors * 512); footer->size = be64_to_cpu(total_sectors * 512); footer->cyls = be16_to_cpu(cyls); footer->heads = heads; footer->secs_per_cyl = secs_per_cyl; footer->type = be32_to_cpu(VHD_DYNAMIC); footer->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); block_size = 0x200000; num_bat_entries = (total_sectors + block_size / 512) / (block_size / 512); if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) return -EIO; if (write(fd, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(fd, 3 * 512, SEEK_SET) < 0) return -EIO; memset(buf, 0xFF, 512); for (i = 0; i < (num_bat_entries * 4 + 511) / 512; i++) if (write(fd, buf, 512) != 512) return -EIO; memset(buf, 0, 1024); strncpy(dyndisk_header->magic, "cxsparse", 8); dyndisk_header->data_offset = be64_to_cpu(0xFFFFFFFF); dyndisk_header->table_offset = be64_to_cpu(3 * 512); dyndisk_header->version = be32_to_cpu(0x00010000); dyndisk_header->block_size = be32_to_cpu(block_size); dyndisk_header->max_table_entries = be32_to_cpu(num_bat_entries); dyndisk_header->checksum = be32_to_cpu(vpc_checksum(buf, 1024)); if (lseek(fd, 512, SEEK_SET) < 0) return -EIO; if (write(fd, buf, 1024) != 1024) return -EIO; close(fd); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(const char *VAR_0, int64_t VAR_1, const char *VAR_2, int VAR_3) { uint8_t buf[1024]; struct vhd_footer* VAR_4 = (struct vhd_footer*) buf; struct vhd_dyndisk_header* VAR_5 = (struct vhd_dyndisk_header*) buf; int VAR_6, VAR_7; uint16_t cyls; uint8_t heads; uint8_t secs_per_cyl; size_t block_size, num_bat_entries; if (VAR_2 != NULL) return -ENOTSUP; VAR_6 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644); if (VAR_6 < 0) return -EIO; calculate_geometry(VAR_1, &cyls, &heads, &secs_per_cyl); VAR_1 = (int64_t) cyls * heads * secs_per_cyl; memset(buf, 0, 1024); strncpy(VAR_4->creator, "conectix", 8); strncpy(VAR_4->creator_app, "qemu", 4); strncpy(VAR_4->creator_os, "Wi2k", 4); VAR_4->features = be32_to_cpu(0x02); VAR_4->version = be32_to_cpu(0x00010000); VAR_4->data_offset = be64_to_cpu(HEADER_SIZE); VAR_4->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE); VAR_4->major = be16_to_cpu(0x0005); VAR_4->minor =be16_to_cpu(0x0003); VAR_4->orig_size = be64_to_cpu(VAR_1 * 512); VAR_4->size = be64_to_cpu(VAR_1 * 512); VAR_4->cyls = be16_to_cpu(cyls); VAR_4->heads = heads; VAR_4->secs_per_cyl = secs_per_cyl; VAR_4->type = be32_to_cpu(VHD_DYNAMIC); VAR_4->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE)); block_size = 0x200000; num_bat_entries = (VAR_1 + block_size / 512) / (block_size / 512); if (write(VAR_6, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(VAR_6, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0) return -EIO; if (write(VAR_6, buf, HEADER_SIZE) != HEADER_SIZE) return -EIO; if (lseek(VAR_6, 3 * 512, SEEK_SET) < 0) return -EIO; memset(buf, 0xFF, 512); for (VAR_7 = 0; VAR_7 < (num_bat_entries * 4 + 511) / 512; VAR_7++) if (write(VAR_6, buf, 512) != 512) return -EIO; memset(buf, 0, 1024); strncpy(VAR_5->magic, "cxsparse", 8); VAR_5->data_offset = be64_to_cpu(0xFFFFFFFF); VAR_5->table_offset = be64_to_cpu(3 * 512); VAR_5->version = be32_to_cpu(0x00010000); VAR_5->block_size = be32_to_cpu(block_size); VAR_5->max_table_entries = be32_to_cpu(num_bat_entries); VAR_5->checksum = be32_to_cpu(vpc_checksum(buf, 1024)); if (lseek(VAR_6, 512, SEEK_SET) < 0) return -EIO; if (write(VAR_6, buf, 1024) != 1024) return -EIO; close(VAR_6); return 0; }
[ "static int FUNC_0(const char *VAR_0, int64_t VAR_1,\nconst char *VAR_2, int VAR_3)\n{", "uint8_t buf[1024];", "struct vhd_footer* VAR_4 = (struct vhd_footer*) buf;", "struct vhd_dyndisk_header* VAR_5 =\n(struct vhd_dyndisk_header*) buf;", "int VAR_6, VAR_7;", "uint16_t cyls;", "uint8_t heads;", "uint8_t secs_per_cyl;", "size_t block_size, num_bat_entries;", "if (VAR_2 != NULL)\nreturn -ENOTSUP;", "VAR_6 = open(VAR_0, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);", "if (VAR_6 < 0)\nreturn -EIO;", "calculate_geometry(VAR_1, &cyls, &heads, &secs_per_cyl);", "VAR_1 = (int64_t) cyls * heads * secs_per_cyl;", "memset(buf, 0, 1024);", "strncpy(VAR_4->creator, \"conectix\", 8);", "strncpy(VAR_4->creator_app, \"qemu\", 4);", "strncpy(VAR_4->creator_os, \"Wi2k\", 4);", "VAR_4->features = be32_to_cpu(0x02);", "VAR_4->version = be32_to_cpu(0x00010000);", "VAR_4->data_offset = be64_to_cpu(HEADER_SIZE);", "VAR_4->timestamp = be32_to_cpu(time(NULL) - VHD_TIMESTAMP_BASE);", "VAR_4->major = be16_to_cpu(0x0005);", "VAR_4->minor =be16_to_cpu(0x0003);", "VAR_4->orig_size = be64_to_cpu(VAR_1 * 512);", "VAR_4->size = be64_to_cpu(VAR_1 * 512);", "VAR_4->cyls = be16_to_cpu(cyls);", "VAR_4->heads = heads;", "VAR_4->secs_per_cyl = secs_per_cyl;", "VAR_4->type = be32_to_cpu(VHD_DYNAMIC);", "VAR_4->checksum = be32_to_cpu(vpc_checksum(buf, HEADER_SIZE));", "block_size = 0x200000;", "num_bat_entries = (VAR_1 + block_size / 512) / (block_size / 512);", "if (write(VAR_6, buf, HEADER_SIZE) != HEADER_SIZE)\nreturn -EIO;", "if (lseek(VAR_6, 1536 + ((num_bat_entries * 4 + 511) & ~511), SEEK_SET) < 0)\nreturn -EIO;", "if (write(VAR_6, buf, HEADER_SIZE) != HEADER_SIZE)\nreturn -EIO;", "if (lseek(VAR_6, 3 * 512, SEEK_SET) < 0)\nreturn -EIO;", "memset(buf, 0xFF, 512);", "for (VAR_7 = 0; VAR_7 < (num_bat_entries * 4 + 511) / 512; VAR_7++)", "if (write(VAR_6, buf, 512) != 512)\nreturn -EIO;", "memset(buf, 0, 1024);", "strncpy(VAR_5->magic, \"cxsparse\", 8);", "VAR_5->data_offset = be64_to_cpu(0xFFFFFFFF);", "VAR_5->table_offset = be64_to_cpu(3 * 512);", "VAR_5->version = be32_to_cpu(0x00010000);", "VAR_5->block_size = be32_to_cpu(block_size);", "VAR_5->max_table_entries = be32_to_cpu(num_bat_entries);", "VAR_5->checksum = be32_to_cpu(vpc_checksum(buf, 1024));", "if (lseek(VAR_6, 512, SEEK_SET) < 0)\nreturn -EIO;", "if (write(VAR_6, buf, 1024) != 1024)\nreturn -EIO;", "close(VAR_6);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 33 ], [ 35, 37 ], [ 43 ], [ 45 ], [ 51 ], [ 55 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 105 ], [ 111 ], [ 113 ], [ 117, 119 ], [ 123, 125 ], [ 127, 129 ], [ 135, 137 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 155 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 175 ], [ 181, 183 ], [ 185, 187 ], [ 191 ], [ 193 ], [ 195 ] ]
16,736
static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; DriveInfo *dinfo; if (!bs) { error_report("usb-msd: drive property not set"); return -1; } /* * Hack alert: this pretends to be a block device, but it's really * a SCSI bus that can serve only a single device, which it * creates automatically. But first it needs to detach from its * blockdev, or else scsi_bus_legacy_add_drive() dies when it * attaches again. * * The hack is probably a bad idea. */ bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; if (!s->serial) { /* try to fall back to value set with legacy -drive serial=... */ dinfo = drive_get_by_blockdev(bs); if (*dinfo->serial) { s->serial = strdup(dinfo->serial); } } if (s->serial) { usb_desc_set_string(dev, STR_SERIALNUMBER, s->serial); } usb_desc_init(dev); scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex); if (!s->scsi_dev) { return -1; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; } } return 0; }
false
qemu
6a84cb1f2822e494839b93dd8c7f7f8fa6c261a9
static int usb_msd_initfn(USBDevice *dev) { MSDState *s = DO_UPCAST(MSDState, dev, dev); BlockDriverState *bs = s->conf.bs; DriveInfo *dinfo; if (!bs) { error_report("usb-msd: drive property not set"); return -1; } bdrv_detach_dev(bs, &s->dev.qdev); s->conf.bs = NULL; if (!s->serial) { dinfo = drive_get_by_blockdev(bs); if (*dinfo->serial) { s->serial = strdup(dinfo->serial); } } if (s->serial) { usb_desc_set_string(dev, STR_SERIALNUMBER, s->serial); } usb_desc_init(dev); scsi_bus_new(&s->bus, &s->dev.qdev, &usb_msd_scsi_info); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex); if (!s->scsi_dev) { return -1; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(dev); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->dev.auto_attach = 0; } else { autostart = 0; } } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(USBDevice *VAR_0) { MSDState *s = DO_UPCAST(MSDState, VAR_0, VAR_0); BlockDriverState *bs = s->conf.bs; DriveInfo *dinfo; if (!bs) { error_report("usb-msd: drive property not set"); return -1; } bdrv_detach_dev(bs, &s->VAR_0.qdev); s->conf.bs = NULL; if (!s->serial) { dinfo = drive_get_by_blockdev(bs); if (*dinfo->serial) { s->serial = strdup(dinfo->serial); } } if (s->serial) { usb_desc_set_string(VAR_0, STR_SERIALNUMBER, s->serial); } usb_desc_init(VAR_0); scsi_bus_new(&s->bus, &s->VAR_0.qdev, &usb_msd_scsi_info); s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable, s->conf.bootindex); if (!s->scsi_dev) { return -1; } s->bus.qbus.allow_hotplug = 0; usb_msd_handle_reset(VAR_0); if (bdrv_key_required(bs)) { if (cur_mon) { monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s); s->VAR_0.auto_attach = 0; } else { autostart = 0; } } return 0; }
[ "static int FUNC_0(USBDevice *VAR_0)\n{", "MSDState *s = DO_UPCAST(MSDState, VAR_0, VAR_0);", "BlockDriverState *bs = s->conf.bs;", "DriveInfo *dinfo;", "if (!bs) {", "error_report(\"usb-msd: drive property not set\");", "return -1;", "}", "bdrv_detach_dev(bs, &s->VAR_0.qdev);", "s->conf.bs = NULL;", "if (!s->serial) {", "dinfo = drive_get_by_blockdev(bs);", "if (*dinfo->serial) {", "s->serial = strdup(dinfo->serial);", "}", "}", "if (s->serial) {", "usb_desc_set_string(VAR_0, STR_SERIALNUMBER, s->serial);", "}", "usb_desc_init(VAR_0);", "scsi_bus_new(&s->bus, &s->VAR_0.qdev, &usb_msd_scsi_info);", "s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, bs, 0, !!s->removable,\ns->conf.bootindex);", "if (!s->scsi_dev) {", "return -1;", "}", "s->bus.qbus.allow_hotplug = 0;", "usb_msd_handle_reset(VAR_0);", "if (bdrv_key_required(bs)) {", "if (cur_mon) {", "monitor_read_bdrv_key_start(cur_mon, bs, usb_msd_password_cb, s);", "s->VAR_0.auto_attach = 0;", "} else {", "autostart = 0;", "}", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 41 ], [ 43 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ] ]
16,738
static int encode_superframe(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ WMACodecContext *s = avctx->priv_data; const short *samples = data; int i, total_gain; s->block_len_bits= s->frame_len_bits; //required by non variable block len s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(avctx, samples, avctx->frame_size); if (s->ms_stereo) { float a, b; int i; for(i = 0; i < s->block_len; i++) { a = s->coefs[0][i]*0.5; b = s->coefs[1][i]*0.5; s->coefs[0][i] = a + b; s->coefs[1][i] = a - b; } } if (buf_size < 2 * MAX_CODED_SUPERFRAME_SIZE) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small\n"); return AVERROR(EINVAL); } #if 1 total_gain= 128; for(i=64; i; i>>=1){ int error= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); if(error<0) total_gain-= i; } #else total_gain= 90; best= encode_frame(s, s->coefs, buf, buf_size, total_gain); for(i=32; i; i>>=1){ int scoreL= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); int scoreR= encode_frame(s, s->coefs, buf, buf_size, total_gain+i); av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, total_gain); if(scoreL < FFMIN(best, scoreR)){ best = scoreL; total_gain -= i; }else if(scoreR < best){ best = scoreR; total_gain += i; } } #endif encode_frame(s, s->coefs, buf, buf_size, total_gain); assert((put_bits_count(&s->pb) & 7) == 0); i= s->block_align - (put_bits_count(&s->pb)+7)/8; assert(i>=0); while(i--) put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); return put_bits_ptr(&s->pb) - s->pb.buf; }
false
FFmpeg
5d652e063bd3a180f9de8915e5137aa4f938846d
static int encode_superframe(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data){ WMACodecContext *s = avctx->priv_data; const short *samples = data; int i, total_gain; s->block_len_bits= s->frame_len_bits; s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(avctx, samples, avctx->frame_size); if (s->ms_stereo) { float a, b; int i; for(i = 0; i < s->block_len; i++) { a = s->coefs[0][i]*0.5; b = s->coefs[1][i]*0.5; s->coefs[0][i] = a + b; s->coefs[1][i] = a - b; } } if (buf_size < 2 * MAX_CODED_SUPERFRAME_SIZE) { av_log(avctx, AV_LOG_ERROR, "output buffer size is too small\n"); return AVERROR(EINVAL); } #if 1 total_gain= 128; for(i=64; i; i>>=1){ int error= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); if(error<0) total_gain-= i; } #else total_gain= 90; best= encode_frame(s, s->coefs, buf, buf_size, total_gain); for(i=32; i; i>>=1){ int scoreL= encode_frame(s, s->coefs, buf, buf_size, total_gain-i); int scoreR= encode_frame(s, s->coefs, buf, buf_size, total_gain+i); av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, total_gain); if(scoreL < FFMIN(best, scoreR)){ best = scoreL; total_gain -= i; }else if(scoreR < best){ best = scoreR; total_gain += i; } } #endif encode_frame(s, s->coefs, buf, buf_size, total_gain); assert((put_bits_count(&s->pb) & 7) == 0); i= s->block_align - (put_bits_count(&s->pb)+7)/8; assert(i>=0); while(i--) put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); return put_bits_ptr(&s->pb) - s->pb.buf; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, unsigned char *VAR_1, int VAR_2, void *VAR_3){ WMACodecContext *s = VAR_0->priv_data; const short *VAR_4 = VAR_3; int VAR_9, VAR_6; s->block_len_bits= s->frame_len_bits; s->block_len = 1 << s->block_len_bits; apply_window_and_mdct(VAR_0, VAR_4, VAR_0->frame_size); if (s->ms_stereo) { float VAR_7, VAR_8; int VAR_9; for(VAR_9 = 0; VAR_9 < s->block_len; VAR_9++) { VAR_7 = s->coefs[0][VAR_9]*0.5; VAR_8 = s->coefs[1][VAR_9]*0.5; s->coefs[0][VAR_9] = VAR_7 + VAR_8; s->coefs[1][VAR_9] = VAR_7 - VAR_8; } } if (VAR_2 < 2 * MAX_CODED_SUPERFRAME_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "output buffer size is too small\n"); return AVERROR(EINVAL); } #if 1 VAR_6= 128; for(VAR_9=64; VAR_9; VAR_9>>=1){ int VAR_9= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6-VAR_9); if(VAR_9<0) VAR_6-= VAR_9; } #else VAR_6= 90; best= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6); for(VAR_9=32; VAR_9; VAR_9>>=1){ int scoreL= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6-VAR_9); int scoreR= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6+VAR_9); av_log(NULL, AV_LOG_ERROR, "%d %d %d (%d)\n", scoreL, best, scoreR, VAR_6); if(scoreL < FFMIN(best, scoreR)){ best = scoreL; VAR_6 -= VAR_9; }else if(scoreR < best){ best = scoreR; VAR_6 += VAR_9; } } #endif encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6); assert((put_bits_count(&s->pb) & 7) == 0); VAR_9= s->block_align - (put_bits_count(&s->pb)+7)/8; assert(VAR_9>=0); while(VAR_9--) put_bits(&s->pb, 8, 'N'); flush_put_bits(&s->pb); return put_bits_ptr(&s->pb) - s->pb.VAR_1; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nunsigned char *VAR_1, int VAR_2, void *VAR_3){", "WMACodecContext *s = VAR_0->priv_data;", "const short *VAR_4 = VAR_3;", "int VAR_9, VAR_6;", "s->block_len_bits= s->frame_len_bits;", "s->block_len = 1 << s->block_len_bits;", "apply_window_and_mdct(VAR_0, VAR_4, VAR_0->frame_size);", "if (s->ms_stereo) {", "float VAR_7, VAR_8;", "int VAR_9;", "for(VAR_9 = 0; VAR_9 < s->block_len; VAR_9++) {", "VAR_7 = s->coefs[0][VAR_9]*0.5;", "VAR_8 = s->coefs[1][VAR_9]*0.5;", "s->coefs[0][VAR_9] = VAR_7 + VAR_8;", "s->coefs[1][VAR_9] = VAR_7 - VAR_8;", "}", "}", "if (VAR_2 < 2 * MAX_CODED_SUPERFRAME_SIZE) {", "av_log(VAR_0, AV_LOG_ERROR, \"output buffer size is too small\\n\");", "return AVERROR(EINVAL);", "}", "#if 1\nVAR_6= 128;", "for(VAR_9=64; VAR_9; VAR_9>>=1){", "int VAR_9= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6-VAR_9);", "if(VAR_9<0)\nVAR_6-= VAR_9;", "}", "#else\nVAR_6= 90;", "best= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6);", "for(VAR_9=32; VAR_9; VAR_9>>=1){", "int scoreL= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6-VAR_9);", "int scoreR= encode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6+VAR_9);", "av_log(NULL, AV_LOG_ERROR, \"%d %d %d (%d)\\n\", scoreL, best, scoreR, VAR_6);", "if(scoreL < FFMIN(best, scoreR)){", "best = scoreL;", "VAR_6 -= VAR_9;", "}else if(scoreR < best){", "best = scoreR;", "VAR_6 += VAR_9;", "}", "}", "#endif\nencode_frame(s, s->coefs, VAR_1, VAR_2, VAR_6);", "assert((put_bits_count(&s->pb) & 7) == 0);", "VAR_9= s->block_align - (put_bits_count(&s->pb)+7)/8;", "assert(VAR_9>=0);", "while(VAR_9--)\nput_bits(&s->pb, 8, 'N');", "flush_put_bits(&s->pb);", "return put_bits_ptr(&s->pb) - s->pb.VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113, 115 ], [ 119 ], [ 121 ], [ 123 ] ]
16,739
static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest, TCGReg c1, TCGArg c2, int c2const, TCGReg r3) { int cc; if (facilities & FACILITY_LOAD_ON_COND) { cc = tgen_cmp(s, type, c, c1, c2, c2const, false); tcg_out_insn(s, RRF, LOCGR, dest, r3, cc); } else { c = tcg_invert_cond(c); cc = tgen_cmp(s, type, c, c1, c2, c2const, false); /* Emit: if (cc) goto over; dest = r3; over: */ tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); tcg_out_insn(s, RRE, LGR, dest, r3); } }
false
qemu
b2c98d9d392c87c9b9e975d30f79924719d9cbbe
static void tgen_movcond(TCGContext *s, TCGType type, TCGCond c, TCGReg dest, TCGReg c1, TCGArg c2, int c2const, TCGReg r3) { int cc; if (facilities & FACILITY_LOAD_ON_COND) { cc = tgen_cmp(s, type, c, c1, c2, c2const, false); tcg_out_insn(s, RRF, LOCGR, dest, r3, cc); } else { c = tcg_invert_cond(c); cc = tgen_cmp(s, type, c, c1, c2, c2const, false); tcg_out_insn(s, RI, BRC, cc, (4 + 4) >> 1); tcg_out_insn(s, RRE, LGR, dest, r3); } }
{ "code": [], "line_no": [] }
static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGCond VAR_2, TCGReg VAR_3, TCGReg VAR_4, TCGArg VAR_5, int VAR_6, TCGReg VAR_7) { int VAR_8; if (facilities & FACILITY_LOAD_ON_COND) { VAR_8 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false); tcg_out_insn(VAR_0, RRF, LOCGR, VAR_3, VAR_7, VAR_8); } else { VAR_2 = tcg_invert_cond(VAR_2); VAR_8 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false); tcg_out_insn(VAR_0, RI, BRC, VAR_8, (4 + 4) >> 1); tcg_out_insn(VAR_0, RRE, LGR, VAR_3, VAR_7); } }
[ "static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGCond VAR_2, TCGReg VAR_3,\nTCGReg VAR_4, TCGArg VAR_5, int VAR_6, TCGReg VAR_7)\n{", "int VAR_8;", "if (facilities & FACILITY_LOAD_ON_COND) {", "VAR_8 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false);", "tcg_out_insn(VAR_0, RRF, LOCGR, VAR_3, VAR_7, VAR_8);", "} else {", "VAR_2 = tcg_invert_cond(VAR_2);", "VAR_8 = tgen_cmp(VAR_0, VAR_1, VAR_2, VAR_4, VAR_5, VAR_6, false);", "tcg_out_insn(VAR_0, RI, BRC, VAR_8, (4 + 4) >> 1);", "tcg_out_insn(VAR_0, RRE, LGR, VAR_3, VAR_7);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ] ]
16,740
static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, QemuOpts *opts, Error **errp) { uint16_t nodenr; uint16List *cpus = NULL; MachineClass *mc = MACHINE_GET_CLASS(ms); if (node->has_nodeid) { nodenr = node->nodeid; } else { nodenr = nb_numa_nodes; } if (nodenr >= MAX_NODES) { error_setg(errp, "Max number of NUMA nodes reached: %" PRIu16 "", nodenr); return; } if (numa_info[nodenr].present) { error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr); return; } if (!mc->cpu_index_to_instance_props) { error_report("NUMA is not supported by this machine-type"); exit(1); } for (cpus = node->cpus; cpus; cpus = cpus->next) { CpuInstanceProperties props; if (cpus->value >= max_cpus) { error_setg(errp, "CPU index (%" PRIu16 ")" " should be smaller than maxcpus (%d)", cpus->value, max_cpus); return; } props = mc->cpu_index_to_instance_props(ms, cpus->value); props.node_id = nodenr; props.has_node_id = true; machine_set_cpu_numa_node(ms, &props, &error_fatal); } if (node->has_mem && node->has_memdev) { error_setg(errp, "cannot specify both mem= and memdev="); return; } if (have_memdevs == -1) { have_memdevs = node->has_memdev; } if (node->has_memdev != have_memdevs) { error_setg(errp, "memdev option must be specified for either " "all or no nodes"); return; } if (node->has_mem) { uint64_t mem_size = node->mem; const char *mem_str = qemu_opt_get(opts, "mem"); /* Fix up legacy suffix-less format */ if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { mem_size <<= 20; } numa_info[nodenr].node_mem = mem_size; } if (node->has_memdev) { Object *o; o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL); if (!o) { error_setg(errp, "memdev=%s is ambiguous", node->memdev); return; } object_ref(o); numa_info[nodenr].node_mem = object_property_get_uint(o, "size", NULL); numa_info[nodenr].node_memdev = MEMORY_BACKEND(o); } numa_info[nodenr].present = true; max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); }
false
qemu
cc001888b78090ed08d05453b5574b3253a143c0
static void parse_numa_node(MachineState *ms, NumaNodeOptions *node, QemuOpts *opts, Error **errp) { uint16_t nodenr; uint16List *cpus = NULL; MachineClass *mc = MACHINE_GET_CLASS(ms); if (node->has_nodeid) { nodenr = node->nodeid; } else { nodenr = nb_numa_nodes; } if (nodenr >= MAX_NODES) { error_setg(errp, "Max number of NUMA nodes reached: %" PRIu16 "", nodenr); return; } if (numa_info[nodenr].present) { error_setg(errp, "Duplicate NUMA nodeid: %" PRIu16, nodenr); return; } if (!mc->cpu_index_to_instance_props) { error_report("NUMA is not supported by this machine-type"); exit(1); } for (cpus = node->cpus; cpus; cpus = cpus->next) { CpuInstanceProperties props; if (cpus->value >= max_cpus) { error_setg(errp, "CPU index (%" PRIu16 ")" " should be smaller than maxcpus (%d)", cpus->value, max_cpus); return; } props = mc->cpu_index_to_instance_props(ms, cpus->value); props.node_id = nodenr; props.has_node_id = true; machine_set_cpu_numa_node(ms, &props, &error_fatal); } if (node->has_mem && node->has_memdev) { error_setg(errp, "cannot specify both mem= and memdev="); return; } if (have_memdevs == -1) { have_memdevs = node->has_memdev; } if (node->has_memdev != have_memdevs) { error_setg(errp, "memdev option must be specified for either " "all or no nodes"); return; } if (node->has_mem) { uint64_t mem_size = node->mem; const char *mem_str = qemu_opt_get(opts, "mem"); if (g_ascii_isdigit(mem_str[strlen(mem_str) - 1])) { mem_size <<= 20; } numa_info[nodenr].node_mem = mem_size; } if (node->has_memdev) { Object *o; o = object_resolve_path_type(node->memdev, TYPE_MEMORY_BACKEND, NULL); if (!o) { error_setg(errp, "memdev=%s is ambiguous", node->memdev); return; } object_ref(o); numa_info[nodenr].node_mem = object_property_get_uint(o, "size", NULL); numa_info[nodenr].node_memdev = MEMORY_BACKEND(o); } numa_info[nodenr].present = true; max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); }
{ "code": [], "line_no": [] }
static void FUNC_0(MachineState *VAR_0, NumaNodeOptions *VAR_1, QemuOpts *VAR_2, Error **VAR_3) { uint16_t nodenr; uint16List *cpus = NULL; MachineClass *mc = MACHINE_GET_CLASS(VAR_0); if (VAR_1->has_nodeid) { nodenr = VAR_1->nodeid; } else { nodenr = nb_numa_nodes; } if (nodenr >= MAX_NODES) { error_setg(VAR_3, "Max number of NUMA nodes reached: %" PRIu16 "", nodenr); return; } if (numa_info[nodenr].present) { error_setg(VAR_3, "Duplicate NUMA nodeid: %" PRIu16, nodenr); return; } if (!mc->cpu_index_to_instance_props) { error_report("NUMA is not supported by this machine-type"); exit(1); } for (cpus = VAR_1->cpus; cpus; cpus = cpus->next) { CpuInstanceProperties props; if (cpus->value >= max_cpus) { error_setg(VAR_3, "CPU index (%" PRIu16 ")" " should be smaller than maxcpus (%d)", cpus->value, max_cpus); return; } props = mc->cpu_index_to_instance_props(VAR_0, cpus->value); props.node_id = nodenr; props.has_node_id = true; machine_set_cpu_numa_node(VAR_0, &props, &error_fatal); } if (VAR_1->has_mem && VAR_1->has_memdev) { error_setg(VAR_3, "cannot specify both mem= and memdev="); return; } if (have_memdevs == -1) { have_memdevs = VAR_1->has_memdev; } if (VAR_1->has_memdev != have_memdevs) { error_setg(VAR_3, "memdev option must be specified for either " "all or no nodes"); return; } if (VAR_1->has_mem) { uint64_t mem_size = VAR_1->mem; const char *VAR_4 = qemu_opt_get(VAR_2, "mem"); if (g_ascii_isdigit(VAR_4[strlen(VAR_4) - 1])) { mem_size <<= 20; } numa_info[nodenr].node_mem = mem_size; } if (VAR_1->has_memdev) { Object *o; o = object_resolve_path_type(VAR_1->memdev, TYPE_MEMORY_BACKEND, NULL); if (!o) { error_setg(VAR_3, "memdev=%s is ambiguous", VAR_1->memdev); return; } object_ref(o); numa_info[nodenr].node_mem = object_property_get_uint(o, "size", NULL); numa_info[nodenr].node_memdev = MEMORY_BACKEND(o); } numa_info[nodenr].present = true; max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1); }
[ "static void FUNC_0(MachineState *VAR_0, NumaNodeOptions *VAR_1,\nQemuOpts *VAR_2, Error **VAR_3)\n{", "uint16_t nodenr;", "uint16List *cpus = NULL;", "MachineClass *mc = MACHINE_GET_CLASS(VAR_0);", "if (VAR_1->has_nodeid) {", "nodenr = VAR_1->nodeid;", "} else {", "nodenr = nb_numa_nodes;", "}", "if (nodenr >= MAX_NODES) {", "error_setg(VAR_3, \"Max number of NUMA nodes reached: %\"\nPRIu16 \"\", nodenr);", "return;", "}", "if (numa_info[nodenr].present) {", "error_setg(VAR_3, \"Duplicate NUMA nodeid: %\" PRIu16, nodenr);", "return;", "}", "if (!mc->cpu_index_to_instance_props) {", "error_report(\"NUMA is not supported by this machine-type\");", "exit(1);", "}", "for (cpus = VAR_1->cpus; cpus; cpus = cpus->next) {", "CpuInstanceProperties props;", "if (cpus->value >= max_cpus) {", "error_setg(VAR_3,\n\"CPU index (%\" PRIu16 \")\"\n\" should be smaller than maxcpus (%d)\",\ncpus->value, max_cpus);", "return;", "}", "props = mc->cpu_index_to_instance_props(VAR_0, cpus->value);", "props.node_id = nodenr;", "props.has_node_id = true;", "machine_set_cpu_numa_node(VAR_0, &props, &error_fatal);", "}", "if (VAR_1->has_mem && VAR_1->has_memdev) {", "error_setg(VAR_3, \"cannot specify both mem= and memdev=\");", "return;", "}", "if (have_memdevs == -1) {", "have_memdevs = VAR_1->has_memdev;", "}", "if (VAR_1->has_memdev != have_memdevs) {", "error_setg(VAR_3, \"memdev option must be specified for either \"\n\"all or no nodes\");", "return;", "}", "if (VAR_1->has_mem) {", "uint64_t mem_size = VAR_1->mem;", "const char *VAR_4 = qemu_opt_get(VAR_2, \"mem\");", "if (g_ascii_isdigit(VAR_4[strlen(VAR_4) - 1])) {", "mem_size <<= 20;", "}", "numa_info[nodenr].node_mem = mem_size;", "}", "if (VAR_1->has_memdev) {", "Object *o;", "o = object_resolve_path_type(VAR_1->memdev, TYPE_MEMORY_BACKEND, NULL);", "if (!o) {", "error_setg(VAR_3, \"memdev=%s is ambiguous\", VAR_1->memdev);", "return;", "}", "object_ref(o);", "numa_info[nodenr].node_mem = object_property_get_uint(o, \"size\", NULL);", "numa_info[nodenr].node_memdev = MEMORY_BACKEND(o);", "}", "numa_info[nodenr].present = true;", "max_numa_nodeid = MAX(max_numa_nodeid, nodenr + 1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63, 65, 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ] ]
16,741
static int calculate_geometry(int64_t total_sectors, uint16_t* cyls, uint8_t* heads, uint8_t* secs_per_cyl) { uint32_t cyls_times_heads; if (total_sectors > 65535 * 16 * 255) return -EFBIG; if (total_sectors > 65535 * 16 * 63) { *secs_per_cyl = 255; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } else { *secs_per_cyl = 17; cyls_times_heads = total_sectors / *secs_per_cyl; *heads = (cyls_times_heads + 1023) / 1024; if (*heads < 4) *heads = 4; if (cyls_times_heads >= (*heads * 1024) || *heads > 16) { *secs_per_cyl = 31; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } if (cyls_times_heads >= (*heads * 1024)) { *secs_per_cyl = 63; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } } *cyls = cyls_times_heads / *heads; return 0; }
false
qemu
258d2edbcd4bb5d267c96163333820332e1c14fa
static int calculate_geometry(int64_t total_sectors, uint16_t* cyls, uint8_t* heads, uint8_t* secs_per_cyl) { uint32_t cyls_times_heads; if (total_sectors > 65535 * 16 * 255) return -EFBIG; if (total_sectors > 65535 * 16 * 63) { *secs_per_cyl = 255; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } else { *secs_per_cyl = 17; cyls_times_heads = total_sectors / *secs_per_cyl; *heads = (cyls_times_heads + 1023) / 1024; if (*heads < 4) *heads = 4; if (cyls_times_heads >= (*heads * 1024) || *heads > 16) { *secs_per_cyl = 31; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } if (cyls_times_heads >= (*heads * 1024)) { *secs_per_cyl = 63; *heads = 16; cyls_times_heads = total_sectors / *secs_per_cyl; } } *cyls = cyls_times_heads / *heads; return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(int64_t VAR_0, uint16_t* VAR_1, uint8_t* VAR_2, uint8_t* VAR_3) { uint32_t cyls_times_heads; if (VAR_0 > 65535 * 16 * 255) return -EFBIG; if (VAR_0 > 65535 * 16 * 63) { *VAR_3 = 255; *VAR_2 = 16; cyls_times_heads = VAR_0 / *VAR_3; } else { *VAR_3 = 17; cyls_times_heads = VAR_0 / *VAR_3; *VAR_2 = (cyls_times_heads + 1023) / 1024; if (*VAR_2 < 4) *VAR_2 = 4; if (cyls_times_heads >= (*VAR_2 * 1024) || *VAR_2 > 16) { *VAR_3 = 31; *VAR_2 = 16; cyls_times_heads = VAR_0 / *VAR_3; } if (cyls_times_heads >= (*VAR_2 * 1024)) { *VAR_3 = 63; *VAR_2 = 16; cyls_times_heads = VAR_0 / *VAR_3; } } *VAR_1 = cyls_times_heads / *VAR_2; return 0; }
[ "static int FUNC_0(int64_t VAR_0, uint16_t* VAR_1,\nuint8_t* VAR_2, uint8_t* VAR_3)\n{", "uint32_t cyls_times_heads;", "if (VAR_0 > 65535 * 16 * 255)\nreturn -EFBIG;", "if (VAR_0 > 65535 * 16 * 63) {", "*VAR_3 = 255;", "*VAR_2 = 16;", "cyls_times_heads = VAR_0 / *VAR_3;", "} else {", "*VAR_3 = 17;", "cyls_times_heads = VAR_0 / *VAR_3;", "*VAR_2 = (cyls_times_heads + 1023) / 1024;", "if (*VAR_2 < 4)\n*VAR_2 = 4;", "if (cyls_times_heads >= (*VAR_2 * 1024) || *VAR_2 > 16) {", "*VAR_3 = 31;", "*VAR_2 = 16;", "cyls_times_heads = VAR_0 / *VAR_3;", "}", "if (cyls_times_heads >= (*VAR_2 * 1024)) {", "*VAR_3 = 63;", "*VAR_2 = 16;", "cyls_times_heads = VAR_0 / *VAR_3;", "}", "}", "*VAR_1 = cyls_times_heads / *VAR_2;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35, 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67 ], [ 71 ], [ 73 ] ]
16,742
static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); #endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); uint64_t pl = get_address(env, 1) & -16; uint64_t svh, svl; uint32_t cc; /* Sanity check the function code and storage characteristic. */ if (fc > 1 || sc > 3) { if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) { goto spec_exception; } if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) { goto spec_exception; } } /* Sanity check the alignments. */ if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { goto spec_exception; } /* Sanity check writability of the store address. */ #ifndef CONFIG_USER_ONLY probe_write(env, a2, mem_idx, ra); #endif /* Note that the compare-and-swap is atomic, and the store is atomic, but the complete operation is not. Therefore we do not need to assert serial context in order to implement this. That said, restart early if we can't support either operation that is supposed to be atomic. */ if (parallel) { int mask = 0; #if !defined(CONFIG_ATOMIC64) mask = -8; #elif !defined(CONFIG_ATOMIC128) mask = -16; #endif if (((4 << fc) | (1 << sc)) & mask) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } /* All loads happen before all stores. For simplicity, load the entire store value area from the parameter list. */ svh = cpu_ldq_data_ra(env, pl + 16, ra); svl = cpu_ldq_data_ra(env, pl + 24, ra); switch (fc) { case 0: { uint32_t nv = cpu_ldl_data_ra(env, pl, ra); uint32_t cv = env->regs[r3]; uint32_t ov; if (parallel) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); #else TCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra); #endif } else { ov = cpu_ldl_data_ra(env, a1, ra); cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov); } break; case 1: { uint64_t nv = cpu_ldq_data_ra(env, pl, ra); uint64_t cv = env->regs[r3]; uint64_t ov; if (parallel) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); # else TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { ov = cpu_ldq_data_ra(env, a1, ra); cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = ov; } break; case 2: { uint64_t nvh = cpu_ldq_data_ra(env, pl, ra); uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra); Int128 nv = int128_make128(nvl, nvh); Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); ov = int128_make128(ol, oh); cc = !int128_eq(ov, cv); if (cc) { nv = ov; } cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); } env->regs[r3 + 0] = int128_gethi(ov); env->regs[r3 + 1] = int128_getlo(ov); } break; default: g_assert_not_reached(); } /* Store only if the comparison succeeded. Note that above we use a pair of 64-bit big-endian loads, so for sc < 3 we must extract the value from the most-significant bits of svh. */ if (cc == 0) { switch (sc) { case 0: cpu_stb_data_ra(env, a2, svh >> 56, ra); break; case 1: cpu_stw_data_ra(env, a2, svh >> 48, ra); break; case 2: cpu_stl_data_ra(env, a2, svh >> 32, ra); break; case 3: cpu_stq_data_ra(env, a2, svh, ra); break; case 4: if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else /* Note that we asserted !parallel above. */ g_assert_not_reached(); #endif } else { cpu_stq_data_ra(env, a2 + 0, svh, ra); cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: g_assert_not_reached(); } } return cc; spec_exception: cpu_restore_state(ENV_GET_CPU(env), ra); program_interrupt(env, PGM_SPECIFICATION, 6); g_assert_not_reached(); }
false
qemu
8d2f850a5ab7579a852f23b28273940a47dfd7ff
static uint32_t do_csst(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); #endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); uint64_t pl = get_address(env, 1) & -16; uint64_t svh, svl; uint32_t cc; if (fc > 1 || sc > 3) { if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) { goto spec_exception; } if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) { goto spec_exception; } } if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { goto spec_exception; } #ifndef CONFIG_USER_ONLY probe_write(env, a2, mem_idx, ra); #endif if (parallel) { int mask = 0; #if !defined(CONFIG_ATOMIC64) mask = -8; #elif !defined(CONFIG_ATOMIC128) mask = -16; #endif if (((4 << fc) | (1 << sc)) & mask) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } svh = cpu_ldq_data_ra(env, pl + 16, ra); svl = cpu_ldq_data_ra(env, pl + 24, ra); switch (fc) { case 0: { uint32_t nv = cpu_ldl_data_ra(env, pl, ra); uint32_t cv = env->regs[r3]; uint32_t ov; if (parallel) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); #else TCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra); #endif } else { ov = cpu_ldl_data_ra(env, a1, ra); cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov); } break; case 1: { uint64_t nv = cpu_ldq_data_ra(env, pl, ra); uint64_t cv = env->regs[r3]; uint64_t ov; if (parallel) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); # else TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else g_assert_not_reached(); #endif } else { ov = cpu_ldq_data_ra(env, a1, ra); cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = ov; } break; case 2: { uint64_t nvh = cpu_ldq_data_ra(env, pl, ra); uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra); Int128 nv = int128_make128(nvl, nvh); Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else g_assert_not_reached(); #endif } else { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); ov = int128_make128(ol, oh); cc = !int128_eq(ov, cv); if (cc) { nv = ov; } cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); } env->regs[r3 + 0] = int128_gethi(ov); env->regs[r3 + 1] = int128_getlo(ov); } break; default: g_assert_not_reached(); } if (cc == 0) { switch (sc) { case 0: cpu_stb_data_ra(env, a2, svh >> 56, ra); break; case 1: cpu_stw_data_ra(env, a2, svh >> 48, ra); break; case 2: cpu_stl_data_ra(env, a2, svh >> 32, ra); break; case 3: cpu_stq_data_ra(env, a2, svh, ra); break; case 4: if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else g_assert_not_reached(); #endif } else { cpu_stq_data_ra(env, a2 + 0, svh, ra); cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: g_assert_not_reached(); } } return cc; spec_exception: cpu_restore_state(ENV_GET_CPU(env), ra); program_interrupt(env, PGM_SPECIFICATION, 6); g_assert_not_reached(); }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(CPUS390XState *env, uint32_t r3, uint64_t a1, uint64_t a2, bool parallel) { #if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128) uint32_t mem_idx = cpu_mmu_index(env, false); #endif uintptr_t ra = GETPC(); uint32_t fc = extract32(env->regs[0], 0, 8); uint32_t sc = extract32(env->regs[0], 8, 8); uint64_t pl = get_address(env, 1) & -16; uint64_t svh, svl; uint32_t cc; if (fc > 1 || sc > 3) { if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) { goto spec_exception; } if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) { goto spec_exception; } } if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) { goto spec_exception; } #ifndef CONFIG_USER_ONLY probe_write(env, a2, mem_idx, ra); #endif if (parallel) { int VAR_0 = 0; #if !defined(CONFIG_ATOMIC64) VAR_0 = -8; #elif !defined(CONFIG_ATOMIC128) VAR_0 = -16; #endif if (((4 << fc) | (1 << sc)) & VAR_0) { cpu_loop_exit_atomic(ENV_GET_CPU(env), ra); } } svh = cpu_ldq_data_ra(env, pl + 16, ra); svl = cpu_ldq_data_ra(env, pl + 24, ra); switch (fc) { case 0: { uint32_t nv = cpu_ldl_data_ra(env, pl, ra); uint32_t cv = env->regs[r3]; uint32_t ov; if (parallel) { #ifdef CONFIG_USER_ONLY uint32_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); #else TCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra); #endif } else { ov = cpu_ldl_data_ra(env, a1, ra); cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov); } break; case 1: { uint64_t nv = cpu_ldq_data_ra(env, pl, ra); uint64_t cv = env->regs[r3]; uint64_t ov; if (parallel) { #ifdef CONFIG_ATOMIC64 # ifdef CONFIG_USER_ONLY uint64_t *haddr = g2h(a1); ov = atomic_cmpxchg__nocheck(haddr, cv, nv); # else TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx); ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra); # endif #else g_assert_not_reached(); #endif } else { ov = cpu_ldq_data_ra(env, a1, ra); cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra); } cc = (ov != cv); env->regs[r3] = ov; } break; case 2: { uint64_t nvh = cpu_ldq_data_ra(env, pl, ra); uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra); Int128 nv = int128_make128(nvl, nvh); Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]); Int128 ov; if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra); cc = !int128_eq(ov, cv); #else g_assert_not_reached(); #endif } else { uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra); uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra); ov = int128_make128(ol, oh); cc = !int128_eq(ov, cv); if (cc) { nv = ov; } cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra); cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra); } env->regs[r3 + 0] = int128_gethi(ov); env->regs[r3 + 1] = int128_getlo(ov); } break; default: g_assert_not_reached(); } if (cc == 0) { switch (sc) { case 0: cpu_stb_data_ra(env, a2, svh >> 56, ra); break; case 1: cpu_stw_data_ra(env, a2, svh >> 48, ra); break; case 2: cpu_stl_data_ra(env, a2, svh >> 32, ra); break; case 3: cpu_stq_data_ra(env, a2, svh, ra); break; case 4: if (parallel) { #ifdef CONFIG_ATOMIC128 TCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx); Int128 sv = int128_make128(svl, svh); helper_atomic_sto_be_mmu(env, a2, sv, oi, ra); #else g_assert_not_reached(); #endif } else { cpu_stq_data_ra(env, a2 + 0, svh, ra); cpu_stq_data_ra(env, a2 + 8, svl, ra); } break; default: g_assert_not_reached(); } } return cc; spec_exception: cpu_restore_state(ENV_GET_CPU(env), ra); program_interrupt(env, PGM_SPECIFICATION, 6); g_assert_not_reached(); }
[ "static uint32_t FUNC_0(CPUS390XState *env, uint32_t r3, uint64_t a1,\nuint64_t a2, bool parallel)\n{", "#if !defined(CONFIG_USER_ONLY) || defined(CONFIG_ATOMIC128)\nuint32_t mem_idx = cpu_mmu_index(env, false);", "#endif\nuintptr_t ra = GETPC();", "uint32_t fc = extract32(env->regs[0], 0, 8);", "uint32_t sc = extract32(env->regs[0], 8, 8);", "uint64_t pl = get_address(env, 1) & -16;", "uint64_t svh, svl;", "uint32_t cc;", "if (fc > 1 || sc > 3) {", "if (!s390_has_feat(S390_FEAT_COMPARE_AND_SWAP_AND_STORE_2)) {", "goto spec_exception;", "}", "if (fc > 2 || sc > 4 || (fc == 2 && (r3 & 1))) {", "goto spec_exception;", "}", "}", "if (extract32(a1, 0, 4 << fc) || extract32(a2, 0, 1 << sc)) {", "goto spec_exception;", "}", "#ifndef CONFIG_USER_ONLY\nprobe_write(env, a2, mem_idx, ra);", "#endif\nif (parallel) {", "int VAR_0 = 0;", "#if !defined(CONFIG_ATOMIC64)\nVAR_0 = -8;", "#elif !defined(CONFIG_ATOMIC128)\nVAR_0 = -16;", "#endif\nif (((4 << fc) | (1 << sc)) & VAR_0) {", "cpu_loop_exit_atomic(ENV_GET_CPU(env), ra);", "}", "}", "svh = cpu_ldq_data_ra(env, pl + 16, ra);", "svl = cpu_ldq_data_ra(env, pl + 24, ra);", "switch (fc) {", "case 0:\n{", "uint32_t nv = cpu_ldl_data_ra(env, pl, ra);", "uint32_t cv = env->regs[r3];", "uint32_t ov;", "if (parallel) {", "#ifdef CONFIG_USER_ONLY\nuint32_t *haddr = g2h(a1);", "ov = atomic_cmpxchg__nocheck(haddr, cv, nv);", "#else\nTCGMemOpIdx oi = make_memop_idx(MO_TEUL | MO_ALIGN, mem_idx);", "ov = helper_atomic_cmpxchgl_be_mmu(env, a1, cv, nv, oi, ra);", "#endif\n} else {", "ov = cpu_ldl_data_ra(env, a1, ra);", "cpu_stl_data_ra(env, a1, (ov == cv ? nv : ov), ra);", "}", "cc = (ov != cv);", "env->regs[r3] = deposit64(env->regs[r3], 32, 32, ov);", "}", "break;", "case 1:\n{", "uint64_t nv = cpu_ldq_data_ra(env, pl, ra);", "uint64_t cv = env->regs[r3];", "uint64_t ov;", "if (parallel) {", "#ifdef CONFIG_ATOMIC64\n# ifdef CONFIG_USER_ONLY\nuint64_t *haddr = g2h(a1);", "ov = atomic_cmpxchg__nocheck(haddr, cv, nv);", "# else\nTCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN, mem_idx);", "ov = helper_atomic_cmpxchgq_be_mmu(env, a1, cv, nv, oi, ra);", "# endif\n#else\ng_assert_not_reached();", "#endif\n} else {", "ov = cpu_ldq_data_ra(env, a1, ra);", "cpu_stq_data_ra(env, a1, (ov == cv ? nv : ov), ra);", "}", "cc = (ov != cv);", "env->regs[r3] = ov;", "}", "break;", "case 2:\n{", "uint64_t nvh = cpu_ldq_data_ra(env, pl, ra);", "uint64_t nvl = cpu_ldq_data_ra(env, pl + 8, ra);", "Int128 nv = int128_make128(nvl, nvh);", "Int128 cv = int128_make128(env->regs[r3 + 1], env->regs[r3]);", "Int128 ov;", "if (parallel) {", "#ifdef CONFIG_ATOMIC128\nTCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx);", "ov = helper_atomic_cmpxchgo_be_mmu(env, a1, cv, nv, oi, ra);", "cc = !int128_eq(ov, cv);", "#else\ng_assert_not_reached();", "#endif\n} else {", "uint64_t oh = cpu_ldq_data_ra(env, a1 + 0, ra);", "uint64_t ol = cpu_ldq_data_ra(env, a1 + 8, ra);", "ov = int128_make128(ol, oh);", "cc = !int128_eq(ov, cv);", "if (cc) {", "nv = ov;", "}", "cpu_stq_data_ra(env, a1 + 0, int128_gethi(nv), ra);", "cpu_stq_data_ra(env, a1 + 8, int128_getlo(nv), ra);", "}", "env->regs[r3 + 0] = int128_gethi(ov);", "env->regs[r3 + 1] = int128_getlo(ov);", "}", "break;", "default:\ng_assert_not_reached();", "}", "if (cc == 0) {", "switch (sc) {", "case 0:\ncpu_stb_data_ra(env, a2, svh >> 56, ra);", "break;", "case 1:\ncpu_stw_data_ra(env, a2, svh >> 48, ra);", "break;", "case 2:\ncpu_stl_data_ra(env, a2, svh >> 32, ra);", "break;", "case 3:\ncpu_stq_data_ra(env, a2, svh, ra);", "break;", "case 4:\nif (parallel) {", "#ifdef CONFIG_ATOMIC128\nTCGMemOpIdx oi = make_memop_idx(MO_TEQ | MO_ALIGN_16, mem_idx);", "Int128 sv = int128_make128(svl, svh);", "helper_atomic_sto_be_mmu(env, a2, sv, oi, ra);", "#else\ng_assert_not_reached();", "#endif\n} else {", "cpu_stq_data_ra(env, a2 + 0, svh, ra);", "cpu_stq_data_ra(env, a2 + 8, svl, ra);", "}", "break;", "default:\ng_assert_not_reached();", "}", "}", "return cc;", "spec_exception:\ncpu_restore_state(ENV_GET_CPU(env), ra);", "program_interrupt(env, PGM_SPECIFICATION, 6);", "g_assert_not_reached();", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11, 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 49 ], [ 51 ], [ 53 ], [ 59, 61 ], [ 63, 75 ], [ 77 ], [ 79, 81 ], [ 83, 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 103 ], [ 105 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131, 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 169 ], [ 171, 173, 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 185, 187, 191 ], [ 193, 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231, 233 ], [ 235 ], [ 237 ], [ 239, 243 ], [ 245, 247 ], [ 249 ], [ 251 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 267 ], [ 269 ], [ 271 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 285, 287 ], [ 289 ], [ 299 ], [ 301 ], [ 303, 305 ], [ 307 ], [ 309, 311 ], [ 313 ], [ 315, 317 ], [ 319 ], [ 321, 323 ], [ 325 ], [ 327, 329 ], [ 331, 333 ], [ 335 ], [ 337 ], [ 339, 343 ], [ 345, 347 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357, 359 ], [ 361 ], [ 363 ], [ 367 ], [ 371, 373 ], [ 375 ], [ 377 ], [ 379 ] ]
16,743
static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
static void test_visitor_out_native_list_int32(TestOutputVisitorData *data, const void *unused) { test_native_list(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S32); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestOutputVisitorData *VAR_0, const void *VAR_1) { test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_S32); }
[ "static void FUNC_0(TestOutputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "test_native_list(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_S32);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
16,745
static void blockdev_mirror_common(BlockDriverState *bs, BlockDriverState *target, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, bool has_unmap, bool unmap, Error **errp) { if (!has_speed) { speed = 0; } if (!has_on_source_error) { on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_on_target_error) { on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_granularity) { granularity = 0; } if (!has_buf_size) { buf_size = 0; } if (!has_unmap) { unmap = true; } if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); return; } if (granularity & (granularity - 1)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2"); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { return; } if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_MIRROR_TARGET, errp)) { return; } if (target->blk) { error_setg(errp, "Cannot mirror to an attached block device"); return; } if (!bs->backing && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } /* pass the node name to replace to mirror start since it's loose coupling * and will allow to check whether the node still exist at mirror completion */ mirror_start(bs, target, has_replaces ? replaces : NULL, speed, granularity, buf_size, sync, on_source_error, on_target_error, unmap, block_job_cb, bs, errp); }
false
qemu
1f0c461b82d5ec2664ca0cfc9548f80da87a8f8a
static void blockdev_mirror_common(BlockDriverState *bs, BlockDriverState *target, bool has_replaces, const char *replaces, enum MirrorSyncMode sync, bool has_speed, int64_t speed, bool has_granularity, uint32_t granularity, bool has_buf_size, int64_t buf_size, bool has_on_source_error, BlockdevOnError on_source_error, bool has_on_target_error, BlockdevOnError on_target_error, bool has_unmap, bool unmap, Error **errp) { if (!has_speed) { speed = 0; } if (!has_on_source_error) { on_source_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_on_target_error) { on_target_error = BLOCKDEV_ON_ERROR_REPORT; } if (!has_granularity) { granularity = 0; } if (!has_buf_size) { buf_size = 0; } if (!has_unmap) { unmap = true; } if (granularity != 0 && (granularity < 512 || granularity > 1048576 * 64)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "a value in range [512B, 64MB]"); return; } if (granularity & (granularity - 1)) { error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "granularity", "power of 2"); return; } if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_MIRROR_SOURCE, errp)) { return; } if (bdrv_op_is_blocked(target, BLOCK_OP_TYPE_MIRROR_TARGET, errp)) { return; } if (target->blk) { error_setg(errp, "Cannot mirror to an attached block device"); return; } if (!bs->backing && sync == MIRROR_SYNC_MODE_TOP) { sync = MIRROR_SYNC_MODE_FULL; } mirror_start(bs, target, has_replaces ? replaces : NULL, speed, granularity, buf_size, sync, on_source_error, on_target_error, unmap, block_job_cb, bs, errp); }
{ "code": [], "line_no": [] }
static void FUNC_0(BlockDriverState *VAR_0, BlockDriverState *VAR_1, bool VAR_2, const char *VAR_3, enum MirrorSyncMode VAR_4, bool VAR_5, int64_t VAR_6, bool VAR_7, uint32_t VAR_8, bool VAR_9, int64_t VAR_10, bool VAR_11, BlockdevOnError VAR_12, bool VAR_13, BlockdevOnError VAR_14, bool VAR_15, bool VAR_16, Error **VAR_17) { if (!VAR_5) { VAR_6 = 0; } if (!VAR_11) { VAR_12 = BLOCKDEV_ON_ERROR_REPORT; } if (!VAR_13) { VAR_14 = BLOCKDEV_ON_ERROR_REPORT; } if (!VAR_7) { VAR_8 = 0; } if (!VAR_9) { VAR_10 = 0; } if (!VAR_15) { VAR_16 = true; } if (VAR_8 != 0 && (VAR_8 < 512 || VAR_8 > 1048576 * 64)) { error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8", "a value in range [512B, 64MB]"); return; } if (VAR_8 & (VAR_8 - 1)) { error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, "VAR_8", "power of 2"); return; } if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_MIRROR_SOURCE, VAR_17)) { return; } if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_MIRROR_TARGET, VAR_17)) { return; } if (VAR_1->blk) { error_setg(VAR_17, "Cannot mirror to an attached block device"); return; } if (!VAR_0->backing && VAR_4 == MIRROR_SYNC_MODE_TOP) { VAR_4 = MIRROR_SYNC_MODE_FULL; } mirror_start(VAR_0, VAR_1, VAR_2 ? VAR_3 : NULL, VAR_6, VAR_8, VAR_10, VAR_4, VAR_12, VAR_14, VAR_16, block_job_cb, VAR_0, VAR_17); }
[ "static void FUNC_0(BlockDriverState *VAR_0,\nBlockDriverState *VAR_1,\nbool VAR_2, const char *VAR_3,\nenum MirrorSyncMode VAR_4,\nbool VAR_5, int64_t VAR_6,\nbool VAR_7, uint32_t VAR_8,\nbool VAR_9, int64_t VAR_10,\nbool VAR_11,\nBlockdevOnError VAR_12,\nbool VAR_13,\nBlockdevOnError VAR_14,\nbool VAR_15, bool VAR_16,\nError **VAR_17)\n{", "if (!VAR_5) {", "VAR_6 = 0;", "}", "if (!VAR_11) {", "VAR_12 = BLOCKDEV_ON_ERROR_REPORT;", "}", "if (!VAR_13) {", "VAR_14 = BLOCKDEV_ON_ERROR_REPORT;", "}", "if (!VAR_7) {", "VAR_8 = 0;", "}", "if (!VAR_9) {", "VAR_10 = 0;", "}", "if (!VAR_15) {", "VAR_16 = true;", "}", "if (VAR_8 != 0 && (VAR_8 < 512 || VAR_8 > 1048576 * 64)) {", "error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, \"VAR_8\",\n\"a value in range [512B, 64MB]\");", "return;", "}", "if (VAR_8 & (VAR_8 - 1)) {", "error_setg(VAR_17, QERR_INVALID_PARAMETER_VALUE, \"VAR_8\",\n\"power of 2\");", "return;", "}", "if (bdrv_op_is_blocked(VAR_0, BLOCK_OP_TYPE_MIRROR_SOURCE, VAR_17)) {", "return;", "}", "if (bdrv_op_is_blocked(VAR_1, BLOCK_OP_TYPE_MIRROR_TARGET, VAR_17)) {", "return;", "}", "if (VAR_1->blk) {", "error_setg(VAR_17, \"Cannot mirror to an attached block device\");", "return;", "}", "if (!VAR_0->backing && VAR_4 == MIRROR_SYNC_MODE_TOP) {", "VAR_4 = MIRROR_SYNC_MODE_FULL;", "}", "mirror_start(VAR_0, VAR_1,\nVAR_2 ? VAR_3 : NULL,\nVAR_6, VAR_8, VAR_10, VAR_4,\nVAR_12, VAR_14, VAR_16,\nblock_job_cb, VAR_0, VAR_17);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 113 ], [ 115 ], [ 117 ], [ 127, 129, 131, 133, 135 ], [ 137 ] ]
16,746
void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1) { int num = 1; unsigned int tmp = env->tlb->nb_tlb; do { tmp >>= 1; num <<= 1; } while (tmp); env->CP0_Index = (env->CP0_Index & 0x80000000) | (arg1 & (num - 1)); }
false
qemu
ba801af429aaa68f6cc03842c8b6be81a6ede65a
void helper_mtc0_index(CPUMIPSState *env, target_ulong arg1) { int num = 1; unsigned int tmp = env->tlb->nb_tlb; do { tmp >>= 1; num <<= 1; } while (tmp); env->CP0_Index = (env->CP0_Index & 0x80000000) | (arg1 & (num - 1)); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1) { int VAR_2 = 1; unsigned int VAR_3 = VAR_0->tlb->nb_tlb; do { VAR_3 >>= 1; VAR_2 <<= 1; } while (VAR_3); VAR_0->CP0_Index = (VAR_0->CP0_Index & 0x80000000) | (VAR_1 & (VAR_2 - 1)); }
[ "void FUNC_0(CPUMIPSState *VAR_0, target_ulong VAR_1)\n{", "int VAR_2 = 1;", "unsigned int VAR_3 = VAR_0->tlb->nb_tlb;", "do {", "VAR_3 >>= 1;", "VAR_2 <<= 1;", "} while (VAR_3);", "VAR_0->CP0_Index = (VAR_0->CP0_Index & 0x80000000) | (VAR_1 & (VAR_2 - 1));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ] ]
16,747
static ram_addr_t kqemu_ram_alloc(ram_addr_t size) { ram_addr_t addr; if ((last_ram_offset + size) > kqemu_phys_ram_size) { fprintf(stderr, "Not enough memory (requested_size = %" PRIu64 ", max memory = %" PRIu64 ")\n", (uint64_t)size, (uint64_t)kqemu_phys_ram_size); abort(); } addr = last_ram_offset; last_ram_offset = TARGET_PAGE_ALIGN(last_ram_offset + size); return addr; }
false
qemu
4a1418e07bdcfaa3177739e04707ecaec75d89e1
static ram_addr_t kqemu_ram_alloc(ram_addr_t size) { ram_addr_t addr; if ((last_ram_offset + size) > kqemu_phys_ram_size) { fprintf(stderr, "Not enough memory (requested_size = %" PRIu64 ", max memory = %" PRIu64 ")\n", (uint64_t)size, (uint64_t)kqemu_phys_ram_size); abort(); } addr = last_ram_offset; last_ram_offset = TARGET_PAGE_ALIGN(last_ram_offset + size); return addr; }
{ "code": [], "line_no": [] }
static ram_addr_t FUNC_0(ram_addr_t size) { ram_addr_t addr; if ((last_ram_offset + size) > kqemu_phys_ram_size) { fprintf(stderr, "Not enough memory (requested_size = %" PRIu64 ", max memory = %" PRIu64 ")\n", (uint64_t)size, (uint64_t)kqemu_phys_ram_size); abort(); } addr = last_ram_offset; last_ram_offset = TARGET_PAGE_ALIGN(last_ram_offset + size); return addr; }
[ "static ram_addr_t FUNC_0(ram_addr_t size)\n{", "ram_addr_t addr;", "if ((last_ram_offset + size) > kqemu_phys_ram_size) {", "fprintf(stderr, \"Not enough memory (requested_size = %\" PRIu64 \", max memory = %\" PRIu64 \")\\n\",\n(uint64_t)size, (uint64_t)kqemu_phys_ram_size);", "abort();", "}", "addr = last_ram_offset;", "last_ram_offset = TARGET_PAGE_ALIGN(last_ram_offset + size);", "return addr;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
16,748
void do_cpu_init(X86CPU *cpu) { CPUX86State *env = &cpu->env; int sipi = env->interrupt_request & CPU_INTERRUPT_SIPI; uint64_t pat = env->pat; cpu_reset(CPU(cpu)); env->interrupt_request = sipi; env->pat = pat; apic_init_reset(env->apic_state); env->halted = !cpu_is_bsp(env); }
false
qemu
dd673288a8ff73ad77fcc1c255486d2466a772e1
void do_cpu_init(X86CPU *cpu) { CPUX86State *env = &cpu->env; int sipi = env->interrupt_request & CPU_INTERRUPT_SIPI; uint64_t pat = env->pat; cpu_reset(CPU(cpu)); env->interrupt_request = sipi; env->pat = pat; apic_init_reset(env->apic_state); env->halted = !cpu_is_bsp(env); }
{ "code": [], "line_no": [] }
void FUNC_0(X86CPU *VAR_0) { CPUX86State *env = &VAR_0->env; int VAR_1 = env->interrupt_request & CPU_INTERRUPT_SIPI; uint64_t pat = env->pat; cpu_reset(CPU(VAR_0)); env->interrupt_request = VAR_1; env->pat = pat; apic_init_reset(env->apic_state); env->halted = !cpu_is_bsp(env); }
[ "void FUNC_0(X86CPU *VAR_0)\n{", "CPUX86State *env = &VAR_0->env;", "int VAR_1 = env->interrupt_request & CPU_INTERRUPT_SIPI;", "uint64_t pat = env->pat;", "cpu_reset(CPU(VAR_0));", "env->interrupt_request = VAR_1;", "env->pat = pat;", "apic_init_reset(env->apic_state);", "env->halted = !cpu_is_bsp(env);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
16,749
static inline int show_tags(WriterContext *wctx, AVDictionary *tags, int section_id) { AVDictionaryEntry *tag = NULL; int ret = 0; if (!tags) return 0; writer_print_section_header(wctx, section_id); while ((tag = av_dict_get(tags, "", tag, AV_DICT_IGNORE_SUFFIX))) { ret = writer_print_string(wctx, tag->key, tag->value, 0); if (ret < 0) break; } writer_print_section_footer(wctx); return ret; }
false
FFmpeg
cbba331aa02f29870581ff0b7ded7477b279ae2c
static inline int show_tags(WriterContext *wctx, AVDictionary *tags, int section_id) { AVDictionaryEntry *tag = NULL; int ret = 0; if (!tags) return 0; writer_print_section_header(wctx, section_id); while ((tag = av_dict_get(tags, "", tag, AV_DICT_IGNORE_SUFFIX))) { ret = writer_print_string(wctx, tag->key, tag->value, 0); if (ret < 0) break; } writer_print_section_footer(wctx); return ret; }
{ "code": [], "line_no": [] }
static inline int FUNC_0(WriterContext *VAR_0, AVDictionary *VAR_1, int VAR_2) { AVDictionaryEntry *tag = NULL; int VAR_3 = 0; if (!VAR_1) return 0; writer_print_section_header(VAR_0, VAR_2); while ((tag = av_dict_get(VAR_1, "", tag, AV_DICT_IGNORE_SUFFIX))) { VAR_3 = writer_print_string(VAR_0, tag->key, tag->value, 0); if (VAR_3 < 0) break; } writer_print_section_footer(VAR_0); return VAR_3; }
[ "static inline int FUNC_0(WriterContext *VAR_0, AVDictionary *VAR_1, int VAR_2)\n{", "AVDictionaryEntry *tag = NULL;", "int VAR_3 = 0;", "if (!VAR_1)\nreturn 0;", "writer_print_section_header(VAR_0, VAR_2);", "while ((tag = av_dict_get(VAR_1, \"\", tag, AV_DICT_IGNORE_SUFFIX))) {", "VAR_3 = writer_print_string(VAR_0, tag->key, tag->value, 0);", "if (VAR_3 < 0)\nbreak;", "}", "writer_print_section_footer(VAR_0);", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ] ]
16,750
static void gen_dozi(DisasContext *ctx) { target_long simm = SIMM(ctx->opcode); int l1 = gen_new_label(); int l2 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1); tcg_gen_subfi_tl(cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
false
qemu
42a268c241183877192c376d03bd9b6d527407c7
static void gen_dozi(DisasContext *ctx) { target_long simm = SIMM(ctx->opcode); int l1 = gen_new_label(); int l2 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(ctx->opcode)], simm, l1); tcg_gen_subfi_tl(cpu_gpr[rD(ctx->opcode)], simm, cpu_gpr[rA(ctx->opcode)]); tcg_gen_br(l2); gen_set_label(l1); tcg_gen_movi_tl(cpu_gpr[rD(ctx->opcode)], 0); gen_set_label(l2); if (unlikely(Rc(ctx->opcode) != 0)) gen_set_Rc0(ctx, cpu_gpr[rD(ctx->opcode)]); }
{ "code": [], "line_no": [] }
static void FUNC_0(DisasContext *VAR_0) { target_long simm = SIMM(VAR_0->opcode); int VAR_1 = gen_new_label(); int VAR_2 = gen_new_label(); tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(VAR_0->opcode)], simm, VAR_1); tcg_gen_subfi_tl(cpu_gpr[rD(VAR_0->opcode)], simm, cpu_gpr[rA(VAR_0->opcode)]); tcg_gen_br(VAR_2); gen_set_label(VAR_1); tcg_gen_movi_tl(cpu_gpr[rD(VAR_0->opcode)], 0); gen_set_label(VAR_2); if (unlikely(Rc(VAR_0->opcode) != 0)) gen_set_Rc0(VAR_0, cpu_gpr[rD(VAR_0->opcode)]); }
[ "static void FUNC_0(DisasContext *VAR_0)\n{", "target_long simm = SIMM(VAR_0->opcode);", "int VAR_1 = gen_new_label();", "int VAR_2 = gen_new_label();", "tcg_gen_brcondi_tl(TCG_COND_LT, cpu_gpr[rA(VAR_0->opcode)], simm, VAR_1);", "tcg_gen_subfi_tl(cpu_gpr[rD(VAR_0->opcode)], simm, cpu_gpr[rA(VAR_0->opcode)]);", "tcg_gen_br(VAR_2);", "gen_set_label(VAR_1);", "tcg_gen_movi_tl(cpu_gpr[rD(VAR_0->opcode)], 0);", "gen_set_label(VAR_2);", "if (unlikely(Rc(VAR_0->opcode) != 0))\ngen_set_Rc0(VAR_0, cpu_gpr[rD(VAR_0->opcode)]);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ] ]
16,751
static inline void t_gen_swapb(TCGv d, TCGv s) { TCGv t, org_s; t = tcg_temp_new(TCG_TYPE_TL); org_s = tcg_temp_new(TCG_TYPE_TL); /* d and s may refer to the same object. */ tcg_gen_mov_tl(org_s, s); tcg_gen_shli_tl(t, org_s, 8); tcg_gen_andi_tl(d, t, 0xff00ff00); tcg_gen_shri_tl(t, org_s, 8); tcg_gen_andi_tl(t, t, 0x00ff00ff); tcg_gen_or_tl(d, d, t); tcg_temp_free(t); tcg_temp_free(org_s); }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static inline void t_gen_swapb(TCGv d, TCGv s) { TCGv t, org_s; t = tcg_temp_new(TCG_TYPE_TL); org_s = tcg_temp_new(TCG_TYPE_TL); tcg_gen_mov_tl(org_s, s); tcg_gen_shli_tl(t, org_s, 8); tcg_gen_andi_tl(d, t, 0xff00ff00); tcg_gen_shri_tl(t, org_s, 8); tcg_gen_andi_tl(t, t, 0x00ff00ff); tcg_gen_or_tl(d, d, t); tcg_temp_free(t); tcg_temp_free(org_s); }
{ "code": [], "line_no": [] }
static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1) { TCGv t, org_s; t = tcg_temp_new(TCG_TYPE_TL); org_s = tcg_temp_new(TCG_TYPE_TL); tcg_gen_mov_tl(org_s, VAR_1); tcg_gen_shli_tl(t, org_s, 8); tcg_gen_andi_tl(VAR_0, t, 0xff00ff00); tcg_gen_shri_tl(t, org_s, 8); tcg_gen_andi_tl(t, t, 0x00ff00ff); tcg_gen_or_tl(VAR_0, VAR_0, t); tcg_temp_free(t); tcg_temp_free(org_s); }
[ "static inline void FUNC_0(TCGv VAR_0, TCGv VAR_1)\n{", "TCGv t, org_s;", "t = tcg_temp_new(TCG_TYPE_TL);", "org_s = tcg_temp_new(TCG_TYPE_TL);", "tcg_gen_mov_tl(org_s, VAR_1);", "tcg_gen_shli_tl(t, org_s, 8);", "tcg_gen_andi_tl(VAR_0, t, 0xff00ff00);", "tcg_gen_shri_tl(t, org_s, 8);", "tcg_gen_andi_tl(t, t, 0x00ff00ff);", "tcg_gen_or_tl(VAR_0, VAR_0, t);", "tcg_temp_free(t);", "tcg_temp_free(org_s);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
16,754
static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ if(get_rac(c, state+0)) return 0; else{ int i, e, a; e= 0; while(get_rac(c, state+1 + e)){ //1..10 e++; } assert(e<=9); a= 1; for(i=e-1; i>=0; i--){ a += a + get_rac(c, state+22 + i); //22..31 } if(is_signed && get_rac(c, state+11 + e)) //11..21 return -a; else return a; } }
true
FFmpeg
223d996aaf9f1668c28519d3d7eb756e6cdf3fcf
static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){ if(get_rac(c, state+0)) return 0; else{ int i, e, a; e= 0; while(get_rac(c, state+1 + e)){ e++; } assert(e<=9); a= 1; for(i=e-1; i>=0; i--){ a += a + get_rac(c, state+22 + i); } if(is_signed && get_rac(c, state+11 + e)) return -a; else return a; } }
{ "code": [ " assert(e<=9);" ], "line_no": [ 19 ] }
static inline int FUNC_0(RangeCoder *VAR_0, uint8_t *VAR_1, int VAR_2){ if(get_rac(VAR_0, VAR_1+0)) return 0; else{ int VAR_3, VAR_4, VAR_5; VAR_4= 0; while(get_rac(VAR_0, VAR_1+1 + VAR_4)){ VAR_4++; } assert(VAR_4<=9); VAR_5= 1; for(VAR_3=VAR_4-1; VAR_3>=0; VAR_3--){ VAR_5 += VAR_5 + get_rac(VAR_0, VAR_1+22 + VAR_3); } if(VAR_2 && get_rac(VAR_0, VAR_1+11 + VAR_4)) return -VAR_5; else return VAR_5; } }
[ "static inline int FUNC_0(RangeCoder *VAR_0, uint8_t *VAR_1, int VAR_2){", "if(get_rac(VAR_0, VAR_1+0))\nreturn 0;", "else{", "int VAR_3, VAR_4, VAR_5;", "VAR_4= 0;", "while(get_rac(VAR_0, VAR_1+1 + VAR_4)){", "VAR_4++;", "}", "assert(VAR_4<=9);", "VAR_5= 1;", "for(VAR_3=VAR_4-1; VAR_3>=0; VAR_3--){", "VAR_5 += VAR_5 + get_rac(VAR_0, VAR_1+22 + VAR_3);", "}", "if(VAR_2 && get_rac(VAR_0, VAR_1+11 + VAR_4))\nreturn -VAR_5;", "else\nreturn VAR_5;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ] ]
16,756
static int asink_query_formats(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layouts = NULL; unsigned i; int ret; CHECK_LIST_SIZE(sample_fmts) CHECK_LIST_SIZE(sample_rates) CHECK_LIST_SIZE(channel_layouts) CHECK_LIST_SIZE(channel_counts) if (buf->sample_fmts_size) { for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++) if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) return ret; ff_set_common_formats(ctx, formats); } if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++) if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) return ret; for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) return ret; if (buf->all_channel_counts) { if (layouts) av_log(ctx, AV_LOG_WARNING, "Conflicting all_channel_counts and list in options\n"); else if (!(layouts = ff_all_channel_counts())) return AVERROR(ENOMEM); } ff_set_common_channel_layouts(ctx, layouts); } if (buf->sample_rates_size) { formats = NULL; for (i = 0; i < NB_ITEMS(buf->sample_rates); i++) if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) return ret; ff_set_common_samplerates(ctx, formats); } return 0; }
true
FFmpeg
fd7a7e11b94b12259c6f1e375da15298cbc37e83
static int asink_query_formats(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layouts = NULL; unsigned i; int ret; CHECK_LIST_SIZE(sample_fmts) CHECK_LIST_SIZE(sample_rates) CHECK_LIST_SIZE(channel_layouts) CHECK_LIST_SIZE(channel_counts) if (buf->sample_fmts_size) { for (i = 0; i < NB_ITEMS(buf->sample_fmts); i++) if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0) return ret; ff_set_common_formats(ctx, formats); } if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { for (i = 0; i < NB_ITEMS(buf->channel_layouts); i++) if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0) return ret; for (i = 0; i < NB_ITEMS(buf->channel_counts); i++) if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0) return ret; if (buf->all_channel_counts) { if (layouts) av_log(ctx, AV_LOG_WARNING, "Conflicting all_channel_counts and list in options\n"); else if (!(layouts = ff_all_channel_counts())) return AVERROR(ENOMEM); } ff_set_common_channel_layouts(ctx, layouts); } if (buf->sample_rates_size) { formats = NULL; for (i = 0; i < NB_ITEMS(buf->sample_rates); i++) if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0) return ret; ff_set_common_samplerates(ctx, formats); } return 0; }
{ "code": [ " if ((ret = ff_add_format(&formats, buf->sample_fmts[i])) < 0)", " if ((ret = ff_add_channel_layout(&layouts, buf->channel_layouts[i])) < 0)", " if ((ret = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[i]))) < 0)", " if ((ret = ff_add_format(&formats, buf->sample_rates[i])) < 0)" ], "line_no": [ 31, 47, 53, 83 ] }
static int FUNC_0(AVFilterContext *VAR_0) { BufferSinkContext *buf = VAR_0->priv; AVFilterFormats *formats = NULL; AVFilterChannelLayouts *layouts = NULL; unsigned VAR_1; int VAR_2; CHECK_LIST_SIZE(sample_fmts) CHECK_LIST_SIZE(sample_rates) CHECK_LIST_SIZE(channel_layouts) CHECK_LIST_SIZE(channel_counts) if (buf->sample_fmts_size) { for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->sample_fmts); VAR_1++) if ((VAR_2 = ff_add_format(&formats, buf->sample_fmts[VAR_1])) < 0) return VAR_2; ff_set_common_formats(VAR_0, formats); } if (buf->channel_layouts_size || buf->channel_counts_size || buf->all_channel_counts) { for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->channel_layouts); VAR_1++) if ((VAR_2 = ff_add_channel_layout(&layouts, buf->channel_layouts[VAR_1])) < 0) return VAR_2; for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->channel_counts); VAR_1++) if ((VAR_2 = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[VAR_1]))) < 0) return VAR_2; if (buf->all_channel_counts) { if (layouts) av_log(VAR_0, AV_LOG_WARNING, "Conflicting all_channel_counts and list in options\n"); else if (!(layouts = ff_all_channel_counts())) return AVERROR(ENOMEM); } ff_set_common_channel_layouts(VAR_0, layouts); } if (buf->sample_rates_size) { formats = NULL; for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->sample_rates); VAR_1++) if ((VAR_2 = ff_add_format(&formats, buf->sample_rates[VAR_1])) < 0) return VAR_2; ff_set_common_samplerates(VAR_0, formats); } return 0; }
[ "static int FUNC_0(AVFilterContext *VAR_0)\n{", "BufferSinkContext *buf = VAR_0->priv;", "AVFilterFormats *formats = NULL;", "AVFilterChannelLayouts *layouts = NULL;", "unsigned VAR_1;", "int VAR_2;", "CHECK_LIST_SIZE(sample_fmts)\nCHECK_LIST_SIZE(sample_rates)\nCHECK_LIST_SIZE(channel_layouts)\nCHECK_LIST_SIZE(channel_counts)\nif (buf->sample_fmts_size) {", "for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->sample_fmts); VAR_1++)", "if ((VAR_2 = ff_add_format(&formats, buf->sample_fmts[VAR_1])) < 0)\nreturn VAR_2;", "ff_set_common_formats(VAR_0, formats);", "}", "if (buf->channel_layouts_size || buf->channel_counts_size ||\nbuf->all_channel_counts) {", "for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->channel_layouts); VAR_1++)", "if ((VAR_2 = ff_add_channel_layout(&layouts, buf->channel_layouts[VAR_1])) < 0)\nreturn VAR_2;", "for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->channel_counts); VAR_1++)", "if ((VAR_2 = ff_add_channel_layout(&layouts, FF_COUNT2LAYOUT(buf->channel_counts[VAR_1]))) < 0)\nreturn VAR_2;", "if (buf->all_channel_counts) {", "if (layouts)\nav_log(VAR_0, AV_LOG_WARNING,\n\"Conflicting all_channel_counts and list in options\\n\");", "else if (!(layouts = ff_all_channel_counts()))\nreturn AVERROR(ENOMEM);", "}", "ff_set_common_channel_layouts(VAR_0, layouts);", "}", "if (buf->sample_rates_size) {", "formats = NULL;", "for (VAR_1 = 0; VAR_1 < NB_ITEMS(buf->sample_rates); VAR_1++)", "if ((VAR_2 = ff_add_format(&formats, buf->sample_rates[VAR_1])) < 0)\nreturn VAR_2;", "ff_set_common_samplerates(VAR_0, formats);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17, 19, 21, 23, 27 ], [ 29 ], [ 31, 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53, 55 ], [ 57 ], [ 59, 61, 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ] ]
16,757
static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFPackage *package = arg; switch(tag) { case 0x4403: package->tracks_count = avio_rb32(pb); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; avio_skip(pb, 4); /* useless size of objects, always 16 according to specs */ avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; case 0x4401: /* UMID, only get last 16 bytes */ avio_skip(pb, 16); avio_read(pb, package->package_uid, 16); break; case 0x4701: avio_read(pb, package->descriptor_ref, 16); break; } return 0; }
true
FFmpeg
fd34dbea58e097609ff09cf7dcc59f74930195d3
static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid) { MXFPackage *package = arg; switch(tag) { case 0x4403: package->tracks_count = avio_rb32(pb); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; avio_skip(pb, 4); avio_read(pb, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; case 0x4401: avio_skip(pb, 16); avio_read(pb, package->package_uid, 16); break; case 0x4701: avio_read(pb, package->descriptor_ref, 16); break; } return 0; }
{ "code": [ "static int mxf_read_source_package(void *arg, AVIOContext *pb, int tag, int size, UID uid)" ], "line_no": [ 1 ] }
static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4) { MXFPackage *package = VAR_0; switch(VAR_2) { case 0x4403: package->tracks_count = avio_rb32(VAR_1); if (package->tracks_count >= UINT_MAX / sizeof(UID)) return -1; package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID)); if (!package->tracks_refs) return -1; avio_skip(VAR_1, 4); avio_read(VAR_1, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID)); break; case 0x4401: avio_skip(VAR_1, 16); avio_read(VAR_1, package->package_uid, 16); break; case 0x4701: avio_read(VAR_1, package->descriptor_ref, 16); break; } return 0; }
[ "static int FUNC_0(void *VAR_0, AVIOContext *VAR_1, int VAR_2, int VAR_3, UID VAR_4)\n{", "MXFPackage *package = VAR_0;", "switch(VAR_2) {", "case 0x4403:\npackage->tracks_count = avio_rb32(VAR_1);", "if (package->tracks_count >= UINT_MAX / sizeof(UID))\nreturn -1;", "package->tracks_refs = av_malloc(package->tracks_count * sizeof(UID));", "if (!package->tracks_refs)\nreturn -1;", "avio_skip(VAR_1, 4);", "avio_read(VAR_1, (uint8_t *)package->tracks_refs, package->tracks_count * sizeof(UID));", "break;", "case 0x4401:\navio_skip(VAR_1, 16);", "avio_read(VAR_1, package->package_uid, 16);", "break;", "case 0x4701:\navio_read(VAR_1, package->descriptor_ref, 16);", "break;", "}", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11 ], [ 13, 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 33 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
16,760
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size) { int ret = 0; uint8_t *p = *buf; int64_t len = 0; while (bytestream2_get_bytes_left(gb) > 2) { uint8_t s = bytestream2_get_byte(gb); if (s < LZF_LITERAL_MAX) { s++; if (s > *size - len) { *size += *size /2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } bytestream2_get_buffer(gb, p, s); p += s; len += s; } else { int l = 2 + (s >> 5); int off = ((s & 0x1f) << 8) + 1; if (l == LZF_LONG_BACKREF) l += bytestream2_get_byte(gb); off += bytestream2_get_byte(gb); if (off > len) return AVERROR_INVALIDDATA; if (l > *size - len) { *size += *size / 2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } av_memcpy_backptr(p, off, l); p += l; len += l; } } *size = len; return 0; }
true
FFmpeg
bb6a7b6f75ac544c956e3eefee297700ef4d3468
int ff_lzf_uncompress(GetByteContext *gb, uint8_t **buf, int64_t *size) { int ret = 0; uint8_t *p = *buf; int64_t len = 0; while (bytestream2_get_bytes_left(gb) > 2) { uint8_t s = bytestream2_get_byte(gb); if (s < LZF_LITERAL_MAX) { s++; if (s > *size - len) { *size += *size /2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } bytestream2_get_buffer(gb, p, s); p += s; len += s; } else { int l = 2 + (s >> 5); int off = ((s & 0x1f) << 8) + 1; if (l == LZF_LONG_BACKREF) l += bytestream2_get_byte(gb); off += bytestream2_get_byte(gb); if (off > len) return AVERROR_INVALIDDATA; if (l > *size - len) { *size += *size / 2; ret = av_reallocp(buf, *size); if (ret < 0) return ret; } av_memcpy_backptr(p, off, l); p += l; len += l; } } *size = len; return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(GetByteContext *VAR_0, uint8_t **VAR_1, int64_t *VAR_2) { int VAR_3 = 0; uint8_t *p = *VAR_1; int64_t len = 0; while (bytestream2_get_bytes_left(VAR_0) > 2) { uint8_t s = bytestream2_get_byte(VAR_0); if (s < LZF_LITERAL_MAX) { s++; if (s > *VAR_2 - len) { *VAR_2 += *VAR_2 /2; VAR_3 = av_reallocp(VAR_1, *VAR_2); if (VAR_3 < 0) return VAR_3; } bytestream2_get_buffer(VAR_0, p, s); p += s; len += s; } else { int VAR_4 = 2 + (s >> 5); int VAR_5 = ((s & 0x1f) << 8) + 1; if (VAR_4 == LZF_LONG_BACKREF) VAR_4 += bytestream2_get_byte(VAR_0); VAR_5 += bytestream2_get_byte(VAR_0); if (VAR_5 > len) return AVERROR_INVALIDDATA; if (VAR_4 > *VAR_2 - len) { *VAR_2 += *VAR_2 / 2; VAR_3 = av_reallocp(VAR_1, *VAR_2); if (VAR_3 < 0) return VAR_3; } av_memcpy_backptr(p, VAR_5, VAR_4); p += VAR_4; len += VAR_4; } } *VAR_2 = len; return 0; }
[ "int FUNC_0(GetByteContext *VAR_0, uint8_t **VAR_1, int64_t *VAR_2)\n{", "int VAR_3 = 0;", "uint8_t *p = *VAR_1;", "int64_t len = 0;", "while (bytestream2_get_bytes_left(VAR_0) > 2) {", "uint8_t s = bytestream2_get_byte(VAR_0);", "if (s < LZF_LITERAL_MAX) {", "s++;", "if (s > *VAR_2 - len) {", "*VAR_2 += *VAR_2 /2;", "VAR_3 = av_reallocp(VAR_1, *VAR_2);", "if (VAR_3 < 0)\nreturn VAR_3;", "}", "bytestream2_get_buffer(VAR_0, p, s);", "p += s;", "len += s;", "} else {", "int VAR_4 = 2 + (s >> 5);", "int VAR_5 = ((s & 0x1f) << 8) + 1;", "if (VAR_4 == LZF_LONG_BACKREF)\nVAR_4 += bytestream2_get_byte(VAR_0);", "VAR_5 += bytestream2_get_byte(VAR_0);", "if (VAR_5 > len)\nreturn AVERROR_INVALIDDATA;", "if (VAR_4 > *VAR_2 - len) {", "*VAR_2 += *VAR_2 / 2;", "VAR_3 = av_reallocp(VAR_1, *VAR_2);", "if (VAR_3 < 0)\nreturn VAR_3;", "}", "av_memcpy_backptr(p, VAR_5, VAR_4);", "p += VAR_4;", "len += VAR_4;", "}", "}", "*VAR_2 = len;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 34 ], [ 38 ], [ 40 ], [ 42 ], [ 44 ], [ 46 ], [ 48 ], [ 52, 54 ], [ 58 ], [ 62, 64 ], [ 68 ], [ 70 ], [ 72 ], [ 74, 76 ], [ 79 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 101 ], [ 103 ] ]
16,761
static int inject_fake_duration_metadata(RTMPContext *rt) { // We need to insert the metdata packet directly after the FLV // header, i.e. we need to move all other already read data by the // size of our fake metadata packet. uint8_t* p; // Keep old flv_data pointer uint8_t* old_flv_data = rt->flv_data; // Allocate a new flv_data pointer with enough space for the additional package if (!(rt->flv_data = av_malloc(rt->flv_size + 55))) { rt->flv_data = old_flv_data; return AVERROR(ENOMEM); } // Copy FLV header memcpy(rt->flv_data, old_flv_data, 13); // Copy remaining packets memcpy(rt->flv_data + 13 + 55, old_flv_data + 13, rt->flv_size - 13); // Increase the size by the injected packet rt->flv_size += 55; // Delete the old FLV data av_free(old_flv_data); p = rt->flv_data + 13; bytestream_put_byte(&p, FLV_TAG_TYPE_META); bytestream_put_be24(&p, 40); // size of data part (sum of all parts below) bytestream_put_be24(&p, 0); // timestamp bytestream_put_be32(&p, 0); // reserved // first event name as a string bytestream_put_byte(&p, AMF_DATA_TYPE_STRING); // "onMetaData" as AMF string bytestream_put_be16(&p, 10); bytestream_put_buffer(&p, "onMetaData", 10); // mixed array (hash) with size and string/type/data tuples bytestream_put_byte(&p, AMF_DATA_TYPE_MIXEDARRAY); bytestream_put_be32(&p, 1); // metadata_count // "duration" as AMF string bytestream_put_be16(&p, 8); bytestream_put_buffer(&p, "duration", 8); bytestream_put_byte(&p, AMF_DATA_TYPE_NUMBER); bytestream_put_be64(&p, av_double2int(rt->duration)); // Finalise object bytestream_put_be16(&p, 0); // Empty string bytestream_put_byte(&p, AMF_END_OF_OBJECT); bytestream_put_be32(&p, 40); // size of data part (sum of all parts below) return 0; }
true
FFmpeg
e55376a1fd5abebbb0a082aa20739d58c2260a37
static int inject_fake_duration_metadata(RTMPContext *rt) { uint8_t* p; uint8_t* old_flv_data = rt->flv_data; if (!(rt->flv_data = av_malloc(rt->flv_size + 55))) { rt->flv_data = old_flv_data; return AVERROR(ENOMEM); } memcpy(rt->flv_data, old_flv_data, 13); memcpy(rt->flv_data + 13 + 55, old_flv_data + 13, rt->flv_size - 13); rt->flv_size += 55; av_free(old_flv_data); p = rt->flv_data + 13; bytestream_put_byte(&p, FLV_TAG_TYPE_META); bytestream_put_be24(&p, 40); bytestream_put_be24(&p, 0); bytestream_put_be32(&p, 0); bytestream_put_byte(&p, AMF_DATA_TYPE_STRING); bytestream_put_be16(&p, 10); bytestream_put_buffer(&p, "onMetaData", 10); bytestream_put_byte(&p, AMF_DATA_TYPE_MIXEDARRAY); bytestream_put_be32(&p, 1); bytestream_put_be16(&p, 8); bytestream_put_buffer(&p, "duration", 8); bytestream_put_byte(&p, AMF_DATA_TYPE_NUMBER); bytestream_put_be64(&p, av_double2int(rt->duration)); bytestream_put_be16(&p, 0); bytestream_put_byte(&p, AMF_END_OF_OBJECT); bytestream_put_be32(&p, 40); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(RTMPContext *VAR_0) { uint8_t* p; uint8_t* old_flv_data = VAR_0->flv_data; if (!(VAR_0->flv_data = av_malloc(VAR_0->flv_size + 55))) { VAR_0->flv_data = old_flv_data; return AVERROR(ENOMEM); } memcpy(VAR_0->flv_data, old_flv_data, 13); memcpy(VAR_0->flv_data + 13 + 55, old_flv_data + 13, VAR_0->flv_size - 13); VAR_0->flv_size += 55; av_free(old_flv_data); p = VAR_0->flv_data + 13; bytestream_put_byte(&p, FLV_TAG_TYPE_META); bytestream_put_be24(&p, 40); bytestream_put_be24(&p, 0); bytestream_put_be32(&p, 0); bytestream_put_byte(&p, AMF_DATA_TYPE_STRING); bytestream_put_be16(&p, 10); bytestream_put_buffer(&p, "onMetaData", 10); bytestream_put_byte(&p, AMF_DATA_TYPE_MIXEDARRAY); bytestream_put_be32(&p, 1); bytestream_put_be16(&p, 8); bytestream_put_buffer(&p, "duration", 8); bytestream_put_byte(&p, AMF_DATA_TYPE_NUMBER); bytestream_put_be64(&p, av_double2int(VAR_0->duration)); bytestream_put_be16(&p, 0); bytestream_put_byte(&p, AMF_END_OF_OBJECT); bytestream_put_be32(&p, 40); return 0; }
[ "static int FUNC_0(RTMPContext *VAR_0)\n{", "uint8_t* p;", "uint8_t* old_flv_data = VAR_0->flv_data;", "if (!(VAR_0->flv_data = av_malloc(VAR_0->flv_size + 55))) {", "VAR_0->flv_data = old_flv_data;", "return AVERROR(ENOMEM);", "}", "memcpy(VAR_0->flv_data, old_flv_data, 13);", "memcpy(VAR_0->flv_data + 13 + 55, old_flv_data + 13, VAR_0->flv_size - 13);", "VAR_0->flv_size += 55;", "av_free(old_flv_data);", "p = VAR_0->flv_data + 13;", "bytestream_put_byte(&p, FLV_TAG_TYPE_META);", "bytestream_put_be24(&p, 40);", "bytestream_put_be24(&p, 0);", "bytestream_put_be32(&p, 0);", "bytestream_put_byte(&p, AMF_DATA_TYPE_STRING);", "bytestream_put_be16(&p, 10);", "bytestream_put_buffer(&p, \"onMetaData\", 10);", "bytestream_put_byte(&p, AMF_DATA_TYPE_MIXEDARRAY);", "bytestream_put_be32(&p, 1);", "bytestream_put_be16(&p, 8);", "bytestream_put_buffer(&p, \"duration\", 8);", "bytestream_put_byte(&p, AMF_DATA_TYPE_NUMBER);", "bytestream_put_be64(&p, av_double2int(VAR_0->duration));", "bytestream_put_be16(&p, 0);", "bytestream_put_byte(&p, AMF_END_OF_OBJECT);", "bytestream_put_be32(&p, 40);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 13 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 33 ], [ 37 ], [ 41 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 63 ], [ 67 ], [ 69 ], [ 75 ], [ 77 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 95 ], [ 97 ], [ 99 ], [ 103 ], [ 105 ] ]
16,762
static int dmg_open(BlockDriverState *bs, int flags) { BDRVDMGState *s = bs->opaque; off_t info_begin,info_end,last_in_offset,last_out_offset; uint32_t count; uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i; int64_t offset; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; /* read offset of info blocks */ offset = bdrv_getlength(bs->file); if (offset < 0) { goto fail; } offset -= 0x1d8; info_begin = read_off(bs, offset); if (info_begin == 0) { goto fail; } if (read_uint32(bs, info_begin) != 0x100) { goto fail; } count = read_uint32(bs, info_begin + 4); if (count == 0) { goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; /* read offsets */ last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; count = read_uint32(bs, offset); if(count==0) goto fail; offset += 4; type = read_uint32(bs, offset); if (type == 0x6d697368 && count >= 244) { int new_size, chunk_count; offset += 4; offset += 200; chunk_count = (count-204)/40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size/2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) { s->types[i] = read_uint32(bs, offset); offset += 4; if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) { if(s->types[i]==0xffffffff) { last_in_offset = s->offsets[i-1]+s->lengths[i-1]; last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; s->sectors[i] = last_out_offset+read_off(bs, offset); offset += 8; s->sectorcounts[i] = read_off(bs, offset); offset += 8; s->offsets[i] = last_in_offset+read_off(bs, offset); offset += 8; s->lengths[i] = read_off(bs, offset); offset += 8; if(s->lengths[i]>max_compressed_size) max_compressed_size = s->lengths[i]; if(s->sectorcounts[i]>max_sectors_per_chunk) max_sectors_per_chunk = s->sectorcounts[i]; } s->n_chunks+=chunk_count; } } /* initialize zlib engine */ s->compressed_chunk = g_malloc(max_compressed_size+1); s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk); if(inflateInit(&s->zstream) != Z_OK) goto fail; s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: return -1; }
true
qemu
69d34a360dfe773e17e72c76d15931c9b9d190f6
static int dmg_open(BlockDriverState *bs, int flags) { BDRVDMGState *s = bs->opaque; off_t info_begin,info_end,last_in_offset,last_out_offset; uint32_t count; uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i; int64_t offset; bs->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; offset = bdrv_getlength(bs->file); if (offset < 0) { goto fail; } offset -= 0x1d8; info_begin = read_off(bs, offset); if (info_begin == 0) { goto fail; } if (read_uint32(bs, info_begin) != 0x100) { goto fail; } count = read_uint32(bs, info_begin + 4); if (count == 0) { goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; count = read_uint32(bs, offset); if(count==0) goto fail; offset += 4; type = read_uint32(bs, offset); if (type == 0x6d697368 && count >= 244) { int new_size, chunk_count; offset += 4; offset += 200; chunk_count = (count-204)/40; new_size = sizeof(uint64_t) * (s->n_chunks + chunk_count); s->types = g_realloc(s->types, new_size/2); s->offsets = g_realloc(s->offsets, new_size); s->lengths = g_realloc(s->lengths, new_size); s->sectors = g_realloc(s->sectors, new_size); s->sectorcounts = g_realloc(s->sectorcounts, new_size); for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) { s->types[i] = read_uint32(bs, offset); offset += 4; if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) { if(s->types[i]==0xffffffff) { last_in_offset = s->offsets[i-1]+s->lengths[i-1]; last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1]; } chunk_count--; i--; offset += 36; continue; } offset += 4; s->sectors[i] = last_out_offset+read_off(bs, offset); offset += 8; s->sectorcounts[i] = read_off(bs, offset); offset += 8; s->offsets[i] = last_in_offset+read_off(bs, offset); offset += 8; s->lengths[i] = read_off(bs, offset); offset += 8; if(s->lengths[i]>max_compressed_size) max_compressed_size = s->lengths[i]; if(s->sectorcounts[i]>max_sectors_per_chunk) max_sectors_per_chunk = s->sectorcounts[i]; } s->n_chunks+=chunk_count; } } s->compressed_chunk = g_malloc(max_compressed_size+1); s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk); if(inflateInit(&s->zstream) != Z_OK) goto fail; s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: return -1; }
{ "code": [ " off_t info_begin,info_end,last_in_offset,last_out_offset;", " uint32_t count;", " info_begin = read_off(bs, offset);", " if (info_begin == 0) {", "\tgoto fail;", " if (read_uint32(bs, info_begin) != 0x100) {", " count = read_uint32(bs, info_begin + 4);", " if (count == 0) {", "\tcount = read_uint32(bs, offset);", "\tif(count==0)", "\t goto fail;", "\ttype = read_uint32(bs, offset);", "\t for(i=s->n_chunks;i<s->n_chunks+chunk_count;i++) {", "\t\ts->types[i] = read_uint32(bs, offset);", "\t\ts->sectors[i] = last_out_offset+read_off(bs, offset);", "\t\toffset += 8;", "\t\ts->sectorcounts[i] = read_off(bs, offset);", "\t\toffset += 8;", "\t\ts->offsets[i] = last_in_offset+read_off(bs, offset);", "\t\toffset += 8;", "\t\ts->lengths[i] = read_off(bs, offset);", "\t\toffset += 8;", " if(inflateInit(&s->zstream) != Z_OK)", "\tgoto fail;", " return -1;" ], "line_no": [ 7, 9, 39, 41, 43, 49, 57, 59, 83, 85, 87, 93, 123, 125, 153, 155, 159, 155, 165, 155, 171, 155, 201, 43, 217 ] }
static int FUNC_0(BlockDriverState *VAR_0, int VAR_1) { BDRVDMGState *s = VAR_0->opaque; off_t info_begin,info_end,last_in_offset,last_out_offset; uint32_t count; uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i; int64_t offset; VAR_0->read_only = 1; s->n_chunks = 0; s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL; offset = bdrv_getlength(VAR_0->file); if (offset < 0) { goto fail; } offset -= 0x1d8; info_begin = read_off(VAR_0, offset); if (info_begin == 0) { goto fail; } if (read_uint32(VAR_0, info_begin) != 0x100) { goto fail; } count = read_uint32(VAR_0, info_begin + 4); if (count == 0) { goto fail; } info_end = info_begin + count; offset = info_begin + 0x100; last_in_offset = last_out_offset = 0; while (offset < info_end) { uint32_t type; count = read_uint32(VAR_0, offset); if(count==0) goto fail; offset += 4; type = read_uint32(VAR_0, offset); if (type == 0x6d697368 && count >= 244) { int VAR_2, VAR_3; offset += 4; offset += 200; VAR_3 = (count-204)/40; VAR_2 = sizeof(uint64_t) * (s->n_chunks + VAR_3); s->types = g_realloc(s->types, VAR_2/2); s->offsets = g_realloc(s->offsets, VAR_2); s->lengths = g_realloc(s->lengths, VAR_2); s->sectors = g_realloc(s->sectors, VAR_2); s->sectorcounts = g_realloc(s->sectorcounts, VAR_2); for(i=s->n_chunks;i<s->n_chunks+VAR_3;i++) { s->types[i] = read_uint32(VAR_0, offset); offset += 4; if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) { if(s->types[i]==0xffffffff) { last_in_offset = s->offsets[i-1]+s->lengths[i-1]; last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1]; } VAR_3--; i--; offset += 36; continue; } offset += 4; s->sectors[i] = last_out_offset+read_off(VAR_0, offset); offset += 8; s->sectorcounts[i] = read_off(VAR_0, offset); offset += 8; s->offsets[i] = last_in_offset+read_off(VAR_0, offset); offset += 8; s->lengths[i] = read_off(VAR_0, offset); offset += 8; if(s->lengths[i]>max_compressed_size) max_compressed_size = s->lengths[i]; if(s->sectorcounts[i]>max_sectors_per_chunk) max_sectors_per_chunk = s->sectorcounts[i]; } s->n_chunks+=VAR_3; } } s->compressed_chunk = g_malloc(max_compressed_size+1); s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk); if(inflateInit(&s->zstream) != Z_OK) goto fail; s->current_chunk = s->n_chunks; qemu_co_mutex_init(&s->lock); return 0; fail: return -1; }
[ "static int FUNC_0(BlockDriverState *VAR_0, int VAR_1)\n{", "BDRVDMGState *s = VAR_0->opaque;", "off_t info_begin,info_end,last_in_offset,last_out_offset;", "uint32_t count;", "uint32_t max_compressed_size=1,max_sectors_per_chunk=1,i;", "int64_t offset;", "VAR_0->read_only = 1;", "s->n_chunks = 0;", "s->offsets = s->lengths = s->sectors = s->sectorcounts = NULL;", "offset = bdrv_getlength(VAR_0->file);", "if (offset < 0) {", "goto fail;", "}", "offset -= 0x1d8;", "info_begin = read_off(VAR_0, offset);", "if (info_begin == 0) {", "goto fail;", "}", "if (read_uint32(VAR_0, info_begin) != 0x100) {", "goto fail;", "}", "count = read_uint32(VAR_0, info_begin + 4);", "if (count == 0) {", "goto fail;", "}", "info_end = info_begin + count;", "offset = info_begin + 0x100;", "last_in_offset = last_out_offset = 0;", "while (offset < info_end) {", "uint32_t type;", "count = read_uint32(VAR_0, offset);", "if(count==0)\ngoto fail;", "offset += 4;", "type = read_uint32(VAR_0, offset);", "if (type == 0x6d697368 && count >= 244) {", "int VAR_2, VAR_3;", "offset += 4;", "offset += 200;", "VAR_3 = (count-204)/40;", "VAR_2 = sizeof(uint64_t) * (s->n_chunks + VAR_3);", "s->types = g_realloc(s->types, VAR_2/2);", "s->offsets = g_realloc(s->offsets, VAR_2);", "s->lengths = g_realloc(s->lengths, VAR_2);", "s->sectors = g_realloc(s->sectors, VAR_2);", "s->sectorcounts = g_realloc(s->sectorcounts, VAR_2);", "for(i=s->n_chunks;i<s->n_chunks+VAR_3;i++) {", "s->types[i] = read_uint32(VAR_0, offset);", "offset += 4;", "if(s->types[i]!=0x80000005 && s->types[i]!=1 && s->types[i]!=2) {", "if(s->types[i]==0xffffffff) {", "last_in_offset = s->offsets[i-1]+s->lengths[i-1];", "last_out_offset = s->sectors[i-1]+s->sectorcounts[i-1];", "}", "VAR_3--;", "i--;", "offset += 36;", "continue;", "}", "offset += 4;", "s->sectors[i] = last_out_offset+read_off(VAR_0, offset);", "offset += 8;", "s->sectorcounts[i] = read_off(VAR_0, offset);", "offset += 8;", "s->offsets[i] = last_in_offset+read_off(VAR_0, offset);", "offset += 8;", "s->lengths[i] = read_off(VAR_0, offset);", "offset += 8;", "if(s->lengths[i]>max_compressed_size)\nmax_compressed_size = s->lengths[i];", "if(s->sectorcounts[i]>max_sectors_per_chunk)\nmax_sectors_per_chunk = s->sectorcounts[i];", "}", "s->n_chunks+=VAR_3;", "}", "}", "s->compressed_chunk = g_malloc(max_compressed_size+1);", "s->uncompressed_chunk = g_malloc(512*max_sectors_per_chunk);", "if(inflateInit(&s->zstream) != Z_OK)\ngoto fail;", "s->current_chunk = s->n_chunks;", "qemu_co_mutex_init(&s->lock);", "return 0;", "fail:\nreturn -1;", "}" ]
[ 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 165 ], [ 167 ], [ 171 ], [ 173 ], [ 177, 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 197 ], [ 199 ], [ 201, 203 ], [ 207 ], [ 211 ], [ 213 ], [ 215, 217 ], [ 219 ] ]
16,763
static void idct32(int *out, int *tab) { int i, j; int *t, *t1, xr; const int *xp = costab32; for(j=31;j>=3;j-=2) tab[j] += tab[j - 2]; t = tab + 30; t1 = tab + 2; do { t[0] += t[-4]; t[1] += t[1 - 4]; t -= 4; } while (t != t1); t = tab + 28; t1 = tab + 4; do { t[0] += t[-8]; t[1] += t[1-8]; t[2] += t[2-8]; t[3] += t[3-8]; t -= 8; } while (t != t1); t = tab; t1 = tab + 32; do { t[ 3] = -t[ 3]; t[ 6] = -t[ 6]; t[11] = -t[11]; t[12] = -t[12]; t[13] = -t[13]; t[15] = -t[15]; t += 16; } while (t != t1); t = tab; t1 = tab + 8; do { int x1, x2, x3, x4; x3 = MUL(t[16], FIX(SQRT2*0.5)); x4 = t[0] - x3; x3 = t[0] + x3; x2 = MUL(-(t[24] + t[8]), FIX(SQRT2*0.5)); x1 = MUL((t[8] - x2), xp[0]); x2 = MUL((t[8] + x2), xp[1]); t[ 0] = x3 + x1; t[ 8] = x4 - x2; t[16] = x4 + x2; t[24] = x3 - x1; t++; } while (t != t1); xp += 2; t = tab; t1 = tab + 4; do { xr = MUL(t[28],xp[0]); t[28] = (t[0] - xr); t[0] = (t[0] + xr); xr = MUL(t[4],xp[1]); t[ 4] = (t[24] - xr); t[24] = (t[24] + xr); xr = MUL(t[20],xp[2]); t[20] = (t[8] - xr); t[ 8] = (t[8] + xr); xr = MUL(t[12],xp[3]); t[12] = (t[16] - xr); t[16] = (t[16] + xr); t++; } while (t != t1); xp += 4; for (i = 0; i < 4; i++) { xr = MUL(tab[30-i*4],xp[0]); tab[30-i*4] = (tab[i*4] - xr); tab[ i*4] = (tab[i*4] + xr); xr = MUL(tab[ 2+i*4],xp[1]); tab[ 2+i*4] = (tab[28-i*4] - xr); tab[28-i*4] = (tab[28-i*4] + xr); xr = MUL(tab[31-i*4],xp[0]); tab[31-i*4] = (tab[1+i*4] - xr); tab[ 1+i*4] = (tab[1+i*4] + xr); xr = MUL(tab[ 3+i*4],xp[1]); tab[ 3+i*4] = (tab[29-i*4] - xr); tab[29-i*4] = (tab[29-i*4] + xr); xp += 2; } t = tab + 30; t1 = tab + 1; do { xr = MUL(t1[0], *xp); t1[0] = (t[0] - xr); t[0] = (t[0] + xr); t -= 2; t1 += 2; xp++; } while (t >= tab); for(i=0;i<32;i++) { out[i] = tab[bitinv32[i]]; } }
false
FFmpeg
11f0acf829e26279c5f2a414c6860bd4933f29af
static void idct32(int *out, int *tab) { int i, j; int *t, *t1, xr; const int *xp = costab32; for(j=31;j>=3;j-=2) tab[j] += tab[j - 2]; t = tab + 30; t1 = tab + 2; do { t[0] += t[-4]; t[1] += t[1 - 4]; t -= 4; } while (t != t1); t = tab + 28; t1 = tab + 4; do { t[0] += t[-8]; t[1] += t[1-8]; t[2] += t[2-8]; t[3] += t[3-8]; t -= 8; } while (t != t1); t = tab; t1 = tab + 32; do { t[ 3] = -t[ 3]; t[ 6] = -t[ 6]; t[11] = -t[11]; t[12] = -t[12]; t[13] = -t[13]; t[15] = -t[15]; t += 16; } while (t != t1); t = tab; t1 = tab + 8; do { int x1, x2, x3, x4; x3 = MUL(t[16], FIX(SQRT2*0.5)); x4 = t[0] - x3; x3 = t[0] + x3; x2 = MUL(-(t[24] + t[8]), FIX(SQRT2*0.5)); x1 = MUL((t[8] - x2), xp[0]); x2 = MUL((t[8] + x2), xp[1]); t[ 0] = x3 + x1; t[ 8] = x4 - x2; t[16] = x4 + x2; t[24] = x3 - x1; t++; } while (t != t1); xp += 2; t = tab; t1 = tab + 4; do { xr = MUL(t[28],xp[0]); t[28] = (t[0] - xr); t[0] = (t[0] + xr); xr = MUL(t[4],xp[1]); t[ 4] = (t[24] - xr); t[24] = (t[24] + xr); xr = MUL(t[20],xp[2]); t[20] = (t[8] - xr); t[ 8] = (t[8] + xr); xr = MUL(t[12],xp[3]); t[12] = (t[16] - xr); t[16] = (t[16] + xr); t++; } while (t != t1); xp += 4; for (i = 0; i < 4; i++) { xr = MUL(tab[30-i*4],xp[0]); tab[30-i*4] = (tab[i*4] - xr); tab[ i*4] = (tab[i*4] + xr); xr = MUL(tab[ 2+i*4],xp[1]); tab[ 2+i*4] = (tab[28-i*4] - xr); tab[28-i*4] = (tab[28-i*4] + xr); xr = MUL(tab[31-i*4],xp[0]); tab[31-i*4] = (tab[1+i*4] - xr); tab[ 1+i*4] = (tab[1+i*4] + xr); xr = MUL(tab[ 3+i*4],xp[1]); tab[ 3+i*4] = (tab[29-i*4] - xr); tab[29-i*4] = (tab[29-i*4] + xr); xp += 2; } t = tab + 30; t1 = tab + 1; do { xr = MUL(t1[0], *xp); t1[0] = (t[0] - xr); t[0] = (t[0] + xr); t -= 2; t1 += 2; xp++; } while (t >= tab); for(i=0;i<32;i++) { out[i] = tab[bitinv32[i]]; } }
{ "code": [], "line_no": [] }
static void FUNC_0(int *VAR_0, int *VAR_1) { int VAR_2, VAR_3; int *VAR_4, *VAR_5, VAR_6; const int *VAR_7 = costab32; for(VAR_3=31;VAR_3>=3;VAR_3-=2) VAR_1[VAR_3] += VAR_1[VAR_3 - 2]; VAR_4 = VAR_1 + 30; VAR_5 = VAR_1 + 2; do { VAR_4[0] += VAR_4[-4]; VAR_4[1] += VAR_4[1 - 4]; VAR_4 -= 4; } while (VAR_4 != VAR_5); VAR_4 = VAR_1 + 28; VAR_5 = VAR_1 + 4; do { VAR_4[0] += VAR_4[-8]; VAR_4[1] += VAR_4[1-8]; VAR_4[2] += VAR_4[2-8]; VAR_4[3] += VAR_4[3-8]; VAR_4 -= 8; } while (VAR_4 != VAR_5); VAR_4 = VAR_1; VAR_5 = VAR_1 + 32; do { VAR_4[ 3] = -VAR_4[ 3]; VAR_4[ 6] = -VAR_4[ 6]; VAR_4[11] = -VAR_4[11]; VAR_4[12] = -VAR_4[12]; VAR_4[13] = -VAR_4[13]; VAR_4[15] = -VAR_4[15]; VAR_4 += 16; } while (VAR_4 != VAR_5); VAR_4 = VAR_1; VAR_5 = VAR_1 + 8; do { int VAR_8, VAR_9, VAR_10, VAR_11; VAR_10 = MUL(VAR_4[16], FIX(SQRT2*0.5)); VAR_11 = VAR_4[0] - VAR_10; VAR_10 = VAR_4[0] + VAR_10; VAR_9 = MUL(-(VAR_4[24] + VAR_4[8]), FIX(SQRT2*0.5)); VAR_8 = MUL((VAR_4[8] - VAR_9), VAR_7[0]); VAR_9 = MUL((VAR_4[8] + VAR_9), VAR_7[1]); VAR_4[ 0] = VAR_10 + VAR_8; VAR_4[ 8] = VAR_11 - VAR_9; VAR_4[16] = VAR_11 + VAR_9; VAR_4[24] = VAR_10 - VAR_8; VAR_4++; } while (VAR_4 != VAR_5); VAR_7 += 2; VAR_4 = VAR_1; VAR_5 = VAR_1 + 4; do { VAR_6 = MUL(VAR_4[28],VAR_7[0]); VAR_4[28] = (VAR_4[0] - VAR_6); VAR_4[0] = (VAR_4[0] + VAR_6); VAR_6 = MUL(VAR_4[4],VAR_7[1]); VAR_4[ 4] = (VAR_4[24] - VAR_6); VAR_4[24] = (VAR_4[24] + VAR_6); VAR_6 = MUL(VAR_4[20],VAR_7[2]); VAR_4[20] = (VAR_4[8] - VAR_6); VAR_4[ 8] = (VAR_4[8] + VAR_6); VAR_6 = MUL(VAR_4[12],VAR_7[3]); VAR_4[12] = (VAR_4[16] - VAR_6); VAR_4[16] = (VAR_4[16] + VAR_6); VAR_4++; } while (VAR_4 != VAR_5); VAR_7 += 4; for (VAR_2 = 0; VAR_2 < 4; VAR_2++) { VAR_6 = MUL(VAR_1[30-VAR_2*4],VAR_7[0]); VAR_1[30-VAR_2*4] = (VAR_1[VAR_2*4] - VAR_6); VAR_1[ VAR_2*4] = (VAR_1[VAR_2*4] + VAR_6); VAR_6 = MUL(VAR_1[ 2+VAR_2*4],VAR_7[1]); VAR_1[ 2+VAR_2*4] = (VAR_1[28-VAR_2*4] - VAR_6); VAR_1[28-VAR_2*4] = (VAR_1[28-VAR_2*4] + VAR_6); VAR_6 = MUL(VAR_1[31-VAR_2*4],VAR_7[0]); VAR_1[31-VAR_2*4] = (VAR_1[1+VAR_2*4] - VAR_6); VAR_1[ 1+VAR_2*4] = (VAR_1[1+VAR_2*4] + VAR_6); VAR_6 = MUL(VAR_1[ 3+VAR_2*4],VAR_7[1]); VAR_1[ 3+VAR_2*4] = (VAR_1[29-VAR_2*4] - VAR_6); VAR_1[29-VAR_2*4] = (VAR_1[29-VAR_2*4] + VAR_6); VAR_7 += 2; } VAR_4 = VAR_1 + 30; VAR_5 = VAR_1 + 1; do { VAR_6 = MUL(VAR_5[0], *VAR_7); VAR_5[0] = (VAR_4[0] - VAR_6); VAR_4[0] = (VAR_4[0] + VAR_6); VAR_4 -= 2; VAR_5 += 2; VAR_7++; } while (VAR_4 >= VAR_1); for(VAR_2=0;VAR_2<32;VAR_2++) { VAR_0[VAR_2] = VAR_1[bitinv32[VAR_2]]; } }
[ "static void FUNC_0(int *VAR_0, int *VAR_1)\n{", "int VAR_2, VAR_3;", "int *VAR_4, *VAR_5, VAR_6;", "const int *VAR_7 = costab32;", "for(VAR_3=31;VAR_3>=3;VAR_3-=2) VAR_1[VAR_3] += VAR_1[VAR_3 - 2];", "VAR_4 = VAR_1 + 30;", "VAR_5 = VAR_1 + 2;", "do {", "VAR_4[0] += VAR_4[-4];", "VAR_4[1] += VAR_4[1 - 4];", "VAR_4 -= 4;", "} while (VAR_4 != VAR_5);", "VAR_4 = VAR_1 + 28;", "VAR_5 = VAR_1 + 4;", "do {", "VAR_4[0] += VAR_4[-8];", "VAR_4[1] += VAR_4[1-8];", "VAR_4[2] += VAR_4[2-8];", "VAR_4[3] += VAR_4[3-8];", "VAR_4 -= 8;", "} while (VAR_4 != VAR_5);", "VAR_4 = VAR_1;", "VAR_5 = VAR_1 + 32;", "do {", "VAR_4[ 3] = -VAR_4[ 3];", "VAR_4[ 6] = -VAR_4[ 6];", "VAR_4[11] = -VAR_4[11];", "VAR_4[12] = -VAR_4[12];", "VAR_4[13] = -VAR_4[13];", "VAR_4[15] = -VAR_4[15];", "VAR_4 += 16;", "} while (VAR_4 != VAR_5);", "VAR_4 = VAR_1;", "VAR_5 = VAR_1 + 8;", "do {", "int VAR_8, VAR_9, VAR_10, VAR_11;", "VAR_10 = MUL(VAR_4[16], FIX(SQRT2*0.5));", "VAR_11 = VAR_4[0] - VAR_10;", "VAR_10 = VAR_4[0] + VAR_10;", "VAR_9 = MUL(-(VAR_4[24] + VAR_4[8]), FIX(SQRT2*0.5));", "VAR_8 = MUL((VAR_4[8] - VAR_9), VAR_7[0]);", "VAR_9 = MUL((VAR_4[8] + VAR_9), VAR_7[1]);", "VAR_4[ 0] = VAR_10 + VAR_8;", "VAR_4[ 8] = VAR_11 - VAR_9;", "VAR_4[16] = VAR_11 + VAR_9;", "VAR_4[24] = VAR_10 - VAR_8;", "VAR_4++;", "} while (VAR_4 != VAR_5);", "VAR_7 += 2;", "VAR_4 = VAR_1;", "VAR_5 = VAR_1 + 4;", "do {", "VAR_6 = MUL(VAR_4[28],VAR_7[0]);", "VAR_4[28] = (VAR_4[0] - VAR_6);", "VAR_4[0] = (VAR_4[0] + VAR_6);", "VAR_6 = MUL(VAR_4[4],VAR_7[1]);", "VAR_4[ 4] = (VAR_4[24] - VAR_6);", "VAR_4[24] = (VAR_4[24] + VAR_6);", "VAR_6 = MUL(VAR_4[20],VAR_7[2]);", "VAR_4[20] = (VAR_4[8] - VAR_6);", "VAR_4[ 8] = (VAR_4[8] + VAR_6);", "VAR_6 = MUL(VAR_4[12],VAR_7[3]);", "VAR_4[12] = (VAR_4[16] - VAR_6);", "VAR_4[16] = (VAR_4[16] + VAR_6);", "VAR_4++;", "} while (VAR_4 != VAR_5);", "VAR_7 += 4;", "for (VAR_2 = 0; VAR_2 < 4; VAR_2++) {", "VAR_6 = MUL(VAR_1[30-VAR_2*4],VAR_7[0]);", "VAR_1[30-VAR_2*4] = (VAR_1[VAR_2*4] - VAR_6);", "VAR_1[ VAR_2*4] = (VAR_1[VAR_2*4] + VAR_6);", "VAR_6 = MUL(VAR_1[ 2+VAR_2*4],VAR_7[1]);", "VAR_1[ 2+VAR_2*4] = (VAR_1[28-VAR_2*4] - VAR_6);", "VAR_1[28-VAR_2*4] = (VAR_1[28-VAR_2*4] + VAR_6);", "VAR_6 = MUL(VAR_1[31-VAR_2*4],VAR_7[0]);", "VAR_1[31-VAR_2*4] = (VAR_1[1+VAR_2*4] - VAR_6);", "VAR_1[ 1+VAR_2*4] = (VAR_1[1+VAR_2*4] + VAR_6);", "VAR_6 = MUL(VAR_1[ 3+VAR_2*4],VAR_7[1]);", "VAR_1[ 3+VAR_2*4] = (VAR_1[29-VAR_2*4] - VAR_6);", "VAR_1[29-VAR_2*4] = (VAR_1[29-VAR_2*4] + VAR_6);", "VAR_7 += 2;", "}", "VAR_4 = VAR_1 + 30;", "VAR_5 = VAR_1 + 1;", "do {", "VAR_6 = MUL(VAR_5[0], *VAR_7);", "VAR_5[0] = (VAR_4[0] - VAR_6);", "VAR_4[0] = (VAR_4[0] + VAR_6);", "VAR_4 -= 2;", "VAR_5 += 2;", "VAR_7++;", "} while (VAR_4 >= VAR_1);", "for(VAR_2=0;VAR_2<32;VAR_2++) {", "VAR_0[VAR_2] = VAR_1[bitinv32[VAR_2]];", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 147 ], [ 149 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 201 ], [ 203 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ] ]
16,764
static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { AC3DecodeContext *s = avctx->priv_data; int16_t *out_samples = (int16_t *)data; int i, blk, ch, err; /* initialize the GetBitContext with the start of valid AC-3 Frame */ if (s->input_buffer) { /* copy input buffer to decoder context to avoid reading past the end of the buffer, which can be caused by a damaged input stream. */ memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_MAX_FRAME_SIZE)); init_get_bits(&s->gbc, s->input_buffer, buf_size * 8); } else { init_get_bits(&s->gbc, buf, buf_size * 8); } /* parse the syncinfo */ err = ac3_parse_header(s); if(err) { switch(err) { case AC3_PARSE_ERROR_SYNC: av_log(avctx, AV_LOG_ERROR, "frame sync error : cannot use error concealment\n"); return -1; case AC3_PARSE_ERROR_BSID: av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); break; case AC3_PARSE_ERROR_SAMPLE_RATE: av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); break; case AC3_PARSE_ERROR_FRAME_SIZE: av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); break; case AC3_PARSE_ERROR_FRAME_TYPE: av_log(avctx, AV_LOG_ERROR, "invalid frame type\n"); break; default: av_log(avctx, AV_LOG_ERROR, "invalid header\n"); break; } } /* check that reported frame size fits in input buffer */ if(s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); return -1; } /* check for crc mismatch */ if(!err && avctx->error_resilience >= FF_ER_CAREFUL) { if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); err = 1; } } /* if frame is ok, set audio parameters */ if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; /* channel config */ s->out_channels = s->channels; s->output_mode = s->channel_mode; if(s->lfe_on) s->output_mode |= AC3_OUTPUT_LFEON; if (avctx->request_channels > 0 && avctx->request_channels <= 2 && avctx->request_channels < s->channels) { s->out_channels = avctx->request_channels; s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } avctx->channels = s->out_channels; /* set downmixing coefficients if needed */ if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && s->fbw_channels == s->out_channels)) { set_downmix_coeffs(s); } } else if (!s->out_channels) { s->out_channels = avctx->channels; if(s->out_channels < s->channels) s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } /* parse the audio blocks */ for (blk = 0; blk < NB_BLOCKS; blk++) { if (!err && ac3_parse_audio_block(s, blk)) { av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); } for (i = 0; i < 256; i++) for (ch = 0; ch < s->out_channels; ch++) *(out_samples++) = s->int_output[ch][i]; } *data_size = NB_BLOCKS * 256 * avctx->channels * sizeof (int16_t); return s->frame_size; }
false
FFmpeg
c78c6d6c588c1db60cf2a1bd5bc65095852f91fc
static int ac3_decode_frame(AVCodecContext * avctx, void *data, int *data_size, const uint8_t *buf, int buf_size) { AC3DecodeContext *s = avctx->priv_data; int16_t *out_samples = (int16_t *)data; int i, blk, ch, err; if (s->input_buffer) { memcpy(s->input_buffer, buf, FFMIN(buf_size, AC3_MAX_FRAME_SIZE)); init_get_bits(&s->gbc, s->input_buffer, buf_size * 8); } else { init_get_bits(&s->gbc, buf, buf_size * 8); } err = ac3_parse_header(s); if(err) { switch(err) { case AC3_PARSE_ERROR_SYNC: av_log(avctx, AV_LOG_ERROR, "frame sync error : cannot use error concealment\n"); return -1; case AC3_PARSE_ERROR_BSID: av_log(avctx, AV_LOG_ERROR, "invalid bitstream id\n"); break; case AC3_PARSE_ERROR_SAMPLE_RATE: av_log(avctx, AV_LOG_ERROR, "invalid sample rate\n"); break; case AC3_PARSE_ERROR_FRAME_SIZE: av_log(avctx, AV_LOG_ERROR, "invalid frame size\n"); break; case AC3_PARSE_ERROR_FRAME_TYPE: av_log(avctx, AV_LOG_ERROR, "invalid frame type\n"); break; default: av_log(avctx, AV_LOG_ERROR, "invalid header\n"); break; } } if(s->frame_size > buf_size) { av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); return -1; } if(!err && avctx->error_resilience >= FF_ER_CAREFUL) { if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &buf[2], s->frame_size-2)) { av_log(avctx, AV_LOG_ERROR, "frame CRC mismatch\n"); err = 1; } } if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate; s->out_channels = s->channels; s->output_mode = s->channel_mode; if(s->lfe_on) s->output_mode |= AC3_OUTPUT_LFEON; if (avctx->request_channels > 0 && avctx->request_channels <= 2 && avctx->request_channels < s->channels) { s->out_channels = avctx->request_channels; s->output_mode = avctx->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } avctx->channels = s->out_channels; if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && s->fbw_channels == s->out_channels)) { set_downmix_coeffs(s); } } else if (!s->out_channels) { s->out_channels = avctx->channels; if(s->out_channels < s->channels) s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } for (blk = 0; blk < NB_BLOCKS; blk++) { if (!err && ac3_parse_audio_block(s, blk)) { av_log(avctx, AV_LOG_ERROR, "error parsing the audio block\n"); } for (i = 0; i < 256; i++) for (ch = 0; ch < s->out_channels; ch++) *(out_samples++) = s->int_output[ch][i]; } *data_size = NB_BLOCKS * 256 * avctx->channels * sizeof (int16_t); return s->frame_size; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1, int *VAR_2, const uint8_t *VAR_3, int VAR_4) { AC3DecodeContext *s = VAR_0->priv_data; int16_t *out_samples = (int16_t *)VAR_1; int VAR_5, VAR_6, VAR_7, VAR_8; if (s->input_buffer) { memcpy(s->input_buffer, VAR_3, FFMIN(VAR_4, AC3_MAX_FRAME_SIZE)); init_get_bits(&s->gbc, s->input_buffer, VAR_4 * 8); } else { init_get_bits(&s->gbc, VAR_3, VAR_4 * 8); } VAR_8 = ac3_parse_header(s); if(VAR_8) { switch(VAR_8) { case AC3_PARSE_ERROR_SYNC: av_log(VAR_0, AV_LOG_ERROR, "frame sync error : cannot use error concealment\n"); return -1; case AC3_PARSE_ERROR_BSID: av_log(VAR_0, AV_LOG_ERROR, "invalid bitstream id\n"); break; case AC3_PARSE_ERROR_SAMPLE_RATE: av_log(VAR_0, AV_LOG_ERROR, "invalid sample rate\n"); break; case AC3_PARSE_ERROR_FRAME_SIZE: av_log(VAR_0, AV_LOG_ERROR, "invalid frame size\n"); break; case AC3_PARSE_ERROR_FRAME_TYPE: av_log(VAR_0, AV_LOG_ERROR, "invalid frame type\n"); break; default: av_log(VAR_0, AV_LOG_ERROR, "invalid header\n"); break; } } if(s->frame_size > VAR_4) { av_log(VAR_0, AV_LOG_ERROR, "incomplete frame\n"); return -1; } if(!VAR_8 && VAR_0->error_resilience >= FF_ER_CAREFUL) { if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &VAR_3[2], s->frame_size-2)) { av_log(VAR_0, AV_LOG_ERROR, "frame CRC mismatch\n"); VAR_8 = 1; } } if (!VAR_8) { VAR_0->sample_rate = s->sample_rate; VAR_0->bit_rate = s->bit_rate; s->out_channels = s->channels; s->output_mode = s->channel_mode; if(s->lfe_on) s->output_mode |= AC3_OUTPUT_LFEON; if (VAR_0->request_channels > 0 && VAR_0->request_channels <= 2 && VAR_0->request_channels < s->channels) { s->out_channels = VAR_0->request_channels; s->output_mode = VAR_0->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } VAR_0->channels = s->out_channels; if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) && s->fbw_channels == s->out_channels)) { set_downmix_coeffs(s); } } else if (!s->out_channels) { s->out_channels = VAR_0->channels; if(s->out_channels < s->channels) s->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO; } for (VAR_6 = 0; VAR_6 < NB_BLOCKS; VAR_6++) { if (!VAR_8 && ac3_parse_audio_block(s, VAR_6)) { av_log(VAR_0, AV_LOG_ERROR, "error parsing the audio block\n"); } for (VAR_5 = 0; VAR_5 < 256; VAR_5++) for (VAR_7 = 0; VAR_7 < s->out_channels; VAR_7++) *(out_samples++) = s->int_output[VAR_7][VAR_5]; } *VAR_2 = NB_BLOCKS * 256 * VAR_0->channels * sizeof (int16_t); return s->frame_size; }
[ "static int FUNC_0(AVCodecContext * VAR_0, void *VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{", "AC3DecodeContext *s = VAR_0->priv_data;", "int16_t *out_samples = (int16_t *)VAR_1;", "int VAR_5, VAR_6, VAR_7, VAR_8;", "if (s->input_buffer) {", "memcpy(s->input_buffer, VAR_3, FFMIN(VAR_4, AC3_MAX_FRAME_SIZE));", "init_get_bits(&s->gbc, s->input_buffer, VAR_4 * 8);", "} else {", "init_get_bits(&s->gbc, VAR_3, VAR_4 * 8);", "}", "VAR_8 = ac3_parse_header(s);", "if(VAR_8) {", "switch(VAR_8) {", "case AC3_PARSE_ERROR_SYNC:\nav_log(VAR_0, AV_LOG_ERROR, \"frame sync error : cannot use error concealment\\n\");", "return -1;", "case AC3_PARSE_ERROR_BSID:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid bitstream id\\n\");", "break;", "case AC3_PARSE_ERROR_SAMPLE_RATE:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid sample rate\\n\");", "break;", "case AC3_PARSE_ERROR_FRAME_SIZE:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid frame size\\n\");", "break;", "case AC3_PARSE_ERROR_FRAME_TYPE:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid frame type\\n\");", "break;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"invalid header\\n\");", "break;", "}", "}", "if(s->frame_size > VAR_4) {", "av_log(VAR_0, AV_LOG_ERROR, \"incomplete frame\\n\");", "return -1;", "}", "if(!VAR_8 && VAR_0->error_resilience >= FF_ER_CAREFUL) {", "if(av_crc(av_crc_get_table(AV_CRC_16_ANSI), 0, &VAR_3[2], s->frame_size-2)) {", "av_log(VAR_0, AV_LOG_ERROR, \"frame CRC mismatch\\n\");", "VAR_8 = 1;", "}", "}", "if (!VAR_8) {", "VAR_0->sample_rate = s->sample_rate;", "VAR_0->bit_rate = s->bit_rate;", "s->out_channels = s->channels;", "s->output_mode = s->channel_mode;", "if(s->lfe_on)\ns->output_mode |= AC3_OUTPUT_LFEON;", "if (VAR_0->request_channels > 0 && VAR_0->request_channels <= 2 &&\nVAR_0->request_channels < s->channels) {", "s->out_channels = VAR_0->request_channels;", "s->output_mode = VAR_0->request_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;", "}", "VAR_0->channels = s->out_channels;", "if(s->channels != s->out_channels && !((s->output_mode & AC3_OUTPUT_LFEON) &&\ns->fbw_channels == s->out_channels)) {", "set_downmix_coeffs(s);", "}", "} else if (!s->out_channels) {", "s->out_channels = VAR_0->channels;", "if(s->out_channels < s->channels)\ns->output_mode = s->out_channels == 1 ? AC3_CHMODE_MONO : AC3_CHMODE_STEREO;", "}", "for (VAR_6 = 0; VAR_6 < NB_BLOCKS; VAR_6++) {", "if (!VAR_8 && ac3_parse_audio_block(s, VAR_6)) {", "av_log(VAR_0, AV_LOG_ERROR, \"error parsing the audio block\\n\");", "}", "for (VAR_5 = 0; VAR_5 < 256; VAR_5++)", "for (VAR_7 = 0; VAR_7 < s->out_channels; VAR_7++)", "*(out_samples++) = s->int_output[VAR_7][VAR_5];", "}", "*VAR_2 = NB_BLOCKS * 256 * VAR_0->channels * sizeof (int16_t);", "return s->frame_size;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55, 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 115 ], [ 117 ], [ 119 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 149, 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ] ]
16,766
static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); SerialState *s; Error *err = NULL; int i; switch (pc->device_id) { case 0x0003: pci->ports = 2; break; case 0x0004: pci->ports = 4; break; } assert(pci->ports > 0); assert(pci->ports <= PCI_SERIAL_MAX_PORTS); pci->dev.config[PCI_CLASS_PROG] = pci->prog_if; pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports); pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar); pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci, pci->ports); for (i = 0; i < pci->ports; i++) { s = pci->state + i; s->baudbase = 115200; serial_realize_core(s, &err); if (err != NULL) { error_propagate(errp, err); return; } s->irq = pci->irqs[i]; pci->name[i] = g_strdup_printf("uart #%d", i+1); memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, pci->name[i], 8); memory_region_add_subregion(&pci->iobar, 8 * i, &s->io); } }
true
qemu
a48da7b5bc1f0c98e7a124337140efd47049066c
static void multi_serial_pci_realize(PCIDevice *dev, Error **errp) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev); PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, dev, dev); SerialState *s; Error *err = NULL; int i; switch (pc->device_id) { case 0x0003: pci->ports = 2; break; case 0x0004: pci->ports = 4; break; } assert(pci->ports > 0); assert(pci->ports <= PCI_SERIAL_MAX_PORTS); pci->dev.config[PCI_CLASS_PROG] = pci->prog_if; pci->dev.config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports); pci_register_bar(&pci->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar); pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci, pci->ports); for (i = 0; i < pci->ports; i++) { s = pci->state + i; s->baudbase = 115200; serial_realize_core(s, &err); if (err != NULL) { error_propagate(errp, err); return; } s->irq = pci->irqs[i]; pci->name[i] = g_strdup_printf("uart #%d", i+1); memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, pci->name[i], 8); memory_region_add_subregion(&pci->iobar, 8 * i, &s->io); } }
{ "code": [ " int i;", " pci->ports = 2;", " pci->ports = 4;", " assert(pci->ports > 0);", " assert(pci->ports <= PCI_SERIAL_MAX_PORTS);", " memory_region_init(&pci->iobar, OBJECT(pci), \"multiserial\", 8 * pci->ports);", " pci->ports);", " for (i = 0; i < pci->ports; i++) {" ], "line_no": [ 13, 21, 27, 33, 35, 43, 49, 53 ] }
static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1) { PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(VAR_0); PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, VAR_0, VAR_0); SerialState *s; Error *err = NULL; int VAR_2; switch (pc->device_id) { case 0x0003: pci->ports = 2; break; case 0x0004: pci->ports = 4; break; } assert(pci->ports > 0); assert(pci->ports <= PCI_SERIAL_MAX_PORTS); pci->VAR_0.config[PCI_CLASS_PROG] = pci->prog_if; pci->VAR_0.config[PCI_INTERRUPT_PIN] = 0x01; memory_region_init(&pci->iobar, OBJECT(pci), "multiserial", 8 * pci->ports); pci_register_bar(&pci->VAR_0, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar); pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci, pci->ports); for (VAR_2 = 0; VAR_2 < pci->ports; VAR_2++) { s = pci->state + VAR_2; s->baudbase = 115200; serial_realize_core(s, &err); if (err != NULL) { error_propagate(VAR_1, err); return; } s->irq = pci->irqs[VAR_2]; pci->name[VAR_2] = g_strdup_printf("uart #%d", VAR_2+1); memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s, pci->name[VAR_2], 8); memory_region_add_subregion(&pci->iobar, 8 * VAR_2, &s->io); } }
[ "static void FUNC_0(PCIDevice *VAR_0, Error **VAR_1)\n{", "PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(VAR_0);", "PCIMultiSerialState *pci = DO_UPCAST(PCIMultiSerialState, VAR_0, VAR_0);", "SerialState *s;", "Error *err = NULL;", "int VAR_2;", "switch (pc->device_id) {", "case 0x0003:\npci->ports = 2;", "break;", "case 0x0004:\npci->ports = 4;", "break;", "}", "assert(pci->ports > 0);", "assert(pci->ports <= PCI_SERIAL_MAX_PORTS);", "pci->VAR_0.config[PCI_CLASS_PROG] = pci->prog_if;", "pci->VAR_0.config[PCI_INTERRUPT_PIN] = 0x01;", "memory_region_init(&pci->iobar, OBJECT(pci), \"multiserial\", 8 * pci->ports);", "pci_register_bar(&pci->VAR_0, 0, PCI_BASE_ADDRESS_SPACE_IO, &pci->iobar);", "pci->irqs = qemu_allocate_irqs(multi_serial_irq_mux, pci,\npci->ports);", "for (VAR_2 = 0; VAR_2 < pci->ports; VAR_2++) {", "s = pci->state + VAR_2;", "s->baudbase = 115200;", "serial_realize_core(s, &err);", "if (err != NULL) {", "error_propagate(VAR_1, err);", "return;", "}", "s->irq = pci->irqs[VAR_2];", "pci->name[VAR_2] = g_strdup_printf(\"uart #%d\", VAR_2+1);", "memory_region_init_io(&s->io, OBJECT(pci), &serial_io_ops, s,\npci->name[VAR_2], 8);", "memory_region_add_subregion(&pci->iobar, 8 * VAR_2, &s->io);", "}", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 81 ] ]
16,768
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ MpegEncContext * const s = &h->s; unsigned int pps_id= get_ue_golomb(&s->gb); PPS *pps; const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8); int bits_left; if(pps_id >= MAX_PPS_COUNT) { av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); return -1; } pps= av_mallocz(sizeof(PPS)); if(pps == NULL) return -1; pps->sps_id= get_ue_golomb_31(&s->gb); if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){ av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); goto fail; } pps->cabac= get_bits1(&s->gb); pps->pic_order_present= get_bits1(&s->gb); pps->slice_group_count= get_ue_golomb(&s->gb) + 1; if(pps->slice_group_count > 1 ){ pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n"); switch(pps->mb_slice_group_map_type){ case 0: #if 0 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | | run_length[ i ] |1 |ue(v) | #endif break; case 2: #if 0 | for( i = 0; i < num_slice_groups_minus1; i++ ) | | | |{ | | | | top_left_mb[ i ] |1 |ue(v) | | bottom_right_mb[ i ] |1 |ue(v) | | } | | | #endif break; case 3: case 4: case 5: #if 0 | slice_group_change_direction_flag |1 |u(1) | | slice_group_change_rate_minus1 |1 |ue(v) | #endif break; case 6: #if 0 | slice_group_id_cnt_minus1 |1 |ue(v) | | for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | |) | | | | slice_group_id[ i ] |1 |u(v) | #endif break; } } pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); goto fail; } pps->weighted_pred= get_bits1(&s->gb); pps->weighted_bipred_idc= get_bits(&s->gb, 2); pps->init_qp= get_se_golomb(&s->gb) + 26 + qp_bd_offset; pps->init_qs= get_se_golomb(&s->gb) + 26 + qp_bd_offset; pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb); pps->deblocking_filter_parameters_present= get_bits1(&s->gb); pps->constrained_intra_pred= get_bits1(&s->gb); pps->redundant_pic_cnt_present = get_bits1(&s->gb); pps->transform_8x8_mode= 0; h->dequant_coeff_pps= -1; //contents of sps/pps can change even if id doesn't, so reinit memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); bits_left = bit_length - get_bits_count(&s->gb); if (bits_left && (bits_left > 8 || show_bits(&s->gb, bits_left) != 1 << (bits_left - 1))) { pps->transform_8x8_mode= get_bits1(&s->gb); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); //second_chroma_qp_index_offset } else { pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0]; } build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], h->sps.bit_depth_luma); build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], h->sps.bit_depth_luma); if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) pps->chroma_qp_diff= 1; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", pps_id, pps->sps_id, pps->cabac ? "CABAC" : "CAVLC", pps->slice_group_count, pps->ref_count[0], pps->ref_count[1], pps->weighted_pred ? "weighted" : "", pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1], pps->deblocking_filter_parameters_present ? "LPAR" : "", pps->constrained_intra_pred ? "CONSTR" : "", pps->redundant_pic_cnt_present ? "REDU" : "", pps->transform_8x8_mode ? "8x8DCT" : "" ); } av_free(h->pps_buffers[pps_id]); h->pps_buffers[pps_id]= pps; return 0; fail: av_free(pps); return -1; }
true
FFmpeg
732f9fcfe54fc9a0a7bbce53fe86b38744c2d301
int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length){ MpegEncContext * const s = &h->s; unsigned int pps_id= get_ue_golomb(&s->gb); PPS *pps; const int qp_bd_offset = 6*(h->sps.bit_depth_luma-8); int bits_left; if(pps_id >= MAX_PPS_COUNT) { av_log(h->s.avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id); return -1; } pps= av_mallocz(sizeof(PPS)); if(pps == NULL) return -1; pps->sps_id= get_ue_golomb_31(&s->gb); if((unsigned)pps->sps_id>=MAX_SPS_COUNT || h->sps_buffers[pps->sps_id] == NULL){ av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); goto fail; } pps->cabac= get_bits1(&s->gb); pps->pic_order_present= get_bits1(&s->gb); pps->slice_group_count= get_ue_golomb(&s->gb) + 1; if(pps->slice_group_count > 1 ){ pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); av_log(h->s.avctx, AV_LOG_ERROR, "FMO not supported\n"); switch(pps->mb_slice_group_map_type){ case 0: #if 0 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | | run_length[ i ] |1 |ue(v) | #endif break; case 2: #if 0 | for( i = 0; i < num_slice_groups_minus1; i++ ) | | | |{ | | | | top_left_mb[ i ] |1 |ue(v) | | bottom_right_mb[ i ] |1 |ue(v) | | } | | | #endif break; case 3: case 4: case 5: #if 0 | slice_group_change_direction_flag |1 |u(1) | | slice_group_change_rate_minus1 |1 |ue(v) | #endif break; case 6: #if 0 | slice_group_id_cnt_minus1 |1 |ue(v) | | for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | |) | | | | slice_group_id[ i ] |1 |u(v) | #endif break; } } pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); goto fail; } pps->weighted_pred= get_bits1(&s->gb); pps->weighted_bipred_idc= get_bits(&s->gb, 2); pps->init_qp= get_se_golomb(&s->gb) + 26 + qp_bd_offset; pps->init_qs= get_se_golomb(&s->gb) + 26 + qp_bd_offset; pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb); pps->deblocking_filter_parameters_present= get_bits1(&s->gb); pps->constrained_intra_pred= get_bits1(&s->gb); pps->redundant_pic_cnt_present = get_bits1(&s->gb); pps->transform_8x8_mode= 0; h->dequant_coeff_pps= -1; memcpy(pps->scaling_matrix4, h->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix8, h->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); bits_left = bit_length - get_bits_count(&s->gb); if (bits_left && (bits_left > 8 || show_bits(&s->gb, bits_left) != 1 << (bits_left - 1))) { pps->transform_8x8_mode= get_bits1(&s->gb); decode_scaling_matrices(h, h->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); } else { pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0]; } build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], h->sps.bit_depth_luma); build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], h->sps.bit_depth_luma); if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) pps->chroma_qp_diff= 1; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", pps_id, pps->sps_id, pps->cabac ? "CABAC" : "CAVLC", pps->slice_group_count, pps->ref_count[0], pps->ref_count[1], pps->weighted_pred ? "weighted" : "", pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1], pps->deblocking_filter_parameters_present ? "LPAR" : "", pps->constrained_intra_pred ? "CONSTR" : "", pps->redundant_pic_cnt_present ? "REDU" : "", pps->transform_8x8_mode ? "8x8DCT" : "" ); } av_free(h->pps_buffers[pps_id]); h->pps_buffers[pps_id]= pps; return 0; fail: av_free(pps); return -1; }
{ "code": [], "line_no": [] }
int FUNC_0(H264Context *VAR_0, int VAR_1){ MpegEncContext * const s = &VAR_0->s; unsigned int VAR_2= get_ue_golomb(&s->gb); PPS *pps; const int VAR_3 = 6*(VAR_0->sps.bit_depth_luma-8); int VAR_4; if(VAR_2 >= MAX_PPS_COUNT) { av_log(VAR_0->s.avctx, AV_LOG_ERROR, "VAR_2 (%d) out of range\n", VAR_2); return -1; } pps= av_mallocz(sizeof(PPS)); if(pps == NULL) return -1; pps->sps_id= get_ue_golomb_31(&s->gb); if((unsigned)pps->sps_id>=MAX_SPS_COUNT || VAR_0->sps_buffers[pps->sps_id] == NULL){ av_log(VAR_0->s.avctx, AV_LOG_ERROR, "sps_id out of range\n"); goto fail; } pps->cabac= get_bits1(&s->gb); pps->pic_order_present= get_bits1(&s->gb); pps->slice_group_count= get_ue_golomb(&s->gb) + 1; if(pps->slice_group_count > 1 ){ pps->mb_slice_group_map_type= get_ue_golomb(&s->gb); av_log(VAR_0->s.avctx, AV_LOG_ERROR, "FMO not supported\n"); switch(pps->mb_slice_group_map_type){ case 0: #if 0 | for( i = 0; i <= num_slice_groups_minus1; i++ ) | | | | run_length[ i ] |1 |ue(v) | #endif break; case 2: #if 0 | for( i = 0; i < num_slice_groups_minus1; i++ ) | | | |{ | | | | top_left_mb[ i ] |1 |ue(v) | | bottom_right_mb[ i ] |1 |ue(v) | | } | | | #endif break; case 3: case 4: case 5: #if 0 | slice_group_change_direction_flag |1 |u(1) | | slice_group_change_rate_minus1 |1 |ue(v) | #endif break; case 6: #if 0 | slice_group_id_cnt_minus1 |1 |ue(v) | | for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | | |) | | | | slice_group_id[ i ] |1 |u(v) | #endif break; } } pps->ref_count[0]= get_ue_golomb(&s->gb) + 1; pps->ref_count[1]= get_ue_golomb(&s->gb) + 1; if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){ av_log(VAR_0->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n"); goto fail; } pps->weighted_pred= get_bits1(&s->gb); pps->weighted_bipred_idc= get_bits(&s->gb, 2); pps->init_qp= get_se_golomb(&s->gb) + 26 + VAR_3; pps->init_qs= get_se_golomb(&s->gb) + 26 + VAR_3; pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb); pps->deblocking_filter_parameters_present= get_bits1(&s->gb); pps->constrained_intra_pred= get_bits1(&s->gb); pps->redundant_pic_cnt_present = get_bits1(&s->gb); pps->transform_8x8_mode= 0; VAR_0->dequant_coeff_pps= -1; memcpy(pps->scaling_matrix4, VAR_0->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4)); memcpy(pps->scaling_matrix8, VAR_0->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8)); VAR_4 = VAR_1 - get_bits_count(&s->gb); if (VAR_4 && (VAR_4 > 8 || show_bits(&s->gb, VAR_4) != 1 << (VAR_4 - 1))) { pps->transform_8x8_mode= get_bits1(&s->gb); decode_scaling_matrices(VAR_0, VAR_0->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8); pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb); } else { pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0]; } build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], VAR_0->sps.bit_depth_luma); build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], VAR_0->sps.bit_depth_luma); if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1]) pps->chroma_qp_diff= 1; if(s->avctx->debug&FF_DEBUG_PICT_INFO){ av_log(VAR_0->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\n", VAR_2, pps->sps_id, pps->cabac ? "CABAC" : "CAVLC", pps->slice_group_count, pps->ref_count[0], pps->ref_count[1], pps->weighted_pred ? "weighted" : "", pps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1], pps->deblocking_filter_parameters_present ? "LPAR" : "", pps->constrained_intra_pred ? "CONSTR" : "", pps->redundant_pic_cnt_present ? "REDU" : "", pps->transform_8x8_mode ? "8x8DCT" : "" ); } av_free(VAR_0->pps_buffers[VAR_2]); VAR_0->pps_buffers[VAR_2]= pps; return 0; fail: av_free(pps); return -1; }
[ "int FUNC_0(H264Context *VAR_0, int VAR_1){", "MpegEncContext * const s = &VAR_0->s;", "unsigned int VAR_2= get_ue_golomb(&s->gb);", "PPS *pps;", "const int VAR_3 = 6*(VAR_0->sps.bit_depth_luma-8);", "int VAR_4;", "if(VAR_2 >= MAX_PPS_COUNT) {", "av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"VAR_2 (%d) out of range\\n\", VAR_2);", "return -1;", "}", "pps= av_mallocz(sizeof(PPS));", "if(pps == NULL)\nreturn -1;", "pps->sps_id= get_ue_golomb_31(&s->gb);", "if((unsigned)pps->sps_id>=MAX_SPS_COUNT || VAR_0->sps_buffers[pps->sps_id] == NULL){", "av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"sps_id out of range\\n\");", "goto fail;", "}", "pps->cabac= get_bits1(&s->gb);", "pps->pic_order_present= get_bits1(&s->gb);", "pps->slice_group_count= get_ue_golomb(&s->gb) + 1;", "if(pps->slice_group_count > 1 ){", "pps->mb_slice_group_map_type= get_ue_golomb(&s->gb);", "av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"FMO not supported\\n\");", "switch(pps->mb_slice_group_map_type){", "case 0:\n#if 0\n| for( i = 0; i <= num_slice_groups_minus1; i++ ) | | |", "| run_length[ i ] |1 |ue(v) |\n#endif\nbreak;", "case 2:\n#if 0\n| for( i = 0; i < num_slice_groups_minus1; i++ ) | | |", "|{ | | |", "| top_left_mb[ i ] |1 |ue(v) |\n| bottom_right_mb[ i ] |1 |ue(v) |\n| } | | |", "#endif\nbreak;", "case 3:\ncase 4:\ncase 5:\n#if 0\n| slice_group_change_direction_flag |1 |u(1) |\n| slice_group_change_rate_minus1 |1 |ue(v) |\n#endif\nbreak;", "case 6:\n#if 0\n| slice_group_id_cnt_minus1 |1 |ue(v) |\n| for( i = 0; i <= slice_group_id_cnt_minus1; i++ | | |", "|) | | |\n| slice_group_id[ i ] |1 |u(v) |\n#endif\nbreak;", "}", "}", "pps->ref_count[0]= get_ue_golomb(&s->gb) + 1;", "pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;", "if(pps->ref_count[0]-1 > 32-1 || pps->ref_count[1]-1 > 32-1){", "av_log(VAR_0->s.avctx, AV_LOG_ERROR, \"reference overflow (pps)\\n\");", "goto fail;", "}", "pps->weighted_pred= get_bits1(&s->gb);", "pps->weighted_bipred_idc= get_bits(&s->gb, 2);", "pps->init_qp= get_se_golomb(&s->gb) + 26 + VAR_3;", "pps->init_qs= get_se_golomb(&s->gb) + 26 + VAR_3;", "pps->chroma_qp_index_offset[0]= get_se_golomb(&s->gb);", "pps->deblocking_filter_parameters_present= get_bits1(&s->gb);", "pps->constrained_intra_pred= get_bits1(&s->gb);", "pps->redundant_pic_cnt_present = get_bits1(&s->gb);", "pps->transform_8x8_mode= 0;", "VAR_0->dequant_coeff_pps= -1;", "memcpy(pps->scaling_matrix4, VAR_0->sps_buffers[pps->sps_id]->scaling_matrix4, sizeof(pps->scaling_matrix4));", "memcpy(pps->scaling_matrix8, VAR_0->sps_buffers[pps->sps_id]->scaling_matrix8, sizeof(pps->scaling_matrix8));", "VAR_4 = VAR_1 - get_bits_count(&s->gb);", "if (VAR_4 && (VAR_4 > 8 ||\nshow_bits(&s->gb, VAR_4) != 1 << (VAR_4 - 1))) {", "pps->transform_8x8_mode= get_bits1(&s->gb);", "decode_scaling_matrices(VAR_0, VAR_0->sps_buffers[pps->sps_id], pps, 0, pps->scaling_matrix4, pps->scaling_matrix8);", "pps->chroma_qp_index_offset[1]= get_se_golomb(&s->gb);", "} else {", "pps->chroma_qp_index_offset[1]= pps->chroma_qp_index_offset[0];", "}", "build_qp_table(pps, 0, pps->chroma_qp_index_offset[0], VAR_0->sps.bit_depth_luma);", "build_qp_table(pps, 1, pps->chroma_qp_index_offset[1], VAR_0->sps.bit_depth_luma);", "if(pps->chroma_qp_index_offset[0] != pps->chroma_qp_index_offset[1])\npps->chroma_qp_diff= 1;", "if(s->avctx->debug&FF_DEBUG_PICT_INFO){", "av_log(VAR_0->s.avctx, AV_LOG_DEBUG, \"pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d/%d %s %s %s %s\\n\",\nVAR_2, pps->sps_id,\npps->cabac ? \"CABAC\" : \"CAVLC\",\npps->slice_group_count,\npps->ref_count[0], pps->ref_count[1],\npps->weighted_pred ? \"weighted\" : \"\",\npps->init_qp, pps->init_qs, pps->chroma_qp_index_offset[0], pps->chroma_qp_index_offset[1],\npps->deblocking_filter_parameters_present ? \"LPAR\" : \"\",\npps->constrained_intra_pred ? \"CONSTR\" : \"\",\npps->redundant_pic_cnt_present ? \"REDU\" : \"\",\npps->transform_8x8_mode ? \"8x8DCT\" : \"\"\n);", "}", "av_free(VAR_0->pps_buffers[VAR_2]);", "VAR_0->pps_buffers[VAR_2]= pps;", "return 0;", "fail:\nav_free(pps);", "return -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 24 ], [ 28 ], [ 30, 32 ], [ 34 ], [ 36 ], [ 38 ], [ 40 ], [ 42 ], [ 46 ], [ 48 ], [ 50 ], [ 52 ], [ 54 ], [ 56 ], [ 58 ], [ 60, 62, 64 ], [ 66, 68, 70 ], [ 72, 74, 76 ], [ 78 ], [ 80, 82, 84 ], [ 86, 88 ], [ 90, 92, 94, 96, 98, 100, 102, 104 ], [ 106, 108, 110, 112 ], [ 114, 116, 118, 120 ], [ 122 ], [ 124 ], [ 126 ], [ 128 ], [ 130 ], [ 132 ], [ 134 ], [ 136 ], [ 140 ], [ 142 ], [ 144 ], [ 146 ], [ 148 ], [ 150 ], [ 152 ], [ 154 ], [ 158 ], [ 160 ], [ 162 ], [ 164 ], [ 168 ], [ 170, 172 ], [ 174 ], [ 176 ], [ 178 ], [ 180 ], [ 182 ], [ 184 ], [ 188 ], [ 190 ], [ 192, 194 ], [ 198 ], [ 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222 ], [ 224 ], [ 228 ], [ 230 ], [ 232 ], [ 234, 236 ], [ 238 ], [ 240 ] ]
16,769
int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr, hwaddr rtas_size) { int ret; int i; ret = fdt_add_mem_rsv(fdt, rtas_addr, rtas_size); if (ret < 0) { fprintf(stderr, "Couldn't add RTAS reserve entry: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-base", rtas_addr); if (ret < 0) { fprintf(stderr, "Couldn't add linux,rtas-base property: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-entry", rtas_addr); if (ret < 0) { fprintf(stderr, "Couldn't add linux,rtas-entry property: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", rtas_size); if (ret < 0) { fprintf(stderr, "Couldn't add rtas-size property: %s\n", fdt_strerror(ret)); return ret; } for (i = 0; i < TOKEN_MAX; i++) { struct rtas_call *call = &rtas_table[i]; if (!call->name) { continue; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", call->name, i + TOKEN_BASE); if (ret < 0) { fprintf(stderr, "Couldn't add rtas token for %s: %s\n", call->name, fdt_strerror(ret)); return ret; } } return 0; }
true
qemu
3a3b8502e6f0c8d30865c5f36d2c3ae4114000b5
int spapr_rtas_device_tree_setup(void *fdt, hwaddr rtas_addr, hwaddr rtas_size) { int ret; int i; ret = fdt_add_mem_rsv(fdt, rtas_addr, rtas_size); if (ret < 0) { fprintf(stderr, "Couldn't add RTAS reserve entry: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-base", rtas_addr); if (ret < 0) { fprintf(stderr, "Couldn't add linux,rtas-base property: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "linux,rtas-entry", rtas_addr); if (ret < 0) { fprintf(stderr, "Couldn't add linux,rtas-entry property: %s\n", fdt_strerror(ret)); return ret; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", rtas_size); if (ret < 0) { fprintf(stderr, "Couldn't add rtas-size property: %s\n", fdt_strerror(ret)); return ret; } for (i = 0; i < TOKEN_MAX; i++) { struct rtas_call *call = &rtas_table[i]; if (!call->name) { continue; } ret = qemu_fdt_setprop_cell(fdt, "/rtas", call->name, i + TOKEN_BASE); if (ret < 0) { fprintf(stderr, "Couldn't add rtas token for %s: %s\n", call->name, fdt_strerror(ret)); return ret; } } return 0; }
{ "code": [ " int i;", " for (i = 0; i < TOKEN_MAX; i++) {", " i + TOKEN_BASE);" ], "line_no": [ 9, 75, 91 ] }
int FUNC_0(void *VAR_0, hwaddr VAR_1, hwaddr VAR_2) { int VAR_3; int VAR_4; VAR_3 = fdt_add_mem_rsv(VAR_0, VAR_1, VAR_2); if (VAR_3 < 0) { fprintf(stderr, "Couldn't add RTAS reserve entry: %s\n", fdt_strerror(VAR_3)); return VAR_3; } VAR_3 = qemu_fdt_setprop_cell(VAR_0, "/rtas", "linux,rtas-base", VAR_1); if (VAR_3 < 0) { fprintf(stderr, "Couldn't add linux,rtas-base property: %s\n", fdt_strerror(VAR_3)); return VAR_3; } VAR_3 = qemu_fdt_setprop_cell(VAR_0, "/rtas", "linux,rtas-entry", VAR_1); if (VAR_3 < 0) { fprintf(stderr, "Couldn't add linux,rtas-entry property: %s\n", fdt_strerror(VAR_3)); return VAR_3; } VAR_3 = qemu_fdt_setprop_cell(VAR_0, "/rtas", "rtas-size", VAR_2); if (VAR_3 < 0) { fprintf(stderr, "Couldn't add rtas-size property: %s\n", fdt_strerror(VAR_3)); return VAR_3; } for (VAR_4 = 0; VAR_4 < TOKEN_MAX; VAR_4++) { struct rtas_call *call = &rtas_table[VAR_4]; if (!call->name) { continue; } VAR_3 = qemu_fdt_setprop_cell(VAR_0, "/rtas", call->name, VAR_4 + TOKEN_BASE); if (VAR_3 < 0) { fprintf(stderr, "Couldn't add rtas token for %s: %s\n", call->name, fdt_strerror(VAR_3)); return VAR_3; } } return 0; }
[ "int FUNC_0(void *VAR_0, hwaddr VAR_1,\nhwaddr VAR_2)\n{", "int VAR_3;", "int VAR_4;", "VAR_3 = fdt_add_mem_rsv(VAR_0, VAR_1, VAR_2);", "if (VAR_3 < 0) {", "fprintf(stderr, \"Couldn't add RTAS reserve entry: %s\\n\",\nfdt_strerror(VAR_3));", "return VAR_3;", "}", "VAR_3 = qemu_fdt_setprop_cell(VAR_0, \"/rtas\", \"linux,rtas-base\",\nVAR_1);", "if (VAR_3 < 0) {", "fprintf(stderr, \"Couldn't add linux,rtas-base property: %s\\n\",\nfdt_strerror(VAR_3));", "return VAR_3;", "}", "VAR_3 = qemu_fdt_setprop_cell(VAR_0, \"/rtas\", \"linux,rtas-entry\",\nVAR_1);", "if (VAR_3 < 0) {", "fprintf(stderr, \"Couldn't add linux,rtas-entry property: %s\\n\",\nfdt_strerror(VAR_3));", "return VAR_3;", "}", "VAR_3 = qemu_fdt_setprop_cell(VAR_0, \"/rtas\", \"rtas-size\",\nVAR_2);", "if (VAR_3 < 0) {", "fprintf(stderr, \"Couldn't add rtas-size property: %s\\n\",\nfdt_strerror(VAR_3));", "return VAR_3;", "}", "for (VAR_4 = 0; VAR_4 < TOKEN_MAX; VAR_4++) {", "struct rtas_call *call = &rtas_table[VAR_4];", "if (!call->name) {", "continue;", "}", "VAR_3 = qemu_fdt_setprop_cell(VAR_0, \"/rtas\", call->name,\nVAR_4 + TOKEN_BASE);", "if (VAR_3 < 0) {", "fprintf(stderr, \"Couldn't add rtas token for %s: %s\\n\",\ncall->name, fdt_strerror(VAR_3));", "return VAR_3;", "}", "}", "return 0;", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 43, 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 59, 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 89, 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 109 ] ]
16,770
static int get_phys_addr_mpu(CPUARMState *env, uint32_t address, int access_type, int is_user, hwaddr *phys_ptr, int *prot) { int n; uint32_t mask; uint32_t base; *phys_ptr = address; for (n = 7; n >= 0; n--) { base = env->cp15.c6_region[n]; if ((base & 1) == 0) continue; mask = 1 << ((base >> 1) & 0x1f); /* Keep this shift separate from the above to avoid an (undefined) << 32. */ mask = (mask << 1) - 1; if (((base ^ address) & ~mask) == 0) break; } if (n < 0) return 2; if (access_type == 2) { mask = env->cp15.c5_insn; } else { mask = env->cp15.c5_data; } mask = (mask >> (n * 4)) & 0xf; switch (mask) { case 0: return 1; case 1: if (is_user) return 1; *prot = PAGE_READ | PAGE_WRITE; break; case 2: *prot = PAGE_READ; if (!is_user) *prot |= PAGE_WRITE; break; case 3: *prot = PAGE_READ | PAGE_WRITE; break; case 5: if (is_user) return 1; *prot = PAGE_READ; break; case 6: *prot = PAGE_READ; break; default: /* Bad permission. */ return 1; } *prot |= PAGE_EXEC; return 0; }
true
qemu
7e09797c299712cafa7bc05dd57c1b13afcc6039
static int get_phys_addr_mpu(CPUARMState *env, uint32_t address, int access_type, int is_user, hwaddr *phys_ptr, int *prot) { int n; uint32_t mask; uint32_t base; *phys_ptr = address; for (n = 7; n >= 0; n--) { base = env->cp15.c6_region[n]; if ((base & 1) == 0) continue; mask = 1 << ((base >> 1) & 0x1f); mask = (mask << 1) - 1; if (((base ^ address) & ~mask) == 0) break; } if (n < 0) return 2; if (access_type == 2) { mask = env->cp15.c5_insn; } else { mask = env->cp15.c5_data; } mask = (mask >> (n * 4)) & 0xf; switch (mask) { case 0: return 1; case 1: if (is_user) return 1; *prot = PAGE_READ | PAGE_WRITE; break; case 2: *prot = PAGE_READ; if (!is_user) *prot |= PAGE_WRITE; break; case 3: *prot = PAGE_READ | PAGE_WRITE; break; case 5: if (is_user) return 1; *prot = PAGE_READ; break; case 6: *prot = PAGE_READ; break; default: return 1; } *prot |= PAGE_EXEC; return 0; }
{ "code": [ "\tmask = env->cp15.c5_insn;", "\tmask = env->cp15.c5_data;" ], "line_no": [ 49, 53 ] }
static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1, int VAR_2, int VAR_3, hwaddr *VAR_4, int *VAR_5) { int VAR_6; uint32_t mask; uint32_t base; *VAR_4 = VAR_1; for (VAR_6 = 7; VAR_6 >= 0; VAR_6--) { base = VAR_0->cp15.c6_region[VAR_6]; if ((base & 1) == 0) continue; mask = 1 << ((base >> 1) & 0x1f); mask = (mask << 1) - 1; if (((base ^ VAR_1) & ~mask) == 0) break; } if (VAR_6 < 0) return 2; if (VAR_2 == 2) { mask = VAR_0->cp15.c5_insn; } else { mask = VAR_0->cp15.c5_data; } mask = (mask >> (VAR_6 * 4)) & 0xf; switch (mask) { case 0: return 1; case 1: if (VAR_3) return 1; *VAR_5 = PAGE_READ | PAGE_WRITE; break; case 2: *VAR_5 = PAGE_READ; if (!VAR_3) *VAR_5 |= PAGE_WRITE; break; case 3: *VAR_5 = PAGE_READ | PAGE_WRITE; break; case 5: if (VAR_3) return 1; *VAR_5 = PAGE_READ; break; case 6: *VAR_5 = PAGE_READ; break; default: return 1; } *VAR_5 |= PAGE_EXEC; return 0; }
[ "static int FUNC_0(CPUARMState *VAR_0, uint32_t VAR_1,\nint VAR_2, int VAR_3,\nhwaddr *VAR_4, int *VAR_5)\n{", "int VAR_6;", "uint32_t mask;", "uint32_t base;", "*VAR_4 = VAR_1;", "for (VAR_6 = 7; VAR_6 >= 0; VAR_6--) {", "base = VAR_0->cp15.c6_region[VAR_6];", "if ((base & 1) == 0)\ncontinue;", "mask = 1 << ((base >> 1) & 0x1f);", "mask = (mask << 1) - 1;", "if (((base ^ VAR_1) & ~mask) == 0)\nbreak;", "}", "if (VAR_6 < 0)\nreturn 2;", "if (VAR_2 == 2) {", "mask = VAR_0->cp15.c5_insn;", "} else {", "mask = VAR_0->cp15.c5_data;", "}", "mask = (mask >> (VAR_6 * 4)) & 0xf;", "switch (mask) {", "case 0:\nreturn 1;", "case 1:\nif (VAR_3)\nreturn 1;", "*VAR_5 = PAGE_READ | PAGE_WRITE;", "break;", "case 2:\n*VAR_5 = PAGE_READ;", "if (!VAR_3)\n*VAR_5 |= PAGE_WRITE;", "break;", "case 3:\n*VAR_5 = PAGE_READ | PAGE_WRITE;", "break;", "case 5:\nif (VAR_3)\nreturn 1;", "*VAR_5 = PAGE_READ;", "break;", "case 6:\n*VAR_5 = PAGE_READ;", "break;", "default:\nreturn 1;", "}", "*VAR_5 |= PAGE_EXEC;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 33 ], [ 35, 37 ], [ 39 ], [ 41, 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65, 67, 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79, 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91, 93, 95 ], [ 97 ], [ 99 ], [ 101, 103 ], [ 105 ], [ 107, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ] ]
16,772
static int huff_build(VLC *vlc, uint8_t *len) { HuffEntry he[256]; uint32_t codes[256]; uint8_t bits[256]; uint8_t syms[256]; uint32_t code; int i; for (i = 0; i < 256; i++) { he[i].sym = 255 - i; he[i].len = len[i]; if (len[i] == 0) return AVERROR_INVALIDDATA; } AV_QSORT(he, 256, HuffEntry, huff_cmp_len); code = 1; for (i = 255; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; syms[i] = he[i].sym; code += 0x80000000u >> (he[i].len - 1); } ff_free_vlc(vlc); return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256, bits, sizeof(*bits), sizeof(*bits), codes, sizeof(*codes), sizeof(*codes), syms, sizeof(*syms), sizeof(*syms), 0); }
true
FFmpeg
341f01290c2353669ed2263f56e1a9f4c67cc597
static int huff_build(VLC *vlc, uint8_t *len) { HuffEntry he[256]; uint32_t codes[256]; uint8_t bits[256]; uint8_t syms[256]; uint32_t code; int i; for (i = 0; i < 256; i++) { he[i].sym = 255 - i; he[i].len = len[i]; if (len[i] == 0) return AVERROR_INVALIDDATA; } AV_QSORT(he, 256, HuffEntry, huff_cmp_len); code = 1; for (i = 255; i >= 0; i--) { codes[i] = code >> (32 - he[i].len); bits[i] = he[i].len; syms[i] = he[i].sym; code += 0x80000000u >> (he[i].len - 1); } ff_free_vlc(vlc); return ff_init_vlc_sparse(vlc, FFMIN(he[255].len, 12), 256, bits, sizeof(*bits), sizeof(*bits), codes, sizeof(*codes), sizeof(*codes), syms, sizeof(*syms), sizeof(*syms), 0); }
{ "code": [ " if (len[i] == 0)", " if (len[i] == 0)", " if (len[i] == 0)" ], "line_no": [ 25, 25, 25 ] }
static int FUNC_0(VLC *VAR_0, uint8_t *VAR_1) { HuffEntry he[256]; uint32_t codes[256]; uint8_t bits[256]; uint8_t syms[256]; uint32_t code; int VAR_2; for (VAR_2 = 0; VAR_2 < 256; VAR_2++) { he[VAR_2].sym = 255 - VAR_2; he[VAR_2].VAR_1 = VAR_1[VAR_2]; if (VAR_1[VAR_2] == 0) return AVERROR_INVALIDDATA; } AV_QSORT(he, 256, HuffEntry, huff_cmp_len); code = 1; for (VAR_2 = 255; VAR_2 >= 0; VAR_2--) { codes[VAR_2] = code >> (32 - he[VAR_2].VAR_1); bits[VAR_2] = he[VAR_2].VAR_1; syms[VAR_2] = he[VAR_2].sym; code += 0x80000000u >> (he[VAR_2].VAR_1 - 1); } ff_free_vlc(VAR_0); return ff_init_vlc_sparse(VAR_0, FFMIN(he[255].VAR_1, 12), 256, bits, sizeof(*bits), sizeof(*bits), codes, sizeof(*codes), sizeof(*codes), syms, sizeof(*syms), sizeof(*syms), 0); }
[ "static int FUNC_0(VLC *VAR_0, uint8_t *VAR_1)\n{", "HuffEntry he[256];", "uint32_t codes[256];", "uint8_t bits[256];", "uint8_t syms[256];", "uint32_t code;", "int VAR_2;", "for (VAR_2 = 0; VAR_2 < 256; VAR_2++) {", "he[VAR_2].sym = 255 - VAR_2;", "he[VAR_2].VAR_1 = VAR_1[VAR_2];", "if (VAR_1[VAR_2] == 0)\nreturn AVERROR_INVALIDDATA;", "}", "AV_QSORT(he, 256, HuffEntry, huff_cmp_len);", "code = 1;", "for (VAR_2 = 255; VAR_2 >= 0; VAR_2--) {", "codes[VAR_2] = code >> (32 - he[VAR_2].VAR_1);", "bits[VAR_2] = he[VAR_2].VAR_1;", "syms[VAR_2] = he[VAR_2].sym;", "code += 0x80000000u >> (he[VAR_2].VAR_1 - 1);", "}", "ff_free_vlc(VAR_0);", "return ff_init_vlc_sparse(VAR_0, FFMIN(he[255].VAR_1, 12), 256,\nbits, sizeof(*bits), sizeof(*bits),\ncodes, sizeof(*codes), sizeof(*codes),\nsyms, sizeof(*syms), sizeof(*syms), 0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53, 55, 57, 59 ], [ 61 ] ]
16,773
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) { uint8_t byte; if (s->buf_end - s->buf < 5) return AVERROR(EINVAL); /* nreslevels = number of resolution levels = number of decomposition level +1 */ c->nreslevels = bytestream_get_byte(&s->buf) + 1; if (c->nreslevels > JPEG2000_MAX_RESLEVELS) return AVERROR_INVALIDDATA; /* compute number of resolution levels to decode */ if (c->nreslevels < s->reduction_factor) c->nreslevels2decode = 1; else c->nreslevels2decode = c->nreslevels - s->reduction_factor; c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; // cblk width c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; // cblk height if (c->log2_cblk_width > 10 || c->log2_cblk_height > 10 || c->log2_cblk_width + c->log2_cblk_height > 12) { av_log(s->avctx, AV_LOG_ERROR, "cblk size invalid\n"); return AVERROR_INVALIDDATA; } c->cblk_style = bytestream_get_byte(&s->buf); if (c->cblk_style != 0) { // cblk style avpriv_request_sample(s->avctx, "Support for extra cblk styles"); return AVERROR_PATCHWELCOME; } c->transform = bytestream_get_byte(&s->buf); // DWT transformation type /* set integer 9/7 DWT in case of BITEXACT flag */ if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97)) c->transform = FF_DWT97_INT; if (c->csty & JPEG2000_CSTY_PREC) { int i; for (i = 0; i < c->nreslevels; i++) { byte = bytestream_get_byte(&s->buf); c->log2_prec_widths[i] = byte & 0x0F; // precinct PPx c->log2_prec_heights[i] = (byte >> 4) & 0x0F; // precinct PPy } } return 0; }
true
FFmpeg
1a3598aae768465a8efc8475b6df5a8261bc62fc
static int get_cox(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c) { uint8_t byte; if (s->buf_end - s->buf < 5) return AVERROR(EINVAL); c->nreslevels = bytestream_get_byte(&s->buf) + 1; if (c->nreslevels > JPEG2000_MAX_RESLEVELS) return AVERROR_INVALIDDATA; if (c->nreslevels < s->reduction_factor) c->nreslevels2decode = 1; else c->nreslevels2decode = c->nreslevels - s->reduction_factor; c->log2_cblk_width = bytestream_get_byte(&s->buf) + 2; c->log2_cblk_height = bytestream_get_byte(&s->buf) + 2; if (c->log2_cblk_width > 10 || c->log2_cblk_height > 10 || c->log2_cblk_width + c->log2_cblk_height > 12) { av_log(s->avctx, AV_LOG_ERROR, "cblk size invalid\n"); return AVERROR_INVALIDDATA; } c->cblk_style = bytestream_get_byte(&s->buf); if (c->cblk_style != 0) { avpriv_request_sample(s->avctx, "Support for extra cblk styles"); return AVERROR_PATCHWELCOME; } c->transform = bytestream_get_byte(&s->buf); if ((s->avctx->flags & CODEC_FLAG_BITEXACT) && (c->transform == FF_DWT97)) c->transform = FF_DWT97_INT; if (c->csty & JPEG2000_CSTY_PREC) { int i; for (i = 0; i < c->nreslevels; i++) { byte = bytestream_get_byte(&s->buf); c->log2_prec_widths[i] = byte & 0x0F; c->log2_prec_heights[i] = (byte >> 4) & 0x0F; } } return 0; }
{ "code": [ " return AVERROR_INVALIDDATA;", " if (s->buf_end - s->buf < 5)", " return AVERROR(EINVAL);", " c->nreslevels = bytestream_get_byte(&s->buf) + 1;", " c->cblk_style = bytestream_get_byte(&s->buf);", " byte = bytestream_get_byte(&s->buf);", " if (s->buf_end - s->buf < 5)" ], "line_no": [ 23, 9, 11, 17, 57, 83, 9 ] }
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1) { uint8_t byte; if (VAR_0->buf_end - VAR_0->buf < 5) return AVERROR(EINVAL); VAR_1->nreslevels = bytestream_get_byte(&VAR_0->buf) + 1; if (VAR_1->nreslevels > JPEG2000_MAX_RESLEVELS) return AVERROR_INVALIDDATA; if (VAR_1->nreslevels < VAR_0->reduction_factor) VAR_1->nreslevels2decode = 1; else VAR_1->nreslevels2decode = VAR_1->nreslevels - VAR_0->reduction_factor; VAR_1->log2_cblk_width = bytestream_get_byte(&VAR_0->buf) + 2; VAR_1->log2_cblk_height = bytestream_get_byte(&VAR_0->buf) + 2; if (VAR_1->log2_cblk_width > 10 || VAR_1->log2_cblk_height > 10 || VAR_1->log2_cblk_width + VAR_1->log2_cblk_height > 12) { av_log(VAR_0->avctx, AV_LOG_ERROR, "cblk size invalid\n"); return AVERROR_INVALIDDATA; } VAR_1->cblk_style = bytestream_get_byte(&VAR_0->buf); if (VAR_1->cblk_style != 0) { avpriv_request_sample(VAR_0->avctx, "Support for extra cblk styles"); return AVERROR_PATCHWELCOME; } VAR_1->transform = bytestream_get_byte(&VAR_0->buf); if ((VAR_0->avctx->flags & CODEC_FLAG_BITEXACT) && (VAR_1->transform == FF_DWT97)) VAR_1->transform = FF_DWT97_INT; if (VAR_1->csty & JPEG2000_CSTY_PREC) { int VAR_2; for (VAR_2 = 0; VAR_2 < VAR_1->nreslevels; VAR_2++) { byte = bytestream_get_byte(&VAR_0->buf); VAR_1->log2_prec_widths[VAR_2] = byte & 0x0F; VAR_1->log2_prec_heights[VAR_2] = (byte >> 4) & 0x0F; } } return 0; }
[ "static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1)\n{", "uint8_t byte;", "if (VAR_0->buf_end - VAR_0->buf < 5)\nreturn AVERROR(EINVAL);", "VAR_1->nreslevels = bytestream_get_byte(&VAR_0->buf) + 1;", "if (VAR_1->nreslevels > JPEG2000_MAX_RESLEVELS)\nreturn AVERROR_INVALIDDATA;", "if (VAR_1->nreslevels < VAR_0->reduction_factor)\nVAR_1->nreslevels2decode = 1;", "else\nVAR_1->nreslevels2decode = VAR_1->nreslevels - VAR_0->reduction_factor;", "VAR_1->log2_cblk_width = bytestream_get_byte(&VAR_0->buf) + 2;", "VAR_1->log2_cblk_height = bytestream_get_byte(&VAR_0->buf) + 2;", "if (VAR_1->log2_cblk_width > 10 || VAR_1->log2_cblk_height > 10 ||\nVAR_1->log2_cblk_width + VAR_1->log2_cblk_height > 12) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"cblk size invalid\\n\");", "return AVERROR_INVALIDDATA;", "}", "VAR_1->cblk_style = bytestream_get_byte(&VAR_0->buf);", "if (VAR_1->cblk_style != 0) {", "avpriv_request_sample(VAR_0->avctx, \"Support for extra cblk styles\");", "return AVERROR_PATCHWELCOME;", "}", "VAR_1->transform = bytestream_get_byte(&VAR_0->buf);", "if ((VAR_0->avctx->flags & CODEC_FLAG_BITEXACT) && (VAR_1->transform == FF_DWT97))\nVAR_1->transform = FF_DWT97_INT;", "if (VAR_1->csty & JPEG2000_CSTY_PREC) {", "int VAR_2;", "for (VAR_2 = 0; VAR_2 < VAR_1->nreslevels; VAR_2++) {", "byte = bytestream_get_byte(&VAR_0->buf);", "VAR_1->log2_prec_widths[VAR_2] = byte & 0x0F;", "VAR_1->log2_prec_heights[VAR_2] = (byte >> 4) & 0x0F;", "}", "}", "return 0;", "}" ]
[ 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 17 ], [ 21, 23 ], [ 29, 31 ], [ 33, 35 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
16,774
void qemu_clock_warp(QEMUClockType type) { int64_t deadline; /* * There are too many global variables to make the "warp" behavior * applicable to other clocks. But a clock argument removes the * need for if statements all over the place. */ if (type != QEMU_CLOCK_VIRTUAL || !use_icount) { return; } /* * If the CPUs have been sleeping, advance QEMU_CLOCK_VIRTUAL timer now. * This ensures that the deadline for the timer is computed correctly below. * This also makes sure that the insn counter is synchronized before the * CPU starts running, in case the CPU is woken by an event other than * the earliest QEMU_CLOCK_VIRTUAL timer. */ icount_warp_rt(NULL); if (!all_cpu_threads_idle() || !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL)) { timer_del(icount_warp_timer); return; } if (qtest_enabled()) { /* When testing, qtest commands advance icount. */ return; } vm_clock_warp_start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); /* We want to use the earliest deadline from ALL vm_clocks */ deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); /* Maintain prior (possibly buggy) behaviour where if no deadline * was set (as there is no QEMU_CLOCK_VIRTUAL timer) or it is more than * INT32_MAX nanoseconds ahead, we still use INT32_MAX * nanoseconds. */ if ((deadline < 0) || (deadline > INT32_MAX)) { deadline = INT32_MAX; } if (deadline > 0) { /* * Ensure QEMU_CLOCK_VIRTUAL proceeds even when the virtual CPU goes to * sleep. Otherwise, the CPU might be waiting for a future timer * interrupt to wake it up, but the interrupt never comes because * the vCPU isn't running any insns and thus doesn't advance the * QEMU_CLOCK_VIRTUAL. * * An extreme solution for this problem would be to never let VCPUs * sleep in icount mode if there is a pending QEMU_CLOCK_VIRTUAL * timer; rather time could just advance to the next QEMU_CLOCK_VIRTUAL * event. Instead, we do stop VCPUs and only advance QEMU_CLOCK_VIRTUAL * after some e"real" time, (related to the time left until the next * event) has passed. The QEMU_CLOCK_REALTIME timer will do this. * This avoids that the warps are visible externally; for example, * you will not be sending network packets continuously instead of * every 100ms. */ timer_mod(icount_warp_timer, vm_clock_warp_start + deadline); } else if (deadline == 0) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } }
true
qemu
ce78d18ced118b03e821135e702ba1d513c8b2a7
void qemu_clock_warp(QEMUClockType type) { int64_t deadline; if (type != QEMU_CLOCK_VIRTUAL || !use_icount) { return; } icount_warp_rt(NULL); if (!all_cpu_threads_idle() || !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL)) { timer_del(icount_warp_timer); return; } if (qtest_enabled()) { return; } vm_clock_warp_start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); if ((deadline < 0) || (deadline > INT32_MAX)) { deadline = INT32_MAX; } if (deadline > 0) { timer_mod(icount_warp_timer, vm_clock_warp_start + deadline); } else if (deadline == 0) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } }
{ "code": [ " if (!all_cpu_threads_idle() || !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL)) {", " timer_del(icount_warp_timer);", " vm_clock_warp_start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);", " if ((deadline < 0) || (deadline > INT32_MAX)) {", " deadline = INT32_MAX;", " timer_mod(icount_warp_timer, vm_clock_warp_start + deadline);" ], "line_no": [ 43, 45, 63, 81, 83, 125 ] }
void FUNC_0(QEMUClockType VAR_0) { int64_t deadline; if (VAR_0 != QEMU_CLOCK_VIRTUAL || !use_icount) { return; } icount_warp_rt(NULL); if (!all_cpu_threads_idle() || !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL)) { timer_del(icount_warp_timer); return; } if (qtest_enabled()) { return; } vm_clock_warp_start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME); deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); if ((deadline < 0) || (deadline > INT32_MAX)) { deadline = INT32_MAX; } if (deadline > 0) { timer_mod(icount_warp_timer, vm_clock_warp_start + deadline); } else if (deadline == 0) { qemu_clock_notify(QEMU_CLOCK_VIRTUAL); } }
[ "void FUNC_0(QEMUClockType VAR_0)\n{", "int64_t deadline;", "if (VAR_0 != QEMU_CLOCK_VIRTUAL || !use_icount) {", "return;", "}", "icount_warp_rt(NULL);", "if (!all_cpu_threads_idle() || !qemu_clock_has_timers(QEMU_CLOCK_VIRTUAL)) {", "timer_del(icount_warp_timer);", "return;", "}", "if (qtest_enabled()) {", "return;", "}", "vm_clock_warp_start = qemu_clock_get_ns(QEMU_CLOCK_REALTIME);", "deadline = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);", "if ((deadline < 0) || (deadline > INT32_MAX)) {", "deadline = INT32_MAX;", "}", "if (deadline > 0) {", "timer_mod(icount_warp_timer, vm_clock_warp_start + deadline);", "} else if (deadline == 0) {", "qemu_clock_notify(QEMU_CLOCK_VIRTUAL);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 19 ], [ 21 ], [ 23 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 57 ], [ 59 ], [ 63 ], [ 67 ], [ 81 ], [ 83 ], [ 85 ], [ 89 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ] ]
16,775
void qpci_plug_device_test(const char *driver, const char *id, uint8_t slot, const char *opts) { QDict *response; char *cmd; cmd = g_strdup_printf("{'execute': 'device_add'," " 'arguments': {" " 'driver': '%s'," " 'addr': '%d'," " %s%s" " 'id': '%s'" "}}", driver, slot, opts ? opts : "", opts ? "," : "", id); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(!qdict_haskey(response, "error")); QDECREF(response); }
false
qemu
acd80015fbe28f4f513e036ad1db2a76738d1f53
void qpci_plug_device_test(const char *driver, const char *id, uint8_t slot, const char *opts) { QDict *response; char *cmd; cmd = g_strdup_printf("{'execute': 'device_add'," " 'arguments': {" " 'driver': '%s'," " 'addr': '%d'," " %s%s" " 'id': '%s'" "}}", driver, slot, opts ? opts : "", opts ? "," : "", id); response = qmp(cmd); g_free(cmd); g_assert(response); g_assert(!qdict_haskey(response, "error")); QDECREF(response); }
{ "code": [], "line_no": [] }
void FUNC_0(const char *VAR_0, const char *VAR_1, uint8_t VAR_2, const char *VAR_3) { QDict *response; char *VAR_4; VAR_4 = g_strdup_printf("{'execute': 'device_add'," " 'arguments': {" " 'VAR_0': '%s'," " 'addr': '%d'," " %s%s" " 'VAR_1': '%s'" "}}", VAR_0, VAR_2, VAR_3 ? VAR_3 : "", VAR_3 ? "," : "", VAR_1); response = qmp(VAR_4); g_free(VAR_4); g_assert(response); g_assert(!qdict_haskey(response, "error")); QDECREF(response); }
[ "void FUNC_0(const char *VAR_0, const char *VAR_1,\nuint8_t VAR_2, const char *VAR_3)\n{", "QDict *response;", "char *VAR_4;", "VAR_4 = g_strdup_printf(\"{'execute': 'device_add',\"", "\" 'arguments': {\"", "\" 'VAR_0': '%s',\"\n\" 'addr': '%d',\"\n\" %s%s\"\n\" 'VAR_1': '%s'\"\n\"}}\", VAR_0, VAR_2,", "VAR_3 ? VAR_3 : \"\", VAR_3 ? \",\" : \"\",\nVAR_1);", "response = qmp(VAR_4);", "g_free(VAR_4);", "g_assert(response);", "g_assert(!qdict_haskey(response, \"error\"));", "QDECREF(response);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17, 19, 21, 23, 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ] ]
16,778
void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) { bool ret; uint32_t fsr = 0; ARMMMUFaultInfo fi = {}; ret = arm_tlb_fill(cs, addr, is_write, mmu_idx, &fsr, &fi); if (unlikely(ret)) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; uint32_t syn, exc; unsigned int target_el; bool same_el; if (retaddr) { /* now we have a real cpu fault */ cpu_restore_state(cs, retaddr); } target_el = exception_target_el(env); if (fi.stage2) { target_el = 2; env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4; } same_el = arm_current_el(env) == target_el; /* AArch64 syndrome does not have an LPAE bit */ syn = fsr & ~(1 << 9); /* For insn and data aborts we assume there is no instruction syndrome * information; this is always true for exceptions reported to EL1. */ if (is_write == 2) { syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn); exc = EXCP_PREFETCH_ABORT; } else { syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, is_write == 1, syn); if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { fsr |= (1 << 11); } exc = EXCP_DATA_ABORT; } env->exception.vaddress = addr; env->exception.fsr = fsr; raise_exception(env, exc, syn, target_el); } }
false
qemu
094d028a7968236cd2b7f7b96394f7a3b8ad97c8
void tlb_fill(CPUState *cs, target_ulong addr, int is_write, int mmu_idx, uintptr_t retaddr) { bool ret; uint32_t fsr = 0; ARMMMUFaultInfo fi = {}; ret = arm_tlb_fill(cs, addr, is_write, mmu_idx, &fsr, &fi); if (unlikely(ret)) { ARMCPU *cpu = ARM_CPU(cs); CPUARMState *env = &cpu->env; uint32_t syn, exc; unsigned int target_el; bool same_el; if (retaddr) { cpu_restore_state(cs, retaddr); } target_el = exception_target_el(env); if (fi.stage2) { target_el = 2; env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4; } same_el = arm_current_el(env) == target_el; syn = fsr & ~(1 << 9); if (is_write == 2) { syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn); exc = EXCP_PREFETCH_ABORT; } else { syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, is_write == 1, syn); if (is_write == 1 && arm_feature(env, ARM_FEATURE_V6)) { fsr |= (1 << 11); } exc = EXCP_DATA_ABORT; } env->exception.vaddress = addr; env->exception.fsr = fsr; raise_exception(env, exc, syn, target_el); } }
{ "code": [], "line_no": [] }
void FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3, uintptr_t VAR_4) { bool ret; uint32_t fsr = 0; ARMMMUFaultInfo fi = {}; ret = arm_tlb_fill(VAR_0, VAR_1, VAR_2, VAR_3, &fsr, &fi); if (unlikely(ret)) { ARMCPU *cpu = ARM_CPU(VAR_0); CPUARMState *env = &cpu->env; uint32_t syn, exc; unsigned int VAR_5; bool same_el; if (VAR_4) { cpu_restore_state(VAR_0, VAR_4); } VAR_5 = exception_target_el(env); if (fi.stage2) { VAR_5 = 2; env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4; } same_el = arm_current_el(env) == VAR_5; syn = fsr & ~(1 << 9); if (VAR_2 == 2) { syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn); exc = EXCP_PREFETCH_ABORT; } else { syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, VAR_2 == 1, syn); if (VAR_2 == 1 && arm_feature(env, ARM_FEATURE_V6)) { fsr |= (1 << 11); } exc = EXCP_DATA_ABORT; } env->exception.vaddress = VAR_1; env->exception.fsr = fsr; raise_exception(env, exc, syn, VAR_5); } }
[ "void FUNC_0(CPUState *VAR_0, target_ulong VAR_1, int VAR_2, int VAR_3,\nuintptr_t VAR_4)\n{", "bool ret;", "uint32_t fsr = 0;", "ARMMMUFaultInfo fi = {};", "ret = arm_tlb_fill(VAR_0, VAR_1, VAR_2, VAR_3, &fsr, &fi);", "if (unlikely(ret)) {", "ARMCPU *cpu = ARM_CPU(VAR_0);", "CPUARMState *env = &cpu->env;", "uint32_t syn, exc;", "unsigned int VAR_5;", "bool same_el;", "if (VAR_4) {", "cpu_restore_state(VAR_0, VAR_4);", "}", "VAR_5 = exception_target_el(env);", "if (fi.stage2) {", "VAR_5 = 2;", "env->cp15.hpfar_el2 = extract64(fi.s2addr, 12, 47) << 4;", "}", "same_el = arm_current_el(env) == VAR_5;", "syn = fsr & ~(1 << 9);", "if (VAR_2 == 2) {", "syn = syn_insn_abort(same_el, 0, fi.s1ptw, syn);", "exc = EXCP_PREFETCH_ABORT;", "} else {", "syn = syn_data_abort(same_el, 0, 0, fi.s1ptw, VAR_2 == 1, syn);", "if (VAR_2 == 1 && arm_feature(env, ARM_FEATURE_V6)) {", "fsr |= (1 << 11);", "}", "exc = EXCP_DATA_ABORT;", "}", "env->exception.vaddress = VAR_1;", "env->exception.fsr = fsr;", "raise_exception(env, exc, syn, VAR_5);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ] ]
16,779
static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf) { int err; err = fstat(fd, stbuf); if (err) { return err; } if (fs_ctx->fs_sm == SM_MAPPED) { /* Actual credentials are part of extended attrs */ uid_t tmp_uid; gid_t tmp_gid; mode_t tmp_mode; dev_t tmp_dev; if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = tmp_uid; } if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = tmp_gid; } if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = tmp_mode; } if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = tmp_dev; } } return err; }
false
qemu
b97400caef60ccfb0bc81c59f8bd824c43a0d6c8
static int local_fstat(FsContext *fs_ctx, int fd, struct stat *stbuf) { int err; err = fstat(fd, stbuf); if (err) { return err; } if (fs_ctx->fs_sm == SM_MAPPED) { uid_t tmp_uid; gid_t tmp_gid; mode_t tmp_mode; dev_t tmp_dev; if (fgetxattr(fd, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { stbuf->st_uid = tmp_uid; } if (fgetxattr(fd, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { stbuf->st_gid = tmp_gid; } if (fgetxattr(fd, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { stbuf->st_mode = tmp_mode; } if (fgetxattr(fd, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { stbuf->st_rdev = tmp_dev; } } return err; }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, int VAR_1, struct stat *VAR_2) { int VAR_3; VAR_3 = fstat(VAR_1, VAR_2); if (VAR_3) { return VAR_3; } if (VAR_0->fs_sm == SM_MAPPED) { uid_t tmp_uid; gid_t tmp_gid; mode_t tmp_mode; dev_t tmp_dev; if (fgetxattr(VAR_1, "user.virtfs.uid", &tmp_uid, sizeof(uid_t)) > 0) { VAR_2->st_uid = tmp_uid; } if (fgetxattr(VAR_1, "user.virtfs.gid", &tmp_gid, sizeof(gid_t)) > 0) { VAR_2->st_gid = tmp_gid; } if (fgetxattr(VAR_1, "user.virtfs.mode", &tmp_mode, sizeof(mode_t)) > 0) { VAR_2->st_mode = tmp_mode; } if (fgetxattr(VAR_1, "user.virtfs.rdev", &tmp_dev, sizeof(dev_t)) > 0) { VAR_2->st_rdev = tmp_dev; } } return VAR_3; }
[ "static int FUNC_0(FsContext *VAR_0, int VAR_1, struct stat *VAR_2)\n{", "int VAR_3;", "VAR_3 = fstat(VAR_1, VAR_2);", "if (VAR_3) {", "return VAR_3;", "}", "if (VAR_0->fs_sm == SM_MAPPED) {", "uid_t tmp_uid;", "gid_t tmp_gid;", "mode_t tmp_mode;", "dev_t tmp_dev;", "if (fgetxattr(VAR_1, \"user.virtfs.uid\", &tmp_uid, sizeof(uid_t)) > 0) {", "VAR_2->st_uid = tmp_uid;", "}", "if (fgetxattr(VAR_1, \"user.virtfs.gid\", &tmp_gid, sizeof(gid_t)) > 0) {", "VAR_2->st_gid = tmp_gid;", "}", "if (fgetxattr(VAR_1, \"user.virtfs.mode\", &tmp_mode, sizeof(mode_t)) > 0) {", "VAR_2->st_mode = tmp_mode;", "}", "if (fgetxattr(VAR_1, \"user.virtfs.rdev\", &tmp_dev, sizeof(dev_t)) > 0) {", "VAR_2->st_rdev = tmp_dev;", "}", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
16,781
static void test_visitor_in_native_list_int8(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S8); }
false
qemu
b3db211f3c80bb996a704d665fe275619f728bd4
static void test_visitor_in_native_list_int8(TestInputVisitorData *data, const void *unused) { test_native_list_integer_helper(data, unused, USER_DEF_NATIVE_LIST_UNION_KIND_S8); }
{ "code": [], "line_no": [] }
static void FUNC_0(TestInputVisitorData *VAR_0, const void *VAR_1) { test_native_list_integer_helper(VAR_0, VAR_1, USER_DEF_NATIVE_LIST_UNION_KIND_S8); }
[ "static void FUNC_0(TestInputVisitorData *VAR_0,\nconst void *VAR_1)\n{", "test_native_list_integer_helper(VAR_0, VAR_1,\nUSER_DEF_NATIVE_LIST_UNION_KIND_S8);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11 ] ]
16,782
static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) { PCIXenPlatformState *s = opaque; PCIDevice *pci_dev = PCI_DEVICE(s); switch (addr) { case 0: /* Platform flags */ platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val); break; case 4: if (val == 1) { /* * SUSE unplug for Xenlinux * xen-kmp used this since xen-3.0.4, instead the official protocol * from xen-3.3+ It did an unconditional "outl(1, (ioaddr + 4));" * Pre VMDP 1.7 used 4 and 8 depending on how VMDP was configured. * If VMDP was to control both disk and LAN it would use 4. * If it controlled just disk or just LAN, it would use 8 below. */ pci_unplug_disks(pci_dev->bus); pci_unplug_nics(pci_dev->bus); } break; case 8: switch (val) { case 1: pci_unplug_disks(pci_dev->bus); break; case 2: pci_unplug_nics(pci_dev->bus); break; default: log_writeb(s, (uint32_t)val); break; } break; default: break; } }
false
qemu
ae4d2eb273b167dad748ea4249720319240b1ac2
static void xen_platform_ioport_writeb(void *opaque, hwaddr addr, uint64_t val, unsigned int size) { PCIXenPlatformState *s = opaque; PCIDevice *pci_dev = PCI_DEVICE(s); switch (addr) { case 0: platform_fixed_ioport_writeb(opaque, 0, (uint32_t)val); break; case 4: if (val == 1) { pci_unplug_disks(pci_dev->bus); pci_unplug_nics(pci_dev->bus); } break; case 8: switch (val) { case 1: pci_unplug_disks(pci_dev->bus); break; case 2: pci_unplug_nics(pci_dev->bus); break; default: log_writeb(s, (uint32_t)val); break; } break; default: break; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, hwaddr VAR_1, uint64_t VAR_2, unsigned int VAR_3) { PCIXenPlatformState *s = VAR_0; PCIDevice *pci_dev = PCI_DEVICE(s); switch (VAR_1) { case 0: platform_fixed_ioport_writeb(VAR_0, 0, (uint32_t)VAR_2); break; case 4: if (VAR_2 == 1) { pci_unplug_disks(pci_dev->bus); pci_unplug_nics(pci_dev->bus); } break; case 8: switch (VAR_2) { case 1: pci_unplug_disks(pci_dev->bus); break; case 2: pci_unplug_nics(pci_dev->bus); break; default: log_writeb(s, (uint32_t)VAR_2); break; } break; default: break; } }
[ "static void FUNC_0(void *VAR_0, hwaddr VAR_1,\nuint64_t VAR_2, unsigned int VAR_3)\n{", "PCIXenPlatformState *s = VAR_0;", "PCIDevice *pci_dev = PCI_DEVICE(s);", "switch (VAR_1) {", "case 0:\nplatform_fixed_ioport_writeb(VAR_0, 0, (uint32_t)VAR_2);", "break;", "case 4:\nif (VAR_2 == 1) {", "pci_unplug_disks(pci_dev->bus);", "pci_unplug_nics(pci_dev->bus);", "}", "break;", "case 8:\nswitch (VAR_2) {", "case 1:\npci_unplug_disks(pci_dev->bus);", "break;", "case 2:\npci_unplug_nics(pci_dev->bus);", "break;", "default:\nlog_writeb(s, (uint32_t)VAR_2);", "break;", "}", "break;", "default:\nbreak;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21, 23 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53, 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81 ] ]
16,784
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) { PerThreadContext *p = avctx->internal->thread_ctx; FrameThreadContext *fctx; AVFrame *dst, *tmp; FF_DISABLE_DEPRECATION_WARNINGS int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) || avctx->thread_safe_callbacks || ( #if FF_API_GET_BUFFER !avctx->get_buffer && #endif avctx->get_buffer2 == avcodec_default_get_buffer2); FF_ENABLE_DEPRECATION_WARNINGS if (!f->f->data[0]) return; if (avctx->debug & FF_DEBUG_BUFFERS) av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f); av_buffer_unref(&f->progress); f->owner = NULL; if (can_direct_free) { av_frame_unref(f->f); return; } fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers)) goto fail; tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated, (p->num_released_buffers + 1) * sizeof(*p->released_buffers)); if (!tmp) goto fail; p->released_buffers = tmp; dst = &p->released_buffers[p->num_released_buffers]; av_frame_move_ref(dst, f->f); p->num_released_buffers++; fail: pthread_mutex_unlock(&fctx->buffer_mutex); }
false
FFmpeg
a553c6a347d3d28d7ee44c3df3d5c4ee780dba23
void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) { PerThreadContext *p = avctx->internal->thread_ctx; FrameThreadContext *fctx; AVFrame *dst, *tmp; FF_DISABLE_DEPRECATION_WARNINGS int can_direct_free = !(avctx->active_thread_type & FF_THREAD_FRAME) || avctx->thread_safe_callbacks || ( #if FF_API_GET_BUFFER !avctx->get_buffer && #endif avctx->get_buffer2 == avcodec_default_get_buffer2); FF_ENABLE_DEPRECATION_WARNINGS if (!f->f->data[0]) return; if (avctx->debug & FF_DEBUG_BUFFERS) av_log(avctx, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", f); av_buffer_unref(&f->progress); f->owner = NULL; if (can_direct_free) { av_frame_unref(f->f); return; } fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers)) goto fail; tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated, (p->num_released_buffers + 1) * sizeof(*p->released_buffers)); if (!tmp) goto fail; p->released_buffers = tmp; dst = &p->released_buffers[p->num_released_buffers]; av_frame_move_ref(dst, f->f); p->num_released_buffers++; fail: pthread_mutex_unlock(&fctx->buffer_mutex); }
{ "code": [], "line_no": [] }
void FUNC_0(AVCodecContext *VAR_0, ThreadFrame *VAR_1) { PerThreadContext *p = VAR_0->internal->thread_ctx; FrameThreadContext *fctx; AVFrame *dst, *tmp; FF_DISABLE_DEPRECATION_WARNINGS int can_direct_free = !(VAR_0->active_thread_type & FF_THREAD_FRAME) || VAR_0->thread_safe_callbacks || ( #if FF_API_GET_BUFFER !VAR_0->get_buffer && #endif VAR_0->get_buffer2 == avcodec_default_get_buffer2); FF_ENABLE_DEPRECATION_WARNINGS if (!VAR_1->VAR_1->data[0]) return; if (VAR_0->debug & FF_DEBUG_BUFFERS) av_log(VAR_0, AV_LOG_DEBUG, "thread_release_buffer called on pic %p\n", VAR_1); av_buffer_unref(&VAR_1->progress); VAR_1->owner = NULL; if (can_direct_free) { av_frame_unref(VAR_1->VAR_1); return; } fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers)) goto fail; tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated, (p->num_released_buffers + 1) * sizeof(*p->released_buffers)); if (!tmp) goto fail; p->released_buffers = tmp; dst = &p->released_buffers[p->num_released_buffers]; av_frame_move_ref(dst, VAR_1->VAR_1); p->num_released_buffers++; fail: pthread_mutex_unlock(&fctx->buffer_mutex); }
[ "void FUNC_0(AVCodecContext *VAR_0, ThreadFrame *VAR_1)\n{", "PerThreadContext *p = VAR_0->internal->thread_ctx;", "FrameThreadContext *fctx;", "AVFrame *dst, *tmp;", "FF_DISABLE_DEPRECATION_WARNINGS\nint can_direct_free = !(VAR_0->active_thread_type & FF_THREAD_FRAME) ||\nVAR_0->thread_safe_callbacks ||\n(\n#if FF_API_GET_BUFFER\n!VAR_0->get_buffer &&\n#endif\nVAR_0->get_buffer2 == avcodec_default_get_buffer2);", "FF_ENABLE_DEPRECATION_WARNINGS\nif (!VAR_1->VAR_1->data[0])\nreturn;", "if (VAR_0->debug & FF_DEBUG_BUFFERS)\nav_log(VAR_0, AV_LOG_DEBUG, \"thread_release_buffer called on pic %p\\n\", VAR_1);", "av_buffer_unref(&VAR_1->progress);", "VAR_1->owner = NULL;", "if (can_direct_free) {", "av_frame_unref(VAR_1->VAR_1);", "return;", "}", "fctx = p->parent;", "pthread_mutex_lock(&fctx->buffer_mutex);", "if (p->num_released_buffers + 1 >= INT_MAX / sizeof(*p->released_buffers))\ngoto fail;", "tmp = av_fast_realloc(p->released_buffers, &p->released_buffers_allocated,\n(p->num_released_buffers + 1) *\nsizeof(*p->released_buffers));", "if (!tmp)\ngoto fail;", "p->released_buffers = tmp;", "dst = &p->released_buffers[p->num_released_buffers];", "av_frame_move_ref(dst, VAR_1->VAR_1);", "p->num_released_buffers++;", "fail:\npthread_mutex_unlock(&fctx->buffer_mutex);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11, 13, 15, 17, 19, 21, 23, 25 ], [ 27, 31, 33 ], [ 37, 39 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65, 67 ], [ 69, 71, 73 ], [ 75, 77 ], [ 79 ], [ 83 ], [ 85 ], [ 89 ], [ 93, 95 ], [ 97 ] ]
16,785
static int count_contiguous_clusters_by_type(int nb_clusters, uint64_t *l2_table, int wanted_type) { int i; for (i = 0; i < nb_clusters; i++) { int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i])); if (type != wanted_type) { break; } } return i; }
false
qemu
4341df8a83d6a528a1e2855735f87fc3aab42b70
static int count_contiguous_clusters_by_type(int nb_clusters, uint64_t *l2_table, int wanted_type) { int i; for (i = 0; i < nb_clusters; i++) { int type = qcow2_get_cluster_type(be64_to_cpu(l2_table[i])); if (type != wanted_type) { break; } } return i; }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0, uint64_t *VAR_1, int VAR_2) { int VAR_3; for (VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) { int VAR_4 = qcow2_get_cluster_type(be64_to_cpu(VAR_1[VAR_3])); if (VAR_4 != VAR_2) { break; } } return VAR_3; }
[ "static int FUNC_0(int VAR_0,\nuint64_t *VAR_1,\nint VAR_2)\n{", "int VAR_3;", "for (VAR_3 = 0; VAR_3 < VAR_0; VAR_3++) {", "int VAR_4 = qcow2_get_cluster_type(be64_to_cpu(VAR_1[VAR_3]));", "if (VAR_4 != VAR_2) {", "break;", "}", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ] ]
16,786
static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint8_t *p = inbuf; int cmd = r->req.cmd.buf[0]; int len = r->req.cmd.xfer; int hdr_len = (cmd == MODE_SELECT ? 4 : 8); int bd_len; int pass; /* We only support PF=1, SP=0. */ if ((r->req.cmd.buf[1] & 0x11) != 0x10) { goto invalid_field; } if (len < hdr_len) { goto invalid_param_len; } bd_len = (cmd == MODE_SELECT ? p[3] : lduw_be_p(&p[6])); len -= hdr_len; p += hdr_len; if (len < bd_len) { goto invalid_param_len; } if (bd_len != 0 && bd_len != 8) { goto invalid_param; } len -= bd_len; p += bd_len; /* Ensure no change is made if there is an error! */ for (pass = 0; pass < 2; pass++) { if (mode_select_pages(r, p, len, pass == 1) < 0) { assert(pass == 0); return; } } if (!bdrv_enable_write_cache(s->qdev.conf.bs)) { /* The request is used as the AIO opaque value, so add a ref. */ scsi_req_ref(&r->req); block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &r->acct, 0, BLOCK_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return; } scsi_req_complete(&r->req, GOOD); return; invalid_param: scsi_check_condition(r, SENSE_CODE(INVALID_PARAM)); return; invalid_param_len: scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); return; invalid_field: scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void scsi_disk_emulate_mode_select(SCSIDiskReq *r, uint8_t *inbuf) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev); uint8_t *p = inbuf; int cmd = r->req.cmd.buf[0]; int len = r->req.cmd.xfer; int hdr_len = (cmd == MODE_SELECT ? 4 : 8); int bd_len; int pass; if ((r->req.cmd.buf[1] & 0x11) != 0x10) { goto invalid_field; } if (len < hdr_len) { goto invalid_param_len; } bd_len = (cmd == MODE_SELECT ? p[3] : lduw_be_p(&p[6])); len -= hdr_len; p += hdr_len; if (len < bd_len) { goto invalid_param_len; } if (bd_len != 0 && bd_len != 8) { goto invalid_param; } len -= bd_len; p += bd_len; for (pass = 0; pass < 2; pass++) { if (mode_select_pages(r, p, len, pass == 1) < 0) { assert(pass == 0); return; } } if (!bdrv_enable_write_cache(s->qdev.conf.bs)) { scsi_req_ref(&r->req); block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &r->acct, 0, BLOCK_ACCT_FLUSH); r->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, r); return; } scsi_req_complete(&r->req, GOOD); return; invalid_param: scsi_check_condition(r, SENSE_CODE(INVALID_PARAM)); return; invalid_param_len: scsi_check_condition(r, SENSE_CODE(INVALID_PARAM_LEN)); return; invalid_field: scsi_check_condition(r, SENSE_CODE(INVALID_FIELD)); }
{ "code": [], "line_no": [] }
static void FUNC_0(SCSIDiskReq *VAR_0, uint8_t *VAR_1) { SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev); uint8_t *p = VAR_1; int VAR_2 = VAR_0->req.VAR_2.buf[0]; int VAR_3 = VAR_0->req.VAR_2.xfer; int VAR_4 = (VAR_2 == MODE_SELECT ? 4 : 8); int VAR_5; int VAR_6; if ((VAR_0->req.VAR_2.buf[1] & 0x11) != 0x10) { goto invalid_field; } if (VAR_3 < VAR_4) { goto invalid_param_len; } VAR_5 = (VAR_2 == MODE_SELECT ? p[3] : lduw_be_p(&p[6])); VAR_3 -= VAR_4; p += VAR_4; if (VAR_3 < VAR_5) { goto invalid_param_len; } if (VAR_5 != 0 && VAR_5 != 8) { goto invalid_param; } VAR_3 -= VAR_5; p += VAR_5; for (VAR_6 = 0; VAR_6 < 2; VAR_6++) { if (mode_select_pages(VAR_0, p, VAR_3, VAR_6 == 1) < 0) { assert(VAR_6 == 0); return; } } if (!bdrv_enable_write_cache(s->qdev.conf.bs)) { scsi_req_ref(&VAR_0->req); block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &VAR_0->acct, 0, BLOCK_ACCT_FLUSH); VAR_0->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, VAR_0); return; } scsi_req_complete(&VAR_0->req, GOOD); return; invalid_param: scsi_check_condition(VAR_0, SENSE_CODE(INVALID_PARAM)); return; invalid_param_len: scsi_check_condition(VAR_0, SENSE_CODE(INVALID_PARAM_LEN)); return; invalid_field: scsi_check_condition(VAR_0, SENSE_CODE(INVALID_FIELD)); }
[ "static void FUNC_0(SCSIDiskReq *VAR_0, uint8_t *VAR_1)\n{", "SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, VAR_0->req.dev);", "uint8_t *p = VAR_1;", "int VAR_2 = VAR_0->req.VAR_2.buf[0];", "int VAR_3 = VAR_0->req.VAR_2.xfer;", "int VAR_4 = (VAR_2 == MODE_SELECT ? 4 : 8);", "int VAR_5;", "int VAR_6;", "if ((VAR_0->req.VAR_2.buf[1] & 0x11) != 0x10) {", "goto invalid_field;", "}", "if (VAR_3 < VAR_4) {", "goto invalid_param_len;", "}", "VAR_5 = (VAR_2 == MODE_SELECT ? p[3] : lduw_be_p(&p[6]));", "VAR_3 -= VAR_4;", "p += VAR_4;", "if (VAR_3 < VAR_5) {", "goto invalid_param_len;", "}", "if (VAR_5 != 0 && VAR_5 != 8) {", "goto invalid_param;", "}", "VAR_3 -= VAR_5;", "p += VAR_5;", "for (VAR_6 = 0; VAR_6 < 2; VAR_6++) {", "if (mode_select_pages(VAR_0, p, VAR_3, VAR_6 == 1) < 0) {", "assert(VAR_6 == 0);", "return;", "}", "}", "if (!bdrv_enable_write_cache(s->qdev.conf.bs)) {", "scsi_req_ref(&VAR_0->req);", "block_acct_start(bdrv_get_stats(s->qdev.conf.bs), &VAR_0->acct, 0,\nBLOCK_ACCT_FLUSH);", "VAR_0->req.aiocb = bdrv_aio_flush(s->qdev.conf.bs, scsi_aio_complete, VAR_0);", "return;", "}", "scsi_req_complete(&VAR_0->req, GOOD);", "return;", "invalid_param:\nscsi_check_condition(VAR_0, SENSE_CODE(INVALID_PARAM));", "return;", "invalid_param_len:\nscsi_check_condition(VAR_0, SENSE_CODE(INVALID_PARAM_LEN));", "return;", "invalid_field:\nscsi_check_condition(VAR_0, SENSE_CODE(INVALID_FIELD));", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 103, 105 ], [ 107 ], [ 111, 113 ], [ 115 ], [ 119, 121 ], [ 123 ] ]
16,788
int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; int32 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0x9E; if ( 0 <= shiftCount ) { if ( a != 0xCF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; } return (sbits32) 0x80000000; } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig = ( aSig | 0x00800000 )<<8; z = aSig>>( - shiftCount ); if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
false
qemu
f090c9d4ad5812fb92843d6470a1111c15190c4c
int32 float32_to_int32_round_to_zero( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; int32 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0x9E; if ( 0 <= shiftCount ) { if ( a != 0xCF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; } return (sbits32) 0x80000000; } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig = ( aSig | 0x00800000 )<<8; z = aSig>>( - shiftCount ); if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
{ "code": [], "line_no": [] }
int32 FUNC_0( float32 a STATUS_PARAM ) { flag aSign; int16 aExp, shiftCount; bits32 aSig; int32 z; aSig = extractFloat32Frac( a ); aExp = extractFloat32Exp( a ); aSign = extractFloat32Sign( a ); shiftCount = aExp - 0x9E; if ( 0 <= shiftCount ) { if ( a != 0xCF000000 ) { float_raise( float_flag_invalid STATUS_VAR); if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF; } return (sbits32) 0x80000000; } else if ( aExp <= 0x7E ) { if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact; return 0; } aSig = ( aSig | 0x00800000 )<<8; z = aSig>>( - shiftCount ); if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) { STATUS(float_exception_flags) |= float_flag_inexact; } if ( aSign ) z = - z; return z; }
[ "int32 FUNC_0( float32 a STATUS_PARAM )\n{", "flag aSign;", "int16 aExp, shiftCount;", "bits32 aSig;", "int32 z;", "aSig = extractFloat32Frac( a );", "aExp = extractFloat32Exp( a );", "aSign = extractFloat32Sign( a );", "shiftCount = aExp - 0x9E;", "if ( 0 <= shiftCount ) {", "if ( a != 0xCF000000 ) {", "float_raise( float_flag_invalid STATUS_VAR);", "if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF;", "}", "return (sbits32) 0x80000000;", "}", "else if ( aExp <= 0x7E ) {", "if ( aExp | aSig ) STATUS(float_exception_flags) |= float_flag_inexact;", "return 0;", "}", "aSig = ( aSig | 0x00800000 )<<8;", "z = aSig>>( - shiftCount );", "if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {", "STATUS(float_exception_flags) |= float_flag_inexact;", "}", "if ( aSign ) z = - z;", "return z;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ] ]
16,789
QEMUFile *qemu_popen_cmd(const char *command, const char *mode) { FILE *stdio_file; QEMUFileStdio *s; stdio_file = popen(command, mode); if (stdio_file == NULL) { return NULL; } if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); return NULL; } s = g_malloc0(sizeof(QEMUFileStdio)); s->stdio_file = stdio_file; if(mode[0] == 'r') { s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops); } else { s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops); } return s->file; }
false
qemu
a4cc73d629d43c8a4d171d043ff229a959df3ca6
QEMUFile *qemu_popen_cmd(const char *command, const char *mode) { FILE *stdio_file; QEMUFileStdio *s; stdio_file = popen(command, mode); if (stdio_file == NULL) { return NULL; } if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); return NULL; } s = g_malloc0(sizeof(QEMUFileStdio)); s->stdio_file = stdio_file; if(mode[0] == 'r') { s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops); } else { s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops); } return s->file; }
{ "code": [], "line_no": [] }
QEMUFile *FUNC_0(const char *command, const char *mode) { FILE *stdio_file; QEMUFileStdio *s; stdio_file = popen(command, mode); if (stdio_file == NULL) { return NULL; } if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) { fprintf(stderr, "qemu_popen: Argument validity check failed\n"); return NULL; } s = g_malloc0(sizeof(QEMUFileStdio)); s->stdio_file = stdio_file; if(mode[0] == 'r') { s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops); } else { s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops); } return s->file; }
[ "QEMUFile *FUNC_0(const char *command, const char *mode)\n{", "FILE *stdio_file;", "QEMUFileStdio *s;", "stdio_file = popen(command, mode);", "if (stdio_file == NULL) {", "return NULL;", "}", "if (mode == NULL || (mode[0] != 'r' && mode[0] != 'w') || mode[1] != 0) {", "fprintf(stderr, \"qemu_popen: Argument validity check failed\\n\");", "return NULL;", "}", "s = g_malloc0(sizeof(QEMUFileStdio));", "s->stdio_file = stdio_file;", "if(mode[0] == 'r') {", "s->file = qemu_fopen_ops(s, &stdio_pipe_read_ops);", "} else {", "s->file = qemu_fopen_ops(s, &stdio_pipe_write_ops);", "}", "return s->file;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ] ]
16,790
static int openpic_load(QEMUFile* f, void *opaque, int version_id) { OpenPICState *opp = (OpenPICState *)opaque; unsigned int i; if (version_id != 1) return -EINVAL; qemu_get_be32s(f, &opp->glbc); qemu_get_be32s(f, &opp->veni); qemu_get_be32s(f, &opp->pint); qemu_get_be32s(f, &opp->spve); qemu_get_be32s(f, &opp->tifr); for (i = 0; i < opp->max_irq; i++) { qemu_get_be32s(f, &opp->src[i].ipvp); qemu_get_be32s(f, &opp->src[i].ide); qemu_get_sbe32s(f, &opp->src[i].last_cpu); qemu_get_sbe32s(f, &opp->src[i].pending); } qemu_get_be32s(f, &opp->nb_cpus); for (i = 0; i < opp->nb_cpus; i++) { qemu_get_be32s(f, &opp->dst[i].pctp); qemu_get_be32s(f, &opp->dst[i].pcsr); openpic_load_IRQ_queue(f, &opp->dst[i].raised); openpic_load_IRQ_queue(f, &opp->dst[i].servicing); } for (i = 0; i < MAX_TMR; i++) { qemu_get_be32s(f, &opp->timers[i].ticc); qemu_get_be32s(f, &opp->timers[i].tibc); } return 0; }
false
qemu
c975330ec4f5674f2899331f914c04ecba6edf26
static int openpic_load(QEMUFile* f, void *opaque, int version_id) { OpenPICState *opp = (OpenPICState *)opaque; unsigned int i; if (version_id != 1) return -EINVAL; qemu_get_be32s(f, &opp->glbc); qemu_get_be32s(f, &opp->veni); qemu_get_be32s(f, &opp->pint); qemu_get_be32s(f, &opp->spve); qemu_get_be32s(f, &opp->tifr); for (i = 0; i < opp->max_irq; i++) { qemu_get_be32s(f, &opp->src[i].ipvp); qemu_get_be32s(f, &opp->src[i].ide); qemu_get_sbe32s(f, &opp->src[i].last_cpu); qemu_get_sbe32s(f, &opp->src[i].pending); } qemu_get_be32s(f, &opp->nb_cpus); for (i = 0; i < opp->nb_cpus; i++) { qemu_get_be32s(f, &opp->dst[i].pctp); qemu_get_be32s(f, &opp->dst[i].pcsr); openpic_load_IRQ_queue(f, &opp->dst[i].raised); openpic_load_IRQ_queue(f, &opp->dst[i].servicing); } for (i = 0; i < MAX_TMR; i++) { qemu_get_be32s(f, &opp->timers[i].ticc); qemu_get_be32s(f, &opp->timers[i].tibc); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(QEMUFile* VAR_0, void *VAR_1, int VAR_2) { OpenPICState *opp = (OpenPICState *)VAR_1; unsigned int VAR_3; if (VAR_2 != 1) return -EINVAL; qemu_get_be32s(VAR_0, &opp->glbc); qemu_get_be32s(VAR_0, &opp->veni); qemu_get_be32s(VAR_0, &opp->pint); qemu_get_be32s(VAR_0, &opp->spve); qemu_get_be32s(VAR_0, &opp->tifr); for (VAR_3 = 0; VAR_3 < opp->max_irq; VAR_3++) { qemu_get_be32s(VAR_0, &opp->src[VAR_3].ipvp); qemu_get_be32s(VAR_0, &opp->src[VAR_3].ide); qemu_get_sbe32s(VAR_0, &opp->src[VAR_3].last_cpu); qemu_get_sbe32s(VAR_0, &opp->src[VAR_3].pending); } qemu_get_be32s(VAR_0, &opp->nb_cpus); for (VAR_3 = 0; VAR_3 < opp->nb_cpus; VAR_3++) { qemu_get_be32s(VAR_0, &opp->dst[VAR_3].pctp); qemu_get_be32s(VAR_0, &opp->dst[VAR_3].pcsr); openpic_load_IRQ_queue(VAR_0, &opp->dst[VAR_3].raised); openpic_load_IRQ_queue(VAR_0, &opp->dst[VAR_3].servicing); } for (VAR_3 = 0; VAR_3 < MAX_TMR; VAR_3++) { qemu_get_be32s(VAR_0, &opp->timers[VAR_3].ticc); qemu_get_be32s(VAR_0, &opp->timers[VAR_3].tibc); } return 0; }
[ "static int FUNC_0(QEMUFile* VAR_0, void *VAR_1, int VAR_2)\n{", "OpenPICState *opp = (OpenPICState *)VAR_1;", "unsigned int VAR_3;", "if (VAR_2 != 1)\nreturn -EINVAL;", "qemu_get_be32s(VAR_0, &opp->glbc);", "qemu_get_be32s(VAR_0, &opp->veni);", "qemu_get_be32s(VAR_0, &opp->pint);", "qemu_get_be32s(VAR_0, &opp->spve);", "qemu_get_be32s(VAR_0, &opp->tifr);", "for (VAR_3 = 0; VAR_3 < opp->max_irq; VAR_3++) {", "qemu_get_be32s(VAR_0, &opp->src[VAR_3].ipvp);", "qemu_get_be32s(VAR_0, &opp->src[VAR_3].ide);", "qemu_get_sbe32s(VAR_0, &opp->src[VAR_3].last_cpu);", "qemu_get_sbe32s(VAR_0, &opp->src[VAR_3].pending);", "}", "qemu_get_be32s(VAR_0, &opp->nb_cpus);", "for (VAR_3 = 0; VAR_3 < opp->nb_cpus; VAR_3++) {", "qemu_get_be32s(VAR_0, &opp->dst[VAR_3].pctp);", "qemu_get_be32s(VAR_0, &opp->dst[VAR_3].pcsr);", "openpic_load_IRQ_queue(VAR_0, &opp->dst[VAR_3].raised);", "openpic_load_IRQ_queue(VAR_0, &opp->dst[VAR_3].servicing);", "}", "for (VAR_3 = 0; VAR_3 < MAX_TMR; VAR_3++) {", "qemu_get_be32s(VAR_0, &opp->timers[VAR_3].ticc);", "qemu_get_be32s(VAR_0, &opp->timers[VAR_3].tibc);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ] ]
16,791
uint64_t HELPER(abs_i64)(int64_t val) { HELPER_LOG("%s: val 0x%" PRIx64 "\n", __func__, val); if (val < 0) { return -val; } else { return val; } }
false
qemu
d30107814c8d02f1896bd57249aef1b5aaed38c9
uint64_t HELPER(abs_i64)(int64_t val) { HELPER_LOG("%s: val 0x%" PRIx64 "\n", __func__, val); if (val < 0) { return -val; } else { return val; } }
{ "code": [], "line_no": [] }
uint64_t FUNC_0(abs_i64)(int64_t val) { HELPER_LOG("%s: val 0x%" PRIx64 "\n", __func__, val); if (val < 0) { return -val; } else { return val; } }
[ "uint64_t FUNC_0(abs_i64)(int64_t val)\n{", "HELPER_LOG(\"%s: val 0x%\" PRIx64 \"\\n\", __func__, val);", "if (val < 0) {", "return -val;", "} else {", "return val;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
16,793
void blk_resume_after_migration(Error **errp) { BlockBackend *blk; Error *local_err = NULL; for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { if (!blk->disable_perm) { continue; } blk->disable_perm = false; blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); if (local_err) { error_propagate(errp, local_err); blk->disable_perm = true; return; } } }
false
qemu
4417ab7adf1613799054be5afedf810fc2524ee8
void blk_resume_after_migration(Error **errp) { BlockBackend *blk; Error *local_err = NULL; for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { if (!blk->disable_perm) { continue; } blk->disable_perm = false; blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); if (local_err) { error_propagate(errp, local_err); blk->disable_perm = true; return; } } }
{ "code": [], "line_no": [] }
void FUNC_0(Error **VAR_0) { BlockBackend *blk; Error *local_err = NULL; for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) { if (!blk->disable_perm) { continue; } blk->disable_perm = false; blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err); if (local_err) { error_propagate(VAR_0, local_err); blk->disable_perm = true; return; } } }
[ "void FUNC_0(Error **VAR_0)\n{", "BlockBackend *blk;", "Error *local_err = NULL;", "for (blk = blk_all_next(NULL); blk; blk = blk_all_next(blk)) {", "if (!blk->disable_perm) {", "continue;", "}", "blk->disable_perm = false;", "blk_set_perm(blk, blk->perm, blk->shared_perm, &local_err);", "if (local_err) {", "error_propagate(VAR_0, local_err);", "blk->disable_perm = true;", "return;", "}", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ] ]
16,796
static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) { VFIOGroup *group; struct vfio_pci_hot_reset_info *info; struct vfio_pci_dependent_device *devices; struct vfio_pci_hot_reset *reset; int32_t *fds; int ret, i, count; bool multi = false; trace_vfio_pci_hot_reset(vdev->vbasedev.name, single ? "one" : "multi"); vfio_pci_pre_reset(vdev); vdev->vbasedev.needs_reset = false; info = g_malloc0(sizeof(*info)); info->argsz = sizeof(*info); ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret && errno != ENOSPC) { ret = -errno; if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %04x:%02x:%02x.%x, " "no available reset mechanism.", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } goto out_single; } count = info->count; info = g_realloc(info, sizeof(*info) + (count * sizeof(*devices))); info->argsz = sizeof(*info) + (count * sizeof(*devices)); devices = &info->devices[0]; ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret) { ret = -errno; error_report("vfio: hot reset info failed: %m"); goto out_single; } trace_vfio_pci_hot_reset_has_dep_devices(vdev->vbasedev.name); /* Verify that we have all the groups required */ for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); trace_vfio_pci_hot_reset_dep_devices(host.domain, host.bus, host.slot, host.function, devices[i].group_id); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %s, " "depends on group %d which is not owned.", vdev->vbasedev.name, devices[i].group_id); } ret = -EPERM; goto out; } /* Prep dependent devices for reset and clear our marker. */ QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { if (single) { ret = -EINVAL; goto out_single; } vfio_pci_pre_reset(tmp); tmp->vbasedev.needs_reset = false; multi = true; break; } } } if (!single && !multi) { ret = -EINVAL; goto out_single; } /* Determine how many group fds need to be passed */ count = 0; QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { count++; break; } } } reset = g_malloc0(sizeof(*reset) + (count * sizeof(*fds))); reset->argsz = sizeof(*reset) + (count * sizeof(*fds)); fds = &reset->group_fds[0]; /* Fill in group fds */ QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { fds[reset->count++] = group->fd; break; } } } /* Bus reset! */ ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, reset); g_free(reset); trace_vfio_pci_hot_reset_result(vdev->vbasedev.name, ret ? "%m" : "Success"); out: /* Re-enable INTx on affected devices */ for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { break; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { vfio_pci_post_reset(tmp); break; } } } out_single: vfio_pci_post_reset(vdev); g_free(info); return ret; }
false
qemu
7df9381b7aa56c897e344f3bfe43bf5848bbd3e0
static int vfio_pci_hot_reset(VFIOPCIDevice *vdev, bool single) { VFIOGroup *group; struct vfio_pci_hot_reset_info *info; struct vfio_pci_dependent_device *devices; struct vfio_pci_hot_reset *reset; int32_t *fds; int ret, i, count; bool multi = false; trace_vfio_pci_hot_reset(vdev->vbasedev.name, single ? "one" : "multi"); vfio_pci_pre_reset(vdev); vdev->vbasedev.needs_reset = false; info = g_malloc0(sizeof(*info)); info->argsz = sizeof(*info); ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret && errno != ENOSPC) { ret = -errno; if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %04x:%02x:%02x.%x, " "no available reset mechanism.", vdev->host.domain, vdev->host.bus, vdev->host.slot, vdev->host.function); } goto out_single; } count = info->count; info = g_realloc(info, sizeof(*info) + (count * sizeof(*devices))); info->argsz = sizeof(*info) + (count * sizeof(*devices)); devices = &info->devices[0]; ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, info); if (ret) { ret = -errno; error_report("vfio: hot reset info failed: %m"); goto out_single; } trace_vfio_pci_hot_reset_has_dep_devices(vdev->vbasedev.name); for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); trace_vfio_pci_hot_reset_dep_devices(host.domain, host.bus, host.slot, host.function, devices[i].group_id); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { if (!vdev->has_pm_reset) { error_report("vfio: Cannot reset device %s, " "depends on group %d which is not owned.", vdev->vbasedev.name, devices[i].group_id); } ret = -EPERM; goto out; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { if (single) { ret = -EINVAL; goto out_single; } vfio_pci_pre_reset(tmp); tmp->vbasedev.needs_reset = false; multi = true; break; } } } if (!single && !multi) { ret = -EINVAL; goto out_single; } count = 0; QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { count++; break; } } } reset = g_malloc0(sizeof(*reset) + (count * sizeof(*fds))); reset->argsz = sizeof(*reset) + (count * sizeof(*fds)); fds = &reset->group_fds[0]; QLIST_FOREACH(group, &vfio_group_list, next) { for (i = 0; i < info->count; i++) { if (group->groupid == devices[i].group_id) { fds[reset->count++] = group->fd; break; } } } ret = ioctl(vdev->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, reset); g_free(reset); trace_vfio_pci_hot_reset_result(vdev->vbasedev.name, ret ? "%m" : "Success"); out: for (i = 0; i < info->count; i++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = devices[i].segment; host.bus = devices[i].bus; host.slot = PCI_SLOT(devices[i].devfn); host.function = PCI_FUNC(devices[i].devfn); if (vfio_pci_host_match(&host, &vdev->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == devices[i].group_id) { break; } } if (!group) { break; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { vfio_pci_post_reset(tmp); break; } } } out_single: vfio_pci_post_reset(vdev); g_free(info); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(VFIOPCIDevice *VAR_0, bool VAR_1) { VFIOGroup *group; struct vfio_pci_hot_reset_info *VAR_2; struct vfio_pci_dependent_device *VAR_3; struct FUNC_0 *VAR_4; int32_t *fds; int VAR_5, VAR_6, VAR_7; bool multi = false; trace_vfio_pci_hot_reset(VAR_0->vbasedev.name, VAR_1 ? "one" : "multi"); vfio_pci_pre_reset(VAR_0); VAR_0->vbasedev.needs_reset = false; VAR_2 = g_malloc0(sizeof(*VAR_2)); VAR_2->argsz = sizeof(*VAR_2); VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, VAR_2); if (VAR_5 && errno != ENOSPC) { VAR_5 = -errno; if (!VAR_0->has_pm_reset) { error_report("vfio: Cannot VAR_4 device %04x:%02x:%02x.%x, " "no available VAR_4 mechanism.", VAR_0->host.domain, VAR_0->host.bus, VAR_0->host.slot, VAR_0->host.function); } goto out_single; } VAR_7 = VAR_2->VAR_7; VAR_2 = g_realloc(VAR_2, sizeof(*VAR_2) + (VAR_7 * sizeof(*VAR_3))); VAR_2->argsz = sizeof(*VAR_2) + (VAR_7 * sizeof(*VAR_3)); VAR_3 = &VAR_2->VAR_3[0]; VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, VAR_2); if (VAR_5) { VAR_5 = -errno; error_report("vfio: hot VAR_4 VAR_2 failed: %m"); goto out_single; } trace_vfio_pci_hot_reset_has_dep_devices(VAR_0->vbasedev.name); for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = VAR_3[VAR_6].segment; host.bus = VAR_3[VAR_6].bus; host.slot = PCI_SLOT(VAR_3[VAR_6].devfn); host.function = PCI_FUNC(VAR_3[VAR_6].devfn); trace_vfio_pci_hot_reset_dep_devices(host.domain, host.bus, host.slot, host.function, VAR_3[VAR_6].group_id); if (vfio_pci_host_match(&host, &VAR_0->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == VAR_3[VAR_6].group_id) { break; } } if (!group) { if (!VAR_0->has_pm_reset) { error_report("vfio: Cannot VAR_4 device %s, " "depends on group %d which is not owned.", VAR_0->vbasedev.name, VAR_3[VAR_6].group_id); } VAR_5 = -EPERM; goto out; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { if (VAR_1) { VAR_5 = -EINVAL; goto out_single; } vfio_pci_pre_reset(tmp); tmp->vbasedev.needs_reset = false; multi = true; break; } } } if (!VAR_1 && !multi) { VAR_5 = -EINVAL; goto out_single; } VAR_7 = 0; QLIST_FOREACH(group, &vfio_group_list, next) { for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) { if (group->groupid == VAR_3[VAR_6].group_id) { VAR_7++; break; } } } VAR_4 = g_malloc0(sizeof(*VAR_4) + (VAR_7 * sizeof(*fds))); VAR_4->argsz = sizeof(*VAR_4) + (VAR_7 * sizeof(*fds)); fds = &VAR_4->group_fds[0]; QLIST_FOREACH(group, &vfio_group_list, next) { for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) { if (group->groupid == VAR_3[VAR_6].group_id) { fds[VAR_4->VAR_7++] = group->fd; break; } } } VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, VAR_4); g_free(VAR_4); trace_vfio_pci_hot_reset_result(VAR_0->vbasedev.name, VAR_5 ? "%m" : "Success"); out: for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) { PCIHostDeviceAddress host; VFIOPCIDevice *tmp; VFIODevice *vbasedev_iter; host.domain = VAR_3[VAR_6].segment; host.bus = VAR_3[VAR_6].bus; host.slot = PCI_SLOT(VAR_3[VAR_6].devfn); host.function = PCI_FUNC(VAR_3[VAR_6].devfn); if (vfio_pci_host_match(&host, &VAR_0->host)) { continue; } QLIST_FOREACH(group, &vfio_group_list, next) { if (group->groupid == VAR_3[VAR_6].group_id) { break; } } if (!group) { break; } QLIST_FOREACH(vbasedev_iter, &group->device_list, next) { if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) { continue; } tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev); if (vfio_pci_host_match(&host, &tmp->host)) { vfio_pci_post_reset(tmp); break; } } } out_single: vfio_pci_post_reset(VAR_0); g_free(VAR_2); return VAR_5; }
[ "static int FUNC_0(VFIOPCIDevice *VAR_0, bool VAR_1)\n{", "VFIOGroup *group;", "struct vfio_pci_hot_reset_info *VAR_2;", "struct vfio_pci_dependent_device *VAR_3;", "struct FUNC_0 *VAR_4;", "int32_t *fds;", "int VAR_5, VAR_6, VAR_7;", "bool multi = false;", "trace_vfio_pci_hot_reset(VAR_0->vbasedev.name, VAR_1 ? \"one\" : \"multi\");", "vfio_pci_pre_reset(VAR_0);", "VAR_0->vbasedev.needs_reset = false;", "VAR_2 = g_malloc0(sizeof(*VAR_2));", "VAR_2->argsz = sizeof(*VAR_2);", "VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, VAR_2);", "if (VAR_5 && errno != ENOSPC) {", "VAR_5 = -errno;", "if (!VAR_0->has_pm_reset) {", "error_report(\"vfio: Cannot VAR_4 device %04x:%02x:%02x.%x, \"\n\"no available VAR_4 mechanism.\", VAR_0->host.domain,\nVAR_0->host.bus, VAR_0->host.slot, VAR_0->host.function);", "}", "goto out_single;", "}", "VAR_7 = VAR_2->VAR_7;", "VAR_2 = g_realloc(VAR_2, sizeof(*VAR_2) + (VAR_7 * sizeof(*VAR_3)));", "VAR_2->argsz = sizeof(*VAR_2) + (VAR_7 * sizeof(*VAR_3));", "VAR_3 = &VAR_2->VAR_3[0];", "VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_GET_PCI_HOT_RESET_INFO, VAR_2);", "if (VAR_5) {", "VAR_5 = -errno;", "error_report(\"vfio: hot VAR_4 VAR_2 failed: %m\");", "goto out_single;", "}", "trace_vfio_pci_hot_reset_has_dep_devices(VAR_0->vbasedev.name);", "for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) {", "PCIHostDeviceAddress host;", "VFIOPCIDevice *tmp;", "VFIODevice *vbasedev_iter;", "host.domain = VAR_3[VAR_6].segment;", "host.bus = VAR_3[VAR_6].bus;", "host.slot = PCI_SLOT(VAR_3[VAR_6].devfn);", "host.function = PCI_FUNC(VAR_3[VAR_6].devfn);", "trace_vfio_pci_hot_reset_dep_devices(host.domain,\nhost.bus, host.slot, host.function, VAR_3[VAR_6].group_id);", "if (vfio_pci_host_match(&host, &VAR_0->host)) {", "continue;", "}", "QLIST_FOREACH(group, &vfio_group_list, next) {", "if (group->groupid == VAR_3[VAR_6].group_id) {", "break;", "}", "}", "if (!group) {", "if (!VAR_0->has_pm_reset) {", "error_report(\"vfio: Cannot VAR_4 device %s, \"\n\"depends on group %d which is not owned.\",\nVAR_0->vbasedev.name, VAR_3[VAR_6].group_id);", "}", "VAR_5 = -EPERM;", "goto out;", "}", "QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {", "if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) {", "continue;", "}", "tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev);", "if (vfio_pci_host_match(&host, &tmp->host)) {", "if (VAR_1) {", "VAR_5 = -EINVAL;", "goto out_single;", "}", "vfio_pci_pre_reset(tmp);", "tmp->vbasedev.needs_reset = false;", "multi = true;", "break;", "}", "}", "}", "if (!VAR_1 && !multi) {", "VAR_5 = -EINVAL;", "goto out_single;", "}", "VAR_7 = 0;", "QLIST_FOREACH(group, &vfio_group_list, next) {", "for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) {", "if (group->groupid == VAR_3[VAR_6].group_id) {", "VAR_7++;", "break;", "}", "}", "}", "VAR_4 = g_malloc0(sizeof(*VAR_4) + (VAR_7 * sizeof(*fds)));", "VAR_4->argsz = sizeof(*VAR_4) + (VAR_7 * sizeof(*fds));", "fds = &VAR_4->group_fds[0];", "QLIST_FOREACH(group, &vfio_group_list, next) {", "for (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) {", "if (group->groupid == VAR_3[VAR_6].group_id) {", "fds[VAR_4->VAR_7++] = group->fd;", "break;", "}", "}", "}", "VAR_5 = ioctl(VAR_0->vbasedev.fd, VFIO_DEVICE_PCI_HOT_RESET, VAR_4);", "g_free(VAR_4);", "trace_vfio_pci_hot_reset_result(VAR_0->vbasedev.name,\nVAR_5 ? \"%m\" : \"Success\");", "out:\nfor (VAR_6 = 0; VAR_6 < VAR_2->VAR_7; VAR_6++) {", "PCIHostDeviceAddress host;", "VFIOPCIDevice *tmp;", "VFIODevice *vbasedev_iter;", "host.domain = VAR_3[VAR_6].segment;", "host.bus = VAR_3[VAR_6].bus;", "host.slot = PCI_SLOT(VAR_3[VAR_6].devfn);", "host.function = PCI_FUNC(VAR_3[VAR_6].devfn);", "if (vfio_pci_host_match(&host, &VAR_0->host)) {", "continue;", "}", "QLIST_FOREACH(group, &vfio_group_list, next) {", "if (group->groupid == VAR_3[VAR_6].group_id) {", "break;", "}", "}", "if (!group) {", "break;", "}", "QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {", "if (vbasedev_iter->type != VFIO_DEVICE_TYPE_PCI) {", "continue;", "}", "tmp = container_of(vbasedev_iter, VFIOPCIDevice, vbasedev);", "if (vfio_pci_host_match(&host, &tmp->host)) {", "vfio_pci_post_reset(tmp);", "break;", "}", "}", "}", "out_single:\nvfio_pci_post_reset(VAR_0);", "g_free(VAR_2);", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109, 111 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 225 ], [ 227 ], [ 229 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 255 ], [ 257 ], [ 261, 263 ], [ 267, 271 ], [ 273 ], [ 275 ], [ 277 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 291 ], [ 293 ], [ 295 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 311 ], [ 313 ], [ 315 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341, 343 ], [ 345 ], [ 349 ], [ 351 ] ]
16,797
pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr) { uint32_t ready_ptr = RS_GET_FIELD(mgr, reqProdIdx); if (ready_ptr != mgr->consumed_ptr) { uint32_t next_ready_ptr = mgr->consumed_ptr++ & mgr->txr_len_mask; uint32_t next_ready_page = next_ready_ptr / PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; uint32_t inpage_idx = next_ready_ptr % PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; return mgr->req_ring_pages_pa[next_ready_page] + inpage_idx * sizeof(PVSCSIRingReqDesc); } else { return 0; } }
false
qemu
d251157ac1928191af851d199a9ff255d330bec9
pvscsi_ring_pop_req_descr(PVSCSIRingInfo *mgr) { uint32_t ready_ptr = RS_GET_FIELD(mgr, reqProdIdx); if (ready_ptr != mgr->consumed_ptr) { uint32_t next_ready_ptr = mgr->consumed_ptr++ & mgr->txr_len_mask; uint32_t next_ready_page = next_ready_ptr / PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; uint32_t inpage_idx = next_ready_ptr % PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; return mgr->req_ring_pages_pa[next_ready_page] + inpage_idx * sizeof(PVSCSIRingReqDesc); } else { return 0; } }
{ "code": [], "line_no": [] }
FUNC_0(PVSCSIRingInfo *VAR_0) { uint32_t ready_ptr = RS_GET_FIELD(VAR_0, reqProdIdx); if (ready_ptr != VAR_0->consumed_ptr) { uint32_t next_ready_ptr = VAR_0->consumed_ptr++ & VAR_0->txr_len_mask; uint32_t next_ready_page = next_ready_ptr / PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; uint32_t inpage_idx = next_ready_ptr % PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE; return VAR_0->req_ring_pages_pa[next_ready_page] + inpage_idx * sizeof(PVSCSIRingReqDesc); } else { return 0; } }
[ "FUNC_0(PVSCSIRingInfo *VAR_0)\n{", "uint32_t ready_ptr = RS_GET_FIELD(VAR_0, reqProdIdx);", "if (ready_ptr != VAR_0->consumed_ptr) {", "uint32_t next_ready_ptr =\nVAR_0->consumed_ptr++ & VAR_0->txr_len_mask;", "uint32_t next_ready_page =\nnext_ready_ptr / PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;", "uint32_t inpage_idx =\nnext_ready_ptr % PVSCSI_MAX_NUM_REQ_ENTRIES_PER_PAGE;", "return VAR_0->req_ring_pages_pa[next_ready_page] +\ninpage_idx * sizeof(PVSCSIRingReqDesc);", "} else {", "return 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15, 17 ], [ 19, 21 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ] ]
16,798
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags, QCryptoTLSCreds *tlscreds, const char *hostname, QIOChannel **outioc, off_t *size, Error **errp) { char buf[256]; uint64_t magic, s; int rc; TRACE("Receiving negotiation tlscreds=%p hostname=%s.", tlscreds, hostname ? hostname : "<null>"); rc = -EINVAL; if (outioc) { *outioc = NULL; } if (tlscreds && !outioc) { error_setg(errp, "Output I/O channel required for TLS"); goto fail; } if (read_sync(ioc, buf, 8) != 8) { error_setg(errp, "Failed to read data"); goto fail; } buf[8] = '\0'; if (strlen(buf) == 0) { error_setg(errp, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(buf[0]) ? buf[0] : '.', qemu_isprint(buf[1]) ? buf[1] : '.', qemu_isprint(buf[2]) ? buf[2] : '.', qemu_isprint(buf[3]) ? buf[3] : '.', qemu_isprint(buf[4]) ? buf[4] : '.', qemu_isprint(buf[5]) ? buf[5] : '.', qemu_isprint(buf[6]) ? buf[6] : '.', qemu_isprint(buf[7]) ? buf[7] : '.'); if (memcmp(buf, "NBDMAGIC", 8) != 0) { error_setg(errp, "Invalid magic received"); goto fail; } if (read_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint32_t opt; uint32_t namesize; uint16_t globalflags; uint16_t exportflags; bool fixedNewStyle = false; if (read_sync(ioc, &globalflags, sizeof(globalflags)) != sizeof(globalflags)) { error_setg(errp, "Failed to read server flags"); goto fail; } globalflags = be16_to_cpu(globalflags); *flags = globalflags << 16; TRACE("Global flags are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } /* client requested flags */ clientflags = cpu_to_be32(clientflags); if (write_sync(ioc, &clientflags, sizeof(clientflags)) != sizeof(clientflags)) { error_setg(errp, "Failed to send clientflags field"); goto fail; } if (tlscreds) { if (fixedNewStyle) { *outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp); if (!*outioc) { goto fail; } ioc = *outioc; } else { error_setg(errp, "Server does not support STARTTLS"); goto fail; } } if (!name) { TRACE("Using default NBD export name \"\""); name = ""; } if (fixedNewStyle) { /* Check our desired export is present in the * server export list. Since NBD_OPT_EXPORT_NAME * cannot return an error message, running this * query gives us good error reporting if the * server required TLS */ if (nbd_receive_query_exports(ioc, name, errp) < 0) { goto fail; } } /* write the export name */ magic = cpu_to_be64(magic); if (write_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to send export name magic"); goto fail; } opt = cpu_to_be32(NBD_OPT_EXPORT_NAME); if (write_sync(ioc, &opt, sizeof(opt)) != sizeof(opt)) { error_setg(errp, "Failed to send export name option number"); goto fail; } namesize = cpu_to_be32(strlen(name)); if (write_sync(ioc, &namesize, sizeof(namesize)) != sizeof(namesize)) { error_setg(errp, "Failed to send export name length"); goto fail; } if (write_sync(ioc, (char *)name, strlen(name)) != strlen(name)) { error_setg(errp, "Failed to send export name"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, &exportflags, sizeof(exportflags)) != sizeof(exportflags)) { error_setg(errp, "Failed to read export flags"); goto fail; } exportflags = be16_to_cpu(exportflags); *flags |= exportflags; TRACE("Export flags are %" PRIx16, exportflags); } else if (magic == NBD_CLIENT_MAGIC) { if (name) { error_setg(errp, "Server does not support export names"); goto fail; } if (tlscreds) { error_setg(errp, "Server does not support STARTTLS"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) { error_setg(errp, "Failed to read export flags"); goto fail; } *flags = be32_to_cpu(*flags); } else { error_setg(errp, "Bad magic received"); goto fail; } if (read_sync(ioc, &buf, 124) != 124) { error_setg(errp, "Failed to read reserved block"); goto fail; } rc = 0; fail: return rc; }
false
qemu
7423f417827146f956df820f172d0bf80a489495
int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint32_t *flags, QCryptoTLSCreds *tlscreds, const char *hostname, QIOChannel **outioc, off_t *size, Error **errp) { char buf[256]; uint64_t magic, s; int rc; TRACE("Receiving negotiation tlscreds=%p hostname=%s.", tlscreds, hostname ? hostname : "<null>"); rc = -EINVAL; if (outioc) { *outioc = NULL; } if (tlscreds && !outioc) { error_setg(errp, "Output I/O channel required for TLS"); goto fail; } if (read_sync(ioc, buf, 8) != 8) { error_setg(errp, "Failed to read data"); goto fail; } buf[8] = '\0'; if (strlen(buf) == 0) { error_setg(errp, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(buf[0]) ? buf[0] : '.', qemu_isprint(buf[1]) ? buf[1] : '.', qemu_isprint(buf[2]) ? buf[2] : '.', qemu_isprint(buf[3]) ? buf[3] : '.', qemu_isprint(buf[4]) ? buf[4] : '.', qemu_isprint(buf[5]) ? buf[5] : '.', qemu_isprint(buf[6]) ? buf[6] : '.', qemu_isprint(buf[7]) ? buf[7] : '.'); if (memcmp(buf, "NBDMAGIC", 8) != 0) { error_setg(errp, "Invalid magic received"); goto fail; } if (read_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint32_t opt; uint32_t namesize; uint16_t globalflags; uint16_t exportflags; bool fixedNewStyle = false; if (read_sync(ioc, &globalflags, sizeof(globalflags)) != sizeof(globalflags)) { error_setg(errp, "Failed to read server flags"); goto fail; } globalflags = be16_to_cpu(globalflags); *flags = globalflags << 16; TRACE("Global flags are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } clientflags = cpu_to_be32(clientflags); if (write_sync(ioc, &clientflags, sizeof(clientflags)) != sizeof(clientflags)) { error_setg(errp, "Failed to send clientflags field"); goto fail; } if (tlscreds) { if (fixedNewStyle) { *outioc = nbd_receive_starttls(ioc, tlscreds, hostname, errp); if (!*outioc) { goto fail; } ioc = *outioc; } else { error_setg(errp, "Server does not support STARTTLS"); goto fail; } } if (!name) { TRACE("Using default NBD export name \"\""); name = ""; } if (fixedNewStyle) { if (nbd_receive_query_exports(ioc, name, errp) < 0) { goto fail; } } magic = cpu_to_be64(magic); if (write_sync(ioc, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(errp, "Failed to send export name magic"); goto fail; } opt = cpu_to_be32(NBD_OPT_EXPORT_NAME); if (write_sync(ioc, &opt, sizeof(opt)) != sizeof(opt)) { error_setg(errp, "Failed to send export name option number"); goto fail; } namesize = cpu_to_be32(strlen(name)); if (write_sync(ioc, &namesize, sizeof(namesize)) != sizeof(namesize)) { error_setg(errp, "Failed to send export name length"); goto fail; } if (write_sync(ioc, (char *)name, strlen(name)) != strlen(name)) { error_setg(errp, "Failed to send export name"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, &exportflags, sizeof(exportflags)) != sizeof(exportflags)) { error_setg(errp, "Failed to read export flags"); goto fail; } exportflags = be16_to_cpu(exportflags); *flags |= exportflags; TRACE("Export flags are %" PRIx16, exportflags); } else if (magic == NBD_CLIENT_MAGIC) { if (name) { error_setg(errp, "Server does not support export names"); goto fail; } if (tlscreds) { error_setg(errp, "Server does not support STARTTLS"); goto fail; } if (read_sync(ioc, &s, sizeof(s)) != sizeof(s)) { error_setg(errp, "Failed to read export length"); goto fail; } *size = be64_to_cpu(s); TRACE("Size is %" PRIu64, *size); if (read_sync(ioc, flags, sizeof(*flags)) != sizeof(*flags)) { error_setg(errp, "Failed to read export flags"); goto fail; } *flags = be32_to_cpu(*flags); } else { error_setg(errp, "Bad magic received"); goto fail; } if (read_sync(ioc, &buf, 124) != 124) { error_setg(errp, "Failed to read reserved block"); goto fail; } rc = 0; fail: return rc; }
{ "code": [], "line_no": [] }
int FUNC_0(QIOChannel *VAR_0, const char *VAR_1, uint32_t *VAR_2, QCryptoTLSCreds *VAR_3, const char *VAR_4, QIOChannel **VAR_5, off_t *VAR_6, Error **VAR_7) { char VAR_8[256]; uint64_t magic, s; int VAR_9; TRACE("Receiving negotiation VAR_3=%p VAR_4=%s.", VAR_3, VAR_4 ? VAR_4 : "<null>"); VAR_9 = -EINVAL; if (VAR_5) { *VAR_5 = NULL; } if (VAR_3 && !VAR_5) { error_setg(VAR_7, "Output I/O channel required for TLS"); goto fail; } if (read_sync(VAR_0, VAR_8, 8) != 8) { error_setg(VAR_7, "Failed to read data"); goto fail; } VAR_8[8] = '\0'; if (strlen(VAR_8) == 0) { error_setg(VAR_7, "Server connection closed unexpectedly"); goto fail; } TRACE("Magic is %c%c%c%c%c%c%c%c", qemu_isprint(VAR_8[0]) ? VAR_8[0] : '.', qemu_isprint(VAR_8[1]) ? VAR_8[1] : '.', qemu_isprint(VAR_8[2]) ? VAR_8[2] : '.', qemu_isprint(VAR_8[3]) ? VAR_8[3] : '.', qemu_isprint(VAR_8[4]) ? VAR_8[4] : '.', qemu_isprint(VAR_8[5]) ? VAR_8[5] : '.', qemu_isprint(VAR_8[6]) ? VAR_8[6] : '.', qemu_isprint(VAR_8[7]) ? VAR_8[7] : '.'); if (memcmp(VAR_8, "NBDMAGIC", 8) != 0) { error_setg(VAR_7, "Invalid magic received"); goto fail; } if (read_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(VAR_7, "Failed to read magic"); goto fail; } magic = be64_to_cpu(magic); TRACE("Magic is 0x%" PRIx64, magic); if (magic == NBD_OPTS_MAGIC) { uint32_t clientflags = 0; uint32_t opt; uint32_t namesize; uint16_t globalflags; uint16_t exportflags; bool fixedNewStyle = false; if (read_sync(VAR_0, &globalflags, sizeof(globalflags)) != sizeof(globalflags)) { error_setg(VAR_7, "Failed to read server VAR_2"); goto fail; } globalflags = be16_to_cpu(globalflags); *VAR_2 = globalflags << 16; TRACE("Global VAR_2 are %" PRIx32, globalflags); if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) { fixedNewStyle = true; TRACE("Server supports fixed new style"); clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE; } clientflags = cpu_to_be32(clientflags); if (write_sync(VAR_0, &clientflags, sizeof(clientflags)) != sizeof(clientflags)) { error_setg(VAR_7, "Failed to send clientflags field"); goto fail; } if (VAR_3) { if (fixedNewStyle) { *VAR_5 = nbd_receive_starttls(VAR_0, VAR_3, VAR_4, VAR_7); if (!*VAR_5) { goto fail; } VAR_0 = *VAR_5; } else { error_setg(VAR_7, "Server does not support STARTTLS"); goto fail; } } if (!VAR_1) { TRACE("Using default NBD export VAR_1 \"\""); VAR_1 = ""; } if (fixedNewStyle) { if (nbd_receive_query_exports(VAR_0, VAR_1, VAR_7) < 0) { goto fail; } } magic = cpu_to_be64(magic); if (write_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) { error_setg(VAR_7, "Failed to send export VAR_1 magic"); goto fail; } opt = cpu_to_be32(NBD_OPT_EXPORT_NAME); if (write_sync(VAR_0, &opt, sizeof(opt)) != sizeof(opt)) { error_setg(VAR_7, "Failed to send export VAR_1 option number"); goto fail; } namesize = cpu_to_be32(strlen(VAR_1)); if (write_sync(VAR_0, &namesize, sizeof(namesize)) != sizeof(namesize)) { error_setg(VAR_7, "Failed to send export VAR_1 length"); goto fail; } if (write_sync(VAR_0, (char *)VAR_1, strlen(VAR_1)) != strlen(VAR_1)) { error_setg(VAR_7, "Failed to send export VAR_1"); goto fail; } if (read_sync(VAR_0, &s, sizeof(s)) != sizeof(s)) { error_setg(VAR_7, "Failed to read export length"); goto fail; } *VAR_6 = be64_to_cpu(s); TRACE("Size is %" PRIu64, *VAR_6); if (read_sync(VAR_0, &exportflags, sizeof(exportflags)) != sizeof(exportflags)) { error_setg(VAR_7, "Failed to read export VAR_2"); goto fail; } exportflags = be16_to_cpu(exportflags); *VAR_2 |= exportflags; TRACE("Export VAR_2 are %" PRIx16, exportflags); } else if (magic == NBD_CLIENT_MAGIC) { if (VAR_1) { error_setg(VAR_7, "Server does not support export names"); goto fail; } if (VAR_3) { error_setg(VAR_7, "Server does not support STARTTLS"); goto fail; } if (read_sync(VAR_0, &s, sizeof(s)) != sizeof(s)) { error_setg(VAR_7, "Failed to read export length"); goto fail; } *VAR_6 = be64_to_cpu(s); TRACE("Size is %" PRIu64, *VAR_6); if (read_sync(VAR_0, VAR_2, sizeof(*VAR_2)) != sizeof(*VAR_2)) { error_setg(VAR_7, "Failed to read export VAR_2"); goto fail; } *VAR_2 = be32_to_cpu(*VAR_2); } else { error_setg(VAR_7, "Bad magic received"); goto fail; } if (read_sync(VAR_0, &VAR_8, 124) != 124) { error_setg(VAR_7, "Failed to read reserved block"); goto fail; } VAR_9 = 0; fail: return VAR_9; }
[ "int FUNC_0(QIOChannel *VAR_0, const char *VAR_1, uint32_t *VAR_2,\nQCryptoTLSCreds *VAR_3, const char *VAR_4,\nQIOChannel **VAR_5,\noff_t *VAR_6, Error **VAR_7)\n{", "char VAR_8[256];", "uint64_t magic, s;", "int VAR_9;", "TRACE(\"Receiving negotiation VAR_3=%p VAR_4=%s.\",\nVAR_3, VAR_4 ? VAR_4 : \"<null>\");", "VAR_9 = -EINVAL;", "if (VAR_5) {", "*VAR_5 = NULL;", "}", "if (VAR_3 && !VAR_5) {", "error_setg(VAR_7, \"Output I/O channel required for TLS\");", "goto fail;", "}", "if (read_sync(VAR_0, VAR_8, 8) != 8) {", "error_setg(VAR_7, \"Failed to read data\");", "goto fail;", "}", "VAR_8[8] = '\\0';", "if (strlen(VAR_8) == 0) {", "error_setg(VAR_7, \"Server connection closed unexpectedly\");", "goto fail;", "}", "TRACE(\"Magic is %c%c%c%c%c%c%c%c\",\nqemu_isprint(VAR_8[0]) ? VAR_8[0] : '.',\nqemu_isprint(VAR_8[1]) ? VAR_8[1] : '.',\nqemu_isprint(VAR_8[2]) ? VAR_8[2] : '.',\nqemu_isprint(VAR_8[3]) ? VAR_8[3] : '.',\nqemu_isprint(VAR_8[4]) ? VAR_8[4] : '.',\nqemu_isprint(VAR_8[5]) ? VAR_8[5] : '.',\nqemu_isprint(VAR_8[6]) ? VAR_8[6] : '.',\nqemu_isprint(VAR_8[7]) ? VAR_8[7] : '.');", "if (memcmp(VAR_8, \"NBDMAGIC\", 8) != 0) {", "error_setg(VAR_7, \"Invalid magic received\");", "goto fail;", "}", "if (read_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) {", "error_setg(VAR_7, \"Failed to read magic\");", "goto fail;", "}", "magic = be64_to_cpu(magic);", "TRACE(\"Magic is 0x%\" PRIx64, magic);", "if (magic == NBD_OPTS_MAGIC) {", "uint32_t clientflags = 0;", "uint32_t opt;", "uint32_t namesize;", "uint16_t globalflags;", "uint16_t exportflags;", "bool fixedNewStyle = false;", "if (read_sync(VAR_0, &globalflags, sizeof(globalflags)) !=\nsizeof(globalflags)) {", "error_setg(VAR_7, \"Failed to read server VAR_2\");", "goto fail;", "}", "globalflags = be16_to_cpu(globalflags);", "*VAR_2 = globalflags << 16;", "TRACE(\"Global VAR_2 are %\" PRIx32, globalflags);", "if (globalflags & NBD_FLAG_FIXED_NEWSTYLE) {", "fixedNewStyle = true;", "TRACE(\"Server supports fixed new style\");", "clientflags |= NBD_FLAG_C_FIXED_NEWSTYLE;", "}", "clientflags = cpu_to_be32(clientflags);", "if (write_sync(VAR_0, &clientflags, sizeof(clientflags)) !=\nsizeof(clientflags)) {", "error_setg(VAR_7, \"Failed to send clientflags field\");", "goto fail;", "}", "if (VAR_3) {", "if (fixedNewStyle) {", "*VAR_5 = nbd_receive_starttls(VAR_0, VAR_3, VAR_4, VAR_7);", "if (!*VAR_5) {", "goto fail;", "}", "VAR_0 = *VAR_5;", "} else {", "error_setg(VAR_7, \"Server does not support STARTTLS\");", "goto fail;", "}", "}", "if (!VAR_1) {", "TRACE(\"Using default NBD export VAR_1 \\\"\\\"\");", "VAR_1 = \"\";", "}", "if (fixedNewStyle) {", "if (nbd_receive_query_exports(VAR_0, VAR_1, VAR_7) < 0) {", "goto fail;", "}", "}", "magic = cpu_to_be64(magic);", "if (write_sync(VAR_0, &magic, sizeof(magic)) != sizeof(magic)) {", "error_setg(VAR_7, \"Failed to send export VAR_1 magic\");", "goto fail;", "}", "opt = cpu_to_be32(NBD_OPT_EXPORT_NAME);", "if (write_sync(VAR_0, &opt, sizeof(opt)) != sizeof(opt)) {", "error_setg(VAR_7, \"Failed to send export VAR_1 option number\");", "goto fail;", "}", "namesize = cpu_to_be32(strlen(VAR_1));", "if (write_sync(VAR_0, &namesize, sizeof(namesize)) !=\nsizeof(namesize)) {", "error_setg(VAR_7, \"Failed to send export VAR_1 length\");", "goto fail;", "}", "if (write_sync(VAR_0, (char *)VAR_1, strlen(VAR_1)) != strlen(VAR_1)) {", "error_setg(VAR_7, \"Failed to send export VAR_1\");", "goto fail;", "}", "if (read_sync(VAR_0, &s, sizeof(s)) != sizeof(s)) {", "error_setg(VAR_7, \"Failed to read export length\");", "goto fail;", "}", "*VAR_6 = be64_to_cpu(s);", "TRACE(\"Size is %\" PRIu64, *VAR_6);", "if (read_sync(VAR_0, &exportflags, sizeof(exportflags)) !=\nsizeof(exportflags)) {", "error_setg(VAR_7, \"Failed to read export VAR_2\");", "goto fail;", "}", "exportflags = be16_to_cpu(exportflags);", "*VAR_2 |= exportflags;", "TRACE(\"Export VAR_2 are %\" PRIx16, exportflags);", "} else if (magic == NBD_CLIENT_MAGIC) {", "if (VAR_1) {", "error_setg(VAR_7, \"Server does not support export names\");", "goto fail;", "}", "if (VAR_3) {", "error_setg(VAR_7, \"Server does not support STARTTLS\");", "goto fail;", "}", "if (read_sync(VAR_0, &s, sizeof(s)) != sizeof(s)) {", "error_setg(VAR_7, \"Failed to read export length\");", "goto fail;", "}", "*VAR_6 = be64_to_cpu(s);", "TRACE(\"Size is %\" PRIu64, *VAR_6);", "if (read_sync(VAR_0, VAR_2, sizeof(*VAR_2)) != sizeof(*VAR_2)) {", "error_setg(VAR_7, \"Failed to read export VAR_2\");", "goto fail;", "}", "*VAR_2 = be32_to_cpu(*VAR_2);", "} else {", "error_setg(VAR_7, \"Bad magic received\");", "goto fail;", "}", "if (read_sync(VAR_0, &VAR_8, 124) != 124) {", "error_setg(VAR_7, \"Failed to read reserved block\");", "goto fail;", "}", "VAR_9 = 0;", "fail:\nreturn VAR_9;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 67, 69, 71, 73, 75, 77, 79, 81, 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 127, 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 213 ], [ 215 ], [ 217 ], [ 219 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245, 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 279, 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 339 ], [ 341 ], [ 343 ], [ 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 361, 363 ], [ 365 ] ]
16,799
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, uint8_t *buf, void *hba_private) { SCSIRequest *req; req = d->info->alloc_req(d, tag, lun, hba_private); memcpy(req->cmd.buf, buf, 16); return req; }
false
qemu
afa46c468acc18914c2773538f1b088c507766ee
SCSIRequest *scsi_req_new(SCSIDevice *d, uint32_t tag, uint32_t lun, uint8_t *buf, void *hba_private) { SCSIRequest *req; req = d->info->alloc_req(d, tag, lun, hba_private); memcpy(req->cmd.buf, buf, 16); return req; }
{ "code": [], "line_no": [] }
SCSIRequest *FUNC_0(SCSIDevice *d, uint32_t tag, uint32_t lun, uint8_t *buf, void *hba_private) { SCSIRequest *req; req = d->info->alloc_req(d, tag, lun, hba_private); memcpy(req->cmd.buf, buf, 16); return req; }
[ "SCSIRequest *FUNC_0(SCSIDevice *d, uint32_t tag, uint32_t lun,\nuint8_t *buf, void *hba_private)\n{", "SCSIRequest *req;", "req = d->info->alloc_req(d, tag, lun, hba_private);", "memcpy(req->cmd.buf, buf, 16);", "return req;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ] ]
16,800
int qemu_read_password(char *buf, int buf_size) { uint8_t ch; int i, ret; printf("password: "); fflush(stdout); term_init(); i = 0; for (;;) { ret = read(0, &ch, 1); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } else if (ret == 0) { ret = -1; break; } else { if (ch == '\r') { ret = 0; break; } if (i < (buf_size - 1)) { buf[i++] = ch; } } } term_exit(); buf[i] = '\0'; printf("\n"); return ret; }
false
qemu
6a11d5183fb7564a3d32007b46846312fd61a1c5
int qemu_read_password(char *buf, int buf_size) { uint8_t ch; int i, ret; printf("password: "); fflush(stdout); term_init(); i = 0; for (;;) { ret = read(0, &ch, 1); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } else if (ret == 0) { ret = -1; break; } else { if (ch == '\r') { ret = 0; break; } if (i < (buf_size - 1)) { buf[i++] = ch; } } } term_exit(); buf[i] = '\0'; printf("\n"); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(char *VAR_0, int VAR_1) { uint8_t ch; int VAR_2, VAR_3; printf("password: "); fflush(stdout); term_init(); VAR_2 = 0; for (;;) { VAR_3 = read(0, &ch, 1); if (VAR_3 == -1) { if (errno == EAGAIN || errno == EINTR) { continue; } else { break; } } else if (VAR_3 == 0) { VAR_3 = -1; break; } else { if (ch == '\r') { VAR_3 = 0; break; } if (VAR_2 < (VAR_1 - 1)) { VAR_0[VAR_2++] = ch; } } } term_exit(); VAR_0[VAR_2] = '\0'; printf("\n"); return VAR_3; }
[ "int FUNC_0(char *VAR_0, int VAR_1)\n{", "uint8_t ch;", "int VAR_2, VAR_3;", "printf(\"password: \");", "fflush(stdout);", "term_init();", "VAR_2 = 0;", "for (;;) {", "VAR_3 = read(0, &ch, 1);", "if (VAR_3 == -1) {", "if (errno == EAGAIN || errno == EINTR) {", "continue;", "} else {", "break;", "}", "} else if (VAR_3 == 0) {", "VAR_3 = -1;", "break;", "} else {", "if (ch == '\\r') {", "VAR_3 = 0;", "break;", "}", "if (VAR_2 < (VAR_1 - 1)) {", "VAR_0[VAR_2++] = ch;", "}", "}", "}", "term_exit();", "VAR_0[VAR_2] = '\\0';", "printf(\"\\n\");", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ] ]
16,801
static void qemu_account_warp_timer(void) { if (!use_icount || !icount_sleep) { return; } /* Nothing to do if the VM is stopped: QEMU_CLOCK_VIRTUAL timers * do not fire, so computing the deadline does not make sense. */ if (!runstate_is_running()) { return; } /* warp clock deterministically in record/replay mode */ if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)) { return; } timer_del(icount_warp_timer); icount_warp_rt(); }
false
qemu
b39e3f34c9de7ead6a11a74aa2de78baf41d81a7
static void qemu_account_warp_timer(void) { if (!use_icount || !icount_sleep) { return; } if (!runstate_is_running()) { return; } if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)) { return; } timer_del(icount_warp_timer); icount_warp_rt(); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { if (!use_icount || !icount_sleep) { return; } if (!runstate_is_running()) { return; } if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)) { return; } timer_del(icount_warp_timer); icount_warp_rt(); }
[ "static void FUNC_0(void)\n{", "if (!use_icount || !icount_sleep) {", "return;", "}", "if (!runstate_is_running()) {", "return;", "}", "if (!replay_checkpoint(CHECKPOINT_CLOCK_WARP_ACCOUNT)) {", "return;", "}", "timer_del(icount_warp_timer);", "icount_warp_rt();", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 19 ], [ 21 ], [ 23 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ] ]
16,802
int host_to_target_signal(int sig) { if (sig >= _NSIG) return sig; return host_to_target_signal_table[sig]; }
false
qemu
167c50d8f94e0ffb880aa5cd2a232a3f32f0df1d
int host_to_target_signal(int sig) { if (sig >= _NSIG) return sig; return host_to_target_signal_table[sig]; }
{ "code": [], "line_no": [] }
int FUNC_0(int VAR_0) { if (VAR_0 >= _NSIG) return VAR_0; return host_to_target_signal_table[VAR_0]; }
[ "int FUNC_0(int VAR_0)\n{", "if (VAR_0 >= _NSIG)\nreturn VAR_0;", "return host_to_target_signal_table[VAR_0];", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 9 ], [ 11 ] ]
16,803
void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu = ENV_GET_CPU(cpu_env); int sig; abi_ulong handler; sigset_t set, old_set; target_sigset_t target_old_set; struct emulated_sigtable *k; struct target_sigaction *sa; struct sigqueue *q; TaskState *ts = cpu->opaque; if (!ts->signal_pending) return; /* FIXME: This is not threadsafe. */ k = ts->sigtab; for(sig = 1; sig <= TARGET_NSIG; sig++) { if (k->pending) goto handle_signal; k++; } /* if no signal is pending, just return */ ts->signal_pending = 0; return; handle_signal: #ifdef DEBUG_SIGNAL fprintf(stderr, "qemu: process signal %d\n", sig); #endif /* dequeue signal */ q = k->first; k->first = q->next; if (!k->first) k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; } else { sa = &sigact_table[sig - 1]; handler = sa->_sa_handler; } if (handler == TARGET_SIG_DFL) { /* default handler : ignore some signal. The other are job control or fatal */ if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } } else if (handler == TARGET_SIG_IGN) { /* ignore sig */ } else if (handler == TARGET_SIG_ERR) { force_sig(sig); } else { /* compute the blocked signals during the handler execution */ target_to_host_sigset(&set, &sa->sa_mask); /* SA_NODEFER indicates that the current signal should not be blocked during the handler */ if (!(sa->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); /* block signals in the handler using Linux */ sigprocmask(SIG_BLOCK, &set, &old_set); /* save the previous blocked signal state to restore it at the end of the signal execution (see do_sigreturn) */ host_to_target_sigset_internal(&target_old_set, &old_set); /* if the CPU is in VM86 mode, we restore the 32 bit values */ #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = cpu_env; if (env->eflags & VM_MASK) save_v86_state(env); } #endif /* prepare the stack frame of the virtual CPU */ #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) /* These targets do not have traditional signals. */ setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) sa->_sa_handler = TARGET_SIG_DFL; } if (q != &k->info) free_sigqueue(cpu_env, q); }
false
qemu
1c275925bfbbc2de84a8f0e09d1dd70bbefb6da3
void process_pending_signals(CPUArchState *cpu_env) { CPUState *cpu = ENV_GET_CPU(cpu_env); int sig; abi_ulong handler; sigset_t set, old_set; target_sigset_t target_old_set; struct emulated_sigtable *k; struct target_sigaction *sa; struct sigqueue *q; TaskState *ts = cpu->opaque; if (!ts->signal_pending) return; k = ts->sigtab; for(sig = 1; sig <= TARGET_NSIG; sig++) { if (k->pending) goto handle_signal; k++; } ts->signal_pending = 0; return; handle_signal: #ifdef DEBUG_SIGNAL fprintf(stderr, "qemu: process signal %d\n", sig); #endif q = k->first; k->first = q->next; if (!k->first) k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { sa = NULL; handler = TARGET_SIG_IGN; } else { sa = &sigact_table[sig - 1]; handler = sa->_sa_handler; } if (handler == TARGET_SIG_DFL) { if (sig == TARGET_SIGTSTP || sig == TARGET_SIGTTIN || sig == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (sig != TARGET_SIGCHLD && sig != TARGET_SIGURG && sig != TARGET_SIGWINCH && sig != TARGET_SIGCONT) { force_sig(sig); } } else if (handler == TARGET_SIG_IGN) { } else if (handler == TARGET_SIG_ERR) { force_sig(sig); } else { target_to_host_sigset(&set, &sa->sa_mask); if (!(sa->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(sig)); sigprocmask(SIG_BLOCK, &set, &old_set); host_to_target_sigset_internal(&target_old_set, &old_set); #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = cpu_env; if (env->eflags & VM_MASK) save_v86_state(env); } #endif #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) sa->_sa_handler = TARGET_SIG_DFL; } if (q != &k->info) free_sigqueue(cpu_env, q); }
{ "code": [], "line_no": [] }
void FUNC_0(CPUArchState *VAR_0) { CPUState *cpu = ENV_GET_CPU(VAR_0); int VAR_1; abi_ulong handler; sigset_t set, old_set; target_sigset_t target_old_set; struct emulated_sigtable *VAR_2; struct target_sigaction *VAR_3; struct sigqueue *VAR_4; TaskState *ts = cpu->opaque; if (!ts->signal_pending) return; VAR_2 = ts->sigtab; for(VAR_1 = 1; VAR_1 <= TARGET_NSIG; VAR_1++) { if (VAR_2->pending) goto handle_signal; VAR_2++; } ts->signal_pending = 0; return; handle_signal: #ifdef DEBUG_SIGNAL fprintf(stderr, "qemu: process signal %d\n", VAR_1); #endif VAR_4 = VAR_2->first; VAR_2->first = VAR_4->next; if (!VAR_2->first) VAR_2->pending = 0; VAR_1 = gdb_handlesig(cpu, VAR_1); if (!VAR_1) { VAR_3 = NULL; handler = TARGET_SIG_IGN; } else { VAR_3 = &sigact_table[VAR_1 - 1]; handler = VAR_3->_sa_handler; } if (handler == TARGET_SIG_DFL) { if (VAR_1 == TARGET_SIGTSTP || VAR_1 == TARGET_SIGTTIN || VAR_1 == TARGET_SIGTTOU) { kill(getpid(),SIGSTOP); } else if (VAR_1 != TARGET_SIGCHLD && VAR_1 != TARGET_SIGURG && VAR_1 != TARGET_SIGWINCH && VAR_1 != TARGET_SIGCONT) { force_sig(VAR_1); } } else if (handler == TARGET_SIG_IGN) { } else if (handler == TARGET_SIG_ERR) { force_sig(VAR_1); } else { target_to_host_sigset(&set, &VAR_3->sa_mask); if (!(VAR_3->sa_flags & TARGET_SA_NODEFER)) sigaddset(&set, target_to_host_signal(VAR_1)); sigprocmask(SIG_BLOCK, &set, &old_set); host_to_target_sigset_internal(&target_old_set, &old_set); #if defined(TARGET_I386) && !defined(TARGET_X86_64) { CPUX86State *env = VAR_0; if (env->eflags & VM_MASK) save_v86_state(env); } #endif #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) setup_rt_frame(VAR_1, VAR_3, &VAR_4->info, &target_old_set, VAR_0); #else if (VAR_3->sa_flags & TARGET_SA_SIGINFO) setup_rt_frame(VAR_1, VAR_3, &VAR_4->info, &target_old_set, VAR_0); else setup_frame(VAR_1, VAR_3, &target_old_set, VAR_0); #endif if (VAR_3->sa_flags & TARGET_SA_RESETHAND) VAR_3->_sa_handler = TARGET_SIG_DFL; } if (VAR_4 != &VAR_2->info) free_sigqueue(VAR_0, VAR_4); }
[ "void FUNC_0(CPUArchState *VAR_0)\n{", "CPUState *cpu = ENV_GET_CPU(VAR_0);", "int VAR_1;", "abi_ulong handler;", "sigset_t set, old_set;", "target_sigset_t target_old_set;", "struct emulated_sigtable *VAR_2;", "struct target_sigaction *VAR_3;", "struct sigqueue *VAR_4;", "TaskState *ts = cpu->opaque;", "if (!ts->signal_pending)\nreturn;", "VAR_2 = ts->sigtab;", "for(VAR_1 = 1; VAR_1 <= TARGET_NSIG; VAR_1++) {", "if (VAR_2->pending)\ngoto handle_signal;", "VAR_2++;", "}", "ts->signal_pending = 0;", "return;", "handle_signal:\n#ifdef DEBUG_SIGNAL\nfprintf(stderr, \"qemu: process signal %d\\n\", VAR_1);", "#endif\nVAR_4 = VAR_2->first;", "VAR_2->first = VAR_4->next;", "if (!VAR_2->first)\nVAR_2->pending = 0;", "VAR_1 = gdb_handlesig(cpu, VAR_1);", "if (!VAR_1) {", "VAR_3 = NULL;", "handler = TARGET_SIG_IGN;", "} else {", "VAR_3 = &sigact_table[VAR_1 - 1];", "handler = VAR_3->_sa_handler;", "}", "if (handler == TARGET_SIG_DFL) {", "if (VAR_1 == TARGET_SIGTSTP || VAR_1 == TARGET_SIGTTIN || VAR_1 == TARGET_SIGTTOU) {", "kill(getpid(),SIGSTOP);", "} else if (VAR_1 != TARGET_SIGCHLD &&", "VAR_1 != TARGET_SIGURG &&\nVAR_1 != TARGET_SIGWINCH &&\nVAR_1 != TARGET_SIGCONT) {", "force_sig(VAR_1);", "}", "} else if (handler == TARGET_SIG_IGN) {", "} else if (handler == TARGET_SIG_ERR) {", "force_sig(VAR_1);", "} else {", "target_to_host_sigset(&set, &VAR_3->sa_mask);", "if (!(VAR_3->sa_flags & TARGET_SA_NODEFER))\nsigaddset(&set, target_to_host_signal(VAR_1));", "sigprocmask(SIG_BLOCK, &set, &old_set);", "host_to_target_sigset_internal(&target_old_set, &old_set);", "#if defined(TARGET_I386) && !defined(TARGET_X86_64)\n{", "CPUX86State *env = VAR_0;", "if (env->eflags & VM_MASK)\nsave_v86_state(env);", "}", "#endif\n#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64)\nsetup_rt_frame(VAR_1, VAR_3, &VAR_4->info, &target_old_set, VAR_0);", "#else\nif (VAR_3->sa_flags & TARGET_SA_SIGINFO)\nsetup_rt_frame(VAR_1, VAR_3, &VAR_4->info, &target_old_set, VAR_0);", "else\nsetup_frame(VAR_1, VAR_3, &target_old_set, VAR_0);", "#endif\nif (VAR_3->sa_flags & TARGET_SA_RESETHAND)\nVAR_3->_sa_handler = TARGET_SIG_DFL;", "}", "if (VAR_4 != &VAR_2->info)\nfree_sigqueue(VAR_0, VAR_4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 33 ], [ 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 53, 55, 57 ], [ 59, 63 ], [ 65 ], [ 67, 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101, 103, 105 ], [ 107 ], [ 109 ], [ 111 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 129, 131 ], [ 137 ], [ 143 ], [ 149, 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 161, 165, 169 ], [ 171, 173, 175 ], [ 177, 179 ], [ 181, 183, 185 ], [ 187 ], [ 189, 191 ], [ 193 ] ]
16,805
static void handle_stream_probing(AVStream *st) { if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) { st->request_probe = AVPROBE_SCORE_EXTENSION; st->probe_packets = FFMIN(st->probe_packets, 14); } }
false
FFmpeg
9f5769437aaab30a359cde254f39d9a28b1ce657
static void handle_stream_probing(AVStream *st) { if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) { st->request_probe = AVPROBE_SCORE_EXTENSION; st->probe_packets = FFMIN(st->probe_packets, 14); } }
{ "code": [], "line_no": [] }
static void FUNC_0(AVStream *VAR_0) { if (VAR_0->codec->codec_id == AV_CODEC_ID_PCM_S16LE) { VAR_0->request_probe = AVPROBE_SCORE_EXTENSION; VAR_0->probe_packets = FFMIN(VAR_0->probe_packets, 14); } }
[ "static void FUNC_0(AVStream *VAR_0)\n{", "if (VAR_0->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {", "VAR_0->request_probe = AVPROBE_SCORE_EXTENSION;", "VAR_0->probe_packets = FFMIN(VAR_0->probe_packets, 14);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
16,806
int avcodec_close(AVCodecContext *avctx) { /* If there is a user-supplied mutex locking routine, call it. */ if (ff_lockmgr_cb) { if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); entangled_thread_counter--; return -1; } if (HAVE_THREADS && avctx->thread_opaque) avcodec_thread_free(avctx); if (avctx->codec->close) avctx->codec->close(avctx); avcodec_default_free_buffers(avctx); av_freep(&avctx->priv_data); avctx->codec = NULL; entangled_thread_counter--; /* Release any user-supplied mutex. */ if (ff_lockmgr_cb) { (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); } return 0; }
false
FFmpeg
dccda293a0576d5414fafc0e95615c82a2f2399f
int avcodec_close(AVCodecContext *avctx) { if (ff_lockmgr_cb) { if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(avctx, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); entangled_thread_counter--; return -1; } if (HAVE_THREADS && avctx->thread_opaque) avcodec_thread_free(avctx); if (avctx->codec->close) avctx->codec->close(avctx); avcodec_default_free_buffers(avctx); av_freep(&avctx->priv_data); avctx->codec = NULL; entangled_thread_counter--; if (ff_lockmgr_cb) { (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(AVCodecContext *VAR_0) { if (ff_lockmgr_cb) { if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN)) return -1; } entangled_thread_counter++; if(entangled_thread_counter != 1){ av_log(VAR_0, AV_LOG_ERROR, "insufficient thread locking around avcodec_open/close()\n"); entangled_thread_counter--; return -1; } if (HAVE_THREADS && VAR_0->thread_opaque) avcodec_thread_free(VAR_0); if (VAR_0->codec->close) VAR_0->codec->close(VAR_0); avcodec_default_free_buffers(VAR_0); av_freep(&VAR_0->priv_data); VAR_0->codec = NULL; entangled_thread_counter--; if (ff_lockmgr_cb) { (*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE); } return 0; }
[ "int FUNC_0(AVCodecContext *VAR_0)\n{", "if (ff_lockmgr_cb) {", "if ((*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_OBTAIN))\nreturn -1;", "}", "entangled_thread_counter++;", "if(entangled_thread_counter != 1){", "av_log(VAR_0, AV_LOG_ERROR, \"insufficient thread locking around avcodec_open/close()\\n\");", "entangled_thread_counter--;", "return -1;", "}", "if (HAVE_THREADS && VAR_0->thread_opaque)\navcodec_thread_free(VAR_0);", "if (VAR_0->codec->close)\nVAR_0->codec->close(VAR_0);", "avcodec_default_free_buffers(VAR_0);", "av_freep(&VAR_0->priv_data);", "VAR_0->codec = NULL;", "entangled_thread_counter--;", "if (ff_lockmgr_cb) {", "(*ff_lockmgr_cb)(&codec_mutex, AV_LOCK_RELEASE);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 7 ], [ 9, 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31, 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
16,807
static int a52_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { AC3DecodeState *s = avctx->priv_data; uint8_t *buf_ptr; int flags, i, len; int sample_rate, bit_rate; short *out_samples = data; float level; static const int ac3_channels[8] = { 2, 1, 2, 3, 3, 4, 4, 5 }; *data_size= 0; buf_ptr = buf; while (buf_size > 0) { len = s->inbuf_ptr - s->inbuf; if (s->frame_size == 0) { /* no header seen : find one. We need at least 7 bytes to parse it */ len = HEADER_SIZE - len; if (len > buf_size) len = buf_size; memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) { len = s->a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate); if (len == 0) { /* no sync found : move by one byte (inefficient, but simple!) */ memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); s->inbuf_ptr--; } else { s->frame_size = len; /* update codec info */ avctx->sample_rate = sample_rate; s->channels = ac3_channels[s->flags & 7]; if (s->flags & A52_LFE) s->channels++; avctx->channels = s->channels; if (avctx->request_channels > 0 && avctx->request_channels <= 2 && avctx->request_channels < s->channels) { avctx->channels = avctx->request_channels; } avctx->bit_rate = bit_rate; } } } else if (len < s->frame_size) { len = s->frame_size - len; if (len > buf_size) len = buf_size; memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; } else { flags = s->flags; if (avctx->channels == 1) flags = A52_MONO; else if (avctx->channels == 2) flags = A52_STEREO; else flags |= A52_ADJUST_LEVEL; level = 1; if (s->a52_frame(s->state, s->inbuf, &flags, &level, 384)) { fail: av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n"); s->inbuf_ptr = s->inbuf; s->frame_size = 0; continue; } for (i = 0; i < 6; i++) { if (s->a52_block(s->state)) goto fail; float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels); } s->inbuf_ptr = s->inbuf; s->frame_size = 0; *data_size = 6 * avctx->channels * 256 * sizeof(int16_t); break; } } return buf_ptr - buf; }
false
FFmpeg
3eca1e6fad56f295fb1ef67cb70aff37ff4936a4
static int a52_decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8_t *buf, int buf_size) { AC3DecodeState *s = avctx->priv_data; uint8_t *buf_ptr; int flags, i, len; int sample_rate, bit_rate; short *out_samples = data; float level; static const int ac3_channels[8] = { 2, 1, 2, 3, 3, 4, 4, 5 }; *data_size= 0; buf_ptr = buf; while (buf_size > 0) { len = s->inbuf_ptr - s->inbuf; if (s->frame_size == 0) { len = HEADER_SIZE - len; if (len > buf_size) len = buf_size; memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) { len = s->a52_syncinfo(s->inbuf, &s->flags, &sample_rate, &bit_rate); if (len == 0) { memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); s->inbuf_ptr--; } else { s->frame_size = len; avctx->sample_rate = sample_rate; s->channels = ac3_channels[s->flags & 7]; if (s->flags & A52_LFE) s->channels++; avctx->channels = s->channels; if (avctx->request_channels > 0 && avctx->request_channels <= 2 && avctx->request_channels < s->channels) { avctx->channels = avctx->request_channels; } avctx->bit_rate = bit_rate; } } } else if (len < s->frame_size) { len = s->frame_size - len; if (len > buf_size) len = buf_size; memcpy(s->inbuf_ptr, buf_ptr, len); buf_ptr += len; s->inbuf_ptr += len; buf_size -= len; } else { flags = s->flags; if (avctx->channels == 1) flags = A52_MONO; else if (avctx->channels == 2) flags = A52_STEREO; else flags |= A52_ADJUST_LEVEL; level = 1; if (s->a52_frame(s->state, s->inbuf, &flags, &level, 384)) { fail: av_log(avctx, AV_LOG_ERROR, "Error decoding frame\n"); s->inbuf_ptr = s->inbuf; s->frame_size = 0; continue; } for (i = 0; i < 6; i++) { if (s->a52_block(s->state)) goto fail; float_to_int(s->samples, out_samples + i * 256 * avctx->channels, avctx->channels); } s->inbuf_ptr = s->inbuf; s->frame_size = 0; *data_size = 6 * avctx->channels * 256 * sizeof(int16_t); break; } } return buf_ptr - buf; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, uint8_t *VAR_3, int VAR_4) { AC3DecodeState *s = VAR_0->priv_data; uint8_t *buf_ptr; int VAR_5, VAR_6, VAR_7; int VAR_8, VAR_9; short *VAR_10 = VAR_1; float VAR_11; static const int VAR_12[8] = { 2, 1, 2, 3, 3, 4, 4, 5 }; *VAR_2= 0; buf_ptr = VAR_3; while (VAR_4 > 0) { VAR_7 = s->inbuf_ptr - s->inbuf; if (s->frame_size == 0) { VAR_7 = HEADER_SIZE - VAR_7; if (VAR_7 > VAR_4) VAR_7 = VAR_4; memcpy(s->inbuf_ptr, buf_ptr, VAR_7); buf_ptr += VAR_7; s->inbuf_ptr += VAR_7; VAR_4 -= VAR_7; if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) { VAR_7 = s->a52_syncinfo(s->inbuf, &s->VAR_5, &VAR_8, &VAR_9); if (VAR_7 == 0) { memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1); s->inbuf_ptr--; } else { s->frame_size = VAR_7; VAR_0->VAR_8 = VAR_8; s->channels = VAR_12[s->VAR_5 & 7]; if (s->VAR_5 & A52_LFE) s->channels++; VAR_0->channels = s->channels; if (VAR_0->request_channels > 0 && VAR_0->request_channels <= 2 && VAR_0->request_channels < s->channels) { VAR_0->channels = VAR_0->request_channels; } VAR_0->VAR_9 = VAR_9; } } } else if (VAR_7 < s->frame_size) { VAR_7 = s->frame_size - VAR_7; if (VAR_7 > VAR_4) VAR_7 = VAR_4; memcpy(s->inbuf_ptr, buf_ptr, VAR_7); buf_ptr += VAR_7; s->inbuf_ptr += VAR_7; VAR_4 -= VAR_7; } else { VAR_5 = s->VAR_5; if (VAR_0->channels == 1) VAR_5 = A52_MONO; else if (VAR_0->channels == 2) VAR_5 = A52_STEREO; else VAR_5 |= A52_ADJUST_LEVEL; VAR_11 = 1; if (s->a52_frame(s->state, s->inbuf, &VAR_5, &VAR_11, 384)) { fail: av_log(VAR_0, AV_LOG_ERROR, "Error decoding frame\n"); s->inbuf_ptr = s->inbuf; s->frame_size = 0; continue; } for (VAR_6 = 0; VAR_6 < 6; VAR_6++) { if (s->a52_block(s->state)) goto fail; float_to_int(s->samples, VAR_10 + VAR_6 * 256 * VAR_0->channels, VAR_0->channels); } s->inbuf_ptr = s->inbuf; s->frame_size = 0; *VAR_2 = 6 * VAR_0->channels * 256 * sizeof(int16_t); break; } } return buf_ptr - VAR_3; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nuint8_t *VAR_3, int VAR_4)\n{", "AC3DecodeState *s = VAR_0->priv_data;", "uint8_t *buf_ptr;", "int VAR_5, VAR_6, VAR_7;", "int VAR_8, VAR_9;", "short *VAR_10 = VAR_1;", "float VAR_11;", "static const int VAR_12[8] = {", "2, 1, 2, 3, 3, 4, 4, 5\n};", "*VAR_2= 0;", "buf_ptr = VAR_3;", "while (VAR_4 > 0) {", "VAR_7 = s->inbuf_ptr - s->inbuf;", "if (s->frame_size == 0) {", "VAR_7 = HEADER_SIZE - VAR_7;", "if (VAR_7 > VAR_4)\nVAR_7 = VAR_4;", "memcpy(s->inbuf_ptr, buf_ptr, VAR_7);", "buf_ptr += VAR_7;", "s->inbuf_ptr += VAR_7;", "VAR_4 -= VAR_7;", "if ((s->inbuf_ptr - s->inbuf) == HEADER_SIZE) {", "VAR_7 = s->a52_syncinfo(s->inbuf, &s->VAR_5, &VAR_8, &VAR_9);", "if (VAR_7 == 0) {", "memcpy(s->inbuf, s->inbuf + 1, HEADER_SIZE - 1);", "s->inbuf_ptr--;", "} else {", "s->frame_size = VAR_7;", "VAR_0->VAR_8 = VAR_8;", "s->channels = VAR_12[s->VAR_5 & 7];", "if (s->VAR_5 & A52_LFE)\ns->channels++;", "VAR_0->channels = s->channels;", "if (VAR_0->request_channels > 0 &&\nVAR_0->request_channels <= 2 &&\nVAR_0->request_channels < s->channels) {", "VAR_0->channels = VAR_0->request_channels;", "}", "VAR_0->VAR_9 = VAR_9;", "}", "}", "} else if (VAR_7 < s->frame_size) {", "VAR_7 = s->frame_size - VAR_7;", "if (VAR_7 > VAR_4)\nVAR_7 = VAR_4;", "memcpy(s->inbuf_ptr, buf_ptr, VAR_7);", "buf_ptr += VAR_7;", "s->inbuf_ptr += VAR_7;", "VAR_4 -= VAR_7;", "} else {", "VAR_5 = s->VAR_5;", "if (VAR_0->channels == 1)\nVAR_5 = A52_MONO;", "else if (VAR_0->channels == 2)\nVAR_5 = A52_STEREO;", "else\nVAR_5 |= A52_ADJUST_LEVEL;", "VAR_11 = 1;", "if (s->a52_frame(s->state, s->inbuf, &VAR_5, &VAR_11, 384)) {", "fail:\nav_log(VAR_0, AV_LOG_ERROR, \"Error decoding frame\\n\");", "s->inbuf_ptr = s->inbuf;", "s->frame_size = 0;", "continue;", "}", "for (VAR_6 = 0; VAR_6 < 6; VAR_6++) {", "if (s->a52_block(s->state))\ngoto fail;", "float_to_int(s->samples, VAR_10 + VAR_6 * 256 * VAR_0->channels, VAR_0->channels);", "}", "s->inbuf_ptr = s->inbuf;", "s->frame_size = 0;", "*VAR_2 = 6 * VAR_0->channels * 256 * sizeof(int16_t);", "break;", "}", "}", "return buf_ptr - VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 85, 87, 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127, 129 ], [ 131, 133 ], [ 135 ], [ 137 ], [ 139, 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ] ]
16,809
static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum) { int64_t start, size; start= url_ftell(bc) - 8; init_checksum(bc, calculate_checksum ? update_adler32 : NULL, 0); size= get_v(bc); nut->packet_start[2] = start; nut->written_packet_size= size; return size; }
false
FFmpeg
a26e1d4c1f7c93d24250dd9c0786241f92fcdea4
static int get_packetheader(NUTContext *nut, ByteIOContext *bc, int calculate_checksum) { int64_t start, size; start= url_ftell(bc) - 8; init_checksum(bc, calculate_checksum ? update_adler32 : NULL, 0); size= get_v(bc); nut->packet_start[2] = start; nut->written_packet_size= size; return size; }
{ "code": [], "line_no": [] }
static int FUNC_0(NUTContext *VAR_0, ByteIOContext *VAR_1, int VAR_2) { int64_t start, size; start= url_ftell(VAR_1) - 8; init_checksum(VAR_1, VAR_2 ? update_adler32 : NULL, 0); size= get_v(VAR_1); VAR_0->packet_start[2] = start; VAR_0->written_packet_size= size; return size; }
[ "static int FUNC_0(NUTContext *VAR_0, ByteIOContext *VAR_1, int VAR_2)\n{", "int64_t start, size;", "start= url_ftell(VAR_1) - 8;", "init_checksum(VAR_1, VAR_2 ? update_adler32 : NULL, 0);", "size= get_v(VAR_1);", "VAR_0->packet_start[2] = start;", "VAR_0->written_packet_size= size;", "return size;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ] ]
16,810
static void rtsp_close_streams(RTSPState *rt) { int i; RTSPStream *rtsp_st; for(i=0;i<rt->nb_rtsp_streams;i++) { rtsp_st = rt->rtsp_streams[i]; if (rtsp_st) { if (rtsp_st->transport_priv) { if (rt->transport == RTSP_TRANSPORT_RDT) ff_rdt_parse_close(rtsp_st->transport_priv); else rtp_parse_close(rtsp_st->transport_priv); } if (rtsp_st->rtp_handle) url_close(rtsp_st->rtp_handle); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) rtsp_st->dynamic_handler->close(rtsp_st->dynamic_protocol_context); } } av_free(rt->rtsp_streams); if (rt->asf_ctx) { av_close_input_stream (rt->asf_ctx); rt->asf_ctx = NULL; } av_freep(&rt->auth_b64); }
false
FFmpeg
c89658008705d949c319df3fa6f400c481ad73e1
static void rtsp_close_streams(RTSPState *rt) { int i; RTSPStream *rtsp_st; for(i=0;i<rt->nb_rtsp_streams;i++) { rtsp_st = rt->rtsp_streams[i]; if (rtsp_st) { if (rtsp_st->transport_priv) { if (rt->transport == RTSP_TRANSPORT_RDT) ff_rdt_parse_close(rtsp_st->transport_priv); else rtp_parse_close(rtsp_st->transport_priv); } if (rtsp_st->rtp_handle) url_close(rtsp_st->rtp_handle); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) rtsp_st->dynamic_handler->close(rtsp_st->dynamic_protocol_context); } } av_free(rt->rtsp_streams); if (rt->asf_ctx) { av_close_input_stream (rt->asf_ctx); rt->asf_ctx = NULL; } av_freep(&rt->auth_b64); }
{ "code": [], "line_no": [] }
static void FUNC_0(RTSPState *VAR_0) { int VAR_1; RTSPStream *rtsp_st; for(VAR_1=0;VAR_1<VAR_0->nb_rtsp_streams;VAR_1++) { rtsp_st = VAR_0->rtsp_streams[VAR_1]; if (rtsp_st) { if (rtsp_st->transport_priv) { if (VAR_0->transport == RTSP_TRANSPORT_RDT) ff_rdt_parse_close(rtsp_st->transport_priv); else rtp_parse_close(rtsp_st->transport_priv); } if (rtsp_st->rtp_handle) url_close(rtsp_st->rtp_handle); if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context) rtsp_st->dynamic_handler->close(rtsp_st->dynamic_protocol_context); } } av_free(VAR_0->rtsp_streams); if (VAR_0->asf_ctx) { av_close_input_stream (VAR_0->asf_ctx); VAR_0->asf_ctx = NULL; } av_freep(&VAR_0->auth_b64); }
[ "static void FUNC_0(RTSPState *VAR_0)\n{", "int VAR_1;", "RTSPStream *rtsp_st;", "for(VAR_1=0;VAR_1<VAR_0->nb_rtsp_streams;VAR_1++) {", "rtsp_st = VAR_0->rtsp_streams[VAR_1];", "if (rtsp_st) {", "if (rtsp_st->transport_priv) {", "if (VAR_0->transport == RTSP_TRANSPORT_RDT)\nff_rdt_parse_close(rtsp_st->transport_priv);", "else\nrtp_parse_close(rtsp_st->transport_priv);", "}", "if (rtsp_st->rtp_handle)\nurl_close(rtsp_st->rtp_handle);", "if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)\nrtsp_st->dynamic_handler->close(rtsp_st->dynamic_protocol_context);", "}", "}", "av_free(VAR_0->rtsp_streams);", "if (VAR_0->asf_ctx) {", "av_close_input_stream (VAR_0->asf_ctx);", "VAR_0->asf_ctx = NULL;", "}", "av_freep(&VAR_0->auth_b64);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23, 25 ], [ 27 ], [ 29, 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ] ]
16,811
static uint32_t drc_isolate_logical(sPAPRDRConnector *drc) { /* if the guest is configuring a device attached to this DRC, we * should reset the configuration state at this point since it may * no longer be reliable (guest released device and needs to start * over, or unplug occurred so the FDT is no longer valid) */ g_free(drc->ccs); drc->ccs = NULL; /* * Fail any requests to ISOLATE the LMB DRC if this LMB doesn't * belong to a DIMM device that is marked for removal. * * Currently the guest userspace tool drmgr that drives the memory * hotplug/unplug will just try to remove a set of 'removable' LMBs * in response to a hot unplug request that is based on drc-count. * If the LMB being removed doesn't belong to a DIMM device that is * actually being unplugged, fail the isolation request here. */ if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB && !drc->unplug_requested) { return RTAS_OUT_HW_ERROR; } drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED; /* if we're awaiting release, but still in an unconfigured state, * it's likely the guest is still in the process of configuring * the device and is transitioning the devices to an ISOLATED * state as a part of that process. so we only complete the * removal when this transition happens for a device in a * configured state, as suggested by the state diagram from PAPR+ * 2.7, 13.4 */ if (drc->unplug_requested) { uint32_t drc_index = spapr_drc_index(drc); if (drc->configured) { trace_spapr_drc_set_isolation_state_finalizing(drc_index); spapr_drc_detach(drc); } else { trace_spapr_drc_set_isolation_state_deferring(drc_index); } } drc->configured = false; return RTAS_OUT_SUCCESS; }
false
qemu
9d4c0f4f0a71e74fd7e04d73620268484d693adf
static uint32_t drc_isolate_logical(sPAPRDRConnector *drc) { g_free(drc->ccs); drc->ccs = NULL; if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB && !drc->unplug_requested) { return RTAS_OUT_HW_ERROR; } drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED; if (drc->unplug_requested) { uint32_t drc_index = spapr_drc_index(drc); if (drc->configured) { trace_spapr_drc_set_isolation_state_finalizing(drc_index); spapr_drc_detach(drc); } else { trace_spapr_drc_set_isolation_state_deferring(drc_index); } } drc->configured = false; return RTAS_OUT_SUCCESS; }
{ "code": [], "line_no": [] }
static uint32_t FUNC_0(sPAPRDRConnector *drc) { g_free(drc->ccs); drc->ccs = NULL; if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB && !drc->unplug_requested) { return RTAS_OUT_HW_ERROR; } drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED; if (drc->unplug_requested) { uint32_t drc_index = spapr_drc_index(drc); if (drc->configured) { trace_spapr_drc_set_isolation_state_finalizing(drc_index); spapr_drc_detach(drc); } else { trace_spapr_drc_set_isolation_state_deferring(drc_index); } } drc->configured = false; return RTAS_OUT_SUCCESS; }
[ "static uint32_t FUNC_0(sPAPRDRConnector *drc)\n{", "g_free(drc->ccs);", "drc->ccs = NULL;", "if (spapr_drc_type(drc) == SPAPR_DR_CONNECTOR_TYPE_LMB\n&& !drc->unplug_requested) {", "return RTAS_OUT_HW_ERROR;", "}", "drc->isolation_state = SPAPR_DR_ISOLATION_STATE_ISOLATED;", "if (drc->unplug_requested) {", "uint32_t drc_index = spapr_drc_index(drc);", "if (drc->configured) {", "trace_spapr_drc_set_isolation_state_finalizing(drc_index);", "spapr_drc_detach(drc);", "} else {", "trace_spapr_drc_set_isolation_state_deferring(drc_index);", "}", "}", "drc->configured = false;", "return RTAS_OUT_SUCCESS;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 15 ], [ 17 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 51 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ] ]
16,813
static void compat_free_buffer(void *opaque, uint8_t *data) { CompatReleaseBufPriv *priv = opaque; priv->avctx.release_buffer(&priv->avctx, &priv->frame); av_freep(&priv); }
false
FFmpeg
a2816230c5c0a8fc72bc0163b7d21a96b194d87a
static void compat_free_buffer(void *opaque, uint8_t *data) { CompatReleaseBufPriv *priv = opaque; priv->avctx.release_buffer(&priv->avctx, &priv->frame); av_freep(&priv); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, uint8_t *VAR_1) { CompatReleaseBufPriv *priv = VAR_0; priv->avctx.release_buffer(&priv->avctx, &priv->frame); av_freep(&priv); }
[ "static void FUNC_0(void *VAR_0, uint8_t *VAR_1)\n{", "CompatReleaseBufPriv *priv = VAR_0;", "priv->avctx.release_buffer(&priv->avctx, &priv->frame);", "av_freep(&priv);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ] ]
16,814
static int aio_write_f(BlockBackend *blk, int argc, char **argv) { int nr_iov, c; int pattern = 0xcd; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); int flags = 0; ctx->blk = blk; while ((c = getopt(argc, argv, "CfqP:uz")) != -1) { switch (c) { case 'C': ctx->Cflag = true; break; case 'f': flags |= BDRV_REQ_FUA; break; case 'q': ctx->qflag = true; break; case 'u': flags |= BDRV_REQ_MAY_UNMAP; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) { g_free(ctx); return 0; } break; case 'z': ctx->zflag = true; break; default: g_free(ctx); return qemuio_command_usage(&aio_write_cmd); } } if (optind > argc - 2) { g_free(ctx); return qemuio_command_usage(&aio_write_cmd); } if (ctx->zflag && optind != argc - 2) { printf("-z supports only a single length parameter\n"); g_free(ctx); return 0; } if ((flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) { printf("-u requires -z to be specified\n"); g_free(ctx); return 0; } if (ctx->zflag && ctx->Pflag) { printf("-z and -P cannot be specified at the same time\n"); g_free(ctx); return 0; } ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { print_cvtnum_err(ctx->offset, argv[optind]); g_free(ctx); return 0; } optind++; if (ctx->zflag) { int64_t count = cvtnum(argv[optind]); if (count < 0) { print_cvtnum_err(count, argv[optind]); g_free(ctx); return 0; } ctx->qiov.size = count; blk_aio_write_zeroes(blk, ctx->offset, count, flags, aio_write_done, ctx); } else { nr_iov = argc - optind; ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, pattern); if (ctx->buf == NULL) { block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE); g_free(ctx); return 0; } gettimeofday(&ctx->t1, NULL); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_WRITE); blk_aio_pwritev(blk, ctx->offset, &ctx->qiov, flags, aio_write_done, ctx); } return 0; }
false
qemu
37546ff28fb89744ebf2223db22cbc253592abe1
static int aio_write_f(BlockBackend *blk, int argc, char **argv) { int nr_iov, c; int pattern = 0xcd; struct aio_ctx *ctx = g_new0(struct aio_ctx, 1); int flags = 0; ctx->blk = blk; while ((c = getopt(argc, argv, "CfqP:uz")) != -1) { switch (c) { case 'C': ctx->Cflag = true; break; case 'f': flags |= BDRV_REQ_FUA; break; case 'q': ctx->qflag = true; break; case 'u': flags |= BDRV_REQ_MAY_UNMAP; break; case 'P': pattern = parse_pattern(optarg); if (pattern < 0) { g_free(ctx); return 0; } break; case 'z': ctx->zflag = true; break; default: g_free(ctx); return qemuio_command_usage(&aio_write_cmd); } } if (optind > argc - 2) { g_free(ctx); return qemuio_command_usage(&aio_write_cmd); } if (ctx->zflag && optind != argc - 2) { printf("-z supports only a single length parameter\n"); g_free(ctx); return 0; } if ((flags & BDRV_REQ_MAY_UNMAP) && !ctx->zflag) { printf("-u requires -z to be specified\n"); g_free(ctx); return 0; } if (ctx->zflag && ctx->Pflag) { printf("-z and -P cannot be specified at the same time\n"); g_free(ctx); return 0; } ctx->offset = cvtnum(argv[optind]); if (ctx->offset < 0) { print_cvtnum_err(ctx->offset, argv[optind]); g_free(ctx); return 0; } optind++; if (ctx->zflag) { int64_t count = cvtnum(argv[optind]); if (count < 0) { print_cvtnum_err(count, argv[optind]); g_free(ctx); return 0; } ctx->qiov.size = count; blk_aio_write_zeroes(blk, ctx->offset, count, flags, aio_write_done, ctx); } else { nr_iov = argc - optind; ctx->buf = create_iovec(blk, &ctx->qiov, &argv[optind], nr_iov, pattern); if (ctx->buf == NULL) { block_acct_invalid(blk_get_stats(blk), BLOCK_ACCT_WRITE); g_free(ctx); return 0; } gettimeofday(&ctx->t1, NULL); block_acct_start(blk_get_stats(blk), &ctx->acct, ctx->qiov.size, BLOCK_ACCT_WRITE); blk_aio_pwritev(blk, ctx->offset, &ctx->qiov, flags, aio_write_done, ctx); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2) { int VAR_3, VAR_4; int VAR_5 = 0xcd; struct aio_ctx *VAR_6 = g_new0(struct aio_ctx, 1); int VAR_7 = 0; VAR_6->VAR_0 = VAR_0; while ((VAR_4 = getopt(VAR_1, VAR_2, "CfqP:uz")) != -1) { switch (VAR_4) { case 'C': VAR_6->Cflag = true; break; case 'f': VAR_7 |= BDRV_REQ_FUA; break; case 'q': VAR_6->qflag = true; break; case 'u': VAR_7 |= BDRV_REQ_MAY_UNMAP; break; case 'P': VAR_5 = parse_pattern(optarg); if (VAR_5 < 0) { g_free(VAR_6); return 0; } break; case 'z': VAR_6->zflag = true; break; default: g_free(VAR_6); return qemuio_command_usage(&aio_write_cmd); } } if (optind > VAR_1 - 2) { g_free(VAR_6); return qemuio_command_usage(&aio_write_cmd); } if (VAR_6->zflag && optind != VAR_1 - 2) { printf("-z supports only a single length parameter\n"); g_free(VAR_6); return 0; } if ((VAR_7 & BDRV_REQ_MAY_UNMAP) && !VAR_6->zflag) { printf("-u requires -z to be specified\n"); g_free(VAR_6); return 0; } if (VAR_6->zflag && VAR_6->Pflag) { printf("-z and -P cannot be specified at the same time\n"); g_free(VAR_6); return 0; } VAR_6->offset = cvtnum(VAR_2[optind]); if (VAR_6->offset < 0) { print_cvtnum_err(VAR_6->offset, VAR_2[optind]); g_free(VAR_6); return 0; } optind++; if (VAR_6->zflag) { int64_t count = cvtnum(VAR_2[optind]); if (count < 0) { print_cvtnum_err(count, VAR_2[optind]); g_free(VAR_6); return 0; } VAR_6->qiov.size = count; blk_aio_write_zeroes(VAR_0, VAR_6->offset, count, VAR_7, aio_write_done, VAR_6); } else { VAR_3 = VAR_1 - optind; VAR_6->buf = create_iovec(VAR_0, &VAR_6->qiov, &VAR_2[optind], VAR_3, VAR_5); if (VAR_6->buf == NULL) { block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE); g_free(VAR_6); return 0; } gettimeofday(&VAR_6->t1, NULL); block_acct_start(blk_get_stats(VAR_0), &VAR_6->acct, VAR_6->qiov.size, BLOCK_ACCT_WRITE); blk_aio_pwritev(VAR_0, VAR_6->offset, &VAR_6->qiov, VAR_7, aio_write_done, VAR_6); } return 0; }
[ "static int FUNC_0(BlockBackend *VAR_0, int VAR_1, char **VAR_2)\n{", "int VAR_3, VAR_4;", "int VAR_5 = 0xcd;", "struct aio_ctx *VAR_6 = g_new0(struct aio_ctx, 1);", "int VAR_7 = 0;", "VAR_6->VAR_0 = VAR_0;", "while ((VAR_4 = getopt(VAR_1, VAR_2, \"CfqP:uz\")) != -1) {", "switch (VAR_4) {", "case 'C':\nVAR_6->Cflag = true;", "break;", "case 'f':\nVAR_7 |= BDRV_REQ_FUA;", "break;", "case 'q':\nVAR_6->qflag = true;", "break;", "case 'u':\nVAR_7 |= BDRV_REQ_MAY_UNMAP;", "break;", "case 'P':\nVAR_5 = parse_pattern(optarg);", "if (VAR_5 < 0) {", "g_free(VAR_6);", "return 0;", "}", "break;", "case 'z':\nVAR_6->zflag = true;", "break;", "default:\ng_free(VAR_6);", "return qemuio_command_usage(&aio_write_cmd);", "}", "}", "if (optind > VAR_1 - 2) {", "g_free(VAR_6);", "return qemuio_command_usage(&aio_write_cmd);", "}", "if (VAR_6->zflag && optind != VAR_1 - 2) {", "printf(\"-z supports only a single length parameter\\n\");", "g_free(VAR_6);", "return 0;", "}", "if ((VAR_7 & BDRV_REQ_MAY_UNMAP) && !VAR_6->zflag) {", "printf(\"-u requires -z to be specified\\n\");", "g_free(VAR_6);", "return 0;", "}", "if (VAR_6->zflag && VAR_6->Pflag) {", "printf(\"-z and -P cannot be specified at the same time\\n\");", "g_free(VAR_6);", "return 0;", "}", "VAR_6->offset = cvtnum(VAR_2[optind]);", "if (VAR_6->offset < 0) {", "print_cvtnum_err(VAR_6->offset, VAR_2[optind]);", "g_free(VAR_6);", "return 0;", "}", "optind++;", "if (VAR_6->zflag) {", "int64_t count = cvtnum(VAR_2[optind]);", "if (count < 0) {", "print_cvtnum_err(count, VAR_2[optind]);", "g_free(VAR_6);", "return 0;", "}", "VAR_6->qiov.size = count;", "blk_aio_write_zeroes(VAR_0, VAR_6->offset, count, VAR_7, aio_write_done,\nVAR_6);", "} else {", "VAR_3 = VAR_1 - optind;", "VAR_6->buf = create_iovec(VAR_0, &VAR_6->qiov, &VAR_2[optind], VAR_3,\nVAR_5);", "if (VAR_6->buf == NULL) {", "block_acct_invalid(blk_get_stats(VAR_0), BLOCK_ACCT_WRITE);", "g_free(VAR_6);", "return 0;", "}", "gettimeofday(&VAR_6->t1, NULL);", "block_acct_start(blk_get_stats(VAR_0), &VAR_6->acct, VAR_6->qiov.size,\nBLOCK_ACCT_WRITE);", "blk_aio_pwritev(VAR_0, VAR_6->offset, &VAR_6->qiov, VAR_7, aio_write_done,\nVAR_6);", "}", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 157, 159 ], [ 161 ], [ 163 ], [ 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 181 ], [ 183, 185 ], [ 189, 191 ], [ 193 ], [ 195 ], [ 197 ] ]
16,815
void *g_malloc_n(size_t nmemb, size_t size) { size_t sz; void *ptr; __coverity_negative_sink__(nmemb); __coverity_negative_sink__(size); sz = nmemb * size; ptr = __coverity_alloc__(size); __coverity_mark_as_uninitialized_buffer__(ptr); __coverity_mark_as_afm_allocated__(ptr, AFM_free); return ptr; }
false
qemu
7ad4c7200111d20eb97eed4f46b6026e3f0b0eef
void *g_malloc_n(size_t nmemb, size_t size) { size_t sz; void *ptr; __coverity_negative_sink__(nmemb); __coverity_negative_sink__(size); sz = nmemb * size; ptr = __coverity_alloc__(size); __coverity_mark_as_uninitialized_buffer__(ptr); __coverity_mark_as_afm_allocated__(ptr, AFM_free); return ptr; }
{ "code": [], "line_no": [] }
void *FUNC_0(size_t VAR_0, size_t VAR_1) { size_t sz; void *VAR_2; __coverity_negative_sink__(VAR_0); __coverity_negative_sink__(VAR_1); sz = VAR_0 * VAR_1; VAR_2 = __coverity_alloc__(VAR_1); __coverity_mark_as_uninitialized_buffer__(VAR_2); __coverity_mark_as_afm_allocated__(VAR_2, AFM_free); return VAR_2; }
[ "void *FUNC_0(size_t VAR_0, size_t VAR_1)\n{", "size_t sz;", "void *VAR_2;", "__coverity_negative_sink__(VAR_0);", "__coverity_negative_sink__(VAR_1);", "sz = VAR_0 * VAR_1;", "VAR_2 = __coverity_alloc__(VAR_1);", "__coverity_mark_as_uninitialized_buffer__(VAR_2);", "__coverity_mark_as_afm_allocated__(VAR_2, AFM_free);", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
16,818
int i2c_recv(I2CBus *bus) { I2CSlaveClass *sc; if ((QLIST_EMPTY(&bus->current_devs)) || (bus->broadcast)) { return -1; } sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt); if (sc->recv) { return sc->recv(QLIST_FIRST(&bus->current_devs)->elt); } return -1; }
false
qemu
056fca7b51d949aa0e18e0eb647838874a53bcbe
int i2c_recv(I2CBus *bus) { I2CSlaveClass *sc; if ((QLIST_EMPTY(&bus->current_devs)) || (bus->broadcast)) { return -1; } sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->elt); if (sc->recv) { return sc->recv(QLIST_FIRST(&bus->current_devs)->elt); } return -1; }
{ "code": [], "line_no": [] }
int FUNC_0(I2CBus *VAR_0) { I2CSlaveClass *sc; if ((QLIST_EMPTY(&VAR_0->current_devs)) || (VAR_0->broadcast)) { return -1; } sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&VAR_0->current_devs)->elt); if (sc->recv) { return sc->recv(QLIST_FIRST(&VAR_0->current_devs)->elt); } return -1; }
[ "int FUNC_0(I2CBus *VAR_0)\n{", "I2CSlaveClass *sc;", "if ((QLIST_EMPTY(&VAR_0->current_devs)) || (VAR_0->broadcast)) {", "return -1;", "}", "sc = I2C_SLAVE_GET_CLASS(QLIST_FIRST(&VAR_0->current_devs)->elt);", "if (sc->recv) {", "return sc->recv(QLIST_FIRST(&VAR_0->current_devs)->elt);", "}", "return -1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
16,819
static int spapr_vga_init(PCIBus *pci_bus) { switch (vga_interface_type) { case VGA_STD: pci_std_vga_init(pci_bus); return 1; case VGA_NONE: return 0; default: fprintf(stderr, "This vga model is not supported," "currently it only supports -vga std\n"); exit(0); break; } }
false
qemu
1ddcae82a2509668b94a13e84921bdcafddcdfff
static int spapr_vga_init(PCIBus *pci_bus) { switch (vga_interface_type) { case VGA_STD: pci_std_vga_init(pci_bus); return 1; case VGA_NONE: return 0; default: fprintf(stderr, "This vga model is not supported," "currently it only supports -vga std\n"); exit(0); break; } }
{ "code": [], "line_no": [] }
static int FUNC_0(PCIBus *VAR_0) { switch (vga_interface_type) { case VGA_STD: pci_std_vga_init(VAR_0); return 1; case VGA_NONE: return 0; default: fprintf(stderr, "This vga model is not supported," "currently it only supports -vga std\n"); exit(0); break; } }
[ "static int FUNC_0(PCIBus *VAR_0)\n{", "switch (vga_interface_type) {", "case VGA_STD:\npci_std_vga_init(VAR_0);", "return 1;", "case VGA_NONE:\nreturn 0;", "default:\nfprintf(stderr, \"This vga model is not supported,\"\n\"currently it only supports -vga std\\n\");", "exit(0);", "break;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13, 15 ], [ 17, 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ] ]
16,820
void async_context_pop(void) { }
false
qemu
4e59b545868a5ee5f59b346337f0c44209929334
void async_context_pop(void) { }
{ "code": [], "line_no": [] }
void FUNC_0(void) { }
[ "void FUNC_0(void)\n{", "}" ]
[ 0, 0 ]
[ [ 1, 3 ], [ 5 ] ]
16,822
static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx) { if (!ctx) { ctx = qemu_get_aio_context(); } memset(pool, 0, sizeof(*pool)); event_notifier_init(&pool->notifier, false); pool->ctx = ctx; qemu_mutex_init(&pool->lock); qemu_cond_init(&pool->check_cancel); qemu_cond_init(&pool->worker_stopped); qemu_sem_init(&pool->sem, 0); pool->max_threads = 64; pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool); QLIST_INIT(&pool->head); QTAILQ_INIT(&pool->request_list); aio_set_event_notifier(ctx, &pool->notifier, event_notifier_ready); }
false
qemu
c2e50e3d11a0bf4c973cc30478c1af0f2d5f8e81
static void thread_pool_init_one(ThreadPool *pool, AioContext *ctx) { if (!ctx) { ctx = qemu_get_aio_context(); } memset(pool, 0, sizeof(*pool)); event_notifier_init(&pool->notifier, false); pool->ctx = ctx; qemu_mutex_init(&pool->lock); qemu_cond_init(&pool->check_cancel); qemu_cond_init(&pool->worker_stopped); qemu_sem_init(&pool->sem, 0); pool->max_threads = 64; pool->new_thread_bh = aio_bh_new(ctx, spawn_thread_bh_fn, pool); QLIST_INIT(&pool->head); QTAILQ_INIT(&pool->request_list); aio_set_event_notifier(ctx, &pool->notifier, event_notifier_ready); }
{ "code": [], "line_no": [] }
static void FUNC_0(ThreadPool *VAR_0, AioContext *VAR_1) { if (!VAR_1) { VAR_1 = qemu_get_aio_context(); } memset(VAR_0, 0, sizeof(*VAR_0)); event_notifier_init(&VAR_0->notifier, false); VAR_0->VAR_1 = VAR_1; qemu_mutex_init(&VAR_0->lock); qemu_cond_init(&VAR_0->check_cancel); qemu_cond_init(&VAR_0->worker_stopped); qemu_sem_init(&VAR_0->sem, 0); VAR_0->max_threads = 64; VAR_0->new_thread_bh = aio_bh_new(VAR_1, spawn_thread_bh_fn, VAR_0); QLIST_INIT(&VAR_0->head); QTAILQ_INIT(&VAR_0->request_list); aio_set_event_notifier(VAR_1, &VAR_0->notifier, event_notifier_ready); }
[ "static void FUNC_0(ThreadPool *VAR_0, AioContext *VAR_1)\n{", "if (!VAR_1) {", "VAR_1 = qemu_get_aio_context();", "}", "memset(VAR_0, 0, sizeof(*VAR_0));", "event_notifier_init(&VAR_0->notifier, false);", "VAR_0->VAR_1 = VAR_1;", "qemu_mutex_init(&VAR_0->lock);", "qemu_cond_init(&VAR_0->check_cancel);", "qemu_cond_init(&VAR_0->worker_stopped);", "qemu_sem_init(&VAR_0->sem, 0);", "VAR_0->max_threads = 64;", "VAR_0->new_thread_bh = aio_bh_new(VAR_1, spawn_thread_bh_fn, VAR_0);", "QLIST_INIT(&VAR_0->head);", "QTAILQ_INIT(&VAR_0->request_list);", "aio_set_event_notifier(VAR_1, &VAR_0->notifier, event_notifier_ready);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ] ]
16,823
static always_inline void gen_cmov (TCGCond inv_cond, int ra, int rb, int rc, int islit, uint8_t lit, int mask) { int l1; if (unlikely(rc == 31)) return; l1 = gen_new_label(); if (ra != 31) { if (mask) { TCGv tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_andi_i64(tmp, cpu_ir[ra], 1); tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1); tcg_temp_free(tmp); } else tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, l1); } else { /* Very uncommon case - Do not bother to optimize. */ TCGv tmp = tcg_const_i64(0); tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1); tcg_temp_free(tmp); } if (islit) tcg_gen_movi_i64(cpu_ir[rc], lit); else tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); gen_set_label(l1); }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static always_inline void gen_cmov (TCGCond inv_cond, int ra, int rb, int rc, int islit, uint8_t lit, int mask) { int l1; if (unlikely(rc == 31)) return; l1 = gen_new_label(); if (ra != 31) { if (mask) { TCGv tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_andi_i64(tmp, cpu_ir[ra], 1); tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1); tcg_temp_free(tmp); } else tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, l1); } else { TCGv tmp = tcg_const_i64(0); tcg_gen_brcondi_i64(inv_cond, tmp, 0, l1); tcg_temp_free(tmp); } if (islit) tcg_gen_movi_i64(cpu_ir[rc], lit); else tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); gen_set_label(l1); }
{ "code": [], "line_no": [] }
static always_inline void FUNC_0 (TCGCond inv_cond, int ra, int rb, int rc, int islit, uint8_t lit, int mask) { int VAR_0; if (unlikely(rc == 31)) return; VAR_0 = gen_new_label(); if (ra != 31) { if (mask) { TCGv tmp = tcg_temp_new(TCG_TYPE_I64); tcg_gen_andi_i64(tmp, cpu_ir[ra], 1); tcg_gen_brcondi_i64(inv_cond, tmp, 0, VAR_0); tcg_temp_free(tmp); } else tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, VAR_0); } else { TCGv tmp = tcg_const_i64(0); tcg_gen_brcondi_i64(inv_cond, tmp, 0, VAR_0); tcg_temp_free(tmp); } if (islit) tcg_gen_movi_i64(cpu_ir[rc], lit); else tcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]); gen_set_label(VAR_0); }
[ "static always_inline void FUNC_0 (TCGCond inv_cond,\nint ra, int rb, int rc,\nint islit, uint8_t lit, int mask)\n{", "int VAR_0;", "if (unlikely(rc == 31))\nreturn;", "VAR_0 = gen_new_label();", "if (ra != 31) {", "if (mask) {", "TCGv tmp = tcg_temp_new(TCG_TYPE_I64);", "tcg_gen_andi_i64(tmp, cpu_ir[ra], 1);", "tcg_gen_brcondi_i64(inv_cond, tmp, 0, VAR_0);", "tcg_temp_free(tmp);", "} else", "tcg_gen_brcondi_i64(inv_cond, cpu_ir[ra], 0, VAR_0);", "} else {", "TCGv tmp = tcg_const_i64(0);", "tcg_gen_brcondi_i64(inv_cond, tmp, 0, VAR_0);", "tcg_temp_free(tmp);", "}", "if (islit)\ntcg_gen_movi_i64(cpu_ir[rc], lit);", "else\ntcg_gen_mov_i64(cpu_ir[rc], cpu_ir[rb]);", "gen_set_label(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 13, 15 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53, 55 ], [ 57, 59 ], [ 61 ], [ 63 ] ]
16,824
static int process_tns_coeffs(TemporalNoiseShaping *tns, float *tns_coefs_raw, int order, int w, int filt) { int i, j; int *idx = tns->coef_idx[w][filt]; float *lpc = tns->coef[w][filt]; const int iqfac_p = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0); const int iqfac_m = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0); float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f}; /* Quantization */ for (i = 0; i < order; i++) { idx[i] = ceilf(asin(tns_coefs_raw[i])*((tns_coefs_raw[i] >= 0) ? iqfac_p : iqfac_m)); lpc[i] = 2*sin(idx[i]/((idx[i] >= 0) ? iqfac_p : iqfac_m)); } /* Trim any coeff less than 0.1f from the end */ for (i = order; i > -1; i--) { lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f; if (lpc[i] != 0.0 ) { order = i; break; } } if (!order) return 0; /* Step up procedure, convert to LPC coeffs */ out[0] = 1.0f; for (i = 1; i <= order; i++) { for (j = 1; j < i; j++) { temp[j] = out[j] + lpc[i]*out[i-j]; } for (j = 1; j <= i; j++) { out[j] = temp[j]; } out[i] = lpc[i-1]; } memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float)); return order; }
false
FFmpeg
f20b67173ca6a05b8c3dee02dad3b7243b96292b
static int process_tns_coeffs(TemporalNoiseShaping *tns, float *tns_coefs_raw, int order, int w, int filt) { int i, j; int *idx = tns->coef_idx[w][filt]; float *lpc = tns->coef[w][filt]; const int iqfac_p = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0); const int iqfac_m = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0); float temp[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f}; for (i = 0; i < order; i++) { idx[i] = ceilf(asin(tns_coefs_raw[i])*((tns_coefs_raw[i] >= 0) ? iqfac_p : iqfac_m)); lpc[i] = 2*sin(idx[i]/((idx[i] >= 0) ? iqfac_p : iqfac_m)); } for (i = order; i > -1; i--) { lpc[i] = (fabs(lpc[i]) > 0.1f) ? lpc[i] : 0.0f; if (lpc[i] != 0.0 ) { order = i; break; } } if (!order) return 0; out[0] = 1.0f; for (i = 1; i <= order; i++) { for (j = 1; j < i; j++) { temp[j] = out[j] + lpc[i]*out[i-j]; } for (j = 1; j <= i; j++) { out[j] = temp[j]; } out[i] = lpc[i-1]; } memcpy(lpc, out, TNS_MAX_ORDER*sizeof(float)); return order; }
{ "code": [], "line_no": [] }
static int FUNC_0(TemporalNoiseShaping *VAR_0, float *VAR_1, int VAR_2, int VAR_3, int VAR_4) { int VAR_5, VAR_6; int *VAR_7 = VAR_0->coef_idx[VAR_3][VAR_4]; float *VAR_8 = VAR_0->coef[VAR_3][VAR_4]; const int VAR_9 = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0); const int VAR_10 = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0); float VAR_11[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f}; for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { VAR_7[VAR_5] = ceilf(asin(VAR_1[VAR_5])*((VAR_1[VAR_5] >= 0) ? VAR_9 : VAR_10)); VAR_8[VAR_5] = 2*sin(VAR_7[VAR_5]/((VAR_7[VAR_5] >= 0) ? VAR_9 : VAR_10)); } for (VAR_5 = VAR_2; VAR_5 > -1; VAR_5--) { VAR_8[VAR_5] = (fabs(VAR_8[VAR_5]) > 0.1f) ? VAR_8[VAR_5] : 0.0f; if (VAR_8[VAR_5] != 0.0 ) { VAR_2 = VAR_5; break; } } if (!VAR_2) return 0; out[0] = 1.0f; for (VAR_5 = 1; VAR_5 <= VAR_2; VAR_5++) { for (VAR_6 = 1; VAR_6 < VAR_5; VAR_6++) { VAR_11[VAR_6] = out[VAR_6] + VAR_8[VAR_5]*out[VAR_5-VAR_6]; } for (VAR_6 = 1; VAR_6 <= VAR_5; VAR_6++) { out[VAR_6] = VAR_11[VAR_6]; } out[VAR_5] = VAR_8[VAR_5-1]; } memcpy(VAR_8, out, TNS_MAX_ORDER*sizeof(float)); return VAR_2; }
[ "static int FUNC_0(TemporalNoiseShaping *VAR_0, float *VAR_1,\nint VAR_2, int VAR_3, int VAR_4)\n{", "int VAR_5, VAR_6;", "int *VAR_7 = VAR_0->coef_idx[VAR_3][VAR_4];", "float *VAR_8 = VAR_0->coef[VAR_3][VAR_4];", "const int VAR_9 = ((1 << (MAX_LPC_PRECISION-1)) - 0.5)/(M_PI/2.0);", "const int VAR_10 = ((1 << (MAX_LPC_PRECISION-1)) + 0.5)/(M_PI/2.0);", "float VAR_11[TNS_MAX_ORDER] = {0.0f}, out[TNS_MAX_ORDER] = {0.0f};", "for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {", "VAR_7[VAR_5] = ceilf(asin(VAR_1[VAR_5])*((VAR_1[VAR_5] >= 0) ? VAR_9 : VAR_10));", "VAR_8[VAR_5] = 2*sin(VAR_7[VAR_5]/((VAR_7[VAR_5] >= 0) ? VAR_9 : VAR_10));", "}", "for (VAR_5 = VAR_2; VAR_5 > -1; VAR_5--) {", "VAR_8[VAR_5] = (fabs(VAR_8[VAR_5]) > 0.1f) ? VAR_8[VAR_5] : 0.0f;", "if (VAR_8[VAR_5] != 0.0 ) {", "VAR_2 = VAR_5;", "break;", "}", "}", "if (!VAR_2)\nreturn 0;", "out[0] = 1.0f;", "for (VAR_5 = 1; VAR_5 <= VAR_2; VAR_5++) {", "for (VAR_6 = 1; VAR_6 < VAR_5; VAR_6++) {", "VAR_11[VAR_6] = out[VAR_6] + VAR_8[VAR_5]*out[VAR_5-VAR_6];", "}", "for (VAR_6 = 1; VAR_6 <= VAR_5; VAR_6++) {", "out[VAR_6] = VAR_11[VAR_6];", "}", "out[VAR_5] = VAR_8[VAR_5-1];", "}", "memcpy(VAR_8, out, TNS_MAX_ORDER*sizeof(float));", "return VAR_2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51, 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ] ]
16,825
static inline void downmix_3f_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) { samples[i] += samples[i + 256]; samples[i + 256] = samples[i + 512]; samples[i + 512] = 0; } }
false
FFmpeg
0058584580b87feb47898e60e4b80c7f425882ad
static inline void downmix_3f_to_stereo(float *samples) { int i; for (i = 0; i < 256; i++) { samples[i] += samples[i + 256]; samples[i + 256] = samples[i + 512]; samples[i + 512] = 0; } }
{ "code": [], "line_no": [] }
static inline void FUNC_0(float *VAR_0) { int VAR_1; for (VAR_1 = 0; VAR_1 < 256; VAR_1++) { VAR_0[VAR_1] += VAR_0[VAR_1 + 256]; VAR_0[VAR_1 + 256] = VAR_0[VAR_1 + 512]; VAR_0[VAR_1 + 512] = 0; } }
[ "static inline void FUNC_0(float *VAR_0)\n{", "int VAR_1;", "for (VAR_1 = 0; VAR_1 < 256; VAR_1++) {", "VAR_0[VAR_1] += VAR_0[VAR_1 + 256];", "VAR_0[VAR_1 + 256] = VAR_0[VAR_1 + 512];", "VAR_0[VAR_1 + 512] = 0;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ] ]
16,826
static int vfio_set_resample_eventfd(VFIOINTp *intp) { VFIODevice *vbasedev = &intp->vdev->vbasedev; struct vfio_irq_set *irq_set; int argsz, ret; int32_t *pfd; argsz = sizeof(*irq_set) + sizeof(*pfd); irq_set = g_malloc0(argsz); irq_set->argsz = argsz; irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK; irq_set->index = intp->pin; irq_set->start = 0; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; *pfd = event_notifier_get_fd(&intp->unmask); qemu_set_fd_handler(*pfd, NULL, NULL, NULL); ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); if (ret < 0) { error_report("vfio: Failed to set resample eventfd: %m"); } return ret; }
false
qemu
a22313deca720e038ebc5805cf451b3a685d29ce
static int vfio_set_resample_eventfd(VFIOINTp *intp) { VFIODevice *vbasedev = &intp->vdev->vbasedev; struct vfio_irq_set *irq_set; int argsz, ret; int32_t *pfd; argsz = sizeof(*irq_set) + sizeof(*pfd); irq_set = g_malloc0(argsz); irq_set->argsz = argsz; irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK; irq_set->index = intp->pin; irq_set->start = 0; irq_set->count = 1; pfd = (int32_t *)&irq_set->data; *pfd = event_notifier_get_fd(&intp->unmask); qemu_set_fd_handler(*pfd, NULL, NULL, NULL); ret = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, irq_set); g_free(irq_set); if (ret < 0) { error_report("vfio: Failed to set resample eventfd: %m"); } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(VFIOINTp *VAR_0) { VFIODevice *vbasedev = &VAR_0->vdev->vbasedev; struct vfio_irq_set *VAR_1; int VAR_2, VAR_3; int32_t *pfd; VAR_2 = sizeof(*VAR_1) + sizeof(*pfd); VAR_1 = g_malloc0(VAR_2); VAR_1->VAR_2 = VAR_2; VAR_1->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK; VAR_1->index = VAR_0->pin; VAR_1->start = 0; VAR_1->count = 1; pfd = (int32_t *)&VAR_1->data; *pfd = event_notifier_get_fd(&VAR_0->unmask); qemu_set_fd_handler(*pfd, NULL, NULL, NULL); VAR_3 = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, VAR_1); g_free(VAR_1); if (VAR_3 < 0) { error_report("vfio: Failed to set resample eventfd: %m"); } return VAR_3; }
[ "static int FUNC_0(VFIOINTp *VAR_0)\n{", "VFIODevice *vbasedev = &VAR_0->vdev->vbasedev;", "struct vfio_irq_set *VAR_1;", "int VAR_2, VAR_3;", "int32_t *pfd;", "VAR_2 = sizeof(*VAR_1) + sizeof(*pfd);", "VAR_1 = g_malloc0(VAR_2);", "VAR_1->VAR_2 = VAR_2;", "VAR_1->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_UNMASK;", "VAR_1->index = VAR_0->pin;", "VAR_1->start = 0;", "VAR_1->count = 1;", "pfd = (int32_t *)&VAR_1->data;", "*pfd = event_notifier_get_fd(&VAR_0->unmask);", "qemu_set_fd_handler(*pfd, NULL, NULL, NULL);", "VAR_3 = ioctl(vbasedev->fd, VFIO_DEVICE_SET_IRQS, VAR_1);", "g_free(VAR_1);", "if (VAR_3 < 0) {", "error_report(\"vfio: Failed to set resample eventfd: %m\");", "}", "return VAR_3;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
16,827
static void test_io_channel_unix_fd_pass(void) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); SocketAddress *connect_addr = g_new0(SocketAddress, 1); QIOChannel *src, *dst; int testfd; int fdsend[3]; int *fdrecv = NULL; size_t nfdrecv = 0; size_t i; char bufsend[12], bufrecv[12]; struct iovec iosend[1], iorecv[1]; #define TEST_SOCKET "test-io-channel-socket.sock" #define TEST_FILE "test-io-channel-socket.txt" testfd = open(TEST_FILE, O_RDWR|O_TRUNC|O_CREAT, 0700); g_assert(testfd != -1); fdsend[0] = testfd; fdsend[1] = testfd; fdsend[2] = testfd; listen_addr->type = SOCKET_ADDRESS_KIND_UNIX; listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); connect_addr->type = SOCKET_ADDRESS_KIND_UNIX; connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); memcpy(bufsend, "Hello World", G_N_ELEMENTS(bufsend)); iosend[0].iov_base = bufsend; iosend[0].iov_len = G_N_ELEMENTS(bufsend); iorecv[0].iov_base = bufrecv; iorecv[0].iov_len = G_N_ELEMENTS(bufrecv); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); qio_channel_writev_full(src, iosend, G_N_ELEMENTS(iosend), fdsend, G_N_ELEMENTS(fdsend), &error_abort); qio_channel_readv_full(dst, iorecv, G_N_ELEMENTS(iorecv), &fdrecv, &nfdrecv, &error_abort); g_assert(nfdrecv == G_N_ELEMENTS(fdsend)); /* Each recvd FD should be different from sent FD */ for (i = 0; i < nfdrecv; i++) { g_assert_cmpint(fdrecv[i], !=, testfd); } /* Each recvd FD should be different from each other */ g_assert_cmpint(fdrecv[0], !=, fdrecv[1]); g_assert_cmpint(fdrecv[0], !=, fdrecv[2]); g_assert_cmpint(fdrecv[1], !=, fdrecv[2]); /* Check the I/O buf we sent at the same time matches */ g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); /* Write some data into the FD we received */ g_assert(write(fdrecv[0], bufsend, G_N_ELEMENTS(bufsend)) == G_N_ELEMENTS(bufsend)); /* Read data from the original FD and make sure it matches */ memset(bufrecv, 0, G_N_ELEMENTS(bufrecv)); g_assert(lseek(testfd, 0, SEEK_SET) == 0); g_assert(read(testfd, bufrecv, G_N_ELEMENTS(bufrecv)) == G_N_ELEMENTS(bufrecv)); g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); qapi_free_SocketAddress(listen_addr); qapi_free_SocketAddress(connect_addr); unlink(TEST_SOCKET); unlink(TEST_FILE); close(testfd); for (i = 0; i < nfdrecv; i++) { close(fdrecv[i]); } g_free(fdrecv); }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
static void test_io_channel_unix_fd_pass(void) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); SocketAddress *connect_addr = g_new0(SocketAddress, 1); QIOChannel *src, *dst; int testfd; int fdsend[3]; int *fdrecv = NULL; size_t nfdrecv = 0; size_t i; char bufsend[12], bufrecv[12]; struct iovec iosend[1], iorecv[1]; #define TEST_SOCKET "test-io-channel-socket.sock" #define TEST_FILE "test-io-channel-socket.txt" testfd = open(TEST_FILE, O_RDWR|O_TRUNC|O_CREAT, 0700); g_assert(testfd != -1); fdsend[0] = testfd; fdsend[1] = testfd; fdsend[2] = testfd; listen_addr->type = SOCKET_ADDRESS_KIND_UNIX; listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); connect_addr->type = SOCKET_ADDRESS_KIND_UNIX; connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); memcpy(bufsend, "Hello World", G_N_ELEMENTS(bufsend)); iosend[0].iov_base = bufsend; iosend[0].iov_len = G_N_ELEMENTS(bufsend); iorecv[0].iov_base = bufrecv; iorecv[0].iov_len = G_N_ELEMENTS(bufrecv); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); qio_channel_writev_full(src, iosend, G_N_ELEMENTS(iosend), fdsend, G_N_ELEMENTS(fdsend), &error_abort); qio_channel_readv_full(dst, iorecv, G_N_ELEMENTS(iorecv), &fdrecv, &nfdrecv, &error_abort); g_assert(nfdrecv == G_N_ELEMENTS(fdsend)); for (i = 0; i < nfdrecv; i++) { g_assert_cmpint(fdrecv[i], !=, testfd); } g_assert_cmpint(fdrecv[0], !=, fdrecv[1]); g_assert_cmpint(fdrecv[0], !=, fdrecv[2]); g_assert_cmpint(fdrecv[1], !=, fdrecv[2]); g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); g_assert(write(fdrecv[0], bufsend, G_N_ELEMENTS(bufsend)) == G_N_ELEMENTS(bufsend)); memset(bufrecv, 0, G_N_ELEMENTS(bufrecv)); g_assert(lseek(testfd, 0, SEEK_SET) == 0); g_assert(read(testfd, bufrecv, G_N_ELEMENTS(bufrecv)) == G_N_ELEMENTS(bufrecv)); g_assert(memcmp(bufsend, bufrecv, G_N_ELEMENTS(bufsend)) == 0); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); qapi_free_SocketAddress(listen_addr); qapi_free_SocketAddress(connect_addr); unlink(TEST_SOCKET); unlink(TEST_FILE); close(testfd); for (i = 0; i < nfdrecv; i++) { close(fdrecv[i]); } g_free(fdrecv); }
{ "code": [], "line_no": [] }
static void FUNC_0(void) { SocketAddress *listen_addr = g_new0(SocketAddress, 1); SocketAddress *connect_addr = g_new0(SocketAddress, 1); QIOChannel *src, *dst; int VAR_0; int VAR_1[3]; int *VAR_2 = NULL; size_t nfdrecv = 0; size_t i; char VAR_3[12], VAR_4[12]; struct iovec VAR_5[1], iorecv[1]; #define TEST_SOCKET "test-io-channel-socket.sock" #define TEST_FILE "test-io-channel-socket.txt" VAR_0 = open(TEST_FILE, O_RDWR|O_TRUNC|O_CREAT, 0700); g_assert(VAR_0 != -1); VAR_1[0] = VAR_0; VAR_1[1] = VAR_0; VAR_1[2] = VAR_0; listen_addr->type = SOCKET_ADDRESS_KIND_UNIX; listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); connect_addr->type = SOCKET_ADDRESS_KIND_UNIX; connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1); connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET); test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst); memcpy(VAR_3, "Hello World", G_N_ELEMENTS(VAR_3)); VAR_5[0].iov_base = VAR_3; VAR_5[0].iov_len = G_N_ELEMENTS(VAR_3); iorecv[0].iov_base = VAR_4; iorecv[0].iov_len = G_N_ELEMENTS(VAR_4); g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS)); g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS)); qio_channel_writev_full(src, VAR_5, G_N_ELEMENTS(VAR_5), VAR_1, G_N_ELEMENTS(VAR_1), &error_abort); qio_channel_readv_full(dst, iorecv, G_N_ELEMENTS(iorecv), &VAR_2, &nfdrecv, &error_abort); g_assert(nfdrecv == G_N_ELEMENTS(VAR_1)); for (i = 0; i < nfdrecv; i++) { g_assert_cmpint(VAR_2[i], !=, VAR_0); } g_assert_cmpint(VAR_2[0], !=, VAR_2[1]); g_assert_cmpint(VAR_2[0], !=, VAR_2[2]); g_assert_cmpint(VAR_2[1], !=, VAR_2[2]); g_assert(memcmp(VAR_3, VAR_4, G_N_ELEMENTS(VAR_3)) == 0); g_assert(write(VAR_2[0], VAR_3, G_N_ELEMENTS(VAR_3)) == G_N_ELEMENTS(VAR_3)); memset(VAR_4, 0, G_N_ELEMENTS(VAR_4)); g_assert(lseek(VAR_0, 0, SEEK_SET) == 0); g_assert(read(VAR_0, VAR_4, G_N_ELEMENTS(VAR_4)) == G_N_ELEMENTS(VAR_4)); g_assert(memcmp(VAR_3, VAR_4, G_N_ELEMENTS(VAR_3)) == 0); object_unref(OBJECT(src)); object_unref(OBJECT(dst)); qapi_free_SocketAddress(listen_addr); qapi_free_SocketAddress(connect_addr); unlink(TEST_SOCKET); unlink(TEST_FILE); close(VAR_0); for (i = 0; i < nfdrecv; i++) { close(VAR_2[i]); } g_free(VAR_2); }
[ "static void FUNC_0(void)\n{", "SocketAddress *listen_addr = g_new0(SocketAddress, 1);", "SocketAddress *connect_addr = g_new0(SocketAddress, 1);", "QIOChannel *src, *dst;", "int VAR_0;", "int VAR_1[3];", "int *VAR_2 = NULL;", "size_t nfdrecv = 0;", "size_t i;", "char VAR_3[12], VAR_4[12];", "struct iovec VAR_5[1], iorecv[1];", "#define TEST_SOCKET \"test-io-channel-socket.sock\"\n#define TEST_FILE \"test-io-channel-socket.txt\"\nVAR_0 = open(TEST_FILE, O_RDWR|O_TRUNC|O_CREAT, 0700);", "g_assert(VAR_0 != -1);", "VAR_1[0] = VAR_0;", "VAR_1[1] = VAR_0;", "VAR_1[2] = VAR_0;", "listen_addr->type = SOCKET_ADDRESS_KIND_UNIX;", "listen_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);", "listen_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);", "connect_addr->type = SOCKET_ADDRESS_KIND_UNIX;", "connect_addr->u.q_unix.data = g_new0(UnixSocketAddress, 1);", "connect_addr->u.q_unix.data->path = g_strdup(TEST_SOCKET);", "test_io_channel_setup_sync(listen_addr, connect_addr, &src, &dst);", "memcpy(VAR_3, \"Hello World\", G_N_ELEMENTS(VAR_3));", "VAR_5[0].iov_base = VAR_3;", "VAR_5[0].iov_len = G_N_ELEMENTS(VAR_3);", "iorecv[0].iov_base = VAR_4;", "iorecv[0].iov_len = G_N_ELEMENTS(VAR_4);", "g_assert(qio_channel_has_feature(src, QIO_CHANNEL_FEATURE_FD_PASS));", "g_assert(qio_channel_has_feature(dst, QIO_CHANNEL_FEATURE_FD_PASS));", "qio_channel_writev_full(src,\nVAR_5,\nG_N_ELEMENTS(VAR_5),\nVAR_1,\nG_N_ELEMENTS(VAR_1),\n&error_abort);", "qio_channel_readv_full(dst,\niorecv,\nG_N_ELEMENTS(iorecv),\n&VAR_2,\n&nfdrecv,\n&error_abort);", "g_assert(nfdrecv == G_N_ELEMENTS(VAR_1));", "for (i = 0; i < nfdrecv; i++) {", "g_assert_cmpint(VAR_2[i], !=, VAR_0);", "}", "g_assert_cmpint(VAR_2[0], !=, VAR_2[1]);", "g_assert_cmpint(VAR_2[0], !=, VAR_2[2]);", "g_assert_cmpint(VAR_2[1], !=, VAR_2[2]);", "g_assert(memcmp(VAR_3, VAR_4, G_N_ELEMENTS(VAR_3)) == 0);", "g_assert(write(VAR_2[0], VAR_3, G_N_ELEMENTS(VAR_3)) ==\nG_N_ELEMENTS(VAR_3));", "memset(VAR_4, 0, G_N_ELEMENTS(VAR_4));", "g_assert(lseek(VAR_0, 0, SEEK_SET) == 0);", "g_assert(read(VAR_0, VAR_4, G_N_ELEMENTS(VAR_4)) ==\nG_N_ELEMENTS(VAR_4));", "g_assert(memcmp(VAR_3, VAR_4, G_N_ELEMENTS(VAR_3)) == 0);", "object_unref(OBJECT(src));", "object_unref(OBJECT(dst));", "qapi_free_SocketAddress(listen_addr);", "qapi_free_SocketAddress(connect_addr);", "unlink(TEST_SOCKET);", "unlink(TEST_FILE);", "close(VAR_0);", "for (i = 0; i < nfdrecv; i++) {", "close(VAR_2[i]);", "}", "g_free(VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29, 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 65 ], [ 69 ], [ 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87, 89, 91, 93, 95, 97 ], [ 101, 103, 105, 107, 109, 111 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 127 ], [ 129 ], [ 131 ], [ 137 ], [ 143, 145 ], [ 151 ], [ 153 ], [ 155, 157 ], [ 159 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ] ]
16,828
static int raw_open_common(BlockDriverState *bs, const char *filename, int bdrv_flags, int open_flags) { BDRVRawState *s = bs->opaque; int fd, ret; ret = raw_normalize_devicepath(&filename); if (ret != 0) { return ret; } s->open_flags = open_flags | O_BINARY; s->open_flags &= ~O_ACCMODE; if (bdrv_flags & BDRV_O_RDWR) { s->open_flags |= O_RDWR; } else { s->open_flags |= O_RDONLY; } /* Use O_DSYNC for write-through caching, no flags for write-back caching, * and O_DIRECT for no caching. */ if ((bdrv_flags & BDRV_O_NOCACHE)) s->open_flags |= O_DIRECT; if (!(bdrv_flags & BDRV_O_CACHE_WB)) s->open_flags |= O_DSYNC; s->fd = -1; fd = qemu_open(filename, s->open_flags, 0644); if (fd < 0) { ret = -errno; if (ret == -EROFS) ret = -EACCES; return ret; } s->fd = fd; s->aligned_buf = NULL; if ((bdrv_flags & BDRV_O_NOCACHE)) { /* * Allocate a buffer for read/modify/write cycles. Chose the size * pessimistically as we don't know the block size yet. */ s->aligned_buf_size = 32 * MAX_BLOCKSIZE; s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size); if (s->aligned_buf == NULL) { goto out_close; } } /* We're falling back to POSIX AIO in some cases so init always */ if (paio_init() < 0) { goto out_free_buf; } #ifdef CONFIG_LINUX_AIO /* * Currently Linux do AIO only for files opened with O_DIRECT * specified so check NOCACHE flag too */ if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { s->aio_ctx = laio_init(); if (!s->aio_ctx) { goto out_free_buf; } s->use_aio = 1; } else #endif { #ifdef CONFIG_LINUX_AIO s->use_aio = 0; #endif } #ifdef CONFIG_XFS if (platform_test_xfs_fd(s->fd)) { s->is_xfs = 1; } #endif return 0; out_free_buf: qemu_vfree(s->aligned_buf); out_close: qemu_close(fd); return -errno; }
false
qemu
fc32a72dc19a79f7e16156784b1e76a128d41841
static int raw_open_common(BlockDriverState *bs, const char *filename, int bdrv_flags, int open_flags) { BDRVRawState *s = bs->opaque; int fd, ret; ret = raw_normalize_devicepath(&filename); if (ret != 0) { return ret; } s->open_flags = open_flags | O_BINARY; s->open_flags &= ~O_ACCMODE; if (bdrv_flags & BDRV_O_RDWR) { s->open_flags |= O_RDWR; } else { s->open_flags |= O_RDONLY; } if ((bdrv_flags & BDRV_O_NOCACHE)) s->open_flags |= O_DIRECT; if (!(bdrv_flags & BDRV_O_CACHE_WB)) s->open_flags |= O_DSYNC; s->fd = -1; fd = qemu_open(filename, s->open_flags, 0644); if (fd < 0) { ret = -errno; if (ret == -EROFS) ret = -EACCES; return ret; } s->fd = fd; s->aligned_buf = NULL; if ((bdrv_flags & BDRV_O_NOCACHE)) { s->aligned_buf_size = 32 * MAX_BLOCKSIZE; s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size); if (s->aligned_buf == NULL) { goto out_close; } } if (paio_init() < 0) { goto out_free_buf; } #ifdef CONFIG_LINUX_AIO if ((bdrv_flags & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { s->aio_ctx = laio_init(); if (!s->aio_ctx) { goto out_free_buf; } s->use_aio = 1; } else #endif { #ifdef CONFIG_LINUX_AIO s->use_aio = 0; #endif } #ifdef CONFIG_XFS if (platform_test_xfs_fd(s->fd)) { s->is_xfs = 1; } #endif return 0; out_free_buf: qemu_vfree(s->aligned_buf); out_close: qemu_close(fd); return -errno; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1, int VAR_2, int VAR_3) { BDRVRawState *s = VAR_0->opaque; int VAR_4, VAR_5; VAR_5 = raw_normalize_devicepath(&VAR_1); if (VAR_5 != 0) { return VAR_5; } s->VAR_3 = VAR_3 | O_BINARY; s->VAR_3 &= ~O_ACCMODE; if (VAR_2 & BDRV_O_RDWR) { s->VAR_3 |= O_RDWR; } else { s->VAR_3 |= O_RDONLY; } if ((VAR_2 & BDRV_O_NOCACHE)) s->VAR_3 |= O_DIRECT; if (!(VAR_2 & BDRV_O_CACHE_WB)) s->VAR_3 |= O_DSYNC; s->VAR_4 = -1; VAR_4 = qemu_open(VAR_1, s->VAR_3, 0644); if (VAR_4 < 0) { VAR_5 = -errno; if (VAR_5 == -EROFS) VAR_5 = -EACCES; return VAR_5; } s->VAR_4 = VAR_4; s->aligned_buf = NULL; if ((VAR_2 & BDRV_O_NOCACHE)) { s->aligned_buf_size = 32 * MAX_BLOCKSIZE; s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size); if (s->aligned_buf == NULL) { goto out_close; } } if (paio_init() < 0) { goto out_free_buf; } #ifdef CONFIG_LINUX_AIO if ((VAR_2 & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) == (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) { s->aio_ctx = laio_init(); if (!s->aio_ctx) { goto out_free_buf; } s->use_aio = 1; } else #endif { #ifdef CONFIG_LINUX_AIO s->use_aio = 0; #endif } #ifdef CONFIG_XFS if (platform_test_xfs_fd(s->VAR_4)) { s->is_xfs = 1; } #endif return 0; out_free_buf: qemu_vfree(s->aligned_buf); out_close: qemu_close(VAR_4); return -errno; }
[ "static int FUNC_0(BlockDriverState *VAR_0, const char *VAR_1,\nint VAR_2, int VAR_3)\n{", "BDRVRawState *s = VAR_0->opaque;", "int VAR_4, VAR_5;", "VAR_5 = raw_normalize_devicepath(&VAR_1);", "if (VAR_5 != 0) {", "return VAR_5;", "}", "s->VAR_3 = VAR_3 | O_BINARY;", "s->VAR_3 &= ~O_ACCMODE;", "if (VAR_2 & BDRV_O_RDWR) {", "s->VAR_3 |= O_RDWR;", "} else {", "s->VAR_3 |= O_RDONLY;", "}", "if ((VAR_2 & BDRV_O_NOCACHE))\ns->VAR_3 |= O_DIRECT;", "if (!(VAR_2 & BDRV_O_CACHE_WB))\ns->VAR_3 |= O_DSYNC;", "s->VAR_4 = -1;", "VAR_4 = qemu_open(VAR_1, s->VAR_3, 0644);", "if (VAR_4 < 0) {", "VAR_5 = -errno;", "if (VAR_5 == -EROFS)\nVAR_5 = -EACCES;", "return VAR_5;", "}", "s->VAR_4 = VAR_4;", "s->aligned_buf = NULL;", "if ((VAR_2 & BDRV_O_NOCACHE)) {", "s->aligned_buf_size = 32 * MAX_BLOCKSIZE;", "s->aligned_buf = qemu_memalign(MAX_BLOCKSIZE, s->aligned_buf_size);", "if (s->aligned_buf == NULL) {", "goto out_close;", "}", "}", "if (paio_init() < 0) {", "goto out_free_buf;", "}", "#ifdef CONFIG_LINUX_AIO\nif ((VAR_2 & (BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) ==\n(BDRV_O_NOCACHE|BDRV_O_NATIVE_AIO)) {", "s->aio_ctx = laio_init();", "if (!s->aio_ctx) {", "goto out_free_buf;", "}", "s->use_aio = 1;", "} else", "#endif\n{", "#ifdef CONFIG_LINUX_AIO\ns->use_aio = 0;", "#endif\n}", "#ifdef CONFIG_XFS\nif (platform_test_xfs_fd(s->VAR_4)) {", "s->is_xfs = 1;", "}", "#endif\nreturn 0;", "out_free_buf:\nqemu_vfree(s->aligned_buf);", "out_close:\nqemu_close(VAR_4);", "return -errno;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 43, 45 ], [ 47, 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 75 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 101 ], [ 103 ], [ 105 ], [ 109, 119, 121 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141, 143 ], [ 145, 147 ], [ 151, 153 ], [ 155 ], [ 157 ], [ 159, 163 ], [ 167, 169 ], [ 171, 173 ], [ 175 ], [ 177 ] ]
16,830
static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs) { return close(fs->fd); }
false
qemu
494a8ebe713055d3946183f4b395f85a18b43e9e
static int proxy_close(FsContext *ctx, V9fsFidOpenState *fs) { return close(fs->fd); }
{ "code": [], "line_no": [] }
static int FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1) { return close(VAR_1->fd); }
[ "static int FUNC_0(FsContext *VAR_0, V9fsFidOpenState *VAR_1)\n{", "return close(VAR_1->fd);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]