Skip to contentSkip to conversation

: Fix and simplify header includes

PATCH In review Gerrit Renker 2 participants 3 messages Jun 17, 2007 – Jun 28, 2007 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 8/9 : Fix and simplify header includes

[TFRC]: Fix and simplify header includes

This updates the header-include structure so that any module wishing to use the service of the tfrc_lib module needs only include "tfrc.h" and has access to all declarations it needs.

---
 net/dccp/ccids/ccid3.c              |    4 ----
 net/dccp/ccids/ccid3.h              |    7 +++----
 net/dccp/ccids/lib/loss_interval.c  |    5 +----
 net/dccp/ccids/lib/loss_interval.h  |    1 -
 net/dccp/ccids/lib/packet_history.c |    1 -
 net/dccp/ccids/lib/packet_history.h |    6 ++----
 net/dccp/ccids/lib/tfrc.h           |    5 +++++
 7 files changed, 11 insertions(+), 18 deletions(-)
net/dccp/ccids/lib/tfrc.h +5 -0
@@ -16,6 +16,11 @@
 #include <linux/types.h>
 #include <asm/div64.h>
 #include "../../dccp.h"
+/* internal includes that this module exports: */
+struct tfrc_rx_hist;
+struct tfrc_loss_hist;
+#include "loss_interval.h"
+#include "packet_history.h"
 
 #ifdef CONFIG_IP_DCCP_TFRC_DEBUG
 extern int tfrc_debug;
net/dccp/ccids/lib/loss_interval.c +1 -4
@@ -10,11 +10,8 @@
  *  the Free Software Foundation; either version 2 of the License, or
  *  (at your option) any later version.
  */
-
-#include <linux/module.h>
 #include <net/sock.h>
-#include "../../dccp.h"
-#include "loss_interval.h"
+#include "tfrc.h"
 
 static struct kmem_cache  *tfrc_lh_slab;
 /* Loss Interval weights from [RFC 3448, 5.4], scaled by 10 */
net/dccp/ccids/ccid3.h +3 -4
@@ -1,3 +1,5 @@
+#ifndef _DCCP_CCID3_H_
+#define _DCCP_CCID3_H_
 /*
  *  net/dccp/ccids/ccid3.h
  *
@@ -33,15 +35,12 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#ifndef _DCCP_CCID3_H_
-#define _DCCP_CCID3_H_
-
 #include <linux/ktime.h>
 #include <linux/list.h>
 #include <linux/time.h>
 #include <linux/types.h>
 #include <linux/tfrc.h>
-#include "lib/packet_history.h"
+#include "lib/tfrc.h"
 #include "../ccid.h"
 
 /* Two seconds as per RFC 3448 4.2 */
net/dccp/ccids/ccid3.c +0 -4
@@ -33,11 +33,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-#include "../ccid.h"
 #include "../dccp.h"
-#include "lib/packet_history.h"
-#include "lib/loss_interval.h"
-#include "lib/tfrc.h"
 #include "ccid3.h"
 
 #ifdef CONFIG_IP_DCCP_CCID3_DEBUG
net/dccp/ccids/lib/packet_history.c +0 -1
@@ -33,7 +33,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-
 #include <linux/string.h>
 #include "packet_history.h"
 
net/dccp/ccids/lib/packet_history.h +2 -4
@@ -1,3 +1,5 @@
+#ifndef _DCCP_PKT_HIST_
+#define _DCCP_PKT_HIST_
 /*
  *  net/dccp/packet_history.h
  *
@@ -33,10 +35,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-
-#ifndef _DCCP_PKT_HIST_
-#define _DCCP_PKT_HIST_
-
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/time.h>
net/dccp/ccids/lib/loss_interval.h +0 -1
@@ -12,7 +12,6 @@
  *  Software Foundation; either version 2 of the License, or (at your option)
  *  any later version.
  */
-
 #include <linux/list.h>
 #include <linux/slab.h>
 #include <linux/time.h>
#1 lore raw
Quoted 6 lines · Gerrit Renker

[TFRC]: Fix and simplify header includes

net/dccp/ccids/lib/tfrc.h line 24

Quoted 9 lines
net/dccp/ccids/lib/tfrc.h +5 -0
@@ -16,6 +16,11 @@
 #include <linux/types.h>
 #include <asm/div64.h>
 #include "../../dccp.h"
+/* internal includes that this module exports: */
+struct tfrc_rx_hist;
+struct tfrc_loss_hist;
+#include "loss_interval.h"
+#include "packet_history.h"
 

Variable definitions in the middle of an include block? Is that necessary? I just haven't seen that done before and it looks a little odd...

Ian

Signature · 3 lines
Web: http://wand.net.nz/~iam4/
Blog: http://iansblog.jandi.co.nz
WAND Network Research Group
#2 lore raw
In reply to Gerrit Renker

Ian McDonald wrote:

|  > +/* internal includes that this module exports: */
|  > +struct tfrc_rx_hist;
|  > +struct tfrc_loss_hist;
|  > +#include "loss_interval.h"
|  > +#include "packet_history.h"
|  >
|  
|  Variable definitions in the middle of an include block? Is that
|  necessary? I just haven't seen that done before and it looks a little
|  odd...
|  

You are right, that is ugly, which is why I have changed it - see subsequent patch. The forward declarations of the two structures are needed since both sub-units -- receiver history and (receiver) loss detection work tightly together

* the RX history does loss detection and needs to know where to pass on a newly identified loss. This is done by tfrc_rx_handle_loss() which talks to struct tfrc_loss_hist.

* the loss interval database needs to access information stored in the receiver history record when creating a new loss interval, to identify whether a loss event starts a new loss interval, and for several internal uses. This is done in tfrc_lh_interval_add(), which talks to struct tfrc_loss_hist.