Mark variables as unused.

clang is smart enough to notice a variable is set but not used,
but these variable are used for testing purposes. Mark one as
unused, and convert the other to a DoNotOptimize.

Bug: 197240255

Test: Compiles without warnings.
Test: Ran unit tests on coral hwasan build.
Change-Id: Ibc873e477355a702579e5a680780c77db0c58046
This commit is contained in:
Christopher Ferris 2021-12-14 06:28:40 +00:00
parent f190be84f5
commit 724efbb57c
2 changed files with 3 additions and 3 deletions

View File

@ -20,7 +20,7 @@
#include <termios.h>
TEST(sys_ttydefaults, flags) {
int i;
[[maybe_unused]] int i;
i = TTYDEF_IFLAG;
i = TTYDEF_OFLAG;
i = TTYDEF_LFLAG;

View File

@ -688,9 +688,9 @@ __attribute__((noinline)) static void HwasanVforkTestChild() {
__attribute__((noinline)) static void HwasanReadMemory(const char* p, size_t size) {
// Read memory byte-by-byte. This will blow up if the pointer tag in p does not match any memory
// tag in [p, p+size).
volatile char z;
char z;
for (size_t i = 0; i < size; ++i) {
z = p[i];
DoNotOptimize(z = p[i]);
}
}