From mboxrd@z Thu Jan 1 00:00:00 1970 From: Lothar =?UTF-8?B?V2HDn21hbm4=?= Date: Mon, 3 Jul 2017 08:52:00 +0200 Subject: [U-Boot] [PATCH v8 8/10] GPT: read partition table from device into a data structure In-Reply-To: <1498948977-28169-1-git-send-email-alison@peloton-tech.com> References: <20170626093432.3d176852@karo-electronics.de> <1498948977-28169-1-git-send-email-alison@peloton-tech.com> Message-ID: <20170703085200.53bf5841@karo-electronics.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hi, On Sat, 1 Jul 2017 15:42:57 -0700 alison at peloton-tech.com wrote: > From: Alison Chaiken >=20 > 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. >=20 > Signed-off-by: Alison Chaiken > --- >=20 > Changes since v7: > The failure-handling logic of get_gpt_info() now is triggered > properly when valid_part=3D1. >=20 > cmd/gpt.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++++++ > include/part.h | 7 ++++ > 2 files changed, 126 insertions(+) >=20 > 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 =3D 1, p, ret; > + disk_partition_t info; > + struct disk_part *new_disk_part; > + > + if (disk_partitions.next =3D=3D NULL) > + INIT_LIST_HEAD(&disk_partitions); > + > + for (p =3D 1; p <=3D MAX_SEARCH_PARTITIONS; p++) { > + ret =3D part_get_info(dev_desc, p, &info); > + if (ret) > + continue; > + > + new_disk_part =3D 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 =3D=3D 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=C3=9Fmann