Skip to contentSkip to conversation

Source code review around jump label usage

PATCH In review SF Markus Elfring 114 participants 1,410 messages Dec 11, 2015 – Jan 5, 2024 2 messages not in the archive Page 2 of 6

Subsystems (101)
lore
Share & tools
lore
#401 lore raw

PATCH 3/3 NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:40:10 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

---
 drivers/nfc/mei_phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nfc/mei_phy.c +1 -1
index 3c74028..99fd87d 100644
@@ -105,7 +105,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy)
 {
 
 	struct mei_nfc_cmd cmd;
-	struct mei_nfc_reply *reply = NULL;
+	struct mei_nfc_reply *reply;
 	struct mei_nfc_if_version *version;
 	size_t if_version_length;
 	int bytes_recv, r;
Signature · 1 line
2.6.3
maintainer
#317 lore raw

Re: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:35:03 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

This patch is unnecessary. The variable initialisation is redundant. See the difference? Sending an unnecessary patch causes unnecessary load on reviewers and maintainers. Keeping redundant code has no measurable cost, and can save the same maintainers a lot of trouble later.

I'd like to keep this particular redundant initialisation as a safe guard against future code refactoring, causing for example the err label to move up. Yes, I do understand that any patch with such a bug should be rejected, but I do know what happens in the real world and how easy it is for something like that to slip through in a stream of unnecessary "cleanup" patches.

Reducing redundancy in the kernel is only making the code less robust. It is harmful. Please stop. Thanks.

Bjørn
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#315 lore raw

Re: [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind()

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:32:07 +0100

Reduce the scope for the local variable "desc" to one branch of an if statement.

This patch is harmless. But is also pointless.

You could at least try to explain why this must be changed. I'm not interested in why you think it is better this way - I might agree with that. what I am interested in is the advantage changing the code gives us. Some analysis of the risk and work involved would also be nice. Is this change really worth it?

Personally I am convinced that I wasted any time I used writing this, and you wasted any time you used reading it. Sorry.

Note: This patch would have been fine if it was a natural part of some *improvement* of the driver, i.e. a bugfix or feaure addition. As a standalone patch I see it as noise.

Please stop the noise and start writing something useful. I'm sure you can fix bugs instead. Wouldn't that be more interesting? More challenging? These mindless robotic code refactoring patches are really best left for robots.

Bjørn
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#397 lore raw

Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()

In reply to SF Markus Elfring

Hi Markus,

Quoted 46 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jan 2016 21:21:24 +0100

This issue was detected by using the Coccinelle software.

Adjust jump targets according to the current Linux coding style convention.

---
 drivers/nfc/mei_phy.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/nfc/mei_phy.c +4 -4
index 83deda4..8e3a69f 100644
@@ -173,8 +173,8 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)
 
        reply = kzalloc(connect_resp_length, GFP_KERNEL);
        if (!reply) {
-               kfree(cmd);
-               return -ENOMEM;
+               r = -ENOMEM;
+               goto free_cmd;
        }
 
        connect_resp = (struct mei_nfc_connect_resp *)reply->data;
@@ -189,7 +189,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)
        r = mei_cldev_send(phy->cldev, (u8 *)cmd, connect_length);
        if (r < 0) {
                pr_err("Could not send connect cmd %d\n", r);
-               goto err;
+               goto free_reply;
        }
 
        bytes_recv = mei_cldev_recv(phy->cldev, (u8 *)reply,
@@ -197,7 +197,7 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)
        if (bytes_recv < 0) {
                r = bytes_recv;
                pr_err("Could not read connect response %d\n", r);
-               goto err;
+               goto free_reply;
        }
 
        MEI_DUMP_NFC_HDR("connect reply", &reply->hdr);

drivers/nfc/mei_phy.c static int mei_nfc_connect(struct nfc_mei_phy *phy) · line 217

Quoted 10 lines
drivers/nfc/mei_phy.c +2 -3
@@ -210,11 +210,10 @@ static int mei_nfc_connect(struct nfc_mei_phy *phy)
                connect_resp->me_hotfix, connect_resp->me_build);
 
        r = 0;
-
-err:
+free_reply:
        kfree(reply);
+free_cmd:
        kfree(cmd);
-

Why are you deleting the two blank lines here?

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
maintainer
#388 lore raw

Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations

In reply to SF Markus Elfring
Quoted 2 lines · SF Markus Elfring

A few update suggestions were taken into account
from static source code analysis.

While static analysis can be useful, I don't think these specific conversions are generally useful.

Perhaps it would be more useful to convert the string duplication or snprintf logic to kstrdup/kasprintf

This:

	if (num_queues = 1) {
		xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		strcpy(xspath, dev->otherend);
	} else {
		xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
		xspath = kzalloc(xspathsize, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
			 queue->id);
	}

could be simplified to something like:

	if (num_queues = 1)
		xspath = kstrdup(dev->otherend, GFP_KERNEL);
	else
		xspath = kasprintf(GFP_KERNEL, "%s/queue-%u",
				   dev->otherend, queue->id);
	if (!xspath)
		etc...

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#389 lore raw

Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations

In reply to SF Markus Elfring
Quoted 2 lines · SF Markus Elfring

A few update suggestions were taken into account
from static source code analysis.

While static analysis can be useful, I don't think these specific conversions are generally useful.

Perhaps it would be more useful to convert the string duplication or snprintf logic to kstrdup/kasprintf

This:

	if (num_queues == 1) {
		xspath = kzalloc(strlen(dev->otherend) + 1, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		strcpy(xspath, dev->otherend);
	} else {
		xspathsize = strlen(dev->otherend) + xenstore_path_ext_size;
		xspath = kzalloc(xspathsize, GFP_KERNEL);
		if (!xspath) {
			xenbus_dev_fatal(dev, -ENOMEM,
					 "reading ring references");
			return -ENOMEM;
		}
		snprintf(xspath, xspathsize, "%s/queue-%u", dev->otherend,
			 queue->id);
	}

could be simplified to something like:

	if (num_queues == 1)
		xspath = kstrdup(dev->otherend, GFP_KERNEL);
	else
		xspath = kasprintf(GFP_KERNEL, "%s/queue-%u",
				   dev->otherend, queue->id);
	if (!xspath)
		etc...
maintainer
#318 lore raw

Re: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()

In reply to Bjørn Mork

From: Bjørn Mork <[email protected]>
Date: Sat, 02 Jan 2016 22:30:48 +0100

Quoted 9 lines
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 17:35:03 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

Quoted 5 lines

This patch is unnecessary. The variable initialisation is redundant. See the difference? Sending an unnecessary patch causes unnecessary load on reviewers and maintainers. Keeping redundant code has no measurable cost, and can save the same maintainers a lot of trouble later.

+1

I'm getting really tired of these changes. And a lot of them are coming in right now...
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#398 lore raw

Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()

In reply to Julian Calaby
Quoted 10 lines

drivers/nfc/mei_phy.c static int mei_nfc_connect(struct nfc_mei_phy *phy) · line 217

Quoted 8 lines
        r = 0;
drivers/nfc/mei_phy.c +2 -3
-
-err:
+free_reply:
        kfree(reply);
+free_cmd:
        kfree(cmd);
-

Why are you deleting the two blank lines here?

Can they be unnecessary at this source code place
according to the Linux coding style convention?

Regards,
Markus

maintainer
#399 lore raw

Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()

Quoted 11 lines · SF Markus Elfring
Quoted 10 lines
Quoted 8 lines

        r = 0;

drivers/nfc/mei_phy.c +1 -2
-
-err:
+free_reply:

        kfree(reply);
+free_cmd:
        kfree(cmd);
-

Why are you deleting the two blank lines here?

Quoted 2 lines

Can they be unnecessary at this source code place
according to the Linux coding style convention?

As far as I know, there's no linux specific accepted convention for blank lines preceding labels.

My personal preference is for a blank line before a new block, but not before the second and subsequent labels in an error handling block.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#402 lore raw

cover rtc-ab-b5ze-s3: Fine-tuning for some function implementations

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:37:34 +0100

Several update suggestions were taken into account from static source code analysis.

Markus Elfring (8):
Better exception handling in abb5zes3_probe()
Delete an unnecessary variable in abb5zes3_rtc_set_alarm()
Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer() Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm() Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm() Delete an unnecessary variable in _abb5zes3_rtc_read_timer()
Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
Delete an unnecessary variable in _abb5zes3_rtc_set_timer()

 drivers/rtc/rtc-ab-b5ze-s3.c | 59 ++++++++++++++++++++------------------------
 1 file changed, 27 insertions(+), 32 deletions(-)
Signature · 1 line
2.6.3
#403 lore raw

PATCH 1/8 rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe()

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:07:49 +0100

This issue was detected by using the Coccinelle software.

* Return directly before the data structure element "irq" was assigned.

* Drop the explicit initialisation for the variable "data" at the beginning then.

* Adjust jump targets according to the Linux coding style convention.

* Simplify a condition check at the end.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +14 -18
index a319bf1..1291206 100644
@@ -889,35 +889,31 @@ static const struct regmap_config abb5zes3_rtc_regmap_config = {
 static int abb5zes3_probe(struct i2c_client *client,
 			  const struct i2c_device_id *id)
 {
-	struct abb5zes3_rtc_data *data = NULL;
+	struct abb5zes3_rtc_data *data;
 	struct device *dev = &client->dev;
 	struct regmap *regmap;
 	int ret;
 
 	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
 				     I2C_FUNC_SMBUS_BYTE_DATA |
-				     I2C_FUNC_SMBUS_I2C_BLOCK)) {
-		ret = -ENODEV;
-		goto err;
-	}
+				     I2C_FUNC_SMBUS_I2C_BLOCK))
+		return -ENODEV;
 
 	regmap = devm_regmap_init_i2c(client, &abb5zes3_rtc_regmap_config);
 	if (IS_ERR(regmap)) {
 		ret = PTR_ERR(regmap);
 		dev_err(dev, "%s: regmap allocation failed: %d\n",
 			__func__, ret);
-		goto err;
+		return ret;
 	}
 
 	ret = abb5zes3_i2c_validate_chip(regmap);
 	if (ret)
-		goto err;
+		return ret;
 
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
-	if (!data) {
-		ret = -ENOMEM;
-		goto err;
-	}
+	if (!data)
+		return -ENOMEM;
 
 	mutex_init(&data->lock);
 	data->regmap = regmap;
@@ -925,7 +921,7 @@ static int abb5zes3_probe(struct i2c_client *client,
 
 	ret = abb5zes3_rtc_check_setup(dev);
 	if (ret)
-		goto err;
+		return ret;
 
 	if (client->irq > 0) {
 		ret = devm_request_threaded_irq(dev, client->irq, NULL,
@@ -940,7 +936,7 @@ static int abb5zes3_probe(struct i2c_client *client,
 		} else {
 			dev_err(dev, "%s: irq %d unavailable (%d)\n",
 				__func__, client->irq, ret);
-			goto err;
+			return ret;
 		}
 	}
 
@@ -950,7 +946,7 @@ static int abb5zes3_probe(struct i2c_client *client,
 	if (ret) {
 		dev_err(dev, "%s: unable to register RTC device (%d)\n",
 			__func__, ret);
-		goto err;
+		goto check_irq;
 	}
 
 	/* Enable battery low detection interrupt if battery not already low */
@@ -959,12 +955,12 @@ static int abb5zes3_probe(struct i2c_client *client,
 		if (ret) {
 			dev_err(dev, "%s: enabling battery low interrupt "
 				"generation failed (%d)\n", __func__, ret);
-			goto err;
+			goto check_irq;
 		}
 	}
-
-err:
-	if (ret && data && data->irq)
+	return 0;
+check_irq:
+	if (data->irq)
 		device_init_wakeup(dev, false);
 	return ret;
 }
Signature · 1 line
2.6.3
#404 lore raw

PATCH 2/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:35:09 +0100

Pass the address of the data structure element "time" directly in a call of the function "rtc_tm_to_time" instead of an extra initialisation for one local variable at the beginning.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +1 -2
index 1291206..ed9b873 100644
@@ -596,7 +596,6 @@ err:
 static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
-	struct rtc_time *alarm_tm = &alarm->time;
 	unsigned long rtc_secs, alarm_secs;
 	struct rtc_time rtc_tm;
 	int ret;
@@ -610,7 +609,7 @@ static int abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	if (ret)
 		goto err;
 
-	ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
+	ret = rtc_tm_to_time(&alarm->time, &alarm_secs);
 	if (ret)
 		goto err;
 
Signature · 1 line
2.6.3
#405 lore raw

PATCH 3/8 rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:42:18 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +1 -1
index ed9b873..33a7cf1 100644
@@ -560,7 +560,7 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
 	u8 regs[ABB5ZES3_TIMA_SEC_LEN];
 	u8 mask = ABB5ZES3_REG_TIM_CLK_TAC0 | ABB5ZES3_REG_TIM_CLK_TAC1;
-	int ret = 0;
+	int ret;
 
 	/* Program given number of seconds to Timer A registers */
 	sec_to_timer_a(secs, &regs[0], &regs[1]);
Signature · 1 line
2.6.3
#406 lore raw

PATCH 4/8 rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 07:51:49 +0100

Replace an explicit initialisation for one local variable at the beginning by an assignment.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -1
index 33a7cf1..0986715 100644
@@ -476,7 +476,7 @@ static int abb5zes3_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
-	struct rtc_time *alarm_tm = &alarm->time;
+	struct rtc_time *alarm_tm;
 	unsigned long rtc_secs, alarm_secs;
 	u8 regs[ABB5ZES3_ALRM_SEC_LEN];
 	struct rtc_time rtc_tm;
@@ -490,6 +490,7 @@ static int _abb5zes3_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
 	if (ret)
 		goto err;
 
+	alarm_tm = &alarm->time;
 	ret = rtc_tm_to_time(alarm_tm, &alarm_secs);
 	if (ret)
 		goto err;
Signature · 1 line
2.6.3
#407 lore raw

PATCH 5/8 rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 08:00:29 +0100

Replace an explicit initialisation for one local variable at the beginning by an assignment.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -1
index 0986715..02e3443 100644
@@ -382,7 +382,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev,
 				    struct rtc_wkalrm *alarm)
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
-	struct rtc_time rtc_tm, *alarm_tm = &alarm->time;
+	struct rtc_time rtc_tm, *alarm_tm;
 	unsigned long rtc_secs, alarm_secs;
 	u8 regs[ABB5ZES3_ALRM_SEC_LEN];
 	unsigned int reg;
@@ -396,6 +396,7 @@ static int _abb5zes3_rtc_read_alarm(struct device *dev,
 		goto err;
 	}
 
+	alarm_tm = &alarm->time;
 	alarm_tm->tm_sec  = 0;
 	alarm_tm->tm_min  = bcd2bin(regs[0] & 0x7f);
 	alarm_tm->tm_hour = bcd2bin(regs[1] & 0x3f);
Signature · 1 line
2.6.3
#408 lore raw

PATCH 6/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 08:46:50 +0100

Pass the address of the data structure element "time" directly in a call of the function "rtc_time_to_tm" instead of an extra initialisation for one local variable at the beginning.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -2
index 02e3443..e3a015a 100644
@@ -326,7 +326,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev,
 				    struct rtc_wkalrm *alarm)
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
-	struct rtc_time rtc_tm, *alarm_tm = &alarm->time;
+	struct rtc_time rtc_tm;
 	u8 regs[ABB5ZES3_TIMA_SEC_LEN + 1];
 	unsigned long rtc_secs;
 	unsigned int reg;
