From 37a93e61244aa6f587cb7db704b1a0af8a0af361 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20K=C3=BCthe?= Date: Fri, 14 Feb 2025 23:28:27 +0000 Subject: [PATCH] Allow signed integers in the utils function Fix https://github.com/traviscross/mtr/issues/523 --- ui/utils.c | 6 +++--- ui/utils.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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); -- 2.47.2