mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-02-19 00:39:38 +00:00
Cleaning up google-breakpad source code of signed-unsigned comparison warnings
http://breakpad.appspot.com/488002/ git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1083 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
@@ -240,7 +240,7 @@ bool ExceptionHandler::InstallHandlersLocked() {
|
||||
return false;
|
||||
|
||||
// Fail if unable to store all the old handlers.
|
||||
for (unsigned i = 0; i < kNumHandledSignals; ++i) {
|
||||
for (int i = 0; i < kNumHandledSignals; ++i) {
|
||||
if (sigaction(kExceptionSignals[i], NULL, &old_handlers[i]) == -1)
|
||||
return false;
|
||||
}
|
||||
@@ -250,13 +250,13 @@ bool ExceptionHandler::InstallHandlersLocked() {
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
// Mask all exception signals when we're handling one of them.
|
||||
for (unsigned i = 0; i < kNumHandledSignals; ++i)
|
||||
for (int i = 0; i < kNumHandledSignals; ++i)
|
||||
sigaddset(&sa.sa_mask, kExceptionSignals[i]);
|
||||
|
||||
sa.sa_sigaction = SignalHandler;
|
||||
sa.sa_flags = SA_ONSTACK | SA_SIGINFO;
|
||||
|
||||
for (unsigned i = 0; i < kNumHandledSignals; ++i) {
|
||||
for (int i = 0; i < kNumHandledSignals; ++i) {
|
||||
if (sigaction(kExceptionSignals[i], &sa, NULL) == -1) {
|
||||
// At this point it is impractical to back out changes, and so failure to
|
||||
// install a signal is intentionally ignored.
|
||||
@@ -273,7 +273,7 @@ void ExceptionHandler::RestoreHandlersLocked() {
|
||||
if (!handlers_installed)
|
||||
return;
|
||||
|
||||
for (unsigned i = 0; i < kNumHandledSignals; ++i) {
|
||||
for (int i = 0; i < kNumHandledSignals; ++i) {
|
||||
if (sigaction(kExceptionSignals[i], &old_handlers[i], NULL) == -1) {
|
||||
signal(kExceptionSignals[i], SIG_DFL);
|
||||
}
|
||||
|
||||
@@ -108,9 +108,9 @@ void ReadMinidumpPathFromPipe(int fd, string* path) {
|
||||
ASSERT_EQ(1, r);
|
||||
ASSERT_TRUE(pfd.revents & POLLIN);
|
||||
|
||||
uint32_t len;
|
||||
int32_t len;
|
||||
ASSERT_EQ(static_cast<ssize_t>(sizeof(len)), read(fd, &len, sizeof(len)));
|
||||
ASSERT_LT(len, static_cast<uint32_t>(2048));
|
||||
ASSERT_LT(len, 2048);
|
||||
char* filename = static_cast<char*>(malloc(len + 1));
|
||||
ASSERT_EQ(len, read(fd, filename, len));
|
||||
filename[len] = 0;
|
||||
@@ -194,7 +194,7 @@ void ChildCrash(bool use_fd) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_path.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
unlink(minidump_path.c_str());
|
||||
}
|
||||
|
||||
@@ -465,7 +465,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_path.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
// Read the minidump. Locate the exception record and the
|
||||
// memory list, and then ensure that there is a memory region
|
||||
@@ -478,7 +478,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemory) {
|
||||
MinidumpMemoryList* memory_list = minidump.GetMemoryList();
|
||||
ASSERT_TRUE(exception);
|
||||
ASSERT_TRUE(memory_list);
|
||||
ASSERT_LT(0, memory_list->region_count());
|
||||
ASSERT_LT(0U, memory_list->region_count());
|
||||
|
||||
MinidumpContext* context = exception->GetContext();
|
||||
ASSERT_TRUE(context);
|
||||
@@ -557,7 +557,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_path.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
// Read the minidump. Locate the exception record and the
|
||||
// memory list, and then ensure that there is a memory region
|
||||
@@ -570,7 +570,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMinBound) {
|
||||
MinidumpMemoryList* memory_list = minidump.GetMemoryList();
|
||||
ASSERT_TRUE(exception);
|
||||
ASSERT_TRUE(memory_list);
|
||||
ASSERT_LT(0, memory_list->region_count());
|
||||
ASSERT_LT(0U, memory_list->region_count());
|
||||
|
||||
MinidumpContext* context = exception->GetContext();
|
||||
ASSERT_TRUE(context);
|
||||
@@ -648,7 +648,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMaxBound) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_path.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
// Read the minidump. Locate the exception record and the memory list, and
|
||||
// then ensure that there is a memory region in the memory list that covers
|
||||
@@ -660,7 +660,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryMaxBound) {
|
||||
MinidumpMemoryList* memory_list = minidump.GetMemoryList();
|
||||
ASSERT_TRUE(exception);
|
||||
ASSERT_TRUE(memory_list);
|
||||
ASSERT_LT(0, memory_list->region_count());
|
||||
ASSERT_LT(0U, memory_list->region_count());
|
||||
|
||||
MinidumpContext* context = exception->GetContext();
|
||||
ASSERT_TRUE(context);
|
||||
@@ -719,7 +719,7 @@ TEST(ExceptionHandlerTest, InstructionPointerMemoryNullPointer) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_path.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
// Read the minidump. Locate the exception record and the
|
||||
// memory list, and then ensure that there is a memory region
|
||||
@@ -887,7 +887,7 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
|
||||
msg.msg_controllen = kControlMsgSize;
|
||||
|
||||
const ssize_t n = HANDLE_EINTR(recvmsg(fds[0], &msg, 0));
|
||||
ASSERT_EQ(kCrashContextSize, n);
|
||||
ASSERT_EQ(static_cast<ssize_t>(kCrashContextSize), n);
|
||||
ASSERT_EQ(kControlMsgSize, msg.msg_controllen);
|
||||
ASSERT_EQ(0, msg.msg_flags);
|
||||
ASSERT_EQ(0, close(fds[0]));
|
||||
@@ -918,14 +918,14 @@ TEST(ExceptionHandlerTest, ExternalDumper) {
|
||||
ASSERT_TRUE(WriteMinidump(templ.c_str(), crashing_pid, context,
|
||||
kCrashContextSize));
|
||||
static const char b = 0;
|
||||
ASSERT_EQ(1U, (HANDLE_EINTR(write(signal_fd, &b, 1))));
|
||||
ASSERT_EQ(1, (HANDLE_EINTR(write(signal_fd, &b, 1))));
|
||||
ASSERT_EQ(0, close(signal_fd));
|
||||
|
||||
ASSERT_NO_FATAL_FAILURE(WaitForProcessToTerminate(child, SIGSEGV));
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(templ.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0U);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
unlink(templ.c_str());
|
||||
}
|
||||
|
||||
@@ -974,7 +974,7 @@ TEST(ExceptionHandlerTest, GenerateMultipleDumpsWithPath) {
|
||||
const MinidumpDescriptor& minidump_1 = handler.minidump_descriptor();
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(minidump_1.path(), &st));
|
||||
ASSERT_GT(st.st_size, 0U);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
string minidump_1_path(minidump_1.path());
|
||||
// Check it is a valid minidump.
|
||||
Minidump minidump1(minidump_1_path);
|
||||
@@ -985,7 +985,7 @@ TEST(ExceptionHandlerTest, GenerateMultipleDumpsWithPath) {
|
||||
ASSERT_TRUE(handler.WriteMinidump());
|
||||
const MinidumpDescriptor& minidump_2 = handler.minidump_descriptor();
|
||||
ASSERT_EQ(0, stat(minidump_2.path(), &st));
|
||||
ASSERT_GT(st.st_size, 0U);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
string minidump_2_path(minidump_2.path());
|
||||
// Check it is a valid minidump.
|
||||
Minidump minidump2(minidump_2_path);
|
||||
@@ -1111,7 +1111,7 @@ TEST(ExceptionHandlerTest, WriteMinidumpForChild) {
|
||||
ASSERT_TRUE(exception);
|
||||
u_int32_t thread_id;
|
||||
ASSERT_TRUE(exception->GetThreadID(&thread_id));
|
||||
EXPECT_EQ(child, thread_id);
|
||||
EXPECT_EQ(child, static_cast<int32_t>(thread_id));
|
||||
|
||||
const MDRawExceptionStream* raw = exception->exception();
|
||||
ASSERT_TRUE(raw);
|
||||
|
||||
@@ -166,7 +166,7 @@ TEST(LineReaderTest, MaxLength) {
|
||||
char l[LineReader::kMaxLineLen - 1];
|
||||
memset(l, 'a', sizeof(l));
|
||||
const int r = HANDLE_EINTR(write(fd, l, sizeof(l)));
|
||||
ASSERT_EQ(sizeof(l), r);
|
||||
ASSERT_EQ(static_cast<ssize_t>(sizeof(l)), r);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
LineReader reader(fd);
|
||||
|
||||
@@ -185,7 +185,7 @@ TEST(LineReaderTest, TooLong) {
|
||||
char l[LineReader::kMaxLineLen];
|
||||
memset(l, 'a', sizeof(l));
|
||||
const int r = HANDLE_EINTR(write(fd, l, sizeof(l)));
|
||||
ASSERT_EQ(sizeof(l), r);
|
||||
ASSERT_EQ(static_cast<ssize_t>(sizeof(l)), r);
|
||||
lseek(fd, 0, SEEK_SET);
|
||||
LineReader reader(fd);
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ TEST(LinuxCoreDumperTest, VerifyDumpWithMultipleThreads) {
|
||||
|
||||
// LinuxCoreDumper cannot determine the crash address and thus it always
|
||||
// sets the crash address to 0.
|
||||
EXPECT_EQ(0, dumper.crash_address());
|
||||
EXPECT_EQ(0U, dumper.crash_address());
|
||||
EXPECT_EQ(kCrashSignal, dumper.crash_signal());
|
||||
EXPECT_EQ(crash_generator.GetThreadId(kCrashThread),
|
||||
dumper.crash_thread());
|
||||
|
||||
@@ -160,7 +160,7 @@ TEST(LinuxPtraceDumperTest, MergedMappings) {
|
||||
// range.
|
||||
EXPECT_EQ(kMappingAddress, mapping.start_addr);
|
||||
EXPECT_EQ(kMappingSize, mapping.size);
|
||||
EXPECT_EQ(0, mapping.offset);
|
||||
EXPECT_EQ(0U, mapping.offset);
|
||||
mapping_count++;
|
||||
}
|
||||
}
|
||||
@@ -212,7 +212,8 @@ TEST(LinuxPtraceDumperTest, VerifyStackReadWithMultipleThreads) {
|
||||
ASSERT_EQ(1, r);
|
||||
ASSERT_TRUE(pfd.revents & POLLIN);
|
||||
uint8_t junk;
|
||||
ASSERT_EQ(read(fds[0], &junk, sizeof(junk)), sizeof(junk));
|
||||
ASSERT_EQ(read(fds[0], &junk, sizeof(junk)),
|
||||
static_cast<ssize_t>(sizeof(junk)));
|
||||
}
|
||||
close(fds[0]);
|
||||
|
||||
|
||||
@@ -653,8 +653,10 @@ class MinidumpWriter {
|
||||
size_t stack_len;
|
||||
if (dumper_->GetStackInfo(&stack, &stack_len, stack_pointer)) {
|
||||
UntypedMDRVA memory(&minidump_writer_);
|
||||
if (max_stack_len >= 0 && stack_len > max_stack_len)
|
||||
if (max_stack_len >= 0 &&
|
||||
stack_len > static_cast<unsigned int>(max_stack_len)) {
|
||||
stack_len = max_stack_len;
|
||||
}
|
||||
if (!memory.Allocate(stack_len))
|
||||
return false;
|
||||
*stack_copy = reinterpret_cast<uint8_t*>(Alloc(stack_len));
|
||||
|
||||
@@ -88,7 +88,7 @@ TEST(MinidumpWriterTest, SetupWithPath) {
|
||||
ASSERT_TRUE(WriteMinidump(templ.c_str(), child, &context, sizeof(context)));
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(templ.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
close(fds[1]);
|
||||
}
|
||||
@@ -118,7 +118,7 @@ TEST(MinidumpWriterTest, SetupWithFD) {
|
||||
ASSERT_TRUE(WriteMinidump(fd, child, &context, sizeof(context)));
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(templ.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
close(fds[1]);
|
||||
}
|
||||
@@ -239,7 +239,7 @@ TEST(MinidumpWriterTest, MappingInfoContained) {
|
||||
|
||||
// These are defined here so the parent can use them to check the
|
||||
// data from the minidump afterwards.
|
||||
const u_int32_t memory_size = sysconf(_SC_PAGESIZE);
|
||||
const int32_t memory_size = sysconf(_SC_PAGESIZE);
|
||||
const char* kMemoryName = "a fake module";
|
||||
const u_int8_t kModuleGUID[sizeof(MDGUID)] = {
|
||||
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
|
||||
@@ -379,7 +379,7 @@ TEST(MinidumpWriterTest, DeletedBinary) {
|
||||
ASSERT_TRUE(pfd.revents & POLLIN);
|
||||
uint8_t junk;
|
||||
const int nr = HANDLE_EINTR(read(fds[0], &junk, sizeof(junk)));
|
||||
ASSERT_EQ(sizeof(junk), nr);
|
||||
ASSERT_EQ(static_cast<ssize_t>(sizeof(junk)), nr);
|
||||
close(fds[0]);
|
||||
|
||||
// Child is ready now.
|
||||
@@ -398,7 +398,7 @@ TEST(MinidumpWriterTest, DeletedBinary) {
|
||||
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(templ.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
|
||||
Minidump minidump(templ.c_str());
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
@@ -623,7 +623,8 @@ TEST(MinidumpWriterTest, MinidumpSizeLimit) {
|
||||
ASSERT_EQ(1, r);
|
||||
ASSERT_TRUE(pfd.revents & POLLIN);
|
||||
uint8_t junk;
|
||||
ASSERT_EQ(read(fds[0], &junk, sizeof(junk)), sizeof(junk));
|
||||
ASSERT_EQ(read(fds[0], &junk, sizeof(junk)),
|
||||
static_cast<ssize_t>(sizeof(junk)));
|
||||
}
|
||||
close(fds[0]);
|
||||
|
||||
@@ -648,14 +649,14 @@ TEST(MinidumpWriterTest, MinidumpSizeLimit) {
|
||||
MappingList(), AppMemoryList()));
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(normal_dump.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
normal_file_size = st.st_size;
|
||||
|
||||
Minidump minidump(normal_dump.c_str());
|
||||
ASSERT_TRUE(minidump.Read());
|
||||
MinidumpThreadList* dump_thread_list = minidump.GetThreadList();
|
||||
ASSERT_TRUE(dump_thread_list);
|
||||
for (int i = 0; i < dump_thread_list->thread_count(); i++) {
|
||||
for (unsigned int i = 0; i < dump_thread_list->thread_count(); i++) {
|
||||
MinidumpThread* thread = dump_thread_list->GetThreadAtIndex(i);
|
||||
ASSERT_TRUE(thread->thread() != NULL);
|
||||
// When the stack size is zero bytes, GetMemory() returns NULL.
|
||||
@@ -699,7 +700,7 @@ TEST(MinidumpWriterTest, MinidumpSizeLimit) {
|
||||
MappingList(), AppMemoryList()));
|
||||
struct stat st;
|
||||
ASSERT_EQ(0, stat(limit_dump.c_str(), &st));
|
||||
ASSERT_GT(st.st_size, 0u);
|
||||
ASSERT_GT(st.st_size, 0);
|
||||
// Make sure the file size is at least smaller than the original.
|
||||
EXPECT_LT(st.st_size, normal_file_size);
|
||||
|
||||
@@ -708,7 +709,7 @@ TEST(MinidumpWriterTest, MinidumpSizeLimit) {
|
||||
MinidumpThreadList* dump_thread_list = minidump.GetThreadList();
|
||||
ASSERT_TRUE(dump_thread_list);
|
||||
int total_limit_stack_size = 0;
|
||||
for (int i = 0; i < dump_thread_list->thread_count(); i++) {
|
||||
for (unsigned int i = 0; i < dump_thread_list->thread_count(); i++) {
|
||||
MinidumpThread* thread = dump_thread_list->GetThreadAtIndex(i);
|
||||
ASSERT_TRUE(thread->thread() != NULL);
|
||||
// When the stack size is zero bytes, GetMemory() returns NULL.
|
||||
|
||||
Reference in New Issue
Block a user