diff mbox series

[meta-oe] gphoto2: Fix build with clang-22

Message ID 20260422013925.1791148-1-khem.raj@oss.qualcomm.com
State New
Headers show
Series [meta-oe] gphoto2: Fix build with clang-22 | expand

Commit Message

Khem Raj April 22, 2026, 1:39 a.m. UTC
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
 ...hoto2-fix-const-qualifier-violations.patch | 73 +++++++++++++++++++
 .../gphoto2/gphoto2_2.5.32.bb                 |  1 +
 2 files changed, 74 insertions(+)
 create mode 100644 meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch

Comments

Gyorgy Sarvari April 22, 2026, 7:57 a.m. UTC | #1
On 4/22/26 03:39, Khem Raj via lists.openembedded.org wrote:
> Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
> ---
>  ...hoto2-fix-const-qualifier-violations.patch | 73 +++++++++++++++++++
>  .../gphoto2/gphoto2_2.5.32.bb                 |  1 +
>  2 files changed, 74 insertions(+)
>  create mode 100644 meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> 
> diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> new file mode 100644
> index 0000000000..a8f85d034c
> --- /dev/null
> +++ b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> @@ -0,0 +1,73 @@
> +From 55edc241e9b61b14153c61fd0baaefac927ad89f Mon Sep 17 00:00:00 2001
> +From: Khem Raj <khem.raj@oss.qualcomm.com>
> +Date: Tue, 21 Apr 2026 17:39:43 -0700
> +Subject: [PATCH] gphoto2: fix const qualifier violations
> +MIME-Version: 1.0
> +Content-Type: text/plain; charset=UTF-8
> +Content-Transfer-Encoding: 8bit
> +
> +No logic is changed. The patch is a pure
> +type-correctness fix that makes the variable
> +declarations match the actual semantics —
> +const char * for pointers into string literals
> +or function parameters that must not be mutated,
> +and char * only for owned heap memory. This
> +satisfies Clang's strict qualifier checking without
> +needing any casts or warning suppressions.
> +
> +Fixes errors seen on clang with
> +  -Werror,-Wincompatible-pointer-types-discards-qualifiers
> +
> +Upstream-Status: Pending
> +Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
> +---
> + gphoto2/main.c | 14 ++++++++------
> + 1 file changed, 8 insertions(+), 6 deletions(-)
> +
> +diff --git a/gphoto2/main.c b/gphoto2/main.c
> +index 5a3c5c1..086f9df 100644
> +--- a/gphoto2/main.c
> ++++ b/gphoto2/main.c
> +@@ -146,7 +146,8 @@ static int
> + get_path_for_file (const char *folder, const char *name, CameraFileType type, CameraFile *file, char **path)
> + {
> + 	unsigned int i, l;
> +-	char *s = NULL, b[1024];
> ++	const char *s = NULL;
> ++	char *p = NULL; char b[1024];
> + 	time_t t = 0;
> + 	struct tm *tm;
> + 	int hour12;
> +@@ -339,18 +340,18 @@ get_path_for_file (const char *folder, const char *name, CameraFileType type, Ca
> + 			b[1] = '\0';
> + 		}
> +
> +-		s = *path ? realloc (*path, strlen (*path) + strlen (b) + 1) :
> ++		p = *path ? realloc (*path, strlen (*path) + strlen (b) + 1) :
> + 			    malloc (strlen (b) + 1);
> +-		if (!s) {
> ++		if (!p) {
> + 			free (*path);
> + 			*path = NULL;
> + 			return (GP_ERROR_NO_MEMORY);
> + 		}
> + 		if (*path) {
> +-			*path = s;
> ++			*path = p;
> + 			strcat (*path, b);
> + 		} else {
> +-			*path = s;
> ++			*path = p;
> + 			strcpy (*path, b);
> + 		}
> + 	}


Is this enough? Variable s is still used a few lines later as an input
parameter, but now it has a different value than before this patch.
(Admittedly haven't looked deep enough to check if the difference is
significant)


> +@@ -696,7 +697,8 @@ dissolve_filename (
> + 	const char *folder, const char *filename,
> + 	char **newfolder, char **newfilename
> + ) {
> +-	char *nfolder, *s;
> ++	char *nfolder;
> ++	const char *s;
> +
> + 	s = strrchr (filename, '/');
> + 	if (!s) {
> diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> index e5e7c6926f..dbd2b0e748 100644
> --- a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> +++ b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> @@ -9,6 +9,7 @@ RDEPENDS:gphoto2 = "libgphoto2"
>  SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.bz2;name=gphoto2 \
>             file://0001-configure.ac-remove-AM_PO_SUBDIRS.patch \
>             file://0001-configure-Filter-out-buildpaths-from-CC.patch \
> +           file://0001-gphoto2-fix-const-qualifier-violations.patch \
>  "
>  SRC_URI[gphoto2.sha256sum] = "4e379a0f12f72b49ee5ee2283ffd806b5d12d099939d75197a3f4bbc7f27a1a1"
> 
> 
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#126539): https://lists.openembedded.org/g/openembedded-devel/message/126539
> Mute This Topic: https://lists.openembedded.org/mt/118948760/6084445
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Khem Raj April 23, 2026, 7:01 a.m. UTC | #2
On Wed, Apr 22, 2026 at 12:57 AM Gyorgy Sarvari <skandigraun@gmail.com>
wrote:

> On 4/22/26 03:39, Khem Raj via lists.openembedded.org wrote:
> > Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
> > ---
> >  ...hoto2-fix-const-qualifier-violations.patch | 73 +++++++++++++++++++
> >  .../gphoto2/gphoto2_2.5.32.bb                 |  1 +
> >  2 files changed, 74 insertions(+)
> >  create mode 100644
> meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> >
> > diff --git
> a/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> > new file mode 100644
> > index 0000000000..a8f85d034c
> > --- /dev/null
> > +++
> b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
> > @@ -0,0 +1,73 @@
> > +From 55edc241e9b61b14153c61fd0baaefac927ad89f Mon Sep 17 00:00:00 2001
> > +From: Khem Raj <khem.raj@oss.qualcomm.com>
> > +Date: Tue, 21 Apr 2026 17:39:43 -0700
> > +Subject: [PATCH] gphoto2: fix const qualifier violations
> > +MIME-Version: 1.0
> > +Content-Type: text/plain; charset=UTF-8
> > +Content-Transfer-Encoding: 8bit
> > +
> > +No logic is changed. The patch is a pure
> > +type-correctness fix that makes the variable
> > +declarations match the actual semantics —
> > +const char * for pointers into string literals
> > +or function parameters that must not be mutated,
> > +and char * only for owned heap memory. This
> > +satisfies Clang's strict qualifier checking without
> > +needing any casts or warning suppressions.
> > +
> > +Fixes errors seen on clang with
> > +  -Werror,-Wincompatible-pointer-types-discards-qualifiers
> > +
> > +Upstream-Status: Pending
> > +Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
> > +---
> > + gphoto2/main.c | 14 ++++++++------
> > + 1 file changed, 8 insertions(+), 6 deletions(-)
> > +
> > +diff --git a/gphoto2/main.c b/gphoto2/main.c
> > +index 5a3c5c1..086f9df 100644
> > +--- a/gphoto2/main.c
> > ++++ b/gphoto2/main.c
> > +@@ -146,7 +146,8 @@ static int
> > + get_path_for_file (const char *folder, const char *name,
> CameraFileType type, CameraFile *file, char **path)
> > + {
> > +     unsigned int i, l;
> > +-    char *s = NULL, b[1024];
> > ++    const char *s = NULL;
> > ++    char *p = NULL; char b[1024];
> > +     time_t t = 0;
> > +     struct tm *tm;
> > +     int hour12;
> > +@@ -339,18 +340,18 @@ get_path_for_file (const char *folder, const char
> *name, CameraFileType type, Ca
> > +                     b[1] = '\0';
> > +             }
> > +
> > +-            s = *path ? realloc (*path, strlen (*path) + strlen (b) +
> 1) :
> > ++            p = *path ? realloc (*path, strlen (*path) + strlen (b) +
> 1) :
> > +                         malloc (strlen (b) + 1);
> > +-            if (!s) {
> > ++            if (!p) {
> > +                     free (*path);
> > +                     *path = NULL;
> > +                     return (GP_ERROR_NO_MEMORY);
> > +             }
> > +             if (*path) {
> > +-                    *path = s;
> > ++                    *path = p;
> > +                     strcat (*path, b);
> > +             } else {
> > +-                    *path = s;
> > ++                    *path = p;
> > +                     strcpy (*path, b);
> > +             }
> > +     }
>
>
> Is this enough? Variable s is still used a few lines later as an input
> parameter, but now it has a different value than before this patch.
> (Admittedly haven't looked deep enough to check if the difference is
> significant)
>
>
I think p should be used instead of s in that function call

return gp_file_get_name_by_type (file, s, type, path);



>
> > +@@ -696,7 +697,8 @@ dissolve_filename (
> > +     const char *folder, const char *filename,
> > +     char **newfolder, char **newfilename
> > + ) {
> > +-    char *nfolder, *s;
> > ++    char *nfolder;
> > ++    const char *s;
> > +
> > +     s = strrchr (filename, '/');
> > +     if (!s) {
> > diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> > index e5e7c6926f..dbd2b0e748 100644
> > --- a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> > +++ b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
> > @@ -9,6 +9,7 @@ RDEPENDS:gphoto2 = "libgphoto2"
> >  SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.bz2;name=gphoto2 \
> >             file://0001-configure.ac-remove-AM_PO_SUBDIRS.patch \
> >             file://0001-configure-Filter-out-buildpaths-from-CC.patch \
> > +           file://0001-gphoto2-fix-const-qualifier-violations.patch \
> >  "
> >  SRC_URI[gphoto2.sha256sum] =
> "4e379a0f12f72b49ee5ee2283ffd806b5d12d099939d75197a3f4bbc7f27a1a1"
> >
> >
> >
> > -=-=-=-=-=-=-=-=-=-=-=-
> > Links: You receive all messages sent to this group.
> > View/Reply Online (#126539):
> https://lists.openembedded.org/g/openembedded-devel/message/126539
> > Mute This Topic: https://lists.openembedded.org/mt/118948760/6084445
> > Group Owner: openembedded-devel+owner@lists.openembedded.org
> > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [
> skandigraun@gmail.com]
> > -=-=-=-=-=-=-=-=-=-=-=-
> >
>
>
Gyorgy Sarvari April 23, 2026, 11:23 a.m. UTC | #3
On 4/23/26 09:01, Khem Raj wrote:
> 
> 
> On Wed, Apr 22, 2026 at 12:57 AM Gyorgy Sarvari <skandigraun@gmail.com
> <mailto:skandigraun@gmail.com>> wrote:
> 
>     On 4/22/26 03:39, Khem Raj via lists.openembedded.org <http://
>     lists.openembedded.org> wrote:
>     > Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com
>     <mailto:khem.raj@oss.qualcomm.com>>
>     > ---
>     >  ...hoto2-fix-const-qualifier-violations.patch | 73 ++++++++++++++
>     +++++
>     >  .../gphoto2/gphoto2_2.5.32.bb <http://gphoto2_2.5.32.bb>         
>            |  1 +
>     >  2 files changed, 74 insertions(+)
>     >  create mode 100644 meta-oe/recipes-graphics/gphoto2/gphoto2/0001-
>     gphoto2-fix-const-qualifier-violations.patch
>     >
>     > diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-
>     gphoto2-fix-const-qualifier-violations.patch b/meta-oe/recipes-
>     graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-
>     violations.patch
>     > new file mode 100644
>     > index 0000000000..a8f85d034c
>     > --- /dev/null
>     > +++ b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-
>     const-qualifier-violations.patch
>     > @@ -0,0 +1,73 @@
>     > +From 55edc241e9b61b14153c61fd0baaefac927ad89f Mon Sep 17 00:00:00
>     2001
>     > +From: Khem Raj <khem.raj@oss.qualcomm.com
>     <mailto:khem.raj@oss.qualcomm.com>>
>     > +Date: Tue, 21 Apr 2026 17:39:43 -0700
>     > +Subject: [PATCH] gphoto2: fix const qualifier violations
>     > +MIME-Version: 1.0
>     > +Content-Type: text/plain; charset=UTF-8
>     > +Content-Transfer-Encoding: 8bit
>     > +
>     > +No logic is changed. The patch is a pure
>     > +type-correctness fix that makes the variable
>     > +declarations match the actual semantics —
>     > +const char * for pointers into string literals
>     > +or function parameters that must not be mutated,
>     > +and char * only for owned heap memory. This
>     > +satisfies Clang's strict qualifier checking without
>     > +needing any casts or warning suppressions.
>     > +
>     > +Fixes errors seen on clang with
>     > +  -Werror,-Wincompatible-pointer-types-discards-qualifiers
>     > +
>     > +Upstream-Status: Pending
>     > +Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com
>     <mailto:khem.raj@oss.qualcomm.com>>
>     > +---
>     > + gphoto2/main.c | 14 ++++++++------
>     > + 1 file changed, 8 insertions(+), 6 deletions(-)
>     > +
>     > +diff --git a/gphoto2/main.c b/gphoto2/main.c
>     > +index 5a3c5c1..086f9df 100644
>     > +--- a/gphoto2/main.c
>     > ++++ b/gphoto2/main.c
>     > +@@ -146,7 +146,8 @@ static int
>     > + get_path_for_file (const char *folder, const char *name,
>     CameraFileType type, CameraFile *file, char **path)
>     > + {
>     > +     unsigned int i, l;
>     > +-    char *s = NULL, b[1024];
>     > ++    const char *s = NULL;
>     > ++    char *p = NULL; char b[1024];
>     > +     time_t t = 0;
>     > +     struct tm *tm;
>     > +     int hour12;
>     > +@@ -339,18 +340,18 @@ get_path_for_file (const char *folder,
>     const char *name, CameraFileType type, Ca
>     > +                     b[1] = '\0';
>     > +             }
>     > +
>     > +-            s = *path ? realloc (*path, strlen (*path) + strlen
>     (b) + 1) :
>     > ++            p = *path ? realloc (*path, strlen (*path) + strlen
>     (b) + 1) :
>     > +                         malloc (strlen (b) + 1);
>     > +-            if (!s) {
>     > ++            if (!p) {
>     > +                     free (*path);
>     > +                     *path = NULL;
>     > +                     return (GP_ERROR_NO_MEMORY);
>     > +             }
>     > +             if (*path) {
>     > +-                    *path = s;
>     > ++                    *path = p;
>     > +                     strcat (*path, b);
>     > +             } else {
>     > +-                    *path = s;
>     > ++                    *path = p;
>     > +                     strcpy (*path, b);
>     > +             }
>     > +     }
> 
> 
>     Is this enough? Variable s is still used a few lines later as an input
>     parameter, but now it has a different value than before this patch.
>     (Admittedly haven't looked deep enough to check if the difference is
>     significant)
> 
> 
> I think p should be used instead of s in that function call
> 
> return gp_file_get_name_by_type (file, s, type, path);
> 
>  


Yeah, that statement caught my eye too
diff mbox series

Patch

diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
new file mode 100644
index 0000000000..a8f85d034c
--- /dev/null
+++ b/meta-oe/recipes-graphics/gphoto2/gphoto2/0001-gphoto2-fix-const-qualifier-violations.patch
@@ -0,0 +1,73 @@ 
+From 55edc241e9b61b14153c61fd0baaefac927ad89f Mon Sep 17 00:00:00 2001
+From: Khem Raj <khem.raj@oss.qualcomm.com>
+Date: Tue, 21 Apr 2026 17:39:43 -0700
+Subject: [PATCH] gphoto2: fix const qualifier violations
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+No logic is changed. The patch is a pure
+type-correctness fix that makes the variable
+declarations match the actual semantics —
+const char * for pointers into string literals
+or function parameters that must not be mutated,
+and char * only for owned heap memory. This
+satisfies Clang's strict qualifier checking without
+needing any casts or warning suppressions.
+
+Fixes errors seen on clang with
+  -Werror,-Wincompatible-pointer-types-discards-qualifiers
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
+---
+ gphoto2/main.c | 14 ++++++++------
+ 1 file changed, 8 insertions(+), 6 deletions(-)
+
+diff --git a/gphoto2/main.c b/gphoto2/main.c
+index 5a3c5c1..086f9df 100644
+--- a/gphoto2/main.c
++++ b/gphoto2/main.c
+@@ -146,7 +146,8 @@ static int
+ get_path_for_file (const char *folder, const char *name, CameraFileType type, CameraFile *file, char **path)
+ {
+ 	unsigned int i, l;
+-	char *s = NULL, b[1024];
++	const char *s = NULL;
++	char *p = NULL; char b[1024];
+ 	time_t t = 0;
+ 	struct tm *tm;
+ 	int hour12;
+@@ -339,18 +340,18 @@ get_path_for_file (const char *folder, const char *name, CameraFileType type, Ca
+ 			b[1] = '\0';
+ 		}
+
+-		s = *path ? realloc (*path, strlen (*path) + strlen (b) + 1) :
++		p = *path ? realloc (*path, strlen (*path) + strlen (b) + 1) :
+ 			    malloc (strlen (b) + 1);
+-		if (!s) {
++		if (!p) {
+ 			free (*path);
+ 			*path = NULL;
+ 			return (GP_ERROR_NO_MEMORY);
+ 		}
+ 		if (*path) {
+-			*path = s;
++			*path = p;
+ 			strcat (*path, b);
+ 		} else {
+-			*path = s;
++			*path = p;
+ 			strcpy (*path, b);
+ 		}
+ 	}
+@@ -696,7 +697,8 @@ dissolve_filename (
+ 	const char *folder, const char *filename,
+ 	char **newfolder, char **newfilename
+ ) {
+-	char *nfolder, *s;
++	char *nfolder;
++	const char *s;
+
+ 	s = strrchr (filename, '/');
+ 	if (!s) {
diff --git a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
index e5e7c6926f..dbd2b0e748 100644
--- a/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
+++ b/meta-oe/recipes-graphics/gphoto2/gphoto2_2.5.32.bb
@@ -9,6 +9,7 @@  RDEPENDS:gphoto2 = "libgphoto2"
 SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.bz2;name=gphoto2 \
            file://0001-configure.ac-remove-AM_PO_SUBDIRS.patch \
            file://0001-configure-Filter-out-buildpaths-from-CC.patch \
+           file://0001-gphoto2-fix-const-qualifier-violations.patch \
 "
 SRC_URI[gphoto2.sha256sum] = "4e379a0f12f72b49ee5ee2283ffd806b5d12d099939d75197a3f4bbc7f27a1a1"