Skip to content

Commit

Permalink
include/windows/unistd.h: Fixed type cast warning on Windows.
Browse files Browse the repository at this point in the history
Currently, the function call type cast for getting file handle
produces a warning during OvS compilation on Windows with the following
message:

 ..\include\windows\unistd.h:97:25: warning:
 cast from function call of type 'intptr_t' (aka 'int') to non-matching
 type 'HANDLE' (aka 'void *') [-Wbad-function-cast]
     HANDLE h = (HANDLE) _get_osfhandle(fd);

There is a function `LongToHandle()` to perform such cast [1].
But as `intptr_t` can be either `long long` for 64-bit or `int` for
32-bit, instead of clogging the code with `#ifdef` macros to use
different cast functions, we can perform this cast directly.

Signed-off-by: Sergey Madaminov <sergey.madaminov@gmail.com>
Acked-by: Michael Santana <msantana@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
smadaminov authored and igsilya committed Sep 15, 2021
1 parent e05e1e3 commit aae08a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/windows/unistd.h
Expand Up @@ -94,7 +94,7 @@ __inline long sysconf(int type)
static __inline int
rpl_isatty(int fd)
{
HANDLE h = (HANDLE) _get_osfhandle(fd);
HANDLE h = (HANDLE)(INT_PTR) _get_osfhandle(fd);
DWORD st;
return (_isatty(STDOUT_FILENO)
&& h != INVALID_HANDLE_VALUE
Expand Down

0 comments on commit aae08a5

Please sign in to comment.