[CRIU] [PATCH 1/3] util: Introduce STREQ and STRNEQ macros

Radostin Stoyanov rstoyanov1 at gmail.com
Mon Jan 28 01:18:57 MSK 2019


The function strcmp() is often used to check whether two strings are
equal. The macros STREQ and STRNEQ could be used instead to improve
readability of the source code.

Signed-off-by: Radostin Stoyanov <rstoyanov1 at gmail.com>
---
 criu/include/util.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/criu/include/util.h b/criu/include/util.h
index d9a1ff0f5..427fd5105 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -200,6 +200,10 @@ extern int read_fd_link(int lfd, char *buf, size_t size);
 
 int vaddr_to_pfn(int fd, unsigned long vaddr, u64 *pfn);
 
+/* String equality tests */
+#define STREQ(a, b) (strcmp(a, b) == 0)
+#define STRNEQ(a, b) (strcmp(a, b) != 0)
+
 /*
  * Check whether @str starts with @sub and report the
  * next character of @str in @end
-- 
2.20.1



More information about the CRIU mailing list