From owner-freebsd-current@FreeBSD.ORG Wed Jun 3 10:15:59 2009 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 993C91065672; Wed, 3 Jun 2009 10:15:59 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) Received: from 0.mx.codelabs.ru (0.mx.codelabs.ru [144.206.177.45]) by mx1.freebsd.org (Postfix) with ESMTP id 29BBB8FC0C; Wed, 3 Jun 2009 10:15:59 +0000 (UTC) (envelope-from rea-fbsd@codelabs.ru) DomainKey-Signature: a=rsa-sha1; q=dns; c=simple; s=one; d=codelabs.ru; h=Received:Date:From:To:Cc:Subject:Message-ID:Reply-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To:Sender; b=dADtYcmglARoP51HU6R6t4BA2pNhAp65i8B60iB2z4ghl8hs7WvWA0v3T/JKVXNFrVyiYbHoHAsp3DKlauxd1U5yywS4NpMX2upMosCMKfhPZPk7qSidwSEK5wiilWie6we/vszs1h2jfyUms57SE/MViwLKGkILvXqRr4vGpBk=; Received: from void.codelabs.ru (void.codelabs.ru [144.206.177.25]) by 0.mx.codelabs.ru with esmtpsa (TLSv1:AES256-SHA:256) id 1MBnVl-000NsR-T1; Wed, 03 Jun 2009 14:15:57 +0400 Date: Wed, 3 Jun 2009 14:15:55 +0400 From: Eygene Ryabinkin To: FreeBSD Tinderbox Message-ID: References: <20090602222445.2F6017302F@freebsd-current.sentex.ca> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EE8jvUPYYQjJtG7J" Content-Disposition: inline In-Reply-To: Sender: rea-fbsd@codelabs.ru Cc: current@freebsd.org, marius@freebsd.org, rwatson@freebsd.org, kmacy@freebsd.org, sparc64@freebsd.org Subject: Re: [head tinderbox] failure on sparc64/sun4v X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: rea-fbsd@codelabs.ru List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Jun 2009 10:16:00 -0000 --EE8jvUPYYQjJtG7J Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 {_.-``-' {_/ # --EE8jvUPYYQjJtG7J Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=p1 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) /* --EE8jvUPYYQjJtG7J--