提交 cf377eb4 编写于 作者: P Patrick McHardy

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: NPatrick McHardy <kaber@trash.net>
上级 d70a011d
...@@ -411,12 +411,12 @@ ipt_log_packet(u_int8_t pf, ...@@ -411,12 +411,12 @@ ipt_log_packet(u_int8_t pf,
skb->mac_header != skb->network_header) { skb->mac_header != skb->network_header) {
int i; int i;
const unsigned char *p = skb_mac_header(skb); const unsigned char *p = skb_mac_header(skb);
for (i = 0; i < skb->dev->hard_header_len; i++,p++)
printk("%02x%c", *p, printk("%02x", *p++);
i==skb->dev->hard_header_len - 1 for (i = 1; i < skb->dev->hard_header_len; i++, p++)
? ' ':':'); printk(":%02x", *p);
} else }
printk(" "); printk(" ");
} }
dump_packet(loginfo, skb, 0); dump_packet(loginfo, skb, 0);
......
...@@ -414,9 +414,9 @@ ip6t_log_packet(u_int8_t pf, ...@@ -414,9 +414,9 @@ ip6t_log_packet(u_int8_t pf,
p = NULL; p = NULL;
if (p != NULL) { if (p != NULL) {
for (i = 0; i < len; i++) printk("%02x", *p++);
printk("%02x%s", p[i], for (i = 1; i < len; i++)
i == len - 1 ? "" : ":"); printk(":%02x", p[i]);
} }
printk(" "); printk(" ");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册