summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Moore <Robert.Moore@intel.com>2014-02-21 09:15:04 -0800
committerRobert Moore <Robert.Moore@intel.com>2014-02-21 09:15:04 -0800
commit74e80e335a68b442df69ff35771bafdfca43ca0c (patch)
treeb8dd6e198b2d1c3431ad33e780b1ce876af9655e
parent70d2a6659594984dbc357c8ce15c48411fd25de8 (diff)
AcpiDump: Update error handling in the os*tbl modules.
Correctly cleanup and return error codes for both the Windows and Linux versions of the utility.
-rw-r--r--source/os_specific/service_layers/oslinuxtbl.c28
-rw-r--r--source/os_specific/service_layers/oswintbl.c26
2 files changed, 30 insertions, 24 deletions
diff --git a/source/os_specific/service_layers/oslinuxtbl.c b/source/os_specific/service_layers/oslinuxtbl.c
index 874954c1a..d08f7491f 100644
--- a/source/os_specific/service_layers/oslinuxtbl.c
+++ b/source/os_specific/service_layers/oslinuxtbl.c
@@ -325,22 +325,22 @@ AcpiOsGetTableByAddress (
if (TableLength == 0)
{
Status = AE_BAD_HEADER;
- goto ErrorExit;
+ goto Exit;
}
LocalTable = calloc (1, TableLength);
if (!LocalTable)
{
Status = AE_NO_MEMORY;
- goto ErrorExit;
+ goto Exit;
}
ACPI_MEMCPY (LocalTable, MappedTable, TableLength);
-ErrorExit:
+Exit:
OslUnmapTable (MappedTable);
*Table = LocalTable;
- return (AE_OK);
+ return (Status);
}
@@ -1075,7 +1075,7 @@ OslGetBiosTable (
if (TableLength == 0)
{
Status = AE_BAD_HEADER;
- goto ErrorExit;
+ goto Exit;
}
/* Copy table to local buffer and return it */
@@ -1084,16 +1084,16 @@ OslGetBiosTable (
if (!LocalTable)
{
Status = AE_NO_MEMORY;
- goto ErrorExit;
+ goto Exit;
}
ACPI_MEMCPY (LocalTable, MappedTable, TableLength);
*Address = TableAddress;
*Table = LocalTable;
-ErrorExit:
+Exit:
OslUnmapTable (MappedTable);
- return (AE_OK);
+ return (Status);
}
@@ -1362,7 +1362,7 @@ OslReadTableFromFile (
{
fprintf (stderr, "Could not read table header: %s\n", Filename);
Status = AE_BAD_HEADER;
- goto ErrorExit;
+ goto Exit;
}
/* If signature is specified, it must match the table */
@@ -1373,14 +1373,14 @@ OslReadTableFromFile (
fprintf (stderr, "Incorrect signature: Expecting %4.4s, found %4.4s\n",
Signature, Header.Signature);
Status = AE_BAD_SIGNATURE;
- goto ErrorExit;
+ goto Exit;
}
TableLength = ApGetTableLength (&Header);
if (TableLength == 0)
{
Status = AE_BAD_HEADER;
- goto ErrorExit;
+ goto Exit;
}
/* Read the entire table into a local buffer */
@@ -1392,7 +1392,7 @@ OslReadTableFromFile (
"%4.4s: Could not allocate buffer for table of length %X\n",
Header.Signature, TableLength);
Status = AE_NO_MEMORY;
- goto ErrorExit;
+ goto Exit;
}
fseek (TableFile, FileOffset, SEEK_SET);
@@ -1405,7 +1405,7 @@ OslReadTableFromFile (
fprintf (stderr, "%4.4s: Could not read table content\n",
Header.Signature);
Status = AE_INVALID_TABLE_LENGTH;
- goto ErrorExit;
+ goto Exit;
}
Total += Count;
@@ -1415,7 +1415,7 @@ OslReadTableFromFile (
(void) ApIsValidChecksum (LocalTable);
-ErrorExit:
+Exit:
fclose (TableFile);
*Table = LocalTable;
return (Status);
diff --git a/source/os_specific/service_layers/oswintbl.c b/source/os_specific/service_layers/oswintbl.c
index bf6158354..972184243 100644
--- a/source/os_specific/service_layers/oswintbl.c
+++ b/source/os_specific/service_layers/oswintbl.c
@@ -294,6 +294,7 @@ AcpiOsGetTableByName (
HKEY SubKey;
ULONG i;
ACPI_TABLE_HEADER *ReturnTable;
+ ACPI_STATUS Status = AE_OK;
/*
@@ -366,7 +367,8 @@ AcpiOsGetTableByName (
{
fprintf (stderr, "Could not open %s entry: %s\n",
Signature, WindowsFormatException (WinStatus));
- return (AE_ERROR);
+ Status = AE_ERROR;
+ goto Cleanup;
}
RegCloseKey (Handle);
@@ -385,7 +387,8 @@ AcpiOsGetTableByName (
{
fprintf (stderr, "Could not get %s registry entry: %s\n",
Signature, WindowsFormatException (WinStatus));
- return (AE_ERROR);
+ Status = AE_ERROR;
+ goto Cleanup;
}
if (Type == REG_BINARY)
@@ -398,11 +401,12 @@ AcpiOsGetTableByName (
WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
NULL, &DataSize);
- if (WinStatus != ERROR_SUCCESS)
+ if (WinStatus = ERROR_SUCCESS)
{
fprintf (stderr, "Could not read the %s table size: %s\n",
Signature, WindowsFormatException (WinStatus));
- return (AE_ERROR);
+ Status = AE_ERROR;
+ goto Cleanup;
}
/* Allocate a new buffer for the table */
@@ -410,6 +414,7 @@ AcpiOsGetTableByName (
ReturnTable = malloc (DataSize);
if (!ReturnTable)
{
+ Status = AE_NO_MEMORY;
goto Cleanup;
}
@@ -417,20 +422,21 @@ AcpiOsGetTableByName (
WinStatus = RegQueryValueEx (Handle, KeyBuffer, NULL, NULL,
(UCHAR *) ReturnTable, &DataSize);
- if (WinStatus != ERROR_SUCCESS)
+ if (WinStatus = ERROR_SUCCESS)
{
fprintf (stderr, "Could not read %s data: %s\n",
Signature, WindowsFormatException (WinStatus));
free (ReturnTable);
- return (AE_ERROR);
+ Status = AE_ERROR;
+ goto Cleanup;
}
-Cleanup:
- RegCloseKey (Handle);
-
*Table = ReturnTable;
*Address = 0;
- return (AE_OK);
+
+Cleanup:
+ RegCloseKey (Handle);
+ return (Status);
}