aboutsummaryrefslogtreecommitdiff
path: root/sf-pcapng.c
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-05-16 15:21:11 +0200
committerfxlb <devel.fx.lebail@orange.fr>2023-05-18 09:51:11 +0000
commitf8e510aaefcb0c229ce72116c3b6902bf2e3da63 (patch)
tree4cd980faa1da2fabdcce38ec80a9ec5f8156232b /sf-pcapng.c
parentc7b90298984c46d820d3cee79a96d24870b5f200 (diff)
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.
Diffstat (limited to 'sf-pcapng.c')
-rw-r--r--sf-pcapng.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sf-pcapng.c b/sf-pcapng.c
index 058a7244..cf87ac66 100644
--- a/sf-pcapng.c
+++ b/sf-pcapng.c
@@ -352,7 +352,7 @@ read_block(FILE *fp, pcap_t *p, struct block_cursor *cursor, char *errbuf)
* of the block.
*/
memcpy(p->buffer, &bhdr, sizeof(bhdr));
- bdata = (u_char *)p->buffer + sizeof(bhdr);
+ bdata = p->buffer + sizeof(bhdr);
data_remaining = bhdr.total_length - sizeof(bhdr);
if (read_bytes(fp, bdata, data_remaining, 1, errbuf) == -1)
return (-1);
@@ -943,12 +943,12 @@ pcap_ng_check_header(const uint8_t *magic, FILE *fp, u_int precision,
* of the SHB.
*/
bhdrp = (struct block_header *)p->buffer;
- shbp = (struct section_header_block *)((u_char *)p->buffer + sizeof(struct block_header));
+ shbp = (struct section_header_block *)(p->buffer + sizeof(struct block_header));
bhdrp->block_type = magic_int;
bhdrp->total_length = total_length;
shbp->byte_order_magic = byte_order_magic;
if (read_bytes(fp,
- (u_char *)p->buffer + (sizeof(magic_int) + sizeof(total_length) + sizeof(byte_order_magic)),
+ p->buffer + (sizeof(magic_int) + sizeof(total_length) + sizeof(byte_order_magic)),
total_length - (sizeof(magic_int) + sizeof(total_length) + sizeof(byte_order_magic)),
1, errbuf) == -1)
goto fail;