This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_magic_set(): remove unused var 's'
authorDavid Mitchell <davem@iabyn.com>
Tue, 1 Dec 2015 15:28:37 +0000 (15:28 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 1 Dec 2015 16:01:49 +0000 (16:01 +0000)
This var is (mostly) unused, but is set in a couple of places, hence:

    mg.c:2657:17: warning: variable ā€˜sā€™ set but not used

In the one place it is used, declare it in a narrower scope.

mg.c

diff --git a/mg.c b/mg.c
index 62b4f18..f8d8f33 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -2654,7 +2654,6 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
 #ifdef USE_ITHREADS
     dVAR;
 #endif
-    const char *s;
     I32 paren;
     const REGEXP * rx;
     I32 i;
@@ -2706,10 +2705,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
 
     case '\004':       /* ^D */
 #ifdef DEBUGGING
-       s = SvPV_nolen_const(sv);
-       PL_debug = get_debug_opts(&s, 0) | DEBUG_TOP_FLAG;
-       if (DEBUG_x_TEST || DEBUG_B_TEST)
-           dump_all_perl(!DEBUG_B_TEST);
+        {
+            const char *s = SvPV_nolen_const(sv);
+            PL_debug = get_debug_opts(&s, 0) | DEBUG_TOP_FLAG;
+            if (DEBUG_x_TEST || DEBUG_B_TEST)
+                dump_all_perl(!DEBUG_B_TEST);
+        }
 #else
        PL_debug = (SvIV(sv)) | DEBUG_TOP_FLAG;
 #endif
@@ -2903,12 +2904,12 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        break;
     case '^':
        Safefree(IoTOP_NAME(GvIOp(PL_defoutgv)));
-       s = IoTOP_NAME(GvIOp(PL_defoutgv)) = savesvpv(sv);
+       IoTOP_NAME(GvIOp(PL_defoutgv)) = savesvpv(sv);
        IoTOP_GV(GvIOp(PL_defoutgv)) =  gv_fetchsv(sv, GV_ADD, SVt_PVIO);
        break;
     case '~':
        Safefree(IoFMT_NAME(GvIOp(PL_defoutgv)));
-       s = IoFMT_NAME(GvIOp(PL_defoutgv)) = savesvpv(sv);
+       IoFMT_NAME(GvIOp(PL_defoutgv)) = savesvpv(sv);
        IoFMT_GV(GvIOp(PL_defoutgv)) =  gv_fetchsv(sv, GV_ADD, SVt_PVIO);
        break;
     case '=':