summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2012-05-15 17:43:32 +0200
committerKarel Zak2012-05-15 17:43:32 +0200
commit33fb5cfd49260382f9f3ef6ede1210a5a92b13ba (patch)
tree5a991e18bfa70395869a60c9014019c39180e973 /disk-utils
parentlib/strutils: create type specific strtoxx_or_err() (diff)
downloadkernel-qcow2-util-linux-33fb5cfd49260382f9f3ef6ede1210a5a92b13ba.tar.gz
kernel-qcow2-util-linux-33fb5cfd49260382f9f3ef6ede1210a5a92b13ba.tar.xz
kernel-qcow2-util-linux-33fb5cfd49260382f9f3ef6ede1210a5a92b13ba.zip
disk-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/mkfs.bfs.c2
-rw-r--r--disk-utils/mkfs.cramfs.c13
-rw-r--r--disk-utils/mkswap.c32
3 files changed, 17 insertions, 30 deletions
diff --git a/disk-utils/mkfs.bfs.c b/disk-utils/mkfs.bfs.c
index b37a94729..c93067e20 100644
--- a/disk-utils/mkfs.bfs.c
+++ b/disk-utils/mkfs.bfs.c
@@ -185,7 +185,7 @@ int main(int argc, char **argv)
if (optind == argc - 1)
user_specified_total_blocks =
- strtoll_or_err(argv[optind], _("invalid block-count"));
+ strtou64_or_err(argv[optind], _("invalid block-count"));
else if (optind != argc)
usage(stderr);
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 8e38a8c89..919f1efbf 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -66,7 +66,7 @@ static int cramfs_is_big_endian = 0; /* target is big endian */
* Note that kernels up to at least 2.3.39 don't support cramfs holes,
* which is why this is turned off by default.
*/
-static int opt_edition = 0;
+static unsigned int opt_edition = 0;
static int opt_errors = 0;
static int opt_holes = 0;
static int opt_pad = 0;
@@ -727,20 +727,13 @@ int main(int argc, char **argv)
case 'h':
usage(MKFS_EX_OK);
case 'b':
- {
- long long tmp = strtoll_or_err(optarg,
- _("failed to parse blocksize argument"));
-
- if (tmp <= 0 || UINT_MAX < tmp)
- errx(MKFS_EX_USAGE, _("invalid block size"));
- blksize = tmp;
+ blksize = strtou32_or_err(optarg, _("invalid blocksize argument"));
break;
- }
case 'E':
opt_errors = 1;
break;
case 'e':
- opt_edition = strtoll_or_err(optarg, _("edition number argument failed"));
+ opt_edition = strtou32_or_err(optarg, _("edition number argument failed"));
break;
case 'N':
if (strcmp(optarg, "big") == 0)
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index db465b7c2..ca49d0e34 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -145,21 +145,21 @@ is_sparc64(void)
* What to do? Let us allow the user to specify the pagesize explicitly.
*
*/
-static long user_pagesize;
-static int pagesize;
+static unsigned int user_pagesize;
+static unsigned int pagesize;
static unsigned long *signature_page = NULL;
static void
init_signature_page(void)
{
- int kernel_pagesize = pagesize = getpagesize();
+ unsigned int kernel_pagesize = pagesize = getpagesize();
if (user_pagesize) {
- if ((user_pagesize & (user_pagesize - 1)) ||
- user_pagesize < (long) sizeof(struct swap_header_v1_2) + 10)
+ if (!is_power_of_2(user_pagesize) ||
+ user_pagesize < sizeof(struct swap_header_v1_2) + 10)
errx(EXIT_FAILURE,
- _("Bad user-specified page size %lu"),
+ _("Bad user-specified page size %u"),
user_pagesize);
pagesize = user_pagesize;
}
@@ -452,7 +452,7 @@ main(int argc, char **argv) {
unsigned long long sz;
off_t offset;
int force = 0;
- long version = 1;
+ int version = 1;
char *block_count = 0;
char *opt_label = NULL;
unsigned char *uuid = NULL;
@@ -486,13 +486,13 @@ main(int argc, char **argv) {
force=1;
break;
case 'p':
- user_pagesize = strtol_or_err(optarg, _("parse page size failed"));
+ user_pagesize = strtou32_or_err(optarg, _("parse page size failed"));
break;
case 'L':
opt_label = optarg;
break;
case 'v':
- version = strtol_or_err(optarg, _("parse version number failed"));
+ version = strtos32_or_err(optarg, _("parse version number failed"));
break;
case 'U':
#ifdef HAVE_LIBUUID
@@ -503,8 +503,7 @@ main(int argc, char **argv) {
#endif
break;
case 'V':
- printf(_("%s from %s\n"), program_invocation_short_name,
- PACKAGE_STRING);
+ printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
case 'h':
usage(stdout);
@@ -523,8 +522,7 @@ main(int argc, char **argv) {
if (version != 1)
errx(EXIT_FAILURE,
- _("does not support swapspace version %lu."),
- version);
+ _("does not support swapspace version %d."), version);
#ifdef HAVE_LIBUUID
if(opt_uuid) {
@@ -543,12 +541,8 @@ main(int argc, char **argv) {
}
if (block_count) {
/* this silly user specified the number of blocks explicitly */
- long long blks;
-
- blks = strtoll_or_err(block_count, "parse block count failed");
- if (blks < 0)
- usage(stderr);
-
+ uint64_t blks = strtou64_or_err(block_count,
+ _("invalid block count argument"));
PAGES = blks / (pagesize / 1024);
}
sz = get_size(device_name);