From 6171150fe9f8edad3f1cfb14cec59e6a42a9c15b Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Thu, 28 Mar 2024 17:29:26 +0100 Subject: =?UTF-8?q?TRANS(ParseAddress):=20Fix=20"assignment=20discards=20?= =?UTF-8?q?=E2=80=98const=E2=80=99=20qualifier"=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Occurs when compiling xserver master with gcc 13.2.1. In file included from /local/stuff/xorg/include/X11/Xtrans/transport.c:69, from ../os/xstrans.c:17: /local/stuff/xorg/include/X11/Xtrans/Xtrans.c: In function ‘_XSERVTransParseAddress’: /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:216:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 216 | _host = ""; | ^ /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:217:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 217 | _port = address; | ^ /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:229:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 229 | _host = ""; | ^ /local/stuff/xorg/include/X11/Xtrans/Xtrans.c:230:15: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 230 | _port = address + 5; | ^ Signed-off-by: Kim Woelders Part-of: --- Xtrans.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Xtrans.c b/Xtrans.c index 12eefe8..3f50f6a 100644 --- a/Xtrans.c +++ b/Xtrans.c @@ -204,8 +204,9 @@ TRANS(ParseAddress) (const char *address, char *mybuf, *tmpptr = NULL; const char *_protocol = NULL; - char *_host, *_port; + const char *_host, *_port; char hostnamebuf[256]; + char *_host_buf; int _host_len; prmsg (3,"ParseAddress(%s)\n", address); @@ -293,7 +294,7 @@ TRANS(ParseAddress) (const char *address, /* Get the host part */ - _host = mybuf; + _host = _host_buf = mybuf; if ((mybuf = strrchr (mybuf,':')) == NULL) { @@ -316,10 +317,10 @@ TRANS(ParseAddress) (const char *address, /* hostname in IPv6 [numeric_addr]:0 form? */ else if ( (_host_len > 3) && ((strcmp(_protocol, "tcp") == 0) || (strcmp(_protocol, "inet6") == 0)) - && (*_host == '[') && (*(_host + _host_len - 1) == ']') ) { + && (_host_buf[0] == '[') && (_host_buf[_host_len - 1] == ']') ) { struct sockaddr_in6 sin6; - *(_host + _host_len - 1) = '\0'; + _host_buf[_host_len - 1] = '\0'; /* Verify address is valid IPv6 numeric form */ if (inet_pton(AF_INET6, _host + 1, &sin6) == 1) { @@ -328,7 +329,7 @@ TRANS(ParseAddress) (const char *address, _protocol = "inet6"; } else { /* It's not, restore it just in case some other code can use it. */ - *(_host + _host_len - 1) = ']'; + _host_buf[_host_len - 1] = ']'; } } #endif -- cgit v1.2.3