a4ac56
From 389f3ef2fdfbba2c2816e7334a69a5f540c0a33d Mon Sep 17 00:00:00 2001
a4ac56
From: David Mitchell <davem@iabyn.com>
a4ac56
Date: Mon, 15 Dec 2014 16:14:13 +0000
a4ac56
Subject: [PATCH] EU::Constant: avoid 'uninit' warning
a4ac56
MIME-Version: 1.0
a4ac56
Content-Type: text/plain; charset=UTF-8
a4ac56
Content-Transfer-Encoding: 8bit
a4ac56
a4ac56
The code generated by ExtUtils::Constant can look something like:
a4ac56
a4ac56
static int
a4ac56
constant (..., IV *iv_return) {
a4ac56
   switch (...) {
a4ac56
     case ...:
a4ac56
       *iv_return = ...;
a4ac56
       return PERL_constant_ISIV;
a4ac56
     ...
a4ac56
  }
a4ac56
}
a4ac56
a4ac56
{
a4ac56
    int type;
a4ac56
    IV iv;
a4ac56
    type = constant(..., &iv;;
a4ac56
    switch (type) {
a4ac56
        case PERL_constant_ISIV:
a4ac56
            PUSHi(iv);
a4ac56
    ...
a4ac56
    }
a4ac56
}
a4ac56
a4ac56
and the compiler isn't clever enough to realise that the value of iv
a4ac56
is only used in the code path where its been set.
a4ac56
a4ac56
So initialise it to zero to shut gcc up. Ditto nv and pv.
a4ac56
a4ac56
Signed-off-by: Petr Písař <ppisar@redhat.com>
a4ac56
---
a4ac56
 cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm | 6 +++---
a4ac56
 1 file changed, 3 insertions(+), 3 deletions(-)
a4ac56
a4ac56
diff --git a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm
a4ac56
index 0dc9258..cf0e1ca 100644
a4ac56
--- a/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm
a4ac56
+++ b/cpan/ExtUtils-Constant/lib/ExtUtils/Constant.pm
a4ac56
@@ -198,17 +198,17 @@ $XS_subname(sv)
a4ac56
 EOT
a4ac56
 
a4ac56
   if ($params->{IV}) {
a4ac56
-    $xs .= "	IV		iv;\n";
a4ac56
+    $xs .= "	IV		iv = 0; /* avoid uninit var warning */\n";
a4ac56
   } else {
a4ac56
     $xs .= "	/* IV\t\tiv;\tUncomment this if you need to return IVs */\n";
a4ac56
   }
a4ac56
   if ($params->{NV}) {
a4ac56
-    $xs .= "	NV		nv;\n";
a4ac56
+    $xs .= "	NV		nv = 0.0; /* avoid uninit var warning */\n";
a4ac56
   } else {
a4ac56
     $xs .= "	/* NV\t\tnv;\tUncomment this if you need to return NVs */\n";
a4ac56
   }
a4ac56
   if ($params->{PV}) {
a4ac56
-    $xs .= "	const char	*pv;\n";
a4ac56
+    $xs .= "	const char	*pv = NULL; /* avoid uninit var warning */\n";
a4ac56
   } else {
a4ac56
     $xs .=
a4ac56
       "	/* const char\t*pv;\tUncomment this if you need to return PVs */\n";
a4ac56
-- 
a4ac56
2.9.4
a4ac56