Extract a ProcessFileList() in:
- Touch.c
- Type.c
to lower the indentation level and simplify the logic.
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
Remove the ShellStatus variable which is not necessary.
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a GetTimeZoneFromString() function to decrease the
size of MainCmdTime().
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a PrintLsOutputCurr() function to decrease
the size of PrintLsOutput().
The patch also rationalize the usage of the Found
parameter:
- Found is updated only when a valid MetaFile is found
- a IsRecursive variable is created to distinguish
the first PrintLsOutput() call from the other
recursive ones.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Invert some conditions in PrintLsOutputRec() to lower
the indentation level.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a PrintLsOutputRec() function to decrease
the size of PrintLsOutput().
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
If no file/directory has been found, the number of
files/directories must be 0.
Hard-code these values to avoid depending on the
FileCount/FileSize/DirCount variables.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a GetCorrectedPath() function to decrease
the size of PrintLsOutput().
Also free the CorrectedPath in PrintLsOutput() before
re-allocating it to prepare for follow-up factorization.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Move ShellCloseFileMetaArg() calls to close the
MetaArg whenever its usage is not needed anymore.
This prepares for follow-up factorization.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a UpdateFileLocalTime() function to decrease
the size of PrintLsOutput().
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a DeleteDirectory() function to decrease
the size of CascadeDelete().
The extracted logic is slighly modified to lower
the indendation level.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Add a GetStopBits() utility function to convert
the StopBits to the EFI_STOP_BITS_TYPE type.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Invert error handling to lower the indentation level
in DisplaySettings().
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Add a GetParityType() utility function to convert
the Parity to the EFI_PARITY_TYPE type.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Add name conversion arrays:
- ParityBitName
- StopBitsName
to seamlessly convert parity/stop bits to a matching name.
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
The "ACPI for Memory System Resource Partitioning and Monitoring" spec
(Arm DEN0065, [1]) in version 2.0 described the "MMIO size" field in the
"MPAM MSC node" subtable as being always 0 if the the "PCC" interface type
is used for that MSC. Version 3.0 of the spec changes that field to convey
the enablement status of that MSC: "If set to 1, this MSC is accessible
... If set to 0, this MSC is non-functional...."
Relax the strict check for this value being 0 in the acpiview validation
checks, to also allow the new value of "1".
[1] https://developer.arm.com/documentation/den0065/3-0/
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Flatten the following functions to make them easier to read:
- TraverseHandleDatabase()
- GetDeviceHandleInfo()
- DoDecodeByProtocol()
No functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Extract a MainCmdXXX() function for each shell command.
This command contains the possible operations the command aims
to operate. The ShellCommandRunXXX() function from which it
is extracted is only responsible of:
- initializing the shell/command environment
- parsing the command parameter and creating a Package
- freeing the Package
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long function present in
the ShellPkg and reduce complexity/nested code and conditions.
Return directly if ShellCommandLineParse() returned an error Status.
In such case, the "Package" that should be allocated by
ShellCommandLineParse() is already freed in:
ShellCommandLineParse()
\-ShellCommandLineParseEx()
\-InternalCommandLineParse()
so there is no need to free it with ShellCommandLineFreeVarList().
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Remove post-parse write to mHestIA32HardwareBankCount.
Keep HEST parsing read-only.
*mHestIA32HardwareBankCount = 0, line in code corrupts the
ACPI HEST table data Hardware bank count to zero.
mHestIA32HardwareBankCount points into the parsed HEST table
data (input buffer). Writing through it modifies ACPI table
contents during parsing, which should be read-only behavior.
Signed-off-by: Gaurav Pandya <Gaurav.Pandya@amd.com>
Refactor GetHandleListByProtocol() to support
additions to the handle list during its execution.
Replace LocateHandle() with LocateHandleBuffer() to
avoid the possibility that the buffer allocated for
LocateHandle() is too small if additional handles
are added during GetHandleListByProtocol() execution.
Note that the previous implementation did not detect
the handle list growth and would cause memory
corruption when writing the terminating NULL handle
to the allocated buffer.
Signed-off-by: Bob Morgan <bobm@nvidia.com>
SmbiosView tool changes for Protocol Records info decode and print.
This commit adds the following decoding functionality:
First, it prints the `MCHostInterfaceProtocol Number`,
then print the `ProtocolType` with the prefix #x(0 based index),
and finally dump `ProtocolTypeData` as hex.
Signed-off-by: Yang Gang <yanggang@byosoft.com.cn>
Changes include:
* Added missing \r\n line endings inside string literals
* Fixed inconsistent indentation in multi-line string entries
* Removed duplicated #language en-US directive
* Aligned string formatting to match the UNI specification
Updated files:
ShellPkg/DynamicCommand/HttpDynamicCommand/Http.uni
ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.uni
The issues were identified during testing of the parser
https://github.com/xpahos/edk2-idea.
Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
The Uni file standard specifies that comments begin with the
characters "//". The following files contained incorrectly
formatted C-style comments and have been updated:
ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.uni
The problems were identified during testing of the parser
https://github.com/xpahos/edk2-idea.
Signed-off-by: Alexander Gryanko <xpahos@gmail.com>
The type field for Smbios tables in smbiosview is set from values in
this query table. An entry is added to correctly display the Type 45
table name rather than "Undefined Value" in smbiosview output.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
Replace traditional `#ifndef`/`#define`/`#endif` include guards with
`#pragma` once.
`#pragma once` is a widely supported preprocessor directive that
prevents header files from being included multiple times. It is
supported by all toolchains used to build edk2: GCC, Clang/LLVM, and
MSVC.
Compared to macro-based include guards, `#pragma once`:
- Eliminates the risk of macro name collisions or copy/paste errors
where two headers inadvertently use the same guard macro.
- Eliminate inconsistency in the way include guard macros are named
(e.g., some files use `__FILE_H__`, others use `FILE_H_`, etc.).
- Reduces boilerplate (three lines replaced by one).
- Avoids polluting the macro namespace with guard symbols.
- Can improve build times as the preprocessor can skip re-opening the
file entirely, rather than re-reading it to find the matching
`#endif` ("multiple-include optimization").
- Note that some compilers may already optimize traditional include
guards, by recognzining the idiomatic pattern.
This change is made acknowledging that overall portability of the
code will technically be reduced, as `#pragma once` is not part of the
C/C++ standards.
However, this is considered acceptable given:
1. edk2 already defines a subset of supported compilers in
BaseTools/Conf/tools_def.template, all of which have supported
`#pragma once` for over two decades.
2. There have been concerns raised to the project about inconsistent
include guard naming and potential macro collisions.
Approximate compiler support dates:
- MSVC: Supported since Visual C++ 4.2 (1996)
- GCC: Supported since 3.4 (2004)
(http://gnu.ist.utl.pt/software/gcc/gcc-3.4/changes.html)
- Clang (LLVM based): Since initial release in 2007
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Add a new parser for the Firmware Performance Data Table (FPDT),
as per the ACPI6.5 specification.
Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@amd.com>
Clang complains about unused variables:
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rimt/RimtParser.c:21:60: error: variable 'mRimtNodeHeader' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
21 | STATIC EFI_ACPI_6_6_RIMT_NODE_HEADER_STRUCTURE mRimtNodeHeader;
| ^~~~~~~~~~~~~~~
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rimt/RimtParser.c:25:60: error: variable 'mRimtIdMappingNode' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
25 | STATIC EFI_ACPI_6_6_RIMT_ID_MAPPING_STRUCTURE mRimtIdMappingNode;
| ^~~~~~~~~~~~~~~~~~
28 | STATIC EFI_ACPI_6_6_RIMT_PCIE_ROOT_COMPLEX_NODE_STRUCTURE mRimtPcieRootComplexNode;
| ^~~~~~~~~~~~~~~~~~~~~~~~
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rimt/RimtParser.c:29:60: error: variable 'mRimtIommuNode' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration]
29 | STATIC EFI_ACPI_6_6_RIMT_IOMMU_NODE_STRUCTURE mRimtIommuNode;
| ^~~~~~~~~~~~~~
4 errors generated.
This is because these variables are only used to take the size of their
fields using the sizeof() operator, which does not support type names
directly.
So create a helper macro SIZE_OF_T () that provides the functionality we
need, and drop the unused variables.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Fix CodeQL cpp/redundant-null-check-simple warning in
ShellPkg/Library/UefiShellLevel1CommandsLib/For.c at line 571 by
removing redundant null and empty-string checks on ArgSetWalker. The
outer guard at line 570 ensures that ArgSetWalker is non-NULL and
non-empty, so the inner condition only needs
ShellIsValidForNumber(ArgSetWalker).
Signed-off-by: Mingjie Shen <shen497@purdue.edu>
- Remove redundant null check in IsValidMove() per CodeQL
cpp/redundant-null-check-simple. Specifically, drop the
"DestPathWalker != NULL" condition from the trimming loop.
Rationale: "DestPathCopy" is allocated at line 181 and checked for
NULL at lines 182–183; "DestPathWalker" is initialized from
"DestPathCopy" at line 186, so it cannot be NULL.
- Cache length once in IsValidMove() and ValidateAndMoveFiles() so the
trimming loop avoids repeated StrLen() calls.
- Guard the zero-length case before indexing the last character to
prevent out-of-bounds access.
Signed-off-by: Mingjie Shen <shen497@purdue.edu>