Bug 1274148 (part 1) - Use MOZ_MUST_USE more in xpcom/io/Base64.h. r=erahm,bagder,mattwoodrow.
☠☠ backed out by f01ad499d0e0 ☠ ☠
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 06 Jun 2016 09:21:00 +1000
changeset 339576 0ed86240bc7725cddfd351b22584bf4a2197d22b
parent 339575 fc00bd9f0d0919c7b350862b9b44239a7d5bd837
child 339577 a87ed5532b9e49a8ada850d80b39ca12f512c5dc
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm, bagder, mattwoodrow
bugs1274148
milestone49.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 1274148 (part 1) - Use MOZ_MUST_USE more in xpcom/io/Base64.h. r=erahm,bagder,mattwoodrow.
gfx/layers/LayerScope.cpp
netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
xpcom/io/Base64.h
--- a/gfx/layers/LayerScope.cpp
+++ b/gfx/layers/LayerScope.cpp
@@ -1472,18 +1472,20 @@ LayerScopeWebSocketManager::SocketHandle
     nsAutoCString guid("258EAFA5-E914-47DA-95CA-C5AB0DC85B11");
     nsAutoCString res;
     SHA1Sum sha1;
     nsCString combined(wsKey + guid);
     sha1.update(combined.get(), combined.Length());
     uint8_t digest[SHA1Sum::kHashSize]; // SHA1 digests are 20 bytes long.
     sha1.finish(digest);
     nsCString newString(reinterpret_cast<char*>(digest), SHA1Sum::kHashSize);
-    Base64Encode(newString, res);
-
+    rv = Base64Encode(newString, res);
+    if (NS_FAILED(rv)) {
+        return false;
+    }
     nsCString response("HTTP/1.1 101 Switching Protocols\r\n");
     response.AppendLiteral("Upgrade: websocket\r\n");
     response.AppendLiteral("Connection: Upgrade\r\n");
     response.Append(nsCString("Sec-WebSocket-Accept: ") + res + nsCString("\r\n"));
     response.AppendLiteral("Sec-WebSocket-Protocol: binary\r\n\r\n");
     uint32_t written = 0;
     uint32_t size = response.Length();
     while (written < size) {
--- a/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
+++ b/netwerk/system/linux/nsNotifyAddrListener_Linux.cpp
@@ -175,17 +175,18 @@ void nsNotifyAddrListener::calculateNetw
                                 nsAutoCString output;
                                 SHA1Sum sha1;
                                 nsCString combined(mac + addition);
                                 sha1.update(combined.get(), combined.Length());
                                 uint8_t digest[SHA1Sum::kHashSize];
                                 sha1.finish(digest);
                                 nsCString newString(reinterpret_cast<char*>(digest),
                                                     SHA1Sum::kHashSize);
-                                Base64Encode(newString, output);
+                                nsresult rv = Base64Encode(newString, output);
+                                MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
                                 LOG(("networkid: id %s\n", output.get()));
                                 if (mNetworkId != output) {
                                     // new id
                                     Telemetry::Accumulate(Telemetry::NETWORK_ID, 1);
                                     mNetworkId = output;
                                 }
                                 else {
                                     // same id
--- a/xpcom/io/Base64.h
+++ b/xpcom/io/Base64.h
@@ -8,63 +8,63 @@
 #define mozilla_Base64_h__
 
 #include "nsString.h"
 
 class nsIInputStream;
 
 namespace mozilla {
 
-nsresult
+MOZ_MUST_USE nsresult
 Base64EncodeInputStream(nsIInputStream* aInputStream,
                         nsACString& aDest,
                         uint32_t aCount,
                         uint32_t aOffset = 0);
-nsresult
+MOZ_MUST_USE nsresult
 Base64EncodeInputStream(nsIInputStream* aInputStream,
                         nsAString& aDest,
                         uint32_t aCount,
                         uint32_t aOffset = 0);
 
-nsresult
+MOZ_MUST_USE nsresult
 Base64Encode(const char* aBinary, uint32_t aBinaryLen, char** aBase64);
-nsresult
+MOZ_MUST_USE nsresult
 Base64Encode(const nsACString& aBinary, nsACString& aBase64);
-nsresult
+MOZ_MUST_USE nsresult
 Base64Encode(const nsAString& aBinary, nsAString& aBase64);
 
-nsresult
+MOZ_MUST_USE nsresult
 Base64Decode(const nsACString& aBase64, nsACString& aBinary);
-nsresult
+MOZ_MUST_USE nsresult
 Base64Decode(const nsAString& aBase64, nsAString& aBinary);
 
 enum class Base64URLEncodePaddingPolicy {
   Include,
   Omit,
 };
 
 /**
  * Converts |aBinary| to an unpadded, Base64 URL-encoded string per RFC 4648.
  * Aims to encode the data in constant time. The caller retains ownership
  * of |aBinary|.
  */
-nsresult
+MOZ_MUST_USE nsresult
 Base64URLEncode(uint32_t aBinaryLen, const uint8_t* aBinary,
                 Base64URLEncodePaddingPolicy aPaddingPolicy,
                 nsACString& aBase64);
 
 enum class Base64URLDecodePaddingPolicy {
   Require,
   Ignore,
   Reject,
 };
 
 /**
  * Decodes a Base64 URL-encoded |aBase64| into |aBinary|.
  */
-nsresult
+MOZ_MUST_USE nsresult
 Base64URLDecode(const nsACString& aBase64,
                 Base64URLDecodePaddingPolicy aPaddingPolicy,
                 FallibleTArray<uint8_t>& aBinary);
 
 } // namespace mozilla
 
 #endif