From 6aca88663ce711006f87be27f827e37699893303 Mon Sep 17 00:00:00 2001 From: krw Date: Tue, 18 Jan 2022 19:37:27 +0000 Subject: [PATCH] PRT_make() can just zap the destination dos_partition if the source prt has prt_ns == 0 or prt_id == DOSPTYP_UNUSED. No functional change. --- sbin/fdisk/part.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 3dd5ee8a701..f7525baa104 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.110 2021/10/18 20:27:32 krw Exp $ */ +/* $OpenBSD: part.c,v 1.111 2022/01/18 19:37:27 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -313,6 +313,11 @@ PRT_make(const struct prt *prt, const uint64_t lba_self, const uint64_t lba_firs uint64_t off, t; uint32_t ecyl, scyl; + if (prt->prt_ns == 0 || prt->prt_id == DOSPTYP_UNUSED) { + memset(dp, 0, sizeof(*dp)); + return; + } + scyl = (prt->prt_scyl > 1023) ? 1023 : prt->prt_scyl; ecyl = (prt->prt_ecyl > 1023) ? 1023 : prt->prt_ecyl; -- 2.20.1