Skip to contentSkip to conversation

xen: avoid type warning in xchg_xen_ulong

PATCH In review Arnd Bergmann 2 participants 3 messages May 29, 2017 – May 31, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: avoid type warning in xchg_xen_ulong

The improved type-checking version of container_of() triggers a warning for xchg_xen_ulong, pointing out that 'xen_ulong_t' is unsigned, but atomic64_t contains a signed value:

drivers/xen/events/events_2l.c: In function 'evtchn_2l_handle_events':
arch/x86/include/asm/cmpxchg.h:87:21: error: 'pending_words' is used uninitialized in this function [-Werror=uninitialized]

This adds a cast to work around the warning

Cc Ian Abbott <[email protected]>
Fixes 85323a991d40 ("xen: arm: mandate EABI and use generic atomic operations.")
Fixes daa2ac80834d ("kernel.h: handle pointers to arrays better in container_of()")
---
 arch/arm/include/asm/xen/events.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/xen/events.h +1 -1
index 71e473d05fcc..620dc75362e5 100644
@@ -16,7 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 	return raw_irqs_disabled_flags(regs->ARM_cpsr);
 }
 
-#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((ptr),	\
+#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((long long*)(ptr),\
 							    atomic64_t,	\
 							    counter), (val))
 
Signature · 1 line
2.9.0
#1 lore raw
Quoted 6 lines · Arnd Bergmann

The improved type-checking version of container_of() triggers a warning for xchg_xen_ulong, pointing out that 'xen_ulong_t' is unsigned, but atomic64_t contains a signed value:

drivers/xen/events/events_2l.c: In function 'evtchn_2l_handle_events':
arch/x86/include/asm/cmpxchg.h:87:21: error: 'pending_words' is used uninitialized in this function [-Werror=uninitialized]

I don't think this is the warning message you wanted to paste here? Other than that, the patch is fine.

Quoted 22 lines

This adds a cast to work around the warning

Cc Ian Abbott <[email protected]>
Fixes 85323a991d40 ("xen: arm: mandate EABI and use generic atomic operations.")
Fixes daa2ac80834d ("kernel.h: handle pointers to arrays better in container_of()")
---
 arch/arm/include/asm/xen/events.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/xen/events.h +1 -1
index 71e473d05fcc..620dc75362e5 100644
@@ -16,7 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 	return raw_irqs_disabled_flags(regs->ARM_cpsr);
 }
 
-#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((ptr),	\
+#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((long long*)(ptr),\
 							    atomic64_t,	\
 							    counter), (val))
#2 lore raw
In reply to Arnd Bergmann
Quoted 6 lines · Arnd Bergmann

The improved type-checking version of container_of() triggers a warning for xchg_xen_ulong, pointing out that 'xen_ulong_t' is unsigned, but atomic64_t contains a signed value:

drivers/xen/events/events_2l.c: In function 'evtchn_2l_handle_events':
arch/x86/include/asm/cmpxchg.h:87:21: error: 'pending_words' is used uninitialized in this function [-Werror=uninitialized]

I don't think this is the warning message you wanted to paste here? Other than that, the patch is fine.

Quoted 15 lines

This adds a cast to work around the warning

Cc Ian Abbott <[email protected]>
Fixes 85323a991d40 ("xen: arm: mandate EABI and use generic atomic operations.")
Fixes daa2ac80834d ("kernel.h: handle pointers to arrays better in container_of()")
---
 arch/arm/include/asm/xen/events.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/include/asm/xen/events.h +0 -0
index 71e473d05fcc..620dc75362e5 100644

arch/arm/include/asm/xen/events.h static inline int xen_irqs_disabled(struct pt_regs *regs) · line 21

Quoted 7 lines
arch/arm/include/asm/xen/events.h +1 -1
@@ -16,7 +16,7 @@ static inline int xen_irqs_disabled(struct pt_regs *regs)
 	return raw_irqs_disabled_flags(regs->ARM_cpsr);
 }
 
-#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((ptr),	\
+#define xchg_xen_ulong(ptr, val) atomic64_xchg(container_of((long long*)(ptr),\
 							    atomic64_t,	\
 							    counter), (val))

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel