mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 05:17:54 +03:00
tests: Fix mode_t usage with va_arg()
Clang complains about it: 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); ^~~~~~ Work around the issue by passing int to va_arg() and casting its return value to mode_t afterwards. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
00d465bb4d
commit
530cecdb7b
@ -87,7 +87,7 @@ open(const char *path, int flags, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
va_start(ap, flags);
|
va_start(ap, flags);
|
||||||
mode = va_arg(ap, int);
|
mode = (mode_t) va_arg(ap, int);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
ret = real_open(newpath ? newpath : path, flags, mode);
|
ret = real_open(newpath ? newpath : path, flags, mode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -731,7 +731,7 @@ int open(const char *path, int flags, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
va_start(ap, flags);
|
va_start(ap, flags);
|
||||||
mode = va_arg(ap, mode_t);
|
mode = (mode_t) va_arg(ap, int);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
ret = real_open(newpath ? newpath : path, flags, mode);
|
ret = real_open(newpath ? newpath : path, flags, mode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -983,7 +983,7 @@ open(const char *path, int flags, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
va_start(ap, flags);
|
va_start(ap, flags);
|
||||||
mode = va_arg(ap, mode_t);
|
mode = (mode_t) va_arg(ap, int);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
ret = real_open(newpath ? newpath : path, flags, mode);
|
ret = real_open(newpath ? newpath : path, flags, mode);
|
||||||
} else {
|
} else {
|
||||||
|
@ -180,7 +180,7 @@ int open(const char *path, int flags, ...)
|
|||||||
va_list ap;
|
va_list ap;
|
||||||
mode_t mode;
|
mode_t mode;
|
||||||
va_start(ap, flags);
|
va_start(ap, flags);
|
||||||
mode = va_arg(ap, mode_t);
|
mode = (mode_t) va_arg(ap, int);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
ret = real_open(path, flags, mode);
|
ret = real_open(path, flags, mode);
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user