Re: [patch] repost of netfilter/NIPQUAD patches

From: Olaf Titz (olaf@bigred.inka.de)
Date: Fri Apr 14 2000 - 16:05:33 EST


> What's the advantage of using %s + inet_ntoa() when compared to using
> the very straightforward %u.%u.%u.%u + NIP_QUAD()? There is none.

The quadrupled %u is ugly, conceptually unlogical[1], harder to write,
more prone to errors in how many arguments the printk actually has
(even if the compiler catches those), and most important, it is common
code repeating over and over again. Library functions are there
exactly to ease this.
Why have strchr() when we can always write
  while (*p && *p!='x') p++;

My quick hack is ugly in one place - its definition - but it removes
ugliness in many other places - where it is used. The real solution
would be another format qualifier, getting actually _all_ of the code
required to print an IP address in _one_ place - but I can hear you
scream "unnecessary special casing" on that.

Olaf

[1] an IP address is _one_ thing to print, not four.

PS. I hope this atrocity (net/ipv6/icmp.c)

                        printk(KERN_DEBUG "ICMPv6 checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
                                ntohs(saddr->in6_u.u6_addr16[0]),
                                ntohs(saddr->in6_u.u6_addr16[1]),
                                ntohs(saddr->in6_u.u6_addr16[2]),
                                ntohs(saddr->in6_u.u6_addr16[3]),
                                ntohs(saddr->in6_u.u6_addr16[4]),
                                ntohs(saddr->in6_u.u6_addr16[5]),
                                ntohs(saddr->in6_u.u6_addr16[6]),
                                ntohs(saddr->in6_u.u6_addr16[7]),
                                ntohs(daddr->in6_u.u6_addr16[0]),
                                ntohs(daddr->in6_u.u6_addr16[1]),
                                ntohs(daddr->in6_u.u6_addr16[2]),
                                ntohs(daddr->in6_u.u6_addr16[3]),
                                ntohs(daddr->in6_u.u6_addr16[4]),
                                ntohs(daddr->in6_u.u6_addr16[5]),
                                ntohs(daddr->in6_u.u6_addr16[6]),
                                ntohs(daddr->in6_u.u6_addr16[7]));

remains an isolated incident.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Apr 15 2000 - 21:00:25 EST