This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
In Perl_safesyscalloc(), only declare total_size if conditional code needs it.
authorNicholas Clark <nick@ccl4.org>
Tue, 29 Mar 2011 14:06:50 +0000 (15:06 +0100)
committerNicholas Clark <nick@ccl4.org>
Wed, 18 May 2011 19:26:54 +0000 (20:26 +0100)
gcc 4.6.0 warns about variables that are set but never read, and for most
combinations of conditional compilation options, total_size is never read.
So avoid declaring or setting it if it's not actually going to be used later.

util.c

diff --git a/util.c b/util.c
index 0ea39c6..bd9010f 100644 (file)
--- a/util.c
+++ b/util.c
@@ -294,11 +294,16 @@ Perl_safesyscalloc(MEM_SIZE count, MEM_SIZE size)
     dTHX;
 #endif
     Malloc_t ptr;
+#if defined(PERL_TRACK_MEMPOOL) || defined(HAS_64K_LIMIT) || defined(DEBUGGING)
     MEM_SIZE total_size = 0;
+#endif
 
     /* Even though calloc() for zero bytes is strange, be robust. */
-    if (size && (count <= MEM_SIZE_MAX / size))
+    if (size && (count <= MEM_SIZE_MAX / size)) {
+#if defined(PERL_TRACK_MEMPOOL) || defined(HAS_64K_LIMIT) || defined(DEBUGGING)
        total_size = size * count;
+#endif
+    }
     else
        Perl_croak_nocontext("%s", PL_memory_wrap);
 #ifdef PERL_TRACK_MEMPOOL