Skip to content

Commit

Permalink
Rename nameseg length macro/define for clarity
Browse files Browse the repository at this point in the history
ACPI_NAME_SIZE changed to ACPI_NAMESEG_SIZE
This clarifies that this is the length of an individual
nameseg, not the length of a generic namestring/namepath.
Improves understanding of the code.
  • Loading branch information
acpibob committed Feb 22, 2019
1 parent 92ec093 commit 24870bd
Show file tree
Hide file tree
Showing 38 changed files with 82 additions and 82 deletions.
2 changes: 1 addition & 1 deletion source/common/acfileio.c
Expand Up @@ -585,7 +585,7 @@ AcValidateTableHeader (
* These fields must be ASCII: OemId, OemTableId, AslCompilerId.
* We allow a NULL terminator in OemId and OemTableId.
*/
for (i = 0; i < ACPI_NAME_SIZE; i++)
for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
{
if (!ACPI_IS_ASCII ((UINT8) TableHeader.AslCompilerId[i]))
{
Expand Down
2 changes: 1 addition & 1 deletion source/common/adisasm.c
Expand Up @@ -459,7 +459,7 @@ AdDisassembleOneTable (
*/
if (AcpiGbl_CaptureComments)
{
strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAME_SIZE);
strncpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAMESEG_SIZE);
}
#endif

Expand Down
6 changes: 3 additions & 3 deletions source/common/dmrestag.c
Expand Up @@ -822,10 +822,10 @@ AcpiGetTagPathname (
* end up in the final compiled AML, it's just an appearance issue for the
* disassembled code.
*/
PathnameEnd = Pathname + (RequiredSize - ACPI_NAME_SIZE - 1);
PathnameEnd = Pathname + (RequiredSize - ACPI_NAMESEG_SIZE - 1);
ACPI_COPY_NAMESEG (PathnameEnd, ResourceNode->Name.Ascii);

PathnameEnd += ACPI_NAME_SIZE;
PathnameEnd += ACPI_NAMESEG_SIZE;
*PathnameEnd = '.';

PathnameEnd++;
Expand Down Expand Up @@ -871,7 +871,7 @@ static void
AcpiDmUpdateResourceName (
ACPI_NAMESPACE_NODE *ResourceNode)
{
char Name[ACPI_NAME_SIZE];
char Name[ACPI_NAMESEG_SIZE];


/* Ignore if a unique name has already been assigned */
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/aslanalyze.c
Expand Up @@ -563,14 +563,14 @@ ApCheckForGpeNameConflict (
{
ACPI_PARSE_OBJECT *NextOp;
UINT32 GpeNumber;
char Name[ACPI_NAME_SIZE + 1];
char Target[ACPI_NAME_SIZE];
char Name[ACPI_NAMESEG_SIZE + 1];
char Target[ACPI_NAMESEG_SIZE];


/* Need a null-terminated string version of NameSeg */

ACPI_MOVE_32_TO_32 (Name, &Op->Asl.NameSeg);
Name[ACPI_NAME_SIZE] = 0;
Name[ACPI_NAMESEG_SIZE] = 0;

/*
* For a GPE method:
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslcompiler.l
Expand Up @@ -813,7 +813,7 @@ NamePathTail [.]{NameSeg}

{NameSeg} { char *s;
count (0);
s=UtLocalCacheCalloc (ACPI_NAME_SIZE + 1);
s=UtLocalCacheCalloc (ACPI_NAMESEG_SIZE + 1);
if (strcmp (AslCompilertext, "\\"))
{
/*
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/aslload.c
Expand Up @@ -703,7 +703,7 @@ LdNamespace1Begin (

/* However, this is an error -- operand to Scope must exist */

if (strlen (Op->Asl.ExternalName) == ACPI_NAME_SIZE)
if (strlen (Op->Asl.ExternalName) == ACPI_NAMESEG_SIZE)
{
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
Op->Asl.ExternalName);
Expand Down Expand Up @@ -1096,7 +1096,7 @@ LdNamespace2Begin (
{
/* Standalone NameSeg vs. NamePath */

if (strlen (Arg->Asl.ExternalName) == ACPI_NAME_SIZE)
if (strlen (Arg->Asl.ExternalName) == ACPI_NAMESEG_SIZE)
{
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
Arg->Asl.ExternalName);
Expand Down
10 changes: 5 additions & 5 deletions source/compiler/asloffset.c
Expand Up @@ -258,7 +258,7 @@ LsAmlOffsetWalk (
/* Get offset of last nameseg and the actual data */

NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(Op->Asl.FinalAmlLength - ACPI_NAME_SIZE);
(Op->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);

DataOffset = AslGbl_CurrentAmlOffset + Length +
Op->Asl.FinalAmlLength;
Expand Down Expand Up @@ -323,7 +323,7 @@ LsAmlOffsetWalk (
/* Get offset of last nameseg and the actual data */

NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE);
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);

DataOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength + 1);
Expand Down Expand Up @@ -370,7 +370,7 @@ LsAmlOffsetWalk (
/* Get offset of last nameseg and the actual data (flags byte) */

NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE);
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);

DataOffset = AslGbl_CurrentAmlOffset + Length +
NextOp->Asl.FinalAmlLength;
Expand All @@ -394,7 +394,7 @@ LsAmlOffsetWalk (
/* Get offset of last nameseg and the actual data (PBlock address) */

NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE);
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);

DataOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength + 1);
Expand All @@ -419,7 +419,7 @@ LsAmlOffsetWalk (
/* Get offset of last nameseg */

NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAME_SIZE);
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);

LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, 0,
Op->Asl.ParseOpName, 0, (UINT8) 0, Op->Asl.AmlOpcode);
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/asloperands.c
Expand Up @@ -1087,13 +1087,13 @@ OpnDoDefinitionBlock (
if (Child->Asl.Value.String)
{
AslGbl_TableSignature = Child->Asl.Value.String;
if (strlen (AslGbl_TableSignature) != ACPI_NAME_SIZE)
if (strlen (AslGbl_TableSignature) != ACPI_NAMESEG_SIZE)
{
AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
"Length must be exactly 4 characters");
}

for (i = 0; i < ACPI_NAME_SIZE; i++)
for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
{
if (!isalnum ((int) AslGbl_TableSignature[i]))
{
Expand Down
8 changes: 4 additions & 4 deletions source/compiler/aslopt.c
Expand Up @@ -241,7 +241,7 @@ OptSearchToRoot (
* not match, and we cannot use this optimization.
*/
Path = &(((char *) TargetPath->Pointer)[
TargetPath->Length - ACPI_NAME_SIZE]);
TargetPath->Length - ACPI_NAMESEG_SIZE]);
ScopeInfo.Scope.Node = CurrentNode;

/* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
Expand Down Expand Up @@ -275,7 +275,7 @@ OptSearchToRoot (

/* We must allocate a new string for the name (TargetPath gets deleted) */

*NewPath = UtLocalCacheCalloc (ACPI_NAME_SIZE + 1);
*NewPath = UtLocalCacheCalloc (ACPI_NAMESEG_SIZE + 1);
strcpy (*NewPath, Path);

if (strncmp (*NewPath, "_T_", 3))
Expand Down Expand Up @@ -343,7 +343,7 @@ OptBuildShortestPath (
* can possibly have in common. (To optimize, we have to have at least 1)
*
* Note: The external NamePath string lengths are always a multiple of 5
* (ACPI_NAME_SIZE + separator)
* (ACPI_NAMESEG_SIZE + separator)
*/
MaxCommonSegments = TargetPath->Length / ACPI_PATH_SEGMENT_LENGTH;
if (CurrentPath->Length < TargetPath->Length)
Expand Down Expand Up @@ -713,7 +713,7 @@ OptOptimizeNamePath (
* to be any possibility that it can be optimized to a shorter string
*/
AmlNameStringLength = strlen (AmlNameString);
if (AmlNameStringLength <= ACPI_NAME_SIZE)
if (AmlNameStringLength <= ACPI_NAMESEG_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"NAMESEG %4.4s\n", AmlNameString));
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslutils.c
Expand Up @@ -752,7 +752,7 @@ UtPadNameWithUnderscores (
UINT32 i;


for (i = 0; (i < ACPI_NAME_SIZE); i++)
for (i = 0; (i < ACPI_NAMESEG_SIZE); i++)
{
if (*NameSeg)
{
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/aslxref.c
Expand Up @@ -708,7 +708,7 @@ XfNamespaceLocateBegin (
* We didn't find the name reference by path -- we can qualify this
* a little better before we print an error message
*/
if (strlen (Path) == ACPI_NAME_SIZE)
if (strlen (Path) == ACPI_NAMESEG_SIZE)
{
/* A simple, one-segment ACPI name */

Expand Down Expand Up @@ -770,7 +770,7 @@ XfNamespaceLocateBegin (
* doesn't exist or just can't be reached. However, we
* can differentiate between a NameSeg vs. NamePath.
*/
if (strlen (Op->Asl.ExternalName) == ACPI_NAME_SIZE)
if (strlen (Op->Asl.ExternalName) == ACPI_NAMESEG_SIZE)
{
AslError (ASL_ERROR, ASL_MSG_NOT_FOUND, Op,
Op->Asl.ExternalName);
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/dttemplate.c
Expand Up @@ -346,7 +346,7 @@ DtCreateOneTemplateFile (
* 2) Signature must be a recognized ACPI table
* 3) There must be a template associated with the signature
*/
if (strlen (Signature) != ACPI_NAME_SIZE)
if (strlen (Signature) != ACPI_NAMESEG_SIZE)
{
fprintf (stderr,
"%s: Invalid ACPI table signature "
Expand Down
2 changes: 1 addition & 1 deletion source/components/debugger/dbnames.c
Expand Up @@ -557,7 +557,7 @@ AcpiDbFindNameInNamespace (
char *AcpiNamePtr = AcpiName;


if (strlen (NameArg) > ACPI_NAME_SIZE)
if (strlen (NameArg) > ACPI_NAMESEG_SIZE)
{
AcpiOsPrintf ("Name must be no longer than 4 characters\n");
return (AE_OK);
Expand Down
6 changes: 3 additions & 3 deletions source/components/disassembler/dmnames.c
Expand Up @@ -199,8 +199,8 @@ AcpiDmDumpName (

/* Remove all trailing underscores from the name */

Length = ACPI_NAME_SIZE;
for (i = (ACPI_NAME_SIZE - 1); i != 0; i--)
Length = ACPI_NAMESEG_SIZE;
for (i = (ACPI_NAMESEG_SIZE - 1); i != 0; i--)
{
if (NewName[i] == '_')
{
Expand Down Expand Up @@ -378,7 +378,7 @@ AcpiDmNamestring (
AcpiOsPrintf (".");
}

Name += ACPI_NAME_SIZE;
Name += ACPI_NAMESEG_SIZE;
}
}

Expand Down
4 changes: 2 additions & 2 deletions source/components/events/evgpeinit.c
Expand Up @@ -447,7 +447,7 @@ AcpiEvMatchGpeMethod (
ACPI_STATUS Status;
UINT32 GpeNumber;
UINT8 TempGpeNumber;
char Name[ACPI_NAME_SIZE + 1];
char Name[ACPI_NAMESEG_SIZE + 1];
UINT8 Type;


Expand All @@ -468,7 +468,7 @@ AcpiEvMatchGpeMethod (
* 1) Extract the method name and null terminate it
*/
ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer);
Name[ACPI_NAME_SIZE] = 0;
Name[ACPI_NAMESEG_SIZE] = 0;

/* 2) Name must begin with an underscore */

Expand Down
6 changes: 3 additions & 3 deletions source/components/executer/exnames.c
Expand Up @@ -207,11 +207,11 @@ AcpiExAllocateNameString (
{
/* Special case for root */

SizeNeeded = 1 + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
SizeNeeded = 1 + (ACPI_NAMESEG_SIZE * NumNameSegs) + 2 + 1;
}
else
{
SizeNeeded = PrefixCount + (ACPI_NAME_SIZE * NumNameSegs) + 2 + 1;
SizeNeeded = PrefixCount + (ACPI_NAMESEG_SIZE * NumNameSegs) + 2 + 1;
}

/*
Expand Down Expand Up @@ -310,7 +310,7 @@ AcpiExNameSegment (
}

for (Index = 0;
(Index < ACPI_NAME_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0));
(Index < ACPI_NAMESEG_SIZE) && (AcpiUtValidNameChar (*AmlAddress, 0));
Index++)
{
CharBuf[Index] = *AmlAddress++;
Expand Down
2 changes: 1 addition & 1 deletion source/components/namespace/nsaccess.c
Expand Up @@ -851,7 +851,7 @@ AcpiNsLookup (

/* Point to next name segment and make this node current */

Path += ACPI_NAME_SIZE;
Path += ACPI_NAMESEG_SIZE;
CurrentNode = ThisNode;
}

Expand Down
2 changes: 1 addition & 1 deletion source/components/namespace/nsdump.c
Expand Up @@ -236,7 +236,7 @@ AcpiNsPrintPathname (
AcpiOsPrintf ("?");
}

Pathname += ACPI_NAME_SIZE;
Pathname += ACPI_NAMESEG_SIZE;
NumSegments--;
if (NumSegments)
{
Expand Down
6 changes: 3 additions & 3 deletions source/components/namespace/nsnames.c
Expand Up @@ -274,7 +274,7 @@ AcpiNsHandleToName (

NodeName = AcpiUtGetNodeName (Node);
ACPI_COPY_NAMESEG (Buffer->Pointer, NodeName);
((char *) Buffer->Pointer) [ACPI_NAME_SIZE] = 0;
((char *) Buffer->Pointer) [ACPI_NAMESEG_SIZE] = 0;

ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%4.4s\n", (char *) Buffer->Pointer));
return_ACPI_STATUS (AE_OK);
Expand Down Expand Up @@ -374,7 +374,7 @@ AcpiNsBuildNormalizedPath (
BOOLEAN NoTrailing)
{
UINT32 Length = 0, i;
char Name[ACPI_NAME_SIZE];
char Name[ACPI_NAMESEG_SIZE];
BOOLEAN DoNoTrailing;
char c, *Left, *Right;
ACPI_NAMESPACE_NODE *NextNode;
Expand Down Expand Up @@ -657,7 +657,7 @@ AcpiNsNormalizePathname (
{
/* Do one nameseg at a time */

for (i = 0; (i < ACPI_NAME_SIZE) && *InputPath; i++)
for (i = 0; (i < ACPI_NAMESEG_SIZE) && *InputPath; i++)
{
if ((i == 0) || (*InputPath != '_')) /* First char is allowed to be underscore */
{
Expand Down
2 changes: 1 addition & 1 deletion source/components/namespace/nsrepair2.c
Expand Up @@ -169,7 +169,7 @@ ACPI_STATUS (*ACPI_REPAIR_FUNCTION) (

typedef struct acpi_repair_info
{
char Name[ACPI_NAME_SIZE];
char Name[ACPI_NAMESEG_SIZE];
ACPI_REPAIR_FUNCTION RepairFunction;

} ACPI_REPAIR_INFO;
Expand Down
10 changes: 5 additions & 5 deletions source/components/namespace/nsutils.c
Expand Up @@ -351,7 +351,7 @@ AcpiNsGetInternalNameLength (
}
}

Info->Length = (ACPI_NAME_SIZE * Info->NumSegments) +
Info->Length = (ACPI_NAMESEG_SIZE * Info->NumSegments) +
4 + Info->NumCarats;

Info->NextExternalChar = NextExternalChar;
Expand Down Expand Up @@ -443,7 +443,7 @@ AcpiNsBuildInternalName (

for (; NumSegments; NumSegments--)
{
for (i = 0; i < ACPI_NAME_SIZE; i++)
for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
{
if (ACPI_IS_PATH_SEPARATOR (*ExternalName) ||
(*ExternalName == 0))
Expand Down Expand Up @@ -472,7 +472,7 @@ AcpiNsBuildInternalName (
/* Move on the next segment */

ExternalName++;
Result += ACPI_NAME_SIZE;
Result += ACPI_NAMESEG_SIZE;
}

/* Terminate the string */
Expand Down Expand Up @@ -725,8 +725,8 @@ AcpiNsExternalizeName (
&InternalName[NamesIndex]);
AcpiUtRepairName (&(*ConvertedName)[j]);

j += ACPI_NAME_SIZE;
NamesIndex += ACPI_NAME_SIZE;
j += ACPI_NAMESEG_SIZE;
NamesIndex += ACPI_NAMESEG_SIZE;
}
}

Expand Down

0 comments on commit 24870bd

Please sign in to comment.