From cb445b8b1458cc2e2e09bfe6b4f999f3ed8b684d Mon Sep 17 00:00:00 2001 From: Burt P Date: Wed, 19 Jul 2017 20:46:36 -0500 Subject: device tree: add helper function for appending elements Cleans up code for lists of mixed-type elements. appf() is like h_strdup_cprintf() but with a cute name, logical param order and adds a space when the string is not empty. Signed-off-by: Burt P --- includes/dt_util.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'includes/dt_util.h') diff --git a/includes/dt_util.h b/includes/dt_util.h index bf56c293..4bd72133 100644 --- a/includes/dt_util.h +++ b/includes/dt_util.h @@ -72,4 +72,10 @@ char *dtr_maps_info(dtr *); /* returns hardinfo shell section */ const char *dtr_find_device_tree_root(void); +#define sp_sep(STR) (strlen(STR) ? " " : "") +/* appends an element to a string, adding a space if + * the string is not empty. + * ex: ret = appf(ret, "%s=%s\n", name, value); */ +char *appf(char *src, char *fmt, ...); + #endif -- cgit v1.2.3