Messages in this thread | | | Date | Tue, 10 Feb 2004 16:55:34 -0800 | From | Andrew Morton <> | Subject | Re: [TRIVIAL patch] 2.6.2-rc2 Remove compile warnings from timer.o |
| |
Darren Williams <dsw@gelato.unsw.edu.au> wrote: > > > To allow the ia64 simulator to run correctly on slower machines > the value of HZ has been defined as 32, this has introduced a compiler > warning (not that much of issue): > kernel/timer.c: In function `second_overflow': > kernel/timer.c:589: warning: right shift count is negative > kernel/timer.c:592: warning: right shift count is negative > > I asked if the value of HZ could be increased for the simulator in > include/asm-ia64/param.h, > which was rejected for reasons below.
Well we really should be able to support values lower than 32 anyway - just from a quality-of-code point of view.
I do recall once spying a piece of code which would cause a div-by-zero if HZ was set to less than 50. These things happen.
> ltemp = time_freq + pps_freq; > + > +#if (SHIFT_SCALE <= (SHIFT_USEC + SHIFT_HZ)) > if (ltemp < 0) > time_adj -= -ltemp >> > (SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE); > else > time_adj += ltemp >> > (SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE); > + > +#else /* (SHIFT_SCALE > (SHIFT_USEC + SHIFT_HZ)) */ > + if (ltemp < 0) > + time_adj -= -ltemp >> SHIFT_SCALE; > + else > + time_adj += ltemp >> SHIFT_SCALE; > + > +#endif /* (SHIFT_SCALE > (SHIFT_USEC + SHIFT_HZ)) */
You should lose the ifdefs. Just do:
if (SHIFT_SCALE <= (SHIFT_USEC + SHIFT_HZ)) { if (ltemp < 0) time_adj -= -ltemp >> (SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE); else time_adj += ltemp >> (SHIFT_USEC + SHIFT_HZ - SHIFT_SCALE); } ...
because
a) It is not revolting and
b) The compiler checks the unused code for you, then throws it away.
- 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/
| |