ACPI: fix test for hex digit.
PATCH 1/1 ACPI: fix test for hex digit.
decimal 0 is ascii for NULL. Hex digit matching should be from '0' (decimal 30 of ascii) to '9' and 'A' to 'F'.
Unfixed version returns true for #,$,%,& etc.
--- drivers/acpi/acpi_pnp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/acpi_pnp.c +1 -1
@@ -322,7 +322,7 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {static bool is_hex_digit (char c) { -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); +return (c >='0' && c <='9' ) || (c >='A' && c <='F' ); }static bool matching_id (char *idstr,char *list_id)
Signature · 1 line
1.8.1.msysgit.1
Quoted 3 lines · Arjun Sreedharan
decimal 0 is ascii for NULL. Hex digit matching should be from '0' (decimal 30 of ascii) to '9' and 'A' to 'F'.
Unfixed version returns true for #,$,%,& etc.
[]
drivers/acpi/acpi_pnp.c
Quoted 1 line
drivers/acpi/acpi_pnp.c +0
-0
[]
drivers/acpi/acpi_pnp.c static const struct acpi_device_id acpi_pnp_device_ids[] = { · line 326
Quoted 7 lines
drivers/acpi/acpi_pnp.c +1
-1@@ -322,7 +322,7 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = {static bool is_hex_digit (char c) { -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); +return (c >='0' && c <='9' ) || (c >='A' && c <='F' ); }
Maybe delete this and do s/is_hex_digit/isxdigit/ ?
PATCH 1/1 Replace faulty is_hex_digit() by isxdigit()
0 is ascii for NULL. Hex digit matching should be from '0'. Unfixed version returns true for #,$,%,& etc.
--- drivers/acpi/acpi_pnp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/acpi/acpi_pnp.c +1 -6
@@ -320,11 +320,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit (char c) -{ -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); -} -static bool matching_id (char *idstr,char *list_id) {int i;
@@ -335,7 +330,7 @@ static bool matching_id(char *idstr, char *list_id)for (i =3 ; i <7 ; i++) {char c =toupper (idstr[i]); -if (!is_hex_digit (c) +if (!isxdigit (c) || (list_id[i] !='X' && c !=toupper (list_id[i])))return false; }
Signature · 1 line
1.7.11.7
Re: [PATCH] Replace faulty is_hex_digit() by isxdigit()
drivers/acpi/acpi_pnp.c
Quoted 12 lines · Arjun Sreedharan
0 is ascii for NULL. Hex digit matching should be from '0'. Unfixed version returns true for #,$,%,& etc.
Signed-off-by Arjun Sreedharan <[email protected]>--- drivers/acpi/acpi_pnp.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)drivers/acpi/acpi_pnp.c +0
-0
#include <linux/ctype.h>
Thanks.
Quoted 22 lines
drivers/acpi/acpi_pnp.c +1
-6@@ -320,11 +320,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit (char c) -{ -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); -} -static bool matching_id (char *idstr,char *list_id) {int i;@@ -335,7 +330,7 @@ static bool matching_id(char *idstr, char *list_id)for (i =3 ; i <7 ; i++) {char c =toupper (idstr[i]); -if (!is_hex_digit (c) +if (!isxdigit (c) || (list_id[i] !='X' && c !=toupper (list_id[i])))return false; }
Signature · 1 line
~Randy
PATCH 1/1 Replace faulty is_hex_digit() by isxdigit()
0 is ascii for NULL. Hex digit matching should be from '0'. Faulty version returns true for #,$,%,& etc.
--- drivers/acpi/acpi_pnp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/acpi/acpi_pnp.c +2 -6
@@ -12,6 +12,7 @@#include <linux/acpi.h> #include <linux/module.h> +#include <linux/ctype.h> static const struct acpi_device_id acpi_pnp_device_ids[] = {/* soc_button_array */
@@ -320,11 +321,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit (char c) -{ -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); -} -static bool matching_id (char *idstr,char *list_id) {int i;
@@ -335,7 +331,7 @@ static bool matching_id(char *idstr, char *list_id)for (i =3 ; i <7 ; i++) {char c =toupper (idstr[i]); -if (!is_hex_digit (c) +if (!isxdigit (c) || (list_id[i] !='X' && c !=toupper (list_id[i])))return false; }
Signature · 1 line
1.7.11.7
Re: [PATCH] Replace faulty is_hex_digit() by isxdigit()
Quoted 4 lines · Arjun Sreedharan
0 is ascii for NULL. Hex digit matching should be from '0'. Faulty version returns true for #,$,%,& etc.
Signed-off-by Arjun Sreedharan <[email protected]>
Thanks.
Quoted 38 lines
--- drivers/acpi/acpi_pnp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/acpi/acpi_pnp.c +2
-6@@ -12,6 +12,7 @@#include <linux/acpi.h> #include <linux/module.h> +#include <linux/ctype.h> static const struct acpi_device_id acpi_pnp_device_ids[] = {/* soc_button_array */ @@ -320,11 +321,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit (char c) -{ -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); -} -static bool matching_id (char *idstr,char *list_id) {int i;@@ -335,7 +331,7 @@ static bool matching_id(char *idstr, char *list_id)for (i =3 ; i <7 ; i++) {char c =toupper (idstr[i]); -if (!is_hex_digit (c) +if (!isxdigit (c) || (list_id[i] !='X' && c !=toupper (list_id[i])))return false; }
Signature · 1 line
~Randy
Rafael J. Wysocki
AppliedRe: [PATCH] Replace faulty is_hex_digit() by isxdigit()
Quoted 7 lines · Randy Dunlap
Quoted 4 lines · Arjun Sreedharan
0 is ascii for NULL. Hex digit matching should be from '0'. Faulty version returns true for #,$,%,& etc.
Signed-off-by Arjun Sreedharan <[email protected]>Acked-by Randy Dunlap <[email protected]>
Applied, thanks!
Quoted 43 lines
Thanks.
Quoted 38 lines
--- drivers/acpi/acpi_pnp.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/acpi/acpi_pnp.c +2
-6@@ -12,6 +12,7 @@#include <linux/acpi.h> #include <linux/module.h> +#include <linux/ctype.h> static const struct acpi_device_id acpi_pnp_device_ids[] = {/* soc_button_array */ @@ -320,11 +321,6 @@ static const struct acpi_device_id acpi_pnp_device_ids[] = { {""}, }; -static bool is_hex_digit (char c) -{ -return (c >=0 && c <='9' ) || (c >='A' && c <='F' ); -} -static bool matching_id (char *idstr,char *list_id) {int i;@@ -335,7 +331,7 @@ static bool matching_id(char *idstr, char *list_id)for (i =3 ; i <7 ; i++) {char c =toupper (idstr[i]); -if (!is_hex_digit (c) +if (!isxdigit (c) || (list_id[i] !='X' && c !=toupper (list_id[i])))return false; }
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.