summaryrefslogtreecommitdiffstats
path: root/__root__
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-03-18 19:40:14 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-03-20 17:41:39 +0100
commit4f9ef88aec2f8e722f9b6a8749ebc64b269f16f1 (patch)
tree5ff7c28a4d311623ba9941bf5d190eaa7b37137a /__root__
parenteb0754ea22d1a9633160ef15dbef92c0d256ad90 (diff)
downloadclufter-4f9ef88aec2f8e722f9b6a8749ebc64b269f16f1.tar.gz
clufter-4f9ef88aec2f8e722f9b6a8749ebc64b269f16f1.tar.xz
clufter-4f9ef88aec2f8e722f9b6a8749ebc64b269f16f1.zip
ccs-flatten/list.h: fix logical subtleties w/ list_do{,ne}
list_do: do not check *list twice list_done: do not check curr, as we are quite sure it will never reach NULL value implicitly (using intended list manipulators incl. the wrapped iteration itself, not explicit redefinition that is broken anyway), otherwise we would have already observed either trivial infloops or segfaults caused by reliance on such an assumption (curr != NULL) Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to '__root__')
-rw-r--r--__root__/ccs-flatten/list.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/__root__/ccs-flatten/list.h b/__root__/ccs-flatten/list.h
index d43ba01..9613eb4 100644
--- a/__root__/ccs-flatten/list.h
+++ b/__root__/ccs-flatten/list.h
@@ -54,14 +54,14 @@ do { \
/*
list_do(list, node) {
- stuff;
+ stuff; // redefining "node" (as well as "list) unsafe!
} while (!list_done(list, node));
*/
# define list_do(list, curr) \
- if (*list && (curr = *list)) do
+ if ((curr = *list)) do
# define list_done(list, curr) \
- (curr && (((curr = (void *)le(curr)->le_next)) && (curr == *list)))
+ ((curr = (void *)le(curr)->le_next) && (curr == *list))
/*
* list_for(list, tmp, counter) {