summaryrefslogtreecommitdiffstats
path: root/plugins/utils.c
diff options
context:
space:
mode:
authorRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-19 12:10:55 +0200
committerRincewindsHat <12514511+RincewindsHat@users.noreply.github.com>2023-10-19 12:10:55 +0200
commit07f9c438f31de7a280e43c4196a32d200ad41fbe (patch)
tree642bd4478a70665df23b83cb7b48770c3020c570 /plugins/utils.c
parent47cb10013e6935bb6cdf470925ea5a5f74464646 (diff)
downloadmonitoring-plugins-07f9c43.tar.gz
Fixes for -Wsign-compare
Diffstat (limited to 'plugins/utils.c')
-rw-r--r--plugins/utils.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/plugins/utils.c b/plugins/utils.c
index 7e14b6e4..e871c5f7 100644
--- a/plugins/utils.c
+++ b/plugins/utils.c
@@ -230,13 +230,21 @@ bool is_intnonneg (char *number) {
230 */ 230 */
231bool is_int64(char *number, int64_t *target) { 231bool is_int64(char *number, int64_t *target) {
232 errno = 0; 232 errno = 0;
233 uint64_t tmp = strtoll(number, NULL, 10); 233 char *endptr = { 0 };
234
235 int64_t tmp = strtoll(number, &endptr, 10);
234 if (errno != 0) { 236 if (errno != 0) {
235 return false; 237 return false;
236 } 238 }
239
240 if (*endptr == '\0') {
241 return 0;
242 }
243
237 if (tmp < INT64_MIN || tmp > INT64_MAX) { 244 if (tmp < INT64_MIN || tmp > INT64_MAX) {
238 return false; 245 return false;
239 } 246 }
247
240 if (target != NULL) { 248 if (target != NULL) {
241 *target = tmp; 249 *target = tmp;
242 } 250 }