Article View: linux.kernel.git
Article #2714Re: [PATCH] repo: zero-initialize configuration values
From: Joie Joie
Date: Mon, 09 Nov 2026 14:26
Date: Mon, 09 Nov 2026 14:26
63 lines
13873 bytes
13873 bytes
Thanks, Junio.
I hadn't considered using a compound literal here. I was following the
existing initialization approach, but your suggestion makes sense,
especially given the update to the CodingGuidelines.
I'll look into changing the initialization to use a compound literal
while preserving the existing defaults and behavior.
On Fri, Nov 6, 2026 at 8:36 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Patrick Steinhardt <ps@pks.im> writes:
>
> > In any case, the patch is obviously correct and is a good improvement in
> > my opinion. So this looks good to me, thanks.
>
> It however does not look good to me. I would prefer to see
>
> struct foo foo = {0};
>
> if everything is zero initialized, or if there are some members
> initialized to specific values, C99 designated initializers to be
> used:
>
> struct foo foo = {
> /* Comment on this stuff */
> .object_creation_mode = OBJECT_CREATION_MODE,
>
> /* Comment on this other stuff */
> .branch_track = BRANCH_TRACK_REMOTE,
> };
>
> Now this is overwriting the passed in structure members, so how we
> write the initialization is not the whole story.
>
> Since we have avoided assuming the universal availability of the
> more recent "compound literals" syntax, which is:
>
> *cfg = (struct foo) {
> ... an initialization with designated initializers ...
> };
>
> we seem to (ab)use struct assignment, e.g.,
>
> static struct foo foo_template = {
> ... an initialization with designated initializers ...
> };
>
> *cfg = foo_template;
>
> in a few places as a fallback in the existing code (DI is C99,
> struct assignment is C89, so it has been a safer assumption than
> assuming compound literals).
>
> But I do recall we made this update to our CodingGuidelines document.
>
> . since late 2024 with v2.48.0-rc0~20, we have been using compound
> literals, e.g., (struct foo){ .member = value };
>
> So perhaps it is time to switch this to assign a compound literal?
Technical Details
Message-ID:
<CAH=d44fX-LN10TU0ZsuJ_RcxE=6QnKsHrLS4dJorAj3T55TZzA@mail.gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74931-linux-kernel-git=dewy.ruReferences:
<pull.2298.git.1793966368860.gitgitgadget@gmail.com> <au3hVGPuDyGVwOw8@pks.im> <xmqq7bipiwgt.fsf@gitster.g>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-74931-linux-kernel-git=dewy.ru
From: soniqjjj@gmail.com (Joie Joie)
Newsgroups: linux.kernel.git
Subject: Re: [PATCH] repo: zero-initialize configuration values
Date: Mon, 9 Nov 2026 15:26:22 +0100
Organization: Usenet Network
Message-ID: <CAH=d44fX-LN10TU0ZsuJ_RcxE=6QnKsHrLS4dJorAj3T55TZzA@mail.gmail.com>
References: <pull.2298.git.1793966368860.gitgitgadget@gmail.com>
<au3hVGPuDyGVwOw8@pks.im> <xmqq7bipiwgt.fsf@gitster.g>
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="377348"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:U7UiVsq+4lAdiis6z4G1YXXWmsI= sha256:YKgzPFfqI8CcTXGNFBxKT/JiLANN9wK+eCMH5H98L90=
sha1:5bETiN0hyNrqVoIIvBe9TyQfOFs= sha256:GxUeCXCjWcIdfU+eRPcWqxzYIzE9InX1QzygCQwNRIM=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id B59DE11382C; Mon, 9 Nov 2026 17:32:40 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id P2nXs7kbN8eK;
Mon, 9 Nov 2026 17:32:37 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-74931-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 2ABFF113777; Mon, 9 Nov 2026 17:32:28 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 1C347E2542; Mon, 9 Nov 2026 14:27:18 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794234434;
b=mT6ZqsGlpWfc98nmfE36N2D+AG0yc0y4ryQGWjGuLKQaOJDu7tibfcZWHQflCn2gSXlF
jNZEVFzUR839O/mvij94QUWWBryerjhHRX1Lqa7qHEaj27GzlEr4IA0UuWNNvu75ICXLP
UShV3L62AziF9PsAB8JhA0zg7zN151d0MyTR0ePJ8TEsuCNiOsXSLkHsP9ZMEBanCsqGS
y1DOy3/uKJjSiYlcHFk2rZR6xrWWf4PzIBkyw+dsaz1qCIJqjP7297hm65txsfK141XE1
Bw1P8KONHwQ7JwAScTY38wxLvxkazQd3fEpT53g15fEVfbCpO6bx9QyZo9t1RlRh+Aw==
X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794234434;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
References:In-Reply-To:From:Date:X-Gm-Features:Message-ID:Subject:To:
Content-Type:Content-Transfer-Encoding;
bh=SCbUUn0h2JspbNaOxybvrCMKuHt7k7RPy6F2uVROTLg=;
b=dQlBWt0ejJaLY8w/jzKsnRlkRfYdNNx/c43lvaRAYS9Xp0s9crzTeRQex1MoA9FsdDdM
3wwswm/SGTjjp6sv+K2smYFpLAaSIaiA9rbcOjbnKj1KBcuItFMjBBxRdCKw8SGogfOD3
O/druPdbKCM6VCJFNyUYKSr+BD5mFCIzj5/sD4UrZtst8BZd8hub62ln8LsuT8lzWvkWk
j0WLBaKttiYZ+Ke147KuCEHIpBJFhPUdsuysjqx+aybLBMJDKiH9gr40Yb5vY0ak9Kmnz
Bw/krB+uz2t+Sh5nrHZ/Ur1TlCUIbt9L6XrFKuvHjq+mn0ia5OLP78oILRZCECQyK/A==
X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FYDwVWJe;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 42350606A33F;
Mon, 9 Nov 2026 14:27:14 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FYDwVWJe
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.42
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1794234433;
b=gVEq70tpsgUNP7JW+PdsIwOFjl0JZpu1+vuBcjG5JXO3QbfD/haKl3zkBZP5r3HUo4hm
MrG8FsEzo3+rTMGu1RhemQ0EAWffhM89Rcvt3GFdoJQWxXE+wnK/lk69+k+YrVCbPtDWZ
2gua9HTUnfZxYz9VqvhZ/xBuQyJ7427zoNtbVoYdNdMIvE8By8EDgTH0CpElVzsWzV5LN
7z4+CxKj/pjWDCJdTYx4ZdkQOTmNQL1c4A1+xb+EoJVOC5rfBJvi6dU8EB9ZLX0V+ysRu
mfZSM7NiZRTOJTSBQbgPtmKg+nG+oEI+nKxKPezo0LoMMZWxDyxxYDRybUfq9l/eGhw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794234433;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:
MIME-Version:References:In-Reply-To:From:Date:X-Gm-Features:
Message-ID:Subject:To:Content-Type:Content-Transfer-Encoding;
bh=SCbUUn0h2JspbNaOxybvrCMKuHt7k7RPy6F2uVROTLg=;
b=In+Rhdw0pNiY5fhPmd1WABr+2O60G/Z+79uIH9MWLCIzvjb+H7QWqatfz059L3NQHZLE
vsv8GTfS3/wKoSKDsS4jAp+MV3SjOS+gbBqv+pWBCoVVEycWYWfOIIbLVUu6x2GSsuaaq
6JvPsiKjH1F0gf8rgTZgST+RoeedV1F4lt9+BGDWIQyGuJsI55yl7/aexXg8dCkzOkZZ7
94S6uFC0kpxZrWkbl7WOERCdA9OVcLF2KmCYVGvOeWgmqUnMgMxi3YcgsSZ/OyHrNVLY8
KjMqCcD96XDDAVDBGAeJ4GeDtYDx8l0Fye6Tn5znz+KO7FlXa01e/JC/0WvlNIV6m9g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FYDwVWJe;
arc=pass header.oldest-pass=0 smtp.remote-ip=209.85.210.42
X-Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 177FF606A325
for <git@vger.kernel.org>; Mon, 9 Nov 2026 14:27:12 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 177FF606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-85d363fb73cso465814a34.1
for <git@vger.kernel.org>; Mon, 09 Nov 2026 06:27:12 -0800 (PST)
X-ARC-Seal: i=1; a=rsa-sha256; t=1794234432; cv=none;
d=google.com; s=arc-20260327;
b=DcvoNlToxag3YZ2WXwoRxrEr4nG03NFCJZ/PXMy7pL+AgouYfsdgXmP+HbYNAbwgpf
T4vgNQHZULdepkPJ0xDvLnfoBv0FJowqDxzXd/llLxbNmgOd7EAHtuj5hBy5X9yqyBJR
o6dnwJVpocV9d26Ys9JTtqDgdgh2u52cegSms1yXcv3U4d13waiRHw92nEJO65Ax/c5f
8d5DbpYxNbHGbWIFO1qcxRtsu4v43wWagxhWMDnogVoN1s8eI1VeFRCs0kut7h9alWIo
jpUgsdj1v6DED9MZ2oF/IsFPXto4kMfadgrp3GlrrlbMQqMy5WBOaG10jtTdMEE77Fr4
eX5Q==
X-ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327;
h=content-transfer-encoding:to:subject:message-id:date:from
:in-reply-to:references:mime-version:dkim-signature;
bh=SCbUUn0h2JspbNaOxybvrCMKuHt7k7RPy6F2uVROTLg=;
fh=YeMfK1c2NBXa6r9LO4lVCoSa5qjj9QhIzQzIDo7F2cs=;
b=mubbtUQJoiGT9wm4z/0rAaoio6I3wB6X21wDkGKtGgFrAF7LsuRmnya1NtwiaI4+X+
k1HX+NvW01E3C7Udq6QbBH8YXW4qKnxaXwccS7ewKw3b3Ge1inoVMyZJ79xOzr6Li6PQ
6+piaKjTKhFjYpJOEo5eS7vwejMHAq4bsoGpf3/su8D1fbnbk8vTuz4X4LWgcTGLcyu8
FoLzvBcCGCwsgvOKVlOJedH4Xmjs92xXvEk17qE2EViUbTQym78vdWp5qeCjb+P+6RXQ
vNPkL1ES2YjdI9JpTfF7tDRGkwvvXUXdUIz1nZnrVDpwpe3v5bYCkuSCi5vU4sIjMxxy
ZHsw==;
darn=vger.kernel.org
X-ARC-Authentication-Results: i=1; mx.google.com; arc=none
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794234432; x=1794839232; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:to:subject:message-id:date
:from:in-reply-to:references:mime-version:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=SCbUUn0h2JspbNaOxybvrCMKuHt7k7RPy6F2uVROTLg=;
b=FYDwVWJeQq8MJoH7+6XZve/DNeqlMcKR7njCSBA/2q4+RyZ5APXcSDjKAUbeWxgjIe
L4mkqeKOr8kc4ZvjxChsTieipfEKbSkrBvS/u3FPpuuH+fcMtkbEOlWsoyIOmkAZcatq
dIcXK/w41lMvkYtknRKVpkfCARWOCuLIh+XRJRLEDOeQqz5EHba+wToVPnDTDTD/SMzE
QsmN+PqlNZbejPaq2I+z1VHkUQ/XHWweYKBMO2rnx4OTZAXnfbqwvLPQDc+m2PZI5tfB
+6zf8TYqsVTKuzGLOiHxSf+HYxqTpjZ39UA4MyJBRfyZQHNLunwPCjj585BY1ydeSQ0u
v3gw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794234432; x=1794839232;
h=content-transfer-encoding:content-type:to:subject:message-id:date
:from:in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state
:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=SCbUUn0h2JspbNaOxybvrCMKuHt7k7RPy6F2uVROTLg=;
b=KAu5YXZRWRwGlUN48QFM3peEAz2Zz2xzEsIwv+r8cmHBHh/4JW75YA0MqFeNnooANJ
ESuKggZhM2dPNcotjD4D/IkSxSO3HhrT+q60N4ONy7r6UhDbFKMxB7RXsK7zN45QhYh4
4m59CtwVj5nSaqaVH7YO5oqzhw9l6gaG8X30DucL34pkS8bOV6nCNeBy9Q8aJwlP2wHR
pOGguc/kc6XfhzVpg/jWz8bKloMs6Pvqrwo05yfyGBWJQMqMkbUo/WgDI2LZgiRW2kTz
0uzqgyWn8gQ5QWDnwGnOShsoCFgv5JrDJED9cgUCQ64Ar+qq+6jrx0i9v1S3EVnZEzB/
JOiw==
X-Forwarded-Encrypted: i=1; AL+hErH1UhmKXdHlRLEZ1dOge29hLZCSTfxbs6Qg9dLkfB824Yo7IH/N+3ObOobSv9fA97RDTOM=@vger.kernel.org
X-Gm-Message-State: APuU4Z/r7G8xjFiyJHiuoGZh57uQWcdo4Zlktoy7UvsuwGww9HlBdD30
oZFqwDncu/zo9ZPys4IPzWkG8MMJNVxsNbqzUwMNfy8RIIq74MRrY/Z7Mw/BY2McmJv5o4nl5My
UOKpTlyAwmZb5I20sbFEIvCxl/iKSnL8=
X-Gm-Gg: AYBFou2pai81UZ4UYzMF+Pz4OMzTzFV/3r9z33yxZKEzsRzVhSbvnZUfQdcPju1uRhp
OLQCTQ/Q45XPbk/ojeID1UUFDROOTR9qvSd+7N7+BRnJ7CkHONrE3Sw6wTDk+4JLIA/XBa95HuL
VkT9TZYWVoH6fTPujAmdvX0a4TfTctEgj7HMPkjmUPj/HMRKDTltWCoetvdgNIuX/W8G8FVNIhe
srv09flkSw+6xxMvFD+r8uSNKtr5PMfB+FepMERhrYBQtVITYVkxajMoSe6zwLO8M3ivksWYacQ
lODJjcP/N0MAsZpmQkQPIoDObjjOEIwnHQIZf5GFZ8SriZ/64THRnu3skA3ItLKRBzyKFxm81JF
9RTANbwbGU91XrdEgrlYh+lzD3U5Uz/DW/uGIu/RohDLB1OGcCM+8zWMzq1AZYpFlNKY/yXtj+D
stgxf/vA==
X-Received: by 2002:a05:6830:44a3:b0:844:d1b5:df47 with SMTP id
46e09a7af769-85f50805808mr3220632a34.19.1794234431852; Mon, 09 Nov 2026
06:27:11 -0800 (PST)
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <xmqq7bipiwgt.fsf@gitster.g>
X-Gm-Features: AclHuK_rpJA2gdej_QqeWbtD-xEac0dPvqhYbcAgEuQCYmb9ZUpTWPSVlp87gO0