Re: [PATCH] EmbeddedPkg/libfdt: Add strncmp macro to use AsciiStrnCmp

Leif Lindholm

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

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

Check below three commits for the corresponding changes on OpenSBI,

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

Cc: Leif Lindholm <leif@...>
Cc: Ard Biesheuvel <ard.biesheuvel@...>
Cc: Daniel Schaefer <daniel.schaefer@...>
Whoops, I failed to file this away in my queue - apologies.
Many thanks for fixing this in opensbi.
Reviewed-by: Leif Lindholm <leif@...>

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 */

Join { to automatically receive all group messages.