@@ -362,7 +362,7 @@ static int _abb5zes3_rtc_read_timer(struct device *dev,
 		goto err;
 
 	/* ... and convert back. */
-	rtc_time_to_tm(rtc_secs + timer_secs, alarm_tm);
+	rtc_time_to_tm(rtc_secs + timer_secs, &alarm->time);
 
 	ret = regmap_read(data->regmap, ABB5ZES3_REG_CTRL2, &reg);
 	if (ret) {
Signature · 1 line
2.6.3
#409 lore raw

PATCH 7/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -5
index e3a015a..88f1d0b 100644
@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	struct i2c_client *client = data;
 	struct device *dev = &client->dev;
 	struct abb5zes3_rtc_data *rtc_data = dev_get_drvdata(dev);
-	struct rtc_device *rtc = rtc_data->rtc;
 	u8 regs[ABB5ZES3_CTRL_SEC_LEN];
 	int ret, handled = IRQ_NONE;
 
@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check alarm flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_AF) {
 		dev_dbg(dev, "RTC alarm!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/* Acknowledge and disable the alarm */
 		_abb5zes3_rtc_clear_alarm(dev);
@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check watchdog Timer A flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_WTAF) {
 		dev_dbg(dev, "RTC timer!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/*
 		 * Acknowledge and disable the alarm. Note: WTAF
Signature · 1 line
2.6.3
#415 lore raw

PATCH 8/8 rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:19:32 +0100

Pass a value directly in a call of the function "regmap_update_bits" instead of an extra initialisation for one local variable at the beginning.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +3 -2
index 88f1d0b..fed52d0 100644
@@ -561,7 +561,6 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
 	u8 regs[ABB5ZES3_TIMA_SEC_LEN];
-	u8 mask = ABB5ZES3_REG_TIM_CLK_TAC0 | ABB5ZES3_REG_TIM_CLK_TAC1;
 	int ret;
 
 	/* Program given number of seconds to Timer A registers */
@@ -575,7 +574,9 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,
 
 	/* Configure Timer A as a watchdog timer */
 	ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_TIM_CLK,
-				 mask, ABB5ZES3_REG_TIM_CLK_TAC1);
+				 ABB5ZES3_REG_TIM_CLK_TAC0
+				 | ABB5ZES3_REG_TIM_CLK_TAC1,
+				 ABB5ZES3_REG_TIM_CLK_TAC1);
 	if (ret)
 		dev_err(dev, "%s: failed to update timer\n", __func__);
 
Signature · 1 line
2.6.3
#346 lore raw

Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring
Quoted 1 line

I have never seen much evolution going on in this area.

I can get an other impression from a specific document for example.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/log/Documentation/CodingStyle

Quoted 1 line

What the patch tries to do is avoid the extra 'if (err)'.

Yes. - I propose to look at related consequences together with the usage of a popular short jump label once more.

When I read a subject saying "Better exception handling" it sounds like a functional improvement. Your change does not change anything functionally and may or may not save a bit of execution time depending on how smart the compiler is. What you change does is confuse people reading the code. So please explain why your update improves exception handling here. I don't see it. The code is not making the driver more robust against failures in this function, which is what I think of reading "better exception handling".

Quoted 9 lines
Quoted 2 lines

Setting coding style aside, the question is whether there is a good metric for the patch.

A software development challenge is to accept changes also around a topic like "error handling". My update suggestion for the source file "drivers/net/wireless/marvell/libertas/if_spi.c" should only improve exception handling. (I came along other source files where more improvements will eventually be possible.)

Quoted 7 lines

When will the run-time behaviour matter also for exceptional situations?

Quoted 1 line

Did you look at the resulting assembly code for different target architectures?

Not yet. - Which execution system variants would you recommend for further comparisons?

Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.

Regards,
Arend

#419 lore raw

cover 390/qeth: Fine-tuning for qeth_core_set_online()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:56:45 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an unnecessary variable initialisation
Refactoring

 drivers/s390/net/qeth_core_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Signature · 1 line
2.6.3
#420 lore raw

PATCH 1/2 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

---
 drivers/s390/net/qeth_core_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +1 -1
index 7871537..54fde2e 100644
@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)
 static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
-	int rc = 0;
+	int rc;
 	int def_discipline;
 
 	if (!card->discipline) {
Signature · 1 line
2.6.3
#426 lore raw

PATCH 2/2 390/qeth: Refactoring for qeth_core_set_online()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:50:11 +0100

Reduce the scope for the local variable "def_discipline" to one branch of an if statement.

---
 drivers/s390/net/qeth_core_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +2 -1
index 54fde2e..3261977 100644
@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
 	int rc;
-	int def_discipline;
 
 	if (!card->discipline) {
+		int def_discipline;
+
 		if (card->info.type = QETH_CARD_TYPE_IQD)
 			def_discipline = QETH_DISCIPLINE_LAYER3;
 		else
Signature · 1 line
2.6.3
#347 lore raw

Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to Arend van Spriel
Quoted 9 lines
Quoted 4 lines
Quoted 1 line

What the patch tries to do is avoid the extra 'if (err)'.

Yes. - I propose to look at related consequences together with the usage of a popular short jump label once more.

When I read a subject saying "Better exception handling" it sounds like a functional improvement. Your change does not change anything functionally and may or may not save a bit of execution time depending on how smart the compiler is.

Can it eventually matter to skip another condition check in three cases?

Quoted 1 line

What you change does is confuse people reading the code.

A few software developers might find this proposal unusual.

Quoted 2 lines

So please explain why your update improves exception handling here. I don't see it.

How does this feedback fit to the mentioned check avoidance?

Quoted 1 line

The code is not making the driver more robust against failures

That's true for this update suggestion.

Quoted 1 line

in this function, which is what I think of reading "better exception handling".

Other implementation details are affected by the shown fine-tuning.

Regards,
Markus

#416 lore raw

Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()

In reply to SF Markus Elfring
Quoted 24 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:19:32 +0100

Pass a value directly in a call of the function "regmap_update_bits" instead of an extra initialisation for one local variable at the beginning.

---
 drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +0 -1
index 88f1d0b..fed52d0 100644
@@ -561,7 +561,6 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,
 {
 	struct abb5zes3_rtc_data *data = dev_get_drvdata(dev);
 	u8 regs[ABB5ZES3_TIMA_SEC_LEN];
-	u8 mask = ABB5ZES3_REG_TIM_CLK_TAC0 | ABB5ZES3_REG_TIM_CLK_TAC1;
 	int ret;
 
 	/* Program given number of seconds to Timer A registers */

drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579

Quoted 7 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3 -1
@@ -575,7 +574,9 @@ static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm,
 
 	/* Configure Timer A as a watchdog timer */
 	ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_TIM_CLK,
-				 mask, ABB5ZES3_REG_TIM_CLK_TAC1);
+				 ABB5ZES3_REG_TIM_CLK_TAC0
+				 | ABB5ZES3_REG_TIM_CLK_TAC1,
+				 ABB5ZES3_REG_TIM_CLK_TAC1);

This doesn't seem like an improvement. The concept (mask) has disappeared, the binary operation is strangely broken, and the function call has one more line of arguments, which all look sort of the same and thus are hard to understand.

Don't underestimate the value of naming things.

julia

Quoted 11 lines
drivers/rtc/rtc-ab-b5ze-s3.c +0 -0
 	if (ret)
 		dev_err(dev, "%s: failed to update timer\n", __func__);
 
Signature · 6 lines
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#410 lore raw

Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

Why is it better?

julia

Quoted 41 lines
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -5
index e3a015a..88f1d0b 100644
@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	struct i2c_client *client = data;
 	struct device *dev = &client->dev;
 	struct abb5zes3_rtc_data *rtc_data = dev_get_drvdata(dev);
-	struct rtc_device *rtc = rtc_data->rtc;
 	u8 regs[ABB5ZES3_CTRL_SEC_LEN];
 	int ret, handled = IRQ_NONE;
 
@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check alarm flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_AF) {
 		dev_dbg(dev, "RTC alarm!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/* Acknowledge and disable the alarm */
 		_abb5zes3_rtc_clear_alarm(dev);
@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check watchdog Timer A flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_WTAF) {
 		dev_dbg(dev, "RTC timer!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/*
 		 * Acknowledge and disable the alarm. Note: WTAF
Signature · 1 line
2.6.3
#413 lore raw

Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 09:00:30 +0100

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

Also, I don't see anything related to time in this patch.

julia

Quoted 42 lines
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/rtc/rtc-ab-b5ze-s3.c +2 -5
index e3a015a..88f1d0b 100644
@@ -816,7 +816,6 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	struct i2c_client *client = data;
 	struct device *dev = &client->dev;
 	struct abb5zes3_rtc_data *rtc_data = dev_get_drvdata(dev);
-	struct rtc_device *rtc = rtc_data->rtc;
 	u8 regs[ABB5ZES3_CTRL_SEC_LEN];
 	int ret, handled = IRQ_NONE;
 
@@ -844,8 +843,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check alarm flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_AF) {
 		dev_dbg(dev, "RTC alarm!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/* Acknowledge and disable the alarm */
 		_abb5zes3_rtc_clear_alarm(dev);
@@ -857,8 +855,7 @@ static irqreturn_t _abb5zes3_rtc_interrupt(int irq, void *data)
 	/* Check watchdog Timer A flag */
 	if (regs[ABB5ZES3_REG_CTRL2] & ABB5ZES3_REG_CTRL2_WTAF) {
 		dev_dbg(dev, "RTC timer!\n");
-
-		rtc_update_irq(rtc, 1, RTC_IRQF | RTC_AF);
+		rtc_update_irq(rtc_data->rtc, 1, RTC_IRQF | RTC_AF);
 
 		/*
 		 * Acknowledge and disable the alarm. Note: WTAF
Signature · 1 line
2.6.3
#348 lore raw

Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to Arend van Spriel
Quoted 7 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Did you look at the resulting assembly code for different target architectures?

Not yet. - Which execution system variants would you recommend for further comparisons?

Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.

Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?

I'm against this patch as well.

Signature · 5 lines
Rafał
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#432 lore raw

PATCH 1/1 staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 17:25:59 +0100

Replace explicit initialisation for two local variables at the beginning by assignments.

---
 drivers/staging/slicoss/slicoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +4 -2
index b23a2d1..8fdcac8 100644
@@ -2301,9 +2301,9 @@ static int slic_adapter_allocresources(struct adapter *adapter,
  */
 static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 {
-	struct sliccard *card = adapter->card;
+	struct sliccard *card;
 	struct net_device *dev = adapter->netdev;
-	__iomem struct slic_regs *slic_regs = adapter->slic_regs;
+	__iomem struct slic_regs *slic_regs;
 	struct slic_shmem *pshmem;
 	int rc;
 
@@ -2348,6 +2348,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 		adapter->queues_initialized = 1;
 	}
 
+	slic_regs = adapter->slic_regs;
 	slic_reg32_write(&slic_regs->slic_icr, ICR_INT_OFF, FLUSH);
 	mdelay(1);
 
@@ -2374,6 +2375,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 	}
 
 	adapter->state = ADAPT_UP;
+	card = adapter->card;
 	if (!card->loadtimerset) {
 		setup_timer(&card->loadtimer, &slic_timer_load_check,
 			    (ulong)card);
Signature · 1 line
2.6.3
#433 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 17:25:59 +0100

Replace explicit initialisation for two local variables at the beginning by assignments.

Why?

julia

Quoted 45 lines
---
 drivers/staging/slicoss/slicoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/staging/slicoss/slicoss.c +4 -2
index b23a2d1..8fdcac8 100644
@@ -2301,9 +2301,9 @@ static int slic_adapter_allocresources(struct adapter *adapter,
  */
 static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 {
-	struct sliccard *card = adapter->card;
+	struct sliccard *card;
 	struct net_device *dev = adapter->netdev;
-	__iomem struct slic_regs *slic_regs = adapter->slic_regs;
+	__iomem struct slic_regs *slic_regs;
 	struct slic_shmem *pshmem;
 	int rc;
 
@@ -2348,6 +2348,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 		adapter->queues_initialized = 1;
 	}
 
+	slic_regs = adapter->slic_regs;
 	slic_reg32_write(&slic_regs->slic_icr, ICR_INT_OFF, FLUSH);
 	mdelay(1);
 
@@ -2374,6 +2375,7 @@ static int slic_if_init(struct adapter *adapter, unsigned long *flags)
 	}
 
 	adapter->state = ADAPT_UP;
+	card = adapter->card;
 	if (!card->loadtimerset) {
 		setup_timer(&card->loadtimer, &slic_timer_load_check,
 			    (ulong)card);
Signature · 6 lines
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#411 lore raw

Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

In reply to Julia Lawall
Quoted 5 lines
Quoted 3 lines

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

Why is it better?

I suggest to refer to the data item "rtc_data->rtc" directly because the variable "rtc" was read only in two if branches.
Does it make sense then to reduce the variable allocation?

Regards,
Markus

#412 lore raw

Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

Quoted 9 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

Why is it better?

I suggest to refer to the data item "rtc_data->rtc" directly because the variable "rtc" was read only in two if branches.
Does it make sense then to reduce the variable allocation?

No. That is the job of the compiler. For a local variable whose address is never taken, the compiler can easily detect its live region, and place the initialization in an optimal way.

julia

#414 lore raw

Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()

In reply to Julia Lawall
Quoted 5 lines
Quoted 3 lines

Pass the address of the data structure element "time" directly in calls of the function "rtc_update_irq" instead of an extra initialisation for one local variable at the beginning.

Also, I don't see anything related to time in this patch.

I should have referred to the data structure element "rtc" here. Should I resend this patch series with a corrected commit message now?

Regards,
Markus

#417 lore raw

Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()

In reply to Julia Lawall
Quoted 7 lines

drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579

Quoted 5 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3 -1
 	ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_TIM_CLK,
-				 mask, ABB5ZES3_REG_TIM_CLK_TAC1);
+				 ABB5ZES3_REG_TIM_CLK_TAC0
+				 | ABB5ZES3_REG_TIM_CLK_TAC1,
+				 ABB5ZES3_REG_TIM_CLK_TAC1);

This doesn't seem like an improvement.

Interesting …

Quoted 1 line

The concept (mask) has disappeared,

I suggest to drop another local variable.
Can the operator "Bitwise OR" be sufficient to indicate the concept "mask"?

Quoted 1 line

the binary operation is strangely broken,

Do you prefer an other source code formatting within the usual line length range?

Quoted 1 line

and the function call has one more line of arguments,

How should several long preprocessor symbols be combined together with indentation so that they will fit into the limit of 80 characters?

Quoted 1 line

which all look sort of the same and thus are hard to understand.

Is this an usual consequence from an ordinary name pattern?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#418 lore raw

Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()

Quoted 24 lines · SF Markus Elfring
Quoted 7 lines

drivers/rtc/rtc-ab-b5ze-s3.c static int _abb5zes3_rtc_set_timer(struct device *dev, struct rtc_wkalrm *alarm, · line 579

Quoted 5 lines
drivers/rtc/rtc-ab-b5ze-s3.c +3 -1
 	ret = regmap_update_bits(data->regmap, ABB5ZES3_REG_TIM_CLK,
-				 mask, ABB5ZES3_REG_TIM_CLK_TAC1);
+				 ABB5ZES3_REG_TIM_CLK_TAC0
+				 | ABB5ZES3_REG_TIM_CLK_TAC1,
+				 ABB5ZES3_REG_TIM_CLK_TAC1);

This doesn't seem like an improvement.

Interesting …

Quoted 1 line

The concept (mask) has disappeared,

I suggest to drop another local variable.
Can the operator "Bitwise OR" be sufficient to indicate the concept "mask"?

Quoted 1 line

the binary operation is strangely broken,

Do you prefer an other source code formatting within the usual line length range?

Quoted 1 line

and the function call has one more line of arguments,

Quoted 7 lines

How should several long preprocessor symbols be combined together with indentation so that they will fit into the limit of 80 characters?

Quoted 1 line

which all look sort of the same and thus are hard to understand.

Is this an usual consequence from an ordinary name pattern?

The original code was better. No 80 character problem, easy to distinguish one argument from another, moderately meaningful variable name, etc.

julia

#434 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

In reply to Julia Lawall
Quoted 4 lines
Quoted 2 lines

Replace explicit initialisation for two local variables at the beginning by assignments.

Why?

I prefer that assignments for variables like "card" and "slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).

Another description could be this view:
I suggest to move the variable initialisation a bit.

Regards,
Markus

#435 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

Replace explicit initialisation for two local variables at the beginning by assignments.

Why?

I prefer that assignments for variables like "card" and "slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).

Another description could be this view:
I suggest to move the variable initialisation a bit.

And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.

greg k-h

#436 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 10 lines
Quoted 6 lines

I prefer that assignments for variables like "card" and "slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).

Another description could be this view:
I suggest to move the variable initialisation a bit.

And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.

I am a bit surprised that you do not like such source code fine-tuning. Will related software improvements get another chance later (eventually together with other changes)?

Regards,
Markus

#437 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 4 lines · SF Markus Elfring
Quoted 4 lines
Quoted 4 lines

I prefer that assignments for variables like "card" and "slic_regs" will only be performed immediately before the corresponding content will be read again (after a few condition checks were executed).

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Another description could be this view:
I suggest to move the variable initialisation a bit.

And like David Miller and others just said, please don't bother us with pointless patches such as this, if you keep it up, I'll have to add you to my killfile as patches like this are a waste of everyone's valuable time.

I am a bit surprised that you do not like such source code fine-tuning.

It's moving stuff around for no real reason, why would I like it? Reading and reviewing and applying this type of stuff takes away from the time I have to spend reviewing and applying actual code fixes from other developers who are doing real and useful work.

Remember maintainer's time is our most limited resource right now. You are abusing that by wasting their time for no valid reason.

Quoted 2 lines

Will related software improvements get another chance later (eventually together with other changes)?

Define "improvements". Did you fix an obvious bug? Did you speed up the code in a measurable way? Did you make the code easier to understand somehow? For this patch you did none of these things.

Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not. Please stop or again, you will end up in some killfiles, if you haven't already been placed there.

thanks,

greg k-h

#438 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 3 lines
Quoted 1 line

I am a bit surprised that you do not like such source code fine-tuning.

It's moving stuff around for no real reason, why would I like it?

Can such fine-tuning result in positive effects for the run-time behaviour?

Quoted 3 lines

Reading and reviewing and applying this type of stuff takes away from the time I have to spend reviewing and applying actual code fixes from other developers who are doing real and useful work.

I am aware that a lot of open issues are competing for your precious software development attention.

Quoted 1 line

Remember maintainer's time is our most limited resource right now.

That is mostly usual.

Quoted 1 line

You are abusing that by wasting their time for no valid reason.

I find a couple of my update suggestions still valid. I agree that the importance of proposed changes is varying.

Quoted 4 lines
Quoted 2 lines

Will related software improvements get another chance later (eventually together with other changes)?

Define "improvements". Did you fix an obvious bug?

Maybe. - It depends on the error classes you are interested in at the moment.

Quoted 1 line

Did you speed up the code in a measurable way?

My suggestions can result in measurable differences.

Quoted 2 lines

Did you make the code easier to understand somehow? For this patch you did none of these things.

Thanks for your view on my approach.

Will it become acceptable to reduce the scope for any more variable definitions in further function implementations?

Quoted 3 lines

Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not.

I am curious on the ways the discussed software can evolve further.

Regards,
Markus

#439 lore raw

Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 5 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

I am a bit surprised that you do not like such source code fine-tuning.

It's moving stuff around for no real reason, why would I like it?

Can such fine-tuning result in positive effects for the run-time behaviour?

If you can not benchmark and show the proof, don't even start to claim such a thing.

Quoted 3 lines
Quoted 1 line

Did you speed up the code in a measurable way?

My suggestions can result in measurable differences.

Show the proof please. That's the only way I will ever accept anything else from you like this.

Quoted 2 lines

Will it become acceptable to reduce the scope for any more variable definitions in further function implementations?

No.

Quoted 5 lines
Quoted 3 lines

Code in staging needs to be moved out of staging, and this patch does nothing toward achieving that goal and it wastes people's time reviewing it to see if it is correct or not.

I am curious on the ways the discussed software can evolve further.

That's nice, but that's not my concern.

greg k-h

#440 lore raw

Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 4 lines
Quoted 1 line

Can such fine-tuning result in positive effects for the run-time behaviour?

If you can not benchmark and show the proof, don't even start to claim such a thing.

Which measurement results would you accept for further discussion?

Quoted 3 lines
Quoted 1 line

My suggestions can result in measurable differences.

Show the proof please.

Which information presentations would finally qualify for "the proof" you request now?

Which test systems will be representative for you?

Quoted 1 line

That's the only way I will ever accept anything else from you like this.

Are there any update suggestions remaining in the waiting queue which have a higher chance of acceptance because their value might be a bit more obvious?

Regards,
Markus

#441 lore raw

Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 6 lines · SF Markus Elfring
Quoted 4 lines
Quoted 1 line

Can such fine-tuning result in positive effects for the run-time behaviour?

If you can not benchmark and show the proof, don't even start to claim such a thing.

Which measurement results would you accept for further discussion?

If you don't know how to show your results, then this whole discussion is pointless.

*plonk*

#442 lore raw

Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()

Quoted 4 lines
Quoted 1 line

Which measurement results would you accept for further discussion?

If you don't know how to show your results, then this whole discussion is pointless.

I could show test results. But it could happen that I would choose insufficient variations for execution environments.

I am unsure about the requested detail and size around test parameters.

Regards,
Markus

#169 lore raw

Re: [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()

In reply to SF Markus Elfring

Am 27.12.2015 um 18:33 schrieb SF Markus Elfring:

Quoted 11 lines

From: Markus Elfring <[email protected]>
Date: Sun, 27 Dec 2015 18:23:57 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the si2165_readreg8() function failed.

2. Reduce the scope for the local variables "ret" and "tmp" to one branch of an if statement.

Quoted 6 lines

3. Delete the jump label "err" then.

4. Return the value from a call of the si2165_writereg8() function without using an extra assignment for the variable "ret" at the end.

The patch looks fine.

Regards
Matthias

PS: I am going to switch to regmap, but this change is not yet polished and until now does not touch this function.

#357 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to SF Markus Elfring

These patches are labour intensive to review because you can't just do it in the email client. Also you were not able to review it properly yourself and introduced a bug.

I am often remove initializers but it's normally because I am changing something else which makes it worthwhile. This patch is the correct thing but it's not "worthwhile". It is not a good use of my time.

Please stop sending cleanup patches, Markus. Just send fixes.

regards,
dan carpenter

#358 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to Dan Carpenter

Btw, GCC misses a lot of uninitialized variable bugs. I have a Smatch check which sometimes catches the bugs that GCC misses but you should not rely on the tools here. These patches need to be reviewed manually.

And the "goto err" before the initialization makes everything more complicated (that's actually what caused the bug in this patch, in fact).

regards,
dan carpenter

#349 lore raw

Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to Rafał Miłecki
Quoted 11 lines · Rafał Miłecki
Quoted 7 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Did you look at the resulting assembly code for different target architectures?

Not yet. - Which execution system variants would you recommend for further comparisons?

Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.

Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?

You are asking me, right ;-) ? I have come across my share of MIPS platforms here at Broadcom, but I still try to avoid them as much as possible.

Quoted 1 line

I'm against this patch as well.

and counting... :-p

Regards,
Arend

#359 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to Dan Carpenter
Quoted 2 lines

These patches are labour intensive to review because you can't just do it in the email client.

Thanks for your general interest.

Quoted 2 lines

Also you were not able to review it properly yourself and introduced a bug.

I admit that it can happen during my software development that I overlook implementation details somehow.

Quoted 2 lines

I am often remove initializers but it's normally because I am changing something else which makes it worthwhile.

It is nice to hear that you are also occasionally looking for similar update candidates.

Quoted 1 line

This patch is the correct thing but it's not "worthwhile".

I find this view interesting.

Quoted 1 line

Please stop sending cleanup patches, Markus. Just send fixes.

How often will source code clean-up fix something?

May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?

Regards,
Markus

#350 lore raw

Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to Arend van Spriel
Quoted 8 lines · Arend van Spriel
Quoted 7 lines · Rafał Miłecki
Quoted 6 lines · Arend van Spriel
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

Did you look at the resulting assembly code for different target architectures?

Not yet. - Which execution system variants would you recommend for further comparisons?

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Guess x86{,_64} and arm would be good candidates, ie. CISC vs. RISC.

Oh, don't forget about MIPS with its fancy branches handling. You know about it, don't you?

You are asking me, right ;-) ? I have come across my share of MIPS platforms here at Broadcom, but I still try to avoid them as much as possible.

I was more thinking about author on this patch. But it's indeed an interesting thing, just to know, how MIPS CPU handles branches ;)

Signature · 1 line
Rafał
#421 lore raw

Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

In reply to SF Markus Elfring
Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

---
 drivers/s390/net/qeth_core_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +0 -0
index 7871537..54fde2e 100644

drivers/s390/net/qeth_core_main.c static void qeth_core_remove_device(struct ccwgroup_device *gdev) · line 5641

Quoted 6 lines
drivers/s390/net/qeth_core_main.c +1 -1
@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)
 static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
-	int rc = 0;
+	int rc;
 	int def_discipline;

You can generate hundreds of patches like this one. There are even plenty more opportunities within this same file. I don't think we need this.

If at all then change all occurrences within a file at once, but that is Ursula's call.

#427 lore raw

Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()

In reply to SF Markus Elfring
Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:50:11 +0100

Reduce the scope for the local variable "def_discipline" to one branch of an if statement.

---
 drivers/s390/net/qeth_core_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +0 -0
index 54fde2e..3261977 100644

drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646

Quoted 10 lines
drivers/s390/net/qeth_core_main.c +2 -1
@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
 	int rc;
-	int def_discipline;
 
 	if (!card->discipline) {
+		int def_discipline;
+
 		if (card->info.type = QETH_CARD_TYPE_IQD)
 			def_discipline = QETH_DISCIPLINE_LAYER3;

Same here: I don't think we want to start with patches like this. This going to be a never ending story without much benefit.

#360 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring
Quoted 1 line

Please stop sending cleanup patches, Markus. Just send fixes.

How often will source code clean-up fix something?

May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?

If you were sending checkpatch.pl fixes that would be easier to deal with but you are sending hundreds of "controversial" cleanups. They are controversial in the sense that they don't fix anything against official kernel style and they go against the author's original intention. I tend to agree that useless initializers are bad and disable GCCs uninitialized variable warnings but just because I agree with you doesn't make it official kernel style. It's slightly rude to go against the author's intention.

regards,
dan carpenter

#361 lore raw

Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

Quoted 4 lines
Quoted 2 lines

May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?

If you were sending checkpatch.pl fixes that would be easier to deal with

Does this feedback mean that you would accept any more suggestions around source code updates which are derived from recommendations of this script?

Quoted 1 line

but you are sending hundreds of "controversial" cleanups.

It depends on the time range you look at for my proposals.

Quoted 2 lines

They are controversial in the sense that they don't fix anything against official kernel style

I find that I suggested also few changes that fit to this aspect.

Quoted 1 line

and they go against the author's original intention.

Can it occasionally help to reconsider the "first approach"?

Quoted 1 line

I tend to agree that useless initializers are bad

Would any more software developers like to share their opinions on this detail?

Quoted 1 line

and disable GCCs uninitialized variable warnings

I hope that this software area can be also improved.

Quoted 1 line

but just because I agree with you doesn't make it official kernel style.

That is fine. - Will it become useful to clarify any extensions to a document like "CodingStyle"?

Quoted 1 line

It's slightly rude to go against the author's intention.

I just dare to propose further special changes.

Regards,
Markus

#428 lore raw

Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()

In reply to Heiko Carstens
Quoted 7 lines
Quoted 7 lines

+++ b/drivers/s390/net/qeth_core_main.c

drivers/s390/net/qeth_core_main.c +0 -1
@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
 	int rc;
-	int def_discipline;
 
Quoted 7 lines

drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646

Quoted 5 lines
drivers/s390/net/qeth_core_main.c +2 -0
 	if (!card->discipline) {
+		int def_discipline;
+
 		if (card->info.type = QETH_CARD_TYPE_IQD)
 			def_discipline = QETH_DISCIPLINE_LAYER3;

Same here: I don't think we want to start with patches like this.

Thanks for your feedback.

Quoted 1 line

This going to be a never ending story without much benefit.

Is the source code a bit clearer and safer if it will be expressed directly that the use of a specific variable is not intended for a complete function implementation but for the smaller scope of an if branch?

Regards,
Markus

maintainer
#366 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to Dan Carpenter
Quoted 1 line · Dan Carpenter

Please stop sending cleanup patches, Markus. Just send fixes.

Thanks for your continued but unwarranted belief in AI.

Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? I am sure there are lots and lots of other examples. There is no reason to believe this will ever stop. He just goes into Eliza mode.

Bjørn
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#429 lore raw

Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()

In reply to SF Markus Elfring
Quoted 18 lines · SF Markus Elfring
Quoted 7 lines
Quoted 7 lines

+++ b/drivers/s390/net/qeth_core_main.c

drivers/s390/net/qeth_core_main.c +0 -1
@@ -5638,9 +5638,10 @@ static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
 	int rc;
-	int def_discipline;
 
Quoted 7 lines

drivers/s390/net/qeth_core_main.c static int qeth_core_set_online(struct ccwgroup_device *gdev) · line 5646

Quoted 5 lines
drivers/s390/net/qeth_core_main.c +2 -0
 	if (!card->discipline) {
+		int def_discipline;
+
 		if (card->info.type = QETH_CARD_TYPE_IQD)
 			def_discipline = QETH_DISCIPLINE_LAYER3;

Same here: I don't think we want to start with patches like this.

Thanks for your feedback.

Quoted 6 lines
Quoted 1 line

This going to be a never ending story without much benefit.

Is the source code a bit clearer and safer if it will be expressed directly that the use of a specific variable is not intended for a complete function implementation but for the smaller scope of an if branch?

This depends on the function and what the author prefers. In this case the function body is very small so I don't see any benefit at all.

#430 lore raw

Re: 390/qeth: Refactoring for qeth_core_set_online()

Quoted 2 lines

In this case the function body is very small
so I don't see any benefit at all.

Do you care for fine-tuning of variable placement occasionally?

Regards,
Markus

#367 lore raw

Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to Bjørn Mork
Quoted 6 lines · Bjørn Mork
Quoted 1 line · Dan Carpenter

Please stop sending cleanup patches, Markus. Just send fixes.

Thanks for your continued but unwarranted belief in AI.

I always tell people that I am very mechanical and you can rely on me to send predictable responses...

Quoted 3 lines

Do you mind if I remind you of https://lkml.org/lkml/2014/11/3/162 ? I am sure there are lots and lots of other examples. There is no reason to believe this will ever stop. He just goes into Eliza mode.

Yup.

I feel some sense of responsibility for any patches where kernel-janitors is on the CC but I'm having a hard time dealing with all of Markus's patches. Normally you just respond to the first patch and people change the later patches but, as you put it, Markus just goes into ELIZA mode.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#362 lore raw

Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to SF Markus Elfring

Hi Markus,

Quoted 7 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

May I resend a consistent patch series for the source file "drivers/net/wireless/rsi/rsi_91x_pkt.c" in the near future?

If you were sending checkpatch.pl fixes that would be easier to deal with

Does this feedback mean that you would accept any more suggestions around source code updates which are derived from recommendations of this script?

A good rule of thumb here would be that if people start complaining about a particular type of change, stop sending them.

Another good rule of thumb is to try to "rock the boat" on coding style and conventions as little as possible. Just because it's possible doesn't mean that people want to do it.

That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it. "This makes things smaller" carries much more weight than "I think this is better". Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#270 lore raw

Re: [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 21:15:15 +0100

A few update suggestions were taken into account
from static source code analysis.

Are you fixing anything? Have you tested your work?

At the moment, I can't find any value in your patches.

Brian

#431 lore raw

Re: 390/qeth: Refactoring for qeth_core_set_online()

In reply to SF Markus Elfring
Quoted 4 lines · SF Markus Elfring
Quoted 2 lines

In this case the function body is very small
so I don't see any benefit at all.

Do you care for fine-tuning of variable placement occasionally?

No.

#363 lore raw

Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

In reply to Julian Calaby
Quoted 4 lines

That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it.

Are you looking also for "a proof" that such changes are worthwhile?

Quoted 2 lines

"This makes things smaller" carries much more weight than "I think this is better".

Can the discussed implementation of a function like "rsi_send_mgmt_pkt" become a bit smaller by the deletion of extra variable initialisations

Quoted 2 lines

Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.

Thanks for your interesting feedback.

Can a further constructive dialogue evolve from the presented information?

Regards,
Markus

#364 lore raw

Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

Hi Markus,

Quoted 6 lines · SF Markus Elfring
Quoted 4 lines

That said, if you figure out some change that produces significant reductions in code or binary size on multiple architectures without making things more complicated, less readable or making the code or binary size larger, then by all means propose it.

Are you looking also for "a proof" that such changes are worthwhile?

It'd be better than "I think doing things this way is better", which is the hallmark of most of your patch sets. (Admittedly not this one, but this one is where the discussion is now, so that's where we're discussing it.)

Quoted 5 lines
Quoted 2 lines

"This makes things smaller" carries much more weight than "I think this is better".

Can the discussed implementation of a function like "rsi_send_mgmt_pkt" become a bit smaller by the deletion of extra variable initialisations

I'm talking in general.

In this case you're asking people to review a patch which requires a lot of careful review for a fairly minor improvement. I must also note that you haven't CC'd the people who wrote this driver, so it's possible that the only people who have reviewed it aren't experts in the code.

The patches you sent recently which moved labels into if statements were a clear case of "I think this is better" where any actual benefit from the changes was eclipsed by the style and readability issues they introduced.

Quoted 4 lines
Quoted 2 lines

Almost all of the changes you've proposed that have seen any discussion whatsoever fall into the latter category.

Thanks for your interesting feedback.

No problem.

Quoted 1 line

Can a further constructive dialogue evolve from the presented information?

Part of the issue here is that you don't seem to be listening to the discussion of your patches, or if you are, you're not significantly changing your approach or attitude in response.

Every time you send a set of patches, there are legitimate issues which people raise, and every time they are discussed, you assert that your patches improve things and seem to ignore the concerns people raise.

I've seen this same pattern of discussion here with these patches, with your patches to move labels into if statements, with the patches you sent late June last year, your patches to remove conditions before kfree() and friends, etc.

You need to change you attitude: just because you can see some benefit from your patches doesn't mean others do and it doesn't mean that they're willing to accept them.

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#365 lore raw

Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

Quoted 1 line

Every time you send a set of patches,

I suggested some updates for Linux source files since October 2014.

Quoted 1 line

there are legitimate issues which people raise,

There was usual feedback.

Quoted 1 line

and every time they are discussed,

The discussion results were mixed between acceptance and usual disagreement.

Quoted 1 line

you assert that your patches improve things

I guess that should be the default intention of every patch, shouldn't it?

Quoted 1 line

and seem to ignore the concerns people raise.

I hope not. - But I can imagine that you might understand some responses from contributors in this way.
Are you waiting for another clarification on a specific issue?

Quoted 4 lines

I've seen this same pattern of discussion here with these patches, with your patches to move labels into if statements, with the patches you sent late June last year, your patches to remove conditions before kfree() and friends, etc.

It seems that communication difficulties come partly from the fact that I chose search patterns from static source code analysis so far which belong to an error category that gets a lower priority.

Quoted 3 lines

You need to change you attitude: just because you can see some benefit from your patches doesn't mean others do and it doesn't mean that they're willing to accept them.

I understand your advice.

Further update suggestions with higher importance might follow for various software areas in the future.

Regards,
Markus

Acked-by on v1 1/1
#282 lore raw

Re: [PATCH] be2net: Delete an unnecessary check in two functions

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 00:11:57 +0100

Remove two checks for null pointers which would be handled by usual error detection before.

This patch is suitable for the net-next tree. Thanks!

#167 lore raw

Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 27 Dec 2015 13:12:10 +0100
Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations

I suggest to return directly instead of using the jump label "err" in two functions (which are working without clean-up there).

Quoted 8 lines

Markus Elfring (2):
One jump label less in iser_reg_sig_mr()
One jump label less in isert_reg_sig_mr()

 drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
 drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
 2 files changed, 5 insertions(+), 7 deletions(-)

Doug, are you going to pick these two minor patches up, or shall I..?

#272 lore raw

Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 31 Dec 2015 22:40:39 +0100

Adjust a jump target to eliminate a check before error logging. Use the identifier "report_failure" instead of "err".

I don't see much value in those changes. Using the 'err' label is ok as it is not misleading and common use. And, there is no need to optimize the check since this is not the fast path and will be compiler optimized anyway. So let's keep the code as it is with the flavor of the original author.

-Robert

Quoted 46 lines
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/ethernet/cavium/thunder/nicvf_main.c +7 -8
index c24cb2a..21e1579 100644
@@ -922,7 +922,7 @@ static int nicvf_register_interrupts(struct nicvf *nic)
 		ret = request_irq(vector, nicvf_intr_handler,
 				  0, nic->irq_name[irq], nic->napi[irq]);
 		if (ret)
-			goto err;
+			goto report_failure;
 		nic->irq_allocated[irq] = true;
 	}
 
@@ -933,7 +933,7 @@ static int nicvf_register_interrupts(struct nicvf *nic)
 		ret = request_irq(vector, nicvf_rbdr_intr_handler,
 				  0, nic->irq_name[irq], nic);
 		if (ret)
-			goto err;
+			goto report_failure;
 		nic->irq_allocated[irq] = true;
 	}
 
@@ -944,13 +944,12 @@ static int nicvf_register_interrupts(struct nicvf *nic)
 	ret = request_irq(nic->msix_entries[irq].vector,
 			  nicvf_qs_err_intr_handler,
 			  0, nic->irq_name[irq], nic);
-	if (!ret)
+	if (!ret) {
 		nic->irq_allocated[irq] = true;
-
-err:
-	if (ret)
-		netdev_err(nic->netdev, "request_irq failed, vector %d\n", irq);
-
+		return 0;
+	}
+report_failure:
+	netdev_err(nic->netdev, "request_irq failed, vector %d\n", irq);
 	return ret;
 }
#422 lore raw

Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

In reply to SF Markus Elfring
Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 3 Jan 2016 10:48:05 +0100

Omit explicit initialisation at the beginning for one local variable that is redefined before its first use.

---
 drivers/s390/net/qeth_core_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/s390/net/qeth_core_main.c +0 -0
index 7871537..54fde2e 100644

drivers/s390/net/qeth_core_main.c static void qeth_core_remove_device(struct ccwgroup_device *gdev) · line 5643

Quoted 8 lines
drivers/s390/net/qeth_core_main.c +1 -1
@@ -5637,7 +5637,7 @@ static void qeth_core_remove_device(struct ccwgroup_device *gdev)
 static int qeth_core_set_online(struct ccwgroup_device *gdev)
 {
 	struct qeth_card *card = dev_get_drvdata(&gdev->dev);
-	int rc = 0;
+	int rc;
 	int def_discipline;
 
 	if (!card->discipline) {

As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches. Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver, or we take care about such minor changes, once we touch the code anyway due to other reasons.

#273 lore raw

Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection

In reply to Robert Richter
Quoted 4 lines
Quoted 2 lines

Adjust a jump target to eliminate a check before error logging. Use the identifier "report_failure" instead of "err".

I don't see much value in those changes.

Thanks for your feedback.

Quoted 1 line

Using the 'err' label is ok as it is not misleading and common use.

Is such a short jump label enough explanation for the information "what" and "why"?

Quoted 1 line

And, there is no need to optimize the check since this is not the fast path

Really? - Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/cavium/thunder/nicvf_main.c?id@fb5f8a60f33133d36afde35a9ad865d35e4423#n940

Quoted 1 line

and will be compiler optimized anyway.

How sure are you about automatic software optimisations?

Can it occasionally help to jump to the really intended source code location directly?

Quoted 18 lines
Quoted 18 lines
drivers/net/ethernet/cavium/thunder/nicvf_main.c +5 -6
@@ -944,13 +944,12 @@ static int nicvf_register_interrupts(struct nicvf *nic)
 	ret = request_irq(nic->msix_entries[irq].vector,
 			  nicvf_qs_err_intr_handler,
 			  0, nic->irq_name[irq], nic);
-	if (!ret)
+	if (!ret) {
 		nic->irq_allocated[irq] = true;
-
-err:
-	if (ret)
-		netdev_err(nic->netdev, "request_irq failed, vector %d\n", irq);
-
+		return 0;
+	}
+report_failure:
+	netdev_err(nic->netdev, "request_irq failed, vector %d\n", irq);
 	return ret;
 }
maintainer
#274 lore raw

Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 7 lines · SF Markus Elfring
Quoted 3 lines
Quoted 2 lines

Adjust a jump target to eliminate a check before error logging. Use the identifier "report_failure" instead of "err".

I don't see much value in those changes

Thanks for your feedback.

Quoted 1 line

Using the 'err' label is ok as it is not misleading and common use.

Is such a short jump label enough explanation for the information "what" and "why"?

When there is only one type of error possible, yes.

Quoted 5 lines
Quoted 2 lines

And, there is no need to optimize the check since this is not the fast path

Really? - Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?

Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.

#275 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 7 lines
Quoted 3 lines

Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?

Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.

* Do any more source code reviewers wonder about the need for such a double check?

* Which object code representations would you find representative for a further constructive discussion around this software component?

Regards,
Markus

maintainer
#276 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 10 lines · SF Markus Elfring
Quoted 7 lines
Quoted 3 lines

Is it a bit more efficient to avoid a double check for the variable "ret" at the end of the current implementation for the discussed function?

Before asking questions you could answer yourself, please look at object code produced by the compiler before and after your proposed changes.

* Do any more source code reviewers wonder about the need for such a double check?

Given the feedback you've already received,
it seems so.

Quoted 3 lines

* Which object code representations would you find representative for a further constructive discussion around this software component?

Evidence of actual object code improvement when
with compiled with optimizations.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#277 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 5 lines
Quoted 3 lines

* Which object code representations would you find representative for a further constructive discussion around this software component?

Evidence of actual object code improvement

How do you think about to provide a function implementation which looks a bit more efficient by default?

Quoted 1 line

when with compiled with optimizations.

Which combinations of hardware and software would you recommend for corresponding system checks?

Regards,
Markus

maintainer
#278 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 8 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines

* Which object code representations would you find representative for a further constructive discussion around this software component?

Evidence of actual object code improvement

How do you think about to provide a function implementation which looks a bit more efficient by default?

It's not a matter of "looks a bit more efficient". it's taste, style, and repetition for various functions.

Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.

Some of your patches are converting these templatized functions to a different form for no added value.

These patches make the local source code inconsistent and generally goes against the authors preferred style.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#279 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 3 lines

Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.

This is another interesting view on involved implementation details.

Quoted 2 lines

Some of your patches are converting these templatized functions to a different form for no added value.

Would you like to distinguish a bit more between my evolving collection of update suggestions and the concrete proposal for the function "nicvf_register_interrupts"?

Quoted 2 lines

These patches make the local source code inconsistent and generally goes against the authors preferred style.

Which programming approach will be the leading one here finally?

Regards,
Markus

maintainer
#280 lore raw

Re: net-thunder: One check less in nicvf_register_interrupts() after error detection

Quoted 3 lines · SF Markus Elfring
Quoted 3 lines

Some prefer that source code be "templatized" regardless of the number of exit points that any particular use of a specific function type.

[]

Quoted 6 lines
Quoted 2 lines

Some of your patches are converting these templatized functions to a different form for no added value.

Would you like to distinguish a bit more between my evolving collection of update suggestions and the concrete proposal for the function "nicvf_register_interrupts"?

No.

Quoted 4 lines
Quoted 2 lines

These patches make the local source code inconsistent and generally goes against the authors preferred style.

Which programming approach will be the leading one here finally?

Whatever the developer wants.

There is no _best_ or _only_ style for this.

#310 lore raw

RE: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()

In reply to SF Markus Elfring
Quoted 6 lines

From: SF Markus Elfring [mailto:elfring at users.sourceforge.net]
Sent: Friday, January 01, 2016 6:33 AM

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 15:11:09 +0100

Quoted 6 lines

Replace explicit initialisations for four local variables at the beginning by assignments that will only be performed if the corresponding code will really be executed.

---

This seems to me to be unnecessary fussing with the code.

sln

#423 lore raw

Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

In reply to Ursula Braun
Quoted 2 lines

As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches.

Thanks for your clarification.

Quoted 2 lines

Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver,

Is there any more fine-tuning cooking in the background?

Quoted 1 line

or we take care about such minor changes, once we touch the code anyway

How often will this really happen?

Quoted 1 line

due to other reasons.

I am curious which ones will trigger further related software improvements.

Regards,
Markus

#424 lore raw

Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

Quoted 10 lines · SF Markus Elfring
Quoted 2 lines

As Heiko already answered, you could propose a lot of this kind of changes with just minor benefit. I do not want to push them in single patches.

Thanks for your clarification.

Quoted 2 lines

Either there is a cleanup patch for explicit initialisation of local variables in the whole qeth driver,

Is there any more fine-tuning cooking in the background?

Not yet; qeth is an important driver for Linux on System z; there are lots of investigation ideas for improvements, which we will take care about according to their priorities. I regard your proposed fine-tuning code change as valid, but prioritize it as one with lowest benefit, since it does not really make a difference once compiled.

Quoted 5 lines
Quoted 3 lines

or we take care about such minor changes, once we touch the code anyway

How often will this really happen?

There is no general rule. Check our git history to answer this question.

Quoted 9 lines
Quoted 3 lines

due to other reasons.

I am curious which ones will trigger further related software improvements.

Regards,
Markus

#311 lore raw

Re: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 15:11:09 +0100

Replace explicit initialisations for four local variables at the beginning
by assignments that will only be performed if the corresponding code will really be executed.

Quoted 5 lines

---
?drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 15 +++++++++---
---
?1 file changed, 9 insertions(+), 6 deletions(-)

Dropping this patch based on feedback from Shannon.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part
URL: <http://lists.osuosl.org/pipermail/intel-wired-lan/attachments/20160108/d5613803/attachment.asc>

#425 lore raw

Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()

In reply to Ursula Braun
Quoted 2 lines
Quoted 1 line

Is there any more fine-tuning cooking in the background?

Not yet;

I am a bit surprised by this information.

Quoted 1 line

qeth is an important driver for Linux on System z;

Good to know …

Quoted 2 lines

there are lots of investigation ideas for improvements, which we will take care about according to their priorities.

Software development as usual …

Quoted 1 line

I regard your proposed fine-tuning code change as valid,

Thanks for a bit of positive feedback.

Quoted 1 line

but prioritize it as one with lowest benefit,

This is fine in principle.

Quoted 1 line

since it does not really make a difference once compiled.

Would you like to help in the determination if deletion of unnecessary variable initialisations (besides in the implementation of the function "qeth_core_set_online") will result in measurable effects?

Regards,
Markus

#309 lore raw

RE: net-i40e: Reconsider further usage of variable "i" in i40e_vc_get_vf_resources_msg()

In reply to SF Markus Elfring
Quoted 11 lines

From: SF Markus Elfring [mailto:elfring at users.sourceforge.net]

Hello,

I have taken another look at the implementation of the function "i40e_vc_get_vf_resources_msg". I find the use of the variable "i"
strange there. It seems that the value from the increment operation in an
if branch is not reused so far.

Quoted 2 lines

I would appreciate a further clarification.
Can this variable be eventually deleted?

Thanks for pointing this out. We've got an internal patch coming that will address this.

Cheers,
sln

#212 lore raw

Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

In reply to SF Markus Elfring

This set is confusing.

Why do you have a cover letter specifying this as a 2 patch set, yet there are 4 patches attached to it?

Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 15:10:48 +0100

What format is this?

Quoted 10 lines

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete an unnecessary variable initialisation
Refactoring

 drivers/mfd/smsc-ece1099.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v1 2/2
#207 lore raw

Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 15:03:31 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the function "devm_regmap_init_i2c" or "regmap_write" failed.

* Delete the jump label "err" then.

Why are you bullet pointing here?

Just use proper sentences to tell us what's going on.

Quoted 4 lines
---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Code looks fine however.

Please re-submit the set with the aforementioned changes along with my:

Quoted 34 lines
drivers/mfd/smsc-ece1099.c +3 -6
index bcac488..951333a 100644
@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 	}
 
 	smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
-	if (IS_ERR(smsc->regmap)) {
-		ret = PTR_ERR(smsc->regmap);
-		goto err;
-	}
+	if (IS_ERR(smsc->regmap))
+		return PTR_ERR(smsc->regmap);
 
 	i2c_set_clientdata(i2c, smsc);
 	smsc->dev = &i2c->dev;
@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 
 	ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk);
 	if (ret)
-		goto err;
+		return ret;
 
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node)
@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 					   NULL, NULL, &i2c->dev);
 #endif
 
-err:
 	return ret;
 }
 
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#208 lore raw

Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()

Oh, the subject line is also duff. Please describe the changes properly.

"refactoring X", "making changes to Y" are not good subject lines.

Quoted 62 lines · Lee Jones
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 15:03:31 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the function "devm_regmap_init_i2c" or "regmap_write" failed.

* Delete the jump label "err" then.

Why are you bullet pointing here?

Just use proper sentences to tell us what's going on.

Quoted 4 lines
---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Code looks fine however.

Please re-submit the set with the aforementioned changes along with my:

Quoted 34 lines
drivers/mfd/smsc-ece1099.c +3 -6
index bcac488..951333a 100644
@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 	}
 
 	smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
