VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (21 months ago)
Author:
vboxsync
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/Library/UefiShellLevel2CommandsLib/Cd.c

    r80721 r99404  
    3232  )
    3333{
    34   CHAR16        *Splitter;
    35   CHAR16        *TempBuffer;
    36   UINTN         TotalSize;
     34  CHAR16  *Splitter;
     35  CHAR16  *TempBuffer;
     36  UINTN   TotalSize;
    3737
    3838  Splitter   = NULL;
     
    4040  TotalSize  = 0;
    4141
    42   if (FullPath == NULL || *FullPath == NULL) {
     42  if ((FullPath == NULL) || (*FullPath == NULL)) {
    4343    return EFI_SUCCESS;
    4444  }
    4545
    4646  Splitter = StrStr (*FullPath, L":");
    47   ASSERT(Splitter != *FullPath);
    48 
    49   if (Splitter != NULL && *(Splitter + 1) != L'\\' && *(Splitter + 1) != L'/') {
    50     TotalSize = StrSize (Cwd) + StrSize (Splitter + 1);
     47  ASSERT (Splitter != *FullPath);
     48
     49  if ((Splitter != NULL) && (*(Splitter + 1) != L'\\') && (*(Splitter + 1) != L'/')) {
     50    TotalSize  = StrSize (Cwd) + StrSize (Splitter + 1);
    5151    TempBuffer = AllocateZeroPool (TotalSize);
    5252    if (TempBuffer == NULL) {
     
    5454    }
    5555
    56     StrCpyS (TempBuffer, TotalSize / sizeof(CHAR16), Cwd);
    57     StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), L"\\");
    58     StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), Splitter + 1);
    59 
    60     FreePool(*FullPath);
     56    StrCpyS (TempBuffer, TotalSize / sizeof (CHAR16), Cwd);
     57    StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), L"\\");
     58    StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), Splitter + 1);
     59
     60    FreePool (*FullPath);
    6161    *FullPath = TempBuffer;
    6262  }
     
    7676BOOLEAN
    7777IsCurrentFileSystem (
    78   IN CONST CHAR16   *FullPath,
    79   IN CONST CHAR16   *Cwd
     78  IN CONST CHAR16  *FullPath,
     79  IN CONST CHAR16  *Cwd
    8080  )
    8181{
    82   CHAR16 *Splitter1;
    83   CHAR16 *Splitter2;
     82  CHAR16  *Splitter1;
     83  CHAR16  *Splitter2;
    8484
    8585  Splitter1 = NULL;
    8686  Splitter2 = NULL;
    8787
    88   ASSERT(FullPath != NULL);
     88  ASSERT (FullPath != NULL);
    8989
    9090  Splitter1 = StrStr (FullPath, L":");
     
    9595  Splitter2 = StrStr (Cwd, L":");
    9696
    97   if (((UINTN) Splitter1 - (UINTN) FullPath) != ((UINTN) Splitter2 - (UINTN) Cwd)) {
     97  if (((UINTN)Splitter1 - (UINTN)FullPath) != ((UINTN)Splitter2 - (UINTN)Cwd)) {
    9898    return FALSE;
    9999  } else {
    100     if (StrniCmp (FullPath, Cwd, ((UINTN) Splitter1 - (UINTN) FullPath) / sizeof (CHAR16)) == 0) {
     100    if (StrniCmp (FullPath, Cwd, ((UINTN)Splitter1 - (UINTN)FullPath) / sizeof (CHAR16)) == 0) {
    101101      return TRUE;
    102102    } else {
     
    120120EFI_STATUS
    121121ExtractDriveAndPath (
    122   IN CONST CHAR16   *FullPath,
    123   OUT CHAR16        **Drive,
    124   OUT CHAR16        **Path
     122  IN CONST CHAR16  *FullPath,
     123  OUT CHAR16       **Drive,
     124  OUT CHAR16       **Path
    125125  )
    126126{
    127   CHAR16 *Splitter;
     127  CHAR16  *Splitter;
    128128
    129129  ASSERT (FullPath != NULL);
     
    133133  if (Splitter == NULL) {
    134134    *Drive = NULL;
    135     *Path = AllocateCopyPool (StrSize (FullPath), FullPath);
     135    *Path  = AllocateCopyPool (StrSize (FullPath), FullPath);
    136136    if (*Path == NULL) {
    137137      return EFI_OUT_OF_RESOURCES;
     
    140140    if (*(Splitter + 1) == CHAR_NULL) {
    141141      *Drive = AllocateCopyPool (StrSize (FullPath), FullPath);
    142       *Path = NULL;
     142      *Path  = NULL;
    143143      if (*Drive == NULL) {
    144144        return EFI_OUT_OF_RESOURCES;
    145145      }
    146146    } else {
    147       *Drive = AllocateCopyPool ((Splitter - FullPath + 2) * sizeof(CHAR16), FullPath);
     147      *Drive = AllocateCopyPool ((Splitter - FullPath + 2) * sizeof (CHAR16), FullPath);
    148148      if (*Drive == NULL) {
    149149        return EFI_OUT_OF_RESOURCES;
    150150      }
     151
    151152      (*Drive)[Splitter - FullPath + 1] = CHAR_NULL;
    152153
     
    175176  )
    176177{
    177   EFI_STATUS        Status;
    178   LIST_ENTRY        *Package;
    179   CONST CHAR16      *Cwd;
    180   CHAR16            *Path;
    181   CHAR16            *Drive;
    182   CHAR16            *ProblemParam;
    183   SHELL_STATUS      ShellStatus;
    184   CONST CHAR16      *Param1;
    185   CHAR16            *Param1Copy;
    186   CHAR16            *Walker;
    187   CHAR16            *Splitter;
    188   CHAR16            *TempBuffer;
    189   UINTN             TotalSize;
    190 
    191   ProblemParam  = NULL;
    192   ShellStatus   = SHELL_SUCCESS;
    193   Cwd           = NULL;
    194   Path          = NULL;
    195   Drive         = NULL;
    196   Splitter      = NULL;
    197   TempBuffer    = NULL;
    198   TotalSize     = 0;
    199 
    200   Status = CommandInit();
    201   ASSERT_EFI_ERROR(Status);
     178  EFI_STATUS    Status;
     179  LIST_ENTRY    *Package;
     180  CONST CHAR16  *Cwd;
     181  CHAR16        *Path;
     182  CHAR16        *Drive;
     183  CHAR16        *ProblemParam;
     184  SHELL_STATUS  ShellStatus;
     185  CONST CHAR16  *Param1;
     186  CHAR16        *Param1Copy;
     187  CHAR16        *Walker;
     188  CHAR16        *Splitter;
     189  CHAR16        *TempBuffer;
     190  UINTN         TotalSize;
     191
     192  ProblemParam = NULL;
     193  ShellStatus  = SHELL_SUCCESS;
     194  Cwd          = NULL;
     195  Path         = NULL;
     196  Drive        = NULL;
     197  Splitter     = NULL;
     198  TempBuffer   = NULL;
     199  TotalSize    = 0;
     200
     201  Status = CommandInit ();
     202  ASSERT_EFI_ERROR (Status);
    202203
    203204  //
    204205  // initialize the shell lib (we must be in non-auto-init...)
    205206  //
    206   Status = ShellInitialize();
    207   ASSERT_EFI_ERROR(Status);
     207  Status = ShellInitialize ();
     208  ASSERT_EFI_ERROR (Status);
    208209
    209210  //
     
    211212  //
    212213  Status = ShellCommandLineParse (EmptyParamList, &Package, &ProblemParam, TRUE);
    213   if (EFI_ERROR(Status)) {
    214     if (Status == EFI_VOLUME_CORRUPTED && ProblemParam != NULL) {
    215       ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cd", ProblemParam);
    216       FreePool(ProblemParam);
     214  if (EFI_ERROR (Status)) {
     215    if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
     216      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellLevel2HiiHandle, L"cd", ProblemParam);
     217      FreePool (ProblemParam);
    217218      ShellStatus = SHELL_INVALID_PARAMETER;
    218219    } else {
    219       ASSERT(FALSE);
     220      ASSERT (FALSE);
    220221    }
    221222  }
     
    224225  // check for "-?"
    225226  //
    226   if (ShellCommandLineGetFlag(Package, L"-?")) {
    227     ASSERT(FALSE);
    228   } else if (ShellCommandLineGetRawValue(Package, 2) != NULL) {
    229     ShellPrintHiiEx(-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"cd");
     227  if (ShellCommandLineGetFlag (Package, L"-?")) {
     228    ASSERT (FALSE);
     229  } else if (ShellCommandLineGetRawValue (Package, 2) != NULL) {
     230    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellLevel2HiiHandle, L"cd");
    230231    ShellStatus = SHELL_INVALID_PARAMETER;
    231232  } else {
     
    238239    Cwd = ShellGetCurrentDir (NULL);
    239240    if (Cwd == NULL) {
    240       ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
     241      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_CWD), gShellLevel2HiiHandle, L"cd");
    241242      ShellStatus = SHELL_NOT_FOUND;
    242243    } else {
     
    246247        // display the current directory
    247248        //
    248         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_CD_PRINT), gShellLevel2HiiHandle, Cwd);
     249        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_CD_PRINT), gShellLevel2HiiHandle, Cwd);
    249250      } else {
    250251        Param1Copy = CatSPrint (NULL, L"%s", Param1, NULL);
    251252        for (Walker = Param1Copy; Walker != NULL && *Walker != CHAR_NULL; Walker++) {
    252253          if (*Walker == L'\"') {
    253             CopyMem (Walker, Walker + 1, StrSize(Walker) - sizeof(Walker[0]));
     254            CopyMem (Walker, Walker + 1, StrSize (Walker) - sizeof (Walker[0]));
    254255          }
    255256        }
    256257
    257         if (Param1Copy != NULL && IsCurrentFileSystem (Param1Copy, Cwd)) {
    258           Status = ReplaceDriveWithCwd (&Param1Copy,Cwd);
     258        if ((Param1Copy != NULL) && IsCurrentFileSystem (Param1Copy, Cwd)) {
     259          Status = ReplaceDriveWithCwd (&Param1Copy, Cwd);
    259260        } else {
    260261          //
     
    265266        }
    266267
    267         if (!EFI_ERROR(Status) && Param1Copy != NULL) {
     268        if (!EFI_ERROR (Status) && (Param1Copy != NULL)) {
    268269          Splitter = StrStr (Cwd, L":");
    269270          if (Param1Copy[0] == L'\\') {
     
    271272            // Absolute Path on current drive letter.
    272273            //
    273             TotalSize = ((Splitter - Cwd + 1) * sizeof(CHAR16)) + StrSize(Param1Copy);
     274            TotalSize  = ((Splitter - Cwd + 1) * sizeof (CHAR16)) + StrSize (Param1Copy);
    274275            TempBuffer = AllocateZeroPool (TotalSize);
    275276            if (TempBuffer == NULL) {
    276277              Status = EFI_OUT_OF_RESOURCES;
    277278            } else {
    278               StrnCpyS (TempBuffer, TotalSize / sizeof(CHAR16), Cwd, (Splitter - Cwd + 1));
    279               StrCatS (TempBuffer, TotalSize / sizeof(CHAR16), Param1Copy);
     279              StrnCpyS (TempBuffer, TotalSize / sizeof (CHAR16), Cwd, (Splitter - Cwd + 1));
     280              StrCatS (TempBuffer, TotalSize / sizeof (CHAR16), Param1Copy);
    280281
    281282              FreePool (Param1Copy);
     
    284285            }
    285286          } else {
    286             if (StrStr (Param1Copy,L":") == NULL) {
    287               TotalSize = StrSize (Cwd) + StrSize (Param1Copy);
     287            if (StrStr (Param1Copy, L":") == NULL) {
     288              TotalSize  = StrSize (Cwd) + StrSize (Param1Copy);
    288289              TempBuffer = AllocateZeroPool (TotalSize);
    289290              if (TempBuffer == NULL) {
     
    302303        }
    303304
    304         if (!EFI_ERROR(Status)) {
     305        if (!EFI_ERROR (Status)) {
    305306          Param1Copy = PathCleanUpDirectories (Param1Copy);
    306           Status = ExtractDriveAndPath (Param1Copy, &Drive, &Path);
    307         }
    308 
    309         if (!EFI_ERROR (Status) && Drive != NULL && Path != NULL) {
    310           if (EFI_ERROR(ShellIsDirectory (Param1Copy))) {
    311             ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Param1Copy);
     307          Status     = ExtractDriveAndPath (Param1Copy, &Drive, &Path);
     308        }
     309
     310        if (!EFI_ERROR (Status) && (Drive != NULL) && (Path != NULL)) {
     311          if (EFI_ERROR (ShellIsDirectory (Param1Copy))) {
     312            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NOT_DIR), gShellLevel2HiiHandle, L"cd", Param1Copy);
    312313            ShellStatus = SHELL_NOT_FOUND;
    313314          } else {
    314315            Status = gEfiShellProtocol->SetCurDir (Drive, Path + 1);
    315316            if (EFI_ERROR (Status)) {
    316               ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN(STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Param1Copy);
     317              ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_DIR_NF), gShellLevel2HiiHandle, L"cd", Param1Copy);
    317318              ShellStatus = SHELL_NOT_FOUND;
    318319            }
     
    343344  return (ShellStatus);
    344345}
    345 
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette