]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[console] Avoid timer wraparound problems in getchar_timeout()
authorMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 17:40:12 +0000 (17:40 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 7 Mar 2011 19:22:20 +0000 (19:22 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/core/getkey.c

index d93ba1e6471fff7f6ed594e75767f41b8c9e14b1..5710f190002dfd99f4d7d3fc9eb80fd183f6104b 100644 (file)
@@ -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();