Skip to contentSkip to conversation

Staging: hv: Fix warning by casting a (const void *) to (void *)

PATCH In review Nicolas Palix 5 participants 7 messages Jul 29, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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
index 68f3442..854fa30 100644
@@ -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
#1 lore raw
Quoted 14 lines · Nicolas Palix

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 +0 -0
index 68f3442..854fa30 100644

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

#2 lore raw
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
---
 drivers/staging/hv/Channel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/Channel.c +0 -0
index 68f3442..854fa30 100644

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.

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.

#3 lore raw
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
---
 drivers/staging/hv/Channel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/hv/Channel.c +0 -0
index 68f3442..854fa30 100644

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,

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

#4 lore raw
In reply to Nicolas Palix

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
index 68f3442..854fa30 100644
@@ -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
index 6a9f568..fa40f46 100644
@@ -228,7 +228,7 @@ static u32
 CopyToRingBuffer(
 	RING_BUFFER_INFO	*RingInfo,
 	u32				StartWriteOffset,
-	void *				Src,
+	const void *			Src,
 	u32				SrcLen);
 
 static u32
@@ -559,7 +559,7 @@ u32
 CopyToRingBuffer(
 	RING_BUFFER_INFO	*RingInfo,
 	u32				StartWriteOffset,
-	void *				Src,
+	const void *			Src,
 	u32				SrcLen)
 {
 	void * ringBuffer=GetRingBuffer(RingInfo);
drivers/staging/hv/RingBuffer.h +1 -1
index a0b6e0e..4cea2af 100644
@@ -28,7 +28,7 @@
 #include "include/osd.h"
 
 typedef struct _SG_BUFFER_LIST {
-	void *	Data;
+	const void *Data;
 	u32	Length;
 } SG_BUFFER_LIST;
 
#5 lore raw
In reply to Nicolas Palix
Quoted 4 lines · Nicolas Palix

Fix compilation warning by casting the const void *Buffer variable into a void *.

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 <><
#6 lore raw
Quoted 10 lines · Arnd Bergmann
Quoted 4 lines · Nicolas Palix

Fix compilation warning by casting the const void *Buffer variable into a void *.

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.

Yes, that's the correct fix to make. That should be done instead.

thanks,

greg k-h