Skip to contentSkip to conversation

Checkpatch cleanups

B.A.T.M.A.N. In review Sven Eckelmann 2 participants 10 messages Apr 29, 2010

lore
Share & tools
lore
#0 lore raw

Hi,

last year in December we decided that it is not worth to strictly follow the 80 chars per line rule in the linux coding style document. But after receiving 3 patches in the last month to fix such or similar problems (which could not be merged due to other changes already applied to both branches) I want to propose following patches which try to resolve these problems in files which get submitted to the mainline kernel.

For trunk:
[PATCH-trunk 1/2] batman-adv: Fix whitespace problems criticized by checkpatch.pl [PATCH-trunk 2/2] batman-adv: Reduce max characters on a line to 80

For maint branch:
[PATCH-maint 1/2] batman-adv: Fix whitespace problems criticized by checkpatch.pl [PATCH-maint 2/2] batman-adv: Reduce max characters on a line to 80

Best regards,
Sven

#1 lore raw

PATCH 1/2 batman-adv: Fix whitespace problems criticized by checkpatch.pl

Trailing spaces at the end of a line or before a tab are against Documentation/CodingStyle "3.1: Spaces" and should be avoided. It is also common style to add a single space after commas unless it is followed either by a newline or a tab.

---
 bitarray.c   |    2 +-
 main.h       |    2 +-
 originator.c |    4 ++--
 types.h      |    4 ++--
 vis.c        |    6 +++---
 5 files changed, 9 insertions(+), 9 deletions(-)
bitarray.c +1 -1
index 437cff8..2fef6e3 100644
@@ -150,7 +150,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int16_t seq_num_diff,
 
 	/* sequence number is much newer, probably missed a lot of packets */
 
-	if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) 
+	if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE)
 		|| (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
 		bat_dbg(DBG_BATMAN,
 			"We missed a lot of packets (%i) !\n",
main.h +1 -1
index 2ce3b45..a2e819b 100644
@@ -70,7 +70,7 @@
 #define MODULE_DEACTIVATING 2
 
 #define BCAST_QUEUE_LEN		256
-#define BATMAN_QUEUE_LEN 	256
+#define BATMAN_QUEUE_LEN	256
 
 /*
  * Debug Messages
originator.c +2 -2
index 9ccb486..3a9430c 100644
@@ -298,7 +298,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	rcu_read_lock();
 	hdr_len = sprintf(buff,
-		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
+		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 		   "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
 		   "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
 		   bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
@@ -355,7 +355,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	if ((batman_count == 0) && (off == 0))
 		bytes_written += sprintf(buff + bytes_written,
-					"No batman nodes in range ... \n");
+					"No batman nodes in range ...\n");
 
 	return bytes_written;
 }
types.h +2 -2
index c926219..c0ede3c 100644
@@ -59,8 +59,8 @@ struct orig_node {               /* structure for orig_list maintaining nodes of
 					    seqno window was reset. */
 	unsigned long batman_seqno_reset;/* time when the batman seqno
 					    window was reset. */
-/*	uint8_t  gwflags;      * flags related to gateway functions: gateway class */
-	uint8_t  flags;    		/* for now only VIS_SERVER flag. */
+/*	uint8_t  gwflags;		  * flags related to gateway functions: gateway class */
+	uint8_t  flags;			 /* for now only VIS_SERVER flag. */
 	unsigned char *hna_buff;
 	int16_t  hna_buff_len;
 	uint16_t last_real_seqno;   /* last and best known squence number */
vis.c +3 -3
index 3144439..b9fa04c 100644
@@ -40,9 +40,9 @@
     * before adding more than 127 to the starting value - it is a predecessor,
     * when adding 128 - it is neither a predecessor nor a successor,
     * after adding more than 127 to the starting value - it is a successor */
-#define seq_before(x,y) ({typeof(x) _dummy = (x - y); \
-                         _dummy > smallest_signed_int(_dummy); })
-#define seq_after(x,y) seq_before(y,x)
+#define seq_before(x, y) ({typeof(x) _dummy = (x - y); \
+			_dummy > smallest_signed_int(_dummy); })
+#define seq_after(x, y) seq_before(y, x)
 
 struct hashtable_t *vis_hash;
 DEFINE_SPINLOCK(vis_hash_lock);
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/2 batman-adv: Fix whitespace problems criticized by checkpatch.pl

In reply to Sven Eckelmann

Trailing spaces at the end of a line or before a tab are against Documentation/CodingStyle "3.1: Spaces" and should be avoided. It is also common style to add a single space after commas unless it is followed either by a newline or a tab.

---
 batman-adv-kernelland/bitarray.c   |    2 +-
 batman-adv-kernelland/main.h       |    2 +-
 batman-adv-kernelland/originator.c |    4 ++--
 batman-adv-kernelland/vis.c        |    6 +++---
 4 files changed, 7 insertions(+), 7 deletions(-)
batman-adv-kernelland/bitarray.c +1 -1
index 1fe1aa9..a607827 100644
@@ -150,7 +150,7 @@ char bit_get_packet(TYPE_OF_WORD *seq_bits, int32_t seq_num_diff,
 
 	/* sequence number is much newer, probably missed a lot of packets */
 
-	if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE) 
+	if ((seq_num_diff >= TQ_LOCAL_WINDOW_SIZE)
 		|| (seq_num_diff < EXPECTED_SEQNO_RANGE)) {
 		bat_dbg(DBG_BATMAN,
 			"We missed a lot of packets (%i) !\n",
batman-adv-kernelland/main.h +1 -1
index c00dcc4..2b47259 100644
@@ -77,7 +77,7 @@
 #define MODULE_DEACTIVATING 2
 
 #define BCAST_QUEUE_LEN		256
-#define BATMAN_QUEUE_LEN 	256
+#define BATMAN_QUEUE_LEN	256
 
 /*
  * Debug Messages
batman-adv-kernelland/originator.c +2 -2
index 896d8ce..e01459a 100644
@@ -309,7 +309,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	rcu_read_lock();
 	hdr_len = sprintf(buff,
-		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)] \n",
+		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 		   "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
 		   "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
 		   bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
@@ -366,7 +366,7 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	if ((batman_count == 0) && (off == 0))
 		bytes_written += sprintf(buff + bytes_written,
-					"No batman nodes in range ... \n");
+					"No batman nodes in range ...\n");
 
 	return bytes_written;
 }
batman-adv-kernelland/vis.c +3 -3
index 936806c..ddef7df 100644
@@ -40,9 +40,9 @@
     * before adding more than 127 to the starting value - it is a predecessor,
     * when adding 128 - it is neither a predecessor nor a successor,
     * after adding more than 127 to the starting value - it is a successor */
-#define seq_before(x,y) ({typeof(x) _dummy = (x - y); \
-                         _dummy > smallest_signed_int(_dummy); })
-#define seq_after(x,y) seq_before(y,x)
+#define seq_before(x, y) ({typeof(x) _dummy = (x - y); \
+			_dummy > smallest_signed_int(_dummy); })
+#define seq_after(x, y) seq_before(y, x)
 
 struct hashtable_t *vis_hash;
 DEFINE_SPINLOCK(vis_hash_lock);
Signature · 1 line
1.7.1
#3 lore raw

PATCH 2/2 batman-adv: Reduce max characters on a line to 80

In reply to Sven Eckelmann

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

---
 device.c            |   22 ++++++++++++++-----
 hard-interface.c    |   19 +++++++++++-----
 main.c              |   17 +++++++++-----
 main.h              |    3 +-
 originator.c        |   37 ++++++++++++++++++++++----------
 proc.c              |   15 +++++++++---
 routing.c           |   58 +++++++++++++++++++++++++++++++++++++-------------
 send.c              |   19 +++++++++++-----
 soft-interface.c    |    8 ++++--
 translation-table.c |   34 +++++++++++++++++++----------
 types.h             |   46 ++++++++++++++++++++++++++++------------
 11 files changed, 193 insertions(+), 85 deletions(-)
device.c +16 -6
index 5f7655b..bbd30f2 100644
@@ -58,7 +58,8 @@ int bat_device_setup(void)
 	/* register our device - kernel assigns a free major number */
 	tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
 	if (tmp_major < 0) {
-		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the character device failed with %d\n",
 			  tmp_major);
 		return 0;
 	}
@@ -66,7 +67,8 @@ int bat_device_setup(void)
 	batman_class = class_create(THIS_MODULE, "batman-adv");
 
 	if (IS_ERR(batman_class)) {
-		printk(KERN_ERR "batman-adv:Could not register class 'batman-adv'\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Could not register class 'batman-adv'\n");
 		return 0;
 	}
 
@@ -109,7 +111,9 @@ int bat_device_open(struct inode *inode, struct file *file)
 	}
 
 	if (i == ARRAY_SIZE(device_client_hash)) {
-		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Error - can't add another packet client: "
+		       "maximum number of clients reached\n");
 		kfree(device_client);
 		return -EXFULL;
 	}
@@ -210,7 +214,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	unsigned long flags;
 
 	if (len < sizeof(struct icmp_packet)) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"invalid packet size\n");
 		return -EINVAL;
 	}
 
@@ -221,12 +227,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 		return -EFAULT;
 
 	if (icmp_packet.packet_type != BAT_ICMP) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus packet type (expected: BAT_ICMP)\n");
 		return -EINVAL;
 	}
 
 	if (icmp_packet.msg_type != ECHO_REQUEST) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus message type (expected: ECHO_REQUEST)\n");
 		return -EINVAL;
 	}
 
hard-interface.c +13 -6
index 5799d6d..0a0ae9d 100644
@@ -150,9 +150,12 @@ static void check_known_mac_addr(uint8_t *addr)
 		if (!compare_orig(batman_if->net_dev->dev_addr, addr))
 			continue;
 
-		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
-		       addr, batman_if->dev);
-		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+		printk(KERN_WARNING "batman-adv:"
+		    "The newly added mac address (%pM) already exists on: %s\n",
+		    addr, batman_if->dev);
+		printk(KERN_WARNING "batman-adv:"
+		    "It is strongly recommended to keep mac addresses unique"
+		    "to avoid problems!\n");
 	}
 	rcu_read_unlock();
 }
@@ -243,7 +246,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
 
 	if (!batman_if->packet_buff) {
-		printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface packet (%s): out of memory\n",
 		       batman_if->dev);
 		goto err;
 	}
