Add sk_ignore_unused_variable to avoid warnings.

https://codereview.appspot.com/7218045/


git-svn-id: http://skia.googlecode.com/svn/trunk@7539 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2013-02-04 15:58:08 +00:00
parent c1f9011ceb
commit 7de18e5c7b
2 changed files with 10 additions and 7 deletions

View File

@ -11,8 +11,7 @@
#include "SkMD5.h"
#include "SkRandom.h"
#include "SkSHA1.h"
template<typename T> inline void sk_ignore_unused(const T&) { }
#include "SkTemplates.h"
enum ChecksumType {
kChecksum_ChecksumType,
@ -57,7 +56,7 @@ protected:
case kChecksum_ChecksumType: {
for (int i = 0; i < N; i++) {
volatile uint32_t result = SkChecksum::Compute(fData, sizeof(fData));
sk_ignore_unused(result);
sk_ignore_unused_variable(result);
}
} break;
case kMD5_ChecksumType: {
@ -66,7 +65,6 @@ protected:
md5.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkMD5::Digest digest;
md5.finish(digest);
sk_ignore_unused(digest);
}
} break;
case kSHA1_ChecksumType: {
@ -75,19 +73,18 @@ protected:
sha1.update(reinterpret_cast<uint8_t*>(fData), sizeof(fData));
SkSHA1::Digest digest;
sha1.finish(digest);
sk_ignore_unused(digest);
}
} break;
case kCityHash32: {
for (int i = 0; i < N; i++) {
volatile uint32_t result = SkCityHash::Compute32(reinterpret_cast<char*>(fData), sizeof(fData));
sk_ignore_unused(result);
sk_ignore_unused_variable(result);
}
} break;
case kCityHash64: {
for (int i = 0; i < N; i++) {
volatile uint64_t result = SkCityHash::Compute64(reinterpret_cast<char*>(fData), sizeof(fData));
sk_ignore_unused(result);
sk_ignore_unused_variable(result);
}
} break;
}

View File

@ -19,6 +19,12 @@
resource management.
*/
/**
* Marks a local variable as known to be unused (to avoid warnings).
* Note that this does *not* prevent the local variable from being optimized away.
*/
template<typename T> inline void sk_ignore_unused_variable(const T&) { }
/**
* SkTIsConst<T>::value is true if the type T is const.
* The type T is constrained not to be an array or reference type.