-	if (IS_ERR(smsc->regmap)) {
-		ret = PTR_ERR(smsc->regmap);
-		goto err;
-	}
+	if (IS_ERR(smsc->regmap))
+		return PTR_ERR(smsc->regmap);
 
 	i2c_set_clientdata(i2c, smsc);
 	smsc->dev = &i2c->dev;
@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 
 	ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk);
 	if (ret)
-		goto err;
+		return ret;
 
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node)
@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 					   NULL, NULL, &i2c->dev);
 #endif
 
-err:
 	return ret;
 }
 
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#205 lore raw

Re: [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 14:47:40 +0100

The variable "ret" will be set to an appropriate value a bit later. Thus let us omit the explicit initialisation at the beginning.

Not sure this change is worth your or my time to be frank. I could understand if you were a first time submitter who was dipping their toe in the water, but for someone with 200+ patches, I really think you should be focusing on less trivial matters.

Quoted 18 lines
---
 drivers/mfd/smsc-ece1099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/smsc-ece1099.c +1 -1
index a4c0df7..bcac488 100644
@@ -36,7 +36,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 {
 	struct smsc *smsc;
 	int devid, rev, venid_l, venid_h;
-	int ret = 0;
+	int ret;
 
 	smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc),
 				GFP_KERNEL);
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#220 lore raw

Re: [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection

In reply to SF Markus Elfring
Quoted 22 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 19:29:08 +0100

The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/twl-core.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/mfd/twl-core.c +0 -0
index 831696e..0d9350c 100644

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 626

Quoted 2 lines
drivers/mfd/twl-core.c +0 -0
@@ -625,7 +625,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 	if (!pdev) {
 		dev_dbg(&twl->client->dev, "can't alloc dev\n");

Change this to be dev_err()

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 628

Quoted 3 lines
drivers/mfd/twl-core.c +1 -1
 		status = -ENOMEM;
-		goto err;
+		goto report_failure;

... and just return status from here.

Quoted 14 lines
drivers/mfd/twl-core.c +1 -1
 	}
 
 	pdev->dev.parent = &twl->client->dev;
@@ -634,7 +634,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -647,21 +647,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 655

Quoted 10 lines
drivers/mfd/twl-core.c +2 -2
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irqs\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-	if (status = 0)
+	if (!status) {

You've changed the way you handle errors from this point. To be more consistent it would be better if you checked for status, then jump to put_device in the case of a failure, as you do above.

Quoted 18 lines
drivers/mfd/twl-core.c +6 -7
 		device_init_wakeup(&pdev->dev, can_wakeup);
-
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&twl->client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
+		return &pdev->dev;
 	}
-	return &pdev->dev;
+put_device:
+	platform_device_put(pdev);
+report_failure:
+	dev_err(&twl->client->dev, "can't add %s dev\n", name);
+	return ERR_PTR(status);
 }
 
 static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#196 lore raw

Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 13:56:42 +0100

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Same comments as before.

Quoted 50 lines
drivers/mfd/dm355evm_msp.c +10 -11
index bc90efe..e4aa1b8 100644
@@ -202,7 +202,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	if (!pdev) {
 		dev_dbg(&client->dev, "can't alloc dev\n");
 		status = -ENOMEM;
-		goto err;
+		goto report_failure;
 	}
 
 	device_init_wakeup(&pdev->dev, can_wakeup);
@@ -212,7 +212,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -225,19 +225,18 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
-	return &pdev->dev;
+	if (!status)
+		return &pdev->dev;
+put_device:
+	platform_device_put(pdev);
+report_failure:
+	dev_err(&client->dev, "can't add %s dev\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Acked-by on v2 1/6
#135 lore raw

Re: [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()

In reply to SF Markus Elfring

This patch series looks good to me

Thanks,

Quoted 50 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 26 Dec 2015 22:18:38 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the _ocrdma_alloc_pd() function failed.

* Reduce the scope for the local variable "status" to one case of an if statement.

* Delete the jump label "err" then.

* Return zero as a constant at the end.

---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -7
index 583001b..7f10cc47 100644
@@ -483,19 +483,16 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
                                    struct ocrdma_ucontext *uctx,
                                    struct ib_udata *udata)
 {
-       int status = 0;
-
        uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
        if (IS_ERR(uctx->cntxt_pd)) {
-               status = PTR_ERR(uctx->cntxt_pd);
+               int status = PTR_ERR(uctx->cntxt_pd);
                uctx->cntxt_pd = NULL;
-               goto err;
+               return status;
        }
 
        uctx->cntxt_pd->uctx = uctx;
        uctx->cntxt_pd->ibpd.device = &dev->ibdev;
-err:
-       return status;
+       return 0;
 }
 
 static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
--

2.6.3

#197 lore raw

Re: mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to Lee Jones
Quoted 7 lines
Quoted 7 lines

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

Quoted 8 lines
Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

Same comments as before.

To which comments do you refer here?

Are you interested in any further clarification of open issues?

Regards,
Markus

#213 lore raw

Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

In reply to Lee Jones
Quoted 4 lines

This set is confusing.

Why do you have a cover letter specifying this as a 2 patch set, yet there are 4 patches attached to it?

I do not see too many messages for this update suggestion.

Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 15:10:48 +0100

What format is this?

Are such specifications needed to preserve the desired authorship information during the transfer of commit messages by email?

Regards,
Markus

#210 lore raw

Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()

In reply to a message not in the archive

Please refrain from replying off-list. Adding back the Cc's.

Quoted 5 lines · SF Markus Elfring
Quoted 3 lines

Oh, the subject line is also duff. Please describe the changes properly.

"refactoring X", "making changes to Y" are not good subject lines.

Which topic would you prefer for my update suggestion instead?

This one.

"mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()"

The function name and just describing the changes as "refactoring" do not describe the changes in a helpful way.

Quoted 11 lines
Quoted 1 line
Quoted 1 line

Code looks fine however.

Thanks for your look.

Quoted 3 lines
Quoted 3 lines

Please re-submit the set with the aforementioned changes along with my:

Do you really request that I should append this tag already to messages for (my adjusted) commits you can not see so far?

Yes. The code looks fine, and if the commit log is still not up to scratch I just won't apply it. :)

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#198 lore raw

Re: mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to SF Markus Elfring
Quoted 14 lines · SF Markus Elfring
Quoted 14 lines
Quoted 13 lines

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
Quoted 5 lines
Quoted 1 line

Same comments as before.

To which comments do you refer here?

Are you interested in any further clarification of open issues?

I'm sure you'll work it out. ;)

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#214 lore raw

Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring
Quoted 4 lines

This set is confusing.

Why do you have a cover letter specifying this as a 2 patch set, yet there are 4 patches attached to it?

I do not see too many messages for this update suggestion.

In my inbox, your set looks like this:

Dec 29 2015 SF Markus Elfring (  0) ┬>[PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection
Dec 29 2015 SF Markus Elfring (  0) ├>[PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
Dec 29 2015 SF Markus Elfring (  0) │├>[PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
Dec 29 2015 SF Markus Elfring (  0) │└>[PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
Dec 29 2015 SF Markus Elfring (  0) └>[PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection

... which is unconventional and pretty confusing.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 15:10:48 +0100

What format is this?

Are such specifications needed to preserve the desired authorship information during the transfer of commit messages by email?

How did you sent this set? I fear you are sending these patches manually, using your mail client. You should instead be creating patches with git format-patch and sending them using git send-email. Then the formatting will be correct.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#215 lore raw

Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

Quoted 1 line

In my inbox, your set looks like this:

Thanks for your information. - I find the display correct.

Quoted 1 line

... which is unconventional and pretty confusing.

Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "drivers/mfd"?

Quoted 1 line

I fear you are sending these patches manually, using your mail client.

I admit that I am doing this usually.

Quoted 1 line

You should instead be creating patches with git format-patch

This happens also …

Quoted 1 line

and sending them using git send-email.

I prefer other software tools for this task so far.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#216 lore raw

Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

Quoted 9 lines · SF Markus Elfring
Quoted 1 line

In my inbox, your set looks like this:

Thanks for your information. - I find the display correct.

Quoted 1 line

... which is unconventional and pretty confusing.

Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "drivers/mfd"?

You have to make that decision yourself. What I'm saying is, if the cover letter says there are 2 patches in the set, that's what we should expect.

Quoted 3 lines
Quoted 1 line

I fear you are sending these patches manually, using your mail client.

I admit that I am doing this usually.

Please don't do that.

Quoted 7 lines
Quoted 1 line

You should instead be creating patches with git format-patch

This happens also …

Quoted 1 line

and sending them using git send-email.

I prefer other software tools for this task so far.

Such as?

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#211 lore raw

Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()

In reply to Lee Jones
Quoted 8 lines
Quoted 1 line

Which topic would you prefer for my update suggestion instead?

This one.

"mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()"

The function name and just describing the changes as "refactoring" do not describe the changes in a helpful way.

Would you find a subject like "mfd: smsc-ece1099: Better exception handling in smsc_i2c_probe()" acceptable?

Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Do you really request that I should append this tag already to messages for (my adjusted) commits you can not see so far?

Yes.

Interesting …

Quoted 1 line

The code looks fine,

Thanks for a bit of positive feedback.

Quoted 1 line

and if the commit log is still not up to scratch I just won't apply it. :)

Can we eventually agree on an useful message before I would dare another commit?

Will it be sufficient to delete the asterisks there?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#217 lore raw

Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

In reply to Lee Jones
Quoted 5 lines
Quoted 3 lines

Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "drivers/mfd"?

You have to make that decision yourself.

I chose on 2015-12-29 to send them in the combination you see.

Quoted 1 line

What I'm saying is, if the cover letter says there are 2 patches

These refer to the component "smsc-ece1099".

Quoted 1 line

in the set, that's what we should expect.

Can changes for the components "dm355evm_msp" and "twl-core" be clarified independently?

Regards,
Markus

#199 lore raw

Re: mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to Lee Jones
Quoted 1 line

I'm sure you'll work it out. ;)

Do you want any changes for this suggestion around the software component "dm355evm_msp"?

Regards,
Markus

#201 lore raw

Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to SF Markus Elfring

The subject format is wrong and the summary itself isn't very informative.

Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 13:56:42 +0100

This patch format is wrong, please consider using git format-patch and git send-email.

Quoted 19 lines

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/mfd/dm355evm_msp.c +0 -0
index bc90efe..e4aa1b8 100644

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 203

Quoted 2 lines
drivers/mfd/dm355evm_msp.c +0 -0
@@ -202,7 +202,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	if (!pdev) {
 		dev_dbg(&client->dev, "can't alloc dev\n");

Make this dev_err().

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 205

Quoted 3 lines
drivers/mfd/dm355evm_msp.c +1 -1
 		status = -ENOMEM;
-		goto err;
+		goto report_failure;

Return here.

Quoted 21 lines
drivers/mfd/dm355evm_msp.c +2 -2
 	}
 
 	device_init_wakeup(&pdev->dev, can_wakeup);
@@ -212,7 +212,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -225,19 +225,18 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 233

Quoted 10 lines
drivers/mfd/dm355evm_msp.c +1 -8
 	status = platform_device_add(pdev);
-
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
-	return &pdev->dev;
+	if (!status)

Be more consistent here.

Reverse the condition and return an instead, as you do above.

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 238

Quoted 5 lines
drivers/mfd/dm355evm_msp.c +5 -0
+		return &pdev->dev;
+put_device:
+	platform_device_put(pdev);
+report_failure:
+	dev_err(&client->dev, "can't add %s dev\n", name);

This isn't a very friendly error message. Better to convert the dev_dbg() calls to dev_err() and tell the user what the problem was.

Quoted 4 lines
drivers/mfd/dm355evm_msp.c +1 -0
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#200 lore raw

Re: mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to SF Markus Elfring
Quoted 4 lines · SF Markus Elfring
Quoted 1 line

I'm sure you'll work it out. ;)

Do you want any changes for this suggestion around the software component "dm355evm_msp"?

There we go.

I have been more explicit as there was obviously some confusion.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#218 lore raw

Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 7 lines · SF Markus Elfring
Quoted 5 lines
Quoted 3 lines

Do you request that I should resend my four update suggestions for different components as a single patch series for the software area "drivers/mfd"?

You have to make that decision yourself.

I chose on 2015-12-29 to send them in the combination you see.

That was not a good choice.

Quoted 3 lines
Quoted 1 line

What I'm saying is, if the cover letter says there are 2 patches

These refer to the component "smsc-ece1099".

That's fine. Then there should have been 2 patches in the set. But then to attach 2 unrelated patches to the set is not fine. They should have either been submitted as part of the set i.e. 0/4 or completely separately.

Quoted 4 lines
Quoted 1 line

in the set, that's what we should expect.

Can changes for the components "dm355evm_msp" and "twl-core" be clarified independently?

Yes, or together would have also been fine. The only think that is not okay is to submit a set of 2 patches, then to "bolt-on" another 2 for some reason.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#202 lore raw

Re: mfd-dm355evm_msp: One function call less in add_child() after error detection

In reply to Lee Jones
Quoted 1 line

The subject format is wrong

Which format do you expect?

Quoted 1 line

and the summary itself isn't very informative.

Which wording do you find more useful?

Quoted 4 lines
Quoted 2 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 13:56:42 +0100

This patch format is wrong,

You might find the use of additional fields in the message body unusual. I have got an other impression from the canonical patch format.

Quoted 1 line

please consider using git format-patch and git send-email.

Thanks for your suggestion.

Quoted 6 lines
Quoted 6 lines

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.

Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention.

I am going to integrate the source code changes that you requested a bit later.

Quoted 5 lines

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 238

Quoted 2 lines
drivers/mfd/dm355evm_msp.c +2 -0
+report_failure:
+	dev_err(&client->dev, "can't add %s dev\n", name);

This isn't a very friendly error message. Better to convert the dev_dbg() calls to dev_err() and tell the user what the problem was.

Which information display would be more appropriate here?

Regards,
Markus

#259 lore raw

Re: [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 20:28:46 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a call of the function "__mmc_set_signal_voltage" or "__mmc_switch" failed. Use the identifier "report_failure" instead of the label "err".

I understand the report, but this unfortunate not the proper solution.

Instead, the "if (err)" check should be entirely removed from the err label.

To do that, mmc_select_hs200() should pre validate whether 4 or 8 -bit bus is supported which then prevents starting to switch to hs200 unless really supported. Moreover it means mmc_select_bus_width() shall return 0 to indicate success instead of as now, returning a positive value or 0.

Kind regards
Uffe

Quoted 45 lines
---
 drivers/mmc/core/mmc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/mmc/core/mmc.c +5 -5
index 549c56e..866f72b 100644
@@ -1256,7 +1256,7 @@ static int mmc_select_hs200(struct mmc_card *card)
 
        /* If fails try again during next card power cycle */
        if (err)
-               goto err;
+               goto report_failure;
 
        mmc_select_driver_type(card);
 
@@ -1276,7 +1276,7 @@ static int mmc_select_hs200(struct mmc_card *card)
                                   card->ext_csd.generic_cmd6_time,
                                   true, send_status, true);
                if (err)
-                       goto err;
+                       goto report_failure;
                old_timing = host->ios.timing;
                mmc_set_timing(host, MMC_TIMING_MMC_HS200);
                if (!send_status) {
@@ -1289,10 +1289,11 @@ static int mmc_select_hs200(struct mmc_card *card)
                                mmc_set_timing(host, old_timing);
                }
        }
-err:
-       if (err)
+       if (err) {
+report_failure:
                pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
                       __func__, err);
+       }
        return err;
 }
 
--

2.6.3

#330 lore raw

Re: [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()

In reply to Arend van Spriel
Quoted 6 lines · Arend van Spriel
Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 20:20:15 +0100

I think it has been said over and over, but please use driver name only as prefix. I don't see value to prepend it with 'net-'.

Yes, please use existing naming schemes. This time I can fix it before I commit the patch, but in the future please use correct prefixes. It's easy to check what has been used previously:

$ git log --oneline --no-merges --follow drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | head -10
63ce3d5db093 brcmfmac: use msecs_to_jiffies() in macro definitions
4011fc499690 brcmfmac: change brcmf_sdio_wd_timer() prototype
a7decc44a002 brcmfmac: fix waitqueue_active without memory barrier in brcmfmac driver
46d703a77539 brcmfmac: Unify methods to define and map firmware files.
64d66c30c37e brcmfmac: no retries on rxglom superframe errors
6866a64a0f9b brcmfmac: constify brcmf_bus_ops structures
05491d2ccf20 brcm80211: move under broadcom vendor directory
ff4445a8502c brcmfmac: expose device memory to devcoredump subsystem
a32be0177252 brcmfmac: include linux/atomic.h
9d6c1dc4f913 brcmfmac: add dedicated debug level for firmware console logging
$
Signature · 1 line
Kalle Valo
#141 lore raw

v3 cover InfiniBand-ocrdma: Fine-tuning for some function implementations

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 18:15:54 +0100

Several update suggestions were taken into account from static source code analysis.

Markus Elfring (6):
One variable and jump label less in ocrdma_alloc_ucontext_pd() Delete unnecessary variable initialisations in 11 functions Returning only value constants in ocrdma_qp_state_change() Return a value from a function call in _ocrdma_modify_qp() directly Returning only value constants in ocrdma_resize_cq() Delete an unnecessary variable in ocrdma_dealloc_pd()

---

v3: Rebase proposed changes on the source files for the software

    "Linux next-20160114".

v2: Unfortunately, the first update step from this series contained
an inappropriate suggestion.
Thus fix that.

 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  7 +++---
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 +--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 39 +++++++++++------------------
 4 files changed, 20 insertions(+), 32 deletions(-)
Signature · 1 line
2.6.3
#142 lore raw

PATCH v3 1/6 InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 17:17:44 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the _ocrdma_alloc_pd() function failed.

* Reduce the scope for the local variable "status" to one case of an if statement.

* Delete the jump label "err" then.

* Return zero as a constant at the end.

---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -6
index d4c687b..4caf167 100644
@@ -483,19 +483,16 @@ static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
 				    struct ocrdma_ucontext *uctx,
 				    struct ib_udata *udata)
 {
-	int status = 0;
-
 	uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
 	if (IS_ERR(uctx->cntxt_pd)) {
-		status = PTR_ERR(uctx->cntxt_pd);
+		int status = PTR_ERR(uctx->cntxt_pd);
 		uctx->cntxt_pd = NULL;
-		goto err;
+		return status;
 	}
 
 	uctx->cntxt_pd->uctx = uctx;
 	uctx->cntxt_pd->ibpd.device = &dev->ibdev;
-err:
-	return status;
+	return 0;
 }
 
 static int ocrdma_dealloc_ucontext_pd(struct ocrdma_ucontext *uctx)
Signature · 1 line
2.6.3
#143 lore raw

PATCH v3 2/6 InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 17:47:59 +0100

The variable "status" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 12 ++++++------
 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_ah.c +1 -1
index a343e03..41f0171 100644
@@ -59,7 +59,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
 			struct ib_ah_attr *attr, union ib_gid *sgid,
 			int pdid, bool *isvlan, u16 vlan_tag)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_eth_vlan eth;
 	struct ocrdma_grh grh;
 	int eth_sz;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2 -2
index 283ca84..159b1d5 100644
@@ -1113,7 +1113,7 @@ mbx_err:
 static int ocrdma_nonemb_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe,
 				 void *payload_va)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mbx_rsp *rsp = payload_va;
 
 	if ((mqe->hdr.spcl_sge_cnt_emb & OCRDMA_MQE_HDR_EMB_MASK) >>
@@ -2871,7 +2871,7 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
 static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
 				      struct ocrdma_dcbx_cfg *dcbxcfg)
 {
-	int status = 0;
+	int status;
 	dma_addr_t pa;
 	struct ocrdma_mqe cmd;
 
drivers/infiniband/hw/ocrdma/ocrdma_stats.c +2 -2
index 86c303a..119baa3 100644
@@ -608,7 +608,7 @@ static char *ocrdma_driver_dbg_stats(struct ocrdma_dev *dev)
 static void ocrdma_update_stats(struct ocrdma_dev *dev)
 {
 	ulong now = jiffies, secs;
-	int status = 0;
+	int status;
 	struct ocrdma_rdma_stats_resp *rdma_stats  		      (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
 	struct ocrdma_rsrc_stats *rsrc_stats = &rdma_stats->act_rsrc_stats;
@@ -639,7 +639,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 {
 	char tmp_str[32];
 	long reset;
-	int status = 0;
+	int status;
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
 
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +6 -6
index 4caf167..1d90d18 100644
@@ -419,7 +419,7 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
 					  struct ib_udata *udata)
 {
 	struct ocrdma_pd *pd = NULL;
-	int status = 0;
+	int status;
 
 	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -468,7 +468,7 @@ static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
 static int _ocrdma_dealloc_pd(struct ocrdma_dev *dev,
 			      struct ocrdma_pd *pd)
 {
-	int status = 0;
+	int status;
 
 	if (dev->pd_mgr->pd_prealloc_valid)
 		status = ocrdma_put_pd_num(dev, pd->id, pd->dpp_enabled);
@@ -593,7 +593,7 @@ map_err:
 
 int ocrdma_dealloc_ucontext(struct ib_ucontext *ibctx)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mm *mm, *tmp;
 	struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibctx->device);
@@ -620,7 +620,7 @@ int ocrdma_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
 	unsigned long vm_page = vma->vm_pgoff << PAGE_SHIFT;
 	u64 unmapped_db = (u64) dev->nic_info.unmapped_db;
 	unsigned long len = (vma->vm_end - vma->vm_start);
-	int status = 0;
+	int status;
 	bool found;
 
 	if (vma->vm_start & (PAGE_SIZE - 1))
@@ -1283,7 +1283,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
 				struct ib_udata *udata, int dpp_offset,
 				int dpp_credit_lmt, int srq)
 {
-	int status = 0;
+	int status;
 	u64 usr_db;
 	struct ocrdma_create_qp_uresp uresp;
 	struct ocrdma_pd *pd = qp->pd;
@@ -1947,7 +1947,7 @@ int ocrdma_modify_srq(struct ib_srq *ibsrq,
 		      enum ib_srq_attr_mask srq_attr_mask,
 		      struct ib_udata *udata)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_srq *srq;
 
 	srq = get_ocrdma_srq(ibsrq);
Signature · 1 line
2.6.3
#157 lore raw

PATCH v3 3/6 InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 17:54:45 +0100

Return zero at the end without using the local variable "status".

---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 -2
index 159b1d5..3766927 100644
@@ -2138,7 +2138,6 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 			   enum ib_qp_state *old_ib_state)
 {
 	unsigned long flags;
-	int status = 0;
 	enum ocrdma_qp_state new_state;
 	new_state = get_ocrdma_qp_state(new_ib_state);
 
@@ -2163,7 +2162,7 @@ int ocrdma_qp_state_change(struct ocrdma_qp *qp, enum ib_qp_state new_ib_state,
 	qp->state = new_state;
 
 	spin_unlock_irqrestore(&qp->q_lock, flags);
-	return status;
+	return 0;
 }
 
 static u32 ocrdma_set_create_qp_mbx_access_flags(struct ocrdma_qp *qp)
Signature · 1 line
2.6.3
#158 lore raw

PATCH v3 4/6 InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 18:00:23 +0100

Return the value from a call of the ocrdma_mbx_modify_qp() function without using an extra assignment for the local variable "status".

---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +1 -3
index 1d90d18..5f2a34a 100644
@@ -1492,9 +1492,7 @@ int _ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
 	 */
 	if (status < 0)
 		return status;
-	status = ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
-
-	return status;
+	return ocrdma_mbx_modify_qp(dev, qp, attr, attr_mask);
 }
 
 int ocrdma_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
Signature · 1 line
2.6.3
#159 lore raw

PATCH v3 5/6 InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 18:04:17 +0100

Return constant integer values without storing them in the local variable "status".

---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +3 -6
index 5f2a34a..d87985b 100644
@@ -1121,15 +1121,12 @@ ctx_err:
 int ocrdma_resize_cq(struct ib_cq *ibcq, int new_cnt,
 		     struct ib_udata *udata)
 {
-	int status = 0;
 	struct ocrdma_cq *cq = get_ocrdma_cq(ibcq);
 
-	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe) {
-		status = -EINVAL;
-		return status;
-	}
+	if (new_cnt < 1 || new_cnt > cq->max_hw_cqe)
+		return -EINVAL;
 	ibcq->cqe = new_cnt;
-	return status;
+	return 0;
 }
 
 static void ocrdma_flush_cq(struct ocrdma_cq *cq)
Signature · 1 line
2.6.3
#160 lore raw

PATCH v3 6/6 InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 18:08:08 +0100

1. Return zero in one case directly.

2. Return the value from a call of the _ocrdma_dealloc_pd() function without using an extra assignment for the local variable.

3. Remove the variable "status" in this function then.

---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +2 -4
index d87985b..e6e1b51 100644
@@ -751,7 +751,6 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 	struct ocrdma_pd *pd = get_ocrdma_pd(ibpd);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibpd->device);
 	struct ocrdma_ucontext *uctx = NULL;
-	int status = 0;
 	u64 usr_db;
 
 	uctx = pd->uctx;
@@ -765,11 +764,10 @@ int ocrdma_dealloc_pd(struct ib_pd *ibpd)
 
 		if (is_ucontext_pd(uctx, pd)) {
 			ocrdma_release_ucontext_pd(uctx);
-			return status;
+			return 0;
 		}
 	}
