mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle
@ 2020-10-01  7:43 Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 2/5] scripts: kwboot: allow piping full buffer size at once Ahmad Fatoum
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-10-01  7:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

driver_d::of_compatible outght to point at a NULL-terminated array.
Fix instances where this is not the case.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/firmware/socfpga.c       | 1 +
 drivers/firmware/zynqmp-fpga.c   | 1 +
 drivers/serial/serial_clps711x.c | 1 +
 3 files changed, 3 insertions(+)

diff --git a/drivers/firmware/socfpga.c b/drivers/firmware/socfpga.c
index 6d11da32a5f7..234fb2d0945f 100644
--- a/drivers/firmware/socfpga.c
+++ b/drivers/firmware/socfpga.c
@@ -471,6 +471,7 @@ static struct of_device_id fpgamgr_id_table[] = {
 	{
 		.compatible = "altr,socfpga-fpga-mgr",
 	},
+	{ /* sentinel */ }
 };
 
 static struct driver_d fpgamgr_driver = {
diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
index e02667355f82..ab70d99933b6 100644
--- a/drivers/firmware/zynqmp-fpga.c
+++ b/drivers/firmware/zynqmp-fpga.c
@@ -403,6 +403,7 @@ static struct of_device_id zynqmpp_fpga_id_table[] = {
 	{
 		.compatible = "xlnx,zynqmp-pcap-fpga",
 	},
+	{ /* sentinel */ }
 };
 
 static struct driver_d zynqmp_fpga_driver = {
diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
index 7a7d595dff93..294c88b92fdd 100644
--- a/drivers/serial/serial_clps711x.c
+++ b/drivers/serial/serial_clps711x.c
@@ -184,6 +184,7 @@ out_err:
 
 static struct of_device_id __maybe_unused clps711x_uart_dt_ids[] = {
 	{ .compatible = "cirrus,ep7209-uart", },
+	{ /* sentinel */ }
 };
 
 static struct driver_d clps711x_driver = {
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/5] scripts: kwboot: allow piping full buffer size at once
  2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
@ 2020-10-01  7:43 ` Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 3/5] ARM: layerscape: ppa: fix wrong return values on some errors Ahmad Fatoum
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-10-01  7:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

While buf == _buf, their type and sizeof differ. The read syscall should
have the buffer size as argument, but instead got the pointer's size.

This likely doesn't change high-level behavior, because read was called
in a loop, so fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/kwboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/kwboot.c b/scripts/kwboot.c
index 43b8b8cbcdc6..60e8a69d187d 100644
--- a/scripts/kwboot.c
+++ b/scripts/kwboot.c
@@ -504,7 +504,7 @@ kwboot_term_pipe(int in, int out, char *quit, int *s)
 	ssize_t nin, nout;
 	char _buf[128], *buf = _buf;
 
-	nin = read(in, buf, sizeof(buf));
+	nin = read(in, _buf, sizeof(_buf));
 	if (nin < 0)
 		return -1;
 
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/5] ARM: layerscape: ppa: fix wrong return values on some errors
  2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 2/5] scripts: kwboot: allow piping full buffer size at once Ahmad Fatoum
@ 2020-10-01  7:43 ` Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 4/5] net: macb: " Ahmad Fatoum
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-10-01  7:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Coccinelle detected that the IS_ERR and ERR_PTR are mismatched.
Fix it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/mach-layerscape/ppa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-layerscape/ppa.c b/arch/arm/mach-layerscape/ppa.c
index f38220dbc1e7..53e73f6a581f 100644
--- a/arch/arm/mach-layerscape/ppa.c
+++ b/arch/arm/mach-layerscape/ppa.c
@@ -76,7 +76,7 @@ static int ppa_init(void *ppa, size_t ppa_size, void *sec_firmware_addr)
 	conf = fit_open_configuration(fit, NULL);
 	if (IS_ERR(conf)) {
 		pr_err("Cannot open default config in ppa FIT image: %pe\n", conf);
-		ret = PTR_ERR(fit);
+		ret = PTR_ERR(conf);
 		goto err;
 	}
 
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/5] net: macb: fix wrong return values on some errors
  2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 2/5] scripts: kwboot: allow piping full buffer size at once Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 3/5] ARM: layerscape: ppa: fix wrong return values on some errors Ahmad Fatoum
@ 2020-10-01  7:43 ` Ahmad Fatoum
  2020-10-01  7:43 ` [PATCH 5/5] scripts: kwbimage: " Ahmad Fatoum
  2020-10-02  4:31 ` [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-10-01  7:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Coccinelle detected that the IS_ERR and ERR_PTR are mismatched.
Fix it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/macb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index 4850e60c49ab..e3e039f67988 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -731,7 +731,7 @@ static int macb_probe(struct device_d *dev)
 
 	if (hclk_name) {
 		macb->hclk = clk_get(dev, pclk_name);
-		if (IS_ERR(macb->pclk)) {
+		if (IS_ERR(macb->hclk)) {
 			dev_err(dev, "no hclk\n");
 			return PTR_ERR(macb->hclk);
 		}
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/5] scripts: kwbimage: fix wrong return values on some errors
  2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2020-10-01  7:43 ` [PATCH 4/5] net: macb: " Ahmad Fatoum
