From 448036945ec71fb8eeb62507ae560df8d27b4c63 Mon Sep 17 00:00:00 2001 From: Robert Watson Date: Mon, 21 May 2007 18:16:04 +0000 Subject: [PATCH] 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 --- lib/libmemstat/memstat_malloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/libmemstat/memstat_malloc.c b/lib/libmemstat/memstat_malloc.c index b9b686f0777b..70320f5861d1 100644 --- a/lib/libmemstat/memstat_malloc.c +++ b/lib/libmemstat/memstat_malloc.c @@ -26,6 +26,7 @@ * $FreeBSD$ */ +#include #include #include #include @@ -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))