diff options
author | Thomas Graf <tgraf@suug.ch> | 2008-06-03 19:36:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-06-03 19:36:54 -0400 |
commit | bc3ed28caaef55e7e3a9316464256353c5f9b1df (patch) | |
tree | 3aed4521aa2d74a36ee2b192c2e229fd23fbe732 /include | |
parent | 1f9d11c7c99da706e33646c3a9080dd5a8ef9a0b (diff) |
netlink: Improve returned error codes
Make nlmsg_trim(), nlmsg_cancel(), genlmsg_cancel(), and
nla_nest_cancel() void functions.
Return -EMSGSIZE instead of -1 if the provided message buffer is not
big enough.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/genetlink.h | 4 | ||||
-rw-r--r-- | include/net/netlink.h | 20 |
2 files changed, 11 insertions, 13 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index decdda546829..747c255d1df0 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -162,9 +162,9 @@ static inline int genlmsg_end(struct sk_buff *skb, void *hdr) | |||
162 | * @skb: socket buffer the message is stored in | 162 | * @skb: socket buffer the message is stored in |
163 | * @hdr: generic netlink message header | 163 | * @hdr: generic netlink message header |
164 | */ | 164 | */ |
165 | static inline int genlmsg_cancel(struct sk_buff *skb, void *hdr) | 165 | static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) |
166 | { | 166 | { |
167 | return nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); | 167 | nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); |
168 | } | 168 | } |
169 | 169 | ||
170 | /** | 170 | /** |
diff --git a/include/net/netlink.h b/include/net/netlink.h index 112dcdf7e34e..dfc3701dfcc3 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -556,14 +556,12 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb) | |||
556 | * @skb: socket buffer the message is stored in | 556 | * @skb: socket buffer the message is stored in |
557 | * @mark: mark to trim to | 557 | * @mark: mark to trim to |
558 | * | 558 | * |
559 | * Trims the message to the provided mark. Returns -1. | 559 | * Trims the message to the provided mark. |
560 | */ | 560 | */ |
561 | static inline int nlmsg_trim(struct sk_buff *skb, const void *mark) | 561 | static inline void nlmsg_trim(struct sk_buff *skb, const void *mark) |
562 | { | 562 | { |
563 | if (mark) | 563 | if (mark) |
564 | skb_trim(skb, (unsigned char *) mark - skb->data); | 564 | skb_trim(skb, (unsigned char *) mark - skb->data); |
565 | |||
566 | return -1; | ||
567 | } | 565 | } |
568 | 566 | ||
569 | /** | 567 | /** |
@@ -572,11 +570,11 @@ static inline int nlmsg_trim(struct sk_buff *skb, const void *mark) | |||
572 | * @nlh: netlink message header | 570 | * @nlh: netlink message header |
573 | * | 571 | * |
574 | * Removes the complete netlink message including all | 572 | * Removes the complete netlink message including all |
575 | * attributes from the socket buffer again. Returns -1. | 573 | * attributes from the socket buffer again. |
576 | */ | 574 | */ |
577 | static inline int nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh) | 575 | static inline void nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh) |
578 | { | 576 | { |
579 | return nlmsg_trim(skb, nlh); | 577 | nlmsg_trim(skb, nlh); |
580 | } | 578 | } |
581 | 579 | ||
582 | /** | 580 | /** |
@@ -775,7 +773,7 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype, | |||
775 | int nested_len = nla_len(nla) - NLA_ALIGN(len); | 773 | int nested_len = nla_len(nla) - NLA_ALIGN(len); |
776 | 774 | ||
777 | if (nested_len < 0) | 775 | if (nested_len < 0) |
778 | return -1; | 776 | return -EINVAL; |
779 | if (nested_len >= nla_attr_size(0)) | 777 | if (nested_len >= nla_attr_size(0)) |
780 | return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), | 778 | return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), |
781 | nested_len, policy); | 779 | nested_len, policy); |
@@ -1080,11 +1078,11 @@ static inline int nla_nest_compat_end(struct sk_buff *skb, struct nlattr *start) | |||
1080 | * @start: container attribute | 1078 | * @start: container attribute |
1081 | * | 1079 | * |
1082 | * Removes the container attribute and including all nested | 1080 | * Removes the container attribute and including all nested |
1083 | * attributes. Returns -1. | 1081 | * attributes. Returns -EMSGSIZE |
1084 | */ | 1082 | */ |
1085 | static inline int nla_nest_cancel(struct sk_buff *skb, struct nlattr *start) | 1083 | static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start) |
1086 | { | 1084 | { |
1087 | return nlmsg_trim(skb, start); | 1085 | nlmsg_trim(skb, start); |
1088 | } | 1086 | } |
1089 | 1087 | ||
1090 | /** | 1088 | /** |