diff mbox

parisc: fix compile warnings triggered by atomic_sub(sizeof(),v)

Message ID 20130227221552.GA2817@p100.box (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Helge Deller Feb. 27, 2013, 10:15 p.m. UTC
commit 4e5a5143e77add104aeee9cd6a92a2f89ab6edd6
Author: Helge Deller <deller@gmx.de>
Date:   Wed Feb 27 00:14:56 2013 +0100

parisc: fix compile warnings triggered by atomic_sub(sizeof(),v)

This fixes compile warnings like this one:
net/ipv4/igmp.c: In function ‘ip_mc_leave_group’:
net/ipv4/igmp.c:1898:3: warning: overflow in implicit constant conversion [-Woverflow]

atomic_sub() is defined as
and if VAL is of type unsigned int (as returned by sizeof()), negating
this value will overflow. Fix this by type-casting VAL to int type:

Signed-off-by: Helge Deller <deller@gmx.de>

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Rolf Eike Beer Feb. 27, 2013, 11:09 p.m. UTC | #1
Helge Deller wrote:

> atomic_sub() is defined as
> and if VAL is of type unsigned int (as returned by sizeof()), negating
> this value will overflow. Fix this by type-casting VAL to int type:

Something in the first line of the message seems missing.

Eike
Helge Deller Feb. 27, 2013, 11:41 p.m. UTC | #2
On 02/28/2013 12:09 AM, Rolf Eike Beer wrote:
> Helge Deller wrote:
> 
>> atomic_sub() is defined as
>> and if VAL is of type unsigned int (as returned by sizeof()), negating
>> this value will overflow. Fix this by type-casting VAL to int type:
> 
> Something in the first line of the message seems missing.

Oops...
This line:
#define atomic_sub(VAL,v)        ((void)(__atomic_add_return(-(VAL),(v))))
is missing.
It was probably ignored by git am or was eaten by vi due to the "#" :-(

I'll fix that.

Thanks!
Helge 

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
index af9cf30..f38e198 100644
--- a/arch/parisc/include/asm/atomic.h
+++ b/arch/parisc/include/asm/atomic.h
@@ -115,8 +115,8 @@  static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
 }
 
 
-#define atomic_add(i,v)	((void)(__atomic_add_return( (i),(v))))
-#define atomic_sub(i,v)	((void)(__atomic_add_return(-(i),(v))))
+#define atomic_add(i,v)	((void)(__atomic_add_return(        (i),(v))))
+#define atomic_sub(i,v)	((void)(__atomic_add_return(-((int) (i)),(v))))
 #define atomic_inc(v)	((void)(__atomic_add_return(   1,(v))))
 #define atomic_dec(v)	((void)(__atomic_add_return(  -1,(v))))