AIX: Fix a few compiler warnings
Avoid that the following compiler warnings are reported:
- Assignment discards const.
- Unused local variable.
- Mismatch between format string and argument list.
Also correct the indentation of two Solaris-specific code statements.
diff --git a/agent/kernel.c b/agent/kernel.c
index 3f0e488..82e4af6 100644
--- a/agent/kernel.c
+++ b/agent/kernel.c
@@ -191,7 +191,7 @@
return 0;
if ((retsiz = klseek((off_t) off)) != off) {
- snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz);
+ snmp_log(LOG_ERR, "klookup(%lx, %p, %zd): ", off, target, siz);
snmp_log_perror("klseek");
return (0);
}
@@ -201,12 +201,12 @@
* these happen too often on too many architectures to print them
* unless we're in debugging mode. People get very full log files.
*/
- snmp_log(LOG_ERR, "klookup(%lx, %p, %d): ", off, target, siz);
+ snmp_log(LOG_ERR, "klookup(%lx, %p, %zd): ", off, target, siz);
snmp_log_perror("klread");
}
return (0);
}
- DEBUGMSGTL(("verbose:kernel:klookup", "klookup(%lx, %p, %d) succeeded", off, target, siz));
+ DEBUGMSGTL(("verbose:kernel:klookup", "klookup(%lx, %p, %zd) succeeded", off, target, siz));
return (1);
}
diff --git a/agent/mibgroup/host/hr_system.c b/agent/mibgroup/host/hr_system.c
index 2a2b049..cbc8fc8 100644
--- a/agent/mibgroup/host/hr_system.c
+++ b/agent/mibgroup/host/hr_system.c
@@ -215,9 +215,6 @@
char bootparam[8192];
#endif
time_t now;
-#if !(defined(NR_TASKS) || defined(solaris2) || defined(hpux10) || defined(hpux11))
- int nproc = 0;
-#endif
#ifdef linux
FILE *fp;
#endif
@@ -286,19 +283,28 @@
#if defined(NR_TASKS)
long_return = NR_TASKS; /* <linux/tasks.h> */
#elif NETSNMP_CAN_USE_SYSCTL && defined(CTL_KERN) && defined(KERN_MAXPROC)
- buf_size = sizeof(nproc);
- if (sysctl(maxproc_mib, 2, &nproc, &buf_size, NULL, 0) < 0)
- return NULL;
- long_return = nproc;
+ {
+ int nproc = 0;
+
+ buf_size = sizeof(nproc);
+ if (sysctl(maxproc_mib, 2, &nproc, &buf_size, NULL, 0) < 0)
+ return NULL;
+ long_return = nproc;
+ }
#elif defined(hpux10) || defined(hpux11)
pstat_getstatic(&pst_buf, sizeof(struct pst_static), 1, 0);
long_return = pst_buf.max_proc;
#elif defined(solaris2)
- long_return=get_max_solaris_processes();
- if(long_return == -1) return NULL;
+ long_return = get_max_solaris_processes();
+ if (long_return == -1)
+ return NULL;
#elif defined(NPROC_SYMBOL)
- auto_nlist(NPROC_SYMBOL, (char *) &nproc, sizeof(int));
- long_return = nproc;
+ {
+ int nproc = 0;
+
+ auto_nlist(NPROC_SYMBOL, (char *) &nproc, sizeof(nproc));
+ long_return = nproc;
+ }
#else
#if NETSNMP_NO_DUMMY_VALUES
return NULL;
diff --git a/snmplib/snmpUnixDomain.c b/snmplib/snmpUnixDomain.c
index 8b6eec8..036e95a 100644
--- a/snmplib/snmpUnixDomain.c
+++ b/snmplib/snmpUnixDomain.c
@@ -245,7 +245,7 @@
}
DEBUGMSGTL(("netsnmp_unix", "accept succeeded (farend %p len %d)\n",
- farend, farendlen));
+ farend, (int) farendlen));
t->data = farend;
t->data_length = sizeof(struct sockaddr_un);
netsnmp_sock_buffer_set(newsock, SO_SNDBUF, 1, 0);
diff --git a/snmplib/system.c b/snmplib/system.c
index 02bf9f9..38ecfeb 100644
--- a/snmplib/system.c
+++ b/snmplib/system.c
@@ -779,7 +779,7 @@
struct nlist nl;
int kmem;
time_t lbolt;
- nl.n_name = "lbolt";
+ nl.n_name = (char *) "lbolt";
if(knlist(&nl, 1, sizeof(struct nlist)) != 0) return(0);
if(nl.n_type == 0 || nl.n_value == 0) return(0);
if((kmem = open("/dev/mem", 0)) < 0) return 0;