diff options
author | Daniel Dragan <bulk88@hotmail.com> | 2013-12-22 01:39:09 -0500 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-12-23 08:25:08 -0800 |
commit | e0b7b5e2d45f1c3adc7e7f4afb29a4cfa6ca788c (patch) | |
tree | 07bf00a7c7dc61fa63157e2a1ef07cd58ecf3c1d /pp_sys.c | |
parent | e8f91c91cc7c3a4a35c08d16f350eabe4852cdf4 (diff) | |
download | perl-e0b7b5e2d45f1c3adc7e7f4afb29a4cfa6ca788c.tar.gz |
refactor pp_socket, pp_socketpair, pp_bind
pp_socket: remove unreachable made by commit 9c9f25b8ce
pp_socketpair: increase locality, now gv2/io2 is tested before gv1 is
processed, *v1 vars become non-const to avoid large WS changes in
opening new scope
pp_bind: move op_type's init so it isn't saved by CC across a func call
Diffstat (limited to 'pp_sys.c')
-rw-r--r-- | pp_sys.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -2379,8 +2379,6 @@ PP(pp_socket) if (!io) { report_evil_fh(gv); - if (io && IoIFP(io)) - do_close(gv, FALSE); SETERRNO(EBADF,LIB_INVARG); RETPUSHUNDEF; } @@ -2413,19 +2411,22 @@ PP(pp_sockpair) { #if defined (HAS_SOCKETPAIR) || (defined (HAS_SOCKET) && defined(SOCK_DGRAM) && defined(AF_INET) && defined(PF_INET)) dVAR; dSP; + int fd[2]; const int protocol = POPi; const int type = POPi; const int domain = POPi; + GV * gv1; + IO * io1; + GV * const gv2 = MUTABLE_GV(POPs); - GV * const gv1 = MUTABLE_GV(POPs); - IO * const io1 = gv1 ? GvIOn(gv1) : NULL; IO * const io2 = gv2 ? GvIOn(gv2) : NULL; - int fd[2]; + if (!io2) + report_evil_fh(gv2); + gv1 = MUTABLE_GV(POPs); + io1 = gv1 ? GvIOn(gv1) : NULL; if (!io1) report_evil_fh(gv1); - if (!io2) - report_evil_fh(gv2); if (io1 && IoIFP(io1)) do_close(gv1, FALSE); @@ -2475,12 +2476,13 @@ PP(pp_bind) GV * const gv = MUTABLE_GV(POPs); IO * const io = GvIOn(gv); STRLEN len; - const int op_type = PL_op->op_type; + int op_type; if (!io || !IoIFP(io)) goto nuts; addr = SvPV_const(addrsv, len); + op_type = PL_op->op_type; TAINT_PROPER(PL_op_desc[op_type]); if ((op_type == OP_BIND ? PerlSock_bind(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) |