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

net: sock_diag_handler structs can be const

read only, so change it to const.

Signed-off-by: Shan Wei <davidshan@tencent.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Shan Wei and committed by
David S. Miller
8dcf01fc 808db80a

+11 -11
+2 -2
include/linux/sock_diag.h
··· 32 32 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh); 33 33 }; 34 34 35 - int sock_diag_register(struct sock_diag_handler *h); 36 - void sock_diag_unregister(struct sock_diag_handler *h); 35 + int sock_diag_register(const struct sock_diag_handler *h); 36 + void sock_diag_unregister(const struct sock_diag_handler *h); 37 37 38 38 void sock_diag_register_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh)); 39 39 void sock_diag_unregister_inet_compat(int (*fn)(struct sk_buff *skb, struct nlmsghdr *nlh));
+6 -6
net/core/sock_diag.c
··· 10 10 #include <linux/inet_diag.h> 11 11 #include <linux/sock_diag.h> 12 12 13 - static struct sock_diag_handler *sock_diag_handlers[AF_MAX]; 13 + static const struct sock_diag_handler *sock_diag_handlers[AF_MAX]; 14 14 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh); 15 15 static DEFINE_MUTEX(sock_diag_table_mutex); 16 16 ··· 70 70 } 71 71 EXPORT_SYMBOL_GPL(sock_diag_unregister_inet_compat); 72 72 73 - int sock_diag_register(struct sock_diag_handler *hndl) 73 + int sock_diag_register(const struct sock_diag_handler *hndl) 74 74 { 75 75 int err = 0; 76 76 ··· 88 88 } 89 89 EXPORT_SYMBOL_GPL(sock_diag_register); 90 90 91 - void sock_diag_unregister(struct sock_diag_handler *hnld) 91 + void sock_diag_unregister(const struct sock_diag_handler *hnld) 92 92 { 93 93 int family = hnld->family; 94 94 ··· 102 102 } 103 103 EXPORT_SYMBOL_GPL(sock_diag_unregister); 104 104 105 - static inline struct sock_diag_handler *sock_diag_lock_handler(int family) 105 + static const inline struct sock_diag_handler *sock_diag_lock_handler(int family) 106 106 { 107 107 if (sock_diag_handlers[family] == NULL) 108 108 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK, ··· 112 112 return sock_diag_handlers[family]; 113 113 } 114 114 115 - static inline void sock_diag_unlock_handler(struct sock_diag_handler *h) 115 + static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h) 116 116 { 117 117 mutex_unlock(&sock_diag_table_mutex); 118 118 } ··· 121 121 { 122 122 int err; 123 123 struct sock_diag_req *req = NLMSG_DATA(nlh); 124 - struct sock_diag_handler *hndl; 124 + const struct sock_diag_handler *hndl; 125 125 126 126 if (nlmsg_len(nlh) < sizeof(*req)) 127 127 return -EINVAL;
+2 -2
net/ipv4/inet_diag.c
··· 999 999 return inet_diag_get_exact(skb, h, (struct inet_diag_req_v2 *)NLMSG_DATA(h)); 1000 1000 } 1001 1001 1002 - static struct sock_diag_handler inet_diag_handler = { 1002 + static const struct sock_diag_handler inet_diag_handler = { 1003 1003 .family = AF_INET, 1004 1004 .dump = inet_diag_handler_dump, 1005 1005 }; 1006 1006 1007 - static struct sock_diag_handler inet6_diag_handler = { 1007 + static const struct sock_diag_handler inet6_diag_handler = { 1008 1008 .family = AF_INET6, 1009 1009 .dump = inet_diag_handler_dump, 1010 1010 };
+1 -1
net/unix/diag.c
··· 310 310 return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); 311 311 } 312 312 313 - static struct sock_diag_handler unix_diag_handler = { 313 + static const struct sock_diag_handler unix_diag_handler = { 314 314 .family = AF_UNIX, 315 315 .dump = unix_diag_handler_dump, 316 316 };