Skip to content

Commit 811a3ba

Browse files
committed
lib/getchar: Deduplicate timer event recreation in ESC handler using restart label
1 parent d6966f1 commit 811a3ba

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/lib/getchar.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ int pit_sleep_and_quit_on_keypress(int seconds) {
284284
events[0] = exproto->WaitForKeyEx;
285285
}
286286

287+
restart:
287288
gBS->CreateEvent(EVT_TIMER, TPL_CALLBACK, NULL, NULL, &events[1]);
288289

289290
gBS->SetTimer(events[1], TimerRelative, (uint64_t)10000000 * seconds);
@@ -339,17 +340,16 @@ int pit_sleep_and_quit_on_keypress(int seconds) {
339340
}
340341

341342
gBS->CloseEvent(events[1]);
342-
gBS->CreateEvent(EVT_TIMER, TPL_CALLBACK, NULL, NULL, &events[1]);
343-
gBS->SetTimer(events[1], TimerRelative, (uint64_t)10000000 * seconds);
344343

345344
if (status != EFI_SUCCESS) {
346-
goto again;
345+
goto restart;
347346
}
348347

349348
if (kd.Key.UnicodeChar == '[') {
350-
gBS->CloseEvent(events[1]);
351349
return input_sequence(!use_sproto, exproto, sproto);
352350
}
351+
352+
goto restart;
353353
}
354354

355355
int ret = getchar_internal(kd.Key.ScanCode, kd.Key.UnicodeChar,

0 commit comments

Comments
 (0)