The following reply was made to PR kern/175759; it has been noted by GNATS.
From: Gleb Smirnoff <gleb...@freebsd.org> To: Andrey Simonenko <si...@comsys.ntu-kpi.kiev.ua> Cc: freebsd-gnats-sub...@freebsd.org Subject: Re: kern/175759: Correct data types for fields of struct qm_trace{} from <sys/queue.h> 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. _______________________________________________ freebsd-bugs@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-bugs To unsubscribe, send any mail to "freebsd-bugs-unsubscr...@freebsd.org"