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