[PATCH 4/4] lxd_domain: Require that VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE is zero

Michal Privoznik posted 4 patches 5 years, 1 month ago
[PATCH 4/4] lxd_domain: Require that VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE is zero
Posted by Michal Privoznik 5 years, 1 month ago
Our parser code relies on the fact that
VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE has value of zero and thus
uses g_new0().  But strictly speaking, this is not mandated by
the enum typedef. Fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/lxc/lxc_domain.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/lxc_domain.h b/src/lxc/lxc_domain.h
index 319f83338f..3b5adcbe1c 100644
--- a/src/lxc/lxc_domain.h
+++ b/src/lxc/lxc_domain.h
@@ -35,7 +35,7 @@ typedef enum {
 } virLXCDomainNamespace;
 
 typedef enum {
-    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE,
+    VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE = 0,
     VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NAME,
     VIR_LXC_DOMAIN_NAMESPACE_SOURCE_PID,
     VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NETNS,
-- 
2.26.2

Re: [PATCH 4/4] lxd_domain: Require that VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE is zero
Posted by Laine Stump 5 years, 1 month ago
On 12/16/20 4:13 PM, Michal Privoznik wrote:
> Our parser code relies on the fact that
> VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE has value of zero and thus
> uses g_new0().  But strictly speaking, this is not mandated by
> the enum typedef. Fix that.


Is there really any C compiler that doesn't make the first value a 0 by 
default? (If so, I wonder why?)


Reviewed-by: Laine Stump <laine@redhat.com>


Re: [PATCH 4/4] lxd_domain: Require that VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE is zero
Posted by Michal Privoznik 5 years, 1 month ago
On 12/17/20 3:53 AM, Laine Stump wrote:
> On 12/16/20 4:13 PM, Michal Privoznik wrote:
>> Our parser code relies on the fact that
>> VIR_LXC_DOMAIN_NAMESPACE_SOURCE_NONE has value of zero and thus
>> uses g_new0().  But strictly speaking, this is not mandated by
>> the enum typedef. Fix that.
> 
> 
> Is there really any C compiler that doesn't make the first value a 0 by 
> default? (If so, I wonder why?)
> 

Honestly, I don't know.

> 
> Reviewed-by: Laine Stump <laine@redhat.com>
> 
> 

Thanks.

Michal