summaryrefslogtreecommitdiff
path: root/Xtrans.c
diff options
context:
space:
mode:
authorKim Woelders <kim@woelders.dk>2024-03-28 17:29:26 +0100
committerKim Woelders <kim@woelders.dk>2024-04-03 20:04:07 +0200
commit6171150fe9f8edad3f1cfb14cec59e6a42a9c15b (patch)
tree19cbcce5e02b45a55c9c2c5c5537c3a03ad8e37d /Xtrans.c
parentc219be946b1d8a641dcbc7a60904293f105e2866 (diff)
TRANS(ParseAddress): Fix "assignment discards ‘const’ qualifier" warnings
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 <kim@woelders.dk> Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxtrans/-/merge_requests/16>
Diffstat (limited to 'Xtrans.c')
-rw-r--r--Xtrans.c11
1 files 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