Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix compile time warnings for unreachable code
  • Loading branch information
falconindy committed Dec 30, 2014
1 parent 4b83592 commit befcf12
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ponymix.cc
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions pulse.cc
Expand Up @@ -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) {
Expand All @@ -205,6 +207,8 @@ Device* PulseClient::GetDevice(const string& name, enum DeviceType type) {
case DEVTYPE_SOURCE_OUTPUT:
return GetSourceOutput(name);
}

throw unreachable();
}

const vector<Device>& PulseClient::GetDevices(enum DeviceType type) const {
Expand All @@ -218,6 +222,8 @@ const vector<Device>& PulseClient::GetDevices(enum DeviceType type) const {
case DEVTYPE_SOURCE_OUTPUT:
return GetSourceOutputs();
}

throw unreachable();
}

Device* PulseClient::GetSink(const uint32_t index) {
Expand Down
10 changes: 10 additions & 0 deletions pulse.h
Expand Up @@ -7,6 +7,7 @@

// C++
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>

Expand Down Expand Up @@ -260,4 +261,13 @@ class PulseClient {
unique_ptr<Notifier> 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:

0 comments on commit befcf12

Please sign in to comment.