public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
@ 2009-07-29 12:10 Nicolas Palix
  2009-07-29 13:02 ` Greg KH
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Nicolas Palix @ 2009-07-29 12:10 UTC (permalink / raw)
  To: gregkh, hjanssen, kernel-janitors, linux-kernel


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

Signed-off-by: Nicolas Palix <npalix@diku.dk>
---
 drivers/staging/hv/Channel.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
index 68f3442..854fa30 100644
--- a/drivers/staging/hv/Channel.c
+++ b/drivers/staging/hv/Channel.c
@@ -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;
-- 
1.6.0.4


-- 
Nicolas Palix

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 12:10 [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *) Nicolas Palix
@ 2009-07-29 13:02 ` Greg KH
  2009-07-29 20:13   ` Hank Janssen
  2009-07-29 13:03 ` Joe Perches
  2009-07-29 13:08 ` Arnd Bergmann
  2 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2009-07-29 13:02 UTC (permalink / raw)
  To: Nicolas Palix; +Cc: hjanssen, kernel-janitors, linux-kernel

On Wed, Jul 29, 2009 at 02:10:28PM +0200, Nicolas Palix wrote:
> 
> Fix compilation warning by casting the const void *Buffer
> variable into a void *.
> 
> Signed-off-by: Nicolas Palix <npalix@diku.dk>
> ---
>  drivers/staging/hv/Channel.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
> index 68f3442..854fa30 100644
> --- a/drivers/staging/hv/Channel.c
> +++ b/drivers/staging/hv/Channel.c
> @@ -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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 12:10 [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *) Nicolas Palix
  2009-07-29 13:02 ` Greg KH
@ 2009-07-29 13:03 ` Joe Perches
  2009-07-29 13:08 ` Arnd Bergmann
  2 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2009-07-29 13:03 UTC (permalink / raw)
  To: Nicolas Palix; +Cc: gregkh, hjanssen, kernel-janitors, linux-kernel

On Wed, 2009-07-29 at 14:10 +0200, Nicolas Palix wrote: 
> Fix compilation warning by casting the const void *Buffer
> variable into a void *.
> diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
> index 68f3442..854fa30 100644
> --- a/drivers/staging/hv/Channel.c
> +++ b/drivers/staging/hv/Channel.c
> @@ -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?

diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c
index 6a9f568..fa40f46 100644
--- a/drivers/staging/hv/RingBuffer.c
+++ b/drivers/staging/hv/RingBuffer.c
@@ -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);
diff --git a/drivers/staging/hv/RingBuffer.h b/drivers/staging/hv/RingBuffer.h
index a0b6e0e..4cea2af 100644
--- a/drivers/staging/hv/RingBuffer.h
+++ b/drivers/staging/hv/RingBuffer.h
@@ -28,7 +28,7 @@
 #include "include/osd.h"
 
 typedef struct _SG_BUFFER_LIST {
-	void *	Data;
+	const void *Data;
 	u32	Length;
 } SG_BUFFER_LIST;
 



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 12:10 [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *) Nicolas Palix
  2009-07-29 13:02 ` Greg KH
  2009-07-29 13:03 ` Joe Perches
@ 2009-07-29 13:08 ` Arnd Bergmann
  2009-07-29 13:13   ` Greg KH
  2 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2009-07-29 13:08 UTC (permalink / raw)
  To: Nicolas Palix; +Cc: gregkh, hjanssen, kernel-janitors, linux-kernel

On Wednesday 29 July 2009, Nicolas Palix wrote:
> Fix compilation warning by casting the const void *Buffer
> variable into a void *.
> 
> Signed-off-by: Nicolas Palix <npalix@diku.dk>

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 <><

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 13:08 ` Arnd Bergmann
@ 2009-07-29 13:13   ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2009-07-29 13:13 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Nicolas Palix, hjanssen, kernel-janitors, linux-kernel

On Wed, Jul 29, 2009 at 03:08:24PM +0200, Arnd Bergmann wrote:
> On Wednesday 29 July 2009, Nicolas Palix wrote:
> > Fix compilation warning by casting the const void *Buffer
> > variable into a void *.
> > 
> > Signed-off-by: Nicolas Palix <npalix@diku.dk>
> 
> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 13:02 ` Greg KH
@ 2009-07-29 20:13   ` Hank Janssen
  2009-07-29 20:44     ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Hank Janssen @ 2009-07-29 20:13 UTC (permalink / raw)
  To: Greg KH, Nicolas Palix
  Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org


>On Wed, Jul 29, 2009 at 02:10:28PM +0200, Nicolas Palix wrote:
>>
>> Fix compilation warning by casting the const void *Buffer
>> variable into a void *.
>>
>>>
[....]
>> Signed-off-by: Nicolas Palix <npalix@diku.dk>
>> ---
>>  drivers/staging/hv/Channel.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
>> index 68f3442..854fa30 100644
>> --- a/drivers/staging/hv/Channel.c
>> +++ b/drivers/staging/hv/Channel.c
>> @@ -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

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.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *)
  2009-07-29 20:13   ` Hank Janssen
@ 2009-07-29 20:44     ` Greg KH
  0 siblings, 0 replies; 7+ messages in thread
From: Greg KH @ 2009-07-29 20:44 UTC (permalink / raw)
  To: Hank Janssen
  Cc: Nicolas Palix, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Wed, Jul 29, 2009 at 08:13:56PM +0000, Hank Janssen wrote:
> 
> >On Wed, Jul 29, 2009 at 02:10:28PM +0200, Nicolas Palix wrote:
> >>
> >> Fix compilation warning by casting the const void *Buffer
> >> variable into a void *.
> >>
> >>>
> [....]
> >> Signed-off-by: Nicolas Palix <npalix@diku.dk>
> >> ---
> >>  drivers/staging/hv/Channel.c |    2 +-
> >>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/drivers/staging/hv/Channel.c b/drivers/staging/hv/Channel.c
> >> index 68f3442..854fa30 100644
> >> --- a/drivers/staging/hv/Channel.c
> >> +++ b/drivers/staging/hv/Channel.c
> >> @@ -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
> 
> 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?

> 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-07-29 20:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-29 12:10 [PATCH 4/4] Staging: hv: Fix warning by casting a (const void *) to (void *) Nicolas Palix
2009-07-29 13:02 ` Greg KH
2009-07-29 20:13   ` Hank Janssen
2009-07-29 20:44     ` Greg KH
2009-07-29 13:03 ` Joe Perches
2009-07-29 13:08 ` Arnd Bergmann
2009-07-29 13:13   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox