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 <[email protected]>

---
 include/windows/unistd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/windows/unistd.h b/include/windows/unistd.h
index 21cc56ff1..62ff90a3f 100644
--- a/include/windows/unistd.h
+++ b/include/windows/unistd.h
@@ -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
-- 
2.25.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to