Re: [PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-07 Thread Jan Kara
On Thu 07-11-13 13:38:00, Andrew Morton wrote: > On Wed, 6 Nov 2013 17:42:30 -0800 Cody P Schafer > wrote: > > > The iterator rbtree_postorder_for_each_entry_safe() relies on pointer > > underflow behavior when testing for loop termination. In particular > > it expects that > > &rb_entry(NULL

Re: [PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-07 Thread Cody P Schafer
On 11/07/2013 01:38 PM, Andrew Morton wrote: On Wed, 6 Nov 2013 17:42:30 -0800 Cody P Schafer wrote: The iterator rbtree_postorder_for_each_entry_safe() relies on pointer underflow behavior when testing for loop termination. In particular it expects that &rb_entry(NULL, type, field)->fiel

Re: [PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-07 Thread Andrew Morton
On Wed, 6 Nov 2013 17:42:30 -0800 Cody P Schafer wrote: > The iterator rbtree_postorder_for_each_entry_safe() relies on pointer > underflow behavior when testing for loop termination. In particular > it expects that > &rb_entry(NULL, type, field)->field > is NULL. But the result of this expre

Re: [PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-07 Thread Cody P Schafer
On 11/07/2013 03:51 AM, Michel Lespinasse wrote: On Wed, Nov 6, 2013 at 5:42 PM, Cody P Schafer wrote: From: Jan Kara [...] +#define rb_entry_safe(ptr, type, member) \ + ({ typeof(ptr) ptr = (ptr); \ + ptr ? rb_entry(ptr, type, member) : NULL; \ + }) + /*

Re: [PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-07 Thread Michel Lespinasse
On Wed, Nov 6, 2013 at 5:42 PM, Cody P Schafer wrote: > From: Jan Kara > > The iterator rbtree_postorder_for_each_entry_safe() relies on pointer > underflow behavior when testing for loop termination. In particular > it expects that > &rb_entry(NULL, type, field)->field > is NULL. But the resul

[PATCH v2 01/11] rbtree: Fix rbtree_postorder_for_each_entry_safe() iterator

2013-11-06 Thread Cody P Schafer
From: Jan Kara The iterator rbtree_postorder_for_each_entry_safe() relies on pointer underflow behavior when testing for loop termination. In particular it expects that &rb_entry(NULL, type, field)->field is NULL. But the result of this expression is not defined by a C standard and some gcc ver