From: Thomas Huth <thuth@redhat.com>
To: "Alex Bennée" <alex.bennee@linaro.org>, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] CODING_STYLE.rst: flesh out our naming conventions.
Date: Sun, 23 Aug 2020 10:20:35 +0200 [thread overview]
Message-ID: <2415571e-bfcd-e870-7994-e249a18fa726@redhat.com> (raw)
In-Reply-To: <20200810105147.10670-1-alex.bennee@linaro.org>
On 10/08/2020 12.51, Alex Bennée wrote:
> Mention a few of the more common naming conventions we follow in the
> code base including common variable names and function prefix and
> suffix examples.
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>
> ---
> v2
> - punctuation fixes suggested by Cornelia
> - re-worded section on qemu_ prefix
> - expanded on _locked suffix
> ---
> CODING_STYLE.rst | 30 ++++++++++++++++++++++++++++--
> 1 file changed, 28 insertions(+), 2 deletions(-)
>
> diff --git a/CODING_STYLE.rst b/CODING_STYLE.rst
> index 427699e0e42..e7ae44aed7f 100644
> --- a/CODING_STYLE.rst
> +++ b/CODING_STYLE.rst
> @@ -109,8 +109,34 @@ names are lower_case_with_underscores_ending_with_a_t, like the POSIX
> uint64_t and family. Note that this last convention contradicts POSIX
> and is therefore likely to be changed.
>
> -When wrapping standard library functions, use the prefix ``qemu_`` to alert
> -readers that they are seeing a wrapped version; otherwise avoid this prefix.
> +Variable Naming Conventions
> +---------------------------
> +
> +A number of short naming conventions exist for variables that use
> +common QEMU types. For example, the architecture independent CPUState
> +this is often held as a ``cs`` pointer variable, whereas the concrete
> +CPUArchState us usually held in a pointer called ``env``.
> +
> +Likewise, in device emulation code the common DeviceState is usually
> +called ``dev`` with the actual status structure often uses the terse
> +``s`` or maybe ``foodev``.
Please let's not recommend single-letter variables like 's' here. This
is a really bad idea, since they are hard to "grep" and can be confused
quite easily. I think it would be best to simply drop that last part of
the sentence (starting with "with the actual...").
Thomas
prev parent reply other threads:[~2020-08-23 8:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-10 10:51 [PATCH v2] CODING_STYLE.rst: flesh out our naming conventions Alex Bennée
2020-08-11 7:08 ` Cornelia Huck
2020-08-11 11:48 ` Alex Bennée
2020-08-11 11:56 ` Cornelia Huck
2020-08-11 15:55 ` Philippe Mathieu-Daudé
2020-08-11 16:06 ` Cornelia Huck
2020-08-23 8:20 ` Thomas Huth [this message]
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=2415571e-bfcd-e870-7994-e249a18fa726@redhat.com \
--to=thuth@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.