[PATCH] tests: fix warning in tst-epoll.cc

5 views
Skip to first unread message

Nadav Har'El

unread,
Jun 15, 2021, 5:52:22 PM6/15/21
to osv...@googlegroups.com, Nadav Har'El
tst-poll.cc has a function write_one() which writes one byte. We didn't
care which byte we were writing, so we didn't bother to initialize the
variable holding this byte. But gcc 11 warns about this.

The solution is to initialize this byte to something - e.g., 0.

Signed-off-by: Nadav Har'El <n...@scylladb.com>
---
tests/tst-epoll.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/tst-epoll.cc b/tests/tst-epoll.cc
index 82658964..30322240 100644
--- a/tests/tst-epoll.cc
+++ b/tests/tst-epoll.cc
@@ -32,7 +32,7 @@ static void report(bool ok, std::string msg)

static void write_one(int fd)
{
- char c;
+ char c = 0;
int w = write(fd, &c, 1);
report(w == 1, "write");
}
--
2.31.1

Commit Bot

unread,
Jun 16, 2021, 6:16:14 PM6/16/21
to osv...@googlegroups.com, Nadav Har'El
From: Nadav Har'El <n...@scylladb.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

tests: fix warning in tst-epoll.cc

tst-poll.cc has a function write_one() which writes one byte. We didn't
care which byte we were writing, so we didn't bother to initialize the
variable holding this byte. But gcc 11 warns about this.

The solution is to initialize this byte to something - e.g., 0.

Signed-off-by: Nadav Har'El <n...@scylladb.com>
Message-Id: <2021061521521...@scylladb.com>

---
diff --git a/tests/tst-epoll.cc b/tests/tst-epoll.cc
Reply all
Reply to author
Forward
0 new messages