aboutsummaryrefslogtreecommitdiff
path: root/modules/devices
diff options
context:
space:
mode:
Diffstat (limited to 'modules/devices')
-rw-r--r--modules/devices/battery.c5
-rw-r--r--modules/devices/inputdevices.c8
-rw-r--r--modules/devices/spd-decode.c5
-rw-r--r--modules/devices/storage.c12
-rw-r--r--modules/devices/usb.c12
-rw-r--r--modules/devices/x86/processor.c2
6 files changed, 25 insertions, 19 deletions
diff --git a/modules/devices/battery.c b/modules/devices/battery.c
index 37416dbb..09c84eeb 100644
--- a/modules/devices/battery.c
+++ b/modules/devices/battery.c
@@ -174,7 +174,10 @@ __scan_battery_acpi(void)
}
if (g_str_equal(present, "yes")) {
- charge_rate = atof(remaining) / atof(capacity);
+ if (remaining && capacity)
+ charge_rate = atof(remaining) / atof(capacity);
+ else
+ charge_rate = 0;
battery_list = h_strdup_cprintf("\n[Battery: %s]\n"
"State=%s (load: %s)\n"
diff --git a/modules/devices/inputdevices.c b/modules/devices/inputdevices.c
index c280e218..31f51fbb 100644
--- a/modules/devices/inputdevices.c
+++ b/modules/devices/inputdevices.c
@@ -46,7 +46,7 @@ __scan_input_devices(void)
FILE *dev;
gchar buffer[128];
gchar *tmp, *name = NULL, *phys = NULL;
- gint bus, vendor, product, version;
+ gint bus = 0, vendor, product, version;
int d = 0, n = 0;
dev = fopen("/proc/bus/input/devices", "r");
@@ -87,7 +87,7 @@ __scan_input_devices(void)
d = 4; //INPUT_UNKNOWN;
break;
case '\n':
- if (strstr(name, "PC Speaker")) {
+ if (name && strstr(name, "PC Speaker")) {
d = 3; // INPUT_PCSPKR
}
@@ -123,12 +123,12 @@ __scan_input_devices(void)
"Version=0x%x\n",
strhash, product, version);
- if (phys[1] != 0) {
+ if (phys && phys[1] != 0) {
strhash = h_strdup_cprintf("Connected to=%s\n",
strhash, phys);
}
- if (strstr(phys,"ir")) {
+ if (phys && strstr(phys, "ir")) {
strhash = h_strdup_cprintf("InfraRed port=yes\n",
strhash);
}
diff --git a/modules/devices/spd-decode.c b/modules/devices/spd-decode.c
index 2a72725b..bb22c1b7 100644
--- a/modules/devices/spd-decode.c
+++ b/modules/devices/spd-decode.c
@@ -633,7 +633,7 @@ static int parity(int value)
static void decode_sdr_module_size(unsigned char *bytes, int *size)
{
- int i, k;
+ int i, k = 0;
i = (bytes[3] & 0x0f) + (bytes[4] & 0x0f) - 17;
if (bytes[5] <= 8 && bytes[17] <= 8) {
@@ -1154,7 +1154,7 @@ static void decode_module_manufacturer(unsigned char *bytes,
do {
ai++;
- } while ((--len && (first = *bytes++ == 0x7f)));
+ } while ((--len && (*bytes++ == 0x7f)));
first = *--bytes;
if (ai == 0) {
@@ -1288,6 +1288,7 @@ static gchar *decode_dimms(GSList *dimm_list, gboolean use_sysfs)
break;
default:
DEBUG("Unsupported EEPROM type: %s\n", ram_types[ram_type]);
+ continue;
}
read_spd(spd_path, 64, 64, use_sysfs, bytes);
diff --git a/modules/devices/storage.c b/modules/devices/storage.c
index 23ab1de2..a9dfd665 100644
--- a/modules/devices/storage.c
+++ b/modules/devices/storage.c
@@ -36,10 +36,10 @@ __scan_scsi_devices(void)
FILE *proc_scsi;
gchar buffer[256], *buf;
gint n = 0;
- gint scsi_controller;
- gint scsi_channel;
- gint scsi_id;
- gint scsi_lun;
+ gint scsi_controller = 0;
+ gint scsi_channel = 0;
+ gint scsi_id = 0 ;
+ gint scsi_lun = 0;
gchar *vendor = NULL, *revision = NULL, *model = NULL;
gchar *scsi_storage_list;
@@ -96,7 +96,7 @@ __scan_scsi_devices(void)
};
int i;
- if (strstr(model, "Flash Disk")) {
+ if (model && strstr(model, "Flash Disk")) {
type = "Flash Disk";
icon = "usbfldisk";
} else {
@@ -146,6 +146,8 @@ __scan_scsi_devices(void)
g_free(model);
g_free(revision);
g_free(vendor);
+
+ scsi_controller = scsi_channel = scsi_id = scsi_lun = 0;
}
}
fclose(proc_scsi);
diff --git a/modules/devices/usb.c b/modules/devices/usb.c
index 39914dd0..f58476eb 100644
--- a/modules/devices/usb.c
+++ b/modules/devices/usb.c
@@ -138,7 +138,7 @@ gboolean __scan_usb_procfs(void)
FILE *dev;
gchar buffer[128];
gchar *tmp, *manuf = NULL, *product = NULL, *mxpwr;
- gint bus, level, port, classid, trash;
+ gint bus, level, port = 0, classid = 0, trash;
gint vendor, prodid;
gfloat ver, rev, speed;
int n = 0;
@@ -183,7 +183,7 @@ gboolean __scan_usb_procfs(void)
tmp = g_strdup_printf("USB%d", ++n);
- if (*product == '\0') {
+ if (product && *product == '\0') {
g_free(product);
if (classid == 9) {
product = g_strdup_printf("USB %.2f Hub", ver);
@@ -195,7 +195,6 @@ gboolean __scan_usb_procfs(void)
}
}
-
if (classid == 9) { /* hub */
usb_list = h_strdup_cprintf("[%s#%d]\n",
usb_list, product, n);
@@ -241,6 +240,7 @@ gboolean __scan_usb_procfs(void)
g_free(product);
manuf = g_strdup("");
product = g_strdup("");
+ port = classid = 0;
}
}
@@ -252,7 +252,7 @@ gboolean __scan_usb_procfs(void)
void __scan_usb_lsusb_add_device(char *buffer, FILE *lsusb, int usb_device_number)
{
gint bus, device, vendor_id, product_id;
- gchar *product, *vendor, *max_power, *tmp, *strhash;
+ gchar *product = NULL, *vendor = NULL, *max_power, *tmp, *strhash;
sscanf(buffer, "Bus %d Device %d: ID %x:%x",
&bus, &device, &vendor_id, &product_id);
@@ -271,7 +271,7 @@ void __scan_usb_lsusb_add_device(char *buffer, FILE *lsusb, int usb_device_numbe
}
tmp = g_strdup_printf("USB%d", usb_device_number);
- usb_list = h_strdup_cprintf("$%s$%s=\n", usb_list, tmp, product);
+ usb_list = h_strdup_cprintf("$%s$%s=\n", usb_list, tmp, product ? product : "Unknown");
strhash = g_strdup_printf("[Device Information]\n"
"Product=%s\n"
@@ -284,7 +284,7 @@ void __scan_usb_lsusb_add_device(char *buffer, FILE *lsusb, int usb_device_numbe
"Product ID=0x%x\n"
"Bus=%d\n",
product,
- vendor,
+ vendor ? vendor : "Unknown",
max_power,
0.0f /* FIXME */,
0 /* FIXME */,
diff --git a/modules/devices/x86/processor.c b/modules/devices/x86/processor.c
index 0aa385ae..e70d1374 100644
--- a/modules/devices/x86/processor.c
+++ b/modules/devices/x86/processor.c
@@ -239,7 +239,7 @@ GSList *processor_scan(void)
__cache_obtain_info(processor, processor_number++);
}
- if (tmp[0] && tmp[1]) {
+ if (processor && tmp[0] && tmp[1]) {
tmp[0] = g_strstrip(tmp[0]);
tmp[1] = g_strstrip(tmp[1]);