giucam / orbital

A Wayland compositor based on Weston and Qt
GNU General Public License v3.0
158 stars 17 forks source link

error: control reaches end of non-void function #14

Closed xiangzhai closed 9 years ago

xiangzhai commented 9 years ago

/data/project/giucam/orbital/src/client/services/hardware/solidbackend.cpp: In function 'Battery::ChargeState fromSolid(Solid::Battery::ChargeState)': /data/project/giucam/orbital/src/client/services/hardware/solidbackend.cpp:84:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1plus: some warnings being treated as errors

my monkey patch shown as below:

diff --git a/src/client/services/hardware/solidbackend.cpp b/src/client/services/hardware/solidbackend.cpp
index 4adea6e..082e6d1 100644
--- a/src/client/services/hardware/solidbackend.cpp
+++ b/src/client/services/hardware/solidbackend.cpp
@@ -80,6 +80,7 @@ static Battery::ChargeState fromSolid(Solid::Battery::ChargeState c)
         case Solid::Battery::Charging: return Battery::ChargeState::Charging;
         case Solid::Battery::Discharging: return Battery::ChargeState::Discharging;
     }
+    return Battery::ChargeState::Stable;
 }

 SolidBattery::SolidBattery(Solid::Battery *b, const QString &udi)

PS: I often use _-Werror_ to cleanup my code ;P https://github.com/xiangzhai/qwx/blob/android/qwx.pro#L11

giucam commented 9 years ago

Ah, clang doesn't complain about it, probably because all the cases are handled in the switch. I'll merge your pathc, thanks.

giucam commented 9 years ago

Btw, that's gcc, right?

xiangzhai commented 9 years ago

yup, gcc -v 4.9.2 20141224