From: "Rebecca Cran" <rebecca@bsdio.com>
To: devel@edk2.groups.io, Liming Gao <gaoliming@byosoft.com.cn>,
Michael D Kinney <michael.d.kinney@intel.com>,
Guomin Jiang <guomin.jiang@intel.com>,
Wei6 Xu <wei6.xu@intel.com>, Guo Dong <guo.dong@intel.com>,
Ray Ni <ray.ni@intel.com>, Sean Rhodes <sean@starlabs.systems>,
James Lu <james.lu@intel.com>, Gua Guo <gua.guo@intel.com>,
Andrew Fish <afish@apple.com>, Hao A Wu <hao.a.wu@intel.com>,
Maciej Rabeda <maciej.rabeda@linux.intel.com>,
Siyuan Fu <siyuan.fu@intel.com>,
Jiewen Yao <jiewen.yao@intel.com>,
Jian J Wang <jian.j.wang@intel.com>,
Xiaoyu Lu <xiaoyu1.lu@intel.com>,
Ard Biesheuvel <ardb+tianocore@kernel.org>,
Sami Mujawar <sami.mujawar@arm.com>,
Supreeth Venkatesh <supreeth.venkatesh@arm.com>,
Michael Kubacki <mikuback@linux.microsoft.com>,
Nate DeSimone <nathaniel.l.desimone@intel.com>,
Sean Brogan <sean.brogan@microsoft.com>
Cc: Rebecca Cran <rebecca@bsdio.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Abner Chang <abner.chang@amd.com>,
Nickle Wang <nicklew@nvidia.com>,
Igor Kulchytskyy <igork@ami.com>,
Daniel Schaefer <git@danielschaefer.me>,
Min Xu <min.m.xu@intel.com>,
Jordan Justen <jordan.l.justen@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Peter Grehan <grehan@freebsd.org>,
Erdem Aktas <erdemaktas@google.com>,
James Bottomley <jejb@linux.ibm.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
Michael Roth <michael.roth@amd.com>,
Sunil V L <sunilvl@ventanamicro.com>,
Andrei Warkentin <andrei.warkentin@intel.com>
Subject: [PATCH 10/18] UnitTestFrameworkPkg: Update to be more C11 compliant by using __func__
Date: Thu, 6 Apr 2023 16:23:11 -0600 [thread overview]
Message-ID: <20230406222319.2281263-11-rebecca@bsdio.com> (raw)
In-Reply-To: <20230406222319.2281263-1-rebecca@bsdio.com>
__FUNCTION__ is a pre-standard extension that gcc and Visual C++ among
others support, while __func__ was standardized in C99.
Since it's more standard, replace __FUNCTION__ with __func__ throughout
UnitTestFrameworkPkg.
Visual Studio versions before VS 2015 don't support __func__ and so
will fail to compile. A workaround is to define __func__ as
__FUNCTION__ :
#define __func__ __FUNCTION__
Signed-off-by: Rebecca Cran <rebecca@bsdio.com>
---
UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/UnitTestBootLibUsbClass.c | 12 ++++-----
UnitTestFrameworkPkg/Library/UnitTestLib/Log.c | 2 +-
UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c | 4 +--
UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.c | 26 ++++++++++----------
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLib.c | 2 +-
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c | 2 +-
UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c | 2 +-
7 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/UnitTestBootLibUsbClass.c b/UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/UnitTestBootLibUsbClass.c
index ebb42186a534..b9b2d23eb14d 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/UnitTestBootLibUsbClass.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestBootLibUsbClass/UnitTestBootLibUsbClass.c
@@ -61,7 +61,7 @@ SetBootNextDevice (
DpEnd = AppendDevicePathNode (NULL, NULL);
if (DpEnd == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. DpEnd is NULL.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. DpEnd is NULL.\n", __func__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
@@ -72,7 +72,7 @@ SetBootNextDevice (
(EFI_DEVICE_PATH_PROTOCOL *)&UsbDp
);
if (Dp == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. Dp is NULL.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a: Unable to create device path. Dp is NULL.\n", __func__));
Status = EFI_OUT_OF_RESOURCES;
goto CLEANUP;
}
@@ -88,15 +88,15 @@ SetBootNextDevice (
OptionalDataSize
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Error creating load option. Status = %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a: Error creating load option. Status = %r\n", __func__, Status));
goto CLEANUP;
}
NewOptionValid = TRUE;
- DEBUG ((DEBUG_VERBOSE, "%a: Generic USB Class Device boot option created.\n", __FUNCTION__));
+ DEBUG ((DEBUG_VERBOSE, "%a: Generic USB Class Device boot option created.\n", __func__));
Status = EfiBootManagerLoadOptionToVariable (&NewOption);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: Error Saving boot option NV variable. Status = %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a: Error Saving boot option NV variable. Status = %r\n", __func__, Status));
goto CLEANUP;
}
@@ -111,7 +111,7 @@ SetBootNextDevice (
&(BootNextValue)
);
- DEBUG ((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_VERBOSE, "%a - Set BootNext Status (%r)\n", __func__, Status));
CLEANUP:
if (Dp != NULL) {
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c b/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c
index 3998aafdf843..19eb8ee0db6e 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/Log.c
@@ -118,7 +118,7 @@ UnitTestLogInit (
// Make sure that you're cooking with gas.
//
if (Test == NULL) {
- DEBUG ((DEBUG_ERROR, "%a called with invalid Test parameter\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a called with invalid Test parameter\n", __func__));
return;
}
diff --git a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
index 5b442ed122ea..322ea15b1575 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestLib/UnitTestLib.c
@@ -274,7 +274,7 @@ InitUnitTestFramework (
//
// Don't actually report it as an error, but emit a warning.
//
- DEBUG ((DEBUG_ERROR, "%a - Cache was detected, but failed to load.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a - Cache was detected, but failed to load.\n", __func__));
Status = EFI_SUCCESS;
}
}
@@ -856,7 +856,7 @@ SaveFrameworkState (
//
Status = SaveUnitTestCache (FrameworkHandle, Header, Header->SaveStateSize);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a - Could not save state! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Could not save state! %r\n", __func__, Status));
Status = EFI_DEVICE_ERROR;
}
diff --git a/UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.c b/UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.c
index d7a62145dac6..b59991683f48 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestPersistenceLibSimpleFileSystem/UnitTestPersistenceLibSimpleFileSystem.c
@@ -61,7 +61,7 @@ GetCacheFileDevicePath (
(VOID **)&LoadedImage
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "%a - Failed to locate DevicePath for loaded image. %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_WARN, "%a - Failed to locate DevicePath for loaded image. %r\n", __func__, Status));
return NULL;
}
@@ -91,7 +91,7 @@ GetCacheFileDevicePath (
// Make sure we didn't get any weird data.
//
if (DirectorySlashOffset == 0) {
- DEBUG ((DEBUG_ERROR, "%a - Weird 0-length string when processing app path.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a - Weird 0-length string when processing app path.\n", __func__));
goto Exit;
}
@@ -112,7 +112,7 @@ GetCacheFileDevicePath (
// Let's check and make sure that's right.
//
if (AppPath[DirectorySlashOffset] != L'\\') {
- DEBUG ((DEBUG_ERROR, "%a - Could not find a single directory separator in app path.\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a - Could not find a single directory separator in app path.\n", __func__));
goto Exit;
}
@@ -202,7 +202,7 @@ DoesCacheExist (
FreePool (FileDevicePath);
}
- DEBUG ((DEBUG_VERBOSE, "%a - Returning %d\n", __FUNCTION__, !EFI_ERROR (Status)));
+ DEBUG ((DEBUG_VERBOSE, "%a - Returning %d\n", __func__, !EFI_ERROR (Status)));
return (!EFI_ERROR (Status));
}
@@ -263,7 +263,7 @@ SaveUnitTestCache (
//
Status = ShellDeleteFile (&FileHandle);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a failed to delete file %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a failed to delete file %r\n", __func__, Status));
}
}
@@ -277,7 +277,7 @@ SaveUnitTestCache (
0
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __func__, Status));
goto Exit;
}
@@ -285,7 +285,7 @@ SaveUnitTestCache (
// Write the data to the file.
//
WriteCount = SaveStateSize;
- DEBUG ((DEBUG_INFO, "%a - Writing %d bytes to file...\n", __FUNCTION__, WriteCount));
+ DEBUG ((DEBUG_INFO, "%a - Writing %d bytes to file...\n", __func__, WriteCount));
Status = ShellWriteFile (
FileHandle,
&WriteCount,
@@ -293,9 +293,9 @@ SaveUnitTestCache (
);
if (EFI_ERROR (Status) || (WriteCount != SaveStateSize)) {
- DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Writing to file failed! %r\n", __func__, Status));
} else {
- DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __FUNCTION__));
+ DEBUG ((DEBUG_INFO, "%a - SUCCESS!\n", __func__));
}
//
@@ -368,7 +368,7 @@ LoadUnitTestCache (
0
);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Opening file for writing failed! %r\n", __func__, Status));
goto Exit;
} else {
IsFileOpened = TRUE;
@@ -379,7 +379,7 @@ LoadUnitTestCache (
//
Status = ShellGetFileSize (FileHandle, &LargeFileSize);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a - Failed to determine file size! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Failed to determine file size! %r\n", __func__, Status));
goto Exit;
}
@@ -390,7 +390,7 @@ LoadUnitTestCache (
*SaveStateSize = FileSize;
Buffer = AllocatePool (FileSize);
if (Buffer == NULL) {
- DEBUG ((DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Failed to allocate a pool to hold the file contents! %r\n", __func__, Status));
Status = EFI_OUT_OF_RESOURCES;
goto Exit;
}
@@ -400,7 +400,7 @@ LoadUnitTestCache (
//
Status = ShellReadFile (FileHandle, &FileSize, Buffer);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a - Failed to read the file contents! %r\n", __FUNCTION__, Status));
+ DEBUG ((DEBUG_ERROR, "%a - Failed to read the file contents! %r\n", __func__, Status));
}
Exit:
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLib.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLib.c
index d088b927a6c2..5e2973beb3e1 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLib.c
@@ -102,7 +102,7 @@ GetStringForFailureType (
//
// Return last entry if no match found.
//
- DEBUG ((DEBUG_INFO, "%a Failure Type does not have string defined 0x%X\n", __FUNCTION__, (UINT32)Failure));
+ DEBUG ((DEBUG_INFO, "%a Failure Type does not have string defined 0x%X\n", __func__, (UINT32)Failure));
return mFailureTypeStrings[Index].String;
}
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
index aba00fe7b962..3bcbf557a168 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibConOut.c
@@ -25,7 +25,7 @@ ReportPrint (
VA_START (Marker, Format);
Length = UnicodeVSPrintAsciiFormat (String, sizeof (String), Format, Marker);
if (Length == 0) {
- DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __func__));
} else {
gST->ConOut->OutputString (gST->ConOut, String);
}
diff --git a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
index ac330861fd40..eb78554f9101 100644
--- a/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
+++ b/UnitTestFrameworkPkg/Library/UnitTestResultReportLib/UnitTestResultReportLibDebugLib.c
@@ -24,7 +24,7 @@ ReportPrint (
VA_START (Marker, Format);
Length = AsciiVSPrint (String, sizeof (String), Format, Marker);
if (Length == 0) {
- DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __FUNCTION__));
+ DEBUG ((DEBUG_ERROR, "%a formatted string is too long\n", __func__));
} else {
DEBUG ((DEBUG_INFO, String));
}
--
2.34.1
next prev parent reply other threads:[~2023-04-06 22:24 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 22:23 [PATCH 00/18] Replace pre-standard macro __FUNCTION__ with C99 __func__ throughout edk2 Rebecca Cran
2023-04-06 22:23 ` [PATCH 01/18] ArmPkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
2023-04-07 20:18 ` [edk2-devel] " Michael D Kinney
2023-04-06 22:23 ` [PATCH 02/18] ArmVirtPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 03/18] UefiCpuPkg: " Rebecca Cran
2023-04-07 3:09 ` Ni, Ray
2023-04-07 11:24 ` Sunil V L
2023-04-06 22:23 ` [PATCH 04/18] OvmfPkg: " Rebecca Cran
2023-04-07 11:19 ` Sunil V L
2023-04-06 22:23 ` [PATCH 05/18] MdeModulePkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 06/18] SecurityPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 07/18] EmbeddedPkg: " Rebecca Cran
2023-04-07 8:25 ` Chang, Abner
2023-04-06 22:23 ` [PATCH 08/18] RedfishPkg: " Rebecca Cran
2023-04-07 5:39 ` Nickle Wang
2023-04-06 22:23 ` [PATCH 09/18] ArmPlatformPkg: " Rebecca Cran
2023-04-06 22:23 ` Rebecca Cran [this message]
2023-04-06 22:23 ` [PATCH 11/18] PrmPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 12/18] StandaloneMmPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 13/18] CryptoPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 14/18] NetworkPkg: " Rebecca Cran
2023-04-06 22:23 ` [PATCH 15/18] SourceLevelDebugPkg: " Rebecca Cran
2023-04-07 3:08 ` Ni, Ray
2023-04-06 22:23 ` [PATCH 16/18] EmulatorPkg: " Rebecca Cran
2023-04-07 3:08 ` Ni, Ray
2023-04-07 8:23 ` Chang, Abner
2023-04-06 22:23 ` [PATCH 17/18] UefiPayloadPkg: " Rebecca Cran
2023-04-07 5:57 ` Guo, Gua
2023-04-07 7:55 ` Lu, James
2023-04-06 22:23 ` [PATCH 18/18] FmpDevicePkg: " Rebecca Cran
2023-04-10 1:05 ` Xu, Wei6
2023-04-07 10:09 ` [edk2-devel] [PATCH 00/18] Replace pre-standard macro __FUNCTION__ with C99 __func__ throughout edk2 Ard Biesheuvel
2023-04-10 14:21 ` Rebecca Cran
2023-04-11 9:15 ` Gerd Hoffmann
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=20230406222319.2281263-11-rebecca@bsdio.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