diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-02 15:10:31 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-05-02 15:10:31 +0000 |
commit | f06529114330fdfa04fa084eeb7f011d4faadee9 (patch) | |
tree | 4256af46de02ecf3160dd2f8d198b4a483985ae0 | |
parent | 00f24a76e880990054c818c051a9955854318670 (diff) |
use strtonum(3) and usage nit; ok millert@
-rw-r--r-- | sbin/tunefs/tunefs.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index 394caeb2ac5..2de1fbed83a 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -254,30 +254,26 @@ main(int argc, char *argv[]) static int getnum(const char *num, const char *desc, int min, int max) { - long n; - char *ep; - - n = strtol(num, &ep, 10); - if (ep[0] != '\0') - errx(1, "Invalid number `%s' for %s", num, desc); - if ((int) n < min) - errx(1, "%s `%s' too small (minimum is %d)", desc, num, min); - if ((int) n > max) - errx(1, "%s `%s' too large (maximum is %d)", desc, num, max); - return ((int)n); + int n; + const char *errstr; + + n = strtonum(num, min, max, &errstr); + if (errstr != NULL) + errx(1, "Invalid number `%s' for %s: %s", num, desc, errstr); + return (n); } static void usage(void) { - fprintf(stderr, "usage: tunefs [-AFN] tuneup-options special-device\n"); - fprintf(stderr, "where tuneup-options are:\n"); - fprintf(stderr, "\t-e maximum blocks per file in a cylinder group\n"); - fprintf(stderr, "\t-g average file size\n"); - fprintf(stderr, "\t-h expected number of files per directory\n"); - fprintf(stderr, "\t-m minimum percentage of free space\n"); - fprintf(stderr, "\t-o optimization preference (`space' or `time')\n"); + fprintf(stderr, "usage: tunefs [-AFN] tuneup-options special-device\n" + "where tuneup-options are:\n" + "\t-e maximum blocks per file in a cylinder group\n" + "\t-g average file size\n" + "\t-h expected number of files per directory\n" + "\t-m minimum percentage of free space\n" + "\t-o optimization preference (`space' or `time')\n"); exit(2); } |