mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-15 22:00:06 -04:00
Fix logic in is_uint64_t to fix type-limit warning
This commit is contained in:
parent
f054ab04e7
commit
1b06060cbc
1 changed files with 13 additions and 4 deletions
|
|
@ -258,16 +258,25 @@ bool is_int64(char *number, int64_t *target) {
|
|||
*/
|
||||
bool is_uint64(char *number, uint64_t *target) {
|
||||
errno = 0;
|
||||
uint64_t tmp = strtoll(number, NULL, 10);
|
||||
char *endptr = { 0 };
|
||||
unsigned long long tmp = strtoull(number, &endptr, 10);
|
||||
|
||||
if (errno != 0) {
|
||||
return false;
|
||||
}
|
||||
if (tmp < 0 || tmp > UINT64_MAX) {
|
||||
|
||||
if (*endptr != '\0') {
|
||||
return false;
|
||||
}
|
||||
if (target != NULL) {
|
||||
*target = tmp;
|
||||
|
||||
if (tmp > UINT64_MAX) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (target != NULL) {
|
||||
*target = (uint64_t)tmp;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue