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

net/core: Allow the compiler to verify declaration and definition consistency

Instead of declaring a function in a .c file, declare it in a header
file and include that header file from the source files that define
and that use the function. That allows the compiler to verify
consistency of declaration and definition. See also commit
52267790ef52 ("sock: add MSG_ZEROCOPY") # v4.14.

Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Bart Van Assche and committed by
David S. Miller
7b7ed885 a986967e

+19 -3
+2
net/core/datagram.c
··· 61 61 #include <trace/events/skb.h> 62 62 #include <net/busy_poll.h> 63 63 64 + #include "datagram.h" 65 + 64 66 /* 65 67 * Is a socket 'connection oriented' ? 66 68 */
+15
net/core/datagram.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + 3 + #ifndef _NET_CORE_DATAGRAM_H_ 4 + #define _NET_CORE_DATAGRAM_H_ 5 + 6 + #include <linux/types.h> 7 + 8 + struct sock; 9 + struct sk_buff; 10 + struct iov_iter; 11 + 12 + int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, 13 + struct iov_iter *from, size_t length); 14 + 15 + #endif /* _NET_CORE_DATAGRAM_H_ */
+2 -3
net/core/skbuff.c
··· 77 77 #include <linux/capability.h> 78 78 #include <linux/user_namespace.h> 79 79 80 + #include "datagram.h" 81 + 80 82 struct kmem_cache *skbuff_head_cache __ro_after_init; 81 83 static struct kmem_cache *skbuff_fclone_cache __ro_after_init; 82 84 #ifdef CONFIG_SKB_EXTENSIONS ··· 1106 1104 } 1107 1105 } 1108 1106 EXPORT_SYMBOL_GPL(sock_zerocopy_put_abort); 1109 - 1110 - extern int __zerocopy_sg_from_iter(struct sock *sk, struct sk_buff *skb, 1111 - struct iov_iter *from, size_t length); 1112 1107 1113 1108 int skb_zerocopy_iter_dgram(struct sk_buff *skb, struct msghdr *msg, int len) 1114 1109 {