diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-12-28 09:50:49 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-12-28 10:04:09 +0000 |
commit | 51087808ceed79175a75ce3a398a755b78f57a75 (patch) | |
tree | 8c7a4646269e7dcc18f10dca6b4a0136c153785f /doio.c | |
parent | 7716c5c554409ba94e8dd56116adbde29e4d5b6c (diff) | |
download | perl-51087808ceed79175a75ce3a398a755b78f57a75.tar.gz |
As report_evil_fh() checks WARN_{CLOSED,UNOPENED}, don't duplicate this.
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.)
Removing the check from Perl_do_close() does not change behaviour, as io is
NULL there, hence Perl_report_evil_fh() will always be checking WARN_UNOPENED
and setting vile to "unopened".
Diffstat (limited to 'doio.c')
-rw-r--r-- | doio.c | 18 |
1 files changed, 6 insertions, 12 deletions
@@ -929,8 +929,7 @@ Perl_do_close(pTHX_ GV *gv, bool not_implicit) io = GvIO(gv); if (!io) { /* never opened */ if (not_implicit) { - if (ckWARN(WARN_UNOPENED)) /* no check for closed here */ - report_evil_fh(gv); + report_evil_fh(gv); SETERRNO(EBADF,SS_IVCHAN); } return FALSE; @@ -1047,8 +1046,7 @@ Perl_do_tell(pTHX_ GV *gv) #endif return PerlIO_tell(fp); } - if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) - report_evil_fh(gv); + report_evil_fh(gv); SETERRNO(EBADF,RMS_IFI); return (Off_t)-1; } @@ -1067,8 +1065,7 @@ Perl_do_seek(pTHX_ GV *gv, Off_t pos, int whence) #endif return PerlIO_seek(fp, pos, whence) >= 0; } - if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) - report_evil_fh(gv); + report_evil_fh(gv); SETERRNO(EBADF,RMS_IFI); return FALSE; } @@ -1084,8 +1081,7 @@ Perl_do_sysseek(pTHX_ GV *gv, Off_t pos, int whence) if (gv && (io = GvIO(gv)) && (fp = IoIFP(io))) return PerlLIO_lseek(PerlIO_fileno(fp), pos, whence); - if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) - report_evil_fh(gv); + report_evil_fh(gv); SETERRNO(EBADF,RMS_IFI); return (Off_t)-1; } @@ -1284,13 +1280,11 @@ Perl_my_stat_flags(pTHX_ const U32 flags) } else if (IoDIRP(io)) { return (PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache)); } else { - if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) - report_evil_fh(gv); + report_evil_fh(gv); return (PL_laststatval = -1); } } else { - if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) - report_evil_fh(gv); + report_evil_fh(gv); return (PL_laststatval = -1); } } |