Hi, On Sat, 1 Jul 2017 15:42:57 -0700 ali...@peloton-tech.com wrote: > From: Alison Chaiken <ali...@peloton-tech.com> > > Make the partition table available for modification by reading it from > the user-specified device into a linked list. Provide an accessor > function for command-line testing. > > Signed-off-by: Alison Chaiken <ali...@peloton-tech.com> > --- > > Changes since v7: > The failure-handling logic of get_gpt_info() now is triggered > properly when valid_part=1. > > cmd/gpt.c | 119 > +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > include/part.h | 7 ++++ > 2 files changed, 126 insertions(+) > > diff --git a/cmd/gpt.c b/cmd/gpt.c > index 65fb80b..dd5f78b 100644 > --- a/cmd/gpt.c > +++ b/cmd/gpt.c [...] > +static int get_gpt_info(struct blk_desc *dev_desc) > +{ > + /* start partition numbering at 1, as U-Boot does */ > + int valid_parts = 1, p, ret; > + disk_partition_t info; > + struct disk_part *new_disk_part; > + > + if (disk_partitions.next == NULL) > + INIT_LIST_HEAD(&disk_partitions); > + > + for (p = 1; p <= MAX_SEARCH_PARTITIONS; p++) { > + ret = part_get_info(dev_desc, p, &info); > + if (ret) > + continue; > + > + new_disk_part = allocate_disk_part(&info, valid_parts); > + if (IS_ERR(new_disk_part)) > + goto out; > + > + list_add_tail(&new_disk_part->list, &disk_partitions); > + valid_parts++; > + } > + if (valid_parts == 1) { > + printf("** No valid partitions found **\n"); > + goto out; > + } > + return --valid_parts; > I personally find it somewhat strange to initialize a counter to 1 and then return its value reduced by one, rather than initializing it to 0 and returning the exact counter value.
Lothar Waßmann _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot