From nobody Sun Feb 8 19:35:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1769807894; cv=none; d=zohomail.com; s=zohoarc; b=EKaShw246ltB6B4D38u+tyJV2pUahulXSR/CLi3PKlWNp90eSPqK0aWzbICwrCTbuyq/0zvgy0YjG4pUa34ZWaE21VICVwrAAh1cHp6pbrqy/B6BtvOeUFDuCMi1VeFt/vHCNmDzmSyLsojaMXORhEXQQCLG75rUCkBMcQQV+bs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769807894; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=eNs2LarDFy0hsmo9TwTrY29oFsZoe+0raBiAeoatqOU=; b=BF39tOpaF1HYzoWW/qNk2Ux5uFU1eLaayuAeU5gmUfsAMEY4l41LgPKzBtGVEPn5IV8HVQNSIw5U1e5PsDlxKt1A92Dfcq4UUsYvlv3VA3oxh/p7CTxBiYZuVaqOLDErEaFstQ5WRNZYAnozEc3HtZHPUvkp4M16wzfibyebgSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176980789413685.05751468522999; Fri, 30 Jan 2026 13:18:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlvsP-0007wV-ML; Fri, 30 Jan 2026 16:18:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlvsO-0007w2-Df for qemu-devel@nongnu.org; Fri, 30 Jan 2026 16:18:00 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vlvsM-0005VT-0a for qemu-devel@nongnu.org; Fri, 30 Jan 2026 16:18:00 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-47f5c2283b6so20499045e9.1 for ; Fri, 30 Jan 2026 13:17:57 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-435e10e4824sm25921038f8f.1.2026.01.30.13.17.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 30 Jan 2026 13:17:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769807876; x=1770412676; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eNs2LarDFy0hsmo9TwTrY29oFsZoe+0raBiAeoatqOU=; b=PSDF+43J1fvd7XF6aPWFPpY3KUJGCK9UoUpEP6J4A5tuUiRqhKdn0YeGryPMhyWnW9 KXMCqcFEQNTE/SJLguzYlYRaqqFrF5NWx9TO4ZqB8+vXocsbwlMN8IlirV88bHA7oTQv z2r5WynHhLMAIDZ4nBijD/QmqR11hvYdKAzDzf5I+yGmhiXRW2nYsUVRCkWna6wfPFnS U2kWADu7wB3Y2NreBmPWrjDXU8qufRN1MoPE5LfdLxhm/MQ3MRXmf1IFDvT40K262GF+ Ae9wg717Prt6T+XNls5QCEABvndWtXZ+KhRtl1NULuVMs8SP6siwHUJaKMtjnmXrjcc1 DlZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769807876; x=1770412676; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=eNs2LarDFy0hsmo9TwTrY29oFsZoe+0raBiAeoatqOU=; b=wZSzfyO4gUOjOMU//tHi0VH4IbTXlWkfqLjVqCyp04b6NepgUcfkojntOHab+wq7wq 1DlppdT1DnFMjAP1w+JL6OkNN7+iyeQUwN29ZzoIl82ZKLlTkebA8FX+hz+Yk3Ghl/Ll 8h1LVipFsBvj/DCDIxpddFVJsCY2BqqK/7y6C7itd2CzZhms4C4IT65NGmS6MudwZB+m LMPBo9gANigt+TQOzqPyPeT0OgthahOzA7FHjywAm2UtV1oa3o5dh6u6yL7/hIM8gTLr CZDM9fn8jcJ/ogzVAS7sjsxqBaYkPxETSYACivAcnlUdGnw9VPF98lUpjE5oW/+UOGZX i6Rw== X-Gm-Message-State: AOJu0YyXu7SKRjR1hzH4jkfFRyj2ZJ8gXONAwnTzQhnlQsol8tYoafaR LVSqnnTtVSw6yOyRWoHRFDi4e8tigBs7YJTZGKM2kC45LeRwjIQiOcy5CY7iP1FZVCKqwiRZnMz DYXw7QEQ= X-Gm-Gg: AZuq6aIL+Z0uk5bL3WXT0jZ2O9rOJKdPTqP4qJkGhc62zFrK+/yzUNwuhfgRmSaA3ay IMRzloXo41zpnNCCBhOYAsFClrkgg6pSNw9/Zu3QJ1N9Hqc5ji7Rom2d+mGkBSkqc1a+9zAX9cD 2QuM2fYuQzYl7ZZKuB1D5oQUVPjTwDgPDRx7gb8QbxPt1EtwLoRRJxfAF1Y/Vf+QaMhNCdMmttf txqhUno7VgVyCWgDB3SE8n4LMG6rSGdRIFhvi2UO6bsGRec/tJW5/jrMi9rydQMMdmtgLACnFbO U3euU69XEVyaDRdmTVX3XPeKN/mlHxz9/FwdP+eK03Ug8XOdjB8Q8wWuDYycSRWvHNVDs41G8Nm 8QzqrZkwoLHOxPGuqiCs5KkVKEwJulD+uNBuLDooZsGwEwpQT9RUhl65bsy3k8Nfptx2fM4DpyQ 3N9vm1zirLH6Q31YKTTULqaQNCQL4qzFfyabJMczAfbapDzMPM25ifXu12LD76 X-Received: by 2002:a05:600c:34cb:b0:47e:e91d:73c0 with SMTP id 5b1f17b1804b1-482db4921bbmr54268245e9.19.1769807875883; Fri, 30 Jan 2026 13:17:55 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: jpcottin@google.com, Markus Armbruster , Roman Kiryanov , Will Hollins , Paolo Bonzini , Peter Maydell , jansene@google.com, Eric Blake Subject: [PATCH v2 1/2] bulk: Stop forward-declaring enum typedefs Date: Fri, 30 Jan 2026 22:17:45 +0100 Message-ID: <20260130211746.46667-2-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130211746.46667-1-philmd@linaro.org> References: <20260130211746.46667-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1769807895751158500 The C99 standard chapter =C2=A76.7.2.2 point 4 mentions: Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration. Align with that recommendation by defining the typedef along with the enum. For information, building with -Werror=3Dpedantic was reporting: In file included from ../../ui/kbd-state.c:10: include/ui/kbd-state.h:12:14: error: ISO C forbids forward references to = 'enum' types [-Werror,-Wpedantic] 12 | typedef enum QKbdModifier QKbdModifier; | ^ ... Reported-by: Roman Kiryanov Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- hw/riscv/riscv-iommu-bits.h | 4 ++-- hw/riscv/riscv-iommu.h | 2 -- include/hw/misc/auxbus.h | 11 ++++------- include/hw/pci/pci_device.h | 5 ++--- include/hw/ssi/ssi.h | 6 ++---- include/hw/xen/interface/io/xenbus.h | 5 ++--- include/io/channel.h | 11 ++++------- include/system/replay.h | 10 ++++------ include/ui/clipboard.h | 15 ++++++--------- include/ui/kbd-state.h | 6 ++---- pc-bios/s390-ccw/virtio.h | 5 ++--- tests/qtest/libqos/qgraph_internal.h | 10 ++++------ hw/core/loader.c | 5 ++--- hw/display/xlnx_dp.c | 11 ++++------- hw/dma/xlnx_dpdma.c | 10 ++++------ qapi/opts-visitor.c | 7 ++----- qapi/string-output-visitor.c | 6 ++---- tests/unit/check-qom-proplist.c | 6 ++---- 18 files changed, 50 insertions(+), 85 deletions(-) diff --git a/hw/riscv/riscv-iommu-bits.h b/hw/riscv/riscv-iommu-bits.h index 47fe01bee58..281afa7bc3f 100644 --- a/hw/riscv/riscv-iommu-bits.h +++ b/hw/riscv/riscv-iommu-bits.h @@ -96,11 +96,11 @@ struct riscv_iommu_pq_record { #define RISCV_IOMMU_CAP_PD17 BIT_ULL(39) #define RISCV_IOMMU_CAP_PD20 BIT_ULL(40) =20 -enum riscv_iommu_igs_modes { +typedef enum riscv_iommu_igs_modes { RISCV_IOMMU_CAP_IGS_MSI =3D 0, RISCV_IOMMU_CAP_IGS_WSI, RISCV_IOMMU_CAP_IGS_BOTH -}; +} riscv_iommu_igs_mode; =20 /* 5.4 Features control register (32bits) */ #define RISCV_IOMMU_REG_FCTL 0x0008 diff --git a/hw/riscv/riscv-iommu.h b/hw/riscv/riscv-iommu.h index 2dabd86941b..fbf70fb81e1 100644 --- a/hw/riscv/riscv-iommu.h +++ b/hw/riscv/riscv-iommu.h @@ -25,8 +25,6 @@ #include "hw/riscv/iommu.h" #include "hw/riscv/riscv-iommu-bits.h" =20 -typedef enum riscv_iommu_igs_modes riscv_iommu_igs_mode; - struct RISCVIOMMUState { /*< private >*/ DeviceState parent_obj; diff --git a/include/hw/misc/auxbus.h b/include/hw/misc/auxbus.h index 5bfdd05e152..11f1a87d44f 100644 --- a/include/hw/misc/auxbus.h +++ b/include/hw/misc/auxbus.h @@ -29,16 +29,13 @@ #include "hw/core/qdev.h" #include "qom/object.h" =20 -typedef enum AUXCommand AUXCommand; -typedef enum AUXReply AUXReply; - #define TYPE_AUXTOI2C "aux-to-i2c-bridge" OBJECT_DECLARE_SIMPLE_TYPE(AUXTOI2CState, AUXTOI2C) =20 #define TYPE_AUX_SLAVE "aux-slave" OBJECT_DECLARE_SIMPLE_TYPE(AUXSlave, AUX_SLAVE) =20 -enum AUXCommand { +typedef enum AUXCommand { WRITE_I2C =3D 0, READ_I2C =3D 1, WRITE_I2C_STATUS =3D 2, @@ -46,15 +43,15 @@ enum AUXCommand { READ_I2C_MOT =3D 5, WRITE_AUX =3D 8, READ_AUX =3D 9 -}; +} AUXCommand; =20 -enum AUXReply { +typedef enum AUXReply { AUX_I2C_ACK =3D 0, AUX_NACK =3D 1, AUX_DEFER =3D 2, AUX_I2C_NACK =3D 4, AUX_I2C_DEFER =3D 8 -}; +} AUXReply; =20 #define TYPE_AUX_BUS "aux-bus" OBJECT_DECLARE_SIMPLE_TYPE(AUXBus, AUX_BUS) diff --git a/include/hw/pci/pci_device.h b/include/hw/pci/pci_device.h index 88ccea50113..85e57fa5ca1 100644 --- a/include/hw/pci/pci_device.h +++ b/include/hw/pci/pci_device.h @@ -43,13 +43,12 @@ struct PCIDeviceClass { bool sriov_vf_user_creatable; }; =20 -enum PCIReqIDType { +typedef enum PCIReqIDType { PCI_REQ_ID_INVALID =3D 0, PCI_REQ_ID_BDF, PCI_REQ_ID_SECONDARY_BUS, PCI_REQ_ID_MAX, -}; -typedef enum PCIReqIDType PCIReqIDType; +} PCIReqIDType; =20 struct PCIReqIDCache { PCIDevice *dev; diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h index 6d6d8ccb3d4..d576e8cb061 100644 --- a/include/hw/ssi/ssi.h +++ b/include/hw/ssi/ssi.h @@ -16,19 +16,17 @@ #include "hw/core/qdev.h" #include "qom/object.h" =20 -typedef enum SSICSMode SSICSMode; - #define TYPE_SSI_PERIPHERAL "ssi-peripheral" OBJECT_DECLARE_TYPE(SSIPeripheral, SSIPeripheralClass, SSI_PERIPHERAL) =20 #define SSI_GPIO_CS "ssi-gpio-cs" =20 -enum SSICSMode { +typedef enum SSICSMode { SSI_CS_NONE =3D 0, SSI_CS_LOW, SSI_CS_HIGH, -}; +} SSICSMode; =20 /* Peripherals. */ struct SSIPeripheralClass { diff --git a/include/hw/xen/interface/io/xenbus.h b/include/hw/xen/interfac= e/io/xenbus.h index 9cd0cd7c670..3fe2f53c22c 100644 --- a/include/hw/xen/interface/io/xenbus.h +++ b/include/hw/xen/interface/io/xenbus.h @@ -16,7 +16,7 @@ * the state of the connection between the driver and the kernel's device * layers. */ -enum xenbus_state { +typedef enum xenbus_state { XenbusStateUnknown =3D 0, =20 XenbusStateInitialising =3D 1, @@ -47,8 +47,7 @@ enum xenbus_state { XenbusStateReconfiguring =3D 7, =20 XenbusStateReconfigured =3D 8 -}; -typedef enum xenbus_state XenbusState; +} XenbusState; =20 #endif /* _XEN_PUBLIC_IO_XENBUS_H */ =20 diff --git a/include/io/channel.h b/include/io/channel.h index 1b02350437d..fb6ec407a91 100644 --- a/include/io/channel.h +++ b/include/io/channel.h @@ -38,9 +38,8 @@ OBJECT_DECLARE_TYPE(QIOChannel, QIOChannelClass, #define QIO_CHANNEL_READ_FLAG_RELAXED_EOF 0x2 #define QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING 0x4 =20 -typedef enum QIOChannelFeature QIOChannelFeature; =20 -enum QIOChannelFeature { +typedef enum QIOChannelFeature { QIO_CHANNEL_FEATURE_FD_PASS, QIO_CHANNEL_FEATURE_SHUTDOWN, QIO_CHANNEL_FEATURE_LISTEN, @@ -48,16 +47,14 @@ enum QIOChannelFeature { QIO_CHANNEL_FEATURE_READ_MSG_PEEK, QIO_CHANNEL_FEATURE_SEEKABLE, QIO_CHANNEL_FEATURE_CONCURRENT_IO, -}; +} QIOChannelFeature; =20 =20 -typedef enum QIOChannelShutdown QIOChannelShutdown; - -enum QIOChannelShutdown { +typedef enum QIOChannelShutdown { QIO_CHANNEL_SHUTDOWN_READ =3D 1, QIO_CHANNEL_SHUTDOWN_WRITE =3D 2, QIO_CHANNEL_SHUTDOWN_BOTH =3D 3, -}; +} QIOChannelShutdown; =20 typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc, GIOCondition condition, diff --git a/include/system/replay.h b/include/system/replay.h index f8715ca9feb..ed34256d8bb 100644 --- a/include/system/replay.h +++ b/include/system/replay.h @@ -19,17 +19,16 @@ #include "qemu/audio.h" =20 /* replay clock kinds */ -enum ReplayClockKind { +typedef enum ReplayClockKind { /* host_clock */ REPLAY_CLOCK_HOST, /* virtual_rt_clock */ REPLAY_CLOCK_VIRTUAL_RT, REPLAY_CLOCK_COUNT -}; -typedef enum ReplayClockKind ReplayClockKind; +} ReplayClockKind; =20 /* IDs of the checkpoints */ -enum ReplayCheckpoint { +typedef enum ReplayCheckpoint { CHECKPOINT_CLOCK_WARP_START, CHECKPOINT_CLOCK_WARP_ACCOUNT, CHECKPOINT_RESET_REQUESTED, @@ -40,8 +39,7 @@ enum ReplayCheckpoint { CHECKPOINT_INIT, CHECKPOINT_RESET, CHECKPOINT_COUNT -}; -typedef enum ReplayCheckpoint ReplayCheckpoint; +} ReplayCheckpoint; =20 typedef struct ReplayNetState ReplayNetState; =20 diff --git a/include/ui/clipboard.h b/include/ui/clipboard.h index 62a96ce9ff5..2704434ded9 100644 --- a/include/ui/clipboard.h +++ b/include/ui/clipboard.h @@ -20,9 +20,6 @@ * is supported for now. */ =20 -typedef enum QemuClipboardType QemuClipboardType; -typedef enum QemuClipboardNotifyType QemuClipboardNotifyType; -typedef enum QemuClipboardSelection QemuClipboardSelection; typedef struct QemuClipboardPeer QemuClipboardPeer; typedef struct QemuClipboardNotify QemuClipboardNotify; typedef struct QemuClipboardInfo QemuClipboardInfo; @@ -36,10 +33,10 @@ extern const VMStateDescription vmstate_cbinfo; * @QEMU_CLIPBOARD_TYPE_TEXT: text/plain; charset=3Dutf-8 * @QEMU_CLIPBOARD_TYPE__COUNT: type count. */ -enum QemuClipboardType { +typedef enum QemuClipboardType { QEMU_CLIPBOARD_TYPE_TEXT, QEMU_CLIPBOARD_TYPE__COUNT, -}; +} QemuClipboardType; =20 /* same as VD_AGENT_CLIPBOARD_SELECTION_* */ /** @@ -50,12 +47,12 @@ enum QemuClipboardType { * @QEMU_CLIPBOARD_SELECTION_SECONDARY: secondary selection (dunno). * @QEMU_CLIPBOARD_SELECTION__COUNT: selection count. */ -enum QemuClipboardSelection { +typedef enum QemuClipboardSelection { QEMU_CLIPBOARD_SELECTION_CLIPBOARD, QEMU_CLIPBOARD_SELECTION_PRIMARY, QEMU_CLIPBOARD_SELECTION_SECONDARY, QEMU_CLIPBOARD_SELECTION__COUNT, -}; +} QemuClipboardSelection; =20 /** * struct QemuClipboardPeer @@ -81,10 +78,10 @@ struct QemuClipboardPeer { * * Clipboard notify type. */ -enum QemuClipboardNotifyType { +typedef enum QemuClipboardNotifyType { QEMU_CLIPBOARD_UPDATE_INFO, QEMU_CLIPBOARD_RESET_SERIAL, -}; +} QemuClipboardNotifyType; =20 /** * struct QemuClipboardNotify diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h index 1f37b932eb6..3522ebe51b9 100644 --- a/include/ui/kbd-state.h +++ b/include/ui/kbd-state.h @@ -9,9 +9,7 @@ =20 #include "qapi/qapi-types-ui.h" =20 -typedef enum QKbdModifier QKbdModifier; - -enum QKbdModifier { +typedef enum QKbdModifier { QKBD_MOD_NONE =3D 0, =20 QKBD_MOD_SHIFT, @@ -23,7 +21,7 @@ enum QKbdModifier { QKBD_MOD_CAPSLOCK, =20 QKBD_MOD__MAX -}; +} QKbdModifier; =20 typedef struct QKbdState QKbdState; =20 diff --git a/pc-bios/s390-ccw/virtio.h b/pc-bios/s390-ccw/virtio.h index 5c5e808a500..67fd0da9fd2 100644 --- a/pc-bios/s390-ccw/virtio.h +++ b/pc-bios/s390-ccw/virtio.h @@ -173,13 +173,12 @@ struct VirtioBlkConfig { } __attribute__((packed)); typedef struct VirtioBlkConfig VirtioBlkConfig; =20 -enum guessed_disk_nature_type { +typedef enum guessed_disk_nature_type { VIRTIO_GDN_NONE =3D 0, VIRTIO_GDN_DASD =3D 1, VIRTIO_GDN_CDROM =3D 2, VIRTIO_GDN_SCSI =3D 3, -}; -typedef enum guessed_disk_nature_type VirtioGDN; +} VirtioGDN; =20 VirtioGDN virtio_guessed_disk_nature(void); void virtio_assume_eckd(void); diff --git a/tests/qtest/libqos/qgraph_internal.h b/tests/qtest/libqos/qgra= ph_internal.h index 87fab1f9f0d..e2e740a59db 100644 --- a/tests/qtest/libqos/qgraph_internal.h +++ b/tests/qtest/libqos/qgraph_internal.h @@ -27,8 +27,6 @@ #include "qgraph.h" =20 typedef struct QOSGraphMachine QOSGraphMachine; -typedef enum QOSEdgeType QOSEdgeType; -typedef enum QOSNodeType QOSNodeType; =20 /* callback called when the walk path algorithm found a * valid path @@ -36,19 +34,19 @@ typedef enum QOSNodeType QOSNodeType; typedef void (*QOSTestCallback) (QOSGraphNode *path, int len); =20 /* edge types*/ -enum QOSEdgeType { +typedef enum QOSEdgeType { QEDGE_CONTAINS, QEDGE_PRODUCES, QEDGE_CONSUMED_BY -}; +} QOSEdgeType; =20 /* node types*/ -enum QOSNodeType { +typedef enum QOSNodeType { QNODE_MACHINE, QNODE_DRIVER, QNODE_INTERFACE, QNODE_TEST -}; +} QOSNodeType; =20 /* Graph Node */ struct QOSGraphNode { diff --git a/hw/core/loader.c b/hw/core/loader.c index 5cbfba0a86d..5b6f022428c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -1688,15 +1688,14 @@ HumanReadableText *qmp_x_query_roms(Error **errp) return human_readable_text_from_str(buf); } =20 -typedef enum HexRecord HexRecord; -enum HexRecord { +typedef enum HexRecord { DATA_RECORD =3D 0, EOF_RECORD, EXT_SEG_ADDR_RECORD, START_SEG_ADDR_RECORD, EXT_LINEAR_ADDR_RECORD, START_LINEAR_ADDR_RECORD, -}; +} HexRecord; =20 /* Each record contains a 16-bit address which is combined with the upper = 16 * bits of the implicit "next address" to form a 32-bit address. diff --git a/hw/display/xlnx_dp.c b/hw/display/xlnx_dp.c index a24e95f0a73..1ab2375625c 100644 --- a/hw/display/xlnx_dp.c +++ b/hw/display/xlnx_dp.c @@ -212,7 +212,7 @@ #define DP_GRAPHIC_DMA_CHANNEL (3) #define DP_VIDEO_DMA_CHANNEL (0) =20 -enum DPGraphicFmt { +typedef enum DPGraphicFmt { DP_GRAPHIC_RGBA8888 =3D 0 << 8, DP_GRAPHIC_ABGR8888 =3D 1 << 8, DP_GRAPHIC_RGB888 =3D 2 << 8, @@ -225,9 +225,9 @@ enum DPGraphicFmt { DP_GRAPHIC_2BPP =3D 9 << 8, DP_GRAPHIC_1BPP =3D 10 << 8, DP_GRAPHIC_MASK =3D 0xF << 8 -}; +} DPGraphicFmt; =20 -enum DPVideoFmt { +typedef enum DPVideoFmt { DP_NL_VID_CB_Y0_CR_Y1 =3D 0, DP_NL_VID_CR_Y0_CB_Y1 =3D 1, DP_NL_VID_Y0_CR_Y1_CB =3D 2, @@ -254,10 +254,7 @@ enum DPVideoFmt { DP_NL_VID_YV16CL_420_10BPC =3D 23, DP_NL_VID_YV16CL2_420_10BPC =3D 24, DP_NL_VID_FMT_MASK =3D 0x1F -}; - -typedef enum DPGraphicFmt DPGraphicFmt; -typedef enum DPVideoFmt DPVideoFmt; +} DPVideoFmt; =20 static const VMStateDescription vmstate_dp =3D { .name =3D TYPE_XLNX_DP, diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c index 32f56036a4c..ef5488b3eca 100644 --- a/hw/dma/xlnx_dpdma.c +++ b/hw/dma/xlnx_dpdma.c @@ -122,15 +122,15 @@ =20 #define DPDMA_FRAG_MAX_SZ (4096) =20 -enum DPDMABurstType { +typedef enum DPDMABurstType { DPDMA_INCR =3D 0, DPDMA_FIXED =3D 1 -}; +} DPDMABurstType; =20 -enum DPDMAMode { +typedef enum DPDMAMode { DPDMA_CONTIGOUS =3D 0, DPDMA_FRAGMENTED =3D 1 -}; +} DPDMAMode; =20 struct DPDMADescriptor { uint32_t control; @@ -153,8 +153,6 @@ struct DPDMADescriptor { uint32_t crc; }; =20 -typedef enum DPDMABurstType DPDMABurstType; -typedef enum DPDMAMode DPDMAMode; typedef struct DPDMADescriptor DPDMADescriptor; =20 static bool xlnx_dpdma_desc_is_last(DPDMADescriptor *desc) diff --git a/qapi/opts-visitor.c b/qapi/opts-visitor.c index 3d1a28b4191..66b1b931a31 100644 --- a/qapi/opts-visitor.c +++ b/qapi/opts-visitor.c @@ -20,8 +20,7 @@ #include "qapi/visitor-impl.h" =20 =20 -enum ListMode -{ +typedef enum ListMode { LM_NONE, /* not traversing a list of repeated options */ =20 LM_IN_PROGRESS, /* @@ -58,9 +57,7 @@ enum ListMode * No more QemuOpt instance in the list. * The traversal has been completed. */ -}; - -typedef enum ListMode ListMode; +} ListMode; =20 struct OptsVisitor { diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c index 5115536b153..5d175773356 100644 --- a/qapi/string-output-visitor.c +++ b/qapi/string-output-visitor.c @@ -17,7 +17,7 @@ #include #include "qemu/range.h" =20 -enum ListMode { +typedef enum ListMode { LM_NONE, /* not traversing a list of repeated options */ LM_STARTED, /* next_list() ready to be called */ =20 @@ -48,9 +48,7 @@ enum ListMode { LM_UNSIGNED_INTERVAL,/* Same as above, only for an unsigned interval. = */ =20 LM_END, /* next_list() called, about to see last element.= */ -}; - -typedef enum ListMode ListMode; +} ListMode; =20 struct StringOutputVisitor { diff --git a/tests/unit/check-qom-proplist.c b/tests/unit/check-qom-proplis= t.c index ee3c6fb32b1..6f3dbc4407a 100644 --- a/tests/unit/check-qom-proplist.c +++ b/tests/unit/check-qom-proplist.c @@ -40,15 +40,13 @@ typedef struct DummyObjectClass DummyObjectClass; DECLARE_INSTANCE_CHECKER(DummyObject, DUMMY_OBJECT, TYPE_DUMMY) =20 -typedef enum DummyAnimal DummyAnimal; - -enum DummyAnimal { +typedef enum DummyAnimal { DUMMY_FROG, DUMMY_ALLIGATOR, DUMMY_PLATYPUS, =20 DUMMY_LAST, -}; +} DummyAnimal; =20 const QEnumLookup dummy_animal_map =3D { .array =3D (const char *const[]) { --=20 2.52.0 From nobody Sun Feb 8 19:35:37 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1769807900; cv=none; d=zohomail.com; s=zohoarc; b=BevdCBMS+b4cm8kC5YmVGeSXt/fJR3tprMOGgcAkX/137RDNr5I5GiURhSokY8yd3/V+DCakEw5QcbqhZsvFZmj+1036mEWbKC2vQJcwKndeFKZY0t9IA3N87leefZ0eoVRFWXnnsTBsu0VaD9x4NnF9R/DpdK8kfKWsfff+WbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769807900; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kNGLFMFJ15V3YxrqLyoQP5mJtCmYxpiMYx7uMcWLKc8=; b=H+t3pFMy+JHbX7w1vP9jWszWSNYHGHgpQ8qewJeDbphAoME2FYNEMEe8rdziPkNsvjud5MGj+XzuQVEb/ZRh0VFOH/cCQ8KnxEIPAVR0apQjsqn4w9xXGxN3p0SraPne7IYZTi00ssV1D2z98RMTxwgrDiyvZXOYj7vNKw+K/B0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1769807900829603.891178014599; Fri, 30 Jan 2026 13:18:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlvsW-0007yP-4E; Fri, 30 Jan 2026 16:18:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vlvsU-0007xZ-56 for qemu-devel@nongnu.org; Fri, 30 Jan 2026 16:18:06 -0500 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vlvsS-0005Xt-LE for qemu-devel@nongnu.org; Fri, 30 Jan 2026 16:18:05 -0500 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4806f3fc50bso25796205e9.0 for ; Fri, 30 Jan 2026 13:18:04 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4806ce4c515sm212846095e9.11.2026.01.30.13.18.01 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 30 Jan 2026 13:18:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769807883; x=1770412683; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kNGLFMFJ15V3YxrqLyoQP5mJtCmYxpiMYx7uMcWLKc8=; b=z5/EcdKUDDRx4CF4Avgbd1v1yzK4PtVZBfhuJ0DlUrsxqKMhrKD1KAwaAV6Mk4jUCH JH+ztPFU0Q/s6taEDPLlmMZ+T1jIQWr+tWXzi0li6ErDgga9bYzAnyIUXMXBmCYoayEw VQnoJag+uYtLgPeBvF3VfMiEm0/ea7H1rkWTTXHzB5iD0eJDTBIj9I/TfiVB0r1yW12Q SAAZUc3DHlgpBh0EzY+ImLAda4v8S6e2RlvhC0M8TduoToTn/WOf5p80B4fC6U8WQkwx G8TWqkpdfkYZP+Xa5FMXDgbqOqrqF9p7QnaSm7XchOn5vVCONsZ0kIsct9eQ9V+z/0er w15A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769807883; x=1770412683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=kNGLFMFJ15V3YxrqLyoQP5mJtCmYxpiMYx7uMcWLKc8=; b=alKID4y1hR5WhYs0BVcHGzVoBfM0Ej/xYHYXIz3hQWVT41WDPKftaufPT5CUChgjZb h6+J3RN1ksJWkV9r05loXZ0VTwypKN7UZ1G7A8GUscl1q+vgGNaVeo9f5uQpn3zxa0NS 7qPOl9lk/gBG6YBaaCb2CoHXL2sQOg4eh87SKEgfoni807m9GErfp2SgcFf42+dxcHnf xlBHIinhOJeiDAlTNLban4UZc/gs1vQQd6rFjtd3LK+ux0/sdqAhbOMXfqmzwX3orxWN pmtnLJAPDZS3nsvOetg9Cwnh+oqQBScKQXMaXovAOkqqo7RYbbb+9qsiVV92sv6HJAGO mncw== X-Gm-Message-State: AOJu0Yz2xAg62fYtWz9UCrEWN3NbBEEx+Ce5t6qZdOl1lOlfsxbPzjpf XyEaXAKnNZCiBCJMZF5YSlJuJwbM37F4+T8c/9KM+DXFlgG7ZYYUSegutr+PxH3/4jD/j6AVsnT PeinKkeg= X-Gm-Gg: AZuq6aKKgEheaXf0+/HqPCk0HQl4nS1m3f18HNZv3qmw6/p1e6UyhHYe40BsuHMknPz M6yqD87U5NdrkV4/+n2ev6BpXUS8GhqBgT1RhM4JAreA+s7QdKmpn6gJKP1WdKXcCUkWYj+HsPt m6t+aq9mmWQMATjmZEG63e/2tU4KZmepISel+zHfyCqJyMI/KB2W675gBCEyVhwd7vBpyKkFxjf xpCOWc3scrJxPorkK/IKwFeaihq7N+QNnxM8rbI9WAMFc4WHCDBzmBdAKpVsLX2bFFA+xc9c33I jbS5S28nptB9VV+SoOYSjx0cyAfETRI3zXRY3lTON1G26Z/tBAa9GMMtcHc90+gVy6EZVXssYDc VqT0EnX6n0izo8iN2m87OnxeRg/kZfqH0GVnISPemLz8jOnb49q5DFX0VGB2LpyXfJJM/GQ6lRi ctHkLXTKlQJdSOcheYwgNNaT2htEI5G6RlV0ypP1cco/nOGp0UBxALsJ3rHMn8 X-Received: by 2002:a05:600c:a08c:b0:47a:975b:e3e6 with SMTP id 5b1f17b1804b1-482db493a7cmr50762575e9.18.1769807882737; Fri, 30 Jan 2026 13:18:02 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: jpcottin@google.com, Markus Armbruster , Roman Kiryanov , Will Hollins , Paolo Bonzini , Peter Maydell , jansene@google.com, Eric Blake Subject: [PATCH v2 2/2] docs/devel: Mention enum typedefs forward-declaration is not allowed Date: Fri, 30 Jan 2026 22:17:46 +0100 Message-ID: <20260130211746.46667-3-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130211746.46667-1-philmd@linaro.org> References: <20260130211746.46667-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=philmd@linaro.org; helo=mail-wm1-x330.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1769807901649158500 Do not allow enum typedef forward-declaration to comply with C99 standard chapter =C2=A76.7.2.2 point 4: Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration. Update checkpatch.pl to catch further additions. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- docs/devel/style.rst | 11 +++++++++++ scripts/checkpatch.pl | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 12e509d10de..5ab5c21447d 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -416,6 +416,17 @@ definitions instead of typedefs in headers and functio= n prototypes; this avoids problems with duplicated typedefs and reduces the need to include headers from other headers. =20 +Enumeration (enum) type can not be forward declared as typedef, because +C compilers should be able to know the size of enums before hand. Simply +define the typedef along with the enum: + +.. code-block:: c + + typedef enum MyEnum { + FOO, + BAR, + } MyEnum; + Bitfields --------- =20 diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3a9557417f7..119b2a6c002 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2414,6 +2414,11 @@ sub process { ERROR("missing space after $1 definition\n" . $herecurr); } =20 +# forward declared enum typedef + if ($line =3D~ /^.\s*typedef\s+enum(?:\s+$Ident)?(?:\s+$Ident)?;/) { + ERROR("forward declared enum typedef\n" . $herecurr); + } + # check for spacing round square brackets; allowed: # 1. with a type on the left -- int [] a; # 2. at the beginning of a line for slice initialisers -- [0...10] =3D 5, --=20 2.52.0