diff options
author | Zhidao HONG <z.hong@f5.com> | 2023-10-10 14:30:02 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2023-10-10 14:30:02 +0800 |
commit | 9c8b9a46a42d47b29453eefc4c5dd325f59e46b4 (patch) | |
tree | 55119f4898d2b70d69b9bd1fdd07af6a1766365a | |
parent | c905d0d393378de2fa44d3e21d2bf317a6c3245c (diff) | |
download | unit-9c8b9a46a42d47b29453eefc4c5dd325f59e46b4.tar.gz unit-9c8b9a46a42d47b29453eefc4c5dd325f59e46b4.tar.bz2 |
Refactored nxt_vsprintf().
-rw-r--r-- | src/nxt_sprintf.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nxt_sprintf.c b/src/nxt_sprintf.c index 9c8e27ed..875f43a5 100644 --- a/src/nxt_sprintf.c +++ b/src/nxt_sprintf.c @@ -156,7 +156,8 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) p = va_arg(args, const u_char *); if (nxt_slow_path(p == NULL)) { - goto copy; + buf = nxt_cpymem(buf, null, nxt_length(null)); + continue; } while (*p != '\0' && buf < end) { @@ -174,6 +175,11 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) fmt++; p = va_arg(args, const u_char *); + if (nxt_slow_path(p == NULL)) { + buf = nxt_cpymem(buf, null, nxt_length(null)); + continue; + } + goto copy; } @@ -556,14 +562,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) copy: - if (nxt_slow_path(p == NULL)) { - p = null; - length = nxt_length(null); - - } else { - length = nxt_min((size_t) (end - buf), length); - } - + length = nxt_min((size_t) (end - buf), length); buf = nxt_cpymem(buf, p, length); continue; } |