Bug 1499277 - Remove unnecessary SCInput::readNativeEndian; fix SCInput::readPtr on big endian systems. r=sfink
authorA. Wilcox <AWilcox@Wilcox-Tech.com>
Tue, 16 Oct 2018 05:43:43 +0000
changeset 490040 3a58f94c3f5ad656c0c96abf87d0522c3066690e
parent 490038 7a7d5508f873579944aee993dbf0007a5503f94f
child 490041 37647eaadbc29b3f744b225825414bca6bad5b1c
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewerssfink
bugs1499277
milestone64.0a1
Bug 1499277 - Remove unnecessary SCInput::readNativeEndian; fix SCInput::readPtr on big endian systems. r=sfink
js/src/vm/StructuredClone.cpp
--- a/js/src/vm/StructuredClone.cpp
+++ b/js/src/vm/StructuredClone.cpp
@@ -361,17 +361,16 @@ class SCInput {
     SCInput(JSContext* cx, JSStructuredCloneData& data);
 
     JSContext* context() const { return cx; }
 
     static void getPtr(uint64_t data, void** ptr);
     static void getPair(uint64_t data, uint32_t* tagp, uint32_t* datap);
 
     MOZ_MUST_USE bool read(uint64_t* p);
-    MOZ_MUST_USE bool readNativeEndian(uint64_t* p);
     MOZ_MUST_USE bool readPair(uint32_t* tagp, uint32_t* datap);
     MOZ_MUST_USE bool readDouble(double* p);
     MOZ_MUST_USE bool readBytes(void* p, size_t nbytes);
     MOZ_MUST_USE bool readChars(Latin1Char* p, size_t nchars);
     MOZ_MUST_USE bool readChars(char16_t* p, size_t nchars);
     MOZ_MUST_USE bool readPtr(void**);
 
     MOZ_MUST_USE bool get(uint64_t* p);
@@ -698,28 +697,16 @@ SCInput::read(uint64_t* p)
         return reportTruncated();
     }
     *p = NativeEndian::swapFromLittleEndian(point.peek());
     point.next();
     return true;
 }
 
 bool
-SCInput::readNativeEndian(uint64_t* p)
-{
-    if (!point.canPeek()) {
-        *p = 0;  // initialize to shut GCC up
-        return reportTruncated();
-    }
-    *p = point.peek();
-    point.next();
-    return true;
-}
-
-bool
 SCInput::readPair(uint32_t* tagp, uint32_t* datap)
 {
     uint64_t u;
     bool ok = read(&u);
     if (ok) {
         *tagp = uint32_t(u >> 32);
         *datap = uint32_t(u);
     }
@@ -849,17 +836,17 @@ SCInput::getPtr(uint64_t data, void** pt
 {
     *ptr = reinterpret_cast<void*>(NativeEndian::swapFromLittleEndian(data));
 }
 
 bool
 SCInput::readPtr(void** p)
 {
     uint64_t u;
-    if (!readNativeEndian(&u)) {
+    if (!read(&u)) {
         return false;
     }
     *p = reinterpret_cast<void*>(u);
     return true;
 }
 
 SCOutput::SCOutput(JSContext* cx, JS::StructuredCloneScope scope)
   : cx(cx), buf(scope)