Date: Wed, 3 Jun 2009 14:15:55 +0400 From: Eygene Ryabinkin <rea-fbsd@codelabs.ru> To: FreeBSD Tinderbox <tinderbox@freebsd.org> Cc: current@freebsd.org, marius@freebsd.org, rwatson@freebsd.org, kmacy@freebsd.org, sparc64@freebsd.org Subject: Re: [head tinderbox] failure on sparc64/sun4v Message-ID: <vGGiriRDUTPxnXzdq/aYGNGLA2U@j4OYE6OL8eALCd4BvSxIfwgoxSc> In-Reply-To: <rPuoszoUcXlrNmrZFDbbbNJuZzs@XX1fo6zQUfC4h0jjRC6IBz3oNH4> References: <20090602222445.2F6017302F@freebsd-current.sentex.ca> <mqQn8SFFPOY77oNsI7n1tk5O7LE@10Ilc7MfiXA2JVIRVQpZfk7cTQ4> <rPuoszoUcXlrNmrZFDbbbNJuZzs@XX1fo6zQUfC4h0jjRC6IBz3oNH4>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Wed, Jun 03, 2009 at 01:54:30PM +0400, Eygene Ryabinkin wrote:
> KTR's case seems to be wrong for PCPU_NAME_LEN larger than 24 bytes.
> Just now we won't be able to reach this with the current definition
> for PCPU_NAME_LEN, but some day (N - (PCPU_NAME_LEN + 7)/8) can
> become negative and that's bad.
And while I am here: definition for PCPU_NAME_LEN seems to be wrong.
It is intended to fit ("CPU %d", cpuid) where cpuid <= MAXCPU. If this
is correct, then (sys/sys/pcpu.h, line 57)
1. sizeof(__XSTRING(MAXCPU) + 1) is a typo: typeof(__XSTRING(...) + 1)
is 'char *', so sizeof() will return the size of the pointer, not
the size of the string contents. The proper expression should be
'sizeof(__XSTRING(MAXCPU)) + 1'.
2. one should not add one, but substract it: sizeof() accounts for the
trailing '\0' and we have two sizeof's, so the size of one '\0'
should be substracted -- this will give the maximal string buffer
length for CPU with its number, no less, no more.
Does the attached patch looks sane?
--
Eygene
_ ___ _.--. #
\`.|\..----...-'` `-._.-'_.-'` # Remember that it is hard
/ ' ` , __.--' # to read the on-line manual
)/' _/ \ `-_, / # while single-stepping the kernel.
`-'" `"\_ ,_.-;_.-\_ ', fsc/as #
_.-'_./ {_.' ; / # -- FreeBSD Developers handbook
{_.-``-' {_/ #
[-- Attachment #2 --]
diff --git a/sys/sys/pcpu.h b/sys/sys/pcpu.h
index 63c3fa3..98705eb 100644
--- a/sys/sys/pcpu.h
+++ b/sys/sys/pcpu.h
@@ -54,7 +54,7 @@ struct rm_queue {
struct rm_queue* volatile rmq_prev;
};
-#define PCPU_NAME_LEN (sizeof("CPU ") + sizeof(__XSTRING(MAXCPU) + 1))
+#define PCPU_NAME_LEN (sizeof("CPU ") + sizeof(__XSTRING(MAXCPU)) - 1)
/*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?vGGiriRDUTPxnXzdq/aYGNGLA2U>
