summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2009-03-16 18:36:44 -0700
committerJosh Stone <jistone@redhat.com>2009-03-16 18:36:44 -0700
commit924a2ea21d0276229a752e58e5c5c1a9346648be (patch)
treeaf0fada1dcf94ed13ce6e84a6d0c5dc48af8ea54
parent86758d5f2b838d5769c7ace15269a4ebc422f94a (diff)
downloadsystemtap-steved-924a2ea21d0276229a752e58e5c5c1a9346648be.tar.gz
systemtap-steved-924a2ea21d0276229a752e58e5c5c1a9346648be.tar.xz
systemtap-steved-924a2ea21d0276229a752e58e5c5c1a9346648be.zip
PR9951: Prevent GCC warnings in deref()
In some configurations, GCC was warning about a possible use of _v in the deref macros. I could not reproduce the error, but the only case where _v is not written is if lookup_bad_addr rejects the address, in which case we will hit DEREF_FAULT and _v won't be used. Now we're priming _v=0 anyway, so GCC has no right to complain...
-rw-r--r--runtime/loc2c-runtime.h11
1 files changed, 5 insertions, 6 deletions
diff --git a/runtime/loc2c-runtime.h b/runtime/loc2c-runtime.h
index 92c017d3..16ddb950 100644
--- a/runtime/loc2c-runtime.h
+++ b/runtime/loc2c-runtime.h
@@ -186,7 +186,7 @@
*/
#define kread(ptr) ({ \
- typeof(*(ptr)) _v; \
+ typeof(*(ptr)) _v = 0; \
if (lookup_bad_addr((unsigned long)(ptr)) || \
probe_kernel_read((void *)&_v, (void *)(ptr), sizeof(*(ptr)))) \
DEREF_FAULT(ptr); \
@@ -202,14 +202,13 @@
})
#define deref(size, addr) ({ \
- intptr_t _i; \
+ intptr_t _i = 0; \
switch (size) { \
case 1: _i = kread((u8 *)(addr)); break; \
case 2: _i = kread((u16 *)(addr)); break; \
case 4: _i = kread((u32 *)(addr)); break; \
case 8: _i = kread((u64 *)(addr)); break; \
default: __deref_bad(); \
- /* uninitialized _i should also be caught by -Werror */ \
} \
_i; \
})
@@ -235,7 +234,7 @@ extern void __store_deref_bad(void);
({ \
int _bad = 0; \
u8 _b; u16 _w; u32 _l; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \
@@ -275,7 +274,7 @@ extern void __store_deref_bad(void);
({ \
int _bad = 0; \
u8 _b; u16 _w; u32 _l; u64 _q; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \
@@ -392,7 +391,7 @@ extern void __store_deref_bad(void);
#define deref(size, addr) \
({ \
int _bad = 0; \
- intptr_t _v; \
+ intptr_t _v = 0; \
if (lookup_bad_addr((unsigned long)addr)) \
_bad = 1; \
else \