From patchwork Thu Aug 31 12:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 719012 Delivered-To: patch@linaro.org Received: by 2002:adf:e5c2:0:b0:31d:da82:a3b4 with SMTP id a2csp466569wrn; Thu, 31 Aug 2023 06:17:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmXoOrKa6ADMYVEIPew9B2IOKj602Mmn+ytXoYD5Z8Ny5rtqL8Kp5uIlxorByW1aDvDWgX X-Received: by 2002:a05:622a:449:b0:40f:e946:a3f4 with SMTP id o9-20020a05622a044900b0040fe946a3f4mr2748007qtx.37.1693487850870; Thu, 31 Aug 2023 06:17:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693487850; cv=none; d=google.com; s=arc-20160816; b=NW+AE06ptsMuIxZo4YgbvlVEycJjGldNSqZzjVrp/5eeY1AnncgsXc7S8fx4ktv2+Q bGC1t8qa7umlqSmnlnTP1riPP8TUTcbW3lbrmqdPLqTNd0w3BoUEPE3Xju26uHf+9RGn fKVwim3/tBSN5i7RxrrxmzpI5G5Dm7OAQin2af64n8gxaNWDJIJ6OY0PAk6x/m4+0aym HmeIi/AkRKdcy5W+xw4/LSvAcC1fznbCR8rBbRAdNYVFjtEoAAwnndlkICh/nOB6fC8W jCZktYQ/X/UH8NPmtXgbLwEZqBChJTVvg5kIBPmlr61O0wn90InrYL6CCsiPBjBeRg+2 hXQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uHTYP96hxROQBfiRHrUY1wrTC25GMnf+igTYqzxdbDE=; fh=zn6o0f0gv5ZkC2kYOnqwo2ZvBbLYdyI8P1mhTaqTiyI=; b=Dtr4GOZepVXteK5TJCNPoFqK4pk3FslPvR1zmlTJrkQbo/gRg0+LbDFrn73JuGE4cU VDQgU/uDWq3vlx6+8XNiTSswbzIYk0vu00Z3xu4OGAT3NT28mvlrUiwWjZ7f1GIGPmQg RAMB2B0thQEyTuyEgno56XeepIaXkjwaa0JgbSTTzpHmzP9Y6oy1jMxJLC2vpcWzT9y5 V7y4vadWWVo46BkDPmJldcAOuoyaBEy3/mJoUrVV8d2Nlad28fnT8qXa6bNHgSirBPga FiT6NfIeS9y7TTE+HCQMcyIaC2PWtUSsHwDK0JlFI3CLnZv2peTpHchMceQOnsPViUpk itZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WD6MAfLi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d17-20020a05622a101100b004009ad9bb96si821083qte.310.2023.08.31.06.17.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 Aug 2023 06:17:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WD6MAfLi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qbhLP-0008Aq-Ny; Thu, 31 Aug 2023 09:04:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qbhHu-0007Mn-Uj for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:00:43 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qbhHq-0006lt-Po for qemu-devel@nongnu.org; Thu, 31 Aug 2023 09:00:42 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-401b393df02so7999425e9.1 for ; Thu, 31 Aug 2023 06:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693486837; x=1694091637; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uHTYP96hxROQBfiRHrUY1wrTC25GMnf+igTYqzxdbDE=; b=WD6MAfLiIo8WFCh9IzuyV3eICQyOVpEgw1+9dovw3501/dIr9lvebzAf8+bRn63dUP 70Q5LftB9Nlee7NrBqhxg1FUenpbAZdn4xxjhfMc9uOL295JqCqDtO3shCQOB8RlGZJy C+pQRAEPasB3nJJ0jUyfe+BH8k9nf/N1Z70ERrxVniOIGBMEp+lYzAw7pPXhIBCxxrRH 9XgTw9r2Xtrmo6lgk/otO4EAHwGj51pefzBFefg7SIttWzmNzVbspBXCtLUyIw2ZIRxM vMZnK2RTQiwC7wQiSBf//rwChAIwapxwgQ/mS8Mzl+PpT6gL9ZGcBFcTEBw1PcHpdOR2 1P3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693486837; x=1694091637; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uHTYP96hxROQBfiRHrUY1wrTC25GMnf+igTYqzxdbDE=; b=KRKDRMaT/QRuW8LiCUO9f87GY1DO2+hmcbq4mHmgBSoVLM4BJ7N7g9B6IhBnqJac5h D4b5StZ9rolXZ5F7BwJy9sfF3nYVaS0nKUtXoRiOQZxpvwIOo8XqCcy+fjDpPpd6e5G6 SJ979O7w4KeVpithXCWWGeOTF9kR7T9ZOQPxRyRfbVrUlz+R2FZS8aiwI+/49uDZwJ50 tn7QzGgYI5ZOLpQxcCXA3NIu3jBaDW+TDrhkAmWzL9cRIlx8ILJNLuHBbv+SRFg5e7mY dHb3eMG5oyFO7EieT5xK8xEWT7QIxUwv8TyYxPRbQALw68OU00IPtKPRgE3IgHtU/wcE xq4A== X-Gm-Message-State: AOJu0YyDticqiGdPicmargilCvqspnAY3guXaSMWWg4YvTwUgbZba/tx 4vcPnReyFDHaTfEqYqk00NEUW781EW1OIyQX1z0= X-Received: by 2002:adf:f5c6:0:b0:314:3b02:a8a8 with SMTP id k6-20020adff5c6000000b003143b02a8a8mr3761369wrp.55.1693486836365; Thu, 31 Aug 2023 06:00:36 -0700 (PDT) Received: from m1x-phil.lan ([176.187.199.245]) by smtp.gmail.com with ESMTPSA id r5-20020adfe685000000b003143867d2ebsm2189041wrm.63.2023.08.31.06.00.34 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 31 Aug 2023 06:00:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-riscv@nongnu.org, qemu-block@nongnu.org, =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson , Thomas Huth , Stefan Hajnoczi , Markus Armbruster , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Juan Quintela Subject: [PULL 38/41] docs/style: permit inline loop variables Date: Thu, 31 Aug 2023 14:56:40 +0200 Message-ID: <20230831125646.67855-39-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230831125646.67855-1-philmd@linaro.org> References: <20230831125646.67855-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Alex Bennée I've already wasted enough of my time debugging aliased variables in deeply nested loops. While not scattering variable declarations around is a good aim I think we can make an exception for stuff used inside a loop. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Reviewed-by: Stefan Hajnoczi Acked-by: Markus Armbruster Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20230822155004.1158931-1-alex.bennee@linaro.org> --- docs/devel/style.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/devel/style.rst b/docs/devel/style.rst index 3cfcdeb9cd..2f68b50079 100644 --- a/docs/devel/style.rst +++ b/docs/devel/style.rst @@ -204,7 +204,14 @@ Declarations Mixed declarations (interleaving statements and declarations within blocks) are generally not allowed; declarations should be at the beginning -of blocks. +of blocks. To avoid accidental re-use it is permissible to declare +loop variables inside for loops: + +.. code-block:: c + + for (int i = 0; i < ARRAY_SIZE(thing); i++) { + /* do something loopy */ + } Every now and then, an exception is made for declarations inside a #ifdef or #ifndef block: if the code looks nicer, such declarations can