aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-04-25 11:22:09 +0000
committerted.mielczarek <ted.mielczarek@4c0a9323-5329-0410-9bdc-e9ce6186880e>2012-04-25 11:22:09 +0000
commit24c3c97633f691fdf2a3467f63aedde19bf8fec1 (patch)
treef4a1716bd787e6471e859f9349c9a6b2f267a8dc /src/client
parentReap child in VerifyStackReadWithMultipleThreads (diff)
downloadbreakpad-24c3c97633f691fdf2a3467f63aedde19bf8fec1.tar.xz
Fix compilation warnings related to unchecked return values
Patch by Chris Dearman <chris@mips.com> R=benchan at http://breakpad.appspot.com/377001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@957 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/client')
-rw-r--r--src/client/linux/handler/exception_handler_unittest.cc9
-rw-r--r--src/client/linux/minidump_writer/line_reader_unittest.cc59
-rw-r--r--src/client/linux/minidump_writer/minidump_writer_unittest.cc3
3 files changed, 43 insertions, 28 deletions
diff --git a/src/client/linux/handler/exception_handler_unittest.cc b/src/client/linux/handler/exception_handler_unittest.cc
index 84fc08ed..6fcf251b 100644
--- a/src/client/linux/handler/exception_handler_unittest.cc
+++ b/src/client/linux/handler/exception_handler_unittest.cc
@@ -669,7 +669,14 @@ CrashHandler(const void* crash_context, size_t crash_context_size,
void* context) {
const int fd = (intptr_t) context;
int fds[2];
- pipe(fds);
+ if (pipe(fds) == -1) {
+ // There doesn't seem to be any way to reliably handle
+ // this failure without the parent process hanging
+ // At least make sure that this process doesn't access
+ // unexpected file descriptors
+ fds[0] = -1;
+ fds[1] = -1;
+ }
struct kernel_msghdr msg = {0};
struct kernel_iovec iov;
iov.iov_base = const_cast<void*>(crash_context);
diff --git a/src/client/linux/minidump_writer/line_reader_unittest.cc b/src/client/linux/minidump_writer/line_reader_unittest.cc
index a2ea17f7..17a54679 100644
--- a/src/client/linux/minidump_writer/line_reader_unittest.cc
+++ b/src/client/linux/minidump_writer/line_reader_unittest.cc
@@ -33,6 +33,7 @@
#include "client/linux/minidump_writer/line_reader.h"
#include "breakpad_googletest_includes.h"
+#include "common/linux/eintr_wrapper.h"
using namespace google_breakpad;
@@ -70,16 +71,17 @@ TEST(LineReaderTest, EmptyFile) {
TEST(LineReaderTest, OneLineTerminated) {
const int fd = TemporaryFile();
- write(fd, "a\n", 2);
+ const int r = HANDLE_EINTR(write(fd, "a\n", 2));
+ ASSERT_EQ(2, r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
const char *line;
unsigned int len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned int)1);
- ASSERT_EQ(line[0], 'a');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned int)1, len);
+ ASSERT_EQ('a', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_FALSE(reader.GetNextLine(&line, &len));
@@ -89,16 +91,17 @@ TEST(LineReaderTest, OneLineTerminated) {
TEST(LineReaderTest, OneLine) {
const int fd = TemporaryFile();
- write(fd, "a", 1);
+ const int r = HANDLE_EINTR(write(fd, "a", 1));
+ ASSERT_EQ(1, r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
const char *line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned)1);
- ASSERT_EQ(line[0], 'a');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned)1, len);
+ ASSERT_EQ('a', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_FALSE(reader.GetNextLine(&line, &len));
@@ -108,22 +111,23 @@ TEST(LineReaderTest, OneLine) {
TEST(LineReaderTest, TwoLinesTerminated) {
const int fd = TemporaryFile();
- write(fd, "a\nb\n", 4);
+ const int r = HANDLE_EINTR(write(fd, "a\nb\n", 4));
+ ASSERT_EQ(4, r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
const char *line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned)1);
- ASSERT_EQ(line[0], 'a');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned)1, len);
+ ASSERT_EQ('a', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned)1);
- ASSERT_EQ(line[0], 'b');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned)1, len);
+ ASSERT_EQ('b', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_FALSE(reader.GetNextLine(&line, &len));
@@ -133,22 +137,23 @@ TEST(LineReaderTest, TwoLinesTerminated) {
TEST(LineReaderTest, TwoLines) {
const int fd = TemporaryFile();
- write(fd, "a\nb", 3);
+ const int r = HANDLE_EINTR(write(fd, "a\nb", 3));
+ ASSERT_EQ(3, r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
const char *line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned)1);
- ASSERT_EQ(line[0], 'a');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned)1, len);
+ ASSERT_EQ('a', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, (unsigned)1);
- ASSERT_EQ(line[0], 'b');
- ASSERT_EQ(line[1], 0);
+ ASSERT_EQ((unsigned)1, len);
+ ASSERT_EQ('b', line[0]);
+ ASSERT_EQ('\0', line[1]);
reader.PopLine(len);
ASSERT_FALSE(reader.GetNextLine(&line, &len));
@@ -160,16 +165,17 @@ TEST(LineReaderTest, MaxLength) {
const int fd = TemporaryFile();
char l[LineReader::kMaxLineLen - 1];
memset(l, 'a', sizeof(l));
- write(fd, l, sizeof(l));
+ const int r = HANDLE_EINTR(write(fd, l, sizeof(l)));
+ ASSERT_EQ(sizeof(l), r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
const char *line;
unsigned len;
ASSERT_TRUE(reader.GetNextLine(&line, &len));
- ASSERT_EQ(len, sizeof(l));
+ ASSERT_EQ(sizeof(l), len);
ASSERT_TRUE(memcmp(l, line, sizeof(l)) == 0);
- ASSERT_EQ(line[len], 0);
+ ASSERT_EQ('\0', line[len]);
close(fd);
}
@@ -178,7 +184,8 @@ TEST(LineReaderTest, TooLong) {
const int fd = TemporaryFile();
char l[LineReader::kMaxLineLen];
memset(l, 'a', sizeof(l));
- write(fd, l, sizeof(l));
+ const int r = HANDLE_EINTR(write(fd, l, sizeof(l)));
+ ASSERT_EQ(sizeof(l), r);
lseek(fd, 0, SEEK_SET);
LineReader reader(fd);
diff --git a/src/client/linux/minidump_writer/minidump_writer_unittest.cc b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
index ef1e7a54..91aafed7 100644
--- a/src/client/linux/minidump_writer/minidump_writer_unittest.cc
+++ b/src/client/linux/minidump_writer/minidump_writer_unittest.cc
@@ -338,7 +338,8 @@ TEST(MinidumpWriterTest, DeletedBinary) {
ASSERT_EQ(1, r);
ASSERT_TRUE(pfd.revents & POLLIN);
uint8_t junk;
- read(fds[0], &junk, sizeof(junk));
+ const int nr = HANDLE_EINTR(read(fds[0], &junk, sizeof(junk)));
+ ASSERT_EQ(sizeof(junk), nr);
close(fds[0]);
// Child is ready now.