fpga: zynq: fix zynq_fpga_has_sync()
Subsystems (3)
PATCH 1/1 fpga: zynq: fix zynq_fpga_has_sync()
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the zynq_fpga_has_sync() function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245 zynq_fpga_has_sync() warn: impossible condition '(buf[2] == 153) => ((-128)-127 == 153)' drivers/fpga/zynq-fpga.c:246 zynq_fpga_has_sync() warn: impossible condition '(buf[3] == 170) => ((-128)-127 == 170)'
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]
buf[3] == 0xaa)
~~~~~~ ^ ~~~~
drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of
constant 153 with expression of type 'const char' is always false
[-Wtautological-constant-out-of-range-compare]
if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&
~~~~~~ ^ ~~~~---
The ada14a023a64 ("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.
After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the author.
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fpga/zynq-fpga.c +1 -1
@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count) {for (; count >=4 ; buf +=4 , count -=4 ) if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&
Signature · 1 line
2.35.1
Tom Rix
reviewerQuoted 53 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossible condition '(buf[2] == 153) => ((-128)-127 == 153)'drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossible condition '(buf[3] == 170) => ((-128)-127 == 170)'
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^ ~~~~Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the author.
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c +0
-0
drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)
This is called from zynq_fpga_ops_write_init, a fpga_manager_ops function that
uses 'const char *' as a type for its write() buf's.
I think const u8 * would be a better type for all of the fpga_manager instances.
If folks agree, I'll make the change.
Tom
Quoted 3 lines
drivers/fpga/zynq-fpga.c +0
-0{for (; count >=4 ; buf +=4 , count -=4 ) if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&
Hi Tom,
Please find my response inline.
Quoted 78 lines
-----Original Message-----
From: Tom Rix <[email protected]>
Sent: Monday, May 9, 2022 6:14 PM
To: Dan Carpenter <[email protected]>; Moritz Fischer <[email protected]>; Nava kishore Manne <[email protected]>; Xu Yilun <[email protected]>; Wu Hao <[email protected]>
Cc: Michal Simek <[email protected]>; [email protected]; kernel- [email protected]
Subject: Re: [PATCH] fpga: zynq: fixzynq_fpga_has_sync()Quoted 5 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossiblecondition '(buf[2] == 153) => ((-128)-127 == 153)'
Quoted 1 line
drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossiblecondition '(buf[3] == 170) => ((-128)-127 == 170)'
Quoted 27 lines
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^~~~~
Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Quoted 7 lines
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the
author.
Quoted 14 lines
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c index renamed from drivers/fpga/zynq-fpga.c +0
-0
6beaba9dfe97..426aa34c6a0d100644drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)This is called from
zynq_fpga_ops_write_init, afpga_manager_opsfunction that
Quoted 7 lines
uses 'const char *' as a type for its
write()buf's.I think const u8 * would be a better type for all of the
fpga_managerinstances.If folks agree, I'll make the change.
I agree, please change it to u8
Regards,
Nava kishore.
Xu Yilun
maintainerQuoted 64 lines · Tom Rix
Quoted 53 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossible condition '(buf[2] == 153) => ((-128)-127 == 153)'drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossible condition '(buf[3] == 170) => ((-128)-127 == 170)'
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^ ~~~~Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the author.
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c +0
-0drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)This is called from
zynq_fpga_ops_write_init, afpga_manager_opsfunction that
Quoted 4 lines
uses 'const char *' as a type for its
write()buf's.I think const u8 * would be a better type for all of the
fpga_managerinstances.
I don't think it's necessary to change the write_init(), const char *buf is fine.
For this case, if the cleanup is necessary, just type casting the buf.
zynq_fpga_has_sync((const u8 *)buf, count)
Thanks,
Yilun
Quoted 8 lines
If folks agree, I'll make the change.
Tom
Quoted 3 lines
drivers/fpga/zynq-fpga.c +0
-0{for (; count >=4 ; buf +=4 , count -=4 ) if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&
Xu Yilun
maintainerQuoted 53 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossible condition '(buf[2] == 153) => ((-128)-127 == 153)'drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossible condition '(buf[3] == 170) => ((-128)-127 == 170)'
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^ ~~~~Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the author.
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c +0
-0
drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)
Hi Dan & Moritz:
Thanks for the patch. But it actually reverts Nava's patch. Since Nava's patch is not pushed to linux-next yet, could we just drop it from linux-fpga?
Thanks,
Yilun
Quoted 5 lines
drivers/fpga/zynq-fpga.c +0
-0{for (; count >=4 ; buf +=4 , count -=4 ) if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 &&Signature · 1 line
2.35.1
Hi,
Please find my response inline.
Quoted 83 lines
-----Original Message-----
From: Xu Yilun <[email protected]>
Sent: Monday, May 9, 2022 10:25 PM
To: Tom Rix <[email protected]>
Cc: Dan Carpenter <[email protected]>; Moritz Fischer <[email protected]>; Nava kishore Manne <[email protected]>; Wu Hao <[email protected]>; Michal Simek <[email protected]>; linux- [email protected]; [email protected]
Subject: Re: [PATCH] fpga: zynq: fixzynq_fpga_has_sync()Quoted 5 lines · Tom Rix
Quoted 3 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detectedby Smatch and Clang:
Quoted 2 lines
Quoted 2 lines
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossiblecondition '(buf[2] == 153) => ((-128)-127 == 153)'
Quoted 1 line
Quoted 1 line
drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossiblecondition '(buf[3] == 170) => ((-128)-127 == 170)'
Quoted 27 lines
Quoted 27 lines
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^~~~~
Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Quoted 7 lines
Quoted 7 lines
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot
to the author.
Quoted 6 lines
Quoted 6 lines
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
Quoted 8 lines
drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void
Quoted 8 lines
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c +0
-0@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void*data)
Quoted 11 lines
drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)This is called from
zynq_fpga_ops_write_init, afpga_manager_opsfunction thatuses 'const char *' as a type for its
write()buf's.
Quoted 9 lines
Quoted 2 lines
I think const u8 * would be a better type for all of the
fpga_managerinstances.I don't think it's necessary to change the
write_init(), const char *buf is fine.For this case, if the cleanup is necessary, just type casting the buf.
zynq_fpga_has_sync((const u8 *)buf, count)
zynq_fpga_ops_write_init() and fpga_manager_ops ideally handle the binary files so I feel 'const u8 *' would be a better option here.
In the Initial version of my patches I have done only type cast. But base on the comments I have changed zynq_fpga_has_sync() API args type. For more details please refer the below links
https://patchwork.kernel.org/project/linux-fpga/patch/[email protected]/
https://patchwork.kernel.org/project/linux-fpga/patch/[email protected]/
Regards,
Navakishore.
Tom Rix
reviewerQuoted 79 lines · Nava kishore Manne
Hi Tom,
Please find my response inline.
Quoted 75 lines
-----Original Message-----
From: Tom Rix <[email protected]>
Sent: Monday, May 9, 2022 6:14 PM
To: Dan Carpenter <[email protected]>; Moritz Fischer <[email protected]>; Nava kishore Manne <[email protected]>; Xu Yilun <[email protected]>; Wu Hao <[email protected]>
Cc: Michal Simek <[email protected]>; [email protected]; kernel- [email protected]
Subject: Re: [PATCH] fpga: zynq: fixzynq_fpga_has_sync()Quoted 5 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossiblecondition '(buf[2] == 153) => ((-128)-127 == 153)'
Quoted 1 line
drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossiblecondition '(buf[3] == 170) => ((-128)-127 == 170)'
Quoted 26 lines
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^~~~~
Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Quoted 7 lines
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the
author.
Quoted 13 lines
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c index renamed from drivers/fpga/zynq-fpga.c +0
-0
6beaba9dfe97..426aa34c6a0d100644drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)This is called from
zynq_fpga_ops_write_init, afpga_manager_opsfunction that
Quoted 8 lines
Quoted 7 lines
uses 'const char *' as a type for its
write()buf's.I think const u8 * would be a better type for all of the
fpga_managerinstances.If folks agree, I'll make the change.
I agree, please change it to u8
I was hoping one of the fpga/ maintainers would chime in.
Though it seems obvious that the type-specifier should be unsigned, this is a general interface change to the subsystem.
I would rather have buy in before spending a couple of days doing the change and having it rejected.
Tom
Quoted 3 lines
Regards,
Nava kishore.
Xu Yilun
maintainerQuoted 83 lines · Tom Rix
Quoted 81 lines · Nava kishore Manne
Hi Tom,
Please find my response inline.
Quoted 77 lines
-----Original Message-----
From: Tom Rix <[email protected]>
Sent: Monday, May 9, 2022 6:14 PM
To: Dan Carpenter <[email protected]>; Moritz Fischer <[email protected]>; Nava kishore Manne <[email protected]>; Xu Yilun <[email protected]>; Wu Hao <[email protected]>
Cc: Michal Simek <[email protected]>; [email protected]; kernel- [email protected]
Subject: Re: [PATCH] fpga: zynq: fixzynq_fpga_has_sync()Quoted 5 lines · Dan Carpenter
The type needs to be u8. The type was accidentally changed to char as a cleanup. Unfortunately, that meant that the
zynq_fpga_has_sync()function never returns true. This bug was detected by Smatch and Clang:
drivers/fpga/zynq-fpga.c:245zynq_fpga_has_sync()warn: impossiblecondition '(buf[2] == 153) => ((-128)-127 == 153)'
Quoted 1 line
drivers/fpga/zynq-fpga.c:246zynq_fpga_has_sync()warn: impossiblecondition '(buf[3] == 170) => ((-128)-127 == 170)'
Quoted 26 lines
drivers/fpga/zynq-fpga.c:246:14: warning: result of comparison of constant 170 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare]buf[3] == 0xaa) ~~~~~~ ^ ~~~~ drivers/fpga/zynq-fpga.c:245:50: warning: result of comparison of constant 153 with expression of type 'const char' is always false [-Wtautological-constant-out-of-range-compare] if (buf[0] == 0x66 && buf[1] == 0x55 && buf[2] == 0x99 && ~~~~~~ ^~~~~
Fixes ada14a023a64 ("fpga: zynq: Fix incorrect variable type")Reported-by kernel test robot <[email protected]>Signed-off-by Dan Carpenter <[email protected]>---
Theada14a023a64("fpga: zynq: Fix incorrect variable type") patch went through six of revisions. The kbuild bug found this bug early on but the author ingored kbuild-bot and kept resending the buggy patch anyway.After the patch was merged then I sent a separate bug report and Xu Yilun asked about why only the author was on the CC list for the first bug reports. A valid question, definitely. I will poke the kbuild devs about this.
Quoted 7 lines
Hm... Actually looking through the list there have been a bunch of bug reports about this because both Smatch and Clang complain so kbuild sends duplicate warnings for this type of bug. And then kbuild sends another to say "This issue is still remaining" warning. And then Xu Yilun sent an email "Kbuild-bot is still complaining. Please don't forget to fix this." So that's at least four public emails about this and one or two private emails directly from kbuild-bot to the
author.
Quoted 13 lines
The kbuild-bot wanted to send *another* warning today, but I decided to send a fix instead.
LOL.
drivers/fpga/zynq-fpga.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fpga/zynq-fpga.c index renamed from drivers/fpga/zynq-fpga.c +0
-0
6beaba9dfe97..426aa34c6a0d100644drivers/fpga/zynq-fpga.c static irqreturn_t zynq_fpga_isr(int irq, void *data) · line 242
Quoted 5 lines
drivers/fpga/zynq-fpga.c +1
-1@@ -239,7 +239,7 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data)* the correct byte order, and be dword aligned. The input is a Xilinx .bin * file with every 32 bit quantity swapped. */ -static bool zynq_fpga_has_sync (const char *buf,size_t count) +static bool zynq_fpga_has_sync (const u8 *buf,size_t count)This is called from
zynq_fpga_ops_write_init, afpga_manager_opsfunction thatuses 'const char *' as a type for its
write()buf's.
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
I think const u8 * would be a better type for all of the
fpga_managerinstances.If folks agree, I'll make the change.
I agree, please change it to u8
I was hoping one of the fpga/ maintainers would chime in.
As I said before, I think const char *buf for write_init() is OK.
Quoted 3 lines
Though it seems obvious that the type-specifier should be unsigned, this is a general interface change to the subsystem.
Searching over all kernel code, we can find many const char *buf/buf[], and also many const u8 *buf/buf[], const unsigned char *buf/buf[]. I think they are all good. They are just a block of data and people don't care about their format. So signed or unsigned is not important.
If a specific driver have its own understanding of the data block and want to parse it, just type casting it as needed to u8/s8/u16/s16 ...
So const char/u8/unsigned char * are all good to me, but for now I don't see the necessity changing to one another for all fpga drivers.
Thanks,
Yilun
Quoted 9 lines
I would rather have buy in before spending a couple of days doing the change and having it rejected.
Tom
Quoted 3 lines
Regards,
Nava kishore.
Quoted 6 lines · Xu Yilun
Hi Dan & Moritz:
Thanks for the patch. But it actually reverts Nava's patch. Since Nava's patch is not pushed to linux-next yet, could we just drop it from linux-fpga?
I don't know if you meant linux-next. It's pushed to linux-next. But linux-next is rebased every day so reverting is fine as far as linux-next goes.
regards,
dan carpenter
Xu Yilun
maintainerQuoted 11 lines · Dan Carpenter
Quoted 6 lines · Xu Yilun
Hi Dan & Moritz:
Thanks for the patch. But it actually reverts Nava's patch. Since Nava's patch is not pushed to linux-next yet, could we just drop it from linux-fpga?
I don't know if you meant linux-next. It's pushed to linux-next. But linux-next is rebased every day so reverting is fine as far as linux-next goes.
Thanks for the info. I was not aware of that and may mess up something. I force pushed the linux-fpga yesterday for this patchset, then linux-next would be conflict with linux-fpga, is it?
If it is the case, how could I remedy?
Thanks,
Yilun
Quoted 3 lines
regards,
dan carpenter
Quoted 13 lines · Xu Yilun
Quoted 11 lines · Dan Carpenter
Quoted 6 lines · Xu Yilun
Hi Dan & Moritz:
Thanks for the patch. But it actually reverts Nava's patch. Since Nava's patch is not pushed to linux-next yet, could we just drop it from linux-fpga?
I don't know if you meant linux-next. It's pushed to linux-next. But linux-next is rebased every day so reverting is fine as far as linux-next goes.
Quoted 5 lines
Thanks for the info. I was not aware of that and may mess up something. I force pushed the linux-fpga yesterday for this patchset, then linux-next would be conflict with linux-fpga, is it?
If it is the case, how could I remedy?
No. Don't worry about linux-next. Stephen rebuilds it from scratch every day. It's fine if you rebase. There are quite a few trees which rebase.
regards,
dan carpenter
Xu Yilun
maintainerQuoted 18 lines · Dan Carpenter
Quoted 17 lines · Xu Yilun
Quoted 11 lines · Dan Carpenter
Quoted 6 lines · Xu Yilun
Hi Dan & Moritz:
Thanks for the patch. But it actually reverts Nava's patch. Since Nava's patch is not pushed to linux-next yet, could we just drop it from linux-fpga?
I don't know if you meant linux-next. It's pushed to linux-next. But linux-next is rebased every day so reverting is fine as far as linux-next goes.
Thanks for the info. I was not aware of that and may mess up something. I force pushed the linux-fpga yesterday for this patchset, then linux-next would be conflict with linux-fpga, is it?
Quoted 5 lines
Quoted 1 line
If it is the case, how could I remedy?
No. Don't worry about linux-next. Stephen rebuilds it from scratch every day. It's fine if you rebase. There are quite a few trees which rebase.
That's good new! Thanks again.
Quoted 3 lines
regards,
dan carpenter