@@ -267,7 +271,9 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	if (hardif_is_iface_up(batman_if))
 		hardif_activate_interface(bat_priv, batman_if);
 	else
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
+		printk(KERN_ERR "batman-adv:"
+		       "Not using interface %s (retrying later): "
+		       "interface not active\n", batman_if->dev);
 
 	/* begin scheduling originator messages on that interface */
 	schedule_own_packet(batman_if);
@@ -317,7 +323,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 
 	batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
 	if (!batman_if) {
-		printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface (%s): out of memory\n",
 		       net_dev->name);
 		goto out;
 	}
main.c +11 -6
index 17810d0..6c39990 100644
@@ -100,14 +100,16 @@ int init_module(void)
 				   interface_setup);
 
 	if (!soft_device) {
-		printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to allocate the batman interface\n");
 		goto end;
 	}
 
 	retval = register_netdev(soft_device);
 
 	if (retval < 0) {
-		printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to register the batman interface: %i\n", retval);
 		goto free_soft_device;
 	}
 
@@ -119,8 +121,9 @@ int init_module(void)
 	register_netdevice_notifier(&hard_if_notifier);
 	dev_add_pack(&batman_adv_packet_type);
 
-	printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
-		  SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
+	printk(KERN_INFO "batman-adv:"
+	       "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
+	       SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
 
 	return 0;
 
@@ -177,7 +180,9 @@ void activate_module(void)
 	goto end;
 
 err:
-	printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
+	printk(KERN_ERR "batman-adv:"
+	       "Unable to allocate memory for mesh information structures: "
+	       "out of mem ?\n");
 	deactivate_module();
 end:
 	return;
@@ -219,7 +224,7 @@ void dec_module_count(void)
 
 int addr_to_string(char *buff, uint8_t *addr)
 {
-	return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x",
+	return sprintf(buff, MAC_FMT,
 		       addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
 }
 
main.h +2 -1
index a2e819b..8d6c1a0 100644
@@ -22,7 +22,8 @@
 /* Kernel Programming */
 #define LINUX
 
-#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, Simon Wunderlich <[email protected]>"
+#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \
+		      "Simon Wunderlich <[email protected]>"
 #define DRIVER_DESC   "B.A.T.M.A.N. advanced"
 #define DRIVER_DEVICE "batman-adv"
 
originator.c +25 -12
index 3a9430c..a2c60d0 100644
@@ -141,8 +141,10 @@ struct orig_node *get_orig_node(uint8_t *addr)
 	memcpy(orig_node->orig, addr, ETH_ALEN);
 	orig_node->router = NULL;
 	orig_node->hna_buff = NULL;
-	orig_node->bcast_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
-	orig_node->batman_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
+	orig_node->bcast_seqno_reset = jiffies - 1
+					- msecs_to_jiffies(RESET_PROTECTION_MS);
+	orig_node->batman_seqno_reset = jiffies - 1
+					- msecs_to_jiffies(RESET_PROTECTION_MS);
 
 	size = bat_priv->num_ifaces * sizeof(TYPE_OF_WORD) * NUM_WORDS;
 
@@ -199,11 +201,15 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
 
 			if (neigh_node->if_incoming->if_status ==
 							IF_TO_BE_REMOVED)
-				bat_dbg(DBG_BATMAN, "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
+				bat_dbg(DBG_BATMAN,
+					"neighbor purge: originator %pM, "
+					"neighbor: %pM, iface: %s\n",
 					orig_node->orig, neigh_node->addr,
 					neigh_node->if_incoming->dev);
 			else
-				bat_dbg(DBG_BATMAN, "neighbor timeout: originator %pM, neighbor: %pM, last_valid: %lu\n",
+				bat_dbg(DBG_BATMAN,
+					"neighbor timeout: originator %pM, "
+					"neighbor: %pM, last_valid: %lu\n",
 					orig_node->orig, neigh_node->addr,
 					(neigh_node->last_valid / HZ));
 
@@ -281,8 +287,9 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
@@ -290,7 +297,8 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (bat_priv->primary_if->if_status != IF_ACTIVE) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
 				       net_dev->name);
 
 		return 0;
@@ -298,7 +306,8 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	rcu_read_lock();
 	hdr_len = sprintf(buff,
-		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
+		   "  %-14s (%s/%i) %17s [%10s]: %20s ... "
+		   "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 		   "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
 		   "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
 		   bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
@@ -367,7 +376,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
 	data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
 			   GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -378,7 +388,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
 
 	data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -427,7 +438,8 @@ static int orig_node_del_if(struct orig_node *orig_node,
 	chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
 	data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -448,7 +460,8 @@ free_bcast_own:
 
 	data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
proc.c +11 -4
index 2bc474e..8526e7e 100644
@@ -68,7 +68,8 @@ static ssize_t proc_interfaces_write(struct file *instance,
 		return -ENOMEM;
 
 	if (count > IFNAMSIZ - 1) {
-		printk(KERN_WARNING "batman-adv:Can't add interface: device name is too long\n");
+		printk(KERN_WARNING "batman-adv:"
+		       "Can't add interface: device name is too long\n");
 		goto end;
 	}
 
@@ -95,7 +96,9 @@ static ssize_t proc_interfaces_write(struct file *instance,
 	rcu_read_lock();
 	list_for_each_entry_rcu(batman_if, &if_list, list) {
 		if (strncmp(batman_if->dev, if_string, count) == 0) {
-			printk(KERN_ERR "batman-adv:Given interface is already active: %s\n", if_string);
+			printk(KERN_ERR "batman-adv:"
+			       "Given interface is already active: %s\n",
+			       if_string);
 			rcu_read_unlock();
 			goto end;
 
@@ -152,7 +155,9 @@ int setup_procfs(void)
 #endif
 
 	if (!proc_batman_dir) {
-		printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s' folder failed\n", PROC_ROOT_DIR);
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the '/proc/net/%s' folder failed\n",
+		       PROC_ROOT_DIR);
 		return -EFAULT;
 	}
 
@@ -162,7 +167,9 @@ int setup_procfs(void)
 	if (proc_interface_file) {
 		proc_interface_file->proc_fops = &proc_interfaces_fops;
 	} else {
-		printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_INTERFACES);
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the '/proc/net/%s/%s' file failed\n",
+		       PROC_ROOT_DIR, PROC_FILE_INTERFACES);
 		cleanup_procfs();
 		return -EFAULT;
 	}
routing.c +43 -15

137 lines not on this page · raw message

send.c +13 -6
index caec6ef..7f3031d 100644
@@ -67,7 +67,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		printk(KERN_WARNING
-		       "batman-adv:Interface %s is not up - can't send packet via that interface!\n",
+		       "batman-adv:Interface %s is not up - "
+		       "can't send packet via that interface!\n",
 		       batman_if->dev);
 		goto send_skb_err;
 	}
@@ -149,7 +150,9 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 							    "Sending own" :
 							    "Forwarding"));
 		bat_dbg(DBG_BATMAN,
-			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) on interface %s [%s]\n",
+			"%s %spacket "
+			"(originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) "
+			"on interface %s [%s]\n",
 			fwd_str,
 			(packet_num > 0 ? "aggregated " : ""),
 			batman_packet->orig, ntohs(batman_packet->seqno),
@@ -179,7 +182,8 @@ static void send_packet(struct forw_packet *forw_packet)
 	unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
 
 	if (!forw_packet->if_incoming) {
-		printk(KERN_ERR "batman-adv: Error - can't forward packet: incoming iface not specified\n");
+		printk(KERN_ERR "batman-adv: Error - can't forward packet: "
+		       "incoming iface not specified\n");
 		return;
 	}
 
@@ -193,7 +197,8 @@ static void send_packet(struct forw_packet *forw_packet)
 
 		/* FIXME: what about aggregated packets ? */
 		bat_dbg(DBG_BATMAN,
-			"%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%s]\n",
+			"%s packet (originator %pM, seqno %d, TTL %d) "
+			"on interface %s [%s]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_packet->orig, ntohs(batman_packet->seqno),
 			batman_packet->ttl, forw_packet->if_incoming->dev,
@@ -323,7 +328,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 			batman_packet->tq = orig_node->router->tq_avg;
 
 			if (orig_node->router->last_ttl)
-				batman_packet->ttl = orig_node->router->last_ttl - 1;
+				batman_packet->ttl = orig_node->router->last_ttl
+							- 1;
 		}
 
 		tq_avg = orig_node->router->tq_avg;
@@ -332,7 +338,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 	/* apply hop penalty */
 	batman_packet->tq = hop_penalty(batman_packet->tq);
 
-	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
+	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, "
+		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
 		in_tq, tq_avg, batman_packet->tq, in_ttl - 1,
 		batman_packet->ttl);
 
soft-interface.c +5 -3
index 37a1f44..2a2f079 100644
@@ -237,6 +237,8 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
 
 		if ((orig_node) &&
 		    (orig_node->router)) {
+			struct neigh_node *router = orig_node->router;
+
 			if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
 				goto unlock;
 
@@ -251,14 +253,14 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
 			memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
 
 			/* net_dev won't be available when not active */
-			if (orig_node->router->if_incoming->if_status != IF_ACTIVE)
+			if (router->if_incoming->if_status != IF_ACTIVE)
 				goto unlock;
 
 			/* don't lock while sending the packets ... we therefore
 			 * copy the required data before sending */
 
-			batman_if = orig_node->router->if_incoming;
-			memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
+			batman_if = router->if_incoming;
+			memcpy(dstaddr, router->addr, ETH_ALEN);
 			spin_unlock_irqrestore(&orig_hash_lock, flags);
 
 			send_skb_packet(skb, batman_if, dstaddr);
translation-table.c +22 -12
index 3ce39a6..a60bc7e 100644
@@ -78,7 +78,10 @@ void hna_local_add(uint8_t *addr)
 	   MAC-flooding. */
 	if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
 	    (num_hna + 1 > 255)) {
-		bat_dbg(DBG_ROUTES, "Can't add new local hna entry (%pM): number of local hna entries exceeds packet size\n", addr);
+		bat_dbg(DBG_ROUTES,
+			"Can't add new local hna entry (%pM): "
+			"number of local hna entries exceeds packet size\n",
+			addr);
 		return;
 	}
 
@@ -109,7 +112,8 @@ void hna_local_add(uint8_t *addr)
 				       hna_local_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize local hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize local hna hash table\n");
 		else
 			hna_local_hash = swaphash;
 	}
@@ -170,14 +174,16 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Locally retrieved addresses (from %s) announced via HNA:\n",
+			  "Locally retrieved addresses (from %s) "
+			  "announced via HNA:\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -197,7 +203,7 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_local_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 22,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT "\n",
 					  hna_local_entry->addr[0],
 					  hna_local_entry->addr[1],
 					  hna_local_entry->addr[2],
@@ -318,7 +324,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 			memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);
 
 			bat_dbg(DBG_ROUTES,
-				"Creating new global hna entry: %pM (via %pM)\n",
+				"Creating new global hna entry: "
+				"%pM (via %pM)\n",
 				hna_global_entry->addr, orig_node->orig);
 
 			spin_lock_irqsave(&hna_global_hash_lock, flags);
