From: Bagas Sanjaya <bagasdotme@gmail.com>
To: Martin Fernandez <martin.fernandez@eclypsium.com>
Cc: linux-doc@vger.kernel.org, dwaipayanray1@gmail.com,
lukas.bulwahn@gmail.com, joe@perches.com
Subject: Re: [PATCH v3] doc/checkpatch: Add description to MACRO_ARG_REUSE
Date: Wed, 6 Jul 2022 14:30:29 +0700 [thread overview]
Message-ID: <YsU6Fc0o0g6DHZ4W@debian.me> (raw)
In-Reply-To: <20220704225757.1811311-1-martin.fernandez@eclypsium.com>
On Mon, Jul 04, 2022 at 07:57:57PM -0300, Martin Fernandez wrote:
> + **ARG_REUSE**
> + Using the same argument multiple times in the macro definition
> + would lead to unwanted side-effects.
> +
> + For example, given a `min` macro defined like::
> +
> + #define min(x, y) ((x) < (y) ? (x) : (y))
> +
> + If you call it with `min(foo(x), 0)`, it would expand to::
> +
> + foo(x) < 0 ? foo(x) : 0
> +
Nit: literal blocks are indented three spaces relative to surrounding
paragraph.
> + If `foo` has side-effects or it's an expensive calculation the
> + results might not be what the user intended.
> +
> + For a workaround the idea is to define local variables to hold the
> + macro's arguments. Checkout the actual implementation of `min` in
> + include/linux/minmax.h for the full implementation of the
> + workaround.
> +
For inline code, the correct syntax is ``some text``. However, by
convention here, the backquotes aren't used where these would be
appropriate, like variable and function names.
For the last paragraph, better say "The workaround is to define local
variables to hold macro arguments. See the min macro in
include/linux/minmax.h for example.".
--
An old man doll... just what I always wanted! - Clara
next prev parent reply other threads:[~2022-07-06 7:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-04 22:57 [PATCH v3] doc/checkpatch: Add description to MACRO_ARG_REUSE Martin Fernandez
2022-07-06 7:30 ` Bagas Sanjaya [this message]
2022-07-06 13:19 ` Martin Fernandez
2022-07-06 14:03 ` Akira Yokosawa
2022-07-06 14:07 ` Martin Fernandez
2022-07-06 11:29 ` Lukas Bulwahn
2022-07-06 13:26 ` Martin Fernandez
2022-07-06 14:21 ` Lukas Bulwahn
2022-07-06 17:19 ` Martin Fernandez
2022-07-06 15:09 ` Akira Yokosawa
2022-07-06 17:24 ` Martin Fernandez
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=YsU6Fc0o0g6DHZ4W@debian.me \
--to=bagasdotme@gmail.com \
--cc=dwaipayanray1@gmail.com \
--cc=joe@perches.com \
--cc=linux-doc@vger.kernel.org \
--cc=lukas.bulwahn@gmail.com \
--cc=martin.fernandez@eclypsium.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).