All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/3] checkpatch: Add support for floating point constants
@ 2012-11-01  7:10 Joe Perches
  2012-11-01  7:12 ` [PATCH V2 1/3] checkpatch: Find hex constants as a single IDENT Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Joe Perches @ 2012-11-01  7:10 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Adil Mujeeb, Pavel Machek, linux-kernel

The kernel doesn't support them though.

v2: Make it clearer that checkpatch understands floating point constants
    Support floating point hex constants too

Joe Perches (3):
  checkpatch: Find hex constants as a single IDENT
  checkpatch: Add support for floating point constants
  checkpatch: Emit an warning when floating point values are used

 scripts/checkpatch.pl |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

-- 
1.7.8.112.g3fd21


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

* [PATCH V2 1/3] checkpatch: Find hex constants as a single IDENT
  2012-11-01  7:10 [PATCH V2 0/3] checkpatch: Add support for floating point constants Joe Perches
@ 2012-11-01  7:12 ` Joe Perches
  2012-11-01  7:12 ` [PATCH V2 2/3] checkpatch: Add support for floating point constants Joe Perches
  2012-11-01  7:12 ` [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used Joe Perches
  2 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2012-11-01  7:12 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: Adil Mujeeb, Pavel Machek, linux-kernel

Hexadecimal values are current found in 2 parts.
A hex constant like 0x123456abcdef is found as
0 and then x123456abcdef and later coalesced.

Instead, reverse the order of the 2 searches in
$Constant to find 0x first, then 0 so that the
entire hex constant is found all at once.

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f18750e..099a0ad 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -227,7 +227,7 @@ our $Inline	= qr{inline|__always_inline|noinline};
 our $Member	= qr{->$Ident|\.$Ident|\[[^]]*\]};
 our $Lval	= qr{$Ident(?:$Member)*};
 
