Skip to contentSkip to conversation

Fixed parentheses malpractice in apex_driver.c

PATCH In review volery 3 participants 5 messages Sep 6, 2019 – Sep 7, 2019 Staging

lore
Share & tools
lore

volery

author
#0 lore raw

PATCH 1/1 Fixed parentheses malpractice in apex_driver.c

There were some parentheses at the end of lines, which I took care of. This is my first patch.

---
 drivers/staging/gasket/apex_driver.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/staging/gasket/apex_driver.c +6 -3
index 464648ee2036..78ebd590f877 100644
@@ -527,17 +527,20 @@ static ssize_t sysfs_show(struct device *device, struct device_attribute *attr,
 	switch (type) {
 	case ATTR_KERNEL_HIB_PAGE_TABLE_SIZE:
 		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
-				gasket_page_table_num_entries(
+				gasket_page_table_num_entries
+				(
 					gasket_dev->page_table[0]));
 		break;
 	case ATTR_KERNEL_HIB_SIMPLE_PAGE_TABLE_SIZE:
 		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
-				gasket_page_table_num_simple_entries(
+				gasket_page_table_num_simple_entries
+				(
 					gasket_dev->page_table[0]));
 		break;
 	case ATTR_KERNEL_HIB_NUM_ACTIVE_PAGES:
 		ret = scnprintf(buf, PAGE_SIZE, "%u\n",
-				gasket_page_table_num_active_pages(
+				gasket_page_table_num_active_pages
+				(
 					gasket_dev->page_table[0]));
 		break;
 	default:
Signature · 1 line
2.23.0
#1 lore raw
Quoted 1 line · volery

There were some parentheses at the end of lines, which I took care of.

Not every instance of this checkpatch warning should be changed.

This specific instance is because it uses very long identifiers and really maybe should just be left alone.

Quoted 1 line

This is my first patch.

Welcome, try again though.

If you really want to do something here maybe do something like use temporaries to reduce line length and remove multiple scnprintf statements. This would also reduce object size.

---
 drivers/staging/gasket/apex_driver.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/gasket/apex_driver.c +10 -10
index 2973bb920a26..ae1a3a14dde6 100644
@@ -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,27 @@ 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_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;
#2 lore raw
In reply to volery

You need a subject prefix. It should be something like:

[PATCH] Staging: gasket: Fix parentheses malpractice in apex_driver.c

Generally "Fix" is considered better style than "Fixed". We aren't going to care about that in staging, but the patch prefix is mandatory so you will need to redo it anyway and might as well fix that as well.

Quoted 2 lines · volery

There were some parentheses at the end of lines, which I took care of. This is my first patch.

^^^^^^^^^^^^^^^^^^^^^^

Put this sort of comments after the --- cut off line

Quoted 3 lines

---

^^^
Put it here. It will be removed when we apply the patch so it won't be recorded in the git log.

Quoted 2 lines
 drivers/staging/gasket/apex_driver.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Joe's comments are, of course, correct as well.

regards,
dan carpenter

#3 lore raw
Quoted 8 lines · Dan Carpenter

You need a subject prefix. It should be something like:

[PATCH] Staging: gasket: Fix parentheses malpractice in apex_driver.c

Thanks for the reply! I'll try to do that better for my next patch.

Quoted 11 lines

Generally "Fix" is considered better style than "Fixed". We aren't going to care about that in staging, but the patch prefix is mandatory so you will need to redo it anyway and might as well fix that as well.

Quoted 3 lines · volery

There were some parentheses at the end of lines, which I took care of. This is my first patch.

^^^^^^^^^^^^^^^^^^^^^^
Put this sort of comments after the --- cut off line

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

---

^^^
Put it here. It will be removed when we apply the patch so it won't be recorded in the git log.

Alright :)

Quoted 8 lines
Quoted 2 lines

drivers/staging/gasket/apex_driver.c | 9 ++++++---

1 file changed, 6 insertions(+), 3 deletions(-)

Joe's comments are, of course, correct as well.

regards,
dan carpenter

I'll take a look at Joe's suggestions too sometime tonight. I'd feel kinda bad tho if I just apply his work and send it in?

- Sandro Volery

#4 lore raw
Quoted 7 lines · Sandro Volery
Quoted 5 lines

Joe's comments are, of course, correct as well.

regards,
dan carpenter

I'll take a look at Joe's suggestions too sometime tonight. I'd feel kinda bad tho if I just apply his work and send it in?

Don't feel bad. Just do it. Give him credit in the commit message if you want. "Thanks to Joe Perches for his help."

I sometimes give people word for word patches and they don't copy it exactly and I wonder if this is why... My exact patch was the best one.

regards,
dan carpenter