Bug 945533 - Convert various server sockets to mozilla/Endian.h. r=sworkman
authorJeff Walden <jwalden@mit.edu>
Sat, 04 May 2013 22:22:55 -0700
changeset 159615 c982e84c0a00a438ae75574869f06b5843329479
parent 159614 9fd377ba90f5aa91e56ea2b29c860da037a2e1a3
child 159616 3d9a20acba5d6665a62a83eeb3cc108163782436
push id25808
push usercbook@mozilla.com
push dateTue, 10 Dec 2013 12:03:31 +0000
treeherdermozilla-central@7fb91a422c5e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssworkman
bugs945533
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 945533 - Convert various server sockets to mozilla/Endian.h. r=sworkman
netwerk/base/src/nsServerSocket.cpp
netwerk/base/src/nsUDPSocket.cpp
--- a/netwerk/base/src/nsServerSocket.cpp
+++ b/netwerk/base/src/nsServerSocket.cpp
@@ -8,16 +8,17 @@
 #include "nsProxyRelease.h"
 #include "nsAutoPtr.h"
 #include "nsError.h"
 #include "nsNetCID.h"
 #include "prnetdb.h"
 #include "prio.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Attributes.h"
+#include "mozilla/Endian.h"
 #include "mozilla/net/DNS.h"
 #include "nsServiceManagerUtils.h"
 #include "nsIFile.h"
 
 using namespace mozilla;
 using namespace mozilla::net;
 
 static NS_DEFINE_CID(kSocketTransportServiceCID, NS_SOCKETTRANSPORTSERVICE_CID);
@@ -516,17 +517,17 @@ nsServerSocket::GetPort(int32_t *aResult
   uint16_t port;
   if (mAddr.raw.family == PR_AF_INET)
     port = mAddr.inet.port;
   else if (mAddr.raw.family == PR_AF_INET6)
     port = mAddr.ipv6.port;
   else
     return NS_ERROR_FAILURE;
 
-  *aResult = (int32_t) PR_ntohs(port);
+  *aResult = static_cast<int32_t>(NetworkEndian::readUint16(&port));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsServerSocket::GetAddress(PRNetAddr *aResult)
 {
   // no need to enter the lock here
   memcpy(aResult, &mAddr, sizeof(mAddr));
--- a/netwerk/base/src/nsUDPSocket.cpp
+++ b/netwerk/base/src/nsUDPSocket.cpp
@@ -1,22 +1,24 @@
 /* vim:set ts=2 sw=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/Attributes.h"
+#include "mozilla/Endian.h"
+
 #include "nsSocketTransport2.h"
 #include "nsUDPSocket.h"
 #include "nsProxyRelease.h"
 #include "nsAutoPtr.h"
 #include "nsError.h"
 #include "nsNetCID.h"
 #include "prnetdb.h"
 #include "prio.h"
-#include "mozilla/Attributes.h"
 #include "nsNetAddr.h"
 #include "nsNetSegmentUtils.h"
 #include "NetworkActivityMonitor.h"
 #include "nsStreamUtils.h"
 #include "nsIPipe.h"
 #include "prerror.h"
 #include "nsThreadUtils.h"
 #include "nsIDNSRecord.h"
@@ -514,17 +516,17 @@ nsUDPSocket::GetPort(int32_t *aResult)
   uint16_t port;
   if (mAddr.raw.family == PR_AF_INET)
     port = mAddr.inet.port;
   else if (mAddr.raw.family == PR_AF_INET6)
     port = mAddr.inet6.port;
   else
     return NS_ERROR_NOT_INITIALIZED;
 
-  *aResult = (int32_t) PR_ntohs(port);
+  *aResult = static_cast<int32_t>(NetworkEndian::readUint16(&port));
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsUDPSocket::GetAddress(NetAddr *aResult)
 {
   // no need to enter the lock here
   memcpy(aResult, &mAddr, sizeof(mAddr));