Fix warnings produced by trunk clang in test code

These are mostly -Wsign-compare warnings, with a -Wconstant-conversion
and a -Wunguarded-availability thrown in.

Bug: chromium:779790
Change-Id: Ic2103f3332ce57378db83eca7fa2569efec1a7b6
Reviewed-on: https://chromium-review.googlesource.com/746081
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
This commit is contained in:
Mark Mentovai 2017-10-31 14:56:28 -04:00
Родитель a0f4f294b1
Коммит a51e912004
8 изменённых файлов: 41 добавлений и 26 удалений

Просмотреть файл

@ -21,6 +21,7 @@
#include <utility>
#include "base/compiler_specific.h"
#include "build/build_config.h"
#include "gtest/gtest.h"
#include "minidump/minidump_stream_writer.h"
#include "minidump/minidump_user_extension_stream_data_source.h"
@ -395,9 +396,18 @@ TEST(MinidumpFileWriter, InitializeFromSnapshot_Exception) {
// In a 32-bit environment, this will give a “timestamp out of range” warning,
// but the test should complete without failure.
constexpr uint32_t kSnapshotTime = 0xfd469ab8;
#if defined(COMPILER_GCC) || defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconstant-conversion"
#define DISABLED_WCONSTANT_CONVERSION
#endif // COMPILER_GCC || __clang__
MSVC_SUPPRESS_WARNING(4309); // Truncation of constant value.
MSVC_SUPPRESS_WARNING(4838); // Narrowing conversion.
constexpr timeval kSnapshotTimeval = {static_cast<time_t>(kSnapshotTime), 0};
#if defined(DISABLED_WCONSTANT_CONVERSION)
#pragma GCC diagnostic pop
#undef DISABLED_WCONSTANT_CONVERSION
#endif // DISABLED_WCONSTANT_CONVERSION
TestProcessSnapshot process_snapshot;
process_snapshot.SetSnapshotTime(kSnapshotTimeval);

Просмотреть файл

@ -42,16 +42,6 @@
#include "util/misc/from_pointer_cast.h"
#include "util/synchronization/semaphore.h"
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
extern "C" {
// Redeclare a typedef whose availability (OS X 10.10) is newer than the
// deployment target.
typedef struct _cl_device_id* cl_device_id;
} // extern "C"
#endif
namespace crashpad {
namespace test {
namespace {
@ -574,10 +564,24 @@ class ScopedOpenCLNoOpKernel {
cl_int rv = clGetPlatformIDs(1, &platform_id, nullptr);
ASSERT_EQ(rv, CL_SUCCESS) << "clGetPlatformIDs";
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 && \
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10
// cl_device_id is really available in OpenCL.framework back to 10.5, but in
// the 10.10 SDK and later, OpenCL.framework includes <OpenGL/CGLDevice.h>,
// which has its own cl_device_id that was introduced in 10.10. That
// triggers erroneous availability warnings.
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
#define DISABLED_WUNGUARDED_AVAILABILITY
#endif // SDK >= 10.10 && DT < 10.10
// Use CL_DEVICE_TYPE_CPU to ensure that the kernel would execute on the
// CPU. This is the only device type that a cl_kernels image will be created
// for.
cl_device_id device_id;
#if defined(DISABLED_WUNGUARDED_AVAILABILITY)
#pragma clang diagnostic pop
#undef DISABLED_WUNGUARDED_AVAILABILITY
#endif // DISABLED_WUNGUARDED_AVAILABILITY
rv =
clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_CPU, 1, &device_id, nullptr);
ASSERT_EQ(rv, CL_SUCCESS) << "clGetDeviceIDs";

Просмотреть файл

@ -80,9 +80,9 @@ void TestInitializeX86Context_FsaveWithoutFxsave() {
EXPECT_EQ(cpu_context_x86.fxsave.fsw, 0x0004);
EXPECT_EQ(cpu_context_x86.fxsave.ftw, 0x00f0);
EXPECT_EQ(cpu_context_x86.fxsave.fop, 0x0bad);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_ip, 0x01234567);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_ip, 0x01234567u);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_cs, 0x0003);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_dp, 0x89abcdef);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_dp, 0x89abcdefu);
EXPECT_EQ(cpu_context_x86.fxsave.fpu_ds, 0x0007);
for (size_t st_mm = 0; st_mm < 7; ++st_mm) {
EXPECT_EQ(

Просмотреть файл

@ -28,7 +28,7 @@ DWORD WINAPI LotsOfReferencesThreadProc(void* param) {
// Allocate a bunch of pointers to things on the stack.
int* pointers[1000];
for (int i = 0; i < arraysize(pointers); ++i) {
for (size_t i = 0; i < arraysize(pointers); ++i) {
pointers[i] = new int[2048];
}
@ -52,7 +52,7 @@ int wmain(int argc, wchar_t* argv[]) {
// verify the cap on pointed-to memory.
crashpad::Semaphore semaphore(0);
crashpad::ScopedKernelHANDLE threads[100];
for (int i = 0; i < arraysize(threads); ++i) {
for (size_t i = 0; i < arraysize(threads); ++i) {
threads[i].reset(CreateThread(nullptr,
0,
&LotsOfReferencesThreadProc,
@ -65,7 +65,7 @@ int wmain(int argc, wchar_t* argv[]) {
}
}
for (int i = 0; i < arraysize(threads); ++i) {
for (size_t i = 0; i < arraysize(threads); ++i) {
semaphore.Wait();
}

Просмотреть файл

@ -203,7 +203,7 @@ class SimulateDelegate : public ExceptionHandlerServer::Delegate {
exception_information_address,
debug_critical_section_address);
EXPECT_TRUE(snapshot.Exception());
EXPECT_EQ(snapshot.Exception()->Exception(), 0x517a7ed);
EXPECT_EQ(snapshot.Exception()->Exception(), 0x517a7edu);
// Verify the dump was captured at the expected location with some slop
// space.
@ -271,7 +271,7 @@ void TestDumpWithoutCrashingChild(const base::FilePath& directory) {
EXPECT_EQ(WaitForSingleObject(completed.get(), INFINITE), WAIT_OBJECT_0)
<< ErrorMessage("WaitForSingleObject");
EXPECT_EQ(child.WaitForExit(), 0);
EXPECT_EQ(child.WaitForExit(), 0u);
}
TEST(SimulateCrash, ChildDumpWithoutCrashing) {

Просмотреть файл

@ -73,13 +73,14 @@ void TestVSFixedFileInfo(ProcessReaderWin* process_reader,
ASSERT_TRUE(observed_rv || !known_dll);
if (observed_rv) {
EXPECT_EQ(observed.dwSignature, VS_FFI_SIGNATURE);
EXPECT_EQ(observed.dwStrucVersion, VS_FFI_STRUCVERSION);
EXPECT_EQ(observed.dwFileFlags & ~observed.dwFileFlagsMask, 0);
EXPECT_EQ(observed.dwFileOS, VOS_NT_WINDOWS32);
EXPECT_EQ(observed.dwSignature, static_cast<DWORD>(VS_FFI_SIGNATURE));
EXPECT_EQ(observed.dwStrucVersion, static_cast<DWORD>(VS_FFI_STRUCVERSION));
EXPECT_EQ(observed.dwFileFlags & ~observed.dwFileFlagsMask, 0u);
if (known_dll) {
EXPECT_EQ(observed.dwFileType, VFT_DLL);
EXPECT_EQ(observed.dwFileOS, static_cast<DWORD>(VOS_NT_WINDOWS32));
EXPECT_EQ(observed.dwFileType, static_cast<DWORD>(VFT_DLL));
} else {
EXPECT_NE(observed.dwFileOS & VOS_NT_WINDOWS32, 0u);
EXPECT_TRUE(observed.dwFileType == VFT_APP ||
observed.dwFileType == VFT_DLL);
}

Просмотреть файл

@ -107,12 +107,12 @@ TEST(ProcessReaderWin, SelfOneThread) {
EXPECT_EQ(threads[0].id, GetCurrentThreadId());
#if defined(ARCH_CPU_64_BITS)
EXPECT_NE(threads[0].context.native.Rip, 0);
EXPECT_NE(threads[0].context.native.Rip, 0u);
#else
EXPECT_NE(threads[0].context.native.Eip, 0u);
#endif
EXPECT_EQ(threads[0].suspend_count, 0);
EXPECT_EQ(threads[0].suspend_count, 0u);
}
class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess {
@ -188,7 +188,7 @@ class ProcessReaderChildThreadSuspendCount final : public WinMultiprocess {
// the pipe.
CheckedReadFileAtEOF(ReadPipeHandle());
for (int i = 0; i < arraysize(threads); ++i)
for (size_t i = 0; i < arraysize(threads); ++i)
done.Signal();
for (auto& thread : threads)
thread.Join();

Просмотреть файл

@ -109,7 +109,7 @@ void TestImageReaderChild(const base::FilePath& directory) {
// Tell the child it can terminate.
EXPECT_TRUE(SetEvent(done.get())) << ErrorMessage("SetEvent");
EXPECT_EQ(child.WaitForExit(), 0);
EXPECT_EQ(child.WaitForExit(), 0u);
}
TEST(ProcessSnapshotTest, CrashpadInfoChild) {