提交 530cecdb 编写于 作者: A Andrea Bolognani

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: NAndrea Bolognani <abologna@redhat.com>
Reviewed-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 00d465bb
......@@ -87,7 +87,7 @@ open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = va_arg(ap, int);
mode = (mode_t) va_arg(ap, int);
va_end(ap);
ret = real_open(newpath ? newpath : path, flags, mode);
} else {
......
......@@ -731,7 +731,7 @@ int open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = va_arg(ap, mode_t);
mode = (mode_t) va_arg(ap, int);
va_end(ap);
ret = real_open(newpath ? newpath : path, flags, mode);
} else {
......
......@@ -983,7 +983,7 @@ open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = va_arg(ap, mode_t);
mode = (mode_t) va_arg(ap, int);
va_end(ap);
ret = real_open(newpath ? newpath : path, flags, mode);
} else {
......
......@@ -180,7 +180,7 @@ int open(const char *path, int flags, ...)
va_list ap;
mode_t mode;
va_start(ap, flags);
mode = va_arg(ap, mode_t);
mode = (mode_t) va_arg(ap, int);
va_end(ap);
ret = real_open(path, flags, mode);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册