linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] virtio_net/vringh: add "else { }" according coding style
@ 2021-06-24  1:17 Cai Huoqing
  2021-06-24  4:02 ` Jason Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Cai Huoqing @ 2021-06-24  1:17 UTC (permalink / raw)
  To: mst, jasowang, davem, kuba
  Cc: virtualization, netdev, linux-kernel, kvm, Cai Huoqing

coding-style.rst shows that:
        if (condition) {
                do_this();
                do_that();
        } else {
                otherwise();
        }

Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
---
 drivers/net/virtio_net.c | 3 ++-
 drivers/vhost/vringh.c   | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 21ff7b9e49c2..7cd062cb468e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -314,8 +314,9 @@ static struct page *get_a_page(struct receive_queue *rq, gfp_t gfp_mask)
                rq->pages = (struct page *)p->private;
                /* clear private here, it is used to chain pages */
                p->private = 0;
-       } else
+       } else {
                p = alloc_page(gfp_mask);
+       }
        return p;
 }

diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
index 4af8fa259d65..79542cad1072 100644
--- a/drivers/vhost/vringh.c
+++ b/drivers/vhost/vringh.c
@@ -454,8 +454,9 @@ static inline int __vringh_complete(struct vringh *vrh,
                if (!err)
                        err = putused(vrh, &used_ring->ring[0], used + part,
                                      num_used - part);
-       } else
+       } else {
                err = putused(vrh, &used_ring->ring[off], used, num_used);
+       }

        if (err) {
                vringh_bad("Failed to write %u used entries %u at %p",
--
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] virtio_net/vringh: add "else { }" according coding style
  2021-06-24  1:17 [PATCH v2] virtio_net/vringh: add "else { }" according coding style Cai Huoqing
@ 2021-06-24  4:02 ` Jason Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Wang @ 2021-06-24  4:02 UTC (permalink / raw)
  To: Cai Huoqing, mst, davem, kuba; +Cc: virtualization, netdev, linux-kernel, kvm


在 2021/6/24 上午9:17, Cai Huoqing 写道:
> coding-style.rst shows that:
>          if (condition) {
>                  do_this();
>                  do_that();
>          } else {
>                  otherwise();
>          }


So git grep told me there're at least 28 similar "issues" in 
drivers/virito. And there will be a lot in the other part of the kernel

I think it's not worth to bother. We can start to work on something that 
is really interesting.

E.g we had the plan to convert to use iov iterator instead of using a 
vringh specific iov "iterator" implementation. Do you want to do that?

Thanks


>
> Signed-off-by: Cai Huoqing <caihuoqing@baidu.com>
> ---
>   drivers/net/virtio_net.c | 3 ++-
>   drivers/vhost/vringh.c   | 3 ++-
>   2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 21ff7b9e49c2..7cd062cb468e 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -314,8 +314,9 @@ static struct page *get_a_page(struct receive_queue *rq, gfp_t gfp_mask)
>                  rq->pages = (struct page *)p->private;
>                  /* clear private here, it is used to chain pages */
>                  p->private = 0;
> -       } else
> +       } else {
>                  p = alloc_page(gfp_mask);
> +       }
>          return p;
>   }
>
> diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
> index 4af8fa259d65..79542cad1072 100644
> --- a/drivers/vhost/vringh.c
> +++ b/drivers/vhost/vringh.c
> @@ -454,8 +454,9 @@ static inline int __vringh_complete(struct vringh *vrh,
>                  if (!err)
>                          err = putused(vrh, &used_ring->ring[0], used + part,
>                                        num_used - part);
> -       } else
> +       } else {
>                  err = putused(vrh, &used_ring->ring[off], used, num_used);
> +       }
>
>          if (err) {
>                  vringh_bad("Failed to write %u used entries %u at %p",
> --
> 2.17.1
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-06-24  4:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-24  1:17 [PATCH v2] virtio_net/vringh: add "else { }" according coding style Cai Huoqing
2021-06-24  4:02 ` Jason Wang

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).