dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
@ 2018-05-21 23:36 Maya Rashish
  2018-05-22  8:33 ` Jani Nikula
  0 siblings, 1 reply; 6+ messages in thread
From: Maya Rashish @ 2018-05-21 23:36 UTC (permalink / raw)
  To: dri-devel

In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
legal for void *.
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
index 62903bae..06f9a61f 100644
--- a/include/drm/drm_dp_helper.h
+++ b/include/drm/drm_dp_helper.h
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
 
-- 
2.17.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
  2018-05-21 23:36 [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer Maya Rashish
@ 2018-05-22  8:33 ` Jani Nikula
  2018-05-23  9:09   ` Daniel Vetter
  0 siblings, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2018-05-22  8:33 UTC (permalink / raw)
  To: Maya Rashish, dri-devel

On Mon, 21 May 2018, Maya Rashish <coypu@sdf.org> wrote:
> In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
> legal for void *.

Well, this isn't pedantic C, it's GCC. There are tons of pointer
arithmetics for void pointers all over the kernel.

BR,
Jani.

> ---
>  include/drm/drm_dp_helper.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 62903bae..06f9a61f 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
>  	unsigned int address;
>  	u8 request;
>  	u8 reply;
> -	void *buffer;
> +	char *buffer;
>  	size_t size;
>  };

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
  2018-05-22  8:33 ` Jani Nikula
@ 2018-05-23  9:09   ` Daniel Vetter
  2018-05-23  9:56     ` Jani Nikula
  2018-05-23 10:09     ` coypu
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-05-23  9:09 UTC (permalink / raw)
  To: Jani Nikula; +Cc: Maya Rashish, dri-devel

On Tue, May 22, 2018 at 11:33:35AM +0300, Jani Nikula wrote:
> On Mon, 21 May 2018, Maya Rashish <coypu@sdf.org> wrote:
> > In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
> > legal for void *.
> 
> Well, this isn't pedantic C, it's GCC. There are tons of pointer
> arithmetics for void pointers all over the kernel.

I thought C99 even deprecated char * as the generic pointer, recommending
void * instead, which guarantees the exact same pointer arithmetic as char
* (but has the special casting rules).

Which static checker came up with this?
-Daniel

> 
> BR,
> Jani.
> 
> > ---
> >  include/drm/drm_dp_helper.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > index 62903bae..06f9a61f 100644
> > --- a/include/drm/drm_dp_helper.h
> > +++ b/include/drm/drm_dp_helper.h
> > @@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
> >  	unsigned int address;
> >  	u8 request;
> >  	u8 reply;
> > -	void *buffer;
> > +	char *buffer;
> >  	size_t size;
> >  };
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
  2018-05-23  9:09   ` Daniel Vetter
@ 2018-05-23  9:56     ` Jani Nikula
  2018-05-24  8:12       ` Daniel Vetter
  2018-05-23 10:09     ` coypu
  1 sibling, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2018-05-23  9:56 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Maya Rashish, dri-devel

On Wed, 23 May 2018, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Tue, May 22, 2018 at 11:33:35AM +0300, Jani Nikula wrote:
>> On Mon, 21 May 2018, Maya Rashish <coypu@sdf.org> wrote:
>> > In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
>> > legal for void *.
>> 
>> Well, this isn't pedantic C, it's GCC. There are tons of pointer
>> arithmetics for void pointers all over the kernel.
>

TTBOMK,

> I thought C99 even deprecated char * as the generic pointer, recommending
> void * instead,

True.

> which guarantees the exact same pointer arithmetic as char *

False.

> (but has the special casting rules).

True.

Void pointer arithmetics is still just a GCC extension, also supported
by Clang for compatibility.

> Which static checker came up with this?

Should be enough to turn GCC warning knobs to 11. But I don't imagine
being able to change this in the kernel code base.

BR,
Jani.

> -Daniel
>
>> 
>> BR,
>> Jani.
>> 
>> > ---
>> >  include/drm/drm_dp_helper.h | 2 +-
>> >  1 file changed, 1 insertion(+), 1 deletion(-)
>> >
>> > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
>> > index 62903bae..06f9a61f 100644
>> > --- a/include/drm/drm_dp_helper.h
>> > +++ b/include/drm/drm_dp_helper.h
>> > @@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
>> >  	unsigned int address;
>> >  	u8 request;
>> >  	u8 reply;
>> > -	void *buffer;
>> > +	char *buffer;
>> >  	size_t size;
>> >  };
>> 
>> -- 
>> Jani Nikula, Intel Open Source Graphics Center
>> _______________________________________________
>> dri-devel mailing list
>> dri-devel@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
  2018-05-23  9:09   ` Daniel Vetter
  2018-05-23  9:56     ` Jani Nikula
@ 2018-05-23 10:09     ` coypu
  1 sibling, 0 replies; 6+ messages in thread
