netfilter: ipt_LOG/ip6t_LOG: remove comparison within loop
authorPatrick McHardy <kaber@trash.net>
Mon, 28 Jun 2010 12:12:41 +0000 (14:12 +0200)
committerPatrick McHardy <kaber@trash.net>
Mon, 28 Jun 2010 12:12:41 +0000 (14:12 +0200)
Remove the comparison within the loop to print the macheader by prepending
the colon to all but the first printk.

Based on suggestion by Jan Engelhardt <jengelh@medozas.de>.

Signed-off-by: Patrick McHardy <kaber@trash.net>
net/ipv4/netfilter/ipt_LOG.c
net/ipv6/netfilter/ip6t_LOG.c

index 5234f4f3499ad87e06c9d1bfab14e27d35b77fe6..0a452a54adbea1930058b27532052452d0185ab4 100644 (file)
@@ -411,12 +411,12 @@ ipt_log_packet(u_int8_t pf,
                    skb->mac_header != skb->network_header) {
                        int i;
                        const unsigned char *p = skb_mac_header(skb);
-                       for (i = 0; i < skb->dev->hard_header_len; i++,p++)
-                               printk("%02x%c", *p,
-                                      i==skb->dev->hard_header_len - 1
-                                      ? ' ':':');
-               } else
-                       printk(" ");
+
+                       printk("%02x", *p++);
+                       for (i = 1; i < skb->dev->hard_header_len; i++, p++)
+                               printk(":%02x", *p);
+               }
+               printk(" ");
        }
 
        dump_packet(loginfo, skb, 0);
index af4ee11f206609861708443150ae20abbc8e64b6..4c7ddac7c62bdd2bbcd11b43cf723c320e7a07d0 100644 (file)
@@ -414,9 +414,9 @@ ip6t_log_packet(u_int8_t pf,
                                p = NULL;
 
                        if (p != NULL) {
-                               for (i = 0; i < len; i++)
-                                       printk("%02x%s", p[i],
-                                              i == len - 1 ? "" : ":");
+                               printk("%02x", *p++);
+                               for (i = 1; i < len; i++)
+                                       printk(":%02x", p[i]);
                        }
                        printk(" ");