]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Silence compiler warnings [-Wdiscarded-qualifiers]
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Wed, 29 Dec 2021 13:10:53 +0000 (14:10 +0100)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 9 Apr 2022 10:06:07 +0000 (12:06 +0200)
It's just a quirk that free takes non-const: it doesn't actually modify
the value pointed to, either conceptually or in practice, it merely looks
up the memory block using the pointer and deallocates it.

Unfortunately, the compiler will emit  warning when attempting to free()
a "const char *". So either switch to a pointer to non-const or cast to
(void *) when calling free() on a pointer to const.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
wintun.c

index 5c544ab257a20a8969f5bac6697a27d59af085c2..b848579f514b8448090d6d8b90a7a19d48a1651b 100644 (file)
--- a/wintun.c
+++ b/wintun.c
@@ -169,7 +169,7 @@ int os_read_wintun(struct openconnect_info *vpninfo, struct pkt *pkt)
        if (!tun_pkt) {
                DWORD err = GetLastError();
                if (err != ERROR_NO_MORE_ITEMS) {
-                       const char *errstr = openconnect__win32_strerror(err);
+                       char *errstr = openconnect__win32_strerror(err);
                        vpn_progress(vpninfo, PRG_ERR, _("Could not retrieve packet from Wintun adapter '%S': %s\n"),
                                     vpninfo->ifname_w, errstr);
                        free(errstr);
@@ -196,7 +196,7 @@ int os_write_wintun(struct openconnect_info *vpninfo, struct pkt *pkt)
                                                 pkt->len);
        if (!tun_pkt) {
                DWORD err = GetLastError();
-               const char *errstr = openconnect__win32_strerror(err);
+               char *errstr = openconnect__win32_strerror(err);
                vpn_progress(vpninfo, PRG_ERR, _("Could not send packet through Wintun adapter '%S': %s\n"),
                             vpninfo->ifname_w, errstr);
                free(errstr);