From: coypu @ 2018-05-23 10:09 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: dri-devel

It's GCC's -Wpointer-arith.

I'm stealing your code for another project that happened to have it on
by default. I'm trying to look for opportunities to contribute back
positive changes :-)

On Wed, May 23, 2018 at 11:09:28AM +0200, Daniel Vetter wrote:
> On Tue, May 22, 2018 at 11:33:35AM +0300, Jani Nikula wrote:
> > On Mon, 21 May 2018, Maya Rashish <coypu@sdf.org> wrote:
> > > In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
> > > legal for void *.
> > 
> > Well, this isn't pedantic C, it's GCC. There are tons of pointer
> > arithmetics for void pointers all over the kernel.
> 
> I thought C99 even deprecated char * as the generic pointer, recommending
> void * instead, which guarantees the exact same pointer arithmetic as char
> * (but has the special casting rules).
> 
> Which static checker came up with this?
> -Daniel
> 
> > 
> > BR,
> > Jani.
> > 
> > > ---
> > >  include/drm/drm_dp_helper.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> > > index 62903bae..06f9a61f 100644
> > > --- a/include/drm/drm_dp_helper.h
> > > +++ b/include/drm/drm_dp_helper.h
> > > @@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
> > >  	unsigned int address;
> > >  	u8 request;
> > >  	u8 reply;
> > > -	void *buffer;
> > > +	char *buffer;
> > >  	size_t size;
> > >  };
> > 
> > -- 
> > Jani Nikula, Intel Open Source Graphics Center
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer
  2018-05-23  9:56     ` Jani Nikula
@ 2018-05-24  8:12       ` Daniel Vetter
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vetter @ 2018-05-24  8:12 UTC (permalink / raw)
  To: Jani Nikula; +Cc: Maya Rashish, dri-devel

On Wed, May 23, 2018 at 12:56:25PM +0300, Jani Nikula wrote:
> On Wed, 23 May 2018, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Tue, May 22, 2018 at 11:33:35AM +0300, Jani Nikula wrote:
> >> On Mon, 21 May 2018, Maya Rashish <coypu@sdf.org> wrote:
> >> > In drm_dp_i2c_drain_msg we do msg.buffer += err which isn't
> >> > legal for void *.
> >> 
> >> Well, this isn't pedantic C, it's GCC. There are tons of pointer
> >> arithmetics for void pointers all over the kernel.
> >
> 
> TTBOMK,
> 
> > I thought C99 even deprecated char * as the generic pointer, recommending
> > void * instead,
> 
> True.
> 
> > which guarantees the exact same pointer arithmetic as char *
> 
> False.

Indeed:

https://stackoverflow.com/questions/3523145/pointer-arithmetic-for-void-pointer-in-c

TIL

> > (but has the special casting rules).
> 
> True.
> 
> Void pointer arithmetics is still just a GCC extension, also supported
> by Clang for compatibility.
> 
> > Which static checker came up with this?
> 
> Should be enough to turn GCC warning knobs to 11. But I don't imagine
> being able to change this in the kernel code base.

Yeah, I think kernel is so full of gccism that this won't work. I think
we'll just leave this as-is. Especially since the stackoverflow answer
suggests I'm by far not the only one who got tricked by the standard's
wording.
-Daniel
> 
> BR,
> Jani.
> 
> > -Daniel
> >
> >> 
> >> BR,
> >> Jani.
> >> 
> >> > ---
> >> >  include/drm/drm_dp_helper.h | 2 +-
> >> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >> >
> >> > diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> >> > index 62903bae..06f9a61f 100644
> >> > --- a/include/drm/drm_dp_helper.h
> >> > +++ b/include/drm/drm_dp_helper.h
> >> > @@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
> >> >  	unsigned int address;
> >> >  	u8 request;
> >> >  	u8 reply;
> >> > -	void *buffer;
> >> > +	char *buffer;
> >> >  	size_t size;
> >> >  };
> >> 
> >> -- 
> >> Jani Nikula, Intel Open Source Graphics Center
> >> _______________________________________________
> >> dri-devel mailing list
> >> dri-devel@lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2018-05-24  8:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-21 23:36 [PATCH 2/2] Use char * for struct drm_dp_aux_msg's buffer Maya Rashish
2018-05-22  8:33 ` Jani Nikula
2018-05-23  9:09   ` Daniel Vetter
2018-05-23  9:56     ` Jani Nikula
2018-05-24  8:12       ` Daniel Vetter
2018-05-23 10:09     ` coypu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).