forked from mirrors/gecko-dev
Bug 1732208 - Silence the unused-but-set-variable warning in xpcom. r=xpcom-reviewers,mccr8
xpcom/tests/gtest/TestAvailableMemoryWatcherWin.cpp(130,22): error: variable 'x' set but not used [-Werror,-Wunused-but-set-variable]
volatile uint8_t x = 0;
^
xpcom/tests/gtest/TestAvailableMemoryWatcherWin.cpp(152,12): error: variable 'consumed' set but not used [-Werror,-Wunused-but-set-variable]
size_t consumed = 0;
^
xpcom/tests/gtest/TestSTLWrappers.cpp:48:7: error: variable 'rv' set but not used [-Werror,-Wunused-but-set-variable]
int rv = 1;
^
Differential Revision: https://phabricator.services.mozilla.com/D126462
This commit is contained in:
parent
b386a9ea29
commit
dcfb8d38be
2 changed files with 2 additions and 6 deletions
|
|
@ -134,6 +134,7 @@ class MemoryEater {
|
|||
// and dereference it.
|
||||
x ^= *(base + i * kPageSize + rand() % kPageSize);
|
||||
}
|
||||
(void)x;
|
||||
}
|
||||
|
||||
static uint32_t GetAvailablePhysicalMemoryInMb() {
|
||||
|
|
@ -149,7 +150,6 @@ class MemoryEater {
|
|||
constexpr size_t kMinGranularity = 64 * 1024;
|
||||
|
||||
size_t currentSize = aSize;
|
||||
size_t consumed = 0;
|
||||
while (aSize >= kMinGranularity) {
|
||||
if (!GetAvailablePhysicalMemoryInMb()) {
|
||||
// If the available physical memory is less than 1MB, we finish
|
||||
|
|
@ -172,7 +172,6 @@ class MemoryEater {
|
|||
}
|
||||
|
||||
aSize -= currentSize;
|
||||
consumed += currentSize;
|
||||
|
||||
// VirtualAlloc consumes the commit space, but we need to *touch* memory
|
||||
// to consume physical memory
|
||||
|
|
|
|||
|
|
@ -45,14 +45,11 @@ void ShouldAbort() {
|
|||
}
|
||||
|
||||
std::vector<int> v;
|
||||
int rv = 1;
|
||||
|
||||
TRY {
|
||||
// v.at(1) on empty v should abort; NOT throw an exception
|
||||
|
||||
// (Do some arithmetic with result of v.at() to avoid
|
||||
// compiler warnings for unused variable/result.)
|
||||
rv += v.at(1) ? 1 : 2;
|
||||
(void)v.at(1);
|
||||
}
|
||||
CATCH(const std::out_of_range&) {
|
||||
fputs("TEST-FAIL | TestSTLWrappers.cpp | caught an exception?\n", stderr);
|
||||
|
|
|
|||
Loading…
Reference in a new issue