platform/x86: acerhdf: Cleanup str_starts_with()
PATCH 1/1 platform/x86: acerhdf: Cleanup str_starts_with()
Since there is already a generic function strstarts() that check if a string starts with a given prefix, cleanup str_starts_with().
--- drivers/platform/x86/acerhdf.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)
drivers/platform/x86/acerhdf.c +3 -18
@@ -584,21 +584,6 @@ static struct platform_driver acerhdf_driver = { .remove = acerhdf_remove, }; -/* checks if str begins with start */ -static int str_starts_with (const char *str,const char *start) -{ -unsigned long str_len =0 , start_len =0 ; - - str_len =strlen (str); - start_len =strlen (start); - -if (str_len >= start_len && - !strncmp (str, start, start_len)) -return 1 ; - -return 0 ; -} -/* check hardware */ static int __init acerhdf_check_hardware (void ) {
@@ -651,9 +636,9 @@ static int __init acerhdf_check_hardware(void)* check if actual hardware BIOS vendor, product and version * IDs start with the strings of BIOS table entry */ -if (str_starts_with (vendor, bt->vendor) && -str_starts_with (product, bt->product) && -str_starts_with (version, bt->version)) { +if (strstarts (vendor, bt->vendor) && +strstarts (product, bt->product) && +strstarts (version, bt->version)) { found =1 ;break ; }
Signature · 1 line
2.25.1
Quoted 2 lines · Wei Li
Since there is already a generic function
strstarts()that check if a string starts with a given prefix, cleanupstr_starts_with().
[]
drivers/platform/x86/acerhdf.c static int __init acerhdf_check_hardware(void) · line 641
Quoted 11 lines
drivers/platform/x86/acerhdf.c +3
-3@@ -651,9 +636,9 @@ static int __init acerhdf_check_hardware(void)* check if actual hardware BIOS vendor, product and version * IDs start with the strings of BIOS table entry */ -if (str_starts_with (vendor, bt->vendor) && -str_starts_with (product, bt->product) && -str_starts_with (version, bt->version)) { +if (strstarts (vendor, bt->vendor) && +strstarts (product, bt->product) && +strstarts (version, bt->version)) {
IMO: It'd be easier for humans to read if aligned like:
if (strstarts(vendor, bt->vendor) &&
strstarts(product, bt->product) &&
strstarts(version, bt->version)) {Quoted 4 lines · Wei Li
Since there is already a generic function
strstarts()that check if a string starts with a given prefix, cleanupstr_starts_with().Signed-off-by Wei Li <[email protected]>
[...]
Hi,
Quoted 4 lines · Wei Li
Since there is already a generic function
strstarts()that check if a string starts with a given prefix, cleanupstr_starts_with().Signed-off-by Wei Li <[email protected]>
Thank you for your patch, I've applied this patch to my review-hans branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be added to the platform-drivers-x86/for-next branch and eventually will be included in the pdx86 pull-request to Linus for the next merge-window.
Regards,
Hans
Quoted 43 lines
--- drivers/platform/x86/acerhdf.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-)drivers/platform/x86/acerhdf.c +3
-18@@ -584,21 +584,6 @@ static struct platform_driver acerhdf_driver = { .remove = acerhdf_remove, }; -/* checks if str begins with start */ -static int str_starts_with (const char *str,const char *start) -{ -unsigned long str_len =0 , start_len =0 ; - - str_len =strlen (str); - start_len =strlen (start); - -if (str_len >= start_len && - !strncmp (str, start, start_len)) -return 1 ; - -return 0 ; -} -/* check hardware */ static int __init acerhdf_check_hardware (void ) {@@ -651,9 +636,9 @@ static int __init acerhdf_check_hardware(void)* check if actual hardware BIOS vendor, product and version * IDs start with the strings of BIOS table entry */ -if (str_starts_with (vendor, bt->vendor) && -str_starts_with (product, bt->product) && -str_starts_with (version, bt->version)) { +if (strstarts (vendor, bt->vendor) && +strstarts (product, bt->product) && +strstarts (version, bt->version)) { found =1 ;break ; }