mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Chen Gang <gang.chen.5i5j@gmail.com>
Cc: Guan Xuetao <gxt@mprc.pku.edu.cn>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	len.brown@intel.com,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kernel/power/hibernate.c: be sure of 'start' is not bigger than 'stop'
Date: Mon, 21 Apr 2014 22:09:30 +0200	[thread overview]
Message-ID: <20140421200930.GA9880@amd.pavel.ucw.cz> (raw)
In-Reply-To: <53551FCB.3030109@gmail.com>

On Mon 2014-04-21 21:40:27, Chen Gang wrote:
> For do_div(), it need 'u64' type, which means the outside must be sure
> of 'start' is not bigger than 'stop', or it will report warning.
> 
> The related warning (with allmodconfig for unicore32):
> 
>     CC      kernel/power/hibernate.o
>   kernel/power/hibernate.c: In function ‘swsusp_show_speed’:
>   kernel/power/hibernate.c:237: warning: comparison of distinct pointer types lacks a cast
> 
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>

>  {
> -	s64 elapsed_centisecs64;
> +	u64 elapsed_centisecs64;
>  	int centisecs;
>  	int k;
>  	int kps;
>  
>  	elapsed_centisecs64 = timeval_to_ns(stop) - timeval_to_ns(start);
> +	if ((s64)elapsed_centisecs64 < 0) {
> +		printk(KERN_ERR "PM: stop: %llu < start %llu\n",
> +			timeval_to_ns(stop), timeval_to_ns(start));
> +		return;
> +	}
>  	do_div(elapsed_centisecs64, NSEC_PER_SEC / 100);
>  	centisecs = elapsed_centisecs64;
>  	if (centisecs == 0)

Quite a lot of code to shut up warning in mostly debugging
function... is there alternative method of shutting it up? Have you
seen < 0 values in wild? Is it worth handing that situation?
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2014-04-21 20:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-21 13:40 Chen Gang
2014-04-21 20:09 ` Pavel Machek [this message]
2014-04-21 20:43   ` Rafael J. Wysocki
2014-04-22  0:58     ` Chen Gang

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=20140421200930.GA9880@amd.pavel.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=gang.chen.5i5j@gmail.com \
    --cc=gxt@mprc.pku.edu.cn \
    --cc=len.brown@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    /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

all inboxes | Powered by JetHome®