diff options
author | Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> | 2023-10-29 11:09:00 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-29 11:09:00 +0100 |
commit | 77e38ac1c025b8431d1834a2c1059f9677c78ab1 (patch) | |
tree | aa8dc016303530e56155826f355cb7e3c3a4ee94 /plugins/utils.c | |
parent | 2eea6bb2a04bbfb169bac5f0f7c319f998e8ab87 (diff) | |
parent | eead88edda047843b911afd7b63e7decfee306ce (diff) | |
download | monitoring-plugins-77e38ac.tar.gz |
Merge pull request #1953 from RincewindsHat/compiler_warnings-sign-compare
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 | } |