Clang complains about it:

  virfilewrapper.c:270:27: error: second argument to 'va_arg'
    is of promotable type 'mode_t' (aka 'unsigned short'); this
    va_arg has undefined behavior because arguments will be
    promoted to 'int' [-Werror,-Wvarargs]

  mode = va_arg(ap, mode_t);
                    ^~~~~~

The issue was raised[1] when the patch was posted, but apparently
not acted upon. Implement the suggested fix.

[1] https://www.redhat.com/archives/libvir-list/2017-October/msg00127.html

Signed-off-by: Andrea Bolognani <abolo...@redhat.com>
---
 tests/virpcimock.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 001b320683..915327e91e 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -994,11 +994,11 @@ open(const char *path, int flags, ...)
 
     if (flags & O_CREAT) {
         va_list ap;
-        mode_t mode;
+        int mode;
         va_start(ap, flags);
-        mode = va_arg(ap, mode_t);
+        mode = va_arg(ap, int);
         va_end(ap);
-        ret = real_open(newpath ? newpath : path, flags, mode);
+        ret = real_open(newpath ? newpath : path, flags, (mode_t) mode);
     } else {
         ret = real_open(newpath ? newpath : path, flags);
     }
-- 
2.14.3

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

Reply via email to