Skip to content

Commit

Permalink
ARCMWDT: Fix cbprintf issue with omitted function prototype
Browse files Browse the repository at this point in the history
MWDT requires function to be declared with argument types.
This PR provides explisitly type cast for out routine
inside z_cbvprintf_impl().

This fixes zephyrproject-rtos#74562

Signed-off-by: Nikolay Agishev <[email protected]>
  • Loading branch information
Nikolay Agishev committed Jun 26, 2024
1 parent 1464209 commit 3504641
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/os/cbprintf_complete.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,13 +1315,19 @@ static inline void store_count(const struct conversion *conv,
}
}

/* Create local type to make calng-based compilers happy when handles OUTC() macro
* (see below). With strict rules (Wincompatible-function-pointer-types-strict)
* it's prohibited to pass arguments with mismatched types. */
typedef int (*cbprintf_cb_local)(int c, void *ctx);

/* Outline function to emit all characters in [sp, ep). */
static int outs(cbprintf_cb out,
static int outs(cbprintf_cb __out,
void *ctx,
const char *sp,
const char *ep)
{
size_t count = 0;
cbprintf_cb_local out = __out;

while ((sp < ep) || ((ep == NULL) && *sp)) {
int rc = out((int)*sp++, ctx);
Expand All @@ -1335,12 +1341,14 @@ static int outs(cbprintf_cb out,
return (int)count;
}

int z_cbvprintf_impl(cbprintf_cb out, void *ctx, const char *fp,
int z_cbvprintf_impl(cbprintf_cb __out, void *ctx, const char *fp,
va_list ap, uint32_t flags)
{
char buf[CONVERTED_BUFLEN];
size_t count = 0;
sint_value_type sint;
cbprintf_cb_local out = __out;


const bool tagged_ap = (flags & Z_CBVPRINTF_PROCESS_FLAG_TAGGED_ARGS)
== Z_CBVPRINTF_PROCESS_FLAG_TAGGED_ARGS;
Expand Down

0 comments on commit 3504641

Please sign in to comment.