misc: printk: Change function return

The result of both printk and vprintk are not used in any place.
MISRA-C says that the return of every non void function must be
checked.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
This commit is contained in:
Flavio Ceolin 2018-09-11 15:57:04 -07:00 committed by Anas Nashif
parent df2cc4084a
commit a1135620ba
4 changed files with 12 additions and 22 deletions

View file

@ -42,8 +42,8 @@ extern "C" {
* @return N/A
*/
#ifdef CONFIG_PRINTK
extern __printf_like(1, 2) int printk(const char *fmt, ...);
extern __printf_like(1, 0) int vprintk(const char *fmt, va_list ap);
extern __printf_like(1, 2) void printk(const char *fmt, ...);
extern __printf_like(1, 0) void vprintk(const char *fmt, va_list ap);
extern __printf_like(3, 4) int snprintk(char *str, size_t size,
const char *fmt, ...);
extern __printf_like(3, 0) int vsnprintk(char *str, size_t size,
@ -52,17 +52,15 @@ extern __printf_like(3, 0) int vsnprintk(char *str, size_t size,
extern __printf_like(3, 0) void _vprintk(int (*out)(int, void *), void *ctx,
const char *fmt, va_list ap);
#else
static inline __printf_like(1, 2) int printk(const char *fmt, ...)
static inline __printf_like(1, 2) void printk(const char *fmt, ...)
{
ARG_UNUSED(fmt);
return 0;
}
static inline __printf_like(1, 0) int vprintk(const char *fmt, va_list ap)
static inline __printf_like(1, 0) void vprintk(const char *fmt, va_list ap)
{
ARG_UNUSED(fmt);
ARG_UNUSED(ap);
return 0;
}
static inline __printf_like(3, 4) int snprintk(char *str, size_t size,

View file

@ -266,7 +266,7 @@ static int char_out(int c, void *ctx_p)
}
#ifdef CONFIG_USERSPACE
int vprintk(const char *fmt, va_list ap)
void vprintk(const char *fmt, va_list ap)
{
if (_is_user_context()) {
struct buf_out_context ctx = { 0 };
@ -276,23 +276,18 @@ int vprintk(const char *fmt, va_list ap)
if (ctx.buf_count) {
buf_flush(&ctx);
}
return ctx.count;
} else {
struct out_context ctx = { 0 };
_vprintk(char_out, &ctx, fmt, ap);
return ctx.count;
}
}
#else
int vprintk(const char *fmt, va_list ap)
void vprintk(const char *fmt, va_list ap)
{
struct out_context ctx = { 0 };
_vprintk(char_out, &ctx, fmt, ap);
return ctx.count;
}
#endif
@ -331,23 +326,20 @@ Z_SYSCALL_HANDLER(k_str_out, c, n)
*
* @param fmt formatted string to output
*
* @return Number of characters printed
* @return N/A
*/
int printk(const char *fmt, ...)
void printk(const char *fmt, ...)
{
int ret;
va_list ap;
va_start(ap, fmt);
if (IS_ENABLED(CONFIG_LOG_PRINTK)) {
ret = log_printk(fmt, ap);
log_printk(fmt, ap);
} else {
ret = vprintk(fmt, ap);
vprintk(fmt, ap);
}
va_end(ap);
return ret;
}
/**

View file

@ -17,7 +17,7 @@
#define MBEDTLS_PRINT printf
#else
#include <misc/printk.h>
#define MBEDTLS_PRINT printk
#define MBEDTLS_PRINT (int(*)(const char *, ...)) printk
#endif /* CONFIG_STDOUT_CONSOLE */
#include <zephyr.h>
#include <string.h>

View file

@ -12,7 +12,7 @@
#define MBEDTLS_PRINT printf
#else
#include <misc/printk.h>
#define MBEDTLS_PRINT printk
#define MBEDTLS_PRINT (int(*)(const char *, ...)) printk
#endif /* CONFIG_STDOUT_CONSOLE */
#include <string.h>