From 2bb562fcecc4251438eac79949afe6ea5aa26017 Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 19 May 2021 21:49:07 +0000 Subject: [PATCH] No need to pass the location of the partition table to GPT_get_partition_table() since the global 'gh' knows where it is. Fixes a couple of missing letoh64() calls by eliminating the need for them. --- sbin/fdisk/gpt.c | 12 ++++++------ sbin/fdisk/gpt.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c index f68d2cdea6e..32b19986080 100644 --- a/sbin/fdisk/gpt.c +++ b/sbin/fdisk/gpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.c,v 1.16 2021/05/15 22:06:43 krw Exp $ */ +/* $OpenBSD: gpt.c,v 1.17 2021/05/19 21:49:07 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller * Copyright (c) 2015 Kenneth R Westerback @@ -147,10 +147,10 @@ GPT_get_header(off_t where) } int -GPT_get_partition_table(off_t where) +GPT_get_partition_table(void) { ssize_t len; - off_t off; + off_t off, where; int secs; uint32_t checksum, partspersec; @@ -167,7 +167,7 @@ GPT_get_partition_table(off_t where) memset(&gp, 0, sizeof(gp)); - where *= dl.d_secsize; + where = letoh64(gh.gh_part_lba) * dl.d_secsize; off = lseek(disk.fd, where, SEEK_SET); if (off == -1) { DPRINTF("seek to gpt partition table @ sector %llu failed\n", @@ -205,7 +205,7 @@ GPT_read(int which) break; case ANYGPT: valid = GPT_get_header(GPTSECTOR); - if (valid != 0 || GPT_get_partition_table(gh.gh_part_lba) != 0) + if (valid != 0 || GPT_get_partition_table() != 0) valid = GPT_get_header(DL_GETDSIZE(&dl) - 1); break; default: @@ -213,7 +213,7 @@ GPT_read(int which) } if (valid == 0) - valid = GPT_get_partition_table(gh.gh_part_lba); + valid = GPT_get_partition_table(); if (valid != 0) { /* No valid GPT found. Zap any artifacts. */ diff --git a/sbin/fdisk/gpt.h b/sbin/fdisk/gpt.h index 19c8bcfe3f5..d32c9fde4c5 100644 --- a/sbin/fdisk/gpt.h +++ b/sbin/fdisk/gpt.h @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.h,v 1.9 2021/05/10 17:16:01 krw Exp $ */ +/* $OpenBSD: gpt.h,v 1.10 2021/05/19 21:49:07 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller * Copyright (c) 2015 Kenneth R Westerback @@ -18,7 +18,7 @@ void GPT_read(int); int GPT_get_header(off_t); -int GPT_get_partition_table(off_t); +int GPT_get_partition_table(void); int GPT_get_lba_start(unsigned int); int GPT_get_lba_end(unsigned int); -- 2.20.1