mate-desktop / mate-applets

Applets for use with the MATE panel
http://www.mate-desktop.org
GNU General Public License v2.0
79 stars 67 forks source link

battstat: implicit conversion changes signedness: 'gboolean' to 'guint' #620

Closed rbuj closed 2 years ago

rbuj commented 2 years ago
CFLAGS="-g -O0 -Wconversion -Wunused-macros -Wunused-parameter" CC=clang ./autogen.sh --prefix=/usr --enable-compile-warnings=maximum && make &> make.log
battstat_applet.c:729:36: warning: implicit conversion changes signedness: 'gboolean' (aka 'int') to 'guint' (aka 'unsigned int') [-Wsign-conversion]
    battstat->last_charging = info.charging;
                            ~ ~~~~~^~~~~~~~
--
battstat_applet.c:732:41: warning: implicit conversion changes signedness: 'gboolean' (aka 'int') to 'guint' (aka 'unsigned int') [-Wsign-conversion]
    battstat->last_acline_status = info.on_ac_power;
                                 ~ ~~~~~^~~~~~~~~~~
mbkma commented 2 years ago

I wonder if there is a good reason why last_charging and last_acline_status are not gbooleans:

$ grep -r last_charging
battstat_applet.c:    if (battstat->last_charging &&
battstat_applet.c:        info.charging != battstat->last_charging)
battstat_applet.c:    battstat->last_charging = (info.charging != FALSE);
battstat_applet.c:    battstat->last_charging = 1000;
battstat.h:  guint last_charging;
grep: battstat-applet: binary file matches
$ grep -r last_acline_status
battstat_applet.c:        battstat->last_acline_status &&
battstat_applet.c:        battstat->last_acline_status!=1000 &&
battstat_applet.c:    if (info.on_ac_power != battstat->last_acline_status ||
battstat_applet.c:        battstat->last_acline_status != info.on_ac_power ||
battstat_applet.c:    battstat->last_acline_status = (info.on_ac_powerg != FALSE);
battstat_applet.c:    battstat->last_acline_status = 1000;
battstat.h:  guint last_acline_status;
grep: battstat-applet: binary file matches
rbuj commented 2 years ago

I wonder if there is a good reason why last_charging and last_acline_status are not gbooleans

They are tristate variables.

enum TriState {Off = 0, On = 1, Unknown = 1000 };
mbkma commented 2 years ago

thanks, that is a lot nicer code :)