All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
@ 2014-03-22  6:38 behanw
  2014-03-22 10:01 ` Arnd Bergmann
  2014-03-31 20:52 ` [PATCH] " H. Peter Anvin
  0 siblings, 2 replies; 19+ messages in thread
From: behanw @ 2014-03-22  6:38 UTC (permalink / raw)
  To: arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Behan Webster,
	Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Fix uninitialized return code in default case in cmpxchg-local.h

This patch fixes the code to prevent an uninitialized return value that is detected
when compiling with clang. The bug produces numerous warnings when compiling the
Linux kernel with clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 include/asm-generic/cmpxchg-local.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..4c41bb8 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
 		break;
 	default:
 		wrong_size_cmpxchg(ptr);
+		prev = 0;
 	}
 	raw_local_irq_restore(flags);
 	return prev;
-- 
1.8.3.2


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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22  6:38 [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable behanw
@ 2014-03-22 10:01 ` Arnd Bergmann
  2014-03-22 15:45   ` Behan Webster
  2014-03-22 15:48   ` [PATCH v2] " behanw
  2014-03-31 20:52 ` [PATCH] " H. Peter Anvin
  1 sibling, 2 replies; 19+ messages in thread
From: Arnd Bergmann @ 2014-03-22 10:01 UTC (permalink / raw)
  To: behanw; +Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On Saturday 22 March 2014, behanw@converseincode.com wrote:
> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> index d8d4c89..4c41bb8 100644
> --- a/include/asm-generic/cmpxchg-local.h
> +++ b/include/asm-generic/cmpxchg-local.h
> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>                 break;
>         default:
>                 wrong_size_cmpxchg(ptr);
> +               prev = 0;
>         }
>         raw_local_irq_restore(flags);
>         return prev;


How about using __unreachable() instead to annotate the fact that you won't
get here?

	Arnd

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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 10:01 ` Arnd Bergmann
@ 2014-03-22 15:45   ` Behan Webster
  2014-03-22 15:48   ` [PATCH v2] " behanw
  1 sibling, 0 replies; 19+ messages in thread
From: Behan Webster @ 2014-03-22 15:45 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/22/14 03:01, Arnd Bergmann wrote:
> On Saturday 22 March 2014, behanw@converseincode.com wrote:
>> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
>> index d8d4c89..4c41bb8 100644
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>>                  break;
>>          default:
>>                  wrong_size_cmpxchg(ptr);
>> +               prev = 0;
>>          }
>>          raw_local_irq_restore(flags);
>>          return prev;
>
> How about using __unreachable() instead to annotate the fact that you won't
> get here?
Yours is a _much_ better idea. Will fix.

Thanks,

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 10:01 ` Arnd Bergmann
  2014-03-22 15:45   ` Behan Webster
@ 2014-03-22 15:48   ` behanw
  2014-03-22 16:21     ` Sam Ravnborg
  2014-03-22 16:29     ` [PATCH v2] " James Bottomley
  1 sibling, 2 replies; 19+ messages in thread
From: behanw @ 2014-03-22 15:48 UTC (permalink / raw)
  To: arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Behan Webster,
	Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Fix uninitialized return code in default case in cmpxchg-local.h

This patch fixes the code to prevent an uninitialized return value that is detected
when compiling with clang. The bug produces numerous warnings when compiling the
Linux kernel with clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 include/asm-generic/cmpxchg-local.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..9112111 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
 		break;
 	default:
 		wrong_size_cmpxchg(ptr);
+		__builtin_unreachable();
 	}
 	raw_local_irq_restore(flags);
 	return prev;
