[edk2-devel] [PATCH] EmbeddedPkg/libfdt: Add strncmp macro to use AsciiStrnCmp

Abner Chang posted 1 patch 3 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/edk2 tags/patchew/20200806023421.25161-1-abner.chang@hpe.com
EmbeddedPkg/Include/libfdt_env.h | 4 ++++
1 file changed, 4 insertions(+)
[edk2-devel] [PATCH] EmbeddedPkg/libfdt: Add strncmp macro to use AsciiStrnCmp
Posted by Abner Chang 3 years, 8 months ago
For the implementation which utilizes libfdt provided in EmbeddedPkg
however it uses strncmp function in the libfdt helper library,
libfdt_env.h should provide the macro implied with edk2 strncmp
implementation.

The example is RISC-V OpenSBI library. edk2 RISC-V port uses OpenSBI
library and incorporate with edk2 libfdt. edk2 libfdt_env.h provides
the necessary macros to build OpenSBI which uses fdt functions in edk2
environment. However, OpenSBI also has libfdt helper library that uses
strncmp function which is not defined in edk2 libfdt_env.h. This commit
addresses the build issue caused by missing strncmp macro in
libfdt_env.h.

Check below three commits for the corresponding changes on OpenSBI,
https://github.com/riscv/opensbi/commit/8e47649eff96c303e02fbd58cdc6c4ed341066ec
https://github.com/riscv/opensbi/commit/2845d2d2cf4fb74a89452ba223995aa4a118c07e
https://github.com/riscv/opensbi/commit/2cfd2fc9048806353298a1b967abf985901e36e8

Signed-off-by: Abner Chang <abner.chang@hpe.com>

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
---
 EmbeddedPkg/Include/libfdt_env.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
index 11a9764733..7feff52bc0 100644
--- a/EmbeddedPkg/Include/libfdt_env.h
+++ b/EmbeddedPkg/Include/libfdt_env.h
@@ -76,4 +76,8 @@ static inline size_t strnlen (const char* str, size_t strsz ) {
   return AsciiStrnLenS (str, strsz);
 }
 
+static inline size_t strncmp (const char* str1, const char* str2, size_t strsz ) {
+  return AsciiStrnCmp (str1, str2, strsz);
+}
+
 #endif /* _LIBFDT_ENV_H */
-- 
2.25.0


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#63767): https://edk2.groups.io/g/devel/message/63767
Mute This Topic: https://groups.io/mt/76021725/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] EmbeddedPkg/libfdt: Add strncmp macro to use AsciiStrnCmp
Posted by Leif Lindholm 3 years, 8 months ago
On Thu, Aug 06, 2020 at 10:34:21 +0800, Abner Chang wrote:
> For the implementation which utilizes libfdt provided in EmbeddedPkg
> however it uses strncmp function in the libfdt helper library,
> libfdt_env.h should provide the macro implied with edk2 strncmp
> implementation.
> 
> The example is RISC-V OpenSBI library. edk2 RISC-V port uses OpenSBI
> library and incorporate with edk2 libfdt. edk2 libfdt_env.h provides
> the necessary macros to build OpenSBI which uses fdt functions in edk2
> environment. However, OpenSBI also has libfdt helper library that uses
> strncmp function which is not defined in edk2 libfdt_env.h. This commit
> addresses the build issue caused by missing strncmp macro in
> libfdt_env.h.
> 
> Check below three commits for the corresponding changes on OpenSBI,
> https://github.com/riscv/opensbi/commit/8e47649eff96c303e02fbd58cdc6c4ed341066ec
> https://github.com/riscv/opensbi/commit/2845d2d2cf4fb74a89452ba223995aa4a118c07e
> https://github.com/riscv/opensbi/commit/2cfd2fc9048806353298a1b967abf985901e36e8
> 
> Signed-off-by: Abner Chang <abner.chang@hpe.com>
> 
> Cc: Leif Lindholm <leif@nuviainc.com>
> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
> Cc: Daniel Schaefer <daniel.schaefer@hpe.com>

