Commit ec0be3ef authored by valenting's avatar valenting
Browse files

Bug 1659132 - Make AddrInfo immutable r=dragana,necko-reviewers

Also adds constructors for NetAddr to avoid it being uninitialized.

Differential Revision: https://phabricator.services.mozilla.com/D87091
parent 125efe18
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -406,8 +406,7 @@ nsresult UDPSocket::InitLocal(const nsAString& aLocalAddress,
    UDPSOCKET_LOG(("%s: %s:%u", __FUNCTION__,
                   NS_ConvertUTF16toUTF8(aLocalAddress).get(), aLocalPort));

    mozilla::net::NetAddr addr;
    PRNetAddrToNetAddr(&prAddr, &addr);
    mozilla::net::NetAddr addr(&prAddr);
    rv = sock->InitWithAddress(&addr, principal, mAddressReuse,
                               /* optionalArgc = */ 1);
  }
+2 −5
Original line number Diff line number Diff line
@@ -139,8 +139,7 @@ nsresult UDPSocketParent::BindInternal(const nsCString& aHost,
      return NS_ERROR_FAILURE;
    }

    mozilla::net::NetAddr addr;
    PRNetAddrToNetAddr(&prAddr, &addr);
    mozilla::net::NetAddr addr(&prAddr);
    rv = sock->InitWithAddress(&addr, mPrincipal, aAddressReuse,
                               /* optional_argc = */ 1);
  }
@@ -288,9 +287,7 @@ nsresult UDPSocketParent::ConnectInternal(const nsCString& aHost,
    return NS_ERROR_FAILURE;
  }

  mozilla::net::NetAddr addr;
  PRNetAddrToNetAddr(&prAddr, &addr);

  mozilla::net::NetAddr addr(&prAddr);
  rv = mSocket->Connect(&addr);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
+1 −5
Original line number Diff line number Diff line
@@ -361,11 +361,7 @@ bool nsHTTPSOnlyUtils::LoopbackOrLocalException(nsIURI* aURI) {
    return false;
  }

  // The linter wants this struct to get initialized,
  // but PRNetAddrToNetAddr will do that.
  mozilla::net::NetAddr addr;  // NOLINT(cppcoreguidelines-pro-type-member-init)
  PRNetAddrToNetAddr(&tempAddr, &addr);

  mozilla::net::NetAddr addr(&tempAddr);
  // Loopback IPs are always exempt
  if (IsLoopBackAddress(&addr)) {
    return true;
+1 −2
Original line number Diff line number Diff line
@@ -241,8 +241,7 @@ bool nsMixedContentBlocker::IsPotentiallyTrustworthyLoopbackHost(
  }

  using namespace mozilla::net;
  NetAddr addr;
  PRNetAddrToNetAddr(&tempAddr, &addr);
  NetAddr addr(&tempAddr);

  // Step 4 of
  // https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy says
+1 −2
Original line number Diff line number Diff line
@@ -322,8 +322,7 @@ void WebrtcTCPSocket::OpenWithoutHttpProxy(nsIProxyInfo* aSocksProxyInfo) {
    return;
  }

  mozilla::net::NetAddr addr;
  PRNetAddrToNetAddr(&prAddr, &addr);
  mozilla::net::NetAddr addr(&prAddr);
  rv = mTransport->Bind(&addr);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    CloseWithReason(rv);
Loading