Skip to content

Commit 97238c0

Browse files
committed
BaseTools/VfrCompile: Minor code cleanup
Add minor code cleanups made while tracking down the bugs fixed in the preceding commits. - Fix spelling 'arrary' -> 'array' where it occurs in the tool code and comments. - When renaming ExtractFieldNameAndArrary to ExtractFieldNameAndArrayIdx, we fix the typo and also clarify what the method does: it returns the field name and the array index when present. Since it is always used to populate a local variable named ArrayIdx, we stick to that spelling in the renamed method. - Add comment clarifying that mArrayNum holds array length (but again, don't go for a bigger global rename). - Rename CVfrVarDataTypeDB::GetFieldWidth to GetFieldType. It is only used once, and the new name correctly matches what it does. Signed-off-by: Mike Beaton <[email protected]>
1 parent b2d31e0 commit 97238c0

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

BaseTools/Source/C/VfrCompile/VfrError.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static SVFR_ERROR_HANDLE VFR_ERROR_HANDLE_TABLE [] = {
3535
{ VFR_RETURN_GET_NVVARSTORE_ERROR, ": get name value varstore error" },
3636
{ VFR_RETURN_QVAR_REUSE, ": variable reused by more than one question" },
3737
{ VFR_RETURN_FLAGS_UNSUPPORTED, ": flags unsupported" },
38-
{ VFR_RETURN_ERROR_ARRARY_NUM, ": array number error, the valid value is in (0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr" },
38+
{ VFR_RETURN_ERROR_ARRAY_NUM, ": array number error, the valid value is in (0 ~ MAX_INDEX-1) for UEFI vfr and in (1 ~ MAX_INDEX) for Framework Vfr" },
3939
{ VFR_RETURN_DATA_STRING_ERROR, ": data field string error or not support"},
4040
{ VFR_RETURN_DEFAULT_VALUE_REDEFINED, ": default value re-defined with different value"},
4141
{ VFR_RETURN_CONSTANT_ONLY, ": only constant is allowed in the expression"},

BaseTools/Source/C/VfrCompile/VfrError.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ typedef enum {
3333
VFR_RETURN_GET_NVVARSTORE_ERROR,
3434
VFR_RETURN_QVAR_REUSE,
3535
VFR_RETURN_FLAGS_UNSUPPORTED,
36-
VFR_RETURN_ERROR_ARRARY_NUM,
36+
VFR_RETURN_ERROR_ARRAY_NUM,
3737
VFR_RETURN_DATA_STRING_ERROR,
3838
VFR_RETURN_DEFAULT_VALUE_REDEFINED,
3939
VFR_RETURN_CONSTANT_ONLY,

BaseTools/Source/C/VfrCompile/VfrFormPkg.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ CFormPkg::DeclarePendingQuestion (
853853
//
854854
// Get Question Info, framework vfr VarName == StructName
855855
//
856-
ReturnCode = lCVfrVarDataTypeDB.ExtractFieldNameAndArrary (VarStr, FName, ArrayIdx);
856+
ReturnCode = lCVfrVarDataTypeDB.ExtractFieldNameAndArrayIdx (VarStr, FName, ArrayIdx);
857857
if (ReturnCode != VFR_RETURN_SUCCESS) {
858858
gCVfrErrorHandle.PrintMsg (pNode->mLineNo, pNode->mKey, "Error", "Var string is not the valid C variable");
859859
return ReturnCode;

BaseTools/Source/C/VfrCompile/VfrUtilityLib.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ CVfrVarDataTypeDB::IsThisBitField (
649649
CHECK_ERROR_RETURN (GetDataType (TName, &pType), VFR_RETURN_SUCCESS);
650650

651651
while (*VarStr != '\0') {
652-
CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
652+
CHECK_ERROR_RETURN(ExtractFieldNameAndArrayIdx(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
653653
CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
654654
pType = pField->mFieldType;
655655
}
@@ -661,7 +661,7 @@ CVfrVarDataTypeDB::IsThisBitField (
661661
}
662662

663663
EFI_VFR_RETURN_CODE
664-
CVfrVarDataTypeDB::ExtractFieldNameAndArrary (
664+
CVfrVarDataTypeDB::ExtractFieldNameAndArrayIdx (
665665
IN CHAR8 *&VarStr,
666666
IN CHAR8 *FName,
667667
OUT UINT32 &ArrayIdx
@@ -766,17 +766,17 @@ CVfrVarDataTypeDB::GetFieldOffset (
766766
}
767767

768768
if ((ArrayIdx != INVALID_ARRAY_INDEX) && ((Field->mArrayNum == 0) || (Field->mArrayNum <= ArrayIdx))) {
769-
return VFR_RETURN_ERROR_ARRARY_NUM;
769+
return VFR_RETURN_ERROR_ARRAY_NUM;
770770
}
771771

772772
//
773773
// Be compatible with the current usage
774-
// If ArraryIdx is not specified, the first one is used.
774+
// If ArrayIdx is not specified, the first one is used.
775775
//
776-
// if ArrayNum is larger than zero, ArraryIdx must be specified.
776+
// if ArrayNum is larger than zero, ArrayIdx must be specified.
777777
//
778778
// if ((ArrayIdx == INVALID_ARRAY_INDEX) && (Field->mArrayNum > 0)) {
779-
// return VFR_RETURN_ERROR_ARRARY_NUM;
779+
// return VFR_RETURN_ERROR_ARRAY_NUM;
780780
// }
781781
//
782782
if (IsBitField) {
@@ -788,7 +788,7 @@ CVfrVarDataTypeDB::GetFieldOffset (
788788
}
789789

790790
UINT8
791-
CVfrVarDataTypeDB::GetFieldWidth (
791+
CVfrVarDataTypeDB::GetFieldType (
792792
IN SVfrDataField *Field
793793
)
794794
{
@@ -1183,7 +1183,7 @@ CVfrVarDataTypeDB::DataTypeAddBitField (
11831183
}
11841184
} else {
11851185
//
1186-
// The bit filed start a new memory
1186+
// The bit field start a new memory
11871187
//
11881188
pNewField->mBitOffset = mNewDataType->mTotalSize * 8;
11891189
UpdateTotalSize = TRUE;
@@ -1408,7 +1408,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
14081408
Size = pType->mTotalSize;
14091409

14101410
while (*VarStr != '\0') {
1411-
CHECK_ERROR_RETURN(ExtractFieldNameAndArrary(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
1411+
CHECK_ERROR_RETURN(ExtractFieldNameAndArrayIdx(VarStr, FName, ArrayIdx), VFR_RETURN_SUCCESS);
14121412
CHECK_ERROR_RETURN(GetTypeField (FName, pType, pField), VFR_RETURN_SUCCESS);
14131413
pType = pField->mFieldType;
14141414
CHECK_ERROR_RETURN(GetFieldOffset (pField, ArrayIdx, Tmp, pField->mIsBitField), VFR_RETURN_SUCCESS);
@@ -1417,7 +1417,7 @@ CVfrVarDataTypeDB::GetDataFieldInfo (
14171417
} else {
14181418
Offset = (UINT16) (Offset + Tmp);
14191419
}
1420-
Type = GetFieldWidth (pField);
1420+
Type = GetFieldType (pField);
14211421
Size = GetFieldSize (pField, ArrayIdx, BitField);
14221422
}
14231423
return VFR_RETURN_SUCCESS;

BaseTools/Source/C/VfrCompile/VfrUtilityLib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct SVfrDataField {
110110
CHAR8 mFieldName[MAX_NAME_LEN];
111111
SVfrDataType *mFieldType;
112112
UINT32 mOffset;
113-
UINT32 mArrayNum;
113+
UINT32 mArrayNum; ///< Holds array length, or zero for non-array.
114114
BOOLEAN mIsBitField;
115115
UINT8 mBitWidth;
116116
UINT32 mBitOffset;
@@ -195,7 +195,7 @@ class CVfrVarDataTypeDB {
195195
EFI_VFR_RETURN_CODE ExtractStructTypeName (IN CHAR8 *&, OUT CHAR8 *);
196196
EFI_VFR_RETURN_CODE GetTypeField (IN CONST CHAR8 *, IN SVfrDataType *, IN SVfrDataField *&);
197197
EFI_VFR_RETURN_CODE GetFieldOffset (IN SVfrDataField *, IN UINT32, OUT UINT32 &, IN BOOLEAN);
198-
UINT8 GetFieldWidth (IN SVfrDataField *);
198+
UINT8 GetFieldType (IN SVfrDataField *);
199199
UINT32 GetFieldSize (IN SVfrDataField *, IN UINT32, IN BOOLEAN);
200200

201201
public:
@@ -214,7 +214,7 @@ class CVfrVarDataTypeDB {
214214
EFI_VFR_RETURN_CODE GetDataFieldInfo (IN CHAR8 *, OUT UINT16 &, OUT UINT8 &, OUT UINT32 &, OUT BOOLEAN &);
215215

216216
EFI_VFR_RETURN_CODE GetUserDefinedTypeNameList (OUT CHAR8 ***, OUT UINT32 *);
217-
EFI_VFR_RETURN_CODE ExtractFieldNameAndArrary (IN CHAR8 *&, OUT CHAR8 *, OUT UINT32 &);
217+
EFI_VFR_RETURN_CODE ExtractFieldNameAndArrayIdx (IN CHAR8 *&, OUT CHAR8 *, OUT UINT32 &);
218218
BOOLEAN DataTypeHasBitField (IN CHAR8 *);
219219
BOOLEAN IsThisBitField (IN CHAR8 *);
220220

0 commit comments

Comments
 (0)