From 461ffcad4f21a2658cc12a8bed1cbef82576dfe5 Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 29 Dec 2021 00:04:45 +0000 Subject: [PATCH] Tweak some DEBUG output. Always put '0x' prefix in front of displayed hex values, i.e. the checksums. Add missing letoh32() so bad endian checksum is clear. Be consistent when displaying 'expected' and 'got' checksums, i.e. 'expected' == calculated checksum and 'got' == checksum found in GPT. --- sbin/fdisk/gpt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/fdisk/gpt.c b/sbin/fdisk/gpt.c index 6547d930867..eb23259bde9 100644 --- a/sbin/fdisk/gpt.c +++ b/sbin/fdisk/gpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gpt.c,v 1.54 2021/12/28 23:44:02 krw Exp $ */ +/* $OpenBSD: gpt.c,v 1.55 2021/12/29 00:04:45 krw Exp $ */ /* * Copyright (c) 2015 Markus Muller * Copyright (c) 2015 Kenneth R Westerback @@ -165,9 +165,9 @@ get_header(const uint64_t sector) gh.gh_csum = 0; new_gh_csum = crc32((unsigned char *)&gh, letoh32(gh.gh_size)); gh.gh_csum = orig_gh_csum; - if (letoh32(orig_gh_csum) != new_gh_csum) { + if (new_gh_csum != letoh32(gh.gh_csum)) { DPRINTF("gpt header checksum: expected 0x%x, got 0x%x\n", - orig_gh_csum, new_gh_csum); + new_gh_csum, letoh32(gh.gh_csum)); return -1; } @@ -244,8 +244,8 @@ get_partition_table(void) checksum = crc32((unsigned char *)&gp, gpbytes); if (checksum != letoh32(gh.gh_part_csum)) { - DPRINTF("gpt partition table checksum: expected %x, got %x\n", - checksum, letoh32(gh.gh_part_csum)); + DPRINTF("gpt partition table checksum: expected 0x%x, " + "got 0x%x\n", checksum, letoh32(gh.gh_part_csum)); return -1; } -- 2.20.1