From 9c815db36681ac01ea7422725a0ac2e183e39b16 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 17 Apr 2024 19:55:40 -0400 Subject: [PATCH] `file-descriptor.hh`: Avoid some Cism for better C++isms - `reinterpret_cast` not C-style cast - `using` not `typedef` --- src/libutil/file-descriptor.hh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libutil/file-descriptor.hh b/src/libutil/file-descriptor.hh index 50201d846..84786e95a 100644 --- a/src/libutil/file-descriptor.hh +++ b/src/libutil/file-descriptor.hh @@ -17,13 +17,13 @@ struct Source; /** * Operating System capability */ -typedef +using Descriptor = #if _WIN32 HANDLE #else int #endif - Descriptor; + ; const Descriptor INVALID_DESCRIPTOR = #if _WIN32 @@ -41,7 +41,7 @@ const Descriptor INVALID_DESCRIPTOR = static inline Descriptor toDescriptor(int fd) { #ifdef _WIN32 - return (HANDLE) _get_osfhandle(fd); + return reinterpret_cast(_get_osfhandle(fd)); #else return fd; #endif @@ -56,7 +56,7 @@ static inline Descriptor toDescriptor(int fd) static inline int fromDescriptorReadOnly(Descriptor fd) { #ifdef _WIN32 - return _open_osfhandle((intptr_t) fd, _O_RDONLY); + return _open_osfhandle(reinterpret_cast(fd), _O_RDONLY); #else return fd; #endif