Re: [PATCH] qemu_monitor_json: Use proper initializer in qemuMonitorJSONGetBlockInfo()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 24, 2025 at 14:27:58 +0200, Michal Privoznik via Devel wrote:
> From: Michal Privoznik <mprivozn@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx>
> ---
>  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
> 



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux