Make pointer argument to kread_string() const since the kernel structure

field is const, and then employ __DECONST before getting into the kvm
code.  This eliminates a gcc 4.2 warning about losing constification.

__DECONST advice from:	sam
This commit is contained in:
Robert Watson 2007-05-21 18:16:04 +00:00
parent 54c41bc6a6
commit 448036945e

View File

@ -26,6 +26,7 @@
* $FreeBSD$
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
@ -253,14 +254,14 @@ kread(kvm_t *kvm, void *kvm_pointer, void *address, size_t size,
}
static int
kread_string(kvm_t *kvm, void *kvm_pointer, char *buffer, int buflen)
kread_string(kvm_t *kvm, const void *kvm_pointer, char *buffer, int buflen)
{
ssize_t ret;
int i;
for (i = 0; i < buflen; i++) {
ret = kvm_read(kvm, (unsigned long)kvm_pointer + i,
&(buffer[i]), sizeof(char));
ret = kvm_read(kvm, __DECONST(unsigned long, kvm_pointer) +
i, &(buffer[i]), sizeof(char));
if (ret < 0)
return (MEMSTAT_ERROR_KVM);
if ((size_t)ret != sizeof(char))