Skip to content

Commit

Permalink
kernel: Change the prototype of k_thread_access_grant.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
AdithyaBaglody committed Jan 3, 2019
1 parent d273e21 commit 18dd538
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
10 changes: 5 additions & 5 deletions include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 0 additions & 19 deletions kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 18dd538

Please sign in to comment.