media-libs/libgphoto2: C23 fix

* Clang-22 is picker about these incompatabilities. This compounds with
  autoconf 2.73 opportunistically using C23 where possible.

Signed-off-by: Alfred Wingate <parona@protonmail.com>
Part-of: https://codeberg.org/gentoo/gentoo/pulls/675
Merges: https://codeberg.org/gentoo/gentoo/pulls/675
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Alfred Wingate
2026-04-20 11:54:35 +03:00
committed by Sam James
parent 4ef6225c41
commit 2ac260a271
2 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
https://github.com/gphoto/libgphoto2/pull/1235
https://github.com/gphoto/libgphoto2/commit/7cbc8b7241f73835270493d26e440b27060cb3df
From 7cbc8b7241f73835270493d26e440b27060cb3df Mon Sep 17 00:00:00 2001
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Sat, 4 Apr 2026 14:56:01 -0700
Subject: [PATCH] libgphoto2: fix const-correctness for c23 builds
C23 treats the return values of strrchr() and strchr() as const char *
when the input string is const-qualified. Update local variables to use
const char * where appropriate to avoid discarded-qualifier warnings and
build failures with -std=gnu23.
No functional change intended.
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
--- a/camlibs/directory/directory.c
+++ b/camlibs/directory/directory.c
@@ -125,7 +125,7 @@ static const char *
get_mime_type (const char *filename)
{
- char *dot;
+ const char *dot;
int x=0;
dot = strrchr(filename, '.');
--- a/libgphoto2/gphoto2-file.c
+++ b/libgphoto2/gphoto2-file.c
@@ -611,7 +611,7 @@ int
gp_file_open (CameraFile *file, const char *filename)
{
FILE *fp;
- char *name, *dot;
+ const char *name, *dot;
long size, size_read;
int i;
struct stat s;
@@ -907,8 +907,8 @@ gp_file_get_name (CameraFile *file, const char **name)
int
gp_file_get_name_by_type (CameraFile *file, const char *basename, CameraFileType type, char **newname)
{
- char *prefix = NULL, *s, *new, *slash = NULL;
- const char *suffix = NULL;
+ char *prefix = NULL, *new;
+ const char *suffix = NULL, *s, *slash = NULL;
int i;
C_PARAMS (file && basename && newname);
--- a/libgphoto2/gphoto2-filesys.c
+++ b/libgphoto2/gphoto2-filesys.c
@@ -521,7 +521,7 @@ append_to_folder (CameraFilesystemFolder *folder,
CameraFilesystemFolder **newfolder
) {
CameraFilesystemFolder *f;
- char *s;
+ const char *s;
GP_LOG_D ("Append to folder %p/%s - %s", folder, folder->name, foldername);
/* Handle multiple slashes, and slashes at the end */
--- a/packaging/generic/print-camera-list.c
+++ b/packaging/generic/print-camera-list.c
@@ -1138,7 +1138,7 @@ escape_html(const char *str) {
newstr = malloc(strlen(str)+1+inc);
s = str; ns = newstr;
do {
- char *x;
+ const char *x;
x = strchr(s,'&');
if (x) {
memcpy (ns, s, x-s);

View File

@@ -80,6 +80,10 @@ MULTILIB_CHOST_TOOLS=(
/usr/bin/gphoto2-config
)
PATCHES=(
"${FILESDIR}"/libgphoto2-2.5.33-c23.patch
)
src_prepare() {
default