Skip to content

Commit

Permalink
De-macroize calls to standard C library functions.
Browse files Browse the repository at this point in the history
Across all of ACPICA. Replace C library macros such as ACPI_STRLEN
with the standard names such as strlen. The original purpose for
these macros is long since obsolete.
  • Loading branch information
acpibob committed Jun 9, 2015
1 parent 960dac7 commit 3b1026e
Show file tree
Hide file tree
Showing 120 changed files with 614 additions and 521 deletions.
2 changes: 1 addition & 1 deletion source/common/adisasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ AdAmlDisassemble (
while (ExternalFileList)
{
ExternalFilename = ExternalFileList->Path;
if (!ACPI_STRCMP (ExternalFilename, Filename))
if (!strcmp (ExternalFilename, Filename))
{
/* Next external file */

Expand Down
2 changes: 1 addition & 1 deletion source/common/ahids.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ AcpiAhMatchHardwareId (

for (Info = AslDeviceIds; Info->Name; Info++)
{
if (!ACPI_STRCMP (HardwareId, Info->Name))
if (!strcmp (HardwareId, Info->Name))
{
return (Info);
}
Expand Down
2 changes: 1 addition & 1 deletion source/common/ahuuids.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ AcpiAhMatchUuid (

AcpiUtConvertStringToUuid (Info->String, UuidBuffer);

if (!ACPI_MEMCMP (Data, UuidBuffer, UUID_BUFFER_LENGTH))
if (!memcmp (Data, UuidBuffer, UUID_BUFFER_LENGTH))
{
return (Info->Description);
}
Expand Down
16 changes: 8 additions & 8 deletions source/common/dmextern.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ AcpiDmNormalizeParentPrefix (
return (NULL);
}

Length = (ACPI_STRLEN (ParentPath) + ACPI_STRLEN (Path) + 1);
Length = (strlen (ParentPath) + strlen (Path) + 1);
if (ParentPath[1])
{
/*
Expand Down Expand Up @@ -325,20 +325,20 @@ AcpiDmNormalizeParentPrefix (
*
* Copy the parent path
*/
ACPI_STRCPY (Fullpath, &ParentPath[Index]);
strcpy (Fullpath, &ParentPath[Index]);

/*
* Add dot separator
* (don't need dot if parent fullpath is a single backslash)
*/
if (ParentPath[1])
{
ACPI_STRCAT (Fullpath, ".");
strcat (Fullpath, ".");
}

/* Copy child path (carat parent prefix(es) were skipped above) */

ACPI_STRCAT (Fullpath, Path);
strcat (Fullpath, Path);

Cleanup:
ACPI_FREE (ParentPath);
Expand Down Expand Up @@ -720,13 +720,13 @@ AcpiDmAddNodeToExternalList (

if ((*ExternalPath == AML_ROOT_PREFIX) && (ExternalPath[1]))
{
Temp = ACPI_ALLOCATE_ZEROED (ACPI_STRLEN (ExternalPath) + 1);
Temp = ACPI_ALLOCATE_ZEROED (strlen (ExternalPath) + 1);
if (!Temp)
{
return_VOID;
}

ACPI_STRCPY (Temp, &ExternalPath[1]);
strcpy (Temp, &ExternalPath[1]);
ACPI_FREE (ExternalPath);
ExternalPath = Temp;
}
Expand Down Expand Up @@ -878,7 +878,7 @@ AcpiDmCreateNewExternal (
NextExternal = AcpiGbl_ExternalList;
while (NextExternal)
{
if (!ACPI_STRCMP (ExternalPath, NextExternal->Path))
if (!strcmp (ExternalPath, NextExternal->Path))
{
/* Duplicate method, check that the Value (ArgCount) is the same */

Expand Down Expand Up @@ -921,7 +921,7 @@ AcpiDmCreateNewExternal (
NewExternal->Value = Value;
NewExternal->Path = ExternalPath;
NewExternal->Type = Type;
NewExternal->Length = (UINT16) ACPI_STRLEN (ExternalPath);
NewExternal->Length = (UINT16) strlen (ExternalPath);
NewExternal->InternalPath = InternalPath;

/* Link the new descriptor into the global list, alphabetically ordered */
Expand Down
8 changes: 4 additions & 4 deletions source/common/dmrestag.c
Original file line number Diff line number Diff line change
Expand Up @@ -751,10 +751,10 @@ AcpiGetTagPathname (
* end up in the final compiled AML, it's just an appearance issue for the
* disassembled code.
*/
Pathname[ACPI_STRLEN (Pathname) - ACPI_NAME_SIZE] = 0;
ACPI_STRNCAT (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
ACPI_STRCAT (Pathname, ".");
ACPI_STRNCAT (Pathname, Tag, ACPI_NAME_SIZE);
Pathname[strlen (Pathname) - ACPI_NAME_SIZE] = 0;
strncat (Pathname, ResourceNode->Name.Ascii, ACPI_NAME_SIZE);
strcat (Pathname, ".");
strncat (Pathname, Tag, ACPI_NAME_SIZE);

/* Internalize the namepath to AML format */

Expand Down
4 changes: 2 additions & 2 deletions source/common/dmtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ AcpiDmDumpDataTable (
TableData = AcpiDmGetTableData (Table->Signature);
if (!TableData)
{
if (!ACPI_STRNCMP (Table->Signature, "OEM", 3))
if (!strncmp (Table->Signature, "OEM", 3))
{
AcpiOsPrintf ("\n**** OEM-defined ACPI table [%4.4s], unknown contents\n\n",
Table->Signature);
Expand Down Expand Up @@ -928,7 +928,7 @@ AcpiDmDumpTable (

case ACPI_DMT_STRING:

ByteLength = ACPI_STRLEN (ACPI_CAST_PTR (char, Target)) + 1;
ByteLength = strlen (ACPI_CAST_PTR (char, Target)) + 1;
break;

case ACPI_DMT_GAS:
Expand Down
6 changes: 3 additions & 3 deletions source/common/dmtbdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ AcpiDmDumpUnicode (

for (i = 0; i < Length; i += 2)
{
if (!ACPI_IS_PRINT (Buffer[i]))
if (!isprint (Buffer[i]))
{
goto DumpRawBuffer;
}
Expand Down Expand Up @@ -1773,7 +1773,7 @@ AcpiDmDumpIort (
InfoTable = AcpiDmTableInfoIort1;
Length = ACPI_OFFSET (ACPI_IORT_NAMED_COMPONENT, DeviceName);
String = ACPI_ADD_PTR (char, IortNode, NodeOffset + Length);
Length += ACPI_STRLEN (String) + 1;
Length += strlen (String) + 1;
break;

case ACPI_IORT_NODE_PCI_ROOT_COMPLEX:
Expand Down Expand Up @@ -3416,7 +3416,7 @@ AcpiDmDumpStao (
while (Offset < Table->Length)
{
Namepath = ACPI_ADD_PTR (char, Table, Offset);
StringLength = ACPI_STRLEN (Namepath) + 1;
StringLength = strlen (Namepath) + 1;

AcpiDmLineHeader (Offset, StringLength, "Namestring");
AcpiOsPrintf ("\"%s\"\n", Namepath);
Expand Down
4 changes: 2 additions & 2 deletions source/common/getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ AcpiGetopt(
{
return (ACPI_OPT_END);
}
else if (ACPI_STRCMP (argv[AcpiGbl_Optind], "--") == 0)
else if (strcmp (argv[AcpiGbl_Optind], "--") == 0)
{
AcpiGbl_Optind++;
return (ACPI_OPT_END);
Expand All @@ -231,7 +231,7 @@ AcpiGetopt(
/* Make sure that the option is legal */

if (CurrentChar == ':' ||
(OptsPtr = ACPI_STRCHR (opts, CurrentChar)) == NULL)
(OptsPtr = strchr (opts, CurrentChar)) == NULL)
{
ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar);

Expand Down
10 changes: 5 additions & 5 deletions source/compiler/aslanalyze.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ AnIsInternalMethod (
ACPI_PARSE_OBJECT *Op)
{

if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
(!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
(!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (TRUE);
}
Expand All @@ -166,8 +166,8 @@ AnGetInternalMethodReturnType (
ACPI_PARSE_OBJECT *Op)
{

if ((!ACPI_STRCMP (Op->Asl.ExternalName, "\\_OSI")) ||
(!ACPI_STRCMP (Op->Asl.ExternalName, "_OSI")))
if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
(!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (ACPI_BTYPE_STRING);
}
Expand Down Expand Up @@ -534,7 +534,7 @@ ApCheckForGpeNameConflict (

/* Verify 3rd/4th chars are a valid hex value */

GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16);
GpeNumber = strtoul (&Name[2], NULL, 16);
if (GpeNumber == ACPI_UINT32_MAX)
{
return;
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ FlCheckForAscii (

/* Ensure character is either printable or a "space" char */

else if (!ACPI_IS_PRINT (Byte) && !ACPI_IS_SPACE (Byte))
else if (!isprint (Byte) && !isspace (Byte))
{
if ((BadBytes < 10) && (DisplayErrors))
{
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslcompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ UtDoConstant (
char *String);

ACPI_STATUS
UtStrtoul64 (
stroul64 (
char *String,
UINT32 Base,
UINT64 *RetInteger);
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslcompiler.l
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ NamePathTail [.]{NameSeg}
return (PARSEOP_NAMESTRING); }

. { count (1);
if (ACPI_IS_PRINT (*AslCompilertext))
if (isprint (*AslCompilertext))
{
sprintf (MsgBuffer,
"Invalid character (%c), expecting ASL keyword or name",
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/aslerror.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,11 +633,11 @@ AslCommonError2 (

/* Keep a copy of the extra message */

ACPI_STRCPY (MessageBuffer, ExtraMessage);
strcpy (MessageBuffer, ExtraMessage);
}

LineBuffer = UtLocalCalloc (strlen (SourceLine) + 1);
ACPI_STRCPY (LineBuffer, SourceLine);
strcpy (LineBuffer, SourceLine);

/* Initialize the error node */

Expand Down Expand Up @@ -719,7 +719,7 @@ AslCommonError (

/* Keep a copy of the extra message */

ACPI_STRCPY (MessageBuffer, ExtraMessage);
strcpy (MessageBuffer, ExtraMessage);
}

/* Initialize the error node */
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslfileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ FlPrintFile (
* Duplicate the output to the user preprocessor (.i) file,
* except: no #line directives.
*/
if (!ACPI_STRNCMP (Format, "#line", 5))
if (!strncmp (Format, "#line", 5))
{
return;
}
Expand Down
2 changes: 1 addition & 1 deletion source/compiler/aslfold.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ TrInstallReducedConstant (

Op->Asl.ParseOpcode = PARSEOP_STRING_LITERAL;
Op->Common.AmlOpcode = AML_STRING_OP;
Op->Asl.AmlLength = ACPI_STRLEN (ObjDesc->String.Pointer) + 1;
Op->Asl.AmlLength = strlen (ObjDesc->String.Pointer) + 1;
Op->Common.Value.String = ObjDesc->String.Pointer;

DbgPrint (ASL_PARSE_OUTPUT,
Expand Down
8 changes: 4 additions & 4 deletions source/compiler/aslmapenter.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ MpCreateGpioInfo (
/* Sort on source DeviceName first */

while (NextGpio &&
(ACPI_STRCMP (DeviceName, NextGpio->DeviceName) > 0))
(strcmp (DeviceName, NextGpio->DeviceName) > 0))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
Expand All @@ -321,7 +321,7 @@ MpCreateGpioInfo (

while (NextGpio &&
(NextGpio->PinNumber < PinNumber) &&
!ACPI_STRCMP (DeviceName, NextGpio->DeviceName))
!strcmp (DeviceName, NextGpio->DeviceName))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
Expand Down Expand Up @@ -388,7 +388,7 @@ MpCreateSerialInfo (
/* Sort on source DeviceName */

while (NextSerial &&
(ACPI_STRCMP (DeviceName, NextSerial->DeviceName) > 0))
(strcmp (DeviceName, NextSerial->DeviceName) > 0))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
Expand All @@ -398,7 +398,7 @@ MpCreateSerialInfo (

while (NextSerial &&
(NextSerial->Address < Address) &&
!ACPI_STRCMP (DeviceName, NextSerial->DeviceName))
!strcmp (DeviceName, NextSerial->DeviceName))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/aslmapoutput.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ MpEmitGpioInfo (
/* Print header info for the controller itself */

if (!PrevDeviceName ||
ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\n\nGPIO Controller: %-8s %-28s",
Expand Down Expand Up @@ -432,7 +432,7 @@ MpEmitSerialInfo (
/* Print header info for the controller itself */

if (!PrevDeviceName ||
ACPI_STRCMP (PrevDeviceName, Info->DeviceName))
strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ",
Type);
Expand Down
4 changes: 2 additions & 2 deletions source/compiler/aslmethod.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,15 @@ MtMethodAnalysisWalkBegin (

/* Special typechecking for _HID */

if (!ACPI_STRCMP (METHOD_NAME__HID, Op->Asl.NameSeg))
if (!strcmp (METHOD_NAME__HID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;
AnCheckId (Next, ASL_TYPE_HID);
}

/* Special typechecking for _CID */

else if (!ACPI_STRCMP (METHOD_NAME__CID, Op->Asl.NameSeg))
else if (!strcmp (METHOD_NAME__CID, Op->Asl.NameSeg))
{
Next = Op->Asl.Child->Asl.Next;

Expand Down
6 changes: 3 additions & 3 deletions source/compiler/aslopcodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ OpcDoEisaId (
* The EISAID string must be exactly 7 characters and of the form
* "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
*/
if (ACPI_STRLEN (InString) != 7)
if (strlen (InString) != 7)
{
Status = AE_BAD_PARAMETER;
}
Expand Down Expand Up @@ -927,7 +927,7 @@ OpcFindName (

for (i = 0, Str = List[0]; Str; i++, Str = List[i])
{
if (!(ACPI_STRNCMP (Str, Name, ACPI_STRLEN (Name))))
if (!(strncmp (Str, Name, strlen (Name))))
{
*Index = i;
return (TRUE);
Expand Down Expand Up @@ -979,7 +979,7 @@ OpcDoPld (
return;
}

ACPI_MEMSET (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));

Node = Op->Asl.Child;
while (Node)
Expand Down
6 changes: 3 additions & 3 deletions source/compiler/asloperands.c
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@ OpnDoDefinitionBlock (
if (Child->Asl.Value.String)
{
Gbl_TableSignature = Child->Asl.Value.String;
if (ACPI_STRLEN (Gbl_TableSignature) != 4)
if (strlen (Gbl_TableSignature) != 4)
{
AslError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, Child,
"Length not exactly 4");
Expand Down Expand Up @@ -1039,9 +1039,9 @@ OpnDoDefinitionBlock (
Child->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
if (Child->Asl.Value.String)
{
Length = ACPI_STRLEN (Child->Asl.Value.String);
Length = strlen (Child->Asl.Value.String);
Gbl_TableId = UtStringCacheCalloc (Length + 1);
ACPI_STRCPY (Gbl_TableId, Child->Asl.Value.String);
strcpy (Gbl_TableId, Child->Asl.Value.String);

/*
* Convert anything non-alphanumeric to an underscore. This
Expand Down
Loading

0 comments on commit 3b1026e

Please sign in to comment.