Skip to content

Commit 18e643c

Browse files
SamuelZOUmstsirkin
authored andcommitted
vdpasim: Fix some coccinelle warnings
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: 2c53d0f ("vdpasim: vDPA device simulator") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Samuel Zou <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent 7dd793f commit 18e643c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
101101

102102
static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq)
103103
{
104-
vq->ready = 0;
104+
vq->ready = false;
105105
vq->desc_addr = 0;
106106
vq->driver_addr = 0;
107107
vq->device_addr = 0;
@@ -131,9 +131,10 @@ static void vdpasim_work(struct work_struct *work)
131131
vdpasim, work);
132132
struct vdpasim_virtqueue *txq = &vdpasim->vqs[1];
133133
struct vdpasim_virtqueue *rxq = &vdpasim->vqs[0];
134-
size_t read, write, total_write;
135-
int err;
134+
ssize_t read, write;
135+
size_t total_write;
136136
int pkts = 0;
137+
int err;
137138

138139
spin_lock(&vdpasim->lock);
139140

0 commit comments

Comments
 (0)