Skip to contentSkip to conversation

two missing bits (was Re: Add -Wcast-qual flag)

PATCH New Christoph Egger 3 participants 7 messages Dec 22, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 two missing bits (was Re: Add -Wcast-qual flag)

Hi!

I catched two pieces with debug and crash_debug enabled. One of them fixes a build error even without the -Wcast-qual flag.

Patch attached.

xen/common/gdbstub.c +1 -1
diff -r f1ddc050d848 xen/common/gdbstub.c
@@ -382,7 +382,7 @@ static int
 static int 
 process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
 {
-    char *ptr;
+    const char *ptr;
     unsigned long addr, length;
     int resume = 0;
 
xen/include/asm-x86/bitops.h +1 -1
diff -r f1ddc050d848 xen/include/asm-x86/bitops.h
@@ -246,7 +246,7 @@ static __inline__ int constant_test_bit(
 	return ((1U << (nr & 31)) & (((const volatile unsigned int *) addr)[nr >> 5])) != 0;
 }
 
-static __inline__ int variable_test_bit(int nr, const volatile void * addr)
+static __inline__ int variable_test_bit(int nr, volatile void * addr)
 {
 	int oldbit;
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#1 lore raw

PATCH 1/1 two missing bits (was Re: Add -Wcast-qual flag)

I object to the change to variable_test_bit() - why is that needed? I had specifically submitted a patch to get the const qualifier added there. Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

"Christoph Egger" <[email protected]> 22.12.06 10:05 >>>

Hi!

I catched two pieces with debug and crash_debug enabled. One of them fixes a build error even without the -Wcast-qual flag.

Patch attached.

#2 lore raw

Maybe we need a CONST_ADDR macro, as I suspect the problem is the cast hidden inside the ADDR macro is dropping the const qualifier.

-- Keir

Quoted 17 lines · Jan Beulich

I object to the change to variable_test_bit() - why is that needed? I had specifically
submitted a patch to get the const qualifier added there. Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

"Christoph Egger" <[email protected]> 22.12.06 10:05 >>>

Hi!

I catched two pieces with debug and crash_debug enabled. One of them fixes a build error even without the -Wcast-qual flag.

Patch attached.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#3 lore raw

If this was with -Wconst-qual, yes. But didn't we agree that at least for now we'll not add that warning (and hence we also don't absolutely have to change code only affected by it)? Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

Keir Fraser <[email protected]> 22.12.06 10:40 >>>

Maybe we need a CONST_ADDR macro, as I suspect the problem is the cast hidden inside the ADDR macro is dropping the const qualifier.

-- Keir

Quoted 17 lines · Jan Beulich

I object to the change to variable_test_bit() - why is that needed? I had specifically
submitted a patch to get the const qualifier added there. Jan

Quoted 1 line
Quoted 1 line
Quoted 1 line

"Christoph Egger" <[email protected]> 22.12.06 10:05 >>>

Hi!

I catched two pieces with debug and crash_debug enabled. One of them fixes a build error even without the -Wcast-qual flag.

Patch attached.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#4 lore raw
Quoted 3 lines · Jan Beulich

If this was with -Wconst-qual, yes. But didn't we agree that at least for now we'll not add that warning (and hence we also don't absolutely have to change code only affected by it)? Jan

So far I understood, we agreed to not add the flag and not to add the __UNCONST() hack.

#5 lore raw
In reply to Keir Fraser
Quoted 2 lines · Keir Fraser

Maybe we need a CONST_ADDR macro, as I suspect the problem is the cast hidden inside the ADDR macro is dropping the const qualifier.

That's right. Yet another alternative patch, this time with the CONST_ADDR macro.

Quoted 6 lines

-- Keir

Quoted 3 lines · Jan Beulich

I object to the change to variable_test_bit() - why is that needed? I had specifically
submitted a patch to get the const qualifier added there. Jan

xen/common/gdbstub.c +1 -1
diff -r f1ddc050d848 xen/common/gdbstub.c
@@ -382,7 +382,7 @@ static int
 static int 
 process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
 {
-    char *ptr;
+    const char *ptr;
     unsigned long addr, length;
     int resume = 0;
 
xen/include/asm-x86/bitops.h +2 -1
diff -r f1ddc050d848 xen/include/asm-x86/bitops.h
@@ -22,6 +22,7 @@
  * used only when the constraint allows the operand to reside in a register.
  */
 
+#define CONST_ADDR (*(const volatile long *) addr)
 #define ADDR (*(volatile long *) addr)
 
 /**
@@ -253,7 +254,7 @@ static __inline__ int variable_test_bit(
 	__asm__ __volatile__(
 		"btl %2,%1\n\tsbbl %0,%0"
 		:"=r" (oldbit)
-		:"m" (ADDR),"dIr" (nr));
+		:"m" (CONST_ADDR),"dIr" (nr));
 	return oldbit;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

#6 lore raw
In reply to Jan Beulich
Quoted 2 lines · Jan Beulich

I object to the change to variable_test_bit() - why is that needed? I had specifically submitted a patch to get the const qualifier added there. Jan

The ADDR macro discards the const again.
I attached an alternative patch.

xen/common/gdbstub.c +1 -1
diff -r f1ddc050d848 xen/common/gdbstub.c
@@ -382,7 +382,7 @@ static int
 static int 
 process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
 {
-    char *ptr;
+    const char *ptr;
     unsigned long addr, length;
     int resume = 0;
 
xen/include/asm-x86/bitops.h +1 -1
diff -r f1ddc050d848 xen/include/asm-x86/bitops.h
@@ -253,7 +253,7 @@ static __inline__ int variable_test_bit(
 	__asm__ __volatile__(
 		"btl %2,%1\n\tsbbl %0,%0"
 		:"=r" (oldbit)
-		:"m" (ADDR),"dIr" (nr));
+		:"m" (*(const volatile long *)addr),"dIr" (nr));
 	return oldbit;
 }
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel