Skip to content

Commit d83ccf0

Browse files
committed
Fix arithmetic on a pointer to void
This is a gnu extension reported as warning when using -Wall -Wextra -pedantic. Avoiding it is easy and more clear. main.c:167:51: warning: arithmetic on a pointer to void is a GNU extension [-Wgnu-pointer-arith] 167 | memcpy(src_mac, pdv[i].vm_pkt_iov[0].iov_base + 6, sizeof(src_mac)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ Signed-off-by: Nir Soffer <[email protected]>
1 parent 6101f67 commit d83ccf0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ static void _on_vmnet_packets_available(interface_ref iface, int64_t buf_count,
163163
for (int i = 0; i < received_count; i++) {
164164
uint8_t dest_mac[6], src_mac[6];
165165
assert(pdv[i].vm_pkt_iov[0].iov_len > 12);
166-
memcpy(dest_mac, pdv[i].vm_pkt_iov[0].iov_base, sizeof(dest_mac));
167-
memcpy(src_mac, pdv[i].vm_pkt_iov[0].iov_base + 6, sizeof(src_mac));
166+
const char *packet = (const char *)pdv[i].vm_pkt_iov[0].iov_base;
167+
memcpy(dest_mac, packet, sizeof(dest_mac));
168+
memcpy(src_mac, packet + 6, sizeof(src_mac));
168169
DEBUGF("[Handler i=%d] Dest %02X:%02X:%02X:%02X:%02X:%02X, Src "
169170
"%02X:%02X:%02X:%02X:%02X:%02X,",
170171
i, dest_mac[0], dest_mac[1], dest_mac[2], dest_mac[3], dest_mac[4],

0 commit comments

Comments
 (0)