tools/xenstore: simplify loop handling connection I/O

The loop handling input and output of connections of xenstored is
open coding list_for_each_entry_safe() in an incredibly complicated
way.

Use list_for_each_entry_safe() instead, making it much more clear how
the code is working.

Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Julien Grall <jgrall@amazon.com>
This commit is contained in:
Juergen Gross authored and Jan Beulich committed 2022-06-15 10:22:38 +02:00
1 parent e2d2b9fd7a
commit e8e6e42279
1 file changed
+2 -10
+2 -10
View File
@@ -2368,16 +2368,8 @@ int main(int argc, char *argv[])
}
}
next = list_entry(connections.next, typeof(*conn), list);
if (&next->list != &connections)
talloc_increase_ref_count(next);
while (&next->list != &connections) {
conn = next;
next = list_entry(conn->list.next,
typeof(*conn), list);
if (&next->list != &connections)
talloc_increase_ref_count(next);
list_for_each_entry_safe(conn, next, &connections, list) {
talloc_increase_ref_count(conn);
if (conn_can_read(conn))
handle_input(conn);
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.