On Tue, Jun 12, 2018 at 04:14:04PM +0100, Ramsay Jones wrote: > > > On 11/06/18 02:51, Luc Van Oostenryck wrote: > > The list walking macros are relatively complex and the code they define > > have often 5 or 6 level of nesting. > > > > However, in a few places, a small rewrite of the code can save one > > nesting level and this help to make the code more readable. > > > > Make this change and reduce the indentation level. > > > > Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> > > --- > > ptrlist.h | 65 ++++++++++++++++++++++++++----------------------------- > > 1 file changed, 31 insertions(+), 34 deletions(-) > > > > diff --git a/ptrlist.h b/ptrlist.h > > index 037fe28ff..c28abce6d 100644 > > --- a/ptrlist.h > > +++ b/ptrlist.h > > @@ -157,44 +157,42 @@ static inline void *last_ptr_list(struct ptr_list *list) > > #define DO_FOR_EACH(head, ptr, __head, __list, __nr, PTR_ENTRY) do { \ > > __typeof__(head) __head = head; \ > > __typeof__(head) __list = head; \ > > - if (__head) { \ > > - do { int __nr; \ > > - for (__nr = 0; __nr < __list->nr; __nr++) { \ > > - do { \ > > - ptr = PTR_ENTRY(__list,__nr); \ > > - if (__list->rm && !ptr) \ > > - continue; \ > > - do { > > + if (!__head) break; \ > > This patch is difficult to read (not your fault), so I will > only say that I think it is correct. ;-) Yes, it's not easy, but it's rather well tested. > Again, not your fault, but it is not helped by this pattern: > > > + do { int __nr; \ > > + for (__nr = 0; __nr < __list->nr; __nr++) { \ > > ... which declares the __nr variable on the 'do {' line. This case > is not the worst, but it throws off the indentation level, for the > sake of saving one line! :( Yes. I have a patch (not yet posted and which I don't really intend to post, at least not in the near future) which abstract things a bit more and where one of the preparatory patch make that the triplets head-list-nr are always kept together. Maybe I should add this one here. -- Luc -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html