This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
As report_wrongway_fh() checks ckWARN(WARN_IO) internally, don't duplicate this.
authorNicholas Clark <nick@ccl4.org>
Tue, 28 Dec 2010 09:30:31 +0000 (09:30 +0000)
committerNicholas Clark <nick@ccl4.org>
Tue, 28 Dec 2010 10:03:48 +0000 (10:03 +0000)
This trades reduced code size for an extra function call in the error path with
warnings disabled. (And removes a duplicated check for the case of taking the
error path *with* warnings enabled.)

doio.c
pp_hot.c
pp_sys.c

diff --git a/doio.c b/doio.c
index 0518bae..9877eba 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -996,7 +996,7 @@ Perl_do_eof(pTHX_ GV *gv)
 
     if (!io)
        return TRUE;
-    else if ((IoTYPE(io) == IoTYPE_WRONLY) && ckWARN(WARN_IO))
+    else if (IoTYPE(io) == IoTYPE_WRONLY)
        report_wrongway_fh(gv, '>');
 
     while (IoIFP(io)) {
index 9e8b2dc..fed7b29 100644 (file)
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -756,12 +756,10 @@ PP(pp_print)
        goto just_say_no;
     }
     else if (!(fp = IoOFP(io))) {
-       if (ckWARN2(WARN_CLOSED, WARN_IO))  {
-           if (IoIFP(io))
-               report_wrongway_fh(gv, '<');
-           else if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
-               report_evil_fh(gv);
-       }
+       if (IoIFP(io))
+           report_wrongway_fh(gv, '<');
+       else if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
+           report_evil_fh(gv);
        SETERRNO(EBADF,IoIFP(io)?RMS_FAC:RMS_IFI);
        goto just_say_no;
     }
@@ -1624,7 +1622,7 @@ Perl_do_readline(pTHX)
        }
        else if (type == OP_GLOB)
            SP--;
-       else if (ckWARN(WARN_IO) && IoTYPE(io) == IoTYPE_WRONLY) {
+       else if (IoTYPE(io) == IoTYPE_WRONLY) {
            report_wrongway_fh(PL_last_in_gv, '>');
        }
     }
index 8737169..e90d33a 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1449,12 +1449,10 @@ PP(pp_leavewrite)
 
     fp = IoOFP(io);
     if (!fp) {
-       if (ckWARN2(WARN_CLOSED,WARN_IO)) {
-           if (IoIFP(io))
-               report_wrongway_fh(gv, '<');
-           else if (ckWARN(WARN_CLOSED))
-               report_evil_fh(gv);
-       }
+       if (IoIFP(io))
+           report_wrongway_fh(gv, '<');
+       else if (ckWARN(WARN_CLOSED))
+           report_evil_fh(gv);
        PUSHs(&PL_sv_no);
     }
     else {
@@ -1517,12 +1515,10 @@ PP(pp_prtf)
        goto just_say_no;
     }
     else if (!(fp = IoOFP(io))) {
-       if (ckWARN2(WARN_CLOSED,WARN_IO))  {
-           if (IoIFP(io))
-               report_wrongway_fh(gv, '<');
-           else if (ckWARN(WARN_CLOSED))
-               report_evil_fh(gv);
-       }
+       if (IoIFP(io))
+           report_wrongway_fh(gv, '<');
+       else if (ckWARN(WARN_CLOSED))
+           report_evil_fh(gv);
        SETERRNO(EBADF,IoIFP(io)?RMS_FAC:RMS_IFI);
        goto just_say_no;
     }
@@ -1763,7 +1759,7 @@ PP(pp_sysread)
            count = -1;
     }
     if (count < 0) {
-       if ((IoTYPE(io) == IoTYPE_WRONLY) && ckWARN(WARN_IO))
+       if (IoTYPE(io) == IoTYPE_WRONLY)
            report_wrongway_fh(gv, '>');
        goto say_undef;
     }