Thread (5 messages) 5 messages, 3 authors, 2022-04-01

Re: [Drbd-dev] [PATCH 2/2] drbd: remove check of list iterator against head past the loop body

From: Jens Axboe <axboe@kernel.dk>
Date: 2022-03-31 23:09:56
Also in: lkml

On 3/31/22 4:28 PM, Christoph B?hmwalder wrote:
Am 01.04.22 um 00:03 schrieb Jakob Koschel:
quoted
When list_for_each_entry() completes the iteration over the whole list
without breaking the loop, the iterator value will be a bogus pointer
computed based on the head element.

While it is safe to use the pointer to determine if it was computed
based on the head element, either with list_entry_is_head() or
&pos->member == head, using the iterator variable after the loop should
be avoided.

In preparation to limit the scope of a list iterator to the list
traversal loop, use a dedicated pointer to point to the found element [1].
Hi Jakob,

Both of these look good to me, thanks.

Reviewed-by: Christoph B?hmwalder <christoph.boehmwalder@linbit.com>
Applied both, but shortened title of this commit. Jakob, please keep it
within the usual 74 chars. In general, it's great to use a cover letter
for anything that's more than one patch. Just some pointers if you're
doing more of these.

-- 
Jens Axboe
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help