This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Further simplify the sockatmark().
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 21:36:41 +0000 (17:36 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Thu, 29 May 2014 21:37:35 +0000 (17:37 -0400)
(And do not assign the fd in PREINIT.)

dist/IO/IO.xs

index 4b13feb..4dc9149 100644 (file)
@@ -566,22 +566,18 @@ sockatmark (sock)
    InputStream sock
    PROTOTYPE: $
    PREINIT:
    InputStream sock
    PROTOTYPE: $
    PREINIT:
-     int fd = PerlIO_fileno(sock);
+     int fd;
    CODE:
    CODE:
-   {
-#ifdef HAS_SOCKATMARK
+     fd = PerlIO_fileno(sock);
      if (fd < 0) {
        errno = EBADF;
        RETVAL = -1;
      if (fd < 0) {
        errno = EBADF;
        RETVAL = -1;
-     } else {
+     }
+#ifdef HAS_SOCKATMARK
+     else {
        RETVAL = sockatmark(fd);
      }
 #else
        RETVAL = sockatmark(fd);
      }
 #else
-     {
-     if (fd < 0) {
-       errno = EBADF;
-       RETVAL = -1;
-     }
      else {
        int flag = 0;
 #   ifdef SIOCATMARK
      else {
        int flag = 0;
 #   ifdef SIOCATMARK
@@ -596,9 +592,7 @@ sockatmark (sock)
 #   endif
        RETVAL = flag;
      }
 #   endif
        RETVAL = flag;
      }
-     }
 #endif
 #endif
-   }
    OUTPUT:
      RETVAL
 
    OUTPUT:
      RETVAL