Browse code

Make valgrind happy. Fix typos.

Shawn Webb authored on 2013/11/05 07:03:33
Showing 1 changed files
... ...
@@ -35,10 +35,10 @@
35 35
 
36 36
 #include "hostid.h"
37 37
 #include "libclamav/md5.h"
38
+#include "libclamav/others.h"
38 39
 
39 40
 struct device *get_device_entry(struct device *devices, size_t *ndevices, const char *name)
40 41
 {
41
-    struct device *device;
42 42
     void *p;
43 43
     size_t i;
44 44
 
... ...
@@ -63,19 +63,18 @@ struct device *get_device_entry(struct device *devices, size_t *ndevices, const
63 63
             devices = p;
64 64
 
65 65
             memset(devices + *ndevices, 0x00, sizeof(struct device));
66
-            (*ndevices)++;
66
+            *ndevices = *ndevices + 1;
67 67
         }
68 68
     } else {
69
-        devices = calloc(1, sizeof(device));
69
+        devices = calloc(1, sizeof(struct device));
70 70
         if (!(devices))
71 71
             return NULL;
72 72
 
73
-        device = devices;
74 73
         *ndevices = 1;
75 74
     }
76 75
 
77
-    if (!(devices[*ndevices - 1].name) && name)
78
-        device[*ndevices - 1].name = strdup(name);
76
+    if (*ndevices && !(devices[*ndevices - 1].name) && name)
77
+        devices[*ndevices - 1].name = strdup(name);
79 78
 
80 79
     return devices;
81 80
 }
... ...
@@ -156,6 +155,11 @@ struct device *get_devices(void)
156 156
     /* This is the Linux version of getting the MAC addresses */
157 157
 #if defined(SIOCGIFHWADDR)
158 158
     for (i=0; i < ndevices; i++) {
159
+        cli_warnmsg("devices[%lu]: %s\n", i, devices[i].name);
160
+
161
+        if (!(devices[i].name))
162
+            continue;
163
+
159 164
         memset(&ifr, 0x00, sizeof(struct ifreq));
160 165
         memset(devices[i].mac, 0x00, sizeof(devices[i].mac));
161 166