Nick Desaulniers
2020-Oct-19 19:42 UTC
[Nouveau] [RFC] treewide: cleanup unreachable breaks
On Sat, Oct 17, 2020 at 10:43 PM Greg KH <gregkh at linuxfoundation.org> wrote:> > On Sat, Oct 17, 2020 at 09:09:28AM -0700, trix at redhat.com wrote: > > From: Tom Rix <trix at redhat.com> > > > > This is a upcoming change to clean up a new warning treewide. > > I am wondering if the change could be one mega patch (see below) or > > normal patch per file about 100 patches or somewhere half way by collecting > > early acks. > > Please break it up into one-patch-per-subsystem, like normal, and get it > merged that way. > > Sending us a patch, without even a diffstat to review, isn't going to > get you very far...Tom, If you're able to automate this cleanup, I suggest checking in a script that can be run on a directory. Then for each subsystem you can say in your commit "I ran scripts/fix_whatever.py on this subdir." Then others can help you drive the tree wide cleanup. Then we can enable -Wunreachable-code-break either by default, or W=2 right now might be a good idea. Ah, George (gbiv@, cc'ed), did an analysis recently of `-Wunreachable-code-loop-increment`, `-Wunreachable-code-break`, and `-Wunreachable-code-return` for Android userspace. From the review: ``` Spoilers: of these, it seems useful to turn on -Wunreachable-code-loop-increment and -Wunreachable-code-return by default for Android ... While these conventions about always having break arguably became obsolete when we enabled -Wfallthrough, my sample turned up zero potential bugs caught by this warning, and we'd need to put a lot of effort into getting a clean tree. So this warning doesn't seem to be worth it. ``` Looks like there's an order of magnitude of `-Wunreachable-code-break` than the other two. We probably should add all 3 to W=2 builds (wrapped in cc-option). I've filed https://github.com/ClangBuiltLinux/linux/issues/1180 to follow up on. -- Thanks, ~Nick Desaulniers
Jason Gunthorpe
2020-Oct-19 23:05 UTC
[Nouveau] [RFC] treewide: cleanup unreachable breaks
On Mon, Oct 19, 2020 at 12:42:15PM -0700, Nick Desaulniers wrote:> On Sat, Oct 17, 2020 at 10:43 PM Greg KH <gregkh at linuxfoundation.org> wrote: > > > > On Sat, Oct 17, 2020 at 09:09:28AM -0700, trix at redhat.com wrote: > > > From: Tom Rix <trix at redhat.com> > > > > > > This is a upcoming change to clean up a new warning treewide. > > > I am wondering if the change could be one mega patch (see below) or > > > normal patch per file about 100 patches or somewhere half way by collecting > > > early acks. > > > > Please break it up into one-patch-per-subsystem, like normal, and get it > > merged that way. > > > > Sending us a patch, without even a diffstat to review, isn't going to > > get you very far... > > Tom, > If you're able to automate this cleanup, I suggest checking in a > script that can be run on a directory. Then for each subsystem you > can say in your commit "I ran scripts/fix_whatever.py on this subdir." > Then others can help you drive the tree wide cleanup. Then we can > enable -Wunreachable-code-break either by default, or W=2 right now > might be a good idea.I remember using clang-modernize in the past to fix issues very similar to this, if clang machinery can generate the warning, can't something like clang-tidy directly generate the patch? You can send me a patch for drivers/infiniband/* as well Thanks, Jason
John Haxby
2020-Oct-20 08:47 UTC
[Nouveau] [Ocfs2-devel] [RFC] treewide: cleanup unreachable breaks
> On 19 Oct 2020, at 20:42, Nick Desaulniers <ndesaulniers at google.com> wrote: > > We probably should add all 3 to W=2 builds (wrapped in cc-option). > I've filed https://github.com/ClangBuiltLinux/linux/issues/1180 to > follow up on.It looks as though the URL mangling has been fixed. If anyone sees that specific URL mangled, please let me know. jch -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 268 bytes Desc: Message signed with OpenPGP URL: <https://lists.freedesktop.org/archives/nouveau/attachments/20201020/094f0e00/attachment-0001.sig>
On 10/19/20 12:42 PM, Nick Desaulniers wrote:> On Sat, Oct 17, 2020 at 10:43 PM Greg KH <gregkh at linuxfoundation.org> wrote: >> On Sat, Oct 17, 2020 at 09:09:28AM -0700, trix at redhat.com wrote: >>> From: Tom Rix <trix at redhat.com> >>> >>> This is a upcoming change to clean up a new warning treewide. >>> I am wondering if the change could be one mega patch (see below) or >>> normal patch per file about 100 patches or somewhere half way by collecting >>> early acks. >> Please break it up into one-patch-per-subsystem, like normal, and get it >> merged that way. >> >> Sending us a patch, without even a diffstat to review, isn't going to >> get you very far... > Tom, > If you're able to automate this cleanup, I suggest checking in a > script that can be run on a directory. Then for each subsystem you > can say in your commit "I ran scripts/fix_whatever.py on this subdir." > Then others can help you drive the tree wide cleanup. Then we can > enable -Wunreachable-code-break either by default, or W=2 right now > might be a good idea.I should have waited for Joe Perches's fixer addition to checkpatch :) The easy fixes I did only cover about 1/2 of the problems. Remaining are mostly nested switches, which from a complexity standpoint is bad.> > Ah, George (gbiv@, cc'ed), did an analysis recently of > `-Wunreachable-code-loop-increment`, `-Wunreachable-code-break`, and > `-Wunreachable-code-return` for Android userspace. From the review: > ``` > Spoilers: of these, it seems useful to turn on > -Wunreachable-code-loop-increment and -Wunreachable-code-return by > default for AndroidIn my simple add-a-cflag bot, i see there are about 250 issues for -Wunreachable-code-return. I'll see about doing this one next.> ... > While these conventions about always having break arguably became > obsolete when we enabled -Wfallthrough, my sample turned up zero > potential bugs caught by this warning, and we'd need to put a lot of > effort into getting a clean tree. So this warning doesn't seem to be > worth it. > ``` > Looks like there's an order of magnitude of `-Wunreachable-code-break` > than the other two. > > We probably should add all 3 to W=2 builds (wrapped in cc-option). > I've filed https://github.com/ClangBuiltLinux/linux/issues/1180 to > follow up on.Yes, i think think these should be added. Tom
On 10/19/20 4:05 PM, Jason Gunthorpe wrote:> On Mon, Oct 19, 2020 at 12:42:15PM -0700, Nick Desaulniers wrote: >> On Sat, Oct 17, 2020 at 10:43 PM Greg KH <gregkh at linuxfoundation.org> wrote: >>> On Sat, Oct 17, 2020 at 09:09:28AM -0700, trix at redhat.com wrote: >>>> From: Tom Rix <trix at redhat.com> >>>> >>>> This is a upcoming change to clean up a new warning treewide. >>>> I am wondering if the change could be one mega patch (see below) or >>>> normal patch per file about 100 patches or somewhere half way by collecting >>>> early acks. >>> Please break it up into one-patch-per-subsystem, like normal, and get it >>> merged that way. >>> >>> Sending us a patch, without even a diffstat to review, isn't going to >>> get you very far... >> Tom, >> If you're able to automate this cleanup, I suggest checking in a >> script that can be run on a directory. Then for each subsystem you >> can say in your commit "I ran scripts/fix_whatever.py on this subdir." >> Then others can help you drive the tree wide cleanup. Then we can >> enable -Wunreachable-code-break either by default, or W=2 right now >> might be a good idea. > I remember using clang-modernize in the past to fix issues very > similar to this, if clang machinery can generate the warning, can't > something like clang-tidy directly generate the patch?Yes clang-tidy and similar are good tools. Sometimes they change too much and your time shifts from editing to analyzing and dropping changes. I am looking at them for auto changing api. When i have something greater than half baked i will post. Tom> > You can send me a patch for drivers/infiniband/* as well > > Thanks, > Jason >
On Mon, 2020-10-19 at 12:42 -0700, Nick Desaulniers wrote:> On Sat, Oct 17, 2020 at 10:43 PM Greg KH <gregkh at linuxfoundation.org> wrote: > > On Sat, Oct 17, 2020 at 09:09:28AM -0700, trix at redhat.com wrote: > > > From: Tom Rix <trix at redhat.com> > > > > > > This is a upcoming change to clean up a new warning treewide. > > > I am wondering if the change could be one mega patch (see below) or > > > normal patch per file about 100 patches or somewhere half way by collecting > > > early acks. > > > > Please break it up into one-patch-per-subsystem, like normal, and get it > > merged that way. > > > > Sending us a patch, without even a diffstat to review, isn't going to > > get you very far... > > Tom, > If you're able to automate this cleanup, I suggest checking in a > script that can be run on a directory. Then for each subsystem you > can say in your commit "I ran scripts/fix_whatever.py on this subdir." > Then others can help you drive the tree wide cleanup. Then we can > enable -Wunreachable-code-break either by default, or W=2 right now > might be a good idea. > > Ah, George (gbiv@, cc'ed), did an analysis recently of > `-Wunreachable-code-loop-increment`, `-Wunreachable-code-break`, and > `-Wunreachable-code-return` for Android userspace. From the review: > ``` > Spoilers: of these, it seems useful to turn on > -Wunreachable-code-loop-increment and -Wunreachable-code-return by > default for Android > ... > While these conventions about always having break arguably became > obsolete when we enabled -Wfallthrough, my sample turned up zero > potential bugs caught by this warning, and we'd need to put a lot of > effort into getting a clean tree. So this warning doesn't seem to be > worth it. > ``` > Looks like there's an order of magnitude of `-Wunreachable-code-break` > than the other two. > > We probably should add all 3 to W=2 builds (wrapped in cc-option). > I've filed https://github.com/ClangBuiltLinux/linux/issues/1180 to > follow up on.I suggest using W=1 as people that are doing cleanups generally use that and not W=123 or any other style. Every other use of W= is still quite noisy and these code warnings are relatively trivially to fix up.