Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: txtimestamp: fix compilation issue

PACKET_TX_TIMESTAMP is defined in if_packet.h but it is not included in
test. Include it instead of <netpacket/packet.h> otherwise the error of
redefinition arrives.
Also fix the compiler warning about ambiguous control flow by adding
explicit braces.

Fixes: 8fe2f761cae9 ("net-timestamp: expand documentation")
Suggested-by: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Signed-off-by: Vadim Fedorenko <vfedorenko@novek.ru>
Acked-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/1612461034-24524-1-git-send-email-vfedorenko@novek.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Vadim Fedorenko and committed by
Jakub Kicinski
647b8dd5 8fd54a73

+3 -3
+3 -3
tools/testing/selftests/net/txtimestamp.c
··· 26 26 #include <inttypes.h> 27 27 #include <linux/errqueue.h> 28 28 #include <linux/if_ether.h> 29 + #include <linux/if_packet.h> 29 30 #include <linux/ipv6.h> 30 31 #include <linux/net_tstamp.h> 31 32 #include <netdb.h> ··· 35 34 #include <netinet/ip.h> 36 35 #include <netinet/udp.h> 37 36 #include <netinet/tcp.h> 38 - #include <netpacket/packet.h> 39 37 #include <poll.h> 40 38 #include <stdarg.h> 41 39 #include <stdbool.h> ··· 495 495 total_len = cfg_payload_len; 496 496 if (cfg_use_pf_packet || cfg_proto == SOCK_RAW) { 497 497 total_len += sizeof(struct udphdr); 498 - if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) 498 + if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) { 499 499 if (family == PF_INET) 500 500 total_len += sizeof(struct iphdr); 501 501 else 502 502 total_len += sizeof(struct ipv6hdr); 503 - 503 + } 504 504 /* special case, only rawv6_sendmsg: 505 505 * pass proto in sin6_port if not connected 506 506 * also see ANK comment in net/ipv4/raw.c