From: Michael Brown Date: Mon, 7 Mar 2011 17:40:12 +0000 (+0000) Subject: [console] Avoid timer wraparound problems in getchar_timeout() X-Git-Tag: v1.20.1~2266 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2969a8567ffd1e0fd1096199ec32b78beaf779fc;p=thirdparty%2Fipxe.git [console] Avoid timer wraparound problems in getchar_timeout() Signed-off-by: Michael Brown --- diff --git a/src/core/getkey.c b/src/core/getkey.c index d93ba1e64..5710f1900 100644 --- a/src/core/getkey.c +++ b/src/core/getkey.c @@ -39,9 +39,9 @@ FILE_LICENCE ( GPL2_OR_LATER ); * @ret character Character read from console */ int getchar_timeout ( unsigned long timeout ) { - unsigned long expiry = ( currticks() + timeout ); + unsigned long start = currticks(); - while ( currticks() < expiry ) { + while ( ( currticks() - start ) < timeout ) { step(); if ( iskey() ) return getchar();