The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: Darren Williams <dsw@gelato.unsw.edu.au>
Cc: linux-kernel@vger.kernel.org, akpm@digeo.com
Subject: Re: [TRIVIAL patch] 2.6.2-rc2 Remove compile warnings from timer.o
Date: Tue, 10 Feb 2004 16:55:34 -0800	[thread overview]
Message-ID: <20040210165534.3bdc22e3.akpm@osdl.org> (raw)
In-Reply-To: <20040211003913.GC15247@cse.unsw.EDU.AU>

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.




  reply	other threads:[~2004-02-11  0:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-11  0:39 [TRIVIAL patch] 2.6.2-rc2 Remove compile warnings from timer.o Darren Williams
2004-02-11  0:55 ` Andrew Morton [this message]
2004-02-11  1:15   ` Darren Williams

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=20040210165534.3bdc22e3.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=akpm@digeo.com \
    --cc=dsw@gelato.unsw.edu.au \
    --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