public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor
@ 2017-04-20 13:58 Ulf Hermann
  2017-05-02 14:43 ` Mark Wielaard
  0 siblings, 1 reply; 2+ messages in thread
From: Ulf Hermann @ 2017-04-20 13:58 UTC (permalink / raw)
  To: elfutils-devel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor
  2017-04-20 13:58 [PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor Ulf Hermann
@ 2017-05-02 14:43 ` Mark Wielaard
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Wielaard @ 2017-05-02 14:43 UTC (permalink / raw)
  To: Ulf Hermann; +Cc: elfutils-devel

On Thu, 2017-04-20 at 15:58 +0200, Ulf Hermann wrote:
> F_GETFD is both cheaper and easier to port, and otherwise has the same
> effect here.

At least for the specific case of checking for failure with errno ==
EBADF it is identical. Applied to master.

Thanks,

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-05-02 11:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 13:58 [PATCH] Use F_GETFD rather than F_GETFL to check validity of file descriptor Ulf Hermann
2017-05-02 14:43 ` Mark Wielaard

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 read-only IMAP folder(s) and NNTP newsgroup(s).