mkfs: fix parsing of value-less -d/-l concurrency cli option
It's supposed to be possible to specify the -d concurrency option with
no value in order to get mkfs calculate the agcount from the number of
CPUs. Unfortunately I forgot to handle that case (optarg is null) so
mkfs crashes instead. Fix that.
Fixes: 9338bc8b1bf073 ("mkfs: allow sizing allocation groups for concurrency")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 956cc29..deaac20 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -1722,7 +1722,7 @@
* "nr_cpus" or "1" means set the concurrency level to the CPU count.
* If this cannot be determined, fall back to the default AG geometry.
*/
- if (!strcmp(value, "nr_cpus"))
+ if (!value || !strcmp(value, "nr_cpus"))
optnum = 1;
else
optnum = getnum(value, opts, subopt);
@@ -1867,7 +1867,7 @@
* "nr_cpus" or 1 means set the concurrency level to the CPU count. If
* this cannot be determined, fall back to the default computation.
*/
- if (!strcmp(value, "nr_cpus"))
+ if (!value || !strcmp(value, "nr_cpus"))
optnum = 1;
else
optnum = getnum(value, opts, subopt);