Skip to content

Commit

Permalink
Use DECLARE_*CHECKER* macros
Browse files Browse the repository at this point in the history
Generated using:

 $ ./scripts/codeconverter/converter.py -i \
   --pattern=TypeCheckMacro $(git grep -l '' -- '*.[ch]')

Reviewed-by: Daniel P. Berrangé <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Juan Quintela <[email protected]>
Message-Id: <[email protected]>
Message-Id: <[email protected]>
Signed-off-by: Eduardo Habkost <[email protected]>
  • Loading branch information
ehabkost committed Sep 9, 2020
1 parent db1015e commit 8110fa1
Show file tree
Hide file tree
Showing 791 changed files with 1,989 additions and 2,425 deletions.
4 changes: 2 additions & 2 deletions accel/tcg/tcg-all.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ typedef struct TCGState TCGState;

#define TYPE_TCG_ACCEL ACCEL_CLASS_NAME("tcg")

#define TCG_STATE(obj) \
OBJECT_CHECK(TCGState, (obj), TYPE_TCG_ACCEL)
DECLARE_INSTANCE_CHECKER(TCGState, TCG_STATE,
TYPE_TCG_ACCEL)

/* mask must never be zero, except for A20 change call */
static void tcg_handle_interrupt(CPUState *cpu, int mask)
Expand Down
5 changes: 2 additions & 3 deletions backends/cryptodev-builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@

typedef struct CryptoDevBackendBuiltin
CryptoDevBackendBuiltin;
#define CRYPTODEV_BACKEND_BUILTIN(obj) \
OBJECT_CHECK(CryptoDevBackendBuiltin, \
(obj), TYPE_CRYPTODEV_BACKEND_BUILTIN)
DECLARE_INSTANCE_CHECKER(CryptoDevBackendBuiltin, CRYPTODEV_BACKEND_BUILTIN,
TYPE_CRYPTODEV_BACKEND_BUILTIN)


