From 41777279ab6ddb7777b7b246eb8513394bb122cb Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Thu, 7 May 2020 18:48:46 -0700 Subject: [PATCH] [clang-tidy] make several member functions const Found with readability-make-member-function-const Signed-off-by: Rosen Penev --- include/fmt/os.h | 8 ++++---- src/os.cc | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/fmt/os.h b/include/fmt/os.h index a9c1b7d8..51a79b14 100644 --- a/include/fmt/os.h +++ b/include/fmt/os.h @@ -313,10 +313,10 @@ class file { FMT_API long long size() const; // Attempts to read count bytes from the file into the specified buffer. - FMT_API size_t read(void* buffer, size_t count); + FMT_API size_t read(void* buffer, size_t count) const; // Attempts to write count bytes from the specified buffer to the file. - FMT_API size_t write(const void* buffer, size_t count); + FMT_API size_t write(const void* buffer, size_t count) const; // Duplicates a file descriptor with the dup function and returns // the duplicate as a file object. @@ -324,11 +324,11 @@ class file { // Makes fd be the copy of this file descriptor, closing fd first if // necessary. - FMT_API void dup2(int fd); + FMT_API void dup2(int fd) const; // Makes fd be the copy of this file descriptor, closing fd first if // necessary. - FMT_API void dup2(int fd, error_code& ec) FMT_NOEXCEPT; + FMT_API void dup2(int fd, error_code& ec) const FMT_NOEXCEPT; // Creates a pipe setting up read_end and write_end file objects for reading // and writing respectively. diff --git a/src/os.cc b/src/os.cc index 328abcee..bd925e44 100644 --- a/src/os.cc +++ b/src/os.cc @@ -227,14 +227,14 @@ long long file::size() const { # endif } -std::size_t file::read(void* buffer, std::size_t count) { +std::size_t file::read(void* buffer, std::size_t count) const { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(read(fd_, buffer, convert_rwcount(count)))); if (result < 0) FMT_THROW(system_error(errno, "cannot read from file")); return internal::to_unsigned(result); } -std::size_t file::write(const void* buffer, std::size_t count) { +std::size_t file::write(const void* buffer, std::size_t count) const { RWResult result = 0; FMT_RETRY(result, FMT_POSIX_CALL(write(fd_, buffer, convert_rwcount(count)))); if (result < 0) FMT_THROW(system_error(errno, "cannot write to file")); @@ -250,7 +250,7 @@ file file::dup(int fd) { return file(new_fd); } -void file::dup2(int fd) { +void file::dup2(int fd) const { int result = 0; FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd))); if (result == -1) { @@ -259,7 +259,7 @@ void file::dup2(int fd) { } } -void file::dup2(int fd, error_code& ec) FMT_NOEXCEPT { +void file::dup2(int fd, error_code& ec) const FMT_NOEXCEPT { int result = 0; FMT_RETRY(result, FMT_POSIX_CALL(dup2(fd_, fd))); if (result == -1) ec = error_code(errno);