Skip to content
Snippets Groups Projects
Commit 3735c522 authored by Tamir Duberstein's avatar Tamir Duberstein Committed by Andrew Morton
Browse files

checkpatch: check return of `git_commit_info`

Avoid string concatenation with an undefined variable when a reference to
a missing commit is contained in a `Fixes` tag.

Given this patch:

: From: Tamir Duberstein <tamird@gmail.com>
: Subject: Test patch
: Date: Fri, 25 Oct 2024 19:30:51 -0400
:
: This is a test patch.
:
: Fixes: deadbeef111
: Signed-off-by: Tamir Duberstein <tamird@gmail.com>
: --- /dev/null
: +++ b/new-file
: @@ -0,0 +1 @@
: +Test.

Before:

WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes:  ("commit title")'
WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled?
Use of uninitialized value $cid in concatenation (.) or string at scripts/checkpatch.pl line 3242.

After:

WARNING: Unknown commit id 'deadbeef111', maybe rebased or not pulled?

This patch also reduce duplication slightly.

[akpm@linux-foundation.org: s/12 chars of sha1/12+ chars of sha1/, per Jon]
  Link: https://lkml.kernel.org/r/87o70kt232.fsf@trenco.lwn.net
Link: https://lkml.kernel.org/r/20241204-checkpatch-missing-commit-v1-1-68b34c94944e@gmail.com


Signed-off-by: default avatarTamir Duberstein <tamird@gmail.com>
Cc: Andy Whitcroft <apw@canonical.com>
Cc: Dwaipayan Ray <dwaipayanray1@gmail.com>
Cc: Joe Perches <joe@perches.com>
Cc: Lukas Bulwahn <lukas.bulwahn@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent f49b42d4
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment