Fix codeql reported issues by flattening MainCmdEfiDecompress(),
making it easier for the tool to evaluate potential risks.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Refactor the Comp command and extract 2 functions:
- OpenFileOperand()
- CompareFiles()
This allows to simplify the logic of MainCmdComp() and
fix some codeql reported potential errors.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Check the return value of LocateProtocol() before
using the decompression protocol. This avoids a
potential NULL pointer derefence spotted by codeql.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract file opening and compression code into helpers.
Upon calling:
- gEfiShellProtocol->GetFileSize()
- gEfiShellProtocol->ReadFile()
the returned Status is now checked.
Upon calling AllocateZeroPool, the failed status is now set to
EFI_OUT_OF_RESOURCES.
Other than that, no functional change.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long functions present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c
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 functions present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c
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 functions present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- LoadPciRom.c
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 functions present in
the ShellPkg and reduce complexity/nested code and conditions.
Lower the indentation level in the newly created MainCmdXXX()
functions.
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c
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 functions 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
For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c
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 functions 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
For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c
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 functions 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
For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- HexEdit/HexEdit.c
- LoadPciRom.c
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 functions 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
For the MemMap and SetVar commands, ShellCommandLineFreeVarList()
calls are removed as the Package is now freed in the caller
function: ShellCommandRunXXX().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
If ShellCommandLineParse() fails, there is no need to free:
- InputStr
- Package
Remove the goto statement.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Package is sometimes initialized to NULL and only
freed if not NULL. Remove these as:
- Package is initialized in ShellCommandLineParse().
- If ShellCommandLineFreeVarList() is reached,
Package cannot be NULL.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This patch aims to help breaking down the long functions 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().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- SerMode.c
- SetSize.c
- SetVar.c
- SmbiosView/SmbiosView.c
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 functions 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().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- MemMap.c
- Mm.c
- Mode.c
- Pci.c
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 functions 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().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Edit/Edit.c
- EfiCompress.c
- EfiDecompress.c
- HexEdit/HexEdit.c
- LoadPciRom.c
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 functions 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().
To avoid having one large commit updating all the UefiShellDebug1
commands, only update these files:
- Comp.c
- Cxl.c
- Dblk.c
- Dmem.c
- DmpStore.c
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Package is always freed in ShellCommandRunLs().
Remove calls to ShellCommandLineFreeVarList() in MainCmdLs().
This double-free was introduced in:
commit 531b0aa002 ("ShellPkg/UefiShellLevel2:
Extract MainCmdXXX() function")
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
The commented out code snippet seems to try to create a new file
with the user input filename. FileBufferRead() seems to have replaced
this code snippet in a better wrapper:
- if the file exists, open it
- otherwise, create the file
Remove the commented-out code snippet.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
The ACPI 6.5 specification introduces the CCEL (CC Event Log) table
in section 5.2.34:
https://uefi.org/specs/ACPI/6.5/
05_ACPI_Software_Programming_Model.html#cc-event-log-acpi-table
Extend AcpiView with a parser to decode and display CCEL table
contents. This allows users to inspect CCEL tables from the UEFI
Shell.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Move the reserved-field validators from MpamParser.c into AcpiParser.c
and expose them through AcpiParser.h so they can be reused by multiple
Acpiview parsers.
Update the AGDI, MPAM and WSMT parsers to use the common helpers for
byte-length and bit-length reserved fields.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
The RegisterParser() function is failing with error code
EFI_OUT_OF_RESOURCES as we have run out of space for
registering the ACPI table parsers in mTableParserList[].
Therefore, increase the MAX_ACPI_TABLE_PARSERS to 128.
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Add the missing SMBIOS Type 28 Temperature Probe location decode values
to smbiosview.
The Type 28 Location field defines values 0x0C through 0x0F for Front
Panel Board, Back Panel Board, Power System Board, and Drive Back Plane,
but smbiosview only decoded values up to 0x0B.
Signed-off-by: VarshitPandya <varshit.pandya@arm.com>
The smbiosview Type 26 Voltage Probe decoder uses the low 5 bits of
LocationAndStatus as the probe location and the high 3 bits as the probe
status.
However, the Type 26 lookup tables were swapped: VPLocationTable contained
status strings and VPStatusTable contained location strings. This caused
valid records to be displayed as, for example:
Voltage Probe - Location: OK
Voltage Probe - Status: Processor
Swap the table contents so Type 26 output matches the SMBIOS
LocationAndStatus bit layout.
Signed-off-by: VarshitPandya <varshit.pandya@arm.com>
In AllocateMemory(), several pointers are used without prior null
checks. This may lead to unexpected behavior or system crashes if any
of these pointers are NULL.
Add explicit null checks for these pointers to ensure safe access and
prevent potential null pointer dereferences.
Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
Use a Temperature Probe specific HII string when displaying the Type 28
Location field in smbiosview.
The Type 28 decoder was using the Voltage Probe location label, causing
temperature probe records to be displayed with the wrong field name.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
Decode the Type 26 Voltage Probe Location and Status fields according
to the SMBIOS 3.9.0 specification, section 7.27, "Voltage Probe
(Type 26)".
Table 95, "Voltage Probe: Location and Status fields", defines bits
4:0 as the Location field and bits 7:5 as the Status field. smbiosview
was decoding these fields in the opposite order, causing the displayed
voltage probe location and status to be swapped.
Signed-off-by: Varshit Pandya <varshit.pandya@arm.com>
Fixes https://github.com/tianocore/edk2/issues/12689
When the UEFI Shell mapping table is empty (NULL), the console layout
becomes corrupted in DEBUG builds. This occurs because the cursor position
for the message map: No mapping found. is computed incorrectly under DEBUG
mode. The presence of DEBUG output from the Shell driver causes
gST->ConOut->Mode->CursorRow to no longer reflect the actual cursor position
on the serial port, leading to misplacement of subsequent output.
This patch replaces the existing print routine with ShellPrintHiiDefaultEx().
The new function automatically calculates the correct cursor position for the
"No mapping found" line, eliminating the dependency on the stale CursorRow
value. As a result, the layout remains consistent regardless of DEBUG message
activity.
Signed-off-by: Qihang Gao <gaoqihang@loongson.cn>
ACPI defines Injection Header Size as the length of the EINJ
injection header, not necessarily the absolute offset of the
instruction entries. Update parser validation to use the correct
entry offset calculation and accept the layout used by Linux and
existing firmware tables.
Signed-off-by: Simon Wang <simowang@nvidia.com>
Fix spelling errors in definitions in Pci22.h.
Update consumers in MdeModulePkg, OvmfPkg, ShellPkg,
and SourceLevelDebugPkg.
Continuous-integration-options: PatchCheck.ignore-multi-package
Signed-off-by: Oliver Smith-Denny <osde@microsoft.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.
Some ASSERT() are removed in Help.c as they check variables
which were initialized a few lines above.
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Extract a PrintMatchingHelp() function in the Help command
to help splitting the logic MainCmdHelp() function.
No functional change should be induced by this patch.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
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>