diff options
Diffstat (limited to 'source/tools/acpibin/abcompare.c')
-rw-r--r-- | source/tools/acpibin/abcompare.c | 52 |
1 files changed, 28 insertions, 24 deletions
diff --git a/source/tools/acpibin/abcompare.c b/source/tools/acpibin/abcompare.c index 46122274d4a9..a0b241f5c4fd 100644 --- a/source/tools/acpibin/abcompare.c +++ b/source/tools/acpibin/abcompare.c @@ -1,4 +1,3 @@ - /****************************************************************************** * * Module Name: abcompare - compare AML files @@ -158,10 +157,10 @@ AbValidateHeader ( if (!AcpiUtValidAcpiName (* (UINT32 *) &Header->Signature)) { printf ("Header signature is invalid\n"); - return FALSE; + return (FALSE); } - return TRUE; + return (TRUE); } @@ -398,14 +397,14 @@ AbCompareAmlFiles ( if (!File1) { printf ("Could not open file %s\n", File1Path); - return -1; + return (-1); } File2 = fopen (File2Path, "rb"); if (!File2) { printf ("Could not open file %s\n", File2Path); - return -1; + return (-1); } /* Read the ACPI header from each file */ @@ -414,20 +413,20 @@ AbCompareAmlFiles ( if (Actual1 < sizeof (ACPI_TABLE_HEADER)) { printf ("File %s does not contain an ACPI table header\n", File1Path); - return -1; + return (-1); } Actual2 = fread (&Header2, 1, sizeof (ACPI_TABLE_HEADER), File2); if (Actual2 < sizeof (ACPI_TABLE_HEADER)) { printf ("File %s does not contain an ACPI table header\n", File2Path); - return -1; + return (-1); } if ((!AbValidateHeader (&Header1)) || (!AbValidateHeader (&Header2))) { - return -1; + return (-1); } /* Table signatures must match */ @@ -435,7 +434,7 @@ AbCompareAmlFiles ( if (*((UINT32 *) Header1.Signature) != *((UINT32 *) Header2.Signature)) { printf ("Table signatures do not match\n"); - return -1; + return (-1); } if (!Gbl_TerseMode) @@ -446,7 +445,7 @@ AbCompareAmlFiles ( AbPrintHeaderInfo (&Header2); } - if (memcmp (Header1.Signature, Header2.Signature, sizeof (ACPI_TABLE_HEADER))) + if (memcmp (&Header1, &Header2, sizeof (ACPI_TABLE_HEADER))) { printf ("Headers do not match exactly\n"); HeaderMismatch = TRUE; @@ -468,7 +467,7 @@ AbCompareAmlFiles ( if (Mismatches > 100) { printf ("100 Mismatches: Too many mismatches\n"); - return -1; + return (-1); } } @@ -500,7 +499,7 @@ AbCompareAmlFiles ( } printf ("%u Mismatches found\n", Mismatches); - return 0; + return (0); } @@ -528,7 +527,7 @@ AbGetFile ( if (!FileHandle) { printf ("Could not open %s\n", Filename); - return NULL; + return (NULL); } /* Need file size to allocate a buffer */ @@ -596,12 +595,12 @@ AbDumpAmlFile ( if (!FileOutHandle) { printf ("Could not open %s\n", File2Path); - return -1; + return (-1); } if (!AbValidateHeader ((ACPI_TABLE_HEADER *) FileBuffer)) { - return -1; + return (-1); } /* Convert binary AML to text, using common dump buffer routine */ @@ -611,10 +610,10 @@ AbDumpAmlFile ( AcpiOsPrintf ("%4.4s\n", ((ACPI_TABLE_HEADER *) FileBuffer)->Signature); AcpiDbgLevel = ACPI_UINT32_MAX; - AcpiUtDumpBuffer ((UINT8 *) FileBuffer, FileSize, + AcpiUtDebugDumpBuffer ((UINT8 *) FileBuffer, FileSize, DB_BYTE_DISPLAY, ACPI_UINT32_MAX); - return 0; + return (0); } @@ -648,14 +647,14 @@ AbExtractAmlFile ( if (!FileHandle) { printf ("Could not open %s\n", File1Path); - return -1; + return (-1); } FileOutHandle = fopen (File2Path, "w+b"); if (!FileOutHandle) { printf ("Could not open %s\n", File2Path); - return -1; + return (-1); } /* Force input table sig to uppercase */ @@ -672,7 +671,7 @@ AbExtractAmlFile ( { /* The 4-char ACPI signature appears at the beginning of a line */ - if (!strncmp (Buffer, TableSig, 4)) + if (ACPI_COMPARE_NAME (Buffer, TableSig)) { printf ("Found table [%4.4s]\n", TableSig); @@ -710,7 +709,12 @@ AbExtractAmlFile ( /* Write the converted (binary) byte */ - fwrite (&Value, 1, 1, FileOutHandle); + if (fwrite (&Value, 1, 1, FileOutHandle) < 1) + { + printf ("Error writing byte %u to output file: %s\n", + Count, File2Path); + goto Exit; + } Count++; } } @@ -725,13 +729,13 @@ AbExtractAmlFile ( printf ("Could not match table signature\n"); fclose (FileHandle); - return -1; + return (-1); Exit: printf ("%u (0x%X) bytes written to %s\n", Count, Count, File2Path); fclose (FileHandle); fclose (FileOutHandle); - return 0; + return (0); } @@ -747,7 +751,7 @@ ACPI_PHYSICAL_ADDRESS AeLocalGetRootPointer ( void) { - return AE_OK; + return (AE_OK); } ACPI_THREAD_ID |