From 9eae2b8ea95d39f23fae75be6491e85ff7c6fc3a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Wed, 27 Apr 2022 23:44:16 +0800 Subject: [PATCH] Use correct type for comparisons `_write()` actually returns `int` type. And fix wrong function parameters. Closes #16938. Closes #16944. --- src/app/main.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index df6c4ee5f..2e7013d91 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #if defined(Q_OS_UNIX) #include @@ -321,17 +322,13 @@ int main(int argc, char *argv[]) void reportToUser(const char *str) { const size_t strLen = strlen(str); -#ifndef Q_OS_WIN - if (write(STDERR_FILENO, str, strLen) < static_cast(strLen)) - { - const auto dummy = write(STDOUT_FILENO, str, strLen); +#ifdef Q_OS_WIN + if (_write(_fileno(stderr), str, strLen) < static_cast(strLen)) + std::ignore = _write(_fileno(stdout), str, strLen); #else - if (_write(STDERR_FILENO, str, strLen) < static_cast(strLen)) - { - const auto dummy = _write(STDOUT_FILENO, str, strLen); + if (write(STDERR_FILENO, str, strLen) < static_cast(strLen)) + std::ignore = write(STDOUT_FILENO, str, strLen); #endif - Q_UNUSED(dummy); - } } #endif