Divide GIG by 512 (DEV_BLKSIZE) so we don't overflow 32 bit u_long

when multiplying by 128 (in 32 bits, 128 * GIG == 0)

Should fix i386 build )and other 32 bit ports).

An alternative would be to use ULL rather than UL for the numbers,
but that would mean needlessly doing 64 bit arith for data that is
resticted to 32 bit results anyway.
This commit is contained in:
kre 2018-11-28 00:44:08 +00:00
parent 0cf68dd3c1
commit fbb3329fd3
1 changed files with 3 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: label.c,v 1.5 2018/11/27 17:13:41 martin Exp $ */
/* $NetBSD: label.c,v 1.6 2018/11/28 00:44:08 kre Exp $ */
/*
* Copyright 1997 Jonathan Stone
@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: label.c,v 1.5 2018/11/27 17:13:41 martin Exp $");
__RCSID("$NetBSD: label.c,v 1.6 2018/11/28 00:44:08 kre Exp $");
#endif
#include <sys/types.h>
@ -237,7 +237,7 @@ set_ptype(partinfo *p, int fstype, int flag)
p->pi_fsize = 512;
else if (p->pi_size < (1000 * MEG / 512))
p->pi_fsize = 1024;
else if (p->pi_size < (128 * GIG / 512))
else if (p->pi_size < (128 * (GIG / 512)))
p->pi_fsize = 2048;
else
p->pi_fsize = 4096;