Whoops, I failed to file this away in my queue - apologies.
Many thanks for fixing this in opensbi.
Reviewed-by: Leif Lindholm <leif@nuviainc.com>


> ---
>  EmbeddedPkg/Include/libfdt_env.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
> index 11a9764733..7feff52bc0 100644
> --- a/EmbeddedPkg/Include/libfdt_env.h
> +++ b/EmbeddedPkg/Include/libfdt_env.h
> @@ -76,4 +76,8 @@ static inline size_t strnlen (const char* str, size_t strsz ) {
>    return AsciiStrnLenS (str, strsz);
>  }
>  
> +static inline size_t strncmp (const char* str1, const char* str2, size_t strsz ) {
> +  return AsciiStrnCmp (str1, str2, strsz);
> +}
> +
>  #endif /* _LIBFDT_ENV_H */
> -- 
> 2.25.0
> 

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64396): https://edk2.groups.io/g/devel/message/64396
Mute This Topic: https://groups.io/mt/76021725/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] EmbeddedPkg/libfdt: Add strncmp macro to use AsciiStrnCmp
Posted by Laszlo Ersek 3 years, 8 months ago
On 08/18/20 20:04, Leif Lindholm wrote:
> On Thu, Aug 06, 2020 at 10:34:21 +0800, Abner Chang wrote:
>> For the implementation which utilizes libfdt provided in EmbeddedPkg
>> however it uses strncmp function in the libfdt helper library,
>> libfdt_env.h should provide the macro implied with edk2 strncmp
>> implementation.
>>
>> The example is RISC-V OpenSBI library. edk2 RISC-V port uses OpenSBI
>> library and incorporate with edk2 libfdt. edk2 libfdt_env.h provides
>> the necessary macros to build OpenSBI which uses fdt functions in edk2
>> environment. However, OpenSBI also has libfdt helper library that uses
>> strncmp function which is not defined in edk2 libfdt_env.h. This commit
>> addresses the build issue caused by missing strncmp macro in
>> libfdt_env.h.
>>
>> Check below three commits for the corresponding changes on OpenSBI,
>> https://github.com/riscv/opensbi/commit/8e47649eff96c303e02fbd58cdc6c4ed341066ec
>> https://github.com/riscv/opensbi/commit/2845d2d2cf4fb74a89452ba223995aa4a118c07e
>> https://github.com/riscv/opensbi/commit/2cfd2fc9048806353298a1b967abf985901e36e8
>>
>> Signed-off-by: Abner Chang <abner.chang@hpe.com>
>>
>> Cc: Leif Lindholm <leif@nuviainc.com>
>> Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
>> Cc: Daniel Schaefer <daniel.schaefer@hpe.com>
> 
> Whoops, I failed to file this away in my queue - apologies.
> Many thanks for fixing this in opensbi.
> Reviewed-by: Leif Lindholm <leif@nuviainc.com>

Merged as commit 019f513a19f8, via
<https://github.com/tianocore/edk2/pull/898>.

If there is an associated TianoCore BZ (the commit message does not
mention one), please flip it to RESOLVED|FIXED, and mark the commit hash
on it.

Thanks,
Laszlo

> 
> 
>> ---
>>  EmbeddedPkg/Include/libfdt_env.h | 4 ++++
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/EmbeddedPkg/Include/libfdt_env.h b/EmbeddedPkg/Include/libfdt_env.h
>> index 11a9764733..7feff52bc0 100644
>> --- a/EmbeddedPkg/Include/libfdt_env.h
>> +++ b/EmbeddedPkg/Include/libfdt_env.h
>> @@ -76,4 +76,8 @@ static inline size_t strnlen (const char* str, size_t strsz ) {
>>    return AsciiStrnLenS (str, strsz);
>>  }
>>  
>> +static inline size_t strncmp (const char* str1, const char* str2, size_t strsz ) {
>> +  return AsciiStrnCmp (str1, str2, strsz);
>> +}
>> +
>>  #endif /* _LIBFDT_ENV_H */
>> -- 
>> 2.25.0
>>
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#64579): https://edk2.groups.io/g/devel/message/64579
Mute This Topic: https://groups.io/mt/76021725/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-