[libvirt] [PATCH] util: pci: Remove always-false condition

Peter Krempa posted 1 patch 4 years, 5 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/7af6b4e7cb24eeb46d1cfa17edc26a5454140222.1573474910.git.pkrempa@redhat.com
src/util/virpci.c | 8 --------
1 file changed, 8 deletions(-)
[libvirt] [PATCH] util: pci: Remove always-false condition
Posted by Peter Krempa 4 years, 5 months ago
Commit d19c21429fd modified the condition so that it checks whether the
value is more than 0xFFFFFFFF. Since addr->domain is an unsigned int, it
will never be more than that.

Remove the whole check

src/util/virpci.c:1291:22: error: result of comparison 'unsigned int' > 4294967295 is always false [-Werror,-Wtautological-type-limit-compare]
    if (addr->domain > 0xFFFFFFFF) {
        ~~~~~~~~~~~~ ^ ~~~~~~~~~~

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
---

This was caught by new clang:

$ clang -v
clang version 9.0.0 (Fedora 9.0.0-1.fc31)

This "fix" is the naive approach which assumes the original patch was
correct.

 src/util/virpci.c | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/src/util/virpci.c b/src/util/virpci.c
index f9e39e79d8..cd560d683b 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1288,14 +1288,6 @@ bool
 virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
                            bool report)
 {
-    if (addr->domain > 0xFFFFFFFF) {
-        if (report)
-            virReportError(VIR_ERR_XML_ERROR,
-                           _("Invalid PCI address domain='0x%x', "
-                             "must be <= 0xFFFF"),
-                           addr->domain);
-        return false;
-    }
     if (addr->bus > 0xFF) {
         if (report)
             virReportError(VIR_ERR_XML_ERROR,
-- 
2.23.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] util: pci: Remove always-false condition
Posted by Peter Krempa 4 years, 5 months ago
On Mon, Nov 11, 2019 at 13:23:05 +0100, Peter Krempa wrote:
> Commit d19c21429fd modified the condition so that it checks whether the
> value is more than 0xFFFFFFFF. Since addr->domain is an unsigned int, it
> will never be more than that.
> 
> Remove the whole check
> 
> src/util/virpci.c:1291:22: error: result of comparison 'unsigned int' > 4294967295 is always false [-Werror,-Wtautological-type-limit-compare]
>     if (addr->domain > 0xFFFFFFFF) {
>         ~~~~~~~~~~~~ ^ ~~~~~~~~~~
> 
> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
> ---
> 
> This was caught by new clang:
> 
> $ clang -v
> clang version 9.0.0 (Fedora 9.0.0-1.fc31)
> 
> This "fix" is the naive approach which assumes the original patch was
> correct.

I'll push this under the build-breaker rule since nobody objected.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list