LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] checkpatch: add __asm__ to function-space-paren exception list
@ 2008-01-29 23:17 Timur Tabi
  2008-02-04 11:22 ` Andy Whitcroft
  0 siblings, 1 reply; 3+ messages in thread
From: Timur Tabi @ 2008-01-29 23:17 UTC (permalink / raw)
  To: apw, linux-kernel; +Cc: Timur Tabi

checkpatch.pl thinks that __asm__ is a function name, so it complains about
a space between the function name and a parenthesis when it sees
"__asm__ ("mov ax,bx")".

This change will also encourage developers to use '__asm__' instead of 'asm'.

Signed-off-by: Timur Tabi <timur@freescale.com>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 579f50f..971c822 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1115,7 +1115,7 @@ sub process {
 
 # check for spaces between functions and their parentheses.
 		while ($line =~ /($Ident)\s+\(/g) {
-			if ($1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case)$/ &&
+			if ($1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case|__asm__)$/ &&
 		            $line !~ /$Type\s+\(/ && $line !~ /^.\#\s*define\b/) {
 				WARN("no space between function name and open parenthesis '('\n" . $herecurr);
 			}
-- 
1.5.2.4


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

* Re: [PATCH] checkpatch: add __asm__ to function-space-paren exception list
  2008-01-29 23:17 [PATCH] checkpatch: add __asm__ to function-space-paren exception list Timur Tabi
@ 2008-02-04 11:22 ` Andy Whitcroft
  2008-02-04 16:38   ` Timur Tabi
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Whitcroft @ 2008-02-04 11:22 UTC (permalink / raw)
  To: Timur Tabi; +Cc: linux-kernel

On Tue, Jan 29, 2008 at 05:17:28PM -0600, Timur Tabi wrote:
> checkpatch.pl thinks that __asm__ is a function name, so it complains about
> a space between the function name and a parenthesis when it sees
> "__asm__ ("mov ax,bx")".
> 
> This change will also encourage developers to use '__asm__' instead of 'asm'.
> 
> Signed-off-by: Timur Tabi <timur@freescale.com>
> ---
>  scripts/checkpatch.pl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 579f50f..971c822 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -1115,7 +1115,7 @@ sub process {
>  
>  # check for spaces between functions and their parentheses.
>  		while ($line =~ /($Ident)\s+\(/g) {
> -			if ($1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case)$/ &&
> +			if ($1 !~ /^(?:if|for|while|switch|return|volatile|__volatile__|__attribute__|format|__extension__|Copyright|case|__asm__)$/ &&
>  		            $line !~ /$Type\s+\(/ && $line !~ /^.\#\s*define\b/) {
>  				WARN("no space between function name and open parenthesis '('\n" . $herecurr);
>  			}
> -- 

It truly is not clear what "type" of thing an __asm__ is these days.
Cirtainly it seems we can use it as an attribute of a type:

        register unsigned long __r16 __asm__("$16") = rtc_access->function;

and yet also in its more traditional form:

	__asm__("	call foo");

The latter form feels like a function?  But cirtainly in the examples it
is shown with a space some of the time, and not others.  Is __asm__ an
attribute of the null function (;) in this context or ... well ?

This patch really just removes any checks for spacing on __asm__ do we
have a preferred style for these?  Attributes do seem to have spaces,
though in their most attribute like usage the __asm__ "attribute" does
not seem to be used with a space, so far anyhow.

Oh and why are we preferring the use of __asm__ over asm?  They both
seem valid.  Should we be recommending one over the other?

-apw

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

* Re: [PATCH] checkpatch: add __asm__ to function-space-paren exception list
  2008-02-04 11:22 ` Andy Whitcroft
@ 2008-02-04 16:38   ` Timur Tabi
  0 siblings, 0 replies; 3+ messages in thread
From: Timur Tabi @ 2008-02-04 16:38 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: linux-kernel

Andy Whitcroft wrote:

> It truly is not clear what "type" of thing an __asm__ is these days.
> Cirtainly it seems we can use it as an attribute of a type:
> 
>         register unsigned long __r16 __asm__("$16") = rtc_access->function;
> 
> and yet also in its more traditional form:
> 
> 	__asm__("	call foo");
> 
> The latter form feels like a function? 

But it's not.  Sure, it defines a block of code that has input and output 
parameters, but one key distinction is that __asm__ is not the name of the 
"function".

? But cirtainly in the examples it
> is shown with a space some of the time, and not others. 

Well, since checkpatch.pl insists that the space be removed, that's probably why 
it's not there a lot of the time.

> Is __asm__ an
> attribute of the null function (;) in this context or ... well ?

I don't think __asm__ can be compared to other C-language syntax constructs.

> This patch really just removes any checks for spacing on __asm__ do we
> have a preferred style for these? 

I don't know, but I do know it's wrong for checkpatch.pl to think that "__asm__" 
is the name of a function.

 > Attributes do seem to have spaces,
> though in their most attribute like usage the __asm__ "attribute" does
> not seem to be used with a space, so far anyhow.

The problem is that checkpatch.pl thinks this is okay:

	__asm__ __volatile__ ("call foo");

but it doesn't like this:

	__asm__ ("call foo");

> Oh and why are we preferring the use of __asm__ over asm?  They both
> seem valid.  Should we be recommending one over the other?

It's a toss-up.  Depending on the architecture, one version has about 60% usage 
and the other about 40%.  I thought I read somewhere that __asm__ is preferred, 
but I can't remember where I read that or who wrote it.

-- 
Timur Tabi
Linux kernel developer at Freescale

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

end of thread, other threads:[~2008-02-04 16:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-29 23:17 [PATCH] checkpatch: add __asm__ to function-space-paren exception list Timur Tabi
2008-02-04 11:22 ` Andy Whitcroft
2008-02-04 16:38   ` Timur Tabi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).