-	status = _ocrdma_dealloc_pd(dev, pd);
-	return status;
+	return _ocrdma_dealloc_pd(dev, pd);
 }
 
 static int ocrdma_alloc_lkey(struct ocrdma_dev *dev, struct ocrdma_mr *mr,
Signature · 1 line
2.6.3
#293 lore raw

v3 cover gianfar: Fine-tuning for gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 11:05:43 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Less function calls after error detection
Delete unnecessary variable initialisations
Extend an initialisation clause of a for loop

---

v3: Rebase proposed changes on the source files for the software

    "Linux next-20160114".

v2: Unfortunately, an inappropriate return code was selected in the first
update step from this series.
Thus fix that.

 drivers/net/ethernet/freescale/gianfar_ethtool.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
Signature · 1 line
2.6.3
#294 lore raw

PATCH v3 1/3 gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:30:37 +0100

The kfree() function was called in one case by the gfar_ethflow_to_filer_table() function during error handling even if a passed variable contained a null pointer.

* Return directly if a memory allocation failed at the beginning.

* Adjust jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +8 -6
index 4b0ee85..825b051 100644
@@ -778,11 +778,13 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 
 	local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
 				    GFP_KERNEL);
+	if (!local_rqfpr)
+		return 0;
 	local_rqfcr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
 				    GFP_KERNEL);
-	if (!local_rqfpr || !local_rqfcr) {
+	if (!local_rqfcr) {
 		ret = 0;
-		goto err;
+		goto free_fpr;
 	}
 
 	switch (class) {
@@ -802,7 +804,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 		netdev_err(priv->ndev,
 			   "Right now this class is not supported\n");
 		ret = 0;
-		goto err;
+		goto free_fcr;
 	}
 
 	for (i = 0; i < MAX_FILER_IDX + 1; i++) {
@@ -819,7 +821,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 		netdev_err(priv->ndev,
 			   "No parse rule found, can't create hash rules\n");
 		ret = 0;
-		goto err;
+		goto free_fcr;
 	}
 
 	/* If a match was found, then it begins the starting of a cluster rule
@@ -862,9 +864,9 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 			break;
 		priv->cur_filer_idx = priv->cur_filer_idx - 1;
 	}
-
-err:
+free_fcr:
 	kfree(local_rqfcr);
+free_fpr:
 	kfree(local_rqfpr);
 	return ret;
 }
Signature · 1 line
2.6.3
#300 lore raw

PATCH v3 2/3 gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:40:24 +0100

Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.

---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +3 -3
index 825b051..8302f7d 100644
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
 static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 				       u64 class)
 {
-	unsigned int last_rule_idx = priv->cur_filer_idx;
+	unsigned int last_rule_idx;
 	unsigned int cmp_rqfpr;
 	unsigned int *local_rqfpr;
 	unsigned int *local_rqfcr;
-	int i = 0x0, k = 0x0;
-	int j = MAX_FILER_IDX, l = 0x0;
+	int i, k, l;
+	int j = MAX_FILER_IDX;
 	int ret = 1;
 
 	local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
Signature · 1 line
2.6.3
#306 lore raw

PATCH v3 3/3 gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:50:34 +0100

Move the assignment for the variable "j" from the beginning into an initialisation clause of a for loop.

---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +2 -3
index 8302f7d..2162adc 100644
@@ -772,8 +772,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 	unsigned int cmp_rqfpr;
 	unsigned int *local_rqfpr;
 	unsigned int *local_rqfcr;
-	int i, k, l;
-	int j = MAX_FILER_IDX;
+	int i, j, k, l;
 	int ret = 1;
 
 	local_rqfpr = kmalloc_array(MAX_FILER_IDX + 1, sizeof(unsigned int),
@@ -807,7 +806,7 @@ static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 		goto free_fcr;
 	}
 
-	for (i = 0; i < MAX_FILER_IDX + 1; i++) {
+	for (i = 0, j = MAX_FILER_IDX; i < MAX_FILER_IDX + 1; i++) {
 		local_rqfpr[j] = priv->ftp_rqfpr[i];
 		local_rqfcr[j] = priv->ftp_rqfcr[i];
 		j--;
Signature · 1 line
2.6.3
#301 lore raw

Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring
Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 10:40:24 +0100

Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.

---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/freescale/gianfar_ethtool.c +0 -0
index 825b051..8302f7d 100644

drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771

Quoted 5 lines
drivers/net/ethernet/freescale/gianfar_ethtool.c +1 -1
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
 static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 				       u64 class)
 {
-	unsigned int last_rule_idx = priv->cur_filer_idx;
+	unsigned int last_rule_idx;

This is a write only variable. We can just remove it.

regards,
dan carpenter

maintainer
#295 lore raw

Re: [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

The kfree() function was called in one case by the gfar_ethflow_to_filer_table() function during error handling even if a passed variable contained a null pointer.

* Return directly if a memory allocation failed at the beginning.

* Adjust jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Is this really better?

Perhaps this particular static analysis isn't too useful.

Why not just allocate once and assign a second pointer?

	local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),
				    sizeof(unsigned int), GFP_KERNEL);
	if (!local_rqfpr)
		goto err;

	local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];

Perhaps this would be better removing the ret variable and using something like:

int gfar_ethflow_to_filer_table(...)

{
	...

	return 0;

err:

	kfree(local_rqfpt);
	return 1;
}

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#302 lore raw

Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to Dan Carpenter
Quoted 9 lines

drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771

Quoted 7 lines

+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c

drivers/net/ethernet/freescale/gianfar_ethtool.c +1 -1
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
 static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 				       u64 class)
 {
-	unsigned int last_rule_idx = priv->cur_filer_idx;
+	unsigned int last_rule_idx;

This is a write only variable. We can just remove it.

Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id·5ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850

Does this place indicate an unwanted value assignment as a leftover, or are there any other actions missing?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#296 lore raw

Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

In reply to Joe Perches
Quoted 9 lines
Quoted 5 lines

* Return directly if a memory allocation failed at the beginning.

* Adjust jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Is this really better?

Perhaps this particular static analysis isn't too useful.

The opinions are still evolving for such a kind of search pattern.

Quoted 8 lines

Why not just allocate once and assign a second pointer?

	local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),
				    sizeof(unsigned int), GFP_KERNEL);
	if (!local_rqfpr)
		goto err;

	local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];

Do you suggest to use only one array (instead of two as before) here?

Regards,
Markus

maintainer
#297 lore raw

Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

Quoted 16 lines · SF Markus Elfring
Quoted 10 lines
Quoted 6 lines

* Return directly if a memory allocation failed at the beginning.

* Adjust jump targets according to the Linux coding style convention.

This issue was detected by using the Coccinelle software.

Is this really better?

Perhaps this particular static analysis isn't too useful.

The opinions are still evolving for such a kind of search pattern.

Quoted 2 lines

Why not just allocate once and assign a second pointer?

Quoted 8 lines
Quoted 6 lines
	local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),
				    sizeof(unsigned int), GFP_KERNEL);
	if (!local_rqfpr)
		goto err;

	local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];

Do you suggest to use only one array (instead of two as before) here?

That's a possibility.

If, as your title suggests, you really want fewer function calls, (which as far as I saw, you didn't do) that could be a mechanism to remove both an allocation and a free.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#303 lore raw

Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring
Quoted 9 lines

drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771

Quoted 7 lines

+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c

drivers/net/ethernet/freescale/gianfar_ethtool.c +1 -1
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
 static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 				       u64 class)
 {
-	unsigned int last_rule_idx = priv->cur_filer_idx;
+	unsigned int last_rule_idx;

This is a write only variable. We can just remove it.

Quoted 2 lines

Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?

Yeah. That's a good idea. I will do that.

Quoted 4 lines

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id·5ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850

Does this place indicate an unwanted value assignment as a leftover, or are there any other actions missing?

I think it's just an extra variable and you can just delete it.

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#372 lore raw

v3 cover net-rsi: Fine-tuning for two function implementations

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:54:43 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() Delete unnecessary variable initialisations in rsi_send_data_pkt() Replace variable initialisations by assignments in rsi_send_data_pkt()

 drivers/net/wireless/rsi/rsi_91x_pkt.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

---

v3: Rebase proposed changes on the source files for the software

    "Linux next-20160114".

v2: Unfortunately, the first update step from this series contained
an inappropriate suggestion.
Thus fix that.

Signature · 1 line
2.6.3
#373 lore raw

PATCH v3 1/3 rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:30:39 +0100

Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.

---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
index 702593f..571eaba 100644
@@ -123,15 +123,15 @@ int rsi_send_mgmt_pkt(struct rsi_common *common,
 		      struct sk_buff *skb)
 {
 	struct rsi_hw *adapter = common->priv;
-	struct ieee80211_hdr *wh = NULL;
+	struct ieee80211_hdr *wh;
 	struct ieee80211_tx_info *info;
-	struct ieee80211_bss_conf *bss = NULL;
+	struct ieee80211_bss_conf *bss;
 	struct ieee80211_hw *hw = adapter->hw;
 	struct ieee80211_conf *conf = &hw->conf;
 	struct skb_info *tx_params;
 	int status = -E2BIG;
-	__le16 *msg = NULL;
-	u8 extnd_size = 0;
+	__le16 *msg;
+	u8 extnd_size;
 	u8 vap_id = 0;
 
 	info = IEEE80211_SKB_CB(skb);
Signature · 1 line
2.6.3
#374 lore raw

PATCH v3 2/3 rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt()

In reply to SF Markus Elfring

From 017d1bb49f46266ffeb33178ddd3022d6b341d71 Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:35:47 +0100
Subject: [PATCH 2/3] rsi: Delete unnecessary variable initialisations in
rsi_send_data_pkt()

Omit explicit initialisation at the beginning for four local variables which are redefined before their first use.

---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +4 -4
index 571eaba..4322df1 100644
@@ -27,15 +27,15 @@
 int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb)
 {
 	struct rsi_hw *adapter = common->priv;
-	struct ieee80211_hdr *tmp_hdr = NULL;
+	struct ieee80211_hdr *tmp_hdr;
 	struct ieee80211_tx_info *info;
 	struct skb_info *tx_params;
-	struct ieee80211_bss_conf *bss = NULL;
+	struct ieee80211_bss_conf *bss;
 	int status = -EINVAL;
 	u8 ieee80211_size = MIN_802_11_HDR_LEN;
-	u8 extnd_size = 0;
+	u8 extnd_size;
 	__le16 *frame_desc;
-	u16 seq_num = 0;
+	u16 seq_num;
 
 	info = IEEE80211_SKB_CB(skb);
 	bss = &info->control.vif->bss_conf;
Signature · 1 line
2.6.3
#375 lore raw

PATCH v3 3/3 rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 13:40:22 +0100

Replace explicit initialisation for two local variables at the beginning by assignments.

---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/wireless/rsi/rsi_91x_pkt.c +6 -4
index 4322df1..2c18c01 100644
@@ -26,12 +26,12 @@
  */
 int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb)
 {
-	struct rsi_hw *adapter = common->priv;
+	struct rsi_hw *adapter;
 	struct ieee80211_hdr *tmp_hdr;
 	struct ieee80211_tx_info *info;
 	struct skb_info *tx_params;
 	struct ieee80211_bss_conf *bss;
-	int status = -EINVAL;
+	int status;
 	u8 ieee80211_size = MIN_802_11_HDR_LEN;
 	u8 extnd_size;
 	__le16 *frame_desc;
@@ -41,8 +41,10 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb)
 	bss = &info->control.vif->bss_conf;
 	tx_params = (struct skb_info *)info->driver_data;
 
-	if (!bss->assoc)
+	if (!bss->assoc) {
+		status = -EINVAL;
 		goto err;
+	}
 
 	tmp_hdr = (struct ieee80211_hdr *)&skb->data[0];
 	seq_num = (le16_to_cpu(tmp_hdr->seq_ctrl) >> 4);
@@ -97,7 +99,7 @@ int rsi_send_data_pkt(struct rsi_common *common, struct sk_buff *skb)
 	frame_desc[7] = cpu_to_le16(((tx_params->tid & 0xf) << 4) |
 				    (skb->priority & 0xf) |
 				    (tx_params->sta_id << 8));
-
+	adapter = common->priv;
 	status = adapter->host_intf_write_pkt(common->priv,
 					      skb->data,
 					      skb->len);
Signature · 1 line
2.6.3
#144 lore raw

Re: [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 14 Jan 2016 17:47:59 +0100

The variable "status" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

What did you try to achieve by this patch?

Quoted 130 lines
---
 drivers/infiniband/hw/ocrdma/ocrdma_ah.c    |  2 +-
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c    |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_stats.c |  4 ++--
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 12 ++++++------
 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/infiniband/hw/ocrdma/ocrdma_ah.c +1 -1
index a343e03..41f0171 100644
@@ -59,7 +59,7 @@ static inline int set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,
 			struct ib_ah_attr *attr, union ib_gid *sgid,
 			int pdid, bool *isvlan, u16 vlan_tag)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_eth_vlan eth;
 	struct ocrdma_grh grh;
 	int eth_sz;
drivers/infiniband/hw/ocrdma/ocrdma_hw.c +2 -2
index 283ca84..159b1d5 100644
@@ -1113,7 +1113,7 @@ mbx_err:
 static int ocrdma_nonemb_mbx_cmd(struct ocrdma_dev *dev, struct ocrdma_mqe *mqe,
 				 void *payload_va)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mbx_rsp *rsp = payload_va;
 
 	if ((mqe->hdr.spcl_sge_cnt_emb & OCRDMA_MQE_HDR_EMB_MASK) >>
@@ -2871,7 +2871,7 @@ int ocrdma_mbx_destroy_srq(struct ocrdma_dev *dev, struct ocrdma_srq *srq)
 static int ocrdma_mbx_get_dcbx_config(struct ocrdma_dev *dev, u32 ptype,
 				      struct ocrdma_dcbx_cfg *dcbxcfg)
 {
-	int status = 0;
+	int status;
 	dma_addr_t pa;
 	struct ocrdma_mqe cmd;
 
drivers/infiniband/hw/ocrdma/ocrdma_stats.c +2 -2
index 86c303a..119baa3 100644
@@ -608,7 +608,7 @@ static char *ocrdma_driver_dbg_stats(struct ocrdma_dev *dev)
 static void ocrdma_update_stats(struct ocrdma_dev *dev)
 {
 	ulong now = jiffies, secs;
-	int status = 0;
+	int status;
 	struct ocrdma_rdma_stats_resp *rdma_stats >  		      (struct ocrdma_rdma_stats_resp *)dev->stats_mem.va;
 	struct ocrdma_rsrc_stats *rsrc_stats = &rdma_stats->act_rsrc_stats;
@@ -639,7 +639,7 @@ static ssize_t ocrdma_dbgfs_ops_write(struct file *filp,
 {
 	char tmp_str[32];
 	long reset;
-	int status = 0;
+	int status;
 	struct ocrdma_stats *pstats = filp->private_data;
 	struct ocrdma_dev *dev = pstats->dev;
 
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +6 -6
index 4caf167..1d90d18 100644
@@ -419,7 +419,7 @@ static struct ocrdma_pd *_ocrdma_alloc_pd(struct ocrdma_dev *dev,
 					  struct ib_udata *udata)
 {
 	struct ocrdma_pd *pd = NULL;
-	int status = 0;
+	int status;
 
 	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
 	if (!pd)
@@ -468,7 +468,7 @@ static inline int is_ucontext_pd(struct ocrdma_ucontext *uctx,
 static int _ocrdma_dealloc_pd(struct ocrdma_dev *dev,
 			      struct ocrdma_pd *pd)
 {
-	int status = 0;
+	int status;
 
 	if (dev->pd_mgr->pd_prealloc_valid)
 		status = ocrdma_put_pd_num(dev, pd->id, pd->dpp_enabled);
@@ -593,7 +593,7 @@ map_err:
 
 int ocrdma_dealloc_ucontext(struct ib_ucontext *ibctx)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_mm *mm, *tmp;
 	struct ocrdma_ucontext *uctx = get_ocrdma_ucontext(ibctx);
 	struct ocrdma_dev *dev = get_ocrdma_dev(ibctx->device);
@@ -620,7 +620,7 @@ int ocrdma_mmap(struct ib_ucontext *context, struct vm_area_struct *vma)
 	unsigned long vm_page = vma->vm_pgoff << PAGE_SHIFT;
 	u64 unmapped_db = (u64) dev->nic_info.unmapped_db;
 	unsigned long len = (vma->vm_end - vma->vm_start);
-	int status = 0;
+	int status;
 	bool found;
 
 	if (vma->vm_start & (PAGE_SIZE - 1))
@@ -1283,7 +1283,7 @@ static int ocrdma_copy_qp_uresp(struct ocrdma_qp *qp,
 				struct ib_udata *udata, int dpp_offset,
 				int dpp_credit_lmt, int srq)
 {
-	int status = 0;
+	int status;
 	u64 usr_db;
 	struct ocrdma_create_qp_uresp uresp;
 	struct ocrdma_pd *pd = qp->pd;
@@ -1947,7 +1947,7 @@ int ocrdma_modify_srq(struct ib_srq *ibsrq,
 		      enum ib_srq_attr_mask srq_attr_mask,
 		      struct ib_udata *udata)
 {
-	int status = 0;
+	int status;
 	struct ocrdma_srq *srq;
 
 	srq = get_ocrdma_srq(ibsrq);
Signature · 6 lines
2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#145 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 4 lines
Quoted 2 lines

The variable "status" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

What did you try to achieve by this patch?

I would like to optimise the affected source files a bit. Would you like to clarify any measurable effects around the implementation detail when various variables will only be initialised immediately before they will be read again?

Regards,
Markus

#146 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 9 lines · SF Markus Elfring
Quoted 4 lines
Quoted 2 lines

The variable "status" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

What did you try to achieve by this patch?

I would like to optimise the affected source files a bit. Would you like to clarify any measurable effects around the implementation detail when various variables will only be initialised immediately before they will be read again?

Compiler will drop this variable initialization by itself because there are no reads between this variable initialization and write.

I recommend you to take a look on the assembly code and ensure it by yourself.

The proposed change won't affect performance at all.

Quoted 3 lines

Regards,
Markus

#147 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 6 lines
Quoted 3 lines

Would you like to clarify any measurable effects around the implementation detail when various variables will only be initialised immediately before they will be read again?

Compiler will drop this variable initialization by itself because there are no reads between this variable initialization and write.

Which compiler variants would you to take into account for such an use case?

Quoted 2 lines

I recommend you to take a look on the assembly code and ensure it by yourself.

Will any configuration parameters and command arguments become relevant to improve also a corresponding software comparison?

Quoted 1 line

The proposed change won't affect performance at all.

Will unneeded variable assignments be really optimised away by default?

By the way:
Will a small source code reduction matter also a bit here?

Regards,
Markus

#148 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 8 lines · SF Markus Elfring
Quoted 6 lines
Quoted 3 lines

Would you like to clarify any measurable effects around the implementation detail when various variables will only be initialised immediately before they will be read again?

Compiler will drop this variable initialization by itself because there are no reads between this variable initialization and write.

Which compiler variants would you to take into account for such an use case?

GCC supported it before 1999 when I saw it first time. My assumption that in 2016 all compilers are doing such optimization now. I would be glad to hear an example of modern compiler which doesn't support this simple optimization.

Quoted 7 lines
Quoted 4 lines

I recommend you to take a look on the assembly code and ensure it by yourself.

Will any configuration parameters and command arguments become relevant to improve also a corresponding software comparison?

Please suggest us, you are proposing this change, and not me.

Quoted 5 lines
Quoted 3 lines

The proposed change won't affect performance at all.

Will unneeded variable assignments be really optimised away by default?

Yes

Quoted 4 lines

By the way:
Will a small source code reduction matter also a bit here?

If you are interested in saving space of one latter, you need to take into account git database increase, do you?

Quoted 3 lines

Regards,
Markus

#149 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Doing bogus initializations turns off GCC's checking for uninitialized variables so it's a bad habbit.

On the other hand, GCC's checking is not perfect and it sometimes misses bugs so these patches have to be reviewed manually which is maybe too much work to be worthwhile.

regards,
dan carpenter

#150 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to Leon Romanovsky
Quoted 2 lines

GCC supported it before 1999 when I saw it first time. My assumption that in 2016 all compilers are doing such optimization now.

Interesting …

Quoted 2 lines

I would be glad to hear an example of modern compiler which doesn't support this simple optimization.

Would you like to take into account any other source code analysis approaches?

Quoted 4 lines
Quoted 2 lines

Will any configuration parameters and command arguments become relevant to improve also a corresponding software comparison?

Please suggest us, you are proposing this change, and not me.

Which combination of hardware and software versions would you find representative for a corresponding system check?

Quoted 5 lines
Quoted 3 lines
Quoted 1 line

The proposed change won't affect performance at all.

Will unneeded variable assignments be really optimised away by default?

Yes

Can it be that this result will depend on special parameters so that data flow analysis and optimisation will be performed in the way you seem to expect?

Quoted 2 lines

If you are interested in saving space of one latter, you need to take into account git database increase, do you?

There are also other aspects to consider:

* Do you insist to initialise a return code at the beginning of every function with a non-void return type?

* Does each bit of extra information can result also in unwanted consequences?

* Is this a specific source code review concern?

* Can this software be improved a bit more only if we dare to talk about potential update candidates?

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#304 lore raw

Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to SF Markus Elfring

From: SF Markus Elfring <[email protected]>
Date: Fri, 15 Jan 2016 12:34:33 +0100

Quoted 10 lines
Quoted 9 lines

drivers/net/ethernet/freescale/gianfar_ethtool.c static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow) · line 771

Quoted 7 lines

+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c

drivers/net/ethernet/freescale/gianfar_ethtool.c +1 -1
@@ -768,12 +768,12 @@ static void ethflow_to_filer_rules (struct gfar_private *priv, u64 ethflow)
 static int gfar_ethflow_to_filer_table(struct gfar_private *priv, u64 ethflow,
 				       u64 class)
 {
-	unsigned int last_rule_idx = priv->cur_filer_idx;
+	unsigned int last_rule_idx;

This is a write only variable. We can just remove it.

Quoted 2 lines

Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?

No, but a human can.

And a human should fully analyze any change he writes based upon static analysis tool results.

I am going to be honest, and say that I am completely ignoring most of your static checker patches. You don't put enough care and consideration into them, and I really don't have time to waste on looking at something like that.

#151 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to SF Markus Elfring

On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:

Since, you didn't answer to my original question, I will repeat it again. [Q.] What did you try to achieve by this patch?

P.S. This is mailing list for developers and not for patch bots. We are glad to see patches that clean the code, but they need to be meaningful. Your automated patches add noise without any real benefit.

You was suggested to be ignored in MTD mailing list exactly for this type of patches, did you learn anything from that experience?

#305 lore raw

Re: gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()

In reply to David Miller
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

This is a write only variable. We can just remove it.

Can a static source code analysis tool like the software "http://smatch.sourceforge.net/" detect that such a variable is not read by this function implementation so far?

No,

I imagine that there are a few tools available which can point such update candidates out. There are various software development challenges to consider.

Quoted 1 line

but a human can.

Some software developers and source code reviewers are struggling with mentioned implementation details as usual. Do they also wonder how the discussed variable assignment was left over in a specific function?

Quoted 2 lines

I am going to be honest, and say that I am completely ignoring most of your static checker patches.

I am curious if you would reconsider the affected source code places once more when you will be notified about related issues by other tools or persons.

Quoted 1 line

You don't put enough care and consideration into them,

Would you like to explain this impression a bit more?

Quoted 1 line

and I really don't have time to waste on looking at something like that.

Thanks for your feedback.

Various open issues are competing for our attention as usual.

Regards,
Markus

#152 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to Leon Romanovsky
Quoted 4 lines · Leon Romanovsky

On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:

Since, you didn't answer to my original question, I will repeat it again. [Q.] What did you try to achieve by this patch?

Hello Leon,

Have you noticed Dan's reply: "Doing bogus initializations turns off GCC's checking for uninitialized variables so it's a bad habit."

Thanks,

Bart.

#298 lore raw

Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

In reply to Joe Perches
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
	local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),
				    sizeof(unsigned int), GFP_KERNEL);
	if (!local_rqfpr)
		goto err;

	local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];

Do you suggest to use only one array (instead of two as before) here?

That's a possibility.

Thanks for your clarification.

Quoted 1 line

If, as your title suggests, you really want fewer function calls,

I am unsure at the moment if more changes will make sense in this function implementation.

Quoted 1 line

(which as far as I saw, you didn't do)

Is my wording "after error detection" insufficient eventually?

Quoted 1 line

that could be a mechanism to remove both an allocation and a free.

Would any more software developers or source code reviewers like to share their opinions in such a direction?

Regards,
Markus

#153 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to Bart Van Assche
Quoted 10 lines · Bart Van Assche
Quoted 4 lines · Leon Romanovsky

On Fri, Jan 15, 2016 at 05:24:50PM +0100, SF Markus Elfring wrote:

Since, you didn't answer to my original question, I will repeat it again. [Q.] What did you try to achieve by this patch?

Hello Leon,

Have you noticed Dan's reply: "Doing bogus initializations turns off GCC's checking for uninitialized variables so it's a bad habit."

Yes and his second part of that message too, that uninitialized checks in GCC work as not as expected [1, 2].

Stackoverflow site has a lot examples of these types of bugs [3]. These examples together with Dan's suggestion requires from all reviewers to be extra cautions when removing variable initialization.

[1] https://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
[2] https://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20uninitialized
[3] http://stackoverflow.com/questions/27063678/compiler-not-detecting-obviously-uninitialized-variable

Quoted 8 lines

Thanks,

Bart.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#154 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

In reply to Leon Romanovsky
Quoted 1 line

[Q.] What did you try to achieve by this patch?

I would appreciate a bit more fine-tuning in the affected source files.

Quoted 1 line

P.S. This is mailing list for developers

Do you try to express any further restrictions?

Quoted 1 line

and not for patch bots.

Would you like to explain such an information a bit more?

Quoted 2 lines

We are glad to see patches that clean the code, but they need to be meaningful.

This is usual.

Quoted 1 line

Your automated patches add noise without any real benefit.

Are you expecting a kind of special proof?

Quoted 2 lines

You was suggested to be ignored in MTD mailing list exactly for this type of patches,

Will the acceptance increase a bit for similar issues over time?

Quoted 1 line

did you learn anything from that experience?

Will another acknowledgement by Selvin Xavier influence any corresponding software improvements?

How do you think about to add any further constructive comments also for the other proposed update steps?

Regards,
Markus

#155 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 3 lines · SF Markus Elfring
Quoted 1 line

[Q.] What did you try to achieve by this patch?

I would appreciate a bit more fine-tuning in the affected source files.

Please provide the numbers BEFORE and AFTER your change which can support that your so called "fine-tuning" worked.

We are waiting to see it together with Tested-By tag to emphasize that your code was tested on real HW and passed minimal sanity checks.

NAK on this patch.

#156 lore raw

Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions

Quoted 2 lines

Please provide the numbers BEFORE and AFTER your change which can support that your so called "fine-tuning" worked.

For which combinations of hardware and software versions would you like to see corresponding results from detailed system checks and special benchmarks?

Quoted 2 lines

We are waiting to see it together with Tested-By tag to emphasize that your code was tested on real HW and passed minimal sanity checks.

Are any other contributors interested to collaborate for such a task?

Quoted 1 line

NAK on this patch.

Thanks for your feedback.

Does it mean that you reject (only) the proposed source code adjustments around the variable "status" in the shown function selection at the moment?

Would you like to clarify the other update steps from this patch series a bit more?

Regards,
Markus

maintainer
#299 lore raw

RE: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

In reply to SF Markus Elfring
Quoted 32 lines

-----Original Message-----
From: SF Markus Elfring [mailto:[email protected]]
Sent: Friday, January 15, 2016 7:33 PM
To: Joe Perches <[email protected]>; [email protected]
Cc: Claudiu Manoil <[email protected]>; LKML <linux- [email protected]>; [email protected]; Julia Lawall <[email protected]>
Subject: Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection

Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
	local_rqfpr = kmalloc_array(2 * (MAX_FILER_IDX + 1),
				    sizeof(unsigned int), GFP_KERNEL);
	if (!local_rqfpr)
		goto err;

	local_rqfcr = &local_rqfpr[MAX_FILER_IDX + 1];

Do you suggest to use only one array (instead of two as before) here?

That's a possibility.

Thanks for your clarification.

Quoted 1 line

If, as your title suggests, you really want fewer function calls,

I am unsure at the moment if more changes will make sense in this function implementation.

Quoted 1 line

(which as far as I saw, you didn't do)

Quoted 8 lines

Is my wording "after error detection" insufficient eventually?

Quoted 1 line

that could be a mechanism to remove both an allocation and a free.

Would any more software developers or source code reviewers like to share their opinions in such a direction?

Hi,
This kind of fixes are net-next stuff at best, no need to push them into the net tree right now.
So please wait with these submissions until net-next re-opens at least. Thanks.

#351 lore raw

Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()

In reply to Julia Lawall
Quoted 36 lines · Julia Lawall
Quoted 16 lines · SF Markus Elfring
Quoted 6 lines
Quoted 4 lines

Move the jump label directly before the desired log statement so that the variable "err" will not be checked once more after it was determined that a function call failed. Use the identifier "report_failure" instead of the label "err".

Why?

I suggest to reconsider the places with which such a jump label is connected.

Quoted 1 line

The code was smart enough

Which action should really be performed after a failure was detected and handled a bit already?

Quoted 8 lines

* Another condition check

* Just additional error logging

Quoted 1 line

and you're making it uglier that it needs to be.

I assume that a software development taste can evolve, can't it?

So far, you have gotten several down votes for this kind of change, and no enthusiasm.

Admittedly, this is a trivial case, because there are no local variables, but do you actually know the semantics in C of a jump into a block? And if you do know, do you think that this semantics is common knowledge? And do you really think that introducing poorly understandable code is really worth saving an if test of a single variable on a non-critical path?

Quoted 5 lines

Most of the kernel code is not performance critical at the level of a single if test. So the goal should be for the code to be easy to understand and robust to change. The code that is performance critical, you should probably not touch, ever. The people who wrote it knew what was important and what was not.

Very well said! Only optimise something you can measure.

I'm dropping this patch.

Signature · 1 line
Kalle Valo
#180 lore raw

Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions

In reply to SF Markus Elfring

Em Mon, 28 Dec 2015 15:38:54 +0100
SF Markus Elfring <[email protected]> escreveu:

Quoted 21 lines

From: Markus Elfring <[email protected]>
Date: Mon, 28 Dec 2015 15:10:30 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement so that the variable "ret" will not be checked once more after a function call.
Use the identifier "report_failure" instead of "err".

---
 drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
 1 file changed, 78 insertions(+), 76 deletions(-)
drivers/media/tuners/m88rs6000t.c +0 -0
index 504bfbc..7e59a9f 100644

drivers/media/tuners/m88rs6000t.c static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe) · line 47

Quoted 5 lines
drivers/media/tuners/m88rs6000t.c +1 -1
@@ -44,7 +44,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
 	/* select demod main mclk */
 	ret = regmap_read(dev->regmap, 0x15, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;

Why to be so verbose? Calling it as "err" is enough, and it means less code to type if we need to add another goto.

Regards,
Mauro

#186 lore raw

Re: [PATCH 2/2] [media] r820t: Better exception handling in generic_set_freq()

In reply to SF Markus Elfring

Em Mon, 28 Dec 2015 17:32:22 +0100
SF Markus Elfring <[email protected]> escreveu:

Quoted 22 lines

From: Markus Elfring <[email protected]>
Date: Mon, 28 Dec 2015 17:13:02 +0100

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement so that the variable "rc" will not be checked once more after a function call.
Use the identifier "report_failure" instead of "err".

The error logging is performed in a separate section at the end now.

---
 drivers/media/tuners/r820t.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/media/tuners/r820t.c +0 -0
index 6ab35e3..f71642e 100644

drivers/media/tuners/r820t.c static int generic_set_freq(struct dvb_frontend *fe, · line 1306

Quoted 5 lines
drivers/media/tuners/r820t.c +1 -1
@@ -1303,7 +1303,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
 
 	rc = r820t_set_tv_standard(priv, bw, type, std, delsys);
 	if (rc < 0)
-		goto err;
+		goto report_failure;

Same thing as my previous comment: just "err" please.

Same applies to other patches you sent with similar hunks.

Quoted 33 lines
drivers/media/tuners/r820t.c +6 -8
 	if ((type = V4L2_TUNER_ANALOG_TV) && (std = V4L2_STD_SECAM_LC))
 		lo_freq = freq - priv->int_freq;
@@ -1312,23 +1312,21 @@ static int generic_set_freq(struct dvb_frontend *fe,
 
 	rc = r820t_set_mux(priv, lo_freq);
 	if (rc < 0)
-		goto err;
+		goto report_failure;
 
 	rc = r820t_set_pll(priv, type, lo_freq);
 	if (rc < 0 || !priv->has_lock)
-		goto err;
+		goto report_failure;
 
 	rc = r820t_sysfreq_sel(priv, freq, type, std, delsys);
 	if (rc < 0)
-		goto err;
+		goto report_failure;
 
 	tuner_dbg("%s: PLL locked on frequency %d Hz, gain=%d\n",
 		  __func__, freq, r820t_read_gain(priv));
-
-err:
-
-	if (rc < 0)
-		tuner_dbg("%s: failed=%d\n", __func__, rc);
+	return 0;
+report_failure:
+	tuner_dbg("%s: failed=%d\n", __func__, rc);
 	return rc;
 }
 
#188 lore raw

Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()

In reply to SF Markus Elfring

Em Mon, 28 Dec 2015 20:20:27 +0100
SF Markus Elfring <[email protected]> escreveu:

Quoted 34 lines

From: Markus Elfring <[email protected]>
Date: Mon, 28 Dec 2015 20:10:30 +0100

This issue was detected by using the Coccinelle software.

Split the previous if statement at the end so that each final log statement will eventually be performed by a direct jump to these labels.
* report_failure
* report_success

A check repetition can be excluded for the variable "ret" at the end then.

Apply also two recommendations from the script "checkpatch.pl".

---
 drivers/media/tuners/xc5000.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/media/tuners/xc5000.c +1 -1
index e6e5e90..1360677 100644
@@ -1166,7 +1166,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
 
 		ret = xc5000_fwupload(fe, desired_fw, fw);
 		if (ret != 0)
-			goto err;
+			goto report_failure;
 
 		msleep(20);
 

drivers/media/tuners/xc5000.c static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) · line 1233

Quoted 6 lines
drivers/media/tuners/xc5000.c +1 -1
@@ -1229,18 +1229,16 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
 		/* Default to "CABLE" mode */
 		ret = xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE);
 		if (!ret)
-			break;
+			goto report_success;
 		printk(KERN_ERR "xc5000: can't set to cable mode.");

It sounds worth to avoid adding a goto here.

Quoted 18 lines
drivers/media/tuners/xc5000.c +5 -7
 	}
 
-err:
-	if (!ret)
-		printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
-		       desired_fw->name);
-	else
-		printk(KERN_CONT " - too many retries. Giving up\n");
-
+report_failure:
+	pr_cont(" - too many retries. Giving up\n");
 	return ret;
+report_success:
+	pr_info("xc5000: Firmware %s loaded and running.\n", desired_fw->name);
+	return 0;
 }
 
 static void xc5000_do_timer_sleep(struct work_struct *timer_sleep)
#181 lore raw

Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions

In reply to Mauro Carvalho Chehab
Quoted 13 lines
Quoted 13 lines

This issue was detected by using the Coccinelle software.

Move the jump label directly before the desired log statement so that the variable "ret" will not be checked once more after a function call.
Use the identifier "report_failure" instead of "err".

---
 drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
 1 file changed, 78 insertions(+), 76 deletions(-)
Quoted 12 lines

drivers/media/tuners/m88rs6000t.c static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe) · line 47

Quoted 10 lines
drivers/media/tuners/m88rs6000t.c +1 -1
index 504bfbc..7e59a9f 100644
@@ -44,7 +44,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
 	/* select demod main mclk */
 	ret = regmap_read(dev->regmap, 0x15, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;

Why to be so verbose?

Does the document "CodingStyle" give an indication in the section "Chapter 7:
Centralized exiting of functions"?

Quoted 1 line

Calling it as "err" is enough,

It seems that some short identifiers are popular during software development.

Quoted 1 line

and it means less code to type if we need to add another goto.

Would you like to increase the usage of jump labels which will contain only a single character?

Regards,
Markus

#189 lore raw

Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()

In reply to Mauro Carvalho Chehab
Quoted 30 lines
Quoted 30 lines

This issue was detected by using the Coccinelle software.

Split the previous if statement at the end so that each final log statement will eventually be performed by a direct jump to these labels.
* report_failure
* report_success

A check repetition can be excluded for the variable "ret" at the end then.

Apply also two recommendations from the script "checkpatch.pl".

---
 drivers/media/tuners/xc5000.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/media/tuners/xc5000.c +1 -1
index e6e5e90..1360677 100644
@@ -1166,7 +1166,7 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
 
 		ret = xc5000_fwupload(fe, desired_fw, fw);
 		if (ret != 0)
-			goto err;
+			goto report_failure;
 
 		msleep(20);
 
Quoted 9 lines

drivers/media/tuners/xc5000.c static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) · line 1233

Quoted 7 lines
drivers/media/tuners/xc5000.c +1 -1
@@ -1229,18 +1229,16 @@ static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force)
 		/* Default to "CABLE" mode */
 		ret = xc_write_reg(priv, XREG_SIGNALSOURCE, XC_RF_MODE_CABLE);
 		if (!ret)
-			break;
+			goto report_success;
 		printk(KERN_ERR "xc5000: can't set to cable mode.");

It sounds worth to avoid adding a goto here.

Are you interested in a bit of software optimisation for the implementation of the function "xc_load_fw_and_init_tuner"?

Quoted 17 lines
Quoted 17 lines
drivers/media/tuners/xc5000.c +5 -7
 	}
 
-err:
-	if (!ret)
-		printk(KERN_INFO "xc5000: Firmware %s loaded and running.\n",
-		       desired_fw->name);
-	else
-		printk(KERN_CONT " - too many retries. Giving up\n");
-
+report_failure:
+	pr_cont(" - too many retries. Giving up\n");
 	return ret;
+report_success:
+	pr_info("xc5000: Firmware %s loaded and running.\n", desired_fw->name);
+	return 0;
 }
 
Quoted 1 line

drivers/media/tuners/xc5000.c static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe, int force) · line 1244

