aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro A. F. Pereira <leandro@hardinfo.org>2007-06-30 01:31:54 +0000
committerLeandro A. F. Pereira <leandro@hardinfo.org>2007-06-30 01:31:54 +0000
commit1f101bcb3952ce79440d0236313f3ed11cba2aaa (patch)
tree43d42b9665f52396b847c169ff4c312a8ecf9a15
parent2d366bc8caf8083b66deaa09435f2dc93ffc9a69 (diff)
Cleanups, fix crashes.
-rw-r--r--hardinfo2/Makefile.in4
-rw-r--r--hardinfo2/arch/common/users.h9
-rw-r--r--hardinfo2/arch/linux/common/battery.h7
-rw-r--r--hardinfo2/arch/linux/common/inputdevices.h6
-rw-r--r--hardinfo2/arch/linux/common/modules.h7
-rw-r--r--hardinfo2/arch/linux/common/net.h7
-rw-r--r--hardinfo2/arch/linux/common/os.h2
-rw-r--r--hardinfo2/arch/linux/common/pci.h11
-rw-r--r--hardinfo2/arch/linux/common/sensors.h15
-rw-r--r--hardinfo2/arch/linux/common/storage.h10
-rw-r--r--hardinfo2/arch/linux/common/usb.h5
-rw-r--r--hardinfo2/benchmark.c23
-rw-r--r--hardinfo2/expr.c7
-rw-r--r--hardinfo2/syncmanager.c6
14 files changed, 50 insertions, 69 deletions
diff --git a/hardinfo2/Makefile.in b/hardinfo2/Makefile.in
index 6acd957a..d02e6e3f 100644
--- a/hardinfo2/Makefile.in
+++ b/hardinfo2/Makefile.in
@@ -1,6 +1,6 @@
-CC = gcc -O3 $(ARCHOPTS)
-CCSLOW = gcc -O0
+CC = gcc $(ARCHOPTS) -O3 -fomit-frame-pointer -funroll-loops
+CCSLOW = gcc -O0 -g
CFLAGS = -fPIC -pipe -Wall -g $(GTK_CFLAGS) $(GLADE_CFLAGS) $(SOUP_CFLAGS) -I.
# ----------------------------------------------------------------------------
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;
diff --git a/hardinfo2/benchmark.c b/hardinfo2/benchmark.c
index 7f5025de..d76a37c3 100644
--- a/hardinfo2/benchmark.c
+++ b/hardinfo2/benchmark.c
@@ -22,6 +22,9 @@
#include <config.h>
#include <syncmanager.h>
+#include <sys/time.h>
+#include <sys/resource.h>
+
enum {
BENCHMARK_ZLIB,
BENCHMARK_FIB,
@@ -151,45 +154,53 @@ gchar *callback_sha1()
return benchmark_include_results_reverse(bench_results[BENCHMARK_SHA1], "CPU SHA1");
}
+#define RUN_WITH_HIGH_PRIORITY(fn) \
+ do { \
+ int old_priority = getpriority(PRIO_PROCESS, 0); \
+ setpriority(PRIO_PROCESS, 0, -20); \
+ fn(); \
+ setpriority(PRIO_PROCESS, 0, old_priority); \
+ } while (0);
+
void scan_zlib(gboolean reload)
{
SCAN_START();
- benchmark_zlib();
+ RUN_WITH_HIGH_PRIORITY(benchmark_zlib);
SCAN_END();
}
void scan_raytr(gboolean reload)
{
SCAN_START();
- benchmark_raytrace();
+ RUN_WITH_HIGH_PRIORITY(benchmark_raytrace);
SCAN_END();
}
void scan_bfsh(gboolean reload)
{
SCAN_START();
- benchmark_fish();
+ RUN_WITH_HIGH_PRIORITY(benchmark_fish);
SCAN_END();
}
void scan_md5(gboolean reload)
{
SCAN_START();
- benchmark_md5();
+ RUN_WITH_HIGH_PRIORITY(benchmark_md5);
SCAN_END();
}
void scan_fib(gboolean reload)
{
SCAN_START();
- benchmark_fib();
+ RUN_WITH_HIGH_PRIORITY(benchmark_fib);
SCAN_END();
}
void scan_sha1(gboolean reload)
{
SCAN_START();
- benchmark_sha1();
+ RUN_WITH_HIGH_PRIORITY(benchmark_sha1);
SCAN_END();
}
diff --git a/hardinfo2/expr.c b/hardinfo2/expr.c
index 2210a4e6..3f4707f5 100644
--- a/hardinfo2/expr.c
+++ b/hardinfo2/expr.c
@@ -168,12 +168,7 @@ GSList *math_string_to_infix(gchar *string)
} else if (strchr("-.1234567890", *expr)) {
gfloat value;
- sscanf(expr, "%f", &value);
-
- while (*expr && strchr(".1234567890", *expr))
- expr++;
- expr--;
-
+ expr += sscanf(expr, "%f", &value);
infix = g_slist_append(infix, new_value(value));
} else if (!isspace(*expr)) {
g_print("Invalid token: [%c][%d]\n", *expr, *expr);
diff --git a/hardinfo2/syncmanager.c b/hardinfo2/syncmanager.c
index 7646990f..f25f0457 100644
--- a/hardinfo2/syncmanager.c
+++ b/hardinfo2/syncmanager.c
@@ -631,12 +631,16 @@ static SyncDialog *sync_dialog_new(void)
dialog = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(dialog), "Network Updater");
- gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_window_set_icon(GTK_WINDOW(dialog),
+ icon_cache_get_pixbuf("syncmanager.png"));
gtk_window_set_default_size(GTK_WINDOW(dialog), 420, 260);
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gtk_window_set_type_hint(GTK_WINDOW(dialog),
GDK_WINDOW_TYPE_HINT_DIALOG);
+ gtk_container_set_border_width(GTK_CONTAINER(dialog), 5);
+
dialog1_vbox = GTK_DIALOG(dialog)->vbox;
gtk_box_set_spacing(GTK_BOX(dialog1_vbox), 5);
gtk_container_set_border_width(GTK_CONTAINER(dialog1_vbox), 4);