diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2007-12-13 09:40:40 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:57:52 -0500 |
commit | dd6303df095d18b0c524a76a42f57bcc679b2039 (patch) | |
tree | 7bb19426bb87c895b3b0cdcb3639623481abbcea /net/dccp | |
parent | af3b867e2f6b72422bc7aacb1f1e26f47a9649bc (diff) |
[DCCP]: Remove unused and redundant validation functions
This removes two inlines which were both called in a single function only:
1) dccp_feat_change() is always called with either DCCPO_CHANGE_L or DCCPO_CHANGE_R as argument
* from dccp_set_socktopt_change() via do_dccp_setsockopt() with DCCP_SOCKOPT_CHANGE_R/L
* from __dccp_feat_init() via dccp_feat_init() also with DCCP_SOCKOPT_CHANGE_R/L.
Hence the dccp_feat_is_valid_type() is completely unnecessary and always returns true.
2) Due to (1), the length test reduces to 'len >= 4', which in turn makes
dccp_feat_is_valid_length() unnecessary.
Furthermore, the inline function dccp_feat_is_reserved() was unfolded,
since only called in a single place.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dccp')
-rw-r--r-- | net/dccp/feat.c | 12 | ||||
-rw-r--r-- | net/dccp/feat.h | 26 |
2 files changed, 4 insertions, 34 deletions
diff --git a/net/dccp/feat.c b/net/dccp/feat.c index 5ebdd86c1b99..084744e624d3 100644 --- a/net/dccp/feat.c +++ b/net/dccp/feat.c | |||
@@ -24,11 +24,7 @@ int dccp_feat_change(struct dccp_minisock *dmsk, u8 type, u8 feature, | |||
24 | 24 | ||
25 | dccp_feat_debug(type, feature, *val); | 25 | dccp_feat_debug(type, feature, *val); |
26 | 26 | ||
27 | if (!dccp_feat_is_valid_type(type)) { | 27 | if (len > 3) { |
28 | DCCP_WARN("option type %d invalid in negotiation\n", type); | ||
29 | return 1; | ||
30 | } | ||
31 | if (!dccp_feat_is_valid_length(type, feature, len)) { | ||
32 | DCCP_WARN("invalid length %d\n", len); | 28 | DCCP_WARN("invalid length %d\n", len); |
33 | return 1; | 29 | return 1; |
34 | } | 30 | } |
@@ -637,12 +633,12 @@ const char *dccp_feat_name(const u8 feat) | |||
637 | [DCCPF_MIN_CSUM_COVER] = "Min. Csum Coverage", | 633 | [DCCPF_MIN_CSUM_COVER] = "Min. Csum Coverage", |
638 | [DCCPF_DATA_CHECKSUM] = "Send Data Checksum", | 634 | [DCCPF_DATA_CHECKSUM] = "Send Data Checksum", |
639 | }; | 635 | }; |
636 | if (feat > DCCPF_DATA_CHECKSUM && feat < DCCPF_MIN_CCID_SPECIFIC) | ||
637 | return feature_names[DCCPF_RESERVED]; | ||
638 | |||
640 | if (feat >= DCCPF_MIN_CCID_SPECIFIC) | 639 | if (feat >= DCCPF_MIN_CCID_SPECIFIC) |
641 | return "CCID-specific"; | 640 | return "CCID-specific"; |
642 | 641 | ||
643 | if (dccp_feat_is_reserved(feat)) | ||
644 | return feature_names[DCCPF_RESERVED]; | ||
645 | |||
646 | return feature_names[feat]; | 642 | return feature_names[feat]; |
647 | } | 643 | } |
648 | 644 | ||
diff --git a/net/dccp/feat.h b/net/dccp/feat.h index 177f7dee4d10..e272222c7ace 100644 --- a/net/dccp/feat.h +++ b/net/dccp/feat.h | |||
@@ -14,32 +14,6 @@ | |||
14 | #include <linux/types.h> | 14 | #include <linux/types.h> |
15 | #include "dccp.h" | 15 | #include "dccp.h" |
16 | 16 | ||
17 | static inline int dccp_feat_is_valid_length(u8 type, u8 feature, u8 len) | ||
18 | { | ||
19 | /* sec. 6.1: Confirm has at least length 3, | ||
20 | * sec. 6.2: Change has at least length 4 */ | ||
21 | if (len < 3) | ||
22 | return 1; | ||
23 | if (len < 4 && (type == DCCPO_CHANGE_L || type == DCCPO_CHANGE_R)) | ||
24 | return 1; | ||
25 | /* XXX: add per-feature length validation (sec. 6.6.8) */ | ||
26 | return 0; | ||
27 | } | ||
28 | |||
29 | static inline int dccp_feat_is_reserved(const u8 feat) | ||
30 | { | ||
31 | return (feat > DCCPF_DATA_CHECKSUM && | ||
32 | feat < DCCPF_MIN_CCID_SPECIFIC) || | ||
33 | feat == DCCPF_RESERVED; | ||
34 | } | ||
35 | |||
36 | /* feature negotiation knows only these four option types (RFC 4340, sec. 6) */ | ||
37 | static inline int dccp_feat_is_valid_type(const u8 optnum) | ||
38 | { | ||
39 | return optnum >= DCCPO_CHANGE_L && optnum <= DCCPO_CONFIRM_R; | ||
40 | |||
41 | } | ||
42 | |||
43 | #ifdef CONFIG_IP_DCCP_DEBUG | 17 | #ifdef CONFIG_IP_DCCP_DEBUG |
44 | extern const char *dccp_feat_typename(const u8 type); | 18 | extern const char *dccp_feat_typename(const u8 type); |
45 | extern const char *dccp_feat_name(const u8 feat); | 19 | extern const char *dccp_feat_name(const u8 feat); |