[Skiboot] [PATCH 14/24] libffs: Fix ffs_lookup_part() return value
Benjamin Herrenschmidt
benh at kernel.crashing.org
Fri Jun 23 02:22:15 AEST 2017
It would return success when the part wasn't found
Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
---
libflash/libffs.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libflash/libffs.c b/libflash/libffs.c
index 7ae9050..8943505 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -348,18 +348,20 @@ void ffs_close(struct ffs_handle *ffs)
int ffs_lookup_part(struct ffs_handle *ffs, const char *name,
uint32_t *part_idx)
{
- int i = 0;
struct ffs_entry *ent = NULL;
+ int i = 0, rc = FFS_ERR_PART_NOT_FOUND;
list_for_each(&ffs->hdr.entries, ent, list) {
- if (strncmp(name, ent->name, sizeof(ent->name)) == 0)
+ if (strncmp(name, ent->name, sizeof(ent->name)) == 0) {
+ rc = 0;
break;
+ }
i++;
}
- if (part_idx)
+ if (rc == 0 && part_idx)
*part_idx = i;
- return ent ? 0 : FFS_ERR_PART_NOT_FOUND;
+ return rc;
}
int ffs_part_info(struct ffs_handle *ffs, uint32_t part_idx,
--
2.9.4
More information about the Skiboot
mailing list