All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
@ 2015-05-12 21:29 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-05-12 21:29 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-kernel, Al Viro, Russell King - ARM Linux

A recent change in kernel/acct.c added a new warning for many
configurations on ARM:

kernel/acct.c: In function 'acct_pin_kill':
arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
  ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\

The code is in fact correct, it's just a cmpxchg() call that intentionally
ignores the result, and no other code does that. The warning does not
show up on x86 because of the way that its cmpxchg() macro is written.

This changes the ARM implementation to use a similar construct with a
compound expression instead of a typecast, which causes the compiler to
not complain about an unused result.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")
---
This helps build some of the ARM defconfigs without warnings once more.

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c3769b01..04be894f7c4e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
  * them available.
  */
 #define cmpxchg_local(ptr, o, n)				  	       \
-	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
-			(unsigned long)(n), sizeof(*(ptr))))
+	({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+			(unsigned long)(n), sizeof(*(ptr)));})
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
 #ifndef CONFIG_SMP
@@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
 }
 
 #define cmpxchg(ptr,o,n)						\
-	((__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
+	({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
 					  (unsigned long)(o),		\
 					  (unsigned long)(n),		\
-					  sizeof(*(ptr))))
+					  sizeof(*(ptr)));})
 
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 					    unsigned long old,


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

* [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
@ 2015-05-12 21:29 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-05-12 21:29 UTC (permalink / raw)
  To: linux-arm-kernel

A recent change in kernel/acct.c added a new warning for many
configurations on ARM:

kernel/acct.c: In function 'acct_pin_kill':
arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
  ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\

The code is in fact correct, it's just a cmpxchg() call that intentionally
ignores the result, and no other code does that. The warning does not
show up on x86 because of the way that its cmpxchg() macro is written.

This changes the ARM implementation to use a similar construct with a
compound expression instead of a typecast, which causes the compiler to
not complain about an unused result.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")
---
This helps build some of the ARM defconfigs without warnings once more.

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c3769b01..04be894f7c4e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
  * them available.
  */
 #define cmpxchg_local(ptr, o, n)				  	       \
-	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
-			(unsigned long)(n), sizeof(*(ptr))))
+	({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+			(unsigned long)(n), sizeof(*(ptr)));})
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
 #ifndef CONFIG_SMP
@@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
 }
 
 #define cmpxchg(ptr,o,n)						\
-	((__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
+	({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
 					  (unsigned long)(o),		\
 					  (unsigned long)(n),		\
-					  sizeof(*(ptr))))
+					  sizeof(*(ptr)));})
 
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 					    unsigned long old,

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