-- 
1.8.3.2


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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 15:48   ` [PATCH v2] " behanw
@ 2014-03-22 16:21     ` Sam Ravnborg
  2014-03-22 16:31       ` Behan Webster
  2014-03-22 16:35       ` [PATCH v3] " behanw
  2014-03-22 16:29     ` [PATCH v2] " James Bottomley
  1 sibling, 2 replies; 19+ messages in thread
From: Sam Ravnborg @ 2014-03-22 16:21 UTC (permalink / raw)
  To: behanw; +Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On Sat, Mar 22, 2014 at 08:48:19AM -0700, behanw@converseincode.com wrote:
> From: Behan Webster <behanw@converseincode.com>
> 
> Fix uninitialized return code in default case in cmpxchg-local.h
> 
> This patch fixes the code to prevent an uninitialized return value that is detected
> when compiling with clang. The bug produces numerous warnings when compiling the
> Linux kernel with clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> ---
>  include/asm-generic/cmpxchg-local.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> index d8d4c89..9112111 100644
> --- a/include/asm-generic/cmpxchg-local.h
> +++ b/include/asm-generic/cmpxchg-local.h
> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>  		break;
>  	default:
>  		wrong_size_cmpxchg(ptr);
> +		__builtin_unreachable();

It is unreachable() - see compiler.h

	Sam

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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 15:48   ` [PATCH v2] " behanw
  2014-03-22 16:21     ` Sam Ravnborg
@ 2014-03-22 16:29     ` James Bottomley
  2014-03-22 16:37       ` Behan Webster
  1 sibling, 1 reply; 19+ messages in thread
From: James Bottomley @ 2014-03-22 16:29 UTC (permalink / raw)
  To: behanw; +Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On Sat, 2014-03-22 at 08:48 -0700, behanw@converseincode.com wrote:
> From: Behan Webster <behanw@converseincode.com>
> 
> Fix uninitialized return code in default case in cmpxchg-local.h
> 
> This patch fixes the code to prevent an uninitialized return value that is detected
> when compiling with clang. The bug produces numerous warnings when compiling the
> Linux kernel with clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> ---
>  include/asm-generic/cmpxchg-local.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> index d8d4c89..9112111 100644
> --- a/include/asm-generic/cmpxchg-local.h
> +++ b/include/asm-generic/cmpxchg-local.h
> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>  		break;
>  	default:
>  		wrong_size_cmpxchg(ptr);
> +		__builtin_unreachable();

No, that's got to be unreachable() so that it works in all compilers,
(__builtin_unreachable is a gcc-4 ism).

Got to say this still looks wrong.  If wrong_size_cmpxchg() cannot
return, the function should be annotated as such with __noreturn (like
panic()) so the unreachable() should be superfluous.

James



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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:21     ` Sam Ravnborg
@ 2014-03-22 16:31       ` Behan Webster
  2014-03-22 16:35       ` [PATCH v3] " behanw
  1 sibling, 0 replies; 19+ messages in thread
From: Behan Webster @ 2014-03-22 16:31 UTC (permalink / raw)
  To: Sam Ravnborg
  Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/22/14 09:21, Sam Ravnborg wrote:
> On Sat, Mar 22, 2014 at 08:48:19AM -0700, behanw@converseincode.com wrote:
>> From: Behan Webster <behanw@converseincode.com>
>>
>> Fix uninitialized return code in default case in cmpxchg-local.h
>>
>> This patch fixes the code to prevent an uninitialized return value that is detected
>> when compiling with clang. The bug produces numerous warnings when compiling the
>> Linux kernel with clang.
>>
>> Signed-off-by: Behan Webster <behanw@converseincode.com>
>> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
>> ---
>>   include/asm-generic/cmpxchg-local.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
>> index d8d4c89..9112111 100644
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>>   		break;
>>   	default:
>>   		wrong_size_cmpxchg(ptr);
>> +		__builtin_unreachable();
> It is unreachable() - see compiler.h
Oh I see.

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* [PATCH v3] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:21     ` Sam Ravnborg
  2014-03-22 16:31       ` Behan Webster
@ 2014-03-22 16:35       ` behanw
  1 sibling, 0 replies; 19+ messages in thread
From: behanw @ 2014-03-22 16:35 UTC (permalink / raw)
  To: arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Behan Webster,
	Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Fix uninitialized return code in default case in cmpxchg-local.h

This patch fixes the code to prevent an uninitialized return value that is detected
when compiling with clang. The bug produces numerous warnings when compiling the
Linux kernel with clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 include/asm-generic/cmpxchg-local.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..a4f5882 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
 		break;
 	default:
 		wrong_size_cmpxchg(ptr);
+		unreachable();
 	}
 	raw_local_irq_restore(flags);
 	return prev;
-- 
1.8.3.2


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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:29     ` [PATCH v2] " James Bottomley
@ 2014-03-22 16:37       ` Behan Webster
  2014-03-22 16:42         ` James Bottomley
  0 siblings, 1 reply; 19+ messages in thread
From: Behan Webster @ 2014-03-22 16:37 UTC (permalink / raw)
  To: James Bottomley
  Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/22/14 09:29, James Bottomley wrote:
