aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorLv Zheng <lv.zheng@intel.com>2014-07-07 22:07:33 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-07-08 08:22:27 -0400
commitfbee6b21a3820a55ec36a2aceb138f3973a955ac (patch)
treeff0c7ecf0730d9e408cdd9ac1d1dc5fae620da8b /tools/power
parenta92e95773d8e2cd58124aea147cb833f33f1e196 (diff)
ACPICA: acpidump: Add memory/string OSL usage to improve portability
This patch adds code to use generic OSL for acpidump to improve the portability of this tool. 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/power')
-rw-r--r--tools/power/acpi/tools/acpidump/apdump.c16
-rw-r--r--tools/power/acpi/tools/acpidump/apfiles.c11
2 files changed, 14 insertions, 13 deletions
diff --git a/tools/power/acpi/tools/acpidump/apdump.c b/tools/power/acpi/tools/acpidump/apdump.c
index e8729aa3a60e..ccb6262829d6 100644
--- a/tools/power/acpi/tools/acpidump/apdump.c
+++ b/tools/power/acpi/tools/acpidump/apdump.c
@@ -252,7 +252,7 @@ int ap_dump_all_tables(void)
252 } 252 }
253 253
254 table_status = ap_dump_table_buffer(table, instance, address); 254 table_status = ap_dump_table_buffer(table, instance, address);
255 free(table); 255 ACPI_FREE(table);
256 256
257 if (table_status) { 257 if (table_status) {
258 break; 258 break;
@@ -303,7 +303,7 @@ int ap_dump_table_by_address(char *ascii_address)
303 } 303 }
304 304
305 table_status = ap_dump_table_buffer(table, 0, address); 305 table_status = ap_dump_table_buffer(table, 0, address);
306 free(table); 306 ACPI_FREE(table);
307 return (table_status); 307 return (table_status);
308} 308}
309 309
@@ -329,7 +329,7 @@ int ap_dump_table_by_name(char *signature)
329 acpi_status status; 329 acpi_status status;
330 int table_status; 330 int table_status;
331 331
332 if (strlen(signature) != ACPI_NAME_SIZE) { 332 if (ACPI_STRLEN(signature) != ACPI_NAME_SIZE) {
333 fprintf(stderr, 333 fprintf(stderr,
334 "Invalid table signature [%s]: must be exactly 4 characters\n", 334 "Invalid table signature [%s]: must be exactly 4 characters\n",
335 signature); 335 signature);
@@ -338,15 +338,15 @@ int ap_dump_table_by_name(char *signature)
338 338
339 /* Table signatures are expected to be uppercase */ 339 /* Table signatures are expected to be uppercase */
340 340
341 strcpy(local_signature, signature); 341 ACPI_STRCPY(local_signature, signature);
342 acpi_ut_strupr(local_signature); 342 acpi_ut_strupr(local_signature);
343 343
344 /* To be friendly, handle tables whose signatures do not match the name */ 344 /* To be friendly, handle tables whose signatures do not match the name */
345 345
346 if (ACPI_COMPARE_NAME(local_signature, "FADT")) { 346 if (ACPI_COMPARE_NAME(local_signature, "FADT")) {
347 strcpy(local_signature, ACPI_SIG_FADT); 347 ACPI_STRCPY(local_signature, ACPI_SIG_FADT);
348 } else if (ACPI_COMPARE_NAME(local_signature, "MADT")) { 348 } else if (ACPI_COMPARE_NAME(local_signature, "MADT")) {
349 strcpy(local_signature, ACPI_SIG_MADT); 349 ACPI_STRCPY(local_signature, ACPI_SIG_MADT);
350 } 350 }
351 351
352 /* Dump all instances of this signature (to handle multiple SSDTs) */ 352 /* Dump all instances of this signature (to handle multiple SSDTs) */
@@ -369,7 +369,7 @@ int ap_dump_table_by_name(char *signature)
369 } 369 }
370 370
371 table_status = ap_dump_table_buffer(table, instance, address); 371 table_status = ap_dump_table_buffer(table, instance, address);
372 free(table); 372 ACPI_FREE(table);
373 373
374 if (table_status) { 374 if (table_status) {
375 break; 375 break;
@@ -424,6 +424,6 @@ int ap_dump_table_from_file(char *pathname)
424 table_status = ap_dump_table_buffer(table, 0, 0); 424 table_status = ap_dump_table_buffer(table, 0, 0);
425 425
426exit: 426exit:
427 free(table); 427 ACPI_FREE(table);
428 return (table_status); 428 return (table_status);
429} 429}
diff --git a/tools/power/acpi/tools/acpidump/apfiles.c b/tools/power/acpi/tools/acpidump/apfiles.c
index 4488accc010b..1d12b9d3d44e 100644
--- a/tools/power/acpi/tools/acpidump/apfiles.c
+++ b/tools/power/acpi/tools/acpidump/apfiles.c
@@ -130,11 +130,12 @@ int ap_write_to_binary_file(struct acpi_table_header *table, u32 instance)
130 /* Handle multiple SSDts - create different filenames for each */ 130 /* Handle multiple SSDts - create different filenames for each */
131 131
132 if (instance > 0) { 132 if (instance > 0) {
133 sprintf(instance_str, "%u", instance); 133 acpi_ut_snprintf(instance_str, sizeof(instance_str), "%u",
134 strcat(filename, instance_str); 134 instance);
135 ACPI_STRCAT(filename, instance_str);
135 } 136 }
136 137
137 strcat(filename, ACPI_TABLE_FILE_SUFFIX); 138 ACPI_STRCAT(filename, ACPI_TABLE_FILE_SUFFIX);
138 139
139 if (gbl_verbose_mode) { 140 if (gbl_verbose_mode) {
140 fprintf(stderr, 141 fprintf(stderr,
@@ -202,7 +203,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
202 203
203 /* Allocate a buffer for the entire file */ 204 /* Allocate a buffer for the entire file */
204 205
205 buffer = calloc(1, file_size); 206 buffer = ACPI_ALLOCATE_ZEROED(file_size);
206 if (!buffer) { 207 if (!buffer) {
207 fprintf(stderr, 208 fprintf(stderr,
208 "Could not allocate file buffer of size: %u\n", 209 "Could not allocate file buffer of size: %u\n",
@@ -215,7 +216,7 @@ struct acpi_table_header *ap_get_table_from_file(char *pathname,
215 actual = fread(buffer, 1, file_size, file); 216 actual = fread(buffer, 1, file_size, file);
216 if (actual != file_size) { 217 if (actual != file_size) {
217 fprintf(stderr, "Could not read input file: %s\n", pathname); 218 fprintf(stderr, "Could not read input file: %s\n", pathname);
218 free(buffer); 219 ACPI_FREE(buffer);
219 buffer = NULL; 220 buffer = NULL;
220 goto cleanup; 221 goto cleanup;
221 } 222 }