]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: str_to_*() - Fix compiler warnings
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 22 Oct 2025 11:27:51 +0000 (14:27 +0300)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 23 Oct 2025 05:23:42 +0000 (05:23 +0000)
Some gcc versions think endp may be uninitialized.

src/lib/strnum.c

index c16cfe017add21e1423a244976c953b5bc81d49d..bd3cd50d9085d9b830d4df657efecf9185b7262d 100644 (file)
@@ -111,7 +111,7 @@ int str_parse_uintmax(const char *str, uintmax_t *num_r, const char **endp_r)
 }
 int str_to_uintmax(const char *str, uintmax_t *num_r)
 {
-       const char *endp;
+       const char *endp = NULL;
        uintmax_t n;
        int ret = str_parse_uintmax(str, &n, &endp);
        if ((ret != 0) || (*endp != '\0'))
@@ -206,7 +206,7 @@ int str_parse_uintmax_hex(const char *str, uintmax_t *num_r,
 }
 int str_to_uintmax_hex(const char *str, uintmax_t *num_r)
 {
-       const char *endp;
+       const char *endp = NULL;
        uintmax_t n;
        int ret = str_parse_uintmax_hex(str, &n, &endp);
        if ((ret != 0) || (*endp != '\0'))
@@ -271,7 +271,7 @@ int str_parse_uintmax_oct(const char *str, uintmax_t *num_r,
 }
 int str_to_uintmax_oct(const char *str, uintmax_t *num_r)
 {
-       const char *endp;
+       const char *endp = NULL;
        uintmax_t n;
        int ret = str_parse_uintmax_oct(str, &n, &endp);
        if ((ret != 0) || (*endp != '\0'))
@@ -346,7 +346,7 @@ str_parse_intmax(const char *str, intmax_t *num_r, const char **endp_r)
 }
 int str_to_intmax(const char *str, intmax_t *num_r)
 {
-       const char *endp;
+       const char *endp = NULL;
        intmax_t n;
        int ret = str_parse_intmax(str, &n, &endp);
        if ((ret != 0) || (*endp != '\0'))