diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-18 12:49:52 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-26 14:11:12 +0200 |
commit | 27ca67f0df6c7b606c8496b1c57434032b2a577c (patch) | |
tree | 54ca4304599841dfac8aa7e6a95a64d685c034e0 | |
parent | 6271479610c95d40daf9ed6ec2c7dead67c74f00 (diff) | |
download | unit-27ca67f0df6c7b606c8496b1c57434032b2a577c.tar.gz unit-27ca67f0df6c7b606c8496b1c57434032b2a577c.tar.bz2 |
Added const to remove unnecessary casts.
Casts are usually very dangerous, disabling most compiler warnings
and basically removing type safety. This change adds 'const' to a
pointer where we don't need to write, improving type safety, and
that also allows removing some casts.
-rw-r--r-- | src/nxt_sprintf.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nxt_sprintf.c b/src/nxt_sprintf.c index 50705ede..90d74335 100644 --- a/src/nxt_sprintf.c +++ b/src/nxt_sprintf.c @@ -97,7 +97,6 @@ static u_char *nxt_number(nxt_sprintf_t *spf, u_char *buf, double n); u_char * nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) { - u_char *p; int d; double f, i; size_t length; @@ -109,6 +108,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) nxt_msec_t ms; nxt_nsec_t ns; nxt_bool_t sign; + const u_char *p; nxt_sprintf_t spf; nxt_file_name_t *fn; @@ -150,7 +150,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) continue; case 's': - p = va_arg(args, u_char *); + p = va_arg(args, const u_char *); if (nxt_fast_path(p != NULL)) { while (*p != '\0' && buf < end) { @@ -168,7 +168,7 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) if (*fmt == 's') { fmt++; - p = va_arg(args, u_char *); + p = va_arg(args, const u_char *); if (nxt_fast_path(p != NULL)) { goto copy; @@ -378,13 +378,13 @@ nxt_vsprintf(u_char *buf, u_char *end, const char *fmt, va_list args) } if (nxt_slow_path(isnan(f))) { - p = (u_char *) nan; + p = nan; length = nxt_length(nan); goto copy; } else if (nxt_slow_path(isinf(f))) { - p = (u_char *) infinity; + p = infinity; length = nxt_length(infinity); goto copy; |