typedef struct CryptoDevBackendBuiltinSession {
Expand Down
5 changes: 2 additions & 3 deletions backends/cryptodev-vhost-user.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@
#define TYPE_CRYPTODEV_BACKEND_VHOST_USER "cryptodev-vhost-user"

typedef struct CryptoDevBackendVhostUser CryptoDevBackendVhostUser;
#define CRYPTODEV_BACKEND_VHOST_USER(obj) \
OBJECT_CHECK(CryptoDevBackendVhostUser, \
(obj), TYPE_CRYPTODEV_BACKEND_VHOST_USER)
DECLARE_INSTANCE_CHECKER(CryptoDevBackendVhostUser, CRYPTODEV_BACKEND_VHOST_USER,
TYPE_CRYPTODEV_BACKEND_VHOST_USER)


struct CryptoDevBackendVhostUser {
Expand Down
8 changes: 2 additions & 6 deletions backends/dbus-vmstate.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@ typedef struct DBusVMState DBusVMState;
typedef struct DBusVMStateClass DBusVMStateClass;

#define TYPE_DBUS_VMSTATE "dbus-vmstate"
#define DBUS_VMSTATE(obj) \
OBJECT_CHECK(DBusVMState, (obj), TYPE_DBUS_VMSTATE)
#define DBUS_VMSTATE_GET_CLASS(obj) \
OBJECT_GET_CLASS(DBusVMStateClass, (obj), TYPE_DBUS_VMSTATE)
#define DBUS_VMSTATE_CLASS(klass) \
OBJECT_CLASS_CHECK(DBusVMStateClass, (klass), TYPE_DBUS_VMSTATE)
DECLARE_OBJ_CHECKERS(DBusVMState, DBusVMStateClass,
DBUS_VMSTATE, TYPE_DBUS_VMSTATE)

struct DBusVMStateClass {
ObjectClass parent_class;
Expand Down
4 changes: 2 additions & 2 deletions backends/hostmem-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "qom/object.h"

typedef struct HostMemoryBackendFile HostMemoryBackendFile;
#define MEMORY_BACKEND_FILE(obj) \
OBJECT_CHECK(HostMemoryBackendFile, (obj), TYPE_MEMORY_BACKEND_FILE)
DECLARE_INSTANCE_CHECKER(HostMemoryBackendFile, MEMORY_BACKEND_FILE,
TYPE_MEMORY_BACKEND_FILE)


struct HostMemoryBackendFile {
Expand Down
4 changes: 2 additions & 2 deletions backends/hostmem-memfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
#define TYPE_MEMORY_BACKEND_MEMFD "memory-backend-memfd"

typedef struct HostMemoryBackendMemfd HostMemoryBackendMemfd;
#define MEMORY_BACKEND_MEMFD(obj) \
OBJECT_CHECK(HostMemoryBackendMemfd, (obj), TYPE_MEMORY_BACKEND_MEMFD)
DECLARE_INSTANCE_CHECKER(HostMemoryBackendMemfd, MEMORY_BACKEND_MEMFD,
TYPE_MEMORY_BACKEND_MEMFD)


struct HostMemoryBackendMemfd {
Expand Down
3 changes: 2 additions & 1 deletion backends/rng-builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
#include "qom/object.h"

typedef struct RngBuiltin RngBuiltin;
#define RNG_BUILTIN(obj) OBJECT_CHECK(RngBuiltin, (obj), TYPE_RNG_BUILTIN)
DECLARE_INSTANCE_CHECKER(RngBuiltin, RNG_BUILTIN,
TYPE_RNG_BUILTIN)

struct RngBuiltin {
RngBackend parent;
Expand Down
3 changes: 2 additions & 1 deletion backends/rng-egd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@

#define TYPE_RNG_EGD "rng-egd"
typedef struct RngEgd RngEgd;
#define RNG_EGD(obj) OBJECT_CHECK(RngEgd, (obj), TYPE_RNG_EGD)
DECLARE_INSTANCE_CHECKER(RngEgd, RNG_EGD,
TYPE_RNG_EGD)

struct RngEgd {
RngBackend parent;
Expand Down
4 changes: 2 additions & 2 deletions backends/tpm/tpm_emulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@

#define TYPE_TPM_EMULATOR "tpm-emulator"
typedef struct TPMEmulator TPMEmulator;
#define TPM_EMULATOR(obj) \
OBJECT_CHECK(TPMEmulator, (obj), TYPE_TPM_EMULATOR)
DECLARE_INSTANCE_CHECKER(TPMEmulator, TPM_EMULATOR,
TYPE_TPM_EMULATOR)

#define TPM_EMULATOR_IMPLEMENTS_ALL_CAPS(S, cap) (((S)->caps & (cap)) == (cap))

Expand Down
4 changes: 2 additions & 2 deletions backends/tpm/tpm_passthrough.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@

#define TYPE_TPM_PASSTHROUGH "tpm-passthrough"
typedef struct TPMPassthruState TPMPassthruState;
#define TPM_PASSTHROUGH(obj) \
OBJECT_CHECK(TPMPassthruState, (obj), TYPE_TPM_PASSTHROUGH)
DECLARE_INSTANCE_CHECKER(TPMPassthruState, TPM_PASSTHROUGH,
TYPE_TPM_PASSTHROUGH)

/* data structures */
struct TPMPassthruState {
Expand Down
3 changes: 2 additions & 1 deletion chardev/baum.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ struct BaumChardev {
typedef struct BaumChardev BaumChardev;

#define TYPE_CHARDEV_BRAILLE "chardev-braille"
#define BAUM_CHARDEV(obj) OBJECT_CHECK(BaumChardev, (obj), TYPE_CHARDEV_BRAILLE)
DECLARE_INSTANCE_CHECKER(BaumChardev, BAUM_CHARDEV,
TYPE_CHARDEV_BRAILLE)

/* Let's assume NABCC by default */
enum way {
Expand Down
3 changes: 2 additions & 1 deletion chardev/char-pty.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ struct PtyChardev {
};
typedef struct PtyChardev PtyChardev;

#define PTY_CHARDEV(obj) OBJECT_CHECK(PtyChardev, (obj), TYPE_CHARDEV_PTY)
DECLARE_INSTANCE_CHECKER(PtyChardev, PTY_CHARDEV,
TYPE_CHARDEV_PTY)

static void pty_chr_state(Chardev *chr, int connected);

Expand Down
4 changes: 2 additions & 2 deletions chardev/char-ringbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ struct RingBufChardev {
};
typedef struct RingBufChardev RingBufChardev;

#define RINGBUF_CHARDEV(obj) \
OBJECT_CHECK(RingBufChardev, (obj), TYPE_CHARDEV_RINGBUF)
DECLARE_INSTANCE_CHECKER(RingBufChardev, RINGBUF_CHARDEV,
TYPE_CHARDEV_RINGBUF)

static size_t ringbuf_count(const Chardev *chr)
{
Expand Down
4 changes: 2 additions & 2 deletions chardev/char-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ struct SocketChardev {
};
typedef struct SocketChardev SocketChardev;

#define SOCKET_CHARDEV(obj) \
OBJECT_CHECK(SocketChardev, (obj), TYPE_CHARDEV_SOCKET)
DECLARE_INSTANCE_CHECKER(SocketChardev, SOCKET_CHARDEV,
TYPE_CHARDEV_SOCKET)

static gboolean socket_reconnect_timeout(gpointer opaque);
static void tcp_chr_telnet_init(Chardev *chr);
Expand Down
3 changes: 2 additions & 1 deletion chardev/char-udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ struct UdpChardev {
};
typedef struct UdpChardev UdpChardev;

#define UDP_CHARDEV(obj) OBJECT_CHECK(UdpChardev, (obj), TYPE_CHARDEV_UDP)
DECLARE_INSTANCE_CHECKER(UdpChardev, UDP_CHARDEV,
TYPE_CHARDEV_UDP)

/* Called with chr_write_lock held. */
static int udp_chr_write(Chardev *chr, const uint8_t *buf, int len)
Expand Down
4 changes: 2 additions & 2 deletions chardev/char-win-stdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct WinStdioChardev {
};
typedef struct WinStdioChardev WinStdioChardev;

#define WIN_STDIO_CHARDEV(obj) \
OBJECT_CHECK(WinStdioChardev, (obj), TYPE_CHARDEV_WIN_STDIO)
DECLARE_INSTANCE_CHECKER(WinStdioChardev, WIN_STDIO_CHARDEV,
TYPE_CHARDEV_WIN_STDIO)

static void win_stdio_wait_func(void *opaque)
{
Expand Down
3 changes: 2 additions & 1 deletion chardev/chardev-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ struct MuxChardev {
};
typedef struct MuxChardev MuxChardev;

#define MUX_CHARDEV(obj) OBJECT_CHECK(MuxChardev, (obj), TYPE_CHARDEV_MUX)
DECLARE_INSTANCE_CHECKER(MuxChardev, MUX_CHARDEV,
TYPE_CHARDEV_MUX)
#define CHARDEV_IS_MUX(chr) \
object_dynamic_cast(OBJECT(chr), TYPE_CHARDEV_MUX)

Expand Down
4 changes: 2 additions & 2 deletions chardev/msmouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ struct MouseChardev {
typedef struct MouseChardev MouseChardev;

#define TYPE_CHARDEV_MSMOUSE "chardev-msmouse"
#define MOUSE_CHARDEV(obj) \
OBJECT_CHECK(MouseChardev, (obj), TYPE_CHARDEV_MSMOUSE)
DECLARE_INSTANCE_CHECKER(MouseChardev, MOUSE_CHARDEV,
TYPE_CHARDEV_MSMOUSE)

static void msmouse_chr_accept_input(Chardev *chr)
{
Expand Down
4 changes: 2 additions & 2 deletions chardev/testdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ struct TestdevChardev {
typedef struct TestdevChardev TestdevChardev;

#define TYPE_CHARDEV_TESTDEV "chardev-testdev"
#define TESTDEV_CHARDEV(obj) \
OBJECT_CHECK(TestdevChardev, (obj), TYPE_CHARDEV_TESTDEV)
DECLARE_INSTANCE_CHECKER(TestdevChardev, TESTDEV_CHARDEV,
TYPE_CHARDEV_TESTDEV)

/* Try to interpret a whole incoming packet */
static int testdev_eat_packet(TestdevChardev *testdev)
Expand Down
4 changes: 2 additions & 2 deletions chardev/wctablet.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ struct TabletChardev {
typedef struct TabletChardev TabletChardev;

#define TYPE_CHARDEV_WCTABLET "chardev-wctablet"
#define WCTABLET_CHARDEV(obj) \
OBJECT_CHECK(TabletChardev, (obj), TYPE_CHARDEV_WCTABLET)
DECLARE_INSTANCE_CHECKER(TabletChardev, WCTABLET_CHARDEV,
TYPE_CHARDEV_WCTABLET)


static void wctablet_chr_accept_input(Chardev *chr);
Expand Down
4 changes: 2 additions & 2 deletions hw/9pfs/virtio-9p.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct V9fsVirtioState {
typedef struct V9fsVirtioState V9fsVirtioState;

#define TYPE_VIRTIO_9P "virtio-9p-device"
#define VIRTIO_9P(obj) \
OBJECT_CHECK(V9fsVirtioState, (obj), TYPE_VIRTIO_9P)
DECLARE_INSTANCE_CHECKER(V9fsVirtioState, VIRTIO_9P,
TYPE_VIRTIO_9P)

#endif
4 changes: 2 additions & 2 deletions hw/acpi/piix4.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ struct PIIX4PMState {
};
typedef struct PIIX4PMState PIIX4PMState;

#define PIIX4_PM(obj) \
OBJECT_CHECK(PIIX4PMState, (obj), TYPE_PIIX4_PM)
DECLARE_INSTANCE_CHECKER(PIIX4PMState, PIIX4_PM,
TYPE_PIIX4_PM)

static void piix4_acpi_system_hot_add_init(MemoryRegion *parent,
PCIBus *bus, PIIX4PMState *s);
Expand Down
4 changes: 2 additions & 2 deletions hw/alpha/typhoon.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ typedef struct TyphoonPchip {
} TyphoonPchip;

typedef struct TyphoonState TyphoonState;
#define TYPHOON_PCI_HOST_BRIDGE(obj) \
OBJECT_CHECK(TyphoonState, (obj), TYPE_TYPHOON_PCI_HOST_BRIDGE)
DECLARE_INSTANCE_CHECKER(TyphoonState, TYPHOON_PCI_HOST_BRIDGE,
TYPE_TYPHOON_PCI_HOST_BRIDGE)

struct TyphoonState {
PCIHostState parent_obj;
Expand Down
4 changes: 2 additions & 2 deletions hw/arm/collie.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ struct CollieMachineState {
typedef struct CollieMachineState CollieMachineState;

#define TYPE_COLLIE_MACHINE MACHINE_TYPE_NAME("collie")
#define COLLIE_MACHINE(obj) \
OBJECT_CHECK(CollieMachineState, obj, TYPE_COLLIE_MACHINE)
DECLARE_INSTANCE_CHECKER(CollieMachineState, COLLIE_MACHINE,
TYPE_COLLIE_MACHINE)

static struct arm_boot_info collie_binfo = {
.loader_start = SA_SDCS0,
Expand Down
4 changes: 2 additions & 2 deletions hw/arm/highbank.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ static const MemoryRegionOps hb_mem_ops = {

#define TYPE_HIGHBANK_REGISTERS "highbank-regs"
typedef struct HighbankRegsState HighbankRegsState;
#define HIGHBANK_REGISTERS(obj) \
OBJECT_CHECK(HighbankRegsState, (obj), TYPE_HIGHBANK_REGISTERS)
DECLARE_INSTANCE_CHECKER(HighbankRegsState, HIGHBANK_REGISTERS,
TYPE_HIGHBANK_REGISTERS)

struct HighbankRegsState {
/*< private >*/
Expand Down
12 changes: 6 additions & 6 deletions hw/arm/integratorcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

#define TYPE_INTEGRATOR_CM "integrator_core"
typedef struct IntegratorCMState IntegratorCMState;
#define INTEGRATOR_CM(obj) \
OBJECT_CHECK(IntegratorCMState, (obj), TYPE_INTEGRATOR_CM)
DECLARE_INSTANCE_CHECKER(IntegratorCMState, INTEGRATOR_CM,
TYPE_INTEGRATOR_CM)

struct IntegratorCMState {
/*< private >*/
Expand Down Expand Up @@ -329,8 +329,8 @@ static void integratorcm_realize(DeviceState *d, Error **errp)

#define TYPE_INTEGRATOR_PIC "integrator_pic"
typedef struct icp_pic_state icp_pic_state;
#define INTEGRATOR_PIC(obj) \
OBJECT_CHECK(icp_pic_state, (obj), TYPE_INTEGRATOR_PIC)
DECLARE_INSTANCE_CHECKER(icp_pic_state, INTEGRATOR_PIC,
TYPE_INTEGRATOR_PIC)

struct icp_pic_state {
/*< private >*/
Expand Down Expand Up @@ -469,8 +469,8 @@ static void icp_pic_init(Object *obj)

#define TYPE_ICP_CONTROL_REGS "icp-ctrl-regs"
typedef struct ICPCtrlRegsState ICPCtrlRegsState;
#define ICP_CONTROL_REGS(obj) \
OBJECT_CHECK(ICPCtrlRegsState, (obj), TYPE_ICP_CONTROL_REGS)
DECLARE_INSTANCE_CHECKER(ICPCtrlRegsState, ICP_CONTROL_REGS,
TYPE_ICP_CONTROL_REGS)

struct ICPCtrlRegsState {
/*< private >*/
Expand Down
4 changes: 2 additions & 2 deletions hw/arm/microbit.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ typedef struct MicrobitMachineState MicrobitMachineState;

#define TYPE_MICROBIT_MACHINE MACHINE_TYPE_NAME("microbit")

#define MICROBIT_MACHINE(obj) \
OBJECT_CHECK(MicrobitMachineState, obj, TYPE_MICROBIT_MACHINE)
DECLARE_INSTANCE_CHECKER(MicrobitMachineState, MICROBIT_MACHINE,
TYPE_MICROBIT_MACHINE)

static void microbit_init(MachineState *machine)
{
Expand Down
8 changes: 2 additions & 6 deletions hw/arm/mps2-tz.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,8 @@ typedef struct MPS2TZMachineState MPS2TZMachineState;
#define TYPE_MPS2TZ_AN505_MACHINE MACHINE_TYPE_NAME("mps2-an505")
#define TYPE_MPS2TZ_AN521_MACHINE MACHINE_TYPE_NAME("mps2-an521")

#define MPS2TZ_MACHINE(obj) \
OBJECT_CHECK(MPS2TZMachineState, obj, TYPE_MPS2TZ_MACHINE)
#define MPS2TZ_MACHINE_GET_CLASS(obj) \
OBJECT_GET_CLASS(MPS2TZMachineClass, obj, TYPE_MPS2TZ_MACHINE)
#define MPS2TZ_MACHINE_CLASS(klass) \
OBJECT_CLASS_CHECK(MPS2TZMachineClass, klass, TYPE_MPS2TZ_MACHINE)
DECLARE_OBJ_CHECKERS(MPS2TZMachineState, MPS2TZMachineClass,
MPS2TZ_MACHINE, TYPE_MPS2TZ_MACHINE)

/* Main SYSCLK frequency in Hz */
#define SYSCLK_FRQ 20000000
Expand Down
8 changes: 2 additions & 6 deletions hw/arm/mps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,8 @@ typedef struct MPS2MachineState MPS2MachineState;
#define TYPE_MPS2_AN385_MACHINE MACHINE_TYPE_NAME("mps2-an385")
#define TYPE_MPS2_AN511_MACHINE MACHINE_TYPE_NAME("mps2-an511")

#define MPS2_MACHINE(obj) \
OBJECT_CHECK(MPS2MachineState, obj, TYPE_MPS2_MACHINE)
#define MPS2_MACHINE_GET_CLASS(obj) \
OBJECT_GET_CLASS(MPS2MachineClass, obj, TYPE_MPS2_MACHINE)
#define MPS2_MACHINE_CLASS(klass) \
OBJECT_CLASS_CHECK(MPS2MachineClass, klass, TYPE_MPS2_MACHINE)
DECLARE_OBJ_CHECKERS(MPS2MachineState, MPS2MachineClass,
MPS2_MACHINE, TYPE_MPS2_MACHINE)

/* Main SYSCLK frequency in Hz */
#define SYSCLK_FRQ 25000000
Expand Down
8 changes: 2 additions & 6 deletions hw/arm/musca.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,8 @@ typedef struct MuscaMachineState MuscaMachineState;
#define TYPE_MUSCA_A_MACHINE MACHINE_TYPE_NAME("musca-a")
#define TYPE_MUSCA_B1_MACHINE MACHINE_TYPE_NAME("musca-b1")

#define MUSCA_MACHINE(obj) \
OBJECT_CHECK(MuscaMachineState, obj, TYPE_MUSCA_MACHINE)
#define MUSCA_MACHINE_GET_CLASS(obj) \
OBJECT_GET_CLASS(MuscaMachineClass, obj, TYPE_MUSCA_MACHINE)
#define MUSCA_MACHINE_CLASS(klass) \
OBJECT_CLASS_CHECK(MuscaMachineClass, klass, TYPE_MUSCA_MACHINE)
DECLARE_OBJ_CHECKERS(MuscaMachineState, MuscaMachineClass,
MUSCA_MACHINE, TYPE_MUSCA_MACHINE)

/*
* Main SYSCLK frequency in Hz
Expand Down
Loading

0 comments on commit 8110fa1

Please sign in to comment.