diff mbox series

[1/1] package/cwiid: fix build with gcc >= 14

Message ID 20240723083608.701739-1-fontaine.fabrice@gmail.com
State Superseded
Headers show
Series [1/1] package/cwiid: fix build with gcc >= 14 | expand

Commit Message

Fabrice Fontaine July 23, 2024, 8:36 a.m. UTC
Fix the following build failure with gcc >= 14:

led.c: In function 'wmplugin_exec':
led.c:86:42: error: assignment to 'struct cwiid_btn_message *' from incompatible pointer type 'struct cwiid_btn_mesg *' [-Wincompatible-pointer-types]
   86 |                                 btn_mesg = &mesg[i].btn_mesg;
      |                                          ^

Fixes:
 - http://autobuild.buildroot.org/results/a3bde74ff2137d088f4261e62930859bfe460cb9

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
---
 ...gins-led-led.c-fix-build-with-gcc-14.patch | 37 +++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100644 package/cwiid/0004-wminput-plugins-led-led.c-fix-build-with-gcc-14.patch

Comments

Thomas Petazzoni July 23, 2024, 8:54 a.m. UTC | #1
Hello Fabrice,

On Tue, 23 Jul 2024 10:36:08 +0200
Fabrice Fontaine <fontaine.fabrice@gmail.com> wrote:

> +diff --git a/wminput/plugins/led/led.c b/wminput/plugins/led/led.c
> +index 93b96d9..723a2db 100644
> +--- a/wminput/plugins/led/led.c
> ++++ b/wminput/plugins/led/led.c
> +@@ -83,7 +83,7 @@ struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg mesg[])
> + 		btn_mesg = NULL;
> + 		for (i=0; i < mesg_count; i++) {
> + 			if (mesg[i].type == CWIID_MESG_BTN) {
> +-				btn_mesg = &mesg[i].btn_mesg;
> ++				btn_mesg = (struct cwiid_btn_message *) &mesg[i].btn_mesg;
> + 				button = mesg[i].btn_mesg.buttons;

Thanks for looking into this. However, do you have some evidence that
it is correct to cast cabbage into carrots?

I.e, why is it correct to cast a struct cwiid_btn_mesg into a struct
cwiid_btn_message ?

Thanks,

Thomas
diff mbox series

Patch

diff --git a/package/cwiid/0004-wminput-plugins-led-led.c-fix-build-with-gcc-14.patch b/package/cwiid/0004-wminput-plugins-led-led.c-fix-build-with-gcc-14.patch
new file mode 100644
index 0000000000..49fa059e6e
--- /dev/null
+++ b/package/cwiid/0004-wminput-plugins-led-led.c-fix-build-with-gcc-14.patch
@@ -0,0 +1,37 @@ 
+From a775fb452ce324ce5b5ff7bf380e72c1861967b1 Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Date: Tue, 23 Jul 2024 10:31:32 +0200
+Subject: [PATCH] wminput/plugins/led/led.c: fix build with gcc >= 14
+
+Fix the following build failure with gcc >= 14:
+
+led.c: In function 'wmplugin_exec':
+led.c:86:42: error: assignment to 'struct cwiid_btn_message *' from incompatible pointer type 'struct cwiid_btn_mesg *' [-Wincompatible-pointer-types]
+   86 |                                 btn_mesg = &mesg[i].btn_mesg;
+      |                                          ^
+
+Fixes:
+ - http://autobuild.buildroot.org/results/a3bde74ff2137d088f4261e62930859bfe460cb9
+
+Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
+Upstream: https://github.com/abstrakraft/cwiid/pull/47
+---
+ wminput/plugins/led/led.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/wminput/plugins/led/led.c b/wminput/plugins/led/led.c
+index 93b96d9..723a2db 100644
+--- a/wminput/plugins/led/led.c
++++ b/wminput/plugins/led/led.c
+@@ -83,7 +83,7 @@ struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg mesg[])
+ 		btn_mesg = NULL;
+ 		for (i=0; i < mesg_count; i++) {
+ 			if (mesg[i].type == CWIID_MESG_BTN) {
+-				btn_mesg = &mesg[i].btn_mesg;
++				btn_mesg = (struct cwiid_btn_message *) &mesg[i].btn_mesg;
+ 				button = mesg[i].btn_mesg.buttons;
+ 			}
+ 		}
+-- 
+2.43.0
+