From patchwork Thu Aug 24 16:39:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 716560 Delivered-To: patch@linaro.org Received: by 2002:adf:f747:0:b0:317:ecd7:513f with SMTP id z7csp1444271wrp; Thu, 24 Aug 2023 09:41:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEaPlVI9K3+Wp6Da2nOG5PRa606VFLdOsLh7nYX0BF0hLYKxjTnBZ0pi6nuzGpR2W6THuFi X-Received: by 2002:a05:6214:2346:b0:63d:580:9c68 with SMTP id hu6-20020a056214234600b0063d05809c68mr15327971qvb.32.1692895316901; Thu, 24 Aug 2023 09:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692895316; cv=none; d=google.com; s=arc-20160816; b=lI/+jEWmeijpUG4Ct2h1tGTWzbEFCIM9qtEu+x9/jYdqSXrQkpb9GI0E0ueWFEwEgc U8GG8z0DTErAenuV84FgcWC7ohwojB2huXLX0VSOoiRAbDkOEP2IXG8w7kOW9MDFQi4P SU/iak7QEZkEp656nsBi9LSbGSkR42f3IYSCVzEt0bxjAgUHfrNoWgWIKyPhnzfW0LaC FSdElyrNA27QiY2yy5cQz2TADZ3xUkU3xJI3sPKl8JAS/103FkN2gGGEGYeNnvZR0s/o OF1s67V7pjwZxqchzPJduLxWz6StSjFyJUNbXuga3HjOLkCVuLoilAatnADkhfG6YL/U wvBg== 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=iiC7cvPGqtDwu4nVf8eS+Cmc1lWchz2oWST+0j9UI/U=; fh=aUL1Q6jN33xXfcVUXrmc30ArCAPLVMr2mlcYRZh/bjY=; b=U7ug1bRtZ/+o7nIIGBRP3WPnpy3MtTPDvLWVYijfmb17lDbPKbUnCBH32u79g2RwG7 rHB2smnoja6BOk8SdW9ActB9E6AhOmzA9P7HwIWpV268B8z0baU2zvH/JWIFX+WeIKmB pCFCBpjAWrymPPaTBepUDvbrn2TFLZw7NS9j3e5WOx1zZW622gZ7ryZC31aaGn+r/4pD c/L3ievhNEMOWOGt00xiqh7WQDY33BbEskcaL1WwDiT/tbBcyNJS2sJ2hX5TKuiOnVfw QnlBHTmbXEAxqI/io26sWL7HDjT80BUa4dMiyI3p2hHRiLaITUyudgJq2aL9/DlXTzM+ 08bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vA04Pnyi; 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 w4-20020a0cdf84000000b0063cea6346fasi118266qvl.396.2023.08.24.09.41.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 24 Aug 2023 09:41:56 -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=vA04Pnyi; 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 1qZDMn-0006Mx-3Y; Thu, 24 Aug 2023 12:39:29 -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 1qZDMk-0006Ln-W5 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 12:39:27 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qZDMb-00087H-92 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 12:39:26 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3fea0640d7aso233125e9.0 for ; Thu, 24 Aug 2023 09:39:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692895155; x=1693499955; 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=iiC7cvPGqtDwu4nVf8eS+Cmc1lWchz2oWST+0j9UI/U=; b=vA04Pnyi1MC8iOQivkJG13qqRHXhRXuNG7cUOMxumPJZedRGejr4eELLl0BrlJyUqV Vd3n/9aUMUboZS3CWZ9lfs67ilKCYueY1h+GPvUoAEg2hwJIF2ezCfTY23rQxpdGn96n AUkUD3bu5RDU2QLQB46APSKzlD6/v4AGjV3U/9/xpLDi//2nBJ+92F1576o2Y+MUr4zX /6Ewj6uwLFC0TRSeEYj0Ri1Xoka63RPdCCYj7cUt5Fh3cixZiZSR2xn+WXOCawLN2wKt tBjFnXRyU6bIG0ix4WNxK119p1EeUcp5omVUWMmQnuj4rH5ZhCFvMmXYcLpLmMeb2Pvn OB8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692895155; x=1693499955; 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=iiC7cvPGqtDwu4nVf8eS+Cmc1lWchz2oWST+0j9UI/U=; b=kS6yqw+/bU8mTCR13TsnsnP71NpImMLG5PJqtj1gKAhPc+QkWJHVOo5e6rksxwnYZV 4k49mSvfzirUQmoGrK2Pe7iuJU6gwQW275/7y1U3yg+ijRv1x/QcPVRyRVWqfYY+whXL KKPaxUd74K2drAuFTZa/F+dtf1FJ5zup2HaplllbHvleCp+HBwurFrqzOcl1zKIXnUJP J4DN60Wq1HdPrIsEwEUOEUOZWvad0KPjX88IWkBlq5Wxq35ABrcggzu7uMmlA8B6ld89 C81PObxGe2/5SGCpB8nMCFcUkN95d14oDoAdPnQdMwbzW5sXOyDKLKNaPSPy8GCwgnSw A+7g== X-Gm-Message-State: AOJu0Yx0lHB2Z41VEiBShOcuyhjSMfz5SsDf4LPZtEXUzcN03YmCl2Y7 0bSEVUf90LMND89yRfl7+ro0YQ== X-Received: by 2002:a05:600c:28c:b0:401:b0f2:88cc with SMTP id 12-20020a05600c028c00b00401b0f288ccmr1218595wmk.41.1692895155495; Thu, 24 Aug 2023 09:39:15 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id s16-20020a05600c045000b003fee0741b8csm3070971wmb.23.2023.08.24.09.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 09:39:13 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A942F1FFBF; Thu, 24 Aug 2023 17:39:10 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Beraldo Leal , Nicholas Piggin , Richard Henderson , Markus Armbruster , Yonggang Luo , qemu-ppc@nongnu.org, David Gibson , Daniel Henrique Barboza , qemu-s390x@nongnu.org, Akihiko Odaki , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, Juan Quintela , Thomas Huth , Peter Maydell , Ilya Leoshkevich , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , David Hildenbrand , Greg Kurz , Wainer dos Santos Moschetta , =?utf-8?q?Philippe_Mathi?= =?utf-8?q?eu-Daud=C3=A9?= , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Stefan Hajnoczi Subject: [PATCH v2 04/12] docs/style: permit inline loop variables Date: Thu, 24 Aug 2023 17:39:02 +0100 Message-Id: <20230824163910.1737079-5-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230824163910.1737079-1-alex.bennee@linaro.org> References: <20230824163910.1737079-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x331.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 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. Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Stefan Hajnoczi Acked-by: Markus Armbruster Reviewed-by: Thomas Huth Reviewed-by: Richard Henderson Signed-off-by: Alex Bennée 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