* cleanup: use ARRAYSIZE, const'ifications and killed an unsed #define
authorBernd Petrovitsch <bernd@firmix.at>
Wed, 24 Oct 2007 13:44:26 +0000 (13:44 +0000)
committerBernd Petrovitsch <bernd@firmix.at>
Wed, 24 Oct 2007 13:44:26 +0000 (13:44 +0000)
src/linux/apm.c

index 5bf74b4..a44b4be 100644 (file)
@@ -36,7 +36,7 @@
  * to the project. For more information see the website or contact
  * the copyright holders.
  *
- * $Id: apm.c,v 1.18 2007/04/25 22:08:17 bernd67 Exp $
+ * $Id: apm.c,v 1.19 2007/10/24 13:44:26 bernd67 Exp $
  */
 
 /*
@@ -70,10 +70,7 @@ struct linux_apm_info
 
 
 /* ACPI related stuff */
-
-#define ACPI_PROC "/proc/acpi/info"
-
-static const char * acpi_info[] = 
+static const char * const acpi_info[] = 
   {
     "/proc/acpi/battery/0/info",
     "/proc/acpi/battery/1/info",
@@ -82,7 +79,7 @@ static const char * acpi_info[] =
     "/proc/acpi/battery/BAT1/info" 
   };
 
-static const char * acpi_state[] =
+static const char * const acpi_state[] =
   {    
     "/proc/acpi/battery/0/status",
     "/proc/acpi/battery/1/status",
@@ -92,17 +89,17 @@ static const char * acpi_state[] =
   };
 
 
-#define ACPI_BT_CNT  (sizeof(acpi_state) / sizeof(char *))
+#define ACPI_BT_CNT  ARRAYSIZE(acpi_state)
 
 
-static const char * acpi_ac[] = 
+static const char * const acpi_ac[] = 
   {    
     "/proc/acpi/ac_adapter/0/status",
     "/proc/acpi/ac_adapter/AC/state",
     "/proc/acpi/ac_adapter/ACAD/state" 
   };
 
-#define ACPI_AC_CNT  (sizeof(acpi_ac) / sizeof(char *))
+#define ACPI_AC_CNT  ARRAYSIZE(acpi_ac)
 
 
 #define USE_APM    1
@@ -213,7 +210,7 @@ apm_read_apm(struct olsr_apm_info *ainfo)
         &lainfo.battery_time,
         units);
 
-  lainfo.using_minutes = !strncmp(units, "min", 3) ? 1 : 0;
+  lainfo.using_minutes = strncmp(units, "min", 3) ? 0 : 1;
 
   /*
    * Should take care of old APM type info here
@@ -248,7 +245,6 @@ apm_read_acpi(struct olsr_apm_info *ainfo)
   
   printf("READING ACPI\n");
 
-
   if(fd_index < 0)
     {
       /* No battery was found or AC power was detected */