@@ -363,7 +370,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 				       hna_global_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize global hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize global hna hash table\n");
 		else
 			hna_global_hash = swaphash;
 	}
@@ -384,14 +392,16 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Globally announced HNAs received via the mesh %s (translation table):\n",
+			  "Globally announced HNAs received via the mesh %s "
+			  "(translation table):\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -411,7 +421,7 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_global_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 44,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT " via " MAC_FMT "\n",
 					  hna_global_entry->addr[0],
 					  hna_global_entry->addr[1],
 					  hna_global_entry->addr[2],
types.h +32 -14

82 lines not on this page · raw message

Signature · 1 line
1.7.1
#4 lore raw

Re: [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Reduce max characters on a line to 80

Quoted 5 lines · Sven Eckelmann

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

Hi Sven

This rules seems to be in dispute. I've seen comments that this should not be done since it can prevent a grep -r from finding the string when it is split over multiple lines.

But as you said, we repeatedly get patches from people trying to remove these checkpatch warnings.....

So we need a compromise. Overall i like what you have done.

device.c int bat_device_setup(void) · line 63

Quoted 4 lines
device.c +2 -1
-		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the character device failed with %d\n",
 			  tmp_major);

I like that you have consistently broken the text after "batman-adv:". Hopefully people will grep without the prefix because generally it has very little value.

hard-interface.c static void check_known_mac_addr(uint8_t *addr) · line 158

Quoted 9 lines
hard-interface.c +6 -3
-		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
-		       addr, batman_if->dev);
-		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+		printk(KERN_WARNING "batman-adv:"
+		    "The newly added mac address (%pM) already exists on: %s\n",
+		    addr, batman_if->dev);
+		printk(KERN_WARNING "batman-adv:"
+		    "It is strongly recommended to keep mac addresses unique"
+		    "to avoid problems!\n");

Thinking about the grep use case, i like that you have split after a variable, which grep will not match on.

hard-interface.c int hardif_enable_interface(struct batman_if *batman_if) · line 276

Quoted 4 lines
hard-interface.c +3 -1
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
+		printk(KERN_ERR "batman-adv:"
+		       "Not using interface %s (retrying later): "
+		       "interface not active\n", batman_if->dev);

Here i would of probably broken the line after %s to keep the rest together.

originator.c ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, · line 295

Quoted 12 lines
originator.c +3 -2
@@ -281,8 +287,9 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}

How about combining to two if's into one, so reducing the indentation, and break the line after %s?

originator.c ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, · line 304

Quoted 10 lines
originator.c +2 -1
@@ -290,7 +297,8 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (bat_priv->primary_if->if_status != IF_ACTIVE) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
 				       net_dev->name);
 
 		return 0;

Same again.

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 473

