public inbox for linux-crypto@vger.kernel.org
 help / color / mirror / Atom feed
From: Alejandro Colomar <alx@kernel.org>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Lucas Segarra Fernandez <lucas.segarra.fernandez@intel.com>,
	herbert@gondor.apana.org.au, linux-kernel@vger.kernel.org,
	linux-crypto@vger.kernel.org, qat-linux@intel.com,
	andriy.shevchenko@intel.com,
	Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
	Kees Cook <keescook@chromium.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH 2/4] linux/array_size.h: Add ARRAY_SIZE_OF_FIELD()
Date: Fri, 18 Aug 2023 00:03:09 +0200	[thread overview]
Message-ID: <57a30a95-b63c-7ad4-070f-db70262b6b7c@kernel.org> (raw)
In-Reply-To: <CAHp75VdZiLbE07h3Ei6OmTNFKJ69ksKMRk1EYOjSCxveR+JFCA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2107 bytes --]

Hello Andy,

On 2023-08-17 23:30, Andy Shevchenko wrote:
> On Thu, Aug 17, 2023 at 11:34 PM Alejandro Colomar <alx@kernel.org> wrote:
>> On 2023-08-17 16:33, Lucas Segarra Fernandez wrote:
> 
> ...
> 
>> Some comment about the name:
>>
>> ARRAY_SIZE() is rather ambiguous, as there's array_size()[1], which means the
>> number of bytes needed to represent the array.  I suggest a name based on
>>
>> -  _Lengthof()  It has been proposed to ISO C to get the number of elements
>>                 of an array:
>>                 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2529.pdf>.
>>
>> -  sizeof_field()  The kernel macro for the size of a struct member
>>
>> So, how about lengthof_field()?
> 
> TBH I do not understand the motivation of making this kind of
> confusion and inconsistency.


> Are you suggesting renaming ARRAY_SIZE()
> to begin with?

No.  ARRAY_SIZE is a very old and known API.  It is array_size() that is
to be blamed, due to having a confusing name.

What I suggest is not reusing the root of the name of ARRAY_SIZE(), which
since the addition of array_size() may be less unambiguous (IMHO).

So, instead of ARRAY_SIZE_*(), which is derived from ARRAY_SIZE(), maybe
it would be more unambiguous to use the _Lengthof() name as a root, since
nobody has messed with it so far.

My suggestion is to keep ARRAY_SIZE() with its old name, but use
lengthof_field() for this struct variant of it.  It's also a shorter name,
which will make for shorter lines.

b19d57d0f3cc ("overflow.h: Add flex_array_size() helper")
	- (Mon Jun 8 20:22:33 2020 -0500)
610b15c50e86 ("overflow.h: Add allocation size calculation helpers")
	- (Mon May 7 16:47:02 2018 -0700)

Nevertheless, it was just a minor suggestion, and if array_size() was
seen as a good enough name, it wouldn't be as confusing as it seems to
me.  If you find them to be fine, go ahead.

Cheers,
Alex

> If so, it's definitely out of the scope of this series.
> 

-- 
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2023-08-17 22:06 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-17 14:33 [PATCH 0/4] Add debugfs pm_status for qat driver Lucas Segarra Fernandez
2023-08-17 14:33 ` [PATCH 1/4] linux/array_size.h: Move ARRAY_SIZE(arr) to a separate header Lucas Segarra Fernandez
2023-08-17 20:24   ` Alejandro Colomar
2023-08-17 14:33 ` [PATCH 2/4] linux/array_size.h: Add ARRAY_SIZE_OF_FIELD() Lucas Segarra Fernandez
2023-08-17 20:34   ` Alejandro Colomar
2023-08-17 21:30     ` Andy Shevchenko
2023-08-17 22:03       ` Alejandro Colomar [this message]
2023-08-17 14:33 ` [PATCH 3/4] crypto: qat - refactor included headers Lucas Segarra Fernandez
2023-08-17 14:33 ` [PATCH 4/4] crypto: qat - add pm_status debugfs file Lucas Segarra Fernandez
2023-08-18  5:28   ` Herbert Xu
2023-08-18  8:46     ` Andy Shevchenko
2023-08-18  8:51       ` Herbert Xu
2023-08-20 19:52       ` [PATCH] linux/container_of.h: Add memberof() Alejandro Colomar
2023-08-21 11:18         ` Andy Shevchenko
2023-08-21 11:23           ` Alejandro Colomar

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=57a30a95-b63c-7ad4-070f-db70262b6b7c@kernel.org \
    --to=alx@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=giovanni.cabiddu@intel.com \
    --cc=gustavoars@kernel.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=keescook@chromium.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucas.segarra.fernandez@intel.com \
    --cc=qat-linux@intel.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