diff options
| author | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-06-30 01:31:54 +0000 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2007-06-30 01:31:54 +0000 | 
| commit | 1f101bcb3952ce79440d0236313f3ed11cba2aaa (patch) | |
| tree | 43d42b9665f52396b847c169ff4c312a8ecf9a15 /hardinfo2/arch | |
| parent | 2d366bc8caf8083b66deaa09435f2dc93ffc9a69 (diff) | |
Cleanups, fix crashes.
Diffstat (limited to 'hardinfo2/arch')
| -rw-r--r-- | hardinfo2/arch/common/users.h | 9 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/battery.h | 7 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/inputdevices.h | 6 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/modules.h | 7 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/net.h | 7 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/os.h | 2 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/pci.h | 11 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/sensors.h | 15 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/storage.h | 10 | ||||
| -rw-r--r-- | hardinfo2/arch/linux/common/usb.h | 5 | 
10 files changed, 25 insertions, 54 deletions
| diff --git a/hardinfo2/arch/common/users.h b/hardinfo2/arch/common/users.h index 84cec9d9..5889dc0a 100644 --- a/hardinfo2/arch/common/users.h +++ b/hardinfo2/arch/common/users.h @@ -4,14 +4,7 @@ static gchar *sys_users = NULL,  static gboolean  remove_users(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "USER", 4)) { -	/* -         * g_free((gchar *) key); -	 * g_free((GtkTreeIter *) value); -         */ -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "USER");  }  static void diff --git a/hardinfo2/arch/linux/common/battery.h b/hardinfo2/arch/linux/common/battery.h index 20979e48..072ac00c 100644 --- a/hardinfo2/arch/linux/common/battery.h +++ b/hardinfo2/arch/linux/common/battery.h @@ -209,4 +209,11 @@ __scan_battery(void)      __scan_battery_acpi();      __scan_battery_apm(); +     +    if (*battery_list == '\0') { +        g_free(battery_list); +         +        battery_list = g_strdup("[No batteries]\n" +                                "No batteries found on this system=\n"); +    }  } diff --git a/hardinfo2/arch/linux/common/inputdevices.h b/hardinfo2/arch/linux/common/inputdevices.h index 1a5baff8..a7102335 100644 --- a/hardinfo2/arch/linux/common/inputdevices.h +++ b/hardinfo2/arch/linux/common/inputdevices.h @@ -21,11 +21,7 @@ static gchar *input_icons = NULL;  static gboolean  remove_input_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "INP", 3)) { -	return TRUE; -    } - -    return FALSE; +    return g_str_has_prefix(key, "INP");  }  static struct { diff --git a/hardinfo2/arch/linux/common/modules.h b/hardinfo2/arch/linux/common/modules.h index 9b895ee8..54e77ddb 100644 --- a/hardinfo2/arch/linux/common/modules.h +++ b/hardinfo2/arch/linux/common/modules.h @@ -26,12 +26,7 @@  static gboolean  remove_module_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "MOD", 3)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value); -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "MOD");  }  static void diff --git a/hardinfo2/arch/linux/common/net.h b/hardinfo2/arch/linux/common/net.h index cd8b8706..18135568 100644 --- a/hardinfo2/arch/linux/common/net.h +++ b/hardinfo2/arch/linux/common/net.h @@ -134,12 +134,7 @@ net_get_iface_type(gchar *name)  static gboolean  remove_net_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "NET", 4)) { -	g_free((gchar *) key); -	g_free((GtkTreeIter *) value); -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "NET");  }  static void diff --git a/hardinfo2/arch/linux/common/os.h b/hardinfo2/arch/linux/common/os.h index d30146ef..0fe06709 100644 --- a/hardinfo2/arch/linux/common/os.h +++ b/hardinfo2/arch/linux/common/os.h @@ -162,8 +162,6 @@ computer_get_os(void)  	}  	if (g_file_test(distro_db[i].file, G_FILE_TEST_EXISTS)) { - -  	    FILE *distro_ver;  	    char buf[128]; diff --git a/hardinfo2/arch/linux/common/pci.h b/hardinfo2/arch/linux/common/pci.h index e50691d0..d6a59bcb 100644 --- a/hardinfo2/arch/linux/common/pci.h +++ b/hardinfo2/arch/linux/common/pci.h @@ -24,14 +24,8 @@ __scan_pci(void)      gchar *category = NULL, *name = NULL;      gint n = 0; -    //if (g_file_test("/usr/bin/gksudo", G_FILE_TEST_EXISTS)) { -    //  lspci = popen("gksudo '/bin/lspci -v'", "r"); -    //} else { -    lspci = popen(LSPCI, "r"); -    //} - -    if (!lspci) { -	return; +    if (!(lspci = popen(LSPCI, "r"))) { +      goto pci_error;      }      gchar *icon; @@ -190,6 +184,7 @@ __scan_pci(void)      }      if (pclose(lspci)) { +pci_error:          /* error (no pci, perhaps?) */          pci_list = g_strconcat(pci_list, "No PCI devices found=\n", NULL);      } else if (strhash) { diff --git a/hardinfo2/arch/linux/common/sensors.h b/hardinfo2/arch/linux/common/sensors.h index 3303d5d2..460c628b 100644 --- a/hardinfo2/arch/linux/common/sensors.h +++ b/hardinfo2/arch/linux/common/sensors.h @@ -162,9 +162,6 @@ static void read_sensors_hwmon(void)  	    read_sensor_labels(driver);  	} -	sensors = g_strdup_printf("%s[Driver Info]\n" -				  "Name=%s\n", sensors, driver); -  	sensors = g_strconcat(sensors, "[Cooling Fans]\n", NULL);  	for (count = 1;; count++) {  	    path_sensor = @@ -258,9 +255,8 @@ static void read_sensors_acpi(void)  	if ((tz = g_dir_open(path_tz, 0, NULL))) {  	    const gchar *entry; +	    gchar *temp = ""; -	    sensors = -		g_strdup_printf("%s\n[ACPI Thermal Zone]\n", sensors);  	    while ((entry = g_dir_read_name(tz))) {  		gchar *path = @@ -272,13 +268,18 @@ static void read_sensors_acpi(void)  		    sscanf(contents, "temperature: %d C", &temperature); -		    sensors = g_strdup_printf("%s\n%s=%d\302\260C\n", -					      sensors, entry, temperature); +		    temp = g_strdup_printf("%s\n%s=%d\302\260C\n", +					      temp, entry, temperature);  		    g_free(contents);  		}  	    } +	    if (*temp != '\0') +    	        sensors = +	    	    g_strdup_printf("%s\n[ACPI Thermal Zone]\n%s", +	    	                    sensors, temp); +  	    g_dir_close(tz);  	}      } diff --git a/hardinfo2/arch/linux/common/storage.h b/hardinfo2/arch/linux/common/storage.h index 836ba7ea..03081e2f 100644 --- a/hardinfo2/arch/linux/common/storage.h +++ b/hardinfo2/arch/linux/common/storage.h @@ -21,10 +21,7 @@ static gchar *storage_icons = "";  static gboolean  remove_scsi_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "SCSI", 4)) { -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "SCSI");  }  /* SCSI support by Pascal F.Martin <pascalmartin@earthlink.net> */ @@ -147,10 +144,7 @@ __scan_scsi_devices(void)  static gboolean  remove_ide_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "IDE", 3)) { -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "IDE");  }  void diff --git a/hardinfo2/arch/linux/common/usb.h b/hardinfo2/arch/linux/common/usb.h index d59f5f01..59f6785c 100644 --- a/hardinfo2/arch/linux/common/usb.h +++ b/hardinfo2/arch/linux/common/usb.h @@ -19,10 +19,7 @@  static gboolean  remove_usb_devices(gpointer key, gpointer value, gpointer data)  { -    if (!strncmp((gchar *) key, "USB", 3)) { -	return TRUE; -    } -    return FALSE; +    return g_str_has_prefix(key, "USB");  }  static gchar *usb_list = NULL; | 
