Use correct type for comparisons

`_write()` actually returns `int` type.

And fix wrong function parameters.

Closes #16938.
Closes #16944.
This commit is contained in:
Chocobo1 2022-04-27 23:44:16 +08:00
parent 9351f66c26
commit 59e37210f3
No known key found for this signature in database
GPG key ID: 210D9C873253A68C

View file

@ -32,6 +32,7 @@
#include <csignal> #include <csignal>
#include <cstdlib> #include <cstdlib>
#include <memory> #include <memory>
#include <tuple>
#if defined(Q_OS_UNIX) #if defined(Q_OS_UNIX)
#include <sys/resource.h> #include <sys/resource.h>
@ -318,17 +319,13 @@ int main(int argc, char *argv[])
void reportToUser(const char *str) void reportToUser(const char *str)
{ {
const size_t strLen = strlen(str); const size_t strLen = strlen(str);
#ifndef Q_OS_WIN #ifdef Q_OS_WIN
if (write(STDERR_FILENO, str, strLen) < static_cast<ssize_t>(strLen)) if (_write(_fileno(stderr), str, strLen) < static_cast<int>(strLen))
{ std::ignore = _write(_fileno(stdout), str, strLen);
const auto dummy = write(STDOUT_FILENO, str, strLen);
#else #else
if (_write(STDERR_FILENO, str, strLen) < static_cast<ssize_t>(strLen)) if (write(STDERR_FILENO, str, strLen) < static_cast<ssize_t>(strLen))
{ std::ignore = write(STDOUT_FILENO, str, strLen);
const auto dummy = _write(STDOUT_FILENO, str, strLen);
#endif #endif
Q_UNUSED(dummy);
}
} }
#endif #endif