ACPICA: De-macroize calls to standard C library functions

ACPICA commit 3b1026e0bdd3c32eb6d5d313f3ba0b1fee7597b4
ACPICA commit 00f0dc83f5cfca53b27a3213ae0d7719b88c2d6b
ACPICA commit 47d22a738d0e19fd241ffe4e3e9d4e198e4afc69

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.
Also cast various invocations as necessary. Bob Moore, Jung-uk Kim, Lv Zheng.

Link: https://github.com/acpica/acpica/commit/3b1026e0
Link: https://github.com/acpica/acpica/commit/00f0dc83
Link: https://github.com/acpica/acpica/commit/47d22a73
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Jung-uk Kim <jkim@FreeBSD.org>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
Bob Moore
2015-07-01 14:45:11 +08:00
committed by Rafael J. Wysocki
parent 63c43812ee
commit 4fa4616e27
56 changed files with 260 additions and 312 deletions

View File

@@ -210,37 +210,35 @@ void acpi_ut_subsystem_shutdown(void);
*/
#ifndef ACPI_USE_SYSTEM_CLIBRARY
acpi_size acpi_ut_strlen(const char *string);
acpi_size strlen(const char *string);
char *acpi_ut_strchr(const char *string, int ch);
char *strchr(const char *string, int ch);
char *acpi_ut_strcpy(char *dst_string, const char *src_string);
char *strcpy(char *dst_string, const char *src_string);
char *acpi_ut_strncpy(char *dst_string,
const char *src_string, acpi_size count);
char *strncpy(char *dst_string, const char *src_string, acpi_size count);
int acpi_ut_memcmp(const char *buffer1, const char *buffer2, acpi_size count);
int strncmp(const char *string1, const char *string2, acpi_size count);
int acpi_ut_strncmp(const char *string1, const char *string2, acpi_size count);
int strcmp(const char *string1, const char *string2);
int acpi_ut_strcmp(const char *string1, const char *string2);
char *strcat(char *dst_string, const char *src_string);
char *acpi_ut_strcat(char *dst_string, const char *src_string);
char *strncat(char *dst_string, const char *src_string, acpi_size count);
char *acpi_ut_strncat(char *dst_string,
const char *src_string, acpi_size count);
u32 strtoul(const char *string, char **terminator, u32 base);
u32 acpi_ut_strtoul(const char *string, char **terminator, u32 base);
char *strstr(char *string1, char *string2);
char *acpi_ut_strstr(char *string1, char *string2);
int memcmp(void *buffer1, void *buffer2, acpi_size count);
void *acpi_ut_memcpy(void *dest, const void *src, acpi_size count);
void *memcpy(void *dest, const void *src, acpi_size count);
void *acpi_ut_memset(void *dest, u8 value, acpi_size count);
void *memset(void *dest, int value, acpi_size count);
int acpi_ut_to_upper(int c);
int toupper(int c);
int acpi_ut_to_lower(int c);
int tolower(int c);
extern const u8 _acpi_ctype[];
@@ -255,13 +253,13 @@ extern const u8 _acpi_ctype[];
#define _ACPI_UP 0x01 /* 'A'-'Z' */
#define _ACPI_XD 0x80 /* '0'-'9', 'A'-'F', 'a'-'f' */
#define ACPI_IS_DIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
#define ACPI_IS_SPACE(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
#define ACPI_IS_XDIGIT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
#define ACPI_IS_UPPER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
#define ACPI_IS_LOWER(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
#define ACPI_IS_PRINT(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
#define ACPI_IS_ALPHA(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
#define isdigit(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_DI))
#define isspace(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_SP))
#define isxdigit(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_XD))
#define isupper(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_UP))
#define islower(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO))
#define isprint(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP | _ACPI_DI | _ACPI_XS | _ACPI_PU))
#define isalpha(c) (_acpi_ctype[(unsigned char)(c)] & (_ACPI_LO | _ACPI_UP))
#endif /* !ACPI_USE_SYSTEM_CLIBRARY */

View File

