ctdb-common: Fix a warning in the pcap code
authorMartin Schwenke <martin@meltin.net>
Mon, 8 Aug 2022 01:31:03 +0000 (11:31 +1000)
committerJule Anger <janger@samba.org>
Tue, 29 Aug 2023 09:35:11 +0000 (09:35 +0000)
[173/416] Compiling ctdb/common/system_socket.c
../../common/system_socket.c: In function ‘ctdb_sys_read_tcp_packet’:
../../common/system_socket.c:1016:15: error: cast discards ‘const’ qualifier from pointer target type [-Werror=cast-qual]
 1016 |         eth = (struct ether_header *)buffer;
      |               ^

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit 8b54587b1aed28aa2f3af7161a077aa9dd83894c)

ctdb/common/system_socket.c

index ced2b17fc211604afe01497f596ccd5d37d2d12a..71c60853ee31fb365501ee31ee858242af93ba28 100644 (file)
@@ -998,7 +998,7 @@ int ctdb_sys_read_tcp_packet(int s,
                             uint16_t *window)
 {
        int ret;
-       struct ether_header *eth;
+       const struct ether_header *eth;
        struct pcap_pkthdr pkthdr;
        const u_char *buffer;
        pcap_t *pt = (pcap_t *)private_data;
@@ -1012,7 +1012,7 @@ int ctdb_sys_read_tcp_packet(int s,
        ZERO_STRUCTP(dst);
 
        /* Ethernet */
-       eth = (struct ether_header *)buffer;
+       eth = (const struct ether_header *)buffer;
 
        /* we want either IPv4 or IPv6 */
        if (eth->ether_type == htons(ETHERTYPE_IP)) {