From ea1935252e287b63f04c6d460cfb85e4e5efe379 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Tue, 18 Jul 2023 14:43:36 +0900 Subject: [PATCH] commond: Introduce FD2NUM to express conversion to number of fds. * common/sysutils.h (FD2NUM): New. * agent/call-pinentry.c (watch_sock): Use FD2NUM. * agent/gpg-agent.c (handle_connections): Likewise. * dirmngr/dirmngr.c (handle_connections): Likewise. * dirmngr/http.c (connect_with_timeout): Likewise. * kbx/keyboxd.c (handle_connections): Likewise. * scd/scdaemon.c (handle_connections): Likewise. * tpm2d/tpm2daemon.c (handle_connections): Likewise. -- GnuPG-bug-id: 6598 Signed-off-by: NIIBE Yutaka --- agent/call-pinentry.c | 2 +- agent/gpg-agent.c | 8 ++++---- common/sysutils.h | 2 ++ dirmngr/dirmngr.c | 2 +- dirmngr/http.c | 2 +- kbx/keyboxd.c | 2 +- scd/scdaemon.c | 2 +- tpm2d/tpm2daemon.c | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c index 2369dffc2..9d8d93aec 100644 --- a/agent/call-pinentry.c +++ b/agent/call-pinentry.c @@ -1302,7 +1302,7 @@ watch_sock (void *arg) FD_ZERO (&fdset); FD_SET (FD2INT (sock), &fdset); - err = npth_select (FD2INT (sock)+1, &fdset, NULL, NULL, &timeout); + err = npth_select (FD2NUM (sock)+1, &fdset, NULL, NULL, &timeout); if (err < 0) { diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index de33d0b4e..335d389c6 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -3070,24 +3070,24 @@ handle_connections (gnupg_fd_t listen_fd, FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); - nfd = FD2INT (listen_fd); + nfd = FD2NUM (listen_fd); if (listen_fd_extra != GNUPG_INVALID_FD) { FD_SET ( FD2INT(listen_fd_extra), &fdset); if (FD2INT (listen_fd_extra) > nfd) - nfd = FD2INT (listen_fd_extra); + nfd = FD2NUM (listen_fd_extra); } if (listen_fd_browser != GNUPG_INVALID_FD) { FD_SET ( FD2INT(listen_fd_browser), &fdset); if (FD2INT (listen_fd_browser) > nfd) - nfd = FD2INT (listen_fd_browser); + nfd = FD2NUM (listen_fd_browser); } if (listen_fd_ssh != GNUPG_INVALID_FD) { FD_SET ( FD2INT(listen_fd_ssh), &fdset); if (FD2INT (listen_fd_ssh) > nfd) - nfd = FD2INT (listen_fd_ssh); + nfd = FD2NUM (listen_fd_ssh); } if (sock_inotify_fd != -1) { diff --git a/common/sysutils.h b/common/sysutils.h index e34fff72f..dac2d9244 100644 --- a/common/sysutils.h +++ b/common/sysutils.h @@ -44,12 +44,14 @@ typedef void *gnupg_fd_t; # define FD2INT(h) ((unsigned int)(h)) # endif #define FD_DBG(h) ((int)(intptr_t)(h)) +#define FD2NUM(h) ((int)(intptr_t)(h)) #else typedef int gnupg_fd_t; #define GNUPG_INVALID_FD (-1) #define INT2FD(s) (s) #define FD2INT(h) (h) #define FD_DBG(h) (h) +#define FD2NUM(h) (h) #endif #ifdef HAVE_STAT diff --git a/dirmngr/dirmngr.c b/dirmngr/dirmngr.c index 8b0fefc64..57f515b40 100644 --- a/dirmngr/dirmngr.c +++ b/dirmngr/dirmngr.c @@ -2377,7 +2377,7 @@ handle_connections (assuan_fd_t listen_fd) to full second. */ FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); - nfd = FD2INT (listen_fd); + nfd = FD2NUM (listen_fd); if (my_inotify_fd != -1) { FD_SET (my_inotify_fd, &fdset); diff --git a/dirmngr/http.c b/dirmngr/http.c index 2345ce8c1..a7fd6ec26 100644 --- a/dirmngr/http.c +++ b/dirmngr/http.c @@ -2906,7 +2906,7 @@ connect_with_timeout (assuan_fd_t sock, tval.tv_sec = timeout / 1000; tval.tv_usec = (timeout % 1000) * 1000; - n = my_select (FD2INT(sock)+1, &rset, &wset, NULL, &tval); + n = my_select (FD2NUM(sock)+1, &rset, &wset, NULL, &tval); if (n < 0) { err = gpg_err_make (default_errsource, gpg_err_code_from_syserror ()); diff --git a/kbx/keyboxd.c b/kbx/keyboxd.c index 8fbc36195..bfb0c653d 100644 --- a/kbx/keyboxd.c +++ b/kbx/keyboxd.c @@ -1521,7 +1521,7 @@ handle_connections (gnupg_fd_t listen_fd) FD_ZERO (&fdset); FD_SET (FD2INT (listen_fd), &fdset); - nfd = FD2INT (listen_fd); + nfd = FD2NUM (listen_fd); if (sock_inotify_fd != -1) { FD_SET (sock_inotify_fd, &fdset); diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 6422ebec9..653fc78cc 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -1313,7 +1313,7 @@ handle_connections (gnupg_fd_t listen_fd) if (listen_fd != GNUPG_INVALID_FD) { FD_SET (FD2INT (listen_fd), &fdset); - nfd = FD2INT (listen_fd); + nfd = FD2NUM (listen_fd); } for (;;) diff --git a/tpm2d/tpm2daemon.c b/tpm2d/tpm2daemon.c index 3246cfc9a..383421c30 100644 --- a/tpm2d/tpm2daemon.c +++ b/tpm2d/tpm2daemon.c @@ -1154,7 +1154,7 @@ handle_connections (gnupg_fd_t listen_fd) if (listen_fd != GNUPG_INVALID_FD) { FD_SET (FD2INT (listen_fd), &fdset); - nfd = FD2INT (listen_fd); + nfd = FD2NUM (listen_fd); } for (;;)