Quoted 1 line
drivers/media/tuners/xc5000.c +0 -0
 static void xc5000_do_timer_sleep(struct work_struct *timer_sleep)

Is the proposed source code restructuring interesting?

Regards,
Markus

#190 lore raw

Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()

Quoted 2 lines

Are you interested in a bit of software optimisation for the implementation of the function "xc_load_fw_and_init_tuner"?

To be clear, absolutely none of the code in question is performance sensitive (i.e. saving a couple of extra CPU cycles has no value in this case). Hence given that I'm assuming you have no intention to actually test any of these patches with a real device I would recommend you do the bare minimum to prevent Coccinelle from complaining and not restructure any of the core business logic unless you plan to also do actual testing.

Thanks,

Devin

Signature · 2 lines
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com
Applied
#265 lore raw

Re: [PATCH 0/2] mmc-host: Fine-tuning for one function

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:54:14 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Delete unnecessary variable initialisations in sdricoh_init_mmc() Less checks in sdricoh_init_mmc() after error detection

Quoted 6 lines
 drivers/mmc/host/sdricoh_cs.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

--
2.6.3

Thanks, applied for next - with some minor change to the prefix of the commit message header.

Kind regards
Uffe

maintainer Acked-by on v1 1/2
#262 lore raw

Re: [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc()

In reply to SF Markus Elfring

Hello,

Am Tue, 29 Dec 2015 22:00:35 +0100
schrieb SF Markus Elfring <[email protected]>:

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:11:45 +0100

These variables will eventually be set to an appropriate value a bit later.
* host
* iobase
* result

Quoted 3 lines

Thus let us omit the explicit initialisation at the beginning.

Best regards

Sascha

maintainer Acked-by on v1 2/2
#264 lore raw

Re: [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection

In reply to SF Markus Elfring

Hello,

Am Tue, 29 Dec 2015 22:02:37 +0100
schrieb SF Markus Elfring <[email protected]>:

Quoted 9 lines

From: Markus Elfring <[email protected]>
Date: Tue, 29 Dec 2015 21:45:34 +0100

This issue was detected by using the Coccinelle software.

Two pointer checks could be repeated by the sdricoh_init_mmc() function during error handling even if the relevant properties can be determined for the involved variables before by source code analysis.

Quoted 7 lines

* This implementation detail could be improved by adjustments for jump targets according to the Linux coding style convention.

* Drop an unnecessary initialisation for the variable "mmc" then.

---

Best regards

Sascha

Reviewed-by on v1 2/2
#324 lore raw

Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

In reply to SF Markus Elfring

Hi Kalle,

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100

Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.

This looks sane to me.

Thanks,

Julian Calaby

Quoted 36 lines
---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +2 -6
index a680a97..30bd59e 100644
@@ -246,7 +246,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
        struct ieee80211_conf *conf = &common->hw->conf;
        bool fastcc;
        struct ieee80211_channel *channel = hw->conf.chandef.chan;
-       struct ath9k_hw_cal_data *caldata = NULL;
+       struct ath9k_hw_cal_data *caldata;
        enum htc_phymode mode;
        __be16 htc_mode;
        u8 cmd_rsp;
@@ -274,10 +274,7 @@ static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
                priv->ah->curchan->channel,
                channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf),
                fastcc);
