Skip to content

Commit 0766c3e

Browse files
committed
Finish switch to NANs.
1 parent 6bb4985 commit 0766c3e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

libbattery.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ battery_fill_info(struct battery_info *i)
128128
}
129129

130130
i->state = NO_BATTERY; /* assume we're just plugged in. */
131-
i->seconds = -1;
132-
i->fraction = -1;
133-
i->voltage = -1;
131+
i->seconds = NAN;
132+
i->fraction = NAN;
133+
i->voltage = NAN;
134+
i->current = NAN;
135+
i->temperature = NAN;
134136

135137
while ((dent = readdir(dirp)) != NULL) {
136138
const char *name = dent->d_name;
@@ -213,8 +215,8 @@ battery_fill_info(struct battery_info *i)
213215
* (failing a report of minutes, we'll take the highest percent.)
214216
*/
215217

216-
if ((secs < 0) && (i->seconds < 0)) {
217-
if ((pct < 0) && (i->fraction < 0)) {
218+
if ((secs < 0) && (isnan(i->seconds))) {
219+
if ((pct < 0) && (isnan(i->fraction))) {
218220
choose = true; /* at least we know there's a battery. */
219221
} else if (pct > i->fraction * 100) {
220222
choose = true;

0 commit comments

Comments
 (0)