[Mesa-dev] [PATCH] util: Silence GCC unused-but-set-variable warning.

Tolga Dalman tolga.dalman at googlemail.com
Mon Jan 16 04:09:24 PST 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 16.01.2012 08:13, Vinson Lee wrote:
> Fix this GCC 4.6 warning with 64-bit builds. u_debug_stack.c: In
> function ‘debug_backtrace_capture’: u_debug_stack.c:45:17: warning:
> variable ‘frame_pointer’ set but not used
> [-Wunused-but-set-variable]
> 
> Signed-off-by: Vinson Lee <vlee at freedesktop.org> --- 
> src/gallium/auxiliary/util/u_debug_stack.c |    2 ++ 1 files
> changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_debug_stack.c
> b/src/gallium/auxiliary/util/u_debug_stack.c index 24e039f..558b911
> 100644 --- a/src/gallium/auxiliary/util/u_debug_stack.c +++
> b/src/gallium/auxiliary/util/u_debug_stack.c @@ -86,6 +86,8 @@
> debug_backtrace_capture(struct debug_stack_frame *backtrace,
> 
> frame_pointer = next_frame_pointer; } +#else +   (void)
> frame_pointer; #endif
> 
> while(nr_frames) {

Why not just move the definition of frame_pointer into the
#ifdef PIPE_ARCH_X86 ? That would also involve some reorganization
in the code before, but I guess that would only cause the code to
be more readable in the end. Look at the preceding few lines:

#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
   __asm__ __volatile__("mov (%%ebp),%0": "=r" (frame_pointer));
   frame_pointer = (const void **)frame_pointer[0];
#elif defined(PIPE_CC_GCC)
   frame_pointer = ((const void **)__builtin_frame_address(1));
#elif defined(PIPE_CC_MSVC) && defined(PIPE_ARCH_X86)
   __asm {
      mov frame_pointer, ebp
   }
   frame_pointer = (const void **)frame_pointer[0];
#else
   frame_pointer = NULL;
#endif

Thus, the second and last block can be removed entirely.

Best regards
Tolga Dalman

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPFBN0AAoJEI0vwg8AaIlUlJoIAMeXYogbvE8ldeO5aeQI0aRX
MyFZNTqOnM9GcAk60e5TPQg5JEA1RH5lCoxL6eLu5S7DBY1lE4clJeDWuhAVKdBq
gJxg5FqX5iCF8g9Wss0QdMIMDMRba543wPEfMenQGTfnhhgn8BnCo3vMK7d/q3Us
TxEJZnROw0HkNjDm2XJ8kYWc4mR3YqdI/k1H1cQTHC3cBmLqyYhAWFaIMwnXH0E7
8sL5pg/NxBtvECnI0tXhL7EsWHRftQeP7IxAU9CNZGQPJDoBfA5RBTwLAjQV44o9
8BWHf3DLNQuAdPGta4+bmw5Q2871WUVi0we51cVNc/XWU8M2t8SxDqzoZYoF/Us=
=Zp28
-----END PGP SIGNATURE-----


More information about the mesa-dev mailing list