From nobody Thu Oct 2 20:42:55 2025 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D926A25F798 for ; Wed, 10 Sep 2025 23:25:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757546751; cv=none; b=u3Zti895pNMDwItdlYC95H0Gchu6SZwT2TcLU6cGK0yxQSOdRsSiRX7957ov1vQBj4Zz80Fsjhu2PNsSQcy2PQZcwvLp4MDHiQTVX+pipaj6mbDTr41U7fC4bK2YawJhfuzsybsba4HuqOwmUKgUzLSTyt+ljZSFQMQyhE4Lymg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757546751; c=relaxed/simple; bh=9V0bE29KEboEUZunP/P29x8kJMn/gBb1WEqSyjpfTwU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dt8wMmeZtPGTjL3foRHTCYhZuFqOvulBDSXGyzSunh7H5S/33f9eqG1RtHtn6/rqkt+g5X4us44Bo5POnthIdCwT22OCvBw8Bq6dl2oL5XCoWne3KGPJOZmKenHkWcP1q4OBSpYGmjwHhB3do+/+WtCIbvXMm4wCgnMNCujY5Ak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=l0fvFCVV; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="l0fvFCVV" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1757546746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4PArehQ+yUqtb9cJ2WUekoqWKkUmPU/daAE92zsO77c=; b=l0fvFCVV26RrqV2E7RNFMoMJjEjJvc1OxGz2rjVaxThrmiXyQPye1bCyz9R6XQDi/mp42p uO8i0TqHVzKuEK/LiuyukecUgdVPOe/dmmjAIePhxMbIpu1DYzvsJoOFMSR/0bNSZMFaGY gG6BQkHwGKC4/e0B9dYzLVS7WK9BLDQ= From: Thorsten Blum To: Andrew Morton , Nick Terrell , David Sterba Cc: Thorsten Blum , linux-kernel@vger.kernel.org Subject: [PATCH] lib/decompress: Use designated initializers for struct compress_format Date: Thu, 11 Sep 2025 01:23:51 +0200 Message-ID: <20250910232350.1308206-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Switch 'compressed_formats[]' to the more modern and flexible designated initializers. This improves readability and allows struct fields to be reordered. Also use a more concise sentinel marker. Remove the curly braces around the for loop while we're at it. No functional changes intended. Signed-off-by: Thorsten Blum Reviewed-by: Kuan-Wei Chiu --- lib/decompress.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/decompress.c b/lib/decompress.c index ab3fc90ffc64..7785471586c6 100644 --- a/lib/decompress.c +++ b/lib/decompress.c @@ -49,15 +49,15 @@ struct compress_format { }; =20 static const struct compress_format compressed_formats[] __initconst =3D { - { {0x1f, 0x8b}, "gzip", gunzip }, - { {0x1f, 0x9e}, "gzip", gunzip }, - { {0x42, 0x5a}, "bzip2", bunzip2 }, - { {0x5d, 0x00}, "lzma", unlzma }, - { {0xfd, 0x37}, "xz", unxz }, - { {0x89, 0x4c}, "lzo", unlzo }, - { {0x02, 0x21}, "lz4", unlz4 }, - { {0x28, 0xb5}, "zstd", unzstd }, - { {0, 0}, NULL, NULL } + { .magic =3D {0x1f, 0x8b}, .name =3D "gzip", .decompressor =3D gunzip }, + { .magic =3D {0x1f, 0x9e}, .name =3D "gzip", .decompressor =3D gunzip }, + { .magic =3D {0x42, 0x5a}, .name =3D "bzip2", .decompressor =3D bunzip2 }, + { .magic =3D {0x5d, 0x00}, .name =3D "lzma", .decompressor =3D unlzma }, + { .magic =3D {0xfd, 0x37}, .name =3D "xz", .decompressor =3D unxz }, + { .magic =3D {0x89, 0x4c}, .name =3D "lzo", .decompressor =3D unlzo }, + { .magic =3D {0x02, 0x21}, .name =3D "lz4", .decompressor =3D unlz4 }, + { .magic =3D {0x28, 0xb5}, .name =3D "zstd", .decompressor =3D unzstd }, + { /* sentinel */ } }; =20 decompress_fn __init decompress_method(const unsigned char *inbuf, long le= n, @@ -73,11 +73,10 @@ decompress_fn __init decompress_method(const unsigned c= har *inbuf, long len, =20 pr_debug("Compressed data magic: %#.2x %#.2x\n", inbuf[0], inbuf[1]); =20 - for (cf =3D compressed_formats; cf->name; cf++) { + for (cf =3D compressed_formats; cf->name; cf++) if (!memcmp(inbuf, cf->magic, 2)) break; =20 - } if (name) *name =3D cf->name; return cf->decompressor; --=20 2.51.0