cvs commit: src/sys/sys pcpu.h

[ Available lists | Index of cvs-src-old | Month of Jul 2011 | Week of 9 Jul 2011 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Marius Strobl <marius@FreeBSD.org>
Date
9 Jul 2011 18:48:15
Subject
cvs commit: src/sys/sys pcpu.h
Message-ID
201107091848.p69ImEt5075864@repoman.freebsd.org


[ Hide this part ]
marius      2011-07-09 18:47:51 UTC

FreeBSD src repository

Modified files:
sys/sys pcpu.h
Log:
SVN rev 223893 on 2011-07-09 18:47:51Z by marius

Fix the definition for PCPU_NAME_LEN, which is intended to fit
("CPU %d", cpuid) where cpuid <= MAXCPU.

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.

Submitted by: rea

Revision Changes Path
1.55 +1 -1 src/sys/sys/pcpu.h


Elapsed time: 0.104 seconds