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
5,954
static av_cold int ape_decode_init(AVCodecContext * avctx) { APEContext *s = avctx->priv_data; int i; if (avctx->extradata_size != 6) { av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n"); return -1; } if (avctx->bits_per_coded_sample != 16) { av_log(avctx, AV_LOG_ERROR, "Only 16-bit samples are supported\n"); return -1; } if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n"); return -1; } s->avctx = avctx; s->channels = avctx->channels; s->fileversion = AV_RL16(avctx->extradata); s->compression_level = AV_RL16(avctx->extradata + 2); s->flags = AV_RL16(avctx->extradata + 4); av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n", s->compression_level, s->flags); if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) { av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n", s->compression_level); return -1; } s->fset = s->compression_level / 1000 - 1; for (i = 0; i < APE_FILTER_LEVELS; i++) { if (!ape_filter_orders[s->fset][i]) break; s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4); } dsputil_init(&s->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; return 0; }
true
FFmpeg
7500781313d11b37772c05a28da20fbc112db478
static av_cold int ape_decode_init(AVCodecContext * avctx) { APEContext *s = avctx->priv_data; int i; if (avctx->extradata_size != 6) { av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n"); return -1; } if (avctx->bits_per_coded_sample != 16) { av_log(avctx, AV_LOG_ERROR, "Only 16-bit samples are supported\n"); return -1; } if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n"); return -1; } s->avctx = avctx; s->channels = avctx->channels; s->fileversion = AV_RL16(avctx->extradata); s->compression_level = AV_RL16(avctx->extradata + 2); s->flags = AV_RL16(avctx->extradata + 4); av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n", s->compression_level, s->flags); if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) { av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n", s->compression_level); return -1; } s->fset = s->compression_level / 1000 - 1; for (i = 0; i < APE_FILTER_LEVELS; i++) { if (!ape_filter_orders[s->fset][i]) break; s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4); } dsputil_init(&s->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; return 0; }
{ "code": [ " s->filterbuf[i] = av_malloc((ape_filter_orders[s->fset][i] * 3 + HISTORY_SIZE) * 4);", " APEContext *s = avctx->priv_data;", " int i;", " return 0;" ], "line_no": [ 65, 5, 7, 77 ] }
static av_cold int FUNC_0(AVCodecContext * avctx) { APEContext *s = avctx->priv_data; int VAR_0; if (avctx->extradata_size != 6) { av_log(avctx, AV_LOG_ERROR, "Incorrect extradata\n"); return -1; } if (avctx->bits_per_coded_sample != 16) { av_log(avctx, AV_LOG_ERROR, "Only 16-bit samples are supported\n"); return -1; } if (avctx->channels > 2) { av_log(avctx, AV_LOG_ERROR, "Only mono and stereo is supported\n"); return -1; } s->avctx = avctx; s->channels = avctx->channels; s->fileversion = AV_RL16(avctx->extradata); s->compression_level = AV_RL16(avctx->extradata + 2); s->flags = AV_RL16(avctx->extradata + 4); av_log(avctx, AV_LOG_DEBUG, "Compression Level: %d - Flags: %d\n", s->compression_level, s->flags); if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) { av_log(avctx, AV_LOG_ERROR, "Incorrect compression level %d\n", s->compression_level); return -1; } s->fset = s->compression_level / 1000 - 1; for (VAR_0 = 0; VAR_0 < APE_FILTER_LEVELS; VAR_0++) { if (!ape_filter_orders[s->fset][VAR_0]) break; s->filterbuf[VAR_0] = av_malloc((ape_filter_orders[s->fset][VAR_0] * 3 + HISTORY_SIZE) * 4); } dsputil_init(&s->dsp, avctx); avctx->sample_fmt = AV_SAMPLE_FMT_S16; avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; return 0; }
[ "static av_cold int FUNC_0(AVCodecContext * avctx)\n{", "APEContext *s = avctx->priv_data;", "int VAR_0;", "if (avctx->extradata_size != 6) {", "av_log(avctx, AV_LOG_ERROR, \"Incorrect extradata\\n\");", "return -1;", "}", "if (avctx->bits_per_coded_sample != 16) {", "av_log(avctx, AV_LOG_ERROR, \"Only 16-bit samples are supported\\n\");", "return -1;", "}", "if (avctx->channels > 2) {", "av_log(avctx, AV_LOG_ERROR, \"Only mono and stereo is supported\\n\");", "return -1;", "}", "s->avctx = avctx;", "s->channels = avctx->channels;", "s->fileversion = AV_RL16(avctx->extradata);", "s->compression_level = AV_RL16(avctx->extradata + 2);", "s->flags = AV_RL16(avctx->extradata + 4);", "av_log(avctx, AV_LOG_DEBUG, \"Compression Level: %d - Flags: %d\\n\", s->compression_level, s->flags);", "if (s->compression_level % 1000 || s->compression_level > COMPRESSION_LEVEL_INSANE) {", "av_log(avctx, AV_LOG_ERROR, \"Incorrect compression level %d\\n\", s->compression_level);", "return -1;", "}", "s->fset = s->compression_level / 1000 - 1;", "for (VAR_0 = 0; VAR_0 < APE_FILTER_LEVELS; VAR_0++) {", "if (!ape_filter_orders[s->fset][VAR_0])\nbreak;", "s->filterbuf[VAR_0] = av_malloc((ape_filter_orders[s->fset][VAR_0] * 3 + HISTORY_SIZE) * 4);", "}", "dsputil_init(&s->dsp, avctx);", "avctx->sample_fmt = AV_SAMPLE_FMT_S16;", "avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;", "return 0;", "}" ]
[ 0, 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, 1, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
5,955
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { char buf[4096]; if (!mon) return; if (monitor_ctrl_mode(mon)) { return; } vsnprintf(buf, sizeof(buf), fmt, ap); monitor_puts(mon, buf); }
true
qemu
e1f2641b5926d20f63d36f0de45206be774da8da
void monitor_vprintf(Monitor *mon, const char *fmt, va_list ap) { char buf[4096]; if (!mon) return; if (monitor_ctrl_mode(mon)) { return; } vsnprintf(buf, sizeof(buf), fmt, ap); monitor_puts(mon, buf); }
{ "code": [ " char buf[4096];", " vsnprintf(buf, sizeof(buf), fmt, ap);" ], "line_no": [ 5, 23 ] }
void FUNC_0(Monitor *VAR_0, const char *VAR_1, va_list VAR_2) { char VAR_3[4096]; if (!VAR_0) return; if (monitor_ctrl_mode(VAR_0)) { return; } vsnprintf(VAR_3, sizeof(VAR_3), VAR_1, VAR_2); monitor_puts(VAR_0, VAR_3); }
[ "void FUNC_0(Monitor *VAR_0, const char *VAR_1, va_list VAR_2)\n{", "char VAR_3[4096];", "if (!VAR_0)\nreturn;", "if (monitor_ctrl_mode(VAR_0)) {", "return;", "}", "vsnprintf(VAR_3, sizeof(VAR_3), VAR_1, VAR_2);", "monitor_puts(VAR_0, VAR_3);", "}" ]
[ 0, 1, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ] ]
5,956
static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; const uint16_t *src = (const uint16_t *) _src; int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; int sh = bits - 4; for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; int val = 0; for (j = 0; j < filterSize; j++) { val += src[srcPos + j] * filter[filterSize * i + j]; } // filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit dst[i] = FFMIN(val >> sh, (1 << 19) - 1); } }
true
FFmpeg
2254b559cbcfc0418135f09add37c0a5866b1981
static void hScale16To19_c(SwsContext *c, int16_t *_dst, int dstW, const uint8_t *_src, const int16_t *filter, const int16_t *filterPos, int filterSize) { int i; int32_t *dst = (int32_t *) _dst; const uint16_t *src = (const uint16_t *) _src; int bits = av_pix_fmt_descriptors[c->srcFormat].comp[0].depth_minus1; int sh = bits - 4; for (i = 0; i < dstW; i++) { int j; int srcPos = filterPos[i]; int val = 0; for (j = 0; j < filterSize; j++) { val += src[srcPos + j] * filter[filterSize * i + j]; } dst[i] = FFMIN(val >> sh, (1 << 19) - 1); } }
{ "code": [ " const int16_t *filterPos, int filterSize)", " const int16_t *filterPos, int filterSize)" ], "line_no": [ 5, 5 ] }
static void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1, int VAR_2, const uint8_t *VAR_3, const int16_t *VAR_4, const int16_t *VAR_5, int VAR_6) { int VAR_7; int32_t *dst = (int32_t *) VAR_1; const uint16_t *VAR_8 = (const uint16_t *) VAR_3; int VAR_9 = av_pix_fmt_descriptors[VAR_0->srcFormat].comp[0].depth_minus1; int VAR_10 = VAR_9 - 4; for (VAR_7 = 0; VAR_7 < VAR_2; VAR_7++) { int VAR_11; int VAR_12 = VAR_5[VAR_7]; int VAR_13 = 0; for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) { VAR_13 += VAR_8[VAR_12 + VAR_11] * VAR_4[VAR_6 * VAR_7 + VAR_11]; } dst[VAR_7] = FFMIN(VAR_13 >> VAR_10, (1 << 19) - 1); } }
[ "static void FUNC_0(SwsContext *VAR_0, int16_t *VAR_1, int VAR_2, const uint8_t *VAR_3,\nconst int16_t *VAR_4,\nconst int16_t *VAR_5, int VAR_6)\n{", "int VAR_7;", "int32_t *dst = (int32_t *) VAR_1;", "const uint16_t *VAR_8 = (const uint16_t *) VAR_3;", "int VAR_9 = av_pix_fmt_descriptors[VAR_0->srcFormat].comp[0].depth_minus1;", "int VAR_10 = VAR_9 - 4;", "for (VAR_7 = 0; VAR_7 < VAR_2; VAR_7++) {", "int VAR_11;", "int VAR_12 = VAR_5[VAR_7];", "int VAR_13 = 0;", "for (VAR_11 = 0; VAR_11 < VAR_6; VAR_11++) {", "VAR_13 += VAR_8[VAR_12 + VAR_11] * VAR_4[VAR_6 * VAR_7 + VAR_11];", "}", "dst[VAR_7] = FFMIN(VAR_13 >> VAR_10, (1 << 19) - 1);", "}", "}" ]
[ 1, 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 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ] ]
5,957
static int milkymist_softusb_init(SysBusDevice *dev) { MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev); sysbus_init_irq(dev, &s->irq); memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s, "milkymist-softusb", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); /* register pmem and dmem */ memory_region_init_ram(&s->pmem, OBJECT(s), "milkymist-softusb.pmem", s->pmem_size, &error_abort); vmstate_register_ram_global(&s->pmem); s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem); sysbus_init_mmio(dev, &s->pmem); memory_region_init_ram(&s->dmem, OBJECT(s), "milkymist-softusb.dmem", s->dmem_size, &error_abort); vmstate_register_ram_global(&s->dmem); s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem); sysbus_init_mmio(dev, &s->dmem); hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain); hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain); return 0; }
true
qemu
f8ed85ac992c48814d916d5df4d44f9a971c5de4
static int milkymist_softusb_init(SysBusDevice *dev) { MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(dev); sysbus_init_irq(dev, &s->irq); memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s, "milkymist-softusb", R_MAX * 4); sysbus_init_mmio(dev, &s->regs_region); memory_region_init_ram(&s->pmem, OBJECT(s), "milkymist-softusb.pmem", s->pmem_size, &error_abort); vmstate_register_ram_global(&s->pmem); s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem); sysbus_init_mmio(dev, &s->pmem); memory_region_init_ram(&s->dmem, OBJECT(s), "milkymist-softusb.dmem", s->dmem_size, &error_abort); vmstate_register_ram_global(&s->dmem); s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem); sysbus_init_mmio(dev, &s->dmem); hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain); hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain); return 0; }
{ "code": [ " s->pmem_size, &error_abort);", " s->dmem_size, &error_abort);" ], "line_no": [ 25, 35 ] }
static int FUNC_0(SysBusDevice *VAR_0) { MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(VAR_0); sysbus_init_irq(VAR_0, &s->irq); memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s, "milkymist-softusb", R_MAX * 4); sysbus_init_mmio(VAR_0, &s->regs_region); memory_region_init_ram(&s->pmem, OBJECT(s), "milkymist-softusb.pmem", s->pmem_size, &error_abort); vmstate_register_ram_global(&s->pmem); s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem); sysbus_init_mmio(VAR_0, &s->pmem); memory_region_init_ram(&s->dmem, OBJECT(s), "milkymist-softusb.dmem", s->dmem_size, &error_abort); vmstate_register_ram_global(&s->dmem); s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem); sysbus_init_mmio(VAR_0, &s->dmem); hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain); hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain); return 0; }
[ "static int FUNC_0(SysBusDevice *VAR_0)\n{", "MilkymistSoftUsbState *s = MILKYMIST_SOFTUSB(VAR_0);", "sysbus_init_irq(VAR_0, &s->irq);", "memory_region_init_io(&s->regs_region, OBJECT(s), &softusb_mmio_ops, s,\n\"milkymist-softusb\", R_MAX * 4);", "sysbus_init_mmio(VAR_0, &s->regs_region);", "memory_region_init_ram(&s->pmem, OBJECT(s), \"milkymist-softusb.pmem\",\ns->pmem_size, &error_abort);", "vmstate_register_ram_global(&s->pmem);", "s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem);", "sysbus_init_mmio(VAR_0, &s->pmem);", "memory_region_init_ram(&s->dmem, OBJECT(s), \"milkymist-softusb.dmem\",\ns->dmem_size, &error_abort);", "vmstate_register_ram_global(&s->dmem);", "s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem);", "sysbus_init_mmio(VAR_0, &s->dmem);", "hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);", "hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13, 15 ], [ 17 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ] ]
5,958
static gnutls_certificate_credentials_t vnc_tls_initialize_x509_cred(VncDisplay *vd) { gnutls_certificate_credentials_t x509_cred; int ret; if (!vd->tls.x509cacert) { VNC_DEBUG("No CA x509 certificate specified\n"); return NULL; } if (!vd->tls.x509cert) { VNC_DEBUG("No server x509 certificate specified\n"); return NULL; } if (!vd->tls.x509key) { VNC_DEBUG("No server private key specified\n"); return NULL; } if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) { VNC_DEBUG("Cannot allocate credentials %s\n", gnutls_strerror(ret)); return NULL; } if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred, vd->tls.x509cacert, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CA certificate %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if ((ret = gnutls_certificate_set_x509_key_file (x509_cred, vd->tls.x509cert, vd->tls.x509key, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load certificate & key %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if (vd->tls.x509cacrl) { if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred, vd->tls.x509cacrl, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CRL %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } } gnutls_certificate_set_dh_params (x509_cred, dh_params); return x509_cred; }
true
qemu
3e305e4a4752f70c0b5c3cf5b43ec957881714f7
static gnutls_certificate_credentials_t vnc_tls_initialize_x509_cred(VncDisplay *vd) { gnutls_certificate_credentials_t x509_cred; int ret; if (!vd->tls.x509cacert) { VNC_DEBUG("No CA x509 certificate specified\n"); return NULL; } if (!vd->tls.x509cert) { VNC_DEBUG("No server x509 certificate specified\n"); return NULL; } if (!vd->tls.x509key) { VNC_DEBUG("No server private key specified\n"); return NULL; } if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) { VNC_DEBUG("Cannot allocate credentials %s\n", gnutls_strerror(ret)); return NULL; } if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred, vd->tls.x509cacert, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CA certificate %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if ((ret = gnutls_certificate_set_x509_key_file (x509_cred, vd->tls.x509cert, vd->tls.x509key, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load certificate & key %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if (vd->tls.x509cacrl) { if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred, vd->tls.x509cacrl, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CRL %s\n", gnutls_strerror(ret)); gnutls_certificate_free_credentials(x509_cred); return NULL; } } gnutls_certificate_set_dh_params (x509_cred, dh_params); return x509_cred; }
{ "code": [ " int ret;", " int ret;", " int ret;", " int ret;", " VNC_DEBUG(\"Cannot allocate credentials %s\\n\", gnutls_strerror(ret));", " return NULL;", "static gnutls_certificate_credentials_t vnc_tls_initialize_x509_cred(VncDisplay *vd)", " gnutls_certificate_credentials_t x509_cred;", " int ret;", " if (!vd->tls.x509cacert) {", " VNC_DEBUG(\"No CA x509 certificate specified\\n\");", " return NULL;", " if (!vd->tls.x509cert) {", " VNC_DEBUG(\"No server x509 certificate specified\\n\");", " return NULL;", " if (!vd->tls.x509key) {", " VNC_DEBUG(\"No server private key specified\\n\");", " return NULL;", " if ((ret = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) {", " VNC_DEBUG(\"Cannot allocate credentials %s\\n\", gnutls_strerror(ret));", " return NULL;", " if ((ret = gnutls_certificate_set_x509_trust_file(x509_cred,", " vd->tls.x509cacert,", " GNUTLS_X509_FMT_PEM)) < 0) {", " VNC_DEBUG(\"Cannot load CA certificate %s\\n\", gnutls_strerror(ret));", " gnutls_certificate_free_credentials(x509_cred);", " return NULL;", " if ((ret = gnutls_certificate_set_x509_key_file (x509_cred,", " vd->tls.x509cert,", " vd->tls.x509key,", " GNUTLS_X509_FMT_PEM)) < 0) {", " VNC_DEBUG(\"Cannot load certificate & key %s\\n\", gnutls_strerror(ret));", " gnutls_certificate_free_credentials(x509_cred);", " return NULL;", " if (vd->tls.x509cacrl) {", " if ((ret = gnutls_certificate_set_x509_crl_file(x509_cred,", " vd->tls.x509cacrl,", " GNUTLS_X509_FMT_PEM)) < 0) {", " VNC_DEBUG(\"Cannot load CRL %s\\n\", gnutls_strerror(ret));", " gnutls_certificate_free_credentials(x509_cred);", " return NULL;", " gnutls_certificate_set_dh_params (x509_cred, dh_params);", " return x509_cred;", " int ret;" ], "line_no": [ 7, 7, 7, 7, 39, 15, 1, 5, 7, 11, 13, 15, 19, 21, 15, 27, 29, 15, 37, 39, 15, 45, 47, 49, 51, 53, 15, 61, 63, 65, 67, 69, 53, 15, 79, 81, 83, 85, 87, 89, 91, 99, 103, 7 ] }
static gnutls_certificate_credentials_t FUNC_0(VncDisplay *vd) { gnutls_certificate_credentials_t x509_cred; int VAR_0; if (!vd->tls.x509cacert) { VNC_DEBUG("No CA x509 certificate specified\n"); return NULL; } if (!vd->tls.x509cert) { VNC_DEBUG("No server x509 certificate specified\n"); return NULL; } if (!vd->tls.x509key) { VNC_DEBUG("No server private key specified\n"); return NULL; } if ((VAR_0 = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) { VNC_DEBUG("Cannot allocate credentials %s\n", gnutls_strerror(VAR_0)); return NULL; } if ((VAR_0 = gnutls_certificate_set_x509_trust_file(x509_cred, vd->tls.x509cacert, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CA certificate %s\n", gnutls_strerror(VAR_0)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if ((VAR_0 = gnutls_certificate_set_x509_key_file (x509_cred, vd->tls.x509cert, vd->tls.x509key, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load certificate & key %s\n", gnutls_strerror(VAR_0)); gnutls_certificate_free_credentials(x509_cred); return NULL; } if (vd->tls.x509cacrl) { if ((VAR_0 = gnutls_certificate_set_x509_crl_file(x509_cred, vd->tls.x509cacrl, GNUTLS_X509_FMT_PEM)) < 0) { VNC_DEBUG("Cannot load CRL %s\n", gnutls_strerror(VAR_0)); gnutls_certificate_free_credentials(x509_cred); return NULL; } } gnutls_certificate_set_dh_params (x509_cred, dh_params); return x509_cred; }
[ "static gnutls_certificate_credentials_t FUNC_0(VncDisplay *vd)\n{", "gnutls_certificate_credentials_t x509_cred;", "int VAR_0;", "if (!vd->tls.x509cacert) {", "VNC_DEBUG(\"No CA x509 certificate specified\\n\");", "return NULL;", "}", "if (!vd->tls.x509cert) {", "VNC_DEBUG(\"No server x509 certificate specified\\n\");", "return NULL;", "}", "if (!vd->tls.x509key) {", "VNC_DEBUG(\"No server private key specified\\n\");", "return NULL;", "}", "if ((VAR_0 = gnutls_certificate_allocate_credentials(&x509_cred)) < 0) {", "VNC_DEBUG(\"Cannot allocate credentials %s\\n\", gnutls_strerror(VAR_0));", "return NULL;", "}", "if ((VAR_0 = gnutls_certificate_set_x509_trust_file(x509_cred,\nvd->tls.x509cacert,\nGNUTLS_X509_FMT_PEM)) < 0) {", "VNC_DEBUG(\"Cannot load CA certificate %s\\n\", gnutls_strerror(VAR_0));", "gnutls_certificate_free_credentials(x509_cred);", "return NULL;", "}", "if ((VAR_0 = gnutls_certificate_set_x509_key_file (x509_cred,\nvd->tls.x509cert,\nvd->tls.x509key,\nGNUTLS_X509_FMT_PEM)) < 0) {", "VNC_DEBUG(\"Cannot load certificate & key %s\\n\", gnutls_strerror(VAR_0));", "gnutls_certificate_free_credentials(x509_cred);", "return NULL;", "}", "if (vd->tls.x509cacrl) {", "if ((VAR_0 = gnutls_certificate_set_x509_crl_file(x509_cred,\nvd->tls.x509cacrl,\nGNUTLS_X509_FMT_PEM)) < 0) {", "VNC_DEBUG(\"Cannot load CRL %s\\n\", gnutls_strerror(VAR_0));", "gnutls_certificate_free_credentials(x509_cred);", "return NULL;", "}", "}", "gnutls_certificate_set_dh_params (x509_cred, dh_params);", "return x509_cred;", "}" ]
[ 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45, 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61, 63, 65, 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81, 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 103 ], [ 105 ] ]
5,959
static int client_migrate_info(Monitor *mon, const QDict *qdict, MonitorCompletion cb, void *opaque) { const char *protocol = qdict_get_str(qdict, "protocol"); const char *hostname = qdict_get_str(qdict, "hostname"); const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); Error *err; int ret; if (strcmp(protocol, "spice") == 0) { if (!qemu_using_spice(&err)) { qerror_report_err(err); return -1; } if (port == -1 && tls_port == -1) { qerror_report(QERR_MISSING_PARAMETER, "port/tls-port"); return -1; } ret = qemu_spice_migrate_info(hostname, port, tls_port, subject, cb, opaque); if (ret != 0) { qerror_report(QERR_UNDEFINED_ERROR); return -1; } return 0; } qerror_report(QERR_INVALID_PARAMETER, "protocol"); return -1; }
true
qemu
606ee8f5eadd79627216bbdde4da0337cb7d4360
static int client_migrate_info(Monitor *mon, const QDict *qdict, MonitorCompletion cb, void *opaque) { const char *protocol = qdict_get_str(qdict, "protocol"); const char *hostname = qdict_get_str(qdict, "hostname"); const char *subject = qdict_get_try_str(qdict, "cert-subject"); int port = qdict_get_try_int(qdict, "port", -1); int tls_port = qdict_get_try_int(qdict, "tls-port", -1); Error *err; int ret; if (strcmp(protocol, "spice") == 0) { if (!qemu_using_spice(&err)) { qerror_report_err(err); return -1; } if (port == -1 && tls_port == -1) { qerror_report(QERR_MISSING_PARAMETER, "port/tls-port"); return -1; } ret = qemu_spice_migrate_info(hostname, port, tls_port, subject, cb, opaque); if (ret != 0) { qerror_report(QERR_UNDEFINED_ERROR); return -1; } return 0; } qerror_report(QERR_INVALID_PARAMETER, "protocol"); return -1; }
{ "code": [ " Error *err;" ], "line_no": [ 17 ] }
static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, MonitorCompletion VAR_2, void *VAR_3) { const char *VAR_4 = qdict_get_str(VAR_1, "VAR_4"); const char *VAR_5 = qdict_get_str(VAR_1, "VAR_5"); const char *VAR_6 = qdict_get_try_str(VAR_1, "cert-VAR_6"); int VAR_7 = qdict_get_try_int(VAR_1, "VAR_7", -1); int VAR_8 = qdict_get_try_int(VAR_1, "tls-VAR_7", -1); Error *err; int VAR_9; if (strcmp(VAR_4, "spice") == 0) { if (!qemu_using_spice(&err)) { qerror_report_err(err); return -1; } if (VAR_7 == -1 && VAR_8 == -1) { qerror_report(QERR_MISSING_PARAMETER, "VAR_7/tls-VAR_7"); return -1; } VAR_9 = qemu_spice_migrate_info(VAR_5, VAR_7, VAR_8, VAR_6, VAR_2, VAR_3); if (VAR_9 != 0) { qerror_report(QERR_UNDEFINED_ERROR); return -1; } return 0; } qerror_report(QERR_INVALID_PARAMETER, "VAR_4"); return -1; }
[ "static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1,\nMonitorCompletion VAR_2, void *VAR_3)\n{", "const char *VAR_4 = qdict_get_str(VAR_1, \"VAR_4\");", "const char *VAR_5 = qdict_get_str(VAR_1, \"VAR_5\");", "const char *VAR_6 = qdict_get_try_str(VAR_1, \"cert-VAR_6\");", "int VAR_7 = qdict_get_try_int(VAR_1, \"VAR_7\", -1);", "int VAR_8 = qdict_get_try_int(VAR_1, \"tls-VAR_7\", -1);", "Error *err;", "int VAR_9;", "if (strcmp(VAR_4, \"spice\") == 0) {", "if (!qemu_using_spice(&err)) {", "qerror_report_err(err);", "return -1;", "}", "if (VAR_7 == -1 && VAR_8 == -1) {", "qerror_report(QERR_MISSING_PARAMETER, \"VAR_7/tls-VAR_7\");", "return -1;", "}", "VAR_9 = qemu_spice_migrate_info(VAR_5, VAR_7, VAR_8, VAR_6,\nVAR_2, VAR_3);", "if (VAR_9 != 0) {", "qerror_report(QERR_UNDEFINED_ERROR);", "return -1;", "}", "return 0;", "}", "qerror_report(QERR_INVALID_PARAMETER, \"VAR_4\");", "return -1;", "}" ]
[ 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ] ]
5,960
static void cmd_inquiry(IDEState *s, uint8_t *buf) { int max_len = buf[4]; buf[0] = 0x05; /* CD-ROM */ buf[1] = 0x80; /* removable */ buf[2] = 0x00; /* ISO */ buf[3] = 0x21; /* ATAPI-2 (XXX: put ATAPI-4 ?) */ buf[4] = 31; /* additional length */ buf[5] = 0; /* reserved */ buf[6] = 0; /* reserved */ buf[7] = 0; /* reserved */ padstr8(buf + 8, 8, "QEMU"); padstr8(buf + 16, 16, "QEMU DVD-ROM"); padstr8(buf + 32, 4, s->version); ide_atapi_cmd_reply(s, 36, max_len); }
true
qemu
9a502563eef7d7c2c9120b237059426e229eefe9
static void cmd_inquiry(IDEState *s, uint8_t *buf) { int max_len = buf[4]; buf[0] = 0x05; buf[1] = 0x80; buf[2] = 0x00; buf[3] = 0x21; buf[4] = 31; buf[5] = 0; buf[6] = 0; buf[7] = 0; padstr8(buf + 8, 8, "QEMU"); padstr8(buf + 16, 16, "QEMU DVD-ROM"); padstr8(buf + 32, 4, s->version); ide_atapi_cmd_reply(s, 36, max_len); }
{ "code": [ " padstr8(buf + 8, 8, \"QEMU\");", " padstr8(buf + 16, 16, \"QEMU DVD-ROM\");", " padstr8(buf + 32, 4, s->version);", " ide_atapi_cmd_reply(s, 36, max_len);" ], "line_no": [ 25, 27, 29, 31 ] }
static void FUNC_0(IDEState *VAR_0, uint8_t *VAR_1) { int VAR_2 = VAR_1[4]; VAR_1[0] = 0x05; VAR_1[1] = 0x80; VAR_1[2] = 0x00; VAR_1[3] = 0x21; VAR_1[4] = 31; VAR_1[5] = 0; VAR_1[6] = 0; VAR_1[7] = 0; padstr8(VAR_1 + 8, 8, "QEMU"); padstr8(VAR_1 + 16, 16, "QEMU DVD-ROM"); padstr8(VAR_1 + 32, 4, VAR_0->version); ide_atapi_cmd_reply(VAR_0, 36, VAR_2); }
[ "static void FUNC_0(IDEState *VAR_0, uint8_t *VAR_1)\n{", "int VAR_2 = VAR_1[4];", "VAR_1[0] = 0x05;", "VAR_1[1] = 0x80;", "VAR_1[2] = 0x00;", "VAR_1[3] = 0x21;", "VAR_1[4] = 31;", "VAR_1[5] = 0;", "VAR_1[6] = 0;", "VAR_1[7] = 0;", "padstr8(VAR_1 + 8, 8, \"QEMU\");", "padstr8(VAR_1 + 16, 16, \"QEMU DVD-ROM\");", "padstr8(VAR_1 + 32, 4, VAR_0->version);", "ide_atapi_cmd_reply(VAR_0, 36, VAR_2);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
5,961
uint32 float32_to_uint32( float32 a STATUS_PARAM ) { int64_t v; uint32 res; v = float32_to_int64(a STATUS_VAR); if (v < 0) { res = 0; float_raise( float_flag_invalid STATUS_VAR); } else if (v > 0xffffffff) { res = 0xffffffff; float_raise( float_flag_invalid STATUS_VAR); } else { res = v; } return res; }
true
qemu
34e1c27bc3094ffe484d9855e07ad104bddf579f
uint32 float32_to_uint32( float32 a STATUS_PARAM ) { int64_t v; uint32 res; v = float32_to_int64(a STATUS_VAR); if (v < 0) { res = 0; float_raise( float_flag_invalid STATUS_VAR); } else if (v > 0xffffffff) { res = 0xffffffff; float_raise( float_flag_invalid STATUS_VAR); } else { res = v; } return res; }
{ "code": [ " float_raise( float_flag_invalid STATUS_VAR);", " float_raise( float_flag_invalid STATUS_VAR);", " res = v;", " float_raise( float_flag_invalid STATUS_VAR);", " float_raise( float_flag_invalid STATUS_VAR);", " res = v;", " float_raise( float_flag_invalid STATUS_VAR);", " float_raise( float_flag_invalid STATUS_VAR);", " res = v;", " float_raise( float_flag_invalid STATUS_VAR);", " float_raise( float_flag_invalid STATUS_VAR);", " res = v;" ], "line_no": [ 17, 17, 27, 17, 17, 27, 17, 17, 27, 17, 17, 27 ] }
uint32 FUNC_0( float32 a STATUS_PARAM ) { int64_t v; uint32 res; v = float32_to_int64(a STATUS_VAR); if (v < 0) { res = 0; float_raise( float_flag_invalid STATUS_VAR); } else if (v > 0xffffffff) { res = 0xffffffff; float_raise( float_flag_invalid STATUS_VAR); } else { res = v; } return res; }
[ "uint32 FUNC_0( float32 a STATUS_PARAM )\n{", "int64_t v;", "uint32 res;", "v = float32_to_int64(a STATUS_VAR);", "if (v < 0) {", "res = 0;", "float_raise( float_flag_invalid STATUS_VAR);", "} else if (v > 0xffffffff) {", "res = 0xffffffff;", "float_raise( float_flag_invalid STATUS_VAR);", "} else {", "res = v;", "}", "return res;", "}" ]
[ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
5,964
sowrite(struct socket *so) { int n,nn; struct sbuf *sb = &so->so_rcv; int len = sb->sb_cc; struct iovec iov[2]; DEBUG_CALL("sowrite"); DEBUG_ARG("so = %p", so); if (so->so_urgc) { sosendoob(so); if (sb->sb_cc == 0) return 0; } /* * No need to check if there's something to write, * sowrite wouldn't have been called otherwise */ iov[0].iov_base = sb->sb_rptr; iov[1].iov_base = NULL; iov[1].iov_len = 0; if (sb->sb_rptr < sb->sb_wptr) { iov[0].iov_len = sb->sb_wptr - sb->sb_rptr; /* Should never succeed, but... */ if (iov[0].iov_len > len) iov[0].iov_len = len; n = 1; } else { iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr; if (iov[0].iov_len > len) iov[0].iov_len = len; len -= iov[0].iov_len; if (len) { iov[1].iov_base = sb->sb_data; iov[1].iov_len = sb->sb_wptr - sb->sb_data; if (iov[1].iov_len > len) iov[1].iov_len = len; n = 2; } else n = 1; } /* Check if there's urgent data to send, and if so, send it */ #ifdef HAVE_READV nn = writev(so->s, (const struct iovec *)iov, n); DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); #else nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len,0); #endif /* This should never happen, but people tell me it does *shrug* */ if (nn < 0 && (errno == EAGAIN || errno == EINTR)) return 0; if (nn <= 0) { DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n", so->so_state, errno)); sofcantsendmore(so); tcp_sockclosed(sototcpcb(so)); return -1; } #ifndef HAVE_READV if (n == 2 && nn == iov[0].iov_len) { int ret; ret = slirp_send(so, iov[1].iov_base, iov[1].iov_len,0); if (ret > 0) nn += ret; } DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); #endif /* Update sbuf */ sb->sb_cc -= nn; sb->sb_rptr += nn; if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen)) sb->sb_rptr -= sb->sb_datalen; /* * If in DRAIN mode, and there's no more data, set * it CANTSENDMORE */ if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0) sofcantsendmore(so); return nn; }
true
qemu
75cb298d905030fca897ea1d80e409c7f7e3e5ea
sowrite(struct socket *so) { int n,nn; struct sbuf *sb = &so->so_rcv; int len = sb->sb_cc; struct iovec iov[2]; DEBUG_CALL("sowrite"); DEBUG_ARG("so = %p", so); if (so->so_urgc) { sosendoob(so); if (sb->sb_cc == 0) return 0; } iov[0].iov_base = sb->sb_rptr; iov[1].iov_base = NULL; iov[1].iov_len = 0; if (sb->sb_rptr < sb->sb_wptr) { iov[0].iov_len = sb->sb_wptr - sb->sb_rptr; if (iov[0].iov_len > len) iov[0].iov_len = len; n = 1; } else { iov[0].iov_len = (sb->sb_data + sb->sb_datalen) - sb->sb_rptr; if (iov[0].iov_len > len) iov[0].iov_len = len; len -= iov[0].iov_len; if (len) { iov[1].iov_base = sb->sb_data; iov[1].iov_len = sb->sb_wptr - sb->sb_data; if (iov[1].iov_len > len) iov[1].iov_len = len; n = 2; } else n = 1; } #ifdef HAVE_READV nn = writev(so->s, (const struct iovec *)iov, n); DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); #else nn = slirp_send(so, iov[0].iov_base, iov[0].iov_len,0); #endif if (nn < 0 && (errno == EAGAIN || errno == EINTR)) return 0; if (nn <= 0) { DEBUG_MISC((dfd, " --- sowrite disconnected, so->so_state = %x, errno = %d\n", so->so_state, errno)); sofcantsendmore(so); tcp_sockclosed(sototcpcb(so)); return -1; } #ifndef HAVE_READV if (n == 2 && nn == iov[0].iov_len) { int ret; ret = slirp_send(so, iov[1].iov_base, iov[1].iov_len,0); if (ret > 0) nn += ret; } DEBUG_MISC((dfd, " ... wrote nn = %d bytes\n", nn)); #endif sb->sb_cc -= nn; sb->sb_rptr += nn; if (sb->sb_rptr >= (sb->sb_data + sb->sb_datalen)) sb->sb_rptr -= sb->sb_datalen; if ((so->so_state & SS_FWDRAIN) && sb->sb_cc == 0) sofcantsendmore(so); return nn; }
{ "code": [ "\t\tsosendoob(so);", "\t\tsosendoob(so);", "\t\tDEBUG_MISC((dfd, \" --- sowrite disconnected, so->so_state = %x, errno = %d\\n\",", "\t\t\tso->so_state, errno));", "\t\tsofcantsendmore(so);", "\t\ttcp_sockclosed(sototcpcb(so));", "\t\treturn -1;" ], "line_no": [ 23, 23, 111, 113, 115, 117, 119 ] }
FUNC_0(struct socket *VAR_0) { int VAR_1,VAR_2; struct sbuf *VAR_3 = &VAR_0->so_rcv; int VAR_4 = VAR_3->sb_cc; struct iovec VAR_5[2]; DEBUG_CALL("FUNC_0"); DEBUG_ARG("VAR_0 = %p", VAR_0); if (VAR_0->so_urgc) { sosendoob(VAR_0); if (VAR_3->sb_cc == 0) return 0; } VAR_5[0].iov_base = VAR_3->sb_rptr; VAR_5[1].iov_base = NULL; VAR_5[1].iov_len = 0; if (VAR_3->sb_rptr < VAR_3->sb_wptr) { VAR_5[0].iov_len = VAR_3->sb_wptr - VAR_3->sb_rptr; if (VAR_5[0].iov_len > VAR_4) VAR_5[0].iov_len = VAR_4; VAR_1 = 1; } else { VAR_5[0].iov_len = (VAR_3->sb_data + VAR_3->sb_datalen) - VAR_3->sb_rptr; if (VAR_5[0].iov_len > VAR_4) VAR_5[0].iov_len = VAR_4; VAR_4 -= VAR_5[0].iov_len; if (VAR_4) { VAR_5[1].iov_base = VAR_3->sb_data; VAR_5[1].iov_len = VAR_3->sb_wptr - VAR_3->sb_data; if (VAR_5[1].iov_len > VAR_4) VAR_5[1].iov_len = VAR_4; VAR_1 = 2; } else VAR_1 = 1; } #ifdef HAVE_READV VAR_2 = writev(VAR_0->s, (const struct iovec *)VAR_5, VAR_1); DEBUG_MISC((dfd, " ... wrote VAR_2 = %d bytes\VAR_1", VAR_2)); #else VAR_2 = slirp_send(VAR_0, VAR_5[0].iov_base, VAR_5[0].iov_len,0); #endif if (VAR_2 < 0 && (errno == EAGAIN || errno == EINTR)) return 0; if (VAR_2 <= 0) { DEBUG_MISC((dfd, " --- FUNC_0 disconnected, VAR_0->so_state = %x, errno = %d\VAR_1", VAR_0->so_state, errno)); sofcantsendmore(VAR_0); tcp_sockclosed(sototcpcb(VAR_0)); return -1; } #ifndef HAVE_READV if (VAR_1 == 2 && VAR_2 == VAR_5[0].iov_len) { int VAR_6; VAR_6 = slirp_send(VAR_0, VAR_5[1].iov_base, VAR_5[1].iov_len,0); if (VAR_6 > 0) VAR_2 += VAR_6; } DEBUG_MISC((dfd, " ... wrote VAR_2 = %d bytes\VAR_1", VAR_2)); #endif VAR_3->sb_cc -= VAR_2; VAR_3->sb_rptr += VAR_2; if (VAR_3->sb_rptr >= (VAR_3->sb_data + VAR_3->sb_datalen)) VAR_3->sb_rptr -= VAR_3->sb_datalen; if ((VAR_0->so_state & SS_FWDRAIN) && VAR_3->sb_cc == 0) sofcantsendmore(VAR_0); return VAR_2; }
[ "FUNC_0(struct socket *VAR_0)\n{", "int VAR_1,VAR_2;", "struct sbuf *VAR_3 = &VAR_0->so_rcv;", "int VAR_4 = VAR_3->sb_cc;", "struct iovec VAR_5[2];", "DEBUG_CALL(\"FUNC_0\");", "DEBUG_ARG(\"VAR_0 = %p\", VAR_0);", "if (VAR_0->so_urgc) {", "sosendoob(VAR_0);", "if (VAR_3->sb_cc == 0)\nreturn 0;", "}", "VAR_5[0].iov_base = VAR_3->sb_rptr;", "VAR_5[1].iov_base = NULL;", "VAR_5[1].iov_len = 0;", "if (VAR_3->sb_rptr < VAR_3->sb_wptr) {", "VAR_5[0].iov_len = VAR_3->sb_wptr - VAR_3->sb_rptr;", "if (VAR_5[0].iov_len > VAR_4) VAR_5[0].iov_len = VAR_4;", "VAR_1 = 1;", "} else {", "VAR_5[0].iov_len = (VAR_3->sb_data + VAR_3->sb_datalen) - VAR_3->sb_rptr;", "if (VAR_5[0].iov_len > VAR_4) VAR_5[0].iov_len = VAR_4;", "VAR_4 -= VAR_5[0].iov_len;", "if (VAR_4) {", "VAR_5[1].iov_base = VAR_3->sb_data;", "VAR_5[1].iov_len = VAR_3->sb_wptr - VAR_3->sb_data;", "if (VAR_5[1].iov_len > VAR_4) VAR_5[1].iov_len = VAR_4;", "VAR_1 = 2;", "} else", "VAR_1 = 1;", "}", "#ifdef HAVE_READV\nVAR_2 = writev(VAR_0->s, (const struct iovec *)VAR_5, VAR_1);", "DEBUG_MISC((dfd, \" ... wrote VAR_2 = %d bytes\\VAR_1\", VAR_2));", "#else\nVAR_2 = slirp_send(VAR_0, VAR_5[0].iov_base, VAR_5[0].iov_len,0);", "#endif\nif (VAR_2 < 0 && (errno == EAGAIN || errno == EINTR))\nreturn 0;", "if (VAR_2 <= 0) {", "DEBUG_MISC((dfd, \" --- FUNC_0 disconnected, VAR_0->so_state = %x, errno = %d\\VAR_1\",\nVAR_0->so_state, errno));", "sofcantsendmore(VAR_0);", "tcp_sockclosed(sototcpcb(VAR_0));", "return -1;", "}", "#ifndef HAVE_READV\nif (VAR_1 == 2 && VAR_2 == VAR_5[0].iov_len) {", "int VAR_6;", "VAR_6 = slirp_send(VAR_0, VAR_5[1].iov_base, VAR_5[1].iov_len,0);", "if (VAR_6 > 0)\nVAR_2 += VAR_6;", "}", "DEBUG_MISC((dfd, \" ... wrote VAR_2 = %d bytes\\VAR_1\", VAR_2));", "#endif\nVAR_3->sb_cc -= VAR_2;", "VAR_3->sb_rptr += VAR_2;", "if (VAR_3->sb_rptr >= (VAR_3->sb_data + VAR_3->sb_datalen))\nVAR_3->sb_rptr -= VAR_3->sb_datalen;", "if ((VAR_0->so_state & SS_FWDRAIN) && VAR_3->sb_cc == 0)\nsofcantsendmore(VAR_0);", "return VAR_2;", "}" ]
[ 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, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 87, 89 ], [ 93 ], [ 95, 97 ], [ 99, 103, 105 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141, 147 ], [ 149 ], [ 151, 153 ], [ 165, 167 ], [ 171 ], [ 173 ] ]
5,966
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { off_t start, data = 0, hole = 0; int64_t total_size; int ret; ret = fd_open(bs); if (ret < 0) { return ret; } start = sector_num * BDRV_SECTOR_SIZE; total_size = bdrv_getlength(bs); if (total_size < 0) { return total_size; } else if (start >= total_size) { *pnum = 0; return 0; } else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) { nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE); } ret = find_allocation(bs, start, &data, &hole); if (ret == -ENXIO) { /* Trailing hole */ *pnum = nb_sectors; ret = BDRV_BLOCK_ZERO; } else if (ret < 0) { /* No info available, so pretend there are no holes */ *pnum = nb_sectors; ret = BDRV_BLOCK_DATA; } else if (data == start) { /* On a data extent, compute sectors to the end of the extent. */ *pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_DATA; } else { /* On a hole, compute sectors to the beginning of the next extent. */ assert(hole == start); *pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_ZERO; } return ret | BDRV_BLOCK_OFFSET_VALID | start; }
true
qemu
f4a769abaa51badea666093077c50c568c35de17
static int64_t coroutine_fn raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { off_t start, data = 0, hole = 0; int64_t total_size; int ret; ret = fd_open(bs); if (ret < 0) { return ret; } start = sector_num * BDRV_SECTOR_SIZE; total_size = bdrv_getlength(bs); if (total_size < 0) { return total_size; } else if (start >= total_size) { *pnum = 0; return 0; } else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) { nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE); } ret = find_allocation(bs, start, &data, &hole); if (ret == -ENXIO) { *pnum = nb_sectors; ret = BDRV_BLOCK_ZERO; } else if (ret < 0) { *pnum = nb_sectors; ret = BDRV_BLOCK_DATA; } else if (data == start) { *pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_DATA; } else { assert(hole == start); *pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_ZERO; } return ret | BDRV_BLOCK_OFFSET_VALID | start; }
{ "code": [ " *pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);" ], "line_no": [ 71 ] }
static int64_t VAR_0 raw_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *pnum) { off_t start, data = 0, hole = 0; int64_t total_size; int ret; ret = fd_open(bs); if (ret < 0) { return ret; } start = sector_num * BDRV_SECTOR_SIZE; total_size = bdrv_getlength(bs); if (total_size < 0) { return total_size; } else if (start >= total_size) { *pnum = 0; return 0; } else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) { nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE); } ret = find_allocation(bs, start, &data, &hole); if (ret == -ENXIO) { *pnum = nb_sectors; ret = BDRV_BLOCK_ZERO; } else if (ret < 0) { *pnum = nb_sectors; ret = BDRV_BLOCK_DATA; } else if (data == start) { *pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_DATA; } else { assert(hole == start); *pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE); ret = BDRV_BLOCK_ZERO; } return ret | BDRV_BLOCK_OFFSET_VALID | start; }
[ "static int64_t VAR_0 raw_co_get_block_status(BlockDriverState *bs,\nint64_t sector_num,\nint nb_sectors, int *pnum)\n{", "off_t start, data = 0, hole = 0;", "int64_t total_size;", "int ret;", "ret = fd_open(bs);", "if (ret < 0) {", "return ret;", "}", "start = sector_num * BDRV_SECTOR_SIZE;", "total_size = bdrv_getlength(bs);", "if (total_size < 0) {", "return total_size;", "} else if (start >= total_size) {", "*pnum = 0;", "return 0;", "} else if (start + nb_sectors * BDRV_SECTOR_SIZE > total_size) {", "nb_sectors = DIV_ROUND_UP(total_size - start, BDRV_SECTOR_SIZE);", "}", "ret = find_allocation(bs, start, &data, &hole);", "if (ret == -ENXIO) {", "*pnum = nb_sectors;", "ret = BDRV_BLOCK_ZERO;", "} else if (ret < 0) {", "*pnum = nb_sectors;", "ret = BDRV_BLOCK_DATA;", "} else if (data == start) {", "*pnum = MIN(nb_sectors, (hole - start) / BDRV_SECTOR_SIZE);", "ret = BDRV_BLOCK_DATA;", "} else {", "assert(hole == start);", "*pnum = MIN(nb_sectors, (data - start) / BDRV_SECTOR_SIZE);", "ret = BDRV_BLOCK_ZERO;", "}", "return ret | BDRV_BLOCK_OFFSET_VALID | start;", "}" ]
[ 0, 0, 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, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ] ]
5,968
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, struct image_info * info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; struct exec interp_ex; int interpreter_fd = -1; /* avoid warning */ abi_ulong load_addr, load_bias; int load_addr_set = 0; unsigned int interpreter_type = INTERPRETER_NONE; unsigned char ibcs2_interpreter; int i; abi_ulong mapped_addr; struct elf_phdr * elf_ppnt; struct elf_phdr *elf_phdata; abi_ulong elf_bss, k, elf_brk; int retval; char * elf_interpreter; abi_ulong elf_entry, interp_load_addr = 0; int status; abi_ulong start_code, end_code, start_data, end_data; abi_ulong reloc_func_desc = 0; abi_ulong elf_stack; char passed_fileno[6]; ibcs2_interpreter = 0; status = 0; load_addr = 0; load_bias = 0; elf_ex = *((struct elfhdr *) bprm->buf); /* exec-header */ #ifdef BSWAP_NEEDED bswap_ehdr(&elf_ex); #endif /* First of all, some simple consistency checks */ if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || (! elf_check_arch(elf_ex.e_machine))) { return -ENOEXEC; } bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p); bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p); bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p); if (!bprm->p) { retval = -E2BIG; } /* Now read in all of the header information */ elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); if (elf_phdata == NULL) { return -ENOMEM; } retval = lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); if(retval > 0) { retval = read(bprm->fd, (char *) elf_phdata, elf_ex.e_phentsize * elf_ex.e_phnum); } if (retval < 0) { perror("load_elf_binary"); exit(-1); free (elf_phdata); return -errno; } #ifdef BSWAP_NEEDED elf_ppnt = elf_phdata; for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) { bswap_phdr(elf_ppnt); } #endif elf_ppnt = elf_phdata; elf_bss = 0; elf_brk = 0; elf_stack = ~((abi_ulong)0UL); elf_interpreter = NULL; start_code = ~((abi_ulong)0UL); end_code = 0; start_data = 0; end_data = 0; for(i=0;i < elf_ex.e_phnum; i++) { if (elf_ppnt->p_type == PT_INTERP) { if ( elf_interpreter != NULL ) { free (elf_phdata); free(elf_interpreter); close(bprm->fd); return -EINVAL; } /* This is the program interpreter used for * shared libraries - for now assume that this * is an a.out format binary */ elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); if (elf_interpreter == NULL) { free (elf_phdata); close(bprm->fd); return -ENOMEM; } retval = lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); if(retval >= 0) { retval = read(bprm->fd, elf_interpreter, elf_ppnt->p_filesz); } if(retval < 0) { perror("load_elf_binary2"); exit(-1); } /* If the program interpreter is one of these two, then assume an iBCS2 image. Otherwise assume a native linux image. */ /* JRP - Need to add X86 lib dir stuff here... */ if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 || strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0) { ibcs2_interpreter = 1; } #if 0 printf("Using ELF interpreter %s\n", elf_interpreter); #endif if (retval >= 0) { retval = open(path(elf_interpreter), O_RDONLY); if(retval >= 0) { interpreter_fd = retval; } else { perror(elf_interpreter); exit(-1); /* retval = -errno; */ } } if (retval >= 0) { retval = lseek(interpreter_fd, 0, SEEK_SET); if(retval >= 0) { retval = read(interpreter_fd,bprm->buf,128); } } if (retval >= 0) { interp_ex = *((struct exec *) bprm->buf); /* aout exec-header */ interp_elf_ex=*((struct elfhdr *) bprm->buf); /* elf exec-header */ } if (retval < 0) { perror("load_elf_binary3"); exit(-1); free (elf_phdata); free(elf_interpreter); close(bprm->fd); return retval; } } elf_ppnt++; } /* Some simple consistency checks for the interpreter */ if (elf_interpreter){ interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; /* Now figure out which format our binary is */ if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) && (N_MAGIC(interp_ex) != QMAGIC)) { interpreter_type = INTERPRETER_ELF; } if (interp_elf_ex.e_ident[0] != 0x7f || strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) { interpreter_type &= ~INTERPRETER_ELF; } if (!interpreter_type) { free(elf_interpreter); free(elf_phdata); close(bprm->fd); return -ELIBBAD; } } /* OK, we are done with that, now set up the arg stuff, and then start this sucker up */ { char * passed_p; if (interpreter_type == INTERPRETER_AOUT) { snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd); passed_p = passed_fileno; if (elf_interpreter) { bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p); bprm->argc++; } } if (!bprm->p) { if (elf_interpreter) { free(elf_interpreter); } free (elf_phdata); close(bprm->fd); return -E2BIG; } } /* OK, This is the point of no return */ info->end_data = 0; info->end_code = 0; info->start_mmap = (abi_ulong)ELF_START_MMAP; info->mmap = 0; elf_entry = (abi_ulong) elf_ex.e_entry; /* Do this so that we can load the interpreter, if need be. We will change some of these later */ info->rss = 0; bprm->p = setup_arg_pages(bprm->p, bprm, info); info->start_stack = bprm->p; /* Now we do a little grungy work by mmaping the ELF image into * the correct location in memory. At this point, we assume that * the image should be loaded at fixed address, not at a variable * address. */ for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { int elf_prot = 0; int elf_flags = 0; abi_ulong error; if (elf_ppnt->p_type != PT_LOAD) continue; if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; elf_flags = MAP_PRIVATE | MAP_DENYWRITE; if (elf_ex.e_type == ET_EXEC || load_addr_set) { elf_flags |= MAP_FIXED; } else if (elf_ex.e_type == ET_DYN) { /* Try and get dynamic programs out of the way of the default mmap base, as well as whatever program they might try to exec. This is because the brk will follow the loader, and is not movable. */ /* NOTE: for qemu, we do a big mmap to get enough space without hardcoding any address */ error = target_mmap(0, ET_DYN_MAP_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); exit(-1); } load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); } error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), (elf_ppnt->p_filesz + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), bprm->fd, (elf_ppnt->p_offset - TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); if (error == -1) { perror("mmap"); exit(-1); } #ifdef LOW_ELF_STACK if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); #endif if (!load_addr_set) { load_addr_set = 1; load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; if (elf_ex.e_type == ET_DYN) { load_bias += error - TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr); load_addr += load_bias; reloc_func_desc = load_bias; } } k = elf_ppnt->p_vaddr; if (k < start_code) start_code = k; if (start_data < k) start_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; if (k > elf_bss) elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) end_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; if (k > elf_brk) elf_brk = k; } elf_entry += load_bias; elf_bss += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias; start_data += load_bias; end_data += load_bias; if (elf_interpreter) { if (interpreter_type & 1) { elf_entry = load_aout_interp(&interp_ex, interpreter_fd); } else if (interpreter_type & 2) { elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd, &interp_load_addr); } reloc_func_desc = interp_load_addr; close(interpreter_fd); free(elf_interpreter); if (elf_entry == ~((abi_ulong)0UL)) { printf("Unable to load interpreter\n"); free(elf_phdata); exit(-1); return 0; } } free(elf_phdata); if (loglevel) load_symbols(&elf_ex, bprm->fd); if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd); info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); #ifdef LOW_ELF_STACK info->start_stack = bprm->p = elf_stack - 4; #endif bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, load_addr, load_bias, interp_load_addr, (interpreter_type == INTERPRETER_AOUT ? 0 : 1), info); info->load_addr = reloc_func_desc; info->start_brk = info->brk = elf_brk; info->end_code = end_code; info->start_code = start_code; info->start_data = start_data; info->end_data = end_data; info->start_stack = bprm->p; /* Calling set_brk effectively mmaps the pages that we need for the bss and break sections */ set_brk(elf_bss, elf_brk); padzero(elf_bss, elf_brk); #if 0 printf("(start_brk) %x\n" , info->start_brk); printf("(end_code) %x\n" , info->end_code); printf("(start_code) %x\n" , info->start_code); printf("(end_data) %x\n" , info->end_data); printf("(start_stack) %x\n" , info->start_stack); printf("(brk) %x\n" , info->brk); #endif if ( info->personality == PER_SVR4 ) { /* Why this, you ask??? Well SVr4 maps page 0 as read-only, and some applications "depend" upon this behavior. Since we do not have the power to recompile these, we emulate the SVr4 behavior. Sigh. */ mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, -1, 0); } info->entry = elf_entry; return 0; }
true
qemu
98448f58c10033a0f7fcd0673cce4626506403fa
int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, struct image_info * info) { struct elfhdr elf_ex; struct elfhdr interp_elf_ex; struct exec interp_ex; int interpreter_fd = -1; abi_ulong load_addr, load_bias; int load_addr_set = 0; unsigned int interpreter_type = INTERPRETER_NONE; unsigned char ibcs2_interpreter; int i; abi_ulong mapped_addr; struct elf_phdr * elf_ppnt; struct elf_phdr *elf_phdata; abi_ulong elf_bss, k, elf_brk; int retval; char * elf_interpreter; abi_ulong elf_entry, interp_load_addr = 0; int status; abi_ulong start_code, end_code, start_data, end_data; abi_ulong reloc_func_desc = 0; abi_ulong elf_stack; char passed_fileno[6]; ibcs2_interpreter = 0; status = 0; load_addr = 0; load_bias = 0; elf_ex = *((struct elfhdr *) bprm->buf); #ifdef BSWAP_NEEDED bswap_ehdr(&elf_ex); #endif if ((elf_ex.e_type != ET_EXEC && elf_ex.e_type != ET_DYN) || (! elf_check_arch(elf_ex.e_machine))) { return -ENOEXEC; } bprm->p = copy_elf_strings(1, &bprm->filename, bprm->page, bprm->p); bprm->p = copy_elf_strings(bprm->envc,bprm->envp,bprm->page,bprm->p); bprm->p = copy_elf_strings(bprm->argc,bprm->argv,bprm->page,bprm->p); if (!bprm->p) { retval = -E2BIG; } elf_phdata = (struct elf_phdr *)malloc(elf_ex.e_phentsize*elf_ex.e_phnum); if (elf_phdata == NULL) { return -ENOMEM; } retval = lseek(bprm->fd, elf_ex.e_phoff, SEEK_SET); if(retval > 0) { retval = read(bprm->fd, (char *) elf_phdata, elf_ex.e_phentsize * elf_ex.e_phnum); } if (retval < 0) { perror("load_elf_binary"); exit(-1); free (elf_phdata); return -errno; } #ifdef BSWAP_NEEDED elf_ppnt = elf_phdata; for (i=0; i<elf_ex.e_phnum; i++, elf_ppnt++) { bswap_phdr(elf_ppnt); } #endif elf_ppnt = elf_phdata; elf_bss = 0; elf_brk = 0; elf_stack = ~((abi_ulong)0UL); elf_interpreter = NULL; start_code = ~((abi_ulong)0UL); end_code = 0; start_data = 0; end_data = 0; for(i=0;i < elf_ex.e_phnum; i++) { if (elf_ppnt->p_type == PT_INTERP) { if ( elf_interpreter != NULL ) { free (elf_phdata); free(elf_interpreter); close(bprm->fd); return -EINVAL; } elf_interpreter = (char *)malloc(elf_ppnt->p_filesz); if (elf_interpreter == NULL) { free (elf_phdata); close(bprm->fd); return -ENOMEM; } retval = lseek(bprm->fd, elf_ppnt->p_offset, SEEK_SET); if(retval >= 0) { retval = read(bprm->fd, elf_interpreter, elf_ppnt->p_filesz); } if(retval < 0) { perror("load_elf_binary2"); exit(-1); } if (strcmp(elf_interpreter,"/usr/lib/libc.so.1") == 0 || strcmp(elf_interpreter,"/usr/lib/ld.so.1") == 0) { ibcs2_interpreter = 1; } #if 0 printf("Using ELF interpreter %s\n", elf_interpreter); #endif if (retval >= 0) { retval = open(path(elf_interpreter), O_RDONLY); if(retval >= 0) { interpreter_fd = retval; } else { perror(elf_interpreter); exit(-1); } } if (retval >= 0) { retval = lseek(interpreter_fd, 0, SEEK_SET); if(retval >= 0) { retval = read(interpreter_fd,bprm->buf,128); } } if (retval >= 0) { interp_ex = *((struct exec *) bprm->buf); interp_elf_ex=*((struct elfhdr *) bprm->buf); } if (retval < 0) { perror("load_elf_binary3"); exit(-1); free (elf_phdata); free(elf_interpreter); close(bprm->fd); return retval; } } elf_ppnt++; } if (elf_interpreter){ interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) && (N_MAGIC(interp_ex) != QMAGIC)) { interpreter_type = INTERPRETER_ELF; } if (interp_elf_ex.e_ident[0] != 0x7f || strncmp((char *)&interp_elf_ex.e_ident[1], "ELF",3) != 0) { interpreter_type &= ~INTERPRETER_ELF; } if (!interpreter_type) { free(elf_interpreter); free(elf_phdata); close(bprm->fd); return -ELIBBAD; } } { char * passed_p; if (interpreter_type == INTERPRETER_AOUT) { snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd); passed_p = passed_fileno; if (elf_interpreter) { bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p); bprm->argc++; } } if (!bprm->p) { if (elf_interpreter) { free(elf_interpreter); } free (elf_phdata); close(bprm->fd); return -E2BIG; } } info->end_data = 0; info->end_code = 0; info->start_mmap = (abi_ulong)ELF_START_MMAP; info->mmap = 0; elf_entry = (abi_ulong) elf_ex.e_entry; info->rss = 0; bprm->p = setup_arg_pages(bprm->p, bprm, info); info->start_stack = bprm->p; for(i = 0, elf_ppnt = elf_phdata; i < elf_ex.e_phnum; i++, elf_ppnt++) { int elf_prot = 0; int elf_flags = 0; abi_ulong error; if (elf_ppnt->p_type != PT_LOAD) continue; if (elf_ppnt->p_flags & PF_R) elf_prot |= PROT_READ; if (elf_ppnt->p_flags & PF_W) elf_prot |= PROT_WRITE; if (elf_ppnt->p_flags & PF_X) elf_prot |= PROT_EXEC; elf_flags = MAP_PRIVATE | MAP_DENYWRITE; if (elf_ex.e_type == ET_EXEC || load_addr_set) { elf_flags |= MAP_FIXED; } else if (elf_ex.e_type == ET_DYN) { error = target_mmap(0, ET_DYN_MAP_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); exit(-1); } load_bias = TARGET_ELF_PAGESTART(error - elf_ppnt->p_vaddr); } error = target_mmap(TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr), (elf_ppnt->p_filesz + TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), bprm->fd, (elf_ppnt->p_offset - TARGET_ELF_PAGEOFFSET(elf_ppnt->p_vaddr))); if (error == -1) { perror("mmap"); exit(-1); } #ifdef LOW_ELF_STACK if (TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(elf_ppnt->p_vaddr); #endif if (!load_addr_set) { load_addr_set = 1; load_addr = elf_ppnt->p_vaddr - elf_ppnt->p_offset; if (elf_ex.e_type == ET_DYN) { load_bias += error - TARGET_ELF_PAGESTART(load_bias + elf_ppnt->p_vaddr); load_addr += load_bias; reloc_func_desc = load_bias; } } k = elf_ppnt->p_vaddr; if (k < start_code) start_code = k; if (start_data < k) start_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; if (k > elf_bss) elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) end_data = k; k = elf_ppnt->p_vaddr + elf_ppnt->p_memsz; if (k > elf_brk) elf_brk = k; } elf_entry += load_bias; elf_bss += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias; start_data += load_bias; end_data += load_bias; if (elf_interpreter) { if (interpreter_type & 1) { elf_entry = load_aout_interp(&interp_ex, interpreter_fd); } else if (interpreter_type & 2) { elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd, &interp_load_addr); } reloc_func_desc = interp_load_addr; close(interpreter_fd); free(elf_interpreter); if (elf_entry == ~((abi_ulong)0UL)) { printf("Unable to load interpreter\n"); free(elf_phdata); exit(-1); return 0; } } free(elf_phdata); if (loglevel) load_symbols(&elf_ex, bprm->fd); if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd); info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX); #ifdef LOW_ELF_STACK info->start_stack = bprm->p = elf_stack - 4; #endif bprm->p = create_elf_tables(bprm->p, bprm->argc, bprm->envc, &elf_ex, load_addr, load_bias, interp_load_addr, (interpreter_type == INTERPRETER_AOUT ? 0 : 1), info); info->load_addr = reloc_func_desc; info->start_brk = info->brk = elf_brk; info->end_code = end_code; info->start_code = start_code; info->start_data = start_data; info->end_data = end_data; info->start_stack = bprm->p; set_brk(elf_bss, elf_brk); padzero(elf_bss, elf_brk); #if 0 printf("(start_brk) %x\n" , info->start_brk); printf("(end_code) %x\n" , info->end_code); printf("(start_code) %x\n" , info->start_code); printf("(end_data) %x\n" , info->end_data); printf("(start_stack) %x\n" , info->start_stack); printf("(brk) %x\n" , info->brk); #endif if ( info->personality == PER_SVR4 ) { mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, -1, 0); } info->entry = elf_entry; return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(struct linux_binprm * VAR_0, struct target_pt_regs * VAR_1, struct image_info * VAR_2) { struct elfhdr VAR_3; struct elfhdr VAR_4; struct exec VAR_5; int VAR_6 = -1; abi_ulong load_addr, load_bias; int VAR_7 = 0; unsigned int VAR_8 = INTERPRETER_NONE; unsigned char VAR_9; int VAR_10; abi_ulong mapped_addr; struct elf_phdr * VAR_11; struct elf_phdr *VAR_12; abi_ulong elf_bss, k, elf_brk; int VAR_13; char * VAR_14; abi_ulong elf_entry, interp_load_addr = 0; int VAR_15; abi_ulong start_code, end_code, start_data, end_data; abi_ulong reloc_func_desc = 0; abi_ulong elf_stack; char VAR_16[6]; VAR_9 = 0; VAR_15 = 0; load_addr = 0; load_bias = 0; VAR_3 = *((struct elfhdr *) VAR_0->buf); #ifdef BSWAP_NEEDED bswap_ehdr(&VAR_3); #endif if ((VAR_3.e_type != ET_EXEC && VAR_3.e_type != ET_DYN) || (! elf_check_arch(VAR_3.e_machine))) { return -ENOEXEC; } VAR_0->p = copy_elf_strings(1, &VAR_0->filename, VAR_0->page, VAR_0->p); VAR_0->p = copy_elf_strings(VAR_0->envc,VAR_0->envp,VAR_0->page,VAR_0->p); VAR_0->p = copy_elf_strings(VAR_0->argc,VAR_0->argv,VAR_0->page,VAR_0->p); if (!VAR_0->p) { VAR_13 = -E2BIG; } VAR_12 = (struct elf_phdr *)malloc(VAR_3.e_phentsize*VAR_3.e_phnum); if (VAR_12 == NULL) { return -ENOMEM; } VAR_13 = lseek(VAR_0->fd, VAR_3.e_phoff, SEEK_SET); if(VAR_13 > 0) { VAR_13 = read(VAR_0->fd, (char *) VAR_12, VAR_3.e_phentsize * VAR_3.e_phnum); } if (VAR_13 < 0) { perror("FUNC_0"); exit(-1); free (VAR_12); return -errno; } #ifdef BSWAP_NEEDED VAR_11 = VAR_12; for (VAR_10=0; VAR_10<VAR_3.e_phnum; VAR_10++, VAR_11++) { bswap_phdr(VAR_11); } #endif VAR_11 = VAR_12; elf_bss = 0; elf_brk = 0; elf_stack = ~((abi_ulong)0UL); VAR_14 = NULL; start_code = ~((abi_ulong)0UL); end_code = 0; start_data = 0; end_data = 0; for(VAR_10=0;VAR_10 < VAR_3.e_phnum; VAR_10++) { if (VAR_11->p_type == PT_INTERP) { if ( VAR_14 != NULL ) { free (VAR_12); free(VAR_14); close(VAR_0->fd); return -EINVAL; } VAR_14 = (char *)malloc(VAR_11->p_filesz); if (VAR_14 == NULL) { free (VAR_12); close(VAR_0->fd); return -ENOMEM; } VAR_13 = lseek(VAR_0->fd, VAR_11->p_offset, SEEK_SET); if(VAR_13 >= 0) { VAR_13 = read(VAR_0->fd, VAR_14, VAR_11->p_filesz); } if(VAR_13 < 0) { perror("load_elf_binary2"); exit(-1); } if (strcmp(VAR_14,"/usr/lib/libc.so.1") == 0 || strcmp(VAR_14,"/usr/lib/ld.so.1") == 0) { VAR_9 = 1; } #if 0 printf("Using ELF interpreter %s\n", VAR_14); #endif if (VAR_13 >= 0) { VAR_13 = open(path(VAR_14), O_RDONLY); if(VAR_13 >= 0) { VAR_6 = VAR_13; } else { perror(VAR_14); exit(-1); } } if (VAR_13 >= 0) { VAR_13 = lseek(VAR_6, 0, SEEK_SET); if(VAR_13 >= 0) { VAR_13 = read(VAR_6,VAR_0->buf,128); } } if (VAR_13 >= 0) { VAR_5 = *((struct exec *) VAR_0->buf); VAR_4=*((struct elfhdr *) VAR_0->buf); } if (VAR_13 < 0) { perror("load_elf_binary3"); exit(-1); free (VAR_12); free(VAR_14); close(VAR_0->fd); return VAR_13; } } VAR_11++; } if (VAR_14){ VAR_8 = INTERPRETER_ELF | INTERPRETER_AOUT; if ((N_MAGIC(VAR_5) != OMAGIC) && (N_MAGIC(VAR_5) != ZMAGIC) && (N_MAGIC(VAR_5) != QMAGIC)) { VAR_8 = INTERPRETER_ELF; } if (VAR_4.e_ident[0] != 0x7f || strncmp((char *)&VAR_4.e_ident[1], "ELF",3) != 0) { VAR_8 &= ~INTERPRETER_ELF; } if (!VAR_8) { free(VAR_14); free(VAR_12); close(VAR_0->fd); return -ELIBBAD; } } { char * VAR_17; if (VAR_8 == INTERPRETER_AOUT) { snprintf(VAR_16, sizeof(VAR_16), "%d", VAR_0->fd); VAR_17 = VAR_16; if (VAR_14) { VAR_0->p = copy_elf_strings(1,&VAR_17,VAR_0->page,VAR_0->p); VAR_0->argc++; } } if (!VAR_0->p) { if (VAR_14) { free(VAR_14); } free (VAR_12); close(VAR_0->fd); return -E2BIG; } } VAR_2->end_data = 0; VAR_2->end_code = 0; VAR_2->start_mmap = (abi_ulong)ELF_START_MMAP; VAR_2->mmap = 0; elf_entry = (abi_ulong) VAR_3.e_entry; VAR_2->rss = 0; VAR_0->p = setup_arg_pages(VAR_0->p, VAR_0, VAR_2); VAR_2->start_stack = VAR_0->p; for(VAR_10 = 0, VAR_11 = VAR_12; VAR_10 < VAR_3.e_phnum; VAR_10++, VAR_11++) { int elf_prot = 0; int elf_flags = 0; abi_ulong error; if (VAR_11->p_type != PT_LOAD) continue; if (VAR_11->p_flags & PF_R) elf_prot |= PROT_READ; if (VAR_11->p_flags & PF_W) elf_prot |= PROT_WRITE; if (VAR_11->p_flags & PF_X) elf_prot |= PROT_EXEC; elf_flags = MAP_PRIVATE | MAP_DENYWRITE; if (VAR_3.e_type == ET_EXEC || VAR_7) { elf_flags |= MAP_FIXED; } else if (VAR_3.e_type == ET_DYN) { error = target_mmap(0, ET_DYN_MAP_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0); if (error == -1) { perror("mmap"); exit(-1); } load_bias = TARGET_ELF_PAGESTART(error - VAR_11->p_vaddr); } error = target_mmap(TARGET_ELF_PAGESTART(load_bias + VAR_11->p_vaddr), (VAR_11->p_filesz + TARGET_ELF_PAGEOFFSET(VAR_11->p_vaddr)), elf_prot, (MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE), VAR_0->fd, (VAR_11->p_offset - TARGET_ELF_PAGEOFFSET(VAR_11->p_vaddr))); if (error == -1) { perror("mmap"); exit(-1); } #ifdef LOW_ELF_STACK if (TARGET_ELF_PAGESTART(VAR_11->p_vaddr) < elf_stack) elf_stack = TARGET_ELF_PAGESTART(VAR_11->p_vaddr); #endif if (!VAR_7) { VAR_7 = 1; load_addr = VAR_11->p_vaddr - VAR_11->p_offset; if (VAR_3.e_type == ET_DYN) { load_bias += error - TARGET_ELF_PAGESTART(load_bias + VAR_11->p_vaddr); load_addr += load_bias; reloc_func_desc = load_bias; } } k = VAR_11->p_vaddr; if (k < start_code) start_code = k; if (start_data < k) start_data = k; k = VAR_11->p_vaddr + VAR_11->p_filesz; if (k > elf_bss) elf_bss = k; if ((VAR_11->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) end_data = k; k = VAR_11->p_vaddr + VAR_11->p_memsz; if (k > elf_brk) elf_brk = k; } elf_entry += load_bias; elf_bss += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias; start_data += load_bias; end_data += load_bias; if (VAR_14) { if (VAR_8 & 1) { elf_entry = load_aout_interp(&VAR_5, VAR_6); } else if (VAR_8 & 2) { elf_entry = load_elf_interp(&VAR_4, VAR_6, &interp_load_addr); } reloc_func_desc = interp_load_addr; close(VAR_6); free(VAR_14); if (elf_entry == ~((abi_ulong)0UL)) { printf("Unable to load interpreter\n"); free(VAR_12); exit(-1); return 0; } } free(VAR_12); if (loglevel) load_symbols(&VAR_3, VAR_0->fd); if (VAR_8 != INTERPRETER_AOUT) close(VAR_0->fd); VAR_2->personality = (VAR_9 ? PER_SVR4 : PER_LINUX); #ifdef LOW_ELF_STACK VAR_2->start_stack = VAR_0->p = elf_stack - 4; #endif VAR_0->p = create_elf_tables(VAR_0->p, VAR_0->argc, VAR_0->envc, &VAR_3, load_addr, load_bias, interp_load_addr, (VAR_8 == INTERPRETER_AOUT ? 0 : 1), VAR_2); VAR_2->load_addr = reloc_func_desc; VAR_2->start_brk = VAR_2->brk = elf_brk; VAR_2->end_code = end_code; VAR_2->start_code = start_code; VAR_2->start_data = start_data; VAR_2->end_data = end_data; VAR_2->start_stack = VAR_0->p; set_brk(elf_bss, elf_brk); padzero(elf_bss, elf_brk); #if 0 printf("(start_brk) %x\n" , VAR_2->start_brk); printf("(end_code) %x\n" , VAR_2->end_code); printf("(start_code) %x\n" , VAR_2->start_code); printf("(end_data) %x\n" , VAR_2->end_data); printf("(start_stack) %x\n" , VAR_2->start_stack); printf("(brk) %x\n" , VAR_2->brk); #endif if ( VAR_2->personality == PER_SVR4 ) { mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC, MAP_FIXED | MAP_PRIVATE, -1, 0); } VAR_2->entry = elf_entry; return 0; }
[ "int FUNC_0(struct linux_binprm * VAR_0, struct target_pt_regs * VAR_1,\nstruct image_info * VAR_2)\n{", "struct elfhdr VAR_3;", "struct elfhdr VAR_4;", "struct exec VAR_5;", "int VAR_6 = -1;", "abi_ulong load_addr, load_bias;", "int VAR_7 = 0;", "unsigned int VAR_8 = INTERPRETER_NONE;", "unsigned char VAR_9;", "int VAR_10;", "abi_ulong mapped_addr;", "struct elf_phdr * VAR_11;", "struct elf_phdr *VAR_12;", "abi_ulong elf_bss, k, elf_brk;", "int VAR_13;", "char * VAR_14;", "abi_ulong elf_entry, interp_load_addr = 0;", "int VAR_15;", "abi_ulong start_code, end_code, start_data, end_data;", "abi_ulong reloc_func_desc = 0;", "abi_ulong elf_stack;", "char VAR_16[6];", "VAR_9 = 0;", "VAR_15 = 0;", "load_addr = 0;", "load_bias = 0;", "VAR_3 = *((struct elfhdr *) VAR_0->buf);", "#ifdef BSWAP_NEEDED\nbswap_ehdr(&VAR_3);", "#endif\nif ((VAR_3.e_type != ET_EXEC && VAR_3.e_type != ET_DYN) ||\n(! elf_check_arch(VAR_3.e_machine))) {", "return -ENOEXEC;", "}", "VAR_0->p = copy_elf_strings(1, &VAR_0->filename, VAR_0->page, VAR_0->p);", "VAR_0->p = copy_elf_strings(VAR_0->envc,VAR_0->envp,VAR_0->page,VAR_0->p);", "VAR_0->p = copy_elf_strings(VAR_0->argc,VAR_0->argv,VAR_0->page,VAR_0->p);", "if (!VAR_0->p) {", "VAR_13 = -E2BIG;", "}", "VAR_12 = (struct elf_phdr *)malloc(VAR_3.e_phentsize*VAR_3.e_phnum);", "if (VAR_12 == NULL) {", "return -ENOMEM;", "}", "VAR_13 = lseek(VAR_0->fd, VAR_3.e_phoff, SEEK_SET);", "if(VAR_13 > 0) {", "VAR_13 = read(VAR_0->fd, (char *) VAR_12,\nVAR_3.e_phentsize * VAR_3.e_phnum);", "}", "if (VAR_13 < 0) {", "perror(\"FUNC_0\");", "exit(-1);", "free (VAR_12);", "return -errno;", "}", "#ifdef BSWAP_NEEDED\nVAR_11 = VAR_12;", "for (VAR_10=0; VAR_10<VAR_3.e_phnum; VAR_10++, VAR_11++) {", "bswap_phdr(VAR_11);", "}", "#endif\nVAR_11 = VAR_12;", "elf_bss = 0;", "elf_brk = 0;", "elf_stack = ~((abi_ulong)0UL);", "VAR_14 = NULL;", "start_code = ~((abi_ulong)0UL);", "end_code = 0;", "start_data = 0;", "end_data = 0;", "for(VAR_10=0;VAR_10 < VAR_3.e_phnum; VAR_10++) {", "if (VAR_11->p_type == PT_INTERP) {", "if ( VAR_14 != NULL )\n{", "free (VAR_12);", "free(VAR_14);", "close(VAR_0->fd);", "return -EINVAL;", "}", "VAR_14 = (char *)malloc(VAR_11->p_filesz);", "if (VAR_14 == NULL) {", "free (VAR_12);", "close(VAR_0->fd);", "return -ENOMEM;", "}", "VAR_13 = lseek(VAR_0->fd, VAR_11->p_offset, SEEK_SET);", "if(VAR_13 >= 0) {", "VAR_13 = read(VAR_0->fd, VAR_14, VAR_11->p_filesz);", "}", "if(VAR_13 < 0) {", "perror(\"load_elf_binary2\");", "exit(-1);", "}", "if (strcmp(VAR_14,\"/usr/lib/libc.so.1\") == 0 ||\nstrcmp(VAR_14,\"/usr/lib/ld.so.1\") == 0) {", "VAR_9 = 1;", "}", "#if 0\nprintf(\"Using ELF interpreter %s\\n\", VAR_14);", "#endif\nif (VAR_13 >= 0) {", "VAR_13 = open(path(VAR_14), O_RDONLY);", "if(VAR_13 >= 0) {", "VAR_6 = VAR_13;", "}", "else {", "perror(VAR_14);", "exit(-1);", "}", "}", "if (VAR_13 >= 0) {", "VAR_13 = lseek(VAR_6, 0, SEEK_SET);", "if(VAR_13 >= 0) {", "VAR_13 = read(VAR_6,VAR_0->buf,128);", "}", "}", "if (VAR_13 >= 0) {", "VAR_5 = *((struct exec *) VAR_0->buf);", "VAR_4=*((struct elfhdr *) VAR_0->buf);", "}", "if (VAR_13 < 0) {", "perror(\"load_elf_binary3\");", "exit(-1);", "free (VAR_12);", "free(VAR_14);", "close(VAR_0->fd);", "return VAR_13;", "}", "}", "VAR_11++;", "}", "if (VAR_14){", "VAR_8 = INTERPRETER_ELF | INTERPRETER_AOUT;", "if ((N_MAGIC(VAR_5) != OMAGIC) && (N_MAGIC(VAR_5) != ZMAGIC) &&\n(N_MAGIC(VAR_5) != QMAGIC)) {", "VAR_8 = INTERPRETER_ELF;", "}", "if (VAR_4.e_ident[0] != 0x7f ||\nstrncmp((char *)&VAR_4.e_ident[1], \"ELF\",3) != 0) {", "VAR_8 &= ~INTERPRETER_ELF;", "}", "if (!VAR_8) {", "free(VAR_14);", "free(VAR_12);", "close(VAR_0->fd);", "return -ELIBBAD;", "}", "}", "{", "char * VAR_17;", "if (VAR_8 == INTERPRETER_AOUT) {", "snprintf(VAR_16, sizeof(VAR_16), \"%d\", VAR_0->fd);", "VAR_17 = VAR_16;", "if (VAR_14) {", "VAR_0->p = copy_elf_strings(1,&VAR_17,VAR_0->page,VAR_0->p);", "VAR_0->argc++;", "}", "}", "if (!VAR_0->p) {", "if (VAR_14) {", "free(VAR_14);", "}", "free (VAR_12);", "close(VAR_0->fd);", "return -E2BIG;", "}", "}", "VAR_2->end_data = 0;", "VAR_2->end_code = 0;", "VAR_2->start_mmap = (abi_ulong)ELF_START_MMAP;", "VAR_2->mmap = 0;", "elf_entry = (abi_ulong) VAR_3.e_entry;", "VAR_2->rss = 0;", "VAR_0->p = setup_arg_pages(VAR_0->p, VAR_0, VAR_2);", "VAR_2->start_stack = VAR_0->p;", "for(VAR_10 = 0, VAR_11 = VAR_12; VAR_10 < VAR_3.e_phnum; VAR_10++, VAR_11++) {", "int elf_prot = 0;", "int elf_flags = 0;", "abi_ulong error;", "if (VAR_11->p_type != PT_LOAD)\ncontinue;", "if (VAR_11->p_flags & PF_R) elf_prot |= PROT_READ;", "if (VAR_11->p_flags & PF_W) elf_prot |= PROT_WRITE;", "if (VAR_11->p_flags & PF_X) elf_prot |= PROT_EXEC;", "elf_flags = MAP_PRIVATE | MAP_DENYWRITE;", "if (VAR_3.e_type == ET_EXEC || VAR_7) {", "elf_flags |= MAP_FIXED;", "} else if (VAR_3.e_type == ET_DYN) {", "error = target_mmap(0, ET_DYN_MAP_SIZE,\nPROT_NONE, MAP_PRIVATE | MAP_ANON,\n-1, 0);", "if (error == -1) {", "perror(\"mmap\");", "exit(-1);", "}", "load_bias = TARGET_ELF_PAGESTART(error - VAR_11->p_vaddr);", "}", "error = target_mmap(TARGET_ELF_PAGESTART(load_bias + VAR_11->p_vaddr),\n(VAR_11->p_filesz +\nTARGET_ELF_PAGEOFFSET(VAR_11->p_vaddr)),\nelf_prot,\n(MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE),\nVAR_0->fd,\n(VAR_11->p_offset -\nTARGET_ELF_PAGEOFFSET(VAR_11->p_vaddr)));", "if (error == -1) {", "perror(\"mmap\");", "exit(-1);", "}", "#ifdef LOW_ELF_STACK\nif (TARGET_ELF_PAGESTART(VAR_11->p_vaddr) < elf_stack)\nelf_stack = TARGET_ELF_PAGESTART(VAR_11->p_vaddr);", "#endif\nif (!VAR_7) {", "VAR_7 = 1;", "load_addr = VAR_11->p_vaddr - VAR_11->p_offset;", "if (VAR_3.e_type == ET_DYN) {", "load_bias += error -\nTARGET_ELF_PAGESTART(load_bias + VAR_11->p_vaddr);", "load_addr += load_bias;", "reloc_func_desc = load_bias;", "}", "}", "k = VAR_11->p_vaddr;", "if (k < start_code)\nstart_code = k;", "if (start_data < k)\nstart_data = k;", "k = VAR_11->p_vaddr + VAR_11->p_filesz;", "if (k > elf_bss)\nelf_bss = k;", "if ((VAR_11->p_flags & PF_X) && end_code < k)\nend_code = k;", "if (end_data < k)\nend_data = k;", "k = VAR_11->p_vaddr + VAR_11->p_memsz;", "if (k > elf_brk) elf_brk = k;", "}", "elf_entry += load_bias;", "elf_bss += load_bias;", "elf_brk += load_bias;", "start_code += load_bias;", "end_code += load_bias;", "start_data += load_bias;", "end_data += load_bias;", "if (VAR_14) {", "if (VAR_8 & 1) {", "elf_entry = load_aout_interp(&VAR_5, VAR_6);", "}", "else if (VAR_8 & 2) {", "elf_entry = load_elf_interp(&VAR_4, VAR_6,\n&interp_load_addr);", "}", "reloc_func_desc = interp_load_addr;", "close(VAR_6);", "free(VAR_14);", "if (elf_entry == ~((abi_ulong)0UL)) {", "printf(\"Unable to load interpreter\\n\");", "free(VAR_12);", "exit(-1);", "return 0;", "}", "}", "free(VAR_12);", "if (loglevel)\nload_symbols(&VAR_3, VAR_0->fd);", "if (VAR_8 != INTERPRETER_AOUT) close(VAR_0->fd);", "VAR_2->personality = (VAR_9 ? PER_SVR4 : PER_LINUX);", "#ifdef LOW_ELF_STACK\nVAR_2->start_stack = VAR_0->p = elf_stack - 4;", "#endif\nVAR_0->p = create_elf_tables(VAR_0->p,\nVAR_0->argc,\nVAR_0->envc,\n&VAR_3,\nload_addr, load_bias,\ninterp_load_addr,\n(VAR_8 == INTERPRETER_AOUT ? 0 : 1),\nVAR_2);", "VAR_2->load_addr = reloc_func_desc;", "VAR_2->start_brk = VAR_2->brk = elf_brk;", "VAR_2->end_code = end_code;", "VAR_2->start_code = start_code;", "VAR_2->start_data = start_data;", "VAR_2->end_data = end_data;", "VAR_2->start_stack = VAR_0->p;", "set_brk(elf_bss, elf_brk);", "padzero(elf_bss, elf_brk);", "#if 0\nprintf(\"(start_brk) %x\\n\" , VAR_2->start_brk);", "printf(\"(end_code) %x\\n\" , VAR_2->end_code);", "printf(\"(start_code) %x\\n\" , VAR_2->start_code);", "printf(\"(end_data) %x\\n\" , VAR_2->end_data);", "printf(\"(start_stack) %x\\n\" , VAR_2->start_stack);", "printf(\"(brk) %x\\n\" , VAR_2->brk);", "#endif\nif ( VAR_2->personality == PER_SVR4 )\n{", "mapped_addr = target_mmap(0, qemu_host_page_size, PROT_READ | PROT_EXEC,\nMAP_FIXED | MAP_PRIVATE, -1, 0);", "}", "VAR_2->entry = elf_entry;", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61, 63 ], [ 65, 71, 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 133, 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143, 145 ], [ 149 ], [ 151 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 172 ], [ 174 ], [ 176, 178 ], [ 180 ], [ 182 ], [ 184 ], [ 186 ], [ 188 ], [ 202 ], [ 206 ], [ 208 ], [ 210 ], [ 212 ], [ 214 ], [ 218 ], [ 220 ], [ 222 ], [ 224 ], [ 226 ], [ 228 ], [ 230 ], [ 232 ], [ 248, 250 ], [ 252 ], [ 254 ], [ 258, 260 ], [ 262, 264 ], [ 266 ], [ 268 ], [ 270 ], [ 272 ], [ 274 ], [ 276 ], [ 278 ], [ 282 ], [ 284 ], [ 288 ], [ 290 ], [ 292 ], [ 294 ], [ 296 ], [ 298 ], [ 300 ], [ 302 ], [ 304 ], [ 306 ], [ 308 ], [ 310 ], [ 312 ], [ 314 ], [ 316 ], [ 318 ], [ 320 ], [ 322 ], [ 324 ], [ 326 ], [ 328 ], [ 334 ], [ 336 ], [ 342, 344 ], [ 346 ], [ 348 ], [ 352, 354 ], [ 356 ], [ 358 ], [ 362 ], [ 364 ], [ 366 ], [ 368 ], [ 370 ], [ 372 ], [ 374 ], [ 384 ], [ 386 ], [ 390 ], [ 392 ], [ 394 ], [ 398 ], [ 400 ], [ 402 ], [ 404 ], [ 406 ], [ 408 ], [ 410 ], [ 412 ], [ 414 ], [ 416 ], [ 418 ], [ 420 ], [ 422 ], [ 424 ], [ 430 ], [ 432 ], [ 434 ], [ 436 ], [ 438 ], [ 446 ], [ 448 ], [ 450 ], [ 466 ], [ 468 ], [ 470 ], [ 472 ], [ 476, 478 ], [ 482 ], [ 484 ], [ 486 ], [ 488 ], [ 490 ], [ 492 ], [ 494 ], [ 506, 508, 510 ], [ 512 ], [ 514 ], [ 516 ], [ 518 ], [ 520 ], [ 522 ], [ 526, 528, 530, 532, 534, 536, 538, 540 ], [ 542 ], [ 544 ], [ 546 ], [ 548 ], [ 552, 554, 556 ], [ 558, 562 ], [ 564 ], [ 566 ], [ 568 ], [ 570, 572 ], [ 574 ], [ 576 ], [ 578 ], [ 580 ], [ 582 ], [ 584, 586 ], [ 588, 590 ], [ 592 ], [ 594, 596 ], [ 598, 600 ], [ 602, 604 ], [ 606 ], [ 608 ], [ 610 ], [ 614 ], [ 616 ], [ 618 ], [ 620 ], [ 622 ], [ 624 ], [ 626 ], [ 630 ], [ 632 ], [ 634 ], [ 636 ], [ 638 ], [ 640, 642 ], [ 644 ], [ 646 ], [ 650 ], [ 652 ], [ 656 ], [ 658 ], [ 660 ], [ 662 ], [ 664 ], [ 666 ], [ 668 ], [ 672 ], [ 676, 678 ], [ 682 ], [ 684 ], [ 688, 690 ], [ 692, 694, 696, 698, 700, 702, 704, 706, 708 ], [ 710 ], [ 712 ], [ 714 ], [ 716 ], [ 718 ], [ 720 ], [ 722 ], [ 730 ], [ 734 ], [ 738, 740 ], [ 742 ], [ 744 ], [ 746 ], [ 748 ], [ 750 ], [ 752, 756, 758 ], [ 768, 770 ], [ 772 ], [ 776 ], [ 780 ], [ 782 ] ]
5,969
static bool hyperv_enabled(X86CPU *cpu) { CPUState *cs = CPU(cpu); return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && (hyperv_hypercall_available(cpu) || cpu->hyperv_time || cpu->hyperv_relaxed_timing); }
true
qemu
f2a53c9e05a24352a0f9740db0539ce5aeed22ca
static bool hyperv_enabled(X86CPU *cpu) { CPUState *cs = CPU(cpu); return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && (hyperv_hypercall_available(cpu) || cpu->hyperv_time || cpu->hyperv_relaxed_timing); }
{ "code": [ " cpu->hyperv_relaxed_timing);" ], "line_no": [ 13 ] }
static bool FUNC_0(X86CPU *cpu) { CPUState *cs = CPU(cpu); return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && (hyperv_hypercall_available(cpu) || cpu->hyperv_time || cpu->hyperv_relaxed_timing); }
[ "static bool FUNC_0(X86CPU *cpu)\n{", "CPUState *cs = CPU(cpu);", "return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 &&\n(hyperv_hypercall_available(cpu) ||\ncpu->hyperv_time ||\ncpu->hyperv_relaxed_timing);", "}" ]
[ 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9, 11, 13 ], [ 15 ] ]
5,971
static void test_butterflies_float(const float *src0, const float *src1) { LOCAL_ALIGNED_16(float, cdst, [LEN]); LOCAL_ALIGNED_16(float, odst, [LEN]); LOCAL_ALIGNED_16(float, cdst1, [LEN]); LOCAL_ALIGNED_16(float, odst1, [LEN]); int i; declare_func(void, float *av_restrict src0, float *av_restrict src1, int len); memcpy(cdst, src0, LEN * sizeof(*src0)); memcpy(cdst1, src1, LEN * sizeof(*src1)); memcpy(odst, src0, LEN * sizeof(*src0)); memcpy(odst1, src1, LEN * sizeof(*src1)); call_ref(cdst, cdst1, LEN); call_new(odst, odst1, LEN); for (i = 0; i < LEN; i++) { if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) { fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", i, cdst[i], odst[i], cdst[i] - odst[i]); fail(); break; } } memcpy(odst, src0, LEN * sizeof(*src0)); memcpy(odst1, src1, LEN * sizeof(*src1)); bench_new(odst, odst1, LEN); }
false
FFmpeg
a579dbb4f7deee142d1bb6545a169c9fcaa467af
static void test_butterflies_float(const float *src0, const float *src1) { LOCAL_ALIGNED_16(float, cdst, [LEN]); LOCAL_ALIGNED_16(float, odst, [LEN]); LOCAL_ALIGNED_16(float, cdst1, [LEN]); LOCAL_ALIGNED_16(float, odst1, [LEN]); int i; declare_func(void, float *av_restrict src0, float *av_restrict src1, int len); memcpy(cdst, src0, LEN * sizeof(*src0)); memcpy(cdst1, src1, LEN * sizeof(*src1)); memcpy(odst, src0, LEN * sizeof(*src0)); memcpy(odst1, src1, LEN * sizeof(*src1)); call_ref(cdst, cdst1, LEN); call_new(odst, odst1, LEN); for (i = 0; i < LEN; i++) { if (!float_near_abs_eps(cdst[i], odst[i], FLT_EPSILON)) { fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", i, cdst[i], odst[i], cdst[i] - odst[i]); fail(); break; } } memcpy(odst, src0, LEN * sizeof(*src0)); memcpy(odst1, src1, LEN * sizeof(*src1)); bench_new(odst, odst1, LEN); }
{ "code": [], "line_no": [] }
static void FUNC_0(const float *VAR_0, const float *VAR_1) { LOCAL_ALIGNED_16(float, cdst, [LEN]); LOCAL_ALIGNED_16(float, odst, [LEN]); LOCAL_ALIGNED_16(float, cdst1, [LEN]); LOCAL_ALIGNED_16(float, odst1, [LEN]); int VAR_2; declare_func(void, float *av_restrict VAR_0, float *av_restrict VAR_1, int len); memcpy(cdst, VAR_0, LEN * sizeof(*VAR_0)); memcpy(cdst1, VAR_1, LEN * sizeof(*VAR_1)); memcpy(odst, VAR_0, LEN * sizeof(*VAR_0)); memcpy(odst1, VAR_1, LEN * sizeof(*VAR_1)); call_ref(cdst, cdst1, LEN); call_new(odst, odst1, LEN); for (VAR_2 = 0; VAR_2 < LEN; VAR_2++) { if (!float_near_abs_eps(cdst[VAR_2], odst[VAR_2], FLT_EPSILON)) { fprintf(stderr, "%d: %- .12f - %- .12f = % .12g\n", VAR_2, cdst[VAR_2], odst[VAR_2], cdst[VAR_2] - odst[VAR_2]); fail(); break; } } memcpy(odst, VAR_0, LEN * sizeof(*VAR_0)); memcpy(odst1, VAR_1, LEN * sizeof(*VAR_1)); bench_new(odst, odst1, LEN); }
[ "static void FUNC_0(const float *VAR_0, const float *VAR_1)\n{", "LOCAL_ALIGNED_16(float, cdst, [LEN]);", "LOCAL_ALIGNED_16(float, odst, [LEN]);", "LOCAL_ALIGNED_16(float, cdst1, [LEN]);", "LOCAL_ALIGNED_16(float, odst1, [LEN]);", "int VAR_2;", "declare_func(void, float *av_restrict VAR_0, float *av_restrict VAR_1,\nint len);", "memcpy(cdst, VAR_0, LEN * sizeof(*VAR_0));", "memcpy(cdst1, VAR_1, LEN * sizeof(*VAR_1));", "memcpy(odst, VAR_0, LEN * sizeof(*VAR_0));", "memcpy(odst1, VAR_1, LEN * sizeof(*VAR_1));", "call_ref(cdst, cdst1, LEN);", "call_new(odst, odst1, LEN);", "for (VAR_2 = 0; VAR_2 < LEN; VAR_2++) {", "if (!float_near_abs_eps(cdst[VAR_2], odst[VAR_2], FLT_EPSILON)) {", "fprintf(stderr, \"%d: %- .12f - %- .12f = % .12g\\n\",\nVAR_2, cdst[VAR_2], odst[VAR_2], cdst[VAR_2] - odst[VAR_2]);", "fail();", "break;", "}", "}", "memcpy(odst, VAR_0, LEN * sizeof(*VAR_0));", "memcpy(odst1, VAR_1, LEN * sizeof(*VAR_1));", "bench_new(odst, odst1, LEN);", "}" ]
[ 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 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
5,972
static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; int64_t left; AVStream *st; WAVDemuxContext *wav = s->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && s->streams[0]->codec->codec_tag == 1) { enum AVCodecID codec; ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, &codec); if (ret > AVPROBE_SCORE_EXTENSION) { s->streams[0]->codec->codec_id = codec; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(s, pkt); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = s->streams[0]->cur_dts; video_dts = s->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { /*We always return a video frame first to get the pixel format first*/ wav->smv_last_stream = wav->smv_given_first ? av_compare_ts(video_dts, s->streams[1]->time_base, audio_dts, s->streams[0]->time_base) > 0 : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(s->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { ret = AVERROR_EOF; goto smv_out; } size = avio_rl24(s->pb); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) goto smv_out; pkt->pos -= 3; pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; pkt->stream_index = 1; smv_out: avio_seek(s->pb, old_pos, SEEK_SET); if (ret == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return ret; } } st = s->streams[0]; left = wav->data_end - avio_tell(s->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(s->pb, ff_w64_guid_data) - 24; else left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(s->pb) + left; } size = MAX_SIZE; if (st->codec->block_align > 1) { if (size < st->codec->block_align) size = st->codec->block_align; size = (size / st->codec->block_align) * st->codec->block_align; } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; return ret; }
false
FFmpeg
dc2e4c2e532b80565f5fbacd3a24a6db7567c257
static int wav_read_packet(AVFormatContext *s, AVPacket *pkt) { int ret, size; int64_t left; AVStream *st; WAVDemuxContext *wav = s->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && s->streams[0]->codec->codec_tag == 1) { enum AVCodecID codec; ret = ff_spdif_probe(s->pb->buffer, s->pb->buf_end - s->pb->buffer, &codec); if (ret > AVPROBE_SCORE_EXTENSION) { s->streams[0]->codec->codec_id = codec; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(s, pkt); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = s->streams[0]->cur_dts; video_dts = s->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { wav->smv_last_stream = wav->smv_given_first ? av_compare_ts(video_dts, s->streams[1]->time_base, audio_dts, s->streams[0]->time_base) > 0 : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(s->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(s->pb, new_pos, SEEK_SET) < 0) { ret = AVERROR_EOF; goto smv_out; } size = avio_rl24(s->pb); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) goto smv_out; pkt->pos -= 3; pkt->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; pkt->stream_index = 1; smv_out: avio_seek(s->pb, old_pos, SEEK_SET); if (ret == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return ret; } } st = s->streams[0]; left = wav->data_end - avio_tell(s->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(s->pb, ff_w64_guid_data) - 24; else left = find_tag(s->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(s->pb) + left; } size = MAX_SIZE; if (st->codec->block_align > 1) { if (size < st->codec->block_align) size = st->codec->block_align; size = (size / st->codec->block_align) * st->codec->block_align; } size = FFMIN(size, left); ret = av_get_packet(s->pb, pkt, size); if (ret < 0) return ret; pkt->stream_index = 0; return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1) { int VAR_2, VAR_3; int64_t left; AVStream *st; WAVDemuxContext *wav = VAR_0->priv_data; if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 && VAR_0->streams[0]->VAR_4->codec_tag == 1) { enum AVCodecID VAR_4; VAR_2 = ff_spdif_probe(VAR_0->pb->buffer, VAR_0->pb->buf_end - VAR_0->pb->buffer, &VAR_4); if (VAR_2 > AVPROBE_SCORE_EXTENSION) { VAR_0->streams[0]->VAR_4->codec_id = VAR_4; wav->spdif = 1; } else { wav->spdif = -1; } } if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1) return ff_spdif_read_packet(VAR_0, VAR_1); if (wav->smv_data_ofs > 0) { int64_t audio_dts, video_dts; smv_retry: audio_dts = VAR_0->streams[0]->cur_dts; video_dts = VAR_0->streams[1]->cur_dts; if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) { wav->smv_last_stream = wav->smv_given_first ? av_compare_ts(video_dts, VAR_0->streams[1]->time_base, audio_dts, VAR_0->streams[0]->time_base) > 0 : 0; wav->smv_given_first = 1; } wav->smv_last_stream = !wav->smv_last_stream; wav->smv_last_stream |= wav->audio_eof; wav->smv_last_stream &= !wav->smv_eof; if (wav->smv_last_stream) { uint64_t old_pos = avio_tell(VAR_0->pb); uint64_t new_pos = wav->smv_data_ofs + wav->smv_block * wav->smv_block_size; if (avio_seek(VAR_0->pb, new_pos, SEEK_SET) < 0) { VAR_2 = AVERROR_EOF; goto smv_out; } VAR_3 = avio_rl24(VAR_0->pb); VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3); if (VAR_2 < 0) goto smv_out; VAR_1->pos -= 3; VAR_1->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt; wav->smv_cur_pt++; if (wav->smv_frames_per_jpeg > 0) wav->smv_cur_pt %= wav->smv_frames_per_jpeg; if (!wav->smv_cur_pt) wav->smv_block++; VAR_1->stream_index = 1; smv_out: avio_seek(VAR_0->pb, old_pos, SEEK_SET); if (VAR_2 == AVERROR_EOF) { wav->smv_eof = 1; goto smv_retry; } return VAR_2; } } st = VAR_0->streams[0]; left = wav->data_end - avio_tell(VAR_0->pb); if (wav->ignore_length) left = INT_MAX; if (left <= 0) { if (CONFIG_W64_DEMUXER && wav->w64) left = find_guid(VAR_0->pb, ff_w64_guid_data) - 24; else left = find_tag(VAR_0->pb, MKTAG('d', 'a', 't', 'a')); if (left < 0) { wav->audio_eof = 1; if (wav->smv_data_ofs > 0 && !wav->smv_eof) goto smv_retry; return AVERROR_EOF; } wav->data_end = avio_tell(VAR_0->pb) + left; } VAR_3 = MAX_SIZE; if (st->VAR_4->block_align > 1) { if (VAR_3 < st->VAR_4->block_align) VAR_3 = st->VAR_4->block_align; VAR_3 = (VAR_3 / st->VAR_4->block_align) * st->VAR_4->block_align; } VAR_3 = FFMIN(VAR_3, left); VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3); if (VAR_2 < 0) return VAR_2; VAR_1->stream_index = 0; return VAR_2; }
[ "static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1)\n{", "int VAR_2, VAR_3;", "int64_t left;", "AVStream *st;", "WAVDemuxContext *wav = VAR_0->priv_data;", "if (CONFIG_SPDIF_DEMUXER && wav->spdif == 0 &&\nVAR_0->streams[0]->VAR_4->codec_tag == 1) {", "enum AVCodecID VAR_4;", "VAR_2 = ff_spdif_probe(VAR_0->pb->buffer, VAR_0->pb->buf_end - VAR_0->pb->buffer,\n&VAR_4);", "if (VAR_2 > AVPROBE_SCORE_EXTENSION) {", "VAR_0->streams[0]->VAR_4->codec_id = VAR_4;", "wav->spdif = 1;", "} else {", "wav->spdif = -1;", "}", "}", "if (CONFIG_SPDIF_DEMUXER && wav->spdif == 1)\nreturn ff_spdif_read_packet(VAR_0, VAR_1);", "if (wav->smv_data_ofs > 0) {", "int64_t audio_dts, video_dts;", "smv_retry:\naudio_dts = VAR_0->streams[0]->cur_dts;", "video_dts = VAR_0->streams[1]->cur_dts;", "if (audio_dts != AV_NOPTS_VALUE && video_dts != AV_NOPTS_VALUE) {", "wav->smv_last_stream = wav->smv_given_first ?\nav_compare_ts(video_dts, VAR_0->streams[1]->time_base,\naudio_dts, VAR_0->streams[0]->time_base) > 0 : 0;", "wav->smv_given_first = 1;", "}", "wav->smv_last_stream = !wav->smv_last_stream;", "wav->smv_last_stream |= wav->audio_eof;", "wav->smv_last_stream &= !wav->smv_eof;", "if (wav->smv_last_stream) {", "uint64_t old_pos = avio_tell(VAR_0->pb);", "uint64_t new_pos = wav->smv_data_ofs +\nwav->smv_block * wav->smv_block_size;", "if (avio_seek(VAR_0->pb, new_pos, SEEK_SET) < 0) {", "VAR_2 = AVERROR_EOF;", "goto smv_out;", "}", "VAR_3 = avio_rl24(VAR_0->pb);", "VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);", "if (VAR_2 < 0)\ngoto smv_out;", "VAR_1->pos -= 3;", "VAR_1->pts = wav->smv_block * wav->smv_frames_per_jpeg + wav->smv_cur_pt;", "wav->smv_cur_pt++;", "if (wav->smv_frames_per_jpeg > 0)\nwav->smv_cur_pt %= wav->smv_frames_per_jpeg;", "if (!wav->smv_cur_pt)\nwav->smv_block++;", "VAR_1->stream_index = 1;", "smv_out:\navio_seek(VAR_0->pb, old_pos, SEEK_SET);", "if (VAR_2 == AVERROR_EOF) {", "wav->smv_eof = 1;", "goto smv_retry;", "}", "return VAR_2;", "}", "}", "st = VAR_0->streams[0];", "left = wav->data_end - avio_tell(VAR_0->pb);", "if (wav->ignore_length)\nleft = INT_MAX;", "if (left <= 0) {", "if (CONFIG_W64_DEMUXER && wav->w64)\nleft = find_guid(VAR_0->pb, ff_w64_guid_data) - 24;", "else\nleft = find_tag(VAR_0->pb, MKTAG('d', 'a', 't', 'a'));", "if (left < 0) {", "wav->audio_eof = 1;", "if (wav->smv_data_ofs > 0 && !wav->smv_eof)\ngoto smv_retry;", "return AVERROR_EOF;", "}", "wav->data_end = avio_tell(VAR_0->pb) + left;", "}", "VAR_3 = MAX_SIZE;", "if (st->VAR_4->block_align > 1) {", "if (VAR_3 < st->VAR_4->block_align)\nVAR_3 = st->VAR_4->block_align;", "VAR_3 = (VAR_3 / st->VAR_4->block_align) * st->VAR_4->block_align;", "}", "VAR_3 = FFMIN(VAR_3, left);", "VAR_2 = av_get_packet(VAR_0->pb, VAR_1, VAR_3);", "if (VAR_2 < 0)\nreturn VAR_2;", "VAR_1->stream_index = 0;", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 57 ], [ 61, 63, 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81, 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97, 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107, 109 ], [ 111, 113 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151, 153 ], [ 155, 157 ], [ 159 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177 ], [ 179 ], [ 181, 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193, 195 ], [ 197 ], [ 201 ], [ 203 ] ]
5,973
int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title) { AVChapter *chapter = NULL; int i; for(i=0; i<s->num_chapters; i++) if(s->chapters[i]->id == id) chapter = s->chapters[i]; if(!chapter){ chapter= av_mallocz(sizeof(AVChapter)); if(!chapter) return AVERROR(ENOMEM); dynarray_add(&s->chapters, &s->num_chapters, chapter); } if(chapter->title) av_free(chapter->title); if (title) chapter->title = av_strdup(title); chapter->id = id; chapter->start = start; chapter->end = end; return 0; }
false
FFmpeg
0dac708e2d31898ebccacdb5911b5496b1616989
int ff_new_chapter(AVFormatContext *s, int id, int64_t start, int64_t end, const char *title) { AVChapter *chapter = NULL; int i; for(i=0; i<s->num_chapters; i++) if(s->chapters[i]->id == id) chapter = s->chapters[i]; if(!chapter){ chapter= av_mallocz(sizeof(AVChapter)); if(!chapter) return AVERROR(ENOMEM); dynarray_add(&s->chapters, &s->num_chapters, chapter); } if(chapter->title) av_free(chapter->title); if (title) chapter->title = av_strdup(title); chapter->id = id; chapter->start = start; chapter->end = end; return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int64_t VAR_3, const char *VAR_4) { AVChapter *chapter = NULL; int VAR_5; for(VAR_5=0; VAR_5<VAR_0->num_chapters; VAR_5++) if(VAR_0->chapters[VAR_5]->VAR_1 == VAR_1) chapter = VAR_0->chapters[VAR_5]; if(!chapter){ chapter= av_mallocz(sizeof(AVChapter)); if(!chapter) return AVERROR(ENOMEM); dynarray_add(&VAR_0->chapters, &VAR_0->num_chapters, chapter); } if(chapter->VAR_4) av_free(chapter->VAR_4); if (VAR_4) chapter->VAR_4 = av_strdup(VAR_4); chapter->VAR_1 = VAR_1; chapter->VAR_2 = VAR_2; chapter->VAR_3 = VAR_3; return 0; }
[ "int FUNC_0(AVFormatContext *VAR_0, int VAR_1, int64_t VAR_2, int64_t VAR_3, const char *VAR_4)\n{", "AVChapter *chapter = NULL;", "int VAR_5;", "for(VAR_5=0; VAR_5<VAR_0->num_chapters; VAR_5++)", "if(VAR_0->chapters[VAR_5]->VAR_1 == VAR_1)\nchapter = VAR_0->chapters[VAR_5];", "if(!chapter){", "chapter= av_mallocz(sizeof(AVChapter));", "if(!chapter)\nreturn AVERROR(ENOMEM);", "dynarray_add(&VAR_0->chapters, &VAR_0->num_chapters, chapter);", "}", "if(chapter->VAR_4)\nav_free(chapter->VAR_4);", "if (VAR_4)\nchapter->VAR_4 = av_strdup(VAR_4);", "chapter->VAR_1 = VAR_1;", "chapter->VAR_2 = VAR_2;", "chapter->VAR_3 = VAR_3;", "return 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 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31, 33 ], [ 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ] ]
5,974
static int flic_decode_frame_8BPP(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf, int buf_size) { FlicDecodeContext *s = avctx->priv_data; GetByteContext g2; int pixel_ptr; int palette_ptr; unsigned char palette_idx1; unsigned char palette_idx2; unsigned int frame_size; int num_chunks; unsigned int chunk_size; int chunk_type; int i, j, ret; int color_packets; int color_changes; int color_shift; unsigned char r, g, b; int lines; int compressed_lines; int starting_line; signed short line_packets; int y_ptr; int byte_run; int pixel_skip; int pixel_countdown; unsigned char *pixels; unsigned int pixel_limit; bytestream2_init(&g2, buf, buf_size); if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) return ret; pixels = s->frame.data[0]; pixel_limit = s->avctx->height * s->frame.linesize[0]; if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE)) return AVERROR_INVALIDDATA; frame_size = bytestream2_get_le32(&g2); if (frame_size > buf_size) frame_size = buf_size; bytestream2_skip(&g2, 2); /* skip the magic number */ num_chunks = bytestream2_get_le16(&g2); bytestream2_skip(&g2, 8); /* skip padding */ frame_size -= 16; /* iterate through the chunks */ while ((frame_size >= 6) && (num_chunks > 0)) { int stream_ptr_after_chunk; chunk_size = bytestream2_get_le32(&g2); if (chunk_size > frame_size) { av_log(avctx, AV_LOG_WARNING, "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); chunk_size = frame_size; } stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size; chunk_type = bytestream2_get_le16(&g2); switch (chunk_type) { case FLI_256_COLOR: case FLI_COLOR: /* check special case: If this file is from the Magic Carpet * game and uses 6-bit colors even though it reports 256-color * chunks in a 0xAF12-type file (fli_type is set to 0xAF13 during * initialization) */ if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE)) color_shift = 0; else color_shift = 2; /* set up the palette */ color_packets = bytestream2_get_le16(&g2); palette_ptr = 0; for (i = 0; i < color_packets; i++) { /* first byte is how many colors to skip */ palette_ptr += bytestream2_get_byte(&g2); /* next byte indicates how many entries to change */ color_changes = bytestream2_get_byte(&g2); /* if there are 0 color changes, there are actually 256 */ if (color_changes == 0) color_changes = 256; if (bytestream2_tell(&g2) + color_changes * 3 > stream_ptr_after_chunk) break; for (j = 0; j < color_changes; j++) { unsigned int entry; /* wrap around, for good measure */ if ((unsigned)palette_ptr >= 256) palette_ptr = 0; r = bytestream2_get_byte(&g2) << color_shift; g = bytestream2_get_byte(&g2) << color_shift; b = bytestream2_get_byte(&g2) << color_shift; entry = 0xFFU << 24 | r << 16 | g << 8 | b; if (color_shift == 2) entry |= entry >> 6 & 0x30303; if (s->palette[palette_ptr] != entry) s->new_palette = 1; s->palette[palette_ptr++] = entry; } } break; case FLI_DELTA: y_ptr = 0; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_le16(&g2); if ((line_packets & 0xC000) == 0xC000) { // line skip opcode line_packets = -line_packets; y_ptr += line_packets * s->frame.linesize[0]; } else if ((line_packets & 0xC000) == 0x4000) { av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets); } else if ((line_packets & 0xC000) == 0x8000) { // "last byte" opcode pixel_ptr= y_ptr + s->frame.linesize[0] - 1; CHECK_PIXEL_PTR(0); pixels[pixel_ptr] = line_packets & 0xff; } else { compressed_lines--; pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; /* account for the skip bytes */ pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += pixel_skip; pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run < 0) { byte_run = -byte_run; palette_idx1 = bytestream2_get_byte(&g2); palette_idx2 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run * 2); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { pixels[pixel_ptr++] = palette_idx1; pixels[pixel_ptr++] = palette_idx2; } } else { CHECK_PIXEL_PTR(byte_run * 2); if (bytestream2_tell(&g2) + byte_run * 2 > stream_ptr_after_chunk) break; for (j = 0; j < byte_run * 2; j++, pixel_countdown--) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); } } } y_ptr += s->frame.linesize[0]; } } break; case FLI_LC: /* line compressed */ starting_line = bytestream2_get_le16(&g2); y_ptr = 0; y_ptr += starting_line * s->frame.linesize[0]; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_byte(&g2); if (line_packets > 0) { for (i = 0; i < line_packets; i++) { /* account for the skip bytes */ if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += pixel_skip; pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2),8); if (byte_run > 0) { CHECK_PIXEL_PTR(byte_run); if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; for (j = 0; j < byte_run; j++, pixel_countdown--) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); } } else if (byte_run < 0) { byte_run = -byte_run; palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { pixels[pixel_ptr++] = palette_idx1; } } } } y_ptr += s->frame.linesize[0]; compressed_lines--; } break; case FLI_BLACK: /* set the whole frame to color 0 (which is usually black) */ memset(pixels, 0, s->frame.linesize[0] * s->avctx->height); break; case FLI_BRUN: /* Byte run compression: This chunk type only occurs in the first * FLI frame and it will update the entire frame. */ y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; /* disregard the line packets; instead, iterate through all * pixels on a row */ bytestream2_skip(&g2, 1); pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (!byte_run) { av_log(avctx, AV_LOG_ERROR, "Invalid byte run value.\n"); return AVERROR_INVALIDDATA; } if (byte_run > 0) { palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } else { /* copy bytes if byte_run < 0 */ byte_run = -byte_run; CHECK_PIXEL_PTR(byte_run); if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } } y_ptr += s->frame.linesize[0]; } break; case FLI_COPY: /* copy the chunk (uncompressed frame) */ if (chunk_size - 6 != s->avctx->width * s->avctx->height) { av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ "has incorrect size, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; y_ptr += s->frame.linesize[0]) { bytestream2_get_buffer(&g2, &pixels[y_ptr], s->avctx->width); } } break; case FLI_MINI: /* some sort of a thumbnail? disregard this chunk... */ break; default: av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); break; } if (stream_ptr_after_chunk - bytestream2_tell(&g2) > 0) bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2)); frame_size -= chunk_size; num_chunks--; } /* by the end of the chunk, the stream ptr should equal the frame * size (minus 1 or 2, possibly); if it doesn't, issue a warning */ if (bytestream2_get_bytes_left(&g2) > 2) av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", buf_size, buf_size - bytestream2_get_bytes_left(&g2)); /* make the palette available on the way out */ memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if (s->new_palette) { s->frame.palette_has_changed = 1; s->new_palette = 0; } if ((ret = av_frame_ref(data, &s->frame)) < 0) return ret; *got_frame = 1; return buf_size; }
false
FFmpeg
f5498ef38daa541f03b9c8d3985579394c8407e5
static int flic_decode_frame_8BPP(AVCodecContext *avctx, void *data, int *got_frame, const uint8_t *buf, int buf_size) { FlicDecodeContext *s = avctx->priv_data; GetByteContext g2; int pixel_ptr; int palette_ptr; unsigned char palette_idx1; unsigned char palette_idx2; unsigned int frame_size; int num_chunks; unsigned int chunk_size; int chunk_type; int i, j, ret; int color_packets; int color_changes; int color_shift; unsigned char r, g, b; int lines; int compressed_lines; int starting_line; signed short line_packets; int y_ptr; int byte_run; int pixel_skip; int pixel_countdown; unsigned char *pixels; unsigned int pixel_limit; bytestream2_init(&g2, buf, buf_size); if ((ret = ff_reget_buffer(avctx, &s->frame)) < 0) return ret; pixels = s->frame.data[0]; pixel_limit = s->avctx->height * s->frame.linesize[0]; if (buf_size < 16 || buf_size > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE)) return AVERROR_INVALIDDATA; frame_size = bytestream2_get_le32(&g2); if (frame_size > buf_size) frame_size = buf_size; bytestream2_skip(&g2, 2); num_chunks = bytestream2_get_le16(&g2); bytestream2_skip(&g2, 8); frame_size -= 16; while ((frame_size >= 6) && (num_chunks > 0)) { int stream_ptr_after_chunk; chunk_size = bytestream2_get_le32(&g2); if (chunk_size > frame_size) { av_log(avctx, AV_LOG_WARNING, "Invalid chunk_size = %u > frame_size = %u\n", chunk_size, frame_size); chunk_size = frame_size; } stream_ptr_after_chunk = bytestream2_tell(&g2) - 4 + chunk_size; chunk_type = bytestream2_get_le16(&g2); switch (chunk_type) { case FLI_256_COLOR: case FLI_COLOR: if ((chunk_type == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE)) color_shift = 0; else color_shift = 2; color_packets = bytestream2_get_le16(&g2); palette_ptr = 0; for (i = 0; i < color_packets; i++) { palette_ptr += bytestream2_get_byte(&g2); color_changes = bytestream2_get_byte(&g2); if (color_changes == 0) color_changes = 256; if (bytestream2_tell(&g2) + color_changes * 3 > stream_ptr_after_chunk) break; for (j = 0; j < color_changes; j++) { unsigned int entry; if ((unsigned)palette_ptr >= 256) palette_ptr = 0; r = bytestream2_get_byte(&g2) << color_shift; g = bytestream2_get_byte(&g2) << color_shift; b = bytestream2_get_byte(&g2) << color_shift; entry = 0xFFU << 24 | r << 16 | g << 8 | b; if (color_shift == 2) entry |= entry >> 6 & 0x30303; if (s->palette[palette_ptr] != entry) s->new_palette = 1; s->palette[palette_ptr++] = entry; } } break; case FLI_DELTA: y_ptr = 0; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_le16(&g2); if ((line_packets & 0xC000) == 0xC000) { line_packets = -line_packets; y_ptr += line_packets * s->frame.linesize[0]; } else if ((line_packets & 0xC000) == 0x4000) { av_log(avctx, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", line_packets); } else if ((line_packets & 0xC000) == 0x8000) { pixel_ptr= y_ptr + s->frame.linesize[0] - 1; CHECK_PIXEL_PTR(0); pixels[pixel_ptr] = line_packets & 0xff; } else { compressed_lines--; pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; for (i = 0; i < line_packets; i++) { if (bytestream2_tell(&g2) + 2 > stream_ptr_after_chunk) break; pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += pixel_skip; pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (byte_run < 0) { byte_run = -byte_run; palette_idx1 = bytestream2_get_byte(&g2); palette_idx2 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run * 2); for (j = 0; j < byte_run; j++, pixel_countdown -= 2) { pixels[pixel_ptr++] = palette_idx1; pixels[pixel_ptr++] = palette_idx2; } } else { CHECK_PIXEL_PTR(byte_run * 2); if (bytestream2_tell(&g2) + byte_run * 2 > stream_ptr_after_chunk) break; for (j = 0; j < byte_run * 2; j++, pixel_countdown--) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); } } } y_ptr += s->frame.linesize[0]; } } break; case FLI_LC: starting_line = bytestream2_get_le16(&g2); y_ptr = 0; y_ptr += starting_line * s->frame.linesize[0]; compressed_lines = bytestream2_get_le16(&g2); while (compressed_lines > 0) { pixel_ptr = y_ptr; CHECK_PIXEL_PTR(0); pixel_countdown = s->avctx->width; if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; line_packets = bytestream2_get_byte(&g2); if (line_packets > 0) { for (i = 0; i < line_packets; i++) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; pixel_skip = bytestream2_get_byte(&g2); pixel_ptr += pixel_skip; pixel_countdown -= pixel_skip; byte_run = sign_extend(bytestream2_get_byte(&g2),8); if (byte_run > 0) { CHECK_PIXEL_PTR(byte_run); if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; for (j = 0; j < byte_run; j++, pixel_countdown--) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); } } else if (byte_run < 0) { byte_run = -byte_run; palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++, pixel_countdown--) { pixels[pixel_ptr++] = palette_idx1; } } } } y_ptr += s->frame.linesize[0]; compressed_lines--; } break; case FLI_BLACK: memset(pixels, 0, s->frame.linesize[0] * s->avctx->height); break; case FLI_BRUN: y_ptr = 0; for (lines = 0; lines < s->avctx->height; lines++) { pixel_ptr = y_ptr; bytestream2_skip(&g2, 1); pixel_countdown = s->avctx->width; while (pixel_countdown > 0) { if (bytestream2_tell(&g2) + 1 > stream_ptr_after_chunk) break; byte_run = sign_extend(bytestream2_get_byte(&g2), 8); if (!byte_run) { av_log(avctx, AV_LOG_ERROR, "Invalid byte run value.\n"); return AVERROR_INVALIDDATA; } if (byte_run > 0) { palette_idx1 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(byte_run); for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = palette_idx1; pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } else { byte_run = -byte_run; CHECK_PIXEL_PTR(byte_run); if (bytestream2_tell(&g2) + byte_run > stream_ptr_after_chunk) break; for (j = 0; j < byte_run; j++) { pixels[pixel_ptr++] = bytestream2_get_byte(&g2); pixel_countdown--; if (pixel_countdown < 0) av_log(avctx, AV_LOG_ERROR, "pixel_countdown < 0 (%d) at line %d\n", pixel_countdown, lines); } } } y_ptr += s->frame.linesize[0]; } break; case FLI_COPY: if (chunk_size - 6 != s->avctx->width * s->avctx->height) { av_log(avctx, AV_LOG_ERROR, "In chunk FLI_COPY : source data (%d bytes) " \ "has incorrect size, skipping chunk\n", chunk_size - 6); bytestream2_skip(&g2, chunk_size - 6); } else { for (y_ptr = 0; y_ptr < s->frame.linesize[0] * s->avctx->height; y_ptr += s->frame.linesize[0]) { bytestream2_get_buffer(&g2, &pixels[y_ptr], s->avctx->width); } } break; case FLI_MINI: break; default: av_log(avctx, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", chunk_type); break; } if (stream_ptr_after_chunk - bytestream2_tell(&g2) > 0) bytestream2_skip(&g2, stream_ptr_after_chunk - bytestream2_tell(&g2)); frame_size -= chunk_size; num_chunks--; } if (bytestream2_get_bytes_left(&g2) > 2) av_log(avctx, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", buf_size, buf_size - bytestream2_get_bytes_left(&g2)); memcpy(s->frame.data[1], s->palette, AVPALETTE_SIZE); if (s->new_palette) { s->frame.palette_has_changed = 1; s->new_palette = 0; } if ((ret = av_frame_ref(data, &s->frame)) < 0) return ret; *got_frame = 1; return buf_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) { FlicDecodeContext *s = VAR_0->priv_data; GetByteContext g2; int VAR_5; int VAR_6; unsigned char VAR_7; unsigned char VAR_8; unsigned int VAR_9; int VAR_10; unsigned int VAR_11; int VAR_12; int VAR_13, VAR_14, VAR_15; int VAR_16; int VAR_17; int VAR_18; unsigned char VAR_19, VAR_20, VAR_21; int VAR_22; int VAR_23; int VAR_24; signed short VAR_25; int VAR_26; int VAR_27; int VAR_28; int VAR_29; unsigned char *VAR_30; unsigned int VAR_31; bytestream2_init(&g2, VAR_3, VAR_4); if ((VAR_15 = ff_reget_buffer(VAR_0, &s->frame)) < 0) return VAR_15; VAR_30 = s->frame.VAR_1[0]; VAR_31 = s->VAR_0->height * s->frame.linesize[0]; if (VAR_4 < 16 || VAR_4 > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE)) return AVERROR_INVALIDDATA; VAR_9 = bytestream2_get_le32(&g2); if (VAR_9 > VAR_4) VAR_9 = VAR_4; bytestream2_skip(&g2, 2); VAR_10 = bytestream2_get_le16(&g2); bytestream2_skip(&g2, 8); VAR_9 -= 16; while ((VAR_9 >= 6) && (VAR_10 > 0)) { int VAR_32; VAR_11 = bytestream2_get_le32(&g2); if (VAR_11 > VAR_9) { av_log(VAR_0, AV_LOG_WARNING, "Invalid VAR_11 = %u > VAR_9 = %u\n", VAR_11, VAR_9); VAR_11 = VAR_9; } VAR_32 = bytestream2_tell(&g2) - 4 + VAR_11; VAR_12 = bytestream2_get_le16(&g2); switch (VAR_12) { case FLI_256_COLOR: case FLI_COLOR: if ((VAR_12 == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE)) VAR_18 = 0; else VAR_18 = 2; VAR_16 = bytestream2_get_le16(&g2); VAR_6 = 0; for (VAR_13 = 0; VAR_13 < VAR_16; VAR_13++) { VAR_6 += bytestream2_get_byte(&g2); VAR_17 = bytestream2_get_byte(&g2); if (VAR_17 == 0) VAR_17 = 256; if (bytestream2_tell(&g2) + VAR_17 * 3 > VAR_32) break; for (VAR_14 = 0; VAR_14 < VAR_17; VAR_14++) { unsigned int VAR_33; if ((unsigned)VAR_6 >= 256) VAR_6 = 0; VAR_19 = bytestream2_get_byte(&g2) << VAR_18; VAR_20 = bytestream2_get_byte(&g2) << VAR_18; VAR_21 = bytestream2_get_byte(&g2) << VAR_18; VAR_33 = 0xFFU << 24 | VAR_19 << 16 | VAR_20 << 8 | VAR_21; if (VAR_18 == 2) VAR_33 |= VAR_33 >> 6 & 0x30303; if (s->palette[VAR_6] != VAR_33) s->new_palette = 1; s->palette[VAR_6++] = VAR_33; } } break; case FLI_DELTA: VAR_26 = 0; VAR_23 = bytestream2_get_le16(&g2); while (VAR_23 > 0) { if (bytestream2_tell(&g2) + 2 > VAR_32) break; VAR_25 = bytestream2_get_le16(&g2); if ((VAR_25 & 0xC000) == 0xC000) { VAR_25 = -VAR_25; VAR_26 += VAR_25 * s->frame.linesize[0]; } else if ((VAR_25 & 0xC000) == 0x4000) { av_log(VAR_0, AV_LOG_ERROR, "Undefined opcode (%x) in DELTA_FLI\n", VAR_25); } else if ((VAR_25 & 0xC000) == 0x8000) { VAR_5= VAR_26 + s->frame.linesize[0] - 1; CHECK_PIXEL_PTR(0); VAR_30[VAR_5] = VAR_25 & 0xff; } else { VAR_23--; VAR_5 = VAR_26; CHECK_PIXEL_PTR(0); VAR_29 = s->VAR_0->width; for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) { if (bytestream2_tell(&g2) + 2 > VAR_32) break; VAR_28 = bytestream2_get_byte(&g2); VAR_5 += VAR_28; VAR_29 -= VAR_28; VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8); if (VAR_27 < 0) { VAR_27 = -VAR_27; VAR_7 = bytestream2_get_byte(&g2); VAR_8 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(VAR_27 * 2); for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29 -= 2) { VAR_30[VAR_5++] = VAR_7; VAR_30[VAR_5++] = VAR_8; } } else { CHECK_PIXEL_PTR(VAR_27 * 2); if (bytestream2_tell(&g2) + VAR_27 * 2 > VAR_32) break; for (VAR_14 = 0; VAR_14 < VAR_27 * 2; VAR_14++, VAR_29--) { VAR_30[VAR_5++] = bytestream2_get_byte(&g2); } } } VAR_26 += s->frame.linesize[0]; } } break; case FLI_LC: VAR_24 = bytestream2_get_le16(&g2); VAR_26 = 0; VAR_26 += VAR_24 * s->frame.linesize[0]; VAR_23 = bytestream2_get_le16(&g2); while (VAR_23 > 0) { VAR_5 = VAR_26; CHECK_PIXEL_PTR(0); VAR_29 = s->VAR_0->width; if (bytestream2_tell(&g2) + 1 > VAR_32) break; VAR_25 = bytestream2_get_byte(&g2); if (VAR_25 > 0) { for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) { if (bytestream2_tell(&g2) + 1 > VAR_32) break; VAR_28 = bytestream2_get_byte(&g2); VAR_5 += VAR_28; VAR_29 -= VAR_28; VAR_27 = sign_extend(bytestream2_get_byte(&g2),8); if (VAR_27 > 0) { CHECK_PIXEL_PTR(VAR_27); if (bytestream2_tell(&g2) + VAR_27 > VAR_32) break; for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) { VAR_30[VAR_5++] = bytestream2_get_byte(&g2); } } else if (VAR_27 < 0) { VAR_27 = -VAR_27; VAR_7 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(VAR_27); for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) { VAR_30[VAR_5++] = VAR_7; } } } } VAR_26 += s->frame.linesize[0]; VAR_23--; } break; case FLI_BLACK: memset(VAR_30, 0, s->frame.linesize[0] * s->VAR_0->height); break; case FLI_BRUN: VAR_26 = 0; for (VAR_22 = 0; VAR_22 < s->VAR_0->height; VAR_22++) { VAR_5 = VAR_26; bytestream2_skip(&g2, 1); VAR_29 = s->VAR_0->width; while (VAR_29 > 0) { if (bytestream2_tell(&g2) + 1 > VAR_32) break; VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8); if (!VAR_27) { av_log(VAR_0, AV_LOG_ERROR, "Invalid byte run value.\n"); return AVERROR_INVALIDDATA; } if (VAR_27 > 0) { VAR_7 = bytestream2_get_byte(&g2); CHECK_PIXEL_PTR(VAR_27); for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) { VAR_30[VAR_5++] = VAR_7; VAR_29--; if (VAR_29 < 0) av_log(VAR_0, AV_LOG_ERROR, "VAR_29 < 0 (%d) at line %d\n", VAR_29, VAR_22); } } else { VAR_27 = -VAR_27; CHECK_PIXEL_PTR(VAR_27); if (bytestream2_tell(&g2) + VAR_27 > VAR_32) break; for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) { VAR_30[VAR_5++] = bytestream2_get_byte(&g2); VAR_29--; if (VAR_29 < 0) av_log(VAR_0, AV_LOG_ERROR, "VAR_29 < 0 (%d) at line %d\n", VAR_29, VAR_22); } } } VAR_26 += s->frame.linesize[0]; } break; case FLI_COPY: if (VAR_11 - 6 != s->VAR_0->width * s->VAR_0->height) { av_log(VAR_0, AV_LOG_ERROR, "In chunk FLI_COPY : source VAR_1 (%d bytes) " \ "has incorrect size, skipping chunk\n", VAR_11 - 6); bytestream2_skip(&g2, VAR_11 - 6); } else { for (VAR_26 = 0; VAR_26 < s->frame.linesize[0] * s->VAR_0->height; VAR_26 += s->frame.linesize[0]) { bytestream2_get_buffer(&g2, &VAR_30[VAR_26], s->VAR_0->width); } } break; case FLI_MINI: break; default: av_log(VAR_0, AV_LOG_ERROR, "Unrecognized chunk type: %d\n", VAR_12); break; } if (VAR_32 - bytestream2_tell(&g2) > 0) bytestream2_skip(&g2, VAR_32 - bytestream2_tell(&g2)); VAR_9 -= VAR_11; VAR_10--; } if (bytestream2_get_bytes_left(&g2) > 2) av_log(VAR_0, AV_LOG_ERROR, "Processed FLI chunk where chunk size = %d " \ "and final chunk ptr = %d\n", VAR_4, VAR_4 - bytestream2_get_bytes_left(&g2)); memcpy(s->frame.VAR_1[1], s->palette, AVPALETTE_SIZE); if (s->new_palette) { s->frame.palette_has_changed = 1; s->new_palette = 0; } if ((VAR_15 = av_frame_ref(VAR_1, &s->frame)) < 0) return VAR_15; *VAR_2 = 1; return VAR_4; }
[ "static int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nconst uint8_t *VAR_3, int VAR_4)\n{", "FlicDecodeContext *s = VAR_0->priv_data;", "GetByteContext g2;", "int VAR_5;", "int VAR_6;", "unsigned char VAR_7;", "unsigned char VAR_8;", "unsigned int VAR_9;", "int VAR_10;", "unsigned int VAR_11;", "int VAR_12;", "int VAR_13, VAR_14, VAR_15;", "int VAR_16;", "int VAR_17;", "int VAR_18;", "unsigned char VAR_19, VAR_20, VAR_21;", "int VAR_22;", "int VAR_23;", "int VAR_24;", "signed short VAR_25;", "int VAR_26;", "int VAR_27;", "int VAR_28;", "int VAR_29;", "unsigned char *VAR_30;", "unsigned int VAR_31;", "bytestream2_init(&g2, VAR_3, VAR_4);", "if ((VAR_15 = ff_reget_buffer(VAR_0, &s->frame)) < 0)\nreturn VAR_15;", "VAR_30 = s->frame.VAR_1[0];", "VAR_31 = s->VAR_0->height * s->frame.linesize[0];", "if (VAR_4 < 16 || VAR_4 > INT_MAX - (3 * 256 + FF_INPUT_BUFFER_PADDING_SIZE))\nreturn AVERROR_INVALIDDATA;", "VAR_9 = bytestream2_get_le32(&g2);", "if (VAR_9 > VAR_4)\nVAR_9 = VAR_4;", "bytestream2_skip(&g2, 2);", "VAR_10 = bytestream2_get_le16(&g2);", "bytestream2_skip(&g2, 8);", "VAR_9 -= 16;", "while ((VAR_9 >= 6) && (VAR_10 > 0)) {", "int VAR_32;", "VAR_11 = bytestream2_get_le32(&g2);", "if (VAR_11 > VAR_9) {", "av_log(VAR_0, AV_LOG_WARNING,\n\"Invalid VAR_11 = %u > VAR_9 = %u\\n\", VAR_11, VAR_9);", "VAR_11 = VAR_9;", "}", "VAR_32 = bytestream2_tell(&g2) - 4 + VAR_11;", "VAR_12 = bytestream2_get_le16(&g2);", "switch (VAR_12) {", "case FLI_256_COLOR:\ncase FLI_COLOR:\nif ((VAR_12 == FLI_256_COLOR) && (s->fli_type != FLC_MAGIC_CARPET_SYNTHETIC_TYPE_CODE))\nVAR_18 = 0;", "else\nVAR_18 = 2;", "VAR_16 = bytestream2_get_le16(&g2);", "VAR_6 = 0;", "for (VAR_13 = 0; VAR_13 < VAR_16; VAR_13++) {", "VAR_6 += bytestream2_get_byte(&g2);", "VAR_17 = bytestream2_get_byte(&g2);", "if (VAR_17 == 0)\nVAR_17 = 256;", "if (bytestream2_tell(&g2) + VAR_17 * 3 > VAR_32)\nbreak;", "for (VAR_14 = 0; VAR_14 < VAR_17; VAR_14++) {", "unsigned int VAR_33;", "if ((unsigned)VAR_6 >= 256)\nVAR_6 = 0;", "VAR_19 = bytestream2_get_byte(&g2) << VAR_18;", "VAR_20 = bytestream2_get_byte(&g2) << VAR_18;", "VAR_21 = bytestream2_get_byte(&g2) << VAR_18;", "VAR_33 = 0xFFU << 24 | VAR_19 << 16 | VAR_20 << 8 | VAR_21;", "if (VAR_18 == 2)\nVAR_33 |= VAR_33 >> 6 & 0x30303;", "if (s->palette[VAR_6] != VAR_33)\ns->new_palette = 1;", "s->palette[VAR_6++] = VAR_33;", "}", "}", "break;", "case FLI_DELTA:\nVAR_26 = 0;", "VAR_23 = bytestream2_get_le16(&g2);", "while (VAR_23 > 0) {", "if (bytestream2_tell(&g2) + 2 > VAR_32)\nbreak;", "VAR_25 = bytestream2_get_le16(&g2);", "if ((VAR_25 & 0xC000) == 0xC000) {", "VAR_25 = -VAR_25;", "VAR_26 += VAR_25 * s->frame.linesize[0];", "} else if ((VAR_25 & 0xC000) == 0x4000) {", "av_log(VAR_0, AV_LOG_ERROR, \"Undefined opcode (%x) in DELTA_FLI\\n\", VAR_25);", "} else if ((VAR_25 & 0xC000) == 0x8000) {", "VAR_5= VAR_26 + s->frame.linesize[0] - 1;", "CHECK_PIXEL_PTR(0);", "VAR_30[VAR_5] = VAR_25 & 0xff;", "} else {", "VAR_23--;", "VAR_5 = VAR_26;", "CHECK_PIXEL_PTR(0);", "VAR_29 = s->VAR_0->width;", "for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {", "if (bytestream2_tell(&g2) + 2 > VAR_32)\nbreak;", "VAR_28 = bytestream2_get_byte(&g2);", "VAR_5 += VAR_28;", "VAR_29 -= VAR_28;", "VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);", "if (VAR_27 < 0) {", "VAR_27 = -VAR_27;", "VAR_7 = bytestream2_get_byte(&g2);", "VAR_8 = bytestream2_get_byte(&g2);", "CHECK_PIXEL_PTR(VAR_27 * 2);", "for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29 -= 2) {", "VAR_30[VAR_5++] = VAR_7;", "VAR_30[VAR_5++] = VAR_8;", "}", "} else {", "CHECK_PIXEL_PTR(VAR_27 * 2);", "if (bytestream2_tell(&g2) + VAR_27 * 2 > VAR_32)\nbreak;", "for (VAR_14 = 0; VAR_14 < VAR_27 * 2; VAR_14++, VAR_29--) {", "VAR_30[VAR_5++] = bytestream2_get_byte(&g2);", "}", "}", "}", "VAR_26 += s->frame.linesize[0];", "}", "}", "break;", "case FLI_LC:\nVAR_24 = bytestream2_get_le16(&g2);", "VAR_26 = 0;", "VAR_26 += VAR_24 * s->frame.linesize[0];", "VAR_23 = bytestream2_get_le16(&g2);", "while (VAR_23 > 0) {", "VAR_5 = VAR_26;", "CHECK_PIXEL_PTR(0);", "VAR_29 = s->VAR_0->width;", "if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;", "VAR_25 = bytestream2_get_byte(&g2);", "if (VAR_25 > 0) {", "for (VAR_13 = 0; VAR_13 < VAR_25; VAR_13++) {", "if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;", "VAR_28 = bytestream2_get_byte(&g2);", "VAR_5 += VAR_28;", "VAR_29 -= VAR_28;", "VAR_27 = sign_extend(bytestream2_get_byte(&g2),8);", "if (VAR_27 > 0) {", "CHECK_PIXEL_PTR(VAR_27);", "if (bytestream2_tell(&g2) + VAR_27 > VAR_32)\nbreak;", "for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {", "VAR_30[VAR_5++] = bytestream2_get_byte(&g2);", "}", "} else if (VAR_27 < 0) {", "VAR_27 = -VAR_27;", "VAR_7 = bytestream2_get_byte(&g2);", "CHECK_PIXEL_PTR(VAR_27);", "for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++, VAR_29--) {", "VAR_30[VAR_5++] = VAR_7;", "}", "}", "}", "}", "VAR_26 += s->frame.linesize[0];", "VAR_23--;", "}", "break;", "case FLI_BLACK:\nmemset(VAR_30, 0,\ns->frame.linesize[0] * s->VAR_0->height);", "break;", "case FLI_BRUN:\nVAR_26 = 0;", "for (VAR_22 = 0; VAR_22 < s->VAR_0->height; VAR_22++) {", "VAR_5 = VAR_26;", "bytestream2_skip(&g2, 1);", "VAR_29 = s->VAR_0->width;", "while (VAR_29 > 0) {", "if (bytestream2_tell(&g2) + 1 > VAR_32)\nbreak;", "VAR_27 = sign_extend(bytestream2_get_byte(&g2), 8);", "if (!VAR_27) {", "av_log(VAR_0, AV_LOG_ERROR, \"Invalid byte run value.\\n\");", "return AVERROR_INVALIDDATA;", "}", "if (VAR_27 > 0) {", "VAR_7 = bytestream2_get_byte(&g2);", "CHECK_PIXEL_PTR(VAR_27);", "for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {", "VAR_30[VAR_5++] = VAR_7;", "VAR_29--;", "if (VAR_29 < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_29 < 0 (%d) at line %d\\n\",\nVAR_29, VAR_22);", "}", "} else {", "VAR_27 = -VAR_27;", "CHECK_PIXEL_PTR(VAR_27);", "if (bytestream2_tell(&g2) + VAR_27 > VAR_32)\nbreak;", "for (VAR_14 = 0; VAR_14 < VAR_27; VAR_14++) {", "VAR_30[VAR_5++] = bytestream2_get_byte(&g2);", "VAR_29--;", "if (VAR_29 < 0)\nav_log(VAR_0, AV_LOG_ERROR, \"VAR_29 < 0 (%d) at line %d\\n\",\nVAR_29, VAR_22);", "}", "}", "}", "VAR_26 += s->frame.linesize[0];", "}", "break;", "case FLI_COPY:\nif (VAR_11 - 6 != s->VAR_0->width * s->VAR_0->height) {", "av_log(VAR_0, AV_LOG_ERROR, \"In chunk FLI_COPY : source VAR_1 (%d bytes) \" \\\n\"has incorrect size, skipping chunk\\n\", VAR_11 - 6);", "bytestream2_skip(&g2, VAR_11 - 6);", "} else {", "for (VAR_26 = 0; VAR_26 < s->frame.linesize[0] * s->VAR_0->height;", "VAR_26 += s->frame.linesize[0]) {", "bytestream2_get_buffer(&g2, &VAR_30[VAR_26],\ns->VAR_0->width);", "}", "}", "break;", "case FLI_MINI:\nbreak;", "default:\nav_log(VAR_0, AV_LOG_ERROR, \"Unrecognized chunk type: %d\\n\", VAR_12);", "break;", "}", "if (VAR_32 - bytestream2_tell(&g2) > 0)\nbytestream2_skip(&g2, VAR_32 - bytestream2_tell(&g2));", "VAR_9 -= VAR_11;", "VAR_10--;", "}", "if (bytestream2_get_bytes_left(&g2) > 2)\nav_log(VAR_0, AV_LOG_ERROR, \"Processed FLI chunk where chunk size = %d \" \\\n\"and final chunk ptr = %d\\n\", VAR_4,\nVAR_4 - bytestream2_get_bytes_left(&g2));", "memcpy(s->frame.VAR_1[1], s->palette, AVPALETTE_SIZE);", "if (s->new_palette) {", "s->frame.palette_has_changed = 1;", "s->new_palette = 0;", "}", "if ((VAR_15 = av_frame_ref(VAR_1, &s->frame)) < 0)\nreturn VAR_15;", "*VAR_2 = 1;", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 73 ], [ 77, 79 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 135 ], [ 137, 139, 149, 151 ], [ 153, 155 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 173 ], [ 179, 181 ], [ 185, 187 ], [ 191 ], [ 193 ], [ 199, 201 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215 ], [ 217, 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 231, 233 ], [ 235 ], [ 237 ], [ 239, 241 ], [ 243 ], [ 245 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273 ], [ 275 ], [ 277 ], [ 279, 281 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315, 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 341, 345 ], [ 347 ], [ 349 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363, 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375, 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391, 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 417 ], [ 419 ], [ 423 ], [ 425 ], [ 427 ], [ 429 ], [ 433, 437, 439 ], [ 441 ], [ 445, 451 ], [ 453 ], [ 455 ], [ 461 ], [ 463 ], [ 465 ], [ 467, 469 ], [ 471 ], [ 473 ], [ 475 ], [ 477 ], [ 479 ], [ 483 ], [ 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495, 497, 499 ], [ 501 ], [ 503 ], [ 505 ], [ 507 ], [ 509, 511 ], [ 513 ], [ 515 ], [ 517 ], [ 519, 521, 523 ], [ 525 ], [ 527 ], [ 529 ], [ 533 ], [ 535 ], [ 537 ], [ 541, 545 ], [ 547, 549 ], [ 551 ], [ 553 ], [ 555 ], [ 557 ], [ 559, 561 ], [ 563 ], [ 565 ], [ 567 ], [ 571, 575 ], [ 579, 581 ], [ 583 ], [ 585 ], [ 589, 591 ], [ 595 ], [ 597 ], [ 599 ], [ 607, 609, 611, 613 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 627 ], [ 631, 633 ], [ 637 ], [ 641 ], [ 643 ] ]
5,975
static int armv7m_nvic_init(SysBusDevice *dev) { nvic_state *s = NVIC(dev); NVICClass *nc = NVIC_GET_CLASS(s); /* The NVIC always has only one CPU */ s->gic.num_cpu = 1; /* Tell the common code we're an NVIC */ s->gic.revision = 0xffffffff; s->num_irq = s->gic.num_irq; nc->parent_init(dev); gic_init_irqs_and_distributor(&s->gic, s->num_irq); /* The NVIC and system controller register area looks like this: * 0..0xff : system control registers, including systick * 0x100..0xcff : GIC-like registers * 0xd00..0xfff : system control registers * We use overlaying to put the GIC like registers * over the top of the system control register region. */ memory_region_init(&s->container, "nvic", 0x1000); /* The system register region goes at the bottom of the priority * stack as it covers the whole page. */ memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); /* Alias the GIC region so we can get only the section of it * we need, and layer it on top of the system register region. */ memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic_iomem_alias, 1); /* Map the whole thing into system memory at the location required * by the v7M architecture. */ memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
true
qemu
53111180946a56d314a9c1d07d09b9ef91e847b9
static int armv7m_nvic_init(SysBusDevice *dev) { nvic_state *s = NVIC(dev); NVICClass *nc = NVIC_GET_CLASS(s); s->gic.num_cpu = 1; s->gic.revision = 0xffffffff; s->num_irq = s->gic.num_irq; nc->parent_init(dev); gic_init_irqs_and_distributor(&s->gic, s->num_irq); memory_region_init(&s->container, "nvic", 0x1000); memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic_iomem_alias, 1); memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
{ "code": [ " return 0;", " return 0;", "static int armv7m_nvic_init(SysBusDevice *dev)", " nc->parent_init(dev);", " return 0;" ], "line_no": [ 77, 77, 1, 21, 77 ] }
static int FUNC_0(SysBusDevice *VAR_0) { nvic_state *s = NVIC(VAR_0); NVICClass *nc = NVIC_GET_CLASS(s); s->gic.num_cpu = 1; s->gic.revision = 0xffffffff; s->num_irq = s->gic.num_irq; nc->parent_init(VAR_0); gic_init_irqs_and_distributor(&s->gic, s->num_irq); memory_region_init(&s->container, "nvic", 0x1000); memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s, "nvic_sysregs", 0x1000); memory_region_add_subregion(&s->container, 0, &s->sysregmem); memory_region_init_alias(&s->gic_iomem_alias, "nvic-gic", &s->gic.iomem, 0x100, 0xc00); memory_region_add_subregion_overlap(&s->container, 0x100, &s->gic_iomem_alias, 1); memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container); s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s); return 0; }
[ "static int FUNC_0(SysBusDevice *VAR_0)\n{", "nvic_state *s = NVIC(VAR_0);", "NVICClass *nc = NVIC_GET_CLASS(s);", "s->gic.num_cpu = 1;", "s->gic.revision = 0xffffffff;", "s->num_irq = s->gic.num_irq;", "nc->parent_init(VAR_0);", "gic_init_irqs_and_distributor(&s->gic, s->num_irq);", "memory_region_init(&s->container, \"nvic\", 0x1000);", "memory_region_init_io(&s->sysregmem, &nvic_sysreg_ops, s,\n\"nvic_sysregs\", 0x1000);", "memory_region_add_subregion(&s->container, 0, &s->sysregmem);", "memory_region_init_alias(&s->gic_iomem_alias, \"nvic-gic\", &s->gic.iomem,\n0x100, 0xc00);", "memory_region_add_subregion_overlap(&s->container, 0x100,\n&s->gic_iomem_alias, 1);", "memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container);", "s->systick.timer = qemu_new_timer_ns(vm_clock, systick_timer_tick, s);", "return 0;", "}" ]
[ 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 39 ], [ 47, 49 ], [ 51 ], [ 59, 61 ], [ 63, 65 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ] ]
5,976
static void nfs_co_generic_bh_cb(void *opaque) { NFSRPC *task = opaque; task->complete = 1; qemu_bh_delete(task->bh); qemu_coroutine_enter(task->co, NULL); }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
static void nfs_co_generic_bh_cb(void *opaque) { NFSRPC *task = opaque; task->complete = 1; qemu_bh_delete(task->bh); qemu_coroutine_enter(task->co, NULL); }
{ "code": [ " qemu_coroutine_enter(task->co, NULL);" ], "line_no": [ 11 ] }
static void FUNC_0(void *VAR_0) { NFSRPC *task = VAR_0; task->complete = 1; qemu_bh_delete(task->bh); qemu_coroutine_enter(task->co, NULL); }
[ "static void FUNC_0(void *VAR_0)\n{", "NFSRPC *task = VAR_0;", "task->complete = 1;", "qemu_bh_delete(task->bh);", "qemu_coroutine_enter(task->co, NULL);", "}" ]
[ 0, 0, 0, 0, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
5,977
static void vnc_resize(VncState *vs) { DisplayState *ds = vs->ds; int size_changed; vs->old_data = qemu_realloc(vs->old_data, ds_get_linesize(ds) * ds_get_height(ds)); if (vs->old_data == NULL) { fprintf(stderr, "vnc: memory allocation failed\n"); exit(1); } if (ds_get_bytes_per_pixel(ds) != vs->serverds.pf.bytes_per_pixel) console_color_init(ds); vnc_colordepth(vs); size_changed = ds_get_width(ds) != vs->serverds.width || ds_get_height(ds) != vs->serverds.height; vs->serverds = *(ds->surface); if (size_changed) { if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) { vnc_write_u8(vs, 0); /* msg id */ vnc_write_u8(vs, 0); vnc_write_u16(vs, 1); /* number of rects */ vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds), VNC_ENCODING_DESKTOPRESIZE); vnc_flush(vs); } } memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); }
true
qemu
6baebed7698a37a0ac5168faf26023426b0ac940
static void vnc_resize(VncState *vs) { DisplayState *ds = vs->ds; int size_changed; vs->old_data = qemu_realloc(vs->old_data, ds_get_linesize(ds) * ds_get_height(ds)); if (vs->old_data == NULL) { fprintf(stderr, "vnc: memory allocation failed\n"); exit(1); } if (ds_get_bytes_per_pixel(ds) != vs->serverds.pf.bytes_per_pixel) console_color_init(ds); vnc_colordepth(vs); size_changed = ds_get_width(ds) != vs->serverds.width || ds_get_height(ds) != vs->serverds.height; vs->serverds = *(ds->surface); if (size_changed) { if (vs->csock != -1 && vnc_has_feature(vs, VNC_FEATURE_RESIZE)) { vnc_write_u8(vs, 0); vnc_write_u8(vs, 0); vnc_write_u16(vs, 1); vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds), VNC_ENCODING_DESKTOPRESIZE); vnc_flush(vs); } } memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row)); memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds)); }
{ "code": [ " vs->old_data = qemu_realloc(vs->old_data, ds_get_linesize(ds) * ds_get_height(ds));", " if (vs->old_data == NULL) {", " fprintf(stderr, \"vnc: memory allocation failed\\n\");", " exit(1);", " if (ds_get_bytes_per_pixel(ds) != vs->serverds.pf.bytes_per_pixel)", " size_changed = ds_get_width(ds) != vs->serverds.width ||", " ds_get_height(ds) != vs->serverds.height;", " vs->serverds = *(ds->surface);", " memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));", " memset(vs->old_data, 42, ds_get_linesize(vs->ds) * ds_get_height(vs->ds));", " memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));" ], "line_no": [ 13, 17, 19, 21, 27, 33, 35, 37, 61, 63, 61 ] }
static void FUNC_0(VncState *VAR_0) { DisplayState *ds = VAR_0->ds; int VAR_1; VAR_0->old_data = qemu_realloc(VAR_0->old_data, ds_get_linesize(ds) * ds_get_height(ds)); if (VAR_0->old_data == NULL) { fprintf(stderr, "vnc: memory allocation failed\n"); exit(1); } if (ds_get_bytes_per_pixel(ds) != VAR_0->serverds.pf.bytes_per_pixel) console_color_init(ds); vnc_colordepth(VAR_0); VAR_1 = ds_get_width(ds) != VAR_0->serverds.width || ds_get_height(ds) != VAR_0->serverds.height; VAR_0->serverds = *(ds->surface); if (VAR_1) { if (VAR_0->csock != -1 && vnc_has_feature(VAR_0, VNC_FEATURE_RESIZE)) { vnc_write_u8(VAR_0, 0); vnc_write_u8(VAR_0, 0); vnc_write_u16(VAR_0, 1); vnc_framebuffer_update(VAR_0, 0, 0, ds_get_width(ds), ds_get_height(ds), VNC_ENCODING_DESKTOPRESIZE); vnc_flush(VAR_0); } } memset(VAR_0->dirty_row, 0xFF, sizeof(VAR_0->dirty_row)); memset(VAR_0->old_data, 42, ds_get_linesize(VAR_0->ds) * ds_get_height(VAR_0->ds)); }
[ "static void FUNC_0(VncState *VAR_0)\n{", "DisplayState *ds = VAR_0->ds;", "int VAR_1;", "VAR_0->old_data = qemu_realloc(VAR_0->old_data, ds_get_linesize(ds) * ds_get_height(ds));", "if (VAR_0->old_data == NULL) {", "fprintf(stderr, \"vnc: memory allocation failed\\n\");", "exit(1);", "}", "if (ds_get_bytes_per_pixel(ds) != VAR_0->serverds.pf.bytes_per_pixel)\nconsole_color_init(ds);", "vnc_colordepth(VAR_0);", "VAR_1 = ds_get_width(ds) != VAR_0->serverds.width ||\nds_get_height(ds) != VAR_0->serverds.height;", "VAR_0->serverds = *(ds->surface);", "if (VAR_1) {", "if (VAR_0->csock != -1 && vnc_has_feature(VAR_0, VNC_FEATURE_RESIZE)) {", "vnc_write_u8(VAR_0, 0);", "vnc_write_u8(VAR_0, 0);", "vnc_write_u16(VAR_0, 1);", "vnc_framebuffer_update(VAR_0, 0, 0, ds_get_width(ds), ds_get_height(ds),\nVNC_ENCODING_DESKTOPRESIZE);", "vnc_flush(VAR_0);", "}", "}", "memset(VAR_0->dirty_row, 0xFF, sizeof(VAR_0->dirty_row));", "memset(VAR_0->old_data, 42, ds_get_linesize(VAR_0->ds) * ds_get_height(VAR_0->ds));", "}" ]
[ 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27, 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ] ]
5,978
e1000_can_receive(VLANClientState *nc) { E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; return (s->mac_reg[RCTL] & E1000_RCTL_EN); }
true
qemu
6cdfab2868dd593902e2b7db3ba9f49f2cc03e3f
e1000_can_receive(VLANClientState *nc) { E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque; return (s->mac_reg[RCTL] & E1000_RCTL_EN); }
{ "code": [ "e1000_can_receive(VLANClientState *nc)", " E1000State *s = DO_UPCAST(NICState, nc, nc)->opaque;", " return (s->mac_reg[RCTL] & E1000_RCTL_EN);" ], "line_no": [ 1, 5, 9 ] }
FUNC_0(VLANClientState *VAR_0) { E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque; return (s->mac_reg[RCTL] & E1000_RCTL_EN); }
[ "FUNC_0(VLANClientState *VAR_0)\n{", "E1000State *s = DO_UPCAST(NICState, VAR_0, VAR_0)->opaque;", "return (s->mac_reg[RCTL] & E1000_RCTL_EN);", "}" ]
[ 1, 1, 1, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ] ]
5,979
static void access_with_adjusted_size(hwaddr addr, uint64_t *value, unsigned size, unsigned access_size_min, unsigned access_size_max, void (*access)(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask), MemoryRegion *mr) { uint64_t access_mask; unsigned access_size; unsigned i; if (!access_size_min) { access_size_min = 1; } if (!access_size_max) { access_size_max = 4; } /* FIXME: support unaligned access? */ access_size = MAX(MIN(size, access_size_max), access_size_min); access_mask = -1ULL >> (64 - access_size * 8); if (memory_region_big_endian(mr)) { for (i = 0; i < size; i += access_size) { access(mr, addr + i, value, access_size, (size - access_size - i) * 8, access_mask); } } else { for (i = 0; i < size; i += access_size) { access(mr, addr + i, value, access_size, i * 8, access_mask); } } }
true
qemu
cc05c43ad942165ecc6ffd39e41991bee43af044
static void access_with_adjusted_size(hwaddr addr, uint64_t *value, unsigned size, unsigned access_size_min, unsigned access_size_max, void (*access)(MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, unsigned shift, uint64_t mask), MemoryRegion *mr) { uint64_t access_mask; unsigned access_size; unsigned i; if (!access_size_min) { access_size_min = 1; } if (!access_size_max) { access_size_max = 4; } access_size = MAX(MIN(size, access_size_max), access_size_min); access_mask = -1ULL >> (64 - access_size * 8); if (memory_region_big_endian(mr)) { for (i = 0; i < size; i += access_size) { access(mr, addr + i, value, access_size, (size - access_size - i) * 8, access_mask); } } else { for (i = 0; i < size; i += access_size) { access(mr, addr + i, value, access_size, i * 8, access_mask); } } }
{ "code": [ "static void access_with_adjusted_size(hwaddr addr,", " void (*access)(MemoryRegion *mr,", " hwaddr addr,", " uint64_t *value,", " unsigned size,", " unsigned shift,", " uint64_t mask),", " MemoryRegion *mr)", " access(mr, addr + i, value, access_size,", " (size - access_size - i) * 8, access_mask);", " access(mr, addr + i, value, access_size, i * 8, access_mask);" ], "line_no": [ 1, 11, 13, 15, 17, 19, 21, 23, 59, 61, 69 ] }
static void FUNC_0(hwaddr VAR_7, uint64_t *VAR_7, unsigned VAR_7, unsigned VAR_3, unsigned VAR_4, void (*VAR_5)(MemoryRegion *VAR_9, hwaddr VAR_7, uint64_t *VAR_7, unsigned VAR_7, unsigned VAR_7, uint64_t VAR_8), MemoryRegion *VAR_9) { uint64_t access_mask; unsigned VAR_9; unsigned VAR_10; if (!VAR_3) { VAR_3 = 1; } if (!VAR_4) { VAR_4 = 4; } VAR_9 = MAX(MIN(VAR_7, VAR_4), VAR_3); access_mask = -1ULL >> (64 - VAR_9 * 8); if (memory_region_big_endian(VAR_9)) { for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10 += VAR_9) { VAR_5(VAR_9, VAR_7 + VAR_10, VAR_7, VAR_9, (VAR_7 - VAR_9 - VAR_10) * 8, access_mask); } } else { for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10 += VAR_9) { VAR_5(VAR_9, VAR_7 + VAR_10, VAR_7, VAR_9, VAR_10 * 8, access_mask); } } }
[ "static void FUNC_0(hwaddr VAR_7,\nuint64_t *VAR_7,\nunsigned VAR_7,\nunsigned VAR_3,\nunsigned VAR_4,\nvoid (*VAR_5)(MemoryRegion *VAR_9,\nhwaddr VAR_7,\nuint64_t *VAR_7,\nunsigned VAR_7,\nunsigned VAR_7,\nuint64_t VAR_8),\nMemoryRegion *VAR_9)\n{", "uint64_t access_mask;", "unsigned VAR_9;", "unsigned VAR_10;", "if (!VAR_3) {", "VAR_3 = 1;", "}", "if (!VAR_4) {", "VAR_4 = 4;", "}", "VAR_9 = MAX(MIN(VAR_7, VAR_4), VAR_3);", "access_mask = -1ULL >> (64 - VAR_9 * 8);", "if (memory_region_big_endian(VAR_9)) {", "for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10 += VAR_9) {", "VAR_5(VAR_9, VAR_7 + VAR_10, VAR_7, VAR_9,\n(VAR_7 - VAR_9 - VAR_10) * 8, access_mask);", "}", "} else {", "for (VAR_10 = 0; VAR_10 < VAR_7; VAR_10 += VAR_9) {", "VAR_5(VAR_9, VAR_7 + VAR_10, VAR_7, VAR_9, VAR_10 * 8, access_mask);", "}", "}", "}" ]
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ]
[ [ 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ] ]
5,980
static void drive_uninit(DriveInfo *dinfo) { qemu_opts_del(dinfo->opts); bdrv_delete(dinfo->bdrv); QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); }
true
qemu
2753d4a5fa44d980cc6a279f323a12ca8d172972
static void drive_uninit(DriveInfo *dinfo) { qemu_opts_del(dinfo->opts); bdrv_delete(dinfo->bdrv); QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); }
{ "code": [], "line_no": [] }
static void FUNC_0(DriveInfo *VAR_0) { qemu_opts_del(VAR_0->opts); bdrv_delete(VAR_0->bdrv); QTAILQ_REMOVE(&drives, VAR_0, next); qemu_free(VAR_0); }
[ "static void FUNC_0(DriveInfo *VAR_0)\n{", "qemu_opts_del(VAR_0->opts);", "bdrv_delete(VAR_0->bdrv);", "QTAILQ_REMOVE(&drives, VAR_0, next);", "qemu_free(VAR_0);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 10 ], [ 12 ], [ 14 ] ]
5,982
static void mpeg_decode_sequence_extension(Mpeg1Context *s1) { MpegEncContext *s = &s1->mpeg_enc_ctx; int horiz_size_ext, vert_size_ext; int bit_rate_ext; skip_bits(&s->gb, 1); /* profile and level esc*/ s->avctx->profile = get_bits(&s->gb, 3); s->avctx->level = get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); /* progressive_sequence */ s->chroma_format = get_bits(&s->gb, 2); /* chroma_format 1=420, 2=422, 3=444 */ if (!s->chroma_format) { s->chroma_format = 1; av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n"); } horiz_size_ext = get_bits(&s->gb, 2); vert_size_ext = get_bits(&s->gb, 2); s->width |= (horiz_size_ext << 12); s->height |= (vert_size_ext << 12); bit_rate_ext = get_bits(&s->gb, 12); /* XXX: handle it */ s->bit_rate += (bit_rate_ext << 18) * 400; check_marker(&s->gb, "after bit rate extension"); s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1; ff_dlog(s->avctx, "sequence extension\n"); s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%"PRId64"\n", s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, s->avctx->rc_buffer_size, s->bit_rate); }
true
FFmpeg
863522431fb2fc7d35fce582fcaacdcf37fc3c44
static void mpeg_decode_sequence_extension(Mpeg1Context *s1) { MpegEncContext *s = &s1->mpeg_enc_ctx; int horiz_size_ext, vert_size_ext; int bit_rate_ext; skip_bits(&s->gb, 1); s->avctx->profile = get_bits(&s->gb, 3); s->avctx->level = get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); s->chroma_format = get_bits(&s->gb, 2); if (!s->chroma_format) { s->chroma_format = 1; av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n"); } horiz_size_ext = get_bits(&s->gb, 2); vert_size_ext = get_bits(&s->gb, 2); s->width |= (horiz_size_ext << 12); s->height |= (vert_size_ext << 12); bit_rate_ext = get_bits(&s->gb, 12); s->bit_rate += (bit_rate_ext << 18) * 400; check_marker(&s->gb, "after bit rate extension"); s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; s1->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; s1->frame_rate_ext.den = get_bits(&s->gb, 5) + 1; ff_dlog(s->avctx, "sequence extension\n"); s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%"PRId64"\n", s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, s->avctx->rc_buffer_size, s->bit_rate); }
{ "code": [ " s->bit_rate += (bit_rate_ext << 18) * 400;" ], "line_no": [ 45 ] }
static void FUNC_0(Mpeg1Context *VAR_0) { MpegEncContext *s = &VAR_0->mpeg_enc_ctx; int VAR_1, VAR_2; int VAR_3; skip_bits(&s->gb, 1); s->avctx->profile = get_bits(&s->gb, 3); s->avctx->level = get_bits(&s->gb, 4); s->progressive_sequence = get_bits1(&s->gb); s->chroma_format = get_bits(&s->gb, 2); if (!s->chroma_format) { s->chroma_format = 1; av_log(s->avctx, AV_LOG_WARNING, "Chroma format invalid\n"); } VAR_1 = get_bits(&s->gb, 2); VAR_2 = get_bits(&s->gb, 2); s->width |= (VAR_1 << 12); s->height |= (VAR_2 << 12); VAR_3 = get_bits(&s->gb, 12); s->bit_rate += (VAR_3 << 18) * 400; check_marker(&s->gb, "after bit rate extension"); s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10; s->low_delay = get_bits1(&s->gb); if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY) s->low_delay = 1; VAR_0->frame_rate_ext.num = get_bits(&s->gb, 2) + 1; VAR_0->frame_rate_ext.den = get_bits(&s->gb, 5) + 1; ff_dlog(s->avctx, "sequence extension\n"); s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO; if (s->avctx->debug & FF_DEBUG_PICT_INFO) av_log(s->avctx, AV_LOG_DEBUG, "profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%"PRId64"\n", s->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format, s->avctx->rc_buffer_size, s->bit_rate); }
[ "static void FUNC_0(Mpeg1Context *VAR_0)\n{", "MpegEncContext *s = &VAR_0->mpeg_enc_ctx;", "int VAR_1, VAR_2;", "int VAR_3;", "skip_bits(&s->gb, 1);", "s->avctx->profile = get_bits(&s->gb, 3);", "s->avctx->level = get_bits(&s->gb, 4);", "s->progressive_sequence = get_bits1(&s->gb);", "s->chroma_format = get_bits(&s->gb, 2);", "if (!s->chroma_format) {", "s->chroma_format = 1;", "av_log(s->avctx, AV_LOG_WARNING, \"Chroma format invalid\\n\");", "}", "VAR_1 = get_bits(&s->gb, 2);", "VAR_2 = get_bits(&s->gb, 2);", "s->width |= (VAR_1 << 12);", "s->height |= (VAR_2 << 12);", "VAR_3 = get_bits(&s->gb, 12);", "s->bit_rate += (VAR_3 << 18) * 400;", "check_marker(&s->gb, \"after bit rate extension\");", "s->avctx->rc_buffer_size += get_bits(&s->gb, 8) * 1024 * 16 << 10;", "s->low_delay = get_bits1(&s->gb);", "if (s->avctx->flags & AV_CODEC_FLAG_LOW_DELAY)\ns->low_delay = 1;", "VAR_0->frame_rate_ext.num = get_bits(&s->gb, 2) + 1;", "VAR_0->frame_rate_ext.den = get_bits(&s->gb, 5) + 1;", "ff_dlog(s->avctx, \"sequence extension\\n\");", "s->codec_id = s->avctx->codec_id = AV_CODEC_ID_MPEG2VIDEO;", "if (s->avctx->debug & FF_DEBUG_PICT_INFO)\nav_log(s->avctx, AV_LOG_DEBUG,\n\"profile: %d, level: %d ps: %d cf:%d vbv buffer: %d, bitrate:%\"PRId64\"\\n\",\ns->avctx->profile, s->avctx->level, s->progressive_sequence, s->chroma_format,\ns->avctx->rc_buffer_size, s->bit_rate);", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55, 57 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 73, 75, 77, 79, 81 ], [ 83 ] ]
5,984
static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, int line_size) { int i; vector unsigned char perm = vec_lvsl(0, pixels); vector unsigned char bytes; const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); vector signed short shorts; for (i = 0; i < 8; i++) { // Read potentially unaligned pixels. // We're reading 16 pixels, and actually only want 8, // but we simply ignore the extras. vector unsigned char pixl = vec_ld( 0, pixels); vector unsigned char pixr = vec_ld(15, pixels); bytes = vec_perm(pixl, pixr, perm); // convert the bytes into shorts shorts = (vector signed short)vec_mergeh(zero, bytes); // save the data to the block, we assume the block is 16-byte aligned vec_st(shorts, i*16, (vector signed short*)block); pixels += line_size; } }
true
FFmpeg
98fdfa99704f1cfef3d3a26c580b92749b6b64cb
static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, int line_size) { int i; vector unsigned char perm = vec_lvsl(0, pixels); vector unsigned char bytes; const vector unsigned char zero = (const vector unsigned char)vec_splat_u8(0); vector signed short shorts; for (i = 0; i < 8; i++) { vector unsigned char pixl = vec_ld( 0, pixels); vector unsigned char pixr = vec_ld(15, pixels); bytes = vec_perm(pixl, pixr, perm); shorts = (vector signed short)vec_mergeh(zero, bytes); vec_st(shorts, i*16, (vector signed short*)block); pixels += line_size; } }
{ "code": [ " vector unsigned char pixl = vec_ld( 0, pixels);", " vector unsigned char pixr = vec_ld(15, pixels);" ], "line_no": [ 25, 27 ] }
static void FUNC_0(int16_t *restrict VAR_0, const uint8_t *VAR_1, int VAR_2) { int VAR_3; vector unsigned char perm = vec_lvsl(0, VAR_1); vector unsigned char bytes; const vector unsigned char VAR_4 = (const vector unsigned char)vec_splat_u8(0); vector signed short shorts; for (VAR_3 = 0; VAR_3 < 8; VAR_3++) { vector unsigned char pixl = vec_ld( 0, VAR_1); vector unsigned char pixr = vec_ld(15, VAR_1); bytes = vec_perm(pixl, pixr, perm); shorts = (vector signed short)vec_mergeh(VAR_4, bytes); vec_st(shorts, VAR_3*16, (vector signed short*)VAR_0); VAR_1 += VAR_2; } }
[ "static void FUNC_0(int16_t *restrict VAR_0, const uint8_t *VAR_1, int VAR_2)\n{", "int VAR_3;", "vector unsigned char perm = vec_lvsl(0, VAR_1);", "vector unsigned char bytes;", "const vector unsigned char VAR_4 = (const vector unsigned char)vec_splat_u8(0);", "vector signed short shorts;", "for (VAR_3 = 0; VAR_3 < 8; VAR_3++) {", "vector unsigned char pixl = vec_ld( 0, VAR_1);", "vector unsigned char pixr = vec_ld(15, VAR_1);", "bytes = vec_perm(pixl, pixr, perm);", "shorts = (vector signed short)vec_mergeh(VAR_4, bytes);", "vec_st(shorts, VAR_3*16, (vector signed short*)VAR_0);", "VAR_1 += VAR_2;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 25 ], [ 27 ], [ 29 ], [ 35 ], [ 41 ], [ 45 ], [ 47 ], [ 49 ] ]
5,985
static void pc_q35_init_1_5(QEMUMachineInitArgs *args) { has_pci_info = false; pc_q35_init(args); }
true
qemu
9604f70fdf8e21ec0dbf6eac5e59a0eb8beadd64
static void pc_q35_init_1_5(QEMUMachineInitArgs *args) { has_pci_info = false; pc_q35_init(args); }
{ "code": [ "static void pc_q35_init_1_5(QEMUMachineInitArgs *args)" ], "line_no": [ 1 ] }
static void FUNC_0(QEMUMachineInitArgs *VAR_0) { has_pci_info = false; pc_q35_init(VAR_0); }
[ "static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{", "has_pci_info = false;", "pc_q35_init(VAR_0);", "}" ]
[ 1, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ] ]
5,986
static int sap_write_close(AVFormatContext *s) { struct SAPState *sap = s->priv_data; int i; for (i = 0; i < s->nb_streams; i++) { AVFormatContext *rtpctx = s->streams[i]->priv_data; if (!rtpctx) continue; av_write_trailer(rtpctx); url_fclose(rtpctx->pb); av_metadata_free(&rtpctx->streams[0]->metadata); av_metadata_free(&rtpctx->metadata); av_free(rtpctx->streams[0]); av_free(rtpctx); s->streams[i]->priv_data = NULL; } if (sap->last_time && sap->ann && sap->ann_fd) { sap->ann[0] |= 4; /* Session deletion*/ url_write(sap->ann_fd, sap->ann, sap->ann_size); } av_freep(&sap->ann); if (sap->ann_fd) url_close(sap->ann_fd); ff_network_close(); return 0; }
true
FFmpeg
a991b8dec654ad09a35494e0cabbbc157bb04dab
static int sap_write_close(AVFormatContext *s) { struct SAPState *sap = s->priv_data; int i; for (i = 0; i < s->nb_streams; i++) { AVFormatContext *rtpctx = s->streams[i]->priv_data; if (!rtpctx) continue; av_write_trailer(rtpctx); url_fclose(rtpctx->pb); av_metadata_free(&rtpctx->streams[0]->metadata); av_metadata_free(&rtpctx->metadata); av_free(rtpctx->streams[0]); av_free(rtpctx); s->streams[i]->priv_data = NULL; } if (sap->last_time && sap->ann && sap->ann_fd) { sap->ann[0] |= 4; url_write(sap->ann_fd, sap->ann, sap->ann_size); } av_freep(&sap->ann); if (sap->ann_fd) url_close(sap->ann_fd); ff_network_close(); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { struct SAPState *VAR_1 = VAR_0->priv_data; int VAR_2; for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) { AVFormatContext *rtpctx = VAR_0->streams[VAR_2]->priv_data; if (!rtpctx) continue; av_write_trailer(rtpctx); url_fclose(rtpctx->pb); av_metadata_free(&rtpctx->streams[0]->metadata); av_metadata_free(&rtpctx->metadata); av_free(rtpctx->streams[0]); av_free(rtpctx); VAR_0->streams[VAR_2]->priv_data = NULL; } if (VAR_1->last_time && VAR_1->ann && VAR_1->ann_fd) { VAR_1->ann[0] |= 4; url_write(VAR_1->ann_fd, VAR_1->ann, VAR_1->ann_size); } av_freep(&VAR_1->ann); if (VAR_1->ann_fd) url_close(VAR_1->ann_fd); ff_network_close(); return 0; }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "struct SAPState *VAR_1 = VAR_0->priv_data;", "int VAR_2;", "for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) {", "AVFormatContext *rtpctx = VAR_0->streams[VAR_2]->priv_data;", "if (!rtpctx)\ncontinue;", "av_write_trailer(rtpctx);", "url_fclose(rtpctx->pb);", "av_metadata_free(&rtpctx->streams[0]->metadata);", "av_metadata_free(&rtpctx->metadata);", "av_free(rtpctx->streams[0]);", "av_free(rtpctx);", "VAR_0->streams[VAR_2]->priv_data = NULL;", "}", "if (VAR_1->last_time && VAR_1->ann && VAR_1->ann_fd) {", "VAR_1->ann[0] |= 4;", "url_write(VAR_1->ann_fd, VAR_1->ann, VAR_1->ann_size);", "}", "av_freep(&VAR_1->ann);", "if (VAR_1->ann_fd)\nurl_close(VAR_1->ann_fd);", "ff_network_close();", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 28 ], [ 30 ], [ 32 ], [ 34 ], [ 38 ], [ 40 ], [ 42 ], [ 44 ], [ 48 ], [ 50, 52 ], [ 54 ], [ 56 ], [ 58 ] ]
5,987
void ahci_hba_enable(AHCIQState *ahci) { /* Bits of interest in this section: * GHC.AE Global Host Control / AHCI Enable * PxCMD.ST Port Command: Start * PxCMD.SUD "Spin Up Device" * PxCMD.POD "Power On Device" * PxCMD.FRE "FIS Receive Enable" * PxCMD.FR "FIS Receive Running" * PxCMD.CR "Command List Running" */ uint32_t reg, ports_impl; uint16_t i; uint8_t num_cmd_slots; g_assert(ahci != NULL); /* Set GHC.AE to 1 */ ahci_set(ahci, AHCI_GHC, AHCI_GHC_AE); reg = ahci_rreg(ahci, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_AE); /* Cache CAP and CAP2. */ ahci->cap = ahci_rreg(ahci, AHCI_CAP); ahci->cap2 = ahci_rreg(ahci, AHCI_CAP2); /* Read CAP.NCS, how many command slots do we have? */ num_cmd_slots = ((ahci->cap & AHCI_CAP_NCS) >> ctzl(AHCI_CAP_NCS)) + 1; g_test_message("Number of Command Slots: %u", num_cmd_slots); /* Determine which ports are implemented. */ ports_impl = ahci_rreg(ahci, AHCI_PI); for (i = 0; ports_impl; ports_impl >>= 1, ++i) { if (!(ports_impl & 0x01)) { continue; } g_test_message("Initializing port %u", i); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); if (BITCLR(reg, AHCI_PX_CMD_ST | AHCI_PX_CMD_CR | AHCI_PX_CMD_FRE | AHCI_PX_CMD_FR)) { g_test_message("port is idle"); } else { g_test_message("port needs to be idled"); ahci_px_clr(ahci, i, AHCI_PX_CMD, (AHCI_PX_CMD_ST | AHCI_PX_CMD_FRE)); /* The port has 500ms to disengage. */ usleep(500000); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_CR); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_FR); g_test_message("port is now idle"); /* The spec does allow for possibly needing a PORT RESET * or HBA reset if we fail to idle the port. */ } /* Allocate Memory for the Command List Buffer & FIS Buffer */ /* PxCLB space ... 0x20 per command, as in 4.2.2 p 36 */ ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20); qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20); g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb); ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb); g_assert_cmphex(ahci->port[i].clb, ==, ahci_px_rreg(ahci, i, AHCI_PX_CLB)); /* PxFB space ... 0x100, as in 4.2.1 p 35 */ ahci->port[i].fb = ahci_alloc(ahci, 0x100); qmemset(ahci->port[i].fb, 0x00, 0x100); g_test_message("FB: 0x%08" PRIx64, ahci->port[i].fb); ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb); g_assert_cmphex(ahci->port[i].fb, ==, ahci_px_rreg(ahci, i, AHCI_PX_FB)); /* Clear PxSERR, PxIS, then IS.IPS[x] by writing '1's. */ ahci_px_wreg(ahci, i, AHCI_PX_SERR, 0xFFFFFFFF); ahci_px_wreg(ahci, i, AHCI_PX_IS, 0xFFFFFFFF); ahci_wreg(ahci, AHCI_IS, (1 << i)); /* Verify Interrupts Cleared */ reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR); g_assert_cmphex(reg, ==, 0); reg = ahci_px_rreg(ahci, i, AHCI_PX_IS); g_assert_cmphex(reg, ==, 0); reg = ahci_rreg(ahci, AHCI_IS); ASSERT_BIT_CLEAR(reg, (1 << i)); /* Enable All Interrupts: */ ahci_px_wreg(ahci, i, AHCI_PX_IE, 0xFFFFFFFF); reg = ahci_px_rreg(ahci, i, AHCI_PX_IE); g_assert_cmphex(reg, ==, ~((uint32_t)AHCI_PX_IE_RESERVED)); /* Enable the FIS Receive Engine. */ ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_FRE); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); ASSERT_BIT_SET(reg, AHCI_PX_CMD_FR); /* AHCI 1.3 spec: if !STS.BSY, !STS.DRQ and PxSSTS.DET indicates * physical presence, a device is present and may be started. However, * PxSERR.DIAG.X /may/ need to be cleared a priori. */ reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR); if (BITSET(reg, AHCI_PX_SERR_DIAG_X)) { ahci_px_set(ahci, i, AHCI_PX_SERR, AHCI_PX_SERR_DIAG_X); } reg = ahci_px_rreg(ahci, i, AHCI_PX_TFD); if (BITCLR(reg, AHCI_PX_TFD_STS_BSY | AHCI_PX_TFD_STS_DRQ)) { reg = ahci_px_rreg(ahci, i, AHCI_PX_SSTS); if ((reg & AHCI_PX_SSTS_DET) == SSTS_DET_ESTABLISHED) { /* Device Found: set PxCMD.ST := 1 */ ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_ST); ASSERT_BIT_SET(ahci_px_rreg(ahci, i, AHCI_PX_CMD), AHCI_PX_CMD_CR); g_test_message("Started Device %u", i); } else if ((reg & AHCI_PX_SSTS_DET)) { /* Device present, but in some unknown state. */ g_assert_not_reached(); } } } /* Enable GHC.IE */ ahci_set(ahci, AHCI_GHC, AHCI_GHC_IE); reg = ahci_rreg(ahci, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_IE); /* TODO: The device should now be idling and waiting for commands. * In the future, a small test-case to inspect the Register D2H FIS * and clear the initial interrupts might be good. */ }
true
qemu
e7c8526b2a1482a9b14319fda9f8ad4bfda5b958
void ahci_hba_enable(AHCIQState *ahci) { uint32_t reg, ports_impl; uint16_t i; uint8_t num_cmd_slots; g_assert(ahci != NULL); ahci_set(ahci, AHCI_GHC, AHCI_GHC_AE); reg = ahci_rreg(ahci, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_AE); ahci->cap = ahci_rreg(ahci, AHCI_CAP); ahci->cap2 = ahci_rreg(ahci, AHCI_CAP2); num_cmd_slots = ((ahci->cap & AHCI_CAP_NCS) >> ctzl(AHCI_CAP_NCS)) + 1; g_test_message("Number of Command Slots: %u", num_cmd_slots); ports_impl = ahci_rreg(ahci, AHCI_PI); for (i = 0; ports_impl; ports_impl >>= 1, ++i) { if (!(ports_impl & 0x01)) { continue; } g_test_message("Initializing port %u", i); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); if (BITCLR(reg, AHCI_PX_CMD_ST | AHCI_PX_CMD_CR | AHCI_PX_CMD_FRE | AHCI_PX_CMD_FR)) { g_test_message("port is idle"); } else { g_test_message("port needs to be idled"); ahci_px_clr(ahci, i, AHCI_PX_CMD, (AHCI_PX_CMD_ST | AHCI_PX_CMD_FRE)); usleep(500000); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_CR); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_FR); g_test_message("port is now idle"); } ahci->port[i].clb = ahci_alloc(ahci, num_cmd_slots * 0x20); qmemset(ahci->port[i].clb, 0x00, num_cmd_slots * 0x20); g_test_message("CLB: 0x%08" PRIx64, ahci->port[i].clb); ahci_px_wreg(ahci, i, AHCI_PX_CLB, ahci->port[i].clb); g_assert_cmphex(ahci->port[i].clb, ==, ahci_px_rreg(ahci, i, AHCI_PX_CLB)); ahci->port[i].fb = ahci_alloc(ahci, 0x100); qmemset(ahci->port[i].fb, 0x00, 0x100); g_test_message("FB: 0x%08" PRIx64, ahci->port[i].fb); ahci_px_wreg(ahci, i, AHCI_PX_FB, ahci->port[i].fb); g_assert_cmphex(ahci->port[i].fb, ==, ahci_px_rreg(ahci, i, AHCI_PX_FB)); ahci_px_wreg(ahci, i, AHCI_PX_SERR, 0xFFFFFFFF); ahci_px_wreg(ahci, i, AHCI_PX_IS, 0xFFFFFFFF); ahci_wreg(ahci, AHCI_IS, (1 << i)); reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR); g_assert_cmphex(reg, ==, 0); reg = ahci_px_rreg(ahci, i, AHCI_PX_IS); g_assert_cmphex(reg, ==, 0); reg = ahci_rreg(ahci, AHCI_IS); ASSERT_BIT_CLEAR(reg, (1 << i)); ahci_px_wreg(ahci, i, AHCI_PX_IE, 0xFFFFFFFF); reg = ahci_px_rreg(ahci, i, AHCI_PX_IE); g_assert_cmphex(reg, ==, ~((uint32_t)AHCI_PX_IE_RESERVED)); ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_FRE); reg = ahci_px_rreg(ahci, i, AHCI_PX_CMD); ASSERT_BIT_SET(reg, AHCI_PX_CMD_FR); reg = ahci_px_rreg(ahci, i, AHCI_PX_SERR); if (BITSET(reg, AHCI_PX_SERR_DIAG_X)) { ahci_px_set(ahci, i, AHCI_PX_SERR, AHCI_PX_SERR_DIAG_X); } reg = ahci_px_rreg(ahci, i, AHCI_PX_TFD); if (BITCLR(reg, AHCI_PX_TFD_STS_BSY | AHCI_PX_TFD_STS_DRQ)) { reg = ahci_px_rreg(ahci, i, AHCI_PX_SSTS); if ((reg & AHCI_PX_SSTS_DET) == SSTS_DET_ESTABLISHED) { ahci_px_set(ahci, i, AHCI_PX_CMD, AHCI_PX_CMD_ST); ASSERT_BIT_SET(ahci_px_rreg(ahci, i, AHCI_PX_CMD), AHCI_PX_CMD_CR); g_test_message("Started Device %u", i); } else if ((reg & AHCI_PX_SSTS_DET)) { g_assert_not_reached(); } } } ahci_set(ahci, AHCI_GHC, AHCI_GHC_IE); reg = ahci_rreg(ahci, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_IE); }
{ "code": [], "line_no": [] }
void FUNC_0(AHCIQState *VAR_0) { uint32_t reg, ports_impl; uint16_t i; uint8_t num_cmd_slots; g_assert(VAR_0 != NULL); ahci_set(VAR_0, AHCI_GHC, AHCI_GHC_AE); reg = ahci_rreg(VAR_0, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_AE); VAR_0->cap = ahci_rreg(VAR_0, AHCI_CAP); VAR_0->cap2 = ahci_rreg(VAR_0, AHCI_CAP2); num_cmd_slots = ((VAR_0->cap & AHCI_CAP_NCS) >> ctzl(AHCI_CAP_NCS)) + 1; g_test_message("Number of Command Slots: %u", num_cmd_slots); ports_impl = ahci_rreg(VAR_0, AHCI_PI); for (i = 0; ports_impl; ports_impl >>= 1, ++i) { if (!(ports_impl & 0x01)) { continue; } g_test_message("Initializing port %u", i); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD); if (BITCLR(reg, AHCI_PX_CMD_ST | AHCI_PX_CMD_CR | AHCI_PX_CMD_FRE | AHCI_PX_CMD_FR)) { g_test_message("port is idle"); } else { g_test_message("port needs to be idled"); ahci_px_clr(VAR_0, i, AHCI_PX_CMD, (AHCI_PX_CMD_ST | AHCI_PX_CMD_FRE)); usleep(500000); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_CR); ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_FR); g_test_message("port is now idle"); } VAR_0->port[i].clb = ahci_alloc(VAR_0, num_cmd_slots * 0x20); qmemset(VAR_0->port[i].clb, 0x00, num_cmd_slots * 0x20); g_test_message("CLB: 0x%08" PRIx64, VAR_0->port[i].clb); ahci_px_wreg(VAR_0, i, AHCI_PX_CLB, VAR_0->port[i].clb); g_assert_cmphex(VAR_0->port[i].clb, ==, ahci_px_rreg(VAR_0, i, AHCI_PX_CLB)); VAR_0->port[i].fb = ahci_alloc(VAR_0, 0x100); qmemset(VAR_0->port[i].fb, 0x00, 0x100); g_test_message("FB: 0x%08" PRIx64, VAR_0->port[i].fb); ahci_px_wreg(VAR_0, i, AHCI_PX_FB, VAR_0->port[i].fb); g_assert_cmphex(VAR_0->port[i].fb, ==, ahci_px_rreg(VAR_0, i, AHCI_PX_FB)); ahci_px_wreg(VAR_0, i, AHCI_PX_SERR, 0xFFFFFFFF); ahci_px_wreg(VAR_0, i, AHCI_PX_IS, 0xFFFFFFFF); ahci_wreg(VAR_0, AHCI_IS, (1 << i)); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SERR); g_assert_cmphex(reg, ==, 0); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_IS); g_assert_cmphex(reg, ==, 0); reg = ahci_rreg(VAR_0, AHCI_IS); ASSERT_BIT_CLEAR(reg, (1 << i)); ahci_px_wreg(VAR_0, i, AHCI_PX_IE, 0xFFFFFFFF); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_IE); g_assert_cmphex(reg, ==, ~((uint32_t)AHCI_PX_IE_RESERVED)); ahci_px_set(VAR_0, i, AHCI_PX_CMD, AHCI_PX_CMD_FRE); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD); ASSERT_BIT_SET(reg, AHCI_PX_CMD_FR); reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SERR); if (BITSET(reg, AHCI_PX_SERR_DIAG_X)) { ahci_px_set(VAR_0, i, AHCI_PX_SERR, AHCI_PX_SERR_DIAG_X); } reg = ahci_px_rreg(VAR_0, i, AHCI_PX_TFD); if (BITCLR(reg, AHCI_PX_TFD_STS_BSY | AHCI_PX_TFD_STS_DRQ)) { reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SSTS); if ((reg & AHCI_PX_SSTS_DET) == SSTS_DET_ESTABLISHED) { ahci_px_set(VAR_0, i, AHCI_PX_CMD, AHCI_PX_CMD_ST); ASSERT_BIT_SET(ahci_px_rreg(VAR_0, i, AHCI_PX_CMD), AHCI_PX_CMD_CR); g_test_message("Started Device %u", i); } else if ((reg & AHCI_PX_SSTS_DET)) { g_assert_not_reached(); } } } ahci_set(VAR_0, AHCI_GHC, AHCI_GHC_IE); reg = ahci_rreg(VAR_0, AHCI_GHC); ASSERT_BIT_SET(reg, AHCI_GHC_IE); }
[ "void FUNC_0(AHCIQState *VAR_0)\n{", "uint32_t reg, ports_impl;", "uint16_t i;", "uint8_t num_cmd_slots;", "g_assert(VAR_0 != NULL);", "ahci_set(VAR_0, AHCI_GHC, AHCI_GHC_AE);", "reg = ahci_rreg(VAR_0, AHCI_GHC);", "ASSERT_BIT_SET(reg, AHCI_GHC_AE);", "VAR_0->cap = ahci_rreg(VAR_0, AHCI_CAP);", "VAR_0->cap2 = ahci_rreg(VAR_0, AHCI_CAP2);", "num_cmd_slots = ((VAR_0->cap & AHCI_CAP_NCS) >> ctzl(AHCI_CAP_NCS)) + 1;", "g_test_message(\"Number of Command Slots: %u\", num_cmd_slots);", "ports_impl = ahci_rreg(VAR_0, AHCI_PI);", "for (i = 0; ports_impl; ports_impl >>= 1, ++i) {", "if (!(ports_impl & 0x01)) {", "continue;", "}", "g_test_message(\"Initializing port %u\", i);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD);", "if (BITCLR(reg, AHCI_PX_CMD_ST | AHCI_PX_CMD_CR |\nAHCI_PX_CMD_FRE | AHCI_PX_CMD_FR)) {", "g_test_message(\"port is idle\");", "} else {", "g_test_message(\"port needs to be idled\");", "ahci_px_clr(VAR_0, i, AHCI_PX_CMD,\n(AHCI_PX_CMD_ST | AHCI_PX_CMD_FRE));", "usleep(500000);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD);", "ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_CR);", "ASSERT_BIT_CLEAR(reg, AHCI_PX_CMD_FR);", "g_test_message(\"port is now idle\");", "}", "VAR_0->port[i].clb = ahci_alloc(VAR_0, num_cmd_slots * 0x20);", "qmemset(VAR_0->port[i].clb, 0x00, num_cmd_slots * 0x20);", "g_test_message(\"CLB: 0x%08\" PRIx64, VAR_0->port[i].clb);", "ahci_px_wreg(VAR_0, i, AHCI_PX_CLB, VAR_0->port[i].clb);", "g_assert_cmphex(VAR_0->port[i].clb, ==,\nahci_px_rreg(VAR_0, i, AHCI_PX_CLB));", "VAR_0->port[i].fb = ahci_alloc(VAR_0, 0x100);", "qmemset(VAR_0->port[i].fb, 0x00, 0x100);", "g_test_message(\"FB: 0x%08\" PRIx64, VAR_0->port[i].fb);", "ahci_px_wreg(VAR_0, i, AHCI_PX_FB, VAR_0->port[i].fb);", "g_assert_cmphex(VAR_0->port[i].fb, ==,\nahci_px_rreg(VAR_0, i, AHCI_PX_FB));", "ahci_px_wreg(VAR_0, i, AHCI_PX_SERR, 0xFFFFFFFF);", "ahci_px_wreg(VAR_0, i, AHCI_PX_IS, 0xFFFFFFFF);", "ahci_wreg(VAR_0, AHCI_IS, (1 << i));", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SERR);", "g_assert_cmphex(reg, ==, 0);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_IS);", "g_assert_cmphex(reg, ==, 0);", "reg = ahci_rreg(VAR_0, AHCI_IS);", "ASSERT_BIT_CLEAR(reg, (1 << i));", "ahci_px_wreg(VAR_0, i, AHCI_PX_IE, 0xFFFFFFFF);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_IE);", "g_assert_cmphex(reg, ==, ~((uint32_t)AHCI_PX_IE_RESERVED));", "ahci_px_set(VAR_0, i, AHCI_PX_CMD, AHCI_PX_CMD_FRE);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_CMD);", "ASSERT_BIT_SET(reg, AHCI_PX_CMD_FR);", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SERR);", "if (BITSET(reg, AHCI_PX_SERR_DIAG_X)) {", "ahci_px_set(VAR_0, i, AHCI_PX_SERR, AHCI_PX_SERR_DIAG_X);", "}", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_TFD);", "if (BITCLR(reg, AHCI_PX_TFD_STS_BSY | AHCI_PX_TFD_STS_DRQ)) {", "reg = ahci_px_rreg(VAR_0, i, AHCI_PX_SSTS);", "if ((reg & AHCI_PX_SSTS_DET) == SSTS_DET_ESTABLISHED) {", "ahci_px_set(VAR_0, i, AHCI_PX_CMD, AHCI_PX_CMD_ST);", "ASSERT_BIT_SET(ahci_px_rreg(VAR_0, i, AHCI_PX_CMD),\nAHCI_PX_CMD_CR);", "g_test_message(\"Started Device %u\", i);", "} else if ((reg & AHCI_PX_SSTS_DET)) {", "g_assert_not_reached();", "}", "}", "}", "ahci_set(VAR_0, AHCI_GHC, AHCI_GHC_IE);", "reg = ahci_rreg(VAR_0, AHCI_GHC);", "ASSERT_BIT_SET(reg, AHCI_GHC_IE);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 37 ], [ 39 ], [ 41 ], [ 47 ], [ 49 ], [ 55 ], [ 57 ], [ 63 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 113 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129, 131 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 153 ], [ 155 ], [ 157 ], [ 163 ], [ 165 ], [ 169 ], [ 171 ], [ 175 ], [ 177 ], [ 183 ], [ 185 ], [ 187 ], [ 193 ], [ 195 ], [ 197 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229, 231 ], [ 233 ], [ 235 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 251 ], [ 253 ], [ 255 ], [ 266 ] ]
5,988
static void ppc6xx_set_irq (void *opaque, int pin, int level) { CPUState *env = opaque; int cur_level; #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, env, pin, level); } #endif cur_level = (env->irq_input_state >> pin) & 1; /* Don't generate spurious events */ if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { switch (pin) { case PPC6xx_INPUT_TBEN: /* Level sensitive - active high */ #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: %s the time base\n", __func__, level ? "start" : "stop"); } #endif if (level) { cpu_ppc_tb_start(env); } else { cpu_ppc_tb_stop(env); } case PPC6xx_INPUT_INT: /* Level sensitive - active high */ #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the external IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_EXT, level); break; case PPC6xx_INPUT_SMI: /* Level sensitive - active high */ #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the SMI IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_SMI, level); break; case PPC6xx_INPUT_MCP: /* Negative edge sensitive */ /* XXX: TODO: actual reaction may depends on HID0 status * 603/604/740/750: check HID0[EMCP] */ if (cur_level == 1 && level == 0) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: raise machine check state\n", __func__); } #endif ppc_set_irq(env, PPC_INTERRUPT_MCK, 1); } break; case PPC6xx_INPUT_CKSTP_IN: /* Level sensitive - active low */ /* XXX: TODO: relay the signal to CKSTP_OUT pin */ /* XXX: Note that the only way to restart the CPU is to reset it */ if (level) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: stop the CPU\n", __func__); } #endif env->halted = 1; } break; case PPC6xx_INPUT_HRESET: /* Level sensitive - active low */ if (level) { #if 0 // XXX: TOFIX #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: reset the CPU\n", __func__); } #endif cpu_reset(env); #endif } break; case PPC6xx_INPUT_SRESET: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the RESET IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_RESET, level); break; default: /* Unknown pin - do nothing */ #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin); } #endif return; } if (level) env->irq_input_state |= 1 << pin; else env->irq_input_state &= ~(1 << pin); } }
true
qemu
ef397e88e96d4a798bd190bcd0c43865c3725ae2
static void ppc6xx_set_irq (void *opaque, int pin, int level) { CPUState *env = opaque; int cur_level; #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, env, pin, level); } #endif cur_level = (env->irq_input_state >> pin) & 1; if ((cur_level == 1 && level == 0) || (cur_level == 0 && level != 0)) { switch (pin) { case PPC6xx_INPUT_TBEN: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: %s the time base\n", __func__, level ? "start" : "stop"); } #endif if (level) { cpu_ppc_tb_start(env); } else { cpu_ppc_tb_stop(env); } case PPC6xx_INPUT_INT: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the external IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_EXT, level); break; case PPC6xx_INPUT_SMI: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the SMI IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_SMI, level); break; case PPC6xx_INPUT_MCP: if (cur_level == 1 && level == 0) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: raise machine check state\n", __func__); } #endif ppc_set_irq(env, PPC_INTERRUPT_MCK, 1); } break; case PPC6xx_INPUT_CKSTP_IN: if (level) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: stop the CPU\n", __func__); } #endif env->halted = 1; } break; case PPC6xx_INPUT_HRESET: if (level) { #if 0 #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: reset the CPU\n", __func__); } #endif cpu_reset(env); #endif } break; case PPC6xx_INPUT_SRESET: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the RESET IRQ state to %d\n", __func__, level); } #endif ppc_set_irq(env, PPC_INTERRUPT_RESET, level); break; default: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin); } #endif return; } if (level) env->irq_input_state |= 1 << pin; else env->irq_input_state &= ~(1 << pin); } }
{ "code": [ " cpu_reset(env);" ], "line_no": [ 171 ] }
static void FUNC_0 (void *VAR_0, int VAR_1, int VAR_2) { CPUState *env = VAR_0; int VAR_3; #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: env %p VAR_1 %d VAR_2 %d\n", __func__, env, VAR_1, VAR_2); } #endif VAR_3 = (env->irq_input_state >> VAR_1) & 1; if ((VAR_3 == 1 && VAR_2 == 0) || (VAR_3 == 0 && VAR_2 != 0)) { switch (VAR_1) { case PPC6xx_INPUT_TBEN: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: %s the time base\n", __func__, VAR_2 ? "start" : "stop"); } #endif if (VAR_2) { cpu_ppc_tb_start(env); } else { cpu_ppc_tb_stop(env); } case PPC6xx_INPUT_INT: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the external IRQ state to %d\n", __func__, VAR_2); } #endif ppc_set_irq(env, PPC_INTERRUPT_EXT, VAR_2); break; case PPC6xx_INPUT_SMI: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the SMI IRQ state to %d\n", __func__, VAR_2); } #endif ppc_set_irq(env, PPC_INTERRUPT_SMI, VAR_2); break; case PPC6xx_INPUT_MCP: if (VAR_3 == 1 && VAR_2 == 0) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: raise machine check state\n", __func__); } #endif ppc_set_irq(env, PPC_INTERRUPT_MCK, 1); } break; case PPC6xx_INPUT_CKSTP_IN: if (VAR_2) { #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: stop the CPU\n", __func__); } #endif env->halted = 1; } break; case PPC6xx_INPUT_HRESET: if (VAR_2) { #if 0 #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: reset the CPU\n", __func__); } #endif cpu_reset(env); #endif } break; case PPC6xx_INPUT_SRESET: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: set the RESET IRQ state to %d\n", __func__, VAR_2); } #endif ppc_set_irq(env, PPC_INTERRUPT_RESET, VAR_2); break; default: #if defined(PPC_DEBUG_IRQ) if (loglevel & CPU_LOG_INT) { fprintf(logfile, "%s: unknown IRQ VAR_1 %d\n", __func__, VAR_1); } #endif return; } if (VAR_2) env->irq_input_state |= 1 << VAR_1; else env->irq_input_state &= ~(1 << VAR_1); } }
[ "static void FUNC_0 (void *VAR_0, int VAR_1, int VAR_2)\n{", "CPUState *env = VAR_0;", "int VAR_3;", "#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: env %p VAR_1 %d VAR_2 %d\\n\", __func__,\nenv, VAR_1, VAR_2);", "}", "#endif\nVAR_3 = (env->irq_input_state >> VAR_1) & 1;", "if ((VAR_3 == 1 && VAR_2 == 0) || (VAR_3 == 0 && VAR_2 != 0)) {", "switch (VAR_1) {", "case PPC6xx_INPUT_TBEN:\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: %s the time base\\n\",\n__func__, VAR_2 ? \"start\" : \"stop\");", "}", "#endif\nif (VAR_2) {", "cpu_ppc_tb_start(env);", "} else {", "cpu_ppc_tb_stop(env);", "}", "case PPC6xx_INPUT_INT:\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: set the external IRQ state to %d\\n\",\n__func__, VAR_2);", "}", "#endif\nppc_set_irq(env, PPC_INTERRUPT_EXT, VAR_2);", "break;", "case PPC6xx_INPUT_SMI:\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: set the SMI IRQ state to %d\\n\",\n__func__, VAR_2);", "}", "#endif\nppc_set_irq(env, PPC_INTERRUPT_SMI, VAR_2);", "break;", "case PPC6xx_INPUT_MCP:\nif (VAR_3 == 1 && VAR_2 == 0) {", "#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: raise machine check state\\n\",\n__func__);", "}", "#endif\nppc_set_irq(env, PPC_INTERRUPT_MCK, 1);", "}", "break;", "case PPC6xx_INPUT_CKSTP_IN:\nif (VAR_2) {", "#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: stop the CPU\\n\", __func__);", "}", "#endif\nenv->halted = 1;", "}", "break;", "case PPC6xx_INPUT_HRESET:\nif (VAR_2) {", "#if 0\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: reset the CPU\\n\", __func__);", "}", "#endif\ncpu_reset(env);", "#endif\n}", "break;", "case PPC6xx_INPUT_SRESET:\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: set the RESET IRQ state to %d\\n\",\n__func__, VAR_2);", "}", "#endif\nppc_set_irq(env, PPC_INTERRUPT_RESET, VAR_2);", "break;", "default:\n#if defined(PPC_DEBUG_IRQ)\nif (loglevel & CPU_LOG_INT) {", "fprintf(logfile, \"%s: unknown IRQ VAR_1 %d\\n\", __func__, VAR_1);", "}", "#endif\nreturn;", "}", "if (VAR_2)\nenv->irq_input_state |= 1 << VAR_1;", "else\nenv->irq_input_state &= ~(1 << 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, 1, 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 ], [ 27 ], [ 29 ], [ 31, 35, 37 ], [ 39, 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57, 61, 63 ], [ 65, 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77, 81, 83 ], [ 85, 87 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97, 107 ], [ 109, 111 ], [ 113, 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127, 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145, 147 ], [ 149 ], [ 151 ], [ 153, 157 ], [ 159, 161, 163 ], [ 165 ], [ 167 ], [ 169, 171 ], [ 173, 175 ], [ 177 ], [ 179, 181, 183 ], [ 185, 187 ], [ 189 ], [ 191, 193 ], [ 195 ], [ 197, 201, 203 ], [ 205 ], [ 207 ], [ 209, 211 ], [ 213 ], [ 215, 217 ], [ 219, 221 ], [ 223 ], [ 225 ] ]
5,989
static void do_order_test(void) { Coroutine *co; co = qemu_coroutine_create(co_order_test); record_push(1, 1); qemu_coroutine_enter(co, NULL); record_push(1, 2); g_assert(!qemu_in_coroutine()); qemu_coroutine_enter(co, NULL); record_push(1, 3); g_assert(!qemu_in_coroutine()); }
true
qemu
0b8b8753e4d94901627b3e86431230f2319215c4
static void do_order_test(void) { Coroutine *co; co = qemu_coroutine_create(co_order_test); record_push(1, 1); qemu_coroutine_enter(co, NULL); record_push(1, 2); g_assert(!qemu_in_coroutine()); qemu_coroutine_enter(co, NULL); record_push(1, 3); g_assert(!qemu_in_coroutine()); }
{ "code": [ " qemu_coroutine_enter(co, NULL);", " qemu_coroutine_enter(co, NULL);", " qemu_coroutine_enter(co, NULL);", " qemu_coroutine_enter(co, NULL);", " qemu_coroutine_enter(co, NULL);", " co = qemu_coroutine_create(co_order_test);", " qemu_coroutine_enter(co, NULL);", " qemu_coroutine_enter(co, NULL);" ], "line_no": [ 13, 13, 13, 13, 13, 9, 13, 13 ] }
static void FUNC_0(void) { Coroutine *co; co = qemu_coroutine_create(co_order_test); record_push(1, 1); qemu_coroutine_enter(co, NULL); record_push(1, 2); g_assert(!qemu_in_coroutine()); qemu_coroutine_enter(co, NULL); record_push(1, 3); g_assert(!qemu_in_coroutine()); }
[ "static void FUNC_0(void)\n{", "Coroutine *co;", "co = qemu_coroutine_create(co_order_test);", "record_push(1, 1);", "qemu_coroutine_enter(co, NULL);", "record_push(1, 2);", "g_assert(!qemu_in_coroutine());", "qemu_coroutine_enter(co, NULL);", "record_push(1, 3);", "g_assert(!qemu_in_coroutine());", "}" ]
[ 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
5,990
static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties) { Jpeg2000CodingStyle tmp; int compno; if (s->buf_end - s->buf < 5) return AVERROR_INVALIDDATA; tmp.log2_prec_width = tmp.log2_prec_height = 15; tmp.csty = bytestream_get_byte(&s->buf); // get progression order tmp.prog_order = bytestream_get_byte(&s->buf); tmp.nlayers = bytestream_get_be16(&s->buf); tmp.mct = bytestream_get_byte(&s->buf); // multiple component transformation get_cox(s, &tmp); for (compno = 0; compno < s->ncomponents; compno++) if (!(properties[compno] & HAD_COC)) memcpy(c + compno, &tmp, sizeof(tmp)); return 0; }
true
FFmpeg
1a3598aae768465a8efc8475b6df5a8261bc62fc
static int get_cod(Jpeg2000DecoderContext *s, Jpeg2000CodingStyle *c, uint8_t *properties) { Jpeg2000CodingStyle tmp; int compno; if (s->buf_end - s->buf < 5) return AVERROR_INVALIDDATA; tmp.log2_prec_width = tmp.log2_prec_height = 15; tmp.csty = bytestream_get_byte(&s->buf); tmp.prog_order = bytestream_get_byte(&s->buf); tmp.nlayers = bytestream_get_be16(&s->buf); tmp.mct = bytestream_get_byte(&s->buf); get_cox(s, &tmp); for (compno = 0; compno < s->ncomponents; compno++) if (!(properties[compno] & HAD_COC)) memcpy(c + compno, &tmp, sizeof(tmp)); return 0; }
{ "code": [ " return AVERROR_INVALIDDATA;", " if (s->buf_end - s->buf < 5)", " if (s->buf_end - s->buf < 5)", " tmp.csty = bytestream_get_byte(&s->buf);", " tmp.prog_order = bytestream_get_byte(&s->buf);", " tmp.nlayers = bytestream_get_be16(&s->buf);" ], "line_no": [ 15, 13, 13, 25, 31, 35 ] }
static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1, uint8_t *VAR_2) { Jpeg2000CodingStyle tmp; int VAR_3; if (VAR_0->buf_end - VAR_0->buf < 5) return AVERROR_INVALIDDATA; tmp.log2_prec_width = tmp.log2_prec_height = 15; tmp.csty = bytestream_get_byte(&VAR_0->buf); tmp.prog_order = bytestream_get_byte(&VAR_0->buf); tmp.nlayers = bytestream_get_be16(&VAR_0->buf); tmp.mct = bytestream_get_byte(&VAR_0->buf); get_cox(VAR_0, &tmp); for (VAR_3 = 0; VAR_3 < VAR_0->ncomponents; VAR_3++) if (!(VAR_2[VAR_3] & HAD_COC)) memcpy(VAR_1 + VAR_3, &tmp, sizeof(tmp)); return 0; }
[ "static int FUNC_0(Jpeg2000DecoderContext *VAR_0, Jpeg2000CodingStyle *VAR_1,\nuint8_t *VAR_2)\n{", "Jpeg2000CodingStyle tmp;", "int VAR_3;", "if (VAR_0->buf_end - VAR_0->buf < 5)\nreturn AVERROR_INVALIDDATA;", "tmp.log2_prec_width =\ntmp.log2_prec_height = 15;", "tmp.csty = bytestream_get_byte(&VAR_0->buf);", "tmp.prog_order = bytestream_get_byte(&VAR_0->buf);", "tmp.nlayers = bytestream_get_be16(&VAR_0->buf);", "tmp.mct = bytestream_get_byte(&VAR_0->buf);", "get_cox(VAR_0, &tmp);", "for (VAR_3 = 0; VAR_3 < VAR_0->ncomponents; VAR_3++)", "if (!(VAR_2[VAR_3] & HAD_COC))\nmemcpy(VAR_1 + VAR_3, &tmp, sizeof(tmp));", "return 0;", "}" ]
[ 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13, 15 ], [ 19, 21 ], [ 25 ], [ 31 ], [ 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ] ]
5,991
static void qtest_process_command(CharDriverState *chr, gchar **words) { const gchar *command; g_assert(words); command = words[0]; if (qtest_log_fp) { qemu_timeval tv; int i; qtest_get_time(&tv); fprintf(qtest_log_fp, "[R +" FMT_timeval "]", (long) tv.tv_sec, (long) tv.tv_usec); for (i = 0; words[i]; i++) { fprintf(qtest_log_fp, " %s", words[i]); } fprintf(qtest_log_fp, "\n"); } g_assert(command); if (strcmp(words[0], "irq_intercept_out") == 0 || strcmp(words[0], "irq_intercept_in") == 0) { DeviceState *dev; NamedGPIOList *ngl; g_assert(words[1]); dev = DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown device\n"); return; } if (irq_intercept_dev) { qtest_send_prefix(chr); if (irq_intercept_dev != dev) { qtest_send(chr, "FAIL IRQ intercept already enabled\n"); } else { qtest_send(chr, "OK\n"); } return; } QLIST_FOREACH(ngl, &dev->gpios, node) { /* We don't support intercept of named GPIOs yet */ if (ngl->name) { continue; } if (words[0][14] == 'o') { int i; for (i = 0; i < ngl->num_out; ++i) { qemu_irq *disconnected = g_new0(qemu_irq, 1); qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, disconnected, i); *disconnected = qdev_intercept_gpio_out(dev, icpt, ngl->name, i); } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, ngl->num_in); } } irq_intercept_dev = dev; qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "outb") == 0 || strcmp(words[0], "outw") == 0 || strcmp(words[0], "outl") == 0) { uint16_t addr; uint32_t value; g_assert(words[1] && words[2]); addr = strtoul(words[1], NULL, 0); value = strtoul(words[2], NULL, 0); if (words[0][3] == 'b') { cpu_outb(addr, value); } else if (words[0][3] == 'w') { cpu_outw(addr, value); } else if (words[0][3] == 'l') { cpu_outl(addr, value); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "inb") == 0 || strcmp(words[0], "inw") == 0 || strcmp(words[0], "inl") == 0) { uint16_t addr; uint32_t value = -1U; g_assert(words[1]); addr = strtoul(words[1], NULL, 0); if (words[0][2] == 'b') { value = cpu_inb(addr); } else if (words[0][2] == 'w') { value = cpu_inw(addr); } else if (words[0][2] == 'l') { value = cpu_inl(addr); } qtest_send_prefix(chr); qtest_send(chr, "OK 0x%04x\n", value); } else if (strcmp(words[0], "writeb") == 0 || strcmp(words[0], "writew") == 0 || strcmp(words[0], "writel") == 0 || strcmp(words[0], "writeq") == 0) { uint64_t addr; uint64_t value; g_assert(words[1] && words[2]); addr = strtoull(words[1], NULL, 0); value = strtoull(words[2], NULL, 0); if (words[0][5] == 'b') { uint8_t data = value; cpu_physical_memory_write(addr, &data, 1); } else if (words[0][5] == 'w') { uint16_t data = value; tswap16s(&data); cpu_physical_memory_write(addr, &data, 2); } else if (words[0][5] == 'l') { uint32_t data = value; tswap32s(&data); cpu_physical_memory_write(addr, &data, 4); } else if (words[0][5] == 'q') { uint64_t data = value; tswap64s(&data); cpu_physical_memory_write(addr, &data, 8); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "readb") == 0 || strcmp(words[0], "readw") == 0 || strcmp(words[0], "readl") == 0 || strcmp(words[0], "readq") == 0) { uint64_t addr; uint64_t value = UINT64_C(-1); g_assert(words[1]); addr = strtoull(words[1], NULL, 0); if (words[0][4] == 'b') { uint8_t data; cpu_physical_memory_read(addr, &data, 1); value = data; } else if (words[0][4] == 'w') { uint16_t data; cpu_physical_memory_read(addr, &data, 2); value = tswap16(data); } else if (words[0][4] == 'l') { uint32_t data; cpu_physical_memory_read(addr, &data, 4); value = tswap32(data); } else if (words[0][4] == 'q') { cpu_physical_memory_read(addr, &value, 8); tswap64s(&value); } qtest_send_prefix(chr); qtest_send(chr, "OK 0x%016" PRIx64 "\n", value); } else if (strcmp(words[0], "read") == 0) { uint64_t addr, len, i; uint8_t *data; g_assert(words[1] && words[2]); addr = strtoull(words[1], NULL, 0); len = strtoull(words[2], NULL, 0); data = g_malloc(len); cpu_physical_memory_read(addr, data, len); qtest_send_prefix(chr); qtest_send(chr, "OK 0x"); for (i = 0; i < len; i++) { qtest_send(chr, "%02x", data[i]); } qtest_send(chr, "\n"); g_free(data); } else if (strcmp(words[0], "write") == 0) { uint64_t addr, len, i; uint8_t *data; size_t data_len; g_assert(words[1] && words[2] && words[3]); addr = strtoull(words[1], NULL, 0); len = strtoull(words[2], NULL, 0); data_len = strlen(words[3]); if (data_len < 3) { qtest_send(chr, "ERR invalid argument size\n"); return; } data = g_malloc(len); for (i = 0; i < len; i++) { if ((i * 2 + 4) <= data_len) { data[i] = hex2nib(words[3][i * 2 + 2]) << 4; data[i] |= hex2nib(words[3][i * 2 + 3]); } else { data[i] = 0; } } cpu_physical_memory_write(addr, data, len); g_free(data); qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) { int64_t ns; if (words[1]) { ns = strtoll(words[1], NULL, 0); } else { ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); } qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) { int64_t ns; g_assert(words[1]); ns = strtoll(words[1], NULL, 0); qtest_clock_warp(ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown command `%s'\n", words[0]); } }
true
qemu
332cc7e9b39ddb2feacb4c71dcd18c3e5b0c3147
static void qtest_process_command(CharDriverState *chr, gchar **words) { const gchar *command; g_assert(words); command = words[0]; if (qtest_log_fp) { qemu_timeval tv; int i; qtest_get_time(&tv); fprintf(qtest_log_fp, "[R +" FMT_timeval "]", (long) tv.tv_sec, (long) tv.tv_usec); for (i = 0; words[i]; i++) { fprintf(qtest_log_fp, " %s", words[i]); } fprintf(qtest_log_fp, "\n"); } g_assert(command); if (strcmp(words[0], "irq_intercept_out") == 0 || strcmp(words[0], "irq_intercept_in") == 0) { DeviceState *dev; NamedGPIOList *ngl; g_assert(words[1]); dev = DEVICE(object_resolve_path(words[1], NULL)); if (!dev) { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown device\n"); return; } if (irq_intercept_dev) { qtest_send_prefix(chr); if (irq_intercept_dev != dev) { qtest_send(chr, "FAIL IRQ intercept already enabled\n"); } else { qtest_send(chr, "OK\n"); } return; } QLIST_FOREACH(ngl, &dev->gpios, node) { if (ngl->name) { continue; } if (words[0][14] == 'o') { int i; for (i = 0; i < ngl->num_out; ++i) { qemu_irq *disconnected = g_new0(qemu_irq, 1); qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, disconnected, i); *disconnected = qdev_intercept_gpio_out(dev, icpt, ngl->name, i); } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, ngl->num_in); } } irq_intercept_dev = dev; qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "outb") == 0 || strcmp(words[0], "outw") == 0 || strcmp(words[0], "outl") == 0) { uint16_t addr; uint32_t value; g_assert(words[1] && words[2]); addr = strtoul(words[1], NULL, 0); value = strtoul(words[2], NULL, 0); if (words[0][3] == 'b') { cpu_outb(addr, value); } else if (words[0][3] == 'w') { cpu_outw(addr, value); } else if (words[0][3] == 'l') { cpu_outl(addr, value); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "inb") == 0 || strcmp(words[0], "inw") == 0 || strcmp(words[0], "inl") == 0) { uint16_t addr; uint32_t value = -1U; g_assert(words[1]); addr = strtoul(words[1], NULL, 0); if (words[0][2] == 'b') { value = cpu_inb(addr); } else if (words[0][2] == 'w') { value = cpu_inw(addr); } else if (words[0][2] == 'l') { value = cpu_inl(addr); } qtest_send_prefix(chr); qtest_send(chr, "OK 0x%04x\n", value); } else if (strcmp(words[0], "writeb") == 0 || strcmp(words[0], "writew") == 0 || strcmp(words[0], "writel") == 0 || strcmp(words[0], "writeq") == 0) { uint64_t addr; uint64_t value; g_assert(words[1] && words[2]); addr = strtoull(words[1], NULL, 0); value = strtoull(words[2], NULL, 0); if (words[0][5] == 'b') { uint8_t data = value; cpu_physical_memory_write(addr, &data, 1); } else if (words[0][5] == 'w') { uint16_t data = value; tswap16s(&data); cpu_physical_memory_write(addr, &data, 2); } else if (words[0][5] == 'l') { uint32_t data = value; tswap32s(&data); cpu_physical_memory_write(addr, &data, 4); } else if (words[0][5] == 'q') { uint64_t data = value; tswap64s(&data); cpu_physical_memory_write(addr, &data, 8); } qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (strcmp(words[0], "readb") == 0 || strcmp(words[0], "readw") == 0 || strcmp(words[0], "readl") == 0 || strcmp(words[0], "readq") == 0) { uint64_t addr; uint64_t value = UINT64_C(-1); g_assert(words[1]); addr = strtoull(words[1], NULL, 0); if (words[0][4] == 'b') { uint8_t data; cpu_physical_memory_read(addr, &data, 1); value = data; } else if (words[0][4] == 'w') { uint16_t data; cpu_physical_memory_read(addr, &data, 2); value = tswap16(data); } else if (words[0][4] == 'l') { uint32_t data; cpu_physical_memory_read(addr, &data, 4); value = tswap32(data); } else if (words[0][4] == 'q') { cpu_physical_memory_read(addr, &value, 8); tswap64s(&value); } qtest_send_prefix(chr); qtest_send(chr, "OK 0x%016" PRIx64 "\n", value); } else if (strcmp(words[0], "read") == 0) { uint64_t addr, len, i; uint8_t *data; g_assert(words[1] && words[2]); addr = strtoull(words[1], NULL, 0); len = strtoull(words[2], NULL, 0); data = g_malloc(len); cpu_physical_memory_read(addr, data, len); qtest_send_prefix(chr); qtest_send(chr, "OK 0x"); for (i = 0; i < len; i++) { qtest_send(chr, "%02x", data[i]); } qtest_send(chr, "\n"); g_free(data); } else if (strcmp(words[0], "write") == 0) { uint64_t addr, len, i; uint8_t *data; size_t data_len; g_assert(words[1] && words[2] && words[3]); addr = strtoull(words[1], NULL, 0); len = strtoull(words[2], NULL, 0); data_len = strlen(words[3]); if (data_len < 3) { qtest_send(chr, "ERR invalid argument size\n"); return; } data = g_malloc(len); for (i = 0; i < len; i++) { if ((i * 2 + 4) <= data_len) { data[i] = hex2nib(words[3][i * 2 + 2]) << 4; data[i] |= hex2nib(words[3][i * 2 + 3]); } else { data[i] = 0; } } cpu_physical_memory_write(addr, data, len); g_free(data); qtest_send_prefix(chr); qtest_send(chr, "OK\n"); } else if (qtest_enabled() && strcmp(words[0], "clock_step") == 0) { int64_t ns; if (words[1]) { ns = strtoll(words[1], NULL, 0); } else { ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); } qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else if (qtest_enabled() && strcmp(words[0], "clock_set") == 0) { int64_t ns; g_assert(words[1]); ns = strtoll(words[1], NULL, 0); qtest_clock_warp(ns); qtest_send_prefix(chr); qtest_send(chr, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else { qtest_send_prefix(chr); qtest_send(chr, "FAIL Unknown command `%s'\n", words[0]); } }
{ "code": [ " qtest_send(chr, \"OK 0x%04x\\n\", value);", " qtest_send(chr, \"OK 0x%016\" PRIx64 \"\\n\", value);", " qtest_send(chr, \"%02x\", data[i]);", " qtest_send(chr, \"OK %\"PRIi64\"\\n\", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));", " qtest_send(chr, \"OK %\"PRIi64\"\\n\", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));", " qtest_send(chr, \"FAIL Unknown command `%s'\\n\", words[0]);" ], "line_no": [ 211, 325, 355, 443, 443, 465 ] }
static void FUNC_0(CharDriverState *VAR_0, gchar **VAR_1) { const gchar *VAR_2; g_assert(VAR_1); VAR_2 = VAR_1[0]; if (qtest_log_fp) { qemu_timeval tv; int VAR_3; qtest_get_time(&tv); fprintf(qtest_log_fp, "[R +" FMT_timeval "]", (long) tv.tv_sec, (long) tv.tv_usec); for (VAR_3 = 0; VAR_1[VAR_3]; VAR_3++) { fprintf(qtest_log_fp, " %s", VAR_1[VAR_3]); } fprintf(qtest_log_fp, "\n"); } g_assert(VAR_2); if (strcmp(VAR_1[0], "irq_intercept_out") == 0 || strcmp(VAR_1[0], "irq_intercept_in") == 0) { DeviceState *dev; NamedGPIOList *ngl; g_assert(VAR_1[1]); dev = DEVICE(object_resolve_path(VAR_1[1], NULL)); if (!dev) { qtest_send_prefix(VAR_0); qtest_send(VAR_0, "FAIL Unknown device\n"); return; } if (irq_intercept_dev) { qtest_send_prefix(VAR_0); if (irq_intercept_dev != dev) { qtest_send(VAR_0, "FAIL IRQ intercept already enabled\n"); } else { qtest_send(VAR_0, "OK\n"); } return; } QLIST_FOREACH(ngl, &dev->gpios, node) { if (ngl->name) { continue; } if (VAR_1[0][14] == 'o') { int VAR_3; for (VAR_3 = 0; VAR_3 < ngl->num_out; ++VAR_3) { qemu_irq *disconnected = g_new0(qemu_irq, 1); qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler, disconnected, VAR_3); *disconnected = qdev_intercept_gpio_out(dev, icpt, ngl->name, VAR_3); } } else { qemu_irq_intercept_in(ngl->in, qtest_irq_handler, ngl->num_in); } } irq_intercept_dev = dev; qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK\n"); } else if (strcmp(VAR_1[0], "outb") == 0 || strcmp(VAR_1[0], "outw") == 0 || strcmp(VAR_1[0], "outl") == 0) { uint16_t addr; uint32_t value; g_assert(VAR_1[1] && VAR_1[2]); addr = strtoul(VAR_1[1], NULL, 0); value = strtoul(VAR_1[2], NULL, 0); if (VAR_1[0][3] == 'b') { cpu_outb(addr, value); } else if (VAR_1[0][3] == 'w') { cpu_outw(addr, value); } else if (VAR_1[0][3] == 'l') { cpu_outl(addr, value); } qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK\n"); } else if (strcmp(VAR_1[0], "inb") == 0 || strcmp(VAR_1[0], "inw") == 0 || strcmp(VAR_1[0], "inl") == 0) { uint16_t addr; uint32_t value = -1U; g_assert(VAR_1[1]); addr = strtoul(VAR_1[1], NULL, 0); if (VAR_1[0][2] == 'b') { value = cpu_inb(addr); } else if (VAR_1[0][2] == 'w') { value = cpu_inw(addr); } else if (VAR_1[0][2] == 'l') { value = cpu_inl(addr); } qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK 0x%04x\n", value); } else if (strcmp(VAR_1[0], "writeb") == 0 || strcmp(VAR_1[0], "writew") == 0 || strcmp(VAR_1[0], "writel") == 0 || strcmp(VAR_1[0], "writeq") == 0) { uint64_t addr; uint64_t value; g_assert(VAR_1[1] && VAR_1[2]); addr = strtoull(VAR_1[1], NULL, 0); value = strtoull(VAR_1[2], NULL, 0); if (VAR_1[0][5] == 'b') { uint8_t data = value; cpu_physical_memory_write(addr, &data, 1); } else if (VAR_1[0][5] == 'w') { uint16_t data = value; tswap16s(&data); cpu_physical_memory_write(addr, &data, 2); } else if (VAR_1[0][5] == 'l') { uint32_t data = value; tswap32s(&data); cpu_physical_memory_write(addr, &data, 4); } else if (VAR_1[0][5] == 'q') { uint64_t data = value; tswap64s(&data); cpu_physical_memory_write(addr, &data, 8); } qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK\n"); } else if (strcmp(VAR_1[0], "readb") == 0 || strcmp(VAR_1[0], "readw") == 0 || strcmp(VAR_1[0], "readl") == 0 || strcmp(VAR_1[0], "readq") == 0) { uint64_t addr; uint64_t value = UINT64_C(-1); g_assert(VAR_1[1]); addr = strtoull(VAR_1[1], NULL, 0); if (VAR_1[0][4] == 'b') { uint8_t data; cpu_physical_memory_read(addr, &data, 1); value = data; } else if (VAR_1[0][4] == 'w') { uint16_t data; cpu_physical_memory_read(addr, &data, 2); value = tswap16(data); } else if (VAR_1[0][4] == 'l') { uint32_t data; cpu_physical_memory_read(addr, &data, 4); value = tswap32(data); } else if (VAR_1[0][4] == 'q') { cpu_physical_memory_read(addr, &value, 8); tswap64s(&value); } qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK 0x%016" PRIx64 "\n", value); } else if (strcmp(VAR_1[0], "read") == 0) { uint64_t addr, len, VAR_3; uint8_t *data; g_assert(VAR_1[1] && VAR_1[2]); addr = strtoull(VAR_1[1], NULL, 0); len = strtoull(VAR_1[2], NULL, 0); data = g_malloc(len); cpu_physical_memory_read(addr, data, len); qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK 0x"); for (VAR_3 = 0; VAR_3 < len; VAR_3++) { qtest_send(VAR_0, "%02x", data[VAR_3]); } qtest_send(VAR_0, "\n"); g_free(data); } else if (strcmp(VAR_1[0], "write") == 0) { uint64_t addr, len, VAR_3; uint8_t *data; size_t data_len; g_assert(VAR_1[1] && VAR_1[2] && VAR_1[3]); addr = strtoull(VAR_1[1], NULL, 0); len = strtoull(VAR_1[2], NULL, 0); data_len = strlen(VAR_1[3]); if (data_len < 3) { qtest_send(VAR_0, "ERR invalid argument size\n"); return; } data = g_malloc(len); for (VAR_3 = 0; VAR_3 < len; VAR_3++) { if ((VAR_3 * 2 + 4) <= data_len) { data[VAR_3] = hex2nib(VAR_1[3][VAR_3 * 2 + 2]) << 4; data[VAR_3] |= hex2nib(VAR_1[3][VAR_3 * 2 + 3]); } else { data[VAR_3] = 0; } } cpu_physical_memory_write(addr, data, len); g_free(data); qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK\n"); } else if (qtest_enabled() && strcmp(VAR_1[0], "clock_step") == 0) { int64_t ns; if (VAR_1[1]) { ns = strtoll(VAR_1[1], NULL, 0); } else { ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); } qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else if (qtest_enabled() && strcmp(VAR_1[0], "clock_set") == 0) { int64_t ns; g_assert(VAR_1[1]); ns = strtoll(VAR_1[1], NULL, 0); qtest_clock_warp(ns); qtest_send_prefix(VAR_0); qtest_send(VAR_0, "OK %"PRIi64"\n", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL)); } else { qtest_send_prefix(VAR_0); qtest_send(VAR_0, "FAIL Unknown VAR_2 `%s'\n", VAR_1[0]); } }
[ "static void FUNC_0(CharDriverState *VAR_0, gchar **VAR_1)\n{", "const gchar *VAR_2;", "g_assert(VAR_1);", "VAR_2 = VAR_1[0];", "if (qtest_log_fp) {", "qemu_timeval tv;", "int VAR_3;", "qtest_get_time(&tv);", "fprintf(qtest_log_fp, \"[R +\" FMT_timeval \"]\",\n(long) tv.tv_sec, (long) tv.tv_usec);", "for (VAR_3 = 0; VAR_1[VAR_3]; VAR_3++) {", "fprintf(qtest_log_fp, \" %s\", VAR_1[VAR_3]);", "}", "fprintf(qtest_log_fp, \"\\n\");", "}", "g_assert(VAR_2);", "if (strcmp(VAR_1[0], \"irq_intercept_out\") == 0\n|| strcmp(VAR_1[0], \"irq_intercept_in\") == 0) {", "DeviceState *dev;", "NamedGPIOList *ngl;", "g_assert(VAR_1[1]);", "dev = DEVICE(object_resolve_path(VAR_1[1], NULL));", "if (!dev) {", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"FAIL Unknown device\\n\");", "return;", "}", "if (irq_intercept_dev) {", "qtest_send_prefix(VAR_0);", "if (irq_intercept_dev != dev) {", "qtest_send(VAR_0, \"FAIL IRQ intercept already enabled\\n\");", "} else {", "qtest_send(VAR_0, \"OK\\n\");", "}", "return;", "}", "QLIST_FOREACH(ngl, &dev->gpios, node) {", "if (ngl->name) {", "continue;", "}", "if (VAR_1[0][14] == 'o') {", "int VAR_3;", "for (VAR_3 = 0; VAR_3 < ngl->num_out; ++VAR_3) {", "qemu_irq *disconnected = g_new0(qemu_irq, 1);", "qemu_irq icpt = qemu_allocate_irq(qtest_irq_handler,\ndisconnected, VAR_3);", "*disconnected = qdev_intercept_gpio_out(dev, icpt,\nngl->name, VAR_3);", "}", "} else {", "qemu_irq_intercept_in(ngl->in, qtest_irq_handler,\nngl->num_in);", "}", "}", "irq_intercept_dev = dev;", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK\\n\");", "} else if (strcmp(VAR_1[0], \"outb\") == 0 ||", "strcmp(VAR_1[0], \"outw\") == 0 ||\nstrcmp(VAR_1[0], \"outl\") == 0) {", "uint16_t addr;", "uint32_t value;", "g_assert(VAR_1[1] && VAR_1[2]);", "addr = strtoul(VAR_1[1], NULL, 0);", "value = strtoul(VAR_1[2], NULL, 0);", "if (VAR_1[0][3] == 'b') {", "cpu_outb(addr, value);", "} else if (VAR_1[0][3] == 'w') {", "cpu_outw(addr, value);", "} else if (VAR_1[0][3] == 'l') {", "cpu_outl(addr, value);", "}", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK\\n\");", "} else if (strcmp(VAR_1[0], \"inb\") == 0 ||", "strcmp(VAR_1[0], \"inw\") == 0 ||\nstrcmp(VAR_1[0], \"inl\") == 0) {", "uint16_t addr;", "uint32_t value = -1U;", "g_assert(VAR_1[1]);", "addr = strtoul(VAR_1[1], NULL, 0);", "if (VAR_1[0][2] == 'b') {", "value = cpu_inb(addr);", "} else if (VAR_1[0][2] == 'w') {", "value = cpu_inw(addr);", "} else if (VAR_1[0][2] == 'l') {", "value = cpu_inl(addr);", "}", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK 0x%04x\\n\", value);", "} else if (strcmp(VAR_1[0], \"writeb\") == 0 ||", "strcmp(VAR_1[0], \"writew\") == 0 ||\nstrcmp(VAR_1[0], \"writel\") == 0 ||\nstrcmp(VAR_1[0], \"writeq\") == 0) {", "uint64_t addr;", "uint64_t value;", "g_assert(VAR_1[1] && VAR_1[2]);", "addr = strtoull(VAR_1[1], NULL, 0);", "value = strtoull(VAR_1[2], NULL, 0);", "if (VAR_1[0][5] == 'b') {", "uint8_t data = value;", "cpu_physical_memory_write(addr, &data, 1);", "} else if (VAR_1[0][5] == 'w') {", "uint16_t data = value;", "tswap16s(&data);", "cpu_physical_memory_write(addr, &data, 2);", "} else if (VAR_1[0][5] == 'l') {", "uint32_t data = value;", "tswap32s(&data);", "cpu_physical_memory_write(addr, &data, 4);", "} else if (VAR_1[0][5] == 'q') {", "uint64_t data = value;", "tswap64s(&data);", "cpu_physical_memory_write(addr, &data, 8);", "}", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK\\n\");", "} else if (strcmp(VAR_1[0], \"readb\") == 0 ||", "strcmp(VAR_1[0], \"readw\") == 0 ||\nstrcmp(VAR_1[0], \"readl\") == 0 ||\nstrcmp(VAR_1[0], \"readq\") == 0) {", "uint64_t addr;", "uint64_t value = UINT64_C(-1);", "g_assert(VAR_1[1]);", "addr = strtoull(VAR_1[1], NULL, 0);", "if (VAR_1[0][4] == 'b') {", "uint8_t data;", "cpu_physical_memory_read(addr, &data, 1);", "value = data;", "} else if (VAR_1[0][4] == 'w') {", "uint16_t data;", "cpu_physical_memory_read(addr, &data, 2);", "value = tswap16(data);", "} else if (VAR_1[0][4] == 'l') {", "uint32_t data;", "cpu_physical_memory_read(addr, &data, 4);", "value = tswap32(data);", "} else if (VAR_1[0][4] == 'q') {", "cpu_physical_memory_read(addr, &value, 8);", "tswap64s(&value);", "}", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK 0x%016\" PRIx64 \"\\n\", value);", "} else if (strcmp(VAR_1[0], \"read\") == 0) {", "uint64_t addr, len, VAR_3;", "uint8_t *data;", "g_assert(VAR_1[1] && VAR_1[2]);", "addr = strtoull(VAR_1[1], NULL, 0);", "len = strtoull(VAR_1[2], NULL, 0);", "data = g_malloc(len);", "cpu_physical_memory_read(addr, data, len);", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK 0x\");", "for (VAR_3 = 0; VAR_3 < len; VAR_3++) {", "qtest_send(VAR_0, \"%02x\", data[VAR_3]);", "}", "qtest_send(VAR_0, \"\\n\");", "g_free(data);", "} else if (strcmp(VAR_1[0], \"write\") == 0) {", "uint64_t addr, len, VAR_3;", "uint8_t *data;", "size_t data_len;", "g_assert(VAR_1[1] && VAR_1[2] && VAR_1[3]);", "addr = strtoull(VAR_1[1], NULL, 0);", "len = strtoull(VAR_1[2], NULL, 0);", "data_len = strlen(VAR_1[3]);", "if (data_len < 3) {", "qtest_send(VAR_0, \"ERR invalid argument size\\n\");", "return;", "}", "data = g_malloc(len);", "for (VAR_3 = 0; VAR_3 < len; VAR_3++) {", "if ((VAR_3 * 2 + 4) <= data_len) {", "data[VAR_3] = hex2nib(VAR_1[3][VAR_3 * 2 + 2]) << 4;", "data[VAR_3] |= hex2nib(VAR_1[3][VAR_3 * 2 + 3]);", "} else {", "data[VAR_3] = 0;", "}", "}", "cpu_physical_memory_write(addr, data, len);", "g_free(data);", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK\\n\");", "} else if (qtest_enabled() && strcmp(VAR_1[0], \"clock_step\") == 0) {", "int64_t ns;", "if (VAR_1[1]) {", "ns = strtoll(VAR_1[1], NULL, 0);", "} else {", "ns = qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL);", "}", "qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns);", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK %\"PRIi64\"\\n\", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));", "} else if (qtest_enabled() && strcmp(VAR_1[0], \"clock_set\") == 0) {", "int64_t ns;", "g_assert(VAR_1[1]);", "ns = strtoll(VAR_1[1], NULL, 0);", "qtest_clock_warp(ns);", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"OK %\"PRIi64\"\\n\", (int64_t)qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));", "} else {", "qtest_send_prefix(VAR_0);", "qtest_send(VAR_0, \"FAIL Unknown VAR_2 `%s'\\n\", 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 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, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109, 111 ], [ 115, 117 ], [ 119 ], [ 121 ], [ 123, 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 147 ], [ 151 ], [ 153 ], [ 155 ], [ 159 ], [ 161 ], [ 163 ], [ 165 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179, 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213 ], [ 215, 217, 219 ], [ 221 ], [ 223 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ], [ 251 ], [ 253 ], [ 255 ], [ 257 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269 ], [ 271 ], [ 273, 275, 277 ], [ 279 ], [ 281 ], [ 285 ], [ 287 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 299 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 313 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 325 ], [ 327 ], [ 329 ], [ 331 ], [ 335 ], [ 337 ], [ 339 ], [ 343 ], [ 345 ], [ 349 ], [ 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 363 ], [ 365 ], [ 367 ], [ 369 ], [ 371 ], [ 375 ], [ 377 ], [ 379 ], [ 383 ], [ 385 ], [ 387 ], [ 389 ], [ 391 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 419 ], [ 421 ], [ 423 ], [ 425 ], [ 429 ], [ 431 ], [ 433 ], [ 435 ], [ 437 ], [ 439 ], [ 441 ], [ 443 ], [ 445 ], [ 447 ], [ 451 ], [ 453 ], [ 455 ], [ 457 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 467 ], [ 469 ] ]
5,992
static target_long monitor_get_msr (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); if (!env) return 0; return env->msr; }
true
qemu
09b9418c6d085a0728372aa760ebd10128a020b1
static target_long monitor_get_msr (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); if (!env) return 0; return env->msr; }
{ "code": [ " if (!env)", " if (!env)", " if (!env)", " if (!env)", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;", " if (!env)", " return 0;" ], "line_no": [ 7, 7, 7, 7, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9, 7, 9 ] }
static target_long FUNC_0 (const struct MonitorDef *md, int val) { CPUState *env = mon_get_cpu(); if (!env) return 0; return env->msr; }
[ "static target_long FUNC_0 (const struct MonitorDef *md, int val)\n{", "CPUState *env = mon_get_cpu();", "if (!env)\nreturn 0;", "return env->msr;", "}" ]
[ 0, 0, 1, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7, 9 ], [ 11 ], [ 13 ] ]
5,993
static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int y, h_size; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } h_size= (c->dstW+7)&~7; if(h_size*4 > FFABS(dstStride[0])) h_size-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" /* zero mm4 */ ); for (y= 0; y<srcSliceH; y++ ) { uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + y*srcStride[0]; uint8_t *_pu = src[1] + (y>>1)*srcStride[1]; uint8_t *_pv = src[2] + (y>>1)*srcStride[2]; long index= -h_size/2; /* this mmx assembly code deals with SINGLE scan line at a time, it convert 8 pixels in each iteration */ __asm__ __volatile__ ( /* load data for start of next scan line */ "movd (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */ "movd (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ "movq (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ // ".balign 16 \n\t" "1: \n\t" YUV2RGB /* convert RGB plane to RGB packed format, mm0 -> B, mm1 -> R, mm2 -> G, mm3 -> 0, mm4 -> GB, mm5 -> AR pixel 4-7, mm6 -> GB, mm7 -> AR pixel 0-3 */ "pxor %%mm3, %%mm3;" /* zero mm3 */ "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */ "movq %%mm1, %%mm7;" /* R7 R6 R5 R4 R3 R2 R1 R0 */ "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */ "movq %%mm1, %%mm5;" /* R7 R6 R5 R4 R3 R2 R1 R0 */ "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */ "punpcklbw %%mm3, %%mm7;" /* 00 R3 00 R2 00 R1 00 R0 */ "punpcklwd %%mm7, %%mm6;" /* 00 R1 B1 G1 00 R0 B0 G0 */ MOVNTQ " %%mm6, (%1);" /* Store ARGB1 ARGB0 */ "movq %%mm0, %%mm6;" /* B7 B6 B5 B4 B3 B2 B1 B0 */ "punpcklbw %%mm2, %%mm6;" /* G3 B3 G2 B2 G1 B1 G0 B0 */ "punpckhwd %%mm7, %%mm6;" /* 00 R3 G3 B3 00 R2 B3 G2 */ MOVNTQ " %%mm6, 8 (%1);" /* Store ARGB3 ARGB2 */ "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */ "punpckhbw %%mm3, %%mm5;" /* 00 R7 00 R6 00 R5 00 R4 */ "punpcklwd %%mm5, %%mm4;" /* 00 R5 B5 G5 00 R4 B4 G4 */ MOVNTQ " %%mm4, 16 (%1);" /* Store ARGB5 ARGB4 */ "movq %%mm0, %%mm4;" /* B7 B6 B5 B4 B3 B2 B1 B0 */ "punpckhbw %%mm2, %%mm4;" /* G7 B7 G6 B6 G5 B5 G4 B4 */ "punpckhwd %%mm5, %%mm4;" /* 00 R7 G7 B7 00 R6 B6 G6 */ MOVNTQ " %%mm4, 24 (%1);" /* Store ARGB7 ARGB6 */ "movd 4 (%2, %0), %%mm0;" /* Load 4 Cb 00 00 00 00 u3 u2 u1 u0 */ "movd 4 (%3, %0), %%mm1;" /* Load 4 Cr 00 00 00 00 v3 v2 v1 v0 */ "pxor %%mm4, %%mm4;" /* zero mm4 */ "movq 8 (%5, %0, 2), %%mm6;" /* Load 8 Y Y7 Y6 Y5 Y4 Y3 Y2 Y1 Y0 */ "add $32, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
true
FFmpeg
428098165de4c3edfe42c1b7f00627d287015863
static inline int RENAME(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int y, h_size; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } h_size= (c->dstW+7)&~7; if(h_size*4 > FFABS(dstStride[0])) h_size-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" ); for (y= 0; y<srcSliceH; y++ ) { uint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + y*srcStride[0]; uint8_t *_pu = src[1] + (y>>1)*srcStride[1]; uint8_t *_pv = src[2] + (y>>1)*srcStride[2]; long index= -h_size/2; __asm__ __volatile__ ( "movd (%2, %0), %%mm0;" "movd (%3, %0), %%mm1;" "movq (%5, %0, 2), %%mm6;" "1: \n\t" YUV2RGB "pxor %%mm3, %%mm3;" "movq %%mm0, %%mm6;" "movq %%mm1, %%mm7;" "movq %%mm0, %%mm4;" "movq %%mm1, %%mm5;" "punpcklbw %%mm2, %%mm6;" "punpcklbw %%mm3, %%mm7;" "punpcklwd %%mm7, %%mm6;" MOVNTQ " %%mm6, (%1);" "movq %%mm0, %%mm6;" "punpcklbw %%mm2, %%mm6;" "punpckhwd %%mm7, %%mm6;" MOVNTQ " %%mm6, 8 (%1);" "punpckhbw %%mm2, %%mm4;" "punpckhbw %%mm3, %%mm5;" "punpcklwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 16 (%1);" "movq %%mm0, %%mm4;" "punpckhbw %%mm2, %%mm4;" "punpckhwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 24 (%1);" "movd 4 (%2, %0), %%mm0;" "movd 4 (%3, %0), %%mm1;" "pxor %%mm4, %%mm4;" "movq 8 (%5, %0, 2), %%mm6;" "add $32, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
{ "code": [ " 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;", "\tuint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];", "\tuint8_t *_py = src[0] + y*srcStride[0];", "\tuint8_t *_pu = src[1] + (y>>1)*srcStride[1];", "\tuint8_t *_pv = src[2] + (y>>1)*srcStride[2];", "\tlong index= -h_size/2;", "\t __asm__ __volatile__ (", "\t\t \"1:\t\t\t\t\\n\\t\"", "\t\t \"add $4, %0\t\t\t\\n\\t\"", "\t\t \" js 1b\t\t\t\t\\n\\t\"", "\t\t : \"+r\" (index), \"+r\" (_image)", "\t\t : \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)", "\t\t );", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\tuint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];", "\tuint8_t *_py = src[0] + y*srcStride[0];", "\tuint8_t *_pu = src[1] + (y>>1)*srcStride[1];", "\tuint8_t *_pv = src[2] + (y>>1)*srcStride[2];", "\tlong index= -h_size/2;", "\t __asm__ __volatile__ (", "\t\t \"1:\t\t\t\t\\n\\t\"", "\t\t \"add $4, %0\t\t\t\\n\\t\"", "\t\t \" js 1b\t\t\t\t\\n\\t\"", "\t\t : \"+r\" (index), \"+r\" (_image)", "\t\t : \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)", "\t\t );", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\tuint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];", "\tuint8_t *_py = src[0] + y*srcStride[0];", "\tuint8_t *_pu = src[1] + (y>>1)*srcStride[1];", "\tuint8_t *_pv = src[2] + (y>>1)*srcStride[2];", "\tlong index= -h_size/2;", "\t __asm__ __volatile__ (", "\t\t \"1:\t\t\t\t\\n\\t\"", "\t\t \"add $4, %0\t\t\t\\n\\t\"", "\t\t \" js 1b\t\t\t\t\\n\\t\"", "\t\t : \"+r\" (index), \"+r\" (_image)", "\t\t : \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)", "\t\t );", " int srcSliceH, uint8_t* dst[], int dstStride[]){", "\tsrcStride[1] *= 2;", "\tsrcStride[2] *= 2;", "\tuint8_t *_image = dst[0] + (y+srcSliceY)*dstStride[0];", "\tuint8_t *_py = src[0] + y*srcStride[0];", "\tuint8_t *_pu = src[1] + (y>>1)*srcStride[1];", "\tuint8_t *_pv = src[2] + (y>>1)*srcStride[2];", "\tlong index= -h_size/2;", "\t __asm__ __volatile__ (", "\t\t \"1:\t\t\t\t\\n\\t\"", "\t\t \"add $32, %1\t\t\t\\n\\t\"", "\t\t \"add $4, %0\t\t\t\\n\\t\"", "\t\t \" js 1b\t\t\t\t\\n\\t\"", "\t\t : \"+r\" (index), \"+r\" (_image)", "\t\t : \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)", "\t\t );" ], "line_no": [ 3, 11, 13, 3, 11, 13, 3, 11, 13, 3, 11, 13, 31, 33, 35, 37, 39, 47, 59, 149, 151, 155, 157, 159, 3, 11, 13, 31, 33, 35, 37, 39, 47, 59, 149, 151, 155, 157, 159, 3, 11, 13, 31, 33, 35, 37, 39, 47, 59, 149, 151, 155, 157, 159, 3, 11, 13, 31, 33, 35, 37, 39, 47, 59, 147, 149, 151, 155, 157, 159 ] }
static inline int FUNC_0(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]){ int VAR_0, VAR_1; if(c->srcFormat == PIX_FMT_YUV422P){ srcStride[1] *= 2; srcStride[2] *= 2; } VAR_1= (c->dstW+7)&~7; if(VAR_1*4 > FFABS(dstStride[0])) VAR_1-=8; __asm__ __volatile__ ("pxor %mm4, %mm4;" ); for (VAR_0= 0; VAR_0<srcSliceH; VAR_0++ ) { uint8_t *_image = dst[0] + (VAR_0+srcSliceY)*dstStride[0]; uint8_t *_py = src[0] + VAR_0*srcStride[0]; uint8_t *_pu = src[1] + (VAR_0>>1)*srcStride[1]; uint8_t *_pv = src[2] + (VAR_0>>1)*srcStride[2]; long index= -VAR_1/2; __asm__ __volatile__ ( "movd (%2, %0), %%mm0;" "movd (%3, %0), %%mm1;" "movq (%5, %0, 2), %%mm6;" "1: \n\t" YUV2RGB "pxor %%mm3, %%mm3;" "movq %%mm0, %%mm6;" "movq %%mm1, %%mm7;" "movq %%mm0, %%mm4;" "movq %%mm1, %%mm5;" "punpcklbw %%mm2, %%mm6;" "punpcklbw %%mm3, %%mm7;" "punpcklwd %%mm7, %%mm6;" MOVNTQ " %%mm6, (%1);" "movq %%mm0, %%mm6;" "punpcklbw %%mm2, %%mm6;" "punpckhwd %%mm7, %%mm6;" MOVNTQ " %%mm6, 8 (%1);" "punpckhbw %%mm2, %%mm4;" "punpckhbw %%mm3, %%mm5;" "punpcklwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 16 (%1);" "movq %%mm0, %%mm4;" "punpckhbw %%mm2, %%mm4;" "punpckhwd %%mm5, %%mm4;" MOVNTQ " %%mm4, 24 (%1);" "movd 4 (%2, %0), %%mm0;" "movd 4 (%3, %0), %%mm1;" "pxor %%mm4, %%mm4;" "movq 8 (%5, %0, 2), %%mm6;" "add $32, %1 \n\t" "add $4, %0 \n\t" " js 1b \n\t" : "+r" (index), "+r" (_image) : "r" (_pu - index), "r" (_pv - index), "r"(&c->redDither), "r" (_py - 2*index) ); } __asm__ __volatile__ (EMMS); return srcSliceH; }
[ "static inline int FUNC_0(yuv420_rgb32)(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,\nint srcSliceH, uint8_t* dst[], int dstStride[]){", "int VAR_0, VAR_1;", "if(c->srcFormat == PIX_FMT_YUV422P){", "srcStride[1] *= 2;", "srcStride[2] *= 2;", "}", "VAR_1= (c->dstW+7)&~7;", "if(VAR_1*4 > FFABS(dstStride[0])) VAR_1-=8;", "__asm__ __volatile__ (\"pxor %mm4, %mm4;\" );", "for (VAR_0= 0; VAR_0<srcSliceH; VAR_0++ ) {", "uint8_t *_image = dst[0] + (VAR_0+srcSliceY)*dstStride[0];", "uint8_t *_py = src[0] + VAR_0*srcStride[0];", "uint8_t *_pu = src[1] + (VAR_0>>1)*srcStride[1];", "uint8_t *_pv = src[2] + (VAR_0>>1)*srcStride[2];", "long index= -VAR_1/2;", "__asm__ __volatile__ (\n\"movd (%2, %0), %%mm0;\"", "\"movd (%3, %0), %%mm1;\"", "\"movq (%5, %0, 2), %%mm6;\"", "\"1:\t\t\t\t\\n\\t\"\nYUV2RGB\n\"pxor %%mm3, %%mm3;\"", "\"movq %%mm0, %%mm6;\"", "\"movq %%mm1, %%mm7;\"", "\"movq %%mm0, %%mm4;\"", "\"movq %%mm1, %%mm5;\"", "\"punpcklbw %%mm2, %%mm6;\"", "\"punpcklbw %%mm3, %%mm7;\"", "\"punpcklwd %%mm7, %%mm6;\"", "MOVNTQ \" %%mm6, (%1);\"", "\"movq %%mm0, %%mm6;\"", "\"punpcklbw %%mm2, %%mm6;\"", "\"punpckhwd %%mm7, %%mm6;\"", "MOVNTQ \" %%mm6, 8 (%1);\"", "\"punpckhbw %%mm2, %%mm4;\"", "\"punpckhbw %%mm3, %%mm5;\"", "\"punpcklwd %%mm5, %%mm4;\"", "MOVNTQ \" %%mm4, 16 (%1);\"", "\"movq %%mm0, %%mm4;\"", "\"punpckhbw %%mm2, %%mm4;\"", "\"punpckhwd %%mm5, %%mm4;\"", "MOVNTQ \" %%mm4, 24 (%1);\"", "\"movd 4 (%2, %0), %%mm0;\"", "\"movd 4 (%3, %0), %%mm1;\"", "\"pxor %%mm4, %%mm4;\"", "\"movq 8 (%5, %0, 2), %%mm6;\"", "\"add $32, %1\t\t\t\\n\\t\"\n\"add $4, %0\t\t\t\\n\\t\"\n\" js 1b\t\t\t\t\\n\\t\"\n: \"+r\" (index), \"+r\" (_image)\n: \"r\" (_pu - index), \"r\" (_pv - index), \"r\"(&c->redDither), \"r\" (_py - 2*index)\n);", "}", "__asm__ __volatile__ (EMMS);", "return srcSliceH;", "}" ]
[ 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 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, 1, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 47, 51 ], [ 53 ], [ 55 ], [ 59, 61, 71 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 105 ], [ 107 ], [ 111 ], [ 113 ], [ 117 ], [ 119 ], [ 123 ], [ 125 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 141 ], [ 143 ], [ 147, 149, 151, 155, 157, 159 ], [ 161 ], [ 165 ], [ 167 ], [ 169 ] ]
5,994
static void gen_ld (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int base, int16_t offset) { const char *opn = "ld"; TCGv t0, t1; if (rt == 0 && env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) { /* Loongson CPU uses a load to zero register for prefetch. We emulate it as a NOP. On other CPU we must perform the actual memory access. */ MIPS_DEBUG("NOP"); return; } t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_base_offset_addr(ctx, t0, base, offset); switch (opc) { #if defined(TARGET_MIPS64) case OPC_LWU: save_cpu_state(ctx, 0); op_ld_lwu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lwu"; break; case OPC_LD: save_cpu_state(ctx, 0); op_ld_ld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ld"; break; case OPC_LLD: save_cpu_state(ctx, 0); op_ld_lld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lld"; break; case OPC_LDL: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(ldl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "ldl"; break; case OPC_LDR: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(ldr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "ldr"; break; case OPC_LDPC: save_cpu_state(ctx, 1); tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); op_ld_ld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ldpc"; break; #endif case OPC_LWPC: save_cpu_state(ctx, 1); tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); op_ld_lw(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lwpc"; break; case OPC_LW: save_cpu_state(ctx, 0); op_ld_lw(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lw"; break; case OPC_LH: save_cpu_state(ctx, 0); op_ld_lh(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lh"; break; case OPC_LHU: save_cpu_state(ctx, 0); op_ld_lhu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lhu"; break; case OPC_LB: save_cpu_state(ctx, 0); op_ld_lb(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lb"; break; case OPC_LBU: save_cpu_state(ctx, 0); op_ld_lbu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lbu"; break; case OPC_LWL: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(lwl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "lwl"; break; case OPC_LWR: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(lwr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "lwr"; break; case OPC_LL: save_cpu_state(ctx, 1); op_ld_ll(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ll"; break; } (void)opn; /* avoid a compiler warning */ MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]); tcg_temp_free(t0); tcg_temp_free(t1); }
true
qemu
b835e919f022d768abdf00e8dc94f1a23fdcab15
static void gen_ld (CPUState *env, DisasContext *ctx, uint32_t opc, int rt, int base, int16_t offset) { const char *opn = "ld"; TCGv t0, t1; if (rt == 0 && env->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) { MIPS_DEBUG("NOP"); return; } t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_base_offset_addr(ctx, t0, base, offset); switch (opc) { #if defined(TARGET_MIPS64) case OPC_LWU: save_cpu_state(ctx, 0); op_ld_lwu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lwu"; break; case OPC_LD: save_cpu_state(ctx, 0); op_ld_ld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ld"; break; case OPC_LLD: save_cpu_state(ctx, 0); op_ld_lld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lld"; break; case OPC_LDL: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(ldl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "ldl"; break; case OPC_LDR: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(ldr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "ldr"; break; case OPC_LDPC: save_cpu_state(ctx, 1); tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); op_ld_ld(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ldpc"; break; #endif case OPC_LWPC: save_cpu_state(ctx, 1); tcg_gen_movi_tl(t1, pc_relative_pc(ctx)); gen_op_addr_add(ctx, t0, t0, t1); op_ld_lw(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lwpc"; break; case OPC_LW: save_cpu_state(ctx, 0); op_ld_lw(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lw"; break; case OPC_LH: save_cpu_state(ctx, 0); op_ld_lh(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lh"; break; case OPC_LHU: save_cpu_state(ctx, 0); op_ld_lhu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lhu"; break; case OPC_LB: save_cpu_state(ctx, 0); op_ld_lb(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lb"; break; case OPC_LBU: save_cpu_state(ctx, 0); op_ld_lbu(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "lbu"; break; case OPC_LWL: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(lwl, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "lwl"; break; case OPC_LWR: save_cpu_state(ctx, 1); gen_load_gpr(t1, rt); gen_helper_3i(lwr, t1, t1, t0, ctx->mem_idx); gen_store_gpr(t1, rt); opn = "lwr"; break; case OPC_LL: save_cpu_state(ctx, 1); op_ld_ll(t0, t0, ctx); gen_store_gpr(t0, rt); opn = "ll"; break; } (void)opn; MIPS_DEBUG("%s %s, %d(%s)", opn, regnames[rt], offset, regnames[base]); tcg_temp_free(t0); tcg_temp_free(t1); }
{ "code": [ " save_cpu_state(ctx, 0);", " save_cpu_state(ctx, 1);", " save_cpu_state(ctx, 1);", " save_cpu_state(ctx, 0);", " save_cpu_state(ctx, 1);", " save_cpu_state(ctx, 1);" ], "line_no": [ 43, 79, 79, 43, 79, 79 ] }
static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2, int VAR_3, int VAR_4, int16_t VAR_5) { const char *VAR_6 = "ld"; TCGv t0, t1; if (VAR_3 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) { MIPS_DEBUG("NOP"); return; } t0 = tcg_temp_new(); t1 = tcg_temp_new(); gen_base_offset_addr(VAR_1, t0, VAR_4, VAR_5); switch (VAR_2) { #if defined(TARGET_MIPS64) case OPC_LWU: save_cpu_state(VAR_1, 0); op_ld_lwu(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lwu"; break; case OPC_LD: save_cpu_state(VAR_1, 0); op_ld_ld(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "ld"; break; case OPC_LLD: save_cpu_state(VAR_1, 0); op_ld_lld(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lld"; break; case OPC_LDL: save_cpu_state(VAR_1, 1); gen_load_gpr(t1, VAR_3); gen_helper_3i(ldl, t1, t1, t0, VAR_1->mem_idx); gen_store_gpr(t1, VAR_3); VAR_6 = "ldl"; break; case OPC_LDR: save_cpu_state(VAR_1, 1); gen_load_gpr(t1, VAR_3); gen_helper_3i(ldr, t1, t1, t0, VAR_1->mem_idx); gen_store_gpr(t1, VAR_3); VAR_6 = "ldr"; break; case OPC_LDPC: save_cpu_state(VAR_1, 1); tcg_gen_movi_tl(t1, pc_relative_pc(VAR_1)); gen_op_addr_add(VAR_1, t0, t0, t1); op_ld_ld(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "ldpc"; break; #endif case OPC_LWPC: save_cpu_state(VAR_1, 1); tcg_gen_movi_tl(t1, pc_relative_pc(VAR_1)); gen_op_addr_add(VAR_1, t0, t0, t1); op_ld_lw(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lwpc"; break; case OPC_LW: save_cpu_state(VAR_1, 0); op_ld_lw(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lw"; break; case OPC_LH: save_cpu_state(VAR_1, 0); op_ld_lh(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lh"; break; case OPC_LHU: save_cpu_state(VAR_1, 0); op_ld_lhu(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lhu"; break; case OPC_LB: save_cpu_state(VAR_1, 0); op_ld_lb(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lb"; break; case OPC_LBU: save_cpu_state(VAR_1, 0); op_ld_lbu(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "lbu"; break; case OPC_LWL: save_cpu_state(VAR_1, 1); gen_load_gpr(t1, VAR_3); gen_helper_3i(lwl, t1, t1, t0, VAR_1->mem_idx); gen_store_gpr(t1, VAR_3); VAR_6 = "lwl"; break; case OPC_LWR: save_cpu_state(VAR_1, 1); gen_load_gpr(t1, VAR_3); gen_helper_3i(lwr, t1, t1, t0, VAR_1->mem_idx); gen_store_gpr(t1, VAR_3); VAR_6 = "lwr"; break; case OPC_LL: save_cpu_state(VAR_1, 1); op_ld_ll(t0, t0, VAR_1); gen_store_gpr(t0, VAR_3); VAR_6 = "ll"; break; } (void)VAR_6; MIPS_DEBUG("%s %s, %d(%s)", VAR_6, regnames[VAR_3], VAR_5, regnames[VAR_4]); tcg_temp_free(t0); tcg_temp_free(t1); }
[ "static void FUNC_0 (CPUState *VAR_0, DisasContext *VAR_1, uint32_t VAR_2,\nint VAR_3, int VAR_4, int16_t VAR_5)\n{", "const char *VAR_6 = \"ld\";", "TCGv t0, t1;", "if (VAR_3 == 0 && VAR_0->insn_flags & (INSN_LOONGSON2E | INSN_LOONGSON2F)) {", "MIPS_DEBUG(\"NOP\");", "return;", "}", "t0 = tcg_temp_new();", "t1 = tcg_temp_new();", "gen_base_offset_addr(VAR_1, t0, VAR_4, VAR_5);", "switch (VAR_2) {", "#if defined(TARGET_MIPS64)\ncase OPC_LWU:\nsave_cpu_state(VAR_1, 0);", "op_ld_lwu(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lwu\";", "break;", "case OPC_LD:\nsave_cpu_state(VAR_1, 0);", "op_ld_ld(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"ld\";", "break;", "case OPC_LLD:\nsave_cpu_state(VAR_1, 0);", "op_ld_lld(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lld\";", "break;", "case OPC_LDL:\nsave_cpu_state(VAR_1, 1);", "gen_load_gpr(t1, VAR_3);", "gen_helper_3i(ldl, t1, t1, t0, VAR_1->mem_idx);", "gen_store_gpr(t1, VAR_3);", "VAR_6 = \"ldl\";", "break;", "case OPC_LDR:\nsave_cpu_state(VAR_1, 1);", "gen_load_gpr(t1, VAR_3);", "gen_helper_3i(ldr, t1, t1, t0, VAR_1->mem_idx);", "gen_store_gpr(t1, VAR_3);", "VAR_6 = \"ldr\";", "break;", "case OPC_LDPC:\nsave_cpu_state(VAR_1, 1);", "tcg_gen_movi_tl(t1, pc_relative_pc(VAR_1));", "gen_op_addr_add(VAR_1, t0, t0, t1);", "op_ld_ld(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"ldpc\";", "break;", "#endif\ncase OPC_LWPC:\nsave_cpu_state(VAR_1, 1);", "tcg_gen_movi_tl(t1, pc_relative_pc(VAR_1));", "gen_op_addr_add(VAR_1, t0, t0, t1);", "op_ld_lw(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lwpc\";", "break;", "case OPC_LW:\nsave_cpu_state(VAR_1, 0);", "op_ld_lw(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lw\";", "break;", "case OPC_LH:\nsave_cpu_state(VAR_1, 0);", "op_ld_lh(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lh\";", "break;", "case OPC_LHU:\nsave_cpu_state(VAR_1, 0);", "op_ld_lhu(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lhu\";", "break;", "case OPC_LB:\nsave_cpu_state(VAR_1, 0);", "op_ld_lb(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lb\";", "break;", "case OPC_LBU:\nsave_cpu_state(VAR_1, 0);", "op_ld_lbu(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"lbu\";", "break;", "case OPC_LWL:\nsave_cpu_state(VAR_1, 1);", "gen_load_gpr(t1, VAR_3);", "gen_helper_3i(lwl, t1, t1, t0, VAR_1->mem_idx);", "gen_store_gpr(t1, VAR_3);", "VAR_6 = \"lwl\";", "break;", "case OPC_LWR:\nsave_cpu_state(VAR_1, 1);", "gen_load_gpr(t1, VAR_3);", "gen_helper_3i(lwr, t1, t1, t0, VAR_1->mem_idx);", "gen_store_gpr(t1, VAR_3);", "VAR_6 = \"lwr\";", "break;", "case OPC_LL:\nsave_cpu_state(VAR_1, 1);", "op_ld_ll(t0, t0, VAR_1);", "gen_store_gpr(t0, VAR_3);", "VAR_6 = \"ll\";", "break;", "}", "(void)VAR_6;", "MIPS_DEBUG(\"%s %s, %d(%s)\", VAR_6, regnames[VAR_3], VAR_5, regnames[VAR_4]);", "tcg_temp_free(t0);", "tcg_temp_free(t1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39, 41, 43 ], [ 45 ], [ 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 ], [ 109 ], [ 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, 177 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199, 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 213, 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227, 229 ], [ 231 ], [ 233 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 245 ], [ 247 ], [ 249 ] ]
5,998
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen) { AACContext *ac = &latmctx->aac_ctx; AVCodecContext *avctx = ac->avctx; MPEG4AudioConfig m4ac = {0}; int config_start_bit = get_bits_count(gb); int sync_extension = 0; int bits_consumed, esize; if (asclen) { sync_extension = 1; asclen = FFMIN(asclen, get_bits_left(gb)); } else asclen = get_bits_left(gb); if (config_start_bit % 8) { av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific " "config not byte aligned.\n", 1); } bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, gb->buffer + (config_start_bit / 8), asclen, sync_extension); if (bits_consumed < 0) if (ac->m4ac.sample_rate != m4ac.sample_rate || ac->m4ac.chan_config != m4ac.chan_config) { av_log(avctx, AV_LOG_INFO, "audio config changed\n"); latmctx->initialized = 0; esize = (bits_consumed+7) / 8; if (avctx->extradata_size < esize) { av_free(avctx->extradata); avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); } avctx->extradata_size = esize; memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE); } skip_bits_long(gb, bits_consumed); return bits_consumed; }
true
FFmpeg
b5fc571e4f730579f328ae9cf77435cb7fddc53d
static int latm_decode_audio_specific_config(struct LATMContext *latmctx, GetBitContext *gb, int asclen) { AACContext *ac = &latmctx->aac_ctx; AVCodecContext *avctx = ac->avctx; MPEG4AudioConfig m4ac = {0}; int config_start_bit = get_bits_count(gb); int sync_extension = 0; int bits_consumed, esize; if (asclen) { sync_extension = 1; asclen = FFMIN(asclen, get_bits_left(gb)); } else asclen = get_bits_left(gb); if (config_start_bit % 8) { av_log_missing_feature(latmctx->aac_ctx.avctx, "audio specific " "config not byte aligned.\n", 1); } bits_consumed = decode_audio_specific_config(NULL, avctx, &m4ac, gb->buffer + (config_start_bit / 8), asclen, sync_extension); if (bits_consumed < 0) if (ac->m4ac.sample_rate != m4ac.sample_rate || ac->m4ac.chan_config != m4ac.chan_config) { av_log(avctx, AV_LOG_INFO, "audio config changed\n"); latmctx->initialized = 0; esize = (bits_consumed+7) / 8; if (avctx->extradata_size < esize) { av_free(avctx->extradata); avctx->extradata = av_malloc(esize + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); } avctx->extradata_size = esize; memcpy(avctx->extradata, gb->buffer + (config_start_bit/8), esize); memset(avctx->extradata+esize, 0, FF_INPUT_BUFFER_PADDING_SIZE); } skip_bits_long(gb, bits_consumed); return bits_consumed; }
{ "code": [], "line_no": [] }
static int FUNC_0(struct LATMContext *VAR_0, GetBitContext *VAR_1, int VAR_2) { AACContext *ac = &VAR_0->aac_ctx; AVCodecContext *avctx = ac->avctx; MPEG4AudioConfig m4ac = {0}; int VAR_3 = get_bits_count(VAR_1); int VAR_4 = 0; int VAR_5, VAR_6; if (VAR_2) { VAR_4 = 1; VAR_2 = FFMIN(VAR_2, get_bits_left(VAR_1)); } else VAR_2 = get_bits_left(VAR_1); if (VAR_3 % 8) { av_log_missing_feature(VAR_0->aac_ctx.avctx, "audio specific " "config not byte aligned.\n", 1); } VAR_5 = decode_audio_specific_config(NULL, avctx, &m4ac, VAR_1->buffer + (VAR_3 / 8), VAR_2, VAR_4); if (VAR_5 < 0) if (ac->m4ac.sample_rate != m4ac.sample_rate || ac->m4ac.chan_config != m4ac.chan_config) { av_log(avctx, AV_LOG_INFO, "audio config changed\n"); VAR_0->initialized = 0; VAR_6 = (VAR_5+7) / 8; if (avctx->extradata_size < VAR_6) { av_free(avctx->extradata); avctx->extradata = av_malloc(VAR_6 + FF_INPUT_BUFFER_PADDING_SIZE); if (!avctx->extradata) return AVERROR(ENOMEM); } avctx->extradata_size = VAR_6; memcpy(avctx->extradata, VAR_1->buffer + (VAR_3/8), VAR_6); memset(avctx->extradata+VAR_6, 0, FF_INPUT_BUFFER_PADDING_SIZE); } skip_bits_long(VAR_1, VAR_5); return VAR_5; }
[ "static int FUNC_0(struct LATMContext *VAR_0,\nGetBitContext *VAR_1, int VAR_2)\n{", "AACContext *ac = &VAR_0->aac_ctx;", "AVCodecContext *avctx = ac->avctx;", "MPEG4AudioConfig m4ac = {0};", "int VAR_3 = get_bits_count(VAR_1);", "int VAR_4 = 0;", "int VAR_5, VAR_6;", "if (VAR_2) {", "VAR_4 = 1;", "VAR_2 = FFMIN(VAR_2, get_bits_left(VAR_1));", "} else", "VAR_2 = get_bits_left(VAR_1);", "if (VAR_3 % 8) {", "av_log_missing_feature(VAR_0->aac_ctx.avctx, \"audio specific \"\n\"config not byte aligned.\\n\", 1);", "}", "VAR_5 = decode_audio_specific_config(NULL, avctx, &m4ac,\nVAR_1->buffer + (VAR_3 / 8),\nVAR_2, VAR_4);", "if (VAR_5 < 0)\nif (ac->m4ac.sample_rate != m4ac.sample_rate ||\nac->m4ac.chan_config != m4ac.chan_config) {", "av_log(avctx, AV_LOG_INFO, \"audio config changed\\n\");", "VAR_0->initialized = 0;", "VAR_6 = (VAR_5+7) / 8;", "if (avctx->extradata_size < VAR_6) {", "av_free(avctx->extradata);", "avctx->extradata = av_malloc(VAR_6 + FF_INPUT_BUFFER_PADDING_SIZE);", "if (!avctx->extradata)\nreturn AVERROR(ENOMEM);", "}", "avctx->extradata_size = VAR_6;", "memcpy(avctx->extradata, VAR_1->buffer + (VAR_3/8), VAR_6);", "memset(avctx->extradata+VAR_6, 0, FF_INPUT_BUFFER_PADDING_SIZE);", "}", "skip_bits_long(VAR_1, VAR_5);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 35, 37 ], [ 40 ], [ 44, 46, 48 ], [ 52, 57, 59 ], [ 63 ], [ 65 ], [ 69 ], [ 73 ], [ 75 ], [ 77 ], [ 79, 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ] ]
6,000
static void ehci_frame_timer(void *opaque) { EHCIState *ehci = opaque; int need_timer = 0; int64_t expire_time, t_now; uint64_t ns_elapsed; uint64_t uframes, skipped_uframes; int i; t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ns_elapsed = t_now - ehci->last_run_ns; uframes = ns_elapsed / UFRAME_TIMER_NS; if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) { need_timer++; if (uframes > (ehci->maxframes * 8)) { skipped_uframes = uframes - (ehci->maxframes * 8); ehci_update_frindex(ehci, skipped_uframes); ehci->last_run_ns += UFRAME_TIMER_NS * skipped_uframes; uframes -= skipped_uframes; DPRINTF("WARNING - EHCI skipped %d uframes\n", skipped_uframes); } for (i = 0; i < uframes; i++) { /* * If we're running behind schedule, we should not catch up * too fast, as that will make some guests unhappy: * 1) We must process a minimum of MIN_UFR_PER_TICK frames, * otherwise we will never catch up * 2) Process frames until the guest has requested an irq (IOC) */ if (i >= MIN_UFR_PER_TICK) { ehci_commit_irq(ehci); if ((ehci->usbsts & USBINTR_MASK) & ehci->usbintr) { break; } } if (ehci->periodic_sched_active) { ehci->periodic_sched_active--; } ehci_update_frindex(ehci, 1); if ((ehci->frindex & 7) == 0) { ehci_advance_periodic_state(ehci); } ehci->last_run_ns += UFRAME_TIMER_NS; } } else { ehci->periodic_sched_active = 0; ehci_update_frindex(ehci, uframes); ehci->last_run_ns += UFRAME_TIMER_NS * uframes; } if (ehci->periodic_sched_active) { ehci->async_stepdown = 0; } else if (ehci->async_stepdown < ehci->maxframes / 2) { ehci->async_stepdown++; } /* Async is not inside loop since it executes everything it can once * called */ if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) { need_timer++; ehci_advance_async_state(ehci); } ehci_commit_irq(ehci); if (ehci->usbsts_pending) { need_timer++; ehci->async_stepdown = 0; } if (ehci_enabled(ehci) && (ehci->usbintr & USBSTS_FLR)) { need_timer++; } if (need_timer) { /* If we've raised int, we speed up the timer, so that we quickly * notice any new packets queued up in response */ if (ehci->int_req_by_async && (ehci->usbsts & USBSTS_INT)) { expire_time = t_now + NANOSECONDS_PER_SECOND / (FRAME_TIMER_FREQ * 4); ehci->int_req_by_async = false; } else { expire_time = t_now + (NANOSECONDS_PER_SECOND * (ehci->async_stepdown+1) / FRAME_TIMER_FREQ); } timer_mod(ehci->frame_timer, expire_time); } }
true
qemu
3bfecee2cb71f21cd39d6183f18b446c01917573
static void ehci_frame_timer(void *opaque) { EHCIState *ehci = opaque; int need_timer = 0; int64_t expire_time, t_now; uint64_t ns_elapsed; uint64_t uframes, skipped_uframes; int i; t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ns_elapsed = t_now - ehci->last_run_ns; uframes = ns_elapsed / UFRAME_TIMER_NS; if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) { need_timer++; if (uframes > (ehci->maxframes * 8)) { skipped_uframes = uframes - (ehci->maxframes * 8); ehci_update_frindex(ehci, skipped_uframes); ehci->last_run_ns += UFRAME_TIMER_NS * skipped_uframes; uframes -= skipped_uframes; DPRINTF("WARNING - EHCI skipped %d uframes\n", skipped_uframes); } for (i = 0; i < uframes; i++) { if (i >= MIN_UFR_PER_TICK) { ehci_commit_irq(ehci); if ((ehci->usbsts & USBINTR_MASK) & ehci->usbintr) { break; } } if (ehci->periodic_sched_active) { ehci->periodic_sched_active--; } ehci_update_frindex(ehci, 1); if ((ehci->frindex & 7) == 0) { ehci_advance_periodic_state(ehci); } ehci->last_run_ns += UFRAME_TIMER_NS; } } else { ehci->periodic_sched_active = 0; ehci_update_frindex(ehci, uframes); ehci->last_run_ns += UFRAME_TIMER_NS * uframes; } if (ehci->periodic_sched_active) { ehci->async_stepdown = 0; } else if (ehci->async_stepdown < ehci->maxframes / 2) { ehci->async_stepdown++; } if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) { need_timer++; ehci_advance_async_state(ehci); } ehci_commit_irq(ehci); if (ehci->usbsts_pending) { need_timer++; ehci->async_stepdown = 0; } if (ehci_enabled(ehci) && (ehci->usbintr & USBSTS_FLR)) { need_timer++; } if (need_timer) { if (ehci->int_req_by_async && (ehci->usbsts & USBSTS_INT)) { expire_time = t_now + NANOSECONDS_PER_SECOND / (FRAME_TIMER_FREQ * 4); ehci->int_req_by_async = false; } else { expire_time = t_now + (NANOSECONDS_PER_SECOND * (ehci->async_stepdown+1) / FRAME_TIMER_FREQ); } timer_mod(ehci->frame_timer, expire_time); } }
{ "code": [ "static void ehci_frame_timer(void *opaque)" ], "line_no": [ 1 ] }
static void FUNC_0(void *VAR_0) { EHCIState *ehci = VAR_0; int VAR_1 = 0; int64_t expire_time, t_now; uint64_t ns_elapsed; uint64_t uframes, skipped_uframes; int VAR_2; t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); ns_elapsed = t_now - ehci->last_run_ns; uframes = ns_elapsed / UFRAME_TIMER_NS; if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) { VAR_1++; if (uframes > (ehci->maxframes * 8)) { skipped_uframes = uframes - (ehci->maxframes * 8); ehci_update_frindex(ehci, skipped_uframes); ehci->last_run_ns += UFRAME_TIMER_NS * skipped_uframes; uframes -= skipped_uframes; DPRINTF("WARNING - EHCI skipped %d uframes\n", skipped_uframes); } for (VAR_2 = 0; VAR_2 < uframes; VAR_2++) { if (VAR_2 >= MIN_UFR_PER_TICK) { ehci_commit_irq(ehci); if ((ehci->usbsts & USBINTR_MASK) & ehci->usbintr) { break; } } if (ehci->periodic_sched_active) { ehci->periodic_sched_active--; } ehci_update_frindex(ehci, 1); if ((ehci->frindex & 7) == 0) { ehci_advance_periodic_state(ehci); } ehci->last_run_ns += UFRAME_TIMER_NS; } } else { ehci->periodic_sched_active = 0; ehci_update_frindex(ehci, uframes); ehci->last_run_ns += UFRAME_TIMER_NS * uframes; } if (ehci->periodic_sched_active) { ehci->async_stepdown = 0; } else if (ehci->async_stepdown < ehci->maxframes / 2) { ehci->async_stepdown++; } if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) { VAR_1++; ehci_advance_async_state(ehci); } ehci_commit_irq(ehci); if (ehci->usbsts_pending) { VAR_1++; ehci->async_stepdown = 0; } if (ehci_enabled(ehci) && (ehci->usbintr & USBSTS_FLR)) { VAR_1++; } if (VAR_1) { if (ehci->int_req_by_async && (ehci->usbsts & USBSTS_INT)) { expire_time = t_now + NANOSECONDS_PER_SECOND / (FRAME_TIMER_FREQ * 4); ehci->int_req_by_async = false; } else { expire_time = t_now + (NANOSECONDS_PER_SECOND * (ehci->async_stepdown+1) / FRAME_TIMER_FREQ); } timer_mod(ehci->frame_timer, expire_time); } }
[ "static void FUNC_0(void *VAR_0)\n{", "EHCIState *ehci = VAR_0;", "int VAR_1 = 0;", "int64_t expire_time, t_now;", "uint64_t ns_elapsed;", "uint64_t uframes, skipped_uframes;", "int VAR_2;", "t_now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);", "ns_elapsed = t_now - ehci->last_run_ns;", "uframes = ns_elapsed / UFRAME_TIMER_NS;", "if (ehci_periodic_enabled(ehci) || ehci->pstate != EST_INACTIVE) {", "VAR_1++;", "if (uframes > (ehci->maxframes * 8)) {", "skipped_uframes = uframes - (ehci->maxframes * 8);", "ehci_update_frindex(ehci, skipped_uframes);", "ehci->last_run_ns += UFRAME_TIMER_NS * skipped_uframes;", "uframes -= skipped_uframes;", "DPRINTF(\"WARNING - EHCI skipped %d uframes\\n\", skipped_uframes);", "}", "for (VAR_2 = 0; VAR_2 < uframes; VAR_2++) {", "if (VAR_2 >= MIN_UFR_PER_TICK) {", "ehci_commit_irq(ehci);", "if ((ehci->usbsts & USBINTR_MASK) & ehci->usbintr) {", "break;", "}", "}", "if (ehci->periodic_sched_active) {", "ehci->periodic_sched_active--;", "}", "ehci_update_frindex(ehci, 1);", "if ((ehci->frindex & 7) == 0) {", "ehci_advance_periodic_state(ehci);", "}", "ehci->last_run_ns += UFRAME_TIMER_NS;", "}", "} else {", "ehci->periodic_sched_active = 0;", "ehci_update_frindex(ehci, uframes);", "ehci->last_run_ns += UFRAME_TIMER_NS * uframes;", "}", "if (ehci->periodic_sched_active) {", "ehci->async_stepdown = 0;", "} else if (ehci->async_stepdown < ehci->maxframes / 2) {", "ehci->async_stepdown++;", "}", "if (ehci_async_enabled(ehci) || ehci->astate != EST_INACTIVE) {", "VAR_1++;", "ehci_advance_async_state(ehci);", "}", "ehci_commit_irq(ehci);", "if (ehci->usbsts_pending) {", "VAR_1++;", "ehci->async_stepdown = 0;", "}", "if (ehci_enabled(ehci) && (ehci->usbintr & USBSTS_FLR)) {", "VAR_1++;", "}", "if (VAR_1) {", "if (ehci->int_req_by_async && (ehci->usbsts & USBSTS_INT)) {", "expire_time = t_now +\nNANOSECONDS_PER_SECOND / (FRAME_TIMER_FREQ * 4);", "ehci->int_req_by_async = false;", "} else {", "expire_time = t_now + (NANOSECONDS_PER_SECOND\n* (ehci->async_stepdown+1) / FRAME_TIMER_FREQ);", "}", "timer_mod(ehci->frame_timer, expire_time);", "}", "}" ]
[ 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147 ], [ 149 ], [ 151 ], [ 155 ], [ 161 ], [ 163, 165 ], [ 167 ], [ 169 ], [ 171, 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ] ]
6,001
int bdrv_inactivate_all(void) { BlockDriverState *bs = NULL; BdrvNextIterator it; int ret = 0; int pass; for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_acquire(bdrv_get_aio_context(bs)); } /* We do two passes of inactivation. The first pass calls to drivers' * .bdrv_inactivate callbacks recursively so all cache is flushed to disk; * the second pass sets the BDRV_O_INACTIVE flag so that no further write * is allowed. */ for (pass = 0; pass < 2; pass++) { for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { ret = bdrv_inactivate_recurse(bs, pass); if (ret < 0) { goto out; } } } out: for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_release(bdrv_get_aio_context(bs)); } return ret; }
true
qemu
5e003f17ec518cd96f5d2ac23ce9e14144426235
int bdrv_inactivate_all(void) { BlockDriverState *bs = NULL; BdrvNextIterator it; int ret = 0; int pass; for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_acquire(bdrv_get_aio_context(bs)); } for (pass = 0; pass < 2; pass++) { for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { ret = bdrv_inactivate_recurse(bs, pass); if (ret < 0) { goto out; } } } out: for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_release(bdrv_get_aio_context(bs)); } return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(void) { BlockDriverState *bs = NULL; BdrvNextIterator it; int VAR_0 = 0; int VAR_1; for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_acquire(bdrv_get_aio_context(bs)); } for (VAR_1 = 0; VAR_1 < 2; VAR_1++) { for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { VAR_0 = bdrv_inactivate_recurse(bs, VAR_1); if (VAR_0 < 0) { goto out; } } } out: for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) { aio_context_release(bdrv_get_aio_context(bs)); } return VAR_0; }
[ "int FUNC_0(void)\n{", "BlockDriverState *bs = NULL;", "BdrvNextIterator it;", "int VAR_0 = 0;", "int VAR_1;", "for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {", "aio_context_acquire(bdrv_get_aio_context(bs));", "}", "for (VAR_1 = 0; VAR_1 < 2; VAR_1++) {", "for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {", "VAR_0 = bdrv_inactivate_recurse(bs, VAR_1);", "if (VAR_0 < 0) {", "goto out;", "}", "}", "}", "out:\nfor (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {", "aio_context_release(bdrv_get_aio_context(bs));", "}", "return 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 ], [ 11 ], [ 15 ], [ 17 ], [ 19 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 40 ], [ 42 ], [ 44 ], [ 46 ], [ 50, 52 ], [ 54 ], [ 56 ], [ 60 ], [ 62 ] ]
6,002
static void x86_cpu_parse_featurestr(CPUState *cs, char *features, Error **errp) { X86CPU *cpu = X86_CPU(cs); char *featurestr; /* Single 'key=value" string being parsed */ FeatureWord w; /* Features to be added */ FeatureWordArray plus_features = { 0 }; /* Features to be removed */ FeatureWordArray minus_features = { 0 }; CPUX86State *env = &cpu->env; Error *local_err = NULL; featurestr = features ? strtok(features, ",") : NULL; while (featurestr) { char *val; if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, plus_features, &local_err); } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, minus_features, &local_err); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; feat2prop(featurestr); if (!strcmp(featurestr, "tsc-freq")) { int64_t tsc_freq; char *err; char num[32]; tsc_freq = qemu_strtosz_suffix_unit(val, &err, QEMU_STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *err) { error_setg(errp, "bad numerical value %s", val); return; } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", &local_err); } else { object_property_parse(OBJECT(cpu), val, featurestr, &local_err); } } else { feat2prop(featurestr); object_property_parse(OBJECT(cpu), "on", featurestr, &local_err); } if (local_err) { error_propagate(errp, local_err); return; } featurestr = strtok(NULL, ","); } if (cpu->host_features) { for (w = 0; w < FEATURE_WORDS; w++) { env->features[w] = x86_cpu_get_supported_feature_word(w, cpu->migratable); } } for (w = 0; w < FEATURE_WORDS; w++) { env->features[w] |= plus_features[w]; env->features[w] &= ~minus_features[w]; } }
false
qemu
dc15c0517b010a9444a2c05794dae980f2a2cbd9
static void x86_cpu_parse_featurestr(CPUState *cs, char *features, Error **errp) { X86CPU *cpu = X86_CPU(cs); char *featurestr; FeatureWord w; FeatureWordArray plus_features = { 0 }; FeatureWordArray minus_features = { 0 }; CPUX86State *env = &cpu->env; Error *local_err = NULL; featurestr = features ? strtok(features, ",") : NULL; while (featurestr) { char *val; if (featurestr[0] == '+') { add_flagname_to_bitmaps(featurestr + 1, plus_features, &local_err); } else if (featurestr[0] == '-') { add_flagname_to_bitmaps(featurestr + 1, minus_features, &local_err); } else if ((val = strchr(featurestr, '='))) { *val = 0; val++; feat2prop(featurestr); if (!strcmp(featurestr, "tsc-freq")) { int64_t tsc_freq; char *err; char num[32]; tsc_freq = qemu_strtosz_suffix_unit(val, &err, QEMU_STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *err) { error_setg(errp, "bad numerical value %s", val); return; } snprintf(num, sizeof(num), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), num, "tsc-frequency", &local_err); } else { object_property_parse(OBJECT(cpu), val, featurestr, &local_err); } } else { feat2prop(featurestr); object_property_parse(OBJECT(cpu), "on", featurestr, &local_err); } if (local_err) { error_propagate(errp, local_err); return; } featurestr = strtok(NULL, ","); } if (cpu->host_features) { for (w = 0; w < FEATURE_WORDS; w++) { env->features[w] = x86_cpu_get_supported_feature_word(w, cpu->migratable); } } for (w = 0; w < FEATURE_WORDS; w++) { env->features[w] |= plus_features[w]; env->features[w] &= ~minus_features[w]; } }
{ "code": [], "line_no": [] }
static void FUNC_0(CPUState *VAR_0, char *VAR_1, Error **VAR_2) { X86CPU *cpu = X86_CPU(VAR_0); char *VAR_3; FeatureWord w; FeatureWordArray plus_features = { 0 }; FeatureWordArray minus_features = { 0 }; CPUX86State *env = &cpu->env; Error *local_err = NULL; VAR_3 = VAR_1 ? strtok(VAR_1, ",") : NULL; while (VAR_3) { char *VAR_4; if (VAR_3[0] == '+') { add_flagname_to_bitmaps(VAR_3 + 1, plus_features, &local_err); } else if (VAR_3[0] == '-') { add_flagname_to_bitmaps(VAR_3 + 1, minus_features, &local_err); } else if ((VAR_4 = strchr(VAR_3, '='))) { *VAR_4 = 0; VAR_4++; feat2prop(VAR_3); if (!strcmp(VAR_3, "tsc-freq")) { int64_t tsc_freq; char *VAR_5; char VAR_6[32]; tsc_freq = qemu_strtosz_suffix_unit(VAR_4, &VAR_5, QEMU_STRTOSZ_DEFSUFFIX_B, 1000); if (tsc_freq < 0 || *VAR_5) { error_setg(VAR_2, "bad numerical value %s", VAR_4); return; } snprintf(VAR_6, sizeof(VAR_6), "%" PRId64, tsc_freq); object_property_parse(OBJECT(cpu), VAR_6, "tsc-frequency", &local_err); } else { object_property_parse(OBJECT(cpu), VAR_4, VAR_3, &local_err); } } else { feat2prop(VAR_3); object_property_parse(OBJECT(cpu), "on", VAR_3, &local_err); } if (local_err) { error_propagate(VAR_2, local_err); return; } VAR_3 = strtok(NULL, ","); } if (cpu->host_features) { for (w = 0; w < FEATURE_WORDS; w++) { env->VAR_1[w] = x86_cpu_get_supported_feature_word(w, cpu->migratable); } } for (w = 0; w < FEATURE_WORDS; w++) { env->VAR_1[w] |= plus_features[w]; env->VAR_1[w] &= ~minus_features[w]; } }
[ "static void FUNC_0(CPUState *VAR_0, char *VAR_1,\nError **VAR_2)\n{", "X86CPU *cpu = X86_CPU(VAR_0);", "char *VAR_3;", "FeatureWord w;", "FeatureWordArray plus_features = { 0 };", "FeatureWordArray minus_features = { 0 };", "CPUX86State *env = &cpu->env;", "Error *local_err = NULL;", "VAR_3 = VAR_1 ? strtok(VAR_1, \",\") : NULL;", "while (VAR_3) {", "char *VAR_4;", "if (VAR_3[0] == '+') {", "add_flagname_to_bitmaps(VAR_3 + 1, plus_features, &local_err);", "} else if (VAR_3[0] == '-') {", "add_flagname_to_bitmaps(VAR_3 + 1, minus_features, &local_err);", "} else if ((VAR_4 = strchr(VAR_3, '='))) {", "*VAR_4 = 0; VAR_4++;", "feat2prop(VAR_3);", "if (!strcmp(VAR_3, \"tsc-freq\")) {", "int64_t tsc_freq;", "char *VAR_5;", "char VAR_6[32];", "tsc_freq = qemu_strtosz_suffix_unit(VAR_4, &VAR_5,\nQEMU_STRTOSZ_DEFSUFFIX_B, 1000);", "if (tsc_freq < 0 || *VAR_5) {", "error_setg(VAR_2, \"bad numerical value %s\", VAR_4);", "return;", "}", "snprintf(VAR_6, sizeof(VAR_6), \"%\" PRId64, tsc_freq);", "object_property_parse(OBJECT(cpu), VAR_6, \"tsc-frequency\",\n&local_err);", "} else {", "object_property_parse(OBJECT(cpu), VAR_4, VAR_3, &local_err);", "}", "} else {", "feat2prop(VAR_3);", "object_property_parse(OBJECT(cpu), \"on\", VAR_3, &local_err);", "}", "if (local_err) {", "error_propagate(VAR_2, local_err);", "return;", "}", "VAR_3 = strtok(NULL, \",\");", "}", "if (cpu->host_features) {", "for (w = 0; w < FEATURE_WORDS; w++) {", "env->VAR_1[w] =\nx86_cpu_get_supported_feature_word(w, cpu->migratable);", "}", "}", "for (w = 0; w < FEATURE_WORDS; w++) {", "env->VAR_1[w] |= plus_features[w];", "env->VAR_1[w] &= ~minus_features[w];", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 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 ], [ 125 ], [ 127 ] ]
6,003
static void do_sendkey(const char *string) { uint8_t keycodes[16]; int nb_keycodes = 0; char keyname_buf[16]; char *separator; int keyname_len, keycode, i; while (1) { separator = strchr(string, '-'); keyname_len = separator ? separator - string : strlen(string); if (keyname_len > 0) { pstrcpy(keyname_buf, sizeof(keyname_buf), string); if (keyname_len > sizeof(keyname_buf) - 1) { term_printf("invalid key: '%s...'\n", keyname_buf); return; } if (nb_keycodes == sizeof(keycodes)) { term_printf("too many keys\n"); return; } keyname_buf[keyname_len] = 0; keycode = get_keycode(keyname_buf); if (keycode < 0) { term_printf("unknown key: '%s'\n", keyname_buf); return; } keycodes[nb_keycodes++] = keycode; } if (!separator) break; string = separator + 1; } /* key down events */ for(i = 0; i < nb_keycodes; i++) { keycode = keycodes[i]; if (keycode & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(keycode & 0x7f); } /* key up events */ for(i = nb_keycodes - 1; i >= 0; i--) { keycode = keycodes[i]; if (keycode & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(keycode | 0x80); } }
false
qemu
c8256f9d23bba4fac3b0b6a9e6e3dc12362cbe0b
static void do_sendkey(const char *string) { uint8_t keycodes[16]; int nb_keycodes = 0; char keyname_buf[16]; char *separator; int keyname_len, keycode, i; while (1) { separator = strchr(string, '-'); keyname_len = separator ? separator - string : strlen(string); if (keyname_len > 0) { pstrcpy(keyname_buf, sizeof(keyname_buf), string); if (keyname_len > sizeof(keyname_buf) - 1) { term_printf("invalid key: '%s...'\n", keyname_buf); return; } if (nb_keycodes == sizeof(keycodes)) { term_printf("too many keys\n"); return; } keyname_buf[keyname_len] = 0; keycode = get_keycode(keyname_buf); if (keycode < 0) { term_printf("unknown key: '%s'\n", keyname_buf); return; } keycodes[nb_keycodes++] = keycode; } if (!separator) break; string = separator + 1; } for(i = 0; i < nb_keycodes; i++) { keycode = keycodes[i]; if (keycode & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(keycode & 0x7f); } for(i = nb_keycodes - 1; i >= 0; i--) { keycode = keycodes[i]; if (keycode & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(keycode | 0x80); } }
{ "code": [], "line_no": [] }
static void FUNC_0(const char *VAR_0) { uint8_t keycodes[16]; int VAR_1 = 0; char VAR_2[16]; char *VAR_3; int VAR_4, VAR_5, VAR_6; while (1) { VAR_3 = strchr(VAR_0, '-'); VAR_4 = VAR_3 ? VAR_3 - VAR_0 : strlen(VAR_0); if (VAR_4 > 0) { pstrcpy(VAR_2, sizeof(VAR_2), VAR_0); if (VAR_4 > sizeof(VAR_2) - 1) { term_printf("invalid key: '%s...'\n", VAR_2); return; } if (VAR_1 == sizeof(keycodes)) { term_printf("too many keys\n"); return; } VAR_2[VAR_4] = 0; VAR_5 = get_keycode(VAR_2); if (VAR_5 < 0) { term_printf("unknown key: '%s'\n", VAR_2); return; } keycodes[VAR_1++] = VAR_5; } if (!VAR_3) break; VAR_0 = VAR_3 + 1; } for(VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) { VAR_5 = keycodes[VAR_6]; if (VAR_5 & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(VAR_5 & 0x7f); } for(VAR_6 = VAR_1 - 1; VAR_6 >= 0; VAR_6--) { VAR_5 = keycodes[VAR_6]; if (VAR_5 & 0x80) kbd_put_keycode(0xe0); kbd_put_keycode(VAR_5 | 0x80); } }
[ "static void FUNC_0(const char *VAR_0)\n{", "uint8_t keycodes[16];", "int VAR_1 = 0;", "char VAR_2[16];", "char *VAR_3;", "int VAR_4, VAR_5, VAR_6;", "while (1) {", "VAR_3 = strchr(VAR_0, '-');", "VAR_4 = VAR_3 ? VAR_3 - VAR_0 : strlen(VAR_0);", "if (VAR_4 > 0) {", "pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);", "if (VAR_4 > sizeof(VAR_2) - 1) {", "term_printf(\"invalid key: '%s...'\\n\", VAR_2);", "return;", "}", "if (VAR_1 == sizeof(keycodes)) {", "term_printf(\"too many keys\\n\");", "return;", "}", "VAR_2[VAR_4] = 0;", "VAR_5 = get_keycode(VAR_2);", "if (VAR_5 < 0) {", "term_printf(\"unknown key: '%s'\\n\", VAR_2);", "return;", "}", "keycodes[VAR_1++] = VAR_5;", "}", "if (!VAR_3)\nbreak;", "VAR_0 = VAR_3 + 1;", "}", "for(VAR_6 = 0; VAR_6 < VAR_1; VAR_6++) {", "VAR_5 = keycodes[VAR_6];", "if (VAR_5 & 0x80)\nkbd_put_keycode(0xe0);", "kbd_put_keycode(VAR_5 & 0x7f);", "}", "for(VAR_6 = VAR_1 - 1; VAR_6 >= 0; VAR_6--) {", "VAR_5 = keycodes[VAR_6];", "if (VAR_5 & 0x80)\nkbd_put_keycode(0xe0);", "kbd_put_keycode(VAR_5 | 0x80);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73, 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87, 89 ], [ 91 ], [ 93 ], [ 95 ] ]
6,004
static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, Error **errp) { NBDClient *client = req->client; g_assert(qemu_in_coroutine()); assert(client->recv_coroutine == qemu_coroutine_self()); if (nbd_receive_request(client->ioc, request, errp) < 0) { return -EIO; } trace_nbd_co_receive_request_decode_type(request->handle, request->type); if (request->type != NBD_CMD_WRITE) { /* No payload, we are ready to read the next request. */ req->complete = true; } if (request->type == NBD_CMD_DISC) { /* Special case: we're going to disconnect without a reply, * whether or not flags, from, or len are bogus */ return -EIO; } /* Check for sanity in the parameters, part 1. Defer as many * checks as possible until after reading any NBD_CMD_WRITE * payload, so we can try and keep the connection alive. */ if ((request->from + request->len) < request->from) { error_setg(errp, "integer overflow detected, you're probably being attacked"); return -EINVAL; } if (request->type == NBD_CMD_READ || request->type == NBD_CMD_WRITE) { if (request->len > NBD_MAX_BUFFER_SIZE) { error_setg(errp, "len (%" PRIu32" ) is larger than max len (%u)", request->len, NBD_MAX_BUFFER_SIZE); return -EINVAL; } req->data = blk_try_blockalign(client->exp->blk, request->len); if (req->data == NULL) { error_setg(errp, "No memory"); return -ENOMEM; } } if (request->type == NBD_CMD_WRITE) { if (nbd_read(client->ioc, req->data, request->len, errp) < 0) { error_prepend(errp, "reading from socket failed: "); return -EIO; } req->complete = true; trace_nbd_co_receive_request_payload_received(request->handle, request->len); } /* Sanity checks, part 2. */ if (request->from + request->len > client->exp->size) { error_setg(errp, "operation past EOF; From: %" PRIu64 ", Len: %" PRIu32 ", Size: %" PRIu64, request->from, request->len, (uint64_t)client->exp->size); return request->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL; } if (request->flags & ~(NBD_CMD_FLAG_FUA | NBD_CMD_FLAG_NO_HOLE)) { error_setg(errp, "unsupported flags (got 0x%x)", request->flags); return -EINVAL; } if (request->type != NBD_CMD_WRITE_ZEROES && (request->flags & NBD_CMD_FLAG_NO_HOLE)) { error_setg(errp, "unexpected flags (got 0x%x)", request->flags); return -EINVAL; } return 0; }
false
qemu
3736cc5be31f0399999e37d8b28ca9a3ed0b4ccb
static int nbd_co_receive_request(NBDRequestData *req, NBDRequest *request, Error **errp) { NBDClient *client = req->client; g_assert(qemu_in_coroutine()); assert(client->recv_coroutine == qemu_coroutine_self()); if (nbd_receive_request(client->ioc, request, errp) < 0) { return -EIO; } trace_nbd_co_receive_request_decode_type(request->handle, request->type); if (request->type != NBD_CMD_WRITE) { req->complete = true; } if (request->type == NBD_CMD_DISC) { return -EIO; } if ((request->from + request->len) < request->from) { error_setg(errp, "integer overflow detected, you're probably being attacked"); return -EINVAL; } if (request->type == NBD_CMD_READ || request->type == NBD_CMD_WRITE) { if (request->len > NBD_MAX_BUFFER_SIZE) { error_setg(errp, "len (%" PRIu32" ) is larger than max len (%u)", request->len, NBD_MAX_BUFFER_SIZE); return -EINVAL; } req->data = blk_try_blockalign(client->exp->blk, request->len); if (req->data == NULL) { error_setg(errp, "No memory"); return -ENOMEM; } } if (request->type == NBD_CMD_WRITE) { if (nbd_read(client->ioc, req->data, request->len, errp) < 0) { error_prepend(errp, "reading from socket failed: "); return -EIO; } req->complete = true; trace_nbd_co_receive_request_payload_received(request->handle, request->len); } if (request->from + request->len > client->exp->size) { error_setg(errp, "operation past EOF; From: %" PRIu64 ", Len: %" PRIu32 ", Size: %" PRIu64, request->from, request->len, (uint64_t)client->exp->size); return request->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL; } if (request->flags & ~(NBD_CMD_FLAG_FUA | NBD_CMD_FLAG_NO_HOLE)) { error_setg(errp, "unsupported flags (got 0x%x)", request->flags); return -EINVAL; } if (request->type != NBD_CMD_WRITE_ZEROES && (request->flags & NBD_CMD_FLAG_NO_HOLE)) { error_setg(errp, "unexpected flags (got 0x%x)", request->flags); return -EINVAL; } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(NBDRequestData *VAR_0, NBDRequest *VAR_1, Error **VAR_2) { NBDClient *client = VAR_0->client; g_assert(qemu_in_coroutine()); assert(client->recv_coroutine == qemu_coroutine_self()); if (nbd_receive_request(client->ioc, VAR_1, VAR_2) < 0) { return -EIO; } trace_nbd_co_receive_request_decode_type(VAR_1->handle, VAR_1->type); if (VAR_1->type != NBD_CMD_WRITE) { VAR_0->complete = true; } if (VAR_1->type == NBD_CMD_DISC) { return -EIO; } if ((VAR_1->from + VAR_1->len) < VAR_1->from) { error_setg(VAR_2, "integer overflow detected, you're probably being attacked"); return -EINVAL; } if (VAR_1->type == NBD_CMD_READ || VAR_1->type == NBD_CMD_WRITE) { if (VAR_1->len > NBD_MAX_BUFFER_SIZE) { error_setg(VAR_2, "len (%" PRIu32" ) is larger than max len (%u)", VAR_1->len, NBD_MAX_BUFFER_SIZE); return -EINVAL; } VAR_0->data = blk_try_blockalign(client->exp->blk, VAR_1->len); if (VAR_0->data == NULL) { error_setg(VAR_2, "No memory"); return -ENOMEM; } } if (VAR_1->type == NBD_CMD_WRITE) { if (nbd_read(client->ioc, VAR_0->data, VAR_1->len, VAR_2) < 0) { error_prepend(VAR_2, "reading from socket failed: "); return -EIO; } VAR_0->complete = true; trace_nbd_co_receive_request_payload_received(VAR_1->handle, VAR_1->len); } if (VAR_1->from + VAR_1->len > client->exp->size) { error_setg(VAR_2, "operation past EOF; From: %" PRIu64 ", Len: %" PRIu32 ", Size: %" PRIu64, VAR_1->from, VAR_1->len, (uint64_t)client->exp->size); return VAR_1->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL; } if (VAR_1->flags & ~(NBD_CMD_FLAG_FUA | NBD_CMD_FLAG_NO_HOLE)) { error_setg(VAR_2, "unsupported flags (got 0x%x)", VAR_1->flags); return -EINVAL; } if (VAR_1->type != NBD_CMD_WRITE_ZEROES && (VAR_1->flags & NBD_CMD_FLAG_NO_HOLE)) { error_setg(VAR_2, "unexpected flags (got 0x%x)", VAR_1->flags); return -EINVAL; } return 0; }
[ "static int FUNC_0(NBDRequestData *VAR_0, NBDRequest *VAR_1,\nError **VAR_2)\n{", "NBDClient *client = VAR_0->client;", "g_assert(qemu_in_coroutine());", "assert(client->recv_coroutine == qemu_coroutine_self());", "if (nbd_receive_request(client->ioc, VAR_1, VAR_2) < 0) {", "return -EIO;", "}", "trace_nbd_co_receive_request_decode_type(VAR_1->handle, VAR_1->type);", "if (VAR_1->type != NBD_CMD_WRITE) {", "VAR_0->complete = true;", "}", "if (VAR_1->type == NBD_CMD_DISC) {", "return -EIO;", "}", "if ((VAR_1->from + VAR_1->len) < VAR_1->from) {", "error_setg(VAR_2,\n\"integer overflow detected, you're probably being attacked\");", "return -EINVAL;", "}", "if (VAR_1->type == NBD_CMD_READ || VAR_1->type == NBD_CMD_WRITE) {", "if (VAR_1->len > NBD_MAX_BUFFER_SIZE) {", "error_setg(VAR_2, \"len (%\" PRIu32\" ) is larger than max len (%u)\",\nVAR_1->len, NBD_MAX_BUFFER_SIZE);", "return -EINVAL;", "}", "VAR_0->data = blk_try_blockalign(client->exp->blk, VAR_1->len);", "if (VAR_0->data == NULL) {", "error_setg(VAR_2, \"No memory\");", "return -ENOMEM;", "}", "}", "if (VAR_1->type == NBD_CMD_WRITE) {", "if (nbd_read(client->ioc, VAR_0->data, VAR_1->len, VAR_2) < 0) {", "error_prepend(VAR_2, \"reading from socket failed: \");", "return -EIO;", "}", "VAR_0->complete = true;", "trace_nbd_co_receive_request_payload_received(VAR_1->handle,\nVAR_1->len);", "}", "if (VAR_1->from + VAR_1->len > client->exp->size) {", "error_setg(VAR_2, \"operation past EOF; From: %\" PRIu64 \", Len: %\" PRIu32", "\", Size: %\" PRIu64, VAR_1->from, VAR_1->len,\n(uint64_t)client->exp->size);", "return VAR_1->type == NBD_CMD_WRITE ? -ENOSPC : -EINVAL;", "}", "if (VAR_1->flags & ~(NBD_CMD_FLAG_FUA | NBD_CMD_FLAG_NO_HOLE)) {", "error_setg(VAR_2, \"unsupported flags (got 0x%x)\", VAR_1->flags);", "return -EINVAL;", "}", "if (VAR_1->type != NBD_CMD_WRITE_ZEROES &&\n(VAR_1->flags & NBD_CMD_FLAG_NO_HOLE)) {", "error_setg(VAR_2, \"unexpected flags (got 0x%x)\", VAR_1->flags);", "return -EINVAL;", "}", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 23 ], [ 27 ], [ 31 ], [ 33 ], [ 37 ], [ 43 ], [ 45 ], [ 55 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 67 ], [ 69 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 107, 109 ], [ 111 ], [ 117 ], [ 119 ], [ 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137, 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ] ]
6,006
int qio_channel_writev_all(QIOChannel *ioc, const struct iovec *iov, size_t niov, Error **errp) { int ret = -1; struct iovec *local_iov = g_new(struct iovec, niov); struct iovec *local_iov_head = local_iov; unsigned int nlocal_iov = niov; nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, iov_size(iov, niov)); while (nlocal_iov > 0) { ssize_t len; len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp); if (len == QIO_CHANNEL_ERR_BLOCK) { qio_channel_wait(ioc, G_IO_OUT); continue; } if (len < 0) { goto cleanup; } iov_discard_front(&local_iov, &nlocal_iov, len); } ret = 0; cleanup: g_free(local_iov_head); return ret; }
false
qemu
9ffb8270205a274a18ee4f8a735e2fccaf957246
int qio_channel_writev_all(QIOChannel *ioc, const struct iovec *iov, size_t niov, Error **errp) { int ret = -1; struct iovec *local_iov = g_new(struct iovec, niov); struct iovec *local_iov_head = local_iov; unsigned int nlocal_iov = niov; nlocal_iov = iov_copy(local_iov, nlocal_iov, iov, niov, 0, iov_size(iov, niov)); while (nlocal_iov > 0) { ssize_t len; len = qio_channel_writev(ioc, local_iov, nlocal_iov, errp); if (len == QIO_CHANNEL_ERR_BLOCK) { qio_channel_wait(ioc, G_IO_OUT); continue; } if (len < 0) { goto cleanup; } iov_discard_front(&local_iov, &nlocal_iov, len); } ret = 0; cleanup: g_free(local_iov_head); return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(QIOChannel *VAR_0, const struct iovec *VAR_1, size_t VAR_2, Error **VAR_3) { int VAR_4 = -1; struct iovec *VAR_5 = g_new(struct iovec, VAR_2); struct iovec *VAR_6 = VAR_5; unsigned int VAR_7 = VAR_2; VAR_7 = iov_copy(VAR_5, VAR_7, VAR_1, VAR_2, 0, iov_size(VAR_1, VAR_2)); while (VAR_7 > 0) { ssize_t len; len = qio_channel_writev(VAR_0, VAR_5, VAR_7, VAR_3); if (len == QIO_CHANNEL_ERR_BLOCK) { qio_channel_wait(VAR_0, G_IO_OUT); continue; } if (len < 0) { goto cleanup; } iov_discard_front(&VAR_5, &VAR_7, len); } VAR_4 = 0; cleanup: g_free(VAR_6); return VAR_4; }
[ "int FUNC_0(QIOChannel *VAR_0,\nconst struct iovec *VAR_1,\nsize_t VAR_2,\nError **VAR_3)\n{", "int VAR_4 = -1;", "struct iovec *VAR_5 = g_new(struct iovec, VAR_2);", "struct iovec *VAR_6 = VAR_5;", "unsigned int VAR_7 = VAR_2;", "VAR_7 = iov_copy(VAR_5, VAR_7,\nVAR_1, VAR_2,\n0, iov_size(VAR_1, VAR_2));", "while (VAR_7 > 0) {", "ssize_t len;", "len = qio_channel_writev(VAR_0, VAR_5, VAR_7, VAR_3);", "if (len == QIO_CHANNEL_ERR_BLOCK) {", "qio_channel_wait(VAR_0, G_IO_OUT);", "continue;", "}", "if (len < 0) {", "goto cleanup;", "}", "iov_discard_front(&VAR_5, &VAR_7, len);", "}", "VAR_4 = 0;", "cleanup:\ng_free(VAR_6);", "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 ]
[ [ 1, 3, 5, 7, 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21, 23, 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 57 ], [ 59, 61 ], [ 63 ], [ 65 ] ]
6,009
static int spapr_vio_busdev_init(DeviceState *qdev) { VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev; VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); uint32_t liobn; char *id; if (dev->reg != -1) { /* * Explicitly assigned address, just verify that no-one else * is using it. other mechanism). We have to open code this * rather than using spapr_vio_find_by_reg() because sdev * itself is already in the list. */ VIOsPAPRDevice *other = reg_conflict(dev); if (other) { fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n", object_get_typename(OBJECT(qdev)), object_get_typename(OBJECT(&other->qdev)), dev->reg); return -1; } } else { /* Need to assign an address */ VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->qdev.parent_bus); do { dev->reg = bus->next_reg++; } while (reg_conflict(dev)); } /* Don't overwrite ids assigned on the command line */ if (!dev->qdev.id) { id = vio_format_dev_name(dev); if (!id) { return -1; } dev->qdev.id = id; } dev->qirq = spapr_allocate_msi(dev->vio_irq_num, &dev->vio_irq_num); if (!dev->qirq) { return -1; } liobn = SPAPR_VIO_BASE_LIOBN | dev->reg; dev->dma = spapr_tce_new_dma_context(liobn, pc->rtce_window_size); return pc->init(dev); }
false
qemu
a307d59434ba78b97544b42b8cfd24a1b62e39a6
static int spapr_vio_busdev_init(DeviceState *qdev) { VIOsPAPRDevice *dev = (VIOsPAPRDevice *)qdev; VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); uint32_t liobn; char *id; if (dev->reg != -1) { VIOsPAPRDevice *other = reg_conflict(dev); if (other) { fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n", object_get_typename(OBJECT(qdev)), object_get_typename(OBJECT(&other->qdev)), dev->reg); return -1; } } else { VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->qdev.parent_bus); do { dev->reg = bus->next_reg++; } while (reg_conflict(dev)); } if (!dev->qdev.id) { id = vio_format_dev_name(dev); if (!id) { return -1; } dev->qdev.id = id; } dev->qirq = spapr_allocate_msi(dev->vio_irq_num, &dev->vio_irq_num); if (!dev->qirq) { return -1; } liobn = SPAPR_VIO_BASE_LIOBN | dev->reg; dev->dma = spapr_tce_new_dma_context(liobn, pc->rtce_window_size); return pc->init(dev); }
{ "code": [], "line_no": [] }
static int FUNC_0(DeviceState *VAR_0) { VIOsPAPRDevice *dev = (VIOsPAPRDevice *)VAR_0; VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev); uint32_t liobn; char *VAR_1; if (dev->reg != -1) { VIOsPAPRDevice *other = reg_conflict(dev); if (other) { fprintf(stderr, "vio: %s and %s devices conflict at address %#x\n", object_get_typename(OBJECT(VAR_0)), object_get_typename(OBJECT(&other->VAR_0)), dev->reg); return -1; } } else { VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->VAR_0.parent_bus); do { dev->reg = bus->next_reg++; } while (reg_conflict(dev)); } if (!dev->VAR_0.VAR_1) { VAR_1 = vio_format_dev_name(dev); if (!VAR_1) { return -1; } dev->VAR_0.VAR_1 = VAR_1; } dev->qirq = spapr_allocate_msi(dev->vio_irq_num, &dev->vio_irq_num); if (!dev->qirq) { return -1; } liobn = SPAPR_VIO_BASE_LIOBN | dev->reg; dev->dma = spapr_tce_new_dma_context(liobn, pc->rtce_window_size); return pc->init(dev); }
[ "static int FUNC_0(DeviceState *VAR_0)\n{", "VIOsPAPRDevice *dev = (VIOsPAPRDevice *)VAR_0;", "VIOsPAPRDeviceClass *pc = VIO_SPAPR_DEVICE_GET_CLASS(dev);", "uint32_t liobn;", "char *VAR_1;", "if (dev->reg != -1) {", "VIOsPAPRDevice *other = reg_conflict(dev);", "if (other) {", "fprintf(stderr, \"vio: %s and %s devices conflict at address %#x\\n\",\nobject_get_typename(OBJECT(VAR_0)),\nobject_get_typename(OBJECT(&other->VAR_0)),\ndev->reg);", "return -1;", "}", "} else {", "VIOsPAPRBus *bus = DO_UPCAST(VIOsPAPRBus, bus, dev->VAR_0.parent_bus);", "do {", "dev->reg = bus->next_reg++;", "} while (reg_conflict(dev));", "}", "if (!dev->VAR_0.VAR_1) {", "VAR_1 = vio_format_dev_name(dev);", "if (!VAR_1) {", "return -1;", "}", "dev->VAR_0.VAR_1 = VAR_1;", "}", "dev->qirq = spapr_allocate_msi(dev->vio_irq_num, &dev->vio_irq_num);", "if (!dev->qirq) {", "return -1;", "}", "liobn = SPAPR_VIO_BASE_LIOBN | dev->reg;", "dev->dma = spapr_tce_new_dma_context(liobn, pc->rtce_window_size);", "return pc->init(dev);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 33 ], [ 35, 37, 39, 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ] ]
6,010
static unsigned int dec_subs_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", memsize_char(size), dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(TCG_TYPE_TL); /* Size can only be qi or hi. */ t_gen_sext(t0, cpu_R[dc->op1], size); cris_alu(dc, CC_OP_SUB, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); tcg_temp_free(t0); return 2; }
false
qemu
a7812ae412311d7d47f8aa85656faadac9d64b56
static unsigned int dec_subs_r(DisasContext *dc) { TCGv t0; int size = memsize_z(dc); DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", memsize_char(size), dc->op1, dc->op2)); cris_cc_mask(dc, CC_MASK_NZVC); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_sext(t0, cpu_R[dc->op1], size); cris_alu(dc, CC_OP_SUB, cpu_R[dc->op2], cpu_R[dc->op2], t0, 4); tcg_temp_free(t0); return 2; }
{ "code": [], "line_no": [] }
static unsigned int FUNC_0(DisasContext *VAR_0) { TCGv t0; int VAR_1 = memsize_z(VAR_0); DIS(fprintf (logfile, "subs.%c $r%u, $r%u\n", memsize_char(VAR_1), VAR_0->op1, VAR_0->op2)); cris_cc_mask(VAR_0, CC_MASK_NZVC); t0 = tcg_temp_new(TCG_TYPE_TL); t_gen_sext(t0, cpu_R[VAR_0->op1], VAR_1); cris_alu(VAR_0, CC_OP_SUB, cpu_R[VAR_0->op2], cpu_R[VAR_0->op2], t0, 4); tcg_temp_free(t0); return 2; }
[ "static unsigned int FUNC_0(DisasContext *VAR_0)\n{", "TCGv t0;", "int VAR_1 = memsize_z(VAR_0);", "DIS(fprintf (logfile, \"subs.%c $r%u, $r%u\\n\",\nmemsize_char(VAR_1),\nVAR_0->op1, VAR_0->op2));", "cris_cc_mask(VAR_0, CC_MASK_NZVC);", "t0 = tcg_temp_new(TCG_TYPE_TL);", "t_gen_sext(t0, cpu_R[VAR_0->op1], VAR_1);", "cris_alu(VAR_0, CC_OP_SUB,\ncpu_R[VAR_0->op2], cpu_R[VAR_0->op2], t0, 4);", "tcg_temp_free(t0);", "return 2;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9, 11, 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ] ]
6,011
blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; /* Sanity check block layer guarantees */ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); if (bs->bl.max_transfer) { assert(bytes <= bs->bl.max_transfer); } QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset = rule->options.inject.offset; if (inject_offset == -1 || (inject_offset >= offset && inject_offset < offset + bytes)) { break; } } if (rule && rule->options.inject.error) { return inject_error(bs, rule); } return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); }
false
qemu
d157ed5f7235f3d2d5596a514ad7507b18e24b88
blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); if (bs->bl.max_transfer) { assert(bytes <= bs->bl.max_transfer); } QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset = rule->options.inject.offset; if (inject_offset == -1 || (inject_offset >= offset && inject_offset < offset + bytes)) { break; } } if (rule && rule->options.inject.error) { return inject_error(bs, rule); } return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); }
{ "code": [], "line_no": [] }
FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2, QEMUIOVector *VAR_3, int VAR_4) { BDRVBlkdebugState *s = VAR_0->opaque; BlkdebugRule *rule = NULL; assert(QEMU_IS_ALIGNED(VAR_1, VAR_0->bl.request_alignment)); assert(QEMU_IS_ALIGNED(VAR_2, VAR_0->bl.request_alignment)); if (VAR_0->bl.max_transfer) { assert(VAR_2 <= VAR_0->bl.max_transfer); } QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset = rule->options.inject.VAR_1; if (inject_offset == -1 || (inject_offset >= VAR_1 && inject_offset < VAR_1 + VAR_2)) { break; } } if (rule && rule->options.inject.error) { return inject_error(VAR_0, rule); } return bdrv_co_preadv(VAR_0->file, VAR_1, VAR_2, VAR_3, VAR_4); }
[ "FUNC_0(BlockDriverState *VAR_0, uint64_t VAR_1, uint64_t VAR_2,\nQEMUIOVector *VAR_3, int VAR_4)\n{", "BDRVBlkdebugState *s = VAR_0->opaque;", "BlkdebugRule *rule = NULL;", "assert(QEMU_IS_ALIGNED(VAR_1, VAR_0->bl.request_alignment));", "assert(QEMU_IS_ALIGNED(VAR_2, VAR_0->bl.request_alignment));", "if (VAR_0->bl.max_transfer) {", "assert(VAR_2 <= VAR_0->bl.max_transfer);", "}", "QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) {", "uint64_t inject_offset = rule->options.inject.VAR_1;", "if (inject_offset == -1 ||\n(inject_offset >= VAR_1 && inject_offset < VAR_1 + VAR_2))\n{", "break;", "}", "}", "if (rule && rule->options.inject.error) {", "return inject_error(VAR_0, rule);", "}", "return bdrv_co_preadv(VAR_0->file, VAR_1, VAR_2, VAR_3, VAR_4);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 33, 35, 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49 ], [ 51 ], [ 55 ], [ 57 ] ]
6,013
static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { char *buf; int ret; BDRVVmdkState *s = bs->opaque; uint32_t magic; buf = vmdk_read_desc(bs->file, 0, errp); if (!buf) { return -EINVAL; } magic = ldl_be_p(buf); switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: ret = vmdk_open_sparse(bs, bs->file, flags, buf, errp); s->desc_offset = 0x200; break; default: ret = vmdk_open_desc_file(bs, flags, buf, errp); break; } if (ret) { goto fail; } /* try to open parent images, if exist */ ret = vmdk_parent_open(bs); if (ret) { goto fail; } s->cid = vmdk_read_cid(bs, 0); s->parent_cid = vmdk_read_cid(bs, 1); qemu_co_mutex_init(&s->lock); /* Disable migration when VMDK images are used */ error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); migrate_add_blocker(s->migration_blocker); g_free(buf); return 0; fail: g_free(buf); g_free(s->create_type); s->create_type = NULL; vmdk_free_extents(bs); return ret; }
false
qemu
a646836784a0fc50fee6f9a0d3fb968289714128
static int vmdk_open(BlockDriverState *bs, QDict *options, int flags, Error **errp) { char *buf; int ret; BDRVVmdkState *s = bs->opaque; uint32_t magic; buf = vmdk_read_desc(bs->file, 0, errp); if (!buf) { return -EINVAL; } magic = ldl_be_p(buf); switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: ret = vmdk_open_sparse(bs, bs->file, flags, buf, errp); s->desc_offset = 0x200; break; default: ret = vmdk_open_desc_file(bs, flags, buf, errp); break; } if (ret) { goto fail; } ret = vmdk_parent_open(bs); if (ret) { goto fail; } s->cid = vmdk_read_cid(bs, 0); s->parent_cid = vmdk_read_cid(bs, 1); qemu_co_mutex_init(&s->lock); error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(bs)); migrate_add_blocker(s->migration_blocker); g_free(buf); return 0; fail: g_free(buf); g_free(s->create_type); s->create_type = NULL; vmdk_free_extents(bs); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2, Error **VAR_3) { char *VAR_4; int VAR_5; BDRVVmdkState *s = VAR_0->opaque; uint32_t magic; VAR_4 = vmdk_read_desc(VAR_0->file, 0, VAR_3); if (!VAR_4) { return -EINVAL; } magic = ldl_be_p(VAR_4); switch (magic) { case VMDK3_MAGIC: case VMDK4_MAGIC: VAR_5 = vmdk_open_sparse(VAR_0, VAR_0->file, VAR_2, VAR_4, VAR_3); s->desc_offset = 0x200; break; default: VAR_5 = vmdk_open_desc_file(VAR_0, VAR_2, VAR_4, VAR_3); break; } if (VAR_5) { goto fail; } VAR_5 = vmdk_parent_open(VAR_0); if (VAR_5) { goto fail; } s->cid = vmdk_read_cid(VAR_0, 0); s->parent_cid = vmdk_read_cid(VAR_0, 1); qemu_co_mutex_init(&s->lock); error_setg(&s->migration_blocker, "The vmdk format used by node '%s' " "does not support live migration", bdrv_get_device_or_node_name(VAR_0)); migrate_add_blocker(s->migration_blocker); g_free(VAR_4); return 0; fail: g_free(VAR_4); g_free(s->create_type); s->create_type = NULL; vmdk_free_extents(VAR_0); return VAR_5; }
[ "static int FUNC_0(BlockDriverState *VAR_0, QDict *VAR_1, int VAR_2,\nError **VAR_3)\n{", "char *VAR_4;", "int VAR_5;", "BDRVVmdkState *s = VAR_0->opaque;", "uint32_t magic;", "VAR_4 = vmdk_read_desc(VAR_0->file, 0, VAR_3);", "if (!VAR_4) {", "return -EINVAL;", "}", "magic = ldl_be_p(VAR_4);", "switch (magic) {", "case VMDK3_MAGIC:\ncase VMDK4_MAGIC:\nVAR_5 = vmdk_open_sparse(VAR_0, VAR_0->file, VAR_2, VAR_4, VAR_3);", "s->desc_offset = 0x200;", "break;", "default:\nVAR_5 = vmdk_open_desc_file(VAR_0, VAR_2, VAR_4, VAR_3);", "break;", "}", "if (VAR_5) {", "goto fail;", "}", "VAR_5 = vmdk_parent_open(VAR_0);", "if (VAR_5) {", "goto fail;", "}", "s->cid = vmdk_read_cid(VAR_0, 0);", "s->parent_cid = vmdk_read_cid(VAR_0, 1);", "qemu_co_mutex_init(&s->lock);", "error_setg(&s->migration_blocker, \"The vmdk format used by node '%s' \"\n\"does not support live migration\",\nbdrv_get_device_or_node_name(VAR_0));", "migrate_add_blocker(s->migration_blocker);", "g_free(VAR_4);", "return 0;", "fail:\ng_free(VAR_4);", "g_free(s->create_type);", "s->create_type = NULL;", "vmdk_free_extents(VAR_0);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 29 ], [ 31, 33, 35 ], [ 37 ], [ 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 77, 79, 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ] ]
6,014
void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) { int64_t value; if (v->type_size) { v->type_size(v, obj, name, errp); } else if (v->type_uint64) { v->type_uint64(v, obj, name, errp); } else { value = *obj; v->type_int64(v, &value, name, errp); *obj = value; } }
false
qemu
f755dea79dc81b0d6a8f6414e0672e165e28d8ba
void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) { int64_t value; if (v->type_size) { v->type_size(v, obj, name, errp); } else if (v->type_uint64) { v->type_uint64(v, obj, name, errp); } else { value = *obj; v->type_int64(v, &value, name, errp); *obj = value; } }
{ "code": [], "line_no": [] }
void FUNC_0(Visitor *VAR_0, uint64_t *VAR_1, const char *VAR_2, Error **VAR_3) { int64_t value; if (VAR_0->type_size) { VAR_0->type_size(VAR_0, VAR_1, VAR_2, VAR_3); } else if (VAR_0->type_uint64) { VAR_0->type_uint64(VAR_0, VAR_1, VAR_2, VAR_3); } else { value = *VAR_1; VAR_0->type_int64(VAR_0, &value, VAR_2, VAR_3); *VAR_1 = value; } }
[ "void FUNC_0(Visitor *VAR_0, uint64_t *VAR_1, const char *VAR_2, Error **VAR_3)\n{", "int64_t value;", "if (VAR_0->type_size) {", "VAR_0->type_size(VAR_0, VAR_1, VAR_2, VAR_3);", "} else if (VAR_0->type_uint64) {", "VAR_0->type_uint64(VAR_0, VAR_1, VAR_2, VAR_3);", "} else {", "value = *VAR_1;", "VAR_0->type_int64(VAR_0, &value, VAR_2, VAR_3);", "*VAR_1 = value;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
6,015
void *virtqueue_pop(VirtQueue *vq, size_t sz) { unsigned int i, head, max; hwaddr desc_pa = vq->vring.desc; VirtIODevice *vdev = vq->vdev; VirtQueueElement *elem; unsigned out_num, in_num; hwaddr addr[VIRTQUEUE_MAX_SIZE]; struct iovec iov[VIRTQUEUE_MAX_SIZE]; VRingDesc desc; if (!virtqueue_num_heads(vq, vq->last_avail_idx)) { return NULL; } /* When we start there are none of either input nor output. */ out_num = in_num = 0; max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } vring_desc_read(vdev, &desc, desc_pa, i); if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } /* loop over the indirect descriptor table */ max = desc.len / sizeof(VRingDesc); desc_pa = desc.addr; i = 0; vring_desc_read(vdev, &desc, desc_pa, i); } /* Collect all the descriptors */ do { if (desc.flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(&in_num, addr + out_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, desc.addr, desc.len); } else { if (in_num) { error_report("Incorrect order for descriptors"); exit(1); } virtqueue_map_desc(&out_num, addr, iov, VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len); } /* If we've got too many, that implies a descriptor loop. */ if ((in_num + out_num) > max) { error_report("Looped descriptor"); exit(1); } } while ((i = virtqueue_read_next_desc(vdev, &desc, desc_pa, max)) != max); /* Now copy what we have collected and mapped */ elem = virtqueue_alloc_element(sz, out_num, in_num); elem->index = head; for (i = 0; i < out_num; i++) { elem->out_addr[i] = addr[i]; elem->out_sg[i] = iov[i]; } for (i = 0; i < in_num; i++) { elem->in_addr[i] = addr[out_num + i]; elem->in_sg[i] = iov[out_num + i]; } vq->inuse++; trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); return elem; }
false
qemu
be1fea9bc286f64c6c995bb0d7145a0b738aeddb
void *virtqueue_pop(VirtQueue *vq, size_t sz) { unsigned int i, head, max; hwaddr desc_pa = vq->vring.desc; VirtIODevice *vdev = vq->vdev; VirtQueueElement *elem; unsigned out_num, in_num; hwaddr addr[VIRTQUEUE_MAX_SIZE]; struct iovec iov[VIRTQUEUE_MAX_SIZE]; VRingDesc desc; if (!virtqueue_num_heads(vq, vq->last_avail_idx)) { return NULL; } out_num = in_num = 0; max = vq->vring.num; i = head = virtqueue_get_head(vq, vq->last_avail_idx++); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(vq, vq->last_avail_idx); } vring_desc_read(vdev, &desc, desc_pa, i); if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } max = desc.len / sizeof(VRingDesc); desc_pa = desc.addr; i = 0; vring_desc_read(vdev, &desc, desc_pa, i); } do { if (desc.flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(&in_num, addr + out_num, iov + out_num, VIRTQUEUE_MAX_SIZE - out_num, true, desc.addr, desc.len); } else { if (in_num) { error_report("Incorrect order for descriptors"); exit(1); } virtqueue_map_desc(&out_num, addr, iov, VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len); } if ((in_num + out_num) > max) { error_report("Looped descriptor"); exit(1); } } while ((i = virtqueue_read_next_desc(vdev, &desc, desc_pa, max)) != max); elem = virtqueue_alloc_element(sz, out_num, in_num); elem->index = head; for (i = 0; i < out_num; i++) { elem->out_addr[i] = addr[i]; elem->out_sg[i] = iov[i]; } for (i = 0; i < in_num; i++) { elem->in_addr[i] = addr[out_num + i]; elem->in_sg[i] = iov[out_num + i]; } vq->inuse++; trace_virtqueue_pop(vq, elem, elem->in_num, elem->out_num); return elem; }
{ "code": [], "line_no": [] }
void *FUNC_0(VirtQueue *VAR_0, size_t VAR_1) { unsigned int VAR_2, VAR_3, VAR_4; hwaddr desc_pa = VAR_0->vring.desc; VirtIODevice *vdev = VAR_0->vdev; VirtQueueElement *elem; unsigned VAR_5, VAR_6; hwaddr addr[VIRTQUEUE_MAX_SIZE]; struct iovec VAR_7[VIRTQUEUE_MAX_SIZE]; VRingDesc desc; if (!virtqueue_num_heads(VAR_0, VAR_0->last_avail_idx)) { return NULL; } VAR_5 = VAR_6 = 0; VAR_4 = VAR_0->vring.num; VAR_2 = VAR_3 = virtqueue_get_head(VAR_0, VAR_0->last_avail_idx++); if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { vring_set_avail_event(VAR_0, VAR_0->last_avail_idx); } vring_desc_read(vdev, &desc, desc_pa, VAR_2); if (desc.flags & VRING_DESC_F_INDIRECT) { if (desc.len % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } VAR_4 = desc.len / sizeof(VRingDesc); desc_pa = desc.addr; VAR_2 = 0; vring_desc_read(vdev, &desc, desc_pa, VAR_2); } do { if (desc.flags & VRING_DESC_F_WRITE) { virtqueue_map_desc(&VAR_6, addr + VAR_5, VAR_7 + VAR_5, VIRTQUEUE_MAX_SIZE - VAR_5, true, desc.addr, desc.len); } else { if (VAR_6) { error_report("Incorrect order for descriptors"); exit(1); } virtqueue_map_desc(&VAR_5, addr, VAR_7, VIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len); } if ((VAR_6 + VAR_5) > VAR_4) { error_report("Looped descriptor"); exit(1); } } while ((VAR_2 = virtqueue_read_next_desc(vdev, &desc, desc_pa, VAR_4)) != VAR_4); elem = virtqueue_alloc_element(VAR_1, VAR_5, VAR_6); elem->index = VAR_3; for (VAR_2 = 0; VAR_2 < VAR_5; VAR_2++) { elem->out_addr[VAR_2] = addr[VAR_2]; elem->out_sg[VAR_2] = VAR_7[VAR_2]; } for (VAR_2 = 0; VAR_2 < VAR_6; VAR_2++) { elem->in_addr[VAR_2] = addr[VAR_5 + VAR_2]; elem->in_sg[VAR_2] = VAR_7[VAR_5 + VAR_2]; } VAR_0->inuse++; trace_virtqueue_pop(VAR_0, elem, elem->VAR_6, elem->VAR_5); return elem; }
[ "void *FUNC_0(VirtQueue *VAR_0, size_t VAR_1)\n{", "unsigned int VAR_2, VAR_3, VAR_4;", "hwaddr desc_pa = VAR_0->vring.desc;", "VirtIODevice *vdev = VAR_0->vdev;", "VirtQueueElement *elem;", "unsigned VAR_5, VAR_6;", "hwaddr addr[VIRTQUEUE_MAX_SIZE];", "struct iovec VAR_7[VIRTQUEUE_MAX_SIZE];", "VRingDesc desc;", "if (!virtqueue_num_heads(VAR_0, VAR_0->last_avail_idx)) {", "return NULL;", "}", "VAR_5 = VAR_6 = 0;", "VAR_4 = VAR_0->vring.num;", "VAR_2 = VAR_3 = virtqueue_get_head(VAR_0, VAR_0->last_avail_idx++);", "if (virtio_vdev_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) {", "vring_set_avail_event(VAR_0, VAR_0->last_avail_idx);", "}", "vring_desc_read(vdev, &desc, desc_pa, VAR_2);", "if (desc.flags & VRING_DESC_F_INDIRECT) {", "if (desc.len % sizeof(VRingDesc)) {", "error_report(\"Invalid size for indirect buffer table\");", "exit(1);", "}", "VAR_4 = desc.len / sizeof(VRingDesc);", "desc_pa = desc.addr;", "VAR_2 = 0;", "vring_desc_read(vdev, &desc, desc_pa, VAR_2);", "}", "do {", "if (desc.flags & VRING_DESC_F_WRITE) {", "virtqueue_map_desc(&VAR_6, addr + VAR_5, VAR_7 + VAR_5,\nVIRTQUEUE_MAX_SIZE - VAR_5, true, desc.addr, desc.len);", "} else {", "if (VAR_6) {", "error_report(\"Incorrect order for descriptors\");", "exit(1);", "}", "virtqueue_map_desc(&VAR_5, addr, VAR_7,\nVIRTQUEUE_MAX_SIZE, false, desc.addr, desc.len);", "}", "if ((VAR_6 + VAR_5) > VAR_4) {", "error_report(\"Looped descriptor\");", "exit(1);", "}", "} while ((VAR_2 = virtqueue_read_next_desc(vdev, &desc, desc_pa, VAR_4)) != VAR_4);", "elem = virtqueue_alloc_element(VAR_1, VAR_5, VAR_6);", "elem->index = VAR_3;", "for (VAR_2 = 0; VAR_2 < VAR_5; VAR_2++) {", "elem->out_addr[VAR_2] = addr[VAR_2];", "elem->out_sg[VAR_2] = VAR_7[VAR_2];", "}", "for (VAR_2 = 0; VAR_2 < VAR_6; VAR_2++) {", "elem->in_addr[VAR_2] = addr[VAR_5 + VAR_2];", "elem->in_sg[VAR_2] = VAR_7[VAR_5 + VAR_2];", "}", "VAR_0->inuse++;", "trace_virtqueue_pop(VAR_0, elem, elem->VAR_6, elem->VAR_5);", "return elem;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 33 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 81 ], [ 83 ], [ 85, 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99, 101 ], [ 103 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 145 ], [ 149 ], [ 151 ], [ 153 ] ]
6,016
static void tgen_ext8s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src) { if (facilities & FACILITY_EXT_IMM) { tcg_out_insn(s, RRE, LGBR, dest, src); return; } if (type == TCG_TYPE_I32) { if (dest == src) { tcg_out_sh32(s, RS_SLL, dest, TCG_REG_NONE, 24); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 24); } tcg_out_sh32(s, RS_SRA, dest, TCG_REG_NONE, 24); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 56); tcg_out_sh64(s, RSY_SRAG, dest, dest, TCG_REG_NONE, 56); } }
false
qemu
b2c98d9d392c87c9b9e975d30f79924719d9cbbe
static void tgen_ext8s(TCGContext *s, TCGType type, TCGReg dest, TCGReg src) { if (facilities & FACILITY_EXT_IMM) { tcg_out_insn(s, RRE, LGBR, dest, src); return; } if (type == TCG_TYPE_I32) { if (dest == src) { tcg_out_sh32(s, RS_SLL, dest, TCG_REG_NONE, 24); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 24); } tcg_out_sh32(s, RS_SRA, dest, TCG_REG_NONE, 24); } else { tcg_out_sh64(s, RSY_SLLG, dest, src, TCG_REG_NONE, 56); tcg_out_sh64(s, RSY_SRAG, dest, dest, TCG_REG_NONE, 56); } }
{ "code": [], "line_no": [] }
static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, TCGReg VAR_3) { if (facilities & FACILITY_EXT_IMM) { tcg_out_insn(VAR_0, RRE, LGBR, VAR_2, VAR_3); return; } if (VAR_1 == TCG_TYPE_I32) { if (VAR_2 == VAR_3) { tcg_out_sh32(VAR_0, RS_SLL, VAR_2, TCG_REG_NONE, 24); } else { tcg_out_sh64(VAR_0, RSY_SLLG, VAR_2, VAR_3, TCG_REG_NONE, 24); } tcg_out_sh32(VAR_0, RS_SRA, VAR_2, TCG_REG_NONE, 24); } else { tcg_out_sh64(VAR_0, RSY_SLLG, VAR_2, VAR_3, TCG_REG_NONE, 56); tcg_out_sh64(VAR_0, RSY_SRAG, VAR_2, VAR_2, TCG_REG_NONE, 56); } }
[ "static void FUNC_0(TCGContext *VAR_0, TCGType VAR_1, TCGReg VAR_2, TCGReg VAR_3)\n{", "if (facilities & FACILITY_EXT_IMM) {", "tcg_out_insn(VAR_0, RRE, LGBR, VAR_2, VAR_3);", "return;", "}", "if (VAR_1 == TCG_TYPE_I32) {", "if (VAR_2 == VAR_3) {", "tcg_out_sh32(VAR_0, RS_SLL, VAR_2, TCG_REG_NONE, 24);", "} else {", "tcg_out_sh64(VAR_0, RSY_SLLG, VAR_2, VAR_3, TCG_REG_NONE, 24);", "}", "tcg_out_sh32(VAR_0, RS_SRA, VAR_2, TCG_REG_NONE, 24);", "} else {", "tcg_out_sh64(VAR_0, RSY_SLLG, VAR_2, VAR_3, TCG_REG_NONE, 56);", "tcg_out_sh64(VAR_0, RSY_SRAG, VAR_2, VAR_2, TCG_REG_NONE, 56);", "}", "}" ]
[ 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 ] ]
6,017
void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i; for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { (*cpu_fprintf)(f, "MIPS '%s'\n", mips_defs[i].name); } }
false
qemu
9a78eead0c74333a394c0f7bbfc4423ac746fcd5
void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) { int i; for (i = 0; i < ARRAY_SIZE(mips_defs); i++) { (*cpu_fprintf)(f, "MIPS '%s'\n", mips_defs[i].name); } }
{ "code": [], "line_no": [] }
void FUNC_0 (FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...)) { int VAR_3; for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(mips_defs); VAR_3++) { (*VAR_1)(VAR_2, "MIPS '%s'\n", mips_defs[VAR_3].name); } }
[ "void FUNC_0 (FILE *VAR_2, int (*VAR_1)(FILE *VAR_2, const char *VAR_2, ...))\n{", "int VAR_3;", "for (VAR_3 = 0; VAR_3 < ARRAY_SIZE(mips_defs); VAR_3++) {", "(*VAR_1)(VAR_2, \"MIPS '%s'\\n\",\nmips_defs[VAR_3].name);", "}", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11, 13 ], [ 15 ], [ 17 ] ]
6,018
static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); const char *value; value = qemu_opt_get(opts, "cancel-path"); tb->cancel_path = g_strdup(value); value = qemu_opt_get(opts, "path"); if (!value) { value = TPM_PASSTHROUGH_DEFAULT_DEVICE; } tpm_pt->tpm_dev = g_strdup(value); tb->path = g_strdup(tpm_pt->tpm_dev); tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR); if (tpm_pt->tpm_fd < 0) { error_report("Cannot access TPM device using '%s': %s", tpm_pt->tpm_dev, strerror(errno)); goto err_free_parameters; } if (tpm_passthrough_test_tpmdev(tpm_pt->tpm_fd)) { error_report("'%s' is not a TPM device.", tpm_pt->tpm_dev); goto err_close_tpmdev; } return 0; err_close_tpmdev: qemu_close(tpm_pt->tpm_fd); tpm_pt->tpm_fd = -1; err_free_parameters: g_free(tb->path); tb->path = NULL; g_free(tpm_pt->tpm_dev); tpm_pt->tpm_dev = NULL; return 1; }
false
qemu
56a3c24ffc11955ddc7bb21362ca8069a3fc8c55
static int tpm_passthrough_handle_device_opts(QemuOpts *opts, TPMBackend *tb) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(tb); const char *value; value = qemu_opt_get(opts, "cancel-path"); tb->cancel_path = g_strdup(value); value = qemu_opt_get(opts, "path"); if (!value) { value = TPM_PASSTHROUGH_DEFAULT_DEVICE; } tpm_pt->tpm_dev = g_strdup(value); tb->path = g_strdup(tpm_pt->tpm_dev); tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR); if (tpm_pt->tpm_fd < 0) { error_report("Cannot access TPM device using '%s': %s", tpm_pt->tpm_dev, strerror(errno)); goto err_free_parameters; } if (tpm_passthrough_test_tpmdev(tpm_pt->tpm_fd)) { error_report("'%s' is not a TPM device.", tpm_pt->tpm_dev); goto err_close_tpmdev; } return 0; err_close_tpmdev: qemu_close(tpm_pt->tpm_fd); tpm_pt->tpm_fd = -1; err_free_parameters: g_free(tb->path); tb->path = NULL; g_free(tpm_pt->tpm_dev); tpm_pt->tpm_dev = NULL; return 1; }
{ "code": [], "line_no": [] }
static int FUNC_0(QemuOpts *VAR_0, TPMBackend *VAR_1) { TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(VAR_1); const char *VAR_2; VAR_2 = qemu_opt_get(VAR_0, "cancel-path"); VAR_1->cancel_path = g_strdup(VAR_2); VAR_2 = qemu_opt_get(VAR_0, "path"); if (!VAR_2) { VAR_2 = TPM_PASSTHROUGH_DEFAULT_DEVICE; } tpm_pt->tpm_dev = g_strdup(VAR_2); VAR_1->path = g_strdup(tpm_pt->tpm_dev); tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR); if (tpm_pt->tpm_fd < 0) { error_report("Cannot access TPM device using '%s': %s", tpm_pt->tpm_dev, strerror(errno)); goto err_free_parameters; } if (tpm_passthrough_test_tpmdev(tpm_pt->tpm_fd)) { error_report("'%s' is not a TPM device.", tpm_pt->tpm_dev); goto err_close_tpmdev; } return 0; err_close_tpmdev: qemu_close(tpm_pt->tpm_fd); tpm_pt->tpm_fd = -1; err_free_parameters: g_free(VAR_1->path); VAR_1->path = NULL; g_free(tpm_pt->tpm_dev); tpm_pt->tpm_dev = NULL; return 1; }
[ "static int FUNC_0(QemuOpts *VAR_0, TPMBackend *VAR_1)\n{", "TPMPassthruState *tpm_pt = TPM_PASSTHROUGH(VAR_1);", "const char *VAR_2;", "VAR_2 = qemu_opt_get(VAR_0, \"cancel-path\");", "VAR_1->cancel_path = g_strdup(VAR_2);", "VAR_2 = qemu_opt_get(VAR_0, \"path\");", "if (!VAR_2) {", "VAR_2 = TPM_PASSTHROUGH_DEFAULT_DEVICE;", "}", "tpm_pt->tpm_dev = g_strdup(VAR_2);", "VAR_1->path = g_strdup(tpm_pt->tpm_dev);", "tpm_pt->tpm_fd = qemu_open(tpm_pt->tpm_dev, O_RDWR);", "if (tpm_pt->tpm_fd < 0) {", "error_report(\"Cannot access TPM device using '%s': %s\",\ntpm_pt->tpm_dev, strerror(errno));", "goto err_free_parameters;", "}", "if (tpm_passthrough_test_tpmdev(tpm_pt->tpm_fd)) {", "error_report(\"'%s' is not a TPM device.\",\ntpm_pt->tpm_dev);", "goto err_close_tpmdev;", "}", "return 0;", "err_close_tpmdev:\nqemu_close(tpm_pt->tpm_fd);", "tpm_pt->tpm_fd = -1;", "err_free_parameters:\ng_free(VAR_1->path);", "VAR_1->path = NULL;", "g_free(tpm_pt->tpm_dev);", "tpm_pt->tpm_dev = NULL;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 27 ], [ 31 ], [ 35 ], [ 37 ], [ 39, 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51, 53 ], [ 55 ], [ 57 ], [ 61 ], [ 65, 67 ], [ 69 ], [ 73, 75 ], [ 77 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ] ]
6,019
void ff_put_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_4w_msa(src - (stride * 2), stride, dst, stride, 4); }
false
FFmpeg
662234a9a22f1cd0f0ac83b8bb1ffadedca90c0a
void ff_put_h264_qpel4_mc02_msa(uint8_t *dst, const uint8_t *src, ptrdiff_t stride) { avc_luma_vt_4w_msa(src - (stride * 2), stride, dst, stride, 4); }
{ "code": [], "line_no": [] }
void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1, ptrdiff_t VAR_2) { avc_luma_vt_4w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 4); }
[ "void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1,\nptrdiff_t VAR_2)\n{", "avc_luma_vt_4w_msa(VAR_1 - (VAR_2 * 2), VAR_2, VAR_0, VAR_2, 4);", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ] ]
6,020
static int nbd_co_writev_1(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { BDRVNBDState *s = bs->opaque; struct nbd_request request; struct nbd_reply reply; request.type = NBD_CMD_WRITE; if (!bdrv_enable_write_cache(bs) && (s->nbdflags & NBD_FLAG_SEND_FUA)) { request.type |= NBD_CMD_FLAG_FUA; } request.from = sector_num * 512; request.len = nb_sectors * 512; nbd_coroutine_start(s, &request); if (nbd_co_send_request(s, &request, qiov->iov, offset) == -1) { reply.error = errno; } else { nbd_co_receive_reply(s, &request, &reply, NULL, 0); } nbd_coroutine_end(s, &request); return -reply.error; }
false
qemu
fc19f8a02e45c4d8ad24dd7eb374330b03dfc28e
static int nbd_co_writev_1(BlockDriverState *bs, int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { BDRVNBDState *s = bs->opaque; struct nbd_request request; struct nbd_reply reply; request.type = NBD_CMD_WRITE; if (!bdrv_enable_write_cache(bs) && (s->nbdflags & NBD_FLAG_SEND_FUA)) { request.type |= NBD_CMD_FLAG_FUA; } request.from = sector_num * 512; request.len = nb_sectors * 512; nbd_coroutine_start(s, &request); if (nbd_co_send_request(s, &request, qiov->iov, offset) == -1) { reply.error = errno; } else { nbd_co_receive_reply(s, &request, &reply, NULL, 0); } nbd_coroutine_end(s, &request); return -reply.error; }
{ "code": [], "line_no": [] }
static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, int VAR_2, QEMUIOVector *VAR_3, int VAR_4) { BDRVNBDState *s = VAR_0->opaque; struct nbd_request VAR_5; struct nbd_reply VAR_6; VAR_5.type = NBD_CMD_WRITE; if (!bdrv_enable_write_cache(VAR_0) && (s->nbdflags & NBD_FLAG_SEND_FUA)) { VAR_5.type |= NBD_CMD_FLAG_FUA; } VAR_5.from = VAR_1 * 512; VAR_5.len = VAR_2 * 512; nbd_coroutine_start(s, &VAR_5); if (nbd_co_send_request(s, &VAR_5, VAR_3->iov, VAR_4) == -1) { VAR_6.error = errno; } else { nbd_co_receive_reply(s, &VAR_5, &VAR_6, NULL, 0); } nbd_coroutine_end(s, &VAR_5); return -VAR_6.error; }
[ "static int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nint VAR_2, QEMUIOVector *VAR_3,\nint VAR_4)\n{", "BDRVNBDState *s = VAR_0->opaque;", "struct nbd_request VAR_5;", "struct nbd_reply VAR_6;", "VAR_5.type = NBD_CMD_WRITE;", "if (!bdrv_enable_write_cache(VAR_0) && (s->nbdflags & NBD_FLAG_SEND_FUA)) {", "VAR_5.type |= NBD_CMD_FLAG_FUA;", "}", "VAR_5.from = VAR_1 * 512;", "VAR_5.len = VAR_2 * 512;", "nbd_coroutine_start(s, &VAR_5);", "if (nbd_co_send_request(s, &VAR_5, VAR_3->iov, VAR_4) == -1) {", "VAR_6.error = errno;", "} else {", "nbd_co_receive_reply(s, &VAR_5, &VAR_6, NULL, 0);", "}", "nbd_coroutine_end(s, &VAR_5);", "return -VAR_6.error;", "}" ]
[ 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 ], [ 27 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ] ]
6,021
void mtree_info(fprintf_function mon_printf, void *f) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; QTAILQ_INIT(&ml_head); mon_printf(f, "memory\n"); mtree_print_mr(mon_printf, f, address_space_memory.root, 0, 0, &ml_head); /* print aliased regions */ QTAILQ_FOREACH(ml, &ml_head, queue) { if (!ml->printed) { mon_printf(f, "%s\n", ml->mr->name); mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head); } } QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) { g_free(ml2); } if (address_space_io.root && !QTAILQ_EMPTY(&address_space_io.root->subregions)) { QTAILQ_INIT(&ml_head); mon_printf(f, "I/O\n"); mtree_print_mr(mon_printf, f, address_space_io.root, 0, 0, &ml_head); } }
true
qemu
88365e47dd19da8776252a94ed5fa0b7242ea9e9
void mtree_info(fprintf_function mon_printf, void *f) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; QTAILQ_INIT(&ml_head); mon_printf(f, "memory\n"); mtree_print_mr(mon_printf, f, address_space_memory.root, 0, 0, &ml_head); QTAILQ_FOREACH(ml, &ml_head, queue) { if (!ml->printed) { mon_printf(f, "%s\n", ml->mr->name); mtree_print_mr(mon_printf, f, ml->mr, 0, 0, &ml_head); } } QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) { g_free(ml2); } if (address_space_io.root && !QTAILQ_EMPTY(&address_space_io.root->subregions)) { QTAILQ_INIT(&ml_head); mon_printf(f, "I/O\n"); mtree_print_mr(mon_printf, f, address_space_io.root, 0, 0, &ml_head); } }
{ "code": [ " g_free(ml2);" ], "line_no": [ 39 ] }
void FUNC_0(fprintf_function VAR_0, void *VAR_1) { MemoryRegionListHead ml_head; MemoryRegionList *ml, *ml2; QTAILQ_INIT(&ml_head); VAR_0(VAR_1, "memory\n"); mtree_print_mr(VAR_0, VAR_1, address_space_memory.root, 0, 0, &ml_head); QTAILQ_FOREACH(ml, &ml_head, queue) { if (!ml->printed) { VAR_0(VAR_1, "%s\n", ml->mr->name); mtree_print_mr(VAR_0, VAR_1, ml->mr, 0, 0, &ml_head); } } QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) { g_free(ml2); } if (address_space_io.root && !QTAILQ_EMPTY(&address_space_io.root->subregions)) { QTAILQ_INIT(&ml_head); VAR_0(VAR_1, "I/O\n"); mtree_print_mr(VAR_0, VAR_1, address_space_io.root, 0, 0, &ml_head); } }
[ "void FUNC_0(fprintf_function VAR_0, void *VAR_1)\n{", "MemoryRegionListHead ml_head;", "MemoryRegionList *ml, *ml2;", "QTAILQ_INIT(&ml_head);", "VAR_0(VAR_1, \"memory\\n\");", "mtree_print_mr(VAR_0, VAR_1, address_space_memory.root, 0, 0, &ml_head);", "QTAILQ_FOREACH(ml, &ml_head, queue) {", "if (!ml->printed) {", "VAR_0(VAR_1, \"%s\\n\", ml->mr->name);", "mtree_print_mr(VAR_0, VAR_1, ml->mr, 0, 0, &ml_head);", "}", "}", "QTAILQ_FOREACH_SAFE(ml, &ml_head, queue, ml2) {", "g_free(ml2);", "}", "if (address_space_io.root &&\n!QTAILQ_EMPTY(&address_space_io.root->subregions)) {", "QTAILQ_INIT(&ml_head);", "VAR_0(VAR_1, \"I/O\\n\");", "mtree_print_mr(VAR_0, VAR_1, address_space_io.root, 0, 0, &ml_head);", "}", "}" ]
[ 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 ], [ 11 ], [ 15 ], [ 17 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ] ]
6,022
static int tm2_read_deltas(TM2Context *ctx, int stream_id) { int d, mb; int i, v; d = get_bits(&ctx->gb, 9); mb = get_bits(&ctx->gb, 5); av_assert2(mb < 32); if ((d < 1) || (d > TM2_DELTAS) || (mb < 1)) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb); return AVERROR_INVALIDDATA; } for (i = 0; i < d; i++) { v = get_bits_long(&ctx->gb, mb); if (v & (1 << (mb - 1))) ctx->deltas[stream_id][i] = v - (1 << mb); else ctx->deltas[stream_id][i] = v; } for (; i < TM2_DELTAS; i++) ctx->deltas[stream_id][i] = 0; return 0; }
true
FFmpeg
c9e884f3d98df85bf7f2cf30d71877b22929fdcb
static int tm2_read_deltas(TM2Context *ctx, int stream_id) { int d, mb; int i, v; d = get_bits(&ctx->gb, 9); mb = get_bits(&ctx->gb, 5); av_assert2(mb < 32); if ((d < 1) || (d > TM2_DELTAS) || (mb < 1)) { av_log(ctx->avctx, AV_LOG_ERROR, "Incorrect delta table: %i deltas x %i bits\n", d, mb); return AVERROR_INVALIDDATA; } for (i = 0; i < d; i++) { v = get_bits_long(&ctx->gb, mb); if (v & (1 << (mb - 1))) ctx->deltas[stream_id][i] = v - (1 << mb); else ctx->deltas[stream_id][i] = v; } for (; i < TM2_DELTAS; i++) ctx->deltas[stream_id][i] = 0; return 0; }
{ "code": [ " ctx->deltas[stream_id][i] = v - (1 << mb);" ], "line_no": [ 35 ] }
static int FUNC_0(TM2Context *VAR_0, int VAR_1) { int VAR_2, VAR_3; int VAR_4, VAR_5; VAR_2 = get_bits(&VAR_0->gb, 9); VAR_3 = get_bits(&VAR_0->gb, 5); av_assert2(VAR_3 < 32); if ((VAR_2 < 1) || (VAR_2 > TM2_DELTAS) || (VAR_3 < 1)) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Incorrect delta table: %VAR_4 deltas x %VAR_4 bits\n", VAR_2, VAR_3); return AVERROR_INVALIDDATA; } for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) { VAR_5 = get_bits_long(&VAR_0->gb, VAR_3); if (VAR_5 & (1 << (VAR_3 - 1))) VAR_0->deltas[VAR_1][VAR_4] = VAR_5 - (1 << VAR_3); else VAR_0->deltas[VAR_1][VAR_4] = VAR_5; } for (; VAR_4 < TM2_DELTAS; VAR_4++) VAR_0->deltas[VAR_1][VAR_4] = 0; return 0; }
[ "static int FUNC_0(TM2Context *VAR_0, int VAR_1)\n{", "int VAR_2, VAR_3;", "int VAR_4, VAR_5;", "VAR_2 = get_bits(&VAR_0->gb, 9);", "VAR_3 = get_bits(&VAR_0->gb, 5);", "av_assert2(VAR_3 < 32);", "if ((VAR_2 < 1) || (VAR_2 > TM2_DELTAS) || (VAR_3 < 1)) {", "av_log(VAR_0->avctx, AV_LOG_ERROR, \"Incorrect delta table: %VAR_4 deltas x %VAR_4 bits\\n\", VAR_2, VAR_3);", "return AVERROR_INVALIDDATA;", "}", "for (VAR_4 = 0; VAR_4 < VAR_2; VAR_4++) {", "VAR_5 = get_bits_long(&VAR_0->gb, VAR_3);", "if (VAR_5 & (1 << (VAR_3 - 1)))\nVAR_0->deltas[VAR_1][VAR_4] = VAR_5 - (1 << VAR_3);", "else\nVAR_0->deltas[VAR_1][VAR_4] = VAR_5;", "}", "for (; VAR_4 < TM2_DELTAS; VAR_4++)", "VAR_0->deltas[VAR_1][VAR_4] = 0;", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ] ]
6,023
static void decode_delta_j(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int h, int bpp, int dst_size) { int32_t pitch; uint8_t *end = dst + dst_size, *ptr; uint32_t type, flag, cols, groups, rows, bytes; uint32_t offset; int planepitch_byte = (w + 7) / 8; int planepitch = ((w + 15) / 16) * 2; int kludge_j, b, g, r, d; GetByteContext gb; pitch = planepitch * bpp; kludge_j = w < 320 ? (320 - w) / 8 / 2 : 0; bytestream2_init(&gb, buf, buf_end - buf); while (bytestream2_get_bytes_left(&gb) >= 2) { type = bytestream2_get_be16(&gb); switch (type) { case 0: return; case 1: flag = bytestream2_get_be16(&gb); cols = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); ptr = dst + offset; if (ptr >= end) return; for (b = 0; b < cols; b++) { for (d = 0; d < bpp; d++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr += planepitch; if (ptr >= end) return; } } if ((cols * bpp) & 1) bytestream2_skip(&gb, 1); } break; case 2: flag = bytestream2_get_be16(&gb); rows = bytestream2_get_be16(&gb); bytes = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); for (r = 0; r < rows; r++) { for (d = 0; d < bpp; d++) { ptr = dst + offset + (r * pitch) + d * planepitch; if (ptr >= end) return; for (b = 0; b < bytes; b++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr++; if (ptr >= end) return; } } } if ((rows * bytes * bpp) & 1) bytestream2_skip(&gb, 1); } break; default: return; } } }
true
FFmpeg
5350e0fc97a50de7cb387d1d5f07fe25c9c4a935
static void decode_delta_j(uint8_t *dst, const uint8_t *buf, const uint8_t *buf_end, int w, int h, int bpp, int dst_size) { int32_t pitch; uint8_t *end = dst + dst_size, *ptr; uint32_t type, flag, cols, groups, rows, bytes; uint32_t offset; int planepitch_byte = (w + 7) / 8; int planepitch = ((w + 15) / 16) * 2; int kludge_j, b, g, r, d; GetByteContext gb; pitch = planepitch * bpp; kludge_j = w < 320 ? (320 - w) / 8 / 2 : 0; bytestream2_init(&gb, buf, buf_end - buf); while (bytestream2_get_bytes_left(&gb) >= 2) { type = bytestream2_get_be16(&gb); switch (type) { case 0: return; case 1: flag = bytestream2_get_be16(&gb); cols = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); ptr = dst + offset; if (ptr >= end) return; for (b = 0; b < cols; b++) { for (d = 0; d < bpp; d++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr += planepitch; if (ptr >= end) return; } } if ((cols * bpp) & 1) bytestream2_skip(&gb, 1); } break; case 2: flag = bytestream2_get_be16(&gb); rows = bytestream2_get_be16(&gb); bytes = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (g = 0; g < groups; g++) { offset = bytestream2_get_be16(&gb); if (kludge_j) offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - kludge_j; else offset = ((offset / planepitch_byte) * pitch) + (offset % planepitch_byte); for (r = 0; r < rows; r++) { for (d = 0; d < bpp; d++) { ptr = dst + offset + (r * pitch) + d * planepitch; if (ptr >= end) return; for (b = 0; b < bytes; b++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr++; if (ptr >= end) return; } } } if ((rows * bytes * bpp) & 1) bytestream2_skip(&gb, 1); } break; default: return; } } }
{ "code": [ " uint8_t *end = dst + dst_size, *ptr;", " ptr = dst + offset;", " if (ptr >= end)", " ptr += planepitch;", " if (ptr >= end)", " ptr = dst + offset + (r * pitch) + d * planepitch;", " if (ptr >= end)", " ptr++;", " if (ptr >= end)" ], "line_no": [ 11, 75, 77, 101, 103, 151, 103, 175, 177 ] }
static void FUNC_0(uint8_t *VAR_0, const uint8_t *VAR_1, const uint8_t *VAR_2, int VAR_3, int VAR_4, int VAR_5, int VAR_6) { int32_t pitch; uint8_t *end = VAR_0 + VAR_6, *ptr; uint32_t type, flag, cols, groups, rows, bytes; uint32_t offset; int VAR_7 = (VAR_3 + 7) / 8; int VAR_8 = ((VAR_3 + 15) / 16) * 2; int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13; GetByteContext gb; pitch = VAR_8 * VAR_5; VAR_9 = VAR_3 < 320 ? (320 - VAR_3) / 8 / 2 : 0; bytestream2_init(&gb, VAR_1, VAR_2 - VAR_1); while (bytestream2_get_bytes_left(&gb) >= 2) { type = bytestream2_get_be16(&gb); switch (type) { case 0: return; case 1: flag = bytestream2_get_be16(&gb); cols = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (VAR_11 = 0; VAR_11 < groups; VAR_11++) { offset = bytestream2_get_be16(&gb); if (VAR_9) offset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - VAR_9; else offset = ((offset / VAR_7) * pitch) + (offset % VAR_7); ptr = VAR_0 + offset; if (ptr >= end) return; for (VAR_10 = 0; VAR_10 < cols; VAR_10++) { for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr += VAR_8; if (ptr >= end) return; } } if ((cols * VAR_5) & 1) bytestream2_skip(&gb, 1); } break; case 2: flag = bytestream2_get_be16(&gb); rows = bytestream2_get_be16(&gb); bytes = bytestream2_get_be16(&gb); groups = bytestream2_get_be16(&gb); for (VAR_11 = 0; VAR_11 < groups; VAR_11++) { offset = bytestream2_get_be16(&gb); if (VAR_9) offset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - VAR_9; else offset = ((offset / VAR_7) * pitch) + (offset % VAR_7); for (VAR_12 = 0; VAR_12 < rows; VAR_12++) { for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) { ptr = VAR_0 + offset + (VAR_12 * pitch) + VAR_13 * VAR_8; if (ptr >= end) return; for (VAR_10 = 0; VAR_10 < bytes; VAR_10++) { uint8_t value = bytestream2_get_byte(&gb); if (flag) ptr[0] ^= value; else ptr[0] = value; ptr++; if (ptr >= end) return; } } } if ((rows * bytes * VAR_5) & 1) bytestream2_skip(&gb, 1); } break; default: return; } } }
[ "static void FUNC_0(uint8_t *VAR_0,\nconst uint8_t *VAR_1, const uint8_t *VAR_2,\nint VAR_3, int VAR_4, int VAR_5, int VAR_6)\n{", "int32_t pitch;", "uint8_t *end = VAR_0 + VAR_6, *ptr;", "uint32_t type, flag, cols, groups, rows, bytes;", "uint32_t offset;", "int VAR_7 = (VAR_3 + 7) / 8;", "int VAR_8 = ((VAR_3 + 15) / 16) * 2;", "int VAR_9, VAR_10, VAR_11, VAR_12, VAR_13;", "GetByteContext gb;", "pitch = VAR_8 * VAR_5;", "VAR_9 = VAR_3 < 320 ? (320 - VAR_3) / 8 / 2 : 0;", "bytestream2_init(&gb, VAR_1, VAR_2 - VAR_1);", "while (bytestream2_get_bytes_left(&gb) >= 2) {", "type = bytestream2_get_be16(&gb);", "switch (type) {", "case 0:\nreturn;", "case 1:\nflag = bytestream2_get_be16(&gb);", "cols = bytestream2_get_be16(&gb);", "groups = bytestream2_get_be16(&gb);", "for (VAR_11 = 0; VAR_11 < groups; VAR_11++) {", "offset = bytestream2_get_be16(&gb);", "if (VAR_9)\noffset = ((offset / (320 / 8)) * pitch) + (offset % (320 / 8)) - VAR_9;", "else\noffset = ((offset / VAR_7) * pitch) + (offset % VAR_7);", "ptr = VAR_0 + offset;", "if (ptr >= end)\nreturn;", "for (VAR_10 = 0; VAR_10 < cols; VAR_10++) {", "for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) {", "uint8_t value = bytestream2_get_byte(&gb);", "if (flag)\nptr[0] ^= value;", "else\nptr[0] = value;", "ptr += VAR_8;", "if (ptr >= end)\nreturn;", "}", "}", "if ((cols * VAR_5) & 1)\nbytestream2_skip(&gb, 1);", "}", "break;", "case 2:\nflag = bytestream2_get_be16(&gb);", "rows = bytestream2_get_be16(&gb);", "bytes = bytestream2_get_be16(&gb);", "groups = bytestream2_get_be16(&gb);", "for (VAR_11 = 0; VAR_11 < groups; VAR_11++) {", "offset = bytestream2_get_be16(&gb);", "if (VAR_9)\noffset = ((offset / (320 / 8)) * pitch) + (offset % (320/ 8)) - VAR_9;", "else\noffset = ((offset / VAR_7) * pitch) + (offset % VAR_7);", "for (VAR_12 = 0; VAR_12 < rows; VAR_12++) {", "for (VAR_13 = 0; VAR_13 < VAR_5; VAR_13++) {", "ptr = VAR_0 + offset + (VAR_12 * pitch) + VAR_13 * VAR_8;", "if (ptr >= end)\nreturn;", "for (VAR_10 = 0; VAR_10 < bytes; VAR_10++) {", "uint8_t value = bytestream2_get_byte(&gb);", "if (flag)\nptr[0] ^= value;", "else\nptr[0] = value;", "ptr++;", "if (ptr >= end)\nreturn;", "}", "}", "}", "if ((rows * bytes * VAR_5) & 1)\nbytestream2_skip(&gb, 1);", "}", "break;", "default:\nreturn;", "}", "}", "}" ]
[ 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 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 ], [ 37 ], [ 39 ], [ 43 ], [ 45, 47 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 65, 67 ], [ 69, 71 ], [ 75 ], [ 77, 79 ], [ 83 ], [ 85 ], [ 87 ], [ 91, 93 ], [ 95, 97 ], [ 101 ], [ 103, 105 ], [ 107 ], [ 109 ], [ 111, 113 ], [ 115 ], [ 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131 ], [ 133 ], [ 137, 139 ], [ 141, 143 ], [ 147 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 159 ], [ 161 ], [ 165, 167 ], [ 169, 171 ], [ 175 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187, 189 ], [ 191 ], [ 193 ], [ 195, 197 ], [ 199 ], [ 201 ], [ 203 ] ]
6,024
static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { SHINEContext *s = avctx->priv_data; MPADecodeHeader hdr; unsigned char *data; long written; int ret, len; if (frame) data = shine_encode_buffer(s->shine, (int16_t **)frame->data, &written); else data = shine_flush(s->shine, &written); if (written < 0) return -1; if (written > 0) { if (s->buffer_index + written > BUFFER_SIZE) { av_log(avctx, AV_LOG_ERROR, "internal buffer too small\n"); return AVERROR_BUG; } memcpy(s->buffer + s->buffer_index, data, written); s->buffer_index += written; } if (frame) { if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } if (s->buffer_index < 4 || !s->afq.frame_count) return 0; if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) { av_log(avctx, AV_LOG_ERROR, "free format output not supported\n"); return -1; } len = hdr.frame_size; if (len <= s->buffer_index) { if ((ret = ff_alloc_packet2(avctx, avpkt, len))) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; memmove(s->buffer, s->buffer + len, s->buffer_index); ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); avpkt->size = len; *got_packet_ptr = 1; } return 0; }
true
FFmpeg
e48a9ac9af5f6e652735aa44a86420b5e7258895
static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr) { SHINEContext *s = avctx->priv_data; MPADecodeHeader hdr; unsigned char *data; long written; int ret, len; if (frame) data = shine_encode_buffer(s->shine, (int16_t **)frame->data, &written); else data = shine_flush(s->shine, &written); if (written < 0) return -1; if (written > 0) { if (s->buffer_index + written > BUFFER_SIZE) { av_log(avctx, AV_LOG_ERROR, "internal buffer too small\n"); return AVERROR_BUG; } memcpy(s->buffer + s->buffer_index, data, written); s->buffer_index += written; } if (frame) { if ((ret = ff_af_queue_add(&s->afq, frame)) < 0) return ret; } if (s->buffer_index < 4 || !s->afq.frame_count) return 0; if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) { av_log(avctx, AV_LOG_ERROR, "free format output not supported\n"); return -1; } len = hdr.frame_size; if (len <= s->buffer_index) { if ((ret = ff_alloc_packet2(avctx, avpkt, len))) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; memmove(s->buffer, s->buffer + len, s->buffer_index); ff_af_queue_remove(&s->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); avpkt->size = len; *got_packet_ptr = 1; } return 0; }
{ "code": [ " long written;" ], "line_no": [ 13 ] }
static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1, const AVFrame *VAR_2, int *VAR_3) { SHINEContext *s = VAR_0->priv_data; MPADecodeHeader hdr; unsigned char *VAR_4; long VAR_5; int VAR_6, VAR_7; if (VAR_2) VAR_4 = shine_encode_buffer(s->shine, (int16_t **)VAR_2->VAR_4, &VAR_5); else VAR_4 = shine_flush(s->shine, &VAR_5); if (VAR_5 < 0) return -1; if (VAR_5 > 0) { if (s->buffer_index + VAR_5 > BUFFER_SIZE) { av_log(VAR_0, AV_LOG_ERROR, "internal buffer too small\n"); return AVERROR_BUG; } memcpy(s->buffer + s->buffer_index, VAR_4, VAR_5); s->buffer_index += VAR_5; } if (VAR_2) { if ((VAR_6 = ff_af_queue_add(&s->afq, VAR_2)) < 0) return VAR_6; } if (s->buffer_index < 4 || !s->afq.frame_count) return 0; if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) { av_log(VAR_0, AV_LOG_ERROR, "free format output not supported\n"); return -1; } VAR_7 = hdr.frame_size; if (VAR_7 <= s->buffer_index) { if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, VAR_7))) return VAR_6; memcpy(VAR_1->VAR_4, s->buffer, VAR_7); s->buffer_index -= VAR_7; memmove(s->buffer, s->buffer + VAR_7, s->buffer_index); ff_af_queue_remove(&s->afq, VAR_0->frame_size, &VAR_1->pts, &VAR_1->duration); VAR_1->size = VAR_7; *VAR_3 = 1; } return 0; }
[ "static int FUNC_0(AVCodecContext *VAR_0, AVPacket *VAR_1,\nconst AVFrame *VAR_2, int *VAR_3)\n{", "SHINEContext *s = VAR_0->priv_data;", "MPADecodeHeader hdr;", "unsigned char *VAR_4;", "long VAR_5;", "int VAR_6, VAR_7;", "if (VAR_2)\nVAR_4 = shine_encode_buffer(s->shine, (int16_t **)VAR_2->VAR_4, &VAR_5);", "else\nVAR_4 = shine_flush(s->shine, &VAR_5);", "if (VAR_5 < 0)\nreturn -1;", "if (VAR_5 > 0) {", "if (s->buffer_index + VAR_5 > BUFFER_SIZE) {", "av_log(VAR_0, AV_LOG_ERROR, \"internal buffer too small\\n\");", "return AVERROR_BUG;", "}", "memcpy(s->buffer + s->buffer_index, VAR_4, VAR_5);", "s->buffer_index += VAR_5;", "}", "if (VAR_2) {", "if ((VAR_6 = ff_af_queue_add(&s->afq, VAR_2)) < 0)\nreturn VAR_6;", "}", "if (s->buffer_index < 4 || !s->afq.frame_count)\nreturn 0;", "if (avpriv_mpegaudio_decode_header(&hdr, AV_RB32(s->buffer))) {", "av_log(VAR_0, AV_LOG_ERROR, \"free format output not supported\\n\");", "return -1;", "}", "VAR_7 = hdr.frame_size;", "if (VAR_7 <= s->buffer_index) {", "if ((VAR_6 = ff_alloc_packet2(VAR_0, VAR_1, VAR_7)))\nreturn VAR_6;", "memcpy(VAR_1->VAR_4, s->buffer, VAR_7);", "s->buffer_index -= VAR_7;", "memmove(s->buffer, s->buffer + VAR_7, s->buffer_index);", "ff_af_queue_remove(&s->afq, VAR_0->frame_size, &VAR_1->pts,\n&VAR_1->duration);", "VAR_1->size = VAR_7;", "*VAR_3 = 1;", "}", "return 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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19, 21 ], [ 23, 25 ], [ 27, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49, 51 ], [ 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87, 89 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ] ]
6,026
static int flac_write_trailer(struct AVFormatContext *s) { ByteIOContext *pb = s->pb; uint8_t *streaminfo = s->streams[0]->codec->extradata; int len = s->streams[0]->codec->extradata_size; int64_t file_size; if (streaminfo && len > 0 && !url_is_streamed(s->pb)) { file_size = url_ftell(pb); url_fseek(pb, 8, SEEK_SET); put_buffer(pb, streaminfo, len); url_fseek(pb, file_size, SEEK_SET); put_flush_packet(pb); } return 0; }
false
FFmpeg
59c6178a54c414fd19e064f0077d00b82a1eb812
static int flac_write_trailer(struct AVFormatContext *s) { ByteIOContext *pb = s->pb; uint8_t *streaminfo = s->streams[0]->codec->extradata; int len = s->streams[0]->codec->extradata_size; int64_t file_size; if (streaminfo && len > 0 && !url_is_streamed(s->pb)) { file_size = url_ftell(pb); url_fseek(pb, 8, SEEK_SET); put_buffer(pb, streaminfo, len); url_fseek(pb, file_size, SEEK_SET); put_flush_packet(pb); } return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(struct AVFormatContext *VAR_0) { ByteIOContext *pb = VAR_0->pb; uint8_t *streaminfo = VAR_0->streams[0]->codec->extradata; int VAR_1 = VAR_0->streams[0]->codec->extradata_size; int64_t file_size; if (streaminfo && VAR_1 > 0 && !url_is_streamed(VAR_0->pb)) { file_size = url_ftell(pb); url_fseek(pb, 8, SEEK_SET); put_buffer(pb, streaminfo, VAR_1); url_fseek(pb, file_size, SEEK_SET); put_flush_packet(pb); } return 0; }
[ "static int FUNC_0(struct AVFormatContext *VAR_0)\n{", "ByteIOContext *pb = VAR_0->pb;", "uint8_t *streaminfo = VAR_0->streams[0]->codec->extradata;", "int VAR_1 = VAR_0->streams[0]->codec->extradata_size;", "int64_t file_size;", "if (streaminfo && VAR_1 > 0 && !url_is_streamed(VAR_0->pb)) {", "file_size = url_ftell(pb);", "url_fseek(pb, 8, SEEK_SET);", "put_buffer(pb, streaminfo, VAR_1);", "url_fseek(pb, file_size, SEEK_SET);", "put_flush_packet(pb);", "}", "return 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 ] ]
6,028
int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd = -1; qemu_egl_rn_fd = qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd == -1) { error_report("egl: no drm render node available"); goto err; } qemu_egl_rn_gbm_dev = gbm_create_device(qemu_egl_rn_fd); if (!qemu_egl_rn_gbm_dev) { error_report("egl: gbm_create_device failed"); goto err; } qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { error_report("egl: EGL_KHR_surfaceless_context not supported"); goto err; } if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_MESA_image_dma_buf_export")) { error_report("egl: EGL_MESA_image_dma_buf_export not supported"); goto err; } qemu_egl_rn_ctx = qemu_egl_init_ctx(); if (!qemu_egl_rn_ctx) { error_report("egl: egl_init_ctx failed"); goto err; } return 0; err: if (qemu_egl_rn_gbm_dev) { gbm_device_destroy(qemu_egl_rn_gbm_dev); } if (qemu_egl_rn_fd != -1) { close(qemu_egl_rn_fd); } return -1; }
true
qemu
151c8e608efc29e4dde4a0dbc2e79ebbc86c319c
int egl_rendernode_init(const char *rendernode) { qemu_egl_rn_fd = -1; qemu_egl_rn_fd = qemu_egl_rendernode_open(rendernode); if (qemu_egl_rn_fd == -1) { error_report("egl: no drm render node available"); goto err; } qemu_egl_rn_gbm_dev = gbm_create_device(qemu_egl_rn_fd); if (!qemu_egl_rn_gbm_dev) { error_report("egl: gbm_create_device failed"); goto err; } qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { error_report("egl: EGL_KHR_surfaceless_context not supported"); goto err; } if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_MESA_image_dma_buf_export")) { error_report("egl: EGL_MESA_image_dma_buf_export not supported"); goto err; } qemu_egl_rn_ctx = qemu_egl_init_ctx(); if (!qemu_egl_rn_ctx) { error_report("egl: egl_init_ctx failed"); goto err; } return 0; err: if (qemu_egl_rn_gbm_dev) { gbm_device_destroy(qemu_egl_rn_gbm_dev); } if (qemu_egl_rn_fd != -1) { close(qemu_egl_rn_fd); } return -1; }
{ "code": [ " qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev);" ], "line_no": [ 33 ] }
int FUNC_0(const char *VAR_0) { qemu_egl_rn_fd = -1; qemu_egl_rn_fd = qemu_egl_rendernode_open(VAR_0); if (qemu_egl_rn_fd == -1) { error_report("egl: no drm render node available"); goto err; } qemu_egl_rn_gbm_dev = gbm_create_device(qemu_egl_rn_fd); if (!qemu_egl_rn_gbm_dev) { error_report("egl: gbm_create_device failed"); goto err; } qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev); if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_KHR_surfaceless_context")) { error_report("egl: EGL_KHR_surfaceless_context not supported"); goto err; } if (!epoxy_has_egl_extension(qemu_egl_display, "EGL_MESA_image_dma_buf_export")) { error_report("egl: EGL_MESA_image_dma_buf_export not supported"); goto err; } qemu_egl_rn_ctx = qemu_egl_init_ctx(); if (!qemu_egl_rn_ctx) { error_report("egl: egl_init_ctx failed"); goto err; } return 0; err: if (qemu_egl_rn_gbm_dev) { gbm_device_destroy(qemu_egl_rn_gbm_dev); } if (qemu_egl_rn_fd != -1) { close(qemu_egl_rn_fd); } return -1; }
[ "int FUNC_0(const char *VAR_0)\n{", "qemu_egl_rn_fd = -1;", "qemu_egl_rn_fd = qemu_egl_rendernode_open(VAR_0);", "if (qemu_egl_rn_fd == -1) {", "error_report(\"egl: no drm render node available\");", "goto err;", "}", "qemu_egl_rn_gbm_dev = gbm_create_device(qemu_egl_rn_fd);", "if (!qemu_egl_rn_gbm_dev) {", "error_report(\"egl: gbm_create_device failed\");", "goto err;", "}", "qemu_egl_init_dpy_mesa((EGLNativeDisplayType)qemu_egl_rn_gbm_dev);", "if (!epoxy_has_egl_extension(qemu_egl_display,\n\"EGL_KHR_surfaceless_context\")) {", "error_report(\"egl: EGL_KHR_surfaceless_context not supported\");", "goto err;", "}", "if (!epoxy_has_egl_extension(qemu_egl_display,\n\"EGL_MESA_image_dma_buf_export\")) {", "error_report(\"egl: EGL_MESA_image_dma_buf_export not supported\");", "goto err;", "}", "qemu_egl_rn_ctx = qemu_egl_init_ctx();", "if (!qemu_egl_rn_ctx) {", "error_report(\"egl: egl_init_ctx failed\");", "goto err;", "}", "return 0;", "err:\nif (qemu_egl_rn_gbm_dev) {", "gbm_device_destroy(qemu_egl_rn_gbm_dev);", "}", "if (qemu_egl_rn_fd != -1) {", "close(qemu_egl_rn_fd);", "}", "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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 33 ], [ 37, 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 75, 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ] ]
6,029
static inline int read_line(AVFormatContext *s, char *rbuf, const int rbufsize, int *rbuflen) { RTSPState *rt = s->priv_data; int idx = 0; int ret = 0; *rbuflen = 0; do { ret = ffurl_read_complete(rt->rtsp_hd, rbuf + idx, 1); if (ret < 0) return ret; if (rbuf[idx] == '\r') { /* Ignore */ } else if (rbuf[idx] == '\n') { rbuf[idx] = '\0'; *rbuflen = idx; return 0; } else idx++; } while (idx < rbufsize); av_log(s, AV_LOG_ERROR, "Message too long\n"); return AVERROR(EIO); }
true
FFmpeg
0c6b9b9fe5edb7b4307e1705bac7f1087262a6fb
static inline int read_line(AVFormatContext *s, char *rbuf, const int rbufsize, int *rbuflen) { RTSPState *rt = s->priv_data; int idx = 0; int ret = 0; *rbuflen = 0; do { ret = ffurl_read_complete(rt->rtsp_hd, rbuf + idx, 1); if (ret < 0) return ret; if (rbuf[idx] == '\r') { } else if (rbuf[idx] == '\n') { rbuf[idx] = '\0'; *rbuflen = idx; return 0; } else idx++; } while (idx < rbufsize); av_log(s, AV_LOG_ERROR, "Message too long\n"); return AVERROR(EIO); }
{ "code": [ " if (ret < 0)", " return ret;" ], "line_no": [ 21, 23 ] }
static inline int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, const int VAR_2, int *VAR_3) { RTSPState *rt = VAR_0->priv_data; int VAR_4 = 0; int VAR_5 = 0; *VAR_3 = 0; do { VAR_5 = ffurl_read_complete(rt->rtsp_hd, VAR_1 + VAR_4, 1); if (VAR_5 < 0) return VAR_5; if (VAR_1[VAR_4] == '\r') { } else if (VAR_1[VAR_4] == '\n') { VAR_1[VAR_4] = '\0'; *VAR_3 = VAR_4; return 0; } else VAR_4++; } while (VAR_4 < VAR_2); av_log(VAR_0, AV_LOG_ERROR, "Message too long\n"); return AVERROR(EIO); }
[ "static inline int FUNC_0(AVFormatContext *VAR_0, char *VAR_1, const int VAR_2,\nint *VAR_3)\n{", "RTSPState *rt = VAR_0->priv_data;", "int VAR_4 = 0;", "int VAR_5 = 0;", "*VAR_3 = 0;", "do {", "VAR_5 = ffurl_read_complete(rt->rtsp_hd, VAR_1 + VAR_4, 1);", "if (VAR_5 < 0)\nreturn VAR_5;", "if (VAR_1[VAR_4] == '\\r') {", "} else if (VAR_1[VAR_4] == '\\n') {", "VAR_1[VAR_4] = '\\0';", "*VAR_3 = VAR_4;", "return 0;", "} else", "VAR_4++;", "} while (VAR_4 < VAR_2);", "av_log(VAR_0, AV_LOG_ERROR, \"Message too long\\n\");", "return AVERROR(EIO);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ] ]
6,030
static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx = -1; HotplugHandlerClass *hhc; Error *local_err = NULL; X86CPU *cpu = X86_CPU(dev); PCMachineState *pcms = PC_MACHINE(hotplug_dev); pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); assert(idx != -1); if (idx == 0) { error_setg(&local_err, "Boot CPU is unpluggable"); hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); if (local_err) { out: error_propagate(errp, local_err);
true
qemu
75ba2ddb188fa07c3442446766782036e3085cba
static void pc_cpu_unplug_request_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { int idx = -1; HotplugHandlerClass *hhc; Error *local_err = NULL; X86CPU *cpu = X86_CPU(dev); PCMachineState *pcms = PC_MACHINE(hotplug_dev); pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &idx); assert(idx != -1); if (idx == 0) { error_setg(&local_err, "Boot CPU is unpluggable"); hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), dev, &local_err); if (local_err) { out: error_propagate(errp, local_err);
{ "code": [], "line_no": [] }
static void FUNC_0(HotplugHandler *VAR_0, DeviceState *VAR_1, Error **VAR_2) { int VAR_3 = -1; HotplugHandlerClass *hhc; Error *local_err = NULL; X86CPU *cpu = X86_CPU(VAR_1); PCMachineState *pcms = PC_MACHINE(VAR_0); pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &VAR_3); assert(VAR_3 != -1); if (VAR_3 == 0) { error_setg(&local_err, "Boot CPU is unpluggable"); hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev); hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), VAR_1, &local_err); if (local_err) { out: error_propagate(VAR_2, local_err);
[ "static void FUNC_0(HotplugHandler *VAR_0,\nDeviceState *VAR_1, Error **VAR_2)\n{", "int VAR_3 = -1;", "HotplugHandlerClass *hhc;", "Error *local_err = NULL;", "X86CPU *cpu = X86_CPU(VAR_1);", "PCMachineState *pcms = PC_MACHINE(VAR_0);", "pc_find_cpu_slot(MACHINE(pcms), cpu->apic_id, &VAR_3);", "assert(VAR_3 != -1);", "if (VAR_3 == 0) {", "error_setg(&local_err, \"Boot CPU is unpluggable\");", "hhc = HOTPLUG_HANDLER_GET_CLASS(pcms->acpi_dev);", "hhc->unplug_request(HOTPLUG_HANDLER(pcms->acpi_dev), VAR_1, &local_err);", "if (local_err) {", "out:\nerror_propagate(VAR_2, local_err);" ]
[ 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 ] ]
6,031
static void lm32_evr_init(QEMUMachineInitArgs *args) { const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq *cpu_irq, irq[32]; ResetInfo *reset_info; int i; /* memory map */ hwaddr flash_base = 0x04000000; size_t flash_sector_size = 256 * 1024; size_t flash_size = 32 * 1024 * 1024; hwaddr ram_base = 0x08000000; size_t ram_size = 64 * 1024 * 1024; hwaddr timer0_base = 0x80002000; hwaddr uart0_base = 0x80006000; hwaddr timer1_base = 0x8000a000; int uart0_irq = 0; int timer0_irq = 1; int timer1_irq = 3; reset_info = g_malloc0(sizeof(ResetInfo)); if (cpu_model == NULL) { cpu_model = "lm32-full"; cpu = cpu_lm32_init(cpu_model); env = &cpu->env; reset_info->cpu = cpu; reset_info->flash_base = flash_base; memory_region_init_ram(phys_ram, NULL, "lm32_evr.sdram", ram_size); vmstate_register_ram_global(phys_ram); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); /* Spansion S29NS128P */ pflash_cfi02_register(flash_base, NULL, "lm32_evr.flash", flash_size, dinfo ? dinfo->bdrv : NULL, flash_sector_size, flash_size / flash_sector_size, 1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1); /* create irq lines */ cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1); env->pic_state = lm32_pic_init(*cpu_irq); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(env->pic_state, i); sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]); sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]); sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]); /* make sure juart isn't the first chardev */ env->juart_state = lm32_juart_init(); reset_info->bootstrap_pc = flash_base; if (kernel_filename) { uint64_t entry; int kernel_size; kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL, 1, ELF_MACHINE, 0); reset_info->bootstrap_pc = entry; if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, ram_base, ram_size); reset_info->bootstrap_pc = ram_base; if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); qemu_register_reset(main_cpu_reset, reset_info);
true
qemu
f41152bd9d01ab327c19a3828bb7896d67cf0752
static void lm32_evr_init(QEMUMachineInitArgs *args) { const char *cpu_model = args->cpu_model; const char *kernel_filename = args->kernel_filename; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq *cpu_irq, irq[32]; ResetInfo *reset_info; int i; hwaddr flash_base = 0x04000000; size_t flash_sector_size = 256 * 1024; size_t flash_size = 32 * 1024 * 1024; hwaddr ram_base = 0x08000000; size_t ram_size = 64 * 1024 * 1024; hwaddr timer0_base = 0x80002000; hwaddr uart0_base = 0x80006000; hwaddr timer1_base = 0x8000a000; int uart0_irq = 0; int timer0_irq = 1; int timer1_irq = 3; reset_info = g_malloc0(sizeof(ResetInfo)); if (cpu_model == NULL) { cpu_model = "lm32-full"; cpu = cpu_lm32_init(cpu_model); env = &cpu->env; reset_info->cpu = cpu; reset_info->flash_base = flash_base; memory_region_init_ram(phys_ram, NULL, "lm32_evr.sdram", ram_size); vmstate_register_ram_global(phys_ram); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi02_register(flash_base, NULL, "lm32_evr.flash", flash_size, dinfo ? dinfo->bdrv : NULL, flash_sector_size, flash_size / flash_sector_size, 1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1); cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1); env->pic_state = lm32_pic_init(*cpu_irq); for (i = 0; i < 32; i++) { irq[i] = qdev_get_gpio_in(env->pic_state, i); sysbus_create_simple("lm32-uart", uart0_base, irq[uart0_irq]); sysbus_create_simple("lm32-timer", timer0_base, irq[timer0_irq]); sysbus_create_simple("lm32-timer", timer1_base, irq[timer1_irq]); env->juart_state = lm32_juart_init(); reset_info->bootstrap_pc = flash_base; if (kernel_filename) { uint64_t entry; int kernel_size; kernel_size = load_elf(kernel_filename, NULL, NULL, &entry, NULL, NULL, 1, ELF_MACHINE, 0); reset_info->bootstrap_pc = entry; if (kernel_size < 0) { kernel_size = load_image_targphys(kernel_filename, ram_base, ram_size); reset_info->bootstrap_pc = ram_base; if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", kernel_filename); qemu_register_reset(main_cpu_reset, reset_info);
{ "code": [], "line_no": [] }
static void FUNC_0(QEMUMachineInitArgs *VAR_0) { const char *VAR_1 = VAR_0->VAR_1; const char *VAR_2 = VAR_0->VAR_2; LM32CPU *cpu; CPULM32State *env; DriveInfo *dinfo; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *phys_ram = g_new(MemoryRegion, 1); qemu_irq *cpu_irq, irq[32]; ResetInfo *reset_info; int VAR_3; hwaddr flash_base = 0x04000000; size_t flash_sector_size = 256 * 1024; size_t flash_size = 32 * 1024 * 1024; hwaddr ram_base = 0x08000000; size_t ram_size = 64 * 1024 * 1024; hwaddr timer0_base = 0x80002000; hwaddr uart0_base = 0x80006000; hwaddr timer1_base = 0x8000a000; int VAR_4 = 0; int VAR_5 = 1; int VAR_6 = 3; reset_info = g_malloc0(sizeof(ResetInfo)); if (VAR_1 == NULL) { VAR_1 = "lm32-full"; cpu = cpu_lm32_init(VAR_1); env = &cpu->env; reset_info->cpu = cpu; reset_info->flash_base = flash_base; memory_region_init_ram(phys_ram, NULL, "lm32_evr.sdram", ram_size); vmstate_register_ram_global(phys_ram); memory_region_add_subregion(address_space_mem, ram_base, phys_ram); dinfo = drive_get(IF_PFLASH, 0, 0); pflash_cfi02_register(flash_base, NULL, "lm32_evr.flash", flash_size, dinfo ? dinfo->bdrv : NULL, flash_sector_size, flash_size / flash_sector_size, 1, 2, 0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1); cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1); env->pic_state = lm32_pic_init(*cpu_irq); for (VAR_3 = 0; VAR_3 < 32; VAR_3++) { irq[VAR_3] = qdev_get_gpio_in(env->pic_state, VAR_3); sysbus_create_simple("lm32-uart", uart0_base, irq[VAR_4]); sysbus_create_simple("lm32-timer", timer0_base, irq[VAR_5]); sysbus_create_simple("lm32-timer", timer1_base, irq[VAR_6]); env->juart_state = lm32_juart_init(); reset_info->bootstrap_pc = flash_base; if (VAR_2) { uint64_t entry; int VAR_7; VAR_7 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL, 1, ELF_MACHINE, 0); reset_info->bootstrap_pc = entry; if (VAR_7 < 0) { VAR_7 = load_image_targphys(VAR_2, ram_base, ram_size); reset_info->bootstrap_pc = ram_base; if (VAR_7 < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", VAR_2); qemu_register_reset(main_cpu_reset, reset_info);
[ "static void FUNC_0(QEMUMachineInitArgs *VAR_0)\n{", "const char *VAR_1 = VAR_0->VAR_1;", "const char *VAR_2 = VAR_0->VAR_2;", "LM32CPU *cpu;", "CPULM32State *env;", "DriveInfo *dinfo;", "MemoryRegion *address_space_mem = get_system_memory();", "MemoryRegion *phys_ram = g_new(MemoryRegion, 1);", "qemu_irq *cpu_irq, irq[32];", "ResetInfo *reset_info;", "int VAR_3;", "hwaddr flash_base = 0x04000000;", "size_t flash_sector_size = 256 * 1024;", "size_t flash_size = 32 * 1024 * 1024;", "hwaddr ram_base = 0x08000000;", "size_t ram_size = 64 * 1024 * 1024;", "hwaddr timer0_base = 0x80002000;", "hwaddr uart0_base = 0x80006000;", "hwaddr timer1_base = 0x8000a000;", "int VAR_4 = 0;", "int VAR_5 = 1;", "int VAR_6 = 3;", "reset_info = g_malloc0(sizeof(ResetInfo));", "if (VAR_1 == NULL) {", "VAR_1 = \"lm32-full\";", "cpu = cpu_lm32_init(VAR_1);", "env = &cpu->env;", "reset_info->cpu = cpu;", "reset_info->flash_base = flash_base;", "memory_region_init_ram(phys_ram, NULL, \"lm32_evr.sdram\", ram_size);", "vmstate_register_ram_global(phys_ram);", "memory_region_add_subregion(address_space_mem, ram_base, phys_ram);", "dinfo = drive_get(IF_PFLASH, 0, 0);", "pflash_cfi02_register(flash_base, NULL, \"lm32_evr.flash\", flash_size,\ndinfo ? dinfo->bdrv : NULL, flash_sector_size,\nflash_size / flash_sector_size, 1, 2,\n0x01, 0x7e, 0x43, 0x00, 0x555, 0x2aa, 1);", "cpu_irq = qemu_allocate_irqs(cpu_irq_handler, cpu, 1);", "env->pic_state = lm32_pic_init(*cpu_irq);", "for (VAR_3 = 0; VAR_3 < 32; VAR_3++) {", "irq[VAR_3] = qdev_get_gpio_in(env->pic_state, VAR_3);", "sysbus_create_simple(\"lm32-uart\", uart0_base, irq[VAR_4]);", "sysbus_create_simple(\"lm32-timer\", timer0_base, irq[VAR_5]);", "sysbus_create_simple(\"lm32-timer\", timer1_base, irq[VAR_6]);", "env->juart_state = lm32_juart_init();", "reset_info->bootstrap_pc = flash_base;", "if (VAR_2) {", "uint64_t entry;", "int VAR_7;", "VAR_7 = load_elf(VAR_2, NULL, NULL, &entry, NULL, NULL,\n1, ELF_MACHINE, 0);", "reset_info->bootstrap_pc = entry;", "if (VAR_7 < 0) {", "VAR_7 = load_image_targphys(VAR_2, ram_base,\nram_size);", "reset_info->bootstrap_pc = ram_base;", "if (VAR_7 < 0) {", "fprintf(stderr, \"qemu: could not load kernel '%s'\\n\",\nVAR_2);", "qemu_register_reset(main_cpu_reset, reset_info);" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ], [ 14 ], [ 15 ], [ 16 ], [ 17 ], [ 18 ], [ 19 ], [ 20 ], [ 21 ], [ 22 ], [ 23 ], [ 24 ], [ 25 ], [ 26 ], [ 27 ], [ 28 ], [ 29 ], [ 30 ], [ 31 ], [ 32 ], [ 33 ], [ 34 ], [ 35 ], [ 37, 38, 39, 40 ], [ 42 ], [ 43 ], [ 44 ], [ 45 ], [ 46 ], [ 47 ], [ 48 ], [ 50 ], [ 51 ], [ 52 ], [ 53 ], [ 54 ], [ 55, 56 ], [ 57 ], [ 58 ], [ 59, 60 ], [ 61 ], [ 62 ], [ 63, 64 ], [ 65 ] ]
6,035
static void nam_writel (void *opaque, uint32_t addr, uint32_t val) { PCIAC97LinkState *d = opaque; AC97LinkState *s = &d->ac97; dolog ("U nam writel %#x <- %#x\n", addr, val); s->cas = 0; }
false
qemu
10ee2aaa417d8d8978cdb2bbed55ebb152df5f6b
static void nam_writel (void *opaque, uint32_t addr, uint32_t val) { PCIAC97LinkState *d = opaque; AC97LinkState *s = &d->ac97; dolog ("U nam writel %#x <- %#x\n", addr, val); s->cas = 0; }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, uint32_t VAR_1, uint32_t VAR_2) { PCIAC97LinkState *d = VAR_0; AC97LinkState *s = &d->ac97; dolog ("U nam writel %#x <- %#x\n", VAR_1, VAR_2); s->cas = 0; }
[ "static void FUNC_0 (void *VAR_0, uint32_t VAR_1, uint32_t VAR_2)\n{", "PCIAC97LinkState *d = VAR_0;", "AC97LinkState *s = &d->ac97;", "dolog (\"U nam writel %#x <- %#x\\n\", VAR_1, VAR_2);", "s->cas = 0;", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
6,036
static void smbios_check_collision(int type, int entry) { if (type < ARRAY_SIZE(first_opt)) { if (first_opt[type].seen) { if (first_opt[type].headertype != entry) { error_report("Can't mix file= and type= for same type"); loc_push_restore(&first_opt[type].loc); error_report("This is the conflicting setting"); loc_pop(&first_opt[type].loc); exit(1); } } else { first_opt[type].seen = true; first_opt[type].headertype = entry; loc_save(&first_opt[type].loc); } } }
false
qemu
2e6e8d7a25a6e31dee58226ea7fc374844d69732
static void smbios_check_collision(int type, int entry) { if (type < ARRAY_SIZE(first_opt)) { if (first_opt[type].seen) { if (first_opt[type].headertype != entry) { error_report("Can't mix file= and type= for same type"); loc_push_restore(&first_opt[type].loc); error_report("This is the conflicting setting"); loc_pop(&first_opt[type].loc); exit(1); } } else { first_opt[type].seen = true; first_opt[type].headertype = entry; loc_save(&first_opt[type].loc); } } }
{ "code": [], "line_no": [] }
static void FUNC_0(int VAR_0, int VAR_1) { if (VAR_0 < ARRAY_SIZE(first_opt)) { if (first_opt[VAR_0].seen) { if (first_opt[VAR_0].headertype != VAR_1) { error_report("Can't mix file= and VAR_0= for same VAR_0"); loc_push_restore(&first_opt[VAR_0].loc); error_report("This is the conflicting setting"); loc_pop(&first_opt[VAR_0].loc); exit(1); } } else { first_opt[VAR_0].seen = true; first_opt[VAR_0].headertype = VAR_1; loc_save(&first_opt[VAR_0].loc); } } }
[ "static void FUNC_0(int VAR_0, int VAR_1)\n{", "if (VAR_0 < ARRAY_SIZE(first_opt)) {", "if (first_opt[VAR_0].seen) {", "if (first_opt[VAR_0].headertype != VAR_1) {", "error_report(\"Can't mix file= and VAR_0= for same VAR_0\");", "loc_push_restore(&first_opt[VAR_0].loc);", "error_report(\"This is the conflicting setting\");", "loc_pop(&first_opt[VAR_0].loc);", "exit(1);", "}", "} else {", "first_opt[VAR_0].seen = true;", "first_opt[VAR_0].headertype = VAR_1;", "loc_save(&first_opt[VAR_0].loc);", "}", "}", "}" ]
[ 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 ], [ 31 ], [ 33 ], [ 35 ] ]
6,037
static void monitor_read_command(Monitor *mon, int show_prompt) { if (!mon->rs) return; readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL); if (show_prompt) readline_show_prompt(mon->rs); }
false
qemu
7060b478d3f3a8bc7a282292609ff5aec6de1958
static void monitor_read_command(Monitor *mon, int show_prompt) { if (!mon->rs) return; readline_start(mon->rs, "(qemu) ", 0, monitor_command_cb, NULL); if (show_prompt) readline_show_prompt(mon->rs); }
{ "code": [], "line_no": [] }
static void FUNC_0(Monitor *VAR_0, int VAR_1) { if (!VAR_0->rs) return; readline_start(VAR_0->rs, "(qemu) ", 0, monitor_command_cb, NULL); if (VAR_1) readline_show_prompt(VAR_0->rs); }
[ "static void FUNC_0(Monitor *VAR_0, int VAR_1)\n{", "if (!VAR_0->rs)\nreturn;", "readline_start(VAR_0->rs, \"(qemu) \", 0, monitor_command_cb, NULL);", "if (VAR_1)\nreadline_show_prompt(VAR_0->rs);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5, 7 ], [ 11 ], [ 13, 15 ], [ 17 ] ]
6,038
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; int snapshot = 0; int ret; translation = BIOS_ATA_TRANSLATION_AUTO; if (default_to_scsi) { type = IF_SCSI; pstrcpy(devname, sizeof(devname), "scsi"); } else { type = IF_IDE; pstrcpy(devname, sizeof(devname), "ide"); } media = MEDIA_DISK; /* extract parameters */ bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", buf); return NULL; } } max_devs = if_max_devs[type]; if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls,heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("'%s' invalid physical CHS format", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE; } else if (!strcmp(buf, "writeback")) { bdrv_flags |= BDRV_O_CACHE_WB; } else if (!strcmp(buf, "unsafe")) { bdrv_flags |= BDRV_O_CACHE_WB; bdrv_flags |= BDRV_O_NO_FLUSH; } else if (!strcmp(buf, "writethrough")) { /* this is the default */ } else { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { /* this is the default */ } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } /* compute bus and unit according index */ if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } /* if user doesn't specify a unit_id, * try to find the first free */ if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } /* check unit id */ if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } /* * catch multiple definitions */ if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); return NULL; } /* init */ dinfo = qemu_mallocz(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(buf); } else { /* no id supplied -> create one */ dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; dinfo->refcount = 1; if (serial) strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: bdrv_set_removable(dinfo->bdrv, 1); dinfo->media_cd = 1; break; } break; case IF_SD: /* FIXME: This isn't really a floppy, but it's a reasonable approximation. */ case IF_FLOPPY: bdrv_set_removable(dinfo->bdrv, 1); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: /* add virtio block device */ opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk"); qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; default: abort(); } if (!file || !*file) { return dinfo; } if (snapshot) { /* always use cache=unsafe with snapshot */ bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (media == MEDIA_CDROM) { /* CDROM is fine for any interface, don't check. */ ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) { error_report("readonly not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); qemu_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); return NULL; }
false
qemu
a659979328fb6d4d6100d398f5bd9a2310c3e169
DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi) { const char *buf; const char *file = NULL; char devname[128]; const char *serial; const char *mediastr = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } media; int bus_id, unit_id; int cyls, heads, secs, translation; BlockDriver *drv = NULL; int max_devs; int index; int ro = 0; int bdrv_flags = 0; int on_read_error, on_write_error; const char *devaddr; DriveInfo *dinfo; int snapshot = 0; int ret; translation = BIOS_ATA_TRANSLATION_AUTO; if (default_to_scsi) { type = IF_SCSI; pstrcpy(devname, sizeof(devname), "scsi"); } else { type = IF_IDE; pstrcpy(devname, sizeof(devname), "ide"); } media = MEDIA_DISK; bus_id = qemu_opt_get_number(opts, "bus", 0); unit_id = qemu_opt_get_number(opts, "unit", -1); index = qemu_opt_get_number(opts, "index", -1); cyls = qemu_opt_get_number(opts, "cyls", 0); heads = qemu_opt_get_number(opts, "heads", 0); secs = qemu_opt_get_number(opts, "secs", 0); snapshot = qemu_opt_get_bool(opts, "snapshot", 0); ro = qemu_opt_get_bool(opts, "readonly", 0); file = qemu_opt_get(opts, "file"); serial = qemu_opt_get(opts, "serial"); if ((buf = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(devname, sizeof(devname), buf); for (type = 0; type < IF_COUNT && strcmp(buf, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", buf); return NULL; } } max_devs = if_max_devs[type]; if (cyls || heads || secs) { if (cyls < 1 || (type == IF_IDE && cyls > 16383)) { error_report("invalid physical cyls number"); return NULL; } if (heads < 1 || (type == IF_IDE && heads > 16)) { error_report("invalid physical heads number"); return NULL; } if (secs < 1 || (type == IF_IDE && secs > 63)) { error_report("invalid physical secs number"); return NULL; } } if ((buf = qemu_opt_get(opts, "trans")) != NULL) { if (!cyls) { error_report("'%s' trans must be used with cyls,heads and secs", buf); return NULL; } if (!strcmp(buf, "none")) translation = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(buf, "lba")) translation = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(buf, "auto")) translation = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid translation type", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "media")) != NULL) { if (!strcmp(buf, "disk")) { media = MEDIA_DISK; } else if (!strcmp(buf, "cdrom")) { if (cyls || secs || heads) { error_report("'%s' invalid physical CHS format", buf); return NULL; } media = MEDIA_CDROM; } else { error_report("'%s' invalid media", buf); return NULL; } } if ((buf = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE; } else if (!strcmp(buf, "writeback")) { bdrv_flags |= BDRV_O_CACHE_WB; } else if (!strcmp(buf, "unsafe")) { bdrv_flags |= BDRV_O_CACHE_WB; bdrv_flags |= BDRV_O_NO_FLUSH; } else if (!strcmp(buf, "writethrough")) { } else { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((buf = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(buf, "native")) { bdrv_flags |= BDRV_O_NATIVE_AIO; } else if (!strcmp(buf, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((buf = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(buf, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(buf); if (!drv) { error_report("'%s' invalid format", buf); return NULL; } } on_write_error = BLOCK_ERR_STOP_ENOSPC; if ((buf = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } on_write_error = parse_block_error_action(buf, 0); if (on_write_error < 0) { return NULL; } } on_read_error = BLOCK_ERR_REPORT; if ((buf = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } on_read_error = parse_block_error_action(buf, 1); if (on_read_error < 0) { return NULL; } } if ((devaddr = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (index != -1) { if (bus_id != 0 || unit_id != -1) { error_report("index cannot be used with bus and unit"); return NULL; } bus_id = drive_index_to_bus_id(type, index); unit_id = drive_index_to_unit_id(type, index); } if (unit_id == -1) { unit_id = 0; while (drive_get(type, bus_id, unit_id) != NULL) { unit_id++; if (max_devs && unit_id >= max_devs) { unit_id -= max_devs; bus_id++; } } } if (max_devs && unit_id >= max_devs) { error_report("unit %d too big (max is %d)", unit_id, max_devs - 1); return NULL; } if (drive_get(type, bus_id, unit_id) != NULL) { error_report("drive with bus=%d, unit=%d (index=%d) exists", bus_id, unit_id, index); return NULL; } dinfo = qemu_mallocz(sizeof(*dinfo)); if ((buf = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(buf); } else { dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) mediastr = (media == MEDIA_CDROM) ? "-cd" : "-hd"; if (max_devs) snprintf(dinfo->id, 32, "%s%i%s%i", devname, bus_id, mediastr, unit_id); else snprintf(dinfo->id, 32, "%s%s%i", devname, mediastr, unit_id); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->devaddr = devaddr; dinfo->type = type; dinfo->bus = bus_id; dinfo->unit = unit_id; dinfo->opts = opts; dinfo->refcount = 1; if (serial) strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(media) { case MEDIA_DISK: if (cyls != 0) { bdrv_set_geometry_hint(dinfo->bdrv, cyls, heads, secs); bdrv_set_translation_hint(dinfo->bdrv, translation); } break; case MEDIA_CDROM: bdrv_set_removable(dinfo->bdrv, 1); dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: bdrv_set_removable(dinfo->bdrv, 1); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk"); qemu_opt_set(opts, "drive", dinfo->id); if (devaddr) qemu_opt_set(opts, "addr", devaddr); break; default: abort(); } if (!file || !*file) { return dinfo; } if (snapshot) { bdrv_flags &= ~BDRV_O_CACHE_MASK; bdrv_flags |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (media == MEDIA_CDROM) { ro = 1; } else if (ro == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) { error_report("readonly not supported by this bus type"); goto err; } } bdrv_flags |= ro ? 0 : BDRV_O_RDWR; ret = bdrv_open(dinfo->bdrv, file, bdrv_flags, drv); if (ret < 0) { error_report("could not open disk image %s: %s", file, strerror(-ret)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); qemu_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); return NULL; }
{ "code": [], "line_no": [] }
DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi) { const char *VAR_0; const char *VAR_1 = NULL; char VAR_2[128]; const char *VAR_3; const char *VAR_4 = ""; BlockInterfaceType type; enum { MEDIA_DISK, MEDIA_CDROM } VAR_5; int VAR_6, VAR_7; int VAR_8, VAR_9, VAR_10, VAR_11; BlockDriver *drv = NULL; int VAR_12; int VAR_13; int VAR_14 = 0; int VAR_15 = 0; int VAR_16, VAR_17; const char *VAR_18; DriveInfo *dinfo; int VAR_19 = 0; int VAR_20; VAR_11 = BIOS_ATA_TRANSLATION_AUTO; if (default_to_scsi) { type = IF_SCSI; pstrcpy(VAR_2, sizeof(VAR_2), "scsi"); } else { type = IF_IDE; pstrcpy(VAR_2, sizeof(VAR_2), "ide"); } VAR_5 = MEDIA_DISK; VAR_6 = qemu_opt_get_number(opts, "bus", 0); VAR_7 = qemu_opt_get_number(opts, "unit", -1); VAR_13 = qemu_opt_get_number(opts, "VAR_13", -1); VAR_8 = qemu_opt_get_number(opts, "VAR_8", 0); VAR_9 = qemu_opt_get_number(opts, "VAR_9", 0); VAR_10 = qemu_opt_get_number(opts, "VAR_10", 0); VAR_19 = qemu_opt_get_bool(opts, "VAR_19", 0); VAR_14 = qemu_opt_get_bool(opts, "readonly", 0); VAR_1 = qemu_opt_get(opts, "VAR_1"); VAR_3 = qemu_opt_get(opts, "VAR_3"); if ((VAR_0 = qemu_opt_get(opts, "if")) != NULL) { pstrcpy(VAR_2, sizeof(VAR_2), VAR_0); for (type = 0; type < IF_COUNT && strcmp(VAR_0, if_name[type]); type++) ; if (type == IF_COUNT) { error_report("unsupported bus type '%s'", VAR_0); return NULL; } } VAR_12 = if_max_devs[type]; if (VAR_8 || VAR_9 || VAR_10) { if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) { error_report("invalid physical VAR_8 number"); return NULL; } if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) { error_report("invalid physical VAR_9 number"); return NULL; } if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) { error_report("invalid physical VAR_10 number"); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "trans")) != NULL) { if (!VAR_8) { error_report("'%s' trans must be used with VAR_8,VAR_9 and VAR_10", VAR_0); return NULL; } if (!strcmp(VAR_0, "none")) VAR_11 = BIOS_ATA_TRANSLATION_NONE; else if (!strcmp(VAR_0, "lba")) VAR_11 = BIOS_ATA_TRANSLATION_LBA; else if (!strcmp(VAR_0, "auto")) VAR_11 = BIOS_ATA_TRANSLATION_AUTO; else { error_report("'%s' invalid VAR_11 type", VAR_0); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "VAR_5")) != NULL) { if (!strcmp(VAR_0, "disk")) { VAR_5 = MEDIA_DISK; } else if (!strcmp(VAR_0, "cdrom")) { if (VAR_8 || VAR_10 || VAR_9) { error_report("'%s' invalid physical CHS format", VAR_0); return NULL; } VAR_5 = MEDIA_CDROM; } else { error_report("'%s' invalid VAR_5", VAR_0); return NULL; } } if ((VAR_0 = qemu_opt_get(opts, "cache")) != NULL) { if (!strcmp(VAR_0, "off") || !strcmp(VAR_0, "none")) { VAR_15 |= BDRV_O_NOCACHE; } else if (!strcmp(VAR_0, "writeback")) { VAR_15 |= BDRV_O_CACHE_WB; } else if (!strcmp(VAR_0, "unsafe")) { VAR_15 |= BDRV_O_CACHE_WB; VAR_15 |= BDRV_O_NO_FLUSH; } else if (!strcmp(VAR_0, "writethrough")) { } else { error_report("invalid cache option"); return NULL; } } #ifdef CONFIG_LINUX_AIO if ((VAR_0 = qemu_opt_get(opts, "aio")) != NULL) { if (!strcmp(VAR_0, "native")) { VAR_15 |= BDRV_O_NATIVE_AIO; } else if (!strcmp(VAR_0, "threads")) { } else { error_report("invalid aio option"); return NULL; } } #endif if ((VAR_0 = qemu_opt_get(opts, "format")) != NULL) { if (strcmp(VAR_0, "?") == 0) { error_printf("Supported formats:"); bdrv_iterate_format(bdrv_format_print, NULL); error_printf("\n"); return NULL; } drv = bdrv_find_whitelisted_format(VAR_0); if (!drv) { error_report("'%s' invalid format", VAR_0); return NULL; } } VAR_17 = BLOCK_ERR_STOP_ENOSPC; if ((VAR_0 = qemu_opt_get(opts, "werror")) != NULL) { if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) { error_report("werror is not supported by this bus type"); return NULL; } VAR_17 = parse_block_error_action(VAR_0, 0); if (VAR_17 < 0) { return NULL; } } VAR_16 = BLOCK_ERR_REPORT; if ((VAR_0 = qemu_opt_get(opts, "rerror")) != NULL) { if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) { error_report("rerror is not supported by this bus type"); return NULL; } VAR_16 = parse_block_error_action(VAR_0, 1); if (VAR_16 < 0) { return NULL; } } if ((VAR_18 = qemu_opt_get(opts, "addr")) != NULL) { if (type != IF_VIRTIO) { error_report("addr is not supported by this bus type"); return NULL; } } if (VAR_13 != -1) { if (VAR_6 != 0 || VAR_7 != -1) { error_report("VAR_13 cannot be used with bus and unit"); return NULL; } VAR_6 = drive_index_to_bus_id(type, VAR_13); VAR_7 = drive_index_to_unit_id(type, VAR_13); } if (VAR_7 == -1) { VAR_7 = 0; while (drive_get(type, VAR_6, VAR_7) != NULL) { VAR_7++; if (VAR_12 && VAR_7 >= VAR_12) { VAR_7 -= VAR_12; VAR_6++; } } } if (VAR_12 && VAR_7 >= VAR_12) { error_report("unit %d too big (max is %d)", VAR_7, VAR_12 - 1); return NULL; } if (drive_get(type, VAR_6, VAR_7) != NULL) { error_report("drive with bus=%d, unit=%d (VAR_13=%d) exists", VAR_6, VAR_7, VAR_13); return NULL; } dinfo = qemu_mallocz(sizeof(*dinfo)); if ((VAR_0 = qemu_opts_id(opts)) != NULL) { dinfo->id = qemu_strdup(VAR_0); } else { dinfo->id = qemu_mallocz(32); if (type == IF_IDE || type == IF_SCSI) VAR_4 = (VAR_5 == MEDIA_CDROM) ? "-cd" : "-hd"; if (VAR_12) snprintf(dinfo->id, 32, "%s%i%s%i", VAR_2, VAR_6, VAR_4, VAR_7); else snprintf(dinfo->id, 32, "%s%s%i", VAR_2, VAR_4, VAR_7); } dinfo->bdrv = bdrv_new(dinfo->id); dinfo->VAR_18 = VAR_18; dinfo->type = type; dinfo->bus = VAR_6; dinfo->unit = VAR_7; dinfo->opts = opts; dinfo->refcount = 1; if (VAR_3) strncpy(dinfo->VAR_3, VAR_3, sizeof(dinfo->VAR_3) - 1); QTAILQ_INSERT_TAIL(&drives, dinfo, next); bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17); switch(type) { case IF_IDE: case IF_SCSI: case IF_XEN: case IF_NONE: switch(VAR_5) { case MEDIA_DISK: if (VAR_8 != 0) { bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10); bdrv_set_translation_hint(dinfo->bdrv, VAR_11); } break; case MEDIA_CDROM: bdrv_set_removable(dinfo->bdrv, 1); dinfo->media_cd = 1; break; } break; case IF_SD: case IF_FLOPPY: bdrv_set_removable(dinfo->bdrv, 1); break; case IF_PFLASH: case IF_MTD: break; case IF_VIRTIO: opts = qemu_opts_create(qemu_find_opts("device"), NULL, 0); qemu_opt_set(opts, "driver", "virtio-blk"); qemu_opt_set(opts, "drive", dinfo->id); if (VAR_18) qemu_opt_set(opts, "addr", VAR_18); break; default: abort(); } if (!VAR_1 || !*VAR_1) { return dinfo; } if (VAR_19) { VAR_15 &= ~BDRV_O_CACHE_MASK; VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH); } if (VAR_5 == MEDIA_CDROM) { VAR_14 = 1; } else if (VAR_14 == 1) { if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) { error_report("readonly not supported by this bus type"); goto err; } } VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR; VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv); if (VAR_20 < 0) { error_report("could not open disk image %s: %s", VAR_1, strerror(-VAR_20)); goto err; } if (bdrv_key_required(dinfo->bdrv)) autostart = 0; return dinfo; err: bdrv_delete(dinfo->bdrv); qemu_free(dinfo->id); QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); return NULL; }
[ "DriveInfo *FUNC_0(QemuOpts *opts, int default_to_scsi)\n{", "const char *VAR_0;", "const char *VAR_1 = NULL;", "char VAR_2[128];", "const char *VAR_3;", "const char *VAR_4 = \"\";", "BlockInterfaceType type;", "enum { MEDIA_DISK, MEDIA_CDROM } VAR_5;", "int VAR_6, VAR_7;", "int VAR_8, VAR_9, VAR_10, VAR_11;", "BlockDriver *drv = NULL;", "int VAR_12;", "int VAR_13;", "int VAR_14 = 0;", "int VAR_15 = 0;", "int VAR_16, VAR_17;", "const char *VAR_18;", "DriveInfo *dinfo;", "int VAR_19 = 0;", "int VAR_20;", "VAR_11 = BIOS_ATA_TRANSLATION_AUTO;", "if (default_to_scsi) {", "type = IF_SCSI;", "pstrcpy(VAR_2, sizeof(VAR_2), \"scsi\");", "} else {", "type = IF_IDE;", "pstrcpy(VAR_2, sizeof(VAR_2), \"ide\");", "}", "VAR_5 = MEDIA_DISK;", "VAR_6 = qemu_opt_get_number(opts, \"bus\", 0);", "VAR_7 = qemu_opt_get_number(opts, \"unit\", -1);", "VAR_13 = qemu_opt_get_number(opts, \"VAR_13\", -1);", "VAR_8 = qemu_opt_get_number(opts, \"VAR_8\", 0);", "VAR_9 = qemu_opt_get_number(opts, \"VAR_9\", 0);", "VAR_10 = qemu_opt_get_number(opts, \"VAR_10\", 0);", "VAR_19 = qemu_opt_get_bool(opts, \"VAR_19\", 0);", "VAR_14 = qemu_opt_get_bool(opts, \"readonly\", 0);", "VAR_1 = qemu_opt_get(opts, \"VAR_1\");", "VAR_3 = qemu_opt_get(opts, \"VAR_3\");", "if ((VAR_0 = qemu_opt_get(opts, \"if\")) != NULL) {", "pstrcpy(VAR_2, sizeof(VAR_2), VAR_0);", "for (type = 0; type < IF_COUNT && strcmp(VAR_0, if_name[type]); type++)", ";", "if (type == IF_COUNT) {", "error_report(\"unsupported bus type '%s'\", VAR_0);", "return NULL;", "}", "}", "VAR_12 = if_max_devs[type];", "if (VAR_8 || VAR_9 || VAR_10) {", "if (VAR_8 < 1 || (type == IF_IDE && VAR_8 > 16383)) {", "error_report(\"invalid physical VAR_8 number\");", "return NULL;", "}", "if (VAR_9 < 1 || (type == IF_IDE && VAR_9 > 16)) {", "error_report(\"invalid physical VAR_9 number\");", "return NULL;", "}", "if (VAR_10 < 1 || (type == IF_IDE && VAR_10 > 63)) {", "error_report(\"invalid physical VAR_10 number\");", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"trans\")) != NULL) {", "if (!VAR_8) {", "error_report(\"'%s' trans must be used with VAR_8,VAR_9 and VAR_10\",\nVAR_0);", "return NULL;", "}", "if (!strcmp(VAR_0, \"none\"))\nVAR_11 = BIOS_ATA_TRANSLATION_NONE;", "else if (!strcmp(VAR_0, \"lba\"))\nVAR_11 = BIOS_ATA_TRANSLATION_LBA;", "else if (!strcmp(VAR_0, \"auto\"))\nVAR_11 = BIOS_ATA_TRANSLATION_AUTO;", "else {", "error_report(\"'%s' invalid VAR_11 type\", VAR_0);", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"VAR_5\")) != NULL) {", "if (!strcmp(VAR_0, \"disk\")) {", "VAR_5 = MEDIA_DISK;", "} else if (!strcmp(VAR_0, \"cdrom\")) {", "if (VAR_8 || VAR_10 || VAR_9) {", "error_report(\"'%s' invalid physical CHS format\", VAR_0);", "return NULL;", "}", "VAR_5 = MEDIA_CDROM;", "} else {", "error_report(\"'%s' invalid VAR_5\", VAR_0);", "return NULL;", "}", "}", "if ((VAR_0 = qemu_opt_get(opts, \"cache\")) != NULL) {", "if (!strcmp(VAR_0, \"off\") || !strcmp(VAR_0, \"none\")) {", "VAR_15 |= BDRV_O_NOCACHE;", "} else if (!strcmp(VAR_0, \"writeback\")) {", "VAR_15 |= BDRV_O_CACHE_WB;", "} else if (!strcmp(VAR_0, \"unsafe\")) {", "VAR_15 |= BDRV_O_CACHE_WB;", "VAR_15 |= BDRV_O_NO_FLUSH;", "} else if (!strcmp(VAR_0, \"writethrough\")) {", "} else {", "error_report(\"invalid cache option\");", "return NULL;", "}", "}", "#ifdef CONFIG_LINUX_AIO\nif ((VAR_0 = qemu_opt_get(opts, \"aio\")) != NULL) {", "if (!strcmp(VAR_0, \"native\")) {", "VAR_15 |= BDRV_O_NATIVE_AIO;", "} else if (!strcmp(VAR_0, \"threads\")) {", "} else {", "error_report(\"invalid aio option\");", "return NULL;", "}", "}", "#endif\nif ((VAR_0 = qemu_opt_get(opts, \"format\")) != NULL) {", "if (strcmp(VAR_0, \"?\") == 0) {", "error_printf(\"Supported formats:\");", "bdrv_iterate_format(bdrv_format_print, NULL);", "error_printf(\"\\n\");", "return NULL;", "}", "drv = bdrv_find_whitelisted_format(VAR_0);", "if (!drv) {", "error_report(\"'%s' invalid format\", VAR_0);", "return NULL;", "}", "}", "VAR_17 = BLOCK_ERR_STOP_ENOSPC;", "if ((VAR_0 = qemu_opt_get(opts, \"werror\")) != NULL) {", "if (type != IF_IDE && type != IF_SCSI && type != IF_VIRTIO && type != IF_NONE) {", "error_report(\"werror is not supported by this bus type\");", "return NULL;", "}", "VAR_17 = parse_block_error_action(VAR_0, 0);", "if (VAR_17 < 0) {", "return NULL;", "}", "}", "VAR_16 = BLOCK_ERR_REPORT;", "if ((VAR_0 = qemu_opt_get(opts, \"rerror\")) != NULL) {", "if (type != IF_IDE && type != IF_VIRTIO && type != IF_SCSI && type != IF_NONE) {", "error_report(\"rerror is not supported by this bus type\");", "return NULL;", "}", "VAR_16 = parse_block_error_action(VAR_0, 1);", "if (VAR_16 < 0) {", "return NULL;", "}", "}", "if ((VAR_18 = qemu_opt_get(opts, \"addr\")) != NULL) {", "if (type != IF_VIRTIO) {", "error_report(\"addr is not supported by this bus type\");", "return NULL;", "}", "}", "if (VAR_13 != -1) {", "if (VAR_6 != 0 || VAR_7 != -1) {", "error_report(\"VAR_13 cannot be used with bus and unit\");", "return NULL;", "}", "VAR_6 = drive_index_to_bus_id(type, VAR_13);", "VAR_7 = drive_index_to_unit_id(type, VAR_13);", "}", "if (VAR_7 == -1) {", "VAR_7 = 0;", "while (drive_get(type, VAR_6, VAR_7) != NULL) {", "VAR_7++;", "if (VAR_12 && VAR_7 >= VAR_12) {", "VAR_7 -= VAR_12;", "VAR_6++;", "}", "}", "}", "if (VAR_12 && VAR_7 >= VAR_12) {", "error_report(\"unit %d too big (max is %d)\",\nVAR_7, VAR_12 - 1);", "return NULL;", "}", "if (drive_get(type, VAR_6, VAR_7) != NULL) {", "error_report(\"drive with bus=%d, unit=%d (VAR_13=%d) exists\",\nVAR_6, VAR_7, VAR_13);", "return NULL;", "}", "dinfo = qemu_mallocz(sizeof(*dinfo));", "if ((VAR_0 = qemu_opts_id(opts)) != NULL) {", "dinfo->id = qemu_strdup(VAR_0);", "} else {", "dinfo->id = qemu_mallocz(32);", "if (type == IF_IDE || type == IF_SCSI)\nVAR_4 = (VAR_5 == MEDIA_CDROM) ? \"-cd\" : \"-hd\";", "if (VAR_12)\nsnprintf(dinfo->id, 32, \"%s%i%s%i\",\nVAR_2, VAR_6, VAR_4, VAR_7);", "else\nsnprintf(dinfo->id, 32, \"%s%s%i\",\nVAR_2, VAR_4, VAR_7);", "}", "dinfo->bdrv = bdrv_new(dinfo->id);", "dinfo->VAR_18 = VAR_18;", "dinfo->type = type;", "dinfo->bus = VAR_6;", "dinfo->unit = VAR_7;", "dinfo->opts = opts;", "dinfo->refcount = 1;", "if (VAR_3)\nstrncpy(dinfo->VAR_3, VAR_3, sizeof(dinfo->VAR_3) - 1);", "QTAILQ_INSERT_TAIL(&drives, dinfo, next);", "bdrv_set_on_error(dinfo->bdrv, VAR_16, VAR_17);", "switch(type) {", "case IF_IDE:\ncase IF_SCSI:\ncase IF_XEN:\ncase IF_NONE:\nswitch(VAR_5) {", "case MEDIA_DISK:\nif (VAR_8 != 0) {", "bdrv_set_geometry_hint(dinfo->bdrv, VAR_8, VAR_9, VAR_10);", "bdrv_set_translation_hint(dinfo->bdrv, VAR_11);", "}", "break;", "case MEDIA_CDROM:\nbdrv_set_removable(dinfo->bdrv, 1);", "dinfo->media_cd = 1;", "break;", "}", "break;", "case IF_SD:\ncase IF_FLOPPY:\nbdrv_set_removable(dinfo->bdrv, 1);", "break;", "case IF_PFLASH:\ncase IF_MTD:\nbreak;", "case IF_VIRTIO:\nopts = qemu_opts_create(qemu_find_opts(\"device\"), NULL, 0);", "qemu_opt_set(opts, \"driver\", \"virtio-blk\");", "qemu_opt_set(opts, \"drive\", dinfo->id);", "if (VAR_18)\nqemu_opt_set(opts, \"addr\", VAR_18);", "break;", "default:\nabort();", "}", "if (!VAR_1 || !*VAR_1) {", "return dinfo;", "}", "if (VAR_19) {", "VAR_15 &= ~BDRV_O_CACHE_MASK;", "VAR_15 |= (BDRV_O_SNAPSHOT|BDRV_O_CACHE_WB|BDRV_O_NO_FLUSH);", "}", "if (VAR_5 == MEDIA_CDROM) {", "VAR_14 = 1;", "} else if (VAR_14 == 1) {", "if (type != IF_SCSI && type != IF_VIRTIO && type != IF_FLOPPY && type != IF_NONE) {", "error_report(\"readonly not supported by this bus type\");", "goto err;", "}", "}", "VAR_15 |= VAR_14 ? 0 : BDRV_O_RDWR;", "VAR_20 = bdrv_open(dinfo->bdrv, VAR_1, VAR_15, drv);", "if (VAR_20 < 0) {", "error_report(\"could not open disk image %s: %s\",\nVAR_1, strerror(-VAR_20));", "goto err;", "}", "if (bdrv_key_required(dinfo->bdrv))\nautostart = 0;", "return dinfo;", "err:\nbdrv_delete(dinfo->bdrv);", "qemu_free(dinfo->id);", "QTAILQ_REMOVE(&drives, dinfo, next);", "qemu_free(dinfo);", "return NULL;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 149 ], [ 151 ], [ 153, 155 ], [ 157 ], [ 159 ], [ 161, 163 ], [ 165, 167 ], [ 169, 171 ], [ 173 ], [ 175 ], [ 177 ], [ 179 ], [ 181 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 197 ], [ 199 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 209 ], [ 211 ], [ 215 ], [ 217 ], [ 219 ], [ 221 ], [ 223 ], [ 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 241 ], [ 243 ], [ 247, 249 ], [ 251 ], [ 253 ], [ 255 ], [ 259 ], [ 261 ], [ 263 ], [ 265 ], [ 267 ], [ 269, 273 ], [ 275 ], [ 277 ], [ 279 ], [ 281 ], [ 283 ], [ 285 ], [ 287 ], [ 289 ], [ 291 ], [ 293 ], [ 295 ], [ 297 ], [ 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ], [ 315 ], [ 317 ], [ 319 ], [ 321 ], [ 323 ], [ 327 ], [ 329 ], [ 331 ], [ 333 ], [ 335 ], [ 337 ], [ 341 ], [ 343 ], [ 345 ], [ 347 ], [ 349 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361 ], [ 363 ], [ 371 ], [ 373 ], [ 375 ], [ 377 ], [ 379 ], [ 381 ], [ 383 ], [ 385 ], [ 397 ], [ 399 ], [ 401 ], [ 403 ], [ 405 ], [ 407 ], [ 409 ], [ 411 ], [ 413 ], [ 415 ], [ 423 ], [ 425, 427 ], [ 429 ], [ 431 ], [ 443 ], [ 445, 447 ], [ 449 ], [ 451 ], [ 459 ], [ 461 ], [ 463 ], [ 465 ], [ 469 ], [ 471, 473 ], [ 475, 477, 479 ], [ 481, 483, 485 ], [ 487 ], [ 489 ], [ 491 ], [ 493 ], [ 495 ], [ 497 ], [ 499 ], [ 501 ], [ 503, 505 ], [ 507 ], [ 511 ], [ 515 ], [ 517, 519, 521, 523, 525 ], [ 527, 529 ], [ 531 ], [ 533 ], [ 535 ], [ 537 ], [ 539, 541 ], [ 543 ], [ 545 ], [ 547 ], [ 549 ], [ 551, 557, 559 ], [ 561 ], [ 563, 565, 567 ], [ 569, 573 ], [ 575 ], [ 577 ], [ 579, 581 ], [ 583 ], [ 585, 587 ], [ 589 ], [ 591 ], [ 593 ], [ 595 ], [ 597 ], [ 601 ], [ 603 ], [ 605 ], [ 609 ], [ 613 ], [ 615 ], [ 617 ], [ 619 ], [ 621 ], [ 623 ], [ 625 ], [ 629 ], [ 633 ], [ 635 ], [ 637, 639 ], [ 641 ], [ 643 ], [ 647, 649 ], [ 651 ], [ 655, 657 ], [ 659 ], [ 661 ], [ 663 ], [ 665 ], [ 667 ] ]
6,039
static void sx1_init(MachineState *machine, const int version) { struct omap_mpu_state_s *mpu; MemoryRegion *address_space = get_system_memory(); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *flash_1 = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t cs0val = 0x00213090; static uint32_t cs1val = 0x00215070; static uint32_t cs2val = 0x00001139; static uint32_t cs3val = 0x00001139; DriveInfo *dinfo; int fl_idx; uint32_t flash_size = flash0_size; int be; if (version == 2) { flash_size = flash2_size; } mpu = omap310_mpu_init(address_space, sx1_binfo.ram_size, machine->cpu_model); /* External Flash (EMIFS) */ memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, &error_abort); vmstate_register_ram_global(flash); memory_region_set_readonly(flash, true); memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "sx1.cs0", OMAP_CS0_SIZE - flash_size); memory_region_add_subregion(address_space, OMAP_CS0_BASE + flash_size, &cs[0]); memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val, "sx1.cs2", OMAP_CS2_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[2]); memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val, "sx1.cs3", OMAP_CS3_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[3]); fl_idx = 0; #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL, "omap_sx1.flash0-1", flash_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } if ((version == 1) && (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size, &error_abort); vmstate_register_ram_global(flash_1); memory_region_set_readonly(flash_1, true); memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE - flash1_size); memory_region_add_subregion(address_space, OMAP_CS1_BASE + flash1_size, &cs[1]); if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL, "omap_sx1.flash1-1", flash1_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash1_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } else { memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE); memory_region_add_subregion(address_space, OMAP_CS1_BASE, &cs[1]); } if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) { fprintf(stderr, "Kernel or Flash image must be specified\n"); exit(1); } /* Load the kernel. */ sx1_binfo.kernel_filename = machine->kernel_filename; sx1_binfo.kernel_cmdline = machine->kernel_cmdline; sx1_binfo.initrd_filename = machine->initrd_filename; arm_load_kernel(mpu->cpu, &sx1_binfo); /* TODO: fix next line */ //~ qemu_console_resize(ds, 640, 480); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
static void sx1_init(MachineState *machine, const int version) { struct omap_mpu_state_s *mpu; MemoryRegion *address_space = get_system_memory(); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *flash_1 = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t cs0val = 0x00213090; static uint32_t cs1val = 0x00215070; static uint32_t cs2val = 0x00001139; static uint32_t cs3val = 0x00001139; DriveInfo *dinfo; int fl_idx; uint32_t flash_size = flash0_size; int be; if (version == 2) { flash_size = flash2_size; } mpu = omap310_mpu_init(address_space, sx1_binfo.ram_size, machine->cpu_model); memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, &error_abort); vmstate_register_ram_global(flash); memory_region_set_readonly(flash, true); memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); memory_region_init_io(&cs[0], NULL, &static_ops, &cs0val, "sx1.cs0", OMAP_CS0_SIZE - flash_size); memory_region_add_subregion(address_space, OMAP_CS0_BASE + flash_size, &cs[0]); memory_region_init_io(&cs[2], NULL, &static_ops, &cs2val, "sx1.cs2", OMAP_CS2_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[2]); memory_region_init_io(&cs[3], NULL, &static_ops, &cs3val, "sx1.cs3", OMAP_CS3_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[3]); fl_idx = 0; #ifdef TARGET_WORDS_BIGENDIAN be = 1; #else be = 0; #endif if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL, "omap_sx1.flash0-1", flash_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } if ((version == 1) && (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size, &error_abort); vmstate_register_ram_global(flash_1); memory_region_set_readonly(flash_1, true); memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE - flash1_size); memory_region_add_subregion(address_space, OMAP_CS1_BASE + flash1_size, &cs[1]); if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL, "omap_sx1.flash1-1", flash1_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash1_size / sector_size, 4, 0, 0, 0, 0, be)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", fl_idx); } fl_idx++; } else { memory_region_init_io(&cs[1], NULL, &static_ops, &cs1val, "sx1.cs1", OMAP_CS1_SIZE); memory_region_add_subregion(address_space, OMAP_CS1_BASE, &cs[1]); } if (!machine->kernel_filename && !fl_idx && !qtest_enabled()) { fprintf(stderr, "Kernel or Flash image must be specified\n"); exit(1); } sx1_binfo.kernel_filename = machine->kernel_filename; sx1_binfo.kernel_cmdline = machine->kernel_cmdline; sx1_binfo.initrd_filename = machine->initrd_filename; arm_load_kernel(mpu->cpu, &sx1_binfo); }
{ "code": [], "line_no": [] }
static void FUNC_0(MachineState *VAR_0, const int VAR_1) { struct omap_mpu_state_s *VAR_2; MemoryRegion *address_space = get_system_memory(); MemoryRegion *flash = g_new(MemoryRegion, 1); MemoryRegion *flash_1 = g_new(MemoryRegion, 1); MemoryRegion *cs = g_new(MemoryRegion, 4); static uint32_t VAR_3 = 0x00213090; static uint32_t VAR_4 = 0x00215070; static uint32_t VAR_5 = 0x00001139; static uint32_t VAR_6 = 0x00001139; DriveInfo *dinfo; int VAR_7; uint32_t flash_size = flash0_size; int VAR_8; if (VAR_1 == 2) { flash_size = flash2_size; } VAR_2 = omap310_mpu_init(address_space, sx1_binfo.ram_size, VAR_0->cpu_model); memory_region_init_ram(flash, NULL, "omap_sx1.flash0-0", flash_size, &error_abort); vmstate_register_ram_global(flash); memory_region_set_readonly(flash, true); memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); memory_region_init_io(&cs[0], NULL, &static_ops, &VAR_3, "sx1.cs0", OMAP_CS0_SIZE - flash_size); memory_region_add_subregion(address_space, OMAP_CS0_BASE + flash_size, &cs[0]); memory_region_init_io(&cs[2], NULL, &static_ops, &VAR_5, "sx1.cs2", OMAP_CS2_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[2]); memory_region_init_io(&cs[3], NULL, &static_ops, &VAR_6, "sx1.cs3", OMAP_CS3_SIZE); memory_region_add_subregion(address_space, OMAP_CS2_BASE, &cs[3]); VAR_7 = 0; #ifdef TARGET_WORDS_BIGENDIAN VAR_8 = 1; #else VAR_8 = 0; #endif if ((dinfo = drive_get(IF_PFLASH, 0, VAR_7)) != NULL) { if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL, "omap_sx1.flash0-1", flash_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash_size / sector_size, 4, 0, 0, 0, 0, VAR_8)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", VAR_7); } VAR_7++; } if ((VAR_1 == 1) && (dinfo = drive_get(IF_PFLASH, 0, VAR_7)) != NULL) { memory_region_init_ram(flash_1, NULL, "omap_sx1.flash1-0", flash1_size, &error_abort); vmstate_register_ram_global(flash_1); memory_region_set_readonly(flash_1, true); memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); memory_region_init_io(&cs[1], NULL, &static_ops, &VAR_4, "sx1.cs1", OMAP_CS1_SIZE - flash1_size); memory_region_add_subregion(address_space, OMAP_CS1_BASE + flash1_size, &cs[1]); if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL, "omap_sx1.flash1-1", flash1_size, blk_bs(blk_by_legacy_dinfo(dinfo)), sector_size, flash1_size / sector_size, 4, 0, 0, 0, 0, VAR_8)) { fprintf(stderr, "qemu: Error registering flash memory %d.\n", VAR_7); } VAR_7++; } else { memory_region_init_io(&cs[1], NULL, &static_ops, &VAR_4, "sx1.cs1", OMAP_CS1_SIZE); memory_region_add_subregion(address_space, OMAP_CS1_BASE, &cs[1]); } if (!VAR_0->kernel_filename && !VAR_7 && !qtest_enabled()) { fprintf(stderr, "Kernel or Flash image must VAR_8 specified\n"); exit(1); } sx1_binfo.kernel_filename = VAR_0->kernel_filename; sx1_binfo.kernel_cmdline = VAR_0->kernel_cmdline; sx1_binfo.initrd_filename = VAR_0->initrd_filename; arm_load_kernel(VAR_2->cpu, &sx1_binfo); }
[ "static void FUNC_0(MachineState *VAR_0, const int VAR_1)\n{", "struct omap_mpu_state_s *VAR_2;", "MemoryRegion *address_space = get_system_memory();", "MemoryRegion *flash = g_new(MemoryRegion, 1);", "MemoryRegion *flash_1 = g_new(MemoryRegion, 1);", "MemoryRegion *cs = g_new(MemoryRegion, 4);", "static uint32_t VAR_3 = 0x00213090;", "static uint32_t VAR_4 = 0x00215070;", "static uint32_t VAR_5 = 0x00001139;", "static uint32_t VAR_6 = 0x00001139;", "DriveInfo *dinfo;", "int VAR_7;", "uint32_t flash_size = flash0_size;", "int VAR_8;", "if (VAR_1 == 2) {", "flash_size = flash2_size;", "}", "VAR_2 = omap310_mpu_init(address_space, sx1_binfo.ram_size,\nVAR_0->cpu_model);", "memory_region_init_ram(flash, NULL, \"omap_sx1.flash0-0\", flash_size,\n&error_abort);", "vmstate_register_ram_global(flash);", "memory_region_set_readonly(flash, true);", "memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash);", "memory_region_init_io(&cs[0], NULL, &static_ops, &VAR_3,\n\"sx1.cs0\", OMAP_CS0_SIZE - flash_size);", "memory_region_add_subregion(address_space,\nOMAP_CS0_BASE + flash_size, &cs[0]);", "memory_region_init_io(&cs[2], NULL, &static_ops, &VAR_5,\n\"sx1.cs2\", OMAP_CS2_SIZE);", "memory_region_add_subregion(address_space,\nOMAP_CS2_BASE, &cs[2]);", "memory_region_init_io(&cs[3], NULL, &static_ops, &VAR_6,\n\"sx1.cs3\", OMAP_CS3_SIZE);", "memory_region_add_subregion(address_space,\nOMAP_CS2_BASE, &cs[3]);", "VAR_7 = 0;", "#ifdef TARGET_WORDS_BIGENDIAN\nVAR_8 = 1;", "#else\nVAR_8 = 0;", "#endif\nif ((dinfo = drive_get(IF_PFLASH, 0, VAR_7)) != NULL) {", "if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL,\n\"omap_sx1.flash0-1\", flash_size,\nblk_bs(blk_by_legacy_dinfo(dinfo)),\nsector_size, flash_size / sector_size,\n4, 0, 0, 0, 0, VAR_8)) {", "fprintf(stderr, \"qemu: Error registering flash memory %d.\\n\",\nVAR_7);", "}", "VAR_7++;", "}", "if ((VAR_1 == 1) &&\n(dinfo = drive_get(IF_PFLASH, 0, VAR_7)) != NULL) {", "memory_region_init_ram(flash_1, NULL, \"omap_sx1.flash1-0\", flash1_size,\n&error_abort);", "vmstate_register_ram_global(flash_1);", "memory_region_set_readonly(flash_1, true);", "memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1);", "memory_region_init_io(&cs[1], NULL, &static_ops, &VAR_4,\n\"sx1.cs1\", OMAP_CS1_SIZE - flash1_size);", "memory_region_add_subregion(address_space,\nOMAP_CS1_BASE + flash1_size, &cs[1]);", "if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL,\n\"omap_sx1.flash1-1\", flash1_size,\nblk_bs(blk_by_legacy_dinfo(dinfo)),\nsector_size, flash1_size / sector_size,\n4, 0, 0, 0, 0, VAR_8)) {", "fprintf(stderr, \"qemu: Error registering flash memory %d.\\n\",\nVAR_7);", "}", "VAR_7++;", "} else {", "memory_region_init_io(&cs[1], NULL, &static_ops, &VAR_4,\n\"sx1.cs1\", OMAP_CS1_SIZE);", "memory_region_add_subregion(address_space,\nOMAP_CS1_BASE, &cs[1]);", "}", "if (!VAR_0->kernel_filename && !VAR_7 && !qtest_enabled()) {", "fprintf(stderr, \"Kernel or Flash image must VAR_8 specified\\n\");", "exit(1);", "}", "sx1_binfo.kernel_filename = VAR_0->kernel_filename;", "sx1_binfo.kernel_cmdline = VAR_0->kernel_cmdline;", "sx1_binfo.initrd_filename = VAR_0->initrd_filename;", "arm_load_kernel(VAR_2->cpu, &sx1_binfo);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 33 ], [ 35 ], [ 37 ], [ 41, 43 ], [ 49, 51 ], [ 53 ], [ 55 ], [ 57 ], [ 61, 63 ], [ 65, 67 ], [ 73, 75 ], [ 77, 79 ], [ 83, 85 ], [ 87, 89 ], [ 93 ], [ 95, 97 ], [ 99, 101 ], [ 103, 107 ], [ 109, 111, 113, 115, 117 ], [ 119, 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131, 133 ], [ 135, 137 ], [ 139 ], [ 141 ], [ 143 ], [ 147, 149 ], [ 151, 153 ], [ 157, 159, 161, 163, 165 ], [ 167, 169 ], [ 171 ], [ 173 ], [ 175 ], [ 177, 179 ], [ 181, 183 ], [ 185 ], [ 189 ], [ 191 ], [ 193 ], [ 195 ], [ 201 ], [ 203 ], [ 205 ], [ 207 ], [ 215 ] ]
6,041
qcrypto_block_luks_load_key(QCryptoBlock *block, QCryptoBlockLUKSKeySlot *slot, const char *password, QCryptoCipherAlgorithm cipheralg, QCryptoCipherMode ciphermode, QCryptoHashAlgorithm hash, QCryptoIVGenAlgorithm ivalg, QCryptoCipherAlgorithm ivcipheralg, QCryptoHashAlgorithm ivhash, uint8_t *masterkey, size_t masterkeylen, QCryptoBlockReadFunc readfunc, void *opaque, Error **errp) { QCryptoBlockLUKS *luks = block->opaque; uint8_t *splitkey; size_t splitkeylen; uint8_t *possiblekey; int ret = -1; ssize_t rv; QCryptoCipher *cipher = NULL; uint8_t keydigest[QCRYPTO_BLOCK_LUKS_DIGEST_LEN]; QCryptoIVGen *ivgen = NULL; size_t niv; if (slot->active != QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) { return 0; } splitkeylen = masterkeylen * slot->stripes; splitkey = g_new0(uint8_t, splitkeylen); possiblekey = g_new0(uint8_t, masterkeylen); /* * The user password is used to generate a (possible) * decryption key. This may or may not successfully * decrypt the master key - we just blindly assume * the key is correct and validate the results of * decryption later. */ if (qcrypto_pbkdf2(hash, (const uint8_t *)password, strlen(password), slot->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, slot->iterations, possiblekey, masterkeylen, errp) < 0) { goto cleanup; } /* * We need to read the master key material from the * LUKS key material header. What we're reading is * not the raw master key, but rather the data after * it has been passed through AFSplit and the result * then encrypted. */ rv = readfunc(block, slot->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, splitkey, splitkeylen, errp, opaque); if (rv < 0) { goto cleanup; } /* Setup the cipher/ivgen that we'll use to try to decrypt * the split master key material */ cipher = qcrypto_cipher_new(cipheralg, ciphermode, possiblekey, masterkeylen, errp); if (!cipher) { goto cleanup; } niv = qcrypto_cipher_get_iv_len(cipheralg, ciphermode); ivgen = qcrypto_ivgen_new(ivalg, ivcipheralg, ivhash, possiblekey, masterkeylen, errp); if (!ivgen) { goto cleanup; } /* * The master key needs to be decrypted in the same * way that the block device payload will be decrypted * later. In particular we'll be using the IV generator * to reset the encryption cipher every time the master * key crosses a sector boundary. */ if (qcrypto_block_decrypt_helper(cipher, niv, ivgen, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, 0, splitkey, splitkeylen, errp) < 0) { goto cleanup; } /* * Now we've decrypted the split master key, join * it back together to get the actual master key. */ if (qcrypto_afsplit_decode(hash, masterkeylen, slot->stripes, splitkey, masterkey, errp) < 0) { goto cleanup; } /* * We still don't know that the masterkey we got is valid, * because we just blindly assumed the user's password * was correct. This is where we now verify it. We are * creating a hash of the master key using PBKDF and * then comparing that to the hash stored in the key slot * header */ if (qcrypto_pbkdf2(hash, masterkey, masterkeylen, luks->header.master_key_salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, luks->header.master_key_iterations, keydigest, G_N_ELEMENTS(keydigest), errp) < 0) { goto cleanup; } if (memcmp(keydigest, luks->header.master_key_digest, QCRYPTO_BLOCK_LUKS_DIGEST_LEN) == 0) { /* Success, we got the right master key */ ret = 1; goto cleanup; } /* Fail, user's password was not valid for this key slot, * tell caller to try another slot */ ret = 0; cleanup: qcrypto_ivgen_free(ivgen); qcrypto_cipher_free(cipher); g_free(splitkey); g_free(possiblekey); return ret; }
false
qemu
375092332eeaa6e47561ce47fd36144cdaf964d0
qcrypto_block_luks_load_key(QCryptoBlock *block, QCryptoBlockLUKSKeySlot *slot, const char *password, QCryptoCipherAlgorithm cipheralg, QCryptoCipherMode ciphermode, QCryptoHashAlgorithm hash, QCryptoIVGenAlgorithm ivalg, QCryptoCipherAlgorithm ivcipheralg, QCryptoHashAlgorithm ivhash, uint8_t *masterkey, size_t masterkeylen, QCryptoBlockReadFunc readfunc, void *opaque, Error **errp) { QCryptoBlockLUKS *luks = block->opaque; uint8_t *splitkey; size_t splitkeylen; uint8_t *possiblekey; int ret = -1; ssize_t rv; QCryptoCipher *cipher = NULL; uint8_t keydigest[QCRYPTO_BLOCK_LUKS_DIGEST_LEN]; QCryptoIVGen *ivgen = NULL; size_t niv; if (slot->active != QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) { return 0; } splitkeylen = masterkeylen * slot->stripes; splitkey = g_new0(uint8_t, splitkeylen); possiblekey = g_new0(uint8_t, masterkeylen); if (qcrypto_pbkdf2(hash, (const uint8_t *)password, strlen(password), slot->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, slot->iterations, possiblekey, masterkeylen, errp) < 0) { goto cleanup; } rv = readfunc(block, slot->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, splitkey, splitkeylen, errp, opaque); if (rv < 0) { goto cleanup; } cipher = qcrypto_cipher_new(cipheralg, ciphermode, possiblekey, masterkeylen, errp); if (!cipher) { goto cleanup; } niv = qcrypto_cipher_get_iv_len(cipheralg, ciphermode); ivgen = qcrypto_ivgen_new(ivalg, ivcipheralg, ivhash, possiblekey, masterkeylen, errp); if (!ivgen) { goto cleanup; } if (qcrypto_block_decrypt_helper(cipher, niv, ivgen, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, 0, splitkey, splitkeylen, errp) < 0) { goto cleanup; } if (qcrypto_afsplit_decode(hash, masterkeylen, slot->stripes, splitkey, masterkey, errp) < 0) { goto cleanup; } if (qcrypto_pbkdf2(hash, masterkey, masterkeylen, luks->header.master_key_salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, luks->header.master_key_iterations, keydigest, G_N_ELEMENTS(keydigest), errp) < 0) { goto cleanup; } if (memcmp(keydigest, luks->header.master_key_digest, QCRYPTO_BLOCK_LUKS_DIGEST_LEN) == 0) { ret = 1; goto cleanup; } ret = 0; cleanup: qcrypto_ivgen_free(ivgen); qcrypto_cipher_free(cipher); g_free(splitkey); g_free(possiblekey); return ret; }
{ "code": [], "line_no": [] }
FUNC_0(QCryptoBlock *VAR_0, QCryptoBlockLUKSKeySlot *VAR_1, const char *VAR_2, QCryptoCipherAlgorithm VAR_3, QCryptoCipherMode VAR_4, QCryptoHashAlgorithm VAR_5, QCryptoIVGenAlgorithm VAR_6, QCryptoCipherAlgorithm VAR_7, QCryptoHashAlgorithm VAR_8, uint8_t *VAR_9, size_t VAR_10, QCryptoBlockReadFunc VAR_11, void *VAR_12, Error **VAR_13) { QCryptoBlockLUKS *luks = VAR_0->VAR_12; uint8_t *splitkey; size_t splitkeylen; uint8_t *possiblekey; int VAR_14 = -1; ssize_t rv; QCryptoCipher *cipher = NULL; uint8_t keydigest[QCRYPTO_BLOCK_LUKS_DIGEST_LEN]; QCryptoIVGen *ivgen = NULL; size_t niv; if (VAR_1->active != QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) { return 0; } splitkeylen = VAR_10 * VAR_1->stripes; splitkey = g_new0(uint8_t, splitkeylen); possiblekey = g_new0(uint8_t, VAR_10); if (qcrypto_pbkdf2(VAR_5, (const uint8_t *)VAR_2, strlen(VAR_2), VAR_1->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, VAR_1->iterations, possiblekey, VAR_10, VAR_13) < 0) { goto cleanup; } rv = VAR_11(VAR_0, VAR_1->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, splitkey, splitkeylen, VAR_13, VAR_12); if (rv < 0) { goto cleanup; } cipher = qcrypto_cipher_new(VAR_3, VAR_4, possiblekey, VAR_10, VAR_13); if (!cipher) { goto cleanup; } niv = qcrypto_cipher_get_iv_len(VAR_3, VAR_4); ivgen = qcrypto_ivgen_new(VAR_6, VAR_7, VAR_8, possiblekey, VAR_10, VAR_13); if (!ivgen) { goto cleanup; } if (qcrypto_block_decrypt_helper(cipher, niv, ivgen, QCRYPTO_BLOCK_LUKS_SECTOR_SIZE, 0, splitkey, splitkeylen, VAR_13) < 0) { goto cleanup; } if (qcrypto_afsplit_decode(VAR_5, VAR_10, VAR_1->stripes, splitkey, VAR_9, VAR_13) < 0) { goto cleanup; } if (qcrypto_pbkdf2(VAR_5, VAR_9, VAR_10, luks->header.master_key_salt, QCRYPTO_BLOCK_LUKS_SALT_LEN, luks->header.master_key_iterations, keydigest, G_N_ELEMENTS(keydigest), VAR_13) < 0) { goto cleanup; } if (memcmp(keydigest, luks->header.master_key_digest, QCRYPTO_BLOCK_LUKS_DIGEST_LEN) == 0) { VAR_14 = 1; goto cleanup; } VAR_14 = 0; cleanup: qcrypto_ivgen_free(ivgen); qcrypto_cipher_free(cipher); g_free(splitkey); g_free(possiblekey); return VAR_14; }
[ "FUNC_0(QCryptoBlock *VAR_0,\nQCryptoBlockLUKSKeySlot *VAR_1,\nconst char *VAR_2,\nQCryptoCipherAlgorithm VAR_3,\nQCryptoCipherMode VAR_4,\nQCryptoHashAlgorithm VAR_5,\nQCryptoIVGenAlgorithm VAR_6,\nQCryptoCipherAlgorithm VAR_7,\nQCryptoHashAlgorithm VAR_8,\nuint8_t *VAR_9,\nsize_t VAR_10,\nQCryptoBlockReadFunc VAR_11,\nvoid *VAR_12,\nError **VAR_13)\n{", "QCryptoBlockLUKS *luks = VAR_0->VAR_12;", "uint8_t *splitkey;", "size_t splitkeylen;", "uint8_t *possiblekey;", "int VAR_14 = -1;", "ssize_t rv;", "QCryptoCipher *cipher = NULL;", "uint8_t keydigest[QCRYPTO_BLOCK_LUKS_DIGEST_LEN];", "QCryptoIVGen *ivgen = NULL;", "size_t niv;", "if (VAR_1->active != QCRYPTO_BLOCK_LUKS_KEY_SLOT_ENABLED) {", "return 0;", "}", "splitkeylen = VAR_10 * VAR_1->stripes;", "splitkey = g_new0(uint8_t, splitkeylen);", "possiblekey = g_new0(uint8_t, VAR_10);", "if (qcrypto_pbkdf2(VAR_5,\n(const uint8_t *)VAR_2, strlen(VAR_2),\nVAR_1->salt, QCRYPTO_BLOCK_LUKS_SALT_LEN,\nVAR_1->iterations,\npossiblekey, VAR_10,\nVAR_13) < 0) {", "goto cleanup;", "}", "rv = VAR_11(VAR_0,\nVAR_1->key_offset * QCRYPTO_BLOCK_LUKS_SECTOR_SIZE,\nsplitkey, splitkeylen,\nVAR_13,\nVAR_12);", "if (rv < 0) {", "goto cleanup;", "}", "cipher = qcrypto_cipher_new(VAR_3, VAR_4,\npossiblekey, VAR_10,\nVAR_13);", "if (!cipher) {", "goto cleanup;", "}", "niv = qcrypto_cipher_get_iv_len(VAR_3,\nVAR_4);", "ivgen = qcrypto_ivgen_new(VAR_6,\nVAR_7,\nVAR_8,\npossiblekey, VAR_10,\nVAR_13);", "if (!ivgen) {", "goto cleanup;", "}", "if (qcrypto_block_decrypt_helper(cipher,\nniv,\nivgen,\nQCRYPTO_BLOCK_LUKS_SECTOR_SIZE,\n0,\nsplitkey,\nsplitkeylen,\nVAR_13) < 0) {", "goto cleanup;", "}", "if (qcrypto_afsplit_decode(VAR_5,\nVAR_10,\nVAR_1->stripes,\nsplitkey,\nVAR_9,\nVAR_13) < 0) {", "goto cleanup;", "}", "if (qcrypto_pbkdf2(VAR_5,\nVAR_9, VAR_10,\nluks->header.master_key_salt,\nQCRYPTO_BLOCK_LUKS_SALT_LEN,\nluks->header.master_key_iterations,\nkeydigest, G_N_ELEMENTS(keydigest),\nVAR_13) < 0) {", "goto cleanup;", "}", "if (memcmp(keydigest, luks->header.master_key_digest,\nQCRYPTO_BLOCK_LUKS_DIGEST_LEN) == 0) {", "VAR_14 = 1;", "goto cleanup;", "}", "VAR_14 = 0;", "cleanup:\nqcrypto_ivgen_free(ivgen);", "qcrypto_cipher_free(cipher);", "g_free(splitkey);", "g_free(possiblekey);", "return VAR_14;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 61 ], [ 63 ], [ 65 ], [ 83, 85, 87, 89, 91, 93 ], [ 95 ], [ 97 ], [ 115, 117, 119, 121, 123 ], [ 125 ], [ 127 ], [ 129 ], [ 139, 141, 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153, 155 ], [ 157, 159, 161, 163, 165 ], [ 167 ], [ 169 ], [ 171 ], [ 191, 193, 195, 197, 199, 201, 203, 205 ], [ 207 ], [ 209 ], [ 221, 223, 225, 227, 229, 231 ], [ 233 ], [ 235 ], [ 257, 259, 261, 263, 265, 267, 269 ], [ 271 ], [ 273 ], [ 277, 279 ], [ 283 ], [ 285 ], [ 287 ], [ 295 ], [ 299, 301 ], [ 303 ], [ 305 ], [ 307 ], [ 309 ], [ 311 ] ]
6,042
static uint64_t gem_read(void *opaque, target_phys_addr_t offset, unsigned size) { GemState *s; uint32_t retval; s = (GemState *)opaque; offset >>= 2; retval = s->regs[offset]; DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval); switch (offset) { case GEM_ISR: qemu_set_irq(s->irq, 0); break; case GEM_PHYMNTNC: if (retval & GEM_PHYMNTNC_OP_R) { uint32_t phy_addr, reg_num; phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; if (phy_addr == BOARD_PHY_ADDRESS) { reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; retval &= 0xFFFF0000; retval |= gem_phy_read(s, reg_num); } else { retval |= 0xFFFF; /* No device at this address */ } } break; } /* Squash read to clear bits */ s->regs[offset] &= ~(s->regs_rtc[offset]); /* Do not provide write only bits */ retval &= ~(s->regs_wo[offset]); DB_PRINT("0x%08x\n", retval); return retval; }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static uint64_t gem_read(void *opaque, target_phys_addr_t offset, unsigned size) { GemState *s; uint32_t retval; s = (GemState *)opaque; offset >>= 2; retval = s->regs[offset]; DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval); switch (offset) { case GEM_ISR: qemu_set_irq(s->irq, 0); break; case GEM_PHYMNTNC: if (retval & GEM_PHYMNTNC_OP_R) { uint32_t phy_addr, reg_num; phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; if (phy_addr == BOARD_PHY_ADDRESS) { reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; retval &= 0xFFFF0000; retval |= gem_phy_read(s, reg_num); } else { retval |= 0xFFFF; } } break; } s->regs[offset] &= ~(s->regs_rtc[offset]); retval &= ~(s->regs_wo[offset]); DB_PRINT("0x%08x\n", retval); return retval; }
{ "code": [], "line_no": [] }
static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset, unsigned size) { GemState *s; uint32_t retval; s = (GemState *)opaque; offset >>= 2; retval = s->regs[offset]; DB_PRINT("offset: 0x%04x read: 0x%08x\n", offset*4, retval); switch (offset) { case GEM_ISR: qemu_set_irq(s->irq, 0); break; case GEM_PHYMNTNC: if (retval & GEM_PHYMNTNC_OP_R) { uint32_t phy_addr, reg_num; phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT; if (phy_addr == BOARD_PHY_ADDRESS) { reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT; retval &= 0xFFFF0000; retval |= gem_phy_read(s, reg_num); } else { retval |= 0xFFFF; } } break; } s->regs[offset] &= ~(s->regs_rtc[offset]); retval &= ~(s->regs_wo[offset]); DB_PRINT("0x%08x\n", retval); return retval; }
[ "static uint64_t FUNC_0(void *opaque, target_phys_addr_t offset, unsigned size)\n{", "GemState *s;", "uint32_t retval;", "s = (GemState *)opaque;", "offset >>= 2;", "retval = s->regs[offset];", "DB_PRINT(\"offset: 0x%04x read: 0x%08x\\n\", offset*4, retval);", "switch (offset) {", "case GEM_ISR:\nqemu_set_irq(s->irq, 0);", "break;", "case GEM_PHYMNTNC:\nif (retval & GEM_PHYMNTNC_OP_R) {", "uint32_t phy_addr, reg_num;", "phy_addr = (retval & GEM_PHYMNTNC_ADDR) >> GEM_PHYMNTNC_ADDR_SHFT;", "if (phy_addr == BOARD_PHY_ADDRESS) {", "reg_num = (retval & GEM_PHYMNTNC_REG) >> GEM_PHYMNTNC_REG_SHIFT;", "retval &= 0xFFFF0000;", "retval |= gem_phy_read(s, reg_num);", "} else {", "retval |= 0xFFFF;", "}", "}", "break;", "}", "s->regs[offset] &= ~(s->regs_rtc[offset]);", "retval &= ~(s->regs_wo[offset]);", "DB_PRINT(\"0x%08x\\n\", retval);", "return retval;", "}" ]
[ 0, 0, 0, 0, 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 ], [ 15 ], [ 17 ], [ 21 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 67 ], [ 73 ], [ 77 ], [ 79 ], [ 81 ] ]
6,044
static void musicpal_lcd_init(DisplayState *ds, uint32_t base) { musicpal_lcd_state *s; int iomemtype; s = qemu_mallocz(sizeof(musicpal_lcd_state)); if (!s) return; s->base = base; s->ds = ds; iomemtype = cpu_register_io_memory(0, musicpal_lcd_readfn, musicpal_lcd_writefn, s); cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype); graphic_console_init(ds, lcd_refresh, NULL, NULL, NULL, s); dpy_resize(ds, 128*3, 64*3); }
false
qemu
167bc3d2fa100590b5a9d8fd9f19ae0207197447
static void musicpal_lcd_init(DisplayState *ds, uint32_t base) { musicpal_lcd_state *s; int iomemtype; s = qemu_mallocz(sizeof(musicpal_lcd_state)); if (!s) return; s->base = base; s->ds = ds; iomemtype = cpu_register_io_memory(0, musicpal_lcd_readfn, musicpal_lcd_writefn, s); cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype); graphic_console_init(ds, lcd_refresh, NULL, NULL, NULL, s); dpy_resize(ds, 128*3, 64*3); }
{ "code": [], "line_no": [] }
static void FUNC_0(DisplayState *VAR_0, uint32_t VAR_1) { musicpal_lcd_state *s; int VAR_2; s = qemu_mallocz(sizeof(musicpal_lcd_state)); if (!s) return; s->VAR_1 = VAR_1; s->VAR_0 = VAR_0; VAR_2 = cpu_register_io_memory(0, musicpal_lcd_readfn, musicpal_lcd_writefn, s); cpu_register_physical_memory(VAR_1, MP_LCD_SIZE, VAR_2); graphic_console_init(VAR_0, lcd_refresh, NULL, NULL, NULL, s); dpy_resize(VAR_0, 128*3, 64*3); }
[ "static void FUNC_0(DisplayState *VAR_0, uint32_t VAR_1)\n{", "musicpal_lcd_state *s;", "int VAR_2;", "s = qemu_mallocz(sizeof(musicpal_lcd_state));", "if (!s)\nreturn;", "s->VAR_1 = VAR_1;", "s->VAR_0 = VAR_0;", "VAR_2 = cpu_register_io_memory(0, musicpal_lcd_readfn,\nmusicpal_lcd_writefn, s);", "cpu_register_physical_memory(VAR_1, MP_LCD_SIZE, VAR_2);", "graphic_console_init(VAR_0, lcd_refresh, NULL, NULL, NULL, s);", "dpy_resize(VAR_0, 128*3, 64*3);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 21, 23 ], [ 25 ], [ 29 ], [ 31 ], [ 33 ] ]
6,045
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_bytes) { unsigned int idx; unsigned int total_bufs, in_total, out_total; idx = vq->last_avail_idx; total_bufs = in_total = out_total = 0; while (virtqueue_num_heads(vq, idx)) { unsigned int max, num_bufs, indirect = 0; hwaddr desc_pa; int i; max = vq->vring.num; num_bufs = total_bufs; i = virtqueue_get_head(vq, idx++); desc_pa = vq->vring.desc; if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_INDIRECT) { if (vring_desc_len(desc_pa, i) % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } /* If we've got too many, that implies a descriptor loop. */ if (num_bufs >= max) { error_report("Looped descriptor"); exit(1); } /* loop over the indirect descriptor table */ indirect = 1; max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); num_bufs = i = 0; desc_pa = vring_desc_addr(desc_pa, i); } do { /* If we've got too many, that implies a descriptor loop. */ if (++num_bufs > max) { error_report("Looped descriptor"); exit(1); } if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) { in_total += vring_desc_len(desc_pa, i); } else { out_total += vring_desc_len(desc_pa, i); } } while ((i = virtqueue_next_desc(desc_pa, i, max)) != max); if (!indirect) total_bufs = num_bufs; else total_bufs++; } if (in_bytes) { *in_bytes = in_total; } if (out_bytes) { *out_bytes = out_total; } }
false
qemu
e1f7b4812eab992de46c98b3726745afb042a7f0
void virtqueue_get_avail_bytes(VirtQueue *vq, unsigned int *in_bytes, unsigned int *out_bytes) { unsigned int idx; unsigned int total_bufs, in_total, out_total; idx = vq->last_avail_idx; total_bufs = in_total = out_total = 0; while (virtqueue_num_heads(vq, idx)) { unsigned int max, num_bufs, indirect = 0; hwaddr desc_pa; int i; max = vq->vring.num; num_bufs = total_bufs; i = virtqueue_get_head(vq, idx++); desc_pa = vq->vring.desc; if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_INDIRECT) { if (vring_desc_len(desc_pa, i) % sizeof(VRingDesc)) { error_report("Invalid size for indirect buffer table"); exit(1); } if (num_bufs >= max) { error_report("Looped descriptor"); exit(1); } indirect = 1; max = vring_desc_len(desc_pa, i) / sizeof(VRingDesc); num_bufs = i = 0; desc_pa = vring_desc_addr(desc_pa, i); } do { if (++num_bufs > max) { error_report("Looped descriptor"); exit(1); } if (vring_desc_flags(desc_pa, i) & VRING_DESC_F_WRITE) { in_total += vring_desc_len(desc_pa, i); } else { out_total += vring_desc_len(desc_pa, i); } } while ((i = virtqueue_next_desc(desc_pa, i, max)) != max); if (!indirect) total_bufs = num_bufs; else total_bufs++; } if (in_bytes) { *in_bytes = in_total; } if (out_bytes) { *out_bytes = out_total; } }
{ "code": [], "line_no": [] }
void FUNC_0(VirtQueue *VAR_0, unsigned int *VAR_1, unsigned int *VAR_2) { unsigned int VAR_3; unsigned int VAR_4, VAR_5, VAR_6; VAR_3 = VAR_0->last_avail_idx; VAR_4 = VAR_5 = VAR_6 = 0; while (virtqueue_num_heads(VAR_0, VAR_3)) { unsigned int VAR_7, VAR_8, VAR_9 = 0; hwaddr desc_pa; int VAR_10; VAR_7 = VAR_0->vring.num; VAR_8 = VAR_4; VAR_10 = virtqueue_get_head(VAR_0, VAR_3++); desc_pa = VAR_0->vring.desc; if (vring_desc_flags(desc_pa, VAR_10) & VRING_DESC_F_INDIRECT) { if (vring_desc_len(desc_pa, VAR_10) % sizeof(VRingDesc)) { error_report("Invalid size for VAR_9 buffer table"); exit(1); } if (VAR_8 >= VAR_7) { error_report("Looped descriptor"); exit(1); } VAR_9 = 1; VAR_7 = vring_desc_len(desc_pa, VAR_10) / sizeof(VRingDesc); VAR_8 = VAR_10 = 0; desc_pa = vring_desc_addr(desc_pa, VAR_10); } do { if (++VAR_8 > VAR_7) { error_report("Looped descriptor"); exit(1); } if (vring_desc_flags(desc_pa, VAR_10) & VRING_DESC_F_WRITE) { VAR_5 += vring_desc_len(desc_pa, VAR_10); } else { VAR_6 += vring_desc_len(desc_pa, VAR_10); } } while ((VAR_10 = virtqueue_next_desc(desc_pa, VAR_10, VAR_7)) != VAR_7); if (!VAR_9) VAR_4 = VAR_8; else VAR_4++; } if (VAR_1) { *VAR_1 = VAR_5; } if (VAR_2) { *VAR_2 = VAR_6; } }
[ "void FUNC_0(VirtQueue *VAR_0, unsigned int *VAR_1,\nunsigned int *VAR_2)\n{", "unsigned int VAR_3;", "unsigned int VAR_4, VAR_5, VAR_6;", "VAR_3 = VAR_0->last_avail_idx;", "VAR_4 = VAR_5 = VAR_6 = 0;", "while (virtqueue_num_heads(VAR_0, VAR_3)) {", "unsigned int VAR_7, VAR_8, VAR_9 = 0;", "hwaddr desc_pa;", "int VAR_10;", "VAR_7 = VAR_0->vring.num;", "VAR_8 = VAR_4;", "VAR_10 = virtqueue_get_head(VAR_0, VAR_3++);", "desc_pa = VAR_0->vring.desc;", "if (vring_desc_flags(desc_pa, VAR_10) & VRING_DESC_F_INDIRECT) {", "if (vring_desc_len(desc_pa, VAR_10) % sizeof(VRingDesc)) {", "error_report(\"Invalid size for VAR_9 buffer table\");", "exit(1);", "}", "if (VAR_8 >= VAR_7) {", "error_report(\"Looped descriptor\");", "exit(1);", "}", "VAR_9 = 1;", "VAR_7 = vring_desc_len(desc_pa, VAR_10) / sizeof(VRingDesc);", "VAR_8 = VAR_10 = 0;", "desc_pa = vring_desc_addr(desc_pa, VAR_10);", "}", "do {", "if (++VAR_8 > VAR_7) {", "error_report(\"Looped descriptor\");", "exit(1);", "}", "if (vring_desc_flags(desc_pa, VAR_10) & VRING_DESC_F_WRITE) {", "VAR_5 += vring_desc_len(desc_pa, VAR_10);", "} else {", "VAR_6 += vring_desc_len(desc_pa, VAR_10);", "}", "} while ((VAR_10 = virtqueue_next_desc(desc_pa, VAR_10, VAR_7)) != VAR_7);", "if (!VAR_9)\nVAR_4 = VAR_8;", "else\nVAR_4++;", "}", "if (VAR_1) {", "*VAR_1 = VAR_5;", "}", "if (VAR_2) {", "*VAR_2 = VAR_6;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 77 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 91 ], [ 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 105, 107 ], [ 109, 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ] ]
6,046
static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint16_t writable_mask = 0; uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask); /* modify emulate register */ writable_mask = ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); /* create value for writing to I/O device register */ if (*val & PCI_COMMAND_INTX_DISABLE) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } else { if (s->machine_irq) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } } *val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask); return 0; }
false
qemu
e2779de053b64f023de382fd87b3596613d47d1e
static int xen_pt_cmd_reg_write(XenPCIPassthroughState *s, XenPTReg *cfg_entry, uint16_t *val, uint16_t dev_value, uint16_t valid_mask) { XenPTRegInfo *reg = cfg_entry->reg; uint16_t writable_mask = 0; uint16_t throughable_mask = get_throughable_mask(s, reg, valid_mask); writable_mask = ~reg->ro_mask & valid_mask; cfg_entry->data = XEN_PT_MERGE_VALUE(*val, cfg_entry->data, writable_mask); if (*val & PCI_COMMAND_INTX_DISABLE) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } else { if (s->machine_irq) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } } *val = XEN_PT_MERGE_VALUE(*val, dev_value, throughable_mask); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTReg *VAR_1, uint16_t *VAR_2, uint16_t VAR_3, uint16_t VAR_4) { XenPTRegInfo *reg = VAR_1->reg; uint16_t writable_mask = 0; uint16_t throughable_mask = get_throughable_mask(VAR_0, reg, VAR_4); writable_mask = ~reg->ro_mask & VAR_4; VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask); if (*VAR_2 & PCI_COMMAND_INTX_DISABLE) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } else { if (VAR_0->machine_irq) { throughable_mask |= PCI_COMMAND_INTX_DISABLE; } } *VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, throughable_mask); return 0; }
[ "static int FUNC_0(XenPCIPassthroughState *VAR_0, XenPTReg *VAR_1,\nuint16_t *VAR_2, uint16_t VAR_3,\nuint16_t VAR_4)\n{", "XenPTRegInfo *reg = VAR_1->reg;", "uint16_t writable_mask = 0;", "uint16_t throughable_mask = get_throughable_mask(VAR_0, reg, VAR_4);", "writable_mask = ~reg->ro_mask & VAR_4;", "VAR_1->data = XEN_PT_MERGE_VALUE(*VAR_2, VAR_1->data, writable_mask);", "if (*VAR_2 & PCI_COMMAND_INTX_DISABLE) {", "throughable_mask |= PCI_COMMAND_INTX_DISABLE;", "} else {", "if (VAR_0->machine_irq) {", "throughable_mask |= PCI_COMMAND_INTX_DISABLE;", "}", "}", "*VAR_2 = XEN_PT_MERGE_VALUE(*VAR_2, VAR_3, throughable_mask);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5, 7 ], [ 9 ], [ 11 ], [ 13 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 43 ], [ 47 ], [ 49 ] ]
6,048
static void v9fs_remove(void *opaque) { int32_t fid; int err = 0; size_t offset = 7; V9fsFidState *fidp; V9fsPDU *pdu = opaque; pdu_unmarshal(pdu, offset, "d", &fid); trace_v9fs_remove(pdu->tag, pdu->id, fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } /* if fs driver is not path based, return EOPNOTSUPP */ if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) { err = -EOPNOTSUPP; goto out_err; } /* * IF the file is unlinked, we cannot reopen * the file later. So don't reclaim fd */ err = v9fs_mark_fids_unreclaim(pdu, &fidp->path); if (err < 0) { goto out_err; } err = v9fs_co_remove(pdu, &fidp->path); if (!err) { err = offset; } out_err: /* For TREMOVE we need to clunk the fid even on failed remove */ clunk_fid(pdu->s, fidp->fid); put_fid(pdu, fidp); out_nofid: complete_pdu(pdu->s, pdu, err); }
false
qemu
ddca7f86ac022289840e0200fd4050b2b58e9176
static void v9fs_remove(void *opaque) { int32_t fid; int err = 0; size_t offset = 7; V9fsFidState *fidp; V9fsPDU *pdu = opaque; pdu_unmarshal(pdu, offset, "d", &fid); trace_v9fs_remove(pdu->tag, pdu->id, fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { err = -EINVAL; goto out_nofid; } if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) { err = -EOPNOTSUPP; goto out_err; } err = v9fs_mark_fids_unreclaim(pdu, &fidp->path); if (err < 0) { goto out_err; } err = v9fs_co_remove(pdu, &fidp->path); if (!err) { err = offset; } out_err: clunk_fid(pdu->s, fidp->fid); put_fid(pdu, fidp); out_nofid: complete_pdu(pdu->s, pdu, err); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { int32_t fid; int VAR_1 = 0; size_t offset = 7; V9fsFidState *fidp; V9fsPDU *pdu = VAR_0; pdu_unmarshal(pdu, offset, "d", &fid); trace_v9fs_remove(pdu->tag, pdu->id, fid); fidp = get_fid(pdu, fid); if (fidp == NULL) { VAR_1 = -EINVAL; goto out_nofid; } if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) { VAR_1 = -EOPNOTSUPP; goto out_err; } VAR_1 = v9fs_mark_fids_unreclaim(pdu, &fidp->path); if (VAR_1 < 0) { goto out_err; } VAR_1 = v9fs_co_remove(pdu, &fidp->path); if (!VAR_1) { VAR_1 = offset; } out_err: clunk_fid(pdu->s, fidp->fid); put_fid(pdu, fidp); out_nofid: complete_pdu(pdu->s, pdu, VAR_1); }
[ "static void FUNC_0(void *VAR_0)\n{", "int32_t fid;", "int VAR_1 = 0;", "size_t offset = 7;", "V9fsFidState *fidp;", "V9fsPDU *pdu = VAR_0;", "pdu_unmarshal(pdu, offset, \"d\", &fid);", "trace_v9fs_remove(pdu->tag, pdu->id, fid);", "fidp = get_fid(pdu, fid);", "if (fidp == NULL) {", "VAR_1 = -EINVAL;", "goto out_nofid;", "}", "if (!(pdu->s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT)) {", "VAR_1 = -EOPNOTSUPP;", "goto out_err;", "}", "VAR_1 = v9fs_mark_fids_unreclaim(pdu, &fidp->path);", "if (VAR_1 < 0) {", "goto out_err;", "}", "VAR_1 = v9fs_co_remove(pdu, &fidp->path);", "if (!VAR_1) {", "VAR_1 = offset;", "}", "out_err:\nclunk_fid(pdu->s, fidp->fid);", "put_fid(pdu, fidp);", "out_nofid:\ncomplete_pdu(pdu->s, pdu, 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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 71 ], [ 73 ], [ 75, 77 ], [ 79 ] ]
6,049
static void mips_qemu_write (void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { if ((addr & 0xffff) == 0 && val == 42) qemu_system_reset_request (); else if ((addr & 0xffff) == 4 && val == 42) qemu_system_shutdown_request (); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void mips_qemu_write (void *opaque, target_phys_addr_t addr, uint64_t val, unsigned size) { if ((addr & 0xffff) == 0 && val == 42) qemu_system_reset_request (); else if ((addr & 0xffff) == 4 && val == 42) qemu_system_shutdown_request (); }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, target_phys_addr_t VAR_1, uint64_t VAR_2, unsigned VAR_3) { if ((VAR_1 & 0xffff) == 0 && VAR_2 == 42) qemu_system_reset_request (); else if ((VAR_1 & 0xffff) == 4 && VAR_2 == 42) qemu_system_shutdown_request (); }
[ "static void FUNC_0 (void *VAR_0, target_phys_addr_t VAR_1,\nuint64_t VAR_2, unsigned VAR_3)\n{", "if ((VAR_1 & 0xffff) == 0 && VAR_2 == 42)\nqemu_system_reset_request ();", "else if ((VAR_1 & 0xffff) == 4 && VAR_2 == 42)\nqemu_system_shutdown_request ();", "}" ]
[ 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7, 9 ], [ 11, 13 ], [ 15 ] ]
6,050
SocketAddress *socket_remote_address(int fd, Error **errp) { struct sockaddr_storage ss; socklen_t sslen = sizeof(ss); if (getpeername(fd, (struct sockaddr *)&ss, &sslen) < 0) { error_setg_errno(errp, errno, "%s", "Unable to query remote socket address"); return NULL; } return socket_sockaddr_to_address(&ss, sslen, errp); }
false
qemu
dfd100f242370886bb6732f70f1f7cbd8eb9fedc
SocketAddress *socket_remote_address(int fd, Error **errp) { struct sockaddr_storage ss; socklen_t sslen = sizeof(ss); if (getpeername(fd, (struct sockaddr *)&ss, &sslen) < 0) { error_setg_errno(errp, errno, "%s", "Unable to query remote socket address"); return NULL; } return socket_sockaddr_to_address(&ss, sslen, errp); }
{ "code": [], "line_no": [] }
SocketAddress *FUNC_0(int fd, Error **errp) { struct sockaddr_storage VAR_0; socklen_t sslen = sizeof(VAR_0); if (getpeername(fd, (struct sockaddr *)&VAR_0, &sslen) < 0) { error_setg_errno(errp, errno, "%s", "Unable to query remote socket address"); return NULL; } return socket_sockaddr_to_address(&VAR_0, sslen, errp); }
[ "SocketAddress *FUNC_0(int fd, Error **errp)\n{", "struct sockaddr_storage VAR_0;", "socklen_t sslen = sizeof(VAR_0);", "if (getpeername(fd, (struct sockaddr *)&VAR_0, &sslen) < 0) {", "error_setg_errno(errp, errno, \"%s\",\n\"Unable to query remote socket address\");", "return NULL;", "}", "return socket_sockaddr_to_address(&VAR_0, sslen, errp);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13, 15 ], [ 17 ], [ 19 ], [ 23 ], [ 25 ] ]
6,051
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; if((uint64_t)atom.size > (1<<30)) return -1; if (st->codec->codec_id == CODEC_ID_QDM2) { // pass all frma atom to codec, needed at least for QDM2 av_free(st->codec->extradata); st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = atom.size; get_buffer(pb, st->codec->extradata, atom.size); } else if (atom.size > 8) { /* to read frma, esds atoms */ if (mov_read_default(c, pb, atom) < 0) return -1; } else url_fskip(pb, atom.size); return 0; }
false
FFmpeg
6a63ff19b6a7fe3bc32c7fb4a62fca8f65786432
static int mov_read_wave(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { AVStream *st = c->fc->streams[c->fc->nb_streams-1]; if((uint64_t)atom.size > (1<<30)) return -1; if (st->codec->codec_id == CODEC_ID_QDM2) { av_free(st->codec->extradata); st->codec->extradata = av_mallocz(atom.size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = atom.size; get_buffer(pb, st->codec->extradata, atom.size); } else if (atom.size > 8) { if (mov_read_default(c, pb, atom) < 0) return -1; } else url_fskip(pb, atom.size); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2) { AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1]; if((uint64_t)VAR_2.size > (1<<30)) return -1; if (st->codec->codec_id == CODEC_ID_QDM2) { av_free(st->codec->extradata); st->codec->extradata = av_mallocz(VAR_2.size + FF_INPUT_BUFFER_PADDING_SIZE); if (!st->codec->extradata) return AVERROR(ENOMEM); st->codec->extradata_size = VAR_2.size; get_buffer(VAR_1, st->codec->extradata, VAR_2.size); } else if (VAR_2.size > 8) { if (mov_read_default(VAR_0, VAR_1, VAR_2) < 0) return -1; } else url_fskip(VAR_1, VAR_2.size); return 0; }
[ "static int FUNC_0(MOVContext *VAR_0, ByteIOContext *VAR_1, MOVAtom VAR_2)\n{", "AVStream *st = VAR_0->fc->streams[VAR_0->fc->nb_streams-1];", "if((uint64_t)VAR_2.size > (1<<30))\nreturn -1;", "if (st->codec->codec_id == CODEC_ID_QDM2) {", "av_free(st->codec->extradata);", "st->codec->extradata = av_mallocz(VAR_2.size + FF_INPUT_BUFFER_PADDING_SIZE);", "if (!st->codec->extradata)\nreturn AVERROR(ENOMEM);", "st->codec->extradata_size = VAR_2.size;", "get_buffer(VAR_1, st->codec->extradata, VAR_2.size);", "} else if (VAR_2.size > 8) {", "if (mov_read_default(VAR_0, VAR_1, VAR_2) < 0)\nreturn -1;", "} else", "url_fskip(VAR_1, VAR_2.size);", "return 0;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 15 ], [ 19 ], [ 21 ], [ 23, 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33, 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ] ]
6,052
fetchline(void) { char *p, *line = malloc(MAXREADLINESZ); if (!line) return NULL; printf("%s", get_prompt()); fflush(stdout); if (!fgets(line, MAXREADLINESZ, stdin)) { free(line); return NULL; } p = line + strlen(line); if (p != line && p[-1] == '\n') p[-1] = '\0'; return line; }
false
qemu
7d7d975c67aaa48a6aaf1630c143a453606567b1
fetchline(void) { char *p, *line = malloc(MAXREADLINESZ); if (!line) return NULL; printf("%s", get_prompt()); fflush(stdout); if (!fgets(line, MAXREADLINESZ, stdin)) { free(line); return NULL; } p = line + strlen(line); if (p != line && p[-1] == '\n') p[-1] = '\0'; return line; }
{ "code": [], "line_no": [] }
FUNC_0(void) { char *VAR_0, *VAR_1 = malloc(MAXREADLINESZ); if (!VAR_1) return NULL; printf("%s", get_prompt()); fflush(stdout); if (!fgets(VAR_1, MAXREADLINESZ, stdin)) { free(VAR_1); return NULL; } VAR_0 = VAR_1 + strlen(VAR_1); if (VAR_0 != VAR_1 && VAR_0[-1] == '\n') VAR_0[-1] = '\0'; return VAR_1; }
[ "FUNC_0(void)\n{", "char\t*VAR_0, *VAR_1 = malloc(MAXREADLINESZ);", "if (!VAR_1)\nreturn NULL;", "printf(\"%s\", get_prompt());", "fflush(stdout);", "if (!fgets(VAR_1, MAXREADLINESZ, stdin)) {", "free(VAR_1);", "return NULL;", "}", "VAR_0 = VAR_1 + strlen(VAR_1);", "if (VAR_0 != VAR_1 && VAR_0[-1] == '\\n')\nVAR_0[-1] = '\\0';", "return VAR_1;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9, 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27, 29 ], [ 31 ], [ 33 ] ]
6,054
static void kvmclock_vm_state_change(void *opaque, int running, RunState state) { KVMClockState *s = opaque; CPUState *cpu; int cap_clock_ctrl = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL); int ret; if (running) { struct kvm_clock_data data = {}; uint64_t time_at_migration = kvmclock_current_nsec(s); s->clock_valid = false; /* We can't rely on the migrated clock value, just discard it */ if (time_at_migration) { s->clock = time_at_migration; } data.clock = s->clock; ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(ret)); abort(); } if (!cap_clock_ctrl) { return; } CPU_FOREACH(cpu) { ret = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); if (ret) { if (ret != -EINVAL) { fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); } return; } } } else { struct kvm_clock_data data; int ret; if (s->clock_valid) { return; } kvm_synchronize_all_tsc(); ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret)); abort(); } s->clock = data.clock; /* * If the VM is stopped, declare the clock state valid to * avoid re-reading it on next vmsave (which would return * a different value). Will be reset when the VM is continued. */ s->clock_valid = true; } }
false
qemu
6053a86fe7bd3d5b07b49dae6c05f2cd0d44e687
static void kvmclock_vm_state_change(void *opaque, int running, RunState state) { KVMClockState *s = opaque; CPUState *cpu; int cap_clock_ctrl = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL); int ret; if (running) { struct kvm_clock_data data = {}; uint64_t time_at_migration = kvmclock_current_nsec(s); s->clock_valid = false; if (time_at_migration) { s->clock = time_at_migration; } data.clock = s->clock; ret = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(ret)); abort(); } if (!cap_clock_ctrl) { return; } CPU_FOREACH(cpu) { ret = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); if (ret) { if (ret != -EINVAL) { fprintf(stderr, "%s: %s\n", __func__, strerror(-ret)); } return; } } } else { struct kvm_clock_data data; int ret; if (s->clock_valid) { return; } kvm_synchronize_all_tsc(); ret = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &data); if (ret < 0) { fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(ret)); abort(); } s->clock = data.clock; s->clock_valid = true; } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, int VAR_1, RunState VAR_2) { KVMClockState *s = VAR_0; CPUState *cpu; int VAR_3 = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL); int VAR_6; if (VAR_1) { struct kvm_clock_data VAR_6 = {}; uint64_t time_at_migration = kvmclock_current_nsec(s); s->clock_valid = false; if (time_at_migration) { s->clock = time_at_migration; } VAR_6.clock = s->clock; VAR_6 = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &VAR_6); if (VAR_6 < 0) { fprintf(stderr, "KVM_SET_CLOCK failed: %s\n", strerror(VAR_6)); abort(); } if (!VAR_3) { return; } CPU_FOREACH(cpu) { VAR_6 = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0); if (VAR_6) { if (VAR_6 != -EINVAL) { fprintf(stderr, "%s: %s\n", __func__, strerror(-VAR_6)); } return; } } } else { struct kvm_clock_data VAR_6; int VAR_6; if (s->clock_valid) { return; } kvm_synchronize_all_tsc(); VAR_6 = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &VAR_6); if (VAR_6 < 0) { fprintf(stderr, "KVM_GET_CLOCK failed: %s\n", strerror(VAR_6)); abort(); } s->clock = VAR_6.clock; s->clock_valid = true; } }
[ "static void FUNC_0(void *VAR_0, int VAR_1,\nRunState VAR_2)\n{", "KVMClockState *s = VAR_0;", "CPUState *cpu;", "int VAR_3 = kvm_check_extension(kvm_state, KVM_CAP_KVMCLOCK_CTRL);", "int VAR_6;", "if (VAR_1) {", "struct kvm_clock_data VAR_6 = {};", "uint64_t time_at_migration = kvmclock_current_nsec(s);", "s->clock_valid = false;", "if (time_at_migration) {", "s->clock = time_at_migration;", "}", "VAR_6.clock = s->clock;", "VAR_6 = kvm_vm_ioctl(kvm_state, KVM_SET_CLOCK, &VAR_6);", "if (VAR_6 < 0) {", "fprintf(stderr, \"KVM_SET_CLOCK failed: %s\\n\", strerror(VAR_6));", "abort();", "}", "if (!VAR_3) {", "return;", "}", "CPU_FOREACH(cpu) {", "VAR_6 = kvm_vcpu_ioctl(cpu, KVM_KVMCLOCK_CTRL, 0);", "if (VAR_6) {", "if (VAR_6 != -EINVAL) {", "fprintf(stderr, \"%s: %s\\n\", __func__, strerror(-VAR_6));", "}", "return;", "}", "}", "} else {", "struct kvm_clock_data VAR_6;", "int VAR_6;", "if (s->clock_valid) {", "return;", "}", "kvm_synchronize_all_tsc();", "VAR_6 = kvm_vm_ioctl(kvm_state, KVM_GET_CLOCK, &VAR_6);", "if (VAR_6 < 0) {", "fprintf(stderr, \"KVM_GET_CLOCK failed: %s\\n\", strerror(VAR_6));", "abort();", "}", "s->clock = VAR_6.clock;", "s->clock_valid = true;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 25 ], [ 31 ], [ 33 ], [ 35 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 85 ], [ 87 ], [ 89 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 121 ], [ 123 ], [ 125 ] ]
6,055
static void nvenc_setup_rate_control(AVCodecContext *avctx) { NVENCContext *ctx = avctx->priv_data; NV_ENC_RC_PARAMS *rc = &ctx->config.rcParams; if (avctx->bit_rate > 0) rc->averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) rc->maxBitRate = avctx->rc_max_rate; if (ctx->rc > 0) { nvenc_override_rate_control(avctx, rc); } else if (ctx->flags & NVENC_LOSSLESS) { set_lossless(avctx, rc); } else if (avctx->global_quality > 0) { set_constqp(avctx, rc); } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { rc->rateControlMode = NV_ENC_PARAMS_RC_VBR; set_vbr(avctx, rc); } if (avctx->rc_buffer_size > 0) rc->vbvBufferSize = avctx->rc_buffer_size; if (rc->averageBitRate > 0) avctx->bit_rate = rc->averageBitRate; #if NVENCAPI_MAJOR_VERSION >= 7 if (ctx->aq) { ctx->config.rcParams.enableAQ = 1; ctx->config.rcParams.aqStrength = ctx->aq_strength; av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n"); } if (ctx->temporal_aq) { ctx->config.rcParams.enableTemporalAQ = 1; av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); } if (ctx->rc_lookahead) { int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - ctx->config.frameIntervalP - 4; if (lkd_bound < 0) { av_log(avctx, AV_LOG_WARNING, "Lookahead not enabled. Increase buffer delay (-delay).\n"); } else { ctx->config.rcParams.enableLookahead = 1; ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); ctx->config.rcParams.disableIadapt = ctx->no_scenecut; ctx->config.rcParams.disableBadapt = !ctx->b_adapt; av_log(avctx, AV_LOG_VERBOSE, "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", ctx->config.rcParams.lookaheadDepth, ctx->config.rcParams.disableIadapt ? "disabled" : "enabled", ctx->config.rcParams.disableBadapt ? "disabled" : "enabled"); } } if (ctx->strict_gop) { ctx->config.rcParams.strictGOPTarget = 1; av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); } if (ctx->nonref_p) ctx->config.rcParams.enableNonRefP = 1; if (ctx->zerolatency) ctx->config.rcParams.zeroReorderDelay = 1; if (ctx->quality) ctx->config.rcParams.targetQuality = ctx->quality; #endif /* NVENCAPI_MAJOR_VERSION >= 7 */ }
false
FFmpeg
5b26d3b789bd19a32dbe1e9c7ccab9498de7ee9b
static void nvenc_setup_rate_control(AVCodecContext *avctx) { NVENCContext *ctx = avctx->priv_data; NV_ENC_RC_PARAMS *rc = &ctx->config.rcParams; if (avctx->bit_rate > 0) rc->averageBitRate = avctx->bit_rate; if (avctx->rc_max_rate > 0) rc->maxBitRate = avctx->rc_max_rate; if (ctx->rc > 0) { nvenc_override_rate_control(avctx, rc); } else if (ctx->flags & NVENC_LOSSLESS) { set_lossless(avctx, rc); } else if (avctx->global_quality > 0) { set_constqp(avctx, rc); } else if (avctx->qmin >= 0 && avctx->qmax >= 0) { rc->rateControlMode = NV_ENC_PARAMS_RC_VBR; set_vbr(avctx, rc); } if (avctx->rc_buffer_size > 0) rc->vbvBufferSize = avctx->rc_buffer_size; if (rc->averageBitRate > 0) avctx->bit_rate = rc->averageBitRate; #if NVENCAPI_MAJOR_VERSION >= 7 if (ctx->aq) { ctx->config.rcParams.enableAQ = 1; ctx->config.rcParams.aqStrength = ctx->aq_strength; av_log(avctx, AV_LOG_VERBOSE, "AQ enabled.\n"); } if (ctx->temporal_aq) { ctx->config.rcParams.enableTemporalAQ = 1; av_log(avctx, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); } if (ctx->rc_lookahead) { int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - ctx->config.frameIntervalP - 4; if (lkd_bound < 0) { av_log(avctx, AV_LOG_WARNING, "Lookahead not enabled. Increase buffer delay (-delay).\n"); } else { ctx->config.rcParams.enableLookahead = 1; ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); ctx->config.rcParams.disableIadapt = ctx->no_scenecut; ctx->config.rcParams.disableBadapt = !ctx->b_adapt; av_log(avctx, AV_LOG_VERBOSE, "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", ctx->config.rcParams.lookaheadDepth, ctx->config.rcParams.disableIadapt ? "disabled" : "enabled", ctx->config.rcParams.disableBadapt ? "disabled" : "enabled"); } } if (ctx->strict_gop) { ctx->config.rcParams.strictGOPTarget = 1; av_log(avctx, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); } if (ctx->nonref_p) ctx->config.rcParams.enableNonRefP = 1; if (ctx->zerolatency) ctx->config.rcParams.zeroReorderDelay = 1; if (ctx->quality) ctx->config.rcParams.targetQuality = ctx->quality; #endif }
{ "code": [], "line_no": [] }
static void FUNC_0(AVCodecContext *VAR_0) { NVENCContext *ctx = VAR_0->priv_data; NV_ENC_RC_PARAMS *rc = &ctx->config.rcParams; if (VAR_0->bit_rate > 0) rc->averageBitRate = VAR_0->bit_rate; if (VAR_0->rc_max_rate > 0) rc->maxBitRate = VAR_0->rc_max_rate; if (ctx->rc > 0) { nvenc_override_rate_control(VAR_0, rc); } else if (ctx->flags & NVENC_LOSSLESS) { set_lossless(VAR_0, rc); } else if (VAR_0->global_quality > 0) { set_constqp(VAR_0, rc); } else if (VAR_0->qmin >= 0 && VAR_0->qmax >= 0) { rc->rateControlMode = NV_ENC_PARAMS_RC_VBR; set_vbr(VAR_0, rc); } if (VAR_0->rc_buffer_size > 0) rc->vbvBufferSize = VAR_0->rc_buffer_size; if (rc->averageBitRate > 0) VAR_0->bit_rate = rc->averageBitRate; #if NVENCAPI_MAJOR_VERSION >= 7 if (ctx->aq) { ctx->config.rcParams.enableAQ = 1; ctx->config.rcParams.aqStrength = ctx->aq_strength; av_log(VAR_0, AV_LOG_VERBOSE, "AQ enabled.\n"); } if (ctx->temporal_aq) { ctx->config.rcParams.enableTemporalAQ = 1; av_log(VAR_0, AV_LOG_VERBOSE, "Temporal AQ enabled.\n"); } if (ctx->rc_lookahead) { int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) - ctx->config.frameIntervalP - 4; if (lkd_bound < 0) { av_log(VAR_0, AV_LOG_WARNING, "Lookahead not enabled. Increase buffer delay (-delay).\n"); } else { ctx->config.rcParams.enableLookahead = 1; ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound); ctx->config.rcParams.disableIadapt = ctx->no_scenecut; ctx->config.rcParams.disableBadapt = !ctx->b_adapt; av_log(VAR_0, AV_LOG_VERBOSE, "Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\n", ctx->config.rcParams.lookaheadDepth, ctx->config.rcParams.disableIadapt ? "disabled" : "enabled", ctx->config.rcParams.disableBadapt ? "disabled" : "enabled"); } } if (ctx->strict_gop) { ctx->config.rcParams.strictGOPTarget = 1; av_log(VAR_0, AV_LOG_VERBOSE, "Strict GOP target enabled.\n"); } if (ctx->nonref_p) ctx->config.rcParams.enableNonRefP = 1; if (ctx->zerolatency) ctx->config.rcParams.zeroReorderDelay = 1; if (ctx->quality) ctx->config.rcParams.targetQuality = ctx->quality; #endif }
[ "static void FUNC_0(AVCodecContext *VAR_0)\n{", "NVENCContext *ctx = VAR_0->priv_data;", "NV_ENC_RC_PARAMS *rc = &ctx->config.rcParams;", "if (VAR_0->bit_rate > 0)\nrc->averageBitRate = VAR_0->bit_rate;", "if (VAR_0->rc_max_rate > 0)\nrc->maxBitRate = VAR_0->rc_max_rate;", "if (ctx->rc > 0) {", "nvenc_override_rate_control(VAR_0, rc);", "} else if (ctx->flags & NVENC_LOSSLESS) {", "set_lossless(VAR_0, rc);", "} else if (VAR_0->global_quality > 0) {", "set_constqp(VAR_0, rc);", "} else if (VAR_0->qmin >= 0 && VAR_0->qmax >= 0) {", "rc->rateControlMode = NV_ENC_PARAMS_RC_VBR;", "set_vbr(VAR_0, rc);", "}", "if (VAR_0->rc_buffer_size > 0)\nrc->vbvBufferSize = VAR_0->rc_buffer_size;", "if (rc->averageBitRate > 0)\nVAR_0->bit_rate = rc->averageBitRate;", "#if NVENCAPI_MAJOR_VERSION >= 7\nif (ctx->aq) {", "ctx->config.rcParams.enableAQ = 1;", "ctx->config.rcParams.aqStrength = ctx->aq_strength;", "av_log(VAR_0, AV_LOG_VERBOSE, \"AQ enabled.\\n\");", "}", "if (ctx->temporal_aq) {", "ctx->config.rcParams.enableTemporalAQ = 1;", "av_log(VAR_0, AV_LOG_VERBOSE, \"Temporal AQ enabled.\\n\");", "}", "if (ctx->rc_lookahead) {", "int lkd_bound = FFMIN(ctx->nb_surfaces, ctx->async_depth) -\nctx->config.frameIntervalP - 4;", "if (lkd_bound < 0) {", "av_log(VAR_0, AV_LOG_WARNING,\n\"Lookahead not enabled. Increase buffer delay (-delay).\\n\");", "} else {", "ctx->config.rcParams.enableLookahead = 1;", "ctx->config.rcParams.lookaheadDepth = av_clip(ctx->rc_lookahead, 0, lkd_bound);", "ctx->config.rcParams.disableIadapt = ctx->no_scenecut;", "ctx->config.rcParams.disableBadapt = !ctx->b_adapt;", "av_log(VAR_0, AV_LOG_VERBOSE,\n\"Lookahead enabled: depth %d, scenecut %s, B-adapt %s.\\n\",\nctx->config.rcParams.lookaheadDepth,\nctx->config.rcParams.disableIadapt ? \"disabled\" : \"enabled\",\nctx->config.rcParams.disableBadapt ? \"disabled\" : \"enabled\");", "}", "}", "if (ctx->strict_gop) {", "ctx->config.rcParams.strictGOPTarget = 1;", "av_log(VAR_0, AV_LOG_VERBOSE, \"Strict GOP target enabled.\\n\");", "}", "if (ctx->nonref_p)\nctx->config.rcParams.enableNonRefP = 1;", "if (ctx->zerolatency)\nctx->config.rcParams.zeroReorderDelay = 1;", "if (ctx->quality)\nctx->config.rcParams.targetQuality = ctx->quality;", "#endif\n}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 51, 53 ], [ 57, 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 81 ], [ 83, 85 ], [ 89 ], [ 91, 93 ], [ 95 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105, 107, 109, 111, 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125 ], [ 127 ], [ 131, 133 ], [ 137, 139 ], [ 143, 145 ], [ 147, 149 ] ]
6,056
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int nb_samples = insamples->audio->nb_samples; AVFilterBufferRef *outpicref = showwaves->outpicref; int linesize = outpicref ? outpicref->linesize[0] : 0; int16_t *p = (int16_t *)insamples->data[0]; int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); int i, j, h; const int n = showwaves->n; const int x = 255 / (nb_channels * n); /* multiplication factor, pre-computed to avoid in-loop divisions */ /* draw data in the buffer */ for (i = 0; i < nb_samples; i++) { if (!outpicref) { showwaves->outpicref = outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); if (!outpicref) return AVERROR(ENOMEM); outpicref->video->w = outlink->w; outpicref->video->h = outlink->h; outpicref->pts = insamples->pts + av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels, (AVRational){ 1, inlink->sample_rate }, outlink->time_base); linesize = outpicref->linesize[0]; memset(outpicref->data[0], 0, showwaves->h*linesize); } for (j = 0; j < nb_channels; j++) { h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16); if (h >= 0 && h < outlink->h) *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == n) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); outpicref = showwaves->outpicref; } avfilter_unref_buffer(insamples); return 0; }
false
FFmpeg
5b10c5e7e4d79750974026f39940164d10b891cb
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *insamples) { AVFilterContext *ctx = inlink->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int nb_samples = insamples->audio->nb_samples; AVFilterBufferRef *outpicref = showwaves->outpicref; int linesize = outpicref ? outpicref->linesize[0] : 0; int16_t *p = (int16_t *)insamples->data[0]; int nb_channels = av_get_channel_layout_nb_channels(insamples->audio->channel_layout); int i, j, h; const int n = showwaves->n; const int x = 255 / (nb_channels * n); for (i = 0; i < nb_samples; i++) { if (!outpicref) { showwaves->outpicref = outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->h); if (!outpicref) return AVERROR(ENOMEM); outpicref->video->w = outlink->w; outpicref->video->h = outlink->h; outpicref->pts = insamples->pts + av_rescale_q((p - (int16_t *)insamples->data[0]) / nb_channels, (AVRational){ 1, inlink->sample_rate }, outlink->time_base); linesize = outpicref->linesize[0]; memset(outpicref->data[0], 0, showwaves->h*linesize); } for (j = 0; j < nb_channels; j++) { h = showwaves->h/2 - av_rescale(*p++, showwaves->h/2, MAX_INT16); if (h >= 0 && h < outlink->h) *(outpicref->data[0] + showwaves->buf_idx + h * linesize) += x; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == n) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); outpicref = showwaves->outpicref; } avfilter_unref_buffer(insamples); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1) { AVFilterContext *ctx = VAR_0->dst; AVFilterLink *outlink = ctx->outputs[0]; ShowWavesContext *showwaves = ctx->priv; const int VAR_2 = VAR_1->audio->VAR_2; AVFilterBufferRef *outpicref = showwaves->outpicref; int VAR_3 = outpicref ? outpicref->VAR_3[0] : 0; int16_t *p = (int16_t *)VAR_1->data[0]; int VAR_4 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout); int VAR_5, VAR_6, VAR_7; const int VAR_8 = showwaves->VAR_8; const int VAR_9 = 255 / (VAR_4 * VAR_8); for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) { if (!outpicref) { showwaves->outpicref = outpicref = ff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN, outlink->w, outlink->VAR_7); if (!outpicref) return AVERROR(ENOMEM); outpicref->video->w = outlink->w; outpicref->video->VAR_7 = outlink->VAR_7; outpicref->pts = VAR_1->pts + av_rescale_q((p - (int16_t *)VAR_1->data[0]) / VAR_4, (AVRational){ 1, VAR_0->sample_rate }, outlink->time_base); VAR_3 = outpicref->VAR_3[0]; memset(outpicref->data[0], 0, showwaves->VAR_7*VAR_3); } for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) { VAR_7 = showwaves->VAR_7/2 - av_rescale(*p++, showwaves->VAR_7/2, MAX_INT16); if (VAR_7 >= 0 && VAR_7 < outlink->VAR_7) *(outpicref->data[0] + showwaves->buf_idx + VAR_7 * VAR_3) += VAR_9; } showwaves->sample_count_mod++; if (showwaves->sample_count_mod == VAR_8) { showwaves->sample_count_mod = 0; showwaves->buf_idx++; } if (showwaves->buf_idx == showwaves->w) push_frame(outlink); outpicref = showwaves->outpicref; } avfilter_unref_buffer(VAR_1); return 0; }
[ "static int FUNC_0(AVFilterLink *VAR_0, AVFilterBufferRef *VAR_1)\n{", "AVFilterContext *ctx = VAR_0->dst;", "AVFilterLink *outlink = ctx->outputs[0];", "ShowWavesContext *showwaves = ctx->priv;", "const int VAR_2 = VAR_1->audio->VAR_2;", "AVFilterBufferRef *outpicref = showwaves->outpicref;", "int VAR_3 = outpicref ? outpicref->VAR_3[0] : 0;", "int16_t *p = (int16_t *)VAR_1->data[0];", "int VAR_4 = av_get_channel_layout_nb_channels(VAR_1->audio->channel_layout);", "int VAR_5, VAR_6, VAR_7;", "const int VAR_8 = showwaves->VAR_8;", "const int VAR_9 = 255 / (VAR_4 * VAR_8);", "for (VAR_5 = 0; VAR_5 < VAR_2; VAR_5++) {", "if (!outpicref) {", "showwaves->outpicref = outpicref =\nff_get_video_buffer(outlink, AV_PERM_WRITE|AV_PERM_ALIGN,\noutlink->w, outlink->VAR_7);", "if (!outpicref)\nreturn AVERROR(ENOMEM);", "outpicref->video->w = outlink->w;", "outpicref->video->VAR_7 = outlink->VAR_7;", "outpicref->pts = VAR_1->pts +\nav_rescale_q((p - (int16_t *)VAR_1->data[0]) / VAR_4,\n(AVRational){ 1, VAR_0->sample_rate },", "outlink->time_base);", "VAR_3 = outpicref->VAR_3[0];", "memset(outpicref->data[0], 0, showwaves->VAR_7*VAR_3);", "}", "for (VAR_6 = 0; VAR_6 < VAR_4; VAR_6++) {", "VAR_7 = showwaves->VAR_7/2 - av_rescale(*p++, showwaves->VAR_7/2, MAX_INT16);", "if (VAR_7 >= 0 && VAR_7 < outlink->VAR_7)\n*(outpicref->data[0] + showwaves->buf_idx + VAR_7 * VAR_3) += VAR_9;", "}", "showwaves->sample_count_mod++;", "if (showwaves->sample_count_mod == VAR_8) {", "showwaves->sample_count_mod = 0;", "showwaves->buf_idx++;", "}", "if (showwaves->buf_idx == showwaves->w)\npush_frame(outlink);", "outpicref = showwaves->outpicref;", "}", "avfilter_unref_buffer(VAR_1);", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 31 ], [ 33 ], [ 35, 37, 39 ], [ 41, 43 ], [ 45 ], [ 47 ], [ 49, 51, 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67, 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 93 ], [ 95 ], [ 97 ] ]
6,057
static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) { int i, d; const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); const int alpha = alpha_table[index_a]; const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; for( i = 0; i < 4; i++ ) { if( bS[i] == 0 ) { pix += 4 * stride; continue; } /* 4px edge length */ for( d = 0; d < 4; d++ ) { const uint8_t p0 = pix[-1]; const uint8_t p1 = pix[-2]; const uint8_t p2 = pix[-3]; const uint8_t q0 = pix[0]; const uint8_t q1 = pix[1]; const uint8_t q2 = pix[2]; if( abs( p0 - q0 ) >= alpha || abs( p1 - p0 ) >= beta || abs( q1 - q0 ) >= beta ) { pix += stride; continue; } if( bS[i] < 4 ) { const int tc0 = tc0_table[index_a][bS[i] - 1]; int tc = tc0; int i_delta; if( abs( p2 - p0 ) < beta ) { pix[-2] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 ); tc++; } if( abs( q2 - q0 ) < beta ) { pix[1] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 ); tc++; } i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-1] = clip( p0 + i_delta, 0, 255 ); /* p0' */ pix[0] = clip( q0 - i_delta, 0, 255 ); /* q0' */ } else { const int c = abs( p0 - q0 ) < (( alpha >> 2 ) + 2 ); if( abs( p2 - p0 ) < beta && c ) { const uint8_t p3 = pix[-4]; /* p0', p1', p2' */ pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3; pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3; } else { /* p0' */ pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; } if( abs( q2 - q0 ) < beta && c ) { const uint8_t q3 = pix[3]; /* q0', q1', q2' */ pix[0] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3; pix[1] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; pix[2] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3; } else { /* q0' */ pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; } } pix += stride; } } }
false
FFmpeg
3ebc7e04dea6072400d91c1c90eb3911754cee06
static void filter_mb_edgev( H264Context *h, uint8_t *pix, int stride, int bS[4], int qp ) { int i, d; const int index_a = clip( qp + h->slice_alpha_c0_offset, 0, 51 ); const int alpha = alpha_table[index_a]; const int beta = beta_table[clip( qp + h->slice_beta_offset, 0, 51 )]; for( i = 0; i < 4; i++ ) { if( bS[i] == 0 ) { pix += 4 * stride; continue; } for( d = 0; d < 4; d++ ) { const uint8_t p0 = pix[-1]; const uint8_t p1 = pix[-2]; const uint8_t p2 = pix[-3]; const uint8_t q0 = pix[0]; const uint8_t q1 = pix[1]; const uint8_t q2 = pix[2]; if( abs( p0 - q0 ) >= alpha || abs( p1 - p0 ) >= beta || abs( q1 - q0 ) >= beta ) { pix += stride; continue; } if( bS[i] < 4 ) { const int tc0 = tc0_table[index_a][bS[i] - 1]; int tc = tc0; int i_delta; if( abs( p2 - p0 ) < beta ) { pix[-2] = p1 + clip( ( p2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( p1 << 1 ) ) >> 1, -tc0, tc0 ); tc++; } if( abs( q2 - q0 ) < beta ) { pix[1] = q1 + clip( ( q2 + ( ( p0 + q0 + 1 ) >> 1 ) - ( q1 << 1 ) ) >> 1, -tc0, tc0 ); tc++; } i_delta = clip( (((q0 - p0 ) << 2) + (p1 - q1) + 4) >> 3, -tc, tc ); pix[-1] = clip( p0 + i_delta, 0, 255 ); pix[0] = clip( q0 - i_delta, 0, 255 ); } else { const int c = abs( p0 - q0 ) < (( alpha >> 2 ) + 2 ); if( abs( p2 - p0 ) < beta && c ) { const uint8_t p3 = pix[-4]; pix[-1] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3; pix[-2] = ( p2 + p1 + p0 + q0 + 2 ) >> 2; pix[-3] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3; } else { pix[-1] = ( 2*p1 + p0 + q1 + 2 ) >> 2; } if( abs( q2 - q0 ) < beta && c ) { const uint8_t q3 = pix[3]; pix[0] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3; pix[1] = ( p0 + q0 + q1 + q2 + 2 ) >> 2; pix[2] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3; } else { pix[0] = ( 2*q1 + q0 + p1 + 2 ) >> 2; } } pix += stride; } } }
{ "code": [], "line_no": [] }
static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3[4], int VAR_4 ) { int VAR_5, VAR_6; const int VAR_7 = clip( VAR_4 + VAR_0->slice_alpha_c0_offset, 0, 51 ); const int VAR_8 = alpha_table[VAR_7]; const int VAR_9 = beta_table[clip( VAR_4 + VAR_0->slice_beta_offset, 0, 51 )]; for( VAR_5 = 0; VAR_5 < 4; VAR_5++ ) { if( VAR_3[VAR_5] == 0 ) { VAR_1 += 4 * VAR_2; continue; } for( VAR_6 = 0; VAR_6 < 4; VAR_6++ ) { const uint8_t VAR_10 = VAR_1[-1]; const uint8_t VAR_11 = VAR_1[-2]; const uint8_t VAR_12 = VAR_1[-3]; const uint8_t VAR_13 = VAR_1[0]; const uint8_t VAR_14 = VAR_1[1]; const uint8_t VAR_15 = VAR_1[2]; if( abs( VAR_10 - VAR_13 ) >= VAR_8 || abs( VAR_11 - VAR_10 ) >= VAR_9 || abs( VAR_14 - VAR_13 ) >= VAR_9 ) { VAR_1 += VAR_2; continue; } if( VAR_3[VAR_5] < 4 ) { const int VAR_16 = tc0_table[VAR_7][VAR_3[VAR_5] - 1]; int VAR_17 = VAR_16; int VAR_18; if( abs( VAR_12 - VAR_10 ) < VAR_9 ) { VAR_1[-2] = VAR_11 + clip( ( VAR_12 + ( ( VAR_10 + VAR_13 + 1 ) >> 1 ) - ( VAR_11 << 1 ) ) >> 1, -VAR_16, VAR_16 ); VAR_17++; } if( abs( VAR_15 - VAR_13 ) < VAR_9 ) { VAR_1[1] = VAR_14 + clip( ( VAR_15 + ( ( VAR_10 + VAR_13 + 1 ) >> 1 ) - ( VAR_14 << 1 ) ) >> 1, -VAR_16, VAR_16 ); VAR_17++; } VAR_18 = clip( (((VAR_13 - VAR_10 ) << 2) + (VAR_11 - VAR_14) + 4) >> 3, -VAR_17, VAR_17 ); VAR_1[-1] = clip( VAR_10 + VAR_18, 0, 255 ); VAR_1[0] = clip( VAR_13 - VAR_18, 0, 255 ); } else { const int VAR_19 = abs( VAR_10 - VAR_13 ) < (( VAR_8 >> 2 ) + 2 ); if( abs( VAR_12 - VAR_10 ) < VAR_9 && VAR_19 ) { const uint8_t VAR_20 = VAR_1[-4]; VAR_1[-1] = ( VAR_12 + 2*VAR_11 + 2*VAR_10 + 2*VAR_13 + VAR_14 + 4 ) >> 3; VAR_1[-2] = ( VAR_12 + VAR_11 + VAR_10 + VAR_13 + 2 ) >> 2; VAR_1[-3] = ( 2*VAR_20 + 3*VAR_12 + VAR_11 + VAR_10 + VAR_13 + 4 ) >> 3; } else { VAR_1[-1] = ( 2*VAR_11 + VAR_10 + VAR_14 + 2 ) >> 2; } if( abs( VAR_15 - VAR_13 ) < VAR_9 && VAR_19 ) { const uint8_t VAR_21 = VAR_1[3]; VAR_1[0] = ( VAR_11 + 2*VAR_10 + 2*VAR_13 + 2*VAR_14 + VAR_15 + 4 ) >> 3; VAR_1[1] = ( VAR_10 + VAR_13 + VAR_14 + VAR_15 + 2 ) >> 2; VAR_1[2] = ( 2*VAR_21 + 3*VAR_15 + VAR_14 + VAR_13 + VAR_10 + 4 ) >> 3; } else { VAR_1[0] = ( 2*VAR_14 + VAR_13 + VAR_11 + 2 ) >> 2; } } VAR_1 += VAR_2; } } }
[ "static void FUNC_0( H264Context *VAR_0, uint8_t *VAR_1, int VAR_2, int VAR_3[4], int VAR_4 ) {", "int VAR_5, VAR_6;", "const int VAR_7 = clip( VAR_4 + VAR_0->slice_alpha_c0_offset, 0, 51 );", "const int VAR_8 = alpha_table[VAR_7];", "const int VAR_9 = beta_table[clip( VAR_4 + VAR_0->slice_beta_offset, 0, 51 )];", "for( VAR_5 = 0; VAR_5 < 4; VAR_5++ ) {", "if( VAR_3[VAR_5] == 0 ) {", "VAR_1 += 4 * VAR_2;", "continue;", "}", "for( VAR_6 = 0; VAR_6 < 4; VAR_6++ ) {", "const uint8_t VAR_10 = VAR_1[-1];", "const uint8_t VAR_11 = VAR_1[-2];", "const uint8_t VAR_12 = VAR_1[-3];", "const uint8_t VAR_13 = VAR_1[0];", "const uint8_t VAR_14 = VAR_1[1];", "const uint8_t VAR_15 = VAR_1[2];", "if( abs( VAR_10 - VAR_13 ) >= VAR_8 ||\nabs( VAR_11 - VAR_10 ) >= VAR_9 ||\nabs( VAR_14 - VAR_13 ) >= VAR_9 ) {", "VAR_1 += VAR_2;", "continue;", "}", "if( VAR_3[VAR_5] < 4 ) {", "const int VAR_16 = tc0_table[VAR_7][VAR_3[VAR_5] - 1];", "int VAR_17 = VAR_16;", "int VAR_18;", "if( abs( VAR_12 - VAR_10 ) < VAR_9 ) {", "VAR_1[-2] = VAR_11 + clip( ( VAR_12 + ( ( VAR_10 + VAR_13 + 1 ) >> 1 ) - ( VAR_11 << 1 ) ) >> 1, -VAR_16, VAR_16 );", "VAR_17++;", "}", "if( abs( VAR_15 - VAR_13 ) < VAR_9 ) {", "VAR_1[1] = VAR_14 + clip( ( VAR_15 + ( ( VAR_10 + VAR_13 + 1 ) >> 1 ) - ( VAR_14 << 1 ) ) >> 1, -VAR_16, VAR_16 );", "VAR_17++;", "}", "VAR_18 = clip( (((VAR_13 - VAR_10 ) << 2) + (VAR_11 - VAR_14) + 4) >> 3, -VAR_17, VAR_17 );", "VAR_1[-1] = clip( VAR_10 + VAR_18, 0, 255 );", "VAR_1[0] = clip( VAR_13 - VAR_18, 0, 255 );", "}", "else\n{", "const int VAR_19 = abs( VAR_10 - VAR_13 ) < (( VAR_8 >> 2 ) + 2 );", "if( abs( VAR_12 - VAR_10 ) < VAR_9 && VAR_19 )\n{", "const uint8_t VAR_20 = VAR_1[-4];", "VAR_1[-1] = ( VAR_12 + 2*VAR_11 + 2*VAR_10 + 2*VAR_13 + VAR_14 + 4 ) >> 3;", "VAR_1[-2] = ( VAR_12 + VAR_11 + VAR_10 + VAR_13 + 2 ) >> 2;", "VAR_1[-3] = ( 2*VAR_20 + 3*VAR_12 + VAR_11 + VAR_10 + VAR_13 + 4 ) >> 3;", "} else {", "VAR_1[-1] = ( 2*VAR_11 + VAR_10 + VAR_14 + 2 ) >> 2;", "}", "if( abs( VAR_15 - VAR_13 ) < VAR_9 && VAR_19 )\n{", "const uint8_t VAR_21 = VAR_1[3];", "VAR_1[0] = ( VAR_11 + 2*VAR_10 + 2*VAR_13 + 2*VAR_14 + VAR_15 + 4 ) >> 3;", "VAR_1[1] = ( VAR_10 + VAR_13 + VAR_14 + VAR_15 + 2 ) >> 2;", "VAR_1[2] = ( 2*VAR_21 + 3*VAR_15 + VAR_14 + VAR_13 + VAR_10 + 4 ) >> 3;", "} else {", "VAR_1[0] = ( 2*VAR_14 + VAR_13 + VAR_11 + 2 ) >> 2;", "}", "}", "VAR_1 += 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 ]
[ [ 1 ], [ 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95, 97 ], [ 99 ], [ 103, 105 ], [ 107 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 133 ], [ 135 ], [ 137 ], [ 139 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 151 ], [ 153 ], [ 155 ] ]
6,058
static void report_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, ...) { va_list vl; va_start(vl, fmt); av_log(NULL, log_level, "%s:%d: ", filename, line_num); av_vlog(NULL, log_level, fmt, vl); va_end(vl); (*errors)++; }
false
FFmpeg
ed1f8915daf6b84a940463dfe83c7b970f82383d
static void report_config_error(const char *filename, int line_num, int log_level, int *errors, const char *fmt, ...) { va_list vl; va_start(vl, fmt); av_log(NULL, log_level, "%s:%d: ", filename, line_num); av_vlog(NULL, log_level, fmt, vl); va_end(vl); (*errors)++; }
{ "code": [], "line_no": [] }
static void FUNC_0(const char *VAR_0, int VAR_1, int VAR_2, int *VAR_3, const char *VAR_4, ...) { va_list vl; va_start(vl, VAR_4); av_log(NULL, VAR_2, "%s:%d: ", VAR_0, VAR_1); av_vlog(NULL, VAR_2, VAR_4, vl); va_end(vl); (*VAR_3)++; }
[ "static void FUNC_0(const char *VAR_0, int VAR_1, int VAR_2, int *VAR_3, const char *VAR_4, ...)\n{", "va_list vl;", "va_start(vl, VAR_4);", "av_log(NULL, VAR_2, \"%s:%d: \", VAR_0, VAR_1);", "av_vlog(NULL, VAR_2, VAR_4, vl);", "va_end(vl);", "(*VAR_3)++;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 17 ], [ 19 ] ]
6,060
static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *v2, const float *v3) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int ret; cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN); fdsp->vector_fmul_add(odst, v1, v2, v3, LEN); if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n"); return ret; }
false
FFmpeg
e53c9065ca08a9153ecc73a6a8940bcc6d667e58
static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, const float *v1, const float *v2, const float *v3) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int ret; cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN); fdsp->vector_fmul_add(odst, v1, v2, v3, LEN); if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n"); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFloatDSPContext *VAR_0, AVFloatDSPContext *VAR_1, const float *VAR_2, const float *VAR_3, const float *VAR_4) { LOCAL_ALIGNED(32, float, cdst, [LEN]); LOCAL_ALIGNED(32, float, odst, [LEN]); int VAR_5; VAR_1->vector_fmul_add(cdst, VAR_2, VAR_3, VAR_4, LEN); VAR_0->vector_fmul_add(odst, VAR_2, VAR_3, VAR_4, LEN); if (VAR_5 = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST)) av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n"); return VAR_5; }
[ "static int FUNC_0(AVFloatDSPContext *VAR_0, AVFloatDSPContext *VAR_1,\nconst float *VAR_2, const float *VAR_3, const float *VAR_4)\n{", "LOCAL_ALIGNED(32, float, cdst, [LEN]);", "LOCAL_ALIGNED(32, float, odst, [LEN]);", "int VAR_5;", "VAR_1->vector_fmul_add(cdst, VAR_2, VAR_3, VAR_4, LEN);", "VAR_0->vector_fmul_add(odst, VAR_2, VAR_3, VAR_4, LEN);", "if (VAR_5 = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST))\nav_log(NULL, AV_LOG_ERROR, \"vector_fmul_add failed\\n\");", "return VAR_5;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 21, 23 ], [ 27 ], [ 29 ] ]
6,061
static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; const int mot_stride = s->mb_stride; const int xy = mb_y *mot_stride + mb_x; int fbmin; int pred_fx= s->b_bidir_forw_mv_table[xy-1][0]; int pred_fy= s->b_bidir_forw_mv_table[xy-1][1]; int pred_bx= s->b_bidir_back_mv_table[xy-1][0]; int pred_by= s->b_bidir_back_mv_table[xy-1][1]; int motion_fx= s->b_bidir_forw_mv_table[xy][0]= s->b_forw_mv_table[xy][0]; int motion_fy= s->b_bidir_forw_mv_table[xy][1]= s->b_forw_mv_table[xy][1]; int motion_bx= s->b_bidir_back_mv_table[xy][0]= s->b_back_mv_table[xy][0]; int motion_by= s->b_bidir_back_mv_table[xy][1]= s->b_back_mv_table[xy][1]; const int flags= c->sub_flags; const int qpel= flags&FLAG_QPEL; const int shift= 1+qpel; const int xmin= c->xmin<<shift; const int ymin= c->ymin<<shift; const int xmax= c->xmax<<shift; const int ymax= c->ymax<<shift; uint8_t map[8][8][8][8]; memset(map,0,sizeof(map)); #define BIDIR_MAP(fx,fy,bx,by) \ map[(motion_fx+fx)&7][(motion_fy+fy)&7][(motion_bx+bx)&7][(motion_by+by)&7] BIDIR_MAP(0,0,0,0) = 1; fbmin= check_bidir_mv(s, motion_fx, motion_fy, motion_bx, motion_by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16); if(s->avctx->bidir_refine){ int score, end; #define CHECK_BIDIR(fx,fy,bx,by)\ if( !BIDIR_MAP(fx,fy,bx,by)\ &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ BIDIR_MAP(fx,fy,bx,by) = 1;\ score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\ if(score < fbmin){\ fbmin= score;\ motion_fx+=fx;\ motion_fy+=fy;\ motion_bx+=bx;\ motion_by+=by;\ end=0;\ }\ } #define CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR(a,b,c,d)\ CHECK_BIDIR(-a,-b,-c,-d) #define CHECK_BIDIRR(a,b,c,d)\ CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR2(b,c,d,a)\ CHECK_BIDIR2(c,d,a,b)\ CHECK_BIDIR2(d,a,b,c) do{ end=1; CHECK_BIDIRR( 0, 0, 0, 1) if(s->avctx->bidir_refine > 1){ CHECK_BIDIRR( 0, 0, 1, 1) CHECK_BIDIR2( 0, 1, 0, 1) CHECK_BIDIR2( 1, 0, 1, 0) CHECK_BIDIRR( 0, 0,-1, 1) CHECK_BIDIR2( 0,-1, 0, 1) CHECK_BIDIR2(-1, 0, 1, 0) if(s->avctx->bidir_refine > 2){ CHECK_BIDIRR( 0, 1, 1, 1) CHECK_BIDIRR( 0,-1, 1, 1) CHECK_BIDIRR( 0, 1,-1, 1) CHECK_BIDIRR( 0, 1, 1,-1) if(s->avctx->bidir_refine > 3){ CHECK_BIDIR2( 1, 1, 1, 1) CHECK_BIDIRR( 1, 1, 1,-1) CHECK_BIDIR2( 1, 1,-1,-1) CHECK_BIDIR2( 1,-1,-1, 1) CHECK_BIDIR2( 1,-1, 1,-1) } } } }while(!end); } s->b_bidir_forw_mv_table[xy][0]= motion_fx; s->b_bidir_forw_mv_table[xy][1]= motion_fy; s->b_bidir_back_mv_table[xy][0]= motion_bx; s->b_bidir_back_mv_table[xy][1]= motion_by; return fbmin; }
false
FFmpeg
8226ecaa6c7ba0c1e7ae9d575bcbdac95aaf673e
static inline int bidir_refine(MpegEncContext * s, int mb_x, int mb_y) { MotionEstContext * const c= &s->me; const int mot_stride = s->mb_stride; const int xy = mb_y *mot_stride + mb_x; int fbmin; int pred_fx= s->b_bidir_forw_mv_table[xy-1][0]; int pred_fy= s->b_bidir_forw_mv_table[xy-1][1]; int pred_bx= s->b_bidir_back_mv_table[xy-1][0]; int pred_by= s->b_bidir_back_mv_table[xy-1][1]; int motion_fx= s->b_bidir_forw_mv_table[xy][0]= s->b_forw_mv_table[xy][0]; int motion_fy= s->b_bidir_forw_mv_table[xy][1]= s->b_forw_mv_table[xy][1]; int motion_bx= s->b_bidir_back_mv_table[xy][0]= s->b_back_mv_table[xy][0]; int motion_by= s->b_bidir_back_mv_table[xy][1]= s->b_back_mv_table[xy][1]; const int flags= c->sub_flags; const int qpel= flags&FLAG_QPEL; const int shift= 1+qpel; const int xmin= c->xmin<<shift; const int ymin= c->ymin<<shift; const int xmax= c->xmax<<shift; const int ymax= c->ymax<<shift; uint8_t map[8][8][8][8]; memset(map,0,sizeof(map)); #define BIDIR_MAP(fx,fy,bx,by) \ map[(motion_fx+fx)&7][(motion_fy+fy)&7][(motion_bx+bx)&7][(motion_by+by)&7] BIDIR_MAP(0,0,0,0) = 1; fbmin= check_bidir_mv(s, motion_fx, motion_fy, motion_bx, motion_by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16); if(s->avctx->bidir_refine){ int score, end; #define CHECK_BIDIR(fx,fy,bx,by)\ if( !BIDIR_MAP(fx,fy,bx,by)\ &&(fx<=0 || motion_fx+fx<=xmax) && (fy<=0 || motion_fy+fy<=ymax) && (bx<=0 || motion_bx+bx<=xmax) && (by<=0 || motion_by+by<=ymax)\ &&(fx>=0 || motion_fx+fx>=xmin) && (fy>=0 || motion_fy+fy>=ymin) && (bx>=0 || motion_bx+bx>=xmin) && (by>=0 || motion_by+by>=ymin)){\ BIDIR_MAP(fx,fy,bx,by) = 1;\ score= check_bidir_mv(s, motion_fx+fx, motion_fy+fy, motion_bx+bx, motion_by+by, pred_fx, pred_fy, pred_bx, pred_by, 0, 16);\ if(score < fbmin){\ fbmin= score;\ motion_fx+=fx;\ motion_fy+=fy;\ motion_bx+=bx;\ motion_by+=by;\ end=0;\ }\ } #define CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR(a,b,c,d)\ CHECK_BIDIR(-a,-b,-c,-d) #define CHECK_BIDIRR(a,b,c,d)\ CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR2(b,c,d,a)\ CHECK_BIDIR2(c,d,a,b)\ CHECK_BIDIR2(d,a,b,c) do{ end=1; CHECK_BIDIRR( 0, 0, 0, 1) if(s->avctx->bidir_refine > 1){ CHECK_BIDIRR( 0, 0, 1, 1) CHECK_BIDIR2( 0, 1, 0, 1) CHECK_BIDIR2( 1, 0, 1, 0) CHECK_BIDIRR( 0, 0,-1, 1) CHECK_BIDIR2( 0,-1, 0, 1) CHECK_BIDIR2(-1, 0, 1, 0) if(s->avctx->bidir_refine > 2){ CHECK_BIDIRR( 0, 1, 1, 1) CHECK_BIDIRR( 0,-1, 1, 1) CHECK_BIDIRR( 0, 1,-1, 1) CHECK_BIDIRR( 0, 1, 1,-1) if(s->avctx->bidir_refine > 3){ CHECK_BIDIR2( 1, 1, 1, 1) CHECK_BIDIRR( 1, 1, 1,-1) CHECK_BIDIR2( 1, 1,-1,-1) CHECK_BIDIR2( 1,-1,-1, 1) CHECK_BIDIR2( 1,-1, 1,-1) } } } }while(!end); } s->b_bidir_forw_mv_table[xy][0]= motion_fx; s->b_bidir_forw_mv_table[xy][1]= motion_fy; s->b_bidir_back_mv_table[xy][0]= motion_bx; s->b_bidir_back_mv_table[xy][1]= motion_by; return fbmin; }
{ "code": [], "line_no": [] }
static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2) { MotionEstContext * const c= &VAR_0->me; const int VAR_3 = VAR_0->mb_stride; const int VAR_4 = VAR_2 *VAR_3 + VAR_1; int VAR_5; int VAR_6= VAR_0->b_bidir_forw_mv_table[VAR_4-1][0]; int VAR_7= VAR_0->b_bidir_forw_mv_table[VAR_4-1][1]; int VAR_8= VAR_0->b_bidir_back_mv_table[VAR_4-1][0]; int VAR_9= VAR_0->b_bidir_back_mv_table[VAR_4-1][1]; int VAR_10= VAR_0->b_bidir_forw_mv_table[VAR_4][0]= VAR_0->b_forw_mv_table[VAR_4][0]; int VAR_11= VAR_0->b_bidir_forw_mv_table[VAR_4][1]= VAR_0->b_forw_mv_table[VAR_4][1]; int VAR_12= VAR_0->b_bidir_back_mv_table[VAR_4][0]= VAR_0->b_back_mv_table[VAR_4][0]; int VAR_13= VAR_0->b_bidir_back_mv_table[VAR_4][1]= VAR_0->b_back_mv_table[VAR_4][1]; const int VAR_14= c->sub_flags; const int VAR_15= VAR_14&FLAG_QPEL; const int VAR_16= 1+VAR_15; const int VAR_17= c->VAR_17<<VAR_16; const int VAR_18= c->VAR_18<<VAR_16; const int VAR_19= c->VAR_19<<VAR_16; const int VAR_20= c->VAR_20<<VAR_16; uint8_t map[8][8][8][8]; memset(map,0,sizeof(map)); #define BIDIR_MAP(fx,fy,bx,by) \ map[(VAR_10+fx)&7][(VAR_11+fy)&7][(VAR_12+bx)&7][(VAR_13+by)&7] BIDIR_MAP(0,0,0,0) = 1; VAR_5= check_bidir_mv(VAR_0, VAR_10, VAR_11, VAR_12, VAR_13, VAR_6, VAR_7, VAR_8, VAR_9, 0, 16); if(VAR_0->avctx->FUNC_0){ int VAR_21, VAR_22; #define CHECK_BIDIR(fx,fy,bx,by)\ if( !BIDIR_MAP(fx,fy,bx,by)\ &&(fx<=0 || VAR_10+fx<=VAR_19) && (fy<=0 || VAR_11+fy<=VAR_20) && (bx<=0 || VAR_12+bx<=VAR_19) && (by<=0 || VAR_13+by<=VAR_20)\ &&(fx>=0 || VAR_10+fx>=VAR_17) && (fy>=0 || VAR_11+fy>=VAR_18) && (bx>=0 || VAR_12+bx>=VAR_17) && (by>=0 || VAR_13+by>=VAR_18)){\ BIDIR_MAP(fx,fy,bx,by) = 1;\ VAR_21= check_bidir_mv(VAR_0, VAR_10+fx, VAR_11+fy, VAR_12+bx, VAR_13+by, VAR_6, VAR_7, VAR_8, VAR_9, 0, 16);\ if(VAR_21 < VAR_5){\ VAR_5= VAR_21;\ VAR_10+=fx;\ VAR_11+=fy;\ VAR_12+=bx;\ VAR_13+=by;\ VAR_22=0;\ }\ } #define CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR(a,b,c,d)\ CHECK_BIDIR(-a,-b,-c,-d) #define CHECK_BIDIRR(a,b,c,d)\ CHECK_BIDIR2(a,b,c,d)\ CHECK_BIDIR2(b,c,d,a)\ CHECK_BIDIR2(c,d,a,b)\ CHECK_BIDIR2(d,a,b,c) do{ VAR_22=1; CHECK_BIDIRR( 0, 0, 0, 1) if(VAR_0->avctx->FUNC_0 > 1){ CHECK_BIDIRR( 0, 0, 1, 1) CHECK_BIDIR2( 0, 1, 0, 1) CHECK_BIDIR2( 1, 0, 1, 0) CHECK_BIDIRR( 0, 0,-1, 1) CHECK_BIDIR2( 0,-1, 0, 1) CHECK_BIDIR2(-1, 0, 1, 0) if(VAR_0->avctx->FUNC_0 > 2){ CHECK_BIDIRR( 0, 1, 1, 1) CHECK_BIDIRR( 0,-1, 1, 1) CHECK_BIDIRR( 0, 1,-1, 1) CHECK_BIDIRR( 0, 1, 1,-1) if(VAR_0->avctx->FUNC_0 > 3){ CHECK_BIDIR2( 1, 1, 1, 1) CHECK_BIDIRR( 1, 1, 1,-1) CHECK_BIDIR2( 1, 1,-1,-1) CHECK_BIDIR2( 1,-1,-1, 1) CHECK_BIDIR2( 1,-1, 1,-1) } } } }while(!VAR_22); } VAR_0->b_bidir_forw_mv_table[VAR_4][0]= VAR_10; VAR_0->b_bidir_forw_mv_table[VAR_4][1]= VAR_11; VAR_0->b_bidir_back_mv_table[VAR_4][0]= VAR_12; VAR_0->b_bidir_back_mv_table[VAR_4][1]= VAR_13; return VAR_5; }
[ "static inline int FUNC_0(MpegEncContext * VAR_0, int VAR_1, int VAR_2)\n{", "MotionEstContext * const c= &VAR_0->me;", "const int VAR_3 = VAR_0->mb_stride;", "const int VAR_4 = VAR_2 *VAR_3 + VAR_1;", "int VAR_5;", "int VAR_6= VAR_0->b_bidir_forw_mv_table[VAR_4-1][0];", "int VAR_7= VAR_0->b_bidir_forw_mv_table[VAR_4-1][1];", "int VAR_8= VAR_0->b_bidir_back_mv_table[VAR_4-1][0];", "int VAR_9= VAR_0->b_bidir_back_mv_table[VAR_4-1][1];", "int VAR_10= VAR_0->b_bidir_forw_mv_table[VAR_4][0]= VAR_0->b_forw_mv_table[VAR_4][0];", "int VAR_11= VAR_0->b_bidir_forw_mv_table[VAR_4][1]= VAR_0->b_forw_mv_table[VAR_4][1];", "int VAR_12= VAR_0->b_bidir_back_mv_table[VAR_4][0]= VAR_0->b_back_mv_table[VAR_4][0];", "int VAR_13= VAR_0->b_bidir_back_mv_table[VAR_4][1]= VAR_0->b_back_mv_table[VAR_4][1];", "const int VAR_14= c->sub_flags;", "const int VAR_15= VAR_14&FLAG_QPEL;", "const int VAR_16= 1+VAR_15;", "const int VAR_17= c->VAR_17<<VAR_16;", "const int VAR_18= c->VAR_18<<VAR_16;", "const int VAR_19= c->VAR_19<<VAR_16;", "const int VAR_20= c->VAR_20<<VAR_16;", "uint8_t map[8][8][8][8];", "memset(map,0,sizeof(map));", "#define BIDIR_MAP(fx,fy,bx,by) \\\nmap[(VAR_10+fx)&7][(VAR_11+fy)&7][(VAR_12+bx)&7][(VAR_13+by)&7]\nBIDIR_MAP(0,0,0,0) = 1;", "VAR_5= check_bidir_mv(VAR_0, VAR_10, VAR_11,\nVAR_12, VAR_13,\nVAR_6, VAR_7,\nVAR_8, VAR_9,\n0, 16);", "if(VAR_0->avctx->FUNC_0){", "int VAR_21, VAR_22;", "#define CHECK_BIDIR(fx,fy,bx,by)\\\nif( !BIDIR_MAP(fx,fy,bx,by)\\\n&&(fx<=0 || VAR_10+fx<=VAR_19) && (fy<=0 || VAR_11+fy<=VAR_20) && (bx<=0 || VAR_12+bx<=VAR_19) && (by<=0 || VAR_13+by<=VAR_20)\\\n&&(fx>=0 || VAR_10+fx>=VAR_17) && (fy>=0 || VAR_11+fy>=VAR_18) && (bx>=0 || VAR_12+bx>=VAR_17) && (by>=0 || VAR_13+by>=VAR_18)){\\", "BIDIR_MAP(fx,fy,bx,by) = 1;\\", "VAR_21= check_bidir_mv(VAR_0, VAR_10+fx, VAR_11+fy, VAR_12+bx, VAR_13+by, VAR_6, VAR_7, VAR_8, VAR_9, 0, 16);\\", "if(VAR_21 < VAR_5){\\", "VAR_5= VAR_21;\\", "VAR_10+=fx;\\", "VAR_11+=fy;\\", "VAR_12+=bx;\\", "VAR_13+=by;\\", "VAR_22=0;\\", "}\\", "}", "#define CHECK_BIDIR2(a,b,c,d)\\\nCHECK_BIDIR(a,b,c,d)\\\nCHECK_BIDIR(-a,-b,-c,-d)\n#define CHECK_BIDIRR(a,b,c,d)\\\nCHECK_BIDIR2(a,b,c,d)\\\nCHECK_BIDIR2(b,c,d,a)\\\nCHECK_BIDIR2(c,d,a,b)\\\nCHECK_BIDIR2(d,a,b,c)\ndo{", "VAR_22=1;", "CHECK_BIDIRR( 0, 0, 0, 1)\nif(VAR_0->avctx->FUNC_0 > 1){", "CHECK_BIDIRR( 0, 0, 1, 1)\nCHECK_BIDIR2( 0, 1, 0, 1)\nCHECK_BIDIR2( 1, 0, 1, 0)\nCHECK_BIDIRR( 0, 0,-1, 1)\nCHECK_BIDIR2( 0,-1, 0, 1)\nCHECK_BIDIR2(-1, 0, 1, 0)\nif(VAR_0->avctx->FUNC_0 > 2){", "CHECK_BIDIRR( 0, 1, 1, 1)\nCHECK_BIDIRR( 0,-1, 1, 1)\nCHECK_BIDIRR( 0, 1,-1, 1)\nCHECK_BIDIRR( 0, 1, 1,-1)\nif(VAR_0->avctx->FUNC_0 > 3){", "CHECK_BIDIR2( 1, 1, 1, 1)\nCHECK_BIDIRR( 1, 1, 1,-1)\nCHECK_BIDIR2( 1, 1,-1,-1)\nCHECK_BIDIR2( 1,-1,-1, 1)\nCHECK_BIDIR2( 1,-1, 1,-1)\n}", "}", "}", "}while(!VAR_22);", "}", "VAR_0->b_bidir_forw_mv_table[VAR_4][0]= VAR_10;", "VAR_0->b_bidir_forw_mv_table[VAR_4][1]= VAR_11;", "VAR_0->b_bidir_back_mv_table[VAR_4][0]= VAR_12;", "VAR_0->b_bidir_back_mv_table[VAR_4][1]= VAR_13;", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 47 ], [ 49, 51, 53 ], [ 57, 59, 61, 63, 65 ], [ 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, 123 ], [ 125 ], [ 129, 131 ], [ 133, 135, 137, 139, 141, 143, 145 ], [ 147, 149, 151, 153, 155 ], [ 157, 159, 161, 163, 165, 167 ], [ 169 ], [ 171 ], [ 173 ], [ 175 ], [ 179 ], [ 181 ], [ 183 ], [ 185 ], [ 189 ], [ 191 ] ]
6,062
int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count) { AVCodecContext *const avctx = h->avctx; H264Context *hx; int i; if (h->mb_y >= h->mb_height) { av_log(h->avctx, AV_LOG_ERROR, "Input contains more MB rows than the frame height.\n"); return AVERROR_INVALIDDATA; } if (h->avctx->hwaccel) return 0; if (context_count == 1) { return decode_slice(avctx, &h); } else { for (i = 1; i < context_count; i++) { hx = h->thread_context[i]; hx->er.error_count = 0; } avctx->execute(avctx, decode_slice, h->thread_context, NULL, context_count, sizeof(void *)); /* pull back stuff from slices to master context */ hx = h->thread_context[context_count - 1]; h->mb_x = hx->mb_x; h->mb_y = hx->mb_y; h->droppable = hx->droppable; h->picture_structure = hx->picture_structure; for (i = 1; i < context_count; i++) h->er.error_count += h->thread_context[i]->er.error_count; } return 0; }
false
FFmpeg
ad786dd450f26ecfbd35bb26e8b149664ecde049
int ff_h264_execute_decode_slices(H264Context *h, unsigned context_count) { AVCodecContext *const avctx = h->avctx; H264Context *hx; int i; if (h->mb_y >= h->mb_height) { av_log(h->avctx, AV_LOG_ERROR, "Input contains more MB rows than the frame height.\n"); return AVERROR_INVALIDDATA; } if (h->avctx->hwaccel) return 0; if (context_count == 1) { return decode_slice(avctx, &h); } else { for (i = 1; i < context_count; i++) { hx = h->thread_context[i]; hx->er.error_count = 0; } avctx->execute(avctx, decode_slice, h->thread_context, NULL, context_count, sizeof(void *)); hx = h->thread_context[context_count - 1]; h->mb_x = hx->mb_x; h->mb_y = hx->mb_y; h->droppable = hx->droppable; h->picture_structure = hx->picture_structure; for (i = 1; i < context_count; i++) h->er.error_count += h->thread_context[i]->er.error_count; } return 0; }
{ "code": [], "line_no": [] }
int FUNC_0(H264Context *VAR_0, unsigned VAR_1) { AVCodecContext *const avctx = VAR_0->avctx; H264Context *hx; int VAR_2; if (VAR_0->mb_y >= VAR_0->mb_height) { av_log(VAR_0->avctx, AV_LOG_ERROR, "Input contains more MB rows than the frame height.\n"); return AVERROR_INVALIDDATA; } if (VAR_0->avctx->hwaccel) return 0; if (VAR_1 == 1) { return decode_slice(avctx, &VAR_0); } else { for (VAR_2 = 1; VAR_2 < VAR_1; VAR_2++) { hx = VAR_0->thread_context[VAR_2]; hx->er.error_count = 0; } avctx->execute(avctx, decode_slice, VAR_0->thread_context, NULL, VAR_1, sizeof(void *)); hx = VAR_0->thread_context[VAR_1 - 1]; VAR_0->mb_x = hx->mb_x; VAR_0->mb_y = hx->mb_y; VAR_0->droppable = hx->droppable; VAR_0->picture_structure = hx->picture_structure; for (VAR_2 = 1; VAR_2 < VAR_1; VAR_2++) VAR_0->er.error_count += VAR_0->thread_context[VAR_2]->er.error_count; } return 0; }
[ "int FUNC_0(H264Context *VAR_0, unsigned VAR_1)\n{", "AVCodecContext *const avctx = VAR_0->avctx;", "H264Context *hx;", "int VAR_2;", "if (VAR_0->mb_y >= VAR_0->mb_height) {", "av_log(VAR_0->avctx, AV_LOG_ERROR,\n\"Input contains more MB rows than the frame height.\\n\");", "return AVERROR_INVALIDDATA;", "}", "if (VAR_0->avctx->hwaccel)\nreturn 0;", "if (VAR_1 == 1) {", "return decode_slice(avctx, &VAR_0);", "} else {", "for (VAR_2 = 1; VAR_2 < VAR_1; VAR_2++) {", "hx = VAR_0->thread_context[VAR_2];", "hx->er.error_count = 0;", "}", "avctx->execute(avctx, decode_slice, VAR_0->thread_context,\nNULL, VAR_1, sizeof(void *));", "hx = VAR_0->thread_context[VAR_1 - 1];", "VAR_0->mb_x = hx->mb_x;", "VAR_0->mb_y = hx->mb_y;", "VAR_0->droppable = hx->droppable;", "VAR_0->picture_structure = hx->picture_structure;", "for (VAR_2 = 1; VAR_2 < VAR_1; VAR_2++)", "VAR_0->er.error_count += VAR_0->thread_context[VAR_2]->er.error_count;", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15, 17 ], [ 19 ], [ 21 ], [ 25, 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 45, 47 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 71 ], [ 73 ] ]
6,064
static int open_next_file(AVFormatContext *avf) { ConcatContext *cat = avf->priv_data; unsigned fileno = cat->cur_file - cat->files; if (cat->cur_file->duration == AV_NOPTS_VALUE) cat->cur_file->duration = cat->avf->duration - (cat->cur_file->file_inpoint - cat->cur_file->file_start_time); if (++fileno >= cat->nb_files) { cat->eof = 1; return AVERROR_EOF; } return open_file(avf, fileno); }
false
FFmpeg
1a0d9b503d2e9c4278d6e93d40873dff9d191a25
static int open_next_file(AVFormatContext *avf) { ConcatContext *cat = avf->priv_data; unsigned fileno = cat->cur_file - cat->files; if (cat->cur_file->duration == AV_NOPTS_VALUE) cat->cur_file->duration = cat->avf->duration - (cat->cur_file->file_inpoint - cat->cur_file->file_start_time); if (++fileno >= cat->nb_files) { cat->eof = 1; return AVERROR_EOF; } return open_file(avf, fileno); }
{ "code": [], "line_no": [] }
static int FUNC_0(AVFormatContext *VAR_0) { ConcatContext *cat = VAR_0->priv_data; unsigned VAR_1 = cat->cur_file - cat->files; if (cat->cur_file->duration == AV_NOPTS_VALUE) cat->cur_file->duration = cat->VAR_0->duration - (cat->cur_file->file_inpoint - cat->cur_file->file_start_time); if (++VAR_1 >= cat->nb_files) { cat->eof = 1; return AVERROR_EOF; } return open_file(VAR_0, VAR_1); }
[ "static int FUNC_0(AVFormatContext *VAR_0)\n{", "ConcatContext *cat = VAR_0->priv_data;", "unsigned VAR_1 = cat->cur_file - cat->files;", "if (cat->cur_file->duration == AV_NOPTS_VALUE)\ncat->cur_file->duration = cat->VAR_0->duration - (cat->cur_file->file_inpoint - cat->cur_file->file_start_time);", "if (++VAR_1 >= cat->nb_files) {", "cat->eof = 1;", "return AVERROR_EOF;", "}", "return open_file(VAR_0, VAR_1);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11, 13 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ] ]
6,065
static void set_signalled(sPAPRDRConnector *drc) { drc->signalled = true; }
false
qemu
307b7715d0256c95444cada36a02882e46bada2f
static void set_signalled(sPAPRDRConnector *drc) { drc->signalled = true; }
{ "code": [], "line_no": [] }
static void FUNC_0(sPAPRDRConnector *VAR_0) { VAR_0->signalled = true; }
[ "static void FUNC_0(sPAPRDRConnector *VAR_0)\n{", "VAR_0->signalled = true;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
6,066
static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, BlkMigDevState *bmds, int is_async) { BlkMigBlock *blk; int64_t total_sectors = bmds->total_sectors; int64_t sector; int nr_sectors; int ret = -EIO; for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) { if (bmds_aio_inflight(bmds, sector)) { qemu_aio_flush(); } if (bdrv_get_dirty(bmds->bs, sector)) { if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) { nr_sectors = total_sectors - sector; } else { nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK; } blk = g_malloc(sizeof(BlkMigBlock)); blk->buf = g_malloc(BLOCK_SIZE); blk->bmds = bmds; blk->sector = sector; blk->nr_sectors = nr_sectors; if (is_async) { blk->iov.iov_base = blk->buf; blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); if (block_mig_state.submitted == 0) { block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock); } blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); if (!blk->aiocb) { goto error; } block_mig_state.submitted++; bmds_set_aio_inflight(bmds, sector, nr_sectors, 1); } else { ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors); if (ret < 0) { goto error; } blk_send(f, blk); g_free(blk->buf); g_free(blk); } bdrv_reset_dirty(bmds->bs, sector, nr_sectors); break; } sector += BDRV_SECTORS_PER_DIRTY_CHUNK; bmds->cur_dirty = sector; } return (bmds->cur_dirty >= bmds->total_sectors); error: monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector); qemu_file_set_error(f, ret); g_free(blk->buf); g_free(blk); return 0; }
false
qemu
922453bca6a927bb527068ae8679d587cfa45dbc
static int mig_save_device_dirty(Monitor *mon, QEMUFile *f, BlkMigDevState *bmds, int is_async) { BlkMigBlock *blk; int64_t total_sectors = bmds->total_sectors; int64_t sector; int nr_sectors; int ret = -EIO; for (sector = bmds->cur_dirty; sector < bmds->total_sectors;) { if (bmds_aio_inflight(bmds, sector)) { qemu_aio_flush(); } if (bdrv_get_dirty(bmds->bs, sector)) { if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) { nr_sectors = total_sectors - sector; } else { nr_sectors = BDRV_SECTORS_PER_DIRTY_CHUNK; } blk = g_malloc(sizeof(BlkMigBlock)); blk->buf = g_malloc(BLOCK_SIZE); blk->bmds = bmds; blk->sector = sector; blk->nr_sectors = nr_sectors; if (is_async) { blk->iov.iov_base = blk->buf; blk->iov.iov_len = nr_sectors * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); if (block_mig_state.submitted == 0) { block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock); } blk->aiocb = bdrv_aio_readv(bmds->bs, sector, &blk->qiov, nr_sectors, blk_mig_read_cb, blk); if (!blk->aiocb) { goto error; } block_mig_state.submitted++; bmds_set_aio_inflight(bmds, sector, nr_sectors, 1); } else { ret = bdrv_read(bmds->bs, sector, blk->buf, nr_sectors); if (ret < 0) { goto error; } blk_send(f, blk); g_free(blk->buf); g_free(blk); } bdrv_reset_dirty(bmds->bs, sector, nr_sectors); break; } sector += BDRV_SECTORS_PER_DIRTY_CHUNK; bmds->cur_dirty = sector; } return (bmds->cur_dirty >= bmds->total_sectors); error: monitor_printf(mon, "Error reading sector %" PRId64 "\n", sector); qemu_file_set_error(f, ret); g_free(blk->buf); g_free(blk); return 0; }
{ "code": [], "line_no": [] }
static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1, BlkMigDevState *VAR_2, int VAR_3) { BlkMigBlock *blk; int64_t total_sectors = VAR_2->total_sectors; int64_t sector; int VAR_4; int VAR_5 = -EIO; for (sector = VAR_2->cur_dirty; sector < VAR_2->total_sectors;) { if (bmds_aio_inflight(VAR_2, sector)) { qemu_aio_flush(); } if (bdrv_get_dirty(VAR_2->bs, sector)) { if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) { VAR_4 = total_sectors - sector; } else { VAR_4 = BDRV_SECTORS_PER_DIRTY_CHUNK; } blk = g_malloc(sizeof(BlkMigBlock)); blk->buf = g_malloc(BLOCK_SIZE); blk->VAR_2 = VAR_2; blk->sector = sector; blk->VAR_4 = VAR_4; if (VAR_3) { blk->iov.iov_base = blk->buf; blk->iov.iov_len = VAR_4 * BDRV_SECTOR_SIZE; qemu_iovec_init_external(&blk->qiov, &blk->iov, 1); if (block_mig_state.submitted == 0) { block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock); } blk->aiocb = bdrv_aio_readv(VAR_2->bs, sector, &blk->qiov, VAR_4, blk_mig_read_cb, blk); if (!blk->aiocb) { goto error; } block_mig_state.submitted++; bmds_set_aio_inflight(VAR_2, sector, VAR_4, 1); } else { VAR_5 = bdrv_read(VAR_2->bs, sector, blk->buf, VAR_4); if (VAR_5 < 0) { goto error; } blk_send(VAR_1, blk); g_free(blk->buf); g_free(blk); } bdrv_reset_dirty(VAR_2->bs, sector, VAR_4); break; } sector += BDRV_SECTORS_PER_DIRTY_CHUNK; VAR_2->cur_dirty = sector; } return (VAR_2->cur_dirty >= VAR_2->total_sectors); error: monitor_printf(VAR_0, "Error reading sector %" PRId64 "\n", sector); qemu_file_set_error(VAR_1, VAR_5); g_free(blk->buf); g_free(blk); return 0; }
[ "static int FUNC_0(Monitor *VAR_0, QEMUFile *VAR_1,\nBlkMigDevState *VAR_2, int VAR_3)\n{", "BlkMigBlock *blk;", "int64_t total_sectors = VAR_2->total_sectors;", "int64_t sector;", "int VAR_4;", "int VAR_5 = -EIO;", "for (sector = VAR_2->cur_dirty; sector < VAR_2->total_sectors;) {", "if (bmds_aio_inflight(VAR_2, sector)) {", "qemu_aio_flush();", "}", "if (bdrv_get_dirty(VAR_2->bs, sector)) {", "if (total_sectors - sector < BDRV_SECTORS_PER_DIRTY_CHUNK) {", "VAR_4 = total_sectors - sector;", "} else {", "VAR_4 = BDRV_SECTORS_PER_DIRTY_CHUNK;", "}", "blk = g_malloc(sizeof(BlkMigBlock));", "blk->buf = g_malloc(BLOCK_SIZE);", "blk->VAR_2 = VAR_2;", "blk->sector = sector;", "blk->VAR_4 = VAR_4;", "if (VAR_3) {", "blk->iov.iov_base = blk->buf;", "blk->iov.iov_len = VAR_4 * BDRV_SECTOR_SIZE;", "qemu_iovec_init_external(&blk->qiov, &blk->iov, 1);", "if (block_mig_state.submitted == 0) {", "block_mig_state.prev_time_offset = qemu_get_clock_ns(rt_clock);", "}", "blk->aiocb = bdrv_aio_readv(VAR_2->bs, sector, &blk->qiov,\nVAR_4, blk_mig_read_cb, blk);", "if (!blk->aiocb) {", "goto error;", "}", "block_mig_state.submitted++;", "bmds_set_aio_inflight(VAR_2, sector, VAR_4, 1);", "} else {", "VAR_5 = bdrv_read(VAR_2->bs, sector, blk->buf, VAR_4);", "if (VAR_5 < 0) {", "goto error;", "}", "blk_send(VAR_1, blk);", "g_free(blk->buf);", "g_free(blk);", "}", "bdrv_reset_dirty(VAR_2->bs, sector, VAR_4);", "break;", "}", "sector += BDRV_SECTORS_PER_DIRTY_CHUNK;", "VAR_2->cur_dirty = sector;", "}", "return (VAR_2->cur_dirty >= VAR_2->total_sectors);", "error:\nmonitor_printf(VAR_0, \"Error reading sector %\" PRId64 \"\\n\", sector);", "qemu_file_set_error(VAR_1, VAR_5);", "g_free(blk->buf);", "g_free(blk);", "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 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47 ], [ 49 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 71, 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 95 ], [ 99 ], [ 101 ], [ 103 ], [ 107 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 121 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 137 ] ]
6,067
static void pm_reset(void *opaque) { ICH9LPCPMRegs *pm = opaque; ich9_pm_iospace_update(pm, 0); acpi_pm1_evt_reset(&pm->acpi_regs); acpi_pm1_cnt_reset(&pm->acpi_regs); acpi_pm_tmr_reset(&pm->acpi_regs); acpi_gpe_reset(&pm->acpi_regs); if (kvm_enabled()) { /* Mark SMM as already inited to prevent SMM from running. KVM does not * support SMM mode. */ pm->smi_en |= ICH9_PMIO_SMI_EN_APMC_EN; } pm->smi_en_wmask = ~0; acpi_update_sci(&pm->acpi_regs, pm->irq); }
false
qemu
fba72476c6b7be60ac74c5bcdc06c61242d1fe4f
static void pm_reset(void *opaque) { ICH9LPCPMRegs *pm = opaque; ich9_pm_iospace_update(pm, 0); acpi_pm1_evt_reset(&pm->acpi_regs); acpi_pm1_cnt_reset(&pm->acpi_regs); acpi_pm_tmr_reset(&pm->acpi_regs); acpi_gpe_reset(&pm->acpi_regs); if (kvm_enabled()) { pm->smi_en |= ICH9_PMIO_SMI_EN_APMC_EN; } pm->smi_en_wmask = ~0; acpi_update_sci(&pm->acpi_regs, pm->irq); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { ICH9LPCPMRegs *pm = VAR_0; ich9_pm_iospace_update(pm, 0); acpi_pm1_evt_reset(&pm->acpi_regs); acpi_pm1_cnt_reset(&pm->acpi_regs); acpi_pm_tmr_reset(&pm->acpi_regs); acpi_gpe_reset(&pm->acpi_regs); if (kvm_enabled()) { pm->smi_en |= ICH9_PMIO_SMI_EN_APMC_EN; } pm->smi_en_wmask = ~0; acpi_update_sci(&pm->acpi_regs, pm->irq); }
[ "static void FUNC_0(void *VAR_0)\n{", "ICH9LPCPMRegs *pm = VAR_0;", "ich9_pm_iospace_update(pm, 0);", "acpi_pm1_evt_reset(&pm->acpi_regs);", "acpi_pm1_cnt_reset(&pm->acpi_regs);", "acpi_pm_tmr_reset(&pm->acpi_regs);", "acpi_gpe_reset(&pm->acpi_regs);", "if (kvm_enabled()) {", "pm->smi_en |= ICH9_PMIO_SMI_EN_APMC_EN;", "}", "pm->smi_en_wmask = ~0;", "acpi_update_sci(&pm->acpi_regs, pm->irq);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 27 ], [ 29 ], [ 31 ], [ 35 ], [ 37 ] ]
6,068
int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { bool enabled; int ret; enabled = bs->io_limits_enabled; bs->io_limits_enabled = false; ret = bdrv_read(bs, sector_num, buf, nb_sectors); bs->io_limits_enabled = enabled; return ret; }
false
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
int bdrv_read_unthrottled(BlockDriverState *bs, int64_t sector_num, uint8_t *buf, int nb_sectors) { bool enabled; int ret; enabled = bs->io_limits_enabled; bs->io_limits_enabled = false; ret = bdrv_read(bs, sector_num, buf, nb_sectors); bs->io_limits_enabled = enabled; return ret; }
{ "code": [], "line_no": [] }
int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1, uint8_t *VAR_2, int VAR_3) { bool enabled; int VAR_4; enabled = VAR_0->io_limits_enabled; VAR_0->io_limits_enabled = false; VAR_4 = bdrv_read(VAR_0, VAR_1, VAR_2, VAR_3); VAR_0->io_limits_enabled = enabled; return VAR_4; }
[ "int FUNC_0(BlockDriverState *VAR_0, int64_t VAR_1,\nuint8_t *VAR_2, int VAR_3)\n{", "bool enabled;", "int VAR_4;", "enabled = VAR_0->io_limits_enabled;", "VAR_0->io_limits_enabled = false;", "VAR_4 = bdrv_read(VAR_0, VAR_1, VAR_2, VAR_3);", "VAR_0->io_limits_enabled = enabled;", "return VAR_4;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3, 5 ], [ 7 ], [ 9 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ] ]
6,070
static void bdrv_aio_bh_cb(void *opaque) { BlockAIOCBSync *acb = opaque; if (!acb->is_write && acb->ret >= 0) { qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); } qemu_vfree(acb->bounce); acb->common.cb(acb->common.opaque, acb->ret); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_unref(acb); }
false
qemu
61007b316cd71ee7333ff7a0a749a8949527575f
static void bdrv_aio_bh_cb(void *opaque) { BlockAIOCBSync *acb = opaque; if (!acb->is_write && acb->ret >= 0) { qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); } qemu_vfree(acb->bounce); acb->common.cb(acb->common.opaque, acb->ret); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_unref(acb); }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0) { BlockAIOCBSync *acb = VAR_0; if (!acb->is_write && acb->ret >= 0) { qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size); } qemu_vfree(acb->bounce); acb->common.cb(acb->common.VAR_0, acb->ret); qemu_bh_delete(acb->bh); acb->bh = NULL; qemu_aio_unref(acb); }
[ "static void FUNC_0(void *VAR_0)\n{", "BlockAIOCBSync *acb = VAR_0;", "if (!acb->is_write && acb->ret >= 0) {", "qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);", "}", "qemu_vfree(acb->bounce);", "acb->common.cb(acb->common.VAR_0, acb->ret);", "qemu_bh_delete(acb->bh);", "acb->bh = NULL;", "qemu_aio_unref(acb);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ] ]
6,071
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret,i; AVFrame *pict = data; float new_aspect; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); #endif #ifdef DEBUG printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif s->flags= avctx->flags; *data_size = 0; /* no supplementary picture */ if (buf_size == 0) { return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int next; ParseContext *pc= &s->parse_context; pc->last_index= pc->index; if(s->codec_id==CODEC_ID_MPEG4){ next= mpeg4_find_frame_end(s, buf, buf_size); }else{ fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); return -1; } if(next==-1){ if(buf_size + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= buf_size + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, buf_size); pc->index += buf_size; return buf_size; } if(pc->index){ if(next + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= next + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; buf= pc->buffer; buf_size= pc->last_index + next; } } retry: if(s->bitstream_buffer_size && buf_size<20){ //divx 5.01+ frame reorder init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); }else init_get_bits(&s->gb, buf, buf_size); s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix return -1; } /* let's go :-) */ if (s->msmpeg4_version==5) { ret= ff_wmv2_decode_picture_header(s); } else if (s->msmpeg4_version) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->avctx->extradata_size && s->picture_number==0){ GetBitContext gb; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size); ret = ff_mpeg4_decode_picture_header(s, &gb); } ret = ff_mpeg4_decode_picture_header(s, &s->gb); if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; } else if (s->h263_intel) { ret = intel_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } avctx->has_b_frames= !s->low_delay; if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->padding_bug_score > -2 && !s->data_partitioning) s->workaround_bugs |= FF_BUG_NO_PADDING; else s->workaround_bugs &= ~FF_BUG_NO_PADDING; if(s->avctx->fourcc == ff_get_fourcc("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; #if 0 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) s->workaround_bugs|= FF_BUG_AC_VLC; if(s->avctx->fourcc == ff_get_fourcc("M4S2")) s->workaround_bugs|= FF_BUG_AC_VLC; #endif if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; s->workaround_bugs|= FF_BUG_AC_VLC; } if(s->divx_version){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA; } if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=3) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if(s->lavc_build && s->lavc_build<4653) s->workaround_bugs|= FF_BUG_STD_QPEL; //printf("padding_bug_score: %d\n", s->padding_bug_score); #if 0 if(s->divx_version==500) s->workaround_bugs|= FF_BUG_NO_PADDING; /* very ugly XVID padding bug detection FIXME/XXX solve this differently * lets hope this at least works */ if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) s->workaround_bugs|= FF_BUG_NO_PADDING; if(s->lavc_build && s->lavc_build<4609) //FIXME not sure about the version num but a 4609 file seems ok s->workaround_bugs|= FF_BUG_NO_PADDING; #endif } if(s->workaround_bugs& FF_BUG_STD_QPEL){ SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } #if 0 // dump bits per frame / qp / complexity { static FILE *f=NULL; if(!f) f=fopen("rate_qp_cplx.txt", "w"); fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale); } #endif /* After H263 & mpeg4 header decode we have the height, width,*/ /* and other parameters. So then we could init the picture */ /* FIXME: By the way H263 decoder is evolving it should have */ /* an H263EncContext */ if(s->aspected_height) new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height); else new_aspect=0; if ( s->width != avctx->width || s->height != avctx->height || ABS(new_aspect - avctx->aspect_ratio) > 0.001) { /* H.263 could change picture size any time */ MPV_common_end(s); s->context_initialized=0; } if (!s->context_initialized) { avctx->width = s->width; avctx->height = s->height; avctx->aspect_ratio= new_aspect; goto retry; } if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)) s->gob_index = ff_h263_get_gob_height(s); if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size); /* skip if the header was thrashed */ if (ret < 0){ fprintf(stderr, "header damaged\n"); return -1; } // for hurry_up==5 s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; /* skip b frames if we dont have reference frames */ if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); /* skip b frames if we are in a hurry */ if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); /* skip everything if we are in a hurry>=5 */ if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) return -1; #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif if(s->error_resilience) memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8)); /* decode each macroblock */ s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; s->mb_x=0; s->mb_y=0; decode_slice(s); s->error_status_table[0]|= VP_START; while(s->mb_y<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){ if(s->msmpeg4_version){ if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0) break; }else{ if(ff_h263_resync(s)<0) break; } if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); decode_slice(s); s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) if(msmpeg4_decode_ext_header(s, buf_size) < 0){ s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; } /* divx 5.01+ bistream reorder stuff */ if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ int current_pos= get_bits_count(&s->gb)>>3; if( buf_size - current_pos > 5 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ int i; int startcode_found=0; for(i=current_pos; i<buf_size-3; i++){ if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ startcode_found=1; break; } } if(startcode_found){ memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size= buf_size - current_pos; } } } if(s->error_resilience){ int error=0, num_end_markers=0; for(i=0; i<s->mb_num; i++){ int status= s->error_status_table[i]; #if 0 if(i%s->mb_width == 0) printf("\n"); printf("%2X ", status); #endif if(status==0) continue; if(status&(DC_ERROR|AC_ERROR|MV_ERROR)) error=1; if(status&VP_START){ if(num_end_markers) error=1; num_end_markers=3; } if(status&AC_END) num_end_markers--; if(status&DC_END) num_end_markers--; if(status&MV_END) num_end_markers--; } if(num_end_markers || error){ fprintf(stderr, "concealing errors\n"); ff_error_resilience(s); } } MPV_frame_end(s); if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture.data[0]){ const int shift= 1 + s->quarter_sample; int mb_y; uint8_t *ptr= s->last_picture.data[0]; s->low_delay=0; //needed to see the vectors without trashing the buffers for(mb_y=0; mb_y<s->mb_height; mb_y++){ int mb_x; for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_index= mb_x + mb_y*s->mb_width; if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){ int i; for(i=0; i<4; i++){ int sx= mb_x*16 + 4 + 8*(i&1); int sy= mb_y*16 + 4 + 8*(i>>1); int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } }else{ int sx= mb_x*16 + 8; int sy= mb_y*16 + 8; int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } s->mbskip_table[mb_index]=0; } } } if(s->pict_type==B_TYPE || s->low_delay){ *pict= *(AVFrame*)&s->current_picture; } else { *pict= *(AVFrame*)&s->last_picture; } if(avctx->debug&FF_DEBUG_QP){ int8_t *qtab= pict->qscale_table; int x,y; for(y=0; y<s->mb_height; y++){ for(x=0; x<s->mb_width; x++){ printf("%2d ", qtab[x + y*s->mb_width]); } printf("\n"); } printf("\n"); } /* Return the Picture timestamp as the frame number */ /* we substract 1 because it is added on utils.c */ avctx->frame_number = s->picture_number - 1; /* dont output the last pic after seeking */ if(s->last_picture.data[0] || s->low_delay) *data_size = sizeof(AVFrame); #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif return get_consumed_bytes(s, buf_size); }
false
FFmpeg
68f593b48433842f3407586679fe07f3e5199ab9
int ff_h263_decode_frame(AVCodecContext *avctx, void *data, int *data_size, UINT8 *buf, int buf_size) { MpegEncContext *s = avctx->priv_data; int ret,i; AVFrame *pict = data; float new_aspect; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); #endif #ifdef DEBUG printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif s->flags= avctx->flags; *data_size = 0; if (buf_size == 0) { return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int next; ParseContext *pc= &s->parse_context; pc->last_index= pc->index; if(s->codec_id==CODEC_ID_MPEG4){ next= mpeg4_find_frame_end(s, buf, buf_size); }else{ fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); return -1; } if(next==-1){ if(buf_size + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= buf_size + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, buf_size); pc->index += buf_size; return buf_size; } if(pc->index){ if(next + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= next + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], buf, next + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; buf= pc->buffer; buf_size= pc->last_index + next; } } retry: if(s->bitstream_buffer_size && buf_size<20){ init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); }else init_get_bits(&s->gb, buf, buf_size); s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) return -1; } if (s->msmpeg4_version==5) { ret= ff_wmv2_decode_picture_header(s); } else if (s->msmpeg4_version) { ret = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->avctx->extradata_size && s->picture_number==0){ GetBitContext gb; init_get_bits(&gb, s->avctx->extradata, s->avctx->extradata_size); ret = ff_mpeg4_decode_picture_header(s, &gb); } ret = ff_mpeg4_decode_picture_header(s, &s->gb); if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; } else if (s->h263_intel) { ret = intel_h263_decode_picture_header(s); } else { ret = h263_decode_picture_header(s); } avctx->has_b_frames= !s->low_delay; if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->padding_bug_score > -2 && !s->data_partitioning) s->workaround_bugs |= FF_BUG_NO_PADDING; else s->workaround_bugs &= ~FF_BUG_NO_PADDING; if(s->avctx->fourcc == ff_get_fourcc("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; #if 0 if(s->avctx->fourcc == ff_get_fourcc("MP4S")) s->workaround_bugs|= FF_BUG_AC_VLC; if(s->avctx->fourcc == ff_get_fourcc("M4S2")) s->workaround_bugs|= FF_BUG_AC_VLC; #endif if(s->avctx->fourcc == ff_get_fourcc("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; s->workaround_bugs|= FF_BUG_AC_VLC; } if(s->divx_version){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA; } if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; if(s->avctx->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=3) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if(s->lavc_build && s->lavc_build<4653) s->workaround_bugs|= FF_BUG_STD_QPEL; #if 0 if(s->divx_version==500) s->workaround_bugs|= FF_BUG_NO_PADDING; if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) s->workaround_bugs|= FF_BUG_NO_PADDING; if(s->lavc_build && s->lavc_build<4609) s->workaround_bugs|= FF_BUG_NO_PADDING; #endif } if(s->workaround_bugs& FF_BUG_STD_QPEL){ SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } #if 0 { static FILE *f=NULL; if(!f) f=fopen("rate_qp_cplx.txt", "w"); fprintf(f, "%d %d %f\n", buf_size, s->qscale, buf_size*(double)s->qscale); } #endif if(s->aspected_height) new_aspect= s->aspected_width*s->width / (float)(s->height*s->aspected_height); else new_aspect=0; if ( s->width != avctx->width || s->height != avctx->height || ABS(new_aspect - avctx->aspect_ratio) > 0.001) { MPV_common_end(s); s->context_initialized=0; } if (!s->context_initialized) { avctx->width = s->width; avctx->height = s->height; avctx->aspect_ratio= new_aspect; goto retry; } if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)) s->gob_index = ff_h263_get_gob_height(s); if(ret==FRAME_SKIPED) return get_consumed_bytes(s, buf_size); if (ret < 0){ fprintf(stderr, "header damaged\n"); return -1; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; if(s->last_picture.data[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); if(avctx->hurry_up>=5) return get_consumed_bytes(s, buf_size); if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, avctx) < 0) return -1; #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif if(s->error_resilience) memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8)); s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; s->mb_x=0; s->mb_y=0; decode_slice(s); s->error_status_table[0]|= VP_START; while(s->mb_y<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){ if(s->msmpeg4_version){ if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0) break; }else{ if(ff_h263_resync(s)<0) break; } if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); decode_slice(s); s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) if(msmpeg4_decode_ext_header(s, buf_size) < 0){ s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; } if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ int current_pos= get_bits_count(&s->gb)>>3; if( buf_size - current_pos > 5 && buf_size - current_pos < BITSTREAM_BUFFER_SIZE){ int i; int startcode_found=0; for(i=current_pos; i<buf_size-3; i++){ if(buf[i]==0 && buf[i+1]==0 && buf[i+2]==1 && buf[i+3]==0xB6){ startcode_found=1; break; } } if(startcode_found){ memcpy(s->bitstream_buffer, buf + current_pos, buf_size - current_pos); s->bitstream_buffer_size= buf_size - current_pos; } } } if(s->error_resilience){ int error=0, num_end_markers=0; for(i=0; i<s->mb_num; i++){ int status= s->error_status_table[i]; #if 0 if(i%s->mb_width == 0) printf("\n"); printf("%2X ", status); #endif if(status==0) continue; if(status&(DC_ERROR|AC_ERROR|MV_ERROR)) error=1; if(status&VP_START){ if(num_end_markers) error=1; num_end_markers=3; } if(status&AC_END) num_end_markers--; if(status&DC_END) num_end_markers--; if(status&MV_END) num_end_markers--; } if(num_end_markers || error){ fprintf(stderr, "concealing errors\n"); ff_error_resilience(s); } } MPV_frame_end(s); if((avctx->debug&FF_DEBUG_VIS_MV) && s->last_picture.data[0]){ const int shift= 1 + s->quarter_sample; int mb_y; uint8_t *ptr= s->last_picture.data[0]; s->low_delay=0; for(mb_y=0; mb_y<s->mb_height; mb_y++){ int mb_x; for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_index= mb_x + mb_y*s->mb_width; if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){ int i; for(i=0; i<4; i++){ int sx= mb_x*16 + 4 + 8*(i&1); int sy= mb_y*16 + 4 + 8*(i>>1); int xy= 1 + mb_x*2 + (i&1) + (mb_y*2 + 1 + (i>>1))*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } }else{ int sx= mb_x*16 + 8; int sy= mb_y*16 + 8; int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>shift) + sx; int my= (s->motion_val[xy][1]>>shift) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } s->mbskip_table[mb_index]=0; } } } if(s->pict_type==B_TYPE || s->low_delay){ *pict= *(AVFrame*)&s->current_picture; } else { *pict= *(AVFrame*)&s->last_picture; } if(avctx->debug&FF_DEBUG_QP){ int8_t *qtab= pict->qscale_table; int x,y; for(y=0; y<s->mb_height; y++){ for(x=0; x<s->mb_width; x++){ printf("%2d ", qtab[x + y*s->mb_width]); } printf("\n"); } printf("\n"); } avctx->frame_number = s->picture_number - 1; if(s->last_picture.data[0] || s->low_delay) *data_size = sizeof(AVFrame); #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif return get_consumed_bytes(s, buf_size); }
{ "code": [], "line_no": [] }
int FUNC_0(AVCodecContext *VAR_0, void *VAR_1, int *VAR_2, UINT8 *VAR_3, int VAR_4) { MpegEncContext *s = VAR_0->priv_data; int VAR_5,VAR_10; AVFrame *pict = VAR_1; float VAR_7; #ifdef PRINT_FRAME_TIME uint64_t time= rdtsc(); #endif #ifdef DEBUG printf("*****frame %d size=%d\n", VAR_0->frame_number, VAR_4); printf("bytes=%VAR_15 %VAR_15 %VAR_15 %VAR_15\n", VAR_3[0], VAR_3[1], VAR_3[2], VAR_3[3]); #endif s->flags= VAR_0->flags; *VAR_2 = 0; if (VAR_4 == 0) { return 0; } if(s->flags&CODEC_FLAG_TRUNCATED){ int VAR_8; ParseContext *pc= &s->parse_context; pc->last_index= pc->index; if(s->codec_id==CODEC_ID_MPEG4){ VAR_8= mpeg4_find_frame_end(s, VAR_3, VAR_4); }else{ fprintf(stderr, "this codec doesnt support truncated bitstreams\n"); return -1; } if(VAR_8==-1){ if(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= VAR_4 + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], VAR_3, VAR_4); pc->index += VAR_4; return VAR_4; } if(pc->index){ if(VAR_8 + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){ pc->buffer_size= VAR_8 + pc->index + 10*1024; pc->buffer= realloc(pc->buffer, pc->buffer_size); } memcpy(&pc->buffer[pc->index], VAR_3, VAR_8 + FF_INPUT_BUFFER_PADDING_SIZE ); pc->index = 0; VAR_3= pc->buffer; VAR_4= pc->last_index + VAR_8; } } retry: if(s->bitstream_buffer_size && VAR_4<20){ init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size); }else init_get_bits(&s->gb, VAR_3, VAR_4); s->bitstream_buffer_size=0; if (!s->context_initialized) { if (MPV_common_init(s) < 0) return -1; } if (s->msmpeg4_version==5) { VAR_5= ff_wmv2_decode_picture_header(s); } else if (s->msmpeg4_version) { VAR_5 = msmpeg4_decode_picture_header(s); } else if (s->h263_pred) { if(s->VAR_0->extradata_size && s->picture_number==0){ GetBitContext gb; init_get_bits(&gb, s->VAR_0->extradata, s->VAR_0->extradata_size); VAR_5 = ff_mpeg4_decode_picture_header(s, &gb); } VAR_5 = ff_mpeg4_decode_picture_header(s, &s->gb); if(s->flags& CODEC_FLAG_LOW_DELAY) s->low_delay=1; } else if (s->h263_intel) { VAR_5 = intel_h263_decode_picture_header(s); } else { VAR_5 = h263_decode_picture_header(s); } VAR_0->has_b_frames= !s->low_delay; if(s->workaround_bugs&FF_BUG_AUTODETECT){ if(s->padding_bug_score > -2 && !s->data_partitioning) s->workaround_bugs |= FF_BUG_NO_PADDING; else s->workaround_bugs &= ~FF_BUG_NO_PADDING; if(s->VAR_0->fourcc == ff_get_fourcc("XVIX")) s->workaround_bugs|= FF_BUG_XVID_ILACE; #if 0 if(s->VAR_0->fourcc == ff_get_fourcc("MP4S")) s->workaround_bugs|= FF_BUG_AC_VLC; if(s->VAR_0->fourcc == ff_get_fourcc("M4S2")) s->workaround_bugs|= FF_BUG_AC_VLC; #endif if(s->VAR_0->fourcc == ff_get_fourcc("UMP4")){ s->workaround_bugs|= FF_BUG_UMP4; s->workaround_bugs|= FF_BUG_AC_VLC; } if(s->divx_version){ s->workaround_bugs|= FF_BUG_QPEL_CHROMA; } if(s->VAR_0->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; if(s->VAR_0->fourcc == ff_get_fourcc("XVID") && s->xvid_build==0) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=3) s->padding_bug_score= 256*256*256*64; if(s->xvid_build && s->xvid_build<=1) s->workaround_bugs|= FF_BUG_QPEL_CHROMA; #define SET_QPEL_FUNC(postfix1, postfix2) \ s->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\ s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\ s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2; if(s->lavc_build && s->lavc_build<4653) s->workaround_bugs|= FF_BUG_STD_QPEL; #if 0 if(s->divx_version==500) s->workaround_bugs|= FF_BUG_NO_PADDING; if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0 && s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0) s->workaround_bugs|= FF_BUG_NO_PADDING; if(s->lavc_build && s->lavc_build<4609) s->workaround_bugs|= FF_BUG_NO_PADDING; #endif } if(s->workaround_bugs& FF_BUG_STD_QPEL){ SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c) SET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c) } #if 0 { static FILE *f=NULL; if(!f) f=fopen("rate_qp_cplx.txt", "w"); fprintf(f, "%d %d %f\n", VAR_4, s->qscale, VAR_4*(double)s->qscale); } #endif if(s->aspected_height) VAR_7= s->aspected_width*s->width / (float)(s->height*s->aspected_height); else VAR_7=0; if ( s->width != VAR_0->width || s->height != VAR_0->height || ABS(VAR_7 - VAR_0->aspect_ratio) > 0.001) { MPV_common_end(s); s->context_initialized=0; } if (!s->context_initialized) { VAR_0->width = s->width; VAR_0->height = s->height; VAR_0->aspect_ratio= VAR_7; goto retry; } if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P)) s->gob_index = ff_h263_get_gob_height(s); if(VAR_5==FRAME_SKIPED) return get_consumed_bytes(s, VAR_4); if (VAR_5 < 0){ fprintf(stderr, "header damaged\n"); return -1; } s->current_picture.pict_type= s->pict_type; s->current_picture.key_frame= s->pict_type == I_TYPE; if(s->last_picture.VAR_1[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, VAR_4); if(VAR_0->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, VAR_4); if(VAR_0->hurry_up>=5) return get_consumed_bytes(s, VAR_4); if(s->next_p_frame_damaged){ if(s->pict_type==B_TYPE) return get_consumed_bytes(s, VAR_4); else s->next_p_frame_damaged=0; } if(MPV_frame_start(s, VAR_0) < 0) return -1; #ifdef DEBUG printf("qscale=%d\n", s->qscale); #endif if(s->error_resilience) memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8)); s->block_wrap[0]= s->block_wrap[1]= s->block_wrap[2]= s->block_wrap[3]= s->mb_width*2 + 2; s->block_wrap[4]= s->block_wrap[5]= s->mb_width + 2; s->mb_x=0; s->VAR_14=0; decode_slice(s); s->error_status_table[0]|= VP_START; while(s->VAR_14<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){ if(s->msmpeg4_version){ if(s->mb_x!=0 || (s->VAR_14%s->slice_height)!=0) break; }else{ if(ff_h263_resync(s)<0) break; } if(s->msmpeg4_version<4 && s->h263_pred) ff_mpeg4_clean_buffers(s); decode_slice(s); s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; } if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) if(msmpeg4_decode_ext_header(s, VAR_4) < 0){ s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; } if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ int VAR_9= get_bits_count(&s->gb)>>3; if( VAR_4 - VAR_9 > 5 && VAR_4 - VAR_9 < BITSTREAM_BUFFER_SIZE){ int VAR_10; int VAR_10=0; for(VAR_10=VAR_9; VAR_10<VAR_4-3; VAR_10++){ if(VAR_3[VAR_10]==0 && VAR_3[VAR_10+1]==0 && VAR_3[VAR_10+2]==1 && VAR_3[VAR_10+3]==0xB6){ VAR_10=1; break; } } if(VAR_10){ memcpy(s->bitstream_buffer, VAR_3 + VAR_9, VAR_4 - VAR_9); s->bitstream_buffer_size= VAR_4 - VAR_9; } } } if(s->error_resilience){ int VAR_11=0, VAR_12=0; for(VAR_10=0; VAR_10<s->mb_num; VAR_10++){ int status= s->error_status_table[VAR_10]; #if 0 if(VAR_10%s->mb_width == 0) printf("\n"); printf("%2X ", status); #endif if(status==0) continue; if(status&(DC_ERROR|AC_ERROR|MV_ERROR)) VAR_11=1; if(status&VP_START){ if(VAR_12) VAR_11=1; VAR_12=3; } if(status&AC_END) VAR_12--; if(status&DC_END) VAR_12--; if(status&MV_END) VAR_12--; } if(VAR_12 || VAR_11){ fprintf(stderr, "concealing errors\n"); ff_error_resilience(s); } } MPV_frame_end(s); if((VAR_0->debug&FF_DEBUG_VIS_MV) && s->last_picture.VAR_1[0]){ const int VAR_13= 1 + s->quarter_sample; int VAR_14; uint8_t *ptr= s->last_picture.VAR_1[0]; s->low_delay=0; for(VAR_14=0; VAR_14<s->mb_height; VAR_14++){ int mb_x; for(mb_x=0; mb_x<s->mb_width; mb_x++){ const int mb_index= mb_x + VAR_14*s->mb_width; if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){ int VAR_10; for(VAR_10=0; VAR_10<4; VAR_10++){ int sx= mb_x*16 + 4 + 8*(VAR_10&1); int sy= VAR_14*16 + 4 + 8*(VAR_10>>1); int xy= 1 + mb_x*2 + (VAR_10&1) + (VAR_14*2 + 1 + (VAR_10>>1))*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>VAR_13) + sx; int my= (s->motion_val[xy][1]>>VAR_13) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } }else{ int sx= mb_x*16 + 8; int sy= VAR_14*16 + 8; int xy= 1 + mb_x*2 + (VAR_14*2 + 1)*(s->mb_width*2 + 2); int mx= (s->motion_val[xy][0]>>VAR_13) + sx; int my= (s->motion_val[xy][1]>>VAR_13) + sy; draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); } s->mbskip_table[mb_index]=0; } } } if(s->pict_type==B_TYPE || s->low_delay){ *pict= *(AVFrame*)&s->current_picture; } else { *pict= *(AVFrame*)&s->last_picture; } if(VAR_0->debug&FF_DEBUG_QP){ int8_t *qtab= pict->qscale_table; int VAR_15,VAR_16; for(VAR_16=0; VAR_16<s->mb_height; VAR_16++){ for(VAR_15=0; VAR_15<s->mb_width; VAR_15++){ printf("%2d ", qtab[VAR_15 + VAR_16*s->mb_width]); } printf("\n"); } printf("\n"); } VAR_0->frame_number = s->picture_number - 1; if(s->last_picture.VAR_1[0] || s->low_delay) *VAR_2 = sizeof(AVFrame); #ifdef PRINT_FRAME_TIME printf("%Ld\n", rdtsc()-time); #endif return get_consumed_bytes(s, VAR_4); }
[ "int FUNC_0(AVCodecContext *VAR_0,\nvoid *VAR_1, int *VAR_2,\nUINT8 *VAR_3, int VAR_4)\n{", "MpegEncContext *s = VAR_0->priv_data;", "int VAR_5,VAR_10;", "AVFrame *pict = VAR_1;", "float VAR_7;", "#ifdef PRINT_FRAME_TIME\nuint64_t time= rdtsc();", "#endif\n#ifdef DEBUG\nprintf(\"*****frame %d size=%d\\n\", VAR_0->frame_number, VAR_4);", "printf(\"bytes=%VAR_15 %VAR_15 %VAR_15 %VAR_15\\n\", VAR_3[0], VAR_3[1], VAR_3[2], VAR_3[3]);", "#endif\ns->flags= VAR_0->flags;", "*VAR_2 = 0;", "if (VAR_4 == 0) {", "return 0;", "}", "if(s->flags&CODEC_FLAG_TRUNCATED){", "int VAR_8;", "ParseContext *pc= &s->parse_context;", "pc->last_index= pc->index;", "if(s->codec_id==CODEC_ID_MPEG4){", "VAR_8= mpeg4_find_frame_end(s, VAR_3, VAR_4);", "}else{", "fprintf(stderr, \"this codec doesnt support truncated bitstreams\\n\");", "return -1;", "}", "if(VAR_8==-1){", "if(VAR_4 + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){", "pc->buffer_size= VAR_4 + pc->index + 10*1024;", "pc->buffer= realloc(pc->buffer, pc->buffer_size);", "}", "memcpy(&pc->buffer[pc->index], VAR_3, VAR_4);", "pc->index += VAR_4;", "return VAR_4;", "}", "if(pc->index){", "if(VAR_8 + FF_INPUT_BUFFER_PADDING_SIZE + pc->index > pc->buffer_size){", "pc->buffer_size= VAR_8 + pc->index + 10*1024;", "pc->buffer= realloc(pc->buffer, pc->buffer_size);", "}", "memcpy(&pc->buffer[pc->index], VAR_3, VAR_8 + FF_INPUT_BUFFER_PADDING_SIZE );", "pc->index = 0;", "VAR_3= pc->buffer;", "VAR_4= pc->last_index + VAR_8;", "}", "}", "retry:\nif(s->bitstream_buffer_size && VAR_4<20){", "init_get_bits(&s->gb, s->bitstream_buffer, s->bitstream_buffer_size);", "}else", "init_get_bits(&s->gb, VAR_3, VAR_4);", "s->bitstream_buffer_size=0;", "if (!s->context_initialized) {", "if (MPV_common_init(s) < 0)\nreturn -1;", "}", "if (s->msmpeg4_version==5) {", "VAR_5= ff_wmv2_decode_picture_header(s);", "} else if (s->msmpeg4_version) {", "VAR_5 = msmpeg4_decode_picture_header(s);", "} else if (s->h263_pred) {", "if(s->VAR_0->extradata_size && s->picture_number==0){", "GetBitContext gb;", "init_get_bits(&gb, s->VAR_0->extradata, s->VAR_0->extradata_size);", "VAR_5 = ff_mpeg4_decode_picture_header(s, &gb);", "}", "VAR_5 = ff_mpeg4_decode_picture_header(s, &s->gb);", "if(s->flags& CODEC_FLAG_LOW_DELAY)\ns->low_delay=1;", "} else if (s->h263_intel) {", "VAR_5 = intel_h263_decode_picture_header(s);", "} else {", "VAR_5 = h263_decode_picture_header(s);", "}", "VAR_0->has_b_frames= !s->low_delay;", "if(s->workaround_bugs&FF_BUG_AUTODETECT){", "if(s->padding_bug_score > -2 && !s->data_partitioning)\ns->workaround_bugs |= FF_BUG_NO_PADDING;", "else\ns->workaround_bugs &= ~FF_BUG_NO_PADDING;", "if(s->VAR_0->fourcc == ff_get_fourcc(\"XVIX\"))\ns->workaround_bugs|= FF_BUG_XVID_ILACE;", "#if 0\nif(s->VAR_0->fourcc == ff_get_fourcc(\"MP4S\"))\ns->workaround_bugs|= FF_BUG_AC_VLC;", "if(s->VAR_0->fourcc == ff_get_fourcc(\"M4S2\"))\ns->workaround_bugs|= FF_BUG_AC_VLC;", "#endif\nif(s->VAR_0->fourcc == ff_get_fourcc(\"UMP4\")){", "s->workaround_bugs|= FF_BUG_UMP4;", "s->workaround_bugs|= FF_BUG_AC_VLC;", "}", "if(s->divx_version){", "s->workaround_bugs|= FF_BUG_QPEL_CHROMA;", "}", "if(s->VAR_0->fourcc == ff_get_fourcc(\"XVID\") && s->xvid_build==0)\ns->workaround_bugs|= FF_BUG_QPEL_CHROMA;", "if(s->VAR_0->fourcc == ff_get_fourcc(\"XVID\") && s->xvid_build==0)\ns->padding_bug_score= 256*256*256*64;", "if(s->xvid_build && s->xvid_build<=3)\ns->padding_bug_score= 256*256*256*64;", "if(s->xvid_build && s->xvid_build<=1)\ns->workaround_bugs|= FF_BUG_QPEL_CHROMA;", "#define SET_QPEL_FUNC(postfix1, postfix2) \\\ns->dsp.put_ ## postfix1 = ff_put_ ## postfix2;\\", "s->dsp.put_no_rnd_ ## postfix1 = ff_put_no_rnd_ ## postfix2;\\", "s->dsp.avg_ ## postfix1 = ff_avg_ ## postfix2;", "if(s->lavc_build && s->lavc_build<4653)\ns->workaround_bugs|= FF_BUG_STD_QPEL;", "#if 0\nif(s->divx_version==500)\ns->workaround_bugs|= FF_BUG_NO_PADDING;", "if( s->resync_marker==0 && s->data_partitioning==0 && s->divx_version==0\n&& s->codec_id==CODEC_ID_MPEG4 && s->vo_type==0)\ns->workaround_bugs|= FF_BUG_NO_PADDING;", "if(s->lavc_build && s->lavc_build<4609)\ns->workaround_bugs|= FF_BUG_NO_PADDING;", "#endif\n}", "if(s->workaround_bugs& FF_BUG_STD_QPEL){", "SET_QPEL_FUNC(qpel_pixels_tab[0][ 5], qpel16_mc11_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][ 7], qpel16_mc31_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][ 9], qpel16_mc12_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][11], qpel16_mc32_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][13], qpel16_mc13_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[0][15], qpel16_mc33_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 5], qpel8_mc11_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 7], qpel8_mc31_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][ 9], qpel8_mc12_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][11], qpel8_mc32_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][13], qpel8_mc13_old_c)\nSET_QPEL_FUNC(qpel_pixels_tab[1][15], qpel8_mc33_old_c)\n}", "#if 0\n{", "static FILE *f=NULL;", "if(!f) f=fopen(\"rate_qp_cplx.txt\", \"w\");", "fprintf(f, \"%d %d %f\\n\", VAR_4, s->qscale, VAR_4*(double)s->qscale);", "}", "#endif\nif(s->aspected_height)\nVAR_7= s->aspected_width*s->width / (float)(s->height*s->aspected_height);", "else\nVAR_7=0;", "if ( s->width != VAR_0->width || s->height != VAR_0->height\n|| ABS(VAR_7 - VAR_0->aspect_ratio) > 0.001) {", "MPV_common_end(s);", "s->context_initialized=0;", "}", "if (!s->context_initialized) {", "VAR_0->width = s->width;", "VAR_0->height = s->height;", "VAR_0->aspect_ratio= VAR_7;", "goto retry;", "}", "if((s->codec_id==CODEC_ID_H263 || s->codec_id==CODEC_ID_H263P))\ns->gob_index = ff_h263_get_gob_height(s);", "if(VAR_5==FRAME_SKIPED) return get_consumed_bytes(s, VAR_4);", "if (VAR_5 < 0){", "fprintf(stderr, \"header damaged\\n\");", "return -1;", "}", "s->current_picture.pict_type= s->pict_type;", "s->current_picture.key_frame= s->pict_type == I_TYPE;", "if(s->last_picture.VAR_1[0]==NULL && s->pict_type==B_TYPE) return get_consumed_bytes(s, VAR_4);", "if(VAR_0->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, VAR_4);", "if(VAR_0->hurry_up>=5) return get_consumed_bytes(s, VAR_4);", "if(s->next_p_frame_damaged){", "if(s->pict_type==B_TYPE)\nreturn get_consumed_bytes(s, VAR_4);", "else\ns->next_p_frame_damaged=0;", "}", "if(MPV_frame_start(s, VAR_0) < 0)\nreturn -1;", "#ifdef DEBUG\nprintf(\"qscale=%d\\n\", s->qscale);", "#endif\nif(s->error_resilience)\nmemset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_num*sizeof(UINT8));", "s->block_wrap[0]=\ns->block_wrap[1]=\ns->block_wrap[2]=\ns->block_wrap[3]= s->mb_width*2 + 2;", "s->block_wrap[4]=\ns->block_wrap[5]= s->mb_width + 2;", "s->mb_x=0;", "s->VAR_14=0;", "decode_slice(s);", "s->error_status_table[0]|= VP_START;", "while(s->VAR_14<s->mb_height && s->gb.size*8 - get_bits_count(&s->gb)>16){", "if(s->msmpeg4_version){", "if(s->mb_x!=0 || (s->VAR_14%s->slice_height)!=0)\nbreak;", "}else{", "if(ff_h263_resync(s)<0)\nbreak;", "}", "if(s->msmpeg4_version<4 && s->h263_pred)\nff_mpeg4_clean_buffers(s);", "decode_slice(s);", "s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START;", "}", "if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE)\nif(msmpeg4_decode_ext_header(s, VAR_4) < 0){", "s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR;", "}", "if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){", "int VAR_9= get_bits_count(&s->gb)>>3;", "if( VAR_4 - VAR_9 > 5\n&& VAR_4 - VAR_9 < BITSTREAM_BUFFER_SIZE){", "int VAR_10;", "int VAR_10=0;", "for(VAR_10=VAR_9; VAR_10<VAR_4-3; VAR_10++){", "if(VAR_3[VAR_10]==0 && VAR_3[VAR_10+1]==0 && VAR_3[VAR_10+2]==1 && VAR_3[VAR_10+3]==0xB6){", "VAR_10=1;", "break;", "}", "}", "if(VAR_10){", "memcpy(s->bitstream_buffer, VAR_3 + VAR_9, VAR_4 - VAR_9);", "s->bitstream_buffer_size= VAR_4 - VAR_9;", "}", "}", "}", "if(s->error_resilience){", "int VAR_11=0, VAR_12=0;", "for(VAR_10=0; VAR_10<s->mb_num; VAR_10++){", "int status= s->error_status_table[VAR_10];", "#if 0\nif(VAR_10%s->mb_width == 0) printf(\"\\n\");", "printf(\"%2X \", status);", "#endif\nif(status==0) continue;", "if(status&(DC_ERROR|AC_ERROR|MV_ERROR))\nVAR_11=1;", "if(status&VP_START){", "if(VAR_12)\nVAR_11=1;", "VAR_12=3;", "}", "if(status&AC_END)\nVAR_12--;", "if(status&DC_END)\nVAR_12--;", "if(status&MV_END)\nVAR_12--;", "}", "if(VAR_12 || VAR_11){", "fprintf(stderr, \"concealing errors\\n\");", "ff_error_resilience(s);", "}", "}", "MPV_frame_end(s);", "if((VAR_0->debug&FF_DEBUG_VIS_MV) && s->last_picture.VAR_1[0]){", "const int VAR_13= 1 + s->quarter_sample;", "int VAR_14;", "uint8_t *ptr= s->last_picture.VAR_1[0];", "s->low_delay=0;", "for(VAR_14=0; VAR_14<s->mb_height; VAR_14++){", "int mb_x;", "for(mb_x=0; mb_x<s->mb_width; mb_x++){", "const int mb_index= mb_x + VAR_14*s->mb_width;", "if(s->co_located_type_table[mb_index] == MV_TYPE_8X8){", "int VAR_10;", "for(VAR_10=0; VAR_10<4; VAR_10++){", "int sx= mb_x*16 + 4 + 8*(VAR_10&1);", "int sy= VAR_14*16 + 4 + 8*(VAR_10>>1);", "int xy= 1 + mb_x*2 + (VAR_10&1) + (VAR_14*2 + 1 + (VAR_10>>1))*(s->mb_width*2 + 2);", "int mx= (s->motion_val[xy][0]>>VAR_13) + sx;", "int my= (s->motion_val[xy][1]>>VAR_13) + sy;", "draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);", "}", "}else{", "int sx= mb_x*16 + 8;", "int sy= VAR_14*16 + 8;", "int xy= 1 + mb_x*2 + (VAR_14*2 + 1)*(s->mb_width*2 + 2);", "int mx= (s->motion_val[xy][0]>>VAR_13) + sx;", "int my= (s->motion_val[xy][1]>>VAR_13) + sy;", "draw_line(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100);", "}", "s->mbskip_table[mb_index]=0;", "}", "}", "}", "if(s->pict_type==B_TYPE || s->low_delay){", "*pict= *(AVFrame*)&s->current_picture;", "} else {", "*pict= *(AVFrame*)&s->last_picture;", "}", "if(VAR_0->debug&FF_DEBUG_QP){", "int8_t *qtab= pict->qscale_table;", "int VAR_15,VAR_16;", "for(VAR_16=0; VAR_16<s->mb_height; VAR_16++){", "for(VAR_15=0; VAR_15<s->mb_width; VAR_15++){", "printf(\"%2d \", qtab[VAR_15 + VAR_16*s->mb_width]);", "}", "printf(\"\\n\");", "}", "printf(\"\\n\");", "}", "VAR_0->frame_number = s->picture_number - 1;", "if(s->last_picture.VAR_1[0] || s->low_delay)\n*VAR_2 = sizeof(AVFrame);", "#ifdef PRINT_FRAME_TIME\nprintf(\"%Ld\\n\", rdtsc()-time);", "#endif\nreturn get_consumed_bytes(s, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 27 ], [ 29 ], [ 31, 33 ], [ 37 ], [ 43 ], [ 45 ], [ 47 ], [ 51 ], [ 53 ], [ 55 ], [ 59 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 99 ], [ 101 ], [ 103 ], [ 105 ], [ 109 ], [ 111 ], [ 113 ], [ 115 ], [ 117 ], [ 119 ], [ 123, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 135 ], [ 139 ], [ 141, 143 ], [ 145 ], [ 151 ], [ 153 ], [ 155 ], [ 157 ], [ 159 ], [ 161 ], [ 163 ], [ 167 ], [ 169 ], [ 171 ], [ 173 ], [ 177, 179 ], [ 181 ], [ 183 ], [ 185 ], [ 187 ], [ 189 ], [ 191 ], [ 195 ], [ 197, 199 ], [ 201, 203 ], [ 207, 209 ], [ 211, 213, 215 ], [ 219, 221 ], [ 223, 225 ], [ 227 ], [ 229 ], [ 231 ], [ 235 ], [ 237 ], [ 239 ], [ 243, 245 ], [ 249, 251 ], [ 255, 257 ], [ 261, 263 ], [ 267, 269 ], [ 271 ], [ 273 ], [ 277, 279 ], [ 285, 287, 289 ], [ 299, 301, 303 ], [ 307, 309 ], [ 311, 313 ], [ 317 ], [ 319, 321, 323, 325, 327, 329, 333, 335, 337, 339, 341, 343, 345 ], [ 349, 351 ], [ 353 ], [ 355 ], [ 357 ], [ 359 ], [ 361, 373, 375 ], [ 377, 379 ], [ 383, 385 ], [ 389 ], [ 391 ], [ 393 ], [ 395 ], [ 397 ], [ 399 ], [ 401 ], [ 405 ], [ 407 ], [ 411, 413 ], [ 417 ], [ 421 ], [ 423 ], [ 425 ], [ 427 ], [ 433 ], [ 435 ], [ 441 ], [ 445 ], [ 449 ], [ 453 ], [ 455, 457 ], [ 459, 461 ], [ 463 ], [ 467, 469 ], [ 473, 475 ], [ 477, 481, 483 ], [ 489, 491, 493, 495 ], [ 497, 499 ], [ 501 ], [ 503 ], [ 507 ], [ 509 ], [ 511 ], [ 513 ], [ 515, 517 ], [ 519 ], [ 521, 523 ], [ 525 ], [ 529, 531 ], [ 535 ], [ 539 ], [ 541 ], [ 545, 547 ], [ 549 ], [ 551 ], [ 557 ], [ 559 ], [ 563, 565 ], [ 567 ], [ 569 ], [ 571 ], [ 573 ], [ 575 ], [ 577 ], [ 579 ], [ 581 ], [ 583 ], [ 585 ], [ 587 ], [ 589 ], [ 591 ], [ 593 ], [ 597 ], [ 599 ], [ 601 ], [ 603 ], [ 605, 607 ], [ 609 ], [ 611, 613 ], [ 617, 619 ], [ 621 ], [ 623, 625 ], [ 627 ], [ 629 ], [ 631, 633 ], [ 635, 637 ], [ 639, 641 ], [ 643 ], [ 645 ], [ 647 ], [ 649 ], [ 651 ], [ 653 ], [ 657 ], [ 661 ], [ 663 ], [ 665 ], [ 667 ], [ 669 ], [ 673 ], [ 675 ], [ 677 ], [ 679 ], [ 681 ], [ 683 ], [ 685 ], [ 687 ], [ 689 ], [ 691 ], [ 693 ], [ 695 ], [ 697 ], [ 699 ], [ 701 ], [ 703 ], [ 705 ], [ 707 ], [ 709 ], [ 711 ], [ 713 ], [ 715 ], [ 717 ], [ 719 ], [ 721 ], [ 723 ], [ 729 ], [ 731 ], [ 733 ], [ 735 ], [ 737 ], [ 741 ], [ 743 ], [ 745 ], [ 749 ], [ 751 ], [ 753 ], [ 755 ], [ 757 ], [ 759 ], [ 761 ], [ 763 ], [ 771 ], [ 777, 779 ], [ 781, 783 ], [ 785, 787 ], [ 789 ] ]
6,073
static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data) { struct bdrv_iterate_context context = { mon, 0 }; if (incoming_expected) { qerror_report(QERR_MIGRATION_EXPECTED); return -1; } bdrv_iterate(encrypted_bdrv_it, &context); /* only resume the vm if all keys are set and valid */ if (!context.err) { vm_start(); return 0; } else { return -1; } }
false
qemu
1bcef683bf840a928d633755031ac572d5fdb851
static int do_cont(Monitor *mon, const QDict *qdict, QObject **ret_data) { struct bdrv_iterate_context context = { mon, 0 }; if (incoming_expected) { qerror_report(QERR_MIGRATION_EXPECTED); return -1; } bdrv_iterate(encrypted_bdrv_it, &context); if (!context.err) { vm_start(); return 0; } else { return -1; } }
{ "code": [], "line_no": [] }
static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2) { struct bdrv_iterate_context VAR_3 = { VAR_0, 0 }; if (incoming_expected) { qerror_report(QERR_MIGRATION_EXPECTED); return -1; } bdrv_iterate(encrypted_bdrv_it, &VAR_3); if (!VAR_3.err) { vm_start(); return 0; } else { return -1; } }
[ "static int FUNC_0(Monitor *VAR_0, const QDict *VAR_1, QObject **VAR_2)\n{", "struct bdrv_iterate_context VAR_3 = { VAR_0, 0 };", "if (incoming_expected) {", "qerror_report(QERR_MIGRATION_EXPECTED);", "return -1;", "}", "bdrv_iterate(encrypted_bdrv_it, &VAR_3);", "if (!VAR_3.err) {", "vm_start();", "return 0;", "} else {", "return -1;", "}", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ] ]
6,075
void qmp_x_blockdev_del(bool has_id, const char *id, bool has_node_name, const char *node_name, Error **errp) { AioContext *aio_context; BlockBackend *blk; BlockDriverState *bs; if (has_id && has_node_name) { error_setg(errp, "Only one of id and node-name must be specified"); return; } else if (!has_id && !has_node_name) { error_setg(errp, "No block device specified"); return; } if (has_id) { /* blk_by_name() never returns a BB that is not owned by the monitor */ blk = blk_by_name(id); if (!blk) { error_setg(errp, "Cannot find block backend %s", id); return; } if (blk_legacy_dinfo(blk)) { error_setg(errp, "Deleting block backend added with drive-add" " is not supported"); return; } if (blk_get_refcnt(blk) > 1) { error_setg(errp, "Block backend %s is in use", id); return; } bs = blk_bs(blk); aio_context = blk_get_aio_context(blk); } else { blk = NULL; bs = bdrv_find_node(node_name); if (!bs) { error_setg(errp, "Cannot find node %s", node_name); return; } if (bdrv_has_blk(bs)) { error_setg(errp, "Node %s is in use by %s", node_name, bdrv_get_parent_name(bs)); return; } aio_context = bdrv_get_aio_context(bs); } aio_context_acquire(aio_context); if (bs) { if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, errp)) { goto out; } if (!blk && !bs->monitor_list.tqe_prev) { error_setg(errp, "Node %s is not owned by the monitor", bs->node_name); goto out; } if (bs->refcnt > 1) { error_setg(errp, "Block device %s is in use", bdrv_get_device_or_node_name(bs)); goto out; } } if (blk) { monitor_remove_blk(blk); blk_unref(blk); } else { QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list); bdrv_unref(bs); } out: aio_context_release(aio_context); }
false
qemu
3b8c1761f0e1523622e008836d01a6544b1c21ab
void qmp_x_blockdev_del(bool has_id, const char *id, bool has_node_name, const char *node_name, Error **errp) { AioContext *aio_context; BlockBackend *blk; BlockDriverState *bs; if (has_id && has_node_name) { error_setg(errp, "Only one of id and node-name must be specified"); return; } else if (!has_id && !has_node_name) { error_setg(errp, "No block device specified"); return; } if (has_id) { blk = blk_by_name(id); if (!blk) { error_setg(errp, "Cannot find block backend %s", id); return; } if (blk_legacy_dinfo(blk)) { error_setg(errp, "Deleting block backend added with drive-add" " is not supported"); return; } if (blk_get_refcnt(blk) > 1) { error_setg(errp, "Block backend %s is in use", id); return; } bs = blk_bs(blk); aio_context = blk_get_aio_context(blk); } else { blk = NULL; bs = bdrv_find_node(node_name); if (!bs) { error_setg(errp, "Cannot find node %s", node_name); return; } if (bdrv_has_blk(bs)) { error_setg(errp, "Node %s is in use by %s", node_name, bdrv_get_parent_name(bs)); return; } aio_context = bdrv_get_aio_context(bs); } aio_context_acquire(aio_context); if (bs) { if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, errp)) { goto out; } if (!blk && !bs->monitor_list.tqe_prev) { error_setg(errp, "Node %s is not owned by the monitor", bs->node_name); goto out; } if (bs->refcnt > 1) { error_setg(errp, "Block device %s is in use", bdrv_get_device_or_node_name(bs)); goto out; } } if (blk) { monitor_remove_blk(blk); blk_unref(blk); } else { QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list); bdrv_unref(bs); } out: aio_context_release(aio_context); }
{ "code": [], "line_no": [] }
void FUNC_0(bool VAR_0, const char *VAR_1, bool VAR_2, const char *VAR_3, Error **VAR_4) { AioContext *aio_context; BlockBackend *blk; BlockDriverState *bs; if (VAR_0 && VAR_2) { error_setg(VAR_4, "Only one of VAR_1 and node-name must be specified"); return; } else if (!VAR_0 && !VAR_2) { error_setg(VAR_4, "No block device specified"); return; } if (VAR_0) { blk = blk_by_name(VAR_1); if (!blk) { error_setg(VAR_4, "Cannot find block backend %s", VAR_1); return; } if (blk_legacy_dinfo(blk)) { error_setg(VAR_4, "Deleting block backend added with drive-add" " is not supported"); return; } if (blk_get_refcnt(blk) > 1) { error_setg(VAR_4, "Block backend %s is in use", VAR_1); return; } bs = blk_bs(blk); aio_context = blk_get_aio_context(blk); } else { blk = NULL; bs = bdrv_find_node(VAR_3); if (!bs) { error_setg(VAR_4, "Cannot find node %s", VAR_3); return; } if (bdrv_has_blk(bs)) { error_setg(VAR_4, "Node %s is in use by %s", VAR_3, bdrv_get_parent_name(bs)); return; } aio_context = bdrv_get_aio_context(bs); } aio_context_acquire(aio_context); if (bs) { if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, VAR_4)) { goto out; } if (!blk && !bs->monitor_list.tqe_prev) { error_setg(VAR_4, "Node %s is not owned by the monitor", bs->VAR_3); goto out; } if (bs->refcnt > 1) { error_setg(VAR_4, "Block device %s is in use", bdrv_get_device_or_node_name(bs)); goto out; } } if (blk) { monitor_remove_blk(blk); blk_unref(blk); } else { QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list); bdrv_unref(bs); } out: aio_context_release(aio_context); }
[ "void FUNC_0(bool VAR_0, const char *VAR_1,\nbool VAR_2, const char *VAR_3, Error **VAR_4)\n{", "AioContext *aio_context;", "BlockBackend *blk;", "BlockDriverState *bs;", "if (VAR_0 && VAR_2) {", "error_setg(VAR_4, \"Only one of VAR_1 and node-name must be specified\");", "return;", "} else if (!VAR_0 && !VAR_2) {", "error_setg(VAR_4, \"No block device specified\");", "return;", "}", "if (VAR_0) {", "blk = blk_by_name(VAR_1);", "if (!blk) {", "error_setg(VAR_4, \"Cannot find block backend %s\", VAR_1);", "return;", "}", "if (blk_legacy_dinfo(blk)) {", "error_setg(VAR_4, \"Deleting block backend added with drive-add\"\n\" is not supported\");", "return;", "}", "if (blk_get_refcnt(blk) > 1) {", "error_setg(VAR_4, \"Block backend %s is in use\", VAR_1);", "return;", "}", "bs = blk_bs(blk);", "aio_context = blk_get_aio_context(blk);", "} else {", "blk = NULL;", "bs = bdrv_find_node(VAR_3);", "if (!bs) {", "error_setg(VAR_4, \"Cannot find node %s\", VAR_3);", "return;", "}", "if (bdrv_has_blk(bs)) {", "error_setg(VAR_4, \"Node %s is in use by %s\",\nVAR_3, bdrv_get_parent_name(bs));", "return;", "}", "aio_context = bdrv_get_aio_context(bs);", "}", "aio_context_acquire(aio_context);", "if (bs) {", "if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_DRIVE_DEL, VAR_4)) {", "goto out;", "}", "if (!blk && !bs->monitor_list.tqe_prev) {", "error_setg(VAR_4, \"Node %s is not owned by the monitor\",\nbs->VAR_3);", "goto out;", "}", "if (bs->refcnt > 1) {", "error_setg(VAR_4, \"Block device %s is in use\",\nbdrv_get_device_or_node_name(bs));", "goto out;", "}", "}", "if (blk) {", "monitor_remove_blk(blk);", "blk_unref(blk);", "} else {", "QTAILQ_REMOVE(&monitor_bdrv_states, bs, monitor_list);", "bdrv_unref(bs);", "}", "out:\naio_context_release(aio_context);", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 47, 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ], [ 61 ], [ 63 ], [ 65 ], [ 67 ], [ 69 ], [ 71 ], [ 73 ], [ 75 ], [ 77 ], [ 79 ], [ 81 ], [ 83, 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93 ], [ 97 ], [ 101 ], [ 103 ], [ 105 ], [ 107 ], [ 111 ], [ 113, 115 ], [ 117 ], [ 119 ], [ 123 ], [ 125, 127 ], [ 129 ], [ 131 ], [ 133 ], [ 137 ], [ 139 ], [ 141 ], [ 143 ], [ 145 ], [ 147 ], [ 149 ], [ 153, 155 ], [ 157 ] ]
6,076
static void channel_store_c(struct fs_dma_ctrl *ctrl, int c) { target_phys_addr_t addr = channel_reg(ctrl, c, RW_GROUP_DOWN); /* Encode and store. FIXME: handle endianness. */ D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, c, addr)); D(dump_d(c, &ctrl->channels[c].current_d)); cpu_physical_memory_write (addr, (void *) &ctrl->channels[c].current_c, sizeof ctrl->channels[c].current_c); }
false
qemu
a8170e5e97ad17ca169c64ba87ae2f53850dab4c
static void channel_store_c(struct fs_dma_ctrl *ctrl, int c) { target_phys_addr_t addr = channel_reg(ctrl, c, RW_GROUP_DOWN); D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, c, addr)); D(dump_d(c, &ctrl->channels[c].current_d)); cpu_physical_memory_write (addr, (void *) &ctrl->channels[c].current_c, sizeof ctrl->channels[c].current_c); }
{ "code": [], "line_no": [] }
static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1) { target_phys_addr_t addr = channel_reg(VAR_0, VAR_1, RW_GROUP_DOWN); D(printf("%s ch=%d addr=" TARGET_FMT_plx "\n", __func__, VAR_1, addr)); D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d)); cpu_physical_memory_write (addr, (void *) &VAR_0->channels[VAR_1].current_c, sizeof VAR_0->channels[VAR_1].current_c); }
[ "static void FUNC_0(struct fs_dma_ctrl *VAR_0, int VAR_1)\n{", "target_phys_addr_t addr = channel_reg(VAR_0, VAR_1, RW_GROUP_DOWN);", "D(printf(\"%s ch=%d addr=\" TARGET_FMT_plx \"\\n\", __func__, VAR_1, addr));", "D(dump_d(VAR_1, &VAR_0->channels[VAR_1].current_d));", "cpu_physical_memory_write (addr,\n(void *) &VAR_0->channels[VAR_1].current_c,\nsizeof VAR_0->channels[VAR_1].current_c);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 11 ], [ 13 ], [ 15, 17, 19 ], [ 21 ] ]
6,077
void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) { sd->readonly_cb = readonly; sd->inserted_cb = insert; qemu_set_irq(readonly, sd->bdrv ? bdrv_is_read_only(sd->bdrv) : 0); qemu_set_irq(insert, sd->bdrv ? bdrv_is_inserted(sd->bdrv) : 0); }
false
qemu
4be746345f13e99e468c60acbd3a355e8183e3ce
void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert) { sd->readonly_cb = readonly; sd->inserted_cb = insert; qemu_set_irq(readonly, sd->bdrv ? bdrv_is_read_only(sd->bdrv) : 0); qemu_set_irq(insert, sd->bdrv ? bdrv_is_inserted(sd->bdrv) : 0); }
{ "code": [], "line_no": [] }
void FUNC_0(SDState *VAR_0, qemu_irq VAR_1, qemu_irq VAR_2) { VAR_0->readonly_cb = VAR_1; VAR_0->inserted_cb = VAR_2; qemu_set_irq(VAR_1, VAR_0->bdrv ? bdrv_is_read_only(VAR_0->bdrv) : 0); qemu_set_irq(VAR_2, VAR_0->bdrv ? bdrv_is_inserted(VAR_0->bdrv) : 0); }
[ "void FUNC_0(SDState *VAR_0, qemu_irq VAR_1, qemu_irq VAR_2)\n{", "VAR_0->readonly_cb = VAR_1;", "VAR_0->inserted_cb = VAR_2;", "qemu_set_irq(VAR_1, VAR_0->bdrv ? bdrv_is_read_only(VAR_0->bdrv) : 0);", "qemu_set_irq(VAR_2, VAR_0->bdrv ? bdrv_is_inserted(VAR_0->bdrv) : 0);", "}" ]
[ 0, 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 13 ] ]
6,078
static int ppc_hash32_check_prot(int prot, int rw, int access_type) { int ret; if (access_type == ACCESS_CODE) { if (prot & PAGE_EXEC) { ret = 0; } else { ret = -2; } } else if (rw) { if (prot & PAGE_WRITE) { ret = 0; } else { ret = -2; } } else { if (prot & PAGE_READ) { ret = 0; } else { ret = -2; } } return ret; }
false
qemu
91cda45b69e45a089f9989979a65db3f710c9925
static int ppc_hash32_check_prot(int prot, int rw, int access_type) { int ret; if (access_type == ACCESS_CODE) { if (prot & PAGE_EXEC) { ret = 0; } else { ret = -2; } } else if (rw) { if (prot & PAGE_WRITE) { ret = 0; } else { ret = -2; } } else { if (prot & PAGE_READ) { ret = 0; } else { ret = -2; } } return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(int VAR_0, int VAR_1, int VAR_2) { int VAR_3; if (VAR_2 == ACCESS_CODE) { if (VAR_0 & PAGE_EXEC) { VAR_3 = 0; } else { VAR_3 = -2; } } else if (VAR_1) { if (VAR_0 & PAGE_WRITE) { VAR_3 = 0; } else { VAR_3 = -2; } } else { if (VAR_0 & PAGE_READ) { VAR_3 = 0; } else { VAR_3 = -2; } } return VAR_3; }
[ "static int FUNC_0(int VAR_0, int VAR_1, int VAR_2)\n{", "int VAR_3;", "if (VAR_2 == ACCESS_CODE) {", "if (VAR_0 & PAGE_EXEC) {", "VAR_3 = 0;", "} else {", "VAR_3 = -2;", "}", "} else if (VAR_1) {", "if (VAR_0 & PAGE_WRITE) {", "VAR_3 = 0;", "} else {", "VAR_3 = -2;", "}", "} else {", "if (VAR_0 & PAGE_READ) {", "VAR_3 = 0;", "} else {", "VAR_3 = -2;", "}", "}", "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 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 11 ], [ 13 ], [ 15 ], [ 17 ], [ 19 ], [ 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29 ], [ 31 ], [ 33 ], [ 35 ], [ 37 ], [ 39 ], [ 41 ], [ 43 ], [ 45 ], [ 49 ], [ 51 ] ]
6,079
static void spr_write_40x_dbcr0 (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_40x_dbcr0(); /* We must stop translation as we may have rebooted */ RET_STOP(ctx); }
false
qemu
e1833e1f96456fd8fc17463246fe0b2050e68efb
static void spr_write_40x_dbcr0 (void *opaque, int sprn) { DisasContext *ctx = opaque; gen_op_store_40x_dbcr0(); RET_STOP(ctx); }
{ "code": [], "line_no": [] }
static void FUNC_0 (void *VAR_0, int VAR_1) { DisasContext *ctx = VAR_0; gen_op_store_40x_dbcr0(); RET_STOP(ctx); }
[ "static void FUNC_0 (void *VAR_0, int VAR_1)\n{", "DisasContext *ctx = VAR_0;", "gen_op_store_40x_dbcr0();", "RET_STOP(ctx);", "}" ]
[ 0, 0, 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 9 ], [ 13 ], [ 15 ] ]
6,080
static void eth_receive(void *opaque, const uint8_t *buf, size_t size) { mv88w8618_eth_state *s = opaque; uint32_t desc_addr; mv88w8618_rx_desc desc; int i; for (i = 0; i < 4; i++) { desc_addr = s->cur_rx[i]; if (!desc_addr) continue; do { eth_rx_desc_get(desc_addr, &desc); if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { cpu_physical_memory_write(desc.buffer + s->vlan_header, buf, size); desc.bytes = size + s->vlan_header; desc.cmdstat &= ~MP_ETH_RX_OWN; s->cur_rx[i] = desc.next; s->icr |= MP_ETH_IRQ_RX; if (s->icr & s->imr) qemu_irq_raise(s->irq); eth_rx_desc_put(desc_addr, &desc); return; } desc_addr = desc.next; } while (desc_addr != s->rx_queue[i]); } }
false
qemu
e3f5ec2b5e92706e3b807059f79b1fb5d936e567
static void eth_receive(void *opaque, const uint8_t *buf, size_t size) { mv88w8618_eth_state *s = opaque; uint32_t desc_addr; mv88w8618_rx_desc desc; int i; for (i = 0; i < 4; i++) { desc_addr = s->cur_rx[i]; if (!desc_addr) continue; do { eth_rx_desc_get(desc_addr, &desc); if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= size) { cpu_physical_memory_write(desc.buffer + s->vlan_header, buf, size); desc.bytes = size + s->vlan_header; desc.cmdstat &= ~MP_ETH_RX_OWN; s->cur_rx[i] = desc.next; s->icr |= MP_ETH_IRQ_RX; if (s->icr & s->imr) qemu_irq_raise(s->irq); eth_rx_desc_put(desc_addr, &desc); return; } desc_addr = desc.next; } while (desc_addr != s->rx_queue[i]); } }
{ "code": [], "line_no": [] }
static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2) { mv88w8618_eth_state *s = VAR_0; uint32_t desc_addr; mv88w8618_rx_desc desc; int VAR_3; for (VAR_3 = 0; VAR_3 < 4; VAR_3++) { desc_addr = s->cur_rx[VAR_3]; if (!desc_addr) continue; do { eth_rx_desc_get(desc_addr, &desc); if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= VAR_2) { cpu_physical_memory_write(desc.buffer + s->vlan_header, VAR_1, VAR_2); desc.bytes = VAR_2 + s->vlan_header; desc.cmdstat &= ~MP_ETH_RX_OWN; s->cur_rx[VAR_3] = desc.next; s->icr |= MP_ETH_IRQ_RX; if (s->icr & s->imr) qemu_irq_raise(s->irq); eth_rx_desc_put(desc_addr, &desc); return; } desc_addr = desc.next; } while (desc_addr != s->rx_queue[VAR_3]); } }
[ "static void FUNC_0(void *VAR_0, const uint8_t *VAR_1, size_t VAR_2)\n{", "mv88w8618_eth_state *s = VAR_0;", "uint32_t desc_addr;", "mv88w8618_rx_desc desc;", "int VAR_3;", "for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {", "desc_addr = s->cur_rx[VAR_3];", "if (!desc_addr)\ncontinue;", "do {", "eth_rx_desc_get(desc_addr, &desc);", "if ((desc.cmdstat & MP_ETH_RX_OWN) && desc.buffer_size >= VAR_2) {", "cpu_physical_memory_write(desc.buffer + s->vlan_header,\nVAR_1, VAR_2);", "desc.bytes = VAR_2 + s->vlan_header;", "desc.cmdstat &= ~MP_ETH_RX_OWN;", "s->cur_rx[VAR_3] = desc.next;", "s->icr |= MP_ETH_IRQ_RX;", "if (s->icr & s->imr)\nqemu_irq_raise(s->irq);", "eth_rx_desc_put(desc_addr, &desc);", "return;", "}", "desc_addr = desc.next;", "} while (desc_addr != s->rx_queue[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 ]
[ [ 1, 3 ], [ 5 ], [ 7 ], [ 9 ], [ 11 ], [ 15 ], [ 17 ], [ 19, 21 ], [ 23 ], [ 25 ], [ 27 ], [ 29, 31 ], [ 33 ], [ 35 ], [ 37 ], [ 41 ], [ 43, 45 ], [ 47 ], [ 49 ], [ 51 ], [ 53 ], [ 55 ], [ 57 ], [ 59 ] ]
6,081
static bool version_is_5(void *opaque, int version_id) { return version_id == 5; }
false
qemu
08b277ac46da8b02e50cec455eca7cb2d12ffcf0
static bool version_is_5(void *opaque, int version_id) { return version_id == 5; }
{ "code": [], "line_no": [] }
static bool FUNC_0(void *opaque, int version_id) { return version_id == 5; }
[ "static bool FUNC_0(void *opaque, int version_id)\n{", "return version_id == 5;", "}" ]
[ 0, 0, 0 ]
[ [ 1, 3 ], [ 5 ], [ 7 ] ]
6,082
static int parse_ifo_palette(DVDSubContext *ctx, char *p) { FILE *ifo; char ifostr[12]; uint32_t sp_pgci, pgci, off_pgc, pgc; uint8_t r, g, b, yuv[65], *buf; int i, y, cb, cr, r_add, g_add, b_add; int ret = 0; const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; ctx->has_palette = 0; if ((ifo = fopen(p, "r")) == NULL) { av_log(ctx, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", p, strerror(errno)); return AVERROR_EOF; } if (fread(ifostr, 12, 1, ifo) != 1 || memcmp(ifostr, "DVDVIDEO-VTS", 12)) { av_log(ctx, AV_LOG_WARNING, "\"%s\" is not a proper IFO file\n", p); ret = AVERROR_INVALIDDATA; goto end; } fseek(ifo, 0xCC, SEEK_SET); if (fread(&sp_pgci, 4, 1, ifo) == 1) { pgci = av_be2ne32(sp_pgci) * 2048; fseek(ifo, pgci + 0x0C, SEEK_SET); if (fread(&off_pgc, 4, 1, ifo) == 1) { pgc = pgci + av_be2ne32(off_pgc); fseek(ifo, pgc + 0xA4, SEEK_SET); if (fread(yuv, 64, 1, ifo) == 1) { buf = yuv; for(i=0; i<16; i++) { y = *++buf; cr = *++buf; cb = *++buf; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); ctx->palette[i] = (r << 16) + (g << 8) + b; buf++; } ctx->has_palette = 1; } } } if (ctx->has_palette == 0) { av_log(ctx, AV_LOG_WARNING, "Failed to read palette from IFO file \"%s\"\n", p); ret = AVERROR_INVALIDDATA; } end: fclose(ifo); return ret; }
false
FFmpeg
1de786777e0fb18ec1e44cea058c77e83980b6c4
static int parse_ifo_palette(DVDSubContext *ctx, char *p) { FILE *ifo; char ifostr[12]; uint32_t sp_pgci, pgci, off_pgc, pgc; uint8_t r, g, b, yuv[65], *buf; int i, y, cb, cr, r_add, g_add, b_add; int ret = 0; const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; ctx->has_palette = 0; if ((ifo = fopen(p, "r")) == NULL) { av_log(ctx, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", p, strerror(errno)); return AVERROR_EOF; } if (fread(ifostr, 12, 1, ifo) != 1 || memcmp(ifostr, "DVDVIDEO-VTS", 12)) { av_log(ctx, AV_LOG_WARNING, "\"%s\" is not a proper IFO file\n", p); ret = AVERROR_INVALIDDATA; goto end; } fseek(ifo, 0xCC, SEEK_SET); if (fread(&sp_pgci, 4, 1, ifo) == 1) { pgci = av_be2ne32(sp_pgci) * 2048; fseek(ifo, pgci + 0x0C, SEEK_SET); if (fread(&off_pgc, 4, 1, ifo) == 1) { pgc = pgci + av_be2ne32(off_pgc); fseek(ifo, pgc + 0xA4, SEEK_SET); if (fread(yuv, 64, 1, ifo) == 1) { buf = yuv; for(i=0; i<16; i++) { y = *++buf; cr = *++buf; cb = *++buf; YUV_TO_RGB1_CCIR(cb, cr); YUV_TO_RGB2_CCIR(r, g, b, y); ctx->palette[i] = (r << 16) + (g << 8) + b; buf++; } ctx->has_palette = 1; } } } if (ctx->has_palette == 0) { av_log(ctx, AV_LOG_WARNING, "Failed to read palette from IFO file \"%s\"\n", p); ret = AVERROR_INVALIDDATA; } end: fclose(ifo); return ret; }
{ "code": [], "line_no": [] }
static int FUNC_0(DVDSubContext *VAR_0, char *VAR_1) { FILE *ifo; char VAR_2[12]; uint32_t sp_pgci, pgci, off_pgc, pgc; uint8_t r, g, b, yuv[65], *buf; int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9; int VAR_10 = 0; const uint8_t *VAR_11 = ff_crop_tab + MAX_NEG_CROP; VAR_0->has_palette = 0; if ((ifo = fopen(VAR_1, "r")) == NULL) { av_log(VAR_0, AV_LOG_WARNING, "Unable to open IFO file \"%s\": %s\n", VAR_1, strerror(errno)); return AVERROR_EOF; } if (fread(VAR_2, 12, 1, ifo) != 1 || memcmp(VAR_2, "DVDVIDEO-VTS", 12)) { av_log(VAR_0, AV_LOG_WARNING, "\"%s\" is not a proper IFO file\n", VAR_1); VAR_10 = AVERROR_INVALIDDATA; goto end; } fseek(ifo, 0xCC, SEEK_SET); if (fread(&sp_pgci, 4, 1, ifo) == 1) { pgci = av_be2ne32(sp_pgci) * 2048; fseek(ifo, pgci + 0x0C, SEEK_SET); if (fread(&off_pgc, 4, 1, ifo) == 1) { pgc = pgci + av_be2ne32(off_pgc); fseek(ifo, pgc + 0xA4, SEEK_SET); if (fread(yuv, 64, 1, ifo) == 1) { buf = yuv; for(VAR_3=0; VAR_3<16; VAR_3++) { VAR_4 = *++buf; VAR_6 = *++buf; VAR_5 = *++buf; YUV_TO_RGB1_CCIR(VAR_5, VAR_6); YUV_TO_RGB2_CCIR(r, g, b, VAR_4); VAR_0->palette[VAR_3] = (r << 16) + (g << 8) + b; buf++; } VAR_0->has_palette = 1; } } } if (VAR_0->has_palette == 0) { av_log(VAR_0, AV_LOG_WARNING, "Failed to read palette from IFO file \"%s\"\n", VAR_1); VAR_10 = AVERROR_INVALIDDATA; } end: fclose(ifo); return VAR_10; }
[ "static int FUNC_0(DVDSubContext *VAR_0, char *VAR_1)\n{", "FILE *ifo;", "char VAR_2[12];", "uint32_t sp_pgci, pgci, off_pgc, pgc;", "uint8_t r, g, b, yuv[65], *buf;", "int VAR_3, VAR_4, VAR_5, VAR_6, VAR_7, VAR_8, VAR_9;", "int VAR_10 = 0;", "const uint8_t *VAR_11 = ff_crop_tab + MAX_NEG_CROP;", "VAR_0->has_palette = 0;", "if ((ifo = fopen(VAR_1, \"r\")) == NULL) {", "av_log(VAR_0, AV_LOG_WARNING, \"Unable to open IFO file \\\"%s\\\": %s\\n\", VAR_1, strerror(errno));", "return AVERROR_EOF;", "}", "if (fread(VAR_2, 12, 1, ifo) != 1 || memcmp(VAR_2, \"DVDVIDEO-VTS\", 12)) {", "av_log(VAR_0, AV_LOG_WARNING, \"\\\"%s\\\" is not a proper IFO file\\n\", VAR_1);", "VAR_10 = AVERROR_INVALIDDATA;", "goto end;", "}", "fseek(ifo, 0xCC, SEEK_SET);", "if (fread(&sp_pgci, 4, 1, ifo) == 1) {", "pgci = av_be2ne32(sp_pgci) * 2048;", "fseek(ifo, pgci + 0x0C, SEEK_SET);", "if (fread(&off_pgc, 4, 1, ifo) == 1) {", "pgc = pgci + av_be2ne32(off_pgc);", "fseek(ifo, pgc + 0xA4, SEEK_SET);", "if (fread(yuv, 64, 1, ifo) == 1) {", "buf = yuv;", "for(VAR_3=0; VAR_3<16; VAR_3++) {", "VAR_4 = *++buf;", "VAR_6 = *++buf;", "VAR_5 = *++buf;", "YUV_TO_RGB1_CCIR(VAR_5, VAR_6);", "YUV_TO_RGB2_CCIR(r, g, b, VAR_4);", "VAR_0->palette[VAR_3] = (r << 16) + (g << 8) + b;", "buf++;", "}", "VAR_0->has_palette = 1;", "}", "}", "}", "if (VAR_0->has_palette == 0) {", "av_log(VAR_0, AV_LOG_WARNING, \"Failed to read palette from IFO file \\\"%s\\\"\\n\", VAR_1);", "VAR_10 = AVERROR_INVALIDDATA;", "}", "end:\nfclose(ifo);", "return VAR_10;", "}" ]
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 ], [ 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 ], [ 77 ], [ 79 ], [ 81 ], [ 83 ], [ 85 ], [ 87 ], [ 89 ], [ 91 ], [ 93, 95 ], [ 97 ], [ 99 ] ]