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