]> granicus.if.org Git - curl/commit
tool_cb_wrt: Silence function cast compiler warning
authorDaniel Gustafsson <daniel@yesql.se>
Mon, 12 Nov 2018 19:54:07 +0000 (20:54 +0100)
committerDaniel Gustafsson <daniel@yesql.se>
Tue, 13 Nov 2018 12:51:46 +0000 (13:51 +0100)
commit2f5f31bb57d68b54e03bffcd9648aece1fe564f8
treeb4b64441c1d679d6c3ab1273f39e70bc3815de2a
parent42fd235040095e77f7bef26ec7506ad0b3cd8039
tool_cb_wrt: Silence function cast compiler warning

Commit 5bfaa86ceb3c2a9ac474a928e748c4a86a703b33 introduced a new
compiler warning on Windows cross compilation with GCC. See below
for an example of the warning from the autobuild logs (whitespace
edited to fit):

/src/tool_cb_wrt.c:175:9: warning: cast from function call of type
    'intptr_t {aka long long int}' to non-matching type 'void *'
    [-Wbad-function-cast]
(HANDLE) _get_osfhandle(fileno(outs->stream)),
^

Store the return value from _get_osfhandle() in an intermediate
variable and cast the variable in WriteConsoleW() rather than the
function call directly to avoid a compiler warning.

In passing, also add inspection of the MultiByteToWideChar() return
value and return failure in case an error is reported.

Closes #3263
Reviewed-by: Marcel Raad <Marcel.Raad@teamviewer.com>
Reviewed-by: Viktor Szakats <commit@vszakats.net>
src/tool_cb_wrt.c