Explicitly pass a specific buffer length to format_bytes() to

make it print memory sizes in humanized readable digits.
This commit is contained in:
tsutsui 2009-04-07 10:49:54 +00:00
parent a4063088f7
commit 3d4412216c
1 changed files with 6 additions and 4 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: init_main.c,v 1.387 2009/04/02 19:43:11 ad Exp $ */
/* $NetBSD: init_main.c,v 1.388 2009/04/07 10:49:54 tsutsui Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@ -97,7 +97,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.387 2009/04/02 19:43:11 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.388 2009/04/07 10:49:54 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_ipsec.h"
@ -919,6 +919,8 @@ calc_cache_size(struct vm_map *map, int pct, int va_pct)
* - Print a limited banner if AB_SILENT.
* - Always send normal banner to the log.
*/
#define MEM_PBUFSIZE sizeof("99999 MB")
void
banner(void)
{
@ -942,8 +944,8 @@ banner(void)
memset(pbuf, 0, sizeof(pbuf));
(*pr)("%s%s", copyright, version);
format_bytes(pbuf, sizeof(pbuf), ctob((uint64_t)physmem));
format_bytes(pbuf, MEM_PBUFSIZE, ctob((uint64_t)physmem));
(*pr)("total memory = %s\n", pbuf);
format_bytes(pbuf, sizeof(pbuf), ctob((uint64_t)uvmexp.free));
format_bytes(pbuf, MEM_PBUFSIZE, ctob((uint64_t)uvmexp.free));
(*pr)("avail memory = %s\n", pbuf);
}