From befcf12820411ace8d9531dc829abd20c957fe60 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Sun, 28 Dec 2014 16:04:47 -0500 Subject: fix compile time warnings for unreachable code --- ponymix.cc | 2 ++ pulse.cc | 6 ++++++ pulse.h | 10 ++++++++++ 3 files changed, 18 insertions(+) diff --git a/ponymix.cc b/ponymix.cc index 37dec3f..a07059d 100644 --- a/ponymix.cc +++ b/ponymix.cc @@ -83,6 +83,8 @@ static const char* type_to_string(enum DeviceType t) { case DEVTYPE_SOURCE_OUTPUT: return "source-output"; } + + throw unreachable(); } static enum DeviceType string_to_devtype_or_die(const char* str) { diff --git a/pulse.cc b/pulse.cc index 5bae79a..64bef66 100644 --- a/pulse.cc +++ b/pulse.cc @@ -192,6 +192,8 @@ Device* PulseClient::GetDevice(const uint32_t index, enum DeviceType type) { case DEVTYPE_SOURCE_OUTPUT: return GetSourceOutput(index); } + + throw unreachable(); } Device* PulseClient::GetDevice(const string& name, enum DeviceType type) { @@ -205,6 +207,8 @@ Device* PulseClient::GetDevice(const string& name, enum DeviceType type) { case DEVTYPE_SOURCE_OUTPUT: return GetSourceOutput(name); } + + throw unreachable(); } const vector& PulseClient::GetDevices(enum DeviceType type) const { @@ -218,6 +222,8 @@ const vector& PulseClient::GetDevices(enum DeviceType type) const { case DEVTYPE_SOURCE_OUTPUT: return GetSourceOutputs(); } + + throw unreachable(); } Device* PulseClient::GetSink(const uint32_t index) { diff --git a/pulse.h b/pulse.h index 55b07c3..32dfe25 100644 --- a/pulse.h +++ b/pulse.h @@ -7,6 +7,7 @@ // C++ #include +#include #include #include @@ -260,4 +261,13 @@ class PulseClient { unique_ptr notifier_; }; +class unreachable : public std::runtime_error { + public: + unreachable() throw() : + std::runtime_error("unreachable code path encountered") {} + + unreachable(const std::string& message) throw() : + std::runtime_error(message) {} +}; + // vim: set et ts=2 sw=2: -- cgit v1.2.3