From 8d6a44d1b71be1e6a25815a0fb293a74c755a870 Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Wed, 26 Feb 2014 15:53:28 +0000 Subject: [PATCH] fixed: osx106 warnings --- src/lib/common/common.h | 3 -- src/lib/io/CCryptoMode.h | 19 +----------- src/lib/io/CCryptoMode_cryptopp.h | 30 +++++++++++++++++++ src/lib/io/CCryptoStream.cpp | 2 +- src/lib/io/CCryptoStream.h | 17 +---------- src/lib/io/CCryptoStream_cryptopp.h | 29 ++++++++++++++++++ src/lib/platform/COSXScreen.cpp | 7 +---- src/lib/platform/COSXScreenSaver.cpp | 7 +---- src/lib/synergy/CDragInformation.cpp | 6 ++-- src/test/gtest.h | 28 +++++++++++++++++ .../unittests/synergy/CClipboardTests.cpp | 2 +- src/test/unittests/synergy/CKeyStateTests.cpp | 2 +- 12 files changed, 97 insertions(+), 55 deletions(-) create mode 100644 src/lib/io/CCryptoMode_cryptopp.h create mode 100644 src/lib/io/CCryptoStream_cryptopp.h create mode 100644 src/test/gtest.h diff --git a/src/lib/common/common.h b/src/lib/common/common.h index 78561acf..2ee5a253 100644 --- a/src/lib/common/common.h +++ b/src/lib/common/common.h @@ -155,7 +155,4 @@ enum { kExitConfig = 4 // cannot read configuration }; -// gnu 4.6+ has pragma diagnostic push and tautological-compare -#define GNUC_46 defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)) - #endif diff --git a/src/lib/io/CCryptoMode.h b/src/lib/io/CCryptoMode.h index d042ef84..15d2fbaf 100644 --- a/src/lib/io/CCryptoMode.h +++ b/src/lib/io/CCryptoMode.h @@ -19,24 +19,7 @@ #include "ECryptoMode.h" #include "CString.h" - -#if __APPLE__ -# if GNUC_46 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wtautological-compare" -# endif -# pragma GCC diagnostic ignored "-Wall" -#endif - -#include -#include -#include - -#if __APPLE__ -# if GNUC_46 -# pragma GCC diagnostic pop -# endif -#endif +#include "CCryptoMode_cryptopp.h" //! Encapsulation of modes /*! diff --git a/src/lib/io/CCryptoMode_cryptopp.h b/src/lib/io/CCryptoMode_cryptopp.h new file mode 100644 index 00000000..1202d796 --- /dev/null +++ b/src/lib/io/CCryptoMode_cryptopp.h @@ -0,0 +1,30 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 Bolton Software Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +// HACK: gcc on osx106 doesn't give you an easy way to hide warnings +// from included headers, so use the system_header pragma. the downside +// is that everything in the header file following this also has warnings +// ignored, so we need to put it in a separate header file. +#if __APPLE__ +# pragma GCC system_header +#endif + +#include +#include +#include diff --git a/src/lib/io/CCryptoStream.cpp b/src/lib/io/CCryptoStream.cpp index 9a9a311e..b9817663 100644 --- a/src/lib/io/CCryptoStream.cpp +++ b/src/lib/io/CCryptoStream.cpp @@ -60,7 +60,7 @@ CCryptoStream::read(void* out, UInt32 n) LOG((CLOG_DEBUG4 "crypto: read %i (decrypt)", n)); byte* cypher = new byte[n]; - int result = getStream()->read(cypher, n); + size_t result = getStream()->read(cypher, n); if (result == 0) { // nothing to read. return 0; diff --git a/src/lib/io/CCryptoStream.h b/src/lib/io/CCryptoStream.h index ceecf29f..45bb1369 100644 --- a/src/lib/io/CCryptoStream.h +++ b/src/lib/io/CCryptoStream.h @@ -20,22 +20,7 @@ #include "BasicTypes.h" #include "CStreamFilter.h" #include "CCryptoMode.h" - -#if __APPLE__ -# if GNUC_46 -# pragma GCC diagnostic push -# endif -# pragma GCC diagnostic ignored "-Wall" -#endif - -#include -#include - -#if __APPLE__ -# if GNUC_46 -# pragma GCC diagnostic pop -# endif -#endif +#include "CCryptoStream_cryptopp.h" class CCryptoOptions; diff --git a/src/lib/io/CCryptoStream_cryptopp.h b/src/lib/io/CCryptoStream_cryptopp.h new file mode 100644 index 00000000..71b1f09d --- /dev/null +++ b/src/lib/io/CCryptoStream_cryptopp.h @@ -0,0 +1,29 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 Bolton Software Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +// HACK: gcc on osx106 doesn't give you an easy way to hide warnings +// from included headers, so use the system_header pragma. the downside +// is that everything in the header file following this also has warnings +// ignored, so we need to put it in a separate header file. +#if __APPLE__ +# pragma GCC system_header +#endif + +#include +#include diff --git a/src/lib/platform/COSXScreen.cpp b/src/lib/platform/COSXScreen.cpp index 542beb2a..112f01e3 100644 --- a/src/lib/platform/COSXScreen.cpp +++ b/src/lib/platform/COSXScreen.cpp @@ -2100,9 +2100,6 @@ COSXScreen::getDraggingFilename() return m_draggingFilename; } -#if GNUC_46 -# pragma GCC diagnostic push -#endif #pragma GCC diagnostic ignored "-Wdeprecated-declarations" void @@ -2143,6 +2140,4 @@ avoidHesitatingCursor() CGSetLocalEventsSuppressionInterval(0.0001); } -#if GNUC_46 -# pragma GCC diagnostic pop -#endif +#pragma GCC diagnostic error "-Wdeprecated-declarations" diff --git a/src/lib/platform/COSXScreenSaver.cpp b/src/lib/platform/COSXScreenSaver.cpp index c9cb7367..f9381f42 100644 --- a/src/lib/platform/COSXScreenSaver.cpp +++ b/src/lib/platform/COSXScreenSaver.cpp @@ -161,9 +161,6 @@ COSXScreenSaver::launchTerminationCallback( return (CallNextEventHandler(nextHandler, theEvent)); } -#if GNUC_46 -# pragma GCC diagnostic push -#endif #pragma GCC diagnostic ignored "-Wdeprecated-declarations" void @@ -199,6 +196,4 @@ testProcessName(const char* name, const ProcessSerialNumber& psn) return (err == 0 && CFEqual(CFSTR("ScreenSaverEngine"), processName)); } -#if GNUC_46 -# pragma GCC diagnostic pop -#endif +#pragma GCC diagnostic error "-Wdeprecated-declarations" diff --git a/src/lib/synergy/CDragInformation.cpp b/src/lib/synergy/CDragInformation.cpp index 14b60a52..048277f6 100644 --- a/src/lib/synergy/CDragInformation.cpp +++ b/src/lib/synergy/CDragInformation.cpp @@ -28,7 +28,7 @@ CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CSt size_t findResult2 = 0; dragFileList.clear(); CString slash("\\"); - if (data.find("/", startPos) != -1) { + if (data.find("/", startPos) != string::npos) { slash = "/"; } @@ -51,9 +51,9 @@ CDragInformation::parseDragInfo(CDragFileList& dragFileList, UInt32 fileNum, CSt CString CDragInformation::getDragFileExtension(CString fileName) { - size_t findResult = -1; + size_t findResult = string::npos; findResult = fileName.find_last_of(".", fileName.size()); - if (findResult != -1) { + if (findResult != string::npos) { return fileName.substr(findResult + 1, fileName.size() - findResult - 1); } else { diff --git a/src/test/gtest.h b/src/test/gtest.h new file mode 100644 index 00000000..493c9025 --- /dev/null +++ b/src/test/gtest.h @@ -0,0 +1,28 @@ +/* + * synergy -- mouse and keyboard sharing utility + * Copyright (C) 2014 Bolton Software Ltd. + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * found in the file COPYING that should have accompanied this file. + * + * This package is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +// HACK: gcc on osx106 doesn't give you an easy way to hide warnings +// from included headers, so use the system_header pragma. the downside +// is that everything in the header file following this also has warnings +// ignored, so we need to put it in a separate header file. +#if __APPLE__ +# pragma GCC system_header +#endif + +#include diff --git a/src/test/unittests/synergy/CClipboardTests.cpp b/src/test/unittests/synergy/CClipboardTests.cpp index 7379f562..97448c71 100644 --- a/src/test/unittests/synergy/CClipboardTests.cpp +++ b/src/test/unittests/synergy/CClipboardTests.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include +#include <../../gtest.h> #include "CClipboard.h" TEST(CClipboardTests, empty_openCalled_returnsTrue) diff --git a/src/test/unittests/synergy/CKeyStateTests.cpp b/src/test/unittests/synergy/CKeyStateTests.cpp index 71ec398b..a1c0feda 100644 --- a/src/test/unittests/synergy/CKeyStateTests.cpp +++ b/src/test/unittests/synergy/CKeyStateTests.cpp @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#include +#include <../../gtest.h> #include #include "CKeyStateTests.h" #include "CMockEventQueue.h"