platform/x86: thinkpad_acpi: Remove unreachable code in beep_read()
Subsystems (3)
PATCH 1/1 platform/x86: thinkpad_acpi: Remove unreachable code in beep_read()
The procfs entry /proc/acpi/ibm/beep is only created if beep_init() succeeds, which requires beep_handle to be non-NULL. Remove the unreachable code branch from beep_read().
--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/platform/x86/lenovo/thinkpad_acpi.c +2 -6
@@ -5936,12 +5936,8 @@ static int __init beep_init(struct ibm_init_struct *iibm)static int beep_read (struct seq_file *m) { -if (!beep_handle) -seq_puts (m,"status:\t\tnot supported\n" ); -else { -seq_puts (m,"status:\t\tsupported\n" ); -seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" ); - } +seq_puts (m,"status:\t\tsupported\n" ); +seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" );return 0 ; }
Mark Pearson
maintainerHi Thorsten,
Quoted 29 lines · Thorsten Blum
The procfs entry
/proc/acpi/ibm/beepis only created ifbeep_init()succeeds, which requiresbeep_handleto be non-NULL. Remove the unreachable code branch frombeep_read().Signed-off-by Thorsten Blum <[email protected]>--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo/thinkpad_acpi.c +2
-6@@ -5936,12 +5936,8 @@ static int __init beep_init(struct ibm_init_struct *iibm)static int beep_read (struct seq_file *m) { -if (!beep_handle) -seq_puts (m,"status:\t\tnot supported\n" ); -else { -seq_puts (m,"status:\t\tsupported\n" ); -seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" ); - } +seq_puts (m,"status:\t\tsupported\n" ); +seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" );return 0 ;
Quoted 1 line
}
Change looks good to me.
I guess the beep_write could be similarly updated?
Mark
Quoted 31 lines · Mark Pearson
Hi Thorsten,
Quoted 28 lines · Thorsten Blum
The procfs entry
/proc/acpi/ibm/beepis only created ifbeep_init()succeeds, which requiresbeep_handleto be non-NULL. Remove the unreachable code branch frombeep_read().Signed-off-by Thorsten Blum <[email protected]>--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo/thinkpad_acpi.c +2
-6@@ -5936,12 +5936,8 @@ static int __init beep_init(struct ibm_init_struct *iibm)static int beep_read (struct seq_file *m) { -if (!beep_handle) -seq_puts (m,"status:\t\tnot supported\n" ); -else { -seq_puts (m,"status:\t\tsupported\n" ); -seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" ); - } +seq_puts (m,"status:\t\tsupported\n" ); +seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" );
Quoted 5 lines
Quoted 2 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0return 0 ;}
Change looks good to me.
I guess thebeep_writecould be similarly updated?
No, beep_write() can be called via the beep= module parameter even if beep_init() failed, so that check is still needed.
Thanks,
Thorsten
Quoted 32 lines · Thorsten Blum
Quoted 31 lines · Mark Pearson
Hi Thorsten,
Quoted 28 lines · Thorsten Blum
The procfs entry
/proc/acpi/ibm/beepis only created ifbeep_init()succeeds, which requiresbeep_handleto be non-NULL. Remove the unreachable code branch frombeep_read().Signed-off-by Thorsten Blum <[email protected]>--- drivers/platform/x86/lenovo/thinkpad_acpi.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)drivers/platform/x86/lenovo/thinkpad_acpi.c +2
-6@@ -5936,12 +5936,8 @@ static int __init beep_init(struct ibm_init_struct *iibm)static int beep_read (struct seq_file *m) { -if (!beep_handle) -seq_puts (m,"status:\t\tnot supported\n" ); -else { -seq_puts (m,"status:\t\tsupported\n" ); -seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" ); - } +seq_puts (m,"status:\t\tsupported\n" ); +seq_puts (m,"commands:\t<cmd> (<cmd> is 0-17)\n" );
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
drivers/platform/x86/lenovo/thinkpad_acpi.c +0
-0return 0 ;}
Change looks good to me.
I guess thebeep_writecould be similarly updated?No,
beep_write()can be called via the beep= module parameter even ifbeep_init()failed, so that check is still needed.
Oh - good point, I had missed that.
With that noted:
Thanks
Mark
Ilpo Järvinen
maintainerQuoted 3 lines · Thorsten Blum
The procfs entry
/proc/acpi/ibm/beepis only created ifbeep_init()succeeds, which requiresbeep_handleto be non-NULL. Remove the unreachable code branch frombeep_read().
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
FYI [if applicable to your patch], as per Linus' policy change, also fixes are mostly routed through for-next unless the fix is for a commit introduced in the most recent cycle or is clearly a regression fix.
The list of commits applied:
[1/1] platform/x86: thinkpad_acpi: Remove unreachable code in beep_read()
commit: c48091a8ac16b0fd1e7ffed29f11c4e6ea1acbb4
--
i.