Changeset 58459 in vbox for trunk/src/VBox/Devices/EFI/Firmware/StdLib/LibC/Main/Main.c
- Timestamp:
- Oct 28, 2015 8:17:18 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103761
- Location:
- trunk/src/VBox/Devices/EFI/Firmware
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/Firmware
-
Property svn:mergeinfo
set to (toggle deleted branches)
/vendor/edk2/current 103735-103757
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/Firmware/StdLib/LibC/Main/Main.c
r48674 r58459 5 5 SIG_DFL; as appropriate. 6 6 7 Copyright (c) 2010 - 201 1, Intel Corporation. All rights reserved.<BR>7 Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR> 8 8 This program and the accompanying materials are licensed and made available under 9 9 the terms and conditions of the BSD License that accompanies this distribution. … … 75 75 ArgvConvert(UINTN Argc, CHAR16 **Argv) 76 76 { 77 s ize_t AVsz; /* Size of a single nArgv string*/77 ssize_t AVsz; /* Size of a single nArgv string, or -1 */ 78 78 UINTN count; 79 79 char **nArgv; … … 82 82 83 83 DEBUG_CODE_BEGIN(); 84 Print(L"ArgvConvert called with %d arguments.\n", Argc);84 DEBUG((DEBUG_INIT, "ArgvConvert called with %d arguments.\n", Argc)); 85 85 for(count = 0; count < ((Argc > 5)? 5: Argc); ++count) { 86 Print(L"Argument[%d] = \"%s\".\n", count, Argv[count]);86 DEBUG((DEBUG_INIT, "Argument[%d] = \"%s\".\n", count, Argv[count])); 87 87 } 88 88 DEBUG_CODE_END(); … … 91 91 /* Determine space needed for narrow Argv strings. */ 92 92 for(count = 0; count < Argc; ++count) { 93 AVsz = wcstombs(NULL, Argv[count], ARG_MAX);93 AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX); 94 94 if(AVsz < 0) { 95 Print(L"ABORTING: Argv[%d] contains an unconvertable character.\n", count);95 DEBUG((DEBUG_ERROR, "ABORTING: Argv[%d] contains an unconvertable character.\n", count)); 96 96 exit(EXIT_FAILURE); 97 97 /* Not Reached */ … … 103 103 gMD->NCmdLine = (char *)AllocateZeroPool(nArgvSize+1); 104 104 if(gMD->NCmdLine == NULL) { 105 Print(L"ABORTING: Insufficient memory.\n");105 DEBUG((DEBUG_ERROR, "ABORTING: Insufficient memory.\n")); 106 106 exit(EXIT_FAILURE); 107 107 /* Not Reached */ … … 113 113 for(count = 0; count < Argc; ++count) { 114 114 nArgv[count] = string; 115 AVsz = wcstombs(string, Argv[count], nArgvSize); 116 string[AVsz] = 0; /* NULL terminate the argument */ 115 AVsz = wcstombs(string, Argv[count], nArgvSize) + 1; 117 116 DEBUG((DEBUG_INFO, "Cvt[%d] %d \"%s\" --> \"%a\"\n", (INT32)count, (INT32)AVsz, Argv[count], nArgv[count])); 118 string += AVsz + 1;119 nArgvSize -= AVsz + 1;117 string += AVsz; 118 nArgvSize -= AVsz; 120 119 if(nArgvSize < 0) { 121 Print(L"ABORTING: Internal Argv[%d] conversion error.\n", count);120 DEBUG((DEBUG_ERROR, "ABORTING: Internal Argv[%d] conversion error.\n", count)); 122 121 exit(EXIT_FAILURE); 123 122 /* Not Reached */ … … 160 159 } 161 160 162 i = open("stdin:", O_RDONLY, 0444); 161 DEBUG((DEBUG_INIT, "StdLib: Open Standard IO.\n")); 162 i = open("stdin:", (O_RDONLY | O_TTY_INIT), 0444); 163 163 if(i == 0) { 164 i = open("stdout:", O_WRONLY, 0222);164 i = open("stdout:", (O_WRONLY | O_TTY_INIT), 0222); 165 165 if(i == 1) { 166 166 i = open("stderr:", O_WRONLY, 0222); … … 179 179 else { 180 180 if( setjmp(gMD->MainExit) == 0) { 181 errno = 0; // Clean up any "scratch" values from startup. 181 182 ExitVal = (INTN)main( (int)Argc, gMD->NArgV); 182 183 exitCleanup(ExitVal);
Note:
See TracChangeset
for help on using the changeset viewer.