-
-       if (!fastcc)
-               caldata = &priv->caldata;
-
+       caldata = fastcc ? NULL : &priv->caldata;
        ret = ath9k_hw_reset(ah, hchan, caldata, fastcc);
        if (ret) {
                ath_err(common,
--

2.6.3

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 4 lines
Julian Calaby

Email: julian.calaby at gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
#325 lore raw

Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

Quoted 7 lines · Julian Calaby

Hi Kalle,

Quoted 3 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100

Quoted 8 lines
Quoted 4 lines

Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.

This looks sane to me.

Before I commit I'll just change the commit title to:

ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

Signature · 1 line
Kalle Valo
#326 lore raw

Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

Hi Kalle,

Quoted 14 lines · Kalle Valo
Quoted 12 lines · Julian Calaby

Hi Kalle,

Quoted 7 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100

Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.

Quoted 7 lines
Quoted 3 lines

This looks sane to me.

Before I commit I'll just change the commit title to:

ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

Sounds good to me.

Thanks,

Signature · 4 lines
Julian Calaby

Email: julian.calaby at gmail.com
Profile: http://www.google.com/profiles/julian.calaby/
Applied
#327 lore raw

Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

In reply to Julian Calaby
Quoted 5 lines · Julian Calaby
Quoted 3 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 1 Jan 2016 19:09:32 +0100

Quoted 8 lines
Quoted 4 lines

Replace an explicit initialisation for one local variable at the beginning by a conditional assignment.

This looks sane to me.

Applied, thanks.

Signature · 1 line
Kalle Valo
#221 lore raw

cover mfd: twl-core: Fine-tuning for add_numbered_child()

In reply to Lee Jones

From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:55:30 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Return directly after a failed platform_device_alloc() in add_numbered_child() Refactoring for add_numbered_child()

 drivers/mfd/twl-core.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
Signature · 1 line
2.8.2
#222 lore raw

PATCH 1/2 mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:20:28 +0200

The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.

* Change an error message.

* Return directly in this case.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/twl-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mfd/twl-core.c +4 -3
index 831696e..dc34e69 100644
@@ -623,9 +623,10 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 
 	pdev = platform_device_alloc(name, num);
 	if (!pdev) {
-		dev_dbg(&twl->client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
+		dev_err(&twl->client->dev,
+			"Allocation failed for device: %s\n",
+			name);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	pdev->dev.parent = &twl->client->dev;
Signature · 1 line
2.8.2
#228 lore raw

PATCH 2/2 mfd: twl-core: Refactoring for add_numbered_child()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:50:55 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/twl-core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/mfd/twl-core.c +9 -10
index dc34e69..3e4f4e4 100644
@@ -635,7 +635,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -648,21 +648,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irqs\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-	if (status = 0)
-		device_init_wakeup(&pdev->dev, can_wakeup);
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&twl->client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
+	device_init_wakeup(&pdev->dev, can_wakeup);
 	return &pdev->dev;
+put_device:
+	platform_device_put(pdev);
+	dev_err(&twl->client->dev, "can't add %s dev\n", name);
+	return ERR_PTR(status);
 }
 
 static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 1 line
2.8.2
#223 lore raw

Re: [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:20:28 +0200

The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.

* Change an error message.

Why? Is dev_err needed? Doesn't it already print out the device name?

In any case, the only source of failure is failure of a kzalloc in platform_device_alloc, which means that a complete backtrace would be generated, so it is not clear that any message is needed at all.

julia

Quoted 36 lines

* Return directly in this case.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/twl-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/mfd/twl-core.c +4 -3
index 831696e..dc34e69 100644
@@ -623,9 +623,10 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 
 	pdev = platform_device_alloc(name, num);
 	if (!pdev) {
-		dev_dbg(&twl->client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
+		dev_err(&twl->client->dev,
+			"Allocation failed for device: %s\n",
+			name);
+		return ERR_PTR(-ENOMEM);
 	}
 
 	pdev->dev.parent = &twl->client->dev;
Signature · 6 lines
2.8.2

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#224 lore raw

Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

Quoted 3 lines
Quoted 1 line

* Change an error message.

Why? Is dev_err needed?

I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104

Regards,
Markus

#225 lore raw

Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

Quoted 6 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

* Change an error message.

Why? Is dev_err needed?

I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104

OK. He didn't ask for the message to be changed though. It's a bit unfortunate that it now takes up multiple lines. And I believe it also prints redundant information. Perhaps he will have some further thoughts on the matter.

julia

#226 lore raw

Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

Quoted 6 lines · Julia Lawall
Quoted 4 lines · SF Markus Elfring
Quoted 3 lines
Quoted 1 line

* Change an error message.

Why? Is dev_err needed?

Quoted 7 lines
Quoted 2 lines

I interpreted Lee's response in this way.
https://lkml.org/lkml/2016/1/11/104

OK. He didn't ask for the message to be changed though. It's a bit unfortunate that it now takes up multiple lines. And I believe it also prints redundant information. Perhaps he will have some further thoughts on the matter.

Yes, Julia is right. We normally don't print anything for OOM errors since Linux reports on them already.

Please remove the print altogether.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#227 lore raw

Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

Quoted 1 line

Please remove the print altogether.

Would you like to omit any extra logging statements at more source code places?

Regards,
Markus

Acked-by on v1 2/2
#229 lore raw

Re: [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child()

In reply to SF Markus Elfring
Quoted 36 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 15 May 2016 19:50:55 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/twl-core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/mfd/twl-core.c +2 -4
index dc34e69..3e4f4e4 100644
@@ -635,7 +635,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -648,21 +648,20 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irqs\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-	if (status == 0)
-		device_init_wakeup(&pdev->dev, can_wakeup);

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 659

Quoted 10 lines
drivers/mfd/twl-core.c +3 -6
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&twl->client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
+	device_init_wakeup(&pdev->dev, can_wakeup);

Nit: Place a '\n' here.

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 660

Quoted 1 line
drivers/mfd/twl-core.c +0 -0
 	return &pdev->dev;

Nit: Place a '\n' here.

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 663

Quoted 3 lines
drivers/mfd/twl-core.c +3 -0
+put_device:
+	platform_device_put(pdev);
+	dev_err(&twl->client->dev, "can't add %s dev\n", name);

Nit: "failed to add device %s\n"

drivers/mfd/twl-core.c add_numbered_child(unsigned mod_no, const char *name, int num, · line 667

Quoted 4 lines
drivers/mfd/twl-core.c +1 -0
+	return ERR_PTR(status);
 }
 
 static inline struct device *add_child(unsigned mod_no, const char *name,

Once you've fixed those, please re-submit with my:

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#230 lore raw

cover mfd: Fine-tuning for three function implementations

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 15:25:43 +0200

Several update suggestions were taken into account from static source code analysis.

Markus Elfring (6):
twl-core: Return directly after a failed platform_device_alloc()
in add_numbered_child()
twl-core: Refactoring for add_numbered_child()
dm355evm_msp: Return directly after a failed platform_device_alloc()
in add_child()
dm355evm_msp: Refactoring for add_child()
smsc-ece1099: Delete an unnecessary variable initialisation

    in smsc_i2c_probe()
  smsc-ece1099: Return directly after a function failure
    in smsc_i2c_probe()
 drivers/mfd/dm355evm_msp.c | 25 ++++++++++++-------------
 drivers/mfd/smsc-ece1099.c | 11 ++++-------
 drivers/mfd/twl-core.c     | 28 +++++++++++++---------------
 3 files changed, 29 insertions(+), 35 deletions(-)
Signature · 1 line
2.9.0
#231 lore raw

PATCH 1/6 mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 12:25:36 +0200

The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/twl-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/twl-core.c +2 -5
index 831696e..9458c6d 100644
@@ -622,11 +622,8 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 	twl = &twl_priv->twl_modules[sid];
 
 	pdev = platform_device_alloc(name, num);
-	if (!pdev) {
-		dev_dbg(&twl->client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
-	}
+	if (!pdev)
+		return ERR_PTR(-ENOMEM);
 
 	pdev->dev.parent = &twl->client->dev;
 
Signature · 1 line
2.9.0
#233 lore raw

PATCH 2/6 mfd: twl-core: Refactoring for add_numbered_child()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:03:59 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/twl-core.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/mfd/twl-core.c +11 -10
index 9458c6d..a49d3db 100644
@@ -631,7 +631,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -644,21 +644,22 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irqs\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-	if (status = 0)
-		device_init_wakeup(&pdev->dev, can_wakeup);
+	if (status)
+		goto put_device;
+
+	device_init_wakeup(&pdev->dev, can_wakeup);
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&twl->client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&twl->client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 1 line
2.9.0
#235 lore raw

PATCH 3/6 mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:40:35 +0200

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/mfd/dm355evm_msp.c +2 -5
index 14661ec..270e19c 100644
@@ -199,11 +199,8 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	int			status;
 
 	pdev = platform_device_alloc(name, -1);
-	if (!pdev) {
-		dev_dbg(&client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
-	}
+	if (!pdev)
+		return ERR_PTR(-ENOMEM);
 
 	device_init_wakeup(&pdev->dev, can_wakeup);
 	pdev->dev.parent = &client->dev;
Signature · 1 line
2.9.0
#237 lore raw

PATCH 4/6 mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:56:58 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/dm355evm_msp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +10 -8
index 270e19c..baf6075 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
+	if (status)
+		goto put_device;
+
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 1 line
2.9.0
#253 lore raw

PATCH 5/6 mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:14:54 +0200

The variable "ret" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/mfd/smsc-ece1099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mfd/smsc-ece1099.c +1 -1
index 7f89e89..2aaf89f 100644
@@ -36,7 +36,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 {
 	struct smsc *smsc;
 	int devid, rev, venid_l, venid_h;
-	int ret = 0;
+	int ret;
 
 	smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc),
 				GFP_KERNEL);
Signature · 1 line
2.9.0
#255 lore raw

PATCH 6/6 mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:30:46 +0200

This issue was detected by using the Coccinelle software.

Return directly if a call of the function "devm_regmap_init_i2c" or "regmap_write" failed.

Delete the jump label "err" then.

---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/mfd/smsc-ece1099.c +3 -6
index 2aaf89f..cd18c09 100644
@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 	}
 
 	smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
-	if (IS_ERR(smsc->regmap)) {
-		ret = PTR_ERR(smsc->regmap);
-		goto err;
-	}
+	if (IS_ERR(smsc->regmap))
+		return PTR_ERR(smsc->regmap);
 
 	i2c_set_clientdata(i2c, smsc);
 	smsc->dev = &i2c->dev;
@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 
 	ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk);
 	if (ret)
-		goto err;
+		return ret;
 
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node)
@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 					   NULL, NULL, &i2c->dev);
 #endif
 
-err:
 	return ret;
 }
 
Signature · 1 line
2.9.0
#257 lore raw

Re: [PATCH 0/6] mfd: Fine-tuning for three function implementations

In reply to SF Markus Elfring
Quoted 14 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 15:25:43 +0200

Several update suggestions were taken into account from static source code analysis.

Markus Elfring (6):
twl-core: Return directly after a failed platform_device_alloc()
in add_numbered_child()
twl-core: Refactoring for add_numbered_child()
dm355evm_msp: Return directly after a failed platform_device_alloc()
in add_child()
dm355evm_msp: Refactoring for add_child()
smsc-ece1099: Delete an unnecessary variable initialisation

Quoted 8 lines
    in smsc_i2c_probe()
  smsc-ece1099: Return directly after a function failure
    in smsc_i2c_probe()
 drivers/mfd/dm355evm_msp.c | 25 ++++++++++++-------------
 drivers/mfd/smsc-ece1099.c | 11 ++++-------
 drivers/mfd/twl-core.c     | 28 +++++++++++++---------------
 3 files changed, 29 insertions(+), 35 deletions(-)

What is this set? A different but related one to the set you tagged it on to? Probably best not to do that. I now have a huge entangled thread in my inbox, which is going to become out of control rather quickly (if it isn't already).

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#232 lore raw

Re: [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()

In reply to SF Markus Elfring
Quoted 2 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 12:25:36 +0200

Please use git send-email when sending patches to the list.

Quoted 11 lines

The platform_device_put() function was called in one case by the add_numbered_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/twl-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Applied though, thanks.

Quoted 18 lines
drivers/mfd/twl-core.c +2 -5
index 831696e..9458c6d 100644
@@ -622,11 +622,8 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 	twl = &twl_priv->twl_modules[sid];
 
 	pdev = platform_device_alloc(name, num);
-	if (!pdev) {
-		dev_dbg(&twl->client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
-	}
+	if (!pdev)
+		return ERR_PTR(-ENOMEM);
 
 	pdev->dev.parent = &twl->client->dev;
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#234 lore raw

Re: [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child()

In reply to SF Markus Elfring
Quoted 11 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:03:59 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/twl-core.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

Applied, thanks.

Quoted 45 lines
drivers/mfd/twl-core.c +11 -10
index 9458c6d..a49d3db 100644
@@ -631,7 +631,7 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -644,21 +644,22 @@ add_numbered_child(unsigned mod_no, const char *name, int num,
 		status = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irqs\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
-	if (status == 0)
-		device_init_wakeup(&pdev->dev, can_wakeup);
+	if (status)
+		goto put_device;
+
+	device_init_wakeup(&pdev->dev, can_wakeup);
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&twl->client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&twl->client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static inline struct device *add_child(unsigned mod_no, const char *name,
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#236 lore raw

Re: [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:40:35 +0200

The platform_device_put() function was called in one case by the add_child() function during error handling even if the passed variable "pdev" contained a null pointer.
Return directly in this case.

Quoted 6 lines

This issue was detected by using the Coccinelle software.

---
 drivers/mfd/dm355evm_msp.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

Applied, thanks.

Quoted 18 lines
drivers/mfd/dm355evm_msp.c +2 -5
index 14661ec..270e19c 100644
@@ -199,11 +199,8 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 	int			status;
 
 	pdev = platform_device_alloc(name, -1);
-	if (!pdev) {
-		dev_dbg(&client->dev, "can't alloc dev\n");
-		status = -ENOMEM;
-		goto err;
-	}
+	if (!pdev)
+		return ERR_PTR(-ENOMEM);
 
 	device_init_wakeup(&pdev->dev, can_wakeup);
 	pdev->dev.parent = &client->dev;
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#238 lore raw

Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring
Quoted 25 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 13:56:58 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/dm355evm_msp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +1 -1
index 270e19c..baf6075 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230

Quoted 10 lines
drivers/mfd/dm355evm_msp.c +1 -1
@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
 

Remove this line too.

Quoted 18 lines
drivers/mfd/dm355evm_msp.c +8 -6
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
+	if (status)
+		goto put_device;
+
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#254 lore raw

Re: [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:14:54 +0200

The variable "ret" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/mfd/smsc-ece1099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

Quoted 13 lines
drivers/mfd/smsc-ece1099.c +1 -1
index 7f89e89..2aaf89f 100644
@@ -36,7 +36,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 {
 	struct smsc *smsc;
 	int devid, rev, venid_l, venid_h;
-	int ret = 0;
+	int ret;
 
 	smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc),
 				GFP_KERNEL);
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Applied
#256 lore raw

Re: [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()

In reply to SF Markus Elfring
Quoted 8 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 26 Jun 2016 14:30:46 +0200

This issue was detected by using the Coccinelle software.

Return directly if a call of the function "devm_regmap_init_i2c" or "regmap_write" failed.

Quoted 6 lines

Delete the jump label "err" then.

---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Applied, thanks.

Quoted 34 lines
drivers/mfd/smsc-ece1099.c +3 -6
index 2aaf89f..cd18c09 100644
@@ -46,10 +46,8 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 	}
 
 	smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
-	if (IS_ERR(smsc->regmap)) {
-		ret = PTR_ERR(smsc->regmap);
-		goto err;
-	}
+	if (IS_ERR(smsc->regmap))
+		return PTR_ERR(smsc->regmap);
 
 	i2c_set_clientdata(i2c, smsc);
 	smsc->dev = &i2c->dev;
@@ -68,7 +66,7 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 
 	ret = regmap_write(smsc->regmap, SMSC_CLK_CTRL, smsc->clk);
 	if (ret)
-		goto err;
+		return ret;
 
 #ifdef CONFIG_OF
 	if (i2c->dev.of_node)
@@ -76,7 +74,6 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
 					   NULL, NULL, &i2c->dev);
 #endif
 
-err:
 	return ret;
 }
 
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#239 lore raw

Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()

In reply to Lee Jones
Quoted 9 lines
Quoted 9 lines
drivers/mfd/dm355evm_msp.c +1 -1
@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
Quoted 4 lines

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230

Quoted 2 lines
drivers/mfd/dm355evm_msp.c +0 -0
 	status = platform_device_add(pdev);
 

Remove this line too.

Do you propose the deletion of a blank line here?

Did you skip this update suggestion while the other patches were finally accepted?

Regards,
Markus

#240 lore raw

Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()

Quoted 9 lines · SF Markus Elfring
Quoted 9 lines
Quoted 9 lines
drivers/mfd/dm355evm_msp.c +1 -1
@@ -222,19 +222,21 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
Quoted 6 lines
Quoted 4 lines

drivers/mfd/dm355evm_msp.c static struct device *add_child(struct i2c_client *client, const char *name, · line 230

Quoted 2 lines
drivers/mfd/dm355evm_msp.c +0 -0
 	status = platform_device_add(pdev);
 

Remove this line too.

Do you propose the deletion of a blank line here?

Yes.

Quoted 1 line

Did you skip this update suggestion while the other patches were finally accepted?

I don't know what this means.

The other patches in the set have been accepted. Please fix this one and send it again on its own.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#241 lore raw

PATCH 1/1 mfd: dm355evm_msp: Refactoring for add_child()

From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/mfd/dm355evm_msp.c +9 -8
index 270e19c..86eca61 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 1 line
2.9.0
maintainer
#242 lore raw

Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()

Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

Two headers in this email:

References: <[email protected]> <[email protected]> <20160111082922.GB14104@x1> <[email protected]> <[email protected]> <20160608111442.GB14888@dell> <[email protected]> <[email protected]> <20160628150725.GL24982@dell> <[email protected]> <20160628163146.GG29166@dell>
In-reply-to: <20160628163146.GG29166@dell>

Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?  Thanks.

Even better would be to use git send-email for these patches.

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#243 lore raw

Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()

Quoted 10 lines · Joe Perches
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

Two headers in this email:

Quoted 7 lines

References: <[email protected]> <[email protected]> <20160111082922.GB14104@x1> <[email protected]> <[email protected]> <20160608111442.GB14888@dell> <[email protected]> <[email protected]> <20160628150725.GL24982@dell> <[email protected]> <20160628163146.GG29166@dell>
In-reply-to: <20160628163146.GG29166@dell>

Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?  Thanks.

Even better would be to use git send-email for these patches.

Yes, I've mentioned this before.

I now have a gargantuan threaded mess consisting of 53 mails in my inbox. Please submit patches using git send-email, not forgetting to increase your submission each time you submit i.e [PATCH v2] and send them independently i.e. not attached to previous submissions.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
Acked-by on v1 1/1
#246 lore raw

Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 30 Jun 2016 21:54:51 +0200

Adjust jump targets according to the Linux coding style convention. Another check for the variable "status" can be omitted then at the end.

---
 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

FYI, code looks fine.

... but please take this opportunity to set-up your submission environment i.e. using git format-patch and git send-email. Once you've done that, please re-submit this patch with my:

Quoted 41 lines
drivers/mfd/dm355evm_msp.c +9 -8
index 270e19c..86eca61 100644
@@ -209,7 +209,7 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_data(pdev, pdata, pdata_len);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add platform_data\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
@@ -222,19 +222,20 @@ static struct device *add_child(struct i2c_client *client, const char *name,
 		status = platform_device_add_resources(pdev, &r, 1);
 		if (status < 0) {
 			dev_dbg(&pdev->dev, "can't add irq\n");
-			goto err;
+			goto put_device;
 		}
 	}
 
 	status = platform_device_add(pdev);
+	if (status)
+		goto put_device;
 
-err:
-	if (status < 0) {
-		platform_device_put(pdev);
-		dev_err(&client->dev, "can't add %s dev\n", name);
-		return ERR_PTR(status);
-	}
 	return &pdev->dev;
+
+put_device:
+	platform_device_put(pdev);
+	dev_err(&client->dev, "failed to add device %s\n", name);
+	return ERR_PTR(status);
 }
 
 static int add_children(struct i2c_client *client)
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#244 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

In reply to Joe Perches
Quoted 2 lines

Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?

I prefer to associate some patches with previous relevant discussion directly.

Quoted 1 line

Even better would be to use git send-email for these patches.

This command can also support a parameter like "--thread", can't it? Would you like point any more views out about communication styles?

Regards,
Markus

#247 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

In reply to Lee Jones
Quoted 1 line

FYI, code looks fine.

Thanks for your acknowledgement.

Quoted 2 lines

... but please take this opportunity to set-up your submission environment i.e. using git format-patch and git send-email.

Would you like to see any special settings to be mentioned in a section like "15) Explicit In-Reply-To headers" from the document "SubmittingPatches"?

Quoted 1 line

you've done that, please re-submit this patch with my:

Does the association of this patch with a bit relevant discussion really hinder the desired commit?

Regards,
Markus

maintainer
#245 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring
Quoted 3 lines

Can you please fix your email client to _not_ send References:
and In-reply-to: headers when sending new patches?

I prefer to associate some patches with previous relevant discussion directly.

Quoted 2 lines

Even better would be to use git send-email for these patches.

This command can also support a parameter like "--thread", can't it?

yes, good to see you can read documentation.

Quoted 1 line

Would you like point any more views out about communication styles?

Actually, yes.

Just because you've submitted a similar patch, an independent patch like this one, doesn't need to refer to those patches you've previously submitted.

For instance, your "References:" for this email
imply some association to a patch series you submitted "[PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table()" for no obvious reason.  What is this reason?

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#443 lore raw

cover Input-at32psif: Fine-tuning for OOM handling in psif_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Return directly after a failed kzalloc()
Remove two OOM messages

 drivers/input/serio/at32psif.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.9.0
#444 lore raw

PATCH 1/2 Input-at32psif: Return directly after a failed kzalloc() in psif_probe()

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 18:34:43 +0200

Return directly after a memory allocation failed at the beginning.

This issue was detected by using the Coccinelle software.

---
 drivers/input/serio/at32psif.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/serio/at32psif.c +1 -3
index 2e4ff5b..fcb769a 100644
@@ -212,8 +212,7 @@ static int __init psif_probe(struct platform_device *pdev)
 	psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
 	if (!psif) {
 		dev_dbg(&pdev->dev, "out of memory\n");
-		ret = -ENOMEM;
-		goto out;
+		return -ENOMEM;
 	}
 	psif->pdev = pdev;
 
@@ -297,7 +296,6 @@ out_free_io:
 	kfree(io);
 out_free_psif:
 	kfree(psif);
-out:
 	return ret;
 }
 
Signature · 1 line
2.9.0
#445 lore raw

PATCH 2/2 Input-at32psif: Remove OOM messages in psif_probe()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:34:18 +0200

Delete two debug messages because Linux will usually provide an appropriate information for a memory allocation failure.

---
 drivers/input/serio/at32psif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/serio/at32psif.c +2 -4
index fcb769a..b30503d 100644
@@ -210,15 +210,13 @@ static int __init psif_probe(struct platform_device *pdev)
 	int ret;
 
 	psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
-	if (!psif) {
-		dev_dbg(&pdev->dev, "out of memory\n");
+	if (!psif)
 		return -ENOMEM;
-	}
+
 	psif->pdev = pdev;
 
 	io = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (!io) {
-		dev_dbg(&pdev->dev, "out of memory\n");
 		ret = -ENOMEM;
 		goto out_free_psif;
 	}
Signature · 1 line
2.9.0
#446 lore raw

Re: [PATCH 2/2] Input-at32psif: Remove OOM messages in psif_probe()

Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:34:18 +0200

Delete two debug messages because Linux will usually provide an appropriate information for a memory allocation failure.

---
 drivers/input/serio/at32psif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/input/serio/at32psif.c +0 -0
index fcb769a..b30503d 100644

drivers/input/serio/at32psif.c static int __init psif_probe(struct platform_device *pdev) · line 215

Quoted 9 lines
drivers/input/serio/at32psif.c +2 -3
@@ -210,15 +210,13 @@ static int __init psif_probe(struct platform_device *pdev)
 	int ret;
 
 	psif = kzalloc(sizeof(struct psif), GFP_KERNEL);
-	if (!psif) {
-		dev_dbg(&pdev->dev, "out of memory\n");
+	if (!psif)
 		return -ENOMEM;
-	}
+

Why add a blank line here?

Quoted 12 lines
drivers/input/serio/at32psif.c +0 -1
 	psif->pdev = pdev;
 
 	io = kzalloc(sizeof(struct serio), GFP_KERNEL);
 	if (!io) {
-		dev_dbg(&pdev->dev, "out of memory\n");
 		ret = -ENOMEM;
 		goto out_free_psif;
 	}
Signature · 1 line
2.9.0
maintainer
#447 lore raw

Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200

A few update suggestions were taken into account
from static source code analysis.

Quoted 6 lines

Markus Elfring (2):
  Return directly after a failed kzalloc()
  Remove two OOM messages

 drivers/input/serio/at32psif.c | 10 +++-------

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

What possible rationale is there for including this "references" header? [email protected]

This message id is for your message:
"Source code review around jump label usage"
sent December 11, 2015!

Please stop adding unnecessary and useless email headers.
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#448 lore raw

Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()

Quoted 7 lines
Quoted 7 lines

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Return directly after a failed kzalloc()
Remove two OOM messages

Quoted 5 lines
Quoted 2 lines
 drivers/input/serio/at32psif.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

What possible rationale is there for including this "references" header? [email protected]

Do any more software developers dare to reconsider source code also around a jump label like "out"?

Quoted 3 lines

This message id is for your message:
"Source code review around jump label usage"
sent December 11, 2015!

Can such an association with a bit of background information be occasionally useful for clarification of corresponding implementation details?

Regards,
Markus

maintainer
#449 lore raw

Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()

In reply to SF Markus Elfring
Quoted 9 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 2 Jul 2016 20:50:09 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Return directly after a failed kzalloc()
Remove two OOM messages

I do not see a compelling reason for taking these...

Thanks.

Signature · 1 line
Dmitry
#69 lore raw

cover staging-Lustre: Fine-tuning for seven function implementations

In reply to Greg Kroah-Hartman

From: Markus Elfring <[email protected]>

Further update suggestions were taken into account after a patch was applied from static source code analysis.

Markus Elfring (12):
ldlm: Delete unnecessary checks before the function call "kset_unregister" Delete unnecessary checks before the function call "kobject_put" One function call less in class_register_type() after error detection Split a condition check in class_register_type()
Optimize error handling in class_register_type()
Return directly after a failed kcalloc() in mgc_process_recover_log() Less checks after a failed alloc_page() in mgc_process_recover_log() Less checks after a failed ptlrpc_request_alloc() inmgc_process_recover_log() Delete a check for the variable "req" in mgc_process_recover_log() Rename jump labels in mgc_process_recover_log()
Move an assignment for the variable "eof" in mgc_process_recover_log() Delete an unnecessary variable initialisation in mgc_process_recover_log()

 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 10 ++---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c     |  5 +--
 drivers/staging/lustre/lustre/lov/lov_obd.c     |  4 +-
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 50 ++++++++++++-------------
 drivers/staging/lustre/lustre/obdclass/genops.c | 41 ++++++++++++--------
 5 files changed, 54 insertions(+), 56 deletions(-)
Signature · 1 line
2.9.2
#70 lore raw

PATCH 1/12 staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister"

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 11:33:43 +0200

The kset_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +2 -4
index 821939f..2c1c2fc 100644
@@ -1067,10 +1067,8 @@ static int ldlm_cleanup(void)
 	if (ldlm_state->ldlm_cb_service)
 		ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
 
-	if (ldlm_ns_kset)
-		kset_unregister(ldlm_ns_kset);
-	if (ldlm_svc_kset)
-		kset_unregister(ldlm_svc_kset);
+	kset_unregister(ldlm_ns_kset);
+	kset_unregister(ldlm_svc_kset);
 	if (ldlm_kobj)
 		kobject_put(ldlm_kobj);
 
Signature · 1 line
2.9.2
#71 lore raw

PATCH 2/12 staging: lustre: Delete unnecessary checks before the function call "kobject_put"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 13:00:32 +0200

The kobject_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed.

This issue was detected by using the Coccinelle software.

---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 4 +---
 drivers/staging/lustre/lustre/lmv/lmv_obd.c     | 5 ++---
 drivers/staging/lustre/lustre/lov/lov_obd.c     | 4 +---
 drivers/staging/lustre/lustre/obdclass/genops.c | 6 ++----
 4 files changed, 6 insertions(+), 13 deletions(-)
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c +1 -3
index 2c1c2fc..52c5dd4 100644
@@ -1069,9 +1069,7 @@ static int ldlm_cleanup(void)
 
 	kset_unregister(ldlm_ns_kset);
 	kset_unregister(ldlm_svc_kset);
-	if (ldlm_kobj)
-		kobject_put(ldlm_kobj);
-
+	kobject_put(ldlm_kobj);
 	ldlm_debugfs_cleanup();
 
 	kfree(ldlm_state);
drivers/staging/lustre/lustre/lmv/lmv_obd.c +2 -3
index 0e1588a..8c2e5b3 100644
@@ -238,7 +238,7 @@ static int lmv_connect(const struct lu_env *env,
 	if (data && data->ocd_connect_flags & OBD_CONNECT_REAL)
 		rc = lmv_check_connect(obd);
 
-	if (rc && lmv->lmv_tgts_kobj)
+	if (rc)
 		kobject_put(lmv->lmv_tgts_kobj);
 
 	return rc;
@@ -648,8 +648,7 @@ static int lmv_disconnect(struct obd_export *exp)
 		lmv_disconnect_mdc(obd, lmv->tgts[i]);
 	}
 
-	if (lmv->lmv_tgts_kobj)
-		kobject_put(lmv->lmv_tgts_kobj);
+	kobject_put(lmv->lmv_tgts_kobj);
 
 out_local:
 	/*
drivers/staging/lustre/lustre/lov/lov_obd.c +1 -3
index 9b92d55..df701f7 100644
@@ -106,9 +106,7 @@ static void lov_putref(struct obd_device *obd)
 			__lov_del_obd(obd, tgt);
 		}
 
-		if (lov->lov_tgts_kobj)
-			kobject_put(lov->lov_tgts_kobj);
-
+		kobject_put(lov->lov_tgts_kobj);
 	} else {
 		mutex_unlock(&lov->lov_lock);
 	}
drivers/staging/lustre/lustre/obdclass/genops.c +2 -4
index 99c2da6..1b5aa9b 100644
@@ -203,8 +203,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	return 0;
 
  failed:
-	if (type->typ_kobj)
-		kobject_put(type->typ_kobj);
+	kobject_put(type->typ_kobj);
 	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
@@ -231,8 +230,7 @@ int class_unregister_type(const char *name)
 		return -EBUSY;
 	}
 
-	if (type->typ_kobj)
-		kobject_put(type->typ_kobj);
+	kobject_put(type->typ_kobj);
 
 	if (!IS_ERR_OR_NULL(type->typ_debugfs_entry))
 		ldebugfs_remove(&type->typ_debugfs_entry);
Signature · 1 line
2.9.2
#72 lore raw

PATCH 3/12 staging: lustre: One function call less in class_register_type() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 13:40:47 +0200

The kobject_put() function was called in a few cases by the class_register_type() function during error handling even if the passed data structure element did not contain a pointer for a valid data item.

Adjust jump targets according to the Linux coding style convention.

---
 drivers/staging/lustre/lustre/obdclass/genops.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +6 -6
index 1b5aa9b..10dd145 100644
@@ -164,7 +164,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	if (!type->typ_dt_ops ||
 	    !type->typ_md_ops ||
 	    !type->typ_name)
-		goto failed;
+		goto free_name;
 
 	*(type->typ_dt_ops) = *dt_ops;
 	/* md_ops is optional */
@@ -180,20 +180,20 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
 					     : -ENOMEM;
 		type->typ_debugfs_entry = NULL;
-		goto failed;
+		goto free_name;
 	}
 
 	type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
 	if (!type->typ_kobj) {
 		rc = -ENOMEM;
-		goto failed;
+		goto free_name;
 	}
 
 	if (ldt) {
 		type->typ_lu = ldt;
 		rc = lu_device_type_init(ldt);
 		if (rc != 0)
-			goto failed;
+			goto put_object;
 	}
 
 	spin_lock(&obd_types_lock);
@@ -201,9 +201,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	spin_unlock(&obd_types_lock);
 
 	return 0;
-
- failed:
+put_object:
 	kobject_put(type->typ_kobj);
+free_name:
 	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
Signature · 1 line
2.9.2
#79 lore raw

PATCH 4/12 staging: lustre: Split a condition check in class_register_type()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 14:10:55 +0200

The kfree() function was called in up to three cases by the class_register_type() function during error handling even if the passed data structure element contained a null pointer.

* Split a condition check for memory allocation failures.

* Improve this implementation detail by the introduction of a few jump labels.

---
 drivers/staging/lustre/lustre/obdclass/genops.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +17 -5
index 10dd145..fd5e61f 100644
@@ -158,13 +158,22 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		return rc;
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
+	if (!type->typ_dt_ops) {
+		rc = -ENOMEM;
+		goto free_type;
+	}
+
 	type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
-	type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
+	if (!type->typ_dt_ops) {
+		rc = -ENOMEM;
+		goto free_dt_ops;
+	}
 
-	if (!type->typ_dt_ops ||
-	    !type->typ_md_ops ||
-	    !type->typ_name)
-		goto free_name;
+	type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
+	if (!type->typ_name) {
+		rc = -ENOMEM;
+		goto free_md_ops;
+	}
 
 	*(type->typ_dt_ops) = *dt_ops;
 	/* md_ops is optional */
@@ -205,8 +214,11 @@ put_object:
 	kobject_put(type->typ_kobj);
 free_name:
 	kfree(type->typ_name);
+free_md_ops:
 	kfree(type->typ_md_ops);
+free_dt_ops:
 	kfree(type->typ_dt_ops);
+free_type:
 	kfree(type);
 	return rc;
 }
Signature · 1 line
2.9.2
#80 lore raw

PATCH 5/12 staging: lustre: Optimize error handling in class_register_type()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 14:23:23 +0200

Return a constant error code without storing it in the local variable "rc" after a failed memory allocation at the beginning of this function.

---
 drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +1 -2
index fd5e61f..4752091 100644
@@ -152,10 +152,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		return -EEXIST;
 	}
 
-	rc = -ENOMEM;
 	type = kzalloc(sizeof(*type), GFP_NOFS);
 	if (!type)
-		return rc;
+		return -ENOMEM;
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	if (!type->typ_dt_ops) {
Signature · 1 line
2.9.2
#84 lore raw

PATCH 6/12 staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 16:32:31 +0200

Return directly after a memory allocation failed at the beginning.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +2 -4
index 9d0bd47..d716bb2 100644
@@ -1339,10 +1339,8 @@ static int mgc_process_recover_log(struct obd_device *obd,
 		nrpages = CONFIG_READ_NRPAGES_INIT;
 
 	pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
-	if (!pages) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!pages)
+		return -ENOMEM;
 
 	for (i = 0; i < nrpages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
Signature · 1 line
2.9.2
#73 lore raw

Re: [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection

In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 13:40:47 +0200

The kobject_put() function was called in a few cases by the class_register_type() function during error handling even if the passed data structure element did not contain a pointer for a valid data item.

But kobject_put() already checks for NULL, right? you just submitted another batch about that in other area.

Quoted 1 line

Adjust jump targets according to the Linux coding style convention.

Not that I am totally against this patch, but when we do not need the extra checks, a single jump target is ok too in my mind (extra benefit - there's not going to be any chance of a mistake to where to jump to). And when we have a single jump target, there's no supersmart naming like free_this_and_that_and_that_other_thing_too.

Quoted 57 lines

---
drivers/staging/lustre/lustre/obdclass/genops.c | 12 ++++++------

1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +6 -6
index 1b5aa9b..10dd145 100644
@@ -164,7 +164,7 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	if (!type->typ_dt_ops ||
 	    !type->typ_md_ops ||
 	    !type->typ_name)
-		goto failed;
+		goto free_name;
 
 	*(type->typ_dt_ops) = *dt_ops;
 	/* md_ops is optional */
@@ -180,20 +180,20 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
 					     : -ENOMEM;
 		type->typ_debugfs_entry = NULL;
-		goto failed;
+		goto free_name;
 	}
 
 	type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
 	if (!type->typ_kobj) {
 		rc = -ENOMEM;
-		goto failed;
+		goto free_name;
 	}
 
 	if (ldt) {
 		type->typ_lu = ldt;
 		rc = lu_device_type_init(ldt);
 		if (rc != 0)
-			goto failed;
+			goto put_object;
 	}
 
 	spin_lock(&obd_types_lock);
@@ -201,9 +201,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 	spin_unlock(&obd_types_lock);
 
 	return 0;
-
- failed:
+put_object:
 	kobject_put(type->typ_kobj);
+free_name:
 	kfree(type->typ_name);
 	kfree(type->typ_md_ops);
 	kfree(type->typ_dt_ops);
Signature · 1 line
2.9.2
#85 lore raw

PATCH 7/12 staging: lustre: Less checks after a failed alloc_page() in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 17:12:51 +0200

Release memory directly after a page allocation failed at the beginning.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +7 -8
index d716bb2..b064bd3 100644
@@ -1346,7 +1346,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 		pages[i] = alloc_page(GFP_KERNEL);
 		if (!pages[i]) {
 			rc = -ENOMEM;
-			goto out;
+			goto free_pages;
 		}
 	}
 
@@ -1461,14 +1461,13 @@ out:
 	if (rc = 0 && !eof)
 		goto again;
 
-	if (pages) {
-		for (i = 0; i < nrpages; i++) {
-			if (!pages[i])
-				break;
-			__free_page(pages[i]);
-		}
-		kfree(pages);
+free_pages:
+	for (i = 0; i < nrpages; i++) {
+		if (!pages[i])
+			break;
+		__free_page(pages[i]);
 	}
+	kfree(pages);
 	return rc;
 }
 
Signature · 1 line
2.9.2
#86 lore raw

PATCH 8/12 staging: lustre: Less checks after a failed ptlrpc_request_alloc() in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 17:54:24 +0200

Release memory directly after a call of the function "ptlrpc_request_alloc" failed.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
index b064bd3..f65bb45 100644
@@ -1357,7 +1357,7 @@ again:
 				   &RQF_MGS_CONFIG_READ);
 	if (!req) {
 		rc = -ENOMEM;
-		goto out;
+		goto free_pages;
 	}
 
 	rc = ptlrpc_request_pack(req, LUSTRE_MGS_VERSION, MGS_CONFIG_READ);
Signature · 1 line
2.9.2
#87 lore raw

PATCH 9/12 staging: lustre: Delete a check for the variable "req" in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 17:56:49 +0200

Delete a check for the local variable "req" which became unnecessary with the previous update step.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -2
index f65bb45..2207af7 100644
@@ -1455,8 +1455,7 @@ again:
 	}
 
 out:
-	if (req)
-		ptlrpc_req_finished(req);
+	ptlrpc_req_finished(req);
 
 	if (rc = 0 && !eof)
 		goto again;
Signature · 1 line
2.9.2
#81 lore raw

Re: [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type()

In reply to SF Markus Elfring
Quoted 16 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 14:23:23 +0200

Return a constant error code without storing it in the local variable "rc" after a failed memory allocation at the beginning of this function.

---
drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +0 -0
index fd5e61f..4752091 100644

drivers/staging/lustre/lustre/obdclass/genops.c int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, · line 155

Quoted 4 lines
drivers/staging/lustre/lustre/obdclass/genops.c +0 -1
@@ -152,10 +152,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		return -EEXIST;
 	}
 
-	rc = -ENOMEM;

NAK.
when you do this, the next statement below breaks:

Quoted 7 lines
drivers/staging/lustre/lustre/obdclass/genops.c +1 -1
 	type = kzalloc(sizeof(*type), GFP_NOFS);
 	if (!type)
-		return rc;
+		return -ENOMEM;
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	if (!type->typ_dt_ops) {

…

                goto failed;

failed:
…
return rc;

So we are now returning an unitialized rc, did you get a gcc warning about it when compiling?-- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#88 lore raw

PATCH 10/12 staging: lustre: Rename jump labels in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 19:29:11 +0200

Adjust jump targets according to the Linux coding style convention.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +9 -10
index 2207af7..ff60b9b 100644
@@ -1362,7 +1362,7 @@ again:
 
 	rc = ptlrpc_request_pack(req, LUSTRE_MGS_VERSION, MGS_CONFIG_READ);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	/* pack request */
 	body = req_capsule_client_get(&req->rq_pill, &RMF_MGS_CONFIG_BODY);
@@ -1370,7 +1370,7 @@ again:
 	if (strlcpy(body->mcb_name, cld->cld_logname, sizeof(body->mcb_name))
 	    >= sizeof(body->mcb_name)) {
 		rc = -E2BIG;
-		goto out;
+		goto finish_request;
 	}
 	body->mcb_offset = cfg->cfg_last_idx + 1;
 	body->mcb_type   = cld->cld_type;
@@ -1382,7 +1382,7 @@ again:
 				    MGS_BULK_PORTAL);
 	if (!desc) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	for (i = 0; i < nrpages; i++)
@@ -1391,12 +1391,12 @@ again:
 	ptlrpc_request_set_replen(req);
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	res = req_capsule_server_get(&req->rq_pill, &RMF_MGS_CONFIG_RES);
 	if (res->mcr_size < res->mcr_offset) {
 		rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	/* always update the index even though it might have errors with
@@ -1411,18 +1411,18 @@ again:
 	ealen = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk, 0);
 	if (ealen < 0) {
 		rc = ealen;
-		goto out;
+		goto finish_request;
 	}
 
 	if (ealen > nrpages << PAGE_SHIFT) {
 		rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	if (ealen = 0) { /* no logs transferred */
 		if (!eof)
 			rc = -EINVAL;
-		goto out;
+		goto finish_request;
 	}
 
 	mne_swab = !!ptlrpc_rep_need_swab(req);
@@ -1453,8 +1453,7 @@ again:
 
 		ealen -= PAGE_SIZE;
 	}
-
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 
 	if (rc = 0 && !eof)
Signature · 1 line
2.9.2
#89 lore raw

PATCH 11/12 staging: lustre: Move an assignment for the variable "eof" in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 19:40:28 +0200

Move the assignment for the local variable "eof" behind the source code for memory allocations by this function.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +2 -1
index ff60b9b..8f5db79 100644
@@ -1322,7 +1322,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 	struct ptlrpc_bulk_desc *desc;
 	struct page **pages;
 	int nrpages;
-	bool eof = true;
+	bool eof;
 	bool mne_swab;
 	int i;
 	int ealen;
@@ -1350,6 +1350,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 		}
 	}
 
+	eof = true;
 again:
 	LASSERT(cld_is_recover(cld));
 	LASSERT(mutex_is_locked(&cld->cld_lock));
Signature · 1 line
2.9.2
#90 lore raw

PATCH 12/12 staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 19:50:40 +0200

The variable "req" will eventually be set to an appropriate pointer from a call of the ptlrpc_request_alloc() function.
Thus omit the explicit initialisation which became unnecessary with a previous update step.

---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/mgc/mgc_request.c +1 -1
index 8f5db79..6e8368e 100644
@@ -1315,7 +1315,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
 static int mgc_process_recover_log(struct obd_device *obd,
 				   struct config_llog_data *cld)
 {
-	struct ptlrpc_request *req = NULL;
+	struct ptlrpc_request *req;
 	struct config_llog_instance *cfg = &cld->cld_cfg;
 	struct mgs_config_body *body;
 	struct mgs_config_res  *res;
Signature · 1 line
2.9.2
#82 lore raw

Re: [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type()

In reply to Oleg Drokin
Quoted 22 lines · Oleg Drokin
Quoted 19 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Tue, 26 Jul 2016 14:23:23 +0200

Return a constant error code without storing it in the local variable "rc" after a failed memory allocation at the beginning of this function.

---
drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/lustre/lustre/obdclass/genops.c +0 -0
index fd5e61f..4752091 100644
@@ -152,10 +152,9 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
 		return -EEXIST;
 	}
 
Quoted 4 lines

drivers/staging/lustre/lustre/obdclass/genops.c int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops, · line 155

Quoted 1 line
drivers/staging/lustre/lustre/obdclass/genops.c +0 -1
-	rc = -ENOMEM;

NAK.
when you do this, the next statement below breaks:

Ah, I see there was patch 4 before patch 5 that actually placed rc assignments everywhere.

So I guess it is fine after all.

Sorry for the noise.

Quoted 15 lines
Quoted 8 lines
drivers/staging/lustre/lustre/obdclass/genops.c +1 -1
 	type = kzalloc(sizeof(*type), GFP_NOFS);
 	if (!type)
-		return rc;
+		return -ENOMEM;
 
 	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
 	if (!type->typ_dt_ops) {

…

               goto failed;

failed:
…
return rc;

Quoted 5 lines

So we are now returning an unitialized rc, did you get a gcc warning about it when compiling?
_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#74 lore raw

Re: staging: lustre: One function call less in class_register_type() after error detection

In reply to Oleg Drokin
Quoted 1 line

But kobject_put() already checks for NULL, right?

Yes. - Such an input parameter validation is performed by the function implementation.

Quoted 1 line

you just submitted another batch about that in other area.

I sent update suggestions because of this function property for two Linux software modules in the year 2015.

Quoted 3 lines
Quoted 1 line

Adjust jump targets according to the Linux coding style convention.

Not that I am totally against this patch,

Thanks for your feedback.

Quoted 1 line

but when we do not need the extra checks, a single jump target is ok too in my mind

A single goto label will look convenient for a while. It will often work for several use cases.

Quoted 1 line

(extra benefit - there's not going to be any chance of a mistake to where to jump to).

I have got an other opinion when you would like to care for a bit more software efficiency.

Quoted 2 lines

And when we have a single jump target, there's no supersmart naming like free_this_and_that_and_that_other_thing_too.

How often do you care for efficient exception handling in the shown function implementations?

Regards,
Markus

#83 lore raw

Re: staging: lustre: Optimize error handling in class_register_type()

In reply to Oleg Drokin
Quoted 2 lines

NAK.
when you do this, the next statement below breaks:

I wonder about this conclusion.

Quoted 8 lines
Quoted 7 lines
	type = kzalloc(sizeof(*type), GFP_NOFS);
	if (!type)
drivers/staging/lustre/lustre/obdclass/genops.c +1 -1
-		return rc;
+		return -ENOMEM;
	type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
	if (!type->typ_dt_ops) {

…

Quoted 7 lines
                goto failed;

failed:
…
return rc;

So we are now returning an unitialized rc, did you get a gcc warning about it when compiling?

I do not get such an impression if my corresponding update suggestion "[PATCH 04/12] staging: lustre: Split a condition check in class_register_type()" will be considered for this use case once more.
https://lkml.org/lkml/2016/7/26/462
https://www.mail-archive.com/[email protected]/msg1197227.html

Regards,
Markus

#75 lore raw

Re: staging: lustre: One function call less in class_register_type() after error detection

In reply to SF Markus Elfring
Quoted 31 lines · SF Markus Elfring
Quoted 1 line

But kobject_put() already checks for NULL, right?

Yes. - Such an input parameter validation is performed by the function implementation.

Quoted 1 line

you just submitted another batch about that in other area.

I sent update suggestions because of this function property for two Linux software modules in the year 2015.

Quoted 3 lines
Quoted 1 line

Adjust jump targets according to the Linux coding style convention.

Not that I am totally against this patch,

Thanks for your feedback.

Quoted 1 line

but when we do not need the extra checks, a single jump target is ok too in my mind

A single goto label will look convenient for a while. It will often work for several use cases.

Quoted 1 line

(extra benefit - there's not going to be any chance of a mistake to where to jump to).

I have got an other opinion when you would like to care for a bit more software efficiency.

Quoted 5 lines
Quoted 2 lines

And when we have a single jump target, there's no supersmart naming like free_this_and_that_and_that_other_thing_too.

How often do you care for efficient exception handling in the shown function implementations?

This function is called several times during lustre module insert. Namely it's called 5 times for 5 types:
osc, mdc, lov, lmv, mgc.

It's not called any more than that, so it's not exactly a super hot-path function to overoptimize it, and the failure is presumed to never happen too (or the module would be non-functional).

I guess you have already did all the work so I don't have any principal objections here, it's just like I said, in a non-super contended path, a single "fail" label is probably easier on the developer when they need to add another check there, as opposed to figuring and possibly adding a correct another label that would do something sensible.

Thank you for your contributions.

#76 lore raw

Re: staging: lustre: One function call less in class_register_type() after error detection

Quoted 3 lines

This function is called several times during lustre module insert. Namely it's called 5 times for 5 types:
osc, mdc, lov, lmv, mgc.

Will any extra memory accesses matter for the successful execution in this use case?

Quoted 3 lines

It's not called any more than that, so it's not exactly a super hot-path function to overoptimize it, and the failure is presumed to never happen too (or the module would be non-functional).

Did the assignment for the local variable "rc" with a well-known error code influence the run-time characteristics in unwanted ways?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/lustre/lustre/obdclass/genops.c?idj5b99a46bedc2cfbba96dec6d255c4b90af9ff8#n140

Regards,
Markus

#77 lore raw

Re: [lustre-devel] staging: lustre: One function call less in class_register_type() after error detection

Quoted 6 lines · SF Markus Elfring
Quoted 3 lines

This function is called several times during lustre module insert. Namely it's called 5 times for 5 types:
osc, mdc, lov, lmv, mgc.

Will any extra memory accesses matter for the successful execution in this use case?

I doubt it.

In typical deployments outside of testing environment, this function is called 5 times every system boot and never again.

Quoted 7 lines
Quoted 3 lines

It's not called any more than that, so it's not exactly a super hot-path function to overoptimize it, and the failure is presumed to never happen too (or the module would be non-functional).

Did the assignment for the local variable "rc" with a well-known error code influence the run-time characteristics in unwanted ways?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/lustre/lustre/obdclass/genops.c?idj5b99a46bedc2cfbba96dec6d255c4b90af9ff8#n140

I am not sure what do you mean here.

#78 lore raw

Re: [lustre-devel] staging: lustre: One function call less in class_register_type() after error detection

Quoted 2 lines

In typical deployments outside of testing environment, this function is called 5 times every system boot and never again.

Does this information mean that a bit more fine-tuning is insignificant at such a source code place?

Quoted 5 lines
Quoted 3 lines

Did the assignment for the local variable "rc" with a well-known error code influence the run-time characteristics in unwanted ways?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/staging/lustre/lustre/obdclass/genops.c?idj5b99a46bedc2cfbba96dec6d255c4b90af9ff8#n140

I am not sure what do you mean here.

I suggest to take another look at corresponding implementation details.

An error code is assigned to the variable "rc" before four memory allocations succeeded so far.
We hope that this function will usually return zero as a constant for the indication of a successful execution. I find that this variable should not be touched in the preferred case.
Will such an unnecessary assignment reduce the execution speed a bit for the desired file system initialisation?

Regards,
Markus

#248 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

In reply to SF Markus Elfring
Quoted 15 lines · SF Markus Elfring
Quoted 1 line

FYI, code looks fine.

Thanks for your acknowledgement.

Quoted 2 lines

... but please take this opportunity to set-up your submission environment i.e. using git format-patch and git send-email.

Would you like to see any special settings to be mentioned in a section like "15) Explicit In-Reply-To headers" from the document "SubmittingPatches"?

Quoted 4 lines
Quoted 1 line

you've done that, please re-submit this patch with my:

Does the association of this patch with a bit relevant discussion really hinder the desired commit?

I'm unsure if you're not re-submitting because you're waiting for an answer for me or not. If you are, here it is. And, don't do that. :)

Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.

Signature · 8 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#249 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

Quoted 2 lines

I'm unsure if you're not re-submitting because you're waiting for an answer for me or not.

I found your five commits (on 2016-06-29) for this patch series sufficient in principle.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?idÓ13cdde71ec9a5c327a515c37a0dca2cca00de5

Quoted 1 line

If you are, here it is. And, don't do that. :)

I find this feedback a bit strange.

Quoted 3 lines

Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.

I would find it nice if another one of my update suggestions could be integrated after a bit of feedback evolved for a special source code search pattern.

https://patchwork.kernel.org/patch/9199519/
https://patchwork.kernel.org/patch/9208925/
https://patchwork.kernel.org/patch/9210291/

It seems to be harder to achieve acceptance similar to the others.

Regards,
Markus
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#250 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

Quoted 21 lines · SF Markus Elfring
Quoted 2 lines

I'm unsure if you're not re-submitting because you're waiting for an answer for me or not.

I found your five commits (on 2016-06-29) for this patch series sufficient in principle.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=d313cdde71ec9a5c327a515c37a0dca2cca00de5

Quoted 1 line

If you are, here it is. And, don't do that. :)

I find this feedback a bit strange.

Quoted 3 lines

Please submit your patch-set *not* connected to this, now very tangled web of submissions, complete with all the Acks you've accrued.

I would find it nice if another one of my update suggestions could be integrated after a bit of feedback evolved for a special source code search pattern.

Quoted 5 lines

https://patchwork.kernel.org/patch/9199519/
https://patchwork.kernel.org/patch/9208925/
https://patchwork.kernel.org/patch/9210291/

It seems to be harder to achieve acceptance similar to the others.

I'm not entirely sure what you're trying to say.

Please rebase all of your unaccepted patches on v4.8-rc1. Apply any Acks that you've collected along the way and re-submit the set.

Please ensure, when you re-submit, you do so using git format-patch and git send-email. Also ensure you do not send them attached to any other patch that you've previously sent.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#251 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

Quoted 1 line

Please rebase all of your unaccepted patches on v4.8-rc1.

Thanks for your suggestion. - Would you like to add any comments to my remaining update suggestions for Linux modules (besides "dm355evm_msp")?

I would like to clarify still a few implementation details then.
https://patchwork.kernel.org/patch/9210291/

Quoted 2 lines

Also ensure you do not send them attached to any other patch that you've previously sent.

I imagine that another patch can evolve as a reply to a constructive software development discussion, can't it?

Regards,
Markus

#252 lore raw

Re: mfd: dm355evm_msp: Refactoring for add_child()

Quoted 10 lines · SF Markus Elfring
Quoted 1 line

Please rebase all of your unaccepted patches on v4.8-rc1.

Thanks for your suggestion. - Would you like to add any comments to my remaining update suggestions for Linux modules (besides "dm355evm_msp")?

I would like to clarify still a few implementation details then.
https://patchwork.kernel.org/patch/9210291/

Quoted 5 lines
Quoted 2 lines

Also ensure you do not send them attached to any other patch that you've previously sent.

I imagine that another patch can evolve as a reply to a constructive software development discussion, can't it?

Yes, just don't send it attached (threaded -- using reply-to).

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#450 lore raw

cover block-cciss: Fine-tuning for two function implementations

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 11:40:04 +0200

Some update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
Use memdup_user()
Less function calls after error detection
Delete unnecessary initialisations
Move an assignment for the variable "sg_used"
Replace three kzalloc() calls by kcalloc()

 drivers/block/cciss.c | 66 ++++++++++++++++++++++++---------------------------
 1 file changed, 31 insertions(+), 35 deletions(-)
Signature · 1 line
2.9.3
#451 lore raw

PATCH 1/5 block-cciss: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:10:29 +0200

* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

---
 drivers/block/cciss.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/block/cciss.c +3 -9
index db9d6bb..e044342 100644
@@ -1587,15 +1587,9 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 		return -EINVAL;
 	if (!capable(CAP_SYS_RAWIO))
 		return -EPERM;
-	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
-	if (!ioc) {
-		status = -ENOMEM;
-		goto cleanup1;
-	}
-	if (copy_from_user(ioc, argp, sizeof(*ioc))) {
-		status = -EFAULT;
-		goto cleanup1;
-	}
+	ioc = memdup_user(argp, sizeof(*ioc));
+	if (IS_ERR(ioc))
+		return PTR_ERR(ioc);
 	if ((ioc->buf_size < 1) &&
 	    (ioc->Request.Type.Direction != XFER_NONE)) {
 		status = -EINVAL;
Signature · 1 line
2.9.3
#452 lore raw

PATCH 2/5 block-cciss: Less function calls in cciss_bigpassthru() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:39:31 +0200

The kfree() function was called in a few cases by the cciss_bigpassthru() function during error handling even if a passed variable contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

---
 drivers/block/cciss.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)
drivers/block/cciss.c +20 -20
index e044342..43ac632 100644
@@ -1593,26 +1593,26 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 	if ((ioc->buf_size < 1) &&
 	    (ioc->Request.Type.Direction != XFER_NONE)) {
 		status = -EINVAL;
-		goto cleanup1;
+		goto free_ioc;
 	}
 	/* Check kmalloc limits  using all SGs */
 	if (ioc->malloc_size > MAX_KMALLOC_SIZE) {
 		status = -EINVAL;
-		goto cleanup1;
+		goto free_ioc;
 	}
 	if (ioc->buf_size > ioc->malloc_size * MAXSGENTRIES) {
 		status = -EINVAL;
-		goto cleanup1;
-	}
-	buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
-	if (!buff) {
-		status = -ENOMEM;
-		goto cleanup1;
+		goto free_ioc;
 	}
 	buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL);
 	if (!buff_size) {
 		status = -ENOMEM;
-		goto cleanup1;
+		goto free_ioc;
+	}
+	buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
+	if (!buff) {
+		status = -ENOMEM;
+		goto free_size;
 	}
 	left = ioc->buf_size;
 	data_ptr = ioc->buf;
@@ -1622,12 +1622,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 		buff[sg_used] = kmalloc(sz, GFP_KERNEL);
 		if (buff[sg_used] = NULL) {
 			status = -ENOMEM;
-			goto cleanup1;
+			goto free_buffer;
 		}
 		if (ioc->Request.Type.Direction = XFER_WRITE) {
 			if (copy_from_user(buff[sg_used], data_ptr, sz)) {
 				status = -EFAULT;
-				goto cleanup1;
+				goto free_buffer;
 			}
 		} else {
 			memset(buff[sg_used], 0, sz);
@@ -1639,7 +1639,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 	c = cmd_special_alloc(h);
 	if (!c) {
 		status = -ENOMEM;
-		goto cleanup1;
+		goto free_buffer;
 	}
 	c->cmd_type = CMD_IOCTL_PEND;
 	c->Header.ReplyQueue = 0;
@@ -1674,7 +1674,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 	if (copy_to_user(argp, ioc, sizeof(*ioc))) {
 		cmd_special_free(h, c);
 		status = -EFAULT;
-		goto cleanup1;
+		goto free_buffer;
 	}
 	if (ioc->Request.Type.Direction = XFER_READ) {
 		/* Copy the data out of the buffer we created */
@@ -1683,20 +1683,20 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 			if (copy_to_user(ptr, buff[i], buff_size[i])) {
 				cmd_special_free(h, c);
 				status = -EFAULT;
-				goto cleanup1;
+				goto free_buffer;
 			}
 			ptr += buff_size[i];
 		}
 	}
 	cmd_special_free(h, c);
 	status = 0;
-cleanup1:
-	if (buff) {
-		for (i = 0; i < sg_used; i++)
-			kfree(buff[i]);
-		kfree(buff);
-	}
+free_buffer:
+	for (i = 0; i < sg_used; i++)
+		kfree(buff[i]);
+	kfree(buff);
+free_size:
 	kfree(buff_size);
+free_ioc:
 	kfree(ioc);
 	return status;
 }
Signature · 1 line
2.9.3
#453 lore raw

PATCH 3/5 block-cciss: Delete unnecessary initialisations in cciss_bigpassthru()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 22:55:51 +0200

Three local variables will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning.

---
 drivers/block/cciss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/block/cciss.c +3 -3
index 43ac632..10e1b0a 100644
@@ -1572,11 +1572,11 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 {
 	BIG_IOCTL_Command_struct *ioc;
 	CommandList_struct *c;
-	unsigned char **buff = NULL;
-	int *buff_size = NULL;
+	unsigned char **buff;
+	int *buff_size;
 	u64bit temp64;
 	BYTE sg_used = 0;
-	int status = 0;
+	int status;
 	int i;
 	DECLARE_COMPLETION_ONSTACK(wait);
 	__u32 left;
Signature · 1 line
2.9.3
#454 lore raw

PATCH 4/5 block-cciss: Move an assignment for the variable "sg_used" in cciss_bigpassthru()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Wed, 17 Aug 2016 23:04:46 +0200

Move the assignment for the local variable "sg_used" behind the source code for some memory allocations by this function.

---
 drivers/block/cciss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/block/cciss.c +2 -1
index 10e1b0a..b08bfb7 100644
@@ -1575,7 +1575,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 	unsigned char **buff;
 	int *buff_size;
 	u64bit temp64;
-	BYTE sg_used = 0;
+	BYTE sg_used;
 	int status;
 	int i;
 	DECLARE_COMPLETION_ONSTACK(wait);
@@ -1616,6 +1616,7 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 	}
 	left = ioc->buf_size;
 	data_ptr = ioc->buf;
+	sg_used = 0;
 	while (left) {
 		sz = (left > ioc->malloc_size) ? ioc->malloc_size : left;
 		buff_size[sg_used] = sz;
Signature · 1 line
2.9.3
#455 lore raw

PATCH 5/5 block-cciss: Replace three kzalloc() calls by kcalloc()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 11:26:18 +0200

* The script "checkpatch.pl" can point information out like the following.

WARNING: Prefer kcalloc over kzalloc with multiply

Thus fix the affected source code places.

* Replace the specification of data structures by pointer dereferences to make the corresponding size determination a bit safer according to the Linux coding style convention.

---
 drivers/block/cciss.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/block/cciss.c +5 -4
index b08bfb7..3502a3a 100644
@@ -1604,12 +1604,12 @@ static int cciss_bigpassthru(ctlr_info_t *h, void __user *argp)
 		status = -EINVAL;
 		goto free_ioc;
 	}
-	buff_size = kmalloc(MAXSGENTRIES * sizeof(int), GFP_KERNEL);
+	buff_size = kcalloc(MAXSGENTRIES, sizeof(*buff_size), GFP_KERNEL);
 	if (!buff_size) {
 		status = -ENOMEM;
 		goto free_ioc;
 	}
-	buff = kzalloc(MAXSGENTRIES * sizeof(char *), GFP_KERNEL);
+	buff = kcalloc(MAXSGENTRIES, sizeof(*buff), GFP_KERNEL);
 	if (!buff) {
 		status = -ENOMEM;
 		goto free_size;
@@ -4838,8 +4838,9 @@ static int cciss_allocate_scatterlists(ctlr_info_t *h)
 	int i;
 
 	/* zero it, so that on free we need not know how many were alloc'ed */
-	h->scatter_list = kzalloc(h->max_commands *
-				sizeof(struct scatterlist *), GFP_KERNEL);
+	h->scatter_list = kcalloc(h->max_commands,
+				  sizeof(*h->scatter_list),
+				  GFP_KERNEL);
 	if (!h->scatter_list)
 		return -ENOMEM;
 
Signature · 1 line
2.9.3
#457 lore raw

cover GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:38:37 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use memdup_user() rather than duplicating its implementation Less function calls after error detection

 drivers/gpu/drm/savage/savage_state.c | 42 +++++++++++++++--------------------
 1 file changed, 18 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
#458 lore raw

PATCH 1/2 GPU-DRM-Savage: Use memdup_user() rather than duplicating

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 18:12:03 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/gpu/drm/savage/savage_state.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/gpu/drm/savage/savage_state.c +3 -9
index c01ad0a..3dc0d8f 100644
@@ -1001,15 +1001,9 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		cmdbuf->cmd_addr = kcmd_addr;
 	}
 	if (cmdbuf->vb_size) {
-		kvb_addr = kmalloc(cmdbuf->vb_size, GFP_KERNEL);
-		if (kvb_addr = NULL) {
-			ret = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(kvb_addr, cmdbuf->vb_addr,
-				       cmdbuf->vb_size)) {
-			ret = -EFAULT;
+		kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size);
+		if (IS_ERR(kvb_addr)) {
+			ret = PTR_ERR(kvb_addr);
 			goto done;
 		}
 		cmdbuf->vb_addr = kvb_addr;
Signature · 1 line
2.9.3
#459 lore raw

PATCH 2/2 GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:28:58 +0200

The kfree() function was called in a few cases by the savage_bci_cmdbuf() function during error handling even if a passed variable contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

---
 drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/savage/savage_state.c +15 -15
index 3dc0d8f..5b484aa 100644
@@ -1004,7 +1004,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size);
 		if (IS_ERR(kvb_addr)) {
 			ret = PTR_ERR(kvb_addr);
-			goto done;
+			goto free_cmd;
 		}
 		cmdbuf->vb_addr = kvb_addr;
 	}
@@ -1013,13 +1013,13 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  GFP_KERNEL);
 		if (kbox_addr = NULL) {
 			ret = -ENOMEM;
-			goto done;
+			goto free_vb;
 		}
 
 		if (copy_from_user(kbox_addr, cmdbuf->box_addr,
 				       cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
 			ret = -EFAULT;
-			goto done;
+			goto free_vb;
 		}
 	cmdbuf->box_addr = kbox_addr;
 	}
@@ -1052,7 +1052,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			/* fall through */
 		case SAVAGE_CMD_DMA_PRIM:
@@ -1071,7 +1071,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 				      cmdbuf->vb_stride,
 				      cmdbuf->nbox, cmdbuf->box_addr);
 				if (ret != 0)
-					goto done;
+					goto free_box;
 				first_draw_cmd = NULL;
 			}
 		}
@@ -1086,7 +1086,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			ret = savage_dispatch_state(dev_priv, &cmd_header,
 				(const uint32_t *)cmdbuf->cmd_addr);
@@ -1099,7 +1099,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			ret = savage_dispatch_clear(dev_priv, &cmd_header,
 						    cmdbuf->cmd_addr,
@@ -1117,12 +1117,12 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 				  cmd_header.cmd.cmd);
 			DMA_FLUSH();
 			ret = -EINVAL;
-			goto done;
+			goto free_box;
 		}
 
 		if (ret != 0) {
 			DMA_FLUSH();
-			goto done;
+			goto free_box;
 		}
 	}
 
@@ -1133,7 +1133,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 			cmdbuf->nbox, cmdbuf->box_addr);
 		if (ret != 0) {
 			DMA_FLUSH();
-			goto done;
+			goto free_box;
 		}
 	}
 
@@ -1147,11 +1147,11 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		savage_freelist_put(dev, dmabuf);
 	}
 
-done:
-	/* If we didn't need to allocate them, these'll be NULL */
-	kfree(kcmd_addr);
-	kfree(kvb_addr);
+free_box:
 	kfree(kbox_addr);
-
+free_vb:
+	kfree(kvb_addr);
+free_cmd:
+	kfree(kcmd_addr);
 	return ret;
 }
Signature · 1 line
2.9.3
#462 lore raw

Re: [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:38:37 +0200

A few update suggestions were taken into account
from static source code analysis.

savage is one of the dri1 legacy drivers, imo not really worth it to spend time on them. otoh no one will notice any breakage either ;-)

I guess I'll apply.
-Daniel

Quoted 11 lines

Markus Elfring (2):
Use memdup_user() rather than duplicating its implementation Less function calls after error detection

 drivers/gpu/drm/savage/savage_state.c | 42 +++++++++++++++--------------------
 1 file changed, 18 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#460 lore raw

Re: [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection

In reply to SF Markus Elfring
Quoted 10 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 18 Aug 2016 21:28:58 +0200

The kfree() function was called in a few cases by the savage_bci_cmdbuf() function during error handling even if a passed variable contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Not sure this is worth it, I'll pass. Patch 1 merged. Btw I consider cocci patches a good way to get started somewhere, but then it's much more useful to do a bit more involved things. We keep a list of small&big janitor tasks:

https://www.x.org/wiki/DRMJanitors/

Cleaning up all the cocci errors in drm isn't good since then the next person won't have something easy to get started, i.e. consider you're budget used up ;-)
-Daniel

Quoted 113 lines
---
 drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)
drivers/gpu/drm/savage/savage_state.c +15 -15
index 3dc0d8f..5b484aa 100644
@@ -1004,7 +1004,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size);
 		if (IS_ERR(kvb_addr)) {
 			ret = PTR_ERR(kvb_addr);
-			goto done;
+			goto free_cmd;
 		}
 		cmdbuf->vb_addr = kvb_addr;
 	}
@@ -1013,13 +1013,13 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  GFP_KERNEL);
 		if (kbox_addr = NULL) {
 			ret = -ENOMEM;
-			goto done;
+			goto free_vb;
 		}
 
 		if (copy_from_user(kbox_addr, cmdbuf->box_addr,
 				       cmdbuf->nbox * sizeof(struct drm_clip_rect))) {
 			ret = -EFAULT;
-			goto done;
+			goto free_vb;
 		}
 	cmdbuf->box_addr = kbox_addr;
 	}
@@ -1052,7 +1052,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			/* fall through */
 		case SAVAGE_CMD_DMA_PRIM:
@@ -1071,7 +1071,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 				      cmdbuf->vb_stride,
 				      cmdbuf->nbox, cmdbuf->box_addr);
 				if (ret != 0)
-					goto done;
+					goto free_box;
 				first_draw_cmd = NULL;
 			}
 		}
@@ -1086,7 +1086,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			ret = savage_dispatch_state(dev_priv, &cmd_header,
 				(const uint32_t *)cmdbuf->cmd_addr);
@@ -1099,7 +1099,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 					  "beyond end of command buffer\n");
 				DMA_FLUSH();
 				ret = -EINVAL;
-				goto done;
+				goto free_box;
 			}
 			ret = savage_dispatch_clear(dev_priv, &cmd_header,
 						    cmdbuf->cmd_addr,
@@ -1117,12 +1117,12 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 				  cmd_header.cmd.cmd);
 			DMA_FLUSH();
 			ret = -EINVAL;
-			goto done;
+			goto free_box;
 		}
 
 		if (ret != 0) {
 			DMA_FLUSH();
-			goto done;
+			goto free_box;
 		}
 	}
 
@@ -1133,7 +1133,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 			cmdbuf->nbox, cmdbuf->box_addr);
 		if (ret != 0) {
 			DMA_FLUSH();
-			goto done;
+			goto free_box;
 		}
 	}
 
@@ -1147,11 +1147,11 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_
 		savage_freelist_put(dev, dmabuf);
 	}
 
-done:
-	/* If we didn't need to allocate them, these'll be NULL */
-	kfree(kcmd_addr);
-	kfree(kvb_addr);
+free_box:
 	kfree(kbox_addr);
-
+free_vb:
+	kfree(kvb_addr);
+free_cmd:
+	kfree(kcmd_addr);
 	return ret;
 }
Signature · 1 line
2.9.3
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#463 lore raw

cover uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 11:11:01 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use memdup_user() rather than duplicating its implementation One function call less after error detection

 drivers/media/usb/uvc/uvc_v4l2.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)
Signature · 1 line
2.9.3
#464 lore raw

PATCH 1/2 uvc_v4l2: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 10:50:05 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/media/usb/uvc/uvc_v4l2.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +3 -8
index 05eed4b..a7e12fd 100644
@@ -70,14 +70,9 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
 		}
 
 		size = xmap->menu_count * sizeof(*map->menu_info);
-		map->menu_info = kmalloc(size, GFP_KERNEL);
-		if (map->menu_info = NULL) {
-			ret = -ENOMEM;
-			goto done;
-		}
-
-		if (copy_from_user(map->menu_info, xmap->menu_info, size)) {
-			ret = -EFAULT;
+		map->menu_info = memdup_user(xmap->menu_info, size);
+		if (IS_ERR(map->menu_info)) {
+			ret = PTR_ERR(map->menu_info);
 			goto done;
 		}
 
Signature · 1 line
2.9.3
#466 lore raw

PATCH 2/2 uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 11:00:38 +0200

The kfree() function was called in two cases by the uvc_ioctl_ctrl_map() function during error handling even if the passed data structure element contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

---
 drivers/media/usb/uvc/uvc_v4l2.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/media/usb/uvc/uvc_v4l2.c +4 -5
index a7e12fd..52a2af8 100644
@@ -66,14 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
 		if (xmap->menu_count = 0 ||
 		    xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) {
 			ret = -EINVAL;
-			goto done;
+			goto free_map;
 		}
 
 		size = xmap->menu_count * sizeof(*map->menu_info);
 		map->menu_info = memdup_user(xmap->menu_info, size);
 		if (IS_ERR(map->menu_info)) {
 			ret = PTR_ERR(map->menu_info);
-			goto done;
+			goto free_map;
 		}
 
 		map->menu_count = xmap->menu_count;
@@ -83,13 +83,12 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain,
 		uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type "
 			  "%u.\n", xmap->v4l2_type);
 		ret = -ENOTTY;
-		goto done;
+		goto free_map;
 	}
 
 	ret = uvc_ctrl_add_mapping(chain, map);
-
-done:
 	kfree(map->menu_info);
+free_map:
 	kfree(map);
 
 	return ret;
Signature · 1 line
2.9.3
#467 lore raw

cover misc/mic/vop: Fine-tuning for vop_ioctl()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 20:20:02 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use memdup_user()
Rename jump labels

 drivers/misc/mic/vop/vop_vringh.c | 43 ++++++++++++++++-----------------------
 1 file changed, 17 insertions(+), 26 deletions(-)
Signature · 1 line
2.9.3
#468 lore raw

PATCH 1/2 misc/mic/vop: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 19:48:45 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/misc/mic/vop/vop_vringh.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)
drivers/misc/mic/vop/vop_vringh.c +6 -15
index 88e4523..84c95fe 100644
@@ -938,13 +938,9 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 		    dd.num_vq > MIC_MAX_VRINGS)
 			return -EINVAL;
 
-		dd_config = kzalloc(mic_desc_size(&dd), GFP_KERNEL);
-		if (!dd_config)
-			return -ENOMEM;
-		if (copy_from_user(dd_config, argp, mic_desc_size(&dd))) {
-			ret = -EFAULT;
-			goto free_ret;
-		}
+		dd_config = memdup_user(argp, mic_desc_size(&dd));
+		if (IS_ERR(dd_config))
+			return PTR_ERR(dd_config);
 		/* Ensure desc has not changed between the two reads */
 		if (memcmp(&dd, dd_config, sizeof(dd))) {
 			ret = -EINVAL;
@@ -996,17 +992,12 @@ _unlock_ret:
 		ret = vop_vdev_inited(vdev);
 		if (ret)
 			goto __unlock_ret;
-		buf = kzalloc(vdev->dd->config_len, GFP_KERNEL);
-		if (!buf) {
-			ret = -ENOMEM;
+		buf = memdup_user(argp, vdev->dd->config_len);
+		if (IS_ERR(buf)) {
+			ret = PTR_ERR(buf);
 			goto __unlock_ret;
 		}
-		if (copy_from_user(buf, argp, vdev->dd->config_len)) {
-			ret = -EFAULT;
-			goto done;
-		}
 		ret = vop_virtio_config_change(vdev, buf);
-done:
 		kfree(buf);
 __unlock_ret:
 		mutex_unlock(&vdev->vdev_mutex);
Signature · 1 line
2.9.3
#469 lore raw

PATCH 2/2 misc/mic/vop: Rename jump labels in vop_ioctl()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 20:02:50 +0200

Adjust jump targets according to the Linux coding style convention.

---
 drivers/misc/mic/vop/vop_vringh.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/misc/mic/vop/vop_vringh.c +11 -11
index 84c95fe..201a662 100644
@@ -944,18 +944,18 @@ static long vop_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
 		/* Ensure desc has not changed between the two reads */
 		if (memcmp(&dd, dd_config, sizeof(dd))) {
 			ret = -EINVAL;
-			goto free_ret;
+			goto free_config;
 		}
 		mutex_lock(&vdev->vdev_mutex);
 		mutex_lock(&vi->vop_mutex);
 		ret = vop_virtio_add_device(vdev, dd_config);
 		if (ret)
-			goto unlock_ret;
+			goto unlock_device_addition;
 		list_add_tail(&vdev->list, &vi->vdev_list);
-unlock_ret:
+unlock_device_addition:
 		mutex_unlock(&vi->vop_mutex);
 		mutex_unlock(&vdev->vdev_mutex);
-free_ret:
+free_config:
 		kfree(dd_config);
 		return ret;
 	}
@@ -966,21 +966,21 @@ free_ret:
 		mutex_lock(&vdev->vdev_mutex);
 		ret = vop_vdev_inited(vdev);
 		if (ret)
-			goto _unlock_ret;
+			goto unlock_desc_copy;
 
 		if (copy_from_user(&copy, argp, sizeof(copy))) {
 			ret = -EFAULT;
-			goto _unlock_ret;
+			goto unlock_desc_copy;
 		}
 
 		ret = vop_virtio_copy_desc(vdev, &copy);
 		if (ret < 0)
-			goto _unlock_ret;
+			goto unlock_desc_copy;
 		if (copy_to_user(
 			&((struct mic_copy_desc __user *)argp)->out_len,
 			&copy.out_len, sizeof(copy.out_len)))
 			ret = -EFAULT;
-_unlock_ret:
+unlock_desc_copy:
 		mutex_unlock(&vdev->vdev_mutex);
 		return ret;
 	}
