diff mbox series

[v3,4/4] spl: fit: improve spl_nand_fit_read(...) readability

Message ID 20200527115621.1062-5-dariobin@libero.it
State Accepted
Commit 84dd1902443cf500b2536eeb14d6662c6b502698
Headers show
Series Fix the SPL loading of a FIT image from NAND | expand

Commit Message

Dario Binacchi May 27, 2020, 11:56 a.m. UTC
Replacing the ret variable with err and handling first the error
condition about the value returned by the spl_nand_fit_read routine,
improves the code readability.
Furthermore, the 'else' int the 'else return ret' instruction was
useless.

cc: Michael Trimarchi <michael at amarulasolutions.com>
Signed-off-by: Dario Binacchi <dariobin at libero.it>
---

Changes in v3: None
Changes in v2: None

 common/spl/spl_nand.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Simon Glass May 31, 2020, 2:08 p.m. UTC | #1
Hi Dario,

On Wed, 27 May 2020 at 05:56, Dario Binacchi <dariobin at libero.it> wrote:
>
> Replacing the ret variable with err and handling first the error
> condition about the value returned by the spl_nand_fit_read routine,
> improves the code readability.
> Furthermore, the 'else' int the 'else return ret' instruction was
> useless.
>
> cc: Michael Trimarchi <michael at amarulasolutions.com>
> Signed-off-by: Dario Binacchi <dariobin at libero.it>
> ---
>
> Changes in v3: None
> Changes in v2: None
>
>  common/spl/spl_nand.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

I think 'ret' is better than 'err' since we don't know if it is an
error until we check it, but we do know it is a return code.

Regards,
Simon
diff mbox series

Patch

diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c
index 1e6f2dce56..d13a524597 100644
--- a/common/spl/spl_nand.c
+++ b/common/spl/spl_nand.c
@@ -43,15 +43,15 @@  static ulong spl_nand_fit_read(struct spl_load_info *load, ulong offs,
 			       ulong size, void *dst)
 {
 	ulong sector;
-	int ret;
+	int err;
 
 	sector = *(int *)load->priv;
 	offs = sector + nand_spl_adjust_offset(sector, offs - sector);
-	ret = nand_spl_load_image(offs, size, dst);
-	if (!ret)
-		return size;
-	else
+	err = nand_spl_load_image(offs, size, dst);
+	if (err)
 		return 0;
+
+	return size;
 }
 
 static int spl_nand_load_element(struct spl_image_info *spl_image,