public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: "Darrick J . Wong" <djwong@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH] xfs: Add const qualifiers
Date: Wed, 14 Dec 2022 11:52:37 +1100	[thread overview]
Message-ID: <20221214005237.GA3600936@dread.disaster.area> (raw)
In-Reply-To: <20221213205446.2998033-1-willy@infradead.org>

On Tue, Dec 13, 2022 at 08:54:45PM +0000, Matthew Wilcox (Oracle) wrote:
> With a container_of() that preserves const, the compiler warns about
> all these places which are currently casting away the const.  For
> the IUL_ITEM() helper, we want to also make it const-preserving,
> and in every other case, we want to just add a const qualifier.

....

> diff --git a/fs/xfs/xfs_iunlink_item.c b/fs/xfs/xfs_iunlink_item.c
> index 43005ce8bd48..ff82a93f8a24 100644
> --- a/fs/xfs/xfs_iunlink_item.c
> +++ b/fs/xfs/xfs_iunlink_item.c
> @@ -20,10 +20,7 @@
>  
>  struct kmem_cache	*xfs_iunlink_cache;
>  
> -static inline struct xfs_iunlink_item *IUL_ITEM(struct xfs_log_item *lip)
> -{
> -	return container_of(lip, struct xfs_iunlink_item, item);
> -}
> +#define IUL_ITEM(lip) container_of(lip, struct xfs_iunlink_item, item)

I think this is somewhat of a step backwards. We moved these log
item type conversions from macros to static inlines to add type
checking so the compiler would catch the type conversion bugs we
found that the macros didn't warn about....

Which makes me ask: why do we even care about const here? What
actual real world problem are you trying to fix with these changes?

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2022-12-14  0:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 20:54 [PATCH] xfs: Add const qualifiers Matthew Wilcox (Oracle)
2022-12-14  0:52 ` Dave Chinner [this message]
2022-12-14 16:54   ` Matthew Wilcox

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=20221214005237.GA3600936@dread.disaster.area \
    --to=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=willy@infradead.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