mirror of https://github.com/citusdata/citus.git
Make bad refactors to foreach_xxx error out
Without this commit you could still use varCell in the body of loop. This makes it easy for bad refactors that still use the ListCell to slip through unnoticed, because the new ListCell will be named the same as the one used in the old code. By renaming the ListCell to varCellDoNotUse this will not happen.pull/3545/head
parent
685b54b3de
commit
c48f0ca7e5
|
@ -27,8 +27,8 @@
|
||||||
* cell in.
|
* cell in.
|
||||||
*
|
*
|
||||||
* How it works:
|
* How it works:
|
||||||
* - A ListCell is declared with the name {var}Cell and used throughout the
|
* - A ListCell is declared with the name {var}CellDoNotUse and used
|
||||||
* for loop using ## to concat.
|
* throughout the for loop using ## to concat.
|
||||||
* - To assign to var it needs to be done in the condition of the for loop,
|
* - To assign to var it needs to be done in the condition of the for loop,
|
||||||
* because we cannot use the initializer since a ListCell* variable is
|
* because we cannot use the initializer since a ListCell* variable is
|
||||||
* declared there.
|
* declared there.
|
||||||
|
@ -36,9 +36,10 @@
|
||||||
* var is NULL.
|
* var is NULL.
|
||||||
*/
|
*/
|
||||||
#define foreach_ptr(var, l) \
|
#define foreach_ptr(var, l) \
|
||||||
for (ListCell *(var ## Cell) = list_head(l); \
|
for (ListCell *(var ## CellDoNotUse) = list_head(l); \
|
||||||
(var ## Cell) != NULL && (((var) = lfirst(var ## Cell)) || true); \
|
(var ## CellDoNotUse) != NULL && \
|
||||||
var ## Cell = lnext(var ## Cell))
|
(((var) = lfirst(var ## CellDoNotUse)) || true); \
|
||||||
|
var ## CellDoNotUse = lnext(var ## CellDoNotUse))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -48,9 +49,10 @@
|
||||||
* For explanation of how it works see foreach_ptr.
|
* For explanation of how it works see foreach_ptr.
|
||||||
*/
|
*/
|
||||||
#define foreach_int(var, l) \
|
#define foreach_int(var, l) \
|
||||||
for (ListCell *(var ## Cell) = list_head(l); \
|
for (ListCell *(var ## CellDoNotUse) = list_head(l); \
|
||||||
(var ## Cell) != NULL && (((var) = lfirst_int(var ## Cell)) || true); \
|
(var ## CellDoNotUse) != NULL && \
|
||||||
var ## Cell = lnext(var ## Cell))
|
(((var) = lfirst_int(var ## CellDoNotUse)) || true); \
|
||||||
|
var ## CellDoNotUse = lnext(var ## CellDoNotUse))
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -60,9 +62,10 @@
|
||||||
* For explanation of how it works see foreach_ptr.
|
* For explanation of how it works see foreach_ptr.
|
||||||
*/
|
*/
|
||||||
#define foreach_oid(var, l) \
|
#define foreach_oid(var, l) \
|
||||||
for (ListCell *(var ## Cell) = list_head(l); \
|
for (ListCell *(var ## CellDoNotUse) = list_head(l); \
|
||||||
(var ## Cell) != NULL && (((var) = lfirst_oid(var ## Cell)) || true); \
|
(var ## CellDoNotUse) != NULL && \
|
||||||
var ## Cell = lnext(var ## Cell))
|
(((var) = lfirst_oid(var ## CellDoNotUse)) || true); \
|
||||||
|
var ## CellDoNotUse = lnext(var ## CellDoNotUse))
|
||||||
|
|
||||||
|
|
||||||
/* utility functions declaration shared within this module */
|
/* utility functions declaration shared within this module */
|
||||||
|
|
Loading…
Reference in New Issue