clang-format: Fix formatting of guard()
PATCH 1/1 clang-format: Fix formatting of guard()
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.
--- .clang-format | 1 - 1 file changed, 1 deletion(-)
.clang-format +0 -1
@@ -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'
Signature · 1 line
2.54.0
Quoted 11 lines · Mickaël Salaün
The previous fix was overzealous and included
guard()along withscoped_guard(), but only the later takes curly braces.The original fix introduced this issue:
(quoted diff) +2
-1- 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
Quoted 10 lines · Miguel Ojeda
Quoted 9 lines · Mickaël Salaün
The previous fix was overzealous and included
guard()along withscoped_guard(), but only the later takes curly braces.The original fix introduced this issue:
(quoted diff) +2
-1- guard(rcu)(); + guard(rcu) + ();
Quoted 6 lines
Quoted 2 lines
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.
Quoted 6 lines
I guess I can just have a section of explicit ones that come from outside the line.
I can pick this one through
clang-formatand take the chance to give an update to the list.
Yes please.
Quoted 5 lines
Thanks!
Cheers,
Miguel
Quoted 3 lines · Mickaël Salaün
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
Quoted 5 lines · Miguel Ojeda
Quoted 3 lines · Mickaël Salaün
What do you mean? Running clang-format -i security/landlock/*.[ch] does some changes.
Quoted 7 lines
I mean the command on the
.clang-formatfile:# 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/[email protected]/
Do you plan to send this file update with a following v7.2-rc?
Quoted 3 lines
Cheers,
Miguel
Quoted 4 lines · Mickaël Salaün
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
Quoted 6 lines · Miguel Ojeda
Quoted 4 lines · Mickaël Salaün
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?
Quoted 7 lines
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_guardback.So we could 1) apply your patch, 2) have a patch to add a new section of the list with the
scoped_guardentry and a comment, 3) update the main list, keeping that new section below or above.
OK, that makes sense. :)
Quoted 2 lines
(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.
Quoted 2 lines
Does that clarify?
Yes, thanks. I'll keep the Landlock-specific patch I sent.
Quoted 3 lines
Having said that,
clang-formatis not enforced (unlikerustfmt), 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
Quoted 3 lines · Mickaël Salaün
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.
Quoted 1 line
Yes, thanks. I'll keep the Landlock-specific patch I sent.
Sounds good.
Quoted 1 line
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
Hi Miguel,
Could you please sent the PR to Linus and Cc stable@?
Thanks,
Mickaël
Quoted 28 lines · Miguel Ojeda
Quoted 3 lines · Mickaël Salaün
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.
Quoted 1 line
Yes, thanks. I'll keep the Landlock-specific patch I sent.
Sounds good.
Quoted 1 line
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
Quoted 2 lines · Mickaël Salaün
Could you please sent the PR to Linus and Cc stable@?
Yeah, sorry, I will prepare the update on top of -rc1.
Regarding the Cc stable, I am not sure. The formatting is not globally enforced and such a change could break things for others that may be locally enforcing it using whatever list was there in the past.
(Some may even consider the Fixes: tag itself here a stretch depending on how one defines "bug"...)
Cheers,
Miguel
Quoted 9 lines · Miguel Ojeda
Quoted 2 lines · Mickaël Salaün
Could you please sent the PR to Linus and Cc stable@?
Yeah, sorry, I will prepare the update on top of -rc1.
Regarding the Cc stable, I am not sure. The formatting is not globally enforced and such a change could break things for others that may be locally enforcing it using whatever list was there in the past.
Well, the bug which is fixed by this patch does "break" the local enforcement for Landlock code. This is how I found it and why I reported it.
Quoted 6 lines
(Some may even consider the Fixes: tag itself here a stretch depending on how one defines "bug"...)
Cheers,
Miguel
Review
Quoted 7 lines · Mickaël Salaün
The previous fix was overzealous and included
guard()along withscoped_guard(), but only the later takes curly braces.The original fix introduced this issue:
(quoted diff) +2
-1- guard(rcu)(); + guard(rcu) + ();