From: Dave Hart Date: Sun, 5 Mar 2023 20:28:23 +0000 (-0500) Subject: Correct const usage of strtouv64 endp argument. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ec2acaeb58356349084eff5c210b0d79eaf2f32;p=thirdparty%2Fntp.git Correct const usage of strtouv64 endp argument. bk: 6404fb67XZpmMm_QpzhHW4v1D9-zoA --- diff --git a/include/vint64ops.h b/include/vint64ops.h index 7c245b963..888d34278 100644 --- a/include/vint64ops.h +++ b/include/vint64ops.h @@ -23,6 +23,6 @@ extern vint64 subv64i32(const vint64 * lhs, int32_t rhs); extern vint64 subv64u32(const vint64 * lhs, uint32_t rhs); /* parsing. works like strtoul() or strtoull() */ -extern vint64 strtouv64(const char * begp, const char ** endp, int base); +extern vint64 strtouv64(char const * begp, char const ** const endp, int base); #endif /*!defined(VINT64OPS_H)*/ diff --git a/libntp/vint64ops.c b/libntp/vint64ops.c index f4fc47fe7..1d5087d95 100644 --- a/libntp/vint64ops.c +++ b/libntp/vint64ops.c @@ -21,9 +21,9 @@ vint64 strtouv64( - const char *begp, - const char **endp, - int base + char const * begp, + char const ** const endp, + int base ) { vint64 res; diff --git a/ntpd/ntp_leapsec.c b/ntpd/ntp_leapsec.c index 7d20873d6..88f9d4e1c 100644 --- a/ntpd/ntp_leapsec.c +++ b/ntpd/ntp_leapsec.c @@ -183,10 +183,11 @@ leapsec_load( void * farg, int use_build_limit) { - char *cp, *ep, linebuf[50]; - vint64 ttime, limit; - long taiof; - struct calendar build; + char const *ep; + char *cp, *endp, linebuf[50]; + vint64 ttime, limit; + long taiof; + struct calendar build; leapsec_clear(pt); if (use_build_limit && ntpcal_get_build_date(&build)) { @@ -220,9 +221,9 @@ leapsec_load( if (parsefail(cp, ep)) goto fail_read; cp = skipws(ep); - taiof = strtol(cp, &ep, 10); - if ( parsefail(cp, ep) - || taiof > SHRT_MAX || taiof < SHRT_MIN) + taiof = strtol(cp, &endp, 10); + if ( parsefail(cp, endp) + || taiof > INT16_MAX || taiof < INT16_MIN) goto fail_read; if (ucmpv64(&ttime, &limit) >= 0) { if (!leapsec_raw(pt, &ttime, diff --git a/tests/libntp/vi64ops.c b/tests/libntp/vi64ops.c index 843c0a334..0891299e5 100644 --- a/tests/libntp/vi64ops.c +++ b/tests/libntp/vi64ops.c @@ -39,7 +39,7 @@ void test_ParseVUI64_pos(void) { vint64 act, exp; const char *sp; - char *ep; + char const *ep; sp = "1234x"; exp.D_s.hi = 0; @@ -55,7 +55,7 @@ void test_ParseVUI64_neg(void) { vint64 act, exp; const char *sp; - char *ep; + char const *ep; sp = "-1234x"; exp.D_s.hi = ~0; @@ -69,7 +69,7 @@ void test_ParseVUI64_case(void) { vint64 act, exp; const char *sp; - char *ep; + char const *ep; sp = "0123456789AbCdEf"; exp.D_s.hi = 0x01234567;