--- a/source.c
+++ b/source.c
@@ -1,4 +1,4 @@
+static void coroutine_fn qemu_co_mutex_lock_slowpath(CoMutex *mutex)

 {

@@ -13,7 +13,7 @@
     trace_qemu_co_mutex_lock_entry(mutex, self);

     w.co = self;
+
     push_waiter(mutex, &w);

static void coroutine_fn qemu_co_mutex_lock_slowpath(CoMutex *mutex)

{

    Coroutine *self = qemu_coroutine_self();

    CoWaitRecord w;

    unsigned old_handoff;

    trace_qemu_co_mutex_lock_entry(mutex, self);

    w.co = self;

    push_waiter(mutex, &w);

    /* This is the "Responsibility Hand-Off" protocol; a lock() picks from

     * a concurrent unlock() the responsibility of waking somebody up.

     */

    old_handoff = atomic_mb_read(&mutex->handoff);

    if (old_handoff &&

        has_waiters(mutex) &&

        atomic_cmpxchg(&mutex->handoff, old_handoff, 0) == old_handoff) {

        /* There can be no concurrent pops, because there can be only

         * one active handoff at a time.

         */

        CoWaitRecord *to_wake = pop_waiter(mutex);

        Coroutine *co = to_wake->co;

        if (co == self) {

            /* We got the lock ourselves!  */

            assert(to_wake == &w);

            return;

        }

        aio_co_wake(co);

    }

    qemu_coroutine_yield();

    trace_qemu_co_mutex_lock_return(mutex, self);

}


--- a/source.c
+++ b/source.c
@@ -6,11 +6,11 @@

     if (monitor_ctrl_mode(mon)) {

+        qerror_report(QERR_MISSING_PARAMETER, "password");
+
+        return -EINVAL;
+
+    } else if (mon->rs) {

         readline_start(mon->rs, "Password: ", 1, readline_func, opaque);

int monitor_read_password(Monitor *mon, ReadLineFunc *readline_func,

                          void *opaque)

{

    if (monitor_ctrl_mode(mon)) {

        qerror_report(QERR_MISSING_PARAMETER, "password");

        return -EINVAL;

    } else if (mon->rs) {

        readline_start(mon->rs, "Password: ", 1, readline_func, opaque);

        /* prompt is printed on return from the command handler */

        return 0;

    } else {

        monitor_printf(mon, "terminal does not support password prompting\n");

        return -ENOTTY;

    }

}


--- a/source.c
+++ b/source.c
@@ -7,11 +7,11 @@
     vdev->vbasedev.group = NULL;

     trace_vfio_put_device(vdev->vbasedev.fd);
+
+    close(vdev->vbasedev.fd);
+
+    g_free(vdev->vbasedev.name);
+
     if (vdev->msix) {

         g_free(vdev->msix);

static void vfio_put_device(VFIOPCIDevice *vdev)

{

    QLIST_REMOVE(vdev, next);

    vdev->vbasedev.group = NULL;

    trace_vfio_put_device(vdev->vbasedev.fd);

    close(vdev->vbasedev.fd);

    g_free(vdev->vbasedev.name);

    if (vdev->msix) {

        g_free(vdev->msix);

        vdev->msix = NULL;

    }

}


--- a/source.c
+++ b/source.c
@@ -6,19 +6,19 @@

     NvmeCreateCq *c = (NvmeCreateCq *)cmd;

+    uint16_t cqid = le16_to_cpu(c->cqid);

     uint16_t vector = le16_to_cpu(c->irq_vector);
+
     uint16_t qsize = le16_to_cpu(c->qsize);

+    uint16_t qflags = le16_to_cpu(c->cq_flags);

     uint64_t prp1 = le64_to_cpu(c->prp1);
+

+    if (!cqid || !nvme_check_cqid(n, cqid)) {

         return NVME_INVALID_CQID | NVME_DNR;

static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeCmd *cmd)

{

    NvmeCQueue *cq;

    NvmeCreateCq *c = (NvmeCreateCq *)cmd;

    uint16_t cqid = le16_to_cpu(c->cqid);

    uint16_t vector = le16_to_cpu(c->irq_vector);

    uint16_t qsize = le16_to_cpu(c->qsize);

    uint16_t qflags = le16_to_cpu(c->cq_flags);

    uint64_t prp1 = le64_to_cpu(c->prp1);

    if (!cqid || !nvme_check_cqid(n, cqid)) {

        return NVME_INVALID_CQID | NVME_DNR;

    }

    if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) {

        return NVME_MAX_QSIZE_EXCEEDED | NVME_DNR;

    }

    if (!prp1) {

        return NVME_INVALID_FIELD | NVME_DNR;

    }

    if (vector > n->num_queues) {

        return NVME_INVALID_IRQ_VECTOR | NVME_DNR;

    }

    if (!(NVME_CQ_FLAGS_PC(qflags))) {

        return NVME_INVALID_FIELD | NVME_DNR;

    }

    cq = g_malloc0(sizeof(*cq));

    nvme_init_cq(cq, n, prp1, cqid, vector, qsize + 1,

        NVME_CQ_FLAGS_IEN(qflags));

    return NVME_SUCCESS;

}


--- a/source.c
+++ b/source.c
@@ -7,11 +7,11 @@
     struct kvm_device_attr attr = {

         .group = KVM_S390_VM_MEM_CTRL,
+
+        .attr = KVM_S390_VM_MEM_CLR_CMMA,
+
+    };
+

     if (mem_path || !kvm_s390_cmma_available()) {

void kvm_s390_cmma_reset(void)

{

    int rc;

    struct kvm_device_attr attr = {

        .group = KVM_S390_VM_MEM_CTRL,

        .attr = KVM_S390_VM_MEM_CLR_CMMA,

    };

    if (mem_path || !kvm_s390_cmma_available()) {

        return;

    }

    rc = kvm_vm_ioctl(kvm_state, KVM_SET_DEVICE_ATTR, &attr);

    trace_kvm_clear_cmma(rc);

}


--- a/source.c
+++ b/source.c
@@ -1,7 +1,7 @@
+static void multipath_pr_init(void)
+
 {
+
     static struct udev *udev;

static void multipath_pr_init(void)

{

    static struct udev *udev;

    udev = udev_new();

    mpath_lib_init(udev);

}


--- a/source.c
+++ b/source.c
@@ -39,11 +39,11 @@

         /* We iterate backwards here because adding nodes
+
+         * to the dtb puts them in last-first.
+
+         */
+
         for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) {

             add_virtio_mmio_node(fdt, acells, scells,

static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)

{

    uint32_t acells, scells, intc;

    const VEDBoardInfo *daughterboard = (const VEDBoardInfo *)info;

    acells = qemu_fdt_getprop_cell(fdt, "/", "#address-cells",

                                   NULL, &error_fatal);

    scells = qemu_fdt_getprop_cell(fdt, "/", "#size-cells",

                                   NULL, &error_fatal);

    intc = find_int_controller(fdt);

    if (!intc) {

        /* Not fatal, we just won't provide virtio. This will

         * happen with older device tree blobs.

         */

        fprintf(stderr, "QEMU: warning: couldn't find interrupt controller in "

                "dtb; will not include virtio-mmio devices in the dtb.\n");

    } else {

        int i;

        const hwaddr *map = daughterboard->motherboard_map;

        /* We iterate backwards here because adding nodes

         * to the dtb puts them in last-first.

         */

        for (i = NUM_VIRTIO_TRANSPORTS - 1; i >= 0; i--) {

            add_virtio_mmio_node(fdt, acells, scells,

                                 map[VE_VIRTIO] + 0x200 * i,

                                 0x200, intc, 40 + i);

        }

    }

}


--- a/source.c
+++ b/source.c
@@ -1,12 +1,12 @@
+void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)

+{

     DriveInfo *dinfo;

     int unit;

+

     for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {

void scsi_bus_legacy_handle_cmdline(SCSIBus *bus)

{

    DriveInfo *dinfo;

    int unit;

    for (unit = 0; unit < MAX_SCSI_DEVS; unit++) {

        dinfo = drive_get(IF_SCSI, bus->busnr, unit);

        if (dinfo == NULL) {

            continue;

        }

        scsi_bus_legacy_add_drive(bus, dinfo, unit);

    }

}


--- a/source.c
+++ b/source.c
@@ -17,7 +17,7 @@
 	dma = qemu_mallocz(sizeof *dma * 2);

+
 	eth = qemu_mallocz(sizeof *eth);

void *etraxfs_eth_init(NICInfo *nd, CPUState *env,

		       qemu_irq *irq, target_phys_addr_t base, int phyaddr)

{

	struct etraxfs_dma_client *dma = NULL;

	struct fs_eth *eth = NULL;

	qemu_check_nic_model(nd, "fseth");

	dma = qemu_mallocz(sizeof *dma * 2);

	eth = qemu_mallocz(sizeof *eth);

	dma[0].client.push = eth_tx_push;

	dma[0].client.opaque = eth;

	dma[1].client.opaque = eth;

	dma[1].client.pull = NULL;

	eth->env = env;

	eth->irq = irq;

	eth->dma_out = dma;

	eth->dma_in = dma + 1;

	/* Connect the phy.  */

	eth->phyaddr = phyaddr & 0x1f;

	tdk_init(&eth->phy);

	mdio_attach(&eth->mdio_bus, &eth->phy, eth->phyaddr);

	eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth);

	cpu_register_physical_memory (base, 0x5c, eth->ethregs);

	eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,

				       eth_receive, eth_can_receive, eth);

	eth->vc->opaque = eth;

	eth->vc->link_status_changed = eth_set_link;

	return dma;

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
 {

     qemu_irq *irqs;
+
     int i;

void ahci_init(AHCIState *s, DeviceState *qdev, AddressSpace *as, int ports)

{

    qemu_irq *irqs;

    int i;

    s->as = as;

    s->ports = ports;

    s->dev = g_malloc0(sizeof(AHCIDevice) * ports);

    ahci_reg_init(s);

    /* XXX BAR size should be 1k, but that breaks, so bump it to 4k for now */

    memory_region_init_io(&s->mem, OBJECT(qdev), &ahci_mem_ops, s,

                          "ahci", AHCI_MEM_BAR_SIZE);

    memory_region_init_io(&s->idp, OBJECT(qdev), &ahci_idp_ops, s,

                          "ahci-idp", 32);

    irqs = qemu_allocate_irqs(ahci_irq_set, s, s->ports);

    for (i = 0; i < s->ports; i++) {

        AHCIDevice *ad = &s->dev[i];

        ide_bus_new(&ad->port, sizeof(ad->port), qdev, i, 1);

        ide_init2(&ad->port, irqs[i]);

        ad->hba = s;

        ad->port_no = i;

        ad->port.dma = &ad->dma;

        ad->port.dma->ops = &ahci_dma_ops;

    }

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
 {

     PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
+
     pc_q35_2_5_machine_options(m);

     m->alias = NULL;

static void pc_q35_2_4_machine_options(MachineClass *m)

{

    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);

    pc_q35_2_5_machine_options(m);

    m->alias = NULL;

    pcmc->broken_reserved_end = true;

    pcmc->inter_dimm_gap = false;

    SET_MACHINE_COMPAT(m, PC_COMPAT_2_4);

}


--- a/source.c
+++ b/source.c
@@ -1,1 +1,1 @@
+static void null_end_frame(AVFilterLink *inlink) { }


--- a/source.c
+++ b/source.c
@@ -5,11 +5,11 @@
     ObjectProperty *prop = object_property_find(parent, part, NULL);

     if (prop == NULL) {
+
+        return NULL;
+
+    }
+

     if (object_property_is_link(prop)) {

Object *object_resolve_path_component(Object *parent, const gchar *part)

{

    ObjectProperty *prop = object_property_find(parent, part, NULL);

    if (prop == NULL) {

        return NULL;

    }

    if (object_property_is_link(prop)) {

        LinkProperty *lprop = prop->opaque;

        return *lprop->child;

    } else if (object_property_is_child(prop)) {

        return prop->opaque;

    } else {

        return NULL;

    }

}


--- a/source.c
+++ b/source.c
@@ -8,7 +8,7 @@

     struct pxa2xx_gpio_info_s *s;

+

     s = (struct pxa2xx_gpio_info_s *)

struct pxa2xx_gpio_info_s *pxa2xx_gpio_init(target_phys_addr_t base,

                CPUState *env, qemu_irq *pic, int lines)

{

    int iomemtype;

    struct pxa2xx_gpio_info_s *s;

    s = (struct pxa2xx_gpio_info_s *)

            qemu_mallocz(sizeof(struct pxa2xx_gpio_info_s));

    memset(s, 0, sizeof(struct pxa2xx_gpio_info_s));

    s->base = base;

    s->pic = pic;

    s->lines = lines;

    s->cpu_env = env;

    iomemtype = cpu_register_io_memory(0, pxa2xx_gpio_readfn,

                    pxa2xx_gpio_writefn, s);

    cpu_register_physical_memory(base, 0x00000fff, iomemtype);

    register_savevm("pxa2xx_gpio", 0, 0,

                    pxa2xx_gpio_save, pxa2xx_gpio_load, s);

    return s;

}


--- a/source.c
+++ b/source.c
@@ -21,11 +21,11 @@
     case RTSP_STATE_PLAYING:

         if (rtsp_read_pause(s) != 0)
+
+            return -1;
+
+        rt->state = RTSP_STATE_SEEKING;
+
         if (rtsp_read_play(s) != 0)

             return -1;

static int rtsp_read_seek(AVFormatContext *s, int stream_index,

                          int64_t timestamp, int flags)

{

    RTSPState *rt = s->priv_data;

    rt->seek_timestamp = av_rescale_q(timestamp, s->streams[stream_index]->time_base, AV_TIME_BASE_Q);

    switch(rt->state) {

    default:

    case RTSP_STATE_IDLE:

        break;

    case RTSP_STATE_PLAYING:

        if (rtsp_read_pause(s) != 0)

            return -1;

        rt->state = RTSP_STATE_SEEKING;

        if (rtsp_read_play(s) != 0)

            return -1;

        break;

    case RTSP_STATE_PAUSED:

        rt->state = RTSP_STATE_IDLE;

        break;

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,7 +1,7 @@
 static void flat_print_int(WriterContext *wctx, const char *key, long long int value)

+{
+
     flat_print_key_prefix(wctx);

     printf("%s=%lld\n", key, value);

static void flat_print_int(WriterContext *wctx, const char *key, long long int value)

{

    flat_print_key_prefix(wctx);

    printf("%s=%lld\n", key, value);

}


--- a/source.c
+++ b/source.c
@@ -28,11 +28,11 @@

         break;

+    default:
+
+        dolog ("U nabm writew %#x <- %#x\n", addr, val);
+
+        break;

     }

static void nabm_writew (void *opaque, uint32_t addr, uint32_t val)

{

    PCIAC97LinkState *d = opaque;

    AC97LinkState *s = &d->ac97;

    AC97BusMasterRegs *r = NULL;

    uint32_t index = addr - s->base[1];

    switch (index) {

    case PI_SR:

    case PO_SR:

    case MC_SR:

        r = &s->bm_regs[GET_BM (index)];

        r->sr |= val & ~(SR_RO_MASK | SR_WCLEAR_MASK);

        update_sr (s, r, r->sr & ~(val & SR_WCLEAR_MASK));

        dolog ("SR[%d] <- %#x (sr %#x)\n", GET_BM (index), val, r->sr);

        break;

    default:

        dolog ("U nabm writew %#x <- %#x\n", addr, val);

        break;

    }

}


--- a/source.c
+++ b/source.c
@@ -4,7 +4,7 @@

     AVDictionary *tmp = NULL;

+    int ret;

     const char *proto_name = avio_find_protocol_name(url);

static int open_url(HLSContext *c, URLContext **uc, const char *url, AVDictionary *opts)

{

    AVDictionary *tmp = NULL;

    int ret;

    const char *proto_name = avio_find_protocol_name(url);

    // only http(s) & file are allowed

    if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))

        return AVERROR_INVALIDDATA;

    if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')

        ;

    else if (strcmp(proto_name, "file") || !strcmp(url, "file,"))

        return AVERROR_INVALIDDATA;

    av_dict_copy(&tmp, c->avio_opts, 0);

    av_dict_copy(&tmp, opts, 0);

    ret = ffurl_open(uc, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);

    if( ret >= 0) {

        // update cookies on http response with setcookies.

        URLContext *u = *uc;

        update_options(&c->cookies, "cookies", u->priv_data);

        av_dict_set(&opts, "cookies", c->cookies, 0);

    }

    av_dict_free(&tmp);

    return ret;

}


--- a/source.c
+++ b/source.c
@@ -1,9 +1,9 @@
 void cpu_x86_inject_mce(CPUState *cenv, int bank, uint64_t status,
+
+                        uint64_t mcg_status, uint64_t addr, uint64_t misc,
+
+                        int broadcast)
+
 {

     unsigned bank_num = cenv->mcg_cap & 0xff;

void cpu_x86_inject_mce(CPUState *cenv, int bank, uint64_t status,

                        uint64_t mcg_status, uint64_t addr, uint64_t misc,

                        int broadcast)

{

    unsigned bank_num = cenv->mcg_cap & 0xff;

    CPUState *env;

    int flag = 0;

    if (bank >= bank_num || !(status & MCI_STATUS_VAL)) {

        return;

    }

    if (broadcast) {

        if (!cpu_x86_support_mca_broadcast(cenv)) {

            fprintf(stderr, "Current CPU does not support broadcast\n");

            return;

        }

    }

    if (kvm_enabled()) {

        if (broadcast) {

            flag |= MCE_BROADCAST;

        }

        kvm_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc, flag);

    } else {

        qemu_inject_x86_mce(cenv, bank, status, mcg_status, addr, misc);

        if (broadcast) {

            for (env = first_cpu; env != NULL; env = env->next_cpu) {

                if (cenv == env) {

                    continue;

                }

                qemu_inject_x86_mce(env, 1, MCI_STATUS_VAL | MCI_STATUS_UC,

                                    MCG_STATUS_MCIP | MCG_STATUS_RIPV, 0, 0);

            }

        }

    }

}


--- a/source.c
+++ b/source.c
@@ -1,7 +1,7 @@
+void block_job_completed(BlockJob *job, int ret)
+
+{
+
     BlockDriverState *bs = job->bs;

void block_job_completed(BlockJob *job, int ret)

{

    BlockDriverState *bs = job->bs;

    assert(bs->job == job);

    job->cb(job->opaque, ret);

    bs->job = NULL;

    bdrv_op_unblock_all(bs, job->blocker);

    error_free(job->blocker);

    g_free(job);

}


--- a/source.c
+++ b/source.c
@@ -60,8 +60,8 @@

 unmarshal_err_out:

+    v9fs_string_free(&path);
+
+    return ret;
+
+}

static int do_create(struct iovec *iovec)

{

    int ret;

    V9fsString path;

    int flags, mode, uid, gid, cur_uid, cur_gid;

    v9fs_string_init(&path);

    ret = proxy_unmarshal(iovec, PROXY_HDR_SZ, "sdddd",

                          &path, &flags, &mode, &uid, &gid);

    if (ret < 0) {

        goto unmarshal_err_out;

    }

    cur_uid = geteuid();

    cur_gid = getegid();

    ret = setfsugid(uid, gid);

    if (ret < 0) {

        /*

         * On failure reset back to the

         * old uid/gid

         */

        ret = -errno;

        goto err_out;

    }

    ret = open(path.data, flags, mode);

    if (ret < 0) {

        ret = -errno;

    }

err_out:

    setfsugid(cur_uid, cur_gid);

unmarshal_err_out:

    v9fs_string_free(&path);

    return ret;

}


--- a/source.c
+++ b/source.c
@@ -5,7 +5,7 @@
                         IOHandler *fd_write,

                         void *opaque)
+
 {

     static IOTrampoline fd_trampolines[FD_SETSIZE];

int qemu_set_fd_handler(int fd,

                        IOHandler *fd_read,

                        IOHandler *fd_write,

                        void *opaque)

{

    static IOTrampoline fd_trampolines[FD_SETSIZE];

    IOTrampoline *tramp = &fd_trampolines[fd];

    if (tramp->tag != 0) {

        g_io_channel_unref(tramp->chan);

        g_source_remove(tramp->tag);

    }

    if (opaque) {

        GIOCondition cond = 0;

        tramp->fd_read = fd_read;

        tramp->fd_write = fd_write;

        tramp->opaque = opaque;

        if (fd_read) {

            cond |= G_IO_IN | G_IO_ERR;

        }

        if (fd_write) {

            cond |= G_IO_OUT | G_IO_ERR;

        }

        tramp->chan = g_io_channel_unix_new(fd);

        tramp->tag = g_io_add_watch(tramp->chan, cond, fd_trampoline, tramp);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -64,10 +64,10 @@

 #define GEN_HELPER 2

+#include "helper.h"
+
+
+
+    tcg_target_init(s);

 }

void tcg_context_init(TCGContext *s)

{

    int op, total_args, n;

    TCGOpDef *def;

    TCGArgConstraint *args_ct;

    int *sorted_args;

    memset(s, 0, sizeof(*s));

    s->nb_globals = 0;

    /* Count total number of arguments and allocate the corresponding

       space */

    total_args = 0;

    for(op = 0; op < NB_OPS; op++) {

        def = &tcg_op_defs[op];

        n = def->nb_iargs + def->nb_oargs;

        total_args += n;

    }

    args_ct = g_malloc(sizeof(TCGArgConstraint) * total_args);

    sorted_args = g_malloc(sizeof(int) * total_args);

    for(op = 0; op < NB_OPS; op++) {

        def = &tcg_op_defs[op];

        def->args_ct = args_ct;

        def->sorted_args = sorted_args;

        n = def->nb_iargs + def->nb_oargs;

        sorted_args += n;

        args_ct += n;

    }

    /* Register helpers.  */

#define GEN_HELPER 2

#include "helper.h"

    tcg_target_init(s);

}


--- a/source.c
+++ b/source.c
@@ -26,11 +26,11 @@

         FD_SET(s->fd, &wfds);

+        tv.tv_sec = 0;
+
+        tv.tv_usec = 100 * 1000;
+
+        select(fd_max + 1, NULL, &wfds, NULL, &tv);

 #ifdef __BEOS__

static int tcp_write(URLContext *h, uint8_t *buf, int size)

{

    TCPContext *s = h->priv_data;

    int ret, size1, fd_max;

    fd_set wfds;

    struct timeval tv;

    size1 = size;

    while (size > 0) {

        if (url_interrupt_cb())

            return -EINTR;

        fd_max = s->fd;

        FD_ZERO(&wfds);

        FD_SET(s->fd, &wfds);

        tv.tv_sec = 0;

        tv.tv_usec = 100 * 1000;

        select(fd_max + 1, NULL, &wfds, NULL, &tv);

#ifdef __BEOS__

        ret = send(s->fd, buf, size, 0);

#else

        ret = write(s->fd, buf, size);

#endif

        if (ret < 0) {

            if (errno != EINTR && errno != EAGAIN) {

#ifdef __BEOS__

                return errno;

#else

                return -errno;

#endif

            }

            continue;

        }

        size -= ret;

        buf += ret;

    }

    return size1 - size;

}


--- a/source.c
+++ b/source.c
@@ -1,13 +1,13 @@
+pci_ebus_init1(PCIDevice *s)
+
 {
+
     isa_bus_new(&s->qdev);

+    s->config[0x04] = 0x06; // command = bus master, pci mem
+
     s->config[0x05] = 0x00;

     s->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error

pci_ebus_init1(PCIDevice *s)

{

    isa_bus_new(&s->qdev);

    s->config[0x04] = 0x06; // command = bus master, pci mem

    s->config[0x05] = 0x00;

    s->config[0x06] = 0xa0; // status = fast back-to-back, 66MHz, no error

    s->config[0x07] = 0x03; // status = medium devsel

    s->config[0x09] = 0x00; // programming i/f

    s->config[0x0D] = 0x0a; // latency_timer

    pci_register_bar(s, 0, 0x1000000, PCI_BASE_ADDRESS_SPACE_MEMORY,

                           ebus_mmio_mapfunc);

    pci_register_bar(s, 1, 0x800000,  PCI_BASE_ADDRESS_SPACE_MEMORY,

                           ebus_mmio_mapfunc);

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -6,11 +6,11 @@

+    if (w->num >= MAXIMUM_WAIT_OBJECTS)
+
+        return -1;
+
+    w->events[w->num] = handle;

     w->func[w->num] = func;

int qemu_add_wait_object(HANDLE handle, WaitObjectFunc *func, void *opaque)

{

    WaitObjects *w = &wait_objects;

    if (w->num >= MAXIMUM_WAIT_OBJECTS)

        return -1;

    w->events[w->num] = handle;

    w->func[w->num] = func;

    w->opaque[w->num] = opaque;

    w->num++;

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
+static void virtio_blk_free_request(VirtIOBlockReq *req)

+{

     if (req) {

static void virtio_blk_free_request(VirtIOBlockReq *req)

{

    if (req) {

        g_slice_free(VirtQueueElement, req->elem);

        g_slice_free(VirtIOBlockReq, req);

    }

}


--- a/source.c
+++ b/source.c
@@ -10,7 +10,7 @@

     char *init_group = strlen(group) ? (char *)group : NULL;

+    char *init_sock = strlen(sock) ? (char *)sock : NULL;

static int net_vde_init(VLANState *vlan, const char *model,

                        const char *name, const char *sock,

                        int port, const char *group, int mode)

{

    VDEState *s;

    char *init_group = strlen(group) ? (char *)group : NULL;

    char *init_sock = strlen(sock) ? (char *)sock : NULL;

    struct vde_open_args args = {

        .port = port,

        .group = init_group,

        .mode = mode,

    };

    s = qemu_mallocz(sizeof(VDEState));

    s->vde = vde_open(init_sock, "QEMU", &args);

    if (!s->vde){

        free(s);

        return -1;

    }

    s->vc = qemu_new_vlan_client(vlan, model, name, vde_from_qemu, NULL, s);

    qemu_set_fd_handler(vde_datafd(s->vde), vde_to_qemu, NULL, s);

    snprintf(s->vc->info_str, sizeof(s->vc->info_str), "sock=%s,fd=%d",

             sock, vde_datafd(s->vde));

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,5 +1,5 @@
 static uint64_t kvmppc_read_int_cpu_dt(const char *propname)
+
 {

     char buf[PATH_MAX];
@@ -9,9 +9,9 @@
         uint32_t v32;

         uint64_t v64;
+
+    } u;
+
     FILE *f;

     int len;

static uint64_t kvmppc_read_int_cpu_dt(const char *propname)

{

    char buf[PATH_MAX];

    union {

        uint32_t v32;

        uint64_t v64;

    } u;

    FILE *f;

    int len;

    if (kvmppc_find_cpu_dt(buf, sizeof(buf))) {

        return -1;

    }

    strncat(buf, "/", sizeof(buf) - strlen(buf));

    strncat(buf, propname, sizeof(buf) - strlen(buf));

    f = fopen(buf, "rb");

    if (!f) {

        return -1;

    }

    len = fread(&u, 1, sizeof(u), f);

    fclose(f);

    switch (len) {

    case 4:

        /* property is a 32-bit quantity */

        return be32_to_cpu(u.v32);

    case 8:

        return be64_to_cpu(u.v64);

    }

    return 0;

}


static inline bool vtd_iova_range_check(uint64_t iova, VTDContextEntry *ce)

{

    /*

     * Check if @iova is above 2^X-1, where X is the minimum of MGAW

     * in CAP_REG and AW in context-entry.

     */

    return !(iova & ~(vtd_iova_limit(ce) - 1));

}


--- a/source.c
+++ b/source.c
@@ -1,12 +1,12 @@
 void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){

     int i, j;
+
     int dc = (((dctcoef*)block)[0] + 32) >> 6;

     INIT_CLIP

+    pixel *dst = (pixel*)_dst;

     stride /= sizeof(pixel);

void FUNCC(ff_h264_idct_dc_add)(uint8_t *_dst, DCTELEM *block, int stride){

    int i, j;

    int dc = (((dctcoef*)block)[0] + 32) >> 6;

    INIT_CLIP

    pixel *dst = (pixel*)_dst;

    stride /= sizeof(pixel);

    for( j = 0; j < 4; j++ )

    {

        for( i = 0; i < 4; i++ )

            dst[i] = CLIP( dst[i] + dc );

        dst += stride;

    }

}


--- a/source.c
+++ b/source.c
@@ -7,11 +7,11 @@

     /* Check cancellation *before* setting busy = false, too!  */
+
+    if (block_job_is_cancelled(job)) {
+
+        return;
+
     }

void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns)

{

    assert(job->busy);

    /* Check cancellation *before* setting busy = false, too!  */

    if (block_job_is_cancelled(job)) {

        return;

    }

    job->busy = false;

    if (block_job_is_paused(job)) {

        qemu_coroutine_yield();

    } else {

        co_aio_sleep_ns(blk_get_aio_context(job->blk), type, ns);

    }

    job->busy = true;

}


--- a/source.c
+++ b/source.c
@@ -1,4 +1,4 @@
+static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)

 {

static size_t refcount_array_byte_size(BDRVQcow2State *s, uint64_t entries)

{

    /* This assertion holds because there is no way we can address more than

     * 2^(64 - 9) clusters at once (with cluster size 512 = 2^9, and because

     * offsets have to be representable in bytes); due to every cluster

     * corresponding to one refcount entry, we are well below that limit */

    assert(entries < (UINT64_C(1) << (64 - 9)));

    /* Thanks to the assertion this will not overflow, because

     * s->refcount_order < 7.

     * (note: x << s->refcount_order == x * s->refcount_bits) */

    return DIV_ROUND_UP(entries << s->refcount_order, 8);

}


--- a/source.c
+++ b/source.c
@@ -1,9 +1,9 @@
 void qemu_thread_exit(void *arg)
+
+{
+
+    QemuThread *thread = TlsGetValue(qemu_thread_tls_index);
+
     thread->ret = arg;

     CloseHandle(thread->thread);

void qemu_thread_exit(void *arg)

{

    QemuThread *thread = TlsGetValue(qemu_thread_tls_index);

    thread->ret = arg;

    CloseHandle(thread->thread);

    thread->thread = NULL;

    ExitThread(0);

}


--- a/source.c
+++ b/source.c
@@ -26,11 +26,11 @@

     tcg_temp_free(t1);

+#else
+
+    tcg_gen_mov_i32(cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);
+
+    tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);

 #endif

static inline void gen_evmergelo(DisasContext *ctx)

{

    if (unlikely(!ctx->spe_enabled)) {

        gen_exception(ctx, POWERPC_EXCP_APU);

        return;

    }

#if defined(TARGET_PPC64)

    TCGv t0 = tcg_temp_new();

    TCGv t1 = tcg_temp_new();

    tcg_gen_ext32u_tl(t0, cpu_gpr[rB(ctx->opcode)]);

    tcg_gen_shli_tl(t1, cpu_gpr[rA(ctx->opcode)], 32);

    tcg_gen_or_tl(cpu_gpr[rD(ctx->opcode)], t0, t1);

    tcg_temp_free(t0);

    tcg_temp_free(t1);

#else

    tcg_gen_mov_i32(cpu_gprh[rD(ctx->opcode)], cpu_gpr[rA(ctx->opcode)]);

    tcg_gen_mov_i32(cpu_gpr[rD(ctx->opcode)], cpu_gpr[rB(ctx->opcode)]);

#endif

}


--- a/source.c
+++ b/source.c
@@ -15,11 +15,11 @@
         .region_add = mem_add,

         .region_nop = mem_add,
+
+        .priority = 0,
+
+    };
+
     d->as = as;

     as->dispatch = d;

void address_space_init_dispatch(AddressSpace *as)

{

    AddressSpaceDispatch *d = g_new(AddressSpaceDispatch, 1);

    d->phys_map  = (PhysPageEntry) { .ptr = PHYS_MAP_NODE_NIL, .is_leaf = 0 };

    d->listener = (MemoryListener) {

        .begin = mem_begin,

        .region_add = mem_add,

        .region_nop = mem_add,

        .priority = 0,

    };

    d->as = as;

    as->dispatch = d;

    memory_listener_register(&d->listener, as);

}


--- a/source.c
+++ b/source.c
@@ -27,11 +27,11 @@
             cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table,

                              VC9_CBPCY_I_VLC_BITS, 2);
+
+            ac_pred = get_bits(&v->gb, 1);
+
+            //Decode blocks from that mb wrt cbpcy
+
         }

     }

static int standard_decode_i_mbs(VC9Context *v)

{

    int x, y, ac_pred, cbpcy;

    /* Select ttmb table depending on pq */

    if (v->pq < 5) v->ttmb_vlc = &vc9_ttmb_vlc[0];

    else if (v->pq < 13) v->ttmb_vlc = &vc9_ttmb_vlc[1];

    else v->ttmb_vlc = &vc9_ttmb_vlc[2];

    for (y=0; y<v->height_mb; y++)

    {

        for (x=0; x<v->width_mb; x++)

        {

            cbpcy = get_vlc2(&v->gb, vc9_cbpcy_i_vlc.table,

                             VC9_CBPCY_I_VLC_BITS, 2);

            ac_pred = get_bits(&v->gb, 1);

            //Decode blocks from that mb wrt cbpcy

        }

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -5,9 +5,9 @@
     /* Currently cannot think of anything to do on destruction */

     /* Still, the framework should be here for reference/use */
+
+    if( ref->twopassbuffer != NULL )
+
         ref->twopassbuffer[0] = 0;

     return 0;

static int xvid_ff_2pass_destroy(struct xvid_context *ref,

                                xvid_plg_destroy_t *param) {

    /* Currently cannot think of anything to do on destruction */

    /* Still, the framework should be here for reference/use */

    if( ref->twopassbuffer != NULL )

        ref->twopassbuffer[0] = 0;

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,16 +1,16 @@
 void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)

+{
+
+    int64_t value;

+    if (!error_is_set(errp)) {
+
+        if (v->type_int16) {
+
             v->type_int16(v, obj, name, errp);

+        } else {

             value = *obj;

void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp)

{

    int64_t value;

    if (!error_is_set(errp)) {

        if (v->type_int16) {

            v->type_int16(v, obj, name, errp);

        } else {

            value = *obj;

            v->type_int(v, &value, name, errp);

            if (value < INT16_MIN || value > INT16_MAX) {

                error_set(errp, QERR_INVALID_PARAMETER_VALUE, name ? name : "null",

                          "int16_t");

                return;

            }

            *obj = value;

        }

    }

}


--- a/source.c
+++ b/source.c
@@ -28,11 +28,11 @@

     assert(position >= 0);

+
+
+    pxb_dev_base = DEVICE(pxb_dev);
+
+    main_host = PCI_HOST_BRIDGE(pxb_dev_base->parent_bus->parent);

     main_host_sbd = SYS_BUS_DEVICE(main_host);

static char *pxb_host_ofw_unit_address(const SysBusDevice *dev)

{

    const PCIHostState *pxb_host;

    const PCIBus *pxb_bus;

    const PXBDev *pxb_dev;

    int position;

    const DeviceState *pxb_dev_base;

    const PCIHostState *main_host;

    const SysBusDevice *main_host_sbd;

    pxb_host = PCI_HOST_BRIDGE(dev);

    pxb_bus = pxb_host->bus;

    pxb_dev = PXB_DEV(pxb_bus->parent_dev);

    position = g_list_index(pxb_dev_list, pxb_dev);

    assert(position >= 0);

    pxb_dev_base = DEVICE(pxb_dev);

    main_host = PCI_HOST_BRIDGE(pxb_dev_base->parent_bus->parent);

    main_host_sbd = SYS_BUS_DEVICE(main_host);

    if (main_host_sbd->num_mmio > 0) {

        return g_strdup_printf(TARGET_FMT_plx ",%x",

                               main_host_sbd->mmio[0].addr, position + 1);

    }

    if (main_host_sbd->num_pio > 0) {

        return g_strdup_printf("i%04x,%x",

                               main_host_sbd->pio[0], position + 1);

    }

    return NULL;

}


--- a/source.c
+++ b/source.c
@@ -5,7 +5,7 @@
     BufferSinkContext *buf = ctx->priv;

     AVFilterFormats *formats = NULL;
+
     unsigned i;

     int ret;

static int vsink_query_formats(AVFilterContext *ctx)

{

    BufferSinkContext *buf = ctx->priv;

    AVFilterFormats *formats = NULL;

    unsigned i;

    int ret;

    CHECK_LIST_SIZE(pixel_fmts)

    if (buf->pixel_fmts_size) {

        for (i = 0; i < NB_ITEMS(buf->pixel_fmts); i++)

            if ((ret = ff_add_format(&formats, buf->pixel_fmts[i])) < 0)

                return ret;

        ff_set_common_formats(ctx, formats);

    } else {

        ff_default_query_formats(ctx);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,16 +1,16 @@
+static uint32_t rtl8139_TxStatus_read(RTL8139State *s, uint8_t addr, int size)
+
 {

     uint32_t reg = (addr - TxStatus0) / 4;
+
     uint32_t offset = addr & 0x3;

     uint32_t ret = 0;
+
+

+    if (addr & (size - 1)) {

         DPRINTF("not implemented read for TxStatus addr=0x%x size=0x%x\n", addr,

static uint32_t rtl8139_TxStatus_read(RTL8139State *s, uint8_t addr, int size)

{

    uint32_t reg = (addr - TxStatus0) / 4;

    uint32_t offset = addr & 0x3;

    uint32_t ret = 0;

    if (addr & (size - 1)) {

        DPRINTF("not implemented read for TxStatus addr=0x%x size=0x%x\n", addr,

                size);

        return ret;

    }

    switch (size) {

    case 1: /* fall through */

    case 2: /* fall through */

    case 4:

        ret = (s->TxStatus[reg] >> offset * 8) & ((1 << (size * 8)) - 1);

        DPRINTF("TxStatus[%d] read addr=0x%x size=0x%x val=0x%08x\n", reg, addr,

                size, ret);

        break;

    default:

        DPRINTF("unsupported size 0x%x of TxStatus reading\n", size);

        break;

    }

    return ret;

}


--- a/source.c
+++ b/source.c
@@ -7,7 +7,7 @@
     uint32_t pcba = pnv_xscom_pcba(chip, addr);

     uint64_t val = 0;
+
     MemTxResult result;

static uint64_t xscom_read(void *opaque, hwaddr addr, unsigned width)

{

    PnvChip *chip = opaque;

    uint32_t pcba = pnv_xscom_pcba(chip, addr);

    uint64_t val = 0;

    MemTxResult result;

    /* Handle some SCOMs here before dispatch */

    val = xscom_read_default(chip, pcba);

    if (val != -1) {

        goto complete;

    }

    val = address_space_ldq(&chip->xscom_as, pcba << 3, MEMTXATTRS_UNSPECIFIED,

                            &result);

    if (result != MEMTX_OK) {

        qemu_log_mask(LOG_GUEST_ERROR, "XSCOM read failed at @0x%"

                      HWADDR_PRIx " pcba=0x%08x\n", addr, pcba);

        xscom_complete(current_cpu, HMER_XSCOM_FAIL | HMER_XSCOM_DONE);

        return 0;

    }

complete:

    xscom_complete(current_cpu, HMER_XSCOM_DONE);

    return val;

}


static inline void RENAME(BEToUV)(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused)

{

#if COMPILE_TEMPLATE_MMX

    __asm__ volatile(

        "movq "MANGLE(bm01010101)", %%mm4           \n\t"

        "mov                    %0, %%"REG_a"       \n\t"

        "1:                                         \n\t"

        "movq    (%1, %%"REG_a",2), %%mm0           \n\t"

        "movq   8(%1, %%"REG_a",2), %%mm1           \n\t"

        "movq    (%2, %%"REG_a",2), %%mm2           \n\t"

        "movq   8(%2, %%"REG_a",2), %%mm3           \n\t"

        "pand                %%mm4, %%mm0           \n\t"

        "pand                %%mm4, %%mm1           \n\t"

        "pand                %%mm4, %%mm2           \n\t"

        "pand                %%mm4, %%mm3           \n\t"

        "packuswb            %%mm1, %%mm0           \n\t"

        "packuswb            %%mm3, %%mm2           \n\t"

        "movq                %%mm0, (%3, %%"REG_a") \n\t"

        "movq                %%mm2, (%4, %%"REG_a") \n\t"

        "add                    $8, %%"REG_a"       \n\t"

        " js                    1b                  \n\t"

        : : "g" ((x86_reg)-width), "r" (src1+width*2), "r" (src2+width*2), "r" (dstU+width), "r" (dstV+width)

        : "%"REG_a

    );

#else

    int i;

    for (i=0; i<width; i++) {

        dstU[i]= src1[2*i];

        dstV[i]= src2[2*i];

    }

#endif

}


--- a/source.c
+++ b/source.c
@@ -65,10 +65,10 @@

     vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx),

+                       0, virtio_queue_get_avail_size(vdev, idx));
+
+    vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx),
+
+                       0, virtio_queue_get_desc_size(vdev, idx));

 }

static void vhost_virtqueue_stop(struct vhost_dev *dev,

                                    struct VirtIODevice *vdev,

                                    struct vhost_virtqueue *vq,

                                    unsigned idx)

{

    int vhost_vq_index = dev->vhost_ops->vhost_get_vq_index(dev, idx);

    struct vhost_vring_state state = {

        .index = vhost_vq_index,

    };

    int r;

    r = dev->vhost_ops->vhost_get_vring_base(dev, &state);

    if (r < 0) {

        VHOST_OPS_DEBUG("vhost VQ %d ring restore failed: %d", idx, r);

    } else {

        virtio_queue_set_last_avail_idx(vdev, idx, state.num);

    }

    virtio_queue_invalidate_signalled_used(vdev, idx);

    virtio_queue_update_used_idx(vdev, idx);

    /* In the cross-endian case, we need to reset the vring endianness to

     * native as legacy devices expect so by default.

    if (vhost_needs_vring_endian(vdev)) {

        vhost_virtqueue_set_vring_endian_legacy(dev,

                                                !virtio_is_big_endian(vdev),

                                                vhost_vq_index);

    }

    vhost_memory_unmap(dev, vq->used, virtio_queue_get_used_size(vdev, idx),

                       1, virtio_queue_get_used_size(vdev, idx));

    vhost_memory_unmap(dev, vq->avail, virtio_queue_get_avail_size(vdev, idx),

                       0, virtio_queue_get_avail_size(vdev, idx));

    vhost_memory_unmap(dev, vq->desc, virtio_queue_get_desc_size(vdev, idx),

                       0, virtio_queue_get_desc_size(vdev, idx));

}


--- a/source.c
+++ b/source.c
@@ -15,11 +15,11 @@
     if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {

         /* if there's no resource/device associated with the DRC, there's
+
+         * no way for us to put it in an allocation state consistent with
+
+         * being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should
+
          * result in an RTAS return code of -3 / "no such indicator"

          */

static uint32_t set_allocation_state(sPAPRDRConnector *drc,

                                     sPAPRDRAllocationState state)

{

    sPAPRDRConnectorClass *drck = SPAPR_DR_CONNECTOR_GET_CLASS(drc);

    DPRINTFN("drc: %x, set_allocation_state: %x", get_index(drc), state);

    if (state == SPAPR_DR_ALLOCATION_STATE_USABLE) {

        /* if there's no resource/device associated with the DRC, there's

         * no way for us to put it in an allocation state consistent with

         * being 'USABLE'. PAPR 2.7, 13.5.3.4 documents that this should

         * result in an RTAS return code of -3 / "no such indicator"

         */

        if (!drc->dev) {

            return RTAS_OUT_NO_SUCH_INDICATOR;

        }

    }

    if (drc->type != SPAPR_DR_CONNECTOR_TYPE_PCI) {

        drc->allocation_state = state;

        if (drc->awaiting_release &&

            drc->allocation_state == SPAPR_DR_ALLOCATION_STATE_UNUSABLE) {

            DPRINTFN("finalizing device removal");

            drck->detach(drc, DEVICE(drc->dev), drc->detach_cb,

                         drc->detach_cb_opaque, NULL);

        }

    }

    return RTAS_OUT_SUCCESS;

}


--- a/source.c
+++ b/source.c
@@ -64,11 +64,11 @@

     }

+
+
+    monfd = qemu_mallocz(sizeof(mon_fd_t));
+
+    monfd->name = qemu_strdup(fdname);

     monfd->fd = fd;

static void do_getfd(Monitor *mon, const QDict *qdict)

{

    const char *fdname = qdict_get_str(qdict, "fdname");

    mon_fd_t *monfd;

    int fd;

    fd = qemu_chr_get_msgfd(mon->chr);

    if (fd == -1) {

        monitor_printf(mon, "getfd: no file descriptor supplied via SCM_RIGHTS\n");

        return;

    }

    if (qemu_isdigit(fdname[0])) {

        monitor_printf(mon, "getfd: monitor names may not begin with a number\n");

        return;

    }

    fd = dup(fd);

    if (fd == -1) {

        monitor_printf(mon, "Failed to dup() file descriptor: %s\n",

                       strerror(errno));

        return;

    }

    LIST_FOREACH(monfd, &mon->fds, next) {

        if (strcmp(monfd->name, fdname) != 0) {

            continue;

        }

        close(monfd->fd);

        monfd->fd = fd;

        return;

    }

    monfd = qemu_mallocz(sizeof(mon_fd_t));

    monfd->name = qemu_strdup(fdname);

    monfd->fd = fd;

    LIST_INSERT_HEAD(&mon->fds, monfd, next);

}


--- a/source.c
+++ b/source.c
@@ -1,20 +1,20 @@
 static void ehci_update_frindex(EHCIState *ehci, int uframes)
+
 {

     int i;
+
+
+
+    if (!ehci_enabled(ehci) && ehci->pstate == EST_INACTIVE) {

+        return;

+    }
+
+

+    for (i = 0; i < uframes; i++) {

         ehci->frindex++;

static void ehci_update_frindex(EHCIState *ehci, int uframes)

{

    int i;

    if (!ehci_enabled(ehci) && ehci->pstate == EST_INACTIVE) {

        return;

    }

    for (i = 0; i < uframes; i++) {

        ehci->frindex++;

        if (ehci->frindex == 0x00002000) {

            ehci_raise_irq(ehci, USBSTS_FLR);

        }

        if (ehci->frindex == 0x00004000) {

            ehci_raise_irq(ehci, USBSTS_FLR);

            ehci->frindex = 0;

            if (ehci->usbsts_frindex >= 0x00004000) {

                ehci->usbsts_frindex -= 0x00004000;

            } else {

                ehci->usbsts_frindex = 0;

            }

        }

    }

}


--- a/source.c
+++ b/source.c
@@ -20,11 +20,11 @@

     addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);

+
+
+    /* socket_listen() blocks in DNS lookups, so we must use a thread */
+
+    trace_qio_channel_socket_listen_async(ioc, addr);

     qio_task_run_in_thread(task,

void qio_channel_socket_listen_async(QIOChannelSocket *ioc,

                                     SocketAddressLegacy *addr,

                                     QIOTaskFunc callback,

                                     gpointer opaque,

                                     GDestroyNotify destroy)

{

    QIOTask *task = qio_task_new(

        OBJECT(ioc), callback, opaque, destroy);

    SocketAddressLegacy *addrCopy;

    addrCopy = QAPI_CLONE(SocketAddressLegacy, addr);

    /* socket_listen() blocks in DNS lookups, so we must use a thread */

    trace_qio_channel_socket_listen_async(ioc, addr);

    qio_task_run_in_thread(task,

                           qio_channel_socket_listen_worker,

                           addrCopy,

                           (GDestroyNotify)qapi_free_SocketAddressLegacy);

}


--- a/source.c
+++ b/source.c
@@ -55,11 +55,11 @@
         monitor_printf(mon, "%s\n", error_get_pretty(local_err));
         error_free(local_err);
         goto the_end;
+    /* create the snapshots */
+    bs1 = NULL;
+    while ((bs1 = bdrv_next(bs1))) {
+        if (bdrv_can_snapshot(bs1)) {
+            /* Write VM state size only to the image that contains the state */
             sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
             ret = bdrv_snapshot_create(bs1, sn);
             if (ret < 0) {

void hmp_savevm(Monitor *mon, const QDict *qdict)
{
    BlockDriverState *bs, *bs1;
    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
    int ret;
    QEMUFile *f;
    int saved_vm_running;
    uint64_t vm_state_size;
    qemu_timeval tv;
    struct tm tm;
    const char *name = qdict_get_try_str(qdict, "name");
    Error *local_err = NULL;
    /* Verify if there is a device that doesn't support snapshots and is writable */
    bs = NULL;
    while ((bs = bdrv_next(bs))) {
        if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
            continue;
        if (!bdrv_can_snapshot(bs)) {
            monitor_printf(mon, "Device '%s' is writable but does not support snapshots.\n",
                               bdrv_get_device_name(bs));
    bs = find_vmstate_bs();
    if (!bs) {
        monitor_printf(mon, "No block device can accept snapshots\n");
    saved_vm_running = runstate_is_running();
    vm_stop(RUN_STATE_SAVE_VM);
    memset(sn, 0, sizeof(*sn));
    /* fill auxiliary fields */
    qemu_gettimeofday(&tv);
    sn->date_sec = tv.tv_sec;
    sn->date_nsec = tv.tv_usec * 1000;
    sn->vm_clock_nsec = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
    if (name) {
        ret = bdrv_snapshot_find(bs, old_sn, name);
        if (ret >= 0) {
            pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
        } else {
            pstrcpy(sn->name, sizeof(sn->name), name);
    } else {
        /* cast below needed for OpenBSD where tv_sec is still 'long' */
        localtime_r((const time_t *)&tv.tv_sec, &tm);
        strftime(sn->name, sizeof(sn->name), "vm-%Y%m%d%H%M%S", &tm);
    /* Delete old snapshots of the same name */
    if (name && del_existing_snapshots(mon, name) < 0) {
        goto the_end;
    /* save the VM state */
    f = qemu_fopen_bdrv(bs, 1);
    if (!f) {
        monitor_printf(mon, "Could not open VM state file\n");
        goto the_end;
    ret = qemu_savevm_state(f, &local_err);
    vm_state_size = qemu_ftell(f);
    qemu_fclose(f);
    if (ret < 0) {
        monitor_printf(mon, "%s\n", error_get_pretty(local_err));
        error_free(local_err);
        goto the_end;
    /* create the snapshots */
    bs1 = NULL;
    while ((bs1 = bdrv_next(bs1))) {
        if (bdrv_can_snapshot(bs1)) {
            /* Write VM state size only to the image that contains the state */
            sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
            ret = bdrv_snapshot_create(bs1, sn);
            if (ret < 0) {
                monitor_printf(mon, "Error while creating snapshot on '%s'\n",
                               bdrv_get_device_name(bs1));
 the_end:
    if (saved_vm_running) {
        vm_start();


--- a/source.c
+++ b/source.c
@@ -35,11 +35,11 @@
     position = buffer - ctx_pic->bitstream;

     if (is_slice_short(ctx))
+
+        fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count],
+
+                         position, size);
+
     else

         fill_slice_long(avctx, &ctx_pic->slice_long[ctx_pic->slice_count],

static int dxva2_h264_decode_slice(AVCodecContext *avctx,

                                   const uint8_t *buffer,

                                   uint32_t size)

{

    const H264Context *h = avctx->priv_data;

    struct dxva_context *ctx = avctx->hwaccel_context;

    const Picture *current_picture = h->cur_pic_ptr;

    struct dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;

    unsigned position;

    if (ctx_pic->slice_count >= MAX_SLICES)

        return -1;

    if (!ctx_pic->bitstream)

        ctx_pic->bitstream = buffer;

    ctx_pic->bitstream_size += size;

    position = buffer - ctx_pic->bitstream;

    if (is_slice_short(ctx))

        fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count],

                         position, size);

    else

        fill_slice_long(avctx, &ctx_pic->slice_long[ctx_pic->slice_count],

                        position, size);

    ctx_pic->slice_count++;

    if (h->slice_type != AV_PICTURE_TYPE_I && h->slice_type != AV_PICTURE_TYPE_SI)

        ctx_pic->pp.wBitFields &= ~(1 << 15); /* Set IntraPicFlag to 0 */

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -39,11 +39,11 @@
         tcp_chr_disconnect(chr);

     }
+
+    object_unref(OBJECT(s->ioc));
+
+    s->ioc = QIO_CHANNEL(tioc);
+

     qio_channel_tls_handshake(tioc,

static void tcp_chr_tls_init(CharDriverState *chr)

{

    TCPCharDriver *s = chr->opaque;

    QIOChannelTLS *tioc;

    Error *err = NULL;

    if (s->is_listen) {

        tioc = qio_channel_tls_new_server(

            s->ioc, s->tls_creds,

            NULL, /* XXX Use an ACL */

            &err);

    } else {

        tioc = qio_channel_tls_new_client(

            s->ioc, s->tls_creds,

            s->addr->u.inet->host,

            &err);

    }

    if (tioc == NULL) {

        error_free(err);

        tcp_chr_disconnect(chr);

    }

    object_unref(OBJECT(s->ioc));

    s->ioc = QIO_CHANNEL(tioc);

    qio_channel_tls_handshake(tioc,

                              tcp_chr_tls_handshake,

                              chr,

                              NULL);

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
 {

     QEDCheck check = {
+
         .s = s,

         .result = result,

int qed_check(BDRVQEDState *s, BdrvCheckResult *result, bool fix)

{

    QEDCheck check = {

        .s = s,

        .result = result,

        .nclusters = qed_bytes_to_clusters(s, s->file_size),

        .request = { .l2_table = NULL },

        .fix = fix,

    };

    int ret;

    check.used_clusters = g_try_malloc0(((check.nclusters + 31) / 32) *

                                        sizeof(check.used_clusters[0]));

    if (check.nclusters && check.used_clusters == NULL) {

        return -ENOMEM;

    }

    check.result->bfi.total_clusters =

        (s->header.image_size + s->header.cluster_size - 1) /

            s->header.cluster_size;

    ret = qed_check_l1_table(&check, s->l1_table);

    if (ret == 0) {

        /* Only check for leaks if entire image was scanned successfully */

        qed_check_for_leaks(&check);

        if (fix) {

            qed_check_mark_clean(s, result);

        }

    }

    g_free(check.used_clusters);

    return ret;

}


--- a/source.c
+++ b/source.c
@@ -26,11 +26,11 @@

     sigaddset(&set, SIGUSR1);

+    pthread_sigmask(SIG_UNBLOCK, &set, NULL);
+
+
+
+    memset(&sigact, 0, sizeof(sigact));

     sigact.sa_handler = cpu_signal;

static void block_io_signals(void)

{

    sigset_t set;

    struct sigaction sigact;

    sigemptyset(&set);

    sigaddset(&set, SIGUSR2);

    sigaddset(&set, SIGIO);

    sigaddset(&set, SIGALRM);

    sigaddset(&set, SIGCHLD);

    pthread_sigmask(SIG_BLOCK, &set, NULL);

    sigemptyset(&set);

    sigaddset(&set, SIGUSR1);

    pthread_sigmask(SIG_UNBLOCK, &set, NULL);

    memset(&sigact, 0, sizeof(sigact));

    sigact.sa_handler = cpu_signal;

    sigaction(SIGUSR1, &sigact, NULL);

}


--- a/source.c
+++ b/source.c
@@ -1,9 +1,9 @@
 static gboolean pty_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
+
+{
+
+    CharDriverState *chr = opaque;
+
     PtyCharDriver *s = chr->opaque;

     gsize size, len;

static gboolean pty_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)

{

    CharDriverState *chr = opaque;

    PtyCharDriver *s = chr->opaque;

    gsize size, len;

    uint8_t buf[READ_BUF_LEN];

    GIOStatus status;

    len = sizeof(buf);

    if (len > s->read_bytes)

        len = s->read_bytes;

    if (len == 0)

        return FALSE;

    status = g_io_channel_read_chars(s->fd, (gchar *)buf, len, &size, NULL);

    if (status != G_IO_STATUS_NORMAL) {

        pty_chr_state(chr, 0);

        return FALSE;

    } else {

        pty_chr_state(chr, 1);

        qemu_chr_be_write(chr, buf, size);

    }

    return TRUE;

}


--- a/source.c
+++ b/source.c
@@ -36,11 +36,11 @@

     }

+    s->esr = 0;
+
+    memset(s->icr, 0, sizeof(s->icr));
+
+    s->divide_conf = 0;

     s->count_shift = 0;

void apic_init_reset(DeviceState *dev)

{

    APICCommonState *s = APIC_COMMON(dev);

    APICCommonClass *info = APIC_COMMON_GET_CLASS(s);

    int i;

    if (!s) {

        return;

    }

    s->tpr = 0;

    s->spurious_vec = 0xff;

    s->log_dest = 0;

    s->dest_mode = 0xf;

    memset(s->isr, 0, sizeof(s->isr));

    memset(s->tmr, 0, sizeof(s->tmr));

    memset(s->irr, 0, sizeof(s->irr));

    for (i = 0; i < APIC_LVT_NB; i++) {

        s->lvt[i] = APIC_LVT_MASKED;

    }

    s->esr = 0;

    memset(s->icr, 0, sizeof(s->icr));

    s->divide_conf = 0;

    s->count_shift = 0;

    s->initial_count = 0;

    s->initial_count_load_time = 0;

    s->next_time = 0;

    s->wait_for_sipi = !cpu_is_bsp(s->cpu);

    if (s->timer) {

        timer_del(s->timer);

    }

    s->timer_expiry = -1;

    if (info->reset) {

        info->reset(s);

    }

}


--- a/source.c
+++ b/source.c
@@ -1,20 +1,20 @@
 static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,

+                                  uint64_t value, unsigned size)
+
+{
+
+    FWCfgState *s = opaque;
+
     uint8_t buf[8];
+
     unsigned i;
+

+
     switch (size) {
+
+    case 1:

         buf[0] = value;

static void fw_cfg_data_mem_write(void *opaque, hwaddr addr,

                                  uint64_t value, unsigned size)

{

    FWCfgState *s = opaque;

    uint8_t buf[8];

    unsigned i;

    switch (size) {

    case 1:

        buf[0] = value;

        break;

    case 2:

        stw_he_p(buf, value);

        break;

    case 4:

        stl_he_p(buf, value);

        break;

    case 8:

        stq_he_p(buf, value);

        break;

    default:

        abort();

    }

    for (i = 0; i < size; ++i) {

        fw_cfg_write(s, buf[i]);

    }

}


--- a/source.c
+++ b/source.c
@@ -1,8 +1,8 @@
+int bdrv_check(BlockDriverState *bs)

 {

+    if (bs->drv->bdrv_check == NULL) {

         return -ENOTSUP;

int bdrv_check(BlockDriverState *bs)

{

    if (bs->drv->bdrv_check == NULL) {

        return -ENOTSUP;

    }

    return bs->drv->bdrv_check(bs);

}


--- a/source.c
+++ b/source.c
@@ -5,11 +5,11 @@
 {

     DisplaySurface *surface = qemu_create_displaysurface(w, h);
+
+    pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];
+
+    pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];
+
     pixman_image_t *glyph;

     int len, x, y, i;

static DisplaySurface *qemu_create_message_surface(int w, int h,

                                                   const char *msg)

{

    DisplaySurface *surface = qemu_create_displaysurface(w, h);

    pixman_color_t bg = color_table_rgb[0][COLOR_BLACK];

    pixman_color_t fg = color_table_rgb[0][COLOR_WHITE];

    pixman_image_t *glyph;

    int len, x, y, i;

    len = strlen(msg);

    x = (w / FONT_WIDTH  - len) / 2;

    y = (h / FONT_HEIGHT - 1)   / 2;

    for (i = 0; i < len; i++) {

        glyph = qemu_pixman_glyph_from_vgafont(FONT_HEIGHT, vgafont16, msg[i]);

        qemu_pixman_glyph_render(glyph, surface->image, &fg, &bg,

                                 x+i, y, FONT_WIDTH, FONT_HEIGHT);

        qemu_pixman_image_unref(glyph);

    }

    return surface;

}


--- a/source.c
+++ b/source.c
@@ -1,9 +1,9 @@
 static int get_packet_size(const uint8_t *buf, int size)

 {
+
+    int score, fec_score, dvhs_score;
+

     if (size < (TS_FEC_PACKET_SIZE * 5 + 1))

static int get_packet_size(const uint8_t *buf, int size)

{

    int score, fec_score, dvhs_score;

    if (size < (TS_FEC_PACKET_SIZE * 5 + 1))

        return AVERROR_INVALIDDATA;

    score      = analyze(buf, size, TS_PACKET_SIZE, NULL);

    dvhs_score = analyze(buf, size, TS_DVHS_PACKET_SIZE, NULL);

    fec_score  = analyze(buf, size, TS_FEC_PACKET_SIZE, NULL);

    av_dlog(NULL, "score: %d, dvhs_score: %d, fec_score: %d \n",

            score, dvhs_score, fec_score);

    if (score > fec_score && score > dvhs_score)

        return TS_PACKET_SIZE;

    else if (dvhs_score > score && dvhs_score > fec_score)

        return TS_DVHS_PACKET_SIZE;

    else if (score < fec_score && dvhs_score < fec_score)

        return TS_FEC_PACKET_SIZE;

    else

        return AVERROR_INVALIDDATA;

}


--- a/source.c
+++ b/source.c
@@ -5,7 +5,7 @@
     uint32_t i;

+
     /* level triggered interrupt */

     if (p->regs[R_MER] & 2) {

static void update_irq(struct xlx_pic *p)

{

    uint32_t i;

    /* level triggered interrupt */

    if (p->regs[R_MER] & 2) {

        p->regs[R_ISR] |= p->irq_pin_state & ~p->c_kind_of_intr;

    }

    /* Update the pending register.  */

    p->regs[R_IPR] = p->regs[R_ISR] & p->regs[R_IER];

    /* Update the vector register.  */

    for (i = 0; i < 32; i++) {

        if (p->regs[R_IPR] & (1 << i))

            break;

    }

    if (i == 32)

        i = ~0;

    p->regs[R_IVR] = i;

    qemu_set_irq(p->parent_irq, (p->regs[R_MER] & 1) && p->regs[R_IPR]);

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
 void ff_get_guid(AVIOContext *s, ff_asf_guid *g)

+{

     assert(sizeof(*g) == 16);

void ff_get_guid(AVIOContext *s, ff_asf_guid *g)

{

    assert(sizeof(*g) == 16);

    avio_read(s, *g, sizeof(*g));

}


static int mov_read_esds(MOVContext *c, ByteIOContext *pb, MOV_atom_t atom)

{

    AVStream *st = c->fc->streams[c->fc->nb_streams-1];

    int tag, len;

    get_be32(pb); /* version + flags */

    len = mp4_read_descr(c, pb, &tag);

    if (tag == MP4ESDescrTag) {

        get_be16(pb); /* ID */

        get_byte(pb); /* priority */

    } else

        get_be16(pb); /* ID */

    len = mp4_read_descr(c, pb, &tag);

    if (tag == MP4DecConfigDescrTag) {

        int object_type_id = get_byte(pb);

        get_byte(pb); /* stream type */

        get_be24(pb); /* buffer size db */

        get_be32(pb); /* max bitrate */

        get_be32(pb); /* avg bitrate */

        st->codec->codec_id= codec_get_id(ff_mp4_obj_type, object_type_id);

        dprintf(c->fc, "esds object type id %d\n", object_type_id);

        len = mp4_read_descr(c, pb, &tag);

        if (tag == MP4DecSpecificDescrTag) {

            dprintf(c->fc, "Specific MPEG4 header len=%d\n", len);

            st->codec->extradata = av_mallocz(len + FF_INPUT_BUFFER_PADDING_SIZE);

            if (!st->codec->extradata)

                return AVERROR(ENOMEM);

            get_buffer(pb, st->codec->extradata, len);

            st->codec->extradata_size = len;

            /* from mplayer */

            if ((*st->codec->extradata >> 3) == 29) {

                st->codec->codec_id = CODEC_ID_MP3ON4;

            }

        }

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -25,11 +25,11 @@
 #ifdef DEBUG_ALLOC2

     printf("alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n",
+
+            size,
+
+            (s->free_cluster_index - nb_clusters) << s->cluster_bits);
+
 #endif

     return (s->free_cluster_index - nb_clusters) << s->cluster_bits;

static int64_t alloc_clusters_noref(BlockDriverState *bs, int64_t size)

{

    BDRVQcowState *s = bs->opaque;

    int i, nb_clusters;

    nb_clusters = size_to_clusters(s, size);

retry:

    for(i = 0; i < nb_clusters; i++) {

        int64_t i = s->free_cluster_index++;

        if (get_refcount(bs, i) != 0)

            goto retry;

    }

#ifdef DEBUG_ALLOC2

    printf("alloc_clusters: size=%" PRId64 " -> %" PRId64 "\n",

            size,

            (s->free_cluster_index - nb_clusters) << s->cluster_bits);

#endif

    return (s->free_cluster_index - nb_clusters) << s->cluster_bits;

}


--- a/source.c
+++ b/source.c
@@ -22,10 +22,10 @@

               env->CP0_Wired;

+    } while (idx == prev_idx);
+
+    prev_idx = idx;
+
+    return idx;

 }

uint32_t cpu_mips_get_random (CPUMIPSState *env)

{

    static uint32_t seed = 1;

    static uint32_t prev_idx = 0;

    uint32_t idx;

    /* Don't return same value twice, so get another value */

    do {

        /* Use a simple algorithm of Linear Congruential Generator

         * from ISO/IEC 9899 standard. */

        seed = 1103515245 * seed + 12345;

        idx = (seed >> 16) % (env->tlb->nb_tlb - env->CP0_Wired) +

              env->CP0_Wired;

    } while (idx == prev_idx);

    prev_idx = idx;

    return idx;

}


static void init_timetables( FM_OPL *OPL , int ARRATE , int DRRATE )

{

	int i;

	double rate;

	/* make attack rate & decay rate tables */

	for (i = 0;i < 4;i++) OPL->AR_TABLE[i] = OPL->DR_TABLE[i] = 0;

	for (i = 4;i <= 60;i++){

		rate  = OPL->freqbase;						/* frequency rate */

		if( i < 60 ) rate *= 1.0+(i&3)*0.25;		/* b0-1 : x1 , x1.25 , x1.5 , x1.75 */

		rate *= 1<<((i>>2)-1);						/* b2-5 : shift bit */

		rate *= (double)(EG_ENT<<ENV_BITS);

		OPL->AR_TABLE[i] = rate / ARRATE;

		OPL->DR_TABLE[i] = rate / DRRATE;

	}

	for (i = 60; i < ARRAY_SIZE(OPL->AR_TABLE); i++)

	{

		OPL->AR_TABLE[i] = EG_AED-1;

		OPL->DR_TABLE[i] = OPL->DR_TABLE[60];

	}

#if 0

	for (i = 0;i < 64 ;i++){	/* make for overflow area */

		LOG(LOG_WAR,("rate %2d , ar %f ms , dr %f ms \n",i,

			((double)(EG_ENT<<ENV_BITS) / OPL->AR_TABLE[i]) * (1000.0 / OPL->rate),

			((double)(EG_ENT<<ENV_BITS) / OPL->DR_TABLE[i]) * (1000.0 / OPL->rate) ));

	}

#endif

}


--- a/source.c
+++ b/source.c
@@ -3,15 +3,15 @@
                                       int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,

                                       int64_t  in_ch_layout, enum AVSampleFormat  in_sample_fmt, int  in_sample_rate,
+
+                                      int log_offset, void *log_ctx){
+
+    if(!s) s= swr_alloc();
+
+    if(!s) return NULL;
+
+
+
     s->log_level_offset= log_offset;

     s->log_ctx= log_ctx;

struct SwrContext *swr_alloc_set_opts(struct SwrContext *s,

                                      int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate,

                                      int64_t  in_ch_layout, enum AVSampleFormat  in_sample_fmt, int  in_sample_rate,

                                      int log_offset, void *log_ctx){

    if(!s) s= swr_alloc();

    if(!s) return NULL;

    s->log_level_offset= log_offset;

    s->log_ctx= log_ctx;

    av_opt_set_int(s, "ocl", out_ch_layout,   0);

    av_opt_set_int(s, "osf", out_sample_fmt,  0);

    av_opt_set_int(s, "osr", out_sample_rate, 0);

    av_opt_set_int(s, "icl", in_ch_layout,    0);

    av_opt_set_int(s, "isf", in_sample_fmt,   0);

    av_opt_set_int(s, "isr", in_sample_rate,  0);

    av_opt_set_int(s, "tsf", AV_SAMPLE_FMT_NONE,   0);

    av_opt_set_int(s, "ich", av_get_channel_layout_nb_channels(s-> in_ch_layout), 0);

    av_opt_set_int(s, "och", av_get_channel_layout_nb_channels(s->out_ch_layout), 0);

    av_opt_set_int(s, "uch", 0, 0);

    return s;

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
+void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,

+                         const char *name, Error **errp)

 {

void visit_get_next_type(Visitor *v, int *obj, const int *qtypes,

                         const char *name, Error **errp)

{

    if (v->get_next_type) {

        v->get_next_type(v, obj, qtypes, name, errp);

    }

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
+static uint32_t add_weights(uint32_t w1, uint32_t w2)
+
+{

     uint32_t max = (w1 & 0xFF) > (w2 & 0xFF) ? (w1 & 0xFF) : (w2 & 0xFF);

static uint32_t add_weights(uint32_t w1, uint32_t w2)

{

    uint32_t max = (w1 & 0xFF) > (w2 & 0xFF) ? (w1 & 0xFF) : (w2 & 0xFF);

    return ((w1 & 0xFFFFFF00) + (w2 & 0xFFFFFF00)) | (1 + max);

}


--- a/source.c
+++ b/source.c
@@ -12,11 +12,11 @@

         assert(replay_data_kind == EVENT_INSTRUCTION);

+        return event == EVENT_INSTRUCTION;
+
+    }
+
+

     while (true) {

bool replay_next_event_is(int event)

{

    bool res = false;

    /* nothing to skip - not all instructions used */

    if (replay_state.instructions_count != 0) {

        assert(replay_data_kind == EVENT_INSTRUCTION);

        return event == EVENT_INSTRUCTION;

    }

    while (true) {

        if (event == replay_data_kind) {

            res = true;

        }

        switch (replay_data_kind) {

        case EVENT_SHUTDOWN:

            replay_finish_event();

            qemu_system_shutdown_request();

            break;

        default:

            /* clock, time_t, checkpoint and other events */

            return res;

        }

    }

    return res;

}


--- a/source.c
+++ b/source.c
@@ -42,11 +42,11 @@

                since this might have been the only active voice */

+            audio_recalc_and_notify_capture (cap);
+
+        }
+
+        sc = sc1;

     }

static void audio_detach_capture (HWVoiceOut *hw)

{

    SWVoiceCap *sc = hw->cap_head.lh_first;

    while (sc) {

        SWVoiceCap *sc1 = sc->entries.le_next;

        SWVoiceOut *sw = &sc->sw;

        CaptureVoiceOut *cap = sc->cap;

        int was_active = sw->active;

        if (sw->rate) {

            st_rate_stop (sw->rate);

            sw->rate = NULL;

        }

        LIST_REMOVE (sw, entries);

        LIST_REMOVE (sc, entries);

        qemu_free (sc);

        if (was_active) {

            /* We have removed soft voice from the capture:

               this might have changed the overall status of the capture

               since this might have been the only active voice */

            audio_recalc_and_notify_capture (cap);

        }

        sc = sc1;

    }

}


--- a/source.c
+++ b/source.c
@@ -46,11 +46,11 @@

+    frame_bits = process_exponents(s, mdct_coef, exp_shift, exp, exp_strategy,
+
+                                   encoded_exp, num_exp_groups, grouped_exp);
+
+

     compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);

static int ac3_encode_frame(AVCodecContext *avctx,

                            unsigned char *frame, int buf_size, void *data)

{

    AC3EncodeContext *s = avctx->priv_data;

    const int16_t *samples = data;

    int16_t planar_samples[AC3_MAX_CHANNELS][AC3_BLOCK_SIZE+AC3_FRAME_SIZE];

    int32_t mdct_coef[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];

    uint8_t exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];

    uint8_t exp_strategy[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];

    uint8_t encoded_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];

    uint8_t num_exp_groups[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];

    uint8_t grouped_exp[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_EXP_GROUPS];

    uint8_t bap[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];

    int8_t exp_shift[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS];

    uint16_t qmant[AC3_MAX_BLOCKS][AC3_MAX_CHANNELS][AC3_MAX_COEFS];

    int frame_bits;

    if (s->bit_alloc.sr_code == 1)

        adjust_frame_size(s);

    deinterleave_input_samples(s, samples, planar_samples);

    apply_mdct(s, planar_samples, exp_shift, mdct_coef);

    frame_bits = process_exponents(s, mdct_coef, exp_shift, exp, exp_strategy,

                                   encoded_exp, num_exp_groups, grouped_exp);

    compute_bit_allocation(s, bap, encoded_exp, exp_strategy, frame_bits);

    quantize_mantissas(s, mdct_coef, exp_shift, encoded_exp, bap, qmant);

    output_frame(s, frame, exp_strategy, num_exp_groups, grouped_exp, bap, qmant);

    return s->frame_size;

}


--- a/source.c
+++ b/source.c
@@ -1,8 +1,8 @@
 static av_cold int init_buffers(SANMVideoContext *ctx)
+
+{
+
+    av_fast_padded_malloc(&ctx->frm0, &ctx->frm0_size, ctx->buf_size);

     av_fast_padded_malloc(&ctx->frm1, &ctx->frm1_size, ctx->buf_size);

static av_cold int init_buffers(SANMVideoContext *ctx)

{

    av_fast_padded_malloc(&ctx->frm0, &ctx->frm0_size, ctx->buf_size);

    av_fast_padded_malloc(&ctx->frm1, &ctx->frm1_size, ctx->buf_size);

    av_fast_padded_malloc(&ctx->frm2, &ctx->frm2_size, ctx->buf_size);

    if (!ctx->version)

        av_fast_padded_malloc(&ctx->stored_frame,

                              &ctx->stored_frame_size, ctx->buf_size);

    if (!ctx->frm0 || !ctx->frm1 || !ctx->frm2 ||

        (!ctx->stored_frame && !ctx->version)) {

        destroy_buffers(ctx);

        return AVERROR(ENOMEM);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -13,11 +13,11 @@
     ebml_master targets;

     int ret;
+
+
+
+    if (!tags->pos) {
+
         ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TAGS, avio_tell(s->pb));

         if (ret < 0) return ret;

static int mkv_write_tag_targets(AVFormatContext *s,

                                 unsigned int elementid, unsigned int uid,

                                 ebml_master *tags, ebml_master* tag)

{

    AVIOContext *pb;

    MatroskaMuxContext *mkv = s->priv_data;

    ebml_master targets;

    int ret;

    if (!tags->pos) {

        ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_TAGS, avio_tell(s->pb));

        if (ret < 0) return ret;

        start_ebml_master_crc32(s->pb, &mkv->tags_bc, tags, MATROSKA_ID_TAGS, 0);

    }

    pb = mkv->tags_bc;

    *tag     = start_ebml_master(pb, MATROSKA_ID_TAG,       0);

    targets = start_ebml_master(pb, MATROSKA_ID_TAGTARGETS, 0);

    if (elementid)

        put_ebml_uint(pb, elementid, uid);

    end_ebml_master(pb, targets);

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -5,5 +5,5 @@
 {

     return is_write && size == 2;
+
+}

static bool fw_cfg_ctl_mem_valid(void *opaque, target_phys_addr_t addr,

                                 unsigned size, bool is_write)

{

    return is_write && size == 2;

}


--- a/source.c
+++ b/source.c
@@ -1,19 +1,19 @@
+static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r,
+
+                       PAMMemoryRegion *mem)
+
 {
+
+    if (mem->initialized) {
+
+        memory_region_del_subregion(d->system_memory, &mem->mem);
+
         memory_region_destroy(&mem->mem);
+
     }

+
+
     //    printf("ISA mapping %08x-0x%08x: %d\n", start, end, r);

     switch(r) {

static void update_pam(PCII440FXState *d, uint32_t start, uint32_t end, int r,

                       PAMMemoryRegion *mem)

{

    if (mem->initialized) {

        memory_region_del_subregion(d->system_memory, &mem->mem);

        memory_region_destroy(&mem->mem);

    }

    //    printf("ISA mapping %08x-0x%08x: %d\n", start, end, r);

    switch(r) {

    case 3:

        /* RAM */

        memory_region_init_alias(&mem->mem, "pam-ram", d->ram_memory,

                                 start, end - start);

        break;

    case 1:

        /* ROM (XXX: not quite correct) */

        memory_region_init_alias(&mem->mem, "pam-rom", d->ram_memory,

                                 start, end - start);

        memory_region_set_readonly(&mem->mem, true);

        break;

    case 2:

    case 0:

        /* XXX: should distinguish read/write cases */

        memory_region_init_alias(&mem->mem, "pam-pci", d->pci_address_space,

                                 start, end - start);

        break;

    }

    memory_region_add_subregion_overlap(d->system_memory,

                                        start, &mem->mem, 1);

    mem->initialized = true;

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
 static int ide_drive_pio_post_load(void *opaque, int version_id)

+{

     IDEState *s = opaque;

static int ide_drive_pio_post_load(void *opaque, int version_id)

{

    IDEState *s = opaque;

    if (s->end_transfer_fn_idx > ARRAY_SIZE(transfer_end_table)) {

        return -EINVAL;

    }

    s->end_transfer_func = transfer_end_table[s->end_transfer_fn_idx];

    s->data_ptr = s->io_buffer + s->cur_io_buffer_offset;

    s->data_end = s->data_ptr + s->cur_io_buffer_len;

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -2,7 +2,7 @@

     pixel *src = (pixel*)_src;

+    int stride = _stride/sizeof(pixel);

     const int dc= (  src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;

static void FUNCC(pred4x4_top_dc)(uint8_t *_src, const uint8_t *topright, int _stride){

    pixel *src = (pixel*)_src;

    int stride = _stride/sizeof(pixel);

    const int dc= (  src[-stride] + src[1-stride] + src[2-stride] + src[3-stride] + 2) >>2;

    ((pixel4*)(src+0*stride))[0]=

    ((pixel4*)(src+1*stride))[0]=

    ((pixel4*)(src+2*stride))[0]=

    ((pixel4*)(src+3*stride))[0]= PIXEL_SPLAT_X4(dc);

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
 static int gen_neon_zip(int rd, int rm, int size, int q)

+{

     TCGv tmp, tmp2;

static int gen_neon_zip(int rd, int rm, int size, int q)

{

    TCGv tmp, tmp2;

    if (size == 3 || (!q && size == 2)) {

        return 1;

    }

    tmp = tcg_const_i32(rd);

    tmp2 = tcg_const_i32(rm);

    if (q) {

        switch (size) {

        case 0:

            gen_helper_neon_qzip8(tmp, tmp2);

            break;

        case 1:

            gen_helper_neon_qzip16(tmp, tmp2);

            break;

        case 2:

            gen_helper_neon_qzip32(tmp, tmp2);

            break;

        default:

            abort();

        }

    } else {

        switch (size) {

        case 0:

            gen_helper_neon_zip8(tmp, tmp2);

            break;

        case 1:

            gen_helper_neon_zip16(tmp, tmp2);

            break;

        default:

            abort();

        }

    }

    tcg_temp_free_i32(tmp);

    tcg_temp_free_i32(tmp2);

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -3,10 +3,10 @@
 {

     CompareState *s = COLO_COMPARE(obj);
+
+
+
+    qemu_chr_fe_deinit(&s->chr_pri_in);

     qemu_chr_fe_deinit(&s->chr_sec_in);

static void colo_compare_finalize(Object *obj)

{

    CompareState *s = COLO_COMPARE(obj);

    qemu_chr_fe_deinit(&s->chr_pri_in);

    qemu_chr_fe_deinit(&s->chr_sec_in);

    qemu_chr_fe_deinit(&s->chr_out);

    g_queue_free(&s->conn_list);

    if (qemu_thread_is_self(&s->thread)) {

        /* compare connection */

        g_queue_foreach(&s->conn_list, colo_compare_connection, s);

        qemu_thread_join(&s->thread);

    }

    g_free(s->pri_indev);

    g_free(s->sec_indev);

    g_free(s->outdev);

}


--- a/source.c
+++ b/source.c
@@ -1,11 +1,11 @@
 static int tta_decode_init(AVCodecContext * avctx)
 {
     TTAContext *s = avctx->priv_data;
+    int i;
+    s->avctx = avctx;
+    // 30bytes includes a seektable with one frame
+    if (avctx->extradata_size < 30)
+    init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size);
     if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("TTA1")))
     {
         /* signature */

static int tta_decode_init(AVCodecContext * avctx)
{
    TTAContext *s = avctx->priv_data;
    int i;
    s->avctx = avctx;
    // 30bytes includes a seektable with one frame
    if (avctx->extradata_size < 30)
    init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size);
    if (show_bits_long(&s->gb, 32) == bswap_32(ff_get_fourcc("TTA1")))
    {
        /* signature */
        skip_bits(&s->gb, 32);
//        if (get_bits_long(&s->gb, 32) != bswap_32(ff_get_fourcc("TTA1"))) {
//            av_log(s->avctx, AV_LOG_ERROR, "Missing magic\n");
//            return -1;
//        }
        s->flags = get_le16(&s->gb);
        if (s->flags != 1 && s->flags != 3)
        {
            av_log(s->avctx, AV_LOG_ERROR, "Invalid flags\n");
        s->is_float = (s->flags == FORMAT_FLOAT);
        avctx->channels = s->channels = get_le16(&s->gb);
        avctx->bits_per_sample = get_le16(&s->gb);
        s->bps = (avctx->bits_per_sample + 7) / 8;
        avctx->sample_rate = get_le32(&s->gb);
        if(avctx->sample_rate > 1000000){ //prevent FRAME_TIME * avctx->sample_rate from overflowing and sanity check
            av_log(avctx, AV_LOG_ERROR, "sample_rate too large\n");
        s->data_length = get_le32(&s->gb);
        skip_bits(&s->gb, 32); // CRC32 of header
        if (s->is_float)
        {
            avctx->sample_fmt = SAMPLE_FMT_FLT;
            av_log(s->avctx, AV_LOG_ERROR, "Unsupported sample format. Please contact the developers.\n");
        else switch(s->bps) {
//            case 1: avctx->sample_fmt = SAMPLE_FMT_U8; break;
            case 2: avctx->sample_fmt = SAMPLE_FMT_S16; break;
//            case 3: avctx->sample_fmt = SAMPLE_FMT_S24; break;
            case 4: avctx->sample_fmt = SAMPLE_FMT_S32; break;
            default:
                av_log(s->avctx, AV_LOG_ERROR, "Invalid/unsupported sample format. Please contact the developers.\n");
        // FIXME: horribly broken, but directly from reference source
#define FRAME_TIME 1.04489795918367346939
        s->frame_length = (int)(FRAME_TIME * avctx->sample_rate);
        s->last_frame_length = s->data_length % s->frame_length;
        s->total_frames = s->data_length / s->frame_length +
                        (s->last_frame_length ? 1 : 0);
        av_log(s->avctx, AV_LOG_DEBUG, "flags: %x chans: %d bps: %d rate: %d block: %d\n",
            s->flags, avctx->channels, avctx->bits_per_sample, avctx->sample_rate,
            avctx->block_align);
        av_log(s->avctx, AV_LOG_DEBUG, "data_length: %d frame_length: %d last: %d total: %d\n",
            s->data_length, s->frame_length, s->last_frame_length, s->total_frames);
        // FIXME: seek table
        for (i = 0; i < s->total_frames; i++)
            skip_bits(&s->gb, 32);
        skip_bits(&s->gb, 32); // CRC32 of seektable
        s->decode_buffer = av_mallocz(sizeof(int32_t)*s->frame_length*s->channels);
    } else {
        av_log(avctx, AV_LOG_ERROR, "Wrong extradata present\n");
    return 0;


--- a/source.c
+++ b/source.c
@@ -32,11 +32,11 @@

                st->codec->sample_rate, sample_rate);

+        goto fail;
+
+    }
+
+    avpriv_set_pts_info(st, 64, 1, sample_rate);

static av_cold int audio_write_header(AVFormatContext *s1)

{

    AlsaData *s = s1->priv_data;

    AVStream *st;

    unsigned int sample_rate;

    enum AVCodecID codec_id;

    int res;

    st = s1->streams[0];

    sample_rate = st->codec->sample_rate;

    codec_id    = st->codec->codec_id;

    res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,

        st->codec->channels, &codec_id);

    if (sample_rate != st->codec->sample_rate) {

        av_log(s1, AV_LOG_ERROR,

               "sample rate %d not available, nearest is %d\n",

               st->codec->sample_rate, sample_rate);

        goto fail;

    }

    avpriv_set_pts_info(st, 64, 1, sample_rate);

    return res;

fail:

    snd_pcm_close(s->h);

    return AVERROR(EIO);

}


--- a/source.c
+++ b/source.c
@@ -1,8 +1,8 @@
 static bool event_notifier_poll(void *opaque)

+{
+
+    EventNotifier *e = opaque;

     AioContext *ctx = container_of(e, AioContext, notifier);

static bool event_notifier_poll(void *opaque)

{

    EventNotifier *e = opaque;

    AioContext *ctx = container_of(e, AioContext, notifier);

    return atomic_read(&ctx->notified);

}


--- a/source.c
+++ b/source.c
@@ -1,6 +1,6 @@
 void acpi_add_table(GArray *table_offsets, GArray *table_data)
+
+{

     uint32_t offset = cpu_to_le32(table_data->len);

void acpi_add_table(GArray *table_offsets, GArray *table_data)

{

    uint32_t offset = cpu_to_le32(table_data->len);

    g_array_append_val(table_offsets, offset);

}


--- a/source.c
+++ b/source.c
@@ -10,11 +10,11 @@

+    if (avctx->width > 4095 || avctx->height > 4095) {
+
+        av_log(avctx, AV_LOG_ERROR,
+
+               "Input dimensions too large, input must be max 4096x4096 !\n");

         return AVERROR_INVALIDDATA;

static av_cold int flashsv_encode_init(AVCodecContext *avctx)

{

    FlashSVContext *s = avctx->priv_data;

    s->avctx = avctx;

    if (avctx->width > 4095 || avctx->height > 4095) {

        av_log(avctx, AV_LOG_ERROR,

               "Input dimensions too large, input must be max 4096x4096 !\n");

        return AVERROR_INVALIDDATA;

    }

    // Needed if zlib unused or init aborted before deflateInit

    memset(&s->zstream, 0, sizeof(z_stream));

    s->last_key_frame = 0;

    s->image_width  = avctx->width;

    s->image_height = avctx->height;

    s->tmpblock  = av_mallocz(3 * 256 * 256);

    s->encbuffer = av_mallocz(s->image_width * s->image_height * 3);

    if (!s->tmpblock || !s->encbuffer) {

        av_log(avctx, AV_LOG_ERROR, "Memory allocation failed.\n");

        return AVERROR(ENOMEM);

    }

    avctx->coded_frame = av_frame_alloc();

    if (!avctx->coded_frame) {

        flashsv_encode_end(avctx);

        return AVERROR(ENOMEM);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -63,11 +63,11 @@
     env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);

     env->eip = offset;
+
+    env->segs[R_CS].selector = selector;
+
+    env->segs[R_CS].base = (uint8_t *)(selector << 4);
+
     env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);

 }

static void do_interrupt_real(int intno, int is_int, int error_code,

                                 unsigned int next_eip)

{

    SegmentCache *dt;

    uint8_t *ptr, *ssp;

    int selector;

    uint32_t offset, esp;

    uint32_t old_cs, old_eip;

    /* real mode (simpler !) */

    dt = &env->idt;

    if (intno * 4 + 3 > dt->limit)

        raise_exception_err(EXCP0D_GPF, intno * 8 + 2);

    ptr = dt->base + intno * 4;

    offset = lduw(ptr);

    selector = lduw(ptr + 2);

    esp = env->regs[R_ESP];

    ssp = env->segs[R_SS].base;

    if (is_int)

        old_eip = next_eip;

    else

        old_eip = env->eip;

    old_cs = env->segs[R_CS].selector;

    esp -= 2;

    stw(ssp + (esp & 0xffff), compute_eflags());

    esp -= 2;

    stw(ssp + (esp & 0xffff), old_cs);

    esp -= 2;

    stw(ssp + (esp & 0xffff), old_eip);

    /* update processor state */

    env->regs[R_ESP] = (env->regs[R_ESP] & ~0xffff) | (esp & 0xffff);

    env->eip = offset;

    env->segs[R_CS].selector = selector;

    env->segs[R_CS].base = (uint8_t *)(selector << 4);

    env->eflags &= ~(IF_MASK | TF_MASK | AC_MASK | RF_MASK);

}


static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)

{

    char path[50];

    if (xs == NULL) {

        fprintf(stderr, "xenstore connection not initialized\n");

        exit(1);

    }

    snprintf(path, sizeof (path), "/local/domain/0/device-model/%u/state", xen_domid);

    if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {

        fprintf(stderr, "error recording dm state\n");

        exit(1);

    }

}


--- a/source.c
+++ b/source.c
@@ -8,7 +8,7 @@

     UserDefFlatUnion *tmp;

+    UserDefUnionBase *base;

static void test_visitor_in_union_flat(TestInputVisitorData *data,

                                       const void *unused)

{

    Visitor *v;

    UserDefFlatUnion *tmp;

    UserDefUnionBase *base;

    v = visitor_input_test_init(data,

                                "{ 'enum1': 'value1', "

                                "'integer': 41, "

                                "'string': 'str', "

                                "'boolean': true }");

    visit_type_UserDefFlatUnion(v, NULL, &tmp, &error_abort);

    g_assert_cmpint(tmp->enum1, ==, ENUM_ONE_VALUE1);

    g_assert_cmpstr(tmp->string, ==, "str");

    g_assert_cmpint(tmp->integer, ==, 41);

    g_assert_cmpint(tmp->u.value1->boolean, ==, true);

    base = qapi_UserDefFlatUnion_base(tmp);

    g_assert(&base->enum1 == &tmp->enum1);

    qapi_free_UserDefFlatUnion(tmp);

}


--- a/source.c
+++ b/source.c
@@ -1,8 +1,8 @@
 void cpu_outl(pio_addr_t addr, uint32_t val)

 {
+
+    LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);

     trace_cpu_out(addr, val);

void cpu_outl(pio_addr_t addr, uint32_t val)

{

    LOG_IOPORT("outl: %04"FMT_pioaddr" %08"PRIx32"\n", addr, val);

    trace_cpu_out(addr, val);

    ioport_write(2, addr, val);

}


--- a/source.c
+++ b/source.c
@@ -1,5 +1,5 @@
 static int check_timecode(void *log_ctx, AVTimecode *tc)
+
 {

     if (tc->fps <= 0) {

static int check_timecode(void *log_ctx, AVTimecode *tc)

{

    if (tc->fps <= 0) {

        av_log(log_ctx, AV_LOG_ERROR, "Timecode frame rate must be specified\n");

        return AVERROR(EINVAL);

    }

    if ((tc->flags & AV_TIMECODE_FLAG_DROPFRAME) && tc->fps != 30 && tc->fps != 60) {

        av_log(log_ctx, AV_LOG_ERROR, "Drop frame is only allowed with 30000/1001 or 60000/1001 FPS\n");

        return AVERROR(EINVAL);

    }

    if (check_fps(tc->fps) < 0) {

        av_log(log_ctx, AV_LOG_WARNING, "Using non-standard frame rate %d/%d\n",

               tc->rate.num, tc->rate.den);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -8,7 +8,7 @@

+    switch (addr) {

     case CG3_REG_BT458_ADDR:

static uint64_t cg3_reg_read(void *opaque, hwaddr addr, unsigned size)

{

    CG3State *s = opaque;

    int val;

    switch (addr) {

    case CG3_REG_BT458_ADDR:

    case CG3_REG_BT458_COLMAP:

        val = 0;

        break;

    case CG3_REG_FBC_CTRL:

        val = s->regs[0];

        break;

    case CG3_REG_FBC_STATUS:

        /* monitor ID 6, board type = 1 (color) */

        val = s->regs[1] | CG3_SR_1152_900_76_B | CG3_SR_ID_COLOR;

        break;

    case CG3_REG_FBC_CURSTART ... CG3_REG_SIZE:

        val = s->regs[addr - 0x10];

        break;

    default:

        qemu_log_mask(LOG_UNIMP,

                  "cg3: Unimplemented register read "

                  "reg 0x%" HWADDR_PRIx " size 0x%x\n",

                  addr, size);

        val = 0;

        break;

    }

    DPRINTF("read %02x from reg %" HWADDR_PRIx "\n", val, addr);

    return val;

}


--- a/source.c
+++ b/source.c
@@ -1,7 +1,7 @@
 static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)

 {
+
     UHCIAsync *curr, *n;

static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)

{

    UHCIAsync *curr, *n;

    QTAILQ_FOREACH_SAFE(curr, &s->async_pending, next, n) {

        if (curr->packet.owner == NULL ||

            curr->packet.owner->dev != dev) {

            continue;

        }

        uhci_async_unlink(s, curr);

        uhci_async_cancel(s, curr);

    }

}


--- a/source.c
+++ b/source.c
@@ -1,4 +1,4 @@
+static int add_shorts_metadata(int count, const char *name,

                                const char *sep, TiffContext *s)

@@ -11,7 +11,7 @@
     int16_t *sp;

+
     if (count >= INT_MAX / sizeof(int16_t) || count <= 0)

         return AVERROR_INVALIDDATA;

static int add_shorts_metadata(int count, const char *name,

                               const char *sep, TiffContext *s)

{

    char *ap;

    int i;

    int16_t *sp;

    if (count >= INT_MAX / sizeof(int16_t) || count <= 0)

        return AVERROR_INVALIDDATA;

    if (bytestream2_get_bytes_left(&s->gb) < count * sizeof(int16_t))

        return AVERROR_INVALIDDATA;

    sp = av_malloc(count * sizeof(int16_t));

    if (!sp)

        return AVERROR(ENOMEM);

    for (i = 0; i < count; i++)

        sp[i] = tget_short(&s->gb, s->le);

    ap = shorts2str(sp, count, sep);

    av_freep(&sp);

    if (!ap)

        return AVERROR(ENOMEM);

    av_dict_set(avpriv_frame_get_metadatap(&s->picture), name, ap, AV_DICT_DONT_STRDUP_VAL);

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,12 +1,12 @@
+static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr)

 {
+
     /* Do the "take the exception" parts of exception entry,

      * but not the pushing of state to the stack. This is

+     * similar to the pseudocode ExceptionTaken() function.

      */

static void v7m_exception_taken(ARMCPU *cpu, uint32_t lr)

{

    /* Do the "take the exception" parts of exception entry,

     * but not the pushing of state to the stack. This is

     * similar to the pseudocode ExceptionTaken() function.

     */

    CPUARMState *env = &cpu->env;

    uint32_t addr;

    armv7m_nvic_acknowledge_irq(env->nvic);

    write_v7m_control_spsel(env, 0);

    arm_clear_exclusive(env);

    /* Clear IT bits */

    env->condexec_bits = 0;

    env->regs[14] = lr;

    addr = arm_v7m_load_vector(cpu);

    env->regs[15] = addr & 0xfffffffe;

    env->thumb = addr & 1;

}


--- a/source.c
+++ b/source.c
@@ -1,5 +1,5 @@
 void OPPROTO op_POWER_sllq (void)
+
 {

     uint32_t msk = -1;

void OPPROTO op_POWER_sllq (void)

{

    uint32_t msk = -1;

    msk = msk << (T1 & 0x1FUL);

    if (T1 & 0x20UL)

        msk = ~msk;

    T1 &= 0x1FUL;

    T0 = (T0 << T1) & msk;

    T0 |= env->spr[SPR_MQ] & ~msk;

    RETURN();

}


--- a/source.c
+++ b/source.c
@@ -13,11 +13,11 @@
     if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {

         fprintf(stderr, "sd_blk_read: read error on host side\n");
+
+        return;
+
+    }
+

     if (end > (addr & ~511) + 512) {

static void sd_blk_read(SDState *sd, uint64_t addr, uint32_t len)

{

    uint64_t end = addr + len;

    DPRINTF("sd_blk_read: addr = 0x%08llx, len = %d\n",

            (unsigned long long) addr, len);

    if (!sd->bdrv || bdrv_read(sd->bdrv, addr >> 9, sd->buf, 1) < 0) {

        fprintf(stderr, "sd_blk_read: read error on host side\n");

        return;

    }

    if (end > (addr & ~511) + 512) {

        memcpy(sd->data, sd->buf + (addr & 511), 512 - (addr & 511));

        if (bdrv_read(sd->bdrv, end >> 9, sd->buf, 1) < 0) {

            fprintf(stderr, "sd_blk_read: read error on host side\n");

            return;

        }

        memcpy(sd->data + 512 - (addr & 511), sd->buf, end & 511);

    } else

        memcpy(sd->data, sd->buf + (addr & 511), len);

}


--- a/source.c
+++ b/source.c
@@ -6,8 +6,8 @@

     DiscardCo rwco = {

+        .bs = bs,
+
         .sector_num = sector_num,

         .nb_sectors = nb_sectors,

int bdrv_discard(BlockDriverState *bs, int64_t sector_num, int nb_sectors)

{

    Coroutine *co;

    DiscardCo rwco = {

        .bs = bs,

        .sector_num = sector_num,

        .nb_sectors = nb_sectors,

        .ret = NOT_DONE,

    };

    if (qemu_in_coroutine()) {

        /* Fast-path if already in coroutine context */

        bdrv_discard_co_entry(&rwco);

    } else {

        AioContext *aio_context = bdrv_get_aio_context(bs);

        co = qemu_coroutine_create(bdrv_discard_co_entry);

        qemu_coroutine_enter(co, &rwco);

        while (rwco.ret == NOT_DONE) {

            aio_poll(aio_context, true);

        }

    }

    return rwco.ret;

}


--- a/source.c
+++ b/source.c
@@ -1,11 +1,11 @@
+static void coroutine_fn v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,

                                             V9fsString *old_name,

                                             V9fsPath *newdir,

+                                            V9fsString *new_name)
+
 {

     V9fsFidState *tfidp;

static void coroutine_fn v9fs_fix_fid_paths(V9fsPDU *pdu, V9fsPath *olddir,

                                            V9fsString *old_name,

                                            V9fsPath *newdir,

                                            V9fsString *new_name)

{

    V9fsFidState *tfidp;

    V9fsPath oldpath, newpath;

    V9fsState *s = pdu->s;

    v9fs_path_init(&oldpath);

    v9fs_path_init(&newpath);

    v9fs_co_name_to_path(pdu, olddir, old_name->data, &oldpath);

    v9fs_co_name_to_path(pdu, newdir, new_name->data, &newpath);

    /*

     * Fixup fid's pointing to the old name to

     * start pointing to the new name

     */

    for (tfidp = s->fid_list; tfidp; tfidp = tfidp->next) {

        if (v9fs_path_is_ancestor(&oldpath, &tfidp->path)) {

            /* replace the name */

            v9fs_fix_path(&tfidp->path, &newpath, strlen(oldpath.data));

        }

    }

    v9fs_path_free(&oldpath);

    v9fs_path_free(&newpath);

}


--- a/source.c
+++ b/source.c
@@ -4,11 +4,11 @@

 #ifdef CONFIG_LINUX

+    struct statfs fs;
+
+    int ret;
+
+

     if (fd != -1) {

static size_t fd_getpagesize(int fd)

{

#ifdef CONFIG_LINUX

    struct statfs fs;

    int ret;

    if (fd != -1) {

        do {

            ret = fstatfs(fd, &fs);

        } while (ret != 0 && errno == EINTR);

        if (ret == 0 && fs.f_type == HUGETLBFS_MAGIC) {

            return fs.f_bsize;

        }

    }

#endif

    return getpagesize();

}


--- a/source.c
+++ b/source.c
@@ -2,7 +2,7 @@

 {

+    DeviceClass *dc = DEVICE_CLASS(klass);

static void isabus_fdc_class_init(ObjectClass *klass, void *data)

{

    DeviceClass *dc = DEVICE_CLASS(klass);

    dc->realize = isabus_fdc_realize;

    dc->fw_name = "fdc";

    dc->no_user = 1;

    dc->reset = fdctrl_external_reset_isa;

    dc->vmsd = &vmstate_isa_fdc;

    dc->props = isa_fdc_properties;

    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
 {

     BDRVQcow2State *s = bs->opaque;
+
     int nr;

     BlockDriverState *file;

static bool is_zero_cluster(BlockDriverState *bs, int64_t start)

{

    BDRVQcow2State *s = bs->opaque;

    int nr;

    BlockDriverState *file;

    int64_t res = bdrv_get_block_status_above(bs, NULL, start,

                                              s->cluster_sectors, &nr, &file);

    return res >= 0 && ((res & BDRV_BLOCK_ZERO) || !(res & BDRV_BLOCK_DATA));

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
                                 AVStream *st, MOVStreamContext *sc,

                                 int size)
+
 {

     if (st->codec->codec_tag == MKTAG('t','m','c','d')) {

static int mov_parse_stsd_data(MOVContext *c, AVIOContext *pb,

                                AVStream *st, MOVStreamContext *sc,

                                int size)

{

    if (st->codec->codec_tag == MKTAG('t','m','c','d')) {

        st->codec->extradata_size = size;

        st->codec->extradata = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);

        if (!st->codec->extradata)

            return AVERROR(ENOMEM);

        avio_read(pb, st->codec->extradata, size);

    } else {

        /* other codec type, just skip (rtp, mp4s ...) */

        avio_skip(pb, size);

    }

    return 0;

}


--- a/source.c
+++ b/source.c
@@ -1,7 +1,7 @@
+void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,
+
+                           uintptr_t length)
+
 {

     uintptr_t addr;

void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, uintptr_t start,

                           uintptr_t length)

{

    uintptr_t addr;

    if (tlb_is_dirty_ram(tlb_entry)) {

        addr = (tlb_entry->addr_write & TARGET_PAGE_MASK) + tlb_entry->addend;

        if ((addr - start) < length) {

            tlb_entry->addr_write |= TLB_NOTDIRTY;

        }

    }

}


--- a/source.c
+++ b/source.c
@@ -1,5 +1,5 @@
+int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,
+
                                    int nb_sectors, int *pnum)

 {

int coroutine_fn bdrv_is_allocated(BlockDriverState *bs, int64_t sector_num,

                                   int nb_sectors, int *pnum)

{

    return bdrv_get_block_status(bs, sector_num, nb_sectors, pnum);

}


--- a/source.c
+++ b/source.c
@@ -28,11 +28,11 @@

            but they aren't.  */

+        s->smart_enabled = 1;
+
+        s->smart_autosave = 1;
+
+        s->smart_errors = 0;

         s->smart_selftest_count = 0;

void ide_init_drive(IDEState *s, DriveInfo *dinfo, const char *version)

{

    int cylinders, heads, secs;

    uint64_t nb_sectors;

    if (dinfo && dinfo->bdrv) {

        s->bs = dinfo->bdrv;

        bdrv_get_geometry(s->bs, &nb_sectors);

        bdrv_guess_geometry(s->bs, &cylinders, &heads, &secs);

        s->cylinders = cylinders;

        s->heads = heads;

        s->sectors = secs;

        s->nb_sectors = nb_sectors;

        /* The SMART values should be preserved across power cycles

           but they aren't.  */

        s->smart_enabled = 1;

        s->smart_autosave = 1;

        s->smart_errors = 0;

        s->smart_selftest_count = 0;

        if (bdrv_get_type_hint(s->bs) == BDRV_TYPE_CDROM) {

            s->is_cdrom = 1;

            bdrv_set_change_cb(s->bs, cdrom_change_cb, s);

        }

        strncpy(s->drive_serial_str, drive_get_serial(s->bs),

                sizeof(s->drive_serial_str));

    }

    if (strlen(s->drive_serial_str) == 0)

        snprintf(s->drive_serial_str, sizeof(s->drive_serial_str),

                 "QM%05d", s->drive_serial);

    if (version) {

        pstrcpy(s->version, sizeof(s->version), version);

    } else {

        pstrcpy(s->version, sizeof(s->version), QEMU_VERSION);

    }

    ide_reset(s);

}


--- a/source.c
+++ b/source.c
@@ -35,11 +35,11 @@
         }

         avio_write(out, buf, n);
+
+        size -= n;
+
+    }
+
     avio_flush(out);

     avio_close(out);

static int copy_moof(AVFormatContext *s, const char* infile, const char *outfile, int64_t size)

{

    AVIOContext *in, *out;

    int ret = 0;

    if ((ret = avio_open2(&in, infile, AVIO_FLAG_READ, &s->interrupt_callback, NULL)) < 0)

        return ret;

    if ((ret = avio_open2(&out, outfile, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL)) < 0) {

        avio_close(in);

        return ret;

    }

    while (size > 0) {

        uint8_t buf[8192];

        int n = FFMIN(size, sizeof(buf));

        n = avio_read(in, buf, n);

        if (n <= 0) {

            ret = AVERROR(EIO);

            break;

        }

        avio_write(out, buf, n);

        size -= n;

    }

    avio_flush(out);

    avio_close(out);

    avio_close(in);

    return ret;

}


--- a/source.c
+++ b/source.c
@@ -9,7 +9,7 @@
     switch (buf[0]) {

     case REPORT_LUNS:
+
         if (!scsi_target_emulate_report_luns(r)) {

             goto illegal_request;

static int32_t scsi_target_send_command(SCSIRequest *req, uint8_t *buf)

{

    SCSITargetReq *r = DO_UPCAST(SCSITargetReq, req, req);

    switch (buf[0]) {

    case REPORT_LUNS:

        if (!scsi_target_emulate_report_luns(r)) {

            goto illegal_request;

        }

        break;

    case INQUIRY:

        if (!scsi_target_emulate_inquiry(r)) {

            goto illegal_request;

        }

        break;

    case REQUEST_SENSE:

        r->len = scsi_device_get_sense(r->req.dev, r->buf,

                                       MIN(req->cmd.xfer, sizeof r->buf),

                                       (req->cmd.buf[1] & 1) == 0);

        if (r->req.dev->sense_is_ua) {

            scsi_device_unit_attention_reported(req->dev);

            r->req.dev->sense_len = 0;

            r->req.dev->sense_is_ua = false;

        }

        break;

    default:

        scsi_req_build_sense(req, SENSE_CODE(LUN_NOT_SUPPORTED));

        scsi_req_complete(req, CHECK_CONDITION);

        return 0;

    illegal_request:

        scsi_req_build_sense(req, SENSE_CODE(INVALID_FIELD));

        scsi_req_complete(req, CHECK_CONDITION);

        return 0;

    }

    if (!r->len) {

        scsi_req_complete(req, GOOD);

    }

    return r->len;

}


--- a/source.c
+++ b/source.c
@@ -7,11 +7,11 @@
         ide_flush_cb(s, 0);

         return;
+
+    }
+
+
+
     s->status |= BUSY_STAT;

     block_acct_start(bdrv_get_stats(s->bs), &s->acct, 0, BLOCK_ACCT_FLUSH);

void ide_flush_cache(IDEState *s)

{

    if (s->bs == NULL) {

        ide_flush_cb(s, 0);

        return;

    }

    s->status |= BUSY_STAT;

    block_acct_start(bdrv_get_stats(s->bs), &s->acct, 0, BLOCK_ACCT_FLUSH);

    s->pio_aiocb = bdrv_aio_flush(s->bs, ide_flush_cb, s);

}


--- a/source.c
+++ b/source.c
@@ -3,7 +3,7 @@
 {

     AVVDPAUContext *hwctx = avctx->hwaccel_context;
+
     MpegEncContext *s = avctx->priv_data;

     Picture *pic = s->current_picture_ptr;

int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx)

{

    AVVDPAUContext *hwctx = avctx->hwaccel_context;

    MpegEncContext *s = avctx->priv_data;

    Picture *pic = s->current_picture_ptr;

    struct vdpau_picture_context *pic_ctx = pic->hwaccel_picture_private;

    VdpVideoSurface surf = ff_vdpau_get_surface_id(&pic->f);

    hwctx->render(hwctx->decoder, surf, (void *)&pic_ctx->info,

                  pic_ctx->bitstream_buffers_used, pic_ctx->bitstream_buffers);

    ff_mpeg_draw_horiz_band(s, 0, s->avctx->height);

    av_freep(&pic_ctx->bitstream_buffers);

    return 0;

}