Quoted 7 lines
routing.c +2 -1
@@ -458,13 +469,16 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 
 	if (is_my_addr) {
 		bat_dbg(DBG_BATMAN,
-			"Drop packet: received my own broadcast (sender: %pM)\n",
+			"Drop packet: received my own broadcast "
+			"(sender: %pM)\n",

I know it probably looks a little odd, but maybe break before %pM so the constant text is whole?

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 481

Quoted 5 lines
routing.c +3 -1
 	if (is_broadcast) {
-		bat_dbg(DBG_BATMAN, "Drop packet: ignoring all packets with broadcast source addr (sender: %pM)\n", ethhdr->h_source);
+		bat_dbg(DBG_BATMAN, "Drop packet: "
+		"ignoring all packets with broadcast source addr "
+		"(sender: %pM)\n", ethhdr->h_source);

Same again?

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 517

Quoted 5 lines
routing.c +3 -1
 	if (is_my_oldorig) {
-		bat_dbg(DBG_BATMAN, "Drop packet: ignoring all rebroadcast echos (sender: %pM)\n", ethhdr->h_source);
+		bat_dbg(DBG_BATMAN,
+			"Drop packet: ignoring all rebroadcast echos "
+			"(sender: %pM)\n", ethhdr->h_source);

Same again...

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 530

Quoted 13 lines
routing.c +3 -1
 		return;
 	}
 
@@ -508,12 +525,15 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 	is_duplicate = count_real_packets(ethhdr, batman_packet, if_incoming);
 
 	if (is_duplicate == -1) {
-		bat_dbg(DBG_BATMAN, "Drop packet: packet within seqno protection time (sender: %pM)\n", ethhdr->h_source);
+		bat_dbg(DBG_BATMAN,
+			"Drop packet: packet within seqno protection time "
+			"(sender: %pM)\n", ethhdr->h_source);

Probably does not fit this time :-(

send.c int send_skb_packet(struct sk_buff *skb, · line 71

Quoted 11 lines
send.c +2 -1
index caec6ef..7f3031d 100644
@@ -67,7 +67,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		printk(KERN_WARNING
-		       "batman-adv:Interface %s is not up - can't send packet via that interface!\n",
+		       "batman-adv:Interface %s is not up - "
+		       "can't send packet via that interface!\n",

Maybe break after the %s?

send.c int send_skb_packet(struct sk_buff *skb,

Quoted 10 lines
send.c +3 -2
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;

Combine the two ifs and break on the %s?

send.c

Quoted 11 lines
send.c +11 -0
+/**
+  *	orig_node - structure for orig_list maintaining nodes of mesh
+  *	@last_valid: when last packet from this node was received
+  *	@bcast_seqno_reset: time when the broadcast seqno window was reset
+  *	@batman_seqno_reset: time when the batman seqno window was reset
+  *	@flags: for now only VIS_SERVER flag
+  *	@last_real_seqno: last and best known squence number
+  *	@last_ttl: ttl of last received packet
+  *	@last_bcast_seqno: last broadcast sequence number received by this host
+ */
+struct orig_node {

Nice :-)

Overall, good patch.

Andrew

#5 lore raw

Re: [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Reduce max characters on a line to 80

Quoted 9 lines · Andrew Lunn
Quoted 5 lines · Sven Eckelmann

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

Hi Sven

Quoted 8 lines

This rules seems to be in dispute. I've seen comments that this should not be done since it can prevent a grep -r from finding the string when it is split over multiple lines.

But as you said, we repeatedly get patches from people trying to remove these checkpatch warnings.....

So we need a compromise. Overall i like what you have done.

Thanks for these great comments. I will look again over the
"Reduce max characters on a line to 80" patches and submit v2 version of them
later.

Best regards,
Sven

#6 lore raw

Re: [B.A.T.M.A.N.] [PATCH-maint 2/2] batman-adv: Reduce max characters on a line to 80

In reply to Andrew Lunn
Quoted 24 lines · Andrew Lunn

hard-interface.c int hardif_enable_interface(struct batman_if *batman_if) · line 276

Quoted 5 lines
(quoted diff) +0 -1
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later):

interface not active\n", batman_if->dev); + printk(KERN_ERR
"batman-adv:"

hard-interface.c +2 -0
+		       "Not using interface %s (retrying later): "
+		       "interface not active\n", batman_if->dev);

Here i would of probably broken the line after %s to keep the rest together.

Quoted 15 lines
(quoted diff) +0 -1
@@ -281,8 +287,9 @@ ssize_t orig_fill_buffer_text(struct net_device
 *net_dev, char *buff,
 
 	if (!bat_priv->primary_if) {
 
 		if (off == 0)
 
 			return sprintf(buff,
 
-				       "BATMAN mesh %s disabled - please specify interfaces to

enable it\n", - net_dev->name);

originator.c +3 -0
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
Quoted 6 lines

device.c int bat_device_setup(void) · line 65

Quoted 3 lines
device.c +0 -0
 		return 0;
 
 	}

How about combining to two if's into one, so reducing the indentation, and break the line after %s?

In this case it doesn't work because the line would be still to long.

Quoted 14 lines
Quoted 14 lines
originator.c +2 -1
@@ -290,7 +297,8 @@ ssize_t orig_fill_buffer_text(struct net_device
 *net_dev, char *buff,
 
 	if (bat_priv->primary_if->if_status != IF_ACTIVE) {
 
 		if (off == 0)
 
 			return sprintf(buff,
 
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
Quoted 5 lines

originator.c ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff, · line 304

Quoted 3 lines
originator.c +0 -0
 				       net_dev->name);
 
 		return 0;

Same again.

Changed

Quoted 5 lines
Quoted 5 lines
routing.c +0 -0
@@ -458,13 +469,16 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 
 	if (is_my_addr) {
 
Quoted 8 lines

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 473

Quoted 5 lines
routing.c +2 -1
 		bat_dbg(DBG_BATMAN,
 
-			"Drop packet: received my own broadcast (sender: %pM)\n",
+			"Drop packet: received my own broadcast "
+			"(sender: %pM)\n",

I know it probably looks a little odd, but maybe break before %pM so the constant text is whole?

Done

Quoted 9 lines

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 481

Quoted 7 lines
routing.c +0 -1
 	if (is_broadcast) {
 
-		bat_dbg(DBG_BATMAN, "Drop packet: ignoring all packets with broadcast
 source addr (sender: %pM)\n", ethhdr->h_source); +		bat_dbg(DBG_BATMAN,

"Drop packet: "

routing.c +2 -0
+		"ignoring all packets with broadcast source addr "
+		"(sender: %pM)\n", ethhdr->h_source);

Same again?

Done

Quoted 8 lines

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 517

Quoted 6 lines
routing.c +0 -1
 	if (is_my_oldorig) {
 
-		bat_dbg(DBG_BATMAN, "Drop packet: ignoring all rebroadcast echos

(sender: %pM)\n", ethhdr->h_source); + bat_dbg(DBG_BATMAN,

routing.c +2 -0
+			"Drop packet: ignoring all rebroadcast echos "
+			"(sender: %pM)\n", ethhdr->h_source);

Same again...

Doesn't fit

Quoted 9 lines
Quoted 9 lines
routing.c +0 -0
 		return;
 
 	}
@@ -508,12 +525,15 @@ void receive_bat_packet(struct ethhdr *ethhdr,
 
 	is_duplicate = count_real_packets(ethhdr, batman_packet, if_incoming);
 
Quoted 8 lines

routing.c void receive_bat_packet(struct ethhdr *ethhdr, · line 530

Quoted 6 lines
routing.c +2 -1
 	if (is_duplicate == -1) {
 
-		bat_dbg(DBG_BATMAN, "Drop packet: packet within seqno protection time
 (sender: %pM)\n", ethhdr->h_source); +		bat_dbg(DBG_BATMAN,
+			"Drop packet: packet within seqno protection time "
+			"(sender: %pM)\n", ethhdr->h_source);

Probably does not fit this time :-(

Correct, doesn't fit.

Quoted 8 lines
Quoted 8 lines
send.c +0 -0
index caec6ef..7f3031d 100644
@@ -67,7 +67,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 
Quoted 7 lines

send.c int send_skb_packet(struct sk_buff *skb, · line 71

Quoted 5 lines
send.c +0 -1
 		printk(KERN_WARNING
 
-		       "batman-adv:Interface %s is not up - can't send packet via that

interface!\n", + "batman-adv:Interface %s is not up - "

send.c +1 -0
+		       "can't send packet via that interface!\n",

Maybe break after the %s?

Done

Quoted 12 lines
Quoted 12 lines
send.c +0 -1
 	if (!bat_priv->primary_if) {
 
 		if (off == 0)
 
 			return sprintf(buff,
 
-				       "BATMAN mesh %s disabled - please specify interfaces to

enable it\n", - net_dev->name);

send.c +3 -0
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
Quoted 3 lines
Quoted 1 line

return 0;

Combine the two ifs and break on the %s?

Still too long.

The rest of the patch was renewed and submitted as

[PATCH-trunk 2/2v2] batman-adv: Reduce max characters on a line to 80 [PATCH-maint 2/2v2] batman-adv: Reduce max characters on a line to 80

Best regards,
Sven

#7 lore raw

[B.A.T.M.A.N.] [PATCH-maint 2/2v2] batman-adv: Reduce max characters on a line to 80

In reply to Sven Eckelmann

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

---
 device.c            |   22 ++++++++++++++-----
 hard-interface.c    |   20 ++++++++++++-----
 main.c              |   17 +++++++++-----
 main.h              |    3 +-
 originator.c        |   47 +++++++++++++++++++++++++---------------
 proc.c              |   15 +++++++++---
 routing.c           |   58 +++++++++++++++++++++++++++++++++++++-------------
 send.c              |   21 +++++++++++-------
 soft-interface.c    |    8 ++++--
 translation-table.c |   34 +++++++++++++++++++----------
 types.h             |   46 ++++++++++++++++++++++++++++------------
 11 files changed, 198 insertions(+), 93 deletions(-)
device.c +16 -6
index 5f7655b..bbd30f2 100644
@@ -58,7 +58,8 @@ int bat_device_setup(void)
 	/* register our device - kernel assigns a free major number */
 	tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
 	if (tmp_major < 0) {
-		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the character device failed with %d\n",
 			  tmp_major);
 		return 0;
 	}
@@ -66,7 +67,8 @@ int bat_device_setup(void)
 	batman_class = class_create(THIS_MODULE, "batman-adv");
 
 	if (IS_ERR(batman_class)) {
-		printk(KERN_ERR "batman-adv:Could not register class 'batman-adv'\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Could not register class 'batman-adv'\n");
 		return 0;
 	}
 
@@ -109,7 +111,9 @@ int bat_device_open(struct inode *inode, struct file *file)
 	}
 
 	if (i == ARRAY_SIZE(device_client_hash)) {
-		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Error - can't add another packet client: "
+		       "maximum number of clients reached\n");
 		kfree(device_client);
 		return -EXFULL;
 	}
@@ -210,7 +214,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	unsigned long flags;
 
 	if (len < sizeof(struct icmp_packet)) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"invalid packet size\n");
 		return -EINVAL;
 	}
 
@@ -221,12 +227,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 		return -EFAULT;
 
 	if (icmp_packet.packet_type != BAT_ICMP) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus packet type (expected: BAT_ICMP)\n");
 		return -EINVAL;
 	}
 
 	if (icmp_packet.msg_type != ECHO_REQUEST) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus message type (expected: ECHO_REQUEST)\n");
 		return -EINVAL;
 	}
 
hard-interface.c +14 -6
index 5799d6d..c17ad85 100644
@@ -150,9 +150,12 @@ static void check_known_mac_addr(uint8_t *addr)
 		if (!compare_orig(batman_if->net_dev->dev_addr, addr))
 			continue;
 
-		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
-		       addr, batman_if->dev);
-		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+		printk(KERN_WARNING "batman-adv:"
+		    "The newly added mac address (%pM) already exists on: %s\n",
+		    addr, batman_if->dev);
+		printk(KERN_WARNING "batman-adv:"
+		    "It is strongly recommended to keep mac addresses unique"
+		    "to avoid problems!\n");
 	}
 	rcu_read_unlock();
 }
@@ -243,7 +246,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
 
 	if (!batman_if->packet_buff) {
-		printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface packet (%s): out of memory\n",
 		       batman_if->dev);
 		goto err;
 	}
@@ -267,7 +271,10 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	if (hardif_is_iface_up(batman_if))
 		hardif_activate_interface(bat_priv, batman_if);
 	else
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
+		printk(KERN_ERR "batman-adv:"
+		       "Not using interface %s "
+		       "(retrying later): interface not active\n",
+		       batman_if->dev);
 
 	/* begin scheduling originator messages on that interface */
 	schedule_own_packet(batman_if);
@@ -317,7 +324,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 
 	batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
 	if (!batman_if) {
-		printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface (%s): out of memory\n",
 		       net_dev->name);
 		goto out;
 	}
main.c +11 -6
index 17810d0..6c39990 100644
@@ -100,14 +100,16 @@ int init_module(void)
 				   interface_setup);
 
 	if (!soft_device) {
-		printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to allocate the batman interface\n");
 		goto end;
 	}
 
 	retval = register_netdev(soft_device);
 
 	if (retval < 0) {
-		printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to register the batman interface: %i\n", retval);
 		goto free_soft_device;
 	}
 
@@ -119,8 +121,9 @@ int init_module(void)
 	register_netdevice_notifier(&hard_if_notifier);
 	dev_add_pack(&batman_adv_packet_type);
 
-	printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
-		  SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
+	printk(KERN_INFO "batman-adv:"
+	       "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
+	       SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
 
 	return 0;
 
@@ -177,7 +180,9 @@ void activate_module(void)
 	goto end;
 
 err:
-	printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
+	printk(KERN_ERR "batman-adv:"
+	       "Unable to allocate memory for mesh information structures: "
+	       "out of mem ?\n");
 	deactivate_module();
 end:
 	return;
@@ -219,7 +224,7 @@ void dec_module_count(void)
 
 int addr_to_string(char *buff, uint8_t *addr)
 {
-	return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x",
+	return sprintf(buff, MAC_FMT,
 		       addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
 }
 
main.h +2 -1
index a2e819b..8d6c1a0 100644
@@ -22,7 +22,8 @@
 /* Kernel Programming */
 #define LINUX
 
-#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, Simon Wunderlich <[email protected]>"
+#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \
+		      "Simon Wunderlich <[email protected]>"
 #define DRIVER_DESC   "B.A.T.M.A.N. advanced"
 #define DRIVER_DEVICE "batman-adv"
 
originator.c +29 -18

100 lines not on this page · raw message

proc.c +11 -4
index 2bc474e..8526e7e 100644
@@ -68,7 +68,8 @@ static ssize_t proc_interfaces_write(struct file *instance,
 		return -ENOMEM;
 
 	if (count > IFNAMSIZ - 1) {
-		printk(KERN_WARNING "batman-adv:Can't add interface: device name is too long\n");
+		printk(KERN_WARNING "batman-adv:"
+		       "Can't add interface: device name is too long\n");
 		goto end;
 	}
 
@@ -95,7 +96,9 @@ static ssize_t proc_interfaces_write(struct file *instance,
 	rcu_read_lock();
 	list_for_each_entry_rcu(batman_if, &if_list, list) {
 		if (strncmp(batman_if->dev, if_string, count) == 0) {
-			printk(KERN_ERR "batman-adv:Given interface is already active: %s\n", if_string);
+			printk(KERN_ERR "batman-adv:"
+			       "Given interface is already active: %s\n",
+			       if_string);
 			rcu_read_unlock();
 			goto end;
 
@@ -152,7 +155,9 @@ int setup_procfs(void)
 #endif
 
 	if (!proc_batman_dir) {
-		printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s' folder failed\n", PROC_ROOT_DIR);
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the '/proc/net/%s' folder failed\n",
+		       PROC_ROOT_DIR);
 		return -EFAULT;
 	}
 
@@ -162,7 +167,9 @@ int setup_procfs(void)
 	if (proc_interface_file) {
 		proc_interface_file->proc_fops = &proc_interfaces_fops;
 	} else {
-		printk(KERN_ERR "batman-adv: Registering the '/proc/net/%s/%s' file failed\n", PROC_ROOT_DIR, PROC_FILE_INTERFACES);
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the '/proc/net/%s/%s' file failed\n",
+		       PROC_ROOT_DIR, PROC_FILE_INTERFACES);
 		cleanup_procfs();
 		return -EFAULT;
 	}
routing.c +43 -15

137 lines not on this page · raw message

send.c +13 -8
index caec6ef..ddcdf7a 100644
@@ -67,7 +67,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		printk(KERN_WARNING
-		       "batman-adv:Interface %s is not up - can't send packet via that interface!\n",
+		       "batman-adv:Interface %s "
+		       "is not up - can't send packet via that interface!\n",
 		       batman_if->dev);
 		goto send_skb_err;
 	}
@@ -149,9 +150,9 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 							    "Sending own" :
 							    "Forwarding"));
 		bat_dbg(DBG_BATMAN,
-			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) on interface %s [%s]\n",
-			fwd_str,
-			(packet_num > 0 ? "aggregated " : ""),
+			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d,"
+			" IDF %s) on interface %s [%s]\n",
+			fwd_str, (packet_num > 0 ? "aggregated " : ""),
 			batman_packet->orig, ntohs(batman_packet->seqno),
 			batman_packet->tq, batman_packet->ttl,
 			(batman_packet->flags & DIRECTLINK ?
@@ -179,7 +180,8 @@ static void send_packet(struct forw_packet *forw_packet)
 	unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
 
 	if (!forw_packet->if_incoming) {
-		printk(KERN_ERR "batman-adv: Error - can't forward packet: incoming iface not specified\n");
+		printk(KERN_ERR "batman-adv: Error - can't forward packet: "
+		       "incoming iface not specified\n");
 		return;
 	}
 
@@ -193,7 +195,8 @@ static void send_packet(struct forw_packet *forw_packet)
 
 		/* FIXME: what about aggregated packets ? */
 		bat_dbg(DBG_BATMAN,
-			"%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%s]\n",
+			"%s packet (originator %pM, seqno %d, TTL %d) "
+			"on interface %s [%s]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_packet->orig, ntohs(batman_packet->seqno),
 			batman_packet->ttl, forw_packet->if_incoming->dev,
@@ -323,7 +326,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 			batman_packet->tq = orig_node->router->tq_avg;
 
 			if (orig_node->router->last_ttl)
-				batman_packet->ttl = orig_node->router->last_ttl - 1;
+				batman_packet->ttl = orig_node->router->last_ttl
+							- 1;
 		}
 
 		tq_avg = orig_node->router->tq_avg;
@@ -332,7 +336,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 	/* apply hop penalty */
 	batman_packet->tq = hop_penalty(batman_packet->tq);
 
-	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
+	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, "
+		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
 		in_tq, tq_avg, batman_packet->tq, in_ttl - 1,
 		batman_packet->ttl);
 
soft-interface.c +5 -3
index 37a1f44..2a2f079 100644
@@ -237,6 +237,8 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
 
 		if ((orig_node) &&
 		    (orig_node->router)) {
+			struct neigh_node *router = orig_node->router;
+
 			if (my_skb_push(skb, sizeof(struct unicast_packet)) < 0)
 				goto unlock;
 
@@ -251,14 +253,14 @@ int interface_tx(struct sk_buff *skb, struct net_device *dev)
 			memcpy(unicast_packet->dest, orig_node->orig, ETH_ALEN);
 
 			/* net_dev won't be available when not active */
-			if (orig_node->router->if_incoming->if_status != IF_ACTIVE)
+			if (router->if_incoming->if_status != IF_ACTIVE)
 				goto unlock;
 
 			/* don't lock while sending the packets ... we therefore
 			 * copy the required data before sending */
 
-			batman_if = orig_node->router->if_incoming;
-			memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
+			batman_if = router->if_incoming;
+			memcpy(dstaddr, router->addr, ETH_ALEN);
 			spin_unlock_irqrestore(&orig_hash_lock, flags);
 
 			send_skb_packet(skb, batman_if, dstaddr);
translation-table.c +22 -12
index 3ce39a6..a60bc7e 100644
@@ -78,7 +78,10 @@ void hna_local_add(uint8_t *addr)
 	   MAC-flooding. */
 	if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
 	    (num_hna + 1 > 255)) {
-		bat_dbg(DBG_ROUTES, "Can't add new local hna entry (%pM): number of local hna entries exceeds packet size\n", addr);
+		bat_dbg(DBG_ROUTES,
+			"Can't add new local hna entry (%pM): "
+			"number of local hna entries exceeds packet size\n",
+			addr);
 		return;
 	}
 
@@ -109,7 +112,8 @@ void hna_local_add(uint8_t *addr)
 				       hna_local_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize local hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize local hna hash table\n");
 		else
 			hna_local_hash = swaphash;
 	}
@@ -170,14 +174,16 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Locally retrieved addresses (from %s) announced via HNA:\n",
+			  "Locally retrieved addresses (from %s) "
+			  "announced via HNA:\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -197,7 +203,7 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_local_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 22,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT "\n",
 					  hna_local_entry->addr[0],
 					  hna_local_entry->addr[1],
 					  hna_local_entry->addr[2],
@@ -318,7 +324,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 			memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);
 
 			bat_dbg(DBG_ROUTES,
-				"Creating new global hna entry: %pM (via %pM)\n",
+				"Creating new global hna entry: "
+				"%pM (via %pM)\n",
 				hna_global_entry->addr, orig_node->orig);
 
 			spin_lock_irqsave(&hna_global_hash_lock, flags);
@@ -363,7 +370,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 				       hna_global_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize global hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize global hna hash table\n");
 		else
 			hna_global_hash = swaphash;
 	}
@@ -384,14 +392,16 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Globally announced HNAs received via the mesh %s (translation table):\n",
+			  "Globally announced HNAs received via the mesh %s "
+			  "(translation table):\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -411,7 +421,7 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_global_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 44,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT " via " MAC_FMT "\n",
 					  hna_global_entry->addr[0],
 					  hna_global_entry->addr[1],
 					  hna_global_entry->addr[2],
types.h +32 -14

82 lines not on this page · raw message

Signature · 1 line
1.7.1
#8 lore raw

PATCH 2/2 batman-adv: Reduce max characters on a line to 80

In reply to Sven Eckelmann

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

---
 batman-adv-kernelland/bat_sysfs.c         |    3 +-
 batman-adv-kernelland/device.c            |   22 ++++++++---
 batman-adv-kernelland/gateway_client.c    |   27 +++++++++----
 batman-adv-kernelland/gateway_common.c    |   45 ++++++++++++++--------
 batman-adv-kernelland/hard-interface.c    |   19 ++++++---
 batman-adv-kernelland/main.c              |   17 +++++---
 batman-adv-kernelland/main.h              |    3 +-
 batman-adv-kernelland/originator.c        |   37 ++++++++++++------
 batman-adv-kernelland/routing.c           |   58 +++++++++++++++++++++-------
 batman-adv-kernelland/send.c              |   19 ++++++---
 batman-adv-kernelland/translation-table.c |   34 +++++++++++------
 batman-adv-kernelland/types.h             |   58 ++++++++++++++++++++--------
 12 files changed, 234 insertions(+), 108 deletions(-)
batman-adv-kernelland/bat_sysfs.c +2 -1
index 43feef5..edf5bce 100644
@@ -237,7 +237,8 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
 	case GW_MODE_SERVER:
 		gw_srv_class_to_kbit(gw_class, &down, &up);
 		bytes_written = sprintf(buff,
-					"status: %s (gw_class: %i -> propagating: %i%s/%i%s)\n",
+					"status: %s (gw_class: %i -> "
+					"propagating: %i%s/%i%s)\n",
 					GW_MODE_SERVER_NAME, gw_class,
 					(down > 2048 ? down / 1024 : down),
 					(down > 2048 ? "MBit" : "KBit"),
batman-adv-kernelland/device.c +16 -6
index c8ec4f9..8a99ea9 100644
@@ -58,7 +58,8 @@ int bat_device_setup(void)
 	/* register our device - kernel assigns a free major number */
 	tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
 	if (tmp_major < 0) {
-		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the character device failed with %d\n",
 			  tmp_major);
 		return 0;
 	}
@@ -66,7 +67,8 @@ int bat_device_setup(void)
 	batman_class = class_create(THIS_MODULE, "batman-adv");
 
 	if (IS_ERR(batman_class)) {
-		printk(KERN_ERR "batman-adv:Could not register class 'batman-adv'\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Could not register class 'batman-adv'\n");
 		return 0;
 	}
 
@@ -109,7 +111,9 @@ int bat_device_open(struct inode *inode, struct file *file)
 	}
 
 	if (i == ARRAY_SIZE(device_client_hash)) {
-		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Error - can't add another packet client: "
+		       "maximum number of clients reached\n");
 		kfree(device_client);
 		return -EXFULL;
 	}
@@ -213,7 +217,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	unsigned long flags;
 
 	if (len < sizeof(struct icmp_packet)) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"invalid packet size\n");
 		return -EINVAL;
 	}
 
@@ -227,12 +233,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 		return -EFAULT;
 
 	if (icmp_packet.packet_type != BAT_ICMP) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus packet type (expected: BAT_ICMP)\n");
 		return -EINVAL;
 	}
 
 	if (icmp_packet.msg_type != ECHO_REQUEST) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus message type (expected: ECHO_REQUEST)\n");
 		return -EINVAL;
 	}
 
batman-adv-kernelland/gateway_client.c +18 -9
index 1f662d8..be76483 100644
@@ -81,7 +81,8 @@ void gw_election(void)
 
 		if (curr_gateway) {
 			bat_dbg(DBG_BATMAN,
-				"Removing selected gateway - no gateway in range\n");
+				"Removing selected gateway - "
+				"no gateway in range\n");
 			gw_deselect();
 		}
 
