public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v2 1/1] ArmPkg/ArmMmuLib: Explicitly cast function pointer argument
@ 2020-10-19 22:12 Michael Kubacki
  2020-10-22 15:02 ` Ard Biesheuvel
  0 siblings, 1 reply; 2+ messages in thread
From: Michael Kubacki @ 2020-10-19 22:12 UTC (permalink / raw)
  To: devel; +Cc: Ard Biesheuvel, Leif Lindholm

From: Michael Kubacki <michael.kubacki@microsoft.com>

The function ArmReplaceLiveTranslationEntry () is passed as a VOID
pointer to WriteBackDataCacheRange (). This produces the following
warning on VS2019:

warning C4152: nonstandard extension, function/data pointer
conversion in expression

This change explicitly casts the argument to the formal parameter
type VOID*.

This can be reproduced with the following build command:
build -b DEBUG -a AARCH64 -t VS2019 -p ArmPkg/ArmPkg.dsc
-m ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Leif Lindholm <leif@nuviainc.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---

Notes:
    V2 changes:
    
    1. Added a cast to UINTN prior to casting to VOID*.
    
       This also makes the change consistent with a very similar change
       in commit 654dc3ed852a.

 ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
index 80317923cfa4..5f259d216420 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
@@ -47,7 +47,7 @@ ArmMmuPeiLibConstructor (
     // The ArmReplaceLiveTranslationEntry () helper function may be invoked
     // with the MMU off so we have to ensure that it gets cleaned to the PoC
     //
-    WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry,
+    WriteBackDataCacheRange ((VOID *) (UINTN) ArmReplaceLiveTranslationEntry,
       ArmReplaceLiveTranslationEntrySize);
   }
 
-- 
2.28.0.windows.1


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

* Re: [PATCH v2 1/1] ArmPkg/ArmMmuLib: Explicitly cast function pointer argument
  2020-10-19 22:12 [PATCH v2 1/1] ArmPkg/ArmMmuLib: Explicitly cast function pointer argument Michael Kubacki
@ 2020-10-22 15:02 ` Ard Biesheuvel
  0 siblings, 0 replies; 2+ messages in thread
From: Ard Biesheuvel @ 2020-10-22 15:02 UTC (permalink / raw)
  To: michael.kubacki, devel; +Cc: Leif Lindholm

On 10/20/20 12:12 AM, michael.kubacki@outlook.com wrote:
> From: Michael Kubacki <michael.kubacki@microsoft.com>
> 
> The function ArmReplaceLiveTranslationEntry () is passed as a VOID
> pointer to WriteBackDataCacheRange (). This produces the following
> warning on VS2019:
> 
> warning C4152: nonstandard extension, function/data pointer
> conversion in expression
> 
> This change explicitly casts the argument to the formal parameter
> type VOID*.
> 
> This can be reproduced with the following build command:
> build -b DEBUG -a AARCH64 -t VS2019 -p ArmPkg/ArmPkg.dsc
> -m ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
> 
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Leif Lindholm <leif@nuviainc.com>
> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>

Thanks Michael

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>

But please, in the future, don't put spaces after () casts.

I have pushed this patch and '[PATCH v1 1/1] ArmPkg/ArmMmuLib: 
Explicitly cast UINT32 data conversions' as #1042.

Thanks,


> ---
> 
> Notes:
>      V2 changes:
>      
>      1. Added a cast to UINTN prior to casting to VOID*.
>      
>         This also makes the change consistent with a very similar change
>         in commit 654dc3ed852a.
> 
>   ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
> index 80317923cfa4..5f259d216420 100644
> --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
> +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuPeiLibConstructor.c
> @@ -47,7 +47,7 @@ ArmMmuPeiLibConstructor (
>       // The ArmReplaceLiveTranslationEntry () helper function may be invoked
>       // with the MMU off so we have to ensure that it gets cleaned to the PoC
>       //
> -    WriteBackDataCacheRange (ArmReplaceLiveTranslationEntry,
> +    WriteBackDataCacheRange ((VOID *) (UINTN) ArmReplaceLiveTranslationEntry,
>         ArmReplaceLiveTranslationEntrySize);
>     }
>   
> 


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

end of thread, other threads:[~2020-10-22 15:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-19 22:12 [PATCH v2 1/1] ArmPkg/ArmMmuLib: Explicitly cast function pointer argument Michael Kubacki
2020-10-22 15:02 ` Ard Biesheuvel

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