[libvirt] [PATCH] tests: Fix build with clang

Jiri Denemark posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/2925f9395eedd75f1084d0f224f3d96b9c6eac43.1507187454.git.jdenemar@redhat.com
tests/virfilewrapper.c | 2 +-
tests/virusbmock.c     | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[libvirt] [PATCH] tests: Fix build with clang
Posted by Jiri Denemark 6 years, 6 months ago
clang doesn't like mode_t type as an argument to va_arg():

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'

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
---

Pushed as a build-breaker.

 tests/virfilewrapper.c | 2 +-
 tests/virusbmock.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/virfilewrapper.c b/tests/virfilewrapper.c
index 1d1d182708..3fd7f7aa8f 100644
--- a/tests/virfilewrapper.c
+++ b/tests/virfilewrapper.c
@@ -267,7 +267,7 @@ int open(const char *path, int flags, ...)
      */
     if (flags & O_CREAT) {
         va_start(ap, flags);
-        mode = va_arg(ap, mode_t);
+        mode = (mode_t) va_arg(ap, int);
         va_end(ap);
     }
 
diff --git a/tests/virusbmock.c b/tests/virusbmock.c
index f430a2edad..12083e2362 100644
--- a/tests/virusbmock.c
+++ b/tests/virusbmock.c
@@ -101,7 +101,7 @@ int open(const char *pathname, int flags, ...)
      */
     if (flags & O_CREAT) {
         va_start(ap, flags);
-        mode = va_arg(ap, mode_t);
+        mode = (mode_t) va_arg(ap, int);
         va_end(ap);
     }
 
-- 
2.14.2

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