@@ -137,16 +138,19 @@ void gw_election(void)
 	if (curr_gateway != curr_gw_tmp) {
 		if ((curr_gateway) && (!curr_gw_tmp))
 			bat_dbg(DBG_BATMAN,
-				"Removing selected gateway - no gateway in range\n");
+				"Removing selected gateway - "
+				"no gateway in range\n");
 		else if ((!curr_gateway) && (curr_gw_tmp))
 			bat_dbg(DBG_BATMAN,
-				"Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
+				"Adding route to gateway %pM "
+				"(gw_flags: %i, tq: %i)\n",
 				curr_gw_tmp->orig_node->orig,
 				curr_gw_tmp->orig_node->gw_flags,
 				curr_gw_tmp->orig_node->router->tq_avg);
 		else
 			bat_dbg(DBG_BATMAN,
-				"Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
+				"Changing route to gateway %pM "
+				"(gw_flags: %i, tq: %i)\n",
 				curr_gw_tmp->orig_node->orig,
 				curr_gw_tmp->orig_node->gw_flags,
 				curr_gw_tmp->orig_node->router->tq_avg);
@@ -197,7 +201,8 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
 		return;
 
 	bat_dbg(DBG_BATMAN,
-		"Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
+		"Restarting gateway selection: better gateway found "
+		"(tq curr: %i, tq new: %i)\n",
 		gw_tq_avg, orig_tq_avg);
 
 deselect:
