libcamera: Don't ignore the return value of read() and write()
The glibc read() and write() functions are defined with the __warn_unused_result__ attribute when using FORTIFY_SOURCE. Don't ignore their return value. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
5caa8a971d
commit
b771196d91
2 changed files with 26 additions and 4 deletions
|
@ -162,7 +162,14 @@ void EventDispatcherPoll::processEvents()
|
||||||
void EventDispatcherPoll::interrupt()
|
void EventDispatcherPoll::interrupt()
|
||||||
{
|
{
|
||||||
uint64_t value = 1;
|
uint64_t value = 1;
|
||||||
write(eventfd_, &value, sizeof(value));
|
ssize_t ret = write(eventfd_, &value, sizeof(value));
|
||||||
|
if (ret != sizeof(value)) {
|
||||||
|
if (ret < 0)
|
||||||
|
ret = -errno;
|
||||||
|
LOG(Event, Error)
|
||||||
|
<< "Failed to interrupt event dispatcher ("
|
||||||
|
<< ret << ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
short EventDispatcherPoll::EventNotifierSetPoll::events() const
|
short EventDispatcherPoll::EventNotifierSetPoll::events() const
|
||||||
|
@ -214,7 +221,13 @@ void EventDispatcherPoll::processInterrupt(const struct pollfd &pfd)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
read(eventfd_, &value, sizeof(value));
|
ssize_t ret = read(eventfd_, &value, sizeof(value));
|
||||||
|
if (ret != sizeof(value)) {
|
||||||
|
if (ret < 0)
|
||||||
|
ret = -errno;
|
||||||
|
LOG(Event, Error)
|
||||||
|
<< "Failed to process interrupt (" << ret << ")";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pollfds)
|
void EventDispatcherPoll::processNotifiers(const std::vector<struct pollfd> &pollfds)
|
||||||
|
|
|
@ -38,6 +38,7 @@ protected:
|
||||||
EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
|
EventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();
|
||||||
std::string data("H2G2");
|
std::string data("H2G2");
|
||||||
Timer timeout;
|
Timer timeout;
|
||||||
|
ssize_t ret;
|
||||||
|
|
||||||
EventNotifier readNotifier(pipefd_[0], EventNotifier::Read);
|
EventNotifier readNotifier(pipefd_[0], EventNotifier::Read);
|
||||||
readNotifier.activated.connect(this, &EventTest::readReady);
|
readNotifier.activated.connect(this, &EventTest::readReady);
|
||||||
|
@ -46,7 +47,11 @@ protected:
|
||||||
memset(data_, 0, sizeof(data_));
|
memset(data_, 0, sizeof(data_));
|
||||||
size_ = 0;
|
size_ = 0;
|
||||||
|
|
||||||
write(pipefd_[1], data.data(), data.size());
|
ret = write(pipefd_[1], data.data(), data.size());
|
||||||
|
if (ret < 0) {
|
||||||
|
cout << "Pipe write failed" << endl;
|
||||||
|
return TestFail;
|
||||||
|
}
|
||||||
|
|
||||||
timeout.start(100);
|
timeout.start(100);
|
||||||
dispatcher->processEvents();
|
dispatcher->processEvents();
|
||||||
|
@ -73,7 +78,11 @@ protected:
|
||||||
notified_ = false;
|
notified_ = false;
|
||||||
readNotifier.setEnabled(false);
|
readNotifier.setEnabled(false);
|
||||||
|
|
||||||
write(pipefd_[1], data.data(), data.size());
|
ret = write(pipefd_[1], data.data(), data.size());
|
||||||
|
if (ret < 0) {
|
||||||
|
cout << "Pipe write failed" << endl;
|
||||||
|
return TestFail;
|
||||||
|
}
|
||||||
|
|
||||||
timeout.start(100);
|
timeout.start(100);
|
||||||
dispatcher->processEvents();
|
dispatcher->processEvents();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue