lib/posix: SPARC newlib has unsigned short mode_t
This commit eliminates a compilation error by passing int to va_arg rather than mode_t on SPARC. Newlib sys/_types.h defines mode_t for SPARC as: typedef unsigned short __mode_t; GCC 10.2.0 gave the following error message and suggested solution: mqueue.c: In function 'mq_open': mqueue.c:61:21: error: 'mode_t' {aka 'short unsigned int'} is promoted to 'int' when passed through '...' [-Werror] 61 | mode = va_arg(va, mode_t); | ^ mqueue.c:61:21: note: (so you should pass 'int' not 'mode_t' {aka 'short unsigned int'} to 'va_arg') Signed-off-by: Martin Åberg <martin.aberg@gaisler.com>
This commit is contained in:
parent
2b1baf6e33
commit
6d126e7481
1 changed files with 12 additions and 1 deletions
|
@ -38,6 +38,17 @@ static int receive_message(mqueue_desc *mqd, char *msg_ptr, size_t msg_len,
|
|||
k_timeout_t timeout);
|
||||
static void remove_mq(mqueue_object *msg_queue);
|
||||
|
||||
#if defined(__sparc__)
|
||||
/*
|
||||
* mode_t is defined as "unsigned short" on SPARC newlib. This type is promoted
|
||||
* to "int" when passed through '...' so we should pass the promoted type to
|
||||
* va_arg().
|
||||
*/
|
||||
#define PROMOTED_MODE_T int
|
||||
#else
|
||||
#define PROMOTED_MODE_T mode_t
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Open a message queue.
|
||||
*
|
||||
|
@ -58,7 +69,7 @@ mqd_t mq_open(const char *name, int oflags, ...)
|
|||
|
||||
va_start(va, oflags);
|
||||
if ((oflags & O_CREAT) != 0) {
|
||||
mode = va_arg(va, mode_t);
|
||||
mode = va_arg(va, PROMOTED_MODE_T);
|
||||
attrs = va_arg(va, mq_attr*);
|
||||
}
|
||||
va_end(va);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue