From 4c339031f062c73abe0081207e4ff0cfa0e9e17c Mon Sep 17 00:00:00 2001 From: Timothy Rae Date: Fri, 31 Mar 2017 12:12:46 +0900 Subject: [PATCH 1/4] Remove const from Database::isUnencrypted() return type Compiling with gcc pedantic mode was leading to a warning: "type qualifiers ignored on function return type" --- include/SQLiteCpp/Database.h | 2 +- src/Database.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/SQLiteCpp/Database.h b/include/SQLiteCpp/Database.h index 0129809d..d3184c08 100644 --- a/include/SQLiteCpp/Database.h +++ b/include/SQLiteCpp/Database.h @@ -412,7 +412,7 @@ class Database * * @throw SQLite::Exception in case of error */ - static const bool isUnencrypted(const std::string& aFilename); + static bool isUnencrypted(const std::string& aFilename); private: /// @{ Database must be non-copyable diff --git a/src/Database.cpp b/src/Database.cpp index cfa54474..a63b3ff7 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -265,7 +265,7 @@ void Database::rekey(const std::string& aNewKey) const } // Test if a file contains an unencrypted database. -const bool Database::isUnencrypted(const std::string& aFilename) +bool Database::isUnencrypted(const std::string& aFilename) { if (aFilename.length() > 0) { std::ifstream fileBuffer(aFilename.c_str(), std::ios::in | std::ios::binary); From b23f2e155f4de21d24cabd72fdb0d994952acf02 Mon Sep 17 00:00:00 2001 From: Timothy Rae Date: Fri, 31 Mar 2017 12:22:38 +0900 Subject: [PATCH 2/4] Use -Wextra flag with gcc From the manual: This enables some extra warning flags that are not enabled by -Wall. (This option used to be called -W. The older name is still supported, but the newer name is more descriptive.) -Wclobbered -Wempty-body -Wignored-qualifiers -Wimplicit-fallthrough=3 -Wmissing-field-initializers -Wmissing-parameter-type (C only) -Wold-style-declaration (C only) -Woverride-init -Wsign-compare (C only) -Wtype-limits -Wuninitialized -Wshift-negative-value (in C++03 and in C99 and newer) -Wunused-parameter (only with -Wunused or -Wall) -Wunused-but-set-parameter (only with -Wunused or -Wall) --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a875e963..9e0ba8c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ else (MSVC) set(CPPLINT_ARG_OUTPUT "--output=eclipse") set(CPPCHECK_ARG_TEMPLATE "--template=gcc") # Useful compile flags and extra warnings - add_compile_options(-fstack-protector -Wall -Winit-self -Wswitch-enum -Wshadow -Winline) + add_compile_options(-fstack-protector -Wall -Wextra -Winit-self -Wswitch-enum -Wshadow -Winline) if (CMAKE_COMPILER_IS_GNUCXX) # GCC flags if (SQLITECPP_USE_GCOV AND CMAKE_COMPILER_IS_GNUCXX) From 400ab71fa338ac0ccd9617f24e626902e190e8a9 Mon Sep 17 00:00:00 2001 From: Timothy Rae Date: Fri, 31 Mar 2017 12:22:48 +0900 Subject: [PATCH 3/4] Fix unused parameter warning --- src/Database.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Database.cpp b/src/Database.cpp index a63b3ff7..164f3e3f 100644 --- a/src/Database.cpp +++ b/src/Database.cpp @@ -259,6 +259,7 @@ void Database::rekey(const std::string& aNewKey) const check(ret); } #else // SQLITE_HAS_CODEC + static_cast(aNewKey); // silence unused parameter warning const SQLite::Exception exception("No encryption support, recompile with SQLITE_HAS_CODEC to enable."); throw exception; #endif // SQLITE_HAS_CODEC From 2123ef034850039c54b47d493ec09907dedb797b Mon Sep 17 00:00:00 2001 From: Timothy Rae Date: Fri, 31 Mar 2017 12:40:58 +0900 Subject: [PATCH 4/4] Use pedantic warnings From the gcc manual: Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std option used. Note: ISO C++98 doesn't support the "long long" data type, so we disable that warning -Winit-self can be removed as it's enabled by -Wall --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e0ba8c1..c87dee56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ else (MSVC) set(CPPLINT_ARG_OUTPUT "--output=eclipse") set(CPPCHECK_ARG_TEMPLATE "--template=gcc") # Useful compile flags and extra warnings - add_compile_options(-fstack-protector -Wall -Wextra -Winit-self -Wswitch-enum -Wshadow -Winline) + add_compile_options(-fstack-protector -Wall -Wextra -Wpedantic -Wno-long-long -Wswitch-enum -Wshadow -Winline) if (CMAKE_COMPILER_IS_GNUCXX) # GCC flags if (SQLITECPP_USE_GCOV AND CMAKE_COMPILER_IS_GNUCXX)