* [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids
@ 2007-11-01 0:31 Leandro
2007-11-01 12:36 ` Tommi Saviranta
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Leandro @ 2007-11-01 0:31 UTC (permalink / raw)
To: dccp
[CCID-3/4] Share ccid3_tx_state_name function via tfrc_ccids
ccid3_tx_state_name is now tfrc_tx_state_name
Signed-off-by: Leandro Melo de Sales <leandro@embedded.ufcg.edu.br>
Index: leandro.new/net/dccp/ccids/ccid3.c
=================================--- leandro.new.orig/net/dccp/ccids/ccid3.c
+++ leandro.new/net/dccp/ccids/ccid3.c
@@ -48,23 +48,6 @@ static int ccid3_debug;
DECLARE_TFRC_TX_CACHE(ccid3_tx_hist);
-/*
- * Transmitter Half-Connection Routines
- */
-#if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
-static const char *ccid3_tx_state_name(enum tfrc_hc_tx_states state)
-{
- static char *ccid3_state_names[] = {
- [TFRC_SSTATE_NO_SENT] = "NO_SENT",
- [TFRC_SSTATE_NO_FBACK] = "NO_FBACK",
- [TFRC_SSTATE_FBACK] = "FBACK",
- [TFRC_SSTATE_TERM] = "TERM",
- };
-
- return ccid3_state_names[state];
-}
-#endif
-
/**
* Each of the following #define aims at maintain the current
* dccp code nomenclature unchanged while still share
@@ -113,8 +96,8 @@ static void ccid3_hc_tx_set_state(struct
enum tfrc_hc_tx_states oldstate = hctx->tfrchctx_state;
ccid3_pr_debug("%s(%p) %-8.8s -> %s\n",
- dccp_role(sk), sk, ccid3_tx_state_name(oldstate),
- ccid3_tx_state_name(state));
+ dccp_role(sk), sk, tfrc_tx_state_name(oldstate),
+ tfrc_tx_state_name(state));
WARN_ON(state = oldstate);
hctx->tfrchctx_state = state;
}
@@ -270,7 +253,7 @@ static void ccid3_hc_tx_no_feedback_time
}
ccid3_pr_debug("%s(%p, state=%s) - entry \n", dccp_role(sk), sk,
- ccid3_tx_state_name(hctx->tfrchctx_state));
+ tfrc_tx_state_name(hctx->tfrchctx_state));
if (hctx->tfrchctx_state = TFRC_SSTATE_FBACK)
ccid3_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
Index: leandro.new/net/dccp/ccids/ccid4.c
=================================--- leandro.new.orig/net/dccp/ccids/ccid4.c
+++ leandro.new/net/dccp/ccids/ccid4.c
@@ -58,23 +58,6 @@ static int ccid4_debug;
DECLARE_TFRC_TX_CACHE(ccid4_tx_hist);
-/*
- * Transmitter Half-Connection Routines
- */
-#ifdef CONFIG_IP_DCCP_CCID4_DEBUG
-static const char *ccid4_tx_state_name(enum tfrc_hc_tx_states state)
-{
- static char *ccid4_state_names[] = {
- [TFRC_SSTATE_NO_SENT] = "NO_SENT",
- [TFRC_SSTATE_NO_FBACK] = "NO_FBACK",
- [TFRC_SSTATE_FBACK] = "FBACK",
- [TFRC_SSTATE_TERM] = "TERM",
- };
-
- return ccid4_state_names[state];
-}
-#endif
-
/**
* Each of the following #define aims at maintain the current
* dccp code nomenclature unchanged while still share
@@ -123,8 +106,8 @@ static void ccid4_hc_tx_set_state(struct
enum tfrc_hc_tx_states oldstate = hctx->tfrchctx_state;
ccid4_pr_debug("%s(%p) %-8.8s -> %s\n",
- dccp_role(sk), sk, ccid4_tx_state_name(oldstate),
- ccid4_tx_state_name(state));
+ dccp_role(sk), sk, tfrc_tx_state_name(oldstate),
+ tfrc_tx_state_name(state));
WARN_ON(state = oldstate);
hctx->tfrchctx_state = state;
}
@@ -296,7 +279,7 @@ static void ccid4_hc_tx_no_feedback_time
}
ccid4_pr_debug("%s(%p, state=%s) - entry \n", dccp_role(sk), sk,
- ccid4_tx_state_name(hctx->tfrchctx_state));
+ tfrc_tx_state_name(hctx->tfrchctx_state));
if (hctx->tfrchctx_state = TFRC_SSTATE_FBACK)
ccid4_hc_tx_set_state(sk, TFRC_SSTATE_NO_FBACK);
Index: leandro.new/net/dccp/ccids/lib/tfrc_ccids.h
=================================--- leandro.new.orig/net/dccp/ccids/lib/tfrc_ccids.h
+++ leandro.new/net/dccp/ccids/lib/tfrc_ccids.h
@@ -154,3 +154,21 @@ static inline struct tfrc_hc_rx_sock *tf
BUG_ON(hcrx = NULL);
return hcrx;
}
+
+/**
+ * Transmitter Half-Connection Routines
+ */
+#if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
+static const char *tfrc_tx_state_name(enum tfrc_hc_tx_states state)
+{
+ static char *tfrc_state_names[] = {
+ [TFRC_SSTATE_NO_SENT] = "NO_SENT",
+ [TFRC_SSTATE_NO_FBACK] = "NO_FBACK",
+ [TFRC_SSTATE_FBACK] = "FBACK",
+ [TFRC_SSTATE_TERM] = "TERM",
+ };
+
+ return tfrc_state_names[state];
+}
+#endif
+
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids
2007-11-01 0:31 [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids Leandro
@ 2007-11-01 12:36 ` Tommi Saviranta
2007-11-10 12:31 ` Gerrit Renker
2007-11-13 16:14 ` Łeandro Sales
2 siblings, 0 replies; 4+ messages in thread
From: Tommi Saviranta @ 2007-11-01 12:36 UTC (permalink / raw)
To: dccp
On Wed, Oct 31, 2007 at 21:31:52 -0300, Leandro wrote:
> [CCID-3/4] Share ccid3_tx_state_name function via tfrc_ccids
>
> ccid3_tx_state_name is now tfrc_tx_state_name
>
> Signed-off-by: Leandro Melo de Sales <leandro@embedded.ufcg.edu.br>
Acked-by: Tommi Saviranta <wnd@iki.fi>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids
2007-11-01 0:31 [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids Leandro
2007-11-01 12:36 ` Tommi Saviranta
@ 2007-11-10 12:31 ` Gerrit Renker
2007-11-13 16:14 ` Łeandro Sales
2 siblings, 0 replies; 4+ messages in thread
From: Gerrit Renker @ 2007-11-10 12:31 UTC (permalink / raw)
To: dccp
| [CCID-3/4] Share ccid3_tx_state_name function via tfrc_ccids
There is a build problem in declaring the following routines as shared:
#if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
static const char *tfrc_tx_state_name(enum tfrc_hc_tx_states state)
{
/* ... */
}
#endif
#if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
static const char *tfrc_rx_state_name(enum tfrc_hc_rx_states state)
{
/* ... */
#endif
When enabling CCID3_DEBUG, but not CCID4_DEBUG, the following build warnings result:
/usr/src/davem-2.6/net/dccp/ccids/lib/tfrc_ccids.h:163: warning: 'tfrc_tx_state_name' defined but not used
/usr/src/davem-2.6/net/dccp/ccids/lib/tfrc_ccids.h:180: warning: 'tfrc_rx_state_name' defined but not used
The reason is that the header file is #included in ccid4.c and this function is only called from
within ccid4_pr_debug(). But when CCID4_DEBUG is disabled, this macro expands to an emptry string,
so the compiler thinks that tfrc_{rx,tx}_state_name() is not used -- which is actually the case.
So not very happy with the above solution. When getting serious about abstracting and sharing
common code, the best think is probably to use a single debugging function, tfrc_pr_debug.
This would be enabled when at least one of CCID3_DEBUG or CCID4_DEBUG is enabled, and one could
add some magic that the module parameters influence the boolean variable tfrc_debug.
The same could be done for the RTO timer - since the identical menu appears in both places.
Maybe it is better for the moment to `un-share' the code.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids
2007-11-01 0:31 [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids Leandro
2007-11-01 12:36 ` Tommi Saviranta
2007-11-10 12:31 ` Gerrit Renker
@ 2007-11-13 16:14 ` Łeandro Sales
2 siblings, 0 replies; 4+ messages in thread
From: Łeandro Sales @ 2007-11-13 16:14 UTC (permalink / raw)
To: dccp
2007/11/10, Gerrit Renker <gerrit@erg.abdn.ac.uk>:
> | [CCID-3/4] Share ccid3_tx_state_name function via tfrc_ccids
>
> There is a build problem in declaring the following routines as shared:
>
> #if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
> static const char *tfrc_tx_state_name(enum tfrc_hc_tx_states state)
> {
> /* ... */
> }
> #endif
>
> #if defined(CONFIG_IP_DCCP_CCID3_DEBUG) || defined(CONFIG_IP_DCCP_CCID4_DEBUG)
> static const char *tfrc_rx_state_name(enum tfrc_hc_rx_states state)
> {
> /* ... */
> #endif
>
> When enabling CCID3_DEBUG, but not CCID4_DEBUG, the following build warnings result:
>
> /usr/src/davem-2.6/net/dccp/ccids/lib/tfrc_ccids.h:163: warning: 'tfrc_tx_state_name' defined but not used
> /usr/src/davem-2.6/net/dccp/ccids/lib/tfrc_ccids.h:180: warning: 'tfrc_rx_state_name' defined but not used
>
> The reason is that the header file is #included in ccid4.c and this function is only called from
> within ccid4_pr_debug(). But when CCID4_DEBUG is disabled, this macro expands to an emptry string,
> so the compiler thinks that tfrc_{rx,tx}_state_name() is not used -- which is actually the case.
>
> So not very happy with the above solution. When getting serious about abstracting and sharing
> common code, the best think is probably to use a single debugging function, tfrc_pr_debug.
> This would be enabled when at least one of CCID3_DEBUG or CCID4_DEBUG is enabled, and one could
> add some magic that the module parameters influence the boolean variable tfrc_debug.
>
> The same could be done for the RTO timer - since the identical menu appears in both places.
>
> Maybe it is better for the moment to `un-share' the code.
> -
> To unsubscribe from this list: send the line "unsubscribe dccp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
Yes Gerrit, this is one of the point that I will talk to you about. I
also agree with you, the best for the moment is to "un-share" this
function.
Leandro.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-11-13 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-01 0:31 [PATCH 17/25] Share ccid3_tx_state_name function via tfrc_ccids Leandro
2007-11-01 12:36 ` Tommi Saviranta
2007-11-10 12:31 ` Gerrit Renker
2007-11-13 16:14 ` Łeandro Sales
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.