Linux Media Controller development
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Jisheng Zhang <jszhang@kernel.org>,
	Sumit Semwal <sumit.semwal@linaro.org>,
	Benjamin Gaignard <benjamin.gaignard@collabora.com>,
	Brian Starkey <Brian.Starkey@arm.com>,
	John Stultz <jstultz@google.com>,
	"T . J . Mercier" <tjmercier@google.com>
Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] dma-buf: system_heap: Use LIST_HEAD() to initialize on stack list head
Date: Tue, 19 May 2026 08:51:00 +0200	[thread overview]
Message-ID: <b4acc363-b307-4ce1-beef-fece0d66e696@amd.com> (raw)
In-Reply-To: <20260519060532.13221-1-jszhang@kernel.org>

On 5/19/26 08:05, Jisheng Zhang wrote:
> Use LIST_HEAD to initialize on stack list head. No intentional
> functional impact.
> 
> Change generated with below coccinelle script:
> 
> @@
> identifier name;
> @@
> - struct list_head name;
> + LIST_HEAD(name);
> ... when != name
> - INIT_LIST_HEAD(&name);

The patch itself looks correct, but my question is why would we want to do that?

Initializing the list head (or any other result variable) directly before it is filled in is usually good practice.

Regards,
Christian.

> 
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
>  drivers/dma-buf/heaps/system_heap.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/dma-buf/heaps/system_heap.c b/drivers/dma-buf/heaps/system_heap.c
> index 03c2b87cb111..6f8b7138ff56 100644
> --- a/drivers/dma-buf/heaps/system_heap.c
> +++ b/drivers/dma-buf/heaps/system_heap.c
> @@ -409,7 +409,7 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
>         struct dma_buf *dmabuf;
>         struct sg_table *table;
>         struct scatterlist *sg;
> -       struct list_head pages;
> +       LIST_HEAD(pages);
>         struct page *page, *tmp_page;
>         int i, ret = -ENOMEM;
> 
> @@ -423,7 +423,6 @@ static struct dma_buf *system_heap_allocate(struct dma_heap *heap,
>         buffer->len = len;
>         buffer->cc_shared = cc_shared;
> 
> -       INIT_LIST_HEAD(&pages);
>         i = 0;
>         while (size_remaining > 0) {
>                 /*
> --
> 2.53.0
> 


  reply	other threads:[~2026-05-19  6:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-19  6:05 [PATCH] dma-buf: system_heap: Use LIST_HEAD() to initialize on stack list head Jisheng Zhang
2026-05-19  6:51 ` Christian König [this message]
2026-05-19 23:19   ` Jisheng Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b4acc363-b307-4ce1-beef-fece0d66e696@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Brian.Starkey@arm.com \
    --cc=benjamin.gaignard@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jstultz@google.com \
    --cc=jszhang@kernel.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=tjmercier@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox