linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linux-ext4@vger.kernel.org
Subject: [PATCH 13/38] lib/{e2p,ss}: remove manual declarations of errno
Date: Sat, 21 Jan 2023 12:32:05 -0800	[thread overview]
Message-ID: <20230121203230.27624-14-ebiggers@kernel.org> (raw)
In-Reply-To: <20230121203230.27624-1-ebiggers@kernel.org>

From: Eric Biggers <ebiggers@google.com>

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>
---
 lib/e2p/fgetversion.c | 2 --
 lib/e2p/fsetversion.c | 1 -
 lib/e2p/getversion.c  | 1 -
 lib/e2p/setversion.c  | 1 -
 lib/ss/execute_cmd.c  | 2 --
 lib/ss/help.c         | 2 --
 lib/ss/pager.c        | 2 --
 7 files changed, 11 deletions(-)

diff --git a/lib/e2p/fgetversion.c b/lib/e2p/fgetversion.c
index a65e9a5c5..f3a5b4cdf 100644
--- a/lib/e2p/fgetversion.c
+++ b/lib/e2p/fgetversion.c
@@ -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)
diff --git a/lib/e2p/fsetversion.c b/lib/e2p/fsetversion.c
index c2e045591..5f844b55e 100644
--- a/lib/e2p/fsetversion.c
+++ b/lib/e2p/fsetversion.c
@@ -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 */
diff --git a/lib/e2p/getversion.c b/lib/e2p/getversion.c
index 9f719b4a9..d374a0ea7 100644
--- a/lib/e2p/getversion.c
+++ b/lib/e2p/getversion.c
@@ -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 */
diff --git a/lib/e2p/setversion.c b/lib/e2p/setversion.c
index 2bc933749..dd4a3f06b 100644
--- a/lib/e2p/setversion.c
+++ b/lib/e2p/setversion.c
@@ -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 */
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index 2e2c8cfa0..d092134a3 100644
--- a/lib/ss/execute_cmd.c
+++ b/lib/ss/execute_cmd.c
@@ -17,8 +17,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 #include "ss_internal.h"
 #include <stdio.h>
diff --git a/lib/ss/help.c b/lib/ss/help.c
index a22b40178..54c78f239 100644
--- a/lib/ss/help.c
+++ b/lib/ss/help.c
@@ -20,8 +20,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 #include <fcntl.h>
 #include <sys/param.h>
diff --git a/lib/ss/pager.c b/lib/ss/pager.c
index b9b889962..ba32b2019 100644
--- a/lib/ss/pager.c
+++ b/lib/ss/pager.c
@@ -20,8 +20,6 @@
 #endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
-#else
-extern int errno;
 #endif
 
 #include "ss_internal.h"
