Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp79945ybk; Fri, 8 May 2020 19:18:40 -0700 (PDT) X-Google-Smtp-Source: APiQypJlUgnXLAwqEjxS9uMbymaefUWH6Dr0dWt+/6nuMCrqB/1p2x3JEHZ4kQkvwU3tbBciEKCg X-Received: by 2002:a05:6402:319c:: with SMTP id di28mr4903288edb.185.1588990720083; Fri, 08 May 2020 19:18:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588990720; cv=none; d=google.com; s=arc-20160816; b=ElGHu+fbJVsOgEjfcRt6Z+nRqLjK5E5IXet0swmJMRdsTJWuCG/l7eZIOUP2sJhO2A B7jwWNsZvtOywTD8pPaqmMLEMyipp1VNFHNjCYJJQ7cNDmlJVrJ+W+7fPq1oo9Y1vumP vPOWt/To+erLHht/gVBf0gHdQ4c891PMRtnqQGYAolZG5EJy/NMGSzBDQkjFUj4nPUny c7FKY0xlWDlCvRSMNBJcd0JGEVxgSc7K/6y3R7opGK/8Sn2XWJYMQ3TA4o/OMLw42PRO z4ikBb63niQFUofZ/loL/B+EW61etmhOZah8XU0RmzoWiUcg4mt4CzvwHoj87O6wVvMe OKfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=ZSGZ5x7ZTrECLopk5bt41QPxuDOGshRfkW63Ki0m/vI=; b=yHkGigVdmdCLJRvKBezL/0ieS6bggBh6Jd5wZ44k88xh9GdZv5Y7DYlngftZE7/QAa pfVCf34HsZ6202PIRF4XdMWsl1MpK0i6Q02KFUMp1mjlmcZ3Xg0BXA0iWvVNzPoi2mAw goOZgAxZFspmK8HPuYrVk9CDWEsKCENLgukHjHK1LCE/fXRCPwLYkzJs2ZcHdfSjRgRF p1uROAudqhcYsv6OeQLs9E/Xk+Uzujczs1bEhI0rNkZm8iGuUOe9MCI/EkSAoV35KOEw FbnJgm2Zrt64dMy0q2awrgIGe0ZOBbisdYSxQLOrhvafP0rcVFs0U1jGGYBshaZbkQ/w wKyw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v29si1840794eda.533.2020.05.08.19.18.09; Fri, 08 May 2020 19:18:40 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728639AbgEICOE (ORCPT + 99 others); Fri, 8 May 2020 22:14:04 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:33808 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728158AbgEICOE (ORCPT ); Fri, 8 May 2020 22:14:04 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 54A5FDA2AAC64CB016C5; Sat, 9 May 2020 10:14:02 +0800 (CST) Received: from linux-lmwb.huawei.com (10.175.103.112) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Sat, 9 May 2020 10:13:53 +0800 From: Samuel Zou To: , CC: , , Samuel Zou Subject: [PATCH -next] vdpasim: Fix some coccinelle warnings Date: Sat, 9 May 2020 10:20:02 +0800 Message-ID: <1588990802-28451-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-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix below warnings reported by coccicheck: drivers/vdpa/vdpa_sim/vdpa_sim.c:104:1-10: WARNING: Assignment of 0/1 to bool variable drivers/vdpa/vdpa_sim/vdpa_sim.c:164:7-11: WARNING: Unsigned expression compared with zero: read <= 0 drivers/vdpa/vdpa_sim/vdpa_sim.c:169:7-12: WARNING: Unsigned expression compared with zero: write <= 0 1. The 'ready' variable in vdpasim_virtqueue struct is bool type. It is better to initialize vq->ready to false 2. Modify 'read' and 'write' variables type from size_t to ssize_t. And preserve the reverse christmas tree ordering of local variables. Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator") Reported-by: Hulk Robot Signed-off-by: Samuel Zou --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c index 01c456f..c7334cc 100644 --- a/drivers/vdpa/vdpa_sim/vdpa_sim.c +++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c @@ -101,7 +101,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx) static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq) { - vq->ready = 0; + vq->ready = false; vq->desc_addr = 0; vq->driver_addr = 0; vq->device_addr = 0; @@ -131,9 +131,10 @@ static void vdpasim_work(struct work_struct *work) vdpasim, work); struct vdpasim_virtqueue *txq = &vdpasim->vqs[1]; struct vdpasim_virtqueue *rxq = &vdpasim->vqs[0]; - size_t read, write, total_write; - int err; + ssize_t read, write; + size_t total_write; int pkts = 0; + int err; spin_lock(&vdpasim->lock); -- 2.6.2