From: Zou Wei <zou_wei@huawei.com>
To: <valentina.manea.m@gmail.com>, <shuah@kernel.org>
Cc: <linux-usb@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Zou Wei <zou_wei@huawei.com>
Subject: [PATCH -next] usbip: tools: Convert list_for_each to entry variant
Date: Tue, 15 Jun 2021 14:58:39 +0800 [thread overview]
Message-ID: <1623740319-15988-1-git-send-email-zou_wei@huawei.com> (raw)
convert list_for_each() to list_for_each_entry() where
applicable.
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Zou Wei <zou_wei@huawei.com>
---
tools/usb/usbip/libsrc/usbip_host_common.c | 4 +---
tools/usb/usbip/src/usbipd.c | 8 ++------
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c
index ca78aa3..80f16f0 100644
--- a/tools/usb/usbip/libsrc/usbip_host_common.c
+++ b/tools/usb/usbip/libsrc/usbip_host_common.c
@@ -267,12 +267,10 @@ int usbip_export_device(struct usbip_exported_device *edev, int sockfd)
struct usbip_exported_device *usbip_generic_get_device(
struct usbip_host_driver *hdriver, int num)
{
- struct list_head *i;
struct usbip_exported_device *edev;
int cnt = 0;
- list_for_each(i, &hdriver->edev_list) {
- edev = list_entry(i, struct usbip_exported_device, node);
+ list_for_each_entry(edev, &hdriver->edev_list, node) {
if (num == cnt)
return edev;
cnt++;
diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
index 48398a7..438346e 100644
--- a/tools/usb/usbip/src/usbipd.c
+++ b/tools/usb/usbip/src/usbipd.c
@@ -93,7 +93,6 @@ static int recv_request_import(int sockfd)
struct op_import_request req;
struct usbip_exported_device *edev;
struct usbip_usb_device pdu_udev;
- struct list_head *i;
int found = 0;
int status = ST_OK;
int rc;
@@ -107,8 +106,7 @@ static int recv_request_import(int sockfd)
}
PACK_OP_IMPORT_REQUEST(0, &req);
- list_for_each(i, &driver->edev_list) {
- edev = list_entry(i, struct usbip_exported_device, node);
+ list_for_each_entry(edev, &driver->edev_list, node) {
if (!strncmp(req.busid, edev->udev.busid, SYSFS_BUS_ID_SIZE)) {
info("found requested device: %s", req.busid);
found = 1;
@@ -160,7 +158,6 @@ static int send_reply_devlist(int connfd)
struct usbip_usb_device pdu_udev;
struct usbip_usb_interface pdu_uinf;
struct op_devlist_reply reply;
- struct list_head *j;
int rc, i;
/*
@@ -174,8 +171,7 @@ static int send_reply_devlist(int connfd)
reply.ndev = 0;
/* number of exported devices */
- list_for_each(j, &driver->edev_list) {
- edev = list_entry(j, struct usbip_exported_device, node);
+ list_for_each_entry(edev, &driver->edev_list, node) {
if (edev->status != SDEV_ST_USED)
reply.ndev += 1;
}
--
2.6.2
next reply other threads:[~2021-06-15 6:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 6:58 Zou Wei [this message]
2021-06-15 17:48 ` [PATCH -next] usbip: tools: Convert list_for_each to entry variant Shuah Khan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1623740319-15988-1-git-send-email-zou_wei@huawei.com \
--to=zou_wei@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=valentina.manea.m@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).