All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] clang-format: Fix formatting of guard()
@ 2026-07-08 10:57 Mickaël Salaün
  2026-07-08 11:06 ` Miguel Ojeda
  2026-07-08 15:48 ` Bart Van Assche
  0 siblings, 2 replies; 9+ messages in thread
From: Mickaël Salaün @ 2026-07-08 10:57 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Mickaël Salaün, linux-kernel, Nathan Chancellor,
	Andrew Morton, Bart Van Assche, Günther Noack, Ingo Molnar,
	Peter Zijlstra

The previous fix was overzealous and included guard() along with
scoped_guard(), but only the later takes curly braces.

The original fix introduced this issue:
-       guard(rcu)();
+       guard(rcu)
+               ();

This is especially visible with security/landlock/*.[ch] which is fully
formatted with clang-format.

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Fixes: 99df2a8eba34 ("clang-format: fix formatting of guard() and scoped_guard() statements")
Closes: https://lore.kernel.org/r/20260702.Eibibi4the9j@digikod.net
Signed-off-by: Mickaël Salaün <mic@digikod.net>
---
 .clang-format | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.clang-format b/.clang-format
index 6a3de86ab27a..14b44703e0a9 100644
--- a/.clang-format
+++ b/.clang-format
@@ -481,7 +481,6 @@ ForEachMacros:
   - 'genradix_for_each'
   - 'genradix_for_each_from'
   - 'genradix_for_each_reverse'
-  - 'guard'
   - 'hash_for_each'
   - 'hash_for_each_possible'
   - 'hash_for_each_possible_rcu'
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 10:57 [PATCH v1] clang-format: Fix formatting of guard() Mickaël Salaün
@ 2026-07-08 11:06 ` Miguel Ojeda
  2026-07-08 11:10   ` Mickaël Salaün
  2026-07-08 15:48 ` Bart Van Assche
  1 sibling, 1 reply; 9+ messages in thread
From: Miguel Ojeda @ 2026-07-08 11:06 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 8, 2026 at 12:57 PM Mickaël Salaün <mic@digikod.net> wrote:
>
> The previous fix was overzealous and included guard() along with
> scoped_guard(), but only the later takes curly braces.
>
> The original fix introduced this issue:
> -       guard(rcu)();
> +       guard(rcu)
> +               ();
>
> This is especially visible with security/landlock/*.[ch] which is fully
> formatted with clang-format.

This one would go away on its own if one runs the command above from
where the list is meant to be generated -- but `scoped_guard()` would
be also removed.

I guess I can just have a section of explicit ones that come from
outside the line.

I can pick this one through `clang-format` and take the chance to give
an update to the list.

Thanks!

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 11:06 ` Miguel Ojeda
@ 2026-07-08 11:10   ` Mickaël Salaün
  2026-07-08 11:11     ` Miguel Ojeda
  0 siblings, 1 reply; 9+ messages in thread
From: Mickaël Salaün @ 2026-07-08 11:10 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 08, 2026 at 01:06:12PM +0200, Miguel Ojeda wrote:
> On Wed, Jul 8, 2026 at 12:57 PM Mickaël Salaün <mic@digikod.net> wrote:
> >
> > The previous fix was overzealous and included guard() along with
> > scoped_guard(), but only the later takes curly braces.
> >
> > The original fix introduced this issue:
> > -       guard(rcu)();
> > +       guard(rcu)
> > +               ();
> >
> > This is especially visible with security/landlock/*.[ch] which is fully
> > formatted with clang-format.
> 
> This one would go away on its own if one runs the command above from
> where the list is meant to be generated -- but `scoped_guard()` would
> be also removed.

What do you mean?  Running clang-format -i security/landlock/*.[ch] does
some changes.

> 
> I guess I can just have a section of explicit ones that come from
> outside the line.
> 
> I can pick this one through `clang-format` and take the chance to give
> an update to the list.

Yes please.

> 
> Thanks!
> 
> Cheers,
> Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 11:10   ` Mickaël Salaün
@ 2026-07-08 11:11     ` Miguel Ojeda
  2026-07-08 11:20       ` Mickaël Salaün
  0 siblings, 1 reply; 9+ messages in thread
From: Miguel Ojeda @ 2026-07-08 11:11 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 8, 2026 at 1:10 PM Mickaël Salaün <mic@digikod.net> wrote:
>
> What do you mean?  Running clang-format -i security/landlock/*.[ch] does
> some changes.

I mean the command on the `.clang-format` file:

  # Taken from:
  #   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*('
include/ tools/ \
  #   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
  #   | LC_ALL=C sort -u

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 11:11     ` Miguel Ojeda
@ 2026-07-08 11:20       ` Mickaël Salaün
  2026-07-08 11:31         ` Miguel Ojeda
  0 siblings, 1 reply; 9+ messages in thread
From: Mickaël Salaün @ 2026-07-08 11:20 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 08, 2026 at 01:11:31PM +0200, Miguel Ojeda wrote:
> On Wed, Jul 8, 2026 at 1:10 PM Mickaël Salaün <mic@digikod.net> wrote:
> >
> > What do you mean?  Running clang-format -i security/landlock/*.[ch] does
> > some changes.
> 
> I mean the command on the `.clang-format` file:
> 
>   # Taken from:
>   #   git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*('
> include/ tools/ \
>   #   | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$,  - '\1'," \
>   #   | LC_ALL=C sort -u

Ok, so the guard/scoped_guard changes will disappear once you refreshed
the .clang-format file.  This means that I should not apply the Landlock
changes [1] right?

[1] https://lore.kernel.org/all/20260708110635.2083515-1-mic@digikod.net/

Do you plan to send this file update with a following v7.2-rc?

> 
> Cheers,
> Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 11:20       ` Mickaël Salaün
@ 2026-07-08 11:31         ` Miguel Ojeda
  2026-07-08 12:34           ` Mickaël Salaün
  0 siblings, 1 reply; 9+ messages in thread
From: Miguel Ojeda @ 2026-07-08 11:31 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 8, 2026 at 1:20 PM Mickaël Salaün <mic@digikod.net> wrote:
>
> Ok, so the guard/scoped_guard changes will disappear once you refreshed
> the .clang-format file.  This means that I should not apply the Landlock
> changes [1] right?

It would disappear, but that is why I said that we could have a
section of the list that is for explicitly-added entries, where we
could add `scoped_guard` back.

So we could 1) apply your patch, 2) have a patch to add a new section
of the list with the `scoped_guard` entry and a comment, 3) update the
main list, keeping that new section below or above.

(If you want to send that series, please feel free, of course!)

Does that clarify?

Having said that, `clang-format` is not enforced (unlike `rustfmt`),
so you could apply your patch (or not) independently.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 11:31         ` Miguel Ojeda
@ 2026-07-08 12:34           ` Mickaël Salaün
  2026-07-08 12:49             ` Miguel Ojeda
  0 siblings, 1 reply; 9+ messages in thread
From: Mickaël Salaün @ 2026-07-08 12:34 UTC (permalink / raw)
  To: Miguel Ojeda
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 08, 2026 at 01:31:47PM +0200, Miguel Ojeda wrote:
> On Wed, Jul 8, 2026 at 1:20 PM Mickaël Salaün <mic@digikod.net> wrote:
> >
> > Ok, so the guard/scoped_guard changes will disappear once you refreshed
> > the .clang-format file.  This means that I should not apply the Landlock
> > changes [1] right?
> 
> It would disappear, but that is why I said that we could have a
> section of the list that is for explicitly-added entries, where we
> could add `scoped_guard` back.
> 
> So we could 1) apply your patch, 2) have a patch to add a new section
> of the list with the `scoped_guard` entry and a comment, 3) update the
> main list, keeping that new section below or above.

OK, that makes sense. :)

> 
> (If you want to send that series, please feel free, of course!)

I guess parts 2 and 3 should probably be send for v7.13 (it's a big
patch) whereas part 1 in 7.12-rcX, so I'll let you handle that properly.

> 
> Does that clarify?

Yes, thanks.  I'll keep the Landlock-specific patch I sent.

> 
> Having said that, `clang-format` is not enforced (unlike `rustfmt`),
> so you could apply your patch (or not) independently.

Yes, but I enforce it for Landlock, which helps a lot:
- security/landlock/
- include/uapi/linux/landlock.h
- tools/testing/selftests/landlock/
- samples/landlock/

Regards,
 Mickaël

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 12:34           ` Mickaël Salaün
@ 2026-07-08 12:49             ` Miguel Ojeda
  0 siblings, 0 replies; 9+ messages in thread
From: Miguel Ojeda @ 2026-07-08 12:49 UTC (permalink / raw)
  To: Mickaël Salaün
  Cc: Miguel Ojeda, linux-kernel, Nathan Chancellor, Andrew Morton,
	Bart Van Assche, Günther Noack, Ingo Molnar, Peter Zijlstra

On Wed, Jul 8, 2026 at 2:34 PM Mickaël Salaün <mic@digikod.net> wrote:
>
> I guess parts 2 and 3 should probably be send for v7.13 (it's a big
> patch) whereas part 1 in 7.12-rcX, so I'll let you handle that properly.

Sometimes I sent these PRs to Linus in -rcs, to catch new code, so it
should be fine, I can do it either way.

> Yes, thanks.  I'll keep the Landlock-specific patch I sent.

Sounds good.

> Yes, but I enforce it for Landlock, which helps a lot:

Yeah, that is very good, and I am very glad to see it is useful for
you and that you could get to enforcement.

What I meant is that it cannot really be "truly enforced" across
trees, especially if the config keeps changing and so on; unlike
`rustfmt`, where one is not supposed to push anything to linux-next
that doesn't pass.

I mean, I would love if we could, but it is a very long-term thing.
Over time, my hope is that more subsystems start enforcing it on their
own and so on.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v1] clang-format: Fix formatting of guard()
  2026-07-08 10:57 [PATCH v1] clang-format: Fix formatting of guard() Mickaël Salaün
  2026-07-08 11:06 ` Miguel Ojeda
@ 2026-07-08 15:48 ` Bart Van Assche
  1 sibling, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2026-07-08 15:48 UTC (permalink / raw)
  To: Mickaël Salaün, Miguel Ojeda
  Cc: linux-kernel, Nathan Chancellor, Andrew Morton,
	Günther Noack, Ingo Molnar, Peter Zijlstra

On 7/8/26 3:57 AM, Mickaël Salaün wrote:
> The previous fix was overzealous and included guard() along with
> scoped_guard(), but only the later takes curly braces.
> 
> The original fix introduced this issue:
> -       guard(rcu)();
> +       guard(rcu)
> +               ();
Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-07-08 15:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-08 10:57 [PATCH v1] clang-format: Fix formatting of guard() Mickaël Salaün
2026-07-08 11:06 ` Miguel Ojeda
2026-07-08 11:10   ` Mickaël Salaün
2026-07-08 11:11     ` Miguel Ojeda
2026-07-08 11:20       ` Mickaël Salaün
2026-07-08 11:31         ` Miguel Ojeda
2026-07-08 12:34           ` Mickaël Salaün
2026-07-08 12:49             ` Miguel Ojeda
2026-07-08 15:48 ` Bart Van Assche

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.