From: Andreas Schwab Date: Wed, 20 Sep 2017 16:28:53 GMT Subject: Re: [PATCH v2] for_each_string_list_item: avoid undefined behavior for empty list Message-ID: <87vakd2v22.fsf@linux-m68k.org> In-Reply-To: <20170920052705.GC126984@aiede.mtv.corp.google.com> On Sep 19 2017, Jonathan Nieder wrote: > B. #define for_each_string_list_item(item, list) \ > if (list->items) \ > for (item = ...; ...; ... ) > > This breaks a caller like > if (foo) > for_each_string_list_item(item, list) > ... > else > ... > > making it a non-starter. That can be fixed with a dangling else. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."