gfe-relnote: n/a(test only) Address warn_unused_result for read() and write in
epoll_server_test.cc
PiperOrigin-RevId: 244667377
Change-Id: Idbab9c6045d57ca5fb7285bfc71550c469d919a7
diff --git a/epoll_server/simple_epoll_server_test.cc b/epoll_server/simple_epoll_server_test.cc
index f5511d0..dbc3292 100644
--- a/epoll_server/simple_epoll_server_test.cc
+++ b/epoll_server/simple_epoll_server_test.cc
@@ -164,7 +164,10 @@
if (event->in_events & EPOLLIN) {
const int kLength = 1024;
char buf[kLength];
- read(fd, &buf, kLength);
+ int data_read;
+ do {
+ data_read = read(fd, &buf, kLength);
+ } while (data_read > 0);
}
}
@@ -1004,7 +1007,7 @@
alarm.Reset();
// Make sure the alarm is called one final time.
- EXPECT_EQ(1, ep.GetNumPendingAlarmsForTest());
+ EXPECT_EQ(1u, ep.GetNumPendingAlarmsForTest());
ep.set_timeout_in_us(alarm_time * 1000 * 2);
WaitForAlarm(&ep, alarm);
@@ -1481,18 +1484,18 @@
EXPECT_EQ(2u, records_one->size());
EXPECT_EQ(2u, records_two->size());
- write(pipe_one[1], &data, 1);
+ EXPECT_EQ(1, write(pipe_one[1], &data, 1));
ep.WaitForEventsAndExecuteCallbacks();
EXPECT_EQ(3u, records_one->size());
EXPECT_EQ(2u, records_two->size());
- write(pipe_two[1], &data, 1);
+ EXPECT_EQ(1, write(pipe_two[1], &data, 1));
ep.WaitForEventsAndExecuteCallbacks();
EXPECT_EQ(3u, records_one->size());
EXPECT_EQ(3u, records_two->size());
- write(pipe_one[1], &data, 1);
- write(pipe_two[1], &data, 1);
+ EXPECT_EQ(1, write(pipe_one[1], &data, 1));
+ EXPECT_EQ(1, write(pipe_two[1], &data, 1));
ep.WaitForEventsAndExecuteCallbacks();
EXPECT_EQ(4u, records_one->size());
EXPECT_EQ(4u, records_two->size());