lkml.org 
[lkml]   [2014]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] kernel/power/hibernate.c: be sure of 'start' is not bigger than 'stop'
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
--
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/

\
 
 \ /
  Last update: 2014-04-21 22:21    [W:0.044 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site