From 0fe3c2611ca99b3cd3ad4d8b91430726642f955f Mon Sep 17 00:00:00 2001 From: Dmitry Yemanov Date: Thu, 16 Apr 2020 18:28:38 +0300 Subject: [PATCH] Reduce warnings --- doc/README.modern_cpp.md | 1 + src/gpre/c_cxx.cpp | 6 ++++-- src/jrd/event_proto.h | 2 +- src/jrd/replication/ChangeLog.cpp | 5 +++-- src/jrd/replication/Manager.h | 2 +- src/jrd/replication/Replicator.cpp | 2 +- src/lock/lock_proto.h | 3 +-- src/remote/server/ReplServer.cpp | 15 ++++++++++----- 8 files changed, 22 insertions(+), 14 deletions(-) diff --git a/doc/README.modern_cpp.md b/doc/README.modern_cpp.md index aae134d3f1..c894ffcc25 100644 --- a/doc/README.modern_cpp.md +++ b/doc/README.modern_cpp.md @@ -25,3 +25,4 @@ Only ones mentioned in this document could be used, but as necessities appears, - [static_assert](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html) - [decltype](https://en.cppreference.com/w/cpp/language/decltype) - [std::is_convertible](https://en.cppreference.com/w/cpp/types/is_convertible) +- [final specifier](https://en.cppreference.com/w/cpp/language/final) diff --git a/src/gpre/c_cxx.cpp b/src/gpre/c_cxx.cpp index 80d52c6222..625cae08b0 100644 --- a/src/gpre/c_cxx.cpp +++ b/src/gpre/c_cxx.cpp @@ -1909,9 +1909,11 @@ static void gen_emodify( const act* action, int column) gen_name(s2, reference, true); if (field->fld_dtype == dtype_varying && field->fld_sub_type == dsc_text_type_fixed) { - fprintf(gpreGlob.out_file, "memcpy (&%s, &%s, %d);", s2, s1, field->fld_length + sizeof(USHORT)); + const int length = field->fld_length + sizeof(USHORT); + fprintf(gpreGlob.out_file, "memcpy (&%s, &%s, %d);", s2, s1, length); } - else if (field->fld_dtype > dtype_cstring || (field->fld_sub_type == dsc_text_type_fixed && field->fld_length == 1)) + else if (field->fld_dtype > dtype_cstring || + (field->fld_sub_type == dsc_text_type_fixed && field->fld_length == 1)) { fprintf(gpreGlob.out_file, "%s = %s;", s2, s1); } diff --git a/src/jrd/event_proto.h b/src/jrd/event_proto.h index 1e35737c48..b21de3ea33 100644 --- a/src/jrd/event_proto.h +++ b/src/jrd/event_proto.h @@ -38,7 +38,7 @@ namespace Jrd { class Attachment; -class EventManager : public Firebird::GlobalStorage, public Firebird::IpcObject +class EventManager final : public Firebird::GlobalStorage, public Firebird::IpcObject { const int PID; diff --git a/src/jrd/replication/ChangeLog.cpp b/src/jrd/replication/ChangeLog.cpp index ff201dc27c..90ec7fdbfc 100644 --- a/src/jrd/replication/ChangeLog.cpp +++ b/src/jrd/replication/ChangeLog.cpp @@ -238,10 +238,11 @@ void ChangeLog::Segment::truncate() unmapHeader(); #ifdef WIN_NT - chsize(m_handle, length); + if (chsize(m_handle, length)) #else - ftruncate(m_handle, length); + if (ftruncate(m_handle, length)) #endif + raiseError("Log file %s truncate failed (error %d)", m_filename.c_str(), ERRNO); mapHeader(); } diff --git a/src/jrd/replication/Manager.h b/src/jrd/replication/Manager.h index 9d32722ed2..cb9e904737 100644 --- a/src/jrd/replication/Manager.h +++ b/src/jrd/replication/Manager.h @@ -53,7 +53,7 @@ namespace Replication TablePermissionMap m_tables; }; - class Manager : public Firebird::GlobalStorage + class Manager final : public Firebird::GlobalStorage { struct SyncReplica { diff --git a/src/jrd/replication/Replicator.cpp b/src/jrd/replication/Replicator.cpp index c0f6d68df1..584f468a7c 100644 --- a/src/jrd/replication/Replicator.cpp +++ b/src/jrd/replication/Replicator.cpp @@ -39,8 +39,8 @@ Replicator::Replicator(MemoryPool& pool, bool cleanupTransactions) : PermanentStorage(pool), m_manager(manager), - m_guid(guid), m_config(manager->getConfig()), + m_guid(guid), m_user(user), m_transactions(pool), m_generators(pool), diff --git a/src/lock/lock_proto.h b/src/lock/lock_proto.h index 26faec9cb8..0acb8ae53a 100644 --- a/src/lock/lock_proto.h +++ b/src/lock/lock_proto.h @@ -293,8 +293,7 @@ namespace Jrd { class thread_db; -class LockManager : public Firebird::GlobalStorage, - public Firebird::IpcObject +class LockManager final : public Firebird::GlobalStorage, public Firebird::IpcObject { class LockTableGuard { diff --git a/src/remote/server/ReplServer.cpp b/src/remote/server/ReplServer.cpp index cd7668944c..e97cce6b10 100644 --- a/src/remote/server/ReplServer.cpp +++ b/src/remote/server/ReplServer.cpp @@ -229,7 +229,8 @@ namespace m_data.db_sequence = db_sequence; lseek(m_handle, 0, SEEK_SET); - write(m_handle, &m_data, sizeof(Data)); + if (write(m_handle, &m_data, sizeof(Data)) != sizeof(Data)) + raiseError("Control file write failed (error: %d)", ERRNO); flush(); } @@ -257,8 +258,10 @@ namespace const ULONG txn_size = m_data.txn_count * sizeof(ActiveTransaction); lseek(m_handle, 0, SEEK_SET); - write(m_handle, &m_data, sizeof(Data)); - write(m_handle, transactions.begin(), txn_size); + if (write(m_handle, &m_data, sizeof(Data)) != sizeof(Data)) + raiseError("Control file write failed (error: %d)", ERRNO); + if (write(m_handle, transactions.begin(), txn_size) != txn_size) + raiseError("Control file write failed (error: %d)", ERRNO); flush(); } } @@ -275,8 +278,10 @@ namespace const ULONG txn_size = m_data.txn_count * sizeof(ActiveTransaction); lseek(m_handle, 0, SEEK_SET); - write(m_handle, &m_data, sizeof(Data)); - write(m_handle, transactions.begin(), txn_size); + if (write(m_handle, &m_data, sizeof(Data)) != sizeof(Data)) + raiseError("Control file write failed (error: %d)", ERRNO); + if (write(m_handle, transactions.begin(), txn_size) != txn_size) + raiseError("Control file write failed (error: %d)", ERRNO); flush(); } }