@@ -239,7 +244,8 @@ void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags)
 			continue;
 
 		bat_dbg(DBG_BATMAN,
-			"Gateway class of originator %pM changed from %i to %i\n",
+			"Gateway class of originator %pM changed from "
+			"%i to %i\n",
 			orig_node->orig, gw_node->orig_node->gw_flags,
 			new_gwflags);
 
@@ -349,7 +355,8 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+				       "BATMAN mesh %s disabled - please "
+				       "specify interfaces to enable it\n",
 				       net_dev->name);
 
 		return 0;
@@ -360,14 +367,16 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
 				       net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "      %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
+			  "      %-12s (%s/%i) %17s [%10s]: gw_class ... "
+			  "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 			  "Gateway", "#", TQ_MAX_VALUE, "Nexthop",
 			  "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR,
 			  bat_priv->primary_if->dev,
batman-adv-kernelland/gateway_common.c +28 -17

94 lines not on this page · raw message

batman-adv-kernelland/hard-interface.c +13 -6
index 64307fc..74c0533 100644
@@ -150,9 +150,12 @@ static void check_known_mac_addr(uint8_t *addr)
 		if (!compare_orig(batman_if->net_dev->dev_addr, addr))
 			continue;
 
-		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
-		       addr, batman_if->dev);
-		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+		printk(KERN_WARNING "batman-adv:"
+		    "The newly added mac address (%pM) already exists on: %s\n",
+		    addr, batman_if->dev);
+		printk(KERN_WARNING "batman-adv:"
+		    "It is strongly recommended to keep mac addresses unique"
+		    "to avoid problems!\n");
 	}
 	rcu_read_unlock();
 }
@@ -243,7 +246,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
 
 	if (!batman_if->packet_buff) {
-		printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface packet (%s): out of memory\n",
 		       batman_if->dev);
 		goto err;
 	}
@@ -267,7 +271,9 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	if (hardif_is_iface_up(batman_if))
 		hardif_activate_interface(bat_priv, batman_if);
 	else
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
+		printk(KERN_ERR "batman-adv:"
+		       "Not using interface %s (retrying later): "
+		       "interface not active\n", batman_if->dev);
 
 	/* begin scheduling originator messages on that interface */
 	schedule_own_packet(batman_if);
@@ -317,7 +323,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 
 	batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
 	if (!batman_if) {
-		printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface (%s): out of memory\n",
 		       net_dev->name);
 		goto out;
 	}
batman-adv-kernelland/main.c +11 -6
index 1203d3f..d03a7fa 100644
@@ -92,14 +92,16 @@ int init_module(void)
 				   interface_setup);
 
 	if (!soft_device) {
-		printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to allocate the batman interface\n");
 		goto end;
 	}
 
 	retval = register_netdev(soft_device);
 
 	if (retval < 0) {
-		printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to register the batman interface: %i\n", retval);
 		goto free_soft_device;
 	}
 
@@ -111,8 +113,9 @@ int init_module(void)
 	register_netdevice_notifier(&hard_if_notifier);
 	dev_add_pack(&batman_adv_packet_type);
 
-	printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
-		  SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
+	printk(KERN_INFO "batman-adv:"
+	       "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
+	       SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
 
 	return 0;
 
@@ -169,7 +172,9 @@ void activate_module(void)
 	goto end;
 
 err:
-	printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
+	printk(KERN_ERR "batman-adv:"
+	       "Unable to allocate memory for mesh information structures: "
+	       "out of mem ?\n");
 	deactivate_module();
 end:
 	return;
@@ -212,7 +217,7 @@ void dec_module_count(void)
 
 int addr_to_string(char *buff, uint8_t *addr)
 {
-	return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x",
+	return sprintf(buff, MAC_FMT,
 		       addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
 }
 
batman-adv-kernelland/main.h +2 -1
index 2b47259..730343e 100644
@@ -22,7 +22,8 @@
 /* Kernel Programming */
 #define LINUX
 
-#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, Simon Wunderlich <[email protected]>"
+#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \
+		      "Simon Wunderlich <[email protected]>"
 #define DRIVER_DESC   "B.A.T.M.A.N. advanced"
 #define DRIVER_DEVICE "batman-adv"
 
batman-adv-kernelland/originator.c +25 -12
index e01459a..755443d 100644
@@ -142,8 +142,10 @@ struct orig_node *get_orig_node(uint8_t *addr)
 	memcpy(orig_node->orig, addr, ETH_ALEN);
 	orig_node->router = NULL;
 	orig_node->hna_buff = NULL;
-	orig_node->bcast_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
-	orig_node->batman_seqno_reset = jiffies - msecs_to_jiffies(RESET_PROTECTION_MS) - 1;
+	orig_node->bcast_seqno_reset = jiffies - 1
+					- msecs_to_jiffies(RESET_PROTECTION_MS);
+	orig_node->batman_seqno_reset = jiffies - 1
+					- msecs_to_jiffies(RESET_PROTECTION_MS);
 
 	size = bat_priv->num_ifaces * sizeof(TYPE_OF_WORD) * NUM_WORDS;
 
@@ -200,11 +202,15 @@ static bool purge_orig_neighbors(struct orig_node *orig_node,
 
 			if (neigh_node->if_incoming->if_status ==
 							IF_TO_BE_REMOVED)
-				bat_dbg(DBG_BATMAN, "neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
+				bat_dbg(DBG_BATMAN,
+					"neighbor purge: originator %pM, "
+					"neighbor: %pM, iface: %s\n",
 					orig_node->orig, neigh_node->addr,
 					neigh_node->if_incoming->dev);
 			else
-				bat_dbg(DBG_BATMAN, "neighbor timeout: originator %pM, neighbor: %pM, last_valid: %lu\n",
+				bat_dbg(DBG_BATMAN,
+					"neighbor timeout: originator %pM, "
+					"neighbor: %pM, last_valid: %lu\n",
 					orig_node->orig, neigh_node->addr,
 					(neigh_node->last_valid / HZ));
 
@@ -292,8 +298,9 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
@@ -301,7 +308,8 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (bat_priv->primary_if->if_status != IF_ACTIVE) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
 				       net_dev->name);
 
 		return 0;
@@ -309,7 +317,8 @@ ssize_t orig_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 	rcu_read_lock();
 	hdr_len = sprintf(buff,
-		   "  %-14s (%s/%i) %17s [%10s]: %20s ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
+		   "  %-14s (%s/%i) %17s [%10s]: %20s ... "
+		   "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 		   "Originator", "#", TQ_MAX_VALUE, "Nexthop", "outgoingIF",
 		   "Potential nexthops", SOURCE_VERSION, REVISION_VERSION_STR,
 		   bat_priv->primary_if->dev, bat_priv->primary_if->addr_str,
@@ -378,7 +387,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
 	data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS,
 			   GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -389,7 +399,8 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num)
 
 	data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -438,7 +449,8 @@ static int orig_node_del_if(struct orig_node *orig_node,
 	chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS;
 	data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
@@ -459,7 +471,8 @@ free_bcast_own:
 
 	data_ptr = kmalloc(max_if_num * sizeof(uint8_t), GFP_ATOMIC);
 	if (!data_ptr) {
-		printk(KERN_ERR "batman-adv:Can't resize orig: out of memory\n");
+		printk(KERN_ERR
+		       "batman-adv:Can't resize orig: out of memory\n");
 		return -1;
 	}
 
batman-adv-kernelland/routing.c +43 -15

137 lines not on this page · raw message

batman-adv-kernelland/send.c +13 -6
index 7667d1f..60fe6d8 100644
@@ -68,7 +68,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		printk(KERN_WARNING
-		       "batman-adv:Interface %s is not up - can't send packet via that interface!\n",
+		       "batman-adv:Interface %s is not up - "
+		       "can't send packet via that interface!\n",
 		       batman_if->dev);
 		goto send_skb_err;
 	}
@@ -150,7 +151,9 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 							    "Sending own" :
 							    "Forwarding"));
 		bat_dbg(DBG_BATMAN,
-			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) on interface %s [%s]\n",
+			"%s %spacket "
+			"(originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) "
+			"on interface %s [%s]\n",
 			fwd_str,
 			(packet_num > 0 ? "aggregated " : ""),
 			batman_packet->orig, ntohl(batman_packet->seqno),
@@ -180,7 +183,8 @@ static void send_packet(struct forw_packet *forw_packet)
 	unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
 
 	if (!forw_packet->if_incoming) {
-		printk(KERN_ERR "batman-adv: Error - can't forward packet: incoming iface not specified\n");
+		printk(KERN_ERR "batman-adv: Error - can't forward packet: "
+		       "incoming iface not specified\n");
 		return;
 	}
 
@@ -194,7 +198,8 @@ static void send_packet(struct forw_packet *forw_packet)
 
 		/* FIXME: what about aggregated packets ? */
 		bat_dbg(DBG_BATMAN,
-			"%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%s]\n",
+			"%s packet (originator %pM, seqno %d, TTL %d) "
+			"on interface %s [%s]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_packet->orig, ntohl(batman_packet->seqno),
 			batman_packet->ttl, forw_packet->if_incoming->dev,
@@ -330,7 +335,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 			batman_packet->tq = orig_node->router->tq_avg;
 
 			if (orig_node->router->last_ttl)
-				batman_packet->ttl = orig_node->router->last_ttl - 1;
+				batman_packet->ttl = orig_node->router->last_ttl
+							- 1;
 		}
 
 		tq_avg = orig_node->router->tq_avg;
@@ -339,7 +345,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 	/* apply hop penalty */
 	batman_packet->tq = hop_penalty(batman_packet->tq);
 
-	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
+	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, "
+		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
 		in_tq, tq_avg, batman_packet->tq, in_ttl - 1,
 		batman_packet->ttl);
 
batman-adv-kernelland/translation-table.c +22 -12
index 3ce39a6..a60bc7e 100644
@@ -78,7 +78,10 @@ void hna_local_add(uint8_t *addr)
 	   MAC-flooding. */
 	if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
 	    (num_hna + 1 > 255)) {
-		bat_dbg(DBG_ROUTES, "Can't add new local hna entry (%pM): number of local hna entries exceeds packet size\n", addr);
+		bat_dbg(DBG_ROUTES,
+			"Can't add new local hna entry (%pM): "
+			"number of local hna entries exceeds packet size\n",
+			addr);
 		return;
 	}
 
