[haiku-commits] Re: BRANCH waddlesplash-github.fixes_dhcp [f783ed2cfd46] src/kits/network/libnetapi

  • From: Paweł Dziepak <pdziepak@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 27 Jul 2015 23:09:40 +0200

On 27 July 2015 at 23:01, waddlesplash-github.fixes_dhcp <
community@xxxxxxxxxxxx> wrote:

added 1 changeset to branch 'refs/remotes/waddlesplash-github/fixes_dhcp'
old head: 0000000000000000000000000000000000000000
new head: f783ed2cfd465693cb56f4c5ad1575c08f17b6b7
overview: https://github.com/waddlesplash/haiku/compare/f783ed2cfd46


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

f783ed2cfd46: 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

Probably fixes #12208, but I don't have hardware that wasn't working
so I can't test.


Oh, it won't fix #12208. The issue from that ticket is that construction of
BNetworkAddress fails if the host is nullptr.



[ Augustin Cavalier <waddlesplash@xxxxxxxxx>
]


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

Commit: f783ed2cfd465693cb56f4c5ad1575c08f17b6b7
Author: Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date: Mon Jul 27 19:56:32 2015 UTC

Ticket: https://dev.haiku-os.org/ticket/12208


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

1 file changed, 25 insertions(+), 11 deletions(-)
src/kits/network/libnetapi/NetworkAddress.cpp | 36 ++++++++++++++++-------


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

diff --git a/src/kits/network/libnetapi/NetworkAddress.cpp
b/src/kits/network/libnetapi/NetworkAddress.cpp
index 307e173..4a50dcd 100644
--- a/src/kits/network/libnetapi/NetworkAddress.cpp
+++ b/src/kits/network/libnetapi/NetworkAddress.cpp
@@ -170,11 +170,14 @@ 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);
+ fStatus = resolver->GetNextAddress(&cookie, *this);
+ return fStatus;
}


@@ -193,11 +196,14 @@ 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);
+ fStatus = resolver->GetNextAddress(&cookie, *this);
+ return fStatus;
}


@@ -208,6 +214,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 +226,8 @@ BNetworkAddress::SetTo(int family, const char* host,
uint16 port, uint32 flags)
return status;

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


@@ -231,6 +239,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 +251,8 @@ BNetworkAddress::SetTo(int family, const char* host,
const char* service,
return status;

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


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

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


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

- return B_OK;
+ return fStatus;
}


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

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

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

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

- return B_OK;
+ return fStatus;
}


@@ -543,6 +553,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 +567,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: