Staging: hv: Fix warning by casting a (const void *) to (void *)
Subsystems (2)
PATCH 4/4 Staging: hv: Fix warning by casting a (const void *) to (void *)
Fix compilation warning by casting the const void *Buffer variable into a void *.
--- drivers/staging/hv/Channel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/Channel.c +1 -1
@@ -787,7 +787,7 @@ VmbusChannelSendPacket( bufferList[0 ].Data = &desc; bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); - bufferList[1 ].Data = Buffer; + bufferList[1 ].Data = (void *)Buffer; bufferList[1 ].Length = BufferLen; bufferList[2 ].Data = &alignedData;
Signature · 5 lines
1.6.0.4 -- Nicolas Palix
Quoted 14 lines · Nicolas Palix
Fix compilation warning by casting the const void *Buffer variable into a void *.
Signed-off-by Nicolas Palix <[email protected]>--- drivers/staging/hv/Channel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/staging/hv/Channel.c +0
-0
drivers/staging/hv/Channel.c VmbusChannelSendPacket( · line 790
Quoted 5 lines
drivers/staging/hv/Channel.c +1
-1@@ -787,7 +787,7 @@ VmbusChannelSendPacket( bufferList[0 ].Data = &desc; bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); - bufferList[1 ].Data = Buffer; + bufferList[1 ].Data = (void *)Buffer;
Yeah, I thought about doing this as well, but it's wrong. If this buffer really isn't being modified, then the Data pointer needs to be const.
Or, if the Data pointer really is going to not be const, then the function parameters need to be changed, but that means lots of code needs to be changed.
Hank, what do you think is the correct thing to do here?
thanks,
greg k-h
Quoted 7 lines · Nicolas Palix
Quoted 5 lines
Fix compilation warning by casting the const void *Buffer variable into a void *.
Quoted 1 line
[....]
Quoted 24 lines
Quoted 10 lines
Signed-off-by Nicolas Palix <[email protected]>--- drivers/staging/hv/Channel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/staging/hv/Channel.c +0
-0drivers/staging/hv/Channel.c VmbusChannelSendPacket( · line 790
Quoted 5 lines
drivers/staging/hv/Channel.c +1
-1@@ -787,7 +787,7 @@ VmbusChannelSendPacket( bufferList[0 ].Data = &desc; bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); - bufferList[1 ].Data = Buffer; + bufferList[1 ].Data = (void *)Buffer;Yeah, I thought about doing this as well, but it's wrong. If this buffer really isn't being modified, then the Data pointer needs to be const.
Or, if the Data pointer really is going to not be const, then the function parameters need to be changed, but that means lots of code needs to be changed.
Quoted 5 lines
Hank, what do you think is the correct thing to do here?
thanks,
greg k-h
I think both will work. At some point in the past for this design was To leave open the possibility for having the buffer modified. Right Now I am pretty sure that it does not get modified.
I am not tied to using either void or const. What makes more sense, are The kernel guidelines that if it does not get modified to define it as const?
The only thing about changing the API signature is that it does trickle into A bunch of changes (primarily in Channel.[ch], ChannelInterface.[ch] and RingBuffer.[ch])
Thanks,
Hank.
Quoted 36 lines · Hank Janssen
Quoted 7 lines · Nicolas Palix
Quoted 5 lines
Fix compilation warning by casting the const void *Buffer variable into a void *.
Quoted 1 line
[....]
Quoted 28 lines
Quoted 10 lines
Signed-off-by Nicolas Palix <[email protected]>--- drivers/staging/hv/Channel.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)drivers/staging/hv/Channel.c +0
-0drivers/staging/hv/Channel.c VmbusChannelSendPacket( · line 790
Quoted 5 lines
drivers/staging/hv/Channel.c +1
-1@@ -787,7 +787,7 @@ VmbusChannelSendPacket( bufferList[0 ].Data = &desc; bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); - bufferList[1 ].Data = Buffer; + bufferList[1 ].Data = (void *)Buffer;Yeah, I thought about doing this as well, but it's wrong. If this buffer really isn't being modified, then the Data pointer needs to be const.
Or, if the Data pointer really is going to not be const, then the function parameters need to be changed, but that means lots of code needs to be changed.
Hank, what do you think is the correct thing to do here?
thanks,
Quoted 8 lines
Quoted 1 line
greg k-h
I think both will work. At some point in the past for this design was To leave open the possibility for having the buffer modified. Right Now I am pretty sure that it does not get modified.
I am not tied to using either void or const. What makes more sense, are The kernel guidelines that if it does not get modified to define it as const?
Yes.
But the best thing to do is the other suggestion, convert it to use the real scatter-gather api, and not duplicate the functionality here. That should solve this issue, right?
Quoted 2 lines
The only thing about changing the API signature is that it does trickle into A bunch of changes (primarily in Channel.[ch], ChannelInterface.[ch] and RingBuffer.[ch])
Yeah, that's why I didn't think it was a good idea overall to do that.
Oh, the ringbuffer code will eventually need to get removed anyway, the kernel already has such infrastructure, so it should be used instead.
thanks,
greg k-h
drivers/staging/hv/Channel.c VmbusChannelSendPacket( · line 791
Quoted 13 lines · Nicolas Palix
Fix compilation warning by casting the const void *Buffer variable into a void *.
drivers/staging/hv/Channel.c +1
-1@@ -787,7 +787,7 @@ VmbusChannelSendPacket( bufferList[0 ].Data = &desc; bufferList[0 ].Length =sizeof (VMPACKET_DESCRIPTOR ); - bufferList[1 ].Data = Buffer; + bufferList[1 ].Data = (void *)Buffer; bufferList[1 ].Length = BufferLen;
Perhaps this is better?
drivers/staging/hv/RingBuffer.c +2 -2
@@ -228,7 +228,7 @@ static u32CopyToRingBuffer (RING_BUFFER_INFO *RingInfo, u32 StartWriteOffset, - void * Src, + const void * Src, u32 SrcLen); static u32
@@ -559,7 +559,7 @@ u32CopyToRingBuffer (RING_BUFFER_INFO *RingInfo, u32 StartWriteOffset, - void * Src, + const void * Src, u32 SrcLen) {void * ringBuffer=GetRingBuffer (RingInfo);
drivers/staging/hv/RingBuffer.h +1 -1
@@ -28,7 +28,7 @@#include "include/osd.h" typedef struct _SG_BUFFER_LIST { -void * Data; +const void *Data;u32 Length; }SG_BUFFER_LIST ;
Quoted 4 lines · Nicolas Palix
Fix compilation warning by casting the const void *Buffer variable into a void *.
Signed-off-by Nicolas Palix <[email protected]>
Not sure if this one is worthwhile. Replacing SG_BUFFER_LIST with the existing struct scatterlist might be a better fix, as sg_set_buf() does not generate a warning like this anyway.
Arnd <><
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Nicolas Palix
Fix compilation warning by casting the const void *Buffer variable into a void *.
Signed-off-by Nicolas Palix <[email protected]>Not sure if this one is worthwhile. Replacing
SG_BUFFER_LISTwith the existing struct scatterlist might be a better fix, assg_set_buf()does not generate a warning like this anyway.
Yes, that's the correct fix to make. That should be done instead.
thanks,
greg k-h