kernel: Change the prototype of k_thread_access_grant.
This API was using variable number of arguments. Which is not
allowed according to misra c guidelines(Rule 17.1). Hence making
this API into a macro and using the util macro FOR_EACH_FIXED_ARG
to get the same functionality.
There is one deviation from the old function. The last argument
shouldn't be NULL.
Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
diff --git a/include/kernel.h b/include/kernel.h
index 02b4e46..2de99c5 100644
--- a/include/kernel.h
+++ b/include/kernel.h
@@ -724,21 +724,21 @@
void *p3);
/**
- * @brief Grant a thread access to a NULL-terminated set of kernel objects
+ * @brief Grant a thread access to a set of kernel objects
*
* This is a convenience function. For the provided thread, grant access to
* the remaining arguments, which must be pointers to kernel objects.
- * The final argument must be a NULL.
*
* The thread object must be initialized (i.e. running). The objects don't
* need to be.
+ * Note that NULL shouldn't be passed as an argument.
*
* @param thread Thread to grant access to objects
- * @param ... NULL-terminated list of kernel object pointers
+ * @param ... list of kernel object pointers
* @req K-THREAD-004
*/
-extern void __attribute__((sentinel))
- k_thread_access_grant(struct k_thread *thread, ...);
+#define k_thread_access_grant(thread, ...) \
+ FOR_EACH_FIXED_ARG(k_object_access_grant, thread, __VA_ARGS__)
/**
* @brief Assign a resource memory pool to a thread
diff --git a/kernel/thread.c b/kernel/thread.c
index e035c24..5354e59 100644
--- a/kernel/thread.c
+++ b/kernel/thread.c
@@ -682,25 +682,6 @@
_init_thread_timeout(thread_base);
}
-void k_thread_access_grant(struct k_thread *thread, ...)
-{
-#ifdef CONFIG_USERSPACE
- va_list args;
- va_start(args, thread);
-
- while (true) {
- void *object = va_arg(args, void *);
- if (object == NULL) {
- break;
- }
- k_object_access_grant(object, thread);
- }
- va_end(args);
-#else
- ARG_UNUSED(thread);
-#endif
-}
-
FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry,
void *p1, void *p2, void *p3)
{