[PATCH 2/3] Turn 1<<31 into 1U<<31

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

 



Apparently, 1 << 31 is signed which in turn does not fit into
a signed integer variable:

../../include/libvirt/libvirt-domain.h:1881:57: error: result of '1 << 31' requires 33 bits to represent, but 'int' only has 32 bits [-Werror=shift-overflow=]
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
                                                         ^~
cc1: all warnings being treated as errors

The solution is to make it an unsigned value. I've found only two
such occurrences in our code base.

Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
---
 include/libvirt/libvirt-domain.h | 2 +-
 src/util/virtypedparam.h         | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 27ed29a..cba4fa5 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -1878,7 +1878,7 @@ typedef enum {
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_OTHER = VIR_CONNECT_LIST_DOMAINS_OTHER,
 
     VIR_CONNECT_GET_ALL_DOMAINS_STATS_BACKING = 1 << 30, /* include backing chain for block stats */
-    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1 << 31, /* enforce requested stats */
+    VIR_CONNECT_GET_ALL_DOMAINS_STATS_ENFORCE_STATS = 1U << 31, /* enforce requested stats */
 } virConnectGetAllDomainStatsFlags;
 
 int virConnectGetAllDomainStats(virConnectPtr conn,
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index 73f710a..7ab143f 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -32,7 +32,7 @@
  * Flag indicating that the params has multiple occurrences of the parameter.
  * Only used as a flag for @type argument of the virTypedParamsValidate.
  */
-# define VIR_TYPED_PARAM_MULTIPLE (1 << 31)
+# define VIR_TYPED_PARAM_MULTIPLE (1U << 31)
 
 verify(!(VIR_TYPED_PARAM_LAST & VIR_TYPED_PARAM_MULTIPLE));
 
-- 
2.8.3

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



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux