Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OvmfPkg/BaseMemEncryptTdxLib: fix variable uninitialized error #10573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

t0rr3sp3dr0
Copy link

Description

While compiling the project, I was getting the error bellow. Whenever Mode wasn't ClearSharedBit, the Status variable was uninitialized but being used by the DEBUG call. This patch initializes Status with EFI_SUCCESS to address the problem.

./OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c:592:7: error: variable 'Status' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
  if (Mode == ClearSharedBit) {
      ^~~~~~~~~~~~~~~~~~~~~~
./OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c:616:5: note: uninitialized use occurs here
    Status
    ^~~~~~
./MdePkg/Include/Library/DebugLib.h:425:24: note: expanded from macro 'DEBUG'
      _DEBUGLIB_DEBUG (Expression);       \
                       ^~~~~~~~~~
./MdePkg/Include/Library/DebugLib.h:378:49: note: expanded from macro '_DEBUGLIB_DEBUG'
#define _DEBUGLIB_DEBUG(Expression)  DebugPrint Expression
                                                ^~~~~~~~~~
./OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c:592:3: note: remove the 'if' if its condition is always true
  if (Mode == ClearSharedBit) {
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
./OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c:529:39: note: initialize the variable 'Status' to silence this warning
  EFI_STATUS                    Status;
                                      ^
                                       = 0
  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Compiled the project again.

Integration Instructions

N/A

@t0rr3sp3dr0
Copy link
Author

I think this was never caught before because the project needs to be compiled with DEBUG_VERBOSE for the error to show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants