From 2b0c60dadf7c472476dbec1b5fe5f5d5b8217d84 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 13 Mar 2016 20:42:13 +0100 Subject: [PATCH] xspice/ipc/ipcsockets.c, choke some warnings Fixme, this code is simply broken, nobody seems to use it. One would need to change the socket protocol (message length) in agreement with the users of the protocol. For the time beeing, just suffocate the warnings in a way which does not change the broken behaviour of this code. --- src/xspice/ipc/ipcsockets.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/xspice/ipc/ipcsockets.c b/src/xspice/ipc/ipcsockets.c index 87c2730c7..f4fa48843 100644 --- a/src/xspice/ipc/ipcsockets.c +++ b/src/xspice/ipc/ipcsockets.c @@ -280,12 +280,25 @@ NON-STANDARD FEATURES =============================================================================*/ +/* FIXME, + * this is seriously broken, + * once it was probably based upon htonl(), + * yet with broken types + * then the game has changed and strtoul() was used + * with a ascii representation of the length + * (probably as a hacky workaround, because it proved unreliable) + * but the buffer is not terminated properly + * Fix this when needed, currently this functionality looks like + * an unused ancient artefact + * Fix it with regard to ipc_transport_get_line() and ipc_transport_send_line() + * and in concert with the actual user at the other side of the socket + */ static u_long bytes_to_integer ( char *str, /* IN - string that contains the bytes to convert */ int start ) /* IN - index into string where bytes are */ { - u_long u; /* Value to be returned */ + uint32_t u; /* Value to be returned */ char buff[4]; /* Transfer str into buff to word align reqd data */ int index; /* Index into str and buff for transfer */ @@ -299,7 +312,7 @@ bytes_to_integer ( index++; } /* u = ntohl (*((u_long *) buff)); */ - u = strtoul(buff, NULL, 10); + u = (uint32_t) strtoul(buff, NULL, 10); return u; } /* end bytes_to_integer */ @@ -658,7 +671,7 @@ ipc_transport_send_line ( /* Write message body header with length: */ hdr_buff[0] = BOL_CHAR; - u = htonl ((u_long) len); + u = htonl ((uint32_t) len); char_ptr = (char *) &u; for(i = 0; i < 4; i++) hdr_buff[i+1] = char_ptr[i];