On 11/22/20 6:56 AM, Matthew Wilcox wrote:
> On Sun, Nov 22, 2020 at 06:46:46AM -0800, Tom Rix wrote:
>> On 11/21/20 7:23 PM, Matthew Wilcox wrote:
>>> On Sat, Nov 21, 2020 at 08:50:58AM -0800, [email protected] wrote:
>>>> The fixer review is
>>>> https://reviews.llvm.org/D91789
>>>>
>>>> A run over allyesconfig for x86_64 finds 62 issues, 5 are false positives.
>>>> The false positives are caused by macros passed to other macros and by
>>>> some macro expansions that did not have an extra semicolon.
>>>>
>>>> This cleans up about 1,000 of the current 10,000 -Wextra-semi-stmt
>>>> warnings in linux-next.
>>> Are any of them not false-positives? It's all very well to enable
>>> stricter warnings, but if they don't fix any bugs, they're just churn.
>>>
>> While enabling additional warnings may be a side effect of this effort
>>
>> the primary goal is to set up a cleaning robot. After that a refactoring robot.
> Why do we need such a thing? Again, it sounds like more churn.
> It's really annoying when I'm working on something important that gets
> derailed by pointless churn. Churn also makes it harder to backport
> patches to earlier kernels.
>
A refactoring example on moving to treewide, consistent use of a new api may help.
Consider
2efc459d06f1630001e3984854848a5647086232
sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output
A new api for printing in the sysfs. How do we use it treewide ?
Done manually, it would be a heroic effort requiring high level maintainers pushing and likely only get partially done.
If a refactoring programatic fixit is done and validated on a one subsystem, it can run on all the subsystems.
The effort is a couple of weeks to write and validate the fixer, hours to run over the tree.
It won't be perfect but will be better than doing it manually.
Tom
On Sun, 2020-11-22 at 08:10 -0800, Tom Rix wrote:
> On 11/22/20 6:56 AM, Matthew Wilcox wrote:
> > On Sun, Nov 22, 2020 at 06:46:46AM -0800, Tom Rix wrote:
> > > On 11/21/20 7:23 PM, Matthew Wilcox wrote:
> > > > On Sat, Nov 21, 2020 at 08:50:58AM -0800, [email protected]
> > > > wrote:
> > > > > The fixer review is
> > > > > https://reviews.llvm.org/D91789
> > > > >
> > > > > A run over allyesconfig for x86_64 finds 62 issues, 5 are
> > > > > false positives. The false positives are caused by macros
> > > > > passed to other macros and by some macro expansions that did
> > > > > not have an extra semicolon.
> > > > >
> > > > > This cleans up about 1,000 of the current 10,000 -Wextra-
> > > > > semi-stmt warnings in linux-next.
> > > > Are any of them not false-positives? It's all very well to
> > > > enable stricter warnings, but if they don't fix any bugs,
> > > > they're just churn.
> > > >
> > > While enabling additional warnings may be a side effect of this
> > > effort
> > >
> > > the primary goal is to set up a cleaning robot. After that a
> > > refactoring robot.
> > Why do we need such a thing? Again, it sounds like more churn.
> > It's really annoying when I'm working on something important that
> > gets derailed by pointless churn. Churn also makes it harder to
> > backport patches to earlier kernels.
> >
> A refactoring example on moving to treewide, consistent use of a new
> api may help.
>
> Consider
>
> 2efc459d06f1630001e3984854848a5647086232
>
> sysfs: Add sysfs_emit and sysfs_emit_at to format sysfs output
>
> A new api for printing in the sysfs. How do we use it treewide ?
>
> Done manually, it would be a heroic effort requiring high level
> maintainers pushing and likely only get partially done.
>
> If a refactoring programatic fixit is done and validated on a one
> subsystem, it can run on all the subsystems.
>
> The effort is a couple of weeks to write and validate the fixer,
> hours to run over the tree.
>
> It won't be perfect but will be better than doing it manually.
Here's a thought: perhaps we don't. sysfs_emit isn't a "new api" its a
minor rewrap of existing best practice. The damage caused by the churn
of forcing its use everywhere would far outweigh any actual benefit
because pretty much every bug in this area has already been caught and
killed by existing tools. We can enforce sysfs_emit going forwards
using tools like checkpatch but there's no benefit and a lot of harm to
be done by trying to churn the entire tree retrofitting it (both in
terms of review time wasted as well as patch series derailed).
James
On Sun, 2020-11-22 at 08:49 -0800, James Bottomley wrote:
> We can enforce sysfs_emit going forwards
> using tools like checkpatch
It's not really possible for checkpatch to find or warn about
sysfs uses of sprintf. checkpatch is really just a trivial
line-by-line parser and it has no concept of code intent.
It just can't warn on every use of the sprintf family.
There are just too many perfectly valid uses.
> but there's no benefit and a lot of harm to
> be done by trying to churn the entire tree
Single uses of sprintf for sysfs is not really any problem.
But likely there are still several possible overrun sprintf/snprintf
paths in sysfs. Some of them are very obscure and unlikely to be
found by a robot as the logic for sysfs buf uses can be fairly twisty.
But provably correct conversions IMO _should_ be done and IMO churn
considerations should generally have less importance.