Skip to content

Commit

Permalink
ACPICA: De-macroize calls to standard C library functions
Browse files Browse the repository at this point in the history
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: acpica/acpica@3b1026e0
Link: acpica/acpica@00f0dc83
Link: acpica/acpica@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>
  • Loading branch information
acpibob authored and rafaeljw committed Jul 1, 2015
1 parent 63c4381 commit 4fa4616
Show file tree
Hide file tree
Showing 56 changed files with 260 additions and 312 deletions.
46 changes: 22 additions & 24 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand All @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/dsfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/dsinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions drivers/acpi/acpica/dsobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/dsutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/evgpeinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions drivers/acpi/acpica/exconvrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
52 changes: 26 additions & 26 deletions drivers/acpi/acpica/exfldio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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);
Expand Down Expand Up @@ -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 =
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
36 changes: 18 additions & 18 deletions drivers/acpi/acpica/exmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" */

Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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) */
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/exnames.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/exoparg2.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions drivers/acpi/acpica/exoparg3.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
Loading

0 comments on commit 4fa4616

Please sign in to comment.