Commit 8e5c952b authored by Philippe Mathieu-Daudé's avatar Philippe Mathieu-Daudé Committed by Markus Armbruster
Browse files

hw: Remove unnecessary DEVICE() cast



The DEVICE() macro is defined as:

  #define DEVICE(obj) OBJECT_CHECK(DeviceState, (obj), TYPE_DEVICE)

which expands to:

  ((DeviceState *)object_dynamic_cast_assert((Object *)(obj), (name),
                                             __FILE__, __LINE__,
                                             __func__))

This assertion can only fail when @obj points to something other
than its stated type, i.e. when we're in undefined behavior country.

Remove the unnecessary DEVICE() casts when we already know the
pointer is of DeviceState type.

Patch created mechanically using spatch with this script:

  @@
  typedef DeviceState;
  DeviceState *s;
  @@
  -   DEVICE(s)
  +   s

Acked-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Acked-by: default avatarPaul Durrant <paul@xen.org>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
Acked-by: default avatarJohn Snow <jsnow@redhat.com>
Reviewed-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Reviewed-by: default avatarMarkus Armbruster <armbru@redhat.com>
Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20200512070020.22782-4-f4bug@amsat.org>
parent 688ffbb4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1353,7 +1353,7 @@ static void artist_realizefn(DeviceState *dev, Error **errp)
    s->cursor_height = 32;
    s->cursor_width = 32;

    s->con = graphic_console_init(DEVICE(dev), 0, &artist_ops, s);
    s->con = graphic_console_init(dev, 0, &artist_ops, s);
    qemu_console_resize(s->con, s->width, s->height);
}

+1 −1
Original line number Diff line number Diff line
@@ -321,7 +321,7 @@ static void cg3_realizefn(DeviceState *dev, Error **errp)

    sysbus_init_irq(sbd, &s->irq);

    s->con = graphic_console_init(DEVICE(dev), 0, &cg3_ops, s);
    s->con = graphic_console_init(dev, 0, &cg3_ops, s);
    qemu_console_resize(s->con, s->width, s->height);
}

+1 −1
Original line number Diff line number Diff line
@@ -1839,7 +1839,7 @@ static void sm501_init(SM501State *s, DeviceState *dev,
                                &s->twoD_engine_region);

    /* create qemu graphic console */
    s->con = graphic_console_init(DEVICE(dev), 0, &sm501_ops, s);
    s->con = graphic_console_init(dev, 0, &sm501_ops, s);
}

static const VMStateDescription vmstate_sm501_state = {
+2 −2
Original line number Diff line number Diff line
@@ -868,9 +868,9 @@ static void tcx_realizefn(DeviceState *dev, Error **errp)
    sysbus_init_irq(sbd, &s->irq);

    if (s->depth == 8) {
        s->con = graphic_console_init(DEVICE(dev), 0, &tcx_ops, s);
        s->con = graphic_console_init(dev, 0, &tcx_ops, s);
    } else {
        s->con = graphic_console_init(DEVICE(dev), 0, &tcx24_ops, s);
        s->con = graphic_console_init(dev, 0, &tcx24_ops, s);
    }
    s->thcmisc = 0;

+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ static void vga_isa_realizefn(DeviceState *dev, Error **errp)
                                        0x000a0000,
                                        vga_io_memory, 1);
    memory_region_set_coalescing(vga_io_memory);
    s->con = graphic_console_init(DEVICE(dev), 0, s->hw_ops, s);
    s->con = graphic_console_init(dev, 0, s->hw_ops, s);

    memory_region_add_subregion(isa_address_space(isadev),
                                VBE_DISPI_LFB_PHYSICAL_ADDRESS,
Loading