From f8e510aaefcb0c229ce72116c3b6902bf2e3da63 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Tue, 16 May 2023 15:21:11 +0200 Subject: struct pcap: Update buffer type from "void *" to "u_char *" This change should avoid these cppcheck warnings: pcap-hurd.c:77:18: warning: 'p->buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] pkt = p->buffer + offsetof(struct net_rcv_msg, packet) ^ pcap-hurd.c:78:8: warning: 'p->buffer+offsetof(struct net_rcv_msg,packet)' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] + sizeof(struct packet_header) - ETH_HLEN; ^ pcap-hurd.c:79:25: warning: 'p->buffer' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined. [arithOperationsOnVoidPointer] memmove(pkt, p->buffer + offsetof(struct net_rcv_msg, header), ^ Remove some '(u_char *)' casts accordingly. --- pcap-snit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pcap-snit.c') diff --git a/pcap-snit.c b/pcap-snit.c index 3f4e69d7..0bd4dabe 100644 --- a/pcap-snit.c +++ b/pcap-snit.c @@ -133,7 +133,7 @@ pcap_read_snit(pcap_t *p, int cnt, pcap_handler callback, u_char *user) errno, "pcap_read"); return (-1); } - bp = (u_char *)p->buffer; + bp = p->buffer; } else bp = p->bp; -- cgit v1.2.3