@@ -109,7 +112,8 @@ void hna_local_add(uint8_t *addr)
 				       hna_local_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize local hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize local hna hash table\n");
 		else
 			hna_local_hash = swaphash;
 	}
@@ -170,14 +174,16 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Locally retrieved addresses (from %s) announced via HNA:\n",
+			  "Locally retrieved addresses (from %s) "
+			  "announced via HNA:\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -197,7 +203,7 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_local_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 22,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT "\n",
 					  hna_local_entry->addr[0],
 					  hna_local_entry->addr[1],
 					  hna_local_entry->addr[2],
@@ -318,7 +324,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 			memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);
 
 			bat_dbg(DBG_ROUTES,
-				"Creating new global hna entry: %pM (via %pM)\n",
+				"Creating new global hna entry: "
+				"%pM (via %pM)\n",
 				hna_global_entry->addr, orig_node->orig);
 
 			spin_lock_irqsave(&hna_global_hash_lock, flags);
@@ -363,7 +370,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 				       hna_global_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize global hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize global hna hash table\n");
 		else
 			hna_global_hash = swaphash;
 	}
@@ -384,14 +392,16 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Globally announced HNAs received via the mesh %s (translation table):\n",
+			  "Globally announced HNAs received via the mesh %s "
+			  "(translation table):\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -411,7 +421,7 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_global_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 44,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT " via " MAC_FMT "\n",
 					  hna_global_entry->addr[0],
 					  hna_global_entry->addr[1],
 					  hna_global_entry->addr[2],
batman-adv-kernelland/types.h +41 -17

99 lines not on this page · raw message

Signature · 1 line
1.7.1
#9 lore raw

[B.A.T.M.A.N.] [PATCH-trunk 2/2v2] batman-adv: Reduce max characters on a line to 80

Documentation/CodingStyle sets a strongly prefered limit of 80 characters per line in "Chapter 2: Breaking long lines and strings".

Strings must be broken into smaller parts and long statements must be rewritten.

---
 batman-adv-kernelland/bat_sysfs.c         |    3 +-
 batman-adv-kernelland/device.c            |   22 ++++++++---
 batman-adv-kernelland/gateway_client.c    |   28 +++++++++-----
 batman-adv-kernelland/gateway_common.c    |   45 ++++++++++++++--------
 batman-adv-kernelland/hard-interface.c    |   20 +++++++---
 batman-adv-kernelland/main.c              |   17 +++++---
 batman-adv-kernelland/main.h              |    3 +-
 batman-adv-kernelland/originator.c        |   47 ++++++++++++++---------
 batman-adv-kernelland/routing.c           |   58 +++++++++++++++++++++-------
 batman-adv-kernelland/send.c              |   19 ++++++---
 batman-adv-kernelland/translation-table.c |   34 +++++++++++------
 batman-adv-kernelland/types.h             |   58 ++++++++++++++++++++--------
 12 files changed, 239 insertions(+), 115 deletions(-)
batman-adv-kernelland/bat_sysfs.c +2 -1
index 43feef5..25193b0 100644
@@ -237,7 +237,8 @@ static ssize_t show_gw_mode(struct kobject *kobj, struct attribute *attr,
 	case GW_MODE_SERVER:
 		gw_srv_class_to_kbit(gw_class, &down, &up);
 		bytes_written = sprintf(buff,
-					"status: %s (gw_class: %i -> propagating: %i%s/%i%s)\n",
+					"status: %s (gw_class: %i "
+					"-> propagating: %i%s/%i%s)\n",
 					GW_MODE_SERVER_NAME, gw_class,
 					(down > 2048 ? down / 1024 : down),
 					(down > 2048 ? "MBit" : "KBit"),
batman-adv-kernelland/device.c +16 -6
index c8ec4f9..8a99ea9 100644
@@ -58,7 +58,8 @@ int bat_device_setup(void)
 	/* register our device - kernel assigns a free major number */
 	tmp_major = register_chrdev(0, DRIVER_DEVICE, &fops);
 	if (tmp_major < 0) {
-		printk(KERN_ERR "batman-adv:Registering the character device failed with %d\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Registering the character device failed with %d\n",
 			  tmp_major);
 		return 0;
 	}
@@ -66,7 +67,8 @@ int bat_device_setup(void)
 	batman_class = class_create(THIS_MODULE, "batman-adv");
 
 	if (IS_ERR(batman_class)) {
-		printk(KERN_ERR "batman-adv:Could not register class 'batman-adv'\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Could not register class 'batman-adv'\n");
 		return 0;
 	}
 
@@ -109,7 +111,9 @@ int bat_device_open(struct inode *inode, struct file *file)
 	}
 
 	if (i == ARRAY_SIZE(device_client_hash)) {
-		printk(KERN_ERR "batman-adv:Error - can't add another packet client: maximum number of clients reached\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Error - can't add another packet client: "
+		       "maximum number of clients reached\n");
 		kfree(device_client);
 		return -EXFULL;
 	}
@@ -213,7 +217,9 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 	unsigned long flags;
 
 	if (len < sizeof(struct icmp_packet)) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: invalid packet size\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"invalid packet size\n");
 		return -EINVAL;
 	}
 
@@ -227,12 +233,16 @@ ssize_t bat_device_write(struct file *file, const char __user *buff,
 		return -EFAULT;
 
 	if (icmp_packet.packet_type != BAT_ICMP) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus packet type (expected: BAT_ICMP)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus packet type (expected: BAT_ICMP)\n");
 		return -EINVAL;
 	}
 
 	if (icmp_packet.msg_type != ECHO_REQUEST) {
-		bat_dbg(DBG_BATMAN, "batman-adv:Error - can't send packet from char device: got bogus message type (expected: ECHO_REQUEST)\n");
+		bat_dbg(DBG_BATMAN, "batman-adv:"
+			"Error - can't send packet from char device: "
+			"got bogus message type (expected: ECHO_REQUEST)\n");
 		return -EINVAL;
 	}
 
batman-adv-kernelland/gateway_client.c +18 -10
index 1f662d8..a5e4f5f 100644
@@ -81,7 +81,8 @@ void gw_election(void)
 
 		if (curr_gateway) {
 			bat_dbg(DBG_BATMAN,
-				"Removing selected gateway - no gateway in range\n");
+				"Removing selected gateway - "
+				"no gateway in range\n");
 			gw_deselect();
 		}
 
@@ -137,16 +138,19 @@ void gw_election(void)
 	if (curr_gateway != curr_gw_tmp) {
 		if ((curr_gateway) && (!curr_gw_tmp))
 			bat_dbg(DBG_BATMAN,
-				"Removing selected gateway - no gateway in range\n");
+				"Removing selected gateway - "
+				"no gateway in range\n");
 		else if ((!curr_gateway) && (curr_gw_tmp))
 			bat_dbg(DBG_BATMAN,
-				"Adding route to gateway %pM (gw_flags: %i, tq: %i)\n",
+				"Adding route to gateway %pM "
+				"(gw_flags: %i, tq: %i)\n",
 				curr_gw_tmp->orig_node->orig,
 				curr_gw_tmp->orig_node->gw_flags,
 				curr_gw_tmp->orig_node->router->tq_avg);
 		else
 			bat_dbg(DBG_BATMAN,
-				"Changing route to gateway %pM (gw_flags: %i, tq: %i)\n",
+				"Changing route to gateway %pM "
+				"(gw_flags: %i, tq: %i)\n",
 				curr_gw_tmp->orig_node->orig,
 				curr_gw_tmp->orig_node->gw_flags,
 				curr_gw_tmp->orig_node->router->tq_avg);
@@ -197,7 +201,8 @@ void gw_check_election(struct bat_priv *bat_priv, struct orig_node *orig_node)
 		return;
 
 	bat_dbg(DBG_BATMAN,
-		"Restarting gateway selection: better gateway found (tq curr: %i, tq new: %i)\n",
+		"Restarting gateway selection: better gateway found (tq curr: "
+		"%i, tq new: %i)\n",
 		gw_tq_avg, orig_tq_avg);
 
 deselect:
@@ -239,7 +244,8 @@ void gw_node_update(struct orig_node *orig_node, uint8_t new_gwflags)
 			continue;
 
 		bat_dbg(DBG_BATMAN,
-			"Gateway class of originator %pM changed from %i to %i\n",
+			"Gateway class of originator %pM changed from "
+			"%i to %i\n",
 			orig_node->orig, gw_node->orig_node->gw_flags,
 			new_gwflags);
 
@@ -349,7 +355,8 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
+				       "BATMAN mesh %s disabled - please "
+				       "specify interfaces to enable it\n",
 				       net_dev->name);
 
 		return 0;
@@ -360,14 +367,15 @@ int gw_client_fill_buffer_text(struct net_device *net_dev, char *buff,
 
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - primary interface not active\n",
+				       "BATMAN mesh %s disabled - "
+				       "primary interface not active\n",
 				       net_dev->name);
 
 		return 0;
 	}
 
-	hdr_len = sprintf(buff,
-			  "      %-12s (%s/%i) %17s [%10s]: gw_class ... [B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
+	hdr_len = sprintf(buff, "      %-12s (%s/%i) %17s [%10s]: gw_class ... "
+			  "[B.A.T.M.A.N. adv %s%s, MainIF/MAC: %s/%s (%s)]\n",
 			  "Gateway", "#", TQ_MAX_VALUE, "Nexthop",
 			  "outgoingIF", SOURCE_VERSION, REVISION_VERSION_STR,
 			  bat_priv->primary_if->dev,
batman-adv-kernelland/gateway_common.c +28 -17

94 lines not on this page · raw message

batman-adv-kernelland/hard-interface.c +14 -6
index 64307fc..5123176 100644
@@ -150,9 +150,12 @@ static void check_known_mac_addr(uint8_t *addr)
 		if (!compare_orig(batman_if->net_dev->dev_addr, addr))
 			continue;
 
-		printk(KERN_WARNING "batman-adv:The newly added mac address (%pM) already exists on: %s\n",
-		       addr, batman_if->dev);
-		printk(KERN_WARNING "batman-adv:It is strongly recommended to keep mac addresses unique to avoid problems!\n");
+		printk(KERN_WARNING "batman-adv:"
+		    "The newly added mac address (%pM) already exists on: %s\n",
+		    addr, batman_if->dev);
+		printk(KERN_WARNING "batman-adv:"
+		    "It is strongly recommended to keep mac addresses unique"
+		    "to avoid problems!\n");
 	}
 	rcu_read_unlock();
 }
