wrapper: rename offset in offset_devp().
PATCH 1/2 wrapper: rename offset in offset_devp().
fdt_wrapper_create_node passes a variable called offset to offset_devp(), which uses said parameter to initialize a local variable called offset.
Due to one of the odder aspects of the C language, the result is an undefined variable, with no error or warning.
--- arch/powerpc/boot/libfdt-wrapper.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
arch/powerpc/boot/libfdt-wrapper.c +2 -2
@@ -44,8 +44,8 @@#define offset_devp (off) \ ({ \ - int offset = (off); \ - check_err(offset) ? NULL : (void *)(offset+1); \ + int _offset = (off); \ + check_err(_offset) ? NULL : (void *)(_offset+1); \ })#define devp_offset (devp) (((int)(devp))-1)
Signature · 1 line
1.5.3.7
arch/powerpc/boot/libfdt-wrapper.c line 49
Quoted 8 lines · On Tue, 11 Dec 2007 15:23:04 -0600 Scott Wood <[email protected]> wrote:
#define
offset_devp(off)\arch/powerpc/boot/libfdt-wrapper.c +2
-2({ \ -int offset = (off); \ -check_err (offset) ?NULL : (void *)(offset+1 ); \ +int _offset = (off); \ +check_err (_offset) ?NULL : (void *)(_offset+1 ); \ })
Just wondering if this could be a static inline function?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Quoted 5 lines · Scott Wood
fdt_wrapper_create_nodepasses a variable called offset tooffset_devp(), which uses said parameter to initialize a local variable called offset.Due to one of the odder aspects of the C language, the result is an undefined variable, with no error or warning.
Ouch, nasty! Good catch.
Quoted 1 line
Signed-off-by Scott Wood <[email protected]>
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Quoted 11 lines · Stephen Rothwell
arch/powerpc/boot/libfdt-wrapper.c line 49
Quoted 8 lines · On Tue, 11 Dec 2007 15:23:04 -0600 Scott Wood <[email protected]> wrote:
#define
offset_devp(off)\arch/powerpc/boot/libfdt-wrapper.c +2
-2({ \ -int offset = (off); \ -check_err (offset) ?NULL : (void *)(offset+1 ); \ +int _offset = (off); \ +check_err (_offset) ?NULL : (void *)(_offset+1 ); \ })Just wondering if this could be a static inline function?
Alas, not really. If we did that, then the __FUNCTION__ and __LINE__ we use in the error message inside check_err() would always refer to the offset_devp() function, which would be substantially less useful than referring to the function which invoked the offset_devp() macro.
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson