X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbin%2Fmemerror.cc;h=14a70c29b0ae506132506a93e29a022569702fde;hb=bbf0f8ea70200393dbcd51d64652f64a357a0cdf;hp=c35684ad06bd5087094906b394a0b8631f38e27a;hpb=7c2da91b9897c54f66e7fc634a675fcaeef32167;p=awesomized%2Flibmemcached diff --git a/src/bin/memerror.cc b/src/bin/memerror.cc index c35684ad..14a70c29 100644 --- a/src/bin/memerror.cc +++ b/src/bin/memerror.cc @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) { char *nptr; unsigned long value = strtoul(argv[optind], &nptr, 10); - if ((errno != 0) or (nptr == argv[optind] and value == 0) + if ((errno) or (nptr == argv[optind] and value == 0) or (value == ULONG_MAX and errno == ERANGE) or (value == 0 and errno == EINVAL)) { std::cerr << "strtoul() was unable to parse given value" << std::endl; @@ -84,17 +84,23 @@ void options_parse(int argc, char *argv[]) { } switch (option_rv) { - case 0: break; + case 0: + break; - case OPT_VERSION: /* --version or -V */ opt_version = true; break; + case OPT_VERSION: /* --version or -V */ + opt_version = true; + break; - case OPT_HELP: /* --help or -h */ opt_help = true; break; + case OPT_HELP: /* --help or -h */ + opt_help = true; + break; case '?': /* getopt_long already printed an error message. */ exit(EXIT_FAILURE); - default: exit(EXIT_FAILURE); + default: + exit(EXIT_FAILURE); } }