@@ -243,7 +246,8 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	batman_if->packet_buff = kmalloc(batman_if->packet_len, GFP_ATOMIC);
 
 	if (!batman_if->packet_buff) {
-		printk(KERN_ERR "batman-adv:Can't add interface packet (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface packet (%s): out of memory\n",
 		       batman_if->dev);
 		goto err;
 	}
@@ -267,7 +271,10 @@ int hardif_enable_interface(struct batman_if *batman_if)
 	if (hardif_is_iface_up(batman_if))
 		hardif_activate_interface(bat_priv, batman_if);
 	else
-		printk(KERN_ERR "batman-adv:Not using interface %s (retrying later): interface not active\n", batman_if->dev);
+		printk(KERN_ERR "batman-adv:"
+		       "Not using interface %s "
+		       "(retrying later): interface not active\n",
+		       batman_if->dev);
 
 	/* begin scheduling originator messages on that interface */
 	schedule_own_packet(batman_if);
@@ -317,7 +324,8 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
 
 	batman_if = kmalloc(sizeof(struct batman_if), GFP_ATOMIC);
 	if (!batman_if) {
-		printk(KERN_ERR "batman-adv:Can't add interface (%s): out of memory\n",
+		printk(KERN_ERR "batman-adv:"
+		       "Can't add interface (%s): out of memory\n",
 		       net_dev->name);
 		goto out;
 	}
batman-adv-kernelland/main.c +11 -6
index 1203d3f..d03a7fa 100644
@@ -92,14 +92,16 @@ int init_module(void)
 				   interface_setup);
 
 	if (!soft_device) {
-		printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n");
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to allocate the batman interface\n");
 		goto end;
 	}
 
 	retval = register_netdev(soft_device);
 
 	if (retval < 0) {
-		printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval);
+		printk(KERN_ERR "batman-adv:"
+		       "Unable to register the batman interface: %i\n", retval);
 		goto free_soft_device;
 	}
 
@@ -111,8 +113,9 @@ int init_module(void)
 	register_netdevice_notifier(&hard_if_notifier);
 	dev_add_pack(&batman_adv_packet_type);
 
-	printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
-		  SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
+	printk(KERN_INFO "batman-adv:"
+	       "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n",
+	       SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION);
 
 	return 0;
 
@@ -169,7 +172,9 @@ void activate_module(void)
 	goto end;
 
 err:
-	printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n");
+	printk(KERN_ERR "batman-adv:"
+	       "Unable to allocate memory for mesh information structures: "
+	       "out of mem ?\n");
 	deactivate_module();
 end:
 	return;
@@ -212,7 +217,7 @@ void dec_module_count(void)
 
 int addr_to_string(char *buff, uint8_t *addr)
 {
-	return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x",
+	return sprintf(buff, MAC_FMT,
 		       addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
 }
 
batman-adv-kernelland/main.h +2 -1
index 2b47259..730343e 100644
@@ -22,7 +22,8 @@
 /* Kernel Programming */
 #define LINUX
 
-#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, Simon Wunderlich <[email protected]>"
+#define DRIVER_AUTHOR "Marek Lindner <[email protected]>, " \
+		      "Simon Wunderlich <[email protected]>"
 #define DRIVER_DESC   "B.A.T.M.A.N. advanced"
 #define DRIVER_DEVICE "batman-adv"
 
batman-adv-kernelland/originator.c +29 -18

100 lines not on this page · raw message

batman-adv-kernelland/routing.c +43 -15

137 lines not on this page · raw message

batman-adv-kernelland/send.c +13 -6
index 7667d1f..bed6cea 100644
@@ -68,7 +68,8 @@ int send_skb_packet(struct sk_buff *skb,
 
 	if (!(batman_if->net_dev->flags & IFF_UP)) {
 		printk(KERN_WARNING
-		       "batman-adv:Interface %s is not up - can't send packet via that interface!\n",
+		       "batman-adv:Interface %s "
+		       "is not up - can't send packet via that interface!\n",
 		       batman_if->dev);
 		goto send_skb_err;
 	}
@@ -150,7 +151,9 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 							    "Sending own" :
 							    "Forwarding"));
 		bat_dbg(DBG_BATMAN,
-			"%s %spacket (originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) on interface %s [%s]\n",
+			"%s %spacket "
+			"(originator %pM, seqno %d, TQ %d, TTL %d, IDF %s) "
+			"on interface %s [%s]\n",
 			fwd_str,
 			(packet_num > 0 ? "aggregated " : ""),
 			batman_packet->orig, ntohl(batman_packet->seqno),
@@ -180,7 +183,8 @@ static void send_packet(struct forw_packet *forw_packet)
 	unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
 
 	if (!forw_packet->if_incoming) {
-		printk(KERN_ERR "batman-adv: Error - can't forward packet: incoming iface not specified\n");
+		printk(KERN_ERR "batman-adv: Error - can't forward packet: "
+		       "incoming iface not specified\n");
 		return;
 	}
 
@@ -194,7 +198,8 @@ static void send_packet(struct forw_packet *forw_packet)
 
 		/* FIXME: what about aggregated packets ? */
 		bat_dbg(DBG_BATMAN,
-			"%s packet (originator %pM, seqno %d, TTL %d) on interface %s [%s]\n",
+			"%s packet (originator %pM, seqno %d, TTL %d) "
+			"on interface %s [%s]\n",
 			(forw_packet->own ? "Sending own" : "Forwarding"),
 			batman_packet->orig, ntohl(batman_packet->seqno),
 			batman_packet->ttl, forw_packet->if_incoming->dev,
@@ -330,7 +335,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 			batman_packet->tq = orig_node->router->tq_avg;
 
 			if (orig_node->router->last_ttl)
-				batman_packet->ttl = orig_node->router->last_ttl - 1;
+				batman_packet->ttl = orig_node->router->last_ttl
+							- 1;
 		}
 
 		tq_avg = orig_node->router->tq_avg;
@@ -339,7 +345,8 @@ void schedule_forward_packet(struct orig_node *orig_node,
 	/* apply hop penalty */
 	batman_packet->tq = hop_penalty(batman_packet->tq);
 
-	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
+	bat_dbg(DBG_BATMAN, "Forwarding packet: tq_orig: %i, tq_avg: %i, "
+		"tq_forw: %i, ttl_orig: %i, ttl_forw: %i\n",
 		in_tq, tq_avg, batman_packet->tq, in_ttl - 1,
 		batman_packet->ttl);
 
batman-adv-kernelland/translation-table.c +22 -12
index 3ce39a6..a60bc7e 100644
@@ -78,7 +78,10 @@ void hna_local_add(uint8_t *addr)
 	   MAC-flooding. */
 	if ((num_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) / ETH_ALEN) ||
 	    (num_hna + 1 > 255)) {
-		bat_dbg(DBG_ROUTES, "Can't add new local hna entry (%pM): number of local hna entries exceeds packet size\n", addr);
+		bat_dbg(DBG_ROUTES,
+			"Can't add new local hna entry (%pM): "
+			"number of local hna entries exceeds packet size\n",
+			addr);
 		return;
 	}
 
@@ -109,7 +112,8 @@ void hna_local_add(uint8_t *addr)
 				       hna_local_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize local hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize local hna hash table\n");
 		else
 			hna_local_hash = swaphash;
 	}
@@ -170,14 +174,16 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Locally retrieved addresses (from %s) announced via HNA:\n",
+			  "Locally retrieved addresses (from %s) "
+			  "announced via HNA:\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -197,7 +203,7 @@ int hna_local_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_local_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 22,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT "\n",
 					  hna_local_entry->addr[0],
 					  hna_local_entry->addr[1],
 					  hna_local_entry->addr[2],
@@ -318,7 +324,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 			memcpy(hna_global_entry->addr, hna_ptr, ETH_ALEN);
 
 			bat_dbg(DBG_ROUTES,
-				"Creating new global hna entry: %pM (via %pM)\n",
+				"Creating new global hna entry: "
+				"%pM (via %pM)\n",
 				hna_global_entry->addr, orig_node->orig);
 
 			spin_lock_irqsave(&hna_global_hash_lock, flags);
@@ -363,7 +370,8 @@ void hna_global_add_orig(struct orig_node *orig_node,
 				       hna_global_hash->size * 2);
 
 		if (swaphash == NULL)
-			printk(KERN_ERR "batman-adv:Couldn't resize global hna hash table\n");
+			printk(KERN_ERR "batman-adv:"
+			       "Couldn't resize global hna hash table\n");
 		else
 			hna_global_hash = swaphash;
 	}
@@ -384,14 +392,16 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 	if (!bat_priv->primary_if) {
 		if (off == 0)
 			return sprintf(buff,
-				       "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
-				       net_dev->name);
+				     "BATMAN mesh %s disabled - "
+				     "please specify interfaces to enable it\n",
+				     net_dev->name);
 
 		return 0;
 	}
 
 	hdr_len = sprintf(buff,
-			  "Globally announced HNAs received via the mesh %s (translation table):\n",
+			  "Globally announced HNAs received via the mesh %s "
+			  "(translation table):\n",
 			  net_dev->name);
 
 	if (off < hdr_len)
@@ -411,7 +421,7 @@ int hna_global_fill_buffer_text(struct net_device *net_dev, char *buff,
 		hna_global_entry = hashit.bucket->data;
 
 		bytes_written += snprintf(buff + bytes_written, 44,
-					  " * %02x:%02x:%02x:%02x:%02x:%02x via %02x:%02x:%02x:%02x:%02x:%02x\n",
+					  " * " MAC_FMT " via " MAC_FMT "\n",
 					  hna_global_entry->addr[0],
 					  hna_global_entry->addr[1],
 					  hna_global_entry->addr[2],
batman-adv-kernelland/types.h +41 -17

99 lines not on this page · raw message

Signature · 1 line
1.7.1