[PATCH] staging: fbtft: replace number with sizeof()

Manuel Ebner posted 1 patch 1 week, 4 days ago
drivers/staging/fbtft/fb_ili9320.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] staging: fbtft: replace number with sizeof()
Posted by Manuel Ebner 1 week, 4 days ago
Replace integer number with sizeof with the goal of prevent future truncation bugs.

Signed-off-by: Manuel Ebner <manuelebnerli@mailbox.org>
---
 drivers/staging/fbtft/fb_ili9320.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/fbtft/fb_ili9320.c b/drivers/staging/fbtft/fb_ili9320.c
index 0f98267a7..655778392 100644
--- a/drivers/staging/fbtft/fb_ili9320.c
+++ b/drivers/staging/fbtft/fb_ili9320.c
@@ -21,7 +21,7 @@
 
 static unsigned int read_devicecode(struct fbtft_par *par)
 {
-	u8 rxbuf[8] = {0, };
+	u8 rxbuf[sizeof(u64)] = {0, };
 
 	write_reg(par, 0x0000);
 	par->fbtftops.read(par, rxbuf, 4);
-- 
2.55.0
Re: [PATCH] staging: fbtft: replace number with sizeof()
Posted by Andy Shevchenko 1 week, 3 days ago
On Mon, Sep 14, 2026 at 12:09 PM Manuel Ebner <manuelebnerli@mailbox.org> wrote:
>
> Replace integer number with sizeof with the goal of prevent future truncation bugs.

preventing

>
> Signed-off-by: Manuel Ebner <manuelebnerli@mailbox.org>

So far I see only a single patch, what are the "future truncation
bugs" you are talking about?

...

>  static unsigned int read_devicecode(struct fbtft_par *par)
>  {
> -       u8 rxbuf[8] = {0, };
> +       u8 rxbuf[sizeof(u64)] = {0, };

This is an unclear change. Where did u64 come from? Why do we even
need a 8-byte buffer when we only do 4-byte operations?

>         write_reg(par, 0x0000);
>         par->fbtftops.read(par, rxbuf, 4);

Perhaps you need to read a datasheet for this panel and come up with a
better understanding?

-- 
With Best Regards,
Andy Shevchenko