From f7f9fb5cb0f779bc1a648b264805d7e12abc4260 Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 10 May 2003 08:35:54 +0000 Subject: [PATCH] Fixes for Debian bug #192701 (64-bit gccs warn about casts between ptrs and ints of different size and -Werror makes this serious). The GTK bits are done by Colin's patch to use GINT_TO_POINTER (thanks); the uxnet bits are done by cleaning up the rest of the code. In particular, network.h now typedefs `OSSocket' to be a type capable of holding whatever the OS's socket data type is that underlies our socket abstraction. Individual platforms can make this typedef themselves if they define OSSOCKET_DEFINED to prevent network.h redoing it; so the Unix OSSocket is now int. Default is still void *, so other platforms should be unaffected. git-svn-id: svn://svn.tartarus.org/sgt/putty@3171 cda61777-01e9-0310-a592-d414129be87e --- network.h | 8 ++++++-- portfwd.c | 2 +- proxy.c | 2 +- proxy.h | 2 +- unix/gtkdlg.c | 11 +++++++---- unix/pterm.c | 5 +++-- unix/unix.h | 3 +++ unix/uxnet.c | 10 +++++----- 8 files changed, 27 insertions(+), 16 deletions(-) diff --git a/network.h b/network.h index ad45547d..9a7a50cf 100644 --- a/network.h +++ b/network.h @@ -25,6 +25,10 @@ typedef struct SockAddr_tag *SockAddr; typedef struct socket_function_table **Socket; typedef struct plug_function_table **Plug; +#ifndef OSSOCKET_DEFINED +typedef void *OSSocket; +#endif + struct socket_function_table { Plug(*plug) (Socket s, Plug p); /* use a different plug (return the old one) */ @@ -64,7 +68,7 @@ struct plug_function_table { * on a socket is cleared or partially cleared. The new backlog * size is passed in the `bufsize' parameter. */ - int (*accepting)(Plug p, void *sock); + int (*accepting)(Plug p, OSSocket sock); /* * returns 0 if the host at address addr is a valid host for connecting or error */ @@ -100,7 +104,7 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline, Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only); -Socket sk_register(void *sock, Plug plug); +Socket sk_register(OSSocket sock, Plug plug); #define sk_plug(s,p) (((*s)->plug) (s, p)) #define sk_close(s) (((*s)->close) (s)) diff --git a/portfwd.c b/portfwd.c index f73d22cc..00132ec6 100644 --- a/portfwd.c +++ b/portfwd.c @@ -381,7 +381,7 @@ const char *pfd_newconnect(Socket *s, char *hostname, int port, called when someone connects to the local port */ -static int pfd_accepting(Plug p, void *sock) +static int pfd_accepting(Plug p, OSSocket sock) { static const struct plug_function_table fn_table = { pfd_closing, diff --git a/proxy.c b/proxy.c index 11054df7..42b713e5 100644 --- a/proxy.c +++ b/proxy.c @@ -234,7 +234,7 @@ static void plug_proxy_sent (Plug p, int bufsize) plug_sent(ps->plug, bufsize); } -static int plug_proxy_accepting (Plug p, void *sock) +static int plug_proxy_accepting (Plug p, OSSocket sock) { Proxy_Plug pp = (Proxy_Plug) p; Proxy_Socket ps = pp->proxy_socket; diff --git a/proxy.h b/proxy.h index d4dec6a1..8f49e60b 100644 --- a/proxy.h +++ b/proxy.h @@ -77,7 +77,7 @@ struct Socket_proxy_tag { int sent_bufsize; /* accepting */ - void *accepting_sock; + OSSocket accepting_sock; /* configuration, used to look up proxy settings */ Config cfg; diff --git a/unix/gtkdlg.c b/unix/gtkdlg.c index a9383e75..ea39c5ed 100644 --- a/unix/gtkdlg.c +++ b/unix/gtkdlg.c @@ -374,7 +374,8 @@ void dlg_listbox_addwithid(union control *ctrl, void *dlg, gtk_container_add(GTK_CONTAINER(uc->menu), menuitem); gtk_widget_show(menuitem); - gtk_object_set_data(GTK_OBJECT(menuitem), "user-data", (gpointer)id); + gtk_object_set_data(GTK_OBJECT(menuitem), "user-data", + GINT_TO_POINTER(id)); gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(menuitem_activate), dp); } else if (!uc->entry) { @@ -436,7 +437,8 @@ void dlg_listbox_addwithid(union control *ctrl, void *dlg, GTK_SIGNAL_FUNC(widget_focus), dp); gtk_signal_connect(GTK_OBJECT(listitem), "button_press_event", GTK_SIGNAL_FUNC(listitem_button), dp); - gtk_object_set_data(GTK_OBJECT(listitem), "user-data", (gpointer)id); + gtk_object_set_data(GTK_OBJECT(listitem), "user-data", + GINT_TO_POINTER(id)); } else { /* * List item in a combo-box list, which means the sensible @@ -448,7 +450,8 @@ void dlg_listbox_addwithid(union control *ctrl, void *dlg, gtk_container_add(GTK_CONTAINER(uc->list), listitem); gtk_widget_show(listitem); - gtk_object_set_data(GTK_OBJECT(listitem), "user-data", (gpointer)id); + gtk_object_set_data(GTK_OBJECT(listitem), "user-data", + GINT_TO_POINTER(id)); } dp->flags &= ~FLAG_UPDATING_COMBO_LIST; @@ -470,7 +473,7 @@ int dlg_listbox_getid(union control *ctrl, void *dlg, int index) item = GTK_OBJECT(g_list_nth_data(children, index)); g_list_free(children); - return (int)gtk_object_get_data(GTK_OBJECT(item), "user-data"); + return GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(item), "user-data")); } /* dlg_listbox_index returns <0 if no single element is selected. */ diff --git a/unix/pterm.c b/unix/pterm.c index b9c88fb1..92adcb13 100644 --- a/unix/pterm.c +++ b/unix/pterm.c @@ -2485,7 +2485,8 @@ void copy_all_menuitem(GtkMenuItem *item, gpointer data) void special_menuitem(GtkMenuItem *item, gpointer data) { struct gui_data *inst = (struct gui_data *)data; - int code = (int)gtk_object_get_data(GTK_OBJECT(item), "user-data"); + int code = GPOINTER_TO_INT(gtk_object_get_data(GTK_OBJECT(item), + "user-data")); inst->back->special(inst->backhandle, code); } @@ -2836,7 +2837,7 @@ void update_specials_menu(void *frontend) if (*specials[i].name) { menuitem = gtk_menu_item_new_with_label(specials[i].name); gtk_object_set_data(GTK_OBJECT(menuitem), "user-data", - (gpointer)specials[i].code); + GINT_TO_POINTER(specials[i].code)); gtk_signal_connect(GTK_OBJECT(menuitem), "activate", GTK_SIGNAL_FUNC(special_menuitem), inst); } else diff --git a/unix/unix.h b/unix/unix.h index 28a026cb..dbb28d6f 100644 --- a/unix/unix.h +++ b/unix/unix.h @@ -15,6 +15,9 @@ struct FontSpec { typedef void *Context; /* FIXME: probably needs changing */ +typedef int OSSocket; +#define OSSOCKET_DEFINED /* stop network.h using its default */ + extern Backend pty_backend; /* diff --git a/unix/uxnet.c b/unix/uxnet.c index 77a4885b..7e5cf6f7 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -90,7 +90,7 @@ static int cmpfortree(void *av, void *bv) static int cmpforsearch(void *av, void *bv) { Actual_Socket b = (Actual_Socket) bv; - int as = (int) av, bs = b->s; + int as = *(int *)av, bs = b->s; if (as < bs) return -1; if (as > bs) @@ -336,7 +336,7 @@ static struct socket_function_table tcp_fn_table = { sk_tcp_socket_error }; -Socket sk_register(void *sock, Plug plug) +Socket sk_register(OSSocket sockfd, Plug plug) { Actual_Socket ret; @@ -357,7 +357,7 @@ Socket sk_register(void *sock, Plug plug) ret->oobpending = FALSE; ret->listener = 0; - ret->s = (int)sock; + ret->s = sockfd; if (ret->s < 0) { ret->error = error_string(errno); @@ -819,7 +819,7 @@ static int net_select_result(int fd, int event) u_long atmark; /* Find the Socket structure */ - s = find234(sktree, (void *) fd, cmpforsearch); + s = find234(sktree, &fd, cmpforsearch); if (!s) return 1; /* boggle */ @@ -876,7 +876,7 @@ static int net_select_result(int fd, int event) if (s->localhost_only && !ipv4_is_loopback(isa.sin_addr)) { close(t); /* someone let nonlocal through?! */ - } else if (plug_accepting(s->plug, (void*)t)) { + } else if (plug_accepting(s->plug, t)) { close(t); /* denied or error */ } break; -- 2.11.0