Bug 1201271 - Warn about unused results for more methods of nsTArray. r=froydnj

This leaves alone the AppendElement methods.
This commit is contained in:
Andrew McCreight 2015-09-15 15:30:44 -07:00
parent 2d06b997a3
commit 2e4be7587d
6 changed files with 34 additions and 23 deletions

View File

@ -93,7 +93,7 @@ AnalyserNode::AnalyserNode(AudioContext* aContext)
// Enough chunks must be recorded to handle the case of fftSize being // Enough chunks must be recorded to handle the case of fftSize being
// increased to maximum immediately before getFloatTimeDomainData() is // increased to maximum immediately before getFloatTimeDomainData() is
// called, for example. // called, for example.
(void)mChunks.SetLength(CHUNK_COUNT, fallible); unused << mChunks.SetLength(CHUNK_COUNT, fallible);
AllocateBuffer(); AllocateBuffer();
} }

View File

@ -494,8 +494,18 @@ struct AssertionConditionType
# define MOZ_ALWAYS_TRUE(expr) MOZ_ASSERT((expr)) # define MOZ_ALWAYS_TRUE(expr) MOZ_ASSERT((expr))
# define MOZ_ALWAYS_FALSE(expr) MOZ_ASSERT(!(expr)) # define MOZ_ALWAYS_FALSE(expr) MOZ_ASSERT(!(expr))
#else #else
# define MOZ_ALWAYS_TRUE(expr) ((void)(expr)) # define MOZ_ALWAYS_TRUE(expr) \
# define MOZ_ALWAYS_FALSE(expr) ((void)(expr)) do { \
if ( ( expr ) ) { \
/* Silence MOZ_WARN_UNUSED_RESULT. */ \
} \
} while (0)
# define MOZ_ALWAYS_FALSE(expr) \
do { \
if ( ( expr ) ) { \
/* Silence MOZ_WARN_UNUSED_RESULT. */ \
} \
} while (0)
#endif #endif
#undef MOZ_DUMP_ASSERTION_STACK #undef MOZ_DUMP_ASSERTION_STACK

View File

@ -110,7 +110,7 @@ BindingParams::BindingParams(mozIStorageBindingParamsArray *aOwningArray,
, mOwningStatement(aOwningStatement) , mOwningStatement(aOwningStatement)
{ {
(void)mOwningStatement->GetParameterCount(&mParamCount); (void)mOwningStatement->GetParameterCount(&mParamCount);
(void)mParameters.SetCapacity(mParamCount); mParameters.SetCapacity(mParamCount);
} }
BindingParams::BindingParams(mozIStorageBindingParamsArray *aOwningArray) BindingParams::BindingParams(mozIStorageBindingParamsArray *aOwningArray)

View File

@ -987,8 +987,8 @@ private:
{ {
MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread"); MOZ_ASSERT(NS_IsMainThread(), "This should be called on the main thread");
(void)mPlaces.SwapElements(aPlaces); mPlaces.SwapElements(aPlaces);
(void)mReferrers.SetLength(mPlaces.Length()); mReferrers.SetLength(mPlaces.Length());
for (nsTArray<VisitData>::size_type i = 0; i < mPlaces.Length(); i++) { for (nsTArray<VisitData>::size_type i = 0; i < mPlaces.Length(); i++) {
mReferrers[i].spec = mPlaces[i].referrerSpec; mReferrers[i].spec = mPlaces[i].referrerSpec;

View File

@ -1193,7 +1193,7 @@ public:
} }
template<class Allocator> template<class Allocator>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
bool Assign(const nsTArray_Impl<E, Allocator>& aOther, bool Assign(const nsTArray_Impl<E, Allocator>& aOther,
const mozilla::fallible_t&) const mozilla::fallible_t&)
{ {
@ -1274,7 +1274,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount, elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item* aArray, size_type aArrayLen, const Item* aArray, size_type aArrayLen,
const mozilla::fallible_t&) const mozilla::fallible_t&)
@ -1295,7 +1295,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount, elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const nsTArray<Item>& aArray, const nsTArray<Item>& aArray,
const mozilla::fallible_t&) const mozilla::fallible_t&)
@ -1314,7 +1314,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount, elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item& aItem, const mozilla::fallible_t&) const Item& aItem, const mozilla::fallible_t&)
{ {
@ -1339,7 +1339,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, const Item* aArray, elem_type* InsertElementsAt(index_type aIndex, const Item* aArray,
size_type aArrayLen, const mozilla::fallible_t&) size_type aArrayLen, const mozilla::fallible_t&)
{ {
@ -1358,7 +1358,7 @@ protected:
public: public:
template<class Item, class Allocator> template<class Item, class Allocator>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, elem_type* InsertElementsAt(index_type aIndex,
const nsTArray_Impl<Item, Allocator>& aArray, const nsTArray_Impl<Item, Allocator>& aArray,
const mozilla::fallible_t&) const mozilla::fallible_t&)
@ -1385,7 +1385,7 @@ protected:
} }
public: public:
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementAt(index_type aIndex, const mozilla::fallible_t&) elem_type* InsertElementAt(index_type aIndex, const mozilla::fallible_t&)
{ {
return InsertElementAt<FallibleAlloc>(aIndex); return InsertElementAt<FallibleAlloc>(aIndex);
@ -1409,7 +1409,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementAt(index_type aIndex, Item&& aItem, elem_type* InsertElementAt(index_type aIndex, Item&& aItem,
const mozilla::fallible_t&) const mozilla::fallible_t&)
{ {
@ -1466,7 +1466,7 @@ protected:
public: public:
template<class Item, class Comparator> template<class Item, class Comparator>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp, elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp,
const mozilla::fallible_t&) const mozilla::fallible_t&)
{ {
@ -1486,7 +1486,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementSorted(Item&& aItem, const mozilla::fallible_t&) elem_type* InsertElementSorted(Item&& aItem, const mozilla::fallible_t&)
{ {
return InsertElementSorted<Item, FallibleAlloc>( return InsertElementSorted<Item, FallibleAlloc>(
@ -1728,7 +1728,7 @@ protected:
} }
public: public:
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
bool SetCapacity(size_type aCapacity, const mozilla::fallible_t&) bool SetCapacity(size_type aCapacity, const mozilla::fallible_t&)
{ {
return SetCapacity<FallibleAlloc>(aCapacity); return SetCapacity<FallibleAlloc>(aCapacity);
@ -1757,7 +1757,7 @@ protected:
} }
public: public:
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
bool SetLength(size_type aNewLen, const mozilla::fallible_t&) bool SetLength(size_type aNewLen, const mozilla::fallible_t&)
{ {
return SetLength<FallibleAlloc>(aNewLen); return SetLength<FallibleAlloc>(aNewLen);
@ -1796,7 +1796,7 @@ protected:
} }
public: public:
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
bool EnsureLengthAtLeast(size_type aMinLen, const mozilla::fallible_t&) bool EnsureLengthAtLeast(size_type aMinLen, const mozilla::fallible_t&)
{ {
return EnsureLengthAtLeast<FallibleAlloc>(aMinLen); return EnsureLengthAtLeast<FallibleAlloc>(aMinLen);
@ -1828,7 +1828,7 @@ protected:
} }
public: public:
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, size_type aCount, elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const mozilla::fallible_t&) const mozilla::fallible_t&)
{ {
@ -1865,7 +1865,7 @@ protected:
public: public:
template<class Item> template<class Item>
/* MOZ_WARN_UNUSED_RESULT */ MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, size_type aCount, elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const Item& aItem, const mozilla::fallible_t&) const Item& aItem, const mozilla::fallible_t&)
{ {

View File

@ -5,6 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/unused.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -1115,9 +1116,9 @@ static bool test_SetLengthAndRetainStorage_no_ctor() {
pre t post; \ pre t post; \
pre tauto post; \ pre tauto post; \
} while (0) } while (0)
// Setup test arrays. // Setup test arrays.
FOR_EACH(;, .SetLength(N, fallible)); FOR_EACH(; unused << , .SetLength(N, fallible));
for (int n = 0; n < N; ++n) { for (int n = 0; n < N; ++n) {
FOR_EACH(;, [n] = n); FOR_EACH(;, [n] = n);
} }