Re: [PATCH 2.4.26] drivers/char/vt.c fix compiler warnings

From: Thomas Gleixner
Date: Mon May 17 2004 - 07:54:38 EST


On Monday 17 May 2004 12:47, Andries Brouwer wrote:
> 4~On Sat, May 15, 2004 at 03:05:23PM +0200, Thomas Gleixner wrote:
> > The patch fixes the following warnings, produced by gcc3.3.3:
> >
> > s is a unsigned char, which can never be >= MAX_NR_KEYMAPS, as
> > MAX_NR_KEYMAPS = 256
> >
> > - if (i >= NR_KEYS || s >= MAX_NR_KEYMAPS)
> > + if (i >= NR_KEYS)
> > return -EINVAL;
>
> You see that you break thew source in order to avoid a compiler warning.
> Bad.
>
> (MAX_NR_KEYMAPS is a #define, often 256, on tiny systems people tend to
> pick 16. The above test is not superfluous. MAX_NR_KEYMAPS is not an
> absolute constant.)

Ooops, did not think about that. Was just annoyed from the compiler warnings.
What about:

--- linux-2.4.26-preempt/drivers/char/vt.c 2002-11-29 00:53:12.000000000 +0100
+++ linux-2.4.26-rc2-work/drivers/char/vt.c 2004-05-17 14:44:27.000000000
+0200
@@ -163,7 +163,11 @@

if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
return -EFAULT;
+#if MAX_NR_KEYMAPS < 256
if (i >= NR_KEYS || s >= MAX_NR_KEYMAPS)
+#else
+ if (i >= NR_KEYS)
+#endif
return -EINVAL;

switch (cmd) {

--
Thomas
________________________________________________________________________
Steve Ballmer quotes the statistic that IT pros spend 70 percent of their
time managing existing systems. That couldnât have anything to do with
the fact that 99 percent of these systems run Windows, could it?
________________________________________________________________________
linutronix - competence in embedded & realtime linux
http://www.linutronix.de
mail: tglx@xxxxxxxxxxxxx

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/