From c883f178b8d57f9acd5208247c6521683346aca3 Mon Sep 17 00:00:00 2001 From: Rosen Penev <rosenp@gmail.com> Date: Fri, 25 Sep 2020 22:05:43 -0700 Subject: [PATCH 1/2] clang-tidy: use auto Found with modernize-use-auto Signed-off-by: Rosen Penev <rosenp@gmail.com> --- src/decoder/DecoderAPI.cxx | 4 ++-- src/io/FileDescriptor.cxx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/decoder/DecoderAPI.cxx b/src/decoder/DecoderAPI.cxx index 2087f00ca..ce19418b6 100644 --- a/src/decoder/DecoderAPI.cxx +++ b/src/decoder/DecoderAPI.cxx @@ -46,7 +46,7 @@ size_t decoder_read_much(DecoderClient *client, InputStream &is, void *_buffer, size_t size) noexcept { - uint8_t *buffer = (uint8_t *)_buffer; + auto buffer = (uint8_t *)_buffer; size_t total = 0; @@ -67,7 +67,7 @@ bool decoder_read_full(DecoderClient *client, InputStream &is, void *_buffer, size_t size) noexcept { - auto *buffer = (uint8_t *)_buffer; + auto buffer = (uint8_t *)_buffer; while (size > 0) { size_t nbytes = decoder_read(client, is, buffer, size); diff --git a/src/io/FileDescriptor.cxx b/src/io/FileDescriptor.cxx index 49fe8cab8..08b457831 100644 --- a/src/io/FileDescriptor.cxx +++ b/src/io/FileDescriptor.cxx @@ -291,7 +291,7 @@ FileDescriptor::GetSize() const noexcept void FileDescriptor::FullRead(void *_buffer, size_t length) { - auto *buffer = (uint8_t *)_buffer; + auto buffer = (uint8_t *)_buffer; while (length > 0) { ssize_t nbytes = Read(buffer, length); @@ -309,7 +309,7 @@ FileDescriptor::FullRead(void *_buffer, size_t length) void FileDescriptor::FullWrite(const void *_buffer, size_t length) { - const uint8_t *buffer = (const uint8_t *)_buffer; + auto buffer = (const uint8_t *)_buffer; while (length > 0) { ssize_t nbytes = Write(buffer, length); From 980e32f69cf97952f38cf295d3d0f063e3486fd9 Mon Sep 17 00:00:00 2001 From: Rosen Penev <rosenp@gmail.com> Date: Tue, 29 Sep 2020 14:51:17 -0700 Subject: [PATCH 2/2] remove clocale test clocale is part of C++11. In practical terms, gcc's libstdc++ comes with its own locale defines when the libc does not have them. Also reworked to be dependent on !ANDROID. Signed-off-by: Rosen Penev <rosenp@gmail.com> --- meson.build | 2 -- src/Main.cxx | 4 +--- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 02e78e412..f5b7ad88a 100644 --- a/meson.build +++ b/meson.build @@ -147,8 +147,6 @@ add_global_arguments(common_cppflags, language: 'cpp') enable_daemon = not is_windows and not is_android and get_option('daemon') conf.set('ENABLE_DAEMON', enable_daemon) -conf.set('HAVE_CLOCALE', compiler.has_header('clocale')) - conf.set('HAVE_GETPWNAM_R', compiler.has_function('getpwnam_r')) conf.set('HAVE_GETPWUID_R', compiler.has_function('getpwuid_r')) conf.set('HAVE_INITGROUPS', compiler.has_function('initgroups')) diff --git a/src/Main.cxx b/src/Main.cxx index 5cf7037e7..c96dac4b7 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -111,7 +111,7 @@ #include <climits> -#ifdef HAVE_CLOCALE +#ifndef ANDROID #include <clocale> #endif @@ -358,11 +358,9 @@ MainConfigured(const struct options &options, const ConfigData &raw_config) #endif #ifndef ANDROID -#ifdef HAVE_CLOCALE /* initialize locale */ std::setlocale(LC_CTYPE,""); std::setlocale(LC_COLLATE, ""); -#endif #endif const ScopeIcuInit icu_init;