From e28f262a86165ffa6fbc76a07e869b750afa75b1 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Fri, 4 Aug 2017 18:02:54 +0000 Subject: [PATCH] Fix off by one in calculation of the number of buckets for the pc addresses. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D11864 --- usr.sbin/pmcstat/pmcpl_gprof.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.sbin/pmcstat/pmcpl_gprof.c b/usr.sbin/pmcstat/pmcpl_gprof.c index b14778608f8d..acb339e96f51 100644 --- a/usr.sbin/pmcstat/pmcpl_gprof.c +++ b/usr.sbin/pmcstat/pmcpl_gprof.c @@ -468,8 +468,8 @@ pmcpl_gmon_process(struct pmcstat_process *pp, struct pmcstat_pmcrecord *pmcr, image, pmcid); pgf->pgf_pmcid = pmcid; assert(image->pi_end > image->pi_start); - pgf->pgf_nbuckets = (image->pi_end - image->pi_start) / - FUNCTION_ALIGNMENT; /* see */ + pgf->pgf_nbuckets = howmany(image->pi_end - image->pi_start, + FUNCTION_ALIGNMENT); /* see */ pgf->pgf_ndatabytes = sizeof(struct gmonhdr) + pgf->pgf_nbuckets * hc_sz; pgf->pgf_nsamples = 0;