kern/175759: Correct data types for fields of struct qm_trace{} from <sys/queue.h>

Gleb Smirnoff glebius at FreeBSD.org
Fri Feb 1 13:10:02 UTC 2013


The following reply was made to PR kern/175759; it has been noted by GNATS.

From: Gleb Smirnoff <glebius at FreeBSD.org>
To: Andrey Simonenko <simon at comsys.ntu-kpi.kiev.ua>
Cc: FreeBSD-gnats-submit at freebsd.org
Subject: Re: kern/175759: Correct data types for fields of struct qm_trace{}
 from <sys/queue.h>
Date: Fri, 1 Feb 2013 17:04:27 +0400

 On Fri, Feb 01, 2013 at 01:43:46PM +0200, Andrey Simonenko wrote:
 A> If QUEUE_MACRO_DEBUG is defined and WARNS >= 4, then a program that
 A> uses some macro definitions from <sys/queue.h> cannot be built because
 A> of "warning: assignment discards qualifiers from pointer target type"
 A> warnings.
 
 Can you please provide a sample file? I can reproduce this with simple
 declaration of TAILQ_HEAD for example, neither with gcc nor clang.
 
 A> 1. File name fields should have "const char *" type.
 
 Paragraph 6.10.8 of standard says that __FILE__ is "a character string
 literal". It doesn't say that it can be referenced only by a pointer
 with const qualifier.
 
 However, the proposed change definitely makes sence.
 
 A> 2. Line number fields should have "long" or "unsigned long" type,
 A>    considering C99 standard and its values for [U]INT_MAX, __LINE__
 A>    and #line.
 
 Paragraph 6.10.8 of standard says that __LINE__ is "an integer constant".
 
 Paragraph 6.4.4.1 on integer constants says that "The type of an integer
 constant is the first of the corresponding list in which its value can
 be represented." The corresponding list starts with "int". According to
 paragraph 6.10.4 line number can't get bigger that 2147483647 (INT_MAX),
 and this value can be represented by int.
 
 Thus, I don't see where standard says that line number should be long.
 
 Correct me please, if I am wrong.
 
 -- 
 Totus tuus, Glebius.


More information about the freebsd-bugs mailing list