Skip to content

Commit

Permalink
try to fix ::ioctl(Private::in.fd(), FIONREAD, &nread)
Browse files Browse the repository at this point in the history
  • Loading branch information
flagarde committed Nov 3, 2024
1 parent 08fb483 commit e0aa3c7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions cpp-terminal/private/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cpp-terminal/private/file.hpp"

#include "cpp-terminal/private/exception.hpp"
#include "cpp-terminal/tty.hpp"

#include <cstdio>
#include <new>

Check warning on line 16 in cpp-terminal/private/file.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter

cpp-terminal/private/file.cpp:16:1 [misc-include-cleaner]

included header new is not used directly
Expand Down Expand Up @@ -143,14 +144,7 @@ std::string Term::Private::InputFileHandler::read() const
static const constexpr std::size_t posix_max_input{256};
#endif
static std::size_t nread{std::max(max_input, posix_max_input)};
try
{
Term::Private::Errno().check_if(::ioctl(Private::in.fd(), FIONREAD, &nread) != 0).throw_exception("::ioctl(Private::in.fd(), FIONREAD, &nread)"); //NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
}
catch(const ErrnoException& exception)
{
if(exception.code() != 25 && exception.code() != 0 && exception.code() != 19) throw;
}
if(is_stdin_a_tty()) Term::Private::Errno().check_if(::ioctl(Private::in.fd(), FIONREAD, &nread) != 0).throw_exception("::ioctl(Private::in.fd(), FIONREAD, &nread)"); //NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
std::string ret(nread, '\0');
if(nread != 0)
{
Expand Down

0 comments on commit e0aa3c7

Please sign in to comment.