فهرست منبع

input_common/sdl: Correct return values within implementations of GetPollers()

In both cases, we weren't actually returning anything, which is
undefined behavior.
Lioncash 7 سال پیش
والد
کامیت
eb335f51ca
2فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 3 1
      src/input_common/sdl/sdl.h
  2. 3 1
      src/input_common/sdl/sdl_impl.cpp

+ 3 - 1
src/input_common/sdl/sdl.h

@@ -34,7 +34,9 @@ public:
 
 
 class NullState : public State {
 class NullState : public State {
 public:
 public:
-    Pollers GetPollers(Polling::DeviceType type) override {}
+    Pollers GetPollers(Polling::DeviceType type) override {
+        return {};
+    }
 };
 };
 
 
 std::unique_ptr<State> Init();
 std::unique_ptr<State> Init();

+ 3 - 1
src/input_common/sdl/sdl_impl.cpp

@@ -652,6 +652,7 @@ private:
 
 
 SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) {
 SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) {
     Pollers pollers;
     Pollers pollers;
+
     switch (type) {
     switch (type) {
     case InputCommon::Polling::DeviceType::Analog:
     case InputCommon::Polling::DeviceType::Analog:
         pollers.emplace_back(std::make_unique<Polling::SDLAnalogPoller>(*this));
         pollers.emplace_back(std::make_unique<Polling::SDLAnalogPoller>(*this));
@@ -659,8 +660,9 @@ SDLState::Pollers SDLState::GetPollers(InputCommon::Polling::DeviceType type) {
     case InputCommon::Polling::DeviceType::Button:
     case InputCommon::Polling::DeviceType::Button:
         pollers.emplace_back(std::make_unique<Polling::SDLButtonPoller>(*this));
         pollers.emplace_back(std::make_unique<Polling::SDLButtonPoller>(*this));
         break;
         break;
-        return pollers;
     }
     }
+
+    return pollers;
 }
 }
 
 
 } // namespace SDL
 } // namespace SDL