From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752682AbcHIKRd (ORCPT ); Tue, 9 Aug 2016 06:17:33 -0400 Received: from prv-mh.provo.novell.com ([137.65.248.74]:48114 "EHLO prv-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751590AbcHIKRb convert rfc822-to-8bit (ORCPT ); Tue, 9 Aug 2016 06:17:31 -0400 Message-Id: <57A9C9D7020000780010426B@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Tue, 09 Aug 2016 04:17:27 -0600 From: "Jan Beulich" To: "David Vrabel" , "Boris Ostrovsky" , "Juergen Gross" Cc: "xen-devel" , Subject: [PATCH v2] xenbus: prefer list_for_each() Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is more efficient than list_for_each_safe() when list modification is accompanied by breaking out of the loop. Signed-off-by: Jan Beulich Reviewed-by: Juergen Gross --- v2: Avoid commit message to continue from subject. --- drivers/xen/xenbus/xenbus_dev_frontend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- 4.8-rc1/drivers/xen/xenbus/xenbus_dev_frontend.c +++ 4.8-rc1-xen-xenbus-dev-list_for_each/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -364,7 +364,7 @@ out: static int xenbus_write_watch(unsigned msg_type, struct xenbus_file_priv *u) { - struct watch_adapter *watch, *tmp_watch; + struct watch_adapter *watch; char *path, *token; int err, rc; LIST_HEAD(staging_q); @@ -399,7 +399,7 @@ static int xenbus_write_watch(unsigned m } list_add(&watch->list, &u->watches); } else { - list_for_each_entry_safe(watch, tmp_watch, &u->watches, list) { + list_for_each_entry(watch, &u->watches, list) { if (!strcmp(watch->token, token) && !strcmp(watch->watch.node, path)) { unregister_xenbus_watch(&watch->watch);