summaryrefslogtreecommitdiff
path: root/bootctl
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2015-11-19 14:43:53 -0800
committerTao Bao <tbao@google.com>2015-11-19 14:51:17 -0800
commit9608201e62a732c74ca71eb67f7b4e7a60612b86 (patch)
tree7e05864cc4353e61f9904c435a71138f12c65196 /bootctl
parent6978131b781d16e6911fa51f68e101abe225de5c (diff)
downloadextras-9608201e62a732c74ca71eb67f7b4e7a60612b86.tar.gz
bootctl: Fix the error checking for strtol result.
system/extras/bootctl/bootctl.c:136:13: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (ret == LONG_MIN || ret == LONG_MAX) { Change-Id: Id4816716e4c6d304c2ca531aadbcc62117ad7376
Diffstat (limited to 'bootctl')
-rw-r--r--bootctl/bootctl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/bootctl/bootctl.c b/bootctl/bootctl.c
index 55eb5bf4..58fdbb69 100644
--- a/bootctl/bootctl.c
+++ b/bootctl/bootctl.c
@@ -132,13 +132,14 @@ static int parse_slot(int pos, int argc, char *argv[])
exit(EX_USAGE);
return -1;
}
- int ret = strtol(argv[pos], NULL, 10);
- if (ret == LONG_MIN || ret == LONG_MAX) {
+ errno = 0;
+ long int ret = strtol(argv[pos], NULL, 10);
+ if (errno != 0 || ret > INT_MAX || ret < 0) {
usage(stderr, argc, argv);
exit(EX_USAGE);
return -1;
}
- return ret;
+ return (int)ret;
}
int main(int argc, char *argv[])