[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [UNIKRAFT PATCH] lib/syscall_shim: Avoid warning about unused system call arguments
Looks good.
Some system call implementations may not use all arguments which causes
a compiler warning. This commit adds the `__maybe_unused` attribute to
the arguments when one of the following macros is used for a system call
implementation: `UK_SYSCALL_DEFINE()`, `UK_LLSYSCALL_DEFINE()`,
`UK_SYSCALL_R_DEFINE()`, and `UK_LLSYSCALL_R_DEFINE()`.
Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
---
lib/syscall_shim/include/uk/syscall.h | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/lib/syscall_shim/include/uk/syscall.h b/lib/syscall_shim/include/uk/syscall.h
index ffa9f1ee4..37d7f5f0e 100644
--- a/lib/syscall_shim/include/uk/syscall.h
+++ b/lib/syscall_shim/include/uk/syscall.h
@@ -105,6 +105,8 @@ typedef long uk_syscall_arg_t;
#define UK_S_ARG_LONG(type, arg) long arg
#define UK_S_ARG_ACTUAL(type, arg) type arg
+#define UK_S_ARG_LONG_MAYBE_UNUSED(type, arg) long arg __maybe_unused
+#define UK_S_ARG_ACTUAL_MAYBE_UNUSED(type, arg) type arg __maybe_unused
#define UK_S_ARG_CAST_LONG(type, arg) (long) arg
#define UK_S_ARG_CAST_ACTUAL(type, arg) (type) arg
@@ -139,7 +141,8 @@ typedef long uk_syscall_arg_t;
UK_ARG_MAPx(x, UK_S_ARG_CAST_ACTUAL, __VA_ARGS__)); \
} \
static inline rtype __##ename(UK_ARG_MAPx(x, \
- UK_S_ARG_ACTUAL, __VA_ARGS__))
+ UK_S_ARG_ACTUAL_MAYBE_UNUSED,\
+ __VA_ARGS__))
#define _UK_LLSYSCALL_DEFINE(...) __UK_LLSYSCALL_DEFINE(__VA_ARGS__)
#define UK_LLSYSCALL_DEFINE(rtype, name, ...) \
_UK_LLSYSCALL_DEFINE(__UK_SYSCALL_DEF_NARGS(__VA_ARGS__), \
@@ -208,8 +211,9 @@ typedef long uk_syscall_arg_t;
return (long) __##rname( \
UK_ARG_MAPx(x, UK_S_ARG_CAST_ACTUAL, __VA_ARGS__)); \
} \
- static inline rtype __##rname(UK_ARG_MAPx(x, UK_S_ARG_ACTUAL, \
- __VA_ARGS__))
+ static inline rtype __##rname(UK_ARG_MAPx(x, \
+ UK_S_ARG_ACTUAL_MAYBE_UNUSED,\
+ __VA_ARGS__))
#define _UK_LLSYSCALL_R_DEFINE(...) __UK_LLSYSCALL_R_DEFINE(__VA_ARGS__)
#define UK_LLSYSCALL_R_DEFINE(rtype, name, ...) \
_UK_LLSYSCALL_R_DEFINE(__UK_SYSCALL_DEF_NARGS(__VA_ARGS__), \
--
2.20.1
|