Skip to content

Commit d3ca4bd

Browse files
Andrew Boienashif
authored andcommitted
lib: os: fix vsnprintk coverage
vsnprintk() was uncovered. Simply adjust snprintk() to use it, instead of duplicating logic. Signed-off-by: Andrew Boie <[email protected]>
1 parent 301558a commit d3ca4bd

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/os/printk.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -506,18 +506,14 @@ static int str_out(int c, struct str_context *ctx)
506506

507507
int snprintk(char *str, size_t size, const char *fmt, ...)
508508
{
509-
struct str_context ctx = { str, size, 0 };
510509
va_list ap;
510+
int ret;
511511

512512
va_start(ap, fmt);
513-
z_vprintk((out_func_t)str_out, &ctx, fmt, ap);
513+
ret = vsnprintk(str, size, fmt, ap);
514514
va_end(ap);
515515

516-
if (ctx.count < ctx.max) {
517-
str[ctx.count] = '\0';
518-
}
519-
520-
return ctx.count;
516+
return ret;
521517
}
522518

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

0 commit comments

Comments
 (0)