Skip to content

Commit e6ebd45

Browse files
authored
use a ternary to replace the if check
1 parent 8f548f7 commit e6ebd45

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

netbsd/Platform.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ void Platform_getBattery(double* percent, ACPresence* isOnAC) {
512512
*isOnAC = isConnected ? AC_PRESENT : AC_ABSENT;
513513
}
514514
}
515-
if (totalCapacity != 0) {
516-
*percent = ((double)totalCharge / (double)totalCapacity) * 100.0;
517-
}
515+
*percent = (totalCapacity > 0)
516+
? ((double)totalCharge / (double)totalCapacity) * 100.0
517+
: NAN;
518518

519519
error:
520520
if (fd != -1)

0 commit comments

Comments
 (0)