All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Fernandez <martin.fernandez@eclypsium.com>
To: Akira Yokosawa <akiyks@gmail.com>
Cc: dwaipayanray1@gmail.com, joe@perches.com,
	linux-doc@vger.kernel.org, lukas.bulwahn@gmail.com
Subject: Re: [PATCH v3] doc/checkpatch: Add description to MACRO_ARG_REUSE
Date: Wed, 6 Jul 2022 14:24:38 -0300	[thread overview]
Message-ID: <CAKgze5aZ8BZ99+ctp2Q4FMj6q5_vx9J+oUtJpwYn6dUb_E13Aw@mail.gmail.com> (raw)
In-Reply-To: <554d0394-321c-c206-1774-7d33360b1553@gmail.com>

On 7/6/22, Akira Yokosawa <akiyks@gmail.com> wrote:
> Hi,
> Minor nit on reST syntax.
>
> On Mon,  4 Jul 2022 19:57:57 -0300, Martin Fernandez wrote:
>> Add a description, an example and a possible workaround to the
>> MACRO_ARG_REUSE check.
>>
>> Signed-off-by: Martin Fernandez <martin.fernandez@eclypsium.com>
>> Acked-by: Dwaipayan Ray <dwaipayanray1@gmail.com>
>> ---
>>  Documentation/dev-tools/checkpatch.rst | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/Documentation/dev-tools/checkpatch.rst
>> b/Documentation/dev-tools/checkpatch.rst
>> index b52452bc2963..86545c65cf7b 100644
>> --- a/Documentation/dev-tools/checkpatch.rst
>> +++ b/Documentation/dev-tools/checkpatch.rst
>> @@ -759,6 +759,26 @@ Indentation and Line Breaks
>>  Macros, Attributes and Symbols
>>  ------------------------------
>>
>> +  **ARG_REUSE**> +    Using the same argument multiple times in the macro
>> definition
>> +    would lead to unwanted side-effects.
>
> You don't need manual emphasis as above, as this list is already
> in the form of so-called "Definition Lists" [1, 2].
>
> [1]:
> https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#definition-lists
> [2]:
> https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html#lists-and-quote-like-blocks

Thank you for the references.

> Defined terms will be automatically emphasized by Sphinx and
> should look in bold face in the generated HTML/PDF.
> (Style of emphasis might be customized by configuration.)
>
> It looks like there exists other similar patterns in this file
> (or might as well be in other related .rst files).  I'd suggest
> removing those manual emphases in a follow-up patch.
>
> This is only a weak suggestion, and there is no urgency.
> Of course, if you have a reason to do the manual emphases,
> there is no need to change.

That's interesting. Didn't really know that. I just saw this unknown
warning for me and since there were no documentation about it I
decided to quickly add it using the rest of the document as a
template. I agree that that's not a very good approach but it was very
quick :)

I'll consider checking the syntax of the whole document for further
patches, thank you for the suggestion.

>         Thanks, Akira
>
>> +
>> +    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
>> +
>> +    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.
>> +
>>    **ARRAY_SIZE**
>>      The ARRAY_SIZE(foo) macro should be preferred over
>>      sizeof(foo)/sizeof(foo[0]) for finding number of elements in an
>> --
>> 2.30.2
>

      reply	other threads:[~2022-07-06 17:24 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
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 [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=CAKgze5aZ8BZ99+ctp2Q4FMj6q5_vx9J+oUtJpwYn6dUb_E13Aw@mail.gmail.com \
    --to=martin.fernandez@eclypsium.com \
    --cc=akiyks@gmail.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.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 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.