Browse Source

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>
pull/12280/head
Adithya Baglody 7 years ago committed by Andrew Boie
parent
commit
392219eab8
  1. 10
      include/kernel.h
  2. 19
      kernel/thread.c

10
include/kernel.h

@ -724,21 +724,21 @@ extern FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry, @@ -724,21 +724,21 @@ extern FUNC_NORETURN void k_thread_user_mode_enter(k_thread_entry_t entry,
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

19
kernel/thread.c

@ -682,25 +682,6 @@ void _init_thread_base(struct _thread_base *thread_base, int priority, @@ -682,25 +682,6 @@ void _init_thread_base(struct _thread_base *thread_base, int priority,
_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)
{

Loading…
Cancel
Save