-our $Constant	= qr{(?i:(?:[0-9]+|0x[0-9a-f]+)[ul]*)};
+our $Constant	= qr{(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*)};
 our $Assignment	= qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
 our $Compare    = qr{<=|>=|==|!=|<|>};
 our $Operators	= qr{
-- 
1.7.8.112.g3fd21


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

* [PATCH V2 2/3] checkpatch: Add support for floating point constants
  2012-11-01  7:10 [PATCH V2 0/3] checkpatch: Add support for floating point constants Joe Perches
  2012-11-01  7:12 ` [PATCH V2 1/3] checkpatch: Find hex constants as a single IDENT Joe Perches
@ 2012-11-01  7:12 ` Joe Perches
  2012-11-01  7:12 ` [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used Joe Perches
  2 siblings, 0 replies; 8+ messages in thread
From: Joe Perches @ 2012-11-01  7:12 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: Adil Mujeeb, Pavel Machek, linux-kernel

Even though the kernel doesn't support using floating point constants,
add a regex for them.

Support forms like: 0x123p1, 123e-1, 1.23, 1.5e23f

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 099a0ad..c3a2162 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -227,7 +227,11 @@ our $Inline	= qr{inline|__always_inline|noinline};
 our $Member	= qr{->$Ident|\.$Ident|\[[^]]*\]};
 our $Lval	= qr{$Ident(?:$Member)*};
 
-our $Constant	= qr{(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*)};
+our $Float_hex	= qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)};
+our $Float_dec	= qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))};
+our $Float_int	= qr{(?i:[0-9]+e-?[0-9]+[fl]?)};
+our $Float	= qr{$Float_hex|$Float_dec|$Float_int};
+our $Constant	= qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))};
 our $Assignment	= qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
 our $Compare    = qr{<=|>=|==|!=|<|>};
 our $Operators	= qr{
-- 
1.7.8.112.g3fd21


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

* [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used
  2012-11-01  7:10 [PATCH V2 0/3] checkpatch: Add support for floating point constants Joe Perches
  2012-11-01  7:12 ` [PATCH V2 1/3] checkpatch: Find hex constants as a single IDENT Joe Perches
  2012-11-01  7:12 ` [PATCH V2 2/3] checkpatch: Add support for floating point constants Joe Perches
@ 2012-11-01  7:12 ` Joe Perches
  2012-11-06 23:36   ` Andrew Morton
  2 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2012-11-01  7:12 UTC (permalink / raw)
  To: Andrew Morton, Andy Whitcroft; +Cc: Adil Mujeeb, Pavel Machek, linux-kernel

Linux kernel doesn't like floating point, say so.

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

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c3a2162..96685c6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2332,6 +2332,13 @@ sub process {
 			     "do not add new typedefs\n" . $herecurr);
 		}
 
+# check for floating point constants
+
+		if ($line =~ /\b$Float\b/) {
+			WARN("KERNEL_FLOAT",
+			     "Floating point is not supported in linux kernel source\n" . $herecurr);
+		}
+
 # * goes on variable not on type
 		# (char*[ const])
 		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
-- 
1.7.8.112.g3fd21


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

* Re: [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used
  2012-11-01  7:12 ` [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used Joe Perches
@ 2012-11-06 23:36   ` Andrew Morton
  2012-11-07  9:40     ` Andy Whitcroft
  2012-11-07 11:09     ` Joe Perches
  0 siblings, 2 replies; 8+ messages in thread
From: Andrew Morton @ 2012-11-06 23:36 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, Adil Mujeeb, Pavel Machek, linux-kernel

On Thu,  1 Nov 2012 00:12:18 -0700
Joe Perches <joe@perches.com> wrote:

> Linux kernel doesn't like floating point, say so.
> 
> ...
>
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2332,6 +2332,13 @@ sub process {
>  			     "do not add new typedefs\n" . $herecurr);
>  		}
>  
> +# check for floating point constants
> +
> +		if ($line =~ /\b$Float\b/) {
> +			WARN("KERNEL_FLOAT",
> +			     "Floating point is not supported in linux kernel source\n" . $herecurr);
> +		}
> +
>  # * goes on variable not on type
>  		# (char*[ const])
>  		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {

The earlier review comments were not addressed.

In particular, I don't see a problem with people doing

	int foo = 1.1 * 2.2;

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

* Re: [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used
  2012-11-06 23:36   ` Andrew Morton
@ 2012-11-07  9:40     ` Andy Whitcroft
  2012-11-07 11:09     ` Joe Perches
  1 sibling, 0 replies; 8+ messages in thread
From: Andy Whitcroft @ 2012-11-07  9:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Joe Perches, Adil Mujeeb, Pavel Machek, linux-kernel

On Tue, Nov 06, 2012 at 03:36:25PM -0800, Andrew Morton wrote:
> On Thu,  1 Nov 2012 00:12:18 -0700
> Joe Perches <joe@perches.com> wrote:
> 
> > Linux kernel doesn't like floating point, say so.
> > 
> > ...
> >
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2332,6 +2332,13 @@ sub process {
> >  			     "do not add new typedefs\n" . $herecurr);
> >  		}
> >  
> > +# check for floating point constants
> > +
> > +		if ($line =~ /\b$Float\b/) {
> > +			WARN("KERNEL_FLOAT",
> > +			     "Floating point is not supported in linux kernel source\n" . $herecurr);
> > +		}
> > +
> >  # * goes on variable not on type
> >  		# (char*[ const])
> >  		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
> 
> The earlier review comments were not addressed.
> 
> In particular, I don't see a problem with people doing
> 
> 	int foo = 1.1 * 2.2;

I thought there was also now a way to enable floats in kernel space and
some use thereof.

-apw

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

* Re: [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used
  2012-11-06 23:36   ` Andrew Morton
  2012-11-07  9:40     ` Andy Whitcroft
@ 2012-11-07 11:09     ` Joe Perches
  2012-11-07 16:52       ` Andrew Morton
  1 sibling, 1 reply; 8+ messages in thread
From: Joe Perches @ 2012-11-07 11:09 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Andy Whitcroft, Adil Mujeeb, Pavel Machek, linux-kernel

On Tue, 2012-11-06 at 15:36 -0800, Andrew Morton wrote:
> On Thu,  1 Nov 2012 00:12:18 -0700
> Joe Perches <joe@perches.com> wrote:
> > Linux kernel doesn't like floating point, say so. 
[]
> > --- a/scripts/checkpatch.pl
> > +++ b/scripts/checkpatch.pl
> > @@ -2332,6 +2332,13 @@ sub process {
> >  			     "do not add new typedefs\n" . $herecurr);
> >  		}
> >  
> > +# check for floating point constants
> > +
> > +		if ($line =~ /\b$Float\b/) {
> > +			WARN("KERNEL_FLOAT",
> > +			     "Floating point is not supported in linux kernel source\n" . $herecurr);
> > +		}
> > +
> >  # * goes on variable not on type
> >  		# (char*[ const])
> >  		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
> 
> The earlier review comments were not addressed.

You didn't read my response in the thread then.
I "addressed" it by saying that the problem exists
without solution.

> In particular, I don't see a problem with people doing
> 
> 	int foo = 1.1 * 2.2;

Neither do I but I know of no way to determine that any
calc is a constant.


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

* Re: [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used
  2012-11-07 11:09     ` Joe Perches
@ 2012-11-07 16:52       ` Andrew Morton
  0 siblings, 0 replies; 8+ messages in thread
From: Andrew Morton @ 2012-11-07 16:52 UTC (permalink / raw)
  To: Joe Perches; +Cc: Andy Whitcroft, Adil Mujeeb, Pavel Machek, linux-kernel

On Wed, 07 Nov 2012 03:09:35 -0800 Joe Perches <joe@perches.com> wrote:

> On Tue, 2012-11-06 at 15:36 -0800, Andrew Morton wrote:
> > On Thu,  1 Nov 2012 00:12:18 -0700
> > Joe Perches <joe@perches.com> wrote:
> > > Linux kernel doesn't like floating point, say so. 
> []
> > > --- a/scripts/checkpatch.pl
> > > +++ b/scripts/checkpatch.pl
> > > @@ -2332,6 +2332,13 @@ sub process {
> > >  			     "do not add new typedefs\n" . $herecurr);
> > >  		}
> > >  
> > > +# check for floating point constants
> > > +
> > > +		if ($line =~ /\b$Float\b/) {
> > > +			WARN("KERNEL_FLOAT",
> > > +			     "Floating point is not supported in linux kernel source\n" . $herecurr);
> > > +		}
> > > +
> > >  # * goes on variable not on type
> > >  		# (char*[ const])
> > >  		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
> > 
> > The earlier review comments were not addressed.
> 
> You didn't read my response in the thread then.

There was no response afaict.  Not here, not on lkml.org?



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

end of thread, other threads:[~2012-11-07 16:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-01  7:10 [PATCH V2 0/3] checkpatch: Add support for floating point constants Joe Perches
2012-11-01  7:12 ` [PATCH V2 1/3] checkpatch: Find hex constants as a single IDENT Joe Perches
2012-11-01  7:12 ` [PATCH V2 2/3] checkpatch: Add support for floating point constants Joe Perches
2012-11-01  7:12 ` [PATCH V2 3/3] checkpatch: Emit an warning when floating point values are used Joe Perches
2012-11-06 23:36   ` Andrew Morton
2012-11-07  9:40     ` Andy Whitcroft
2012-11-07 11:09     ` Joe Perches
2012-11-07 16:52       ` Andrew Morton

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.