diff options
| author | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-19 12:10:55 +0200 |
|---|---|---|
| committer | RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-19 12:10:55 +0200 |
| commit | 07f9c438f31de7a280e43c4196a32d200ad41fbe (patch) | |
| tree | 642bd4478a70665df23b83cb7b48770c3020c570 /plugins/utils.c | |
| parent | 47cb10013e6935bb6cdf470925ea5a5f74464646 (diff) | |
| download | monitoring-plugins-07f9c438f31de7a280e43c4196a32d200ad41fbe.tar.gz | |
Fixes for -Wsign-compare
Diffstat (limited to 'plugins/utils.c')
| -rw-r--r-- | plugins/utils.c | 10 |
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 | */ |
| 231 | bool is_int64(char *number, int64_t *target) { | 231 | bool 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 | } |
