[PATCH 1/4] string: add isempty helper
Marco Felsch
m.felsch at pengutronix.de
Wed Mar 13 12:45:44 PDT 2024
This adds systemd's isempty() helper which can be very handy.
Signed-off-by: Marco Felsch <m.felsch at pengutronix.de>
---
include/string.h | 2 ++
lib/string.c | 6 ++++++
2 files changed, 8 insertions(+)
diff --git a/include/string.h b/include/string.h
index 43911b75762f..ffe7c42d3093 100644
--- a/include/string.h
+++ b/include/string.h
@@ -20,4 +20,6 @@ char *parse_assignment(char *str);
int strverscmp(const char *a, const char *b);
+bool isempty(const char *s);
+
#endif /* __STRING_H */
diff --git a/lib/string.c b/lib/string.c
index bf0f0455ab3f..20e6947347de 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -1000,3 +1000,9 @@ char *parse_assignment(char *str)
return value;
}
+
+bool isempty(const char *s)
+{
+ return !s || s[0] == '\0';
+}
+EXPORT_SYMBOL(isempty);
--
2.39.2
More information about the barebox
mailing list