Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: David Mosberger-Tang <davidm@AZStarNet.com>
Subject: Re: Minor problem with RHCL/AXP 2.1
Date: Mon, 3 Jun 1996 09:07:08 -0700	[thread overview]
Message-ID: <199606031607.JAA10807@koala.azstarnet.com> (raw)

>>>>> On Mon, 03 Jun 1996 16:50:36 +0100, Nigel Metheringham <Nigel.Metheringham@theplanet.net> 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

             reply	other threads:[~1996-06-03 16:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-03 16:07 David Mosberger-Tang [this message]
  -- strict thread matches above, loose matches on Subject: below --
1996-06-03 15:50 Minor problem with RHCL/AXP 2.1 Nigel Metheringham
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox