diff options
author | Willy Tarreau <w@1wt.eu> | 2022-03-21 20:33:07 +0300 |
---|---|---|
committer | Paul E. McKenney <paulmck@kernel.org> | 2022-04-21 03:05:45 +0300 |
commit | 170b230d22e89681ebca1a3d972dca441c8e4be5 (patch) | |
tree | 0076ffc6acdf7d96dc07410c6ea2c84fcebe82fb | |
parent | f0f04f28d5ae483b3b354cb3b63a3bab0b00cee4 (diff) | |
download | linux-170b230d22e89681ebca1a3d972dca441c8e4be5.tar.xz |
tools/nolibc/stdio: make printf(%s) accept NULL
It's often convenient to support this, especially in test programs where
a NULL may correspond to an allocation error or a non-existing value.
Let's make printf("%s") support being passed a NULL. In this case it
prints "(null)" like glibc's printf().
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
-rw-r--r-- | tools/include/nolibc/stdio.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/include/nolibc/stdio.h b/tools/include/nolibc/stdio.h index cb4d3ab3a565..559ebe052a75 100644 --- a/tools/include/nolibc/stdio.h +++ b/tools/include/nolibc/stdio.h @@ -220,6 +220,8 @@ int vfprintf(FILE *stream, const char *fmt, va_list args) } else if (c == 's') { outstr = va_arg(args, char *); + if (!outstr) + outstr="(null)"; } else if (c == '%') { /* queue it verbatim */ |