unity-api-bugs team mailing list archive
-
unity-api-bugs team
-
Mailing list archive
-
Message #01169
[Bug 1071757] Re: Logic error in the code
** Changed in: indicator-power
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of Unity API
bugs, which is subscribed to indicator-power.
https://bugs.launchpad.net/bugs/1071757
Title:
Logic error in the code
Status in The Power Indicator:
Fix Released
Bug description:
Found by clang static analyzer
in
static gint compare_func (gconstpointer ga, gconstpointer gb)
there is some code that says
if (b_state != state) /* a is charging */
{
ret = 1;
}
if (a_state != state) /* b is charging */
{
ret = -1;
}
else /* both are discharging; most-time-to-charge goes first */
{
if (!a_time || !b_time) /* known time always trumps unknown time */
ret = a_time ? -1 : 1;
else if (a_time != b_time)
ret = a_time > b_time ? -1 : 1;
else
ret = a_percentage < b_percentage ? -1 : 1;
}
As you can see the first "if (b_state != state)" is 'useless' as the
second if assigns ret all the time, both in the true branch and in the
else branch, so either it has to be removed or if the calculation is
indeed useful the second ifs/elses have to be tweaked
To manage notifications about this bug go to:
https://bugs.launchpad.net/indicator-power/+bug/1071757/+subscriptions