Re: [PATCH] checkpatch: fix uninitialized var when run with --no-tree

From: Andrew Morton
Date: Tue Nov 08 2016 - 18:10:48 EST


On Fri, 28 Oct 2016 19:36:09 -0700 Brian Norris <computersforpeace@xxxxxxxxx> wrote:

> On Fri, Oct 28, 2016 at 07:26:31PM -0700, Brian Norris wrote:
> > From: Brian Norris <computersforpeace@xxxxxxxxx>
> >
> > If checkpatch.pl gets copied out of the tree, --no-tree shouldn't start
> > complaining:
> >
> > Use of uninitialized value $root in concatenation (.) or string at
> > /path/to/checkpatch.pl line 764.
> >
> > Let's just give the safe answer instead -- don't warn about "obsolete"
> > files.
> >
> > Fixes: 85b0ee18bbf8 ("checkpatch: see if modified files are marked obsolete in MAINTAINERS")
> > Signed-off-by: Brian Norris <computersforpeace@xxxxxxxxx>
> > ---
> > This is a 4.9-rc1 regression
> >
> > scripts/checkpatch.pl | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index a8368d1c4348..c8cd643dbc6f 100755
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -761,6 +761,8 @@ sub seed_camelcase_file {
> > sub is_maintained_obsolete {
> > my ($filename) = @_;
> >
> > + return 0 if (!$tree);
>
> Actually, I'm torn on this. It looks really odd to check for !$tree
> here, but it's the only supported case where $root shouldn't be defined.
> Maybe (!defined $root) is a better test? (Sorry, I did a double-take on
> this after I sent it.)
>
> Both would be equally correct, but I suppose the latter would be
> clearer. I'll send v2.

I already have the below. Good enough?

From: Jerome Forissier <jerome.forissier@xxxxxxxxxx>
Subject: checkpatch: don't try to get maintained status when --no-tree is given

Fixes the following warning:
Use of uninitialized value $root in concatenation (.) or string at /path/to/checkpatch.pl line 764.

Link: http://lkml.kernel.org/r/1476719709-16668-1-git-send-email-jerome.forissier@xxxxxxxxxx
Signed-off-by: Jerome Forissier <jerome.forissier@xxxxxxxxxx>
Acked-by: Joe Perches <joe@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff -puN scripts/checkpatch.pl~checkpatch-dont-try-to-get-maintained-status-when-no-tree-is-given scripts/checkpatch.pl
--- a/scripts/checkpatch.pl~checkpatch-dont-try-to-get-maintained-status-when-no-tree-is-given
+++ a/scripts/checkpatch.pl
@@ -761,7 +761,7 @@ sub seed_camelcase_file {
sub is_maintained_obsolete {
my ($filename) = @_;

- return 0 if (!(-e "$root/scripts/get_maintainer.pl"));
+ return 0 if (!$tree || !(-e "$root/scripts/get_maintainer.pl"));

my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback -f $filename 2>&1`;

_