Skip to content

Commit

Permalink
warnings: fix unused result warnings
Browse files Browse the repository at this point in the history
Fix a few unused result warnings that have popped up in gcc.

In some cases this involves actually checking the return type, mostly
for write(event_fd,...) and in this case it seems that we never
expect any type of failure here (non-zero return code would only
be on eventfd wrap if fd is in blocking mode, invalid arguments).
  • Loading branch information
travisdowns committed Sep 21, 2024
1 parent 2756b9b commit 188baf1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/core/reactor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,8 @@ reactor::wakeup() {
_sleeping.store(false, std::memory_order_relaxed);

uint64_t one = 1;
::write(_notify_eventfd.get(), &one, sizeof(one));
auto res = ::write(_notify_eventfd.get(), &one, sizeof(one));
assert(res == sizeof(one) && "write(2) failed on _reactor._notify_eventfd");
}

void reactor::start_aio_eventfd_loop() {
Expand All @@ -2916,7 +2917,7 @@ void reactor::start_aio_eventfd_loop() {
future<> loop_done = repeat([this] {
return _aio_eventfd->readable().then([this] {
char garbage[8];
::read(_aio_eventfd->get_fd(), garbage, 8); // totally uninteresting
std::ignore = ::read(_aio_eventfd->get_fd(), garbage, 8); // totally uninteresting
return _stopping ? stop_iteration::yes : stop_iteration::no;
});
});
Expand All @@ -2931,7 +2932,8 @@ void reactor::stop_aio_eventfd_loop() {
return;
}
uint64_t one = 1;
::write(_aio_eventfd->get_fd(), &one, 8);
auto res = ::write(_aio_eventfd->get_fd(), &one, 8);
assert(res == 8 && "write(2) failed on _reactor._aio_eventfd");
}

inline
Expand Down
3 changes: 2 additions & 1 deletion src/core/thread_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ void thread_pool::work(sstring name) {
std::atomic_thread_fence(std::memory_order_seq_cst);
if (_main_thread_idle.load(std::memory_order_relaxed)) {
uint64_t one = 1;
::write(_reactor._notify_eventfd.get(), &one, 8);
auto res = ::write(_reactor._notify_eventfd.get(), &one, 8);
assert(res == 8 && "write(2) failed on _reactor._notify_eventfd");
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion tests/perf/linux_perf_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
* This file was copied from Scylla (https://github.com/scylladb/scylla)
*/

#include <cassert>

#include <seastar/testing/linux_perf_event.hh>

#include <linux/perf_event.h>
Expand Down Expand Up @@ -61,7 +63,8 @@ linux_perf_event::read() {
return 0;
}
uint64_t ret;
::read(_fd, &ret, sizeof(ret));
auto res = ::read(_fd, &ret, sizeof(ret));
assert(res == sizeof(ret) && "read(2) failed on perf_event fd");
return ret;
}

Expand Down
17 changes: 11 additions & 6 deletions tests/unit/unix_domain_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
/*
* Copyright (C) 2019 Red Hat, Inc.
*/
*/

#include <filesystem>

Expand Down Expand Up @@ -88,7 +88,7 @@ future<> ud_server_client::init_server() {
}
}
client_round();
}
}
});

return do_until([this](){return rounds_left<=0;}, [&lstn,this]() {
Expand Down Expand Up @@ -131,7 +131,7 @@ future<> ud_server_client::init_server() {
/// If 'client_path' is set, the client binds to the named path.
// Runs in a seastar::thread.
void ud_server_client::client_round() {
auto cc = client_path ?
auto cc = client_path ?
engine().net().connect(server_addr, socket_address{unix_domain_addr{*client_path}}).get() :
engine().net().connect(server_addr).get();

Expand All @@ -154,11 +154,16 @@ future<> ud_server_client::run() {

}

void rm(std::string_view what) {
auto res = system(fmt::format("rm -f {}", what).c_str());
BOOST_REQUIRE_EQUAL(res, 0);
}

// testing the various address types, both on the server and on the
// client side

SEASTAR_TEST_CASE(unixdomain_server) {
system("rm -f /tmp/ry");
rm("/tmp/ry");
ud_server_client uds("/tmp/ry", std::nullopt, 3);
return do_with(std::move(uds), [](auto& uds){
return uds.run();
Expand Down Expand Up @@ -205,15 +210,15 @@ SEASTAR_TEST_CASE(unixdomain_text) {
}

SEASTAR_TEST_CASE(unixdomain_bind) {
system("rm -f 111 112");
rm("111 112");
ud_server_client uds("111"s, "112"s, 1);
return do_with(std::move(uds), [](auto& uds){
return uds.run();
});
}

SEASTAR_TEST_CASE(unixdomain_short) {
system("rm -f 3");
rm("3");
ud_server_client uds("3"s, std::nullopt, 10);
return do_with(std::move(uds), [](auto& uds){
return uds.run();
Expand Down

0 comments on commit 188baf1

Please sign in to comment.