Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

netfilter: ipt_LOG/ip6t_LOG: remove comparison within loop

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>

+9 -9
+6 -6
net/ipv4/netfilter/ipt_LOG.c
··· 411 411 skb->mac_header != skb->network_header) { 412 412 int i; 413 413 const unsigned char *p = skb_mac_header(skb); 414 - for (i = 0; i < skb->dev->hard_header_len; i++,p++) 415 - printk("%02x%c", *p, 416 - i==skb->dev->hard_header_len - 1 417 - ? ' ':':'); 418 - } else 419 - printk(" "); 414 + 415 + printk("%02x", *p++); 416 + for (i = 1; i < skb->dev->hard_header_len; i++, p++) 417 + printk(":%02x", *p); 418 + } 419 + printk(" "); 420 420 } 421 421 422 422 dump_packet(loginfo, skb, 0);
+3 -3
net/ipv6/netfilter/ip6t_LOG.c
··· 414 414 p = NULL; 415 415 416 416 if (p != NULL) { 417 - for (i = 0; i < len; i++) 418 - printk("%02x%s", p[i], 419 - i == len - 1 ? "" : ":"); 417 + printk("%02x", *p++); 418 + for (i = 1; i < len; i++) 419 + printk(":%02x", p[i]); 420 420 } 421 421 printk(" "); 422 422