On Tue, Jun 24, 2025 at 14:27:58 +0200, Michal Privoznik via Devel wrote:
From: Michal Privoznik <mprivozn(a)redhat.com>
Inside of qemuMonitorJSONGetBlockInfo() there's a for loop in
which a variable of struct qemuDomainDiskInfo type is declared
and initialized as { false }. This works only because stdbool.h
declares 'false' as a macro, so preprocessor expands initializer
to proper form of { 0 }.
Could you please elaborate what's wrong here?
The struct is declared as:
struct qemuDomainDiskInfo {
bool removable;
bool tray;
bool tray_open;
bool empty;
int io_status;
char *nodename;
};
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/qemu/qemu_monitor_json.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index a6fb2a2013..2de68d6518 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2206,7 +2206,7 @@ int qemuMonitorJSONGetBlockInfo(qemuMonitor *mon,
for (i = 0; i < virJSONValueArraySize(devices); i++) {
virJSONValue *dev;
virJSONValue *image;
- struct qemuDomainDiskInfo info = { false };
Thus this defines 'info' as 'struct qemuDomainDiskInfo' and initializes
the 'removable' (first member) to 'false'. The rest is then
empty-initialized.
+ struct qemuDomainDiskInfo info = { 0 };
const char *thisdev;
const char *status;
const char *qdev;
--
2.49.0