kvm_write: fix -Wcast-qual warning in pointer arithmetic argument
Cast buf to const char * when doing arithmetic operation to match
cp's type.
MFC after: 1 week
Sponsored by: Dell EMC Isilon
Differential D10082
kvm_write: fix -Wcast-qual warning in pointer arithmetic argument Authored by ngie on Mar 21 2017, 7:24 PM. Tags None Referenced Files
Details kvm_write: fix -Wcast-qual warning in pointer arithmetic argument Cast buf to const char * when doing arithmetic operation to match MFC after: 1 week
Diff Detail
Event TimelineComment Actions Why not just cast buf (const void *) to const char * to match cp? This is not a situation where DECONST is actually needed. Comment Actions clang 4.0.0 and gcc 6.3.0 both don't like that. clang: /usr/src/lib/libkvm/kvm.c:479:26: error: arithmetic on pointers to void is a GNU extension [-Werror,-Wpointer-arith]
return ((const void*)cp - buf);
~~~~~~~~~~~~~~~ ^ ~~~
1 error generated.
*** Error code 1gcc: /usr/src/lib/libkvm/kvm.c: In function 'kvm_write':
/usr/src/lib/libkvm/kvm.c:479:26: error: pointer of type 'void *' used in subtraction [-Werror=pointer-arith]
return ((const void*)cp - buf);
^
cc1: all warnings being treated as errors
*** Error code 1
Stop.
make: stopped in /usr/src/lib/libkvmComment Actions Per cem/vangyzen: don't use __DECONST (overkill); use const char * cast instead to |