From owner-freebsd-tinderbox@FreeBSD.ORG Wed Jun 3 20:02:19 2009 Return-Path: Delivered-To: tinderbox@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 306E910656EF; Wed, 3 Jun 2009 20:02:19 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (alchemy.franken.de [194.94.249.214]) by mx1.freebsd.org (Postfix) with ESMTP id 9793F8FC1C; Wed, 3 Jun 2009 20:02:18 +0000 (UTC) (envelope-from marius@alchemy.franken.de) Received: from alchemy.franken.de (localhost [127.0.0.1]) by alchemy.franken.de (8.14.3/8.14.3/ALCHEMY.FRANKEN.DE) with ESMTP id n53K0DXQ043438; Wed, 3 Jun 2009 22:00:13 +0200 (CEST) (envelope-from marius@alchemy.franken.de) Received: (from marius@localhost) by alchemy.franken.de (8.14.3/8.14.3/Submit) id n53K0DTo043437; Wed, 3 Jun 2009 22:00:13 +0200 (CEST) (envelope-from marius) Date: Wed, 3 Jun 2009 22:00:13 +0200 From: Marius Strobl To: Eygene Ryabinkin , jeff@freebsd.org Message-ID: <20090603200013.GB43137@alchemy.franken.de> References: <20090602222445.2F6017302F@freebsd-current.sentex.ca> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Cc: current@freebsd.org, kmacy@freebsd.org, rwatson@freebsd.org, FreeBSD Tinderbox , sparc64@freebsd.org Subject: Re: [head tinderbox] failure on sparc64/sun4v X-BeenThere: freebsd-tinderbox@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Tinderbox reports, responses, and meta-comments" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 20:02:20 -0000 On Wed, Jun 03, 2009 at 02:15:55PM +0400, Eygene Ryabinkin wrote: > 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? > 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) > > > /* This looks correct to me. Jeff? Marius