diff mbox

libflash: Fix pflash -i

Message ID 20170325091843.20418-1-mikey@neuling.org
State Accepted
Headers show

Commit Message

Michael Neuling March 25, 2017, 9:18 a.m. UTC
pflash -i is currently broken due to this commit

  commit 602dee4505cd0ceb5b69f056ec403f982b585791
  Author: Cyril Bur <cyril.bur@au1.ibm.com>
  libflash/libffs: Rework libffs

It's output doesn't correctly detect the last partition and continues
printing forever.

This fixes it by returning null when we don't find a partition in
ffs_get_part().

Signed-off-by: Michael Neuling <mikey@neuling.org>
---
 libflash/libffs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Cyril Bur March 27, 2017, 2:57 a.m. UTC | #1
On Sat, 2017-03-25 at 20:18 +1100, Michael Neuling wrote:
> pflash -i is currently broken due to this commit
> 
>   commit 602dee4505cd0ceb5b69f056ec403f982b585791
>   Author: Cyril Bur <cyril.bur@au1.ibm.com>
>   libflash/libffs: Rework libffs
> 
> It's output doesn't correctly detect the last partition and continues
> printing forever.
> 
> This fixes it by returning null when we don't find a partition in
> ffs_get_part().
> 

How we don't have tests for this escapes me, good find Mikey!

> Signed-off-by: Michael Neuling <mikey@neuling.org>

Acked-by: Cyril Bur <cyril.bur@au1.ibm.com>


> ---
>  libflash/libffs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libflash/libffs.c b/libflash/libffs.c
> index 9ce7224824..dca40188ed 100644
> --- a/libflash/libffs.c
> +++ b/libflash/libffs.c
> @@ -187,9 +187,10 @@ static struct ffs_entry *ffs_get_part(struct ffs_handle *ffs, uint32_t index)
>  
>  	list_for_each(&ffs->hdr.entries, ent, list)
>  		if (i++ == index)
> -			break;
> +			return ent;
>  
> -	return ent;
> +	/* Didn't find partition */
> +	return NULL;
>  }
>  
>  bool has_ecc(struct ffs_entry *ent)
Stewart Smith March 27, 2017, 3:22 a.m. UTC | #2
Michael Neuling <mikey@neuling.org> writes:
> pflash -i is currently broken due to this commit
>
>   commit 602dee4505cd0ceb5b69f056ec403f982b585791
>   Author: Cyril Bur <cyril.bur@au1.ibm.com>
>   libflash/libffs: Rework libffs
>
> It's output doesn't correctly detect the last partition and continues
> printing forever.
>
> This fixes it by returning null when we don't find a partition in
> ffs_get_part().
>
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> ---
>  libflash/libffs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

merged to master as of 6a3a09c27315d858647a1c978fa7032591a8e6c5
diff mbox

Patch

diff --git a/libflash/libffs.c b/libflash/libffs.c
index 9ce7224824..dca40188ed 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -187,9 +187,10 @@  static struct ffs_entry *ffs_get_part(struct ffs_handle *ffs, uint32_t index)
 
 	list_for_each(&ffs->hdr.entries, ent, list)
 		if (i++ == index)
-			break;
+			return ent;
 
-	return ent;
+	/* Didn't find partition */
+	return NULL;
 }
 
 bool has_ecc(struct ffs_entry *ent)