diff options
author | Gerrit Renker <gerrit@erg.abdn.ac.uk> | 2006-11-15 18:27:47 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2006-12-03 00:23:49 -0500 |
commit | 3c6952624a8f600f9a0fbc1f5db5560a7ef9b13e (patch) | |
tree | 294924e950000cd786b0cdaf026ed58b2f81102d /net/dccp/ccids | |
parent | 6bb100b9fc8f1ce330231b360028ab705a9f0378 (diff) |
[DCCP]: Introduce DCCP_{BUG{_ON},CRIT} macros, use enum:8 for the ccid3 states
This patch tackles the following problem:
* the ccid3_hc_{t,r}x_sock define ccid3hc{t,r}x_state as `u8', but
in reality there can only be a few, pre-defined enum names
* this necessitates addiditional checking for unexpected values
which would otherwise be caught by the compiler
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk>
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Diffstat (limited to 'net/dccp/ccids')
-rw-r--r-- | net/dccp/ccids/ccid3.c | 45 | ||||
-rw-r--r-- | net/dccp/ccids/ccid3.h | 19 |
2 files changed, 29 insertions, 35 deletions
diff --git a/net/dccp/ccids/ccid3.c b/net/dccp/ccids/ccid3.c index cec23ad286de..2fa0c6d1fbee 100644 --- a/net/dccp/ccids/ccid3.c +++ b/net/dccp/ccids/ccid3.c | |||
@@ -75,14 +75,6 @@ static struct dccp_tx_hist *ccid3_tx_hist; | |||
75 | static struct dccp_rx_hist *ccid3_rx_hist; | 75 | static struct dccp_rx_hist *ccid3_rx_hist; |
76 | static struct dccp_li_hist *ccid3_li_hist; | 76 | static struct dccp_li_hist *ccid3_li_hist; |
77 | 77 | ||
78 | /* TFRC sender states */ | ||
79 | enum ccid3_hc_tx_states { | ||
80 | TFRC_SSTATE_NO_SENT = 1, | ||
81 | TFRC_SSTATE_NO_FBACK, | ||
82 | TFRC_SSTATE_FBACK, | ||
83 | TFRC_SSTATE_TERM, | ||
84 | }; | ||
85 | |||
86 | #ifdef CCID3_DEBUG | 78 | #ifdef CCID3_DEBUG |
87 | static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) | 79 | static const char *ccid3_tx_state_name(enum ccid3_hc_tx_states state) |
88 | { | 80 | { |
@@ -251,9 +243,8 @@ static void ccid3_hc_tx_no_feedback_timer(unsigned long data) | |||
251 | hctx->ccid3hctx_x)); | 243 | hctx->ccid3hctx_x)); |
252 | break; | 244 | break; |
253 | default: | 245 | default: |
254 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 246 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
255 | __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); | 247 | hctx->ccid3hctx_state); |
256 | dump_stack(); | ||
257 | goto out; | 248 | goto out; |
258 | } | 249 | } |
259 | 250 | ||
@@ -329,9 +320,8 @@ static int ccid3_hc_tx_send_packet(struct sock *sk, | |||
329 | rc = delay > 0 ? delay : 0; | 320 | rc = delay > 0 ? delay : 0; |
330 | break; | 321 | break; |
331 | default: | 322 | default: |
332 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 323 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
333 | __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); | 324 | hctx->ccid3hctx_state); |
334 | dump_stack(); | ||
335 | rc = -EINVAL; | 325 | rc = -EINVAL; |
336 | break; | 326 | break; |
337 | } | 327 | } |
@@ -423,9 +413,8 @@ static void ccid3_hc_tx_packet_sent(struct sock *sk, int more, int len) | |||
423 | } | 413 | } |
424 | break; | 414 | break; |
425 | default: | 415 | default: |
426 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 416 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
427 | __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); | 417 | hctx->ccid3hctx_state); |
428 | dump_stack(); | ||
429 | break; | 418 | break; |
430 | } | 419 | } |
431 | } | 420 | } |
@@ -568,9 +557,8 @@ static void ccid3_hc_tx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
568 | hctx->ccid3hctx_idle = 1; | 557 | hctx->ccid3hctx_idle = 1; |
569 | break; | 558 | break; |
570 | default: | 559 | default: |
571 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 560 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
572 | __FUNCTION__, dccp_role(sk), sk, hctx->ccid3hctx_state); | 561 | hctx->ccid3hctx_state); |
573 | dump_stack(); | ||
574 | break; | 562 | break; |
575 | } | 563 | } |
576 | } | 564 | } |
@@ -688,13 +676,6 @@ static void ccid3_hc_tx_exit(struct sock *sk) | |||
688 | * RX Half Connection methods | 676 | * RX Half Connection methods |
689 | */ | 677 | */ |
690 | 678 | ||
691 | /* TFRC receiver states */ | ||
692 | enum ccid3_hc_rx_states { | ||
693 | TFRC_RSTATE_NO_DATA = 1, | ||
694 | TFRC_RSTATE_DATA, | ||
695 | TFRC_RSTATE_TERM = 127, | ||
696 | }; | ||
697 | |||
698 | #ifdef CCID3_DEBUG | 679 | #ifdef CCID3_DEBUG |
699 | static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) | 680 | static const char *ccid3_rx_state_name(enum ccid3_hc_rx_states state) |
700 | { | 681 | { |
@@ -744,9 +725,8 @@ static void ccid3_hc_rx_send_feedback(struct sock *sk) | |||
744 | } | 725 | } |
745 | break; | 726 | break; |
746 | default: | 727 | default: |
747 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 728 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
748 | __FUNCTION__, dccp_role(sk), sk, hcrx->ccid3hcrx_state); | 729 | hcrx->ccid3hcrx_state); |
749 | dump_stack(); | ||
750 | return; | 730 | return; |
751 | } | 731 | } |
752 | 732 | ||
@@ -1088,9 +1068,8 @@ static void ccid3_hc_rx_packet_recv(struct sock *sk, struct sk_buff *skb) | |||
1088 | } | 1068 | } |
1089 | return; | 1069 | return; |
1090 | default: | 1070 | default: |
1091 | printk(KERN_CRIT "%s: %s, sk=%p, Illegal state (%d)!\n", | 1071 | DCCP_BUG("%s, sk=%p, Illegal state (%d)!", dccp_role(sk), sk, |
1092 | __FUNCTION__, dccp_role(sk), sk, hcrx->ccid3hcrx_state); | 1072 | hcrx->ccid3hcrx_state); |
1093 | dump_stack(); | ||
1094 | return; | 1073 | return; |
1095 | } | 1074 | } |
1096 | 1075 | ||
diff --git a/net/dccp/ccids/ccid3.h b/net/dccp/ccids/ccid3.h index 0a2cb7536d26..c122e757eb7f 100644 --- a/net/dccp/ccids/ccid3.h +++ b/net/dccp/ccids/ccid3.h | |||
@@ -73,6 +73,14 @@ struct ccid3_options_received { | |||
73 | u32 ccid3or_receive_rate; | 73 | u32 ccid3or_receive_rate; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | /* TFRC sender states */ | ||
77 | enum ccid3_hc_tx_states { | ||
78 | TFRC_SSTATE_NO_SENT = 1, | ||
79 | TFRC_SSTATE_NO_FBACK, | ||
80 | TFRC_SSTATE_FBACK, | ||
81 | TFRC_SSTATE_TERM, | ||
82 | }; | ||
83 | |||
76 | /** struct ccid3_hc_tx_sock - CCID3 sender half connection sock | 84 | /** struct ccid3_hc_tx_sock - CCID3 sender half connection sock |
77 | * | 85 | * |
78 | * @ccid3hctx_state - Sender state | 86 | * @ccid3hctx_state - Sender state |
@@ -103,7 +111,7 @@ struct ccid3_hc_tx_sock { | |||
103 | #define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto | 111 | #define ccid3hctx_t_rto ccid3hctx_tfrc.tfrctx_rto |
104 | #define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi | 112 | #define ccid3hctx_t_ipi ccid3hctx_tfrc.tfrctx_ipi |
105 | u16 ccid3hctx_s; | 113 | u16 ccid3hctx_s; |
106 | u8 ccid3hctx_state; | 114 | enum ccid3_hc_tx_states ccid3hctx_state:8; |
107 | u8 ccid3hctx_last_win_count; | 115 | u8 ccid3hctx_last_win_count; |
108 | u8 ccid3hctx_idle; | 116 | u8 ccid3hctx_idle; |
109 | struct timeval ccid3hctx_t_last_win_count; | 117 | struct timeval ccid3hctx_t_last_win_count; |
@@ -115,6 +123,13 @@ struct ccid3_hc_tx_sock { | |||
115 | struct ccid3_options_received ccid3hctx_options_received; | 123 | struct ccid3_options_received ccid3hctx_options_received; |
116 | }; | 124 | }; |
117 | 125 | ||
126 | /* TFRC receiver states */ | ||
127 | enum ccid3_hc_rx_states { | ||
128 | TFRC_RSTATE_NO_DATA = 1, | ||
129 | TFRC_RSTATE_DATA, | ||
130 | TFRC_RSTATE_TERM = 127, | ||
131 | }; | ||
132 | |||
118 | struct ccid3_hc_rx_sock { | 133 | struct ccid3_hc_rx_sock { |
119 | struct tfrc_rx_info ccid3hcrx_tfrc; | 134 | struct tfrc_rx_info ccid3hcrx_tfrc; |
120 | #define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv | 135 | #define ccid3hcrx_x_recv ccid3hcrx_tfrc.tfrcrx_x_recv |
@@ -122,8 +137,8 @@ struct ccid3_hc_rx_sock { | |||
122 | #define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p | 137 | #define ccid3hcrx_p ccid3hcrx_tfrc.tfrcrx_p |
123 | u64 ccid3hcrx_seqno_nonloss:48, | 138 | u64 ccid3hcrx_seqno_nonloss:48, |
124 | ccid3hcrx_ccval_nonloss:4, | 139 | ccid3hcrx_ccval_nonloss:4, |
125 | ccid3hcrx_state:8, | ||
126 | ccid3hcrx_ccval_last_counter:4; | 140 | ccid3hcrx_ccval_last_counter:4; |
141 | enum ccid3_hc_rx_states ccid3hcrx_state:8; | ||
127 | u32 ccid3hcrx_bytes_recv; | 142 | u32 ccid3hcrx_bytes_recv; |
128 | struct timeval ccid3hcrx_tstamp_last_feedback; | 143 | struct timeval ccid3hcrx_tstamp_last_feedback; |
129 | struct timeval ccid3hcrx_tstamp_last_ack; | 144 | struct timeval ccid3hcrx_tstamp_last_ack; |