From: Thomas Huth <thuth@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Juan Quintela" <quintela@redhat.com>
Subject: Re: [RFC PATCH] docs/style: permit inline loop variables
Date: Tue, 22 Aug 2023 18:13:33 +0200 [thread overview]
Message-ID: <b311bb8e-d2c0-ced9-b5d3-05558abaa800@redhat.com> (raw)
In-Reply-To: <20230822155004.1158931-1-alex.bennee@linaro.org>
On 22/08/2023 17.50, Alex Bennée wrote:
> 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 <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 */
> + }
Reviewed-by: Thomas Huth <thuth@redhat.com>
next prev parent reply other threads:[~2023-08-22 16:14 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-22 15:50 [RFC PATCH] docs/style: permit inline loop variables Alex Bennée
2023-08-22 15:52 ` Stefan Hajnoczi
2023-08-22 15:57 ` Peter Maydell
2023-08-23 5:59 ` Markus Armbruster
2023-08-24 13:18 ` Peter Maydell
2023-08-31 13:29 ` Markus Armbruster
2023-08-22 16:09 ` Richard Henderson
2023-08-22 16:13 ` Thomas Huth [this message]
2023-08-22 16:31 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b311bb8e-d2c0-ced9-b5d3-05558abaa800@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).