[PATCH] libxlutil: avoid almost-undefined behavior

Jan Beulich posted 1 patch 3 years, 2 months ago
Test gitlab-ci passed
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/1d735cfa-d011-c8f5-ff39-81e0227e3a5d@suse.com
[PATCH] libxlutil: avoid almost-undefined behavior
Posted by Jan Beulich 3 years, 2 months ago
While only value computations of an object are disallowed in the
presence of another unsequenced side effect, at least gcc 4.3 looks to
extend this to taking the object's address. The resulting warning causes
the build to fail, because of -Werror.

While there also correct an adjacent comment.

Fixes: bdc0799fe26a ("libxlu: introduce xlu_pci_parse_spec_string()")
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/tools/libs/util/libxlu_pci.c
+++ b/tools/libs/util/libxlu_pci.c
@@ -155,9 +155,10 @@ int xlu_pci_parse_spec_string(XLU_Config
     if (!ret) {
         bdf_present = true;
 
-        /* Check whether 'vslot' if present */
+        /* Check whether 'vslot' is present */
         if (*ptr == '@') {
-            ret = parse_vslot(&pci->vdevfn, ++ptr, &ptr);
+            ++ptr;
+            ret = parse_vslot(&pci->vdevfn, ptr, &ptr);
             if (ret)
                 return ret;
         }

Re: [PATCH] libxlutil: avoid almost-undefined behavior
Posted by Ian Jackson 3 years, 2 months ago
Jan Beulich writes ("[PATCH] libxlutil: avoid almost-undefined behavior"):
> While only value computations of an object are disallowed in the
> presence of another unsequenced side effect, at least gcc 4.3 looks to
> extend this to taking the object's address. The resulting warning causes
> the build to fail, because of -Werror.
> 
> While there also correct an adjacent comment.
> 
> Fixes: bdc0799fe26a ("libxlu: introduce xlu_pci_parse_spec_string()")
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>