* [PATCH] arm64: cmpxchg: update macros to prevent warnings
@ 2013-12-03 19:15 Mark Brown
2013-12-03 19:20 ` Mark Brown
2013-12-04 19:29 ` Will Deacon
0 siblings, 2 replies; 8+ messages in thread
From: Mark Brown @ 2013-12-03 19:15 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Hambleton <mahamble@broadcom.com>
Make sure the value we are going to return is referenced in order to
avoid warnings from newer GCCs such as:
arch/arm64/include/asm/cmpxchg.h:162:3: warning: value computed is not used [-Wunused-value]
((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
^
net/netfilter/nf_conntrack_core.c:674:2: note: in expansion of macro ?cmpxchg?
cmpxchg(&nf_conntrack_hash_rnd, 0, rand);
[Modified to use the current underlying implementation as current
mainline for both cmpxchg() and cmpxchg_local() does -- broonie]
Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
---
arch/arm64/include/asm/cmpxchg.h | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
index 3914c0dcd09c..3f75fdb59447 100644
--- a/arch/arm64/include/asm/cmpxchg.h
+++ b/arch/arm64/include/asm/cmpxchg.h
@@ -158,17 +158,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
return ret;
}
-#define cmpxchg(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
-
-#define cmpxchg_local(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg((ptr), (unsigned long)(o), (unsigned long)(n), \
+ sizeof(*(ptr))); \
+ __ret; \
+})
+
+#define cmpxchg_local(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg_local((ptr), (unsigned long)(o), \
+ (unsigned long)(n), sizeof(*(ptr))); \
+ __ret; \
+})
#define cmpxchg64(ptr,o,n) cmpxchg((ptr),(o),(n))
#define cmpxchg64_local(ptr,o,n) cmpxchg_local((ptr),(o),(n))
--
1.8.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] arm64: cmpxchg: update macros to prevent warnings
2013-12-03 19:15 [PATCH] arm64: cmpxchg: update macros to prevent warnings Mark Brown
@ 2013-12-03 19:20 ` Mark Brown
2013-12-04 19:29 ` Will Deacon
1 sibling, 0 replies; 8+ messages in thread
From: Mark Brown @ 2013-12-03 19:20 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 03, 2013 at 07:15:27PM +0000, Mark Brown wrote:
> From: Mark Hambleton <mahamble@broadcom.com>
>
> Make sure the value we are going to return is referenced in order to
> avoid warnings from newer GCCs such as:
Sorry, I was missing a commit --amend here - resent with the correction
made.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131203/264dc0d8/attachment-0001.sig>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] arm64: cmpxchg: update macros to prevent warnings
2013-12-03 19:15 [PATCH] arm64: cmpxchg: update macros to prevent warnings Mark Brown
2013-12-03 19:20 ` Mark Brown
@ 2013-12-04 19:29 ` Will Deacon
2013-12-04 19:38 ` Mark Brown
1 sibling, 1 reply; 8+ messages in thread
From: Will Deacon @ 2013-12-04 19:29 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 03, 2013 at 07:15:27PM +0000, Mark Brown wrote:
> From: Mark Hambleton <mahamble@broadcom.com>
>
> Make sure the value we are going to return is referenced in order to
> avoid warnings from newer GCCs such as:
>
> arch/arm64/include/asm/cmpxchg.h:162:3: warning: value computed is not used [-Wunused-value]
> ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
> ^
> net/netfilter/nf_conntrack_core.c:674:2: note: in expansion of macro ?cmpxchg?
> cmpxchg(&nf_conntrack_hash_rnd, 0, rand);
>
> [Modified to use the current underlying implementation as current
> mainline for both cmpxchg() and cmpxchg_local() does -- broonie]
>
> Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
> Signed-off-by: Mark Brown <broonie@linaro.org>
> ---
> arch/arm64/include/asm/cmpxchg.h | 28 +++++++++++++++++-----------
> 1 file changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
> index 3914c0dcd09c..3f75fdb59447 100644
> --- a/arch/arm64/include/asm/cmpxchg.h
> +++ b/arch/arm64/include/asm/cmpxchg.h
> @@ -158,17 +158,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
> return ret;
> }
>
> -#define cmpxchg(ptr,o,n) \
> - ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
> - (unsigned long)(o), \
> - (unsigned long)(n), \
> - sizeof(*(ptr))))
> -
> -#define cmpxchg_local(ptr,o,n) \
> - ((__typeof__(*(ptr)))__cmpxchg((ptr), \
> - (unsigned long)(o), \
> - (unsigned long)(n), \
> - sizeof(*(ptr))))
> +#define cmpxchg(ptr, o, n) \
> +({ \
> + __typeof__(*(ptr)) __ret; \
> + __ret = (__typeof__(*(ptr))) \
> + __cmpxchg((ptr), (unsigned long)(o), (unsigned long)(n), \
> + sizeof(*(ptr))); \
> + __ret; \
> +})
> +
> +#define cmpxchg_local(ptr, o, n) \
> +({ \
> + __typeof__(*(ptr)) __ret; \
> + __ret = (__typeof__(*(ptr))) \
> + __cmpxchg_local((ptr), (unsigned long)(o), \
> + (unsigned long)(n), sizeof(*(ptr))); \
> + __ret; \
> +})
NAK.
This removes barrier semantics from cmpxchg and makes cmpxchg_local refer to
something which isn't defined anywhere, so the kernel doesn't even build.
Will
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH] arm64: cmpxchg: update macros to prevent warnings
@ 2013-12-03 19:19 Mark Brown
0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2013-12-03 19:19 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Hambleton <mahamble@broadcom.com>
Make sure the value we are going to return is referenced in order to
avoid warnings from newer GCCs such as:
arch/arm64/include/asm/cmpxchg.h:162:3: warning: value computed is not used [-Wunused-value]
((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
^
net/netfilter/nf_conntrack_core.c:674:2: note: in expansion of macro ?cmpxchg?
cmpxchg(&nf_conntrack_hash_rnd, 0, rand);
[Modified to use the current underlying implementation as current
mainline for both cmpxchg() and cmpxchg_local() does -- broonie]
Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
---
arch/arm64/include/asm/cmpxchg.h | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
index 3914c0dcd09c..c558da59989e 100644
--- a/arch/arm64/include/asm/cmpxchg.h
+++ b/arch/arm64/include/asm/cmpxchg.h
@@ -158,17 +158,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
return ret;
}
-#define cmpxchg(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
-
-#define cmpxchg_local(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg_mb((ptr), (unsigned long)(o), (unsigned long)(n), \
+ sizeof(*(ptr))); \
+ __ret; \
+})
+
+#define cmpxchg_local(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg((ptr), (unsigned long)(o), \
+ (unsigned long)(n), sizeof(*(ptr))); \
+ __ret; \
+})
#define cmpxchg64(ptr,o,n) cmpxchg((ptr),(o),(n))
#define cmpxchg64_local(ptr,o,n) cmpxchg_local((ptr),(o),(n))
--
1.8.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] arm64: cmpxchg: update macros to prevent warnings
@ 2013-12-20 12:42 Mark Brown
2013-12-20 14:10 ` Catalin Marinas
0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2013-12-20 12:42 UTC (permalink / raw)
To: linux-arm-kernel
From: Mark Hambleton <mahamble@broadcom.com>
Make sure the value we are going to return is referenced in order to
avoid warnings from newer GCCs such as:
arch/arm64/include/asm/cmpxchg.h:162:3: warning: value computed is not used [-Wunused-value]
((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
^
net/netfilter/nf_conntrack_core.c:674:2: note: in expansion of macro ?cmpxchg?
cmpxchg(&nf_conntrack_hash_rnd, 0, rand);
[Modified to use the current underlying implementation as current
mainline for both cmpxchg() and cmpxchg_local() does -- broonie]
Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
---
arch/arm64/include/asm/cmpxchg.h | 28 +++++++++++++++++-----------
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h
index 3914c0dcd09c..c558da59989e 100644
--- a/arch/arm64/include/asm/cmpxchg.h
+++ b/arch/arm64/include/asm/cmpxchg.h
@@ -158,17 +158,23 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
return ret;
}
-#define cmpxchg(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
-
-#define cmpxchg_local(ptr,o,n) \
- ((__typeof__(*(ptr)))__cmpxchg((ptr), \
- (unsigned long)(o), \
- (unsigned long)(n), \
- sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg_mb((ptr), (unsigned long)(o), (unsigned long)(n), \
+ sizeof(*(ptr))); \
+ __ret; \
+})
+
+#define cmpxchg_local(ptr, o, n) \
+({ \
+ __typeof__(*(ptr)) __ret; \
+ __ret = (__typeof__(*(ptr))) \
+ __cmpxchg((ptr), (unsigned long)(o), \
+ (unsigned long)(n), sizeof(*(ptr))); \
+ __ret; \
+})
#define cmpxchg64(ptr,o,n) cmpxchg((ptr),(o),(n))
#define cmpxchg64_local(ptr,o,n) cmpxchg_local((ptr),(o),(n))
--
1.8.5.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH] arm64: cmpxchg: update macros to prevent warnings
2013-12-20 12:42 Mark Brown
@ 2013-12-20 14:10 ` Catalin Marinas
2013-12-20 16:02 ` Mark Brown
0 siblings, 1 reply; 8+ messages in thread
From: Catalin Marinas @ 2013-12-20 14:10 UTC (permalink / raw)
To: linux-arm-kernel
On Fri, Dec 20, 2013 at 12:42:14PM +0000, Mark Brown wrote:
> From: Mark Hambleton <mahamble@broadcom.com>
>
> Make sure the value we are going to return is referenced in order to
> avoid warnings from newer GCCs such as:
>
> arch/arm64/include/asm/cmpxchg.h:162:3: warning: value computed is not used [-Wunused-value]
> ((__typeof__(*(ptr)))__cmpxchg_mb((ptr), \
> ^
> net/netfilter/nf_conntrack_core.c:674:2: note: in expansion of macro ???cmpxchg???
> cmpxchg(&nf_conntrack_hash_rnd, 0, rand);
>
> [Modified to use the current underlying implementation as current
> mainline for both cmpxchg() and cmpxchg_local() does -- broonie]
>
> Signed-off-by: Mark Hambleton <mahamble@broadcom.com>
> Signed-off-by: Mark Brown <broonie@linaro.org>
I merged the previous one (should be in -next as of last night), I guess
it's the same since the patch doesn't have a version number. But I
wonder whether uses of cmpxchg without checking the return value are
sane.
--
Catalin
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2013-12-20 16:02 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-03 19:15 [PATCH] arm64: cmpxchg: update macros to prevent warnings Mark Brown
2013-12-03 19:20 ` Mark Brown
2013-12-04 19:29 ` Will Deacon
2013-12-04 19:38 ` Mark Brown
-- strict thread matches above, loose matches on Subject: below --
2013-12-03 19:19 Mark Brown
2013-12-20 12:42 Mark Brown
2013-12-20 14:10 ` Catalin Marinas
2013-12-20 16:02 ` Mark Brown
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).