[Libguestfs] [nbdkit PATCH v3 2/3] utils/vector: pass only unsigned arguments to (ADD|MUL)_OVERFLOW

Laszlo Ersek lersek at redhat.com
Fri Nov 26 14:06:51 UTC 2021


In a subsequent patch, the (ADD|MUL)_OVERFLOW macros will require each
operand to have some unsigned integer type. To prevent a build failure in
"common/utils/vector.c", satisfy that requirement in advance.

Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 common/utils/vector.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/utils/vector.c b/common/utils/vector.c
index ee7591560ca5..54e6b810bea6 100644
--- a/common/utils/vector.c
+++ b/common/utils/vector.c
@@ -60,7 +60,7 @@ generic_vector_reserve (struct generic_vector *v, size_t n, size_t itemsize)
    *   newcap = v->cap + (v->cap + 1) / 2
    *   newbytes = newcap * itemsize
    */
-  if (ADD_OVERFLOW (v->cap, 1, &t) ||
+  if (ADD_OVERFLOW (v->cap, 1u, &t) ||
       ADD_OVERFLOW (v->cap, t/2, &newcap) ||
       MUL_OVERFLOW (newcap, itemsize, &newbytes) ||
       newbytes < reqbytes) {
-- 
2.19.1.3.g30247aa5d201




More information about the Libguestfs mailing list