This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
[PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor
- From: Ulf Hermann <ulf dot hermann at qt dot io>
- To: <elfutils-devel at sourceware dot org>
- Date: Thu, 20 Apr 2017 15:58:43 +0200
- Subject: [PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor
- Authentication-results: sourceware.org; auth=none
- Authentication-results: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=qt.io;
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qtcompany.onmicrosoft.com; s=selector1-qt-io; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=/N7CDZt1jCxsGZmW4gYbpG3UJm08KwCdxgGZ4/coTTA=; b=W6CdycCenwcqfbpkdASKJpLkmgrOtfPeBY7sz9g2nN7+ZcU+7Dpsf1FqnjvxTO+poc3Ummde6+Vq8ceLXDyhSVWaZ+4FapAm0+WcdcJEICme2ESuUbrww5CC03oDovuIavYk4qUO6x4nosHhNLFVbMfULb85AIHm+85ChC3Op1E=
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
F_GETFD is both cheaper and easier to port, and otherwise has the same
effect here.
Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
libelf/ChangeLog | 4 ++++
libelf/elf_begin.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 23cd942..e32590a 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,5 +1,9 @@
2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+ * elf_begin.c: Use F_GETFD rather than F_GETFL.
+
+2017-04-20 Ulf Hermann <ulf.hermann@qt.io>
+
* libelf.h: Define macros for various function attributes and use
them.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 5e9099c..6f85038 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -1075,7 +1075,7 @@ elf_begin (int fildes, Elf_Cmd cmd, Elf *ref)
if (ref != NULL)
/* Make sure the descriptor is not suddenly going away. */
rwlock_rdlock (ref->lock);
- else if (unlikely (fcntl (fildes, F_GETFL) == -1 && errno == EBADF))
+ else if (unlikely (fcntl (fildes, F_GETFD) == -1 && errno == EBADF))
{
/* We cannot do anything productive without a file descriptor. */
__libelf_seterrno (ELF_E_INVALID_FILE);
--
2.1.4