From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199606031607.JAA10807@koala.azstarnet.com> Date: Mon, 3 Jun 1996 09:07:08 -0700 From: David Mosberger-Tang Subject: Re: Minor problem with RHCL/AXP 2.1 >>>>> On Mon, 03 Jun 1996 16:50:36 +0100, Nigel Metheringham said: Nigel> I have been running a SQUID cache on our alpha box running Nigel> RHCL/AXP 2.1. Nigel> The new version broke, badly! Nigel> This was due to a line like this:- Nigel> if (inet_addr(ip) != -1) { Nigel> which never failed (ie never returned -1). This is becuase Nigel> in /usr/include/arpa/inet.h there was a definition like Nigel> this... unsigned long inet_addr __P((const char *)); inet_addr() returns INADDR_NONE in case of failure. It is wrong to test for -1 (the Linux man-page is incorrect in this respect). OSF/1 declare inet_addr() to return an "unsigned int" which works around the problem, but it is apparently inconsistent with one of the POSIX standards. The correct way to test the return value of inet_addr is: if (inet_addr(ip) == INADDR_NONE) or, if you insist on using -1 instead of INADDR_NONE: if ((int32_t) inet_addr(ip) == -1) An even better solution is to use inet_aton(): if (!inet_aton (ip, NULL)) because this will work even in the case "ip" specifies a local broadcast address. --david