[haiku-commits] Re: r40411 - haiku/trunk/src/tests/kits/net/preflet/InterfacesAddOn

  • From: Alexander von Gluck <kallisti5@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 10 Feb 2011 07:07:16 -0600

On Thu, 2011-02-10 at 09:43 +0100, Axel Dörfler wrote:
> kallisti5@xxxxxxxxxxx wrote:
> > Log:
> > FindFirstAddress returns errno when there is no address matching your
> > search
> 
> Which it actually shouldn't do.
> Since it returns an int32, it should only be the index, or -1 if it couldn't 
> be found - same for FindAddress() - I can take care of that this evening.
> 
> > -   if (fNetworkInterface.GetAddressAt(zeroAddrV4, netIntAddr4) == B_OK) {
> > +   if (zeroAddrV4 != errno) {
> > +           fNetworkInterface.GetAddressAt(zeroAddrV4, netIntAddr4);
> 
> However, this doesn't make any sense at all!
> You do not use errno like this, it's not a constant, it's a variable (or 
> macro) that contains the last POSIX error. If no error happened, it would 
> just be 0 which could also point to the first interface.
> You only check if errno is a certain error, you cannot even check it against 
> 0, as functions usually aren't allowed to set it unless something failed; you 
> would need to test if a function fails that sets errno, and only then 
> evaluate it.

I know. This is the only way could figure out to get it to work.  errno
== the last error... as the last error was the FindFirstAddress call
failing.. it seemed to work. (although open to lots of problems)

As soon as FindFirstAddress and FindAddress returns something we can
check for an error... I'll fix it via zeroAddrVn >= B_OK

 -- Alex


Other related posts: