weston: Fix build with musl

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj
2023-12-14 09:25:11 -08:00
committed by Matt Madison
parent cbce07f070
commit 3fd54413c3
2 changed files with 73 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
From 50a44ee682360fc9793e74aea86f53efe8286094 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Thu, 14 Dec 2023 09:13:54 -0800
Subject: [PATCH] libweston,tools: Include libgen.h for basename signature
Latest musl has removed the declaration from string.h [1] as it only
implements POSIX version alone and string.h in glibc implements GNU
version of basename. This now results in compile errors on musl.
This might be a warning with older compilers but it is error with
Clang-17+ as it treats -Wimplicit-function-declaration as error
Switch the use in backlight_init function to use POSIX version
[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
Upstream-Status: Submitted [https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/1420]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
libweston/backend-drm/libbacklight.c | 8 +++++---
tools/zunitc/src/zunitc_impl.c | 1 +
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/libweston/backend-drm/libbacklight.c b/libweston/backend-drm/libbacklight.c
index ca7f2d68..973d15ff 100644
--- a/libweston/backend-drm/libbacklight.c
+++ b/libweston/backend-drm/libbacklight.c
@@ -41,6 +41,7 @@
#include <drm.h>
#include <fcntl.h>
#include <malloc.h>
+#include <libgen.h>
#include <string.h>
#include <errno.h>
@@ -167,7 +168,7 @@ struct backlight *backlight_init(struct udev_device *drm_device,
DIR *backlights = NULL;
struct dirent *entry;
enum backlight_type type = 0;
- char buffer[100];
+ char buffer[100], basename_buffer[100];
struct backlight *backlight = NULL;
int ret;
@@ -186,9 +187,10 @@ struct backlight *backlight_init(struct udev_device *drm_device,
free(path);
if (ret < 0)
return NULL;
-
+ strncpy(basename_buffer, buffer, ret);
buffer[ret] = '\0';
- pci_name = basename(buffer);
+ basename_buffer[ret] = '\0';
+ pci_name = basename(basename_buffer);
if (connector_type <= 0)
return NULL;
diff --git a/tools/zunitc/src/zunitc_impl.c b/tools/zunitc/src/zunitc_impl.c
index 18f03015..9b460fa0 100644
--- a/tools/zunitc/src/zunitc_impl.c
+++ b/tools/zunitc/src/zunitc_impl.c
@@ -27,6 +27,7 @@
#include <errno.h>
#include <fcntl.h>
+#include <libgen.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
--
2.43.0

View File

@@ -7,6 +7,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d79ee9e66bb0f95d3386a7acae780b70 \
"
SRC_URI = "https://gitlab.freedesktop.org/wayland/weston/-/releases/${PV}/downloads/${BPN}-${PV}.tar.xz \
file://0001-libweston-tools-Include-libgen.h-for-basename-signat.patch \
file://weston.png \
file://weston.desktop \
file://xwayland.weston-start \