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

Re: [PATCH] conf: Don't check virTristateBool < 0



Heh, not fast enough these days. I see it's already fixed :-).

Regards,
Jim

On 9/1/20 4:18 PM, Jim Fehlig wrote:
Commit 9d15647dcb introduced a check of virtTristateBool < 0, which
causes a build failure in some environments

../dist-unpack/libvirt-6.8.0/src/conf/domain_conf.c:8144:78: error:
result of comparison of unsigned enum expression < 0 is always false
[-Werror,-Wtautological-unsigned-enum-zero-compare]
if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {

Fix it by assigning the return value of virTristateBoolTypeFromString
to a temp int variable, which allows checking for unknown values before
assigning to the virtTristateBool variable.

Signed-off-by: Jim Fehlig <jfehlig suse com>
---

Perhaps considered trivial and could be pushed under the build-breaker
rule, but I'd prefer a review since I've botched trivial patches in the
past :-).

  src/conf/domain_conf.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7d177a5562..5b224ccd78 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8141,12 +8141,15 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node,
      xmlNodePtr cur;
if ((filtering = virXMLPropString(node, "writeFiltering"))) {
-        if ((def->writeFiltering = virTristateBoolTypeFromString(filtering)) < 0) {
+        int filterval;
+
+        if ((filterval = virTristateBoolTypeFromString(filtering)) < 0) {
              virReportError(VIR_ERR_XML_ERROR,
                             _("unknown pci writeFiltering setting '%s'"),
                             filtering);
              return -1;
          }
+        def->writeFiltering = filterval;
      }
cur = node->children;



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