diff options
author | NeilBrown <neilb@suse.de> | 2012-10-04 16:34:20 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-10-04 16:34:20 +1000 |
commit | 822e393a050510b0002bdfb1b0554fa8d7860a99 (patch) | |
tree | 80799a3b855960a91c5aaa0bb8471a18988952a1 /mdadm.c | |
parent | 7103b9b88d8c27989e17c80d7296eda97370dc1e (diff) |
Allow parse_size to return 0.
We will shortly introduce --data-offset= which is allowed to
be zero. We will want to use parse_size() so it needs to be
able to return '0' without it being an error.
So define INVALID_SECTORS to be an impossible value (currently '1')
and return and test for it consistently.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'mdadm.c')
-rw-r--r-- | mdadm.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -372,7 +372,8 @@ int main(int argc, char *argv[]) exit(2); } s.chunk = parse_size(optarg); - if (s.chunk < 8 || (s.chunk&1)) { + if (s.chunk == INVALID_SECTORS || + s.chunk < 8 || (s.chunk&1)) { pr_err("invalid chunk/rounding value: %s\n", optarg); exit(2); @@ -426,7 +427,8 @@ int main(int argc, char *argv[]) s.size = MAX_SIZE; else { s.size = parse_size(optarg); - if (s.size < 8) { + if (s.size == INVALID_SECTORS || + s.size < 8) { pr_err("invalid size: %s\n", optarg); exit(2); @@ -446,7 +448,8 @@ int main(int argc, char *argv[]) array_size = MAX_SIZE; else { array_size = parse_size(optarg); - if (array_size <= 0) { + if (array_size == 0 || + array_size == INVALID_SECTORS) { pr_err("invalid array size: %s\n", optarg); exit(2); @@ -1062,7 +1065,8 @@ int main(int argc, char *argv[]) case O(BUILD,BitmapChunk): case O(CREATE,BitmapChunk): /* bitmap chunksize */ s.bitmap_chunk = parse_size(optarg); - if (s.bitmap_chunk <= 0 || + if (s.bitmap_chunk == 0 || + s.bitmap_chunk == INVALID_SECTORS || s.bitmap_chunk & (s.bitmap_chunk - 1)) { pr_err("invalid bitmap chunksize: %s\n", optarg); |