public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Marwin Hormiz" <marwinhormiz@gmail.com>,
	"Dave Penkler" <dpenkler@gmail.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Cc: "Dan Carpenter" <dan.carpenter@linaro.org>,
	matchstick@neverthere.org,
	"Nihar Chaithanya" <niharchaithanya@gmail.com>,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/1] staging: gpib: gpio: Fix memory allocation style in gpib_bitbang.c
Date: Tue, 22 Apr 2025 08:19:55 +0200	[thread overview]
Message-ID: <eb79a1fc-080d-4be7-9d72-5fa248f48fee@app.fastmail.com> (raw)
In-Reply-To: <20250421184144.220972-1-marwinhormiz@gmail.com>

On Mon, Apr 21, 2025, at 20:41, Marwin Hormiz wrote:
> Change kzalloc() to use sizeof(*variable) instead of sizeof(struct type)
> to improve code maintainability. This follows the kernel coding style
> recommendation for memory allocations.
>
> Signed-off-by: Marwin Hormiz <marwinhormiz@gmail.com>

The build bot reply already shows that you did not even build test
the patch. :(

> @@ -46,10 +46,10 @@
>  			dev_dbg(board->gpib_dev, frm, ## __VA_ARGS__); } \
>  	while (0)
> 
> -#define LINVAL gpiod_get_value(DAV),		\
> +#define LINVAL (gpiod_get_value(DAV),		\
>  		gpiod_get_value(NRFD),		\
>  		gpiod_get_value(NDAC),		\
> -		gpiod_get_value(SRQ)
> +		gpiod_get_value(SRQ))
>  #define LINFMT "DAV: %d	 NRFD:%d  NDAC: %d SRQ: %d"

This change is completely unrelated to the rest of the patch
and not described, aside from being broken. The macro is clearly
confusing, so if you want to imprve this, I would suggest removing
it and instead open-coding the contents.

> @@ -1063,7 +1063,7 @@ static int bb_line_status(const struct gpib_board *board)
> 
>  static int allocate_private(struct gpib_board *board)
>  {
> -	board->private_data = kzalloc(sizeof(struct bb_priv), GFP_KERNEL);
> +	board->private_data = kzalloc(sizeof(*board->private_data), GFP_KERNEL);
>  	if (!board->private_data)
>  		return -1;
>  	return 0;

When you do this type of change, you have to check that the
types are actually the same. The original code makes sense,
your change is broken because 'private_data' as usual refers to
a opaque pointer.

     Arnd

  parent reply	other threads:[~2025-04-22  6:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21 18:41 [PATCH 1/1] staging: gpib: gpio: Fix memory allocation style in gpib_bitbang.c Marwin Hormiz
2025-04-22  2:09 ` kernel test robot
2025-04-22  6:19 ` Arnd Bergmann [this message]
2025-04-22  6:33 ` kernel test robot

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=eb79a1fc-080d-4be7-9d72-5fa248f48fee@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=dan.carpenter@linaro.org \
    --cc=dpenkler@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=marwinhormiz@gmail.com \
    --cc=matchstick@neverthere.org \
    --cc=niharchaithanya@gmail.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