From: krw Date: Sat, 20 Nov 2021 15:29:45 +0000 (+0000) Subject: Sectors-per-cylinder (spc) is a constant value, so make it const X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=48561fc32647a8a035cfb68afeafba0f1a3334bb;p=openbsd Sectors-per-cylinder (spc) is a constant value, so make it const and use it instead of calculating it twice in MBR_init(). No functional change. --- diff --git a/sbin/fdisk/mbr.c b/sbin/fdisk/mbr.c index ae3b4c060d8..415d92b6805 100644 --- a/sbin/fdisk/mbr.c +++ b/sbin/fdisk/mbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mbr.c,v 1.107 2021/11/14 17:28:29 krw Exp $ */ +/* $OpenBSD: mbr.c,v 1.108 2021/11/20 15:29:45 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -45,7 +45,7 @@ MBR_init(struct mbr *mbr) struct prt bootprt, obsdprt; uint64_t adj; daddr_t daddr; - uint32_t spc; + const uint32_t spc = disk.dk_heads * disk.dk_sectors; memset(&gmbr, 0, sizeof(gmbr)); memset(&gh, 0, sizeof(gh)); @@ -81,7 +81,6 @@ MBR_init(struct mbr *mbr) obsdprt.prt_flag = 0; if (bootprt.prt_ns > 0) obsdprt.prt_bs = bootprt.prt_bs + bootprt.prt_ns; - spc = disk.dk_heads * disk.dk_sectors; if (obsdprt.prt_bs % spc != 0) obsdprt.prt_bs += spc - (obsdprt.prt_bs % spc); #else @@ -99,7 +98,7 @@ MBR_init(struct mbr *mbr) obsdprt.prt_bs += adj; /* Use all space up to end of last complete cylinder. */ - obsdprt.prt_ns = disk.dk_cylinders * disk.dk_heads * disk.dk_sectors; + obsdprt.prt_ns = disk.dk_cylinders * spc; obsdprt.prt_ns -= obsdprt.prt_bs; PRT_fix_CHS(&bootprt);