Skip to content
Browse files

lib: os: fix vsnprintk coverage

vsnprintk() was uncovered. Simply adjust snprintk() to use
it, instead of duplicating logic.

Signed-off-by: Andrew Boie <>
  • Loading branch information...
andrewboie committed Jun 28, 2019
1 parent c3d4e65 commit 05212e823f454294f60fc7293bd236488bec8e18
Showing with 3 additions and 7 deletions.
  1. +3 −7 lib/os/printk.c
@@ -524,18 +524,14 @@ static int str_out(int c, struct str_context *ctx)

int snprintk(char *str, size_t size, const char *fmt, ...)
struct str_context ctx = { str, size, 0 };
va_list ap;
int ret;

va_start(ap, fmt);
z_vprintk((out_func_t)str_out, &ctx, fmt, ap);
ret = vsnprintk(str, size, fmt, ap);

if (ctx.count < ctx.max) {
str[ctx.count] = '\0';

return ctx.count;
return ret;

int vsnprintk(char *str, size_t size, const char *fmt, va_list ap)

0 comments on commit 05212e8

Please sign in to comment.
You can’t perform that action at this time.