]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: fix parsing of value-less -d/-l concurrency cli option
authorDarrick J. Wong <djwong@kernel.org>
Thu, 16 Jan 2025 21:22:04 +0000 (13:22 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 16 Jan 2025 21:27:27 +0000 (13:27 -0800)
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
mkfs/xfs_mkfs.c

index 956cc295489342a69d916c236a6f18021526b37e..deaac2044b94dd39fe58f5969414abaf52784420 100644 (file)
@@ -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);