dcavalca / rpms / systemd

Forked from rpms/systemd 3 months ago
Clone
Zbigniew Jędrzejewski-Szmek 62fe94
From 4a690c47260ca507bbcf92e2a68f66d3ec9a23fb Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 62fe94
From: Tom Gundersen <teg@jklm.no>
Zbigniew Jędrzejewski-Szmek 62fe94
Date: Thu, 25 Sep 2014 16:12:41 +0200
Zbigniew Jędrzejewski-Szmek 62fe94
Subject: [PATCH] shared: path-util - try to make PATH_FORECH_PREFIX look less
Zbigniew Jędrzejewski-Szmek 62fe94
 wrong
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
We replace the idiom "X && !(*foo = 0)" with "X && ((*foo = 0), true)".
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
This is not a functional change, but should hopefully make it less
Zbigniew Jędrzejewski-Szmek 62fe94
likely that people and static analyzers believe there is a typo here
Zbigniew Jędrzejewski-Szmek 62fe94
(i.e., to make it clear that the intention was not "X && *foo != 0").
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
Thanks to David Herrmann for the suggestion.
Zbigniew Jędrzejewski-Szmek 62fe94
---
Zbigniew Jędrzejewski-Szmek 62fe94
 src/shared/path-util.h | 4 ++--
Zbigniew Jędrzejewski-Szmek 62fe94
 1 file changed, 2 insertions(+), 2 deletions(-)
Zbigniew Jędrzejewski-Szmek 62fe94
Zbigniew Jędrzejewski-Szmek 62fe94
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
Zbigniew Jędrzejewski-Szmek 62fe94
index d85291bb44..8d171a57ec 100644
Zbigniew Jędrzejewski-Szmek 62fe94
--- a/src/shared/path-util.h
Zbigniew Jędrzejewski-Szmek 62fe94
+++ b/src/shared/path-util.h
Zbigniew Jędrzejewski-Szmek 62fe94
@@ -65,8 +65,8 @@ int fsck_exists(const char *fstype);
Zbigniew Jędrzejewski-Szmek 62fe94
  * the tree, to root. Also returns "" (and not "/"!) for the root
Zbigniew Jędrzejewski-Szmek 62fe94
  * directory. Excludes the specified directory itself */
Zbigniew Jędrzejewski-Szmek 62fe94
 #define PATH_FOREACH_PREFIX(prefix, path) \
Zbigniew Jędrzejewski-Szmek 62fe94
-        for (char *_slash = ({ path_kill_slashes(strcpy(prefix, path)); streq(prefix, "/") ? NULL : strrchr(prefix, '/'); }); _slash && !(*_slash = 0); _slash = strrchr((prefix), '/'))
Zbigniew Jędrzejewski-Szmek 62fe94
+        for (char *_slash = ({ path_kill_slashes(strcpy(prefix, path)); streq(prefix, "/") ? NULL : strrchr(prefix, '/'); }); _slash && ((*_slash = 0), true); _slash = strrchr((prefix), '/'))
Zbigniew Jędrzejewski-Szmek 62fe94
 
Zbigniew Jędrzejewski-Szmek 62fe94
 /* Same as PATH_FOREACH_PREFIX but also includes the specified path itself */
Zbigniew Jędrzejewski-Szmek 62fe94
 #define PATH_FOREACH_PREFIX_MORE(prefix, path) \
Zbigniew Jędrzejewski-Szmek 62fe94
-        for (char *_slash = ({ path_kill_slashes(strcpy(prefix, path)); if (streq(prefix, "/")) prefix[0] = 0; strrchr(prefix, 0); }); _slash && !(*_slash = 0); _slash = strrchr((prefix), '/'))
Zbigniew Jędrzejewski-Szmek 62fe94
+        for (char *_slash = ({ path_kill_slashes(strcpy(prefix, path)); if (streq(prefix, "/")) prefix[0] = 0; strrchr(prefix, 0); }); _slash && ((*_slash = 0), true); _slash = strrchr((prefix), '/'))