[haiku-commits] haiku: hrev49467 - src/kits/network/libnetapi

  • From: waddlesplash@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 27 Jul 2015 23:28:32 +0200 (CEST)

hrev49467 adds 1 changeset to branch 'master'
old head: 5934b30b95a239eee4a088a9b9cb425eef13f22d
new head: 71b756a0546837050d004088c19fcb9a70a5558b
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=71b756a05468+%5E5934b30b95a2

----------------------------------------------------------------------------

71b756a05468: BNetworkAddress: Fix setting fStatus all over the place.

Relevant quote from IRC:
<pdziepak> i would expect all overloads of SetTo to return status_t
<pdziepak> actually, i don't think what i would expect from class with such
interface
<pdziepak> bugs probably

[ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision: hrev49467
Commit: 71b756a0546837050d004088c19fcb9a70a5558b
URL: http://cgit.haiku-os.org/haiku/commit/?id=71b756a05468
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jul 27 20:17:51 2015 UTC

----------------------------------------------------------------------------

1 file changed, 39 insertions(+), 15 deletions(-)
src/kits/network/libnetapi/NetworkAddress.cpp | 54 ++++++++++++++++-------

----------------------------------------------------------------------------

diff --git a/src/kits/network/libnetapi/NetworkAddress.cpp
b/src/kits/network/libnetapi/NetworkAddress.cpp
index 307e173..82737de 100644
--- a/src/kits/network/libnetapi/NetworkAddress.cpp
+++ b/src/kits/network/libnetapi/NetworkAddress.cpp
@@ -59,28 +59,28 @@ BNetworkAddress::BNetworkAddress()

BNetworkAddress::BNetworkAddress(const char* host, uint16 port, uint32 flags)
{
- SetTo(host, port, flags);
+ fStatus = SetTo(host, port, flags);
}


BNetworkAddress::BNetworkAddress(const char* host, const char* service,
uint32 flags)
{
- SetTo(host, service, flags);
+ fStatus = SetTo(host, service, flags);
}


BNetworkAddress::BNetworkAddress(int family, const char* host, uint16 port,
uint32 flags)
{
- SetTo(family, host, port, flags);
+ fStatus = SetTo(family, host, port, flags);
}


BNetworkAddress::BNetworkAddress(int family, const char* host,
const char* service, uint32 flags)
{
- SetTo(family, host, service, flags);
+ fStatus = SetTo(family, host, service, flags);
}


@@ -170,11 +170,16 @@ BNetworkAddress::SetTo(const char* host, uint16 port,
uint32 flags)

uint32 cookie = 0;
status = resolver->GetNextAddress(AF_INET6, &cookie, *this);
- if (status == B_OK)
+ if (status == B_OK) {
+ fStatus = B_OK;
return B_OK;
+ }

cookie = 0;
- return resolver->GetNextAddress(&cookie, *this);
+ status = resolver->GetNextAddress(&cookie, *this);
+ if (status == B_OK)
+ fStatus = B_OK;
+ return status;
}


@@ -193,11 +198,16 @@ BNetworkAddress::SetTo(const char* host, const char*
service, uint32 flags)

uint32 cookie = 0;
status = resolver->GetNextAddress(AF_INET6, &cookie, *this);
- if (status == B_OK)
+ if (status == B_OK) {
+ fStatus = B_OK;
return B_OK;
+ }

cookie = 0;
- return resolver->GetNextAddress(&cookie, *this);
+ status = resolver->GetNextAddress(&cookie, *this);
+ if (status == B_OK)
+ fStatus = B_OK;
+ return status;
}


@@ -208,6 +218,7 @@ BNetworkAddress::SetTo(int family, const char* host, uint16
port, uint32 flags)
if (port != 0)
return B_BAD_VALUE;
return _ParseLinkAddress(host);
+ // SetToLinkAddress takes care of setting fStatus
}

BReference<const BNetworkAddressResolver> resolver
@@ -219,7 +230,10 @@ BNetworkAddress::SetTo(int family, const char* host,
uint16 port, uint32 flags)
return status;

uint32 cookie = 0;
- return resolver->GetNextAddress(&cookie, *this);
+ status = resolver->GetNextAddress(&cookie, *this);
+ if (status == B_OK)
+ fStatus = B_OK;
+ return status;
}


@@ -231,6 +245,7 @@ BNetworkAddress::SetTo(int family, const char* host, const
char* service,
if (service != NULL)
return B_BAD_VALUE;
return _ParseLinkAddress(host);
+ // SetToLinkAddress takes care of setting fStatus
}

BReference<const BNetworkAddressResolver> resolver
@@ -242,7 +257,10 @@ BNetworkAddress::SetTo(int family, const char* host, const
char* service,
return status;

uint32 cookie = 0;
- return resolver->GetNextAddress(&cookie, *this);
+ status = resolver->GetNextAddress(&cookie, *this);
+ if (status == B_OK)
+ fStatus = B_OK;
+ return status;
}


@@ -360,7 +378,7 @@ BNetworkAddress::SetToBroadcast(int family, uint16 port)
return fStatus = B_NOT_SUPPORTED;

SetTo(INADDR_BROADCAST, port);
- return B_OK;
+ return fStatus;
}


@@ -390,7 +408,7 @@ BNetworkAddress::SetToLoopback(int family, uint16 port)
return fStatus = B_NOT_SUPPORTED;
}

- return B_OK;
+ return fStatus;
}


@@ -439,7 +457,7 @@ BNetworkAddress::SetToMask(int family, uint32 prefixLength)
}

default:
- return fStatus = B_NOT_SUPPORTED;
+ return B_NOT_SUPPORTED;
}

return fStatus = B_OK;
@@ -459,10 +477,10 @@ BNetworkAddress::SetToWildcard(int family, uint16 port)
break;

default:
- return fStatus = B_NOT_SUPPORTED;
+ return B_NOT_SUPPORTED;
}

- return B_OK;
+ return fStatus;
}


@@ -522,6 +540,8 @@ BNetworkAddress::SetToLinkLevel(uint8* address, size_t
length)
link.sdl_len = sizeof(sockaddr_dl);
if (length > sizeof(link.sdl_data))
link.sdl_len += length - sizeof(link.sdl_data);
+
+ fStatus = B_OK;
}


@@ -543,6 +563,8 @@ BNetworkAddress::SetToLinkLevel(const char* name)
link.sdl_len = sizeof(sockaddr_dl);
if (link.sdl_nlen > sizeof(link.sdl_data))
link.sdl_len += link.sdl_nlen - sizeof(link.sdl_data);
+
+ fStatus = B_OK;
}


@@ -555,6 +577,8 @@ BNetworkAddress::SetToLinkLevel(uint32 index)
link.sdl_family = AF_LINK;
link.sdl_len = sizeof(sockaddr_dl);
link.sdl_index = index;
+
+ fStatus = B_OK;
}




Other related posts: