Skip to contentSkip to conversation

arch: x86: include: asm: need 'unsigned' type cast for atomic_clear_mask()

PATCH In review Chen Gang 2 participants 4 messages Jun 8, 2013

Subsystems (3)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 arch: x86: include: asm: need 'unsigned' type cast for atomic_clear_mask()

atomic_set_mask() has already have 'unsigned' type case, and atomic_clear_mask() is the pair of atomic_set_mask().

So it also need 'unsigned' type case.

---
 arch/x86/include/asm/atomic.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
arch/x86/include/asm/atomic.h +1 -1
index 722aa3b..5b5cf52 100644
@@ -255,7 +255,7 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
 /* These are x86-specific, used by some header files */
 #define atomic_clear_mask(mask, addr)				\
 	asm volatile(LOCK_PREFIX "andl %0,%1"			\
-		     : : "r" (~(mask)), "m" (*(addr)) : "memory")
+		     : : "r" (~(unsigned)(mask)), "m" (*(addr)) : "memory")
 
 #define atomic_set_mask(mask, addr)				\
 	asm volatile(LOCK_PREFIX "orl %0,%1"			\
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 6 lines · Chen Gang

atomic_set_mask() has already have 'unsigned' type case, and atomic_clear_mask() is the pair of atomic_set_mask().

So it also need 'unsigned' type case.

Pray tell, in what situation does this matter? The only reason I can think of is if "mask" is actually a long...

-hpa

author
#2 lore raw
Quoted 9 lines · H. Peter Anvin
Quoted 6 lines · Chen Gang
Quoted 6 lines

atomic_set_mask() has already have 'unsigned' type case, and atomic_clear_mask() is the pair of atomic_set_mask().

So it also need 'unsigned' type case.

Pray tell, in what situation does this matter? The only reason I can think of is if "mask" is actually a long...

Excuse me, in fact, I don't know whether it will cause issue. Since atomic_set_mask() has done, I think atomic_clear_mask() also need it.

If atomic_clear_mask() do need it, the atomic_set_mask() do not need it either, they are the pairs --> they will face the same situation.

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation
author
#3 lore raw
Quoted 8 lines · Chen Gang
Quoted 7 lines · H. Peter Anvin
Quoted 7 lines · Chen Gang
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

atomic_set_mask() has already have 'unsigned' type case, and atomic_clear_mask() is the pair of atomic_set_mask().

So it also need 'unsigned' type case.

Quoted 7 lines
Quoted 2 lines
Quoted 2 lines

Pray tell, in what situation does this matter? The only reason I can think of is if "mask" is actually a long...

Excuse me, in fact, I don't know whether it will cause issue. Since atomic_set_mask() has done, I think atomic_clear_mask() also need it.

If atomic_clear_mask() do need it, the atomic_set_mask() do not need it either, they are the pairs --> they will face the same situation.

Oh, my typo, it should be "If atomic_clear_mask() do not need it, the atomic_set_mask() do not need it either, the are face same situation".

Thanks.

Signature · 3 lines
Chen Gang

Asianux Corporation