From 040c1f7e29e25785d2d84044b1a766aa819d527a Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 28 May 2026 11:20:07 +1000 Subject: [PATCH] libfdt: Revert accidental ABI breakage Commit bdca8612 introduced the new fdt_setprop_namelen() and fdt_setprop_placeholder_namelen() functions, making the existing fdt_setprop() and fdt_setprop_placeholder() trivial inline wrappers around them. I failed to realise that replacing the existing functions with (static) inlines breaks the library ABI. Theoretically it's possible to have the functions available as both an inline and a "real" symbol. However, because they do need to call strlen() before the lower level fdt function, these wrappers aren't quite as trivial as they appear (inlining may not be zero cost). So, instead revert and keep the old functions as true functions. Reported-by: David Runge Fixes: bdca8612 ("libfdt: Add fdt_setprop_namelen()") Link: https://github.com/dgibson/dtc/issues/184 Signed-off-by: David Gibson --- libfdt/fdt_rw.c | 14 ++++++++++++++ libfdt/libfdt.h | 17 ++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c index bea45ed..850aafe 100644 --- a/libfdt/fdt_rw.c +++ b/libfdt/fdt_rw.c @@ -292,6 +292,13 @@ int fdt_setprop_placeholder_namelen(void *fdt, int nodeoffset, const char *name, return 0; } +int fdt_setprop_placeholder(void *fdt, int nodeoffset, + const char *name, int len, void **prop_data) +{ + return fdt_setprop_placeholder_namelen(fdt, nodeoffset, name, + strlen(name), len, prop_data); +} + int fdt_setprop_namelen(void *fdt, int nodeoffset, const char *name, int namelen, const void *val, int len) { @@ -308,6 +315,13 @@ int fdt_setprop_namelen(void *fdt, int nodeoffset, const char *name, return 0; } +int fdt_setprop(void *fdt, int nodeoffset, const char *name, + const void *val, int len) +{ + return fdt_setprop_namelen(fdt, nodeoffset, name, strlen(name), val, + len); +} + int fdt_appendprop(void *fdt, int nodeoffset, const char *name, const void *val, int len) { diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h index 8c7770e..c69a18e 100644 --- a/libfdt/libfdt.h +++ b/libfdt/libfdt.h @@ -1935,12 +1935,8 @@ int fdt_setprop_namelen(void *fdt, int nodeoffset, const char *name, * -FDT_ERR_BADLAYOUT, * -FDT_ERR_TRUNCATED, standard meanings */ -static inline int fdt_setprop(void *fdt, int nodeoffset, const char *name, - const void *val, int len) -{ - return fdt_setprop_namelen(fdt, nodeoffset, name, strlen(name), val, - len); -} +int fdt_setprop(void *fdt, int nodeoffset, const char *name, + const void *val, int len); /** * fdt_setprop_placeholder_namelen - allocate space for a property @@ -2002,13 +1998,8 @@ int fdt_setprop_placeholder_namelen(void *fdt, int nodeoffset, const char *name, * -FDT_ERR_BADLAYOUT, * -FDT_ERR_TRUNCATED, standard meanings */ -static inline int fdt_setprop_placeholder(void *fdt, int nodeoffset, - const char *name, int len, - void **prop_data) -{ - return fdt_setprop_placeholder_namelen(fdt, nodeoffset, name, - strlen(name), len, prop_data); -} +int fdt_setprop_placeholder(void *fdt, int nodeoffset, + const char *name, int len, void **prop_data); /** * fdt_setprop_u32 - set a property to a 32-bit integer