diff options
| author | Khem Raj <khem.raj@oss.qualcomm.com> | 2026-04-04 15:02:23 -0700 |
|---|---|---|
| committer | Khem Raj <khem.raj@oss.qualcomm.com> | 2026-04-05 22:13:57 -0700 |
| commit | f3da39cf754fc16b47aba8e340fe93e71ab5cbf0 (patch) | |
| tree | dd4a856fd2282b2fa435f5a64706921342cf68e1 | |
| parent | 1d12cee712ceead8c340fd7551f6b1c6c007de42 (diff) | |
| download | meta-openembedded-f3da39cf754fc16b47aba8e340fe93e71ab5cbf0.tar.gz | |
libgphoto2: Fix c23 build errors
Fixes errors e.g.
error: assigning to 'char *' from 'const char *' discards qualifiers [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
131 | dot = strrchr(filename, '.');
| ^ ~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
They are latent and brought to fore with autoconf 2.73 which switches
defaults to use -std=gnu23
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
| -rw-r--r-- | meta-oe/recipes-graphics/gphoto2/libgphoto2/0001-libgphoto2-fix-const-correctness-for-c23-builds.patch | 84 | ||||
| -rw-r--r-- | meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb | 1 |
2 files changed, 85 insertions, 0 deletions
diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2/0001-libgphoto2-fix-const-correctness-for-c23-builds.patch b/meta-oe/recipes-graphics/gphoto2/libgphoto2/0001-libgphoto2-fix-const-correctness-for-c23-builds.patch new file mode 100644 index 0000000000..9ded174095 --- /dev/null +++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2/0001-libgphoto2-fix-const-correctness-for-c23-builds.patch | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | From bfa786a260bfd4660e8186ebad8778718e85e8cd Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Khem Raj <khem.raj@oss.qualcomm.com> | ||
| 3 | Date: Sat, 4 Apr 2026 14:56:01 -0700 | ||
| 4 | Subject: [PATCH] libgphoto2: fix const-correctness for c23 builds | ||
| 5 | |||
| 6 | C23 treats the return values of strrchr() and strchr() as const char * | ||
| 7 | when the input string is const-qualified. Update local variables to use | ||
| 8 | const char * where appropriate to avoid discarded-qualifier warnings and | ||
| 9 | build failures with -std=gnu23. | ||
| 10 | |||
| 11 | No functional change intended. | ||
| 12 | |||
| 13 | Upstream-Status: Submitted [https://github.com/gphoto/libgphoto2/pull/1235] | ||
| 14 | Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com> | ||
| 15 | --- | ||
| 16 | camlibs/directory/directory.c | 2 +- | ||
| 17 | libgphoto2/gphoto2-file.c | 6 +++--- | ||
| 18 | libgphoto2/gphoto2-filesys.c | 2 +- | ||
| 19 | packaging/generic/print-camera-list.c | 2 +- | ||
| 20 | 4 files changed, 6 insertions(+), 6 deletions(-) | ||
| 21 | |||
| 22 | diff --git a/camlibs/directory/directory.c b/camlibs/directory/directory.c | ||
| 23 | index 790405d54..cc63c6684 100644 | ||
| 24 | --- a/camlibs/directory/directory.c | ||
| 25 | +++ b/camlibs/directory/directory.c | ||
| 26 | @@ -125,7 +125,7 @@ static const char * | ||
| 27 | get_mime_type (const char *filename) | ||
| 28 | { | ||
| 29 | |||
| 30 | - char *dot; | ||
| 31 | + const char *dot; | ||
| 32 | int x=0; | ||
| 33 | |||
| 34 | dot = strrchr(filename, '.'); | ||
| 35 | diff --git a/libgphoto2/gphoto2-file.c b/libgphoto2/gphoto2-file.c | ||
| 36 | index 04d4d5e3e..1a9dbc193 100644 | ||
| 37 | --- a/libgphoto2/gphoto2-file.c | ||
| 38 | +++ b/libgphoto2/gphoto2-file.c | ||
| 39 | @@ -610,7 +610,7 @@ int | ||
| 40 | gp_file_open (CameraFile *file, const char *filename) | ||
| 41 | { | ||
| 42 | FILE *fp; | ||
| 43 | - char *name, *dot; | ||
| 44 | + const char *name, *dot; | ||
| 45 | long size, size_read; | ||
| 46 | int i; | ||
| 47 | struct stat s; | ||
| 48 | @@ -906,8 +906,8 @@ gp_file_get_name (CameraFile *file, const char **name) | ||
| 49 | int | ||
| 50 | gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname) | ||
| 51 | { | ||
| 52 | - char *prefix = NULL, *s, *new, *slash = NULL; | ||
| 53 | - const char *suffix = NULL; | ||
| 54 | + char *prefix = NULL, *new; | ||
| 55 | + const char *suffix = NULL, *s, *slash = NULL; | ||
| 56 | int i; | ||
| 57 | |||
| 58 | C_PARAMS (file && basename && newname); | ||
| 59 | diff --git a/libgphoto2/gphoto2-filesys.c b/libgphoto2/gphoto2-filesys.c | ||
| 60 | index 45f957292..07decff24 100644 | ||
| 61 | --- a/libgphoto2/gphoto2-filesys.c | ||
| 62 | +++ b/libgphoto2/gphoto2-filesys.c | ||
| 63 | @@ -521,7 +521,7 @@ append_to_folder (CameraFilesystemFolder *folder, | ||
| 64 | CameraFilesystemFolder **newfolder | ||
| 65 | ) { | ||
| 66 | CameraFilesystemFolder *f; | ||
| 67 | - char *s; | ||
| 68 | + const char *s; | ||
| 69 | |||
| 70 | GP_LOG_D ("Append to folder %p/%s - %s", folder, folder->name, foldername); | ||
| 71 | /* Handle multiple slashes, and slashes at the end */ | ||
| 72 | diff --git a/packaging/generic/print-camera-list.c b/packaging/generic/print-camera-list.c | ||
| 73 | index 1707b4e87..44530b4ae 100644 | ||
| 74 | --- a/packaging/generic/print-camera-list.c | ||
| 75 | +++ b/packaging/generic/print-camera-list.c | ||
| 76 | @@ -1138,7 +1138,7 @@ escape_html(const char *str) { | ||
| 77 | newstr = malloc(strlen(str)+1+inc); | ||
| 78 | s = str; ns = newstr; | ||
| 79 | do { | ||
| 80 | - char *x; | ||
| 81 | + const char *x; | ||
| 82 | x = strchr(s,'&'); | ||
| 83 | if (x) { | ||
| 84 | memcpy (ns, s, x-s); | ||
diff --git a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb index 6b5e6c21b9..3644bd9bf4 100644 --- a/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb +++ b/meta-oe/recipes-graphics/gphoto2/libgphoto2_2.5.33.bb | |||
| @@ -12,6 +12,7 @@ DEPENDS = "libtool jpeg virtual/libusb0 libexif zlib libxml2" | |||
| 12 | SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \ | 12 | SRC_URI = "${SOURCEFORGE_MIRROR}/gphoto/${BP}.tar.xz;name=libgphoto2 \ |
| 13 | file://40-libgphoto2.rules \ | 13 | file://40-libgphoto2.rules \ |
| 14 | file://0001-configure-Filter-out-buildpaths-from-CC.patch \ | 14 | file://0001-configure-Filter-out-buildpaths-from-CC.patch \ |
| 15 | file://0001-libgphoto2-fix-const-correctness-for-c23-builds.patch \ | ||
| 15 | " | 16 | " |
| 16 | SRC_URI[libgphoto2.sha256sum] = "28825f767a85544cb58f6e15028f8e53a5bb37a62148b3f1708b524781c3bef2" | 17 | SRC_URI[libgphoto2.sha256sum] = "28825f767a85544cb58f6e15028f8e53a5bb37a62148b3f1708b524781c3bef2" |
| 17 | 18 | ||
