Skip to contentSkip to conversation

Share ccid3_tx_state_name function via tfrc_ccids

PATCH In review Leandro 3 participants 4 messages Nov 1, 2007 – Nov 13, 2007

lore
Share & tools
lore

Leandro

author
#0 lore raw

PATCH 17/25 Share ccid3_tx_state_name function via tfrc_ccids

[CCID-3/4] Share ccid3_tx_state_name function via tfrc_ccids

ccid3_tx_state_name is now tfrc_tx_state_name

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
+

#2 lore raw
In reply to Leandro

| [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.

#3 lore raw
In reply to Leandro

2007/11/10, Gerrit Renker <[email protected]>:

Quoted 31 lines

| [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.

Quoted 8 lines

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 [email protected]
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.