ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}()
PATCH 1/1 ACPI: APEI: Remove redundant assignments in erst_dbg_{ioctl|write}()
Use the result of copy_from_user() directly instead of assigning it to the local variable 'rc' and then overwriting it in erst_dbg_write() or immediately returning from erst_dbg_ioctl().
--- drivers/acpi/apei/erst-dbg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/acpi/apei/erst-dbg.c +3 -5
@@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)switch (cmd) {case APEI_ERST_CLEAR_RECORD : - rc =copy_from_user (&record_id, (void __user *)arg, -sizeof (record_id)); -if (rc) +if (copy_from_user (&record_id, (void __user *)arg, +sizeof (record_id)))return -EFAULT ;return erst_clear (record_id);case APEI_ERST_GET_RECORD_COUNT :
@@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, erst_dbg_buf = p; erst_dbg_buf_len = usize; } - rc =copy_from_user (erst_dbg_buf, ubuf, usize); -if (rc) { +if (copy_from_user (erst_dbg_buf, ubuf, usize)) { rc = -EFAULT ; goto out; }
Signature · 1 line
2.51.0
Quoted 26 lines · Thorsten Blum
Use the result of
copy_from_user()directly instead of assigning it to the local variable 'rc' and then overwriting it inerst_dbg_write()or immediately returning fromerst_dbg_ioctl().Signed-off-by Thorsten Blum <[email protected]>--- drivers/acpi/apei/erst-dbg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/acpi/apei/erst-dbg.c +2
-3@@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)switch (cmd) {case APEI_ERST_CLEAR_RECORD : - rc =copy_from_user (&record_id, (void __user *)arg, -sizeof (record_id)); -if (rc) +if (copy_from_user (&record_id, (void __user *)arg, +sizeof (record_id)))return -EFAULT ;return erst_clear (record_id);case APEI_ERST_GET_RECORD_COUNT :
drivers/acpi/apei/erst-dbg.c static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, · line 180
Quoted 9 lines
drivers/acpi/apei/erst-dbg.c +1
-2@@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, erst_dbg_buf = p; erst_dbg_buf_len = usize; } - rc =copy_from_user (erst_dbg_buf, ubuf, usize); -if (rc) { +if (copy_from_user (erst_dbg_buf, ubuf, usize)) { rc = -EFAULT ; goto out; }
Hi Thorsten,
Thanks for the patch.
The changes look good to me.
Since this is a code cleanup with no functional changes, could you please mention "no functional change" or similar wording in the commit message to make it clear?
With that addressed:
Thanks,
Shuai
Rafael J. Wysocki
maintainerQuoted 43 lines · Shuai Xue
Quoted 26 lines · Thorsten Blum
Use the result of
copy_from_user()directly instead of assigning it to the local variable 'rc' and then overwriting it inerst_dbg_write()or immediately returning fromerst_dbg_ioctl().Signed-off-by Thorsten Blum <[email protected]>--- drivers/acpi/apei/erst-dbg.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)drivers/acpi/apei/erst-dbg.c +2
-3@@ -60,9 +60,8 @@ static long erst_dbg_ioctl(struct file *f, unsigned int cmd, unsigned long arg)switch (cmd) {case APEI_ERST_CLEAR_RECORD : - rc =copy_from_user (&record_id, (void __user *)arg, -sizeof (record_id)); -if (rc) +if (copy_from_user (&record_id, (void __user *)arg, +sizeof (record_id)))return -EFAULT ;return erst_clear (record_id);case APEI_ERST_GET_RECORD_COUNT :drivers/acpi/apei/erst-dbg.c static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, · line 180
Quoted 9 lines
drivers/acpi/apei/erst-dbg.c +1
-2@@ -175,8 +174,7 @@ static ssize_t erst_dbg_write(struct file *filp, const char __user *ubuf, erst_dbg_buf = p; erst_dbg_buf_len = usize; } - rc =copy_from_user (erst_dbg_buf, ubuf, usize); -if (rc) { +if (copy_from_user (erst_dbg_buf, ubuf, usize)) { rc = -EFAULT ; goto out; }Hi Thorsten,
Thanks for the patch.
Quoted 5 lines
The changes look good to me.
Since this is a code cleanup with no functional changes, could you please mention "no functional change" or similar wording in the commit message to make it clear?
Added.
Quoted 2 lines
With that addressed:
Reviewed-by Shuai Xue <[email protected]>
And patch applied as 6.18 material, thanks!