Skip to content

Commit

Permalink
ACPICA: Utilities: split hex detection into smaller functions
Browse files Browse the repository at this point in the history
acpi_ut_implicit_strtoul64() called acpi_ut_detect_hex_prefix() and
ignored the return value. Instead, use acpi_ut_remove_hex_prefix().

Signed-off-by: Erik Schmauss <erik.schmauss@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Erik Schmauss authored and Rafael J. Wysocki committed Aug 14, 2018
1 parent 8a55c69 commit 089b2be
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 2 additions & 0 deletions drivers/acpi/acpica/acutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ char acpi_ut_remove_leading_zeros(char **string);

u8 acpi_ut_detect_hex_prefix(char **string);

void acpi_ut_remove_hex_prefix(char **string);

u8 acpi_ut_detect_octal_prefix(char **string);

/*
Expand Down
26 changes: 23 additions & 3 deletions drivers/acpi/acpica/utstrsuppt.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,14 +231,34 @@ char acpi_ut_remove_whitespace(char **string)

u8 acpi_ut_detect_hex_prefix(char **string)
{
char *initial_position = *string;

acpi_ut_remove_hex_prefix(string);
if (*string != initial_position) {
return (TRUE); /* String is past leading 0x */
}

return (FALSE); /* Not a hex string */
}

/*******************************************************************************
*
* FUNCTION: acpi_ut_remove_hex_prefix
*
* PARAMETERS: string - Pointer to input ASCII string
*
* RETURN: none
*
* DESCRIPTION: Remove a hex "0x" prefix
*
******************************************************************************/

void acpi_ut_remove_hex_prefix(char **string)
{
if ((**string == ACPI_ASCII_ZERO) &&
(tolower((int)*(*string + 1)) == 'x')) {
*string += 2; /* Go past the leading 0x */
return (TRUE);
}

return (FALSE); /* Not a hex string */
}

/*******************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/utstrtoul64.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ u64 acpi_ut_implicit_strtoul64(char *string)
* implicit conversions, and the "0x" prefix is "not allowed".
* However, allow a "0x" prefix as an ACPI extension.
*/
acpi_ut_detect_hex_prefix(&string);
acpi_ut_remove_hex_prefix(&string);

if (!acpi_ut_remove_leading_zeros(&string)) {
return_VALUE(0);
Expand Down

0 comments on commit 089b2be

Please sign in to comment.