Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1003)

Unified Diff: minidump/minidump_system_info_writer_test.cc

Issue 886143004: win: fix various warnings in minidump_system_info_writer_test.cc (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@minidump_test-3
Patch Set: allow_unused_local Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: minidump/minidump_system_info_writer_test.cc
diff --git a/minidump/minidump_system_info_writer_test.cc b/minidump/minidump_system_info_writer_test.cc
index 59145e19d54d05619c99cab3ff7178a354eb5c52..f127bc7fbdf87fd8c47ffb805f216332a27343e3 100644
--- a/minidump/minidump_system_info_writer_test.cc
+++ b/minidump/minidump_system_info_writer_test.cc
@@ -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 version’s MINIDUMP_STRING::Buffer.
- const size_t kCSDVersionBytes =
- csd_version_length * sizeof(MINIDUMP_STRING::Buffer[0]);
+ MINIDUMP_STRING tmp = {0};
Mark Mentovai 2015/02/05 17:13:02 Is the initialization required?
scottmg 2015/02/05 17:39:44 Yes, it otherwise complains that: warning C4815:
+ 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,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698