summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2013-11-24 19:58:26 +0000
committerDavid Mitchell <davem@iabyn.com>2013-11-24 20:24:25 +0000
commitcca0492ec62cab786a01ea96c47e549fe0aa8c61 (patch)
tree0c636fc1dddc96e5b658254fd423ce7ed55756c2 /sv.c
parent04783dc7025287c5d75ab531602c7ec786a1e787 (diff)
downloadperl-cca0492ec62cab786a01ea96c47e549fe0aa8c61.tar.gz
fix Gconvert 'ignoring return value' warnings
On some systems, Gconvert() is #deffed to gcvt(), and on linux, that function has a mandatory return value, so you get lots of 'ignoring return value' warnings. So define a V_Gconvert() macro that does Gconvert() in a void context. Ideally this macro would be part of the original definition of Gconvert() in config.sh, but since Gconvert() is only used in sv.c, it was easier to to just define V_Gconvert() locally there.
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/sv.c b/sv.c
index aa3764a0be..9cfddc1e27 100644
--- a/sv.c
+++ b/sv.c
@@ -46,6 +46,17 @@
char *gconvert(double, int, int, char *);
#endif
+/* void Gconvert: on Linux at least, gcvt (which Gconvert gets deffed to),
+ * has a mandatory return value, even though that value is just the same
+ * as the buf arg */
+
+#define V_Gconvert(x,n,t,b) \
+{ \
+ char *rc = Gconvert(x,n,t,b); \
+ PERL_UNUSED_VAR(rc); \
+}
+
+
#ifdef PERL_UTF8_CACHE_ASSERT
/* if adding more checks watch out for the following tests:
* t/op/index.t t/op/length.t t/op/pat.t t/op/substr.t
@@ -2947,7 +2958,7 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
/* some Xenix systems wipe out errno here */
#ifndef USE_LOCALE_NUMERIC
- Gconvert(SvNVX(sv), NV_DIG, 0, s);
+ V_Gconvert(SvNVX(sv), NV_DIG, 0, s);
SvPOK_on(sv);
#else
/* Gconvert always uses the current locale. That's the right thing
@@ -2957,7 +2968,7 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
* But if we're already in the C locale (PL_numeric_standard is
* TRUE in that case), no need to do any changing */
if (PL_numeric_standard || IN_SOME_LOCALE_FORM_RUNTIME) {
- Gconvert(SvNVX(sv), NV_DIG, 0, s);
+ V_Gconvert(SvNVX(sv), NV_DIG, 0, s);
/* If the radix character is UTF-8, and actually is in the
* output, turn on the UTF-8 flag for the scalar */
@@ -2971,7 +2982,7 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags)
else {
char *loc = savepv(setlocale(LC_NUMERIC, NULL));
setlocale(LC_NUMERIC, "C");
- Gconvert(SvNVX(sv), NV_DIG, 0, s);
+ V_Gconvert(SvNVX(sv), NV_DIG, 0, s);
setlocale(LC_NUMERIC, loc);
Safefree(loc);
@@ -10460,7 +10471,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
a Configure test for this. */
if (digits && digits < sizeof(ebuf) - NV_DIG - 10) {
/* 0, point, slack */
- Gconvert(nv, (int)digits, 0, ebuf);
+ V_Gconvert(nv, (int)digits, 0, ebuf);
sv_catpv_nomg(sv, ebuf);
if (*ebuf) /* May return an empty string for digits==0 */
return;
@@ -11320,7 +11331,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
/* See earlier comment about buggy Gconvert when digits,
aka precis is 0 */
if ( c == 'g' && precis) {
- Gconvert((NV)nv, (int)precis, 0, PL_efloatbuf);
+ V_Gconvert((NV)nv, (int)precis, 0, PL_efloatbuf);
/* May return an empty string for digits==0 */
if (*PL_efloatbuf) {
elen = strlen(PL_efloatbuf);