linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Christoph Hellwig <hch@infradead.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org
Subject: Re: [PATCH v4][next] xfs: Replace one-element arrays with flexible-array members
Date: Mon, 12 Apr 2021 10:36:51 -0500	[thread overview]
Message-ID: <63078523-8a57-36f4-228b-1594f0e3b025@embeddedor.com> (raw)
In-Reply-To: <20210412152906.GA1075717@infradead.org>



On 4/12/21 10:29, Christoph Hellwig wrote:
>> Below are the results of running xfstests for "all" with the following
>> configuration in local.config:
> 
> ...
> 
>> Other tests might need to be run in order to verify everything is working
>> as expected. For such tests, the intervention of the maintainers might be
>> needed.
> 
> This is a little weird for a commit log.  If you want to show results
> this would be something that goes into a cover letter.
> 
>> +/*
>> + * Calculates the size of structure xfs_efi_log_format followed by an
>> + * array of n number of efi_extents elements.
>> + */
>> +static inline size_t
>> +sizeof_efi_log_format(size_t n)
>> +{
>> +	return struct_size((struct xfs_efi_log_format *)0, efi_extents, n);
> 
> These helpers are completely silly.  Just keep the existing open code
> version using sizeof with the one-off removed.

This was proposed by Darrick[1]. However, I'm curious, why do you think
they are "completely silly"?

> 
>> -					(sizeof(struct xfs_efd_log_item) +
>> -					(XFS_EFD_MAX_FAST_EXTENTS - 1) *
>> -					sizeof(struct xfs_extent)),
>> -					0, 0, NULL);
>> +					 struct_size((struct xfs_efd_log_item *)0,
>> +					 efd_format.efd_extents,
>> +					 XFS_EFD_MAX_FAST_EXTENTS),
>> +					 0, 0, NULL);
>>  	if (!xfs_efd_zone)
>>  		goto out_destroy_buf_item_zone;
>>  
>>  	xfs_efi_zone = kmem_cache_create("xfs_efi_item",
>> -					 (sizeof(struct xfs_efi_log_item) +
>> -					 (XFS_EFI_MAX_FAST_EXTENTS - 1) *
>> -					 sizeof(struct xfs_extent)),
>> +					 struct_size((struct xfs_efi_log_item *)0,
>> +					 efi_format.efi_extents,
>> +					 XFS_EFI_MAX_FAST_EXTENTS),
> 
> Same here.  And this obsfucated version also adds completely pointless
> overly long lines while making the code unreadable.

This could actually use one of the inline helpers you think are silly. :)

Thanks
--
Gustavo

[1] https://lore.kernel.org/lkml/20210311031745.GT3419940@magnolia/

  reply	other threads:[~2021-04-12 15:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-12 13:56 [PATCH v4][next] xfs: Replace one-element arrays with flexible-array members Gustavo A. R. Silva
2021-04-12 15:29 ` Christoph Hellwig
2021-04-12 15:36   ` Gustavo A. R. Silva [this message]
2021-04-12 15:48   ` Darrick J. Wong
2021-04-12 15:57     ` Gustavo A. R. Silva
2021-04-13 16:53     ` Christoph Hellwig
2021-07-14  9:27       ` Chen, Rong A
2021-07-15  5:33         ` Christoph Hellwig

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=63078523-8a57-36f4-228b-1594f0e3b025@embeddedor.com \
    --to=gustavo@embeddedor.com \
    --cc=djwong@kernel.org \
    --cc=gustavoars@kernel.org \
    --cc=hch@infradead.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.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 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).