mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Elliott, Robert (Servers)" <elliott@hpe.com>,
	Antonio Borneo <borneo.antonio@gmail.com>,
	Andy Whitcroft <apw@canonical.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] checkpatch: add command-line option for TAB size
Date: Wed, 08 May 2019 14:59:48 -0700	[thread overview]
Message-ID: <4ce8826150026abd7649acb7b9fc143a033b7720.camel@perches.com> (raw)
In-Reply-To: <AT5PR8401MB1169149078CDB1274A259703AB320@AT5PR8401MB1169.NAMPRD84.PROD.OUTLOOK.COM>

On Wed, 2019-05-08 at 21:14 +0000, Elliott, Robert (Servers) wrote:
> > -----Original Message-----
> > From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-owner@vger.kernel.org] On Behalf Of
> > Antonio Borneo
> > Sent: Wednesday, May 8, 2019 12:44 PM
> > Subject: [PATCH v2] checkpatch: add command-line option for TAB size
> ...
> > Add a command-line option "--tab-size" to let the user select a
> > TAB size value other than 8.
> > This makes easy to reuse this script by other projects with
> > different requirements in their coding style (e.g. OpenOCD [1]
> > requires TAB size of 4 characters [2]).
> ...
> > +  --tab-size=n               set the number of spaces for tab (default 8)
> ...
> > +	'tab-size=i'	=> \$tabsize,
> ...
> > -			for (; ($n % 8) != 0; $n++) {
> > +			for (; ($n % $tabsize) != 0; $n++) {
> ...
> > -			if ($indent % 8) {
> > +			if ($indent % $tabsize) {
> > -					"\t" x ($pos / 8) .
> > -					" "  x ($pos % 8);
> > +					"\t" x ($pos / $tabsize) .
> > +					" "  x ($pos % $tabsize);
> ...
> > -			    (($sindent % 8) != 0 ||
> > +			    (($sindent % $tabsize) != 0 ||
> ...
> > -			     ($sindent > $indent + 8))) {
> > +			     ($sindent > $indent + $tabsize))) {
> 
> Checking for 0 before using the value in division and modulo
> operations would be prudent.

true.

Maybe test $tabsize for <= 0 after GetOptions and error out
if so.



  reply	other threads:[~2019-05-08 21:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-08 17:43 Antonio Borneo
2019-05-08 17:56 ` Joe Perches
2019-05-08 18:19   ` Antonio Borneo
2019-05-08 18:36     ` [PATCH v3] " Antonio Borneo
2019-05-08 21:14 ` [PATCH v2] " Elliott, Robert (Servers)
2019-05-08 21:59   ` Joe Perches [this message]
2019-05-08 22:03   ` Antonio Borneo
  -- strict thread matches above, loose matches on Subject: below --
2019-05-09  7:21 [PATCH v4] " Antonio Borneo
2019-05-09  8:03 ` Joe Perches
2019-05-09  9:26   ` Antonio Borneo
2019-05-09  9:39     ` [PATCH v5] " Antonio Borneo
2020-01-22 16:38       ` [PATCH V6] " Antonio Borneo
2019-05-08 12:27 [PATCH 1/4] checkpatch: fix multiple const * types Antonio Borneo
2019-05-08 12:27 ` [PATCH 2/4] checkpatch: add --fix for warning LINE_CONTINUATIONS Antonio Borneo
2019-05-08 14:19   ` Joe Perches
2019-05-08 12:27 ` [PATCH 3/4] checkpatch: fix minor typo and mixed space+tab in indentation Antonio Borneo
2020-01-22 16:38   ` [PATCH V2] " Antonio Borneo
2020-01-22 17:26     ` Joe Perches
2019-05-08 12:27 ` [PATCH 4/4] checkpatch: replace magic value for TAB size Antonio Borneo
2019-05-08 14:52   ` Joe Perches
2019-05-08 15:32     ` Antonio Borneo
2019-05-08 17:02       ` Joe Perches
2019-05-08 14:51 ` [PATCH 1/4] checkpatch: fix multiple const * types Joe Perches
2019-05-08 15:26   ` Antonio Borneo
2020-01-22 16:38     ` [PATCH V3] " Antonio Borneo
2019-05-08 17:43   ` [PATCH v2] " Antonio Borneo
2019-09-04  9:37     ` Antonio Borneo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ce8826150026abd7649acb7b9fc143a033b7720.camel@perches.com \
    --to=joe@perches.com \
    --cc=apw@canonical.com \
    --cc=borneo.antonio@gmail.com \
    --cc=elliott@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®