From: Thibaut VARENE <varenet@parisc-linux.org>
To: linux-kernel@vger.kernel.org
Subject: linux-2.5 min()/max() macros generate warnings with gcc-3.0.4
Date: Sat, 9 Nov 2002 01:21:20 +0100 [thread overview]
Message-ID: <20021109012120.53dd8f55.varenet@parisc-linux.org> (raw)
Hi,
I'm currently trying to cleanup some warnings on 2.5 kernel tree, (especially on parisc files), and i noticed the following warnings when compiling with gcc-3.0.4:
mm/vmscan.c: In function `shrink_caches':
mm/vmscan.c:746: warning: duplicate `const'
mm/swap_state.c: In function `free_pages_and_swap_cache':
mm/swap_state.c:299: warning: duplicate `const'
in swap_state.c, the faulty line is:
int todo = min(chunk, nr);
where chunk is "const int" and nr is "int".
min()/max() are defined in include/linux/kernel.h:145
Here is the preprocessed compiler output for swap_state.c regarding the faulty line:
int todo = ({ const typeof(chunk) _x = (chunk); const typeof(nr) _y = (nr); (void) (&_x == &_y); _x < _y ? _x : _y; });
which should be read in particular as:
int todo = ({ const typeof(const int chunk) _x = (const int chunk);
with types expanded.
Therefore, it seems that gcc doesn't like the redundancy of 'const' around 'typeof'.
But, according to C99, section 6.7.3 "Type qualifiers", paragraph 4, "if the same qualifier appears more than once in the same specifier-qualifier-list, [...] the behavior is the same as if it appeared only once."
So gcc shouldn't be complaining...
FWIW, casting as follow solves the warning but it definitly _evil_, since we lose const'ness:
int todo = min((int)chunk, nr);
HTH,
Thibaut VARENE
The PA/Linux ESIEE Team
http://pateam.esiee.fr/
PS: please CC me when answering.
reply other threads:[~2002-11-09 0:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20021109012120.53dd8f55.varenet@parisc-linux.org \
--to=varenet@parisc-linux.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®