Skip to contentSkip to conversation

Use char * for struct drm_dp_aux_msg's buffer

PATCH Superseded Maya Rashish 3 participants 6 messages May 21, 2018 – May 24, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Use char * for struct drm_dp_aux_msg's buffer

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(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
 
Signature · 6 lines
2.17.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 2 lines · Maya Rashish

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.

Quoted 16 lines
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 6 lines · Jani Nikula
Quoted 2 lines · Maya Rashish

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

Quoted 27 lines

BR,
Jani.

Quoted 16 lines
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Jani Nikula
Quoted 2 lines · Maya Rashish

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,

Quoted 2 lines

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

True.

Quoted 1 line

which guarantees the exact same pointer arithmetic as char *

False.

Quoted 1 line

(but has the special casting rules).

True.

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

Quoted 1 line

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.

Quoted 29 lines

-Daniel

Quoted 27 lines

BR,
Jani.

Quoted 16 lines
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#4 lore raw
Quoted 12 lines · Jani Nikula
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Jani Nikula
Quoted 2 lines · Maya Rashish

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,

Quoted 8 lines
Quoted 2 lines

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

True.

Quoted 1 line

which guarantees the exact same pointer arithmetic as char *

False.

Indeed:

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

TIL

Quoted 11 lines
Quoted 1 line

(but has the special casting rules).

True.

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

Quoted 1 line

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

Quoted 36 lines

BR,
Jani.

Quoted 29 lines

-Daniel

Quoted 27 lines

BR,
Jani.

Quoted 16 lines
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#5 lore raw
In reply to Daniel Vetter

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

Quoted 34 lines · Daniel Vetter
Quoted 6 lines · Jani Nikula
Quoted 2 lines · Maya Rashish

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

Quoted 19 lines

BR,
Jani.

Quoted 15 lines
---
 include/drm/drm_dp_helper.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/drm/drm_dp_helper.h +1 -1
index 62903bae..06f9a61f 100644
@@ -1058,7 +1058,7 @@ struct drm_dp_aux_msg {
 	unsigned int address;
 	u8 request;
 	u8 reply;
-	void *buffer;
+	char *buffer;
 	size_t size;
Quoted 13 lines
Quoted 8 lines
Quoted 1 line
include/drm/drm_dp_helper.h +0 -0
 };
Signature · 5 lines
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel