btrfs-progs: cleanup and comment parse_range
Simplify a check and unindent some code. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
89c0e3b706
commit
9288d0bc23
|
@ -88,15 +88,27 @@ static int parse_u64(const char *str, u64 *result)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse range that's missing some part that can be implicit:
|
||||
* a..b - exact range, a can be equal to b
|
||||
* a.. - implicitly unbounded maximum (end == (u64)-1)
|
||||
* ..b - implicitly starting at 0
|
||||
* a - invalid; unclear semantics, use parse_u64 instead
|
||||
*
|
||||
* Returned values are u64, value validation and interpretation should be done
|
||||
* by the caller.
|
||||
*/
|
||||
static int parse_range(const char *range, u64 *start, u64 *end)
|
||||
{
|
||||
char *dots;
|
||||
|
||||
dots = strstr(range, "..");
|
||||
if (dots) {
|
||||
const char *rest = dots + 2;
|
||||
const char *rest;
|
||||
int skipped = 0;
|
||||
|
||||
dots = strstr(range, "..");
|
||||
if (!dots)
|
||||
return 1;
|
||||
|
||||
rest = dots + 2;
|
||||
*dots = 0;
|
||||
|
||||
if (!*rest) {
|
||||
|
@ -123,7 +135,6 @@ static int parse_range(const char *range, u64 *start, u64 *end)
|
|||
|
||||
if (skipped <= 1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue