[PATCH] Fix missing-field-initializers error

From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn> When compile libvirt via ninja tool with default configuration, it report the error message as the following: "missing initializer for field 'path' of 'virTPMBinaryInfo'". So initialize the 'path' field in 'virTPMBinaryInfo' with 'NULL'. Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn> --- src/util/virtpm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/util/virtpm.c b/src/util/virtpm.c index cf4c7c4..a02d933 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -122,13 +122,16 @@ typedef struct _virTPMBinaryInfo { static virTPMBinaryInfo swtpmBinaries[VIR_TPM_BINARY_LAST] = { [VIR_TPM_BINARY_SWTPM] = { + .path = NULL, .parm = "socket", .capsParse = virTPMSwtpmFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_SETUP] = { + .path = NULL, .capsParse = virTPMSwtpmSetupFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_IOCTL] = { + .path = NULL, }, }; -- 1.8.3.1

On Thu, Jan 13, 2022 at 12:11:47AM +0800, huangy81@chinatelecom.cn wrote:
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
When compile libvirt via ninja tool with default configuration, it report the error message as the following: "missing initializer for field 'path' of 'virTPMBinaryInfo'". So initialize the 'path' field in 'virTPMBinaryInfo' with 'NULL'.
I'm wondering why this isn't reported by our automated CI. What OS distro / GCC / CLang version are you seeing this with ?
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn> --- src/util/virtpm.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c index cf4c7c4..a02d933 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -122,13 +122,16 @@ typedef struct _virTPMBinaryInfo {
static virTPMBinaryInfo swtpmBinaries[VIR_TPM_BINARY_LAST] = { [VIR_TPM_BINARY_SWTPM] = { + .path = NULL, .parm = "socket", .capsParse = virTPMSwtpmFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_SETUP] = { + .path = NULL, .capsParse = virTPMSwtpmSetupFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_IOCTL] = { + .path = NULL, }, };
-- 1.8.3.1
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

在 2022/1/13 0:22, Daniel P. Berrangé 写道:
On Thu, Jan 13, 2022 at 12:11:47AM +0800, huangy81@chinatelecom.cn wrote:
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
When compile libvirt via ninja tool with default configuration, it report the error message as the following: "missing initializer for field 'path' of 'virTPMBinaryInfo'". So initialize the 'path' field in 'virTPMBinaryInfo' with 'NULL'.
I'm wondering why this isn't reported by our automated CI.
What OS distro / GCC / CLang version are you seeing this with ? The following is my work env:
OS distro: CentOS Linux release 7.9.2009 (Core) GCC version: gcc (GCC) 7.5.0 ninja: 1.10.2 meson: 0.55.1 The following step can reproduce the error: meson builddir meson configure --prefix=/usr/local ninja -C builddir Thanks for quick response. Hyman
Signed-off-by: Hyman Huang(黄勇) <huangy81@chinatelecom.cn> --- src/util/virtpm.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/src/util/virtpm.c b/src/util/virtpm.c index cf4c7c4..a02d933 100644 --- a/src/util/virtpm.c +++ b/src/util/virtpm.c @@ -122,13 +122,16 @@ typedef struct _virTPMBinaryInfo {
static virTPMBinaryInfo swtpmBinaries[VIR_TPM_BINARY_LAST] = { [VIR_TPM_BINARY_SWTPM] = { + .path = NULL, .parm = "socket", .capsParse = virTPMSwtpmFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_SETUP] = { + .path = NULL, .capsParse = virTPMSwtpmSetupFeatureTypeFromString, }, [VIR_TPM_BINARY_SWTPM_IOCTL] = { + .path = NULL, }, };
-- 1.8.3.1
Regards, Daniel

On Thu, Jan 13, 2022 at 12:37:45AM +0800, Hyman wrote:
在 2022/1/13 0:22, Daniel P. Berrangé 写道:
On Thu, Jan 13, 2022 at 12:11:47AM +0800, huangy81@chinatelecom.cn wrote:
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
When compile libvirt via ninja tool with default configuration, it report the error message as the following: "missing initializer for field 'path' of 'virTPMBinaryInfo'". So initialize the 'path' field in 'virTPMBinaryInfo' with 'NULL'.
I'm wondering why this isn't reported by our automated CI.
What OS distro / GCC / CLang version are you seeing this with ? The following is my work env:
OS distro: CentOS Linux release 7.9.2009 (Core)
CentOS 7 is no longer a supported build platform for libvirt (nor QEMU either)
GCC version: gcc (GCC) 7.5.0
That GCC is used in Ubuntu 18.04 and isn't issuing warnings about this. Finally -Wmissing-field-initializers is explicitly documented as *not* issuing a warning for named fields [quote "info gcc"] '-Wmissing-field-initializers' Warn if a structure's initializer has some fields missing. For example, the following code causes such a warning, because 'x.h' is implicitly zero: struct s { int f, g, h; }; struct s x = { 3, 4 }; This option does not warn about designated initializers, so the following modification does not trigger a warning: struct s { int f, g, h; }; struct s x = { .f = 3, .g = 4 }; [/quote] Given CentOS 7 is no longer a supported platform, we can see GCC 7.5.0 works on other platforms, and the -Wmissing-field-initializers warning isn';t supposed to complain about this scenario, I don't want to take this patch. I'd also strongly encourage you to upgrade to a newer development platform, given CentOS 7 is explicitly not something the libvirt project wants to target anymore. Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

在 2022/1/13 1:31, Daniel P. Berrangé 写道:
On Thu, Jan 13, 2022 at 12:37:45AM +0800, Hyman wrote:
在 2022/1/13 0:22, Daniel P. Berrangé 写道:
On Thu, Jan 13, 2022 at 12:11:47AM +0800, huangy81@chinatelecom.cn wrote:
From: Hyman Huang(黄勇) <huangy81@chinatelecom.cn>
When compile libvirt via ninja tool with default configuration, it report the error message as the following: "missing initializer for field 'path' of 'virTPMBinaryInfo'". So initialize the 'path' field in 'virTPMBinaryInfo' with 'NULL'.
I'm wondering why this isn't reported by our automated CI.
What OS distro / GCC / CLang version are you seeing this with ? The following is my work env:
OS distro: CentOS Linux release 7.9.2009 (Core)
CentOS 7 is no longer a supported build platform for libvirt (nor QEMU either)
GCC version: gcc (GCC) 7.5.0
That GCC is used in Ubuntu 18.04 and isn't issuing warnings about this.
Finally -Wmissing-field-initializers is explicitly documented as *not* issuing a warning for named fields
[quote "info gcc"] '-Wmissing-field-initializers' Warn if a structure's initializer has some fields missing. For example, the following code causes such a warning, because 'x.h' is implicitly zero:
struct s { int f, g, h; }; struct s x = { 3, 4 };
This option does not warn about designated initializers, so the following modification does not trigger a warning:
struct s { int f, g, h; }; struct s x = { .f = 3, .g = 4 }; [/quote]
Given CentOS 7 is no longer a supported platform, we can see GCC 7.5.0 works on other platforms, and the -Wmissing-field-initializers warning isn';t supposed to complain about this scenario, I don't want to take this patch. Ok, sounds reasonable.
I'd also strongly encourage you to upgrade to a newer development platform, given CentOS 7 is explicitly not something the libvirt project wants to target anymore.
Ok, i get it and thanks for the eetailed explanation :)
Regards, Daniel
participants (3)
-
Daniel P. Berrangé
-
huangy81@chinatelecom.cn
-
Hyman