Skip to content

Commit 74349bc

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: add support for floating point constants
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> Cc: Andy Whitcroft <apw@canonical.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 6b7eaf6 commit 74349bc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/checkpatch.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,11 @@ sub help {
230230
our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
231231
our $Lval = qr{$Ident(?:$Member)*};
232232

233-
our $Constant = qr{(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*)};
233+
our $Float_hex = qr{(?i:0x[0-9a-f]+p-?[0-9]+[fl]?)};
234+
our $Float_dec = qr{(?i:((?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?))};
235+
our $Float_int = qr{(?i:[0-9]+e-?[0-9]+[fl]?)};
236+
our $Float = qr{$Float_hex|$Float_dec|$Float_int};
237+
our $Constant = qr{(?:$Float|(?i:(?:0x[0-9a-f]+|[0-9]+)[ul]*))};
234238
our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
235239
our $Compare = qr{<=|>=|==|!=|<|>};
236240
our $Operators = qr{

0 commit comments

Comments
 (0)