Message ID | 20170913025905.16419-1-xypron.glpk@gmx.de |
---|---|
State | Accepted |
Commit | 5c761ce58666b3a1695697498598f8bf3484a0c7 |
Delegated to: | Tom Rini |
Headers | show |
Series | [U-Boot,1/1] checkpatch.pl: Add warning for new __packed additions | expand |
On Wed, Sep 13, 2017 at 04:59:05AM +0200, Heinrich Schuchardt wrote: > While there are valid reasons to use __packed, often the answer is that > you should be doing something else here instead. > > This reintroduces the changes of > f503cc49a570 (Add warning for new __packed additions) > > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Applied to u-boot/master, thanks!
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 2287a0bca8..4142f5c837 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5616,6 +5616,13 @@ sub process { "__packed is preferred over __attribute__((packed))\n" . $herecurr); } +# Check for new packed members, warn to use care + if ($realfile !~ m@\binclude/uapi/@ && + $line =~ /\b(__attribute__\s*\(\s*\(.*\bpacked|__packed)\b/) { + WARN("NEW_PACKED", + "Adding new packed members is to be done with care\n" . $herecurr); + } + # Check for __attribute__ aligned, prefer __aligned if ($realfile !~ m@\binclude/uapi/@ && $line =~ /\b__attribute__\s*\(\s*\(.*aligned/) {
While there are valid reasons to use __packed, often the answer is that you should be doing something else here instead. This reintroduces the changes of f503cc49a570 (Add warning for new __packed additions) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> --- This patch is to go after [PATCH v2 1/1] checkpatch: update from Linux v4.13-rc6 In the git log I found no other contributions that we loose by upgrading to the new checkpatch version. I just wonder if the warning text makes sense. Wouldn't it be more helpful to write: "Sequencing structure members in a packed order is preferable to using __packed." Maybe this is also the reason why this check was not accepted by upstream. --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+)