Re: arch/i386/kernel/mpparse.c warning fixes
mikpe@csd.uu.se
Thu, 22 May 2003 20:49:33 +0200
William Lee Irwin III writes:
> William Lee Irwin III writes:
> >> m->mpc_apicid is an 8-bit type; MAX_APICS can be 256. The above fix
> >> properly compares two integral expressions of equal width.
>
> On Thu, May 22, 2003 at 08:29:41PM +0200, mikpe@csd.uu.se wrote:
> > In the original "_>_", the 8-bit mpc_apicid is implicitly converted to int
> > before the comparison, as part of the "integer promotions" in the "usual
> > arithmetic conversions" (C standard lingo). The same happens in your "_-_<=0".
> > So what's the benefit of the rewrite?
>
> It removes a warning about comparisons being always true or false by
> virtue of the limited range of a type.
Ah, so it's a workaround to silence a compiler warning on char > 256.
Frankly, I'd rather see a cast there in this case. I.e.,
(unsigned int)m->mpc_apicid >= MAX_APICS
or something like that, with a suitable comment.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/