From: Father Chrysostomos Date: Sat, 14 Jan 2012 08:33:15 +0000 (-0800) Subject: Don’t emit unopened warning for other stat(HANDLE) error X-Git-Tag: accepted/trunk/20130322.191538~1183 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8080e3c81732aa2a08a2191391ba00b29588ab46;p=platform%2Fupstream%2Fperl.git Don’t emit unopened warning for other stat(HANDLE) error -r or -T on a GV with no IO or on an IO with no fp (or dirp for -r) will produce an ‘unopened’ warning. stat() on a filehandle will warn about an unopened filehandle not only if there is no fp, but also if the fstat call fails (with errno containing EBADP, EFAULT or EIO, at least on Darwin). I don’t know if there is a way to test this. (But pp_stat and my_stat_flags are getting closer, so this must be correct. :-) --- diff --git a/pp_sys.c b/pp_sys.c index 7767764..88e2f4e 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -2759,6 +2759,7 @@ PP(pp_stat) if (PL_op->op_flags & OPf_REF ? (gv = cGVOP_gv, 1) : !!(sv=POPs, gv = MAYBE_DEREF_GV(sv))) { + bool havefp = FALSE; if (PL_op->op_type == OP_LSTAT) { if (gv != PL_defgv) { do_fstat_warning_check: @@ -2784,9 +2785,11 @@ PP(pp_stat) if (IoIFP(io)) { PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache); + havefp = TRUE; } else if (IoDIRP(io)) { PL_laststatval = PerlLIO_fstat(my_dirfd(IoDIRP(io)), &PL_statcache); + havefp = TRUE; } else { PL_laststatval = -1; } @@ -2795,7 +2798,7 @@ PP(pp_stat) } if (PL_laststatval < 0) { - report_evil_fh(gv); + if (!havefp) report_evil_fh(gv); max = 0; } }