diff options
author | Stephen Warren <swarren@nvidia.com> | 2012-10-08 18:15:26 -0400 |
---|---|---|
committer | Rob Herring <rob.herring@calxeda.com> | 2012-10-17 16:53:04 -0400 |
commit | 205a8eb7ce713c7f1722297dd97d19dcea6f266c (patch) | |
tree | 9c7aaff54986d38023d329fc504de04c2e663ee3 /scripts/dtc | |
parent | 24fb530f990394915e8daceeca2a4a4e929e156f (diff) |
dtc: fix for_each_*() to skip first object if deleted
The previous definition of for_each_*() would always include the very
first object within the list, irrespective of whether it was marked
deleted, since the deleted flag was not checked on the first object,
but only on any "next" object.
Fix for_each_*() to check the deleted flag in the loop body every
iteration to correct this.
(upstream dtc commit 1762ab42ef77db7ab2776d0d6cba3515150f518a)
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Diffstat (limited to 'scripts/dtc')
-rw-r--r-- | scripts/dtc/dtc.h | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/scripts/dtc/dtc.h b/scripts/dtc/dtc.h index d501c8605f26..3e42a071070e 100644 --- a/scripts/dtc/dtc.h +++ b/scripts/dtc/dtc.h | |||
@@ -161,51 +161,27 @@ struct node { | |||
161 | struct label *labels; | 161 | struct label *labels; |
162 | }; | 162 | }; |
163 | 163 | ||
164 | static inline struct label *for_each_label_next(struct label *l) | ||
165 | { | ||
166 | do { | ||
167 | l = l->next; | ||
168 | } while (l && l->deleted); | ||
169 | |||
170 | return l; | ||
171 | } | ||
172 | |||
173 | #define for_each_label(l0, l) \ | ||
174 | for ((l) = (l0); (l); (l) = for_each_label_next(l)) | ||
175 | |||
176 | #define for_each_label_withdel(l0, l) \ | 164 | #define for_each_label_withdel(l0, l) \ |
177 | for ((l) = (l0); (l); (l) = (l)->next) | 165 | for ((l) = (l0); (l); (l) = (l)->next) |
178 | 166 | ||
179 | static inline struct property *for_each_property_next(struct property *p) | 167 | #define for_each_label(l0, l) \ |
180 | { | 168 | for_each_label_withdel(l0, l) \ |
181 | do { | 169 | if (!(l)->deleted) |
182 | p = p->next; | ||
183 | } while (p && p->deleted); | ||
184 | |||
185 | return p; | ||
186 | } | ||
187 | |||
188 | #define for_each_property(n, p) \ | ||
189 | for ((p) = (n)->proplist; (p); (p) = for_each_property_next(p)) | ||
190 | 170 | ||
191 | #define for_each_property_withdel(n, p) \ | 171 | #define for_each_property_withdel(n, p) \ |
192 | for ((p) = (n)->proplist; (p); (p) = (p)->next) | 172 | for ((p) = (n)->proplist; (p); (p) = (p)->next) |
193 | 173 | ||
194 | static inline struct node *for_each_child_next(struct node *c) | 174 | #define for_each_property(n, p) \ |
195 | { | 175 | for_each_property_withdel(n, p) \ |
196 | do { | 176 | if (!(p)->deleted) |
197 | c = c->next_sibling; | ||
198 | } while (c && c->deleted); | ||
199 | |||
200 | return c; | ||
201 | } | ||
202 | |||
203 | #define for_each_child(n, c) \ | ||
204 | for ((c) = (n)->children; (c); (c) = for_each_child_next(c)) | ||
205 | 177 | ||
206 | #define for_each_child_withdel(n, c) \ | 178 | #define for_each_child_withdel(n, c) \ |
207 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) | 179 | for ((c) = (n)->children; (c); (c) = (c)->next_sibling) |
208 | 180 | ||
181 | #define for_each_child(n, c) \ | ||
182 | for_each_child_withdel(n, c) \ | ||
183 | if (!(c)->deleted) | ||
184 | |||
209 | void add_label(struct label **labels, char *label); | 185 | void add_label(struct label **labels, char *label); |
210 | void delete_labels(struct label **labels); | 186 | void delete_labels(struct label **labels); |
211 | 187 | ||