win: fix various warnings in minidump_system_info_writer_test.cc

- Stack object instantiated for sizeof to avoid

d:\src\crashpad\crashpad\minidump\minidump_system_info_writer_test.cc(43) : error C2597: illegal reference to non-static member '_MINIDUMP_STRING::Buffer'

Could also just be sizeof(WCHAR) if that feels less ugly.

- narrowing cast
- potentially uninitialize variable warning

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/886143004
This commit is contained in:
Scott Graham 2015-02-05 09:39:54 -08:00
Родитель 2d2ad633ea
Коммит 38a026ffc7
1 изменённых файлов: 16 добавлений и 14 удалений

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

@ -22,6 +22,7 @@
#include <algorithm>
#include <string>
#include "base/compiler_specific.h"
#include "gtest/gtest.h"
#include "minidump/minidump_file_writer.h"
#include "minidump/test/minidump_file_writer_test_util.h"
@ -39,10 +40,11 @@ void GetSystemInfoStream(const std::string& file_contents,
const MINIDUMP_SYSTEM_INFO** system_info,
const MINIDUMP_STRING** csd_version) {
// The expected number of bytes for the CSD versions MINIDUMP_STRING::Buffer.
const size_t kCSDVersionBytes =
csd_version_length * sizeof(MINIDUMP_STRING::Buffer[0]);
MINIDUMP_STRING tmp = {0};
ALLOW_UNUSED_LOCAL(tmp);
const size_t kCSDVersionBytes = csd_version_length * sizeof(tmp.Buffer[0]);
const size_t kCSDVersionBytesWithNUL =
kCSDVersionBytes + sizeof(MINIDUMP_STRING::Buffer[0]);
kCSDVersionBytes + sizeof(tmp.Buffer[0]);
const size_t kDirectoryOffset = sizeof(MINIDUMP_HEADER);
const size_t kSystemInfoStreamOffset =
@ -85,8 +87,8 @@ TEST(MinidumpSystemInfoWriter, Empty) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_STRING* csd_version;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version = nullptr;
ASSERT_NO_FATAL_FAILURE(
GetSystemInfoStream(file_writer.string(), 0, &system_info, &csd_version));
@ -156,8 +158,8 @@ TEST(MinidumpSystemInfoWriter, X86_Win) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_STRING* csd_version;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version = nullptr;
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
file_writer.string(), strlen(kCSDVersion), &system_info, &csd_version));
@ -216,7 +218,7 @@ TEST(MinidumpSystemInfoWriter, AMD64_Mac) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version;
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(
@ -258,7 +260,7 @@ TEST(MinidumpSystemInfoWriter, X86_CPUVendorFromRegisters) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version;
ASSERT_NO_FATAL_FAILURE(
@ -280,7 +282,7 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
const uint8_t kCPUStepping = 1;
const uint8_t kCPUBasicFamily =
std::min(kCPUFamily, implicit_cast<uint16_t>(15));
static_cast<uint8_t>(std::min(kCPUFamily, static_cast<uint16_t>(15)));
const uint8_t kCPUExtendedFamily = kCPUFamily - kCPUBasicFamily;
// These checks ensure that even if the constants above change, they represent
@ -338,8 +340,8 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_X86) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_STRING* csd_version;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version = nullptr;
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(file_writer.string(),
strlen(kOSVersionBuild),
&system_info,
@ -433,8 +435,8 @@ TEST(MinidumpSystemInfoWriter, InitializeFromSnapshot_AMD64) {
StringFileWriter file_writer;
ASSERT_TRUE(minidump_file_writer.WriteEverything(&file_writer));
const MINIDUMP_SYSTEM_INFO* system_info;
const MINIDUMP_STRING* csd_version;
const MINIDUMP_SYSTEM_INFO* system_info = nullptr;
const MINIDUMP_STRING* csd_version = nullptr;
ASSERT_NO_FATAL_FAILURE(GetSystemInfoStream(file_writer.string(),
strlen(kOSVersionBuild),
&system_info,