Whamcloud - gitweb
lib/{e2p,ss}: remove manual declarations of errno
authorEric Biggers <ebiggers@google.com>
Sat, 21 Jan 2023 20:32:05 +0000 (12:32 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 27 Jan 2023 17:33:59 +0000 (12:33 -0500)
As per 'man 3 errno':

    On some ancient systems, <errno.h> was not present or did not
    declare errno, so that it was necessary to declare errno manually
    (i.e., extern int errno).   **Do not do this**.  It long ago ceased
    to be necessary, and it will cause problems with modern versions of
    the C library.

One of the platforms it causes a problem on is Windows:

    In file included from fgetversion.c:28:
    fgetversion.c: In function ‘fgetversion’:
    fgetversion.c:68:20: warning: ‘_errno’ redeclared without dllimport attribute: previous dllimport ignored [-Wattributes]
       68 |         extern int errno;
          |                    ^~~~~

Just remove these obsolete manual declarations of errno.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/e2p/fgetversion.c
lib/e2p/fsetversion.c
lib/e2p/getversion.c
lib/e2p/setversion.c
lib/ss/execute_cmd.c
lib/ss/help.c
lib/ss/pager.c

index a65e9a5..f3a5b4c 100644 (file)
@@ -65,8 +65,6 @@ int fgetversion(const char *name, unsigned long *version)
        rc = syscall(SYS_fsctl, name, EXT2_IOC_GETVERSION, &ver, 0);
 # endif /* !APPLE_DARWIN */
 #else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
-
        errno = EOPNOTSUPP;
 #endif /* ! HAVE_EXT2_IOCTLS */
        if (rc == 0)
index c2e0455..5f844b5 100644 (file)
@@ -65,7 +65,6 @@ int fsetversion (const char * name, unsigned long version)
    return syscall(SYS_fsctl, name, EXT2_IOC_SETVERSION, &ver, 0);
 #endif
 #else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
        errno = EOPNOTSUPP;
        return -1;
 #endif /* ! HAVE_EXT2_IOCTLS */
index 9f719b4..d374a0e 100644 (file)
@@ -35,7 +35,6 @@ int getversion (int fd, unsigned long * version)
        *version = ver;
        return r;
 #else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
        errno = EOPNOTSUPP;
        return -1;
 #endif /* ! HAVE_EXT2_IOCTLS */
index 2bc9337..dd4a3f0 100644 (file)
@@ -34,7 +34,6 @@ int setversion (int fd, unsigned long version)
        ver = (int) version;
        return ioctl (fd, EXT2_IOC_SETVERSION, &ver);
 #else /* ! HAVE_EXT2_IOCTLS */
-       extern int errno;
        errno = EOPNOTSUPP;
        return -1;
 #endif /* ! HAVE_EXT2_IOCTLS */
index 2e2c8cf..d092134 100644 (file)
@@ -17,8 +17,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 #include "ss_internal.h"
 #include <stdio.h>
index a22b401..54c78f2 100644 (file)
@@ -20,8 +20,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 #include <fcntl.h>
 #include <sys/param.h>
index b9b8899..ba32b20 100644 (file)
@@ -20,8 +20,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 
 #include "ss_internal.h"