Staging: gasket: Use temporaries to reduce line length.
PATCH 1/1 Staging: gasket: Use temporaries to reduce line length.
Using temporaries for gasket_page_table entries to remove scnprintf() statements and reduce line length, as suggested by Joe Perches. Thanks!
--- drivers/staging/gasket/apex_driver.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/staging/gasket/apex_driver.c +9 -11
@@ -509,6 +509,8 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr,struct gasket_dev *gasket_dev;struct gasket_sysfs_attribute *gasket_attr;enum sysfs_attribute_type type; +struct gasket_page_table *gpt; +uint val; gasket_dev =gasket_sysfs_get_device_data (device);if (!gasket_dev) {
@@ -524,29 +526,25 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, } type = (enum sysfs_attribute_type )gasket_attr->data.attr_type; + gpt = gasket_dev->page_table[0 ];switch (type) {case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_entries ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_simple_entries (gpt);break ;case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_simple_entries ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_simple_entries (gpt);break ;case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_active_pages ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_active_pages (gpt);break ;default :dev_dbg (gasket_dev->dev,"Unknown attribute: %s\n" , attr->attr.name); ret =0 ; -break ; + goto exit; } - + ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , val); +exit:gasket_sysfs_put_attr (device, gasket_attr);gasket_sysfs_put_device_data (device, gasket_dev);return ret;
Signature · 1 line
2.23.0
Quoted 2 lines · Sandro Volery
Using temporaries for
gasket_page_tableentries to removescnprintf()statements and reduce line length, as suggested by Joe Perches. Thanks!
nak. Slow down. You broke the code.
Please be _way_ more careful and verify for yourself the code you submit _before_ you submit it.
compile/test/verify, twice if necessary.
You also should have cc'd me on this patch.
drivers/staging/gasket/apex_driver.c
Quoted 1 line
drivers/staging/gasket/apex_driver.c +0
-0
[]
drivers/staging/gasket/apex_driver.c static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, · line 532
Quoted 11 lines
drivers/staging/gasket/apex_driver.c +2
-3@@ -524,29 +526,25 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, } type = (enum sysfs_attribute_type )gasket_attr->data.attr_type; + gpt = gasket_dev->page_table[0 ];switch (type) {case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_entries ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_simple_entries (gpt);
You likely duplicated this line via copy/paste.
This should be:
val = gasket_page_table_num_entries(gpt);
drivers/staging/gasket/apex_driver.c static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, · line 535
Quoted 6 lines
drivers/staging/gasket/apex_driver.c +1
-3break ;case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_simple_entries ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_simple_entries (gpt);
break;
Quoted 19 lines
drivers/staging/gasket/apex_driver.c +4
-5case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_active_pages ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_active_pages (gpt);break ;default :dev_dbg (gasket_dev->dev,"Unknown attribute: %s\n" , attr->attr.name); ret =0 ; -break ; + goto exit; } - + ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , val); +exit:gasket_sysfs_put_attr (device, gasket_attr);gasket_sysfs_put_device_data (device, gasket_dev);return ret;
Quoted 8 lines · Joe Perches
Quoted 2 lines · Sandro Volery
Using temporaries for
gasket_page_tableentries to removescnprintf()statements and reduce line length, as suggested by Joe Perches. Thanks!
Quoted 7 lines
nak. Slow down. You broke the code.
Please be _way_ more careful and verify for yourself the code you submit _before_ you submit it.
compile/test/verify, twice if necessary.
Shoot. I'm sorry I'm just really trying to get into all this...
Quoted 2 lines
You also should have cc'd me on this patch.
Will do! I'll submit v2 this afternoon.
Quoted 16 lines
drivers/staging/gasket/apex_driver.c
Quoted 1 line
drivers/staging/gasket/apex_driver.c +0
-0[]
drivers/staging/gasket/apex_driver.c static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, · line 532
Quoted 11 lines
drivers/staging/gasket/apex_driver.c +2
-3@@ -524,29 +526,25 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr, } type = (enum sysfs_attribute_type )gasket_attr->data.attr_type; + gpt = gasket_dev->page_table[0 ];switch (type) {case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE : - ret =scnprintf (buf,PAGE_SIZE ,"%u\n" , -gasket_page_table_num_entries ( - gasket_dev->page_table[0 ])); + val =gasket_page_table_num_simple_entries (gpt);You likely duplicated this line via copy/paste.
This should be:
Quoted 2 lines
val = gasket_page_table_num_entries(gpt);
Thanks for being patient with me so far... I'd imagine others would've freaked out at me by now :)