On 2021/1/15 ??6:00, Jiapeng Zhong wrote:> Fix the following coccicheck warnings: > > ./drivers/virtio/virtio_ring.c:1637:1-29: WARNING: Assignment of > 0/1 to bool variable. > > ./drivers/virtio/virtio_ring.c:1636:1-30: WARNING: Assignment of > 0/1 to bool variable. > > Reported-by: Abaci Robot <abaci at linux.alibaba.com> > Signed-off-by: Jiapeng Zhong <abaci-bugfix at linux.alibaba.com>It looks to me it's not the only places: git grep avail_wrap_counter drivers/virtio/virtio_ring.c:?????????????????? bool avail_wrap_counter; drivers/virtio/virtio_ring.c: vq->packed.avail_wrap_counter ^= 1; drivers/virtio/virtio_ring.c: vq->packed.avail_wrap_counter ^= 1; drivers/virtio/virtio_ring.c:?? if (wrap_counter != vq->packed.avail_wrap_counter) drivers/virtio/virtio_ring.c:?? vq->packed.avail_wrap_counter = 1; Thanks> --- > drivers/virtio/virtio_ring.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > index 71e16b5..5adb361 100644 > --- a/drivers/virtio/virtio_ring.c > +++ b/drivers/virtio/virtio_ring.c > @@ -1633,8 +1633,8 @@ static struct virtqueue *vring_create_virtqueue_packed( > vq->packed.vring.device = device; > > vq->packed.next_avail_idx = 0; > - vq->packed.avail_wrap_counter = 1; > - vq->packed.used_wrap_counter = 1; > + vq->packed.avail_wrap_counter = true; > + vq->packed.used_wrap_counter = true; > vq->packed.event_flags_shadow = 0; > vq->packed.avail_used_flags = 1 << VRING_PACKED_DESC_F_AVAIL; >
Michael S. Tsirkin
2021-May-03 08:17 UTC
[PATCH] virtio_ring: boolean values to a bool variable
On Mon, Jan 18, 2021 at 10:57:03AM +0800, Jason Wang wrote:> > On 2021/1/15 ??6:00, Jiapeng Zhong wrote: > > Fix the following coccicheck warnings: > > > > ./drivers/virtio/virtio_ring.c:1637:1-29: WARNING: Assignment of > > 0/1 to bool variable. > > > > ./drivers/virtio/virtio_ring.c:1636:1-30: WARNING: Assignment of > > 0/1 to bool variable. > > > > Reported-by: Abaci Robot <abaci at linux.alibaba.com> > > Signed-off-by: Jiapeng Zhong <abaci-bugfix at linux.alibaba.com> > > > It looks to me it's not the only places: > > git grep avail_wrap_counter > drivers/virtio/virtio_ring.c:?????????????????? bool avail_wrap_counter; > drivers/virtio/virtio_ring.c: vq->packed.avail_wrap_counter ^= 1; > drivers/virtio/virtio_ring.c: vq->packed.avail_wrap_counter ^= 1; > drivers/virtio/virtio_ring.c:?? if (wrap_counter !> vq->packed.avail_wrap_counter) > drivers/virtio/virtio_ring.c:?? vq->packed.avail_wrap_counter = 1; > > ThanksAgreed if we are doing this let's change them all.> > > --- > > drivers/virtio/virtio_ring.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > index 71e16b5..5adb361 100644 > > --- a/drivers/virtio/virtio_ring.c > > +++ b/drivers/virtio/virtio_ring.c > > @@ -1633,8 +1633,8 @@ static struct virtqueue *vring_create_virtqueue_packed( > > vq->packed.vring.device = device; > > vq->packed.next_avail_idx = 0; > > - vq->packed.avail_wrap_counter = 1; > > - vq->packed.used_wrap_counter = 1; > > + vq->packed.avail_wrap_counter = true; > > + vq->packed.used_wrap_counter = true; > > vq->packed.event_flags_shadow = 0; > > vq->packed.avail_used_flags = 1 << VRING_PACKED_DESC_F_AVAIL;