summaryrefslogtreecommitdiff
path: root/net/net-snmp/patches/patch-es
blob: b7630418bce85c1680d181351d27f29d90f71e5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$NetBSD: patch-es,v 1.1 2006/10/02 00:09:55 seb Exp $

--- agent/mibgroup/ucd-snmp/memory_netbsd1.c.orig	2005-08-17 12:36:14.000000000 +0000
+++ agent/mibgroup/ucd-snmp/memory_netbsd1.c
@@ -163,7 +163,7 @@ var_extensible_mem(struct variable *vp,
     static char     errmsg[1024];
 
     static struct uvmexp uvmexp;
-    int             uvmexp_size = sizeof(uvmexp);
+    size_t          uvmexp_size = sizeof(uvmexp);
     int             uvmexp_mib[] = { CTL_VM, VM_UVMEXP };
     static struct vmtotal total;
     size_t          total_size = sizeof(total);
@@ -179,13 +179,22 @@ var_extensible_mem(struct variable *vp,
     /*
      * Memory info 
      */
-    sysctl(uvmexp_mib, 2, &uvmexp, &uvmexp_size, NULL, 0);
-    sysctl(total_mib, 2, &total, &total_size, NULL, 0);
+    if (sysctl(uvmexp_mib, 2, &uvmexp, &uvmexp_size, NULL, 0) == -1) {
+        snmp_log(LOG_ERR, "sysctl VM_UVMEXP failed (errno %d)\n", errno);
+        return NULL;
+    }
+    if (sysctl(total_mib, 2, &total, &total_size, NULL, 0) == -1) {
+        snmp_log(LOG_ERR, "sysctl VM_METER failed (errno %d)\n", errno);
+        return NULL;
+    }
 
     /*
      * Physical memory 
      */
-    sysctl(phys_mem_mib, 2, &phys_mem, &phys_mem_size, NULL, 0);
+    if (sysctl(phys_mem_mib, 2, &phys_mem, &phys_mem_size, NULL, 0) == -1) {
+        snmp_log(LOG_ERR, "sysctl HW_USERMEM failed (errno %d)\n", errno);
+        return NULL;
+    }
 
     long_ret = 0;               /* set to 0 as default */