diff options
author | David S. Miller <davem@davemloft.net> | 2012-06-27 00:41:00 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-27 00:41:00 -0400 |
commit | b61bb01974730e2fd7d36ab4cc848ca6f44cffd4 (patch) | |
tree | a04943cb4e70f12f2f655ce5ecd65d0eafe129bc /net/unix | |
parent | 8b00a53c633789394d7fec6ee0833d5f0cda3bca (diff) |
unix_diag: Move away from NLMSG_PUT().
And use nlmsg_data() while we're here too and remove useless
casts.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/unix')
-rw-r--r-- | net/unix/diag.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/net/unix/diag.c b/net/unix/diag.c index 7e8a24bff34a..977ca317550d 100644 --- a/net/unix/diag.c +++ b/net/unix/diag.c | |||
@@ -126,10 +126,12 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r | |||
126 | struct nlmsghdr *nlh; | 126 | struct nlmsghdr *nlh; |
127 | struct unix_diag_msg *rep; | 127 | struct unix_diag_msg *rep; |
128 | 128 | ||
129 | nlh = NLMSG_PUT(skb, pid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rep)); | 129 | nlh = nlmsg_put(skb, pid, seq, SOCK_DIAG_BY_FAMILY, sizeof(*rep), 0); |
130 | if (!nlh) | ||
131 | goto out_nlmsg_trim; | ||
130 | nlh->nlmsg_flags = flags; | 132 | nlh->nlmsg_flags = flags; |
131 | 133 | ||
132 | rep = NLMSG_DATA(nlh); | 134 | rep = nlmsg_data(nlh); |
133 | 135 | ||
134 | rep->udiag_family = AF_UNIX; | 136 | rep->udiag_family = AF_UNIX; |
135 | rep->udiag_type = sk->sk_type; | 137 | rep->udiag_type = sk->sk_type; |
@@ -139,32 +141,32 @@ static int sk_diag_fill(struct sock *sk, struct sk_buff *skb, struct unix_diag_r | |||
139 | 141 | ||
140 | if ((req->udiag_show & UDIAG_SHOW_NAME) && | 142 | if ((req->udiag_show & UDIAG_SHOW_NAME) && |
141 | sk_diag_dump_name(sk, skb)) | 143 | sk_diag_dump_name(sk, skb)) |
142 | goto nlmsg_failure; | 144 | goto out_nlmsg_trim; |
143 | 145 | ||
144 | if ((req->udiag_show & UDIAG_SHOW_VFS) && | 146 | if ((req->udiag_show & UDIAG_SHOW_VFS) && |
145 | sk_diag_dump_vfs(sk, skb)) | 147 | sk_diag_dump_vfs(sk, skb)) |
146 | goto nlmsg_failure; | 148 | goto out_nlmsg_trim; |
147 | 149 | ||
148 | if ((req->udiag_show & UDIAG_SHOW_PEER) && | 150 | if ((req->udiag_show & UDIAG_SHOW_PEER) && |
149 | sk_diag_dump_peer(sk, skb)) | 151 | sk_diag_dump_peer(sk, skb)) |
150 | goto nlmsg_failure; | 152 | goto out_nlmsg_trim; |
151 | 153 | ||
152 | if ((req->udiag_show & UDIAG_SHOW_ICONS) && | 154 | if ((req->udiag_show & UDIAG_SHOW_ICONS) && |
153 | sk_diag_dump_icons(sk, skb)) | 155 | sk_diag_dump_icons(sk, skb)) |
154 | goto nlmsg_failure; | 156 | goto out_nlmsg_trim; |
155 | 157 | ||
156 | if ((req->udiag_show & UDIAG_SHOW_RQLEN) && | 158 | if ((req->udiag_show & UDIAG_SHOW_RQLEN) && |
157 | sk_diag_show_rqlen(sk, skb)) | 159 | sk_diag_show_rqlen(sk, skb)) |
158 | goto nlmsg_failure; | 160 | goto out_nlmsg_trim; |
159 | 161 | ||
160 | if ((req->udiag_show & UDIAG_SHOW_MEMINFO) && | 162 | if ((req->udiag_show & UDIAG_SHOW_MEMINFO) && |
161 | sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO)) | 163 | sock_diag_put_meminfo(sk, skb, UNIX_DIAG_MEMINFO)) |
162 | goto nlmsg_failure; | 164 | goto out_nlmsg_trim; |
163 | 165 | ||
164 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; | 166 | nlh->nlmsg_len = skb_tail_pointer(skb) - b; |
165 | return skb->len; | 167 | return skb->len; |
166 | 168 | ||
167 | nlmsg_failure: | 169 | out_nlmsg_trim: |
168 | nlmsg_trim(skb, b); | 170 | nlmsg_trim(skb, b); |
169 | return -EMSGSIZE; | 171 | return -EMSGSIZE; |
170 | } | 172 | } |
@@ -189,7 +191,7 @@ static int unix_diag_dump(struct sk_buff *skb, struct netlink_callback *cb) | |||
189 | struct unix_diag_req *req; | 191 | struct unix_diag_req *req; |
190 | int num, s_num, slot, s_slot; | 192 | int num, s_num, slot, s_slot; |
191 | 193 | ||
192 | req = NLMSG_DATA(cb->nlh); | 194 | req = nlmsg_data(cb->nlh); |
193 | 195 | ||
194 | s_slot = cb->args[0]; | 196 | s_slot = cb->args[0]; |
195 | num = s_num = cb->args[1]; | 197 | num = s_num = cb->args[1]; |
@@ -309,7 +311,7 @@ static int unix_diag_handler_dump(struct sk_buff *skb, struct nlmsghdr *h) | |||
309 | }; | 311 | }; |
310 | return netlink_dump_start(sock_diag_nlsk, skb, h, &c); | 312 | return netlink_dump_start(sock_diag_nlsk, skb, h, &c); |
311 | } else | 313 | } else |
312 | return unix_diag_get_exact(skb, h, (struct unix_diag_req *)NLMSG_DATA(h)); | 314 | return unix_diag_get_exact(skb, h, nlmsg_data(h)); |
313 | } | 315 | } |
314 | 316 | ||
315 | static const struct sock_diag_handler unix_diag_handler = { | 317 | static const struct sock_diag_handler unix_diag_handler = { |