summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2014-04-29 22:03:45 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-05-06 18:54:59 -0400
commitd87a2b75cd00a9e62c2b218e7d586c30961eb311 (patch)
treeb8341e525068cf8cabe678b8a4a5753a705dcb19 /tools
parentfad6449b4a96d7d7e61ebdfd16fd3a80833526bf (diff)
ACPICA: acpidump: Fix code issue in invoking fread in the loop.
This patch fixes an issue that the while loop is not needed as fread() should return exact the bytes of expected. The patch is tested by runing diff against the output of "-c" mode and the normal mode, and only finds the following differences: 1. table addresses: the "-c" mode will always fill 0x0000000000000000 for the address. 2. RSDP/RSDT/XSDT: there is no generation of such tables for "-c" mode. So the test result shows the fix is valid. Lv Zheng. Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/power/acpi/os_specific/service_layers/oslinuxtbl.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
index e975aa90016a..dc6509884c25 100644
--- a/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
+++ b/tools/power/acpi/os_specific/service_layers/oslinuxtbl.c
@@ -1112,7 +1112,6 @@ osl_read_table_from_file(char *filename,
1112 struct acpi_table_header *local_table = NULL; 1112 struct acpi_table_header *local_table = NULL;
1113 u32 table_length; 1113 u32 table_length;
1114 s32 count; 1114 s32 count;
1115 u32 total = 0;
1116 acpi_status status = AE_OK; 1115 acpi_status status = AE_OK;
1117 1116
1118 /* Open the file */ 1117 /* Open the file */
@@ -1163,16 +1162,12 @@ osl_read_table_from_file(char *filename,
1163 1162
1164 fseek(table_file, file_offset, SEEK_SET); 1163 fseek(table_file, file_offset, SEEK_SET);
1165 1164
1166 while (!feof(table_file) && total < table_length) { 1165 count = fread(local_table, 1, table_length, table_file);
1167 count = fread(local_table + total, 1, table_length - total, table_file); 1166 if (count != table_length) {
1168 if (count < 0) { 1167 fprintf(stderr, "%4.4s: Could not read table content\n",
1169 fprintf(stderr, "%4.4s: Could not read table content\n", 1168 header.signature);
1170 header.signature); 1169 status = AE_INVALID_TABLE_LENGTH;
1171 status = AE_INVALID_TABLE_LENGTH; 1170 goto exit;
1172 goto exit;
1173 }
1174
1175 total += count;
1176 } 1171 }
1177 1172
1178 /* Validate checksum */ 1173 /* Validate checksum */