From fed15dc29d0f66bc014a38f88f00e8b528557a5e Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Thu, 11 Dec 2014 05:11:02 +0000 Subject: [PATCH] Fix a couple of ordinary and pedantic warnings Add previously missing -Wall to warning flags in CMake. Remove -Wformat and -Wvariadic-macros (enabled by default; latter is not meaningful in C99 mode we use), -Wdeclaration-after-statement (again, not needed as we use C99). Move -Wmissing-declarations to C-only flags (GCC man says so). Add copyrights year to crypto-utils-fallback.c. --- CMakeLists.txt | 15 +++++++++------ libtransmission/crypto-utils-fallback.c | 2 +- libtransmission/platform-quota.c | 8 ++++++-- libtransmission/utils-test.c | 6 +++--- qt/app.cc | 4 ++-- qt/favicon.h | 2 +- qt/file-tree.h | 2 +- qt/prefs.h | 2 +- qt/torrent.h | 2 +- 9 files changed, 25 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d77fe3b22..8009304b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,25 +271,28 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") set(NEEDED_COMPILER_FLAGS + -Wall + -W -Wcast-align - -Wextra -Wfloat-equal - -Wformat -Wformat-security - -Winit-self -Winline - -Wmissing-declarations -Wmissing-format-attribute -Wpointer-arith -Wredundant-decls -Wundef -Wunused-parameter - -Wvariadic-macros -Wwrite-strings) + if(NOT CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "3.3") + list(APPEND NEEDED_COMPILER_FLAGS + -Wextra + -Winit-self) + endif() + set(NEEDED_C_COMPILER_FLAGS ${NEEDED_COMPILER_FLAGS} - -Wdeclaration-after-statement + -Wmissing-declarations -Wnested-externs -Wstrict-prototypes) string(REPLACE ";" " " NEEDED_C_COMPILER_FLAGS_STRING "${NEEDED_C_COMPILER_FLAGS}") diff --git a/libtransmission/crypto-utils-fallback.c b/libtransmission/crypto-utils-fallback.c index e06bc9207..0ca1ad75e 100644 --- a/libtransmission/crypto-utils-fallback.c +++ b/libtransmission/crypto-utils-fallback.c @@ -1,5 +1,5 @@ /* - * This file Copyright (C) Mnemosyne LLC + * This file Copyright (C) 2014 Mnemosyne LLC * * It may be used under the GNU GPL versions 2 or 3 * or any future license endorsed by Mnemosyne LLC. diff --git a/libtransmission/platform-quota.c b/libtransmission/platform-quota.c index 42b70f27c..0375a16df 100644 --- a/libtransmission/platform-quota.c +++ b/libtransmission/platform-quota.c @@ -46,8 +46,12 @@ #endif #ifdef __APPLE__ - #define HAVE_SYS_STATVFS_H - #define HAVE_STATVFS + #ifndef HAVE_SYS_STATVFS_H + #define HAVE_SYS_STATVFS_H + #endif + #ifndef HAVE_STATVFS + #define HAVE_STATVFS + #endif #endif #ifdef HAVE_SYS_STATVFS_H diff --git a/libtransmission/utils-test.c b/libtransmission/utils-test.c index 64cfde187..88c8f6444 100644 --- a/libtransmission/utils-test.c +++ b/libtransmission/utils-test.c @@ -117,8 +117,8 @@ test_utf8 (void) check_streq ("hello", out); tr_free (out); - /* this version is not utf-8 */ - in = " "; + /* this version is not utf-8 (but cp866) */ + in = "\x92\xE0\xE3\xA4\xAD\xAE \xA1\xEB\xE2\xEC \x81\xAE\xA3\xAE\xAC"; out = tr_utf8clean (in, 17); check (out != NULL); check ((strlen (out) == 17) || (strlen (out) == 32)); @@ -126,7 +126,7 @@ test_utf8 (void) tr_free (out); /* same string, but utf-8 clean */ - in = "Òðóäíî áûòü Áîãîì"; + in = "Трудно быть Богом"; out = tr_utf8clean (in, -1); check (out != NULL); check (tr_utf8_validate (out, -1, NULL)); diff --git a/qt/app.cc b/qt/app.cc index 97cc0ce70..c301cefd7 100644 --- a/qt/app.cc +++ b/qt/app.cc @@ -84,12 +84,12 @@ namespace MyApp :: MyApp (int& argc, char ** argv): QApplication (argc, argv), - myLastFullUpdateTime (0), myPrefs(nullptr), mySession(nullptr), myModel(nullptr), myWindow(nullptr), - myWatchDir(nullptr) + myWatchDir(nullptr), + myLastFullUpdateTime (0) { const QString MY_CONFIG_NAME = QString::fromUtf8 ("transmission"); diff --git a/qt/favicon.h b/qt/favicon.h index e5d0deb28..c18fe3805 100644 --- a/qt/favicon.h +++ b/qt/favicon.h @@ -21,7 +21,7 @@ class QUrl; class Favicons: public QObject { - Q_OBJECT; + Q_OBJECT public: diff --git a/qt/file-tree.h b/qt/file-tree.h index 0543619ed..a1b811238 100644 --- a/qt/file-tree.h +++ b/qt/file-tree.h @@ -33,7 +33,7 @@ class QStyle; class FileTreeItem: public QObject { - Q_OBJECT; + Q_OBJECT enum { LOW=(1<<0), NORMAL=(1<<1), HIGH=(1<<2) }; diff --git a/qt/prefs.h b/qt/prefs.h index b5831ea01..d8fcb9dba 100644 --- a/qt/prefs.h +++ b/qt/prefs.h @@ -27,7 +27,7 @@ extern "C" class Prefs: public QObject { - Q_OBJECT; + Q_OBJECT public: diff --git a/qt/torrent.h b/qt/torrent.h index 85f1b289b..155681919 100644 --- a/qt/torrent.h +++ b/qt/torrent.h @@ -115,7 +115,7 @@ Q_DECLARE_METATYPE(FileList) class Torrent: public QObject { - Q_OBJECT; + Q_OBJECT public: