public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] gentoo-x86 commit in x11-plugins/wmacpiload-ac/files: wmacpiload-ac-acpi-fix-battery-unit.patch wmacpiload-ac-acpi-segfault.patch wmacpiload-ac-acpi-sys-temp-hwmon.patch
@ 2012-10-18 14:15 Michele Noberasco (s4t4n)
  0 siblings, 0 replies; only message in thread
From: Michele Noberasco (s4t4n) @ 2012-10-18 14:15 UTC (permalink / raw
  To: gentoo-commits

s4t4n       12/10/18 14:15:51

  Added:                wmacpiload-ac-acpi-fix-battery-unit.patch
                        wmacpiload-ac-acpi-segfault.patch
                        wmacpiload-ac-acpi-sys-temp-hwmon.patch
  Log:
  Revision bump. Closes bug #372417.
  
  (Portage version: 2.1.10.49/cvs/Linux x86_64)

Revision  Changes    Path
1.1                  x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-fix-battery-unit.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-fix-battery-unit.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-fix-battery-unit.patch?rev=1.1&content-type=text/plain

Index: wmacpiload-ac-acpi-fix-battery-unit.patch
===================================================================
--- wmacpiload-0.2.0/src/battery.c	2012-10-18 15:42:04.000000000 +0200
+++ wmacpiload-0.2.0.new/src/battery.c	2012-10-18 15:43:33.000000000 +0200
@@ -42,7 +42,8 @@
  ************************************************************************/
 
 /* used to parse the battery state file */
-#define CAPACITY_UNIT " mAh"
+#define CAPACITY_UNIT1 " mAh"
+#define CAPACITY_UNIT2 " mWh"
 
 /************************************************************************
  * Global constants definitions
@@ -164,7 +165,7 @@
             char *endptr;
 
             capacity = strtoul(buf, &endptr, 10);
-            if (strcmp(endptr, CAPACITY_UNIT) != 0) {
+            if (strcmp(endptr, CAPACITY_UNIT1) != 0 && strcmp(endptr, CAPACITY_UNIT2) != 0) {
                 fprintf(stderr,
                         "%s : Battery %s unplugged or unconsistent data\n",
                         PACKAGE, bat->name);
@@ -238,7 +239,7 @@
             char *endptr;
 
             remain = strtol(buf, &endptr, 10);
-            if (strcmp(endptr, CAPACITY_UNIT) == 0)
+            if (strcmp(endptr, CAPACITY_UNIT1) == 0 || strcmp(endptr, CAPACITY_UNIT2) == 0)
                 bat->percentage = (int) ((remain * 100.0) / bat->capacity);
             else
                 bat->percentage = -1;


1.1                  x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-segfault.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-segfault.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-segfault.patch?rev=1.1&content-type=text/plain

Index: wmacpiload-ac-acpi-segfault.patch
===================================================================
diff -ru wmacpiload-0.2.0/include/lib_acpi.h wmacpiload-0.2.0.new//include/lib_acpi.h
--- wmacpiload-0.2.0/include/lib_acpi.h	2005-07-21 21:33:19.000000000 -0400
+++ wmacpiload-0.2.0.new//include/lib_acpi.h	2011-06-20 19:53:30.458953984 -0400
@@ -32,7 +32,7 @@
  * Macros
  ************************************************************************/
 
-#  define ACPIDEV "/proc/acpi/info"
+#  define ACPIDEV "/proc/acpi/battery"
 
   /* use ? */
 #  ifndef ACPI_32_BIT_SUPPORT
diff -ru wmacpiload-0.2.0/src/dockapp.c wmacpiload-0.2.0.new//src/dockapp.c
--- wmacpiload-0.2.0/src/dockapp.c	2005-08-16 18:38:36.000000000 -0400
+++ wmacpiload-0.2.0.new//src/dockapp.c	2011-06-20 19:44:20.022684448 -0400
@@ -431,5 +431,6 @@
 void
 dockapp_cleanup(void)
 {
+  if (display != NULL)
     XCloseDisplay(display);
 }


1.1                  x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-sys-temp-hwmon.patch

file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-sys-temp-hwmon.patch?rev=1.1&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/x11-plugins/wmacpiload-ac/files/wmacpiload-ac-acpi-sys-temp-hwmon.patch?rev=1.1&content-type=text/plain

Index: wmacpiload-ac-acpi-sys-temp-hwmon.patch
===================================================================
diff -ru wmacpiload-0.2.0/src/lib_acpi.c wmacpiload-0.2.0.new//src/lib_acpi.c
--- wmacpiload-0.2.0/src/lib_acpi.c	2005-07-21 21:41:31.000000000 -0400
+++ wmacpiload-0.2.0.new//src/lib_acpi.c	2011-06-28 23:37:50.148092904 -0400
@@ -83,7 +83,7 @@
         if (!k->ac)
             fprintf(stderr, "%s : no AC adapter detected\n", PACKAGE);
 
-        n = snprintf(dir, FILENAME_MAX + 1, "%s%s", "/proc/acpi",
+        n = snprintf(dir, FILENAME_MAX + 1, "%s%s", "/sys/class",
                      thermal_zone_dir);
         if (n > FILENAME_MAX) {
             fprintf(stderr, "%s : file name too long, "
@@ -322,10 +322,10 @@
     n = strlen(searched);
 
     if (dest != NULL && dest_size > 0
-        && n > 0 && n < (sizeof buffer) - 1
+        && n < (sizeof buffer) - 1
         && file_name != NULL && (fd = fopen(file_name, "r")) != NULL) {
         while (fgets(buffer, sizeof buffer, fd) != NULL)
-            if (strncmp(buffer, searched, n) == 0) {
+            if (n == 0 || strncmp(buffer, searched, n) == 0) {
                 char *src;
                 char *end;
                 size_t len;
diff -ru wmacpiload-0.2.0/src/thermal.c wmacpiload-0.2.0.new//src/thermal.c
--- wmacpiload-0.2.0/src/thermal.c	2005-09-29 19:32:46.000000000 -0400
+++ wmacpiload-0.2.0.new//src/thermal.c	2011-06-29 00:18:24.851904854 -0400
@@ -30,12 +30,17 @@
 #endif
 
 #include <stdio.h>
+#include <errno.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 #include <dirent.h>
 #include "lib_acpi.h"
 #include "wmacpiload.h"
 #include "thermal.h"
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 
 /************************************************************************
  * Macro definitions
@@ -48,8 +53,10 @@
  * Global constants definitions
  ************************************************************************/
 
-const char *const thermal_zone_dir = "/thermal_zone/";
-const char *const thermal_zone_status_file = "/temperature";
+const char *const thermal_zone_dir = "/hwmon/";
+const char *const thermal_zone_status_file = "/temp1_input";
+const char *const thermal_zone_search[] = { "", "/device" };
+const int thermal_zone_MAX_SEARCH = 2;
 
 /************************************************************************
  * Function definitions
@@ -86,9 +93,24 @@
     }
     strcpy(tz->name, fd->d_name);
 
-    tz->tempfile =
-        strcat4("/proc/acpi", thermal_zone_dir, tz->name,
-                thermal_zone_status_file);
+    int i;
+    for (i=0; i < thermal_zone_MAX_SEARCH ; i++) {
+      char device_name[MAXSTRLEN+1];
+      char *tempfile;
+      struct stat tempstat;
+      snprintf(device_name, MAXSTRLEN, "%s%s", tz->name, thermal_zone_search[i]);
+      tempfile = 
+	strcat4("/sys/class", thermal_zone_dir, device_name, 
+	    thermal_zone_status_file);
+      if (stat(tempfile, &tempstat) == -1) {
+	if (verbose)
+		printf("Unable to read thermal zone '%s'\n", tempfile);
+      } else {
+	tz->tempfile = tempfile;
+	break;
+      }
+    }
+
     if (!tz->tempfile) {
         fprintf(stderr, "%s : could not allocate memory "
                 "for thermal zone tempfile concerning "
@@ -127,16 +149,19 @@
 
     if (tz != NULL) {
         if (parse_file(tz->tempfile,
-                       "temperature:", buf, sizeof buf) != NULL) {
+                       "", buf, sizeof buf) != NULL) {
             char *endptr;
 
             temp = strtoul(buf, &endptr, 10);
             /*
-             * The format is "temperature:    xx C" where xx is the
-             * temperature in celcius degrees. So we check if we have the
-             * " C" left in the buffer to see if all went well. 
+             * The format is "xxxxxx" where xx is the
+             * temperature in celcius degrees times 1000.
              */
-            if (strcmp(endptr, TEMP_UNIT) != 0) {
+	    errno = 0;
+	    if ((errno == ERANGE && (temp == LONG_MAX || temp == LONG_MIN) ) ||
+		(errno != 0 && temp == 0) ||
+		endptr == buf) {
+	      perror("strtol");
                 fprintf(stderr, "%s : Unconsistent temperature  "
                         "about thermal zone %s\n", PACKAGE, tz->name);
                 temp = 0;
@@ -144,7 +169,7 @@
         } else {
             temp = 0;
         }
-        tz->temp = temp;
+        tz->temp = temp / 1000;
     }
 }
 




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-18 14:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-18 14:15 [gentoo-commits] gentoo-x86 commit in x11-plugins/wmacpiload-ac/files: wmacpiload-ac-acpi-fix-battery-unit.patch wmacpiload-ac-acpi-segfault.patch wmacpiload-ac-acpi-sys-temp-hwmon.patch Michele Noberasco (s4t4n)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox