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
PcdMaximumUnicodeStringLength. Add comments to make it more obvious.

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4859
Reported-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
This commit is contained in:
Pierre Gondois 2024-10-02 11:57:42 +02:00 committed by mergify[bot]
parent bf32c2d61f
commit 3ee2ceb6fa
1 changed files with 20 additions and 0 deletions

View File

@ -166,6 +166,10 @@ FatStriCmp (
IN CHAR16 *S2
)
{
//
// ASSERT s1 and s2 are shorter than PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
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 PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);
@ -207,6 +215,10 @@ FatStrLwr (
IN OUT CHAR16 *String
)
{
//
// ASSERT String is shorter than PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);
@ -231,6 +243,10 @@ FatFatToStr (
)
{
ASSERT (Fat != NULL);
//
// ASSERT String is shorter than PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
ASSERT (String != NULL);
ASSERT (((UINTN)String & 0x01) == 0);
ASSERT (mUnicodeCollationInterface != NULL);
@ -257,6 +273,10 @@ FatStrToFat (
)
{
ASSERT (Fat != NULL);
//
// ASSERT String is shorter than PcdMaximumUnicodeStringLength.
// Length tests are performed inside StrLen().
//
ASSERT (StrSize (String) != 0);
ASSERT (mUnicodeCollationInterface != NULL);