Provide GNU basename compatible implementation
Subsystems (2)
PATCH v4 1/1 Provide GNU basename compatible implementation
Call to basename() relies on a GNU extension
to take a const char * vs a char *. Let's define
a trivial helper function to ensure compatibility
with musl.
Fixes Issue: https://github.com/bluez/bluez/issues/843
---
v2: Fix code formatter reported errors
v3: Make just node_name as const and keep node_dir as such
v4: Fix code formatting errors
Makefile.mesh | 2 ++ Makefile.tools | 3 ++- mesh/mesh-config-json.c | 6 ++++-- mesh/rpl.c | 3 ++- src/shared/util.h | 7 +++++++ tools/hex2hcd.c | 3 ++- 6 files changed, 19 insertions(+), 5 deletions(-)
Makefile.mesh +2 -0
@@ -47,6 +47,8 @@ mesh/main.$(OBJEXT): src/builtin.h lib/bluetooth/bluetooth.h mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c +mesh_bluetooth_meshd_CFLAGS = -I${top_srcdir}/src + if MANPAGES man_MANS += mesh/bluetooth-meshd.8 endif
Makefile.tools +2 -1
@@ -328,7 +328,8 @@ tools_l2ping_LDADD = lib/libbluetooth-internal.la tools_bluemoon_SOURCES = tools/bluemoon.c monitor/bt.h tools_bluemoon_LDADD = src/libshared-mainloop.la -tools_hex2hcd_SOURCES = tools/hex2hcd.c +tools_hex2hcd_SOURCES = tools/hex2hcd.c src/shared/util.h +tools_hex2hcd_CFLAGS = -I${top_srcdir}/src tools_mpris_proxy_SOURCES = tools/mpris-proxy.c tools_mpris_proxy_LDADD = gdbus/libgdbus-internal.la $(GLIB_LIBS) $(DBUS_LIBS)
mesh/mesh-config-json.c +4 -2
@@ -28,6 +28,7 @@#include <ell/ell.h> #include <json-c/json.h> +#include "shared/util.h" #include "mesh/mesh-defs.h" #include "mesh/util.h" #include "mesh/mesh-config.h"
@@ -2694,7 +2695,8 @@ bool mesh_config_load_nodes(const char *cfgdir_name, mesh_config_node_func_t cb,void mesh_config_destroy_nvm (struct mesh_config *cfg) { -char *node_dir, *node_name; +char *node_dir; +const char *node_name;char uuid[33 ];if (!cfg)
@@ -2706,7 +2708,7 @@ void mesh_config_destroy_nvm(struct mesh_config *cfg)if (!hex2str (cfg->uuid,16 , uuid,sizeof (uuid)))return ; - node_name =basename (node_dir); + node_name =bluez_basename (node_dir);/* Make sure path name of node follows expected guidelines */ if (strcmp (node_name, uuid))
mesh/rpl.c +2 -1
@@ -24,6 +24,7 @@#include <ell/ell.h> +#include "shared/util.h" #include "mesh/mesh-defs.h" #include "mesh/node.h"
@@ -146,7 +147,7 @@ static void get_entries(const char *iv_path, struct l_queue *rpl_list)if (!dir)return ; - iv_txt =basename (iv_path); + iv_txt =bluez_basename (iv_path);if (sscanf (iv_txt,"%08x" , &iv_index) !=1 ) {closedir (dir);return ;
src/shared/util.h +7 -0
@@ -296,3 +296,10 @@ static inline void put_be64(uint64_t val, void *dst) {put_unaligned (cpu_to_be64 (val), (uint64_t *) dst); } + +static inline const char *bluez_basename (const char *path) +{ +const char *base =strrchr (path,'/' ); + +return base ? base +1 : path; +}
tools/hex2hcd.c +2 -1
@@ -24,6 +24,7 @@#include <stdlib.h> #include <stdbool.h> #include <sys/stat.h> +#include "shared/util.h" static ssize_t process_record (int fd,const char *line,uint16_t *upper_addr) {
@@ -302,7 +303,7 @@ static void ver_parse_entry(const char *pathname) }if (S_ISREG (st.st_mode)) { -ver_parse_file (basename (pathname)); +ver_parse_file (bluez_basename (pathname)); goto done; }
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=883958
---Test result---
Test Summary:
CheckPatch PASS 0.45 seconds GitLint PASS 0.30 seconds BuildEll PASS 24.65 seconds BluezMake PASS 1716.84 seconds MakeCheck PASS 13.81 seconds MakeDistcheck PASS 179.04 seconds CheckValgrind PASS 251.42 seconds CheckSmatch WARNING 357.66 seconds bluezmakeextell PASS 120.50 seconds IncrementalBuild PASS 1467.02 seconds ScanBuild PASS 1010.90 seconds
Details
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:tools/hex2hcd.c:136:26: warning: Variable length array is used.
---
Regards,
Linux Bluetooth