]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Correct const usage of strtouv64 endp argument.
authorDave Hart <hart@ntp.org>
Sun, 5 Mar 2023 20:28:23 +0000 (15:28 -0500)
committerDave Hart <hart@ntp.org>
Sun, 5 Mar 2023 20:28:23 +0000 (15:28 -0500)
bk: 6404fb67XZpmMm_QpzhHW4v1D9-zoA

include/vint64ops.h
libntp/vint64ops.c
ntpd/ntp_leapsec.c
tests/libntp/vi64ops.c

index 7c245b963285c6cf051ffba50362e353bd70a5ba..888d342781fb35fd2a8f76a7fed9ff824d8cbc7b 100644 (file)
@@ -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)*/
index f4fc47fe71430f9978ce7db1ae207d20d90cb005..1d5087d95438df3c44b5e1f8116a8b0bb8ac342a 100644 (file)
@@ -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;
index 7d20873d618d44a42c1c655efc05f41d4f703d63..88f9d4e1cc2395310a3a1f34d81277098a89ba11 100644 (file)
@@ -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,
index 843c0a334b73b3c0940cc86cbab3a79b1d5cc9fc..0891299e52fdc5b8842f969f1a7aab1871049f73 100644 (file)
@@ -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;