Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 11 Apr 2015 01:17:21 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r281389 - in stable: 10/usr.sbin/acpi/acpiconf 8/usr.sbin/acpi/acpiconf 9/usr.sbin/acpi/acpiconf
Message-ID:  <201504110117.t3B1HLAq068511@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Sat Apr 11 01:17:19 2015
New Revision: 281389
URL: https://svnweb.freebsd.org/changeset/base/281389

Log:
  MFC:	r281171
  
  Tidy up battery status information.  Remove a trailing white space.
  
  PR:		193671

Modified:
  stable/9/usr.sbin/acpi/acpiconf/acpiconf.c
Directory Properties:
  stable/9/usr.sbin/acpi/acpiconf/   (props changed)

Changes in other areas also in this revision:
Modified:
  stable/10/usr.sbin/acpi/acpiconf/acpiconf.c
  stable/8/usr.sbin/acpi/acpiconf/acpiconf.c
Directory Properties:
  stable/10/   (props changed)
  stable/8/usr.sbin/acpi/acpiconf/   (props changed)

Modified: stable/9/usr.sbin/acpi/acpiconf/acpiconf.c
==============================================================================
--- stable/9/usr.sbin/acpi/acpiconf/acpiconf.c	Sat Apr 11 01:06:59 2015	(r281388)
+++ stable/9/usr.sbin/acpi/acpiconf/acpiconf.c	Sat Apr 11 01:17:19 2015	(r281389)
@@ -136,16 +136,30 @@ acpi_battinfo(int num)
 	if (ioctl(acpifd, ACPIIO_BATT_GET_BATTINFO, &battio) == -1)
 		err(EX_IOERR, "get battery user info (%d) failed", num);
 	if (battio.battinfo.state != ACPI_BATT_STAT_NOT_PRESENT) {
-		printf("State:\t\t\t");
-		if (battio.battinfo.state == 0)
-			printf("high ");
-		if (battio.battinfo.state & ACPI_BATT_STAT_CRITICAL)
-			printf("critical ");
-		if (battio.battinfo.state & ACPI_BATT_STAT_DISCHARG)
-			printf("discharging ");
-		if (battio.battinfo.state & ACPI_BATT_STAT_CHARGING)
-			printf("charging ");
-		printf("\n");
+		const char *state;
+		switch (battio.battinfo.state & ACPI_BATT_STAT_BST_MASK) {
+		case 0:
+			state = "high";
+			break;
+		case ACPI_BATT_STAT_DISCHARG:
+			state = "discharging";
+			break;
+		case ACPI_BATT_STAT_CHARGING:
+			state = "charging";
+			break;
+		case ACPI_BATT_STAT_CRITICAL:
+			state = "critical";
+			break;
+		case ACPI_BATT_STAT_DISCHARG | ACPI_BATT_STAT_CRITICAL:
+			state = "critical discharging";
+			break;
+		case ACPI_BATT_STAT_CHARGING | ACPI_BATT_STAT_CRITICAL:
+			state = "critical charging";
+			break;
+		default:
+			state = "invalid";
+		}
+		printf("State:\t\t\t%s\n", state);
 		if (battio.battinfo.cap == -1)
 			printf("Remaining capacity:\tunknown\n");
 		else



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201504110117.t3B1HLAq068511>