lkml.org 
[lkml]   [2019]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] checkpatch: add command-line option for TAB size
From
Date
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.


\
 
 \ /
  Last update: 2019-05-09 00:00    [W:0.104 / U:0.224 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site