From: Darrick J. Wong Date: Thu, 16 Jan 2025 21:22:04 +0000 (-0800) Subject: mkfs: fix parsing of value-less -d/-l concurrency cli option X-Git-Tag: v6.13.0~11 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=93711a36ed549ac902ab9d9fbb87846abeb95763;p=thirdparty%2Fxfsprogs-dev.git 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" Reviewed-by: Christoph Hellwig --- diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 956cc295..deaac204 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -1722,7 +1722,7 @@ set_data_concurrency( * "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 @@ set_log_concurrency( * "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);