This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Build fixes for Win32 after the Coverity smoke.
[perl5.git] / dist / IO / IO.xs
index eed7139..4b13feb 100644 (file)
@@ -566,11 +566,10 @@ sockatmark (sock)
    InputStream sock
    PROTOTYPE: $
    PREINIT:
-     int fd;
+     int fd = PerlIO_fileno(sock);
    CODE:
    {
 #ifdef HAS_SOCKATMARK
-     int fd = PerlIO_fileno(sock);
      if (fd < 0) {
        errno = EBADF;
        RETVAL = -1;
@@ -579,6 +578,11 @@ sockatmark (sock)
      }
 #else
      {
+     if (fd < 0) {
+       errno = EBADF;
+       RETVAL = -1;
+     }
+     else {
        int flag = 0;
 #   ifdef SIOCATMARK
 #     if defined(NETWARE) || defined(WIN32)
@@ -592,6 +596,7 @@ sockatmark (sock)
 #   endif
        RETVAL = flag;
      }
+     }
 #endif
    }
    OUTPUT: