From: "Kinney, Michael D" <michael.d.kinney@intel.com>
To: edk2-devel@lists.01.org
Cc: Sean Brogan <sean.brogan@microsoft.com>,
Liming Gao <liming.gao@intel.com>,
Michael D Kinney <michael.d.kinney@intel.com>
Subject: [staging/edk2-test Patch 07/10] MsUnitTestPkg/Library: Update __FUNCTION__ usage
Date: Tue, 19 Dec 2017 16:00:11 -0800 [thread overview]
Message-ID: <20171220000014.9140-8-michael.d.kinney@intel.com> (raw)
In-Reply-To: <20171220000014.9140-1-michael.d.kinney@intel.com>
Update all libraries in MsUnitTestPkg to treat __FUNCTION__
as a variable instead of a literal string. This fixes build
error with GCC compilers that require __FUNCTION__ to be used
as a variable:
https://gcc.gnu.org/onlinedocs/gcc-6.4.0/gcc/Function-Names.html
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
---
.../UnitTestBootUsbClassLib/UnitTestBootUsb.c | 12 +++++-----
.../UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c | 10 ++++-----
MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c | 8 +++----
.../Library/UnitTestLogLib/UnitTestLogLib.c | 2 +-
.../UnitTestPersistenceFileSystemLib.c | 26 +++++++++++-----------
.../UnitTestResultReportLib.c | 2 +-
6 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
index 7fe82fb849..5f6b328b7e 100644
--- a/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
+++ b/MsUnitTestPkg/Library/UnitTestBootUsbClassLib/UnitTestBootUsb.c
@@ -66,7 +66,7 @@ SetUsbBootNext(
DpEnd = AppendDevicePathNode(NULL, NULL);
if (DpEnd == NULL)
{
- DEBUG((DEBUG_ERROR, __FUNCTION__ ": Unable to create device path. DpEnd is NULL.\n"));
+ DEBUG((DEBUG_ERROR, "%a: Unable to create device path. DpEnd is NULL.\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
@@ -74,7 +74,7 @@ SetUsbBootNext(
Dp = AppendDevicePathNode(DpEnd, (EFI_DEVICE_PATH_PROTOCOL *)&UsbDp); //@MRT --- Is this memory leak becasue we lose the old Dp memory
if (Dp == NULL)
{
- DEBUG((DEBUG_ERROR, __FUNCTION__ ": Unable to create device path. Dp is NULL.\n"));
+ DEBUG((DEBUG_ERROR, "%a: Unable to create device path. Dp is NULL.\n", __FUNCTION__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
@@ -91,15 +91,15 @@ SetUsbBootNext(
);
if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, __FUNCTION__ ": Error creating load option. Status = %r\n", Status));
+ DEBUG((DEBUG_ERROR, "%a: Error creating load option. Status = %r\n", __FUNCTION__, Status));
goto CLEANUP;
}
NewOptionValid = TRUE;
- DEBUG((DEBUG_VERBOSE, __FUNCTION__ ": Generic USB Class Device boot option created.\n"));
+ DEBUG((DEBUG_VERBOSE, "%a: Generic USB Class Device boot option created.\n", __FUNCTION__));
Status = EfiBootManagerLoadOptionToVariable(&NewOption);
if (EFI_ERROR(Status)) {
- DEBUG((DEBUG_ERROR, __FUNCTION__ ": Error Saving boot option NV variable. Status = %r\n", Status));
+ DEBUG((DEBUG_ERROR, "%a: Error Saving boot option NV variable. Status = %r\n", __FUNCTION__, Status));
goto CLEANUP;
}
@@ -110,7 +110,7 @@ SetUsbBootNext(
sizeof(BootNextValue),
&(BootNextValue));
- DEBUG((DEBUG_VERBOSE, __FUNCTION__" - Set BootNext Status (%r)\n", Status));
+ DEBUG((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status));
CLEANUP:
if (Dp != NULL)
diff --git a/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c b/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
index 677d3edb0a..059c031bf9 100644
--- a/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
+++ b/MsUnitTestPkg/Library/UnitTestBootUsbMicrosoftLib/UnitTestBootUsb.c
@@ -59,7 +59,7 @@ SetUsbBootNext (
UnicodeValueToStringS(BootOptionIndexChar, sizeof (BootOptionName) / sizeof (BootOptionName[0]) - StrLen(BootOptionName), 0, (INT64)BootOptionIndex, 1);
// Attempt to retrieve the option.
- DEBUG(( DEBUG_VERBOSE, __FUNCTION__" - Checking for %s...\n", BootOptionName ));
+ DEBUG(( DEBUG_VERBOSE, "%a - Checking for %s...\n", __FUNCTION__, BootOptionName ));
VariableSize = OptionBufferSize;
Status = gRT->GetVariable( BootOptionName,
&gEfiGlobalVariableGuid,
@@ -79,7 +79,7 @@ SetUsbBootNext (
// If you fail to... we've gotta get out of here.
if (OptionBuffer == NULL)
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Failed to allocate memory for Boot option variable %s...\n", BootOptionName ));
+ DEBUG(( DEBUG_ERROR, "%a - Failed to allocate memory for Boot option variable %s...\n", __FUNCTION__, BootOptionName ));
return EFI_OUT_OF_RESOURCES;
}
OptionBufferSize = VariableSize;
@@ -95,7 +95,7 @@ SetUsbBootNext (
// If we failed to retrieve this option... move on with your life.
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_VERBOSE, __FUNCTION__" - Failed to locate option (%r). Moving on.\n", Status ));
+ DEBUG(( DEBUG_VERBOSE, "%a - Failed to locate option (%r). Moving on.\n", __FUNCTION__, Status ));
continue;
}
@@ -121,11 +121,11 @@ SetUsbBootNext (
(EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE),
sizeof( BootOptionIndex ),
&BootOptionIndex );
- DEBUG(( DEBUG_VERBOSE, __FUNCTION__" - Set BootNext Status (%r)\n", Status ));
+ DEBUG(( DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status ));
}
else
{
- DEBUG(( DEBUG_WARN, __FUNCTION__" - Could not find generic USB boot option.\n" ));
+ DEBUG(( DEBUG_WARN, "%a - Could not find generic USB boot option.\n", __FUNCTION__));
Status = EFI_NOT_FOUND;
}
diff --git a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
index b94e916a87..c181eae5e4 100644
--- a/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/MsUnitTestPkg/Library/UnitTestLib/UnitTestLib.c
@@ -282,7 +282,7 @@ InitUnitTestFramework (
if (EFI_ERROR( Status ))
{
// Don't actually report it as an error, but emit a warning.
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Cache was detected, but failed to load.\n" ));
+ DEBUG(( DEBUG_ERROR, "%a - Cache was detected, but failed to load.\n", __FUNCTION__));
Status = EFI_SUCCESS;
}
}
@@ -864,7 +864,7 @@ SaveFrameworkState (
Status = SaveUnitTestCache( FrameworkHandle, Header );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Could not save state! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Could not save state! %r\n", __FUNCTION__, Status ));
Status = EFI_DEVICE_ERROR;
}
@@ -908,7 +908,7 @@ SaveFrameworkStateAndQuit (
//
// Quit
gBS->Exit( gImageHandle, EFI_SUCCESS, 0, NULL );
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Unit test failed to quit! Framework can no longer be used!\n" ));
+ DEBUG(( DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__ ));
//
// We REALLY shouldn't be here.
@@ -966,7 +966,7 @@ SaveFrameworkStateAndReboot (
//
// Reset
gRT->ResetSystem( ResetType, EFI_SUCCESS, 0, NULL );
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Unit test failed to quit! Framework can no longer be used!\n" ));
+ DEBUG(( DEBUG_ERROR, "%a - Unit test failed to quit! Framework can no longer be used!\n", __FUNCTION__));
//
// We REALLY shouldn't be here.
diff --git a/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c b/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
index 19cdac152b..d5146fcacb 100644
--- a/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
+++ b/MsUnitTestPkg/Library/UnitTestLogLib/UnitTestLogLib.c
@@ -169,7 +169,7 @@ IN UINTN BufferSize
//
if (Test == NULL)
{
- DEBUG((DEBUG_ERROR, __FUNCTION__ " called with invalid Test parameter\n"));
+ DEBUG((DEBUG_ERROR, "%a called with invalid Test parameter\n", __FUNCTION__));
return;
}
diff --git a/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c b/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
index 3c77f0afa0..c137a1b738 100644
--- a/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
+++ b/MsUnitTestPkg/Library/UnitTestPersistenceFileSystemLib/UnitTestPersistenceFileSystemLib.c
@@ -70,7 +70,7 @@ GetCacheFileDevicePath (
(VOID**)&LoadedImage );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_WARN, __FUNCTION__" - Failed to locate DevicePath for loaded image. %r\n", Status ));
+ DEBUG(( DEBUG_WARN, "%a - Failed to locate DevicePath for loaded image. %r\n", __FUNCTION__, Status ));
return NULL;
}
@@ -87,7 +87,7 @@ GetCacheFileDevicePath (
// Make sure we didn't get any weird data.
if (DirectorySlashOffset == 0)
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Weird 0-length string when processing app path.\n" ));
+ DEBUG(( DEBUG_ERROR, "%a - Weird 0-length string when processing app path.\n", __FUNCTION__ ));
goto Exit;
}
// Now that we know we have a decent string, let's take a deeper look.
@@ -107,7 +107,7 @@ GetCacheFileDevicePath (
//
if (AppPath[DirectorySlashOffset] != L'\\')
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Could not find a single directory separator in app path.\n" ));
+ DEBUG(( DEBUG_ERROR, "%a - Could not find a single directory separator in app path.\n", __FUNCTION__ ));
goto Exit;
}
@@ -189,7 +189,7 @@ DoesCacheExist (
FreePool( FileDevicePath );
}
- DEBUG(( DEBUG_VERBOSE, __FUNCTION__" - Returning %d\n", !EFI_ERROR( Status ) ));
+ DEBUG(( DEBUG_VERBOSE, "%a - Returning %d\n", __FUNCTION__, !EFI_ERROR( Status ) ));
return !EFI_ERROR( Status );
} // DoesCacheExist()
@@ -248,7 +248,7 @@ SaveUnitTestCache (
Status = ShellDeleteFile(&FileHandle);
if (EFI_ERROR(Status))
{
- DEBUG((DEBUG_ERROR, __FUNCTION__ " failed to delete file %r\n", Status));
+ DEBUG((DEBUG_ERROR, "%a failed to delete file %r\n", __FUNCTION__, Status));
}
}
@@ -262,7 +262,7 @@ SaveUnitTestCache (
0 );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Opening file for writing failed! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status ));
goto Exit;
}
@@ -270,18 +270,18 @@ SaveUnitTestCache (
// Write the data to the file.
//
WriteCount = SaveData->BlobSize;
- DEBUG(( DEBUG_INFO, __FUNCTION__" - Writing %d bytes to file...\n", WriteCount ));
+ DEBUG(( DEBUG_INFO, "%a - Writing %d bytes to file...\n", __FUNCTION__, WriteCount ));
Status = ShellWriteFile( FileHandle,
&WriteCount,
SaveData );
if (EFI_ERROR( Status ) || WriteCount != SaveData->BlobSize)
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Writing to file failed! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status ));
}
else
{
- DEBUG(( DEBUG_INFO, __FUNCTION__" - SUCCESS!\n" ));
+ DEBUG(( DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
}
//
@@ -351,7 +351,7 @@ LoadUnitTestCache (
0 );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Opening file for writing failed! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status ));
goto Exit;
}
else
@@ -364,7 +364,7 @@ LoadUnitTestCache (
Status = ShellGetFileSize( FileHandle, &LargeFileSize );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Failed to determine file size! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Failed to determine file size! %r\n", __FUNCTION__, Status ));
goto Exit;
}
@@ -374,7 +374,7 @@ LoadUnitTestCache (
Buffer = AllocatePool( FileSize );
if (Buffer == NULL)
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Failed to allocate a pool to hold the file contents! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __FUNCTION__, Status ));
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
@@ -384,7 +384,7 @@ LoadUnitTestCache (
Status = ShellReadFile( FileHandle, &FileSize, Buffer );
if (EFI_ERROR( Status ))
{
- DEBUG(( DEBUG_ERROR, __FUNCTION__" - Failed to read the file contents! %r\n", Status ));
+ DEBUG(( DEBUG_ERROR, "%a - Failed to read the file contents! %r\n", __FUNCTION__, Status ));
}
Exit:
diff --git a/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c b/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
index 91a9d7b436..9c243a34e3 100644
--- a/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
+++ b/MsUnitTestPkg/Library/UnitTestResultReportPlainTextOutputLib/UnitTestResultReportLib.c
@@ -121,7 +121,7 @@ GetStringForFailureType(
}
if (Result == mUnknownFailureType)
{
- DEBUG((DEBUG_INFO, __FUNCTION__ " Failure Type does not have string defined 0x%X\n", (UINT32)Failure));
+ DEBUG((DEBUG_INFO, "%a Failure Type does not have string defined 0x%X\n", __FUNCTION__ , (UINT32)Failure));
}
return Result;
--
2.14.2.windows.3
next prev parent reply other threads:[~2017-12-19 23:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-20 0:00 [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support and sample Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 01/10] " Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 02/10] MsUnitTestPkg: Update copyright and license info Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 03/10] MsUnitTestPkg: Update for VS2017 and 32-bit apps Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 04/10] MsUnitTestPkg/Include: Remove use of variadic macros Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 05/10] MsUnitTestPkg/Library: Use safe string functions Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 06/10] MsUnitTestPkg/UnitTestLib: Fix GCC build errors Kinney, Michael D
2017-12-20 0:00 ` Kinney, Michael D [this message]
2017-12-20 0:00 ` [staging/edk2-test Patch 08/10] MsUnitTestPkg: Add missing library classes Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 09/10] MsUnitTestPkg: Add missing DSC file Kinney, Michael D
2017-12-20 0:00 ` [staging/edk2-test Patch 10/10] MsUnitTestPkg: Fix EDK II style issues Kinney, Michael D
2018-01-18 8:10 ` [staging/edk2-test Patch 00/10] MsUnitTestPkg: Add Unit Test Support and sample Sean Brogan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171220000014.9140-8-michael.d.kinney@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox