Thread (1 message) 1 message, 1 author, 2017-09-20

Re: [PATCH v2] for_each_string_list_item: avoid undefined behavior for empty list

From: Andreas Schwab <hidden>
Date: 2017-09-20 21:52:02

On Sep 20 2017, Jonathan Nieder [off-list ref] wrote:
Andreas Schwab wrote:
quoted
On Sep 19 2017, Jonathan Nieder [off-list ref] wrote:
quoted
quoted
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.
I believe the fix you're referring to is option C, from the same email
you are replying to.  If not, please correct me.
A variant thereof, yes.

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."
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help