From 54c57918ae267c32f4a46e38081485213d33f395 Mon Sep 17 00:00:00 2001 From: Acretock Date: Wed, 24 Nov 2021 14:57:05 +0500 Subject: [PATCH 1/5] fix int -> uint warning --- src/os.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os.cc b/src/os.cc index 4d0d0a71db97..25f72669278d 100644 --- a/src/os.cc +++ b/src/os.cc @@ -218,7 +218,7 @@ int buffered_file::fileno() const { #if FMT_USE_FCNTL file::file(cstring_view path, int oflag) { - int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + unsigned int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; # if defined(_WIN32) && !defined(__MINGW32__) fd_ = -1; FMT_POSIX_CALL(sopen_s(&fd_, path.c_str(), oflag, _SH_DENYNO, mode)); From b5f0ec49deaa5dd52244755f609b2e865ac487fc Mon Sep 17 00:00:00 2001 From: Acretock Date: Mon, 29 Nov 2021 17:30:05 +0500 Subject: [PATCH 2/5] change unsigned int to mode_t --- src/os.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/os.cc b/src/os.cc index 25f72669278d..4e711941baf8 100644 --- a/src/os.cc +++ b/src/os.cc @@ -20,6 +20,9 @@ # ifndef _WIN32 # include +# ifndef mode_t +# define mode_t unsigned int +# endif # else # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN @@ -41,6 +44,9 @@ # ifndef S_IROTH # define S_IROTH 0 # endif +# ifndef mode_t +# define mode_t int +# endif # ifdef __MINGW32__ # define _SH_DENYNO 0x40 @@ -218,7 +224,7 @@ int buffered_file::fileno() const { #if FMT_USE_FCNTL file::file(cstring_view path, int oflag) { - unsigned int mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; # if defined(_WIN32) && !defined(__MINGW32__) fd_ = -1; FMT_POSIX_CALL(sopen_s(&fd_, path.c_str(), oflag, _SH_DENYNO, mode)); From 302c6667dbabbe362cf941fd5e3960d451d5eca8 Mon Sep 17 00:00:00 2001 From: Acretock Date: Mon, 29 Nov 2021 17:52:26 +0500 Subject: [PATCH 3/5] undef + warn uint -> ushort loss presision --- src/os.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/os.cc b/src/os.cc index 4e711941baf8..8ea57a1cf9fd 100644 --- a/src/os.cc +++ b/src/os.cc @@ -21,7 +21,7 @@ # ifndef _WIN32 # include # ifndef mode_t -# define mode_t unsigned int +# define mode_t unsigned short # endif # else # ifndef WIN32_LEAN_AND_MEAN @@ -367,5 +367,8 @@ long getpagesize() { FMT_API void ostream::grow(size_t) { if (this->size() == this->capacity()) flush(); } +# ifdef mode_t +# undef mode_t +# endif #endif // FMT_USE_FCNTL FMT_END_NAMESPACE From 787d499134306331abddf5d2f51bb5575d2efb4e Mon Sep 17 00:00:00 2001 From: Acretock Date: Mon, 29 Nov 2021 18:36:10 +0500 Subject: [PATCH 4/5] fix mode_t --- src/os.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/os.cc b/src/os.cc index 8ea57a1cf9fd..cdec7e4ab3fe 100644 --- a/src/os.cc +++ b/src/os.cc @@ -20,9 +20,6 @@ # ifndef _WIN32 # include -# ifndef mode_t -# define mode_t unsigned short -# endif # else # ifndef WIN32_LEAN_AND_MEAN # define WIN32_LEAN_AND_MEAN @@ -44,12 +41,12 @@ # ifndef S_IROTH # define S_IROTH 0 # endif -# ifndef mode_t -# define mode_t int -# endif + # ifdef __MINGW32__ # define _SH_DENYNO 0x40 +# else + using mode_t = int; # endif # endif // _WIN32 #endif // FMT_USE_FCNTL @@ -367,8 +364,5 @@ long getpagesize() { FMT_API void ostream::grow(size_t) { if (this->size() == this->capacity()) flush(); } -# ifdef mode_t -# undef mode_t -# endif #endif // FMT_USE_FCNTL FMT_END_NAMESPACE From d6be2226b2efec337b7c037e3038481ce9cdc7ea Mon Sep 17 00:00:00 2001 From: Acretock Date: Tue, 30 Nov 2021 19:01:38 +0500 Subject: [PATCH 5/5] mode_t in detail --- src/os.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/os.cc b/src/os.cc index cdec7e4ab3fe..c682625a8742 100644 --- a/src/os.cc +++ b/src/os.cc @@ -42,11 +42,8 @@ # define S_IROTH 0 # endif - # ifdef __MINGW32__ # define _SH_DENYNO 0x40 -# else - using mode_t = int; # endif # endif // _WIN32 #endif // FMT_USE_FCNTL @@ -110,6 +107,8 @@ int detail::utf16_to_utf8::convert(basic_string_view s) { namespace detail { +using mode_t = int; + class system_message { system_message(const system_message&) = delete; void operator=(const system_message&) = delete; @@ -221,6 +220,7 @@ int buffered_file::fileno() const { #if FMT_USE_FCNTL file::file(cstring_view path, int oflag) { + using namespace detail; mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; # if defined(_WIN32) && !defined(__MINGW32__) fd_ = -1;