StdLib: Simple code cleanup
StdLib/LibC/Main/Main.c Change Print to Debug statements. Ensure errno is initialized to 0 before calling main(). StdLib/LibC/StdLib/Malloc.c Aesthetic Cleanup: remove unnecessary cast, fix two whitespace alignment problems. StdLib/LibC/Uefi/InteractiveIO/NonCanonRead.c Change Include order. StdLib/Include/paths.h Add definition _PATH_LIB for the path to the library directory: /Efi/StdLib/lib. StdLib/LibC/Stdio/vfwscanf.c Align declarations and initializations. Initialize the multipurpose pointer, p, to NULL. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Daryl McDaniel <daryl.mcdaniel@intel.com> Reviewed-by: Jaben Carsey <Jaben.carsey@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15664 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
committed by
darylm503
parent
caf89d64ff
commit
dfa51bb619
@ -1,6 +1,6 @@
|
|||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
are licensed and made available under the terms and conditions of the BSD License
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
which accompanies this distribution. The full text of the license may be found at
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
@ -50,6 +50,7 @@
|
|||||||
#define _PATH_STDLIB "/Efi/StdLib/"
|
#define _PATH_STDLIB "/Efi/StdLib/"
|
||||||
#define _PATH_ETC _PATH_STDLIB "etc/"
|
#define _PATH_ETC _PATH_STDLIB "etc/"
|
||||||
#define _PATH_TMP _PATH_STDLIB "tmp/"
|
#define _PATH_TMP _PATH_STDLIB "tmp/"
|
||||||
|
#define _PATH_LIB _PATH_STDLIB "lib/"
|
||||||
#define _PATH_BIN "/Efi/Tools/"
|
#define _PATH_BIN "/Efi/Tools/"
|
||||||
|
|
||||||
/* DOS style device paths */
|
/* DOS style device paths */
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
All of the global data in the gMD structure is initialized to 0, NULL, or
|
All of the global data in the gMD structure is initialized to 0, NULL, or
|
||||||
SIG_DFL; as appropriate.
|
SIG_DFL; as appropriate.
|
||||||
|
|
||||||
Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -81,9 +81,9 @@ ArgvConvert(UINTN Argc, CHAR16 **Argv)
|
|||||||
INTN nArgvSize; /* Cumulative size of narrow Argv[i] */
|
INTN nArgvSize; /* Cumulative size of narrow Argv[i] */
|
||||||
|
|
||||||
DEBUG_CODE_BEGIN();
|
DEBUG_CODE_BEGIN();
|
||||||
Print(L"ArgvConvert called with %d arguments.\n", Argc);
|
DEBUG((DEBUG_INIT, "ArgvConvert called with %d arguments.\n", Argc));
|
||||||
for(count = 0; count < ((Argc > 5)? 5: Argc); ++count) {
|
for(count = 0; count < ((Argc > 5)? 5: Argc); ++count) {
|
||||||
Print(L"Argument[%d] = \"%s\".\n", count, Argv[count]);
|
DEBUG((DEBUG_INIT, "Argument[%d] = \"%s\".\n", count, Argv[count]));
|
||||||
}
|
}
|
||||||
DEBUG_CODE_END();
|
DEBUG_CODE_END();
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ DEBUG_CODE_END();
|
|||||||
for(count = 0; count < Argc; ++count) {
|
for(count = 0; count < Argc; ++count) {
|
||||||
AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX);
|
AVsz = (ssize_t)wcstombs(NULL, Argv[count], ARG_MAX);
|
||||||
if(AVsz < 0) {
|
if(AVsz < 0) {
|
||||||
Print(L"ABORTING: Argv[%d] contains an unconvertable character.\n", count);
|
DEBUG((DEBUG_ERROR, "ABORTING: Argv[%d] contains an unconvertable character.\n", count));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
/* Not Reached */
|
/* Not Reached */
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ DEBUG_CODE_END();
|
|||||||
/* Reserve space for the converted strings. */
|
/* Reserve space for the converted strings. */
|
||||||
gMD->NCmdLine = (char *)AllocateZeroPool(nArgvSize+1);
|
gMD->NCmdLine = (char *)AllocateZeroPool(nArgvSize+1);
|
||||||
if(gMD->NCmdLine == NULL) {
|
if(gMD->NCmdLine == NULL) {
|
||||||
Print(L"ABORTING: Insufficient memory.\n");
|
DEBUG((DEBUG_ERROR, "ABORTING: Insufficient memory.\n"));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
/* Not Reached */
|
/* Not Reached */
|
||||||
}
|
}
|
||||||
@ -117,7 +117,7 @@ DEBUG_CODE_END();
|
|||||||
string += AVsz;
|
string += AVsz;
|
||||||
nArgvSize -= AVsz;
|
nArgvSize -= AVsz;
|
||||||
if(nArgvSize < 0) {
|
if(nArgvSize < 0) {
|
||||||
Print(L"ABORTING: Internal Argv[%d] conversion error.\n", count);
|
DEBUG((DEBUG_ERROR, "ABORTING: Internal Argv[%d] conversion error.\n", count));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
/* Not Reached */
|
/* Not Reached */
|
||||||
}
|
}
|
||||||
@ -158,6 +158,7 @@ ShellAppMain (
|
|||||||
mfd[i].MyFD = (UINT16)i;
|
mfd[i].MyFD = (UINT16)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEBUG((DEBUG_INIT, "StdLib: Open Standard IO.\n"));
|
||||||
i = open("stdin:", (O_RDONLY | O_TTY_INIT), 0444);
|
i = open("stdin:", (O_RDONLY | O_TTY_INIT), 0444);
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
i = open("stdout:", (O_WRONLY | O_TTY_INIT), 0222);
|
i = open("stdout:", (O_WRONLY | O_TTY_INIT), 0222);
|
||||||
@ -177,6 +178,7 @@ ShellAppMain (
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if( setjmp(gMD->MainExit) == 0) {
|
if( setjmp(gMD->MainExit) == 0) {
|
||||||
|
errno = 0; // Clean up any "scratch" values from startup.
|
||||||
ExitVal = (INTN)main( (int)Argc, gMD->NArgV);
|
ExitVal = (INTN)main( (int)Argc, gMD->NArgV);
|
||||||
exitCleanup(ExitVal);
|
exitCleanup(ExitVal);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +98,7 @@ malloc(size_t Size)
|
|||||||
|
|
||||||
DEBUG((DEBUG_POOL, "malloc(%d): NodeSz: %d", Size, NodeSize));
|
DEBUG((DEBUG_POOL, "malloc(%d): NodeSz: %d", Size, NodeSize));
|
||||||
|
|
||||||
Status = gBS->AllocatePool( EfiLoaderData, NodeSize, (void **)&Head);
|
Status = gBS->AllocatePool( EfiLoaderData, NodeSize, &Head);
|
||||||
if( Status != EFI_SUCCESS) {
|
if( Status != EFI_SUCCESS) {
|
||||||
RetVal = NULL;
|
RetVal = NULL;
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
/*-
|
/** @file
|
||||||
Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
|
valist worker function for the wide-character fscanf.
|
||||||
|
|
||||||
|
Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -140,7 +142,7 @@ __vfwscanf_unlocked(FILE * __restrict fp, const wchar_t * __restrict fmt, va_lis
|
|||||||
{
|
{
|
||||||
wint_t c; /* character from format, or conversion */
|
wint_t c; /* character from format, or conversion */
|
||||||
size_t width; /* field width, or 0 */
|
size_t width; /* field width, or 0 */
|
||||||
wchar_t *p; /* points into all kinds of strings */
|
wchar_t *p = NULL; /* points into all kinds of strings */
|
||||||
int n; /* handy integer */
|
int n; /* handy integer */
|
||||||
int flags; /* flags as defined above */
|
int flags; /* flags as defined above */
|
||||||
wchar_t *p0; /* saves original value of p when necessary */
|
wchar_t *p0; /* saves original value of p when necessary */
|
||||||
@ -156,9 +158,9 @@ __vfwscanf_unlocked(FILE * __restrict fp, const wchar_t * __restrict fmt, va_lis
|
|||||||
char *mbp; /* multibyte string pointer for %c %s %[ */
|
char *mbp; /* multibyte string pointer for %c %s %[ */
|
||||||
size_t nconv; /* number of bytes in mb. conversion */
|
size_t nconv; /* number of bytes in mb. conversion */
|
||||||
char mbbuf[MB_LEN_MAX]; /* temporary mb. character buffer */
|
char mbbuf[MB_LEN_MAX]; /* temporary mb. character buffer */
|
||||||
static const mbstate_t initial = { 0 };
|
|
||||||
mbstate_t mbs;
|
mbstate_t mbs;
|
||||||
|
|
||||||
|
static const mbstate_t initial = { 0 };
|
||||||
/* `basefix' is used to avoid `if' tests in the integer scanner */
|
/* `basefix' is used to avoid `if' tests in the integer scanner */
|
||||||
static short basefix[17] =
|
static short basefix[17] =
|
||||||
{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
{ 10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
|
||||||
@ -166,10 +168,12 @@ __vfwscanf_unlocked(FILE * __restrict fp, const wchar_t * __restrict fmt, va_lis
|
|||||||
nassigned = 0;
|
nassigned = 0;
|
||||||
nconversions = 0;
|
nconversions = 0;
|
||||||
nread = 0;
|
nread = 0;
|
||||||
ccls = ccle = NULL;
|
ccls = NULL;
|
||||||
|
ccle = NULL;
|
||||||
base = 0;
|
base = 0;
|
||||||
cclcompl = 0;
|
cclcompl = 0;
|
||||||
mbp = NULL;
|
mbp = NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = *fmt++;
|
c = *fmt++;
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
The functions assume that isatty() is TRUE at the time they are called.
|
The functions assume that isatty() is TRUE at the time they are called.
|
||||||
If _S_IWTTY is set, the device returns WIDE characters.
|
If _S_IWTTY is set, the device returns WIDE characters.
|
||||||
|
|
||||||
Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
distribution. The full text of the license may be found at
|
distribution. The full text of the license may be found at
|
||||||
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#include <sys/syslimits.h>
|
#include <sys/syslimits.h>
|
||||||
#include <sys/termios.h>
|
#include <sys/termios.h>
|
||||||
#include <Device/IIO.h>
|
|
||||||
#include <Containers/Fifo.h>
|
#include <Containers/Fifo.h>
|
||||||
|
#include <Device/IIO.h>
|
||||||
|
|
||||||
/** Perform a noncanonical read of input.
|
/** Perform a noncanonical read of input.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user