Skip to content

Commit

Permalink
lib: os: fix vsnprintk coverage
Browse files Browse the repository at this point in the history
vsnprintk() was uncovered. Simply adjust snprintk() to use
it, instead of duplicating logic.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
  • Loading branch information
Andrew Boie authored and andrewboie committed Jun 29, 2019
1 parent c3d4e65 commit 05212e8
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lib/os/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
va_end(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)
Expand Down

0 comments on commit 05212e8

Please sign in to comment.