Alexander Hall wrote:
> Alexandr Shadchin wrote:
>> Hi!
>>
>> Small code cleaning :)
>>
>> inetname() is called with nflag = 0
>> In inetname() is checking nflag != 0, why?
> 
> Seems reasonable to me, but also change the comment above the function.
> 
> /Alexander
> 
> .
> 

Yes, forgot about the comment (

inetname() is called only in print()
inetname () is called only when nflag = 0
Why have something that is not used?

void
print(u_char *buf, int cc, struct sockaddr_in *from)
{
        struct ip *ip;
        int hlen;

        ip = (struct ip *) buf;
        hlen = ip->ip_hl << 2;
        cc -= hlen;

        if (nflag)                                           <----------
                printf(" %s", inet_ntoa(from->sin_addr));    <----------
        else                                                 <----------
                printf(" %s (%s)", inetname(from->sin_addr), <----------
                    inet_ntoa(from->sin_addr));              <----------

        if (verbose)
                printf(" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
}
Index: traceroute.c
===================================================================
RCS file: /cvs/src/usr.sbin/traceroute/traceroute.c,v
retrieving revision 1.66
diff -u -r1.66 traceroute.c
--- traceroute.c        4 Oct 2008 02:21:49 -0000       1.66
+++ traceroute.c        11 Apr 2009 02:17:42 -0000
@@ -1002,8 +1002,6 @@
 
 /*
  * Construct an Internet address representation.
- * If the nflag has been supplied, give
- * numeric value, otherwise try for symbolic name.
  */
 char *
 inetname(struct in_addr in)
@@ -1013,14 +1011,14 @@
        struct hostent *hp;
        char *cp;
 
-       if (first && !nflag) {
+       if (first) {
                first = 0;
                if (gethostname(domain, sizeof domain) == 0 &&
                    (cp = strchr(domain, '.')) != NULL) {
                        strlcpy(domain, cp + 1, sizeof(domain));
                }
        }
-       if (!nflag && in.s_addr != INADDR_ANY) {
+       if (in.s_addr != INADDR_ANY) {
                hp = gethostbyaddr((char *)&in, sizeof(in), AF_INET);
                if (hp != NULL) {
                        if ((cp = strchr(hp->h_name, '.')) != NULL &&

Reply via email to