Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3407778pxj; Mon, 14 Jun 2021 23:41:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKPKC2s6JbGzZBAAvq6ltmGOQIjG1z7qaYDQpEbynn5IIBmSyUibopVgv2L1zLjKRdall8 X-Received: by 2002:a05:6e02:ec5:: with SMTP id i5mr16763095ilk.168.1623739283257; Mon, 14 Jun 2021 23:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623739283; cv=none; d=google.com; s=arc-20160816; b=DLNESKGDuecnB4KlTlSBI7sOGx4jBQ/bZIheTmfprt1ihERCj3zwxxTEMZiaL2bj/8 35L9/KAiAU0FlC2eVJzRbFBATFoAar5fC1qCQNpgY09P5gDYAwpe0aH8AKnVwPdQGUek qC119oe2XyfGJPFVoPrDyl4zbjtkjRFJ66B7oyyMX8fsKLEoPJdEGUoZnaZvC2qXIyVN ut0t5irDNZQvTFpO7YG4k4G3oFdDTicQfct5KD9olErIvBX/T/iixmoCThQgA7hulyr3 DWyWq5DjUnPVjaB7sB3Df11lw+QR7sKbT+y5HVbfPXsOZcwYdE980rWFKpBVa8bqSFV4 QIXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=dTgRtJYmdTUSpf/yaGHqeYDMz+QJ4oOxZ1VS8invptc=; b=hZcZxi2RTGjYL1QRBn369/AfeSe22FZAbbVaUWliIiuu9LrNHLFOgCQWsUlGcc1cI6 rBVRKJ8FqyWs8R/3pexieaaU4qK+xOYsLur5S2cDBQILDNZkjWvOyto64n8xokzeTGIQ YbgC0FLzH9TkT6whXh+YDVBX58HUTDF5qp9158sLuLswVIVdPLTveY6Iki7WuP1cwMBi gpSZTL19lfbo77YDIxHMuFMAU846jLKQK/6H5xtLv+rxBoaOxBdzKZcb8eooNuq4CxCk tRC5xgmjmlDOdR80joR7DRMZC9ffENy39xWp77nv47Wk5wtwAk2bC3AA2K6AgoJoqFEh uUIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i19si20247613ilj.131.2021.06.14.23.41.11; Mon, 14 Jun 2021 23:41:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229976AbhFOGmV (ORCPT + 99 others); Tue, 15 Jun 2021 02:42:21 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:4782 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbhFOGmS (ORCPT ); Tue, 15 Jun 2021 02:42:18 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4G3z8J0jrbzXg4G; Tue, 15 Jun 2021 14:35:12 +0800 (CST) Received: from dggemi762-chm.china.huawei.com (10.1.198.148) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Tue, 15 Jun 2021 14:40:09 +0800 Received: from linux-lmwb.huawei.com (10.175.103.112) by dggemi762-chm.china.huawei.com (10.1.198.148) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 15 Jun 2021 14:40:08 +0800 From: Zou Wei To: , CC: , , Zou Wei Subject: [PATCH -next] usbip: tools: Convert list_for_each to entry variant Date: Tue, 15 Jun 2021 14:58:39 +0800 Message-ID: <1623740319-15988-1-git-send-email-zou_wei@huawei.com> X-Mailer: git-send-email 2.6.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.103.112] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggemi762-chm.china.huawei.com (10.1.198.148) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org convert list_for_each() to list_for_each_entry() where applicable. Reported-by: Hulk Robot Signed-off-by: Zou Wei --- 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