From c2d00b27dfa59f2418bb5bb6941394f2346fb0e9 Mon Sep 17 00:00:00 2001 From: Charles Nicholson Date: Wed, 23 Nov 2022 23:54:12 -0500 Subject: [PATCH] remove temporary variable (#235) --- nanoprintf.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nanoprintf.h b/nanoprintf.h index 1d2e4e3..755590a 100644 --- a/nanoprintf.h +++ b/nanoprintf.h @@ -762,8 +762,9 @@ int npf_vpprintf(npf_putc pc, void *pc_ctx, char const *format, va_list args) { case NPF_FMT_SPEC_CONV_STRING: { cbuf = va_arg(args, char *); #if NANOPRINTF_USE_PRECISION_FORMAT_SPECIFIERS == 1 - int const n = (fs.prec_opt == NPF_FMT_SPEC_OPT_NONE) ? -1 : fs.prec; - for (char const *s = cbuf; *s && ((n == -1) || (cbuf_len < n)); ++s, ++cbuf_len); + for (char const *s = cbuf; + *s && ((fs.prec_opt == NPF_FMT_SPEC_OPT_NONE) || (cbuf_len < fs.prec)); + ++s, ++cbuf_len); #else for (char const *s = cbuf; *s; ++s, ++cbuf_len); // strlen #endif