Linux-bcachefs Archive mirror
 help / color / mirror / Atom feed
From: Kent Overstreet <kent.overstreet@linux.dev>
To: Thorsten Blum <thorsten.blum@toblux.com>
Cc: Brian Foster <bfoster@redhat.com>,
	linux-bcachefs@vger.kernel.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bcachefs: Rename struct field swap to prevent macro naming collision
Date: Sat, 6 Apr 2024 17:38:09 -0400	[thread overview]
Message-ID: <aihoh7frnx5pf2qxlvcntfx4jazdn5m3vnse6q7yqexhqaaul3@luxph6dm5tbz> (raw)
In-Reply-To: <E5B1C1FA-0B85-49ED-8EE6-4F01FBA2AC99@toblux.com>

On Sat, Apr 06, 2024 at 11:21:37PM +0200, Thorsten Blum wrote:
> On 6. Apr 2024, at 20:48, Kent Overstreet <kent.overstreet@linux.dev> wrote:
> > 
> > On Sat, Apr 06, 2024 at 04:19:20PM +0200, Thorsten Blum wrote:
> >> The struct field swap can collide with the swap() macro defined in
> >> linux/minmax.h. Rename the struct field to prevent such collisions.
> > 
> > Same as in lib/sort.c, so what's the actual reason?
> 
> I included <linux/minmax.h> in arch/m68k/include/asm/bitops.h (to use the min()
> macro), but received the following error:
> 
> fs/bcachefs/eytzinger.c: In function ‘do_swap’:
> fs/bcachefs/eytzinger.c:128:69: error: macro "swap" passed 3 arguments, but takes just 2
>   128 |                 ((const struct wrapper *)priv)->swap(a, b, (int)size);
>       |                                                                     ^
> In file included from ./arch/m68k/include/asm/bitops.h:16,
>                  from ./include/linux/bitops.h:68,
>                  from fs/bcachefs/eytzinger.h:5,
>                  from fs/bcachefs/eytzinger.c:3:
> ./include/linux/minmax.h:270: note: macro "swap" defined here
>   270 | #define swap(a, b) \
>       |
> fs/bcachefs/eytzinger.c:128:47: warning: statement with no effect [-Wunused-value]
>   128 |                 ((const struct wrapper *)priv)->swap(a, b, (int)size);
>       |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
> make[4]: *** [scripts/Makefile.build:244: fs/bcachefs/eytzinger.o] Error 1
> make[3]: *** [scripts/Makefile.build:485: fs/bcachefs] Error 2
> 
> I thought about using #undef swap, but renaming it seemed to be the least
> disruptive change. Maybe there's a better solution?

No it's fine, I was just curious - I'll go ahead and apply it

      reply	other threads:[~2024-04-06 21:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-06 14:19 [PATCH] bcachefs: Rename struct field swap to prevent macro naming collision Thorsten Blum
2024-04-06 18:48 ` Kent Overstreet
2024-04-06 21:21   ` Thorsten Blum
2024-04-06 21:38     ` Kent Overstreet [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=aihoh7frnx5pf2qxlvcntfx4jazdn5m3vnse6q7yqexhqaaul3@luxph6dm5tbz \
    --to=kent.overstreet@linux.dev \
    --cc=bfoster@redhat.com \
    --cc=linux-bcachefs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thorsten.blum@toblux.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 read-only IMAP folder(s) and NNTP newsgroup(s).