public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse
@ 2023-07-02  1:03 Marek Vasut
  2023-07-02 12:58 ` Fabio Estevam
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marek Vasut @ 2023-07-02  1:03 UTC (permalink / raw)
  To: u-boot
  Cc: trini, Marek Vasut, Peng Fan, NXP i.MX U-Boot Team, Fabio Estevam,
	Heiko Schocher, Heinrich Schuchardt, Rasmus Villemoes,
	Simon Glass, Stefano Babic, Ye Li

Bitwise operations on signed integers are not defined,
replace them with per-call checks.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
Cc: Fabio Estevam <festevam@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Cc: Stefano Babic <sbabic@denx.de>
Cc: Tom Rini <trini@konsulko.com>
Cc: Ye Li <ye.li@nxp.com>
---
V2: - s@then@them@
    - Add RB from Peng
---
 arch/arm/mach-imx/spl_imx_romapi.c | 32 ++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/arch/arm/mach-imx/spl_imx_romapi.c b/arch/arm/mach-imx/spl_imx_romapi.c
index 9164045115f..4af41699678 100644
--- a/arch/arm/mach-imx/spl_imx_romapi.c
+++ b/arch/arm/mach-imx/spl_imx_romapi.c
@@ -76,13 +76,16 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	u32 image_offset;
 
 	ret = rom_api_query_boot_infor(QUERY_IVT_OFF, &offset);
-	ret |= rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
-	ret |= rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset);
+	if (ret != ROM_API_OKAY)
+		goto err;
 
-	if (ret != ROM_API_OKAY) {
-		puts("ROMAPI: Failure query boot infor pagesize/offset\n");
-		return -1;
-	}
+	ret = rom_api_query_boot_infor(QUERY_PAGE_SZ, &pagesize);
+	if (ret != ROM_API_OKAY)
+		goto err;
+
+	ret = rom_api_query_boot_infor(QUERY_IMG_OFF, &image_offset);
+	if (ret != ROM_API_OKAY)
+		goto err;
 
 	header = (struct legacy_img_hdr *)(CONFIG_SPL_IMX_ROMAPI_LOADADDR);
 
@@ -124,6 +127,10 @@ static int spl_romapi_load_image_seekable(struct spl_image_info *spl_image,
 	}
 
 	return 0;
+
+err:
+	puts("ROMAPI: Failure query boot infor pagesize/offset\n");
+	return -1;
 }
 
 static ulong spl_ram_load_read(struct spl_load_info *load, ulong sector,
@@ -344,12 +351,12 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 	u32 boot, bstage;
 
 	ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
-	ret |= rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
+	if (ret != ROM_API_OKAY)
+		goto err;
 
-	if (ret != ROM_API_OKAY) {
-		puts("ROMAPI: failure at query_boot_info\n");
-		return -1;
-	}
+	ret = rom_api_query_boot_infor(QUERY_BT_STAGE, &bstage);
+	if (ret != ROM_API_OKAY)
+		goto err;
 
 	printf("Boot Stage: ");
 
@@ -374,4 +381,7 @@ int board_return_to_bootrom(struct spl_image_info *spl_image,
 		return spl_romapi_load_image_stream(spl_image, bootdev);
 
 	return spl_romapi_load_image_seekable(spl_image, bootdev, boot);
+err:
+	puts("ROMAPI: failure at query_boot_info\n");
+	return -1;
 }
-- 
2.40.1


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

* Re: [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse
  2023-07-02  1:03 [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse Marek Vasut
@ 2023-07-02 12:58 ` Fabio Estevam
  2023-07-03  5:42 ` Heiko Schocher
  2023-07-11 19:44 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: Fabio Estevam @ 2023-07-02 12:58 UTC (permalink / raw)
  To: Marek Vasut
  Cc: u-boot, trini, Peng Fan, NXP i.MX U-Boot Team, Heiko Schocher,
	Heinrich Schuchardt, Rasmus Villemoes, Simon Glass, Stefano Babic,
	Ye Li

On 01/07/2023 22:03, Marek Vasut wrote:
> Bitwise operations on signed integers are not defined,
> replace them with per-call checks.
> 
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Marek Vasut <marex@denx.de>

Reviewed-by: Fabio Estevam <festevam@denx.de>

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

* Re: [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse
  2023-07-02  1:03 [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse Marek Vasut
  2023-07-02 12:58 ` Fabio Estevam
@ 2023-07-03  5:42 ` Heiko Schocher
  2023-07-11 19:44 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: Heiko Schocher @ 2023-07-03  5:42 UTC (permalink / raw)
  To: Marek Vasut, u-boot
  Cc: trini, Peng Fan, NXP i.MX U-Boot Team, Fabio Estevam,
	Heinrich Schuchardt, Rasmus Villemoes, Simon Glass, Stefano Babic,
	Ye Li

Hello Marek,

On 02.07.23 03:03, Marek Vasut wrote:
> Bitwise operations on signed integers are not defined,
> replace them with per-call checks.
> 
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "NXP i.MX U-Boot Team" <uboot-imx@nxp.com>
> Cc: Fabio Estevam <festevam@denx.de>
> Cc: Heiko Schocher <hs@denx.de>
> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Stefano Babic <sbabic@denx.de>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Ye Li <ye.li@nxp.com>
> ---
> V2: - s@then@them@
>     - Add RB from Peng
> ---
>  arch/arm/mach-imx/spl_imx_romapi.c | 32 ++++++++++++++++++++----------
>  1 file changed, 21 insertions(+), 11 deletions(-)

good catch!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs@denx.de

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

* [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse
  2023-07-02  1:03 [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse Marek Vasut
  2023-07-02 12:58 ` Fabio Estevam
  2023-07-03  5:42 ` Heiko Schocher
@ 2023-07-11 19:44 ` sbabic
  2 siblings, 0 replies; 4+ messages in thread
From: sbabic @ 2023-07-11 19:44 UTC (permalink / raw)
  To: Marek Vasut, u-boot

> Bitwise operations on signed integers are not defined,
> replace them with per-call checks.
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> Reviewed-by: Fabio Estevam <festevam@denx.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,        Managing Director: Erika Unter  
HRB 165235 Munich,   Office: Kirchenstr.5, 82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic@denx.de
=====================================================================

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

end of thread, other threads:[~2023-07-11 19:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-02  1:03 [PATCH v2] ARM: imx: romapi: Fix signed integer bitwise ops misuse Marek Vasut
2023-07-02 12:58 ` Fabio Estevam
2023-07-03  5:42 ` Heiko Schocher
2023-07-11 19:44 ` sbabic

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