From b211836f6598da14dbf8bb4f22b9f26173fcfd77 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Sun, 3 Nov 2019 14:47:22 +0100 Subject: [PATCH] OcAppleKeyMapLib: Merge ExactMatch TRUE/FALSE control flows --- Library/OcAppleKeyMapLib/OcAppleKeyMapLib.c | 61 +++---------------- .../OcBootManagementLib/OcBootManagementLib.c | 5 ++ 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.c b/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.c index cd9eae5d..12503cfe 100644 --- a/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.c +++ b/Library/OcAppleKeyMapLib/OcAppleKeyMapLib.c @@ -118,31 +118,6 @@ InternalGetKeyStrokesByIndex ( return KeyStrokesInfo; } -// InternalMinSort -STATIC -VOID -InternalMinSort ( - IN OUT UINT16 *Operand, - IN UINTN NumberOfChilds - ) -{ - - UINTN Index; - UINTN Index2; - UINT16 FirstChild; - - for (Index = 0; Index < NumberOfChilds; ++Index) { - for (Index2 = (Index + 1); Index2 < NumberOfChilds; ++Index2) { - FirstChild = Operand[Index]; - - if (FirstChild > Operand[Index2]) { - Operand[Index] = Operand[Index2]; - Operand[Index2] = FirstChild; - } - } - } -} - // InternalGetKeyStrokes /** Returns all pressed keys and key modifiers into the appropiate buffers. @@ -271,7 +246,6 @@ InternalContainsKeyStrokes ( UINTN DbNumberOfKeyCodes; APPLE_MODIFIER_MAP DbModifiers; APPLE_KEY_CODE DbKeyCodes[8]; - INTN Result; UINTN Index; UINTN DbIndex; @@ -292,34 +266,19 @@ InternalContainsKeyStrokes ( || (DbNumberOfKeyCodes != NumberOfKeyCodes)) { return EFI_NOT_FOUND; } + } else if ((DbModifiers & Modifiers) != Modifiers) { + return EFI_NOT_FOUND; + } - InternalMinSort ((UINT16 *)KeyCodes, NumberOfKeyCodes); - InternalMinSort ((UINT16 *)DbKeyCodes, DbNumberOfKeyCodes); - - Result = CompareMem ( - (VOID *)KeyCodes, - (VOID *)DbKeyCodes, - (NumberOfKeyCodes * sizeof (*KeyCodes)) - ); - - if (Result != 0) { - return EFI_NOT_FOUND; - } - } else { - if ((DbModifiers & Modifiers) != Modifiers) { - return EFI_NOT_FOUND; + for (Index = 0; Index < NumberOfKeyCodes; ++Index) { + for (DbIndex = 0; DbIndex < DbNumberOfKeyCodes; ++DbIndex) { + if (KeyCodes[Index] == DbKeyCodes[DbIndex]) { + break; + } } - for (Index = 0; Index < NumberOfKeyCodes; ++Index) { - for (DbIndex = 0; DbIndex < DbNumberOfKeyCodes; ++DbIndex) { - if (KeyCodes[Index] == DbKeyCodes[DbIndex]) { - break; - } - } - - if (DbNumberOfKeyCodes == DbIndex) { - return EFI_NOT_FOUND; - } + if (DbNumberOfKeyCodes == DbIndex) { + return EFI_NOT_FOUND; } } diff --git a/Library/OcBootManagementLib/OcBootManagementLib.c b/Library/OcBootManagementLib/OcBootManagementLib.c index 6618163e..1749e78c 100644 --- a/Library/OcBootManagementLib/OcBootManagementLib.c +++ b/Library/OcBootManagementLib/OcBootManagementLib.c @@ -1039,6 +1039,11 @@ OcWaitForAppleKeyIndex ( &CsrActiveConfigSize, &CsrActiveConfig ); + // + // FIXME: CMD+S+Minus behaves as CMD+S when "slide=0" is not supported + // by the SIP configuration. This might be an oversight, but is + // consistent with the boot.efi implementation. + // WantsZeroSlide = !EFI_ERROR (Status) && (CsrActiveConfig & CSR_ALLOW_UNRESTRICTED_NVRAM) != 0; }