public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
@ 2023-02-09 15:45 Rebecca Cran
  2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-02-09 15:45 UTC (permalink / raw)
  To: devel, Michael D Kinney, Liming Gao, Zhiguang Liu; +Cc: Rebecca Cran

With the introduction of the use of _Static_assert, edk2 requires a C11
compatible compiler. Update Include/Base.h to be compliant with C11.

As of C11, the maximum type of an enum is type `int`. Since the UEFI
Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
the 32-bit enum check to use a signed int.

Since the UEFI 2.3 Specification only allowed signed int, update the
comment to reference 2.3.1 Errata C where the change was made to allow
unsigned int.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
---
 MdePkg/Include/Base.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
index d209e6de280a..e89c84962ab2 100644
--- a/MdePkg/Include/Base.h
+++ b/MdePkg/Include/Base.h
@@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specif
 //
 // The following three enum types are used to verify that the compiler
 // configuration for enum types is compliant with Section 2.3.1 of the
-// UEFI 2.3 Specification. These enum types and enum values are not
-// intended to be used. A prefix of '__' is used avoid conflicts with
-// other types.
+// UEFI 2.3.1 Errata C Specification. These enum types and enum values
+// are not intended to be used. A prefix of '__' is used avoid
+// conflicts with other types.
 //
 typedef enum {
   __VerifyUint8EnumValue = 0xff
@@ -809,12 +809,12 @@ typedef enum {
 } __VERIFY_UINT16_ENUM_SIZE;
 
 typedef enum {
-  __VerifyUint32EnumValue = 0xffffffff
-} __VERIFY_UINT32_ENUM_SIZE;
+  __VerifyInt32EnumValue = 0x7fffffff
+} __VERIFY_INT32_ENUM_SIZE;
 
 STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
-STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
+STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
 
 /**
   Macro that returns a pointer to the data structure that contains a specified field of
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-09 15:45 [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Rebecca Cran
@ 2023-02-09 15:45 ` Rebecca Cran
  2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
  2023-03-17  4:23   ` Sunil V L
  2023-02-10  1:03 ` [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Michael D Kinney
  2023-03-06 16:39 ` Rebecca Cran
  2 siblings, 2 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-02-09 15:45 UTC (permalink / raw)
  To: devel, Michael D Kinney, Liming Gao, Zhiguang Liu; +Cc: Rebecca Cran

__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
MdePkg.

Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
---
 MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
 MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++---------
 MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
 MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
 MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
 MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
 MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
 7 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
index 34ec956b9c0e..d0f2dfb070d5 100644
--- a/MdePkg/Include/Library/PerformanceLib.h
+++ b/MdePkg/Include/Library/PerformanceLib.h
@@ -526,7 +526,7 @@ LogPerformanceMeasurement (
 #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
     } \
   } while (FALSE)
 
@@ -542,7 +542,7 @@ LogPerformanceMeasurement (
 #define PERF_EVENT_SIGNAL_END(EventGuid) \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
     } \
   } while (FALSE)
 
@@ -558,7 +558,7 @@ LogPerformanceMeasurement (
 #define PERF_CALLBACK_BEGIN(TriggerGuid) \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
     } \
   } while (FALSE)
 
@@ -574,7 +574,7 @@ LogPerformanceMeasurement (
 #define PERF_CALLBACK_END(TriggerGuid) \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
     } \
   } while (FALSE)
 
@@ -589,7 +589,7 @@ LogPerformanceMeasurement (
 #define PERF_FUNCTION_BEGIN() \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
     } \
   } while (FALSE)
 
@@ -604,7 +604,7 @@ LogPerformanceMeasurement (
 #define PERF_FUNCTION_END() \
   do { \
     if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
-      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
     } \
   } while (FALSE)
 
diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
index 71c205b1b143..321a310602d7 100644
--- a/MdePkg/Include/Library/UnitTestLib.h
+++ b/MdePkg/Include/Library/UnitTestLib.h
@@ -348,7 +348,7 @@ SaveFrameworkState (
   @param[in]  Expression  Expression to be evaluated for TRUE.
 **/
 #define UT_ASSERT_TRUE(Expression)                                                                 \
-  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
+  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
   }
 
@@ -360,7 +360,7 @@ SaveFrameworkState (
   @param[in]  Expression  Expression to be evaluated for FALSE.
 **/
 #define UT_ASSERT_FALSE(Expression)                                                                 \
-  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
+  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
   }
 
@@ -373,7 +373,7 @@ SaveFrameworkState (
   @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
 **/
 #define UT_ASSERT_EQUAL(ValueA, ValueB)                                                                           \
-  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
+  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                                           \
   }
 
@@ -387,7 +387,7 @@ SaveFrameworkState (
   @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
 **/
 #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)                                                                                                              \
-  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #BufferA, #BufferB)) { \
+  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__, DEBUG_LINE_NUMBER, __FILE__, #BufferA, #BufferB)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                                                                                            \
   }
 
@@ -400,7 +400,7 @@ SaveFrameworkState (
   @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
 **/
 #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)                                                                                       \
-  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
+  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                                                           \
   }
 
@@ -412,7 +412,7 @@ SaveFrameworkState (
   @param[in]  Status  EFI_STATUS value to check.
 **/
 #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
-  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
+  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
   }
 
@@ -425,7 +425,7 @@ SaveFrameworkState (
   @param[in]  Expected  EFI_STATUS values to compare for equality.
 **/
 #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
-  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
+  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
   }
 
@@ -437,7 +437,7 @@ SaveFrameworkState (
   @param[in]  Pointer  Pointer to be checked against NULL.
 **/
 #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
-  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
+  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
     return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
   }
 
