]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
macro: add STRLITERALLEN() and STRARRAYLEN()
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 22 Sep 2018 09:14:08 +0000 (11:14 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 23 Sep 2018 10:56:13 +0000 (12:56 +0200)
sizeof() implementation for string literals and string arrays that makes
it behave like strlen() for strings.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/macro.h

index 3ff40648ac3d805014468f9ee55d963348b054a4..52acfee807a221b1cbfba6c558cd10b97ce3eeb6 100644 (file)
@@ -348,4 +348,7 @@ extern int __build_bug_on_failed;
 #define LXC_INVALID_UID ((uid_t)-1)
 #define LXC_INVALID_GID ((gid_t)-1)
 
+#define STRLITERALLEN(x) (sizeof(""x"") - 1)
+#define STRARRAYLEN(x) (sizeof(x) - 1)
+
 #endif /* __LXC_MACRO_H */