-- 
2.39.0


  parent reply	other threads:[~2023-01-21 20:36 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-21 20:31 [PATCH 00/38] e2fsprogs: misc fixes, and add a GitHub Actions file Eric Biggers
2023-01-21 20:31 ` [PATCH 01/38] configure.ac: only use Windows I/O manager on native Windows Eric Biggers
2023-01-21 20:31 ` [PATCH 02/38] configure.ac: disable tdb by default on Windows Eric Biggers
2023-01-21 20:31 ` [PATCH 03/38] configure.ac: automatically add include/mingw/ headers Eric Biggers
2023-01-21 20:31 ` [PATCH 04/38] configure: regenerate Eric Biggers
2023-01-21 20:31 ` [PATCH 05/38] config/install-sh: update to latest version Eric Biggers
2023-01-21 20:31 ` [PATCH 06/38] lib, misc: eliminate dependency on Winsock Eric Biggers
2023-01-21 20:31 ` [PATCH 07/38] lib/blkid: remove 32-bit x86 byteswap assembly Eric Biggers
2023-01-24 18:21   ` Andreas Dilger
2023-01-21 20:32 ` [PATCH 08/38] lib/blkid: fix unaligned access to hfs_mdb Eric Biggers
2023-01-21 20:32 ` [PATCH 09/38] lib/blkid: fix -Wunused-variable warning in blkid_get_dev_size() Eric Biggers
2023-01-21 20:32 ` [PATCH 10/38] lib/blkid: suppress -Wunused-result warning in blkid_flush_cache() Eric Biggers
2023-01-21 20:32 ` [PATCH 11/38] lib/blkid: suppress -Wstringop-truncation warning in blkid_strndup() Eric Biggers
2023-01-21 20:32 ` [PATCH 12/38] lib/e2p: fix a -Wunused-variable warning in getflags() Eric Biggers
2023-01-21 20:32 ` Eric Biggers [this message]
2023-01-21 20:32 ` [PATCH 14/38] lib/et: fix "unused variable" warnings when !HAVE_FCNTL Eric Biggers
2023-01-21 20:32 ` [PATCH 15/38] lib/ext2fs: remove 32-bit x86 bitops assembly Eric Biggers
2023-01-21 20:32 ` [PATCH 16/38] lib/ext2fs: consistently use #ifdefs in ext2fs_print_bmap_statistics() Eric Biggers
2023-01-21 20:32 ` [PATCH 17/38] lib/ext2fs: remove unused variable in ext2fs_xattrs_read_inode() Eric Biggers
2023-01-21 20:32 ` [PATCH 18/38] lib/ext2fs: fix a printf format specifier in file_test() Eric Biggers
2023-01-21 20:32 ` [PATCH 19/38] lib/ext2fs: fix two compiler warnings in windows_io.c Eric Biggers
2023-01-21 20:32 ` [PATCH 20/38] lib/ext2fs: fix a -Wpointer-sign warning in ext2fs_mmp_start() Eric Biggers
2023-01-21 20:32 ` [PATCH 21/38] lib/{ext2fs,support}: fix 32-bit Windows build Eric Biggers
2023-01-21 20:32 ` [PATCH 22/38] lib/ss: fix 'make install' by creating man1dir Eric Biggers
2023-01-21 20:32 ` [PATCH 23/38] lib/support: remove unused label in get_devname() Eric Biggers
2023-01-21 20:32 ` [PATCH 24/38] lib/support: clean up definition of flags_array Eric Biggers
2023-01-21 20:32 ` [PATCH 25/38] lib/uuid: remove conflicting Windows implementation of gettimeofday() Eric Biggers
2023-01-21 20:32 ` [PATCH 26/38] e2fsck: use real functions for kernel slab functions Eric Biggers
2023-01-21 20:32 ` [PATCH 27/38] misc/create_inode: fix -Wunused-variable warnings in __populate_fs() Eric Biggers
2023-01-21 20:32 ` [PATCH 28/38] misc/create_inode: simplify logic in scandir() Eric Biggers
2023-01-21 20:32 ` [PATCH 29/38] misc/e4defrag: fix -Wstringop-truncation warnings Eric Biggers
2023-01-21 20:32 ` [PATCH 30/38] misc/fuse2fs: avoid error-prone strncpy() pattern Eric Biggers
2023-01-21 20:32 ` [PATCH 31/38] misc/mk_hugefiles: simplify get_partition_start() Eric Biggers
2023-01-21 20:32 ` [PATCH 32/38] misc/mke2fs: fix Windows build Eric Biggers
2023-01-21 20:32 ` [PATCH 33/38] misc/mke2fs: fix a -Wunused-variable warning in PRS() Eric Biggers
2023-01-21 20:32 ` [PATCH 34/38] misc/tune2fs: fix setting fsuuid::fsu_len Eric Biggers
2023-01-21 20:32 ` [PATCH 35/38] misc/tune2fs: fix -Wunused-variable warnings in handle_fslabel() Eric Biggers
2023-01-21 20:32 ` [PATCH 36/38] misc/util.c: enable MinGW alarm() when building for Windows Eric Biggers
2023-01-21 20:32 ` [PATCH 37/38] resize2fs: remove unused variable from adjust_superblock() Eric Biggers
2023-01-21 20:32 ` [PATCH 38/38] Add a configuration file for GitHub Actions Eric Biggers
2023-01-24 20:59 ` [PATCH 00/38] e2fsprogs: misc fixes, and add a GitHub Actions file Andreas Dilger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230121203230.27624-14-ebiggers@kernel.org \
    --to=ebiggers@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).