@ 2020-10-01  7:43 ` Ahmad Fatoum
  2020-10-02  4:31 ` [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-10-01  7:43 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Coccinelle detected that bootfrom and nandeccmode are unsigned, but
check to be less than zero. Both are only used to hold the return value
of functions that either return up to 0xFF on success and a negative
error code otherwise. It's thus safe to make them signed. Do so.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/kwbimage.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/kwbimage.c b/scripts/kwbimage.c
index 26eb07fa81bc..75c9e9cda9c2 100644
--- a/scripts/kwbimage.c
+++ b/scripts/kwbimage.c
@@ -186,7 +186,7 @@ struct image_cfg_element {
 	} type;
 	union {
 		unsigned int version;
-		unsigned int bootfrom;
+		int bootfrom;
 		struct {
 			char *file;
 			unsigned int args[BINARY_MAX_ARGS];
@@ -197,7 +197,7 @@ struct image_cfg_element {
 		unsigned int execaddr;
 		unsigned int nandblksz;
 		unsigned int nandbadblklocation;
-		unsigned int nandeccmode;
+		int nandeccmode;
 		unsigned int nandpagesz;
 		struct ext_hdr_v0_reg regdata;
 	};
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle
  2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2020-10-01  7:43 ` [PATCH 5/5] scripts: kwbimage: " Ahmad Fatoum
@ 2020-10-02  4:31 ` Sascha Hauer
  4 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2020-10-02  4:31 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Thu, Oct 01, 2020 at 09:43:33AM +0200, Ahmad Fatoum wrote:
> driver_d::of_compatible outght to point at a NULL-terminated array.
> Fix instances where this is not the case.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  drivers/firmware/socfpga.c       | 1 +
>  drivers/firmware/zynqmp-fpga.c   | 1 +
>  drivers/serial/serial_clps711x.c | 1 +
>  3 files changed, 3 insertions(+)

Applied, thanks

Sascha

> 
> diff --git a/drivers/firmware/socfpga.c b/drivers/firmware/socfpga.c
> index 6d11da32a5f7..234fb2d0945f 100644
> --- a/drivers/firmware/socfpga.c
> +++ b/drivers/firmware/socfpga.c
> @@ -471,6 +471,7 @@ static struct of_device_id fpgamgr_id_table[] = {
>  	{
>  		.compatible = "altr,socfpga-fpga-mgr",
>  	},
> +	{ /* sentinel */ }
>  };
>  
>  static struct driver_d fpgamgr_driver = {
> diff --git a/drivers/firmware/zynqmp-fpga.c b/drivers/firmware/zynqmp-fpga.c
> index e02667355f82..ab70d99933b6 100644
> --- a/drivers/firmware/zynqmp-fpga.c
> +++ b/drivers/firmware/zynqmp-fpga.c
> @@ -403,6 +403,7 @@ static struct of_device_id zynqmpp_fpga_id_table[] = {
>  	{
>  		.compatible = "xlnx,zynqmp-pcap-fpga",
>  	},
> +	{ /* sentinel */ }
>  };
>  
>  static struct driver_d zynqmp_fpga_driver = {
> diff --git a/drivers/serial/serial_clps711x.c b/drivers/serial/serial_clps711x.c
> index 7a7d595dff93..294c88b92fdd 100644
> --- a/drivers/serial/serial_clps711x.c
> +++ b/drivers/serial/serial_clps711x.c
> @@ -184,6 +184,7 @@ out_err:
>  
>  static struct of_device_id __maybe_unused clps711x_uart_dt_ids[] = {
>  	{ .compatible = "cirrus,ep7209-uart", },
> +	{ /* sentinel */ }
>  };
>  
>  static struct driver_d clps711x_driver = {
> -- 
> 2.28.0
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2020-10-02  4:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-01  7:43 [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Ahmad Fatoum
2020-10-01  7:43 ` [PATCH 2/5] scripts: kwboot: allow piping full buffer size at once Ahmad Fatoum
2020-10-01  7:43 ` [PATCH 3/5] ARM: layerscape: ppa: fix wrong return values on some errors Ahmad Fatoum
2020-10-01  7:43 ` [PATCH 4/5] net: macb: " Ahmad Fatoum
2020-10-01  7:43 ` [PATCH 5/5] scripts: kwbimage: " Ahmad Fatoum
2020-10-02  4:31 ` [PATCH 1/5] treewide: fix unterminated of_device_id[] reported by Coccinelle Sascha Hauer

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