summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
7103b9b)
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>
exit(2);
}
s.chunk = parse_size(optarg);
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);
pr_err("invalid chunk/rounding value: %s\n",
optarg);
exit(2);
s.size = MAX_SIZE;
else {
s.size = parse_size(optarg);
s.size = MAX_SIZE;
else {
s.size = parse_size(optarg);
+ if (s.size == INVALID_SECTORS ||
+ s.size < 8) {
pr_err("invalid size: %s\n",
optarg);
exit(2);
pr_err("invalid size: %s\n",
optarg);
exit(2);
array_size = MAX_SIZE;
else {
array_size = parse_size(optarg);
array_size = MAX_SIZE;
else {
array_size = parse_size(optarg);
+ if (array_size == 0 ||
+ array_size == INVALID_SECTORS) {
pr_err("invalid array size: %s\n",
optarg);
exit(2);
pr_err("invalid array size: %s\n",
optarg);
exit(2);
case O(BUILD,BitmapChunk):
case O(CREATE,BitmapChunk): /* bitmap chunksize */
s.bitmap_chunk = parse_size(optarg);
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);
s.bitmap_chunk & (s.bitmap_chunk - 1)) {
pr_err("invalid bitmap chunksize: %s\n",
optarg);
* In those cases with use MAX_SIZE
*/
#define MAX_SIZE 1
* In those cases with use MAX_SIZE
*/
#define MAX_SIZE 1
+
+/* We want to use unsigned numbers for sector counts, but need
+ * a value for 'invalid'. Use '1'.
+ */
+#define INVALID_SECTORS 1
+
* followed by 'K', 'M', or 'G'.
* Without a suffix, K is assumed.
* Number returned is in sectors (half-K)
* followed by 'K', 'M', or 'G'.
* Without a suffix, K is assumed.
* Number returned is in sectors (half-K)
+ * INVALID_SECTORS returned on error.
*/
char *c;
long long s = strtoll(size, &c, 10);
*/
char *c;
long long s = strtoll(size, &c, 10);