> On Sat, 2014-03-22 at 08:48 -0700, behanw@converseincode.com wrote:
>> From: Behan Webster <behanw@converseincode.com>
>>
>> Fix uninitialized return code in default case in cmpxchg-local.h
>>
>> This patch fixes the code to prevent an uninitialized return value that is detected
>> when compiling with clang. The bug produces numerous warnings when compiling the
>> Linux kernel with clang.
>>
>> Signed-off-by: Behan Webster <behanw@converseincode.com>
>> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
>> ---
>>   include/asm-generic/cmpxchg-local.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
>> index d8d4c89..9112111 100644
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>>   		break;
>>   	default:
>>   		wrong_size_cmpxchg(ptr);
>> +		__builtin_unreachable();
> No, that's got to be unreachable() so that it works in all compilers,
> (__builtin_unreachable is a gcc-4 ism).
It is also supported by clang.

> Got to say this still looks wrong.  If wrong_size_cmpxchg() cannot
> return, the function should be annotated as such with __noreturn (like
> panic()) so the unreachable() should be superfluous.
Okay. I can try that instead.

Thanks,

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:37       ` Behan Webster
@ 2014-03-22 16:42         ` James Bottomley
  2014-03-23  6:32           ` Behan Webster
                             ` (2 more replies)
  0 siblings, 3 replies; 19+ messages in thread
From: James Bottomley @ 2014-03-22 16:42 UTC (permalink / raw)
  To: Behan Webster
  Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On Sat, 2014-03-22 at 09:37 -0700, Behan Webster wrote:
> On 03/22/14 09:29, James Bottomley wrote:
> > On Sat, 2014-03-22 at 08:48 -0700, behanw@converseincode.com wrote:
> >> From: Behan Webster <behanw@converseincode.com>
> >>
> >> Fix uninitialized return code in default case in cmpxchg-local.h
> >>
> >> This patch fixes the code to prevent an uninitialized return value that is detected
> >> when compiling with clang. The bug produces numerous warnings when compiling the
> >> Linux kernel with clang.
> >>
> >> Signed-off-by: Behan Webster <behanw@converseincode.com>
> >> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> >> ---
> >>   include/asm-generic/cmpxchg-local.h | 1 +
> >>   1 file changed, 1 insertion(+)
> >>
> >> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> >> index d8d4c89..9112111 100644
> >> --- a/include/asm-generic/cmpxchg-local.h
> >> +++ b/include/asm-generic/cmpxchg-local.h
> >> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
> >>   		break;
> >>   	default:
> >>   		wrong_size_cmpxchg(ptr);
> >> +		__builtin_unreachable();
> > No, that's got to be unreachable() so that it works in all compilers,
> > (__builtin_unreachable is a gcc-4 ism).
> It is also supported by clang.

OK, but it's not supported by gcc-3.  So gcc-3 would crap out seeing the
statement, which is why we have to wrapper it.

> > Got to say this still looks wrong.  If wrong_size_cmpxchg() cannot
> > return, the function should be annotated as such with __noreturn (like
> > panic()) so the unreachable() should be superfluous.
> Okay. I can try that instead.

Great; This seems to work for me (but then my compiler doesn't see the
unreachable problem).

James

---
diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..70bef78 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -4,7 +4,8 @@
 #include <linux/types.h>
 #include <linux/irqflags.h>
 
-extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
+extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
+	__noreturn;
 
 /*
  * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned



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

* Re: [PATCH v2] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:42         ` James Bottomley
@ 2014-03-23  6:32           ` Behan Webster
  2014-03-24  5:53           ` [PATCH v4] " behanw
  2014-03-24  9:46           ` David Howells
  2 siblings, 0 replies; 19+ messages in thread
From: Behan Webster @ 2014-03-23  6:32 UTC (permalink / raw)
  To: James Bottomley
  Cc: arnd, linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/22/14 09:42, James Bottomley wrote:
> On Sat, 2014-03-22 at 09:37 -0700, Behan Webster wrote:
>> On 03/22/14 09:29, James Bottomley wrote:
>>> On Sat, 2014-03-22 at 08:48 -0700, behanw@converseincode.com wrote:
>>>> From: Behan Webster <behanw@converseincode.com>
>>>>
>>>> Fix uninitialized return code in default case in cmpxchg-local.h
>>>>
>>>> This patch fixes the code to prevent an uninitialized return value that is detected
>>>> when compiling with clang. The bug produces numerous warnings when compiling the
>>>> Linux kernel with clang.
>>>>
>>>> Signed-off-by: Behan Webster <behanw@converseincode.com>
>>>> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
>>>> ---
>>>>    include/asm-generic/cmpxchg-local.h | 1 +
>>>>    1 file changed, 1 insertion(+)
>>>>
>>>> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
>>>> index d8d4c89..9112111 100644
>>>> --- a/include/asm-generic/cmpxchg-local.h
>>>> +++ b/include/asm-generic/cmpxchg-local.h
>>>> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>>>>    		break;
>>>>    	default:
>>>>    		wrong_size_cmpxchg(ptr);
>>>> +		__builtin_unreachable();
>>> No, that's got to be unreachable() so that it works in all compilers,
>>> (__builtin_unreachable is a gcc-4 ism).
>> It is also supported by clang.
> OK, but it's not supported by gcc-3.  So gcc-3 would crap out seeing the
> statement, which is why we have to wrapper it.
Sorry. I wasn't clear. It is not merely a gcc-4 ism; it is also 
supported by clang.

I'm not arguing it should be used. I understand (and agree with) your 
objection to its use since it isn't supported before gcc-4.

>>> Got to say this still looks wrong.  If wrong_size_cmpxchg() cannot
>>> return, the function should be annotated as such with __noreturn (like
>>> panic()) so the unreachable() should be superfluous.
>> Okay. I can try that instead.
> Great; This seems to work for me (but then my compiler doesn't see the
> unreachable problem).
>
> James
>
> ---
> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> index d8d4c89..70bef78 100644
> --- a/include/asm-generic/cmpxchg-local.h
> +++ b/include/asm-generic/cmpxchg-local.h
> @@ -4,7 +4,8 @@
>   #include <linux/types.h>
>   #include <linux/irqflags.h>
>   
> -extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
> +extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
> +	__noreturn;
>   
>   /*
>    * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
Nice. I'll give it a try. It looks like a much better solution.

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* [PATCH v4] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:42         ` James Bottomley
  2014-03-23  6:32           ` Behan Webster
@ 2014-03-24  5:53           ` behanw
  2014-03-25 17:16             ` Arnd Bergmann
  2014-03-24  9:46           ` David Howells
  2 siblings, 1 reply; 19+ messages in thread
From: behanw @ 2014-03-24  5:53 UTC (permalink / raw)
  To: arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Behan Webster,
	Mark Charlebois

From: Behan Webster <behanw@converseincode.com>

Fix uninitialized return code in default case in cmpxchg-local.h

This patch fixes the code to prevent an uninitialized return value that is detected
when compiling with clang. The bug produces numerous warnings when compiling the
Linux kernel with clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Signed-off-by: Mark Charlebois <charlebm@gmail.com>
---
 include/asm-generic/cmpxchg-local.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
index d8d4c89..70bef78 100644
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -4,7 +4,8 @@
 #include <linux/types.h>
 #include <linux/irqflags.h>
 
-extern unsigned long wrong_size_cmpxchg(volatile void *ptr);
+extern unsigned long wrong_size_cmpxchg(volatile void *ptr)
+	__noreturn;
 
 /*
  * Generic version of __cmpxchg_local (disables interrupts). Takes an unsigned
-- 
1.8.3.2


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

* Re: [PATCH v4] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22 16:42         ` James Bottomley
  2014-03-23  6:32           ` Behan Webster
  2014-03-24  5:53           ` [PATCH v4] " behanw
@ 2014-03-24  9:46           ` David Howells
  2 siblings, 0 replies; 19+ messages in thread
From: David Howells @ 2014-03-24  9:46 UTC (permalink / raw)
  To: behanw
  Cc: dhowells, arnd, linux-arch, linux-kernel, dwmw2, pageexec,
	Mark Charlebois

behanw@converseincode.com wrote:

> From: Behan Webster <behanw@converseincode.com>
> 
> Fix uninitialized return code in default case in cmpxchg-local.h
> 
> This patch fixes the code to prevent an uninitialized return value that is detected
> when compiling with clang. The bug produces numerous warnings when compiling the
> Linux kernel with clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>

Acked-by: David Howells <dhowells@redhat.com>

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

* Re: [PATCH v4] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-24  5:53           ` [PATCH v4] " behanw
@ 2014-03-25 17:16             ` Arnd Bergmann
  0 siblings, 0 replies; 19+ messages in thread
From: Arnd Bergmann @ 2014-03-25 17:16 UTC (permalink / raw)
  To: behanw; +Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On Monday 24 March 2014, behanw@converseincode.com wrote:
> 
> From: Behan Webster <behanw@converseincode.com>
> 
> Fix uninitialized return code in default case in cmpxchg-local.h
> 
> This patch fixes the code to prevent an uninitialized return value that is detected
> when compiling with clang. The bug produces numerous warnings when compiling the
> Linux kernel with clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>

Acked-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-22  6:38 [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable behanw
  2014-03-22 10:01 ` Arnd Bergmann
@ 2014-03-31 20:52 ` H. Peter Anvin
  2014-03-31 22:10   ` Behan Webster
  1 sibling, 1 reply; 19+ messages in thread
From: H. Peter Anvin @ 2014-03-31 20:52 UTC (permalink / raw)
  To: behanw, arnd; +Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/21/2014 11:38 PM, behanw@converseincode.com wrote:
> From: Behan Webster <behanw@converseincode.com>
> 
> Fix uninitialized return code in default case in cmpxchg-local.h
> 
> This patch fixes the code to prevent an uninitialized return value that is detected
> when compiling with clang. The bug produces numerous warnings when compiling the
> Linux kernel with clang.
> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
> ---
>  include/asm-generic/cmpxchg-local.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
> index d8d4c89..4c41bb8 100644
> --- a/include/asm-generic/cmpxchg-local.h
> +++ b/include/asm-generic/cmpxchg-local.h
> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>  		break;
>  	default:
>  		wrong_size_cmpxchg(ptr);
> +		prev = 0;
>  	}
>  	raw_local_irq_restore(flags);
>  	return prev;
> 

Shouldn't this be a build time assert (__compiletime_error())?

	-hpa


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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-31 20:52 ` [PATCH] " H. Peter Anvin
@ 2014-03-31 22:10   ` Behan Webster
  2014-03-31 22:11     ` H. Peter Anvin
  0 siblings, 1 reply; 19+ messages in thread
From: Behan Webster @ 2014-03-31 22:10 UTC (permalink / raw)
  To: H. Peter Anvin, arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/31/14 13:52, H. Peter Anvin wrote:
> On 03/21/2014 11:38 PM, behanw@converseincode.com wrote:
>> From: Behan Webster <behanw@converseincode.com>
>>
>> Fix uninitialized return code in default case in cmpxchg-local.h
>>
>> This patch fixes the code to prevent an uninitialized return value that is detected
>> when compiling with clang. The bug produces numerous warnings when compiling the
>> Linux kernel with clang.
>>
>> Signed-off-by: Behan Webster <behanw@converseincode.com>
>> Signed-off-by: Mark Charlebois <charlebm@gmail.com>
>> ---
>>   include/asm-generic/cmpxchg-local.h | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/include/asm-generic/cmpxchg-local.h b/include/asm-generic/cmpxchg-local.h
>> index d8d4c89..4c41bb8 100644
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -41,6 +41,7 @@ static inline unsigned long __cmpxchg_local_generic(volatile void *ptr,
>>   		break;
>>   	default:
>>   		wrong_size_cmpxchg(ptr);
>> +		prev = 0;
>>   	}
>>   	raw_local_irq_restore(flags);
>>   	return prev;
>>
> Shouldn't this be a build time assert (__compiletime_error())?
I changed it to a __noreturn on wrong_size_cmpxchg thanks to James 
Bottomley.

Which would be better?

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-31 22:10   ` Behan Webster
@ 2014-03-31 22:11     ` H. Peter Anvin
  2014-03-31 22:16       ` Behan Webster
  0 siblings, 1 reply; 19+ messages in thread
From: H. Peter Anvin @ 2014-03-31 22:11 UTC (permalink / raw)
  To: Behan Webster, arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/31/2014 03:10 PM, Behan Webster wrote:
>>>
>>> diff --git a/include/asm-generic/cmpxchg-local.h
>>> b/include/asm-generic/cmpxchg-local.h
>>> index d8d4c89..4c41bb8 100644
>>> --- a/include/asm-generic/cmpxchg-local.h
>>> +++ b/include/asm-generic/cmpxchg-local.h
>>> @@ -41,6 +41,7 @@ static inline unsigned long
>>> __cmpxchg_local_generic(volatile void *ptr,
>>>           break;
>>>       default:
>>>           wrong_size_cmpxchg(ptr);
>>> +        prev = 0;
>>>       }
>>>       raw_local_irq_restore(flags);
>>>       return prev;
>>>
>> Shouldn't this be a build time assert (__compiletime_error())?
> I changed it to a __noreturn on wrong_size_cmpxchg thanks to James
> Bottomley.
> 
> Which would be better?
> 

__compiletime_error traps at compile time rather than link time, which
is what you want.

	-hpa



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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-31 22:11     ` H. Peter Anvin
@ 2014-03-31 22:16       ` Behan Webster
  2014-03-31 22:19         ` H. Peter Anvin
  0 siblings, 1 reply; 19+ messages in thread
From: Behan Webster @ 2014-03-31 22:16 UTC (permalink / raw)
  To: H. Peter Anvin, arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/31/14 15:11, H. Peter Anvin wrote:
> On 03/31/2014 03:10 PM, Behan Webster wrote:
>>>> diff --git a/include/asm-generic/cmpxchg-local.h
>>>> b/include/asm-generic/cmpxchg-local.h
>>>> index d8d4c89..4c41bb8 100644
>>>> --- a/include/asm-generic/cmpxchg-local.h
>>>> +++ b/include/asm-generic/cmpxchg-local.h
>>>> @@ -41,6 +41,7 @@ static inline unsigned long
>>>> __cmpxchg_local_generic(volatile void *ptr,
>>>>            break;
>>>>        default:
>>>>            wrong_size_cmpxchg(ptr);
>>>> +        prev = 0;
>>>>        }
>>>>        raw_local_irq_restore(flags);
>>>>        return prev;
>>>>
>>> Shouldn't this be a build time assert (__compiletime_error())?
>> I changed it to a __noreturn on wrong_size_cmpxchg thanks to James
>> Bottomley.
>>
>> Which would be better?
>>
> __compiletime_error traps at compile time rather than link time, which
> is what you want.
The idea is to remove the compile time warning that the return code 
"prev" isn't initialized in the default case. Indicating that 
wrong_size_cmpxchg doesn't return fixes that false positive.

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable
  2014-03-31 22:16       ` Behan Webster
@ 2014-03-31 22:19         ` H. Peter Anvin
  0 siblings, 0 replies; 19+ messages in thread
From: H. Peter Anvin @ 2014-03-31 22:19 UTC (permalink / raw)
  To: Behan Webster, arnd
  Cc: linux-arch, linux-kernel, dwmw2, pageexec, Mark Charlebois

On 03/31/2014 03:16 PM, Behan Webster wrote:
>>>
>> __compiletime_error traps at compile time rather than link time, which
>> is what you want.
> The idea is to remove the compile time warning that the return code
> "prev" isn't initialized in the default case. Indicating that
> wrong_size_cmpxchg doesn't return fixes that false positive.
> 

Perhaps __compiletime_error() should have __noreturn built in?

	-hpa



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

end of thread, other threads:[~2014-03-31 22:20 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-22  6:38 [PATCH] LLVMLinux: Remove warning about returning an uninitialized variable behanw
2014-03-22 10:01 ` Arnd Bergmann
2014-03-22 15:45   ` Behan Webster
2014-03-22 15:48   ` [PATCH v2] " behanw
2014-03-22 16:21     ` Sam Ravnborg
2014-03-22 16:31       ` Behan Webster
2014-03-22 16:35       ` [PATCH v3] " behanw
2014-03-22 16:29     ` [PATCH v2] " James Bottomley
2014-03-22 16:37       ` Behan Webster
2014-03-22 16:42         ` James Bottomley
2014-03-23  6:32           ` Behan Webster
2014-03-24  5:53           ` [PATCH v4] " behanw
2014-03-25 17:16             ` Arnd Bergmann
2014-03-24  9:46           ` David Howells
2014-03-31 20:52 ` [PATCH] " H. Peter Anvin
2014-03-31 22:10   ` Behan Webster
2014-03-31 22:11     ` H. Peter Anvin
2014-03-31 22:16       ` Behan Webster
2014-03-31 22:19         ` H. Peter Anvin

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.