* Re: [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
  2015-05-12 21:29 ` Arnd Bergmann
@ 2015-06-02  9:07   ` Frans Klaver
  -1 siblings, 0 replies; 6+ messages in thread
From: Frans Klaver @ 2015-06-02  9:07 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: linux-arm-kernel, Russell King - ARM Linux, linux-kernel, Al Viro

On Tue, May 12, 2015 at 11:29 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> A recent change in kernel/acct.c added a new warning for many
> configurations on ARM:
>
> kernel/acct.c: In function 'acct_pin_kill':
> arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
>   ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
>
> The code is in fact correct, it's just a cmpxchg() call that intentionally
> ignores the result, and no other code does that. The warning does not
> show up on x86 because of the way that its cmpxchg() macro is written.
>
> This changes the ARM implementation to use a similar construct with a
> compound expression instead of a typecast, which causes the compiler to
> not complain about an unused result.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")
> ---
> This helps build some of the ARM defconfigs without warnings once more.
>
> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> index abb2c3769b01..04be894f7c4e 100644
> --- a/arch/arm/include/asm/cmpxchg.h
> +++ b/arch/arm/include/asm/cmpxchg.h
> @@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>   * them available.
>   */
>  #define cmpxchg_local(ptr, o, n)                                              \
> -       ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
> -                       (unsigned long)(n), sizeof(*(ptr))))
> +       ({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
> +                       (unsigned long)(n), sizeof(*(ptr)));})
>  #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
>
>  #ifndef CONFIG_SMP
> @@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
>  }
>
>  #define cmpxchg(ptr,o,n)                                               \
> -       ((__typeof__(*(ptr)))__cmpxchg_mb((ptr),                        \
> +       ({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),                       \
>                                           (unsigned long)(o),           \
>                                           (unsigned long)(n),           \
> -                                         sizeof(*(ptr))))
> +                                         sizeof(*(ptr)));})
>
>  static inline unsigned long __cmpxchg_local(volatile void *ptr,
>                                             unsigned long old,
>
>

Works for me.

Thanks,
Frans

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

* [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
@ 2015-06-02  9:07   ` Frans Klaver
  0 siblings, 0 replies; 6+ messages in thread
From: Frans Klaver @ 2015-06-02  9:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Tue, May 12, 2015 at 11:29 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> A recent change in kernel/acct.c added a new warning for many
> configurations on ARM:
>
> kernel/acct.c: In function 'acct_pin_kill':
> arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
>   ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
>
> The code is in fact correct, it's just a cmpxchg() call that intentionally
> ignores the result, and no other code does that. The warning does not
> show up on x86 because of the way that its cmpxchg() macro is written.
>
> This changes the ARM implementation to use a similar construct with a
> compound expression instead of a typecast, which causes the compiler to
> not complain about an unused result.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")
> ---
> This helps build some of the ARM defconfigs without warnings once more.
>
> diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
> index abb2c3769b01..04be894f7c4e 100644
> --- a/arch/arm/include/asm/cmpxchg.h
> +++ b/arch/arm/include/asm/cmpxchg.h
> @@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
>   * them available.
>   */
>  #define cmpxchg_local(ptr, o, n)                                              \
> -       ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
> -                       (unsigned long)(n), sizeof(*(ptr))))
> +       ({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
> +                       (unsigned long)(n), sizeof(*(ptr)));})
>  #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
>
>  #ifndef CONFIG_SMP
> @@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
>  }
>
>  #define cmpxchg(ptr,o,n)                                               \
> -       ((__typeof__(*(ptr)))__cmpxchg_mb((ptr),                        \
> +       ({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),                       \
>                                           (unsigned long)(o),           \
>                                           (unsigned long)(n),           \
> -                                         sizeof(*(ptr))))
> +                                         sizeof(*(ptr)));})
>
>  static inline unsigned long __cmpxchg_local(volatile void *ptr,
>                                             unsigned long old,
>
>

Works for me.

Thanks,
Frans

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

* [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
@ 2015-03-04 14:21 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-03-04 14:21 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux-kernel, viro, Russell King, Felipe Balbi

A recent change in kernel/acct.c added a new warning for many
configurations on ARM:

kernel/acct.c: In function 'acct_pin_kill':
arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
  ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\

The code is in fact correct, it's just a cmpxchg() call that intentionally
ignores the result, and no other code does that. The warning does not
show up on x86 because of the way that its cmpxchg() macro is written.

This changes the ARM implementation to use a similar construct with a
compound expression instead of a typecast, which causes the compiler to
not complain about an unused result.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c3769b01..04be894f7c4e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
  * them available.
  */
 #define cmpxchg_local(ptr, o, n)				  	       \
-	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
-			(unsigned long)(n), sizeof(*(ptr))))
+	({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+			(unsigned long)(n), sizeof(*(ptr)));})
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
 #ifndef CONFIG_SMP
@@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
 }
 
 #define cmpxchg(ptr,o,n)						\
-	((__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
+	({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
 					  (unsigned long)(o),		\
 					  (unsigned long)(n),		\
-					  sizeof(*(ptr))))
+					  sizeof(*(ptr)));})
 
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 					    unsigned long old,


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

* [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c
@ 2015-03-04 14:21 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2015-03-04 14:21 UTC (permalink / raw)
  To: linux-arm-kernel

A recent change in kernel/acct.c added a new warning for many
configurations on ARM:

kernel/acct.c: In function 'acct_pin_kill':
arch/arm/include/asm/cmpxchg.h:122:3: warning: value computed is not used [-Wunused-value]
  ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\

The code is in fact correct, it's just a cmpxchg() call that intentionally
ignores the result, and no other code does that. The warning does not
show up on x86 because of the way that its cmpxchg() macro is written.

This changes the ARM implementation to use a similar construct with a
compound expression instead of a typecast, which causes the compiler to
not complain about an unused result.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 3b994d98a815 ("get rid of the second argument of acct_kill()")

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c3769b01..04be894f7c4e 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -119,8 +119,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
  * them available.
  */
 #define cmpxchg_local(ptr, o, n)				  	       \
-	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
-			(unsigned long)(n), sizeof(*(ptr))))
+	({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
+			(unsigned long)(n), sizeof(*(ptr)));})
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
 #ifndef CONFIG_SMP
@@ -202,10 +202,10 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
 }
 
 #define cmpxchg(ptr,o,n)						\
-	((__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
+	({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
 					  (unsigned long)(o),		\
 					  (unsigned long)(n),		\
-					  sizeof(*(ptr))))
+					  sizeof(*(ptr)));})
 
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 					    unsigned long old,

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

end of thread, other threads:[~2015-06-02  9:08 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-12 21:29 [PATCH] ARM: avoid cmpxchg warning in kernel/acct.c Arnd Bergmann
2015-05-12 21:29 ` Arnd Bergmann
2015-06-02  9:07 ` Frans Klaver
2015-06-02  9:07   ` Frans Klaver
  -- strict thread matches above, loose matches on Subject: below --
2015-03-04 14:21 Arnd Bergmann
2015-03-04 14:21 ` Arnd Bergmann

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.