mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* linux-2.5 min()/max() macros generate warnings with gcc-3.0.4
@ 2002-11-09  0:21 Thibaut VARENE
  0 siblings, 0 replies; only message in thread
From: Thibaut VARENE @ 2002-11-09  0:21 UTC (permalink / raw)
  To: linux-kernel

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-11-09  0:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-09  0:21 linux-2.5 min()/max() macros generate warnings with gcc-3.0.4 Thibaut VARENE

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®