Skip to content

Commit

Permalink
fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Jan 18, 2024
1 parent 1b83ec5 commit 70cdcd0
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/tateyama/datastore/backup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,26 @@ namespace tateyama::datastore {
static bool prompt(std::string_view msg)
{
struct termios oldt{};
int oldf;

memset(&oldt, 0x00, sizeof(struct termios));
if (tcgetattr(STDIN_FILENO, &oldt) == -1) {
throw std::runtime_error("error tcgetattr");
}

auto newt = oldt;
newt.c_iflag = ~( BRKINT | ISTRIP | IXON );
newt.c_lflag = ~( ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHONL );
newt.c_iflag = ~( BRKINT | ISTRIP | IXON ); // NOLINT
newt.c_lflag = ~( ICANON | IEXTEN | ECHO | ECHOE | ECHOK | ECHONL ); // NOLINT
newt.c_cc[VTIME] = 0;
newt.c_cc[VMIN] = 1;

if (tcsetattr(STDIN_FILENO, TCSANOW, &newt) == -1) {
throw std::runtime_error("error tcsetattr");
}
oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
if (oldf<0) {
int oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
if (oldf < 0) {
throw std::runtime_error("error fcntl");
}
if (fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK) < 0) {
if (fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK) < 0) { // NOLINT
throw std::runtime_error("error fcntl");
}

Expand All @@ -89,7 +88,7 @@ static bool prompt(std::string_view msg)
if (tcsetattr(STDIN_FILENO, TCSANOW, &oldt) == -1) {
throw std::runtime_error("error tcsetattr");
}
if (fcntl(STDIN_FILENO, F_SETFL, oldf) < 0) {
if (fcntl(STDIN_FILENO, F_SETFL, oldf) < 0) { // NOLINT
throw std::runtime_error("error fcntl");
}
return rtnv;
Expand Down

0 comments on commit 70cdcd0

Please sign in to comment.