Bug 1248851 part 1 - Explicitly mark some release() calls result-unused. r=Waldo

MozReview-Commit-ID: Cgubemm1Et3
This commit is contained in:
Xidorn Quan 2016-02-20 11:06:25 +08:00
parent cec1b856d6
commit 84038e63d4
4 changed files with 13 additions and 6 deletions

View File

@ -34,7 +34,9 @@ DeserializeArrayBuffer(JSContext* cx,
JSObject* obj = JS_NewArrayBufferWithContents(cx, aBuffer.Length(), data.get());
if (!obj)
return false;
data.release();
// If JS_NewArrayBufferWithContents returns non-null, the ownership of
// the data is transfered to obj, so we release the ownership here.
mozilla::Unused << data.release();
aVal.setObject(*obj);
return true;

View File

@ -7,6 +7,7 @@
#include "FileReaderSync.h"
#include "jsfriendapi.h"
#include "mozilla/unused.h"
#include "mozilla/Base64.h"
#include "mozilla/dom/EncodingUtils.h"
#include "mozilla/dom/File.h"
@ -85,7 +86,9 @@ FileReaderSync::ReadAsArrayBuffer(JSContext* aCx,
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return;
}
bufferData.release();
// arrayBuffer takes the ownership when it is not null. Otherwise we
// need to release it explicitly.
mozilla::Unused << bufferData.release();
aRetval.set(arrayBuffer);
}

View File

@ -7,6 +7,7 @@
#include "builtin/TestingFunctions.h"
#include "mozilla/Move.h"
#include "mozilla/unused.h"
#include <cmath>
@ -2612,7 +2613,7 @@ FindPath(JSContext* cx, unsigned argc, Value* vp)
RootedString edgeStr(cx, NewString<CanGC>(cx, edgeName.get(), js_strlen(edgeName.get())));
if (!edgeStr)
return false;
edgeName.release(); // edgeStr acquired ownership
mozilla::Unused << edgeName.release(); // edgeStr acquired ownership
if (!JS_DefineProperty(cx, obj, "edge", edgeStr, JSPROP_ENUMERATE, nullptr, nullptr))
return false;

View File

@ -13,6 +13,7 @@
#include "mozilla/PodOperations.h"
#include "mozilla/Range.h"
#include "mozilla/TypeTraits.h"
#include "mozilla/unused.h"
#include <ctype.h>
#include <string.h>
@ -645,7 +646,7 @@ ToLowerCase(JSContext* cx, JSLinearString* str)
if (!res)
return nullptr;
newChars.release();
mozilla::Unused << newChars.release();
return res;
}
@ -788,13 +789,13 @@ ToUpperCase(JSContext* cx, JSLinearString* str)
if (!res)
return nullptr;
newChars.ref<Latin1CharPtr>().release();
mozilla::Unused << newChars.ref<Latin1CharPtr>().release();
} else {
res = NewStringDontDeflate<CanGC>(cx, newChars.ref<TwoByteCharPtr>().get(), length);
if (!res)
return nullptr;
newChars.ref<TwoByteCharPtr>().release();
mozilla::Unused << newChars.ref<TwoByteCharPtr>().release();
}
return res;