From owner-freebsd-bugs@FreeBSD.ORG Mon Feb 4 14:10:02 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4336CC25 for ; Mon, 4 Feb 2013 14:10:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 1CFE91DB6 for ; Mon, 4 Feb 2013 14:10:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r14EA2mU065090 for ; Mon, 4 Feb 2013 14:10:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r14EA1gT065089; Mon, 4 Feb 2013 14:10:02 GMT (envelope-from gnats) Date: Mon, 4 Feb 2013 14:10:02 GMT Message-Id: <201302041410.r14EA1gT065089@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Gleb Smirnoff Subject: Re: kern/175759: Correct data types for fields of struct qm_trace{} from X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Gleb Smirnoff List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2013 14:10:02 -0000 The following reply was made to PR kern/175759; it has been noted by GNATS. From: Gleb Smirnoff To: Andrey Simonenko Cc: FreeBSD-gnats-submit@freebsd.org Subject: Re: kern/175759: Correct data types for fields of struct qm_trace{} from Date: Mon, 4 Feb 2013 18:05:54 +0400 Andrey, On Fri, Feb 01, 2013 at 03:49:07PM +0200, Andrey Simonenko wrote: A> > A> 1. File name fields should have "const char *" type. A> > A> > Paragraph 6.10.8 of standard says that __FILE__ is "a character string A> > literal". It doesn't say that it can be referenced only by a pointer A> > with const qualifier. A> > A> > However, the proposed change definitely makes sence. A> A> Yes, but values these pointers are pointed to are not expected A> to be modified and pointing (char *) to __FILE__ will generate above A> given warning message. Thanks for sample code. A> > A> 2. Line number fields should have "long" or "unsigned long" type, A> > A> considering C99 standard and its values for [U]INT_MAX, __LINE__ A> > A> and #line. A> > A> > Paragraph 6.10.8 of standard says that __LINE__ is "an integer constant". A> > A> > Paragraph 6.4.4.1 on integer constants says that "The type of an integer A> > constant is the first of the corresponding list in which its value can A> > be represented." The corresponding list starts with "int". According to A> > paragraph 6.10.4 line number can't get bigger that 2147483647 (INT_MAX), A> > and this value can be represented by int. A> > A> > Thus, I don't see where standard says that line number should be long. A> A> 5.2.4.2.1 says "Their implementation-defined values shall be equal or A> greater in magnitude (absolute value) to those shown, with the same sign." A> A> -- maximum value for an object of type int A> INT_MAX +32767 // 2^15-1 A> -- maximum value for an object of type unsigned int A> UINT_MAX 65535 // 2^16-1 A> -- maximum value for an object of type long int A> LONG_MAX +2147483647 // 2^31-1 A> -- maximum value for an object of type unsigned long int A> ULONG_MAX 4294967295 // 2^32-1 A> A> According to this information the closest integer data type to the maximum A> value of a line number given in #line is "long" or "unsigned long". A> A> Even if we assume that INT_MAX is bigger that 2^31-1 then specifying A> "unsigned long" in that structure (without changing the order of its fields) A> will not change its size on i386 and amd64. Yes, my error was that I looked into INT_MAX on my machine, not in standard. Thanks again. -- Totus tuus, Glebius.