@@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
       }                                                                \
       if (!UnitTestExpectAssertFailure (                               \
              UnitTestJumpStatus,                                       \
-             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
+             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
              #FunctionCall, Status)) {                                 \
         return UNIT_TEST_ERROR_TEST_FAILED;                            \
       }                                                                \
diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
index 4c8773278c3c..617b0f4218b8 100644
--- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
+++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
@@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
   VOID
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
 }
 
 /**
@@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
   IN      UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
   return Address;
 }
 
@@ -191,7 +191,7 @@ WriteBackDataCacheRange (
   IN      UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
   return Address;
 }
 
diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
index 67a3387ff3c6..bb26fe013d8b 100644
--- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
+++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
@@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
   IN UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
   return Address;
 }
 
@@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
   VOID
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
 }
 
 /**
@@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
   IN      UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
   return Address;
 }
 
@@ -152,7 +152,7 @@ WriteBackDataCache (
   VOID
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
 }
 
 /**
@@ -187,7 +187,7 @@ WriteBackDataCacheRange (
   IN      UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
   return Address;
 }
 
@@ -245,6 +245,6 @@ InvalidateDataCacheRange (
   IN      UINTN  Length
   )
 {
-  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
+  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
   return Address;
 }
diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
index b75b33381732..954d3f8c8988 100644
--- a/MdePkg/Library/BaseLib/SafeString.c
+++ b/MdePkg/Library/BaseLib/SafeString.c
@@ -17,7 +17,7 @@
     if (!(Expression)) { \
       DEBUG ((DEBUG_VERBOSE, \
         "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
-        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
+        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
       return Status; \
     } \
   } while (FALSE)
diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
index f47301de8982..a23113f9c91d 100644
--- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
+++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
@@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
   CONST RED_BLACK_TREE_NODE  *Last;
   CONST RED_BLACK_TREE_NODE  *Node;
 
-  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
+  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
 
   //
   // property #5
@@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
   DEBUG ((
     DEBUG_VERBOSE,
     "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
-    __FUNCTION__,
+    __func__,
     Tree,
     (INT64)BlackHeight,
     (INT64)ForwardCount
diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
index 82129aa44598..46aea515924f 100644
--- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
+++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
@@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
   RngProtocol = NULL;
 
   if (Buffer == NULL) {
-    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
+    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
     return EFI_INVALID_PARAMETER;
   }
 
   Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
   if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
-    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
+    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
     return Status;
   }
 
   Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
-  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
+  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
   if (!EFI_ERROR (Status)) {
     return Status;
   }
 
   Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
-  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
+  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
   if (!EFI_ERROR (Status)) {
     return Status;
   }
 
   Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
-  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
+  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
   if (!EFI_ERROR (Status)) {
     return Status;
   }
 
   // If all the other methods have failed, use the default method from the RngProtocol
   Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
-  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
+  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
   if (!EFI_ERROR (Status)) {
     return Status;
   }
 
   // If we get to this point, we have failed
-  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
+  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
 
   return Status;
 }// GenerateRandomNumberViaNist800Algorithm()
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
@ 2023-02-10  1:01   ` Michael D Kinney
  2023-02-10  1:21     ` Rebecca Cran
                       ` (2 more replies)
  2023-03-17  4:23   ` Sunil V L
  1 sibling, 3 replies; 26+ messages in thread
From: Michael D Kinney @ 2023-02-10  1:01 UTC (permalink / raw)
  To: devel@edk2.groups.io, quic_rcran@quicinc.com, Gao, Liming,
	Liu, Zhiguang
  Cc: Rebecca Cran, Kinney, Michael D

Hi Rebecca,

Did this pass EDK II CI?

This change does break EBC compiler builds.  The following has to be added to
MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.

    #define __func__ __FUNCTION__

I also see __FUNCTION__ used in many packages.  I am wondering if we want
to do this clean up if it should be its own patch series and update all
packages in once series.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Thursday, February 9, 2023 7:45 AM
> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>
> Cc: Rebecca Cran <rebecca@quicinc.com>
> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> __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
> MdePkg.
> 
> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> ---
>  MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>  MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++---------
>  MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>  MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>  MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>  MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>  MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>  7 files changed, 34 insertions(+), 34 deletions(-)
> 
> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
> index 34ec956b9c0e..d0f2dfb070d5 100644
> --- a/MdePkg/Include/Library/PerformanceLib.h
> +++ b/MdePkg/Include/Library/PerformanceLib.h
> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>  #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>      } \
>    } while (FALSE)
> 
> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>  #define PERF_EVENT_SIGNAL_END(EventGuid) \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>      } \
>    } while (FALSE)
> 
> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>  #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>      } \
>    } while (FALSE)
> 
> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>  #define PERF_CALLBACK_END(TriggerGuid) \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>      } \
>    } while (FALSE)
> 
> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>  #define PERF_FUNCTION_BEGIN() \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
>      } \
>    } while (FALSE)
> 
> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>  #define PERF_FUNCTION_END() \
>    do { \
>      if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
>      } \
>    } while (FALSE)
> 
> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
> index 71c205b1b143..321a310602d7 100644
> --- a/MdePkg/Include/Library/UnitTestLib.h
> +++ b/MdePkg/Include/Library/UnitTestLib.h
> @@ -348,7 +348,7 @@ SaveFrameworkState (
>    @param[in]  Expression  Expression to be evaluated for TRUE.
>  **/
>  #define UT_ASSERT_TRUE(Expression)                                                                 \
> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>    }
> 
> @@ -360,7 +360,7 @@ SaveFrameworkState (
>    @param[in]  Expression  Expression to be evaluated for FALSE.
>  **/
>  #define UT_ASSERT_FALSE(Expression)                                                                 \
> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>    }
> 
> @@ -373,7 +373,7 @@ SaveFrameworkState (
>    @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>  **/
>  #define UT_ASSERT_EQUAL(ValueA, ValueB)                                                                           \
> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                                           \
>    }
> 
> @@ -387,7 +387,7 @@ SaveFrameworkState (
>    @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>  **/
>  #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
> \
> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER,
> __FILE__, #BufferA, #BufferB)) { \
> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__, DEBUG_LINE_NUMBER,
> __FILE__, #BufferA, #BufferB)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;
> \
>    }
> 
> @@ -400,7 +400,7 @@ SaveFrameworkState (
>    @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>  **/
>  #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)                                                                                       \
> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                                                           \
>    }
> 
> @@ -412,7 +412,7 @@ SaveFrameworkState (
>    @param[in]  Status  EFI_STATUS value to check.
>  **/
>  #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>    }
> 
> @@ -425,7 +425,7 @@ SaveFrameworkState (
>    @param[in]  Expected  EFI_STATUS values to compare for equality.
>  **/
>  #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>    }
> 
> @@ -437,7 +437,7 @@ SaveFrameworkState (
>    @param[in]  Pointer  Pointer to be checked against NULL.
>  **/
>  #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>      return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>    }
> 
> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>        }                                                                \
>        if (!UnitTestExpectAssertFailure (                               \
>               UnitTestJumpStatus,                                       \
> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>               #FunctionCall, Status)) {                                 \
>          return UNIT_TEST_ERROR_TEST_FAILED;                            \
>        }                                                                \
> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> index 4c8773278c3c..617b0f4218b8 100644
> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>    VOID
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>  }
> 
>  /**
> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>    IN      UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>    return Address;
>  }
> 
> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>    IN      UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>    return Address;
>  }
> 
> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> index 67a3387ff3c6..bb26fe013d8b 100644
> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>    IN UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>    return Address;
>  }
> 
> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>    VOID
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>  }
> 
>  /**
> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>    IN      UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>    return Address;
>  }
> 
> @@ -152,7 +152,7 @@ WriteBackDataCache (
>    VOID
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>  }
> 
>  /**
> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>    IN      UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>    return Address;
>  }
> 
> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>    IN      UINTN  Length
>    )
>  {
> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>    return Address;
>  }
> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
> index b75b33381732..954d3f8c8988 100644
> --- a/MdePkg/Library/BaseLib/SafeString.c
> +++ b/MdePkg/Library/BaseLib/SafeString.c
> @@ -17,7 +17,7 @@
>      if (!(Expression)) { \
>        DEBUG ((DEBUG_VERBOSE, \
>          "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>        return Status; \
>      } \
>    } while (FALSE)
> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> index f47301de8982..a23113f9c91d 100644
> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>    CONST RED_BLACK_TREE_NODE  *Last;
>    CONST RED_BLACK_TREE_NODE  *Node;
> 
> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> 
>    //
>    // property #5
> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>    DEBUG ((
>      DEBUG_VERBOSE,
>      "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> -    __FUNCTION__,
> +    __func__,
>      Tree,
>      (INT64)BlackHeight,
>      (INT64)ForwardCount
> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> index 82129aa44598..46aea515924f 100644
> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>    RngProtocol = NULL;
> 
>    if (Buffer == NULL) {
> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>      return EFI_INVALID_PARAMETER;
>    }
> 
>    Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>    if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
>      return Status;
>    }
> 
>    Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
>    if (!EFI_ERROR (Status)) {
>      return Status;
>    }
> 
>    Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
>    if (!EFI_ERROR (Status)) {
>      return Status;
>    }
> 
>    Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>    if (!EFI_ERROR (Status)) {
>      return Status;
>    }
> 
>    // If all the other methods have failed, use the default method from the RngProtocol
>    Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>    if (!EFI_ERROR (Status)) {
>      return Status;
>    }
> 
>    // If we get to this point, we have failed
> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
> 
>    return Status;
>  }// GenerateRandomNumberViaNist800Algorithm()
> --
> 2.30.2
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-02-09 15:45 [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Rebecca Cran
  2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
@ 2023-02-10  1:03 ` Michael D Kinney
  2023-02-10  1:14   ` Rebecca Cran
  2023-03-06 16:39 ` Rebecca Cran
  2 siblings, 1 reply; 26+ messages in thread
From: Michael D Kinney @ 2023-02-10  1:03 UTC (permalink / raw)
  To: devel@edk2.groups.io, quic_rcran@quicinc.com, Gao, Liming,
	Liu, Zhiguang
  Cc: Rebecca Cran, Kinney, Michael D

Hi Rebecca,

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>

Do you think this needs to be considered for edk2-stable202302?

Thanks,

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Thursday, February 9, 2023 7:45 AM
> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>
> Cc: Rebecca Cran <rebecca@quicinc.com>
> Subject: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
> 
> With the introduction of the use of _Static_assert, edk2 requires a C11
> compatible compiler. Update Include/Base.h to be compliant with C11.
> 
> As of C11, the maximum type of an enum is type `int`. Since the UEFI
> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
> the 32-bit enum check to use a signed int.
> 
> Since the UEFI 2.3 Specification only allowed signed int, update the
> comment to reference 2.3.1 Errata C where the change was made to allow
> unsigned int.
> 
> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> ---
>  MdePkg/Include/Base.h | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index d209e6de280a..e89c84962ab2 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specif
>  //
>  // The following three enum types are used to verify that the compiler
>  // configuration for enum types is compliant with Section 2.3.1 of the
> -// UEFI 2.3 Specification. These enum types and enum values are not
> -// intended to be used. A prefix of '__' is used avoid conflicts with
> -// other types.
> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
> +// are not intended to be used. A prefix of '__' is used avoid
> +// conflicts with other types.
>  //
>  typedef enum {
>    __VerifyUint8EnumValue = 0xff
> @@ -809,12 +809,12 @@ typedef enum {
>  } __VERIFY_UINT16_ENUM_SIZE;
> 
>  typedef enum {
> -  __VerifyUint32EnumValue = 0xffffffff
> -} __VERIFY_UINT32_ENUM_SIZE;
> +  __VerifyInt32EnumValue = 0x7fffffff
> +} __VERIFY_INT32_ENUM_SIZE;
> 
>  STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>  STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
> 
>  /**
>    Macro that returns a pointer to the data structure that contains a specified field of
> --
> 2.30.2
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-02-10  1:03 ` [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Michael D Kinney
@ 2023-02-10  1:14   ` Rebecca Cran
  2023-02-10  4:15     ` Rebecca Cran
  0 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-02-10  1:14 UTC (permalink / raw)
  To: devel, michael.d.kinney, quic_rcran@quicinc.com, Gao, Liming,
	Liu, Zhiguang
  Cc: Rebecca Cran

Since it's just a cleanup I don't see any need for it to be in 
edk2-stable202303.

-- 
Rebecca Cran

On 2/9/23 18:03, Michael D Kinney wrote:
> Hi Rebecca,
> 
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> 
> Do you think this needs to be considered for edk2-stable202302?
> 
> Thanks,
> 
> Mike
> 
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>> Sent: Thursday, February 9, 2023 7:45 AM
>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
>> <zhiguang.liu@intel.com>
>> Cc: Rebecca Cran <rebecca@quicinc.com>
>> Subject: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
>>
>> With the introduction of the use of _Static_assert, edk2 requires a C11
>> compatible compiler. Update Include/Base.h to be compliant with C11.
>>
>> As of C11, the maximum type of an enum is type `int`. Since the UEFI
>> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
>> the 32-bit enum check to use a signed int.
>>
>> Since the UEFI 2.3 Specification only allowed signed int, update the
>> comment to reference 2.3.1 Errata C where the change was made to allow
>> unsigned int.
>>
>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>> ---
>>   MdePkg/Include/Base.h | 12 ++++++------
>>   1 file changed, 6 insertions(+), 6 deletions(-)
>>
>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>> index d209e6de280a..e89c84962ab2 100644
>> --- a/MdePkg/Include/Base.h
>> +++ b/MdePkg/Include/Base.h
>> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specif
>>   //
>>   // The following three enum types are used to verify that the compiler
>>   // configuration for enum types is compliant with Section 2.3.1 of the
>> -// UEFI 2.3 Specification. These enum types and enum values are not
>> -// intended to be used. A prefix of '__' is used avoid conflicts with
>> -// other types.
>> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
>> +// are not intended to be used. A prefix of '__' is used avoid
>> +// conflicts with other types.
>>   //
>>   typedef enum {
>>     __VerifyUint8EnumValue = 0xff
>> @@ -809,12 +809,12 @@ typedef enum {
>>   } __VERIFY_UINT16_ENUM_SIZE;
>>
>>   typedef enum {
>> -  __VerifyUint32EnumValue = 0xffffffff
>> -} __VERIFY_UINT32_ENUM_SIZE;
>> +  __VerifyInt32EnumValue = 0x7fffffff
>> +} __VERIFY_INT32_ENUM_SIZE;
>>
>>   STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>>   STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>>
>>   /**
>>     Macro that returns a pointer to the data structure that contains a specified field of
>> --
>> 2.30.2
>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
@ 2023-02-10  1:21     ` Rebecca Cran
  2023-02-10 11:45       ` Ard Biesheuvel
  2023-02-12 19:59     ` Rebecca Cran
  2023-03-14  2:19     ` Rebecca Cran
  2 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-02-10  1:21 UTC (permalink / raw)
  To: devel, michael.d.kinney, Gao, Liming, Liu, Zhiguang

Mike,

Yes, it passed CI - see https://github.com/tianocore/edk2/pull/4022 .

I wasn't sure if we cared about EBC builds these days. Given the link on 
https://www.intel.com/content/www/us/en/architecture-and-technology/unified-extensible-firmware-interface/efi-homepage-general-technology.html 
to the compiler goes to a generic page that doesn't mention it, is it 
possible to get a copy if I want to verify if changes I'm making are 
compatible?

I know there was a project to add support for building EBC using LLVM, 
but I'm not sure if anything came of it.


The cover letter didn't come through, since my email from 
rebecca@quicinc.com is increasingly unreliable as some outgoing mail is 
blocked (see my message "Changes to my email").



The cover letter that didn't come through with the patch series is:

Update MdePkg to be more C11 compliant.

We require C11 following the addition of the _Static_assert macro in
Base.h.

Fix the 32-bit enum size check to use a signed int (which is the maximum
size allowed by C11), and change the use of the pre-standard __FUNCTION__
to the C11 __func__.

Personal PR: https://github.com/tianocore/edk2/pull/4022

On 2/9/23 18:01, Michael D Kinney wrote:
> Hi Rebecca,
> 
> Did this pass EDK II CI?
> 
> This change does break EBC compiler builds.  The following has to be added to
> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> 
>      #define __func__ __FUNCTION__
> 
> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> to do this clean up if it should be its own patch series and update all
> packages in once series.
> 
> Mike
> 
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>> Sent: Thursday, February 9, 2023 7:45 AM
>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
>> <zhiguang.liu@intel.com>
>> Cc: Rebecca Cran <rebecca@quicinc.com>
>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>
>> __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
>> MdePkg.
>>
>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>> ---
>>   MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>>   MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++---------
>>   MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>>   MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>>   MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>>   MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>>   MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>>   7 files changed, 34 insertions(+), 34 deletions(-)
>>
>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
>> index 34ec956b9c0e..d0f2dfb070d5 100644
>> --- a/MdePkg/Include/Library/PerformanceLib.h
>> +++ b/MdePkg/Include/Library/PerformanceLib.h
>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>>   #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>>   #define PERF_EVENT_SIGNAL_END(EventGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>>   #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>>   #define PERF_CALLBACK_END(TriggerGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>>   #define PERF_FUNCTION_BEGIN() \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>>   #define PERF_FUNCTION_END() \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
>> index 71c205b1b143..321a310602d7 100644
>> --- a/MdePkg/Include/Library/UnitTestLib.h
>> +++ b/MdePkg/Include/Library/UnitTestLib.h
>> @@ -348,7 +348,7 @@ SaveFrameworkState (
>>     @param[in]  Expression  Expression to be evaluated for TRUE.
>>   **/
>>   #define UT_ASSERT_TRUE(Expression)                                                                 \
>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>>     }
>>
>> @@ -360,7 +360,7 @@ SaveFrameworkState (
>>     @param[in]  Expression  Expression to be evaluated for FALSE.
>>   **/
>>   #define UT_ASSERT_FALSE(Expression)                                                                 \
>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>>     }
>>
>> @@ -373,7 +373,7 @@ SaveFrameworkState (
>>     @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>>   **/
>>   #define UT_ASSERT_EQUAL(ValueA, ValueB)                                                                           \
>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                           \
>>     }
>>
>> @@ -387,7 +387,7 @@ SaveFrameworkState (
>>     @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>>   **/
>>   #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
>> \
>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER,
>> __FILE__, #BufferA, #BufferB)) { \
>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__, DEBUG_LINE_NUMBER,
>> __FILE__, #BufferA, #BufferB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;
>> \
>>     }
>>
>> @@ -400,7 +400,7 @@ SaveFrameworkState (
>>     @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>>   **/
>>   #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)                                                                                       \
>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                                           \
>>     }
>>
>> @@ -412,7 +412,7 @@ SaveFrameworkState (
>>     @param[in]  Status  EFI_STATUS value to check.
>>   **/
>>   #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>>     }
>>
>> @@ -425,7 +425,7 @@ SaveFrameworkState (
>>     @param[in]  Expected  EFI_STATUS values to compare for equality.
>>   **/
>>   #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>>     }
>>
>> @@ -437,7 +437,7 @@ SaveFrameworkState (
>>     @param[in]  Pointer  Pointer to be checked against NULL.
>>   **/
>>   #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>>     }
>>
>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>>         }                                                                \
>>         if (!UnitTestExpectAssertFailure (                               \
>>                UnitTestJumpStatus,                                       \
>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>>                #FunctionCall, Status)) {                                 \
>>           return UNIT_TEST_ERROR_TEST_FAILED;                            \
>>         }                                                                \
>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> index 4c8773278c3c..617b0f4218b8 100644
>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>   }
>>
>>   /**
>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>     return Address;
>>   }
>>
>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> index 67a3387ff3c6..bb26fe013d8b 100644
>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>>     IN UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>   }
>>
>>   /**
>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -152,7 +152,7 @@ WriteBackDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>   }
>>
>>   /**
>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
>> index b75b33381732..954d3f8c8988 100644
>> --- a/MdePkg/Library/BaseLib/SafeString.c
>> +++ b/MdePkg/Library/BaseLib/SafeString.c
>> @@ -17,7 +17,7 @@
>>       if (!(Expression)) { \
>>         DEBUG ((DEBUG_VERBOSE, \
>>           "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>         return Status; \
>>       } \
>>     } while (FALSE)
>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> index f47301de8982..a23113f9c91d 100644
>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>>     CONST RED_BLACK_TREE_NODE  *Last;
>>     CONST RED_BLACK_TREE_NODE  *Node;
>>
>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
>>
>>     //
>>     // property #5
>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>>     DEBUG ((
>>       DEBUG_VERBOSE,
>>       "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>> -    __FUNCTION__,
>> +    __func__,
>>       Tree,
>>       (INT64)BlackHeight,
>>       (INT64)ForwardCount
>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> index 82129aa44598..46aea515924f 100644
>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>>     RngProtocol = NULL;
>>
>>     if (Buffer == NULL) {
>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>>       return EFI_INVALID_PARAMETER;
>>     }
>>
>>     Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>>     if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     // If all the other methods have failed, use the default method from the RngProtocol
>>     Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     // If we get to this point, we have failed
>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
>>
>>     return Status;
>>   }// GenerateRandomNumberViaNist800Algorithm()
>> --
>> 2.30.2
>>
>>
>>
>>
>>
> 
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-02-10  1:14   ` Rebecca Cran
@ 2023-02-10  4:15     ` Rebecca Cran
  0 siblings, 0 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-02-10  4:15 UTC (permalink / raw)
  To: devel, michael.d.kinney, Gao, Liming, Liu, Zhiguang

Also the fact that it's been like this since 2016!

-- 
Rebecca Cran

On 2/9/23 18:14, Rebecca Cran wrote:
> Since it's just a cleanup I don't see any need for it to be in 
> edk2-stable202303.
> 

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10  1:21     ` Rebecca Cran
@ 2023-02-10 11:45       ` Ard Biesheuvel
  2023-02-10 15:19         ` Leif Lindholm
  0 siblings, 1 reply; 26+ messages in thread
From: Ard Biesheuvel @ 2023-02-10 11:45 UTC (permalink / raw)
  To: devel, rebecca
  Cc: michael.d.kinney, Gao, Liming, Liu, Zhiguang, Leif Lindholm

On Fri, 10 Feb 2023 at 02:21, Rebecca Cran <rebecca@bsdio.com> wrote:
>
> Mike,
>
> Yes, it passed CI - see https://github.com/tianocore/edk2/pull/4022 .
>
> I wasn't sure if we cared about EBC builds these days. Given the link on
> https://www.intel.com/content/www/us/en/architecture-and-technology/unified-extensible-firmware-interface/efi-homepage-general-technology.html
> to the compiler goes to a generic page that doesn't mention it, is it
> possible to get a copy if I want to verify if changes I'm making are
> compatible?
>

We tried to get access to this at Linaro, but I don't think it is
still available. Leif may remember better.

> I know there was a project to add support for building EBC using LLVM,
> but I'm not sure if anything came of it.
>

No that never went anywhere afaik. The problem was that, in EBC,
sizeof() is not a compile time constant, and this breaks too many
assumptions in the existing frontends, so this would only be feasible
if we restricted ourselves to a specialized version of EBC that
targets 64-bit architectures only, but this seems like a lot of effort
for questionable benefits.

Given that X64 code can run on arm64 under emulation without too many
problems [0], and that the 32-bit ARM procedure call standard is
fundamentally incompatible with EBC, the issue lost its urgency
somewhat, at least from the side of ARM at the time.

[0] https://github.com/ardbiesheuvel/X86EmulatorPkg

I wonder whether we should simply drop EBC support? It is unlikely
that all the changes that went into EDK2 over the years have not
caused a single EBC regression in the library components that are
needed to build UEFI drivers that target EBC.

Or is this still being used/tested internally at Intel?

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10 11:45       ` Ard Biesheuvel
@ 2023-02-10 15:19         ` Leif Lindholm
  2023-02-10 18:16           ` Michael D Kinney
  0 siblings, 1 reply; 26+ messages in thread
From: Leif Lindholm @ 2023-02-10 15:19 UTC (permalink / raw)
  To: devel, ardb, rebecca; +Cc: michael.d.kinney, Gao, Liming, Liu, Zhiguang

On 2023-02-10 11:45, Ard Biesheuvel wrote:
>> I wasn't sure if we cared about EBC builds these days. Given the link on
>> https://www.intel.com/content/www/us/en/architecture-and-technology/unified-extensible-firmware-interface/efi-homepage-general-technology.html
>> to the compiler goes to a generic page that doesn't mention it, is it
>> possible to get a copy if I want to verify if changes I'm making are
>> compatible?
> 
> We tried to get access to this at Linaro, but I don't think it is
> still available. Leif may remember better.

After asking around, some shady character in a café passed me a very 
long and customized URL on a note in a brown paper bag, and I was able 
to procure a single license for ARM. I don't think we succeeded for Linaro.

> I wonder whether we should simply drop EBC support? It is unlikely
> that all the changes that went into EDK2 over the years have not
> caused a single EBC regression in the library components that are
> needed to build UEFI drivers that target EBC.

The appearance of RISC-V and Loongarch since those days highlight why 
architecture independent drivers would be a good thing, but EBC is 
pining for the fjords.

If we don't drop EBC now, we should start drafting a timeline for when 
we will.

/
     Leif


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10 15:19         ` Leif Lindholm
@ 2023-02-10 18:16           ` Michael D Kinney
  0 siblings, 0 replies; 26+ messages in thread
From: Michael D Kinney @ 2023-02-10 18:16 UTC (permalink / raw)
  To: Leif Lindholm, devel@edk2.groups.io, ardb@kernel.org,
	rebecca@bsdio.com
  Cc: Gao, Liming, Liu, Zhiguang, Kinney, Michael D

I would like to propose removing EBC support from edk2 and BaseTools after 
edk2-stable202302.

Anyone requiring EBC can use edk2-stable202302 or older releases.

Mike

> -----Original Message-----
> From: Leif Lindholm <quic_llindhol@quicinc.com>
> Sent: Friday, February 10, 2023 7:20 AM
> To: devel@edk2.groups.io; ardb@kernel.org; rebecca@bsdio.com
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> On 2023-02-10 11:45, Ard Biesheuvel wrote:
> >> I wasn't sure if we cared about EBC builds these days. Given the link on
> >> https://www.intel.com/content/www/us/en/architecture-and-technology/unified-extensible-firmware-interface/efi-homepage-
> general-technology.html
> >> to the compiler goes to a generic page that doesn't mention it, is it
> >> possible to get a copy if I want to verify if changes I'm making are
> >> compatible?
> >
> > We tried to get access to this at Linaro, but I don't think it is
> > still available. Leif may remember better.
> 
> After asking around, some shady character in a café passed me a very
> long and customized URL on a note in a brown paper bag, and I was able
> to procure a single license for ARM. I don't think we succeeded for Linaro.
> 
> > I wonder whether we should simply drop EBC support? It is unlikely
> > that all the changes that went into EDK2 over the years have not
> > caused a single EBC regression in the library components that are
> > needed to build UEFI drivers that target EBC.
> 
> The appearance of RISC-V and Loongarch since those days highlight why
> architecture independent drivers would be a good thing, but EBC is
> pining for the fjords.
> 
> If we don't drop EBC now, we should start drafting a timeline for when
> we will.
> 
> /
>      Leif


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
  2023-02-10  1:21     ` Rebecca Cran
@ 2023-02-12 19:59     ` Rebecca Cran
  2023-03-14  2:19     ` Rebecca Cran
  2 siblings, 0 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-02-12 19:59 UTC (permalink / raw)
  To: devel, michael.d.kinney, Gao, Liming, Liu, Zhiguang

On 2/9/23 18:01, Michael D Kinney wrote:
> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> to do this clean up if it should be its own patch series and update all
> packages in once series.
To simplify review, I was planning to send out separate patch series for 
each package.

-- 
Rebecca Cran

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-02-09 15:45 [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Rebecca Cran
  2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
  2023-02-10  1:03 ` [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Michael D Kinney
@ 2023-03-06 16:39 ` Rebecca Cran
  2023-03-10  2:45   ` 回复: " gaoliming
  2 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-03-06 16:39 UTC (permalink / raw)
  To: devel, quic_rcran, Michael D Kinney, Liming Gao, Zhiguang Liu

Now that edk2-stable202302 has been released, I'd like to get this patch 
series committed.


-- 
Rebecca Cran


On 2/9/23 8:45 AM, Rebecca Cran wrote:
> With the introduction of the use of _Static_assert, edk2 requires a C11
> compatible compiler. Update Include/Base.h to be compliant with C11.
>
> As of C11, the maximum type of an enum is type `int`. Since the UEFI
> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
> the 32-bit enum check to use a signed int.
>
> Since the UEFI 2.3 Specification only allowed signed int, update the
> comment to reference 2.3.1 Errata C where the change was made to allow
> unsigned int.
>
> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> ---
>   MdePkg/Include/Base.h | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> index d209e6de280a..e89c84962ab2 100644
> --- a/MdePkg/Include/Base.h
> +++ b/MdePkg/Include/Base.h
> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof (L\"A\") does not meet UEFI Specif
>   //
>   // The following three enum types are used to verify that the compiler
>   // configuration for enum types is compliant with Section 2.3.1 of the
> -// UEFI 2.3 Specification. These enum types and enum values are not
> -// intended to be used. A prefix of '__' is used avoid conflicts with
> -// other types.
> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
> +// are not intended to be used. A prefix of '__' is used avoid
> +// conflicts with other types.
>   //
>   typedef enum {
>     __VerifyUint8EnumValue = 0xff
> @@ -809,12 +809,12 @@ typedef enum {
>   } __VERIFY_UINT16_ENUM_SIZE;
>   
>   typedef enum {
> -  __VerifyUint32EnumValue = 0xffffffff
> -} __VERIFY_UINT32_ENUM_SIZE;
> +  __VerifyInt32EnumValue = 0x7fffffff
> +} __VERIFY_INT32_ENUM_SIZE;
>   
>   STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>   STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum does not meet UEFI Specification Data Type requirements");
>   
>   /**
>     Macro that returns a pointer to the data structure that contains a specified field of

^ permalink raw reply	[flat|nested] 26+ messages in thread

* 回复: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-03-06 16:39 ` Rebecca Cran
@ 2023-03-10  2:45   ` gaoliming
  2023-03-10 17:58     ` Rebecca Cran
  2023-03-13 17:54     ` Rebecca Cran
  0 siblings, 2 replies; 26+ messages in thread
From: gaoliming @ 2023-03-10  2:45 UTC (permalink / raw)
  To: 'Rebecca Cran', devel, quic_rcran,
	'Michael D Kinney', 'Zhiguang Liu'

Rebecca:
  This patch pass code review. It can be merged now. The second change to using __func__ is only for MdePkg. Do you expect the change in MdePkg is first merged?

Thanks
Liming
> -----邮件原件-----
> 发件人: Rebecca Cran <rebecca@bsdio.com>
> 发送时间: 2023年3月7日 0:39
> 收件人: devel@edk2.groups.io; quic_rcran@quicinc.com; Michael D Kinney
> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> Zhiguang Liu <zhiguang.liu@intel.com>
> 主题: Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant
> with C11
> 
> Now that edk2-stable202302 has been released, I'd like to get this patch
> series committed.
> 
> 
> --
> Rebecca Cran
> 
> 
> On 2/9/23 8:45 AM, Rebecca Cran wrote:
> > With the introduction of the use of _Static_assert, edk2 requires a C11
> > compatible compiler. Update Include/Base.h to be compliant with C11.
> >
> > As of C11, the maximum type of an enum is type `int`. Since the UEFI
> > Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
> > the 32-bit enum check to use a signed int.
> >
> > Since the UEFI 2.3 Specification only allowed signed int, update the
> > comment to reference 2.3.1 Errata C where the change was made to allow
> > unsigned int.
> >
> > Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> > ---
> >   MdePkg/Include/Base.h | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> > index d209e6de280a..e89c84962ab2 100644
> > --- a/MdePkg/Include/Base.h
> > +++ b/MdePkg/Include/Base.h
> > @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof
> (L\"A\") does not meet UEFI Specif
> >   //
> >   // The following three enum types are used to verify that the compiler
> >   // configuration for enum types is compliant with Section 2.3.1 of the
> > -// UEFI 2.3 Specification. These enum types and enum values are not
> > -// intended to be used. A prefix of '__' is used avoid conflicts with
> > -// other types.
> > +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
> > +// are not intended to be used. A prefix of '__' is used avoid
> > +// conflicts with other types.
> >   //
> >   typedef enum {
> >     __VerifyUint8EnumValue = 0xff
> > @@ -809,12 +809,12 @@ typedef enum {
> >   } __VERIFY_UINT16_ENUM_SIZE;
> >
> >   typedef enum {
> > -  __VerifyUint32EnumValue = 0xffffffff
> > -} __VERIFY_UINT32_ENUM_SIZE;
> > +  __VerifyInt32EnumValue = 0x7fffffff
> > +} __VERIFY_INT32_ENUM_SIZE;
> >
> >   STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of
> enum does not meet UEFI Specification Data Type requirements");
> >   STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of
> enum does not meet UEFI Specification Data Type requirements");
> > -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of
> enum does not meet UEFI Specification Data Type requirements");
> > +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum
> does not meet UEFI Specification Data Type requirements");
> >
> >   /**
> >     Macro that returns a pointer to the data structure that contains a
> specified field of



^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: 回复: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-03-10  2:45   ` 回复: " gaoliming
@ 2023-03-10 17:58     ` Rebecca Cran
  2023-03-13 17:54     ` Rebecca Cran
  1 sibling, 0 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-03-10 17:58 UTC (permalink / raw)
  To: gaoliming, devel, 'Michael D Kinney',
	'Zhiguang Liu'

Yes. Now that the MdePkg change has been reviewed and will be committed, 
I'll proceed with submitting patches for the other packages.


-- 

Rebecca Cran


On 3/9/23 7:45 PM, gaoliming wrote:
> Rebecca:
>    This patch pass code review. It can be merged now. The second change to using __func__ is only for MdePkg. Do you expect the change in MdePkg is first merged?
>
> Thanks
> Liming
>> -----邮件原件-----
>> 发件人: Rebecca Cran <rebecca@bsdio.com>
>> 发送时间: 2023年3月7日 0:39
>> 收件人: devel@edk2.groups.io; quic_rcran@quicinc.com; Michael D Kinney
>> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
>> Zhiguang Liu <zhiguang.liu@intel.com>
>> 主题: Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant
>> with C11
>>
>> Now that edk2-stable202302 has been released, I'd like to get this patch
>> series committed.
>>
>>
>> --
>> Rebecca Cran
>>
>>
>> On 2/9/23 8:45 AM, Rebecca Cran wrote:
>>> With the introduction of the use of _Static_assert, edk2 requires a C11
>>> compatible compiler. Update Include/Base.h to be compliant with C11.
>>>
>>> As of C11, the maximum type of an enum is type `int`. Since the UEFI
>>> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
>>> the 32-bit enum check to use a signed int.
>>>
>>> Since the UEFI 2.3 Specification only allowed signed int, update the
>>> comment to reference 2.3.1 Errata C where the change was made to allow
>>> unsigned int.
>>>
>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>>> ---
>>>    MdePkg/Include/Base.h | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>>> index d209e6de280a..e89c84962ab2 100644
>>> --- a/MdePkg/Include/Base.h
>>> +++ b/MdePkg/Include/Base.h
>>> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof
>> (L\"A\") does not meet UEFI Specif
>>>    //
>>>    // The following three enum types are used to verify that the compiler
>>>    // configuration for enum types is compliant with Section 2.3.1 of the
>>> -// UEFI 2.3 Specification. These enum types and enum values are not
>>> -// intended to be used. A prefix of '__' is used avoid conflicts with
>>> -// other types.
>>> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
>>> +// are not intended to be used. A prefix of '__' is used avoid
>>> +// conflicts with other types.
>>>    //
>>>    typedef enum {
>>>      __VerifyUint8EnumValue = 0xff
>>> @@ -809,12 +809,12 @@ typedef enum {
>>>    } __VERIFY_UINT16_ENUM_SIZE;
>>>
>>>    typedef enum {
>>> -  __VerifyUint32EnumValue = 0xffffffff
>>> -} __VERIFY_UINT32_ENUM_SIZE;
>>> +  __VerifyInt32EnumValue = 0x7fffffff
>>> +} __VERIFY_INT32_ENUM_SIZE;
>>>
>>>    STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>>    STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum
>> does not meet UEFI Specification Data Type requirements");
>>>    /**
>>>      Macro that returns a pointer to the data structure that contains a
>> specified field of
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: 回复: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-03-10  2:45   ` 回复: " gaoliming
  2023-03-10 17:58     ` Rebecca Cran
@ 2023-03-13 17:54     ` Rebecca Cran
  2023-03-13 20:46       ` Michael D Kinney
  1 sibling, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-03-13 17:54 UTC (permalink / raw)
  To: devel, gaoliming, 'Michael D Kinney',
	'Zhiguang Liu'

I know I have access to the Github tianocore project and can push to the 
edk2-libc repo, but I've been assuming that I'm not allowed to push to 
the edk2 repo.

Is that correct, or can I go ahead and push this and any other patches 
that get reviewed?


-- 
Rebecca Cran


On 3/9/23 7:45 PM, gaoliming via groups.io wrote:
> Rebecca:
>    This patch pass code review. It can be merged now. The second change to using __func__ is only for MdePkg. Do you expect the change in MdePkg is first merged?
>
> Thanks
> Liming
>> -----邮件原件-----
>> 发件人: Rebecca Cran <rebecca@bsdio.com>
>> 发送时间: 2023年3月7日 0:39
>> 收件人: devel@edk2.groups.io; quic_rcran@quicinc.com; Michael D Kinney
>> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
>> Zhiguang Liu <zhiguang.liu@intel.com>
>> 主题: Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant
>> with C11
>>
>> Now that edk2-stable202302 has been released, I'd like to get this patch
>> series committed.
>>
>>
>> --
>> Rebecca Cran
>>
>>
>> On 2/9/23 8:45 AM, Rebecca Cran wrote:
>>> With the introduction of the use of _Static_assert, edk2 requires a C11
>>> compatible compiler. Update Include/Base.h to be compliant with C11.
>>>
>>> As of C11, the maximum type of an enum is type `int`. Since the UEFI
>>> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
>>> the 32-bit enum check to use a signed int.
>>>
>>> Since the UEFI 2.3 Specification only allowed signed int, update the
>>> comment to reference 2.3.1 Errata C where the change was made to allow
>>> unsigned int.
>>>
>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>>> ---
>>>    MdePkg/Include/Base.h | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
>>> index d209e6de280a..e89c84962ab2 100644
>>> --- a/MdePkg/Include/Base.h
>>> +++ b/MdePkg/Include/Base.h
>>> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof
>> (L\"A\") does not meet UEFI Specif
>>>    //
>>>    // The following three enum types are used to verify that the compiler
>>>    // configuration for enum types is compliant with Section 2.3.1 of the
>>> -// UEFI 2.3 Specification. These enum types and enum values are not
>>> -// intended to be used. A prefix of '__' is used avoid conflicts with
>>> -// other types.
>>> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
>>> +// are not intended to be used. A prefix of '__' is used avoid
>>> +// conflicts with other types.
>>>    //
>>>    typedef enum {
>>>      __VerifyUint8EnumValue = 0xff
>>> @@ -809,12 +809,12 @@ typedef enum {
>>>    } __VERIFY_UINT16_ENUM_SIZE;
>>>
>>>    typedef enum {
>>> -  __VerifyUint32EnumValue = 0xffffffff
>>> -} __VERIFY_UINT32_ENUM_SIZE;
>>> +  __VerifyInt32EnumValue = 0x7fffffff
>>> +} __VERIFY_INT32_ENUM_SIZE;
>>>
>>>    STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>>    STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of
>> enum does not meet UEFI Specification Data Type requirements");
>>> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum
>> does not meet UEFI Specification Data Type requirements");
>>>    /**
>>>      Macro that returns a pointer to the data structure that contains a
>> specified field of
>
>
>
> 
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: 回复: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
  2023-03-13 17:54     ` Rebecca Cran
@ 2023-03-13 20:46       ` Michael D Kinney
  0 siblings, 0 replies; 26+ messages in thread
From: Michael D Kinney @ 2023-03-13 20:46 UTC (permalink / raw)
  To: Rebecca Cran, devel@edk2.groups.io, Gao, Liming, Liu, Zhiguang
  Cc: Kinney, Michael D

Hi Rebecca,

You are a member of EDK II Maintainers, so you have permissions to set 'push' label.
It is preferred for the maintainer for a package to do this for the packages/content
they maintain.

If you have updated the patch series with Rbs and synced to latest edk2 repo, then
send an email with a link to the PRs.  That makes it simple for maintainers to perform
a final review and set 'push' label.

Thanks,

Mike

> -----Original Message-----
> From: Rebecca Cran <rebecca@bsdio.com>
> Sent: Monday, March 13, 2023 10:54 AM
> To: devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Kinney, Michael D <michael.d.kinney@intel.com>;
> Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: Re: 回复: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11
> 
> I know I have access to the Github tianocore project and can push to the
> edk2-libc repo, but I've been assuming that I'm not allowed to push to
> the edk2 repo.
> 
> Is that correct, or can I go ahead and push this and any other patches
> that get reviewed?
> 
> 
> --
> Rebecca Cran
> 
> 
> On 3/9/23 7:45 PM, gaoliming via groups.io wrote:
> > Rebecca:
> >    This patch pass code review. It can be merged now. The second change to using __func__ is only for MdePkg. Do
> you expect the change in MdePkg is first merged?
> >
> > Thanks
> > Liming
> >> -----邮件原件-----
> >> 发件人: Rebecca Cran <rebecca@bsdio.com>
> >> 发送时间: 2023年3月7日 0:39
> >> 收件人: devel@edk2.groups.io; quic_rcran@quicinc.com; Michael D Kinney
> >> <michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
> >> Zhiguang Liu <zhiguang.liu@intel.com>
> >> 主题: Re: [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant
> >> with C11
> >>
> >> Now that edk2-stable202302 has been released, I'd like to get this patch
> >> series committed.
> >>
> >>
> >> --
> >> Rebecca Cran
> >>
> >>
> >> On 2/9/23 8:45 AM, Rebecca Cran wrote:
> >>> With the introduction of the use of _Static_assert, edk2 requires a C11
> >>> compatible compiler. Update Include/Base.h to be compliant with C11.
> >>>
> >>> As of C11, the maximum type of an enum is type `int`. Since the UEFI
> >>> Specification 2.3.1 Errata C allows either `int` or `unsigned int`, fix
> >>> the 32-bit enum check to use a signed int.
> >>>
> >>> Since the UEFI 2.3 Specification only allowed signed int, update the
> >>> comment to reference 2.3.1 Errata C where the change was made to allow
> >>> unsigned int.
> >>>
> >>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> >>> ---
> >>>    MdePkg/Include/Base.h | 12 ++++++------
> >>>    1 file changed, 6 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h
> >>> index d209e6de280a..e89c84962ab2 100644
> >>> --- a/MdePkg/Include/Base.h
> >>> +++ b/MdePkg/Include/Base.h
> >>> @@ -796,9 +796,9 @@ STATIC_ASSERT (sizeof (L"A")    == 4, "sizeof
> >> (L\"A\") does not meet UEFI Specif
> >>>    //
> >>>    // The following three enum types are used to verify that the compiler
> >>>    // configuration for enum types is compliant with Section 2.3.1 of the
> >>> -// UEFI 2.3 Specification. These enum types and enum values are not
> >>> -// intended to be used. A prefix of '__' is used avoid conflicts with
> >>> -// other types.
> >>> +// UEFI 2.3.1 Errata C Specification. These enum types and enum values
> >>> +// are not intended to be used. A prefix of '__' is used avoid
> >>> +// conflicts with other types.
> >>>    //
> >>>    typedef enum {
> >>>      __VerifyUint8EnumValue = 0xff
> >>> @@ -809,12 +809,12 @@ typedef enum {
> >>>    } __VERIFY_UINT16_ENUM_SIZE;
> >>>
> >>>    typedef enum {
> >>> -  __VerifyUint32EnumValue = 0xffffffff
> >>> -} __VERIFY_UINT32_ENUM_SIZE;
> >>> +  __VerifyInt32EnumValue = 0x7fffffff
> >>> +} __VERIFY_INT32_ENUM_SIZE;
> >>>
> >>>    STATIC_ASSERT (sizeof (__VERIFY_UINT8_ENUM_SIZE) == 4, "Size of
> >> enum does not meet UEFI Specification Data Type requirements");
> >>>    STATIC_ASSERT (sizeof (__VERIFY_UINT16_ENUM_SIZE) == 4, "Size of
> >> enum does not meet UEFI Specification Data Type requirements");
> >>> -STATIC_ASSERT (sizeof (__VERIFY_UINT32_ENUM_SIZE) == 4, "Size of
> >> enum does not meet UEFI Specification Data Type requirements");
> >>> +STATIC_ASSERT (sizeof (__VERIFY_INT32_ENUM_SIZE) == 4, "Size of enum
> >> does not meet UEFI Specification Data Type requirements");
> >>>    /**
> >>>      Macro that returns a pointer to the data structure that contains a
> >> specified field of
> >
> >
> >
> > 
> >
> >

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
  2023-02-10  1:21     ` Rebecca Cran
  2023-02-12 19:59     ` Rebecca Cran
@ 2023-03-14  2:19     ` Rebecca Cran
  2023-03-14 20:40       ` Michael D Kinney
  2 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-03-14  2:19 UTC (permalink / raw)
  To: devel, michael.d.kinney, Gao, Liming, Liu, Zhiguang

Mike,


I think your concerns with this patch were addressed?

Could you add a Reviewed-by please?


Thanks.
Rebecca


On 2/9/23 6:01 PM, Michael D Kinney wrote:
> Hi Rebecca,
>
> Did this pass EDK II CI?
>
> This change does break EBC compiler builds.  The following has to be added to
> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
>
>      #define __func__ __FUNCTION__
>
> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> to do this clean up if it should be its own patch series and update all
> packages in once series.
>
> Mike
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>> Sent: Thursday, February 9, 2023 7:45 AM
>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
>> <zhiguang.liu@intel.com>
>> Cc: Rebecca Cran <rebecca@quicinc.com>
>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>
>> __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
>> MdePkg.
>>
>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>> ---
>>   MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>>   MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++---------
>>   MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>>   MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>>   MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>>   MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>>   MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>>   7 files changed, 34 insertions(+), 34 deletions(-)
>>
>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
>> index 34ec956b9c0e..d0f2dfb070d5 100644
>> --- a/MdePkg/Include/Library/PerformanceLib.h
>> +++ b/MdePkg/Include/Library/PerformanceLib.h
>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>>   #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>>   #define PERF_EVENT_SIGNAL_END(EventGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>>   #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>>   #define PERF_CALLBACK_END(TriggerGuid) \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>>   #define PERF_FUNCTION_BEGIN() \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
>>       } \
>>     } while (FALSE)
>>
>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>>   #define PERF_FUNCTION_END() \
>>     do { \
>>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
>>       } \
>>     } while (FALSE)
>>
>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
>> index 71c205b1b143..321a310602d7 100644
>> --- a/MdePkg/Include/Library/UnitTestLib.h
>> +++ b/MdePkg/Include/Library/UnitTestLib.h
>> @@ -348,7 +348,7 @@ SaveFrameworkState (
>>     @param[in]  Expression  Expression to be evaluated for TRUE.
>>   **/
>>   #define UT_ASSERT_TRUE(Expression)                                                                 \
>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>>     }
>>
>> @@ -360,7 +360,7 @@ SaveFrameworkState (
>>     @param[in]  Expression  Expression to be evaluated for FALSE.
>>   **/
>>   #define UT_ASSERT_FALSE(Expression)                                                                 \
>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>>     }
>>
>> @@ -373,7 +373,7 @@ SaveFrameworkState (
>>     @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>>   **/
>>   #define UT_ASSERT_EQUAL(ValueA, ValueB)                                                                           \
>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                           \
>>     }
>>
>> @@ -387,7 +387,7 @@ SaveFrameworkState (
>>     @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>>   **/
>>   #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
>> \
>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__, DEBUG_LINE_NUMBER,
>> __FILE__, #BufferA, #BufferB)) { \
>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__, DEBUG_LINE_NUMBER,
>> __FILE__, #BufferA, #BufferB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;
>> \
>>     }
>>
>> @@ -400,7 +400,7 @@ SaveFrameworkState (
>>     @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>>   **/
>>   #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)                                                                                       \
>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA, #ValueB)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                                           \
>>     }
>>
>> @@ -412,7 +412,7 @@ SaveFrameworkState (
>>     @param[in]  Status  EFI_STATUS value to check.
>>   **/
>>   #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>>     }
>>
>> @@ -425,7 +425,7 @@ SaveFrameworkState (
>>     @param[in]  Expected  EFI_STATUS values to compare for equality.
>>   **/
>>   #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>>     }
>>
>> @@ -437,7 +437,7 @@ SaveFrameworkState (
>>     @param[in]  Pointer  Pointer to be checked against NULL.
>>   **/
>>   #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>       return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>>     }
>>
>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>>         }                                                                \
>>         if (!UnitTestExpectAssertFailure (                               \
>>                UnitTestJumpStatus,                                       \
>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>>                #FunctionCall, Status)) {                                 \
>>           return UNIT_TEST_ERROR_TEST_FAILED;                            \
>>         }                                                                \
>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> index 4c8773278c3c..617b0f4218b8 100644
>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>   }
>>
>>   /**
>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>     return Address;
>>   }
>>
>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> index 67a3387ff3c6..bb26fe013d8b 100644
>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>>     IN UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>   }
>>
>>   /**
>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -152,7 +152,7 @@ WriteBackDataCache (
>>     VOID
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>   }
>>
>>   /**
>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>>
>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>>     IN      UINTN  Length
>>     )
>>   {
>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>     return Address;
>>   }
>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
>> index b75b33381732..954d3f8c8988 100644
>> --- a/MdePkg/Library/BaseLib/SafeString.c
>> +++ b/MdePkg/Library/BaseLib/SafeString.c
>> @@ -17,7 +17,7 @@
>>       if (!(Expression)) { \
>>         DEBUG ((DEBUG_VERBOSE, \
>>           "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>         return Status; \
>>       } \
>>     } while (FALSE)
>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> index f47301de8982..a23113f9c91d 100644
>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>>     CONST RED_BLACK_TREE_NODE  *Last;
>>     CONST RED_BLACK_TREE_NODE  *Node;
>>
>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
>>
>>     //
>>     // property #5
>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>>     DEBUG ((
>>       DEBUG_VERBOSE,
>>       "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>> -    __FUNCTION__,
>> +    __func__,
>>       Tree,
>>       (INT64)BlackHeight,
>>       (INT64)ForwardCount
>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> index 82129aa44598..46aea515924f 100644
>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>>     RngProtocol = NULL;
>>
>>     if (Buffer == NULL) {
>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>>       return EFI_INVALID_PARAMETER;
>>     }
>>
>>     Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>>     if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     // If all the other methods have failed, use the default method from the RngProtocol
>>     Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>     if (!EFI_ERROR (Status)) {
>>       return Status;
>>     }
>>
>>     // If we get to this point, we have failed
>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
>>
>>     return Status;
>>   }// GenerateRandomNumberViaNist800Algorithm()
>> --
>> 2.30.2
>>
>>
>>
>>
>>
>
>
> 
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-14  2:19     ` Rebecca Cran
@ 2023-03-14 20:40       ` Michael D Kinney
  2023-03-17 13:31         ` Rebecca Cran
  0 siblings, 1 reply; 26+ messages in thread
From: Michael D Kinney @ 2023-03-14 20:40 UTC (permalink / raw)
  To: devel@edk2.groups.io, rebecca@bsdio.com, Gao, Liming,
	Liu, Zhiguang
  Cc: Kinney, Michael D

Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>


> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Monday, March 13, 2023 7:20 PM
> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> Liu, Zhiguang <zhiguang.liu@intel.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> Mike,
> 
> 
> I think your concerns with this patch were addressed?
> 
> Could you add a Reviewed-by please?
> 
> 
> Thanks.
> Rebecca
> 
> 
> On 2/9/23 6:01 PM, Michael D Kinney wrote:
> > Hi Rebecca,
> >
> > Did this pass EDK II CI?
> >
> > This change does break EBC compiler builds.  The following has to be added to
> > MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> >
> >      #define __func__ __FUNCTION__
> >
> > I also see __FUNCTION__ used in many packages.  I am wondering if we want
> > to do this clean up if it should be its own patch series and update all
> > packages in once series.
> >
> > Mike
> >
> >> -----Original Message-----
> >> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >> Sent: Thursday, February 9, 2023 7:45 AM
> >> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> Liu, Zhiguang
> >> <zhiguang.liu@intel.com>
> >> Cc: Rebecca Cran <rebecca@quicinc.com>
> >> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>
> >> __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
> >> MdePkg.
> >>
> >> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> >> ---
> >>   MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
> >>   MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
> ---
> >>   MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
> >>   MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
> >>   MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
> >>   MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
> >>   MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
> >>   7 files changed, 34 insertions(+), 34 deletions(-)
> >>
> >> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
> >> index 34ec956b9c0e..d0f2dfb070d5 100644
> >> --- a/MdePkg/Include/Library/PerformanceLib.h
> >> +++ b/MdePkg/Include/Library/PerformanceLib.h
> >> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_EVENT_SIGNAL_END(EventGuid) \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_CALLBACK_BEGIN(TriggerGuid) \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_CALLBACK_END(TriggerGuid) \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_FUNCTION_BEGIN() \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
> >>   #define PERF_FUNCTION_END() \
> >>     do { \
> >>       if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> >> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
> >>       } \
> >>     } while (FALSE)
> >>
> >> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
> >> index 71c205b1b143..321a310602d7 100644
> >> --- a/MdePkg/Include/Library/UnitTestLib.h
> >> +++ b/MdePkg/Include/Library/UnitTestLib.h
> >> @@ -348,7 +348,7 @@ SaveFrameworkState (
> >>     @param[in]  Expression  Expression to be evaluated for TRUE.
> >>   **/
> >>   #define UT_ASSERT_TRUE(Expression)                                                                 \
> >> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
> >>     }
> >>
> >> @@ -360,7 +360,7 @@ SaveFrameworkState (
> >>     @param[in]  Expression  Expression to be evaluated for FALSE.
> >>   **/
> >>   #define UT_ASSERT_FALSE(Expression)                                                                 \
> >> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
> >>     }
> >>
> >> @@ -373,7 +373,7 @@ SaveFrameworkState (
> >>     @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
> >>   **/
> >>   #define UT_ASSERT_EQUAL(ValueA, ValueB)
> \
> >> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> #ValueA, #ValueB)) { \
> >> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
> #ValueB)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;
> \
> >>     }
> >>
> >> @@ -387,7 +387,7 @@ SaveFrameworkState (
> >>     @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
> >>   **/
> >>   #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
> >> \
> >> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
> DEBUG_LINE_NUMBER,
> >> __FILE__, #BufferA, #BufferB)) { \
> >> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
> DEBUG_LINE_NUMBER,
> >> __FILE__, #BufferA, #BufferB)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;
> >> \
> >>     }
> >>
> >> @@ -400,7 +400,7 @@ SaveFrameworkState (
> >>     @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
> >>   **/
> >>   #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
> \
> >> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> #ValueA, #ValueB)) { \
> >> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
> #ValueA, #ValueB)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;
> \
> >>     }
> >>
> >> @@ -412,7 +412,7 @@ SaveFrameworkState (
> >>     @param[in]  Status  EFI_STATUS value to check.
> >>   **/
> >>   #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> >> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
> >>     }
> >>
> >> @@ -425,7 +425,7 @@ SaveFrameworkState (
> >>     @param[in]  Expected  EFI_STATUS values to compare for equality.
> >>   **/
> >>   #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> >> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
> >>     }
> >>
> >> @@ -437,7 +437,7 @@ SaveFrameworkState (
> >>     @param[in]  Pointer  Pointer to be checked against NULL.
> >>   **/
> >>   #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> >> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>       return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
> >>     }
> >>
> >> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
> >>         }                                                                \
> >>         if (!UnitTestExpectAssertFailure (                               \
> >>                UnitTestJumpStatus,                                       \
> >> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> >> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>                #FunctionCall, Status)) {                                 \
> >>           return UNIT_TEST_ERROR_TEST_FAILED;                            \
> >>         }                                                                \
> >> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >> index 4c8773278c3c..617b0f4218b8 100644
> >> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
> >>     VOID
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>   }
> >>
> >>   /**
> >> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
> >>     IN      UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>     return Address;
> >>   }
> >>
> >> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
> >>     IN      UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>     return Address;
> >>   }
> >>
> >> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >> index 67a3387ff3c6..bb26fe013d8b 100644
> >> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
> >>     IN UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>     return Address;
> >>   }
> >>
> >> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
> >>     VOID
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>   }
> >>
> >>   /**
> >> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
> >>     IN      UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>     return Address;
> >>   }
> >>
> >> @@ -152,7 +152,7 @@ WriteBackDataCache (
> >>     VOID
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>   }
> >>
> >>   /**
> >> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
> >>     IN      UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>     return Address;
> >>   }
> >>
> >> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
> >>     IN      UINTN  Length
> >>     )
> >>   {
> >> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>     return Address;
> >>   }
> >> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
> >> index b75b33381732..954d3f8c8988 100644
> >> --- a/MdePkg/Library/BaseLib/SafeString.c
> >> +++ b/MdePkg/Library/BaseLib/SafeString.c
> >> @@ -17,7 +17,7 @@
> >>       if (!(Expression)) { \
> >>         DEBUG ((DEBUG_VERBOSE, \
> >>           "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> >> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>         return Status; \
> >>       } \
> >>     } while (FALSE)
> >> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >> index f47301de8982..a23113f9c91d 100644
> >> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
> >>     CONST RED_BLACK_TREE_NODE  *Last;
> >>     CONST RED_BLACK_TREE_NODE  *Node;
> >>
> >> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
> >> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> >>
> >>     //
> >>     // property #5
> >> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
> >>     DEBUG ((
> >>       DEBUG_VERBOSE,
> >>       "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> >> -    __FUNCTION__,
> >> +    __func__,
> >>       Tree,
> >>       (INT64)BlackHeight,
> >>       (INT64)ForwardCount
> >> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >> index 82129aa44598..46aea515924f 100644
> >> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
> >>     RngProtocol = NULL;
> >>
> >>     if (Buffer == NULL) {
> >> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> >> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
> >>       return EFI_INVALID_PARAMETER;
> >>     }
> >>
> >>     Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
> >>     if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> >> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> >> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
> >>       return Status;
> >>     }
> >>
> >>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> >> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
> >> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
> >>     if (!EFI_ERROR (Status)) {
> >>       return Status;
> >>     }
> >>
> >>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> >> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
> >> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
> >>     if (!EFI_ERROR (Status)) {
> >>       return Status;
> >>     }
> >>
> >>     Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> >> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>     if (!EFI_ERROR (Status)) {
> >>       return Status;
> >>     }
> >>
> >>     // If all the other methods have failed, use the default method from the RngProtocol
> >>     Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
> >> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>     if (!EFI_ERROR (Status)) {
> >>       return Status;
> >>     }
> >>
> >>     // If we get to this point, we have failed
> >> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
> >> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
> >>
> >>     return Status;
> >>   }// GenerateRandomNumberViaNist800Algorithm()
> >> --
> >> 2.30.2
> >>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
> >
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
  2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
@ 2023-03-17  4:23   ` Sunil V L
  1 sibling, 0 replies; 26+ messages in thread
From: Sunil V L @ 2023-03-17  4:23 UTC (permalink / raw)
  To: devel, quic_rcran
  Cc: Michael D Kinney, Liming Gao, Zhiguang Liu, Rebecca Cran

On Thu, Feb 09, 2023 at 08:45:07AM -0700, Rebecca Cran wrote:
> __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
> MdePkg.
> 
> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> ---
Hi Rebecca,

Thank you for this effort!. After this gets merged (or once all
packages migrate to __func__), would CI fail if someone adds a new
__FUNCTION__ ?

Changes LGTM. You need to rebase and resolve a merge conflict.

Reviewed-by: Sunil V L <sunilvl@ventanamicro.com>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-14 20:40       ` Michael D Kinney
@ 2023-03-17 13:31         ` Rebecca Cran
  2023-03-17 15:16           ` Michael D Kinney
  0 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-03-17 13:31 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io, Gao, Liming,
	Liu, Zhiguang, Michael Kubacki, Sean Brogan

(+Michael Kubacki, Sean Brogan)

Mike, Michael, Sean:


This change is going to break building edk2 with anything older than 
Visual Studio 2015, which is where support for __func__ was added.

I checked and currently it appears that VS2013 builds edk2 but VS2012 
has errors. Given that the stuart tools don't support anything older 
than VS2017 I'm thinking this is okay, but I want to double check before 
pushing this change.


-- 

Rebecca Cran


On 3/14/23 2:40 PM, Kinney, Michael D wrote:
> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>> Sent: Monday, March 13, 2023 7:20 PM
>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
>> Liu, Zhiguang <zhiguang.liu@intel.com>
>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>
>> Mike,
>>
>>
>> I think your concerns with this patch were addressed?
>>
>> Could you add a Reviewed-by please?
>>
>>
>> Thanks.
>> Rebecca
>>
>>
>> On 2/9/23 6:01 PM, Michael D Kinney wrote:
>>> Hi Rebecca,
>>>
>>> Did this pass EDK II CI?
>>>
>>> This change does break EBC compiler builds.  The following has to be added to
>>> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
>>>
>>>       #define __func__ __FUNCTION__
>>>
>>> I also see __FUNCTION__ used in many packages.  I am wondering if we want
>>> to do this clean up if it should be its own patch series and update all
>>> packages in once series.
>>>
>>> Mike
>>>
>>>> -----Original Message-----
>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>>>> Sent: Thursday, February 9, 2023 7:45 AM
>>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
>> Liu, Zhiguang
>>>> <zhiguang.liu@intel.com>
>>>> Cc: Rebecca Cran <rebecca@quicinc.com>
>>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>>>
>>>> __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
>>>> MdePkg.
>>>>
>>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>>>> ---
>>>>    MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>>>>    MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
>> ---
>>>>    MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>>>>    MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>>>>    MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>>>>    MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>>>>    MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>>>>    7 files changed, 34 insertions(+), 34 deletions(-)
>>>>
>>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
>>>> index 34ec956b9c0e..d0f2dfb070d5 100644
>>>> --- a/MdePkg/Include/Library/PerformanceLib.h
>>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
>>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_EVENT_SIGNAL_END(EventGuid) \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_CALLBACK_END(TriggerGuid) \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_FUNCTION_BEGIN() \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>>>>    #define PERF_FUNCTION_END() \
>>>>      do { \
>>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
>>>>        } \
>>>>      } while (FALSE)
>>>>
>>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
>>>> index 71c205b1b143..321a310602d7 100644
>>>> --- a/MdePkg/Include/Library/UnitTestLib.h
>>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
>>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
>>>>      @param[in]  Expression  Expression to be evaluated for TRUE.
>>>>    **/
>>>>    #define UT_ASSERT_TRUE(Expression)                                                                 \
>>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>>>>      }
>>>>
>>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
>>>>      @param[in]  Expression  Expression to be evaluated for FALSE.
>>>>    **/
>>>>    #define UT_ASSERT_FALSE(Expression)                                                                 \
>>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>>>>      }
>>>>
>>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
>>>>      @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>>>>    **/
>>>>    #define UT_ASSERT_EQUAL(ValueA, ValueB)
>> \
>>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>> #ValueA, #ValueB)) { \
>>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
>> #ValueB)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;
>> \
>>>>      }
>>>>
>>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
>>>>      @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>>>>    **/
>>>>    #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
>>>> \
>>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
>> DEBUG_LINE_NUMBER,
>>>> __FILE__, #BufferA, #BufferB)) { \
>>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
>> DEBUG_LINE_NUMBER,
>>>> __FILE__, #BufferA, #BufferB)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;
>>>> \
>>>>      }
>>>>
>>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
>>>>      @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>>>>    **/
>>>>    #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
>> \
>>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>> #ValueA, #ValueB)) { \
>>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
>> #ValueA, #ValueB)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;
>> \
>>>>      }
>>>>
>>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
>>>>      @param[in]  Status  EFI_STATUS value to check.
>>>>    **/
>>>>    #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
>>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>>>>      }
>>>>
>>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
>>>>      @param[in]  Expected  EFI_STATUS values to compare for equality.
>>>>    **/
>>>>    #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
>>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>>>>      }
>>>>
>>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
>>>>      @param[in]  Pointer  Pointer to be checked against NULL.
>>>>    **/
>>>>    #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
>>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>>>>      }
>>>>
>>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>>>>          }                                                                \
>>>>          if (!UnitTestExpectAssertFailure (                               \
>>>>                 UnitTestJumpStatus,                                       \
>>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>>                 #FunctionCall, Status)) {                                 \
>>>>            return UNIT_TEST_ERROR_TEST_FAILED;                            \
>>>>          }                                                                \
>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>> index 4c8773278c3c..617b0f4218b8 100644
>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>>>>      VOID
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>    }
>>>>
>>>>    /**
>>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>>>>      IN      UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>      return Address;
>>>>    }
>>>>
>>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>>>>      IN      UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>      return Address;
>>>>    }
>>>>
>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>> index 67a3387ff3c6..bb26fe013d8b 100644
>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>>>>      IN UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>      return Address;
>>>>    }
>>>>
>>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>>>>      VOID
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>    }
>>>>
>>>>    /**
>>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>>>>      IN      UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>      return Address;
>>>>    }
>>>>
>>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
>>>>      VOID
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>    }
>>>>
>>>>    /**
>>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>>>>      IN      UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>      return Address;
>>>>    }
>>>>
>>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>>>>      IN      UINTN  Length
>>>>      )
>>>>    {
>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>      return Address;
>>>>    }
>>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
>>>> index b75b33381732..954d3f8c8988 100644
>>>> --- a/MdePkg/Library/BaseLib/SafeString.c
>>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
>>>> @@ -17,7 +17,7 @@
>>>>        if (!(Expression)) { \
>>>>          DEBUG ((DEBUG_VERBOSE, \
>>>>            "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
>>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>>          return Status; \
>>>>        } \
>>>>      } while (FALSE)
>>>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>> index f47301de8982..a23113f9c91d 100644
>>>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>>>>      CONST RED_BLACK_TREE_NODE  *Last;
>>>>      CONST RED_BLACK_TREE_NODE  *Node;
>>>>
>>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
>>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
>>>>
>>>>      //
>>>>      // property #5
>>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>>>>      DEBUG ((
>>>>        DEBUG_VERBOSE,
>>>>        "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>>>> -    __FUNCTION__,
>>>> +    __func__,
>>>>        Tree,
>>>>        (INT64)BlackHeight,
>>>>        (INT64)ForwardCount
>>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>> index 82129aa44598..46aea515924f 100644
>>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>>>>      RngProtocol = NULL;
>>>>
>>>>      if (Buffer == NULL) {
>>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
>>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>>>>        return EFI_INVALID_PARAMETER;
>>>>      }
>>>>
>>>>      Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>>>>      if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
>>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
>>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
>>>>        return Status;
>>>>      }
>>>>
>>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
>>>>      if (!EFI_ERROR (Status)) {
>>>>        return Status;
>>>>      }
>>>>
>>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
>>>>      if (!EFI_ERROR (Status)) {
>>>>        return Status;
>>>>      }
>>>>
>>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>>>      if (!EFI_ERROR (Status)) {
>>>>        return Status;
>>>>      }
>>>>
>>>>      // If all the other methods have failed, use the default method from the RngProtocol
>>>>      Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>>>      if (!EFI_ERROR (Status)) {
>>>>        return Status;
>>>>      }
>>>>
>>>>      // If we get to this point, we have failed
>>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
>>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
>>>>
>>>>      return Status;
>>>>    }// GenerateRandomNumberViaNist800Algorithm()
>>>> --
>>>> 2.30.2
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>
>> 
>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-17 13:31         ` Rebecca Cran
@ 2023-03-17 15:16           ` Michael D Kinney
  2023-03-22 16:58             ` Michael D Kinney
  0 siblings, 1 reply; 26+ messages in thread
From: Michael D Kinney @ 2023-03-17 15:16 UTC (permalink / raw)
  To: devel@edk2.groups.io, rebecca@bsdio.com, Gao, Liming,
	Liu, Zhiguang, Michael Kubacki, Sean Brogan
  Cc: Kinney, Michael D

Hi Rebecca,

For older compilers that do not support __func__, I believe a workaround
could be added to define __func__ to __FUNCTION__.  We do not need to do
this for any of these patches.  It can be something consumers can do if
they really want to use an older compiler.

You can try it out on VS2012 locally.  If it works, then you can mention
that workaround in the commit message.

Do we have any information on GCC/CLANG compatibility for this feature?

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Friday, March 17, 2023 6:32 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> (+Michael Kubacki, Sean Brogan)
> 
> Mike, Michael, Sean:
> 
> 
> This change is going to break building edk2 with anything older than
> Visual Studio 2015, which is where support for __func__ was added.
> 
> I checked and currently it appears that VS2013 builds edk2 but VS2012
> has errors. Given that the stuart tools don't support anything older
> than VS2017 I'm thinking this is okay, but I want to double check before
> pushing this change.
> 
> 
> --
> 
> Rebecca Cran
> 
> 
> On 3/14/23 2:40 PM, Kinney, Michael D wrote:
> > Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> >
> >
> >> -----Original Message-----
> >> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >> Sent: Monday, March 13, 2023 7:20 PM
> >> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> >> Liu, Zhiguang <zhiguang.liu@intel.com>
> >> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>
> >> Mike,
> >>
> >>
> >> I think your concerns with this patch were addressed?
> >>
> >> Could you add a Reviewed-by please?
> >>
> >>
> >> Thanks.
> >> Rebecca
> >>
> >>
> >> On 2/9/23 6:01 PM, Michael D Kinney wrote:
> >>> Hi Rebecca,
> >>>
> >>> Did this pass EDK II CI?
> >>>
> >>> This change does break EBC compiler builds.  The following has to be added to
> >>> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> >>>
> >>>       #define __func__ __FUNCTION__
> >>>
> >>> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> >>> to do this clean up if it should be its own patch series and update all
> >>> packages in once series.
> >>>
> >>> Mike
> >>>
> >>>> -----Original Message-----
> >>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >>>> Sent: Thursday, February 9, 2023 7:45 AM
> >>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> >> Liu, Zhiguang
> >>>> <zhiguang.liu@intel.com>
> >>>> Cc: Rebecca Cran <rebecca@quicinc.com>
> >>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>>>
> >>>> __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
> >>>> MdePkg.
> >>>>
> >>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> >>>> ---
> >>>>    MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
> >>>>    MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
> >> ---
> >>>>    MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
> >>>>    MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
> >>>>    MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
> >>>>    MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
> >>>>    MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
> >>>>    7 files changed, 34 insertions(+), 34 deletions(-)
> >>>>
> >>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
> >>>> index 34ec956b9c0e..d0f2dfb070d5 100644
> >>>> --- a/MdePkg/Include/Library/PerformanceLib.h
> >>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
> >>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_EVENT_SIGNAL_END(EventGuid) \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_CALLBACK_BEGIN(TriggerGuid) \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_CALLBACK_END(TriggerGuid) \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_FUNCTION_BEGIN() \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
> >>>>    #define PERF_FUNCTION_END() \
> >>>>      do { \
> >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>>
> >>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
> >>>> index 71c205b1b143..321a310602d7 100644
> >>>> --- a/MdePkg/Include/Library/UnitTestLib.h
> >>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
> >>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Expression  Expression to be evaluated for TRUE.
> >>>>    **/
> >>>>    #define UT_ASSERT_TRUE(Expression)                                                                 \
> >>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
> >>>>      }
> >>>>
> >>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Expression  Expression to be evaluated for FALSE.
> >>>>    **/
> >>>>    #define UT_ASSERT_FALSE(Expression)                                                                 \
> >>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
> >>>>      }
> >>>>
> >>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
> >>>>      @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
> >>>>    **/
> >>>>    #define UT_ASSERT_EQUAL(ValueA, ValueB)
> >> \
> >>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >> #ValueA, #ValueB)) { \
> >>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
> >> #ValueB)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> >> \
> >>>>      }
> >>>>
> >>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
> >>>>    **/
> >>>>    #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
> >>>> \
> >>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
> >> DEBUG_LINE_NUMBER,
> >>>> __FILE__, #BufferA, #BufferB)) { \
> >>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
> >> DEBUG_LINE_NUMBER,
> >>>> __FILE__, #BufferA, #BufferB)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> >>>> \
> >>>>      }
> >>>>
> >>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
> >>>>      @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
> >>>>    **/
> >>>>    #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
> >> \
> >>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >> #ValueA, #ValueB)) { \
> >>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
> >> #ValueA, #ValueB)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> >> \
> >>>>      }
> >>>>
> >>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Status  EFI_STATUS value to check.
> >>>>    **/
> >>>>    #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> >>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
> >>>>      }
> >>>>
> >>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Expected  EFI_STATUS values to compare for equality.
> >>>>    **/
> >>>>    #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> >>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
> >>>>      }
> >>>>
> >>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
> >>>>      @param[in]  Pointer  Pointer to be checked against NULL.
> >>>>    **/
> >>>>    #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> >>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
> >>>>      }
> >>>>
> >>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
> >>>>          }                                                                \
> >>>>          if (!UnitTestExpectAssertFailure (                               \
> >>>>                 UnitTestJumpStatus,                                       \
> >>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>>                 #FunctionCall, Status)) {                                 \
> >>>>            return UNIT_TEST_ERROR_TEST_FAILED;                            \
> >>>>          }                                                                \
> >>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>> index 4c8773278c3c..617b0f4218b8 100644
> >>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
> >>>>      VOID
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>    }
> >>>>
> >>>>    /**
> >>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>      IN      UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>>
> >>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
> >>>>      IN      UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>>
> >>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>> index 67a3387ff3c6..bb26fe013d8b 100644
> >>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
> >>>>      IN UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>>
> >>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
> >>>>      VOID
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>    }
> >>>>
> >>>>    /**
> >>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>      IN      UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>>
> >>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
> >>>>      VOID
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>    }
> >>>>
> >>>>    /**
> >>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
> >>>>      IN      UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>>
> >>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
> >>>>      IN      UINTN  Length
> >>>>      )
> >>>>    {
> >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>      return Address;
> >>>>    }
> >>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
> >>>> index b75b33381732..954d3f8c8988 100644
> >>>> --- a/MdePkg/Library/BaseLib/SafeString.c
> >>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
> >>>> @@ -17,7 +17,7 @@
> >>>>        if (!(Expression)) { \
> >>>>          DEBUG ((DEBUG_VERBOSE, \
> >>>>            "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> >>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>>          return Status; \
> >>>>        } \
> >>>>      } while (FALSE)
> >>>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>> index f47301de8982..a23113f9c91d 100644
> >>>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
> >>>>      CONST RED_BLACK_TREE_NODE  *Last;
> >>>>      CONST RED_BLACK_TREE_NODE  *Node;
> >>>>
> >>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
> >>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> >>>>
> >>>>      //
> >>>>      // property #5
> >>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
> >>>>      DEBUG ((
> >>>>        DEBUG_VERBOSE,
> >>>>        "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> >>>> -    __FUNCTION__,
> >>>> +    __func__,
> >>>>        Tree,
> >>>>        (INT64)BlackHeight,
> >>>>        (INT64)ForwardCount
> >>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>> index 82129aa44598..46aea515924f 100644
> >>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
> >>>>      RngProtocol = NULL;
> >>>>
> >>>>      if (Buffer == NULL) {
> >>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> >>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
> >>>>        return EFI_INVALID_PARAMETER;
> >>>>      }
> >>>>
> >>>>      Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
> >>>>      if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> >>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> >>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
> >>>>        return Status;
> >>>>      }
> >>>>
> >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
> >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
> >>>>      if (!EFI_ERROR (Status)) {
> >>>>        return Status;
> >>>>      }
> >>>>
> >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
> >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
> >>>>      if (!EFI_ERROR (Status)) {
> >>>>        return Status;
> >>>>      }
> >>>>
> >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>>>      if (!EFI_ERROR (Status)) {
> >>>>        return Status;
> >>>>      }
> >>>>
> >>>>      // If all the other methods have failed, use the default method from the RngProtocol
> >>>>      Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
> >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>>>      if (!EFI_ERROR (Status)) {
> >>>>        return Status;
> >>>>      }
> >>>>
> >>>>      // If we get to this point, we have failed
> >>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
> >>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
> >>>>
> >>>>      return Status;
> >>>>    }// GenerateRandomNumberViaNist800Algorithm()
> >>>> --
> >>>> 2.30.2
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-17 15:16           ` Michael D Kinney
@ 2023-03-22 16:58             ` Michael D Kinney
  2023-03-22 17:45               ` Rebecca Cran
  0 siblings, 1 reply; 26+ messages in thread
From: Michael D Kinney @ 2023-03-22 16:58 UTC (permalink / raw)
  To: devel@edk2.groups.io, rebecca@bsdio.com, Gao, Liming,
	Liu, Zhiguang, Michael Kubacki, Sean Brogan
  Cc: Kinney, Michael D

Hi Rebecca,

It appears that some of the older release of VS2015 do not support
__func__.

Can you please work on a patch that implements the workaround?

Thanks,

Mike

> -----Original Message-----
> From: Kinney, Michael D <michael.d.kinney@intel.com>
> Sent: Friday, March 17, 2023 8:16 AM
> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: RE: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> Hi Rebecca,
> 
> For older compilers that do not support __func__, I believe a workaround
> could be added to define __func__ to __FUNCTION__.  We do not need to do
> this for any of these patches.  It can be something consumers can do if
> they really want to use an older compiler.
> 
> You can try it out on VS2012 locally.  If it works, then you can mention
> that workaround in the commit message.
> 
> Do we have any information on GCC/CLANG compatibility for this feature?
> 
> Mike
> 
> > -----Original Message-----
> > From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> > Sent: Friday, March 17, 2023 6:32 AM
> > To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> > <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> > Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >
> > (+Michael Kubacki, Sean Brogan)
> >
> > Mike, Michael, Sean:
> >
> >
> > This change is going to break building edk2 with anything older than
> > Visual Studio 2015, which is where support for __func__ was added.
> >
> > I checked and currently it appears that VS2013 builds edk2 but VS2012
> > has errors. Given that the stuart tools don't support anything older
> > than VS2017 I'm thinking this is okay, but I want to double check before
> > pushing this change.
> >
> >
> > --
> >
> > Rebecca Cran
> >
> >
> > On 3/14/23 2:40 PM, Kinney, Michael D wrote:
> > > Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> > >
> > >
> > >> -----Original Message-----
> > >> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> > >> Sent: Monday, March 13, 2023 7:20 PM
> > >> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> > >> Liu, Zhiguang <zhiguang.liu@intel.com>
> > >> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> > >>
> > >> Mike,
> > >>
> > >>
> > >> I think your concerns with this patch were addressed?
> > >>
> > >> Could you add a Reviewed-by please?
> > >>
> > >>
> > >> Thanks.
> > >> Rebecca
> > >>
> > >>
> > >> On 2/9/23 6:01 PM, Michael D Kinney wrote:
> > >>> Hi Rebecca,
> > >>>
> > >>> Did this pass EDK II CI?
> > >>>
> > >>> This change does break EBC compiler builds.  The following has to be added to
> > >>> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> > >>>
> > >>>       #define __func__ __FUNCTION__
> > >>>
> > >>> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> > >>> to do this clean up if it should be its own patch series and update all
> > >>> packages in once series.
> > >>>
> > >>> Mike
> > >>>
> > >>>> -----Original Message-----
> > >>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> > >>>> Sent: Thursday, February 9, 2023 7:45 AM
> > >>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> > >> Liu, Zhiguang
> > >>>> <zhiguang.liu@intel.com>
> > >>>> Cc: Rebecca Cran <rebecca@quicinc.com>
> > >>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> > >>>>
> > >>>> __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
> > >>>> MdePkg.
> > >>>>
> > >>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> > >>>> ---
> > >>>>    MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
> > >>>>    MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
> > >> ---
> > >>>>    MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
> > >>>>    MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
> > >>>>    MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
> > >>>>    MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
> > >>>>    MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
> > >>>>    7 files changed, 34 insertions(+), 34 deletions(-)
> > >>>>
> > >>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
> > >>>> index 34ec956b9c0e..d0f2dfb070d5 100644
> > >>>> --- a/MdePkg/Include/Library/PerformanceLib.h
> > >>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
> > >>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_EVENT_SIGNAL_END(EventGuid) \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_CALLBACK_BEGIN(TriggerGuid) \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_CALLBACK_END(TriggerGuid) \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_FUNCTION_BEGIN() \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
> > >>>>    #define PERF_FUNCTION_END() \
> > >>>>      do { \
> > >>>>        if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> > >>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> > >>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>>
> > >>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
> > >>>> index 71c205b1b143..321a310602d7 100644
> > >>>> --- a/MdePkg/Include/Library/UnitTestLib.h
> > >>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
> > >>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Expression  Expression to be evaluated for TRUE.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_TRUE(Expression)                                                                 \
> > >>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> > >>>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
> > >>>>      }
> > >>>>
> > >>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Expression  Expression to be evaluated for FALSE.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_FALSE(Expression)                                                                 \
> > >>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> > >>>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
> > >>>>      }
> > >>>>
> > >>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
> > >>>>    **/
> > >>>>    #define UT_ASSERT_EQUAL(ValueA, ValueB)
> > >> \
> > >>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> > >> #ValueA, #ValueB)) { \
> > >>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
> > >> #ValueB)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> > >> \
> > >>>>      }
> > >>>>
> > >>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
> > >>>> \
> > >>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
> > >> DEBUG_LINE_NUMBER,
> > >>>> __FILE__, #BufferA, #BufferB)) { \
> > >>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
> > >> DEBUG_LINE_NUMBER,
> > >>>> __FILE__, #BufferA, #BufferB)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> > >>>> \
> > >>>>      }
> > >>>>
> > >>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
> > >>>>    **/
> > >>>>    #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
> > >> \
> > >>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> > >> #ValueA, #ValueB)) { \
> > >>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
> > >> #ValueA, #ValueB)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;
> > >> \
> > >>>>      }
> > >>>>
> > >>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Status  EFI_STATUS value to check.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> > >>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> > >>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
> > >>>>      }
> > >>>>
> > >>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Expected  EFI_STATUS values to compare for equality.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> > >>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> > >>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
> > >>>>      }
> > >>>>
> > >>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
> > >>>>      @param[in]  Pointer  Pointer to be checked against NULL.
> > >>>>    **/
> > >>>>    #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> > >>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> > >>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> > >>>>        return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
> > >>>>      }
> > >>>>
> > >>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
> > >>>>          }                                                                \
> > >>>>          if (!UnitTestExpectAssertFailure (                               \
> > >>>>                 UnitTestJumpStatus,                                       \
> > >>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> > >>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
> > >>>>                 #FunctionCall, Status)) {                                 \
> > >>>>            return UNIT_TEST_ERROR_TEST_FAILED;                            \
> > >>>>          }                                                                \
> > >>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> > >> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> > >>>> index 4c8773278c3c..617b0f4218b8 100644
> > >>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> > >>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> > >>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
> > >>>>      VOID
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> > >>>>    }
> > >>>>
> > >>>>    /**
> > >>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
> > >>>>      IN      UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>>
> > >>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
> > >>>>      IN      UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>>
> > >>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > >> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > >>>> index 67a3387ff3c6..bb26fe013d8b 100644
> > >>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > >>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> > >>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
> > >>>>      IN UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>>
> > >>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
> > >>>>      VOID
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>    }
> > >>>>
> > >>>>    /**
> > >>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
> > >>>>      IN      UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>>
> > >>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
> > >>>>      VOID
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>    }
> > >>>>
> > >>>>    /**
> > >>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
> > >>>>      IN      UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>>
> > >>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
> > >>>>      IN      UINTN  Length
> > >>>>      )
> > >>>>    {
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> > >>>>      return Address;
> > >>>>    }
> > >>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
> > >>>> index b75b33381732..954d3f8c8988 100644
> > >>>> --- a/MdePkg/Library/BaseLib/SafeString.c
> > >>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
> > >>>> @@ -17,7 +17,7 @@
> > >>>>        if (!(Expression)) { \
> > >>>>          DEBUG ((DEBUG_VERBOSE, \
> > >>>>            "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> > >>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> > >>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> > >>>>          return Status; \
> > >>>>        } \
> > >>>>      } while (FALSE)
> > >>>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> > >>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> > >>>> index f47301de8982..a23113f9c91d 100644
> > >>>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> > >>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> > >>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
> > >>>>      CONST RED_BLACK_TREE_NODE  *Last;
> > >>>>      CONST RED_BLACK_TREE_NODE  *Node;
> > >>>>
> > >>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
> > >>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> > >>>>
> > >>>>      //
> > >>>>      // property #5
> > >>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
> > >>>>      DEBUG ((
> > >>>>        DEBUG_VERBOSE,
> > >>>>        "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> > >>>> -    __FUNCTION__,
> > >>>> +    __func__,
> > >>>>        Tree,
> > >>>>        (INT64)BlackHeight,
> > >>>>        (INT64)ForwardCount
> > >>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> > >>>> index 82129aa44598..46aea515924f 100644
> > >>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> > >>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> > >>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
> > >>>>      RngProtocol = NULL;
> > >>>>
> > >>>>      if (Buffer == NULL) {
> > >>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> > >>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
> > >>>>        return EFI_INVALID_PARAMETER;
> > >>>>      }
> > >>>>
> > >>>>      Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
> > >>>>      if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> > >>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> > >>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
> > >>>>        return Status;
> > >>>>      }
> > >>>>
> > >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> > >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
> > >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
> > >>>>      if (!EFI_ERROR (Status)) {
> > >>>>        return Status;
> > >>>>      }
> > >>>>
> > >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> > >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
> > >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
> > >>>>      if (!EFI_ERROR (Status)) {
> > >>>>        return Status;
> > >>>>      }
> > >>>>
> > >>>>      Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> > >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> > >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> > >>>>      if (!EFI_ERROR (Status)) {
> > >>>>        return Status;
> > >>>>      }
> > >>>>
> > >>>>      // If all the other methods have failed, use the default method from the RngProtocol
> > >>>>      Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
> > >>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> > >>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> > >>>>      if (!EFI_ERROR (Status)) {
> > >>>>        return Status;
> > >>>>      }
> > >>>>
> > >>>>      // If we get to this point, we have failed
> > >>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
> > >>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
> > >>>>
> > >>>>      return Status;
> > >>>>    }// GenerateRandomNumberViaNist800Algorithm()
> > >>>> --
> > >>>> 2.30.2
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>
> > >>
> > >>
> >
> >
> > 
> >


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-22 16:58             ` Michael D Kinney
@ 2023-03-22 17:45               ` Rebecca Cran
  2023-03-23  0:58                 ` Michael D Kinney
  0 siblings, 1 reply; 26+ messages in thread
From: Rebecca Cran @ 2023-03-22 17:45 UTC (permalink / raw)
  To: Kinney, Michael D, devel@edk2.groups.io, Gao, Liming,
	Liu, Zhiguang, Michael Kubacki, Sean Brogan

Can we not require that VS2015 Update 3 is installed?

Do people have reasons to be running older builds, or is it just that 
they forget to install the updates?


-- 
Rebecca Cran


On 3/22/23 10:58 AM, Kinney, Michael D wrote:
> Hi Rebecca,
>
> It appears that some of the older release of VS2015 do not support
> __func__.
>
> Can you please work on a patch that implements the workaround?
>
> Thanks,
>
> Mike
>
>> -----Original Message-----
>> From: Kinney, Michael D <michael.d.kinney@intel.com>
>> Sent: Friday, March 17, 2023 8:16 AM
>> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
>> Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>> Subject: RE: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>
>> Hi Rebecca,
>>
>> For older compilers that do not support __func__, I believe a workaround
>> could be added to define __func__ to __FUNCTION__.  We do not need to do
>> this for any of these patches.  It can be something consumers can do if
>> they really want to use an older compiler.
>>
>> You can try it out on VS2012 locally.  If it works, then you can mention
>> that workaround in the commit message.
>>
>> Do we have any information on GCC/CLANG compatibility for this feature?
>>
>> Mike
>>
>>> -----Original Message-----
>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>>> Sent: Friday, March 17, 2023 6:32 AM
>>> To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
>>> <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>>
>>> (+Michael Kubacki, Sean Brogan)
>>>
>>> Mike, Michael, Sean:
>>>
>>>
>>> This change is going to break building edk2 with anything older than
>>> Visual Studio 2015, which is where support for __func__ was added.
>>>
>>> I checked and currently it appears that VS2013 builds edk2 but VS2012
>>> has errors. Given that the stuart tools don't support anything older
>>> than VS2017 I'm thinking this is okay, but I want to double check before
>>> pushing this change.
>>>
>>>
>>> --
>>>
>>> Rebecca Cran
>>>
>>>
>>> On 3/14/23 2:40 PM, Kinney, Michael D wrote:
>>>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>>>>
>>>>
>>>>> -----Original Message-----
>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>>>>> Sent: Monday, March 13, 2023 7:20 PM
>>>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
>>>>> Liu, Zhiguang <zhiguang.liu@intel.com>
>>>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>>>>
>>>>> Mike,
>>>>>
>>>>>
>>>>> I think your concerns with this patch were addressed?
>>>>>
>>>>> Could you add a Reviewed-by please?
>>>>>
>>>>>
>>>>> Thanks.
>>>>> Rebecca
>>>>>
>>>>>
>>>>> On 2/9/23 6:01 PM, Michael D Kinney wrote:
>>>>>> Hi Rebecca,
>>>>>>
>>>>>> Did this pass EDK II CI?
>>>>>>
>>>>>> This change does break EBC compiler builds.  The following has to be added to
>>>>>> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
>>>>>>
>>>>>>        #define __func__ __FUNCTION__
>>>>>>
>>>>>> I also see __FUNCTION__ used in many packages.  I am wondering if we want
>>>>>> to do this clean up if it should be its own patch series and update all
>>>>>> packages in once series.
>>>>>>
>>>>>> Mike
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
>>>>>>> Sent: Thursday, February 9, 2023 7:45 AM
>>>>>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
>>>>> Liu, Zhiguang
>>>>>>> <zhiguang.liu@intel.com>
>>>>>>> Cc: Rebecca Cran <rebecca@quicinc.com>
>>>>>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>>>>>>>
>>>>>>> __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
>>>>>>> MdePkg.
>>>>>>>
>>>>>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>>>>>>> ---
>>>>>>>     MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>>>>>>>     MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
>>>>> ---
>>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>>>>>>>     MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>>>>>>>     MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>>>>>>>     MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>>>>>>>     7 files changed, 34 insertions(+), 34 deletions(-)
>>>>>>>
>>>>>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
>>>>>>> index 34ec956b9c0e..d0f2dfb070d5 100644
>>>>>>> --- a/MdePkg/Include/Library/PerformanceLib.h
>>>>>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
>>>>>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_EVENT_SIGNAL_END(EventGuid) \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_CALLBACK_END(TriggerGuid) \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_FUNCTION_BEGIN() \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>>>>>>>     #define PERF_FUNCTION_END() \
>>>>>>>       do { \
>>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>>
>>>>>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
>>>>>>> index 71c205b1b143..321a310602d7 100644
>>>>>>> --- a/MdePkg/Include/Library/UnitTestLib.h
>>>>>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
>>>>>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Expression  Expression to be evaluated for TRUE.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_TRUE(Expression)                                                                 \
>>>>>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Expression  Expression to be evaluated for FALSE.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_FALSE(Expression)                                                                 \
>>>>>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_EQUAL(ValueA, ValueB)
>>>>> \
>>>>>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>>>>> #ValueA, #ValueB)) { \
>>>>>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
>>>>> #ValueB)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
>>>>> \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
>>>>>>> \
>>>>>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
>>>>> DEBUG_LINE_NUMBER,
>>>>>>> __FILE__, #BufferA, #BufferB)) { \
>>>>>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
>>>>> DEBUG_LINE_NUMBER,
>>>>>>> __FILE__, #BufferA, #BufferB)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
>>>>>>> \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
>>>>> \
>>>>>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>>>>> #ValueA, #ValueB)) { \
>>>>>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
>>>>> #ValueA, #ValueB)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
>>>>> \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Status  EFI_STATUS value to check.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
>>>>>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Expected  EFI_STATUS values to compare for equality.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
>>>>>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
>>>>>>>       @param[in]  Pointer  Pointer to be checked against NULL.
>>>>>>>     **/
>>>>>>>     #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
>>>>>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>>>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>>>>>>>       }
>>>>>>>
>>>>>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>>>>>>>           }                                                                \
>>>>>>>           if (!UnitTestExpectAssertFailure (                               \
>>>>>>>                  UnitTestJumpStatus,                                       \
>>>>>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>>>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>>>>>                  #FunctionCall, Status)) {                                 \
>>>>>>>             return UNIT_TEST_ERROR_TEST_FAILED;                            \
>>>>>>>           }                                                                \
>>>>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>> index 4c8773278c3c..617b0f4218b8 100644
>>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>>>>>>>       VOID
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>>>>     }
>>>>>>>
>>>>>>>     /**
>>>>>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>>>>>>>       IN      UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>>
>>>>>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>>>>>>>       IN      UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>>
>>>>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>> index 67a3387ff3c6..bb26fe013d8b 100644
>>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>>>>>>>       IN UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>>
>>>>>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>>>>>>>       VOID
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>     }
>>>>>>>
>>>>>>>     /**
>>>>>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>>>>>>>       IN      UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>>
>>>>>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
>>>>>>>       VOID
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>     }
>>>>>>>
>>>>>>>     /**
>>>>>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>>>>>>>       IN      UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>>
>>>>>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>>>>>>>       IN      UINTN  Length
>>>>>>>       )
>>>>>>>     {
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
>>>>>>>       return Address;
>>>>>>>     }
>>>>>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
>>>>>>> index b75b33381732..954d3f8c8988 100644
>>>>>>> --- a/MdePkg/Library/BaseLib/SafeString.c
>>>>>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
>>>>>>> @@ -17,7 +17,7 @@
>>>>>>>         if (!(Expression)) { \
>>>>>>>           DEBUG ((DEBUG_VERBOSE, \
>>>>>>>             "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
>>>>>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>>>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>>>>>           return Status; \
>>>>>>>         } \
>>>>>>>       } while (FALSE)
>>>>>>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>>>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>>>>> index f47301de8982..a23113f9c91d 100644
>>>>>>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>>>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
>>>>>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>>>>>>>       CONST RED_BLACK_TREE_NODE  *Last;
>>>>>>>       CONST RED_BLACK_TREE_NODE  *Node;
>>>>>>>
>>>>>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
>>>>>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
>>>>>>>
>>>>>>>       //
>>>>>>>       // property #5
>>>>>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>>>>>>>       DEBUG ((
>>>>>>>         DEBUG_VERBOSE,
>>>>>>>         "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>>>>>>> -    __FUNCTION__,
>>>>>>> +    __func__,
>>>>>>>         Tree,
>>>>>>>         (INT64)BlackHeight,
>>>>>>>         (INT64)ForwardCount
>>>>>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>> index 82129aa44598..46aea515924f 100644
>>>>>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>>>>>>>       RngProtocol = NULL;
>>>>>>>
>>>>>>>       if (Buffer == NULL) {
>>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
>>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>>>>>>>         return EFI_INVALID_PARAMETER;
>>>>>>>       }
>>>>>>>
>>>>>>>       Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>>>>>>>       if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
>>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
>>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
>>>>>>>         return Status;
>>>>>>>       }
>>>>>>>
>>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
>>>>>>>       if (!EFI_ERROR (Status)) {
>>>>>>>         return Status;
>>>>>>>       }
>>>>>>>
>>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
>>>>>>>       if (!EFI_ERROR (Status)) {
>>>>>>>         return Status;
>>>>>>>       }
>>>>>>>
>>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>>>>>>       if (!EFI_ERROR (Status)) {
>>>>>>>         return Status;
>>>>>>>       }
>>>>>>>
>>>>>>>       // If all the other methods have failed, use the default method from the RngProtocol
>>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
>>>>>>>       if (!EFI_ERROR (Status)) {
>>>>>>>         return Status;
>>>>>>>       }
>>>>>>>
>>>>>>>       // If we get to this point, we have failed
>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
>>>>>>>
>>>>>>>       return Status;
>>>>>>>     }// GenerateRandomNumberViaNist800Algorithm()
>>>>>>> --
>>>>>>> 2.30.2
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>>> 
>>>

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-22 17:45               ` Rebecca Cran
@ 2023-03-23  0:58                 ` Michael D Kinney
  2023-03-23  1:43                   ` Huang, Yanbo
  0 siblings, 1 reply; 26+ messages in thread
From: Michael D Kinney @ 2023-03-23  0:58 UTC (permalink / raw)
  To: devel@edk2.groups.io, rebecca@bsdio.com, Gao, Liming,
	Liu, Zhiguang, Michael Kubacki, Sean Brogan
  Cc: Kinney, Michael D

Hi Rebecca,

Using latest release would be my preference as well and what EDK II should recommend.

We should document that the min supported version of VS2015 Update 3.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> Sent: Wednesday, March 22, 2023 10:46 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang
> <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> 
> Can we not require that VS2015 Update 3 is installed?
> 
> Do people have reasons to be running older builds, or is it just that
> they forget to install the updates?
> 
> 
> --
> Rebecca Cran
> 
> 
> On 3/22/23 10:58 AM, Kinney, Michael D wrote:
> > Hi Rebecca,
> >
> > It appears that some of the older release of VS2015 do not support
> > __func__.
> >
> > Can you please work on a patch that implements the workaround?
> >
> > Thanks,
> >
> > Mike
> >
> >> -----Original Message-----
> >> From: Kinney, Michael D <michael.d.kinney@intel.com>
> >> Sent: Friday, March 17, 2023 8:16 AM
> >> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
> >> Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> >> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> >> Subject: RE: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>
> >> Hi Rebecca,
> >>
> >> For older compilers that do not support __func__, I believe a workaround
> >> could be added to define __func__ to __FUNCTION__.  We do not need to do
> >> this for any of these patches.  It can be something consumers can do if
> >> they really want to use an older compiler.
> >>
> >> You can try it out on VS2012 locally.  If it works, then you can mention
> >> that workaround in the commit message.
> >>
> >> Do we have any information on GCC/CLANG compatibility for this feature?
> >>
> >> Mike
> >>
> >>> -----Original Message-----
> >>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >>> Sent: Friday, March 17, 2023 6:32 AM
> >>> To: Kinney, Michael D <michael.d.kinney@intel.com>; devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu,
> Zhiguang
> >>> <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> >>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>>
> >>> (+Michael Kubacki, Sean Brogan)
> >>>
> >>> Mike, Michael, Sean:
> >>>
> >>>
> >>> This change is going to break building edk2 with anything older than
> >>> Visual Studio 2015, which is where support for __func__ was added.
> >>>
> >>> I checked and currently it appears that VS2013 builds edk2 but VS2012
> >>> has errors. Given that the stuart tools don't support anything older
> >>> than VS2017 I'm thinking this is okay, but I want to double check before
> >>> pushing this change.
> >>>
> >>>
> >>> --
> >>>
> >>> Rebecca Cran
> >>>
> >>>
> >>> On 3/14/23 2:40 PM, Kinney, Michael D wrote:
> >>>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> >>>>
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >>>>> Sent: Monday, March 13, 2023 7:20 PM
> >>>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> >>>>> Liu, Zhiguang <zhiguang.liu@intel.com>
> >>>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>>>>
> >>>>> Mike,
> >>>>>
> >>>>>
> >>>>> I think your concerns with this patch were addressed?
> >>>>>
> >>>>> Could you add a Reviewed-by please?
> >>>>>
> >>>>>
> >>>>> Thanks.
> >>>>> Rebecca
> >>>>>
> >>>>>
> >>>>> On 2/9/23 6:01 PM, Michael D Kinney wrote:
> >>>>>> Hi Rebecca,
> >>>>>>
> >>>>>> Did this pass EDK II CI?
> >>>>>>
> >>>>>> This change does break EBC compiler builds.  The following has to be added to
> >>>>>> MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> >>>>>>
> >>>>>>        #define __func__ __FUNCTION__
> >>>>>>
> >>>>>> I also see __FUNCTION__ used in many packages.  I am wondering if we want
> >>>>>> to do this clean up if it should be its own patch series and update all
> >>>>>> packages in once series.
> >>>>>>
> >>>>>> Mike
> >>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca Cran
> >>>>>>> Sent: Thursday, February 9, 2023 7:45 AM
> >>>>>>> To: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>;
> >>>>> Liu, Zhiguang
> >>>>>>> <zhiguang.liu@intel.com>
> >>>>>>> Cc: Rebecca Cran <rebecca@quicinc.com>
> >>>>>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
> >>>>>>>
> >>>>>>> __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
> >>>>>>> MdePkg.
> >>>>>>>
> >>>>>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> >>>>>>> ---
> >>>>>>>     MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
> >>>>>>>     MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
> >>>>> ---
> >>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
> >>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
> >>>>>>>     MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
> >>>>>>>     MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
> >>>>>>>     MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
> >>>>>>>     7 files changed, 34 insertions(+), 34 deletions(-)
> >>>>>>>
> >>>>>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h b/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> index 34ec956b9c0e..d0f2dfb070d5 100644
> >>>>>>> --- a/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_EVENT_SIGNAL_END(EventGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_CALLBACK_BEGIN(TriggerGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_CALLBACK_END(TriggerGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_FUNCTION_BEGIN() \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_FUNCTION_END() \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h b/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> index 71c205b1b143..321a310602d7 100644
> >>>>>>> --- a/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expression  Expression to be evaluated for TRUE.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_TRUE(Expression)                                                                 \
> >>>>>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>> +  if(!UnitTestAssertTrue ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expression  Expression to be evaluated for FALSE.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_FALSE(Expression)                                                                 \
> >>>>>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>> +  if(!UnitTestAssertFalse ((Expression), __func__, DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_EQUAL(ValueA, ValueB)
> >>>>> \
> >>>>>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, #ValueA,
> >>>>> #ValueB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
> >>>>> \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length)
> >>>>>>> \
> >>>>>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
> >>>>> DEBUG_LINE_NUMBER,
> >>>>>>> __FILE__, #BufferA, #BufferB)) { \
> >>>>>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID *)(UINTN)(BufferB), (UINTN)Length, __func__,
> >>>>> DEBUG_LINE_NUMBER,
> >>>>>>> __FILE__, #BufferA, #BufferB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
> >>>>>>> \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
> >>>>> \
> >>>>>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
> >>>>> \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Status  EFI_STATUS value to check.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> >>>>>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expected  EFI_STATUS values to compare for equality.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> >>>>>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Pointer  Pointer to be checked against NULL.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> >>>>>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>>>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
> >>>>>>>           }                                                                \
> >>>>>>>           if (!UnitTestExpectAssertFailure (                               \
> >>>>>>>                  UnitTestJumpStatus,                                       \
> >>>>>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>>>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>>>>>                  #FunctionCall, Status)) {                                 \
> >>>>>>>             return UNIT_TEST_ERROR_TEST_FAILED;                            \
> >>>>>>>           }                                                                \
> >>>>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> index 4c8773278c3c..617b0f4218b8 100644
> >>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on LoongArch.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> diff --git a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> index 67a3387ff3c6..bb26fe013d8b 100644
> >>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
> >>>>>>>       IN UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c b/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> index b75b33381732..954d3f8c8988 100644
> >>>>>>> --- a/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> @@ -17,7 +17,7 @@
> >>>>>>>         if (!(Expression)) { \
> >>>>>>>           DEBUG ((DEBUG_VERBOSE, \
> >>>>>>>             "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> >>>>>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>>>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>>>>>           return Status; \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>> diff --git a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>>>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>>>>> index f47301de8982..a23113f9c91d 100644
> >>>>>>> --- a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>>>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
> >>>>>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
> >>>>>>>       CONST RED_BLACK_TREE_NODE  *Last;
> >>>>>>>       CONST RED_BLACK_TREE_NODE  *Node;
> >>>>>>>
> >>>>>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));
> >>>>>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> >>>>>>>
> >>>>>>>       //
> >>>>>>>       // property #5
> >>>>>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
> >>>>>>>       DEBUG ((
> >>>>>>>         DEBUG_VERBOSE,
> >>>>>>>         "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> >>>>>>> -    __FUNCTION__,
> >>>>>>> +    __func__,
> >>>>>>>         Tree,
> >>>>>>>         (INT64)BlackHeight,
> >>>>>>>         (INT64)ForwardCount
> >>>>>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> index 82129aa44598..46aea515924f 100644
> >>>>>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
> >>>>>>>       RngProtocol = NULL;
> >>>>>>>
> >>>>>>>       if (Buffer == NULL) {
> >>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> >>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
> >>>>>>>         return EFI_INVALID_PARAMETER;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
> >>>>>>>       if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> >>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __func__, Status));
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       // If all the other methods have failed, use the default method from the RngProtocol
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, NULL, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       // If we get to this point, we have failed
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", __func__, Status));
> >>>>>>>
> >>>>>>>       return Status;
> >>>>>>>     }// GenerateRandomNumberViaNist800Algorithm()
> >>>>>>> --
> >>>>>>> 2.30.2
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >>>
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-23  0:58                 ` Michael D Kinney
@ 2023-03-23  1:43                   ` Huang, Yanbo
  2023-03-23  1:46                     ` Rebecca Cran
  0 siblings, 1 reply; 26+ messages in thread
From: Huang, Yanbo @ 2023-03-23  1:43 UTC (permalink / raw)
  To: devel@edk2.groups.io, Kinney, Michael D, rebecca@bsdio.com,
	Gao, Liming, Liu, Zhiguang, Michael Kubacki, Sean Brogan

Hi Rebecca,

The commit message “Visual Studio versions before VS 2015 don't support __func__” may cause confuse since some of the older release of VS2015 also do not support __func__.
Some of my fellows report the error since they use the VS 2015 version before Update 3.

Best Regards,
Yanbo Huang

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney
Sent: Thursday, March 23, 2023 8:58 AM
To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
Cc: Kinney, Michael D <michael.d.kinney@intel.com>
Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__

Hi Rebecca,

Using latest release would be my preference as well and what EDK II should recommend.

We should document that the min supported version of VS2015 Update 3.

Mike

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca 
> Cran
> Sent: Wednesday, March 22, 2023 10:46 AM
> To: Kinney, Michael D <michael.d.kinney@intel.com>; 
> devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, 
> Zhiguang <zhiguang.liu@intel.com>; Michael Kubacki 
> <mikuback@linux.microsoft.com>; Sean Brogan 
> <sean.brogan@microsoft.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more 
> C11 compliant by using __func__
> 
> Can we not require that VS2015 Update 3 is installed?
> 
> Do people have reasons to be running older builds, or is it just that 
> they forget to install the updates?
> 
> 
> --
> Rebecca Cran
> 
> 
> On 3/22/23 10:58 AM, Kinney, Michael D wrote:
> > Hi Rebecca,
> >
> > It appears that some of the older release of VS2015 do not support 
> > __func__.
> >
> > Can you please work on a patch that implements the workaround?
> >
> > Thanks,
> >
> > Mike
> >
> >> -----Original Message-----
> >> From: Kinney, Michael D <michael.d.kinney@intel.com>
> >> Sent: Friday, March 17, 2023 8:16 AM
> >> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming 
> >> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; 
> >> Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan 
> >> <sean.brogan@microsoft.com>
> >> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> >> Subject: RE: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be 
> >> more C11 compliant by using __func__
> >>
> >> Hi Rebecca,
> >>
> >> For older compilers that do not support __func__, I believe a 
> >> workaround could be added to define __func__ to __FUNCTION__.  We 
> >> do not need to do this for any of these patches.  It can be 
> >> something consumers can do if they really want to use an older compiler.
> >>
> >> You can try it out on VS2012 locally.  If it works, then you can 
> >> mention that workaround in the commit message.
> >>
> >> Do we have any information on GCC/CLANG compatibility for this feature?
> >>
> >> Mike
> >>
> >>> -----Original Message-----
> >>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of 
> >>> Rebecca Cran
> >>> Sent: Friday, March 17, 2023 6:32 AM
> >>> To: Kinney, Michael D <michael.d.kinney@intel.com>; 
> >>> devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu,
> Zhiguang
> >>> <zhiguang.liu@intel.com>; Michael Kubacki 
> >>> <mikuback@linux.microsoft.com>; Sean Brogan 
> >>> <sean.brogan@microsoft.com>
> >>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be 
> >>> more C11 compliant by using __func__
> >>>
> >>> (+Michael Kubacki, Sean Brogan)
> >>>
> >>> Mike, Michael, Sean:
> >>>
> >>>
> >>> This change is going to break building edk2 with anything older 
> >>> than Visual Studio 2015, which is where support for __func__ was added.
> >>>
> >>> I checked and currently it appears that VS2013 builds edk2 but 
> >>> VS2012 has errors. Given that the stuart tools don't support 
> >>> anything older than VS2017 I'm thinking this is okay, but I want 
> >>> to double check before pushing this change.
> >>>
> >>>
> >>> --
> >>>
> >>> Rebecca Cran
> >>>
> >>>
> >>> On 3/14/23 2:40 PM, Kinney, Michael D wrote:
> >>>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
> >>>>
> >>>>
> >>>>> -----Original Message-----
> >>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of 
> >>>>> Rebecca Cran
> >>>>> Sent: Monday, March 13, 2023 7:20 PM
> >>>>> To: devel@edk2.groups.io; Kinney, Michael D 
> >>>>> <michael.d.kinney@intel.com>; Gao, Liming 
> >>>>> <gaoliming@byosoft.com.cn>; Liu, Zhiguang 
> >>>>> <zhiguang.liu@intel.com>
> >>>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be 
> >>>>> more C11 compliant by using __func__
> >>>>>
> >>>>> Mike,
> >>>>>
> >>>>>
> >>>>> I think your concerns with this patch were addressed?
> >>>>>
> >>>>> Could you add a Reviewed-by please?
> >>>>>
> >>>>>
> >>>>> Thanks.
> >>>>> Rebecca
> >>>>>
> >>>>>
> >>>>> On 2/9/23 6:01 PM, Michael D Kinney wrote:
> >>>>>> Hi Rebecca,
> >>>>>>
> >>>>>> Did this pass EDK II CI?
> >>>>>>
> >>>>>> This change does break EBC compiler builds.  The following has 
> >>>>>> to be added to MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
> >>>>>>
> >>>>>>        #define __func__ __FUNCTION__
> >>>>>>
> >>>>>> I also see __FUNCTION__ used in many packages.  I am wondering 
> >>>>>> if we want to do this clean up if it should be its own patch 
> >>>>>> series and update all packages in once series.
> >>>>>>
> >>>>>> Mike
> >>>>>>
> >>>>>>> -----Original Message-----
> >>>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of 
> >>>>>>> Rebecca Cran
> >>>>>>> Sent: Thursday, February 9, 2023 7:45 AM
> >>>>>>> To: devel@edk2.groups.io; Kinney, Michael D 
> >>>>>>> <michael.d.kinney@intel.com>; Gao, Liming 
> >>>>>>> <gaoliming@byosoft.com.cn>;
> >>>>> Liu, Zhiguang
> >>>>>>> <zhiguang.liu@intel.com>
> >>>>>>> Cc: Rebecca Cran <rebecca@quicinc.com>
> >>>>>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be 
> >>>>>>> more C11 compliant by using __func__
> >>>>>>>
> >>>>>>> __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 MdePkg.
> >>>>>>>
> >>>>>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
> >>>>>>> ---
> >>>>>>>     MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
> >>>>>>>     MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
> >>>>> ---
> >>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
> >>>>>>>     MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
> >>>>>>>     MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
> >>>>>>>     MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
> >>>>>>>     MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
> >>>>>>>     7 files changed, 34 insertions(+), 34 deletions(-)
> >>>>>>>
> >>>>>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h 
> >>>>>>> b/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> index 34ec956b9c0e..d0f2dfb070d5 100644
> >>>>>>> --- a/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
> >>>>>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, 
> >>>>>>> + EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_EVENT_SIGNAL_END(EventGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, 
> >>>>>>> + EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_CALLBACK_BEGIN(TriggerGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, 
> >>>>>>> + TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_CALLBACK_END(TriggerGuid) \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, 
> >>>>>>> + TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_FUNCTION_BEGIN() \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, 
> >>>>>>> + __func__ , 0, PERF_FUNCTION_START_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
> >>>>>>>     #define PERF_FUNCTION_END() \
> >>>>>>>       do { \
> >>>>>>>         if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
> >>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
> >>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, 
> >>>>>>> + __func__ , 0, PERF_FUNCTION_END_ID); \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>>
> >>>>>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h 
> >>>>>>> b/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> index 71c205b1b143..321a310602d7 100644
> >>>>>>> --- a/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
> >>>>>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expression  Expression to be evaluated for TRUE.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_TRUE(Expression)                                                                 \
> >>>>>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__, 
> >>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>> +  if(!UnitTestAssertTrue ((Expression), __func__, 
> >>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expression  Expression to be evaluated for FALSE.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_FALSE(Expression)                                                                 \
> >>>>>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__, 
> >>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>> +  if(!UnitTestAssertFalse ((Expression), __func__, 
> >>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_EQUAL(ValueA, ValueB)
> >>>>> \
> >>>>>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA), 
> >>>>>>> (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA), 
> >>>>>>> + (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__, 
> >>>>>>> + #ValueA,
> >>>>> #ValueB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
> >>>>> \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length) \
> >>>>>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID 
> >>>>>>> *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
> >>>>> DEBUG_LINE_NUMBER,
> >>>>>>> __FILE__, #BufferA, #BufferB)) { \
> >>>>>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID 
> >>>>>>> + *)(UINTN)(BufferB), (UINTN)Length, __func__,
> >>>>> DEBUG_LINE_NUMBER,
> >>>>>>> __FILE__, #BufferA, #BufferB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED; \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
> >>>>> \
> >>>>>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), 
> >>>>>>> (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA), 
> >>>>>>> + (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
> >>>>> #ValueA, #ValueB)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;
> >>>>> \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Status  EFI_STATUS value to check.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
> >>>>>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__, 
> >>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__, 
> >>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Expected  EFI_STATUS values to compare for equality.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
> >>>>>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected), 
> >>>>>>> __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected), 
> >>>>>>> + __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
> >>>>>>>       @param[in]  Pointer  Pointer to be checked against NULL.
> >>>>>>>     **/
> >>>>>>>     #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
> >>>>>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__, 
> >>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>>>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__, 
> >>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
> >>>>>>>         return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
> >>>>>>>       }
> >>>>>>>
> >>>>>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
> >>>>>>>           }                                                                \
> >>>>>>>           if (!UnitTestExpectAssertFailure (                               \
> >>>>>>>                  UnitTestJumpStatus,                                       \
> >>>>>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>>>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
> >>>>>>>                  #FunctionCall, Status)) {                                 \
> >>>>>>>             return UNIT_TEST_ERROR_TEST_FAILED;                            \
> >>>>>>>           }                                                                \
> >>>>>>> diff --git 
> >>>>>>> a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> index 4c8773278c3c..617b0f4218b8 100644
> >>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
> >>>>>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> + LoongArch.\n", __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> + LoongArch.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> LoongArch.\n", __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on 
> >>>>>>> + LoongArch.\n", __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> diff --git 
> >>>>>>> a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> index 67a3387ff3c6..bb26fe013d8b 100644
> >>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
> >>>>>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
> >>>>>>>       IN UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
> >>>>>>>       VOID
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>     }
> >>>>>>>
> >>>>>>>     /**
> >>>>>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>>
> >>>>>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
> >>>>>>>       IN      UINTN  Length
> >>>>>>>       )
> >>>>>>>     {
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> __FUNCTION__));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n", 
> >>>>>>> + __func__));
> >>>>>>>       return Address;
> >>>>>>>     }
> >>>>>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c 
> >>>>>>> b/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> index b75b33381732..954d3f8c8988 100644
> >>>>>>> --- a/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
> >>>>>>> @@ -17,7 +17,7 @@
> >>>>>>>         if (!(Expression)) { \
> >>>>>>>           DEBUG ((DEBUG_VERBOSE, \
> >>>>>>>             "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
> >>>>>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>>>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__, 
> >>>>>>> + DEBUG_EXPRESSION_STRING (Expression), Status)); \
> >>>>>>>           return Status; \
> >>>>>>>         } \
> >>>>>>>       } while (FALSE)
> >>>>>>> diff --git 
> >>>>>>> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
> >>>>>>> redCollectionRedBlackTreeLib.c 
> >>>>>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
> >>>>>>> redCollectionRedBlackTreeLib.c index 
> >>>>>>> f47301de8982..a23113f9c91d 100644
> >>>>>>> --- 
> >>>>>>> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
> >>>>>>> redCollectionRedBlackTreeLib.c
> >>>>>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/Base
> >>>>>>> +++ OrderedCollectionRedBlackTreeLib.c
> >>>>>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
> >>>>>>>       CONST RED_BLACK_TREE_NODE  *Last;
> >>>>>>>       CONST RED_BLACK_TREE_NODE  *Node;
> >>>>>>>
> >>>>>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, 
> >>>>>>> Tree));
> >>>>>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
> >>>>>>>
> >>>>>>>       //
> >>>>>>>       // property #5
> >>>>>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
> >>>>>>>       DEBUG ((
> >>>>>>>         DEBUG_VERBOSE,
> >>>>>>>         "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
> >>>>>>> -    __FUNCTION__,
> >>>>>>> +    __func__,
> >>>>>>>         Tree,
> >>>>>>>         (INT64)BlackHeight,
> >>>>>>>         (INT64)ForwardCount
> >>>>>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c 
> >>>>>>> b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> index 82129aa44598..46aea515924f 100644
> >>>>>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
> >>>>>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
> >>>>>>>       RngProtocol = NULL;
> >>>>>>>
> >>>>>>>       if (Buffer == NULL) {
> >>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
> >>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
> >>>>>>>         return EFI_INVALID_PARAMETER;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
> >>>>>>>       if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
> >>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
> >>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG 
> >>>>>>> + prototocol, Status = %r\n", __func__, Status));
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, 
> >>>>>>> &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status 
> >>>>>>> = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status 
> >>>>>>> + = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, 
> >>>>>>> &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status 
> >>>>>>> = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status 
> >>>>>>> + = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, 
> >>>>>>> &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status 
> >>>>>>> = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status 
> >>>>>>> + = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       // If all the other methods have failed, use the default method from the RngProtocol
> >>>>>>>       Status = RngProtocol->GetRNG (RngProtocol, NULL, 
> >>>>>>> BufferSize, Buffer);
> >>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status 
> >>>>>>> = %r\n", __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status 
> >>>>>>> + = %r\n", __func__, Status));
> >>>>>>>       if (!EFI_ERROR (Status)) {
> >>>>>>>         return Status;
> >>>>>>>       }
> >>>>>>>
> >>>>>>>       // If we get to this point, we have failed
> >>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", 
> >>>>>>> __FUNCTION__, Status));
> >>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n", 
> >>>>>>> + __func__, Status));
> >>>>>>>
> >>>>>>>       return Status;
> >>>>>>>     }// GenerateRandomNumberViaNist800Algorithm()
> >>>>>>> --
> >>>>>>> 2.30.2
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>
> >>>
> >>>
> 
> 
> 
> 







^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
  2023-03-23  1:43                   ` Huang, Yanbo
@ 2023-03-23  1:46                     ` Rebecca Cran
  0 siblings, 0 replies; 26+ messages in thread
From: Rebecca Cran @ 2023-03-23  1:46 UTC (permalink / raw)
  To: Huang, Yanbo, devel@edk2.groups.io, Kinney, Michael D,
	Gao, Liming, Liu, Zhiguang, Michael Kubacki, Sean Brogan

Sorry, I didn't realize there were people still using older builds of VS 
2015.


-- 
Rebecca Cran


On 3/22/23 7:43 PM, Huang, Yanbo wrote:
> Hi Rebecca,
>
> The commit message “Visual Studio versions before VS 2015 don't support __func__” may cause confuse since some of the older release of VS2015 also do not support __func__.
> Some of my fellows report the error since they use the VS 2015 version before Update 3.
>
> Best Regards,
> Yanbo Huang
>
> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael D Kinney
> Sent: Thursday, March 23, 2023 8:58 AM
> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>; Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan <sean.brogan@microsoft.com>
> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__
>
> Hi Rebecca,
>
> Using latest release would be my preference as well and what EDK II should recommend.
>
> We should document that the min supported version of VS2015 Update 3.
>
> Mike
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca
>> Cran
>> Sent: Wednesday, March 22, 2023 10:46 AM
>> To: Kinney, Michael D <michael.d.kinney@intel.com>;
>> devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu,
>> Zhiguang <zhiguang.liu@intel.com>; Michael Kubacki
>> <mikuback@linux.microsoft.com>; Sean Brogan
>> <sean.brogan@microsoft.com>
>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be more
>> C11 compliant by using __func__
>>
>> Can we not require that VS2015 Update 3 is installed?
>>
>> Do people have reasons to be running older builds, or is it just that
>> they forget to install the updates?
>>
>>
>> --
>> Rebecca Cran
>>
>>
>> On 3/22/23 10:58 AM, Kinney, Michael D wrote:
>>> Hi Rebecca,
>>>
>>> It appears that some of the older release of VS2015 do not support
>>> __func__.
>>>
>>> Can you please work on a patch that implements the workaround?
>>>
>>> Thanks,
>>>
>>> Mike
>>>
>>>> -----Original Message-----
>>>> From: Kinney, Michael D <michael.d.kinney@intel.com>
>>>> Sent: Friday, March 17, 2023 8:16 AM
>>>> To: devel@edk2.groups.io; rebecca@bsdio.com; Gao, Liming
>>>> <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>;
>>>> Michael Kubacki <mikuback@linux.microsoft.com>; Sean Brogan
>>>> <sean.brogan@microsoft.com>
>>>> Cc: Kinney, Michael D <michael.d.kinney@intel.com>
>>>> Subject: RE: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be
>>>> more C11 compliant by using __func__
>>>>
>>>> Hi Rebecca,
>>>>
>>>> For older compilers that do not support __func__, I believe a
>>>> workaround could be added to define __func__ to __FUNCTION__.  We
>>>> do not need to do this for any of these patches.  It can be
>>>> something consumers can do if they really want to use an older compiler.
>>>>
>>>> You can try it out on VS2012 locally.  If it works, then you can
>>>> mention that workaround in the commit message.
>>>>
>>>> Do we have any information on GCC/CLANG compatibility for this feature?
>>>>
>>>> Mike
>>>>
>>>>> -----Original Message-----
>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
>>>>> Rebecca Cran
>>>>> Sent: Friday, March 17, 2023 6:32 AM
>>>>> To: Kinney, Michael D <michael.d.kinney@intel.com>;
>>>>> devel@edk2.groups.io; Gao, Liming <gaoliming@byosoft.com.cn>; Liu,
>> Zhiguang
>>>>> <zhiguang.liu@intel.com>; Michael Kubacki
>>>>> <mikuback@linux.microsoft.com>; Sean Brogan
>>>>> <sean.brogan@microsoft.com>
>>>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be
>>>>> more C11 compliant by using __func__
>>>>>
>>>>> (+Michael Kubacki, Sean Brogan)
>>>>>
>>>>> Mike, Michael, Sean:
>>>>>
>>>>>
>>>>> This change is going to break building edk2 with anything older
>>>>> than Visual Studio 2015, which is where support for __func__ was added.
>>>>>
>>>>> I checked and currently it appears that VS2013 builds edk2 but
>>>>> VS2012 has errors. Given that the stuart tools don't support
>>>>> anything older than VS2017 I'm thinking this is okay, but I want
>>>>> to double check before pushing this change.
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Rebecca Cran
>>>>>
>>>>>
>>>>> On 3/14/23 2:40 PM, Kinney, Michael D wrote:
>>>>>> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
>>>>>>
>>>>>>
>>>>>>> -----Original Message-----
>>>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
>>>>>>> Rebecca Cran
>>>>>>> Sent: Monday, March 13, 2023 7:20 PM
>>>>>>> To: devel@edk2.groups.io; Kinney, Michael D
>>>>>>> <michael.d.kinney@intel.com>; Gao, Liming
>>>>>>> <gaoliming@byosoft.com.cn>; Liu, Zhiguang
>>>>>>> <zhiguang.liu@intel.com>
>>>>>>> Subject: Re: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be
>>>>>>> more C11 compliant by using __func__
>>>>>>>
>>>>>>> Mike,
>>>>>>>
>>>>>>>
>>>>>>> I think your concerns with this patch were addressed?
>>>>>>>
>>>>>>> Could you add a Reviewed-by please?
>>>>>>>
>>>>>>>
>>>>>>> Thanks.
>>>>>>> Rebecca
>>>>>>>
>>>>>>>
>>>>>>> On 2/9/23 6:01 PM, Michael D Kinney wrote:
>>>>>>>> Hi Rebecca,
>>>>>>>>
>>>>>>>> Did this pass EDK II CI?
>>>>>>>>
>>>>>>>> This change does break EBC compiler builds.  The following has
>>>>>>>> to be added to MdePkg/Include/Ebc/ProcessorBind.h in order to use __func__ everywhere.
>>>>>>>>
>>>>>>>>         #define __func__ __FUNCTION__
>>>>>>>>
>>>>>>>> I also see __FUNCTION__ used in many packages.  I am wondering
>>>>>>>> if we want to do this clean up if it should be its own patch
>>>>>>>> series and update all packages in once series.
>>>>>>>>
>>>>>>>> Mike
>>>>>>>>
>>>>>>>>> -----Original Message-----
>>>>>>>>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of
>>>>>>>>> Rebecca Cran
>>>>>>>>> Sent: Thursday, February 9, 2023 7:45 AM
>>>>>>>>> To: devel@edk2.groups.io; Kinney, Michael D
>>>>>>>>> <michael.d.kinney@intel.com>; Gao, Liming
>>>>>>>>> <gaoliming@byosoft.com.cn>;
>>>>>>> Liu, Zhiguang
>>>>>>>>> <zhiguang.liu@intel.com>
>>>>>>>>> Cc: Rebecca Cran <rebecca@quicinc.com>
>>>>>>>>> Subject: [edk2-devel] [PATCH 2/2] MdePkg: Update code to be
>>>>>>>>> more C11 compliant by using __func__
>>>>>>>>>
>>>>>>>>> __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 MdePkg.
>>>>>>>>>
>>>>>>>>> Signed-off-by: Rebecca Cran <rebecca@quicinc.com>
>>>>>>>>> ---
>>>>>>>>>      MdePkg/Include/Library/PerformanceLib.h                                                    | 12 ++++++------
>>>>>>>>>      MdePkg/Include/Library/UnitTestLib.h                                                       | 18 +++++++++------
>>>>>>> ---
>>>>>>>>>      MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c                                    |  6 +++---
>>>>>>>>>      MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c                                        | 12 ++++++------
>>>>>>>>>      MdePkg/Library/BaseLib/SafeString.c                                                        |  2 +-
>>>>>>>>>      MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c |  4 ++--
>>>>>>>>>      MdePkg/Library/DxeRngLib/DxeRngLib.c                                                       | 14 +++++++-------
>>>>>>>>>      7 files changed, 34 insertions(+), 34 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/MdePkg/Include/Library/PerformanceLib.h
>>>>>>>>> b/MdePkg/Include/Library/PerformanceLib.h
>>>>>>>>> index 34ec956b9c0e..d0f2dfb070d5 100644
>>>>>>>>> --- a/MdePkg/Include/Library/PerformanceLib.h
>>>>>>>>> +++ b/MdePkg/Include/Library/PerformanceLib.h
>>>>>>>>> @@ -526,7 +526,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid,
>>>>>>>>> + EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> @@ -542,7 +542,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_EVENT_SIGNAL_END(EventGuid) \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid,
>>>>>>>>> + EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> @@ -558,7 +558,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_CALLBACK_BEGIN(TriggerGuid) \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid,
>>>>>>>>> + TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> @@ -574,7 +574,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_CALLBACK_END(TriggerGuid) \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid,
>>>>>>>>> + TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> @@ -589,7 +589,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_FUNCTION_BEGIN() \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL,
>>>>>>>>> + __func__ , 0, PERF_FUNCTION_START_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> @@ -604,7 +604,7 @@ LogPerformanceMeasurement (
>>>>>>>>>      #define PERF_FUNCTION_END() \
>>>>>>>>>        do { \
>>>>>>>>>          if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
>>>>>>>>> -      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \
>>>>>>>>> +      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL,
>>>>>>>>> + __func__ , 0, PERF_FUNCTION_END_ID); \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>>
>>>>>>>>> diff --git a/MdePkg/Include/Library/UnitTestLib.h
>>>>>>>>> b/MdePkg/Include/Library/UnitTestLib.h
>>>>>>>>> index 71c205b1b143..321a310602d7 100644
>>>>>>>>> --- a/MdePkg/Include/Library/UnitTestLib.h
>>>>>>>>> +++ b/MdePkg/Include/Library/UnitTestLib.h
>>>>>>>>> @@ -348,7 +348,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Expression  Expression to be evaluated for TRUE.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_TRUE(Expression)                                                                 \
>>>>>>>>> -  if(!UnitTestAssertTrue ((Expression), __FUNCTION__,
>>>>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>>> +  if(!UnitTestAssertTrue ((Expression), __func__,
>>>>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;                                                            \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -360,7 +360,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Expression  Expression to be evaluated for FALSE.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_FALSE(Expression)                                                                 \
>>>>>>>>> -  if(!UnitTestAssertFalse ((Expression), __FUNCTION__,
>>>>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>>> +  if(!UnitTestAssertFalse ((Expression), __func__,
>>>>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Expression)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;                                                             \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -373,7 +373,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  ValueB  Value to be compared for equality (64-bit comparison).
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_EQUAL(ValueA, ValueB)
>>>>>>> \
>>>>>>>>> -  if(!UnitTestAssertEqual ((UINT64)(ValueA),
>>>>>>>>> (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>>>>>>> #ValueA, #ValueB)) { \
>>>>>>>>> +  if(!UnitTestAssertEqual ((UINT64)(ValueA),
>>>>>>>>> + (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
>>>>>>>>> + #ValueA,
>>>>>>> #ValueB)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;
>>>>>>> \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -387,7 +387,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Length   Number of bytes to compare in BufferA and BufferB.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_MEM_EQUAL(BufferA, BufferB, Length) \
>>>>>>>>> -  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID
>>>>>>>>> *)(UINTN)(BufferB), (UINTN)Length, __FUNCTION__,
>>>>>>> DEBUG_LINE_NUMBER,
>>>>>>>>> __FILE__, #BufferA, #BufferB)) { \
>>>>>>>>> +  if(!UnitTestAssertMemEqual ((VOID *)(UINTN)(BufferA), (VOID
>>>>>>>>> + *)(UINTN)(BufferB), (UINTN)Length, __func__,
>>>>>>> DEBUG_LINE_NUMBER,
>>>>>>>>> __FILE__, #BufferA, #BufferB)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED; \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -400,7 +400,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  ValueB  Value to be compared for inequality (64-bit comparison).
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_NOT_EQUAL(ValueA, ValueB)
>>>>>>> \
>>>>>>>>> -  if(!UnitTestAssertNotEqual ((UINT64)(ValueA),
>>>>>>>>> (UINT64)(ValueB), __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,
>>>>>>> #ValueA, #ValueB)) { \
>>>>>>>>> +  if(!UnitTestAssertNotEqual ((UINT64)(ValueA),
>>>>>>>>> + (UINT64)(ValueB), __func__, DEBUG_LINE_NUMBER, __FILE__,
>>>>>>> #ValueA, #ValueB)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;
>>>>>>> \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -412,7 +412,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Status  EFI_STATUS value to check.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_NOT_EFI_ERROR(Status)                                                           \
>>>>>>>>> -  if(!UnitTestAssertNotEfiError ((Status), __FUNCTION__,
>>>>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>>> +  if(!UnitTestAssertNotEfiError ((Status), __func__,
>>>>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;                                                           \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -425,7 +425,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Expected  EFI_STATUS values to compare for equality.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_STATUS_EQUAL(Status, Expected)                                                              \
>>>>>>>>> -  if(!UnitTestAssertStatusEqual ((Status), (Expected),
>>>>>>>>> __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>>> +  if(!UnitTestAssertStatusEqual ((Status), (Expected),
>>>>>>>>> + __func__, DEBUG_LINE_NUMBER, __FILE__, #Status)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;                                                                       \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -437,7 +437,7 @@ SaveFrameworkState (
>>>>>>>>>        @param[in]  Pointer  Pointer to be checked against NULL.
>>>>>>>>>      **/
>>>>>>>>>      #define UT_ASSERT_NOT_NULL(Pointer)                                                             \
>>>>>>>>> -  if(!UnitTestAssertNotNull ((Pointer), __FUNCTION__,
>>>>>>>>> DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>>>>>>> +  if(!UnitTestAssertNotNull ((Pointer), __func__,
>>>>>>>>> + DEBUG_LINE_NUMBER, __FILE__, #Pointer)) { \
>>>>>>>>>          return UNIT_TEST_ERROR_TEST_FAILED;                                                         \
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>> @@ -482,7 +482,7 @@ extern BASE_LIBRARY_JUMP_BUFFER  *gUnitTestExpectAssertFailureJumpBuffer;
>>>>>>>>>            }                                                                \
>>>>>>>>>            if (!UnitTestExpectAssertFailure (                               \
>>>>>>>>>                   UnitTestJumpStatus,                                       \
>>>>>>>>> -             __FUNCTION__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>>>>>>> +             __func__, DEBUG_LINE_NUMBER, __FILE__,                \
>>>>>>>>>                   #FunctionCall, Status)) {                                 \
>>>>>>>>>              return UNIT_TEST_ERROR_TEST_FAILED;                            \
>>>>>>>>>            }                                                                \
>>>>>>>>> diff --git
>>>>>>>>> a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>>>> index 4c8773278c3c..617b0f4218b8 100644
>>>>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/LoongArchCache.c
>>>>>>>>> @@ -100,7 +100,7 @@ WriteBackInvalidateDataCache (
>>>>>>>>>        VOID
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> LoongArch.\n", __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> + LoongArch.\n", __func__));
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> @@ -136,7 +136,7 @@ WriteBackInvalidateDataCacheRange (
>>>>>>>>>        IN      UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> LoongArch.\n", __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> + LoongArch.\n", __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> @@ -191,7 +191,7 @@ WriteBackDataCacheRange (
>>>>>>>>>        IN      UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> LoongArch.\n", __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: Not currently implemented on
>>>>>>>>> + LoongArch.\n", __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> diff --git
>>>>>>>>> a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>> b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>>>> index 67a3387ff3c6..bb26fe013d8b 100644
>>>>>>>>> --- a/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>>>> +++ b/MdePkg/Library/BaseCacheMaintenanceLib/RiscVCache.c
>>>>>>>>> @@ -76,7 +76,7 @@ InvalidateInstructionCacheRange (
>>>>>>>>>        IN UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> @@ -96,7 +96,7 @@ WriteBackInvalidateDataCache (
>>>>>>>>>        VOID
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> @@ -132,7 +132,7 @@ WriteBackInvalidateDataCacheRange (
>>>>>>>>>        IN      UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> @@ -152,7 +152,7 @@ WriteBackDataCache (
>>>>>>>>>        VOID
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>>      /**
>>>>>>>>> @@ -187,7 +187,7 @@ WriteBackDataCacheRange (
>>>>>>>>>        IN      UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>>
>>>>>>>>> @@ -245,6 +245,6 @@ InvalidateDataCacheRange (
>>>>>>>>>        IN      UINTN  Length
>>>>>>>>>        )
>>>>>>>>>      {
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> __FUNCTION__));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a:RISC-V unsupported function.\n",
>>>>>>>>> + __func__));
>>>>>>>>>        return Address;
>>>>>>>>>      }
>>>>>>>>> diff --git a/MdePkg/Library/BaseLib/SafeString.c
>>>>>>>>> b/MdePkg/Library/BaseLib/SafeString.c
>>>>>>>>> index b75b33381732..954d3f8c8988 100644
>>>>>>>>> --- a/MdePkg/Library/BaseLib/SafeString.c
>>>>>>>>> +++ b/MdePkg/Library/BaseLib/SafeString.c
>>>>>>>>> @@ -17,7 +17,7 @@
>>>>>>>>>          if (!(Expression)) { \
>>>>>>>>>            DEBUG ((DEBUG_VERBOSE, \
>>>>>>>>>              "%a(%d) %a: SAFE_STRING_CONSTRAINT_CHECK(%a) failed.  Return %r\n", \
>>>>>>>>> -        __FILE__, DEBUG_LINE_NUMBER, __FUNCTION__, DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>>>>>>> +        __FILE__, DEBUG_LINE_NUMBER, __func__,
>>>>>>>>> + DEBUG_EXPRESSION_STRING (Expression), Status)); \
>>>>>>>>>            return Status; \
>>>>>>>>>          } \
>>>>>>>>>        } while (FALSE)
>>>>>>>>> diff --git
>>>>>>>>> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
>>>>>>>>> redCollectionRedBlackTreeLib.c
>>>>>>>>> b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
>>>>>>>>> redCollectionRedBlackTreeLib.c index
>>>>>>>>> f47301de8982..a23113f9c91d 100644
>>>>>>>>> ---
>>>>>>>>> a/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrde
>>>>>>>>> redCollectionRedBlackTreeLib.c
>>>>>>>>> +++ b/MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/Base
>>>>>>>>> +++ OrderedCollectionRedBlackTreeLib.c
>>>>>>>>> @@ -1416,7 +1416,7 @@ RedBlackTreeValidate (
>>>>>>>>>        CONST RED_BLACK_TREE_NODE  *Last;
>>>>>>>>>        CONST RED_BLACK_TREE_NODE  *Node;
>>>>>>>>>
>>>>>>>>> -  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__,
>>>>>>>>> Tree));
>>>>>>>>> +  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __func__, Tree));
>>>>>>>>>
>>>>>>>>>        //
>>>>>>>>>        // property #5
>>>>>>>>> @@ -1459,7 +1459,7 @@ RedBlackTreeValidate (
>>>>>>>>>        DEBUG ((
>>>>>>>>>          DEBUG_VERBOSE,
>>>>>>>>>          "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",
>>>>>>>>> -    __FUNCTION__,
>>>>>>>>> +    __func__,
>>>>>>>>>          Tree,
>>>>>>>>>          (INT64)BlackHeight,
>>>>>>>>>          (INT64)ForwardCount
>>>>>>>>> diff --git a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>>>> b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>>>> index 82129aa44598..46aea515924f 100644
>>>>>>>>> --- a/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>>>> +++ b/MdePkg/Library/DxeRngLib/DxeRngLib.c
>>>>>>>>> @@ -37,43 +37,43 @@ GenerateRandomNumberViaNist800Algorithm (
>>>>>>>>>        RngProtocol = NULL;
>>>>>>>>>
>>>>>>>>>        if (Buffer == NULL) {
>>>>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __FUNCTION__));
>>>>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Buffer == NULL.\n", __func__));
>>>>>>>>>          return EFI_INVALID_PARAMETER;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        Status = gBS->LocateProtocol (&gEfiRngProtocolGuid, NULL, (VOID **)&RngProtocol);
>>>>>>>>>        if (EFI_ERROR (Status) || (RngProtocol == NULL)) {
>>>>>>>>> -    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG prototocol, Status = %r\n", __FUNCTION__, Status));
>>>>>>>>> +    DEBUG ((DEBUG_ERROR, "%a: Could not locate RNG
>>>>>>>>> + prototocol, Status = %r\n", __func__, Status));
>>>>>>>>>          return Status;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        Status = RngProtocol->GetRNG (RngProtocol,
>>>>>>>>> &gEfiRngAlgorithmSp80090Ctr256Guid, BufferSize, Buffer);
>>>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status
>>>>>>>>> = %r\n", __FUNCTION__, Status));
>>>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm CTR-256 - Status
>>>>>>>>> + = %r\n", __func__, Status));
>>>>>>>>>        if (!EFI_ERROR (Status)) {
>>>>>>>>>          return Status;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        Status = RngProtocol->GetRNG (RngProtocol,
>>>>>>>>> &gEfiRngAlgorithmSp80090Hmac256Guid, BufferSize, Buffer);
>>>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status
>>>>>>>>> = %r\n", __FUNCTION__, Status));
>>>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm HMAC-256 - Status
>>>>>>>>> + = %r\n", __func__, Status));
>>>>>>>>>        if (!EFI_ERROR (Status)) {
>>>>>>>>>          return Status;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        Status = RngProtocol->GetRNG (RngProtocol,
>>>>>>>>> &gEfiRngAlgorithmSp80090Hash256Guid, BufferSize, Buffer);
>>>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status
>>>>>>>>> = %r\n", __FUNCTION__, Status));
>>>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status
>>>>>>>>> + = %r\n", __func__, Status));
>>>>>>>>>        if (!EFI_ERROR (Status)) {
>>>>>>>>>          return Status;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        // If all the other methods have failed, use the default method from the RngProtocol
>>>>>>>>>        Status = RngProtocol->GetRNG (RngProtocol, NULL,
>>>>>>>>> BufferSize, Buffer);
>>>>>>>>> -  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status
>>>>>>>>> = %r\n", __FUNCTION__, Status));
>>>>>>>>> +  DEBUG ((DEBUG_INFO, "%a: GetRNG algorithm Hash-256 - Status
>>>>>>>>> + = %r\n", __func__, Status));
>>>>>>>>>        if (!EFI_ERROR (Status)) {
>>>>>>>>>          return Status;
>>>>>>>>>        }
>>>>>>>>>
>>>>>>>>>        // If we get to this point, we have failed
>>>>>>>>> -  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n",
>>>>>>>>> __FUNCTION__, Status));
>>>>>>>>> +  DEBUG ((DEBUG_ERROR, "%a: GetRNG() failed, staus = %r\n",
>>>>>>>>> + __func__, Status));
>>>>>>>>>
>>>>>>>>>        return Status;
>>>>>>>>>      }// GenerateRandomNumberViaNist800Algorithm()
>>>>>>>>> --
>>>>>>>>> 2.30.2
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>
>>>>>
>>
>>
>>
>
>
> 
>
>

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2023-03-23  1:46 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-09 15:45 [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Rebecca Cran
2023-02-09 15:45 ` [PATCH 2/2] MdePkg: Update code to be more C11 compliant by using __func__ Rebecca Cran
2023-02-10  1:01   ` [edk2-devel] " Michael D Kinney
2023-02-10  1:21     ` Rebecca Cran
2023-02-10 11:45       ` Ard Biesheuvel
2023-02-10 15:19         ` Leif Lindholm
2023-02-10 18:16           ` Michael D Kinney
2023-02-12 19:59     ` Rebecca Cran
2023-03-14  2:19     ` Rebecca Cran
2023-03-14 20:40       ` Michael D Kinney
2023-03-17 13:31         ` Rebecca Cran
2023-03-17 15:16           ` Michael D Kinney
2023-03-22 16:58             ` Michael D Kinney
2023-03-22 17:45               ` Rebecca Cran
2023-03-23  0:58                 ` Michael D Kinney
2023-03-23  1:43                   ` Huang, Yanbo
2023-03-23  1:46                     ` Rebecca Cran
2023-03-17  4:23   ` Sunil V L
2023-02-10  1:03 ` [edk2-devel] [PATCH 1/2] MdePkg: Update Base.h to be compliant with C11 Michael D Kinney
2023-02-10  1:14   ` Rebecca Cran
2023-02-10  4:15     ` Rebecca Cran
2023-03-06 16:39 ` Rebecca Cran
2023-03-10  2:45   ` 回复: " gaoliming
2023-03-10 17:58     ` Rebecca Cran
2023-03-13 17:54     ` Rebecca Cran
2023-03-13 20:46       ` Michael D Kinney

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox