[PATCH gnupg] Fix pointer to integer cast warnings in Windows platform
Biswapriyo Nath
nathbappai at gmail.com
Tue Sep 27 15:28:05 CEST 2022
-------------- next part --------------
From 6c042a15d268a28986642367fda57209026d0563 Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath <nathbappai at gmail.com>
Date: Tue, 27 Sep 2022 18:55:17 +0530
Subject: [PATCH gnupg] Fix pointer to integer cast warnings in Windows platform
Signed-off-by: Biswapriyo Nath <nathbappai at gmail.com>
---
agent/call-daemon.c | 2 +-
agent/call-pinentry.c | 2 +-
agent/command-ssh.c | 2 +-
common/exechelp-w32.c | 2 +-
common/iobuf.c | 8 ++++----
common/sysutils.c | 2 +-
common/sysutils.h | 4 ++--
dirmngr/http.c | 6 +++---
dirmngr/ldap-wrapper.c | 2 +-
g10/exec.c | 2 +-
tools/gpg-connect-agent.c | 8 ++++----
11 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/agent/call-daemon.c b/agent/call-daemon.c
index 0c36052..cb03f3a 100644
--- a/agent/call-daemon.c
+++ b/agent/call-daemon.c
@@ -472,7 +472,7 @@ daemon_start (enum daemon_type type, ctrl_t ctrl)
#ifdef HAVE_W32_SYSTEM
snprintf (buf, sizeof buf, "OPTION event-signal=%lx",
- (unsigned long)get_agent_daemon_notify_event ());
+ (unsigned long)(uintptr_t)get_agent_daemon_notify_event ());
#else
snprintf (buf, sizeof buf, "OPTION event-signal=%d", SIGUSR2);
#endif
diff --git a/agent/call-pinentry.c b/agent/call-pinentry.c
index c6c52be..aecdd6e 100644
--- a/agent/call-pinentry.c
+++ b/agent/call-pinentry.c
@@ -129,7 +129,7 @@ void
agent_query_dump_state (void)
{
log_info ("agent_query_dump_state: entry_ctx=%p pid=%ld popup_tid=%p\n",
- entry_ctx, (long)assuan_get_pid (entry_ctx), (void*)popup_tid);
+ entry_ctx, (long)assuan_get_pid (entry_ctx), (void*)(uintptr_t)popup_tid);
}
/* Called to make sure that a popup window owned by the current
diff --git a/agent/command-ssh.c b/agent/command-ssh.c
index ce2b5df..80e14e9 100644
--- a/agent/command-ssh.c
+++ b/agent/command-ssh.c
@@ -3779,7 +3779,7 @@ start_command_handler_ssh (ctrl_t ctrl, gnupg_fd_t sock_client)
es_syshd_t syshd;
syshd.type = ES_SYSHD_SOCK;
- syshd.u.sock = sock_client;
+ syshd.u.sock = FD2INT (sock_client);
err = agent_copy_startup_env (ctrl);
if (err)
diff --git a/common/exechelp-w32.c b/common/exechelp-w32.c
index 19cf85c..ac72cca 100644
--- a/common/exechelp-w32.c
+++ b/common/exechelp-w32.c
@@ -83,7 +83,7 @@
# define fd_to_handle(a) ((HANDLE)(a))
# define handle_to_fd(a) ((intptr_t)(a))
# define pid_to_handle(a) ((HANDLE)(a))
-# define handle_to_pid(a) ((int)(a))
+# define handle_to_pid(a) ((int)(intptr_t)(a))
/* Helper */
diff --git a/common/iobuf.c b/common/iobuf.c
index c88d679..e8e5da6 100644
--- a/common/iobuf.c
+++ b/common/iobuf.c
@@ -379,7 +379,7 @@ fd_cache_close (const char *fname, gnupg_fd_t fp)
close (fp);
#endif
if (DBG_IOBUF)
- log_debug ("fd_cache_close (%d) real\n", (int)fp);
+ log_debug ("fd_cache_close (%d) real\n", FD2INT (fp));
return;
}
/* try to reuse a slot */
@@ -2889,11 +2889,11 @@ translate_file_handle (int fd, int for_write)
(void)for_write;
if (fd == 0)
- x = (int) GetStdHandle (STD_INPUT_HANDLE);
+ x = FD2INT (GetStdHandle (STD_INPUT_HANDLE));
else if (fd == 1)
- x = (int) GetStdHandle (STD_OUTPUT_HANDLE);
+ x = FD2INT (GetStdHandle (STD_OUTPUT_HANDLE));
else if (fd == 2)
- x = (int) GetStdHandle (STD_ERROR_HANDLE);
+ x = FD2INT (GetStdHandle (STD_ERROR_HANDLE));
else
x = fd;
diff --git a/common/sysutils.c b/common/sysutils.c
index c30f9a0..4b260ce 100644
--- a/common/sysutils.c
+++ b/common/sysutils.c
@@ -564,7 +564,7 @@ translate_sys2libc_fd_int (int fd, int for_write)
if (fd <= 2)
return fd; /* Do not do this for error, stdin, stdout, stderr. */
- return translate_sys2libc_fd ((void*)fd, for_write);
+ return translate_sys2libc_fd (INT2FD (fd), for_write);
#else
(void)for_write;
return fd;
diff --git a/common/sysutils.h b/common/sysutils.h
index 7063da0..a157832 100644
--- a/common/sysutils.h
+++ b/common/sysutils.h
@@ -37,8 +37,8 @@
#ifdef HAVE_W32_SYSTEM
typedef void *gnupg_fd_t;
#define GNUPG_INVALID_FD ((void*)(-1))
-#define INT2FD(s) ((void *)(s))
-#define FD2INT(h) ((unsigned int)(h))
+#define INT2FD(s) ((void *)(uintptr_t)(s))
+#define FD2INT(h) ((unsigned int)(uintptr_t)(h))
#else
typedef int gnupg_fd_t;
#define GNUPG_INVALID_FD (-1)
diff --git a/dirmngr/http.c b/dirmngr/http.c
index 20f71f6..07e65e5 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -397,7 +397,7 @@ _my_socket_new (int lnr, assuan_fd_t fd)
so->refcount = 1;
if (opt_debug)
log_debug ("http.c:%d:socket_new: object %p for fd %d created\n",
- lnr, so, (int)so->fd);
+ lnr, so, FD2INT (so->fd));
return so;
}
#define my_socket_new(a) _my_socket_new (__LINE__, (a))
@@ -409,7 +409,7 @@ _my_socket_ref (int lnr, my_socket_t so)
so->refcount++;
if (opt_debug > 1)
log_debug ("http.c:%d:socket_ref: object %p for fd %d refcount now %d\n",
- lnr, so, (int)so->fd, so->refcount);
+ lnr, so, FD2INT (so->fd), so->refcount);
return so;
}
#define my_socket_ref(a) _my_socket_ref (__LINE__,(a))
@@ -427,7 +427,7 @@ _my_socket_unref (int lnr, my_socket_t so,
so->refcount--;
if (opt_debug > 1)
log_debug ("http.c:%d:socket_unref: object %p for fd %d ref now %d\n",
- lnr, so, (int)so->fd, so->refcount);
+ lnr, so, FD2INT (so->fd), so->refcount);
if (!so->refcount)
{
diff --git a/dirmngr/ldap-wrapper.c b/dirmngr/ldap-wrapper.c
index 446e543..ac29de9 100644
--- a/dirmngr/ldap-wrapper.c
+++ b/dirmngr/ldap-wrapper.c
@@ -571,7 +571,7 @@ ldap_reaper_launch_thread (void)
/* Wait until all ldap wrappers have terminated. We assume that the
kill has already been sent to all of them. */
void
-ldap_wrapper_wait_connections ()
+ldap_wrapper_wait_connections (void)
{
lock_reaper_list ();
{
diff --git a/g10/exec.c b/g10/exec.c
index 75b39e0..d91bcbb 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -86,7 +86,7 @@ w32_system(const char *command)
}
if (DBG_EXTPROG)
log_debug ("ShellExecuteEx succeeded (hProcess=%p,hInstApp=%d)\n",
- see.hProcess, (int)see.hInstApp);
+ see.hProcess, FD2INT (see.hInstApp));
if (!see.hProcess)
{
diff --git a/tools/gpg-connect-agent.c b/tools/gpg-connect-agent.c
index eb89728..1cc51e4 100644
--- a/tools/gpg-connect-agent.c
+++ b/tools/gpg-connect-agent.c
@@ -1038,8 +1038,8 @@ do_open (char *line)
}
if (opt.verbose)
log_info ("file '%s' opened in \"%s\" mode, fd=%d (libc=%d)\n",
- name, mode, (int)open_fd_table[fd].handle, fd);
- set_int_var (varname, (int)open_fd_table[fd].handle);
+ name, mode, FD2INT (open_fd_table[fd].handle), fd);
+ set_int_var (varname, FD2INT (open_fd_table[fd].handle));
#else /* Unix */
if (opt.verbose)
log_info ("file '%s' opened in \"%s\" mode, fd=%d\n",
@@ -1066,7 +1066,7 @@ do_close (char *line)
int i;
for (i=0; i < DIM (open_fd_table); i++)
- if ( open_fd_table[i].inuse && open_fd_table[i].handle == (void*)fd)
+ if ( open_fd_table[i].inuse && open_fd_table[i].handle == INT2FD (fd))
break;
if (i < DIM (open_fd_table))
fd = i;
@@ -1105,7 +1105,7 @@ do_showopen (void)
if (open_fd_table[i].inuse)
{
#ifdef HAVE_W32_SYSTEM
- printf ("%-15d (libc=%d)\n", (int)open_fd_table[i].handle, i);
+ printf ("%-15d (libc=%d)\n", FD2INT (open_fd_table[i].handle), i);
#else
printf ("%-15d\n", i);
#endif
--
2.37.3
More information about the Gnupg-devel
mailing list