From 0f3dc2194ee751a28680e442417cb410848777c4 Mon Sep 17 00:00:00 2001 From: Pierre Gondois Date: Wed, 2 Oct 2024 11:57:42 +0200 Subject: [PATCH] FatPkg/EnhancedFatDxe: Add comments around StrSize() checks StrSize() cannot return 0. As done in other packages, StrSize() checks the length of the string doesn't exceed PcdMaximumAsciiStringLength. Add comments to make it more obvious. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4859 Reported-by: Tormod Volden Signed-off-by: Pierre Gondois --- FatPkg/EnhancedFatDxe/UnicodeCollation.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/FatPkg/EnhancedFatDxe/UnicodeCollation.c b/FatPkg/EnhancedFatDxe/UnicodeCollation.c index 813f153617ec..095e257733cf 100644 --- a/FatPkg/EnhancedFatDxe/UnicodeCollation.c +++ b/FatPkg/EnhancedFatDxe/UnicodeCollation.c @@ -166,6 +166,10 @@ FatStriCmp ( IN CHAR16 *S2 ) { + // + // ASSERT s1 and s2 are shorter than PcdMaximumAsciiStringLength. + // Length tests are performed inside AsciiStrLen(). + // ASSERT (StrSize (S1) != 0); ASSERT (StrSize (S2) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -189,6 +193,10 @@ FatStrUpr ( IN OUT CHAR16 *String ) { + // + // ASSERT String is shorter than PcdMaximumAsciiStringLength. + // Length tests are performed inside AsciiStrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -207,6 +215,10 @@ FatStrLwr ( IN OUT CHAR16 *String ) { + // + // ASSERT String is shorter than PcdMaximumAsciiStringLength. + // Length tests are performed inside AsciiStrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -231,6 +243,10 @@ FatFatToStr ( ) { ASSERT (Fat != NULL); + // + // ASSERT String is shorter than PcdMaximumAsciiStringLength. + // Length tests are performed inside AsciiStrLen(). + // ASSERT (String != NULL); ASSERT (((UINTN)String & 0x01) == 0); ASSERT (mUnicodeCollationInterface != NULL); @@ -257,6 +273,10 @@ FatStrToFat ( ) { ASSERT (Fat != NULL); + // + // ASSERT String is shorter than PcdMaximumAsciiStringLength. + // Length tests are performed inside AsciiStrLen(). + // ASSERT (StrSize (String) != 0); ASSERT (mUnicodeCollationInterface != NULL);