public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type)
@ 2024-06-02  8:49 Erick Archer
  2024-06-03  7:52 ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Erick Archer @ 2024-06-02  8:49 UTC (permalink / raw)
  To: Andy Shevchenko, Geert Uytterhoeven, Uwe Kleine-König,
	Kees Cook, Gustavo A. R. Silva, Justin Stitt
  Cc: Erick Archer, linux-kernel, linux-hardening

It is preferred to use sizeof(*pointer) instead of sizeof(type)
due to the type of the variable can change and one needs not
change the former (unlike the latter). This patch has no effect
on runtime behavior.

Signed-off-by: Erick Archer <erick.archer@outlook.com>
---
 drivers/auxdisplay/arm-charlcd.c | 2 +-
 drivers/auxdisplay/hd44780.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/arm-charlcd.c b/drivers/auxdisplay/arm-charlcd.c
index 0b1c99cca733..a7eae99a48f7 100644
--- a/drivers/auxdisplay/arm-charlcd.c
+++ b/drivers/auxdisplay/arm-charlcd.c
@@ -270,7 +270,7 @@ static int __init charlcd_probe(struct platform_device *pdev)
 	struct charlcd *lcd;
 	struct resource *res;
 
-	lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL);
+	lcd = kzalloc(sizeof(*lcd), GFP_KERNEL);
 	if (!lcd)
 		return -ENOMEM;
 
diff --git a/drivers/auxdisplay/hd44780.c b/drivers/auxdisplay/hd44780.c
index 7ac0b1b1d548..025dc6855cb2 100644
--- a/drivers/auxdisplay/hd44780.c
+++ b/drivers/auxdisplay/hd44780.c
@@ -230,7 +230,7 @@ static int hd44780_probe(struct platform_device *pdev)
 	if (!lcd)
 		goto fail1;
 
-	hd = kzalloc(sizeof(struct hd44780), GFP_KERNEL);
+	hd = kzalloc(sizeof(*hd), GFP_KERNEL);
 	if (!hd)
 		goto fail2;
 
-- 
2.25.1


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

* Re: [PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type)
  2024-06-02  8:49 [PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type) Erick Archer
@ 2024-06-03  7:52 ` Geert Uytterhoeven
  2024-06-03 19:50   ` Andy Shevchenko
  0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2024-06-03  7:52 UTC (permalink / raw)
  To: Erick Archer
  Cc: Andy Shevchenko, Kees Cook, Gustavo A. R. Silva, Justin Stitt,
	linux-kernel, linux-hardening, Uwe Kleine-König

On Sun, Jun 2, 2024 at 10:49 AM Erick Archer <erick.archer@outlook.com> wrote:
> It is preferred to use sizeof(*pointer) instead of sizeof(type)
> due to the type of the variable can change and one needs not
> change the former (unlike the latter). This patch has no effect
> on runtime behavior.
>
> Signed-off-by: Erick Archer <erick.archer@outlook.com>

Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type)
  2024-06-03  7:52 ` Geert Uytterhoeven
@ 2024-06-03 19:50   ` Andy Shevchenko
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2024-06-03 19:50 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Erick Archer, Kees Cook, Gustavo A. R. Silva, Justin Stitt,
	linux-kernel, linux-hardening, Uwe Kleine-König

On Mon, Jun 03, 2024 at 09:52:57AM +0200, Geert Uytterhoeven wrote:
> On Sun, Jun 2, 2024 at 10:49 AM Erick Archer <erick.archer@outlook.com> wrote:
> > It is preferred to use sizeof(*pointer) instead of sizeof(type)
> > due to the type of the variable can change and one needs not
> > change the former (unlike the latter). This patch has no effect
> > on runtime behavior.
> >
> > Signed-off-by: Erick Archer <erick.archer@outlook.com>
> 
> Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>

Pushed to my review and testing queue, thanks!

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2024-06-03 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-02  8:49 [PATCH] auxdisplay: Use sizeof(*pointer) instead of sizeof(type) Erick Archer
2024-06-03  7:52 ` Geert Uytterhoeven
2024-06-03 19:50   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox