All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Add test for keywords not starting on tabstops
@ 2016-04-21 19:41 Joe Perches
  2018-01-05  8:30   ` [B.A.T.M.A.N.] " Sven Eckelmann
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2016-04-21 19:41 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: linux-kernel

It's somewhat common and in general a defect for c90 keywords to
not start on a tabstop.

Add a test for this condition and warn when it occurs.

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3d9c34..6c1213c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2755,6 +2755,19 @@ sub process {
 			    "Logical continuations should be on the previous line\n" . $hereprev);
 		}
 
+# check indentation starts on a tab stop
+		if ($^V && $^V ge 5.10.0 &&
+		    $sline =~ /^\+\t+( +)(?:$c90_Keywords\b|\{\s*$|\}\s*(?:else\b|while\b|\s*$))/) {
+			my $indent = length($1);
+			if ($indent % 8) {
+				if (WARN("TABSTOP",
+					 "Statements should start on a tabstop\n" . $herecurr) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s@(^\+\t+) +@$1 . "\t" x ($indent/8)@e;
+				}
+			}
+		}
+
 # check multi-line statement indentation matches previous line
 		if ($^V && $^V ge 5.10.0 &&
 		    $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|$Ident\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) {
-- 
2.8.0.rc4.16.g56331f8

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: checkpatch: Add test for keywords not starting on tabstops
  2016-04-21 19:41 [PATCH] checkpatch: Add test for keywords not starting on tabstops Joe Perches
@ 2018-01-05  8:30   ` Sven Eckelmann
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2018-01-05  8:30 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andrew Morton, Andy Whitcroft, linux-kernel, b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On Donnerstag, 21. April 2016 12:41:37 CET Joe Perches wrote:
> It's somewhat common and in general a defect for c90 keywords to
> not start on a tabstop.
> 
> Add a test for this condition and warn when it occurs.

This seems to create some new false positives:

    WARNING: Statements should start on a tabstop
    #919: FILE: ./net/batman-adv/sysfs.c:919:
    +                                     char ifname[IFNAMSIZ])
    
    total: 0 errors, 1 warnings, 0 checks, 1251 lines checked

The code at this position is:

    /**
     * batadv_store_mesh_iface_finish() - store new hardif mesh_iface state
     * @net_dev: netdevice to add/remove to/from batman-adv soft-interface
     * @ifname: name of soft-interface to modify
     *
     * Changes the parts of the hard+soft interface which can not be modified under
     * sysfs lock (to prevent deadlock situations).
     *
     * Return: 0 on success, 0 < on failure
     */
    static int batadv_store_mesh_iface_finish(struct net_device *net_dev,
    					  char ifname[IFNAMSIZ])
    {
    	struct net *net = dev_net(net_dev);


I know, my mail client is most likely mangling the tabs - so better check
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/net/batman-adv/sysfs.c?id=72deacce011bde7475c90e6ee7d4c7d28c384873#n918

Problem seems to be the [IFNAMSIZ]

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] checkpatch: Add test for keywords not starting on tabstops
@ 2018-01-05  8:30   ` Sven Eckelmann
  0 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2018-01-05  8:30 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andrew Morton, Andy Whitcroft, linux-kernel, b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

On Donnerstag, 21. April 2016 12:41:37 CET Joe Perches wrote:
> It's somewhat common and in general a defect for c90 keywords to
> not start on a tabstop.
> 
> Add a test for this condition and warn when it occurs.

This seems to create some new false positives:

    WARNING: Statements should start on a tabstop
    #919: FILE: ./net/batman-adv/sysfs.c:919:
    +                                     char ifname[IFNAMSIZ])
    
    total: 0 errors, 1 warnings, 0 checks, 1251 lines checked

The code at this position is:

    /**
     * batadv_store_mesh_iface_finish() - store new hardif mesh_iface state
     * @net_dev: netdevice to add/remove to/from batman-adv soft-interface
     * @ifname: name of soft-interface to modify
     *
     * Changes the parts of the hard+soft interface which can not be modified under
     * sysfs lock (to prevent deadlock situations).
     *
     * Return: 0 on success, 0 < on failure
     */
    static int batadv_store_mesh_iface_finish(struct net_device *net_dev,
    					  char ifname[IFNAMSIZ])
    {
    	struct net *net = dev_net(net_dev);


I know, my mail client is most likely mangling the tabs - so better check
https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git/tree/net/batman-adv/sysfs.c?id=72deacce011bde7475c90e6ee7d4c7d28c384873#n918

Problem seems to be the [IFNAMSIZ]

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [B.A.T.M.A.N.] checkpatch: Add test for keywords not starting on tabstops
  2018-01-05  8:30   ` [B.A.T.M.A.N.] " Sven Eckelmann
  (?)
@ 2018-01-05  8:43   ` Sven Eckelmann
  -1 siblings, 0 replies; 4+ messages in thread
From: Sven Eckelmann @ 2018-01-05  8:43 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Joe Perches, Andy Whitcroft, Andrew Morton, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 817 bytes --]

On Freitag, 5. Januar 2018 09:30:27 CET Sven Eckelmann wrote:
> On Donnerstag, 21. April 2016 12:41:37 CET Joe Perches wrote:
> > It's somewhat common and in general a defect for c90 keywords to
> > not start on a tabstop.
> >
> > Add a test for this condition and warn when it occurs.
> 
> This seems to create some new false positives:
> 
>     WARNING: Statements should start on a tabstop
>     #919: FILE: ./net/batman-adv/sysfs.c:919:
>     +                                     char ifname[IFNAMSIZ])
>     
>     total: 0 errors, 1 warnings, 0 checks, 1251 lines checked
[...]

Grml, just noticed that I've replied to the wrong mail. This was of course introduced by 
http://lkml.kernel.org/r/1b5f97673f36595956ad43329f77bf1a5546d2ff.1513976662.git.joe@perches.com 
and not by this patch.

Kind regards,
	Sven

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-01-05  8:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-21 19:41 [PATCH] checkpatch: Add test for keywords not starting on tabstops Joe Perches
2018-01-05  8:30 ` Sven Eckelmann
2018-01-05  8:30   ` [B.A.T.M.A.N.] " Sven Eckelmann
2018-01-05  8:43   ` Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.