mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 05:01:23 +00:00
uvcgadget: Use g_path_get_basename instead of libc basename
Musl does not implement GNU basename and have fixed a bug where the prototype was leaked into string.h [1], which resullts in compile errors with GCC-14 and Clang-17+ | sys/uvcgadget/configfs.c:262:21: error: call to undeclared function 'basename' ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] | 262 | const char *v = basename (globbuf.gl_pathv[i]); | | ^ Use glib function instead makes it portable across musl and glibc on linux [1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7a Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7028>
This commit is contained in:
parent
9a26c25211
commit
3e319081f5
1 changed files with 12 additions and 6 deletions
|
@ -7,7 +7,7 @@
|
||||||
* Contact: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
* Contact: Kieran Bingham <kieran.bingham@ideasonboard.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* To provide basename and asprintf from the GNU library. */
|
/* To provide asprintf from the GNU library. */
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
@ -259,9 +259,10 @@ udc_find_video_device (const char *udc, const char *function)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < globbuf.gl_pathc) {
|
if (i < globbuf.gl_pathc) {
|
||||||
const char *v = basename (globbuf.gl_pathv[i]);
|
gchar *v = g_path_get_basename (globbuf.gl_pathv[i]);
|
||||||
|
|
||||||
video = path_join ("/dev", v);
|
video = path_join ("/dev", v);
|
||||||
|
g_free (v);
|
||||||
}
|
}
|
||||||
|
|
||||||
globfree (&globbuf);
|
globfree (&globbuf);
|
||||||
|
@ -894,6 +895,7 @@ configfs_parse_uvc_function (const char *function)
|
||||||
{
|
{
|
||||||
struct uvc_function_config *fc;
|
struct uvc_function_config *fc;
|
||||||
char *fpath;
|
char *fpath;
|
||||||
|
gchar *bname;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
fc = malloc (sizeof *fc);
|
fc = malloc (sizeof *fc);
|
||||||
|
@ -923,11 +925,10 @@ configfs_parse_uvc_function (const char *function)
|
||||||
* Parse the function configuration. Remove the gadget name qualifier
|
* Parse the function configuration. Remove the gadget name qualifier
|
||||||
* from the function name, if any.
|
* from the function name, if any.
|
||||||
*/
|
*/
|
||||||
if (function)
|
bname = g_path_get_basename (function);
|
||||||
function = basename (function);
|
|
||||||
|
|
||||||
fc->udc = attribute_read_str (fpath, "../../UDC");
|
fc->udc = attribute_read_str (fpath, "../../UDC");
|
||||||
fc->video = udc_find_video_device (fc->udc, function);
|
fc->video = udc_find_video_device (fc->udc, bname);
|
||||||
if (!fc->video) {
|
if (!fc->video) {
|
||||||
ret = -ENODEV;
|
ret = -ENODEV;
|
||||||
goto done;
|
goto done;
|
||||||
|
@ -942,6 +943,7 @@ done:
|
||||||
}
|
}
|
||||||
|
|
||||||
free (fpath);
|
free (fpath);
|
||||||
|
g_free (bname);
|
||||||
|
|
||||||
return fc;
|
return fc;
|
||||||
}
|
}
|
||||||
|
@ -979,12 +981,16 @@ configfs_parse_uvc_videodev (int fd, const char *video)
|
||||||
char *function = NULL;
|
char *function = NULL;
|
||||||
char rpath[PATH_MAX];
|
char rpath[PATH_MAX];
|
||||||
char *res;
|
char *res;
|
||||||
|
gchar *bname;
|
||||||
|
|
||||||
res = realpath (video, rpath);
|
res = realpath (video, rpath);
|
||||||
if (!res)
|
if (!res)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
function = video_find_config_name (basename (rpath));
|
bname = g_path_get_basename (rpath);
|
||||||
|
function = video_find_config_name (bname);
|
||||||
|
g_free (bname);
|
||||||
|
|
||||||
if (!function)
|
if (!function)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue