summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-07-13 16:20:30 +0200
committerStanislaw Halik <sthalik@misaki.pl>2018-07-13 16:20:30 +0200
commit68f5f213bf0cbd0bd60a6849bf4379113ea06282 (patch)
tree7906520ed59fe4ef7c03de91d55f4f74b87e4072
parentdb47f9fc711f9b0abeb8461042c40c70d5a71021 (diff)
appease analyzer
-rw-r--r--.clang-tidy30
-rw-r--r--api/plugin-api.cpp35
-rw-r--r--api/plugin-api.hpp16
-rw-r--r--cmake/msvc.cmake5
-rw-r--r--cmake/opentrack-platform.cmake1
-rw-r--r--compat/meta.hpp13
-rw-r--r--compat/sleep.cpp2
-rw-r--r--gui/settings.hpp2
-rw-r--r--logic/main-settings.hpp6
-rw-r--r--logic/runtime-libraries.cpp6
-rw-r--r--logic/win32-shortcuts.cpp2
-rw-r--r--logic/win32-shortcuts.h2
-rw-r--r--options/metatype.cpp2
-rw-r--r--options/metatype.hpp9
-rw-r--r--options/value.hpp21
-rw-r--r--tracker-hatire/ftnoir_tracker_hat.cpp4
-rw-r--r--tracker-joystick/ftnoir_tracker_joystick.cpp4
-rw-r--r--tracker-pt/point_tracker.h4
-rw-r--r--tracker-rift-140/rift-140.cpp4
-rw-r--r--tracker-rift-140/rift-140.hpp6
-rw-r--r--tracker-steamvr/steamvr.cpp2
-rw-r--r--tracker-test/test.cpp10
-rw-r--r--tracker-test/test.h2
-rw-r--r--tracker-wii/wiiyourself/wiimote.cpp8
24 files changed, 112 insertions, 84 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 3b222fa9..803a54a4 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -3,6 +3,9 @@ Checks:
clang-analyzer-*,clang-diagnostic-*,
cppcoreguidelines-*,performance-*,bugprone-*,
readability-*,misc-*,hicpp-*,cert-*,modernize-*,
+ -clang-diagnostic-nonportable-include-path,
+ -clang-analyzer-deadcode-DeadStores,
+ -clang-analyze-core.CallAndMessage,
-cppcoreguidelines-special-member-functions,-hicpp-special-member-functions,
-hicpp-braces-around-statements,-readability-braces-around-statements,
-hicpp-use-equals-default -modernize-use-equals-default,
@@ -34,6 +37,31 @@ Checks:
-hicpp-function-size,
-cppcoreguidelines-pro-type-static-cast-downcast,
-hicpp-use-override,
+ -hicpp-use-equals-delete,
+ -readability-static-accessed-through-instance,
+ -cert-flp30-c,
AnalyzeTemporaryDtors: true
-HeaderFilterRegex: '/dev/opentrack'
+#HeaderFilterRegex: '/dev/opentrack'
+
+CheckOptions:
+ - key: cert-dcl59-cpp.HeaderFileExtensions
+ value: ',h,hpp'
+ - key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
+ value: '1'
+ - key: readability-simplify-boolean-expr.ChainedConditionalAssignment
+ value: '1'
+ - key: readability-simplify-boolean-expr.ChainedConditionalReturn
+ value: '1'
+ - key: readability-function-size.BranchThreshold
+ value: '15'
+ - key: readability-function-size.LineThreshold
+ value: '120'
+ - key: readability-function-size.NestingThreshold
+ value: '6'
+ - key: readability-function-size.ParameterThreshold
+ value: '8'
+ - key: readability-function-size.StatementThreshold
+ value: '90'
+ - key: readability-function-size.VariableThreshold
+ value: '10'
diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp
index 0ce321c7..5a485d62 100644
--- a/api/plugin-api.cpp
+++ b/api/plugin-api.cpp
@@ -6,16 +6,16 @@ using namespace plugin_api::detail;
// these exist so that vtable is emitted in a single compilation unit, not all of them.
-Metadata_::~Metadata_() {}
-IFilter::~IFilter() {}
-IProtocol::~IProtocol() {}
-ITracker::~ITracker() {}
-IExtension::~IExtension() {}
+Metadata_::~Metadata_() = default;
+IFilter::~IFilter() = default;
+IProtocol::~IProtocol() = default;
+ITracker::~ITracker() = default;
+IExtension::~IExtension() = default;
void ITrackerDialog::register_tracker(ITracker*) {}
void ITrackerDialog::unregister_tracker() {}
-BaseDialog::BaseDialog() {}
+BaseDialog::BaseDialog() = default;
void BaseDialog::closeEvent(QCloseEvent*)
{
@@ -38,13 +38,13 @@ module_status ITracker::error(const QString& error)
return module_status(error);
}
-Metadata_::Metadata_() {}
-IFilter::IFilter() {}
-IFilterDialog::IFilterDialog() {}
-IProtocol::IProtocol() {}
-IProtocolDialog::IProtocolDialog() {}
-ITracker::ITracker() {}
-ITrackerDialog::ITrackerDialog() {}
+Metadata_::Metadata_() = default;
+IFilter::IFilter() = default;
+IFilterDialog::IFilterDialog() = default;
+IProtocol::IProtocol() = default;
+IProtocolDialog::IProtocolDialog() = default;
+ITracker::ITracker() = default;
+ITrackerDialog::ITrackerDialog() = default;
void BaseDialog::done(int)
{
@@ -55,9 +55,7 @@ void BaseDialog::done(int)
}
}
-IExtensionDialog::~IExtensionDialog()
-{
-}
+IExtensionDialog::~IExtensionDialog() = default;
bool module_status::is_ok() const
{
@@ -66,10 +64,13 @@ bool module_status::is_ok() const
module_status::module_status(QString error) : error(std::move(error)) {}
-module_status module_status_mixin::status_ok() { return module_status(); }
+module_status module_status_mixin::status_ok() { return {}; }
module_status module_status_mixin::error(const QString& error)
{
return module_status(error.isEmpty() ? "Unknown error" : error);
}
+
+Metadata::Metadata() = default;
+Metadata::~Metadata() = default;
diff --git a/api/plugin-api.hpp b/api/plugin-api.hpp
index 53d4fac6..72175d0a 100644
--- a/api/plugin-api.hpp
+++ b/api/plugin-api.hpp
@@ -42,24 +42,20 @@ private slots:
void done(int) override;
};
-} // ns
+} // ns plugin_api::detail
#define OTR_PLUGIN_EXPORT OTR_GENERIC_EXPORT
#define OPENTRACK_DECLARE_PLUGIN_INTERNAL(ctor_class, ctor_ret_class, metadata_class, dialog_class, dialog_ret_class) \
- extern "C" OTR_PLUGIN_EXPORT ctor_ret_class* GetConstructor(); \
- extern "C" OTR_PLUGIN_EXPORT Metadata_* GetMetadata(); \
- extern "C" OTR_PLUGIN_EXPORT dialog_ret_class* GetDialog(); \
- \
- extern "C" OTR_PLUGIN_EXPORT ctor_ret_class* GetConstructor() \
+ extern "C" OTR_PLUGIN_EXPORT ctor_ret_class* GetConstructor(void) \
{ \
return new ctor_class; \
} \
- extern "C" OTR_PLUGIN_EXPORT Metadata_* GetMetadata() \
+ extern "C" OTR_PLUGIN_EXPORT Metadata_* GetMetadata(void) \
{ \
return new metadata_class; \
} \
- extern "C" OTR_PLUGIN_EXPORT dialog_ret_class* GetDialog() \
+ extern "C" OTR_PLUGIN_EXPORT dialog_ret_class* GetDialog(void) \
{ \
return new dialog_class; \
}
@@ -84,8 +80,8 @@ class OTR_API_EXPORT Metadata : public TR, public Metadata_
Q_OBJECT
public:
- Metadata() {}
- ~Metadata() {}
+ Metadata();
+ ~Metadata();
};
struct OTR_API_EXPORT module_status final
diff --git a/cmake/msvc.cmake b/cmake/msvc.cmake
index a4a1f5c6..0aad2ac8 100644
--- a/cmake/msvc.cmake
+++ b/cmake/msvc.cmake
@@ -51,7 +51,6 @@ if(CMAKE_PROJECT_NAME STREQUAL "opentrack")
endforeach()
set(cc "${cc} -GR-")
- set(cc "${cc} -EHs-c-")
set(CMAKE_RC_FLAGS "/nologo /DWIN32")
endif()
@@ -66,7 +65,7 @@ set(_CFLAGS_DEBUG "-GS -sdl -Gs -guard:cf")
set(_CXXFLAGS_RELEASE "${cc}")
set(_CXXFLAGS_DEBUG "${_CFLAGS_DEBUG}")
-set(_LDFLAGS "-cgthreads:1 -DEBUG")
+set(_LDFLAGS "-cgthreads:1 -DEBUG -machine:x86 -WX")
#set(_ltcg "-LTCG")
set(_ltcg "-LTCG:INCREMENTAL")
@@ -74,7 +73,7 @@ set(_ltcg "-LTCG:INCREMENTAL")
set(_LDFLAGS_RELEASE "-OPT:REF,ICF=4 ${_ltcg}")
set(_LDFLAGS_DEBUG "")
-set(_LDFLAGS_STATIC "-WX")
+set(_LDFLAGS_STATIC "-machine:x86 -WX")
set(_LDFLAGS_STATIC_RELEASE "${_ltcg}")
set(_LDFLAGS_STATIC_DEBUG "")
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
index 5ad2709c..630da3bd 100644
--- a/cmake/opentrack-platform.cmake
+++ b/cmake/opentrack-platform.cmake
@@ -60,6 +60,7 @@ if(MSVC)
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
add_definitions(-D_HAS_EXCEPTIONS=0)
add_definitions(-D_USE_MATH_DEFINES=1)
+ add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
add_definitions(-D_SILENCE_CXX17_NEGATORS_DEPRECATION_WARNING)
add_definitions(-D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING)
diff --git a/compat/meta.hpp b/compat/meta.hpp
index 11c5ca0f..a116cebc 100644
--- a/compat/meta.hpp
+++ b/compat/meta.hpp
@@ -45,6 +45,15 @@ namespace meta::detail {
{
using type = to<xs...>;
};
+
+ template<typename...> struct cons_;
+
+ template<template<typename...> class t, typename x, typename... xs>
+ struct cons_<t<xs...>, x>
+ {
+ using type = t<x, xs...>;
+ };
+
} // ns meta::detail
namespace meta {
@@ -66,5 +75,9 @@ namespace meta {
template<typename... xs>
using last = lift<first, reverse<xs...>>;
+
+ template<typename... xs>
+ using cons = detail::cons_<xs...>;
+
} // ns meta
diff --git a/compat/sleep.cpp b/compat/sleep.cpp
index 6a22adeb..4ec61db5 100644
--- a/compat/sleep.cpp
+++ b/compat/sleep.cpp
@@ -11,11 +11,13 @@ namespace portable
OTR_COMPAT_EXPORT void sleep(int milliseconds)
{
if (milliseconds > 0)
+ {
#ifdef _WIN32
Sleep(milliseconds);
#else
usleep(unsigned(milliseconds) * 1000U); // takes microseconds
#endif
+ }
}
}
diff --git a/gui/settings.hpp b/gui/settings.hpp
index ebcaa66c..50245a59 100644
--- a/gui/settings.hpp
+++ b/gui/settings.hpp
@@ -17,7 +17,7 @@ class OTR_GUI_EXPORT options_dialog : public QDialog
signals:
void closing();
public:
- options_dialog(std::function<void(bool)>&& pause_keybindings);
+ explicit options_dialog(std::function<void(bool)>&& pause_keybindings);
private:
main_settings main;
std::function<void(bool)> pause_keybindings;
diff --git a/logic/main-settings.hpp b/logic/main-settings.hpp
index df86f856..b7a9fdce 100644
--- a/logic/main-settings.hpp
+++ b/logic/main-settings.hpp
@@ -72,6 +72,6 @@ struct OTR_LOGIC_EXPORT main_settings final
} // ns main_settings_impl
-using main_settings_impl::key_opts;
-using main_settings_impl::module_settings;
-using main_settings_impl::main_settings;
+using key_opts = main_settings_impl::key_opts;
+using module_settings = main_settings_impl::module_settings;
+using main_settings = main_settings_impl::main_settings;
diff --git a/logic/runtime-libraries.cpp b/logic/runtime-libraries.cpp
index aa38b032..478b9e0e 100644
--- a/logic/runtime-libraries.cpp
+++ b/logic/runtime-libraries.cpp
@@ -20,7 +20,7 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli
if(status = pProtocol->initialize(), !status.is_ok())
{
status = tr("Error occurred while loading protocol %1\n\n%2\n")
- .arg(p->name).arg(status.error);
+ .arg(p->name, status.error);
goto end;
}
@@ -37,14 +37,14 @@ runtime_libraries::runtime_libraries(QFrame* frame, dylibptr t, dylibptr p, dyli
if(status = pFilter->initialize(), !status.is_ok())
{
status = tr("Error occurred while loading filter %1\n\n%2\n")
- .arg(f->name).arg(status.error);
+ .arg(f->name, status.error);
goto end;
}
if (status = pTracker->start_tracker(frame), !status.is_ok())
{
status = tr("Error occurred while loading tracker %1\n\n%2\n")
- .arg(t->name).arg(status.error);
+ .arg(t->name, status.error);
goto end;
}
diff --git a/logic/win32-shortcuts.cpp b/logic/win32-shortcuts.cpp
index 11764807..4da86afd 100644
--- a/logic/win32-shortcuts.cpp
+++ b/logic/win32-shortcuts.cpp
@@ -158,7 +158,7 @@ bool win_key::to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods
return false;
}
-bool win_key::from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers& mods)
+bool win_key::from_qt(QKeySequence const& qt_, int& dik, Qt::KeyboardModifiers& mods)
{
// CAVEAT don't use QVariant::toUInt() or conversion fails
const unsigned qt = static_cast<unsigned>(QVariant(qt_).toInt());
diff --git a/logic/win32-shortcuts.h b/logic/win32-shortcuts.h
index 437d251a..af90472f 100644
--- a/logic/win32-shortcuts.h
+++ b/logic/win32-shortcuts.h
@@ -13,7 +13,7 @@ struct OTR_LOGIC_EXPORT win_key
//win_key(int win, Qt::Key qt) : win(win), qt(qt) {}
int win;
Qt::Key qt;
- static bool from_qt(QKeySequence qt_, int& dik, Qt::KeyboardModifiers &mods);
+ static bool from_qt(const QKeySequence& qt_, int& dik, Qt::KeyboardModifiers &mods);
static bool to_qt(const Key& k, QKeySequence& qt_, Qt::KeyboardModifiers &mods);
};
diff --git a/options/metatype.cpp b/options/metatype.cpp
index e54970c0..1d13cbdd 100644
--- a/options/metatype.cpp
+++ b/options/metatype.cpp
@@ -20,7 +20,7 @@ int declare_metatype_for_type(const char* str)
OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr)
#define OPENTRACK_DEFINE_METATYPE4(t, sym) \
- static class sym { \
+ class sym { \
static const int dribble; \
} sym ## _singleton; \
const int sym :: dribble = ::options::detail::declare_metatype_for_type<t>(#t)
diff --git a/options/metatype.hpp b/options/metatype.hpp
index 27e37c80..3f92e09f 100644
--- a/options/metatype.hpp
+++ b/options/metatype.hpp
@@ -1,21 +1,21 @@
#pragma once
+#include "slider.hpp"
+#include "defs.hpp"
+
#include <QList>
#include <QString>
#include <QPointF>
#include <QDebug>
-#include "slider.hpp"
-#include "defs.hpp"
#include <QMetaType>
-#if !defined OPENTRACK_METATYPE_ || defined Q_CREATOR_RUN
+#if !defined OPENTRACK_METATYPE_ || defined Q_CREATOR_RUN || defined __clang_analyzer__
# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x)
#else
# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) OPENTRACK_METATYPE_(x)
#endif
-#if !defined __clang_analyzer__
OPENTRACK_METATYPE(QList<double>);
OPENTRACK_METATYPE(QList<float>);
OPENTRACK_METATYPE(QList<int>);
@@ -23,4 +23,3 @@ OPENTRACK_METATYPE(QList<bool>);
OPENTRACK_METATYPE(QList<QString>);
OPENTRACK_METATYPE(QList<QPointF>);
OPENTRACK_METATYPE(::options::slider_value);
-#endif
diff --git a/options/value.hpp b/options/value.hpp
index af3cfd57..7c0a8d56 100644
--- a/options/value.hpp
+++ b/options/value.hpp
@@ -21,6 +21,17 @@
#include <QMetaType>
+namespace options::detail {
+ template<typename t>
+ struct dereference_wrapper final
+ {
+ cc_forceinline constexpr t const* operator->() const { return &x; }
+ cc_forceinline constexpr t* operator->() { return &x; }
+ t x;
+ constexpr explicit cc_forceinline dereference_wrapper(t&& x) : x(x) {}
+ };
+} // ns options::detail
+
namespace options {
template<typename t>
@@ -116,15 +127,7 @@ public:
auto operator->() const
{
- struct dereference_wrapper final
- {
- cc_forceinline t const* operator->() const { return &x; }
- cc_forceinline t* operator->() { return &x; }
- t x;
- explicit cc_forceinline dereference_wrapper(t&& x) : x(x) {}
- };
-
- return dereference_wrapper { get() };
+ return detail::dereference_wrapper<t>{get()};
}
cc_noinline
diff --git a/tracker-hatire/ftnoir_tracker_hat.cpp b/tracker-hatire/ftnoir_tracker_hat.cpp
index 9ac44cf2..3ec89499 100644
--- a/tracker-hatire/ftnoir_tracker_hat.cpp
+++ b/tracker-hatire/ftnoir_tracker_hat.cpp
@@ -28,9 +28,7 @@ hatire::hatire()
End.append((unsigned char) 0x55);
}
-hatire::~hatire()
-{
-}
+hatire::~hatire() = default;
//send RESET to Arduino
void hatire::reset()
diff --git a/tracker-joystick/ftnoir_tracker_joystick.cpp b/tracker-joystick/ftnoir_tracker_joystick.cpp
index fce7cf04..bd7e51ed 100644
--- a/tracker-joystick/ftnoir_tracker_joystick.cpp
+++ b/tracker-joystick/ftnoir_tracker_joystick.cpp
@@ -22,9 +22,7 @@ joystick::joystick()
}
}
-joystick::~joystick()
-{
-}
+joystick::~joystick() = default;
void joystick::data(double *data)
{
diff --git a/tracker-pt/point_tracker.h b/tracker-pt/point_tracker.h
index cfe3735c..00325ee4 100644
--- a/tracker-pt/point_tracker.h
+++ b/tracker-pt/point_tracker.h
@@ -43,7 +43,7 @@ struct PointModel final
enum Model { Clip, Cap, Custom };
- PointModel(const pt_settings& s);
+ explicit PointModel(const pt_settings& s);
void set_model(const pt_settings& s);
void get_d_order(const vec2* points, unsigned* d_order, const vec2& d) const;
@@ -82,7 +82,7 @@ private:
bool init_phase = true, prev_order_valid = false;
};
-} // ns pt_impl
+} // ns pt_module
using PointTracker = pt_module::PointTracker;
using PointModel = pt_module::PointModel;
diff --git a/tracker-rift-140/rift-140.cpp b/tracker-rift-140/rift-140.cpp
index 5ed2866b..ee309ce8 100644
--- a/tracker-rift-140/rift-140.cpp
+++ b/tracker-rift-140/rift-140.cpp
@@ -21,9 +21,7 @@
using namespace OVR;
-rift_tracker_140::rift_tracker_140() : old_yaw(0), hmd(nullptr)
-{
-}
+rift_tracker_140::rift_tracker_140() = default;
rift_tracker_140::~rift_tracker_140()
{
diff --git a/tracker-rift-140/rift-140.hpp b/tracker-rift-140/rift-140.hpp
index dd314432..4437333b 100644
--- a/tracker-rift-140/rift-140.hpp
+++ b/tracker-rift-140/rift-140.hpp
@@ -28,9 +28,9 @@ public:
module_status start_tracker(QFrame *) override;
void data(double *data) override;
private:
- double old_yaw;
- ovrSession hmd;
- ovrGraphicsLuid luid;
+ double old_yaw = 0;
+ ovrSession hmd = nullptr;
+ ovrGraphicsLuid luid {};
settings s;
};
diff --git a/tracker-steamvr/steamvr.cpp b/tracker-steamvr/steamvr.cpp
index 10d73462..bf37f4fc 100644
--- a/tracker-steamvr/steamvr.cpp
+++ b/tracker-steamvr/steamvr.cpp
@@ -317,7 +317,7 @@ void steamvr_dialog::doCancel()
QString device_spec::to_string() const
{
- return QStringLiteral("<%1> %2 [%3]").arg(type).arg(model).arg(serial);
+ return QStringLiteral("<%1> %2 [%3]").arg(type, model, serial);
}
OPENTRACK_DECLARE_TRACKER(steamvr, steamvr_dialog, steamvr_metadata)
diff --git a/tracker-test/test.cpp b/tracker-test/test.cpp
index f93f1556..0e09deb5 100644
--- a/tracker-test/test.cpp
+++ b/tracker-test/test.cpp
@@ -21,14 +21,9 @@ const double test_tracker::incr[6] =
70, 5, 3
};
-test_tracker::test_tracker() :
- last_x { 0, 0, 0, 0, 0, 0 }
-{
-}
+test_tracker::test_tracker() = default;
-test_tracker::~test_tracker()
-{
-}
+test_tracker::~test_tracker() = default;
module_status test_tracker::start_tracker(QFrame*)
{
@@ -81,6 +76,7 @@ test_dialog::test_dialog()
connect(ui.buttonBox, &QDialogButtonBox::clicked, [this](QAbstractButton* btn) {
if (btn == ui.buttonBox->button(QDialogButtonBox::Abort))
+ // NOLINTNEXTLINE
*(volatile int*)nullptr = 0;
});
diff --git a/tracker-test/test.h b/tracker-test/test.h
index 3d5e92bd..6b4357cb 100644
--- a/tracker-test/test.h
+++ b/tracker-test/test.h
@@ -16,7 +16,7 @@ public:
private:
static const double incr[6];
- double last_x[6];
+ double last_x[6] {};
Timer t;
};
diff --git a/tracker-wii/wiiyourself/wiimote.cpp b/tracker-wii/wiiyourself/wiimote.cpp
index 2d101926..f53e1acf 100644
--- a/tracker-wii/wiiyourself/wiimote.cpp
+++ b/tracker-wii/wiiyourself/wiimote.cpp
@@ -22,11 +22,7 @@
#include "wiimote.h"
#include <setupapi.h>
extern "C" {
-# ifdef __MINGW32__
-# include <ddk/hidsdi.h>// from WinDDK
-# else
-# include <hidsdi.h>
-# endif
+#include <hidsdi.h>// from WinDDK
}
#include <sys/types.h> // for _stat
#include <sys/stat.h> // "
@@ -90,7 +86,7 @@ static void __cdecl _TRACE(const TCHAR* fmt, ...)
va_list argptr;
va_start(argptr, fmt);
-#if (_MSC_VER >= 1400) // VC 2005+
+#ifdef _MSC_VER
_vsntprintf_s(buffer, ARRAY_ENTRIES(buffer), _TRUNCATE, fmt, argptr);
#else
_vsntprintf(buffer, ARRAY_ENTRIES(buffer), fmt, argptr);