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
// increased to maximum immediately before getFloatTimeDomainData() is
// called, for example.
(void)mChunks.SetLength(CHUNK_COUNT, fallible);
unused << mChunks.SetLength(CHUNK_COUNT, fallible);
AllocateBuffer();
}

View File

@ -494,8 +494,18 @@ struct AssertionConditionType
# define MOZ_ALWAYS_TRUE(expr) MOZ_ASSERT((expr))
# define MOZ_ALWAYS_FALSE(expr) MOZ_ASSERT(!(expr))
#else
# define MOZ_ALWAYS_TRUE(expr) ((void)(expr))
# define MOZ_ALWAYS_FALSE(expr) ((void)(expr))
# define MOZ_ALWAYS_TRUE(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
#undef MOZ_DUMP_ASSERTION_STACK

View File

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

View File

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

View File

@ -1193,7 +1193,7 @@ public:
}
template<class Allocator>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
bool Assign(const nsTArray_Impl<E, Allocator>& aOther,
const mozilla::fallible_t&)
{
@ -1274,7 +1274,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item* aArray, size_type aArrayLen,
const mozilla::fallible_t&)
@ -1295,7 +1295,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const nsTArray<Item>& aArray,
const mozilla::fallible_t&)
@ -1314,7 +1314,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* ReplaceElementsAt(index_type aStart, size_type aCount,
const Item& aItem, const mozilla::fallible_t&)
{
@ -1339,7 +1339,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, const Item* aArray,
size_type aArrayLen, const mozilla::fallible_t&)
{
@ -1358,7 +1358,7 @@ protected:
public:
template<class Item, class Allocator>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex,
const nsTArray_Impl<Item, Allocator>& aArray,
const mozilla::fallible_t&)
@ -1385,7 +1385,7 @@ protected:
}
public:
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementAt(index_type aIndex, const mozilla::fallible_t&)
{
return InsertElementAt<FallibleAlloc>(aIndex);
@ -1409,7 +1409,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementAt(index_type aIndex, Item&& aItem,
const mozilla::fallible_t&)
{
@ -1466,7 +1466,7 @@ protected:
public:
template<class Item, class Comparator>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementSorted(Item&& aItem, const Comparator& aComp,
const mozilla::fallible_t&)
{
@ -1486,7 +1486,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementSorted(Item&& aItem, const mozilla::fallible_t&)
{
return InsertElementSorted<Item, FallibleAlloc>(
@ -1728,7 +1728,7 @@ protected:
}
public:
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
bool SetCapacity(size_type aCapacity, const mozilla::fallible_t&)
{
return SetCapacity<FallibleAlloc>(aCapacity);
@ -1757,7 +1757,7 @@ protected:
}
public:
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
bool SetLength(size_type aNewLen, const mozilla::fallible_t&)
{
return SetLength<FallibleAlloc>(aNewLen);
@ -1796,7 +1796,7 @@ protected:
}
public:
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
bool EnsureLengthAtLeast(size_type aMinLen, const mozilla::fallible_t&)
{
return EnsureLengthAtLeast<FallibleAlloc>(aMinLen);
@ -1828,7 +1828,7 @@ protected:
}
public:
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
const mozilla::fallible_t&)
{
@ -1865,7 +1865,7 @@ protected:
public:
template<class Item>
/* MOZ_WARN_UNUSED_RESULT */
MOZ_WARN_UNUSED_RESULT
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
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/. */
#include "mozilla/ArrayUtils.h"
#include "mozilla/unused.h"
#include <stdlib.h>
#include <stdio.h>
@ -1117,7 +1118,7 @@ static bool test_SetLengthAndRetainStorage_no_ctor() {
} while (0)
// Setup test arrays.
FOR_EACH(;, .SetLength(N, fallible));
FOR_EACH(; unused << , .SetLength(N, fallible));
for (int n = 0; n < N; ++n) {
FOR_EACH(;, [n] = n);
}