@@ -502,7 +502,7 @@ acpi_ds_create_field(union acpi_parse_object *op,
}
}
ACPI_MEMSET(&info, 0, sizeof(struct acpi_create_field_info));
memset(&info, 0, sizeof(struct acpi_create_field_info));
/* Second arg is the field flags */

View File

@@ -207,7 +207,7 @@ acpi_ds_initialize_objects(u32 table_index,
/* Set all init info to zero */
ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info));
memset(&info, 0, sizeof(struct acpi_init_walk_info));
info.owner_id = owner_id;
info.table_index = table_index;

View File

@@ -339,8 +339,8 @@ acpi_ds_build_internal_buffer_obj(struct acpi_walk_state *walk_state,
/* Initialize buffer from the byte_list (if present) */
if (byte_list) {
ACPI_MEMCPY(obj_desc->buffer.pointer,
byte_list->named.data, byte_list_length);
memcpy(obj_desc->buffer.pointer, byte_list->named.data,
byte_list_length);
}
}
@@ -750,8 +750,7 @@ acpi_ds_init_object_from_op(struct acpi_walk_state *walk_state,
case ACPI_TYPE_STRING:
obj_desc->string.pointer = op->common.value.string;
obj_desc->string.length =
(u32)ACPI_STRLEN(op->common.value.string);
obj_desc->string.length = (u32)strlen(op->common.value.string);
/*
* The string is contained in the ACPI table, don't ever try

View File

@@ -572,8 +572,8 @@ acpi_ds_create_operand(struct acpi_walk_state *walk_state,
obj_desc =
acpi_ut_create_string_object((acpi_size) name_length);
ACPI_STRNCPY(obj_desc->string.pointer,
name_string, name_length);
strncpy(obj_desc->string.pointer,
name_string, name_length);
status = AE_OK;
} else {
/*

View File

@@ -377,7 +377,7 @@ acpi_ev_match_gpe_method(acpi_handle obj_handle,
/* 4) The last two characters of the name are the hex GPE Number */
gpe_number = ACPI_STRTOUL(&name[2], NULL, 16);
gpe_number = strtoul(&name[2], NULL, 16);
if (gpe_number == ACPI_UINT32_MAX) {
/* Conversion failed; invalid method, just ignore it */

View File

@@ -470,7 +470,7 @@ acpi_ex_load_op(union acpi_operand_object *obj_desc,
return_ACPI_STATUS(AE_NO_MEMORY);
}
ACPI_MEMCPY(table, table_header, length);
memcpy(table, table_header, length);
break;
default:

View File

@@ -227,9 +227,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
/* Copy the integer to the buffer, LSB first */
new_buf = return_desc->buffer.pointer;
ACPI_MEMCPY(new_buf,
&obj_desc->integer.value,
acpi_gbl_integer_byte_width);
memcpy(new_buf,
&obj_desc->integer.value, acpi_gbl_integer_byte_width);
break;
case ACPI_TYPE_STRING:
@@ -252,8 +251,8 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,
/* Copy the string to the buffer */
new_buf = return_desc->buffer.pointer;
ACPI_STRNCPY((char *)new_buf, (char *)obj_desc->string.pointer,
obj_desc->string.length);
strncpy((char *)new_buf, (char *)obj_desc->string.pointer,
obj_desc->string.length);
break;
default:

View File

@@ -428,7 +428,7 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc,
}
buffer = buffer_desc->buffer.pointer;
ACPI_MEMCPY(buffer, source_desc->buffer.pointer, length);
memcpy(buffer, source_desc->buffer.pointer, length);
/* Lock entire transaction if requested */

View File

@@ -416,22 +416,22 @@ acpi_ex_field_datum_io(union acpi_operand_object *obj_desc,
* Copy the data from the source buffer.
* Length is the field width in bytes.
*/
ACPI_MEMCPY(value,
(obj_desc->buffer_field.buffer_obj)->buffer.
pointer +
obj_desc->buffer_field.base_byte_offset +
field_datum_byte_offset,
obj_desc->common_field.access_byte_width);
memcpy(value,
(obj_desc->buffer_field.buffer_obj)->buffer.
pointer +
obj_desc->buffer_field.base_byte_offset +
field_datum_byte_offset,
obj_desc->common_field.access_byte_width);
} else {
/*
* Copy the data to the target buffer.
* Length is the field width in bytes.
*/
ACPI_MEMCPY((obj_desc->buffer_field.buffer_obj)->buffer.
pointer +
obj_desc->buffer_field.base_byte_offset +
field_datum_byte_offset, value,
obj_desc->common_field.access_byte_width);
memcpy((obj_desc->buffer_field.buffer_obj)->buffer.
pointer +
obj_desc->buffer_field.base_byte_offset +
field_datum_byte_offset, value,
obj_desc->common_field.access_byte_width);
}
status = AE_OK;
@@ -703,7 +703,7 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
return_ACPI_STATUS(AE_BUFFER_OVERFLOW);
}
ACPI_MEMSET(buffer, 0, buffer_length);
memset(buffer, 0, buffer_length);
access_bit_width = ACPI_MUL_8(obj_desc->common_field.access_byte_width);
/* Handle the simple case here */
@@ -720,7 +720,7 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
status =
acpi_ex_field_datum_io(obj_desc, 0, &raw_datum,
ACPI_READ);
ACPI_MEMCPY(buffer, &raw_datum, buffer_length);
memcpy(buffer, &raw_datum, buffer_length);
}
return_ACPI_STATUS(status);
@@ -793,9 +793,9 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
/* Write merged datum to target buffer */
ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
memcpy(((char *)buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
buffer_offset += obj_desc->common_field.access_byte_width;
merged_datum =
@@ -811,9 +811,9 @@ acpi_ex_extract_from_field(union acpi_operand_object *obj_desc,
/* Write the last datum to the buffer */
ACPI_MEMCPY(((char *)buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
memcpy(((char *)buffer) + buffer_offset, &merged_datum,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
return_ACPI_STATUS(AE_OK);
}
@@ -878,7 +878,7 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
* at Byte zero. All unused (upper) bytes of the
* buffer will be 0.
*/
ACPI_MEMCPY((char *)new_buffer, (char *)buffer, buffer_length);
memcpy((char *)new_buffer, (char *)buffer, buffer_length);
buffer = new_buffer;
buffer_length = required_length;
}
@@ -918,9 +918,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
/* Get initial Datum from the input buffer */
ACPI_MEMCPY(&raw_datum, buffer,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
memcpy(&raw_datum, buffer,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum =
raw_datum << obj_desc->common_field.start_field_bit_offset;
@@ -970,9 +970,9 @@ acpi_ex_insert_into_field(union acpi_operand_object *obj_desc,
/* Get the next input datum from the buffer */
buffer_offset += obj_desc->common_field.access_byte_width;
ACPI_MEMCPY(&raw_datum, ((char *)buffer) + buffer_offset,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
memcpy(&raw_datum, ((char *)buffer) + buffer_offset,
ACPI_MIN(obj_desc->common_field.access_byte_width,
buffer_length - buffer_offset));
merged_datum |=
raw_datum << obj_desc->common_field.start_field_bit_offset;

View File

@@ -209,8 +209,8 @@ acpi_ex_concat_template(union acpi_operand_object *operand0,
* end_tag descriptor is copied from Operand1.
*/
new_buf = return_desc->buffer.pointer;
ACPI_MEMCPY(new_buf, operand0->buffer.pointer, length0);
ACPI_MEMCPY(new_buf + length0, operand1->buffer.pointer, length1);
memcpy(new_buf, operand0->buffer.pointer, length0);
memcpy(new_buf + length0, operand1->buffer.pointer, length1);
/* Insert end_tag and set the checksum to zero, means "ignore checksum" */
@@ -318,14 +318,14 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
/* Copy the first integer, LSB first */
ACPI_MEMCPY(new_buf, &operand0->integer.value,
acpi_gbl_integer_byte_width);
memcpy(new_buf, &operand0->integer.value,
acpi_gbl_integer_byte_width);
/* Copy the second integer (LSB first) after the first */
ACPI_MEMCPY(new_buf + acpi_gbl_integer_byte_width,
&local_operand1->integer.value,
acpi_gbl_integer_byte_width);
memcpy(new_buf + acpi_gbl_integer_byte_width,
&local_operand1->integer.value,
acpi_gbl_integer_byte_width);
break;
case ACPI_TYPE_STRING:
@@ -346,9 +346,9 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
/* Concatenate the strings */
ACPI_STRCPY(new_buf, operand0->string.pointer);
ACPI_STRCPY(new_buf + operand0->string.length,
local_operand1->string.pointer);
strcpy(new_buf, operand0->string.pointer);
strcpy(new_buf + operand0->string.length,
local_operand1->string.pointer);
break;
case ACPI_TYPE_BUFFER:
@@ -369,11 +369,11 @@ acpi_ex_do_concatenate(union acpi_operand_object *operand0,
/* Concatenate the buffers */
ACPI_MEMCPY(new_buf, operand0->buffer.pointer,
operand0->buffer.length);
ACPI_MEMCPY(new_buf + operand0->buffer.length,
local_operand1->buffer.pointer,
local_operand1->buffer.length);
memcpy(new_buf, operand0->buffer.pointer,
operand0->buffer.length);
memcpy(new_buf + operand0->buffer.length,
local_operand1->buffer.pointer,
local_operand1->buffer.length);
break;
default:
@@ -660,9 +660,9 @@ acpi_ex_do_logical_op(u16 opcode,
/* Lexicographic compare: compare the data bytes */
compare = ACPI_MEMCMP(operand0->buffer.pointer,
local_operand1->buffer.pointer,
(length0 > length1) ? length1 : length0);
compare = memcmp(operand0->buffer.pointer,
local_operand1->buffer.pointer,
(length0 > length1) ? length1 : length0);
switch (opcode) {
case AML_LEQUAL_OP: /* LEqual (Operand0, Operand1) */

View File

@@ -192,7 +192,7 @@ static acpi_status acpi_ex_name_segment(u8 ** in_aml_address, char *name_string)
char_buf[4] = '\0';
if (name_string) {
ACPI_STRCAT(name_string, char_buf);
strcat(name_string, char_buf);
ACPI_DEBUG_PRINT((ACPI_DB_NAMES,
"Appended to - %s\n", name_string));
} else {

View File

@@ -337,8 +337,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
* Copy the raw buffer data with no transform.
* (NULL terminated already)
*/
ACPI_MEMCPY(return_desc->string.pointer,
operand[0]->buffer.pointer, length);
memcpy(return_desc->string.pointer,
operand[0]->buffer.pointer, length);
break;
case AML_CONCAT_RES_OP:

View File

@@ -237,8 +237,8 @@ acpi_status acpi_ex_opcode_3A_1T_1R(struct acpi_walk_state *walk_state)
/* We have a buffer, copy the portion requested */
ACPI_MEMCPY(buffer, operand[0]->string.pointer + index,
length);
memcpy(buffer, operand[0]->string.pointer + index,
length);
}
/* Set the length of the new String/Buffer */

View File

@@ -517,15 +517,14 @@ acpi_ex_data_table_space_handler(u32 function,
switch (function) {
case ACPI_READ:
ACPI_MEMCPY(ACPI_CAST_PTR(char, value),
ACPI_PHYSADDR_TO_PTR(address),
ACPI_DIV_8(bit_width));
memcpy(ACPI_CAST_PTR(char, value),
ACPI_PHYSADDR_TO_PTR(address), ACPI_DIV_8(bit_width));
break;
case ACPI_WRITE:
ACPI_MEMCPY(ACPI_PHYSADDR_TO_PTR(address),
ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
memcpy(ACPI_PHYSADDR_TO_PTR(address),
ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
break;
default:

View File

@@ -100,9 +100,9 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
/* Clear existing buffer and copy in the new one */
ACPI_MEMSET(target_desc->buffer.pointer, 0,
target_desc->buffer.length);
ACPI_MEMCPY(target_desc->buffer.pointer, buffer, length);
memset(target_desc->buffer.pointer, 0,
target_desc->buffer.length);
memcpy(target_desc->buffer.pointer, buffer, length);
#ifdef ACPI_OBSOLETE_BEHAVIOR
/*
@@ -129,8 +129,8 @@ acpi_ex_store_buffer_to_buffer(union acpi_operand_object *source_desc,
} else {
/* Truncate the source, copy only what will fit */
ACPI_MEMCPY(target_desc->buffer.pointer, buffer,
target_desc->buffer.length);
memcpy(target_desc->buffer.pointer, buffer,
target_desc->buffer.length);
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Truncating source buffer from %X to %X\n",
@@ -187,9 +187,9 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
* String will fit in existing non-static buffer.
* Clear old string and copy in the new one
*/
ACPI_MEMSET(target_desc->string.pointer, 0,
(acpi_size) target_desc->string.length + 1);
ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
memset(target_desc->string.pointer, 0,
(acpi_size) target_desc->string.length + 1);
memcpy(target_desc->string.pointer, buffer, length);
} else {
/*
* Free the current buffer, then allocate a new buffer
@@ -210,7 +210,7 @@ acpi_ex_store_string_to_string(union acpi_operand_object *source_desc,
}
target_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
ACPI_MEMCPY(target_desc->string.pointer, buffer, length);
memcpy(target_desc->string.pointer, buffer, length);
}
/* Set the new target length */

View File

@@ -102,7 +102,7 @@ acpi_status acpi_ns_root_initialize(void)
/* _OSI is optional for now, will be permanent later */
if (!ACPI_STRCMP(init_val->name, "_OSI")
if (!strcmp(init_val->name, "_OSI")
&& !acpi_gbl_create_osi_method) {
continue;
}
@@ -180,7 +180,7 @@ acpi_status acpi_ns_root_initialize(void)
/* Build an object around the static string */
obj_desc->string.length = (u32)ACPI_STRLEN(val);
obj_desc->string.length = (u32)strlen(val);
obj_desc->string.pointer = val;
obj_desc->common.flags |= AOPOBJ_STATIC_POINTER;
break;
@@ -203,7 +203,7 @@ acpi_status acpi_ns_root_initialize(void)
/* Special case for ACPI Global Lock */
if (ACPI_STRCMP(init_val->name, "_GL_") == 0) {
if (strcmp(init_val->name, "_GL_") == 0) {
acpi_gbl_global_lock_mutex = obj_desc;
/* Create additional counting semaphore for global lock */

View File

@@ -187,8 +187,8 @@ acpi_ns_convert_to_string(union acpi_operand_object *original_object,
* Copy the raw buffer data with no transform. String is already NULL
* terminated at Length+1.
*/
ACPI_MEMCPY(new_object->string.pointer,
original_object->buffer.pointer, length);
memcpy(new_object->string.pointer,
original_object->buffer.pointer, length);
break;
default:
@@ -251,9 +251,9 @@ acpi_ns_convert_to_buffer(union acpi_operand_object *original_object,
return (AE_NO_MEMORY);
}
ACPI_MEMCPY(new_object->buffer.pointer,
original_object->string.pointer,
original_object->string.length);
memcpy(new_object->buffer.pointer,
original_object->string.pointer,
original_object->string.length);
break;
case ACPI_TYPE_PACKAGE:

View File

@@ -101,7 +101,7 @@ void acpi_ns_print_pathname(u32 num_segments, char *pathname)
while (num_segments) {
for (i = 0; i < 4; i++) {
ACPI_IS_PRINT(pathname[i]) ?
isprint((int)pathname[i]) ?
acpi_os_printf("%c", pathname[i]) :
acpi_os_printf("?");
}

View File

@@ -440,7 +440,7 @@ acpi_ns_exec_module_code(union acpi_operand_object *method_obj,
/* Initialize the evaluation information block */
ACPI_MEMSET(info, 0, sizeof(struct acpi_evaluate_info));
memset(info, 0, sizeof(struct acpi_evaluate_info));
info->prefix_node = parent_node;
/*

Some files were not shown because too many files have changed in this diff Show More