[PATCH v2 5/6] panic: sys_info: Deduplicate local variable 'table; assignments

Andy Shevchenko posted 6 patches 5 months, 1 week ago
There is a newer version of this series
[PATCH v2 5/6] panic: sys_info: Deduplicate local variable 'table; assignments
Posted by Andy Shevchenko 5 months, 1 week ago
The both handlers use the local 'table' variable and assign
the same data to it, deduplicate that.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 lib/sys_info.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/lib/sys_info.c b/lib/sys_info.c
index 027b2c432d07..c86f52644857 100644
--- a/lib/sys_info.c
+++ b/lib/sys_info.c
@@ -63,12 +63,13 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
 	if (!names)
 		return -ENOMEM;
 
+	table = *ro_table;
+	table.data = names;
+	table.maxlen = maxlen;
+
 	if (write) {
 		int ret;
 
-		table = *ro_table;
-		table.data = names;
-		table.maxlen = maxlen;
 		ret = proc_dostring(&table, write, buffer, lenp, ppos);
 		if (ret)
 			return ret;
@@ -91,9 +92,6 @@ int sysctl_sys_info_handler(const struct ctl_table *ro_table, int write,
 			delim = ",";
 		}
 
-		table = *ro_table;
-		table.data = names;
-		table.maxlen = maxlen;
 		return proc_dostring(&table, write, buffer, lenp, ppos);
 	}
 }
-- 
2.50.1
Re: [PATCH v2 5/6] panic: sys_info: Deduplicate local variable 'table; assignments
Posted by Feng Tang 5 months, 1 week ago
On Wed, Oct 29, 2025 at 12:07:40PM +0100, Andy Shevchenko wrote:
> The both handlers use the local 'table' variable and assign
> the same data to it, deduplicate that.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Reviewed-by: Feng Tang <feng.tang@linux.alibaba.com>

Thanks!