From: Marek Küthe Date: Fri, 14 Feb 2025 23:28:27 +0000 (+0000) Subject: Allow signed integers in the utils function X-Git-Tag: v0.96~9^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37a93e61244aa6f587cb7db704b1a0af8a0af361;p=thirdparty%2Fmtr.git Allow signed integers in the utils function Fix https://github.com/traviscross/mtr/issues/523 --- diff --git a/ui/utils.c b/ui/utils.c index 5e3a701..5754894 100644 --- a/ui/utils.c +++ b/ui/utils.c @@ -70,17 +70,17 @@ char *trim( } /* Parse string, and return positive signed int. */ -int strtonum_or_err( +long int strtonum_or_err( const char *str, const char *errmesg, const int type) { - unsigned long int num; + long int num; char *end = NULL; if (str != NULL && *str != '\0') { errno = 0; - num = strtoul(str, &end, 0); + num = strtol(str, &end, 0); if (errno == 0 && str != end && end != NULL && *end == '\0') { switch (type) { case STRTO_INT: diff --git a/ui/utils.h b/ui/utils.h index 1a44a8c..621e3d3 100644 --- a/ui/utils.h +++ b/ui/utils.h @@ -25,7 +25,7 @@ enum { extern char *trim( char *s, const char c); -extern int strtonum_or_err( +extern long int strtonum_or_err( const char *str, const char *errmesg, const int type);