@@ -991,15 +991,15 @@ _unlock_ret:
 		mutex_lock(&vdev->vdev_mutex);
 		ret = vop_vdev_inited(vdev);
 		if (ret)
-			goto __unlock_ret;
+			goto unlock_config_change;
 		buf = memdup_user(argp, vdev->dd->config_len);
 		if (IS_ERR(buf)) {
 			ret = PTR_ERR(buf);
-			goto __unlock_ret;
+			goto unlock_config_change;
 		}
 		ret = vop_virtio_config_change(vdev, buf);
 		kfree(buf);
-__unlock_ret:
+unlock_config_change:
 		mutex_unlock(&vdev->vdev_mutex);
 		return ret;
 	}
Signature · 1 line
2.9.3
#470 lore raw

PATCH 1/1 VMCI: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 21:12:41 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/misc/vmw_vmci/vmci_host.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/misc/vmw_vmci/vmci_host.c +4 -15
index 9ec262a..0a20475 100644
@@ -759,27 +759,16 @@ static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev,
 	if (copy_from_user(&set_info, uptr, sizeof(set_info)))
 		return -EFAULT;
 
-	cpt_buf = kmalloc(set_info.buf_size, GFP_KERNEL);
-	if (!cpt_buf) {
-		vmci_ioctl_err(
-			"cannot allocate memory to set cpt state (type=%d)\n",
-			set_info.cpt_type);
-		return -ENOMEM;
-	}
-
-	if (copy_from_user(cpt_buf, (void __user *)(uintptr_t)set_info.cpt_buf,
-			   set_info.buf_size)) {
-		retval = -EFAULT;
-		goto out;
-	}
+	cpt_buf = memdup_user((void __user *)(uintptr_t)set_info.cpt_buf,
+			      set_info.buf_size);
+	if (IS_ERR(cpt_buf))
+		return PTR_ERR(cpt_buf);
 
 	cid = vmci_ctx_get_id(vmci_host_dev->context);
 	set_info.result = vmci_ctx_set_chkpt_state(cid, set_info.cpt_type,
 						   set_info.buf_size, cpt_buf);
 
 	retval = copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAULT : 0;
-
-out:
 	kfree(cpt_buf);
 	return retval;
 }
Signature · 1 line
2.9.3
#471 lore raw

cover mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 23:00:23 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use memdup_user()
Rename jump labels

 drivers/mmc/card/block.c | 34 +++++++++++++---------------------
 1 file changed, 13 insertions(+), 21 deletions(-)
Signature · 1 line
2.9.3
#472 lore raw

PATCH 1/2 mmc-block: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:46:38 +0200

* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

* Delete the integer variable "err" then because the pointer variable "idata" should be sufficient to handle return values alone in this function.

---
 drivers/mmc/card/block.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/mmc/card/block.c +9 -17
index 48a5dd7..6ce9492 100644
@@ -337,22 +337,21 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 	struct mmc_ioc_cmd __user *user)
 {
 	struct mmc_blk_ioc_data *idata;
-	int err;
 
 	idata = kmalloc(sizeof(*idata), GFP_KERNEL);
 	if (!idata) {
-		err = -ENOMEM;
+		idata = ERR_PTR(-ENOMEM);
 		goto out;
 	}
 
 	if (copy_from_user(&idata->ic, user, sizeof(idata->ic))) {
-		err = -EFAULT;
+		idata = ERR_PTR(-EFAULT);
 		goto idata_err;
 	}
 
 	idata->buf_bytes = (u64) idata->ic.blksz * idata->ic.blocks;
 	if (idata->buf_bytes > MMC_IOC_MAX_BYTES) {
-		err = -EOVERFLOW;
+		idata = ERR_PTR(-EOVERFLOW);
 		goto idata_err;
 	}
 
@@ -361,26 +360,19 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 		return idata;
 	}
 
-	idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
-	if (!idata->buf) {
-		err = -ENOMEM;
+	idata->buf = memdup_user((void __user *)(unsigned long)
+				 idata->ic.data_ptr,
+				 idata->buf_bytes);
+	if (IS_ERR(idata->buf)) {
+		idata = (void *) idata->buf;
 		goto idata_err;
 	}
-
-	if (copy_from_user(idata->buf, (void __user *)(unsigned long)
-					idata->ic.data_ptr, idata->buf_bytes)) {
-		err = -EFAULT;
-		goto copy_err;
-	}
-
 	return idata;
 
-copy_err:
-	kfree(idata->buf);
 idata_err:
 	kfree(idata);
 out:
-	return ERR_PTR(err);
+	return idata;
 }
 
 static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,
Signature · 1 line
2.9.3
#474 lore raw

PATCH 2/2 mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:52:50 +0200

Adjust jump targets according to the Linux coding style convention.

---
 drivers/mmc/card/block.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/mmc/card/block.c +4 -4
index 6ce9492..0d83c56 100644
@@ -346,13 +346,13 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 
 	if (copy_from_user(&idata->ic, user, sizeof(idata->ic))) {
 		idata = ERR_PTR(-EFAULT);
-		goto idata_err;
+		goto free_idata;
 	}
 
 	idata->buf_bytes = (u64) idata->ic.blksz * idata->ic.blocks;
 	if (idata->buf_bytes > MMC_IOC_MAX_BYTES) {
 		idata = ERR_PTR(-EOVERFLOW);
-		goto idata_err;
+		goto free_idata;
 	}
 
 	if (!idata->buf_bytes) {
@@ -365,11 +365,11 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 				 idata->buf_bytes);
 	if (IS_ERR(idata->buf)) {
 		idata = (void *) idata->buf;
-		goto idata_err;
+		goto free_idata;
 	}
 	return idata;
 
-idata_err:
+free_idata:
 	kfree(idata);
 out:
 	return idata;
Signature · 1 line
2.9.3
#475 lore raw

PATCH 1/1 mlx5/core: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 07:50:09 +0200

* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +3 -14
index 6388bc0..bb89f04 100644
@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	struct mlx5_core_dev *dev = filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	void *ptr;
-	int err;
 
 	if (*pos != 0)
 		return -EINVAL;
@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	kfree(dbg->in_msg);
 	dbg->in_msg = NULL;
 	dbg->inlen = 0;
-
-	ptr = kzalloc(count, GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	if (copy_from_user(ptr, buf, count)) {
-		err = -EFAULT;
-		goto out;
-	}
+	ptr = memdup_user(buf, count);
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
 	dbg->in_msg = ptr;
 	dbg->inlen = count;
 
 	*pos = count;
 
 	return count;
-
-out:
-	kfree(ptr);
-	return err;
 }
 
 static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
Signature · 1 line
2.9.3
#478 lore raw

cover tun: Fine-tuning for update_filter()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:16:16 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (2):
Use memdup_user()
Rename a jump label

 drivers/net/tun.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)
Signature · 1 line
2.9.3
#479 lore raw

PATCH 1/2 tun: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:54:15 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/net/tun.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/net/tun.c +3 -8
index 9c8b5bc..a1aeccb 100644
@@ -731,14 +731,9 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
 	}
 
 	alen = ETH_ALEN * uf.count;
-	addr = kmalloc(alen, GFP_KERNEL);
-	if (!addr)
-		return -ENOMEM;
-
-	if (copy_from_user(addr, arg + sizeof(uf), alen)) {
-		err = -EFAULT;
-		goto done;
-	}
+	addr = memdup_user(arg + sizeof(uf), alen);
+	if (IS_ERR(addr))
+		return PTR_ERR(addr);
 
 	/* The filter is updated without holding any locks. Which is
 	 * perfectly safe. We disable it first and in the worst
Signature · 1 line
2.9.3
#482 lore raw

PATCH 2/2 tun: Rename a jump label in update_filter()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 09:00:34 +0200

Adjust a jump target according to the Linux coding style convention.

---
 drivers/net/tun.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/net/tun.c +2 -3
index a1aeccb..e249428 100644
@@ -753,7 +753,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
 	for (; n < uf.count; n++) {
 		if (!is_multicast_ether_addr(addr[n].u)) {
 			err = 0; /* no filter */
-			goto done;
+			goto free_addr;
 		}
 		addr_hash_set(filter->mask, addr[n].u);
 	}
@@ -769,8 +769,7 @@ static int update_filter(struct tap_filter *filter, void __user *arg)
 
 	/* Return the number of exact filters */
 	err = nexact;
-
-done:
+free_addr:
 	kfree(addr);
 	return err;
 }
Signature · 1 line
2.9.3
#473 lore raw

Re: [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

Am 19.08.2016 23:10, schrieb SF Markus Elfring:

Quoted 68 lines

From: Markus Elfring <[email protected]>
Date: Fri, 19 Aug 2016 22:46:38 +0200

* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

* Delete the integer variable "err" then because the pointer variable "idata" should be sufficient to handle return values alone in this function.

---
 drivers/mmc/card/block.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)
drivers/mmc/card/block.c +8 -14
index 48a5dd7..6ce9492 100644
@@ -337,22 +337,21 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 	struct mmc_ioc_cmd __user *user)
 {
 	struct mmc_blk_ioc_data *idata;
-	int err;
 
 	idata = kmalloc(sizeof(*idata), GFP_KERNEL);
 	if (!idata) {
-		err = -ENOMEM;
+		idata = ERR_PTR(-ENOMEM);
 		goto out;
 	}
 
 	if (copy_from_user(&idata->ic, user, sizeof(idata->ic))) {
-		err = -EFAULT;
+		idata = ERR_PTR(-EFAULT);
 		goto idata_err;
 	}
 
 	idata->buf_bytes = (u64) idata->ic.blksz * idata->ic.blocks;
 	if (idata->buf_bytes > MMC_IOC_MAX_BYTES) {
-		err = -EOVERFLOW;
+		idata = ERR_PTR(-EOVERFLOW);
 		goto idata_err;
 	}
 
@@ -361,26 +360,19 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user(
 		return idata;
 	}
 
-	idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL);
-	if (!idata->buf) {
-		err = -ENOMEM;
+	idata->buf = memdup_user((void __user *)(unsigned long)
+				 idata->ic.data_ptr,
+				 idata->buf_bytes);
+	if (IS_ERR(idata->buf)) {
+		idata = (void *) idata->buf;
 		goto idata_err;
 	}
-
-	if (copy_from_user(idata->buf, (void __user *)(unsigned long)
-					idata->ic.data_ptr, idata->buf_bytes)) {
-		err = -EFAULT;
-		goto copy_err;
-	}
-

drivers/mmc/card/block.c static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( · line 376

Quoted 10 lines
drivers/mmc/card/block.c +1 -3
 	return idata;
 
-copy_err:
-	kfree(idata->buf);
 idata_err:
 	kfree(idata);
 out:
-	return ERR_PTR(err);
+	return idata;
 }

This looks strange, returning a freed pointer is a bad idea. I suggest a idata=NULL after kfree().

re,
wh

Quoted 2 lines
drivers/mmc/card/block.c +0 -0
 static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,
#476 lore raw

Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

Am 20.08.2016 08:01, schrieb SF Markus Elfring:

Quoted 38 lines

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 07:50:09 +0200

* Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

* Return directly if this copy operation failed.

---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +0 -8
index 6388bc0..bb89f04 100644
@@ -1132,7 +1132,6 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	struct mlx5_core_dev *dev = filp->private_data;
 	struct mlx5_cmd_debug *dbg = &dev->cmd.dbg;
 	void *ptr;
-	int err;
 
 	if (*pos != 0)
 		return -EINVAL;
@@ -1140,25 +1139,15 @@ static ssize_t data_write(struct file *filp, const char __user *buf,
 	kfree(dbg->in_msg);
 	dbg->in_msg = NULL;
 	dbg->inlen = 0;
-
-	ptr = kzalloc(count, GFP_KERNEL);
-	if (!ptr)
-		return -ENOMEM;
-
-	if (copy_from_user(ptr, buf, count)) {
-		err = -EFAULT;

drivers/net/ethernet/mellanox/mlx5/core/cmd.c static ssize_t data_write(struct file *filp, const char __user *buf, · line 1149

Quoted 10 lines
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +3 -2
-		goto out;
-	}
+	ptr = memdup_user(buf, count);
+	if (IS_ERR(ptr))
+		return PTR_ERR(ptr);
 	dbg->in_msg = ptr;
 	dbg->inlen = count;
 
 	*pos = count;
 

maybe i am missing something here but why do you need ptr ?

The use of count looks even more confusing it is stored in
dbg->inlen, *pos and is returned.
is that realy needed ?

re,
wh

Quoted 8 lines
drivers/net/ethernet/mellanox/mlx5/core/cmd.c +0 -4
 	return count;
-
-out:
-	kfree(ptr);
-	return err;
 }
 
 static ssize_t data_read(struct file *filp, char __user *buf, size_t count,
Reviewed-by on v1 1/2
#480 lore raw

Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

Hi,

Quoted 9 lines · On Sat, 20 Aug 2016 09:34:56 +0200 SF Markus Elfring…

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 08:54:15 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

#486 lore raw

cover hostap: Fine-tuning for a few functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:35:43 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Use memdup_user()
Delete an unnecessary jump label
Delete unnecessary variable initialisations

 .../net/wireless/intersil/hostap/hostap_ioctl.c    | 36 ++++++++--------------
 1 file changed, 12 insertions(+), 24 deletions(-)
Signature · 1 line
2.9.3
#487 lore raw

PATCH 1/3 hostap: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:19:43 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 .../net/wireless/intersil/hostap/hostap_ioctl.c    | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +6 -16
index 3e5fa78..4e271f9 100644
@@ -3041,14 +3041,9 @@ static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
 	    p->length > 1024 || !p->pointer)
 		return -EINVAL;
 
-	param = kmalloc(p->length, GFP_KERNEL);
-	if (param = NULL)
-		return -ENOMEM;
-
-	if (copy_from_user(param, p->pointer, p->length)) {
-		ret = -EFAULT;
-		goto out;
-	}
+	param = memdup_user(p->pointer, p->length);
+	if (IS_ERR(param))
+		return PTR_ERR(param);
 
 	if (p->length < sizeof(struct prism2_download_param) +
 	    param->num_areas * sizeof(struct prism2_download_area)) {
@@ -3803,14 +3798,9 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
 	    p->length > PRISM2_HOSTAPD_MAX_BUF_SIZE || !p->pointer)
 		return -EINVAL;
 
-	param = kmalloc(p->length, GFP_KERNEL);
-	if (param = NULL)
-		return -ENOMEM;
-
-	if (copy_from_user(param, p->pointer, p->length)) {
-		ret = -EFAULT;
-		goto out;
-	}
+	param = memdup_user(p->pointer, p->length);
+	if (IS_ERR(param))
+		return PTR_ERR(param);
 
 	switch (param->cmd) {
 	case PRISM2_SET_ENCRYPTION:
Signature · 1 line
2.9.3
#489 lore raw

PATCH 2/3 hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:21:29 +0200

Remove a jump label which is unneeded in this function at the end.

---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +2 -4
index 4e271f9..5942917 100644
@@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
 	}
 
 	if (ret = 1 || !ap_ioctl) {
-		if (copy_to_user(p->pointer, param, p->length)) {
+		if (copy_to_user(p->pointer, param, p->length))
 			ret = -EFAULT;
-			goto out;
-		} else if (ap_ioctl)
+		else if (ap_ioctl)
 			ret = 0;
 	}
 
- out:
 	kfree(param);
 	return ret;
 }
Signature · 1 line
2.9.3
#499 lore raw

PATCH 3/3 hostap: Delete unnecessary initialisations for the variable "ret"

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:23:14 +0200

The local variable "ret" will be set to an appropriate value a bit later. Thus omit the explicit initialisation at the beginning of four functions.

---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +4 -4
index 5942917..c37b0bb 100644
@@ -2895,7 +2895,7 @@ static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)
 {
 	struct hostap_interface *iface;
 	local_info_t *local;
-	int ret = 0;
+	int ret;
 	u32 mode;
 
 	iface = netdev_priv(dev);
@@ -3035,7 +3035,7 @@ static int ap_mac_cmd_ioctl(local_info_t *local, int *cmd)
 static int prism2_ioctl_priv_download(local_info_t *local, struct iw_point *p)
 {
 	struct prism2_download_param *param;
-	int ret = 0;
+	int ret;
 
 	if (p->length < sizeof(struct prism2_download_param) ||
 	    p->length > 1024 || !p->pointer)
@@ -3791,7 +3791,7 @@ static int prism2_ioctl_scan_req(local_info_t *local,
 static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
 {
 	struct prism2_hostapd_param *param;
-	int ret = 0;
+	int ret;
 	int ap_ioctl = 0;
 
 	if (p->length < sizeof(struct prism2_hostapd_param) ||
@@ -3954,7 +3954,7 @@ int hostap_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
 	struct iwreq *wrq = (struct iwreq *) ifr;
 	struct hostap_interface *iface;
 	local_info_t *local;
-	int ret = 0;
+	int ret;
 
 	iface = netdev_priv(dev);
 	local = iface->local;
Signature · 1 line
2.9.3
#508 lore raw

PATCH 1/1 s390/tape: Use memdup_user() rather than duplicating its implementation

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 19:25:34 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/s390/char/tape_3590.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/s390/char/tape_3590.c +3 -8
index d3d1936..e352047 100644
@@ -312,15 +312,10 @@ static int tape_3592_ioctl_kekl_set(struct tape_device *device,
 		return -ENOSYS;
 	if (!crypt_enabled(device))
 		return -EUNATCH;
-	ext_kekls = kmalloc(sizeof(*ext_kekls), GFP_KERNEL);
-	if (!ext_kekls)
-		return -ENOMEM;
-	if (copy_from_user(ext_kekls, (char __user *)arg, sizeof(*ext_kekls))) {
-		rc = -EFAULT;
-		goto out;
-	}
+	ext_kekls = memdup_user((char __user *)arg, sizeof(*ext_kekls));
+	if (IS_ERR(ext_kekls))
+		return PTR_ERR(ext_kekls);
 	rc = tape_3592_kekl_set(device, ext_kekls);
-out:
 	kfree(ext_kekls);
 	return rc;
 }
Signature · 1 line
2.9.3
maintainer
#500 lore raw

Re: [PATCH 0/3] hostap: Fine-tuning for a few functions

In reply to SF Markus Elfring
Quoted 5 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:35:43 +0200

A few update suggestions were taken into account
from static source code analysis.

Is it worth touching this old stuff especially when you are not making any functional changes.

Regards,
Arend

Quoted 8 lines

Markus Elfring (3):
Use memdup_user()
Delete an unnecessary jump label
Delete unnecessary variable initialisations

 .../net/wireless/intersil/hostap/hostap_ioctl.c    | 36 ++++++++--------------
 1 file changed, 12 insertions(+), 24 deletions(-)
#490 lore raw

Re: [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()

In reply to SF Markus Elfring

Hi Marcus,

Quoted 18 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 18:21:29 +0200

Remove a jump label which is unneeded in this function at the end.

---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +0 -0
index 4e271f9..5942917 100644
@@ -3835,14 +3835,12 @@ static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p)
        }
 
        if (ret = 1 || !ap_ioctl) {

drivers/net/wireless/intersil/hostap/hostap_ioctl.c static int prism2_ioctl_priv_hostapd(local_info_t *local, struct iw_point *p) · line 3845

Quoted 10 lines
drivers/net/wireless/intersil/hostap/hostap_ioctl.c +2 -4
-               if (copy_to_user(p->pointer, param, p->length)) {
+               if (copy_to_user(p->pointer, param, p->length))
                        ret = -EFAULT;
-                       goto out;
-               } else if (ap_ioctl)
+               else if (ap_ioctl)
                        ret = 0;
        }
 
- out:

Does this change make any difference to the compiled code?

Thanks,

Signature · 4 lines
Julian Calaby

Email: [email protected]
Profile: http://www.google.com/profiles/julian.calaby/
#510 lore raw

cover aacraid: Fine-tuning for a few functions

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Sun, 21 Aug 2016 09:03:21 +0200

Several update suggestions were taken into account from static source code analysis.

Markus Elfring (7):
Use memdup_user() rather than duplicating its implementation One function call less in aac_send_raw_srb() after error detection Delete unnecessary initialisations in aac_send_raw_srb() Delete unnecessary braces
Add spaces after control flow keywords
Improve determination of a few sizes
Apply another recommendation from "checkpatch.pl"

 drivers/scsi/aacraid/commctrl.c | 140 +++++++++++++++++++---------------------
 1 file changed, 67 insertions(+), 73 deletions(-)
Signature · 1 line
2.9.3
#511 lore raw

PATCH 1/7 aacraid: Use memdup_user() rather than duplicating its implementation

From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 20:05:24 +0200

Reuse existing functionality from memdup_user() instead of keeping duplicate source code.

This issue was detected by using the Coccinelle software.

---
 drivers/scsi/aacraid/commctrl.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
drivers/scsi/aacraid/commctrl.c +3 -9
index 5648b71..1af3084 100644
@@ -526,15 +526,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 		goto cleanup;
 	}
 
-	user_srbcmd = kmalloc(fibsize, GFP_KERNEL);
-	if (!user_srbcmd) {
-		dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n"));
-		rcode = -ENOMEM;
-		goto cleanup;
-	}
-	if(copy_from_user(user_srbcmd, user_srb,fibsize)){
-		dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n"));
-		rcode = -EFAULT;
+	user_srbcmd = memdup_user(user_srb, fibsize);
+	if (IS_ERR(user_srbcmd)) {
+		rcode = PTR_ERR(user_srbcmd);
 		goto cleanup;
 	}
 
Signature · 1 line
2.9.3
#515 lore raw

PATCH 2/7 aacraid: One function call less in aac_send_raw_srb() after error detection

In reply to SF Markus Elfring

From e8187662ee30aab709a260c72fb86c51673f8e0d Mon Sep 17 00:00:00 2001
From: Markus Elfring <[email protected]>
Date: Sat, 20 Aug 2016 20:40:47 +0200
Subject: [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb()
after error detection

The kfree() function was called in a few cases by the aac_send_raw_srb() function during error handling even if the variable "user_srbcmd" contained eventually an inappropriate pointer value.

---
 drivers/scsi/aacraid/commctrl.c | 49 ++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 25 deletions(-)
drivers/scsi/aacraid/commctrl.c +24 -25
index 1af3084..6dcdf91 100644
@@ -517,19 +517,19 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
 		dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
 		rcode = -EFAULT;
-		goto cleanup;
+		goto free_sg_list;
 	}
 
 	if ((fibsize < (sizeof(struct user_aac_srb) - sizeof(struct user_sgentry))) ||
 	    (fibsize > (dev->max_fib_size - sizeof(struct aac_fibhdr)))) {
 		rcode = -EINVAL;
-		goto cleanup;
+		goto free_sg_list;
 	}
 
 	user_srbcmd = memdup_user(user_srb, fibsize);
 	if (IS_ERR(user_srbcmd)) {
 		rcode = PTR_ERR(user_srbcmd);
-		goto cleanup;
+		goto free_sg_list;
 	}
 
 	user_reply = arg+fibsize;
@@ -564,7 +564,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 		dprintk((KERN_DEBUG"aacraid: too many sg entries %d\n",
 		  le32_to_cpu(srbcmd->sg.count)));
 		rcode = -EINVAL;
-		goto cleanup;
+		goto free_user_srbcmd;
 	}
 	actual_fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) +
 		((user_srbcmd->sg.count & 0xff) * sizeof(struct sgentry));
@@ -580,12 +580,12 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 		  sizeof(struct aac_srb), sizeof(struct sgentry),
 		  sizeof(struct sgentry64), fibsize));
 		rcode = -EINVAL;
-		goto cleanup;
+		goto free_user_srbcmd;
 	}
 	if ((data_dir = DMA_NONE) && user_srbcmd->sg.count) {
 		dprintk((KERN_DEBUG"aacraid: SG with no direction specified in Raw SRB command\n"));
 		rcode = -EINVAL;
-		goto cleanup;
+		goto free_user_srbcmd;
 	}
 	byte_count = 0;
 	if (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64) {
@@ -606,7 +606,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				      (dev->scsi_host_ptr->max_sectors << 9) :
 				      65536)) {
 					rcode = -EINVAL;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);
@@ -614,7 +614,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 					dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
 					  upsg->sg[i].count,i,upsg->count));
 					rcode = -ENOMEM;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				addr = (u64)upsg->sg[i].addr[0];
 				addr += ((u64)upsg->sg[i].addr[1]) << 32;
@@ -626,7 +626,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 					if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
 						dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
 						rcode = -EFAULT;
-						goto cleanup;
+						goto free_user_srbcmd;
 					}
 				}
 				addr = pci_map_single(dev->pdev, p, upsg->sg[i].count, data_dir);
@@ -644,7 +644,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 			if (!usg) {
 				dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
 				rcode = -ENOMEM;
-				goto cleanup;
+				goto free_user_srbcmd;
 			}
 			actual_fibsize = actual_fibsize64;
 
@@ -658,7 +658,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				      65536)) {
 					kfree(usg);
 					rcode = -EINVAL;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
@@ -667,7 +667,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 					  usg->sg[i].count,i,usg->count));
 					kfree(usg);
 					rcode = -ENOMEM;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				sg_user[i] = (void __user *)(uintptr_t)usg->sg[i].addr;
 				sg_list[i] = p; // save so we can clean up later
@@ -678,7 +678,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 						kfree (usg);
 						dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
 						rcode = -EFAULT;
-						goto cleanup;
+						goto free_user_srbcmd;
 					}
 				}
 				addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir);
@@ -711,7 +711,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				      (dev->scsi_host_ptr->max_sectors << 9) :
 				      65536)) {
 					rcode = -EINVAL;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
@@ -719,7 +719,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 					dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
 					  usg->sg[i].count,i,usg->count));
 					rcode = -ENOMEM;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				addr = (u64)usg->sg[i].addr[0];
 				addr += ((u64)usg->sg[i].addr[1]) << 32;
@@ -731,7 +731,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 					if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
 						dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
 						rcode = -EFAULT;
-						goto cleanup;
+						goto free_user_srbcmd;
 					}
 				}
 				addr = pci_map_single(dev->pdev, p, usg->sg[i].count, data_dir);
@@ -750,14 +750,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				      (dev->scsi_host_ptr->max_sectors << 9) :
 				      65536)) {
 					rcode = -EINVAL;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				p = kmalloc(upsg->sg[i].count, GFP_KERNEL);
 				if (!p) {
 					dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
 					  upsg->sg[i].count, i, upsg->count));
 					rcode = -ENOMEM;
-					goto cleanup;
+					goto free_user_srbcmd;
 				}
 				sg_user[i] = (void __user *)(uintptr_t)upsg->sg[i].addr;
 				sg_list[i] = p; // save so we can clean up later
@@ -768,7 +768,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 							upsg->sg[i].count)) {
 						dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
 						rcode = -EFAULT;
-						goto cleanup;
+						goto free_user_srbcmd;
 					}
 				}
 				addr = pci_map_single(dev->pdev, p,
@@ -788,13 +788,13 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	}
 	if (status = -ERESTARTSYS) {
 		rcode = -ERESTARTSYS;
-		goto cleanup;
+		goto free_user_srbcmd;
 	}
 
 	if (status != 0){
 		dprintk((KERN_DEBUG"aacraid: Could not send raw srb fib to hba\n"));
 		rcode = -ENXIO;
-		goto cleanup;
+		goto free_user_srbcmd;
 	}
 
 	if (flags & SRB_DataIn) {
@@ -806,7 +806,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 			if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
 				dprintk((KERN_DEBUG"aacraid: Could not copy sg data to user\n"));
 				rcode = -EFAULT;
-				goto cleanup;
+				goto free_user_srbcmd;
 
 			}
 		}
@@ -816,11 +816,10 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
 		dprintk((KERN_DEBUG"aacraid: Could not copy reply to user\n"));
 		rcode = -EFAULT;
-		goto cleanup;
 	}
-
-cleanup:
+free_user_srbcmd:
 	kfree(user_srbcmd);
+free_sg_list:
 	for(i=0; i <= sg_indx; i++){
 		kfree(sg_list[i]);
 	}
Signature · 1 line
2.9.3