From nobody Mon Feb 9 03:30:15 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=1769792697; cv=none; d=zohomail.com; s=zohoarc; b=jWkZFDwpjSIP4WLcGINodkJU/XCyHiqKZTMqZkH1kxpJW8QKKbQjsKnFa4uy/9HIOBQKJ3YUPoDqLanejMwqn5tAKlICBd5AG3umobAvZ9J90fpwvekfAZQ4DNDzSpJY8kx2oovaZocYBV1oqwUtbP3Rg3ca6mmjVzktZIqmZCs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769792697; 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=yBsvtlT9a2mEFTQbV/7WLscemlhDinZSQIc0AYLytT8=; b=MbsSpBJAw8FnbLvJaz402ZOE712IfGDdzJcRjKls0OE1ZBkQiisXSe/BUbjG3KYC8rm5BzxX2ibfyXUrwQSeOrOEZm0zD0FLPTTvsZc3aSkFi3zWfLyH/vRkI+peBVQqQItNjSDqergLx1xs2No+T0ZaqqOurRMYTTmANQ5ptXA= 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 1769792696920823.1913628623046; Fri, 30 Jan 2026 09:04:56 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlrv6-0000e3-Tb; Fri, 30 Jan 2026 12:04:32 -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 1vlrv5-0000de-AV for qemu-devel@nongnu.org; Fri, 30 Jan 2026 12:04:31 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vlrv2-0001hM-Td for qemu-devel@nongnu.org; Fri, 30 Jan 2026 12:04:31 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4806f80cac9so14738615e9.1 for ; Fri, 30 Jan 2026 09:04:28 -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-482e256f639sm17768835e9.13.2026.01.30.09.04.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 30 Jan 2026 09:04:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769792667; x=1770397467; 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=yBsvtlT9a2mEFTQbV/7WLscemlhDinZSQIc0AYLytT8=; b=PkA1hAlC8PkCf+2uGQyRpKc0jhJVpXltUhQW3ccWmXaTtzLjIfvRap/eIpkqs0LAkH IrPKPBLOstsxbz5r3SUso3xQlbWrzdb0bOyUR6KhhJ4in/q45LhwIXla7w7MEOJ8x3nl t8DrozwffYDxamb8QhaAXg9GitvdBSTJIkk1FDTrEKnUBwxINsSjbfiw0baBA1Mr0k1H HW5VED2n+H5D1xCtmV+Q92dbwkN4XrdzOWTIActZvKRJbwjwHI10ZjoAJFAgpxOU9RRX MyJ/JdAaHxY6/lFoIbhTIDeMQyuaFAZUcSQug7Gtiv6FpsTnqvw16mXCBuEorJY8VuPA nyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769792667; x=1770397467; 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=yBsvtlT9a2mEFTQbV/7WLscemlhDinZSQIc0AYLytT8=; b=QzfWS/DVrDvOwZomTNLEIW5rS1erT+0+3WMLhi9w//37yJoZ+NSLw4XEhovUDwtlv6 A+fbP23ax7ZiMQCvFy25GDl3LOxaj728GgkeQgzaWZLV2jcT4p5iMgVwHj7wtGzL/I/t uADB859+ABQ4uue00lYH49hk/O4uBgfVIvZA4jxh7GZfUHYNfyi1znRNI78x6/Kt9Qrm Yb9dlRYKpNCBkNjjB01EO9yfLswODq7Jp6iw/Bft+Pkr0fepR8VN/d3fPxyPVTqfI3PI 8fI7cNWmz4yCJMEEAFm9MwdVPcE4yz8lHT56xjS+b3+vCnBhKKHlk7SeTmZIIf9N9QLv rZMg== X-Gm-Message-State: AOJu0YxwRZK5CCzdUImmxBQqQvdvpM8i9OxXwpwMfTm4fIVkqYQCO+L2 Ynsapr3l6zAWcc9/H4elQ1hE1B/RszXoxbS39cwAlgOOvxau0eMFZAzEmAd6lPSYOURoCGjL/TB eK8x8VSM= X-Gm-Gg: AZuq6aKv7817bgLs9ytl/4YU8pO1q7uMXBe653heqAsvZzjRIpdcByXiJGsMIFomhHQ R/ZcEB+eo5Cx2R85CJtkr5YXZ5f8VcE7ihmyuURSb1G5cWQecug+DN/S2WlygMQwlNSBhKhdNdm j6hE38TgNRe8Tq4XKmR3OjF/2LusYidx996LHwyHI8P+Fmgvg0TYImKSsS3H3xUUkQUkWkJTyw7 xcs1HBr2bnixzYN/VCT+iFr7+P+dVIM0+rjBCzVJfagNjVlSR4VJEPxbY7Csu/6U3pehtxsm/Dz 8UyYiT8wqC+wBDqZv9DjRqlsxGki0kjSCQT2zcYukwxGzZC4KiaClmn2iA9A2QuU5cJNc8EzljO sAR7ajAkOeSiaRkNMAD2++ALWyDVAHniYPhTXgD35qz1Q6BeArt1qAPaz83lkSxO+dh7rdcRiDH dKtYCkdZ+upehUGp+T6sFP9HnLAWeakwqj0EDZzZmyvTbvP0lLqxaFLSZSRM+q X-Received: by 2002:a05:600c:3b23:b0:47a:8cce:2940 with SMTP id 5b1f17b1804b1-482db49ff27mr41901715e9.14.1769792666693; Fri, 30 Jan 2026 09:04:26 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Roman Kiryanov , Paolo Bonzini , Peter Maydell , Eric Blake , Will Hollins , jpcottin@google.com, jansene@google.com Subject: [PATCH 1/2] bulk: Stop forward-declaring enum typedefs Date: Fri, 30 Jan 2026 18:04:16 +0100 Message-ID: <20260130170417.43356-2-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130170417.43356-1-philmd@linaro.org> References: <20260130170417.43356-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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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: 1769792698786158500 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..84b7d6c54a4 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, -}; +} QemuClipboardSelection; =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 Mon Feb 9 03:30:15 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=1769792706; cv=none; d=zohomail.com; s=zohoarc; b=TuXU9Ez7yC4xKKYnGhfK8AQVMJL5AN8Fu6wzfVxby72D1BZc/abWEQG2tKprz3HLTSU37fD7WqIW3xshTlcn8xKxIAUgSYpd5vX5pqeXomGGybLvqkKQ1HV8h6ZJF0eQpXPXbySScPNPvCkdGHtMACUZ2XatlU8ICF6o3fF2TE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769792706; 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=hEgcS586WoXQ1bA7kiDLx0TFML9LLxwYDy+VF81ztcM=; b=J3q4I/UhRe1uhJIYXm6r+WVcZUwnG9VJi2qH0Rff9VHeLtUcgCOdz2gzr+P/cuBKxg70EEe5TbNhi3OTcbfjpWVIzzCbTsmZl1IQe81puPvbUBfCtBfE1cCmHgygQ1gSmH7v/wjFX9z80DAaAkeAJBQ6bp5ZvLRUDt1vjIVrOOk= 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 17697927063471022.9493397847227; Fri, 30 Jan 2026 09:05:06 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vlrvC-0000er-86; Fri, 30 Jan 2026 12:04:38 -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 1vlrvA-0000eV-SF for qemu-devel@nongnu.org; Fri, 30 Jan 2026 12:04:36 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vlrv9-0001hp-EA for qemu-devel@nongnu.org; Fri, 30 Jan 2026 12:04:36 -0500 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4806f3fc50bso24004925e9.0 for ; Fri, 30 Jan 2026 09:04:35 -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-48066bee687sm414400655e9.5.2026.01.30.09.04.32 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 30 Jan 2026 09:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1769792673; x=1770397473; 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=hEgcS586WoXQ1bA7kiDLx0TFML9LLxwYDy+VF81ztcM=; b=TfLTpYKNAxkoeXQtzxjwa8XRIWyO6BbTPunhgMq26uBwP8IrQlYz0gMkdTKBPDW9ew 0rvN5ON4+Ofyv4/CBywjfVV/r6tiF715IKEKDLYh7CONESL0fhgm2qjpu8IrmFPO82Us majwxYFJ0PgO0lmXGDIfrPKqQyWdcV0k041PdNn04NqagstxmRTZ5Qft/qvhRgwxJK5U M8B1GVYxydFFx4bR3H3uVh4D2PmoJFTAAQLuntKJ7yKxblIDJbnBnd9lgM2ca0/B0wEA qMIj85ktw3X4Y0sgipMoD9QVKCP2Bm1qdLm+aPgBWaiDZSA/m4JRL85bq/07cXpg5Cr1 P3kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769792673; x=1770397473; 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=hEgcS586WoXQ1bA7kiDLx0TFML9LLxwYDy+VF81ztcM=; b=uKsV3KaFSPeF7V/fllUN2YWE9n2TpgGNK2L+u5b/Fv3lwb8M7hvyBi9HOFYsoCZ5gu WSvrt1D7CoB6GGnvCOMrbPUryLQRIo7k8mWSvSXQirw1i5ZQlucsIa36eiqP6SwB5YKA +W2K+T7xCjzoVee8dbnBoiYwtVn39/QlbzHVLa4IViuUYV+FrDHErYLhV7wYc6Mu+ntI K695U038F4uuhbFmbvTCpHQ3NoPHG92luAiHJSW+L9RdO2rWfcgzbt2jZiLSAOMqAOjS AmPW/H8Spx3QS3T8Rpb1kTCrvq/+xqECfkR0Pcaqgikptetw3yxUwt9mNXlGb0xUYe1K 4hdA== X-Gm-Message-State: AOJu0Yx0i8FjInUD3QRIr7Lk72ZGskEDPe7aGqnKJuqUlNxsiks+q9mV vK8sBtbhdZXG1ZHZpnViSa7fvyGbK/XXPqsDEkdh7hjNBT8vqy54P6L8iYb+luiwa4qhQLuY49J COuPYXX0= X-Gm-Gg: AZuq6aK9/YyzT97lYBhaQe/WyzmVyzRTdaXE72ULt5zd2TlYkUVoaKSg1Kkg66m8uXR ZyeEv8MUJlbDyG8TlFDCsa7mVt+/p9HagROJnQO78o3mwOqQWtsan5ZjRFarx2S5lhAZErJOtlX hoHKJjxvm2a0rxc4wE8YRLd17TTIV/3ipuasvkO9PInuWWzUWxccMMHyiR0JtmT382sdPtfVWLK HZLFoJ42x+PZTjzyJ8q2PVj8dgy7ZWctCxz+lmjSVw8h1pk8j2mPv0U7g50kqTy4SCuB+30gGxm IZ7NbmOJ+qpUCyMpKtSg1uY9tKPmT+bjLLwgs47FoBqG8cDeJWvckcX4B4sZNaOFQED8goU3WOw dJgVuPcpsoTD484bQs7TZHgtkAI3bp51CHvr/b5eaYSg0wBEW+8gGhkmfXnhpDvBNno06KpgXgD I7kfn3MZFLPzy2c+5Pg8opuvrNK1cUhUUEXJNyBUVYcijzDmExmu2zX97Vsv6q X-Received: by 2002:a05:600c:4e87:b0:477:b734:8c53 with SMTP id 5b1f17b1804b1-482db46557cmr41828305e9.12.1769792673568; Fri, 30 Jan 2026 09:04:33 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Markus Armbruster , Roman Kiryanov , Paolo Bonzini , Peter Maydell , Eric Blake , Will Hollins , jpcottin@google.com, jansene@google.com Subject: [PATCH 2/2] docs/devel: Mention enum typedefs forward-declaration is not allowed Date: Fri, 30 Jan 2026 18:04:17 +0100 Message-ID: <20260130170417.43356-3-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130170417.43356-1-philmd@linaro.org> References: <20260130170417.43356-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::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.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: 1769792707821158500 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. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Pierrick Bouvier --- docs/devel/style.rst | 11 +++++++++++ 1 file changed, 11 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 --=20 2.52.0