linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] wrapper: rename offset in offset_devp().
@ 2007-12-11 21:23 Scott Wood
  2007-12-12  4:45 ` Stephen Rothwell
  2007-12-17  0:40 ` David Gibson
  0 siblings, 2 replies; 4+ messages in thread
From: Scott Wood @ 2007-12-11 21:23 UTC (permalink / raw)
  To: paulus; +Cc: linuxppc-dev, david

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.

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/libfdt-wrapper.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c
index 002da16..868c504 100644
--- a/arch/powerpc/boot/libfdt-wrapper.c
+++ b/arch/powerpc/boot/libfdt-wrapper.c
@@ -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)
-- 
1.5.3.7

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] wrapper: rename offset in offset_devp().
  2007-12-11 21:23 [PATCH 1/2] wrapper: rename offset in offset_devp() Scott Wood
@ 2007-12-12  4:45 ` Stephen Rothwell
  2007-12-17  0:44   ` David Gibson
  2007-12-17  0:40 ` David Gibson
  1 sibling, 1 reply; 4+ messages in thread
From: Stephen Rothwell @ 2007-12-12  4:45 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, paulus, david

[-- Attachment #1: Type: text/plain, Size: 471 bytes --]

On Tue, 11 Dec 2007 15:23:04 -0600 Scott Wood <scottwood@freescale.com> wrote:
>
>  #define offset_devp(off)	\
>  	({ \
> -		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?

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] wrapper: rename offset in offset_devp().
  2007-12-11 21:23 [PATCH 1/2] wrapper: rename offset in offset_devp() Scott Wood
  2007-12-12  4:45 ` Stephen Rothwell
@ 2007-12-17  0:40 ` David Gibson
  1 sibling, 0 replies; 4+ messages in thread
From: David Gibson @ 2007-12-17  0:40 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev, paulus

On Tue, Dec 11, 2007 at 03:23:04PM -0600, Scott Wood wrote:
> 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.

Ouch, nasty!  Good catch.

> Signed-off-by: Scott Wood <scottwood@freescale.com>

Acked-by: David Gibson <david@gibson.dropbear.id.au>

-- 
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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] wrapper: rename offset in offset_devp().
  2007-12-12  4:45 ` Stephen Rothwell
@ 2007-12-17  0:44   ` David Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2007-12-17  0:44 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: linuxppc-dev, paulus

[-- Attachment #1: Type: text/plain, Size: 931 bytes --]

On Wed, Dec 12, 2007 at 03:45:28PM +1100, Stephen Rothwell wrote:
> On Tue, 11 Dec 2007 15:23:04 -0600 Scott Wood <scottwood@freescale.com> wrote:
> >
> >  #define offset_devp(off)	\
> >  	({ \
> > -		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.

-- 
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

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-12-17  0:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-11 21:23 [PATCH 1/2] wrapper: rename offset in offset_devp() Scott Wood
2007-12-12  4:45 ` Stephen Rothwell
2007-12-17  0:44   ` David Gibson
2007-12-17  0:40 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).