linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Source code review around jump label usage
@ 2015-12-11 12:08 SF Markus Elfring
  2015-12-11 12:14 ` Julia Lawall
                   ` (95 more replies)
  0 siblings, 96 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-11 12:08 UTC (permalink / raw)
  To: LKML; +Cc: kernel-janitors, Julia Lawall, Derek M. Jones

Hello,

I have tried another specific analysis out on the source files
of "Linux next-20151211" with help of the software "Coccinelle 1.0.4".
I have taken a more detailed look on the use of the goto statement
and corresponding jump labels.

Can statistics like the following support software evolution
and further constructive considerations?

╔═════════════════════════════════════════╤═══════════╗
║                 target                  │ incidence ║
╠═════════════════════════════════════════╪═══════════╣
║ out                                     │      9782 ║
║ done                                    │      1344 ║
║ exit                                    │       950 ║
║ out_unlock                              │       538 ║
║ unlock                                  │       509 ║
║ bail                                    │       486 ║
║ error                                   │       418 ║
║ retry                                   │       414 ║
║ err                                     │       400 ║
║ end                                     │       332 ║
║                 …                       │     …     ║
║ abts_pending                            │         1 ║
║ abts_err                                │         1 ║
║ absolute_address                        │         1 ║
║ abort2                                  │         1 ║
║ abort_fail                              │         1 ║
║ abort_end                               │         1 ║
║ abituguru_probe_error                   │         1 ║
║ abituguru_detect_no_pwms_exit           │         1 ║
║ abituguru_detect_bank1_sensor_type_exit │         1 ║
╚═════════════════════════════════════════╧═══════════╝


How often are different jump targets used within function implementations?
(Functions without jump labels were not searched for this analysis approach.)

╔═════════╤═══════════╗
║ counter │ incidence ║
╠═════════╪═══════════╣
║       1 │     18442 ║
║       2 │      2002 ║
║       3 │       356 ║
║       4 │       106 ║
║       5 │        31 ║
║       6 │         7 ║
║       7 │         2 ║
║       8 │         3 ║
╚═════════╧═══════════╝


How does the text length distribution look like for the used jump targets?

╔════════╤═══════════╗
║ length │ incidence ║
╠════════╪═══════════╣
║      1 │         2 ║
║      2 │        29 ║
║      3 │     10640 ║
║      4 │      3564 ║
║      5 │      1714 ║
║      6 │      1162 ║
║      7 │      1245 ║
║      8 │       881 ║
║      9 │       787 ║
║     10 │      1252 ║
║   …    │     …     ║
║     35 │         4 ║
║     36 │         1 ║
║     37 │         2 ║
║     38 │         1 ║
║     39 │         1 ║
╚════════╧═══════════╝


How often are jump targets called within specific function implementations?

╔══════════════════════════╤═════════════════════════════════════════╤══════╤══════════════════════╤═════════╗
║         function         │          source file                    │ line │      go to           │ counter ║
╠══════════════════════════╪═════════════════════════════════════════╪══════╪══════════════════════╪═════════╣
║ do_ipv6_setsockopt       │ net/ipv6/ipv6_sockglue.c                │  140 │ e_inval              │      52 ║
║ dvb_register             │ drivers/media/pci/cx88/cx88-dvb.c       │ 1005 │ frontend_detach      │      43 ║
║ dvb_init                 │ drivers/media/pci/saa7134/saa7134-dvb.c │ 1210 │ detach_frontend      │      40 ║
║ gdbstub_single_step      │ arch/mn10300/kernel/gdb-stub.c          │  491 │ fault                │      38 ║
║ uinput_ioctl_handler     │ drivers/input/misc/uinput.c             │  701 │ out                  │      32 ║
║         …                │               …                         │  …   │        …             │    …    ║
║ kvm_vm_compat_ioctl      │ virt/kvm/kvm_main.c                     │ 2916 │ out                  │       1 ║
║ kvm_vm_ioctl             │ virt/kvm/kvm_main.c                     │ 2742 │ out_free_irq_routing │       1 ║
║ kvm_vm_ioctl_create_vcpu │ virt/kvm/kvm_main.c                     │ 2257 │ vcpu_destroy         │       1 ║
╚══════════════════════════╧═════════════════════════════════════════╧══════╧══════════════════════╧═════════╝


Do any of these numbers indicate update candidates which correspond to the
"one error jump label bug" symptom that is mentioned in the Linux coding
style documentation?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
@ 2015-12-11 12:14 ` Julia Lawall
  2015-12-11 12:48 ` Dan Carpenter
                   ` (94 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2015-12-11 12:14 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Derek M. Jones

> Do any of these numbers indicate update candidates which correspond to the
> "one error jump label bug" symptom that is mentioned in the Linux coding
> style documentation?

I don't think that numbers could indicate that.  The point of that is a
single label followed by a bunch of ifs, or by calls to functions that
perform tests on input validity.  That is, it is the content of the code
that causes the problem, not its size.  Dan also discourages the use of
labels like out, that don't indicate anything about anything, or
kmalloc_err, which don't indicate anything about what happens at the label
target.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
  2015-12-11 12:14 ` Julia Lawall
@ 2015-12-11 12:48 ` Dan Carpenter
  2015-12-11 18:00 ` Christophe JAILLET
                   ` (93 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-11 12:48 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall, Derek M. Jones

I hate out labels but a lot of people like them and they're not
prohibited by kernel style. I only complain about them when they
introduce bugs.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
  2015-12-11 12:14 ` Julia Lawall
  2015-12-11 12:48 ` Dan Carpenter
@ 2015-12-11 18:00 ` Christophe JAILLET
  2015-12-11 18:19 ` [PATCH 0/2] block: Fine-tuning for two function implementations SF Markus Elfring
                   ` (92 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: Christophe JAILLET @ 2015-12-11 18:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

Le 11/12/2015 13:08, SF Markus Elfring a écrit :
> How does the text length distribution look like for the used jump targets?
>
> ╔════════╤═══════════╗
> ║ length │ incidence ║
> ╠════════╪═══════════╣
> ║      1 │         2 ║
> ║      2 │        29 ║
> ║      3 │     10640 ║
> ║      4 │      3564 ║
> ║      5 │      1714 ║
> ║      6 │      1162 ║
> ║      7 │      1245 ║
> ║      8 │       881 ║
> ║      9 │       787 ║
> ║     10 │      1252 ║
> ║   …    │     …     ║
> ║     35 │         4 ║
> ║     36 │         1 ║
> ║     37 │         2 ║
> ║     38 │         1 ║
> ║     39 │         1 ║
> ╚════════╧═══════════╝
>

Maybe having a look at the 1 or 2 chars long labels would make sense.
They are likely to be too short for being of any use.

IMHO, too long labels may also reduce readability.

Best regards,
CJ


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] block: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (2 preceding siblings ...)
  2015-12-11 18:00 ` Christophe JAILLET
@ 2015-12-11 18:19 ` SF Markus Elfring
  2015-12-11 18:24   ` [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection SF Markus Elfring
  2015-12-11 18:26   ` [PATCH 2/2] z2ram: Delete a jump label in z2_init() SF Markus Elfring
  2015-12-12  9:16 ` [PATCH] uinput: Rename a jump label in uinput_ioctl_handler() SF Markus Elfring
                   ` (91 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-11 18:19 UTC (permalink / raw)
  To: LKML, Minchan Kim, Nitin Gupta, Sergey Senozhatsky
  Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Dec 2015 19:12:34 +0100

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

Markus Elfring (2):
  zram: Less checks in zram_bvec_write() after error detection
  z2ram: Delete a jump label in z2_init()

 drivers/block/z2ram.c         |  4 +---
 drivers/block/zram/zram_drv.c | 26 +++++++++++++-------------
 2 files changed, 14 insertions(+), 16 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-11 18:19 ` [PATCH 0/2] block: Fine-tuning for two function implementations SF Markus Elfring
@ 2015-12-11 18:24   ` SF Markus Elfring
  2015-12-14  0:27     ` Sergey Senozhatsky
  2015-12-11 18:26   ` [PATCH 2/2] z2ram: Delete a jump label in z2_init() SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-11 18:24 UTC (permalink / raw)
  To: LKML, Minchan Kim, Nitin Gupta, Sergey Senozhatsky
  Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Dec 2015 18:20:59 +0100

This issue was detected by using the Coccinelle software.

A few checks could be repeated by the zram_bvec_write() function
at two places even if the passed variables contained a null pointer.

* This implementation detail could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* Let us return directly if a memory allocation failed.

* Drop unnecessary initialisations for the variables "uncmem"
  and "zstrm" then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/zram/zram_drv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 47915d7..69d7fcd 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -652,9 +652,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 	size_t clen;
 	unsigned long handle;
 	struct page *page;
-	unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
+	unsigned char *user_mem, *cmem, *src, *uncmem;
 	struct zram_meta *meta = zram->meta;
-	struct zcomp_strm *zstrm = NULL;
+	struct zcomp_strm *zstrm;
 	unsigned long alloced_pages;
 
 	page = bvec->bv_page;
@@ -664,13 +664,11 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 		 * before to write the changes.
 		 */
 		uncmem = kmalloc(PAGE_SIZE, GFP_NOIO);
-		if (!uncmem) {
-			ret = -ENOMEM;
-			goto out;
-		}
+		if (!uncmem)
+			return -ENOMEM;
 		ret = zram_decompress_page(zram, uncmem, index);
 		if (ret)
-			goto out;
+			goto free_uncmem;
 	}
 
 	zstrm = zcomp_strm_find(zram->comp);
@@ -696,7 +694,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 
 		atomic64_inc(&zram->stats.zero_pages);
 		ret = 0;
-		goto out;
+		goto check_strm;
 	}
 
 	ret = zcomp_compress(zram->comp, zstrm, uncmem, &clen);
@@ -708,7 +706,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 
 	if (unlikely(ret)) {
 		pr_err("Compression failed! err=%d\n", ret);
-		goto out;
+		goto check_strm;
 	}
 	src = zstrm->buffer;
 	if (unlikely(clen > max_zpage_size)) {
@@ -722,7 +720,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 		pr_err("Error allocating memory for compressed page: %u, size=%zu\n",
 			index, clen);
 		ret = -ENOMEM;
-		goto out;
+		goto check_strm;
 	}
 
 	alloced_pages = zs_get_total_pages(meta->mem_pool);
@@ -731,7 +729,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 	if (zram->limit_pages && alloced_pages > zram->limit_pages) {
 		zs_free(meta->mem_pool, handle);
 		ret = -ENOMEM;
-		goto out;
+		goto check_strm;
 	}
 
 	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO);
@@ -762,11 +760,13 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
 	/* Update stats */
 	atomic64_add(clen, &zram->stats.compr_data_size);
 	atomic64_inc(&zram->stats.pages_stored);
-out:
+check_strm:
 	if (zstrm)
 		zcomp_strm_release(zram->comp, zstrm);
-	if (is_partial_io(bvec))
+	if (is_partial_io(bvec)) {
+free_uncmem:
 		kfree(uncmem);
+	}
 	return ret;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] z2ram: Delete a jump label in z2_init()
  2015-12-11 18:19 ` [PATCH 0/2] block: Fine-tuning for two function implementations SF Markus Elfring
  2015-12-11 18:24   ` [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection SF Markus Elfring
@ 2015-12-11 18:26   ` SF Markus Elfring
  2015-12-14  0:36     ` Sergey Senozhatsky
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-11 18:26 UTC (permalink / raw)
  To: LKML, Minchan Kim, Nitin Gupta, Sergey Senozhatsky
  Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 11 Dec 2015 18:48:14 +0100

This issue was detected by using the Coccinelle software.

* Let us return directly if a call of the function "register_blkdev" failed.

* Remove the jump label "err" then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/z2ram.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index 968f9e5..b07581d 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -345,9 +345,8 @@ z2_init(void)
     if (!MACH_IS_AMIGA)
 	return -ENODEV;
 
-    ret = -EBUSY;
     if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
-	goto err;
+	return -EBUSY;
 
     ret = -ENOMEM;
     z2ram_gendisk = alloc_disk(1);
@@ -374,7 +373,6 @@ out_queue:
     put_disk(z2ram_gendisk);
 out_disk:
     unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
-err:
     return ret;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (3 preceding siblings ...)
  2015-12-11 18:19 ` [PATCH 0/2] block: Fine-tuning for two function implementations SF Markus Elfring
@ 2015-12-12  9:16 ` SF Markus Elfring
  2015-12-12 22:23   ` Dmitry Torokhov
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
                   ` (90 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12  9:16 UTC (permalink / raw)
  To: LKML, linux-input, Dmitry Torokhov; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 10:06:00 +0100

This issue was detected by using the Coccinelle software.

Choose a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/misc/uinput.c | 66 ++++++++++++++++++++++-----------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index 5adbced..466f62d 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -717,7 +717,7 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
 	if (!udev->dev) {
 		retval = uinput_allocate_device(udev);
 		if (retval)
-			goto out;
+			goto unlock;
 	}
 
 	switch (cmd) {
@@ -725,82 +725,82 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
 			if (put_user(UINPUT_VERSION,
 				     (unsigned int __user *)p))
 				retval = -EFAULT;
-			goto out;
+			goto unlock;
 
 		case UI_DEV_CREATE:
 			retval = uinput_create_device(udev);
-			goto out;
+			goto unlock;
 
 		case UI_DEV_DESTROY:
 			uinput_destroy_device(udev);
-			goto out;
+			goto unlock;
 
 		case UI_SET_EVBIT:
 			retval = uinput_set_bit(arg, evbit, EV_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_KEYBIT:
 			retval = uinput_set_bit(arg, keybit, KEY_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_RELBIT:
 			retval = uinput_set_bit(arg, relbit, REL_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_ABSBIT:
 			retval = uinput_set_bit(arg, absbit, ABS_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_MSCBIT:
 			retval = uinput_set_bit(arg, mscbit, MSC_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_LEDBIT:
 			retval = uinput_set_bit(arg, ledbit, LED_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_SNDBIT:
 			retval = uinput_set_bit(arg, sndbit, SND_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_FFBIT:
 			retval = uinput_set_bit(arg, ffbit, FF_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_SWBIT:
 			retval = uinput_set_bit(arg, swbit, SW_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_PROPBIT:
 			retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX);
-			goto out;
+			goto unlock;
 
 		case UI_SET_PHYS:
 			if (udev->state == UIST_CREATED) {
 				retval = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 
 			phys = strndup_user(p, 1024);
 			if (IS_ERR(phys)) {
 				retval = PTR_ERR(phys);
-				goto out;
+				goto unlock;
 			}
 
 			kfree(udev->dev->phys);
 			udev->dev->phys = phys;
-			goto out;
+			goto unlock;
 
 		case UI_BEGIN_FF_UPLOAD:
 			retval = uinput_ff_upload_from_user(p, &ff_up);
 			if (retval)
-				goto out;
+				goto unlock;
 
 			req = uinput_request_find(udev, ff_up.request_id);
 			if (!req || req->code != UI_FF_UPLOAD ||
 			    !req->u.upload.effect) {
 				retval = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 
 			ff_up.retval = 0;
@@ -811,60 +811,60 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
 				memset(&ff_up.old, 0, sizeof(struct ff_effect));
 
 			retval = uinput_ff_upload_to_user(p, &ff_up);
-			goto out;
+			goto unlock;
 
 		case UI_BEGIN_FF_ERASE:
 			if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
 				retval = -EFAULT;
-				goto out;
+				goto unlock;
 			}
 
 			req = uinput_request_find(udev, ff_erase.request_id);
 			if (!req || req->code != UI_FF_ERASE) {
 				retval = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 
 			ff_erase.retval = 0;
 			ff_erase.effect_id = req->u.effect_id;
 			if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) {
 				retval = -EFAULT;
-				goto out;
+				goto unlock;
 			}
 
-			goto out;
+			goto unlock;
 
 		case UI_END_FF_UPLOAD:
 			retval = uinput_ff_upload_from_user(p, &ff_up);
 			if (retval)
-				goto out;
+				goto unlock;
 
 			req = uinput_request_find(udev, ff_up.request_id);
 			if (!req || req->code != UI_FF_UPLOAD ||
 			    !req->u.upload.effect) {
 				retval = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 
 			req->retval = ff_up.retval;
 			uinput_request_done(udev, req);
-			goto out;
+			goto unlock;
 
 		case UI_END_FF_ERASE:
 			if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
 				retval = -EFAULT;
-				goto out;
+				goto unlock;
 			}
 
 			req = uinput_request_find(udev, ff_erase.request_id);
 			if (!req || req->code != UI_FF_ERASE) {
 				retval = -EINVAL;
-				goto out;
+				goto unlock;
 			}
 
 			req->retval = ff_erase.retval;
 			uinput_request_done(udev, req);
-			goto out;
+			goto unlock;
 	}
 
 	size = _IOC_SIZE(cmd);
@@ -874,15 +874,15 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
 	case UI_GET_SYSNAME(0):
 		if (udev->state != UIST_CREATED) {
 			retval = -ENOENT;
-			goto out;
+			goto unlock;
 		}
 		name = dev_name(&udev->dev->dev);
 		retval = uinput_str_to_user(p, name, size);
-		goto out;
+		goto unlock;
 	}
 
 	retval = -EINVAL;
- out:
+ unlock:
 	mutex_unlock(&udev->mutex);
 	return retval;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (4 preceding siblings ...)
  2015-12-12  9:16 ` [PATCH] uinput: Rename a jump label in uinput_ioctl_handler() SF Markus Elfring
@ 2015-12-12 14:30 ` SF Markus Elfring
  2015-12-12 14:34   ` [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly SF Markus Elfring
                     ` (6 more replies)
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                   ` (89 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:30 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 15:25:20 +0100

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

Markus Elfring (7):
  Use a variable initialisation in iscsi_set_default_param() directly
  Less checks in iscsi_set_default_param() after error detection
  Delete an unnecessary variable initialisation in iscsi_create_default_params()
  Make a variable initialisation a bit more obvious in iscsi_create_default_params()
  Rename a jump label in iscsi_create_default_params()
  Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support()
  Make two variable initialisations a bit more obvious in iscsi_check_valuelist_for_support()

 drivers/target/iscsi/iscsi_target_parameters.c | 100 ++++++++++++-------------
 1 file changed, 47 insertions(+), 53 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
@ 2015-12-12 14:34   ` SF Markus Elfring
  2015-12-12 19:49     ` Dan Carpenter
  2015-12-12 14:37   ` [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:34 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 11:36:02 +0100

Omit the unnecessary setting to a null pointer for the variable "param"
at the beginning of the function "iscsi_set_default_param"
because it can be directly initialized with the return value
from the function "kzalloc".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 3a1f9a7..0a8bd3f 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
 		char *name, char *value, u8 phase, u8 scope, u8 sender,
 		u16 type_range, u8 use)
 {
-	struct iscsi_param *param = NULL;
+	struct iscsi_param *param = kzalloc(sizeof(*param), GFP_KERNEL);
 
-	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
 	if (!param) {
 		pr_err("Unable to allocate memory for parameter.\n");
 		goto out;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
  2015-12-12 14:34   ` [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly SF Markus Elfring
@ 2015-12-12 14:37   ` SF Markus Elfring
  2015-12-12 14:40   ` [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_params() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:37 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 12:50:10 +0100

This issue was detected by using the Coccinelle software.

A sanity check would be performed by the iscsi_set_default_param() function
even if it is known already that the passed variable contained
a null pointer.

* This implementation detail could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* Let us return directly if a call of the function "kzalloc" failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 0a8bd3f..15b2618 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -131,20 +131,20 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
 
 	if (!param) {
 		pr_err("Unable to allocate memory for parameter.\n");
-		goto out;
+		return NULL;
 	}
 	INIT_LIST_HEAD(&param->p_list);
 
 	param->name = kstrdup(name, GFP_KERNEL);
 	if (!param->name) {
 		pr_err("Unable to allocate memory for parameter name.\n");
-		goto out;
+		goto free_param;
 	}
 
 	param->value = kstrdup(value, GFP_KERNEL);
 	if (!param->value) {
 		pr_err("Unable to allocate memory for parameter value.\n");
-		goto out;
+		goto free_name;
 	}
 
 	param->phase		= phase;
@@ -182,18 +182,17 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
 	default:
 		pr_err("Unknown type_range 0x%02x\n",
 				param->type_range);
-		goto out;
+		goto free_value;
 	}
 	list_add_tail(&param->p_list, &param_list->param_list);
 
 	return param;
-out:
-	if (param) {
-		kfree(param->value);
-		kfree(param->name);
-		kfree(param);
-	}
-
+free_value:
+	kfree(param->value);
+free_name:
+	kfree(param->name);
+free_param:
+	kfree(param);
 	return NULL;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_params()
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
  2015-12-12 14:34   ` [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly SF Markus Elfring
  2015-12-12 14:37   ` [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection SF Markus Elfring
@ 2015-12-12 14:40   ` SF Markus Elfring
  2015-12-12 14:41   ` [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious " SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:40 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 13:20:08 +0100

The variable "param" will eventually be set to an appropriate pointer
from a call of the iscsi_set_default_param() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 15b2618..e0b173d 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -199,7 +199,7 @@ free_param:
 /* #warning Add extension keys */
 int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
 {
-	struct iscsi_param *param = NULL;
+	struct iscsi_param *param;
 	struct iscsi_param_list *pl;
 
 	pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_default_params()
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-12 14:40   ` [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_params() SF Markus Elfring
@ 2015-12-12 14:41   ` SF Markus Elfring
  2015-12-12 14:45     ` Julia Lawall
  2015-12-12 14:42   ` [PATCH 5/7] iscsi-target: Rename a jump label " SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:41 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 13:44:06 +0100

The variable "pl" was declared and immediately assigned a return value
from a function call in a separate statement.

* Let us express the desired variable initialisation directly.

* Avoid the repetition of the data type specification for the
  involved memory allocation according to the Linux coding
  style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index e0b173d..3f3842f 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -200,9 +200,8 @@ free_param:
 int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
 {
 	struct iscsi_param *param;
-	struct iscsi_param_list *pl;
+	struct iscsi_param_list *pl = kzalloc(sizeof(*pl), GFP_KERNEL);
 
-	pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
 	if (!pl) {
 		pr_err("Unable to allocate memory for"
 				" struct iscsi_param_list.\n");
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] iscsi-target: Rename a jump label in iscsi_create_default_params()
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2015-12-12 14:41   ` [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious " SF Markus Elfring
@ 2015-12-12 14:42   ` SF Markus Elfring
  2015-12-12 14:43   ` [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support() SF Markus Elfring
  2015-12-12 14:45   ` [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious " SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:42 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 14:12:50 +0100

This issue was detected by using the Coccinelle software.

Choose a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 64 +++++++++++++-------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 3f3842f..29ecf29 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -225,185 +225,185 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
 			PHASE_SECURITY, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_AUTH, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, HEADERDIGEST, INITIAL_HEADERDIGEST,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_DIGEST, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, DATADIGEST, INITIAL_DATADIGEST,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_DIGEST, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, MAXCONNECTIONS,
 			INITIAL_MAXCONNECTIONS, PHASE_OPERATIONAL,
 			SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, SENDTARGETS, INITIAL_SENDTARGETS,
 			PHASE_FFP0, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
 			TYPERANGE_UTF8, 0);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, TARGETNAME, INITIAL_TARGETNAME,
 			PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_ISCSINAME, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, INITIATORNAME,
 			INITIAL_INITIATORNAME, PHASE_DECLARATIVE,
 			SCOPE_SESSION_WIDE, SENDER_INITIATOR,
 			TYPERANGE_ISCSINAME, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, TARGETALIAS, INITIAL_TARGETALIAS,
 			PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
 			TYPERANGE_UTF8, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, INITIATORALIAS,
 			INITIAL_INITIATORALIAS, PHASE_DECLARATIVE,
 			SCOPE_SESSION_WIDE, SENDER_INITIATOR, TYPERANGE_UTF8,
 			USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, TARGETADDRESS,
 			INITIAL_TARGETADDRESS, PHASE_DECLARATIVE,
 			SCOPE_SESSION_WIDE, SENDER_TARGET,
 			TYPERANGE_TARGETADDRESS, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, TARGETPORTALGROUPTAG,
 			INITIAL_TARGETPORTALGROUPTAG,
 			PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_TARGET,
 			TYPERANGE_0_TO_65535, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, INITIALR2T, INITIAL_INITIALR2T,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, IMMEDIATEDATA,
 			INITIAL_IMMEDIATEDATA, PHASE_OPERATIONAL,
 			SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_AND,
 			USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, MAXXMITDATASEGMENTLENGTH,
 			INITIAL_MAXXMITDATASEGMENTLENGTH,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, MAXRECVDATASEGMENTLENGTH,
 			INITIAL_MAXRECVDATASEGMENTLENGTH,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, MAXBURSTLENGTH,
 			INITIAL_MAXBURSTLENGTH, PHASE_OPERATIONAL,
 			SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, FIRSTBURSTLENGTH,
 			INITIAL_FIRSTBURSTLENGTH,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, DEFAULTTIME2WAIT,
 			INITIAL_DEFAULTTIME2WAIT,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, DEFAULTTIME2RETAIN,
 			INITIAL_DEFAULTTIME2RETAIN,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_0_TO_3600, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, MAXOUTSTANDINGR2T,
 			INITIAL_MAXOUTSTANDINGR2T,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_1_TO_65535, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, DATAPDUINORDER,
 			INITIAL_DATAPDUINORDER, PHASE_OPERATIONAL,
 			SCOPE_SESSION_WIDE, SENDER_BOTH, TYPERANGE_BOOL_OR,
 			USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, DATASEQUENCEINORDER,
 			INITIAL_DATASEQUENCEINORDER,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_BOOL_OR, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, ERRORRECOVERYLEVEL,
 			INITIAL_ERRORRECOVERYLEVEL,
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_0_TO_2, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, SESSIONTYPE, INITIAL_SESSIONTYPE,
 			PHASE_DECLARATIVE, SCOPE_SESSION_WIDE, SENDER_INITIATOR,
 			TYPERANGE_SESSIONTYPE, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, IFMARKER, INITIAL_IFMARKER,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, OFMARKER, INITIAL_OFMARKER,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_BOOL_AND, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, IFMARKINT, INITIAL_IFMARKINT,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_UTF8, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, OFMARKINT, INITIAL_OFMARKINT,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_UTF8, USE_INITIAL_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	/*
 	 * Extra parameters for ISER from RFC-5046
@@ -412,25 +412,25 @@ int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
 			PHASE_OPERATIONAL, SCOPE_SESSION_WIDE, SENDER_BOTH,
 			TYPERANGE_BOOL_AND, USE_LEADING_ONLY);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, INITIATORRECVDATASEGMENTLENGTH,
 			INITIAL_INITIATORRECVDATASEGMENTLENGTH,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	param = iscsi_set_default_param(pl, TARGETRECVDATASEGMENTLENGTH,
 			INITIAL_TARGETRECVDATASEGMENTLENGTH,
 			PHASE_OPERATIONAL, SCOPE_CONNECTION_ONLY, SENDER_BOTH,
 			TYPERANGE_512_TO_16777215, USE_ALL);
 	if (!param)
-		goto out;
+		goto release_list;
 
 	*param_list_ptr = pl;
 	return 0;
-out:
+release_list:
 	iscsi_release_param_list(pl);
 	return -1;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support()
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2015-12-12 14:42   ` [PATCH 5/7] iscsi-target: Rename a jump label " SF Markus Elfring
@ 2015-12-12 14:43   ` SF Markus Elfring
  2015-12-12 14:45   ` [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious " SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:43 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 14:34:26 +0100

The variables "tmp1" and "tmp2" will eventually be set to appropriate
pointers from a call of the strchr() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 29ecf29..53e3345 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -920,7 +920,7 @@ static char *iscsi_check_valuelist_for_support(
 	struct iscsi_param *param,
 	char *value)
 {
-	char *tmp1 = NULL, *tmp2 = NULL;
+	char *tmp1, *tmp2;
 	char *acceptor_values = NULL, *proposer_values = NULL;
 
 	acceptor_values = param->value;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious in iscsi_check_valuelist_for_support()
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2015-12-12 14:43   ` [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support() SF Markus Elfring
@ 2015-12-12 14:45   ` SF Markus Elfring
  2015-12-12 17:17     ` walter harms
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 14:45 UTC (permalink / raw)
  To: linux-scsi, target-devel, Nicholas A. Bellinger
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 12 Dec 2015 15:04:57 +0100

The variable "acceptor_values" and "proposer_values" were initialized
by null pointers and immediately assigned values from input parameters
by separate statements.
Let us express the desired variable initialisations directly.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/target/iscsi/iscsi_target_parameters.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
index 53e3345..fb6fd34 100644
--- a/drivers/target/iscsi/iscsi_target_parameters.c
+++ b/drivers/target/iscsi/iscsi_target_parameters.c
@@ -921,10 +921,7 @@ static char *iscsi_check_valuelist_for_support(
 	char *value)
 {
 	char *tmp1, *tmp2;
-	char *acceptor_values = NULL, *proposer_values = NULL;
-
-	acceptor_values = param->value;
-	proposer_values = value;
+	char *acceptor_values = param->value, *proposer_values = value;
 
 	do {
 		if (!proposer_values)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_default_params()
  2015-12-12 14:41   ` [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious " SF Markus Elfring
@ 2015-12-12 14:45     ` Julia Lawall
  2015-12-12 15:02       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2015-12-12 14:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-scsi, target-devel, Nicholas A. Bellinger, LKML, kernel-janitors



On Sat, 12 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 12 Dec 2015 13:44:06 +0100
>
> The variable "pl" was declared and immediately assigned a return value
> from a function call in a separate statement.
>
> * Let us express the desired variable initialisation directly.
>
> * Avoid the repetition of the data type specification for the
>   involved memory allocation according to the Linux coding
>   style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/target/iscsi/iscsi_target_parameters.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> index e0b173d..3f3842f 100644
> --- a/drivers/target/iscsi/iscsi_target_parameters.c
> +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> @@ -200,9 +200,8 @@ free_param:
>  int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
>  {
>  	struct iscsi_param *param;
> -	struct iscsi_param_list *pl;
> +	struct iscsi_param_list *pl = kzalloc(sizeof(*pl), GFP_KERNEL);
>
> -	pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);

I don't see the benefit of this change, and the pattern assignment ->
failure test becomes more obscure.

julia

>  	if (!pl) {
>  		pr_err("Unable to allocate memory for"
>  				" struct iscsi_param_list.\n");
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_default_params()
  2015-12-12 14:45     ` Julia Lawall
@ 2015-12-12 15:02       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 15:02 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-scsi, target-devel, Nicholas A. Bellinger, LKML, kernel-janitors

>> @@ -200,9 +200,8 @@ free_param:
>>  int iscsi_create_default_params(struct iscsi_param_list **param_list_ptr)
>>  {
>>  	struct iscsi_param *param;
>> -	struct iscsi_param_list *pl;
>> +	struct iscsi_param_list *pl = kzalloc(sizeof(*pl), GFP_KERNEL);
>>
>> -	pl = kzalloc(sizeof(struct iscsi_param_list), GFP_KERNEL);
> 
> I don't see the benefit of this change, and the pattern assignment ->
> failure test becomes more obscure.

Are there any more software developers who prefer to specify
such a variable initialisation on a single line?

Does the proposed small source code reduction matter for you?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious in iscsi_check_valuelist_for_support()
  2015-12-12 14:45   ` [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious " SF Markus Elfring
@ 2015-12-12 17:17     ` walter harms
  0 siblings, 0 replies; 1373+ messages in thread
From: walter harms @ 2015-12-12 17:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-scsi, target-devel, Nicholas A. Bellinger, LKML,
	kernel-janitors, Julia Lawall



Am 12.12.2015 15:45, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 12 Dec 2015 15:04:57 +0100
> 
> The variable "acceptor_values" and "proposer_values" were initialized
> by null pointers and immediately assigned values from input parameters
> by separate statements.
> Let us express the desired variable initialisations directly.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/target/iscsi/iscsi_target_parameters.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> index 53e3345..fb6fd34 100644
> --- a/drivers/target/iscsi/iscsi_target_parameters.c
> +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> @@ -921,10 +921,7 @@ static char *iscsi_check_valuelist_for_support(
>  	char *value)
>  {
>  	char *tmp1, *tmp2;
> -	char *acceptor_values = NULL, *proposer_values = NULL;
> -
> -	acceptor_values = param->value;
> -	proposer_values = value;
> +	char *acceptor_values = param->value, *proposer_values = value;
>  

I do not thing that this is a good idea,
i find the first version more readable
but you are right the NULL can be removed.

just my 2 cents,

re,
 wh



>  	do {
>  		if (!proposer_values)

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 14:34   ` [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly SF Markus Elfring
@ 2015-12-12 19:49     ` Dan Carpenter
  2015-12-12 21:22       ` SF Markus Elfring
  2015-12-14  8:41       ` Johannes Thumshirn
  0 siblings, 2 replies; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-12 19:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-scsi, target-devel, Nicholas A. Bellinger, LKML,
	kernel-janitors, Julia Lawall

On Sat, Dec 12, 2015 at 03:34:50PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 12 Dec 2015 11:36:02 +0100
> 
> Omit the unnecessary setting to a null pointer for the variable "param"
> at the beginning of the function "iscsi_set_default_param"
> because it can be directly initialized with the return value
> from the function "kzalloc".
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/target/iscsi/iscsi_target_parameters.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> index 3a1f9a7..0a8bd3f 100644
> --- a/drivers/target/iscsi/iscsi_target_parameters.c
> +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> @@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
>  		char *name, char *value, u8 phase, u8 scope, u8 sender,
>  		u16 type_range, u8 use)
>  {
> -	struct iscsi_param *param = NULL;
> +	struct iscsi_param *param = kzalloc(sizeof(*param), GFP_KERNEL);
>  
> -	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
>  	if (!param) {
>  		pr_err("Unable to allocate memory for parameter.\n");
>  		goto out;

It's better to just get rid of the initialization but leave the
kzalloc() as-is for two reasons.

1)  Initializer code normally contains more bugs per line than other
    code.  I am thinking about dereferencing pointers before checking
    for NULL or not checking the allocation for failure.

2)  It puts a blank line between the allocation and the check for
    failure.  It's like a new paragraph.  The allocation and the check
    should be next to each other.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 19:49     ` Dan Carpenter
@ 2015-12-12 21:22       ` SF Markus Elfring
  2015-12-14  8:41       ` Johannes Thumshirn
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-12 21:22 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-scsi, target-devel, Nicholas A. Bellinger, LKML,
	kernel-janitors, Julia Lawall

>> @@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
>>  		char *name, char *value, u8 phase, u8 scope, u8 sender,
>>  		u16 type_range, u8 use)
>>  {
>> -	struct iscsi_param *param = NULL;
>> +	struct iscsi_param *param = kzalloc(sizeof(*param), GFP_KERNEL);
>>  
>> -	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
>>  	if (!param) {
>>  		pr_err("Unable to allocate memory for parameter.\n");
>>  		goto out;
> 
> It's better to just get rid of the initialization but leave the
> kzalloc() as-is for two reasons.
> 
> 1)  Initializer code normally contains more bugs per line than other
>     code.  I am thinking about dereferencing pointers before checking
>     for NULL or not checking the allocation for failure.

I can follow your concerns a bit.


> 2)  It puts a blank line between the allocation and the check for failure.

Is there a target conflict between "convenient" variable initialisation
in the declaration section and the function outline that seems to be checked
by the script "checkpatch.pl" to some degree while corresponding preferences
or recommendations are not mentioned in the document "CodingStyle"?


>     It's like a new paragraph.

I do not see the separation in a strict way so far.


>     The allocation and the check should be next to each other.

I find that these actions are still close enough in the discussed use case.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
  2015-12-12  9:16 ` [PATCH] uinput: Rename a jump label in uinput_ioctl_handler() SF Markus Elfring
@ 2015-12-12 22:23   ` Dmitry Torokhov
  0 siblings, 0 replies; 1373+ messages in thread
From: Dmitry Torokhov @ 2015-12-12 22:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, linux-input, kernel-janitors, Julia Lawall

Hi Markus,

On Sat, Dec 12, 2015 at 10:16:34AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 12 Dec 2015 10:06:00 +0100
> 
> This issue was detected by using the Coccinelle software.
> 
> Choose a jump label according to the current Linux coding style convention.

While I am mildly curious where you  found this Coccinelle script
complaining about label names I find the current name is perfectly fine.

Thanks.

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/input/misc/uinput.c | 66 ++++++++++++++++++++++-----------------------
>  1 file changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index 5adbced..466f62d 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -717,7 +717,7 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
>  	if (!udev->dev) {
>  		retval = uinput_allocate_device(udev);
>  		if (retval)
> -			goto out;
> +			goto unlock;
>  	}
>  
>  	switch (cmd) {
> @@ -725,82 +725,82 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
>  			if (put_user(UINPUT_VERSION,
>  				     (unsigned int __user *)p))
>  				retval = -EFAULT;
> -			goto out;
> +			goto unlock;
>  
>  		case UI_DEV_CREATE:
>  			retval = uinput_create_device(udev);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_DEV_DESTROY:
>  			uinput_destroy_device(udev);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_EVBIT:
>  			retval = uinput_set_bit(arg, evbit, EV_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_KEYBIT:
>  			retval = uinput_set_bit(arg, keybit, KEY_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_RELBIT:
>  			retval = uinput_set_bit(arg, relbit, REL_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_ABSBIT:
>  			retval = uinput_set_bit(arg, absbit, ABS_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_MSCBIT:
>  			retval = uinput_set_bit(arg, mscbit, MSC_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_LEDBIT:
>  			retval = uinput_set_bit(arg, ledbit, LED_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_SNDBIT:
>  			retval = uinput_set_bit(arg, sndbit, SND_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_FFBIT:
>  			retval = uinput_set_bit(arg, ffbit, FF_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_SWBIT:
>  			retval = uinput_set_bit(arg, swbit, SW_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_PROPBIT:
>  			retval = uinput_set_bit(arg, propbit, INPUT_PROP_MAX);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_SET_PHYS:
>  			if (udev->state == UIST_CREATED) {
>  				retval = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			phys = strndup_user(p, 1024);
>  			if (IS_ERR(phys)) {
>  				retval = PTR_ERR(phys);
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			kfree(udev->dev->phys);
>  			udev->dev->phys = phys;
> -			goto out;
> +			goto unlock;
>  
>  		case UI_BEGIN_FF_UPLOAD:
>  			retval = uinput_ff_upload_from_user(p, &ff_up);
>  			if (retval)
> -				goto out;
> +				goto unlock;
>  
>  			req = uinput_request_find(udev, ff_up.request_id);
>  			if (!req || req->code != UI_FF_UPLOAD ||
>  			    !req->u.upload.effect) {
>  				retval = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			ff_up.retval = 0;
> @@ -811,60 +811,60 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
>  				memset(&ff_up.old, 0, sizeof(struct ff_effect));
>  
>  			retval = uinput_ff_upload_to_user(p, &ff_up);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_BEGIN_FF_ERASE:
>  			if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
>  				retval = -EFAULT;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			req = uinput_request_find(udev, ff_erase.request_id);
>  			if (!req || req->code != UI_FF_ERASE) {
>  				retval = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			ff_erase.retval = 0;
>  			ff_erase.effect_id = req->u.effect_id;
>  			if (copy_to_user(p, &ff_erase, sizeof(ff_erase))) {
>  				retval = -EFAULT;
> -				goto out;
> +				goto unlock;
>  			}
>  
> -			goto out;
> +			goto unlock;
>  
>  		case UI_END_FF_UPLOAD:
>  			retval = uinput_ff_upload_from_user(p, &ff_up);
>  			if (retval)
> -				goto out;
> +				goto unlock;
>  
>  			req = uinput_request_find(udev, ff_up.request_id);
>  			if (!req || req->code != UI_FF_UPLOAD ||
>  			    !req->u.upload.effect) {
>  				retval = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			req->retval = ff_up.retval;
>  			uinput_request_done(udev, req);
> -			goto out;
> +			goto unlock;
>  
>  		case UI_END_FF_ERASE:
>  			if (copy_from_user(&ff_erase, p, sizeof(ff_erase))) {
>  				retval = -EFAULT;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			req = uinput_request_find(udev, ff_erase.request_id);
>  			if (!req || req->code != UI_FF_ERASE) {
>  				retval = -EINVAL;
> -				goto out;
> +				goto unlock;
>  			}
>  
>  			req->retval = ff_erase.retval;
>  			uinput_request_done(udev, req);
> -			goto out;
> +			goto unlock;
>  	}
>  
>  	size = _IOC_SIZE(cmd);
> @@ -874,15 +874,15 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
>  	case UI_GET_SYSNAME(0):
>  		if (udev->state != UIST_CREATED) {
>  			retval = -ENOENT;
> -			goto out;
> +			goto unlock;
>  		}
>  		name = dev_name(&udev->dev->dev);
>  		retval = uinput_str_to_user(p, name, size);
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	retval = -EINVAL;
> - out:
> + unlock:
>  	mutex_unlock(&udev->mutex);
>  	return retval;
>  }
> -- 
> 2.6.3
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (5 preceding siblings ...)
  2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
@ 2015-12-13 13:48 ` SF Markus Elfring
  2015-12-13 13:52   ` [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
                     ` (7 more replies)
  2015-12-14 22:10 ` [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection SF Markus Elfring
                   ` (88 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:48 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 14:40:14 +0100

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

Markus Elfring (7):
  Delete unnecessary goto statements in six functions
  Rename a jump label for ptlrpc_req_finished() calls
  Rename a jump label for a kfree(key) call
  Delete an unnecessary variable initialisation in mgc_process_recover_log()
  Less checks in mgc_process_recover_log() after error detection
  A few checks less in mgc_process_recover_log() after error detection
  Rename a jump label for module_put() calls

 drivers/staging/lustre/lustre/llite/file.c         |  26 ++---
 drivers/staging/lustre/lustre/llite/lloop.c        |   8 +-
 drivers/staging/lustre/lustre/llite/namei.c        |  13 +--
 drivers/staging/lustre/lustre/llite/xattr.c        |  20 ++--
 drivers/staging/lustre/lustre/mdc/mdc_request.c    | 124 ++++++++++-----------
 drivers/staging/lustre/lustre/mgc/mgc_request.c    |  53 ++++-----
 drivers/staging/lustre/lustre/osc/osc_request.c    |  52 ++++-----
 drivers/staging/lustre/lustre/ptlrpc/llog_client.c |  22 ++--
 8 files changed, 152 insertions(+), 166 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-13 13:52   ` SF Markus Elfring
  2015-12-15 14:27     ` Joe Perches
  2015-12-13 13:54   ` [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:52 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 09:30:47 +0100

Six goto statements referred to a source code position directly behind them.
Thus omit such unnecessary jumps.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/llite/namei.c     | 1 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c | 7 -------
 2 files changed, 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 64db5e8..2113dd4 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
 		retval = NULL;
 	else
 		retval = dentry;
-	goto out;
  out:
 	if (req)
 		ptlrpc_req_finished(req);
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 294c050..920b1e9 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1181,7 +1181,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1216,7 +1215,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1282,7 +1280,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1362,8 +1359,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
-
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1427,8 +1422,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
-
 out:
 	ptlrpc_req_finished(req);
 	return rc;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-13 13:52   ` [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
@ 2015-12-13 13:54   ` SF Markus Elfring
  2015-12-14  6:53     ` Dan Carpenter
  2015-12-13 13:55   ` [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:54 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 10:33:38 +0100

This issue was detected by using the Coccinelle software.

Choose a jump label according to the current Linux coding style convention.
I suggest to improve this implementation detail by the reuse of a script
like the following for the semantic patch language.

@rename_jump_label exists@
identifier work;
type return_type;
@@
 return_type work(...)
 {
 ... when any
 goto
-out
+finish_request
 ;
 ... when any
-out
+finish_request
 :
 ptlrpc_req_finished(...);
 ... when any
 }

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/llite/file.c         | 26 +++++------
 drivers/staging/lustre/lustre/llite/namei.c        | 12 ++---
 drivers/staging/lustre/lustre/llite/xattr.c        | 20 ++++----
 drivers/staging/lustre/lustre/mdc/mdc_request.c    | 54 +++++++++++-----------
 drivers/staging/lustre/lustre/osc/osc_request.c    | 28 +++++------
 drivers/staging/lustre/lustre/ptlrpc/llog_client.c | 22 ++++-----
 6 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 31cd6b3..b94df54 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -427,27 +427,27 @@ static int ll_intent_file_open(struct dentry *dentry, void *lmm,
 		*/
 		if (!it_disposition(itp, DISP_OPEN_OPEN) ||
 		     it_open_error(DISP_OPEN_OPEN, itp))
-			goto out;
+			goto finish_request;
 		ll_release_openhandle(inode, itp);
-		goto out;
+		goto finish_request;
 	}
 
 	if (it_disposition(itp, DISP_LOOKUP_NEG)) {
 		rc = -ENOENT;
-		goto out;
+		goto finish_request;
 	}
 
 	if (rc != 0 || it_open_error(DISP_OPEN_OPEN, itp)) {
 		rc = rc ? rc : it_open_error(DISP_OPEN_OPEN, itp);
 		CDEBUG(D_VFSTRACE, "lock enqueue: err: %d\n", rc);
-		goto out;
+		goto finish_request;
 	}
 
 	rc = ll_prep_inode(&inode, req, NULL, itp);
 	if (!rc && itp->d.lustre.it_lock_mode)
 		ll_set_lock_data(sbi->ll_md_exp, inode, itp, NULL);
 
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	ll_intent_drop_lock(itp);
 
@@ -2900,13 +2900,13 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 		oit.it_create_mode &= ~M_CHECK_STALE;
 		if (rc < 0) {
 			rc = ll_inode_revalidate_fini(inode, rc);
-			goto out;
+			goto finish_request;
 		}
 
 		rc = ll_revalidate_it_finish(req, &oit, inode);
 		if (rc != 0) {
 			ll_intent_release(&oit);
-			goto out;
+			goto finish_request;
 		}
 
 		/* Unlinked? Unhash dentry, so it is not picked up later by
@@ -2946,7 +2946,7 @@ static int __ll_inode_revalidate(struct dentry *dentry, __u64 ibits)
 
 		rc = ll_prep_inode(&inode, req, NULL, NULL);
 	}
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -3315,25 +3315,25 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
 	body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
 	if (body == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	lmmsize = body->eadatasize;
 	if (lmmsize == 0) /* empty layout */ {
 		rc = 0;
-		goto out;
+		goto finish_request;
 	}
 
 	lmm = req_capsule_server_sized_get(&req->rq_pill, &RMF_EADATA, lmmsize);
 	if (lmm == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	lvbdata = libcfs_kvzalloc(lmmsize, GFP_NOFS);
 	if (lvbdata == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	memcpy(lvbdata, lmm, lmmsize);
@@ -3345,7 +3345,7 @@ static int ll_layout_fetch(struct inode *inode, struct ldlm_lock *lock)
 	lock->l_lvb_len = lmmsize;
 	unlock_res_and_lock(lock);
 
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 2113dd4..7501f70 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -686,7 +686,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
 	rc = ll_prep_inode(&inode, request, dir->i_sb, it);
 	if (rc) {
 		inode = ERR_PTR(rc);
-		goto out;
+		goto finish_request;
 	}
 
 	LASSERT(hlist_empty(&inode->i_dentry));
@@ -697,7 +697,7 @@ static struct inode *ll_create_node(struct inode *dir, struct lookup_intent *it)
 	CDEBUG(D_DLMTRACE, "setting l_ast_data to inode %p (%lu/%u)\n",
 	       inode, inode->i_ino, inode->i_generation);
 	ll_set_lock_data(sbi->ll_md_exp, inode, it, NULL);
- out:
+ finish_request:
 	ptlrpc_req_finished(request);
 	return inode;
 }
@@ -960,13 +960,13 @@ static int ll_unlink(struct inode *dir, struct dentry *dentry)
 	rc = md_unlink(ll_i2sbi(dir)->ll_md_exp, op_data, &request);
 	ll_finish_md_op_data(op_data);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	ll_update_times(request, dir);
 	ll_stats_ops_tally(ll_i2sbi(dir), LPROC_LL_UNLINK, 1);
 
 	rc = ll_objects_destroy(request, dir);
- out:
+ finish_request:
 	ptlrpc_req_finished(request);
 	return rc;
 }
@@ -1059,11 +1059,11 @@ static int ll_link(struct dentry *old_dentry, struct inode *dir,
 	err = md_link(sbi->ll_md_exp, op_data, &request);
 	ll_finish_md_op_data(op_data);
 	if (err)
-		goto out;
+		goto finish_request;
 
 	ll_update_times(request, dir);
 	ll_stats_ops_tally(sbi, LPROC_LL_LINK, 1);
-out:
+finish_request:
 	ptlrpc_req_finished(request);
 	return err;
 }
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index 660b8ac..8d3287c 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -390,19 +390,19 @@ getxattr_nocache:
 		/* only detect the xattr size */
 		if (size == 0) {
 			rc = body->eadatasize;
-			goto out;
+			goto finish_request;
 		}
 
 		if (size < body->eadatasize) {
 			CERROR("server bug: replied size %u > %u\n",
 				body->eadatasize, (int)size);
 			rc = -ERANGE;
-			goto out;
+			goto finish_request;
 		}
 
 		if (body->eadatasize == 0) {
 			rc = -ENODATA;
-			goto out;
+			goto finish_request;
 		}
 
 		/* do not need swab xattr data */
@@ -410,7 +410,7 @@ getxattr_nocache:
 							body->eadatasize);
 		if (!xdata) {
 			rc = -EFAULT;
-			goto out;
+			goto finish_request;
 		}
 
 		memcpy(buffer, xdata, body->eadatasize);
@@ -425,14 +425,14 @@ getxattr_nocache:
 					(posix_acl_xattr_header *)buffer, rc);
 		if (IS_ERR(acl)) {
 			rc = PTR_ERR(acl);
-			goto out;
+			goto finish_request;
 		}
 
 		rc = ee_add(&sbi->ll_et, current_pid(), ll_inode2fid(inode),
 			    xattr_type, acl);
 		if (unlikely(rc < 0)) {
 			lustre_ext_acl_xattr_free(acl);
-			goto out;
+			goto finish_request;
 		}
 	}
 #endif
@@ -444,7 +444,7 @@ out_xattr:
 			ll_get_fsname(inode->i_sb, NULL, 0), rc);
 		sbi->ll_flags &= ~LL_SBI_USER_XATTR;
 	}
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -555,7 +555,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
 
 	rc = ll_getxattr_common(inode, NULL, buffer, size, OBD_MD_FLXATTRLS);
 	if (rc < 0)
-		goto out;
+		goto finish_request;
 
 	if (buffer != NULL) {
 		struct ll_sb_info *sbi = ll_i2sbi(inode);
@@ -589,7 +589,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
 
 	if (rc2 < 0) {
 		rc2 = 0;
-		goto out;
+		goto finish_request;
 	} else if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) {
 		const int prefix_len = sizeof(XATTR_LUSTRE_PREFIX) - 1;
 		const size_t name_len   = sizeof("lov") - 1;
@@ -608,7 +608,7 @@ ssize_t ll_listxattr(struct dentry *dentry, char *buffer, size_t size)
 		}
 		rc2 = total_len;
 	}
-out:
+finish_request:
 	ptlrpc_req_finished(request);
 	rc = rc + rc2;
 
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 920b1e9..2a76685 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -92,12 +92,12 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
 
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
 	if (body == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*rootfid = body->fid1;
@@ -105,7 +105,7 @@ static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
 	       "root fid="DFID", last_committed=%llu\n",
 	       PFID(rootfid),
 	       lustre_msg_get_last_committed(req->rq_repmsg));
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1084,17 +1084,17 @@ static int mdc_statfs(const struct lu_env *env,
 		/* check connection error first */
 		if (imp->imp_connect_error)
 			rc = imp->imp_connect_error;
-		goto out;
+		goto finish_request;
 	}
 
 	msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
 	if (msfs == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*osfs = *msfs;
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 output:
 	class_import_put(imp);
@@ -1163,7 +1163,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 					LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1172,7 +1172,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 	req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
 	if (req_hpk == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*req_hpk = *hpk;
@@ -1181,7 +1181,7 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1197,7 +1197,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
 					MDS_HSM_CT_REGISTER);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1207,7 +1207,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
 					      &RMF_MDS_HSM_ARCHIVE);
 	if (archive_mask == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*archive_mask = archives;
@@ -1215,7 +1215,7 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1246,18 +1246,18 @@ static int mdc_ioc_hsm_current_action(struct obd_export *exp,
 
 	rc = mdc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	req_hca = req_capsule_server_get(&req->rq_pill,
 					 &RMF_MDS_HSM_CURRENT_ACTION);
 	if (req_hca == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*hca = *req_hca;
 
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1272,7 +1272,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
 					MDS_HSM_CT_UNREGISTER);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
@@ -1280,7 +1280,7 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1311,17 +1311,17 @@ static int mdc_ioc_hsm_state_get(struct obd_export *exp,
 
 	rc = mdc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	req_hus = req_capsule_server_get(&req->rq_pill, &RMF_HSM_USER_STATE);
 	if (req_hus == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*hus = *req_hus;
 
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1352,14 +1352,14 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 	req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET);
 	if (req_hss == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 	*req_hss = *hss;
 
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1377,7 +1377,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT,
@@ -1398,7 +1398,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST);
 	if (req_hr == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 	*req_hr = hur->hur_request;
 
@@ -1406,7 +1406,7 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	req_hui = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM);
 	if (req_hui == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 	memcpy(req_hui, hur->hur_user_item,
 	       hur->hur_request.hr_itemcount * sizeof(struct hsm_user_item));
@@ -1415,14 +1415,14 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	req_opaque = req_capsule_client_get(&req->rq_pill, &RMF_GENERIC_DATA);
 	if (req_opaque == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 	memcpy(req_opaque, hur_data(hur), hur->hur_request.hr_data_len);
 
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index d6c1447..3a56fb7 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -291,12 +291,12 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
 
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
 	if (body == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	CDEBUG(D_INODE, "mode: %o\n", body->oa.o_mode);
@@ -306,7 +306,7 @@ static int osc_getattr(const struct lu_env *env, struct obd_export *exp,
 	oinfo->oi_oa->o_blksize = cli_brw_size(exp->exp_obd);
 	oinfo->oi_oa->o_valid |= OBD_MD_FLBLKSZ;
 
- out:
+ finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -336,18 +336,18 @@ static int osc_setattr(const struct lu_env *env, struct obd_export *exp,
 
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	body = req_capsule_server_get(&req->rq_pill, &RMF_OST_BODY);
 	if (body == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	lustre_get_wire_obdo(&req->rq_import->imp_connect_data, oinfo->oi_oa,
 			     &body->oa);
 
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -1276,7 +1276,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 
 	if (desc == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 	/* NB request now owns desc and will free it when it gets freed */
 
@@ -1407,7 +1407,7 @@ static int osc_brw_prep_request(int cmd, struct client_obd *cli,
 	*reqp = req;
 	return 0;
 
- out:
+ finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -2513,17 +2513,17 @@ static int osc_statfs(const struct lu_env *env, struct obd_export *exp,
 
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
 	if (msfs == NULL) {
 		rc = -EPROTO;
-		goto out;
+		goto finish_request;
 	}
 
 	*osfs = *msfs;
 
- out:
+ finish_request:
 	ptlrpc_req_finished(req);
 	return rc;
 }
@@ -2718,16 +2718,16 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
 		ptlrpc_request_set_replen(req);
 		rc = ptlrpc_queue_wait(req);
 		if (rc)
-			goto out;
+			goto finish_request;
 
 		reply = req_capsule_server_get(&req->rq_pill, &RMF_OBD_ID);
 		if (reply == NULL) {
 			rc = -EPROTO;
-			goto out;
+			goto finish_request;
 		}
 
 		*((u64 *)val) = *reply;
-	out:
+	finish_request:
 		ptlrpc_req_finished(req);
 		return rc;
 	} else if (KEY_IS(KEY_FIEMAP)) {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
index 5122205..150d2ec 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/llog_client.c
@@ -176,26 +176,26 @@ static int llog_client_next_block(const struct lu_env *env,
 	ptlrpc_request_set_replen(req);
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
 	if (body == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	/* The log records are swabbed as they are processed */
 	ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
 	if (ptr == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	*cur_idx = body->lgd_saved_index;
 	*cur_offset = body->lgd_cur_offset;
 
 	memcpy(buf, ptr, len);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 err_exit:
 	LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp);
@@ -233,22 +233,22 @@ static int llog_client_prev_block(const struct lu_env *env,
 
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	body = req_capsule_server_get(&req->rq_pill, &RMF_LLOGD_BODY);
 	if (body == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	ptr = req_capsule_server_get(&req->rq_pill, &RMF_EADATA);
 	if (ptr == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	memcpy(buf, ptr, len);
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 err_exit:
 	LLOG_CLIENT_EXIT(loghandle->lgh_ctxt, imp);
@@ -282,12 +282,12 @@ static int llog_client_read_header(const struct lu_env *env,
 	ptlrpc_request_set_replen(req);
 	rc = ptlrpc_queue_wait(req);
 	if (rc)
-		goto out;
+		goto finish_request;
 
 	hdr = req_capsule_server_get(&req->rq_pill, &RMF_LLOG_LOG_HDR);
 	if (hdr == NULL) {
 		rc = -EFAULT;
-		goto out;
+		goto finish_request;
 	}
 
 	memcpy(handle->lgh_hdr, hdr, sizeof(*hdr));
@@ -305,7 +305,7 @@ static int llog_client_read_header(const struct lu_env *env,
 		CERROR("you may need to re-run lconf --write_conf.\n");
 		rc = -EIO;
 	}
-out:
+finish_request:
 	ptlrpc_req_finished(req);
 err_exit:
 	LLOG_CLIENT_EXIT(handle->lgh_ctxt, imp);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-13 13:52   ` [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
  2015-12-13 13:54   ` [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
@ 2015-12-13 13:55   ` SF Markus Elfring
  2015-12-13 13:56   ` [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:55 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 10:56:35 +0100

This issue was detected by using the Coccinelle software.

Choose a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mdc/mdc_request.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 2a76685..2085ba6 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1125,7 +1125,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
 
 	if (!fid_is_sane(&gf->gf_fid)) {
 		rc = -EINVAL;
-		goto out;
+		goto free_key;
 	}
 
 	/* Val is struct getinfo_fid2path result plus path */
@@ -1133,20 +1133,19 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
 
 	rc = obd_get_info(NULL, exp, keylen, key, &vallen, gf, NULL);
 	if (rc != 0 && rc != -EREMOTE)
-		goto out;
+		goto free_key;
 
 	if (vallen <= sizeof(*gf)) {
 		rc = -EPROTO;
-		goto out;
+		goto free_key;
 	} else if (vallen > sizeof(*gf) + gf->gf_pathlen) {
 		rc = -EOVERFLOW;
-		goto out;
+		goto free_key;
 	}
 
 	CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n%s\n",
 	       PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
-
-out:
+free_key:
 	kfree(key);
 	return rc;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-13 13:55   ` [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring
@ 2015-12-13 13:56   ` SF Markus Elfring
  2015-12-13 13:57   ` [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:56 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 12:00:32 +0100

The variable "mne_swab" will eventually be set to an appropriate value
from a call of the ptlrpc_rep_need_swab() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 2c48847..da130f4 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1293,7 +1293,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 	struct page **pages;
 	int nrpages;
 	bool eof = true;
-	bool mne_swab = false;
+	bool mne_swab;
 	int i;
 	int ealen;
 	int rc;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2015-12-13 13:56   ` [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
@ 2015-12-13 13:57   ` SF Markus Elfring
  2015-12-14 11:00     ` Dan Carpenter
  2015-12-13 13:58   ` [PATCH 6/7] staging: lustre: A few checks less " SF Markus Elfring
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:57 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 12:21:17 +0100

A few checks would be performed by the mgc_process_recover_log() function
even if it is known already that the passed variable "pages" contained
a null pointer.

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

* Move assignments for the variables "eof" and "req" behind
  this memory allocation.

* Delete a sanity check then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index da130f4..f3b4c30 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1285,14 +1285,14 @@ 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;
 	struct ptlrpc_bulk_desc *desc;
 	struct page **pages;
 	int nrpages;
-	bool eof = true;
+	bool eof;
 	bool mne_swab;
 	int i;
 	int ealen;
@@ -1309,10 +1309,11 @@ static int mgc_process_recover_log(struct obd_device *obd,
 		nrpages = CONFIG_READ_NRPAGES_INIT;
 
 	pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
-	if (pages == NULL) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!pages)
+		return -ENOMEM;
+
+	req = NULL;
+	eof = true;
 
 	for (i = 0; i < nrpages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
@@ -1432,14 +1433,12 @@ out:
 	if (rc == 0 && !eof)
 		goto again;
 
-	if (pages) {
-		for (i = 0; i < nrpages; i++) {
-			if (pages[i] == NULL)
-				break;
-			__free_page(pages[i]);
-		}
-		kfree(pages);
+	for (i = 0; i < nrpages; i++) {
+		if (pages[i] == NULL)
+			break;
+		__free_page(pages[i]);
 	}
+	kfree(pages);
 	return rc;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2015-12-13 13:57   ` [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
@ 2015-12-13 13:58   ` SF Markus Elfring
  2015-12-13 14:00   ` [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:58 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 13:03:58 +0100

A few checks would be performed by the mgc_process_recover_log() function
even if it was determined that a call of the alloc_page() function failed.

* This implementation detail could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* Move the assignment for the variable "eof" behind the memory allocation.

* Delete another sanity check then.

* The variable "req" will eventually be set to an appropriate pointer
  from a call of the ptlrpc_request_alloc() function.
  Thus let us omit the explicit initialisation before.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 32 +++++++++++--------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index f3b4c30..7048722 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1312,17 +1312,15 @@ static int mgc_process_recover_log(struct obd_device *obd,
 	if (!pages)
 		return -ENOMEM;
 
-	req = NULL;
-	eof = true;
-
 	for (i = 0; i < nrpages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
 		if (pages[i] == NULL) {
 			rc = -ENOMEM;
-			goto out;
+			goto free_pages;
 		}
 	}
 
+	eof = true;
 again:
 	LASSERT(cld_is_recover(cld));
 	LASSERT(mutex_is_locked(&cld->cld_lock));
@@ -1330,12 +1328,12 @@ again:
 				   &RQF_MGS_CONFIG_READ);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto free_pages;
 	}
 
 	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);
@@ -1344,7 +1342,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;
@@ -1356,7 +1354,7 @@ again:
 				    MGS_BULK_PORTAL);
 	if (desc == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	for (i = 0; i < nrpages; i++)
@@ -1365,12 +1363,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
@@ -1384,18 +1382,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_CACHE_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);
@@ -1425,14 +1423,12 @@ again:
 
 		ealen -= PAGE_CACHE_SIZE;
 	}
-
-out:
-	if (req)
-		ptlrpc_req_finished(req);
+finish_request:
+	ptlrpc_req_finished(req);
 
 	if (rc == 0 && !eof)
 		goto again;
-
+free_pages:
 	for (i = 0; i < nrpages; i++) {
 		if (pages[i] == NULL)
 			break;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2015-12-13 13:58   ` [PATCH 6/7] staging: lustre: A few checks less " SF Markus Elfring
@ 2015-12-13 14:00   ` SF Markus Elfring
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-13 14:00 UTC (permalink / raw)
  To: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 13 Dec 2015 14:05:57 +0100

This issue was detected by using the Coccinelle software.

Choose a jump label according to the current Linux coding style convention.
I suggest to improve this implementation detail by the reuse of a script
like the following for the semantic patch language.

@rename_jump_label exists@
identifier target != put_module, work;
type return_type;
@@
 return_type work(...)
 {
 ... when any
 goto
-target
+put_module
 ;
 ... when any
-target
+put_module
 :
 module_put(...);
 ... when any
 }

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/llite/lloop.c     |  8 ++--
 drivers/staging/lustre/lustre/mdc/mdc_request.c | 52 ++++++++++++-------------
 drivers/staging/lustre/lustre/osc/osc_request.c | 24 ++++++------
 3 files changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c
index 420d391..ebeef3b 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -484,14 +484,14 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 
 	error = -EBUSY;
 	if (lo->lo_state != LLOOP_UNBOUND)
-		goto out;
+		goto put_module;
 
 	mapping = file->f_mapping;
 	inode = mapping->host;
 
 	error = -EINVAL;
 	if (!S_ISREG(inode->i_mode) || inode->i_sb->s_magic != LL_SUPER_MAGIC)
-		goto out;
+		goto put_module;
 
 	if (!(file->f_mode & FMODE_WRITE))
 		lo_flags |= LO_FLAGS_READ_ONLY;
@@ -500,7 +500,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 
 	if ((loff_t)(sector_t)size != size) {
 		error = -EFBIG;
-		goto out;
+		goto put_module;
 	}
 
 	/* remove all pages in cache so as dirty pages not to be existent. */
@@ -542,7 +542,7 @@ static int loop_set_fd(struct lloop_device *lo, struct file *unused,
 	down(&lo->lo_sem);
 	return 0;
 
-out:
+put_module:
 	/* This is safe: open() is still holding a reference. */
 	module_put(THIS_MODULE);
 	return error;
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 2085ba6..eaeca9a 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1734,7 +1734,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 	switch (cmd) {
 	case OBD_IOC_CHANGELOG_SEND:
 		rc = mdc_ioc_changelog_send(obd, karg);
-		goto out;
+		goto put_module;
 	case OBD_IOC_CHANGELOG_CLEAR: {
 		struct ioc_changelog *icc = karg;
 		struct changelog_setinfo cs = {
@@ -1745,47 +1745,47 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		rc = obd_set_info_async(NULL, exp, strlen(KEY_CHANGELOG_CLEAR),
 					KEY_CHANGELOG_CLEAR, sizeof(cs), &cs,
 					NULL);
-		goto out;
+		goto put_module;
 	}
 	case OBD_IOC_FID2PATH:
 		rc = mdc_ioc_fid2path(exp, karg);
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_CT_START:
 		rc = mdc_ioc_hsm_ct_start(exp, karg);
 		/* ignore if it was already registered on this MDS. */
 		if (rc == -EEXIST)
 			rc = 0;
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_PROGRESS:
 		rc = mdc_ioc_hsm_progress(exp, karg);
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_STATE_GET:
 		rc = mdc_ioc_hsm_state_get(exp, karg);
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_STATE_SET:
 		rc = mdc_ioc_hsm_state_set(exp, karg);
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_ACTION:
 		rc = mdc_ioc_hsm_current_action(exp, karg);
-		goto out;
+		goto put_module;
 	case LL_IOC_HSM_REQUEST:
 		rc = mdc_ioc_hsm_request(exp, karg);
-		goto out;
+		goto put_module;
 	case OBD_IOC_CLIENT_RECOVER:
 		rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0);
 		if (rc < 0)
-			goto out;
+			goto put_module;
 		rc = 0;
-		goto out;
+		goto put_module;
 	case IOC_OSC_SET_ACTIVE:
 		rc = ptlrpc_set_import_active(imp, data->ioc_offset);
-		goto out;
+		goto put_module;
 	case OBD_IOC_POLL_QUOTACHECK:
 		rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg);
-		goto out;
+		goto put_module;
 	case OBD_IOC_PING_TARGET:
 		rc = ptlrpc_obd_ping(obd);
-		goto out;
+		goto put_module;
 	/*
 	 * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
 	 * LMV instead of MDC. But when the cluster is upgraded from 1.8,
@@ -1798,7 +1798,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 
 		if (*((__u32 *) data->ioc_inlbuf2) != 0) {
 			rc = -ENODEV;
-			goto out;
+			goto put_module;
 		}
 
 		/* copy UUID */
@@ -1806,24 +1806,24 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 				 min_t(size_t, data->ioc_plen2,
 					       sizeof(struct obd_uuid)))) {
 			rc = -EFAULT;
-			goto out;
+			goto put_module;
 		}
 
 		rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
 				cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
 				0);
 		if (rc != 0)
-			goto out;
+			goto put_module;
 
 		if (copy_to_user(data->ioc_pbuf1, &stat_buf,
 				 min_t(size_t, data->ioc_plen1,
 					       sizeof(stat_buf)))) {
 			rc = -EFAULT;
-			goto out;
+			goto put_module;
 		}
 
 		rc = 0;
-		goto out;
+		goto put_module;
 	}
 	case OBD_IOC_QUOTACTL: {
 		struct if_quotactl *qctl = karg;
@@ -1832,7 +1832,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
 		if (!oqctl) {
 			rc = -ENOMEM;
-			goto out;
+			goto put_module;
 		}
 
 		QCTL_COPY(oqctl, qctl);
@@ -1844,26 +1844,26 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		}
 
 		kfree(oqctl);
-		goto out;
+		goto put_module;
 	}
 	case LL_IOC_GET_CONNECT_FLAGS:
 		if (copy_to_user(uarg, exp_connect_flags_ptr(exp),
 				 sizeof(*exp_connect_flags_ptr(exp)))) {
 			rc = -EFAULT;
-			goto out;
+			goto put_module;
 		}
 
 		rc = 0;
-		goto out;
+		goto put_module;
 	case LL_IOC_LOV_SWAP_LAYOUTS:
 		rc = mdc_ioc_swap_layouts(exp, karg);
-		goto out;
+		goto put_module;
 	default:
 		CERROR("unrecognised ioctl: cmd = %#x\n", cmd);
 		rc = -ENOTTY;
-		goto out;
+		goto put_module;
 	}
-out:
+put_module:
 	module_put(THIS_MODULE);
 
 	return rc;
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index 3a56fb7..3ee1ff8 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2611,7 +2611,7 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		len = 0;
 		if (obd_ioctl_getdata(&buf, &len, uarg)) {
 			err = -EINVAL;
-			goto out;
+			goto put_module;
 		}
 
 		data = (struct obd_ioctl_data *)buf;
@@ -2619,13 +2619,13 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		if (sizeof(*desc) > data->ioc_inllen1) {
 			obd_ioctl_freedata(buf, len);
 			err = -EINVAL;
-			goto out;
+			goto put_module;
 		}
 
 		if (data->ioc_inllen2 < sizeof(uuid)) {
 			obd_ioctl_freedata(buf, len);
 			err = -EINVAL;
-			goto out;
+			goto put_module;
 		}
 
 		desc = (struct lov_desc *)data->ioc_inlbuf1;
@@ -2643,39 +2643,39 @@ static int osc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 		if (err)
 			err = -EFAULT;
 		obd_ioctl_freedata(buf, len);
-		goto out;
+		goto put_module;
 	}
 	case LL_IOC_LOV_SETSTRIPE:
 		err = obd_alloc_memmd(exp, karg);
 		if (err > 0)
 			err = 0;
-		goto out;
+		goto put_module;
 	case LL_IOC_LOV_GETSTRIPE:
 		err = osc_getstripe(karg, uarg);
-		goto out;
+		goto put_module;
 	case OBD_IOC_CLIENT_RECOVER:
 		err = ptlrpc_recover_import(obd->u.cli.cl_import,
 					    data->ioc_inlbuf1, 0);
 		if (err > 0)
 			err = 0;
-		goto out;
+		goto put_module;
 	case IOC_OSC_SET_ACTIVE:
 		err = ptlrpc_set_import_active(obd->u.cli.cl_import,
 					       data->ioc_offset);
-		goto out;
+		goto put_module;
 	case OBD_IOC_POLL_QUOTACHECK:
 		err = osc_quota_poll_check(exp, karg);
-		goto out;
+		goto put_module;
 	case OBD_IOC_PING_TARGET:
 		err = ptlrpc_obd_ping(obd);
-		goto out;
+		goto put_module;
 	default:
 		CDEBUG(D_INODE, "unrecognised ioctl %#x by %s\n",
 		       cmd, current_comm());
 		err = -ENOTTY;
-		goto out;
+		goto put_module;
 	}
-out:
+put_module:
 	module_put(THIS_MODULE);
 	return err;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-11 18:24   ` [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection SF Markus Elfring
@ 2015-12-14  0:27     ` Sergey Senozhatsky
  2015-12-14  6:58       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Sergey Senozhatsky @ 2015-12-14  0:27 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: LKML, Minchan Kim, Nitin Gupta, Sergey Senozhatsky,
	kernel-janitors, Julia Lawall

On (12/11/15 19:24), SF Markus Elfring wrote:
[..]
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 47915d7..69d7fcd 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -652,9 +652,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  	size_t clen;
>  	unsigned long handle;
>  	struct page *page;
> -	unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
> +	unsigned char *user_mem, *cmem, *src, *uncmem;
>  	struct zram_meta *meta = zram->meta;
> -	struct zcomp_strm *zstrm = NULL;
> +	struct zcomp_strm *zstrm;
>  	unsigned long alloced_pages;
>  
>  	page = bvec->bv_page;
> @@ -664,13 +664,11 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  		 * before to write the changes.
>  		 */
>  		uncmem = kmalloc(PAGE_SIZE, GFP_NOIO);
> -		if (!uncmem) {
> -			ret = -ENOMEM;
> -			goto out;
> -		}
> +		if (!uncmem)
> +			return -ENOMEM;

ok.

>  		ret = zram_decompress_page(zram, uncmem, index);
>  		if (ret)
> -			goto out;
> +			goto free_uncmem;

here and later, I don't want to split `out' label.
you still need to do both 'if zstrm' and 'if is_partial_io' checks anyway, what's the gain?
the more labels we have the trickier it may get.

>  	}
>  
>  	zstrm = zcomp_strm_find(zram->comp);
> @@ -696,7 +694,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  
>  		atomic64_inc(&zram->stats.zero_pages);
>  		ret = 0;
> -		goto out;
> +		goto check_strm;
>  	}
>  
>  	ret = zcomp_compress(zram->comp, zstrm, uncmem, &clen);
> @@ -708,7 +706,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  
>  	if (unlikely(ret)) {
>  		pr_err("Compression failed! err=%d\n", ret);
> -		goto out;
> +		goto check_strm;
>  	}
>  	src = zstrm->buffer;
>  	if (unlikely(clen > max_zpage_size)) {
> @@ -722,7 +720,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  		pr_err("Error allocating memory for compressed page: %u, size=%zu\n",
>  			index, clen);
>  		ret = -ENOMEM;
> -		goto out;
> +		goto check_strm;
>  	}
>  
>  	alloced_pages = zs_get_total_pages(meta->mem_pool);
> @@ -731,7 +729,7 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  	if (zram->limit_pages && alloced_pages > zram->limit_pages) {
>  		zs_free(meta->mem_pool, handle);
>  		ret = -ENOMEM;
> -		goto out;
> +		goto check_strm;
>  	}
>  
>  	cmem = zs_map_object(meta->mem_pool, handle, ZS_MM_WO);
> @@ -762,11 +760,13 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>  	/* Update stats */
>  	atomic64_add(clen, &zram->stats.compr_data_size);
>  	atomic64_inc(&zram->stats.pages_stored);
> -out:
> +check_strm:
>  	if (zstrm)
>  		zcomp_strm_release(zram->comp, zstrm);
> -	if (is_partial_io(bvec))
> +	if (is_partial_io(bvec)) {
> +free_uncmem:
>  		kfree(uncmem);
> +	}

a label inside of `if'?   no.
keep it the way it is please.

>  	return ret;
>  }

	-ss

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] z2ram: Delete a jump label in z2_init()
  2015-12-11 18:26   ` [PATCH 2/2] z2ram: Delete a jump label in z2_init() SF Markus Elfring
@ 2015-12-14  0:36     ` Sergey Senozhatsky
  2015-12-14  9:10       ` Geert Uytterhoeven
  0 siblings, 1 reply; 1373+ messages in thread
From: Sergey Senozhatsky @ 2015-12-14  0:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: LKML, Minchan Kim, Nitin Gupta, Sergey Senozhatsky,
	kernel-janitors, Julia Lawall, Andrew Morton, Jens Axboe,
	Geert Uytterhoeven

Cc Jens, Andrew, Geert

On (12/11/15 19:26), SF Markus Elfring wrote:
>
> This issue was detected by using the Coccinelle software.
> 
> * Let us return directly if a call of the function "register_blkdev" failed.
> 
> * Remove the jump label "err" then.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/z2ram.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
> index 968f9e5..b07581d 100644
> --- a/drivers/block/z2ram.c
> +++ b/drivers/block/z2ram.c
> @@ -345,9 +345,8 @@ z2_init(void)
>      if (!MACH_IS_AMIGA)
>  	return -ENODEV;
>  
> -    ret = -EBUSY;
>      if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
> -	goto err;
> +	return -EBUSY;
>  
>      ret = -ENOMEM;
>      z2ram_gendisk = alloc_disk(1);
> @@ -374,7 +373,6 @@ out_queue:
>      put_disk(z2ram_gendisk);
>  out_disk:
>      unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
> -err:
>      return ret;
>  }

z2ram and zram are different drivers, but the change looks
ok to me.

z2ram can be improved in many ways, so my question is - do
people still use it?

	-ss

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-13 13:54   ` [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
@ 2015-12-14  6:53     ` Dan Carpenter
  2015-12-14  9:08       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-14  6:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, Julia Lawall, kernel-janitors, LKML

Markus, please stop sending these things to rename out labels unless
there is a bug.  CodingStyle allows out labels.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-14  0:27     ` Sergey Senozhatsky
@ 2015-12-14  6:58       ` SF Markus Elfring
  2015-12-14  7:17         ` Julia Lawall
  2015-12-14 10:03         ` Sergey Senozhatsky
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14  6:58 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: LKML, Minchan Kim, Nitin Gupta, kernel-janitors, Julia Lawall

>> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
>> index 47915d7..69d7fcd 100644
>> --- a/drivers/block/zram/zram_drv.c
>> +++ b/drivers/block/zram/zram_drv.c
>> @@ -652,9 +652,9 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>>  	size_t clen;
>>  	unsigned long handle;
>>  	struct page *page;
>> -	unsigned char *user_mem, *cmem, *src, *uncmem = NULL;
>> +	unsigned char *user_mem, *cmem, *src, *uncmem;
>>  	struct zram_meta *meta = zram->meta;
>> -	struct zcomp_strm *zstrm = NULL;
>> +	struct zcomp_strm *zstrm;
>>  	unsigned long alloced_pages;
>>  
>>  	page = bvec->bv_page;
>> @@ -664,13 +664,11 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>>  		 * before to write the changes.
>>  		 */
>>  		uncmem = kmalloc(PAGE_SIZE, GFP_NOIO);
>> -		if (!uncmem) {
>> -			ret = -ENOMEM;
>> -			goto out;
>> -		}
>> +		if (!uncmem)
>> +			return -ENOMEM;
> 
> ok.

Thanks for your terse acknowledgement.


>>  		ret = zram_decompress_page(zram, uncmem, index);
>>  		if (ret)
>> -			goto out;
>> +			goto free_uncmem;
> 
> here and later, I don't want to split `out' label.

I guess that corresponding software design concerns can evolve a bit.


> you still need to do both 'if zstrm' and 'if is_partial_io' checks anyway, what's the gain?

How are the chances to reduce the number of dispensable sanity checks?


> the more labels we have the trickier it may get.

I hope that more unique jump labels can make the involved exception handling also clearer.


>> @@ -762,11 +760,13 @@ static int zram_bvec_write(struct zram *zram, struct bio_vec *bvec, u32 index,
>>  	/* Update stats */
>>  	atomic64_add(clen, &zram->stats.compr_data_size);
>>  	atomic64_inc(&zram->stats.pages_stored);
>> -out:
>> +check_strm:
>>  	if (zstrm)
>>  		zcomp_strm_release(zram->comp, zstrm);
>> -	if (is_partial_io(bvec))
>> +	if (is_partial_io(bvec)) {
>> +free_uncmem:
>>  		kfree(uncmem);
>> +	}
> 
> a label inside of `if'?   no.

Do any more software developers find such an use case interesting?


> keep it the way it is please.

I suggest to make the affected exception handling a bit more efficient.
Such source code fine-tuning has got a few special consequences.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-14  6:58       ` SF Markus Elfring
@ 2015-12-14  7:17         ` Julia Lawall
  2015-12-14 10:03         ` Sergey Senozhatsky
  1 sibling, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2015-12-14  7:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergey Senozhatsky, LKML, Minchan Kim, Nitin Gupta, kernel-janitors

> I suggest to make the affected exception handling a bit more efficient.
> Such source code fine-tuning has got a few special consequences.

Exception handling is by definition exceptional, and thus its efficiency 
is rarely important.  What is important is that it should be correct, and 
ideally clearly correct, so that someone can check its correctness easily.  
Optimizations, if they have any effect at all, typically make the 
correctness less obvious.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 19:49     ` Dan Carpenter
  2015-12-12 21:22       ` SF Markus Elfring
@ 2015-12-14  8:41       ` Johannes Thumshirn
  2015-12-14 11:38         ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Johannes Thumshirn @ 2015-12-14  8:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, linux-scsi, target-devel,
	Nicholas A. Bellinger, LKML, kernel-janitors, Julia Lawall

On Sat, Dec 12, 2015 at 10:49:40PM +0300, Dan Carpenter wrote:
> On Sat, Dec 12, 2015 at 03:34:50PM +0100, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 12 Dec 2015 11:36:02 +0100
> > 
> > Omit the unnecessary setting to a null pointer for the variable "param"
> > at the beginning of the function "iscsi_set_default_param"
> > because it can be directly initialized with the return value
> > from the function "kzalloc".
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  drivers/target/iscsi/iscsi_target_parameters.c | 3 +--
> >  1 file changed, 1 insertion(+), 2 deletions(-)
> > 
> > diff --git a/drivers/target/iscsi/iscsi_target_parameters.c b/drivers/target/iscsi/iscsi_target_parameters.c
> > index 3a1f9a7..0a8bd3f 100644
> > --- a/drivers/target/iscsi/iscsi_target_parameters.c
> > +++ b/drivers/target/iscsi/iscsi_target_parameters.c
> > @@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
> >  		char *name, char *value, u8 phase, u8 scope, u8 sender,
> >  		u16 type_range, u8 use)
> >  {
> > -	struct iscsi_param *param = NULL;
> > +	struct iscsi_param *param = kzalloc(sizeof(*param), GFP_KERNEL);
> >  
> > -	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
> >  	if (!param) {
> >  		pr_err("Unable to allocate memory for parameter.\n");
> >  		goto out;
> 
> It's better to just get rid of the initialization but leave the
> kzalloc() as-is for two reasons.
> 
> 1)  Initializer code normally contains more bugs per line than other
>     code.  I am thinking about dereferencing pointers before checking
>     for NULL or not checking the allocation for failure.
> 
> 2)  It puts a blank line between the allocation and the check for
>     failure.  It's like a new paragraph.  The allocation and the check
>     should be next to each other.

I agree with Dan here. Please don't do it.

@@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
 		char *name, char *value, u8 phase, u8 scope, u8 sender,
 		u16 type_range, u8 use)
 {
-	struct iscsi_param *param = NULL;
+	struct iscsi_param *param;
 
	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
 	if (!param) {
 		pr_err("Unable to allocate memory for parameter.\n");


This way it would be _far_ more readable. IMHO one should have a 1 action per
line of code style and only assign values in at declaration time if really 
necessary.

But what is the benefit from this? Is it fixing a (hypothetical) bug? I somehow
fail to see it.

Thanks,
	Johannes

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-14  6:53     ` Dan Carpenter
@ 2015-12-14  9:08       ` SF Markus Elfring
  2015-12-14  9:31         ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14  9:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, Julia Lawall, kernel-janitors, LKML

> Markus, please stop sending these things to rename out labels unless
> there is a bug.  CodingStyle allows out labels.

How does this feedback fit to information like the following?

"…
Chapter 7: …
…
Choose label names which say what the goto does or why the goto exists.
… Avoid using GW-BASIC names …
…"

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] z2ram: Delete a jump label in z2_init()
  2015-12-14  0:36     ` Sergey Senozhatsky
@ 2015-12-14  9:10       ` Geert Uytterhoeven
  0 siblings, 0 replies; 1373+ messages in thread
From: Geert Uytterhoeven @ 2015-12-14  9:10 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: SF Markus Elfring, LKML, Minchan Kim, Nitin Gupta,
	kernel-janitors, Julia Lawall, Andrew Morton, Jens Axboe,
	Linux/m68k

On Mon, Dec 14, 2015 at 1:36 AM, Sergey Senozhatsky
<sergey.senozhatsky.work@gmail.com> wrote:
> Cc Jens, Andrew, Geert
>
> On (12/11/15 19:26), SF Markus Elfring wrote:
>>
>> This issue was detected by using the Coccinelle software.
>>
>> * Let us return directly if a call of the function "register_blkdev" failed.
>>
>> * Remove the jump label "err" then.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

>> ---
>>  drivers/block/z2ram.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
>> index 968f9e5..b07581d 100644
>> --- a/drivers/block/z2ram.c
>> +++ b/drivers/block/z2ram.c
>> @@ -345,9 +345,8 @@ z2_init(void)
>>      if (!MACH_IS_AMIGA)
>>       return -ENODEV;
>>
>> -    ret = -EBUSY;
>>      if (register_blkdev(Z2RAM_MAJOR, DEVICE_NAME))
>> -     goto err;
>> +     return -EBUSY;
>>
>>      ret = -ENOMEM;
>>      z2ram_gendisk = alloc_disk(1);
>> @@ -374,7 +373,6 @@ out_queue:
>>      put_disk(z2ram_gendisk);
>>  out_disk:
>>      unregister_blkdev(Z2RAM_MAJOR, DEVICE_NAME);
>> -err:
>>      return ret;
>>  }
>
> z2ram and zram are different drivers, but the change looks
> ok to me.
>
> z2ram can be improved in many ways, so my question is - do
> people still use it?

I think it's still used.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-14  9:08       ` SF Markus Elfring
@ 2015-12-14  9:31         ` Dan Carpenter
  2015-12-14 10:03           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-14  9:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

On Mon, Dec 14, 2015 at 10:08:03AM +0100, SF Markus Elfring wrote:
> > Markus, please stop sending these things to rename out labels unless
> > there is a bug.  CodingStyle allows out labels.
> 
> How does this feedback fit to information like the following?
> 
> "…
> Chapter 7: …
> …
> Choose label names which say what the goto does or why the goto exists.

A lot of people think "out" says what the goto does and why it exists.
I personally don't agree with them but if you look at when I complain
about it, it's almost always when it causes a bug.

> … Avoid using GW-BASIC names …

Those when people just use numbers for their label names instead of
words like out1, out2, out4, out5.  It's a different thing.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-14  6:58       ` SF Markus Elfring
  2015-12-14  7:17         ` Julia Lawall
@ 2015-12-14 10:03         ` Sergey Senozhatsky
  2015-12-14 14:03           ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Sergey Senozhatsky @ 2015-12-14 10:03 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergey Senozhatsky, LKML, Minchan Kim, Nitin Gupta,
	kernel-janitors, Julia Lawall, Andrew Morton

On (12/14/15 07:58), SF Markus Elfring wrote:
[..]
> > keep it the way it is please.
> 
> I suggest to make the affected exception handling a bit more efficient.
> Such source code fine-tuning has got a few special consequences.

by 'more efficient' you mean saving cpu cycles on 'bvec->bv_len != PAGE_SIZE'
comparison in exception/error path?

...
check_strm:
	if (zstrm)
		zcomp_strm_release(zram->comp, zstrm);
	if (is_partial_io(bvec)) {
free_uncmem:
		kfree(uncmem);
	}
...


no.

	-ss

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-14  9:31         ` Dan Carpenter
@ 2015-12-14 10:03           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 10:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

>>> Markus, please stop sending these things to rename out labels unless
>>> there is a bug.  CodingStyle allows out labels.
>>
>> How does this feedback fit to information like the following?
>>
>> "…
>> Chapter 7: …
>> …
>> Choose label names which say what the goto does or why the goto exists.
> 
> A lot of people think "out" says what the goto does and why it exists.

I have got the impression that this short identifier is only partly appropriate.


> I personally don't agree with them

I guess that my opinion goes into a similar direction here.


> but if you look at when I complain about it, it's almost always
> when it causes a bug.

I agree that the combination with bug fixing is more appealing
than an attempt to improve coding style applications.


>> … Avoid using GW-BASIC names …
> 
> Those when people just use numbers for their label names instead of
> words like out1, out2, out4, out5.  It's a different thing.

The difference is not so clear for me as it appears to you.
How many software developers can still remember habits around
the selection of such identifiers from GW-BASIC times?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-13 13:57   ` [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
@ 2015-12-14 11:00     ` Dan Carpenter
  2015-12-14 12:04       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-14 11:00 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, Julia Lawall, kernel-janitors, LKML

On Sun, Dec 13, 2015 at 02:57:38PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 13 Dec 2015 12:21:17 +0100
> 
> A few checks would be performed by the mgc_process_recover_log() function
> even if it is known already that the passed variable "pages" contained
> a null pointer.
> 
> * Let us return directly if a call of the kcalloc() function failed.
> 
> * Move assignments for the variables "eof" and "req" behind
>   this memory allocation.

Why?  Then in the next patch it moves again.  It's like cup shuffle to
read these patches sometimes.

regards,
dan carpenter



^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-14  8:41       ` Johannes Thumshirn
@ 2015-12-14 11:38         ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 11:38 UTC (permalink / raw)
  To: Johannes Thumshirn
  Cc: Dan Carpenter, linux-scsi, target-devel, Nicholas A. Bellinger,
	LKML, kernel-janitors, Julia Lawall

> @@ -127,9 +127,8 @@ static struct iscsi_param *iscsi_set_default_param(struct iscsi_param_list *para
>  		char *name, char *value, u8 phase, u8 scope, u8 sender,
>  		u16 type_range, u8 use)
>  {
> -	struct iscsi_param *param = NULL;
> +	struct iscsi_param *param;
>  
> 	param = kzalloc(sizeof(struct iscsi_param), GFP_KERNEL);
>  	if (!param) {
>  		pr_err("Unable to allocate memory for parameter.\n");
> 
> 
> This way it would be _far_ more readable.

I guess that there are some opinions available for this implementation detail.


> IMHO one should have a 1 action per line of code style

How often do you care for such style issues?


> and only assign values in at declaration time if really necessary.

Which is or might become the official Linux coding style recommendation
for this aspect?


> But what is the benefit from this? Is it fixing a (hypothetical) bug?

I find the shown null pointer initialisation just needless.

Regards,
Markus


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 11:00     ` Dan Carpenter
@ 2015-12-14 12:04       ` SF Markus Elfring
  2015-12-14 12:38         ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 12:04 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, Julia Lawall, kernel-janitors, LKML

>> A few checks would be performed by the mgc_process_recover_log() function
>> even if it is known already that the passed variable "pages" contained
>> a null pointer.
>>
>> * Let us return directly if a call of the kcalloc() function failed.
>>
>> * Move assignments for the variables "eof" and "req" behind
>>   this memory allocation.
> 
> Why?

The positions of their initialisation depends on the selected exception 
handling implementation, doesn't it?

Can you accept the proposed changes around the affected memory allocations?


> Then in the next patch it moves again.

This detail is a matter of patch granularity.


> It's like cup shuffle to read these patches sometimes.

Do you prefer to stash any changes together for a bigger update step?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 12:04       ` SF Markus Elfring
@ 2015-12-14 12:38         ` Dan Carpenter
  2015-12-14 12:45           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-14 12:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

On Mon, Dec 14, 2015 at 01:04:14PM +0100, SF Markus Elfring wrote:
> >> A few checks would be performed by the mgc_process_recover_log() function
> >> even if it is known already that the passed variable "pages" contained
> >> a null pointer.
> >>
> >> * Let us return directly if a call of the kcalloc() function failed.
> >>
> >> * Move assignments for the variables "eof" and "req" behind
> >>   this memory allocation.
> > 
> > Why?
> 
> The positions of their initialisation depends on the selected exception 
> handling implementation, doesn't it?
> 
> Can you accept the proposed changes around the affected memory allocations?
> 

Just leave it as-is if there is no reason.

> 
> > Then in the next patch it moves again.
> 
> This detail is a matter of patch granularity.
> 
> 
> > It's like cup shuffle to read these patches sometimes.
> 
> Do you prefer to stash any changes together for a bigger update step?

Yes.  Patches 5 and 6 would be easier to review if they were folded into
one patch.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 12:38         ` Dan Carpenter
@ 2015-12-14 12:45           ` SF Markus Elfring
  2015-12-14 13:57             ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 12:45 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

>> Can you accept the proposed changes around the affected memory allocations?
> 
> Just leave it as-is if there is no reason.

I suggest to make the implementation of the function "mgc_process_recover_log"
a bit more efficient.


>> Do you prefer to stash any changes together for a bigger update step?
> 
> Yes.  Patches 5 and 6 would be easier to review if they were folded into
> one patch.

I do not like patch squashing for my update suggestions here.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 12:45           ` SF Markus Elfring
@ 2015-12-14 13:57             ` Dan Carpenter
  2015-12-14 17:43               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-14 13:57 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

On Mon, Dec 14, 2015 at 01:45:11PM +0100, SF Markus Elfring wrote:
> >> Do you prefer to stash any changes together for a bigger update step?
> > 
> > Yes.  Patches 5 and 6 would be easier to review if they were folded into
> > one patch.
> 
> I do not like patch squashing for my update suggestions here.

I am a maintainer in drivers/staging.  I am telling you what you need to
do if you want us to apply your patch.  What you do with that
information is up to you.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-14 10:03         ` Sergey Senozhatsky
@ 2015-12-14 14:03           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 14:03 UTC (permalink / raw)
  To: Sergey Senozhatsky
  Cc: LKML, Minchan Kim, Nitin Gupta, kernel-janitors, Julia Lawall,
	Andrew Morton

>> I suggest to make the affected exception handling a bit more efficient.
>> Such source code fine-tuning has got a few special consequences.
> 
> by 'more efficient' you mean saving cpu cycles on 'bvec->bv_len != PAGE_SIZE'
> comparison in exception/error path?

Yes …


> ...
> check_strm:
> 	if (zstrm)
> 		zcomp_strm_release(zram->comp, zstrm);
> 	if (is_partial_io(bvec)) {
> free_uncmem:
> 		kfree(uncmem);
> 	}
> ...

I propose to jump over two sanity checks.


> no.

Thanks for your feedback.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 13:57             ` Dan Carpenter
@ 2015-12-14 17:43               ` SF Markus Elfring
  2015-12-15 11:42                 ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 17:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

>> I do not like patch squashing for my update suggestions here.
> 
> I am a maintainer in drivers/staging.

Thanks for this information.


> I am telling you what you need to do if you want us to apply your patch.

I am still waiting for a bit more constructive feedback for this
patch series. How many days should I wait before I should send adjusted
update suggestions for this approach?


> What you do with that information is up to you.

Our software development dialogue seems to trigger special
challenges between us so far.
Are you generally willing to change the exception handling for
the memory allocations in the function "mgc_process_recover_log"
at all?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (6 preceding siblings ...)
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-14 22:10 ` SF Markus Elfring
  2015-12-14 22:20   ` Scott Wood
  2015-12-23  9:43 ` [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() " SF Markus Elfring
                   ` (87 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-14 22:10 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman, Paul Mackerras, linuxppc-dev
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 14 Dec 2015 23:01:32 +0100

A status check was performed by the fsl_get_immr() function even if it
was known already that a system setting did not fit to the expectations.

This implementation detail could be improved by an adjustment for
a jump label according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/boot/fsl-soc.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/boot/fsl-soc.c b/arch/powerpc/boot/fsl-soc.c
index b835ed6..ff1dae3 100644
--- a/arch/powerpc/boot/fsl-soc.c
+++ b/arch/powerpc/boot/fsl-soc.c
@@ -34,24 +34,24 @@ u32 *fsl_get_immr(void)
 			naddr = 2;
 
 		if (naddr != 1 && naddr != 2)
-			goto err;
+			goto report_failure;
 
 		size = getprop(soc, "ranges", prop_buf, MAX_PROP_LEN);
 
 		if (size < 12)
-			goto err;
+			goto report_failure;
 		if (prop_buf[0] != 0)
-			goto err;
+			goto report_failure;
 		if (naddr == 2 && prop_buf[1] != 0)
-			goto err;
+			goto report_failure;
 
 		if (!dt_xlate_addr(soc, prop_buf + naddr, 8, &ret))
 			ret = 0;
 	}
 
-err:
-	if (!ret)
+	if (!ret) {
+report_failure:
 		printf("fsl_get_immr: Failed to find immr base\r\n");
-
+	}
 	return (u32 *)ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
  2015-12-14 22:10 ` [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection SF Markus Elfring
@ 2015-12-14 22:20   ` Scott Wood
  0 siblings, 0 replies; 1373+ messages in thread
From: Scott Wood @ 2015-12-14 22:20 UTC (permalink / raw)
  To: SF Markus Elfring, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras, linuxppc-dev
  Cc: LKML, kernel-janitors, Julia Lawall

On Mon, 2015-12-14 at 23:10 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 14 Dec 2015 23:01:32 +0100
> 
> A status check was performed by the fsl_get_immr() function even if it
> was known already that a system setting did not fit to the expectations.
> 
> This implementation detail could be improved by an adjustment for
> a jump label according to the Linux coding style convention.

What is the actual problem you're trying to solve?  Cluttering the code to
micro-optimize an error path is not an improvement.

-Scott


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-14 17:43               ` SF Markus Elfring
@ 2015-12-15 11:42                 ` Dan Carpenter
  2015-12-15 15:00                   ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-15 11:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

On Mon, Dec 14, 2015 at 06:43:15PM +0100, SF Markus Elfring wrote:
> Our software development dialogue seems to trigger special
> challenges between us so far.

I try very hard to review patches mechanically and not be biased so that
after a while people know if their patches will be merged or not without
waiting for feedback.

In this case, I had asked you not to send patches renaming out labels
and then the next day you sent me a string of patches renaming out
labels.  If you were a lustre dev then I would accept these renames
definitely.  But I believe that for anyone else, I would ask them what
the point of doing these renames is.  I do not think I have been unfair
to you.  There was no element of surprise.

Part of the reason we have CodingStyle is so that we can tell people
"That's not in CodingStyle, that's just your own opinion so don't redo
code just because you have a different opinion from the maintainer."

> Are you generally willing to change the exception handling for
> the memory allocations in the function "mgc_process_recover_log"
> at all?

I like the first patch in this series.  I do not like the renames.  I
don't care too much about patches 5 and 6 except that they should be
folded together and you should not move "req" and "eof" around.

Mostly I wish you would just focus on fixing bugs instead of these sorts
of patches.  It is a lot of work for me to explain how to redo patches
but it is worth it for bugfixes.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-13 13:52   ` [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
@ 2015-12-15 14:27     ` Joe Perches
  2015-12-15 14:41       ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 14:27 UTC (permalink / raw)
  To: SF Markus Elfring, Andreas Dilger, Greg Kroah-Hartman,
	Oleg Drokin, lustre-devel, devel
  Cc: LKML, kernel-janitors, Julia Lawall

On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 13 Dec 2015 09:30:47 +0100
> 
> Six goto statements referred to a source code position directly behind them.
> Thus omit such unnecessary jumps.

I suggest you leave a blank line instead
of deleting the goto.

> diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
[]
> @@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
>  		retval = NULL;
>  	else
>  		retval = dentry;
> -	goto out;
>   out:
>  	if (req)
>  		ptlrpc_req_finished(req);

etc.,,

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 14:27     ` Joe Perches
@ 2015-12-15 14:41       ` Dan Carpenter
  2015-12-15 15:02         ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-15 14:41 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Andreas Dilger, Greg Kroah-Hartman,
	Oleg Drokin, lustre-devel, devel, LKML, kernel-janitors,
	Julia Lawall

On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote:
> On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 13 Dec 2015 09:30:47 +0100
> > 
> > Six goto statements referred to a source code position directly behind them.
> > Thus omit such unnecessary jumps.
> 
> I suggest you leave a blank line instead
> of deleting the goto.
> 

What is the point of the little bunny hop?

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-15 11:42                 ` Dan Carpenter
@ 2015-12-15 15:00                   ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-15 15:00 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: devel, Andreas Dilger, Greg Kroah-Hartman, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

> If you were a lustre dev then I would accept these renames definitely.

I find this information interesting.
Would any more contributors like to share their opinion?


> I do not think I have been unfair to you.

This view is correct in principle.


> There was no element of surprise.

I am trying to discuss further "special" update suggestions
where the topic focus might evolve to new directions.
I got the impression that you had some difficulties already
with my previous proposals. So I am unsure about the general
change acceptance from you alone.

You pointed out that you are maintainer for this software area.
I was not so aware about this detail while I noticed that
you are very active Linux software developer.
(You are not mentioned in the file "MAINTAINERS" for example.)


> Part of the reason we have CodingStyle is so that we can tell people
> "That's not in CodingStyle, that's just your own opinion so don't redo
> code just because you have a different opinion from the maintainer."

I find this description reasonable.

But I see some challenges to improve the coding style specification.
I would appreciate if some items can become less ambiguous and imprecise.
I assume that a few recommendations from the script "checkpatch.pl"
should also be mentioned there.

>
>> Are you generally willing to change the exception handling for
>> the memory allocations in the function "mgc_process_recover_log"
>> at all?
> I like the first patch in this series.

Thanks for a bit of positive feedback.


> I do not like the renames.

I guess that this design aspect can be clarified a bit more.


> I don't care too much about patches 5 and 6 except that they should be
> folded together and you should not move "req" and "eof" around.

I can understand this concern better than your first response
for these update steps.

I might send an adjusted patch series a few days later.


> Mostly I wish you would just focus on fixing bugs instead of these sorts
> of patches.

How often are deviations from the coding style also just ordinary bugs?

It seems that changes for this area are occasionally not so attractive
in comparison to software improvements for components
which are more popular.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 14:41       ` Dan Carpenter
@ 2015-12-15 15:02         ` Joe Perches
  2015-12-15 17:48           ` Dan Carpenter
  2015-12-15 18:02           ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 15:02 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Andreas Dilger, Greg Kroah-Hartman,
	Oleg Drokin, lustre-devel, devel, LKML, kernel-janitors,
	Julia Lawall

On Tue, 2015-12-15 at 17:41 +0300, Dan Carpenter wrote:
> On Tue, Dec 15, 2015 at 06:27:56AM -0800, Joe Perches wrote:
> > On Sun, 2015-12-13 at 14:52 +0100, SF Markus Elfring wrote:
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Sun, 13 Dec 2015 09:30:47 +0100
> > > 
> > > Six goto statements referred to a source code position directly behind them.
> > > Thus omit such unnecessary jumps.
> > 
> > I suggest you leave a blank line instead
> > of deleting the goto.
> > 
> 
> What is the point of the little bunny hop?
> 
> regards,
> dan carpenter
> 

-ENOPARSE little bunny hop
(though I could have said "just leave a blank line)

I think that code blocks are more obvious to read.

This is the original code:

	result = foo();
	if (result)
		goto label;

	result = bar();
	if (result)
		goto label;

	result = baz();
	if (result)
		goto label;

label:
	go on...

He proposes:

	result = foo();
	if (result)
		goto label;

	result = bar();
	if (result)
		goto label;

	result = baz();
label:
	go on...


I don't find the test->goto label; label: use offensive,
but if he does, I think keeping a blank line in place of
the test->goto might be better.

	result = foo();
	if (result)
		goto label;

	result = bar();
	if (result)
		goto label;

	result = baz();

label:
	go on...


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 15:02         ` Joe Perches
@ 2015-12-15 17:48           ` Dan Carpenter
  2015-12-15 18:10             ` Joe Perches
  2015-12-15 18:02           ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-15 17:48 UTC (permalink / raw)
  To: Joe Perches
  Cc: SF Markus Elfring, Andreas Dilger, Greg Kroah-Hartman,
	Oleg Drokin, lustre-devel, devel, LKML, kernel-janitors,
	Julia Lawall

On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote:
> This is the original code:
> 
> 	result = foo();
> 	if (result)
> 		goto label;
> 
> 	result = bar();
> 	if (result)
> 		goto label;
>
> 	result = baz();
> 	if (result)
> 		goto label;
> 
> label:
> 	go on...
> 

No.  There is no test.  The original code looks like:

	result = foo();
	if (result)
		goto out;
	result = baz();
	goto out;
out:
	go on..

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 15:02         ` Joe Perches
  2015-12-15 17:48           ` Dan Carpenter
@ 2015-12-15 18:02           ` SF Markus Elfring
  2015-12-15 18:22             ` Joe Perches
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:02 UTC (permalink / raw)
  To: Joe Perches, Dan Carpenter
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, LKML, kernel-janitors, Julia Lawall

> This is the original code:
Really …?
> 	result = baz();
> 	if (result)
> 		goto label;
>
> label:
> 	go on...

I do not see such a source code structure
at the six places I propose to clean-up.


> I don't find the test->goto label; label: use offensive,
> but if he does, I think keeping a blank line in place of
> the test->goto might be better.

I find this an interesting view on source code layout.
Are there any more opinions around such implementation details?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 17:48           ` Dan Carpenter
@ 2015-12-15 18:10             ` Joe Perches
  2015-12-15 18:26               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 18:10 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, Andreas Dilger, Greg Kroah-Hartman,
	Oleg Drokin, lustre-devel, devel, LKML, kernel-janitors,
	Julia Lawall

On Tue, 2015-12-15 at 20:48 +0300, Dan Carpenter wrote:
> On Tue, Dec 15, 2015 at 07:02:31AM -0800, Joe Perches wrote:
> > This is the original code:
> > 
> > 	result = foo();
> > 	if (result)
> > 		goto label;
> > 
> > 	result = bar();
> > 	if (result)
> > 		goto label;
> > 
> > 	result = baz();
> > 	if (result)
> > 		goto label;
> > 
> > label:
> > 	go on...
> > 
> 
> No.  There is no test.  The original code looks like:
> 
> 	result = foo();
> 	if (result)
> 		goto out;
> 	result = baz();
> 	goto out;
> out:
> 	go on..
> 
> regards,
> dan carpenter

Here is the original code:
---------------------
	/* Copy hsm_progress struct */
	req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
	if (req_hpk == NULL) {
		rc = -EPROTO;
		goto out;
	}

	*req_hpk = *hpk;
	req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval);

	ptlrpc_request_set_replen(req);

	rc = mdc_queue_wait(req);
	goto out;
out:
	ptlrpc_req_finished(req);
	return rc;
}
---------------------

I think if the last goto out; is to be removed,
then it should be replaced by a blank line.

It separates the last operation block from the return.

cheers, Joe

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 18:02           ` SF Markus Elfring
@ 2015-12-15 18:22             ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 18:22 UTC (permalink / raw)
  To: SF Markus Elfring, Dan Carpenter
  Cc: Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin, lustre-devel,
	devel, LKML, kernel-janitors, Julia Lawall

On Tue, 2015-12-15 at 19:02 +0100, SF Markus Elfring wrote:
> > This is the original code:
> Really …?
> > 	result = baz();
> > 	if (result)
> > 		goto label;
> > 
> > label:
> > 	go on...
> 
> I do not see such a source code structure
> at the six places I propose to clean-up.
> 
> 
> > I don't find the test->goto label; label: use offensive,
> > but if he does, I think keeping a blank line in place of
> > the test->goto might be better.
> 
> I find this an interesting view on source code layout.
> Are there any more opinions around such implementation details?

Or to put it another way, use a blank line before the
first or only label in an error/out block.

I don't find it different then commonly written blocks like:

void foo(void)
{
	...;

	wind1();

	val = func1(...);
	if (val) {
		printk(...);
		goto err_type;
	}

	wind2();

	val = func2(...);
	if (val) {
		printk(...);
		goto err_type2;
	}

	...

	return 0;

err_type2:
	unwind2();
err_type:
	unwind1();
	return -ERR;
}

Yes, you can elide all the blank lines, but using them can
help readability.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 18:10             ` Joe Perches
@ 2015-12-15 18:26               ` SF Markus Elfring
  2015-12-15 18:34                 ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: Dan Carpenter, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin,
	lustre-devel, devel, LKML, kernel-janitors, Julia Lawall


> 	rc = mdc_queue_wait(req);
> 	goto out;
> out:
> 	ptlrpc_req_finished(req);
> 	return rc;
> }
> ---------------------
>
> I think if the last goto out; is to be removed,
> then it should be replaced by a blank line.
>
> It separates the last operation block from the return.

Would you like to point a very specific coding style issue out?
How often should jump labels preceded with blank lines?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 18:26               ` SF Markus Elfring
@ 2015-12-15 18:34                 ` Joe Perches
  2015-12-15 18:49                   ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 18:34 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin,
	lustre-devel, devel, LKML, kernel-janitors, Julia Lawall

On Tue, 2015-12-15 at 19:26 +0100, SF Markus Elfring wrote:
> > 	rc = mdc_queue_wait(req);
> > 	goto out;
> > out:
> > 	ptlrpc_req_finished(req);
> > 	return rc;
> > }
> > ---------------------
> > 
> > I think if the last goto out; is to be removed,
> > then it should be replaced by a blank line.
> > 
> > It separates the last operation block from the return.
> 
> Would you like to point a very specific coding style issue out?

Other than using vertical separation can help readability?

I think there should _not_ be a hardened rule.
Style is just a guide.  Do what you think appropriate.

> How often should jump labels preceded with blank lines?

When other nearby blocks are also separated by blank lines.

Localized consistency can be useful.

Inconsistency can make code harder to follow/predict.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 18:34                 ` Joe Perches
@ 2015-12-15 18:49                   ` SF Markus Elfring
  2015-12-15 18:55                     ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:49 UTC (permalink / raw)
  To: Joe Perches
  Cc: Dan Carpenter, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin,
	lustre-devel, devel, LKML, kernel-janitors, Julia Lawall

> I think there should _not_ be a hardened rule.

I guess that it can become hard to achieve consensus on a precise rule.


> Style is just a guide.

Generally nice …


>   Do what you think appropriate.

I'm sorry for my evolving understanding. - But I imagine that your feedback
can cause further software development troubles if the acceptance for
this update suggestion will really depend on the number of blank lines
before a jump label.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 18:49                   ` SF Markus Elfring
@ 2015-12-15 18:55                     ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2015-12-15 18:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin,
	lustre-devel, devel, LKML, kernel-janitors, Julia Lawall

On Tue, 2015-12-15 at 19:49 +0100, SF Markus Elfring wrote:
> > I think there should _not_ be a hardened rule.
> I guess that it can become hard to achieve consensus on a precise rule.

Consensus isn't unanimity.

> I imagine that your feedback
> can cause further software development troubles if the acceptance for
> this update suggestion will really depend on the number of blank lines
> before a jump label.

<shrug>

The author of any particular bit of code can do
whatever they want.

Localized consistency is probably more valuable than
global consistency.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations
  2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2015-12-13 14:00   ` [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring
@ 2015-12-21 19:05   ` SF Markus Elfring
  2015-12-21 19:09     ` [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
                       ` (3 more replies)
  7 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-21 19:05 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Dec 2015 20:00:02 +0100

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

Markus Elfring (4):
  Delete unnecessary goto statements in six functions
  Delete an unnecessary variable initialisation in mgc_process_recover_log()
  Less checks in mgc_process_recover_log() after error detection
  Fix a jump label position in osc_get_info()

 drivers/staging/lustre/lustre/llite/namei.c     |  1 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c |  7 ----
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 53 +++++++++++--------------
 drivers/staging/lustre/lustre/osc/osc_request.c |  2 +-
 4 files changed, 25 insertions(+), 38 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-21 19:09     ` SF Markus Elfring
  2015-12-21 19:10     ` [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-21 19:09 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Dec 2015 18:15:45 +0100

Six goto statements referred to a source code position
directly behind them.
Thus omit such unnecessary jumps.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/llite/namei.c     | 1 -
 drivers/staging/lustre/lustre/mdc/mdc_request.c | 7 -------
 2 files changed, 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 64db5e8..2113dd4 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -554,7 +554,6 @@ static struct dentry *ll_lookup_it(struct inode *parent, struct dentry *dentry,
 		retval = NULL;
 	else
 		retval = dentry;
-	goto out;
  out:
 	if (req)
 		ptlrpc_req_finished(req);
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index 294c050..920b1e9 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1181,7 +1181,6 @@ static int mdc_ioc_hsm_progress(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1216,7 +1215,6 @@ static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1282,7 +1280,6 @@ static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1362,8 +1359,6 @@ static int mdc_ioc_hsm_state_set(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
-
 out:
 	ptlrpc_req_finished(req);
 	return rc;
@@ -1427,8 +1422,6 @@ static int mdc_ioc_hsm_request(struct obd_export *exp,
 	ptlrpc_request_set_replen(req);
 
 	rc = mdc_queue_wait(req);
-	goto out;
-
 out:
 	ptlrpc_req_finished(req);
 	return rc;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-21 19:09     ` [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
@ 2015-12-21 19:10     ` SF Markus Elfring
  2015-12-21 19:12     ` [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
  2015-12-21 19:13     ` [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info() SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-21 19:10 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Dec 2015 18:24:45 +0100

The variable "mne_swab" will eventually be set to an appropriate value
from a call of the ptlrpc_rep_need_swab() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 2c48847..da130f4 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1293,7 +1293,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
 	struct page **pages;
 	int nrpages;
 	bool eof = true;
-	bool mne_swab = false;
+	bool mne_swab;
 	int i;
 	int ealen;
 	int rc;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-21 19:09     ` [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
  2015-12-21 19:10     ` [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
@ 2015-12-21 19:12     ` SF Markus Elfring
  2015-12-21 23:48       ` Greg Kroah-Hartman
  2015-12-21 19:13     ` [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-21 19:12 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Dec 2015 18:58:51 +0100

A few checks would be performed by the mgc_process_recover_log() function
even though it was determined that the passed variable "pages" contained
a null pointer or a call of the alloc_page() function failed.

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

2. Corresponding implementation details could be improved by adjustments
   for jump targets according to the Linux coding style convention.

3. Delete sanity checks then.

4. Move an assignment for the variable "eof" behind memory allocations.

5. The variable "req" will eventually be set to an appropriate pointer
   from a call of the ptlrpc_request_alloc() function.
   Thus let us omit the explicit initialisation before.

6. Apply a recommendation from the script "checkpatch.pl".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 51 +++++++++++--------------
 1 file changed, 23 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index da130f4..5f581df 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1285,14 +1285,14 @@ 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;
 	struct ptlrpc_bulk_desc *desc;
 	struct page **pages;
 	int nrpages;
-	bool eof = true;
+	bool eof;
 	bool mne_swab;
 	int i;
 	int ealen;
@@ -1309,19 +1309,18 @@ static int mgc_process_recover_log(struct obd_device *obd,
 		nrpages = CONFIG_READ_NRPAGES_INIT;
 
 	pages = kcalloc(nrpages, sizeof(*pages), GFP_KERNEL);
-	if (pages == NULL) {
-		rc = -ENOMEM;
-		goto out;
-	}
+	if (!pages)
+		return -ENOMEM;
 
 	for (i = 0; i < nrpages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
 		if (pages[i] == NULL) {
 			rc = -ENOMEM;
-			goto out;
+			goto free_pages;
 		}
 	}
 
+	eof = true;
 again:
 	LASSERT(cld_is_recover(cld));
 	LASSERT(mutex_is_locked(&cld->cld_lock));
@@ -1329,12 +1328,12 @@ again:
 				   &RQF_MGS_CONFIG_READ);
 	if (req == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto free_pages;
 	}
 
 	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);
@@ -1343,7 +1342,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;
@@ -1355,7 +1354,7 @@ again:
 				    MGS_BULK_PORTAL);
 	if (desc == NULL) {
 		rc = -ENOMEM;
-		goto out;
+		goto finish_request;
 	}
 
 	for (i = 0; i < nrpages; i++)
@@ -1364,12 +1363,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
@@ -1383,18 +1382,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_CACHE_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);
@@ -1424,22 +1423,18 @@ again:
 
 		ealen -= PAGE_CACHE_SIZE;
 	}
-
-out:
-	if (req)
-		ptlrpc_req_finished(req);
+finish_request:
+	ptlrpc_req_finished(req);
 
 	if (rc == 0 && !eof)
 		goto again;
-
-	if (pages) {
-		for (i = 0; i < nrpages; i++) {
-			if (pages[i] == NULL)
-				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;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info()
  2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
                       ` (2 preceding siblings ...)
  2015-12-21 19:12     ` [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
@ 2015-12-21 19:13     ` SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-21 19:13 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 21 Dec 2015 19:30:42 +0100

The script "checkpatch.pl" pointed out that labels should not be indented.
Thus delete a horizontal tab before the jump label "out"
in the function "osc_get_info".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/osc/osc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index d6c1447..85ab180 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -2727,7 +2727,7 @@ static int osc_get_info(const struct lu_env *env, struct obd_export *exp,
 		}
 
 		*((u64 *)val) = *reply;
-	out:
+out:
 		ptlrpc_req_finished(req);
 		return rc;
 	} else if (KEY_IS(KEY_FIEMAP)) {
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-21 19:12     ` [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
@ 2015-12-21 23:48       ` Greg Kroah-Hartman
  2015-12-22  7:15         ` SF Markus Elfring
                           ` (2 more replies)
  0 siblings, 3 replies; 1373+ messages in thread
From: Greg Kroah-Hartman @ 2015-12-21 23:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: lustre-devel, devel, Andreas Dilger, Oleg Drokin, LKML,
	kernel-janitors, Julia Lawall

On Mon, Dec 21, 2015 at 08:12:12PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 21 Dec 2015 18:58:51 +0100
> 
> A few checks would be performed by the mgc_process_recover_log() function
> even though it was determined that the passed variable "pages" contained
> a null pointer or a call of the alloc_page() function failed.
> 
> 1. Let us return directly if a call of the kcalloc() function failed.
> 
> 2. Corresponding implementation details could be improved by adjustments
>    for jump targets according to the Linux coding style convention.
> 
> 3. Delete sanity checks then.
> 
> 4. Move an assignment for the variable "eof" behind memory allocations.
> 
> 5. The variable "req" will eventually be set to an appropriate pointer
>    from a call of the ptlrpc_request_alloc() function.
>    Thus let us omit the explicit initialisation before.
> 
> 6. Apply a recommendation from the script "checkpatch.pl".

That's 6 different things, shouldn't this be 6 different patches?

please redo.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-21 23:48       ` Greg Kroah-Hartman
@ 2015-12-22  7:15         ` SF Markus Elfring
  2015-12-22  8:00         ` Dan Carpenter
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-22  7:15 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: lustre-devel, devel, Andreas Dilger, Oleg Drokin, LKML,
	kernel-janitors, Julia Lawall, Dan Carpenter

>> 6. Apply a recommendation from the script "checkpatch.pl".
> 
> That's 6 different things, shouldn't this be 6 different patches?
> 
> please redo.

Dan Carpenter requested to squash the previous update steps 5 and 6
into a single patch for better source code review.
Now I see further software development challenges to increase
the patch granularity even more as you suggest.

Which route would Lustre developers like to follow?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-21 23:48       ` Greg Kroah-Hartman
  2015-12-22  7:15         ` SF Markus Elfring
@ 2015-12-22  8:00         ` Dan Carpenter
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2015-12-22  8:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: SF Markus Elfring, devel, Andreas Dilger, kernel-janitors, LKML,
	Oleg Drokin, Julia Lawall, lustre-devel

On Mon, Dec 21, 2015 at 03:48:57PM -0800, Greg Kroah-Hartman wrote:
> 
> That's 6 different things, shouldn't this be 6 different patches?
> 

Not really.  The patch could be described as just "change from using one
exit label to using several."  Markus has sent a number of these patches
and I am CC'd on them because of kernel-janitors, it's really painful to
review when he breaks them up into tiny patches where he changes one
label at a time.  It's like trying to put coleslaw back together into a
head of cabbage.

> On Mon, Dec 21, 2015 at 08:12:12PM +0100, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Mon, 21 Dec 2015 18:58:51 +0100
> > 
> > A few checks would be performed by the mgc_process_recover_log() function
> > even though it was determined that the passed variable "pages" contained
> > a null pointer or a call of the alloc_page() function failed.
> > 
> > 1. Let us return directly if a call of the kcalloc() function failed.
> > 
> > 2. Corresponding implementation details could be improved by adjustments
> >    for jump targets according to the Linux coding style convention.
> > 
> > 3. Delete sanity checks then.

These are not sanity checks, of course.  They were required because of a
common exit path.

> > 
> > 4. Move an assignment for the variable "eof" behind memory allocations.

I had asked Markus not to do this.  It is unrelated.

> > 
> > 5. The variable "req" will eventually be set to an appropriate pointer
> >    from a call of the ptlrpc_request_alloc() function.
> >    Thus let us omit the explicit initialisation before.

Now that we use multiple labels it isn't necessary to initialize "req".

> > 
> > 6. Apply a recommendation from the script "checkpatch.pl".

This is where he changed pages[i] == NULL to !(pages[i]).  It's not
strictly related but it's minor and he was changing those lines anyway.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (7 preceding siblings ...)
  2015-12-14 22:10 ` [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection SF Markus Elfring
@ 2015-12-23  9:43 ` SF Markus Elfring
  2015-12-23 10:41   ` Julia Lawall
  2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
                   ` (86 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23  9:43 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Dec 2015 22:32:07 +0100

This issue was detected by using the Coccinelle software.

Let us return directly if a memory allocation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index e507cfb..a50385c 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
 	tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
 	if (!tb[1]) {
 		ldm_crit("Out of memory.");
-		goto err;
+		return false;
 	}
 	tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
 	tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-23  9:43 ` [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() " SF Markus Elfring
@ 2015-12-23 10:41   ` Julia Lawall
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2015-12-23 10:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon, LKML,
	kernel-janitors



On Wed, 23 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 22 Dec 2015 22:32:07 +0100
>
> This issue was detected by using the Coccinelle software.
>
> Let us return directly if a memory allocation failed.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  block/partitions/ldm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
> index e507cfb..a50385c 100644
> --- a/block/partitions/ldm.c
> +++ b/block/partitions/ldm.c
> @@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
>  	tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
>  	if (!tb[1]) {
>  		ldm_crit("Out of memory.");
> -		goto err;
> +		return false;

The ldm_crit, which is just a printk, is also not necessary, because
kmalloc already generates backtrace information on failure.  So you could
clean up the whole thing at once.

julia

>  	}
>  	tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
>  	tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
> --
> 2.6.3
>
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] block-LDM: Improvements for exception handling
  2015-12-23 10:41   ` Julia Lawall
@ 2015-12-23 18:02     ` SF Markus Elfring
  2015-12-23 18:06       ` [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection SF Markus Elfring
                         ` (4 more replies)
  0 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:02 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Dec 2015 17:32:12 +0100

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

Markus Elfring (5):
  One function call less in ldm_validate_tocblocks() after error detection
  Delete extra log messages for memory allocation failures
  One function call less in ldm_partition() after error detection
  Less function calls in ldm_validate_privheads() after error detection
  Fine-tuning for the source code formatting

 block/partitions/ldm.c | 455 +++++++++++++++++++++++++------------------------
 1 file changed, 236 insertions(+), 219 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
@ 2015-12-23 18:06       ` SF Markus Elfring
  2015-12-23 18:09       ` [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures SF Markus Elfring
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:06 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 22 Dec 2015 22:32:07 +0100

This issue was detected by using the Coccinelle software.

Let us return directly if a memory allocation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index e507cfb..a50385c 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -433,7 +433,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
 	tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
 	if (!tb[1]) {
 		ldm_crit("Out of memory.");
-		goto err;
+		return false;
 	}
 	tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
 	tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
  2015-12-23 18:06       ` [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection SF Markus Elfring
@ 2015-12-23 18:09       ` SF Markus Elfring
  2015-12-23 18:10       ` [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection SF Markus Elfring
                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:09 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Dec 2015 13:21:01 +0100

A failed call of the kmalloc() function can generate appropriate
information about insufficient memory already.
Thus remove unnecessary log messages for such failures.

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index a50385c..856658a 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -343,10 +343,8 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 
 	ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
 	ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
-	if (!ph[1] || !ph[2]) {
-		ldm_crit ("Out of memory.");
+	if (!ph[1] || !ph[2])
 		goto out;
-	}
 
 	/* off[1 & 2] are relative to ph[0]->config_start */
 	ph[0]->config_start = 0;
@@ -431,10 +429,8 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
 	ph = &ldb->ph;
 	tb[0] = &ldb->toc;
 	tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
-	if (!tb[1]) {
-		ldm_crit("Out of memory.");
+	if (!tb[1])
 		return false;
-	}
 	tb[2] = (struct tocblock*)((u8*)tb[1] + sizeof(*tb[1]));
 	tb[3] = (struct tocblock*)((u8*)tb[2] + sizeof(*tb[2]));
 	/*
@@ -1239,10 +1235,8 @@ static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
 	BUG_ON (!data || !ldb);
 
 	vb = kmalloc (sizeof (*vb), GFP_KERNEL);
-	if (!vb) {
-		ldm_crit ("Out of memory.");
+	if (!vb)
 		return false;
-	}
 
 	if (!ldm_parse_vblk (data, len, vb)) {
 		kfree(vb);
@@ -1325,10 +1319,8 @@ static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
 	}
 
 	f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL);
-	if (!f) {
-		ldm_crit ("Out of memory.");
+	if (!f)
 		return false;
-	}
 
 	f->group = group;
 	f->num   = num;
@@ -1519,10 +1511,8 @@ int ldm_partition(struct parsed_partitions *state)
 		return 0;
 
 	ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
-	if (!ldb) {
-		ldm_crit ("Out of memory.");
+	if (!ldb)
 		goto out;
-	}
 
 	/* Parse and check privheads. */
 	if (!ldm_validate_privheads(state, &ldb->ph))
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
  2015-12-23 18:06       ` [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection SF Markus Elfring
  2015-12-23 18:09       ` [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures SF Markus Elfring
@ 2015-12-23 18:10       ` SF Markus Elfring
  2015-12-23 18:12       ` [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() " SF Markus Elfring
  2015-12-23 18:13       ` [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:10 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Dec 2015 13:32:51 +0100

Let us return directly if a memory allocation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 856658a..3118d24 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -1512,7 +1512,7 @@ int ldm_partition(struct parsed_partitions *state)
 
 	ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
 	if (!ldb)
-		goto out;
+		return -1;
 
 	/* Parse and check privheads. */
 	if (!ldm_validate_privheads(state, &ldb->ph))
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() after error detection
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
                         ` (2 preceding siblings ...)
  2015-12-23 18:10       ` [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection SF Markus Elfring
@ 2015-12-23 18:12       ` SF Markus Elfring
  2015-12-23 18:13       ` [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:12 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Dec 2015 14:31:01 +0100

The kfree() function was called by the ldm_validate_privheads() function
during error handling even if the passed variable "ph" contained
a null pointer.

* Corresponding implementation details could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* The variable "result" will eventually be set to an appropriate value.
  Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 30 ++++++++++++++++++------------
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 3118d24..6fc9150 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -335,16 +335,20 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 	struct privhead *ph[3] = { ph1 };
 	Sector sect;
 	u8 *data;
-	bool result = false;
+	bool result;
 	long num_sects;
 	int i;
 
 	BUG_ON (!state || !ph1);
 
 	ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
+	if (!ph[1])
+		return false;
 	ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
-	if (!ph[1] || !ph[2])
-		goto out;
+	if (!ph[2]) {
+		result = false;
+		goto free_a_head;
+	}
 
 	/* off[1 & 2] are relative to ph[0]->config_start */
 	ph[0]->config_start = 0;
@@ -355,14 +359,15 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 					&sect);
 		if (!data) {
 			ldm_crit ("Disk read failed.");
-			goto out;
+			result = false;
+			goto free_another_head;
 		}
 		result = ldm_parse_privhead (data, ph[i]);
 		put_dev_sector (sect);
 		if (!result) {
 			ldm_error ("Cannot find PRIVHEAD %d.", i+1); /* Log again */
 			if (i < 2)
-				goto out;	/* Already logged */
+				goto free_another_head;	/* Already logged */
 			else
 				break;	/* FIXME ignore for now, 3rd PH can fail on odd-sized disks */
 		}
@@ -373,30 +378,31 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 	if ((ph[0]->config_start > num_sects) ||
 	   ((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
 		ldm_crit ("Database extends beyond the end of the disk.");
-		goto out;
+		goto free_another_head;
 	}
 
 	if ((ph[0]->logical_disk_start > ph[0]->config_start) ||
 	   ((ph[0]->logical_disk_start + ph[0]->logical_disk_size)
 		    > ph[0]->config_start)) {
 		ldm_crit ("Disk and database overlap.");
-		goto out;
+		goto free_another_head;
 	}
 
 	if (!ldm_compare_privheads (ph[0], ph[1])) {
 		ldm_crit ("Primary and backup PRIVHEADs don't match.");
-		goto out;
+		goto free_another_head;
 	}
 	/* FIXME ignore this for now
 	if (!ldm_compare_privheads (ph[0], ph[2])) {
 		ldm_crit ("Primary and backup PRIVHEADs don't match.");
-		goto out;
+		goto free_another_head;
 	}*/
 	ldm_debug ("Validated PRIVHEADs successfully.");
 	result = true;
-out:
-	kfree (ph[1]);
-	kfree (ph[2]);
+free_another_head:
+	kfree(ph[2]);
+free_a_head:
+	kfree(ph[1]);
 	return result;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting
  2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
                         ` (3 preceding siblings ...)
  2015-12-23 18:12       ` [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() " SF Markus Elfring
@ 2015-12-23 18:13       ` SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-23 18:13 UTC (permalink / raw)
  To: linux-ntfs-dev, linux-block, Jens Axboe, Richard Russon
  Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 23 Dec 2015 17:23:25 +0100

1. Remove some space characters and add a few according to the Linux coding
   style convention.

2. Reformat a bit of source code also for one switch statement.

3. Apply a few more recommendations from the script "checkpatch.pl".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 block/partitions/ldm.c | 405 ++++++++++++++++++++++++++-----------------------
 1 file changed, 213 insertions(+), 192 deletions(-)

diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c
index 6fc9150..3ebe033 100644
--- a/block/partitions/ldm.c
+++ b/block/partitions/ldm.c
@@ -42,12 +42,12 @@
 #ifndef CONFIG_LDM_DEBUG
 #define ldm_debug(...)	do {} while (0)
 #else
-#define ldm_debug(f, a...) _ldm_printk (KERN_DEBUG, __func__, f, ##a)
+#define ldm_debug(f, a...) _ldm_printk(KERN_DEBUG, __func__, f, ##a)
 #endif
 
-#define ldm_crit(f, a...)  _ldm_printk (KERN_CRIT,  __func__, f, ##a)
-#define ldm_error(f, a...) _ldm_printk (KERN_ERR,   __func__, f, ##a)
-#define ldm_info(f, a...)  _ldm_printk (KERN_INFO,  __func__, f, ##a)
+#define ldm_crit(f, a...)  _ldm_printk(KERN_CRIT,  __func__, f, ##a)
+#define ldm_error(f, a...) _ldm_printk(KERN_ERR,   __func__, f, ##a)
+#define ldm_info(f, a...)  _ldm_printk(KERN_INFO,  __func__, f, ##a)
 
 static __printf(3, 4)
 void _ldm_printk(const char *level, const char *function, const char *fmt, ...)
@@ -55,7 +55,7 @@ void _ldm_printk(const char *level, const char *function, const char *fmt, ...)
 	struct va_format vaf;
 	va_list args;
 
-	va_start (args, fmt);
+	va_start(args, fmt);
 
 	vaf.fmt = fmt;
 	vaf.va = &args;
@@ -74,7 +74,7 @@ void _ldm_printk(const char *level, const char *function, const char *fmt, ...)
  * Return:  0-255  Success, the byte was parsed correctly
  *          -1     Error, an invalid character was supplied
  */
-static int ldm_parse_hexbyte (const u8 *src)
+static int ldm_parse_hexbyte(const u8 *src)
 {
 	unsigned int x;		/* For correct wrapping */
 	int h;
@@ -102,7 +102,7 @@ static int ldm_parse_hexbyte (const u8 *src)
  * Return:  'true'   @dest contains binary GUID
  *          'false'  @dest contents are undefined
  */
-static bool ldm_parse_guid (const u8 *src, u8 *dest)
+static bool ldm_parse_guid(const u8 *src, u8 *dest)
 {
 	static const int size[] = { 4, 2, 2, 2, 6 };
 	int i, j, v;
@@ -112,10 +112,11 @@ static bool ldm_parse_guid (const u8 *src, u8 *dest)
 		return false;
 
 	for (j = 0; j < 5; j++, src++)
-		for (i = 0; i < size[j]; i++, src+=2, *dest++ = v)
-			if ((v = ldm_parse_hexbyte (src)) < 0)
+		for (i = 0; i < size[j]; i++, src += 2, *dest++ = v) {
+			v = ldm_parse_hexbyte(src);
+			if (v < 0)
 				return false;
-
+		}
 	return true;
 }
 
@@ -189,36 +190,36 @@ static bool ldm_parse_privhead(const u8 *data, struct privhead *ph)
  * Return:  'true'   @toc contains the TOCBLOCK data
  *          'false'  @toc contents are undefined
  */
-static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
+static bool ldm_parse_tocblock(const u8 *data, struct tocblock *toc)
 {
-	BUG_ON (!data || !toc);
+	BUG_ON(!data || !toc);
 
 	if (MAGIC_TOCBLOCK != get_unaligned_be64(data)) {
-		ldm_crit ("Cannot find TOCBLOCK, database may be corrupt.");
+		ldm_crit("Cannot find TOCBLOCK, database may be corrupt.");
 		return false;
 	}
-	strncpy (toc->bitmap1_name, data + 0x24, sizeof (toc->bitmap1_name));
+	strncpy(toc->bitmap1_name, data + 0x24, sizeof(toc->bitmap1_name));
 	toc->bitmap1_name[sizeof (toc->bitmap1_name) - 1] = 0;
 	toc->bitmap1_start = get_unaligned_be64(data + 0x2E);
 	toc->bitmap1_size  = get_unaligned_be64(data + 0x36);
 
-	if (strncmp (toc->bitmap1_name, TOC_BITMAP1,
-			sizeof (toc->bitmap1_name)) != 0) {
-		ldm_crit ("TOCBLOCK's first bitmap is '%s', should be '%s'.",
+	if (strncmp(toc->bitmap1_name, TOC_BITMAP1,
+			sizeof(toc->bitmap1_name)) != 0) {
+		ldm_crit("TOCBLOCK's first bitmap is '%s', should be '%s'.",
 				TOC_BITMAP1, toc->bitmap1_name);
 		return false;
 	}
-	strncpy (toc->bitmap2_name, data + 0x46, sizeof (toc->bitmap2_name));
-	toc->bitmap2_name[sizeof (toc->bitmap2_name) - 1] = 0;
+	strncpy(toc->bitmap2_name, data + 0x46, sizeof(toc->bitmap2_name));
+	toc->bitmap2_name[sizeof(toc->bitmap2_name) - 1] = 0;
 	toc->bitmap2_start = get_unaligned_be64(data + 0x50);
 	toc->bitmap2_size  = get_unaligned_be64(data + 0x58);
-	if (strncmp (toc->bitmap2_name, TOC_BITMAP2,
-			sizeof (toc->bitmap2_name)) != 0) {
-		ldm_crit ("TOCBLOCK's second bitmap is '%s', should be '%s'.",
+	if (strncmp(toc->bitmap2_name, TOC_BITMAP2,
+			sizeof(toc->bitmap2_name)) != 0) {
+		ldm_crit("TOCBLOCK's second bitmap is '%s', should be '%s'.",
 				TOC_BITMAP2, toc->bitmap2_name);
 		return false;
 	}
-	ldm_debug ("Parsed TOCBLOCK successfully.");
+	ldm_debug("Parsed TOCBLOCK successfully.");
 	return true;
 }
 
@@ -235,33 +236,33 @@ static bool ldm_parse_tocblock (const u8 *data, struct tocblock *toc)
  * Return:  'true'   @vm contains VMDB info
  *          'false'  @vm contents are undefined
  */
-static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
+static bool ldm_parse_vmdb(const u8 *data, struct vmdb *vm)
 {
-	BUG_ON (!data || !vm);
+	BUG_ON(!data || !vm);
 
 	if (MAGIC_VMDB != get_unaligned_be32(data)) {
-		ldm_crit ("Cannot find the VMDB, database may be corrupt.");
+		ldm_crit("Cannot find the VMDB, database may be corrupt.");
 		return false;
 	}
 
 	vm->ver_major = get_unaligned_be16(data + 0x12);
 	vm->ver_minor = get_unaligned_be16(data + 0x14);
 	if ((vm->ver_major != 4) || (vm->ver_minor != 10)) {
-		ldm_error ("Expected VMDB version %d.%d, got %d.%d. "
+		ldm_error("Expected VMDB version %d.%d, got %d.%d. "
 			"Aborting.", 4, 10, vm->ver_major, vm->ver_minor);
 		return false;
 	}
 
 	vm->vblk_size     = get_unaligned_be32(data + 0x08);
 	if (vm->vblk_size == 0) {
-		ldm_error ("Illegal VBLK size");
+		ldm_error("Illegal VBLK size");
 		return false;
 	}
 
 	vm->vblk_offset   = get_unaligned_be32(data + 0x0C);
 	vm->last_vblk_seq = get_unaligned_be32(data + 0x04);
 
-	ldm_debug ("Parsed VMDB successfully.");
+	ldm_debug("Parsed VMDB successfully.");
 	return true;
 }
 
@@ -275,10 +276,10 @@ static bool ldm_parse_vmdb (const u8 *data, struct vmdb *vm)
  * Return:  'true'   Identical
  *          'false'  Different
  */
-static bool ldm_compare_privheads (const struct privhead *ph1,
+static bool ldm_compare_privheads(const struct privhead *ph1,
 				   const struct privhead *ph2)
 {
-	BUG_ON (!ph1 || !ph2);
+	BUG_ON(!ph1 || !ph2);
 
 	return ((ph1->ver_major          == ph2->ver_major)		&&
 		(ph1->ver_minor          == ph2->ver_minor)		&&
@@ -286,7 +287,7 @@ static bool ldm_compare_privheads (const struct privhead *ph1,
 		(ph1->logical_disk_size  == ph2->logical_disk_size)	&&
 		(ph1->config_start       == ph2->config_start)		&&
 		(ph1->config_size        == ph2->config_size)		&&
-		!memcmp (ph1->disk_id, ph2->disk_id, GUID_SIZE));
+		!memcmp(ph1->disk_id, ph2->disk_id, GUID_SIZE));
 }
 
 /**
@@ -299,19 +300,19 @@ static bool ldm_compare_privheads (const struct privhead *ph1,
  * Return:  'true'   Identical
  *          'false'  Different
  */
-static bool ldm_compare_tocblocks (const struct tocblock *toc1,
+static bool ldm_compare_tocblocks(const struct tocblock *toc1,
 				   const struct tocblock *toc2)
 {
-	BUG_ON (!toc1 || !toc2);
+	BUG_ON(!toc1 || !toc2);
 
 	return ((toc1->bitmap1_start == toc2->bitmap1_start)	&&
 		(toc1->bitmap1_size  == toc2->bitmap1_size)	&&
 		(toc1->bitmap2_start == toc2->bitmap2_start)	&&
 		(toc1->bitmap2_size  == toc2->bitmap2_size)	&&
-		!strncmp (toc1->bitmap1_name, toc2->bitmap1_name,
-			sizeof (toc1->bitmap1_name))		&&
-		!strncmp (toc1->bitmap2_name, toc2->bitmap2_name,
-			sizeof (toc1->bitmap2_name)));
+		!strncmp(toc1->bitmap1_name, toc2->bitmap1_name,
+			sizeof(toc1->bitmap1_name))		&&
+		!strncmp(toc1->bitmap2_name, toc2->bitmap2_name,
+			sizeof(toc1->bitmap2_name)));
 }
 
 /**
@@ -339,12 +340,12 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 	long num_sects;
 	int i;
 
-	BUG_ON (!state || !ph1);
+	BUG_ON(!state || !ph1);
 
-	ph[1] = kmalloc (sizeof (*ph[1]), GFP_KERNEL);
+	ph[1] = kmalloc(sizeof(*ph[1]), GFP_KERNEL);
 	if (!ph[1])
 		return false;
-	ph[2] = kmalloc (sizeof (*ph[2]), GFP_KERNEL);
+	ph[2] = kmalloc(sizeof(*ph[2]), GFP_KERNEL);
 	if (!ph[2]) {
 		result = false;
 		goto free_a_head;
@@ -358,18 +359,23 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 		data = read_part_sector(state, ph[0]->config_start + off[i],
 					&sect);
 		if (!data) {
-			ldm_crit ("Disk read failed.");
+			ldm_crit("Disk read failed.");
 			result = false;
 			goto free_another_head;
 		}
-		result = ldm_parse_privhead (data, ph[i]);
+		result = ldm_parse_privhead(data, ph[i]);
 		put_dev_sector (sect);
 		if (!result) {
-			ldm_error ("Cannot find PRIVHEAD %d.", i+1); /* Log again */
+			/* Log again */
+			ldm_error("Cannot find PRIVHEAD %d.", i + 1);
 			if (i < 2)
 				goto free_another_head;	/* Already logged */
 			else
-				break;	/* FIXME ignore for now, 3rd PH can fail on odd-sized disks */
+				/*
+				 * FIXME: ignore for now,
+				 *        3rd PH can fail on odd-sized disks
+				 */
+				break;
 		}
 	}
 
@@ -377,19 +383,19 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 
 	if ((ph[0]->config_start > num_sects) ||
 	   ((ph[0]->config_start + ph[0]->config_size) > num_sects)) {
-		ldm_crit ("Database extends beyond the end of the disk.");
+		ldm_crit("Database extends beyond the end of the disk.");
 		goto free_another_head;
 	}
 
 	if ((ph[0]->logical_disk_start > ph[0]->config_start) ||
 	   ((ph[0]->logical_disk_start + ph[0]->logical_disk_size)
 		    > ph[0]->config_start)) {
-		ldm_crit ("Disk and database overlap.");
+		ldm_crit("Disk and database overlap.");
 		goto free_another_head;
 	}
 
-	if (!ldm_compare_privheads (ph[0], ph[1])) {
-		ldm_crit ("Primary and backup PRIVHEADs don't match.");
+	if (!ldm_compare_privheads(ph[0], ph[1])) {
+		ldm_crit("Primary and backup PRIVHEADs don't match.");
 		goto free_another_head;
 	}
 	/* FIXME ignore this for now
@@ -397,7 +403,7 @@ static bool ldm_validate_privheads(struct parsed_partitions *state,
 		ldm_crit ("Primary and backup PRIVHEADs don't match.");
 		goto free_another_head;
 	}*/
-	ldm_debug ("Validated PRIVHEADs successfully.");
+	ldm_debug("Validated PRIVHEADs successfully.");
 	result = true;
 free_another_head:
 	kfree(ph[2]);
@@ -501,42 +507,42 @@ static bool ldm_validate_vmdb(struct parsed_partitions *state,
 	struct vmdb *vm;
 	struct tocblock *toc;
 
-	BUG_ON (!state || !ldb);
+	BUG_ON(!state || !ldb);
 
 	vm  = &ldb->vm;
 	toc = &ldb->toc;
 
 	data = read_part_sector(state, base + OFF_VMDB, &sect);
 	if (!data) {
-		ldm_crit ("Disk read failed.");
+		ldm_crit("Disk read failed.");
 		return false;
 	}
 
-	if (!ldm_parse_vmdb (data, vm))
+	if (!ldm_parse_vmdb(data, vm))
 		goto out;				/* Already logged */
 
 	/* Are there uncommitted transactions? */
 	if (get_unaligned_be16(data + 0x10) != 0x01) {
-		ldm_crit ("Database is not in a consistent state.  Aborting.");
+		ldm_crit("Database is not in a consistent state.  Aborting.");
 		goto out;
 	}
 
 	if (vm->vblk_offset != 512)
-		ldm_info ("VBLKs start at offset 0x%04x.", vm->vblk_offset);
+		ldm_info("VBLKs start at offset 0x%04x.", vm->vblk_offset);
 
 	/*
 	 * The last_vblkd_seq can be before the end of the vmdb, just make sure
 	 * it is not out of bounds.
 	 */
 	if ((vm->vblk_size * vm->last_vblk_seq) > (toc->bitmap1_size << 9)) {
-		ldm_crit ("VMDB exceeds allowed size specified by TOCBLOCK.  "
+		ldm_crit("VMDB exceeds allowed size specified by TOCBLOCK.  "
 				"Database is corrupt.  Aborting.");
 		goto out;
 	}
 
 	result = true;
 out:
-	put_dev_sector (sect);
+	put_dev_sector(sect);
 	return result;
 }
 
@@ -569,11 +575,11 @@ static bool ldm_validate_partition_table(struct parsed_partitions *state)
 
 	data = read_part_sector(state, 0, &sect);
 	if (!data) {
-		ldm_info ("Disk read failed.");
+		ldm_info("Disk read failed.");
 		return false;
 	}
 
-	if (*(__le16*) (data + 0x01FE) != cpu_to_le16 (MSDOS_LABEL_MAGIC))
+	if (*(__le16 *) (data + 0x01FE) != cpu_to_le16(MSDOS_LABEL_MAGIC))
 		goto out;
 
 	p = (struct partition*)(data + 0x01BE);
@@ -584,10 +590,10 @@ static bool ldm_validate_partition_table(struct parsed_partitions *state)
 		}
 
 	if (result)
-		ldm_debug ("Found W2K dynamic disk partition type.");
+		ldm_debug("Found W2K dynamic disk partition type.");
 
 out:
-	put_dev_sector (sect);
+	put_dev_sector(sect);
 	return result;
 }
 
@@ -603,15 +609,16 @@ out:
  * Return:  Pointer, A matching vblk was found
  *          NULL,    No match, or an error
  */
-static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)
+static struct vblk *ldm_get_disk_objid(const struct ldmdb *ldb)
 {
 	struct list_head *item;
 
-	BUG_ON (!ldb);
+	BUG_ON(!ldb);
 
-	list_for_each (item, &ldb->v_disk) {
-		struct vblk *v = list_entry (item, struct vblk, list);
-		if (!memcmp (v->vblk.disk.disk_id, ldb->ph.disk_id, GUID_SIZE))
+	list_for_each(item, &ldb->v_disk) {
+		struct vblk *v = list_entry(item, struct vblk, list);
+
+		if (!memcmp(v->vblk.disk.disk_id, ldb->ph.disk_id, GUID_SIZE))
 			return v;
 	}
 
@@ -635,7 +642,7 @@ static struct vblk * ldm_get_disk_objid (const struct ldmdb *ldb)
  * Return:  'true'   Partition created
  *          'false'  Error, probably a range checking problem
  */
-static bool ldm_create_data_partitions (struct parsed_partitions *pp,
+static bool ldm_create_data_partitions(struct parsed_partitions *pp,
 					const struct ldmdb *ldb)
 {
 	struct list_head *item;
@@ -644,25 +651,25 @@ static bool ldm_create_data_partitions (struct parsed_partitions *pp,
 	struct vblk_part *part;
 	int part_num = 1;
 
-	BUG_ON (!pp || !ldb);
+	BUG_ON(!pp || !ldb);
 
-	disk = ldm_get_disk_objid (ldb);
+	disk = ldm_get_disk_objid(ldb);
 	if (!disk) {
-		ldm_crit ("Can't find the ID of this disk in the database.");
+		ldm_crit("Can't find the ID of this disk in the database.");
 		return false;
 	}
 
 	strlcat(pp->pp_buf, " [LDM]", PAGE_SIZE);
 
 	/* Create the data partitions */
-	list_for_each (item, &ldb->v_part) {
-		vb = list_entry (item, struct vblk, list);
+	list_for_each(item, &ldb->v_part) {
+		vb = list_entry(item, struct vblk, list);
 		part = &vb->vblk.part;
 
 		if (part->disk_id != disk->obj_id)
 			continue;
 
-		put_partition (pp, part_num, ldb->ph.logical_disk_start +
+		put_partition(pp, part_num, ldb->ph.logical_disk_start +
 				part->start, part->size);
 		part_num++;
 	}
@@ -722,12 +729,12 @@ static int ldm_relative(const u8 *buffer, int buflen, int base, int offset)
  * Return:  n A number
  *          0 Zero, or an error occurred
  */
-static u64 ldm_get_vnum (const u8 *block)
+static u64 ldm_get_vnum(const u8 *block)
 {
 	u64 tmp = 0;
 	u8 length;
 
-	BUG_ON (!block);
+	BUG_ON(!block);
 
 	length = *block++;
 
@@ -735,7 +742,7 @@ static u64 ldm_get_vnum (const u8 *block)
 		while (length--)
 			tmp = (tmp << 8) | *block++;
 	else
-		ldm_error ("Illegal length %d.", length);
+		ldm_error("Illegal length %d.", length);
 
 	return tmp;
 }
@@ -757,18 +764,18 @@ static u64 ldm_get_vnum (const u8 *block)
  *          n, String length in characters (excluding NULL)
  *          buflen-1, String was truncated.
  */
-static int ldm_get_vstr (const u8 *block, u8 *buffer, int buflen)
+static int ldm_get_vstr(const u8 *block, u8 *buffer, int buflen)
 {
 	int length;
 
-	BUG_ON (!block || !buffer);
+	BUG_ON(!block || !buffer);
 
 	length = block[0];
 	if (length >= buflen) {
-		ldm_error ("Truncating string %d -> %d.", length, buflen);
+		ldm_error("Truncating string %d -> %d.", length, buflen);
 		length = buflen - 1;
 	}
-	memcpy (buffer, block + 1, length);
+	memcpy(buffer, block + 1, length);
 	buffer[length] = 0;
 	return length;
 }
@@ -785,22 +792,22 @@ static int ldm_get_vstr (const u8 *block, u8 *buffer, int buflen)
  * Return:  'true'   @vb contains a Component VBLK
  *          'false'  @vb contents are not defined
  */
-static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
+static bool ldm_parse_cmp3(const u8 *buffer, int buflen, struct vblk *vb)
 {
 	int r_objid, r_name, r_vstate, r_child, r_parent, r_stripe, r_cols, len;
 	struct vblk_comp *comp;
 
-	BUG_ON (!buffer || !vb);
+	BUG_ON(!buffer || !vb);
 
-	r_objid  = ldm_relative (buffer, buflen, 0x18, 0);
-	r_name   = ldm_relative (buffer, buflen, 0x18, r_objid);
-	r_vstate = ldm_relative (buffer, buflen, 0x18, r_name);
-	r_child  = ldm_relative (buffer, buflen, 0x1D, r_vstate);
-	r_parent = ldm_relative (buffer, buflen, 0x2D, r_child);
+	r_objid  = ldm_relative(buffer, buflen, 0x18, 0);
+	r_name   = ldm_relative(buffer, buflen, 0x18, r_objid);
+	r_vstate = ldm_relative(buffer, buflen, 0x18, r_name);
+	r_child  = ldm_relative(buffer, buflen, 0x1D, r_vstate);
+	r_parent = ldm_relative(buffer, buflen, 0x2D, r_child);
 
 	if (buffer[0x12] & VBLK_FLAG_COMP_STRIPE) {
-		r_stripe = ldm_relative (buffer, buflen, 0x2E, r_parent);
-		r_cols   = ldm_relative (buffer, buflen, 0x2E, r_stripe);
+		r_stripe = ldm_relative(buffer, buflen, 0x2E, r_parent);
+		r_cols   = ldm_relative(buffer, buflen, 0x2E, r_stripe);
 		len = r_cols;
 	} else {
 		r_stripe = 0;
@@ -815,12 +822,12 @@ static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
 		return false;
 
 	comp = &vb->vblk.comp;
-	ldm_get_vstr (buffer + 0x18 + r_name, comp->state,
-		sizeof (comp->state));
+	ldm_get_vstr(buffer + 0x18 + r_name, comp->state,
+		sizeof(comp->state));
 	comp->type      = buffer[0x18 + r_vstate];
-	comp->children  = ldm_get_vnum (buffer + 0x1D + r_vstate);
-	comp->parent_id = ldm_get_vnum (buffer + 0x2D + r_child);
-	comp->chunksize = r_stripe ? ldm_get_vnum (buffer+r_parent+0x2E) : 0;
+	comp->children  = ldm_get_vnum(buffer + 0x1D + r_vstate);
+	comp->parent_id = ldm_get_vnum(buffer + 0x2D + r_child);
+	comp->chunksize = r_stripe ? ldm_get_vnum(buffer + r_parent + 0x2E) : 0;
 
 	return true;
 }
@@ -836,20 +843,20 @@ static bool ldm_parse_cmp3 (const u8 *buffer, int buflen, struct vblk *vb)
  * Return:  'true'   @vb contains a Disk Group VBLK
  *          'false'  @vb contents are not defined
  */
-static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
+static int ldm_parse_dgr3(const u8 *buffer, int buflen, struct vblk *vb)
 {
 	int r_objid, r_name, r_diskid, r_id1, r_id2, len;
 	struct vblk_dgrp *dgrp;
 
-	BUG_ON (!buffer || !vb);
+	BUG_ON(!buffer || !vb);
 
-	r_objid  = ldm_relative (buffer, buflen, 0x18, 0);
-	r_name   = ldm_relative (buffer, buflen, 0x18, r_objid);
-	r_diskid = ldm_relative (buffer, buflen, 0x18, r_name);
+	r_objid  = ldm_relative(buffer, buflen, 0x18, 0);
+	r_name   = ldm_relative(buffer, buflen, 0x18, r_objid);
+	r_diskid = ldm_relative(buffer, buflen, 0x18, r_name);
 
 	if (buffer[0x12] & VBLK_FLAG_DGR3_IDS) {
-		r_id1 = ldm_relative (buffer, buflen, 0x24, r_diskid);
-		r_id2 = ldm_relative (buffer, buflen, 0x24, r_id1);
+		r_id1 = ldm_relative(buffer, buflen, 0x24, r_diskid);
+		r_id2 = ldm_relative(buffer, buflen, 0x24, r_id1);
 		len = r_id2;
 	} else {
 		r_id1 = 0;
@@ -864,8 +871,8 @@ static int ldm_parse_dgr3 (const u8 *buffer, int buflen, struct vblk *vb)
 		return false;
 
 	dgrp = &vb->vblk.dgrp;
-	ldm_get_vstr (buffer + 0x18 + r_name, dgrp->disk_id,
-		sizeof (dgrp->disk_id));
+	ldm_get_vstr(buffer + 0x18 + r_name, dgrp->disk_id,
+		sizeof(dgrp->disk_id));
 	return true;
 }
 
@@ -886,14 +893,14 @@ static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
 	int r_objid, r_name, r_id1, r_id2, len;
 	struct vblk_dgrp *dgrp;
 
-	BUG_ON (!buffer || !vb);
+	BUG_ON(!buffer || !vb);
 
-	r_objid  = ldm_relative (buffer, buflen, 0x18, 0);
-	r_name   = ldm_relative (buffer, buflen, 0x18, r_objid);
+	r_objid = ldm_relative(buffer, buflen, 0x18, 0);
+	r_name  = ldm_relative(buffer, buflen, 0x18, r_objid);
 
 	if (buffer[0x12] & VBLK_FLAG_DGR4_IDS) {
-		r_id1 = ldm_relative (buffer, buflen, 0x44, r_name);
-		r_id2 = ldm_relative (buffer, buflen, 0x44, r_id1);
+		r_id1 = ldm_relative(buffer, buflen, 0x44, r_name);
+		r_id2 = ldm_relative(buffer, buflen, 0x44, r_id1);
 		len = r_id2;
 	} else {
 		r_id1 = 0;
@@ -909,7 +916,7 @@ static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
 
 	dgrp = &vb->vblk.dgrp;
 
-	ldm_get_vstr (buffer + 0x18 + r_objid, buf, sizeof (buf));
+	ldm_get_vstr(buffer + 0x18 + r_objid, buf, sizeof(buf));
 	return true;
 }
 
@@ -924,17 +931,17 @@ static bool ldm_parse_dgr4 (const u8 *buffer, int buflen, struct vblk *vb)
  * Return:  'true'   @vb contains a Disk VBLK
  *          'false'  @vb contents are not defined
  */
-static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
+static bool ldm_parse_dsk3(const u8 *buffer, int buflen, struct vblk *vb)
 {
 	int r_objid, r_name, r_diskid, r_altname, len;
 	struct vblk_disk *disk;
 
-	BUG_ON (!buffer || !vb);
+	BUG_ON(!buffer || !vb);
 
-	r_objid   = ldm_relative (buffer, buflen, 0x18, 0);
-	r_name    = ldm_relative (buffer, buflen, 0x18, r_objid);
-	r_diskid  = ldm_relative (buffer, buflen, 0x18, r_name);
-	r_altname = ldm_relative (buffer, buflen, 0x18, r_diskid);
+	r_objid   = ldm_relative(buffer, buflen, 0x18, 0);
+	r_name    = ldm_relative(buffer, buflen, 0x18, r_objid);
+	r_diskid  = ldm_relative(buffer, buflen, 0x18, r_name);
+	r_altname = ldm_relative(buffer, buflen, 0x18, r_diskid);
 	len = r_altname;
 	if (len < 0)
 		return false;
@@ -944,9 +951,9 @@ static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
 		return false;
 
 	disk = &vb->vblk.disk;
-	ldm_get_vstr (buffer + 0x18 + r_diskid, disk->alt_name,
-		sizeof (disk->alt_name));
-	if (!ldm_parse_guid (buffer + 0x19 + r_name, disk->disk_id))
+	ldm_get_vstr(buffer + 0x18 + r_diskid, disk->alt_name,
+		sizeof(disk->alt_name));
+	if (!ldm_parse_guid(buffer + 0x19 + r_name, disk->disk_id))
 		return false;
 
 	return true;
@@ -963,15 +970,15 @@ static bool ldm_parse_dsk3 (const u8 *buffer, int buflen, struct vblk *vb)
  * Return:  'true'   @vb contains a Disk VBLK
  *          'false'  @vb contents are not defined
  */
-static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
+static bool ldm_parse_dsk4(const u8 *buffer, int buflen, struct vblk *vb)
 {
 	int r_objid, r_name, len;
 	struct vblk_disk *disk;
 
-	BUG_ON (!buffer || !vb);
+	BUG_ON(!buffer || !vb);
 
-	r_objid = ldm_relative (buffer, buflen, 0x18, 0);
-	r_name  = ldm_relative (buffer, buflen, 0x18, r_objid);
+	r_objid = ldm_relative(buffer, buflen, 0x18, 0);
+	r_name  = ldm_relative(buffer, buflen, 0x18, r_objid);
 	len     = r_name;
 	if (len < 0)
 		return false;
@@ -981,7 +988,7 @@ static bool ldm_parse_dsk4 (const u8 *buffer, int buflen, struct vblk *vb)
 		return false;
 
 	disk = &vb->vblk.disk;
-	memcpy (disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE);
+	memcpy(disk->disk_id, buffer + 0x18 + r_name, GUID_SIZE);
 	return true;
 }
 
@@ -1181,39 +1188,53 @@ static bool ldm_parse_vol5(const u8 *buffer, int buflen, struct vblk *vb)
  * Return:  'true'   @vb contains a VBLK
  *          'false'  @vb contents are not defined
  */
-static bool ldm_parse_vblk (const u8 *buf, int len, struct vblk *vb)
+static bool ldm_parse_vblk(const u8 *buf, int len, struct vblk *vb)
 {
 	bool result = false;
 	int r_objid;
 
-	BUG_ON (!buf || !vb);
+	BUG_ON(!buf || !vb);
 
-	r_objid = ldm_relative (buf, len, 0x18, 0);
+	r_objid = ldm_relative(buf, len, 0x18, 0);
 	if (r_objid < 0) {
-		ldm_error ("VBLK header is corrupt.");
+		ldm_error("VBLK header is corrupt.");
 		return false;
 	}
 
 	vb->flags  = buf[0x12];
 	vb->type   = buf[0x13];
-	vb->obj_id = ldm_get_vnum (buf + 0x18);
-	ldm_get_vstr (buf+0x18+r_objid, vb->name, sizeof (vb->name));
+	vb->obj_id = ldm_get_vnum(buf + 0x18);
+	ldm_get_vstr(buf + 0x18 + r_objid, vb->name, sizeof(vb->name));
 
 	switch (vb->type) {
-		case VBLK_CMP3:  result = ldm_parse_cmp3 (buf, len, vb); break;
-		case VBLK_DSK3:  result = ldm_parse_dsk3 (buf, len, vb); break;
-		case VBLK_DSK4:  result = ldm_parse_dsk4 (buf, len, vb); break;
-		case VBLK_DGR3:  result = ldm_parse_dgr3 (buf, len, vb); break;
-		case VBLK_DGR4:  result = ldm_parse_dgr4 (buf, len, vb); break;
-		case VBLK_PRT3:  result = ldm_parse_prt3 (buf, len, vb); break;
-		case VBLK_VOL5:  result = ldm_parse_vol5 (buf, len, vb); break;
+	case VBLK_CMP3:
+		result = ldm_parse_cmp3(buf, len, vb);
+		break;
+	case VBLK_DSK3:
+		result = ldm_parse_dsk3(buf, len, vb);
+		break;
+	case VBLK_DSK4:
+		result = ldm_parse_dsk4(buf, len, vb);
+		break;
+	case VBLK_DGR3:
+		result = ldm_parse_dgr3(buf, len, vb);
+		break;
+	case VBLK_DGR4:
+		result = ldm_parse_dgr4(buf, len, vb);
+		break;
+	case VBLK_PRT3:
+		result = ldm_parse_prt3(buf, len, vb);
+		break;
+	case VBLK_VOL5:
+		result = ldm_parse_vol5(buf, len, vb);
+		break;
 	}
 
 	if (result)
-		ldm_debug ("Parsed VBLK 0x%llx (type: 0x%02x) ok.",
+		ldm_debug("Parsed VBLK 0x%llx (type: 0x%02x) ok.",
 			 (unsigned long long) vb->obj_id, vb->type);
 	else
-		ldm_error ("Failed to parse VBLK 0x%llx (type: 0x%02x).",
+		ldm_error("Failed to parse VBLK 0x%llx (type: 0x%02x).",
 			(unsigned long long) vb->obj_id, vb->type);
 
 	return result;
@@ -1238,13 +1259,13 @@ static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
 	struct vblk *vb;
 	struct list_head *item;
 
-	BUG_ON (!data || !ldb);
+	BUG_ON(!data || !ldb);
 
-	vb = kmalloc (sizeof (*vb), GFP_KERNEL);
+	vb = kmalloc(sizeof(*vb), GFP_KERNEL);
 	if (!vb)
 		return false;
 
-	if (!ldm_parse_vblk (data, len, vb)) {
+	if (!ldm_parse_vblk(data, len, vb)) {
 		kfree(vb);
 		return false;			/* Already logged */
 	}
@@ -1253,29 +1274,29 @@ static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
 	switch (vb->type) {
 	case VBLK_DGR3:
 	case VBLK_DGR4:
-		list_add (&vb->list, &ldb->v_dgrp);
+		list_add(&vb->list, &ldb->v_dgrp);
 		break;
 	case VBLK_DSK3:
 	case VBLK_DSK4:
-		list_add (&vb->list, &ldb->v_disk);
+		list_add(&vb->list, &ldb->v_disk);
 		break;
 	case VBLK_VOL5:
-		list_add (&vb->list, &ldb->v_volu);
+		list_add(&vb->list, &ldb->v_volu);
 		break;
 	case VBLK_CMP3:
-		list_add (&vb->list, &ldb->v_comp);
+		list_add(&vb->list, &ldb->v_comp);
 		break;
 	case VBLK_PRT3:
 		/* Sort by the partition's start sector. */
-		list_for_each (item, &ldb->v_part) {
-			struct vblk *v = list_entry (item, struct vblk, list);
+		list_for_each(item, &ldb->v_part) {
+			struct vblk *v = list_entry(item, struct vblk, list);
 			if ((v->vblk.part.disk_id == vb->vblk.part.disk_id) &&
 			    (v->vblk.part.start > vb->vblk.part.start)) {
-				list_add_tail (&vb->list, &v->list);
+				list_add_tail(&vb->list, &v->list);
 				return true;
 			}
 		}
-		list_add_tail (&vb->list, &ldb->v_part);
+		list_add_tail(&vb->list, &ldb->v_part);
 		break;
 	}
 	return true;
@@ -1293,13 +1314,13 @@ static bool ldm_ldmdb_add (u8 *data, int len, struct ldmdb *ldb)
  * Return:  'true'   Success, the VBLK was added to the list
  *          'false'  Error, a problem occurred
  */
-static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
+static bool ldm_frag_add(const u8 *data, int size, struct list_head *frags)
 {
 	struct frag *f;
 	struct list_head *item;
 	int rec, num, group;
 
-	BUG_ON (!data || !frags);
+	BUG_ON(!data || !frags);
 
 	if (size < 2 * VBLK_SIZE_HEAD) {
 		ldm_error("Value of size is to small.");
@@ -1310,7 +1331,7 @@ static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
 	rec   = get_unaligned_be16(data + 0x0C);
 	num   = get_unaligned_be16(data + 0x0E);
 	if ((num < 1) || (num > 4)) {
-		ldm_error ("A VBLK claims to have %d parts.", num);
+		ldm_error("A VBLK claims to have %d parts.", num);
 		return false;
 	}
 	if (rec >= num) {
@@ -1318,13 +1339,13 @@ static bool ldm_frag_add (const u8 *data, int size, struct list_head *frags)
 		return false;
 	}
 
-	list_for_each (item, frags) {
-		f = list_entry (item, struct frag, list);
+	list_for_each(item, frags) {
+		f = list_entry(item, struct frag, list);
 		if (f->group == group)
 			goto found;
 	}
 
-	f = kmalloc (sizeof (*f) + size*num, GFP_KERNEL);
+	f = kmalloc(sizeof(*f) + size*num, GFP_KERNEL);
 	if (!f)
 		return false;
 
@@ -1340,7 +1361,7 @@ found:
 		return false;
 	}
 	if (f->map & (1 << rec)) {
-		ldm_error ("Duplicate VBLK, part %d.", rec);
+		ldm_error("Duplicate VBLK, part %d.", rec);
 		f->map &= 0x7F;			/* Mark the group as broken */
 		return false;
 	}
@@ -1361,14 +1382,14 @@ found:
  *
  * Return:  none
  */
-static void ldm_frag_free (struct list_head *list)
+static void ldm_frag_free(struct list_head *list)
 {
 	struct list_head *item, *tmp;
 
-	BUG_ON (!list);
+	BUG_ON(!list);
 
-	list_for_each_safe (item, tmp, list)
-		kfree (list_entry (item, struct frag, list));
+	list_for_each_safe(item, tmp, list)
+		kfree(list_entry(item, struct frag, list));
 }
 
 /**
@@ -1382,23 +1403,23 @@ static void ldm_frag_free (struct list_head *list)
  * Return:  'true'   All the fragments we added successfully
  *          'false'  One or more of the fragments we invalid
  */
-static bool ldm_frag_commit (struct list_head *frags, struct ldmdb *ldb)
+static bool ldm_frag_commit(struct list_head *frags, struct ldmdb *ldb)
 {
 	struct frag *f;
 	struct list_head *item;
 
-	BUG_ON (!frags || !ldb);
+	BUG_ON(!frags || !ldb);
 
-	list_for_each (item, frags) {
-		f = list_entry (item, struct frag, list);
+	list_for_each(item, frags) {
+		f = list_entry(item, struct frag, list);
 
 		if (f->map != 0xFF) {
-			ldm_error ("VBLK group %d is incomplete (0x%02x).",
+			ldm_error("VBLK group %d is incomplete (0x%02x).",
 				f->group, f->map);
 			return false;
 		}
 
-		if (!ldm_ldmdb_add (f->data, f->num*ldb->vm.vblk_size, ldb))
+		if (!ldm_ldmdb_add(f->data, f->num*ldb->vm.vblk_size, ldb))
 			return false;		/* Already logged */
 	}
 	return true;
@@ -1435,35 +1456,35 @@ static bool ldm_get_vblks(struct parsed_partitions *state, unsigned long base,
 	for (s = skip; s < finish; s++) {		/* For each sector */
 		data = read_part_sector(state, base + OFF_VMDB + s, &sect);
 		if (!data) {
-			ldm_crit ("Disk read failed.");
+			ldm_crit("Disk read failed.");
 			goto out;
 		}
 
 		for (v = 0; v < perbuf; v++, data+=size) {  /* For each vblk */
 			if (MAGIC_VBLK != get_unaligned_be32(data)) {
-				ldm_error ("Expected to find a VBLK.");
+				ldm_error("Expected to find a VBLK.");
 				goto out;
 			}
 
 			recs = get_unaligned_be16(data + 0x0E);	/* Number of records */
 			if (recs == 1) {
-				if (!ldm_ldmdb_add (data, size, ldb))
+				if (!ldm_ldmdb_add(data, size, ldb))
 					goto out;	/* Already logged */
 			} else if (recs > 1) {
-				if (!ldm_frag_add (data, size, &frags))
+				if (!ldm_frag_add(data, size, &frags))
 					goto out;	/* Already logged */
 			}
 			/* else Record is not in use, ignore it. */
 		}
-		put_dev_sector (sect);
+		put_dev_sector(sect);
 		data = NULL;
 	}
 
-	result = ldm_frag_commit (&frags, ldb);	/* Failures, already logged */
+	result = ldm_frag_commit(&frags, ldb);	/* Failures, already logged */
 out:
 	if (data)
-		put_dev_sector (sect);
-	ldm_frag_free (&frags);
+		put_dev_sector(sect);
+	ldm_frag_free(&frags);
 
 	return result;
 }
@@ -1476,14 +1497,14 @@ out:
  *
  * Return:  none
  */
-static void ldm_free_vblks (struct list_head *lh)
+static void ldm_free_vblks(struct list_head *lh)
 {
 	struct list_head *item, *tmp;
 
-	BUG_ON (!lh);
+	BUG_ON(!lh);
 
-	list_for_each_safe (item, tmp, lh)
-		kfree (list_entry (item, struct vblk, list));
+	list_for_each_safe(item, tmp, lh)
+		kfree(list_entry(item, struct vblk, list));
 }
 
 
@@ -1516,7 +1537,7 @@ int ldm_partition(struct parsed_partitions *state)
 	if (!ldm_validate_partition_table(state))
 		return 0;
 
-	ldb = kmalloc (sizeof (*ldb), GFP_KERNEL);
+	ldb = kmalloc(sizeof(*ldb), GFP_KERNEL);
 	if (!ldb)
 		return -1;
 
@@ -1533,31 +1554,31 @@ int ldm_partition(struct parsed_partitions *state)
 	    	goto out;		/* Already logged */
 
 	/* Initialize vblk lists in ldmdb struct */
-	INIT_LIST_HEAD (&ldb->v_dgrp);
-	INIT_LIST_HEAD (&ldb->v_disk);
-	INIT_LIST_HEAD (&ldb->v_volu);
-	INIT_LIST_HEAD (&ldb->v_comp);
-	INIT_LIST_HEAD (&ldb->v_part);
+	INIT_LIST_HEAD(&ldb->v_dgrp);
+	INIT_LIST_HEAD(&ldb->v_disk);
+	INIT_LIST_HEAD(&ldb->v_volu);
+	INIT_LIST_HEAD(&ldb->v_comp);
+	INIT_LIST_HEAD(&ldb->v_part);
 
 	if (!ldm_get_vblks(state, base, ldb)) {
-		ldm_crit ("Failed to read the VBLKs from the database.");
+		ldm_crit("Failed to read the VBLKs from the database.");
 		goto cleanup;
 	}
 
 	/* Finally, create the data partition devices. */
 	if (ldm_create_data_partitions(state, ldb)) {
-		ldm_debug ("Parsed LDM database successfully.");
+		ldm_debug("Parsed LDM database successfully.");
 		result = 1;
 	}
 	/* else Already logged */
 
 cleanup:
-	ldm_free_vblks (&ldb->v_dgrp);
-	ldm_free_vblks (&ldb->v_disk);
-	ldm_free_vblks (&ldb->v_volu);
-	ldm_free_vblks (&ldb->v_comp);
-	ldm_free_vblks (&ldb->v_part);
+	ldm_free_vblks(&ldb->v_dgrp);
+	ldm_free_vblks(&ldb->v_disk);
+	ldm_free_vblks(&ldb->v_volu);
+	ldm_free_vblks(&ldb->v_comp);
+	ldm_free_vblks(&ldb->v_part);
 out:
-	kfree (ldb);
+	kfree(ldb);
 	return result;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (8 preceding siblings ...)
  2015-12-23  9:43 ` [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() " SF Markus Elfring
@ 2015-12-24 12:31 ` SF Markus Elfring
  2015-12-24 12:34   ` [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main() SF Markus Elfring
                     ` (2 more replies)
  2015-12-25 10:35 ` ACPI-fan: Another source code review around null pointer handling? SF Markus Elfring
                   ` (85 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 12:31 UTC (permalink / raw)
  To: linux-doc, Jonathan Corbet; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 24 Dec 2015 13:23:34 +0100

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

Markus Elfring (3):
  Fix a check for container file usage in main()
  Apply a recommendation from "checkpatch.pl" in main()
  Less function calls in usage()

 Documentation/accounting/getdelays.c | 36 ++++++++++++++++++++----------------
 1 file changed, 20 insertions(+), 16 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
  2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
@ 2015-12-24 12:34   ` SF Markus Elfring
  2015-12-24 14:22     ` Jonathan Corbet
  2015-12-24 12:36   ` [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" " SF Markus Elfring
  2015-12-24 12:38   ` [PATCH 3/3] Documentation-getdelays: Less function calls in usage() SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 12:34 UTC (permalink / raw)
  To: linux-doc, Jonathan Corbet; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 24 Dec 2015 11:00:54 +0100

The close() function could be called by the main() function even if
the passed variable "cfd" was assigned a negative value.

* Corresponding implementation details could be improved by adjustments
  for jump targets according to the Linux coding style convention.

* Fix the affected condition check.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 Documentation/accounting/getdelays.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index f405780..6656c0c 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -383,7 +383,7 @@ int main(int argc, char *argv[])
 	id = get_family_id(nl_sd);
 	if (!id) {
 		fprintf(stderr, "Error getting family id, errno %d\n", errno);
-		goto err;
+		goto close_socket;
 	}
 	PRINTF("family id %d\n", id);
 
@@ -394,13 +394,13 @@ int main(int argc, char *argv[])
 		PRINTF("Sent register cpumask, retval %d\n", rc);
 		if (rc < 0) {
 			fprintf(stderr, "error sending register cpumask\n");
-			goto err;
+			goto close_socket;
 		}
 	}
 
 	if (tid && containerset) {
 		fprintf(stderr, "Select either -t or -C, not both\n");
-		goto err;
+		goto close_socket;
 	}
 
 	/*
@@ -426,18 +426,18 @@ int main(int argc, char *argv[])
 		cfd = open(containerpath, O_RDONLY);
 		if (cfd < 0) {
 			perror("error opening container file");
-			goto err;
+			goto close_socket;
 		}
 		rc = send_cmd(nl_sd, id, mypid, CGROUPSTATS_CMD_GET,
 			      CGROUPSTATS_CMD_ATTR_FD, &cfd, sizeof(__u32));
 		if (rc < 0) {
 			perror("error sending cgroupstats command");
-			goto err;
+			goto close_container;
 		}
 	}
 	if (!maskset && !tid && !containerset) {
 		usage();
-		goto err;
+		goto check_container;
 	}
 
 	do {
@@ -536,11 +536,14 @@ done:
 		if (rc < 0)
 			err(rc, "error sending deregister cpumask\n");
 	}
-err:
+check_container:
+	if (cfd >= 0) {
+close_container:
+		close(cfd);
+	}
+close_socket:
 	close(nl_sd);
 	if (fd)
 		close(fd);
-	if (cfd)
-		close(cfd);
 	return 0;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
  2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
  2015-12-24 12:34   ` [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main() SF Markus Elfring
@ 2015-12-24 12:36   ` SF Markus Elfring
  2015-12-24 14:22     ` Jonathan Corbet
  2015-12-24 12:38   ` [PATCH 3/3] Documentation-getdelays: Less function calls in usage() SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 12:36 UTC (permalink / raw)
  To: linux-doc, Jonathan Corbet; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 24 Dec 2015 11:05:32 +0100

The script "checkpatch.pl" pointed out that assignments should usually
not be performed within condition checks.
Thus move the assignment for the variable "nl_sd" to a separate statement.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 Documentation/accounting/getdelays.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index 6656c0c..9ca318d 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -375,7 +375,8 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	if ((nl_sd = create_nl_socket(NETLINK_GENERIC)) < 0)
+	nl_sd = create_nl_socket(NETLINK_GENERIC);
+	if (nl_sd < 0)
 		err(1, "error creating Netlink socket\n");
 
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
  2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
  2015-12-24 12:34   ` [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main() SF Markus Elfring
  2015-12-24 12:36   ` [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" " SF Markus Elfring
@ 2015-12-24 12:38   ` SF Markus Elfring
  2015-12-24 14:23     ` Jonathan Corbet
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 12:38 UTC (permalink / raw)
  To: linux-doc, Jonathan Corbet; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 24 Dec 2015 13:10:19 +0100

A single call of the fprintf() function is sufficient for the desired
display of the usage information.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 Documentation/accounting/getdelays.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Documentation/accounting/getdelays.c b/Documentation/accounting/getdelays.c
index 9ca318d..1ad3de8 100644
--- a/Documentation/accounting/getdelays.c
+++ b/Documentation/accounting/getdelays.c
@@ -74,12 +74,12 @@ char cpumask[100+6*MAX_CPUS];
 static void usage(void)
 {
 	fprintf(stderr, "getdelays [-dilv] [-w logfile] [-r bufsize] "
-			"[-m cpumask] [-t tgid] [-p pid]\n");
-	fprintf(stderr, "  -d: print delayacct stats\n");
-	fprintf(stderr, "  -i: print IO accounting (works only with -p)\n");
-	fprintf(stderr, "  -l: listen forever\n");
-	fprintf(stderr, "  -v: debug on\n");
-	fprintf(stderr, "  -C: container path\n");
+			"[-m cpumask] [-t tgid] [-p pid]\n"
+			"  -d: print delayacct stats\n"
+			"  -i: print IO accounting (works only with -p)\n"
+			"  -l: listen forever\n"
+			"  -v: debug on\n"
+			"  -C: container path\n");
 }
 
 /*
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
  2015-12-24 12:34   ` [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main() SF Markus Elfring
@ 2015-12-24 14:22     ` Jonathan Corbet
  2015-12-24 17:54       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jonathan Corbet @ 2015-12-24 14:22 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-doc, LKML, kernel-janitors, Julia Lawall

On Thu, 24 Dec 2015 13:34:20 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> The close() function could be called by the main() function even if
> the passed variable "cfd" was assigned a negative value.
> 
> * Corresponding implementation details could be improved by adjustments
>   for jump targets according to the Linux coding style convention.
> 
> * Fix the affected condition check.

This seems more easily fixed by simply making the condition > 0.
Meanwhile, I'd really not add labels-inside-if-statements as an example
in the documentation tree.

Thanks,

jon

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
  2015-12-24 12:36   ` [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" " SF Markus Elfring
@ 2015-12-24 14:22     ` Jonathan Corbet
  0 siblings, 0 replies; 1373+ messages in thread
From: Jonathan Corbet @ 2015-12-24 14:22 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-doc, LKML, kernel-janitors, Julia Lawall

On Thu, 24 Dec 2015 13:36:48 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> The script "checkpatch.pl" pointed out that assignments should usually
> not be performed within condition checks.
> Thus move the assignment for the variable "nl_sd" to a separate statement.

Fine, applied to the docs tree.

jon

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
  2015-12-24 12:38   ` [PATCH 3/3] Documentation-getdelays: Less function calls in usage() SF Markus Elfring
@ 2015-12-24 14:23     ` Jonathan Corbet
  2015-12-24 19:40       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jonathan Corbet @ 2015-12-24 14:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-doc, LKML, kernel-janitors, Julia Lawall

On Thu, 24 Dec 2015 13:38:01 +0100
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> A single call of the fprintf() function is sufficient for the desired
> display of the usage information.

This seems like churn that doesn't actually fix anything.

jon

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Documentation-getdelays: Fix a check for container file usage in main()
  2015-12-24 14:22     ` Jonathan Corbet
@ 2015-12-24 17:54       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 17:54 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-doc, LKML, kernel-janitors, Julia Lawall

>> The close() function could be called by the main() function even if
>> the passed variable "cfd" was assigned a negative value.
> This seems more easily fixed by simply making the condition > 0.

How do you think about the reuse of the error predicate "cfd != -1"
for the return value from a call of the function "open"?
http://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/Documentation/accounting/getdelays.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n425


> Meanwhile, I'd really not add labels-inside-if-statements as an example
> in the documentation tree.

How are the chances to improve the affected error detection
and corresponding exception handling?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Documentation-getdelays: Less function calls in usage()
  2015-12-24 14:23     ` Jonathan Corbet
@ 2015-12-24 19:40       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-24 19:40 UTC (permalink / raw)
  To: Jonathan Corbet; +Cc: linux-doc, LKML, kernel-janitors, Julia Lawall

>> A single call of the fprintf() function is sufficient for the desired
>> display of the usage information.
> 
> This seems like churn that doesn't actually fix anything.

Will it matter occasionally to reduce the number of function calls
by combining several text fragments into the passing of one longer
string parameter?

Does a warning like "quoted string split across lines" need also
any further considerations for the Linux coding style specification?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/scripts/checkpatch.pl?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n4837

Regards,
Markus


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* ACPI-fan: Another source code review around null pointer handling?
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (9 preceding siblings ...)
  2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
@ 2015-12-25 10:35 ` SF Markus Elfring
  2015-12-25 16:00 ` sata_mv: Another source code review around exception handling? SF Markus Elfring
                   ` (84 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-25 10:35 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, Julia Lawall

Hello,

I have looked at the source file for the ACPI fan driver once more.
I would appreciate if a specific implementation detail can be clarified there.

Static source code analysis can point out that functions like the following
share an approach for error detection and corresponding exception handling.
* acpi_fan_get_fif
* acpi_fan_get_fps
* fan_get_state_acpi4
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/acpi/fan.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n107

Can it matter eventually to handle a detected null pointer differently from
further checks for an attribute like "obj->type" or "obj->package"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* sata_mv: Another source code review around exception handling?
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (10 preceding siblings ...)
  2015-12-25 10:35 ` ACPI-fan: Another source code review around null pointer handling? SF Markus Elfring
@ 2015-12-25 16:00 ` SF Markus Elfring
  2015-12-28 16:10   ` Tejun Heo
  2015-12-25 18:49 ` [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe() SF Markus Elfring
                   ` (83 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-25 16:00 UTC (permalink / raw)
  To: linux-ide, Tejun Heo; +Cc: LKML, kernel-janitors, Julia Lawall

Hello,

I have looked at the source file for the Marvell SATA support driver once more.
I would appreciate if a specific implementation detail can be clarified there.

Static source code analysis can point out that functions like the following
are called by the mv_platform_probe() function.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/ata/sata_mv.c?id=80c75a0f1d81922bf322c0634d1e1a15825a89e6#n4055

* ata_host_alloc_pinfo
  http://lxr.free-electrons.com/source/drivers/ata/libata-core.c?v=4.3#L5768

* devm_kzalloc
  http://lxr.free-electrons.com/source/include/linux/device.h?v=4.3#L645


The value "-ENOMEM" will be returned if one of these function calls failed.
Can it be that any system resources (like memory) are not appropriately
released if any calls of this sequence succeeded before the failure?


Is the use of the single jump label "err" also suspicious here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (11 preceding siblings ...)
  2015-12-25 16:00 ` sata_mv: Another source code review around exception handling? SF Markus Elfring
@ 2015-12-25 18:49 ` SF Markus Elfring
  2015-12-26  6:34 ` [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection SF Markus Elfring
                   ` (82 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-25 18:49 UTC (permalink / raw)
  To: linux-gpio, Alexandre Courbot, Linus Walleij
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 25 Dec 2015 19:36:20 +0100

The variable "err" will eventually be set to an appropriate value
from a call of the gpiochip_add() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpio/gpio-ucb1400.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-ucb1400.c b/drivers/gpio/gpio-ucb1400.c
index d502825..c963517 100644
--- a/drivers/gpio/gpio-ucb1400.c
+++ b/drivers/gpio/gpio-ucb1400.c
@@ -46,7 +46,7 @@ static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val)
 static int ucb1400_gpio_probe(struct platform_device *dev)
 {
 	struct ucb1400_gpio *ucb = dev_get_platdata(&dev->dev);
-	int err = 0;
+	int err;
 
 	if (!(ucb && ucb->gpio_offset)) {
 		err = -EINVAL;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (12 preceding siblings ...)
  2015-12-25 18:49 ` [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe() SF Markus Elfring
@ 2015-12-26  6:34 ` SF Markus Elfring
  2015-12-26  6:47   ` kbuild test robot
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
                   ` (81 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26  6:34 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 07:30:35 +0100

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

Implementation details could be improved by the adjustment of jump targets.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-core.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7349b00..a24e06c 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -313,18 +313,18 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command,
 	client = kzalloc(sizeof(*client), GFP_KERNEL);
 	if (!client) {
 		ret = AE_NO_MEMORY;
-		goto err;
+		goto free_ares;
 	}
 
 	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
 		ret = AE_BAD_PARAMETER;
-		goto err;
+		goto free_client;
 	}
 
 	sb = &ares->data.i2c_serial_bus;
 	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
 		ret = AE_BAD_PARAMETER;
-		goto err;
+		goto free_client;
 	}
 
 	client->adapter = adapter;
@@ -405,9 +405,9 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command,
 	}
 
 	gsb->status = status;
-
- err:
+free_client:
 	kfree(client);
+free_ares:
 	ACPI_FREE(ares);
 	return ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  6:34 ` [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection SF Markus Elfring
@ 2015-12-26  6:47   ` kbuild test robot
  2015-12-26  7:08     ` [PATCH v2] " SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: kbuild test robot @ 2015-12-26  6:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, linux-i2c, Wolfram Sang, LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 1789 bytes --]

[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
Hi Markus,

[auto build test ERROR on wsa/i2c/for-next]
[also build test ERROR on v4.4-rc6 next-20151223]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/i2c-core-One-function-call-less-in-acpi_i2c_space_handler-after-error-detection/20151226-143820
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux i2c/for-next
config: x86_64-randconfig-x010-12251849 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers/i2c/i2c-core.c: In function 'acpi_i2c_space_handler':
>> drivers/i2c/i2c-core.c:404:3: error: label 'err' used but not defined
      goto err;
      ^

vim +/err +404 drivers/i2c/i2c-core.c

17f4a5c4 Wolfram Sang 2014-09-22  398  		}
17f4a5c4 Wolfram Sang 2014-09-22  399  		break;
17f4a5c4 Wolfram Sang 2014-09-22  400  
17f4a5c4 Wolfram Sang 2014-09-22  401  	default:
17f4a5c4 Wolfram Sang 2014-09-22  402  		pr_info("protocol(0x%02x) is not supported.\n", accessor_type);
17f4a5c4 Wolfram Sang 2014-09-22  403  		ret = AE_BAD_PARAMETER;
17f4a5c4 Wolfram Sang 2014-09-22 @404  		goto err;
17f4a5c4 Wolfram Sang 2014-09-22  405  	}
17f4a5c4 Wolfram Sang 2014-09-22  406  
17f4a5c4 Wolfram Sang 2014-09-22  407  	gsb->status = status;

:::::: The code at line 404 was first introduced by commit
:::::: 17f4a5c47f28de9ea59182f48d07f8c44ee5dcc9 i2c: move acpi code back into the core

:::::: TO: Wolfram Sang <wsa@the-dreams.de>
:::::: CC: Wolfram Sang <wsa@the-dreams.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 25102 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  6:47   ` kbuild test robot
@ 2015-12-26  7:08     ` SF Markus Elfring
  2015-12-26  7:48       ` Wolfram Sang
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26  7:08 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: kbuild-all, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 08:00:52 +0100

The kfree() function was called in one case by the
acpi_i2c_space_handler() function during error handling
even if the passed variable "client" 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 7349b00..9996531 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -313,18 +313,18 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command,
 	client = kzalloc(sizeof(*client), GFP_KERNEL);
 	if (!client) {
 		ret = AE_NO_MEMORY;
-		goto err;
+		goto free_ares;
 	}
 
 	if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) {
 		ret = AE_BAD_PARAMETER;
-		goto err;
+		goto free_client;
 	}
 
 	sb = &ares->data.i2c_serial_bus;
 	if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) {
 		ret = AE_BAD_PARAMETER;
-		goto err;
+		goto free_client;
 	}
 
 	client->adapter = adapter;
@@ -401,13 +401,13 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command,
 	default:
 		pr_info("protocol(0x%02x) is not supported.\n", accessor_type);
 		ret = AE_BAD_PARAMETER;
-		goto err;
+		goto free_client;
 	}
 
 	gsb->status = status;
-
- err:
+free_client:
 	kfree(client);
+free_ares:
 	ACPI_FREE(ares);
 	return ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  7:08     ` [PATCH v2] " SF Markus Elfring
@ 2015-12-26  7:48       ` Wolfram Sang
  2015-12-26  8:52         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Wolfram Sang @ 2015-12-26  7:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-i2c, kbuild-all, LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 289 bytes --]

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

This is OK. kfree() is known to be NULL-tolerant and we rely on it in
various places to keep the code simpler.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  7:48       ` Wolfram Sang
@ 2015-12-26  8:52         ` SF Markus Elfring
  2015-12-26 18:41           ` Wolfram Sang
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26  8:52 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, LKML, kernel-janitors, Julia Lawall

>> The kfree() function was called in one case by the
>> acpi_i2c_space_handler() function during error handling
>> even if the passed variable "client" contained a null pointer.
> 
> This is OK. kfree() is known to be NULL-tolerant and we rely on it in
> various places to keep the code simpler.

I would appreciate if an unnecessary function call can be avoided here
so that the affected exception handling can become also a bit more efficient.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (13 preceding siblings ...)
  2015-12-26  6:34 ` [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection SF Markus Elfring
@ 2015-12-26 10:10 ` SF Markus Elfring
  2015-12-26 10:15   ` [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection SF Markus Elfring
                     ` (3 more replies)
  2015-12-26 13:04 ` [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection SF Markus Elfring
                   ` (80 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 10:10 UTC (permalink / raw)
  To: linux-ide, David S. Miller; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 11:04:56 +0100

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

Markus Elfring (3):
  One function call less in ide_get_dev_handle() after error detection
  Delete unnecessary null pointer checks in ide_get_dev_handle()
  Move an assignment for one variable in ide_get_dev_handle()

 drivers/ide/ide-acpi.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
@ 2015-12-26 10:15   ` SF Markus Elfring
  2015-12-26 10:17   ` [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 10:15 UTC (permalink / raw)
  To: linux-ide, David S. Miller; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 10:01:36 +0100

The kfree() function was called in two cases by the
ide_get_dev_handle() function during error handling
even if the passed variable "dinfo" contained a null pointer.

* Let us return directly if a call of the function "ACPI_HANDLE"
  or "acpi_get_object_info" failed.

* Delete the explicit initialisation for the variables "dinfo" and "ret"
  at the beginning then.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide-acpi.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index b694099..319b754 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -126,8 +126,8 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 	u64 addr;
 	acpi_handle dev_handle;
 	acpi_status status;
-	struct acpi_device_info	*dinfo = NULL;
-	int ret = -ENODEV;
+	struct acpi_device_info	*dinfo;
+	int ret;
 
 	bus = pdev->bus->number;
 	devnum = PCI_SLOT(pdev->devfn);
@@ -140,13 +140,13 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 	dev_handle = ACPI_HANDLE(dev);
 	if (!dev_handle) {
 		DEBPRINT("no acpi handle for device\n");
-		goto err;
+		return -ENODEV;
 	}
 
 	status = acpi_get_object_info(dev_handle, &dinfo);
 	if (ACPI_FAILURE(status)) {
 		DEBPRINT("get_object_info for device failed\n");
-		goto err;
+		return -ENODEV;
 	}
 	if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
 	    dinfo->address == addr) {
@@ -157,13 +157,14 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 			" address: %llu, should be %u\n",
 			dinfo ? (unsigned long long)dinfo->address : -1ULL,
 			(unsigned int)addr);
-		goto err;
+		ret = -ENODEV;
+		goto free_info;
 	}
 
 	DEBPRINT("for dev=0x%x.%x, addr=0x%llx, *handle=0x%p\n",
 		 devnum, func, (unsigned long long)addr, *handle);
 	ret = 0;
-err:
+free_info:
 	kfree(dinfo);
 	return ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle()
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
  2015-12-26 10:15   ` [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection SF Markus Elfring
@ 2015-12-26 10:17   ` SF Markus Elfring
  2015-12-26 10:20   ` [PATCH 3/3] IDE-ACPI: Move an assignment for one variable " SF Markus Elfring
  2015-12-26 18:12   ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function David Miller
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 10:17 UTC (permalink / raw)
  To: linux-ide, David S. Miller; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 10:33:48 +0100

The variable "dinfo" will contain an appropropriate pointer after a call
of the acpi_get_object_info() function succeeded.
Thus remove two safety checks.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide-acpi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 319b754..b6b2111 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -148,14 +148,14 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 		DEBPRINT("get_object_info for device failed\n");
 		return -ENODEV;
 	}
-	if (dinfo && (dinfo->valid & ACPI_VALID_ADR) &&
+	if ((dinfo->valid & ACPI_VALID_ADR) &&
 	    dinfo->address == addr) {
 		*pcidevfn = addr;
 		*handle = dev_handle;
 	} else {
 		DEBPRINT("get_object_info for device has wrong "
 			" address: %llu, should be %u\n",
-			dinfo ? (unsigned long long)dinfo->address : -1ULL,
+			(unsigned long long)dinfo->address,
 			(unsigned int)addr);
 		ret = -ENODEV;
 		goto free_info;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] IDE-ACPI: Move an assignment for one variable in ide_get_dev_handle()
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
  2015-12-26 10:15   ` [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection SF Markus Elfring
  2015-12-26 10:17   ` [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle() SF Markus Elfring
@ 2015-12-26 10:20   ` SF Markus Elfring
  2015-12-26 18:12   ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function David Miller
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 10:20 UTC (permalink / raw)
  To: linux-ide, David S. Miller; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 10:50:33 +0100

Move the assignment for the variable "addr" to the statement
where its value is used after previous function calls succeeded.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/ide/ide-acpi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index b6b2111..c2de9f9 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -132,9 +132,6 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 	bus = pdev->bus->number;
 	devnum = PCI_SLOT(pdev->devfn);
 	func = PCI_FUNC(pdev->devfn);
-	/* ACPI _ADR encoding for PCI bus: */
-	addr = (u64)(devnum << 16 | func);
-
 	DEBPRINT("ENTER: pci %02x:%02x.%01x\n", bus, devnum, func);
 
 	dev_handle = ACPI_HANDLE(dev);
@@ -148,6 +145,8 @@ static int ide_get_dev_handle(struct device *dev, acpi_handle *handle,
 		DEBPRINT("get_object_info for device failed\n");
 		return -ENODEV;
 	}
+	/* ACPI _ADR encoding for PCI bus: */
+	addr = (u64)(devnum << 16 | func);
 	if ((dinfo->valid & ACPI_VALID_ADR) &&
 	    dinfo->address == addr) {
 		*pcidevfn = addr;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (14 preceding siblings ...)
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
@ 2015-12-26 13:04 ` SF Markus Elfring
  2016-01-02 18:28   ` Jonathan Cameron
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                   ` (79 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 13:04 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 13:53:15 +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" does not need to be checked once more
after it was determined that a function call failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/adc/qcom-spmi-vadc.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index c2babe5..391eefa 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -424,7 +424,7 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
 	prop = vadc_get_channel(vadc, VADC_REF_1250MV);
 	ret = vadc_do_conversion(vadc, prop, &read_1);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	/* Try with buffered 625mV channel first */
 	prop = vadc_get_channel(vadc, VADC_SPARE1);
@@ -433,11 +433,11 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
 
 	ret = vadc_do_conversion(vadc, prop, &read_2);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (read_1 == read_2) {
 		ret = -EINVAL;
-		goto err;
+		goto report_failure;
 	}
 
 	vadc->graph[VADC_CALIB_ABSOLUTE].dy = read_1 - read_2;
@@ -447,23 +447,24 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
 	prop = vadc_get_channel(vadc, VADC_VDD_VADC);
 	ret = vadc_do_conversion(vadc, prop, &read_1);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	prop = vadc_get_channel(vadc, VADC_GND_REF);
 	ret = vadc_do_conversion(vadc, prop, &read_2);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (read_1 == read_2) {
 		ret = -EINVAL;
-		goto err;
+		goto report_failure;
 	}
 
 	vadc->graph[VADC_CALIB_RATIOMETRIC].dy = read_1 - read_2;
 	vadc->graph[VADC_CALIB_RATIOMETRIC].gnd = read_2;
-err:
-	if (ret)
+	if (ret) {
+report_failure:
 		dev_err(vadc->dev, "measure reference points failed\n");
+	}
 
 	return ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-26 10:20   ` [PATCH 3/3] IDE-ACPI: Move an assignment for one variable " SF Markus Elfring
@ 2015-12-26 18:12   ` David Miller
  2015-12-26 23:43     ` Joe Perches
  3 siblings, 1 reply; 1373+ messages in thread
From: David Miller @ 2015-12-26 18:12 UTC (permalink / raw)
  To: elfring; +Cc: linux-ide, linux-kernel, kernel-janitors, julia.lawall


IDE is in deep freeze maintainence mode.

Therefore patches that perform simplications and cleanups will
not be accepted.

Thanks.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (15 preceding siblings ...)
  2015-12-26 13:04 ` [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection SF Markus Elfring
@ 2015-12-26 18:39 ` SF Markus Elfring
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
                     ` (6 more replies)
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                   ` (78 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:39 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 19:30: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()

 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(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  8:52         ` SF Markus Elfring
@ 2015-12-26 18:41           ` Wolfram Sang
  2015-12-26 19:30             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Wolfram Sang @ 2015-12-26 18:41 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-i2c, LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

On Sat, Dec 26, 2015 at 09:52:11AM +0100, SF Markus Elfring wrote:
> >> The kfree() function was called in one case by the
> >> acpi_i2c_space_handler() function during error handling
> >> even if the passed variable "client" contained a null pointer.
> > 
> > This is OK. kfree() is known to be NULL-tolerant and we rely on it in
> > various places to keep the code simpler.
> 
> I would appreciate if an unnecessary function call can be avoided here
> so that the affected exception handling can become also a bit more efficient.

Simpler code is easier to maintain. See your patch, you didn't get it
correctly at your first try. Also, this is not a hot path, so I see
it as a micro-optimization also adding complexity. I don't favor that.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-26 18:43   ` SF Markus Elfring
  2015-12-26 19:41     ` kbuild test robot
  2015-12-26 18:45   ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:43 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 17:16:00 +0100

This issue was detected by using the Coccinelle software.

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

* Delete the jump label "err" and the local variable "status" then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 583001b..374c839 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -483,19 +483,15 @@ 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);
 		uctx->cntxt_pd = NULL;
-		goto err;
+		return PTR_ERR(uctx->cntxt_pd);
 	}
 
 	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


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
@ 2015-12-26 18:45   ` SF Markus Elfring
  2015-12-26 18:47   ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:45 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 18:18:18 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index 9820074..98c0abd 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -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;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 30f67be..6647aa6 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -1089,7 +1089,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) >>
@@ -2842,7 +2842,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;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 86c303a..119baa3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -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;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 374c839..aba1b5a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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);
@@ -592,7 +592,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);
@@ -619,7 +619,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))
@@ -1282,7 +1282,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;
@@ -1946,7 +1946,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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
  2015-12-26 18:45   ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2015-12-26 18:47   ` SF Markus Elfring
  2015-12-26 18:49   ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:47 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 18:28:35 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 6647aa6..9a2b153 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -2110,7 +2110,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);
 
@@ -2135,7 +2134,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)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-26 18:47   ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
@ 2015-12-26 18:49   ` SF Markus Elfring
  2015-12-26 18:50   ` [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:49 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 18:40:43 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index aba1b5a..2de39d3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1491,9 +1491,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,
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2015-12-26 18:49   ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
@ 2015-12-26 18:50   ` SF Markus Elfring
  2015-12-26 18:51   ` [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:50 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 18:54:47 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 2de39d3..7bedf44 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -1120,15 +1120,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)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2015-12-26 18:50   ` [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
@ 2015-12-26 18:51   ` SF Markus Elfring
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:51 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 26 Dec 2015 19:09:23 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 7bedf44..0f79a01 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -750,7 +750,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;
@@ -764,11 +763,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,
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26 18:41           ` Wolfram Sang
@ 2015-12-26 19:30             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 19:30 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-i2c, LKML, kernel-janitors, Julia Lawall

>> I would appreciate if an unnecessary function call can be avoided here
>> so that the affected exception handling can become also a bit more efficient.
> 
> Simpler code is easier to maintain.

There are different opinions available around the desired simplicity.


> See your patch, you didn't get it correctly at your first try.

I wonder myself about the circumstances on how my incomplete update suggestion
did happen.


> Also, this is not a hot path,

I'm curious if approaches around better exception handling can eventually become
a "hot topic".


> so I see it as a micro-optimization

I can agree to this view for this function implementation.

 
> also adding complexity.

There are the usual software development trade-offs.


> I don't favor that.

Thanks for your constructive feedback.

Is an identifier like "free_client" a bit nicer (according to the Linux coding
style recommendations) than the short jump label "err" in the discussed use case?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
@ 2015-12-26 19:41     ` kbuild test robot
  2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: kbuild test robot @ 2015-12-26 19:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
Hi Markus,

[auto build test WARNING on v4.4-rc6]
[also build test WARNING on next-20151223]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/InfiniBand-ocrdma-Fine-tuning-for-some-function-implementations/20151227-025304


coccinelle warnings: (new ones prefixed by >>)

>> drivers/infiniband/hw/ocrdma/ocrdma_verbs.c:489:9-16: ERROR: PTR_ERR applied after initialization to constant on line 488

vim +489 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c

   482	static int ocrdma_alloc_ucontext_pd(struct ocrdma_dev *dev,
   483					    struct ocrdma_ucontext *uctx,
   484					    struct ib_udata *udata)
   485	{
   486		uctx->cntxt_pd = _ocrdma_alloc_pd(dev, uctx, udata);
   487		if (IS_ERR(uctx->cntxt_pd)) {
 > 488			uctx->cntxt_pd = NULL;
 > 489			return PTR_ERR(uctx->cntxt_pd);
   490		}
   491	
   492		uctx->cntxt_pd->uctx = uctx;

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 19:41     ` kbuild test robot
@ 2015-12-26 21:28       ` SF Markus Elfring
  2016-01-11 13:11         ` Selvin Xavier
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-26 21:28 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: kbuild-all, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 583001b..7f10cc47 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-26 18:12   ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function David Miller
@ 2015-12-26 23:43     ` Joe Perches
  2015-12-27  6:08       ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2015-12-26 23:43 UTC (permalink / raw)
  To: David Miller, elfring
  Cc: linux-ide, linux-kernel, kernel-janitors, julia.lawall

On Sat, 2015-12-26 at 13:12 -0500, David Miller wrote:
> IDE is in deep freeze maintainence mode.
> 
> Therefore patches that perform simplications and cleanups will
> not be accepted.

Maybe there should be something like a README
in drivers/ide that says that.

Maybe the MAINTAINERS entry for "IDE SUBSYSTEM"
should be something like:

S:	Frozen - critical fixes only


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-26 23:43     ` Joe Perches
@ 2015-12-27  6:08       ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2015-12-27  6:08 UTC (permalink / raw)
  To: Joe Perches
  Cc: David Miller, elfring, linux-ide, linux-kernel, kernel-janitors



On Sat, 26 Dec 2015, Joe Perches wrote:

> On Sat, 2015-12-26 at 13:12 -0500, David Miller wrote:
> > IDE is in deep freeze maintainence mode.
> > 
> > Therefore patches that perform simplications and cleanups will
> > not be accepted.
> 
> Maybe there should be something like a README
> in drivers/ide that says that.
> 
> Maybe the MAINTAINERS entry for "IDE SUBSYSTEM"
> should be something like:
> 
> S:	Frozen - critical fixes only

This could be a good idea.  Sometimes I hold off on sending patches for 
things becuse I have the impression that the subsystem doesn't want minor 
fixes, but I could be wrong, and if one could have a deterministic way to 
know, it could be better for everyone.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (16 preceding siblings ...)
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-27 12:36 ` SF Markus Elfring
  2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
                     ` (5 more replies)
  2015-12-27 17:33 ` [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8() SF Markus Elfring
                   ` (77 subsequent siblings)
  95 siblings, 6 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:36 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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).

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(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr()
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
@ 2015-12-27 12:40   ` SF Markus Elfring
  2015-12-27 12:41   ` [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr() SF Markus Elfring
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:40 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 11:41:42 +0100

This issue was detected by using the Coccinelle software.

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

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index ea765fb..14e08b3 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -443,7 +443,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
 	memset(sig_attrs, 0, sizeof(*sig_attrs));
 	ret = iser_set_sig_attrs(iser_task->sc, sig_attrs);
 	if (ret)
-		goto err;
+		return ret;
 
 	iser_set_prot_checks(iser_task->sc, &sig_attrs->check_mask);
 
@@ -475,8 +475,7 @@ iser_reg_sig_mr(struct iscsi_iser_task *iser_task,
 	iser_dbg("lkey=0x%x rkey=0x%x addr=0x%llx length=%u\n",
 		 sig_reg->sge.lkey, sig_reg->rkey, sig_reg->sge.addr,
 		 sig_reg->sge.length);
-err:
-	return ret;
+	return 0;
 }
 
 static int iser_fast_reg_mr(struct iscsi_iser_task *iser_task,
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr()
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
  2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
@ 2015-12-27 12:41   ` SF Markus Elfring
  2015-12-27 12:43   ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-27 12:41 UTC (permalink / raw)
  To: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 12:54:52 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a call of the function "isert_set_sig_attrs"
   or "ib_post_send" failed.

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 8a51c3b..9b22db0 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -2660,7 +2660,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	memset(&sig_attrs, 0, sizeof(sig_attrs));
 	ret = isert_set_sig_attrs(se_cmd, &sig_attrs);
 	if (ret)
-		goto err;
+		return ret;
 
 	sig_attrs.check_mask = isert_set_prot_checks(se_cmd->prot_checks);
 
@@ -2688,7 +2688,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	ret = ib_post_send(isert_conn->qp, wr, &bad_wr);
 	if (ret) {
 		isert_err("fast registration failed, ret:%d\n", ret);
-		goto err;
+		return ret;
 	}
 	fr_desc->ind &= ~ISERT_SIG_KEY_VALID;
 
@@ -2706,8 +2706,7 @@ isert_reg_sig_mr(struct isert_conn *isert_conn,
 	isert_dbg("sig_sge: addr: 0x%llx  length: %u lkey: %x\n",
 		  rdma_wr->ib_sg[SIG].addr, rdma_wr->ib_sg[SIG].length,
 		  rdma_wr->ib_sg[SIG].lkey);
-err:
-	return ret;
+	return 0;
 }
 
 static int
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
  2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
  2015-12-27 12:41   ` [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr() SF Markus Elfring
@ 2015-12-27 12:43   ` Leon Romanovsky
  2015-12-27 12:52   ` Leon Romanovsky
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 27 Dec 2015 13:12:10 +0100
> Subject: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
Just a note for the future submissions (no need to respin), we are using
different subject line: InfiniBand-iSER: --> IB/iser:

> 
> I suggest to return directly instead of using the jump label "err"
> in two functions (which are working without clean-up there).
> 
> 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(-)
> 
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-27 12:43   ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
@ 2015-12-27 12:52   ` Leon Romanovsky
  2015-12-27 15:26   ` Sagi Grimberg
  2016-01-06 18:47   ` Nicholas A. Bellinger
  5 siblings, 0 replies; 1373+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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).
> 
> Markus Elfring (2):
>   One jump label less in iser_reg_sig_mr()
>   One jump label less in isert_reg_sig_mr()
Looks good,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

> 
>  drivers/infiniband/ulp/iser/iser_memory.c | 5 ++---
>  drivers/infiniband/ulp/isert/ib_isert.c   | 7 +++----
>  2 files changed, 5 insertions(+), 7 deletions(-)
> 
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2015-12-27 12:52   ` Leon Romanovsky
@ 2015-12-27 15:26   ` Sagi Grimberg
  2016-01-06 18:47   ` Nicholas A. Bellinger
  5 siblings, 0 replies; 1373+ messages in thread
From: Sagi Grimberg @ 2015-12-27 15:26 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, target-devel, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

Along with Leon's prefix comment:

Acked-by: Sagi Grimberg <sagig@mellanox.com>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (17 preceding siblings ...)
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
@ 2015-12-27 17:33 ` SF Markus Elfring
  2016-01-04  8:39   ` Matthias Schwarzott
  2015-12-27 21:22 ` [PATCH] [media] bttv: Returning only value constants in two functions SF Markus Elfring
                   ` (76 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-27 17:33 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/dvb-frontends/si2165.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/media/dvb-frontends/si2165.c b/drivers/media/dvb-frontends/si2165.c
index 2b93241..e8518ae 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -225,22 +225,18 @@ static int si2165_writereg32(struct si2165_state *state, const u16 reg, u32 val)
 static int si2165_writereg_mask8(struct si2165_state *state, const u16 reg,
 				 u8 val, u8 mask)
 {
-	int ret;
-	u8 tmp;
-
 	if (mask != 0xff) {
-		ret = si2165_readreg8(state, reg, &tmp);
+		u8 tmp;
+		int ret = si2165_readreg8(state, reg, &tmp);
+
 		if (ret < 0)
-			goto err;
+			return ret;
 
 		val &= mask;
 		tmp &= ~mask;
 		val |= tmp;
 	}
-
-	ret = si2165_writereg8(state, reg, val);
-err:
-	return ret;
+	return si2165_writereg8(state, reg, val);
 }
 
 #define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] bttv: Returning only value constants in two functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (18 preceding siblings ...)
  2015-12-27 17:33 ` [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8() SF Markus Elfring
@ 2015-12-27 21:22 ` SF Markus Elfring
  2015-12-28  9:15 ` [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection SF Markus Elfring
                   ` (75 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-27 21:22 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 27 Dec 2015 22:02:21 +0100

Return constant integer values without storing them in the local
variable "err" or "rc".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/pci/bt8xx/bttv-driver.c | 25 ++++++-------------------
 1 file changed, 6 insertions(+), 19 deletions(-)

diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 9400e99..cd7d6ef 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -1726,22 +1726,15 @@ static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
 	struct bttv_fh *fh  = priv;
 	struct bttv *btv = fh->btv;
 	unsigned int i;
-	int err = 0;
 
 	for (i = 0; i < BTTV_TVNORMS; i++)
 		if (id & bttv_tvnorms[i].v4l2_id)
 			break;
-	if (i == BTTV_TVNORMS) {
-		err = -EINVAL;
-		goto err;
-	}
-
+	if (i == BTTV_TVNORMS)
+		return -EINVAL;
 	btv->std = id;
 	set_tvnorm(btv, i);
-
-err:
-
-	return err;
+	return 0;
 }
 
 static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
@@ -1770,12 +1763,9 @@ static int bttv_enum_input(struct file *file, void *priv,
 {
 	struct bttv_fh *fh = priv;
 	struct bttv *btv = fh->btv;
-	int rc = 0;
 
-	if (i->index >= bttv_tvcards[btv->c.type].video_inputs) {
-		rc = -EINVAL;
-		goto err;
-	}
+	if (i->index >= bttv_tvcards[btv->c.type].video_inputs)
+		return -EINVAL;
 
 	i->type     = V4L2_INPUT_TYPE_CAMERA;
 	i->audioset = 0;
@@ -1799,10 +1789,7 @@ static int bttv_enum_input(struct file *file, void *priv,
 	}
 
 	i->std = BTTV_NORMS;
-
-err:
-
-	return rc;
+	return 0;
 }
 
 static int bttv_g_input(struct file *file, void *priv, unsigned int *i)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (19 preceding siblings ...)
  2015-12-27 21:22 ` [PATCH] [media] bttv: Returning only value constants in two functions SF Markus Elfring
@ 2015-12-28  9:15 ` SF Markus Elfring
  2015-12-28  9:20   ` Julia Lawall
  2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
                   ` (74 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28  9:15 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 10:10:34 +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 it was determined that a function call failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/m88rs6000t.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
index 504bfbc..b45594e 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -510,27 +510,27 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
 
 	ret = regmap_read(dev->regmap, 0x5A, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	RF_GC = val & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x5F, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	IF_GC = val & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x3F, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	TIA_GC = (val >> 4) & 0x07;
 
 	ret = regmap_read(dev->regmap, 0x77, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	BB_GC = (val >> 4) & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x76, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	PGA2_GC = val & 0x3f;
 	PGA2_cri = PGA2_GC >> 2;
 	PGA2_crf = PGA2_GC & 0x03;
@@ -562,9 +562,11 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
 	/* scale value to 0x0000-0xffff */
 	gain = clamp_val(gain, 1000U, 10500U);
 	*strength = (10500 - gain) * 0xffff / (10500 - 1000);
-err:
-	if (ret)
+
+	if (ret) {
+report_failure:
 		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+	}
 	return ret;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-28  9:15 ` [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection SF Markus Elfring
@ 2015-12-28  9:20   ` Julia Lawall
  2015-12-28 10:30     ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2015-12-28  9:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors

On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 28 Dec 2015 10:10:34 +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 it was determined that a function call failed.

Why not avoid both unnecessary ifs and the enormous ugliness of a label
inside an if by making two returns: a return 0 for success and a dev_dbg
and return ret for failure?

julia


> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/tuners/m88rs6000t.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
> index 504bfbc..b45594e 100644
> --- a/drivers/media/tuners/m88rs6000t.c
> +++ b/drivers/media/tuners/m88rs6000t.c
> @@ -510,27 +510,27 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
>
>  	ret = regmap_read(dev->regmap, 0x5A, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	RF_GC = val & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x5F, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	IF_GC = val & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x3F, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	TIA_GC = (val >> 4) & 0x07;
>
>  	ret = regmap_read(dev->regmap, 0x77, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	BB_GC = (val >> 4) & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x76, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	PGA2_GC = val & 0x3f;
>  	PGA2_cri = PGA2_GC >> 2;
>  	PGA2_crf = PGA2_GC & 0x03;
> @@ -562,9 +562,11 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
>  	/* scale value to 0x0000-0xffff */
>  	gain = clamp_val(gain, 1000U, 10500U);
>  	*strength = (10500 - gain) * 0xffff / (10500 - 1000);
> -err:
> -	if (ret)
> +
> +	if (ret) {
> +report_failure:
>  		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +	}
>  	return ret;
>  }
>
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-28  9:20   ` Julia Lawall
@ 2015-12-28 10:30     ` SF Markus Elfring
  2015-12-28 10:36       ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 10:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors

>> Move the jump label directly before the desired log statement
>> so that the variable "ret" will not be checked once more
>> after it was determined that a function call failed.
> 
> Why not avoid both unnecessary ifs

I would find such a fine-tuning also nice in principle at more source code places.


> and the enormous ugliness of a label inside an if by making two returns:
> a return 0 for success and a dev_dbg and return ret for failure?

How should your suggestion finally work when the desired execution success
can be determined for such functions only after several other calls succeeded?

Is consistent checking of failure predicates usually required?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-28 10:30     ` SF Markus Elfring
@ 2015-12-28 10:36       ` Julia Lawall
  2015-12-28 14:36         ` [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2015-12-28 10:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors



On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> >> Move the jump label directly before the desired log statement
> >> so that the variable "ret" will not be checked once more
> >> after it was determined that a function call failed.
> >
> > Why not avoid both unnecessary ifs
>
> I would find such a fine-tuning also nice in principle at more source code places.
>
>
> > and the enormous ugliness of a label inside an if by making two returns:
> > a return 0 for success and a dev_dbg and return ret for failure?
>
> How should your suggestion finally work when the desired execution success
> can be determined for such functions only after several other calls succeeded?

Not idea what this means, but immediate return 0 followed by various code
for reacting to an error is very common, so it looks like it should be
possible here.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations
  2015-12-28 10:36       ` Julia Lawall
@ 2015-12-28 14:36         ` SF Markus Elfring
  2015-12-28 14:38           ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
  2015-12-28 14:42           ` [PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep() SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 14:36 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 15:32:20 +0100

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

Markus Elfring (2):
  Better exception handling in five functions
  Refactoring for m88rs6000t_sleep()

 drivers/media/tuners/m88rs6000t.c | 165 +++++++++++++++++++-------------------
 1 file changed, 83 insertions(+), 82 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions
  2015-12-28 14:36         ` [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations SF Markus Elfring
@ 2015-12-28 14:38           ` SF Markus Elfring
  2015-12-28 14:42             ` Julia Lawall
  2016-01-25 17:01             ` [PATCH 1/2] " Mauro Carvalho Chehab
  2015-12-28 14:42           ` [PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep() SF Markus Elfring
  1 sibling, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 14:38 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
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".

Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
 1 file changed, 78 insertions(+), 76 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
index 504bfbc..7e59a9f 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -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;
 	reg15 = utmp;
 	if (c->symbol_rate > 45010000) {
 		reg11 = 0x0E;
@@ -106,7 +106,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
 
 	ret = regmap_read(dev->regmap, 0x1D, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	reg1D = utmp;
 	reg1D &= ~0x03;
 	reg1D |= N - 1;
@@ -116,42 +116,42 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
 	/* program and recalibrate demod PLL */
 	ret = regmap_write(dev->regmap, 0x05, 0x40);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x11, 0x08);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x15, reg15);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x16, reg16);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x1D, reg1D);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x1E, reg1E);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x1F, reg1F);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x17, 0xc1);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x17, 0x81);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(5000, 50000);
 	ret = regmap_write(dev->regmap, 0x05, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x11, reg11);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(5000, 50000);
-err:
-	if (ret)
-		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+	return 0;
+report_failure:
+	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
 	return ret;
 }
 
@@ -169,13 +169,13 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
 
 	ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x31, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x2c, 0x02);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (tuner_freq_MHz >= 1550) {
 		ucLoDiv1 = 2;
@@ -227,105 +227,105 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
 	reg27 = (((ulNDiv1 >> 8) & 0x0F) + ucLomod1) & 0x7F;
 	ret = regmap_write(dev->regmap, 0x27, reg27);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF));
 	if (ret)
-		goto err;
+		goto report_failure;
 	reg29 = (((ulNDiv2 >> 8) & 0x0F) + ucLomod2) & 0x7f;
 	ret = regmap_write(dev->regmap, 0x29, reg29);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x2a, (u8)(ulNDiv2 & 0xFF));
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x2F, 0xf5);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x30, 0x05);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x1f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x3f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x20);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x3e, 0x11);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x2f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x3f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x10);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(2000, 50000);
 
 	ret = regmap_read(dev->regmap, 0x42, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	reg42 = utmp;
 
 	ret = regmap_write(dev->regmap, 0x3e, 0x10);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x2f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x08, 0x3f);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x10);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x09, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(2000, 50000);
 
 	ret = regmap_read(dev->regmap, 0x42, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	reg42buf = utmp;
 	if (reg42buf < reg42) {
 		ret = regmap_write(dev->regmap, 0x3e, 0x11);
 		if (ret)
-			goto err;
+			goto report_failure;
 	}
 	usleep_range(5000, 50000);
 
 	ret = regmap_read(dev->regmap, 0x2d, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x2d, utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_read(dev->regmap, 0x2e, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x2e, utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	ret = regmap_read(dev->regmap, 0x27, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	reg27 = utmp & 0x70;
 	ret = regmap_read(dev->regmap, 0x83, &utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 	if (reg27 == (utmp & 0x70)) {
 		ucLoDiv	= ucLoDiv1;
 		ulNDiv = ulNDiv1;
@@ -340,7 +340,7 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
 		refDiv = 18;
 		ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
 		if (ret)
-			goto err;
+			goto report_failure;
 		ulNDiv = ((tuner_freq_MHz * ucLoDiv * 1000) * refDiv
 				/ fcry_KHz - 1024) / 2;
 	}
@@ -349,16 +349,16 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
 			+ ((ulNDiv >> 8) & 0x0F)) & 0xFF;
 	ret = regmap_write(dev->regmap, 0x27, reg27);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv & 0xFF));
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x29, 0x80);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x31, 0x03);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (ucLoDiv == 3)
 		utmp = 0xCE;
@@ -366,15 +366,15 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
 		utmp = 0x8A;
 	ret = regmap_write(dev->regmap, 0x3b, utmp);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	dev->frequency_khz = fcry_KHz * (ulNDiv * 2 + 1024) / refDiv / ucLoDiv;
 
 	dev_dbg(&dev->client->dev,
 		"actual tune frequency=%d\n", dev->frequency_khz);
-err:
-	if (ret)
-		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+	return 0;
+report_failure:
+	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
 	return ret;
 }
 
@@ -413,21 +413,23 @@ static int m88rs6000t_set_params(struct dvb_frontend *fe)
 	freq_MHz = (realFreq + 500) / 1000;
 	ret = m88rs6000t_set_pll_freq(dev, freq_MHz);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = m88rs6000t_set_bb(dev, c->symbol_rate / 1000, lpf_offset_KHz);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x00, 0x01);
 	if (ret)
-		goto err;
+		goto report_failure;
 	ret = regmap_write(dev->regmap, 0x00, 0x00);
 	if (ret)
-		goto err;
+		goto report_failure;
 	/* set demod mlck */
 	ret = m88rs6000t_set_demod_mclk(fe);
-err:
 	if (ret)
-		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+		goto report_failure;
+	return 0;
+report_failure:
+	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
 	return ret;
 }
 
@@ -440,16 +442,16 @@ static int m88rs6000t_init(struct dvb_frontend *fe)
 
 	ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(5000, 50000);
 	ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01);
 	if (ret)
-		goto err;
+		goto report_failure;
 	usleep_range(10000, 50000);
 	ret = regmap_write(dev->regmap, 0x07, 0x7d);
-err:
-	if (ret)
-		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+	return 0;
+report_failure:
+	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
 	return ret;
 }
 
@@ -510,27 +512,27 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
 
 	ret = regmap_read(dev->regmap, 0x5A, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	RF_GC = val & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x5F, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	IF_GC = val & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x3F, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	TIA_GC = (val >> 4) & 0x07;
 
 	ret = regmap_read(dev->regmap, 0x77, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	BB_GC = (val >> 4) & 0x0f;
 
 	ret = regmap_read(dev->regmap, 0x76, &val);
 	if (ret)
-		goto err;
+		goto report_failure;
 	PGA2_GC = val & 0x3f;
 	PGA2_cri = PGA2_GC >> 2;
 	PGA2_crf = PGA2_GC & 0x03;
@@ -562,9 +564,9 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
 	/* scale value to 0x0000-0xffff */
 	gain = clamp_val(gain, 1000U, 10500U);
 	*strength = (10500 - gain) * 0xffff / (10500 - 1000);
-err:
-	if (ret)
-		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
+	return 0;
+report_failure:
+	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
 	return ret;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions
  2015-12-28 14:38           ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
@ 2015-12-28 14:42             ` Julia Lawall
  2015-12-28 15:03               ` SF Markus Elfring
  2016-01-25 17:01             ` [PATCH 1/2] " Mauro Carvalho Chehab
  1 sibling, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2015-12-28 14:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors



On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

This commit message fits with the previous change.

It could be nice to put a blank line before the error handling code.  See
what is done elsewhere in the file.

julia

>
> Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
>  1 file changed, 78 insertions(+), 76 deletions(-)
>
> diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
> index 504bfbc..7e59a9f 100644
> --- a/drivers/media/tuners/m88rs6000t.c
> +++ b/drivers/media/tuners/m88rs6000t.c
> @@ -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;
>  	reg15 = utmp;
>  	if (c->symbol_rate > 45010000) {
>  		reg11 = 0x0E;
> @@ -106,7 +106,7 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
>
>  	ret = regmap_read(dev->regmap, 0x1D, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	reg1D = utmp;
>  	reg1D &= ~0x03;
>  	reg1D |= N - 1;
> @@ -116,42 +116,42 @@ static int m88rs6000t_set_demod_mclk(struct dvb_frontend *fe)
>  	/* program and recalibrate demod PLL */
>  	ret = regmap_write(dev->regmap, 0x05, 0x40);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x11, 0x08);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x15, reg15);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x16, reg16);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x1D, reg1D);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x1E, reg1E);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x1F, reg1F);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x17, 0xc1);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x17, 0x81);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(5000, 50000);
>  	ret = regmap_write(dev->regmap, 0x05, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x11, reg11);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(5000, 50000);
> -err:
> -	if (ret)
> -		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +	return 0;
> +report_failure:
> +	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
>  	return ret;
>  }
>
> @@ -169,13 +169,13 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
>
>  	ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x31, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x2c, 0x02);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>
>  	if (tuner_freq_MHz >= 1550) {
>  		ucLoDiv1 = 2;
> @@ -227,105 +227,105 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
>  	reg27 = (((ulNDiv1 >> 8) & 0x0F) + ucLomod1) & 0x7F;
>  	ret = regmap_write(dev->regmap, 0x27, reg27);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv1 & 0xFF));
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	reg29 = (((ulNDiv2 >> 8) & 0x0F) + ucLomod2) & 0x7f;
>  	ret = regmap_write(dev->regmap, 0x29, reg29);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x2a, (u8)(ulNDiv2 & 0xFF));
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x2F, 0xf5);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x30, 0x05);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x1f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x3f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x20);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x3e, 0x11);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x2f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x3f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x10);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(2000, 50000);
>
>  	ret = regmap_read(dev->regmap, 0x42, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	reg42 = utmp;
>
>  	ret = regmap_write(dev->regmap, 0x3e, 0x10);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x2f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x08, 0x3f);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x10);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x09, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(2000, 50000);
>
>  	ret = regmap_read(dev->regmap, 0x42, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	reg42buf = utmp;
>  	if (reg42buf < reg42) {
>  		ret = regmap_write(dev->regmap, 0x3e, 0x11);
>  		if (ret)
> -			goto err;
> +			goto report_failure;
>  	}
>  	usleep_range(5000, 50000);
>
>  	ret = regmap_read(dev->regmap, 0x2d, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x2d, utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_read(dev->regmap, 0x2e, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x2e, utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>
>  	ret = regmap_read(dev->regmap, 0x27, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	reg27 = utmp & 0x70;
>  	ret = regmap_read(dev->regmap, 0x83, &utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	if (reg27 == (utmp & 0x70)) {
>  		ucLoDiv	= ucLoDiv1;
>  		ulNDiv = ulNDiv1;
> @@ -340,7 +340,7 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
>  		refDiv = 18;
>  		ret = regmap_write(dev->regmap, 0x36, (refDiv - 8));
>  		if (ret)
> -			goto err;
> +			goto report_failure;
>  		ulNDiv = ((tuner_freq_MHz * ucLoDiv * 1000) * refDiv
>  				/ fcry_KHz - 1024) / 2;
>  	}
> @@ -349,16 +349,16 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
>  			+ ((ulNDiv >> 8) & 0x0F)) & 0xFF;
>  	ret = regmap_write(dev->regmap, 0x27, reg27);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x28, (u8)(ulNDiv & 0xFF));
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x29, 0x80);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x31, 0x03);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>
>  	if (ucLoDiv == 3)
>  		utmp = 0xCE;
> @@ -366,15 +366,15 @@ static int m88rs6000t_set_pll_freq(struct m88rs6000t_dev *dev,
>  		utmp = 0x8A;
>  	ret = regmap_write(dev->regmap, 0x3b, utmp);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>
>  	dev->frequency_khz = fcry_KHz * (ulNDiv * 2 + 1024) / refDiv / ucLoDiv;
>
>  	dev_dbg(&dev->client->dev,
>  		"actual tune frequency=%d\n", dev->frequency_khz);
> -err:
> -	if (ret)
> -		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +	return 0;
> +report_failure:
> +	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
>  	return ret;
>  }
>
> @@ -413,21 +413,23 @@ static int m88rs6000t_set_params(struct dvb_frontend *fe)
>  	freq_MHz = (realFreq + 500) / 1000;
>  	ret = m88rs6000t_set_pll_freq(dev, freq_MHz);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = m88rs6000t_set_bb(dev, c->symbol_rate / 1000, lpf_offset_KHz);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x00, 0x01);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	ret = regmap_write(dev->regmap, 0x00, 0x00);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	/* set demod mlck */
>  	ret = m88rs6000t_set_demod_mclk(fe);
> -err:
>  	if (ret)
> -		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +		goto report_failure;
> +	return 0;
> +report_failure:
> +	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
>  	return ret;
>  }
>
> @@ -440,16 +442,16 @@ static int m88rs6000t_init(struct dvb_frontend *fe)
>
>  	ret = regmap_update_bits(dev->regmap, 0x11, 0x08, 0x08);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(5000, 50000);
>  	ret = regmap_update_bits(dev->regmap, 0x10, 0x01, 0x01);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	usleep_range(10000, 50000);
>  	ret = regmap_write(dev->regmap, 0x07, 0x7d);
> -err:
> -	if (ret)
> -		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +	return 0;
> +report_failure:
> +	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
>  	return ret;
>  }
>
> @@ -510,27 +512,27 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
>
>  	ret = regmap_read(dev->regmap, 0x5A, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	RF_GC = val & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x5F, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	IF_GC = val & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x3F, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	TIA_GC = (val >> 4) & 0x07;
>
>  	ret = regmap_read(dev->regmap, 0x77, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	BB_GC = (val >> 4) & 0x0f;
>
>  	ret = regmap_read(dev->regmap, 0x76, &val);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  	PGA2_GC = val & 0x3f;
>  	PGA2_cri = PGA2_GC >> 2;
>  	PGA2_crf = PGA2_GC & 0x03;
> @@ -562,9 +564,9 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength)
>  	/* scale value to 0x0000-0xffff */
>  	gain = clamp_val(gain, 1000U, 10500U);
>  	*strength = (10500 - gain) * 0xffff / (10500 - 1000);
> -err:
> -	if (ret)
> -		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
> +	return 0;
> +report_failure:
> +	dev_dbg(&dev->client->dev, "failed=%d\n", ret);
>  	return ret;
>  }
>
> --
> 2.6.3
>
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep()
  2015-12-28 14:36         ` [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations SF Markus Elfring
  2015-12-28 14:38           ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
@ 2015-12-28 14:42           ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 14:42 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 15:20:45 +0100

This issue was detected by using the Coccinelle software.

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

2. Delete the jump label "err" then.

3. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/m88rs6000t.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
index 7e59a9f..8d10798 100644
--- a/drivers/media/tuners/m88rs6000t.c
+++ b/drivers/media/tuners/m88rs6000t.c
@@ -463,13 +463,12 @@ static int m88rs6000t_sleep(struct dvb_frontend *fe)
 	dev_dbg(&dev->client->dev, "%s:\n", __func__);
 
 	ret = regmap_write(dev->regmap, 0x07, 0x6d);
-	if (ret)
-		goto err;
-	usleep_range(5000, 10000);
-err:
-	if (ret)
+	if (ret) {
 		dev_dbg(&dev->client->dev, "failed=%d\n", ret);
-	return ret;
+		return ret;
+	}
+	usleep_range(5000, 10000);
+	return 0;
 }
 
 static int m88rs6000t_get_frequency(struct dvb_frontend *fe, u32 *frequency)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [media] m88rs6000t: Better exception handling in five functions
  2015-12-28 14:42             ` Julia Lawall
@ 2015-12-28 15:03               ` SF Markus Elfring
  2015-12-28 15:12                 ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 15:03 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors

>> 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.
> 
> This commit message fits with the previous change.

Do you prefer an other wording?


> It could be nice to put a blank line before the error handling code.

Is it really a coding style requirement to insert another blank line between
the suggested placement of the statement "return 0;" and the jump label?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [media] m88rs6000t: Better exception handling in five functions
  2015-12-28 15:03               ` SF Markus Elfring
@ 2015-12-28 15:12                 ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2015-12-28 15:12 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-media, Mauro Carvalho Chehab, LKML, kernel-janitors

On Mon, 28 Dec 2015, SF Markus Elfring wrote:

> >> 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.
> >
> > This commit message fits with the previous change.
>
> Do you prefer an other wording?

Something like "Split the return into success and error cases, to avoid
the need for testing before logging."

The concept of the return being duplicated didn't come across in your
message.

> > It could be nice to put a blank line before the error handling code.
>
> Is it really a coding style requirement to insert another blank line between
> the suggested placement of the statement "return 0;" and the jump label?

I don't think it is a requirement.  But some files do it, and if other
functions in this file do it, then it would be nice to do the same.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sata_mv: Another source code review around exception handling?
  2015-12-25 16:00 ` sata_mv: Another source code review around exception handling? SF Markus Elfring
@ 2015-12-28 16:10   ` Tejun Heo
  0 siblings, 0 replies; 1373+ messages in thread
From: Tejun Heo @ 2015-12-28 16:10 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-ide, LKML, kernel-janitors, Julia Lawall

Hello,

On Fri, Dec 25, 2015 at 05:00:30PM +0100, SF Markus Elfring wrote:
> The value "-ENOMEM" will be returned if one of these function calls failed.
> Can it be that any system resources (like memory) are not appropriately
> released if any calls of this sequence succeeded before the failure?

Most of those are managed resources (devm_, pcim_ and so on) and are
released automatically when the driver detaches from the device.

> Is the use of the single jump label "err" also suspicious here?

And that exit label deal with resources which aren't managed - some
just haven't grown managed variant yet while others don't fit the
model too well.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (20 preceding siblings ...)
  2015-12-28  9:15 ` [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection SF Markus Elfring
@ 2015-12-28 16:24 ` SF Markus Elfring
  2015-12-28 16:30   ` [PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq() SF Markus Elfring
  2015-12-28 16:32   ` [PATCH 2/2] [media] r820t: Better exception handling " SF Markus Elfring
  2015-12-28 19:20 ` [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner() SF Markus Elfring
                   ` (73 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 16:24 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 17:18:34 +0100

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

Markus Elfring (2):
  Delete an unnecessary variable initialisation
  Better exception handling

 drivers/media/tuners/r820t.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq()
  2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
@ 2015-12-28 16:30   ` SF Markus Elfring
  2015-12-28 16:32   ` [PATCH 2/2] [media] r820t: Better exception handling " SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 16:30 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 16:36:44 +0100

The variable "rc" will be set to an appropriate value from a call of
the r820t_set_tv_standard() function.
Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/r820t.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index a7a8452..6ab35e3 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -1295,7 +1295,7 @@ static int generic_set_freq(struct dvb_frontend *fe,
 			    v4l2_std_id std, u32 delsys)
 {
 	struct r820t_priv		*priv = fe->tuner_priv;
-	int				rc = -EINVAL;
+	int				rc;
 	u32				lo_freq;
 
 	tuner_dbg("should set frequency to %d kHz, bw %d MHz\n",
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] [media] r820t: Better exception handling in generic_set_freq()
  2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
  2015-12-28 16:30   ` [PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq() SF Markus Elfring
@ 2015-12-28 16:32   ` SF Markus Elfring
  2016-01-25 17:04     ` Mauro Carvalho Chehab
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 16:32 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/r820t.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
index 6ab35e3..f71642e 100644
--- a/drivers/media/tuners/r820t.c
+++ b/drivers/media/tuners/r820t.c
@@ -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;
 
 	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;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (21 preceding siblings ...)
  2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
@ 2015-12-28 19:20 ` SF Markus Elfring
  2016-01-25 17:06   ` Mauro Carvalho Chehab
  2015-12-28 21:15 ` [PATCH] [media] airspy: Better exception handling in two functions SF Markus Elfring
                   ` (72 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 19:20 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/tuners/xc5000.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
index e6e5e90..1360677 100644
--- a/drivers/media/tuners/xc5000.c
+++ b/drivers/media/tuners/xc5000.c
@@ -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);
 
@@ -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.");
 	}
 
-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)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] airspy: Better exception handling in two functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (22 preceding siblings ...)
  2015-12-28 19:20 ` [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner() SF Markus Elfring
@ 2015-12-28 21:15 ` SF Markus Elfring
  2015-12-28 21:56 ` [PATCH] [media] au0828: Refactoring for start_urb_transfer() SF Markus Elfring
                   ` (71 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 21:15 UTC (permalink / raw)
  To: linux-media, Antti Palosaari, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 22:10:28 +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".

The error logging is performed in a separate section at the end now.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/airspy/airspy.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/media/usb/airspy/airspy.c b/drivers/media/usb/airspy/airspy.c
index 0d4ac59..cf2444a 100644
--- a/drivers/media/usb/airspy/airspy.c
+++ b/drivers/media/usb/airspy/airspy.c
@@ -889,18 +889,17 @@ static int airspy_set_lna_gain(struct airspy *s)
 	ret = airspy_ctrl_msg(s, CMD_SET_LNA_AGC, 0, s->lna_gain_auto->val,
 			&u8tmp, 1);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (s->lna_gain_auto->val == false) {
 		ret = airspy_ctrl_msg(s, CMD_SET_LNA_GAIN, 0, s->lna_gain->val,
 				&u8tmp, 1);
 		if (ret)
-			goto err;
+			goto report_failure;
 	}
-err:
-	if (ret)
-		dev_dbg(s->dev, "failed=%d\n", ret);
-
+	return 0;
+report_failure:
+	dev_dbg(s->dev, "failed=%d\n", ret);
 	return ret;
 }
 
@@ -916,18 +915,17 @@ static int airspy_set_mixer_gain(struct airspy *s)
 	ret = airspy_ctrl_msg(s, CMD_SET_MIXER_AGC, 0, s->mixer_gain_auto->val,
 			&u8tmp, 1);
 	if (ret)
-		goto err;
+		goto report_failure;
 
 	if (s->mixer_gain_auto->val == false) {
 		ret = airspy_ctrl_msg(s, CMD_SET_MIXER_GAIN, 0,
 				s->mixer_gain->val, &u8tmp, 1);
 		if (ret)
-			goto err;
+			goto report_failure;
 	}
-err:
-	if (ret)
-		dev_dbg(s->dev, "failed=%d\n", ret);
-
+	return 0;
+report_failure:
+	dev_dbg(s->dev, "failed=%d\n", ret);
 	return ret;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] au0828: Refactoring for start_urb_transfer()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (23 preceding siblings ...)
  2015-12-28 21:15 ` [PATCH] [media] airspy: Better exception handling in two functions SF Markus Elfring
@ 2015-12-28 21:56 ` SF Markus Elfring
  2015-12-29 10:18 ` [PATCH] [media] hdpvr: Refactoring for hdpvr_read() SF Markus Elfring
                   ` (70 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-28 21:56 UTC (permalink / raw)
  To: linux-media, Mauro Carvalho Chehab; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 28 Dec 2015 22:52:48 +0100

This issue was detected by using the Coccinelle software.

1. Let us return directly if a buffer allocation failed.

2. Delete the jump label "err" then.

3. Drop the explicit initialisation for the variable "ret"
   at the beginning.

4. Return zero as a constant at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/au0828/au0828-dvb.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/au0828/au0828-dvb.c b/drivers/media/usb/au0828/au0828-dvb.c
index cd542b4..e5f1e20 100644
--- a/drivers/media/usb/au0828/au0828-dvb.c
+++ b/drivers/media/usb/au0828/au0828-dvb.c
@@ -181,7 +181,7 @@ static int stop_urb_transfer(struct au0828_dev *dev)
 static int start_urb_transfer(struct au0828_dev *dev)
 {
 	struct urb *purb;
-	int i, ret = -ENOMEM;
+	int i, ret;
 
 	dprintk(2, "%s()\n", __func__);
 
@@ -194,7 +194,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
 
 		dev->urbs[i] = usb_alloc_urb(0, GFP_KERNEL);
 		if (!dev->urbs[i])
-			goto err;
+			return -ENOMEM;
 
 		purb = dev->urbs[i];
 
@@ -207,9 +207,10 @@ static int start_urb_transfer(struct au0828_dev *dev)
 		if (!purb->transfer_buffer) {
 			usb_free_urb(purb);
 			dev->urbs[i] = NULL;
+			ret = -ENOMEM;
 			pr_err("%s: failed big buffer allocation, err = %d\n",
 			       __func__, ret);
-			goto err;
+			return ret;
 		}
 
 		purb->status = -EINPROGRESS;
@@ -235,10 +236,7 @@ static int start_urb_transfer(struct au0828_dev *dev)
 	}
 
 	dev->urb_streaming = true;
-	ret = 0;
-
-err:
-	return ret;
+	return 0;
 }
 
 static void au0828_start_transport(struct au0828_dev *dev)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] hdpvr: Refactoring for hdpvr_read()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (24 preceding siblings ...)
  2015-12-28 21:56 ` [PATCH] [media] au0828: Refactoring for start_urb_transfer() SF Markus Elfring
@ 2015-12-29 10:18 ` SF Markus Elfring
  2015-12-29 11:37 ` [PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc() SF Markus Elfring
                   ` (69 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 10:18 UTC (permalink / raw)
  To: linux-media, Hans Verkuil, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 29 Dec 2015 11:02:43 +0100

Let us return directly if the element "status" of the variable "buf"
indicates "BUFSTAT_READY".
A check repetition can be excluded for the variable "ret" at the end then.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/hdpvr/hdpvr-video.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 7dee22d..ba7f022 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -462,10 +462,8 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
 			}
 
 			if (wait_event_interruptible(dev->wait_data,
-					      buf->status == BUFSTAT_READY)) {
-				ret = -ERESTARTSYS;
-				goto err;
-			}
+					      buf->status == BUFSTAT_READY))
+				return -ERESTARTSYS;
 		}
 
 		if (buf->status != BUFSTAT_READY)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (25 preceding siblings ...)
  2015-12-29 10:18 ` [PATCH] [media] hdpvr: Refactoring for hdpvr_read() SF Markus Elfring
@ 2015-12-29 11:37 ` SF Markus Elfring
  2015-12-29 13:04 ` [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection SF Markus Elfring
                   ` (68 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 11:37 UTC (permalink / raw)
  To: linux-media, Antti Palosaari, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 29 Dec 2015 12:32:41 +0100

This issue was detected by using the Coccinelle software.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/msi2500/msi2500.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/media/usb/msi2500/msi2500.c b/drivers/media/usb/msi2500/msi2500.c
index c104315..2d33033 100644
--- a/drivers/media/usb/msi2500/msi2500.c
+++ b/drivers/media/usb/msi2500/msi2500.c
@@ -839,8 +839,6 @@ static int msi2500_set_usb_adc(struct msi2500_dev *dev)
 		goto err;
 
 	ret = msi2500_ctrl_msg(dev, CMD_WREG, reg3);
-	if (ret)
-		goto err;
 err:
 	return ret;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (26 preceding siblings ...)
  2015-12-29 11:37 ` [PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc() SF Markus Elfring
@ 2015-12-29 13:04 ` SF Markus Elfring
  2016-01-11  8:31   ` Lee Jones
  2016-01-12 11:59   ` [PATCH] " Lee Jones
  2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
                   ` (67 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 13:04 UTC (permalink / raw)
  To: LKML, Lee Jones; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index bc90efe..e4aa1b8 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -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)
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (27 preceding siblings ...)
  2015-12-29 13:04 ` [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection SF Markus Elfring
@ 2015-12-29 14:15 ` SF Markus Elfring
  2015-12-29 14:17   ` [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
                     ` (2 more replies)
  2015-12-29 18:34 ` [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection SF Markus Elfring
                   ` (66 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 14:15 UTC (permalink / raw)
  To: LKML, Lee Jones; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 29 Dec 2015 15:10:48 +0100

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(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
  2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
@ 2015-12-29 14:17   ` SF Markus Elfring
  2016-01-11  8:15     ` Lee Jones
  2015-12-29 14:18   ` [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe() SF Markus Elfring
  2016-01-11  8:08   ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning " Lee Jones
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 14:17 UTC (permalink / raw)
  To: LKML, Lee Jones; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/smsc-ece1099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
index a4c0df7..bcac488 100644
--- a/drivers/mfd/smsc-ece1099.c
+++ b/drivers/mfd/smsc-ece1099.c
@@ -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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
  2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
  2015-12-29 14:17   ` [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
@ 2015-12-29 14:18   ` SF Markus Elfring
  2016-01-11  8:10     ` Lee Jones
  2016-01-11  8:08   ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning " Lee Jones
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 14:18 UTC (permalink / raw)
  To: LKML, Lee Jones; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
index bcac488..951333a 100644
--- a/drivers/mfd/smsc-ece1099.c
+++ b/drivers/mfd/smsc-ece1099.c
@@ -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;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (28 preceding siblings ...)
  2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
@ 2015-12-29 18:34 ` SF Markus Elfring
  2016-01-11  8:29   ` Lee Jones
  2015-12-29 19:50 ` [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection SF Markus Elfring
                   ` (65 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 18:34 UTC (permalink / raw)
  To: linux-omap, Lee Jones, Tony Lindgren; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/twl-core.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 831696e..0d9350c 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -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");
 		status = -ENOMEM;
-		goto err;
+		goto report_failure;
 	}
 
 	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);
 		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) {
 		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,
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (29 preceding siblings ...)
  2015-12-29 18:34 ` [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection SF Markus Elfring
@ 2015-12-29 19:50 ` SF Markus Elfring
  2016-01-12 15:07   ` Ulf Hansson
  2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
                   ` (64 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 19:50 UTC (permalink / raw)
  To: linux-mmc, Ulf Hansson; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/core/mmc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 549c56e..866f72b 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -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


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] mmc-host: Fine-tuning for one function
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (30 preceding siblings ...)
  2015-12-29 19:50 ` [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection SF Markus Elfring
@ 2015-12-29 20:57 ` SF Markus Elfring
  2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
                     ` (2 more replies)
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
                   ` (63 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 20:57 UTC (permalink / raw)
  To: linux-mmc, Sascha Sommer, Ulf Hansson; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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

 drivers/mmc/host/sdricoh_cs.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc()
  2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
@ 2015-12-29 21:00   ` SF Markus Elfring
  2016-02-21  9:11     ` Sascha Sommer
  2015-12-29 21:02   ` [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection SF Markus Elfring
  2016-01-27 14:15   ` [PATCH 0/2] mmc-host: Fine-tuning for one function Ulf Hansson
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 21:00 UTC (permalink / raw)
  To: linux-mmc, Sascha Sommer, Ulf Hansson; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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

Thus let us omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/host/sdricoh_cs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index b7e3057..5e57d9f 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -398,10 +398,10 @@ static struct mmc_host_ops sdricoh_ops = {
 static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 			    struct pcmcia_device *pcmcia_dev)
 {
-	int result = 0;
-	void __iomem *iobase = NULL;
+	int result;
+	void __iomem *iobase;
 	struct mmc_host *mmc = NULL;
-	struct sdricoh_host *host = NULL;
+	struct sdricoh_host *host;
 	struct device *dev = &pcmcia_dev->dev;
 	/* map iomem */
 	if (pci_resource_len(pci_dev, SDRICOH_PCI_REGION) !=
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection
  2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
  2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
@ 2015-12-29 21:02   ` SF Markus Elfring
  2016-02-21  9:15     ` Sascha Sommer
  2016-01-27 14:15   ` [PATCH 0/2] mmc-host: Fine-tuning for one function Ulf Hansson
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-29 21:02 UTC (permalink / raw)
  To: linux-mmc, Sascha Sommer, Ulf Hansson; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

* 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/host/sdricoh_cs.c | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/drivers/mmc/host/sdricoh_cs.c b/drivers/mmc/host/sdricoh_cs.c
index 5e57d9f..5ff26ab 100644
--- a/drivers/mmc/host/sdricoh_cs.c
+++ b/drivers/mmc/host/sdricoh_cs.c
@@ -400,7 +400,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 {
 	int result;
 	void __iomem *iobase;
-	struct mmc_host *mmc = NULL;
+	struct mmc_host *mmc;
 	struct sdricoh_host *host;
 	struct device *dev = &pcmcia_dev->dev;
 	/* map iomem */
@@ -419,7 +419,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 	if (readl(iobase + R104_VERSION) != 0x4000) {
 		dev_dbg(dev, "no supported mmc controller found\n");
 		result = -ENODEV;
-		goto err;
+		goto unmap_io;
 	}
 	/* allocate privdata */
 	mmc = pcmcia_dev->priv =
@@ -427,7 +427,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 	if (!mmc) {
 		dev_err(dev, "mmc_alloc_host failed\n");
 		result = -ENOMEM;
-		goto err;
+		goto unmap_io;
 	}
 	host = mmc_priv(mmc);
 
@@ -451,8 +451,7 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 	if (sdricoh_reset(host)) {
 		dev_dbg(dev, "could not reset\n");
 		result = -EIO;
-		goto err;
-
+		goto free_host;
 	}
 
 	result = mmc_add_host(mmc);
@@ -461,13 +460,10 @@ static int sdricoh_init_mmc(struct pci_dev *pci_dev,
 		dev_dbg(dev, "mmc host registered\n");
 		return 0;
 	}
-
-err:
-	if (iobase)
-		pci_iounmap(pci_dev, iobase);
-	if (mmc)
-		mmc_free_host(mmc);
-
+free_host:
+	mmc_free_host(mmc);
+unmap_io:
+	pci_iounmap(pci_dev, iobase);
 	return result;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (31 preceding siblings ...)
  2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
@ 2015-12-31 20:21 ` SF Markus Elfring
  2015-12-31 20:25   ` [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents() SF Markus Elfring
                     ` (3 more replies)
  2015-12-31 21:47 ` [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection SF Markus Elfring
                   ` (62 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 20:21 UTC (permalink / raw)
  To: linux-mtd, Brian Norris, David Woodhouse
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 21:15:15 +0100

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

Markus Elfring (3):
  Replace a variable initialisation by assignments
  Refactoring for move_block_contents()
  Refactoring for erase_block()

 drivers/mtd/rfd_ftl.c | 38 +++++++++++++++++---------------------
 1 file changed, 17 insertions(+), 21 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents()
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
@ 2015-12-31 20:25   ` SF Markus Elfring
  2015-12-31 20:26   ` [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 20:25 UTC (permalink / raw)
  To: linux-mtd, Brian Norris, David Woodhouse
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 20:34:51 +0100

Replace an explicit initialisation for the variable "rc" at the beginning
by assignments that will only be performed if a memory allocation failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/rfd_ftl.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index d1cbf26..2927e1b 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -359,17 +359,21 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
 	void *sector_data;
 	u16 *map;
 	size_t retlen;
-	int i, rc = -ENOMEM;
+	int i, rc;
 
 	part->is_reclaiming = 1;
 
 	sector_data = kmalloc(SECTOR_SIZE, GFP_KERNEL);
-	if (!sector_data)
+	if (!sector_data) {
+		rc = -ENOMEM;
 		goto err3;
+	}
 
 	map = kmalloc(part->header_size, GFP_KERNEL);
-	if (!map)
+	if (!map) {
+		rc = -ENOMEM;
 		goto err2;
+	}
 
 	rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset,
 		      part->header_size, &retlen, (u_char *)map);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents()
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
  2015-12-31 20:25   ` [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents() SF Markus Elfring
@ 2015-12-31 20:26   ` SF Markus Elfring
  2015-12-31 20:27   ` [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block() SF Markus Elfring
  2016-01-05  0:13   ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations Brian Norris
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 20:26 UTC (permalink / raw)
  To: linux-mtd, Brian Norris, David Woodhouse
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 20:54:50 +0100

This issue was detected by using the Coccinelle software.

Rename jump labels according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/rfd_ftl.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 2927e1b..9b59423 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -366,13 +366,13 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
 	sector_data = kmalloc(SECTOR_SIZE, GFP_KERNEL);
 	if (!sector_data) {
 		rc = -ENOMEM;
-		goto err3;
+		goto reset_reclaim;
 	}
 
 	map = kmalloc(part->header_size, GFP_KERNEL);
 	if (!map) {
 		rc = -ENOMEM;
-		goto err2;
+		goto free_sector;
 	}
 
 	rc = mtd_read(part->mbd.mtd, part->blocks[block_no].offset,
@@ -385,8 +385,7 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
 		printk(KERN_ERR PREFIX "error reading '%s' at "
 			"0x%lx\n", part->mbd.mtd->name,
 			part->blocks[block_no].offset);
-
-		goto err;
+		goto free_map;
 	}
 
 	for (i=0; i<part->data_sectors_per_block; i++) {
@@ -417,7 +416,6 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
 		}
 		rc = mtd_read(part->mbd.mtd, addr, SECTOR_SIZE, &retlen,
 			      sector_data);
-
 		if (!rc && retlen != SECTOR_SIZE)
 			rc = -EIO;
 
@@ -425,24 +423,20 @@ static int move_block_contents(struct partition *part, int block_no, u_long *old
 			printk(KERN_ERR PREFIX "'%s': Unable to "
 				"read sector for relocation\n",
 				part->mbd.mtd->name);
-
-			goto err;
+			goto free_map;
 		}
 
 		rc = rfd_ftl_writesect((struct mtd_blktrans_dev*)part,
 				entry, sector_data);
-
 		if (rc)
-			goto err;
+			goto free_map;
 	}
-
-err:
+free_map:
 	kfree(map);
-err2:
+free_sector:
 	kfree(sector_data);
-err3:
+reset_reclaim:
 	part->is_reclaiming = 0;
-
 	return rc;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block()
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
  2015-12-31 20:25   ` [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents() SF Markus Elfring
  2015-12-31 20:26   ` [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents() SF Markus Elfring
@ 2015-12-31 20:27   ` SF Markus Elfring
  2016-01-05  0:13   ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations Brian Norris
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 20:27 UTC (permalink / raw)
  To: linux-mtd, Brian Norris, David Woodhouse
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 31 Dec 2015 21:06:27 +0100

This issue was detected by using the Coccinelle software.

* Return directly if a memory allocation failed.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/rfd_ftl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index 9b59423..8379447 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -326,11 +326,11 @@ static void erase_callback(struct erase_info *erase)
 static int erase_block(struct partition *part, int block)
 {
 	struct erase_info *erase;
-	int rc = -ENOMEM;
+	int rc;
 
 	erase = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
 	if (!erase)
-		goto err;
+		return -ENOMEM;
 
 	erase->mtd = part->mbd.mtd;
 	erase->callback = erase_callback;
@@ -349,8 +349,6 @@ static int erase_block(struct partition *part, int block)
 				(unsigned long long)erase->len, part->mbd.mtd->name);
 		kfree(erase);
 	}
-
-err:
 	return rc;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (32 preceding siblings ...)
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
@ 2015-12-31 21:47 ` SF Markus Elfring
  2016-01-07 11:07   ` Robert Richter
  2015-12-31 23:22 ` [PATCH] be2net: Delete an unnecessary check in two functions SF Markus Elfring
                   ` (61 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 21:47 UTC (permalink / raw)
  To: netdev, linux-arm-kernel, Robert Richter, Sunil Goutham
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/cavium/thunder/nicvf_main.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index c24cb2a..21e1579 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -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;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] be2net: Delete an unnecessary check in two functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (33 preceding siblings ...)
  2015-12-31 21:47 ` [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection SF Markus Elfring
@ 2015-12-31 23:22 ` SF Markus Elfring
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
                   ` (60 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2015-12-31 23:22 UTC (permalink / raw)
  To: netdev, Ajit Khaparde, Padmanabh Ratnakar, Sathya Perla,
	Sriharsha Basavapatna
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 00:11:57 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/emulex/benet/be_cmds.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be_cmds.c b/drivers/net/ethernet/emulex/benet/be_cmds.c
index b63d8ad..ba98297 100644
--- a/drivers/net/ethernet/emulex/benet/be_cmds.c
+++ b/drivers/net/ethernet/emulex/benet/be_cmds.c
@@ -4366,9 +4366,7 @@ int be_cmd_get_profile_config(struct be_adapter *adapter,
 	if (vf_res)
 		res->vf_if_cap_flags = vf_res->cap_flags;
 err:
-	if (cmd.va)
-		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
-				  cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);
 	return status;
 }
 
@@ -4398,10 +4396,7 @@ static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
 	memcpy(req->desc, desc, size);
 
 	status = be_cmd_notify_wait(adapter, &wrb);
-
-	if (cmd.va)
-		dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va,
-				  cmd.dma);
+	dma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);
 	return status;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (34 preceding siblings ...)
  2015-12-31 23:22 ` [PATCH] be2net: Delete an unnecessary check in two functions SF Markus Elfring
@ 2016-01-01 12:18 ` SF Markus Elfring
  2016-01-01 12:22   ` [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
                     ` (3 more replies)
  2016-01-01 14:32 ` [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg() SF Markus Elfring
                   ` (59 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 12:18 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 13:15:34 +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

 drivers/net/ethernet/freescale/gianfar_ethtool.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-01 12:22   ` SF Markus Elfring
  2016-01-01 12:35     ` Julia Lawall
  2016-01-01 12:23   ` [PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 12:22 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 11:16:04 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 4b0ee85..be4941e 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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 1;
 	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;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  2016-01-01 12:22   ` [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
@ 2016-01-01 12:23   ` SF Markus Elfring
  2016-01-01 12:24   ` [PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
  2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 12:23 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 12:56:23 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index be4941e..508be89 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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),
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table()
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  2016-01-01 12:22   ` [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
  2016-01-01 12:23   ` [PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-01 12:24   ` SF Markus Elfring
  2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 12:24 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 13:00:06 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 508be89..6a7b035 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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--;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 12:22   ` [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
@ 2016-01-01 12:35     ` Julia Lawall
  2016-01-01 12:50       ` SF Markus Elfring
  2016-01-01 13:04       ` [PATCH v2 " SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-01-01 12:35 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: netdev, Claudiu Manoil, LKML, kernel-janitors



On Fri, 1 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 11:16:04 +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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> index 4b0ee85..be4941e 100644
> --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> @@ -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 1;

Why return 1?  Previously 0 was returned.

Normally, one returns -ENOMEM for this case, but it looks like this 
function is returning 0 on failure.

julia

>  	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;
>  }
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 12:35     ` Julia Lawall
@ 2016-01-01 12:50       ` SF Markus Elfring
  2016-01-01 13:05         ` Julia Lawall
  2016-01-01 13:04       ` [PATCH v2 " SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 12:50 UTC (permalink / raw)
  To: Julia Lawall; +Cc: netdev, Claudiu Manoil, LKML, kernel-janitors

>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
>> @@ -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 1;
> 
> Why return 1?  Previously 0 was returned.

You are right. - Unfortunately, I made a mistake at this place
of my update suggestion.


> Normally, one returns -ENOMEM for this case, but it looks like this 
> function is returning 0 on failure.

Should a symbol like "false" be used instead of such a special number?

Regards,
Markus


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 12:35     ` Julia Lawall
  2016-01-01 12:50       ` SF Markus Elfring
@ 2016-01-01 13:04       ` SF Markus Elfring
  2016-01-02  3:16         ` David Miller
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 13:04 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: Julia Lawall, LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 13:56:09 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 4b0ee85..825b051 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 12:50       ` SF Markus Elfring
@ 2016-01-01 13:05         ` Julia Lawall
  2016-01-01 14:45           ` Francois Romieu
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-01-01 13:05 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, netdev, Claudiu Manoil, LKML, kernel-janitors

On Fri, 1 Jan 2016, SF Markus Elfring wrote:

> >> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> >> @@ -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 1;
> > 
> > Why return 1?  Previously 0 was returned.
> 
> You are right. - Unfortunately, I made a mistake at this place
> of my update suggestion.
> 
> 
> > Normally, one returns -ENOMEM for this case, but it looks like this 
> > function is returning 0 on failure.
> 
> Should a symbol like "false" be used instead of such a special number?

Maybe it's better than 0 and 1...

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (35 preceding siblings ...)
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-01 14:32 ` SF Markus Elfring
  2016-01-07 22:43   ` Nelson, Shannon
  2016-01-08 10:42   ` Jeff Kirsher
  2016-01-01 15:57 ` [PATCH] net-huawei_cdc_ncm: Delete an unnecessary variable initialisation in huawei_cdc_ncm_bind() SF Markus Elfring
                   ` (58 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 14:32 UTC (permalink / raw)
  To: netdev, intel-wired-lan, Bruce Allan, Carolyn Wyborny,
	Don Skidmore, Jeff Kirsher, Jesse Brandeburg, John Ronciak,
	Mitch Williams, Shannon Nelson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
index aa58a49..e0874f5 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c
@@ -1172,16 +1172,18 @@ static int i40e_vc_get_version_msg(struct i40e_vf *vf, u8 *msg)
  **/
 static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
 {
-	struct i40e_virtchnl_vf_resource *vfres = NULL;
-	struct i40e_pf *pf = vf->pf;
-	i40e_status aq_ret = 0;
+	struct i40e_virtchnl_vf_resource *vfres;
+	struct i40e_pf *pf;
+	i40e_status aq_ret;
 	struct i40e_vsi *vsi;
-	int i = 0, len = 0;
+	int i = 0;
 	int num_vsis = 1;
-	int ret;
+	int len, ret;
 
 	if (!test_bit(I40E_VF_STAT_INIT, &vf->vf_states)) {
 		aq_ret = I40E_ERR_PARAM;
+		vfres = NULL;
+		len = 0;
 		goto err;
 	}
 
@@ -1202,6 +1204,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
 				  I40E_VIRTCHNL_VF_OFFLOAD_VLAN;
 
 	vfres->vf_offload_flags = I40E_VIRTCHNL_VF_OFFLOAD_L2;
+	pf = vf->pf;
 	vsi = pf->vsi[vf->lan_vsi_idx];
 	if (!vsi->info.pvid)
 		vfres->vf_offload_flags |= I40E_VIRTCHNL_VF_OFFLOAD_VLAN;
@@ -1231,7 +1234,7 @@ static int i40e_vc_get_vf_resources_msg(struct i40e_vf *vf, u8 *msg)
 		i++;
 	}
 	set_bit(I40E_VF_STAT_ACTIVE, &vf->vf_states);
-
+	aq_ret = 0;
 err:
 	/* send the response back to the VF */
 	ret = i40e_vc_send_msg_to_vf(vf, I40E_VIRTCHNL_OP_GET_VF_RESOURCES,
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 13:05         ` Julia Lawall
@ 2016-01-01 14:45           ` Francois Romieu
  0 siblings, 0 replies; 1373+ messages in thread
From: Francois Romieu @ 2016-01-01 14:45 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, netdev, Claudiu Manoil, LKML, kernel-janitors

Julia Lawall <julia.lawall@lip6.fr> :
> On Fri, 1 Jan 2016, SF Markus Elfring wrote:
[...]
> > > Normally, one returns -ENOMEM for this case, but it looks like this 
> > > function is returning 0 on failure.
> > 
> > Should a symbol like "false" be used instead of such a special number?
> 
> Maybe it's better than 0 and 1...

Your suggestion about -ENOMEM is consistent with the callchain. Nothing
else is needed.

Btw:
1. kfree does not care about NULL parameter, especially in this hardly
   timing sensitive path.
2. kmalloc_array for small kernel controlled arrays of integers (see
   drivers/net/ethernet/freescale/gianfar.h), seriously ?

   I'd suggest the janitor to introduce a dedicated struct to embed both
   gfar_private.ftp_rqf{p, c}r then use a single, plain kmalloc in
   gfar_ethflow_to_filer_table.

Happy tasteful 2016 :o)

-- 
Ueimor

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] net-huawei_cdc_ncm: Delete an unnecessary variable initialisation in huawei_cdc_ncm_bind()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (36 preceding siblings ...)
  2016-01-01 14:32 ` [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg() SF Markus Elfring
@ 2016-01-01 15:57 ` SF Markus Elfring
  2016-01-01 16:50 ` [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations SF Markus Elfring
                   ` (57 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 15:57 UTC (permalink / raw)
  To: linux-usb, netdev; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 16:54:13 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/huawei_cdc_ncm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c
index 2680a65..53caeb3 100644
--- a/drivers/net/usb/huawei_cdc_ncm.c
+++ b/drivers/net/usb/huawei_cdc_ncm.c
@@ -71,7 +71,7 @@ static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev,
 {
 	struct cdc_ncm_ctx *ctx;
 	struct usb_driver *subdriver = ERR_PTR(-ENODEV);
-	int ret = -ENODEV;
+	int ret;
 	struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data;
 	int drvflags = 0;
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (37 preceding siblings ...)
  2016-01-01 15:57 ` [PATCH] net-huawei_cdc_ncm: Delete an unnecessary variable initialisation in huawei_cdc_ncm_bind() SF Markus Elfring
@ 2016-01-01 16:50 ` SF Markus Elfring
  2016-01-01 16:54   ` [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind() SF Markus Elfring
  2016-01-01 16:56   ` [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver() SF Markus Elfring
  2016-01-01 18:21 ` [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations SF Markus Elfring
                   ` (56 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 16:50 UTC (permalink / raw)
  To: linux-usb, netdev, Bjørn Mork; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 17:47:46 +0100

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

Markus Elfring (2):
  Refactoring for qmi_wwan_bind()
  Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()

 drivers/net/usb/qmi_wwan.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind()
  2016-01-01 16:50 ` [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-01 16:54   ` SF Markus Elfring
  2016-01-02 21:38     ` Bjørn Mork
  2016-01-01 16:56   ` [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver() SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 16:54 UTC (permalink / raw)
  To: linux-usb, netdev, Bjørn Mork; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 17:32:07 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/qmi_wwan.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index d0b2973..5b8af06 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -345,7 +345,6 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 	int status = -1;
 	u8 *buf = intf->cur_altsetting->extra;
 	int len = intf->cur_altsetting->extralen;
-	struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
 	struct usb_cdc_union_desc *cdc_union;
 	struct usb_cdc_ether_desc *cdc_ether;
 	struct usb_driver *driver = driver_of(intf);
@@ -366,6 +365,8 @@ static int qmi_wwan_bind(struct usbnet *dev, struct usb_interface *intf)
 
 	/* Use separate control and data interfaces if we found a CDC Union */
 	if (cdc_union) {
+		struct usb_interface_descriptor *desc = &intf->cur_altsetting->desc;
+
 		info->data = usb_ifnum_to_if(dev->udev,
 					     cdc_union->bSlaveInterface0);
 		if (desc->bInterfaceNumber != cdc_union->bMasterInterface0 ||
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
  2016-01-01 16:50 ` [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-01 16:54   ` [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind() SF Markus Elfring
@ 2016-01-01 16:56   ` SF Markus Elfring
  2016-01-02 21:30     ` Bjørn Mork
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 16:56 UTC (permalink / raw)
  To: linux-usb, netdev, Bjørn Mork; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/usb/qmi_wwan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 5b8af06..5962099 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -286,7 +286,7 @@ static int qmi_wwan_cdc_wdm_manage_power(struct usb_interface *intf, int on)
 static int qmi_wwan_register_subdriver(struct usbnet *dev)
 {
 	int rv;
-	struct usb_driver *subdriver = NULL;
+	struct usb_driver *subdriver;
 	struct qmi_wwan_state *info = (void *)&dev->data;
 
 	/* collect bulk endpoints */
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (38 preceding siblings ...)
  2016-01-01 16:50 ` [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-01 18:21 ` SF Markus Elfring
  2016-01-01 18:23   ` [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream() SF Markus Elfring
  2016-01-01 18:25   ` [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel() SF Markus Elfring
  2016-01-01 19:26 ` [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware() SF Markus Elfring
                   ` (55 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 18:21 UTC (permalink / raw)
  To: ath9k-devel, linux-wireless, netdev, ath9k-devel, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 19:16:05 +0100

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

Markus Elfring (2):
  Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream()
  Replace a variable initialisation by an assignment in ath9k_htc_set_channel()

 drivers/net/wireless/ath/ath9k/hif_usb.c      | 2 +-
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++-----
 2 files changed, 3 insertions(+), 6 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream()
  2016-01-01 18:21 ` [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-01 18:23   ` SF Markus Elfring
  2016-01-01 19:14     ` Oleksij Rempel
  2016-01-01 18:25   ` [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel() SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 18:23 UTC (permalink / raw)
  To: ath9k-devel, linux-wireless, netdev, ath9k-devel, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 19:00:53 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 165dd20..51bd61b 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -525,7 +525,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
 				    struct sk_buff *skb)
 {
 	struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER];
-	int index = 0, i = 0, len = skb->len;
+	int index = 0, i, len = skb->len;
 	int rx_remain_len, rx_pkt_len;
 	u16 pool_index = 0;
 	u8 *ptr;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-01-01 18:21 ` [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-01 18:23   ` [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream() SF Markus Elfring
@ 2016-01-01 18:25   ` SF Markus Elfring
  2016-01-01 19:14     ` Oleksij Rempel
  2016-04-08  1:40     ` Julian Calaby
  1 sibling, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 18:25 UTC (permalink / raw)
  To: ath9k-devel, linux-wireless, netdev, ath9k-devel, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 19:09:32 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index a680a97..30bd59e 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -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


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-01-01 18:25   ` [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel() SF Markus Elfring
@ 2016-01-01 19:14     ` Oleksij Rempel
  2016-04-08  1:40     ` Julian Calaby
  1 sibling, 0 replies; 1373+ messages in thread
From: Oleksij Rempel @ 2016-01-01 19:14 UTC (permalink / raw)
  To: SF Markus Elfring, ath9k-devel, linux-wireless, netdev,
	ath9k-devel, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 1572 bytes --]

Am 01.01.2016 um 19:25 schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 19:09:32 +0100
> 
> Replace an explicit initialisation for one local variable at the beginning
> by a conditional assignment.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> index a680a97..30bd59e 100644
> --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> @@ -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,
> 

Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>

-- 
Regards,
Oleksij


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream()
  2016-01-01 18:23   ` [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream() SF Markus Elfring
@ 2016-01-01 19:14     ` Oleksij Rempel
  0 siblings, 0 replies; 1373+ messages in thread
From: Oleksij Rempel @ 2016-01-01 19:14 UTC (permalink / raw)
  To: SF Markus Elfring, ath9k-devel, linux-wireless, netdev,
	ath9k-devel, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

Am 01.01.2016 um 19:23 schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 19:00:53 +0100
> 
> Omit explicit initialisation at the beginning for one local variable
> that is redefined before its first use.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wireless/ath/ath9k/hif_usb.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
> index 165dd20..51bd61b 100644
> --- a/drivers/net/wireless/ath/ath9k/hif_usb.c
> +++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
> @@ -525,7 +525,7 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb *hif_dev,
>  				    struct sk_buff *skb)
>  {
>  	struct sk_buff *nskb, *skb_pool[MAX_PKT_NUM_IN_TRANSFER];
> -	int index = 0, i = 0, len = skb->len;
> +	int index = 0, i, len = skb->len;
>  	int rx_remain_len, rx_pkt_len;
>  	u16 pool_index = 0;
>  	u8 *ptr;
> 


Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>

-- 
Regards,
Oleksij


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (39 preceding siblings ...)
  2016-01-01 18:21 ` [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-01 19:26 ` SF Markus Elfring
  2016-01-02  8:50   ` Arend van Spriel
  2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
                   ` (54 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 19:26 UTC (permalink / raw)
  To: brcm80211-dev-list, linux-wireless, netdev, Arend van Spriel,
	Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 20:20:15 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
index ceb2a75..c21eeb1 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
@@ -3260,7 +3260,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,
 					const struct firmware *fw,
 					void *nvram, u32 nvlen)
 {
-	int bcmerror = -EFAULT;
+	int bcmerror;
 	u32 rstvec;
 
 	sdio_claim_host(bus->sdiodev->func[1]);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (40 preceding siblings ...)
  2016-01-01 19:26 ` [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware() SF Markus Elfring
@ 2016-01-01 20:27 ` SF Markus Elfring
  2016-01-01 20:30   ` [PATCH 1/3] net-iwlegacy: Refactoring " SF Markus Elfring
                     ` (2 more replies)
  2016-01-01 21:33 ` [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker() SF Markus Elfring
                   ` (53 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 20:27 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 21:25:43 +0100

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

Markus Elfring (3):
  Refactoring
  One check less after error detection
  Another refactoring

 drivers/net/wireless/intel/iwlegacy/common.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] net-iwlegacy: Refactoring for il_eeprom_init()
  2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
@ 2016-01-01 20:30   ` SF Markus Elfring
  2016-01-04  9:33     ` Stanislaw Gruszka
  2016-01-01 20:31   ` [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection SF Markus Elfring
  2016-01-01 20:32   ` [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init() SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 20:30 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 20:54:25 +0100

Return directly if a memory allocation failed at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/intel/iwlegacy/common.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index eb5cb60..c3afaf7 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -723,10 +723,9 @@ il_eeprom_init(struct il_priv *il)
 	sz = il->cfg->eeprom_size;
 	D_EEPROM("NVM size = %d\n", sz);
 	il->eeprom = kzalloc(sz, GFP_KERNEL);
-	if (!il->eeprom) {
-		ret = -ENOMEM;
-		goto alloc_err;
-	}
+	if (!il->eeprom)
+		return -ENOMEM;
+
 	e = (__le16 *) il->eeprom;
 
 	il->ops->apm_init(il);
@@ -778,7 +777,6 @@ err:
 		il_eeprom_free(il);
 	/* Reset chip to save power until we load uCode during "up". */
 	il_apm_stop(il);
-alloc_err:
 	return ret;
 }
 EXPORT_SYMBOL(il_eeprom_init);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection
  2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
  2016-01-01 20:30   ` [PATCH 1/3] net-iwlegacy: Refactoring " SF Markus Elfring
@ 2016-01-01 20:31   ` SF Markus Elfring
  2016-01-01 23:13     ` Sergei Shtylyov
  2016-01-01 20:32   ` [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init() SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 20:31 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 21:12:29 +0100

This issue was detected by using the Coccinelle software.

Adjust a jump target to avoid a check repetition before the function
call "il_eeprom_free".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/intel/iwlegacy/common.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index c3afaf7..ae45fd3 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -734,7 +734,7 @@ il_eeprom_init(struct il_priv *il)
 	if (ret < 0) {
 		IL_ERR("EEPROM not found, EEPROM_GP=0x%08x\n", gp);
 		ret = -ENOENT;
-		goto err;
+		goto free_eeprom;
 	}
 
 	/* Make sure driver (instead of uCode) is allowed to read EEPROM */
@@ -742,7 +742,7 @@ il_eeprom_init(struct il_priv *il)
 	if (ret < 0) {
 		IL_ERR("Failed to acquire EEPROM semaphore.\n");
 		ret = -ENOENT;
-		goto err;
+		goto free_eeprom;
 	}
 
 	/* eeprom is an array of 16bit values */
@@ -772,9 +772,11 @@ il_eeprom_init(struct il_priv *il)
 done:
 	il->ops->eeprom_release_semaphore(il);
 
-err:
-	if (ret)
+	if (ret) {
+free_eeprom:
 		il_eeprom_free(il);
+	}
+
 	/* Reset chip to save power until we load uCode during "up". */
 	il_apm_stop(il);
 	return ret;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init()
  2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
  2016-01-01 20:30   ` [PATCH 1/3] net-iwlegacy: Refactoring " SF Markus Elfring
  2016-01-01 20:31   ` [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection SF Markus Elfring
@ 2016-01-01 20:32   ` SF Markus Elfring
  2016-01-02 18:18     ` Souptick Joarder
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 20:32 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 21:16:01 +0100

Rename a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/intel/iwlegacy/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
index ae45fd3..660ab2b 100644
--- a/drivers/net/wireless/intel/iwlegacy/common.c
+++ b/drivers/net/wireless/intel/iwlegacy/common.c
@@ -759,7 +759,7 @@ il_eeprom_init(struct il_priv *il)
 				 IL_EEPROM_ACCESS_TIMEOUT);
 		if (ret < 0) {
 			IL_ERR("Time out reading EEPROM[%d]\n", addr);
-			goto done;
+			goto release_semaphore;
 		}
 		r = _il_rd(il, CSR_EEPROM_REG);
 		e[addr / 2] = cpu_to_le16(r >> 16);
@@ -769,7 +769,7 @@ il_eeprom_init(struct il_priv *il)
 		 il_eeprom_query16(il, EEPROM_VERSION));
 
 	ret = 0;
-done:
+release_semaphore:
 	il->ops->eeprom_release_semaphore(il);
 
 	if (ret) {
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (41 preceding siblings ...)
  2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
@ 2016-01-01 21:33 ` SF Markus Elfring
  2016-01-01 21:41   ` Julia Lawall
  2016-01-01 23:14   ` Sergei Shtylyov
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
                   ` (52 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-01 21:33 UTC (permalink / raw)
  To: libertas-dev, linux-wireless, netdev, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 1 Jan 2016 22:27:20 +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 function call failed.
Use the identifier "report_failure" instead of the label "err".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/marvell/libertas/if_spi.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c b/drivers/net/wireless/marvell/libertas/if_spi.c
index 82c0796..c9ae27e 100644
--- a/drivers/net/wireless/marvell/libertas/if_spi.c
+++ b/drivers/net/wireless/marvell/libertas/if_spi.c
@@ -880,18 +880,18 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
 				&hiStatus);
 	if (err) {
 		netdev_err(priv->dev, "I/O error\n");
-		goto err;
+		goto report_failure;
 	}
 
 	if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY) {
 		err = if_spi_c2h_cmd(card);
 		if (err)
-			goto err;
+			goto report_failure;
 	}
 	if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY) {
 		err = if_spi_c2h_data(card);
 		if (err)
-			goto err;
+			goto report_failure;
 	}
 
 	/*
@@ -940,9 +940,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
 	if (hiStatus & IF_SPI_HIST_CARD_EVENT)
 		if_spi_e2h(card);
 
-err:
-	if (err)
+	if (err) {
+report_failure:
 		netdev_err(priv->dev, "%s: got error %d\n", __func__, err);
+	}
 
 	lbs_deb_leave(LBS_DEB_SPI);
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-01 21:33 ` [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker() SF Markus Elfring
@ 2016-01-01 21:41   ` Julia Lawall
  2016-01-01 23:14   ` Sergei Shtylyov
  1 sibling, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-01-01 21:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: libertas-dev, linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors



On Fri, 1 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 22:27:20 +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 function call failed.

Putting a label inside an if is ugly.

julia

> Use the identifier "report_failure" instead of the label "err".
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wireless/marvell/libertas/if_spi.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/wireless/marvell/libertas/if_spi.c b/drivers/net/wireless/marvell/libertas/if_spi.c
> index 82c0796..c9ae27e 100644
> --- a/drivers/net/wireless/marvell/libertas/if_spi.c
> +++ b/drivers/net/wireless/marvell/libertas/if_spi.c
> @@ -880,18 +880,18 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  				&hiStatus);
>  	if (err) {
>  		netdev_err(priv->dev, "I/O error\n");
> -		goto err;
> +		goto report_failure;
>  	}
>  
>  	if (hiStatus & IF_SPI_HIST_CMD_UPLOAD_RDY) {
>  		err = if_spi_c2h_cmd(card);
>  		if (err)
> -			goto err;
> +			goto report_failure;
>  	}
>  	if (hiStatus & IF_SPI_HIST_RX_UPLOAD_RDY) {
>  		err = if_spi_c2h_data(card);
>  		if (err)
> -			goto err;
> +			goto report_failure;
>  	}
>  
>  	/*
> @@ -940,9 +940,10 @@ static void if_spi_host_to_card_worker(struct work_struct *work)
>  	if (hiStatus & IF_SPI_HIST_CARD_EVENT)
>  		if_spi_e2h(card);
>  
> -err:
> -	if (err)
> +	if (err) {
> +report_failure:
>  		netdev_err(priv->dev, "%s: got error %d\n", __func__, err);
> +	}
>  
>  	lbs_deb_leave(LBS_DEB_SPI);
>  }
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection
  2016-01-01 20:31   ` [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection SF Markus Elfring
@ 2016-01-01 23:13     ` Sergei Shtylyov
  0 siblings, 0 replies; 1373+ messages in thread
From: Sergei Shtylyov @ 2016-01-01 23:13 UTC (permalink / raw)
  To: SF Markus Elfring, linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka
  Cc: LKML, kernel-janitors, Julia Lawall

Hello.

On 1/1/2016 11:31 PM, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 21:12:29 +0100
>
> This issue was detected by using the Coccinelle software.
>
> Adjust a jump target to avoid a check repetition before the function
> call "il_eeprom_free".

    One question: why?

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/intel/iwlegacy/common.c | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
> index c3afaf7..ae45fd3 100644
> --- a/drivers/net/wireless/intel/iwlegacy/common.c
> +++ b/drivers/net/wireless/intel/iwlegacy/common.c
[...]
> @@ -772,9 +772,11 @@ il_eeprom_init(struct il_priv *il)
>   done:
>   	il->ops->eeprom_release_semaphore(il);
>
> -err:
> -	if (ret)
> +	if (ret) {
> +free_eeprom:

    This is ugly, I'd say.

[...]

MBR, Sergei


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-01 21:33 ` [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker() SF Markus Elfring
  2016-01-01 21:41   ` Julia Lawall
@ 2016-01-01 23:14   ` Sergei Shtylyov
  2016-01-02  8:09     ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Sergei Shtylyov @ 2016-01-01 23:14 UTC (permalink / raw)
  To: SF Markus Elfring, libertas-dev, linux-wireless, netdev, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

Hello

On 1/2/2016 12:33 AM, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 22:27:20 +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 function call failed.
> Use the identifier "report_failure" instead of the label "err".

    Why? The code was smart enough and you're making it uglier that it needs 
to be.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

MBR, Sergei


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-01 13:04       ` [PATCH v2 " SF Markus Elfring
@ 2016-01-02  3:16         ` David Miller
  0 siblings, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-01-02  3:16 UTC (permalink / raw)
  To: elfring
  Cc: netdev, claudiu.manoil, julia.lawall, linux-kernel, kernel-janitors


This is not the proper way to resubmit patches when you are asked
to make changes to some portion of a multi-patch series.

You must always resubmit the entire series when this happens,
not just the patch that changes.

And in the revised cover "0/N" posting you list the revisions
that were made.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-01 23:14   ` Sergei Shtylyov
@ 2016-01-02  8:09     ` SF Markus Elfring
  2016-01-02  8:21       ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02  8:09 UTC (permalink / raw)
  To: Sergei Shtylyov, libertas-dev, linux-wireless, netdev, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

>> 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.


> The code was smart enough

Which action should really be performed after a failure was detected
and handled a bit already?

* Another condition check

* Just additional error logging


> and you're making it uglier that it needs to be.

I assume that a software development taste can evolve, can't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02  8:09     ` SF Markus Elfring
@ 2016-01-02  8:21       ` Julia Lawall
  2016-01-02  9:08         ` SF Markus Elfring
  2016-01-21 15:07         ` [PATCH] " Kalle Valo
  0 siblings, 2 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-01-02  8:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Sergei Shtylyov, libertas-dev, linux-wireless, netdev,
	Kalle Valo, LKML, kernel-janitors



On Sat, 2 Jan 2016, SF Markus Elfring wrote:

> >> 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.
> 
> 
> > The code was smart enough
> 
> Which action should really be performed after a failure was detected
> and handled a bit already?
> 
> * Another condition check
> 
> * Just additional error logging
> 
> 
> > 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?

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.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
  2016-01-01 19:26 ` [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware() SF Markus Elfring
@ 2016-01-02  8:50   ` Arend van Spriel
  2016-01-14  6:58     ` Kalle Valo
  0 siblings, 1 reply; 1373+ messages in thread
From: Arend van Spriel @ 2016-01-02  8:50 UTC (permalink / raw)
  To: SF Markus Elfring, brcm80211-dev-list, linux-wireless, netdev,
	Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

On 01/01/2016 08:26 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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-'.

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

That being said here is my....

Acked-by: Arend van Spriel <arend@broadcom.com>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
> index ceb2a75..c21eeb1 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
> @@ -3260,7 +3260,7 @@ static int brcmf_sdio_download_firmware(struct brcmf_sdio *bus,
>   					const struct firmware *fw,
>   					void *nvram, u32 nvlen)
>   {
> -	int bcmerror = -EFAULT;
> +	int bcmerror;
>   	u32 rstvec;
>
>   	sdio_claim_host(bus->sdiodev->func[1]);
>


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02  8:21       ` Julia Lawall
@ 2016-01-02  9:08         ` SF Markus Elfring
  2016-01-02 10:13           ` Arend van Spriel
  2016-01-21 15:07         ` [PATCH] " Kalle Valo
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02  9:08 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Sergei Shtylyov, libertas-dev, linux-wireless, netdev,
	Kalle Valo, LKML, kernel-janitors

>> 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,

I am curious when more contributors will share corresponding opinions.


> and no enthusiasm.

How many software designers and developers can become enthusiastic
about better exception handling to some degree?


> The code that is performance critical, you should probably not touch, ever.

I imagine that technical evolution will result in further considerations
so that "unchangeable" components can be adjusted once more.


> The people who wrote it knew what was important and what was not.

I might come along at some places where the affected knowledge will also evolve.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02  9:08         ` SF Markus Elfring
@ 2016-01-02 10:13           ` Arend van Spriel
  2016-01-02 11:21             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Arend van Spriel @ 2016-01-02 10:13 UTC (permalink / raw)
  To: SF Markus Elfring, Julia Lawall
  Cc: Sergei Shtylyov, libertas-dev, linux-wireless, netdev,
	Kalle Valo, LKML, kernel-janitors



On 02-01-16 10:08, SF Markus Elfring wrote:
>>> 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,
> 
> I am curious when more contributors will share corresponding opinions.

Let's burn some cycles on this while the holidays give me time to do so.
"software development taste" is another term for "coding style". In
every project battles are fought over this between friends and foes. I
have never seen much evolution going on in this area.

>> and no enthusiasm.
> 
> How many software designers and developers can become enthusiastic
> about better exception handling to some degree?

I had to  take a look at this particular patch and I have to say that I
don't see, using your favorite term, evolution at work. It looks more
like the result of inbred. What the patch tries to do is avoid the extra
'if (err)'. Setting coding style aside, the question is whether there is
a good metric for the patch. So does it really safe processing time? Did
you look at the resulting assembly code for different target architectures?

You got pushed back on the change so you have to come up with solid
arguments for your change instead of spewing ideas about evolution in
software development. Running Coccinelle is one thing, but understanding
the results and what you are ultimately proposing to be changed is more
important.

Regards,
Arend

>> The code that is performance critical, you should probably not touch, ever.
> 
> I imagine that technical evolution will result in further considerations
> so that "unchangeable" components can be adjusted once more.
> 
> 
>> The people who wrote it knew what was important and what was not.
> 
> I might come along at some places where the affected knowledge will also evolve.
> 
> Regards,
> Markus
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02 10:13           ` Arend van Spriel
@ 2016-01-02 11:21             ` SF Markus Elfring
  2016-01-03  9:36               ` Arend van Spriel
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 11:21 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Julia Lawall, Sergei Shtylyov, libertas-dev, linux-wireless,
	netdev, Kalle Valo, LKML, kernel-janitors

> 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


> 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.


> 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.)

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


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

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] net-rsi: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (42 preceding siblings ...)
  2016-01-01 21:33 ` [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker() SF Markus Elfring
@ 2016-01-02 14:40 ` SF Markus Elfring
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
                     ` (3 more replies)
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                   ` (51 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 14:40 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 15:36:25 +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 | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-02 14:43   ` SF Markus Elfring
  2016-01-02 15:12     ` net-rsi: Reconsider usage of variable "vap_id" " SF Markus Elfring
                       ` (2 more replies)
  2016-01-02 14:44   ` [PATCH 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 14:43 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 14:54:30 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index 702593f..ee98f5b 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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;
+	int status;
+	__le16 *msg;
+	u8 extnd_size;
 	u8 vap_id = 0;
 
 	info = IEEE80211_SKB_CB(skb);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt()
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
@ 2016-01-02 14:44   ` SF Markus Elfring
  2016-01-02 14:45   ` [PATCH 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
  2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 14:44 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 15:15:12 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index ee98f5b..ec65e1c 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
  2016-01-02 14:44   ` [PATCH 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
@ 2016-01-02 14:45   ` SF Markus Elfring
  2016-01-02 15:07     ` Francois Romieu
  2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 14:45 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 15:25:34 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index ec65e1c..fe36e7d 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
  2016-01-02 14:45   ` [PATCH 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
@ 2016-01-02 15:07     ` Francois Romieu
  0 siblings, 0 replies; 1373+ messages in thread
From: Francois Romieu @ 2016-01-02 15:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 2 Jan 2016 15:25:34 +0100
> 
> Replace explicit initialisation for two local variables at the beginning
> by assignments.

It makes no sense for the 'adapter' variable.

-- 
Ueimor

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* net-rsi: Reconsider usage of variable "vap_id" in rsi_send_mgmt_pkt()
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
@ 2016-01-02 15:12     ` SF Markus Elfring
  2016-01-02 16:32     ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations " kbuild test robot
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 15:12 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo; +Cc: LKML, kernel-janitors, Julia Lawall

Hello,

I have taken another look at the implementation of the function "rsi_send_mgmt_pkt".
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/wireless/rsi/rsi_91x_pkt.c?id=e8c58e7a5a106c3d557fccd01cd4d1128f9bab38#n114

I find the following statement combination interesting there.

…
	u8 vap_id = 0;
…
	msg[7] |= cpu_to_le16(vap_id << 8);
…

I would appreciate a further clarification.
Does a shift operation for a variable which contains zero indicate an open issue?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
  2016-01-02 15:12     ` net-rsi: Reconsider usage of variable "vap_id" " SF Markus Elfring
@ 2016-01-02 16:32     ` kbuild test robot
  2016-01-02 18:27       ` [PATCH v2 " SF Markus Elfring
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
  2 siblings, 1 reply; 1373+ messages in thread
From: kbuild test robot @ 2016-01-02 16:32 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 2786 bytes --]

Hi Markus,

[auto build test WARNING on wireless-drivers-next/master]
[also build test WARNING on v4.4-rc7 next-20151231]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/net-rsi-Fine-tuning-for-two-function-implementations/20160102-224740
base:   https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master
config: x86_64-randconfig-s2-01030012 (attached as .config)
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   drivers/net/wireless/rsi/rsi_91x_pkt.c: In function 'rsi_send_mgmt_pkt':
>> drivers/net/wireless/rsi/rsi_91x_pkt.c:211:2: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized]
     rsi_indicate_tx_status(common->priv, skb, status);
     ^

vim +/status +211 drivers/net/wireless/rsi/rsi_91x_pkt.c

dad0d04f Fariya Fatima 2014-03-16  195  	/* Indicate to firmware to give cfm */
dad0d04f Fariya Fatima 2014-03-16  196  	if ((skb->data[16] == IEEE80211_STYPE_PROBE_REQ) && (!bss->assoc)) {
dad0d04f Fariya Fatima 2014-03-16  197  		msg[1] |= cpu_to_le16(BIT(10));
dad0d04f Fariya Fatima 2014-03-16  198  		msg[7] = cpu_to_le16(PROBEREQ_CONFIRM);
dad0d04f Fariya Fatima 2014-03-16  199  		common->mgmt_q_block = true;
dad0d04f Fariya Fatima 2014-03-16  200  	}
dad0d04f Fariya Fatima 2014-03-16  201  
dad0d04f Fariya Fatima 2014-03-16  202  	msg[7] |= cpu_to_le16(vap_id << 8);
dad0d04f Fariya Fatima 2014-03-16  203  
dad0d04f Fariya Fatima 2014-03-16  204  	status = adapter->host_intf_write_pkt(common->priv,
dad0d04f Fariya Fatima 2014-03-16  205  					      (u8 *)msg,
dad0d04f Fariya Fatima 2014-03-16  206  					      skb->len);
dad0d04f Fariya Fatima 2014-03-16  207  	if (status)
dad0d04f Fariya Fatima 2014-03-16  208  		rsi_dbg(ERR_ZONE, "%s: Failed to write the packet\n", __func__);
dad0d04f Fariya Fatima 2014-03-16  209  
dad0d04f Fariya Fatima 2014-03-16  210  err:
dad0d04f Fariya Fatima 2014-03-16 @211  	rsi_indicate_tx_status(common->priv, skb, status);
dad0d04f Fariya Fatima 2014-03-16  212  	return status;
dad0d04f Fariya Fatima 2014-03-16  213  }

:::::: The code at line 211 was first introduced by commit
:::::: dad0d04fa7ba41ce603a01e8e64967650303e9a2 rsi: Add RS9113 wireless driver

:::::: TO: Fariya Fatima <fariyaf@gmail.com>
:::::: CC: John W. Linville <linville@tuxdriver.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 27399 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (43 preceding siblings ...)
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-02 17:50 ` SF Markus Elfring
  2016-01-02 17:54   ` [PATCH 1/5] xen-netback: Delete an unnecessary assignment in connect_rings() SF Markus Elfring
                     ` (7 more replies)
  2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
                   ` (50 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 17:50 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 18:46:45 +0100

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

Markus Elfring (5):
  Delete an unnecessary assignment in connect_rings()
  Delete an unnecessary goto statement in connect_rings()
  Replace a variable initialisation by an assignment in read_xenbus_vif_flags()
  Replace a variable initialisation by an assignment in xen_register_watchers()
  Delete an unnecessary variable initialisation in xen_register_watchers()

 drivers/net/xen-netback/xenbus.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] xen-netback: Delete an unnecessary assignment in connect_rings()
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
@ 2016-01-02 17:54   ` SF Markus Elfring
  2016-01-02 17:55   ` [PATCH 2/5] xen-netback: Delete an unnecessary goto statement " SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 17:54 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 17:32:40 +0100

Remove the assignment for a local variable because its value is not
changed compared to the one from a previous function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/xen-netback/xenbus.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 56ebd82..7f2895d 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -941,7 +941,6 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)
 		goto err;
 	}
 
-	err = 0;
 err: /* Regular return falls through with err == 0 */
 	kfree(xspath);
 	return err;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] xen-netback: Delete an unnecessary goto statement in connect_rings()
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
  2016-01-02 17:54   ` [PATCH 1/5] xen-netback: Delete an unnecessary assignment in connect_rings() SF Markus Elfring
@ 2016-01-02 17:55   ` SF Markus Elfring
  2016-01-02 17:57   ` [PATCH 3/5] xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags() SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 17:55 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 17:50:21 +0100

One goto statement referred to a source code position directly behind it.
Thus omit such an unnecessary jump.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/xen-netback/xenbus.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 7f2895d..d4947e1 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -933,13 +933,11 @@ static int connect_rings(struct backend_info *be, struct xenvif_queue *queue)
 	/* Map the shared frame, irq etc. */
 	err = xenvif_connect(queue, tx_ring_ref, rx_ring_ref,
 			     tx_evtchn, rx_evtchn);
-	if (err) {
+	if (err)
 		xenbus_dev_fatal(dev, err,
 				 "mapping shared-frames %lu/%lu port tx %u rx %u",
 				 tx_ring_ref, rx_ring_ref,
 				 tx_evtchn, rx_evtchn);
-		goto err;
-	}
 
 err: /* Regular return falls through with err == 0 */
 	kfree(xspath);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags()
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
  2016-01-02 17:54   ` [PATCH 1/5] xen-netback: Delete an unnecessary assignment in connect_rings() SF Markus Elfring
  2016-01-02 17:55   ` [PATCH 2/5] xen-netback: Delete an unnecessary goto statement " SF Markus Elfring
@ 2016-01-02 17:57   ` SF Markus Elfring
  2016-01-02 17:58   ` [PATCH 4/5] xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers() SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 17:57 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 18:01:57 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/xen-netback/xenbus.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index d4947e1..aff963f 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -946,7 +946,7 @@ err: /* Regular return falls through with err == 0 */
 
 static int read_xenbus_vif_flags(struct backend_info *be)
 {
-	struct xenvif *vif = be->vif;
+	struct xenvif *vif;
 	struct xenbus_device *dev = be->dev;
 	unsigned int rx_copy;
 	int err, val;
@@ -968,13 +968,14 @@ static int read_xenbus_vif_flags(struct backend_info *be)
 	if (xenbus_scanf(XBT_NIL, dev->otherend,
 			 "feature-rx-notify", "%d", &val) < 0)
 		val = 0;
+	vif = be->vif;
 	if (!val) {
 		/* - Reduce drain timeout to poll more frequently for
 		 *   Rx requests.
 		 * - Disable Rx stall detection.
 		 */
-		be->vif->drain_timeout = msecs_to_jiffies(30);
-		be->vif->stall_timeout = 0;
+		vif->drain_timeout = msecs_to_jiffies(30);
+		vif->stall_timeout = 0;
 	}
 
 	if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-sg",
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers()
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-01-02 17:57   ` [PATCH 3/5] xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags() SF Markus Elfring
@ 2016-01-02 17:58   ` SF Markus Elfring
  2016-01-02 18:00   ` [PATCH 5/5] xen-netback: Delete an unnecessary variable initialisation " SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 17:58 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 18:23:16 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/xen-netback/xenbus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index aff963f..e8dfc3d 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -687,11 +687,12 @@ static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
 {
 	int err = 0;
 	char *node;
-	unsigned maxlen = strlen(dev->nodename) + sizeof("/rate");
+	unsigned maxlen;
 
 	if (vif->credit_watch.node)
 		return -EADDRINUSE;
 
+	maxlen = strlen(dev->nodename) + sizeof("/rate");
 	node = kmalloc(maxlen, GFP_KERNEL);
 	if (!node)
 		return -ENOMEM;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] xen-netback: Delete an unnecessary variable initialisation in xen_register_watchers()
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-01-02 17:58   ` [PATCH 4/5] xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers() SF Markus Elfring
@ 2016-01-02 18:00   ` SF Markus Elfring
  2016-01-03  1:34   ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations Joe Perches
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 18:00 UTC (permalink / raw)
  To: xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 18:28:26 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/xen-netback/xenbus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index e8dfc3d..55f0735 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -685,7 +685,7 @@ static void xen_net_rate_changed(struct xenbus_watch *watch,
 
 static int xen_register_watchers(struct xenbus_device *dev, struct xenvif *vif)
 {
-	int err = 0;
+	int err;
 	char *node;
 	unsigned maxlen;
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init()
  2016-01-01 20:32   ` [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init() SF Markus Elfring
@ 2016-01-02 18:18     ` Souptick Joarder
  0 siblings, 0 replies; 1373+ messages in thread
From: Souptick Joarder @ 2016-01-02 18:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, Stanislaw Gruszka, LKML,
	kernel-janitors, Julia Lawall

On Sat, Jan 2, 2016 at 2:02 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 21:16:01 +0100
>
> Rename a jump label according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wireless/intel/iwlegacy/common.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c
> index ae45fd3..660ab2b 100644
> --- a/drivers/net/wireless/intel/iwlegacy/common.c
> +++ b/drivers/net/wireless/intel/iwlegacy/common.c
> @@ -759,7 +759,7 @@ il_eeprom_init(struct il_priv *il)
>                                  IL_EEPROM_ACCESS_TIMEOUT);
>                 if (ret < 0) {
>                         IL_ERR("Time out reading EEPROM[%d]\n", addr);
> -                       goto done;
> +                       goto release_semaphore;

Current code looks good.
>                 }
>                 r = _il_rd(il, CSR_EEPROM_REG);
>                 e[addr / 2] = cpu_to_le16(r >> 16);
> @@ -769,7 +769,7 @@ il_eeprom_init(struct il_priv *il)
>                  il_eeprom_query16(il, EEPROM_VERSION));
>
>         ret = 0;
> -done:
> +release_semaphore:
>         il->ops->eeprom_release_semaphore(il);
>
>         if (ret) {
> --
> 2.6.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-Souptick

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-02 16:32     ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations " kbuild test robot
@ 2016-01-02 18:27       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 18:27 UTC (permalink / raw)
  To: linux-wireless, netdev, Kalle Valo
  Cc: kbuild-all, LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 19:22:36 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index 702593f..571eaba 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection
  2015-12-26 13:04 ` [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection SF Markus Elfring
@ 2016-01-02 18:28   ` Jonathan Cameron
  0 siblings, 0 replies; 1373+ messages in thread
From: Jonathan Cameron @ 2016-01-02 18:28 UTC (permalink / raw)
  To: SF Markus Elfring, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald
  Cc: LKML, kernel-janitors, Julia Lawall

On 26/12/15 13:04, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 26 Dec 2015 13:53:15 +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" does not need to be checked once more
> after it was determined that a function call failed.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
If we are going to change this, I would prefer to see more useful
local error messages and direct returns rather than jumping to
a very generic message at the end.

I'm also less than keen on jumping into conditionals as I find
it slightly less readable. 

We might technically be 'simplifying' the code, but in this case
the gain is very minor for a fair bit of code churn...

Thanks,

Jonathan
> ---
>  drivers/iio/adc/qcom-spmi-vadc.c | 17 +++++++++--------
>  1 file changed, 9 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
> index c2babe5..391eefa 100644
> --- a/drivers/iio/adc/qcom-spmi-vadc.c
> +++ b/drivers/iio/adc/qcom-spmi-vadc.c
> @@ -424,7 +424,7 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
>  	prop = vadc_get_channel(vadc, VADC_REF_1250MV);
>  	ret = vadc_do_conversion(vadc, prop, &read_1);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
In this first case we have already had a report that a conversion failed.
I suppose adding that it was during reference point measurement 'might'
be useful additional information.  I'm not really convinced of it does
however... Hence I'd drop reporting it entirely in this function.
>  
>  	/* Try with buffered 625mV channel first */
>  	prop = vadc_get_channel(vadc, VADC_SPARE1);
> @@ -433,11 +433,11 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
>  
>  	ret = vadc_do_conversion(vadc, prop, &read_2);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  
>  	if (read_1 == read_2) {
>  		ret = -EINVAL;
I think this one indicates we can't actually read anything at all
for some reason...  It's the only form of error we won't have effectively
already reported so is worthy of some sort of debug message...
> -		goto err;
> +		goto report_failure;
>  	}
>  
>  	vadc->graph[VADC_CALIB_ABSOLUTE].dy = read_1 - read_2;
> @@ -447,23 +447,24 @@ static int vadc_measure_ref_points(struct vadc_priv *vadc)
>  	prop = vadc_get_channel(vadc, VADC_VDD_VADC);
>  	ret = vadc_do_conversion(vadc, prop, &read_1);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  
>  	prop = vadc_get_channel(vadc, VADC_GND_REF);
>  	ret = vadc_do_conversion(vadc, prop, &read_2);
>  	if (ret)
> -		goto err;
> +		goto report_failure;
>  
>  	if (read_1 == read_2) {
>  		ret = -EINVAL;
> -		goto err;
> +		goto report_failure;
>  	}
>  
>  	vadc->graph[VADC_CALIB_RATIOMETRIC].dy = read_1 - read_2;
>  	vadc->graph[VADC_CALIB_RATIOMETRIC].gnd = read_2;
> -err:
> -	if (ret)
> +	if (ret) {
> +report_failure:
>  		dev_err(vadc->dev, "measure reference points failed\n");
> +	}
>  
>  	return ret;
>  }
> 


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] NFC-mei_phy: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (44 preceding siblings ...)
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
@ 2016-01-02 20:51 ` SF Markus Elfring
  2016-01-02 20:54   ` [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect() SF Markus Elfring
                     ` (2 more replies)
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                   ` (49 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 20:51 UTC (permalink / raw)
  To: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio, Samuel Ortiz
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 21:47:30 +0100

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

Markus Elfring (3):
  Refactoring for mei_nfc_connect()
  Refactoring for mei_nfc_if_version()
  Delete an unnecessary variable initialisation in mei_nfc_if_version()

 drivers/nfc/mei_phy.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
  2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
@ 2016-01-02 20:54   ` SF Markus Elfring
  2016-01-02 23:41     ` Julian Calaby
  2016-01-02 20:55   ` [PATCH 2/3] NFC-mei_phy: Refactoring for mei_nfc_if_version() SF Markus Elfring
  2016-01-02 20:56   ` [PATCH 3/3] NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version() SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 20:54 UTC (permalink / raw)
  To: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio, Samuel Ortiz
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/nfc/mei_phy.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
index 83deda4..8e3a69f 100644
--- a/drivers/nfc/mei_phy.c
+++ b/drivers/nfc/mei_phy.c
@@ -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);
@@ -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);
-
 	return r;
 }
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] NFC-mei_phy: Refactoring for mei_nfc_if_version()
  2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
  2016-01-02 20:54   ` [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect() SF Markus Elfring
@ 2016-01-02 20:55   ` SF Markus Elfring
  2016-01-02 20:56   ` [PATCH 3/3] NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version() SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 20:55 UTC (permalink / raw)
  To: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio, Samuel Ortiz
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 2 Jan 2016 21:33:04 +0100

Rename a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/nfc/mei_phy.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
index 8e3a69f..3c74028 100644
--- a/drivers/nfc/mei_phy.c
+++ b/drivers/nfc/mei_phy.c
@@ -136,7 +136,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy)
 	if (bytes_recv < 0 || bytes_recv < sizeof(struct mei_nfc_reply)) {
 		pr_err("Could not read IF version\n");
 		r = -EIO;
-		goto err;
+		goto free_reply;
 	}
 
 	version = (struct mei_nfc_if_version *)reply->data;
@@ -144,8 +144,7 @@ static int mei_nfc_if_version(struct nfc_mei_phy *phy)
 	phy->fw_ivn = version->fw_ivn;
 	phy->vendor_id = version->vendor_id;
 	phy->radio_type = version->radio_type;
-
-err:
+free_reply:
 	kfree(reply);
 	return r;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version()
  2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
  2016-01-02 20:54   ` [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect() SF Markus Elfring
  2016-01-02 20:55   ` [PATCH 2/3] NFC-mei_phy: Refactoring for mei_nfc_if_version() SF Markus Elfring
@ 2016-01-02 20:56   ` SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-02 20:56 UTC (permalink / raw)
  To: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio, Samuel Ortiz
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/nfc/mei_phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
index 3c74028..99fd87d 100644
--- a/drivers/nfc/mei_phy.c
+++ b/drivers/nfc/mei_phy.c
@@ -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;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
  2016-01-01 16:56   ` [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver() SF Markus Elfring
@ 2016-01-02 21:30     ` Bjørn Mork
  2016-01-03  1:45       ` David Miller
  0 siblings, 1 reply; 1373+ messages in thread
From: Bjørn Mork @ 2016-01-02 21:30 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-usb, netdev, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind()
  2016-01-01 16:54   ` [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind() SF Markus Elfring
@ 2016-01-02 21:38     ` Bjørn Mork
  0 siblings, 0 replies; 1373+ messages in thread
From: Bjørn Mork @ 2016-01-02 21:38 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-usb, netdev, LKML, kernel-janitors, Julia Lawall

SF Markus Elfring <elfring@users.sourceforge.net> writes:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
  2016-01-02 20:54   ` [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect() SF Markus Elfring
@ 2016-01-02 23:41     ` Julian Calaby
  2016-01-03  7:00       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-01-02 23:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio,
	Samuel Ortiz, LKML, kernel-janitors, Julia Lawall

Hi Markus,

On Sun, Jan 3, 2016 at 7:54 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/nfc/mei_phy.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/nfc/mei_phy.c b/drivers/nfc/mei_phy.c
> index 83deda4..8e3a69f 100644
> --- a/drivers/nfc/mei_phy.c
> +++ b/drivers/nfc/mei_phy.c
> @@ -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);
> @@ -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,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-01-02 18:00   ` [PATCH 5/5] xen-netback: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2016-01-03  1:34   ` Joe Perches
  2016-01-04  9:40   ` Dan Carpenter
  2016-01-04 11:08   ` Wei Liu
  7 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-01-03  1:34 UTC (permalink / raw)
  To: SF Markus Elfring, xen-devel, netdev, Ian Campbell, Wei Liu
  Cc: LKML, kernel-janitors, Julia Lawall

On Sat, 2016-01-02 at 18:50 +0100, SF Markus Elfring wrote:
> 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...


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver()
  2016-01-02 21:30     ` Bjørn Mork
@ 2016-01-03  1:45       ` David Miller
  0 siblings, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-01-03  1:45 UTC (permalink / raw)
  To: bjorn
  Cc: elfring, linux-usb, netdev, linux-kernel, kernel-janitors, julia.lawall

From: Bjørn Mork <bjorn@mork.no>
Date: Sat, 02 Jan 2016 22:30:48 +0100

> SF Markus Elfring <elfring@users.sourceforge.net> writes:
> 
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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.

+1

I'm getting really tired of these changes.  And a lot of them are
coming in right now...

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
  2016-01-02 23:41     ` Julian Calaby
@ 2016-01-03  7:00       ` SF Markus Elfring
  2016-01-03  7:29         ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  7:00 UTC (permalink / raw)
  To: Julian Calaby
  Cc: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio,
	Samuel Ortiz, LKML, kernel-janitors, Julia Lawall

>>         r = 0;
>> -
>> -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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect()
  2016-01-03  7:00       ` SF Markus Elfring
@ 2016-01-03  7:29         ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-01-03  7:29 UTC (permalink / raw)
  To: SF Markus Elfring, Julian Calaby
  Cc: linux-wireless, Aloisio Almeida Jr, Lauro Ramos Venancio,
	Samuel Ortiz, LKML, kernel-janitors, Julia Lawall

On Sun, 2016-01-03 at 08:00 +0100, SF Markus Elfring wrote:
> > >         r = 0;
> > > -
> > > -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?

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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (45 preceding siblings ...)
  2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
@ 2016-01-03  8:43 ` SF Markus Elfring
  2016-01-03  8:50   ` [PATCH 1/8] rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe() SF Markus Elfring
                     ` (7 more replies)
  2016-01-03 10:00 ` [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online() SF Markus Elfring
                   ` (48 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:43 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/8] rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-01-03  8:50   ` SF Markus Elfring
  2016-01-03  8:51   ` [PATCH 2/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm() SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:50 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 32 ++++++++++++++------------------
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index a319bf1..1291206 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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;
 }
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
  2016-01-03  8:50   ` [PATCH 1/8] rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe() SF Markus Elfring
@ 2016-01-03  8:51   ` SF Markus Elfring
  2016-01-03  8:52   ` [PATCH 3/8] rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer() SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:51 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index 1291206..ed9b873 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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;
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/8] rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
  2016-01-03  8:50   ` [PATCH 1/8] rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe() SF Markus Elfring
  2016-01-03  8:51   ` [PATCH 2/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm() SF Markus Elfring
@ 2016-01-03  8:52   ` SF Markus Elfring
  2016-01-03  8:53   ` [PATCH 4/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm() SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:52 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index ed9b873..33a7cf1 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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]);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-01-03  8:52   ` [PATCH 3/8] rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer() SF Markus Elfring
@ 2016-01-03  8:53   ` SF Markus Elfring
  2016-01-03  8:54   ` [PATCH 5/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm() SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:53 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 3 Jan 2016 07:51:49 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index 33a7cf1..0986715 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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;
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-01-03  8:53   ` [PATCH 4/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm() SF Markus Elfring
@ 2016-01-03  8:54   ` SF Markus Elfring
  2016-01-03  8:55   ` [PATCH 6/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer() SF Markus Elfring
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:54 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 3 Jan 2016 08:00:29 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index 0986715..02e3443 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-01-03  8:54   ` [PATCH 5/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm() SF Markus Elfring
@ 2016-01-03  8:55   ` SF Markus Elfring
  2016-01-03  8:56   ` [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt() SF Markus Elfring
  2016-01-03  8:57   ` [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer() SF Markus Elfring
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:55 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index 02e3443..e3a015a 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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) {
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-01-03  8:55   ` [PATCH 6/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer() SF Markus Elfring
@ 2016-01-03  8:56   ` SF Markus Elfring
  2016-01-03 12:48     ` Julia Lawall
  2016-01-03 12:48     ` Julia Lawall
  2016-01-03  8:57   ` [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer() SF Markus Elfring
  7 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:56 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index e3a015a..88f1d0b 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-01-03  8:56   ` [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt() SF Markus Elfring
@ 2016-01-03  8:57   ` SF Markus Elfring
  2016-01-03 12:47     ` Julia Lawall
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03  8:57 UTC (permalink / raw)
  To: rtc-linux, Alessandro Zummo, Alexandre Belloni
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
index 88f1d0b..fed52d0 100644
--- a/drivers/rtc/rtc-ab-b5ze-s3.c
+++ b/drivers/rtc/rtc-ab-b5ze-s3.c
@@ -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__);
 
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02 11:21             ` SF Markus Elfring
@ 2016-01-03  9:36               ` Arend van Spriel
  2016-01-03 12:13                 ` SF Markus Elfring
  2016-01-03 15:18                 ` Rafał Miłecki
  0 siblings, 2 replies; 1373+ messages in thread
From: Arend van Spriel @ 2016-01-03  9:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, Sergei Shtylyov, libertas-dev, linux-wireless,
	netdev, Kalle Valo, LKML, kernel-janitors



On 02-01-16 12:21, SF Markus Elfring wrote:
>> 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
> 
> 
>> 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".

>> 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.)
> 
> When will the run-time behaviour matter also for exceptional situations?
> 
> 
>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (46 preceding siblings ...)
  2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-01-03 10:00 ` SF Markus Elfring
  2016-01-03 10:02   ` [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online() SF Markus Elfring
  2016-01-03 10:02   ` [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online() SF Markus Elfring
  2016-01-03 16:32 ` [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init() SF Markus Elfring
                   ` (47 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 10:00 UTC (permalink / raw)
  To: linux-s390, Heiko Carstens, Martin Schwidefsky, Ursula Braun
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.6.3


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-03 10:00 ` [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online() SF Markus Elfring
@ 2016-01-03 10:02   ` SF Markus Elfring
  2016-01-04 11:29     ` Heiko Carstens
  2016-01-07 14:33     ` Ursula Braun
  2016-01-03 10:02   ` [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online() SF Markus Elfring
  1 sibling, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 10:02 UTC (permalink / raw)
  To: linux-s390, Heiko Carstens, Martin Schwidefsky, Ursula Braun
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/net/qeth_core_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 7871537..54fde2e 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -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) {
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-03 10:00 ` [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online() SF Markus Elfring
  2016-01-03 10:02   ` [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online() SF Markus Elfring
@ 2016-01-03 10:02   ` SF Markus Elfring
  2016-01-04 11:30     ` Heiko Carstens
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 10:02 UTC (permalink / raw)
  To: linux-s390, Heiko Carstens, Martin Schwidefsky, Ursula Braun
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/net/qeth_core_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 54fde2e..3261977 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -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
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-03  9:36               ` Arend van Spriel
@ 2016-01-03 12:13                 ` SF Markus Elfring
  2016-01-03 15:18                 ` Rafał Miłecki
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 12:13 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: Julia Lawall, Sergei Shtylyov, libertas-dev, linux-wireless,
	netdev, Kalle Valo, LKML, kernel-janitors

>>> 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?


> What you change does is confuse people reading the code.

A few software developers might find this proposal unusual.


> 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?


> The code is not making the driver more robust against failures

That's true for this update suggestion.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
  2016-01-03  8:57   ` [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer() SF Markus Elfring
@ 2016-01-03 12:47     ` Julia Lawall
  2016-01-03 17:25       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 12:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML,
	kernel-janitors, Julia Lawall

On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-ab-b5ze-s3.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
> index 88f1d0b..fed52d0 100644
> --- a/drivers/rtc/rtc-ab-b5ze-s3.c
> +++ b/drivers/rtc/rtc-ab-b5ze-s3.c
> @@ -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);

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

>  	if (ret)
>  		dev_err(dev, "%s: failed to update timer\n", __func__);
>  
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03  8:56   ` [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt() SF Markus Elfring
@ 2016-01-03 12:48     ` Julia Lawall
  2016-01-03 16:54       ` SF Markus Elfring
  2016-01-03 12:48     ` Julia Lawall
  1 sibling, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 12:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML,
	kernel-janitors, Julia Lawall

On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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
 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
> index e3a015a..88f1d0b 100644
> --- a/drivers/rtc/rtc-ab-b5ze-s3.c
> +++ b/drivers/rtc/rtc-ab-b5ze-s3.c
> @@ -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
> -- 
> 2.6.3
> 
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03  8:56   ` [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt() SF Markus Elfring
  2016-01-03 12:48     ` Julia Lawall
@ 2016-01-03 12:48     ` Julia Lawall
  2016-01-03 17:00       ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 12:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML,
	kernel-janitors, Julia Lawall

On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/rtc/rtc-ab-b5ze-s3.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-ab-b5ze-s3.c b/drivers/rtc/rtc-ab-b5ze-s3.c
> index e3a015a..88f1d0b 100644
> --- a/drivers/rtc/rtc-ab-b5ze-s3.c
> +++ b/drivers/rtc/rtc-ab-b5ze-s3.c
> @@ -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
> -- 
> 2.6.3
> 
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-03  9:36               ` Arend van Spriel
  2016-01-03 12:13                 ` SF Markus Elfring
@ 2016-01-03 15:18                 ` Rafał Miłecki
  2016-01-04 10:05                   ` Arend van Spriel
  1 sibling, 1 reply; 1373+ messages in thread
From: Rafał Miłecki @ 2016-01-03 15:18 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: SF Markus Elfring, Julia Lawall, Sergei Shtylyov, libertas-dev,
	linux-wireless, Network Development, Kalle Valo, LKML,
	kernel-janitors

On 3 January 2016 at 10:36, Arend van Spriel <aspriel@gmail.com> wrote:
> On 02-01-16 12:21, SF Markus Elfring wrote:
>>> 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.

-- 
Rafał

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (47 preceding siblings ...)
  2016-01-03 10:00 ` [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online() SF Markus Elfring
@ 2016-01-03 16:32 ` SF Markus Elfring
  2016-01-03 16:41   ` Julia Lawall
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
                   ` (46 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 16:32 UTC (permalink / raw)
  To: devel, Christopher Harrer, Greg Kroah-Hartman, Lior Dotan
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 3 Jan 2016 17:25:59 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/slicoss/slicoss.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index b23a2d1..8fdcac8 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -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);
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 16:32 ` [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init() SF Markus Elfring
@ 2016-01-03 16:41   ` Julia Lawall
  2016-01-03 17:48     ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 16:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Christopher Harrer, Greg Kroah-Hartman, Lior Dotan, LKML,
	kernel-janitors, Julia Lawall

On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 3 Jan 2016 17:25:59 +0100
> 
> Replace explicit initialisation for two local variables at the beginning
> by assignments.

Why?

julia

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/staging/slicoss/slicoss.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
> index b23a2d1..8fdcac8 100644
> --- a/drivers/staging/slicoss/slicoss.c
> +++ b/drivers/staging/slicoss/slicoss.c
> @@ -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);
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03 12:48     ` Julia Lawall
@ 2016-01-03 16:54       ` SF Markus Elfring
  2016-01-03 16:59         ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 16:54 UTC (permalink / raw)
  To: Julia Lawall
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML, kernel-janitors

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03 16:54       ` SF Markus Elfring
@ 2016-01-03 16:59         ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 16:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML, kernel-janitors



On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> >> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt()
  2016-01-03 12:48     ` Julia Lawall
@ 2016-01-03 17:00       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 17:00 UTC (permalink / raw)
  To: Julia Lawall
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML, kernel-janitors

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
  2016-01-03 12:47     ` Julia Lawall
@ 2016-01-03 17:25       ` SF Markus Elfring
  2016-01-03 17:29         ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 17:25 UTC (permalink / raw)
  To: Julia Lawall
  Cc: rtc-linux, Alessandro Zummo, Alexandre Belloni, LKML, kernel-janitors

>>  	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 …


> The concept (mask) has disappeared,

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


> the binary operation is strangely broken,

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


> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer()
  2016-01-03 17:25       ` SF Markus Elfring
@ 2016-01-03 17:29         ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-01-03 17:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, rtc-linux, Alessandro Zummo, Alexandre Belloni,
	LKML, kernel-janitors

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1155 bytes --]

On Sun, 3 Jan 2016, SF Markus Elfring wrote:

> >>  	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 …
> 
> 
> > The concept (mask) has disappeared,
> 
> I suggest to drop another local variable.
> Can the operator "Bitwise OR" be sufficient to indicate the concept "mask"?
> 
> 
> > the binary operation is strangely broken,
> 
> Do you prefer an other source code formatting within the usual line length range?
> 
> 
> > 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?
> 
> 
> > 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 16:41   ` Julia Lawall
@ 2016-01-03 17:48     ` SF Markus Elfring
  2016-01-03 17:58       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 17:48 UTC (permalink / raw)
  To: Julia Lawall
  Cc: devel, Christopher Harrer, Greg Kroah-Hartman, Lior Dotan, LKML,
	kernel-janitors

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 17:48     ` SF Markus Elfring
@ 2016-01-03 17:58       ` Greg Kroah-Hartman
  2016-01-03 18:16         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Greg Kroah-Hartman @ 2016-01-03 17:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

On Sun, Jan 03, 2016 at 06:48:17PM +0100, SF Markus Elfring wrote:
> >> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 17:58       ` Greg Kroah-Hartman
@ 2016-01-03 18:16         ` SF Markus Elfring
  2016-01-03 18:26           ` Greg Kroah-Hartman
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 18:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 18:16         ` SF Markus Elfring
@ 2016-01-03 18:26           ` Greg Kroah-Hartman
  2016-01-03 18:50             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Greg Kroah-Hartman @ 2016-01-03 18:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

On Sun, Jan 03, 2016 at 07:16:49PM +0100, SF Markus Elfring wrote:
> >> 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.

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.

> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 18:26           ` Greg Kroah-Hartman
@ 2016-01-03 18:50             ` SF Markus Elfring
  2016-01-03 19:45               ` Greg Kroah-Hartman
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 18:50 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

>> 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?


> 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.


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

That is mostly usual.


> 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.


>> 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.


> Did you speed up the code in a measurable way?

My suggestions can result in measurable differences.


> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 18:50             ` SF Markus Elfring
@ 2016-01-03 19:45               ` Greg Kroah-Hartman
  2016-01-03 20:10                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Greg Kroah-Hartman @ 2016-01-03 19:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

On Sun, Jan 03, 2016 at 07:50:18PM +0100, SF Markus Elfring wrote:
> >> 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.

> > 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.

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

No.

> > 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 19:45               ` Greg Kroah-Hartman
@ 2016-01-03 20:10                 ` SF Markus Elfring
  2016-01-03 20:15                   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 20:10 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

>> 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?


>> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 20:10                 ` SF Markus Elfring
@ 2016-01-03 20:15                   ` Greg Kroah-Hartman
  2016-01-03 20:21                     ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Greg Kroah-Hartman @ 2016-01-03 20:15 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

On Sun, Jan 03, 2016 at 09:10:45PM +0100, SF Markus Elfring wrote:
> >> 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*

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging-slicoss: Replace variable initialisations by assignments in slic_if_init()
  2016-01-03 20:15                   ` Greg Kroah-Hartman
@ 2016-01-03 20:21                     ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-03 20:21 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Julia Lawall, devel, kernel-janitors, LKML, Lior Dotan,
	Christopher Harrer

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()
  2015-12-27 17:33 ` [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8() SF Markus Elfring
@ 2016-01-04  8:39   ` Matthias Schwarzott
  0 siblings, 0 replies; 1373+ messages in thread
From: Matthias Schwarzott @ 2016-01-04  8:39 UTC (permalink / raw)
  To: SF Markus Elfring, linux-media, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

Am 27.12.2015 um 18:33 schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

The patch looks fine.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>

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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
  2016-01-02 15:12     ` net-rsi: Reconsider usage of variable "vap_id" " SF Markus Elfring
  2016-01-02 16:32     ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations " kbuild test robot
@ 2016-01-04  9:28     ` Dan Carpenter
  2016-01-04  9:38       ` Dan Carpenter
                         ` (3 more replies)
  2 siblings, 4 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-04  9:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

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


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] net-iwlegacy: Refactoring for il_eeprom_init()
  2016-01-01 20:30   ` [PATCH 1/3] net-iwlegacy: Refactoring " SF Markus Elfring
@ 2016-01-04  9:33     ` Stanislaw Gruszka
  0 siblings, 0 replies; 1373+ messages in thread
From: Stanislaw Gruszka @ 2016-01-04  9:33 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

On Fri, Jan 01, 2016 at 09:30:10PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 20:54:25 +0100
> 
> Return directly if a memory allocation failed at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Stanislaw Gruszka <sgruszka@redhat.com>


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
@ 2016-01-04  9:38       ` Dan Carpenter
  2016-01-04 10:44       ` SF Markus Elfring
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-04  9:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

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


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-01-03  1:34   ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations Joe Perches
@ 2016-01-04  9:40   ` Dan Carpenter
  2016-01-04 11:08   ` Wei Liu
  7 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-04  9:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: xen-devel, netdev, Ian Campbell, Wei Liu, LKML, kernel-janitors,
	Julia Lawall

The original code is fine.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-03 15:18                 ` Rafał Miłecki
@ 2016-01-04 10:05                   ` Arend van Spriel
  2016-01-04 11:18                     ` Rafał Miłecki
  0 siblings, 1 reply; 1373+ messages in thread
From: Arend van Spriel @ 2016-01-04 10:05 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: SF Markus Elfring, Julia Lawall, Sergei Shtylyov, libertas-dev,
	linux-wireless, Network Development, Kalle Valo, LKML,
	kernel-janitors



On 03-01-16 16:18, Rafał Miłecki wrote:
> On 3 January 2016 at 10:36, Arend van Spriel <aspriel@gmail.com> wrote:
>> On 02-01-16 12:21, SF Markus Elfring wrote:
>>>> 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.

> I'm against this patch as well.

and counting... :-p

Regards,
Arend

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
  2016-01-04  9:38       ` Dan Carpenter
@ 2016-01-04 10:44       ` SF Markus Elfring
  2016-01-04 11:48         ` Dan Carpenter
  2016-01-04 13:17       ` [PATCH 1/3] " Bjørn Mork
  2016-01-04 17:14       ` David Miller
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-04 10:44 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

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

Thanks for your general interest.


> 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.


> 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.


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

I find this view interesting.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/5] xen-netback: Fine-tuning for three function implementations
  2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-01-04  9:40   ` Dan Carpenter
@ 2016-01-04 11:08   ` Wei Liu
  7 siblings, 0 replies; 1373+ messages in thread
From: Wei Liu @ 2016-01-04 11:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: xen-devel, netdev, Ian Campbell, Wei Liu, LKML, kernel-janitors,
	Julia Lawall

I think the original code is fine.

Wei.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-04 10:05                   ` Arend van Spriel
@ 2016-01-04 11:18                     ` Rafał Miłecki
  0 siblings, 0 replies; 1373+ messages in thread
From: Rafał Miłecki @ 2016-01-04 11:18 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: SF Markus Elfring, Julia Lawall, Sergei Shtylyov, libertas-dev,
	linux-wireless, Network Development, Kalle Valo, LKML,
	kernel-janitors

On 4 January 2016 at 11:05, Arend van Spriel <aspriel@gmail.com> wrote:
> On 03-01-16 16:18, Rafał Miłecki wrote:
>> On 3 January 2016 at 10:36, Arend van Spriel <aspriel@gmail.com> wrote:
>>> On 02-01-16 12:21, SF Markus Elfring wrote:
>>>>> 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.

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

-- 
Rafał

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-03 10:02   ` [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online() SF Markus Elfring
@ 2016-01-04 11:29     ` Heiko Carstens
  2016-01-07 14:33     ` Ursula Braun
  1 sibling, 0 replies; 1373+ messages in thread
From: Heiko Carstens @ 2016-01-04 11:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

On Sun, Jan 03, 2016 at 11:02:00AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/qeth_core_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
> index 7871537..54fde2e 100644
> --- a/drivers/s390/net/qeth_core_main.c
> +++ b/drivers/s390/net/qeth_core_main.c
> @@ -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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-03 10:02   ` [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online() SF Markus Elfring
@ 2016-01-04 11:30     ` Heiko Carstens
  2016-01-04 13:10       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Heiko Carstens @ 2016-01-04 11:30 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

On Sun, Jan 03, 2016 at 11:02:56AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/qeth_core_main.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
> index 54fde2e..3261977 100644
> --- a/drivers/s390/net/qeth_core_main.c
> +++ b/drivers/s390/net/qeth_core_main.c
> @@ -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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04 10:44       ` SF Markus Elfring
@ 2016-01-04 11:48         ` Dan Carpenter
  2016-01-04 12:33           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-04 11:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

On Mon, Jan 04, 2016 at 11:44:15AM +0100, SF Markus Elfring wrote:
> > 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04 11:48         ` Dan Carpenter
@ 2016-01-04 12:33           ` SF Markus Elfring
  2016-01-04 23:54             ` Julian Calaby
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-04 12:33 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: linux-wireless, netdev, Kalle Valo, LKML, kernel-janitors, Julia Lawall

>> 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?


> but you are sending hundreds of "controversial" cleanups.

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


> 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.


> and they go against the author's original intention.

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


> I tend to agree that useless initializers are bad

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


> and disable GCCs uninitialized variable warnings

I hope that this software area can be also improved.


> 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"?


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

I just dare to propose further special changes.

Regards,
Markus


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-04 11:30     ` Heiko Carstens
@ 2016-01-04 13:10       ` SF Markus Elfring
  2016-01-04 14:04         ` Heiko Carstens
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-04 13:10 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

>> +++ b/drivers/s390/net/qeth_core_main.c
>> @@ -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.

Thanks for your feedback.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
  2016-01-04  9:38       ` Dan Carpenter
  2016-01-04 10:44       ` SF Markus Elfring
@ 2016-01-04 13:17       ` Bjørn Mork
  2016-01-04 14:25         ` Dan Carpenter
  2016-01-04 17:14       ` David Miller
  3 siblings, 1 reply; 1373+ messages in thread
From: Bjørn Mork @ 2016-01-04 13:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

Dan Carpenter <dan.carpenter@oracle.com> writes:

> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-04 13:10       ` SF Markus Elfring
@ 2016-01-04 14:04         ` Heiko Carstens
  2016-01-04 14:10           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Heiko Carstens @ 2016-01-04 14:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

On Mon, Jan 04, 2016 at 02:10:34PM +0100, SF Markus Elfring wrote:
> >> +++ b/drivers/s390/net/qeth_core_main.c
> >> @@ -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.
> 
> Thanks for your feedback.
> 
> 
> > 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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-04 14:04         ` Heiko Carstens
@ 2016-01-04 14:10           ` SF Markus Elfring
  2016-01-05  7:54             ` Heiko Carstens
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-04 14:10 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04 13:17       ` [PATCH 1/3] " Bjørn Mork
@ 2016-01-04 14:25         ` Dan Carpenter
  0 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-04 14:25 UTC (permalink / raw)
  To: Bjørn Mork
  Cc: SF Markus Elfring, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

On Mon, Jan 04, 2016 at 02:17:40PM +0100, Bjørn Mork wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
> 
> > 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...

> 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


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04  9:28     ` [PATCH " Dan Carpenter
                         ` (2 preceding siblings ...)
  2016-01-04 13:17       ` [PATCH 1/3] " Bjørn Mork
@ 2016-01-04 17:14       ` David Miller
  3 siblings, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-01-04 17:14 UTC (permalink / raw)
  To: dan.carpenter
  Cc: elfring, linux-wireless, netdev, kvalo, linux-kernel,
	kernel-janitors, julia.lawall

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Mon, 4 Jan 2016 12:28:57 +0300

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

+1

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04 12:33           ` SF Markus Elfring
@ 2016-01-04 23:54             ` Julian Calaby
  2016-01-05  8:29               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-01-04 23:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

On Mon, Jan 4, 2016 at 11:33 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> 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,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations
  2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2015-12-31 20:27   ` [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block() SF Markus Elfring
@ 2016-01-05  0:13   ` Brian Norris
  3 siblings, 0 replies; 1373+ messages in thread
From: Brian Norris @ 2016-01-05  0:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mtd, David Woodhouse, LKML, kernel-janitors, Julia Lawall

On Thu, Dec 31, 2015 at 09:21:14PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: 390/qeth: Refactoring for qeth_core_set_online()
  2016-01-04 14:10           ` SF Markus Elfring
@ 2016-01-05  7:54             ` Heiko Carstens
  0 siblings, 0 replies; 1373+ messages in thread
From: Heiko Carstens @ 2016-01-05  7:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Martin Schwidefsky, Ursula Braun, LKML,
	kernel-janitors, Julia Lawall

On Mon, Jan 04, 2016 at 03:10:41PM +0100, SF Markus Elfring wrote:
> > 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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-04 23:54             ` Julian Calaby
@ 2016-01-05  8:29               ` SF Markus Elfring
  2016-01-05  9:47                 ` Julian Calaby
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-05  8:29 UTC (permalink / raw)
  To: Julian Calaby
  Cc: Dan Carpenter, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

> 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?


> "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


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-05  8:29               ` SF Markus Elfring
@ 2016-01-05  9:47                 ` Julian Calaby
  2016-01-05 16:23                   ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-01-05  9:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Dan Carpenter, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

On Tue, Jan 5, 2016 at 7:29 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> 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.)

>> "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.

>> 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.

> 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,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-05  9:47                 ` Julian Calaby
@ 2016-01-05 16:23                   ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-05 16:23 UTC (permalink / raw)
  To: Julian Calaby
  Cc: Dan Carpenter, linux-wireless, netdev, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

> Every time you send a set of patches,

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


> there are legitimate issues which people raise,

There was usual feedback.


> and every time they are discussed,

The discussion results were mixed between acceptance
and usual disagreement.


> you assert that your patches improve things

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


> 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?


> 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.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2015-12-27 15:26   ` Sagi Grimberg
@ 2016-01-06 18:47   ` Nicholas A. Bellinger
  5 siblings, 0 replies; 1373+ messages in thread
From: Nicholas A. Bellinger @ 2016-01-06 18:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, target-devel, Doug Ledford, Hal Rosenstock,
	Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

On Sun, 2015-12-27 at 13:36 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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).
> 
> 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..?


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
  2015-12-31 21:47 ` [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection SF Markus Elfring
@ 2016-01-07 11:07   ` Robert Richter
  2016-01-07 19:30     ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Robert Richter @ 2016-01-07 11:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, linux-arm-kernel, Sunil Goutham, LKML, kernel-janitors,
	Julia Lawall

On 31.12.15 22:47:31, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/cavium/thunder/nicvf_main.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
> index c24cb2a..21e1579 100644
> --- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
> +++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
> @@ -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;
>  }

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-03 10:02   ` [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online() SF Markus Elfring
  2016-01-04 11:29     ` Heiko Carstens
@ 2016-01-07 14:33     ` Ursula Braun
  2016-01-08  7:18       ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Ursula Braun @ 2016-01-07 14:33 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Heiko Carstens, Martin Schwidefsky, LKML,
	kernel-janitors, Julia Lawall

On Sun, 2016-01-03 at 11:02 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/s390/net/qeth_core_main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
> index 7871537..54fde2e 100644
> --- a/drivers/s390/net/qeth_core_main.c
> +++ b/drivers/s390/net/qeth_core_main.c
> @@ -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.


^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 11:07   ` Robert Richter
@ 2016-01-07 19:30     ` SF Markus Elfring
  2016-01-07 19:44       ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-07 19:30 UTC (permalink / raw)
  To: Robert Richter
  Cc: netdev, linux-arm-kernel, Sunil Goutham, LKML, kernel-janitors,
	Julia Lawall

>> 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.


> 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"?


> 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=40fb5f8a60f33133d36afde35a9ad865d35e4423#n940


> 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?


>> @@ -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;
>>  }

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 19:30     ` SF Markus Elfring
@ 2016-01-07 19:44       ` Joe Perches
  2016-01-07 19:56         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-01-07 19:44 UTC (permalink / raw)
  To: SF Markus Elfring, Robert Richter
  Cc: netdev, linux-arm-kernel, Sunil Goutham, LKML, kernel-janitors,
	Julia Lawall

On Thu, 2016-01-07 at 20:30 +0100, SF Markus Elfring wrote:
> > > 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.
> > 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.

> > 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 19:44       ` Joe Perches
@ 2016-01-07 19:56         ` SF Markus Elfring
  2016-01-07 19:59           ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-07 19:56 UTC (permalink / raw)
  To: Joe Perches
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 19:56         ` SF Markus Elfring
@ 2016-01-07 19:59           ` Joe Perches
  2016-01-07 20:07             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-01-07 19:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-01-07 at 20:56 +0100, SF Markus Elfring wrote:
> > > 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.

> * 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 19:59           ` Joe Perches
@ 2016-01-07 20:07             ` SF Markus Elfring
  2016-01-07 20:28               ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-07 20:07 UTC (permalink / raw)
  To: Joe Perches
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

>> * 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?


> when with compiled with optimizations.

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 20:07             ` SF Markus Elfring
@ 2016-01-07 20:28               ` Joe Perches
  2016-01-07 20:38                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-01-07 20:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-01-07 at 21:07 +0100, SF Markus Elfring wrote:
> > > * 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 20:28               ` Joe Perches
@ 2016-01-07 20:38                 ` SF Markus Elfring
  2016-01-07 20:42                   ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-07 20:38 UTC (permalink / raw)
  To: Joe Perches
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

> 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.


> 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"?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: net-thunder: One check less in nicvf_register_interrupts() after error detection
  2016-01-07 20:38                 ` SF Markus Elfring
@ 2016-01-07 20:42                   ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-01-07 20:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Robert Richter, netdev, linux-arm-kernel, Sunil Goutham, LKML,
	kernel-janitors, Julia Lawall

On Thu, 2016-01-07 at 21:38 +0100, SF Markus Elfring wrote:
> > 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.
> 
> 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.

> > 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* RE: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
  2016-01-01 14:32 ` [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg() SF Markus Elfring
@ 2016-01-07 22:43   ` Nelson, Shannon
  2016-01-08 10:42   ` Jeff Kirsher
  1 sibling, 0 replies; 1373+ messages in thread
From: Nelson, Shannon @ 2016-01-07 22:43 UTC (permalink / raw)
  To: SF Markus Elfring, netdev, intel-wired-lan, Allan, Bruce W,
	Wyborny, Carolyn, Skidmore, Donald C, Kirsher, Jeffrey T,
	Brandeburg, Jesse, Ronciak, John, Williams, Mitch A
  Cc: LKML, kernel-janitors, Julia Lawall

> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Friday, January 01, 2016 6:33 AM
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

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

sln

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-07 14:33     ` Ursula Braun
@ 2016-01-08  7:18       ` SF Markus Elfring
  2016-01-08  8:25         ` Ursula Braun
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-08  7:18 UTC (permalink / raw)
  To: Ursula Braun
  Cc: linux-s390, Heiko Carstens, Martin Schwidefsky, LKML,
	kernel-janitors, Julia Lawall

> 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.


> 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?


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

How often will this really happen?


> due to other reasons.

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-08  7:18       ` SF Markus Elfring
@ 2016-01-08  8:25         ` Ursula Braun
  2016-01-08 12:00           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Ursula Braun @ 2016-01-08  8:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Heiko Carstens, Martin Schwidefsky, LKML,
	kernel-janitors, Julia Lawall

On Fri, 2016-01-08 at 08:18 +0100, SF Markus Elfring wrote:
> > 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.
> 
> 
> > 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.
> 
> 
> > 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.
> 
> 
> > due to other reasons.
> 
> I am curious which ones will trigger further related software improvements.
> 
> Regards,
> Markus
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg()
  2016-01-01 14:32 ` [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg() SF Markus Elfring
  2016-01-07 22:43   ` Nelson, Shannon
@ 2016-01-08 10:42   ` Jeff Kirsher
  1 sibling, 0 replies; 1373+ messages in thread
From: Jeff Kirsher @ 2016-01-08 10:42 UTC (permalink / raw)
  To: SF Markus Elfring, netdev, intel-wired-lan, Bruce Allan,
	Carolyn Wyborny, Don Skidmore, Jesse Brandeburg, John Ronciak,
	Mitch Williams, Shannon Nelson
  Cc: LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 605 bytes --]

On Fri, 2016-01-01 at 15:32 +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  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.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online()
  2016-01-08  8:25         ` Ursula Braun
@ 2016-01-08 12:00           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-08 12:00 UTC (permalink / raw)
  To: Ursula Braun
  Cc: linux-s390, Heiko Carstens, Martin Schwidefsky, LKML,
	kernel-janitors, Julia Lawall

>> Is there any more fine-tuning cooking in the background?
> Not yet;

I am a bit surprised by this information.


> qeth is an important driver for Linux on System z;

Good to know …


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

Software development as usual …


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

Thanks for a bit of positive feedback.


> but prioritize it as one with lowest benefit,

This is fine in principle.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
  2015-12-29 14:17   ` [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
  2015-12-29 14:18   ` [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe() SF Markus Elfring
@ 2016-01-11  8:08   ` Lee Jones
  2016-01-12  9:00     ` SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:08 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

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?

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 29 Dec 2015 15:10:48 +0100

What format is this?

> 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(-)
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
  2015-12-29 14:18   ` [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe() SF Markus Elfring
@ 2016-01-11  8:10     ` Lee Jones
  2016-01-11  8:12       ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:10 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 29 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  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:

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
> index bcac488..951333a 100644
> --- a/drivers/mfd/smsc-ece1099.c
> +++ b/drivers/mfd/smsc-ece1099.c
> @@ -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;
>  }
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
  2016-01-11  8:10     ` Lee Jones
@ 2016-01-11  8:12       ` Lee Jones
       [not found]         ` <5694BE21.3010504@users.sourceforge.net>
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:12 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

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

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

On Mon, 11 Jan 2016, Lee Jones wrote:
> On Tue, 29 Dec 2015, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > 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.
> 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  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:
> 
> Acked-by: Lee Jones <lee.jones@linaro.org>
> 
> > diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
> > index bcac488..951333a 100644
> > --- a/drivers/mfd/smsc-ece1099.c
> > +++ b/drivers/mfd/smsc-ece1099.c
> > @@ -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;
> >  }
> >  
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
  2015-12-29 14:17   ` [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
@ 2016-01-11  8:15     ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:15 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 29 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/smsc-ece1099.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
> index a4c0df7..bcac488 100644
> --- a/drivers/mfd/smsc-ece1099.c
> +++ b/drivers/mfd/smsc-ece1099.c
> @@ -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);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection
  2015-12-29 18:34 ` [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection SF Markus Elfring
@ 2016-01-11  8:29   ` Lee Jones
  2016-05-15 18:11     ` [PATCH 0/2] mfd: twl-core: Fine-tuning for add_numbered_child() SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-omap, Tony Lindgren, LKML, kernel-janitors, Julia Lawall

On Tue, 29 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/twl-core.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 831696e..0d9350c 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -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()

>  		status = -ENOMEM;
> -		goto err;
> +		goto report_failure;

... and just return status from here.

>  	}
>  
>  	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);
>  		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.

>  		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,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection
  2015-12-29 13:04 ` [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection SF Markus Elfring
@ 2016-01-11  8:31   ` Lee Jones
  2016-01-12  8:34     ` SF Markus Elfring
  2016-01-12 11:59   ` [PATCH] " Lee Jones
  1 sibling, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-11  8:31 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 29 Dec 2015, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)

Same comments as before.

> diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
> index bc90efe..e4aa1b8 100644
> --- a/drivers/mfd/dm355evm_msp.c
> +++ b/drivers/mfd/dm355evm_msp.c
> @@ -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)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
@ 2016-01-11 13:11         ` Selvin Xavier
  0 siblings, 0 replies; 1373+ messages in thread
From: Selvin Xavier @ 2016-01-11 13:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, kbuild-all, LKML, kernel-janitors,
	Julia Lawall

This patch series looks good to me

Thanks,

Acked-by: Selvin Xavier <selvin.xavier@avagotech.com>



On Sun, Dec 27, 2015 at 2:58 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 583001b..7f10cc47 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd-dm355evm_msp: One function call less in add_child() after error detection
  2016-01-11  8:31   ` Lee Jones
@ 2016-01-12  8:34     ` SF Markus Elfring
  2016-01-12  9:06       ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12  8:34 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

>> 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.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-11  8:08   ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning " Lee Jones
@ 2016-01-12  9:00     ` SF Markus Elfring
  2016-01-12  9:12       ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12  9:00 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> 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.


>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
       [not found]         ` <5694BE21.3010504@users.sourceforge.net>
@ 2016-01-12  9:05           ` Lee Jones
  2016-01-12 11:28             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-12  9:05 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

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

On Tue, 12 Jan 2016, SF Markus Elfring wrote:
> > 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.

> >> Code looks fine however.
> 
> Thanks for your look.
> 
> 
> >> Please re-submit the set with the aforementioned changes along with my:
> >>
> >> Acked-by: Lee Jones <lee.jones@linaro.org>
> 
> 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. :)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd-dm355evm_msp: One function call less in add_child() after error detection
  2016-01-12  8:34     ` SF Markus Elfring
@ 2016-01-12  9:06       ` Lee Jones
  2016-01-12 11:48         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-12  9:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 12 Jan 2016, SF Markus Elfring wrote:

> >> 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.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> ---
> >>  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?

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

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-12  9:00     ` SF Markus Elfring
@ 2016-01-12  9:12       ` Lee Jones
  2016-01-12 11:03         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-12  9:12 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 12 Jan 2016, SF Markus Elfring wrote:

> > 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.

> >> From: Markus Elfring <elfring@users.sourceforge.net>
> >> 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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-12  9:12       ` Lee Jones
@ 2016-01-12 11:03         ` SF Markus Elfring
  2016-01-12 11:14           ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12 11:03 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> In my inbox, your set looks like this:

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


> ... 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"?


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

I admit that I am doing this usually.


> You should instead be creating patches with `git format-patch`

This happens also …


> and sending them using `git send-email`.

I prefer other software tools for this task so far.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-12 11:03         ` SF Markus Elfring
@ 2016-01-12 11:14           ` Lee Jones
  2016-01-12 11:42             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-12 11:14 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 12 Jan 2016, SF Markus Elfring wrote:

> > In my inbox, your set looks like this:
> 
> Thanks for your information. - I find the display correct.
> 
> > ... 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.

> > 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.

> > You should instead be creating patches with `git format-patch`
> 
> This happens also …
> 
> > and sending them using `git send-email`.
> 
> I prefer other software tools for this task so far.

Such as?

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe()
  2016-01-12  9:05           ` Lee Jones
@ 2016-01-12 11:28             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12 11:28 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

>> 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?


>>>> Acked-by: Lee Jones <lee.jones@linaro.org>
>>
>> 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 …


> The code looks fine,

Thanks for a bit of positive feedback.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-12 11:14           ` Lee Jones
@ 2016-01-12 11:42             ` SF Markus Elfring
  2016-01-12 12:03               ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12 11:42 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

>> 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.


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

These refer to the component "smsc-ece1099".


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

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd-dm355evm_msp: One function call less in add_child() after error detection
  2016-01-12  9:06       ` Lee Jones
@ 2016-01-12 11:48         ` SF Markus Elfring
  2016-01-12 11:59           ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12 11:48 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

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

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection
  2015-12-29 13:04 ` [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection SF Markus Elfring
  2016-01-11  8:31   ` Lee Jones
@ 2016-01-12 11:59   ` Lee Jones
  2016-01-12 12:20     ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-01-12 11:59 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

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

On Tue, 29 Dec 2015, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 29 Dec 2015 13:56:42 +0100

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

> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/dm355evm_msp.c | 21 ++++++++++-----------
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
> index bc90efe..e4aa1b8 100644
> --- a/drivers/mfd/dm355evm_msp.c
> +++ b/drivers/mfd/dm355evm_msp.c
> @@ -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().

>  		status = -ENOMEM;
> -		goto err;
> +		goto report_failure;

Return here.

>  	}
>  
>  	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)

Be more consistent here.

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

> +		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.

> +	return ERR_PTR(status);
>  }
>  
>  static int add_children(struct i2c_client *client)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd-dm355evm_msp: One function call less in add_child() after error detection
  2016-01-12 11:48         ` SF Markus Elfring
@ 2016-01-12 11:59           ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-01-12 11:59 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 12 Jan 2016, SF Markus Elfring wrote:

> > 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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe()
  2016-01-12 11:42             ` SF Markus Elfring
@ 2016-01-12 12:03               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-01-12 12:03 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Tue, 12 Jan 2016, SF Markus Elfring wrote:

> >> 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.

> > 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.

> > 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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd-dm355evm_msp: One function call less in add_child() after error detection
  2016-01-12 11:59   ` [PATCH] " Lee Jones
@ 2016-01-12 12:20     ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-12 12:20 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> The subject format is wrong

Which format do you expect?


> and the summary itself isn't very informative.

Which wording do you find more useful?


>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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.


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

Thanks for your suggestion.


>> 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.


>> +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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection
  2015-12-29 19:50 ` [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection SF Markus Elfring
@ 2016-01-12 15:07   ` Ulf Hansson
  0 siblings, 0 replies; 1373+ messages in thread
From: Ulf Hansson @ 2016-01-12 15:07 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-mmc, LKML, kernel-janitors, Julia Lawall

On 29 December 2015 at 20:50, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mmc/core/mmc.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 549c56e..866f72b 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -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
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware()
  2016-01-02  8:50   ` Arend van Spriel
@ 2016-01-14  6:58     ` Kalle Valo
  0 siblings, 0 replies; 1373+ messages in thread
From: Kalle Valo @ 2016-01-14  6:58 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: SF Markus Elfring, brcm80211-dev-list, linux-wireless, netdev,
	Brett Rudley, Franky (Zhenhui) Lin, Hante Meuleman, LKML,
	kernel-janitors, Julia Lawall

Arend van Spriel <arend@broadcom.com> writes:

> On 01/01/2016 08:26 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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
$

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
  2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2015-12-26 18:51   ` [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
@ 2016-01-14 17:18   ` SF Markus Elfring
  2016-01-14 17:38     ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
                       ` (5 more replies)
  6 siblings, 6 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:18 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.6.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-01-14 17:38     ` SF Markus Elfring
  2016-01-14 17:43     ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
                       ` (4 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:38 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d4c687b..4caf167 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2016-01-14 17:38     ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
@ 2016-01-14 17:43     ` SF Markus Elfring
  2016-01-15 13:20       ` Leon Romanovsky
  2016-01-14 17:45     ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
                       ` (3 subsequent siblings)
  5 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:43 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
index a343e03..41f0171 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
@@ -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;
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 283ca84..159b1d5 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -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;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
index 86c303a..119baa3 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
@@ -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;
 
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 4caf167..1d90d18 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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);
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
  2016-01-14 17:38     ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
  2016-01-14 17:43     ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2016-01-14 17:45     ` SF Markus Elfring
  2016-01-14 17:48     ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
                       ` (2 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:45 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 17:54:45 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
index 159b1d5..3766927 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
@@ -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)
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                       ` (2 preceding siblings ...)
  2016-01-14 17:45     ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
@ 2016-01-14 17:48     ` SF Markus Elfring
  2016-01-14 17:50     ` [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
  2016-01-14 17:51     ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:48 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 1d90d18..5f2a34a 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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,
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                       ` (3 preceding siblings ...)
  2016-01-14 17:48     ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
@ 2016-01-14 17:50     ` SF Markus Elfring
  2016-01-14 17:51     ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:50 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 14 Jan 2016 18:04:17 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index 5f2a34a..d87985b 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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)
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
  2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
                       ` (4 preceding siblings ...)
  2016-01-14 17:50     ` [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
@ 2016-01-14 17:51     ` SF Markus Elfring
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-14 17:51 UTC (permalink / raw)
  To: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
index d87985b..e6e1b51 100644
--- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
+++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
@@ -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,
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table()
  2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-01-01 12:24   ` [PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
@ 2016-01-15 10:09   ` SF Markus Elfring
  2016-01-15 10:11     ` [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
                       ` (2 more replies)
  3 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 10:09 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.6.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-15 10:11     ` SF Markus Elfring
  2016-01-15 10:37       ` Joe Perches
  2016-01-15 10:12     ` [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
  2016-01-15 10:14     ` [PATCH v3 3/3] gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 10:11 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 4b0ee85..825b051 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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;
 }
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  2016-01-15 10:11     ` [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
@ 2016-01-15 10:12     ` SF Markus Elfring
  2016-01-15 10:29       ` Dan Carpenter
  2016-01-15 10:14     ` [PATCH v3 3/3] gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 10:12 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 825b051..8302f7d 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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),
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 3/3] gianfar: Extend an initialisation clause of a for loop in gfar_ethflow_to_filer_table()
  2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
  2016-01-15 10:11     ` [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
  2016-01-15 10:12     ` [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-15 10:14     ` SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 10:14 UTC (permalink / raw)
  To: netdev, Claudiu Manoil; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/freescale/gianfar_ethtool.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
index 8302f7d..2162adc 100644
--- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
+++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
@@ -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--;
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 10:12     ` [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
@ 2016-01-15 10:29       ` Dan Carpenter
  2016-01-15 11:34         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-15 10:29 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

On Fri, Jan 15, 2016 at 11:12:42AM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/freescale/gianfar_ethtool.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/gianfar_ethtool.c b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> index 825b051..8302f7d 100644
> --- a/drivers/net/ethernet/freescale/gianfar_ethtool.c
> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> @@ -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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 10:11     ` [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
@ 2016-01-15 10:37       ` Joe Perches
  2016-01-15 11:47         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-01-15 10:37 UTC (permalink / raw)
  To: SF Markus Elfring, netdev, Claudiu Manoil
  Cc: LKML, kernel-janitors, Julia Lawall

On Fri, 2016-01-15 at 11:11 +0100, SF Markus Elfring wrote:
> 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;
}

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 10:29       ` Dan Carpenter
@ 2016-01-15 11:34         ` SF Markus Elfring
  2016-01-15 12:15           ` Dan Carpenter
  2016-01-15 16:42           ` David Miller
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 11:34 UTC (permalink / raw)
  To: Dan Carpenter, netdev; +Cc: Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
>> @@ -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=b75ec3af27bf011a760e2f44eb25a99b6fbb0fb3#n850

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

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 10:37       ` Joe Perches
@ 2016-01-15 11:47         ` SF Markus Elfring
  2016-01-15 12:03           ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 11:47 UTC (permalink / raw)
  To: Joe Perches, netdev; +Cc: Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

>> * 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.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 11:47         ` SF Markus Elfring
@ 2016-01-15 12:03           ` Joe Perches
  2016-01-15 17:32             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-01-15 12:03 UTC (permalink / raw)
  To: SF Markus Elfring, netdev
  Cc: Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

On Fri, 2016-01-15 at 12:47 +0100, SF Markus Elfring wrote:
> > > * 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.
> 
> 
> > 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?

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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 11:34         ` SF Markus Elfring
@ 2016-01-15 12:15           ` Dan Carpenter
  2016-01-15 16:42           ` David Miller
  1 sibling, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-15 12:15 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

On Fri, Jan 15, 2016 at 12:34:33PM +0100, SF Markus Elfring wrote:
> >> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
> >> @@ -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?

Yeah.  That's a good idea.  I will do that.

> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/tree/drivers/net/ethernet/freescale/gianfar_ethtool.c?id=b75ec3af27bf011a760e2f44eb25a99b6fbb0fb3#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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations
  2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-01-02 14:45   ` [PATCH 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
@ 2016-01-15 13:04   ` SF Markus Elfring
  2016-01-15 13:09     ` [PATCH v3 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
                       ` (2 more replies)
  3 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 13:04 UTC (permalink / raw)
  To: linux-wireless, netdev, Fariya Fatima, Jahnavi Meher, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall, John W. Linville

From: Markus Elfring <elfring@users.sourceforge.net>
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.

-- 
2.6.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v3 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt()
  2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-01-15 13:09     ` SF Markus Elfring
  2016-01-15 13:10     ` [PATCH v3 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
  2016-01-15 13:12     ` [PATCH v3 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 13:09 UTC (permalink / raw)
  To: linux-wireless, netdev, Fariya Fatima, Jahnavi Meher, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall, John W. Linville

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index 702593f..571eaba 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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);
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt()
  2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-15 13:09     ` [PATCH v3 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
@ 2016-01-15 13:10     ` SF Markus Elfring
  2016-01-15 13:12     ` [PATCH v3 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 13:10 UTC (permalink / raw)
  To: linux-wireless, netdev, Fariya Fatima, Jahnavi Meher, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall, John W. Linville

>From 017d1bb49f46266ffeb33178ddd3022d6b341d71 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index 571eaba..4322df1 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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;
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v3 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
  2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
  2016-01-15 13:09     ` [PATCH v3 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
  2016-01-15 13:10     ` [PATCH v3 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
@ 2016-01-15 13:12     ` SF Markus Elfring
  2016-01-19 12:40       ` Dan Carpenter
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 13:12 UTC (permalink / raw)
  To: linux-wireless, netdev, Fariya Fatima, Jahnavi Meher, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall, John W. Linville

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 15 Jan 2016 13:40:22 +0100

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/rsi/rsi_91x_pkt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_pkt.c b/drivers/net/wireless/rsi/rsi_91x_pkt.c
index 4322df1..2c18c01 100644
--- a/drivers/net/wireless/rsi/rsi_91x_pkt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_pkt.c
@@ -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);
-- 
2.6.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-14 17:43     ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
@ 2016-01-15 13:20       ` Leon Romanovsky
  2016-01-15 14:50         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-15 13:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Thu, Jan 14, 2016 at 06:43:13PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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?

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  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(-)
> 
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> index a343e03..41f0171 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_ah.c
> @@ -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;
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> index 283ca84..159b1d5 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c
> @@ -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;
>  
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> index 86c303a..119baa3 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_stats.c
> @@ -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;
>  
> diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> index 4caf167..1d90d18 100644
> --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
> @@ -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);
> -- 
> 2.6.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 13:20       ` Leon Romanovsky
@ 2016-01-15 14:50         ` SF Markus Elfring
  2016-01-15 15:09           ` Leon Romanovsky
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 14:50 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall

>> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 14:50         ` SF Markus Elfring
@ 2016-01-15 15:09           ` Leon Romanovsky
  2016-01-15 15:26             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-15 15:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Fri, Jan 15, 2016 at 03:50:27PM +0100, SF Markus Elfring wrote:
> >> 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.

> 
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 15:09           ` Leon Romanovsky
@ 2016-01-15 15:26             ` SF Markus Elfring
  2016-01-15 15:59               ` Leon Romanovsky
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 15:26 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall

>> 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?


> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 15:26             ` SF Markus Elfring
@ 2016-01-15 15:59               ` Leon Romanovsky
  2016-01-15 16:10                 ` Dan Carpenter
  2016-01-15 16:24                 ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-15 15:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Fri, Jan 15, 2016 at 04:26:36PM +0100, SF Markus Elfring wrote:
> >> 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.

> 
> 
> > 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.

> 
> 
> > The proposed change won't affect performance at all.
> 
> Will unneeded variable assignments be really optimised away by default?

Yes

> 
> 
> 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?

> 
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 15:59               ` Leon Romanovsky
@ 2016-01-15 16:10                 ` Dan Carpenter
  2016-01-15 16:24                 ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-15 16:10 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 15:59               ` Leon Romanovsky
  2016-01-15 16:10                 ` Dan Carpenter
@ 2016-01-15 16:24                 ` SF Markus Elfring
  2016-01-15 17:00                   ` Leon Romanovsky
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 16:24 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall

> GCC supported it before 1999 when I saw it first time. My assumption
> that in 2016 all compilers are doing such optimization now.

Interesting …


> 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?


>> 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?


>>> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 11:34         ` SF Markus Elfring
  2016-01-15 12:15           ` Dan Carpenter
@ 2016-01-15 16:42           ` David Miller
  2016-01-15 17:15             ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: David Miller @ 2016-01-15 16:42 UTC (permalink / raw)
  To: elfring
  Cc: dan.carpenter, netdev, claudiu.manoil, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 15 Jan 2016 12:34:33 +0100

>>> +++ b/drivers/net/ethernet/freescale/gianfar_ethtool.c
>>> @@ -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?

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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 16:24                 ` SF Markus Elfring
@ 2016-01-15 17:00                   ` Leon Romanovsky
  2016-01-15 17:19                     ` Bart Van Assche
  2016-01-15 18:19                     ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-15 17:00 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

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?

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table()
  2016-01-15 16:42           ` David Miller
@ 2016-01-15 17:15             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 17:15 UTC (permalink / raw)
  To: David Miller, Dan Carpenter
  Cc: netdev, Claudiu Manoil, linux-kernel, kernel-janitors, Julia Lawall

>>> 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.


> 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?


> 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.


> You don't put enough care and consideration into them,

Would you like to explain this impression a bit more?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 17:00                   ` Leon Romanovsky
@ 2016-01-15 17:19                     ` Bart Van Assche
  2016-01-15 17:41                       ` Leon Romanovsky
  2016-01-15 18:19                     ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Bart Van Assche @ 2016-01-15 17:19 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

On 01/15/2016 09:00 AM, Leon Romanovsky wrote:
> 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 12:03           ` Joe Perches
@ 2016-01-15 17:32             ` SF Markus Elfring
  2016-01-18 13:11               ` Claudiu Manoil
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 17:32 UTC (permalink / raw)
  To: Joe Perches, netdev; +Cc: Claudiu Manoil, LKML, kernel-janitors, Julia Lawall

>>> 	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.


> 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.


> (which as far as I saw, you didn't do)

Is my wording "after error detection" insufficient eventually?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 17:19                     ` Bart Van Assche
@ 2016-01-15 17:41                       ` Leon Romanovsky
  0 siblings, 0 replies; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-15 17:41 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: SF Markus Elfring, linux-rdma, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML,
	kernel-janitors, Julia Lawall

On Fri, Jan 15, 2016 at 09:19:38AM -0800, Bart Van Assche wrote:
> On 01/15/2016 09:00 AM, Leon Romanovsky wrote:
> >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

> 
> Thanks,
> 
> Bart.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 17:00                   ` Leon Romanovsky
  2016-01-15 17:19                     ` Bart Van Assche
@ 2016-01-15 18:19                     ` SF Markus Elfring
  2016-01-16  6:18                       ` Leon Romanovsky
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-15 18:19 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall

> [Q.] What did you try to achieve by this patch?

I would appreciate a bit more fine-tuning in the affected source files.


> P.S. This is mailing list for developers

Do you try to express any further restrictions?


> and not for patch bots.

Would you like to explain such an information a bit more?


> We are glad to see patches that clean the code, but they need to
> be meaningful.

This is usual.


> Your automated patches add noise without any real benefit.

Are you expecting a kind of special proof?


> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-15 18:19                     ` SF Markus Elfring
@ 2016-01-16  6:18                       ` Leon Romanovsky
  2016-01-16  8:30                         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Leon Romanovsky @ 2016-01-16  6:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma, Devesh Sharma, Doug Ledford, Hal Rosenstock,
	Mitesh Ahuja, Sean Hefty, Selvin Xavier, LKML, kernel-janitors,
	Julia Lawall

On Fri, Jan 15, 2016 at 07:19:31PM +0100, SF Markus Elfring wrote:
> > [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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2016-01-16  6:18                       ` Leon Romanovsky
@ 2016-01-16  8:30                         ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-16  8:30 UTC (permalink / raw)
  To: linux-rdma, Leon Romanovsky
  Cc: Devesh Sharma, Doug Ledford, Hal Rosenstock, Mitesh Ahuja,
	Sean Hefty, Selvin Xavier, LKML, kernel-janitors, Julia Lawall,
	kbuild-all, ltp, users

> 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?


> 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?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* RE: gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection
  2016-01-15 17:32             ` SF Markus Elfring
@ 2016-01-18 13:11               ` Claudiu Manoil
  0 siblings, 0 replies; 1373+ messages in thread
From: Claudiu Manoil @ 2016-01-18 13:11 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Claudiu Manoil, LKML, kernel-janitors, netdev

>-----Original Message-----
>From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
>Sent: Friday, January 15, 2016 7:33 PM
>To: Joe Perches <joe@perches.com>; netdev@vger.kernel.org
>Cc: Claudiu Manoil <claudiu.manoil@freescale.com>; LKML <linux-
>kernel@vger.kernel.org>; kernel-janitors@vger.kernel.org; Julia Lawall
><julia.lawall@lip6.fr>
>Subject: Re: gianfar: Less function calls in gfar_ethflow_to_filer_table() after
>error detection
>
>>>> 	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.
>
>
>> 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.
>
>
>> (which as far as I saw, you didn't do)
>
>Is my wording "after error detection" insufficient eventually?
>
>
>> 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v3 3/3] rsi: Replace variable initialisations by assignments in rsi_send_data_pkt()
  2016-01-15 13:12     ` [PATCH v3 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
@ 2016-01-19 12:40       ` Dan Carpenter
  0 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-01-19 12:40 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Fariya Fatima, Jahnavi Meher, Kalle Valo,
	LKML, kernel-janitors, Julia Lawall, John W. Linville

Still makes no sense for adapter like Francois Romieu said.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker()
  2016-01-02  8:21       ` Julia Lawall
  2016-01-02  9:08         ` SF Markus Elfring
@ 2016-01-21 15:07         ` Kalle Valo
  1 sibling, 0 replies; 1373+ messages in thread
From: Kalle Valo @ 2016-01-21 15:07 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Sergei Shtylyov, libertas-dev, linux-wireless,
	netdev, LKML, kernel-janitors

Julia Lawall <julia.lawall@lip6.fr> writes:

> On Sat, 2 Jan 2016, SF Markus Elfring wrote:
>
>> >> 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.
>> 
>> 
>> > The code was smart enough
>> 
>> Which action should really be performed after a failure was detected
>> and handled a bit already?
>> 
>> * Another condition check
>> 
>> * Just additional error logging
>> 
>> 
>> > 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?
>
> 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.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions
  2015-12-28 14:38           ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
  2015-12-28 14:42             ` Julia Lawall
@ 2016-01-25 17:01             ` Mauro Carvalho Chehab
  2016-01-25 18:15               ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 17:01 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-media, Julia Lawall, LKML, kernel-janitors

Em Mon, 28 Dec 2015 15:38:54 +0100
SF Markus Elfring <elfring@users.sourceforge.net> escreveu:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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".
> 
> Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
>  1 file changed, 78 insertions(+), 76 deletions(-)
> 
> diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
> index 504bfbc..7e59a9f 100644
> --- a/drivers/media/tuners/m88rs6000t.c
> +++ b/drivers/media/tuners/m88rs6000t.c
> @@ -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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] [media] r820t: Better exception handling in generic_set_freq()
  2015-12-28 16:32   ` [PATCH 2/2] [media] r820t: Better exception handling " SF Markus Elfring
@ 2016-01-25 17:04     ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 1373+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 17:04 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-media, LKML, kernel-janitors, Julia Lawall

Em Mon, 28 Dec 2015 17:32:22 +0100
SF Markus Elfring <elfring@users.sourceforge.net> escreveu:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/tuners/r820t.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/tuners/r820t.c b/drivers/media/tuners/r820t.c
> index 6ab35e3..f71642e 100644
> --- a/drivers/media/tuners/r820t.c
> +++ b/drivers/media/tuners/r820t.c
> @@ -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.

>  
>  	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;
>  }
>  

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()
  2015-12-28 19:20 ` [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner() SF Markus Elfring
@ 2016-01-25 17:06   ` Mauro Carvalho Chehab
  2016-01-25 18:23     ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Mauro Carvalho Chehab @ 2016-01-25 17:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-media, LKML, kernel-janitors, Julia Lawall

Em Mon, 28 Dec 2015 20:20:27 +0100
SF Markus Elfring <elfring@users.sourceforge.net> escreveu:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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".
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/media/tuners/xc5000.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
> index e6e5e90..1360677 100644
> --- a/drivers/media/tuners/xc5000.c
> +++ b/drivers/media/tuners/xc5000.c
> @@ -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);
>  
> @@ -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.

>  	}
>  
> -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)

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions
  2016-01-25 17:01             ` [PATCH 1/2] " Mauro Carvalho Chehab
@ 2016-01-25 18:15               ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-25 18:15 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, LKML, kernel-janitors, Julia Lawall

>> 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".
>>
>> Suggested-by: Julia Lawall <julia.lawall@lip6.fr>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/media/tuners/m88rs6000t.c | 154 +++++++++++++++++++-------------------
>>  1 file changed, 78 insertions(+), 76 deletions(-)
>>
>> diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c
>> index 504bfbc..7e59a9f 100644
>> --- a/drivers/media/tuners/m88rs6000t.c
>> +++ b/drivers/media/tuners/m88rs6000t.c
>> @@ -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"?


> Calling it as "err" is enough,

It seems that some short identifiers are popular during software development.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()
  2016-01-25 17:06   ` Mauro Carvalho Chehab
@ 2016-01-25 18:23     ` SF Markus Elfring
  2016-01-25 18:38       ` Devin Heitmueller
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-01-25 18:23 UTC (permalink / raw)
  To: Mauro Carvalho Chehab; +Cc: linux-media, LKML, kernel-janitors, Julia Lawall

>> 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".
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>>  drivers/media/tuners/xc5000.c | 16 +++++++---------
>>  1 file changed, 7 insertions(+), 9 deletions(-)
>>
>> diff --git a/drivers/media/tuners/xc5000.c b/drivers/media/tuners/xc5000.c
>> index e6e5e90..1360677 100644
>> --- a/drivers/media/tuners/xc5000.c
>> +++ b/drivers/media/tuners/xc5000.c
>> @@ -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);
>>  
>> @@ -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"?


>>  	}
>>  
>> -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)


Is the proposed source code restructuring interesting?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner()
  2016-01-25 18:23     ` SF Markus Elfring
@ 2016-01-25 18:38       ` Devin Heitmueller
  0 siblings, 0 replies; 1373+ messages in thread
From: Devin Heitmueller @ 2016-01-25 18:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Mauro Carvalho Chehab, Linux Media Mailing List, LKML,
	kernel-janitors, Julia Lawall

> 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

-- 
Devin J. Heitmueller - Kernel Labs
http://www.kernellabs.com

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] mmc-host: Fine-tuning for one function
  2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
  2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
  2015-12-29 21:02   ` [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection SF Markus Elfring
@ 2016-01-27 14:15   ` Ulf Hansson
  2 siblings, 0 replies; 1373+ messages in thread
From: Ulf Hansson @ 2016-01-27 14:15 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mmc, Sascha Sommer, LKML, kernel-janitors, Julia Lawall

On 29 December 2015 at 21:57, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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
>
>  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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc()
  2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
@ 2016-02-21  9:11     ` Sascha Sommer
  0 siblings, 0 replies; 1373+ messages in thread
From: Sascha Sommer @ 2016-02-21  9:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mmc, Ulf Hansson, LKML, kernel-janitors, Julia Lawall

Hello,

Am Tue, 29 Dec 2015 22:00:35 +0100
schrieb SF Markus Elfring <elfring@users.sourceforge.net>:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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
> 
> Thus let us omit the explicit initialisation at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Sascha Sommer <saschasommer@freenet.de>


Best regards

Sascha

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection
  2015-12-29 21:02   ` [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection SF Markus Elfring
@ 2016-02-21  9:15     ` Sascha Sommer
  0 siblings, 0 replies; 1373+ messages in thread
From: Sascha Sommer @ 2016-02-21  9:15 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-mmc, Ulf Hansson, LKML, kernel-janitors, Julia Lawall

Hello,

Am Tue, 29 Dec 2015 22:02:37 +0100
schrieb SF Markus Elfring <elfring@users.sourceforge.net>:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> * 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Acked-by: Sascha Sommer <saschasommer@freenet.de>

Best regards

Sascha

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-01-01 18:25   ` [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel() SF Markus Elfring
  2016-01-01 19:14     ` Oleksij Rempel
@ 2016-04-08  1:40     ` Julian Calaby
  2016-04-15 12:09       ` Kalle Valo
  2016-04-19 16:13       ` Kalle Valo
  1 sibling, 2 replies; 1373+ messages in thread
From: Julian Calaby @ 2016-04-08  1:40 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath9k-devel, linux-wireless, netdev, QCA ath9k Development, LKML,
	SF Markus Elfring, kernel-janitors, Julia Lawall

Hi Kalle,

On Sat, Jan 2, 2016 at 5:25 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 1 Jan 2016 19:09:32 +0100
>
> Replace an explicit initialisation for one local variable at the beginning
> by a conditional assignment.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

This looks sane to me.

Reviewed-by: Julian Calaby <julian.calaby@gmail.com>

Thanks,

Julian Calaby

> ---
>  drivers/net/wireless/ath/ath9k/htc_drv_main.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> index a680a97..30bd59e 100644
> --- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> +++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
> @@ -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@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html



-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-04-08  1:40     ` Julian Calaby
@ 2016-04-15 12:09       ` Kalle Valo
  2016-04-15 14:34         ` Julian Calaby
  2016-04-19 16:13       ` Kalle Valo
  1 sibling, 1 reply; 1373+ messages in thread
From: Kalle Valo @ 2016-04-15 12:09 UTC (permalink / raw)
  To: Julian Calaby
  Cc: ath9k-devel, linux-wireless, netdev, QCA ath9k Development, LKML,
	SF Markus Elfring, kernel-janitors, Julia Lawall

Julian Calaby <julian.calaby@gmail.com> writes:

> Hi Kalle,
>
> On Sat, Jan 2, 2016 at 5:25 AM, SF Markus Elfring
> <elfring@users.sourceforge.net> wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Fri, 1 Jan 2016 19:09:32 +0100
>>
>> Replace an explicit initialisation for one local variable at the beginning
>> by a conditional assignment.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>
> This looks sane to me.
>
> Reviewed-by: Julian Calaby <julian.calaby@gmail.com>

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()

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-04-15 12:09       ` Kalle Valo
@ 2016-04-15 14:34         ` Julian Calaby
  0 siblings, 0 replies; 1373+ messages in thread
From: Julian Calaby @ 2016-04-15 14:34 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath9k-devel, linux-wireless, netdev, QCA ath9k Development, LKML,
	SF Markus Elfring, kernel-janitors, Julia Lawall

Hi Kalle,

On Fri, Apr 15, 2016 at 10:09 PM, Kalle Valo <kvalo@codeaurora.org> wrote:
> Julian Calaby <julian.calaby@gmail.com> writes:
>
>> Hi Kalle,
>>
>> On Sat, Jan 2, 2016 at 5:25 AM, SF Markus Elfring
>> <elfring@users.sourceforge.net> wrote:
>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>> Date: Fri, 1 Jan 2016 19:09:32 +0100
>>>
>>> Replace an explicit initialisation for one local variable at the beginning
>>> by a conditional assignment.
>>>
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>
>> This looks sane to me.
>>
>> Reviewed-by: Julian Calaby <julian.calaby@gmail.com>
>
> 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,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel()
  2016-04-08  1:40     ` Julian Calaby
  2016-04-15 12:09       ` Kalle Valo
@ 2016-04-19 16:13       ` Kalle Valo
  1 sibling, 0 replies; 1373+ messages in thread
From: Kalle Valo @ 2016-04-19 16:13 UTC (permalink / raw)
  To: Julian Calaby
  Cc: ath9k-devel, linux-wireless, netdev, QCA ath9k Development, LKML,
	SF Markus Elfring, kernel-janitors, Julia Lawall

Julian Calaby <julian.calaby@gmail.com> writes:

> On Sat, Jan 2, 2016 at 5:25 AM, SF Markus Elfring
> <elfring@users.sourceforge.net> wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Fri, 1 Jan 2016 19:09:32 +0100
>>
>> Replace an explicit initialisation for one local variable at the beginning
>> by a conditional assignment.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>
> This looks sane to me.
>
> Reviewed-by: Julian Calaby <julian.calaby@gmail.com>

Applied, thanks.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] mfd: twl-core: Fine-tuning for add_numbered_child()
  2016-01-11  8:29   ` Lee Jones
@ 2016-05-15 18:11     ` SF Markus Elfring
  2016-05-16  6:26       ` [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
  2016-05-16  6:28       ` [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-05-15 18:11 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.8.2

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-15 18:11     ` [PATCH 0/2] mfd: twl-core: Fine-tuning for add_numbered_child() SF Markus Elfring
@ 2016-05-16  6:26       ` SF Markus Elfring
  2016-05-16  6:51         ` Julia Lawall
  2016-05-16  6:28       ` [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-05-16  6:26 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/twl-core.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 831696e..dc34e69 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -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;
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child()
  2016-05-15 18:11     ` [PATCH 0/2] mfd: twl-core: Fine-tuning for add_numbered_child() SF Markus Elfring
  2016-05-16  6:26       ` [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
@ 2016-05-16  6:28       ` SF Markus Elfring
  2016-06-08 11:14         ` Lee Jones
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-05-16  6:28 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/twl-core.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index dc34e69..3e4f4e4 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -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,
-- 
2.8.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-16  6:26       ` [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
@ 2016-05-16  6:51         ` Julia Lawall
  2016-05-16  7:54           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-05-16  6:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Lee Jones, Tony Lindgren, linux-omap, LKML, kernel-janitors



On Mon, 16 May 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> 
> * Return directly in this case.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/twl-core.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 831696e..dc34e69 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -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;
> -- 
> 2.8.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-16  6:51         ` Julia Lawall
@ 2016-05-16  7:54           ` SF Markus Elfring
  2016-05-16  8:07             ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-05-16  7:54 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Lee Jones, Tony Lindgren, linux-omap, LKML, kernel-janitors

>> * 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-16  7:54           ` SF Markus Elfring
@ 2016-05-16  8:07             ` Julia Lawall
  2016-05-17  6:00               ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-05-16  8:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Lee Jones, Tony Lindgren, linux-omap, LKML, kernel-janitors

On Mon, 16 May 2016, SF Markus Elfring wrote:

> >> * 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-16  8:07             ` Julia Lawall
@ 2016-05-17  6:00               ` Lee Jones
  2016-05-17 14:15                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-05-17  6:00 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, Tony Lindgren, linux-omap, LKML, kernel-janitors

On Mon, 16 May 2016, Julia Lawall wrote:

> On Mon, 16 May 2016, SF Markus Elfring wrote:
> 
> > >> * 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.

Yes, Julia is right.  We normally don't print anything for OOM
errors since Linux reports on them already.

Please remove the print altogether.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-05-17  6:00               ` Lee Jones
@ 2016-05-17 14:15                 ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-05-17 14:15 UTC (permalink / raw)
  To: Lee Jones; +Cc: Julia Lawall, Tony Lindgren, linux-omap, LKML, kernel-janitors

> Please remove the print altogether.

Would you like to omit any extra logging statements at more source code places?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child()
  2016-05-16  6:28       ` [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
@ 2016-06-08 11:14         ` Lee Jones
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-06-08 11:14 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Mon, 16 May 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/twl-core.c | 19 +++++++++----------
>  1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index dc34e69..3e4f4e4 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -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);

Nit: Place a '\n' here.

>  	return &pdev->dev;

Nit: Place a '\n' here.

> +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"

> +	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:

Acked-by: Lee Jones <lee.jones@linaro.org>

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/6] mfd: Fine-tuning for three function implementations
  2016-06-08 11:14         ` Lee Jones
@ 2016-06-26 13:34           ` SF Markus Elfring
  2016-06-26 13:45             ` [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
                               ` (6 more replies)
  0 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:34 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
@ 2016-06-26 13:45             ` SF Markus Elfring
  2016-06-28 15:02               ` Lee Jones
  2016-06-26 13:47             ` [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
                               ` (5 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:45 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/twl-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 831696e..9458c6d 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -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;
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
  2016-06-26 13:45             ` [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
@ 2016-06-26 13:47             ` SF Markus Elfring
  2016-06-28 15:03               ` Lee Jones
  2016-06-26 13:48             ` [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child() SF Markus Elfring
                               ` (4 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:47 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Acked-by: Lee Jones <lee.jones@linaro.org>
---
 drivers/mfd/twl-core.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
index 9458c6d..a49d3db 100644
--- a/drivers/mfd/twl-core.c
+++ b/drivers/mfd/twl-core.c
@@ -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,
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
  2016-06-26 13:45             ` [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
  2016-06-26 13:47             ` [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
@ 2016-06-26 13:48             ` SF Markus Elfring
  2016-06-28 15:03               ` Lee Jones
  2016-06-26 13:50             ` [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child() SF Markus Elfring
                               ` (3 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:48 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/dm355evm_msp.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 14661ec..270e19c 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -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;
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
                               ` (2 preceding siblings ...)
  2016-06-26 13:48             ` [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child() SF Markus Elfring
@ 2016-06-26 13:50             ` SF Markus Elfring
  2016-06-28 15:07               ` Lee Jones
  2016-06-26 13:51             ` [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
                               ` (2 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:50 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/dm355evm_msp.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 270e19c..baf6075 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -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)
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
                               ` (3 preceding siblings ...)
  2016-06-26 13:50             ` [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child() SF Markus Elfring
@ 2016-06-26 13:51             ` SF Markus Elfring
  2016-06-28 15:07               ` Lee Jones
  2016-06-26 13:54             ` [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure " SF Markus Elfring
  2016-06-28 15:01             ` [PATCH 0/6] mfd: Fine-tuning for three function implementations Lee Jones
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:51 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/smsc-ece1099.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
index 7f89e89..2aaf89f 100644
--- a/drivers/mfd/smsc-ece1099.c
+++ b/drivers/mfd/smsc-ece1099.c
@@ -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);
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
                               ` (4 preceding siblings ...)
  2016-06-26 13:51             ` [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
@ 2016-06-26 13:54             ` SF Markus Elfring
  2016-06-28 15:08               ` Lee Jones
  2016-06-28 15:01             ` [PATCH 0/6] mfd: Fine-tuning for three function implementations Lee Jones
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-26 13:54 UTC (permalink / raw)
  To: Lee Jones, Tony Lindgren, linux-omap; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/smsc-ece1099.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
index 2aaf89f..cd18c09 100644
--- a/drivers/mfd/smsc-ece1099.c
+++ b/drivers/mfd/smsc-ece1099.c
@@ -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;
 }
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/6] mfd: Fine-tuning for three function implementations
  2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
                               ` (5 preceding siblings ...)
  2016-06-26 13:54             ` [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure " SF Markus Elfring
@ 2016-06-28 15:01             ` Lee Jones
  6 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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(-)

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).

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child()
  2016-06-26 13:45             ` [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
@ 2016-06-28 15:02               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:02 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 26 Jun 2016 12:25:36 +0200

Please use `git send-email` when sending patches to the list.

> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/twl-core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)

Applied though, thanks.

> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 831696e..9458c6d 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -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;
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child()
  2016-06-26 13:47             ` [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
@ 2016-06-28 15:03               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:03 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> Acked-by: Lee Jones <lee.jones@linaro.org>
> ---
>  drivers/mfd/twl-core.c | 21 +++++++++++----------
>  1 file changed, 11 insertions(+), 10 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 9458c6d..a49d3db 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -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,

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child()
  2016-06-26 13:48             ` [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child() SF Markus Elfring
@ 2016-06-28 15:03               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:03 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/dm355evm_msp.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
> index 14661ec..270e19c 100644
> --- a/drivers/mfd/dm355evm_msp.c
> +++ b/drivers/mfd/dm355evm_msp.c
> @@ -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;

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-26 13:50             ` [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child() SF Markus Elfring
@ 2016-06-28 15:07               ` Lee Jones
  2016-06-28 15:40                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/dm355evm_msp.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
> index 270e19c..baf6075 100644
> --- a/drivers/mfd/dm355evm_msp.c
> +++ b/drivers/mfd/dm355evm_msp.c
> @@ -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);
>  

Remove this line too.

> -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)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe()
  2016-06-26 13:51             ` [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
@ 2016-06-28 15:07               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/smsc-ece1099.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.

> diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
> index 7f89e89..2aaf89f 100644
> --- a/drivers/mfd/smsc-ece1099.c
> +++ b/drivers/mfd/smsc-ece1099.c
> @@ -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);

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure in smsc_i2c_probe()
  2016-06-26 13:54             ` [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure " SF Markus Elfring
@ 2016-06-28 15:08               ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 15:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Sun, 26 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mfd/smsc-ece1099.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)

Applied, thanks.

> diff --git a/drivers/mfd/smsc-ece1099.c b/drivers/mfd/smsc-ece1099.c
> index 2aaf89f..cd18c09 100644
> --- a/drivers/mfd/smsc-ece1099.c
> +++ b/drivers/mfd/smsc-ece1099.c
> @@ -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;
>  }
>  

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-28 15:07               ` Lee Jones
@ 2016-06-28 15:40                 ` SF Markus Elfring
  2016-06-28 16:31                   ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-28 15:40 UTC (permalink / raw)
  To: Lee Jones; +Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

>> @@ -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.

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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-28 15:40                 ` SF Markus Elfring
@ 2016-06-28 16:31                   ` Lee Jones
  2016-06-30 20:15                     ` [PATCH] " SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-06-28 16:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Tony Lindgren, linux-omap, LKML, kernel-janitors, Julia Lawall

On Tue, 28 Jun 2016, SF Markus Elfring wrote:

> >> @@ -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.
> 
> Do you propose the deletion of a blank line here?

Yes.

> 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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-28 16:31                   ` Lee Jones
@ 2016-06-30 20:15                     ` SF Markus Elfring
  2016-06-30 20:34                       ` Joe Perches
  2016-07-01  9:17                       ` [PATCH] " Lee Jones
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-06-30 20:15 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mfd/dm355evm_msp.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
index 270e19c..86eca61 100644
--- a/drivers/mfd/dm355evm_msp.c
+++ b/drivers/mfd/dm355evm_msp.c
@@ -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)
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-30 20:15                     ` [PATCH] " SF Markus Elfring
@ 2016-06-30 20:34                       ` Joe Perches
  2016-06-30 21:00                         ` Lee Jones
  2016-07-01 14:40                         ` SF Markus Elfring
  2016-07-01  9:17                       ` [PATCH] " Lee Jones
  1 sibling, 2 replies; 1373+ messages in thread
From: Joe Perches @ 2016-06-30 20:34 UTC (permalink / raw)
  To: SF Markus Elfring, Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

On Thu, 2016-06-30 at 22:15 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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: <566ABCD9.1060404@users.sourceforge.net> <5682D228.7070902@users.sourceforge.net> <20160111082922.GB14104@x1> <05b7db2a-437a-60ac-d289-71d2150e7f5f@users.sourceforge.net> <de3598c4-f85a-6807-303a-55ee0ac707f2@users.sourceforge.net> <20160608111442.GB14888@dell> <e4eaf0b4-e539-b400-c8a2-70f210cee1fa@users.sourceforge.net> <75c1cc23-3a2d-db78-d0f2-b5934b18e828@users.sourceforge.net> <20160628150725.GL24982@dell> <c220895b-e56f-dc95-500d-0cf9d2f51777@users.sourceforge.net> <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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-30 20:34                       ` Joe Perches
@ 2016-06-30 21:00                         ` Lee Jones
  2016-07-01 14:40                         ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-06-30 21:00 UTC (permalink / raw)
  To: Joe Perches; +Cc: SF Markus Elfring, LKML, kernel-janitors, Julia Lawall

On Thu, 30 Jun 2016, Joe Perches wrote:

> On Thu, 2016-06-30 at 22:15 +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > 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: <566ABCD9.1060404@users.sourceforge.net> <5682D228.7070902@users.sourceforge.net> <20160111082922.GB14104@x1> <05b7db2a-437a-60ac-d289-71d2150e7f5f@users.sourceforge.net> <de3598c4-f85a-6807-303a-55ee0ac707f2@users.sourceforge.net> <20160608111442.GB14888@dell> <e4eaf0b4-e539-b400-c8a2-70f210cee1fa@users.sourceforge.net> <75c1cc23-3a2d-db78-d0f2-b5934b18e828@users.sourceforge.net> <20160628150725.GL24982@dell> <c220895b-e56f-dc95-500d-0cf9d2f51777@users.sourceforge.net> <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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-30 20:15                     ` [PATCH] " SF Markus Elfring
  2016-06-30 20:34                       ` Joe Perches
@ 2016-07-01  9:17                       ` Lee Jones
  2016-07-01 14:54                         ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-07-01  9:17 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Thu, 30 Jun 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  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:

Acked-by: Lee Jones <lee.jones@linaro.org>

> diff --git a/drivers/mfd/dm355evm_msp.c b/drivers/mfd/dm355evm_msp.c
> index 270e19c..86eca61 100644
> --- a/drivers/mfd/dm355evm_msp.c
> +++ b/drivers/mfd/dm355evm_msp.c
> @@ -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)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-06-30 20:34                       ` Joe Perches
  2016-06-30 21:00                         ` Lee Jones
@ 2016-07-01 14:40                         ` SF Markus Elfring
  2016-07-01 16:23                           ` Joe Perches
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-01 14:40 UTC (permalink / raw)
  To: Joe Perches; +Cc: Lee Jones, LKML, kernel-janitors, Julia Lawall

> 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.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-07-01  9:17                       ` [PATCH] " Lee Jones
@ 2016-07-01 14:54                         ` SF Markus Elfring
  2016-08-05  7:50                           ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-01 14:54 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> FYI, code looks fine.

Thanks for your acknowledgement.


> ... 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"?



> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-07-01 14:40                         ` SF Markus Elfring
@ 2016-07-01 16:23                           ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-07-01 16:23 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Lee Jones, LKML, kernel-janitors, Julia Lawall

On Fri, 2016-07-01 at 16:40 +0200, SF Markus Elfring wrote:
> > 
> > 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.
> 
> 
> > 
> > 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.

> 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?

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (48 preceding siblings ...)
  2016-01-03 16:32 ` [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init() SF Markus Elfring
@ 2016-07-02 19:00 ` SF Markus Elfring
  2016-07-02 19:05   ` [PATCH 1/2] Input-at32psif: Return directly after a failed kzalloc() " SF Markus Elfring
                     ` (3 more replies)
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
                   ` (45 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-02 19:00 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] Input-at32psif: Return directly after a failed kzalloc() in psif_probe()
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
@ 2016-07-02 19:05   ` SF Markus Elfring
  2016-07-02 19:07   ` [PATCH 2/2] Input-at32psif: Remove OOM messages " SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-02 19:05 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/serio/at32psif.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c
index 2e4ff5b..fcb769a 100644
--- a/drivers/input/serio/at32psif.c
+++ b/drivers/input/serio/at32psif.c
@@ -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;
 }
 
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] Input-at32psif: Remove OOM messages in psif_probe()
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
  2016-07-02 19:05   ` [PATCH 1/2] Input-at32psif: Return directly after a failed kzalloc() " SF Markus Elfring
@ 2016-07-02 19:07   ` SF Markus Elfring
  2016-07-02 19:29     ` Julia Lawall
  2016-07-02 20:45   ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling " Joe Perches
  2016-07-13 22:01   ` Dmitry Torokhov
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-02 19:07 UTC (permalink / raw)
  To: Dmitry Torokhov, linux-input; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/serio/at32psif.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c
index fcb769a..b30503d 100644
--- a/drivers/input/serio/at32psif.c
+++ b/drivers/input/serio/at32psif.c
@@ -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;
 	}
-- 
2.9.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] Input-at32psif: Remove OOM messages in psif_probe()
  2016-07-02 19:07   ` [PATCH 2/2] Input-at32psif: Remove OOM messages " SF Markus Elfring
@ 2016-07-02 19:29     ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-07-02 19:29 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: Dmitry Torokhov, linux-input, LKML, kernel-janitors



On Sat, 2 Jul 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/input/serio/at32psif.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/input/serio/at32psif.c b/drivers/input/serio/at32psif.c
> index fcb769a..b30503d 100644
> --- a/drivers/input/serio/at32psif.c
> +++ b/drivers/input/serio/at32psif.c
> @@ -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?

>  	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;
>  	}
> -- 
> 2.9.0
> 
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
  2016-07-02 19:05   ` [PATCH 1/2] Input-at32psif: Return directly after a failed kzalloc() " SF Markus Elfring
  2016-07-02 19:07   ` [PATCH 2/2] Input-at32psif: Remove OOM messages " SF Markus Elfring
@ 2016-07-02 20:45   ` Joe Perches
  2016-07-03  8:01     ` SF Markus Elfring
  2016-07-13 22:01   ` Dmitry Torokhov
  3 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-07-02 20:45 UTC (permalink / raw)
  To: SF Markus Elfring, Dmitry Torokhov, linux-input
  Cc: LKML, kernel-janitors, Julia Lawall

On Sat, 2016-07-02 at 21:00 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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(-)

What possible rationale is there for including this "references" header?
566ABCD9.1060404@users.sourceforge.net

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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
  2016-07-02 20:45   ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling " Joe Perches
@ 2016-07-03  8:01     ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-03  8:01 UTC (permalink / raw)
  To: Joe Perches, Dmitry Torokhov, linux-input
  Cc: LKML, kernel-janitors, Julia Lawall

>> 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(-)
> 
> What possible rationale is there for including this "references" header?
> 566ABCD9.1060404@users.sourceforge.net

Do any more software developers dare to reconsider source code
also around a jump label like "out"?


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe()
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-07-02 20:45   ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling " Joe Perches
@ 2016-07-13 22:01   ` Dmitry Torokhov
  3 siblings, 0 replies; 1373+ messages in thread
From: Dmitry Torokhov @ 2016-07-13 22:01 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux-input, LKML, kernel-janitors, Julia Lawall

On Sat, Jul 02, 2016 at 09:00:36PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations
  2015-12-21 23:48       ` Greg Kroah-Hartman
  2015-12-22  7:15         ` SF Markus Elfring
  2015-12-22  8:00         ` Dan Carpenter
@ 2016-07-26 18:54         ` SF Markus Elfring
  2016-07-26 18:56           ` [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
                             ` (11 more replies)
  2 siblings, 12 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 18:54 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>

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(-)

-- 
2.9.2

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister"
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
@ 2016-07-26 18:56           ` SF Markus Elfring
  2016-07-26 19:00           ` [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put" SF Markus Elfring
                             ` (10 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 18:56 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 821939f..2c1c2fc 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -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);
 
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put"
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
  2016-07-26 18:56           ` [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
@ 2016-07-26 19:00           ` SF Markus Elfring
  2016-07-26 19:02           ` [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
                             ` (9 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:00 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 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(-)

diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 2c1c2fc..52c5dd4 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -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);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 0e1588a..8c2e5b3 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -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:
 	/*
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 9b92d55..df701f7 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -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);
 	}
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 99c2da6..1b5aa9b 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -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);
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
  2016-07-26 18:56           ` [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
  2016-07-26 19:00           ` [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put" SF Markus Elfring
@ 2016-07-26 19:02           ` SF Markus Elfring
  2016-07-26 19:08             ` Oleg Drokin
  2016-07-26 19:04           ` [PATCH 04/12] staging: lustre: Split a condition check in class_register_type() SF Markus Elfring
                             ` (8 subsequent siblings)
  11 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:02 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/obdclass/genops.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 1b5aa9b..10dd145 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -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);
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/12] staging: lustre: Split a condition check in class_register_type()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (2 preceding siblings ...)
  2016-07-26 19:02           ` [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
@ 2016-07-26 19:04           ` SF Markus Elfring
  2016-07-26 19:05           ` [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
                             ` (7 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:04 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/obdclass/genops.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 10dd145..fd5e61f 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -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;
 }
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (3 preceding siblings ...)
  2016-07-26 19:04           ` [PATCH 04/12] staging: lustre: Split a condition check in class_register_type() SF Markus Elfring
@ 2016-07-26 19:05           ` SF Markus Elfring
  2016-07-26 19:11             ` Oleg Drokin
  2016-07-26 19:07           ` [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log() SF Markus Elfring
                             ` (6 subsequent siblings)
  11 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:05 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index fd5e61f..4752091 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -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) {
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (4 preceding siblings ...)
  2016-07-26 19:05           ` [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
@ 2016-07-26 19:07           ` SF Markus Elfring
  2016-07-26 19:08           ` [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() " SF Markus Elfring
                             ` (5 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:07 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Jul 2016 16:32:31 +0200

Return directly after a memory allocation failed at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 9d0bd47..d716bb2 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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);
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection
  2016-07-26 19:02           ` [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
@ 2016-07-26 19:08             ` Oleg Drokin
  2016-07-26 19:56               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Oleg Drokin @ 2016-07-26 19:08 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal


On Jul 26, 2016, at 3:02 PM, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.

> 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.

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/staging/lustre/lustre/obdclass/genops.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index 1b5aa9b..10dd145 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -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);
> -- 
> 2.9.2

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (5 preceding siblings ...)
  2016-07-26 19:07           ` [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log() SF Markus Elfring
@ 2016-07-26 19:08           ` SF Markus Elfring
  2016-07-26 19:09           ` [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() " SF Markus Elfring
                             ` (4 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:08 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Jul 2016 17:12:51 +0200

Release memory directly after a page allocation failed at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index d716bb2..b064bd3 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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;
 }
 
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (6 preceding siblings ...)
  2016-07-26 19:08           ` [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() " SF Markus Elfring
@ 2016-07-26 19:09           ` SF Markus Elfring
  2016-07-26 19:10           ` [PATCH 09/12] staging: lustre: Delete a check for the variable "req" " SF Markus Elfring
                             ` (3 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:09 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Jul 2016 17:54:24 +0200

Release memory directly after a call of the function
"ptlrpc_request_alloc" failed.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index b064bd3..f65bb45 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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);
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/12] staging: lustre: Delete a check for the variable "req" in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (7 preceding siblings ...)
  2016-07-26 19:09           ` [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() " SF Markus Elfring
@ 2016-07-26 19:10           ` SF Markus Elfring
  2016-07-26 19:12           ` [PATCH 10/12] staging: lustre: Rename jump labels " SF Markus Elfring
                             ` (2 subsequent siblings)
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:10 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index f65bb45..2207af7 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -1455,8 +1455,7 @@ again:
 	}
 
 out:
-	if (req)
-		ptlrpc_req_finished(req);
+	ptlrpc_req_finished(req);
 
 	if (rc == 0 && !eof)
 		goto again;
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type()
  2016-07-26 19:05           ` [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
@ 2016-07-26 19:11             ` Oleg Drokin
  2016-07-26 19:16               ` [lustre-devel] " Oleg Drokin
  2016-07-26 20:11               ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Oleg Drokin @ 2016-07-26 19:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal


On Jul 26, 2016, at 3:05 PM, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
> index fd5e61f..4752091 100644
> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
> @@ -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:

> 	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?

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 10/12] staging: lustre: Rename jump labels in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (8 preceding siblings ...)
  2016-07-26 19:10           ` [PATCH 09/12] staging: lustre: Delete a check for the variable "req" " SF Markus Elfring
@ 2016-07-26 19:12           ` SF Markus Elfring
  2016-07-26 19:13           ` [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" " SF Markus Elfring
  2016-07-26 19:14           ` [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation " SF Markus Elfring
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:12 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 26 Jul 2016 19:29:11 +0200

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 2207af7..ff60b9b 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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)
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (9 preceding siblings ...)
  2016-07-26 19:12           ` [PATCH 10/12] staging: lustre: Rename jump labels " SF Markus Elfring
@ 2016-07-26 19:13           ` SF Markus Elfring
  2016-07-26 19:14           ` [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation " SF Markus Elfring
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:13 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index ff60b9b..8f5db79 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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));
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
  2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
                             ` (10 preceding siblings ...)
  2016-07-26 19:13           ` [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" " SF Markus Elfring
@ 2016-07-26 19:14           ` SF Markus Elfring
  11 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:14 UTC (permalink / raw)
  To: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, Oleg Drokin
  Cc: LKML, kernel-janitors, Julia Lawall, Bhumika Goyal

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/mgc/mgc_request.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 8f5db79..6e8368e 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -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;
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [lustre-devel] [PATCH 05/12] staging: lustre: Optimize error handling in class_register_type()
  2016-07-26 19:11             ` Oleg Drokin
@ 2016-07-26 19:16               ` Oleg Drokin
  2016-07-26 20:11               ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: Oleg Drokin @ 2016-07-26 19:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Greg Kroah-Hartman, kernel-janitors, LKML, Julia Lawall,
	Bhumika Goyal, lustre-devel


On Jul 26, 2016, at 3:11 PM, Oleg Drokin wrote:

> 
> On Jul 26, 2016, at 3:05 PM, SF Markus Elfring wrote:
> 
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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.
>> 
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>> ---
>> drivers/staging/lustre/lustre/obdclass/genops.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>> 
>> diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
>> index fd5e61f..4752091 100644
>> --- a/drivers/staging/lustre/lustre/obdclass/genops.c
>> +++ b/drivers/staging/lustre/lustre/obdclass/genops.c
>> @@ -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:

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.

> 
>> 	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?
> _______________________________________________
> lustre-devel mailing list
> lustre-devel@lists.lustre.org
> http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: One function call less in class_register_type() after error detection
  2016-07-26 19:08             ` Oleg Drokin
@ 2016-07-26 19:56               ` SF Markus Elfring
  2016-07-26 21:49                 ` Oleg Drokin
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 19:56 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal

> But kobject_put() already checks for NULL, right?

Yes. - Such an input parameter validation is performed by the
function implementation.


> 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.


>> Adjust jump targets according to the Linux coding style convention.
> 
> Not that I am totally against this patch,

Thanks for your feedback.


> 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.


> (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.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: Optimize error handling in class_register_type()
  2016-07-26 19:11             ` Oleg Drokin
  2016-07-26 19:16               ` [lustre-devel] " Oleg Drokin
@ 2016-07-26 20:11               ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-26 20:11 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal

> NAK.
> when you do this, the next statement below breaks:

I wonder about this conclusion.


>> 	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?

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/linux-kernel@vger.kernel.org/msg1197227.html

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: One function call less in class_register_type() after error detection
  2016-07-26 19:56               ` SF Markus Elfring
@ 2016-07-26 21:49                 ` Oleg Drokin
  2016-07-28  5:53                   ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Oleg Drokin @ 2016-07-26 21:49 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal


On Jul 26, 2016, at 3:56 PM, SF Markus Elfring wrote:

>> But kobject_put() already checks for NULL, right?
> 
> Yes. - Such an input parameter validation is performed by the
> function implementation.
> 
> 
>> 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.
> 
> 
>>> Adjust jump targets according to the Linux coding style convention.
>> 
>> Not that I am totally against this patch,
> 
> Thanks for your feedback.
> 
> 
>> 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.
> 
> 
>> (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.
> 
> 
>> 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.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: staging: lustre: One function call less in class_register_type() after error detection
  2016-07-26 21:49                 ` Oleg Drokin
@ 2016-07-28  5:53                   ` SF Markus Elfring
  2016-07-29 15:28                     ` [lustre-devel] " Oleg Drokin
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-28  5:53 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: devel, lustre-devel, Andreas Dilger, Greg Kroah-Hartman, LKML,
	kernel-janitors, Julia Lawall, Bhumika Goyal

> 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?


> 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?id=6a5b99a46bedc2cfbba96dec6d255c4b90af9ff8#n140

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [lustre-devel] staging: lustre: One function call less in class_register_type() after error detection
  2016-07-28  5:53                   ` SF Markus Elfring
@ 2016-07-29 15:28                     ` Oleg Drokin
  2016-07-30  6:24                       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Oleg Drokin @ 2016-07-29 15:28 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: devel, Greg Kroah-Hartman, kernel-janitors, LKML, Julia Lawall,
	Bhumika Goyal, lustre-devel


On Jul 28, 2016, at 1:53 AM, SF Markus Elfring wrote:

>> 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.

>> 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?id=6a5b99a46bedc2cfbba96dec6d255c4b90af9ff8#n140

I am not sure what do you mean here.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [lustre-devel] staging: lustre: One function call less in class_register_type() after error detection
  2016-07-29 15:28                     ` [lustre-devel] " Oleg Drokin
@ 2016-07-30  6:24                       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-07-30  6:24 UTC (permalink / raw)
  To: Oleg Drokin
  Cc: devel, Greg Kroah-Hartman, kernel-janitors, LKML, Julia Lawall,
	Bhumika Goyal, lustre-devel

> 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?


>> 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?id=6a5b99a46bedc2cfbba96dec6d255c4b90af9ff8#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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-07-01 14:54                         ` SF Markus Elfring
@ 2016-08-05  7:50                           ` Lee Jones
  2016-08-05 18:51                             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-08-05  7:50 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Fri, 01 Jul 2016, SF Markus Elfring wrote:

> > FYI, code looks fine.
> 
> Thanks for your acknowledgement.
> 
> 
> > ... 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"?
> 
> 
> 
> > 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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-08-05  7:50                           ` Lee Jones
@ 2016-08-05 18:51                             ` SF Markus Elfring
  2016-08-08  9:11                               ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-05 18:51 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> 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


> If you are, here it is.  And, don't do that. :)

I find this feedback a bit strange.


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-08-05 18:51                             ` SF Markus Elfring
@ 2016-08-08  9:11                               ` Lee Jones
  2016-08-08  9:30                                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Lee Jones @ 2016-08-08  9:11 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Fri, 05 Aug 2016, SF Markus Elfring wrote:

> > 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
> 
> 
> > If you are, here it is.  And, don't do that. :)
> 
> I find this feedback a bit strange.
> 
> 
> > 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.

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.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-08-08  9:11                               ` Lee Jones
@ 2016-08-08  9:30                                 ` SF Markus Elfring
  2016-08-09  9:41                                   ` Lee Jones
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-08  9:30 UTC (permalink / raw)
  To: Lee Jones; +Cc: LKML, kernel-janitors, Julia Lawall

> 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/


> 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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: mfd: dm355evm_msp: Refactoring for add_child()
  2016-08-08  9:30                                 ` SF Markus Elfring
@ 2016-08-09  9:41                                   ` Lee Jones
  0 siblings, 0 replies; 1373+ messages in thread
From: Lee Jones @ 2016-08-09  9:41 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: LKML, kernel-janitors, Julia Lawall

On Mon, 08 Aug 2016, SF Markus Elfring wrote:

> > 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/
> 
> 
> > 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).

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] block-cciss: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (49 preceding siblings ...)
  2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
@ 2016-08-18  9:48 ` SF Markus Elfring
  2016-08-18  9:55   ` [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (4 more replies)
  2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
                   ` (44 subsequent siblings)
  95 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18  9:48 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-08-18  9:55   ` SF Markus Elfring
  2016-08-18  9:56   ` [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection SF Markus Elfring
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18  9:55 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/cciss.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index db9d6bb..e044342 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
  2016-08-18  9:55   ` [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-18  9:56   ` SF Markus Elfring
  2016-08-18 10:00   ` [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru() SF Markus Elfring
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18  9:56 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/cciss.c | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index e044342..43ac632 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru()
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
  2016-08-18  9:55   ` [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-18  9:56   ` [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection SF Markus Elfring
@ 2016-08-18 10:00   ` SF Markus Elfring
  2016-08-18 10:02   ` [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" " SF Markus Elfring
  2016-08-18 10:03   ` [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 10:00 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/cciss.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 43ac632..10e1b0a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" in cciss_bigpassthru()
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-18 10:00   ` [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru() SF Markus Elfring
@ 2016-08-18 10:02   ` SF Markus Elfring
  2016-08-18 10:03   ` [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 10:02 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/cciss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 10e1b0a..b08bfb7 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc()
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-18 10:02   ` [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" " SF Markus Elfring
@ 2016-08-18 10:03   ` SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 10:03 UTC (permalink / raw)
  To: esc.storagedev, iss_storagedev, linux-scsi, Don Brace
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/cciss.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index b08bfb7..3502a3a 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -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;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (50 preceding siblings ...)
  2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-08-18 19:42 ` SF Markus Elfring
  2016-08-18 19:45   ` [PATCH 1/2] GPU-DRM-Savage: Use memdup_user() rather than duplicating SF Markus Elfring
                     ` (2 more replies)
  2016-08-19  9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
                   ` (43 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 19:42 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] GPU-DRM-Savage: Use memdup_user() rather than duplicating
  2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
@ 2016-08-18 19:45   ` SF Markus Elfring
  2016-08-18 19:48   ` [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection SF Markus Elfring
  2016-08-19  7:41   ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() Daniel Vetter
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 19:45 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/savage/savage_state.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index c01ad0a..3dc0d8f 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection
  2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
  2016-08-18 19:45   ` [PATCH 1/2] GPU-DRM-Savage: Use memdup_user() rather than duplicating SF Markus Elfring
@ 2016-08-18 19:48   ` SF Markus Elfring
  2016-08-19  7:50     ` Daniel Vetter
  2016-08-19  7:41   ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() Daniel Vetter
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-18 19:48 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
index 3dc0d8f..5b484aa 100644
--- a/drivers/gpu/drm/savage/savage_state.c
+++ b/drivers/gpu/drm/savage/savage_state.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf()
  2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
  2016-08-18 19:45   ` [PATCH 1/2] GPU-DRM-Savage: Use memdup_user() rather than duplicating SF Markus Elfring
  2016-08-18 19:48   ` [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection SF Markus Elfring
@ 2016-08-19  7:41   ` Daniel Vetter
  2 siblings, 0 replies; 1373+ messages in thread
From: Daniel Vetter @ 2016-08-19  7:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, LKML, kernel-janitors,
	Julia Lawall

On Thu, Aug 18, 2016 at 09:42:33PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> 
> 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(-)
> 
> -- 
> 2.9.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection
  2016-08-18 19:48   ` [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection SF Markus Elfring
@ 2016-08-19  7:50     ` Daniel Vetter
  0 siblings, 0 replies; 1373+ messages in thread
From: Daniel Vetter @ 2016-08-19  7:50 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, LKML, kernel-janitors,
	Julia Lawall

On Thu, Aug 18, 2016 at 09:48:04PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

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

> ---
>  drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++---------------
>  1 file changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c
> index 3dc0d8f..5b484aa 100644
> --- a/drivers/gpu/drm/savage/savage_state.c
> +++ b/drivers/gpu/drm/savage/savage_state.c
> @@ -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;
>  }
> -- 
> 2.9.3
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (51 preceding siblings ...)
  2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
@ 2016-08-19  9:17 ` SF Markus Elfring
  2016-08-19  9:23   ` [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-19  9:25   ` [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection SF Markus Elfring
  2016-08-19 18:27 ` [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl() SF Markus Elfring
                   ` (42 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19  9:17 UTC (permalink / raw)
  To: linux-media, Laurent Pinchart, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation
  2016-08-19  9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
@ 2016-08-19  9:23   ` SF Markus Elfring
  2016-08-19  9:25   ` [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19  9:23 UTC (permalink / raw)
  To: linux-media, Laurent Pinchart, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/uvc/uvc_v4l2.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index 05eed4b..a7e12fd 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -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;
 		}
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection
  2016-08-19  9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
  2016-08-19  9:23   ` [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-19  9:25   ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19  9:25 UTC (permalink / raw)
  To: linux-media, Laurent Pinchart, Mauro Carvalho Chehab
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/media/usb/uvc/uvc_v4l2.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index a7e12fd..52a2af8 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (52 preceding siblings ...)
  2016-08-19  9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
@ 2016-08-19 18:27 ` SF Markus Elfring
  2016-08-19 18:28   ` [PATCH 1/2] misc/mic/vop: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-19 18:30   ` [PATCH 2/2] misc/mic/vop: Rename jump labels in vop_ioctl() SF Markus Elfring
  2016-08-19 19:21 ` [PATCH] VMCI: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                   ` (41 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 18:27 UTC (permalink / raw)
  To: Ashutosh Dixit, Sudeep Dutt
  Cc: LKML, kernel-janitors, Julia Lawall, Greg Kroah-Hartman

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] misc/mic/vop: Use memdup_user() rather than duplicating its implementation
  2016-08-19 18:27 ` [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl() SF Markus Elfring
@ 2016-08-19 18:28   ` SF Markus Elfring
  2016-08-19 18:30   ` [PATCH 2/2] misc/mic/vop: Rename jump labels in vop_ioctl() SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 18:28 UTC (permalink / raw)
  To: Ashutosh Dixit, Sudeep Dutt
  Cc: LKML, kernel-janitors, Julia Lawall, Greg Kroah-Hartman

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/mic/vop/vop_vringh.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index 88e4523..84c95fe 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -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);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] misc/mic/vop: Rename jump labels in vop_ioctl()
  2016-08-19 18:27 ` [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl() SF Markus Elfring
  2016-08-19 18:28   ` [PATCH 1/2] misc/mic/vop: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-19 18:30   ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 18:30 UTC (permalink / raw)
  To: Ashutosh Dixit, Sudeep Dutt
  Cc: LKML, kernel-janitors, Julia Lawall, Greg Kroah-Hartman

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 Aug 2016 20:02:50 +0200

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/mic/vop/vop_vringh.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/misc/mic/vop/vop_vringh.c b/drivers/misc/mic/vop/vop_vringh.c
index 84c95fe..201a662 100644
--- a/drivers/misc/mic/vop/vop_vringh.c
+++ b/drivers/misc/mic/vop/vop_vringh.c
@@ -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;
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] VMCI: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (53 preceding siblings ...)
  2016-08-19 18:27 ` [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl() SF Markus Elfring
@ 2016-08-19 19:21 ` SF Markus Elfring
  2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
                   ` (40 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 19:21 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/misc/vmw_vmci/vmci_host.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/misc/vmw_vmci/vmci_host.c b/drivers/misc/vmw_vmci/vmci_host.c
index 9ec262a..0a20475 100644
--- a/drivers/misc/vmw_vmci/vmci_host.c
+++ b/drivers/misc/vmw_vmci/vmci_host.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (54 preceding siblings ...)
  2016-08-19 19:21 ` [PATCH] VMCI: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-19 21:07 ` SF Markus Elfring
  2016-08-19 21:10   ` [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-19 21:12   ` [PATCH 2/2] mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user() SF Markus Elfring
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                   ` (39 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 21:07 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Grant Grundler, Jens Axboe, Jon Hunter,
	Mike Christie, Shawn Lin, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation
  2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
@ 2016-08-19 21:10   ` SF Markus Elfring
  2016-08-20  9:25     ` walter harms
  2016-08-19 21:12   ` [PATCH 2/2] mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user() SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 21:10 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Grant Grundler, Jens Axboe, Jon Hunter,
	Mike Christie, Shawn Lin, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/card/block.c | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 48a5dd7..6ce9492 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -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,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user()
  2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
  2016-08-19 21:10   ` [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-19 21:12   ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-19 21:12 UTC (permalink / raw)
  To: linux-mmc, Adrian Hunter, Grant Grundler, Jens Axboe, Jon Hunter,
	Mike Christie, Shawn Lin, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 19 Aug 2016 22:52:50 +0200

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mmc/card/block.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 6ce9492..0d83c56 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (55 preceding siblings ...)
  2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
@ 2016-08-20  6:01 ` SF Markus Elfring
  2016-08-20  9:32   ` walter harms
  2016-08-23  0:05   ` David Miller
  2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
                   ` (38 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20  6:01 UTC (permalink / raw)
  To: linux-rdma, netdev, Leon Romanovsky, Matan Barak
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
index 6388bc0..bb89f04 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
@@ -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,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] tun: Fine-tuning for update_filter()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (56 preceding siblings ...)
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20  7:27 ` SF Markus Elfring
  2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (2 more replies)
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
                   ` (37 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20  7:27 UTC (permalink / raw)
  To: netdev, David S. Miller, Eric Dumazet, Jason Wang,
	Michael S. Tsirkin, Mike Rapoport, Paolo Abeni,
	Soheil Hassas Yeganeh
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation
  2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
@ 2016-08-20  7:34   ` SF Markus Elfring
  2016-08-20 11:47     ` Shmulik Ladkani
  2016-08-22  1:43     ` Michael S. Tsirkin
  2016-08-20  7:37   ` [PATCH 2/2] tun: Rename a jump label in update_filter() SF Markus Elfring
  2016-08-21  2:11   ` [PATCH 0/2] tun: Fine-tuning for update_filter() David Miller
  2 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20  7:34 UTC (permalink / raw)
  To: netdev, David S. Miller, Eric Dumazet, Jason Wang,
	Michael S. Tsirkin, Mike Rapoport, Paolo Abeni,
	Soheil Hassas Yeganeh
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/tun.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 9c8b5bc..a1aeccb 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] tun: Rename a jump label in update_filter()
  2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
  2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20  7:37   ` SF Markus Elfring
  2016-08-22  1:41     ` Michael S. Tsirkin
  2016-08-21  2:11   ` [PATCH 0/2] tun: Fine-tuning for update_filter() David Miller
  2 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20  7:37 UTC (permalink / raw)
  To: netdev, David S. Miller, Eric Dumazet, Jason Wang,
	Michael S. Tsirkin, Mike Rapoport, Paolo Abeni,
	Soheil Hassas Yeganeh
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 09:00:34 +0200

Adjust a jump target according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/tun.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index a1aeccb..e249428 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation
  2016-08-19 21:10   ` [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20  9:25     ` walter harms
  0 siblings, 0 replies; 1373+ messages in thread
From: walter harms @ 2016-08-20  9:25 UTC (permalink / raw)
  Cc: linux-mmc, Adrian Hunter, Grant Grundler, Jens Axboe, Jon Hunter,
	Mike Christie, Shawn Lin, Ulf Hansson, LKML, kernel-janitors,
	Julia Lawall



Am 19.08.2016 23:10, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/mmc/card/block.c | 26 +++++++++-----------------
>  1 file changed, 9 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 48a5dd7..6ce9492 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -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;
>  }


This looks strange, returning a freed pointer is a bad idea. I suggest a
idata=NULL after kfree().

re,
 wh

>  
>  static int mmc_blk_ioctl_copy_to_user(struct mmc_ioc_cmd __user *ic_ptr,

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20  9:32   ` walter harms
  2016-08-23  0:05   ` David Miller
  1 sibling, 0 replies; 1373+ messages in thread
From: walter harms @ 2016-08-20  9:32 UTC (permalink / raw)
  Cc: linux-rdma, netdev, Leon Romanovsky, Matan Barak, LKML,
	kernel-janitors, Julia Lawall



Am 20.08.2016 08:01, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> index 6388bc0..bb89f04 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c
> @@ -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;
>  

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

>  	return count;
> -
> -out:
> -	kfree(ptr);
> -	return err;
>  }
>  
>  static ssize_t data_read(struct file *filp, char __user *buf, size_t count,

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation
  2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20 11:47     ` Shmulik Ladkani
  2016-08-22  1:43     ` Michael S. Tsirkin
  1 sibling, 0 replies; 1373+ messages in thread
From: Shmulik Ladkani @ 2016-08-20 11:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, David S. Miller, Eric Dumazet, Jason Wang,
	Michael S. Tsirkin, Mike Rapoport, Paolo Abeni,
	Soheil Hassas Yeganeh, LKML, kernel-janitors, Julia Lawall

Hi,

On Sat, 20 Aug 2016 09:34:56 +0200 SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Shmulik Ladkani <shmulik.ladkani@gmail.com>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/3] hostap: Fine-tuning for a few functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (57 preceding siblings ...)
  2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
@ 2016-08-20 16:43 ` SF Markus Elfring
  2016-08-20 16:45   ` [PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (3 more replies)
  2016-08-20 17:32 ` [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                   ` (36 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20 16:43 UTC (permalink / raw)
  To: linux-wireless, netdev, Jouni Malinen, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
@ 2016-08-20 16:45   ` SF Markus Elfring
  2016-08-20 16:46   ` [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20 16:45 UTC (permalink / raw)
  To: linux-wireless, netdev, Jouni Malinen, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 .../net/wireless/intersil/hostap/hostap_ioctl.c    | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 3e5fa78..4e271f9 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -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:
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
  2016-08-20 16:45   ` [PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-20 16:46   ` SF Markus Elfring
  2016-08-21  1:45     ` Julian Calaby
  2016-08-20 16:48   ` [PATCH 3/3] hostap: Delete unnecessary initialisations for the variable "ret" SF Markus Elfring
  2016-08-20 19:26   ` [PATCH 0/3] hostap: Fine-tuning for a few functions Arend van Spriel
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20 16:46 UTC (permalink / raw)
  To: linux-wireless, netdev, Jouni Malinen, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 18:21:29 +0200

Remove a jump label which is unneeded in this function at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 4e271f9..5942917 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/3] hostap: Delete unnecessary initialisations for the variable "ret"
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
  2016-08-20 16:45   ` [PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-20 16:46   ` [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd() SF Markus Elfring
@ 2016-08-20 16:48   ` SF Markus Elfring
  2016-08-20 19:26   ` [PATCH 0/3] hostap: Fine-tuning for a few functions Arend van Spriel
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20 16:48 UTC (permalink / raw)
  To: linux-wireless, netdev, Jouni Malinen, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
index 5942917..c37b0bb 100644
--- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
+++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
@@ -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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (58 preceding siblings ...)
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
@ 2016-08-20 17:32 ` SF Markus Elfring
  2016-08-22  6:24   ` Martin Schwidefsky
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
                   ` (35 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-20 17:32 UTC (permalink / raw)
  To: linux-s390, Heiko Carstens, Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/s390/char/tape_3590.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/s390/char/tape_3590.c b/drivers/s390/char/tape_3590.c
index d3d1936..e352047 100644
--- a/drivers/s390/char/tape_3590.c
+++ b/drivers/s390/char/tape_3590.c
@@ -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;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] hostap: Fine-tuning for a few functions
  2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-20 16:48   ` [PATCH 3/3] hostap: Delete unnecessary initialisations for the variable "ret" SF Markus Elfring
@ 2016-08-20 19:26   ` Arend van Spriel
  2016-08-22 15:49     ` Kalle Valo
  3 siblings, 1 reply; 1373+ messages in thread
From: Arend van Spriel @ 2016-08-20 19:26 UTC (permalink / raw)
  To: SF Markus Elfring, linux-wireless, netdev, Jouni Malinen, Kalle Valo
  Cc: LKML, kernel-janitors, Julia Lawall

On 20-08-16 18:43, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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

> 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(-)
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd()
  2016-08-20 16:46   ` [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd() SF Markus Elfring
@ 2016-08-21  1:45     ` Julian Calaby
  0 siblings, 0 replies; 1373+ messages in thread
From: Julian Calaby @ 2016-08-21  1:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-wireless, netdev, Jouni Malinen, Kalle Valo, LKML,
	kernel-janitors, Julia Lawall

Hi Marcus,

On Sun, Aug 21, 2016 at 2:46 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 20 Aug 2016 18:21:29 +0200
>
> Remove a jump label which is unneeded in this function at the end.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/net/wireless/intersil/hostap/hostap_ioctl.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> index 4e271f9..5942917 100644
> --- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> +++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c
> @@ -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:

Does this change make any difference to the compiled code?

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] tun: Fine-tuning for update_filter()
  2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
  2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-20  7:37   ` [PATCH 2/2] tun: Rename a jump label in update_filter() SF Markus Elfring
@ 2016-08-21  2:11   ` David Miller
  2 siblings, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-08-21  2:11 UTC (permalink / raw)
  To: elfring
  Cc: netdev, edumazet, jasowang, mst, rppt, pabeni, soheil,
	linux-kernel, kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 09:27:39 +0200

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

Series applied.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] aacraid: Fine-tuning for a few functions
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (59 preceding siblings ...)
  2016-08-20 17:32 ` [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21  7:14 ` SF Markus Elfring
  2016-08-21  7:19   ` [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (6 more replies)
  2016-08-21  8:48 ` [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                   ` (34 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:14 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
@ 2016-08-21  7:19   ` SF Markus Elfring
  2016-08-22 18:00     ` David Carroll
  2016-08-21  7:20   ` [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb() after error detection SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:19 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 5648b71..1af3084 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -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;
 	}
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb() after error detection
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
  2016-08-21  7:19   ` [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21  7:20   ` SF Markus Elfring
  2016-08-21  7:22   ` [PATCH 3/7] aacraid: Delete unnecessary initialisations in aac_send_raw_srb() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:20 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

>From e8187662ee30aab709a260c72fb86c51673f8e0d Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 49 ++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 25 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 1af3084..6dcdf91 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -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]);
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] aacraid: Delete unnecessary initialisations in aac_send_raw_srb()
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
  2016-08-21  7:19   ` [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-21  7:20   ` [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb() after error detection SF Markus Elfring
@ 2016-08-21  7:22   ` SF Markus Elfring
  2016-08-21  7:24   ` [PATCH 4/7] aacraid: Delete unnecessary braces SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:22 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 21:25:20 +0200

Six local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 6dcdf91..49a664f 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -476,20 +476,20 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 {
 	struct fib* srbfib;
 	int status;
-	struct aac_srb *srbcmd = NULL;
-	struct user_aac_srb *user_srbcmd = NULL;
+	struct aac_srb *srbcmd;
+	struct user_aac_srb *user_srbcmd;
 	struct user_aac_srb __user *user_srb = arg;
 	struct aac_srb_reply __user *user_reply;
 	struct aac_srb_reply* reply;
-	u32 fibsize = 0;
-	u32 flags = 0;
+	u32 fibsize;
+	u32 flags;
 	s32 rcode = 0;
 	u32 data_dir;
 	void __user *sg_user[32];
 	void *sg_list[32];
 	u32 sg_indx = 0;
-	u32 byte_count = 0;
-	u32 actual_fibsize64, actual_fibsize = 0;
+	u32 byte_count;
+	u32 actual_fibsize64, actual_fibsize;
 	int i;
 
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] aacraid: Delete unnecessary braces
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-21  7:22   ` [PATCH 3/7] aacraid: Delete unnecessary initialisations in aac_send_raw_srb() SF Markus Elfring
@ 2016-08-21  7:24   ` SF Markus Elfring
  2016-08-21  7:25   ` [PATCH 5/7] aacraid: Add spaces after control flow keywords SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:24 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 07:07:08 +0200

Do not use curly brackets at some source code places
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 49a664f..9f4ddb0 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -66,13 +66,11 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
 	unsigned int size, osize;
 	int retval;
 
-	if (dev->in_reset) {
+	if (dev->in_reset)
 		return -EBUSY;
-	}
 	fibptr = aac_fib_alloc(dev);
-	if(fibptr == NULL) {
+	if (!fibptr)
 		return -ENOMEM;
-	}
 
 	kfib = fibptr->hw_fib_va;
 	/*
@@ -138,9 +136,8 @@ static int ioctl_send_fib(struct aac_dev * dev, void __user *arg)
 		retval = aac_fib_send(le16_to_cpu(kfib->header.Command), fibptr,
 				le16_to_cpu(kfib->header.Size) , FsaNormal,
 				1, 1, NULL, NULL);
-		if (retval) {
+		if (retval)
 			goto cleanup;
-		}
 		if (aac_fib_complete(fibptr) != 0) {
 			retval = -EINVAL;
 			goto cleanup;
@@ -228,12 +225,10 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
 		}
 		list_add_tail(&fibctx->next, &dev->fib_list);
 		spin_unlock_irqrestore(&dev->fib_lock, flags);
-		if (copy_to_user(arg, &fibctx->unique,
-						sizeof(fibctx->unique))) {
+		if (copy_to_user(arg, &fibctx->unique, sizeof(fibctx->unique)))
 			status = -EFAULT;
-		} else {
+		else
 			status = 0;
-		}
 	}
 	return status;
 }
@@ -820,9 +815,8 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 free_user_srbcmd:
 	kfree(user_srbcmd);
 free_sg_list:
-	for(i=0; i <= sg_indx; i++){
+	for (i = 0; i <= sg_indx; i++)
 		kfree(sg_list[i]);
-	}
 	if (rcode != -ERESTARTSYS) {
 		aac_fib_complete(srbfib);
 		aac_fib_free(srbfib);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] aacraid: Add spaces after control flow keywords
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-21  7:24   ` [PATCH 4/7] aacraid: Delete unnecessary braces SF Markus Elfring
@ 2016-08-21  7:25   ` SF Markus Elfring
  2016-08-21  7:27   ` [PATCH 6/7] aacraid: Improve determination of a few sizes SF Markus Elfring
  2016-08-21  7:29   ` [PATCH 7/7] aacraid: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:25 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 07:10:43 +0200

Keywords which belong to the category "control flow" in the C programming
language should be followed by a space character according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 41 ++++++++++++++++++++++++-----------------
 1 file changed, 24 insertions(+), 17 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index 9f4ddb0..cda03f0 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -251,7 +251,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
 	struct list_head * entry;
 	unsigned long flags;
 
-	if(copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
+	if (copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
 		return -EFAULT;
 	/*
 	 *	Verify that the HANDLE passed in was a valid AdapterFibContext
@@ -280,7 +280,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
 		return -EINVAL;
 	}
 
-	if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
+	if ((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
 		 (fibctx->size != sizeof(struct aac_fib_context))) {
 		spin_unlock_irqrestore(&dev->fib_lock, flags);
 		dprintk ((KERN_INFO "Fib Context corrupt?\n"));
@@ -327,7 +327,7 @@ return_fib:
 			ssleep(1);
 		}
 		if (f.wait) {
-			if(down_interruptible(&fibctx->wait_sem) < 0) {
+			if (down_interruptible(&fibctx->wait_sem) < 0) {
 				status = -ERESTARTSYS;
 			} else {
 				/* Lock again and retry */
@@ -404,7 +404,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
 	entry = dev->fib_list.next;
 	fibctx = NULL;
 
-	while(entry != &dev->fib_list) {
+	while (entry != &dev->fib_list) {
 		fibctx = list_entry(entry, struct aac_fib_context, next);
 		/*
 		 *	Extract the fibctx from the input parameters
@@ -418,7 +418,7 @@ static int close_getadapter_fib(struct aac_dev * dev, void __user *arg)
 	if (!fibctx)
 		return 0; /* Already gone */
 
-	if((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
+	if ((fibctx->type != FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT) ||
 		 (fibctx->size != sizeof(struct aac_fib_context)))
 		return -EINVAL;
 	spin_lock_irqsave(&dev->fib_lock, flags);
@@ -509,7 +509,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	srbcmd = (struct aac_srb*) fib_data(srbfib);
 
 	memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
-	if(copy_from_user(&fibsize, &user_srb->count,sizeof(u32))){
+	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 free_sg_list;
@@ -605,7 +605,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(upsg->sg[i].count,GFP_KERNEL|__GFP_DMA);
-				if(!p) {
+				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;
@@ -618,7 +618,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				sg_indx = i;
 
 				if (flags & SRB_DataOut) {
-					if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
+					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 free_user_srbcmd;
@@ -657,7 +659,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
-				if(!p) {
+				if (!p) {
 					dprintk((KERN_DEBUG "aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
 					  usg->sg[i].count,i,usg->count));
 					kfree(usg);
@@ -669,7 +671,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				sg_indx = i;
 
 				if (flags & SRB_DataOut) {
-					if(copy_from_user(p,sg_user[i],upsg->sg[i].count)){
+					if (copy_from_user(p,
+							   sg_user[i],
+							   upsg->sg[i].count)) {
 						kfree (usg);
 						dprintk((KERN_DEBUG"aacraid: Could not copy sg data from user\n"));
 						rcode = -EFAULT;
@@ -710,7 +714,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				}
 				/* Does this really need to be GFP_DMA? */
 				p = kmalloc(usg->sg[i].count,GFP_KERNEL|__GFP_DMA);
-				if(!p) {
+				if (!p) {
 					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;
@@ -723,7 +727,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				sg_indx = i;
 
 				if (flags & SRB_DataOut) {
-					if(copy_from_user(p,sg_user[i],usg->sg[i].count)){
+					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 free_user_srbcmd;
@@ -759,8 +765,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 				sg_indx = i;
 
 				if (flags & SRB_DataOut) {
-					if(copy_from_user(p, sg_user[i],
-							upsg->sg[i].count)) {
+					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 free_user_srbcmd;
@@ -793,12 +800,12 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	}
 
 	if (flags & SRB_DataIn) {
-		for(i = 0 ; i <= sg_indx; i++){
+		for (i = 0 ; i <= sg_indx; i++) {
 			byte_count = le32_to_cpu(
 			  (dev->adapter_info.options & AAC_OPT_SGMAP_HOST64)
 			      ? ((struct sgmap64*)&srbcmd->sg)->sg[i].count
 			      : srbcmd->sg.sg[i].count);
-			if(copy_to_user(sg_user[i], sg_list[i], byte_count)){
+			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 free_user_srbcmd;
@@ -808,7 +815,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	}
 
 	reply = (struct aac_srb_reply *) fib_data(srbfib);
-	if(copy_to_user(user_reply,reply,sizeof(struct aac_srb_reply))){
+	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;
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] aacraid: Improve determination of a few sizes
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-08-21  7:25   ` [PATCH 5/7] aacraid: Add spaces after control flow keywords SF Markus Elfring
@ 2016-08-21  7:27   ` SF Markus Elfring
  2016-08-21  7:29   ` [PATCH 7/7] aacraid: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:27 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 08:04:48 +0200

Replace the specification of data structures by references for variables
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index cda03f0..d2029db 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -177,7 +177,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
 	struct aac_fib_context * fibctx;
 	int status;
 
-	fibctx = kmalloc(sizeof(struct aac_fib_context), GFP_KERNEL);
+	fibctx = kmalloc(sizeof(*fibctx), GFP_KERNEL);
 	if (fibctx == NULL) {
 		status = -ENOMEM;
 	} else {
@@ -186,7 +186,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg)
 		struct aac_fib_context * context;
 
 		fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT;
-		fibctx->size = sizeof(struct aac_fib_context);
+		fibctx->size = sizeof(*fibctx);
 		/*
 		 *	Yes yes, I know this could be an index, but we have a
 		 * better guarantee of uniqueness for the locked loop below.
@@ -251,7 +251,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg)
 	struct list_head * entry;
 	unsigned long flags;
 
-	if (copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl)))
+	if (copy_from_user(&f, arg, sizeof(f)))
 		return -EFAULT;
 	/*
 	 *	Verify that the HANDLE passed in was a valid AdapterFibContext
@@ -509,7 +509,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	srbcmd = (struct aac_srb*) fib_data(srbfib);
 
 	memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */
-	if (copy_from_user(&fibsize, &user_srb->count, sizeof(u32))) {
+	if (copy_from_user(&fibsize, &user_srb->count, sizeof(fibsize))) {
 		dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n"));
 		rcode = -EFAULT;
 		goto free_sg_list;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] aacraid: Apply another recommendation from "checkpatch.pl"
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-08-21  7:27   ` [PATCH 6/7] aacraid: Improve determination of a few sizes SF Markus Elfring
@ 2016-08-21  7:29   ` SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  7:29 UTC (permalink / raw)
  To: linux-scsi, aacraid, James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 08:23:25 +0200

The script "checkpatch.pl" can point out that assignments should usually
not be performed within condition checks.
Thus move the assignment for the variable "srbfib" to a separate statement.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/aacraid/commctrl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index d2029db..7e6c76d 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -499,9 +499,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
 	/*
 	 *	Allocate and initialize a Fib then setup a SRB command
 	 */
-	if (!(srbfib = aac_fib_alloc(dev))) {
+	srbfib = aac_fib_alloc(dev);
+	if (!srbfib)
 		return -ENOMEM;
-	}
 	aac_fib_init(srbfib);
 	/* raw_srb FIB is not FastResponseCapable */
 	srbfib->hw_fib_va->header.XferState &= ~cpu_to_le32(FastResponseCapable);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (60 preceding siblings ...)
  2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
@ 2016-08-21  8:48 ` SF Markus Elfring
  2016-08-22  9:31   ` Sumit Saxena
  2016-08-24  2:47   ` Martin K. Petersen
  2016-08-21  9:45 ` [PATCH] staging/lustre/llite: " SF Markus Elfring
                   ` (33 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  8:48 UTC (permalink / raw)
  To: linux-scsi, megaraidlinux.pdl, James E. J. Bottomley,
	Kashyap Desai, Martin K. Petersen, Sumit Saxena, Uday Lingala
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 10:39:04 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index c1ed25a..9a2fe4e 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -6711,14 +6711,9 @@ static int megasas_mgmt_ioctl_fw(struct file *file, unsigned long arg)
 	unsigned long flags;
 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
 
-	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
-	if (!ioc)
-		return -ENOMEM;
-
-	if (copy_from_user(ioc, user_ioc, sizeof(*ioc))) {
-		error = -EFAULT;
-		goto out_kfree_ioc;
-	}
+	ioc = memdup_user(user_ioc, sizeof(*ioc));
+	if (IS_ERR(ioc))
+		return PTR_ERR(ioc);
 
 	instance = megasas_lookup_instance(ioc->host_no);
 	if (!instance) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (61 preceding siblings ...)
  2016-08-21  8:48 ` [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21  9:45 ` SF Markus Elfring
  2016-08-21  9:59   ` Christophe JAILLET
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
                   ` (32 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21  9:45 UTC (permalink / raw)
  To: lustre-devel, devel, Andreas Dilger, Fan Yong,
	Greg Kroah-Hartman, James Simmons, Oleg Drokin, wang di
  Cc: LKML, kernel-janitors, Julia Lawall, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 11:30:57 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index 031c9e4..8b70e42 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -1676,14 +1676,9 @@ out_poll:
 	case LL_IOC_QUOTACTL: {
 		struct if_quotactl *qctl;
 
-		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
-		if (!qctl)
-			return -ENOMEM;
-
-		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
-			rc = -EFAULT;
-			goto out_quotactl;
-		}
+		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
+		if (IS_ERR(qctl))
+			return PTR_ERR(qctl);
 
 		rc = quotactl_ioctl(sbi, qctl);
 
@@ -1691,7 +1686,6 @@ out_poll:
 					    sizeof(*qctl)))
 			rc = -EFAULT;
 
-out_quotactl:
 		kfree(qctl);
 		return rc;
 	}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2016-08-21  9:45 ` [PATCH] staging/lustre/llite: " SF Markus Elfring
@ 2016-08-21  9:59   ` Christophe JAILLET
  2016-08-21 10:31     ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: Christophe JAILLET @ 2016-08-21  9:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: lustre-devel, kernel-janitors, kernel-janitors, linux-kernel

Le 21/08/2016 à 11:45, SF Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 11:30:57 +0200
>
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
>   1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
> index 031c9e4..8b70e42 100644
> --- a/drivers/staging/lustre/lustre/llite/dir.c
> +++ b/drivers/staging/lustre/lustre/llite/dir.c
> @@ -1676,14 +1676,9 @@ out_poll:
>   	case LL_IOC_QUOTACTL: {
>   		struct if_quotactl *qctl;
>   
> -		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
Same as previously reported in another patch, GFP_NOFS has not the same 
meaning than GPF_KERNEL.
So your proposed clean-up is not 100% equivalent.

Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code?

Maybe, the coccinelle check should be tweak to only spot "kzalloc(..., 
GFP_KERNEL)" allocation?

> -		if (!qctl)
> -			return -ENOMEM;
> -
> -		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
> -			rc = -EFAULT;
> -			goto out_quotactl;
> -		}
> +		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
> +		if (IS_ERR(qctl))
> +			return PTR_ERR(qctl);
>   
>   		rc = quotactl_ioctl(sbi, qctl);
>   
> @@ -1691,7 +1686,6 @@ out_poll:
>   					    sizeof(*qctl)))
>   			rc = -EFAULT;
>   
> -out_quotactl:
>   		kfree(qctl);
>   		return rc;
>   	}



---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2016-08-21  9:59   ` Christophe JAILLET
@ 2016-08-21 10:31     ` Julia Lawall
  2016-08-21 10:55       ` Vaishali Thakkar
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-21 10:31 UTC (permalink / raw)
  To: Christophe JAILLET; +Cc: kernel-janitors, linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2780 bytes --]



On Sun, 21 Aug 2016, Christophe JAILLET wrote:

> Le 21/08/2016 à 11:45, SF Markus Elfring a écrit :
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 21 Aug 2016 11:30:57 +0200
> >
> > Reuse existing functionality from memdup_user() instead of keeping
> > duplicate source code.
> >
> > This issue was detected by using the Coccinelle software.
> >
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >   drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
> >   1 file changed, 3 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/staging/lustre/lustre/llite/dir.c
> > b/drivers/staging/lustre/lustre/llite/dir.c
> > index 031c9e4..8b70e42 100644
> > --- a/drivers/staging/lustre/lustre/llite/dir.c
> > +++ b/drivers/staging/lustre/lustre/llite/dir.c
> > @@ -1676,14 +1676,9 @@ out_poll:
> >   	case LL_IOC_QUOTACTL: {
> >   		struct if_quotactl *qctl;
> >   -		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
> Same as previously reported in another patch, GFP_NOFS has not the same
> meaning than GPF_KERNEL.
> So your proposed clean-up is not 100% equivalent.
>
> Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code?
>
> Maybe, the coccinelle check should be tweak to only spot "kzalloc(...,
> GFP_KERNEL)" allocation?

To my dim recollection, GFP_NOFS is not actually allowed in a place where
copy_from_user is being used.  copy_from_user can block due to page
faults, and GFP_NOFS is used when a certain kind of blocking is not
allowed.  So if the code really needs GFP_NOFS, then something else is
wrong.

The semantic patch intentionally does not specify GFP_KERNEL for this
reason, ie so that these issues will come up and be discussed.  On the
ther hand I agree about the GFP_DMA case, since that doesn't relate to
blocking, as far as I know.  The semantic patch should be updated to not
make/propose the change in that case.

julia

>
> > -		if (!qctl)
> > -			return -ENOMEM;
> > -
> > -		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
> > -			rc = -EFAULT;
> > -			goto out_quotactl;
> > -		}
> > +		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
> > +		if (IS_ERR(qctl))
> > +			return PTR_ERR(qctl);
> >     		rc = quotactl_ioctl(sbi, qctl);
> >   @@ -1691,7 +1686,6 @@ out_poll:
> >   					    sizeof(*qctl)))
> >   			rc = -EFAULT;
> >   -out_quotactl:
> >   		kfree(qctl);
> >   		return rc;
> >   	}
>
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2016-08-21 10:31     ` Julia Lawall
@ 2016-08-21 10:55       ` Vaishali Thakkar
  2016-08-21 11:01         ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: Vaishali Thakkar @ 2016-08-21 10:55 UTC (permalink / raw)
  To: Julia Lawall, Christophe JAILLET; +Cc: kernel-janitors, linux-kernel



On Sunday 21 August 2016 04:01 PM, Julia Lawall wrote:
> 
> 
> On Sun, 21 Aug 2016, Christophe JAILLET wrote:
> 
>> Le 21/08/2016 à 11:45, SF Markus Elfring a écrit :
>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>> Date: Sun, 21 Aug 2016 11:30:57 +0200
>>>
>>> Reuse existing functionality from memdup_user() instead of keeping
>>> duplicate source code.
>>>
>>> This issue was detected by using the Coccinelle software.
>>>
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>> ---
>>>   drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
>>>   1 file changed, 3 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/staging/lustre/lustre/llite/dir.c
>>> b/drivers/staging/lustre/lustre/llite/dir.c
>>> index 031c9e4..8b70e42 100644
>>> --- a/drivers/staging/lustre/lustre/llite/dir.c
>>> +++ b/drivers/staging/lustre/lustre/llite/dir.c
>>> @@ -1676,14 +1676,9 @@ out_poll:
>>>   	case LL_IOC_QUOTACTL: {
>>>   		struct if_quotactl *qctl;
>>>   -		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
>> Same as previously reported in another patch, GFP_NOFS has not the same
>> meaning than GPF_KERNEL.
>> So your proposed clean-up is not 100% equivalent.
>>
>> Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code?
>>
>> Maybe, the coccinelle check should be tweak to only spot "kzalloc(...,
>> GFP_KERNEL)" allocation?
> 
> To my dim recollection, GFP_NOFS is not actually allowed in a place where
> copy_from_user is being used.  copy_from_user can block due to page
> faults, and GFP_NOFS is used when a certain kind of blocking is not
> allowed.  So if the code really needs GFP_NOFS, then something else is
> wrong.
> 
> The semantic patch intentionally does not specify GFP_KERNEL for this
> reason, ie so that these issues will come up and be discussed.  On the
> ther hand I agree about the GFP_DMA case, since that doesn't relate to
> blocking, as far as I know.  The semantic patch should be updated to not
> make/propose the change in that case.

I think semantic patch should be updated for all possible flags except
GFP_NOFS and GFP_ATOMIC. Because only using these 2 flags with
copy_from_user can cause blocking.

> julia
> 
>>
>>> -		if (!qctl)
>>> -			return -ENOMEM;
>>> -
>>> -		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
>>> -			rc = -EFAULT;
>>> -			goto out_quotactl;
>>> -		}
>>> +		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
>>> +		if (IS_ERR(qctl))
>>> +			return PTR_ERR(qctl);
>>>     		rc = quotactl_ioctl(sbi, qctl);
>>>   @@ -1691,7 +1686,6 @@ out_poll:
>>>   					    sizeof(*qctl)))
>>>   			rc = -EFAULT;
>>>   -out_quotactl:
>>>   		kfree(qctl);
>>>   		return rc;
>>>   	}
>>
>>
>>
>> ---
>> L'absence de virus dans ce courrier électronique a été vérifiée par le
>> logiciel antivirus Avast.
>> https://www.avast.com/antivirus
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
> 

-- 
Vaishali

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2016-08-21 10:55       ` Vaishali Thakkar
@ 2016-08-21 11:01         ` Julia Lawall
  2016-08-21 12:09           ` Vaishali Thakkar
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-21 11:01 UTC (permalink / raw)
  To: Vaishali Thakkar
  Cc: Julia Lawall, Christophe JAILLET, kernel-janitors, linux-kernel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 3608 bytes --]



On Sun, 21 Aug 2016, Vaishali Thakkar wrote:

>
>
> On Sunday 21 August 2016 04:01 PM, Julia Lawall wrote:
> >
> >
> > On Sun, 21 Aug 2016, Christophe JAILLET wrote:
> >
> >> Le 21/08/2016 à 11:45, SF Markus Elfring a écrit :
> >>> From: Markus Elfring <elfring@users.sourceforge.net>
> >>> Date: Sun, 21 Aug 2016 11:30:57 +0200
> >>>
> >>> Reuse existing functionality from memdup_user() instead of keeping
> >>> duplicate source code.
> >>>
> >>> This issue was detected by using the Coccinelle software.
> >>>
> >>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >>> ---
> >>>   drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
> >>>   1 file changed, 3 insertions(+), 9 deletions(-)
> >>>
> >>> diff --git a/drivers/staging/lustre/lustre/llite/dir.c
> >>> b/drivers/staging/lustre/lustre/llite/dir.c
> >>> index 031c9e4..8b70e42 100644
> >>> --- a/drivers/staging/lustre/lustre/llite/dir.c
> >>> +++ b/drivers/staging/lustre/lustre/llite/dir.c
> >>> @@ -1676,14 +1676,9 @@ out_poll:
> >>>   	case LL_IOC_QUOTACTL: {
> >>>   		struct if_quotactl *qctl;
> >>>   -		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
> >> Same as previously reported in another patch, GFP_NOFS has not the same
> >> meaning than GPF_KERNEL.
> >> So your proposed clean-up is not 100% equivalent.
> >>
> >> Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code?
> >>
> >> Maybe, the coccinelle check should be tweak to only spot "kzalloc(...,
> >> GFP_KERNEL)" allocation?
> >
> > To my dim recollection, GFP_NOFS is not actually allowed in a place where
> > copy_from_user is being used.  copy_from_user can block due to page
> > faults, and GFP_NOFS is used when a certain kind of blocking is not
> > allowed.  So if the code really needs GFP_NOFS, then something else is
> > wrong.
> >
> > The semantic patch intentionally does not specify GFP_KERNEL for this
> > reason, ie so that these issues will come up and be discussed.  On the
> > ther hand I agree about the GFP_DMA case, since that doesn't relate to
> > blocking, as far as I know.  The semantic patch should be updated to not
> > make/propose the change in that case.
>
> I think semantic patch should be updated for all possible flags except
> GFP_NOFS and GFP_ATOMIC. Because only using these 2 flags with
> copy_from_user can cause blocking.

They don't cause blocking, but rather prevent it.

But people could use variables as well.  Since other things are rare, it
seems like it could be better to only block reports on what is known to
be safe, and not to block reports on unknown things.  A warning could be
given in some cases.

julia

>
> > julia
> >
> >>
> >>> -		if (!qctl)
> >>> -			return -ENOMEM;
> >>> -
> >>> -		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
> >>> -			rc = -EFAULT;
> >>> -			goto out_quotactl;
> >>> -		}
> >>> +		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
> >>> +		if (IS_ERR(qctl))
> >>> +			return PTR_ERR(qctl);
> >>>     		rc = quotactl_ioctl(sbi, qctl);
> >>>   @@ -1691,7 +1686,6 @@ out_poll:
> >>>   					    sizeof(*qctl)))
> >>>   			rc = -EFAULT;
> >>>   -out_quotactl:
> >>>   		kfree(qctl);
> >>>   		return rc;
> >>>   	}
> >>
> >>
> >>
> >> ---
> >> L'absence de virus dans ce courrier électronique a été vérifiée par le
> >> logiciel antivirus Avast.
> >> https://www.avast.com/antivirus
> >>
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >>
> >
>
> --
> Vaishali
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation
  2016-08-21 11:01         ` Julia Lawall
@ 2016-08-21 12:09           ` Vaishali Thakkar
  0 siblings, 0 replies; 1373+ messages in thread
From: Vaishali Thakkar @ 2016-08-21 12:09 UTC (permalink / raw)
  To: Julia Lawall; +Cc: Christophe JAILLET, kernel-janitors, linux-kernel



On Sunday 21 August 2016 04:31 PM, Julia Lawall wrote:
> 
> 
> On Sun, 21 Aug 2016, Vaishali Thakkar wrote:
> 
>>
>>
>> On Sunday 21 August 2016 04:01 PM, Julia Lawall wrote:
>>>
>>>
>>> On Sun, 21 Aug 2016, Christophe JAILLET wrote:
>>>
>>>> Le 21/08/2016 à 11:45, SF Markus Elfring a écrit :
>>>>> From: Markus Elfring <elfring@users.sourceforge.net>
>>>>> Date: Sun, 21 Aug 2016 11:30:57 +0200
>>>>>
>>>>> Reuse existing functionality from memdup_user() instead of keeping
>>>>> duplicate source code.
>>>>>
>>>>> This issue was detected by using the Coccinelle software.
>>>>>
>>>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>>>> ---
>>>>>   drivers/staging/lustre/lustre/llite/dir.c | 12 +++---------
>>>>>   1 file changed, 3 insertions(+), 9 deletions(-)
>>>>>
>>>>> diff --git a/drivers/staging/lustre/lustre/llite/dir.c
>>>>> b/drivers/staging/lustre/lustre/llite/dir.c
>>>>> index 031c9e4..8b70e42 100644
>>>>> --- a/drivers/staging/lustre/lustre/llite/dir.c
>>>>> +++ b/drivers/staging/lustre/lustre/llite/dir.c
>>>>> @@ -1676,14 +1676,9 @@ out_poll:
>>>>>   	case LL_IOC_QUOTACTL: {
>>>>>   		struct if_quotactl *qctl;
>>>>>   -		qctl = kzalloc(sizeof(*qctl), GFP_NOFS);
>>>> Same as previously reported in another patch, GFP_NOFS has not the same
>>>> meaning than GPF_KERNEL.
>>>> So your proposed clean-up is not 100% equivalent.
>>>>
>>>> Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code?
>>>>
>>>> Maybe, the coccinelle check should be tweak to only spot "kzalloc(...,
>>>> GFP_KERNEL)" allocation?
>>>
>>> To my dim recollection, GFP_NOFS is not actually allowed in a place where
>>> copy_from_user is being used.  copy_from_user can block due to page
>>> faults, and GFP_NOFS is used when a certain kind of blocking is not
>>> allowed.  So if the code really needs GFP_NOFS, then something else is
>>> wrong.
>>>
>>> The semantic patch intentionally does not specify GFP_KERNEL for this
>>> reason, ie so that these issues will come up and be discussed.  On the
>>> ther hand I agree about the GFP_DMA case, since that doesn't relate to
>>> blocking, as far as I know.  The semantic patch should be updated to not
>>> make/propose the change in that case.
>>
>> I think semantic patch should be updated for all possible flags except
>> GFP_NOFS and GFP_ATOMIC. Because only using these 2 flags with
>> copy_from_user can cause blocking.
> 
> They don't cause blocking, but rather prevent it.

Yes, sorry. I meant blocking functions which may sleep in between.

> But people could use variables as well.  Since other things are rare, it
> seems like it could be better to only block reports on what is known to
> be safe, and not to block reports on unknown things.  A warning could be
> given in some cases.

Sounds reasonable. Warning will work I guess.

> julia
> 
>>
>>> julia
>>>
>>>>
>>>>> -		if (!qctl)
>>>>> -			return -ENOMEM;
>>>>> -
>>>>> -		if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) {
>>>>> -			rc = -EFAULT;
>>>>> -			goto out_quotactl;
>>>>> -		}
>>>>> +		qctl = memdup_user((void __user *)arg, sizeof(*qctl));
>>>>> +		if (IS_ERR(qctl))
>>>>> +			return PTR_ERR(qctl);
>>>>>     		rc = quotactl_ioctl(sbi, qctl);
>>>>>   @@ -1691,7 +1686,6 @@ out_poll:
>>>>>   					    sizeof(*qctl)))
>>>>>   			rc = -EFAULT;
>>>>>   -out_quotactl:
>>>>>   		kfree(qctl);
>>>>>   		return rc;
>>>>>   	}
>>>>
>>>>
>>>>
>>>> ---
>>>> L'absence de virus dans ce courrier électronique a été vérifiée par le
>>>> logiciel antivirus Avast.
>>>> https://www.avast.com/antivirus
>>>>
>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>>
>>>
>>
>> --
>> Vaishali
>>
> 

-- 
Vaishali

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (62 preceding siblings ...)
  2016-08-21  9:45 ` [PATCH] staging/lustre/llite: " SF Markus Elfring
@ 2016-08-21 13:50 ` SF Markus Elfring
  2016-08-21 13:55   ` [PATCH 1/7] USB-iowarrior: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (6 more replies)
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
                   ` (31 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 13:50 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:41:23 +0200

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

Markus Elfring (7):
  Use memdup_user() rather than duplicating its implementation
  Delete unnecessary initialisations for the variable "dev"
  Delete an unnecessary initialisation in iowarrior_release()
  Delete unnecessary initialisations in iowarrior_open()
  Delete unnecessary initialisations in iowarrior_write()
  Delete unnecessary braces
  Apply another recommendation from "checkpatch.pl"

 drivers/usb/misc/iowarrior.c | 53 ++++++++++++++++++--------------------------
 1 file changed, 22 insertions(+), 31 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] USB-iowarrior: Use memdup_user() rather than duplicating its implementation
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-08-21 13:55   ` SF Markus Elfring
  2016-08-21 13:56   ` [PATCH 2/7] USB-iowarrior: Delete unnecessary initialisations for the variable "dev" SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 13:55 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 12:48:27 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 7defa34..8ae01b0 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -368,14 +368,9 @@ static ssize_t iowarrior_write(struct file *file,
 	case USB_DEVICE_ID_CODEMERCS_IOWPV2:
 	case USB_DEVICE_ID_CODEMERCS_IOW40:
 		/* IOW24 and IOW40 use a synchronous call */
-		buf = kmalloc(count, GFP_KERNEL);
-		if (!buf) {
-			retval = -ENOMEM;
-			goto exit;
-		}
-		if (copy_from_user(buf, user_buffer, count)) {
-			retval = -EFAULT;
-			kfree(buf);
+		buf = memdup_user(user_buffer, count);
+		if (IS_ERR(buf)) {
+			retval = PTR_ERR(buf);
 			goto exit;
 		}
 		retval = usb_set_report(dev->interface, 2, 0, buf, count);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] USB-iowarrior: Delete unnecessary initialisations for the variable "dev"
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
  2016-08-21 13:55   ` [PATCH 1/7] USB-iowarrior: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21 13:56   ` SF Markus Elfring
  2016-08-21 13:58   ` [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 13:56 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 13:26:09 +0200

The local variable "dev" was initialised despite of the detail
that it was immediately reassigned by the following statement.
Thus remove such unnecessary specifications.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 8ae01b0..6048f97 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -468,7 +468,7 @@ exit:
 static long iowarrior_ioctl(struct file *file, unsigned int cmd,
 							unsigned long arg)
 {
-	struct iowarrior *dev = NULL;
+	struct iowarrior *dev;
 	__u8 *buffer;
 	__u8 __user *user_buffer;
 	int retval;
@@ -751,7 +751,7 @@ static int iowarrior_probe(struct usb_interface *interface,
 			   const struct usb_device_id *id)
 {
 	struct usb_device *udev = interface_to_usbdev(interface);
-	struct iowarrior *dev = NULL;
+	struct iowarrior *dev;
 	struct usb_host_interface *iface_desc;
 	struct usb_endpoint_descriptor *endpoint;
 	int i;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release()
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
  2016-08-21 13:55   ` [PATCH 1/7] USB-iowarrior: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-21 13:56   ` [PATCH 2/7] USB-iowarrior: Delete unnecessary initialisations for the variable "dev" SF Markus Elfring
@ 2016-08-21 13:58   ` SF Markus Elfring
  2016-08-21 14:00   ` [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open() SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 13:58 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 13:45:09 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 6048f97..449bf64 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -644,7 +644,7 @@ out:
 static int iowarrior_release(struct inode *inode, struct file *file)
 {
 	struct iowarrior *dev;
-	int retval = 0;
+	int retval;
 
 	dev = file->private_data;
 	if (dev == NULL) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open()
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-21 13:58   ` [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release() SF Markus Elfring
@ 2016-08-21 14:00   ` SF Markus Elfring
  2016-08-21 14:02   ` [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 14:00 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:15:03 +0200

Two local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 449bf64..e3564d8 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -587,10 +587,10 @@ error_out:
  */
 static int iowarrior_open(struct inode *inode, struct file *file)
 {
-	struct iowarrior *dev = NULL;
+	struct iowarrior *dev;
 	struct usb_interface *interface;
 	int subminor;
-	int retval = 0;
+	int retval;
 
 	mutex_lock(&iowarrior_mutex);
 	subminor = iminor(inode);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write()
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-21 14:00   ` [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open() SF Markus Elfring
@ 2016-08-21 14:02   ` SF Markus Elfring
  2016-08-21 14:04   ` [PATCH 6/7] USB-iowarrior: Delete unnecessary braces SF Markus Elfring
  2016-08-21 14:06   ` [PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 14:02 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:17:22 +0200

Two local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index e3564d8..ffbbb74 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -338,8 +338,8 @@ static ssize_t iowarrior_write(struct file *file,
 			       size_t count, loff_t *ppos)
 {
 	struct iowarrior *dev;
-	int retval = 0;
-	char *buf = NULL;	/* for IOW24 and IOW56 we need a buffer */
+	int retval;
+	char *buf;	/* for IOW24 and IOW56 we need a buffer */
 	struct urb *int_out_urb = NULL;
 
 	dev = file->private_data;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] USB-iowarrior: Delete unnecessary braces
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-08-21 14:02   ` [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write() SF Markus Elfring
@ 2016-08-21 14:04   ` SF Markus Elfring
  2016-08-21 14:06   ` [PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 14:04 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:25:30 +0200

Do not use curly brackets at a few source code places
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index ffbbb74..132c8cf 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -227,10 +227,10 @@ static void iowarrior_write_callback(struct urb *urb)
 	/* sync/async unlink faults aren't errors */
 	if (status &&
 	    !(status == -ENOENT ||
-	      status == -ECONNRESET || status == -ESHUTDOWN)) {
+	      status == -ECONNRESET || status == -ESHUTDOWN))
 		dev_dbg(&dev->interface->dev,
 			"nonzero write bulk status received: %d\n", status);
-	}
+
 	/* free up our allocated buffer */
 	usb_free_coherent(urb->dev, urb->transfer_buffer_length,
 			  urb->transfer_buffer, urb->transfer_dma);
@@ -304,25 +304,21 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
 								      read_index
 								      (dev)) !=
 								  -1));
-				if (r) {
+				if (r)
 					//we were interrupted by a signal
 					return -ERESTART;
-				}
-				if (!dev->present) {
+				if (!dev->present)
 					//The device was unplugged
 					return -ENODEV;
-				}
-				if (read_idx == -1) {
+				if (read_idx == -1)
 					// Can this happen ???
 					return 0;
-				}
 			}
 		}
 
 		offset = read_idx * (dev->report_size + 1);
-		if (copy_to_user(buffer, dev->read_queue + offset, count)) {
+		if (copy_to_user(buffer, dev->read_queue + offset, count))
 			return -EFAULT;
-		}
 	} while (atomic_read(&dev->overflow_flag));
 
 	read_idx = ++read_idx == MAX_INTERRUPT_BUFFER ? 0 : read_idx;
@@ -475,9 +471,8 @@ static long iowarrior_ioctl(struct file *file, unsigned int cmd,
 	int io_res;		/* checks for bytes read/written and copy_to/from_user results */
 
 	dev = file->private_data;
-	if (dev == NULL) {
+	if (!dev)
 		return -ENODEV;
-	}
 
 	buffer = kzalloc(dev->report_size, GFP_KERNEL);
 	if (!buffer)
@@ -647,9 +642,8 @@ static int iowarrior_release(struct inode *inode, struct file *file)
 	int retval;
 
 	dev = file->private_data;
-	if (dev == NULL) {
+	if (!dev)
 		return -ENODEV;
-	}
 
 	dev_dbg(&dev->interface->dev, "minor %d\n", dev->minor);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl"
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-08-21 14:04   ` [PATCH 6/7] USB-iowarrior: Delete unnecessary braces SF Markus Elfring
@ 2016-08-21 14:06   ` SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 14:06 UTC (permalink / raw)
  To: linux-usb, Greg Kroah-Hartman, Josh Boyer, Wolfram Sang
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 15:30:11 +0200

The script "checkpatch.pl" can point out that assignments should usually
not be performed within condition checks.
Thus move the assignments for two local variables to separate statements.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/usb/misc/iowarrior.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/misc/iowarrior.c b/drivers/usb/misc/iowarrior.c
index 132c8cf..78b5d65 100644
--- a/drivers/usb/misc/iowarrior.c
+++ b/drivers/usb/misc/iowarrior.c
@@ -292,7 +292,8 @@ static ssize_t iowarrior_read(struct file *file, char __user *buffer,
 	/* repeat until no buffer overrun in callback handler occur */
 	do {
 		atomic_set(&dev->overflow_flag, 0);
-		if ((read_idx = read_index(dev)) == -1) {
+		read_idx = read_index(dev);
+		if (read_idx == -1) {
 			/* queue empty */
 			if (file->f_flags & O_NONBLOCK)
 				return -EAGAIN;
@@ -616,7 +617,8 @@ static int iowarrior_open(struct inode *inode, struct file *file)
 	}
 
 	/* setup interrupt handler for receiving values */
-	if ((retval = usb_submit_urb(dev->int_in_urb, GFP_KERNEL)) < 0) {
+	retval = usb_submit_urb(dev->int_in_urb, GFP_KERNEL);
+	if (retval < 0) {
 		dev_err(&interface->dev, "Error %d while submitting URB\n", retval);
 		retval = -EFAULT;
 		goto out;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (63 preceding siblings ...)
  2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-08-21 17:39 ` SF Markus Elfring
  2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (2 more replies)
  2016-08-21 18:26 ` [PATCH] Smack: " SF Markus Elfring
                   ` (30 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:39 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 19:34:12 +0200

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

Markus Elfring (2):
  Use memdup_user()
  Delete an unnecessary initialisation

 include/rdma/ib_verbs.h | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
@ 2016-08-21 17:42   ` SF Markus Elfring
  2016-08-21 17:45   ` [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring
  2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:42 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 18:45:22 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 include/rdma/ib_verbs.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6f667dd..033610b 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2205,16 +2205,11 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 	if (len > USHRT_MAX)
 		return false;
 
-	buf = kmalloc(len, GFP_KERNEL);
-	if (!buf)
+	buf = memdup_user(p, len);
+	if (IS_ERR(buf))
 		return false;
 
-	if (copy_from_user(buf, p, len))
-		goto free;
-
 	ret = !memchr_inv(buf, 0, len);
-
-free:
 	kfree(buf);
 	return ret;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared()
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
  2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21 17:45   ` SF Markus Elfring
  2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 17:45 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 19:23:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 include/rdma/ib_verbs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 033610b..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,7 +2199,7 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 				       size_t len)
 {
 	const void __user *p = udata->inbuf + offset;
-	bool ret = false;
+	bool ret;
 	u8 *buf;
 
 	if (len > USHRT_MAX)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
  2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-21 17:45   ` [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring
@ 2016-08-21 18:03   ` Joe Perches
  2016-08-21 19:51     ` SF Markus Elfring
  2 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-08-21 18:03 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

On Sun, 2016-08-21 at 19:39 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 19:34:12 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.

Don't introduce a defect in patch 1 and correct
that introduced defect in patch 2.

This should be a single patch.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] Smack: Use memdup_user() rather than duplicating its implementation
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (64 preceding siblings ...)
  2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
@ 2016-08-21 18:26 ` SF Markus Elfring
  2016-08-23 21:56   ` Casey Schaufler
  2016-08-21 19:41 ` [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
                   ` (29 subsequent siblings)
  95 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 18:26 UTC (permalink / raw)
  To: linux-security-module, Casey Schaufler, James Morris, Serge E. Hallyn
  Cc: LKML, kernel-janitors, Julia Lawall, Nicolas Palix

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 20:17:36 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 security/smack/smackfs.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
index e249a66..6492fe9 100644
--- a/security/smack/smackfs.c
+++ b/security/smack/smackfs.c
@@ -2523,14 +2523,9 @@ static ssize_t smk_write_revoke_subj(struct file *file, const char __user *buf,
 	if (count == 0 || count > SMK_LONGLABEL)
 		return -EINVAL;
 
-	data = kzalloc(count, GFP_KERNEL);
-	if (data == NULL)
-		return -ENOMEM;
-
-	if (copy_from_user(data, buf, count) != 0) {
-		rc = -EFAULT;
-		goto out_data;
-	}
+	data = memdup_user(buf, count);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
 
 	cp = smk_parse_smack(data, count);
 	if (IS_ERR(cp)) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (65 preceding siblings ...)
  2016-08-21 18:26 ` [PATCH] Smack: " SF Markus Elfring
@ 2016-08-21 19:41 ` SF Markus Elfring
  2016-08-21 19:43   ` [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                   ` (28 subsequent siblings)
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 19:41 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 21:35:43 +0200

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

Markus Elfring (2):
  Use memdup_user()
  Reduce the scope for two variables

 sound/core/compress_offload.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation
  2016-08-21 19:41 ` [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
@ 2016-08-21 19:43   ` SF Markus Elfring
  2016-08-22  5:01     ` Vinod Koul
  2016-08-22 12:05     ` [alsa-devel] " Takashi Iwai
  2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
  1 sibling, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 19:43 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 21:02:06 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/compress_offload.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 2c49848..583d407 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -553,13 +553,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
 		 * we should allow parameter change only when stream has been
 		 * opened not in other cases
 		 */
-		params = kmalloc(sizeof(*params), GFP_KERNEL);
-		if (!params)
-			return -ENOMEM;
-		if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
-			retval = -EFAULT;
-			goto out;
-		}
+		params = memdup_user((void __user *)arg, sizeof(*params));
+		if (IS_ERR(params))
+			return PTR_ERR(params);
 
 		retval = snd_compress_check_input(params);
 		if (retval)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params()
  2016-08-21 19:41 ` [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
  2016-08-21 19:43   ` [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-21 19:45   ` SF Markus Elfring
  2016-08-21 19:51     ` Joe Perches
                       ` (2 more replies)
  1 sibling, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 19:45 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 21 Aug 2016 21:26:18 +0200

Reduce the scope for the local variables to an if branch.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/compress_offload.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 583d407..b43aec5 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
 static int
 snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
 {
-	struct snd_compr_params *params;
-	int retval;
-
 	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
 		/*
 		 * we should allow parameter change only when stream has been
 		 * opened not in other cases
 		 */
+		int retval;
+		struct snd_compr_params *params;
+
 		params = memdup_user((void __user *)arg, sizeof(*params));
 		if (IS_ERR(params))
 			return PTR_ERR(params);
@@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
 			stream->runtime->state = SNDRV_PCM_STATE_SETUP;
 		else
 			stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
+out:
+		kfree(params);
+		return retval;
 	} else {
 		return -EPERM;
 	}
-out:
-	kfree(params);
-	return retval;
 }
 
 static int
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
@ 2016-08-21 19:51     ` SF Markus Elfring
  2016-08-21 19:53       ` Joe Perches
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 19:51 UTC (permalink / raw)
  To: Joe Perches, linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

>> A few update suggestions were taken into account
>> from static source code analysis.
> 
> Don't introduce a defect in patch 1 and correct
> that introduced defect in patch 2.

Which detail do you not like here?


> This should be a single patch.

Do any more software software developers would like to get
the proposed changes in a single update step?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params()
  2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
@ 2016-08-21 19:51     ` Joe Perches
  2016-08-22  8:34       ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
  2016-08-21 20:36     ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Julia Lawall
  2016-08-22  7:20     ` walter harms
  2 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-08-21 19:51 UTC (permalink / raw)
  To: SF Markus Elfring, alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

On Sun, 2016-08-21 at 21:45 +0200, SF Markus Elfring wrote:
> Reduce the scope for the local variables to an if branch.
[]
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
[]
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
>  static int
>  snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  {
> -	struct snd_compr_params *params;
> -	int retval;
> -
>  	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {

Likely better not reducing variable scope but changing:

 	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN)

to

	if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
		return -EPERM;

and unindenting the remainder of the code one level instead.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 19:51     ` SF Markus Elfring
@ 2016-08-21 19:53       ` Joe Perches
  2016-08-21 20:15         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Joe Perches @ 2016-08-21 19:53 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty
  Cc: LKML, kernel-janitors, Julia Lawall

On Sun, 2016-08-21 at 21:51 +0200, SF Markus Elfring wrote:

> > Don't introduce a defect in patch 1 and correct
> > that introduced defect in patch 2.
> Which detail do you not like here?

See above.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 19:53       ` Joe Perches
@ 2016-08-21 20:15         ` SF Markus Elfring
  2016-08-22  9:46           ` Yann Droneaud
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-21 20:15 UTC (permalink / raw)
  To: Joe Perches
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

>>> Don't introduce a defect in patch 1 and correct
>>> that introduced defect in patch 2.
>> Which detail do you not like here?
> 
> See above.

This feedback is not clearer.

I find that the two update steps should work in principle,
shouldn't they?

I guess that we have got different preferences for the shown
patch granularity. Another update variant can follow a bit later
with the changes squashed together.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params()
  2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
  2016-08-21 19:51     ` Joe Perches
@ 2016-08-21 20:36     ` Julia Lawall
  2016-08-22  5:01       ` Vinod Koul
  2016-08-22  7:20     ` walter harms
  2 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-21 20:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul, LKML,
	kernel-janitors



On Sun, 21 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:26:18 +0200
>
> Reduce the scope for the local variables to an if branch.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/core/compress_offload.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 583d407..b43aec5 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
>  static int
>  snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  {
> -	struct snd_compr_params *params;
> -	int retval;
> -
>  	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
>  		/*
>  		 * we should allow parameter change only when stream has been
>  		 * opened not in other cases
>  		 */
> +		int retval;
> +		struct snd_compr_params *params;

I don't like this at all.  Local variables should be at the top of the
function, not hiding under 4 lines of comments in the middle of the code.

julia


> +
>  		params = memdup_user((void __user *)arg, sizeof(*params));
>  		if (IS_ERR(params))
>  			return PTR_ERR(params);
> @@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  			stream->runtime->state = SNDRV_PCM_STATE_SETUP;
>  		else
>  			stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
> +out:
> +		kfree(params);
> +		return retval;
>  	} else {
>  		return -EPERM;
>  	}
> -out:
> -	kfree(params);
> -	return retval;
>  }
>
>  static int
> --
> 2.9.3
>
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] tun: Rename a jump label in update_filter()
  2016-08-20  7:37   ` [PATCH 2/2] tun: Rename a jump label in update_filter() SF Markus Elfring
@ 2016-08-22  1:41     ` Michael S. Tsirkin
  2016-08-22  5:26       ` Mike Rapoport
  0 siblings, 1 reply; 1373+ messages in thread
From: Michael S. Tsirkin @ 2016-08-22  1:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, David S. Miller, Eric Dumazet, Jason Wang, Mike Rapoport,
	Paolo Abeni, Soheil Hassas Yeganeh, LKML, kernel-janitors,
	Julia Lawall

On Sat, Aug 20, 2016 at 09:37:16AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 20 Aug 2016 09:00:34 +0200
> 
> Adjust a jump target according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

I don't have an opinion of this one. Which convention do you refer to?

> ---
>  drivers/net/tun.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index a1aeccb..e249428 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -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;
>  }
> -- 
> 2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation
  2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-20 11:47     ` Shmulik Ladkani
@ 2016-08-22  1:43     ` Michael S. Tsirkin
  1 sibling, 0 replies; 1373+ messages in thread
From: Michael S. Tsirkin @ 2016-08-22  1:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: netdev, David S. Miller, Eric Dumazet, Jason Wang, Mike Rapoport,
	Paolo Abeni, Soheil Hassas Yeganeh, LKML, kernel-janitors,
	Julia Lawall

On Sat, Aug 20, 2016 at 09:34:56AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>


Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/net/tun.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 9c8b5bc..a1aeccb 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -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
> -- 
> 2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation
  2016-08-21 19:43   ` [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-22  5:01     ` Vinod Koul
  2016-08-22 12:05     ` [alsa-devel] " Takashi Iwai
  1 sibling, 0 replies; 1373+ messages in thread
From: Vinod Koul @ 2016-08-22  5:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, LKML, kernel-janitors,
	Julia Lawall

On Sun, Aug 21, 2016 at 09:43:22PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:02:06 +0200
> 
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
> 
> This issue was detected by using the Coccinelle software.

It usually helps to have Coccinelle script in changelog.

But nevertheless

Acked-by: Vinod Koul <vinod.koul@intel.com>

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/core/compress_offload.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 2c49848..583d407 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -553,13 +553,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  		 * we should allow parameter change only when stream has been
>  		 * opened not in other cases
>  		 */
> -		params = kmalloc(sizeof(*params), GFP_KERNEL);
> -		if (!params)
> -			return -ENOMEM;
> -		if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
> -			retval = -EFAULT;
> -			goto out;
> -		}
> +		params = memdup_user((void __user *)arg, sizeof(*params));
> +		if (IS_ERR(params))
> +			return PTR_ERR(params);
>  
>  		retval = snd_compress_check_input(params);
>  		if (retval)
> -- 
> 2.9.3
> 

-- 
~Vinod

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params()
  2016-08-21 20:36     ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Julia Lawall
@ 2016-08-22  5:01       ` Vinod Koul
  0 siblings, 0 replies; 1373+ messages in thread
From: Vinod Koul @ 2016-08-22  5:01 UTC (permalink / raw)
  To: Julia Lawall
  Cc: SF Markus Elfring, alsa-devel, Jaroslav Kysela, Takashi Iwai,
	LKML, kernel-janitors

On Sun, Aug 21, 2016 at 04:36:22PM -0400, Julia Lawall wrote:
> 
> 
> On Sun, 21 Aug 2016, SF Markus Elfring wrote:
> 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 21 Aug 2016 21:26:18 +0200
> >
> > Reduce the scope for the local variables to an if branch.
> >
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > ---
> >  sound/core/compress_offload.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> > index 583d407..b43aec5 100644
> > --- a/sound/core/compress_offload.c
> > +++ b/sound/core/compress_offload.c
> > @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
> >  static int
> >  snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
> >  {
> > -	struct snd_compr_params *params;
> > -	int retval;
> > -
> >  	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
> >  		/*
> >  		 * we should allow parameter change only when stream has been
> >  		 * opened not in other cases
> >  		 */
> > +		int retval;
> > +		struct snd_compr_params *params;
> 
> I don't like this at all.  Local variables should be at the top of the
> function, not hiding under 4 lines of comments in the middle of the code.

I agree with you this, it doesn't help IMO as well

-- 
~Vinod

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] tun: Rename a jump label in update_filter()
  2016-08-22  1:41     ` Michael S. Tsirkin
@ 2016-08-22  5:26       ` Mike Rapoport
  0 siblings, 0 replies; 1373+ messages in thread
From: Mike Rapoport @ 2016-08-22  5:26 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: SF Markus Elfring, netdev, David S. Miller, Eric Dumazet,
	Jason Wang, Paolo Abeni, Soheil Hassas Yeganeh, LKML,
	kernel-janitors, Julia Lawall

On Mon, Aug 22, 2016 at 04:41:11AM +0300, Michael S. Tsirkin wrote:
> On Sat, Aug 20, 2016 at 09:37:16AM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sat, 20 Aug 2016 09:00:34 +0200
> > 
> > Adjust a jump target according to the Linux coding style convention.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> I don't have an opinion of this one. Which convention do you refer to?

Citing Documentation/CodingStyle:

Choose label names which say what the goto does or why the goto exists.  An
example of a good name could be "out_buffer:" if the goto frees "buffer".
Avoid using GW-BASIC names like "err1:" and "err2:".  Also don't name them after
the goto location like "err_kmalloc_failed:"

> 
> > ---
> >  drivers/net/tun.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index a1aeccb..e249428 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -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;
> >  }
> > -- 
> > 2.9.3
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation
  2016-08-20 17:32 ` [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-22  6:24   ` Martin Schwidefsky
  0 siblings, 0 replies; 1373+ messages in thread
From: Martin Schwidefsky @ 2016-08-22  6:24 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, Heiko Carstens, LKML, kernel-janitors, Julia Lawall

On Sat, 20 Aug 2016 19:32:03 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied to linux-s390. Thanks.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params()
  2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
  2016-08-21 19:51     ` Joe Perches
  2016-08-21 20:36     ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Julia Lawall
@ 2016-08-22  7:20     ` walter harms
  2 siblings, 0 replies; 1373+ messages in thread
From: walter harms @ 2016-08-22  7:20 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Jaroslav Kysela, Takashi Iwai, Vinod Koul, LKML,
	kernel-janitors, Julia Lawall



Am 21.08.2016 21:45, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:26:18 +0200
> 
> Reduce the scope for the local variables to an if branch.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  sound/core/compress_offload.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
> index 583d407..b43aec5 100644
> --- a/sound/core/compress_offload.c
> +++ b/sound/core/compress_offload.c
> @@ -545,14 +545,14 @@ static int snd_compress_check_input(struct snd_compr_params *params)
>  static int
>  snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  {
> -	struct snd_compr_params *params;
> -	int retval;
> -
>  	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
>  		/*
>  		 * we should allow parameter change only when stream has been
>  		 * opened not in other cases
>  		 */
> +		int retval;
> +		struct snd_compr_params *params;
> +
>  		params = memdup_user((void __user *)arg, sizeof(*params));
>  		if (IS_ERR(params))
>  			return PTR_ERR(params);
> @@ -578,12 +578,12 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
>  			stream->runtime->state = SNDRV_PCM_STATE_SETUP;
>  		else
>  			stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
> +out:
> +		kfree(params);
> +		return retval;
>  	} else {
>  		return -EPERM;
>  	}
> -out:
> -	kfree(params);
> -	return retval;
>  }
>  
>  static int


if would make sense to have

if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
	return -EPERM;

and read adjust the indent.

just my 2 cents
re,
 wh

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params()
  2016-08-21 19:51     ` Joe Perches
@ 2016-08-22  8:34       ` SF Markus Elfring
  2016-08-22  8:38         ` [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() SF Markus Elfring
                           ` (2 more replies)
  0 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22  8:34 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Joe Perches, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 10:27:01 +0200

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

Markus Elfring (2):
  Restructure source code around an if statement
  Use memdup_user()

 sound/core/compress_offload.c | 58 +++++++++++++++++++------------------------
 1 file changed, 26 insertions(+), 32 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params()
  2016-08-22  8:34       ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
@ 2016-08-22  8:38         ` SF Markus Elfring
  2016-08-22  8:40         ` [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-23  4:04         ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() Vinod Koul
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22  8:38 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Joe Perches, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 10:01:52 +0200

* Reverse a condition check.

* Reduce the indentation one level then for some source code
  from a previous if branch.

Suggested-by: Joe Perches <joe@perches.com>
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/compress_offload.c | 62 +++++++++++++++++++++----------------------
 1 file changed, 30 insertions(+), 32 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 2c49848..a10d139 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -548,43 +548,41 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
 	struct snd_compr_params *params;
 	int retval;
 
-	if (stream->runtime->state == SNDRV_PCM_STATE_OPEN) {
-		/*
-		 * we should allow parameter change only when stream has been
-		 * opened not in other cases
-		 */
-		params = kmalloc(sizeof(*params), GFP_KERNEL);
-		if (!params)
-			return -ENOMEM;
-		if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
-			retval = -EFAULT;
-			goto out;
-		}
+	if (stream->runtime->state != SNDRV_PCM_STATE_OPEN)
+		return -EPERM;
+	/*
+	 * we should allow parameter change only when stream has been
+	 * opened not in other cases
+	 */
+	params = kmalloc(sizeof(*params), GFP_KERNEL);
+	if (!params)
+		return -ENOMEM;
+	if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
+		retval = -EFAULT;
+		goto out;
+	}
 
-		retval = snd_compress_check_input(params);
-		if (retval)
-			goto out;
+	retval = snd_compress_check_input(params);
+	if (retval)
+		goto out;
 
-		retval = snd_compr_allocate_buffer(stream, params);
-		if (retval) {
-			retval = -ENOMEM;
-			goto out;
-		}
+	retval = snd_compr_allocate_buffer(stream, params);
+	if (retval) {
+		retval = -ENOMEM;
+		goto out;
+	}
 
-		retval = stream->ops->set_params(stream, params);
-		if (retval)
-			goto out;
+	retval = stream->ops->set_params(stream, params);
+	if (retval)
+		goto out;
 
-		stream->metadata_set = false;
-		stream->next_track = false;
+	stream->metadata_set = false;
+	stream->next_track = false;
 
-		if (stream->direction == SND_COMPRESS_PLAYBACK)
-			stream->runtime->state = SNDRV_PCM_STATE_SETUP;
-		else
-			stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
-	} else {
-		return -EPERM;
-	}
+	if (stream->direction == SND_COMPRESS_PLAYBACK)
+		stream->runtime->state = SNDRV_PCM_STATE_SETUP;
+	else
+		stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
 out:
 	kfree(params);
 	return retval;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation
  2016-08-22  8:34       ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
  2016-08-22  8:38         ` [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() SF Markus Elfring
@ 2016-08-22  8:40         ` SF Markus Elfring
  2016-08-23  4:04         ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() Vinod Koul
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22  8:40 UTC (permalink / raw)
  To: alsa-devel, Jaroslav Kysela, Joe Perches, Takashi Iwai, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 10:12:37 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 sound/core/compress_offload.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index a10d139..786989b 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -554,13 +554,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
 	 * we should allow parameter change only when stream has been
 	 * opened not in other cases
 	 */
-	params = kmalloc(sizeof(*params), GFP_KERNEL);
-	if (!params)
-		return -ENOMEM;
-	if (copy_from_user(params, (void __user *)arg, sizeof(*params))) {
-		retval = -EFAULT;
-		goto out;
-	}
+	params = memdup_user((void __user *)arg, sizeof(*params));
+	if (IS_ERR(params))
+		return PTR_ERR(params);
 
 	retval = snd_compress_check_input(params);
 	if (retval)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* RE: [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation
  2016-08-21  8:48 ` [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-22  9:31   ` Sumit Saxena
  2016-08-24  2:47   ` Martin K. Petersen
  1 sibling, 0 replies; 1373+ messages in thread
From: Sumit Saxena @ 2016-08-22  9:31 UTC (permalink / raw)
  To: SF Markus Elfring, linux-scsi, megaraidlinux.pdl,
	James E. J. Bottomley, Kashyap Desai, Martin K. Petersen,
	Sumit Saxena, Uday Lingala
  Cc: LKML, kernel-janitors, Julia Lawall

>-----Original Message-----
>From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
>Sent: Sunday, August 21, 2016 2:19 PM
>To: linux-scsi@vger.kernel.org; megaraidlinux.pdl@avagotech.com; James E.
>J.
>Bottomley; Kashyap Desai; Martin K. Petersen; Sumit Saxena; Uday Lingala
>Cc: LKML; kernel-janitors@vger.kernel.org; Julia Lawall
>Subject: [PATCH] megaraid_sas: Use memdup_user() rather than duplicating
>its
>implementation
>
>From: Markus Elfring <elfring@users.sourceforge.net>
>Date: Sun, 21 Aug 2016 10:39:04 +0200
>
>Reuse existing functionality from memdup_user() instead of keeping
>duplicate
>source code.
>
>This issue was detected by using the Coccinelle software.
>
>Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>---
> drivers/scsi/megaraid/megaraid_sas_base.c | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c
>b/drivers/scsi/megaraid/megaraid_sas_base.c
>index c1ed25a..9a2fe4e 100644
>--- a/drivers/scsi/megaraid/megaraid_sas_base.c
>+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
>@@ -6711,14 +6711,9 @@ static int megasas_mgmt_ioctl_fw(struct file *file,
>unsigned long arg)
> 	unsigned long flags;
> 	u32 wait_time = MEGASAS_RESET_WAIT_TIME;
>
>-	ioc = kmalloc(sizeof(*ioc), GFP_KERNEL);
>-	if (!ioc)
>-		return -ENOMEM;
>-
>-	if (copy_from_user(ioc, user_ioc, sizeof(*ioc))) {
>-		error = -EFAULT;
>-		goto out_kfree_ioc;
>-	}
>+	ioc = memdup_user(user_ioc, sizeof(*ioc));
>+	if (IS_ERR(ioc))
>+		return PTR_ERR(ioc);
>
> 	instance = megasas_lookup_instance(ioc->host_no);
> 	if (!instance) {

Acked by: Sumit Saxena <sumit.saxena@broadcom.com>

>--
>2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: IB/core: Fine-tuning for ib_is_udata_cleared()
  2016-08-21 20:15         ` SF Markus Elfring
@ 2016-08-22  9:46           ` Yann Droneaud
  2016-08-22 16:30             ` [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Yann Droneaud @ 2016-08-22  9:46 UTC (permalink / raw)
  To: SF Markus Elfring, Joe Perches
  Cc: linux-rdma, Doug Ledford, Hal Rosenstock, Sean Hefty, LKML,
	kernel-janitors, Julia Lawall

Hi,

Le dimanche 21 août 2016 à 22:15 +0200, SF Markus Elfring a écrit :
> > 
> > > 
> > > > 
> > > > Don't introduce a defect in patch 1 and correct
> > > > that introduced defect in patch 2.
> > > Which detail do you not like here?
> > 
> > See above.
> 
> This feedback is not clearer.
> 

It's clear enough: your second patch fixes an issue you introduced in
your first patch by removing the code which made use of the ret
initialization value:

-       if (copy_from_user(buf, p, len))
-               goto free;

> I find that the two update steps should work in principle,
> shouldn't they?
> 

It would be better to squash them here.

Regards.

-- 
Yann Droneaud
OPTEYA

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation
  2016-08-21 19:43   ` [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-22  5:01     ` Vinod Koul
@ 2016-08-22 12:05     ` Takashi Iwai
  2016-08-23  3:55       ` Vinod Koul
  1 sibling, 1 reply; 1373+ messages in thread
From: Takashi Iwai @ 2016-08-22 12:05 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Jaroslav Kysela, Vinod Koul, Julia Lawall,
	kernel-janitors, LKML

On Sun, 21 Aug 2016 21:43:22 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 21:02:06 +0200
> 
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied this one, but the second patch won't be, since other people
seem to disagree with the usefulness.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] hostap: Fine-tuning for a few functions
  2016-08-20 19:26   ` [PATCH 0/3] hostap: Fine-tuning for a few functions Arend van Spriel
@ 2016-08-22 15:49     ` Kalle Valo
  2016-08-22 16:18       ` Joe Perches
  2016-08-22 18:17       ` [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS Joe Perches
  0 siblings, 2 replies; 1373+ messages in thread
From: Kalle Valo @ 2016-08-22 15:49 UTC (permalink / raw)
  To: Arend van Spriel
  Cc: SF Markus Elfring, linux-wireless, netdev, Jouni Malinen, LKML,
	kernel-janitors, Julia Lawall

Arend van Spriel <arend.vanspriel@broadcom.com> writes:

> On 20-08-16 18:43, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> 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.

On the other hand if these patches break something this might be a good
way to get feedback if someone is really using this driver ;)

But yeah, not really sure what to do with these obsolete drivers like
hostap, ray_cs and wl3501.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/3] hostap: Fine-tuning for a few functions
  2016-08-22 15:49     ` Kalle Valo
@ 2016-08-22 16:18       ` Joe Perches
  2016-08-22 18:17       ` [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS Joe Perches
  1 sibling, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-08-22 16:18 UTC (permalink / raw)
  To: Kalle Valo, Arend van Spriel
  Cc: SF Markus Elfring, linux-wireless, netdev, Jouni Malinen, LKML,
	kernel-janitors, Julia Lawall

On Mon, 2016-08-22 at 18:49 +0300, Kalle Valo wrote:
> Arend van Spriel <arend.vanspriel@broadcom.com> writes:
[]
> But yeah, not really sure what to do with these obsolete drivers like
> hostap, ray_cs and wl3501.

Maybe marking sections obsolete in MAINTAINERS could
flag some "shouldn't touch this" warning for old code
in checkpatch.pl and/or get_maintainer.pl

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation
  2016-08-22  9:46           ` Yann Droneaud
@ 2016-08-22 16:30             ` SF Markus Elfring
  2016-08-23 16:43               ` Doug Ledford
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22 16:30 UTC (permalink / raw)
  To: linux-rdma, Doug Ledford, Hal Rosenstock, Joe Perches,
	Sean Hefty, Yann Droneaud
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 22 Aug 2016 18:23:24 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

  This issue was detected by using the Coccinelle software.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2: The desired changes were put into a single patch instead of
    distributing them over two update steps.

 include/rdma/ib_verbs.h | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
index 6f667dd..0d8100f 100644
--- a/include/rdma/ib_verbs.h
+++ b/include/rdma/ib_verbs.h
@@ -2199,22 +2199,17 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
 				       size_t len)
 {
 	const void __user *p = udata->inbuf + offset;
-	bool ret = false;
+	bool ret;
 	u8 *buf;
 
 	if (len > USHRT_MAX)
 		return false;
 
-	buf = kmalloc(len, GFP_KERNEL);
-	if (!buf)
+	buf = memdup_user(p, len);
+	if (IS_ERR(buf))
 		return false;
 
-	if (copy_from_user(buf, p, len))
-		goto free;
-
 	ret = !memchr_inv(buf, 0, len);
-
-free:
 	kfree(buf);
 	return ret;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* RE: [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation
  2016-08-21  7:19   ` [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-22 18:00     ` David Carroll
  2016-08-22 20:23       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: David Carroll @ 2016-08-22 18:00 UTC (permalink / raw)
  To: SF Markus Elfring, linux-scsi, dl-esc-Aacraid Linux Driver,
	James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/scsi/aacraid/commctrl.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
> index 5648b71..1af3084 100644
> --- a/drivers/scsi/aacraid/commctrl.c
> +++ b/drivers/scsi/aacraid/commctrl.c
> @@ -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;
>         }
> 
> --

Hi Markus,

Patch 2/7 should precede Patch 1/7, as falling into kfree() would not look pretty.

Thanks, -Dave

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS
  2016-08-22 15:49     ` Kalle Valo
  2016-08-22 16:18       ` Joe Perches
@ 2016-08-22 18:17       ` Joe Perches
  2016-08-22 20:50         ` SF Markus Elfring
  2016-08-23  7:26         ` SF Markus Elfring
  1 sibling, 2 replies; 1373+ messages in thread
From: Joe Perches @ 2016-08-22 18:17 UTC (permalink / raw)
  To: Andrew Morton, Kalle Valo, Arend van Spriel, Andy Whitcroft
  Cc: SF Markus Elfring, linux-wireless, netdev, Jouni Malinen,
	kernel-janitors, Julia Lawall, linux-kernel

Use get_maintainer to check the status of individual files.
If "obsolete", suggest leaving the files alone.

Signed-off-by: Joe Perches <joe@perches.com>
---
 scripts/checkpatch.pl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4de3cc4..df5e9d9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -704,6 +704,16 @@ sub seed_camelcase_file {
 	}
 }
 
+sub is_maintained_obsolete {
+	my ($filename) = @_;
+
+	return 0 if (!(-e "$root/scripts/get_maintainer.pl"));
+
+	my $status = `perl $root/scripts/get_maintainer.pl --status --nom --nol --nogit --nogit-fallback $filename 2>&1`;
+
+	return $status =~ /obsolete/i;
+}
+
 my $camelcase_seeded = 0;
 sub seed_camelcase_includes {
 	return if ($camelcase_seeded);
@@ -2289,6 +2299,10 @@ sub process {
 		}
 
 		if ($found_file) {
+			if (is_maintained_obsolete($realfile)) {
+				WARN("OBSOLETE",
+				     "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy.  No unnecessary modifications please.\n");
+			}
 			if ($realfile =~ m@^(?:drivers/net/|net/|drivers/staging/)@) {
 				$check = 1;
 			} else {
-- 
2.8.0.rc4.16.g56331f8

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation
  2016-08-22 18:00     ` David Carroll
@ 2016-08-22 20:23       ` SF Markus Elfring
  2016-08-24 23:01         ` David Carroll
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22 20:23 UTC (permalink / raw)
  To: David Carroll, linux-scsi, dl-esc-Aacraid Linux Driver,
	James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

>> @@ -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;
>>         }
>>
>> --
> 
> Hi Markus,
> 
> Patch 2/7 should precede Patch 1/7, as falling into kfree() would not look pretty.

Do you eventually prefer that this source code adjustment should be combined with
the update suggestion "[2/7] aacraid: One function call less in aac_send_raw_srb()
after error detection" in a single update step?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS
  2016-08-22 18:17       ` [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS Joe Perches
@ 2016-08-22 20:50         ` SF Markus Elfring
  2016-08-22 20:56           ` Joe Perches
  2016-08-23  7:26         ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-22 20:50 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Kalle Valo, Arend van Spriel, Andy Whitcroft,
	linux-wireless, netdev, Jouni Malinen, kernel-janitors,
	Julia Lawall, linux-kernel

> @@ -2289,6 +2299,10 @@ sub process {
>  		}
>  
>  		if ($found_file) {
> +			if (is_maintained_obsolete($realfile)) {
> +				WARN("OBSOLETE",
> +				     "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy.  No unnecessary modifications please.\n");
> +			}

How do you think about to avoid a double negation in such a warning message?

Would a wording like "… Only really necessary modifications please.\n"
be more useful here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS
  2016-08-22 20:50         ` SF Markus Elfring
@ 2016-08-22 20:56           ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-08-22 20:56 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Andrew Morton, Kalle Valo, Arend van Spriel, Andy Whitcroft,
	linux-wireless, netdev, Jouni Malinen, kernel-janitors,
	Julia Lawall, linux-kernel

On Mon, 2016-08-22 at 22:50 +0200, SF Markus Elfring wrote:
> > @@ -2289,6 +2299,10 @@ sub process {
> >  		}
> >  
> >  		if ($found_file) {
> > +			if (is_maintained_obsolete($realfile)) {
> > +				WARN("OBSOLETE",
> > +				     "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy.  No unnecessary modifications please.\n");
> > +			}
> How do you think about to avoid a double negation in such a warning message?
> 
> Would a wording like "… Only really necessary modifications please.\n"
> be more useful here?

No, probably not.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation
  2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-20  9:32   ` walter harms
@ 2016-08-23  0:05   ` David Miller
  1 sibling, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-08-23  0:05 UTC (permalink / raw)
  To: elfring
  Cc: linux-rdma, netdev, leonro, matanb, linux-kernel,
	kernel-janitors, julia.lawall

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 20 Aug 2016 08:01:22 +0200

> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation
  2016-08-22 12:05     ` [alsa-devel] " Takashi Iwai
@ 2016-08-23  3:55       ` Vinod Koul
  0 siblings, 0 replies; 1373+ messages in thread
From: Vinod Koul @ 2016-08-23  3:55 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: SF Markus Elfring, alsa-devel, Jaroslav Kysela, Julia Lawall,
	kernel-janitors, LKML

On Mon, Aug 22, 2016 at 02:05:43PM +0200, Takashi Iwai wrote:
> On Sun, 21 Aug 2016 21:43:22 +0200,
> SF Markus Elfring wrote:
> > 
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Sun, 21 Aug 2016 21:02:06 +0200
> > 
> > Reuse existing functionality from memdup_user() instead of keeping
> > duplicate source code.
> > 
> > This issue was detected by using the Coccinelle software.
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> Applied this one, but the second patch won't be, since other people
> seem to disagree with the usefulness.

I see a v2 as well discarding patch 2 here and some other changes

-- 
~Vinod

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params()
  2016-08-22  8:34       ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
  2016-08-22  8:38         ` [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() SF Markus Elfring
  2016-08-22  8:40         ` [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-23  4:04         ` Vinod Koul
  2 siblings, 0 replies; 1373+ messages in thread
From: Vinod Koul @ 2016-08-23  4:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: alsa-devel, Jaroslav Kysela, Joe Perches, Takashi Iwai, LKML,
	kernel-janitors, Julia Lawall

On Mon, Aug 22, 2016 at 10:34:19AM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 Aug 2016 10:27:01 +0200
> 
> A few update suggestions were taken into account
> from static source code analysis.

Both:

Acked-by: Vinod Koul <vinod.koul@intel.com>

-- 
~Vinod

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: checkpatch: See if modified files are marked obsolete in MAINTAINERS
  2016-08-22 18:17       ` [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS Joe Perches
  2016-08-22 20:50         ` SF Markus Elfring
@ 2016-08-23  7:26         ` SF Markus Elfring
  2016-08-23 10:18           ` Julia Lawall
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-23  7:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: Andrew Morton, Kalle Valo, Arend van Spriel, Andy Whitcroft,
	linux-wireless, netdev, Jouni Malinen, kernel-janitors,
	Julia Lawall, linux-kernel, Fengguang Wu

> Use get_maintainer to check the status of individual files.
> If "obsolete", suggest leaving the files alone.

Will another software system like the "kbuild test robot"
need any more fine-tuning for this change?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: checkpatch: See if modified files are marked obsolete in MAINTAINERS
  2016-08-23  7:26         ` SF Markus Elfring
@ 2016-08-23 10:18           ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-08-23 10:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Joe Perches, Andrew Morton, Kalle Valo, Arend van Spriel,
	Andy Whitcroft, linux-wireless, netdev, Jouni Malinen,
	kernel-janitors, Julia Lawall, linux-kernel, Fengguang Wu



On Tue, 23 Aug 2016, SF Markus Elfring wrote:

> > Use get_maintainer to check the status of individual files.
> > If "obsolete", suggest leaving the files alone.
>
> Will another software system like the "kbuild test robot"
> need any more fine-tuning for this change?

It only works on files in which there have been commits, thus by
definition not obsolete.

julia


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

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation
  2016-08-22 16:30             ` [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-08-23 16:43               ` Doug Ledford
  0 siblings, 0 replies; 1373+ messages in thread
From: Doug Ledford @ 2016-08-23 16:43 UTC (permalink / raw)
  To: SF Markus Elfring, linux-rdma, Hal Rosenstock, Joe Perches,
	Sean Hefty, Yann Droneaud
  Cc: LKML, kernel-janitors, Julia Lawall


[-- Attachment #1.1: Type: text/plain, Size: 623 bytes --]

On 8/22/2016 12:30 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 22 Aug 2016 18:23:24 +0200
> 
> * Reuse existing functionality from memdup_user() instead of keeping
>   duplicate source code.
> 
>   This issue was detected by using the Coccinelle software.
> 
> * The local variable "ret" will be set to an appropriate value a bit later.
>   Thus omit the explicit initialisation at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied, thanks.


-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] Smack: Use memdup_user() rather than duplicating its implementation
  2016-08-21 18:26 ` [PATCH] Smack: " SF Markus Elfring
@ 2016-08-23 21:56   ` Casey Schaufler
  0 siblings, 0 replies; 1373+ messages in thread
From: Casey Schaufler @ 2016-08-23 21:56 UTC (permalink / raw)
  To: SF Markus Elfring, linux-security-module, James Morris, Serge E. Hallyn
  Cc: LKML, kernel-janitors, Julia Lawall, Nicolas Palix

On 8/21/2016 11:26 AM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 21 Aug 2016 20:17:36 +0200
>
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Acked-by: Casey Schaufler <casey@schaufler-ca.com>

Applied to git://github.com/cschaufler/smack-next.git#smack-for-4.9

> ---
>  security/smack/smackfs.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
> index e249a66..6492fe9 100644
> --- a/security/smack/smackfs.c
> +++ b/security/smack/smackfs.c
> @@ -2523,14 +2523,9 @@ static ssize_t smk_write_revoke_subj(struct file *file, const char __user *buf,
>  	if (count == 0 || count > SMK_LONGLABEL)
>  		return -EINVAL;
>  
> -	data = kzalloc(count, GFP_KERNEL);
> -	if (data == NULL)
> -		return -ENOMEM;
> -
> -	if (copy_from_user(data, buf, count) != 0) {
> -		rc = -EFAULT;
> -		goto out_data;
> -	}
> +	data = memdup_user(buf, count);
> +	if (IS_ERR(data))
> +		return PTR_ERR(data);
>  
>  	cp = smk_parse_smack(data, count);
>  	if (IS_ERR(cp)) {

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation
  2016-08-21  8:48 ` [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
  2016-08-22  9:31   ` Sumit Saxena
@ 2016-08-24  2:47   ` Martin K. Petersen
  1 sibling, 0 replies; 1373+ messages in thread
From: Martin K. Petersen @ 2016-08-24  2:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-scsi, megaraidlinux.pdl, James E. J. Bottomley,
	Kashyap Desai, Martin K. Petersen, Sumit Saxena, Uday Lingala,
	LKML, kernel-janitors, Julia Lawall

>>>>> "SF" == SF Markus Elfring <elfring@users.sourceforge.net> writes:

SF> Reuse existing functionality from memdup_user() instead of keeping
SF> duplicate source code.

Applied to 4.9/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* RE: [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation
  2016-08-22 20:23       ` SF Markus Elfring
@ 2016-08-24 23:01         ` David Carroll
  0 siblings, 0 replies; 1373+ messages in thread
From: David Carroll @ 2016-08-24 23:01 UTC (permalink / raw)
  To: SF Markus Elfring, linux-scsi, dl-esc-Aacraid Linux Driver,
	James E. J. Bottomley, Martin K. Petersen
  Cc: LKML, kernel-janitors, Julia Lawall

> >
> > Hi Markus,
> >
> > Patch 2/7 should precede Patch 1/7, as falling into kfree() would not look
> pretty.
> 
> Do you eventually prefer that this source code adjustment should be combined
> with the update suggestion "[2/7] aacraid: One function call less in
> aac_send_raw_srb() after error detection" in a single update step?
> 

Hi Markus,

My primary objective in this would be the ability to bisect ... The secondary would be one issue/patch. I think my preference would be to swap patches 1 and 2.

Thanks, -Dave

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (66 preceding siblings ...)
  2016-08-21 19:41 ` [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
@ 2016-08-26 12:43 ` SF Markus Elfring
  2016-08-26 12:48   ` [PATCH 1/8] cris-cryptocop: Use kmalloc_array() in two functions SF Markus Elfring
                     ` (7 more replies)
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
                   ` (27 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:43 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 14:34:34 +0200

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

Markus Elfring (8):
  Use kmalloc_array() in two functions
  Improve determination of sizes in five functions
  Delete unnecessary braces
  Less function calls after error detection
  Move an assignment for the variable "nooutpages"
  Delete two variables
  Delete unnecessary variable initialisations
  Apply another recommendation from "checkpatch.pl"

 arch/cris/arch-v32/drivers/cryptocop.c | 299 +++++++++++++++------------------
 1 file changed, 140 insertions(+), 159 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/8] cris-cryptocop: Use kmalloc_array() in two functions
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-08-26 12:48   ` SF Markus Elfring
  2016-08-26 12:50   ` [PATCH 2/8] cris-cryptocop: Improve determination of sizes in five functions SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:48 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Aug 2016 22:11:44 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specifications of data structures by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 2081d8b..1632abc 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -1532,7 +1532,9 @@ int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_
 		return -ENOMEM;
 	}
 
-	sess->tfrm_ctx = kmalloc(no_tfrms * sizeof(struct cryptocop_transform_ctx), alloc_flag);
+	sess->tfrm_ctx = kmalloc_array(no_tfrms,
+				       sizeof(*sess->tfrm_ctx),
+				       alloc_flag);
 	if (!sess->tfrm_ctx) {
 		DEBUG_API(printk("cryptocop_new_session, kmalloc cryptocop_transform_ctx\n"));
 		kfree(sess);
@@ -2697,7 +2699,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	/* Map user pages for in and out data of the operation. */
 	noinpages = (((unsigned long int)(oper.indata + prev_ix) & ~PAGE_MASK) + oper.inlen - 1 - prev_ix + ~PAGE_MASK) >> PAGE_SHIFT;
 	DEBUG(printk("cryptocop_ioctl_process: noinpages=%d\n", noinpages));
-	inpages = kmalloc(noinpages * sizeof(struct page*), GFP_KERNEL);
+	inpages = kmalloc_array(noinpages, sizeof(*inpages), GFP_KERNEL);
 	if (!inpages){
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc inpages\n"));
 		nooutpages = noinpages = 0;
@@ -2707,7 +2709,9 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	if (oper.do_cipher){
 		nooutpages = (((unsigned long int)oper.cipher_outdata & ~PAGE_MASK) + oper.cipher_outlen - 1 + ~PAGE_MASK) >> PAGE_SHIFT;
 		DEBUG(printk("cryptocop_ioctl_process: nooutpages=%d\n", nooutpages));
-		outpages = kmalloc(nooutpages * sizeof(struct page*), GFP_KERNEL);
+		outpages = kmalloc_array(nooutpages,
+					 sizeof(*outpages),
+					 GFP_KERNEL);
 		if (!outpages){
 			DEBUG_API(printk("cryptocop_ioctl_process: kmalloc outpages\n"));
 			nooutpages = noinpages = 0;
@@ -2753,8 +2757,12 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 
 	/* Add 6 to nooutpages to make room for possibly inserted buffers for storing digest and
 	 * csum output and splits when units are (dis-)connected. */
-	cop->tfrm_op.indata = kmalloc((noinpages) * sizeof(struct iovec), GFP_KERNEL);
-	cop->tfrm_op.outdata = kmalloc((6 + nooutpages) * sizeof(struct iovec), GFP_KERNEL);
+	cop->tfrm_op.indata = kmalloc_array(noinpages,
+					    sizeof(*cop->tfrm_op.indata),
+					    GFP_KERNEL);
+	cop->tfrm_op.outdata = kmalloc_array(6 + nooutpages,
+					     sizeof(*cop->tfrm_op.outdata),
+					     GFP_KERNEL);
 	if (!cop->tfrm_op.indata || !cop->tfrm_op.outdata) {
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc iovecs\n"));
 		err = -ENOMEM;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/8] cris-cryptocop: Improve determination of sizes in five functions
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
  2016-08-26 12:48   ` [PATCH 1/8] cris-cryptocop: Use kmalloc_array() in two functions SF Markus Elfring
@ 2016-08-26 12:50   ` SF Markus Elfring
  2016-08-26 12:51   ` [PATCH 3/8] cris-cryptocop: Delete unnecessary braces SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:50 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 25 Aug 2016 22:32:27 +0200

Replace the specification of data structures by references for variables
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 1632abc..8e04b92 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -323,7 +323,7 @@ static struct cryptocop_dma_desc *alloc_cdesc(int alloc_flag)
 		spin_unlock_irqrestore(&descr_pool_lock, flags);
 		cdesc->from_pool = 1;
 	} else {
-		cdesc = kmalloc(sizeof(struct cryptocop_dma_desc), alloc_flag);
+		cdesc = kmalloc(sizeof(*cdesc), alloc_flag);
 		if (!cdesc) {
 			DEBUG_API(printk("alloc_cdesc: kmalloc\n"));
 			return NULL;
@@ -1526,7 +1526,7 @@ int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_
 		return -EINVAL;
 	}
 
-	sess = kmalloc(sizeof(struct cryptocop_session), alloc_flag);
+	sess = kmalloc(sizeof(*sess), alloc_flag);
 	if (!sess){
 		DEBUG_API(printk("cryptocop_new_session, kmalloc cryptocop_session\n"));
 		return -ENOMEM;
@@ -2247,7 +2247,7 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
 	int  alloc_flag = operation->in_interrupt ? GFP_ATOMIC : GFP_KERNEL;
 	void *iop_alloc_ptr = NULL;
 
-	*pj = kmalloc(sizeof (struct cryptocop_prio_job), alloc_flag);
+	*pj = kmalloc(sizeof(**pj), alloc_flag);
 	if (!*pj) return -ENOMEM;
 
 	DEBUG(printk("cryptocop_job_setup: operation=0x%p\n", operation));
@@ -2552,12 +2552,12 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		return -EFAULT;
 	}
 
-	cop = kmalloc(sizeof(struct cryptocop_operation), GFP_KERNEL);
+	cop = kmalloc(sizeof(*cop), GFP_KERNEL);
 	if (!cop) {
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc\n"));
 		return -ENOMEM;
 	}
-	jc = kmalloc(sizeof(struct ioctl_job_cb_ctx), GFP_KERNEL);
+	jc = kmalloc(sizeof(*jc), GFP_KERNEL);
 	if (!jc) {
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc\n"));
 		err = -ENOMEM;
@@ -3082,7 +3082,7 @@ static int cryptocop_ioctl_create_session(struct inode *inode, struct file *filp
 		ti_csum.next = tis;
 		tis = &ti_csum;
 	} /* (sop.csum != cryptocop_csum_none) */
-	dev = kmalloc(sizeof(struct cryptocop_private), GFP_KERNEL);
+	dev = kmalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev){
 		DEBUG_API(printk("create session, alloc dev\n"));
 		return -ENOMEM;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/8] cris-cryptocop: Delete unnecessary braces
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
  2016-08-26 12:48   ` [PATCH 1/8] cris-cryptocop: Use kmalloc_array() in two functions SF Markus Elfring
  2016-08-26 12:50   ` [PATCH 2/8] cris-cryptocop: Improve determination of sizes in five functions SF Markus Elfring
@ 2016-08-26 12:51   ` SF Markus Elfring
  2016-08-26 12:54   ` [PATCH 4/8] cris-cryptocop: Less function calls in cryptocop_ioctl_process() after error detection SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:51 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 08:15:38 +0200

Do not use curly brackets at some source code places
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 140 +++++++++++++--------------------
 1 file changed, 56 insertions(+), 84 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 8e04b92..1165639 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -352,11 +352,10 @@ static void setup_descr_chain(struct cryptocop_dma_desc *cd)
 {
 	DEBUG(printk("setup_descr_chain: entering\n"));
 	while (cd) {
-		if (cd->next) {
+		if (cd->next)
 			cd->dma_descr->next = (dma_descr_data*)virt_to_phys(cd->next->dma_descr);
-		} else {
+		else
 			cd->dma_descr->next = NULL;
-		}
 		cd = cd->next;
 	}
 	DEBUG(printk("setup_descr_chain: exit\n"));
@@ -996,13 +995,15 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 
 			DEBUG(printk("cryptocop_setup_dma_list: parsing an operation descriptor configuration.\n"));
 			/* Get the local context for the transform and mark it as the output unit if it produces output. */
-			if (digest_ctx.tcfg && (digest_ctx.tcfg->tid == dcfg->tid)){
+			if (digest_ctx.tcfg &&
+			   (digest_ctx.tcfg->tid == dcfg->tid))
 				tc = &digest_ctx;
-			} else if (cipher_ctx.tcfg && (cipher_ctx.tcfg->tid == dcfg->tid)){
+			else if (cipher_ctx.tcfg &&
+				(cipher_ctx.tcfg->tid == dcfg->tid))
 				tc = &cipher_ctx;
-			} else if (csum_ctx.tcfg && (csum_ctx.tcfg->tid == dcfg->tid)){
+			else if (csum_ctx.tcfg &&
+				(csum_ctx.tcfg->tid == dcfg->tid))
 				tc = &csum_ctx;
-			}
 			if (!tc) {
 				DEBUG_API(printk("cryptocop_setup_dma_list: invalid transform %d specified in descriptor.\n", dcfg->tid));
 				failed = -EINVAL;
@@ -1047,13 +1048,12 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 			}
 			if (tc->current_src != src_dma) {
 				/* Find the unit we are sourcing from. */
-				if (digest_ctx.unit_no == tc->current_src){
+				if (digest_ctx.unit_no == tc->current_src)
 					tc->curr_src = &digest_ctx;
-				} else if (cipher_ctx.unit_no == tc->current_src){
+				else if (cipher_ctx.unit_no == tc->current_src)
 					tc->curr_src = &cipher_ctx;
-				} else if (csum_ctx.unit_no == tc->current_src){
+				else if (csum_ctx.unit_no == tc->current_src)
 					tc->curr_src = &csum_ctx;
-				}
 				if ((tc->curr_src == tc) && (tc->unit_no != src_dma)){
 					DEBUG_API(printk("cryptocop_setup_dma_list: unit %d configured to source from itself.\n", tc->unit_no));
 					failed = -EINVAL;
@@ -1065,7 +1065,7 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 
 			/* Detect source switch. */
 			DEBUG(printk("cryptocop_setup_dma_list: tc->active=%d tc->unit_no=%d tc->current_src=%d tc->previous_src=%d, tc->curr_src=0x%p, tc->prev_srv=0x%p\n", tc->active, tc->unit_no, tc->current_src, tc->previous_src, tc->curr_src, tc->prev_src));
-			if (tc->active && (tc->current_src != tc->previous_src)) {
+			if (tc->active && (tc->current_src != tc->previous_src))
 				/* Only allow source switch when both the old source unit and the new one have
 				 * no pending data to process (i.e. the consumed length must be a multiple of the
 				 * transform blocklength). */
@@ -1077,12 +1077,10 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 					failed = -EINVAL;
 					goto error_cleanup;
 				}
-			}
 			/* Detect unit deactivation. */
-			if (dcfg->last) {
+			if (dcfg->last)
 				/* Length check of this is handled below. */
 				tc->done = 1;
-			}
 			dcfg = dcfg->next;
 		} /* while (dcfg) */
 		DEBUG(printk("cryptocop_setup_dma_list: parsing operation descriptor configuration complete.\n"));
@@ -1116,20 +1114,17 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 
 		if (csum_ctx.active) {
 			csum_ctx.consumed += desc_len;
-			if (csum_ctx.done) {
+			if (csum_ctx.done)
 				csum_ctx.produced = 2;
-			}
 			DEBUG(printk("cryptocop_setup_dma_list: csum_ctx producing: consumed=%d, produced=%d, blocklength=%d.\n", csum_ctx.consumed, csum_ctx.produced, csum_ctx.blocklength));
 		}
 		if (digest_ctx.active) {
 			digest_ctx.consumed += desc_len;
-			if (digest_ctx.done) {
-				if (digest_ctx.unit_no == src_md5) {
+			if (digest_ctx.done)
+				if (digest_ctx.unit_no == src_md5)
 					digest_ctx.produced = MD5_STATE_LENGTH;
-				} else {
+				else
 					digest_ctx.produced = SHA1_STATE_LENGTH;
-				}
-			}
 			DEBUG(printk("cryptocop_setup_dma_list: digest_ctx producing: consumed=%d, produced=%d, blocklength=%d.\n", digest_ctx.consumed, digest_ctx.produced, digest_ctx.blocklength));
 		}
 		if (cipher_ctx.active) {
@@ -1137,9 +1132,11 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 			assert(cipher_ctx.current_src == src_dma);
 			cipher_ctx.consumed += desc_len;
 			cipher_ctx.produced = cipher_ctx.blocklength * (cipher_ctx.consumed / cipher_ctx.blocklength);
-			if (cipher_ctx.cbcmode && !(cipher_ctx.tcfg->flags & CRYPTOCOP_EXPLICIT_IV) && cipher_ctx.produced){
+			if (cipher_ctx.cbcmode &&
+			    !(cipher_ctx.tcfg->flags
+			     & CRYPTOCOP_EXPLICIT_IV) &&
+			    cipher_ctx.produced)
 				cipher_ctx.produced -= cipher_ctx.blocklength; /* Compensate for CBC iv. */
-			}
 			DEBUG(printk("cryptocop_setup_dma_list: cipher_ctx producing: consumed=%d, produced=%d, blocklength=%d.\n", cipher_ctx.consumed, cipher_ctx.produced, cipher_ctx.blocklength));
 		}
 
@@ -1149,12 +1146,11 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 		eop_needed_count = 0;
 		if (cipher_ctx.active) {
 			++active_count;
-			if (cipher_ctx.unit_no == src_dma){
+			if (cipher_ctx.unit_no == src_dma)
 				/* mem2mem */
 				meta_out.ciphsel = src_none;
-			} else {
+			else
 				meta_out.ciphsel = cipher_ctx.current_src;
-			}
 			meta_out.ciphconf = cipher_ctx.ciph_conf;
 			meta_out.cbcmode = cipher_ctx.cbcmode;
 			meta_out.decrypt = cipher_ctx.decrypt;
@@ -1223,12 +1219,11 @@ static int cryptocop_setup_dma_list(struct cryptocop_operation *operation, struc
 
 				assert(cipher_ctx.active && cipher_ctx.done);
 
-				if (cipher_ctx.unit_no == src_dma){
+				if (cipher_ctx.unit_no == src_dma)
 					/* mem2mem */
 					ed_mo.ciphsel = src_none;
-				} else {
+				else
 					ed_mo.ciphsel = cipher_ctx.current_src;
-				}
 				ed_mo.ciphconf = cipher_ctx.ciph_conf;
 				ed_mo.cbcmode = cipher_ctx.cbcmode;
 				ed_mo.decrypt = cipher_ctx.decrypt;
@@ -1596,13 +1591,11 @@ int cryptocop_free_session(cryptocop_session_id sid)
 		psess = sess;
 		sess = sess->next;
 	}
-	if (sess){
-		if (psess){
+	if (sess)
+		if (psess)
 			psess->next = sess->next;
-		} else {
+		else
 			cryptocop_sessions = sess->next;
-		}
-	}
 	spin_unlock_irqrestore(&cryptocop_sessions_lock, flags);
 
 	if (!sess) return -EINVAL;
@@ -1610,16 +1603,13 @@ int cryptocop_free_session(cryptocop_session_id sid)
 	/* Remove queued jobs. */
 	spin_lock_irqsave(&cryptocop_job_queue_lock, flags);
 
-	for (i = 0; i < cryptocop_prio_no_prios; i++){
-		if (!list_empty(&(cryptocop_job_queues[i].jobs))){
+	for (i = 0; i < cryptocop_prio_no_prios; i++)
+		if (!list_empty(&(cryptocop_job_queues[i].jobs)))
 			list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) {
 				pj = list_entry(node, struct cryptocop_prio_job, node);
-				if (pj->oper->sid == sid) {
+				if (pj->oper->sid == sid)
 					list_move_tail(node, &remove_list);
-				}
 			}
-		}
-	}
 	spin_unlock_irqrestore(&cryptocop_job_queue_lock, flags);
 
 	list_for_each_safe(node, tmp, &remove_list) {
@@ -1653,9 +1643,8 @@ static struct cryptocop_session *get_session(cryptocop_session_id sid)
 
 	spin_lock_irqsave(&cryptocop_sessions_lock, flags);
 	sess = cryptocop_sessions;
-	while (sess && (sess->sid != sid)){
+	while (sess && (sess->sid != sid))
 		sess = sess->next;
-	}
 	spin_unlock_irqrestore(&cryptocop_sessions_lock, flags);
 
 	return sess;
@@ -1779,9 +1768,8 @@ static void get_aes_decrypt_key(unsigned char *dec_key, const unsigned  char *ke
 
 	/* Need to do host byte order correction here since key is byte oriented and the
 	 * kx algorithm is word (u32) oriented. */
-	for (i = 0; i < nk; i+=1) {
+	for (i = 0; i < nk; ++i)
 		w_ring[i] = be32_to_cpu(*(u32*)&key[4*i]);
-	}
 
 	i = (int)nk;
 	w_last_ix = i - 1;
@@ -2055,8 +2043,8 @@ static void cryptocop_job_queue_close(void)
 	spin_lock_irqsave(&cryptocop_process_lock, process_flags);
 
 	/* Empty the job queue. */
-	for (i = 0; i < cryptocop_prio_no_prios; i++){
-		if (!list_empty(&(cryptocop_job_queues[i].jobs))){
+	for (i = 0; i < cryptocop_prio_no_prios; i++)
+		if (!list_empty(&(cryptocop_job_queues[i].jobs)))
 			list_for_each_safe(node, tmp, &(cryptocop_job_queues[i].jobs)) {
 				pj = list_entry(node, struct cryptocop_prio_job, node);
 				list_del(node);
@@ -2069,8 +2057,6 @@ static void cryptocop_job_queue_close(void)
 				delete_internal_operation(pj->iop);
 				kfree(pj);
 			}
-		}
-	}
 	spin_unlock_irqrestore(&cryptocop_process_lock, process_flags);
 
 	/* Remove the running job, if any. */
@@ -2321,9 +2307,8 @@ static int cryptocop_release(struct inode *inode, struct file *filp)
 
 	while (dev){
 		dev_next = dev->next;
-		if (dev->sid != CRYPTOCOP_SESSION_ID_NONE) {
+		if (dev->sid != CRYPTOCOP_SESSION_ID_NONE)
 			(void)cryptocop_free_session(dev->sid);
-		}
 		kfree(dev);
 		dev = dev_next;
 	}
@@ -2353,11 +2338,10 @@ static int cryptocop_ioctl_close_session(struct inode *inode, struct file *filp,
 		dev = dev->next;
 	}
 	if (dev){
-		if (prev_dev){
+		if (prev_dev)
 			prev_dev->next = dev->next;
-		} else {
+		else
 			filp->private_data = dev->next;
-		}
 		err = cryptocop_free_session(dev->sid);
 		if (err) return -EFAULT;
 	} else {
@@ -2401,27 +2385,24 @@ static size_t next_cfg_change_ix(struct strcop_crypto_op *crp_op, size_t ix)
 	size_t ch_ix = INT_MAX;
 	size_t tmp_ix = 0;
 
-	if (crp_op->do_cipher && ((crp_op->cipher_start + crp_op->cipher_len) > ix)){
-		if (crp_op->cipher_start > ix) {
+	if (crp_op->do_cipher &&
+	   ((crp_op->cipher_start + crp_op->cipher_len) > ix))
+		if (crp_op->cipher_start > ix)
 			ch_ix = crp_op->cipher_start;
-		} else {
+		else
 			ch_ix = crp_op->cipher_start + crp_op->cipher_len;
-		}
-	}
 	if (crp_op->do_digest && ((crp_op->digest_start + crp_op->digest_len) > ix)){
-		if (crp_op->digest_start > ix) {
+		if (crp_op->digest_start > ix)
 			tmp_ix = crp_op->digest_start;
-		} else {
+		else
 			tmp_ix = crp_op->digest_start + crp_op->digest_len;
-		}
 		if (tmp_ix < ch_ix) ch_ix = tmp_ix;
 	}
 	if (crp_op->do_csum && ((crp_op->csum_start + crp_op->csum_len) > ix)){
-		if (crp_op->csum_start > ix) {
+		if (crp_op->csum_start > ix)
 			tmp_ix = crp_op->csum_start;
-		} else {
+		else
 			tmp_ix = crp_op->csum_start + crp_op->csum_len;
-		}
 		if (tmp_ix < ch_ix) ch_ix = tmp_ix;
 	}
 	if (ch_ix == INT_MAX) ch_ix = ix;
@@ -2635,11 +2616,10 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			return -EINVAL;
 		}
 
-		if (oper.decrypt){
+		if (oper.decrypt)
 			ciph_tcfg.flags |= CRYPTOCOP_DECRYPT;
-		} else {
+		else
 			ciph_tcfg.flags |= CRYPTOCOP_ENCRYPT;
-		}
 		ciph_tcfg.next = cop->tfrm_op.tfrm_cfg;
 		cop->tfrm_op.tfrm_cfg = &ciph_tcfg;
 	}
@@ -2861,11 +2841,10 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		prev_ix = next_ix;
 		next_ix = next_cfg_change_ix(&oper, prev_ix);
 	}
-	if (desc_ix > 0){
+	if (desc_ix > 0)
 		descs[desc_ix-1].next = NULL;
-	} else {
+	else
 		descs[0].next = NULL;
-	}
 	if (oper.do_digest) {
 		DEBUG(printk("cryptocop_ioctl_process: mapping %d byte digest output to iovec %d\n", digest_length, iovix));
 		/* Add outdata iovec, length == <length of type of digest> */
@@ -2881,13 +2860,12 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		cop->tfrm_op.outdata[iovix].iov_len = 2;
 		++iovix;
 	}
-	if (oper.do_cipher) {
+	if (oper.do_cipher)
 		if (!map_pages_to_iovec(cop->tfrm_op.outdata, iovlen, &iovix, outpages, nooutpages, &pageix, &pageoffset, oper.cipher_outlen)){
 			DEBUG_API(printk("cryptocop_ioctl_process: failed to map pages to iovec.\n"));
 			err = -ENOSYS; /* This should be impossible barring bugs. */
 			goto error_cleanup;
 		}
-	}
 	DEBUG(printk("cryptocop_ioctl_process: setting cop->tfrm_op.outcount %d\n", iovix));
 	cop->tfrm_op.outcount = iovix;
 	assert(iovix <= (nooutpages + 6));
@@ -2942,19 +2920,16 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 
  error_cleanup:
 	/* Release page caches. */
-	for (i = 0; i < noinpages; i++){
+	for (i = 0; i < noinpages; i++)
 		put_page(inpages[i]);
-	}
 	for (i = 0; i < nooutpages; i++){
 		int spdl_err;
 		/* Mark output pages dirty. */
 		spdl_err = set_page_dirty_lock(outpages[i]);
 		DEBUG(if (spdl_err < 0)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err));
 	}
-	for (i = 0; i < nooutpages; i++){
+	for (i = 0; i < nooutpages; i++)
 		put_page(outpages[i]);
-	}
-
 	kfree(digest_result);
 	kfree(inpages);
 	kfree(outpages);
@@ -2987,9 +2962,8 @@ static int cryptocop_ioctl_create_session(struct inode *inode, struct file *filp
 		return -EFAULT;
 	err = copy_from_user(&sop, sess_op, sizeof(struct strcop_session_op));
 	if (err) return -EFAULT;
-	if (sop.cipher != cryptocop_cipher_none) {
+	if (sop.cipher != cryptocop_cipher_none)
 		if (!access_ok(VERIFY_READ, sop.key, sop.keylen)) return -EFAULT;
-	}
 	DEBUG(printk("cryptocop_ioctl_create_session, sess_op:\n"));
 
 	DEBUG(printk("\tcipher:%d\n"
@@ -3362,23 +3336,21 @@ static void print_cryptocop_operation(struct cryptocop_operation *cop)
 			d = d->next;
 		}
 		printk("\n====iniov\n");
-		for (i = 0; i < cop->tfrm_op.incount; i++){
+		for (i = 0; i < cop->tfrm_op.incount; i++)
 			printk("indata[%d]\n"
 			       "base=0x%p\n"
 			       "len=%d\n",
 			       i,
 			       cop->tfrm_op.indata[i].iov_base,
 			       cop->tfrm_op.indata[i].iov_len);
-		}
 		printk("\n====outiov\n");
-		for (i = 0; i < cop->tfrm_op.outcount; i++){
+		for (i = 0; i < cop->tfrm_op.outcount; i++)
 			printk("outdata[%d]\n"
 			       "base=0x%p\n"
 			       "len=%d\n",
 			       i,
 			       cop->tfrm_op.outdata[i].iov_base,
 			       cop->tfrm_op.outdata[i].iov_len);
-		}
 	}
 	printk("------------end print_cryptocop_operation\n");
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/8] cris-cryptocop: Less function calls in cryptocop_ioctl_process() after error detection
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-26 12:51   ` [PATCH 3/8] cris-cryptocop: Delete unnecessary braces SF Markus Elfring
@ 2016-08-26 12:54   ` SF Markus Elfring
  2016-08-26 12:55   ` [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process() SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:54 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 13:31:40 +0200

1. The kfree() function was called in some cases by the
   cryptocop_ioctl_process() function during error handling
   even if the passed variable contained a null pointer.

2. Split a condition check for memory allocation failures.

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

4. Omit an unneeded check for the local variable "cop" then at the end.

5. Delete assignments which became unnecessary with this refactoring
   for two local variables.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 80 ++++++++++++++++++----------------
 1 file changed, 42 insertions(+), 38 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 1165639..26347a2 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2542,7 +2542,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	if (!jc) {
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc\n"));
 		err = -ENOMEM;
-		goto error_cleanup;
+		goto free_cop;
 	}
 	jc->processed = 0;
 
@@ -2575,7 +2575,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		if (!tc) {
 			DEBUG_API(printk("cryptocop_ioctl_process: no cipher transform in session.\n"));
 			err = -EINVAL;
-			goto error_cleanup;
+			goto free_jc;
 		}
 		ciph_tcfg.tid = CRYPTOCOP_IOCTL_CIPHER_TID;
 		ciph_tcfg.inject_ix = 0;
@@ -2628,14 +2628,14 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		if (!tc) {
 			DEBUG_API(printk("cryptocop_ioctl_process: no digest transform in session.\n"));
 			err = -EINVAL;
-			goto error_cleanup;
+			goto free_jc;
 		}
 		digest_length = tc->init.alg == cryptocop_alg_md5 ? 16 : 20;
 		digest_result = kmalloc(digest_length, GFP_KERNEL);
 		if (!digest_result) {
 			DEBUG_API(printk("cryptocop_ioctl_process: kmalloc digest_result\n"));
 			err = -EINVAL;
-			goto error_cleanup;
+			goto free_jc;
 		}
 		DEBUG(memset(digest_result, 0xff, digest_length));
 
@@ -2645,7 +2645,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		if ((oper.digest_start < 0) || (oper.digest_len <= 0) || (oper.digest_start > oper.inlen) || ((oper.digest_start + oper.digest_len) > oper.inlen)){
 			DEBUG_API(printk("cryptocop_ioctl_process: bad digest length\n"));
 			err = -EINVAL;
-			goto error_cleanup;
+			goto free_digest;
 		}
 
 		digest_tcfg.next = cop->tfrm_op.tfrm_cfg;
@@ -2670,9 +2670,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	prev_ix = first_cfg_change_ix(&oper);
 	if (prev_ix > oper.inlen) {
 		DEBUG_API(printk("cryptocop_ioctl_process: length mismatch\n"));
-		nooutpages = noinpages = 0;
 		err = -EINVAL;
-		goto error_cleanup;
+		goto free_digest;
 	}
 	DEBUG(printk("cryptocop_ioctl_process: inlen=%d, cipher_outlen=%d\n", oper.inlen, oper.cipher_outlen));
 
@@ -2682,9 +2681,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	inpages = kmalloc_array(noinpages, sizeof(*inpages), GFP_KERNEL);
 	if (!inpages){
 		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc inpages\n"));
-		nooutpages = noinpages = 0;
 		err = -ENOMEM;
-		goto error_cleanup;
+		goto free_digest;
 	}
 	if (oper.do_cipher){
 		nooutpages = (((unsigned long int)oper.cipher_outdata & ~PAGE_MASK) + oper.cipher_outlen - 1 + ~PAGE_MASK) >> PAGE_SHIFT;
@@ -2694,9 +2692,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 					 GFP_KERNEL);
 		if (!outpages){
 			DEBUG_API(printk("cryptocop_ioctl_process: kmalloc outpages\n"));
-			nooutpages = noinpages = 0;
 			err = -ENOMEM;
-			goto error_cleanup;
+			goto free_inpages;
 		}
 	}
 
@@ -2712,9 +2709,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 
 	if (err < 0) {
 		up_read(&current->mm->mmap_sem);
-		nooutpages = noinpages = 0;
 		DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages indata\n"));
-		goto error_cleanup;
+		goto free_outpages;
 	}
 	noinpages = err;
 	if (oper.do_cipher){
@@ -2726,9 +2722,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 				     NULL);
 		up_read(&current->mm->mmap_sem);
 		if (err < 0) {
-			nooutpages = 0;
 			DEBUG_API(printk("cryptocop_ioctl_process: get_user_pages outdata\n"));
-			goto error_cleanup;
+			goto put_inpages;
 		}
 		nooutpages = err;
 	} else {
@@ -2740,13 +2735,18 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	cop->tfrm_op.indata = kmalloc_array(noinpages,
 					    sizeof(*cop->tfrm_op.indata),
 					    GFP_KERNEL);
+	if (!cop->tfrm_op.indata) {
+		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc indata\n"));
+		err = -ENOMEM;
+		goto put_outpages;
+	}
 	cop->tfrm_op.outdata = kmalloc_array(6 + nooutpages,
 					     sizeof(*cop->tfrm_op.outdata),
 					     GFP_KERNEL);
-	if (!cop->tfrm_op.indata || !cop->tfrm_op.outdata) {
-		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc iovecs\n"));
+	if (!cop->tfrm_op.outdata) {
+		DEBUG_API(printk("cryptocop_ioctl_process: kmalloc outdata\n"));
 		err = -ENOMEM;
-		goto error_cleanup;
+		goto free_indata;
 	}
 
 	cop->tfrm_op.inlen = oper.inlen - prev_ix;
@@ -2780,7 +2780,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	if (prev_ix == next_ix){
 		DEBUG_API(printk("cryptocop_ioctl_process: length configuration broken.\n"));
 		err = -EINVAL;  /* This should be impossible barring bugs. */
-		goto error_cleanup;
+		goto free_outdata;
 	}
 	while (prev_ix != next_ix){
 		end_digest = end_csum = cipher_active = digest_active = csum_active = 0;
@@ -2834,7 +2834,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		if (!descs[desc_ix].cfg){
 			DEBUG_API(printk("cryptocop_ioctl_process: data segment %d (%d to %d) had no active transforms\n", desc_ix, prev_ix, next_ix));
 			err = -EINVAL;
-			goto error_cleanup;
+			goto mark_outpages_dirty;
 		}
 		descs[desc_ix].next = &(descs[desc_ix]) + 1;
 		++desc_ix;
@@ -2864,7 +2864,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		if (!map_pages_to_iovec(cop->tfrm_op.outdata, iovlen, &iovix, outpages, nooutpages, &pageix, &pageoffset, oper.cipher_outlen)){
 			DEBUG_API(printk("cryptocop_ioctl_process: failed to map pages to iovec.\n"));
 			err = -ENOSYS; /* This should be impossible barring bugs. */
-			goto error_cleanup;
+			goto mark_outpages_dirty;
 		}
 	DEBUG(printk("cryptocop_ioctl_process: setting cop->tfrm_op.outcount %d\n", iovix));
 	cop->tfrm_op.outcount = iovix;
@@ -2878,7 +2878,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	if ((err = cryptocop_job_queue_insert_user_job(cop)) != 0) {
 		DEBUG_API(printk("cryptocop_ioctl_process: insert job %d\n", err));
 		err = -EINVAL;
-		goto error_cleanup;
+		goto mark_outpages_dirty;
 	}
 
 	DEBUG(printk("cryptocop_ioctl_process: begin wait for result\n"));
@@ -2888,7 +2888,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
         if (!jc->processed){
 		printk(KERN_WARNING "cryptocop_ioctl_process: job not processed at completion\n");
 		err = -EIO;
-		goto error_cleanup;
+		goto mark_outpages_dirty;
 	}
 
 	/* Job process done.  Cipher output should already be correct in job so no post processing of outdata. */
@@ -2900,7 +2900,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			if (0 != err){
 				DEBUG_API(printk("cryptocop_ioctl_process: copy_to_user, digest length %d, err %d\n", digest_length, err));
 				err = -EFAULT;
-				goto error_cleanup;
+				goto mark_outpages_dirty;
 			}
 		}
 		if (oper.do_csum){
@@ -2909,7 +2909,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			if (0 != err){
 				DEBUG_API(printk("cryptocop_ioctl_process: copy_to_user, csum, err %d\n", err));
 				err = -EFAULT;
-				goto error_cleanup;
+				goto mark_outpages_dirty;
 			}
 		}
 		err = 0;
@@ -2917,29 +2917,33 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 		DEBUG(printk("cryptocop_ioctl_process: returning err = operation_status = %d\n", cop->operation_status));
 		err = cop->operation_status;
 	}
-
- error_cleanup:
-	/* Release page caches. */
-	for (i = 0; i < noinpages; i++)
-		put_page(inpages[i]);
+ mark_outpages_dirty:
 	for (i = 0; i < nooutpages; i++){
 		int spdl_err;
 		/* Mark output pages dirty. */
 		spdl_err = set_page_dirty_lock(outpages[i]);
 		DEBUG(if (spdl_err < 0)printk("cryptocop_ioctl_process: set_page_dirty_lock returned %d\n", spdl_err));
 	}
+ free_outdata:
+	kfree(cop->tfrm_op.outdata);
+ free_indata:
+	kfree(cop->tfrm_op.indata);
+ put_outpages:
 	for (i = 0; i < nooutpages; i++)
 		put_page(outpages[i]);
-	kfree(digest_result);
-	kfree(inpages);
+ put_inpages:
+	for (i = 0; i < noinpages; i++)
+		put_page(inpages[i]);
+ free_outpages:
 	kfree(outpages);
-	if (cop){
-		kfree(cop->tfrm_op.indata);
-		kfree(cop->tfrm_op.outdata);
-		kfree(cop);
-	}
+ free_inpages:
+	kfree(inpages);
+ free_digest:
+	kfree(digest_result);
+ free_jc:
 	kfree(jc);
-
+ free_cop:
+	kfree(cop);
 	DEBUG(print_lock_status());
 
 	return err;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process()
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-26 12:54   ` [PATCH 4/8] cris-cryptocop: Less function calls in cryptocop_ioctl_process() after error detection SF Markus Elfring
@ 2016-08-26 12:55   ` SF Markus Elfring
  2016-08-27 19:07     ` Julia Lawall
  2016-08-26 12:56   ` [PATCH 6/8] cris-cryptocop: Delete two variables " SF Markus Elfring
                     ` (2 subsequent siblings)
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:55 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 13:38:30 +0200

Move the assignment for the local variable "nooutpages" behind
the source code for memory allocations by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 26347a2..cd34723 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2469,7 +2469,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	struct page                     **inpages = NULL;
 	struct page                     **outpages = NULL;
 	int                             noinpages = 0;
-	int                             nooutpages = 0;
+	int                             nooutpages;
 
 	struct cryptocop_desc           descs[5]; /* Max 5 descriptors are needed, there are three transforms that
 						   * can get connected/disconnected on different places in the indata. */
@@ -2695,6 +2695,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			err = -ENOMEM;
 			goto free_inpages;
 		}
+	} else {
+		nooutpages = 0;
 	}
 
 	/* Acquire the mm page semaphore. */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/8] cris-cryptocop: Delete two variables in cryptocop_ioctl_process()
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-08-26 12:55   ` [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process() SF Markus Elfring
@ 2016-08-26 12:56   ` SF Markus Elfring
  2016-08-26 12:58   ` [PATCH 7/8] cris-cryptocop: Delete unnecessary variable initialisations " SF Markus Elfring
  2016-08-26 13:00   ` [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:56 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 13:40:29 +0200

A zero was assigned to the local variables "cipher_done" and "csum_done"
at one place. But they were not read within this function.
Thus remove them.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index cd34723..a682b1f 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2497,8 +2497,6 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	int    cipher_active, digest_active, csum_active;
 	int    end_digest, end_csum;
 	int    digest_done = 0;
-	int    cipher_done = 0;
-	int    csum_done = 0;
 
 	DEBUG(printk("cryptocop_ioctl_process\n"));
 
@@ -2794,12 +2792,10 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			dcfgs[dcfg_ix].src = cryptocop_source_dma;
 			cipher_active = 1;
 
-			if (next_ix == (oper.cipher_start + oper.cipher_len)){
-				cipher_done = 1;
+			if (next_ix == (oper.cipher_start + oper.cipher_len))
 				dcfgs[dcfg_ix].last = 1;
-			} else {
+			else
 				dcfgs[dcfg_ix].last = 0;
-			}
 			dcfgs[dcfg_ix].next = descs[desc_ix].cfg;
 			descs[desc_ix].cfg = &dcfgs[dcfg_ix];
 			++dcfg_ix;
@@ -2823,12 +2819,10 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 			csum_active = 1;
 			dcfgs[dcfg_ix].tid = CRYPTOCOP_IOCTL_CSUM_TID;
 			dcfgs[dcfg_ix].src = cryptocop_source_dma;
-			if (next_ix == (oper.csum_start + oper.csum_len)){
-				csum_done = 1;
+			if (next_ix == (oper.csum_start + oper.csum_len))
 				dcfgs[dcfg_ix].last = 1;
-			} else {
+			else
 				dcfgs[dcfg_ix].last = 0;
-			}
 			dcfgs[dcfg_ix].next = descs[desc_ix].cfg;
 			descs[desc_ix].cfg = &dcfgs[dcfg_ix];
 			++dcfg_ix;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/8] cris-cryptocop: Delete unnecessary variable initialisations in cryptocop_ioctl_process()
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-08-26 12:56   ` [PATCH 6/8] cris-cryptocop: Delete two variables " SF Markus Elfring
@ 2016-08-26 12:58   ` SF Markus Elfring
  2016-08-26 13:00   ` [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 12:58 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 13:57:21 +0200

Nine local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation which became unnecessary with
a previous update step.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index a682b1f..1a966dc 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -2461,14 +2461,12 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 	struct cryptocop_private        *dev = filp->private_data;
 	struct strcop_crypto_op         *crp_oper = (struct strcop_crypto_op *)arg;
 	struct strcop_crypto_op         oper = {0};
-	int                             err = 0;
-	struct cryptocop_operation      *cop = NULL;
-
-	struct ioctl_job_cb_ctx         *jc = NULL;
-
-	struct page                     **inpages = NULL;
+	int                             err;
+	struct cryptocop_operation      *cop;
+	struct ioctl_job_cb_ctx         *jc;
+	struct page                     **inpages;
 	struct page                     **outpages = NULL;
-	int                             noinpages = 0;
+	int                             noinpages;
 	int                             nooutpages;
 
 	struct cryptocop_desc           descs[5]; /* Max 5 descriptors are needed, there are three transforms that
@@ -2482,16 +2480,14 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 
 	unsigned char                   *digest_result = NULL;
 	int                             digest_length = 0;
-	int                             cblocklen = 0;
+	int                             cblocklen;
 	unsigned char                   csum_result[CSUM_BLOCK_LENGTH];
 	struct cryptocop_session        *sess;
-
-	int    iovlen = 0;
+	int    iovlen;
 	int    iovix = 0;
 	int    pageix = 0;
-	int    pageoffset = 0;
-
-	size_t prev_ix = 0;
+	int    pageoffset;
+	size_t prev_ix;
 	size_t next_ix;
 
 	int    cipher_active, digest_active, csum_active;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl"
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-08-26 12:58   ` [PATCH 7/8] cris-cryptocop: Delete unnecessary variable initialisations " SF Markus Elfring
@ 2016-08-26 13:00   ` SF Markus Elfring
  2016-08-27 19:06     ` Julia Lawall
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-26 13:00 UTC (permalink / raw)
  To: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 26 Aug 2016 14:23:06 +0200

The script "checkpatch.pl" can point out that assignments should usually
not be performed within condition checks.
Thus move the assignments for a local variable to separate statements
in three functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/cris/arch-v32/drivers/cryptocop.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
index 1a966dc..00231a7 100644
--- a/arch/cris/arch-v32/drivers/cryptocop.c
+++ b/arch/cris/arch-v32/drivers/cryptocop.c
@@ -1510,7 +1510,8 @@ int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_
 	while (tfrm_in){
 		int err;
 		++no_tfrms;
-		if ((err = transform_ok(tfrm_in))) {
+		err = transform_ok(tfrm_in);
+		if (err) {
 			DEBUG_API(printk("cryptocop_new_session, bad transform\n"));
 			return err;
 		}
@@ -2276,7 +2277,10 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
 		(*pj)->iop->ctx_in.saved_data = operation->list_op.inlist;
 		(*pj)->iop->ctx_in.saved_data_buf = operation->list_op.in_data_buf;
 	} else {
-		if ((err = cryptocop_setup_dma_list(operation, &(*pj)->iop, alloc_flag))) {
+		err = cryptocop_setup_dma_list(operation,
+					       &(*pj)->iop,
+					       alloc_flag);
+		if (err) {
 			DEBUG_API(printk("cryptocop_job_setup: cryptocop_setup_dma_list failed %d\n", err));
 			kfree(*pj);
 			return err;
@@ -2867,7 +2871,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
 
 	DEBUG(printk("cryptocop_ioctl_process: inserting job, cb_data=0x%p\n", cop->cb_data));
 
-	if ((err = cryptocop_job_queue_insert_user_job(cop)) != 0) {
+	err = cryptocop_job_queue_insert_user_job(cop);
+	if (err) {
 		DEBUG_API(printk("cryptocop_ioctl_process: insert job %d\n", err));
 		err = -EINVAL;
 		goto mark_outpages_dirty;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl"
  2016-08-26 13:00   ` [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
@ 2016-08-27 19:06     ` Julia Lawall
  2016-08-28  7:18       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-27 19:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner,
	LKML, kernel-janitors, Paolo Bonzini



On Fri, 26 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 26 Aug 2016 14:23:06 +0200
>
> The script "checkpatch.pl" can point out that assignments should usually
> not be performed within condition checks.
> Thus move the assignments for a local variable to separate statements
> in three functions.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/cris/arch-v32/drivers/cryptocop.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
> index 1a966dc..00231a7 100644
> --- a/arch/cris/arch-v32/drivers/cryptocop.c
> +++ b/arch/cris/arch-v32/drivers/cryptocop.c
> @@ -1510,7 +1510,8 @@ int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_
>  	while (tfrm_in){
>  		int err;
>  		++no_tfrms;
> -		if ((err = transform_ok(tfrm_in))) {
> +		err = transform_ok(tfrm_in);
> +		if (err) {
>  			DEBUG_API(printk("cryptocop_new_session, bad transform\n"));
>  			return err;
>  		}
> @@ -2276,7 +2277,10 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
>  		(*pj)->iop->ctx_in.saved_data = operation->list_op.inlist;
>  		(*pj)->iop->ctx_in.saved_data_buf = operation->list_op.in_data_buf;
>  	} else {
> -		if ((err = cryptocop_setup_dma_list(operation, &(*pj)->iop, alloc_flag))) {
> +		err = cryptocop_setup_dma_list(operation,
> +					       &(*pj)->iop,
> +					       alloc_flag);

Checkpatch didn't say to put every argument on a different line, and that
wasn't done before, so why do it now?  There is plenty of room for at
least &(*pj)->iop on the line before.

julia

> +		if (err) {
>  			DEBUG_API(printk("cryptocop_job_setup: cryptocop_setup_dma_list failed %d\n", err));
>  			kfree(*pj);
>  			return err;
> @@ -2867,7 +2871,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
>
>  	DEBUG(printk("cryptocop_ioctl_process: inserting job, cb_data=0x%p\n", cop->cb_data));
>
> -	if ((err = cryptocop_job_queue_insert_user_job(cop)) != 0) {
> +	err = cryptocop_job_queue_insert_user_job(cop);
> +	if (err) {
>  		DEBUG_API(printk("cryptocop_ioctl_process: insert job %d\n", err));
>  		err = -EINVAL;
>  		goto mark_outpages_dirty;
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process()
  2016-08-26 12:55   ` [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process() SF Markus Elfring
@ 2016-08-27 19:07     ` Julia Lawall
  2016-08-28  7:28       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-27 19:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner,
	LKML, kernel-janitors, Julia Lawall, Paolo Bonzini



On Fri, 26 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 26 Aug 2016 13:38:30 +0200
>
> Move the assignment for the local variable "nooutpages" behind
> the source code for memory allocations by this function.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/cris/arch-v32/drivers/cryptocop.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/arch/cris/arch-v32/drivers/cryptocop.c b/arch/cris/arch-v32/drivers/cryptocop.c
> index 26347a2..cd34723 100644
> --- a/arch/cris/arch-v32/drivers/cryptocop.c
> +++ b/arch/cris/arch-v32/drivers/cryptocop.c
> @@ -2469,7 +2469,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
>  	struct page                     **inpages = NULL;
>  	struct page                     **outpages = NULL;
>  	int                             noinpages = 0;
> -	int                             nooutpages = 0;
> +	int                             nooutpages;
>
>  	struct cryptocop_desc           descs[5]; /* Max 5 descriptors are needed, there are three transforms that
>  						   * can get connected/disconnected on different places in the indata. */
> @@ -2695,6 +2695,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
>  			err = -ENOMEM;
>  			goto free_inpages;
>  		}
> +	} else {
> +		nooutpages = 0;

Why is it better?  4 characters have becomes 2 lines.

julia

>  	}
>
>  	/* Acquire the mm page semaphore. */
> --
> 2.9.3
>
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl"
  2016-08-27 19:06     ` Julia Lawall
@ 2016-08-28  7:18       ` SF Markus Elfring
  2016-08-28 10:25         ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28  7:18 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner,
	LKML, kernel-janitors, Paolo Bonzini

>> @@ -2276,7 +2277,10 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
>>  		(*pj)->iop->ctx_in.saved_data = operation->list_op.inlist;
>>  		(*pj)->iop->ctx_in.saved_data_buf = operation->list_op.in_data_buf;
>>  	} else {
>> -		if ((err = cryptocop_setup_dma_list(operation, &(*pj)->iop, alloc_flag))) {
>> +		err = cryptocop_setup_dma_list(operation,
>> +					       &(*pj)->iop,
>> +					       alloc_flag);
> 
> Checkpatch didn't say to put every argument on a different line,

I agree to this information.


> and that wasn't done before, so why do it now?

I tend to give each function parameter its own text line in such an use case
(for the known length limitation).


> There is plenty of room for at least &(*pj)->iop on the line before.

This is true. - Do you prefer an other indentation approach here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process()
  2016-08-27 19:07     ` Julia Lawall
@ 2016-08-28  7:28       ` SF Markus Elfring
  2016-08-28 10:24         ` Julia Lawall
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28  7:28 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner,
	LKML, kernel-janitors, Paolo Bonzini

>> +++ b/arch/cris/arch-v32/drivers/cryptocop.c
>> @@ -2469,7 +2469,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
>>  	struct page                     **inpages = NULL;
>>  	struct page                     **outpages = NULL;
>>  	int                             noinpages = 0;
>> -	int                             nooutpages = 0;
>> +	int                             nooutpages;
>>
>>  	struct cryptocop_desc           descs[5]; /* Max 5 descriptors are needed, there are three transforms that
>>  						   * can get connected/disconnected on different places in the indata. */
>> @@ -2695,6 +2695,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
>>  			err = -ENOMEM;
>>  			goto free_inpages;
>>  		}
>> +	} else {
>> +		nooutpages = 0;
> 
> Why is it better?  4 characters have becomes 2 lines.

I suggest to express in a more precise way where this variable is needed actually.

* It would also be an update candidate for the refactoring "Reduce the scope of a variable", wouldn't it?

* Or would the refactoring "Split the implementation of a function into further functions" more appropriate here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process()
  2016-08-28  7:28       ` SF Markus Elfring
@ 2016-08-28 10:24         ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-08-28 10:24 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, linux-cris-kernel, Adam Buchbinder, Dave Hansen,
	Ingo Molnar, Jesper Nilsson, Jiri Kosina, Mikael Starvik,
	Thomas Gleixner, LKML, kernel-janitors, Paolo Bonzini



On Sun, 28 Aug 2016, SF Markus Elfring wrote:

> >> +++ b/arch/cris/arch-v32/drivers/cryptocop.c
> >> @@ -2469,7 +2469,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
> >>  	struct page                     **inpages = NULL;
> >>  	struct page                     **outpages = NULL;
> >>  	int                             noinpages = 0;
> >> -	int                             nooutpages = 0;
> >> +	int                             nooutpages;
> >>
> >>  	struct cryptocop_desc           descs[5]; /* Max 5 descriptors are needed, there are three transforms that
> >>  						   * can get connected/disconnected on different places in the indata. */
> >> @@ -2695,6 +2695,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
> >>  			err = -ENOMEM;
> >>  			goto free_inpages;
> >>  		}
> >> +	} else {
> >> +		nooutpages = 0;
> >
> > Why is it better?  4 characters have becomes 2 lines.
>
> I suggest to express in a more precise way where this variable is needed
> actually.

The variable is used in the cleanup code at the end of the function.
Thus it conceptually has global scope, and it is completely reasonable to
initialize it at the beginning of its function, along with noinpages.

This code is horrible in so many ways: no space before {, lots of 0
initializations instead of kzalloc, random use of local cleanup code and
a label at the end of the function, the use of DEBUG, the use of printk,
the use of the very long function name in strings instead of __func__,
constants on the left of a != test, etc.  On the other hand there are also
very few commits on this code, and even fewer that are specific to this
code, so perhaps no one cares about it.

julia


>
> * It would also be an update candidate for the refactoring "Reduce the scope of a variable", wouldn't it?
>
> * Or would the refactoring "Split the implementation of a function into further functions" more appropriate here?
>
> Regards,
> Markus
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl"
  2016-08-28  7:18       ` SF Markus Elfring
@ 2016-08-28 10:25         ` Julia Lawall
  2016-08-28 13:22           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julia Lawall @ 2016-08-28 10:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Julia Lawall, linux-cris-kernel, Adam Buchbinder, Dave Hansen,
	Ingo Molnar, Jesper Nilsson, Jiri Kosina, Mikael Starvik,
	Thomas Gleixner, LKML, kernel-janitors, Paolo Bonzini



On Sun, 28 Aug 2016, SF Markus Elfring wrote:

> >> @@ -2276,7 +2277,10 @@ static int cryptocop_job_setup(struct cryptocop_prio_job **pj, struct cryptocop_
> >>  		(*pj)->iop->ctx_in.saved_data = operation->list_op.inlist;
> >>  		(*pj)->iop->ctx_in.saved_data_buf = operation->list_op.in_data_buf;
> >>  	} else {
> >> -		if ((err = cryptocop_setup_dma_list(operation, &(*pj)->iop, alloc_flag))) {
> >> +		err = cryptocop_setup_dma_list(operation,
> >> +					       &(*pj)->iop,
> >> +					       alloc_flag);
> >
> > Checkpatch didn't say to put every argument on a different line,
>
> I agree to this information.
>
>
> > and that wasn't done before, so why do it now?
>
> I tend to give each function parameter its own text line in such an use case
> (for the known length limitation).
>
>
> > There is plenty of room for at least &(*pj)->iop on the line before.
>
> This is true. - Do you prefer an other indentation approach here?

Very much.  Most of the kernel code puts as much information on a line as
possible, unless there is a reason to do otherwise.  Then more of the code
will fit on the screen at one time.

julia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: cris-cryptocop: Apply another recommendation from "checkpatch.pl"
  2016-08-28 10:25         ` Julia Lawall
@ 2016-08-28 13:22           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 13:22 UTC (permalink / raw)
  To: Julia Lawall
  Cc: linux-cris-kernel, Adam Buchbinder, Dave Hansen, Ingo Molnar,
	Jesper Nilsson, Jiri Kosina, Mikael Starvik, Thomas Gleixner,
	LKML, kernel-janitors, Paolo Bonzini, linux-doc

>>> There is plenty of room for at least &(*pj)->iop on the line before.
>>
>> This is true. - Do you prefer an other indentation approach here?
> 
> Very much.  Most of the kernel code puts as much information on a line as
> possible, unless there is a reason to do otherwise.  Then more of the code
> will fit on the screen at one time.

How do you think about to clarify such an implementation detail also
in a document like "CodingStyle"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (67 preceding siblings ...)
  2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
@ 2016-08-28 17:09 ` SF Markus Elfring
  2016-08-28 17:12   ` [PATCH 1/6] KVM: PPC: e500: Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
                     ` (6 more replies)
  2016-08-29 11:00 ` [PATCH 0/5] PowerPC: Fine-tuning for three " SF Markus Elfring
                   ` (26 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:09 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 19:01:02 +0200

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

Markus Elfring (6):
  Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb()
  Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection
  Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb()
  Replace kzalloc() calls by kcalloc() in two functions
  Use kmalloc_array() in kvmppc_e500_tlb_init()
  Rename jump labels in kvmppc_e500_tlb_init()

 arch/powerpc/kvm/e500_mmu.c | 71 +++++++++++++++++++++++----------------------
 1 file changed, 36 insertions(+), 35 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] KVM: PPC: e500: Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb()
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-08-28 17:12   ` SF Markus Elfring
  2016-08-28 17:14   ` [PATCH 2/6] KVM: PPC: e500: Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:12 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 16:30:07 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 29911a0..26f3737 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -779,7 +779,7 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 
 	num_pages = DIV_ROUND_UP(cfg->array + array_len - 1, PAGE_SIZE) -
 		    cfg->array / PAGE_SIZE;
-	pages = kmalloc(sizeof(struct page *) * num_pages, GFP_KERNEL);
+	pages = kmalloc_array(num_pages, sizeof(*pages), GFP_KERNEL);
 	if (!pages)
 		return -ENOMEM;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] KVM: PPC: e500: Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
  2016-08-28 17:12   ` [PATCH 1/6] KVM: PPC: e500: Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
@ 2016-08-28 17:14   ` SF Markus Elfring
  2016-08-28 17:15   ` [PATCH 3/6] KVM: PPC: e500: Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:14 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 17:34:46 +0200

The kfree() function was called in two cases by the
kvm_vcpu_ioctl_config_tlb() function during error handling
even if the passed data structure element contained a null pointer.

* Split a condition check for memory allocation failures.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 26f3737..b65a894 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -785,35 +785,39 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 
 	ret = get_user_pages_fast(cfg->array, num_pages, 1, pages);
 	if (ret < 0)
-		goto err_pages;
+		goto free_pages;
 
 	if (ret != num_pages) {
 		num_pages = ret;
 		ret = -EFAULT;
-		goto err_put_page;
+		goto put_pages;
 	}
 
 	virt = vmap(pages, num_pages, VM_MAP, PAGE_KERNEL);
 	if (!virt) {
 		ret = -ENOMEM;
-		goto err_put_page;
+		goto put_pages;
 	}
 
 	privs[0] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[0],
 			   GFP_KERNEL);
+	if (!privs[0]) {
+		ret = -ENOMEM;
+		goto put_pages;
+	}
+
 	privs[1] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[1],
 			   GFP_KERNEL);
-
-	if (!privs[0] || !privs[1]) {
+	if (!privs[1]) {
 		ret = -ENOMEM;
-		goto err_privs;
+		goto free_privs_first;
 	}
 
 	g2h_bitmap = kzalloc(sizeof(u64) * params.tlb_sizes[1],
 	                     GFP_KERNEL);
 	if (!g2h_bitmap) {
 		ret = -ENOMEM;
-		goto err_privs;
+		goto free_privs_second;
 	}
 
 	free_gtlb(vcpu_e500);
@@ -845,16 +849,14 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 
 	kvmppc_recalc_tlb1map_range(vcpu_e500);
 	return 0;
-
-err_privs:
-	kfree(privs[0]);
+ free_privs_second:
 	kfree(privs[1]);
-
-err_put_page:
+ free_privs_first:
+	kfree(privs[0]);
+ put_pages:
 	for (i = 0; i < num_pages; i++)
 		put_page(pages[i]);
-
-err_pages:
+ free_pages:
 	kfree(pages);
 	return ret;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] KVM: PPC: e500: Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb()
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
  2016-08-28 17:12   ` [PATCH 1/6] KVM: PPC: e500: Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
  2016-08-28 17:14   ` [PATCH 2/6] KVM: PPC: e500: Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection SF Markus Elfring
@ 2016-08-28 17:15   ` SF Markus Elfring
  2016-08-28 17:16   ` [PATCH 4/6] KVM: PPC: e500: Replace kzalloc() calls by kcalloc() in two functions SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:15 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 17:37:10 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index b65a894..e9c19e9 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -743,7 +743,7 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 	char *virt;
 	struct page **pages;
 	struct tlbe_priv *privs[2] = {};
-	u64 *g2h_bitmap = NULL;
+	u64 *g2h_bitmap;
 	size_t array_len;
 	u32 sets;
 	int num_pages, ret, i;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] KVM: PPC: e500: Replace kzalloc() calls by kcalloc() in two functions
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-28 17:15   ` [PATCH 3/6] KVM: PPC: e500: Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
@ 2016-08-28 17:16   ` SF Markus Elfring
  2016-08-28 17:18   ` [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:16 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 18:30:38 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kcalloc".

  Suggested-by: Paolo Bonzini <pbonzini@redhat.com>

  This issue was detected also by using the Coccinelle software.

* 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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index e9c19e9..2be2afc4 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -799,22 +799,21 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu,
 		goto put_pages;
 	}
 
-	privs[0] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[0],
-			   GFP_KERNEL);
+	privs[0] = kcalloc(params.tlb_sizes[0], sizeof(*privs[0]), GFP_KERNEL);
 	if (!privs[0]) {
 		ret = -ENOMEM;
 		goto put_pages;
 	}
 
-	privs[1] = kzalloc(sizeof(struct tlbe_priv) * params.tlb_sizes[1],
-			   GFP_KERNEL);
+	privs[1] = kcalloc(params.tlb_sizes[1], sizeof(*privs[1]), GFP_KERNEL);
 	if (!privs[1]) {
 		ret = -ENOMEM;
 		goto free_privs_first;
 	}
 
-	g2h_bitmap = kzalloc(sizeof(u64) * params.tlb_sizes[1],
-	                     GFP_KERNEL);
+	g2h_bitmap = kcalloc(params.tlb_sizes[1],
+			     sizeof(*g2h_bitmap),
+			     GFP_KERNEL);
 	if (!g2h_bitmap) {
 		ret = -ENOMEM;
 		goto free_privs_second;
@@ -929,20 +928,20 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 	vcpu_e500->gtlb_offset[0] = 0;
 	vcpu_e500->gtlb_offset[1] = KVM_E500_TLB0_SIZE;
 
-	vcpu_e500->gtlb_priv[0] = kzalloc(sizeof(struct tlbe_ref) *
-					  vcpu_e500->gtlb_params[0].entries,
+	vcpu_e500->gtlb_priv[0] = kcalloc(vcpu_e500->gtlb_params[0].entries,
+					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[0])
 		goto err;
 
-	vcpu_e500->gtlb_priv[1] = kzalloc(sizeof(struct tlbe_ref) *
-					  vcpu_e500->gtlb_params[1].entries,
+	vcpu_e500->gtlb_priv[1] = kcalloc(vcpu_e500->gtlb_params[1].entries,
+					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[1])
 		goto err;
 
-	vcpu_e500->g2h_tlb1_map = kzalloc(sizeof(u64) *
-					  vcpu_e500->gtlb_params[1].entries,
+	vcpu_e500->g2h_tlb1_map = kcalloc(vcpu_e500->gtlb_params[1].entries,
+					  sizeof(*vcpu_e500->g2h_tlb1_map),
 					  GFP_KERNEL);
 	if (!vcpu_e500->g2h_tlb1_map)
 		goto err;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init()
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-28 17:16   ` [PATCH 4/6] KVM: PPC: e500: Replace kzalloc() calls by kcalloc() in two functions SF Markus Elfring
@ 2016-08-28 17:18   ` SF Markus Elfring
  2016-08-28 17:46     ` Julia Lawall
  2016-08-28 17:19   ` [PATCH 6/6] KVM: PPC: e500: Rename jump labels " SF Markus Elfring
  2016-09-12  0:54   ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations Paul Mackerras
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:18 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 18:40:08 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 2be2afc4..0a2eeb1 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -905,8 +905,6 @@ static int vcpu_mmu_init(struct kvm_vcpu *vcpu,
 int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 {
 	struct kvm_vcpu *vcpu = &vcpu_e500->vcpu;
-	int entry_size = sizeof(struct kvm_book3e_206_tlb_entry);
-	int entries = KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE;
 
 	if (e500_mmu_host_init(vcpu_e500))
 		goto err;
@@ -921,7 +919,10 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 	vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE;
 	vcpu_e500->gtlb_params[1].sets = 1;
 
-	vcpu_e500->gtlb_arch = kmalloc(entries * entry_size, GFP_KERNEL);
+	vcpu_e500->gtlb_arch = kmalloc_array(KVM_E500_TLB0_SIZE +
+					     KVM_E500_TLB1_SIZE,
+					     sizeof(*vcpu_e500->gtlb_arch),
+					     GFP_KERNEL);
 	if (!vcpu_e500->gtlb_arch)
 		return -ENOMEM;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] KVM: PPC: e500: Rename jump labels in kvmppc_e500_tlb_init()
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-08-28 17:18   ` [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init() SF Markus Elfring
@ 2016-08-28 17:19   ` SF Markus Elfring
  2016-08-28 17:48     ` Julia Lawall
  2016-09-11 23:25     ` Paul Mackerras
  2016-09-12  0:54   ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations Paul Mackerras
  6 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-28 17:19 UTC (permalink / raw)
  To: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 28 Aug 2016 18:45:26 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kvm/e500_mmu.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 0a2eeb1..da8f22b 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -933,26 +933,25 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[0])
-		goto err;
+		goto free_vcpu;
 
 	vcpu_e500->gtlb_priv[1] = kcalloc(vcpu_e500->gtlb_params[1].entries,
 					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[1])
-		goto err;
+		goto free_vcpu;
 
 	vcpu_e500->g2h_tlb1_map = kcalloc(vcpu_e500->gtlb_params[1].entries,
 					  sizeof(*vcpu_e500->g2h_tlb1_map),
 					  GFP_KERNEL);
 	if (!vcpu_e500->g2h_tlb1_map)
-		goto err;
+		goto free_vcpu;
 
 	vcpu_mmu_init(vcpu, vcpu_e500->gtlb_params);
 
 	kvmppc_recalc_tlb1map_range(vcpu_e500);
 	return 0;
-
-err:
+ free_vcpu:
 	free_gtlb(vcpu_e500);
 	return -1;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init()
  2016-08-28 17:18   ` [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init() SF Markus Elfring
@ 2016-08-28 17:46     ` Julia Lawall
  0 siblings, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-08-28 17:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář,
	LKML, kernel-janitors



On Sun, 28 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Aug 2016 18:40:08 +0200
>
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
>
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/powerpc/kvm/e500_mmu.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
> index 2be2afc4..0a2eeb1 100644
> --- a/arch/powerpc/kvm/e500_mmu.c
> +++ b/arch/powerpc/kvm/e500_mmu.c
> @@ -905,8 +905,6 @@ static int vcpu_mmu_init(struct kvm_vcpu *vcpu,
>  int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
>  {
>  	struct kvm_vcpu *vcpu = &vcpu_e500->vcpu;
> -	int entry_size = sizeof(struct kvm_book3e_206_tlb_entry);
> -	int entries = KVM_E500_TLB0_SIZE + KVM_E500_TLB1_SIZE;
>
>  	if (e500_mmu_host_init(vcpu_e500))
>  		goto err;
> @@ -921,7 +919,10 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
>  	vcpu_e500->gtlb_params[1].ways = KVM_E500_TLB1_SIZE;
>  	vcpu_e500->gtlb_params[1].sets = 1;
>
> -	vcpu_e500->gtlb_arch = kmalloc(entries * entry_size, GFP_KERNEL);
> +	vcpu_e500->gtlb_arch = kmalloc_array(KVM_E500_TLB0_SIZE +
> +					     KVM_E500_TLB1_SIZE,
> +					     sizeof(*vcpu_e500->gtlb_arch),
> +					     GFP_KERNEL);

There are changes here that are not mentioned in the commit log.

julia

>  	if (!vcpu_e500->gtlb_arch)
>  		return -ENOMEM;
>
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/6] KVM: PPC: e500: Rename jump labels in kvmppc_e500_tlb_init()
  2016-08-28 17:19   ` [PATCH 6/6] KVM: PPC: e500: Rename jump labels " SF Markus Elfring
@ 2016-08-28 17:48     ` Julia Lawall
  2016-09-11 23:25     ` Paul Mackerras
  1 sibling, 0 replies; 1373+ messages in thread
From: Julia Lawall @ 2016-08-28 17:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Paul Mackerras, Radim Krčmář,
	LKML, kernel-janitors



On Sun, 28 Aug 2016, SF Markus Elfring wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Aug 2016 18:45:26 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/powerpc/kvm/e500_mmu.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
> index 0a2eeb1..da8f22b 100644
> --- a/arch/powerpc/kvm/e500_mmu.c
> +++ b/arch/powerpc/kvm/e500_mmu.c
> @@ -933,26 +933,25 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
>  					  sizeof(struct tlbe_ref),
>  					  GFP_KERNEL);
>  	if (!vcpu_e500->gtlb_priv[0])
> -		goto err;
> +		goto free_vcpu;
>
>  	vcpu_e500->gtlb_priv[1] = kcalloc(vcpu_e500->gtlb_params[1].entries,
>  					  sizeof(struct tlbe_ref),
>  					  GFP_KERNEL);
>  	if (!vcpu_e500->gtlb_priv[1])
> -		goto err;
> +		goto free_vcpu;
>
>  	vcpu_e500->g2h_tlb1_map = kcalloc(vcpu_e500->gtlb_params[1].entries,
>  					  sizeof(*vcpu_e500->g2h_tlb1_map),
>  					  GFP_KERNEL);
>  	if (!vcpu_e500->g2h_tlb1_map)
> -		goto err;
> +		goto free_vcpu;
>
>  	vcpu_mmu_init(vcpu, vcpu_e500->gtlb_params);
>
>  	kvmppc_recalc_tlb1map_range(vcpu_e500);
>  	return 0;
> -
> -err:
> + free_vcpu:
>  	free_gtlb(vcpu_e500);
>  	return -1;

I doubt that -1 is the best return value.  One could guess that it should
be -ENOMEM.  But see what the call sites expect.

julia

>  }
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] PowerPC: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (68 preceding siblings ...)
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-08-29 11:00 ` SF Markus Elfring
  2016-08-29 11:00 ` SF Markus Elfring
                   ` (25 subsequent siblings)
  95 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:00 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:44:22 +0200

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

Markus Elfring (5):
  Use kmalloc_array() in mpic_init()
  Use kmalloc_array() in ppc4xx_setup_msi_irqs()
  Use kmalloc_array() in hsta_msi_probe()
  Rename jump labels in hsta_msi_probe()
  Move three assignments in hsta_msi_probe()

 arch/powerpc/sysdev/mpic.c            |  5 +++--
 arch/powerpc/sysdev/ppc4xx_hsta_msi.c | 26 +++++++++++++-------------
 arch/powerpc/sysdev/ppc4xx_msi.c      |  4 +++-
 3 files changed, 19 insertions(+), 16 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] PowerPC: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (69 preceding siblings ...)
  2016-08-29 11:00 ` [PATCH 0/5] PowerPC: Fine-tuning for three " SF Markus Elfring
@ 2016-08-29 11:00 ` SF Markus Elfring
  2016-08-29 11:07   ` [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init() SF Markus Elfring
                     ` (4 more replies)
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                   ` (24 subsequent siblings)
  95 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:00 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:44:22 +0200

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

Markus Elfring (5):
  Use kmalloc_array() in mpic_init()
  Use kmalloc_array() in ppc4xx_setup_msi_irqs()
  Use kmalloc_array() in hsta_msi_probe()
  Rename jump labels in hsta_msi_probe()
  Move three assignments in hsta_msi_probe()

 arch/powerpc/sysdev/mpic.c            |  5 +++--
 arch/powerpc/sysdev/ppc4xx_hsta_msi.c | 26 +++++++++++++-------------
 arch/powerpc/sysdev/ppc4xx_msi.c      |  4 +++-
 3 files changed, 19 insertions(+), 16 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init()
  2016-08-29 11:00 ` SF Markus Elfring
@ 2016-08-29 11:07   ` SF Markus Elfring
  2016-08-29 11:09   ` [PATCH 2/5] powerpc-MSI: Use kmalloc_array() in ppc4xx_setup_msi_irqs() SF Markus Elfring
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:07 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:00:11 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/sysdev/mpic.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 7de45b2..5e79c0d24 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -1641,8 +1641,9 @@ void __init mpic_init(struct mpic *mpic)
 
 #ifdef CONFIG_PM
 	/* allocate memory to save mpic state */
-	mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
-				  GFP_KERNEL);
+	mpic->save_data = kmalloc_array(mpic->num_sources,
+					sizeof(*mpic->save_data),
+					GFP_KERNEL);
 	BUG_ON(mpic->save_data == NULL);
 #endif
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] powerpc-MSI: Use kmalloc_array() in ppc4xx_setup_msi_irqs()
  2016-08-29 11:00 ` SF Markus Elfring
  2016-08-29 11:07   ` [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init() SF Markus Elfring
@ 2016-08-29 11:09   ` SF Markus Elfring
  2016-08-29 11:10   ` [PATCH 3/5] powerpc-MSI-HSTA: Use kmalloc_array() in hsta_msi_probe() SF Markus Elfring
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:09 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:11:24 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/sysdev/ppc4xx_msi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/ppc4xx_msi.c b/arch/powerpc/sysdev/ppc4xx_msi.c
index 8fb8061..0bd5e4b 100644
--- a/arch/powerpc/sysdev/ppc4xx_msi.c
+++ b/arch/powerpc/sysdev/ppc4xx_msi.c
@@ -89,7 +89,9 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
 	if (type == PCI_CAP_ID_MSIX)
 		pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n");
 
-	msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int), GFP_KERNEL);
+	msi_data->msi_virqs = kmalloc_array(msi_irqs,
+					    sizeof(*msi_data->msi_virqs),
+					    GFP_KERNEL);
 	if (!msi_data->msi_virqs)
 		return -ENOMEM;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] powerpc-MSI-HSTA: Use kmalloc_array() in hsta_msi_probe()
  2016-08-29 11:00 ` SF Markus Elfring
  2016-08-29 11:07   ` [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init() SF Markus Elfring
  2016-08-29 11:09   ` [PATCH 2/5] powerpc-MSI: Use kmalloc_array() in ppc4xx_setup_msi_irqs() SF Markus Elfring
@ 2016-08-29 11:10   ` SF Markus Elfring
  2016-08-29 11:12   ` [PATCH 4/5] powerpc-MSI-HSTA: Rename jump labels " SF Markus Elfring
  2016-08-29 11:13   ` [PATCH 5/5] powerpc-MSI-HSTA: Move three assignments " SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:10 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:20:39 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/sysdev/ppc4xx_hsta_msi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
index 52a93dc..691db9a 100644
--- a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
+++ b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
@@ -156,7 +156,9 @@ static int hsta_msi_probe(struct platform_device *pdev)
 	if (ret)
 		goto out;
 
-	ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL);
+	ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count,
+						sizeof(*ppc4xx_hsta_msi.irq_map),
+						GFP_KERNEL);
 	if (!ppc4xx_hsta_msi.irq_map) {
 		ret = -ENOMEM;
 		goto out1;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] powerpc-MSI-HSTA: Rename jump labels in hsta_msi_probe()
  2016-08-29 11:00 ` SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-08-29 11:10   ` [PATCH 3/5] powerpc-MSI-HSTA: Use kmalloc_array() in hsta_msi_probe() SF Markus Elfring
@ 2016-08-29 11:12   ` SF Markus Elfring
  2016-08-29 11:13   ` [PATCH 5/5] powerpc-MSI-HSTA: Move three assignments " SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:12 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:22:19 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/sysdev/ppc4xx_hsta_msi.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
index 691db9a..3097ddd 100644
--- a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
+++ b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
@@ -154,14 +154,14 @@ static int hsta_msi_probe(struct platform_device *pdev)
 
 	ret = msi_bitmap_alloc(&ppc4xx_hsta_msi.bmp, irq_count, dev->of_node);
 	if (ret)
-		goto out;
+		goto unmap_io;
 
 	ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count,
 						sizeof(*ppc4xx_hsta_msi.irq_map),
 						GFP_KERNEL);
 	if (!ppc4xx_hsta_msi.irq_map) {
 		ret = -ENOMEM;
-		goto out1;
+		goto free_bitmap;
 	}
 
 	/* Setup a mapping from irq offsets to hardware irq numbers */
@@ -171,7 +171,7 @@ static int hsta_msi_probe(struct platform_device *pdev)
 		if (ppc4xx_hsta_msi.irq_map[irq] == NO_IRQ) {
 			dev_err(dev, "Unable to map IRQ\n");
 			ret = -EINVAL;
-			goto out2;
+			goto free_irq_map;
 		}
 	}
 
@@ -180,14 +180,11 @@ static int hsta_msi_probe(struct platform_device *pdev)
 		phb->controller_ops.teardown_msi_irqs = hsta_teardown_msi_irqs;
 	}
 	return 0;
-
-out2:
+ free_irq_map:
 	kfree(ppc4xx_hsta_msi.irq_map);
-
-out1:
+ free_bitmap:
 	msi_bitmap_free(&ppc4xx_hsta_msi.bmp);
-
-out:
+ unmap_io:
 	iounmap(ppc4xx_hsta_msi.data);
 	return ret;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] powerpc-MSI-HSTA: Move three assignments in hsta_msi_probe()
  2016-08-29 11:00 ` SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-08-29 11:12   ` [PATCH 4/5] powerpc-MSI-HSTA: Rename jump labels " SF Markus Elfring
@ 2016-08-29 11:13   ` SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-08-29 11:13 UTC (permalink / raw)
  To: linuxppc-dev, Adam Buchbinder, Andrew Donnellan,
	Benjamin Herrenschmidt, Marc Zyngier, Michael Ellerman,
	Paul Mackerras, Scott Wood, Sudeep Holla, Thomas Gleixner
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 29 Aug 2016 11:30:48 +0200

Move the assignments for three data structure members to the end
so that they will only be performed if the desired resource allocations
succeeded by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/sysdev/ppc4xx_hsta_msi.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
index 3097ddd..57014ce 100644
--- a/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
+++ b/arch/powerpc/sysdev/ppc4xx_hsta_msi.c
@@ -143,10 +143,7 @@ static int hsta_msi_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	ppc4xx_hsta_msi.dev = dev;
-	ppc4xx_hsta_msi.address = mem->start;
 	ppc4xx_hsta_msi.data = ioremap(mem->start, resource_size(mem));
-	ppc4xx_hsta_msi.irq_count = irq_count;
 	if (!ppc4xx_hsta_msi.data) {
 		dev_err(dev, "Unable to map memory\n");
 		return -ENOMEM;
@@ -179,6 +176,10 @@ static int hsta_msi_probe(struct platform_device *pdev)
 		phb->controller_ops.setup_msi_irqs = hsta_setup_msi_irqs;
 		phb->controller_ops.teardown_msi_irqs = hsta_teardown_msi_irqs;
 	}
+
+	ppc4xx_hsta_msi.dev = dev;
+	ppc4xx_hsta_msi.address = mem->start;
+	ppc4xx_hsta_msi.irq_count = irq_count;
 	return 0;
  free_irq_map:
 	kfree(ppc4xx_hsta_msi.irq_map);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 00/17] s390/debug: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (70 preceding siblings ...)
  2016-08-29 11:00 ` SF Markus Elfring
@ 2016-09-03 12:04 ` SF Markus Elfring
  2016-09-03 12:10   ` [PATCH 01/17] s390/debug: Use kmalloc_array() in debug_areas_alloc() SF Markus Elfring
                     ` (17 more replies)
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
                   ` (23 subsequent siblings)
  95 siblings, 18 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:04 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 13:54:32 +0200

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

Markus Elfring (17):
  Use kmalloc_array() in debug_areas_alloc()
  Delete unnecessary braces
  Add some spaces for better code readability
  Rename jump labels in debug_areas_alloc()
  Fix jump targets in debug_info_alloc()
  Rename jump labels in debug_info_copy()
  Rename jump labels in debug_open()
  Fix a jump target in debug_register_mode()
  Return directly if a null pointer was passed to debug_unregister()
  Delete an unnecessary initialisation in debug_prolog_level_fn()
  Fix indentation in 13 functions
  Use memdup_user() rather than duplicating its implementation
  Improve a size determination in debug_open()
  Improve a size determination in debug_sprintf_format_fn()
  Improve a size determination in debug_raw_header_fn()
  Improve determination of sizes in debug_info_alloc()
  Improve another size determination in debug_info_alloc()

 arch/s390/kernel/debug.c | 433 ++++++++++++++++++++++-------------------------
 1 file changed, 204 insertions(+), 229 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/17] s390/debug: Use kmalloc_array() in debug_areas_alloc()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-03 12:10   ` SF Markus Elfring
  2016-09-03 12:13   ` [PATCH 02/17] s390/debug: Delete unnecessary braces SF Markus Elfring
                     ` (16 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:10 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 14:41:01 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index aa12de7..8e2be30 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -196,14 +196,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 	debug_entry_t*** areas;
 	int i,j;
 
-	areas = kmalloc(nr_areas *
-					sizeof(debug_entry_t**),
-					GFP_KERNEL);
+	areas = kmalloc_array(nr_areas, sizeof(*areas), GFP_KERNEL);
 	if (!areas)
 		goto fail_malloc_areas;
 	for (i = 0; i < nr_areas; i++) {
-		areas[i] = kmalloc(pages_per_area *
-				sizeof(debug_entry_t*),GFP_KERNEL);
+		areas[i] = kmalloc_array(pages_per_area,
+					 sizeof(*areas[i]),
+					 GFP_KERNEL);
 		if (!areas[i]) {
 			goto fail_malloc_areas2;
 		}
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/17] s390/debug: Delete unnecessary braces
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-03 12:10   ` [PATCH 01/17] s390/debug: Use kmalloc_array() in debug_areas_alloc() SF Markus Elfring
@ 2016-09-03 12:13   ` SF Markus Elfring
  2016-09-03 12:14   ` [PATCH 03/17] s390/debug: Add some spaces for better code readability SF Markus Elfring
                     ` (15 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:13 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 15:06:06 +0200

Do not use curly brackets at some source code places
where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 48 ++++++++++++++++--------------------------------
 1 file changed, 16 insertions(+), 32 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 8e2be30..ddfc5e4 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -203,15 +203,13 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 		areas[i] = kmalloc_array(pages_per_area,
 					 sizeof(*areas[i]),
 					 GFP_KERNEL);
-		if (!areas[i]) {
+		if (!areas[i])
 			goto fail_malloc_areas2;
-		}
 		for(j = 0; j < pages_per_area; j++) {
 			areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
 			if(!areas[i][j]) {
-				for(j--; j >=0 ; j--) {
+				for (j--; j >= 0; j--)
 					kfree(areas[i][j]);
-				}
 				kfree(areas[i]);
 				goto fail_malloc_areas2;
 			}
@@ -221,9 +219,8 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 
 fail_malloc_areas2:
 	for(i--; i >= 0; i--){
-		for(j=0; j < pages_per_area;j++){
+		for (j = 0; j < pages_per_area; j++)
 			kfree(areas[i][j]);
-		}
 		kfree(areas[i]);
 	}
 	kfree(areas);
@@ -303,9 +300,8 @@ debug_areas_free(debug_info_t* db_info)
 	if(!db_info->areas)
 		return;
 	for (i = 0; i < db_info->nr_areas; i++) {
-		for(j = 0; j < db_info->pages_per_area; j++) {
+		for (j = 0; j < db_info->pages_per_area; j++)
 			kfree(db_info->areas[i][j]);
-		}
 		kfree(db_info->areas[i]);
 	}
 	kfree(db_info->areas);
@@ -396,11 +392,9 @@ debug_info_copy(debug_info_t* in, int mode)
 	if (mode == NO_AREAS)
                 goto out;
 
-        for(i = 0; i < in->nr_areas; i++){
-		for(j = 0; j < in->pages_per_area; j++) {
+	for (i = 0; i < in->nr_areas; i++)
+		for (j = 0; j < in->pages_per_area; j++)
 			memcpy(rc->areas[i][j], in->areas[i][j],PAGE_SIZE);
-		}
-        }
 out:
         spin_unlock_irqrestore(&in->lock, flags);
         return rc;
@@ -711,9 +705,8 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
         debug_register_view(rc, &debug_flush_view);
 	debug_register_view(rc, &debug_pages_view);
 out:
-        if (!rc){
+	if (!rc)
 		pr_err("Registering debug feature %s failed\n", name);
-        }
 	mutex_unlock(&debug_mutex);
 	return rc;
 }
@@ -1005,10 +998,9 @@ debug_count_numargs(char *string)
 {
 	int numargs=0;
 
-	while(*string) {
+	while (*string)
 		if(*string++=='%')
 			numargs++;
-	}
 	return(numargs);
 }
 
@@ -1114,10 +1106,9 @@ debug_register_view(debug_info_t * id, struct debug_view *view)
 		goto out;
 	}
 	spin_lock_irqsave(&id->lock, flags);
-	for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
+	for (i = 0; i < DEBUG_MAX_VIEWS; i++)
 		if (!id->views[i])
 			break;
-	}
 	if (i == DEBUG_MAX_VIEWS) {
 		pr_err("Registering view %s/%s would exceed the maximum "
 		       "number of views %i\n", id->name, view->name, i);
@@ -1148,10 +1139,9 @@ debug_unregister_view(debug_info_t * id, struct debug_view *view)
 	if (!id)
 		goto out;
 	spin_lock_irqsave(&id->lock, flags);
-	for (i = 0; i < DEBUG_MAX_VIEWS; i++) {
+	for (i = 0; i < DEBUG_MAX_VIEWS; i++)
 		if (id->views[i] == view)
 			break;
-	}
 	if (i == DEBUG_MAX_VIEWS)
 		rc = -1;
 	else {
@@ -1193,9 +1183,8 @@ debug_get_uint(char *buf)
 
 	buf = skip_spaces(buf);
 	rc = simple_strtoul(buf, &buf, 10);
-	if(*buf){
+	if (*buf)
 		rc = -EINVAL;
-	}
 	return rc;
 }
 
@@ -1265,12 +1254,10 @@ debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf)
 {
 	int rc = 0;
 
-	if(id->level == DEBUG_OFF_LEVEL) {
+	if (id->level == DEBUG_OFF_LEVEL)
 		rc = sprintf(out_buf,"-\n");
-	}
-	else {
+	else
 		rc = sprintf(out_buf, "%i\n", id->level);
-	}
 	return rc;
 }
 
@@ -1336,16 +1323,14 @@ static void debug_flush(debug_info_t* id, int area)
                 memset(id->active_entries, 0, id->nr_areas * sizeof(int));
                 for (i = 0; i < id->nr_areas; i++) {
 			id->active_pages[i] = 0;
-			for(j = 0; j < id->pages_per_area; j++) {
+			for (j = 0; j < id->pages_per_area; j++)
                         	memset(id->areas[i][j], 0, PAGE_SIZE);
-			}
 		}
         } else if(area >= 0 && area < id->nr_areas) {
                 id->active_entries[area] = 0;
 		id->active_pages[area] = 0;
-		for(i = 0; i < id->pages_per_area; i++) {
+		for (i = 0; i < id->pages_per_area; i++)
                 	memset(id->areas[area][i],0,PAGE_SIZE);
-		}
         }
         spin_unlock_irqrestore(&id->lock,flags);
 }
@@ -1430,10 +1415,9 @@ debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
 {
 	int i, rc = 0;
 
-	for (i = 0; i < id->buf_size; i++) {
+	for (i = 0; i < id->buf_size; i++)
                 rc += sprintf(out_buf + rc, "%02x ",
                               ((unsigned char *) in_buf)[i]);
-        }
 	rc += sprintf(out_buf + rc, "| ");
 	for (i = 0; i < id->buf_size; i++) {
 		unsigned char c = in_buf[i];
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/17] s390/debug: Add some spaces for better code readability
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-03 12:10   ` [PATCH 01/17] s390/debug: Use kmalloc_array() in debug_areas_alloc() SF Markus Elfring
  2016-09-03 12:13   ` [PATCH 02/17] s390/debug: Delete unnecessary braces SF Markus Elfring
@ 2016-09-03 12:14   ` SF Markus Elfring
  2016-09-03 12:16   ` [PATCH 04/17] s390/debug: Rename jump labels in debug_areas_alloc() SF Markus Elfring
                     ` (14 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:14 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 16:00:39 +0200

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 177 +++++++++++++++++++++++++----------------------
 1 file changed, 93 insertions(+), 84 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index ddfc5e4..5bb9108 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -205,9 +205,9 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 					 GFP_KERNEL);
 		if (!areas[i])
 			goto fail_malloc_areas2;
-		for(j = 0; j < pages_per_area; j++) {
+		for (j = 0; j < pages_per_area; j++) {
 			areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
-			if(!areas[i][j]) {
+			if (!areas[i][j]) {
 				for (j--; j >= 0; j--)
 					kfree(areas[i][j]);
 				kfree(areas[i]);
@@ -218,7 +218,7 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 	return areas;
 
 fail_malloc_areas2:
-	for(i--; i >= 0; i--){
+	for (i--; i >= 0; i--) {
 		for (j = 0; j < pages_per_area; j++)
 			kfree(areas[i][j]);
 		kfree(areas[i]);
@@ -271,7 +271,7 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
 	rc->entry_size     = sizeof(debug_entry_t) + buf_size;
 	strlcpy(rc->name, name, sizeof(rc->name));
 	memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
-	memset(rc->debugfs_entries, 0 ,DEBUG_MAX_VIEWS *
+	memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS *
 		sizeof(struct dentry*));
 	atomic_set(&(rc->ref_count), 0);
 
@@ -297,7 +297,7 @@ debug_areas_free(debug_info_t* db_info)
 {
 	int i,j;
 
-	if(!db_info->areas)
+	if (!db_info->areas)
 		return;
 	for (i = 0; i < db_info->nr_areas; i++) {
 		for (j = 0; j < db_info->pages_per_area; j++)
@@ -334,7 +334,7 @@ debug_info_create(const char *name, int pages_per_area, int nr_areas,
 
         rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size,
 				DEBUG_DEFAULT_LEVEL, ALL_AREAS);
-        if(!rc) 
+	if (!rc)
 		goto out;
 
 	rc->mode = mode & ~S_IFMT;
@@ -378,10 +378,10 @@ debug_info_copy(debug_info_t* in, int mode)
 		rc = debug_info_alloc(in->name, in->pages_per_area,
 			in->nr_areas, in->buf_size, in->level, mode);
 		spin_lock_irqsave(&in->lock, flags);
-		if(!rc)
+		if (!rc)
 			goto out;
 		/* has something changed in the meantime ? */
-		if((rc->pages_per_area == in->pages_per_area) &&
+		if ((rc->pages_per_area == in->pages_per_area) &&
 		   (rc->nr_areas == in->nr_areas)) {
 			break;
 		}
@@ -394,7 +394,7 @@ debug_info_copy(debug_info_t* in, int mode)
 
 	for (i = 0; i < in->nr_areas; i++)
 		for (j = 0; j < in->pages_per_area; j++)
-			memcpy(rc->areas[i][j], in->areas[i][j],PAGE_SIZE);
+			memcpy(rc->areas[i][j], in->areas[i][j], PAGE_SIZE);
 out:
         spin_unlock_irqrestore(&in->lock, flags);
         return rc;
@@ -431,12 +431,14 @@ debug_info_put(debug_info_t *db_info)
 			debugfs_remove(db_info->debugfs_entries[i]);
 		}
 		debugfs_remove(db_info->debugfs_root_entry);
-		if(db_info == debug_area_first)
+		if (db_info == debug_area_first)
 			debug_area_first = db_info->next;
-		if(db_info == debug_area_last)
+		if (db_info == debug_area_last)
 			debug_area_last = db_info->prev;
-		if(db_info->prev) db_info->prev->next = db_info->next;
-		if(db_info->next) db_info->next->prev = db_info->prev;
+		if (db_info->prev)
+			db_info->prev->next = db_info->next;
+		if (db_info->next)
+			db_info->next->prev = db_info->prev;
 		debug_info_free(db_info);
 	}
 }
@@ -453,10 +455,13 @@ debug_format_entry(file_private_info_t *p_info)
 	struct debug_view *view = p_info->view;
 	debug_entry_t *act_entry;
 	size_t len = 0;
-	if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
+
+	if (p_info->act_entry == DEBUG_PROLOG_ENTRY) {
 		/* print prolog */
         	if (view->prolog_proc)
-                	len += view->prolog_proc(id_snap,view,p_info->temp_buf);
+			len += view->prolog_proc(id_snap,
+						 view,
+						 p_info->temp_buf);
 		goto out;
 	}
 	if (!id_snap->areas) /* this is true, if we have a prolog only view */
@@ -487,25 +492,25 @@ debug_next_entry(file_private_info_t *p_info)
 	debug_info_t *id;
 
 	id = p_info->debug_info_snap;
-	if(p_info->act_entry == DEBUG_PROLOG_ENTRY){
+	if (p_info->act_entry == DEBUG_PROLOG_ENTRY) {
 		p_info->act_entry = 0;
 		p_info->act_page  = 0;
 		goto out;
 	}
-	if(!id->areas)
+	if (!id->areas)
 		return 1;
 	p_info->act_entry += id->entry_size;
 	/* switch to next page, if we reached the end of the page  */
-	if (p_info->act_entry > (PAGE_SIZE - id->entry_size)){
+	if (p_info->act_entry > (PAGE_SIZE - id->entry_size)) {
 		/* next page */
 		p_info->act_entry = 0;
 		p_info->act_page += 1;
-		if((p_info->act_page % id->pages_per_area) == 0) {
+		if ((p_info->act_page % id->pages_per_area) == 0) {
 			/* next area */
         		p_info->act_area++;
 			p_info->act_page=0;
 		}
-        	if(p_info->act_area >= id->nr_areas)
+		if (p_info->act_area >= id->nr_areas)
 			return 1;
 	}
 out:
@@ -531,10 +536,10 @@ debug_output(struct file *file,		/* file descriptor */
 	p_info = ((file_private_info_t *) file->private_data);
 	if (*offset != p_info->offset) 
 		return -EPIPE;
-	if(p_info->act_area >= p_info->debug_info_snap->nr_areas)
+	if (p_info->act_area >= p_info->debug_info_snap->nr_areas)
 		return 0;
 	entry_offset = p_info->act_entry_offset;
-	while(count < len){
+	while (count < len) {
 		int formatted_line_size;
 		int formatted_line_residue;
 		int user_buf_residue;
@@ -544,16 +549,16 @@ debug_output(struct file *file,		/* file descriptor */
 		formatted_line_residue = formatted_line_size - entry_offset;
 		user_buf_residue = len-count;
 		copy_size = min(user_buf_residue, formatted_line_residue);
-		if(copy_size){
+		if (copy_size) {
 			if (copy_to_user(user_buf + count, p_info->temp_buf
 					+ entry_offset, copy_size))
 				return -EFAULT;
 			count += copy_size;
 			entry_offset += copy_size;
 		}
-		if(copy_size == formatted_line_residue){
+		if (copy_size == formatted_line_residue) {
 			entry_offset = 0;
-			if(debug_next_entry(p_info))
+			if (debug_next_entry(p_info))
 				goto out;
 		}
 	}
@@ -624,20 +629,20 @@ found:
 	/* To copy all the areas is only needed, if we have a view which  */
 	/* formats the debug areas. */
 
-	if(!debug_info->views[i]->format_proc &&
-		!debug_info->views[i]->header_proc){
+	if (!debug_info->views[i]->format_proc &&
+		!debug_info->views[i]->header_proc) {
 		debug_info_snapshot = debug_info_copy(debug_info, NO_AREAS);
 	} else {
 		debug_info_snapshot = debug_info_copy(debug_info, ALL_AREAS);
 	}
 
-	if(!debug_info_snapshot){
+	if (!debug_info_snapshot) {
 		rc = -ENOMEM;
 		goto out;
 	}
 	p_info = kmalloc(sizeof(file_private_info_t),
 						GFP_KERNEL);
-	if(!p_info){
+	if (!p_info) {
 		debug_info_free(debug_info_snapshot);
 		rc = -ENOMEM;
 		goto out;
@@ -669,7 +674,7 @@ debug_close(struct inode *inode, struct file *file)
 {
 	file_private_info_t *p_info;
 	p_info = (file_private_info_t *) file->private_data;
-	if(p_info->debug_info_snap)
+	if (p_info->debug_info_snap)
 		debug_info_free(p_info->debug_info_snap);
 	debug_info_put(p_info->debug_info_org);
 	kfree(file->private_data);
@@ -699,7 +704,7 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
         /* create new debug_info */
 
 	rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
-	if(!rc) 
+	if (!rc)
 		goto out;
 	debug_register_view(rc, &debug_level_view);
         debug_register_view(rc, &debug_flush_view);
@@ -754,11 +759,11 @@ debug_set_size(debug_info_t* id, int nr_areas, int pages_per_area)
 {
 	unsigned long flags;
 	debug_entry_t *** new_areas;
-	int rc=0;
+	int rc = 0;
 
-	if(!id || (nr_areas <= 0) || (pages_per_area < 0))
+	if (!id || (nr_areas <= 0) || (pages_per_area < 0))
 		return -EINVAL;
-	if(pages_per_area > 0){
+	if (pages_per_area > 0) {
 		new_areas = debug_areas_alloc(pages_per_area, nr_areas);
 		if(!new_areas) {
 			pr_info("Allocating memory for %i pages failed\n",
@@ -769,16 +774,16 @@ debug_set_size(debug_info_t* id, int nr_areas, int pages_per_area)
 	} else {
 		new_areas = NULL;
 	}
-	spin_lock_irqsave(&id->lock,flags);
+	spin_lock_irqsave(&id->lock, flags);
 	debug_areas_free(id);
 	id->areas = new_areas;
 	id->nr_areas = nr_areas;
 	id->pages_per_area = pages_per_area;
 	id->active_area = 0;
-	memset(id->active_entries,0,sizeof(int)*id->nr_areas);
-	memset(id->active_pages, 0, sizeof(int)*id->nr_areas);
-	spin_unlock_irqrestore(&id->lock,flags);
-	pr_info("%s: set new size (%i pages)\n" ,id->name, pages_per_area);
+	memset(id->active_entries, 0, sizeof(int) * id->nr_areas);
+	memset(id->active_pages, 0, sizeof(int) * id->nr_areas);
+	spin_unlock_irqrestore(&id->lock, flags);
+	pr_info("%s: set new size (%i pages)\n", id->name, pages_per_area);
 out:
 	return rc;
 }
@@ -794,17 +799,17 @@ debug_set_level(debug_info_t* id, int new_level)
 	unsigned long flags;
 	if(!id)
 		return;	
-	spin_lock_irqsave(&id->lock,flags);
-        if(new_level == DEBUG_OFF_LEVEL){
+	spin_lock_irqsave(&id->lock, flags);
+	if (new_level == DEBUG_OFF_LEVEL) {
                 id->level = DEBUG_OFF_LEVEL;
-		pr_info("%s: switched off\n",id->name);
+		pr_info("%s: switched off\n", id->name);
         } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
 		pr_info("%s: level %i is out of range (%i - %i)\n",
                         id->name, new_level, 0, DEBUG_MAX_LEVEL);
         } else {
                 id->level = new_level;
         }
-	spin_unlock_irqrestore(&id->lock,flags);
+	spin_unlock_irqrestore(&id->lock, flags);
 }
 EXPORT_SYMBOL(debug_set_level);
 
@@ -996,10 +1001,10 @@ EXPORT_SYMBOL(debug_exception_common);
 static inline int
 debug_count_numargs(char *string)
 {
-	int numargs=0;
+	int numargs = 0;
 
 	while (*string)
-		if(*string++=='%')
+		if (*string++ == '%')
 			numargs++;
 	return(numargs);
 }
@@ -1019,7 +1024,7 @@ __debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
 
 	if (!debug_active || !id->areas)
 		return NULL;
-	numargs=debug_count_numargs(string);
+	numargs = debug_count_numargs(string);
 
 	if (debug_critical) {
 		if (!spin_trylock_irqsave(&id->lock, flags))
@@ -1027,11 +1032,13 @@ __debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
 	} else
 		spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
-	curr_event=(debug_sprintf_entry_t *) DEBUG_DATA(active);
+	curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active);
 	va_start(ap,string);
-	curr_event->string=string;
-	for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
-		curr_event->args[idx]=va_arg(ap,long);
+	curr_event->string = string;
+	for (idx = 0;
+	     idx < min(numargs, (int)(id->buf_size / sizeof(long)) - 1);
+	     idx++)
+		curr_event->args[idx] = va_arg(ap, long);
 	va_end(ap);
 	debug_finish_entry(id, active, level, 0);
 	spin_unlock_irqrestore(&id->lock, flags);
@@ -1056,7 +1063,7 @@ __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
 	if (!debug_active || !id->areas)
 		return NULL;
 
-	numargs=debug_count_numargs(string);
+	numargs = debug_count_numargs(string);
 
 	if (debug_critical) {
 		if (!spin_trylock_irqsave(&id->lock, flags))
@@ -1064,11 +1071,13 @@ __debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
 	} else
 		spin_lock_irqsave(&id->lock, flags);
 	active = get_active_entry(id);
-	curr_event=(debug_sprintf_entry_t *)DEBUG_DATA(active);
-	va_start(ap,string);
-	curr_event->string=string;
-	for(idx=0;idx<min(numargs,(int)(id->buf_size / sizeof(long))-1);idx++)
-		curr_event->args[idx]=va_arg(ap,long);
+	curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active);
+	va_start(ap, string);
+	curr_event->string = string;
+	for (idx = 0;
+	     idx < min(numargs, (int)(id->buf_size / sizeof(long)) - 1);
+	     idx++)
+		curr_event->args[idx] = va_arg(ap, long);
 	va_end(ap);
 	debug_finish_entry(id, active, level, 1);
 	spin_unlock_irqrestore(&id->lock, flags);
@@ -1214,26 +1223,26 @@ debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
 			size_t user_len, loff_t * offset)
 {
 	char *str;
-	int rc,new_pages;
+	int rc, new_pages;
 
 	if (user_len > 0x10000)
                 user_len = 0x10000;
-	if (*offset != 0){
+	if (*offset != 0) {
 		rc = -EPIPE;
 		goto out;
 	}
-	str = debug_get_user_string(user_buf,user_len);
-	if(IS_ERR(str)){
+	str = debug_get_user_string(user_buf, user_len);
+	if (IS_ERR(str)) {
 		rc = PTR_ERR(str);
 		goto out;
 	}
 	new_pages = debug_get_uint(str);
-	if(new_pages < 0){
+	if (new_pages < 0) {
 		rc = -EINVAL;
 		goto free_str;
 	}
-	rc = debug_set_size(id,id->nr_areas, new_pages);
-	if(rc != 0){
+	rc = debug_set_size(id, id->nr_areas, new_pages);
+	if (rc != 0) {
 		rc = -EINVAL;
 		goto free_str;
 	}
@@ -1271,27 +1280,27 @@ debug_input_level_fn(debug_info_t * id, struct debug_view *view,
 			size_t user_len, loff_t * offset)
 {
 	char *str;
-	int rc,new_level;
+	int rc, new_level;
 
 	if (user_len > 0x10000)
                 user_len = 0x10000;
-	if (*offset != 0){
+	if (*offset != 0) {
 		rc = -EPIPE;
 		goto out;
 	}
-	str = debug_get_user_string(user_buf,user_len);
-	if(IS_ERR(str)){
+	str = debug_get_user_string(user_buf, user_len);
+	if (IS_ERR(str)) {
 		rc = PTR_ERR(str);
 		goto out;
 	}
-	if(str[0] == '-'){
+	if (str[0] == '-') {
 		debug_set_level(id, DEBUG_OFF_LEVEL);
 		rc = user_len;
 		goto free_str;
 	} else {
 		new_level = debug_get_uint(str);
 	}
-	if(new_level < 0) {
+	if (new_level < 0) {
 		pr_warn("%s is not a valid level for a debug feature\n", str);
 		rc = -EINVAL;
 	} else {
@@ -1313,12 +1322,12 @@ out:
 static void debug_flush(debug_info_t* id, int area)
 {
         unsigned long flags;
-        int i,j;
+	int i, j;
 
-        if(!id || !id->areas)
+	if (!id || !id->areas)
                 return;
-        spin_lock_irqsave(&id->lock,flags);
-        if(area == DEBUG_FLUSH_ALL){
+	spin_lock_irqsave(&id->lock, flags);
+	if (area == DEBUG_FLUSH_ALL) {
                 id->active_area = 0;
                 memset(id->active_entries, 0, id->nr_areas * sizeof(int));
                 for (i = 0; i < id->nr_areas; i++) {
@@ -1326,13 +1335,13 @@ static void debug_flush(debug_info_t* id, int area)
 			for (j = 0; j < id->pages_per_area; j++)
                         	memset(id->areas[i][j], 0, PAGE_SIZE);
 		}
-        } else if(area >= 0 && area < id->nr_areas) {
+	} else if (area >= 0 && area < id->nr_areas) {
                 id->active_entries[area] = 0;
 		id->active_pages[area] = 0;
 		for (i = 0; i < id->pages_per_area; i++)
-                	memset(id->areas[area][i],0,PAGE_SIZE);
+			memset(id->areas[area][i], 0, PAGE_SIZE);
         }
-        spin_unlock_irqrestore(&id->lock,flags);
+	spin_unlock_irqrestore(&id->lock, flags);
 }
 
 /*
@@ -1349,15 +1358,15 @@ debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
 
 	if (user_len > 0x10000)
                 user_len = 0x10000;
-        if (*offset != 0){
+	if (*offset != 0) {
 		rc = -EPIPE;
                 goto out;
 	}
-        if (copy_from_user(input_buf, user_buf, 1)){
+	if (copy_from_user(input_buf, user_buf, 1)) {
                 rc = -EFAULT;
                 goto out;
         }
-        if(input_buf[0] == '-') { 
+	if (input_buf[0] == '-') {
                 debug_flush(id, DEBUG_FLUSH_ALL);
                 goto out;
         }
@@ -1386,7 +1395,7 @@ debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
         int rc;
 
 	rc = sizeof(debug_entry_t);
-	memcpy(out_buf,entry,sizeof(debug_entry_t));
+	memcpy(out_buf, entry, sizeof(debug_entry_t));
         return rc;
 }
 
@@ -1477,9 +1486,9 @@ debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
 	/* count of longs fit into one entry */
 	num_longs = id->buf_size /  sizeof(long); 
 
-	if(num_longs < 1)
+	if (num_longs < 1)
 		goto out; /* bufsize of entry too small */
-	if(num_longs == 1) {
+	if (num_longs == 1) {
 		/* no args, we use only the string */
 		strcpy(out_buf, curr_event->string);
 		rc = strlen(curr_event->string);
@@ -1489,9 +1498,9 @@ debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
 	/* number of arguments used for sprintf (without the format string) */
 	num_used_args   = min(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
 
-	memset(index,0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
+	memset(index, 0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
 
-	for(i = 0; i < num_used_args; i++)
+	for (i = 0; i < num_used_args; i++)
 		index[i] = i;
 
 	rc =  sprintf(out_buf, curr_event->string, curr_event->args[index[0]],
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/17] s390/debug: Rename jump labels in debug_areas_alloc()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-03 12:14   ` [PATCH 03/17] s390/debug: Add some spaces for better code readability SF Markus Elfring
@ 2016-09-03 12:16   ` SF Markus Elfring
  2016-09-03 12:18   ` [PATCH 05/17] s390/debug: Fix jump targets in debug_info_alloc() SF Markus Elfring
                     ` (13 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:16 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 18:10:21 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 5bb9108..0af14a4 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -198,33 +198,32 @@ debug_areas_alloc(int pages_per_area, int nr_areas)
 
 	areas = kmalloc_array(nr_areas, sizeof(*areas), GFP_KERNEL);
 	if (!areas)
-		goto fail_malloc_areas;
+		goto exit;
 	for (i = 0; i < nr_areas; i++) {
 		areas[i] = kmalloc_array(pages_per_area,
 					 sizeof(*areas[i]),
 					 GFP_KERNEL);
 		if (!areas[i])
-			goto fail_malloc_areas2;
+			goto free_areas;
 		for (j = 0; j < pages_per_area; j++) {
 			areas[i][j] = kzalloc(PAGE_SIZE, GFP_KERNEL);
 			if (!areas[i][j]) {
 				for (j--; j >= 0; j--)
 					kfree(areas[i][j]);
 				kfree(areas[i]);
-				goto fail_malloc_areas2;
+				goto free_areas;
 			}
 		}
 	}
 	return areas;
-
-fail_malloc_areas2:
+ free_areas:
 	for (i--; i >= 0; i--) {
 		for (j = 0; j < pages_per_area; j++)
 			kfree(areas[i][j]);
 		kfree(areas[i]);
 	}
 	kfree(areas);
-fail_malloc_areas:
+ exit:
 	return NULL;
 
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/17] s390/debug: Fix jump targets in debug_info_alloc()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-03 12:16   ` [PATCH 04/17] s390/debug: Rename jump labels in debug_areas_alloc() SF Markus Elfring
@ 2016-09-03 12:18   ` SF Markus Elfring
  2016-09-03 12:20   ` [PATCH 06/17] s390/debug: Rename jump labels in debug_info_copy() SF Markus Elfring
                     ` (12 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:18 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 18:26:58 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 0af14a4..c5da41b 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -244,17 +244,17 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
 
 	rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
 	if(!rc)
-		goto fail_malloc_rc;
+		goto exit;
 	rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
 	if(!rc->active_entries)
-		goto fail_malloc_active_entries;
+		goto free_rc;
 	rc->active_pages = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
 	if(!rc->active_pages)
-		goto fail_malloc_active_pages;
+		goto free_entries;
 	if((mode == ALL_AREAS) && (pages_per_area != 0)){
 		rc->areas = debug_areas_alloc(pages_per_area, nr_areas);
 		if(!rc->areas)
-			goto fail_malloc_areas;
+			goto free_pages;
 	} else {
 		rc->areas = NULL;
 	}
@@ -275,14 +275,13 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
 	atomic_set(&(rc->ref_count), 0);
 
 	return rc;
-
-fail_malloc_areas:
+ free_pages:
 	kfree(rc->active_pages);
-fail_malloc_active_pages:
+ free_entries:
 	kfree(rc->active_entries);
-fail_malloc_active_entries:
+ free_rc:
 	kfree(rc);
-fail_malloc_rc:
+ exit:
 	return NULL;
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/17] s390/debug: Rename jump labels in debug_info_copy()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-03 12:18   ` [PATCH 05/17] s390/debug: Fix jump targets in debug_info_alloc() SF Markus Elfring
@ 2016-09-03 12:20   ` SF Markus Elfring
  2016-09-03 12:21   ` [PATCH 07/17] s390/debug: Rename jump labels in debug_open() SF Markus Elfring
                     ` (11 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:20 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 18:32:19 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index c5da41b..1f32578 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -377,7 +377,7 @@ debug_info_copy(debug_info_t* in, int mode)
 			in->nr_areas, in->buf_size, in->level, mode);
 		spin_lock_irqsave(&in->lock, flags);
 		if (!rc)
-			goto out;
+			goto unlock;
 		/* has something changed in the meantime ? */
 		if ((rc->pages_per_area == in->pages_per_area) &&
 		   (rc->nr_areas == in->nr_areas)) {
@@ -388,12 +388,12 @@ debug_info_copy(debug_info_t* in, int mode)
 	} while (1);
 
 	if (mode == NO_AREAS)
-                goto out;
+		goto unlock;
 
 	for (i = 0; i < in->nr_areas; i++)
 		for (j = 0; j < in->pages_per_area; j++)
 			memcpy(rc->areas[i][j], in->areas[i][j], PAGE_SIZE);
-out:
+ unlock:
         spin_unlock_irqrestore(&in->lock, flags);
         return rc;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/17] s390/debug: Rename jump labels in debug_open()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-03 12:20   ` [PATCH 06/17] s390/debug: Rename jump labels in debug_info_copy() SF Markus Elfring
@ 2016-09-03 12:21   ` SF Markus Elfring
  2016-09-03 12:23   ` [PATCH 08/17] s390/debug: Fix a jump target in debug_register_mode() SF Markus Elfring
                     ` (10 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:21 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 18:44:17 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 1f32578..1cce76a 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -614,15 +614,13 @@ debug_open(struct inode *inode, struct file *file)
 			continue;
 		else if (debug_info->debugfs_entries[i] ==
 			 file->f_path.dentry) {
-			goto found;	/* found view ! */
+			goto copy_info;
 		}
 	}
 	/* no entry found */
 	rc = -EINVAL;
-	goto out;
-
-found:
-
+	goto unlock;
+ copy_info:
 	/* Make snapshot of current debug areas to get it consistent.     */
 	/* To copy all the areas is only needed, if we have a view which  */
 	/* formats the debug areas. */
@@ -636,14 +634,14 @@ found:
 
 	if (!debug_info_snapshot) {
 		rc = -ENOMEM;
-		goto out;
+		goto unlock;
 	}
 	p_info = kmalloc(sizeof(file_private_info_t),
 						GFP_KERNEL);
 	if (!p_info) {
 		debug_info_free(debug_info_snapshot);
 		rc = -ENOMEM;
-		goto out;
+		goto unlock;
 	}
 	p_info->offset = 0;
 	p_info->debug_info_snap = debug_info_snapshot;
@@ -656,7 +654,7 @@ found:
 	file->private_data = p_info;
 	debug_info_get(debug_info);
 	nonseekable_open(inode, file);
-out:
+ unlock:
 	mutex_unlock(&debug_mutex);
 	return rc;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/17] s390/debug: Fix a jump target in debug_register_mode()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-03 12:21   ` [PATCH 07/17] s390/debug: Rename jump labels in debug_open() SF Markus Elfring
@ 2016-09-03 12:23   ` SF Markus Elfring
  2016-09-03 12:24   ` [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister() SF Markus Elfring
                     ` (9 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:23 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 19:26:16 +0200

* Move an error message.

* Adjust a jump target according to the current Linux coding
  style convention.

* Delete a repeated check which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 1cce76a..c4a4641 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -700,14 +700,14 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
         /* create new debug_info */
 
 	rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
-	if (!rc)
-		goto out;
+	if (!rc) {
+		pr_err("Registering debug feature %s failed\n", name);
+		goto unlock;
+	}
 	debug_register_view(rc, &debug_level_view);
         debug_register_view(rc, &debug_flush_view);
 	debug_register_view(rc, &debug_pages_view);
-out:
-	if (!rc)
-		pr_err("Registering debug feature %s failed\n", name);
+ unlock:
 	mutex_unlock(&debug_mutex);
 	return rc;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-03 12:23   ` [PATCH 08/17] s390/debug: Fix a jump target in debug_register_mode() SF Markus Elfring
@ 2016-09-03 12:24   ` SF Markus Elfring
  2016-09-03 12:42     ` walter harms
  2016-09-03 12:26   ` [PATCH 10/17] s390/debug: Delete an unnecessary initialisation in debug_prolog_level_fn() SF Markus Elfring
                     ` (8 subsequent siblings)
  17 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:24 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 19:34:45 +0200

Return directly at the beginning if a null pointer was passed for
the input parameter of this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index c4a4641..d137150 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -736,13 +736,10 @@ void
 debug_unregister(debug_info_t * id)
 {
 	if (!id)
-		goto out;
+		return;
 	mutex_lock(&debug_mutex);
 	debug_info_put(id);
 	mutex_unlock(&debug_mutex);
-
-out:
-	return;
 }
 EXPORT_SYMBOL(debug_unregister);
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/17] s390/debug: Delete an unnecessary initialisation in debug_prolog_level_fn()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-03 12:24   ` [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister() SF Markus Elfring
@ 2016-09-03 12:26   ` SF Markus Elfring
  2016-09-03 12:28   ` [PATCH 11/17] s390/debug: Fix indentation in 13 functions SF Markus Elfring
                     ` (7 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:26 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 21:19:02 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index d137150..ef0db06 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -1254,7 +1254,7 @@ out:
 static int
 debug_prolog_level_fn(debug_info_t * id, struct debug_view *view, char *out_buf)
 {
-	int rc = 0;
+	int rc;
 
 	if (id->level == DEBUG_OFF_LEVEL)
 		rc = sprintf(out_buf,"-\n");
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/17] s390/debug: Fix indentation in 13 functions
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-03 12:26   ` [PATCH 10/17] s390/debug: Delete an unnecessary initialisation in debug_prolog_level_fn() SF Markus Elfring
@ 2016-09-03 12:28   ` SF Markus Elfring
  2016-09-03 12:30   ` [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (6 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:28 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Sep 2016 23:05:51 +0200

The script "checkpatch.pl" can point the following information out.

ERROR: code indent should use tabs where possible

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 118 +++++++++++++++++++++++------------------------
 1 file changed, 59 insertions(+), 59 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index ef0db06..4a12faf 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -330,7 +330,7 @@ debug_info_create(const char *name, int pages_per_area, int nr_areas,
 {
 	debug_info_t* rc;
 
-        rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size,
+	rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size,
 				DEBUG_DEFAULT_LEVEL, ALL_AREAS);
 	if (!rc)
 		goto out;
@@ -338,21 +338,21 @@ debug_info_create(const char *name, int pages_per_area, int nr_areas,
 	rc->mode = mode & ~S_IFMT;
 
 	/* create root directory */
-        rc->debugfs_root_entry = debugfs_create_dir(rc->name,
+	rc->debugfs_root_entry = debugfs_create_dir(rc->name,
 					debug_debugfs_root_entry);
 
 	/* append new element to linked list */
-        if (!debug_area_first) {
-                /* first element in list */
-                debug_area_first = rc;
-                rc->prev = NULL;
-        } else {
-                /* append element to end of list */
-                debug_area_last->next = rc;
-                rc->prev = debug_area_last;
-        }
-        debug_area_last = rc;
-        rc->next = NULL;
+	if (!debug_area_first) {
+		/* first element in list */
+		debug_area_first = rc;
+		rc->prev = NULL;
+	} else {
+		/* append element to end of list */
+		debug_area_last->next = rc;
+		rc->prev = debug_area_last;
+	}
+	debug_area_last = rc;
+	rc->next = NULL;
 
 	debug_info_get(rc);
 out:
@@ -394,8 +394,8 @@ debug_info_copy(debug_info_t* in, int mode)
 		for (j = 0; j < in->pages_per_area; j++)
 			memcpy(rc->areas[i][j], in->areas[i][j], PAGE_SIZE);
  unlock:
-        spin_unlock_irqrestore(&in->lock, flags);
-        return rc;
+	spin_unlock_irqrestore(&in->lock, flags);
+	return rc;
 }
 
 /*
@@ -456,7 +456,7 @@ debug_format_entry(file_private_info_t *p_info)
 
 	if (p_info->act_entry == DEBUG_PROLOG_ENTRY) {
 		/* print prolog */
-        	if (view->prolog_proc)
+		if (view->prolog_proc)
 			len += view->prolog_proc(id_snap,
 						 view,
 						 p_info->temp_buf);
@@ -476,7 +476,7 @@ debug_format_entry(file_private_info_t *p_info)
 		len += view->format_proc(id_snap, view, p_info->temp_buf + len,
 						DEBUG_DATA(act_entry));
 out:
-        return len;
+	return len;
 }
 
 /*
@@ -505,7 +505,7 @@ debug_next_entry(file_private_info_t *p_info)
 		p_info->act_page += 1;
 		if ((p_info->act_page % id->pages_per_area) == 0) {
 			/* next area */
-        		p_info->act_area++;
+			p_info->act_area++;
 			p_info->act_page=0;
 		}
 		if (p_info->act_area >= id->nr_areas)
@@ -697,15 +697,14 @@ debug_info_t *debug_register_mode(const char *name, int pages_per_area,
 	BUG_ON(!initialized);
 	mutex_lock(&debug_mutex);
 
-        /* create new debug_info */
-
+	/* create new debug_info */
 	rc = debug_info_create(name, pages_per_area, nr_areas, buf_size, mode);
 	if (!rc) {
 		pr_err("Registering debug feature %s failed\n", name);
 		goto unlock;
 	}
 	debug_register_view(rc, &debug_level_view);
-        debug_register_view(rc, &debug_flush_view);
+	debug_register_view(rc, &debug_flush_view);
 	debug_register_view(rc, &debug_pages_view);
  unlock:
 	mutex_unlock(&debug_mutex);
@@ -794,14 +793,14 @@ debug_set_level(debug_info_t* id, int new_level)
 		return;	
 	spin_lock_irqsave(&id->lock, flags);
 	if (new_level == DEBUG_OFF_LEVEL) {
-                id->level = DEBUG_OFF_LEVEL;
+		id->level = DEBUG_OFF_LEVEL;
 		pr_info("%s: switched off\n", id->name);
-        } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
+	} else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
 		pr_info("%s: level %i is out of range (%i - %i)\n",
-                        id->name, new_level, 0, DEBUG_MAX_LEVEL);
-        } else {
-                id->level = new_level;
-        }
+			id->name, new_level, 0, DEBUG_MAX_LEVEL);
+	} else {
+		id->level = new_level;
+	}
 	spin_unlock_irqrestore(&id->lock, flags);
 }
 EXPORT_SYMBOL(debug_set_level);
@@ -1175,7 +1174,7 @@ debug_get_user_string(const char __user *user_buf, size_t user_len)
 		buffer[user_len - 1] = 0;
 	else
 		buffer[user_len] = 0;
-        return buffer;
+	return buffer;
 }
 
 static inline int
@@ -1219,7 +1218,7 @@ debug_input_pages_fn(debug_info_t * id, struct debug_view *view,
 	int rc, new_pages;
 
 	if (user_len > 0x10000)
-                user_len = 0x10000;
+		user_len = 0x10000;
 	if (*offset != 0) {
 		rc = -EPIPE;
 		goto out;
@@ -1276,7 +1275,7 @@ debug_input_level_fn(debug_info_t * id, struct debug_view *view,
 	int rc, new_level;
 
 	if (user_len > 0x10000)
-                user_len = 0x10000;
+		user_len = 0x10000;
 	if (*offset != 0) {
 		rc = -EPIPE;
 		goto out;
@@ -1314,26 +1313,26 @@ out:
  
 static void debug_flush(debug_info_t* id, int area)
 {
-        unsigned long flags;
+	unsigned long flags;
 	int i, j;
 
 	if (!id || !id->areas)
-                return;
+		return;
 	spin_lock_irqsave(&id->lock, flags);
 	if (area == DEBUG_FLUSH_ALL) {
-                id->active_area = 0;
-                memset(id->active_entries, 0, id->nr_areas * sizeof(int));
-                for (i = 0; i < id->nr_areas; i++) {
+		id->active_area = 0;
+		memset(id->active_entries, 0, id->nr_areas * sizeof(int));
+		for (i = 0; i < id->nr_areas; i++) {
 			id->active_pages[i] = 0;
 			for (j = 0; j < id->pages_per_area; j++)
-                        	memset(id->areas[i][j], 0, PAGE_SIZE);
+				memset(id->areas[i][j], 0, PAGE_SIZE);
 		}
 	} else if (area >= 0 && area < id->nr_areas) {
-                id->active_entries[area] = 0;
+		id->active_entries[area] = 0;
 		id->active_pages[area] = 0;
 		for (i = 0; i < id->pages_per_area; i++)
 			memset(id->areas[area][i], 0, PAGE_SIZE);
-        }
+	}
 	spin_unlock_irqrestore(&id->lock, flags);
 }
 
@@ -1346,35 +1345,36 @@ debug_input_flush_fn(debug_info_t * id, struct debug_view *view,
 			struct file *file, const char __user *user_buf,
 			size_t user_len, loff_t * offset)
 {
-        char input_buf[1];
-        int rc = user_len;
+	char input_buf[1];
+	int rc = user_len;
 
 	if (user_len > 0x10000)
-                user_len = 0x10000;
+		user_len = 0x10000;
 	if (*offset != 0) {
 		rc = -EPIPE;
-                goto out;
+		goto out;
 	}
 	if (copy_from_user(input_buf, user_buf, 1)) {
-                rc = -EFAULT;
-                goto out;
-        }
+		rc = -EFAULT;
+		goto out;
+	}
 	if (input_buf[0] == '-') {
-                debug_flush(id, DEBUG_FLUSH_ALL);
-                goto out;
-        }
-        if (isdigit(input_buf[0])) {
-                int area = ((int) input_buf[0] - (int) '0');
-                debug_flush(id, area);
-                goto out;
-        }
+		debug_flush(id, DEBUG_FLUSH_ALL);
+		goto out;
+	}
+	if (isdigit(input_buf[0])) {
+		int area = ((int) input_buf[0] - (int) '0');
+
+		debug_flush(id, area);
+		goto out;
+	}
 
 	pr_info("Flushing debug data failed because %c is not a valid "
 		 "area\n", input_buf[0]);
 
 out:
-        *offset += user_len;
-        return rc;              /* number of input characters */
+	*offset += user_len;
+	return rc;              /* number of input characters */
 }
 
 /*
@@ -1385,11 +1385,11 @@ static int
 debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
 			int area, debug_entry_t * entry, char *out_buf)
 {
-        int rc;
+	int rc;
 
 	rc = sizeof(debug_entry_t);
 	memcpy(out_buf, entry, sizeof(debug_entry_t));
-        return rc;
+	return rc;
 }
 
 /*
@@ -1418,8 +1418,8 @@ debug_hex_ascii_format_fn(debug_info_t * id, struct debug_view *view,
 	int i, rc = 0;
 
 	for (i = 0; i < id->buf_size; i++)
-                rc += sprintf(out_buf + rc, "%02x ",
-                              ((unsigned char *) in_buf)[i]);
+		rc += sprintf(out_buf + rc, "%02x ",
+			      ((unsigned char *) in_buf)[i]);
 	rc += sprintf(out_buf + rc, "| ");
 	for (i = 0; i < id->buf_size; i++) {
 		unsigned char c = in_buf[i];
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-03 12:28   ` [PATCH 11/17] s390/debug: Fix indentation in 13 functions SF Markus Elfring
@ 2016-09-03 12:30   ` SF Markus Elfring
  2016-09-03 13:10     ` kbuild test robot
  2016-09-03 12:32   ` [PATCH 13/17] s390/debug: Improve a size determination in debug_open() SF Markus Elfring
                     ` (5 subsequent siblings)
  17 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:30 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 08:45:26 +0200

Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 4a12faf..a9fcf72 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -1162,13 +1162,9 @@ debug_get_user_string(const char __user *user_buf, size_t user_len)
 {
 	char* buffer;
 
-	buffer = kmalloc(user_len + 1, GFP_KERNEL);
-	if (!buffer)
-		return ERR_PTR(-ENOMEM);
-	if (copy_from_user(buffer, user_buf, user_len) != 0) {
-		kfree(buffer);
-		return ERR_PTR(-EFAULT);
-	}
+	buffer = memdup_user(user_buf, user_len + 1);
+	if (IS_ERR(buffer))
+		return PTR_ERR(buffer);
 	/* got the string, now strip linefeed. */
 	if (buffer[user_len - 1] == '\n')
 		buffer[user_len - 1] = 0;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/17] s390/debug: Improve a size determination in debug_open()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-03 12:30   ` [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-09-03 12:32   ` SF Markus Elfring
  2016-09-03 12:34   ` [PATCH 14/17] s390/debug: Improve a size determination in debug_sprintf_format_fn() SF Markus Elfring
                     ` (4 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:32 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 09:02:22 +0200

* Replace the specification of a data type by a pointer dereference
  as the parameter for the operator "sizeof" to make the corresponding size
  determination a bit safer according to the Linux coding style convention.

* Improve source code layout for one function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index a9fcf72..32ceb5e 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -636,8 +636,7 @@ debug_open(struct inode *inode, struct file *file)
 		rc = -ENOMEM;
 		goto unlock;
 	}
-	p_info = kmalloc(sizeof(file_private_info_t),
-						GFP_KERNEL);
+	p_info = kmalloc(sizeof(*p_info), GFP_KERNEL);
 	if (!p_info) {
 		debug_info_free(debug_info_snapshot);
 		rc = -ENOMEM;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/17] s390/debug: Improve a size determination in debug_sprintf_format_fn()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-03 12:32   ` [PATCH 13/17] s390/debug: Improve a size determination in debug_open() SF Markus Elfring
@ 2016-09-03 12:34   ` SF Markus Elfring
  2016-09-03 12:36   ` [PATCH 15/17] s390/debug: Improve a size determination in debug_raw_header_fn() SF Markus Elfring
                     ` (3 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:34 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 14:32:08 +0200

Replace a multiplication by a reference for a local array variable
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 32ceb5e..6792a9c 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -1486,7 +1486,7 @@ debug_sprintf_format_fn(debug_info_t * id, struct debug_view *view,
 	/* number of arguments used for sprintf (without the format string) */
 	num_used_args   = min(DEBUG_SPRINTF_MAX_ARGS, (num_longs - 1));
 
-	memset(index, 0, DEBUG_SPRINTF_MAX_ARGS * sizeof(int));
+	memset(index, 0, sizeof(index));
 
 	for (i = 0; i < num_used_args; i++)
 		index[i] = i;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 15/17] s390/debug: Improve a size determination in debug_raw_header_fn()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-03 12:34   ` [PATCH 14/17] s390/debug: Improve a size determination in debug_sprintf_format_fn() SF Markus Elfring
@ 2016-09-03 12:36   ` SF Markus Elfring
  2016-09-03 12:38   ` [PATCH 16/17] s390/debug: Improve determination of sizes in debug_info_alloc() SF Markus Elfring
                     ` (2 subsequent siblings)
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:36 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 14:34:22 +0200

* Replace the specification of a data type by pointer dereferences
  as the parameter for the operator "sizeof" to make the corresponding size
  determination a bit safer according to the Linux coding style convention.

* Return a constant directly without storing the desired value
  in a local variable.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 6792a9c..ff8e705 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -1380,11 +1380,8 @@ static int
 debug_raw_header_fn(debug_info_t * id, struct debug_view *view,
 			int area, debug_entry_t * entry, char *out_buf)
 {
-	int rc;
-
-	rc = sizeof(debug_entry_t);
-	memcpy(out_buf, entry, sizeof(debug_entry_t));
-	return rc;
+	memcpy(out_buf, entry, sizeof(*entry));
+	return sizeof(*entry);
 }
 
 /*
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 16/17] s390/debug: Improve determination of sizes in debug_info_alloc()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-03 12:36   ` [PATCH 15/17] s390/debug: Improve a size determination in debug_raw_header_fn() SF Markus Elfring
@ 2016-09-03 12:38   ` SF Markus Elfring
  2016-09-03 12:40   ` [PATCH 17/17] s390/debug: Improve another size determination " SF Markus Elfring
  2016-09-05 10:31   ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations Martin Schwidefsky
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:38 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 14:39:00 +0200

* Replace two multiplications by references for an array in a local
  data structure as the parameter for the operator "sizeof" to make
  the corresponding size determination a bit safer.

* Improve source code layout for one function call.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index ff8e705..408a8da 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -269,9 +269,8 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
 	rc->buf_size       = buf_size;
 	rc->entry_size     = sizeof(debug_entry_t) + buf_size;
 	strlcpy(rc->name, name, sizeof(rc->name));
-	memset(rc->views, 0, DEBUG_MAX_VIEWS * sizeof(struct debug_view *));
-	memset(rc->debugfs_entries, 0, DEBUG_MAX_VIEWS *
-		sizeof(struct dentry*));
+	memset(rc->views, 0, sizeof(rc->views));
+	memset(rc->debugfs_entries, 0, sizeof(rc->debugfs_entries));
 	atomic_set(&(rc->ref_count), 0);
 
 	return rc;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 17/17] s390/debug: Improve another size determination in debug_info_alloc()
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (15 preceding siblings ...)
  2016-09-03 12:38   ` [PATCH 16/17] s390/debug: Improve determination of sizes in debug_info_alloc() SF Markus Elfring
@ 2016-09-03 12:40   ` SF Markus Elfring
  2016-09-05 10:31   ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations Martin Schwidefsky
  17 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 12:40 UTC (permalink / raw)
  To: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 2 Sep 2016 14:41:02 +0200

Replace the specification of a data type by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/s390/kernel/debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
index 408a8da..ffc6af6 100644
--- a/arch/s390/kernel/debug.c
+++ b/arch/s390/kernel/debug.c
@@ -241,8 +241,7 @@ debug_info_alloc(const char *name, int pages_per_area, int nr_areas,
 	debug_info_t* rc;
 
 	/* alloc everything */
-
-	rc = kmalloc(sizeof(debug_info_t), GFP_KERNEL);
+	rc = kmalloc(sizeof(*rc), GFP_KERNEL);
 	if(!rc)
 		goto exit;
 	rc->active_entries = kcalloc(nr_areas, sizeof(int), GFP_KERNEL);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister()
  2016-09-03 12:24   ` [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister() SF Markus Elfring
@ 2016-09-03 12:42     ` walter harms
  0 siblings, 0 replies; 1373+ messages in thread
From: walter harms @ 2016-09-03 12:42 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches,
	Martin Schwidefsky, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini



Am 03.09.2016 14:24, schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 1 Sep 2016 19:34:45 +0200
> 
> Return directly at the beginning if a null pointer was passed for
> the input parameter of this function.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/s390/kernel/debug.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c
> index c4a4641..d137150 100644
> --- a/arch/s390/kernel/debug.c
> +++ b/arch/s390/kernel/debug.c
> @@ -736,13 +736,10 @@ void
>  debug_unregister(debug_info_t * id)
>  {
>  	if (!id)
> -		goto out;
> +		return;
>  	mutex_lock(&debug_mutex);
>  	debug_info_put(id);
>  	mutex_unlock(&debug_mutex);
> -
> -out:
> -	return;
>  }
>  EXPORT_SYMBOL(debug_unregister);
> 

debug_info_put() will check for NULL, the whole check can be removed.

re,
 wh

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation
  2016-09-03 12:30   ` [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-09-03 13:10     ` kbuild test robot
  0 siblings, 0 replies; 1373+ messages in thread
From: kbuild test robot @ 2016-09-03 13:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, linux-s390, David Hildenbrand, Heiko Carstens,
	Joe Perches, Martin Schwidefsky, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 2184 bytes --]

Hi Markus,

[auto build test WARNING on s390/features]
[also build test WARNING on v4.8-rc4 next-20160825]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/s390-debug-Fine-tuning-for-several-function-implementations/20160903-204622
base:   https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git features
config: s390-allmodconfig (attached as .config)
compiler: s390x-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=s390 

All warnings (new ones prefixed by >>):

   arch/s390/kernel/debug.c: In function 'debug_get_user_string':
>> arch/s390/kernel/debug.c:1167:10: warning: return makes pointer from integer without a cast [-Wint-conversion]
      return PTR_ERR(buffer);
             ^

vim +1167 arch/s390/kernel/debug.c

  1151			id->debugfs_entries[i] = NULL;
  1152		}
  1153		spin_unlock_irqrestore(&id->lock, flags);
  1154		debugfs_remove(dentry);
  1155	out:
  1156		return rc;
  1157	}
  1158	EXPORT_SYMBOL(debug_unregister_view);
  1159	
  1160	static inline char *
  1161	debug_get_user_string(const char __user *user_buf, size_t user_len)
  1162	{
  1163		char* buffer;
  1164	
  1165		buffer = memdup_user(user_buf, user_len + 1);
  1166		if (IS_ERR(buffer))
> 1167			return PTR_ERR(buffer);
  1168		/* got the string, now strip linefeed. */
  1169		if (buffer[user_len - 1] == '\n')
  1170			buffer[user_len - 1] = 0;
  1171		else
  1172			buffer[user_len] = 0;
  1173		return buffer;
  1174	}
  1175	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 42341 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (71 preceding siblings ...)
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-03 16:33 ` SF Markus Elfring
  2016-09-03 16:36   ` [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() SF Markus Elfring
                     ` (3 more replies)
  2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
                   ` (22 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 16:33 UTC (permalink / raw)
  To: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 18:28:02 +0200

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

Markus Elfring (4):
  Use kmalloc_array()
  Move four assignments
  Avoid assignment for the variable "flen" if BPF JIT is disabled.
  Rename jump labels

 arch/sparc/net/bpf_jit_comp.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile()
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
@ 2016-09-03 16:36   ` SF Markus Elfring
  2016-09-03 16:51     ` Daniel Borkmann
  2016-09-03 16:38   ` [PATCH 2/4] sparc: bpf_jit: Move four assignments " SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 16:36 UTC (permalink / raw)
  To: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 17:10:20 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/sparc/net/bpf_jit_comp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a6d9204..ced1393 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -372,7 +372,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
 	if (!bpf_jit_enable)
 		return;
 
-	addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
+	addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
 	if (addrs == NULL)
 		return;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
  2016-09-03 16:36   ` [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() SF Markus Elfring
@ 2016-09-03 16:38   ` SF Markus Elfring
  2016-09-04  3:21     ` Julian Calaby
  2016-09-03 16:40   ` [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled SF Markus Elfring
  2016-09-03 16:41   ` [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 16:38 UTC (permalink / raw)
  To: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 17:45:28 +0200

Move the assignments for four local variables a bit at the beginning
so that they will only be performed if a corresponding memory allocation
succeeded by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/sparc/net/bpf_jit_comp.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index ced1393..a927470 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -362,10 +362,10 @@ do {	*prog++ = BR_OPC | WDISP22(OFF);		\
 
 void bpf_jit_compile(struct bpf_prog *fp)
 {
-	unsigned int cleanup_addr, proglen, oldproglen = 0;
-	u32 temp[8], *prog, *func, seen = 0, pass;
-	const struct sock_filter *filter = fp->insns;
-	int i, flen = fp->len, pc_ret0 = -1;
+	unsigned int cleanup_addr, proglen, oldproglen;
+	u32 temp[8], *prog, *func, seen, pass;
+	const struct sock_filter *filter;
+	int i, flen = fp->len, pc_ret0;
 	unsigned int *addrs;
 	void *image;
 
@@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp)
 	}
 	cleanup_addr = proglen; /* epilogue address */
 	image = NULL;
+	filter = fp->insns;
+	oldproglen = 0;
+	pc_ret0 = -1;
+	seen = 0;
 	for (pass = 0; pass < 10; pass++) {
 		u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
  2016-09-03 16:36   ` [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() SF Markus Elfring
  2016-09-03 16:38   ` [PATCH 2/4] sparc: bpf_jit: Move four assignments " SF Markus Elfring
@ 2016-09-03 16:40   ` SF Markus Elfring
  2016-09-03 16:58     ` Daniel Borkmann
  2016-09-03 16:41   ` [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 16:40 UTC (permalink / raw)
  To: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 18:00:03 +0200

Move the assignment for the local variable "flen" a bit at the beginning
so that it will only be performed if BPF JIT is enabled for this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/sparc/net/bpf_jit_comp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a927470..a6b6e29 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -365,13 +365,14 @@ void bpf_jit_compile(struct bpf_prog *fp)
 	unsigned int cleanup_addr, proglen, oldproglen;
 	u32 temp[8], *prog, *func, seen, pass;
 	const struct sock_filter *filter;
-	int i, flen = fp->len, pc_ret0;
+	int i, flen, pc_ret0;
 	unsigned int *addrs;
 	void *image;
 
 	if (!bpf_jit_enable)
 		return;
 
+	flen = fp->len;
 	addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
 	if (addrs == NULL)
 		return;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-03 16:40   ` [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled SF Markus Elfring
@ 2016-09-03 16:41   ` SF Markus Elfring
  2016-09-03 16:52     ` Daniel Borkmann
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 16:41 UTC (permalink / raw)
  To: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 18:14:19 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/sparc/net/bpf_jit_comp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
index a6b6e29..3aa19a1 100644
--- a/arch/sparc/net/bpf_jit_comp.c
+++ b/arch/sparc/net/bpf_jit_comp.c
@@ -761,7 +761,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
 
 			default:
 				/* hmm, too complex filter, give up with jit compiler */
-				goto out;
+				goto free_addresses;
 			}
 			ilen = (void *) prog - (void *) temp;
 			if (image) {
@@ -793,7 +793,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
 		if (proglen == oldproglen) {
 			image = module_alloc(proglen);
 			if (!image)
-				goto out;
+				goto free_addresses;
 		}
 		oldproglen = proglen;
 	}
@@ -806,7 +806,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
 		fp->bpf_func = (void *)image;
 		fp->jited = 1;
 	}
-out:
+ free_addresses:
 	kfree(addrs);
 	return;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile()
  2016-09-03 16:36   ` [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() SF Markus Elfring
@ 2016-09-03 16:51     ` Daniel Borkmann
  0 siblings, 0 replies; 1373+ messages in thread
From: Daniel Borkmann @ 2016-09-03 16:51 UTC (permalink / raw)
  To: SF Markus Elfring, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

On 09/03/2016 06:36 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 17:10:20 +0200
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.

When you talk about "issue", could you please explain yourself what
concrete "issue" you were seeing ?!

This particular multiplication here is guaranteed to never overflow,
so at best a minor cleanup if you will.

(Do you actually have a sparc to test out your changes?)

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>   arch/sparc/net/bpf_jit_comp.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
> index a6d9204..ced1393 100644
> --- a/arch/sparc/net/bpf_jit_comp.c
> +++ b/arch/sparc/net/bpf_jit_comp.c
> @@ -372,7 +372,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
>   	if (!bpf_jit_enable)
>   		return;
>
> -	addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
> +	addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
>   	if (addrs == NULL)
>   		return;
>
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-03 16:41   ` [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile() SF Markus Elfring
@ 2016-09-03 16:52     ` Daniel Borkmann
  2016-09-04  6:06       ` David Miller
  0 siblings, 1 reply; 1373+ messages in thread
From: Daniel Borkmann @ 2016-09-03 16:52 UTC (permalink / raw)
  To: SF Markus Elfring, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

On 09/03/2016 06:41 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 18:14:19 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

NAK, just noise.

> ---
>   arch/sparc/net/bpf_jit_comp.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
> index a6b6e29..3aa19a1 100644
> --- a/arch/sparc/net/bpf_jit_comp.c
> +++ b/arch/sparc/net/bpf_jit_comp.c
> @@ -761,7 +761,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
>
>   			default:
>   				/* hmm, too complex filter, give up with jit compiler */
> -				goto out;
> +				goto free_addresses;
>   			}
>   			ilen = (void *) prog - (void *) temp;
>   			if (image) {
> @@ -793,7 +793,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
>   		if (proglen == oldproglen) {
>   			image = module_alloc(proglen);
>   			if (!image)
> -				goto out;
> +				goto free_addresses;
>   		}
>   		oldproglen = proglen;
>   	}
> @@ -806,7 +806,7 @@ cond_branch:			f_offset = addrs[i + filter[i].jf];
>   		fp->bpf_func = (void *)image;
>   		fp->jited = 1;
>   	}
> -out:
> + free_addresses:
>   	kfree(addrs);
>   	return;
>   }
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled
  2016-09-03 16:40   ` [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled SF Markus Elfring
@ 2016-09-03 16:58     ` Daniel Borkmann
  0 siblings, 0 replies; 1373+ messages in thread
From: Daniel Borkmann @ 2016-09-03 16:58 UTC (permalink / raw)
  To: SF Markus Elfring, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, David S. Miller, Rabin Vincent
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

On 09/03/2016 06:40 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 18:00:03 +0200
>
> Move the assignment for the local variable "flen" a bit at the beginning
> so that it will only be performed if BPF JIT is enabled for this function.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Why is that a particular issue (did you measure some improvement when
you say "fine-tuning" as per subject) ?

That's all not in critical path here by the way, same for patch 2.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] tile-module: Fine-tuning for module_alloc()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (72 preceding siblings ...)
  2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
@ 2016-09-03 19:00 ` SF Markus Elfring
  2016-09-03 19:01   ` [PATCH 1/2] tile-module: Use kmalloc_array() in module_alloc() SF Markus Elfring
                     ` (2 more replies)
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
                   ` (21 subsequent siblings)
  95 siblings, 3 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 19:00 UTC (permalink / raw)
  To: Chris Metcalf, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 20:52:10 +0200

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

Markus Elfring (2):
  Use kmalloc_array()
  Rename jump labels

 arch/tile/kernel/module.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] tile-module: Use kmalloc_array() in module_alloc()
  2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
@ 2016-09-03 19:01   ` SF Markus Elfring
  2016-09-03 19:02   ` [PATCH 2/2] tile-module: Rename jump labels " SF Markus Elfring
  2016-09-06 15:25   ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() Chris Metcalf
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 19:01 UTC (permalink / raw)
  To: Chris Metcalf, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 20:40:57 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/tile/kernel/module.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index 2305084..dce4120 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -43,7 +43,7 @@ void *module_alloc(unsigned long size)
 	int npages;
 
 	npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
-	pages = kmalloc(npages * sizeof(struct page *), GFP_KERNEL);
+	pages = kmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
 	if (pages == NULL)
 		return NULL;
 	for (; i < npages; ++i) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] tile-module: Rename jump labels in module_alloc()
  2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
  2016-09-03 19:01   ` [PATCH 1/2] tile-module: Use kmalloc_array() in module_alloc() SF Markus Elfring
@ 2016-09-03 19:02   ` SF Markus Elfring
  2016-09-06 15:25   ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() Chris Metcalf
  2 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-03 19:02 UTC (permalink / raw)
  To: Chris Metcalf, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 3 Sep 2016 20:45:20 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/tile/kernel/module.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/tile/kernel/module.c b/arch/tile/kernel/module.c
index dce4120..09233fb 100644
--- a/arch/tile/kernel/module.c
+++ b/arch/tile/kernel/module.c
@@ -49,23 +49,22 @@ void *module_alloc(unsigned long size)
 	for (; i < npages; ++i) {
 		pages[i] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
 		if (!pages[i])
-			goto error;
+			goto free_pages;
 	}
 
 	area = __get_vm_area(size, VM_ALLOC, MEM_MODULE_START, MEM_MODULE_END);
 	if (!area)
-		goto error;
+		goto free_pages;
 	area->nr_pages = npages;
 	area->pages = pages;
 
 	if (map_vm_area(area, prot_rwx, pages)) {
 		vunmap(area->addr);
-		goto error;
+		goto free_pages;
 	}
 
 	return area->addr;
-
-error:
+ free_pages:
 	while (--i >= 0)
 		__free_page(pages[i]);
 	kfree(pages);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-03 16:38   ` [PATCH 2/4] sparc: bpf_jit: Move four assignments " SF Markus Elfring
@ 2016-09-04  3:21     ` Julian Calaby
  2016-09-04  4:33       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  3:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

Hi Markus,

On Sun, Sep 4, 2016 at 2:38 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 17:45:28 +0200
>
> Move the assignments for four local variables a bit at the beginning
> so that they will only be performed if a corresponding memory allocation
> succeeded by this function.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/sparc/net/bpf_jit_comp.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/arch/sparc/net/bpf_jit_comp.c b/arch/sparc/net/bpf_jit_comp.c
> index ced1393..a927470 100644
> --- a/arch/sparc/net/bpf_jit_comp.c
> +++ b/arch/sparc/net/bpf_jit_comp.c
> @@ -362,10 +362,10 @@ do {      *prog++ = BR_OPC | WDISP22(OFF);                \
>
>  void bpf_jit_compile(struct bpf_prog *fp)
>  {
> -       unsigned int cleanup_addr, proglen, oldproglen = 0;
> -       u32 temp[8], *prog, *func, seen = 0, pass;
> -       const struct sock_filter *filter = fp->insns;
> -       int i, flen = fp->len, pc_ret0 = -1;
> +       unsigned int cleanup_addr, proglen, oldproglen;
> +       u32 temp[8], *prog, *func, seen, pass;
> +       const struct sock_filter *filter;
> +       int i, flen = fp->len, pc_ret0;
>         unsigned int *addrs;
>         void *image;
>
> @@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp)
>         }
>         cleanup_addr = proglen; /* epilogue address */
>         image = NULL;
> +       filter = fp->insns;
> +       oldproglen = 0;
> +       pc_ret0 = -1;
> +       seen = 0;
>         for (pass = 0; pass < 10; pass++) {
>                 u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;

This is utterly pointless, why?

If you were moving the assignments on declaration onto separate lines
at the top of the file then ok, but why all the way down here?

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  3:21     ` Julian Calaby
@ 2016-09-04  4:33       ` SF Markus Elfring
  2016-09-04  4:44         ` Julian Calaby
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  4:33 UTC (permalink / raw)
  To: Julian Calaby
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

>> Date: Sat, 3 Sep 2016 17:45:28 +0200
>>
>> Move the assignments for four local variables a bit at the beginning
>> so that they will only be performed if a corresponding memory allocation
>> succeeded by this function.
>> @@ -362,10 +362,10 @@ do {      *prog++ = BR_OPC | WDISP22(OFF);                \
>>
>>  void bpf_jit_compile(struct bpf_prog *fp)
>>  {
>> -       unsigned int cleanup_addr, proglen, oldproglen = 0;
>> -       u32 temp[8], *prog, *func, seen = 0, pass;
>> -       const struct sock_filter *filter = fp->insns;
>> -       int i, flen = fp->len, pc_ret0 = -1;
>> +       unsigned int cleanup_addr, proglen, oldproglen;
>> +       u32 temp[8], *prog, *func, seen, pass;
>> +       const struct sock_filter *filter;
>> +       int i, flen = fp->len, pc_ret0;
>>         unsigned int *addrs;
>>         void *image;
>>
>> @@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp)
>>         }
>>         cleanup_addr = proglen; /* epilogue address */
>>         image = NULL;
>> +       filter = fp->insns;
>> +       oldproglen = 0;
>> +       pc_ret0 = -1;
>> +       seen = 0;
>>         for (pass = 0; pass < 10; pass++) {
>>                 u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
> If you were moving the assignments on declaration onto separate lines
> at the top of the file then ok,

I see another software design option where the transformation result might be looking
more pleasing for you again.


> but why all the way down here?

* How do you think about the reason I gave in the short commit message?

* Are you interested in an other software refactoring instead?
  http://refactoring.com/catalog/reduceScopeOfVariable.html

  Would you eventually like to move the source code for this for loop into another function?
  http://refactoring.com/catalog/extractMethod.html

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  4:33       ` SF Markus Elfring
@ 2016-09-04  4:44         ` Julian Calaby
  2016-09-04  5:00           ` SF Markus Elfring
  2016-09-04 19:33           ` [PATCH 2/4] " Bjørn Mork
  0 siblings, 2 replies; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  4:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

Hi Markus,

On Sun, Sep 4, 2016 at 2:33 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> Date: Sat, 3 Sep 2016 17:45:28 +0200
>>>
>>> Move the assignments for four local variables a bit at the beginning
>>> so that they will only be performed if a corresponding memory allocation
>>> succeeded by this function.
> …
>>> @@ -362,10 +362,10 @@ do {      *prog++ = BR_OPC | WDISP22(OFF);                \
>>>
>>>  void bpf_jit_compile(struct bpf_prog *fp)
>>>  {
>>> -       unsigned int cleanup_addr, proglen, oldproglen = 0;
>>> -       u32 temp[8], *prog, *func, seen = 0, pass;
>>> -       const struct sock_filter *filter = fp->insns;
>>> -       int i, flen = fp->len, pc_ret0 = -1;
>>> +       unsigned int cleanup_addr, proglen, oldproglen;
>>> +       u32 temp[8], *prog, *func, seen, pass;
>>> +       const struct sock_filter *filter;
>>> +       int i, flen = fp->len, pc_ret0;
>>>         unsigned int *addrs;
>>>         void *image;
>>>
>>> @@ -385,6 +385,10 @@ void bpf_jit_compile(struct bpf_prog *fp)
>>>         }
>>>         cleanup_addr = proglen; /* epilogue address */
>>>         image = NULL;
>>> +       filter = fp->insns;
>>> +       oldproglen = 0;
>>> +       pc_ret0 = -1;
>>> +       seen = 0;
>>>         for (pass = 0; pass < 10; pass++) {
>>>                 u8 seen_or_pass0 = (pass == 0) ? (SEEN_XREG | SEEN_DATAREF | SEEN_MEM) : seen;
> …
>> If you were moving the assignments on declaration onto separate lines
>> at the top of the file then ok,
>
> I see another software design option where the transformation result might be looking
> more pleasing for you again.
>
>
>> but why all the way down here?
>
> * How do you think about the reason I gave in the short commit message?

Does this change improve the resulting binary? I.e. does it make it
smaller or faster? If it's smaller, by how much? if it's faster,
measure it.

Otherwise this change is useless churn - you're making the code more
complicated, longer and harder to read for practically no benefit.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  4:44         ` Julian Calaby
@ 2016-09-04  5:00           ` SF Markus Elfring
  2016-09-04  5:16             ` Julian Calaby
  2016-09-04  6:32             ` David Miller
  2016-09-04 19:33           ` [PATCH 2/4] " Bjørn Mork
  1 sibling, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  5:00 UTC (permalink / raw)
  To: Julian Calaby
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

> Does this change improve the resulting binary?

I hope so. - I propose to give the refactorings "Reduce scope of variable"
and "Extract a function" (and the corresponding consequences) another look.


> I.e. does it make it smaller or faster?

It is generally possible that a specific code generation variant will also affect
the run time properties you mentioned.


> Otherwise this change is useless churn - you're making the code more
> complicated, longer and harder to read for practically no benefit.

I imagine that there other reasons you could eventually accept
for this use case, aren't there?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:00           ` SF Markus Elfring
@ 2016-09-04  5:16             ` Julian Calaby
  2016-09-04  5:45               ` SF Markus Elfring
  2016-09-04  6:32             ` David Miller
  1 sibling, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  5:16 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

Hi Markus,

On Sun, Sep 4, 2016 at 3:00 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> Does this change improve the resulting binary?
>
> I hope so. - I propose to give the refactorings "Reduce scope of variable"
> and "Extract a function" (and the corresponding consequences) another look.

So you _think_ it does. Come back with real proof.

I must also point out that these sorts of optimisations are things the
compiler does automatically when compiling this code. Therefore it's
highly likely that this change will make absolutely no difference
whatsoever. (And no it won't improve compile speed in any justifiable
way)

>> I.e. does it make it smaller or faster?
>
> It is generally possible that a specific code generation variant will also affect
> the run time properties you mentioned.

It's _possible_? Come back with benchmarks.

I must also point out that this is a "slow path" i.e. as long as it's
not stupidly inefficient, the speed doesn't matter that much. This
change isn't going to improve the speed of this function by any amount
that matters.

>> Otherwise this change is useless churn - you're making the code more
>> complicated, longer and harder to read for practically no benefit.
>
> I imagine that there other reasons you could eventually accept
> for this use case, aren't there?

Unless you have some pretty damn good proof that these changes improve
things, there is absolutely no reason to take them as-is - you are
making the code longer and more difficult to read for no benefit and
wasting everyone's time in the process.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:16             ` Julian Calaby
@ 2016-09-04  5:45               ` SF Markus Elfring
  2016-09-04  5:59                 ` Julian Calaby
  2016-09-04  6:34                 ` David Miller
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  5:45 UTC (permalink / raw)
  To: Julian Calaby
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

>> I hope so. - I propose to give the refactorings "Reduce scope of variable"
>> and "Extract a function" (and the corresponding consequences) another look.
> 
> So you _think_ it does. Come back with real proof.

Which test environments would you find acceptable for further clarification?


> I must also point out that these sorts of optimisations are things the
> compiler does automatically when compiling this code.

Do you take this detail for granted?


> Therefore it's highly likely that this change will make absolutely
> no difference whatsoever.

I find this outcome unlikely.


> (And no it won't improve compile speed in any justifiable way)

This was not a goal of my update suggestion for the function "bpf_jit_compile".


>> It is generally possible that a specific code generation variant will also affect
>> the run time properties you mentioned.
> 
> It's _possible_? Come back with benchmarks.

Which code generation variant would be useful to be clarified further?

Should we avoid to compare software things similar to "apples" and "oranges"
(while these fruits can make more fun)?   ;-)


> I must also point out that this is a "slow path" i.e. as long as it's
> not stupidly inefficient, the speed doesn't matter that much.

Can this execution path become warmer (or even "hot") for some other use cases?


> This change isn't going to improve the speed of this function by any amount
> that matters.

This is also possible.


> Unless you have some pretty damn good proof that these changes improve things,
> there is absolutely no reason to take them as-is

Would you care for a better source code structure?


> - you are making the code longer

Yes. - This is true for the suggested update in this function.


> and more difficult to read for no benefit

I proposed specific benefits for this software module.


> and wasting everyone's time in the process.

I assume that a few contributors can take the presented ideas for further considerations.
Will their value evolve a bit more later?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:45               ` SF Markus Elfring
@ 2016-09-04  5:59                 ` Julian Calaby
  2016-09-04  6:28                   ` SF Markus Elfring
  2016-09-04  6:34                 ` David Miller
  1 sibling, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  5:59 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

Hi Markus,

On Sun, Sep 4, 2016 at 3:45 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> I hope so. - I propose to give the refactorings "Reduce scope of variable"
>>> and "Extract a function" (and the corresponding consequences) another look.
>>
>> So you _think_ it does. Come back with real proof.
>
> Which test environments would you find acceptable for further clarification?

Compiling it on GCC for Sparc, obviously.

>> I must also point out that these sorts of optimisations are things the
>> compiler does automatically when compiling this code.
>
> Do you take this detail for granted?

I trust that the GCC developers have done their work well.

>> Therefore it's highly likely that this change will make absolutely
>> no difference whatsoever.
>
> I find this outcome unlikely.

Then provide proof.

>> (And no it won't improve compile speed in any justifiable way)
>
> This was not a goal of my update suggestion for the function "bpf_jit_compile".

I'm looking for some glimmer of usefullness in this patch. I'm not seeing any.

>>> It is generally possible that a specific code generation variant will also affect
>>> the run time properties you mentioned.
>>
>> It's _possible_? Come back with benchmarks.
>
> Which code generation variant would be useful to be clarified further?
>
> Should we avoid to compare software things similar to "apples" and "oranges"
> (while these fruits can make more fun)?   ;-)

Write a benchmark that exercises this function. Measure the time it
took without this change, measure the time it took with this change,
is there a difference.

You cannot expect people to take you seriously if you're proposing
performance changes without any actual ability or interest in
producing performance related data to go along with them.

>> I must also point out that this is a "slow path" i.e. as long as it's
>> not stupidly inefficient, the speed doesn't matter that much.
>
> Can this execution path become warmer (or even "hot") for some other use cases?

That is for you to prove.

>> This change isn't going to improve the speed of this function by any amount
>> that matters.
>
> This is also possible.
>
>
>> Unless you have some pretty damn good proof that these changes improve things,
>> there is absolutely no reason to take them as-is
>
> Would you care for a better source code structure?

You're essentially saying "I think doing things this way is better"
and providing _nothing_ else. I think that things are perfectly fine
the way they are. Convince me with data or something else. Was this
suggested by some expert? Is this part of some big tree-wide effort to
do this that was started by some expert? Did someone do this to some
other driver and you're applying the same fix elsewhere?

>> - you are making the code longer
>
> Yes. - This is true for the suggested update in this function.
>
>
>> and more difficult to read for no benefit
>
> I proposed specific benefits for this software module.

What benefits? You have not proved that this change produces any
useful benefits.

>> and wasting everyone's time in the process.
>
> I assume that a few contributors can take the presented ideas for further considerations.
> Will their value evolve a bit more later?

I am subscribed to four fairly high traffic mailing lists and I read
hundreds of patches each week. You are the only person proposing
changes like these ones as you are (as far as I know) the only person
who thinks they have any value.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-03 16:52     ` Daniel Borkmann
@ 2016-09-04  6:06       ` David Miller
  2016-09-04  6:50         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: David Miller @ 2016-09-04  6:06 UTC (permalink / raw)
  To: daniel
  Cc: elfring, sparclinux, adam.buchbinder, ast, rabin, linux-kernel,
	kernel-janitors, julia.lawall, pbonzini

From: Daniel Borkmann <daniel@iogearbox.net>
Date: Sat, 03 Sep 2016 18:52:44 +0200

> On 09/03/2016 06:41 PM, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Sat, 3 Sep 2016 18:14:19 +0200
>>
>> Adjust jump labels according to the current Linux coding style
>> convention.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> NAK, just noise.

And frankly I hate that leading space.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:59                 ` Julian Calaby
@ 2016-09-04  6:28                   ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  6:28 UTC (permalink / raw)
  To: Julian Calaby
  Cc: sparclinux, Adam Buchbinder, Alexei Starovoitov, Daniel Borkmann,
	David S. Miller, Rabin Vincent, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

>> Which test environments would you find acceptable for further clarification?
> 
> Compiling it on GCC for Sparc, obviously.

Are there any more configuration details to consider?


>>> I must also point out that these sorts of optimisations are things the
>>> compiler does automatically when compiling this code.
>>
>> Do you take this detail for granted?
> 
> I trust that the GCC developers have done their work well.

Will any more compiler implementations matter here?

Do you like software which can run better by default also without application
of special compilation parameters?


> I'm looking for some glimmer of usefullness in this patch. I'm not seeing any.

Thanks for your honest feedback.


>> Should we avoid to compare software things similar to "apples" and "oranges"
>> (while these fruits can make more fun)?   ;-)
> 
> Write a benchmark that exercises this function. Measure the time it
> took without this change, measure the time it took with this change,
> is there a difference.

Is an accepted test system already available for the purpose that every commit
would be checked in the way automatically you expect here?


> You cannot expect people to take you seriously if you're proposing
> performance changes without any actual ability or interest in
> producing performance related data to go along with them.

I suggested small changes which I found "logical".


> You're essentially saying "I think doing things this way is better"

Yes …


> and providing _nothing_ else.

You might be looking for more information than I can practically give you
at the moment.


> I think that things are perfectly fine the way they are.

I have got an other impression for "perfection" in this software module.
I found an implementation detail for further considerations.


> Convince me with data or something else.

I imagine that the "else" can become harder than you find reasonable.


> Did someone do this to some other driver and you're applying the same fix elsewhere?

Is a similar software development discussion still running for other modules?


> You are the only person proposing changes like these ones as you are

I am picking special software improvement opportunities up.


> (as far as I know) the only person who thinks they have any value.

I can accept that the value of specific changes will usually be categorised
as lower than updates that you prefer so far.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:00           ` SF Markus Elfring
  2016-09-04  5:16             ` Julian Calaby
@ 2016-09-04  6:32             ` David Miller
  2016-09-04  6:44               ` Julian Calaby
  1 sibling, 1 reply; 1373+ messages in thread
From: David Miller @ 2016-09-04  6:32 UTC (permalink / raw)
  To: elfring
  Cc: julian.calaby, sparclinux, adam.buchbinder, ast, daniel, rabin,
	linux-kernel, kernel-janitors, julia.lawall, pbonzini


Markus, I'm really not going to consider any of these changes.

And your replies to the feedback you were given disappoint me even
more.

Please don't submit any more sparc patches until you can get you act
in gear and not waste everyone's time.

Thank you.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  5:45               ` SF Markus Elfring
  2016-09-04  5:59                 ` Julian Calaby
@ 2016-09-04  6:34                 ` David Miller
  1 sibling, 0 replies; 1373+ messages in thread
From: David Miller @ 2016-09-04  6:34 UTC (permalink / raw)
  To: elfring
  Cc: julian.calaby, sparclinux, adam.buchbinder, ast, daniel, rabin,
	linux-kernel, kernel-janitors, julia.lawall, pbonzini

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 07:45:04 +0200

>> and wasting everyone's time in the process.
> 
> I assume that a few contributors can take the presented ideas for further considerations.
> Will their value evolve a bit more later?

No, really, you are wasting everyone's time.

And as the sole maintainer of the sparc port, you are specifically
wasting mine.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  6:32             ` David Miller
@ 2016-09-04  6:44               ` Julian Calaby
  2016-09-04  7:07                 ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  6:44 UTC (permalink / raw)
  To: David Miller
  Cc: SF Markus Elfring, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, Daniel Borkmann, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini

Hi David,

On Sun, Sep 4, 2016 at 4:32 PM, David Miller <davem@davemloft.net> wrote:
>
> Markus, I'm really not going to consider any of these changes.
>
> And your replies to the feedback you were given disappoint me even
> more.
>
> Please don't submit any more sparc patches until you can get you act
> in gear and not waste everyone's time.

In Markus' defence, he does occasionally write okay patches, (for
example the kmalloc(a * b) => kmalloc_array(a, b) changes get my small
tick of approval) however he also submits a lot of patches which are
little more than moving stuff around pointlessly.

I really wish he'd concentrate on the former rather than the latter.

He's not another Nick Krause.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  6:06       ` David Miller
@ 2016-09-04  6:50         ` SF Markus Elfring
  2016-09-04  6:59           ` David Miller
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  6:50 UTC (permalink / raw)
  To: David Miller
  Cc: Daniel Borkmann, sparclinux, Adam Buchbinder, Alexei Starovoitov,
	Rabin Vincent, linux-kernel, kernel-janitors, Julia Lawall,
	Paolo Bonzini, linux-doc, Jean Delvare

>> NAK, just noise.
> 
> And frankly I hate that leading space.

Would you like to comment the recent update of the document "CodingStyle" any more?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  6:50         ` SF Markus Elfring
@ 2016-09-04  6:59           ` David Miller
  2016-09-04  7:20             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: David Miller @ 2016-09-04  6:59 UTC (permalink / raw)
  To: elfring
  Cc: daniel, sparclinux, adam.buchbinder, ast, rabin, linux-kernel,
	kernel-janitors, julia.lawall, pbonzini, linux-doc, jdelvare

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 08:50:20 +0200

>>> NAK, just noise.
>> 
>> And frankly I hate that leading space.
> 
> Would you like to comment the recent update of the document "CodingStyle" any more?
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51

You seem to lack understanding of the difference between absolute
requirements and "advice".

As Sparc maintainer I can choose to not take this "advice", and I so
choose to do so.

If you want to be completely ignored by me, then keep arguing the way
you are right now.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  6:44               ` Julian Calaby
@ 2016-09-04  7:07                 ` SF Markus Elfring
  2016-09-04  7:18                   ` Julian Calaby
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  7:07 UTC (permalink / raw)
  To: Julian Calaby
  Cc: David Miller, sparclinux, Adam Buchbinder, Alexei Starovoitov,
	Daniel Borkmann, Rabin Vincent, linux-kernel, kernel-janitors,
	Julia Lawall, Paolo Bonzini

> In Markus' defence, he does occasionally write okay patches,
> (for example the kmalloc(a * b) => kmalloc_array(a, b) changes
> get my small tick of approval)

Thanks for another bit of acceptance for this kind of software change.


> however he also submits a lot of patches which are little more than moving stuff around

This is true to some degree.


> pointlessly.

Do we agree to disagree on the value of some collateral software evolutions
I'm proposing for a while?


> I really wish he'd concentrate on the former rather than the latter.

I am on the way for such a software development adventure.
There are further improvement opportunities to consider besides the main route,
aren't there?


> He's not another Nick Krause.

Are you going to remember me under an other nickname anyhow?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  7:07                 ` SF Markus Elfring
@ 2016-09-04  7:18                   ` Julian Calaby
  0 siblings, 0 replies; 1373+ messages in thread
From: Julian Calaby @ 2016-09-04  7:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: David Miller, sparclinux, Adam Buchbinder, Alexei Starovoitov,
	Daniel Borkmann, Rabin Vincent, linux-kernel, kernel-janitors,
	Julia Lawall, Paolo Bonzini

Hi Markus,

On Sun, Sep 4, 2016 at 5:07 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> I really wish he'd concentrate on the former rather than the latter.
>
> I am on the way for such a software development adventure.
> There are further improvement opportunities to consider besides the main route,
> aren't there?

You're missing the point here. Find something useful to change.

People are going through the kernel finding functions that should be
static for example - this is useful as it provides better
documentation for those functions (static == not used outside this
file) and fixes errors reported by GCC and static code checkers. Those
changes are useful.

Another useful change would be ensuring that every struct that has a
bool member is kzalloc'd instead of kmalloc'd as this eliminates a
possible source of undefined behaviour. (A bool is effectively a u8
with behaviour defined for when that value is 0 or 1, kmalloc'd memory
can have any data in it, therefore it's possible and likely that a
kmalloc'd struct with a bool member will end up with some value for
that member that isn't 0 or 1. kzalloc eliminates this possibility.)

Moving four assignments because you think they might improve stuff is
just annoying people.

>> He's not another Nick Krause.
>
> Are you going to remember me under an other nickname anyhow?

Nick Krause submitted patches that make yours look good. At least yours compile.

Thanks,

-- 
Julian Calaby

Email: julian.calaby@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  6:59           ` David Miller
@ 2016-09-04  7:20             ` SF Markus Elfring
  2016-09-04  7:32               ` David Miller
  2016-09-04  9:56               ` Daniel Borkmann
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  7:20 UTC (permalink / raw)
  To: David Miller
  Cc: Daniel Borkmann, sparclinux, Adam Buchbinder, Alexei Starovoitov,
	Rabin Vincent, linux-kernel, kernel-janitors, Julia Lawall,
	Paolo Bonzini, linux-doc, Jean Delvare

>> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51
> 
> You seem to lack understanding of the difference between absolute
> requirements and "advice".
> 
> As Sparc maintainer I can choose to not take this "advice",
> and I so choose to do so.

Your conclusion can be fine in principle.

I am just curious on how much further software development "fun" the recent update
by a topic like "CodingStyle: Clarify and complete chapter 7" will trigger.


> If you want to be completely ignored by me,

I hope that this action does not need to happen.


> then keep arguing the way you are right now.

I guess that I will stumble on more software improvement opportunities
you find harder to become comfortable with.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  7:20             ` SF Markus Elfring
@ 2016-09-04  7:32               ` David Miller
  2016-09-04  7:40                 ` SF Markus Elfring
  2016-09-04  9:56               ` Daniel Borkmann
  1 sibling, 1 reply; 1373+ messages in thread
From: David Miller @ 2016-09-04  7:32 UTC (permalink / raw)
  To: elfring
  Cc: daniel, sparclinux, adam.buchbinder, ast, rabin, linux-kernel,
	kernel-janitors, julia.lawall, pbonzini, linux-doc, jdelvare

From: SF Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 09:20:55 +0200

> I guess that I will stumble on more software improvement opportunities
> you find harder to become comfortable with.

Improvement is a matter of opinion.  So your statement assumes that
your changes are an improvement, and everyone in this thread clearly
disagrees with that.

This is why everything you are doing here is so irritating.

It's not because I find improvements "uncomfortable", but rather it's
because your changes are not seen as improvements in the first place.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  7:32               ` David Miller
@ 2016-09-04  7:40                 ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04  7:40 UTC (permalink / raw)
  To: David Miller
  Cc: Daniel Borkmann, sparclinux, Adam Buchbinder, Alexei Starovoitov,
	Rabin Vincent, linux-kernel, kernel-janitors, Julia Lawall,
	Paolo Bonzini, linux-doc, Jean Delvare

> It's not because I find improvements "uncomfortable", but rather it's
> because your changes are not seen as improvements in the first place.

What is your software development opinion for the update step
"[1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile()"
from this small patch series?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  7:20             ` SF Markus Elfring
  2016-09-04  7:32               ` David Miller
@ 2016-09-04  9:56               ` Daniel Borkmann
  2016-09-04 13:50                 ` Clarification for source code formatting around jump labels SF Markus Elfring
  2016-09-05 11:07                 ` sparc: bpf_jit: Rename jump labels in bpf_jit_compile() Jean Delvare
  1 sibling, 2 replies; 1373+ messages in thread
From: Daniel Borkmann @ 2016-09-04  9:56 UTC (permalink / raw)
  To: Jonathan Corbet
  Cc: SF Markus Elfring, David Miller, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, Rabin Vincent, linux-kernel, kernel-janitors,
	Julia Lawall, Paolo Bonzini, linux-doc, Jean Delvare

On 09/04/2016 09:20 AM, SF Markus Elfring wrote:
>>> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51

[ + Jonathan for above commit in linux-next ]

>> You seem to lack understanding of the difference between absolute
>> requirements and "advice".
>>
>> As Sparc maintainer I can choose to not take this "advice",
>> and I so choose to do so.
>
> Your conclusion can be fine in principle.
>
> I am just curious on how much further software development "fun" the recent update
> by a topic like "CodingStyle: Clarify and complete chapter 7" will trigger.

I don't want to drag this thread onwards for (way) too long, but clearly "it is
advised to indent labels with a single space (not tab)" (from diff in above commit)
doesn't really reflect the majority of kernel practice we have in-tree today and
actually rather adds more confusion than any clarification whatsoever:

   $ git grep -n "^\ [a-z_]*:" -- '*.[ch]' | wc -l
   4919
   $ git grep -n "^[a-z_]*:" -- '*.[ch]' | wc -l
   54686

A CodingStyle document should document what's regarded as a general consensus of
kernel coding practices, and thus should represent the /majority/ of coding style,
which (if I didn't screw up my git-grep line completely) above 9% does not really
reflect at all. So, new folks starting with kernel hacking reading this are rather
misguided, and code-wise it just adds up to have more inconsistencies from new
patches, or worse, have noisy patches (like this one) flying around that try to
brute-force everything into this advice.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Clarification for source code formatting around jump labels
  2016-09-04  9:56               ` Daniel Borkmann
@ 2016-09-04 13:50                 ` SF Markus Elfring
  2016-09-04 17:04                   ` Daniel Borkmann
  2016-09-05 11:07                 ` sparc: bpf_jit: Rename jump labels in bpf_jit_compile() Jean Delvare
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 13:50 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Jonathan Corbet, David Miller, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, Rabin Vincent, linux-kernel, kernel-janitors,
	Julia Lawall, Paolo Bonzini, linux-doc, Jean Delvare

>> I am just curious on how much further software development "fun" the recent update
>> by a topic like "CodingStyle: Clarify and complete chapter 7" will trigger.
> 
> I don't want to drag this thread onwards for (way) too long, but clearly "it is
> advised to indent labels with a single space (not tab)" (from diff in above commit)

How do you think about the reason (which you omitted from your quotation) for this advice?

“…,
so that "diff -p" does not confuse labels with functions.
…”


> doesn't really reflect the majority of kernel practice we have in-tree today and
> actually rather adds more confusion than any clarification whatsoever:
> 
>   $ git grep -n "^\ [a-z_]*:" -- '*.[ch]' | wc -l
>   4919
>   $ git grep -n "^[a-z_]*:" -- '*.[ch]' | wc -l
>   54686

So there is a mixture already.


> A CodingStyle document should document what's regarded as a general consensus of
> kernel coding practices, and thus should represent the /majority/ of coding style,
> which (if I didn't screw up my git-grep line completely)

1. Is the used character class specification complete in the shown regular expression?

2. I guess that you should use the regex operator "plus" (instead of the asterisk).

3. Would you like to try another source code analysis out which can be a bit safer
   with the usage of the semantic patch language?


> above 9% does not really reflect at all.

How tolerant are you for using an extra space character before the identifier for
a jump label?


> So, new folks starting with kernel hacking reading this are rather misguided,
> and code-wise it just adds up to have more inconsistencies from new patches,
> or worse, have noisy patches (like this one) flying around that try to
> brute-force everything into this advice.

In which ways would you prefer that the style specifications should be
clarified further?

Where should source code become more consistent?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Clarification for source code formatting around jump labels
  2016-09-04 13:50                 ` Clarification for source code formatting around jump labels SF Markus Elfring
@ 2016-09-04 17:04                   ` Daniel Borkmann
  0 siblings, 0 replies; 1373+ messages in thread
From: Daniel Borkmann @ 2016-09-04 17:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jonathan Corbet, David Miller, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, Rabin Vincent, linux-kernel, kernel-janitors,
	Julia Lawall, Paolo Bonzini, linux-doc, Jean Delvare

On 09/04/2016 03:50 PM, SF Markus Elfring wrote:
>>> I am just curious on how much further software development "fun" the recent update
>>> by a topic like "CodingStyle: Clarify and complete chapter 7" will trigger.
>>
>> I don't want to drag this thread onwards for (way) too long, but clearly "it is
>> advised to indent labels with a single space (not tab)" (from diff in above commit)
>
> How do you think about the reason (which you omitted from your quotation) for this advice?
>
> “…,
> so that "diff -p" does not confuse labels with functions.
> …”

Yep, since this recently came up in a different thread as well, please
see here, for example:

   http://patchwork.ozlabs.org/patch/664966/

>> doesn't really reflect the majority of kernel practice we have in-tree today and
>> actually rather adds more confusion than any clarification whatsoever:
>>
>>    $ git grep -n "^\ [a-z_]*:" -- '*.[ch]' | wc -l
>>    4919
>>    $ git grep -n "^[a-z_]*:" -- '*.[ch]' | wc -l
>>    54686
>
> So there is a mixture already.
>
[...]
> In which ways would you prefer that the style specifications should be
> clarified further?
>
> Where should source code become more consistent?

It would likely make sense to document that git config mentioned in the
link above as a recommendation for that paragraph, and stick with what
is used in the vast majority of cases already, meaning no leading space
before labels.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (73 preceding siblings ...)
  2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
@ 2016-09-04 17:49 ` SF Markus Elfring
  2016-09-04 17:54   ` [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init() SF Markus Elfring
                     ` (4 more replies)
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                   ` (20 subsequent siblings)
  95 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 17:49 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Peter Zijlstra, Richard Cochran, Stephane Eranian,
	Thomas Gleixner, Tony Luck, Vikas Shivappa
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 19:40:40 +0200

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

Markus Elfring (4):
  Use kmalloc_array() in intel_mbm_init()
  Replace two kmalloc() calls by kmalloc_array() in intel_mbm_init()
  One check and another variable less in intel_mbm_init()
  Rename jump labels in intel_cqm_init()

 arch/x86/events/intel/cqm.c | 52 ++++++++++++++++++++++-----------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init()
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-04 17:54   ` SF Markus Elfring
  2016-09-05  7:52     ` Peter Zijlstra
  2016-09-04 17:56   ` [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by " SF Markus Elfring
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 17:54 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Peter Zijlstra, Richard Cochran, Stephane Eranian,
	Thomas Gleixner, Tony Luck, Vikas Shivappa
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 17:28:13 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/events/intel/cqm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 783c49d..ec61522 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -1651,8 +1651,9 @@ static int intel_mbm_init(void)
 		goto out;
 	}
 
-	array_size = sizeof(struct hrtimer) * mbm_socket_max;
-	mbm_timers = kmalloc(array_size, GFP_KERNEL);
+	mbm_timers = kmalloc_array(mbm_socket_max,
+				   sizeof(*mbm_timers),
+				   GFP_KERNEL);
 	if (!mbm_timers) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by kmalloc_array() in intel_mbm_init()
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-04 17:54   ` [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init() SF Markus Elfring
@ 2016-09-04 17:56   ` SF Markus Elfring
  2016-09-05  7:53     ` Peter Zijlstra
  2016-09-04 17:58   ` [PATCH 3/4] perf/x86/cqm: One check and another variable less " SF Markus Elfring
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 17:56 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Peter Zijlstra, Richard Cochran, Stephane Eranian,
	Thomas Gleixner, Tony Luck, Vikas Shivappa
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 18:25:09 +0200

1. A multiplication for the size determination of memory allocations
   indicated that array data structures should be processed.
   Thus use the corresponding function "kmalloc_array".

2. Replace the specification of a data structure by pointer dereferences
   to make the corresponding size determination a bit safer according to
   the Linux coding style convention.

3. Delete the local variable "array_size" which became unnecessary
   with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/events/intel/cqm.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index ec61522..29f756e 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -1637,15 +1637,18 @@ static const struct x86_cpu_id intel_mbm_total_match[] = {
 
 static int intel_mbm_init(void)
 {
-	int ret = 0, array_size, maxid = cqm_max_rmid + 1;
+	int ret = 0, maxid = cqm_max_rmid + 1;
 
 	mbm_socket_max = topology_max_packages();
-	array_size = sizeof(struct sample) * maxid * mbm_socket_max;
-	mbm_local = kmalloc(array_size, GFP_KERNEL);
+	mbm_local = kmalloc_array(maxid * mbm_socket_max,
+				  sizeof(*mbm_local),
+				  GFP_KERNEL);
 	if (!mbm_local)
 		return -ENOMEM;
 
-	mbm_total = kmalloc(array_size, GFP_KERNEL);
+	mbm_total = kmalloc_array(maxid * mbm_socket_max,
+				  sizeof(*mbm_total),
+				  GFP_KERNEL);
 	if (!mbm_total) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] perf/x86/cqm: One check and another variable less in intel_mbm_init()
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-04 17:54   ` [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init() SF Markus Elfring
  2016-09-04 17:56   ` [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by " SF Markus Elfring
@ 2016-09-04 17:58   ` SF Markus Elfring
  2016-09-05  7:54     ` Peter Zijlstra
  2016-09-04 18:00   ` [PATCH 4/4] perf/x86/cqm: Rename jump labels in intel_cqm_init() SF Markus Elfring
  2016-09-05  7:55   ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations Peter Zijlstra
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 17:58 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Peter Zijlstra, Richard Cochran, Stephane Eranian,
	Thomas Gleixner, Tony Luck, Vikas Shivappa
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 19:06:33 +0200

1. Adjust a jump target to eliminate an extra check at the end.

2. Move a jump label according to the current Linux coding style convention.

3. Return only constant values for the success or failure indication.

4. Delete the local variable "ret" which became unnecessary with
   this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/events/intel/cqm.c | 25 ++++++++++---------------
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 29f756e..304caf53 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -1637,7 +1637,7 @@ static const struct x86_cpu_id intel_mbm_total_match[] = {
 
 static int intel_mbm_init(void)
 {
-	int ret = 0, maxid = cqm_max_rmid + 1;
+	int const maxid = cqm_max_rmid + 1;
 
 	mbm_socket_max = topology_max_packages();
 	mbm_local = kmalloc_array(maxid * mbm_socket_max,
@@ -1649,25 +1649,20 @@ static int intel_mbm_init(void)
 	mbm_total = kmalloc_array(maxid * mbm_socket_max,
 				  sizeof(*mbm_total),
 				  GFP_KERNEL);
-	if (!mbm_total) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	if (!mbm_total)
+		goto free_mbm;
 
 	mbm_timers = kmalloc_array(mbm_socket_max,
 				   sizeof(*mbm_timers),
 				   GFP_KERNEL);
-	if (!mbm_timers) {
-		ret = -ENOMEM;
-		goto out;
-	}
-	mbm_hrtimer_init();
+	if (!mbm_timers)
+		goto free_mbm;
 
-out:
-	if (ret)
-		mbm_cleanup();
-
-	return ret;
+	mbm_hrtimer_init();
+	return 0;
+ free_mbm:
+	mbm_cleanup();
+	return -ENOMEM;
 }
 
 static int __init intel_cqm_init(void)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] perf/x86/cqm: Rename jump labels in intel_cqm_init()
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-04 17:58   ` [PATCH 3/4] perf/x86/cqm: One check and another variable less " SF Markus Elfring
@ 2016-09-04 18:00   ` SF Markus Elfring
  2016-09-05  7:55   ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations Peter Zijlstra
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-04 18:00 UTC (permalink / raw)
  To: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Peter Zijlstra, Richard Cochran, Stephane Eranian,
	Thomas Gleixner, Tony Luck, Vikas Shivappa
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 4 Sep 2016 19:23:57 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/x86/events/intel/cqm.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
index 304caf53..6cf508a 100644
--- a/arch/x86/events/intel/cqm.c
+++ b/arch/x86/events/intel/cqm.c
@@ -1701,7 +1701,7 @@ static int __init intel_cqm_init(void)
 		if (c->x86_cache_occ_scale != cqm_l3_scale) {
 			pr_err("Multiple LLC scale values, disabling\n");
 			ret = -EINVAL;
-			goto out;
+			goto put_cpus;
 		}
 	}
 
@@ -1719,19 +1719,19 @@ static int __init intel_cqm_init(void)
 	str = kstrdup(scale, GFP_KERNEL);
 	if (!str) {
 		ret = -ENOMEM;
-		goto out;
+		goto put_cpus;
 	}
 
 	event_attr_intel_cqm_llc_scale.event_str = str;
 
 	ret = intel_cqm_setup_rmid_cache();
 	if (ret)
-		goto out;
+		goto put_cpus;
 
 	if (mbm_enabled)
 		ret = intel_mbm_init();
 	if (ret && !cqm_enabled)
-		goto out;
+		goto put_cpus;
 
 	if (cqm_enabled && mbm_enabled)
 		intel_cqm_events_group.attrs = intel_cmt_mbm_events_attr;
@@ -1743,7 +1743,7 @@ static int __init intel_cqm_init(void)
 	ret = perf_pmu_register(&intel_cqm_pmu, "intel_cqm", -1);
 	if (ret) {
 		pr_err("Intel CQM perf registration failed: %d\n", ret);
-		goto out;
+		goto put_cpus;
 	}
 
 	if (cqm_enabled)
@@ -1760,8 +1760,7 @@ static int __init intel_cqm_init(void)
 			  intel_cqm_cpu_starting, NULL);
 	cpuhp_setup_state(CPUHP_AP_PERF_X86_CQM_ONLINE, "AP_PERF_X86_CQM_ONLINE",
 			  NULL, intel_cqm_cpu_exit);
-
-out:
+ put_cpus:
 	put_online_cpus();
 
 	if (ret) {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] sparc: bpf_jit: Move four assignments in bpf_jit_compile()
  2016-09-04  4:44         ` Julian Calaby
  2016-09-04  5:00           ` SF Markus Elfring
@ 2016-09-04 19:33           ` Bjørn Mork
  1 sibling, 0 replies; 1373+ messages in thread
From: Bjørn Mork @ 2016-09-04 19:33 UTC (permalink / raw)
  To: Julian Calaby
  Cc: SF Markus Elfring, sparclinux, Adam Buchbinder,
	Alexei Starovoitov, Daniel Borkmann, David S. Miller,
	Rabin Vincent, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini

Julian Calaby <julian.calaby@gmail.com> writes:

> Otherwise this change is useless churn - you're making the code more
> complicated, longer and harder to read for practically no benefit.

He has been doing that for years now. And wasted maintainer resources
along the way, discussing all the pointless churn.  There are zero
indications that this will ever change from his side.

Do not feed.


Bjørn

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init()
  2016-09-04 17:54   ` [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init() SF Markus Elfring
@ 2016-09-05  7:52     ` Peter Zijlstra
  0 siblings, 0 replies; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05  7:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Richard Cochran, Stephane Eranian, Thomas Gleixner, Tony Luck,
	Vikas Shivappa, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini

On Sun, Sep 04, 2016 at 07:54:47PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 4 Sep 2016 17:28:13 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data structure by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.

Again, lack of actual reason..

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by kmalloc_array() in intel_mbm_init()
  2016-09-04 17:56   ` [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by " SF Markus Elfring
@ 2016-09-05  7:53     ` Peter Zijlstra
  0 siblings, 0 replies; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05  7:53 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Richard Cochran, Stephane Eranian, Thomas Gleixner, Tony Luck,
	Vikas Shivappa, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini

On Sun, Sep 04, 2016 at 07:56:30PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 4 Sep 2016 18:25:09 +0200
> 
> 1. A multiplication for the size determination of memory allocations
>    indicated that array data structures should be processed.
>    Thus use the corresponding function "kmalloc_array".
> 
> 2. Replace the specification of a data structure by pointer dereferences
>    to make the corresponding size determination a bit safer according to
>    the Linux coding style convention.
> 
> 3. Delete the local variable "array_size" which became unnecessary
>    with this refactoring.

3 is an admission you made the code worse in absense of other
improvements.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] perf/x86/cqm: One check and another variable less in intel_mbm_init()
  2016-09-04 17:58   ` [PATCH 3/4] perf/x86/cqm: One check and another variable less " SF Markus Elfring
@ 2016-09-05  7:54     ` Peter Zijlstra
  0 siblings, 0 replies; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05  7:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Richard Cochran, Stephane Eranian, Thomas Gleixner, Tony Luck,
	Vikas Shivappa, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini

On Sun, Sep 04, 2016 at 07:58:32PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 4 Sep 2016 19:06:33 +0200
> 
> 1. Adjust a jump target to eliminate an extra check at the end.
> 
> 2. Move a jump label according to the current Linux coding style convention.

WTF does that even mean?

> 
> 3. Return only constant values for the success or failure indication.
> 
> 4. Delete the local variable "ret" which became unnecessary with
>    this refactoring.

Also, 4 things should be 4 patches if anything.

> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  arch/x86/events/intel/cqm.c | 25 ++++++++++---------------
>  1 file changed, 10 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/x86/events/intel/cqm.c b/arch/x86/events/intel/cqm.c
> index 29f756e..304caf53 100644
> --- a/arch/x86/events/intel/cqm.c
> +++ b/arch/x86/events/intel/cqm.c
> @@ -1637,7 +1637,7 @@ static const struct x86_cpu_id intel_mbm_total_match[] = {
>  
>  static int intel_mbm_init(void)
>  {
> -	int ret = 0, maxid = cqm_max_rmid + 1;
> +	int const maxid = cqm_max_rmid + 1;
>  
>  	mbm_socket_max = topology_max_packages();
>  	mbm_local = kmalloc_array(maxid * mbm_socket_max,
> @@ -1649,25 +1649,20 @@ static int intel_mbm_init(void)
>  	mbm_total = kmalloc_array(maxid * mbm_socket_max,
>  				  sizeof(*mbm_total),
>  				  GFP_KERNEL);
> -	if (!mbm_total) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> +	if (!mbm_total)
> +		goto free_mbm;
>  
>  	mbm_timers = kmalloc_array(mbm_socket_max,
>  				   sizeof(*mbm_timers),
>  				   GFP_KERNEL);
> -	if (!mbm_timers) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> -	mbm_hrtimer_init();
> +	if (!mbm_timers)
> +		goto free_mbm;
>  
> -out:
> -	if (ret)
> -		mbm_cleanup();
> -
> -	return ret;
> +	mbm_hrtimer_init();
> +	return 0;
> + free_mbm:

No!! no stupid indented labels.

> +	mbm_cleanup();
> +	return -ENOMEM;
>  }

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-04 18:00   ` [PATCH 4/4] perf/x86/cqm: Rename jump labels in intel_cqm_init() SF Markus Elfring
@ 2016-09-05  7:55   ` Peter Zijlstra
  4 siblings, 0 replies; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05  7:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: x86, Borislav Petkov, H. Peter Anvin, Ingo Molnar,
	Richard Cochran, Stephane Eranian, Thomas Gleixner, Tony Luck,
	Vikas Shivappa, LKML, kernel-janitors, Julia Lawall,
	Paolo Bonzini



Send me more of this mindless gunk and you're on a /dev/null filter.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/17] s390/debug: Fine-tuning for several function implementations
  2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
                     ` (16 preceding siblings ...)
  2016-09-03 12:40   ` [PATCH 17/17] s390/debug: Improve another size determination " SF Markus Elfring
@ 2016-09-05 10:31   ` Martin Schwidefsky
  2016-09-05 10:40     ` SF Markus Elfring
  2016-09-09 16:50     ` SF Markus Elfring
  17 siblings, 2 replies; 1373+ messages in thread
From: Martin Schwidefsky @ 2016-09-05 10:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches, LKML,
	kernel-janitors, Julia Lawall, Paolo Bonzini

On Sat, 3 Sep 2016 14:04:18 +0200
SF Markus Elfring <elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 13:54:32 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (17):
>   Use kmalloc_array() in debug_areas_alloc()
>   Delete unnecessary braces
>   Add some spaces for better code readability
>   Rename jump labels in debug_areas_alloc()
>   Fix jump targets in debug_info_alloc()
>   Rename jump labels in debug_info_copy()
>   Rename jump labels in debug_open()
>   Fix a jump target in debug_register_mode()
>   Return directly if a null pointer was passed to debug_unregister()
>   Delete an unnecessary initialisation in debug_prolog_level_fn()
>   Fix indentation in 13 functions
>   Use memdup_user() rather than duplicating its implementation
>   Improve a size determination in debug_open()
>   Improve a size determination in debug_sprintf_format_fn()
>   Improve a size determination in debug_raw_header_fn()
>   Improve determination of sizes in debug_info_alloc()
>   Improve another size determination in debug_info_alloc()
> 
>  arch/s390/kernel/debug.c | 433 ++++++++++++++++++++++-------------------------
>  1 file changed, 204 insertions(+), 229 deletions(-)
 
While I agree that the old code in arch/s390/kernel/debug.c does not abide to
the current coding style standards, I doubt there is much value in these patches.
To be honest I got annoyed after the third patch and stopped reading after
the forth. 

NAK.

-- 
blue skies,
   Martin.

"Reality continues to ruin my life." - Calvin.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: s390/debug: Fine-tuning for several function implementations
  2016-09-05 10:31   ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations Martin Schwidefsky
@ 2016-09-05 10:40     ` SF Markus Elfring
  2016-09-09 16:50     ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 10:40 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches, LKML,
	kernel-janitors, Julia Lawall, Paolo Bonzini

> While I agree that the old code in arch/s390/kernel/debug.c does not abide to
> the current coding style standards, I doubt there is much value in these patches.

How do you value the recommended compliance with the current Linux coding style convention?

Will my contribution be useful for further considerations?


> To be honest I got annoyed after the third patch

Thanks for your response.


> and stopped reading after the forth.

Does anybody in your company care for further improvements also in this software module?

Are there still opportunities to continue development in more constructive ways here?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-04  9:56               ` Daniel Borkmann
  2016-09-04 13:50                 ` Clarification for source code formatting around jump labels SF Markus Elfring
@ 2016-09-05 11:07                 ` Jean Delvare
  2016-09-05 11:37                   ` Peter Zijlstra
  1 sibling, 1 reply; 1373+ messages in thread
From: Jean Delvare @ 2016-09-05 11:07 UTC (permalink / raw)
  To: Daniel Borkmann
  Cc: Jonathan Corbet, Peter Zijlstra, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

Hi Daniel,

Preliminary note: the SNR of Markus Elfring is incredibly low. I advise
you just ignore him.

On Sun, 04 Sep 2016 11:56:58 +0200, Daniel Borkmann wrote:
> I don't want to drag this thread onwards for (way) too long, but clearly "it is
> advised to indent labels with a single space (not tab)" (from diff in above commit)
> doesn't really reflect the majority of kernel practice we have in-tree today and
> actually rather adds more confusion than any clarification whatsoever:
> 
>    $ git grep -n "^\ [a-z_]*:" -- '*.[ch]' | wc -l
>    4919
>    $ git grep -n "^[a-z_]*:" -- '*.[ch]' | wc -l
>    54686

Well the documentation update in question has not hit mainline yet, so
it's not really surprising.

> A CodingStyle document should document what's regarded as a general consensus of
> kernel coding practices, and thus should represent the /majority/ of coding style,

I beg to disagree. Recommendations are not meant to document what
people are currently doing but what we think they should be doing. By
your reasoning, we would have killed all the devm infrastructure,
because at some point in time (and it might still be the case) most
drivers were not using it.

There is a rationale for the leading space, it is given in the patch,
but sadly you decided to not quote it above.

> which (if I didn't screw up my git-grep line completely) above 9% does not really
> reflect at all. So, new folks starting with kernel hacking reading this are rather

Your grep patterns are slightly inaccurate. Space doesn't need to be
escaped, labels can use capital letters, and except for the first
character, digits are accepted too. Also to be completely fair, you
should also count the labels which are intended using tabs. But it
doesn't change the balance noticeably anyway, so no big deal.

> misguided, and code-wise it just adds up to have more inconsistencies from new
> patches, or worse, have noisy patches (like this one) flying around that try to
> brute-force everything into this advice.

Guys who like to waste our time with pointless patches will always find
a way to do that, sadly, so I don't think this point is relevant.

The acceptance of an optional single space before labels dates back to
at least June 2007, as supported by the very first incarnation of
checkpatch.pl. So nothing really new here, except for a preference
(my preference, admittedly, but I'm know I'm not alone) being expressed
in the coding style document.

My assumption was that the behavior of "diff -p" would never change, as
despite the language-specificity of its long option name, it seemed too
generic to be loaded with C-specific rules.

Now I see in http://patchwork.ozlabs.org/patch/664966/ that Peter
Zijlstra reportedly changed the behavior of "diff -p" so that it
handles unindented C labels nicely. If this actually happens, it could
change my point of view. However I can't find this commit in upstream
diffutils. Peter, can you please clarify the situation? Is it just a
local hack on your own instance of "diff"?

Even if upstream diff is ever changed, it will take some time until new
versions propagate to all developers. And until this happens, my
preference for one-space-indented labels will remain.

Also git has its own implementation of "diff", so any change in the
behavior of GNU diff's -p and/or --show-c-function options should be
reflected there as well for consistency.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-05 11:07                 ` sparc: bpf_jit: Rename jump labels in bpf_jit_compile() Jean Delvare
@ 2016-09-05 11:37                   ` Peter Zijlstra
  2016-09-05 11:54                     ` Jean Delvare
  0 siblings, 1 reply; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05 11:37 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

On Mon, Sep 05, 2016 at 01:07:37PM +0200, Jean Delvare wrote:
> Now I see in http://patchwork.ozlabs.org/patch/664966/ that Peter
> Zijlstra reportedly changed the behavior of "diff -p" so that it
> handles unindented C labels nicely. If this actually happens, it could
> change my point of view. However I can't find this commit in upstream
> diffutils. Peter, can you please clarify the situation? Is it just a
> local hack on your own instance of "diff"?

I have it in my local .gitconfig, and recommend it to people who send me
patches.

I've never tried to get diffutils fixed, although maybe I should.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-05 11:37                   ` Peter Zijlstra
@ 2016-09-05 11:54                     ` Jean Delvare
  2016-09-05 11:58                       ` Peter Zijlstra
  0 siblings, 1 reply; 1373+ messages in thread
From: Jean Delvare @ 2016-09-05 11:54 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

On Mon, 5 Sep 2016 13:37:04 +0200, Peter Zijlstra wrote:
> On Mon, Sep 05, 2016 at 01:07:37PM +0200, Jean Delvare wrote:
> > Now I see in http://patchwork.ozlabs.org/patch/664966/ that Peter
> > Zijlstra reportedly changed the behavior of "diff -p" so that it
> > handles unindented C labels nicely. If this actually happens, it could
> > change my point of view. However I can't find this commit in upstream
> > diffutils. Peter, can you please clarify the situation? Is it just a
> > local hack on your own instance of "diff"?
> 
> I have it in my local .gitconfig, and recommend it to people who send me
> patches.

What does it look like, please?

> I've never tried to get diffutils fixed, although maybe I should.

If you don't want one-space-indented labels to become the norm, then
yes you should.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-05 11:54                     ` Jean Delvare
@ 2016-09-05 11:58                       ` Peter Zijlstra
  2016-09-06 14:34                         ` Jean Delvare
  0 siblings, 1 reply; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-05 11:58 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

On Mon, Sep 05, 2016 at 01:54:45PM +0200, Jean Delvare wrote:
> On Mon, 5 Sep 2016 13:37:04 +0200, Peter Zijlstra wrote:
> > On Mon, Sep 05, 2016 at 01:07:37PM +0200, Jean Delvare wrote:
> > > Now I see in http://patchwork.ozlabs.org/patch/664966/ that Peter
> > > Zijlstra reportedly changed the behavior of "diff -p" so that it
> > > handles unindented C labels nicely. If this actually happens, it could
> > > change my point of view. However I can't find this commit in upstream
> > > diffutils. Peter, can you please clarify the situation? Is it just a
> > > local hack on your own instance of "diff"?
> > 
> > I have it in my local .gitconfig, and recommend it to people who send me
> > patches.
> 
> What does it look like, please?

[diff "default"]
        xfuncname = "^[[:alpha:]$_].*[^:]$"
[core]
	abbrev = 12
[alias]
	one = show -s --pretty='format:%h (\"%s\")'
[rerere]
	enable = true
	enabled = true
	autoupdate = true

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (74 preceding siblings ...)
  2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-05 16:42 ` SF Markus Elfring
  2016-09-05 16:45   ` [PATCH 01/21] ACPI-video: Use kmalloc_array() in acpi_video_get_levels() SF Markus Elfring
                     ` (21 more replies)
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                   ` (19 subsequent siblings)
  95 siblings, 22 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:42 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 18:22:11 +0200

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

Markus Elfring (21):
  Use kmalloc_array() in acpi_video_get_levels()
  Return directly after a failed device query
  Delete an error message for a failed kzalloc() call
  Rename jump labels in acpi_video_get_levels()
  Delete an unnecessary initialisation in acpi_video_get_levels()
  Move four assignments in acpi_video_get_levels()
  Rename jump labels in acpi_video_bus_add()
  Improve a size determination in acpi_video_bus_add()
  Rename jump labels in acpi_video_register()
  Return directly after a failed input_allocate_device()
  Rename jump labels in acpi_video_bus_add_notify_handler()
  Delete unnecessary if statement in acpi_video_switch_brightness()
  Improve a jump target in acpi_video_switch_brightness()
  Improve a size determination in acpi_video_device_enumerate()
  Delete an unnecessary initialisation in acpi_video_device_enumerate()
  Rename jump labels in acpi_video_device_enumerate()
  Delete an unnecessary initialisation in acpi_video_init_brightness()
  Rename jump labels in acpi_video_init_brightness()
  Rename a jump label in acpi_video_device_lcd_query_levels()
  Improve a size determination in acpi_video_dev_register_backlight()
  Improve a size determination in acpi_video_bus_get_one_device()

 drivers/acpi/acpi_video.c | 114 +++++++++++++++++++++-------------------------
 1 file changed, 52 insertions(+), 62 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/21] ACPI-video: Use kmalloc_array() in acpi_video_get_levels()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
@ 2016-09-05 16:45   ` SF Markus Elfring
  2016-09-05 16:46   ` [PATCH 02/21] ACPI-video: Return directly after a failed device query SF Markus Elfring
                     ` (20 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:45 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 11:33:30 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index c5557d0..3d39b53 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -784,8 +784,9 @@ int acpi_video_get_levels(struct acpi_device *device,
 		goto out;
 	}
 
-	br->levels = kmalloc((obj->package.count + 2) * sizeof *(br->levels),
-				GFP_KERNEL);
+	br->levels = kmalloc_array(obj->package.count + 2,
+				   sizeof(*br->levels),
+				   GFP_KERNEL);
 	if (!br->levels) {
 		result = -ENOMEM;
 		goto out_free;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/21] ACPI-video: Return directly after a failed device query
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
  2016-09-05 16:45   ` [PATCH 01/21] ACPI-video: Use kmalloc_array() in acpi_video_get_levels() SF Markus Elfring
@ 2016-09-05 16:46   ` SF Markus Elfring
  2016-09-05 16:48   ` [PATCH 03/21] ACPI-video: Delete an error message for a failed kzalloc() call SF Markus Elfring
                     ` (19 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:46 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 13:25:01 +0200

Return directly after a function call "acpi_video_device_lcd_query_levels"
failed at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 3d39b53..8f0807a 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -768,8 +768,7 @@ int acpi_video_get_levels(struct acpi_device *device,
 								&obj))) {
 		ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Could not query available "
 						"LCD brightness level\n"));
-		result = -ENODEV;
-		goto out;
+		return -ENODEV;
 	}
 
 	if (obj->package.count < 2) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/21] ACPI-video: Delete an error message for a failed kzalloc() call
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
  2016-09-05 16:45   ` [PATCH 01/21] ACPI-video: Use kmalloc_array() in acpi_video_get_levels() SF Markus Elfring
  2016-09-05 16:46   ` [PATCH 02/21] ACPI-video: Return directly after a failed device query SF Markus Elfring
@ 2016-09-05 16:48   ` SF Markus Elfring
  2016-09-05 16:50   ` [PATCH 04/21] ACPI-video: Rename jump labels in acpi_video_get_levels() SF Markus Elfring
                     ` (18 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:48 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 13:57:33 +0200

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 8f0807a..420d125 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -778,7 +778,6 @@ int acpi_video_get_levels(struct acpi_device *device,
 
 	br = kzalloc(sizeof(*br), GFP_KERNEL);
 	if (!br) {
-		printk(KERN_ERR "can't allocate memory\n");
 		result = -ENOMEM;
 		goto out;
 	}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/21] ACPI-video: Rename jump labels in acpi_video_get_levels()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-05 16:48   ` [PATCH 03/21] ACPI-video: Delete an error message for a failed kzalloc() call SF Markus Elfring
@ 2016-09-05 16:50   ` SF Markus Elfring
  2016-09-05 16:51   ` [PATCH 05/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
                     ` (17 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:50 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 14:11:43 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 420d125..82987db 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -773,13 +773,13 @@ int acpi_video_get_levels(struct acpi_device *device,
 
 	if (obj->package.count < 2) {
 		result = -EINVAL;
-		goto out;
+		goto free_object;
 	}
 
 	br = kzalloc(sizeof(*br), GFP_KERNEL);
 	if (!br) {
 		result = -ENOMEM;
-		goto out;
+		goto free_object;
 	}
 
 	br->levels = kmalloc_array(obj->package.count + 2,
@@ -787,7 +787,7 @@ int acpi_video_get_levels(struct acpi_device *device,
 				   GFP_KERNEL);
 	if (!br->levels) {
 		result = -ENOMEM;
-		goto out_free;
+		goto free_brightness;
 	}
 
 	for (i = 0; i < obj->package.count; i++) {
@@ -843,13 +843,12 @@ int acpi_video_get_levels(struct acpi_device *device,
 	*dev_br = br;
 	if (pmax_level)
 		*pmax_level = max_level;
-
-out:
+ free_object:
 	kfree(obj);
 	return result;
-out_free:
+ free_brightness:
 	kfree(br);
-	goto out;
+	goto free_object;
 }
 EXPORT_SYMBOL(acpi_video_get_levels);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_get_levels()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-05 16:50   ` [PATCH 04/21] ACPI-video: Rename jump labels in acpi_video_get_levels() SF Markus Elfring
@ 2016-09-05 16:51   ` SF Markus Elfring
  2016-09-05 16:52   ` [PATCH 06/21] ACPI-video: Move four assignments " SF Markus Elfring
                     ` (16 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:51 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 14:23:55 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 82987db..0799865 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -760,7 +760,7 @@ int acpi_video_get_levels(struct acpi_device *device,
 	union acpi_object *obj = NULL;
 	int i, max_level = 0, count = 0, level_ac_battery = 0;
 	union acpi_object *o;
-	struct acpi_video_device_brightness *br = NULL;
+	struct acpi_video_device_brightness *br;
 	int result = 0;
 	u32 value;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/21] ACPI-video: Move four assignments in acpi_video_get_levels()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-05 16:51   ` [PATCH 05/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-05 16:52   ` SF Markus Elfring
  2016-09-05 16:53   ` [PATCH 07/21] ACPI-video: Rename jump labels in acpi_video_bus_add() SF Markus Elfring
                     ` (15 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:52 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 14:40:46 +0200

Move the assignments for four local variables so that they will only
be performed if the corresponding data processing succeeded
by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 0799865..0fca196 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -758,10 +758,10 @@ int acpi_video_get_levels(struct acpi_device *device,
 			  int *pmax_level)
 {
 	union acpi_object *obj = NULL;
-	int i, max_level = 0, count = 0, level_ac_battery = 0;
+	int i, max_level, count, level_ac_battery;
 	union acpi_object *o;
 	struct acpi_video_device_brightness *br;
-	int result = 0;
+	int result;
 	u32 value;
 
 	if (!ACPI_SUCCESS(acpi_video_device_lcd_query_levels(device->handle,
@@ -790,6 +790,8 @@ int acpi_video_get_levels(struct acpi_device *device,
 		goto free_brightness;
 	}
 
+	max_level = 0;
+	count = 0;
 	for (i = 0; i < obj->package.count; i++) {
 		o = (union acpi_object *)&obj->package.elements[i];
 		if (o->type != ACPI_TYPE_INTEGER) {
@@ -814,6 +816,7 @@ int acpi_video_get_levels(struct acpi_device *device,
 	 * In this case, the first two elements in _BCL packages
 	 * are also supported brightness levels that OS should take care of.
 	 */
+	level_ac_battery = 0;
 	for (i = 2; i < count; i++) {
 		if (br->levels[i] == br->levels[0])
 			level_ac_battery++;
@@ -843,6 +846,7 @@ int acpi_video_get_levels(struct acpi_device *device,
 	*dev_br = br;
 	if (pmax_level)
 		*pmax_level = max_level;
+	result = 0;
  free_object:
 	kfree(obj);
 	return result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/21] ACPI-video: Rename jump labels in acpi_video_bus_add()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-05 16:52   ` [PATCH 06/21] ACPI-video: Move four assignments " SF Markus Elfring
@ 2016-09-05 16:53   ` SF Markus Elfring
  2016-09-05 16:54   ` [PATCH 08/21] ACPI-video: Improve a size determination " SF Markus Elfring
                     ` (14 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:53 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 15:01:23 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 0fca196..8003c90 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1983,14 +1983,14 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	acpi_video_bus_find_cap(video);
 	error = acpi_video_bus_check(video);
 	if (error)
-		goto err_free_video;
+		goto free_video;
 
 	mutex_init(&video->device_list_lock);
 	INIT_LIST_HEAD(&video->video_device_list);
 
 	error = acpi_video_bus_get_devices(video, device);
 	if (error)
-		goto err_put_video;
+		goto put_devices;
 
 	printk(KERN_INFO PREFIX "%s [%s] (multi-head: %s  rom: %s  post: %s)\n",
 	       ACPI_VIDEO_DEVICE_NAME, acpi_device_bid(device),
@@ -2005,11 +2005,10 @@ static int acpi_video_bus_add(struct acpi_device *device)
 	acpi_video_bus_add_notify_handler(video);
 
 	return 0;
-
-err_put_video:
+ put_devices:
 	acpi_video_bus_put_devices(video);
 	kfree(video->attached_array);
-err_free_video:
+ free_video:
 	kfree(video);
 	device->driver_data = NULL;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/21] ACPI-video: Improve a size determination in acpi_video_bus_add()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-05 16:53   ` [PATCH 07/21] ACPI-video: Rename jump labels in acpi_video_bus_add() SF Markus Elfring
@ 2016-09-05 16:54   ` SF Markus Elfring
  2016-09-05 16:56   ` [PATCH 09/21] ACPI-video: Rename jump labels in acpi_video_register() SF Markus Elfring
                     ` (13 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:54 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 15:16:26 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 8003c90..c9fbc6e 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1958,7 +1958,7 @@ static int acpi_video_bus_add(struct acpi_device *device)
 			return -ENODEV;
 	}
 
-	video = kzalloc(sizeof(struct acpi_video_bus), GFP_KERNEL);
+	video = kzalloc(sizeof(*video), GFP_KERNEL);
 	if (!video)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/21] ACPI-video: Rename jump labels in acpi_video_register()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-05 16:54   ` [PATCH 08/21] ACPI-video: Improve a size determination " SF Markus Elfring
@ 2016-09-05 16:56   ` SF Markus Elfring
  2016-09-05 16:57   ` [PATCH 10/21] ACPI-video: Return directly after a failed input_allocate_device() SF Markus Elfring
                     ` (12 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:56 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 15:28:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index c9fbc6e..74e5a40 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -2080,22 +2080,21 @@ int acpi_video_register(void)
 		 * if the function of acpi_video_register is already called,
 		 * don't register the acpi_vide_bus again and return no error.
 		 */
-		goto leave;
+		goto unlock;
 	}
 
 	dmi_check_system(video_dmi_table);
 
 	ret = acpi_bus_register_driver(&acpi_video_bus);
 	if (ret)
-		goto leave;
+		goto unlock;
 
 	/*
 	 * When the acpi_video_bus is loaded successfully, increase
 	 * the counter reference.
 	 */
 	register_count = 1;
-
-leave:
+ unlock:
 	mutex_unlock(&register_count_mutex);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/21] ACPI-video: Return directly after a failed input_allocate_device()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-05 16:56   ` [PATCH 09/21] ACPI-video: Rename jump labels in acpi_video_register() SF Markus Elfring
@ 2016-09-05 16:57   ` SF Markus Elfring
  2016-09-05 16:58   ` [PATCH 11/21] ACPI-video: Rename jump labels in acpi_video_bus_add_notify_handler() SF Markus Elfring
                     ` (11 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:57 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 15:46:19 +0200

* Return directly after a call of the function "input_allocate_device"
  failed at the beginning.

* Delete the jump label "out" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 74e5a40..6c871dd 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1852,10 +1852,8 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video)
 	int error;
 
 	video->input = input = input_allocate_device();
-	if (!input) {
-		error = -ENOMEM;
-		goto out;
-	}
+	if (!input)
+		return -ENOMEM;
 
 	error = acpi_video_bus_start_devices(video);
 	if (error)
@@ -1895,7 +1893,6 @@ err_stop_dev:
 err_free_input:
 	input_free_device(input);
 	video->input = NULL;
-out:
 	return error;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/21] ACPI-video: Rename jump labels in acpi_video_bus_add_notify_handler()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-05 16:57   ` [PATCH 10/21] ACPI-video: Return directly after a failed input_allocate_device() SF Markus Elfring
@ 2016-09-05 16:58   ` SF Markus Elfring
  2016-09-05 16:59   ` [PATCH 12/21] ACPI-video: Delete unnecessary if statement in acpi_video_switch_brightness() SF Markus Elfring
                     ` (10 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:58 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 15:50:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 6c871dd..fe9b40e 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1857,7 +1857,7 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video)
 
 	error = acpi_video_bus_start_devices(video);
 	if (error)
-		goto err_free_input;
+		goto free_device;
 
 	snprintf(video->phys, sizeof(video->phys),
 			"%s/video/input0", acpi_device_hid(video->device));
@@ -1879,7 +1879,7 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video)
 
 	error = input_register_device(input);
 	if (error)
-		goto err_stop_dev;
+		goto stop_devices;
 
 	mutex_lock(&video->device_list_lock);
 	list_for_each_entry(dev, &video->video_device_list, entry)
@@ -1887,10 +1887,9 @@ static int acpi_video_bus_add_notify_handler(struct acpi_video_bus *video)
 	mutex_unlock(&video->device_list_lock);
 
 	return 0;
-
-err_stop_dev:
+ stop_devices:
 	acpi_video_bus_stop_devices(video);
-err_free_input:
+ free_device:
 	input_free_device(input);
 	video->input = NULL;
 	return error;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/21] ACPI-video: Delete unnecessary if statement in acpi_video_switch_brightness()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-05 16:58   ` [PATCH 11/21] ACPI-video: Rename jump labels in acpi_video_bus_add_notify_handler() SF Markus Elfring
@ 2016-09-05 16:59   ` SF Markus Elfring
  2016-09-05 17:00   ` [PATCH 13/21] ACPI-video: Improve a jump target " SF Markus Elfring
                     ` (9 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 16:59 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 16:10:40 +0200

Move a function call into an else branch for successful function execution.
Omit a duplicate check for the local variable "result" then at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index fe9b40e..0362a43 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1372,14 +1372,12 @@ acpi_video_switch_brightness(struct work_struct *work)
 	level_next = acpi_video_get_next_level(device, level_current, event);
 
 	result = acpi_video_device_lcd_set_level(device, level_next);
-
-	if (!result)
-		backlight_force_update(device->backlight,
-				       BACKLIGHT_UPDATE_HOTKEY);
-
 out:
 	if (result)
 		printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
+	else
+		backlight_force_update(device->backlight,
+				       BACKLIGHT_UPDATE_HOTKEY);
 }
 
 int acpi_video_get_edid(struct acpi_device *device, int type, int device_id,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/21] ACPI-video: Improve a jump target in acpi_video_switch_brightness()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-05 16:59   ` [PATCH 12/21] ACPI-video: Delete unnecessary if statement in acpi_video_switch_brightness() SF Markus Elfring
@ 2016-09-05 17:00   ` SF Markus Elfring
  2016-09-05 17:01   ` [PATCH 14/21] ACPI-video: Improve a size determination in acpi_video_device_enumerate() SF Markus Elfring
                     ` (8 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:00 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 16:34:08 +0200

* Avoid another duplicate check for the local variable "result"
  then at the end.

* Jump directly to an error message in the case that the desired brightness
  can not be switched.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 0362a43..fe10d3f 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1361,19 +1361,19 @@ acpi_video_switch_brightness(struct work_struct *work)
 		return;
 
 	if (!device->brightness)
-		goto out;
+		goto report_failure;
 
 	result = acpi_video_device_lcd_get_level_current(device,
 							 &level_current,
 							 false);
 	if (result)
-		goto out;
+		goto report_failure;
 
 	level_next = acpi_video_get_next_level(device, level_current, event);
 
 	result = acpi_video_device_lcd_set_level(device, level_next);
-out:
 	if (result)
+ report_failure:
 		printk(KERN_ERR PREFIX "Failed to switch the brightness\n");
 	else
 		backlight_force_update(device->backlight,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/21] ACPI-video: Improve a size determination in acpi_video_device_enumerate()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-05 17:00   ` [PATCH 13/21] ACPI-video: Improve a jump target " SF Markus Elfring
@ 2016-09-05 17:01   ` SF Markus Elfring
  2016-09-05 17:02   ` [PATCH 15/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
                     ` (7 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:01 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 16:45:41 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index fe10d3f..df06390 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1268,7 +1268,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 			  dod->package.count));
 
 	active_list = kcalloc(1 + dod->package.count,
-			      sizeof(struct acpi_video_enumerated_device),
+			      sizeof(*active_list),
 			      GFP_KERNEL);
 	if (!active_list) {
 		status = -ENOMEM;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 15/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_device_enumerate()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-05 17:01   ` [PATCH 14/21] ACPI-video: Improve a size determination in acpi_video_device_enumerate() SF Markus Elfring
@ 2016-09-05 17:02   ` SF Markus Elfring
  2016-09-05 17:03   ` [PATCH 16/21] ACPI-video: Rename jump labels " SF Markus Elfring
                     ` (6 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:02 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 16:54:55 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index df06390..fcf74e7 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1245,7 +1245,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 	int i;
 	struct acpi_video_enumerated_device *active_list;
 	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
-	union acpi_object *dod = NULL;
+	union acpi_object *dod;
 	union acpi_object *obj;
 
 	if (!video->cap._DOD)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 16/21] ACPI-video: Rename jump labels in acpi_video_device_enumerate()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-05 17:02   ` [PATCH 15/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-05 17:03   ` SF Markus Elfring
  2016-09-05 17:04   ` [PATCH 17/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_init_brightness() SF Markus Elfring
                     ` (5 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:03 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:01:30 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index fcf74e7..2fc775a 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1261,7 +1261,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 	if (!dod || (dod->type != ACPI_TYPE_PACKAGE)) {
 		ACPI_EXCEPTION((AE_INFO, status, "Invalid _DOD data"));
 		status = -EFAULT;
-		goto out;
+		goto free_buffer;
 	}
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d video heads in _DOD\n",
@@ -1272,7 +1272,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 			      GFP_KERNEL);
 	if (!active_list) {
 		status = -ENOMEM;
-		goto out;
+		goto free_buffer;
 	}
 
 	count = 0;
@@ -1296,8 +1296,7 @@ static int acpi_video_device_enumerate(struct acpi_video_bus *video)
 
 	video->attached_array = active_list;
 	video->attached_count = count;
-
-out:
+ free_buffer:
 	kfree(buffer.pointer);
 	return status;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 17/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_init_brightness()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (15 preceding siblings ...)
  2016-09-05 17:03   ` [PATCH 16/21] ACPI-video: Rename jump labels " SF Markus Elfring
@ 2016-09-05 17:04   ` SF Markus Elfring
  2016-09-05 17:05   ` [PATCH 18/21] ACPI-video: Rename jump labels " SF Markus Elfring
                     ` (4 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:04 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:20:22 +0200

The local variable "result" will be assigned with a statement that follows
it directly. Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 2fc775a..5f1ef6e 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -872,7 +872,7 @@ acpi_video_init_brightness(struct acpi_video_device *device)
 	int i, max_level = 0;
 	unsigned long long level, level_old;
 	struct acpi_video_device_brightness *br = NULL;
-	int result = -EINVAL;
+	int result;
 
 	result = acpi_video_get_levels(device->dev, &br, &max_level);
 	if (result)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 18/21] ACPI-video: Rename jump labels in acpi_video_init_brightness()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (16 preceding siblings ...)
  2016-09-05 17:04   ` [PATCH 17/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_init_brightness() SF Markus Elfring
@ 2016-09-05 17:05   ` SF Markus Elfring
  2016-09-05 17:06   ` [PATCH 19/21] ACPI-video: Rename a jump label in acpi_video_device_lcd_query_levels() SF Markus Elfring
                     ` (3 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:05 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:28:45 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 5f1ef6e..5566f68 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -888,11 +888,11 @@ acpi_video_init_brightness(struct acpi_video_device *device)
 	result = acpi_video_device_lcd_get_level_current(device,
 							 &level_old, true);
 	if (result)
-		goto out_free_levels;
+		goto free_levels;
 
 	result = acpi_video_bqc_quirk(device, max_level, level_old);
 	if (result)
-		goto out_free_levels;
+		goto free_levels;
 	/*
 	 * cap._BQC may get cleared due to _BQC is found to be broken
 	 * in acpi_video_bqc_quirk, so check again here.
@@ -912,17 +912,15 @@ acpi_video_init_brightness(struct acpi_video_device *device)
 			break;
 	if (i == br->count || !level)
 		level = max_level;
-
-set_level:
+ set_level:
 	result = acpi_video_device_lcd_set_level(device, level);
 	if (result)
-		goto out_free_levels;
+		goto free_levels;
 
 	ACPI_DEBUG_PRINT((ACPI_DB_INFO,
 			  "found %d brightness levels\n", br->count - 2));
 	return 0;
-
-out_free_levels:
+ free_levels:
 	kfree(br->levels);
 	kfree(br);
 	device->brightness = NULL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 19/21] ACPI-video: Rename a jump label in acpi_video_device_lcd_query_levels()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (17 preceding siblings ...)
  2016-09-05 17:05   ` [PATCH 18/21] ACPI-video: Rename jump labels " SF Markus Elfring
@ 2016-09-05 17:06   ` SF Markus Elfring
  2016-09-05 17:07   ` [PATCH 20/21] ACPI-video: Improve a size determination in acpi_video_dev_register_backlight() SF Markus Elfring
                     ` (2 subsequent siblings)
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:06 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:34:40 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 5566f68..231fab3 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -329,14 +329,13 @@ acpi_video_device_lcd_query_levels(acpi_handle handle,
 	if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) {
 		printk(KERN_ERR PREFIX "Invalid _BCL data\n");
 		status = -EFAULT;
-		goto err;
+		goto free_buffer;
 	}
 
 	*levels = obj;
 
 	return 0;
-
-err:
+ free_buffer:
 	kfree(buffer.pointer);
 
 	return status;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 20/21] ACPI-video: Improve a size determination in acpi_video_dev_register_backlight()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (18 preceding siblings ...)
  2016-09-05 17:06   ` [PATCH 19/21] ACPI-video: Rename a jump label in acpi_video_device_lcd_query_levels() SF Markus Elfring
@ 2016-09-05 17:07   ` SF Markus Elfring
  2016-09-05 17:09   ` [PATCH 21/21] ACPI-video: Improve a size determination in acpi_video_bus_get_one_device() SF Markus Elfring
  2016-09-05 21:41   ` [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations Rafael J. Wysocki
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:07 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:45:40 +0200

Replace the specification of a data structure by a reference for
a local variable as the parameter for the operator "sizeof" to make
the corresponding size determination a bit safer according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 231fab3..9685725 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1685,7 +1685,7 @@ static void acpi_video_dev_register_backlight(struct acpi_video_device *device)
 		pci_dev_put(pdev);
 	}
 
-	memset(&props, 0, sizeof(struct backlight_properties));
+	memset(&props, 0, sizeof(props));
 	props.type = BACKLIGHT_FIRMWARE;
 	props.max_brightness = device->brightness->count - 3;
 	device->backlight = backlight_device_register(name,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 21/21] ACPI-video: Improve a size determination in acpi_video_bus_get_one_device()
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (19 preceding siblings ...)
  2016-09-05 17:07   ` [PATCH 20/21] ACPI-video: Improve a size determination in acpi_video_dev_register_backlight() SF Markus Elfring
@ 2016-09-05 17:09   ` SF Markus Elfring
  2016-09-05 21:41   ` [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations Rafael J. Wysocki
  21 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 17:09 UTC (permalink / raw)
  To: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki, Zhang Rui
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 17:50:04 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/acpi_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c
index 9685725..4cd693e 100644
--- a/drivers/acpi/acpi_video.c
+++ b/drivers/acpi/acpi_video.c
@@ -1084,7 +1084,7 @@ acpi_video_bus_get_one_device(struct acpi_device *device,
 	if (ACPI_FAILURE(status))
 		return 0;
 
-	data = kzalloc(sizeof(struct acpi_video_device), GFP_KERNEL);
+	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (75 preceding siblings ...)
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
@ 2016-09-05 20:12 ` SF Markus Elfring
  2016-09-05 20:15   ` [PATCH 1/7] ACPI-APEI-HEST: Fix a typo in a comment line SF Markus Elfring
                     ` (7 more replies)
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
                   ` (18 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:12 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 22:05:05 +0200

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

Markus Elfring (7):
  Fix a typo in a comment line
  Use kmalloc_array() in hest_ghes_dev_register()
  Move an assignment in hest_ghes_dev_register()
  Rename jump labels in hest_ghes_dev_register()
  Rename jump labels in acpi_hest_init()
  Reduce the scope for a variable in acpi_hest_init()
  Rename jump labels in hest_parse_ghes()

 drivers/acpi/apei/hest.c | 35 +++++++++++++++++++----------------
 1 file changed, 19 insertions(+), 16 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] ACPI-APEI-HEST: Fix a typo in a comment line
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
@ 2016-09-05 20:15   ` SF Markus Elfring
  2016-09-05 20:17   ` [PATCH 2/7] ACPI-APEI-HEST: Use kmalloc_array() in hest_ghes_dev_register() SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:15 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 20:37:38 +0200

Add a missing character to the fourth word at the beginning of this file.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 20b3fcf..e170885 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -1,5 +1,5 @@
 /*
- * APEI Hardware Error Souce Table support
+ * APEI Hardware Error Source Table support
  *
  * HEST describes error sources in detail; communicates operational
  * parameters (i.e. severity levels, masking bits, and threshold
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] ACPI-APEI-HEST: Use kmalloc_array() in hest_ghes_dev_register()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
  2016-09-05 20:15   ` [PATCH 1/7] ACPI-APEI-HEST: Fix a typo in a comment line SF Markus Elfring
@ 2016-09-05 20:17   ` SF Markus Elfring
  2016-09-05 20:18   ` [PATCH 3/7] ACPI-APEI-HEST: Move an assignment " SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:17 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 20:55:33 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus reuse the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index e170885..a852237 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -186,7 +186,9 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
 	struct ghes_arr ghes_arr;
 
 	ghes_arr.count = 0;
-	ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL);
+	ghes_arr.ghes_devs = kmalloc_array(ghes_count,
+					   sizeof(*ghes_arr.ghes_devs),
+					   GFP_KERNEL);
 	if (!ghes_arr.ghes_devs)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] ACPI-APEI-HEST: Move an assignment in hest_ghes_dev_register()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
  2016-09-05 20:15   ` [PATCH 1/7] ACPI-APEI-HEST: Fix a typo in a comment line SF Markus Elfring
  2016-09-05 20:17   ` [PATCH 2/7] ACPI-APEI-HEST: Use kmalloc_array() in hest_ghes_dev_register() SF Markus Elfring
@ 2016-09-05 20:18   ` SF Markus Elfring
  2016-09-05 20:20   ` [PATCH 4/7] ACPI-APEI-HEST: Rename jump labels " SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:18 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 21:15:22 +0200

Move one assignment for a data structure member in one local variable
so that its setting will only be performed after a corresponding memory
allocation succeeded by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index a852237..26f5e78 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -185,13 +185,13 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
 	int rc, i;
 	struct ghes_arr ghes_arr;
 
-	ghes_arr.count = 0;
 	ghes_arr.ghes_devs = kmalloc_array(ghes_count,
 					   sizeof(*ghes_arr.ghes_devs),
 					   GFP_KERNEL);
 	if (!ghes_arr.ghes_devs)
 		return -ENOMEM;
 
+	ghes_arr.count = 0;
 	rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
 	if (rc)
 		goto err;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] ACPI-APEI-HEST: Rename jump labels in hest_ghes_dev_register()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-05 20:18   ` [PATCH 3/7] ACPI-APEI-HEST: Move an assignment " SF Markus Elfring
@ 2016-09-05 20:20   ` SF Markus Elfring
  2016-09-05 20:21   ` [PATCH 5/7] ACPI-APEI-HEST: Rename jump labels in acpi_hest_init() SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:20 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 21:22:55 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 26f5e78..03dd7d3 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -194,14 +194,14 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
 	ghes_arr.count = 0;
 	rc = apei_hest_parse(hest_parse_ghes, &ghes_arr);
 	if (rc)
-		goto err;
-out:
+		goto unregister;
+ free_array:
 	kfree(ghes_arr.ghes_devs);
 	return rc;
-err:
+ unregister:
 	for (i = 0; i < ghes_arr.count; i++)
 		platform_device_unregister(ghes_arr.ghes_devs[i]);
-	goto out;
+	goto free_array;
 }
 
 static int __init setup_hest_disable(char *str)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] ACPI-APEI-HEST: Rename jump labels in acpi_hest_init()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-05 20:20   ` [PATCH 4/7] ACPI-APEI-HEST: Rename jump labels " SF Markus Elfring
@ 2016-09-05 20:21   ` SF Markus Elfring
  2016-09-05 20:22   ` [PATCH 6/7] ACPI-APEI-HEST: Reduce the scope for a variable " SF Markus Elfring
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:21 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 21:30:06 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 03dd7d3..ddff1b1 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -226,12 +226,12 @@ void __init acpi_hest_init(void)
 	status = acpi_get_table(ACPI_SIG_HEST, 0,
 				(struct acpi_table_header **)&hest_tab);
 	if (status == AE_NOT_FOUND)
-		goto err;
+		goto disable_hest;
 	else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
 		pr_err(HEST_PFX "Failed to get table, %s\n", msg);
 		rc = -EINVAL;
-		goto err;
+		goto disable_hest;
 	}
 
 	if (!acpi_disable_cmcff)
@@ -240,14 +240,14 @@ void __init acpi_hest_init(void)
 	if (!ghes_disable) {
 		rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
 		if (rc)
-			goto err;
+			goto disable_hest;
 		rc = hest_ghes_dev_register(ghes_count);
 		if (rc)
-			goto err;
+			goto disable_hest;
 	}
 
 	pr_info(HEST_PFX "Table parsing has been initialized.\n");
 	return;
-err:
+ disable_hest:
 	hest_disable = 1;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] ACPI-APEI-HEST: Reduce the scope for a variable in acpi_hest_init()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-05 20:21   ` [PATCH 5/7] ACPI-APEI-HEST: Rename jump labels in acpi_hest_init() SF Markus Elfring
@ 2016-09-05 20:22   ` SF Markus Elfring
  2016-09-05 20:23   ` [PATCH 7/7] ACPI-APEI-HEST: Rename jump labels in hest_parse_ghes() SF Markus Elfring
  2016-09-05 21:43   ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations Rafael J. Wysocki
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:22 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 21:50:34 +0200

Move the definition for the local variable "ghes_count" into an if branch
so that the corresponding setting will only be performed if GHES could be
enabled by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index ddff1b1..0e629c0 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -216,7 +216,6 @@ void __init acpi_hest_init(void)
 {
 	acpi_status status;
 	int rc = -ENODEV;
-	unsigned int ghes_count = 0;
 
 	if (hest_disable) {
 		pr_info(HEST_PFX "Table parsing disabled.\n");
@@ -238,6 +237,8 @@ void __init acpi_hest_init(void)
 		apei_hest_parse(hest_parse_cmc, NULL);
 
 	if (!ghes_disable) {
+		unsigned int ghes_count = 0;
+
 		rc = apei_hest_parse(hest_parse_ghes_count, &ghes_count);
 		if (rc)
 			goto disable_hest;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] ACPI-APEI-HEST: Rename jump labels in hest_parse_ghes()
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-05 20:22   ` [PATCH 6/7] ACPI-APEI-HEST: Reduce the scope for a variable " SF Markus Elfring
@ 2016-09-05 20:23   ` SF Markus Elfring
  2016-09-05 21:43   ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations Rafael J. Wysocki
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-05 20:23 UTC (permalink / raw)
  To: linux-acpi, Len Brown, Rafael J. Wysocki
  Cc: LKML, kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 5 Sep 2016 21:56:02 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/acpi/apei/hest.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
index 0e629c0..d5b75fe 100644
--- a/drivers/acpi/apei/hest.c
+++ b/drivers/acpi/apei/hest.c
@@ -167,15 +167,15 @@ static int __init hest_parse_ghes(struct acpi_hest_header *hest_hdr, void *data)
 
 	rc = platform_device_add_data(ghes_dev, &hest_hdr, sizeof(void *));
 	if (rc)
-		goto err;
+		goto put_device;
 
 	rc = platform_device_add(ghes_dev);
 	if (rc)
-		goto err;
+		goto put_device;
 	ghes_arr->ghes_devs[ghes_arr->count++] = ghes_dev;
 
 	return 0;
-err:
+ put_device:
 	platform_device_put(ghes_dev);
 	return rc;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations
  2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
                     ` (20 preceding siblings ...)
  2016-09-05 17:09   ` [PATCH 21/21] ACPI-video: Improve a size determination in acpi_video_bus_get_one_device() SF Markus Elfring
@ 2016-09-05 21:41   ` Rafael J. Wysocki
  2016-09-06  3:28     ` SF Markus Elfring
  21 siblings, 1 reply; 1373+ messages in thread
From: Rafael J. Wysocki @ 2016-09-05 21:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: ACPI Devel Maling List, Hans de Goede, Len Brown,
	Rafael J. Wysocki, Zhang Rui, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

On Mon, Sep 5, 2016 at 6:42 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 5 Sep 2016 18:22:11 +0200
>
> Several update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (21):
>   Use kmalloc_array() in acpi_video_get_levels()
>   Return directly after a failed device query
>   Delete an error message for a failed kzalloc() call
>   Rename jump labels in acpi_video_get_levels()
>   Delete an unnecessary initialisation in acpi_video_get_levels()
>   Move four assignments in acpi_video_get_levels()
>   Rename jump labels in acpi_video_bus_add()
>   Improve a size determination in acpi_video_bus_add()
>   Rename jump labels in acpi_video_register()
>   Return directly after a failed input_allocate_device()
>   Rename jump labels in acpi_video_bus_add_notify_handler()
>   Delete unnecessary if statement in acpi_video_switch_brightness()
>   Improve a jump target in acpi_video_switch_brightness()
>   Improve a size determination in acpi_video_device_enumerate()
>   Delete an unnecessary initialisation in acpi_video_device_enumerate()
>   Rename jump labels in acpi_video_device_enumerate()
>   Delete an unnecessary initialisation in acpi_video_init_brightness()
>   Rename jump labels in acpi_video_init_brightness()
>   Rename a jump label in acpi_video_device_lcd_query_levels()
>   Improve a size determination in acpi_video_dev_register_backlight()
>   Improve a size determination in acpi_video_bus_get_one_device()

I'd prefer this to be combined into fewer patches that each will
address several issues of one type, ie. put all label renames into one
patch, all size determination improvements into another one and so on.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-05 20:23   ` [PATCH 7/7] ACPI-APEI-HEST: Rename jump labels in hest_parse_ghes() SF Markus Elfring
@ 2016-09-05 21:43   ` Rafael J. Wysocki
  2016-09-06  3:38     ` SF Markus Elfring
  7 siblings, 1 reply; 1373+ messages in thread
From: Rafael J. Wysocki @ 2016-09-05 21:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: ACPI Devel Maling List, Len Brown, Rafael J. Wysocki, LKML,
	kernel-janitors, trivial, Julia Lawall, Paolo Bonzini

On Mon, Sep 5, 2016 at 10:12 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 5 Sep 2016 22:05:05 +0200
>
> Some update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (7):
>   Fix a typo in a comment line
>   Use kmalloc_array() in hest_ghes_dev_register()
>   Move an assignment in hest_ghes_dev_register()
>   Rename jump labels in hest_ghes_dev_register()
>   Rename jump labels in acpi_hest_init()
>   Reduce the scope for a variable in acpi_hest_init()
>   Rename jump labels in hest_parse_ghes()

Like in the other patch series I've just commented, please put all
label renames into one patch.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-video: Fine-tuning for several function implementations
  2016-09-05 21:41   ` [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations Rafael J. Wysocki
@ 2016-09-06  3:28     ` SF Markus Elfring
  2016-09-06 11:21       ` Rafael J. Wysocki
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-06  3:28 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki,
	Zhang Rui, LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

> I'd prefer this to be combined into fewer patches
> that each will address several issues of one type,

I understand your concern a bit in principle.


> ie. put all label renames into one patch,

Are any of my update suggestions controversial here?


> all size determination improvements into another one and so on.

I am unsure about the acceptance for the selected software change opportunities.
So I chose a very specific patch granularity intentionally.

I tend to provide some change ideas for each affected function
implementation individually. I imagine that this way should support
the recombination of update steps to some degree already, shouldn't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-APEI-HEST: Fine-tuning for three function implementations
  2016-09-05 21:43   ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations Rafael J. Wysocki
@ 2016-09-06  3:38     ` SF Markus Elfring
  2016-09-06 11:25       ` Rafael J. Wysocki
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-06  3:38 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Len Brown, Rafael J. Wysocki, LKML, kernel-janitors,
	trivial, Julia Lawall, Paolo Bonzini

> Like in the other patch series I've just commented,

Thanks for your quick response.


> please put all label renames into one patch.

Could you accept these update suggestions generally?


I would prefer to avoid squashing special changes together by default.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-video: Fine-tuning for several function implementations
  2016-09-06  3:28     ` SF Markus Elfring
@ 2016-09-06 11:21       ` Rafael J. Wysocki
  2016-09-06 14:10         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Rafael J. Wysocki @ 2016-09-06 11:21 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Rafael J. Wysocki, ACPI Devel Maling List, Hans de Goede,
	Len Brown, Rafael J. Wysocki, Zhang Rui, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

On Tue, Sep 6, 2016 at 5:28 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> I'd prefer this to be combined into fewer patches
>> that each will address several issues of one type,
>
> I understand your concern a bit in principle.
>
>
>> ie. put all label renames into one patch,
>
> Are any of my update suggestions controversial here?

Well, the label renames have a little value in general IMO, but that
depends on a particular case.

Anyway, if there's something I don't like in particular, I'll let you know.

>> all size determination improvements into another one and so on.
>
> I am unsure about the acceptance for the selected software change opportunities.
> So I chose a very specific patch granularity intentionally.
>
> I tend to provide some change ideas for each affected function
> implementation individually. I imagine that this way should support
> the recombination of update steps to some degree already, shouldn't it?

However, it's a pain to review 20 patches if you could review 4 instead.

Please take the reviewers' time into consideration too.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-APEI-HEST: Fine-tuning for three function implementations
  2016-09-06  3:38     ` SF Markus Elfring
@ 2016-09-06 11:25       ` Rafael J. Wysocki
  2016-09-06 14:21         ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Rafael J. Wysocki @ 2016-09-06 11:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Rafael J. Wysocki, ACPI Devel Maling List, Len Brown,
	Rafael J. Wysocki, LKML, kernel-janitors, trivial, Julia Lawall,
	Paolo Bonzini

On Tue, Sep 6, 2016 at 5:38 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> Like in the other patch series I've just commented,
>
> Thanks for your quick response.
>
>
>> please put all label renames into one patch.
>
> Could you accept these update suggestions generally?
>
>
> I would prefer to avoid squashing special changes together by default.

Well, as I said elsewhere, if you make the same type of change in
multiple places in one piece of code (or code maintained by the same
maintainer), you make it easier to review those changes if they go in
one patch.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-video: Fine-tuning for several function implementations
  2016-09-06 11:21       ` Rafael J. Wysocki
@ 2016-09-06 14:10         ` SF Markus Elfring
  2016-09-06 21:05           ` Rafael J. Wysocki
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-06 14:10 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki,
	Zhang Rui, LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

> Anyway, if there's something I don't like in particular, I'll let you know.

Thanks for your general interest.

I hope that occasional disagreements can be resolved in constructive ways.


> However, it's a pain to review 20 patches if you could review 4 instead.

Are there any more possibilities to improve the convenience for this
change review process with advanced tools?


> Please take the reviewers' time into consideration too.

I am trying this to some degree.

But I guess that it is hard to do something about corresponding efforts
when various contributors can easily spot many software update opportunities
in the discussed source files, isn't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-APEI-HEST: Fine-tuning for three function implementations
  2016-09-06 11:25       ` Rafael J. Wysocki
@ 2016-09-06 14:21         ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-06 14:21 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Len Brown, Rafael J. Wysocki, LKML, kernel-janitors,
	trivial, Julia Lawall, Paolo Bonzini

> Well, as I said elsewhere, if you make the same type of change in
> multiple places in one piece of code (or code maintained by the same maintainer),

I can imagine that my update suggestions will also trigger some additional
development efforts. I assume that some contributors appreciate
fine-grained patch series, don't they?


> you make it easier to review those changes if they go in one patch.

It might look convenient. But I find that there are more aspects to consider
for a better patch granularity.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-05 11:58                       ` Peter Zijlstra
@ 2016-09-06 14:34                         ` Jean Delvare
  2016-09-06 14:47                           ` Peter Zijlstra
  0 siblings, 1 reply; 1373+ messages in thread
From: Jean Delvare @ 2016-09-06 14:34 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

Hi Peter,

On Mon, 5 Sep 2016 13:58:38 +0200, Peter Zijlstra wrote:
> On Mon, Sep 05, 2016 at 01:54:45PM +0200, Jean Delvare wrote:
> > On Mon, 5 Sep 2016 13:37:04 +0200, Peter Zijlstra wrote:
> > > I have it in my local .gitconfig, and recommend it to people who send me
> > > patches.
> > 
> > What does it look like, please?
> 
> [diff "default"]
>         xfuncname = "^[[:alpha:]$_].*[^:]$"

OK, I see. As mentioned somewhere else, it fails for labels which have
comments. I was also surprised by the $ but apparently it's valid in
identifiers for at least some incarnations of C o.O

My worry is that you recommending it to contributors on a individual
and opportunity basis, doesn't scale. Basing coding style
recommendations on a personal quirk doesn't strike me as the best idea
ever in the long run.

The reason why I proposed an update to CodingStyle regarding this topic
was precisely to avoid having to repeat the same to contributors, like
you do (although our recommendations are different.)

While looking at the syntax of your example, I have found something
which looks more promising. git already has predefined xfuncname
definitions for various languages, including C. These can be enabled
based on file name patterns via gitattributes. The
following .gitattribute file placed at the root of the kernel source
tree achieves what you want:

*.c   diff=cpp
*.h   diff=cpp

The major difference between git config and gitattributes is that the
latter can be part of the project itself, just like gitignore. So we
could just push that .gitattribute file upstream, and then labels
without leading spaces would no longer be a problem, at least within
git. It would still be a problem for me as an inveterate quilt user, at
least until GNU diff gets "fixed." Which I did not even try, as I'm not
sure if upstream really considers this a bug in the first place.

And just for completeness, git's "cpp" predefined pattern doesn't
actually support $ as part of identifiers.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-06 14:34                         ` Jean Delvare
@ 2016-09-06 14:47                           ` Peter Zijlstra
  2016-09-06 15:29                             ` Joe Perches
  2016-09-07 12:30                             ` Jean Delvare
  0 siblings, 2 replies; 1373+ messages in thread
From: Peter Zijlstra @ 2016-09-06 14:47 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

On Tue, Sep 06, 2016 at 04:34:13PM +0200, Jean Delvare wrote:
> > [diff "default"]
> >         xfuncname = "^[[:alpha:]$_].*[^:]$"
> 
> OK, I see. As mentioned somewhere else, it fails for labels which have
> comments. 

Heh, There's labels that have comments?

> My worry is that you recommending it to contributors on a individual
> and opportunity basis, doesn't scale. Basing coding style
> recommendations on a personal quirk doesn't strike me as the best idea
> ever in the long run.

Don't care too much, I simply will not take any patch that adds stupid
spaces :-)

> While looking at the syntax of your example, I have found something
> which looks more promising. git already has predefined xfuncname
> definitions for various languages, including C. These can be enabled
> based on file name patterns via gitattributes. The
> following .gitattribute file placed at the root of the kernel source
> tree achieves what you want:
> 
> *.c   diff=cpp
> *.h   diff=cpp
> 
> The major difference between git config and gitattributes is that the
> latter can be part of the project itself, just like gitignore. So we
> could just push that .gitattribute file upstream, and then labels
> without leading spaces would no longer be a problem, at least within
> git.

Works for me, and last time this came up Linus agreed with the
"whitespace before labels is stupid" thing. Although I cannot find a
link to that just now.

> It would still be a problem for me as an inveterate quilt user,

Add the below to your .quiltrc or environment:

QUILT_DIFF_OPTS="-F ^[[:alpha:]\$_].*[^:]\$"

Same caveat about labels with comments, but then I'd not take a patch
doing that in the first place.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/2] tile-module: Fine-tuning for module_alloc()
  2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
  2016-09-03 19:01   ` [PATCH 1/2] tile-module: Use kmalloc_array() in module_alloc() SF Markus Elfring
  2016-09-03 19:02   ` [PATCH 2/2] tile-module: Rename jump labels " SF Markus Elfring
@ 2016-09-06 15:25   ` Chris Metcalf
  2 siblings, 0 replies; 1373+ messages in thread
From: Chris Metcalf @ 2016-09-06 15:25 UTC (permalink / raw)
  To: SF Markus Elfring, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

On 9/3/2016 3:00 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 20:52:10 +0200
>
> A few update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (2):
>    Use kmalloc_array()
>    Rename jump labels
>
>   arch/tile/kernel/module.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)

Thanks!  Taken into the tile tree.

-- 
Chris Metcalf, Mellanox Technologies
http://www.mellanox.com

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-06 14:47                           ` Peter Zijlstra
@ 2016-09-06 15:29                             ` Joe Perches
  2016-09-07 12:30                             ` Jean Delvare
  1 sibling, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-09-06 15:29 UTC (permalink / raw)
  To: Peter Zijlstra, Jean Delvare
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

On Tue, 2016-09-06 at 16:47 +0200, Peter Zijlstra wrote:
> On Tue, Sep 06, 2016 at 04:34:13PM +0200, Jean Delvare wrote:
> > > [diff "default"]
> > >         xfuncname = "^[[:alpha:]$_].*[^:]$"
> > OK, I see. As mentioned somewhere else, it fails for labels which have
> > comments. 
> Heh, There's labels that have comments?

Only a few dozen.

The pattern with the perl-like $_ took me a depressingly
long time to parse followed by a self forehead slap.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-video: Fine-tuning for several function implementations
  2016-09-06 14:10         ` SF Markus Elfring
@ 2016-09-06 21:05           ` Rafael J. Wysocki
  2016-09-07  6:40             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Rafael J. Wysocki @ 2016-09-06 21:05 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Rafael J. Wysocki, ACPI Devel Maling List, Hans de Goede,
	Len Brown, Rafael J. Wysocki, Zhang Rui, LKML, kernel-janitors,
	Julia Lawall, Paolo Bonzini

On Tue, Sep 6, 2016 at 4:10 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> Anyway, if there's something I don't like in particular, I'll let you know.
>
> Thanks for your general interest.
>
> I hope that occasional disagreements can be resolved in constructive ways.
>
>
>> However, it's a pain to review 20 patches if you could review 4 instead.
>
> Are there any more possibilities to improve the convenience for this
> change review process with advanced tools?
>
>
>> Please take the reviewers' time into consideration too.
>
> I am trying this to some degree.
>
> But I guess that it is hard to do something about corresponding efforts
> when various contributors can easily spot many software update opportunities
> in the discussed source files, isn't it?

OK, look.

Your patches happen to modify code maintained by me.  From my
perspective the value of the changes made by them is marginal.
Nevertheless, I might take them if you made my life somewhat easier,
so I've tried to tell you politely how to do that.

If you're not willing to do it, though, this is where it ends.  And
attempts to convince me that I may not want my life to be easier after
all are not likely to succeed.

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: ACPI-video: Fine-tuning for several function implementations
  2016-09-06 21:05           ` Rafael J. Wysocki
@ 2016-09-07  6:40             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-07  6:40 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: linux-acpi, Hans de Goede, Len Brown, Rafael J. Wysocki,
	Zhang Rui, LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

> Your patches happen to modify code maintained by me.  From my
> perspective the value of the changes made by them is marginal.

Thanks for another bit of interesting information.


> Nevertheless, I might take them if you made my life somewhat easier,

I am also looking for further approaches to help you there.


> so I've tried to tell you politely how to do that.

This feedback is generally fine.


> If you're not willing to do it,

My willingness is depending on also some factors.


> though, this is where it ends.

I hope that a bit more clarification can improve the situation.


> And attempts to convince me that I may not want my life to be easier
> after all are not likely to succeed.

We usually want that life will become more comfortable.

I chose to contribute something to Linux source files for this purpose.
My knowledge evolved in the way that I am using some tools for
static source code analysis. Such advanced tools can point various
change opportunities out. I picked a few special search patterns up.
It happened then that hundreds of source files were found which contain
update candidates. I am trying to inform the corresponding developers
about improvement possibilities in affected systems.


Further challenges are relevant then as usual.

* Handling of the search process and their results

* Communication between contributors


Search patterns can occasionally be categorised as "too special".
The software technology contains also the risk for showing "false positives".

The reactions of code reviewers are varying between rejection and acceptance.
Now I would like to determine again which details of the proposed changes
have got a higher chance for acceptance.

The discussed concrete patch series is just another example for usual
difficulties or more interesting software development challenges.
I hope that they can be resolved in a systematic way.
I sent analysis results as a series of small software updates. I find
it important to understand them also in the way that they belong to
software design patterns. I can imagine that it is harder to recognise
the involved patterns from the presented combination of update steps.

Would you like to check and clarify these patterns once more
before the desired improvements will happen (in a software area you maintain)?


So there are further constraints to consider. My software development experience
leaded me to a very specific kind of patch granularity here.
My software development interest evolved also in the way that I dared
to fiddle with the source files "drivers/acpi/processor_perflib.c"
and "drivers/acpi/processor_throttling.c" yesterday.
The consequence is that I would to publish a corresponding series
of 30 update steps for integration into another source code repository.
It seems that I need to wait a bit more for the next contribution attempt
before the change acceptance will fit to such an approach.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: sparc: bpf_jit: Rename jump labels in bpf_jit_compile()
  2016-09-06 14:47                           ` Peter Zijlstra
  2016-09-06 15:29                             ` Joe Perches
@ 2016-09-07 12:30                             ` Jean Delvare
  1 sibling, 0 replies; 1373+ messages in thread
From: Jean Delvare @ 2016-09-07 12:30 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Daniel Borkmann, Jonathan Corbet, David Miller, sparclinux,
	Adam Buchbinder, Alexei Starovoitov, Rabin Vincent, linux-kernel,
	kernel-janitors, Julia Lawall, Paolo Bonzini, linux-doc

Hi Peter,

On Tue, 6 Sep 2016 16:47:56 +0200, Peter Zijlstra wrote:
> On Tue, Sep 06, 2016 at 04:34:13PM +0200, Jean Delvare wrote:
> > > [diff "default"]
> > >         xfuncname = "^[[:alpha:]$_].*[^:]$"
> > 
> > OK, I see. As mentioned somewhere else, it fails for labels which have
> > comments. 
> 
> Heh, There's labels that have comments?

Yes, 43.

> > My worry is that you recommending it to contributors on a individual
> > and opportunity basis, doesn't scale. Basing coding style
> > recommendations on a personal quirk doesn't strike me as the best idea
> > ever in the long run.
> 
> Don't care too much, I simply will not take any patch that adds stupid
> spaces :-)
> 
> > While looking at the syntax of your example, I have found something
> > which looks more promising. git already has predefined xfuncname
> > definitions for various languages, including C. These can be enabled
> > based on file name patterns via gitattributes. The
> > following .gitattribute file placed at the root of the kernel source
> > tree achieves what you want:
> > 
> > *.c   diff=cpp
> > *.h   diff=cpp
> > 
> > The major difference between git config and gitattributes is that the
> > latter can be part of the project itself, just like gitignore. So we
> > could just push that .gitattribute file upstream, and then labels
> > without leading spaces would no longer be a problem, at least within
> > git.
> 
> Works for me,

OK, I'll send a patch now.

> and last time this came up Linus agreed with the
> "whitespace before labels is stupid" thing. Although I cannot find a
> link to that just now.

Murphy's law applies, you can never find links again the day you
desperately need them. If you ever get your hands on that one again,
please let me know, I really would like to read that post.

> > It would still be a problem for me as an inveterate quilt user,
> 
> Add the below to your .quiltrc or environment:
> 
> QUILT_DIFF_OPTS="-F ^[[:alpha:]\$_].*[^:]\$"

I didn't know this option existed, thanks for the pointer.

Now I'm sure I won't try to get the behavior of GNU diff option -p
changed, as I think I know what the answer would be.

> Same caveat about labels with comments, but then I'd not take a patch
> doing that in the first place.

I'll improve the regular expression if I ever have to (I don't think a
function declaration can have a colon anywhere?), but I'm happy if it
works in 99.9 % of the cases, thank sagain.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: s390/debug: Fine-tuning for several function implementations
  2016-09-05 10:31   ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations Martin Schwidefsky
  2016-09-05 10:40     ` SF Markus Elfring
@ 2016-09-09 16:50     ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-09 16:50 UTC (permalink / raw)
  To: Martin Schwidefsky
  Cc: linux-s390, David Hildenbrand, Heiko Carstens, Joe Perches, LKML,
	kernel-janitors, Julia Lawall, Paolo Bonzini

> While I agree that the old code in arch/s390/kernel/debug.c does not abide to
> the current coding style standards,

Thanks for this kind of acknowledgement.

Is such an information worth for further development considerations?


> I doubt there is much value in these patches.

I assume that your doubts could be adjusted, couldn't they?

Are there any other concerns involved in the background?


> To be honest I got annoyed after the third patch

Which of the proposed changes did trigger such a reaction?


I find this response also a bit surprising because of the aspect
that I offered you some results from my work as a free software developer.


> and stopped reading after the forth.

I imagine that you could have aborted the review of my update suggestions
a bit too early for your debug software module.

I agree that the value is varying for the presented 17 update steps.
But I hope that their value is potentially bigger overall
than you categorise them at first glance.

Now I would like to try to get a bit of your software development attention
once more for two of them at least. I hope that it can be easier to clarify
their value.

* Do the implementations of the functions "debug_areas_alloc"
  and "debug_get_user_string" need another look together with a more detailed
  source code review?

* How do you think about to use functions like "kmalloc_array"
  and "memdup_user" there instead?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init()
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (76 preceding siblings ...)
  2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
@ 2016-09-10 14:20 ` SF Markus Elfring
  2016-09-10 14:23   ` [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init() SF Markus Elfring
                     ` (6 more replies)
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                   ` (17 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:20 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 16:17:01 +0200

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

Markus Elfring (7):
  Use kmalloc_array()
  Delete an error message for a failed kmalloc_array() call
  Return directly if the driver "ks0108" was not initialized
  Return directly after a failed get_zeroed_page()
  Rename jump labels
  Return an error code only as a constant
  Adjust two checks for null pointers

 drivers/auxdisplay/cfag12864b.c | 37 +++++++++++++------------------------
 1 file changed, 13 insertions(+), 24 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init()
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
@ 2016-09-10 14:23   ` SF Markus Elfring
  2016-09-10 14:26   ` [PATCH 2/7] cfag12864b: Delete an error message for a failed kmalloc_array() call SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:23 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 14:40:48 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index 41ce4bd..88260f4 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -347,8 +347,9 @@ static int __init cfag12864b_init(void)
 		goto none;
 	}
 
-	cfag12864b_cache = kmalloc(sizeof(unsigned char) *
-		CFAG12864B_SIZE, GFP_KERNEL);
+	cfag12864b_cache = kmalloc_array(CFAG12864B_SIZE,
+					 sizeof(*cfag12864b_cache),
+					 GFP_KERNEL);
 	if (cfag12864b_cache == NULL) {
 		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 			"can't alloc cache buffer (%i bytes)\n",
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] cfag12864b: Delete an error message for a failed kmalloc_array() call
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
  2016-09-10 14:23   ` [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init() SF Markus Elfring
@ 2016-09-10 14:26   ` SF Markus Elfring
  2016-09-10 14:27   ` [PATCH 3/7] cfag12864b: Return directly if the driver "ks0108" was not initialized SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:26 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 14:54:05 +0200

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index 88260f4..fd07fad 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -351,9 +351,6 @@ static int __init cfag12864b_init(void)
 					 sizeof(*cfag12864b_cache),
 					 GFP_KERNEL);
 	if (cfag12864b_cache == NULL) {
-		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
-			"can't alloc cache buffer (%i bytes)\n",
-			CFAG12864B_SIZE);
 		ret = -ENOMEM;
 		goto bufferalloced;
 	}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] cfag12864b: Return directly if the driver "ks0108" was not initialized
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
  2016-09-10 14:23   ` [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init() SF Markus Elfring
  2016-09-10 14:26   ` [PATCH 2/7] cfag12864b: Delete an error message for a failed kmalloc_array() call SF Markus Elfring
@ 2016-09-10 14:27   ` SF Markus Elfring
  2016-09-10 14:28   ` [PATCH 4/7] cfag12864b: Return directly after a failed get_zeroed_page() SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:27 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 15:15:10 +0200

* Return directly if the LCD controller driver was not initialized
  at the beginning.

* Omit an explicit variable initialisation which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index fd07fad..921e177 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -329,13 +329,13 @@ EXPORT_SYMBOL_GPL(cfag12864b_isinited);
 
 static int __init cfag12864b_init(void)
 {
-	int ret = -EINVAL;
+	int ret;
 
 	/* ks0108_init() must be called first */
 	if (!ks0108_isinited()) {
 		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 			"ks0108 is not initialized\n");
-		goto none;
+		return -EINVAL;
 	}
 	BUILD_BUG_ON(PAGE_SIZE < CFAG12864B_SIZE);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] cfag12864b: Return directly after a failed get_zeroed_page()
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-10 14:27   ` [PATCH 3/7] cfag12864b: Return directly if the driver "ks0108" was not initialized SF Markus Elfring
@ 2016-09-10 14:28   ` SF Markus Elfring
  2016-09-10 14:29   ` [PATCH 5/7] cfag12864b: Rename jump labels in cfag12864b_init() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:28 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 15:30:56 +0200

* Return directly after a call of the function "get_zeroed_page" failed
  at the beginning.

* Delete the jump label "none" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index 921e177..2fa149b 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -343,8 +343,7 @@ static int __init cfag12864b_init(void)
 	if (cfag12864b_buffer == NULL) {
 		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 			"can't get a free page\n");
-		ret = -ENOMEM;
-		goto none;
+		return -ENOMEM;
 	}
 
 	cfag12864b_cache = kmalloc_array(CFAG12864B_SIZE,
@@ -370,8 +369,6 @@ cachealloced:
 
 bufferalloced:
 	free_page((unsigned long) cfag12864b_buffer);
-
-none:
 	return ret;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] cfag12864b: Rename jump labels in cfag12864b_init()
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-10 14:28   ` [PATCH 4/7] cfag12864b: Return directly after a failed get_zeroed_page() SF Markus Elfring
@ 2016-09-10 14:29   ` SF Markus Elfring
  2016-09-10 14:30   ` [PATCH 6/7] cfag12864b: Return an error code only as a constant " SF Markus Elfring
  2016-09-10 14:32   ` [PATCH 7/7] cfag12864b: Adjust two checks for null pointers " SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:29 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 15:35:02 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index 2fa149b..b471b28 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -351,23 +351,21 @@ static int __init cfag12864b_init(void)
 					 GFP_KERNEL);
 	if (cfag12864b_cache == NULL) {
 		ret = -ENOMEM;
-		goto bufferalloced;
+		goto free_buffer;
 	}
 
 	cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
 	if (cfag12864b_workqueue == NULL)
-		goto cachealloced;
+		goto free_cache;
 
 	cfag12864b_clear();
 	cfag12864b_on();
 
 	cfag12864b_inited = 1;
 	return 0;
-
-cachealloced:
+ free_cache:
 	kfree(cfag12864b_cache);
-
-bufferalloced:
+ free_buffer:
 	free_page((unsigned long) cfag12864b_buffer);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] cfag12864b: Return an error code only as a constant in cfag12864b_init()
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-10 14:29   ` [PATCH 5/7] cfag12864b: Rename jump labels in cfag12864b_init() SF Markus Elfring
@ 2016-09-10 14:30   ` SF Markus Elfring
  2016-09-10 14:32   ` [PATCH 7/7] cfag12864b: Adjust two checks for null pointers " SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:30 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 15:50:25 +0200

1. Return an error code without storing it in a local variable.

2. Do not use curly brackets at one source code place
   where a single statement should be sufficient.

3. Delete the local variable "ret" which became unnecessary with
   this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index b471b28..b2533e2 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -329,8 +329,6 @@ EXPORT_SYMBOL_GPL(cfag12864b_isinited);
 
 static int __init cfag12864b_init(void)
 {
-	int ret;
-
 	/* ks0108_init() must be called first */
 	if (!ks0108_isinited()) {
 		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
@@ -349,10 +347,8 @@ static int __init cfag12864b_init(void)
 	cfag12864b_cache = kmalloc_array(CFAG12864B_SIZE,
 					 sizeof(*cfag12864b_cache),
 					 GFP_KERNEL);
-	if (cfag12864b_cache == NULL) {
-		ret = -ENOMEM;
+	if (!cfag12864b_cache)
 		goto free_buffer;
-	}
 
 	cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
 	if (cfag12864b_workqueue == NULL)
@@ -367,7 +363,7 @@ static int __init cfag12864b_init(void)
 	kfree(cfag12864b_cache);
  free_buffer:
 	free_page((unsigned long) cfag12864b_buffer);
-	return ret;
+	return -ENOMEM;
 }
 
 static void __exit cfag12864b_exit(void)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] cfag12864b: Adjust two checks for null pointers in cfag12864b_init()
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-10 14:30   ` [PATCH 6/7] cfag12864b: Return an error code only as a constant " SF Markus Elfring
@ 2016-09-10 14:32   ` SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-10 14:32 UTC (permalink / raw)
  To: kernel-janitors, Miguel Ojeda Sandonis; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 10 Sep 2016 16:06:19 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/auxdisplay/cfag12864b.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c
index b2533e2..3956b9f 100644
--- a/drivers/auxdisplay/cfag12864b.c
+++ b/drivers/auxdisplay/cfag12864b.c
@@ -338,7 +338,7 @@ static int __init cfag12864b_init(void)
 	BUILD_BUG_ON(PAGE_SIZE < CFAG12864B_SIZE);
 
 	cfag12864b_buffer = (unsigned char *) get_zeroed_page(GFP_KERNEL);
-	if (cfag12864b_buffer == NULL) {
+	if (!cfag12864b_buffer) {
 		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 			"can't get a free page\n");
 		return -ENOMEM;
@@ -351,7 +351,7 @@ static int __init cfag12864b_init(void)
 		goto free_buffer;
 
 	cfag12864b_workqueue = create_singlethread_workqueue(CFAG12864B_NAME);
-	if (cfag12864b_workqueue == NULL)
+	if (!cfag12864b_workqueue)
 		goto free_cache;
 
 	cfag12864b_clear();
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/6] KVM: PPC: e500: Rename jump labels in kvmppc_e500_tlb_init()
  2016-08-28 17:19   ` [PATCH 6/6] KVM: PPC: e500: Rename jump labels " SF Markus Elfring
  2016-08-28 17:48     ` Julia Lawall
@ 2016-09-11 23:25     ` Paul Mackerras
  2016-09-12 21:00       ` [PATCH] " SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Paul Mackerras @ 2016-09-11 23:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Radim Krčmář,
	LKML, kernel-janitors, Julia Lawall

On Sun, Aug 28, 2016 at 07:19:22PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Aug 2016 18:45:26 +0200
> 
> Adjust jump labels according to the current Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

With this I get a compile error:

  CC      arch/powerpc/kvm/e500_mmu.o
/home/paulus/kernel/kvm/arch/powerpc/kvm/e500_mmu.c: In function ‘kvmppc_e500_tlb_init’:
/home/paulus/kernel/kvm/arch/powerpc/kvm/e500_mmu.c:910:3: error: label ‘err’ used but not defined
   goto err;
   ^
/home/paulus/kernel/kvm/scripts/Makefile.build:289: recipe for target 'arch/powerpc/kvm/e500_mmu.o' failed
make[2]: *** [arch/powerpc/kvm/e500_mmu.o] Error 1

Paul.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations
  2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-08-28 17:19   ` [PATCH 6/6] KVM: PPC: e500: Rename jump labels " SF Markus Elfring
@ 2016-09-12  0:54   ` Paul Mackerras
  6 siblings, 0 replies; 1373+ messages in thread
From: Paul Mackerras @ 2016-09-12  0:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kvm, kvm-ppc, linuxppc-dev, Alexander Graf,
	Benjamin Herrenschmidt, Michael Ellerman, Paolo Bonzini,
	Radim Krčmář,
	LKML, kernel-janitors, Julia Lawall

On Sun, Aug 28, 2016 at 07:09:57PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 28 Aug 2016 19:01:02 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (6):
>   Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb()
>   Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection
>   Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb()
>   Replace kzalloc() calls by kcalloc() in two functions
>   Use kmalloc_array() in kvmppc_e500_tlb_init()
>   Rename jump labels in kvmppc_e500_tlb_init()

Thanks, patches 1-5 applied to my kvm-ppc-next branch.

Paul.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (77 preceding siblings ...)
  2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
@ 2016-09-12 18:40 ` SF Markus Elfring
  2016-09-12 18:42   ` [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk() SF Markus Elfring
                     ` (47 more replies)
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
                   ` (16 subsequent siblings)
  95 siblings, 48 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:40 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:35:20 +0200

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

Markus Elfring (47):
  Use kmalloc_array() in rbd_header_from_disk()
  Less function calls in rbd_header_from_disk() after error detection
  Adjust the position of a jump label in rbd_header_from_disk()
  Refactor two calls for memory allocations in rbd_dev_image_id()
  One function call less in rbd_dev_image_id() after error detection
  Rename jump labels in rbd_add_parse_args()
  Rename a jump label in rbd_dev_v2_snap_name()
  Rename jump labels in rbd_dev_v2_snap_context()
  Rename a jump label in rbd_spec_fill_names()
  One function call less in rbd_dev_image_name() after error detection
  Delete three unnecessary initialisations in rbd_dev_image_name()
  One function call less in rbd_dev_v2_parent_info() after error detection
  Delete an unnecessary initialisation in rbd_dev_v2_parent_info()
  Rename a jump label in rbd_dev_v2_object_prefix()
  Rename jump labels in rbd_dev_create()
  Rename jump labels in rbd_dev_v1_header_info()
  Rename jump labels in rbd_init_disk()
  Fix jump targets in rbd_queue_workfn()
  Rename a jump label in rbd_reregister_watch()
  Rename a jump label in rbd_register_watch()
  Rename jump labels in rbd_try_lock()
  Rename a jump label in find_watcher()
  Rename jump labels in get_lock_owner_info()
  Rename jump labels in rbd_request_lock()
  Fix jump targets in rbd_img_parent_read()
  Rename a jump label in rbd_img_parent_read_callback()
  Rename a jump label in rbd_img_request_submit()
  Refactor a jump target in rbd_img_obj_exists_submit()
  Delete an unnecessary initialisation in rbd_img_obj_exists_submit()
  Refactor a jump target in rbd_img_obj_exists_callback()
  Fix three jump targets in rbd_img_obj_parent_read_full()
  Rename a jump label in rbd_img_obj_parent_read_full_callback()
  Adjust the position of a jump label in rbd_img_request_fill()
  Rename a jump label in rbd_img_obj_callback()
  Rename jump labels in rbd_osd_req_create_copyup()
  Rename jump labels in rbd_osd_req_create()
  Rename a jump label in bio_chain_clone_range()
  Rename jump labels in rbd_client_create()
  Rename a jump label in rbd_ioctl_set_ro()
  One function call less in rbd_dev_probe_parent() after error detection
  Rename jump labels in rbd_dev_device_setup()
  Rename jump labels in rbd_dev_image_probe()
  Rename jump labels in do_rbd_add()
  Delete an unnecessary initialisation in do_rbd_add()
  Rename a jump label in rbd_slab_init()
  Rename jump labels in rbd_init()
  Delete unwanted spaces behind usages of the sizeof operator

 drivers/block/rbd.c | 544 ++++++++++++++++++++++++++--------------------------
 1 file changed, 272 insertions(+), 272 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-12 18:42   ` SF Markus Elfring
  2016-09-14 15:25     ` Ilya Dryomov
  2016-09-12 18:43   ` [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection SF Markus Elfring
                     ` (46 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:42 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 12:21:25 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 35fc1da..e406c27 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -979,7 +979,6 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	char *snap_names = NULL;
 	u64 *snap_sizes = NULL;
 	u32 snap_count;
-	size_t size;
 	int ret = -ENOMEM;
 	u32 i;
 
@@ -1017,9 +1016,9 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 			goto out_err;
 
 		/* ...as well as the array of their sizes. */
-
-		size = snap_count * sizeof (*header->snap_sizes);
-		snap_sizes = kmalloc(size, GFP_KERNEL);
+		snap_sizes = kmalloc_array(snap_count,
+					   sizeof(*header->snap_sizes),
+					   GFP_KERNEL);
 		if (!snap_sizes)
 			goto out_err;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-12 18:42   ` [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk() SF Markus Elfring
@ 2016-09-12 18:43   ` SF Markus Elfring
  2016-09-13  7:58     ` Ilya Dryomov
  2016-09-12 18:44   ` [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk() SF Markus Elfring
                     ` (45 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:43 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 13:18:57 +0200

The functions "ceph_put_snap_context" and "kfree" were called in a few
cases by the function "rbd_header_from_disk" during error handling
even if the passed variables contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e406c27..f4212e1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1001,7 +1001,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	snap_count = le32_to_cpu(ondisk->snap_count);
 	snapc = ceph_create_snap_context(snap_count, GFP_KERNEL);
 	if (!snapc)
-		goto out_err;
+		goto free_prefix;
 	snapc->seq = le64_to_cpu(ondisk->snap_seq);
 	if (snap_count) {
 		struct rbd_image_snap_ondisk *snaps;
@@ -1013,14 +1013,14 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 			goto out_2big;
 		snap_names = kmalloc(snap_names_len, GFP_KERNEL);
 		if (!snap_names)
-			goto out_err;
+			goto put_snap_context;
 
 		/* ...as well as the array of their sizes. */
 		snap_sizes = kmalloc_array(snap_count,
 					   sizeof(*header->snap_sizes),
 					   GFP_KERNEL);
 		if (!snap_sizes)
-			goto out_err;
+			goto free_names;
 
 		/*
 		 * Copy the names, and fill in each snapshot's id
@@ -1066,10 +1066,12 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	return 0;
 out_2big:
 	ret = -EIO;
-out_err:
 	kfree(snap_sizes);
+ free_names:
 	kfree(snap_names);
+ put_snap_context:
 	ceph_put_snap_context(snapc);
+ free_prefix:
 	kfree(object_prefix);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-12 18:42   ` [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk() SF Markus Elfring
  2016-09-12 18:43   ` [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection SF Markus Elfring
@ 2016-09-12 18:44   ` SF Markus Elfring
  2016-09-13  8:01     ` Ilya Dryomov
  2016-09-12 18:45   ` [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id() SF Markus Elfring
                     ` (44 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:44 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 13:37:34 +0200

Add a space character before a single jump label in this function
according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f4212e1..d61a066 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 	header->snap_sizes = snap_sizes;
 
 	return 0;
-out_2big:
+ out_2big:
 	ret = -EIO;
 	kfree(snap_sizes);
  free_names:
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-12 18:44   ` [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk() SF Markus Elfring
@ 2016-09-12 18:45   ` SF Markus Elfring
  2016-09-13  8:03     ` Ilya Dryomov
  2016-09-12 18:46   ` [PATCH 05/47] block-rbd: One function call less in rbd_dev_image_id() after error detection SF Markus Elfring
                     ` (43 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:45 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 14:48:41 +0200

* Pass the sizes for memory allocations to the corresponding functions
  directly without storing the calculated values in an
  intermediate variable.

* Delete the local variable "size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index d61a066..c1da844 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5833,7 +5833,6 @@ again:
 static int rbd_dev_image_id(struct rbd_device *rbd_dev)
 {
 	int ret;
-	size_t size;
 	char *object_name;
 	void *response;
 	char *image_id;
@@ -5854,17 +5853,16 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
 	 * First, see if the format 2 image id file exists, and if
 	 * so, get the image's persistent id from it.
 	 */
-	size = sizeof (RBD_ID_PREFIX) + strlen(rbd_dev->spec->image_name);
-	object_name = kmalloc(size, GFP_NOIO);
+	object_name = kmalloc(sizeof(RBD_ID_PREFIX)
+			      + strlen(rbd_dev->spec->image_name),
+			      GFP_NOIO);
 	if (!object_name)
 		return -ENOMEM;
 	sprintf(object_name, "%s%s", RBD_ID_PREFIX, rbd_dev->spec->image_name);
 	dout("rbd id object name is %s\n", object_name);
 
 	/* Response will be an encoded string, which includes a length */
-
-	size = sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX;
-	response = kzalloc(size, GFP_NOIO);
+	response = kzalloc(sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX, GFP_NOIO);
 	if (!response) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/47] block-rbd: One function call less in rbd_dev_image_id() after error detection
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-12 18:45   ` [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id() SF Markus Elfring
@ 2016-09-12 18:46   ` SF Markus Elfring
  2016-09-12 18:46   ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations Joe Perches
                     ` (42 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:46 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 15:05:49 +0200

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

Adjust a jump target according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index c1da844..a6d9a06 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5865,7 +5865,7 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
 	response = kzalloc(sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX, GFP_NOIO);
 	if (!response) {
 		ret = -ENOMEM;
-		goto out;
+		goto free_name;
 	}
 
 	/* If it doesn't exist we'll assume it's a format 1 image */
@@ -5893,8 +5893,8 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
 		rbd_dev->spec->image_id = image_id;
 		dout("image_id is %s\n", image_id);
 	}
-out:
 	kfree(response);
+ free_name:
 	kfree(object_name);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-12 18:46   ` [PATCH 05/47] block-rbd: One function call less in rbd_dev_image_id() after error detection SF Markus Elfring
@ 2016-09-12 18:46   ` Joe Perches
  2016-09-12 18:47   ` [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args() SF Markus Elfring
                     ` (41 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-09-12 18:46 UTC (permalink / raw)
  To: SF Markus Elfring, ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

On Mon, 2016-09-12 at 20:40 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 12 Sep 2016 20:35:20 +0200

This email header and all children contains:

References: <566ABCD9.1060404@users.sourceforge.net>

Markus, just stop using references lines.

Stop.

It doesn't add any value for any patch you've submitted here.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-12 18:46   ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations Joe Perches
@ 2016-09-12 18:47   ` SF Markus Elfring
  2016-09-13  8:05     ` Ilya Dryomov
  2016-09-12 18:48   ` [PATCH 07/47] block-rbd: Rename a jump label in rbd_dev_v2_snap_name() SF Markus Elfring
                     ` (40 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:47 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 11 Sep 2016 15:20:48 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a6d9a06..dd4da1f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5709,27 +5709,27 @@ static int rbd_add_parse_args(const char *buf,
 		return -ENOMEM;
 	if (!*options) {
 		rbd_warn(NULL, "no options provided");
-		goto out_err;
+		goto free_options;
 	}
 
 	spec = rbd_spec_alloc();
 	if (!spec)
-		goto out_mem;
+		goto status_indication;
 
 	spec->pool_name = dup_token(&buf, NULL);
 	if (!spec->pool_name)
-		goto out_mem;
+		goto status_indication;
 	if (!*spec->pool_name) {
 		rbd_warn(NULL, "no pool name provided");
-		goto out_err;
+		goto free_options;
 	}
 
 	spec->image_name = dup_token(&buf, NULL);
 	if (!spec->image_name)
-		goto out_mem;
+		goto status_indication;
 	if (!*spec->image_name) {
 		rbd_warn(NULL, "no image name provided");
-		goto out_err;
+		goto free_options;
 	}
 
 	/*
@@ -5742,11 +5742,11 @@ static int rbd_add_parse_args(const char *buf,
 		len = sizeof (RBD_SNAP_HEAD_NAME) - 1;
 	} else if (len > RBD_MAX_SNAP_NAME_LEN) {
 		ret = -ENAMETOOLONG;
-		goto out_err;
+		goto free_options;
 	}
 	snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
 	if (!snap_name)
-		goto out_mem;
+		goto status_indication;
 	*(snap_name + len) = '\0';
 	spec->snap_name = snap_name;
 
@@ -5754,7 +5754,7 @@ static int rbd_add_parse_args(const char *buf,
 
 	rbd_opts = kzalloc(sizeof (*rbd_opts), GFP_KERNEL);
 	if (!rbd_opts)
-		goto out_mem;
+		goto status_indication;
 
 	rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;
 	rbd_opts->queue_depth = RBD_QUEUE_DEPTH_DEFAULT;
@@ -5764,7 +5764,7 @@ static int rbd_add_parse_args(const char *buf,
 					parse_rbd_opts_token, rbd_opts);
 	if (IS_ERR(copts)) {
 		ret = PTR_ERR(copts);
-		goto out_err;
+		goto free_options;
 	}
 	kfree(options);
 
@@ -5773,9 +5773,9 @@ static int rbd_add_parse_args(const char *buf,
 	*rbd_spec = spec;
 
 	return 0;
-out_mem:
+ status_indication:
 	ret = -ENOMEM;
-out_err:
+ free_options:
 	kfree(rbd_opts);
 	rbd_spec_put(spec);
 	kfree(options);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/47] block-rbd: Rename a jump label in rbd_dev_v2_snap_name()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-12 18:47   ` [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args() SF Markus Elfring
@ 2016-09-12 18:48   ` SF Markus Elfring
  2016-09-12 18:49   ` [PATCH 08/47] block-rbd: Rename jump labels in rbd_dev_v2_snap_context() SF Markus Elfring
                     ` (39 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:48 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 17:53:19 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index dd4da1f..4164551 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5532,18 +5532,18 @@ static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0) {
 		snap_name = ERR_PTR(ret);
-		goto out;
+		goto free_buffer;
 	}
 
 	p = reply_buf;
 	end = reply_buf + ret;
 	snap_name = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
 	if (IS_ERR(snap_name))
-		goto out;
+		goto free_buffer;
 
 	dout("  snap_id 0x%016llx snap_name = %s\n",
 		(unsigned long long)snap_id, snap_name);
-out:
+ free_buffer:
 	kfree(reply_buf);
 
 	return snap_name;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/47] block-rbd: Rename jump labels in rbd_dev_v2_snap_context()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-12 18:48   ` [PATCH 07/47] block-rbd: Rename a jump label in rbd_dev_v2_snap_name() SF Markus Elfring
@ 2016-09-12 18:49   ` SF Markus Elfring
  2016-09-12 18:50   ` [PATCH 09/47] block-rbd: Rename a jump label in rbd_spec_fill_names() SF Markus Elfring
                     ` (38 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:49 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 17:55:51 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 4164551..45109ff 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5465,13 +5465,13 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)
 				reply_buf, size);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
-		goto out;
+		goto free_buffer;
 
 	p = reply_buf;
 	end = reply_buf + ret;
 	ret = -ERANGE;
-	ceph_decode_64_safe(&p, end, seq, out);
-	ceph_decode_32_safe(&p, end, snap_count, out);
+	ceph_decode_64_safe(&p, end, seq, free_buffer);
+	ceph_decode_32_safe(&p, end, snap_count, free_buffer);
 
 	/*
 	 * Make sure the reported number of snapshot ids wouldn't go
@@ -5482,16 +5482,16 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)
 	if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
 				 / sizeof (u64)) {
 		ret = -EINVAL;
-		goto out;
+		goto free_buffer;
 	}
 	if (!ceph_has_room(&p, end, snap_count * sizeof (__le64)))
-		goto out;
+		goto free_buffer;
 	ret = 0;
 
 	snapc = ceph_create_snap_context(snap_count, GFP_KERNEL);
 	if (!snapc) {
 		ret = -ENOMEM;
-		goto out;
+		goto free_buffer;
 	}
 	snapc->seq = seq;
 	for (i = 0; i < snap_count; i++)
@@ -5502,7 +5502,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)
 
 	dout("  snap context seq = %llu, snap_count = %u\n",
 		(unsigned long long)seq, (unsigned int)snap_count);
-out:
+ free_buffer:
 	kfree(reply_buf);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/47] block-rbd: Rename a jump label in rbd_spec_fill_names()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-12 18:49   ` [PATCH 08/47] block-rbd: Rename jump labels in rbd_dev_v2_snap_context() SF Markus Elfring
@ 2016-09-12 18:50   ` SF Markus Elfring
  2016-09-12 18:51   ` [PATCH 10/47] block-rbd: One function call less in rbd_dev_image_name() after error detection SF Markus Elfring
                     ` (37 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:50 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 17:58:18 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 45109ff..aac51a1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5421,7 +5421,7 @@ static int rbd_spec_fill_names(struct rbd_device *rbd_dev)
 	snap_name = rbd_snap_name(rbd_dev, spec->snap_id);
 	if (IS_ERR(snap_name)) {
 		ret = PTR_ERR(snap_name);
-		goto out_err;
+		goto free_name;
 	}
 
 	spec->pool_name = pool_name;
@@ -5429,8 +5429,7 @@ static int rbd_spec_fill_names(struct rbd_device *rbd_dev)
 	spec->snap_name = snap_name;
 
 	return 0;
-
-out_err:
+ free_name:
 	kfree(image_name);
 	kfree(pool_name);
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/47] block-rbd: One function call less in rbd_dev_image_name() after error detection
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-12 18:50   ` [PATCH 09/47] block-rbd: Rename a jump label in rbd_spec_fill_names() SF Markus Elfring
@ 2016-09-12 18:51   ` SF Markus Elfring
  2016-09-12 18:54   ` [PATCH 11/47] block-rbd: Delete three unnecessary initialisations in rbd_dev_image_name() SF Markus Elfring
                     ` (36 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:51 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:00:18 +0200

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

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index aac51a1..145bbcc 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5276,14 +5276,14 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
 	size = sizeof (__le32) + RBD_IMAGE_NAME_LEN_MAX;
 	reply_buf = kmalloc(size, GFP_KERNEL);
 	if (!reply_buf)
-		goto out;
+		goto free_id;
 
 	ret = rbd_obj_method_sync(rbd_dev, RBD_DIRECTORY,
 				"rbd", "dir_get_name",
 				image_id, image_id_size,
 				reply_buf, size);
 	if (ret < 0)
-		goto out;
+		goto free_buffer;
 	p = reply_buf;
 	end = reply_buf + ret;
 
@@ -5292,8 +5292,9 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
 		image_name = NULL;
 	else
 		dout("%s: name is %s len is %zd\n", __func__, image_name, len);
-out:
+ free_buffer:
 	kfree(reply_buf);
+ free_id:
 	kfree(image_id);
 
 	return image_name;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/47] block-rbd: Delete three unnecessary initialisations in rbd_dev_image_name()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-12 18:51   ` [PATCH 10/47] block-rbd: One function call less in rbd_dev_image_name() after error detection SF Markus Elfring
@ 2016-09-12 18:54   ` SF Markus Elfring
  2016-09-12 18:57   ` [PATCH 12/47] block-rbd: One function call less in rbd_dev_v2_parent_info() after error detection SF Markus Elfring
                     ` (35 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:54 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:02:16 +0200

Three local variables will be set to appropriate values a bit later.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 145bbcc..90797aa 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5256,9 +5256,9 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
 	void *p;
 	void *end;
 	size_t size;
-	void *reply_buf = NULL;
-	size_t len = 0;
-	char *image_name = NULL;
+	void *reply_buf;
+	size_t len;
+	char *image_name;
 	int ret;
 
 	rbd_assert(!rbd_dev->spec->image_name);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/47] block-rbd: One function call less in rbd_dev_v2_parent_info() after error detection
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-12 18:54   ` [PATCH 11/47] block-rbd: Delete three unnecessary initialisations in rbd_dev_image_name() SF Markus Elfring
@ 2016-09-12 18:57   ` SF Markus Elfring
  2016-09-12 18:58   ` [PATCH 13/47] block-rbd: Delete an unnecessary initialisation in rbd_dev_v2_parent_info() SF Markus Elfring
                     ` (34 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:57 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:05:00 +0200

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

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 90797aa..946e3ca 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5105,7 +5105,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 	reply_buf = kmalloc(size, GFP_KERNEL);
 	if (!reply_buf) {
 		ret = -ENOMEM;
-		goto out_err;
+		goto put_spec;
 	}
 
 	snapid = cpu_to_le64(rbd_dev->spec->snap_id);
@@ -5115,12 +5115,12 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 				reply_buf, size);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
-		goto out_err;
+		goto free_buffer;
 
 	p = reply_buf;
 	end = reply_buf + ret;
 	ret = -ERANGE;
-	ceph_decode_64_safe(&p, end, pool_id, out_err);
+	ceph_decode_64_safe(&p, end, pool_id, free_buffer);
 	if (pool_id == CEPH_NOPOOL) {
 		/*
 		 * Either the parent never existed, or we have
@@ -5138,7 +5138,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 				rbd_dev->disk->disk_name);
 		}
 
-		goto out;	/* No parent?  No problem. */
+		goto success_indication;	/* No parent?  No problem. */
 	}
 
 	/* The ceph file layout needs to fit pool id in 32 bits */
@@ -5147,16 +5147,16 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 	if (pool_id > (u64)U32_MAX) {
 		rbd_warn(NULL, "parent pool id too large (%llu > %u)",
 			(unsigned long long)pool_id, U32_MAX);
-		goto out_err;
+		goto free_buffer;
 	}
 
 	image_id = ceph_extract_encoded_string(&p, end, NULL, GFP_KERNEL);
 	if (IS_ERR(image_id)) {
 		ret = PTR_ERR(image_id);
-		goto out_err;
+		goto free_buffer;
 	}
-	ceph_decode_64_safe(&p, end, snap_id, out_err);
-	ceph_decode_64_safe(&p, end, overlap, out_err);
+	ceph_decode_64_safe(&p, end, snap_id, free_buffer);
+	ceph_decode_64_safe(&p, end, overlap, free_buffer);
 
 	/*
 	 * The parent won't change (except when the clone is
@@ -5189,11 +5189,11 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 		}
 	}
 	rbd_dev->parent_overlap = overlap;
-
-out:
+ success_indication:
 	ret = 0;
-out_err:
+ free_buffer:
 	kfree(reply_buf);
+ put_spec:
 	rbd_spec_put(parent_spec);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/47] block-rbd: Delete an unnecessary initialisation in rbd_dev_v2_parent_info()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-12 18:57   ` [PATCH 12/47] block-rbd: One function call less in rbd_dev_v2_parent_info() after error detection SF Markus Elfring
@ 2016-09-12 18:58   ` SF Markus Elfring
  2016-09-12 18:59   ` [PATCH 14/47] block-rbd: Rename a jump label in rbd_dev_v2_object_prefix() SF Markus Elfring
                     ` (33 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:58 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:08:14 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 946e3ca..aff8c4e 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5084,7 +5084,7 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 {
 	struct rbd_spec *parent_spec;
 	size_t size;
-	void *reply_buf = NULL;
+	void *reply_buf;
 	__le64 snapid;
 	void *p;
 	void *end;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/47] block-rbd: Rename a jump label in rbd_dev_v2_object_prefix()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-12 18:58   ` [PATCH 13/47] block-rbd: Delete an unnecessary initialisation in rbd_dev_v2_parent_info() SF Markus Elfring
@ 2016-09-12 18:59   ` SF Markus Elfring
  2016-09-12 19:00   ` [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create() SF Markus Elfring
                     ` (32 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 18:59 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:10:02 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index aff8c4e..6acddc53 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5017,7 +5017,7 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
 				reply_buf, RBD_OBJ_PREFIX_LEN_MAX);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
-		goto out;
+		goto free_buffer;
 
 	p = reply_buf;
 	rbd_dev->header.object_prefix = ceph_extract_encoded_string(&p,
@@ -5030,7 +5030,7 @@ static int rbd_dev_v2_object_prefix(struct rbd_device *rbd_dev)
 	} else {
 		dout("  object_prefix = %s\n", rbd_dev->header.object_prefix);
 	}
-out:
+ free_buffer:
 	kfree(reply_buf);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-12 18:59   ` [PATCH 14/47] block-rbd: Rename a jump label in rbd_dev_v2_object_prefix() SF Markus Elfring
@ 2016-09-12 19:00   ` SF Markus Elfring
  2016-09-13  8:07     ` Ilya Dryomov
  2016-09-12 19:01   ` [PATCH 16/47] block-rbd: Rename jump labels in rbd_dev_v1_header_info() SF Markus Elfring
                     ` (31 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:00 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:12:39 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6acddc53..262805a 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4930,23 +4930,22 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
 					 minor_to_rbd_dev_id(1 << MINORBITS),
 					 GFP_KERNEL);
 	if (rbd_dev->dev_id < 0)
-		goto fail_rbd_dev;
+		goto free_device;
 
 	sprintf(rbd_dev->name, RBD_DRV_NAME "%d", rbd_dev->dev_id);
 	rbd_dev->task_wq = alloc_ordered_workqueue("%s-tasks", WQ_MEM_RECLAIM,
 						   rbd_dev->name);
 	if (!rbd_dev->task_wq)
-		goto fail_dev_id;
+		goto remove_id;
 
 	/* we have a ref from do_rbd_add() */
 	__module_get(THIS_MODULE);
 
 	dout("%s rbd_dev %p dev_id %d\n", __func__, rbd_dev, rbd_dev->dev_id);
 	return rbd_dev;
-
-fail_dev_id:
+ remove_id:
 	ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
-fail_rbd_dev:
+ free_device:
 	rbd_dev_free(rbd_dev);
 	return NULL;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 16/47] block-rbd: Rename jump labels in rbd_dev_v1_header_info()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (15 preceding siblings ...)
  2016-09-12 19:00   ` [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create() SF Markus Elfring
@ 2016-09-12 19:01   ` SF Markus Elfring
  2016-09-12 19:03   ` [PATCH 17/47] block-rbd: Rename jump labels in rbd_init_disk() SF Markus Elfring
                     ` (30 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:01 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:15:44 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 262805a..0b6f0f9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4352,17 +4352,17 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev)
 		ret = rbd_obj_read_sync(rbd_dev, rbd_dev->header_oid.name,
 				       0, size, ondisk);
 		if (ret < 0)
-			goto out;
+			goto free_header;
 		if ((size_t)ret < size) {
 			ret = -ENXIO;
 			rbd_warn(rbd_dev, "short header read (want %zd got %d)",
 				size, ret);
-			goto out;
+			goto free_header;
 		}
 		if (!rbd_dev_ondisk_valid(ondisk)) {
 			ret = -ENXIO;
 			rbd_warn(rbd_dev, "invalid header");
-			goto out;
+			goto free_header;
 		}
 
 		names_size = le64_to_cpu(ondisk->snap_names_len);
@@ -4371,7 +4371,7 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev)
 	} while (snap_count != want_count);
 
 	ret = rbd_header_from_disk(rbd_dev, ondisk);
-out:
+ free_header:
 	kfree(ondisk);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 17/47] block-rbd: Rename jump labels in rbd_init_disk()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (16 preceding siblings ...)
  2016-09-12 19:01   ` [PATCH 16/47] block-rbd: Rename jump labels in rbd_dev_v1_header_info() SF Markus Elfring
@ 2016-09-12 19:03   ` SF Markus Elfring
  2016-09-12 19:04   ` [PATCH 18/47] block-rbd: Fix jump targets in rbd_queue_workfn() SF Markus Elfring
                     ` (29 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:03 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:26:28 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0b6f0f9..97d4d63 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4500,12 +4500,12 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
 
 	err = blk_mq_alloc_tag_set(&rbd_dev->tag_set);
 	if (err)
-		goto out_disk;
+		goto put_disk;
 
 	q = blk_mq_init_queue(&rbd_dev->tag_set);
 	if (IS_ERR(q)) {
 		err = PTR_ERR(q);
-		goto out_tag_set;
+		goto free_tag_set;
 	}
 
 	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, q);
@@ -4537,9 +4537,9 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
 	rbd_dev->disk = disk;
 
 	return 0;
-out_tag_set:
+ free_tag_set:
 	blk_mq_free_tag_set(&rbd_dev->tag_set);
-out_disk:
+ put_disk:
 	put_disk(disk);
 	return err;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 18/47] block-rbd: Fix jump targets in rbd_queue_workfn()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (17 preceding siblings ...)
  2016-09-12 19:03   ` [PATCH 17/47] block-rbd: Rename jump labels in rbd_init_disk() SF Markus Elfring
@ 2016-09-12 19:04   ` SF Markus Elfring
  2016-09-12 19:05   ` [PATCH 19/47] block-rbd: Rename a jump label in rbd_reregister_watch() SF Markus Elfring
                     ` (28 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:04 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 18:28:23 +0200

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

* Delete a duplicate check then at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 97d4d63..2b5f76e 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4113,7 +4113,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 		dout("%s: non-fs request type %d\n", __func__,
 			(int) rq->cmd_type);
 		result = -EIO;
-		goto err;
+		goto end_request;
 	}
 
 	if (req_op(rq) == REQ_OP_DISCARD)
@@ -4128,7 +4128,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 	if (!length) {
 		dout("%s: zero-length request\n", __func__);
 		result = 0;
-		goto err_rq;
+		goto put_snap_context;
 	}
 
 	/* Only reads are allowed to a read-only device */
@@ -4136,7 +4136,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 	if (op_type != OBJ_OP_READ) {
 		if (rbd_dev->mapping.read_only) {
 			result = -EROFS;
-			goto err_rq;
+			goto warn_more;
 		}
 		rbd_assert(rbd_dev->spec->snap_id == CEPH_NOSNAP);
 	}
@@ -4151,14 +4151,14 @@ static void rbd_queue_workfn(struct work_struct *work)
 		dout("request for non-existent snapshot");
 		rbd_assert(rbd_dev->spec->snap_id != CEPH_NOSNAP);
 		result = -ENXIO;
-		goto err_rq;
+		goto warn_more;
 	}
 
 	if (offset && length > U64_MAX - offset + 1) {
 		rbd_warn(rbd_dev, "bad request range (%llu~%llu)", offset,
 			 length);
 		result = -EINVAL;
-		goto err_rq;	/* Shouldn't happen */
+		goto warn_more;	/* Shouldn't happen */
 	}
 
 	blk_mq_start_request(rq);
@@ -4176,7 +4176,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 		rbd_warn(rbd_dev, "beyond EOD (%llu~%llu > %llu)", offset,
 			 length, mapping_size);
 		result = -EIO;
-		goto err_rq;
+		goto warn_more;
 	}
 
 	if (must_be_locked) {
@@ -4189,7 +4189,7 @@ static void rbd_queue_workfn(struct work_struct *work)
 					     snapc);
 	if (!img_request) {
 		result = -ENOMEM;
-		goto err_unlock;
+		goto unlock;
 	}
 	img_request->rq = rq;
 	snapc = NULL; /* img_request consumes a ref */
@@ -4201,27 +4201,30 @@ static void rbd_queue_workfn(struct work_struct *work)
 		result = rbd_img_request_fill(img_request, OBJ_REQUEST_BIO,
 					      rq->bio);
 	if (result)
-		goto err_img_request;
+		goto put_request;
 
 	result = rbd_img_request_submit(img_request);
 	if (result)
-		goto err_img_request;
+		goto put_request;
 
 	if (must_be_locked)
 		up_read(&rbd_dev->lock_rwsem);
 	return;
-
-err_img_request:
+ put_request:
 	rbd_img_request_put(img_request);
-err_unlock:
+ unlock:
 	if (must_be_locked)
 		up_read(&rbd_dev->lock_rwsem);
-err_rq:
-	if (result)
-		rbd_warn(rbd_dev, "%s %llx at %llx result %d",
-			 obj_op_name(op_type), length, offset, result);
+ warn_more:
+	rbd_warn(rbd_dev,
+		 "%s %llx at %llx result %d",
+		 obj_op_name(op_type),
+		 length,
+		 offset,
+		 result);
+ put_snap_context:
 	ceph_put_snap_context(snapc);
-err:
+ end_request:
 	blk_mq_end_request(rq, result);
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 19/47] block-rbd: Rename a jump label in rbd_reregister_watch()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (18 preceding siblings ...)
  2016-09-12 19:04   ` [PATCH 18/47] block-rbd: Fix jump targets in rbd_queue_workfn() SF Markus Elfring
@ 2016-09-12 19:05   ` SF Markus Elfring
  2016-09-12 19:06   ` [PATCH 20/47] block-rbd: Rename a jump label in rbd_register_watch() SF Markus Elfring
                     ` (27 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:05 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:31:04 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 2b5f76e..97dbc1a 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3950,7 +3950,7 @@ static void rbd_reregister_watch(struct work_struct *work)
 
 	mutex_lock(&rbd_dev->watch_mutex);
 	if (rbd_dev->watch_state != RBD_WATCH_STATE_ERROR)
-		goto fail_unlock;
+		goto unlock;
 
 	ret = __rbd_register_watch(rbd_dev);
 	if (ret) {
@@ -3959,7 +3959,7 @@ static void rbd_reregister_watch(struct work_struct *work)
 			queue_delayed_work(rbd_dev->task_wq,
 					   &rbd_dev->watch_dwork,
 					   RBD_RETRY_DELAY);
-		goto fail_unlock;
+		goto unlock;
 	}
 
 	rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED;
@@ -3980,8 +3980,7 @@ static void rbd_reregister_watch(struct work_struct *work)
 	up_write(&rbd_dev->lock_rwsem);
 	wake_requests(rbd_dev, true);
 	return;
-
-fail_unlock:
+ unlock:
 	mutex_unlock(&rbd_dev->watch_mutex);
 	up_write(&rbd_dev->lock_rwsem);
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 20/47] block-rbd: Rename a jump label in rbd_register_watch()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (19 preceding siblings ...)
  2016-09-12 19:05   ` [PATCH 19/47] block-rbd: Rename a jump label in rbd_reregister_watch() SF Markus Elfring
@ 2016-09-12 19:06   ` SF Markus Elfring
  2016-09-12 19:07   ` [PATCH 21/47] block-rbd: Rename jump labels in rbd_try_lock() SF Markus Elfring
                     ` (26 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:06 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:33:00 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 97dbc1a..b0b5a3b 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3900,12 +3900,11 @@ static int rbd_register_watch(struct rbd_device *rbd_dev)
 	rbd_assert(rbd_dev->watch_state == RBD_WATCH_STATE_UNREGISTERED);
 	ret = __rbd_register_watch(rbd_dev);
 	if (ret)
-		goto out;
+		goto unlock;
 
 	rbd_dev->watch_state = RBD_WATCH_STATE_REGISTERED;
 	rbd_dev->watch_cookie = rbd_dev->watch_handle->linger_id;
-
-out:
+ unlock:
 	mutex_unlock(&rbd_dev->watch_mutex);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 21/47] block-rbd: Rename jump labels in rbd_try_lock()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (20 preceding siblings ...)
  2016-09-12 19:06   ` [PATCH 20/47] block-rbd: Rename a jump label in rbd_register_watch() SF Markus Elfring
@ 2016-09-12 19:07   ` SF Markus Elfring
  2016-09-12 19:08   ` [PATCH 22/47] block-rbd: Rename a jump label in find_watcher() SF Markus Elfring
                     ` (25 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:07 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:35:08 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b0b5a3b..7802351 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3478,7 +3478,7 @@ static int rbd_try_lock(struct rbd_device *rbd_dev)
 		if (ret) {
 			if (ret > 0)
 				ret = 0; /* have to request lock */
-			goto out;
+			goto free_lockers;
 		}
 
 		rbd_warn(rbd_dev, "%s%llu seems dead, breaking lock",
@@ -3489,7 +3489,7 @@ static int rbd_try_lock(struct rbd_device *rbd_dev)
 		if (ret) {
 			rbd_warn(rbd_dev, "blacklist of %s%llu failed: %d",
 				 ENTITY_NAME(lockers[0].id.name), ret);
-			goto out;
+			goto free_lockers;
 		}
 
 		ret = ceph_cls_break_lock(&client->osdc, &rbd_dev->header_oid,
@@ -3497,13 +3497,11 @@ static int rbd_try_lock(struct rbd_device *rbd_dev)
 					  lockers[0].id.cookie,
 					  &lockers[0].id.name);
 		if (ret && ret != -ENOENT)
-			goto out;
-
-again:
+			goto free_lockers;
+ again:
 		ceph_free_lockers(lockers, num_lockers);
 	}
-
-out:
+ free_lockers:
 	ceph_free_lockers(lockers, num_lockers);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 22/47] block-rbd: Rename a jump label in find_watcher()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (21 preceding siblings ...)
  2016-09-12 19:07   ` [PATCH 21/47] block-rbd: Rename jump labels in rbd_try_lock() SF Markus Elfring
@ 2016-09-12 19:08   ` SF Markus Elfring
  2016-09-12 19:09   ` [PATCH 23/47] block-rbd: Rename jump labels in get_lock_owner_info() SF Markus Elfring
                     ` (24 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:08 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:36:23 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7802351..ba8fb74 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3440,13 +3440,13 @@ static int find_watcher(struct rbd_device *rbd_dev,
 			     rbd_dev, cid.gid, cid.handle);
 			rbd_set_owner_cid(rbd_dev, &cid);
 			ret = 1;
-			goto out;
+			goto free_watchers;
 		}
 	}
 
 	dout("%s rbd_dev %p no watchers\n", __func__, rbd_dev);
 	ret = 0;
-out:
+free_watchers:
 	kfree(watchers);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 23/47] block-rbd: Rename jump labels in get_lock_owner_info()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (22 preceding siblings ...)
  2016-09-12 19:08   ` [PATCH 22/47] block-rbd: Rename a jump label in find_watcher() SF Markus Elfring
@ 2016-09-12 19:09   ` SF Markus Elfring
  2016-09-12 19:10   ` [PATCH 24/47] block-rbd: Rename jump labels in rbd_request_lock() SF Markus Elfring
                     ` (23 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:09 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:37:52 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index ba8fb74..e175d21 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3381,20 +3381,20 @@ static int get_lock_owner_info(struct rbd_device *rbd_dev,
 
 	if (*num_lockers == 0) {
 		dout("%s rbd_dev %p no lockers detected\n", __func__, rbd_dev);
-		goto out;
+		goto free_tag;
 	}
 
 	if (strcmp(lock_tag, RBD_LOCK_TAG)) {
 		rbd_warn(rbd_dev, "locked by external mechanism, tag %s",
 			 lock_tag);
 		ret = -EBUSY;
-		goto out;
+		goto free_tag;
 	}
 
 	if (lock_type == CEPH_CLS_LOCK_SHARED) {
 		rbd_warn(rbd_dev, "shared lock type detected");
 		ret = -EBUSY;
-		goto out;
+		goto free_tag;
 	}
 
 	if (strncmp((*lockers)[0].id.cookie, RBD_LOCK_COOKIE_PREFIX,
@@ -3402,10 +3402,8 @@ static int get_lock_owner_info(struct rbd_device *rbd_dev,
 		rbd_warn(rbd_dev, "locked by external mechanism, cookie %s",
 			 (*lockers)[0].id.cookie);
 		ret = -EBUSY;
-		goto out;
 	}
-
-out:
+ free_tag:
 	kfree(lock_tag);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 24/47] block-rbd: Rename jump labels in rbd_request_lock()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (23 preceding siblings ...)
  2016-09-12 19:09   ` [PATCH 23/47] block-rbd: Rename jump labels in get_lock_owner_info() SF Markus Elfring
@ 2016-09-12 19:10   ` SF Markus Elfring
  2016-09-12 19:11   ` [PATCH 25/47] block-rbd: Fix jump targets in rbd_img_parent_read() SF Markus Elfring
                     ` (22 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:10 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:38:52 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e175d21..09a0ed3 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3297,7 +3297,7 @@ static int rbd_request_lock(struct rbd_device *rbd_dev)
 				   &reply_pages, &reply_len);
 	if (ret && ret != -ETIMEDOUT) {
 		rbd_warn(rbd_dev, "failed to request lock: %d", ret);
-		goto out;
+		goto release_page_vector;
 	}
 
 	if (reply_len > 0 && reply_len <= PAGE_SIZE) {
@@ -3321,7 +3321,7 @@ static int rbd_request_lock(struct rbd_device *rbd_dev)
 				rbd_warn(rbd_dev,
 					 "duplicate lock owners detected");
 				ret = -EIO;
-				goto out;
+				goto release_page_vector;
 			}
 
 			lock_owner_responded = true;
@@ -3342,14 +3342,12 @@ static int rbd_request_lock(struct rbd_device *rbd_dev)
 		rbd_warn(rbd_dev, "no lock owners detected");
 		ret = -ETIMEDOUT;
 	}
-
-out:
+ release_page_vector:
 	ceph_release_page_vector(reply_pages, calc_pages_for(0, reply_len));
 	return ret;
-
-e_inval:
+ e_inval:
 	ret = -EINVAL;
-	goto out;
+	goto release_page_vector;
 }
 
 static void wake_requests(struct rbd_device *rbd_dev, bool wake_all)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 25/47] block-rbd: Fix jump targets in rbd_img_parent_read()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (24 preceding siblings ...)
  2016-09-12 19:10   ` [PATCH 24/47] block-rbd: Rename jump labels in rbd_request_lock() SF Markus Elfring
@ 2016-09-12 19:11   ` SF Markus Elfring
  2016-09-12 19:12   ` [PATCH 26/47] block-rbd: Rename a jump label in rbd_img_parent_read_callback() SF Markus Elfring
                     ` (21 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:11 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:39:54 +0200

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

* Delete a duplicate check then at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 09a0ed3..6777464 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3120,7 +3120,7 @@ static void rbd_img_parent_read(struct rbd_obj_request *obj_request)
 						obj_request->length);
 	result = -ENOMEM;
 	if (!img_request)
-		goto out_err;
+		goto status_indication;
 
 	if (obj_request->type == OBJ_REQUEST_BIO)
 		result = rbd_img_request_fill(img_request, OBJ_REQUEST_BIO,
@@ -3129,17 +3129,17 @@ static void rbd_img_parent_read(struct rbd_obj_request *obj_request)
 		result = rbd_img_request_fill(img_request, OBJ_REQUEST_PAGES,
 						obj_request->pages);
 	if (result)
-		goto out_err;
+		goto put_request;
 
 	img_request->callback = rbd_img_parent_read_callback;
 	result = rbd_img_request_submit(img_request);
 	if (result)
-		goto out_err;
+		goto put_request;
 
 	return;
-out_err:
-	if (img_request)
-		rbd_img_request_put(img_request);
+ put_request:
+	rbd_img_request_put(img_request);
+ status_indication:
 	obj_request->result = result;
 	obj_request->xferred = 0;
 	obj_request_done_set(obj_request);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 26/47] block-rbd: Rename a jump label in rbd_img_parent_read_callback()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (25 preceding siblings ...)
  2016-09-12 19:11   ` [PATCH 25/47] block-rbd: Fix jump targets in rbd_img_parent_read() SF Markus Elfring
@ 2016-09-12 19:12   ` SF Markus Elfring
  2016-09-12 19:13   ` [PATCH 27/47] block-rbd: Rename a jump label in rbd_img_request_submit() SF Markus Elfring
                     ` (20 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:12 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:40:45 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 6777464..23812e4 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3077,7 +3077,7 @@ static void rbd_img_parent_read_callback(struct rbd_img_request *img_request)
 
 	obj_request->result = img_result;
 	if (obj_request->result)
-		goto out;
+		goto callback;
 
 	/*
 	 * We need to zero anything beyond the parent overlap
@@ -3099,7 +3099,7 @@ static void rbd_img_parent_read_callback(struct rbd_img_request *img_request)
 	} else {
 		obj_request->xferred = img_xferred;
 	}
-out:
+ callback:
 	rbd_img_obj_request_read_callback(obj_request);
 	rbd_obj_request_complete(obj_request);
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 27/47] block-rbd: Rename a jump label in rbd_img_request_submit()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (26 preceding siblings ...)
  2016-09-12 19:12   ` [PATCH 26/47] block-rbd: Rename a jump label in rbd_img_parent_read_callback() SF Markus Elfring
@ 2016-09-12 19:13   ` SF Markus Elfring
  2016-09-12 19:14   ` [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit() SF Markus Elfring
                     ` (19 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:13 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:43:35 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 23812e4..17bdc21 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -3033,10 +3033,9 @@ static int rbd_img_request_submit(struct rbd_img_request *img_request)
 	for_each_obj_request_safe(img_request, obj_request, next_obj_request) {
 		ret = rbd_img_obj_request_submit(obj_request);
 		if (ret)
-			goto out_put_ireq;
+			goto put_request;
 	}
-
-out_put_ireq:
+ put_request:
 	rbd_img_request_put(img_request);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (27 preceding siblings ...)
  2016-09-12 19:13   ` [PATCH 27/47] block-rbd: Rename a jump label in rbd_img_request_submit() SF Markus Elfring
@ 2016-09-12 19:14   ` SF Markus Elfring
  2016-09-13  8:10     ` Ilya Dryomov
  2016-09-12 19:15   ` [PATCH 29/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
                     ` (18 subsequent siblings)
  47 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:14 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:44:30 +0200

Adjust a jump target so that a duplicate check can then be avoided
at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 17bdc21..66801ec 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2920,7 +2920,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 	stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0,
 							OBJ_REQUEST_PAGES);
 	if (!stat_request)
-		goto out;
+		goto put_request;
 
 	rbd_obj_request_get(obj_request);
 	stat_request->obj_request = obj_request;
@@ -2932,7 +2932,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 	stat_request->osd_req = rbd_osd_req_create(rbd_dev, OBJ_OP_READ, 1,
 						   stat_request);
 	if (!stat_request->osd_req)
-		goto out;
+		goto put_request;
 	stat_request->callback = rbd_img_obj_exists_callback;
 
 	osd_req_op_init(stat_request->osd_req, 0, CEPH_OSD_OP_STAT, 0);
@@ -2942,8 +2942,8 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 
 	osdc = &rbd_dev->rbd_client->client->osdc;
 	ret = rbd_obj_request_submit(osdc, stat_request);
-out:
 	if (ret)
+ put_request:
 		rbd_obj_request_put(obj_request);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 29/47] block-rbd: Delete an unnecessary initialisation in rbd_img_obj_exists_submit()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (28 preceding siblings ...)
  2016-09-12 19:14   ` [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit() SF Markus Elfring
@ 2016-09-12 19:15   ` SF Markus Elfring
  2016-09-12 19:16   ` [PATCH 30/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_callback() SF Markus Elfring
                     ` (17 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:15 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:45:29 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 66801ec..f3f2919 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2897,7 +2897,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 	struct rbd_obj_request *stat_request;
 	struct rbd_device *rbd_dev;
 	struct ceph_osd_client *osdc;
-	struct page **pages = NULL;
+	struct page **pages;
 	u32 page_count;
 	size_t size;
 	int ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 30/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_callback()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (29 preceding siblings ...)
  2016-09-12 19:15   ` [PATCH 29/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-12 19:16   ` SF Markus Elfring
  2016-09-12 19:18   ` [PATCH 31/47] block-rbd: Fix three jump targets in rbd_img_obj_parent_read_full() SF Markus Elfring
                     ` (16 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:16 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:46:43 +0200

Adjust a jump target so that a duplicate check can then be avoided
at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f3f2919..7d5f7b9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2879,7 +2879,7 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request)
 		obj_request_existence_set(orig_request, false);
 	} else if (result) {
 		orig_request->result = result;
-		goto out;
+		goto complete_request;
 	}
 
 	/*
@@ -2887,8 +2887,8 @@ static void rbd_img_obj_exists_callback(struct rbd_obj_request *obj_request)
 	 * whether the target object exists.
 	 */
 	orig_request->result = rbd_img_obj_request_submit(orig_request);
-out:
 	if (orig_request->result)
+ complete_request:
 		rbd_obj_request_complete(orig_request);
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 31/47] block-rbd: Fix three jump targets in rbd_img_obj_parent_read_full()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (30 preceding siblings ...)
  2016-09-12 19:16   ` [PATCH 30/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_callback() SF Markus Elfring
@ 2016-09-12 19:18   ` SF Markus Elfring
  2016-09-12 19:20   ` [PATCH 32/47] block-rbd: Rename a jump label in rbd_img_obj_parent_read_full_callback() SF Markus Elfring
                     ` (15 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:18 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:48:46 +0200

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

* Delete two duplicate checks then at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

I find that this function implementation needs another close look.
It seems that four lines can not be executed according to the shown
control flow at the moment.
How do you think about to avoid "dead" source code there anyhow?

 drivers/block/rbd.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7d5f7b9..1b8a8c5 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2789,18 +2789,18 @@ static int rbd_img_obj_parent_read_full(struct rbd_obj_request *obj_request)
 	if (IS_ERR(pages)) {
 		result = PTR_ERR(pages);
 		pages = NULL;
-		goto out_err;
+		goto status_indication;
 	}
 
 	result = -ENOMEM;
 	parent_request = rbd_parent_request_create(obj_request,
 						img_offset, length);
 	if (!parent_request)
-		goto out_err;
+		goto release_page_vector;
 
 	result = rbd_img_request_fill(parent_request, OBJ_REQUEST_PAGES, pages);
 	if (result)
-		goto out_err;
+		goto put_request;
 	parent_request->copyup_pages = pages;
 	parent_request->copyup_page_count = page_count;
 
@@ -2813,11 +2813,11 @@ static int rbd_img_obj_parent_read_full(struct rbd_obj_request *obj_request)
 	parent_request->copyup_page_count = 0;
 	parent_request->obj_request = NULL;
 	rbd_obj_request_put(obj_request);
-out_err:
-	if (pages)
-		ceph_release_page_vector(pages, page_count);
-	if (parent_request)
-		rbd_img_request_put(parent_request);
+ put_request:
+	rbd_img_request_put(parent_request);
+ release_page_vector:
+	ceph_release_page_vector(pages, page_count);
+ status_indication:
 	obj_request->result = result;
 	obj_request->xferred = 0;
 	obj_request_done_set(obj_request);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 32/47] block-rbd: Rename a jump label in rbd_img_obj_parent_read_full_callback()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (31 preceding siblings ...)
  2016-09-12 19:18   ` [PATCH 31/47] block-rbd: Fix three jump targets in rbd_img_obj_parent_read_full() SF Markus Elfring
@ 2016-09-12 19:20   ` SF Markus Elfring
  2016-09-12 19:22   ` [PATCH 33/47] block-rbd: Adjust the position of a jump label in rbd_img_request_fill() SF Markus Elfring
                     ` (14 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:20 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:49:33 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 1b8a8c5..7a43711 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2687,7 +2687,7 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request)
 	}
 
 	if (img_result)
-		goto out_err;
+		goto status_indication;
 
 	/*
 	 * The original osd request is of no use to use any more.
@@ -2698,7 +2698,7 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request)
 	img_result = -ENOMEM;
 	osd_req = rbd_osd_req_create_copyup(orig_request);
 	if (!osd_req)
-		goto out_err;
+		goto status_indication;
 	rbd_osd_req_destroy(orig_request->osd_req);
 	orig_request->osd_req = osd_req;
 	orig_request->copyup_pages = pages;
@@ -2721,7 +2721,7 @@ rbd_img_obj_parent_read_full_callback(struct rbd_img_request *img_request)
 	img_result = rbd_obj_request_submit(osdc, orig_request);
 	if (!img_result)
 		return;
-out_err:
+ status_indication:
 	/* Record the error code and complete the request */
 
 	orig_request->result = img_result;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 33/47] block-rbd: Adjust the position of a jump label in rbd_img_request_fill()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (32 preceding siblings ...)
  2016-09-12 19:20   ` [PATCH 32/47] block-rbd: Rename a jump label in rbd_img_obj_parent_read_full_callback() SF Markus Elfring
@ 2016-09-12 19:22   ` SF Markus Elfring
  2016-09-12 19:23   ` [PATCH 34/47] block-rbd: Rename a jump label in rbd_img_obj_callback() SF Markus Elfring
                     ` (13 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:22 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

>From a0cfdf15bae448d9a0e2d5d6480c70cfa3f77322 Mon Sep 17 00:00:00 2001
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:50:43 +0200
Subject: [PATCH 33/47] block-rbd: Adjust the position of a jump label in
 rbd_img_request_fill()

Add a space character before a single jump label in this function
according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7a43711..34ccbf1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2588,8 +2588,7 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
 	}
 
 	return 0;
-
-out_unwind:
+ out_unwind:
 	for_each_obj_request_safe(img_request, obj_request, next_obj_request)
 		rbd_img_obj_request_del(img_request, obj_request);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 34/47] block-rbd: Rename a jump label in rbd_img_obj_callback()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (33 preceding siblings ...)
  2016-09-12 19:22   ` [PATCH 33/47] block-rbd: Adjust the position of a jump label in rbd_img_request_fill() SF Markus Elfring
@ 2016-09-12 19:23   ` SF Markus Elfring
  2016-09-12 19:24   ` [PATCH 35/47] block-rbd: Rename jump labels in rbd_osd_req_create_copyup() SF Markus Elfring
                     ` (12 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:23 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:51:29 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 34ccbf1..c349975 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2394,7 +2394,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
 
 	spin_lock_irq(&img_request->completion_lock);
 	if (which != img_request->next_completion)
-		goto out;
+		goto unlock;
 
 	for_each_obj_request_from(img_request, obj_request) {
 		rbd_assert(more);
@@ -2408,7 +2408,7 @@ static void rbd_img_obj_callback(struct rbd_obj_request *obj_request)
 
 	rbd_assert(more ^ (which == img_request->obj_request_count));
 	img_request->next_completion = which;
-out:
+ unlock:
 	spin_unlock_irq(&img_request->completion_lock);
 	rbd_img_request_put(img_request);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 35/47] block-rbd: Rename jump labels in rbd_osd_req_create_copyup()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (34 preceding siblings ...)
  2016-09-12 19:23   ` [PATCH 34/47] block-rbd: Rename a jump label in rbd_img_obj_callback() SF Markus Elfring
@ 2016-09-12 19:24   ` SF Markus Elfring
  2016-09-12 19:25   ` [PATCH 36/47] block-rbd: Rename jump labels in rbd_osd_req_create() SF Markus Elfring
                     ` (11 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:24 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:53:26 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index c349975..f779ff3 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -2046,7 +2046,7 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request)
 	osd_req = ceph_osdc_alloc_request(osdc, snapc, num_osd_ops,
 						false, GFP_NOIO);
 	if (!osd_req)
-		goto fail;
+		goto put_request;
 
 	osd_req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
 	osd_req->r_callback = rbd_osd_req_callback;
@@ -2055,14 +2055,13 @@ rbd_osd_req_create_copyup(struct rbd_obj_request *obj_request)
 	osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;
 	if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
 			     obj_request->object_name))
-		goto fail;
+		goto put_request;
 
 	if (ceph_osdc_alloc_messages(osd_req, GFP_NOIO))
-		goto fail;
+		goto put_request;
 
 	return osd_req;
-
-fail:
+ put_request:
 	ceph_osdc_put_request(osd_req);
 	return NULL;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 36/47] block-rbd: Rename jump labels in rbd_osd_req_create()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (35 preceding siblings ...)
  2016-09-12 19:24   ` [PATCH 35/47] block-rbd: Rename jump labels in rbd_osd_req_create_copyup() SF Markus Elfring
@ 2016-09-12 19:25   ` SF Markus Elfring
  2016-09-12 19:26   ` [PATCH 37/47] block-rbd: Rename a jump label in bio_chain_clone_range() SF Markus Elfring
                     ` (10 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:25 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:54:39 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f779ff3..8e9d30f7 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1988,7 +1988,7 @@ static struct ceph_osd_request *rbd_osd_req_create(
 	osd_req = ceph_osdc_alloc_request(osdc, snapc, num_ops, false,
 					  GFP_NOIO);
 	if (!osd_req)
-		goto fail;
+		goto put_request;
 
 	if (op_type == OBJ_OP_WRITE || op_type == OBJ_OP_DISCARD)
 		osd_req->r_flags = CEPH_OSD_FLAG_WRITE | CEPH_OSD_FLAG_ONDISK;
@@ -2001,14 +2001,13 @@ static struct ceph_osd_request *rbd_osd_req_create(
 	osd_req->r_base_oloc.pool = rbd_dev->layout.pool_id;
 	if (ceph_oid_aprintf(&osd_req->r_base_oid, GFP_NOIO, "%s",
 			     obj_request->object_name))
-		goto fail;
+		goto put_request;
 
 	if (ceph_osdc_alloc_messages(osd_req, GFP_NOIO))
-		goto fail;
+		goto put_request;
 
 	return osd_req;
-
-fail:
+ put_request:
 	ceph_osdc_put_request(osd_req);
 	return NULL;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 37/47] block-rbd: Rename a jump label in bio_chain_clone_range()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (36 preceding siblings ...)
  2016-09-12 19:25   ` [PATCH 36/47] block-rbd: Rename jump labels in rbd_osd_req_create() SF Markus Elfring
@ 2016-09-12 19:26   ` SF Markus Elfring
  2016-09-12 19:27   ` [PATCH 38/47] block-rbd: Rename jump labels in rbd_client_create() SF Markus Elfring
                     ` (9 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:26 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:56:37 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8e9d30f7..abc2dcb 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1421,12 +1421,12 @@ static struct bio *bio_chain_clone_range(struct bio **bio_src,
 
 		if (!bi) {
 			rbd_warn(NULL, "bio_chain exhausted with %u left", len);
-			goto out_err;	/* EINVAL; ran out of bio's */
+			goto put_chain;	/* EINVAL; ran out of bio's */
 		}
 		bi_size = min_t(unsigned int, bi->bi_iter.bi_size - off, len);
 		bio = bio_clone_range(bi, off, bi_size, gfpmask);
 		if (!bio)
-			goto out_err;	/* ENOMEM */
+			goto put_chain;	/* ENOMEM */
 
 		*end = bio;
 		end = &bio->bi_next;
@@ -1442,7 +1442,7 @@ static struct bio *bio_chain_clone_range(struct bio **bio_src,
 	*offset = off;
 
 	return chain;
-out_err:
+ put_chain:
 	bio_chain_put(chain);
 
 	return NULL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 38/47] block-rbd: Rename jump labels in rbd_client_create()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (37 preceding siblings ...)
  2016-09-12 19:26   ` [PATCH 37/47] block-rbd: Rename a jump label in bio_chain_clone_range() SF Markus Elfring
@ 2016-09-12 19:27   ` SF Markus Elfring
  2016-09-12 19:28   ` [PATCH 39/47] block-rbd: Rename a jump label in rbd_ioctl_set_ro() SF Markus Elfring
                     ` (8 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:27 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:57:19 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index abc2dcb..9902a7f 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -718,19 +718,19 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts)
 	dout("%s:\n", __func__);
 	rbdc = kmalloc(sizeof(struct rbd_client), GFP_KERNEL);
 	if (!rbdc)
-		goto out_opt;
+		goto check_input;
 
 	kref_init(&rbdc->kref);
 	INIT_LIST_HEAD(&rbdc->node);
 
 	rbdc->client = ceph_create_client(ceph_opts, rbdc, 0, 0);
 	if (IS_ERR(rbdc->client))
-		goto out_rbdc;
+		goto free_rbdc;
 	ceph_opts = NULL; /* Now rbdc->client is responsible for ceph_opts */
 
 	ret = ceph_open_session(rbdc->client);
 	if (ret < 0)
-		goto out_client;
+		goto destroy_client;
 
 	spin_lock(&rbd_client_list_lock);
 	list_add_tail(&rbdc->node, &rbd_client_list);
@@ -739,11 +739,11 @@ static struct rbd_client *rbd_client_create(struct ceph_options *ceph_opts)
 	dout("%s: rbdc %p\n", __func__, rbdc);
 
 	return rbdc;
-out_client:
+ destroy_client:
 	ceph_destroy_client(rbdc->client);
-out_rbdc:
+ free_rbdc:
 	kfree(rbdc);
-out_opt:
+ check_input:
 	if (ceph_opts)
 		ceph_destroy_options(ceph_opts);
 	dout("%s: error %d\n", __func__, ret);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 39/47] block-rbd: Rename a jump label in rbd_ioctl_set_ro()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (38 preceding siblings ...)
  2016-09-12 19:27   ` [PATCH 38/47] block-rbd: Rename jump labels in rbd_client_create() SF Markus Elfring
@ 2016-09-12 19:28   ` SF Markus Elfring
  2016-09-12 19:29   ` [PATCH 40/47] block-rbd: One function call less in rbd_dev_probe_parent() after error detection SF Markus Elfring
                     ` (7 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:28 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 19:58:22 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 9902a7f..e01df3c 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -654,15 +654,14 @@ static int rbd_ioctl_set_ro(struct rbd_device *rbd_dev, unsigned long arg)
 	/* prevent others open this device */
 	if (rbd_dev->open_count > 1) {
 		ret = -EBUSY;
-		goto out;
+		goto unlock;
 	}
 
 	if (rbd_dev->mapping.read_only != ro) {
 		rbd_dev->mapping.read_only = ro;
 		ro_changed = true;
 	}
-
-out:
+ unlock:
 	spin_unlock_irq(&rbd_dev->lock);
 	/* set_disk_ro() may sleep, so call it after releasing rbd_dev->lock */
 	if (ret == 0 && ro_changed)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 40/47] block-rbd: One function call less in rbd_dev_probe_parent() after error detection
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (39 preceding siblings ...)
  2016-09-12 19:28   ` [PATCH 39/47] block-rbd: Rename a jump label in rbd_ioctl_set_ro() SF Markus Elfring
@ 2016-09-12 19:29   ` SF Markus Elfring
  2016-09-12 19:30   ` [PATCH 41/47] block-rbd: Rename jump labels in rbd_dev_device_setup() SF Markus Elfring
                     ` (6 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:29 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:00:08 +0200

The rbd_dev_destroy() function was called in two cases by the
rbd_dev_probe_parent() function during error handling even if
the passed variable contained a null pointer.

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

* Delete an initialisation for the variable "parent" at the beginning
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e01df3c..a037a5d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -5950,7 +5950,7 @@ out_err:
  */
 static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
 {
-	struct rbd_device *parent = NULL;
+	struct rbd_device *parent;
 	int ret;
 
 	if (!rbd_dev->parent_spec)
@@ -5959,13 +5959,13 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
 	if (++depth > RBD_MAX_PARENT_CHAIN_LEN) {
 		pr_info("parent chain is too long (%d)\n", depth);
 		ret = -EINVAL;
-		goto out_err;
+		goto unparent_device;
 	}
 
 	parent = __rbd_dev_create(rbd_dev->rbd_client, rbd_dev->parent_spec);
 	if (!parent) {
 		ret = -ENOMEM;
-		goto out_err;
+		goto unparent_device;
 	}
 
 	/*
@@ -5977,15 +5977,15 @@ static int rbd_dev_probe_parent(struct rbd_device *rbd_dev, int depth)
 
 	ret = rbd_dev_image_probe(parent, depth);
 	if (ret < 0)
-		goto out_err;
+		goto destroy_device;
 
 	rbd_dev->parent = parent;
 	atomic_set(&rbd_dev->parent_ref, 1);
 	return 0;
-
-out_err:
-	rbd_dev_unparent(rbd_dev);
+ destroy_device:
 	rbd_dev_destroy(parent);
+ unparent_device:
+	rbd_dev_unparent(rbd_dev);
 	return ret;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 41/47] block-rbd: Rename jump labels in rbd_dev_device_setup()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (40 preceding siblings ...)
  2016-09-12 19:29   ` [PATCH 40/47] block-rbd: One function call less in rbd_dev_probe_parent() after error detection SF Markus Elfring
@ 2016-09-12 19:30   ` SF Markus Elfring
  2016-09-12 19:31   ` [PATCH 42/47] block-rbd: Rename jump labels in rbd_dev_image_probe() SF Markus Elfring
                     ` (5 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:30 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:01:03 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index a037a5d..80983f6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6002,7 +6002,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
 	if (!single_major) {
 		ret = register_blkdev(0, rbd_dev->name);
 		if (ret < 0)
-			goto err_out_unlock;
+			goto unlock;
 
 		rbd_dev->major = ret;
 		rbd_dev->minor = 0;
@@ -6015,11 +6015,11 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
 
 	ret = rbd_init_disk(rbd_dev);
 	if (ret)
-		goto err_out_blkdev;
+		goto check_single;
 
 	ret = rbd_dev_mapping_set(rbd_dev);
 	if (ret)
-		goto err_out_disk;
+		goto free_disk;
 
 	set_capacity(rbd_dev->disk, rbd_dev->mapping.size / SECTOR_SIZE);
 	set_disk_ro(rbd_dev->disk, rbd_dev->mapping.read_only);
@@ -6027,7 +6027,7 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
 	dev_set_name(&rbd_dev->dev, "%d", rbd_dev->dev_id);
 	ret = device_add(&rbd_dev->dev);
 	if (ret)
-		goto err_out_mapping;
+		goto clear_mapping;
 
 	/* Everything's ready.  Announce the disk to the world. */
 
@@ -6044,15 +6044,14 @@ static int rbd_dev_device_setup(struct rbd_device *rbd_dev)
 		rbd_dev->header.features);
 
 	return ret;
-
-err_out_mapping:
+ clear_mapping:
 	rbd_dev_mapping_clear(rbd_dev);
-err_out_disk:
+ free_disk:
 	rbd_free_disk(rbd_dev);
-err_out_blkdev:
+ check_single:
 	if (!single_major)
 		unregister_blkdev(rbd_dev->major, rbd_dev->name);
-err_out_unlock:
+ unlock:
 	up_write(&rbd_dev->header_rwsem);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 42/47] block-rbd: Rename jump labels in rbd_dev_image_probe()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (41 preceding siblings ...)
  2016-09-12 19:30   ` [PATCH 41/47] block-rbd: Rename jump labels in rbd_dev_device_setup() SF Markus Elfring
@ 2016-09-12 19:31   ` SF Markus Elfring
  2016-09-12 19:32   ` [PATCH 43/47] block-rbd: Rename jump labels in do_rbd_add() SF Markus Elfring
                     ` (4 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:31 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:02:16 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 80983f6..eec41ed 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6108,7 +6108,7 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
 
 	ret = rbd_dev_header_name(rbd_dev);
 	if (ret)
-		goto err_out_format;
+		goto status_indication;
 
 	if (!depth) {
 		ret = rbd_register_watch(rbd_dev);
@@ -6117,13 +6117,13 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
 				pr_info("image %s/%s does not exist\n",
 					rbd_dev->spec->pool_name,
 					rbd_dev->spec->image_name);
-			goto err_out_format;
+			goto status_indication;
 		}
 	}
 
 	ret = rbd_dev_header_info(rbd_dev);
 	if (ret)
-		goto err_out_watch;
+		goto check_input;
 
 	/*
 	 * If this image is the one being mapped, we have pool name and
@@ -6141,13 +6141,13 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
 				rbd_dev->spec->pool_name,
 				rbd_dev->spec->image_name,
 				rbd_dev->spec->snap_name);
-		goto err_out_probe;
+		goto unprobe_device;
 	}
 
 	if (rbd_dev->header.features & RBD_FEATURE_LAYERING) {
 		ret = rbd_dev_v2_parent_info(rbd_dev);
 		if (ret)
-			goto err_out_probe;
+			goto unprobe_device;
 
 		/*
 		 * Need to warn users if this image is the one being
@@ -6160,18 +6160,17 @@ static int rbd_dev_image_probe(struct rbd_device *rbd_dev, int depth)
 
 	ret = rbd_dev_probe_parent(rbd_dev, depth);
 	if (ret)
-		goto err_out_probe;
+		goto unprobe_device;
 
 	dout("discovered format %u image, header name is %s\n",
 		rbd_dev->image_format, rbd_dev->header_oid.name);
 	return 0;
-
-err_out_probe:
+ unprobe_device:
 	rbd_dev_unprobe(rbd_dev);
-err_out_watch:
+ check_input:
 	if (!depth)
 		rbd_unregister_watch(rbd_dev);
-err_out_format:
+ status_indication:
 	rbd_dev->image_format = 0;
 	kfree(rbd_dev->spec->image_id);
 	rbd_dev->spec->image_id = NULL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 43/47] block-rbd: Rename jump labels in do_rbd_add()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (42 preceding siblings ...)
  2016-09-12 19:31   ` [PATCH 42/47] block-rbd: Rename jump labels in rbd_dev_image_probe() SF Markus Elfring
@ 2016-09-12 19:32   ` SF Markus Elfring
  2016-09-12 19:33   ` [PATCH 44/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
                     ` (3 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:32 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:03:34 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index eec41ed..7df0b90 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6195,12 +6195,12 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 	/* parse add command */
 	rc = rbd_add_parse_args(buf, &ceph_opts, &rbd_opts, &spec);
 	if (rc < 0)
-		goto out;
+		goto put_module;
 
 	rbdc = rbd_get_client(ceph_opts);
 	if (IS_ERR(rbdc)) {
 		rc = PTR_ERR(rbdc);
-		goto err_out_args;
+		goto put_spec;
 	}
 
 	/* pick the pool */
@@ -6208,14 +6208,14 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 	if (rc < 0) {
 		if (rc == -ENOENT)
 			pr_info("pool %s does not exist\n", spec->pool_name);
-		goto err_out_client;
+		goto put_client;
 	}
 	spec->pool_id = (u64)rc;
 
 	rbd_dev = rbd_dev_create(rbdc, spec, rbd_opts);
 	if (!rbd_dev) {
 		rc = -ENOMEM;
-		goto err_out_client;
+		goto put_client;
 	}
 	rbdc = NULL;		/* rbd_dev now owns this */
 	spec = NULL;		/* rbd_dev now owns this */
@@ -6224,14 +6224,14 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 	rbd_dev->config_info = kstrdup(buf, GFP_KERNEL);
 	if (!rbd_dev->config_info) {
 		rc = -ENOMEM;
-		goto err_out_rbd_dev;
+		goto destroy_device;
 	}
 
 	down_write(&rbd_dev->header_rwsem);
 	rc = rbd_dev_image_probe(rbd_dev, 0);
 	if (rc < 0) {
 		up_write(&rbd_dev->header_rwsem);
-		goto err_out_rbd_dev;
+		goto destroy_device;
 	}
 
 	/* If we are mapping a snapshot it must be marked read-only */
@@ -6250,22 +6250,21 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 		 */
 		rbd_unregister_watch(rbd_dev);
 		rbd_dev_image_release(rbd_dev);
-		goto out;
+		goto put_module;
 	}
 
 	rc = count;
-out:
+ put_module:
 	module_put(THIS_MODULE);
 	return rc;
-
-err_out_rbd_dev:
+ destroy_device:
 	rbd_dev_destroy(rbd_dev);
-err_out_client:
+ put_client:
 	rbd_put_client(rbdc);
-err_out_args:
+ put_spec:
 	rbd_spec_put(spec);
 	kfree(rbd_opts);
-	goto out;
+	goto put_module;
 }
 
 static ssize_t rbd_add(struct bus_type *bus,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 44/47] block-rbd: Delete an unnecessary initialisation in do_rbd_add()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (43 preceding siblings ...)
  2016-09-12 19:32   ` [PATCH 43/47] block-rbd: Rename jump labels in do_rbd_add() SF Markus Elfring
@ 2016-09-12 19:33   ` SF Markus Elfring
  2016-09-12 19:34   ` [PATCH 45/47] block-rbd: Rename a jump label in rbd_slab_init() SF Markus Elfring
                     ` (2 subsequent siblings)
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:33 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:04:31 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 7df0b90..b106c68 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6181,7 +6181,7 @@ static ssize_t do_rbd_add(struct bus_type *bus,
 			  const char *buf,
 			  size_t count)
 {
-	struct rbd_device *rbd_dev = NULL;
+	struct rbd_device *rbd_dev;
 	struct ceph_options *ceph_opts = NULL;
 	struct rbd_options *rbd_opts = NULL;
 	struct rbd_spec *spec = NULL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 45/47] block-rbd: Rename a jump label in rbd_slab_init()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (44 preceding siblings ...)
  2016-09-12 19:33   ` [PATCH 44/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
@ 2016-09-12 19:34   ` SF Markus Elfring
  2016-09-12 19:35   ` [PATCH 46/47] block-rbd: Rename jump labels in rbd_init() SF Markus Elfring
  2016-09-12 19:36   ` [PATCH 47/47] block-rbd: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:34 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:05:42 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b106c68..8802a06 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6454,14 +6454,14 @@ static int rbd_slab_init(void)
 	rbd_assert(!rbd_obj_request_cache);
 	rbd_obj_request_cache = KMEM_CACHE(rbd_obj_request, 0);
 	if (!rbd_obj_request_cache)
-		goto out_err;
+		goto destroy_cache;
 
 	rbd_assert(!rbd_segment_name_cache);
 	rbd_segment_name_cache = kmem_cache_create("rbd_segment_name",
 					CEPH_MAX_OID_NAME_LEN + 1, 1, 0, NULL);
 	if (rbd_segment_name_cache)
 		return 0;
-out_err:
+ destroy_cache:
 	kmem_cache_destroy(rbd_obj_request_cache);
 	rbd_obj_request_cache = NULL;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 46/47] block-rbd: Rename jump labels in rbd_init()
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (45 preceding siblings ...)
  2016-09-12 19:34   ` [PATCH 45/47] block-rbd: Rename a jump label in rbd_slab_init() SF Markus Elfring
@ 2016-09-12 19:35   ` SF Markus Elfring
  2016-09-12 19:36   ` [PATCH 47/47] block-rbd: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:35 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:06:54 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8802a06..8897815 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -6506,20 +6506,20 @@ static int __init rbd_init(void)
 	rbd_wq = alloc_workqueue(RBD_DRV_NAME, WQ_MEM_RECLAIM, 0);
 	if (!rbd_wq) {
 		rc = -ENOMEM;
-		goto err_out_slab;
+		goto exit_slab;
 	}
 
 	if (single_major) {
 		rbd_major = register_blkdev(0, RBD_DRV_NAME);
 		if (rbd_major < 0) {
 			rc = rbd_major;
-			goto err_out_wq;
+			goto destroy_workqueue;
 		}
 	}
 
 	rc = rbd_sysfs_init();
 	if (rc)
-		goto err_out_blkdev;
+		goto check_single;
 
 	if (single_major)
 		pr_info("loaded (major %d)\n", rbd_major);
@@ -6527,13 +6527,12 @@ static int __init rbd_init(void)
 		pr_info("loaded\n");
 
 	return 0;
-
-err_out_blkdev:
+ check_single:
 	if (single_major)
 		unregister_blkdev(rbd_major, RBD_DRV_NAME);
-err_out_wq:
+ destroy_workqueue:
 	destroy_workqueue(rbd_wq);
-err_out_slab:
+ exit_slab:
 	rbd_slab_exit();
 	return rc;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 47/47] block-rbd: Delete unwanted spaces behind usages of the sizeof operator
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
                     ` (46 preceding siblings ...)
  2016-09-12 19:35   ` [PATCH 46/47] block-rbd: Rename jump labels in rbd_init() SF Markus Elfring
@ 2016-09-12 19:36   ` SF Markus Elfring
  47 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 19:36 UTC (permalink / raw)
  To: ceph-devel, Alex Elder, Ilya Dryomov, Sage Weil
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 20:10:13 +0200

* Replace the source code "sizeof (" by "sizeof("
  according to the Linux coding style convention.

* Improve indentation at some places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/rbd.c | 112 ++++++++++++++++++++++++++++++----------------------
 1 file changed, 64 insertions(+), 48 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 8897815..4ed6983 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -101,7 +101,7 @@ static int atomic_dec_return_safe(atomic_t *v)
 
 #define RBD_SNAP_DEV_NAME_PREFIX	"snap_"
 #define RBD_MAX_SNAP_NAME_LEN	\
-			(NAME_MAX - (sizeof (RBD_SNAP_DEV_NAME_PREFIX) - 1))
+			(NAME_MAX - (sizeof(RBD_SNAP_DEV_NAME_PREFIX) - 1))
 
 #define RBD_MAX_SNAP_COUNT	510	/* allows max snapc to fit in 4KB */
 
@@ -110,7 +110,7 @@ static int atomic_dec_return_safe(atomic_t *v)
 #define	BAD_SNAP_INDEX	U32_MAX		/* invalid index into snap array */
 
 /* This allows a single page to hold an image name sent by OSD */
-#define RBD_IMAGE_NAME_LEN_MAX	(PAGE_SIZE - sizeof (__le32) - 1)
+#define RBD_IMAGE_NAME_LEN_MAX	(PAGE_SIZE - sizeof(__le32) - 1)
 #define RBD_IMAGE_ID_LEN_MAX	64
 
 #define RBD_OBJ_PREFIX_LEN_MAX	64
@@ -931,7 +931,7 @@ static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
 	u32 snap_count;
 
 	/* The header has to start with the magic rbd header text */
-	if (memcmp(&ondisk->text, RBD_HEADER_TEXT, sizeof (RBD_HEADER_TEXT)))
+	if (memcmp(&ondisk->text, RBD_HEADER_TEXT, sizeof(RBD_HEADER_TEXT)))
 		return false;
 
 	/* The bio layer requires at least sector-sized I/O */
@@ -941,7 +941,7 @@ static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
 
 	/* If we use u64 in a few spots we may be able to loosen this */
 
-	if (ondisk->options.order > 8 * sizeof (int) - 1)
+	if (ondisk->options.order > 8 * sizeof(int) - 1)
 		return false;
 
 	/*
@@ -949,15 +949,15 @@ static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
 	 * that limits the number of snapshots.
 	 */
 	snap_count = le32_to_cpu(ondisk->snap_count);
-	size = SIZE_MAX - sizeof (struct ceph_snap_context);
-	if (snap_count > size / sizeof (__le64))
+	size = SIZE_MAX - sizeof(struct ceph_snap_context);
+	if (snap_count > size / sizeof(__le64))
 		return false;
 
 	/*
 	 * Not only that, but the size of the entire the snapshot
 	 * header must also be representable in a size_t.
 	 */
-	size -= snap_count * sizeof (__le64);
+	size -= snap_count * sizeof(__le64);
 	if ((u64) size < le64_to_cpu(ondisk->snap_names_len))
 		return false;
 
@@ -987,7 +987,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
 		size_t len;
 
 		len = strnlen(ondisk->object_prefix,
-				sizeof (ondisk->object_prefix));
+			      sizeof(ondisk->object_prefix));
 		object_prefix = kmalloc(len + 1, GFP_KERNEL);
 		if (!object_prefix)
 			return -ENOMEM;
@@ -1121,7 +1121,7 @@ static u32 rbd_dev_snap_index(struct rbd_device *rbd_dev, u64 snap_id)
 	u64 *found;
 
 	found = bsearch(&snap_id, &snapc->snaps, snapc->num_snaps,
-				sizeof (snap_id), snapid_compare_reverse);
+			sizeof(snap_id), snapid_compare_reverse);
 
 	return found ? (u32)(found - &snapc->snaps[0]) : BAD_SNAP_INDEX;
 }
@@ -2906,7 +2906,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 	 *         le32 tv_nsec;
 	 *     } mtime;
 	 */
-	size = sizeof (__le64) + sizeof (__le32) + sizeof (__le32);
+	size = sizeof(__le64) + sizeof(__le32) + sizeof(__le32);
 	page_count = (u32)calc_pages_for(0, size);
 	pages = ceph_alloc_page_vector(page_count, GFP_KERNEL);
 	if (IS_ERR(pages))
@@ -4023,7 +4023,7 @@ static int rbd_obj_method_sync(struct rbd_device *rbd_dev,
 	if (outbound_size) {
 		struct ceph_pagelist *pagelist;
 
-		pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS);
+		pagelist = kmalloc(sizeof(*pagelist), GFP_NOFS);
 		if (!pagelist)
 			goto out;
 
@@ -4332,8 +4332,8 @@ static int rbd_dev_v1_header_info(struct rbd_device *rbd_dev)
 
 		kfree(ondisk);
 
-		size = sizeof (*ondisk);
-		size += snap_count * sizeof (struct rbd_image_snap_ondisk);
+		size = sizeof(*ondisk);
+		size += snap_count * sizeof(struct rbd_image_snap_ondisk);
 		size += names_size;
 		ondisk = kmalloc(size, GFP_KERNEL);
 		if (!ondisk)
@@ -4797,7 +4797,7 @@ static struct rbd_spec *rbd_spec_alloc(void)
 {
 	struct rbd_spec *spec;
 
-	spec = kzalloc(sizeof (*spec), GFP_KERNEL);
+	spec = kzalloc(sizeof(*spec), GFP_KERNEL);
 	if (!spec)
 		return NULL;
 
@@ -4961,14 +4961,18 @@ static int _rbd_dev_v2_snap_size(struct rbd_device *rbd_dev, u64 snap_id,
 		__le64 size;
 	} __attribute__ ((packed)) size_buf = { 0 };
 
-	ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_oid.name,
-				"rbd", "get_size",
-				&snapid, sizeof (snapid),
-				&size_buf, sizeof (size_buf));
+	ret = rbd_obj_method_sync(rbd_dev,
+				  rbd_dev->header_oid.name,
+				  "rbd",
+				  "get_size",
+				  &snapid,
+				  sizeof(snapid),
+				  &size_buf,
+				  sizeof(size_buf));
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
 		return ret;
-	if (ret < sizeof (size_buf))
+	if (ret < sizeof(size_buf))
 		return -ERANGE;
 
 	if (order) {
@@ -5036,14 +5040,18 @@ static int _rbd_dev_v2_snap_features(struct rbd_device *rbd_dev, u64 snap_id,
 	u64 unsup;
 	int ret;
 
-	ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_oid.name,
-				"rbd", "get_features",
-				&snapid, sizeof (snapid),
-				&features_buf, sizeof (features_buf));
+	ret = rbd_obj_method_sync(rbd_dev,
+				  rbd_dev->header_oid.name,
+				  "rbd",
+				  "get_features",
+				  &snapid,
+				  sizeof(snapid),
+				  &features_buf,
+				  sizeof(features_buf));
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
 		return ret;
-	if (ret < sizeof (features_buf))
+	if (ret < sizeof(features_buf))
 		return -ERANGE;
 
 	unsup = le64_to_cpu(features_buf.incompat) & ~RBD_FEATURES_SUPPORTED;
@@ -5087,10 +5095,10 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 	if (!parent_spec)
 		return -ENOMEM;
 
-	size = sizeof (__le64) +				/* pool_id */
-		sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX +	/* image_id */
-		sizeof (__le64) +				/* snap_id */
-		sizeof (__le64);				/* overlap */
+	size = sizeof(__le64) +				/* pool_id */
+	       sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX +	/* image_id */
+	       sizeof(__le64) +				/* snap_id */
+	       sizeof(__le64);				/* overlap */
 	reply_buf = kmalloc(size, GFP_KERNEL);
 	if (!reply_buf) {
 		ret = -ENOMEM;
@@ -5098,10 +5106,14 @@ static int rbd_dev_v2_parent_info(struct rbd_device *rbd_dev)
 	}
 
 	snapid = cpu_to_le64(rbd_dev->spec->snap_id);
-	ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_oid.name,
-				"rbd", "get_parent",
-				&snapid, sizeof (snapid),
-				reply_buf, size);
+	ret = rbd_obj_method_sync(rbd_dev,
+				  rbd_dev->header_oid.name,
+				  "rbd",
+				  "get_parent",
+				  &snapid,
+				  sizeof(snapid),
+				  reply_buf,
+				  size);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0)
 		goto free_buffer;
@@ -5194,7 +5206,7 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev)
 		__le64 stripe_unit;
 		__le64 stripe_count;
 	} __attribute__ ((packed)) striping_info_buf = { 0 };
-	size_t size = sizeof (striping_info_buf);
+	size_t size = sizeof(striping_info_buf);
 	void *p;
 	u64 obj_size;
 	u64 stripe_unit;
@@ -5253,7 +5265,7 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
 	rbd_assert(!rbd_dev->spec->image_name);
 
 	len = strlen(rbd_dev->spec->image_id);
-	image_id_size = sizeof (__le32) + len;
+	image_id_size = sizeof(__le32) + len;
 	image_id = kmalloc(image_id_size, GFP_KERNEL);
 	if (!image_id)
 		return NULL;
@@ -5262,7 +5274,7 @@ static char *rbd_dev_image_name(struct rbd_device *rbd_dev)
 	end = image_id + image_id_size;
 	ceph_encode_string(&p, end, rbd_dev->spec->image_id, (u32)len);
 
-	size = sizeof (__le32) + RBD_IMAGE_NAME_LEN_MAX;
+	size = sizeof(__le32) + RBD_IMAGE_NAME_LEN_MAX;
 	reply_buf = kmalloc(size, GFP_KERNEL);
 	if (!reply_buf)
 		goto free_id;
@@ -5443,8 +5455,8 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)
 	 * For now we have a fixed upper limit on the number we're
 	 * prepared to receive.
 	 */
-	size = sizeof (__le64) + sizeof (__le32) +
-			RBD_MAX_SNAP_COUNT * sizeof (__le64);
+	size = sizeof(__le64) + sizeof(__le32) +
+	       RBD_MAX_SNAP_COUNT * sizeof(__le64);
 	reply_buf = kzalloc(size, GFP_KERNEL);
 	if (!reply_buf)
 		return -ENOMEM;
@@ -5468,12 +5480,12 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev)
 	 * make sure the computed size of the snapshot context we
 	 * allocate is representable in a size_t.
 	 */
-	if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context))
-				 / sizeof (u64)) {
+	if (snap_count > (SIZE_MAX - sizeof(struct ceph_snap_context))
+			 / sizeof(u64)) {
 		ret = -EINVAL;
 		goto free_buffer;
 	}
-	if (!ceph_has_room(&p, end, snap_count * sizeof (__le64)))
+	if (!ceph_has_room(&p, end, snap_count * sizeof(__le64)))
 		goto free_buffer;
 	ret = 0;
 
@@ -5508,16 +5520,20 @@ static const char *rbd_dev_v2_snap_name(struct rbd_device *rbd_dev,
 	void *end;
 	char *snap_name;
 
-	size = sizeof (__le32) + RBD_MAX_SNAP_NAME_LEN;
+	size = sizeof(__le32) + RBD_MAX_SNAP_NAME_LEN;
 	reply_buf = kmalloc(size, GFP_KERNEL);
 	if (!reply_buf)
 		return ERR_PTR(-ENOMEM);
 
 	snapid = cpu_to_le64(snap_id);
-	ret = rbd_obj_method_sync(rbd_dev, rbd_dev->header_oid.name,
-				"rbd", "get_snapshot_name",
-				&snapid, sizeof (snapid),
-				reply_buf, size);
+	ret = rbd_obj_method_sync(rbd_dev,
+				  rbd_dev->header_oid.name,
+				  "rbd",
+				  "get_snapshot_name",
+				  &snapid,
+				  sizeof(snapid),
+				  reply_buf,
+				  size);
 	dout("%s: rbd_obj_method_sync returned %d\n", __func__, ret);
 	if (ret < 0) {
 		snap_name = ERR_PTR(ret);
@@ -5728,7 +5744,7 @@ static int rbd_add_parse_args(const char *buf,
 	len = next_token(&buf);
 	if (!len) {
 		buf = RBD_SNAP_HEAD_NAME; /* No snapshot supplied */
-		len = sizeof (RBD_SNAP_HEAD_NAME) - 1;
+		len = sizeof(RBD_SNAP_HEAD_NAME) - 1;
 	} else if (len > RBD_MAX_SNAP_NAME_LEN) {
 		ret = -ENAMETOOLONG;
 		goto free_options;
@@ -5741,7 +5757,7 @@ static int rbd_add_parse_args(const char *buf,
 
 	/* Initialize all rbd options to the defaults */
 
-	rbd_opts = kzalloc(sizeof (*rbd_opts), GFP_KERNEL);
+	rbd_opts = kzalloc(sizeof(*rbd_opts), GFP_KERNEL);
 	if (!rbd_opts)
 		goto status_indication;
 
@@ -5906,7 +5922,7 @@ static void rbd_dev_unprobe(struct rbd_device *rbd_dev)
 	kfree(header->snap_sizes);
 	kfree(header->snap_names);
 	kfree(header->object_prefix);
-	memset(header, 0, sizeof (*header));
+	memset(header, 0, sizeof(*header));
 }
 
 static int rbd_dev_v2_header_onetime(struct rbd_device *rbd_dev)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH] KVM: PPC: e500: Rename jump labels in kvmppc_e500_tlb_init()
  2016-09-11 23:25     ` Paul Mackerras
@ 2016-09-12 21:00       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-12 21:00 UTC (permalink / raw)
  To: Paul Mackerras, kvm, kvm-ppc, linuxppc-dev
  Cc: Alexander Graf, Benjamin Herrenschmidt, Michael Ellerman,
	Paolo Bonzini, Radim Krčmář,
	LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 12 Sep 2016 22:33:53 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

Thanks that five update steps could be integrated into the branch "kvm-ppc-next"
of another source code repository.


> With this I get a compile error:
> 
>   CC      arch/powerpc/kvm/e500_mmu.o
> /home/paulus/kernel/kvm/arch/powerpc/kvm/e500_mmu.c: In function ‘kvmppc_e500_tlb_init’:
> /home/paulus/kernel/kvm/arch/powerpc/kvm/e500_mmu.c:910:3: error: label ‘err’ used but not defined
>    goto err;
>    ^
> /home/paulus/kernel/kvm/scripts/Makefile.build:289: recipe for target 'arch/powerpc/kvm/e500_mmu.o' failed
> make[2]: *** [arch/powerpc/kvm/e500_mmu.o] Error 1

I overlooked a single goto statement there somehow.

I hope that you like my second approach for this function implementation better.


 arch/powerpc/kvm/e500_mmu.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c
index 0a2eeb1..ddbf8f0 100644
--- a/arch/powerpc/kvm/e500_mmu.c
+++ b/arch/powerpc/kvm/e500_mmu.c
@@ -907,7 +907,7 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 	struct kvm_vcpu *vcpu = &vcpu_e500->vcpu;
 
 	if (e500_mmu_host_init(vcpu_e500))
-		goto err;
+		goto free_vcpu;
 
 	vcpu_e500->gtlb_params[0].entries = KVM_E500_TLB0_SIZE;
 	vcpu_e500->gtlb_params[1].entries = KVM_E500_TLB1_SIZE;
@@ -933,26 +933,25 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500)
 					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[0])
-		goto err;
+		goto free_vcpu;
 
 	vcpu_e500->gtlb_priv[1] = kcalloc(vcpu_e500->gtlb_params[1].entries,
 					  sizeof(struct tlbe_ref),
 					  GFP_KERNEL);
 	if (!vcpu_e500->gtlb_priv[1])
-		goto err;
+		goto free_vcpu;
 
 	vcpu_e500->g2h_tlb1_map = kcalloc(vcpu_e500->gtlb_params[1].entries,
 					  sizeof(*vcpu_e500->g2h_tlb1_map),
 					  GFP_KERNEL);
 	if (!vcpu_e500->g2h_tlb1_map)
-		goto err;
+		goto free_vcpu;
 
 	vcpu_mmu_init(vcpu, vcpu_e500->gtlb_params);
 
 	kvmppc_recalc_tlb1map_range(vcpu_e500);
 	return 0;
-
-err:
+ free_vcpu:
 	free_gtlb(vcpu_e500);
 	return -1;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection
  2016-09-12 18:43   ` [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection SF Markus Elfring
@ 2016-09-13  7:58     ` Ilya Dryomov
  0 siblings, 0 replies; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  7:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 8:43 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Sep 2016 13:18:57 +0200
>
> The functions "ceph_put_snap_context" and "kfree" were called in a few
> cases by the function "rbd_header_from_disk" during error handling
> even if the passed variables contained a null pointer.
>
> Adjust jump targets according to the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index e406c27..f4212e1 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1001,7 +1001,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>         snap_count = le32_to_cpu(ondisk->snap_count);
>         snapc = ceph_create_snap_context(snap_count, GFP_KERNEL);
>         if (!snapc)
> -               goto out_err;
> +               goto free_prefix;
>         snapc->seq = le64_to_cpu(ondisk->snap_seq);
>         if (snap_count) {
>                 struct rbd_image_snap_ondisk *snaps;
> @@ -1013,14 +1013,14 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>                         goto out_2big;
>                 snap_names = kmalloc(snap_names_len, GFP_KERNEL);
>                 if (!snap_names)
> -                       goto out_err;
> +                       goto put_snap_context;
>
>                 /* ...as well as the array of their sizes. */
>                 snap_sizes = kmalloc_array(snap_count,
>                                            sizeof(*header->snap_sizes),
>                                            GFP_KERNEL);
>                 if (!snap_sizes)
> -                       goto out_err;
> +                       goto free_names;
>
>                 /*
>                  * Copy the names, and fill in each snapshot's id
> @@ -1066,10 +1066,12 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>         return 0;
>  out_2big:
>         ret = -EIO;
> -out_err:
>         kfree(snap_sizes);
> + free_names:
>         kfree(snap_names);
> + put_snap_context:
>         ceph_put_snap_context(snapc);
> + free_prefix:
>         kfree(object_prefix);
>
>         return ret;
> --
> 2.10.0
>

Please don't send patches that restructure error handling gotos unless
you've spotted a bug.  These patches are easy to get wrong, especially
when done in bulk, and require careful review.

Some people fancy a single sink label approach, others like separate
labels for each cleanup action - as long as the code is working, it's
a matter of taste.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-12 18:44   ` [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk() SF Markus Elfring
@ 2016-09-13  8:01     ` Ilya Dryomov
  2016-09-13  8:12       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  8:01 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 8:44 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Sep 2016 13:37:34 +0200
>
> Add a space character before a single jump label in this function
> according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index f4212e1..d61a066 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>         header->snap_sizes = snap_sizes;
>
>         return 0;
> -out_2big:
> + out_2big:
>         ret = -EIO;
>         kfree(snap_sizes);
>   free_names:
> --
> 2.10.0
>

Can you point where this current convention is documented?  Certainly
not in CodingStyle, AFAICT...

I know some people prefer a single space in there because it makes
"diff -p" work better, but nowadays with "git diff" this argument is
pretty moot.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id()
  2016-09-12 18:45   ` [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id() SF Markus Elfring
@ 2016-09-13  8:03     ` Ilya Dryomov
  2016-09-13  8:36       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  8:03 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 8:45 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Sep 2016 14:48:41 +0200
>
> * Pass the sizes for memory allocations to the corresponding functions
>   directly without storing the calculated values in an
>   intermediate variable.
>
> * Delete the local variable "size" which became unnecessary with
>   this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index d61a066..c1da844 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -5833,7 +5833,6 @@ again:
>  static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>  {
>         int ret;
> -       size_t size;
>         char *object_name;
>         void *response;
>         char *image_id;
> @@ -5854,17 +5853,16 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>          * First, see if the format 2 image id file exists, and if
>          * so, get the image's persistent id from it.
>          */
> -       size = sizeof (RBD_ID_PREFIX) + strlen(rbd_dev->spec->image_name);
> -       object_name = kmalloc(size, GFP_NOIO);
> +       object_name = kmalloc(sizeof(RBD_ID_PREFIX)
> +                             + strlen(rbd_dev->spec->image_name),
> +                             GFP_NOIO);
>         if (!object_name)
>                 return -ENOMEM;
>         sprintf(object_name, "%s%s", RBD_ID_PREFIX, rbd_dev->spec->image_name);
>         dout("rbd id object name is %s\n", object_name);
>
>         /* Response will be an encoded string, which includes a length */
> -
> -       size = sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX;
> -       response = kzalloc(size, GFP_NOIO);
> +       response = kzalloc(sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX, GFP_NOIO);
>         if (!response) {
>                 ret = -ENOMEM;
>                 goto out;
> --
> 2.10.0
>

How is this any better?  If anything, it makes the first kmalloc() call
slightly less readable.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args()
  2016-09-12 18:47   ` [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args() SF Markus Elfring
@ 2016-09-13  8:05     ` Ilya Dryomov
  0 siblings, 0 replies; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  8:05 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 8:47 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Sep 2016 15:20:48 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 24 ++++++++++++------------
>  1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index a6d9a06..dd4da1f 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -5709,27 +5709,27 @@ static int rbd_add_parse_args(const char *buf,
>                 return -ENOMEM;
>         if (!*options) {
>                 rbd_warn(NULL, "no options provided");
> -               goto out_err;
> +               goto free_options;
>         }
>
>         spec = rbd_spec_alloc();
>         if (!spec)
> -               goto out_mem;
> +               goto status_indication;
>
>         spec->pool_name = dup_token(&buf, NULL);
>         if (!spec->pool_name)
> -               goto out_mem;
> +               goto status_indication;
>         if (!*spec->pool_name) {
>                 rbd_warn(NULL, "no pool name provided");
> -               goto out_err;
> +               goto free_options;
>         }
>
>         spec->image_name = dup_token(&buf, NULL);
>         if (!spec->image_name)
> -               goto out_mem;
> +               goto status_indication;
>         if (!*spec->image_name) {
>                 rbd_warn(NULL, "no image name provided");
> -               goto out_err;
> +               goto free_options;
>         }
>
>         /*
> @@ -5742,11 +5742,11 @@ static int rbd_add_parse_args(const char *buf,
>                 len = sizeof (RBD_SNAP_HEAD_NAME) - 1;
>         } else if (len > RBD_MAX_SNAP_NAME_LEN) {
>                 ret = -ENAMETOOLONG;
> -               goto out_err;
> +               goto free_options;
>         }
>         snap_name = kmemdup(buf, len + 1, GFP_KERNEL);
>         if (!snap_name)
> -               goto out_mem;
> +               goto status_indication;
>         *(snap_name + len) = '\0';
>         spec->snap_name = snap_name;
>
> @@ -5754,7 +5754,7 @@ static int rbd_add_parse_args(const char *buf,
>
>         rbd_opts = kzalloc(sizeof (*rbd_opts), GFP_KERNEL);
>         if (!rbd_opts)
> -               goto out_mem;
> +               goto status_indication;
>
>         rbd_opts->read_only = RBD_READ_ONLY_DEFAULT;
>         rbd_opts->queue_depth = RBD_QUEUE_DEPTH_DEFAULT;
> @@ -5764,7 +5764,7 @@ static int rbd_add_parse_args(const char *buf,
>                                         parse_rbd_opts_token, rbd_opts);
>         if (IS_ERR(copts)) {
>                 ret = PTR_ERR(copts);
> -               goto out_err;
> +               goto free_options;
>         }
>         kfree(options);
>
> @@ -5773,9 +5773,9 @@ static int rbd_add_parse_args(const char *buf,
>         *rbd_spec = spec;
>
>         return 0;
> -out_mem:
> + status_indication:
>         ret = -ENOMEM;
> -out_err:
> + free_options:
>         kfree(rbd_opts);
>         rbd_spec_put(spec);
>         kfree(options);
> --
> 2.10.0

For a ret = -ENOMEM; statement, your status_indication label actually
conveys less information than out_mem did.  Don't waste everybody's
time by sending these pointless rename patches, please.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create()
  2016-09-12 19:00   ` [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create() SF Markus Elfring
@ 2016-09-13  8:07     ` Ilya Dryomov
  0 siblings, 0 replies; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  8:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 9:00 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 12 Sep 2016 18:12:39 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 6acddc53..262805a 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -4930,23 +4930,22 @@ static struct rbd_device *rbd_dev_create(struct rbd_client *rbdc,
>                                          minor_to_rbd_dev_id(1 << MINORBITS),
>                                          GFP_KERNEL);
>         if (rbd_dev->dev_id < 0)
> -               goto fail_rbd_dev;
> +               goto free_device;
>
>         sprintf(rbd_dev->name, RBD_DRV_NAME "%d", rbd_dev->dev_id);
>         rbd_dev->task_wq = alloc_ordered_workqueue("%s-tasks", WQ_MEM_RECLAIM,
>                                                    rbd_dev->name);
>         if (!rbd_dev->task_wq)
> -               goto fail_dev_id;
> +               goto remove_id;
>
>         /* we have a ref from do_rbd_add() */
>         __module_get(THIS_MODULE);
>
>         dout("%s rbd_dev %p dev_id %d\n", __func__, rbd_dev, rbd_dev->dev_id);
>         return rbd_dev;
> -
> -fail_dev_id:
> + remove_id:
>         ida_simple_remove(&rbd_dev_id_ida, rbd_dev->dev_id);
> -fail_rbd_dev:
> + free_device:
>         rbd_dev_free(rbd_dev);
>         return NULL;
>  }
> --
> 2.10.0
>

Really?  I mean out_err -> free_device I can understand, but this?

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit()
  2016-09-12 19:14   ` [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit() SF Markus Elfring
@ 2016-09-13  8:10     ` Ilya Dryomov
  0 siblings, 0 replies; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  8:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 9:14 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 12 Sep 2016 19:44:30 +0200
>
> Adjust a jump target so that a duplicate check can then be avoided
> at the end.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/rbd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 17bdc21..66801ec 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -2920,7 +2920,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
>         stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0,
>                                                         OBJ_REQUEST_PAGES);
>         if (!stat_request)
> -               goto out;
> +               goto put_request;
>
>         rbd_obj_request_get(obj_request);
>         stat_request->obj_request = obj_request;
> @@ -2932,7 +2932,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
>         stat_request->osd_req = rbd_osd_req_create(rbd_dev, OBJ_OP_READ, 1,
>                                                    stat_request);
>         if (!stat_request->osd_req)
> -               goto out;
> +               goto put_request;
>         stat_request->callback = rbd_img_obj_exists_callback;
>
>         osd_req_op_init(stat_request->osd_req, 0, CEPH_OSD_OP_STAT, 0);
> @@ -2942,8 +2942,8 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
>
>         osdc = &rbd_dev->rbd_client->client->osdc;
>         ret = rbd_obj_request_submit(osdc, stat_request);
> -out:
>         if (ret)
> + put_request:
>                 rbd_obj_request_put(obj_request);
>
>         return ret;
> --
> 2.10.0

Don't do this.  goto into an if block is rarely a good idea, more so
when you are attempting to micro-optimize a very cold error path.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13  8:01     ` Ilya Dryomov
@ 2016-09-13  8:12       ` SF Markus Elfring
  2016-09-13  9:16         ` Ilya Dryomov
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13  8:12 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: ceph-devel, Alex Elder, Sage Weil, LKML, kernel-janitors, Julia Lawall

>> @@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>>         header->snap_sizes = snap_sizes;
>>
>>         return 0;
>> -out_2big:
>> + out_2big:
>>         ret = -EIO;
>>         kfree(snap_sizes);
>>   free_names:
> Can you point where this current convention is documented?

Yes.
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51

Do you find the software update "CodingStyle: Clarify and complete chapter 7" interesting?


> Certainly not in CodingStyle, AFAICT...

I suggest to look at the current version once more.


> I know some people prefer a single space in there because it makes
> "diff -p" work better, but nowadays with "git diff" this argument is
> pretty moot.

Would you like to discuss the corresponding software evolution a bit more?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id()
  2016-09-13  8:03     ` Ilya Dryomov
@ 2016-09-13  8:36       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13  8:36 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: ceph-devel, Alex Elder, Sage Weil, LKML, kernel-janitors, Julia Lawall

>> @@ -5833,7 +5833,6 @@ again:
>>  static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>>  {
>>         int ret;
>> -       size_t size;
>>         char *object_name;
>>         void *response;
>>         char *image_id;
>> @@ -5854,17 +5853,16 @@ static int rbd_dev_image_id(struct rbd_device *rbd_dev)
>>          * First, see if the format 2 image id file exists, and if
>>          * so, get the image's persistent id from it.
>>          */
>> -       size = sizeof (RBD_ID_PREFIX) + strlen(rbd_dev->spec->image_name);
>> -       object_name = kmalloc(size, GFP_NOIO);
>> +       object_name = kmalloc(sizeof(RBD_ID_PREFIX)
>> +                             + strlen(rbd_dev->spec->image_name),
>> +                             GFP_NOIO);
>>         if (!object_name)
>>                 return -ENOMEM;
>>         sprintf(object_name, "%s%s", RBD_ID_PREFIX, rbd_dev->spec->image_name);
>>         dout("rbd id object name is %s\n", object_name);
>>
>>         /* Response will be an encoded string, which includes a length */
>> -
>> -       size = sizeof (__le32) + RBD_IMAGE_ID_LEN_MAX;
>> -       response = kzalloc(size, GFP_NOIO);
>> +       response = kzalloc(sizeof(__le32) + RBD_IMAGE_ID_LEN_MAX, GFP_NOIO);
>>         if (!response) {
>>                 ret = -ENOMEM;
>>                 goto out;
> How is this any better?

I find it useful to omit the local variable "size" here.


> If anything, it makes the first kmalloc() call slightly less readable.

I got an other impression. The refactored function call did not fit into a single line
because of a well-known length limitation.

Does the kzalloc() call look a bit nicer for you now?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13  8:12       ` SF Markus Elfring
@ 2016-09-13  9:16         ` Ilya Dryomov
  2016-09-13 14:36           ` Jean Delvare
  0 siblings, 1 reply; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13  9:16 UTC (permalink / raw)
  To: SF Markus Elfring, Jonathan Corbet
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall, Jean Delvare

On Tue, Sep 13, 2016 at 10:12 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> @@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>>>         header->snap_sizes = snap_sizes;
>>>
>>>         return 0;
>>> -out_2big:
>>> + out_2big:
>>>         ret = -EIO;
>>>         kfree(snap_sizes);
>>>   free_names:
> …
>> Can you point where this current convention is documented?
>
> Yes.
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51

Huh.  That patch is not in Linus' tree.

>
> Do you find the software update "CodingStyle: Clarify and complete chapter 7" interesting?
>
>
>> Certainly not in CodingStyle, AFAICT...
>
> I suggest to look at the current version once more.
>
>
>> I know some people prefer a single space in there because it makes
>> "diff -p" work better, but nowadays with "git diff" this argument is
>> pretty moot.
>
> Would you like to discuss the corresponding software evolution a bit more?

Jon, could you please yank 865a1caa4b6b ("CodingStyle: Clarify and
complete chapter 7") from your linux-next branch or at least change "It
is advised to indent labels" to something less stronger?  It hasn't
even hit mainline yet and we are already getting spammed.

Looks like 9 out of 10 labels are not indented

$ git grep '^[a-z0-9]\+:' -- *.c | wc -l
27945
$ git grep '^ [a-z0-9]\+:' -- *.c | wc -l
2925

so I'd say that's a bad advise as far as consistency goes, and the
"diff -p" argument is pretty moot nowadays.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] block-virtio: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (78 preceding siblings ...)
  2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-13 12:10 ` SF Markus Elfring
  2016-09-13 12:12   ` [PATCH 1/4] virtio_blk: Use kmalloc_array() in init_vq() SF Markus Elfring
                     ` (3 more replies)
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
                   ` (15 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 12:10 UTC (permalink / raw)
  To: virtualization, Michael S. Tsirkin; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 14:05:05 +0200

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

Markus Elfring (4):
  Use kmalloc_array() in init_vq()
  Less function calls in init_vq() after error detection
  Delete an unnecessary initialisation in init_vq()
  Rename a jump label in virtblk_get_id()

 drivers/block/virtio_blk.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] virtio_blk: Use kmalloc_array() in init_vq()
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-13 12:12   ` SF Markus Elfring
  2016-09-13 12:13   ` [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 12:12 UTC (permalink / raw)
  To: virtualization, Michael S. Tsirkin; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 11:32:22 +0200

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/virtio_blk.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 93b1aaa..6553eb7 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -390,13 +390,13 @@ static int init_vq(struct virtio_blk *vblk)
 	if (err)
 		num_vqs = 1;
 
-	vblk->vqs = kmalloc(sizeof(*vblk->vqs) * num_vqs, GFP_KERNEL);
+	vblk->vqs = kmalloc_array(num_vqs, sizeof(*vblk->vqs), GFP_KERNEL);
 	if (!vblk->vqs)
 		return -ENOMEM;
 
-	names = kmalloc(sizeof(*names) * num_vqs, GFP_KERNEL);
-	callbacks = kmalloc(sizeof(*callbacks) * num_vqs, GFP_KERNEL);
-	vqs = kmalloc(sizeof(*vqs) * num_vqs, GFP_KERNEL);
+	names = kmalloc_array(num_vqs, sizeof(*names), GFP_KERNEL);
+	callbacks = kmalloc_array(num_vqs, sizeof(*callbacks), GFP_KERNEL);
+	vqs = kmalloc_array(num_vqs, sizeof(*vqs), GFP_KERNEL);
 	if (!names || !callbacks || !vqs) {
 		err = -ENOMEM;
 		goto out;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-13 12:12   ` [PATCH 1/4] virtio_blk: Use kmalloc_array() in init_vq() SF Markus Elfring
@ 2016-09-13 12:13   ` SF Markus Elfring
  2016-09-13 12:54     ` Christian Borntraeger
  2016-09-13 12:14   ` [PATCH 3/4] virtio_blk: Delete an unnecessary initialisation in init_vq() SF Markus Elfring
  2016-09-13 12:15   ` [PATCH 4/4] virtio_blk: Rename a jump label in virtblk_get_id() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 12:13 UTC (permalink / raw)
  To: virtualization, Michael S. Tsirkin; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 13:20:44 +0200

The kfree() function was called in up to three cases
by the init_vq() function during error handling even if
the passed variable contained a null pointer.

* Split a condition check for memory allocation failures.

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/virtio_blk.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 6553eb7..d28dbcf 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -395,11 +395,21 @@ static int init_vq(struct virtio_blk *vblk)
 		return -ENOMEM;
 
 	names = kmalloc_array(num_vqs, sizeof(*names), GFP_KERNEL);
+	if (!names) {
+		err = -ENOMEM;
+		goto free_vblk_vqs;
+	}
+
 	callbacks = kmalloc_array(num_vqs, sizeof(*callbacks), GFP_KERNEL);
+	if (!callbacks) {
+		err = -ENOMEM;
+		goto free_names;
+	}
+
 	vqs = kmalloc_array(num_vqs, sizeof(*vqs), GFP_KERNEL);
-	if (!names || !callbacks || !vqs) {
+	if (!vqs) {
 		err = -ENOMEM;
-		goto out;
+		goto free_callbacks;
 	}
 
 	for (i = 0; i < num_vqs; i++) {
@@ -411,19 +421,21 @@ static int init_vq(struct virtio_blk *vblk)
 	/* Discover virtqueues and write information to configuration.  */
 	err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names);
 	if (err)
-		goto out;
+		goto free_vqs;
 
 	for (i = 0; i < num_vqs; i++) {
 		spin_lock_init(&vblk->vqs[i].lock);
 		vblk->vqs[i].vq = vqs[i];
 	}
 	vblk->num_vqs = num_vqs;
-
-out:
+ free_vqs:
 	kfree(vqs);
+ free_callbacks:
 	kfree(callbacks);
+ free_names:
 	kfree(names);
 	if (err)
+ free_vblk_vqs:
 		kfree(vblk->vqs);
 	return err;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] virtio_blk: Delete an unnecessary initialisation in init_vq()
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-13 12:12   ` [PATCH 1/4] virtio_blk: Use kmalloc_array() in init_vq() SF Markus Elfring
  2016-09-13 12:13   ` [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection SF Markus Elfring
@ 2016-09-13 12:14   ` SF Markus Elfring
  2016-09-13 12:15   ` [PATCH 4/4] virtio_blk: Rename a jump label in virtblk_get_id() SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 12:14 UTC (permalink / raw)
  To: virtualization, Michael S. Tsirkin; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 13:43:50 +0200

The local variable "err" will be set to an appropriate value
by a following statement.
Thus omit the explicit initialisation at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/virtio_blk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index d28dbcf..696f452 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -376,7 +376,7 @@ static void virtblk_config_changed(struct virtio_device *vdev)
 
 static int init_vq(struct virtio_blk *vblk)
 {
-	int err = 0;
+	int err;
 	int i;
 	vq_callback_t **callbacks;
 	const char **names;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] virtio_blk: Rename a jump label in virtblk_get_id()
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-13 12:14   ` [PATCH 3/4] virtio_blk: Delete an unnecessary initialisation in init_vq() SF Markus Elfring
@ 2016-09-13 12:15   ` SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 12:15 UTC (permalink / raw)
  To: virtualization, Michael S. Tsirkin; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 13:50:56 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/block/virtio_blk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 696f452..fef2bd0 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -247,10 +247,10 @@ static int virtblk_get_id(struct gendisk *disk, char *id_str)
 
 	err = blk_rq_map_kern(q, req, id_str, VIRTIO_BLK_ID_BYTES, GFP_KERNEL);
 	if (err)
-		goto out;
+		goto put_request;
 
 	err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false);
-out:
+ put_request:
 	blk_put_request(req);
 	return err;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 12:13   ` [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection SF Markus Elfring
@ 2016-09-13 12:54     ` Christian Borntraeger
  2016-09-13 14:33       ` SF Markus Elfring
  2016-09-13 17:30       ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Christian Borntraeger @ 2016-09-13 12:54 UTC (permalink / raw)
  To: SF Markus Elfring, virtualization, Michael S. Tsirkin
  Cc: Julia Lawall, kernel-janitors, LKML

On 09/13/2016 02:13 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 13 Sep 2016 13:20:44 +0200
> 
> The kfree() function was called in up to three cases
> by the init_vq() function during error handling even if
> the passed variable contained a null pointer.
> 
> * Split a condition check for memory allocation failures.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/block/virtio_blk.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)

Can't you see from this diffstat that the patch actually seems to makes
the code more complex?
In addition, please have a look at commit 347a529398e8e723338cca5d8a8ae2d9e7e93448
    virtio_blk: Fix a slient kernel panic

which did the opposite of your patch. And in fact it fixed a bug. Quite obviously
multiple labels are harder to read and harder to get right. For error handling with
just kfree one label is just the right thing to.

> 
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 6553eb7..d28dbcf 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -395,11 +395,21 @@ static int init_vq(struct virtio_blk *vblk)
>  		return -ENOMEM;
> 
>  	names = kmalloc_array(num_vqs, sizeof(*names), GFP_KERNEL);
> +	if (!names) {
> +		err = -ENOMEM;
> +		goto free_vblk_vqs;
> +	}
> +
>  	callbacks = kmalloc_array(num_vqs, sizeof(*callbacks), GFP_KERNEL);
> +	if (!callbacks) {
> +		err = -ENOMEM;
> +		goto free_names;
> +	}
> +
>  	vqs = kmalloc_array(num_vqs, sizeof(*vqs), GFP_KERNEL);
> -	if (!names || !callbacks || !vqs) {
> +	if (!vqs) {
>  		err = -ENOMEM;
> -		goto out;
> +		goto free_callbacks;
>  	}
> 
>  	for (i = 0; i < num_vqs; i++) {
> @@ -411,19 +421,21 @@ static int init_vq(struct virtio_blk *vblk)
>  	/* Discover virtqueues and write information to configuration.  */
>  	err = vdev->config->find_vqs(vdev, num_vqs, vqs, callbacks, names);
>  	if (err)
> -		goto out;
> +		goto free_vqs;
> 
>  	for (i = 0; i < num_vqs; i++) {
>  		spin_lock_init(&vblk->vqs[i].lock);
>  		vblk->vqs[i].vq = vqs[i];
>  	}
>  	vblk->num_vqs = num_vqs;
> -
> -out:
> + free_vqs:
>  	kfree(vqs);
> + free_callbacks:
>  	kfree(callbacks);
> + free_names:
>  	kfree(names);
>  	if (err)
> + free_vblk_vqs:
>  		kfree(vblk->vqs);
>  	return err;
>  }
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 12:54     ` Christian Borntraeger
@ 2016-09-13 14:33       ` SF Markus Elfring
  2016-09-13 17:30       ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 14:33 UTC (permalink / raw)
  To: Christian Bornträger, virtualization, Michael S. Tsirkin
  Cc: Julia Lawall, kernel-janitors, LKML, linux-doc, Minfei Huang

>>  drivers/block/virtio_blk.c | 22 +++++++++++++++++-----
>>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> Can't you see from this diffstat that the patch actually seems to makes
> the code more complex?

I find that the repeated usage of a bit more error handling code is almost
unavoidable if you would like to handle allocation failures more directly
as I dared to propose again here.


> In addition, please have a look at commit 347a529398e8e723338cca5d8a8ae2d9e7e93448
>     virtio_blk: Fix a slient kernel panic
> 
> which did the opposite of your patch.

This software update adjusted also the jump targets. This approach
triggered another update suggestion (in addition to improvements around
the function "kmalloc_array").

Such a software development shows different views on the implementation
for correct exception handling. I am not so "silent" on this development topic
for years.


> And in fact it fixed a bug.

I get the impression from Minfei's contribution that the statement "err = -ENOMEM;"
was added behind memory allocations.
It was also chosen to restructure this function implementation so that
the single label "out" was used there for a while.

* Is this detail worth for another look?

* How does this name selection fit to the current Linux coding style convention?


> Quite obviously multiple labels are harder to read

I do not agree agree completely to your opinion.


> and harder to get right.

These identifiers can generate their own kind of software development
challenges as usual.


> For error handling with just kfree one label is just the right thing to.

This approach can look convenient at first glance.
Does the correctness aspect need any further considerations?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13  9:16         ` Ilya Dryomov
@ 2016-09-13 14:36           ` Jean Delvare
  2016-09-13 15:30             ` Ilya Dryomov
  0 siblings, 1 reply; 1373+ messages in thread
From: Jean Delvare @ 2016-09-13 14:36 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Jonathan Corbet, Ceph Development, Alex Elder, Sage Weil, LKML,
	kernel-janitors, Julia Lawall, Andrew Morton

Hi Ilya,

Thanks for adding me.

On Tue, 13 Sep 2016 11:16:13 +0200, Ilya Dryomov wrote:
> On Tue, Sep 13, 2016 at 10:12 AM, SF Markus Elfring
> <elfring@users.sourceforge.net> wrote:
> >>> @@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
> >>>         header->snap_sizes = snap_sizes;
> >>>
> >>>         return 0;
> >>> -out_2big:
> >>> + out_2big:
> >>>         ret = -EIO;
> >>>         kfree(snap_sizes);
> >>>   free_names:
> > …
> >> Can you point where this current convention is documented?
> >
> > Yes.
> > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51
> 
> Huh.  That patch is not in Linus' tree.
> 
> >
> > Do you find the software update "CodingStyle: Clarify and complete chapter 7" interesting?
> >
> >
> >> Certainly not in CodingStyle, AFAICT...
> >
> > I suggest to look at the current version once more.
> >
> >
> >> I know some people prefer a single space in there because it makes
> >> "diff -p" work better, but nowadays with "git diff" this argument is
> >> pretty moot.
> >
> > Would you like to discuss the corresponding software evolution a bit more?
> 
> Jon, could you please yank 865a1caa4b6b ("CodingStyle: Clarify and
> complete chapter 7") from your linux-next branch or at least change "It
> is advised to indent labels" to something less stronger?  It hasn't
> even hit mainline yet and we are already getting spammed.

The problem isn't the documentation update nor whether you or me like a
space before labels or not. The problem is Markus Elfring. The guy just
spend his time flooding maintainers with unneeded changes they never
asked for. Ignore him and you'll be much better. If he was not flooding
you with this, he would find something else :-(

When I wrote "It is advised to indent labels with one space", I never
meant that all the existing code should be converted that way. I
expressed a preference, and provided a rationale for this preference.
After that, an advice is just that: an advice.

> Looks like 9 out of 10 labels are not indented
> 
> $ git grep '^[a-z0-9]\+:' -- *.c | wc -l
> 27945
> $ git grep '^ [a-z0-9]\+:' -- *.c | wc -l
> 2925

Your regexps are wrong ;-) but the ratio is correct.

> so I'd say that's a bad advise as far as consistency goes, and the
> "diff -p" argument is pretty moot nowadays.

It wasn't moot when I sent the documentation update patch. Or why would
you think it was? "git diff", by default, behaves exactly the same as
"diff -p" with regards to unindented labels (i.e. it doesn't handle
them properly.)

However, since then the issue was discussed somewhere else:
https://lkml.org/lkml/2016/9/5/214

As you can see, alternatives to indenting labels with one space were
found. Therefore you will soon be correct saying "the diff -p argument
is pretty moot." As soon as my patch hits mainline, actually. Which
shouldn't take too long as Andrew Morton picked it 4 days ago.

Once this happens, I'm fine with CodingStyle being updated again to
reflect the current situation.

Hope it clarifies,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13 14:36           ` Jean Delvare
@ 2016-09-13 15:30             ` Ilya Dryomov
  2016-09-13 16:50               ` Jean Delvare
  0 siblings, 1 reply; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13 15:30 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Jonathan Corbet, Ceph Development, Alex Elder, Sage Weil, LKML,
	kernel-janitors, Julia Lawall, Andrew Morton

On Tue, Sep 13, 2016 at 4:36 PM, Jean Delvare <jdelvare@suse.de> wrote:
> Hi Ilya,
>
> Thanks for adding me.
>
> On Tue, 13 Sep 2016 11:16:13 +0200, Ilya Dryomov wrote:
>> On Tue, Sep 13, 2016 at 10:12 AM, SF Markus Elfring
>> <elfring@users.sourceforge.net> wrote:
>> >>> @@ -1064,7 +1064,7 @@ static int rbd_header_from_disk(struct rbd_device *rbd_dev,
>> >>>         header->snap_sizes = snap_sizes;
>> >>>
>> >>>         return 0;
>> >>> -out_2big:
>> >>> + out_2big:
>> >>>         ret = -EIO;
>> >>>         kfree(snap_sizes);
>> >>>   free_names:
>> > …
>> >> Can you point where this current convention is documented?
>> >
>> > Yes.
>> > https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=865a1caa4b6b886babdd9d67e7c3608be4567a51
>>
>> Huh.  That patch is not in Linus' tree.
>>
>> >
>> > Do you find the software update "CodingStyle: Clarify and complete chapter 7" interesting?
>> >
>> >
>> >> Certainly not in CodingStyle, AFAICT...
>> >
>> > I suggest to look at the current version once more.
>> >
>> >
>> >> I know some people prefer a single space in there because it makes
>> >> "diff -p" work better, but nowadays with "git diff" this argument is
>> >> pretty moot.
>> >
>> > Would you like to discuss the corresponding software evolution a bit more?
>>
>> Jon, could you please yank 865a1caa4b6b ("CodingStyle: Clarify and
>> complete chapter 7") from your linux-next branch or at least change "It
>> is advised to indent labels" to something less stronger?  It hasn't
>> even hit mainline yet and we are already getting spammed.
>
> The problem isn't the documentation update nor whether you or me like a
> space before labels or not. The problem is Markus Elfring. The guy just
> spend his time flooding maintainers with unneeded changes they never
> asked for. Ignore him and you'll be much better. If he was not flooding
> you with this, he would find something else :-(
>
> When I wrote "It is advised to indent labels with one space", I never
> meant that all the existing code should be converted that way. I

Hi Jean,

That much is clear, however ...

> expressed a preference, and provided a rationale for this preference.
> After that, an advice is just that: an advice.
>
>> Looks like 9 out of 10 labels are not indented
>>
>> $ git grep '^[a-z0-9]\+:' -- *.c | wc -l
>> 27945
>> $ git grep '^ [a-z0-9]\+:' -- *.c | wc -l
>> 2925
>
> Your regexps are wrong ;-) but the ratio is correct.

... one of the main points of any coding style is consistency.  When
someone new wanting to submit say a new driver opens CodingStyle and
sees "It is advised to indent labels ...", they might start indenting
labels in their code and advise others to do the same.  Given the 9/10
existing ratio, that advice is wrong.  If I wanted to clarify the
situation, I'd have gone with "one space indented labels are also
acceptable" or so.  The example you've re-indented dates back to 2.6.4
times...

>
>> so I'd say that's a bad advise as far as consistency goes, and the
>> "diff -p" argument is pretty moot nowadays.
>
> It wasn't moot when I sent the documentation update patch. Or why would
> you think it was? "git diff", by default, behaves exactly the same as
> "diff -p" with regards to unindented labels (i.e. it doesn't handle
> them properly.)

The git diff xfuncname incantation is a few years old now.  git diff
also works on regular files, BTW.

>
> However, since then the issue was discussed somewhere else:
> https://lkml.org/lkml/2016/9/5/214
>
> As you can see, alternatives to indenting labels with one space were
> found. Therefore you will soon be correct saying "the diff -p argument
> is pretty moot." As soon as my patch hits mainline, actually. Which
> shouldn't take too long as Andrew Morton picked it 4 days ago.
>
> Once this happens, I'm fine with CodingStyle being updated again to
> reflect the current situation.

I'm not sure which patch you are talking about - the message you linked
is not a patch and it's impossible to follow large threads on lkml.org.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13 15:30             ` Ilya Dryomov
@ 2016-09-13 16:50               ` Jean Delvare
  2016-09-13 18:31                 ` Ilya Dryomov
  0 siblings, 1 reply; 1373+ messages in thread
From: Jean Delvare @ 2016-09-13 16:50 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Jonathan Corbet, Ceph Development, Alex Elder, Sage Weil, LKML,
	kernel-janitors, Julia Lawall, Andrew Morton

On Tue, 13 Sep 2016 17:30:33 +0200, Ilya Dryomov wrote:
> On Tue, Sep 13, 2016 at 4:36 PM, Jean Delvare <jdelvare@suse.de> wrote:
> > On Tue, 13 Sep 2016 11:16:13 +0200, Ilya Dryomov wrote:
> >> Jon, could you please yank 865a1caa4b6b ("CodingStyle: Clarify and
> >> complete chapter 7") from your linux-next branch or at least change "It
> >> is advised to indent labels" to something less stronger?  It hasn't
> >> even hit mainline yet and we are already getting spammed.
> >
> > The problem isn't the documentation update nor whether you or me like a
> > space before labels or not. The problem is Markus Elfring. The guy just
> > spend his time flooding maintainers with unneeded changes they never
> > asked for. Ignore him and you'll be much better. If he was not flooding
> > you with this, he would find something else :-(
> >
> > When I wrote "It is advised to indent labels with one space", I never
> > meant that all the existing code should be converted that way. I
> 
> Hi Jean,
> 
> That much is clear, however ...
> 
> > expressed a preference, and provided a rationale for this preference.
> > After that, an advice is just that: an advice.
> >
> >> Looks like 9 out of 10 labels are not indented
> >>
> >> $ git grep '^[a-z0-9]\+:' -- *.c | wc -l
> >> 27945
> >> $ git grep '^ [a-z0-9]\+:' -- *.c | wc -l
> >> 2925
> >
> > Your regexps are wrong ;-) but the ratio is correct.
> 
> ... one of the main points of any coding style is consistency.  When
> someone new wanting to submit say a new driver opens CodingStyle and
> sees "It is advised to indent labels ...", they might start indenting
> labels in their code and advise others to do the same.  Given the 9/10
> existing ratio, that advice is wrong.

Or you could read the thread I pointed you to, where I explain why this
reasoning is wrong.

> If I wanted to clarify the
> situation, I'd have gone with "one space indented labels are also
> acceptable" or so.  The example you've re-indented dates back to 2.6.4
> times...

I can't see how this is relevant.

> >> so I'd say that's a bad advise as far as consistency goes, and the
> >> "diff -p" argument is pretty moot nowadays.
> >
> > It wasn't moot when I sent the documentation update patch. Or why would
> > you think it was? "git diff", by default, behaves exactly the same as
> > "diff -p" with regards to unindented labels (i.e. it doesn't handle
> > them properly.)
> 
> The git diff xfuncname incantation is a few years old now.

It doesn't help if a majority of developers don't know about it (as was
my case until last week), and the project itself doesn't carry the
required configuration bits to make it work out of the box (which
hopefully will be the case soon, see below.)

> git diff also works on regular files, BTW.

I have no idea what you mean here, sorry.

> > However, since then the issue was discussed somewhere else:
> > https://lkml.org/lkml/2016/9/5/214
> >
> > As you can see, alternatives to indenting labels with one space were
> > found. Therefore you will soon be correct saying "the diff -p argument
> > is pretty moot." As soon as my patch hits mainline, actually. Which
> > shouldn't take too long as Andrew Morton picked it 4 days ago.
> >
> > Once this happens, I'm fine with CodingStyle being updated again to
> > reflect the current situation.
> 
> I'm not sure which patch you are talking about - the message you linked
> is not a patch and it's impossible to follow large threads on lkml.org.

The solution was in this thread, which I expected you to read. The
patch proper was sent separately:

http://marc.info/?l=linux-kernel&m=147325166209844&w=2

It uses the git diff xfuncname feature you mentioned above. To be
honest I'm surprised it isn't the git default, it seems odd to have so
many diff drivers included in git and not enable them on obvious file
extensions. Oh well.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 12:54     ` Christian Borntraeger
  2016-09-13 14:33       ` SF Markus Elfring
@ 2016-09-13 17:30       ` SF Markus Elfring
  2016-09-13 18:24         ` Christian Borntraeger
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 17:30 UTC (permalink / raw)
  To: Christian Bornträger, virtualization, Michael S. Tsirkin,
	Minfei Huang, Cornelia Huck, Stefan Hajnoczi
  Cc: Julia Lawall, kernel-janitors, LKML, Chao Fan

> In addition, please have a look at commit 347a529398e8e723338cca5d8a8ae2d9e7e93448
>     virtio_blk: Fix a slient kernel panic

I would like to add another view on the implementation details in this software update.


> which did the opposite of your patch.

This update contained a different approach for error detection and corresponding
exception handling.


> And in fact it fixed a bug.

This is great in principle according to an information in the commit description.

"…
To fix this bug, we should take care of allocation failure,
and return correct value to let caller know what happen.
…"


> Quite obviously multiple labels are harder to read and harder to get right.
> For error handling with just kfree one label is just the right thing to.

Unfortunately, I get an other impression here after a closer look.

Can it be that the discussed commit from 2016-08-09 accepted (or tolerated)
two weaknesses at least?

1. Commit title:
   Is the word "slient" a typo?
   Would you like to read "silent" there instead?

2. Source code:
   Why would another memory allocation be attempted if it could be determined quicker
   that a previous one failed and this function implementation can not succeed then?

   How much will it matter in general that two function calls are performed
   in this use case without checking their return values immediately?
   https://cwe.mitre.org/data/definitions/252.html

	if (!names || !callbacks || !vqs) { …

   https://cwe.mitre.org/data/definitions/754.html


Was the software development attention a bit too low as it happens occasionally?


I hope that my suggestions can improve the affected situation a bit more
also for this software module.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 17:30       ` SF Markus Elfring
@ 2016-09-13 18:24         ` Christian Borntraeger
  2016-09-14  6:56           ` SF Markus Elfring
  2016-09-14  8:10           ` Cornelia Huck
  0 siblings, 2 replies; 1373+ messages in thread
From: Christian Borntraeger @ 2016-09-13 18:24 UTC (permalink / raw)
  To: SF Markus Elfring, virtualization, Michael S. Tsirkin,
	Minfei Huang, Cornelia Huck, Stefan Hajnoczi
  Cc: Julia Lawall, kernel-janitors, LKML, Chao Fan

On 09/13/2016 07:30 PM, SF Markus Elfring wrote:
[...]
> Unfortunately, I get an other impression here after a closer look.
> 
> Can it be that the discussed commit from 2016-08-09 accepted (or tolerated)
> two weaknesses at least?
> 
> 1. Commit title:
>    Is the word "slient" a typo?
>    Would you like to read "silent" there instead?
> 
> 2. Source code:
>    Why would another memory allocation be attempted if it could be determined quicker
>    that a previous one failed and this function implementation can not succeed then?
> 
>    How much will it matter in general that two function calls are performed
>    in this use case without checking their return values immediately?
>    https://cwe.mitre.org/data/definitions/252.html
> 
> 	if (!names || !callbacks || !vqs) { …
> 
>    https://cwe.mitre.org/data/definitions/754.html
> 

The return values are checked, just a bit later.
Markus, kernel patches are not about be formally correct vs. CodingStyle and/or checkpatch
or against code guidelines from sombody else. You will find many people consider gotos
an no-go, still it is accepted in the kernel for good reasons.
You have to think about each change and its tradeoffs (e.g simplicity vs. performance) 
for each code part again. Here we have slow path error handling, so given the low coverage
of these code parts, simplicity is important.
Yes, your code makes an unlikely error case bail out faster, but is the cost of your
patch (review time, danger of adding bugs, danger of merge conflicts, making git blame less
useful) in sync with the expected win? This is certainly Michaels area of maintainership 
and if he wants your patch, it will be fine too. (Well, having a label between the if and 
the function like
>   	if (err)
> + free_vblk_vqs:
>  		kfree(vblk->vqs);

is certainly ugly in itself)


> Was the software development attention a bit too low as it happens occasionally?
> 
> 
> I hope that my suggestions can improve the affected situation a bit more
> also for this software module.

Do you realize that your discussion style is not very helpful?
I just grepped the last LKML mails and you already pissed of several maintainers
in totally different areas. When that happens, why don't you stop for a moment and
think about "what is going wrong right now". 

Your attitude seems to be "I spend my spare time doing this, please thank me for that".
The thing is, with each patch you actually request time from the maintainer.
Now here begins the interesting part: Is the patch just a cosmetic change that does
not give you any benefit or is the patch improving the code. And remember: there
are always tradeoffs: performance, code size, code maintainability etc.

See, some of your patches are accepted, e.g. the memdup_user changes have usually
been applied by most maintainers including myself. If maintainers won't take other change,
please accept that. If you continue to waste peoples time by discussing "maybe" patches
you actually risk that people will stop taking any patches from you including the "yes"
ones.

Christian

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13 16:50               ` Jean Delvare
@ 2016-09-13 18:31                 ` Ilya Dryomov
  2016-09-19  9:37                   ` Jean Delvare
  0 siblings, 1 reply; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-13 18:31 UTC (permalink / raw)
  To: Jean Delvare
  Cc: Jonathan Corbet, Ceph Development, Alex Elder, Sage Weil, LKML,
	kernel-janitors, Julia Lawall, Andrew Morton

On Tue, Sep 13, 2016 at 6:50 PM, Jean Delvare <jdelvare@suse.de> wrote:
> On Tue, 13 Sep 2016 17:30:33 +0200, Ilya Dryomov wrote:
>> On Tue, Sep 13, 2016 at 4:36 PM, Jean Delvare <jdelvare@suse.de> wrote:
>> > On Tue, 13 Sep 2016 11:16:13 +0200, Ilya Dryomov wrote:
>> >> Jon, could you please yank 865a1caa4b6b ("CodingStyle: Clarify and
>> >> complete chapter 7") from your linux-next branch or at least change "It
>> >> is advised to indent labels" to something less stronger?  It hasn't
>> >> even hit mainline yet and we are already getting spammed.
>> >
>> > The problem isn't the documentation update nor whether you or me like a
>> > space before labels or not. The problem is Markus Elfring. The guy just
>> > spend his time flooding maintainers with unneeded changes they never
>> > asked for. Ignore him and you'll be much better. If he was not flooding
>> > you with this, he would find something else :-(
>> >
>> > When I wrote "It is advised to indent labels with one space", I never
>> > meant that all the existing code should be converted that way. I
>>
>> Hi Jean,
>>
>> That much is clear, however ...
>>
>> > expressed a preference, and provided a rationale for this preference.
>> > After that, an advice is just that: an advice.
>> >
>> >> Looks like 9 out of 10 labels are not indented
>> >>
>> >> $ git grep '^[a-z0-9]\+:' -- *.c | wc -l
>> >> 27945
>> >> $ git grep '^ [a-z0-9]\+:' -- *.c | wc -l
>> >> 2925
>> >
>> > Your regexps are wrong ;-) but the ratio is correct.
>>
>> ... one of the main points of any coding style is consistency.  When
>> someone new wanting to submit say a new driver opens CodingStyle and
>> sees "It is advised to indent labels ...", they might start indenting
>> labels in their code and advise others to do the same.  Given the 9/10
>> existing ratio, that advice is wrong.
>
> Or you could read the thread I pointed you to, where I explain why this
> reasoning is wrong.

Sorry, navigating lkml.org archive is a pain, and I was expecting to
see patch.  Your points

"The acceptance of an optional single space before labels dates back to
at least June 2007, as supported by the very first incarnation of
checkpatch.pl. So nothing really new here, except for a preference
(my preference, admittedly, but I'm know I'm not alone) being expressed
in the coding style document."

"Recommendations are not meant to document what people are currently
doing but what we think they should be doing."

are valid, but note that there is a world of difference between an
acceptance and a preference.  The *only* point of whitespace guidelines
is to keep the code base consistent.  You don't go changing whitespace
preferences in such a huge project, not unless you have a *very* good
rationale and existing code base is swayed (which it isn't, given the
9/10 ratio).

>
>> If I wanted to clarify the
>> situation, I'd have gone with "one space indented labels are also
>> acceptable" or so.  The example you've re-indented dates back to 2.6.4
>> times...
>
> I can't see how this is relevant.

That was a 12 year old example, codifying an existing style used in
~90% cases, serving as a guideline for new contributors.

>
>> >> so I'd say that's a bad advise as far as consistency goes, and the
>> >> "diff -p" argument is pretty moot nowadays.
>> >
>> > It wasn't moot when I sent the documentation update patch. Or why would
>> > you think it was? "git diff", by default, behaves exactly the same as
>> > "diff -p" with regards to unindented labels (i.e. it doesn't handle
>> > them properly.)
>>
>> The git diff xfuncname incantation is a few years old now.
>
> It doesn't help if a majority of developers don't know about it (as was
> my case until last week), and the project itself doesn't carry the
> required configuration bits to make it work out of the box (which
> hopefully will be the case soon, see below.)
>
>> git diff also works on regular files, BTW.
>
> I have no idea what you mean here, sorry.

Oh, just that it works outside of git repos too, so you aren't stuck
with diffutils if you want to diff two random .c files.

>
>> > However, since then the issue was discussed somewhere else:
>> > https://lkml.org/lkml/2016/9/5/214
>> >
>> > As you can see, alternatives to indenting labels with one space were
>> > found. Therefore you will soon be correct saying "the diff -p argument
>> > is pretty moot." As soon as my patch hits mainline, actually. Which
>> > shouldn't take too long as Andrew Morton picked it 4 days ago.
>> >
>> > Once this happens, I'm fine with CodingStyle being updated again to
>> > reflect the current situation.
>>
>> I'm not sure which patch you are talking about - the message you linked
>> is not a patch and it's impossible to follow large threads on lkml.org.
>
> The solution was in this thread, which I expected you to read. The
> patch proper was sent separately:
>
> http://marc.info/?l=linux-kernel&m=147325166209844&w=2
>
> It uses the git diff xfuncname feature you mentioned above. To be
> honest I'm surprised it isn't the git default, it seems odd to have so
> many diff drivers included in git and not enable them on obvious file
> extensions. Oh well.

This came up before: http://www.spinics.net/lists/git/msg164216.html,
Linus didn't like it.  I suggest you add him to the CC on this patch to
see if he changed his mind.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] AGPGART: Fine-tuning for four function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (79 preceding siblings ...)
  2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-13 20:38 ` SF Markus Elfring
  2016-09-13 20:42   ` [PATCH 1/7] AGPGART: Use kmalloc_array() in compat_agpioc_reserve_wrap() SF Markus Elfring
                     ` (6 more replies)
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                   ` (14 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:38 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 22:34:56 +0200

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

Markus Elfring (7):
  Use kmalloc_array() in compat_agpioc_reserve_wrap()
  Use memdup_user() rather than duplicating its implementation
  Rename jump labels in compat_agp_ioctl()
  Use kmalloc_array() in agp_sgi_init()
  Use kmalloc_array() in uninorth_create_gatt_table()
  Rename a jump label in uninorth_create_gatt_table()
  Delete an unnecessary check in uninorth_create_gatt_table()

 drivers/char/agp/compat_ioctl.c | 31 +++++++++++++------------------
 drivers/char/agp/sgi-agp.c      |  6 +++---
 drivers/char/agp/uninorth-agp.c | 12 ++++++------
 3 files changed, 22 insertions(+), 27 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] AGPGART: Use kmalloc_array() in compat_agpioc_reserve_wrap()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-13 20:42   ` SF Markus Elfring
  2016-09-13 20:43   ` [PATCH 2/7] AGPGART: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:42 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 17:51:32 +0200

Multiplications for the size determination of memory allocations
indicated that array data structures should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/compat_ioctl.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index a48e05b..a2b69db 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 		if (ureserve.seg_count >= 16384)
 			return -EINVAL;
 
-		usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
+		usegment = kmalloc_array(ureserve.seg_count,
+					 sizeof(*usegment),
+					 GFP_KERNEL);
 		if (!usegment)
 			return -ENOMEM;
 
-		ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
+		ksegment = kmalloc_array(kreserve.seg_count,
+					 sizeof(*ksegment),
+					 GFP_KERNEL);
 		if (!ksegment) {
 			kfree(usegment);
 			return -ENOMEM;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] AGPGART: Use memdup_user() rather than duplicating its implementation
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-13 20:42   ` [PATCH 1/7] AGPGART: Use kmalloc_array() in compat_agpioc_reserve_wrap() SF Markus Elfring
@ 2016-09-13 20:43   ` SF Markus Elfring
  2016-09-13 20:44   ` [PATCH 3/7] AGPGART: Rename jump labels in compat_agp_ioctl() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:43 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 21:00:44 +0200

* Reuse existing functionality from memdup_user() instead of keeping
  duplicate source code.

* Try this copy operation before allocating memory for the local
  variable "ksegment".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/compat_ioctl.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index a2b69db..68d4dc7 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -98,11 +98,10 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 		if (ureserve.seg_count >= 16384)
 			return -EINVAL;
 
-		usegment = kmalloc_array(ureserve.seg_count,
-					 sizeof(*usegment),
-					 GFP_KERNEL);
-		if (!usegment)
-			return -ENOMEM;
+		usegment = memdup_user((void __user *) ureserve.seg_list,
+				       sizeof(*usegment) * ureserve.seg_count);
+		if (IS_ERR(usegment))
+			return PTR_ERR(usegment);
 
 		ksegment = kmalloc_array(kreserve.seg_count,
 					 sizeof(*ksegment),
@@ -112,13 +111,6 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 			return -ENOMEM;
 		}
 
-		if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
-				   sizeof(*usegment) * ureserve.seg_count)) {
-			kfree(usegment);
-			kfree(ksegment);
-			return -EFAULT;
-		}
-
 		for (seg = 0; seg < ureserve.seg_count; seg++) {
 			ksegment[seg].pg_start = usegment[seg].pg_start;
 			ksegment[seg].pg_count = usegment[seg].pg_count;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] AGPGART: Rename jump labels in compat_agp_ioctl()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-13 20:42   ` [PATCH 1/7] AGPGART: Use kmalloc_array() in compat_agpioc_reserve_wrap() SF Markus Elfring
  2016-09-13 20:43   ` [PATCH 2/7] AGPGART: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
@ 2016-09-13 20:44   ` SF Markus Elfring
  2016-09-13 20:46   ` [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init() SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:44 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 21:12:02 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/compat_ioctl.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index 68d4dc7..4220956 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -209,24 +209,24 @@ long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	if ((agp_fe.current_controller == NULL) &&
 	    (cmd != AGPIOC_ACQUIRE32)) {
 		ret_val = -EINVAL;
-		goto ioctl_out;
+		goto unlock;
 	}
 	if ((agp_fe.backend_acquired != true) &&
 	    (cmd != AGPIOC_ACQUIRE32)) {
 		ret_val = -EBUSY;
-		goto ioctl_out;
+		goto unlock;
 	}
 	if (cmd != AGPIOC_ACQUIRE32) {
 		if (!(test_bit(AGP_FF_IS_CONTROLLER, &curr_priv->access_flags))) {
 			ret_val = -EPERM;
-			goto ioctl_out;
+			goto unlock;
 		}
 		/* Use the original pid of the controller,
 		 * in case it's threaded */
 
 		if (agp_fe.current_controller->pid != curr_priv->my_pid) {
 			ret_val = -EBUSY;
-			goto ioctl_out;
+			goto unlock;
 		}
 	}
 
@@ -274,8 +274,7 @@ long compat_agp_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	case AGPIOC_CHIPSET_FLUSH32:
 		break;
 	}
-
-ioctl_out:
+ unlock:
 	DBG("ioctl returns %d\n", ret_val);
 	mutex_unlock(&(agp_fe.agp_mutex));
 	return ret_val;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-13 20:44   ` [PATCH 3/7] AGPGART: Rename jump labels in compat_agp_ioctl() SF Markus Elfring
@ 2016-09-13 20:46   ` SF Markus Elfring
  2016-09-13 20:47   ` [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in uninorth_create_gatt_table() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:46 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 21:30:58 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/sgi-agp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c
index 3051c73..798ad20 100644
--- a/drivers/char/agp/sgi-agp.c
+++ b/drivers/char/agp/sgi-agp.c
@@ -280,9 +280,9 @@ static int agp_sgi_init(void)
 	else
 		return 0;
 
-	sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
-					sizeof(struct agp_bridge_data *),
-					GFP_KERNEL);
+	sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
+					      sizeof(*sgi_tioca_agp_bridges),
+					      GFP_KERNEL);
 	if (!sgi_tioca_agp_bridges)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in uninorth_create_gatt_table()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-13 20:46   ` [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init() SF Markus Elfring
@ 2016-09-13 20:47   ` SF Markus Elfring
  2016-09-13 20:48   ` [PATCH 6/7] AGPGART-UniNorth: Rename a jump label " SF Markus Elfring
  2016-09-13 20:50   ` [PATCH 7/7] AGPGART-UniNorth: Delete an unnecessary check " SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:47 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 21:50:44 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/uninorth-agp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index fdced54..8d144cd 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 	if (table == NULL)
 		return -ENOMEM;
 
-	uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL);
+	uninorth_priv.pages_arr = kmalloc_array(1 << page_order,
+						sizeof(*uninorth_priv.pages_arr),
+						GFP_KERNEL);
 	if (uninorth_priv.pages_arr == NULL)
 		goto enomem;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in uninorth_create_gatt_table()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-13 20:47   ` [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in uninorth_create_gatt_table() SF Markus Elfring
@ 2016-09-13 20:48   ` SF Markus Elfring
  2016-09-15 17:37     ` kbuild test robot
  2016-09-13 20:50   ` [PATCH 7/7] AGPGART-UniNorth: Delete an unnecessary check " SF Markus Elfring
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:48 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 22:00:19 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/uninorth-agp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 8d144cd..8b1eb72 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -406,7 +406,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 						sizeof(*uninorth_priv.pages_arr),
 						GFP_KERNEL);
 	if (uninorth_priv.pages_arr == NULL)
-		goto enomem;
+		goto free_page_array;
 
 	table_end = table + ((PAGE_SIZE * (1 << page_order)) - 1);
 
@@ -436,8 +436,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 		bridge->gatt_table[i] = scratch_value;
 
 	return 0;
-
-enomem:
+ free_page_array:
 	kfree(uninorth_priv.pages_arr);
 	if (table)
 		free_pages((unsigned long)table, page_order);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] AGPGART-UniNorth: Delete an unnecessary check in uninorth_create_gatt_table()
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-13 20:48   ` [PATCH 6/7] AGPGART-UniNorth: Rename a jump label " SF Markus Elfring
@ 2016-09-13 20:50   ` SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-13 20:50 UTC (permalink / raw)
  To: kernel-janitors, David Airlie; +Cc: LKML, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 13 Sep 2016 22:15:56 +0200

The check for the local variable "table" is unnecessary at the end
of this function because the corresponding source code place should only
be reached with a non-zero pointer for it after a failed call of the
function "kmalloc_array".
Thus remove it.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/agp/uninorth-agp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c
index 8b1eb72..657cf17 100644
--- a/drivers/char/agp/uninorth-agp.c
+++ b/drivers/char/agp/uninorth-agp.c
@@ -438,8 +438,7 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 	return 0;
  free_page_array:
 	kfree(uninorth_priv.pages_arr);
-	if (table)
-		free_pages((unsigned long)table, page_order);
+	free_pages((unsigned long)table, page_order);
 	return -ENOMEM;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 18:24         ` Christian Borntraeger
@ 2016-09-14  6:56           ` SF Markus Elfring
  2016-09-14  8:10           ` Cornelia Huck
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14  6:56 UTC (permalink / raw)
  To: Christian Bornträger, virtualization, Michael S. Tsirkin
  Cc: Minfei Huang, Cornelia Huck, Stefan Hajnoczi, Julia Lawall,
	kernel-janitors, LKML, Chao Fan

>>    How much will it matter in general that two function calls are performed
>>    in this use case without checking their return values immediately?
>>    https://cwe.mitre.org/data/definitions/252.html
>>
>> 	if (!names || !callbacks || !vqs) { …
>>
>>    https://cwe.mitre.org/data/definitions/754.html
> 
> The return values are checked,

I agree to this information.


> just a bit later.

I suggest to reconsider this design detail if it is really acceptable
for the safe implementation of such a software module.


> Markus, kernel patches are not about be formally correct vs. CodingStyle and/or checkpatch

I guess that some of the involved technical advices will also matter here, don't they?


> or against code guidelines from sombody else.

Some ideas or advices are integrated from other information sources also into various
Linux software.


> You will find many people consider gotos an no-go,

I became trained also in this design direction for a while.


> still it is accepted in the kernel for good reasons.

I can follow such reasons to some degree.


> You have to think about each change and its tradeoffs (e.g simplicity vs. performance) 
> for each code part again.

This can happen as usual for an ordinary source code review process.
I would be interested to clarify if items could be optimised for repeated checks
in this work flow.


> Here we have slow path error handling, so given the low coverage of these code parts,

Would you like to add any other background information for this aspect?


> simplicity is important.

I can follow this opinion to some degree.


> Yes, your code makes an unlikely error case bail out faster,

Is this kind of functionality desired finally?


> but is the cost of your patch (review time, danger of adding bugs, danger of merge conflicts,
> making git blame less useful) in sync with the expected win?

I hope so.

Do the mentioned aspects express a fear or other general concerns which hinder changes
and make the proposed software improvement unlikely?


> (Well, having a label between the if and the function like
>>   	if (err)
>> + free_vblk_vqs:
>>  		kfree(vblk->vqs);
> 
> is certainly ugly in itself)

Would you find such a source code approach better if curly brackets will be
added there?


> Do you realize that your discussion style is not very helpful?

I find that this view is debatable.


> I just grepped the last LKML mails and you already pissed of several maintainers
> in totally different areas.

Yes. - It can happen that some contributors get occasionally grumpy.

Would you like to discuss their reasons a bit more?


> When that happens, why don't you stop for a moment
> and think about "what is going wrong right now". 

This happened also a few times already.


> Your attitude seems to be "I spend my spare time doing this, please thank me for that".

I guess that I am not so different in this aspect as I am trying to be another
respectable free software developer for years.


> The thing is, with each patch you actually request time from the maintainer.

This is a consequence of software development as usual.


> Now here begins the interesting part: Is the patch just a cosmetic change that does
> not give you any benefit or is the patch improving the code.

How do you categorise my concrete update suggestion which builds on previous contributions
by others?


> And remember: there are always tradeoffs: performance, code size, code maintainability etc.

I find that I pick some of such design goals up for my software contributions already
for a while.


> See, some of your patches are accepted, e.g. the memdup_user changes have usually
> been applied by most maintainers including myself.

I thank you once more that you could also accept one of the proposed special software updates.


> If maintainers won't take other change, please accept that.

It can happen that change acceptance needs to evolve over time.
Can a healthy pressure help to achieve special software improvements?


> If you continue to waste peoples time by discussing "maybe" patches

Can it be that this category of software updates has got a high potential for further
clarifications because some approaches are occasionally interpreted as controversial?


> you actually risk that people will stop taking any patches from you
> including the "yes" ones.

I assume that this risk is hard to avoid. - It is a matter for each contributor
on how the desired communication should evolve further.


My knowledge evolved in the way that I am using some tools for
static source code analysis. Such advanced tools can point various
change opportunities out. I picked a few special search patterns up.
It happened then that hundreds of source files were found which contain
update candidates.


Further challenges are relevant then as usual.

* Handling of the search process and their results

* Communication between contributors


Search patterns can occasionally be categorised as "too special".
The software technology contains also the risk for showing "false positives".

The reactions of code reviewers are varying between agreement and rejection.


The discussed concrete (and small) patch series is just another example
for usual difficulties or more interesting software development challenges.
I hope that they can be resolved in a systematic way.

So there are further constraints to consider, aren't there?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Less function calls in init_vq() after error detection
  2016-09-13 18:24         ` Christian Borntraeger
  2016-09-14  6:56           ` SF Markus Elfring
@ 2016-09-14  8:10           ` Cornelia Huck
  2016-09-14  9:09             ` virtio_blk: Clarification for communication difficulties? SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Cornelia Huck @ 2016-09-14  8:10 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: SF Markus Elfring, virtualization, Michael S. Tsirkin,
	Minfei Huang, Stefan Hajnoczi, Julia Lawall, kernel-janitors,
	LKML, Chao Fan

On Tue, 13 Sep 2016 20:24:58 +0200
Christian Borntraeger <borntraeger@de.ibm.com> wrote:

> See, some of your patches are accepted, e.g. the memdup_user changes have usually
> been applied by most maintainers including myself. If maintainers won't take other change,
> please accept that. If you continue to waste peoples time by discussing "maybe" patches
> you actually risk that people will stop taking any patches from you including the "yes"
> ones.

FWIW, he already gained a place on my ignore list for pestering me
offline about his patches and not stopping even when told to do so. So
while I won't object if you choose to apply selected patches, I won't
comment on any and won't take any (hey, I even won't see them unless
someone else replies...)

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_blk: Clarification for communication difficulties?
  2016-09-14  8:10           ` Cornelia Huck
@ 2016-09-14  9:09             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14  9:09 UTC (permalink / raw)
  To: Cornelia Huck
  Cc: Christian Bornträger, virtualization, Michael S. Tsirkin,
	Minfei Huang, Stefan Hajnoczi, Julia Lawall, kernel-janitors,
	LKML, Chao Fan

> FWIW, he already gained a place on my ignore list for pestering me
> offline about his patches and not stopping even when told to do so.

How did I "pester" you "offline"?


> So while I won't object if you choose to apply selected patches,

Another bit of interesting information, isn't it?


> I won't comment on any and won't take any (hey, I even won't see
> them unless someone else replies...)

I find this reaction strange. - I hope that our collaboration potential
can be still constructive, can't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (80 preceding siblings ...)
  2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-14 13:56 ` SF Markus Elfring
  2016-09-14 14:00   ` [PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs() SF Markus Elfring
                     ` (10 more replies)
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
                   ` (13 subsequent siblings)
  95 siblings, 11 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 13:56 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:43:21 +0200

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

Markus Elfring (11):
  Use kmalloc_array() in init_vqs()
  Less function calls in init_vqs() after error detection
  Rename a jump label in init()
  Rename jump labels in virtcons_probe()
  Rename jump labels in add_port()
  Rename a jump label in port_fops_open()
  Rename a jump label in port_fops_splice_write()
  Rename jump labels in port_fops_write()
  Rename a jump label in __send_to_port()
  Rename jump labels in alloc_buf()
  Rename a jump label in five functions

 drivers/char/virtio_console.c | 155 ++++++++++++++++++++++++------------------
 1 file changed, 87 insertions(+), 68 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
@ 2016-09-14 14:00   ` SF Markus Elfring
  2016-09-14 14:01   ` [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring
                     ` (9 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:00 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 11:23:59 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structures should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specifications of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index d2406fe..325ebc6 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1881,13 +1881,17 @@ static int init_vqs(struct ports_device *portdev)
 	nr_ports = portdev->config.max_nr_ports;
 	nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
 
-	vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
-	io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
-	io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
-	portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
-				  GFP_KERNEL);
-	portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
-				   GFP_KERNEL);
+	vqs = kmalloc_array(nr_queues, sizeof(*vqs), GFP_KERNEL);
+	io_callbacks = kmalloc_array(nr_queues,
+				     sizeof(*io_callbacks),
+				     GFP_KERNEL);
+	io_names = kmalloc_array(nr_queues, sizeof(*io_names), GFP_KERNEL);
+	portdev->in_vqs = kmalloc_array(nr_ports,
+					sizeof(*portdev->in_vqs),
+					GFP_KERNEL);
+	portdev->out_vqs = kmalloc_array(nr_ports,
+					 sizeof(*portdev->out_vqs),
+					 GFP_KERNEL);
 	if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
 	    !portdev->out_vqs) {
 		err = -ENOMEM;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
  2016-09-14 14:00   ` [PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs() SF Markus Elfring
@ 2016-09-14 14:01   ` SF Markus Elfring
  2016-09-21 12:10     ` Amit Shah
  2016-09-14 14:02   ` [PATCH 03/11] virtio_console: Rename a jump label in init() SF Markus Elfring
                     ` (8 subsequent siblings)
  10 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:01 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 14:00:35 +0200

The kfree() function was called in up to five cases
by the init_vqs() function during error handling even if
the passed variable contained a null pointer.

* Return directly after a call of the function "kmalloc_array" failed
  at the beginning.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 325ebc6..bf0ad57 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1882,20 +1882,37 @@ static int init_vqs(struct ports_device *portdev)
 	nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
 
 	vqs = kmalloc_array(nr_queues, sizeof(*vqs), GFP_KERNEL);
+	if (!vqs)
+		return -ENOMEM;
+
 	io_callbacks = kmalloc_array(nr_queues,
 				     sizeof(*io_callbacks),
 				     GFP_KERNEL);
+	if (!io_callbacks) {
+		err = -ENOMEM;
+		goto free_vqs;
+	}
+
 	io_names = kmalloc_array(nr_queues, sizeof(*io_names), GFP_KERNEL);
+	if (!io_names) {
+		err = -ENOMEM;
+		goto free_callbacks;
+	}
+
 	portdev->in_vqs = kmalloc_array(nr_ports,
 					sizeof(*portdev->in_vqs),
 					GFP_KERNEL);
+	if (!portdev->in_vqs) {
+		err = -ENOMEM;
+		goto free_names;
+	}
+
 	portdev->out_vqs = kmalloc_array(nr_ports,
 					 sizeof(*portdev->out_vqs),
 					 GFP_KERNEL);
-	if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
-	    !portdev->out_vqs) {
+	if (!portdev->out_vqs) {
 		err = -ENOMEM;
-		goto free;
+		goto free_in_vqs;
 	}
 
 	/*
@@ -1929,7 +1946,7 @@ static int init_vqs(struct ports_device *portdev)
 					      io_callbacks,
 					      (const char **)io_names);
 	if (err)
-		goto free;
+		goto free_out_vqs;
 
 	j = 0;
 	portdev->in_vqs[0] = vqs[0];
@@ -1950,12 +1967,15 @@ static int init_vqs(struct ports_device *portdev)
 	kfree(vqs);
 
 	return 0;
-
-free:
+ free_out_vqs:
 	kfree(portdev->out_vqs);
+ free_in_vqs:
 	kfree(portdev->in_vqs);
+ free_names:
 	kfree(io_names);
+ free_callbacks:
 	kfree(io_callbacks);
+ free_vqs:
 	kfree(vqs);
 
 	return err;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/11] virtio_console: Rename a jump label in init()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
  2016-09-14 14:00   ` [PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs() SF Markus Elfring
  2016-09-14 14:01   ` [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring
@ 2016-09-14 14:02   ` SF Markus Elfring
  2016-09-14 14:03   ` [PATCH 04/11] virtio_console: Rename jump labels in virtcons_probe() SF Markus Elfring
                     ` (7 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:02 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 14:10:24 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index bf0ad57..004314e 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -2309,7 +2309,7 @@ static int __init init(void)
 	err = register_virtio_driver(&virtio_console);
 	if (err < 0) {
 		pr_err("Error %d registering virtio driver\n", err);
-		goto free;
+		goto remove;
 	}
 	err = register_virtio_driver(&virtio_rproc_serial);
 	if (err < 0) {
@@ -2318,9 +2318,9 @@ static int __init init(void)
 		goto unregister;
 	}
 	return 0;
-unregister:
+ unregister:
 	unregister_virtio_driver(&virtio_console);
-free:
+ remove:
 	debugfs_remove_recursive(pdrvdata.debugfs_dir);
 	class_destroy(pdrvdata.class);
 	return err;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/11] virtio_console: Rename jump labels in virtcons_probe()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-14 14:02   ` [PATCH 03/11] virtio_console: Rename a jump label in init() SF Markus Elfring
@ 2016-09-14 14:03   ` SF Markus Elfring
  2016-09-14 14:04   ` [PATCH 05/11] virtio_console: Rename jump labels in add_port() SF Markus Elfring
                     ` (6 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:03 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 14:24:05 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 004314e..768bbb7 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -2037,7 +2037,7 @@ static int virtcons_probe(struct virtio_device *vdev)
 	portdev = kmalloc(sizeof(*portdev), GFP_KERNEL);
 	if (!portdev) {
 		err = -ENOMEM;
-		goto fail;
+		goto exit;
 	}
 
 	/* Attach this portdev to this virtio_device, and vice-versa. */
@@ -2051,7 +2051,7 @@ static int virtcons_probe(struct virtio_device *vdev)
 			"Error %d registering chrdev for device %u\n",
 			portdev->chr_major, vdev->index);
 		err = portdev->chr_major;
-		goto free;
+		goto free_port;
 	}
 
 	multiport = false;
@@ -2068,7 +2068,7 @@ static int virtcons_probe(struct virtio_device *vdev)
 	err = init_vqs(portdev);
 	if (err < 0) {
 		dev_err(&vdev->dev, "Error %d initializing vqs\n", err);
-		goto free_chrdev;
+		goto unregister;
 	}
 
 	spin_lock_init(&portdev->ports_lock);
@@ -2091,7 +2091,7 @@ static int virtcons_probe(struct virtio_device *vdev)
 			dev_err(&vdev->dev,
 				"Error allocating buffers for control queue\n");
 			err = -ENOMEM;
-			goto free_vqs;
+			goto send_control_message;
 		}
 	} else {
 		/*
@@ -2121,17 +2121,16 @@ static int virtcons_probe(struct virtio_device *vdev)
 		wait_for_completion(&early_console_added);
 
 	return 0;
-
-free_vqs:
+ send_control_message:
 	/* The host might want to notify mgmt sw about device add failure */
 	__send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID,
 			   VIRTIO_CONSOLE_DEVICE_READY, 0);
 	remove_vqs(portdev);
-free_chrdev:
+ unregister:
 	unregister_chrdev(portdev->chr_major, "virtio-portsdev");
-free:
+ free_port:
 	kfree(portdev);
-fail:
+ exit:
 	return err;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/11] virtio_console: Rename jump labels in add_port()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-14 14:03   ` [PATCH 04/11] virtio_console: Rename jump labels in virtcons_probe() SF Markus Elfring
@ 2016-09-14 14:04   ` SF Markus Elfring
  2016-09-14 14:05   ` [PATCH 06/11] virtio_console: Rename a jump label in port_fops_open() SF Markus Elfring
                     ` (5 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:04 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 14:53:00 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 768bbb7..40b8775 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1399,7 +1399,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 	port = kmalloc(sizeof(*port), GFP_KERNEL);
 	if (!port) {
 		err = -ENOMEM;
-		goto fail;
+		goto send_control_message;
 	}
 	kref_init(&port->kref);
 
@@ -1434,7 +1434,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 	if (err < 0) {
 		dev_err(&port->portdev->vdev->dev,
 			"Error %d adding cdev for port %u\n", err, id);
-		goto free_cdev;
+		goto delete_cdev;
 	}
 	port->dev = device_create(pdrvdata.class, &port->portdev->vdev->dev,
 				  devt, port, "vport%up%u",
@@ -1444,7 +1444,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 		dev_err(&port->portdev->vdev->dev,
 			"Error %d creating device for port %u\n",
 			err, id);
-		goto free_cdev;
+		goto delete_cdev;
 	}
 
 	spin_lock_init(&port->inbuf_lock);
@@ -1456,7 +1456,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 	if (!nr_added_bufs) {
 		dev_err(port->dev, "Error allocating inbufs\n");
 		err = -ENOMEM;
-		goto free_device;
+		goto destroy_device;
 	}
 
 	if (is_rproc_serial(port->portdev->vdev))
@@ -1473,7 +1473,7 @@ static int add_port(struct ports_device *portdev, u32 id)
 		 */
 		err = init_port_console(port);
 		if (err)
-			goto free_inbufs;
+			goto free_buffers;
 	}
 
 	spin_lock_irq(&portdev->ports_lock);
@@ -1500,17 +1500,16 @@ static int add_port(struct ports_device *portdev, u32 id)
 							 &port_debugfs_ops);
 	}
 	return 0;
-
-free_inbufs:
+ free_buffers:
 	while ((buf = virtqueue_detach_unused_buf(port->in_vq)))
 		free_buf(buf, true);
-free_device:
+ destroy_device:
 	device_destroy(pdrvdata.class, port->dev->devt);
-free_cdev:
+ delete_cdev:
 	cdev_del(port->cdev);
-free_port:
+ free_port:
 	kfree(port);
-fail:
+ send_control_message:
 	/* The host might want to notify management sw about port add failure */
 	__send_control_msg(portdev, id, VIRTIO_CONSOLE_PORT_READY, 0);
 	return err;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/11] virtio_console: Rename a jump label in port_fops_open()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-14 14:04   ` [PATCH 05/11] virtio_console: Rename jump labels in add_port() SF Markus Elfring
@ 2016-09-14 14:05   ` SF Markus Elfring
  2016-09-14 14:06   ` [PATCH 07/11] virtio_console: Rename a jump label in port_fops_splice_write() SF Markus Elfring
                     ` (4 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:05 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 14:58:24 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 40b8775..99dc659 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -1058,7 +1058,7 @@ static int port_fops_open(struct inode *inode, struct file *filp)
 	 */
 	if (is_console_port(port)) {
 		ret = -ENXIO;
-		goto out;
+		goto put_ref;
 	}
 
 	/* Allow only one process to open a particular port at a time */
@@ -1066,7 +1066,7 @@ static int port_fops_open(struct inode *inode, struct file *filp)
 	if (port->guest_connected) {
 		spin_unlock_irq(&port->inbuf_lock);
 		ret = -EBUSY;
-		goto out;
+		goto put_ref;
 	}
 
 	port->guest_connected = true;
@@ -1087,7 +1087,7 @@ static int port_fops_open(struct inode *inode, struct file *filp)
 	send_control_msg(filp->private_data, VIRTIO_CONSOLE_PORT_OPEN, 1);
 
 	return 0;
-out:
+ put_ref:
 	kref_put(&port->kref, remove_port);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/11] virtio_console: Rename a jump label in port_fops_splice_write()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-14 14:05   ` [PATCH 06/11] virtio_console: Rename a jump label in port_fops_open() SF Markus Elfring
@ 2016-09-14 14:06   ` SF Markus Elfring
  2016-09-14 14:07   ` [PATCH 08/11] virtio_console: Rename jump labels in port_fops_write() SF Markus Elfring
                     ` (3 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:06 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:01:51 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 99dc659..d8681d9 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -947,17 +947,17 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
 	pipe_lock(pipe);
 	if (!pipe->nrbufs) {
 		ret = 0;
-		goto error_out;
+		goto unlock;
 	}
 
 	ret = wait_port_writable(port, filp->f_flags & O_NONBLOCK);
 	if (ret < 0)
-		goto error_out;
+		goto unlock;
 
 	buf = alloc_buf(port->out_vq, 0, pipe->nrbufs);
 	if (!buf) {
 		ret = -ENOMEM;
-		goto error_out;
+		goto unlock;
 	}
 
 	sgl.n = 0;
@@ -973,8 +973,7 @@ static ssize_t port_fops_splice_write(struct pipe_inode_info *pipe,
 	if (unlikely(ret <= 0))
 		free_buf(buf, true);
 	return ret;
-
-error_out:
+ unlock:
 	pipe_unlock(pipe);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/11] virtio_console: Rename jump labels in port_fops_write()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-14 14:06   ` [PATCH 07/11] virtio_console: Rename a jump label in port_fops_splice_write() SF Markus Elfring
@ 2016-09-14 14:07   ` SF Markus Elfring
  2016-09-14 14:08   ` [PATCH 09/11] virtio_console: Rename a jump label in __send_to_port() SF Markus Elfring
                     ` (2 subsequent siblings)
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:07 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:07:42 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index d8681d9..babc812 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -842,7 +842,7 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
 	ret = copy_from_user(buf->buf, ubuf, count);
 	if (ret) {
 		ret = -EFAULT;
-		goto free_buf;
+		goto free_buffer;
 	}
 
 	/*
@@ -857,11 +857,10 @@ static ssize_t port_fops_write(struct file *filp, const char __user *ubuf,
 	ret = __send_to_port(port, sg, 1, count, buf, nonblock);
 
 	if (nonblock && ret > 0)
-		goto out;
-
-free_buf:
+		goto exit;
+ free_buffer:
 	free_buf(buf, true);
-out:
+ exit:
 	return ret;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/11] virtio_console: Rename a jump label in __send_to_port()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-14 14:07   ` [PATCH 08/11] virtio_console: Rename jump labels in port_fops_write() SF Markus Elfring
@ 2016-09-14 14:08   ` SF Markus Elfring
  2016-09-14 14:09   ` [PATCH 10/11] virtio_console: Rename jump labels in alloc_buf() SF Markus Elfring
  2016-09-14 14:10   ` [PATCH 11/11] virtio_console: Rename a jump label in five functions SF Markus Elfring
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:08 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:15:06 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index babc812..69c6718 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -634,14 +634,14 @@ static ssize_t __send_to_port(struct port *port, struct scatterlist *sg,
 
 	if (err) {
 		in_count = 0;
-		goto done;
+		goto unlock;
 	}
 
 	if (out_vq->num_free == 0)
 		port->outvq_full = true;
 
 	if (nonblock)
-		goto done;
+		goto unlock;
 
 	/*
 	 * Wait till the host acknowledges it pushed out the data we
@@ -655,7 +655,7 @@ static ssize_t __send_to_port(struct port *port, struct scatterlist *sg,
 	while (!virtqueue_get_buf(out_vq, &len)
 		&& !virtqueue_is_broken(out_vq))
 		cpu_relax();
-done:
+ unlock:
 	spin_unlock_irqrestore(&port->outvq_lock, flags);
 
 	port->stats.bytes_sent += in_count;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/11] virtio_console: Rename jump labels in alloc_buf()
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-14 14:08   ` [PATCH 09/11] virtio_console: Rename a jump label in __send_to_port() SF Markus Elfring
@ 2016-09-14 14:09   ` SF Markus Elfring
  2016-09-14 14:10   ` [PATCH 11/11] virtio_console: Rename a jump label in five functions SF Markus Elfring
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:09 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:20:30 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 69c6718..0c4d4e7 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -431,7 +431,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
 	buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages,
 		      GFP_KERNEL);
 	if (!buf)
-		goto fail;
+		goto exit;
 
 	buf->sgpages = pages;
 	if (pages > 0) {
@@ -451,7 +451,7 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
 		 * in dma-coherent.c
 		 */
 		if (!vq->vdev->dev.parent || !vq->vdev->dev.parent->parent)
-			goto free_buf;
+			goto free_buffer;
 		buf->dev = vq->vdev->dev.parent->parent;
 
 		/* Increase device refcnt to avoid freeing it */
@@ -464,15 +464,14 @@ static struct port_buffer *alloc_buf(struct virtqueue *vq, size_t buf_size,
 	}
 
 	if (!buf->buf)
-		goto free_buf;
+		goto free_buffer;
 	buf->len = 0;
 	buf->offset = 0;
 	buf->size = buf_size;
 	return buf;
-
-free_buf:
+ free_buffer:
 	kfree(buf);
-fail:
+ exit:
 	return NULL;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/11] virtio_console: Rename a jump label in five functions
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-14 14:09   ` [PATCH 10/11] virtio_console: Rename jump labels in alloc_buf() SF Markus Elfring
@ 2016-09-14 14:10   ` SF Markus Elfring
  10 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 14:10 UTC (permalink / raw)
  To: virtualization, Amit Shah, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 15:37:52 +0200

Adjust a jump label according to the current Linux coding style convention.
Thus replace the identifier "out" by "unlock".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/char/virtio_console.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
index 0c4d4e7..6c90c9c 100644
--- a/drivers/char/virtio_console.c
+++ b/drivers/char/virtio_console.c
@@ -257,11 +257,11 @@ static struct port *find_port_by_vtermno(u32 vtermno)
 	list_for_each_entry(cons, &pdrvdata.consoles, list) {
 		if (cons->vtermno == vtermno) {
 			port = container_of(cons, struct port, cons);
-			goto out;
+			goto unlock;
 		}
 	}
 	port = NULL;
-out:
+ unlock:
 	spin_unlock_irqrestore(&pdrvdata_lock, flags);
 	return port;
 }
@@ -276,11 +276,11 @@ static struct port *find_port_by_devt_in_portdev(struct ports_device *portdev,
 	list_for_each_entry(port, &portdev->ports, list) {
 		if (port->cdev->dev == dev) {
 			kref_get(&port->kref);
-			goto out;
+			goto unlock;
 		}
 	}
 	port = NULL;
-out:
+ unlock:
 	spin_unlock_irqrestore(&portdev->ports_lock, flags);
 
 	return port;
@@ -296,10 +296,10 @@ static struct port *find_port_by_devt(dev_t dev)
 	list_for_each_entry(portdev, &pdrvdata.portdevs, list) {
 		port = find_port_by_devt_in_portdev(portdev, dev);
 		if (port)
-			goto out;
+			goto unlock;
 	}
 	port = NULL;
-out:
+ unlock:
 	spin_unlock_irqrestore(&pdrvdata_lock, flags);
 	return port;
 }
@@ -312,9 +312,9 @@ static struct port *find_port_by_id(struct ports_device *portdev, u32 id)
 	spin_lock_irqsave(&portdev->ports_lock, flags);
 	list_for_each_entry(port, &portdev->ports, list)
 		if (port->id == id)
-			goto out;
+			goto unlock;
 	port = NULL;
-out:
+ unlock:
 	spin_unlock_irqrestore(&portdev->ports_lock, flags);
 
 	return port;
@@ -329,9 +329,9 @@ static struct port *find_port_by_vq(struct ports_device *portdev,
 	spin_lock_irqsave(&portdev->ports_lock, flags);
 	list_for_each_entry(port, &portdev->ports, list)
 		if (port->in_vq == vq || port->out_vq == vq)
-			goto out;
+			goto unlock;
 	port = NULL;
-out:
+ unlock:
 	spin_unlock_irqrestore(&portdev->ports_lock, flags);
 	return port;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk()
  2016-09-12 18:42   ` [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk() SF Markus Elfring
@ 2016-09-14 15:25     ` Ilya Dryomov
  0 siblings, 0 replies; 1373+ messages in thread
From: Ilya Dryomov @ 2016-09-14 15:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Ceph Development, Alex Elder, Sage Weil, LKML, kernel-janitors,
	Julia Lawall

On Mon, Sep 12, 2016 at 8:42 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 11 Sep 2016 12:21:25 +0200
>
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
>
>   This issue was detected by using the Coccinelle software.
>
> * Delete the local variable "size" which became unnecessary with
>   this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Now applied.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (81 preceding siblings ...)
  2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
@ 2016-09-14 19:56 ` SF Markus Elfring
  2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
                     ` (3 more replies)
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                   ` (12 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 19:56 UTC (permalink / raw)
  To: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 21:48:48 +0200

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

Markus Elfring (4):
  Use kmalloc_array() in cpg_mstp_clocks_init()
  Delete an error message for a failed memory allocation
  Less function calls in cpg_mstp_clocks_init() after error detection
  Rename jump labels in cpg_mstp_attach_dev()

 drivers/clk/renesas/clk-mstp.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init()
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-14 20:00   ` SF Markus Elfring
  2016-09-15 19:11     ` Geert Uytterhoeven
  2016-09-16 23:13     ` Stephen Boyd
  2016-09-14 20:01   ` [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 20:00 UTC (permalink / raw)
  To: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 21:10:47 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/renesas/clk-mstp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 5093a25..9375777 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -167,7 +167,7 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
 	unsigned int i;
 
 	group = kzalloc(sizeof(*group), GFP_KERNEL);
-	clks = kmalloc(MSTP_MAX_CLOCKS * sizeof(*clks), GFP_KERNEL);
+	clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL);
 	if (group == NULL || clks == NULL) {
 		kfree(group);
 		kfree(clks);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
@ 2016-09-14 20:01   ` SF Markus Elfring
  2016-09-15 19:07     ` Geert Uytterhoeven
  2016-09-14 20:03   ` [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection SF Markus Elfring
  2016-09-14 20:04   ` [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 20:01 UTC (permalink / raw)
  To: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall, Wolfram Sang

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 21:17:18 +0200

Omit an extra message for a memory allocation failure in this function.

Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/renesas/clk-mstp.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 9375777..1fdc44b 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -171,7 +171,6 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
 	if (group == NULL || clks == NULL) {
 		kfree(group);
 		kfree(clks);
-		pr_err("%s: failed to allocate group\n", __func__);
 		return;
 	}
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
  2016-09-14 20:01   ` [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation SF Markus Elfring
@ 2016-09-14 20:03   ` SF Markus Elfring
  2016-09-15 19:11     ` Geert Uytterhoeven
  2016-09-14 20:04   ` [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 20:03 UTC (permalink / raw)
  To: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 21:30:27 +0200

The kfree() function was called in up to two cases
by the cpg_mstp_clocks_init() function during error handling even if
the passed variable contained a null pointer.

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/renesas/clk-mstp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 1fdc44b..6c82e0e 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -167,10 +167,12 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
 	unsigned int i;
 
 	group = kzalloc(sizeof(*group), GFP_KERNEL);
+	if (!group)
+		return;
+
 	clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL);
-	if (group == NULL || clks == NULL) {
+	if (!clks) {
 		kfree(group);
-		kfree(clks);
 		return;
 	}
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev()
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-14 20:03   ` [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection SF Markus Elfring
@ 2016-09-14 20:04   ` SF Markus Elfring
  2016-09-15 19:18     ` Geert Uytterhoeven
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-14 20:04 UTC (permalink / raw)
  To: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 14 Sep 2016 21:41:50 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/clk/renesas/clk-mstp.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
index 6c82e0e..2f90718 100644
--- a/drivers/clk/renesas/clk-mstp.c
+++ b/drivers/clk/renesas/clk-mstp.c
@@ -256,19 +256,18 @@ int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev)
 					   &clkspec)) {
 		if (of_device_is_compatible(clkspec.np,
 					    "renesas,cpg-mstp-clocks"))
-			goto found;
+			goto get_clk;
 
 		/* BSC on r8a73a4/sh73a0 uses zb_clk instead of an mstp clock */
 		if (!strcmp(clkspec.np->name, "zb_clk"))
-			goto found;
+			goto get_clk;
 
 		of_node_put(clkspec.np);
 		i++;
 	}
 
 	return 0;
-
-found:
+ get_clk:
 	clk = of_clk_get_from_provider(&clkspec);
 	of_node_put(clkspec.np);
 
@@ -278,20 +277,19 @@ found:
 	error = pm_clk_create(dev);
 	if (error) {
 		dev_err(dev, "pm_clk_create failed %d\n", error);
-		goto fail_put;
+		goto put_clk;
 	}
 
 	error = pm_clk_add_clk(dev, clk);
 	if (error) {
 		dev_err(dev, "pm_clk_add_clk %pC failed %d\n", clk, error);
-		goto fail_destroy;
+		goto destroy_clk;
 	}
 
 	return 0;
-
-fail_destroy:
+ destroy_clk:
 	pm_clk_destroy(dev);
-fail_put:
+ put_clk:
 	clk_put(clk);
 	return error;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* crypto-caamhash: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (82 preceding siblings ...)
  2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-15 14:36 ` SF Markus Elfring
  2016-09-15 14:40   ` [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() SF Markus Elfring
                     ` (7 more replies)
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                   ` (11 subsequent siblings)
  95 siblings, 8 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:36 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 16:27:23 +0200

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

Markus Elfring (6):
  Use kmalloc_array() in ahash_setkey()
  Rename jump labels in ahash_setkey()
  Rename a jump label in five functions
  Return a value directly in caam_hash_cra_init()
  Delete an unnecessary initialisation in seven functions
  Move common error handling code in two functions

 drivers/crypto/caam/caamhash.c | 111 +++++++++++++++++++----------------------
 1 file changed, 52 insertions(+), 59 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey()
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-15 14:40   ` SF Markus Elfring
  2016-09-15 15:12     ` Horia Geanta Neag
  2016-09-15 14:41   ` [PATCH 2/6] crypto-caamhash: Rename jump labels " SF Markus Elfring
                     ` (6 subsequent siblings)
  7 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:40 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 11:20:09 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 9d7fc9e..f19df8f 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -525,8 +525,9 @@ static int ahash_setkey(struct crypto_ahash *ahash,
 #endif
 
 	if (keylen > blocksize) {
-		hashed_key = kmalloc(sizeof(u8) * digestsize, GFP_KERNEL |
-				     GFP_DMA);
+		hashed_key = kmalloc_array(digestsize,
+					   sizeof(*hashed_key),
+					   GFP_KERNEL | GFP_DMA);
 		if (!hashed_key)
 			return -ENOMEM;
 		ret = hash_digest_key(ctx, key, &keylen, hashed_key,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] crypto-caamhash: Rename jump labels in ahash_setkey()
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-15 14:40   ` [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() SF Markus Elfring
@ 2016-09-15 14:41   ` SF Markus Elfring
  2016-09-15 14:42   ` [PATCH 3/6] crypto-caamhash: Rename a jump label in five functions SF Markus Elfring
                     ` (5 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:41 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 13:54:49 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index f19df8f..6017470 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -533,7 +533,7 @@ static int ahash_setkey(struct crypto_ahash *ahash,
 		ret = hash_digest_key(ctx, key, &keylen, hashed_key,
 				      digestsize);
 		if (ret)
-			goto badkey;
+			goto bad_free_key;
 		key = hashed_key;
 	}
 
@@ -551,14 +551,14 @@ static int ahash_setkey(struct crypto_ahash *ahash,
 
 	ret = gen_split_hash_key(ctx, key, keylen);
 	if (ret)
-		goto badkey;
+		goto bad_free_key;
 
 	ctx->key_dma = dma_map_single(jrdev, ctx->key, ctx->split_key_pad_len,
 				      DMA_TO_DEVICE);
 	if (dma_mapping_error(jrdev, ctx->key_dma)) {
 		dev_err(jrdev, "unable to map key i/o memory\n");
 		ret = -ENOMEM;
-		goto map_err;
+		goto error_free_key;
 	}
 #ifdef DEBUG
 	print_hex_dump(KERN_ERR, "ctx.key@"__stringify(__LINE__)": ",
@@ -571,11 +571,10 @@ static int ahash_setkey(struct crypto_ahash *ahash,
 		dma_unmap_single(jrdev, ctx->key_dma, ctx->split_key_pad_len,
 				 DMA_TO_DEVICE);
 	}
-
-map_err:
+ error_free_key:
 	kfree(hashed_key);
 	return ret;
-badkey:
+ bad_free_key:
 	kfree(hashed_key);
 	crypto_ahash_set_flags(ahash, CRYPTO_TFM_RES_BAD_KEY_LEN);
 	return -EINVAL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] crypto-caamhash: Rename a jump label in five functions
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-15 14:40   ` [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() SF Markus Elfring
  2016-09-15 14:41   ` [PATCH 2/6] crypto-caamhash: Rename jump labels " SF Markus Elfring
@ 2016-09-15 14:42   ` SF Markus Elfring
  2016-09-15 14:43   ` [PATCH 4/6] crypto-caamhash: Return a value directly in caam_hash_cra_init() SF Markus Elfring
                     ` (4 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:42 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 14:43:38 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 49 +++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 6017470..933252f 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -889,7 +889,7 @@ static int ahash_update_ctx(struct ahash_request *req)
 		ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
 					 edesc->sec4_sg, DMA_BIDIRECTIONAL);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 		state->buf_dma = try_buf_map_to_sec4_sg(jrdev,
 							edesc->sec4_sg + 1,
@@ -919,7 +919,7 @@ static int ahash_update_ctx(struct ahash_request *req)
 		if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) {
 			dev_err(jrdev, "unable to map S/G table\n");
 			ret = -ENOMEM;
-			goto err;
+			goto unmap_ctx;
 		}
 
 		append_seq_in_ptr(desc, edesc->sec4_sg_dma, ctx->ctx_len +
@@ -935,7 +935,7 @@ static int ahash_update_ctx(struct ahash_request *req)
 
 		ret = caam_jr_enqueue(jrdev, desc, ahash_done_bi, req);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 		ret = -EINPROGRESS;
 	} else if (*next_buflen) {
@@ -953,8 +953,7 @@ static int ahash_update_ctx(struct ahash_request *req)
 #endif
 
 	return ret;
-
- err:
+ unmap_ctx:
 	ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_BIDIRECTIONAL);
 	kfree(edesc);
 	return ret;
@@ -996,7 +995,7 @@ static int ahash_final_ctx(struct ahash_request *req)
 	ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
 				 edesc->sec4_sg, DMA_TO_DEVICE);
 	if (ret)
-		goto err;
+		goto unmap_ctx;
 
 	state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1,
 						buf, state->buf_dma, buflen,
@@ -1009,7 +1008,7 @@ static int ahash_final_ctx(struct ahash_request *req)
 	if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) {
 		dev_err(jrdev, "unable to map S/G table\n");
 		ret = -ENOMEM;
-		goto err;
+		goto unmap_ctx;
 	}
 
 	append_seq_in_ptr(desc, edesc->sec4_sg_dma, ctx->ctx_len + buflen,
@@ -1020,7 +1019,7 @@ static int ahash_final_ctx(struct ahash_request *req)
 	if (dma_mapping_error(jrdev, edesc->dst_dma)) {
 		dev_err(jrdev, "unable to map dst\n");
 		ret = -ENOMEM;
-		goto err;
+		goto unmap_ctx;
 	}
 
 #ifdef DEBUG
@@ -1030,11 +1029,10 @@ static int ahash_final_ctx(struct ahash_request *req)
 
 	ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_src, req);
 	if (ret)
-		goto err;
+		goto unmap_ctx;
 
 	return -EINPROGRESS;
-
-err:
+ unmap_ctx:
 	ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
 	kfree(edesc);
 	return ret;
@@ -1094,7 +1092,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
 	ret = ctx_map_to_sec4_sg(desc, jrdev, state, ctx->ctx_len,
 				 edesc->sec4_sg, DMA_TO_DEVICE);
 	if (ret)
-		goto err;
+		goto unmap_ctx;
 
 	state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1,
 						buf, state->buf_dma, buflen,
@@ -1104,14 +1102,14 @@ static int ahash_finup_ctx(struct ahash_request *req)
 				  sec4_sg_src_index, ctx->ctx_len + buflen,
 				  req->nbytes);
 	if (ret)
-		goto err;
+		goto unmap_ctx;
 
 	edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
 						digestsize);
 	if (dma_mapping_error(jrdev, edesc->dst_dma)) {
 		dev_err(jrdev, "unable to map dst\n");
 		ret = -ENOMEM;
-		goto err;
+		goto unmap_ctx;
 	}
 
 #ifdef DEBUG
@@ -1121,11 +1119,10 @@ static int ahash_finup_ctx(struct ahash_request *req)
 
 	ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_src, req);
 	if (ret)
-		goto err;
+		goto unmap_ctx;
 
 	return -EINPROGRESS;
-
-err:
+ unmap_ctx:
 	ahash_unmap_ctx(jrdev, edesc, req, digestsize, DMA_FROM_DEVICE);
 	kfree(edesc);
 	return ret;
@@ -1350,14 +1347,14 @@ static int ahash_update_no_ctx(struct ahash_request *req)
 		if (dma_mapping_error(jrdev, edesc->sec4_sg_dma)) {
 			dev_err(jrdev, "unable to map S/G table\n");
 			ret = -ENOMEM;
-			goto err;
+			goto unmap_ctx;
 		}
 
 		append_seq_in_ptr(desc, edesc->sec4_sg_dma, to_hash, LDST_SGF);
 
 		ret = map_seq_out_ptr_ctx(desc, jrdev, state, ctx->ctx_len);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 #ifdef DEBUG
 		print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
@@ -1367,7 +1364,7 @@ static int ahash_update_no_ctx(struct ahash_request *req)
 
 		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 		ret = -EINPROGRESS;
 		state->update = ahash_update_ctx;
@@ -1388,8 +1385,7 @@ static int ahash_update_no_ctx(struct ahash_request *req)
 #endif
 
 	return ret;
-
-err:
+ unmap_ctx:
 	ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_TO_DEVICE);
 	kfree(edesc);
 	return ret;
@@ -1548,7 +1544,7 @@ static int ahash_update_first(struct ahash_request *req)
 		ret = ahash_edesc_add_src(ctx, edesc, req, mapped_nents, 0, 0,
 					  to_hash);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 		if (*next_buflen)
 			scatterwalk_map_and_copy(next_buf, req->src, to_hash,
@@ -1558,7 +1554,7 @@ static int ahash_update_first(struct ahash_request *req)
 
 		ret = map_seq_out_ptr_ctx(desc, jrdev, state, ctx->ctx_len);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 #ifdef DEBUG
 		print_hex_dump(KERN_ERR, "jobdesc@"__stringify(__LINE__)": ",
@@ -1568,7 +1564,7 @@ static int ahash_update_first(struct ahash_request *req)
 
 		ret = caam_jr_enqueue(jrdev, desc, ahash_done_ctx_dst, req);
 		if (ret)
-			goto err;
+			goto unmap_ctx;
 
 		ret = -EINPROGRESS;
 		state->update = ahash_update_ctx;
@@ -1588,8 +1584,7 @@ static int ahash_update_first(struct ahash_request *req)
 #endif
 
 	return ret;
-
-err:
+ unmap_ctx:
 	ahash_unmap_ctx(jrdev, edesc, req, ctx->ctx_len, DMA_TO_DEVICE);
 	kfree(edesc);
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] crypto-caamhash: Return a value directly in caam_hash_cra_init()
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-15 14:42   ` [PATCH 3/6] crypto-caamhash: Rename a jump label in five functions SF Markus Elfring
@ 2016-09-15 14:43   ` SF Markus Elfring
  2016-09-15 14:44   ` [PATCH 5/6] crypto-caamhash: Delete an unnecessary initialisation in seven functions SF Markus Elfring
                     ` (3 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:43 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 14:56:12 +0200

* Return a value at the end without storing it in an intermediate variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index 933252f..b1dbc53 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -1846,7 +1846,6 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
 					 HASH_MSG_LEN + SHA256_DIGEST_SIZE,
 					 HASH_MSG_LEN + 64,
 					 HASH_MSG_LEN + SHA512_DIGEST_SIZE };
-	int ret = 0;
 
 	/*
 	 * Get a Job ring from Job Ring driver to ensure in-order
@@ -1866,10 +1865,7 @@ static int caam_hash_cra_init(struct crypto_tfm *tfm)
 
 	crypto_ahash_set_reqsize(__crypto_ahash_cast(tfm),
 				 sizeof(struct caam_hash_state));
-
-	ret = ahash_set_sh_desc(ahash);
-
-	return ret;
+	return ahash_set_sh_desc(ahash);
 }
 
 static void caam_hash_cra_exit(struct crypto_tfm *tfm)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] crypto-caamhash: Delete an unnecessary initialisation in seven functions
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-15 14:43   ` [PATCH 4/6] crypto-caamhash: Return a value directly in caam_hash_cra_init() SF Markus Elfring
@ 2016-09-15 14:44   ` SF Markus Elfring
  2016-09-15 14:45   ` [PATCH 6/6] crypto-caamhash: Move common error handling code in two functions SF Markus Elfring
                     ` (2 subsequent siblings)
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:44 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 15:24:02 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index b1dbc53..adb8b19 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -440,7 +440,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in,
 	u32 *desc;
 	struct split_key_result result;
 	dma_addr_t src_dma, dst_dma;
-	int ret = 0;
+	int ret;
 
 	desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA);
 	if (!desc) {
@@ -517,7 +517,7 @@ static int ahash_setkey(struct crypto_ahash *ahash,
 	struct device *jrdev = ctx->jrdev;
 	int blocksize = crypto_tfm_alg_blocksize(&ahash->base);
 	int digestsize = crypto_ahash_digestsize(ahash);
-	int ret = 0;
+	int ret;
 	u8 *hashed_key = NULL;
 
 #ifdef DEBUG
@@ -975,7 +975,7 @@ static int ahash_final_ctx(struct ahash_request *req)
 	int sec4_sg_bytes, sec4_sg_src_index;
 	int digestsize = crypto_ahash_digestsize(ahash);
 	struct ahash_edesc *edesc;
-	int ret = 0;
+	int ret;
 
 	sec4_sg_src_index = 1 + (buflen ? 1 : 0);
 	sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry);
@@ -1055,7 +1055,7 @@ static int ahash_finup_ctx(struct ahash_request *req)
 	int src_nents, mapped_nents;
 	int digestsize = crypto_ahash_digestsize(ahash);
 	struct ahash_edesc *edesc;
-	int ret = 0;
+	int ret;
 
 	src_nents = sg_nents_for_len(req->src, req->nbytes);
 	if (src_nents < 0) {
@@ -1139,7 +1139,7 @@ static int ahash_digest(struct ahash_request *req)
 	int digestsize = crypto_ahash_digestsize(ahash);
 	int src_nents, mapped_nents;
 	struct ahash_edesc *edesc;
-	int ret = 0;
+	int ret;
 
 	src_nents = sg_nents_for_len(req->src, req->nbytes);
 	if (src_nents < 0) {
@@ -1218,7 +1218,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
 	u32 *desc;
 	int digestsize = crypto_ahash_digestsize(ahash);
 	struct ahash_edesc *edesc;
-	int ret = 0;
+	int ret;
 
 	/* allocate space for base edesc and hw desc commands, link tables */
 	edesc = ahash_edesc_alloc(ctx, 0, ctx->sh_desc_digest,
@@ -1408,7 +1408,7 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
 	int sec4_sg_bytes, sec4_sg_src_index, src_nents, mapped_nents;
 	int digestsize = crypto_ahash_digestsize(ahash);
 	struct ahash_edesc *edesc;
-	int ret = 0;
+	int ret;
 
 	src_nents = sg_nents_for_len(req->src, req->nbytes);
 	if (src_nents < 0) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] crypto-caamhash: Move common error handling code in two functions
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-15 14:44   ` [PATCH 5/6] crypto-caamhash: Delete an unnecessary initialisation in seven functions SF Markus Elfring
@ 2016-09-15 14:45   ` SF Markus Elfring
  2016-09-15 15:30   ` crypto-caamhash: Fine-tuning for several function implementations Horia Geanta Neag
  2016-09-22 10:44   ` Herbert Xu
  7 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 14:45 UTC (permalink / raw)
  To: linux-crypto, David S. Miller, Herbert Xu, Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 15 Sep 2016 16:00:55 +0200

Move statements for error handling which were identical
in two if branches to the end of these functions.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/crypto/caam/caamhash.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index adb8b19..660dc20 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -1231,9 +1231,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
 	state->buf_dma = dma_map_single(jrdev, buf, buflen, DMA_TO_DEVICE);
 	if (dma_mapping_error(jrdev, state->buf_dma)) {
 		dev_err(jrdev, "unable to map src\n");
-		ahash_unmap(jrdev, edesc, req, digestsize);
-		kfree(edesc);
-		return -ENOMEM;
+		goto unmap;
 	}
 
 	append_seq_in_ptr(desc, state->buf_dma, buflen, 0);
@@ -1242,9 +1240,7 @@ static int ahash_final_no_ctx(struct ahash_request *req)
 						digestsize);
 	if (dma_mapping_error(jrdev, edesc->dst_dma)) {
 		dev_err(jrdev, "unable to map dst\n");
-		ahash_unmap(jrdev, edesc, req, digestsize);
-		kfree(edesc);
-		return -ENOMEM;
+		goto unmap;
 	}
 	edesc->src_nents = 0;
 
@@ -1262,6 +1258,11 @@ static int ahash_final_no_ctx(struct ahash_request *req)
 	}
 
 	return ret;
+ unmap:
+	ahash_unmap(jrdev, edesc, req, digestsize);
+	kfree(edesc);
+	return -ENOMEM;
+
 }
 
 /* submit ahash update if it the first job descriptor after update */
@@ -1453,18 +1454,14 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
 				  req->nbytes);
 	if (ret) {
 		dev_err(jrdev, "unable to map S/G table\n");
-		ahash_unmap(jrdev, edesc, req, digestsize);
-		kfree(edesc);
-		return -ENOMEM;
+		goto unmap;
 	}
 
 	edesc->dst_dma = map_seq_out_ptr_result(desc, jrdev, req->result,
 						digestsize);
 	if (dma_mapping_error(jrdev, edesc->dst_dma)) {
 		dev_err(jrdev, "unable to map dst\n");
-		ahash_unmap(jrdev, edesc, req, digestsize);
-		kfree(edesc);
-		return -ENOMEM;
+		goto unmap;
 	}
 
 #ifdef DEBUG
@@ -1481,6 +1478,11 @@ static int ahash_finup_no_ctx(struct ahash_request *req)
 	}
 
 	return ret;
+ unmap:
+	ahash_unmap(jrdev, edesc, req, digestsize);
+	kfree(edesc);
+	return -ENOMEM;
+
 }
 
 /* submit first update job descriptor after init */
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey()
  2016-09-15 14:40   ` [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() SF Markus Elfring
@ 2016-09-15 15:12     ` Horia Geanta Neag
  0 siblings, 0 replies; 1373+ messages in thread
From: Horia Geanta Neag @ 2016-09-15 15:12 UTC (permalink / raw)
  To: SF Markus Elfring, linux-crypto, David S. Miller, Herbert Xu,
	Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

On 9/15/2016 5:43 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 15 Sep 2016 11:20:09 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/crypto/caam/caamhash.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
> index 9d7fc9e..f19df8f 100644
> --- a/drivers/crypto/caam/caamhash.c
> +++ b/drivers/crypto/caam/caamhash.c
> @@ -525,8 +525,9 @@ static int ahash_setkey(struct crypto_ahash *ahash,
>  #endif
>  
>  	if (keylen > blocksize) {
> -		hashed_key = kmalloc(sizeof(u8) * digestsize, GFP_KERNEL |
> -				     GFP_DMA);
> +		hashed_key = kmalloc_array(digestsize,
> +					   sizeof(*hashed_key),
> +					   GFP_KERNEL | GFP_DMA);
While correct, instead I would go with kmalloc() and get rid of sizeof(u8).

Horia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: crypto-caamhash: Fine-tuning for several function implementations
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-15 14:45   ` [PATCH 6/6] crypto-caamhash: Move common error handling code in two functions SF Markus Elfring
@ 2016-09-15 15:30   ` Horia Geanta Neag
  2016-09-22 10:44   ` Herbert Xu
  7 siblings, 0 replies; 1373+ messages in thread
From: Horia Geanta Neag @ 2016-09-15 15:30 UTC (permalink / raw)
  To: SF Markus Elfring, linux-crypto, David S. Miller, Herbert Xu,
	Labbe Corentin, Russell King
  Cc: LKML, kernel-janitors, Julia Lawall

On 9/15/2016 5:37 PM, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 15 Sep 2016 16:27:23 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (6):
>   Use kmalloc_array() in ahash_setkey()
>   Rename jump labels in ahash_setkey()
>   Rename a jump label in five functions
>   Return a value directly in caam_hash_cra_init()
>   Delete an unnecessary initialisation in seven functions
>   Move common error handling code in two functions
> 
>  drivers/crypto/caam/caamhash.c | 111 +++++++++++++++++++----------------------
>  1 file changed, 52 insertions(+), 59 deletions(-)
> 
Thanks Markus!

For patches 2-6:
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

though headline prefix should be changed to "crypto: caam -"

Horia

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in uninorth_create_gatt_table()
  2016-09-13 20:48   ` [PATCH 6/7] AGPGART-UniNorth: Rename a jump label " SF Markus Elfring
@ 2016-09-15 17:37     ` kbuild test robot
  2016-09-15 18:26       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: kbuild test robot @ 2016-09-15 17:37 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: kbuild-all, kernel-janitors, David Airlie, LKML, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 2472 bytes --]

Hi Markus,

[auto build test ERROR on drm/drm-next]
[also build test ERROR on v4.8-rc6 next-20160915]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
[Suggest to use git(>=2.9.0) format-patch --base=<commit> (or --base=auto for convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:    https://github.com/0day-ci/linux/commits/SF-Markus-Elfring/AGPGART-Fine-tuning-for-four-function-implementations/20160914-045406
base:   git://people.freedesktop.org/~airlied/linux.git drm-next
config: powerpc-pmac32_defconfig (attached as .config)
compiler: powerpc-linux-gnu-gcc (Debian 5.4.0-6) 5.4.0 20160609
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=powerpc 

All errors (new ones prefixed by >>):

   drivers/char/agp/uninorth-agp.c: In function 'uninorth_create_gatt_table':
>> drivers/char/agp/uninorth-agp.c:426:3: error: label 'enomem' used but not defined
      goto enomem;
      ^

vim +/enomem +426 drivers/char/agp/uninorth-agp.c

e8a5f9001 Michel Dänzer   2009-08-04  420  	/* Need to clear out any dirty data still sitting in caches */
e8a5f9001 Michel Dänzer   2009-08-04  421  	flush_dcache_range((unsigned long)table,
79905ad50 Paul Mackerras  2010-06-01  422  			   (unsigned long)table_end + 1);
5ada62b10 Denis Kirjanov  2015-06-12  423  	bridge->gatt_table = vmap(uninorth_priv.pages_arr, (1 << page_order), 0, PAGE_KERNEL_NCG);
e8a5f9001 Michel Dänzer   2009-08-04  424  
e8a5f9001 Michel Dänzer   2009-08-04  425  	if (bridge->gatt_table == NULL)
e8a5f9001 Michel Dänzer   2009-08-04 @426  		goto enomem;
e8a5f9001 Michel Dänzer   2009-08-04  427  
6a12235c7 David Woodhouse 2009-07-29  428  	bridge->gatt_bus_addr = virt_to_phys(table);
^1da177e4 Linus Torvalds  2005-04-16  429  

:::::: The code at line 426 was first introduced by commit
:::::: e8a5f900148d058bce2d7bdce3d6bcbcb40267ec agp/uninorth: Simplify cache flushing.

:::::: TO: Michel Dänzer <daenzer@vmware.com>
:::::: CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 21903 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/7] AGPGART-UniNorth: Rename a jump label in uninorth_create_gatt_table()
  2016-09-15 17:37     ` kbuild test robot
@ 2016-09-15 18:26       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 18:26 UTC (permalink / raw)
  To: kernel-janitors, David Airlie
  Cc: kbuild test robot, kbuild-all, LKML, Julia Lawall

>    drivers/char/agp/uninorth-agp.c: In function 'uninorth_create_gatt_table':
>>> drivers/char/agp/uninorth-agp.c:426:3: error: label 'enomem' used but not defined
>       goto enomem;
>       ^
> 
> vim +/enomem +426 drivers/char/agp/uninorth-agp.c

This error message points a glitch out which was triggered by my update suggestion.
Unfortunately, it means that the proposed renaming of such an identifier was incomplete
at this source code place.

In which ways would you like to improve the shown software situation?

* Would you like to fix a single identifier anyhow directly?

* Do you expect that I should resend a corrected patch series as a whole package?

* Would it be sufficient to send another update only for the software module
  "AGPGART-UniNorth" a bit later?

* Can I worry about this programming mistake a bit less just because
  the suggested renaming would eventually be rejected?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-14 20:01   ` [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation SF Markus Elfring
@ 2016-09-15 19:07     ` Geert Uytterhoeven
  2016-09-15 19:13       ` Laurent Pinchart
  0 siblings, 1 reply; 1373+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 19:07 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall, Wolfram Sang

On Wed, Sep 14, 2016 at 10:01 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 21:17:18 +0200
>
> Omit an extra message for a memory allocation failure in this function.
>
> Link: http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refactor_Strings-WSang_0.pdf
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection
  2016-09-14 20:03   ` [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection SF Markus Elfring
@ 2016-09-15 19:11     ` Geert Uytterhoeven
  2016-09-15 20:40       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 19:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

On Wed, Sep 14, 2016 at 10:03 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 21:30:27 +0200
>
> The kfree() function was called in up to two cases
> by the cpg_mstp_clocks_init() function during error handling even if
> the passed variable contained a null pointer.

It's perfectly legal to call kfree() on a NULL pointer.

> * Split a condition check for memory allocation failures so that
>   each pointer from these function calls will be checked immediately.
>
>   See also background information:
>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>   Link: https://cwe.mitre.org/data/definitions/754.html
>
> * Return directly after a call of the function "kzalloc" failed
>   at the beginning.

Both calls are already close together.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/clk/renesas/clk-mstp.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

In addition, your patch increases the LoC, IMHO without improving the code.

>
> diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
> index 1fdc44b..6c82e0e 100644
> --- a/drivers/clk/renesas/clk-mstp.c
> +++ b/drivers/clk/renesas/clk-mstp.c
> @@ -167,10 +167,12 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
>         unsigned int i;
>
>         group = kzalloc(sizeof(*group), GFP_KERNEL);
> +       if (!group)
> +               return;
> +
>         clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL);
> -       if (group == NULL || clks == NULL) {
> +       if (!clks) {
>                 kfree(group);
> -               kfree(clks);
>                 return;
>         }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init()
  2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
@ 2016-09-15 19:11     ` Geert Uytterhoeven
  2016-09-16 23:13     ` Stephen Boyd
  1 sibling, 0 replies; 1373+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 19:11 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

On Wed, Sep 14, 2016 at 10:00 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 21:10:47 +0200
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-15 19:07     ` Geert Uytterhoeven
@ 2016-09-15 19:13       ` Laurent Pinchart
  2016-09-15 19:41         ` Wolfram Sang
  2016-09-15 20:17         ` SF Markus Elfring
  0 siblings, 2 replies; 1373+ messages in thread
From: Laurent Pinchart @ 2016-09-15 19:13 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: SF Markus Elfring, linux-clk, Geert Uytterhoeven,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall, Wolfram Sang

On Thursday 15 Sep 2016 21:07:17 Geert Uytterhoeven wrote:
> On Wed, Sep 14, 2016 at 10:01 PM, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Wed, 14 Sep 2016 21:17:18 +0200
> > 
> > Omit an extra message for a memory allocation failure in this function.
> > 
> > Link:
> > http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refacto
> > r_Strings-WSang_0.pdf
> > 
> > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> 
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

There are two other memory allocation failures printed by drivers in the same 
directory that, you'll get my ack if you extend this patch to remove the three 
messages in one go.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev()
  2016-09-14 20:04   ` [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev() SF Markus Elfring
@ 2016-09-15 19:18     ` Geert Uytterhoeven
  2016-09-16  6:00       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 19:18 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

Hi Markus,

On Wed, Sep 14, 2016 at 10:04 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 21:41:50 +0200
>
> Adjust jump labels according to the current Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/clk/renesas/clk-mstp.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
> index 6c82e0e..2f90718 100644
> --- a/drivers/clk/renesas/clk-mstp.c
> +++ b/drivers/clk/renesas/clk-mstp.c
> @@ -256,19 +256,18 @@ int cpg_mstp_attach_dev(struct generic_pm_domain *unused, struct device *dev)
>                                            &clkspec)) {
>                 if (of_device_is_compatible(clkspec.np,
>                                             "renesas,cpg-mstp-clocks"))
> -                       goto found;
> +                       goto get_clk;
>
>                 /* BSC on r8a73a4/sh73a0 uses zb_clk instead of an mstp clock */
>                 if (!strcmp(clkspec.np->name, "zb_clk"))
> -                       goto found;
> +                       goto get_clk;
>
>                 of_node_put(clkspec.np);
>                 i++;
>         }
>
>         return 0;
> -
> -found:
> + get_clk:

"Choose label names which say what the goto does or why the goto exists."

I prefer the "why" over the "what".

And the "indent labels with a single space" rule will be removed soon, as
there's no longer a technical reason for it after
https://lkml.org/lkml/2016/9/7/316

>         clk = of_clk_get_from_provider(&clkspec);
>         of_node_put(clkspec.np);
>
> @@ -278,20 +277,19 @@ found:
>         error = pm_clk_create(dev);
>         if (error) {
>                 dev_err(dev, "pm_clk_create failed %d\n", error);
> -               goto fail_put;
> +               goto put_clk;
>         }
>
>         error = pm_clk_add_clk(dev, clk);
>         if (error) {
>                 dev_err(dev, "pm_clk_add_clk %pC failed %d\n", clk, error);
> -               goto fail_destroy;
> +               goto destroy_clk;
>         }
>
>         return 0;
> -
> -fail_destroy:
> + destroy_clk:
>         pm_clk_destroy(dev);
> -fail_put:
> + put_clk:

Same here.

>         clk_put(clk);
>         return error;
>  }

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-15 19:13       ` Laurent Pinchart
@ 2016-09-15 19:41         ` Wolfram Sang
  2016-09-15 20:17         ` SF Markus Elfring
  1 sibling, 0 replies; 1373+ messages in thread
From: Wolfram Sang @ 2016-09-15 19:41 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Geert Uytterhoeven, SF Markus Elfring, linux-clk,
	Geert Uytterhoeven, Michael Turquette, Simon Horman,
	Stephen Boyd, Ulf Hansson, LKML, kernel-janitors, Julia Lawall

[-- Attachment #1: Type: text/plain, Size: 868 bytes --]

On Thu, Sep 15, 2016 at 10:13:17PM +0300, Laurent Pinchart wrote:
> On Thursday 15 Sep 2016 21:07:17 Geert Uytterhoeven wrote:
> > On Wed, Sep 14, 2016 at 10:01 PM, SF Markus Elfring wrote:
> > > From: Markus Elfring <elfring@users.sourceforge.net>
> > > Date: Wed, 14 Sep 2016 21:17:18 +0200
> > > 
> > > Omit an extra message for a memory allocation failure in this function.
> > > 
> > > Link:
> > > http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refacto
> > > r_Strings-WSang_0.pdf
> > > 
> > > Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> > 
> > Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> There are two other memory allocation failures printed by drivers in the same 
> directory that, you'll get my ack if you extend this patch to remove the three 
> messages in one go.

I agree.


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-15 19:13       ` Laurent Pinchart
  2016-09-15 19:41         ` Wolfram Sang
@ 2016-09-15 20:17         ` SF Markus Elfring
  2016-09-15 22:55           ` Laurent Pinchart
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 20:17 UTC (permalink / raw)
  To: Laurent Pinchart, Geert Uytterhoeven
  Cc: linux-clk, Geert Uytterhoeven, Michael Turquette, Simon Horman,
	Stephen Boyd, Ulf Hansson, LKML, kernel-janitors, Julia Lawall,
	Wolfram Sang

>>> Omit an extra message for a memory allocation failure in this function.
>>>
>>> Link:
>>> http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refacto
>>> r_Strings-WSang_0.pdf
>>>
>>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>>
>> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> 
> There are two other memory allocation failures printed by drivers in the same 
> directory that, you'll get my ack

Does this kind of feedback express a general acceptance for the deletion
of similar error messages?


> if you extend this patch to remove the three messages in one go.

Does this wish influence the handling of suggested changes for the source file
"drivers/clk/renesas/clk-mstp.c" anyhow?
https://patchwork.kernel.org/patch/9332363/

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection
  2016-09-15 19:11     ` Geert Uytterhoeven
@ 2016-09-15 20:40       ` SF Markus Elfring
  2016-09-15 20:48         ` Geert Uytterhoeven
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-15 20:40 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

> It's perfectly legal to call kfree() on a NULL pointer.

I know this function property well.


>> * Split a condition check for memory allocation failures so that
>>   each pointer from these function calls will be checked immediately.
>>
>>   See also background information:
>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>
>> * Return directly after a call of the function "kzalloc" failed
>>   at the beginning.
> 
> Both calls are already close together.

Can it be that an other software development concern is eventually
overlooked because of this "neighbourship" (or is categorised with
a lower priority)?

I suggest to reconsider this design detail if it is really acceptable
for the safe implementation of such a software module.

* How much will it matter in general that one function call was performed
  in this use case without checking its return values immediately?

* Should it usually be determined quicker if a required resource like
  memory could be acquired before trying the next allocation?


> In addition, your patch increases the LoC, IMHO without improving the code.

I find this consequence still debatable.


>> diff --git a/drivers/clk/renesas/clk-mstp.c b/drivers/clk/renesas/clk-mstp.c
>> index 1fdc44b..6c82e0e 100644
>> --- a/drivers/clk/renesas/clk-mstp.c
>> +++ b/drivers/clk/renesas/clk-mstp.c
>> @@ -167,10 +167,12 @@ static void __init cpg_mstp_clocks_init(struct device_node *np)
>>         unsigned int i;
>>
>>         group = kzalloc(sizeof(*group), GFP_KERNEL);
>> +       if (!group)
>> +               return;
>> +
>>         clks = kmalloc_array(MSTP_MAX_CLOCKS, sizeof(*clks), GFP_KERNEL);
>> -       if (group == NULL || clks == NULL) {
>> +       if (!clks) {
>>                 kfree(group);
>> -               kfree(clks);
>>                 return;
>>         }

Is this update suggestion worth for another look?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection
  2016-09-15 20:40       ` SF Markus Elfring
@ 2016-09-15 20:48         ` Geert Uytterhoeven
  2016-09-16  5:32           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Geert Uytterhoeven @ 2016-09-15 20:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

On Thu, Sep 15, 2016 at 10:40 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> * Split a condition check for memory allocation failures so that
>>>   each pointer from these function calls will be checked immediately.
>>>
>>>   See also background information:
>>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>>
>>> * Return directly after a call of the function "kzalloc" failed
>>>   at the beginning.
>>
>> Both calls are already close together.
>
> Can it be that an other software development concern is eventually
> overlooked because of this "neighbourship" (or is categorised with
> a lower priority)?
>
> I suggest to reconsider this design detail if it is really acceptable
> for the safe implementation of such a software module.
>
> * How much will it matter in general that one function call was performed
>   in this use case without checking its return values immediately?
>
> * Should it usually be determined quicker if a required resource like
>   memory could be acquired before trying the next allocation?

Note that if memory allocation fails in this driver, the system won't
boot at all. So even not checking for allocation failures at all could be
acceptable.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-15 20:17         ` SF Markus Elfring
@ 2016-09-15 22:55           ` Laurent Pinchart
  2016-09-16  5:21             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Laurent Pinchart @ 2016-09-15 22:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Geert Uytterhoeven, linux-clk, Geert Uytterhoeven,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall, Wolfram Sang

On Thursday 15 Sep 2016 22:17:41 SF Markus Elfring wrote:
> >>> Omit an extra message for a memory allocation failure in this function.
> >>> 
> >>> Link:
> >>> http://events.linuxfoundation.org/sites/events/files/slides/LCJ16-Refact
> >>> or_Strings-WSang_0.pdf
> >>> 
> >>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >> 
> >> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> > 
> > There are two other memory allocation failures printed by drivers in the
> > same directory that, you'll get my ack
> 
> Does this kind of feedback express a general acceptance for the deletion
> of similar error messages?

No, it's my opinion only.

> > if you extend this patch to remove the three messages in one go.
> 
> Does this wish influence the handling of suggested changes for the source
> file "drivers/clk/renesas/clk-mstp.c" anyhow?
> https://patchwork.kernel.org/patch/9332363/

Yes, please submit a new version of this patch that removes all the memory 
allocation error messages from drivers/clk/renesas/ in one go.

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: clk/Renesas-MSTP: Delete an error message for a failed memory allocation
  2016-09-15 22:55           ` Laurent Pinchart
@ 2016-09-16  5:21             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-16  5:21 UTC (permalink / raw)
  To: Laurent Pinchart, Wolfram Sang
  Cc: Geert Uytterhoeven, linux-clk, Geert Uytterhoeven,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

>> Does this wish influence the handling of suggested changes for the source
>> file "drivers/clk/renesas/clk-mstp.c" anyhow?
>> https://patchwork.kernel.org/patch/9332363/
> 
> Yes, please submit a new version of this patch that removes all the memory 
> allocation error messages from drivers/clk/renesas/ in one go.

I find this kind of feedback a bit surprising and it seems to be promising
to increase software development in this design direction.
Have you got any corresponding scripts for the semantic patch language
prepared to make such a source code adjustment safer (and a bit more convenient
with the help of the Coccinelle software)?

I am also curious on how the change acceptance will evolve for the other
three update steps from this patch series when this one indicates further
software update opportunities already.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection
  2016-09-15 20:48         ` Geert Uytterhoeven
@ 2016-09-16  5:32           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-16  5:32 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

>> * Should it usually be determined quicker if a required resource like
>>   memory could be acquired before trying the next allocation?
> 
> Note that if memory allocation fails in this driver, the system won't
> boot at all.

Thanks for this information.


> So even not checking for allocation failures at all could be acceptable.

I find this opinion interesting somehow.

I would generally prefer to check return values from various function calls
immediately instead of keeping the discussed source code structure unchanged.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev()
  2016-09-15 19:18     ` Geert Uytterhoeven
@ 2016-09-16  6:00       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-16  6:00 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Stephen Boyd, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall, linux-doc

> "Choose label names which say what the goto does or why the goto exists."
> 
> I prefer the "why" over the "what".

Does your opinion indicate also that you would appreciate another adjustment
around the quoted sentence from "Chapter 7: Centralized exiting of functions"
of the document "CodingStyle"?

Would you like to achieve that the potential for confusion will be reduced
a bit more there?


> And the "indent labels with a single space" rule will be removed soon,

I am unsure on how this "story" will evolve further.

Will the indentation rules become any more precise for Linux source code?


> as there's no longer a technical reason for it after
> https://lkml.org/lkml/2016/9/7/316

The software update "Set git diff driver for C source code files" is also
interesting for current versions.

Will language-specific rules which are supported by recent Git software
influence any capabilities for the command "diff --show-c-function"?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init()
  2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
  2016-09-15 19:11     ` Geert Uytterhoeven
@ 2016-09-16 23:13     ` Stephen Boyd
  1 sibling, 0 replies; 1373+ messages in thread
From: Stephen Boyd @ 2016-09-16 23:13 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-clk, Geert Uytterhoeven, Laurent Pinchart,
	Michael Turquette, Simon Horman, Ulf Hansson, LKML,
	kernel-janitors, Julia Lawall

On 09/14, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 21:10:47 +0200
> 
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---

Applied to clk-next

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/24] ste_dma40: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (83 preceding siblings ...)
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-17 15:05 ` SF Markus Elfring
  2016-09-17 15:07   ` [PATCH 01/24] ste_dma40: Use kmalloc_array() in d40_lcla_allocate() SF Markus Elfring
                     ` (24 more replies)
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                   ` (10 subsequent siblings)
  95 siblings, 25 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:05 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:56:56 +0200

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

Markus Elfring (24):
  Use kmalloc_array() in d40_lcla_allocate()
  Return directly after a failed kmalloc_array()
  Rename a jump label in d40_lcla_allocate()
  Move an assignment in d40_lcla_allocate()
  Improve a size determination in d40_of_probe()
  Replace four kzalloc() calls by kcalloc() in d40_hw_detect_init()
  Use kmalloc_array() in d40_hw_detect_init()
  Less checks in d40_hw_detect_init() after error detection
  Delete unnecessary variable initialisations in d40_hw_detect_init()
  Adjust the position of a jump label in d40_probe()
  Rename a jump label in d40_probe()
  Rename jump labels in d40_dmaengine_init()
  Rename a jump label in d40_alloc_chan_resources()
  One check less in d40_prep_sg() after error detection
  Move two assignments in d40_prep_sg()
  Rename a jump label in d40_prep_desc()
  Move an assignment in d40_prep_desc()
  Rename a jump label in d40_is_paused()
  Rename a jump label in d40_free_dma()
  Rename a jump label in d40_alloc_mask_free()
  Rename jump labels in d40_alloc_mask_set()
  Rename a jump label in dma_tasklet()
  Rename a jump label in __d40_execute_command_phy()
  Rename a jump label in d40_log_lli_to_lcxa()

 drivers/dma/ste_dma40.c | 253 +++++++++++++++++++++++-------------------------
 1 file changed, 122 insertions(+), 131 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/24] ste_dma40: Use kmalloc_array() in d40_lcla_allocate()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
@ 2016-09-17 15:07   ` SF Markus Elfring
  2016-09-17 15:08   ` [PATCH 02/24] ste_dma40: Return directly after a failed kmalloc_array() SF Markus Elfring
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:07 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 16 Sep 2016 17:56:07 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 73203ac..fbebeff 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3409,9 +3409,9 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 	 * To full fill this hardware requirement without wasting 256 kb
 	 * we allocate pages until we get an aligned one.
 	 */
-	page_list = kmalloc(sizeof(unsigned long) * MAX_LCLA_ALLOC_ATTEMPTS,
-			    GFP_KERNEL);
-
+	page_list = kmalloc_array(MAX_LCLA_ALLOC_ATTEMPTS,
+				  sizeof(*page_list),
+				  GFP_KERNEL);
 	if (!page_list) {
 		ret = -ENOMEM;
 		goto failure;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/24] ste_dma40: Return directly after a failed kmalloc_array()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
  2016-09-17 15:07   ` [PATCH 01/24] ste_dma40: Use kmalloc_array() in d40_lcla_allocate() SF Markus Elfring
@ 2016-09-17 15:08   ` SF Markus Elfring
  2016-09-17 15:09   ` [PATCH 03/24] ste_dma40: Rename a jump label in d40_lcla_allocate() SF Markus Elfring
                     ` (22 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:08 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 08:21:30 +0200

Return directly after a memory allocation failed in this function
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index fbebeff..80a199a 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3412,10 +3412,8 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 	page_list = kmalloc_array(MAX_LCLA_ALLOC_ATTEMPTS,
 				  sizeof(*page_list),
 				  GFP_KERNEL);
-	if (!page_list) {
-		ret = -ENOMEM;
-		goto failure;
-	}
+	if (!page_list)
+		return -ENOMEM;
 
 	/* Calculating how many pages that are required */
 	base->lcla_pool.pages = SZ_1K * base->num_phy_chans / PAGE_SIZE;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/24] ste_dma40: Rename a jump label in d40_lcla_allocate()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
  2016-09-17 15:07   ` [PATCH 01/24] ste_dma40: Use kmalloc_array() in d40_lcla_allocate() SF Markus Elfring
  2016-09-17 15:08   ` [PATCH 02/24] ste_dma40: Return directly after a failed kmalloc_array() SF Markus Elfring
@ 2016-09-17 15:09   ` SF Markus Elfring
  2016-09-17 15:10   ` [PATCH 04/24] ste_dma40: Move an assignment " SF Markus Elfring
                     ` (21 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:09 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 08:23:37 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 80a199a..76d63b6 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3429,7 +3429,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 
 			for (j = 0; j < i; j++)
 				free_pages(page_list[j], base->lcla_pool.pages);
-			goto failure;
+			goto free_page_list;
 		}
 
 		if ((virt_to_phys((void *)page_list[i]) &
@@ -3456,7 +3456,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 							 GFP_KERNEL);
 		if (!base->lcla_pool.base_unaligned) {
 			ret = -ENOMEM;
-			goto failure;
+			goto free_page_list;
 		}
 
 		base->lcla_pool.base = PTR_ALIGN(base->lcla_pool.base_unaligned,
@@ -3469,12 +3469,12 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 	if (dma_mapping_error(base->dev, pool->dma_addr)) {
 		pool->dma_addr = 0;
 		ret = -ENOMEM;
-		goto failure;
+		goto free_page_list;
 	}
 
 	writel(virt_to_phys(base->lcla_pool.base),
 	       base->virtbase + D40_DREG_LCLA);
-failure:
+ free_page_list:
 	kfree(page_list);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/24] ste_dma40: Move an assignment in d40_lcla_allocate()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-17 15:09   ` [PATCH 03/24] ste_dma40: Rename a jump label in d40_lcla_allocate() SF Markus Elfring
@ 2016-09-17 15:10   ` SF Markus Elfring
  2016-09-17 15:11   ` [PATCH 05/24] ste_dma40: Improve a size determination in d40_of_probe() SF Markus Elfring
                     ` (20 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:10 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 08:24:46 +0200

Move one assignment for the local variable "ret" so that its setting
will only be performed after corresponding data processing succeeded
by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 76d63b6..220129e 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3402,7 +3402,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 	struct d40_lcla_pool *pool = &base->lcla_pool;
 	unsigned long *page_list;
 	int i, j;
-	int ret = 0;
+	int ret;
 
 	/*
 	 * This is somewhat ugly. We need 8192 bytes that are 18 bit aligned,
@@ -3474,6 +3474,7 @@ static int __init d40_lcla_allocate(struct d40_base *base)
 
 	writel(virt_to_phys(base->lcla_pool.base),
 	       base->virtbase + D40_DREG_LCLA);
+	ret = 0;
  free_page_list:
 	kfree(page_list);
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/24] ste_dma40: Improve a size determination in d40_of_probe()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-17 15:10   ` [PATCH 04/24] ste_dma40: Move an assignment " SF Markus Elfring
@ 2016-09-17 15:11   ` SF Markus Elfring
  2016-09-17 15:12   ` [PATCH 06/24] ste_dma40: Replace four kzalloc() calls by kcalloc() in d40_hw_detect_init() SF Markus Elfring
                     ` (19 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:11 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 08:28:05 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 220129e..57d87a8 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3487,9 +3487,7 @@ static int __init d40_of_probe(struct platform_device *pdev,
 	int num_phy = 0, num_memcpy = 0, num_disabled = 0;
 	const __be32 *list;
 
-	pdata = devm_kzalloc(&pdev->dev,
-			     sizeof(struct stedma40_platform_data),
-			     GFP_KERNEL);
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
 	if (!pdata)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/24] ste_dma40: Replace four kzalloc() calls by kcalloc() in d40_hw_detect_init()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-17 15:11   ` [PATCH 05/24] ste_dma40: Improve a size determination in d40_of_probe() SF Markus Elfring
@ 2016-09-17 15:12   ` SF Markus Elfring
  2016-09-17 15:15   ` [PATCH 07/24] ste_dma40: Use kmalloc_array() " SF Markus Elfring
                     ` (18 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:12 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 09:56:32 +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 types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 57d87a8..b5d15a1 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3281,19 +3281,20 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 		base->gen_dmac.init_reg_size = ARRAY_SIZE(dma_init_reg_v4a);
 	}
 
-	base->phy_res = kzalloc(num_phy_chans * sizeof(struct d40_phy_res),
+	base->phy_res = kcalloc(num_phy_chans,
+				sizeof(*base->phy_res),
 				GFP_KERNEL);
 	if (!base->phy_res)
 		goto failure;
 
-	base->lookup_phy_chans = kzalloc(num_phy_chans *
-					 sizeof(struct d40_chan *),
+	base->lookup_phy_chans = kcalloc(num_phy_chans,
+					 sizeof(*base->lookup_phy_chans),
 					 GFP_KERNEL);
 	if (!base->lookup_phy_chans)
 		goto failure;
 
-	base->lookup_log_chans = kzalloc(num_log_chans *
-					 sizeof(struct d40_chan *),
+	base->lookup_log_chans = kcalloc(num_log_chans,
+					 sizeof(*base->lookup_log_chans),
 					 GFP_KERNEL);
 	if (!base->lookup_log_chans)
 		goto failure;
@@ -3304,9 +3305,10 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	if (!base->reg_val_backup_chan)
 		goto failure;
 
-	base->lcla_pool.alloc_map =
-		kzalloc(num_phy_chans * sizeof(struct d40_desc *)
-			* D40_LCLA_LINK_PER_EVENT_GRP, GFP_KERNEL);
+	base->lcla_pool.alloc_map = kcalloc(num_phy_chans
+					    * D40_LCLA_LINK_PER_EVENT_GRP,
+					    sizeof(*base->lcla_pool.alloc_map),
+					    GFP_KERNEL);
 	if (!base->lcla_pool.alloc_map)
 		goto failure;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/24] ste_dma40: Use kmalloc_array() in d40_hw_detect_init()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-17 15:12   ` [PATCH 06/24] ste_dma40: Replace four kzalloc() calls by kcalloc() in d40_hw_detect_init() SF Markus Elfring
@ 2016-09-17 15:15   ` SF Markus Elfring
  2016-09-17 15:16   ` [PATCH 08/24] ste_dma40: Less checks in d40_hw_detect_init() after error detection SF Markus Elfring
                     ` (17 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:15 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 11:44:55 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected also by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index b5d15a1..f813056 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3299,9 +3299,9 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	if (!base->lookup_log_chans)
 		goto failure;
 
-	base->reg_val_backup_chan = kmalloc(base->num_phy_chans *
-					    sizeof(d40_backup_regs_chan),
-					    GFP_KERNEL);
+	base->reg_val_backup_chan = kmalloc_array(base->num_phy_chans,
+						  sizeof(d40_backup_regs_chan),
+						  GFP_KERNEL);
 	if (!base->reg_val_backup_chan)
 		goto failure;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/24] ste_dma40: Less checks in d40_hw_detect_init() after error detection
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-17 15:15   ` [PATCH 07/24] ste_dma40: Use kmalloc_array() " SF Markus Elfring
@ 2016-09-17 15:16   ` SF Markus Elfring
  2016-09-17 15:17   ` [PATCH 09/24] ste_dma40: Delete unnecessary variable initialisations in d40_hw_detect_init() SF Markus Elfring
                     ` (16 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:16 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 14:10:47 +0200

Four checks could be repeated by the d40_hw_detect_init() function during
error handling even if the passed variables contained a null pointer.

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

* Call the interface "iounmap" only once at the end.

* Delete the repeated checks which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 67 ++++++++++++++++++++++++-------------------------
 1 file changed, 33 insertions(+), 34 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index f813056..c680dd3 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3158,27 +3158,27 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		d40_err(&pdev->dev, "No matching clock found\n");
-		goto failure;
+		goto check_prepare_enabled;
 	}
 
 	clk_ret = clk_prepare_enable(clk);
 	if (clk_ret) {
 		d40_err(&pdev->dev, "Failed to prepare/enable clock\n");
-		goto failure;
+		goto disable_unprepare;
 	}
 
 	/* Get IO for DMAC base address */
 	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "base");
 	if (!res)
-		goto failure;
+		goto disable_unprepare;
 
 	if (request_mem_region(res->start, resource_size(res),
 			       D40_NAME " I/O base") == NULL)
-		goto failure;
+		goto release_region;
 
 	virtbase = ioremap(res->start, resource_size(res));
 	if (!virtbase)
-		goto failure;
+		goto release_region;
 
 	/* This is just a regular AMBA PrimeCell ID actually */
 	for (pid = 0, i = 0; i < 4; i++)
@@ -3190,13 +3190,13 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 
 	if (cid != AMBA_CID) {
 		d40_err(&pdev->dev, "Unknown hardware! No PrimeCell ID\n");
-		goto failure;
+		goto unmap_io;
 	}
 	if (AMBA_MANF_BITS(pid) != AMBA_VENDOR_ST) {
 		d40_err(&pdev->dev, "Unknown designer! Got %x wanted %x\n",
 			AMBA_MANF_BITS(pid),
 			AMBA_VENDOR_ST);
-		goto failure;
+		goto unmap_io;
 	}
 	/*
 	 * HW revision:
@@ -3210,7 +3210,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 	rev = AMBA_REV_BITS(pid);
 	if (rev < 2) {
 		d40_err(&pdev->dev, "hardware revision: %d is not supported", rev);
-		goto failure;
+		goto unmap_io;
 	}
 
 	/* The number of physical channels on this HW */
@@ -3236,7 +3236,7 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 		       sizeof(struct d40_chan), GFP_KERNEL);
 
 	if (base == NULL)
-		goto failure;
+		goto unmap_io;
 
 	base->rev = rev;
 	base->clk = clk;
@@ -3285,63 +3285,62 @@ static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 				sizeof(*base->phy_res),
 				GFP_KERNEL);
 	if (!base->phy_res)
-		goto failure;
+		goto free_base;
 
 	base->lookup_phy_chans = kcalloc(num_phy_chans,
 					 sizeof(*base->lookup_phy_chans),
 					 GFP_KERNEL);
 	if (!base->lookup_phy_chans)
-		goto failure;
+		goto free_phy_res;
 
 	base->lookup_log_chans = kcalloc(num_log_chans,
 					 sizeof(*base->lookup_log_chans),
 					 GFP_KERNEL);
 	if (!base->lookup_log_chans)
-		goto failure;
+		goto free_phy_chans;
 
 	base->reg_val_backup_chan = kmalloc_array(base->num_phy_chans,
 						  sizeof(d40_backup_regs_chan),
 						  GFP_KERNEL);
 	if (!base->reg_val_backup_chan)
-		goto failure;
+		goto free_log_chans;
 
 	base->lcla_pool.alloc_map = kcalloc(num_phy_chans
 					    * D40_LCLA_LINK_PER_EVENT_GRP,
 					    sizeof(*base->lcla_pool.alloc_map),
 					    GFP_KERNEL);
 	if (!base->lcla_pool.alloc_map)
-		goto failure;
+		goto free_backup_chan;
 
 	base->desc_slab = kmem_cache_create(D40_NAME, sizeof(struct d40_desc),
 					    0, SLAB_HWCACHE_ALIGN,
 					    NULL);
 	if (base->desc_slab == NULL)
-		goto failure;
+		goto free_map;
 
 	return base;
-
-failure:
+ free_map:
+	kfree(base->lcla_pool.alloc_map);
+ free_backup_chan:
+	kfree(base->reg_val_backup_chan);
+ free_log_chans:
+	kfree(base->lookup_log_chans);
+ free_phy_chans:
+	kfree(base->lookup_phy_chans);
+ free_phy_res:
+	kfree(base->phy_res);
+ free_base:
+	kfree(base);
+ unmap_io:
+	iounmap(virtbase);
+ release_region:
+	release_mem_region(res->start, resource_size(res));
+ check_prepare_enabled:
 	if (!clk_ret)
+ disable_unprepare:
 		clk_disable_unprepare(clk);
 	if (!IS_ERR(clk))
 		clk_put(clk);
-	if (virtbase)
-		iounmap(virtbase);
-	if (res)
-		release_mem_region(res->start,
-				   resource_size(res));
-	if (virtbase)
-		iounmap(virtbase);
-
-	if (base) {
-		kfree(base->lcla_pool.alloc_map);
-		kfree(base->reg_val_backup_chan);
-		kfree(base->lookup_log_chans);
-		kfree(base->lookup_phy_chans);
-		kfree(base->phy_res);
-		kfree(base);
-	}
-
 	return NULL;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/24] ste_dma40: Delete unnecessary variable initialisations in d40_hw_detect_init()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-17 15:16   ` [PATCH 08/24] ste_dma40: Less checks in d40_hw_detect_init() after error detection SF Markus Elfring
@ 2016-09-17 15:17   ` SF Markus Elfring
  2016-09-17 15:18   ` [PATCH 10/24] ste_dma40: Adjust the position of a jump label in d40_probe() SF Markus Elfring
                     ` (15 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:17 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 14:34:18 +0200

Five local variables will be set to an appropriate value a bit later.
Thus omit the explicit initialisation which became unnecessary with
a previous update step.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index c680dd3..ebb00a8 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3142,11 +3142,11 @@ static int __init d40_phy_res_init(struct d40_base *base)
 static struct d40_base * __init d40_hw_detect_init(struct platform_device *pdev)
 {
 	struct stedma40_platform_data *plat_data = dev_get_platdata(&pdev->dev);
-	struct clk *clk = NULL;
-	void __iomem *virtbase = NULL;
-	struct resource *res = NULL;
-	struct d40_base *base = NULL;
-	int num_log_chans = 0;
+	struct clk *clk;
+	void __iomem *virtbase;
+	struct resource *res;
+	struct d40_base *base;
+	int num_log_chans;
 	int num_phy_chans;
 	int num_memcpy_chans;
 	int clk_ret = -EINVAL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/24] ste_dma40: Adjust the position of a jump label in d40_probe()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-17 15:17   ` [PATCH 09/24] ste_dma40: Delete unnecessary variable initialisations in d40_hw_detect_init() SF Markus Elfring
@ 2016-09-17 15:18   ` SF Markus Elfring
  2016-09-17 15:19   ` [PATCH 11/24] ste_dma40: Rename " SF Markus Elfring
                     ` (14 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:18 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 14:36:26 +0200

Add a space character before a single jump label in this function
according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index ebb00a8..4ebc825 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3728,7 +3728,7 @@ failure:
 	kfree(base->lookup_phy_chans);
 	kfree(base->phy_res);
 	kfree(base);
-report_failure:
+ report_failure:
 	d40_err(&pdev->dev, "probe failed\n");
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/24] ste_dma40: Rename a jump label in d40_probe()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-17 15:18   ` [PATCH 10/24] ste_dma40: Adjust the position of a jump label in d40_probe() SF Markus Elfring
@ 2016-09-17 15:19   ` SF Markus Elfring
  2016-09-17 15:20   ` [PATCH 12/24] ste_dma40: Rename jump labels in d40_dmaengine_init() SF Markus Elfring
                     ` (13 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:19 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 14:50:53 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 4ebc825..ed96039 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -3570,7 +3570,7 @@ static int __init d40_probe(struct platform_device *pdev)
 	if (!res) {
 		ret = -ENOENT;
 		d40_err(&pdev->dev, "No \"lcpa\" memory resource\n");
-		goto failure;
+		goto destroy_cache;
 	}
 	base->lcpa_size = resource_size(res);
 	base->phy_lcpa = res->start;
@@ -3579,7 +3579,7 @@ static int __init d40_probe(struct platform_device *pdev)
 			       D40_NAME " I/O lcpa") == NULL) {
 		ret = -EBUSY;
 		d40_err(&pdev->dev, "Failed to request LCPA region %pR\n", res);
-		goto failure;
+		goto destroy_cache;
 	}
 
 	/* We make use of ESRAM memory for this. */
@@ -3595,7 +3595,7 @@ static int __init d40_probe(struct platform_device *pdev)
 	if (!base->lcpa_base) {
 		ret = -ENOMEM;
 		d40_err(&pdev->dev, "Failed to ioremap LCPA region\n");
-		goto failure;
+		goto destroy_cache;
 	}
 	/* If lcla has to be located in ESRAM we don't need to allocate */
 	if (base->plat_data->use_esram_lcla) {
@@ -3605,14 +3605,14 @@ static int __init d40_probe(struct platform_device *pdev)
 			ret = -ENOENT;
 			d40_err(&pdev->dev,
 				"No \"lcla_esram\" memory resource\n");
-			goto failure;
+			goto destroy_cache;
 		}
 		base->lcla_pool.base = ioremap(res->start,
 						resource_size(res));
 		if (!base->lcla_pool.base) {
 			ret = -ENOMEM;
 			d40_err(&pdev->dev, "Failed to ioremap LCLA region\n");
-			goto failure;
+			goto destroy_cache;
 		}
 		writel(res->start, base->virtbase + D40_DREG_LCLA);
 
@@ -3620,7 +3620,7 @@ static int __init d40_probe(struct platform_device *pdev)
 		ret = d40_lcla_allocate(base);
 		if (ret) {
 			d40_err(&pdev->dev, "Failed to allocate LCLA area\n");
-			goto failure;
+			goto destroy_cache;
 		}
 	}
 
@@ -3631,7 +3631,7 @@ static int __init d40_probe(struct platform_device *pdev)
 	ret = request_irq(base->irq, d40_handle_interrupt, 0, D40_NAME, base);
 	if (ret) {
 		d40_err(&pdev->dev, "No IRQ defined\n");
-		goto failure;
+		goto destroy_cache;
 	}
 
 	if (base->plat_data->use_esram_lcla) {
@@ -3641,7 +3641,7 @@ static int __init d40_probe(struct platform_device *pdev)
 			d40_err(&pdev->dev, "Failed to get lcpa_regulator\n");
 			ret = PTR_ERR(base->lcpa_regulator);
 			base->lcpa_regulator = NULL;
-			goto failure;
+			goto destroy_cache;
 		}
 
 		ret = regulator_enable(base->lcpa_regulator);
@@ -3650,7 +3650,7 @@ static int __init d40_probe(struct platform_device *pdev)
 				"Failed to enable lcpa_regulator\n");
 			regulator_put(base->lcpa_regulator);
 			base->lcpa_regulator = NULL;
-			goto failure;
+			goto destroy_cache;
 		}
 	}
 
@@ -3665,13 +3665,13 @@ static int __init d40_probe(struct platform_device *pdev)
 
 	ret = d40_dmaengine_init(base, num_reserved_chans);
 	if (ret)
-		goto failure;
+		goto destroy_cache;
 
 	base->dev->dma_parms = &base->dma_parms;
 	ret = dma_set_max_seg_size(base->dev, STEDMA40_MAX_SEG_SIZE);
 	if (ret) {
 		d40_err(&pdev->dev, "Failed to set dma max seg size\n");
-		goto failure;
+		goto destroy_cache;
 	}
 
 	d40_hw_init(base);
@@ -3685,8 +3685,7 @@ static int __init d40_probe(struct platform_device *pdev)
 
 	dev_info(base->dev, "initialized\n");
 	return 0;
-
-failure:
+ destroy_cache:
 	kmem_cache_destroy(base->desc_slab);
 	if (base->virtbase)
 		iounmap(base->virtbase);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/24] ste_dma40: Rename jump labels in d40_dmaengine_init()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-17 15:19   ` [PATCH 11/24] ste_dma40: Rename " SF Markus Elfring
@ 2016-09-17 15:20   ` SF Markus Elfring
  2016-09-17 15:22   ` [PATCH 13/24] ste_dma40: Rename a jump label in d40_alloc_chan_resources() SF Markus Elfring
                     ` (12 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:20 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:10:15 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index ed96039..c7b73f1 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2889,7 +2889,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,
 
 	if (err) {
 		d40_err(base->dev, "Failed to register slave channels\n");
-		goto failure1;
+		goto exit;
 	}
 
 	d40_chan_init(base, &base->dma_memcpy, base->log_chans,
@@ -2906,7 +2906,7 @@ static int __init d40_dmaengine_init(struct d40_base *base,
 	if (err) {
 		d40_err(base->dev,
 			"Failed to register memcpy only channels\n");
-		goto failure2;
+		goto unregister_slave;
 	}
 
 	d40_chan_init(base, &base->dma_both, base->phy_chans,
@@ -2924,14 +2924,14 @@ static int __init d40_dmaengine_init(struct d40_base *base,
 	if (err) {
 		d40_err(base->dev,
 			"Failed to register logical and physical capable channels\n");
-		goto failure3;
+		goto unregister_memcpy;
 	}
 	return 0;
-failure3:
+ unregister_memcpy:
 	dma_async_device_unregister(&base->dma_memcpy);
-failure2:
+ unregister_slave:
 	dma_async_device_unregister(&base->dma_slave);
-failure1:
+ exit:
 	return err;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/24] ste_dma40: Rename a jump label in d40_alloc_chan_resources()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-17 15:20   ` [PATCH 12/24] ste_dma40: Rename jump labels in d40_dmaengine_init() SF Markus Elfring
@ 2016-09-17 15:22   ` SF Markus Elfring
  2016-09-17 15:23   ` [PATCH 14/24] ste_dma40: One check less in d40_prep_sg() after error detection SF Markus Elfring
                     ` (11 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:22 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:15:15 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index c7b73f1..0788add 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2424,7 +2424,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
 		err = d40_config_memcpy(d40c);
 		if (err) {
 			chan_err(d40c, "Failed to configure memcpy channel\n");
-			goto fail;
+			goto mark_last_busy;
 		}
 	}
 
@@ -2432,7 +2432,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
 	if (err) {
 		chan_err(d40c, "Failed to allocate channel\n");
 		d40c->configured = false;
-		goto fail;
+		goto mark_last_busy;
 	}
 
 	pm_runtime_get_sync(d40c->base->dev);
@@ -2466,7 +2466,7 @@ static int d40_alloc_chan_resources(struct dma_chan *chan)
 	 */
 	if (is_free_phy)
 		d40_config_write(d40c);
-fail:
+ mark_last_busy:
 	pm_runtime_mark_last_busy(d40c->base->dev);
 	pm_runtime_put_autosuspend(d40c->base->dev);
 	spin_unlock_irqrestore(&d40c->lock, flags);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/24] ste_dma40: One check less in d40_prep_sg() after error detection
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-17 15:22   ` [PATCH 13/24] ste_dma40: Rename a jump label in d40_alloc_chan_resources() SF Markus Elfring
@ 2016-09-17 15:23   ` SF Markus Elfring
  2016-09-17 15:25   ` [PATCH 15/24] ste_dma40: Move two assignments in d40_prep_sg() SF Markus Elfring
                     ` (10 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:23 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:34:07 +0200

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

* Delete a repeated check which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 0788add..a7e7cd0 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2251,7 +2251,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 
 	desc = d40_prep_desc(chan, sg_src, sg_len, dma_flags);
 	if (desc == NULL)
-		goto err;
+		goto unlock;
 
 	if (sg_next(&sg_src[sg_len - 1]) == sg_src)
 		desc->cyclic = true;
@@ -2271,7 +2271,7 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 	if (ret) {
 		chan_err(chan, "Failed to prepare %s sg job: %d\n",
 			 chan_is_logical(chan) ? "log" : "phy", ret);
-		goto err;
+		goto free_desc;
 	}
 
 	/*
@@ -2283,10 +2283,9 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 	spin_unlock_irqrestore(&chan->lock, flags);
 
 	return &desc->txd;
-
-err:
-	if (desc)
-		d40_desc_free(chan, desc);
+ free_desc:
+	d40_desc_free(chan, desc);
+ unlock:
 	spin_unlock_irqrestore(&chan->lock, flags);
 	return NULL;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 15/24] ste_dma40: Move two assignments in d40_prep_sg()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-17 15:23   ` [PATCH 14/24] ste_dma40: One check less in d40_prep_sg() after error detection SF Markus Elfring
@ 2016-09-17 15:25   ` SF Markus Elfring
  2016-09-17 15:26   ` [PATCH 16/24] ste_dma40: Rename a jump label in d40_prep_desc() SF Markus Elfring
                     ` (9 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:25 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:40:05 +0200

Move assignments for two local variables so that their setting
will only be performed after corresponding data processing succeeded
by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index a7e7cd0..6725b66 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2236,8 +2236,8 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 	    enum dma_transfer_direction direction, unsigned long dma_flags)
 {
 	struct d40_chan *chan = container_of(dchan, struct d40_chan, chan);
-	dma_addr_t src_dev_addr = 0;
-	dma_addr_t dst_dev_addr = 0;
+	dma_addr_t src_dev_addr;
+	dma_addr_t dst_dev_addr;
 	struct d40_desc *desc;
 	unsigned long flags;
 	int ret;
@@ -2256,6 +2256,8 @@ d40_prep_sg(struct dma_chan *dchan, struct scatterlist *sg_src,
 	if (sg_next(&sg_src[sg_len - 1]) == sg_src)
 		desc->cyclic = true;
 
+	src_dev_addr = 0;
+	dst_dev_addr = 0;
 	if (direction == DMA_DEV_TO_MEM)
 		src_dev_addr = chan->runtime_addr;
 	else if (direction == DMA_MEM_TO_DEV)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 16/24] ste_dma40: Rename a jump label in d40_prep_desc()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-17 15:25   ` [PATCH 15/24] ste_dma40: Move two assignments in d40_prep_sg() SF Markus Elfring
@ 2016-09-17 15:26   ` SF Markus Elfring
  2016-09-17 15:27   ` [PATCH 17/24] ste_dma40: Move an assignment " SF Markus Elfring
                     ` (8 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:26 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:51:37 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 6725b66..7f38496 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2208,13 +2208,13 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
 					cfg->dst_info.data_width);
 	if (desc->lli_len < 0) {
 		chan_err(chan, "Unaligned size\n");
-		goto err;
+		goto free_desc;
 	}
 
 	ret = d40_pool_lli_alloc(chan, desc, desc->lli_len);
 	if (ret < 0) {
 		chan_err(chan, "Could not allocate lli\n");
-		goto err;
+		goto free_desc;
 	}
 
 	desc->lli_current = 0;
@@ -2224,8 +2224,7 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
 	dma_async_tx_descriptor_init(&desc->txd, &chan->chan);
 
 	return desc;
-
-err:
+ free_desc:
 	d40_desc_free(chan, desc);
 	return NULL;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 17/24] ste_dma40: Move an assignment in d40_prep_desc()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (15 preceding siblings ...)
  2016-09-17 15:26   ` [PATCH 16/24] ste_dma40: Rename a jump label in d40_prep_desc() SF Markus Elfring
@ 2016-09-17 15:27   ` SF Markus Elfring
  2016-09-17 15:30   ` [PATCH 18/24] ste_dma40: Rename a jump label in d40_is_paused() SF Markus Elfring
                     ` (7 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:27 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 15:54:12 +0200

Move one assignment for the local variable "cfg" so that its setting
will only be performed after a call of the function "d40_desc_get"
succeeded by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 7f38496..4a21778 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2196,7 +2196,7 @@ static struct d40_desc *
 d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
 	      unsigned int sg_len, unsigned long dma_flags)
 {
-	struct stedma40_chan_cfg *cfg = &chan->dma_cfg;
+	struct stedma40_chan_cfg *cfg;
 	struct d40_desc *desc;
 	int ret;
 
@@ -2204,6 +2204,7 @@ d40_prep_desc(struct d40_chan *chan, struct scatterlist *sg,
 	if (!desc)
 		return NULL;
 
+	cfg = &chan->dma_cfg;
 	desc->lli_len = d40_sg_2_dmalen(sg, sg_len, cfg->src_info.data_width,
 					cfg->dst_info.data_width);
 	if (desc->lli_len < 0) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 18/24] ste_dma40: Rename a jump label in d40_is_paused()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (16 preceding siblings ...)
  2016-09-17 15:27   ` [PATCH 17/24] ste_dma40: Move an assignment " SF Markus Elfring
@ 2016-09-17 15:30   ` SF Markus Elfring
  2016-09-17 15:31   ` [PATCH 19/24] ste_dma40: Rename a jump label in d40_free_dma() SF Markus Elfring
                     ` (6 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:30 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:00:05 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 4a21778..d99241c 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2092,8 +2092,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
 			D40_CHAN_POS(d40c->phy_chan->num);
 		if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP)
 			is_paused = true;
-
-		goto _exit;
+		goto unlock;
 	}
 
 	if (d40c->dma_cfg.dir == DMA_MEM_TO_DEV ||
@@ -2103,7 +2102,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
 		status = readl(chanbase + D40_CHAN_REG_SSLNK);
 	} else {
 		chan_err(d40c, "Unknown direction\n");
-		goto _exit;
+		goto unlock;
 	}
 
 	status = (status & D40_EVENTLINE_MASK(event)) >>
@@ -2111,7 +2110,7 @@ static bool d40_is_paused(struct d40_chan *d40c)
 
 	if (status != D40_DMA_RUN)
 		is_paused = true;
-_exit:
+ unlock:
 	spin_unlock_irqrestore(&d40c->lock, flags);
 	return is_paused;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 19/24] ste_dma40: Rename a jump label in d40_free_dma()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (17 preceding siblings ...)
  2016-09-17 15:30   ` [PATCH 18/24] ste_dma40: Rename a jump label in d40_is_paused() SF Markus Elfring
@ 2016-09-17 15:31   ` SF Markus Elfring
  2016-09-17 15:32   ` [PATCH 20/24] ste_dma40: Rename a jump label in d40_alloc_mask_free() SF Markus Elfring
                     ` (5 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:31 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:04:46 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index d99241c..917b24a 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2045,7 +2045,7 @@ static int d40_free_dma(struct d40_chan *d40c)
 	res = d40_channel_execute_command(d40c, D40_DMA_STOP);
 	if (res) {
 		chan_err(d40c, "stop failed\n");
-		goto out;
+		goto mark_last_busy;
 	}
 
 	d40_alloc_mask_free(phy, is_src, chan_is_logical(d40c) ? event : 0);
@@ -2063,8 +2063,7 @@ static int d40_free_dma(struct d40_chan *d40c)
 	d40c->busy = false;
 	d40c->phy_chan = NULL;
 	d40c->configured = false;
-out:
-
+ mark_last_busy:
 	pm_runtime_mark_last_busy(d40c->base->dev);
 	pm_runtime_put_autosuspend(d40c->base->dev);
 	return res;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 20/24] ste_dma40: Rename a jump label in d40_alloc_mask_free()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (18 preceding siblings ...)
  2016-09-17 15:31   ` [PATCH 19/24] ste_dma40: Rename a jump label in d40_free_dma() SF Markus Elfring
@ 2016-09-17 15:32   ` SF Markus Elfring
  2016-09-17 15:33   ` [PATCH 21/24] ste_dma40: Rename jump labels in d40_alloc_mask_set() SF Markus Elfring
                     ` (4 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:32 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:10:41 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 917b24a..fbe87a2 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1829,7 +1829,7 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,
 		phy->allocated_dst = D40_ALLOC_FREE;
 		phy->allocated_src = D40_ALLOC_FREE;
 		is_free = true;
-		goto out;
+		goto unlock;
 	}
 
 	/* Logical channel */
@@ -1845,8 +1845,7 @@ static bool d40_alloc_mask_free(struct d40_phy_res *phy, bool is_src,
 
 	is_free = ((phy->allocated_src | phy->allocated_dst) ==
 		   D40_ALLOC_FREE);
-
-out:
+ unlock:
 	spin_unlock_irqrestore(&phy->lock, flags);
 
 	return is_free;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 21/24] ste_dma40: Rename jump labels in d40_alloc_mask_set()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (19 preceding siblings ...)
  2016-09-17 15:32   ` [PATCH 20/24] ste_dma40: Rename a jump label in d40_alloc_mask_free() SF Markus Elfring
@ 2016-09-17 15:33   ` SF Markus Elfring
  2016-09-17 15:34   ` [PATCH 22/24] ste_dma40: Rename a jump label in dma_tasklet() SF Markus Elfring
                     ` (3 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:33 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:16:42 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index fbe87a2..4a2f39b 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1778,42 +1778,40 @@ static bool d40_alloc_mask_set(struct d40_phy_res *phy,
 		    phy->allocated_dst == D40_ALLOC_FREE) {
 			phy->allocated_dst = D40_ALLOC_PHY;
 			phy->allocated_src = D40_ALLOC_PHY;
-			goto found;
+			goto found_unlock;
 		} else
-			goto not_found;
+			goto not_found_unlock;
 	}
 
 	/* Logical channel */
 	if (is_src) {
 		if (phy->allocated_src == D40_ALLOC_PHY)
-			goto not_found;
+			goto not_found_unlock;
 
 		if (phy->allocated_src == D40_ALLOC_FREE)
 			phy->allocated_src = D40_ALLOC_LOG_FREE;
 
 		if (!(phy->allocated_src & BIT(log_event_line))) {
 			phy->allocated_src |= BIT(log_event_line);
-			goto found;
+			goto found_unlock;
 		} else
-			goto not_found;
+			goto not_found_unlock;
 	} else {
 		if (phy->allocated_dst == D40_ALLOC_PHY)
-			goto not_found;
+			goto not_found_unlock;
 
 		if (phy->allocated_dst == D40_ALLOC_FREE)
 			phy->allocated_dst = D40_ALLOC_LOG_FREE;
 
 		if (!(phy->allocated_dst & BIT(log_event_line))) {
 			phy->allocated_dst |= BIT(log_event_line);
-			goto found;
-		} else
-			goto not_found;
+			goto found_unlock;
+		}
 	}
-
-not_found:
+ not_found_unlock:
 	spin_unlock_irqrestore(&phy->lock, flags);
 	return false;
-found:
+ found_unlock:
 	spin_unlock_irqrestore(&phy->lock, flags);
 	return true;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 22/24] ste_dma40: Rename a jump label in dma_tasklet()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (20 preceding siblings ...)
  2016-09-17 15:33   ` [PATCH 21/24] ste_dma40: Rename jump labels in d40_alloc_mask_set() SF Markus Elfring
@ 2016-09-17 15:34   ` SF Markus Elfring
  2016-09-17 15:35   ` [PATCH 23/24] ste_dma40: Rename a jump label in __d40_execute_command_phy() SF Markus Elfring
                     ` (2 subsequent siblings)
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:34 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:23:43 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 4a2f39b..0082ae0 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1606,7 +1606,7 @@ static void dma_tasklet(unsigned long data)
 		/* Check if we have reached here for cyclic job */
 		d40d = d40_first_active_get(d40c);
 		if (d40d == NULL || !d40d->cyclic)
-			goto err;
+			goto check_pending_tx;
 	}
 
 	if (!d40d->cyclic)
@@ -1648,8 +1648,7 @@ static void dma_tasklet(unsigned long data)
 		dmaengine_desc_callback_invoke(&cb, NULL);
 
 	return;
-
-err:
+ check_pending_tx:
 	/* Rescue manouver if receiving double interrupts */
 	if (d40c->pending_tx > 0)
 		d40c->pending_tx--;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 23/24] ste_dma40: Rename a jump label in __d40_execute_command_phy()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (21 preceding siblings ...)
  2016-09-17 15:34   ` [PATCH 22/24] ste_dma40: Rename a jump label in dma_tasklet() SF Markus Elfring
@ 2016-09-17 15:35   ` SF Markus Elfring
  2016-09-17 15:36   ` [PATCH 24/24] ste_dma40: Rename a jump label in d40_log_lli_to_lcxa() SF Markus Elfring
  2016-09-23  9:41   ` [PATCH 00/24] ste_dma40: Fine-tuning for several function implementations Linus Walleij
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:35 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:28:54 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 0082ae0..01fe3a2 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1083,7 +1083,7 @@ static int __d40_execute_command_phy(struct d40_chan *d40c,
 			D40_CHAN_POS(d40c->phy_chan->num);
 
 		if (status == D40_DMA_SUSPENDED || status == D40_DMA_STOP)
-			goto done;
+			goto unlock;
 	}
 
 	wmask = 0xffffffff & ~(D40_CHAN_POS_MASK(d40c->phy_chan->num));
@@ -1119,7 +1119,7 @@ static int __d40_execute_command_phy(struct d40_chan *d40c,
 		}
 
 	}
-done:
+ unlock:
 	spin_unlock_irqrestore(&d40c->base->execmd_lock, flags);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 24/24] ste_dma40: Rename a jump label in d40_log_lli_to_lcxa()
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (22 preceding siblings ...)
  2016-09-17 15:35   ` [PATCH 23/24] ste_dma40: Rename a jump label in __d40_execute_command_phy() SF Markus Elfring
@ 2016-09-17 15:36   ` SF Markus Elfring
  2016-09-23  9:41   ` [PATCH 00/24] ste_dma40: Fine-tuning for several function implementations Linus Walleij
  24 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-17 15:36 UTC (permalink / raw)
  To: dmaengine, linux-arm-kernel, Dan Williams, Linus Walleij, Vinod Koul
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 16:39:06 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/dma/ste_dma40.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 01fe3a2..dcb26c6 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -874,7 +874,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
 	}
 
 	if (curr_lcla < 0)
-		goto out;
+		goto set_current;
 
 	for (; lli_current < lli_len; lli_current++) {
 		unsigned int lcla_offset = chan->phy_chan->num * 1024 +
@@ -925,8 +925,7 @@ static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
 			break;
 		}
 	}
-
-out:
+ set_current:
 	desc->lli_current = lli_current;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 00/10] firewire-net: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (84 preceding siblings ...)
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
@ 2016-09-18  6:08 ` SF Markus Elfring
  2016-09-18  6:10   ` [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start() SF Markus Elfring
                     ` (9 more replies)
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
                   ` (9 subsequent siblings)
  95 siblings, 10 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:08 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 08:04:02 +0200

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

Markus Elfring (10):
  Use kmalloc_array() in fwnet_broadcast_start()
  Rename a jump label in fwnet_broadcast_start()
  Rename jump labels in fwnet_init()
  Rename jump labels in fwnet_probe()
  Rename a jump label in fwnet_tx()
  Rename a jump label in fwnet_send_packet()
  Rename a jump label in fwnet_incoming_packet()
  Rename a jump label in fwnet_finish_incoming_packet()
  Rename jump labels in fwnet_pd_new()
  Adjust checks for null pointers in five functions

 drivers/firewire/net.c | 94 +++++++++++++++++++++++---------------------------
 1 file changed, 44 insertions(+), 50 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
@ 2016-09-18  6:10   ` SF Markus Elfring
  2016-09-24 11:41     ` Stefan Richter
  2016-09-18  6:12   ` [PATCH 02/10] firewire-net: Rename a jump label " SF Markus Elfring
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:10 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 21:55:42 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 309311b..7911f13 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1103,8 +1103,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 
 	max_receive = 1U << (dev->card->max_receive + 1);
 	num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
-
-	ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
+	ptrptr = kmalloc_array(num_packets, sizeof(*ptrptr), GFP_KERNEL);
 	if (!ptrptr) {
 		retval = -ENOMEM;
 		goto failed;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/10] firewire-net: Rename a jump label in fwnet_broadcast_start()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
  2016-09-18  6:10   ` [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start() SF Markus Elfring
@ 2016-09-18  6:12   ` SF Markus Elfring
  2016-09-24 12:58     ` Stefan Richter
  2016-09-18  6:14   ` [PATCH 03/10] firewire-net: Rename jump labels in fwnet_init() SF Markus Elfring
                     ` (7 subsequent siblings)
  9 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:12 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:02:44 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 7911f13..89afed3 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1106,7 +1106,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 	ptrptr = kmalloc_array(num_packets, sizeof(*ptrptr), GFP_KERNEL);
 	if (!ptrptr) {
 		retval = -ENOMEM;
-		goto failed;
+		goto stop_broadcast;
 	}
 	dev->broadcast_rcv_buffer_ptrs = ptrptr;
 
@@ -1116,13 +1116,13 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 					fwnet_receive_broadcast, dev);
 	if (IS_ERR(context)) {
 		retval = PTR_ERR(context);
-		goto failed;
+		goto stop_broadcast;
 	}
 
 	retval = fw_iso_buffer_init(&dev->broadcast_rcv_buffer, dev->card,
 				    FWNET_ISO_PAGE_COUNT, DMA_FROM_DEVICE);
 	if (retval < 0)
-		goto failed;
+		goto stop_broadcast;
 
 	dev->broadcast_state = FWNET_BROADCAST_STOPPED;
 
@@ -1148,7 +1148,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 		retval = fw_iso_context_queue(context, &packet,
 				&dev->broadcast_rcv_buffer, offset);
 		if (retval < 0)
-			goto failed;
+			goto stop_broadcast;
 
 		offset += max_receive;
 	}
@@ -1158,7 +1158,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 	retval = fw_iso_context_start(context, -1, 0,
 			FW_ISO_CONTEXT_MATCH_ALL_TAGS); /* ??? sync */
 	if (retval < 0)
-		goto failed;
+		goto stop_broadcast;
 
 	/* FIXME: adjust it according to the min. speed of all known peers? */
 	dev->broadcast_xmt_max_payload = IEEE1394_MAX_PAYLOAD_S100
@@ -1166,8 +1166,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 	dev->broadcast_state = FWNET_BROADCAST_RUNNING;
 
 	return 0;
-
- failed:
+ stop_broadcast:
 	__fwnet_broadcast_stop(dev);
 	return retval;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/10] firewire-net: Rename jump labels in fwnet_init()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
  2016-09-18  6:10   ` [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start() SF Markus Elfring
  2016-09-18  6:12   ` [PATCH 02/10] firewire-net: Rename a jump label " SF Markus Elfring
@ 2016-09-18  6:14   ` SF Markus Elfring
  2016-09-18  6:15   ` [PATCH 04/10] firewire-net: Rename jump labels in fwnet_probe() SF Markus Elfring
                     ` (6 subsequent siblings)
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:14 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:11:25 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 89afed3..cedfade 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1662,14 +1662,14 @@ static int __init fwnet_init(void)
 #if IS_ENABLED(CONFIG_IPV6)
 	err = fw_core_add_descriptor(&rfc3146_unit_directory);
 	if (err)
-		goto out;
+		goto remove_descriptor_rfc2374;
 #endif
 
 	fwnet_packet_task_cache = kmem_cache_create("packet_task",
 			sizeof(struct fwnet_packet_task), 0, 0, NULL);
 	if (!fwnet_packet_task_cache) {
 		err = -ENOMEM;
-		goto out2;
+		goto remove_descriptor_rfc3146;
 	}
 
 	err = driver_register(&fwnet_driver.driver);
@@ -1677,10 +1677,10 @@ static int __init fwnet_init(void)
 		return 0;
 
 	kmem_cache_destroy(fwnet_packet_task_cache);
-out2:
+ remove_descriptor_rfc3146:
 #if IS_ENABLED(CONFIG_IPV6)
 	fw_core_remove_descriptor(&rfc3146_unit_directory);
-out:
+ remove_descriptor_rfc2374:
 #endif
 	fw_core_remove_descriptor(&rfc2374_unit_directory);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/10] firewire-net: Rename jump labels in fwnet_probe()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-18  6:14   ` [PATCH 03/10] firewire-net: Rename jump labels in fwnet_init() SF Markus Elfring
@ 2016-09-18  6:15   ` SF Markus Elfring
  2016-09-18  6:16   ` [PATCH 05/10] firewire-net: Rename a jump label in fwnet_tx() SF Markus Elfring
                     ` (5 subsequent siblings)
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:15 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:17:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index cedfade..2ca2d57 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1442,7 +1442,7 @@ static int fwnet_probe(struct fw_unit *unit,
 	dev = fwnet_dev_find(card);
 	if (dev) {
 		net = dev->netdev;
-		goto have_dev;
+		goto add_peer;
 	}
 
 	net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
@@ -1469,7 +1469,7 @@ static int fwnet_probe(struct fw_unit *unit,
 
 	ret = fwnet_fifo_start(dev);
 	if (ret < 0)
-		goto out;
+		goto stop_fifo;
 	dev->local_fifo = dev->handler.offset;
 
 	/*
@@ -1492,17 +1492,17 @@ static int fwnet_probe(struct fw_unit *unit,
 
 	ret = register_netdev(net);
 	if (ret)
-		goto out;
+		goto stop_fifo;
 
 	list_add_tail(&dev->dev_link, &fwnet_device_list);
 	dev_notice(&net->dev, "IP over IEEE 1394 on card %s\n",
 		   dev_name(card->device));
- have_dev:
+ add_peer:
 	ret = fwnet_add_peer(dev, unit, device);
 	if (ret && allocated_netdev) {
 		unregister_netdev(net);
 		list_del(&dev->dev_link);
- out:
+ stop_fifo:
 		fwnet_fifo_stop(dev);
 		free_netdev(net);
 	}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/10] firewire-net: Rename a jump label in fwnet_tx()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-18  6:15   ` [PATCH 04/10] firewire-net: Rename jump labels in fwnet_probe() SF Markus Elfring
@ 2016-09-18  6:16   ` SF Markus Elfring
  2016-09-18  6:17   ` [PATCH 06/10] firewire-net: Rename a jump label in fwnet_send_packet() SF Markus Elfring
                     ` (4 subsequent siblings)
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:16 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:22:58 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 2ca2d57..24725be 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1233,11 +1233,11 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 
 	ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC);
 	if (ptask == NULL)
-		goto fail;
+		goto unlock;
 
 	skb = skb_share_check(skb, GFP_ATOMIC);
 	if (!skb)
-		goto fail;
+		goto unlock;
 
 	/*
 	 * Make a copy of the driver-specific header.
@@ -1254,7 +1254,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 #endif
 		break;
 	default:
-		goto fail;
+		goto unlock;
 	}
 
 	skb_pull(skb, sizeof(hdr_buf));
@@ -1279,7 +1279,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 
 		peer = fwnet_peer_find_by_guid(dev, be64_to_cpu(guid));
 		if (!peer)
-			goto fail;
+			goto unlock;
 
 		generation         = peer->generation;
 		dest_node          = peer->node_id;
@@ -1324,8 +1324,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 	fwnet_send_packet(ptask);
 
 	return NETDEV_TX_OK;
-
- fail:
+ unlock:
 	spin_unlock_irqrestore(&dev->lock, flags);
 
 	if (ptask)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/10] firewire-net: Rename a jump label in fwnet_send_packet()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-18  6:16   ` [PATCH 05/10] firewire-net: Rename a jump label in fwnet_tx() SF Markus Elfring
@ 2016-09-18  6:17   ` SF Markus Elfring
  2016-09-18  6:18   ` [PATCH 07/10] firewire-net: Rename a jump label in fwnet_incoming_packet() SF Markus Elfring
                     ` (3 subsequent siblings)
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:17 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:27:52 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 24725be..a0ccab3 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -1003,8 +1003,7 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
 			dec_queued_datagrams(dev);
 
 		spin_unlock_irqrestore(&dev->lock, flags);
-
-		goto out;
+		goto check_free;
 	}
 
 	fw_send_request(dev->card, &ptask->transaction,
@@ -1024,7 +1023,7 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
 	spin_unlock_irqrestore(&dev->lock, flags);
 
 	netif_trans_update(dev->netdev);
- out:
+ check_free:
 	if (free)
 		fwnet_free_ptask(ptask);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/10] firewire-net: Rename a jump label in fwnet_incoming_packet()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-18  6:17   ` [PATCH 06/10] firewire-net: Rename a jump label in fwnet_send_packet() SF Markus Elfring
@ 2016-09-18  6:18   ` SF Markus Elfring
  2016-09-18  6:19   ` [PATCH 08/10] firewire-net: Rename a jump label in fwnet_finish_incoming_packet() SF Markus Elfring
                     ` (2 subsequent siblings)
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:18 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:32:14 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index a0ccab3..7e802e7 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -621,7 +621,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 	peer = fwnet_peer_find_by_node_id(dev, source_node_id, generation);
 	if (!peer) {
 		retval = -ENOENT;
-		goto fail;
+		goto unlock;
 	}
 
 	pd = fwnet_pd_find(peer, datagram_label);
@@ -636,7 +636,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 				  dg_size, buf, fg_off, len);
 		if (pd == NULL) {
 			retval = -ENOMEM;
-			goto fail;
+			goto unlock;
 		}
 		peer->pdg_size++;
 	} else {
@@ -652,7 +652,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 			if (pd == NULL) {
 				peer->pdg_size--;
 				retval = -ENOMEM;
-				goto fail;
+				goto unlock;
 			}
 		} else {
 			if (!fwnet_pd_update(peer, pd, buf, fg_off, len)) {
@@ -664,7 +664,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 				fwnet_pd_delete(pd);
 				peer->pdg_size--;
 				retval = -ENOMEM;
-				goto fail;
+				goto unlock;
 			}
 		}
 	} /* new datagram or add to existing one */
@@ -688,7 +688,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 	 * moment.
 	 */
 	retval = 0;
- fail:
+ unlock:
 	spin_unlock_irqrestore(&dev->lock, flags);
 
 	return retval;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/10] firewire-net: Rename a jump label in fwnet_finish_incoming_packet()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-18  6:18   ` [PATCH 07/10] firewire-net: Rename a jump label in fwnet_incoming_packet() SF Markus Elfring
@ 2016-09-18  6:19   ` SF Markus Elfring
  2016-09-18  6:21   ` [PATCH 09/10] firewire-net: Rename jump labels in fwnet_pd_new() SF Markus Elfring
  2016-09-18  6:22   ` [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions SF Markus Elfring
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:19 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:40:05 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 7e802e7..6dd3174 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -495,7 +495,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
 #endif
 		break;
 	default:
-		goto err;
+		goto increment_counter;
 	}
 
 	dev = netdev_priv(net);
@@ -551,8 +551,7 @@ static int fwnet_finish_incoming_packet(struct net_device *net,
 	}
 
 	return 0;
-
- err:
+ increment_counter:
 	net->stats.rx_errors++;
 	net->stats.rx_dropped++;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/10] firewire-net: Rename jump labels in fwnet_pd_new()
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-18  6:19   ` [PATCH 08/10] firewire-net: Rename a jump label in fwnet_finish_incoming_packet() SF Markus Elfring
@ 2016-09-18  6:21   ` SF Markus Elfring
  2016-09-18  6:22   ` [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions SF Markus Elfring
  9 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:21 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 17 Sep 2016 22:48:46 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index 6dd3174..eb7ce5e 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -362,18 +362,18 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net,
 
 	new = kmalloc(sizeof(*new), GFP_ATOMIC);
 	if (!new)
-		goto fail;
+		goto exit;
 
 	INIT_LIST_HEAD(&new->fi_list);
 	fi = fwnet_frag_new(new, frag_off, frag_len);
 	if (fi == NULL)
-		goto fail_w_new;
+		goto free_new;
 
 	new->datagram_label = datagram_label;
 	new->datagram_size = dg_size;
 	new->skb = dev_alloc_skb(dg_size + LL_RESERVED_SPACE(net));
 	if (new->skb == NULL)
-		goto fail_w_fi;
+		goto free_fragment_info;
 
 	skb_reserve(new->skb, LL_RESERVED_SPACE(net));
 	new->pbuf = skb_put(new->skb, dg_size);
@@ -381,12 +381,11 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net,
 	list_add_tail(&new->pd_link, &peer->pd_list);
 
 	return new;
-
-fail_w_fi:
+ free_fragment_info:
 	kfree(fi);
-fail_w_new:
+ free_new:
 	kfree(new);
-fail:
+ exit:
 	return NULL;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-18  6:21   ` [PATCH 09/10] firewire-net: Rename jump labels in fwnet_pd_new() SF Markus Elfring
@ 2016-09-18  6:22   ` SF Markus Elfring
  2016-09-24 12:06     ` Stefan Richter
  9 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18  6:22 UTC (permalink / raw)
  To: linux1394-devel, Stefan Richter; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 07:48:56 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firewire/net.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
index eb7ce5e..e313be3 100644
--- a/drivers/firewire/net.c
+++ b/drivers/firewire/net.c
@@ -366,13 +366,13 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net,
 
 	INIT_LIST_HEAD(&new->fi_list);
 	fi = fwnet_frag_new(new, frag_off, frag_len);
-	if (fi == NULL)
+	if (!fi)
 		goto free_new;
 
 	new->datagram_label = datagram_label;
 	new->datagram_size = dg_size;
 	new->skb = dev_alloc_skb(dg_size + LL_RESERVED_SPACE(net));
-	if (new->skb == NULL)
+	if (!new->skb)
 		goto free_fragment_info;
 
 	skb_reserve(new->skb, LL_RESERVED_SPACE(net));
@@ -418,7 +418,7 @@ static bool fwnet_pd_update(struct fwnet_peer *peer,
 		struct fwnet_partial_datagram *pd, void *frag_buf,
 		unsigned frag_off, unsigned frag_len)
 {
-	if (fwnet_frag_new(pd, frag_off, frag_len) == NULL)
+	if (!fwnet_frag_new(pd, frag_off, frag_len))
 		return false;
 
 	memcpy(pd->pbuf + frag_off, frag_buf, frag_len);
@@ -623,7 +623,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 	}
 
 	pd = fwnet_pd_find(peer, datagram_label);
-	if (pd == NULL) {
+	if (!pd) {
 		while (peer->pdg_size >= FWNET_MAX_FRAGMENTS) {
 			/* remove the oldest */
 			fwnet_pd_delete(list_first_entry(&peer->pd_list,
@@ -632,7 +632,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 		}
 		pd = fwnet_pd_new(net, peer, datagram_label,
 				  dg_size, buf, fg_off, len);
-		if (pd == NULL) {
+		if (!pd) {
 			retval = -ENOMEM;
 			goto unlock;
 		}
@@ -647,7 +647,7 @@ static int fwnet_incoming_packet(struct fwnet_device *dev, __be32 *buf, int len,
 			fwnet_pd_delete(pd);
 			pd = fwnet_pd_new(net, peer, datagram_label,
 					  dg_size, buf, fg_off, len);
-			if (pd == NULL) {
+			if (!pd) {
 				peer->pdg_size--;
 				retval = -ENOMEM;
 				goto unlock;
@@ -1229,7 +1229,7 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
 	}
 
 	ptask = kmem_cache_alloc(fwnet_packet_task_cache, GFP_ATOMIC);
-	if (ptask == NULL)
+	if (!ptask)
 		goto unlock;
 
 	skb = skb_share_check(skb, GFP_ATOMIC);
@@ -1443,7 +1443,7 @@ static int fwnet_probe(struct fw_unit *unit,
 
 	net = alloc_netdev(sizeof(*dev), "firewire%d", NET_NAME_UNKNOWN,
 			   fwnet_init_dev);
-	if (net == NULL) {
+	if (!net) {
 		mutex_unlock(&fwnet_device_mutex);
 		return -ENOMEM;
 	}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (85 preceding siblings ...)
  2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
@ 2016-09-18 12:48 ` SF Markus Elfring
  2016-09-18 12:50   ` [PATCH 1/6] firmware-qemu_fw_cfg: Use kmalloc_array() in fw_cfg_register_dir_entries() SF Markus Elfring
                     ` (6 more replies)
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
                   ` (8 subsequent siblings)
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:48 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 14:43:21 +0200

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

Markus Elfring (6):
  Use kmalloc_array() in fw_cfg_register_dir_entries()
  Improve a size determination in fw_cfg_register_file()
  Rename jump labels in fw_cfg_register_file()
  Improve a size determination in fw_cfg_build_symlink()
  Rename jump labels in fw_cfg_sysfs_probe()
  Move a variable assignment in fw_cfg_sysfs_probe()

 drivers/firmware/qemu_fw_cfg.c | 53 +++++++++++++++++++++---------------------
 1 file changed, 27 insertions(+), 26 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] firmware-qemu_fw_cfg: Use kmalloc_array() in fw_cfg_register_dir_entries()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-18 12:50   ` SF Markus Elfring
  2016-09-18 12:52   ` [PATCH 2/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_register_file() SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:50 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 09:39:31 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data structure by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "dir_size" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index 0e20116..e69653e 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -491,17 +491,17 @@ static int fw_cfg_register_dir_entries(void)
 	int ret = 0;
 	u32 count, i;
 	struct fw_cfg_file *dir;
-	size_t dir_size;
 
 	fw_cfg_read_blob(FW_CFG_FILE_DIR, &count, 0, sizeof(count));
 	count = be32_to_cpu(count);
-	dir_size = count * sizeof(struct fw_cfg_file);
-
-	dir = kmalloc(dir_size, GFP_KERNEL);
+	dir = kmalloc_array(count, sizeof(*dir), GFP_KERNEL);
 	if (!dir)
 		return -ENOMEM;
 
-	fw_cfg_read_blob(FW_CFG_FILE_DIR, dir, sizeof(count), dir_size);
+	fw_cfg_read_blob(FW_CFG_FILE_DIR,
+			 dir,
+			 sizeof(count),
+			 sizeof(*dir) * count);
 
 	for (i = 0; i < count; i++) {
 		dir[i].size = be32_to_cpu(dir[i].size);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_register_file()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-18 12:50   ` [PATCH 1/6] firmware-qemu_fw_cfg: Use kmalloc_array() in fw_cfg_register_dir_entries() SF Markus Elfring
@ 2016-09-18 12:52   ` SF Markus Elfring
  2016-09-18 12:53   ` [PATCH 3/6] firmware-qemu_fw_cfg: Rename jump labels " SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:52 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 10:43:27 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index e69653e..a229df6 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -458,7 +458,7 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)
 		return -ENOMEM;
 
 	/* set file entry information */
-	memcpy(&entry->f, f, sizeof(struct fw_cfg_file));
+	memcpy(&entry->f, f, sizeof(*f));
 
 	/* register entry under "/sys/firmware/qemu_fw_cfg/by_key/" */
 	err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] firmware-qemu_fw_cfg: Rename jump labels in fw_cfg_register_file()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-18 12:50   ` [PATCH 1/6] firmware-qemu_fw_cfg: Use kmalloc_array() in fw_cfg_register_dir_entries() SF Markus Elfring
  2016-09-18 12:52   ` [PATCH 2/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_register_file() SF Markus Elfring
@ 2016-09-18 12:53   ` SF Markus Elfring
  2016-09-18 12:55   ` [PATCH 4/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_build_symlink() SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:53 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 11:23:46 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a229df6..a834d01 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -464,12 +464,12 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)
 	err = kobject_init_and_add(&entry->kobj, &fw_cfg_sysfs_entry_ktype,
 				   fw_cfg_sel_ko, "%d", entry->f.select);
 	if (err)
-		goto err_register;
+		goto free_entry;
 
 	/* add raw binary content access */
 	err = sysfs_create_bin_file(&entry->kobj, &fw_cfg_sysfs_attr_raw);
 	if (err)
-		goto err_add_raw;
+		goto delete_object;
 
 	/* try adding "/sys/firmware/qemu_fw_cfg/by_name/" symlink */
 	fw_cfg_build_symlink(fw_cfg_fname_kset, &entry->kobj, entry->f.name);
@@ -477,10 +477,9 @@ static int fw_cfg_register_file(const struct fw_cfg_file *f)
 	/* success, add entry to global cache */
 	fw_cfg_sysfs_cache_enlist(entry);
 	return 0;
-
-err_add_raw:
+ delete_object:
 	kobject_del(&entry->kobj);
-err_register:
+ free_entry:
 	kfree(entry);
 	return err;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_build_symlink()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-18 12:53   ` [PATCH 3/6] firmware-qemu_fw_cfg: Rename jump labels " SF Markus Elfring
@ 2016-09-18 12:55   ` SF Markus Elfring
  2016-09-18 12:56   ` [PATCH 5/6] firmware-qemu_fw_cfg: Rename jump labels in fw_cfg_sysfs_probe() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:55 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 14:02:02 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a834d01..a4b108a 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -399,7 +399,7 @@ static int fw_cfg_build_symlink(struct kset *dir,
 			dir = to_kset(ko);
 		} else {
 			/* create new subdirectory kset */
-			subdir = kzalloc(sizeof(struct kset), GFP_KERNEL);
+			subdir = kzalloc(sizeof(*subdir), GFP_KERNEL);
 			if (!subdir) {
 				ret = -ENOMEM;
 				break;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] firmware-qemu_fw_cfg: Rename jump labels in fw_cfg_sysfs_probe()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-18 12:55   ` [PATCH 4/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_build_symlink() SF Markus Elfring
@ 2016-09-18 12:56   ` SF Markus Elfring
  2016-09-18 12:58   ` [PATCH 6/6] firmware-qemu_fw_cfg: Move a variable assignment " SF Markus Elfring
  2016-09-20 11:09   ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations Gabriel L. Somlo
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:56 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 14:04:48 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a4b108a..a09e59c 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -538,42 +538,41 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
 	err = -ENOMEM;
 	fw_cfg_sel_ko = kobject_create_and_add("by_key", fw_cfg_top_ko);
 	if (!fw_cfg_sel_ko)
-		goto err_sel;
+		goto exit;
 	fw_cfg_fname_kset = kset_create_and_add("by_name", NULL, fw_cfg_top_ko);
 	if (!fw_cfg_fname_kset)
-		goto err_name;
+		goto cleanup_object;
 
 	/* initialize fw_cfg device i/o from platform data */
 	err = fw_cfg_do_platform_probe(pdev);
 	if (err)
-		goto err_probe;
+		goto unregister;
 
 	/* get revision number, add matching top-level attribute */
 	fw_cfg_read_blob(FW_CFG_ID, &fw_cfg_rev, 0, sizeof(fw_cfg_rev));
 	fw_cfg_rev = le32_to_cpu(fw_cfg_rev);
 	err = sysfs_create_file(fw_cfg_top_ko, &fw_cfg_rev_attr.attr);
 	if (err)
-		goto err_rev;
+		goto cleanup_io;
 
 	/* process fw_cfg file directory entry, registering each file */
 	err = fw_cfg_register_dir_entries();
 	if (err)
-		goto err_dir;
+		goto cleanup_cache;
 
 	/* success */
 	pr_debug("fw_cfg: loaded.\n");
 	return 0;
-
-err_dir:
+ cleanup_cache:
 	fw_cfg_sysfs_cache_cleanup();
 	sysfs_remove_file(fw_cfg_top_ko, &fw_cfg_rev_attr.attr);
-err_rev:
+ cleanup_io:
 	fw_cfg_io_cleanup();
-err_probe:
+ unregister:
 	fw_cfg_kset_unregister_recursive(fw_cfg_fname_kset);
-err_name:
+ cleanup_object:
 	fw_cfg_kobj_cleanup(fw_cfg_sel_ko);
-err_sel:
+ exit:
 	return err;
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] firmware-qemu_fw_cfg: Move a variable assignment in fw_cfg_sysfs_probe()
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-18 12:56   ` [PATCH 5/6] firmware-qemu_fw_cfg: Rename jump labels in fw_cfg_sysfs_probe() SF Markus Elfring
@ 2016-09-18 12:58   ` SF Markus Elfring
  2016-09-20 11:09   ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations Gabriel L. Somlo
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 12:58 UTC (permalink / raw)
  To: qemu-devel, Gabriel Somlo, Michael S. Tsirkin
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 14:25:55 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignment into
two if branches to indicate a software failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/firmware/qemu_fw_cfg.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index a09e59c..23293a1 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -535,13 +535,16 @@ static int fw_cfg_sysfs_probe(struct platform_device *pdev)
 		return -EBUSY;
 
 	/* create by_key and by_name subdirs of /sys/firmware/qemu_fw_cfg/ */
-	err = -ENOMEM;
 	fw_cfg_sel_ko = kobject_create_and_add("by_key", fw_cfg_top_ko);
-	if (!fw_cfg_sel_ko)
+	if (!fw_cfg_sel_ko) {
+		err = -ENOMEM;
 		goto exit;
+	}
 	fw_cfg_fname_kset = kset_create_and_add("by_name", NULL, fw_cfg_top_ko);
-	if (!fw_cfg_fname_kset)
+	if (!fw_cfg_fname_kset) {
+		err = -ENOMEM;
 		goto cleanup_object;
+	}
 
 	/* initialize fw_cfg device i/o from platform data */
 	err = fw_cfg_do_platform_probe(pdev);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] drm/amdgpu: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (86 preceding siblings ...)
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-18 16:48 ` SF Markus Elfring
  2016-09-18 16:50   ` [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() SF Markus Elfring
                     ` (4 more replies)
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
                   ` (7 subsequent siblings)
  95 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:48 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 18:38:48 +0200

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

Markus Elfring (5):
  Use kmalloc_array() in amdgpu_debugfs_gca_config_read()
  Improve determination of sizes in two functions
  Rename a jump label in amdgpu_debugfs_regs_read()
  Rename a jump label in amdgpu_device_init()
  Adjust checks for null pointers in nine functions

 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 68 +++++++++++++++---------------
 1 file changed, 33 insertions(+), 35 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read()
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
@ 2016-09-18 16:50   ` SF Markus Elfring
  2016-09-19 17:25     ` Alex Deucher
  2016-09-18 16:51   ` [PATCH 2/5] drm/amdgpu: Improve determination of sizes in two functions SF Markus Elfring
                     ` (3 subsequent siblings)
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:50 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 17:00:52 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index df7ab245..2709ebd 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2438,7 +2438,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
 	if (size & 0x3 || *pos & 0x3)
 		return -EINVAL;
 
-	config = kmalloc(256 * sizeof(*config), GFP_KERNEL);
+	config = kmalloc_array(256, sizeof(*config), GFP_KERNEL);
 	if (!config)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] drm/amdgpu: Improve determination of sizes in two functions
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
  2016-09-18 16:50   ` [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() SF Markus Elfring
@ 2016-09-18 16:51   ` SF Markus Elfring
  2016-09-18 16:52   ` [PATCH 3/5] drm/amdgpu: Rename a jump label in amdgpu_debugfs_regs_read() SF Markus Elfring
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:51 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 17:24:47 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2709ebd..96a2457 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -855,7 +855,7 @@ static void amdgpu_atombios_fini(struct amdgpu_device *adev)
 static int amdgpu_atombios_init(struct amdgpu_device *adev)
 {
 	struct card_info *atom_card_info =
-	    kzalloc(sizeof(struct card_info), GFP_KERNEL);
+	    kzalloc(sizeof(*atom_card_info), GFP_KERNEL);
 
 	if (!atom_card_info)
 		return -ENOMEM;
@@ -1224,7 +1224,8 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
 	}
 
 	adev->ip_block_status = kcalloc(adev->num_ip_blocks,
-					sizeof(struct amdgpu_ip_block_status), GFP_KERNEL);
+					sizeof(*adev->ip_block_status),
+					GFP_KERNEL);
 	if (adev->ip_block_status == NULL)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] drm/amdgpu: Rename a jump label in amdgpu_debugfs_regs_read()
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
  2016-09-18 16:50   ` [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() SF Markus Elfring
  2016-09-18 16:51   ` [PATCH 2/5] drm/amdgpu: Improve determination of sizes in two functions SF Markus Elfring
@ 2016-09-18 16:52   ` SF Markus Elfring
  2016-09-18 16:53   ` [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init() SF Markus Elfring
  2016-09-18 16:54   ` [PATCH 5/5] drm/amdgpu: Adjust checks for null pointers in nine functions SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:52 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 17:35:24 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 96a2457..2b8ba97 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -2208,13 +2208,13 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
 		uint32_t value;
 
 		if (*pos > adev->rmmio_size)
-			goto end;
+			goto check_bank;
 
 		value = RREG32(*pos >> 2);
 		r = put_user(value, (uint32_t *)buf);
 		if (r) {
 			result = r;
-			goto end;
+			goto check_bank;
 		}
 
 		result += 4;
@@ -2222,8 +2222,7 @@ static ssize_t amdgpu_debugfs_regs_read(struct file *f, char __user *buf,
 		*pos += 4;
 		size -= 4;
 	}
-
-end:
+ check_bank:
 	if (use_bank) {
 		amdgpu_gfx_select_se_sh(adev, 0xffffffff, 0xffffffff, 0xffffffff);
 		mutex_unlock(&adev->grbm_idx_mutex);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init()
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-18 16:52   ` [PATCH 3/5] drm/amdgpu: Rename a jump label in amdgpu_debugfs_regs_read() SF Markus Elfring
@ 2016-09-18 16:53   ` SF Markus Elfring
  2016-09-19 13:56     ` Deucher, Alexander
  2016-09-18 16:54   ` [PATCH 5/5] drm/amdgpu: Adjust checks for null pointers in nine functions SF Markus Elfring
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:53 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 17:50:09 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 2b8ba97..fed4854 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1566,18 +1566,18 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	/* Read BIOS */
 	if (!amdgpu_get_bios(adev)) {
 		r = -EINVAL;
-		goto failed;
+		goto check_runtime;
 	}
 	/* Must be an ATOMBIOS */
 	if (!adev->is_atom_bios) {
 		dev_err(adev->dev, "Expecting atombios for GPU\n");
 		r = -EINVAL;
-		goto failed;
+		goto check_runtime;
 	}
 	r = amdgpu_atombios_init(adev);
 	if (r) {
 		dev_err(adev->dev, "amdgpu_atombios_init failed\n");
-		goto failed;
+		goto check_runtime;
 	}
 
 	/* See if the asic supports SR-IOV */
@@ -1595,7 +1595,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 		if (!adev->bios) {
 			dev_err(adev->dev, "Card not posted and no BIOS - ignoring\n");
 			r = -EINVAL;
-			goto failed;
+			goto check_runtime;
 		}
 		DRM_INFO("GPU not posted. posting now...\n");
 		amdgpu_atom_asic_init(adev->mode_info.atom_context);
@@ -1605,7 +1605,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	r = amdgpu_atombios_get_clock_info(adev);
 	if (r) {
 		dev_err(adev->dev, "amdgpu_atombios_get_clock_info failed\n");
-		goto failed;
+		goto check_runtime;
 	}
 	/* init i2c buses */
 	amdgpu_atombios_i2c_init(adev);
@@ -1614,7 +1614,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	r = amdgpu_fence_driver_init(adev);
 	if (r) {
 		dev_err(adev->dev, "amdgpu_fence_driver_init failed\n");
-		goto failed;
+		goto check_runtime;
 	}
 
 	/* init the mode config */
@@ -1624,7 +1624,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	if (r) {
 		dev_err(adev->dev, "amdgpu_init failed\n");
 		amdgpu_fini(adev);
-		goto failed;
+		goto check_runtime;
 	}
 
 	adev->accel_working = true;
@@ -1634,7 +1634,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	r = amdgpu_ib_pool_init(adev);
 	if (r) {
 		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
-		goto failed;
+		goto check_runtime;
 	}
 
 	r = amdgpu_ib_ring_tests(adev);
@@ -1682,12 +1682,11 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	r = amdgpu_late_init(adev);
 	if (r) {
 		dev_err(adev->dev, "amdgpu_late_init failed\n");
-		goto failed;
+		goto check_runtime;
 	}
 
 	return 0;
-
-failed:
+ check_runtime:
 	if (runtime)
 		vga_switcheroo_fini_domain_pm_ops(adev->dev);
 	return r;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] drm/amdgpu: Adjust checks for null pointers in nine functions
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-18 16:53   ` [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init() SF Markus Elfring
@ 2016-09-18 16:54   ` SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-18 16:54 UTC (permalink / raw)
  To: dri-devel, Alex Deucher, Christian König, Chunming Zhou,
	David Airlie, Monk Liu, Tom St Denis
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 18 Sep 2016 18:32:28 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* The script "checkpatch.pl" can point information out like the following.

  Comparison to NULL could be written !…

  Thus fix the affected source code places.

* Do also not use curly brackets at corresponding source code places
  where a single statement should be sufficient.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 +++++++++++++++---------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index fed4854..b5b7cfb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -251,7 +251,7 @@ static int amdgpu_vram_scratch_init(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (adev->vram_scratch.robj == NULL) {
+	if (!adev->vram_scratch.robj) {
 		r = amdgpu_bo_create(adev, AMDGPU_GPU_PAGE_SIZE,
 				     PAGE_SIZE, true, AMDGPU_GEM_DOMAIN_VRAM,
 				     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
@@ -283,9 +283,9 @@ static void amdgpu_vram_scratch_fini(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (adev->vram_scratch.robj == NULL) {
+	if (!adev->vram_scratch.robj)
 		return;
-	}
+
 	r = amdgpu_bo_reserve(adev->vram_scratch.robj, false);
 	if (likely(r == 0)) {
 		amdgpu_bo_kunmap(adev->vram_scratch.robj);
@@ -359,9 +359,9 @@ static int amdgpu_doorbell_init(struct amdgpu_device *adev)
 		return -EINVAL;
 
 	adev->doorbell.ptr = ioremap(adev->doorbell.base, adev->doorbell.num_doorbells * sizeof(u32));
-	if (adev->doorbell.ptr == NULL) {
+	if (!adev->doorbell.ptr)
 		return -ENOMEM;
-	}
+
 	DRM_INFO("doorbell mmio base: 0x%08X\n", (uint32_t)adev->doorbell.base);
 	DRM_INFO("doorbell mmio size: %u\n", (unsigned)adev->doorbell.size);
 
@@ -456,7 +456,7 @@ static int amdgpu_wb_init(struct amdgpu_device *adev)
 {
 	int r;
 
-	if (adev->wb.wb_obj == NULL) {
+	if (!adev->wb.wb_obj) {
 		r = amdgpu_bo_create(adev, AMDGPU_MAX_WB * 4, PAGE_SIZE, true,
 				     AMDGPU_GEM_DOMAIN_GTT, 0,  NULL, NULL,
 				     &adev->wb.wb_obj);
@@ -657,7 +657,7 @@ int amdgpu_dummy_page_init(struct amdgpu_device *adev)
 	if (adev->dummy_page.page)
 		return 0;
 	adev->dummy_page.page = alloc_page(GFP_DMA32 | GFP_KERNEL | __GFP_ZERO);
-	if (adev->dummy_page.page == NULL)
+	if (!adev->dummy_page.page)
 		return -ENOMEM;
 	adev->dummy_page.addr = pci_map_page(adev->pdev, adev->dummy_page.page,
 					0, PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
@@ -679,7 +679,7 @@ int amdgpu_dummy_page_init(struct amdgpu_device *adev)
  */
 void amdgpu_dummy_page_fini(struct amdgpu_device *adev)
 {
-	if (adev->dummy_page.page == NULL)
+	if (!adev->dummy_page.page)
 		return;
 	pci_unmap_page(adev->pdev, adev->dummy_page.addr,
 			PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
@@ -1226,10 +1226,10 @@ static int amdgpu_early_init(struct amdgpu_device *adev)
 	adev->ip_block_status = kcalloc(adev->num_ip_blocks,
 					sizeof(*adev->ip_block_status),
 					GFP_KERNEL);
-	if (adev->ip_block_status == NULL)
+	if (!adev->ip_block_status)
 		return -ENOMEM;
 
-	if (adev->ip_blocks == NULL) {
+	if (!adev->ip_blocks) {
 		DRM_ERROR("No IP blocks found!\n");
 		return r;
 	}
@@ -1525,9 +1525,9 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 	adev->rmmio_base = pci_resource_start(adev->pdev, 5);
 	adev->rmmio_size = pci_resource_len(adev->pdev, 5);
 	adev->rmmio = ioremap(adev->rmmio_base, adev->rmmio_size);
-	if (adev->rmmio == NULL) {
+	if (!adev->rmmio)
 		return -ENOMEM;
-	}
+
 	DRM_INFO("register mmio base: 0x%08X\n", (uint32_t)adev->rmmio_base);
 	DRM_INFO("register mmio size: %u\n", (unsigned)adev->rmmio_size);
 
@@ -1542,7 +1542,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 			break;
 		}
 	}
-	if (adev->rio_mem == NULL)
+	if (!adev->rio_mem)
 		DRM_ERROR("Unable to find PCI I/O BAR\n");
 
 	/* early init functions */
@@ -1758,9 +1758,8 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
 	struct drm_connector *connector;
 	int r;
 
-	if (dev == NULL || dev->dev_private == NULL) {
+	if (!dev || !dev->dev_private)
 		return -ENODEV;
-	}
 
 	adev = dev->dev_private;
 
@@ -1791,9 +1790,9 @@ int amdgpu_suspend_kms(struct drm_device *dev, bool suspend, bool fbcon)
 			}
 		}
 
-		if (rfb == NULL || rfb->obj == NULL) {
+		if (!rfb || !rfb->obj)
 			continue;
-		}
+
 		robj = gem_to_amdgpu_bo(rfb->obj);
 		/* don't unpin kernel fb objects */
 		if (!amdgpu_fbdev_robj_is_fb(adev, robj)) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk()
  2016-09-13 18:31                 ` Ilya Dryomov
@ 2016-09-19  9:37                   ` Jean Delvare
  0 siblings, 0 replies; 1373+ messages in thread
From: Jean Delvare @ 2016-09-19  9:37 UTC (permalink / raw)
  To: Ilya Dryomov
  Cc: Jonathan Corbet, Ceph Development, Alex Elder, Sage Weil, LKML,
	kernel-janitors, Julia Lawall, Andrew Morton

Hi Ilya,

Sorry for the late answer.

On Tue, 13 Sep 2016 20:31:57 +0200, Ilya Dryomov wrote:
> Sorry, navigating lkml.org archive is a pain, and I was expecting to
> see patch.  Your points
> 
> "The acceptance of an optional single space before labels dates back to
> at least June 2007, as supported by the very first incarnation of
> checkpatch.pl. So nothing really new here, except for a preference
> (my preference, admittedly, but I'm know I'm not alone) being expressed
> in the coding style document."
> 
> "Recommendations are not meant to document what people are currently
> doing but what we think they should be doing."
> 
> are valid, but note that there is a world of difference between an
> acceptance and a preference.  The *only* point of whitespace guidelines
> is to keep the code base consistent.

Consistency is half of the reason, the other half is readability. This
is why the CodingStyle document has a number of rationales explained.
This is also why we put whitespace in the first place, while the C
language doesn't require any ;-)

The sense of my proposal was to address a readability (or usability)
issue.

> You don't go changing whitespace
> preferences in such a huge project, not unless you have a *very* good
> rationale and existing code base is swayed (which it isn't, given the
> 9/10 ratio).

I did consider the reason to be good enough to warrant a "change",
actually. Or more exactly from "one space is allowed" to "one space is
recommended." Which is quite different from changing all the code
actively. I can understand how you don't like it, but again, this
"inconsistency" has been accepted for almost a decade now, so I find it
strange to see so much resistance when someone finally tries to sort it
out.

> >> If I wanted to clarify the
> >> situation, I'd have gone with "one space indented labels are also
> >> acceptable" or so.  The example you've re-indented dates back to 2.6.4
> >> times...
> >
> > I can't see how this is relevant.
> 
> That was a 12 year old example, codifying an existing style used in
> ~90% cases, serving as a guideline for new contributors.

OK, I get your point now. But the CodingStyle document isn't carved
into stone. I see 43 changes to that file in recent history (since
April 2005), some of which are actual changes or clarifications of our
coding style. This very section of the document was updated in December
2014, so not so long ago.

In the end I suppose it boils down to how problematic you consider the
current situation to be. Apparently you and several other maintainers
think it's just fine, while me (and a few others apparently) think it
is not.

> >> git diff also works on regular files, BTW.
> >
> > I have no idea what you mean here, sorry.
> 
> Oh, just that it works outside of git repos too, so you aren't stuck
> with diffutils if you want to diff two random .c files.

Oh, I had never thought of that. Thanks for the hint :-)

> > (...)
> > http://marc.info/?l=linux-kernel&m=147325166209844&w=2
> >
> > It uses the git diff xfuncname feature you mentioned above. To be
> > honest I'm surprised it isn't the git default, it seems odd to have so
> > many diff drivers included in git and not enable them on obvious file
> > extensions. Oh well.
> 
> This came up before: http://www.spinics.net/lists/git/msg164216.html,
> Linus didn't like it.  I suggest you add him to the CC on this patch to
> see if he changed his mind.

Thanks for the pointer. It is interesting to see many people had been
bothered by the same problem for many years and even proposed solution
for it. But also sad to see that nothing happened :-(

Well Linus suggested to improve the default, he was not opposed to the
change per se I think. But it was 5 years ago and nothing happened
since then, so I'd rather go with what is available today. Which means
either one space before labels, or drivers in .gitattributes. Choose
your poison ;-)

Thanks,
-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* RE: [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init()
  2016-09-18 16:53   ` [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init() SF Markus Elfring
@ 2016-09-19 13:56     ` Deucher, Alexander
  0 siblings, 0 replies; 1373+ messages in thread
From: Deucher, Alexander @ 2016-09-19 13:56 UTC (permalink / raw)
  To: 'SF Markus Elfring',
	dri-devel, Koenig, Christian, Zhou, David(ChunMing),
	David Airlie, Liu, Monk, StDenis, Tom
  Cc: LKML, kernel-janitors, Julia Lawall

> -----Original Message-----
> From: SF Markus Elfring [mailto:elfring@users.sourceforge.net]
> Sent: Sunday, September 18, 2016 12:53 PM
> To: dri-devel@lists.freedesktop.org; Deucher, Alexander; Koenig, Christian;
> Zhou, David(ChunMing); David Airlie; Liu, Monk; StDenis, Tom
> Cc: LKML; kernel-janitors@vger.kernel.org; Julia Lawall
> Subject: [PATCH 4/5] drm/amdgpu: Rename a jump label in
> amdgpu_device_init()
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 18 Sep 2016 17:50:09 +0200
> 
> Adjust jump labels according to the current Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 21 ++++++++++----------
> -
>  1 file changed, 10 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 2b8ba97..fed4854 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -1566,18 +1566,18 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	/* Read BIOS */
>  	if (!amdgpu_get_bios(adev)) {
>  		r = -EINVAL;
> -		goto failed;
> +		goto check_runtime;

NACK.  Failed is a more appropriate label here.  The runtime check is just part of the failure cleanup.

Alex

>  	}
>  	/* Must be an ATOMBIOS */
>  	if (!adev->is_atom_bios) {
>  		dev_err(adev->dev, "Expecting atombios for GPU\n");
>  		r = -EINVAL;
> -		goto failed;
> +		goto check_runtime;
>  	}
>  	r = amdgpu_atombios_init(adev);
>  	if (r) {
>  		dev_err(adev->dev, "amdgpu_atombios_init failed\n");
> -		goto failed;
> +		goto check_runtime;
>  	}
> 
>  	/* See if the asic supports SR-IOV */
> @@ -1595,7 +1595,7 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  		if (!adev->bios) {
>  			dev_err(adev->dev, "Card not posted and no BIOS -
> ignoring\n");
>  			r = -EINVAL;
> -			goto failed;
> +			goto check_runtime;
>  		}
>  		DRM_INFO("GPU not posted. posting now...\n");
>  		amdgpu_atom_asic_init(adev->mode_info.atom_context);
> @@ -1605,7 +1605,7 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	r = amdgpu_atombios_get_clock_info(adev);
>  	if (r) {
>  		dev_err(adev->dev, "amdgpu_atombios_get_clock_info
> failed\n");
> -		goto failed;
> +		goto check_runtime;
>  	}
>  	/* init i2c buses */
>  	amdgpu_atombios_i2c_init(adev);
> @@ -1614,7 +1614,7 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	r = amdgpu_fence_driver_init(adev);
>  	if (r) {
>  		dev_err(adev->dev, "amdgpu_fence_driver_init failed\n");
> -		goto failed;
> +		goto check_runtime;
>  	}
> 
>  	/* init the mode config */
> @@ -1624,7 +1624,7 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	if (r) {
>  		dev_err(adev->dev, "amdgpu_init failed\n");
>  		amdgpu_fini(adev);
> -		goto failed;
> +		goto check_runtime;
>  	}
> 
>  	adev->accel_working = true;
> @@ -1634,7 +1634,7 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	r = amdgpu_ib_pool_init(adev);
>  	if (r) {
>  		dev_err(adev->dev, "IB initialization failed (%d).\n", r);
> -		goto failed;
> +		goto check_runtime;
>  	}
> 
>  	r = amdgpu_ib_ring_tests(adev);
> @@ -1682,12 +1682,11 @@ int amdgpu_device_init(struct amdgpu_device
> *adev,
>  	r = amdgpu_late_init(adev);
>  	if (r) {
>  		dev_err(adev->dev, "amdgpu_late_init failed\n");
> -		goto failed;
> +		goto check_runtime;
>  	}
> 
>  	return 0;
> -
> -failed:
> + check_runtime:
>  	if (runtime)
>  		vga_switcheroo_fini_domain_pm_ops(adev->dev);
>  	return r;
> --
> 2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (87 preceding siblings ...)
  2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
@ 2016-09-19 15:51 ` SF Markus Elfring
  2016-09-19 15:53   ` [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring
                     ` (4 more replies)
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
                   ` (6 subsequent siblings)
  95 siblings, 5 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:51 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:47:37 +0200

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

Markus Elfring (5):
  Use kmalloc_array() in drm_legacy_addbufs_pci()
  Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()
  Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
  Rename a jump label in drm_legacy_mapbufs()

 drivers/gpu/drm/drm_bufs.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci()
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-19 15:53   ` SF Markus Elfring
  2016-09-19 15:54   ` [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() " SF Markus Elfring
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:53 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:07:06 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 3219151..ed33f43 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -923,8 +923,9 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
 	/* Keep the original pagelist until we know all the allocations
 	 * have succeeded
 	 */
-	temp_pagelist = kmalloc((dma->page_count + (count << page_order)) *
-			       sizeof(*dma->pagelist), GFP_KERNEL);
+	temp_pagelist = kmalloc_array(dma->page_count + (count << page_order),
+				      sizeof(*dma->pagelist),
+				      GFP_KERNEL);
 	if (!temp_pagelist) {
 		kfree(entry->buflist);
 		kfree(entry->seglist);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() in drm_legacy_addbufs_pci()
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-19 15:53   ` [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring
@ 2016-09-19 15:54   ` SF Markus Elfring
  2016-09-19 15:55   ` [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp() SF Markus Elfring
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:54 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:17:34 +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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index ed33f43..8a31dac 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -905,14 +905,14 @@ int drm_legacy_addbufs_pci(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
 		return -ENOMEM;
 	}
 
-	entry->seglist = kzalloc(count * sizeof(*entry->seglist), GFP_KERNEL);
+	entry->seglist = kcalloc(count, sizeof(*entry->seglist), GFP_KERNEL);
 	if (!entry->seglist) {
 		kfree(entry->buflist);
 		mutex_unlock(&dev->struct_mutex);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp()
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
  2016-09-19 15:53   ` [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring
  2016-09-19 15:54   ` [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() " SF Markus Elfring
@ 2016-09-19 15:55   ` SF Markus Elfring
  2016-09-19 15:56   ` [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() SF Markus Elfring
  2016-09-19 15:58   ` [PATCH 5/5] GPU-DRM: Rename a jump label in drm_legacy_mapbufs() SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:55 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:24:20 +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 place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 8a31dac..36dd685 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -755,7 +755,7 @@ int drm_legacy_addbufs_agp(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist), GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-19 15:55   ` [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp() SF Markus Elfring
@ 2016-09-19 15:56   ` SF Markus Elfring
  2016-09-21 11:22     ` Daniel Vetter
  2016-09-19 15:58   ` [PATCH 5/5] GPU-DRM: Rename a jump label in drm_legacy_mapbufs() SF Markus Elfring
  4 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:56 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:30:31 +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 place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index 36dd685..adb1dd7 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1117,8 +1117,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
 		return -EINVAL;
 	}
 
-	entry->buflist = kzalloc(count * sizeof(*entry->buflist),
-				GFP_KERNEL);
+	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
 	if (!entry->buflist) {
 		mutex_unlock(&dev->struct_mutex);
 		atomic_dec(&dev->buf_alloc);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/5] GPU-DRM: Rename a jump label in drm_legacy_mapbufs()
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-19 15:56   ` [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() SF Markus Elfring
@ 2016-09-19 15:58   ` SF Markus Elfring
  4 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-19 15:58 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 19 Sep 2016 17:37:27 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/drm_bufs.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
index adb1dd7..0d5ee1e 100644
--- a/drivers/gpu/drm/drm_bufs.c
+++ b/drivers/gpu/drm/drm_bufs.c
@@ -1476,7 +1476,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 
 			if (!map) {
 				retcode = -EINVAL;
-				goto done;
+				goto status_indication;
 			}
 			virtual = vm_mmap(file_priv->filp, 0, map->size,
 					  PROT_READ | PROT_WRITE,
@@ -1490,7 +1490,7 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 		if (virtual > -1024UL) {
 			/* Real error */
 			retcode = (signed long)virtual;
-			goto done;
+			goto status_indication;
 		}
 		request->virtual = (void __user *)virtual;
 
@@ -1499,28 +1499,28 @@ int drm_legacy_mapbufs(struct drm_device *dev, void *data,
 					 &dma->buflist[i]->idx,
 					 sizeof(request->list[0].idx))) {
 				retcode = -EFAULT;
-				goto done;
+				goto status_indication;
 			}
 			if (copy_to_user(&request->list[i].total,
 					 &dma->buflist[i]->total,
 					 sizeof(request->list[0].total))) {
 				retcode = -EFAULT;
-				goto done;
+				goto status_indication;
 			}
 			if (copy_to_user(&request->list[i].used,
 					 &zero, sizeof(zero))) {
 				retcode = -EFAULT;
-				goto done;
+				goto status_indication;
 			}
 			address = virtual + dma->buflist[i]->offset;	/* *** */
 			if (copy_to_user(&request->list[i].address,
 					 &address, sizeof(address))) {
 				retcode = -EFAULT;
-				goto done;
+				goto status_indication;
 			}
 		}
 	}
-      done:
+ status_indication:
 	request->count = dma->buf_count;
 	DRM_DEBUG("%d buffers, retcode = %d\n", request->count, retcode);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read()
  2016-09-18 16:50   ` [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() SF Markus Elfring
@ 2016-09-19 17:25     ` Alex Deucher
  0 siblings, 0 replies; 1373+ messages in thread
From: Alex Deucher @ 2016-09-19 17:25 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Maling list - DRI developers, Alex Deucher, Christian König,
	Chunming Zhou, David Airlie, Monk Liu, Tom St Denis,
	Julia Lawall, kernel-janitors, LKML

On Sun, Sep 18, 2016 at 12:50 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 18 Sep 2016 17:00:52 +0200
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Applied.  thanks.

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index df7ab245..2709ebd 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -2438,7 +2438,7 @@ static ssize_t amdgpu_debugfs_gca_config_read(struct file *f, char __user *buf,
>         if (size & 0x3 || *pos & 0x3)
>                 return -EINVAL;
>
> -       config = kmalloc(256 * sizeof(*config), GFP_KERNEL);
> +       config = kmalloc_array(256, sizeof(*config), GFP_KERNEL);
>         if (!config)
>                 return -ENOMEM;
>
> --
> 2.10.0
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (88 preceding siblings ...)
  2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
@ 2016-09-20  8:54 ` SF Markus Elfring
  2016-09-20  8:55   ` [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10() SF Markus Elfring
                     ` (5 more replies)
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                   ` (5 subsequent siblings)
  95 siblings, 6 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  8:54 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 10:48:04 +0200

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

Markus Elfring (6):
  Use kmalloc_array() in mid_get_vbt_data_r10()
  Rename a jump label in mid_get_vbt_data_r10()
  Move a variable assignment in mid_get_vbt_data_r10()
  Fix indentation for a function call parameter in mid_get_vbt_data_r10()
  One error message less for a GCT revision mismatch in mid_get_vbt_data()
  Rename a jump label in mid_get_vbt_data()

 drivers/gpu/drm/gma500/mid_bios.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-20  8:55   ` SF Markus Elfring
  2016-09-20 10:06     ` Jani Nikula
  2016-09-20  8:57   ` [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  8:55 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 08:54:07 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index d75ecb3..a833568 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -235,7 +235,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 	if (read_vbt_r10(addr, &vbt))
 		return -1;
 
-	gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
+	gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
 	if (!gct)
 		return -1;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label in mid_get_vbt_data_r10()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-20  8:55   ` [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10() SF Markus Elfring
@ 2016-09-20  8:57   ` SF Markus Elfring
  2016-09-20 10:05     ` Jani Nikula
  2016-09-20  8:58   ` [PATCH 3/6] GPU-DRM-GMA500: Move a variable assignment " SF Markus Elfring
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  8:57 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 09:09:10 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index a833568..cf4e605 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -242,7 +242,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 	gct_virtual = ioremap(addr + sizeof(vbt),
 			sizeof(*gct) * vbt.panel_count);
 	if (!gct_virtual)
-		goto out;
+		goto free_gct;
 	memcpy_fromio(gct, gct_virtual, sizeof(*gct));
 	iounmap(gct_virtual);
 
@@ -270,7 +270,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 	dp_ti->vsync_pulse_width_lo = ti->vsync_pulse_width_lo;
 
 	ret = 0;
-out:
+ free_gct:
 	kfree(gct);
 	return ret;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/6] GPU-DRM-GMA500: Move a variable assignment in mid_get_vbt_data_r10()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
  2016-09-20  8:55   ` [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10() SF Markus Elfring
  2016-09-20  8:57   ` [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
@ 2016-09-20  8:58   ` SF Markus Elfring
  2016-09-20  8:59   ` [PATCH 4/6] GPU-DRM-GMA500: Fix indentation for a function call parameter " SF Markus Elfring
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  8:58 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 10:32:12 +0200

One local variable was set to an error code before a concrete
error situation was detected. Thus move the corresponding assignment into
an if branch to indicate a software failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index cf4e605..3caee42 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -230,7 +230,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 	struct gct_r10 *gct;
 	struct oaktrail_timing_info *dp_ti = &dev_priv->gct_data.DTD;
 	struct gct_r10_timing_info *ti;
-	int ret = -1;
+	int ret;
 
 	if (read_vbt_r10(addr, &vbt))
 		return -1;
@@ -241,8 +241,10 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 
 	gct_virtual = ioremap(addr + sizeof(vbt),
 			sizeof(*gct) * vbt.panel_count);
-	if (!gct_virtual)
+	if (!gct_virtual) {
+		ret = -1;
 		goto free_gct;
+	}
 	memcpy_fromio(gct, gct_virtual, sizeof(*gct));
 	iounmap(gct_virtual);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/6] GPU-DRM-GMA500: Fix indentation for a function call parameter in mid_get_vbt_data_r10()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-20  8:58   ` [PATCH 3/6] GPU-DRM-GMA500: Move a variable assignment " SF Markus Elfring
@ 2016-09-20  8:59   ` SF Markus Elfring
  2016-09-20  9:00   ` [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data() SF Markus Elfring
  2016-09-20  9:01   ` [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
  5 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  8:59 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 10:34:28 +0200

Adjust the indentation for a single function call parameter here.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index 3caee42..9004d30 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -240,7 +240,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
 		return -1;
 
 	gct_virtual = ioremap(addr + sizeof(vbt),
-			sizeof(*gct) * vbt.panel_count);
+			      sizeof(*gct) * vbt.panel_count);
 	if (!gct_virtual) {
 		ret = -1;
 		goto free_gct;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-20  8:59   ` [PATCH 4/6] GPU-DRM-GMA500: Fix indentation for a function call parameter " SF Markus Elfring
@ 2016-09-20  9:00   ` SF Markus Elfring
  2016-09-20 10:07     ` Jani Nikula
  2016-09-20  9:01   ` [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
  5 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  9:00 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 10:36:19 +0200

A single error message should be sufficient to inform about
the detection of an unknown GCT revision at the end.
Thus return after the logging call in this case directly.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index 9004d30..e5cece0 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -320,6 +320,7 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 		break;
 	default:
 		dev_err(dev->dev, "Unknown revision of GCT!\n");
+		return;
 	}
 
 out:
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label in mid_get_vbt_data()
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-20  9:00   ` [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data() SF Markus Elfring
@ 2016-09-20  9:01   ` SF Markus Elfring
  2016-09-20 10:08     ` Jani Nikula
  5 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20  9:01 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 20 Sep 2016 10:40:22 +0200

* Adjust a jump target.

* Delete the explicit initialisation for the local variable "ret"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/gma500/mid_bios.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
index e5cece0..602d16f 100644
--- a/drivers/gpu/drm/gma500/mid_bios.c
+++ b/drivers/gpu/drm/gma500/mid_bios.c
@@ -284,7 +284,7 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 	u8 __iomem *vbt_virtual;
 	struct mid_vbt_header vbt_header;
 	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
-	int ret = -1;
+	int ret;
 
 	/* Get the address of the platform config vbt */
 	pci_read_config_dword(pci_gfx_root, 0xFC, &addr);
@@ -293,18 +293,18 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 	dev_dbg(dev->dev, "drm platform config address is %x\n", addr);
 
 	if (!addr)
-		goto out;
+		goto report_failure;
 
 	/* get the virtual address of the vbt */
 	vbt_virtual = ioremap(addr, sizeof(vbt_header));
 	if (!vbt_virtual)
-		goto out;
+		goto report_failure;
 
 	memcpy_fromio(&vbt_header, vbt_virtual, sizeof(vbt_header));
 	iounmap(vbt_virtual);
 
 	if (memcmp(&vbt_header.signature, "$GCT", 4))
-		goto out;
+		goto report_failure;
 
 	dev_dbg(dev->dev, "GCT revision is %02x\n", vbt_header.revision);
 
@@ -322,9 +322,8 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
 		dev_err(dev->dev, "Unknown revision of GCT!\n");
 		return;
 	}
-
-out:
 	if (ret)
+ report_failure:
 		dev_err(dev->dev, "Unable to read GCT!");
 	else
 		dev_priv->has_gct = true;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label in mid_get_vbt_data_r10()
  2016-09-20  8:57   ` [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
@ 2016-09-20 10:05     ` Jani Nikula
  0 siblings, 0 replies; 1373+ messages in thread
From: Jani Nikula @ 2016-09-20 10:05 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson
  Cc: Julia Lawall, kernel-janitors, LKML

On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 20 Sep 2016 09:09:10 +0200
>
> Adjust a jump label according to the current Linux coding style convention.

Generally, please don't send patches to fix checkpatch issues in
existing code. Moreover, this particular "convention" is just something
someone sneaked into CodingStyle, it's subjective, and it's probably
going to be removed soon.

NAK.

BR,
Jani.

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/gma500/mid_bios.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
> index a833568..cf4e605 100644
> --- a/drivers/gpu/drm/gma500/mid_bios.c
> +++ b/drivers/gpu/drm/gma500/mid_bios.c
> @@ -242,7 +242,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
>  	gct_virtual = ioremap(addr + sizeof(vbt),
>  			sizeof(*gct) * vbt.panel_count);
>  	if (!gct_virtual)
> -		goto out;
> +		goto free_gct;
>  	memcpy_fromio(gct, gct_virtual, sizeof(*gct));
>  	iounmap(gct_virtual);
>  
> @@ -270,7 +270,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
>  	dp_ti->vsync_pulse_width_lo = ti->vsync_pulse_width_lo;
>  
>  	ret = 0;
> -out:
> + free_gct:
>  	kfree(gct);
>  	return ret;
>  }

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10()
  2016-09-20  8:55   ` [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10() SF Markus Elfring
@ 2016-09-20 10:06     ` Jani Nikula
  2016-09-20 10:30       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jani Nikula @ 2016-09-20 10:06 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson
  Cc: Julia Lawall, kernel-janitors, LKML

On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 20 Sep 2016 08:54:07 +0200
>
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
>
> This issue was detected by using the Coccinelle software.

Did you test this running on the hardware?

BR,
Jani.

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/gma500/mid_bios.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
> index d75ecb3..a833568 100644
> --- a/drivers/gpu/drm/gma500/mid_bios.c
> +++ b/drivers/gpu/drm/gma500/mid_bios.c
> @@ -235,7 +235,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
>  	if (read_vbt_r10(addr, &vbt))
>  		return -1;
>  
> -	gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
> +	gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
>  	if (!gct)
>  		return -1;

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20  9:00   ` [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data() SF Markus Elfring
@ 2016-09-20 10:07     ` Jani Nikula
  2016-09-20 10:32       ` SF Markus Elfring
  2016-09-20 10:48       ` [PATCH 5/6] " Dan Carpenter
  0 siblings, 2 replies; 1373+ messages in thread
From: Jani Nikula @ 2016-09-20 10:07 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson
  Cc: Julia Lawall, kernel-janitors, LKML

On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 20 Sep 2016 10:36:19 +0200
>
> A single error message should be sufficient to inform about
> the detection of an unknown GCT revision at the end.
> Thus return after the logging call in this case directly.

Did you test this?

BR,
Jani.

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/gma500/mid_bios.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
> index 9004d30..e5cece0 100644
> --- a/drivers/gpu/drm/gma500/mid_bios.c
> +++ b/drivers/gpu/drm/gma500/mid_bios.c
> @@ -320,6 +320,7 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
>  		break;
>  	default:
>  		dev_err(dev->dev, "Unknown revision of GCT!\n");
> +		return;
>  	}
>  
>  out:

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label in mid_get_vbt_data()
  2016-09-20  9:01   ` [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
@ 2016-09-20 10:08     ` Jani Nikula
  2016-09-20 12:40       ` Dan Carpenter
  0 siblings, 1 reply; 1373+ messages in thread
From: Jani Nikula @ 2016-09-20 10:08 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson
  Cc: Julia Lawall, kernel-janitors, LKML

On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 20 Sep 2016 10:40:22 +0200
>
> * Adjust a jump target.

Please don't.

BR,
Jani.

>
> * Delete the explicit initialisation for the local variable "ret"
>   which became unnecessary with this refactoring.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/gma500/mid_bios.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c
> index e5cece0..602d16f 100644
> --- a/drivers/gpu/drm/gma500/mid_bios.c
> +++ b/drivers/gpu/drm/gma500/mid_bios.c
> @@ -284,7 +284,7 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
>  	u8 __iomem *vbt_virtual;
>  	struct mid_vbt_header vbt_header;
>  	struct pci_dev *pci_gfx_root = pci_get_bus_and_slot(0, PCI_DEVFN(2, 0));
> -	int ret = -1;
> +	int ret;
>  
>  	/* Get the address of the platform config vbt */
>  	pci_read_config_dword(pci_gfx_root, 0xFC, &addr);
> @@ -293,18 +293,18 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
>  	dev_dbg(dev->dev, "drm platform config address is %x\n", addr);
>  
>  	if (!addr)
> -		goto out;
> +		goto report_failure;
>  
>  	/* get the virtual address of the vbt */
>  	vbt_virtual = ioremap(addr, sizeof(vbt_header));
>  	if (!vbt_virtual)
> -		goto out;
> +		goto report_failure;
>  
>  	memcpy_fromio(&vbt_header, vbt_virtual, sizeof(vbt_header));
>  	iounmap(vbt_virtual);
>  
>  	if (memcmp(&vbt_header.signature, "$GCT", 4))
> -		goto out;
> +		goto report_failure;
>  
>  	dev_dbg(dev->dev, "GCT revision is %02x\n", vbt_header.revision);
>  
> @@ -322,9 +322,8 @@ static void mid_get_vbt_data(struct drm_psb_private *dev_priv)
>  		dev_err(dev->dev, "Unknown revision of GCT!\n");
>  		return;
>  	}
> -
> -out:
>  	if (ret)
> + report_failure:
>  		dev_err(dev->dev, "Unable to read GCT!");
>  	else
>  		dev_priv->has_gct = true;

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10()
  2016-09-20 10:06     ` Jani Nikula
@ 2016-09-20 10:30       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20 10:30 UTC (permalink / raw)
  To: Jani Nikula, dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson
  Cc: Julia Lawall, kernel-janitors, LKML

>> A multiplication for the size determination of a memory allocation
>> indicated that an array data structure should be processed.
>> Thus use the corresponding function "kmalloc_array".
>>
>> This issue was detected by using the Coccinelle software.
> 
> Did you test this running on the hardware?

No. - My "test computer" does not provide the corresponding hardware for the
affected driver source files.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 10:07     ` Jani Nikula
@ 2016-09-20 10:32       ` SF Markus Elfring
  2016-09-20 10:48       ` [PATCH 5/6] " Dan Carpenter
  1 sibling, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20 10:32 UTC (permalink / raw)
  To: Jani Nikula
  Cc: dri-devel, Daniel Vetter, David Airlie, Patrik Jakobsson,
	Julia Lawall, kernel-janitors, LKML

>> A single error message should be sufficient to inform about
>> the detection of an unknown GCT revision at the end.
>> Thus return after the logging call in this case directly.
> 
> Did you test this?

What is your software development opinion for this update suggestion?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 10:07     ` Jani Nikula
  2016-09-20 10:32       ` SF Markus Elfring
@ 2016-09-20 10:48       ` Dan Carpenter
  2016-09-20 11:03         ` SF Markus Elfring
  2016-09-20 12:08         ` [PATCH 5/6] " Jani Nikula
  1 sibling, 2 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-09-20 10:48 UTC (permalink / raw)
  To: Jani Nikula
  Cc: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

On Tue, Sep 20, 2016 at 01:07:35PM +0300, Jani Nikula wrote:
> On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 20 Sep 2016 10:36:19 +0200
> >
> > A single error message should be sufficient to inform about
> > the detection of an unknown GCT revision at the end.
> > Thus return after the logging call in this case directly.
> 
> Did you test this?
> 

Don't be a dummy...  This is easy to review an it fixes a bug.

I'm fine with you NAKing all these patches based on who they are from.
I mostly just delete these without responding because the guy has
history of introducing bugs and never listens to feedback.  But asking
pointless rhetorical questions is not helpful.

A lot of people are CC'd and you're wasting everyone's time by asking
questions where you know the answer.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 10:48       ` [PATCH 5/6] " Dan Carpenter
@ 2016-09-20 11:03         ` SF Markus Elfring
  2016-09-20 11:17           ` Dan Carpenter
  2016-09-20 12:08         ` [PATCH 5/6] " Jani Nikula
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20 11:03 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jani Nikula, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

>>> A single error message should be sufficient to inform about
>>> the detection of an unknown GCT revision at the end.
>>> Thus return after the logging call in this case directly.
>>
>> Did you test this?
>>
> 
> Don't be a dummy...  This is easy to review an it fixes a bug.

Thanks for this kind of constructive feedback.


> I'm fine with you NAKing all these patches based on who they are from.

Would you like to clarify such an information a bit more?


> I mostly just delete these without responding because the guy has
> history of introducing bugs and never listens to feedback.

I admit that I'll stumble on programming mistakes again occasionally
as another ordinary free software developer who is struggling various open issues.

I am listening to various feedback. My responses might not be pleasing enough
for you. Are you looking for any special information to improve
a corresponding discussion?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations
  2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-18 12:58   ` [PATCH 6/6] firmware-qemu_fw_cfg: Move a variable assignment " SF Markus Elfring
@ 2016-09-20 11:09   ` Gabriel L. Somlo
  6 siblings, 0 replies; 1373+ messages in thread
From: Gabriel L. Somlo @ 2016-09-20 11:09 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: qemu-devel, Michael S. Tsirkin, LKML, kernel-janitors, Julia Lawall

On Sun, Sep 18, 2016 at 02:48:30PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 18 Sep 2016 14:43:21 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (6):
>   Use kmalloc_array() in fw_cfg_register_dir_entries()
>   Improve a size determination in fw_cfg_register_file()
>   Rename jump labels in fw_cfg_register_file()
>   Improve a size determination in fw_cfg_build_symlink()
>   Rename jump labels in fw_cfg_sysfs_probe()
>   Move a variable assignment in fw_cfg_sysfs_probe()

Acked-by: Gabriel Somlo <somlo@cmu.edu>

>  drivers/firmware/qemu_fw_cfg.c | 53 +++++++++++++++++++++---------------------
>  1 file changed, 27 insertions(+), 26 deletions(-)
> 
> -- 
> 2.10.0
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 11:03         ` SF Markus Elfring
@ 2016-09-20 11:17           ` Dan Carpenter
  2016-09-20 11:30             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2016-09-20 11:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jani Nikula, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

On Tue, Sep 20, 2016 at 01:03:06PM +0200, SF Markus Elfring wrote:
> Are you looking for any special information to improve
> a corresponding discussion?

If you restricted yourself to only sending bug fixes and not sending
any more cleanups that would be good.

Please stop sending clean up patches.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 11:17           ` Dan Carpenter
@ 2016-09-20 11:30             ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-20 11:30 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Jani Nikula, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

> If you restricted yourself to only sending bug fixes and not sending
> any more cleanups that would be good.

Thanks for another bit of constructive feedback.


> Please stop sending clean up patches.

This will not happen for a while.

I am in the process of informing various developers about some software
update opportunities. The proposed changes will belong to a mixture of error
categories as you observe them so far usually.

The involved static source code analysis will point more details out
for further considerations, won't it?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 10:48       ` [PATCH 5/6] " Dan Carpenter
  2016-09-20 11:03         ` SF Markus Elfring
@ 2016-09-20 12:08         ` Jani Nikula
  2016-09-20 20:23           ` Patrik Jakobsson
  1 sibling, 1 reply; 1373+ messages in thread
From: Jani Nikula @ 2016-09-20 12:08 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

On Tue, 20 Sep 2016, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Don't be a dummy...  This is easy to review an it fixes a bug.
>
> I'm fine with you NAKing all these patches based on who they are from.
> I mostly just delete these without responding because the guy has
> history of introducing bugs and never listens to feedback.  But asking
> pointless rhetorical questions is not helpful.
>
> A lot of people are CC'd and you're wasting everyone's time by asking
> questions where you know the answer.

Fair enough, sorry for the noise.

To be honest, I did only look at the patches, not who they were from. We
have CI for drm/i915, but I don't think it's constructive to keep
changing drivers like this where the upstream isn't actively developed
and tested. But I digress. It's up to Patrik anyway.

BR,
Jani.



-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label in mid_get_vbt_data()
  2016-09-20 10:08     ` Jani Nikula
@ 2016-09-20 12:40       ` Dan Carpenter
  0 siblings, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-09-20 12:40 UTC (permalink / raw)
  To: Jani Nikula
  Cc: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie,
	Patrik Jakobsson, Julia Lawall, kernel-janitors, LKML

On Tue, Sep 20, 2016 at 01:08:12PM +0300, Jani Nikula wrote:
> On Tue, 20 Sep 2016, SF Markus Elfring <elfring@users.sourceforge.net> wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Tue, 20 Sep 2016 10:40:22 +0200
> >
> > * Adjust a jump target.
> 
> Please don't.
> 

Also there is nothing in CodingStyle that prohibits out: labels.  I
wrote that section and I wrote it in a deliberately way because no one
wants to see a bunch of "cleanup" patches that change the label names
for no reason.

People have been complaining about this in the kernel-summit mailing
list as if CodingStyle bans out labels and that it's my fault.  Neither
of these complaints are accurate.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data()
  2016-09-20 12:08         ` [PATCH 5/6] " Jani Nikula
@ 2016-09-20 20:23           ` Patrik Jakobsson
  0 siblings, 0 replies; 1373+ messages in thread
From: Patrik Jakobsson @ 2016-09-20 20:23 UTC (permalink / raw)
  To: Jani Nikula
  Cc: Dan Carpenter, SF Markus Elfring, dri-devel, Daniel Vetter,
	David Airlie, Julia Lawall, kernel-janitors, LKML

On Tue, Sep 20, 2016 at 2:08 PM, Jani Nikula
<jani.nikula@linux.intel.com> wrote:
> On Tue, 20 Sep 2016, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>> Don't be a dummy...  This is easy to review an it fixes a bug.

In this particular case it might not be clear that an unknown GCT
version causes a complete GCT failure so both messages are useful.

>>
>> I'm fine with you NAKing all these patches based on who they are from.
>> I mostly just delete these without responding because the guy has
>> history of introducing bugs and never listens to feedback.  But asking
>> pointless rhetorical questions is not helpful.
>>
>> A lot of people are CC'd and you're wasting everyone's time by asking
>> questions where you know the answer.
>
> Fair enough, sorry for the noise.
>
> To be honest, I did only look at the patches, not who they were from. We
> have CI for drm/i915, but I don't think it's constructive to keep
> changing drivers like this where the upstream isn't actively developed
> and tested. But I digress. It's up to Patrik anyway.

Nothing in this series is very helpful so NAK. In general I'm not fond
of trivial changes like this since it's hard to say what motivates the
author. In theory it shouldn't matter but so far it's been directly
related to the quality of the patches. I can help test changes for
gma500 if needed but please make it worth my while.

Best regards
Patrik

>
> BR,
> Jani.
>
>
>
> --
> Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg()
  2016-09-19 15:56   ` [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() SF Markus Elfring
@ 2016-09-21 11:22     ` Daniel Vetter
  0 siblings, 0 replies; 1373+ messages in thread
From: Daniel Vetter @ 2016-09-21 11:22 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, Julia Lawall,
	kernel-janitors, LKML

On Mon, Sep 19, 2016 at 05:56:49PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 19 Sep 2016 17:30:31 +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 place.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Merged patches 1-4. I agree with Jani that changing jump labels is a pure
bikeshed, so didn't apply them.

Also I'll repeat that imo checkpatch patches are great to get started, but
it's much better to do more involved work. Both since that tends to be
more interesting, and fixing all the checkpatch issues will rob the next
newbies of some great starting opportunity. Which means from now on I'll
only selectively apply your checkpatch patches.

We have todo list with some ideas at:

https://www.x.org/wiki/DRMJanitors/

Thanks, Daniel
> ---
>  drivers/gpu/drm/drm_bufs.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_bufs.c b/drivers/gpu/drm/drm_bufs.c
> index 36dd685..adb1dd7 100644
> --- a/drivers/gpu/drm/drm_bufs.c
> +++ b/drivers/gpu/drm/drm_bufs.c
> @@ -1117,8 +1117,7 @@ static int drm_legacy_addbufs_sg(struct drm_device *dev,
>  		return -EINVAL;
>  	}
>  
> -	entry->buflist = kzalloc(count * sizeof(*entry->buflist),
> -				GFP_KERNEL);
> +	entry->buflist = kcalloc(count, sizeof(*entry->buflist), GFP_KERNEL);
>  	if (!entry->buflist) {
>  		mutex_unlock(&dev->struct_mutex);
>  		atomic_dec(&dev->buf_alloc);
> -- 
> 2.10.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection
  2016-09-14 14:01   ` [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring
@ 2016-09-21 12:10     ` Amit Shah
  2016-09-21 13:06       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Amit Shah @ 2016-09-21 12:10 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: virtualization, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell, LKML, kernel-janitors,
	Julia Lawall

Hi,

On (Wed) 14 Sep 2016 [16:01:28], SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 14 Sep 2016 14:00:35 +0200
> 
> The kfree() function was called in up to five cases
> by the init_vqs() function during error handling even if
> the passed variable contained a null pointer.
> 
> * Return directly after a call of the function "kmalloc_array" failed
>   at the beginning.
> 
> * Split a condition check for memory allocation failures so that
>   each pointer from these function calls will be checked immediately.
> 
>   See also background information:
>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>   Link: https://cwe.mitre.org/data/definitions/754.html
> 
> * Adjust jump targets according to the Linux coding style convention.

So I've seen this series and I'm not yet sure how I feel about the
patches - f.e. in this one, it adds more lines than it removes to
achieve the same effect.  I think the code is currently more readable
than after these changes.  And even if kfree is called multiple times,
it isn't a huge bother -- it's error case anyway, very unlikely to
trigger, but keeps everything very readble.


		Amit

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: virtio_console: Less function calls in init_vqs() after error detection
  2016-09-21 12:10     ` Amit Shah
@ 2016-09-21 13:06       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 13:06 UTC (permalink / raw)
  To: Amit Shah
  Cc: virtualization, Arnd Bergmann, Greg Kroah-Hartman,
	Michael S. Tsirkin, Rusty Russell, LKML, kernel-janitors,
	Julia Lawall

>> The kfree() function was called in up to five cases
>> by the init_vqs() function during error handling even if
>> the passed variable contained a null pointer.
>>
>> * Return directly after a call of the function "kmalloc_array" failed
>>   at the beginning.
>>
>> * Split a condition check for memory allocation failures so that
>>   each pointer from these function calls will be checked immediately.
>>
>>   See also background information:
>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>
>> * Adjust jump targets according to the Linux coding style convention.
> 
> So I've seen this series and I'm not yet sure how I feel about the
> patches - f.e. in this one, it adds more lines than it removes to
> achieve the same effect.

I find this consequence still debatable.


> I think the code is currently more readable than after these changes.

Thanks for your constructive feedback.

Can it be that an other software development concern is eventually overlooked?


> And even if kfree is called multiple times, it isn't a huge bother

I know also that the implementation of this function tolerates the passing
of null pointers.


> -- it's error case anyway, very unlikely to trigger, but keeps everything very readble.

I suggest to reconsider this design detail if it is really acceptable
for the safe implementation of such a software module.

* How much will it matter in general that four function call were performed
  in this use case without checking their return values immediately?

* Should it usually be determined quicker if a required resource like
  memory could be acquired before trying the next allocation?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (89 preceding siblings ...)
  2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
@ 2016-09-21 16:35 ` SF Markus Elfring
  2016-09-21 16:38   ` [PATCH 01/14] GPU-DRM-OMAP: Use kmalloc_array() in tiler_map_show() SF Markus Elfring
                     ` (15 more replies)
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
                   ` (4 subsequent siblings)
  95 siblings, 16 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:35 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 18:28:38 +0200

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

Markus Elfring (14):
  Use kmalloc_array() in tiler_map_show()
  Replace another kmalloc() call by kmalloc_array() in tiler_map_show()
  Less function calls in tiler_map_show() after error detection
  Delete an unnecessary variable initialisation in tiler_map_show()
  Improve a size determination in dmm_txn_append()
  Improve a size determination in omap_dmm_probe()
  Rename a jump label in omap_dmm_probe()
  Rename a jump label in dmm_txn_commit()
  Delete an unnecessary variable initialisation in dmm_txn_commit()
  Use kmalloc_array() in omap_gem_attach_pages()
  Replace a kzalloc() call by kcalloc() in omap_gem_attach_pages()
  Move a variable assignment in omap_gem_attach_pages()
  Rename a jump label in omap_gem_new_dmabuf()
  Rename a jump label in four functions

 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 58 ++++++++++++++++----------------
 drivers/gpu/drm/omapdrm/omap_gem.c       | 44 +++++++++++-------------
 2 files changed, 49 insertions(+), 53 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/14] GPU-DRM-OMAP: Use kmalloc_array() in tiler_map_show()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-21 16:38   ` SF Markus Elfring
  2016-09-21 16:39   ` [PATCH 02/14] GPU-DRM-OMAP: Replace another kmalloc() call by " SF Markus Elfring
                     ` (14 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:38 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 12:23:46 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 4ceed7a9..7b32dd3 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -917,8 +917,7 @@ int tiler_map_show(struct seq_file *s, void *arg)
 
 	h_adj = omap_dmm->container_height / ydiv;
 	w_adj = omap_dmm->container_width / xdiv;
-
-	map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
+	map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
 	global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
 
 	if (!map || !global_map)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/14] GPU-DRM-OMAP: Replace another kmalloc() call by kmalloc_array() in tiler_map_show()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-21 16:38   ` [PATCH 01/14] GPU-DRM-OMAP: Use kmalloc_array() in tiler_map_show() SF Markus Elfring
@ 2016-09-21 16:39   ` SF Markus Elfring
  2016-09-21 16:40   ` [PATCH 03/14] GPU-DRM-OMAP: Less function calls in tiler_map_show() after error detection SF Markus Elfring
                     ` (13 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:39 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 12:54:07 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array" at another place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 7b32dd3..3a4f91b 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -918,8 +918,7 @@ int tiler_map_show(struct seq_file *s, void *arg)
 	h_adj = omap_dmm->container_height / ydiv;
 	w_adj = omap_dmm->container_width / xdiv;
 	map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
-	global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
-
+	global_map = kmalloc_array(h_adj, w_adj + 1, GFP_KERNEL);
 	if (!map || !global_map)
 		goto error;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/14] GPU-DRM-OMAP: Less function calls in tiler_map_show() after error detection
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-21 16:38   ` [PATCH 01/14] GPU-DRM-OMAP: Use kmalloc_array() in tiler_map_show() SF Markus Elfring
  2016-09-21 16:39   ` [PATCH 02/14] GPU-DRM-OMAP: Replace another kmalloc() call by " SF Markus Elfring
@ 2016-09-21 16:40   ` SF Markus Elfring
  2016-09-21 16:41   ` [PATCH 04/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in tiler_map_show() Markus Elfring
                     ` (12 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:40 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 13:16:20 +0200

The kfree() function was called in up to two cases
by the tiler_map_show() function during error handling even if
the passed variable contained a null pointer.

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

* Split a condition check for memory allocation failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

* Return directly after a call of the function "kmalloc_array" failed
  at the beginning.

* Move an assignment for the local variable "w_adj" behind the first
  memory allocation.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 3a4f91b..60beeb9 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -916,11 +916,14 @@ int tiler_map_show(struct seq_file *s, void *arg)
 	}
 
 	h_adj = omap_dmm->container_height / ydiv;
-	w_adj = omap_dmm->container_width / xdiv;
 	map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
+	if (!map)
+		return 0;
+
+	w_adj = omap_dmm->container_width / xdiv;
 	global_map = kmalloc_array(h_adj, w_adj + 1, GFP_KERNEL);
-	if (!map || !global_map)
-		goto error;
+	if (!global_map)
+		goto free_map;
 
 	for (lut_idx = 0; lut_idx < omap_dmm->num_lut; lut_idx++) {
 		memset(map, 0, h_adj * sizeof(*map));
@@ -982,10 +985,9 @@ int tiler_map_show(struct seq_file *s, void *arg)
 		}
 	}
 
-error:
-	kfree(map);
 	kfree(global_map);
-
+ free_map:
+	kfree(map);
 	return 0;
 }
 #endif
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in tiler_map_show()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-21 16:40   ` [PATCH 03/14] GPU-DRM-OMAP: Less function calls in tiler_map_show() after error detection SF Markus Elfring
@ 2016-09-21 16:41   ` Markus Elfring
  2016-09-21 16:45   ` SF Markus Elfring
                     ` (11 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: Markus Elfring @ 2016-09-21 16:41 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 13:31:45 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 60beeb9..c262ef5 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -896,7 +896,7 @@ static void map_2d_info(char **map, int xdiv, int ydiv, char *nice,
 int tiler_map_show(struct seq_file *s, void *arg)
 {
 	int xdiv = 2, ydiv = 1;
-	char **map = NULL, *global_map;
+	char **map, *global_map;
 	struct tiler_block *block;
 	struct tcm_area a, p;
 	int i;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in tiler_map_show()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-21 16:41   ` [PATCH 04/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in tiler_map_show() Markus Elfring
@ 2016-09-21 16:45   ` SF Markus Elfring
  2016-09-21 16:46   ` [PATCH 05/14] GPU-DRM-OMAP: Improve a size determination in dmm_txn_append() SF Markus Elfring
                     ` (10 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:45 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 13:31:45 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 60beeb9..c262ef5 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -896,7 +896,7 @@ static void map_2d_info(char **map, int xdiv, int ydiv, char *nice,
 int tiler_map_show(struct seq_file *s, void *arg)
 {
 	int xdiv = 2, ydiv = 1;
-	char **map = NULL, *global_map;
+	char **map, *global_map;
 	struct tiler_block *block;
 	struct tcm_area a, p;
 	int i;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/14] GPU-DRM-OMAP: Improve a size determination in dmm_txn_append()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-21 16:45   ` SF Markus Elfring
@ 2016-09-21 16:46   ` SF Markus Elfring
  2016-09-21 16:47   ` [PATCH 06/14] GPU-DRM-OMAP: Improve a size determination in omap_dmm_probe() SF Markus Elfring
                     ` (9 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:46 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 13:53:11 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index c262ef5..f110965 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -224,7 +224,7 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
 	int rows = (1 + area->y1 - area->y0);
 	int i = columns*rows;
 
-	pat = alloc_dma(txn, sizeof(struct pat), &pat_pa);
+	pat = alloc_dma(txn, sizeof(*pat), &pat_pa);
 
 	if (txn->last_pat)
 		txn->last_pat->next_pa = (uint32_t)pat_pa;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/14] GPU-DRM-OMAP: Improve a size determination in omap_dmm_probe()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-21 16:46   ` [PATCH 05/14] GPU-DRM-OMAP: Improve a size determination in dmm_txn_append() SF Markus Elfring
@ 2016-09-21 16:47   ` SF Markus Elfring
  2016-09-21 16:48   ` [PATCH 07/14] GPU-DRM-OMAP: Rename a jump label " SF Markus Elfring
                     ` (8 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:47 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:21:57 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index f110965..c6a7197 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -735,7 +735,8 @@ static int omap_dmm_probe(struct platform_device *dev)
 
 	/* alloc engines */
 	omap_dmm->engines = kcalloc(omap_dmm->num_engines,
-				    sizeof(struct refill_engine), GFP_KERNEL);
+				    sizeof(*omap_dmm->engines),
+				    GFP_KERNEL);
 	if (!omap_dmm->engines) {
 		ret = -ENOMEM;
 		goto fail;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/14] GPU-DRM-OMAP: Rename a jump label in omap_dmm_probe()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-21 16:47   ` [PATCH 06/14] GPU-DRM-OMAP: Improve a size determination in omap_dmm_probe() SF Markus Elfring
@ 2016-09-21 16:48   ` SF Markus Elfring
  2016-09-21 16:49   ` [PATCH 08/14] GPU-DRM-OMAP: Rename a jump label in dmm_txn_commit() SF Markus Elfring
                     ` (7 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:48 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:30:25 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index c6a7197..5f6f21b 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -624,7 +624,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 
 	omap_dmm = kzalloc(sizeof(*omap_dmm), GFP_KERNEL);
 	if (!omap_dmm)
-		goto fail;
+		goto check_dmm_removal;
 
 	/* initialize lists */
 	INIT_LIST_HEAD(&omap_dmm->alloc_head);
@@ -648,20 +648,20 @@ static int omap_dmm_probe(struct platform_device *dev)
 	mem = platform_get_resource(dev, IORESOURCE_MEM, 0);
 	if (!mem) {
 		dev_err(&dev->dev, "failed to get base address resource\n");
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	omap_dmm->base = ioremap(mem->start, SZ_2K);
 
 	if (!omap_dmm->base) {
 		dev_err(&dev->dev, "failed to get dmm base address\n");
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	omap_dmm->irq = platform_get_irq(dev, 0);
 	if (omap_dmm->irq < 0) {
 		dev_err(&dev->dev, "failed to get IRQ resource\n");
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	omap_dmm->dev = &dev->dev;
@@ -699,7 +699,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 		dev_err(&dev->dev, "couldn't register IRQ %d, error %d\n",
 			omap_dmm->irq, ret);
 		omap_dmm->irq = -1;
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	/* Enable all interrupts for each refill engine except
@@ -714,13 +714,13 @@ static int omap_dmm_probe(struct platform_device *dev)
 	if (!omap_dmm->dummy_page) {
 		dev_err(&dev->dev, "could not allocate dummy page\n");
 		ret = -ENOMEM;
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	/* set dma mask for device */
 	ret = dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(32));
 	if (ret)
-		goto fail;
+		goto check_dmm_removal;
 
 	omap_dmm->dummy_pa = page_to_phys(omap_dmm->dummy_page);
 
@@ -730,7 +730,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 					   &omap_dmm->refill_pa, GFP_KERNEL);
 	if (!omap_dmm->refill_va) {
 		dev_err(&dev->dev, "could not allocate refill memory\n");
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	/* alloc engines */
@@ -739,7 +739,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 				    GFP_KERNEL);
 	if (!omap_dmm->engines) {
 		ret = -ENOMEM;
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	for (i = 0; i < omap_dmm->num_engines; i++) {
@@ -758,7 +758,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 				GFP_KERNEL);
 	if (!omap_dmm->tcm) {
 		ret = -ENOMEM;
-		goto fail;
+		goto check_dmm_removal;
 	}
 
 	/* init containers */
@@ -772,7 +772,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 		if (!omap_dmm->tcm[i]) {
 			dev_err(&dev->dev, "failed to allocate container\n");
 			ret = -ENOMEM;
-			goto fail;
+			goto check_dmm_removal;
 		}
 
 		omap_dmm->tcm[i]->lut_id = i;
@@ -812,8 +812,7 @@ static int omap_dmm_probe(struct platform_device *dev)
 	dev_info(omap_dmm->dev, "initialized all PAT entries\n");
 
 	return 0;
-
-fail:
+ check_dmm_removal:
 	if (omap_dmm_remove(dev))
 		dev_err(&dev->dev, "cleanup failed\n");
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/14] GPU-DRM-OMAP: Rename a jump label in dmm_txn_commit()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-21 16:48   ` [PATCH 07/14] GPU-DRM-OMAP: Rename a jump label " SF Markus Elfring
@ 2016-09-21 16:49   ` SF Markus Elfring
  2016-09-21 16:50   ` [PATCH 09/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation " SF Markus Elfring
                     ` (6 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:49 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:32:42 +0200

Adjust a jump target so that redundant checks can be avoided at the end.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index 5f6f21b..c8ced158 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -269,7 +269,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
 	if (!txn->last_pat) {
 		dev_err(engine->dmm->dev, "need at least one txn\n");
 		ret = -EINVAL;
-		goto cleanup;
+		goto release_engine;
 	}
 
 	txn->last_pat->next_pa = 0;
@@ -281,7 +281,7 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
 	ret = wait_status(engine, DMM_PATSTATUS_READY);
 	if (ret) {
 		ret = -EFAULT;
-		goto cleanup;
+		goto release_engine;
 	}
 
 	/* mark whether it is async to denote list management in IRQ handler */
@@ -301,9 +301,9 @@ static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
 		}
 	}
 
-cleanup:
 	/* only place engine back on list if we are done with it */
 	if (ret || wait)
+ release_engine:
 		release_engine(engine);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in dmm_txn_commit()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-21 16:49   ` [PATCH 08/14] GPU-DRM-OMAP: Rename a jump label in dmm_txn_commit() SF Markus Elfring
@ 2016-09-21 16:50   ` SF Markus Elfring
  2016-09-21 16:52   ` [PATCH 10/14] GPU-DRM-OMAP: Use kmalloc_array() in omap_gem_attach_pages() SF Markus Elfring
                     ` (5 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:50 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:34:40 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
index c8ced158..c5c3793 100644
--- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
+++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
@@ -262,7 +262,7 @@ static void dmm_txn_append(struct dmm_txn *txn, struct pat_area *area,
  */
 static int dmm_txn_commit(struct dmm_txn *txn, bool wait)
 {
-	int ret = 0;
+	int ret;
 	struct refill_engine *engine = txn->engine_handle;
 	struct dmm *dmm = engine->dmm;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/14] GPU-DRM-OMAP: Use kmalloc_array() in omap_gem_attach_pages()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-21 16:50   ` [PATCH 09/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation " SF Markus Elfring
@ 2016-09-21 16:52   ` SF Markus Elfring
  2016-09-21 16:53   ` [PATCH 11/14] GPU-DRM-OMAP: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
                     ` (4 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:52 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:37:04 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 505dee0..e4f1924 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -259,7 +259,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 	 * DSS, GPU, etc. are not cache coherent:
 	 */
 	if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
-		addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL);
+		addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL);
 		if (!addrs) {
 			ret = -ENOMEM;
 			goto free_pages;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/14] GPU-DRM-OMAP: Replace a kzalloc() call by kcalloc() in omap_gem_attach_pages()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-21 16:52   ` [PATCH 10/14] GPU-DRM-OMAP: Use kmalloc_array() in omap_gem_attach_pages() SF Markus Elfring
@ 2016-09-21 16:53   ` SF Markus Elfring
  2016-09-21 16:54   ` [PATCH 12/14] GPU-DRM-OMAP: Move a variable assignment " SF Markus Elfring
                     ` (3 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:53 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:40:20 +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 place.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index e4f1924..26f1212 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -283,7 +283,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 			}
 		}
 	} else {
-		addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
+		addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL);
 		if (!addrs) {
 			ret = -ENOMEM;
 			goto free_pages;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/14] GPU-DRM-OMAP: Move a variable assignment in omap_gem_attach_pages()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-21 16:53   ` [PATCH 11/14] GPU-DRM-OMAP: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
@ 2016-09-21 16:54   ` SF Markus Elfring
  2016-09-21 16:55   ` [PATCH 13/14] GPU-DRM-OMAP: Rename a jump label in omap_gem_new_dmabuf() SF Markus Elfring
                     ` (2 subsequent siblings)
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:54 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:42:28 +0200

Move one assignment for the local variable "npages" so that its setting
will only be performed after a call of the function "drm_gem_get_pages"
succeeded by this function.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 26f1212..3c49ad9 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -243,7 +243,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 	struct drm_device *dev = obj->dev;
 	struct omap_gem_object *omap_obj = to_omap_bo(obj);
 	struct page **pages;
-	int npages = obj->size >> PAGE_SHIFT;
+	int npages;
 	int i, ret;
 	dma_addr_t *addrs;
 
@@ -255,6 +255,8 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 		return PTR_ERR(pages);
 	}
 
+	npages = obj->size >> PAGE_SHIFT;
+
 	/* for non-cached buffers, ensure the new pages are clean because
 	 * DSS, GPU, etc. are not cache coherent:
 	 */
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/14] GPU-DRM-OMAP: Rename a jump label in omap_gem_new_dmabuf()
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-21 16:54   ` [PATCH 12/14] GPU-DRM-OMAP: Move a variable assignment " SF Markus Elfring
@ 2016-09-21 16:55   ` SF Markus Elfring
  2016-09-21 16:56   ` [PATCH 14/14] GPU-DRM-OMAP: Rename a jump label in four functions SF Markus Elfring
  2016-09-22  6:45   ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations Daniel Vetter
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:55 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 17:45:04 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 3c49ad9..92510de 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -1442,7 +1442,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 	obj = omap_gem_new(dev, gsize, OMAP_BO_MEM_DMABUF | OMAP_BO_WC);
 	if (!obj) {
 		obj = ERR_PTR(-ENOMEM);
-		goto done;
+		goto unlock;
 	}
 
 	omap_obj = to_omap_bo(obj);
@@ -1462,7 +1462,7 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 		if (!pages) {
 			omap_gem_free_object(obj);
 			obj = ERR_PTR(-ENOMEM);
-			goto done;
+			goto unlock;
 		}
 
 		omap_obj->pages = pages;
@@ -1476,11 +1476,10 @@ struct drm_gem_object *omap_gem_new_dmabuf(struct drm_device *dev, size_t size,
 		if (WARN_ON(i != npages)) {
 			omap_gem_free_object(obj);
 			obj = ERR_PTR(-ENOMEM);
-			goto done;
+			goto unlock;
 		}
 	}
-
-done:
+ unlock:
 	mutex_unlock(&dev->struct_mutex);
 	return obj;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/14] GPU-DRM-OMAP: Rename a jump label in four functions
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-21 16:55   ` [PATCH 13/14] GPU-DRM-OMAP: Rename a jump label in omap_gem_new_dmabuf() SF Markus Elfring
@ 2016-09-21 16:56   ` SF Markus Elfring
  2016-09-22  6:45   ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations Daniel Vetter
  15 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-21 16:56 UTC (permalink / raw)
  To: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Sep 2016 18:00:23 +0200

Adjust jump labels according to the current Linux coding style convention.
Thus replace the identifier "fail" by "unlock" for this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/omapdrm/omap_gem.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c
index 92510de..ea7ad1c 100644
--- a/drivers/gpu/drm/omapdrm/omap_gem.c
+++ b/drivers/gpu/drm/omapdrm/omap_gem.c
@@ -549,7 +549,7 @@ int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 	/* if a shmem backed object, make sure we have pages attached now */
 	ret = get_pages(obj, &pages);
 	if (ret)
-		goto fail;
+		goto unlock;
 
 	/* where should we do corresponding put_pages().. we are mapping
 	 * the original page, rather than thru a GART, so we can't rely
@@ -561,9 +561,7 @@ int omap_gem_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 		ret = fault_2d(obj, vma, vmf);
 	else
 		ret = fault_1d(obj, vma, vmf);
-
-
-fail:
+ unlock:
 	mutex_unlock(&dev->struct_mutex);
 	switch (ret) {
 	case 0:
@@ -682,14 +680,13 @@ int omap_gem_dumb_map_offset(struct drm_file *file, struct drm_device *dev,
 	obj = drm_gem_object_lookup(file, handle);
 	if (obj == NULL) {
 		ret = -ENOENT;
-		goto fail;
+		goto unlock;
 	}
 
 	*offset = omap_gem_mmap_offset(obj);
 
 	drm_gem_object_unreference_unlocked(obj);
-
-fail:
+ unlock:
 	return ret;
 }
 
@@ -719,13 +716,12 @@ int omap_gem_roll(struct drm_gem_object *obj, uint32_t roll)
 		struct page **pages;
 		ret = get_pages(obj, &pages);
 		if (ret)
-			goto fail;
+			goto unlock;
 		ret = tiler_pin(omap_obj->block, pages, npages, roll, true);
 		if (ret)
 			dev_err(obj->dev->dev, "could not repin: %d\n", ret);
 	}
-
-fail:
+ unlock:
 	mutex_unlock(&obj->dev->struct_mutex);
 
 	return ret;
@@ -825,7 +821,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 
 			ret = get_pages(obj, &pages);
 			if (ret)
-				goto fail;
+				goto unlock;
 
 			if (omap_obj->flags & OMAP_BO_TILED) {
 				block = tiler_reserve_2d(fmt,
@@ -839,7 +835,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 				ret = PTR_ERR(block);
 				dev_err(obj->dev->dev,
 					"could not remap: %d (%d)\n", ret, fmt);
-				goto fail;
+				goto unlock;
 			}
 
 			/* TODO: enable async refill.. */
@@ -849,7 +845,7 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 				tiler_release(block);
 				dev_err(obj->dev->dev,
 						"could not pin: %d\n", ret);
-				goto fail;
+				goto unlock;
 			}
 
 			omap_obj->paddr = tiler_ssptr(block);
@@ -865,10 +861,9 @@ int omap_gem_get_paddr(struct drm_gem_object *obj,
 		*paddr = omap_obj->paddr;
 	} else {
 		ret = -EINVAL;
-		goto fail;
+		goto unlock;
 	}
-
-fail:
+ unlock:
 	mutex_unlock(&obj->dev->struct_mutex);
 
 	return ret;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
                     ` (14 preceding siblings ...)
  2016-09-21 16:56   ` [PATCH 14/14] GPU-DRM-OMAP: Rename a jump label in four functions SF Markus Elfring
@ 2016-09-22  6:45   ` Daniel Vetter
  2016-09-22  6:54     ` Laurent Pinchart
  15 siblings, 1 reply; 1373+ messages in thread
From: Daniel Vetter @ 2016-09-22  6:45 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, David Airlie, Laurent Pinchart, Tomi Valkeinen,
	Julia Lawall, kernel-janitors, LKML

On Wed, Sep 21, 2016 at 06:35:59PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Wed, 21 Sep 2016 18:28:38 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.

For the next pile of driver patches _please_ talk with driver maintainers
before starting to create&submit patches. Like I said I won't take them,
and many of your changes are not clear-cut at all, so I expect many driver
maintaines also won't take them. Again, your contributions are welcome,
but blindly following suggestions from code checkers in drivers you cant
test isn't really all that useful. At the scale you're doing it, I think
it's mostly wasting everyone's time :( I'd like to avoid that.

Thanks, Daniel
> 
> Markus Elfring (14):
>   Use kmalloc_array() in tiler_map_show()
>   Replace another kmalloc() call by kmalloc_array() in tiler_map_show()
>   Less function calls in tiler_map_show() after error detection
>   Delete an unnecessary variable initialisation in tiler_map_show()
>   Improve a size determination in dmm_txn_append()
>   Improve a size determination in omap_dmm_probe()
>   Rename a jump label in omap_dmm_probe()
>   Rename a jump label in dmm_txn_commit()
>   Delete an unnecessary variable initialisation in dmm_txn_commit()
>   Use kmalloc_array() in omap_gem_attach_pages()
>   Replace a kzalloc() call by kcalloc() in omap_gem_attach_pages()
>   Move a variable assignment in omap_gem_attach_pages()
>   Rename a jump label in omap_gem_new_dmabuf()
>   Rename a jump label in four functions
> 
>  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 58 ++++++++++++++++----------------
>  drivers/gpu/drm/omapdrm/omap_gem.c       | 44 +++++++++++-------------
>  2 files changed, 49 insertions(+), 53 deletions(-)
> 
> -- 
> 2.10.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations
  2016-09-22  6:45   ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations Daniel Vetter
@ 2016-09-22  6:54     ` Laurent Pinchart
  2016-09-22  9:11       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Laurent Pinchart @ 2016-09-22  6:54 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: SF Markus Elfring, dri-devel, David Airlie, Tomi Valkeinen,
	Julia Lawall, kernel-janitors, LKML

On Thursday 22 Sep 2016 08:45:01 Daniel Vetter wrote:
> On Wed, Sep 21, 2016 at 06:35:59PM +0200, SF Markus Elfring wrote:
> > From: Markus Elfring <elfring@users.sourceforge.net>
> > Date: Wed, 21 Sep 2016 18:28:38 +0200
> > 
> > Several update suggestions were taken into account
> > from static source code analysis.
> 
> For the next pile of driver patches _please_ talk with driver maintainers
> before starting to create&submit patches. Like I said I won't take them,
> and many of your changes are not clear-cut at all, so I expect many driver
> maintaines also won't take them. Again, your contributions are welcome,
> but blindly following suggestions from code checkers in drivers you cant
> test isn't really all that useful. At the scale you're doing it, I think
> it's mostly wasting everyone's time :( I'd like to avoid that.

I second that. After a very quick review, I see that the series splits related 
changes in multiple patches. I've already commented in reply to another series 
submitted by Markus that patches should then be combined. I will thus ignore 
this series completely for the time being.

> > Markus Elfring (14):
> >   Use kmalloc_array() in tiler_map_show()
> >   Replace another kmalloc() call by kmalloc_array() in tiler_map_show()
> >   Less function calls in tiler_map_show() after error detection
> >   Delete an unnecessary variable initialisation in tiler_map_show()
> >   Improve a size determination in dmm_txn_append()
> >   Improve a size determination in omap_dmm_probe()
> >   Rename a jump label in omap_dmm_probe()
> >   Rename a jump label in dmm_txn_commit()
> >   Delete an unnecessary variable initialisation in dmm_txn_commit()
> >   Use kmalloc_array() in omap_gem_attach_pages()
> >   Replace a kzalloc() call by kcalloc() in omap_gem_attach_pages()
> >   Move a variable assignment in omap_gem_attach_pages()
> >   Rename a jump label in omap_gem_new_dmabuf()
> >   Rename a jump label in four functions
> >  
> >  drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | 58 +++++++++++++--------------
> >  drivers/gpu/drm/omapdrm/omap_gem.c       | 44 +++++++++++-------------
> >  2 files changed, 49 insertions(+), 53 deletions(-)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (90 preceding siblings ...)
  2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-22  8:30 ` SF Markus Elfring
  2016-09-22  8:31   ` [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init() SF Markus Elfring
                     ` (3 more replies)
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                   ` (3 subsequent siblings)
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  8:30 UTC (permalink / raw)
  To: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 10:25:43 +0200

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

Markus Elfring (4):
  Use kmalloc_array()
  Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  Less function calls in tilcdc_convert_slave_node() after error detection
  Delete unnecessary variable initialisations

 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 36 +++++++++++++++-------------
 1 file changed, 20 insertions(+), 16 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init()
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
@ 2016-09-22  8:31   ` SF Markus Elfring
  2016-09-22 16:55     ` Jyri Sarha
  2016-09-22  8:32   ` [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node() SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  8:31 UTC (permalink / raw)
  To: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 09:05:14 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
index f9c79da..8faa28f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
@@ -32,8 +32,7 @@ static int __init kfree_table_init(struct kfree_table *kft)
 {
 	kft->total = 32;
 	kft->num = 0;
-	kft->table = kmalloc(kft->total * sizeof(*kft->table),
-			     GFP_KERNEL);
+	kft->table = kmalloc_array(kft->total, sizeof(*kft->table), GFP_KERNEL);
 	if (!kft->table)
 		return -ENOMEM;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
  2016-09-22  8:31   ` [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init() SF Markus Elfring
@ 2016-09-22  8:32   ` SF Markus Elfring
  2016-09-22 10:58     ` Dan Carpenter
  2016-09-22 16:57     ` Jyri Sarha
  2016-09-22  8:33   ` [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection SF Markus Elfring
  2016-09-22  8:34   ` [PATCH 4/4] GPU-DRM-TILCDC: Delete unnecessary variable initialisations in tilcdc_convert_slave_node() SF Markus Elfring
  3 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  8:32 UTC (permalink / raw)
  To: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 09:29:23 +0200

Return directly after a memory allocation failed in this function
at the beginning.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
index 8faa28f..6204405 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
@@ -206,7 +206,7 @@ void __init tilcdc_convert_slave_node(void)
 	int ret;
 
 	if (kfree_table_init(&kft))
-		goto out;
+		return;
 
 	lcdc = of_find_matching_node(NULL, tilcdc_of_match);
 	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
  2016-09-22  8:31   ` [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init() SF Markus Elfring
  2016-09-22  8:32   ` [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node() SF Markus Elfring
@ 2016-09-22  8:33   ` SF Markus Elfring
  2016-09-22 17:04     ` Jyri Sarha
  2016-09-22  8:34   ` [PATCH 4/4] GPU-DRM-TILCDC: Delete unnecessary variable initialisations in tilcdc_convert_slave_node() SF Markus Elfring
  3 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  8:33 UTC (permalink / raw)
  To: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 10:06:50 +0200

The of_node_put() function was called in some cases
by the tilcdc_convert_slave_node() function during error handling
even if the passed variable contained a null pointer.

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

* Split a condition check for resource detection failures so that
  each pointer from these function calls will be checked immediately.

  See also background information:
  Topic "CWE-754: Improper check for unusual or exceptional conditions"
  Link: https://cwe.mitre.org/data/definitions/754.html

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
index 6204405..6ee5865 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
@@ -209,25 +209,27 @@ void __init tilcdc_convert_slave_node(void)
 		return;
 
 	lcdc = of_find_matching_node(NULL, tilcdc_of_match);
-	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
+	if (!of_device_is_available(lcdc))
+		goto free_table;
 
-	if (!slave || !of_device_is_available(lcdc))
-		goto out;
+	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
+	if (!slave)
+		goto put_node_lcdc;
 
 	i2c = of_parse_phandle(slave, "i2c", 0);
 	if (!i2c) {
 		pr_err("%s: Can't find i2c node trough phandle\n", __func__);
-		goto out;
+		goto put_node_slave;
 	}
 
 	overlay = tilcdc_get_overlay(&kft);
 	if (!overlay)
-		goto out;
+		goto put_node_i2c;
 
 	encoder = of_find_matching_node(overlay, tilcdc_tda998x_of_match);
 	if (!encoder) {
 		pr_err("%s: Failed to find tda998x node\n", __func__);
-		goto out;
+		goto put_node_i2c;
 	}
 
 	tilcdc_copy_props(slave, encoder, tilcdc_slave_props, &kft);
@@ -238,10 +240,10 @@ void __init tilcdc_convert_slave_node(void)
 			continue;
 		if (!strncmp("i2c", (char *)prop->value, prop->length))
 			if (tilcdc_prop_str_update(prop, i2c->full_name, &kft))
-				goto out;
+				goto put_node_fragment;
 		if (!strncmp("lcdc", (char *)prop->value, prop->length))
 			if (tilcdc_prop_str_update(prop, lcdc->full_name, &kft))
-				goto out;
+				goto put_node_fragment;
 	}
 
 	tilcdc_node_disable(slave);
@@ -252,12 +254,16 @@ void __init tilcdc_convert_slave_node(void)
 	else
 		pr_info("%s: ti,tilcdc,slave node successfully converted\n",
 			__func__);
-out:
-	kfree_table_free(&kft);
+ put_node_fragment:
+	of_node_put(fragment);
+ put_node_i2c:
 	of_node_put(i2c);
+ put_node_slave:
 	of_node_put(slave);
+ put_node_lcdc:
 	of_node_put(lcdc);
-	of_node_put(fragment);
+ free_table:
+	kfree_table_free(&kft);
 }
 
 int __init tilcdc_slave_compat_init(void)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] GPU-DRM-TILCDC: Delete unnecessary variable initialisations in tilcdc_convert_slave_node()
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-22  8:33   ` [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection SF Markus Elfring
@ 2016-09-22  8:34   ` SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  8:34 UTC (permalink / raw)
  To: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 10:15:36 +0200

Four local variables will be set to an appropriate pointer a bit later.
Thus omit the explicit initialisation which became unnecessary with
a previous update step.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
index 6ee5865..ae90728 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
@@ -196,8 +196,7 @@ static const char * const tilcdc_slave_props[] __initconst = {
 
 void __init tilcdc_convert_slave_node(void)
 {
-	struct device_node *slave = NULL, *lcdc = NULL;
-	struct device_node *i2c = NULL, *fragment = NULL;
+	struct device_node *slave, *lcdc, *i2c, *fragment;
 	struct device_node *overlay, *encoder;
 	struct property *prop;
 	/* For all memory needed for the overlay tree. This memory can
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-OMAP: Fine-tuning for several function implementations
  2016-09-22  6:54     ` Laurent Pinchart
@ 2016-09-22  9:11       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22  9:11 UTC (permalink / raw)
  To: Laurent Pinchart, Daniel Vetter
  Cc: dri-devel, David Airlie, Tomi Valkeinen, Julia Lawall,
	kernel-janitors, LKML

>> For the next pile of driver patches _please_ talk with driver maintainers
>> before starting to create&submit patches.

Did the software development discussion start a bit here?

Would you like to support an other "talking style" on a conference
like in Berlin next month?


>> Like I said I won't take them,

It's a pity.


>> and many of your changes are not clear-cut at all,

I know that specific update suggestions could be interpreted as controversial.


>> so I expect many driver maintaines also won't take them.

I am curious on useful responses.


>> Again, your contributions are welcome,

Thanks for another bit of constructive feedback.


>> but blindly following suggestions from code checkers in drivers

I propose to dare another look at corresponding information sources.


>> you cant test isn't really all that useful.

I have got an other impression.

How many improvements can still be achieved by usual (advanced) collaboration
techniques for free software development?


>> At the scale you're doing it, I think it's mostly wasting everyone's time

I hope not.


> :( I'd like to avoid that.

I am going to point more update opportunities out also for various Linux software.


> I second that.

Thanks for your opinion on this issue.


> After a very quick review, I see that the series splits related changes
> in multiple patches.

I chose a specific patch granularity for this proposal.


> I've already commented in reply to another series submitted by Markus
> that patches should then be combined.

Will such a combination depend on any more agreements between the involved contributors?


> I will thus ignore this series completely for the time being.

I hope that you can give similar ideas a second chance somehow.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: crypto-caamhash: Fine-tuning for several function implementations
  2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-15 15:30   ` crypto-caamhash: Fine-tuning for several function implementations Horia Geanta Neag
@ 2016-09-22 10:44   ` Herbert Xu
  7 siblings, 0 replies; 1373+ messages in thread
From: Herbert Xu @ 2016-09-22 10:44 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-crypto, David S. Miller, Labbe Corentin, Russell King,
	LKML, kernel-janitors, Julia Lawall

On Thu, Sep 15, 2016 at 04:36:35PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 15 Sep 2016 16:27:23 +0200
> 
> Some update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (6):
>   Use kmalloc_array() in ahash_setkey()
>   Rename jump labels in ahash_setkey()
>   Rename a jump label in five functions
>   Return a value directly in caam_hash_cra_init()
>   Delete an unnecessary initialisation in seven functions
>   Move common error handling code in two functions
> 
>  drivers/crypto/caam/caamhash.c | 111 +++++++++++++++++++----------------------
>  1 file changed, 52 insertions(+), 59 deletions(-)

All applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  2016-09-22  8:32   ` [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node() SF Markus Elfring
@ 2016-09-22 10:58     ` Dan Carpenter
  2016-09-22 16:57     ` Jyri Sarha
  1 sibling, 0 replies; 1373+ messages in thread
From: Dan Carpenter @ 2016-09-22 10:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, David Airlie, Jyri Sarha, Tomi Valkeinen, LKML,
	kernel-janitors, Julia Lawall

This one is actually a bug fix...  But finding bug fixes in this series
is like looking for kernels of edible corn in piles of monkey poop.

Also, classic "One Err" bug.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init()
  2016-09-22  8:31   ` [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init() SF Markus Elfring
@ 2016-09-22 16:55     ` Jyri Sarha
  0 siblings, 0 replies; 1373+ messages in thread
From: Jyri Sarha @ 2016-09-22 16:55 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, David Airlie, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

On 09/22/16 11:31, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 22 Sep 2016 09:05:14 +0200
> 
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> index f9c79da..8faa28f 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> @@ -32,8 +32,7 @@ static int __init kfree_table_init(struct kfree_table *kft)
>  {
>  	kft->total = 32;
>  	kft->num = 0;
> -	kft->table = kmalloc(kft->total * sizeof(*kft->table),
> -			     GFP_KERNEL);
> +	kft->table = kmalloc_array(kft->total, sizeof(*kft->table), GFP_KERNEL);

I was not sure if it is Ok to call kremalloc() for a pointer that was
previously allocated with kmalloc_array(). And at least it felt pointless.

But if you can confirm that it is ok, then sure I can take the patch.

Thanks,
Jyri

>  	if (!kft->table)
>  		return -ENOMEM;
>  
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  2016-09-22  8:32   ` [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node() SF Markus Elfring
  2016-09-22 10:58     ` Dan Carpenter
@ 2016-09-22 16:57     ` Jyri Sarha
  2016-09-22 18:17       ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Jyri Sarha @ 2016-09-22 16:57 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, David Airlie, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

On 09/22/16 11:32, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 22 Sep 2016 09:29:23 +0200
> 
> Return directly after a memory allocation failed in this function
> at the beginning.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> index 8faa28f..6204405 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> @@ -206,7 +206,7 @@ void __init tilcdc_convert_slave_node(void)
>  	int ret;
>  
>  	if (kfree_table_init(&kft))
> -		goto out;
> +		return;
>  
>  	lcdc = of_find_matching_node(NULL, tilcdc_of_match);
>  	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
> 

Thanks,
This is a real bug. I'll pick this up, but with your permission I change
the commit subject to follow the current convention.

Best regards,
Jyri

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22  8:33   ` [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection SF Markus Elfring
@ 2016-09-22 17:04     ` Jyri Sarha
  2016-09-22 18:38       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jyri Sarha @ 2016-09-22 17:04 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, David Airlie, Tomi Valkeinen
  Cc: LKML, kernel-janitors, Julia Lawall

On 09/22/16 11:33, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 22 Sep 2016 10:06:50 +0200
> 
> The of_node_put() function was called in some cases
> by the tilcdc_convert_slave_node() function during error handling
> even if the passed variable contained a null pointer.
> 
> * Adjust jump targets according to the Linux coding style convention.
> 
> * Split a condition check for resource detection failures so that
>   each pointer from these function calls will be checked immediately.
> 
>   See also background information:
>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>   Link: https://cwe.mitre.org/data/definitions/754.html
> 

I don't really agree with this patch. There is no harm in calling
of_node_put() with NULL as an argument and because of that there is no
point in making the function more complex and harder to maintain.

Best regards,
Jyri

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> index 6204405..6ee5865 100644
> --- a/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> +++ b/drivers/gpu/drm/tilcdc/tilcdc_slave_compat.c
> @@ -209,25 +209,27 @@ void __init tilcdc_convert_slave_node(void)
>  		return;
>  
>  	lcdc = of_find_matching_node(NULL, tilcdc_of_match);
> -	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
> +	if (!of_device_is_available(lcdc))
> +		goto free_table;
>  
> -	if (!slave || !of_device_is_available(lcdc))
> -		goto out;
> +	slave = of_find_matching_node(NULL, tilcdc_slave_of_match);
> +	if (!slave)
> +		goto put_node_lcdc;
>  
>  	i2c = of_parse_phandle(slave, "i2c", 0);
>  	if (!i2c) {
>  		pr_err("%s: Can't find i2c node trough phandle\n", __func__);
> -		goto out;
> +		goto put_node_slave;
>  	}
>  
>  	overlay = tilcdc_get_overlay(&kft);
>  	if (!overlay)
> -		goto out;
> +		goto put_node_i2c;
>  
>  	encoder = of_find_matching_node(overlay, tilcdc_tda998x_of_match);
>  	if (!encoder) {
>  		pr_err("%s: Failed to find tda998x node\n", __func__);
> -		goto out;
> +		goto put_node_i2c;
>  	}
>  
>  	tilcdc_copy_props(slave, encoder, tilcdc_slave_props, &kft);
> @@ -238,10 +240,10 @@ void __init tilcdc_convert_slave_node(void)
>  			continue;
>  		if (!strncmp("i2c", (char *)prop->value, prop->length))
>  			if (tilcdc_prop_str_update(prop, i2c->full_name, &kft))
> -				goto out;
> +				goto put_node_fragment;
>  		if (!strncmp("lcdc", (char *)prop->value, prop->length))
>  			if (tilcdc_prop_str_update(prop, lcdc->full_name, &kft))
> -				goto out;
> +				goto put_node_fragment;
>  	}
>  
>  	tilcdc_node_disable(slave);
> @@ -252,12 +254,16 @@ void __init tilcdc_convert_slave_node(void)
>  	else
>  		pr_info("%s: ti,tilcdc,slave node successfully converted\n",
>  			__func__);
> -out:
> -	kfree_table_free(&kft);
> + put_node_fragment:
> +	of_node_put(fragment);
> + put_node_i2c:
>  	of_node_put(i2c);
> + put_node_slave:
>  	of_node_put(slave);
> + put_node_lcdc:
>  	of_node_put(lcdc);
> -	of_node_put(fragment);
> + free_table:
> +	kfree_table_free(&kft);
>  }
>  
>  int __init tilcdc_slave_compat_init(void)
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (91 preceding siblings ...)
  2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
@ 2016-09-22 17:32 ` SF Markus Elfring
  2016-09-22 17:33   ` [PATCH 01/14] GPU-DRM-TTM: Use kmalloc_array() in two functions SF Markus Elfring
                     ` (14 more replies)
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
                   ` (2 subsequent siblings)
  95 siblings, 15 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:32 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 19:00:01 +0200

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

Markus Elfring (14):
  Use kmalloc_array() in two functions
  Rename a jump label in ttm_alloc_new_pages()
  Rename jump labels in ttm_page_pool_free()
  Rename a jump label in ttm_page_pool_get_pages()
  Use kmalloc_array() in two more functions
  Rename a jump label in ttm_dma_pool_alloc_new_pages()
  Rename jump labels in ttm_dma_page_pool_free()
  Rename a jump label in ttm_dma_pool_shrink_scan()
  Return directly after a failed kzalloc() in ttm_dma_page_alloc_init()
  Return directly after a failed kobject_init_and_add() in ttm_dma_page_alloc_init()
  Return an error code only as a constant in ttm_dma_pool_init()
  Less function calls in ttm_dma_pool_init() after error detection
  Delete unnecessary variable initialisations in ttm_dma_pool_init()
  Mark an array of text strings as "const" in ttm_dma_pool_init()

 drivers/gpu/drm/ttm/ttm_page_alloc.c     | 30 ++++++++---------
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 58 +++++++++++++++-----------------
 2 files changed, 42 insertions(+), 46 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 01/14] GPU-DRM-TTM: Use kmalloc_array() in two functions
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-22 17:33   ` SF Markus Elfring
  2016-09-22 17:34   ` [PATCH 02/14] GPU-DRM-TTM: Rename a jump label in ttm_alloc_new_pages() SF Markus Elfring
                     ` (13 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:33 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:00:31 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index a37de5d..bfc51cb 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -315,8 +315,9 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
 	if (use_static)
 		pages_to_free = static_buf;
 	else
-		pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-					GFP_KERNEL);
+		pages_to_free = kmalloc_array(npages_to_free,
+					      sizeof(*pages_to_free),
+					      GFP_KERNEL);
 	if (!pages_to_free) {
 		pr_err("Failed to allocate memory for pool free operation\n");
 		return 0;
@@ -501,8 +502,9 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
 			(unsigned)(PAGE_SIZE/sizeof(struct page *)));
 
 	/* allocate array for page caching change */
-	caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
-
+	caching_array = kmalloc_array(max_cpages,
+				      sizeof(*caching_array),
+				      GFP_KERNEL);
 	if (!caching_array) {
 		pr_err("Unable to allocate table for new pages\n");
 		return -ENOMEM;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 02/14] GPU-DRM-TTM: Rename a jump label in ttm_alloc_new_pages()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-22 17:33   ` [PATCH 01/14] GPU-DRM-TTM: Use kmalloc_array() in two functions SF Markus Elfring
@ 2016-09-22 17:34   ` SF Markus Elfring
  2016-09-22 17:35   ` [PATCH 03/14] GPU-DRM-TTM: Rename jump labels in ttm_page_pool_free() SF Markus Elfring
                     ` (12 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:34 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:16:05 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index bfc51cb..13fdd19 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -527,7 +527,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
 						caching_array, cpages);
 			}
 			r = -ENOMEM;
-			goto out;
+			goto free_array;
 		}
 
 #ifdef CONFIG_HIGHMEM
@@ -546,7 +546,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
 					ttm_handle_caching_state_failure(pages,
 						ttm_flags, cstate,
 						caching_array, cpages);
-					goto out;
+					goto free_array;
 				}
 				cpages = 0;
 			}
@@ -562,7 +562,7 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
 					ttm_flags, cstate,
 					caching_array, cpages);
 	}
-out:
+ free_array:
 	kfree(caching_array);
 
 	return r;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 03/14] GPU-DRM-TTM: Rename jump labels in ttm_page_pool_free()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-22 17:33   ` [PATCH 01/14] GPU-DRM-TTM: Use kmalloc_array() in two functions SF Markus Elfring
  2016-09-22 17:34   ` [PATCH 02/14] GPU-DRM-TTM: Rename a jump label in ttm_alloc_new_pages() SF Markus Elfring
@ 2016-09-22 17:35   ` SF Markus Elfring
  2016-09-22 17:36   ` [PATCH 04/14] GPU-DRM-TTM: Rename a jump label in ttm_page_pool_get_pages() SF Markus Elfring
                     ` (11 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:35 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:30:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index 13fdd19..f33f6f6 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -322,8 +322,7 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
 		pr_err("Failed to allocate memory for pool free operation\n");
 		return 0;
 	}
-
-restart:
+ lock_restart:
 	spin_lock_irqsave(&pool->lock, irq_flags);
 
 	list_for_each_entry_reverse(p, &pool->list, lru) {
@@ -356,14 +355,13 @@ restart:
 
 			/* free all so restart the processing */
 			if (nr_free)
-				goto restart;
+				goto lock_restart;
 
 			/* Not allowed to fall through or break because
 			 * following context is inside spinlock while we are
 			 * outside here.
 			 */
-			goto out;
-
+			goto check_pages_to_free;
 		}
 	}
 
@@ -379,7 +377,7 @@ restart:
 
 	if (freed_pages)
 		ttm_pages_put(pages_to_free, freed_pages);
-out:
+ check_pages_to_free:
 	if (pages_to_free != static_buf)
 		kfree(pages_to_free);
 	return nr_free;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 04/14] GPU-DRM-TTM: Rename a jump label in ttm_page_pool_get_pages()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-22 17:35   ` [PATCH 03/14] GPU-DRM-TTM: Rename jump labels in ttm_page_pool_free() SF Markus Elfring
@ 2016-09-22 17:36   ` SF Markus Elfring
  2016-09-22 17:37   ` [PATCH 05/14] GPU-DRM-TTM: Use kmalloc_array() in two more functions SF Markus Elfring
                     ` (10 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:36 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:36:47 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
index f33f6f6..3dd603f 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
@@ -646,7 +646,7 @@ static unsigned ttm_page_pool_get_pages(struct ttm_page_pool *pool,
 		list_splice_init(&pool->list, pages);
 		count -= pool->npages;
 		pool->npages = 0;
-		goto out;
+		goto unlock;
 	}
 	/* find the last pages to include for requested number of pages. Split
 	 * pool to begin and halve it to reduce search space. */
@@ -667,7 +667,7 @@ static unsigned ttm_page_pool_get_pages(struct ttm_page_pool *pool,
 	list_cut_position(pages, &pool->list, p);
 	pool->npages -= count;
 	count = 0;
-out:
+ unlock:
 	spin_unlock_irqrestore(&pool->lock, irq_flags);
 	return count;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 05/14] GPU-DRM-TTM: Use kmalloc_array() in two more functions
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-22 17:36   ` [PATCH 04/14] GPU-DRM-TTM: Rename a jump label in ttm_page_pool_get_pages() SF Markus Elfring
@ 2016-09-22 17:37   ` SF Markus Elfring
  2016-09-22 17:38   ` [PATCH 06/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_alloc_new_pages() SF Markus Elfring
                     ` (9 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:37 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:48:39 +0200

* Multiplications for the size determination of memory allocations
  indicated that array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of data types by pointer dereferences
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index bef9f6f..194818d 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -439,8 +439,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
 	if (use_static)
 		pages_to_free = static_buf;
 	else
-		pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-					GFP_KERNEL);
+		pages_to_free = kmalloc_array(npages_to_free,
+					      sizeof(*pages_to_free),
+					      GFP_KERNEL);
 
 	if (!pages_to_free) {
 		pr_err("%s: Failed to allocate memory for pool free operation\n",
@@ -726,8 +727,9 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 			(unsigned)(PAGE_SIZE/sizeof(struct page *)));
 
 	/* allocate array for page caching change */
-	caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
-
+	caching_array = kmalloc_array(max_cpages,
+				      sizeof(*caching_array),
+				      GFP_KERNEL);
 	if (!caching_array) {
 		pr_err("%s: Unable to allocate table for new pages\n",
 		       pool->dev_name);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 06/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_alloc_new_pages()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-22 17:37   ` [PATCH 05/14] GPU-DRM-TTM: Use kmalloc_array() in two more functions SF Markus Elfring
@ 2016-09-22 17:38   ` SF Markus Elfring
  2016-09-22 17:39   ` [PATCH 07/14] GPU-DRM-TTM: Rename jump labels in ttm_dma_page_pool_free() SF Markus Elfring
                     ` (8 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:38 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 14:54:12 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 194818d..9dc1632 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -758,7 +758,7 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 						cpages);
 			}
 			r = -ENOMEM;
-			goto out;
+			goto free_array;
 		}
 		p = dma_p->p;
 #ifdef CONFIG_HIGHMEM
@@ -777,7 +777,7 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 					ttm_dma_handle_caching_state_failure(
 						pool, d_pages, caching_array,
 						cpages);
-					goto out;
+					goto free_array;
 				}
 				cpages = 0;
 			}
@@ -791,7 +791,7 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 			ttm_dma_handle_caching_state_failure(pool, d_pages,
 					caching_array, cpages);
 	}
-out:
+ free_array:
 	kfree(caching_array);
 	return r;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 07/14] GPU-DRM-TTM: Rename jump labels in ttm_dma_page_pool_free()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-22 17:38   ` [PATCH 06/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_alloc_new_pages() SF Markus Elfring
@ 2016-09-22 17:39   ` SF Markus Elfring
  2016-09-22 17:40   ` [PATCH 08/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_shrink_scan() SF Markus Elfring
                     ` (7 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:39 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 15:32:32 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 9dc1632..ce3d361 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -449,7 +449,7 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
 		return 0;
 	}
 	INIT_LIST_HEAD(&d_pages);
-restart:
+ lock_restart:
 	spin_lock_irqsave(&pool->lock, irq_flags);
 
 	/* We picking the oldest ones off the list */
@@ -489,14 +489,13 @@ restart:
 
 			/* free all so restart the processing */
 			if (nr_free)
-				goto restart;
+				goto lock_restart;
 
 			/* Not allowed to fall through or break because
 			 * following context is inside spinlock while we are
 			 * outside here.
 			 */
-			goto out;
-
+			goto check_pages_to_free;
 		}
 	}
 
@@ -510,7 +509,7 @@ restart:
 
 	if (freed_pages)
 		ttm_dma_pages_put(pool, &d_pages, pages_to_free, freed_pages);
-out:
+ check_pages_to_free:
 	if (pages_to_free != static_buf)
 		kfree(pages_to_free);
 	return nr_free;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 08/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_shrink_scan()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (6 preceding siblings ...)
  2016-09-22 17:39   ` [PATCH 07/14] GPU-DRM-TTM: Rename jump labels in ttm_dma_page_pool_free() SF Markus Elfring
@ 2016-09-22 17:40   ` SF Markus Elfring
  2016-09-22 17:41   ` [PATCH 09/14] GPU-DRM-TTM: Return directly after a failed kzalloc() in ttm_dma_page_alloc_init() SF Markus Elfring
                     ` (6 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:40 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 16:02:36 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index ce3d361..e3f5542 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -1025,7 +1025,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 	if (!mutex_trylock(&_manager->lock))
 		return SHRINK_STOP;
 	if (!_manager->npools)
-		goto out;
+		goto unlock;
 	pool_offset = ++start_pool % _manager->npools;
 	list_for_each_entry(p, &_manager->pools, pools) {
 		unsigned nr_free;
@@ -1046,7 +1046,7 @@ ttm_dma_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
 			 p->pool->dev_name, p->pool->name, current->pid,
 			 nr_free, shrink_pages);
 	}
-out:
+ unlock:
 	mutex_unlock(&_manager->lock);
 	return freed;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 09/14] GPU-DRM-TTM: Return directly after a failed kzalloc() in ttm_dma_page_alloc_init()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (7 preceding siblings ...)
  2016-09-22 17:40   ` [PATCH 08/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_shrink_scan() SF Markus Elfring
@ 2016-09-22 17:41   ` SF Markus Elfring
  2016-09-22 17:42   ` [PATCH 10/14] GPU-DRM-TTM: Return directly after a failed kobject_init_and_add() " SF Markus Elfring
                     ` (5 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:41 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 16:16:36 +0200

* Return directly after a memory allocation failed in this function
  at the beginning.

* Delete the explicit initialisation for the local variable "ret"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index e3f5542..feba278 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -1080,7 +1080,7 @@ static void ttm_dma_pool_mm_shrink_fini(struct ttm_pool_manager *manager)
 
 int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
 {
-	int ret = -ENOMEM;
+	int ret;
 
 	WARN_ON(_manager);
 
@@ -1088,7 +1088,7 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
 
 	_manager = kzalloc(sizeof(*_manager), GFP_KERNEL);
 	if (!_manager)
-		goto err;
+		return -ENOMEM;
 
 	mutex_init(&_manager->lock);
 	INIT_LIST_HEAD(&_manager->pools);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 10/14] GPU-DRM-TTM: Return directly after a failed kobject_init_and_add() in ttm_dma_page_alloc_init()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (8 preceding siblings ...)
  2016-09-22 17:41   ` [PATCH 09/14] GPU-DRM-TTM: Return directly after a failed kzalloc() in ttm_dma_page_alloc_init() SF Markus Elfring
@ 2016-09-22 17:42   ` SF Markus Elfring
  2016-09-22 17:43   ` [PATCH 11/14] GPU-DRM-TTM: Return an error code only as a constant in ttm_dma_pool_init() SF Markus Elfring
                     ` (4 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:42 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 16:24:43 +0200

* Return directly after a call of the function "kobject_init_and_add"
  failed here.

* Delete the jump target "err" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index feba278..c21f45f 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -1102,12 +1102,10 @@ int ttm_dma_page_alloc_init(struct ttm_mem_global *glob, unsigned max_pages)
 				   &glob->kobj, "dma_pool");
 	if (unlikely(ret != 0)) {
 		kobject_put(&_manager->kobj);
-		goto err;
+		return ret;
 	}
 	ttm_dma_pool_mm_shrink_init(_manager);
 	return 0;
-err:
-	return ret;
 }
 
 void ttm_dma_page_alloc_fini(void)
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 11/14] GPU-DRM-TTM: Return an error code only as a constant in ttm_dma_pool_init()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (9 preceding siblings ...)
  2016-09-22 17:42   ` [PATCH 10/14] GPU-DRM-TTM: Return directly after a failed kobject_init_and_add() " SF Markus Elfring
@ 2016-09-22 17:43   ` SF Markus Elfring
  2016-09-22 17:44   ` [PATCH 12/14] GPU-DRM-TTM: Less function calls in ttm_dma_pool_init() after error detection SF Markus Elfring
                     ` (3 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:43 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 17:17:19 +0200

* Return an error code without storing it in a local variable.

* Delete the local variable "ret" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index c21f45f..d5f41ed 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -579,7 +579,6 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 	struct device_pools *sec_pool = NULL;
 	struct dma_pool *pool = NULL, **ptr;
 	unsigned i;
-	int ret = -ENODEV;
 	char *p;
 
 	if (!dev)
@@ -589,8 +588,6 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 	if (!ptr)
 		return NULL;
 
-	ret = -ENOMEM;
-
 	pool = kmalloc_node(sizeof(struct dma_pool), GFP_KERNEL,
 			    dev_to_node(dev));
 	if (!pool)
@@ -644,7 +641,7 @@ err_mem:
 	devres_free(ptr);
 	kfree(sec_pool);
 	kfree(pool);
-	return ERR_PTR(ret);
+	return ERR_PTR(-ENOMEM);
 }
 
 static struct dma_pool *ttm_dma_find_pool(struct device *dev,
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 12/14] GPU-DRM-TTM: Less function calls in ttm_dma_pool_init() after error detection
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (10 preceding siblings ...)
  2016-09-22 17:43   ` [PATCH 11/14] GPU-DRM-TTM: Return an error code only as a constant in ttm_dma_pool_init() SF Markus Elfring
@ 2016-09-22 17:44   ` SF Markus Elfring
  2016-09-22 17:45   ` [PATCH 13/14] GPU-DRM-TTM: Delete unnecessary variable initialisations in ttm_dma_pool_init() SF Markus Elfring
                     ` (2 subsequent siblings)
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:44 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 17:30:52 +0200

The kfree() function was called in up to two cases
by the ttm_dma_pool_init() function during error handling
even if the passed variable contained a null pointer.

Adjust jump targets according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index d5f41ed..4c50196 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -591,12 +591,12 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 	pool = kmalloc_node(sizeof(struct dma_pool), GFP_KERNEL,
 			    dev_to_node(dev));
 	if (!pool)
-		goto err_mem;
+		goto free_devres;
 
 	sec_pool = kmalloc_node(sizeof(struct device_pools), GFP_KERNEL,
 				dev_to_node(dev));
 	if (!sec_pool)
-		goto err_mem;
+		goto free_pool;
 
 	INIT_LIST_HEAD(&sec_pool->pools);
 	sec_pool->dev = dev;
@@ -637,10 +637,10 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 	devres_add(dev, ptr);
 
 	return pool;
-err_mem:
-	devres_free(ptr);
-	kfree(sec_pool);
+ free_pool:
 	kfree(pool);
+ free_devres:
+	devres_free(ptr);
 	return ERR_PTR(-ENOMEM);
 }
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 13/14] GPU-DRM-TTM: Delete unnecessary variable initialisations in ttm_dma_pool_init()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (11 preceding siblings ...)
  2016-09-22 17:44   ` [PATCH 12/14] GPU-DRM-TTM: Less function calls in ttm_dma_pool_init() after error detection SF Markus Elfring
@ 2016-09-22 17:45   ` SF Markus Elfring
  2016-09-22 17:46   ` [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" " SF Markus Elfring
  2016-09-23  9:44   ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations Christian König
  14 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:45 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 17:37:24 +0200

Two local variables will be set to an appropriate pointer a bit later.
Thus omit the explicit initialisation which became unnecessary with
a previous update step.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 4c50196..aa1679d 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -576,8 +576,8 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 {
 	char *n[] = {"wc", "uc", "cached", " dma32", "unknown",};
 	enum pool_type t[] = {IS_WC, IS_UC, IS_CACHED, IS_DMA32, IS_UNDEFINED};
-	struct device_pools *sec_pool = NULL;
-	struct dma_pool *pool = NULL, **ptr;
+	struct device_pools *sec_pool;
+	struct dma_pool *pool, **ptr;
 	unsigned i;
 	char *p;
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" in ttm_dma_pool_init()
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (12 preceding siblings ...)
  2016-09-22 17:45   ` [PATCH 13/14] GPU-DRM-TTM: Delete unnecessary variable initialisations in ttm_dma_pool_init() SF Markus Elfring
@ 2016-09-22 17:46   ` SF Markus Elfring
  2016-09-22 18:49     ` Joe Perches
  2016-09-23  9:44   ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations Christian König
  14 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 17:46 UTC (permalink / raw)
  To: dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 22 Sep 2016 18:46:01 +0200

The local variable "n" was not modified after it was initialized with
a few text strings.
Thus express this detail also by the data type qualifier "const".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index aa1679d..e21c1b3 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -574,7 +574,7 @@ static int ttm_dma_pool_match(struct device *dev, void *res, void *match_data)
 static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 					  enum pool_type type)
 {
-	char *n[] = {"wc", "uc", "cached", " dma32", "unknown",};
+	char const * const n[] = {"wc", "uc", "cached", " dma32", "unknown",};
 	enum pool_type t[] = {IS_WC, IS_UC, IS_CACHED, IS_DMA32, IS_UNDEFINED};
 	struct device_pools *sec_pool;
 	struct dma_pool *pool, **ptr;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node()
  2016-09-22 16:57     ` Jyri Sarha
@ 2016-09-22 18:17       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 18:17 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

> I'll pick this up, but with your permission I change
> the commit subject to follow the current convention.

I guess that I can accept the integration of this update suggestion
also with an adjusted prefix in the commit title.   ;-)

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22 17:04     ` Jyri Sarha
@ 2016-09-22 18:38       ` SF Markus Elfring
  2016-09-22 20:22         ` Jyri Sarha
  2016-09-23 10:58         ` Rob Clark
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-22 18:38 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

>> The of_node_put() function was called in some cases
>> by the tilcdc_convert_slave_node() function during error handling
>> even if the passed variable contained a null pointer.
>>
>> * Adjust jump targets according to the Linux coding style convention.
>>
>> * Split a condition check for resource detection failures so that
>>   each pointer from these function calls will be checked immediately.
>>
>>   See also background information:
>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>
> 
> I don't really agree with this patch.

This kind of feedback can be fine at first glance.


> There is no harm in calling of_node_put() with NULL as an argument

The cost of additional function calls will be eventually not noticed
just because they belong to an exception handling implementation so far.


> and because of that there is no point in making the function more complex

There is inherent software complexity involved.


> and harder to maintain.

How do you think about to discuss this aspect a bit more?


I suggest to reconsider this design detail if it is really acceptable
for the safe implementation of such a software module.

* How much will it matter in general that one function call was performed
  in this use case without checking its return value immediately?

* Should it usually be determined quicker if a required resource
  could be acquired before trying the next allocation?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" in ttm_dma_pool_init()
  2016-09-22 17:46   ` [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" " SF Markus Elfring
@ 2016-09-22 18:49     ` Joe Perches
  0 siblings, 0 replies; 1373+ messages in thread
From: Joe Perches @ 2016-09-22 18:49 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: LKML, kernel-janitors, Julia Lawall

On Thu, 2016-09-22 at 19:46 +0200, SF Markus Elfring wrote:
> The local variable "n" was not modified after it was initialized with
> a few text strings.
> Thus express this detail also by the data type qualifier "const".
[]
> diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
[]
> @@ -574,7 +574,7 @@ static int ttm_dma_pool_match(struct device *dev, void *res, void *match_data)
>  static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
>  					  enum pool_type type)
>  {
> -	char *n[] = {"wc", "uc", "cached", " dma32", "unknown",};
> +	char const * const n[] = {"wc", "uc", "cached", " dma32", "unknown",};
>  	enum pool_type t[] = {IS_WC, IS_UC, IS_CACHED, IS_DMA32, IS_UNDEFINED};


Please think a little deeper about what you are changing here
and look at the line immediately below it too.

Both should be static const to avoid unnecessary reload.

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22 18:38       ` SF Markus Elfring
@ 2016-09-22 20:22         ` Jyri Sarha
  2016-09-23  7:36           ` SF Markus Elfring
  2016-09-23 10:58         ` Rob Clark
  1 sibling, 1 reply; 1373+ messages in thread
From: Jyri Sarha @ 2016-09-22 20:22 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

On 09/22/16 21:38, SF Markus Elfring wrote:
>>> The of_node_put() function was called in some cases
>>> by the tilcdc_convert_slave_node() function during error handling
>>> even if the passed variable contained a null pointer.
>>>
>>> * Adjust jump targets according to the Linux coding style convention.
>>>
>>> * Split a condition check for resource detection failures so that
>>>   each pointer from these function calls will be checked immediately.
>>>
>>>   See also background information:
>>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>>
>>
>> I don't really agree with this patch.
> 
> This kind of feedback can be fine at first glance.
> 
> 
>> There is no harm in calling of_node_put() with NULL as an argument
> 
> The cost of additional function calls will be eventually not noticed
> just because they belong to an exception handling implementation so far.
> 
> 
>> and because of that there is no point in making the function more complex
> 
> There is inherent software complexity involved.
> 

I think the "if (node)" in the of_node_put() is there on purpose,
because it potentially saves the caller one extra if()-statement and
keeps the caller code simpler.

> 
>> and harder to maintain.
> 
> How do you think about to discuss this aspect a bit more?
> 

Keeping the goto labels in right order needs precision and can lead to
subtle errors. Sometimes there is no way to avoid that, but here there is.

Best regards,
Jyri

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22 20:22         ` Jyri Sarha
@ 2016-09-23  7:36           ` SF Markus Elfring
  2016-09-23 10:37             ` Jyri Sarha
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23  7:36 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

> I think the "if (node)" in the of_node_put() is there on purpose,

Yes, of course.

Does such an implementation detail correspond to a general software design pattern?


> because it potentially saves the caller one extra if()-statement

This can occasionally happen.


> and keeps the caller code simpler.

A special view on software simplicity can also lead to questionable intermediate
function implementation, can't it?


> Keeping the goto labels in right order needs precision

I can agree to this view.


> and can lead to subtle errors.

The management of jump labels is just another software development challenge
as usual, isn't it?


> Sometimes there is no way to avoid that,

How do you think about to clarify the constraints which you imagine a bit more?


> but here there is.

I disagree to this conclusion.

Would you like to care a bit more for efficiency and software correctness
around the discussed exception handling?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/24] ste_dma40: Fine-tuning for several function implementations
  2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
                     ` (23 preceding siblings ...)
  2016-09-17 15:36   ` [PATCH 24/24] ste_dma40: Rename a jump label in d40_log_lli_to_lcxa() SF Markus Elfring
@ 2016-09-23  9:41   ` Linus Walleij
  24 siblings, 0 replies; 1373+ messages in thread
From: Linus Walleij @ 2016-09-23  9:41 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dmaengine, linux-arm-kernel, Dan Williams, Vinod Koul, LKML,
	kernel-janitors, Julia Lawall

On Sat, Sep 17, 2016 at 5:05 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:

> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 17 Sep 2016 16:56:56 +0200
>
> Several update suggestions were taken into account
> from static source code analysis.

All look very nice!

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Vinod, please apply them all!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
                     ` (13 preceding siblings ...)
  2016-09-22 17:46   ` [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" " SF Markus Elfring
@ 2016-09-23  9:44   ` Christian König
  2016-09-23 10:20     ` SF Markus Elfring
  14 siblings, 1 reply; 1373+ messages in thread
From: Christian König @ 2016-09-23  9:44 UTC (permalink / raw)
  To: SF Markus Elfring, dri-devel, Daniel Vetter, David Airlie, Emil Velikov
  Cc: Julia Lawall, kernel-janitors, LKML

First of all please stop sending your patches as a reply to an earlier 
and completely unrelated series.

Second please prefix all TTM related patches with "drm/ttm:".

Additional to that I don't really see the point in renaming some of the 
jump labels, if you call it "restart" or "lock_restart" doesn't make 
much difference.

Regards,
Christian.

Am 22.09.2016 um 19:32 schrieb SF Markus Elfring:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Thu, 22 Sep 2016 19:00:01 +0200
>
> Several update suggestions were taken into account
> from static source code analysis.
>
> Markus Elfring (14):
>    Use kmalloc_array() in two functions
>    Rename a jump label in ttm_alloc_new_pages()
>    Rename jump labels in ttm_page_pool_free()
>    Rename a jump label in ttm_page_pool_get_pages()
>    Use kmalloc_array() in two more functions
>    Rename a jump label in ttm_dma_pool_alloc_new_pages()
>    Rename jump labels in ttm_dma_page_pool_free()
>    Rename a jump label in ttm_dma_pool_shrink_scan()
>    Return directly after a failed kzalloc() in ttm_dma_page_alloc_init()
>    Return directly after a failed kobject_init_and_add() in ttm_dma_page_alloc_init()
>    Return an error code only as a constant in ttm_dma_pool_init()
>    Less function calls in ttm_dma_pool_init() after error detection
>    Delete unnecessary variable initialisations in ttm_dma_pool_init()
>    Mark an array of text strings as "const" in ttm_dma_pool_init()
>
>   drivers/gpu/drm/ttm/ttm_page_alloc.c     | 30 ++++++++---------
>   drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 58 +++++++++++++++-----------------
>   2 files changed, 42 insertions(+), 46 deletions(-)
>

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23  9:44   ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations Christian König
@ 2016-09-23 10:20     ` SF Markus Elfring
  2016-09-23 10:38       ` Christian König
  2016-09-23 12:55       ` Dan Carpenter
  0 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 10:20 UTC (permalink / raw)
  To: Christian König
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

> Additional to that I don't really see the point in renaming some of the jump labels,

I am suggesting changes for another collateral software evolution.


> if you call it "restart" or "lock_restart" doesn't make much difference.

Do other identifiers fit better to a specification from the document "CodingStyle"
like the following?

"…
Choose label names which say what the goto does or why the goto exists.
…"


Does this wording need any more adjustments?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23  7:36           ` SF Markus Elfring
@ 2016-09-23 10:37             ` Jyri Sarha
  2016-09-23 10:55               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jyri Sarha @ 2016-09-23 10:37 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

On 09/23/16 10:36, SF Markus Elfring wrote:
>> I think the "if (node)" in the of_node_put() is there on purpose,
> 
> Yes, of course.
> 
> Does such an implementation detail correspond to a general software design pattern?
> 

Yes it does. For instance standard malloc()/free() implementation [1].

> 
>> because it potentially saves the caller one extra if()-statement
> 
> This can occasionally happen.
> 
> 
>> and keeps the caller code simpler.
> 
> A special view on software simplicity can also lead to questionable intermediate
> function implementation, can't it?
> 

I don't really follow. But in any case I do not see anything
questionable in the current tilcdc_convert_slave_node() implementation.

> 
>> Keeping the goto labels in right order needs precision
> 
> I can agree to this view.
> 
> 
>> and can lead to subtle errors.
> 
> The management of jump labels is just another software development challenge
> as usual, isn't it?
> 

Yes. But usually it pays of to avoid complexity when possible.

> 
>> Sometimes there is no way to avoid that,
> 
> How do you think about to clarify the constraints which you imagine a bit more?
> 

If the the of_node_put() behaviour would not be specified with null
pointer as parameter, there would be such a constraint.

I am beginning to have a feeling that this discussion is not going anywhere.

> 
>> but here there is.
> 
> I disagree to this conclusion.
> 
> Would you like to care a bit more for efficiency and software correctness
> around the discussed exception handling?
> 

No, I would not. I think we have reached the bottom of this discussion.
For the moment I have more important tasks to do.

Best regards,
Jyri

[1] http://pubs.opengroup.org/onlinepubs/9699919799/functions/free.html

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 10:20     ` SF Markus Elfring
@ 2016-09-23 10:38       ` Christian König
  2016-09-23 11:07         ` SF Markus Elfring
  2016-09-23 12:55       ` Dan Carpenter
  1 sibling, 1 reply; 1373+ messages in thread
From: Christian König @ 2016-09-23 10:38 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

Am 23.09.2016 um 12:20 schrieb SF Markus Elfring:
>> Additional to that I don't really see the point in renaming some of the jump labels,
> I am suggesting changes for another collateral software evolution.
>
>
>> if you call it "restart" or "lock_restart" doesn't make much difference.
> Do other identifiers fit better to a specification from the document "CodingStyle"
> like the following?

No, not really.

>
> "…
> Choose label names which say what the goto does or why the goto exists.
> …"
>
>
> Does this wording need any more adjustments?

Of hand I can't find any better wording.

It's just the names like "out" or "restart" perfectly explain why the 
labels exists. So they fulfill this requirement from the coding style as 
far as I can see.

So why do you want to change them?

Regards,
Christian.

>
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23 10:37             ` Jyri Sarha
@ 2016-09-23 10:55               ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 10:55 UTC (permalink / raw)
  To: Jyri Sarha
  Cc: dri-devel, David Airlie, Tomi Valkeinen, LKML, kernel-janitors,
	Julia Lawall

>> A special view on software simplicity can also lead to questionable intermediate
>> function implementation, can't it?
> 
> I don't really follow. But in any case I do not see anything
> questionable in the current tilcdc_convert_slave_node() implementation.

I identified update candidates there like the following.

1. Delayed checking for null pointers
…
	if (!slave || !of_device_is_available(lcdc))
…

2. Usage of a single jump label for (too many?) cases
…
		goto out;
…

   Can the corresponding exception handling become also a bit more efficient?


>> Would you like to care a bit more for efficiency and software correctness
>> around the discussed exception handling?
> 
> No, I would not.

Thanks for this information.

I hope that the software situation can also be improved around
this design aspect somehow.


> For the moment I have more important tasks to do.

I know also that various open issues are competing for your software
development attention as usual.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-22 18:38       ` SF Markus Elfring
  2016-09-22 20:22         ` Jyri Sarha
@ 2016-09-23 10:58         ` Rob Clark
  2016-09-23 11:19           ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Rob Clark @ 2016-09-23 10:58 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jyri Sarha, kernel-janitors, LKML, dri-devel, Julia Lawall,
	Tomi Valkeinen

On Thu, Sep 22, 2016 at 2:38 PM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> The of_node_put() function was called in some cases
>>> by the tilcdc_convert_slave_node() function during error handling
>>> even if the passed variable contained a null pointer.
>>>
>>> * Adjust jump targets according to the Linux coding style convention.
>>>
>>> * Split a condition check for resource detection failures so that
>>>   each pointer from these function calls will be checked immediately.
>>>
>>>   See also background information:
>>>   Topic "CWE-754: Improper check for unusual or exceptional conditions"
>>>   Link: https://cwe.mitre.org/data/definitions/754.html
>>>
>>
>> I don't really agree with this patch.
>
> This kind of feedback can be fine at first glance.
>
>
>> There is no harm in calling of_node_put() with NULL as an argument
>
> The cost of additional function calls will be eventually not noticed
> just because they belong to an exception handling implementation so far.

iirc, there are Coccinelle rules that find code with unnecessary null
checks and removes them..

Although you probably made this complex enough that cocinelle would
not find it.  That is not a complement.  One should not make error
handling/cleanup more complex than needed.

BR,
-R

>
>> and because of that there is no point in making the function more complex
>
> There is inherent software complexity involved.
>
>
>> and harder to maintain.
>
> How do you think about to discuss this aspect a bit more?
>
>
> I suggest to reconsider this design detail if it is really acceptable
> for the safe implementation of such a software module.
>
> * How much will it matter in general that one function call was performed
>   in this use case without checking its return value immediately?
>
> * Should it usually be determined quicker if a required resource
>   could be acquired before trying the next allocation?
>
> Regards,
> Markus
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 10:38       ` Christian König
@ 2016-09-23 11:07         ` SF Markus Elfring
  2016-09-23 11:17           ` Christian König
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 11:07 UTC (permalink / raw)
  To: Christian König
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

> It's just the names like "out" or "restart" perfectly explain why the labels exists.

I have got an other impression.


> So they fulfill this requirement from the coding style as far as I can see.

Short identifiers might look more convenient in some cases because
they are quicker to type.


> So why do you want to change them?

1. I suggest to select identifiers also for jump labels which are more meaningful
   and eventually unique for some function implementations.

2. How do you think about to add a single space character before any label?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 11:07         ` SF Markus Elfring
@ 2016-09-23 11:17           ` Christian König
  2016-09-23 11:49             ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Christian König @ 2016-09-23 11:17 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

Am 23.09.2016 um 13:07 schrieb SF Markus Elfring:
>> It's just the names like "out" or "restart" perfectly explain why the labels exists.
> I have got an other impression.
>
>
>> So they fulfill this requirement from the coding style as far as I can see.
> Short identifiers might look more convenient in some cases because
> they are quicker to type.
>
>
>> So why do you want to change them?
> 1. I suggest to select identifiers also for jump labels which are more meaningful
>     and eventually unique for some function implementations.

I completely disagree. A longer identifier is not necessarily more 
meaningful than a shorter one.

The difference between calling a label "retry" and "lock_retry" is 
negligible, doesn't improve readability as far as I can see and is 
actually incorrect because the main meaning of the label is that we 
don't take the lock but rather that we restart the allocation operation.

Calling the label "unlock" instead of "out" is arguable a little better, 
but nothing I would call a major improvement either.

So that is a clear NAK to all those patches.

> 2. How do you think about to add a single space character before any label?

Bad as well. Why would anybody want to do this?

Christian.

>
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23 10:58         ` Rob Clark
@ 2016-09-23 11:19           ` SF Markus Elfring
  2016-09-23 11:31             ` Rob Clark
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 11:19 UTC (permalink / raw)
  To: Rob Clark
  Cc: Jyri Sarha, kernel-janitors, LKML, dri-devel, Julia Lawall,
	Tomi Valkeinen

> iirc, there are Coccinelle rules that find code with unnecessary null
> checks and removes them.

This kind of software change is not needed here.

I find that a corresponding return value check happens one function call
too late.


> Although you probably made this complex enough that cocinelle would
> not find it.  That is not a complement.

I imagine that scripts for the semantic patch language can find more
source code places where questionable disjunctions are used so far.
Would you dare to split any more condition checks?


> One should not make error handling/cleanup more complex than needed.

I see a need to improve not only correctness there but also a bit of
software efficiency.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23 11:19           ` SF Markus Elfring
@ 2016-09-23 11:31             ` Rob Clark
  2016-09-23 12:17               ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Rob Clark @ 2016-09-23 11:31 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jyri Sarha, kernel-janitors, LKML, dri-devel, Julia Lawall,
	Tomi Valkeinen

On Fri, Sep 23, 2016 at 7:19 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>> iirc, there are Coccinelle rules that find code with unnecessary null
>> checks and removes them.
>
> This kind of software change is not needed here.
>
> I find that a corresponding return value check happens one function call
> too late.
>

I think you misunderstand my point.. which is that additional
conditional checks wrapping a function call to something that already
checks for null should be removed.. not introduced.

>
>> Although you probably made this complex enough that cocinelle would
>> not find it.  That is not a complement.
>
> I imagine that scripts for the semantic patch language can find more
> source code places where questionable disjunctions are used so far.
> Would you dare to split any more condition checks?
>
>
>> One should not make error handling/cleanup more complex than needed.
>
> I see a need to improve not only correctness there but also a bit of
> software efficiency.

If you can measure any performance difference and present some results
(esp. considering that this is something that just happens when the
driver is loaded), then we'll talk.  Until then, please don't send
this sort of patch.  Thank you.

BR,
-R

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 11:17           ` Christian König
@ 2016-09-23 11:49             ` SF Markus Elfring
  2016-09-23 13:06               ` Christian König
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 11:49 UTC (permalink / raw)
  To: Christian König
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

> Calling the label "unlock" instead of "out" is arguable a little better,

Thanks that you can follow a renaming for this direction in principle.


> but nothing I would call a major improvement either.

This was not my intention for such an use case.

I am proposing some small software updates according to such a design pattern.


> So that is a clear NAK to all those patches.

Do you reject also update steps like the following then?

* drm/ttm: Use kmalloc_array() in two (or four?) functions"

* drm/ttm: Less function calls in ttm_dma_pool_init() after error detection

* Would you like to improve the usage of the variables "n" and "t"
  in the function "ttm_dma_pool_init" any further as Joe Perches suggested it?


>> 2. How do you think about to add a single space character before any label?
> 
> Bad as well. Why would anybody want to do this?

Do you find another software evolution interesting according to a recent commit?

"docs: Remove space-before-label guidance from CodingStyle"
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=79c70c304b0b443429b2a0019518532c5162817a


Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23 11:31             ` Rob Clark
@ 2016-09-23 12:17               ` SF Markus Elfring
  2016-09-23 13:04                 ` Rob Clark
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 12:17 UTC (permalink / raw)
  To: Rob Clark
  Cc: Jyri Sarha, kernel-janitors, LKML, dri-devel, Julia Lawall,
	Tomi Valkeinen

>> I see a need to improve not only correctness there but also a bit of
>> software efficiency.
> 
> If you can measure any performance difference and present some results
> (esp. considering that this is something that just happens when the
> driver is loaded), then we'll talk.

Are you really interested to increase your software development attention
for a quicker exception handling implementation in this function?


> Until then, please don't send this sort of patch.  Thank you.

Will benchmark statistics change such a change rejection ever?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 10:20     ` SF Markus Elfring
  2016-09-23 10:38       ` Christian König
@ 2016-09-23 12:55       ` Dan Carpenter
  2016-09-23 13:46         ` SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: Dan Carpenter @ 2016-09-23 12:55 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Christian König, dri-devel, Daniel Vetter, David Airlie,
	Emil Velikov, Julia Lawall, kernel-janitors, LKML

On Fri, Sep 23, 2016 at 12:20:54PM +0200, SF Markus Elfring wrote:
> > if you call it "restart" or "lock_restart" doesn't make much difference.
> 
> Do other identifiers fit better to a specification from the document "CodingStyle"
> like the following?
> 
> "…
> Choose label names which say what the goto does or why the goto exists.
> …"
>
> 
> Does this wording need any more adjustments?

No.  I wrote that and "restart" seems like a pretty clear name to me.  I
never wrote that you should harrass people with your nonsense patches.
In fact, I have asked you over and over again to stop.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection
  2016-09-23 12:17               ` SF Markus Elfring
@ 2016-09-23 13:04                 ` Rob Clark
  0 siblings, 0 replies; 1373+ messages in thread
From: Rob Clark @ 2016-09-23 13:04 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Jyri Sarha, kernel-janitors, LKML, dri-devel, Julia Lawall,
	Tomi Valkeinen

On Fri, Sep 23, 2016 at 8:17 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
>>> I see a need to improve not only correctness there but also a bit of
>>> software efficiency.
>>
>> If you can measure any performance difference and present some results
>> (esp. considering that this is something that just happens when the
>> driver is loaded), then we'll talk.
>
> Are you really interested to increase your software development attention
> for a quicker exception handling implementation in this function?
>

No one is interested in making error handling more complex for a
non-existent benefit ;-)

>
>> Until then, please don't send this sort of patch.  Thank you.
>
> Will benchmark statistics change such a change rejection ever?

If you could demonstrate a real benefit to additional complexity for
something that actually matters (ie. not something like this that runs
once at bootup) I would care.

I don't recommend that you waste your time, since there is
approximately nothing in modesetting path that happens with a high
enough frequency to benefit from such a micro-optimization.
Especially not initialization code that runs once at boot up.

Fixing actual bugs is useful and valuable.  Premature "optimization"
at the expense of extra complexity is very much not useful.

BR,
-R

> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 11:49             ` SF Markus Elfring
@ 2016-09-23 13:06               ` Christian König
  0 siblings, 0 replies; 1373+ messages in thread
From: Christian König @ 2016-09-23 13:06 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: dri-devel, Daniel Vetter, David Airlie, Emil Velikov,
	Julia Lawall, kernel-janitors, LKML

Am 23.09.2016 um 13:49 schrieb SF Markus Elfring:
>> Calling the label "unlock" instead of "out" is arguable a little better,
> Thanks that you can follow a renaming for this direction in principle.
>
>
>> but nothing I would call a major improvement either.
> This was not my intention for such an use case.
>
> I am proposing some small software updates according to such a design pattern.
>
>
>> So that is a clear NAK to all those patches.
> Do you reject also update steps like the following then?
>
> * drm/ttm: Use kmalloc_array() in two (or four?) functions"
>
> * drm/ttm: Less function calls in ttm_dma_pool_init() after error detection

The reason behind the advise to use kmalloc_array() is to avoid overruns 
when one of the parameters come from an IOCTL and so are controllable by 
user space.

Those overruns where the source of numerous security problems, but in 
this case the parameters don't come from an IOCTL and aren't user space 
controllable.

So this change actually doesn't make to much sense either, but I'm 
leaning towards accepting them for coding style consistency.

Regards,
Christian.

> * Would you like to improve the usage of the variables "n" and "t"
>    in the function "ttm_dma_pool_init" any further as Joe Perches suggested it?
>
>
>>> 2. How do you think about to add a single space character before any label?
>> Bad as well. Why would anybody want to do this?
> Do you find another software evolution interesting according to a recent commit?
>
> "docs: Remove space-before-label guidance from CodingStyle"
> https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=79c70c304b0b443429b2a0019518532c5162817a
>
>
> Regards,
> Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: GPU-DRM-TTM: Fine-tuning for several function implementations
  2016-09-23 12:55       ` Dan Carpenter
@ 2016-09-23 13:46         ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 13:46 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Christian König, dri-devel, Daniel Vetter, David Airlie,
	Emil Velikov, Julia Lawall, kernel-janitors, LKML

>> Do other identifiers fit better to a specification from the document "CodingStyle"
>> like the following?
>>
>> "…
>> Choose label names which say what the goto does or why the goto exists.
>> …"
>>
>>
>> Does this wording need any more adjustments?
> 
> No.

I have got an other impression.

The terse description can trigger disagreements about the "what" and "why",
can't it?


> I wrote that and "restart" seems like a pretty clear name to me.

This identifier might be good enough to some degree.
I imagined that it would become better by the addition of a bit of information
from the jump target.


> I never wrote that you should harrass people with your nonsense patches.

This is true in principle.

But your adjustment for the document "CodingStyle" supported also a reconsideration
of the corresponding identifier selection.

Some developers disagreed with a proposed renaming while others reacted
in a positive way.


> In fact, I have asked you over and over again to stop.

This happened under different software update contexts occasionally.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 0/4] i2c-dev: Fine-tuning for four function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (92 preceding siblings ...)
  2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-23 19:42 ` SF Markus Elfring
  2016-09-23 19:44   ` [PATCH 1/4] i2c-dev: Use kmalloc_array() in i2cdev_ioctl_rdwr() SF Markus Elfring
                     ` (3 more replies)
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-24 11:07 ` [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations SF Markus Elfring
  95 siblings, 4 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 19:42 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 21:38:21 +0200

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

Markus Elfring (4):
  Use kmalloc_array() in i2cdev_ioctl_rdwr()
  Improve another size determination in i2cdev_ioctl_rdwr()
  Rename jump labels in i2cdev_attach_adapter()
  Adjust checks for null pointers in three functions

 drivers/i2c/i2c-dev.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/4] i2c-dev: Use kmalloc_array() in i2cdev_ioctl_rdwr()
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
@ 2016-09-23 19:44   ` SF Markus Elfring
  2016-09-23 19:45   ` [PATCH 2/4] i2c-dev: Improve another size determination " SF Markus Elfring
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 19:44 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 20:30:07 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-dev.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 66f323f..6d8226d 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -260,7 +260,9 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
 	if (IS_ERR(rdwr_pa))
 		return PTR_ERR(rdwr_pa);
 
-	data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
+	data_ptrs = kmalloc_array(rdwr_arg.nmsgs,
+				  sizeof(*data_ptrs),
+				  GFP_KERNEL);
 	if (data_ptrs == NULL) {
 		kfree(rdwr_pa);
 		return -ENOMEM;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/4] i2c-dev: Improve another size determination in i2cdev_ioctl_rdwr()
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
  2016-09-23 19:44   ` [PATCH 1/4] i2c-dev: Use kmalloc_array() in i2cdev_ioctl_rdwr() SF Markus Elfring
@ 2016-09-23 19:45   ` SF Markus Elfring
  2016-09-23 19:46   ` [PATCH 3/4] i2c-dev: Rename jump labels in i2cdev_attach_adapter() SF Markus Elfring
  2016-09-23 19:47   ` [PATCH 4/4] i2c-dev: Adjust checks for null pointers in three functions SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 19:45 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 20:45:40 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 6d8226d..a6e35ce 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -256,7 +256,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
 		return -EINVAL;
 
 	rdwr_pa = memdup_user(rdwr_arg.msgs,
-			      rdwr_arg.nmsgs * sizeof(struct i2c_msg));
+			      rdwr_arg.nmsgs * sizeof(*rdwr_pa));
 	if (IS_ERR(rdwr_pa))
 		return PTR_ERR(rdwr_pa);
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/4] i2c-dev: Rename jump labels in i2cdev_attach_adapter()
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
  2016-09-23 19:44   ` [PATCH 1/4] i2c-dev: Use kmalloc_array() in i2cdev_ioctl_rdwr() SF Markus Elfring
  2016-09-23 19:45   ` [PATCH 2/4] i2c-dev: Improve another size determination " SF Markus Elfring
@ 2016-09-23 19:46   ` SF Markus Elfring
  2016-09-23 19:47   ` [PATCH 4/4] i2c-dev: Adjust checks for null pointers in three functions SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 19:46 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 21:21:39 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-dev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index a6e35ce..7d3e3ca 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -555,7 +555,7 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy)
 	i2c_dev->cdev.owner = THIS_MODULE;
 	res = cdev_add(&i2c_dev->cdev, MKDEV(I2C_MAJOR, adap->nr), 1);
 	if (res)
-		goto error_cdev;
+		goto put_i2c;
 
 	/* register this i2c device with the driver core */
 	i2c_dev->dev = device_create(i2c_dev_class, &adap->dev,
@@ -563,15 +563,15 @@ static int i2cdev_attach_adapter(struct device *dev, void *dummy)
 				     "i2c-%d", adap->nr);
 	if (IS_ERR(i2c_dev->dev)) {
 		res = PTR_ERR(i2c_dev->dev);
-		goto error;
+		goto delete_cdev;
 	}
 
 	pr_debug("i2c-dev: adapter [%s] registered as minor %d\n",
 		 adap->name, adap->nr);
 	return 0;
-error:
+delete_cdev:
 	cdev_del(&i2c_dev->cdev);
-error_cdev:
+put_i2c:
 	put_i2c_dev(i2c_dev);
 	return res;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/4] i2c-dev: Adjust checks for null pointers in three functions
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-23 19:46   ` [PATCH 3/4] i2c-dev: Rename jump labels in i2cdev_attach_adapter() SF Markus Elfring
@ 2016-09-23 19:47   ` SF Markus Elfring
  3 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-23 19:47 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang; +Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 21:30:20 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/i2c/i2c-dev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
index 7d3e3ca..8f7eddd 100644
--- a/drivers/i2c/i2c-dev.c
+++ b/drivers/i2c/i2c-dev.c
@@ -147,7 +147,7 @@ static ssize_t i2cdev_read(struct file *file, char __user *buf, size_t count,
 		count = 8192;
 
 	tmp = kmalloc(count, GFP_KERNEL);
-	if (tmp == NULL)
+	if (!tmp)
 		return -ENOMEM;
 
 	pr_debug("i2c-dev: i2c-%d reading %zu bytes.\n",
@@ -263,7 +263,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
 	data_ptrs = kmalloc_array(rdwr_arg.nmsgs,
 				  sizeof(*data_ptrs),
 				  GFP_KERNEL);
-	if (data_ptrs == NULL) {
+	if (!data_ptrs) {
 		kfree(rdwr_pa);
 		return -ENOMEM;
 	}
@@ -374,7 +374,7 @@ static noinline int i2cdev_ioctl_smbus(struct i2c_client *client,
 				      client->flags, data_arg.read_write,
 				      data_arg.command, data_arg.size, NULL);
 
-	if (data_arg.data == NULL) {
+	if (!data_arg.data) {
 		dev_dbg(&client->adapter->dev,
 			"data is NULL pointer in ioctl I2C_SMBUS.\n");
 		return -EINVAL;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/7] iio: Fine-tuning for several function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (93 preceding siblings ...)
  2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
@ 2016-09-24  6:22 ` SF Markus Elfring
  2016-09-24  6:24   ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
                     ` (6 more replies)
  2016-09-24 11:07 ` [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations SF Markus Elfring
  95 siblings, 7 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:22 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 08:10:08 +0200

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

Markus Elfring (7):
  Use kmalloc_array() in iio_scan_mask_set()
  Rename a jump label in iio_buffer_store_watermark()
  Rename a jump label in iio_buffer_store_enable()
  Rename a jump label in iio_buffer_write_length()
  Rename a jump label in iio_scan_el_ts_store()
  Rename a jump label in iio_scan_el_store()
  Adjust checks for null pointers in six functions

 drivers/iio/industrialio-buffer.c | 55 ++++++++++++++++++---------------------
 1 file changed, 26 insertions(+), 29 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-24  6:24   ` SF Markus Elfring
  2016-09-24 15:36     ` Jonathan Cameron
  2016-09-24  6:25   ` [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark() SF Markus Elfring
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:24 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 23 Sep 2016 22:30:32 +0200

A multiplication for the size determination of a memory allocation
indicated that an array data structure should be processed.
Thus use the corresponding function "kmalloc_array".

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 49bf9c5..7a4d9499 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
 	const unsigned long *mask;
 	unsigned long *trialmask;
 
-	trialmask = kmalloc(sizeof(*trialmask)*
-			    BITS_TO_LONGS(indio_dev->masklength),
-			    GFP_KERNEL);
-
+	trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
+				  sizeof(*trialmask),
+				  GFP_KERNEL);
 	if (trialmask == NULL)
 		return -ENOMEM;
 	if (!indio_dev->masklength) {
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-24  6:24   ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
@ 2016-09-24  6:25   ` SF Markus Elfring
  2016-09-24 15:32     ` Jonathan Cameron
  2016-09-24  6:26   ` [PATCH 3/7] iio: Rename a jump label in iio_buffer_store_enable() SF Markus Elfring
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:25 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 06:54:49 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 7a4d9499..a865af8 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -1028,16 +1028,16 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
 
 	if (val > buffer->length) {
 		ret = -EINVAL;
-		goto out;
+		goto unlock;
 	}
 
 	if (iio_buffer_is_active(indio_dev->buffer)) {
 		ret = -EBUSY;
-		goto out;
+		goto unlock;
 	}
 
 	buffer->watermark = val;
-out:
+unlock:
 	mutex_unlock(&indio_dev->mlock);
 
 	return ret ? ret : len;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 3/7] iio: Rename a jump label in iio_buffer_store_enable()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
  2016-09-24  6:24   ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
  2016-09-24  6:25   ` [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark() SF Markus Elfring
@ 2016-09-24  6:26   ` SF Markus Elfring
  2016-09-24  6:28   ` [PATCH 4/7] iio: Rename a jump label in iio_buffer_write_length() SF Markus Elfring
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:26 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 07:11:32 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index a865af8..6509f0f 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -982,7 +982,7 @@ static ssize_t iio_buffer_store_enable(struct device *dev,
 	inlist = iio_buffer_is_active(indio_dev->buffer);
 	/* Already in desired state */
 	if (inlist == requested_state)
-		goto done;
+		goto unlock;
 
 	if (requested_state)
 		ret = __iio_update_buffers(indio_dev,
@@ -990,8 +990,7 @@ static ssize_t iio_buffer_store_enable(struct device *dev,
 	else
 		ret = __iio_update_buffers(indio_dev,
 					 NULL, indio_dev->buffer);
-
-done:
+unlock:
 	mutex_unlock(&indio_dev->mlock);
 	return (ret < 0) ? ret : len;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 4/7] iio: Rename a jump label in iio_buffer_write_length()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
                     ` (2 preceding siblings ...)
  2016-09-24  6:26   ` [PATCH 3/7] iio: Rename a jump label in iio_buffer_store_enable() SF Markus Elfring
@ 2016-09-24  6:28   ` SF Markus Elfring
  2016-09-24  6:29   ` [PATCH 5/7] iio: Rename a jump label in iio_scan_el_ts_store() SF Markus Elfring
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:28 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 07:17:44 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 6509f0f..376101f 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -505,10 +505,10 @@ static ssize_t iio_buffer_write_length(struct device *dev,
 		ret = 0;
 	}
 	if (ret)
-		goto out;
+		goto unlock;
 	if (buffer->length && buffer->length < buffer->watermark)
 		buffer->watermark = buffer->length;
-out:
+unlock:
 	mutex_unlock(&indio_dev->mlock);
 
 	return ret ? ret : len;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 5/7] iio: Rename a jump label in iio_scan_el_ts_store()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
                     ` (3 preceding siblings ...)
  2016-09-24  6:28   ` [PATCH 4/7] iio: Rename a jump label in iio_buffer_write_length() SF Markus Elfring
@ 2016-09-24  6:29   ` SF Markus Elfring
  2016-09-24  6:30   ` [PATCH 6/7] iio: Rename a jump label in iio_scan_el_store() SF Markus Elfring
  2016-09-24  6:31   ` [PATCH 7/7] iio: Adjust checks for null pointers in six functions SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:29 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 07:27:26 +0200

Adjust a jump label according to the current Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 376101f..4b8f313 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -409,10 +409,10 @@ static ssize_t iio_scan_el_ts_store(struct device *dev,
 	mutex_lock(&indio_dev->mlock);
 	if (iio_buffer_is_active(indio_dev->buffer)) {
 		ret = -EBUSY;
-		goto error_ret;
+		goto unlock;
 	}
 	indio_dev->buffer->scan_timestamp = state;
-error_ret:
+unlock:
 	mutex_unlock(&indio_dev->mlock);
 
 	return ret ? ret : len;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 6/7] iio: Rename a jump label in iio_scan_el_store()
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
                     ` (4 preceding siblings ...)
  2016-09-24  6:29   ` [PATCH 5/7] iio: Rename a jump label in iio_scan_el_ts_store() SF Markus Elfring
@ 2016-09-24  6:30   ` SF Markus Elfring
  2016-09-24  6:31   ` [PATCH 7/7] iio: Adjust checks for null pointers in six functions SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:30 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 07:40:59 +0200

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

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 4b8f313..57e201a 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -363,22 +363,21 @@ static ssize_t iio_scan_el_store(struct device *dev,
 	mutex_lock(&indio_dev->mlock);
 	if (iio_buffer_is_active(indio_dev->buffer)) {
 		ret = -EBUSY;
-		goto error_ret;
+		goto unlock;
 	}
 	ret = iio_scan_mask_query(indio_dev, buffer, this_attr->address);
 	if (ret < 0)
-		goto error_ret;
+		goto unlock;
 	if (!state && ret) {
 		ret = iio_scan_mask_clear(buffer, this_attr->address);
 		if (ret)
-			goto error_ret;
+			goto unlock;
 	} else if (state && !ret) {
 		ret = iio_scan_mask_set(indio_dev, buffer, this_attr->address);
 		if (ret)
-			goto error_ret;
+			goto unlock;
 	}
-
-error_ret:
+unlock:
 	mutex_unlock(&indio_dev->mlock);
 
 	return ret < 0 ? ret : len;
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 7/7] iio: Adjust checks for null pointers in six functions
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
                     ` (5 preceding siblings ...)
  2016-09-24  6:30   ` [PATCH 6/7] iio: Rename a jump label in iio_scan_el_store() SF Markus Elfring
@ 2016-09-24  6:31   ` SF Markus Elfring
  6 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24  6:31 UTC (permalink / raw)
  To: linux-iio, Hartmut Knaack, Jonathan Cameron, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 08:00:07 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script "checkpatch.pl" can point information out like the following.

Comparison to NULL could be written !…

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/iio/industrialio-buffer.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index 57e201a..6893639 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -310,7 +310,7 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
 	trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
 				  sizeof(*trialmask),
 				  GFP_KERNEL);
-	if (trialmask == NULL)
+	if (!trialmask)
 		return -ENOMEM;
 	if (!indio_dev->masklength) {
 		WARN(1, "Trying to set scanmask prior to registering buffer\n");
@@ -711,7 +711,7 @@ static int iio_verify_update(struct iio_dev *indio_dev,
 	/* What scan mask do we actually have? */
 	compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
 				sizeof(long), GFP_KERNEL);
-	if (compound_mask == NULL)
+	if (!compound_mask)
 		return -ENOMEM;
 
 	scan_timestamp = false;
@@ -736,7 +736,7 @@ static int iio_verify_update(struct iio_dev *indio_dev,
 				    compound_mask,
 				    strict_scanmask);
 		kfree(compound_mask);
-		if (scan_mask == NULL)
+		if (!scan_mask)
 			return -EINVAL;
 	} else {
 	    scan_mask = compound_mask;
@@ -940,7 +940,7 @@ int iio_update_buffers(struct iio_dev *indio_dev,
 		goto out_unlock;
 	}
 
-	if (indio_dev->info == NULL) {
+	if (!indio_dev->info) {
 		ret = -ENODEV;
 		goto out_unlock;
 	}
@@ -1130,11 +1130,11 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
 				indio_dev->scan_index_timestamp =
 					channels[i].scan_index;
 		}
-		if (indio_dev->masklength && buffer->scan_mask == NULL) {
+		if (indio_dev->masklength && !buffer->scan_mask) {
 			buffer->scan_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
 						    sizeof(*buffer->scan_mask),
 						    GFP_KERNEL);
-			if (buffer->scan_mask == NULL) {
+			if (!buffer->scan_mask) {
 				ret = -ENOMEM;
 				goto error_cleanup_dynamic;
 			}
@@ -1146,7 +1146,7 @@ int iio_buffer_alloc_sysfs_and_mask(struct iio_dev *indio_dev)
 	buffer->scan_el_group.attrs = kcalloc(attrcount + 1,
 					      sizeof(buffer->scan_el_group.attrs[0]),
 					      GFP_KERNEL);
-	if (buffer->scan_el_group.attrs == NULL) {
+	if (!buffer->scan_el_group.attrs) {
 		ret = -ENOMEM;
 		goto error_free_scan_mask;
 	}
@@ -1291,7 +1291,7 @@ static int iio_buffer_add_demux(struct iio_buffer *buffer,
 		(*p)->length += length;
 	} else {
 		*p = kmalloc(sizeof(**p), GFP_KERNEL);
-		if (*p == NULL)
+		if (!*p)
 			return -ENOMEM;
 		(*p)->from = in_loc;
 		(*p)->to = out_loc;
@@ -1356,7 +1356,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev,
 		in_loc += length;
 	}
 	buffer->demux_bounce = kzalloc(out_loc, GFP_KERNEL);
-	if (buffer->demux_bounce == NULL) {
+	if (!buffer->demux_bounce) {
 		ret = -ENOMEM;
 		goto error_clear_mux_table;
 	}
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations
  2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
                   ` (94 preceding siblings ...)
  2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
@ 2016-09-24 11:07 ` SF Markus Elfring
  2016-09-24 11:08   ` [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val() SF Markus Elfring
  2016-09-24 11:10   ` [PATCH 2/2] Input-evdev: Rename a jump label in two functions SF Markus Elfring
  95 siblings, 2 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 11:07 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 13:03:13 +0200

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

Markus Elfring (2):
  Use kmalloc_array()
  Rename a jump label in two functions

 drivers/input/evdev.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

-- 
2.10.0

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val()
  2016-09-24 11:07 ` [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations SF Markus Elfring
@ 2016-09-24 11:08   ` SF Markus Elfring
  2016-09-24 17:54     ` Dmitry Torokhov
  2016-09-24 11:10   ` [PATCH 2/2] Input-evdev: Rename a jump label in two functions SF Markus Elfring
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 11:08 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 12:42:45 +0200

* A multiplication for the size determination of a memory allocation
  indicated that an array data structure should be processed.
  Thus use the corresponding function "kmalloc_array".

  This issue was detected by using the Coccinelle software.

* Replace the specification of a data type by a pointer dereference
  to make the corresponding size determination a bit safer according to
  the Linux coding style convention.

* Delete the local variable "len" which became unnecessary with
  this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/evdev.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index e9ae3d5..83fcfd6 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -919,18 +919,14 @@ static int evdev_handle_get_val(struct evdev_client *client,
 {
 	int ret;
 	unsigned long *mem;
-	size_t len;
 
-	len = BITS_TO_LONGS(maxbit) * sizeof(unsigned long);
-	mem = kmalloc(len, GFP_KERNEL);
+	mem = kmalloc_array(BITS_TO_LONGS(maxbit), sizeof(*mem), GFP_KERNEL);
 	if (!mem)
 		return -ENOMEM;
 
 	spin_lock_irq(&dev->event_lock);
 	spin_lock(&client->buffer_lock);
-
-	memcpy(mem, bits, len);
-
+	memcpy(mem, bits, sizeof(*mem) * BITS_TO_LONGS(maxbit));
 	spin_unlock(&dev->event_lock);
 
 	__evdev_flush_queue(client, type);
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* [PATCH 2/2] Input-evdev: Rename a jump label in two functions
  2016-09-24 11:07 ` [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations SF Markus Elfring
  2016-09-24 11:08   ` [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val() SF Markus Elfring
@ 2016-09-24 11:10   ` SF Markus Elfring
  2016-09-24 17:47     ` Dmitry Torokhov
  1 sibling, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 11:10 UTC (permalink / raw)
  To: linux-input, Dmitry Torokhov, Henrik Rydberg
  Cc: LKML, kernel-janitors, Julia Lawall

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 24 Sep 2016 12:50:31 +0200

Adjust a jump label according to the current Linux coding style convention.
Thus replace the identifier "out" by "unlock".

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/input/evdev.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index 83fcfd6..548874d 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -545,22 +545,21 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
 
 	if (!evdev->exist || client->revoked) {
 		retval = -ENODEV;
-		goto out;
+		goto unlock;
 	}
 
 	while (retval + input_event_size() <= count) {
 
 		if (input_event_from_user(buffer + retval, &event)) {
 			retval = -EFAULT;
-			goto out;
+			goto unlock;
 		}
 		retval += input_event_size();
 
 		input_inject_event(&evdev->handle,
 				   event.type, event.code, event.value);
 	}
-
- out:
+unlock:
 	mutex_unlock(&evdev->mutex);
 	return retval;
 }
@@ -1292,12 +1291,11 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
 
 	if (!evdev->exist || client->revoked) {
 		retval = -ENODEV;
-		goto out;
+		goto unlock;
 	}
 
 	retval = evdev_do_ioctl(file, cmd, p, compat_mode);
-
- out:
+unlock:
 	mutex_unlock(&evdev->mutex);
 	return retval;
 }
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 1373+ messages in thread

* Re: [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start()
  2016-09-18  6:10   ` [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start() SF Markus Elfring
@ 2016-09-24 11:41     ` Stefan Richter
  2016-09-24 15:29       ` [PATCH 01/10] " SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Stefan Richter @ 2016-09-24 11:41 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux1394-devel, LKML, kernel-janitors, Julia Lawall

On Sep 18 SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 17 Sep 2016 21:55:42 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
> 
>   This issue was detected by using the Coccinelle software.
> 
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/firewire/net.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index 309311b..7911f13 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -1103,8 +1103,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
>  
>  	max_receive = 1U << (dev->card->max_receive + 1);
>  	num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
> -
> -	ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
> +	ptrptr = kmalloc_array(num_packets, sizeof(*ptrptr), GFP_KERNEL);
>  	if (!ptrptr) {
>  		retval = -ENOMEM;
>  		goto failed;

Coccinelle enabled you to determine that kmalloc_array /could/ be used
here.  But whether it /should/ be used here is another question, and it is
not addressed in your changelog.  (You state that there is an "issue" but
do not explain.)

kmalloc_array is a kmalloc wrapper which adds an inline check for integer
overflow.  So, can sizeof(void *) * num_packets ever overflow size_t?

If yes,
	do we want a runtime check here (which kmalloc_array provides),
	or do we want a compile-time check?

If no,
	then the remaining benefit of the patch is that it is more obvious
	to the reader that dev->broadcast_rcv_buffer_ptrs is an array,
	but possibly at the cost of superfluous code.  Is gcc's optimizer
	able to resolve kmalloc_array's check at compile time as always
	false, such that the superfluous code is eliminated as dead code?

I believe I know answers to this but prefer to hear what you as the patch
author think about it.
-- 
Stefan Richter
-======----- =--= ==---
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions
  2016-09-18  6:22   ` [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions SF Markus Elfring
@ 2016-09-24 12:06     ` Stefan Richter
  0 siblings, 0 replies; 1373+ messages in thread
From: Stefan Richter @ 2016-09-24 12:06 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux1394-devel, LKML, kernel-janitors, Julia Lawall

On Sep 18 SF Markus Elfring wrote:
> The script "checkpatch.pl" can point information out like the following.

A side note:  checkpatch.pl is for authors to help prepare their
submissions of new code (or their refactoring of existing code if for some
reason a refactoring is undertaken).

> Comparison to NULL could be written !…

Yes it could, or it could remain as is.  Both styles are used in
drivers/firewire/net.c, so it is indeed preferable to normalize it to one
of them.  I keep your patch for the next occasion when related work is
being done on drivers/firewire/net.c or drivers/firewire.

> Thus fix the affected source code places.

It is not a "fix", it is a stylistic change.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/firewire/net.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index eb7ce5e..e313be3 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -366,13 +366,13 @@ static struct fwnet_partial_datagram *fwnet_pd_new(struct net_device *net,
>  
>  	INIT_LIST_HEAD(&new->fi_list);
>  	fi = fwnet_frag_new(new, frag_off, frag_len);
> -	if (fi == NULL)
> +	if (!fi)
>  		goto free_new;
[...]
-- 
Stefan Richter
-======----- =--= ==---
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 02/10] firewire-net: Rename a jump label in fwnet_broadcast_start()
  2016-09-18  6:12   ` [PATCH 02/10] firewire-net: Rename a jump label " SF Markus Elfring
@ 2016-09-24 12:58     ` Stefan Richter
  0 siblings, 0 replies; 1373+ messages in thread
From: Stefan Richter @ 2016-09-24 12:58 UTC (permalink / raw)
  To: SF Markus Elfring; +Cc: linux1394-devel, LKML, kernel-janitors, Julia Lawall

On Sep 18 SF Markus Elfring wrote:
> Adjust jump labels according to the current Linux coding style
> convention.

The current CodingStyle says:  "Choose label names which say what the goto
does or why the goto exists."  Given the choice between /what/ and /why/,
I for one lean towards /why/.

In this instance, the what and why is "clean up and exit after an error
occurred".  'failed' looks to me to be a better shorthand of this than
'stop_broadcast'.  The latter merely says /how/ the cleanup is done.

> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/firewire/net.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c
> index 7911f13..89afed3 100644
> --- a/drivers/firewire/net.c
> +++ b/drivers/firewire/net.c
> @@ -1106,7 +1106,7 @@ static int fwnet_broadcast_start(struct
> fwnet_device *dev) ptrptr = kmalloc_array(num_packets, sizeof(*ptrptr),
> GFP_KERNEL); if (!ptrptr) {
>  		retval = -ENOMEM;
> -		goto failed;
> +		goto stop_broadcast;
>  	}
>  	dev->broadcast_rcv_buffer_ptrs = ptrptr;
>  
> @@ -1116,13 +1116,13 @@ static int fwnet_broadcast_start(struct
> fwnet_device *dev) fwnet_receive_broadcast, dev);
>  	if (IS_ERR(context)) {
>  		retval = PTR_ERR(context);
> -		goto failed;
> +		goto stop_broadcast;
>  	}
[...]
> @@ -1166,8 +1166,7 @@ static int fwnet_broadcast_start(struct
> fwnet_device *dev) dev->broadcast_state = FWNET_BROADCAST_RUNNING;
>  
>  	return 0;
> -
> - failed:
> + stop_broadcast:
>  	__fwnet_broadcast_stop(dev);
>  	return retval;
>  }

I see no reason to remove the blank line between the return statement and
the label.
-- 
Stefan Richter
-======----- =--= ==---
http://arcgraph.de/sr/

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 01/10] firewire-net: Use kmalloc_array() in fwnet_broadcast_start()
  2016-09-24 11:41     ` Stefan Richter
@ 2016-09-24 15:29       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 15:29 UTC (permalink / raw)
  To: Stefan Richter
  Cc: linux1394-devel, LKML, kernel-janitors, Julia Lawall, Paolo Bonzini

>> @@ -1103,8 +1103,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
>>  
>>  	max_receive = 1U << (dev->card->max_receive + 1);
>>  	num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
>> -
>> -	ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
>> +	ptrptr = kmalloc_array(num_packets, sizeof(*ptrptr), GFP_KERNEL);
>>  	if (!ptrptr) {
>>  		retval = -ENOMEM;
>>  		goto failed;
> 
> Coccinelle enabled you to determine that kmalloc_array /could/ be used here.

A script for the semantic patch language pointed hundreds of source files out
with such software update opportunities.


> But whether it /should/ be used here is another question, and it is
> not addressed in your changelog.

I can expand the corresponding description when it will be desired.


> (You state that there is an "issue" but do not explain.)

Do you prefer an other wording for such an update candidate?


> kmalloc_array is a kmalloc wrapper which adds an inline check for integer
> overflow.  So, can sizeof(void *) * num_packets ever overflow size_t?
> 
> If yes,

Is there a probability that the calculated number of packets will become
too big for the preferred system limits anyhow?


> 	do we want a runtime check here (which kmalloc_array provides),

Did you notice the information from the commit "mm: faster kmalloc_array(), kcalloc()"
(from 2016-07-26) already?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=91c6a05f72a996bee5133e76374ab3ad7d3b9b72


> 	or do we want a compile-time check?

I guess that some software developers and subsystem maintainers are looking
for a bit more clarification around involved design dependencies.


> If no,
> 	then the remaining benefit of the patch is that it is more obvious
> 	to the reader that dev->broadcast_rcv_buffer_ptrs is an array,

How do you value such a kind of source code annotation?


> 	but possibly at the cost of superfluous code.

How do you think about to care for a bit more consistent use of Linux programming interfaces?


> 	Is gcc's optimizer able to resolve kmalloc_array's check at compile time
> 	as always false, such that the superfluous code is eliminated as dead code?

Which versions of compiler implementations would you like to check further?


> I believe I know answers to this but prefer to hear what you as the patch
> author think about it.

I presented another update suggestion also for this software module as a result
from a general source code search pattern.
The corresponding change acceptance varies and is evolving as usual.

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark()
  2016-09-24  6:25   ` [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark() SF Markus Elfring
@ 2016-09-24 15:32     ` Jonathan Cameron
  2016-09-24 19:21       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jonathan Cameron @ 2016-09-24 15:32 UTC (permalink / raw)
  To: SF Markus Elfring, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

On 24/09/16 07:25, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 24 Sep 2016 06:54:49 +0200
> 
> Adjust jump labels according to the current Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
I'm not necessarily against this change which does perhaps clarify the code
ever so slightly, but I am interested to know where 
'current Linux coding style convention' comes from?

Jonathan
> ---
>  drivers/iio/industrialio-buffer.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 7a4d9499..a865af8 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -1028,16 +1028,16 @@ static ssize_t iio_buffer_store_watermark(struct device *dev,
>  
>  	if (val > buffer->length) {
>  		ret = -EINVAL;
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	if (iio_buffer_is_active(indio_dev->buffer)) {
>  		ret = -EBUSY;
> -		goto out;
> +		goto unlock;
>  	}
>  
>  	buffer->watermark = val;
> -out:
> +unlock:
>  	mutex_unlock(&indio_dev->mlock);
>  
>  	return ret ? ret : len;
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
  2016-09-24  6:24   ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
@ 2016-09-24 15:36     ` Jonathan Cameron
  2016-09-24 16:18       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Jonathan Cameron @ 2016-09-24 15:36 UTC (permalink / raw)
  To: SF Markus Elfring, linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler
  Cc: LKML, kernel-janitors, Julia Lawall

On 24/09/16 07:24, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 23 Sep 2016 22:30:32 +0200
> 
> A multiplication for the size determination of a memory allocation
> indicated that an array data structure should be processed.
> Thus use the corresponding function "kmalloc_array".
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Applied to the togreg branch of iio.git - initially pushed out
as testing for the autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/industrialio-buffer.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
> index 49bf9c5..7a4d9499 100644
> --- a/drivers/iio/industrialio-buffer.c
> +++ b/drivers/iio/industrialio-buffer.c
> @@ -307,10 +307,9 @@ static int iio_scan_mask_set(struct iio_dev *indio_dev,
>  	const unsigned long *mask;
>  	unsigned long *trialmask;
>  
> -	trialmask = kmalloc(sizeof(*trialmask)*
> -			    BITS_TO_LONGS(indio_dev->masklength),
> -			    GFP_KERNEL);
> -
> +	trialmask = kmalloc_array(BITS_TO_LONGS(indio_dev->masklength),
> +				  sizeof(*trialmask),
> +				  GFP_KERNEL);
>  	if (trialmask == NULL)
>  		return -ENOMEM;
>  	if (!indio_dev->masklength) {
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
  2016-09-24 15:36     ` Jonathan Cameron
@ 2016-09-24 16:18       ` SF Markus Elfring
  2016-09-24 16:36         ` Jonathan Cameron
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 16:18 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, LKML, kernel-janitors, Julia Lawall

> Applied to the togreg branch of iio.git - initially pushed out
> as testing for the autobuilders to play with it.

Thanks for your positive response.


Do you see any need to improve the software situation around
the macro "BITS_TO_LONGS" further?

Do you fiddle with a programming interface like "bitmap_alloc" occasionally?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set()
  2016-09-24 16:18       ` SF Markus Elfring
@ 2016-09-24 16:36         ` Jonathan Cameron
  0 siblings, 0 replies; 1373+ messages in thread
From: Jonathan Cameron @ 2016-09-24 16:36 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, LKML, kernel-janitors, Julia Lawall

On 24/09/16 17:18, SF Markus Elfring wrote:
>> Applied to the togreg branch of iio.git - initially pushed out
>> as testing for the autobuilders to play with it.
> 
> Thanks for your positive response.
> 
> 
> Do you see any need to improve the software situation around
> the macro "BITS_TO_LONGS" further?
> 
> Do you fiddle with a programming interface like "bitmap_alloc" occasionally?
It might be clearer than having an array allocation as we do after this
patch. Obviously the representation is an array, but it is a little ugly
as it stands!
> 
> Regards,
> Markus
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 2/2] Input-evdev: Rename a jump label in two functions
  2016-09-24 11:10   ` [PATCH 2/2] Input-evdev: Rename a jump label in two functions SF Markus Elfring
@ 2016-09-24 17:47     ` Dmitry Torokhov
  0 siblings, 0 replies; 1373+ messages in thread
From: Dmitry Torokhov @ 2016-09-24 17:47 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-input, Henrik Rydberg, LKML, kernel-janitors, Julia Lawall

On Sat, Sep 24, 2016 at 4:10 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 24 Sep 2016 12:50:31 +0200
>
> Adjust a jump label according to the current Linux coding style convention.
> Thus replace the identifier "out" by "unlock".

No, just no.

>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
>  drivers/input/evdev.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
> index 83fcfd6..548874d 100644
> --- a/drivers/input/evdev.c
> +++ b/drivers/input/evdev.c
> @@ -545,22 +545,21 @@ static ssize_t evdev_write(struct file *file, const char __user *buffer,
>
>         if (!evdev->exist || client->revoked) {
>                 retval = -ENODEV;
> -               goto out;
> +               goto unlock;
>         }
>
>         while (retval + input_event_size() <= count) {
>
>                 if (input_event_from_user(buffer + retval, &event)) {
>                         retval = -EFAULT;
> -                       goto out;
> +                       goto unlock;
>                 }
>                 retval += input_event_size();
>
>                 input_inject_event(&evdev->handle,
>                                    event.type, event.code, event.value);
>         }
> -
> - out:
> +unlock:
>         mutex_unlock(&evdev->mutex);
>         return retval;
>  }
> @@ -1292,12 +1291,11 @@ static long evdev_ioctl_handler(struct file *file, unsigned int cmd,
>
>         if (!evdev->exist || client->revoked) {
>                 retval = -ENODEV;
> -               goto out;
> +               goto unlock;
>         }
>
>         retval = evdev_do_ioctl(file, cmd, p, compat_mode);
> -
> - out:
> +unlock:
>         mutex_unlock(&evdev->mutex);
>         return retval;
>  }
> --
> 2.10.0
>



-- 
Dmitry

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val()
  2016-09-24 11:08   ` [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val() SF Markus Elfring
@ 2016-09-24 17:54     ` Dmitry Torokhov
  2016-09-24 18:16       ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dmitry Torokhov @ 2016-09-24 17:54 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-input, Henrik Rydberg, LKML, kernel-janitors, Julia Lawall

On Sat, Sep 24, 2016 at 4:08 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 24 Sep 2016 12:42:45 +0200
>
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
>
>   This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
>
> * Delete the local variable "len" which became unnecessary with
>   this refactoring.

So we have to multiply twice now, once in kmalloc_array, the second
time in memcpy(). No, thank you.

Also, please note that we do not really treat the allocated "mem" as
an array, but rather area of memory that holds all bits that we need
to transfer, and so I consider using kmalloc_array() actually wrong
here.

Please do not blindly follow checkpatch and coccinelle suggestions.
They are just that: suggestions and not hared rules.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Input-evdev: Use kmalloc_array() in evdev_handle_get_val()
  2016-09-24 17:54     ` Dmitry Torokhov
@ 2016-09-24 18:16       ` SF Markus Elfring
  2016-09-24 18:34         ` Dmitry Torokhov
  0 siblings, 1 reply; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 18:16 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, Henrik Rydberg, LKML, kernel-janitors, Julia Lawall

> So we have to multiply twice now, once in kmalloc_array, the second
> time in memcpy().

It looks so in the source code after the suggested refactoring.


> No, thank you.

Would you like to check any further if a specific compiler implementation
will still optimise common subexpressions as you desired it?


> Also, please note that we do not really treat the allocated "mem" as an array,
> but rather area of memory that holds all bits that we need to transfer,
> and so I consider using kmalloc_array() actually wrong here.

Thanks for your explanation.


> Please do not blindly follow checkpatch and coccinelle suggestions.
> They are just that: suggestions and not hared rules.

I am curious on how to clarify corresponding deviations further.


Would you like to suggest any other details so that the evolving scripts
can become better and safer for static source code analysis?

Do you know any special properties which should be additionally checked
at call sites which are similar to the discussed place?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Input-evdev: Use kmalloc_array() in evdev_handle_get_val()
  2016-09-24 18:16       ` SF Markus Elfring
@ 2016-09-24 18:34         ` Dmitry Torokhov
  2016-09-24 19:04           ` SF Markus Elfring
  0 siblings, 1 reply; 1373+ messages in thread
From: Dmitry Torokhov @ 2016-09-24 18:34 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-input, Henrik Rydberg, LKML, kernel-janitors, Julia Lawall

On Sat, Sep 24, 2016 at 08:16:16PM +0200, SF Markus Elfring wrote:
> > So we have to multiply twice now, once in kmalloc_array, the second
> > time in memcpy().
> 
> It looks so in the source code after the suggested refactoring.
> 
> 
> > No, thank you.
> 
> Would you like to check any further if a specific compiler implementation
> will still optimise common subexpressions as you desired it?
> 
> 
> > Also, please note that we do not really treat the allocated "mem" as an array,
> > but rather area of memory that holds all bits that we need to transfer,
> > and so I consider using kmalloc_array() actually wrong here.
> 
> Thanks for your explanation.
> 
> 
> > Please do not blindly follow checkpatch and coccinelle suggestions.
> > They are just that: suggestions and not hared rules.
> 
> I am curious on how to clarify corresponding deviations further.
> 
> 
> Would you like to suggest any other details so that the evolving scripts
> can become better and safer for static source code analysis?
> 
> Do you know any special properties which should be additionally checked
> at call sites which are similar to the discussed place?

If you are asking for some formal rules then no.

Again, what is the purpose of the changes? Are you working on the code
and the fact that the driver is older-style hinders your progress? Or
there are runtime improvements from your changes? Correctness issues?

I do not very much appreciate changes just to satisfy checkpatch rule
du jour.

Thanks.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: Input-evdev: Use kmalloc_array() in evdev_handle_get_val()
  2016-09-24 18:34         ` Dmitry Torokhov
@ 2016-09-24 19:04           ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 19:04 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: linux-input, Henrik Rydberg, LKML, kernel-janitors, Julia Lawall

> Again, what is the purpose of the changes?

I came also along a few source code places where their maintainers
requested the usage of a function like "kmalloc_array".

How do you think about to clarify the consistent use of programming
interfaces for Linux a bit more?


> Are you working on the code

I am trying to improve various free software (including Linux).


> and the fact that the driver is older-style hinders your progress?

Not for me directly.


> Or there are runtime improvements from your changes?

It depends on some factors.

Can an array memory allocator organise the desired data in a safer
and more efficient way than a "default approach"?


> Correctness issues?

This can be.

Do you care for source code annotations?


> I do not very much appreciate changes just to satisfy checkpatch rule
> du jour.

Do these rules contain knowledge which you give a significant value?

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

* Re: iio: Rename a jump label in iio_buffer_store_watermark()
  2016-09-24 15:32     ` Jonathan Cameron
@ 2016-09-24 19:21       ` SF Markus Elfring
  0 siblings, 0 replies; 1373+ messages in thread
From: SF Markus Elfring @ 2016-09-24 19:21 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: linux-iio, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald-Stadler, LKML, kernel-janitors, Julia Lawall

> I'm not necessarily against this change which does perhaps clarify the code
> ever so slightly,

Thanks for another bit of positive feedback.


> but I am interested to know where 'current Linux coding style convention' comes from?

How often do you check the status of a document like "CodingStyle" for example?   ;-)

How do you think about information from a commit like
"docs: Remove space-before-label guidance from CodingStyle" (on 2016-09-21)?
https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/Documentation/CodingStyle?id=79c70c304b0b443429b2a0019518532c5162817a

Regards,
Markus

^ permalink raw reply	[flat|nested] 1373+ messages in thread

end of thread, other threads:[~2016-09-24 19:21 UTC | newest]

Thread overview: 1373+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-11 12:08 Source code review around jump label usage SF Markus Elfring
2015-12-11 12:14 ` Julia Lawall
2015-12-11 12:48 ` Dan Carpenter
2015-12-11 18:00 ` Christophe JAILLET
2015-12-11 18:19 ` [PATCH 0/2] block: Fine-tuning for two function implementations SF Markus Elfring
2015-12-11 18:24   ` [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection SF Markus Elfring
2015-12-14  0:27     ` Sergey Senozhatsky
2015-12-14  6:58       ` SF Markus Elfring
2015-12-14  7:17         ` Julia Lawall
2015-12-14 10:03         ` Sergey Senozhatsky
2015-12-14 14:03           ` SF Markus Elfring
2015-12-11 18:26   ` [PATCH 2/2] z2ram: Delete a jump label in z2_init() SF Markus Elfring
2015-12-14  0:36     ` Sergey Senozhatsky
2015-12-14  9:10       ` Geert Uytterhoeven
2015-12-12  9:16 ` [PATCH] uinput: Rename a jump label in uinput_ioctl_handler() SF Markus Elfring
2015-12-12 22:23   ` Dmitry Torokhov
2015-12-12 14:30 ` [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations SF Markus Elfring
2015-12-12 14:34   ` [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly SF Markus Elfring
2015-12-12 19:49     ` Dan Carpenter
2015-12-12 21:22       ` SF Markus Elfring
2015-12-14  8:41       ` Johannes Thumshirn
2015-12-14 11:38         ` SF Markus Elfring
2015-12-12 14:37   ` [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection SF Markus Elfring
2015-12-12 14:40   ` [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_params() SF Markus Elfring
2015-12-12 14:41   ` [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious " SF Markus Elfring
2015-12-12 14:45     ` Julia Lawall
2015-12-12 15:02       ` SF Markus Elfring
2015-12-12 14:42   ` [PATCH 5/7] iscsi-target: Rename a jump label " SF Markus Elfring
2015-12-12 14:43   ` [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support() SF Markus Elfring
2015-12-12 14:45   ` [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious " SF Markus Elfring
2015-12-12 17:17     ` walter harms
2015-12-13 13:48 ` [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
2015-12-13 13:52   ` [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
2015-12-15 14:27     ` Joe Perches
2015-12-15 14:41       ` Dan Carpenter
2015-12-15 15:02         ` Joe Perches
2015-12-15 17:48           ` Dan Carpenter
2015-12-15 18:10             ` Joe Perches
2015-12-15 18:26               ` SF Markus Elfring
2015-12-15 18:34                 ` Joe Perches
2015-12-15 18:49                   ` SF Markus Elfring
2015-12-15 18:55                     ` Joe Perches
2015-12-15 18:02           ` SF Markus Elfring
2015-12-15 18:22             ` Joe Perches
2015-12-13 13:54   ` [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls SF Markus Elfring
2015-12-14  6:53     ` Dan Carpenter
2015-12-14  9:08       ` SF Markus Elfring
2015-12-14  9:31         ` Dan Carpenter
2015-12-14 10:03           ` SF Markus Elfring
2015-12-13 13:55   ` [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call SF Markus Elfring
2015-12-13 13:56   ` [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
2015-12-13 13:57   ` [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
2015-12-14 11:00     ` Dan Carpenter
2015-12-14 12:04       ` SF Markus Elfring
2015-12-14 12:38         ` Dan Carpenter
2015-12-14 12:45           ` SF Markus Elfring
2015-12-14 13:57             ` Dan Carpenter
2015-12-14 17:43               ` SF Markus Elfring
2015-12-15 11:42                 ` Dan Carpenter
2015-12-15 15:00                   ` SF Markus Elfring
2015-12-13 13:58   ` [PATCH 6/7] staging: lustre: A few checks less " SF Markus Elfring
2015-12-13 14:00   ` [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls SF Markus Elfring
2015-12-21 19:05   ` [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations SF Markus Elfring
2015-12-21 19:09     ` [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions SF Markus Elfring
2015-12-21 19:10     ` [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log() SF Markus Elfring
2015-12-21 19:12     ` [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection SF Markus Elfring
2015-12-21 23:48       ` Greg Kroah-Hartman
2015-12-22  7:15         ` SF Markus Elfring
2015-12-22  8:00         ` Dan Carpenter
2016-07-26 18:54         ` [PATCH 00/12] staging-Lustre: Fine-tuning for seven function implementations SF Markus Elfring
2016-07-26 18:56           ` [PATCH 01/12] staging/lustre/ldlm: Delete unnecessary checks before the function call "kset_unregister" SF Markus Elfring
2016-07-26 19:00           ` [PATCH 02/12] staging: lustre: Delete unnecessary checks before the function call "kobject_put" SF Markus Elfring
2016-07-26 19:02           ` [PATCH 03/12] staging: lustre: One function call less in class_register_type() after error detection SF Markus Elfring
2016-07-26 19:08             ` Oleg Drokin
2016-07-26 19:56               ` SF Markus Elfring
2016-07-26 21:49                 ` Oleg Drokin
2016-07-28  5:53                   ` SF Markus Elfring
2016-07-29 15:28                     ` [lustre-devel] " Oleg Drokin
2016-07-30  6:24                       ` SF Markus Elfring
2016-07-26 19:04           ` [PATCH 04/12] staging: lustre: Split a condition check in class_register_type() SF Markus Elfring
2016-07-26 19:05           ` [PATCH 05/12] staging: lustre: Optimize error handling " SF Markus Elfring
2016-07-26 19:11             ` Oleg Drokin
2016-07-26 19:16               ` [lustre-devel] " Oleg Drokin
2016-07-26 20:11               ` SF Markus Elfring
2016-07-26 19:07           ` [PATCH 06/12] staging: lustre: Return directly after a failed kcalloc() in mgc_process_recover_log() SF Markus Elfring
2016-07-26 19:08           ` [PATCH 07/12] staging: lustre: Less checks after a failed alloc_page() " SF Markus Elfring
2016-07-26 19:09           ` [PATCH 08/12] staging: lustre: Less checks after a failed ptlrpc_request_alloc() " SF Markus Elfring
2016-07-26 19:10           ` [PATCH 09/12] staging: lustre: Delete a check for the variable "req" " SF Markus Elfring
2016-07-26 19:12           ` [PATCH 10/12] staging: lustre: Rename jump labels " SF Markus Elfring
2016-07-26 19:13           ` [PATCH 11/12] staging: lustre: Move an assignment for the variable "eof" " SF Markus Elfring
2016-07-26 19:14           ` [PATCH 12/12] staging: lustre: Delete an unnecessary variable initialisation " SF Markus Elfring
2015-12-21 19:13     ` [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info() SF Markus Elfring
2015-12-14 22:10 ` [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection SF Markus Elfring
2015-12-14 22:20   ` Scott Wood
2015-12-23  9:43 ` [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() " SF Markus Elfring
2015-12-23 10:41   ` Julia Lawall
2015-12-23 18:02     ` [PATCH 0/5] block-LDM: Improvements for exception handling SF Markus Elfring
2015-12-23 18:06       ` [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection SF Markus Elfring
2015-12-23 18:09       ` [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures SF Markus Elfring
2015-12-23 18:10       ` [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection SF Markus Elfring
2015-12-23 18:12       ` [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() " SF Markus Elfring
2015-12-23 18:13       ` [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting SF Markus Elfring
2015-12-24 12:31 ` [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions SF Markus Elfring
2015-12-24 12:34   ` [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main() SF Markus Elfring
2015-12-24 14:22     ` Jonathan Corbet
2015-12-24 17:54       ` SF Markus Elfring
2015-12-24 12:36   ` [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" " SF Markus Elfring
2015-12-24 14:22     ` Jonathan Corbet
2015-12-24 12:38   ` [PATCH 3/3] Documentation-getdelays: Less function calls in usage() SF Markus Elfring
2015-12-24 14:23     ` Jonathan Corbet
2015-12-24 19:40       ` SF Markus Elfring
2015-12-25 10:35 ` ACPI-fan: Another source code review around null pointer handling? SF Markus Elfring
2015-12-25 16:00 ` sata_mv: Another source code review around exception handling? SF Markus Elfring
2015-12-28 16:10   ` Tejun Heo
2015-12-25 18:49 ` [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe() SF Markus Elfring
2015-12-26  6:34 ` [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection SF Markus Elfring
2015-12-26  6:47   ` kbuild test robot
2015-12-26  7:08     ` [PATCH v2] " SF Markus Elfring
2015-12-26  7:48       ` Wolfram Sang
2015-12-26  8:52         ` SF Markus Elfring
2015-12-26 18:41           ` Wolfram Sang
2015-12-26 19:30             ` SF Markus Elfring
2015-12-26 10:10 ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function SF Markus Elfring
2015-12-26 10:15   ` [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection SF Markus Elfring
2015-12-26 10:17   ` [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle() SF Markus Elfring
2015-12-26 10:20   ` [PATCH 3/3] IDE-ACPI: Move an assignment for one variable " SF Markus Elfring
2015-12-26 18:12   ` [PATCH 0/3] IDE-ACPI: Fine-tuning for a function David Miller
2015-12-26 23:43     ` Joe Perches
2015-12-27  6:08       ` Julia Lawall
2015-12-26 13:04 ` [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection SF Markus Elfring
2016-01-02 18:28   ` Jonathan Cameron
2015-12-26 18:39 ` [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
2015-12-26 18:43   ` [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
2015-12-26 19:41     ` kbuild test robot
2015-12-26 21:28       ` [PATCH v2 1/6] InfiniBand-ocrdma: One " SF Markus Elfring
2016-01-11 13:11         ` Selvin Xavier
2015-12-26 18:45   ` [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
2015-12-26 18:47   ` [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
2015-12-26 18:49   ` [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
2015-12-26 18:50   ` [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2015-12-26 18:51   ` [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2016-01-14 17:18   ` [PATCH v3 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations SF Markus Elfring
2016-01-14 17:38     ` [PATCH v3 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd() SF Markus Elfring
2016-01-14 17:43     ` [PATCH v3 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions SF Markus Elfring
2016-01-15 13:20       ` Leon Romanovsky
2016-01-15 14:50         ` SF Markus Elfring
2016-01-15 15:09           ` Leon Romanovsky
2016-01-15 15:26             ` SF Markus Elfring
2016-01-15 15:59               ` Leon Romanovsky
2016-01-15 16:10                 ` Dan Carpenter
2016-01-15 16:24                 ` SF Markus Elfring
2016-01-15 17:00                   ` Leon Romanovsky
2016-01-15 17:19                     ` Bart Van Assche
2016-01-15 17:41                       ` Leon Romanovsky
2016-01-15 18:19                     ` SF Markus Elfring
2016-01-16  6:18                       ` Leon Romanovsky
2016-01-16  8:30                         ` SF Markus Elfring
2016-01-14 17:45     ` [PATCH v3 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change() SF Markus Elfring
2016-01-14 17:48     ` [PATCH v3 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly SF Markus Elfring
2016-01-14 17:50     ` [PATCH v3 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq() SF Markus Elfring
2016-01-14 17:51     ` [PATCH v3 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd() SF Markus Elfring
2015-12-27 12:36 ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations SF Markus Elfring
2015-12-27 12:40   ` [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr() SF Markus Elfring
2015-12-27 12:41   ` [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr() SF Markus Elfring
2015-12-27 12:43   ` [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations Leon Romanovsky
2015-12-27 12:52   ` Leon Romanovsky
2015-12-27 15:26   ` Sagi Grimberg
2016-01-06 18:47   ` Nicholas A. Bellinger
2015-12-27 17:33 ` [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8() SF Markus Elfring
2016-01-04  8:39   ` Matthias Schwarzott
2015-12-27 21:22 ` [PATCH] [media] bttv: Returning only value constants in two functions SF Markus Elfring
2015-12-28  9:15 ` [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection SF Markus Elfring
2015-12-28  9:20   ` Julia Lawall
2015-12-28 10:30     ` SF Markus Elfring
2015-12-28 10:36       ` Julia Lawall
2015-12-28 14:36         ` [PATCH 0/2] [media] m88rs6000t: Fine-tuning for some function implementations SF Markus Elfring
2015-12-28 14:38           ` [PATCH 1/2] [media] m88rs6000t: Better exception handling in five functions SF Markus Elfring
2015-12-28 14:42             ` Julia Lawall
2015-12-28 15:03               ` SF Markus Elfring
2015-12-28 15:12                 ` Julia Lawall
2016-01-25 17:01             ` [PATCH 1/2] " Mauro Carvalho Chehab
2016-01-25 18:15               ` SF Markus Elfring
2015-12-28 14:42           ` [PATCH 2/2] [media] tuners: Refactoring for m88rs6000t_sleep() SF Markus Elfring
2015-12-28 16:24 ` [PATCH 0/2] [media] r820t: Fine-tuning for generic_set_freq() SF Markus Elfring
2015-12-28 16:30   ` [PATCH 1/2] [media] r820t: Delete an unnecessary variable initialisation in generic_set_freq() SF Markus Elfring
2015-12-28 16:32   ` [PATCH 2/2] [media] r820t: Better exception handling " SF Markus Elfring
2016-01-25 17:04     ` Mauro Carvalho Chehab
2015-12-28 19:20 ` [PATCH] [media] xc5000: Faster result reporting in xc_load_fw_and_init_tuner() SF Markus Elfring
2016-01-25 17:06   ` Mauro Carvalho Chehab
2016-01-25 18:23     ` SF Markus Elfring
2016-01-25 18:38       ` Devin Heitmueller
2015-12-28 21:15 ` [PATCH] [media] airspy: Better exception handling in two functions SF Markus Elfring
2015-12-28 21:56 ` [PATCH] [media] au0828: Refactoring for start_urb_transfer() SF Markus Elfring
2015-12-29 10:18 ` [PATCH] [media] hdpvr: Refactoring for hdpvr_read() SF Markus Elfring
2015-12-29 11:37 ` [PATCH] [media] msi2500: Delete an unnecessary check in msi2500_set_usb_adc() SF Markus Elfring
2015-12-29 13:04 ` [PATCH] mfd-dm355evm_msp: One function call less in add_child() after error detection SF Markus Elfring
2016-01-11  8:31   ` Lee Jones
2016-01-12  8:34     ` SF Markus Elfring
2016-01-12  9:06       ` Lee Jones
2016-01-12 11:48         ` SF Markus Elfring
2016-01-12 11:59           ` Lee Jones
2016-01-12 11:59   ` [PATCH] " Lee Jones
2016-01-12 12:20     ` SF Markus Elfring
2015-12-29 14:15 ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning for smsc_i2c_probe() SF Markus Elfring
2015-12-29 14:17   ` [PATCH 1/2] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
2016-01-11  8:15     ` Lee Jones
2015-12-29 14:18   ` [PATCH 2/2] mfd: smsc-ece1099: Refactoring for smsc_i2c_probe() SF Markus Elfring
2016-01-11  8:10     ` Lee Jones
2016-01-11  8:12       ` Lee Jones
     [not found]         ` <5694BE21.3010504@users.sourceforge.net>
2016-01-12  9:05           ` Lee Jones
2016-01-12 11:28             ` SF Markus Elfring
2016-01-11  8:08   ` [PATCH 0/2] mfd: smsc-ece1099: Fine-tuning " Lee Jones
2016-01-12  9:00     ` SF Markus Elfring
2016-01-12  9:12       ` Lee Jones
2016-01-12 11:03         ` SF Markus Elfring
2016-01-12 11:14           ` Lee Jones
2016-01-12 11:42             ` SF Markus Elfring
2016-01-12 12:03               ` Lee Jones
2015-12-29 18:34 ` [PATCH] mfd: twl-core: One function call less in add_numbered_child() after error detection SF Markus Elfring
2016-01-11  8:29   ` Lee Jones
2016-05-15 18:11     ` [PATCH 0/2] mfd: twl-core: Fine-tuning for add_numbered_child() SF Markus Elfring
2016-05-16  6:26       ` [PATCH 1/2] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
2016-05-16  6:51         ` Julia Lawall
2016-05-16  7:54           ` SF Markus Elfring
2016-05-16  8:07             ` Julia Lawall
2016-05-17  6:00               ` Lee Jones
2016-05-17 14:15                 ` SF Markus Elfring
2016-05-16  6:28       ` [PATCH 2/2] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
2016-06-08 11:14         ` Lee Jones
2016-06-26 13:34           ` [PATCH 0/6] mfd: Fine-tuning for three function implementations SF Markus Elfring
2016-06-26 13:45             ` [PATCH 1/6] mfd: twl-core: Return directly after a failed platform_device_alloc() in add_numbered_child() SF Markus Elfring
2016-06-28 15:02               ` Lee Jones
2016-06-26 13:47             ` [PATCH 2/6] mfd: twl-core: Refactoring for add_numbered_child() SF Markus Elfring
2016-06-28 15:03               ` Lee Jones
2016-06-26 13:48             ` [PATCH 3/6] mfd: dm355evm_msp: Return directly after a failed platform_device_alloc() in add_child() SF Markus Elfring
2016-06-28 15:03               ` Lee Jones
2016-06-26 13:50             ` [PATCH 4/6] mfd: dm355evm_msp: Refactoring for add_child() SF Markus Elfring
2016-06-28 15:07               ` Lee Jones
2016-06-28 15:40                 ` SF Markus Elfring
2016-06-28 16:31                   ` Lee Jones
2016-06-30 20:15                     ` [PATCH] " SF Markus Elfring
2016-06-30 20:34                       ` Joe Perches
2016-06-30 21:00                         ` Lee Jones
2016-07-01 14:40                         ` SF Markus Elfring
2016-07-01 16:23                           ` Joe Perches
2016-07-01  9:17                       ` [PATCH] " Lee Jones
2016-07-01 14:54                         ` SF Markus Elfring
2016-08-05  7:50                           ` Lee Jones
2016-08-05 18:51                             ` SF Markus Elfring
2016-08-08  9:11                               ` Lee Jones
2016-08-08  9:30                                 ` SF Markus Elfring
2016-08-09  9:41                                   ` Lee Jones
2016-06-26 13:51             ` [PATCH 5/6] mfd: smsc-ece1099: Delete an unnecessary variable initialisation in smsc_i2c_probe() SF Markus Elfring
2016-06-28 15:07               ` Lee Jones
2016-06-26 13:54             ` [PATCH 6/6] mfd: smsc-ece1099: Return directly after a function failure " SF Markus Elfring
2016-06-28 15:08               ` Lee Jones
2016-06-28 15:01             ` [PATCH 0/6] mfd: Fine-tuning for three function implementations Lee Jones
2015-12-29 19:50 ` [PATCH] mmc-core: One check less in mmc_select_hs200() after error detection SF Markus Elfring
2016-01-12 15:07   ` Ulf Hansson
2015-12-29 20:57 ` [PATCH 0/2] mmc-host: Fine-tuning for one function SF Markus Elfring
2015-12-29 21:00   ` [PATCH 1/2] mmc-sdricoh_cs: Delete unnecessary variable initialisations in sdricoh_init_mmc() SF Markus Elfring
2016-02-21  9:11     ` Sascha Sommer
2015-12-29 21:02   ` [PATCH 2/2] mmc-sdricoh_cs: Less checks in sdricoh_init_mmc() after, error detection SF Markus Elfring
2016-02-21  9:15     ` Sascha Sommer
2016-01-27 14:15   ` [PATCH 0/2] mmc-host: Fine-tuning for one function Ulf Hansson
2015-12-31 20:21 ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations SF Markus Elfring
2015-12-31 20:25   ` [PATCH 1/3] mtd-rfd_ftl: Replace a variable initialisation by assignments in move_block_contents() SF Markus Elfring
2015-12-31 20:26   ` [PATCH 2/3] mtd-rfd_ftl: Refactoring for move_block_contents() SF Markus Elfring
2015-12-31 20:27   ` [PATCH 3/3] mtd-rfd_ftl: Refactoring for erase_block() SF Markus Elfring
2016-01-05  0:13   ` [PATCH 0/3] mtd-rfd_ftl: Fine-tuning for two function implementations Brian Norris
2015-12-31 21:47 ` [PATCH] net-thunder: One check less in nicvf_register_interrupts() after error detection SF Markus Elfring
2016-01-07 11:07   ` Robert Richter
2016-01-07 19:30     ` SF Markus Elfring
2016-01-07 19:44       ` Joe Perches
2016-01-07 19:56         ` SF Markus Elfring
2016-01-07 19:59           ` Joe Perches
2016-01-07 20:07             ` SF Markus Elfring
2016-01-07 20:28               ` Joe Perches
2016-01-07 20:38                 ` SF Markus Elfring
2016-01-07 20:42                   ` Joe Perches
2015-12-31 23:22 ` [PATCH] be2net: Delete an unnecessary check in two functions SF Markus Elfring
2016-01-01 12:18 ` [PATCH 0/3] net-gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
2016-01-01 12:22   ` [PATCH 1/3] net-gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
2016-01-01 12:35     ` Julia Lawall
2016-01-01 12:50       ` SF Markus Elfring
2016-01-01 13:05         ` Julia Lawall
2016-01-01 14:45           ` Francois Romieu
2016-01-01 13:04       ` [PATCH v2 " SF Markus Elfring
2016-01-02  3:16         ` David Miller
2016-01-01 12:23   ` [PATCH 2/3] net-gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
2016-01-01 12:24   ` [PATCH 3/3] net-gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
2016-01-15 10:09   ` [PATCH v3 0/3] gianfar: Fine-tuning for gfar_ethflow_to_filer_table() SF Markus Elfring
2016-01-15 10:11     ` [PATCH v3 1/3] gianfar: Less function calls in gfar_ethflow_to_filer_table() after error detection SF Markus Elfring
2016-01-15 10:37       ` Joe Perches
2016-01-15 11:47         ` SF Markus Elfring
2016-01-15 12:03           ` Joe Perches
2016-01-15 17:32             ` SF Markus Elfring
2016-01-18 13:11               ` Claudiu Manoil
2016-01-15 10:12     ` [PATCH v3 2/3] gianfar: Delete unnecessary variable initialisations in gfar_ethflow_to_filer_table() SF Markus Elfring
2016-01-15 10:29       ` Dan Carpenter
2016-01-15 11:34         ` SF Markus Elfring
2016-01-15 12:15           ` Dan Carpenter
2016-01-15 16:42           ` David Miller
2016-01-15 17:15             ` SF Markus Elfring
2016-01-15 10:14     ` [PATCH v3 3/3] gianfar: Extend an initialisation clause of a for loop " SF Markus Elfring
2016-01-01 14:32 ` [PATCH] net-i40e: Replace variable initialisations by assignments in i40e_vc_get_vf_resources_msg() SF Markus Elfring
2016-01-07 22:43   ` Nelson, Shannon
2016-01-08 10:42   ` Jeff Kirsher
2016-01-01 15:57 ` [PATCH] net-huawei_cdc_ncm: Delete an unnecessary variable initialisation in huawei_cdc_ncm_bind() SF Markus Elfring
2016-01-01 16:50 ` [PATCH 0/2] net-qmi_wwan: Fine-tuning for two function implementations SF Markus Elfring
2016-01-01 16:54   ` [PATCH 1/2] net-qmi_wwan: Refactoring for qmi_wwan_bind() SF Markus Elfring
2016-01-02 21:38     ` Bjørn Mork
2016-01-01 16:56   ` [PATCH 2/2] net-qmi_wwan: Delete an unnecessary variable initialisation in qmi_wwan_register_subdriver() SF Markus Elfring
2016-01-02 21:30     ` Bjørn Mork
2016-01-03  1:45       ` David Miller
2016-01-01 18:21 ` [PATCH 0/2] net-ath9k_htc: Fine-tuning for two function implementations SF Markus Elfring
2016-01-01 18:23   ` [PATCH 1/2] net-ath9k_htc: Delete an unnecessary variable initialisation in ath9k_hif_usb_rx_stream() SF Markus Elfring
2016-01-01 19:14     ` Oleksij Rempel
2016-01-01 18:25   ` [PATCH 2/2] net-ath9k_htc: Replace a variable initialisation by an assignment in ath9k_htc_set_channel() SF Markus Elfring
2016-01-01 19:14     ` Oleksij Rempel
2016-04-08  1:40     ` Julian Calaby
2016-04-15 12:09       ` Kalle Valo
2016-04-15 14:34         ` Julian Calaby
2016-04-19 16:13       ` Kalle Valo
2016-01-01 19:26 ` [PATCH] net-brcmfmac: Delete an unnecessary variable initialisation in brcmf_sdio_download_firmware() SF Markus Elfring
2016-01-02  8:50   ` Arend van Spriel
2016-01-14  6:58     ` Kalle Valo
2016-01-01 20:27 ` [PATCH 0/3] net-iwlegacy: Fine-tuning for il_eeprom_init() SF Markus Elfring
2016-01-01 20:30   ` [PATCH 1/3] net-iwlegacy: Refactoring " SF Markus Elfring
2016-01-04  9:33     ` Stanislaw Gruszka
2016-01-01 20:31   ` [PATCH 2/3] net-iwlegacy: One check less in il_eeprom_init() after error detection SF Markus Elfring
2016-01-01 23:13     ` Sergei Shtylyov
2016-01-01 20:32   ` [PATCH 3/3] net-iwlegacy: Another refactoring for il_eeprom_init() SF Markus Elfring
2016-01-02 18:18     ` Souptick Joarder
2016-01-01 21:33 ` [PATCH] net-libertas: Better exception handling in if_spi_host_to_card_worker() SF Markus Elfring
2016-01-01 21:41   ` Julia Lawall
2016-01-01 23:14   ` Sergei Shtylyov
2016-01-02  8:09     ` SF Markus Elfring
2016-01-02  8:21       ` Julia Lawall
2016-01-02  9:08         ` SF Markus Elfring
2016-01-02 10:13           ` Arend van Spriel
2016-01-02 11:21             ` SF Markus Elfring
2016-01-03  9:36               ` Arend van Spriel
2016-01-03 12:13                 ` SF Markus Elfring
2016-01-03 15:18                 ` Rafał Miłecki
2016-01-04 10:05                   ` Arend van Spriel
2016-01-04 11:18                     ` Rafał Miłecki
2016-01-21 15:07         ` [PATCH] " Kalle Valo
2016-01-02 14:40 ` [PATCH 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
2016-01-02 14:43   ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
2016-01-02 15:12     ` net-rsi: Reconsider usage of variable "vap_id" " SF Markus Elfring
2016-01-02 16:32     ` [PATCH 1/3] rsi: Delete unnecessary variable initialisations " kbuild test robot
2016-01-02 18:27       ` [PATCH v2 " SF Markus Elfring
2016-01-04  9:28     ` [PATCH " Dan Carpenter
2016-01-04  9:38       ` Dan Carpenter
2016-01-04 10:44       ` SF Markus Elfring
2016-01-04 11:48         ` Dan Carpenter
2016-01-04 12:33           ` SF Markus Elfring
2016-01-04 23:54             ` Julian Calaby
2016-01-05  8:29               ` SF Markus Elfring
2016-01-05  9:47                 ` Julian Calaby
2016-01-05 16:23                   ` SF Markus Elfring
2016-01-04 13:17       ` [PATCH 1/3] " Bjørn Mork
2016-01-04 14:25         ` Dan Carpenter
2016-01-04 17:14       ` David Miller
2016-01-02 14:44   ` [PATCH 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
2016-01-02 14:45   ` [PATCH 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
2016-01-02 15:07     ` Francois Romieu
2016-01-15 13:04   ` [PATCH v3 0/3] net-rsi: Fine-tuning for two function implementations SF Markus Elfring
2016-01-15 13:09     ` [PATCH v3 1/3] rsi: Delete unnecessary variable initialisations in rsi_send_mgmt_pkt() SF Markus Elfring
2016-01-15 13:10     ` [PATCH v3 2/3] rsi: Delete unnecessary variable initialisations in rsi_send_data_pkt() SF Markus Elfring
2016-01-15 13:12     ` [PATCH v3 3/3] rsi: Replace variable initialisations by assignments " SF Markus Elfring
2016-01-19 12:40       ` Dan Carpenter
2016-01-02 17:50 ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations SF Markus Elfring
2016-01-02 17:54   ` [PATCH 1/5] xen-netback: Delete an unnecessary assignment in connect_rings() SF Markus Elfring
2016-01-02 17:55   ` [PATCH 2/5] xen-netback: Delete an unnecessary goto statement " SF Markus Elfring
2016-01-02 17:57   ` [PATCH 3/5] xen-netback: Replace a variable initialisation by an assignment in read_xenbus_vif_flags() SF Markus Elfring
2016-01-02 17:58   ` [PATCH 4/5] xen-netback: Replace a variable initialisation by an assignment in xen_register_watchers() SF Markus Elfring
2016-01-02 18:00   ` [PATCH 5/5] xen-netback: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-01-03  1:34   ` [PATCH 0/5] xen-netback: Fine-tuning for three function implementations Joe Perches
2016-01-04  9:40   ` Dan Carpenter
2016-01-04 11:08   ` Wei Liu
2016-01-02 20:51 ` [PATCH 0/3] NFC-mei_phy: Fine-tuning for two " SF Markus Elfring
2016-01-02 20:54   ` [PATCH 1/3] NFC-mei_phy: Refactoring for mei_nfc_connect() SF Markus Elfring
2016-01-02 23:41     ` Julian Calaby
2016-01-03  7:00       ` SF Markus Elfring
2016-01-03  7:29         ` Joe Perches
2016-01-02 20:55   ` [PATCH 2/3] NFC-mei_phy: Refactoring for mei_nfc_if_version() SF Markus Elfring
2016-01-02 20:56   ` [PATCH 3/3] NFC-mei_phy: Delete an unnecessary variable initialisation in mei_nfc_if_version() SF Markus Elfring
2016-01-03  8:43 ` [PATCH 0/8] rtc-ab-b5ze-s3: Fine-tuning for some function implementations SF Markus Elfring
2016-01-03  8:50   ` [PATCH 1/8] rtc-ab-b5ze-s3: Better exception handling in abb5zes3_probe() SF Markus Elfring
2016-01-03  8:51   ` [PATCH 2/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in abb5zes3_rtc_set_alarm() SF Markus Elfring
2016-01-03  8:52   ` [PATCH 3/8] rtc-ab-b5ze-s3: Delete an unnecessary variable initialisation in _abb5zes3_rtc_set_timer() SF Markus Elfring
2016-01-03  8:53   ` [PATCH 4/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_set_alarm() SF Markus Elfring
2016-01-03  8:54   ` [PATCH 5/8] rtc-ab-b5ze-s3: Replace a variable initialisation by an assignment in _abb5zes3_rtc_read_alarm() SF Markus Elfring
2016-01-03  8:55   ` [PATCH 6/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_read_timer() SF Markus Elfring
2016-01-03  8:56   ` [PATCH 7/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_interrupt() SF Markus Elfring
2016-01-03 12:48     ` Julia Lawall
2016-01-03 16:54       ` SF Markus Elfring
2016-01-03 16:59         ` Julia Lawall
2016-01-03 12:48     ` Julia Lawall
2016-01-03 17:00       ` SF Markus Elfring
2016-01-03  8:57   ` [PATCH 8/8] rtc-ab-b5ze-s3: Delete an unnecessary variable in _abb5zes3_rtc_set_timer() SF Markus Elfring
2016-01-03 12:47     ` Julia Lawall
2016-01-03 17:25       ` SF Markus Elfring
2016-01-03 17:29         ` Julia Lawall
2016-01-03 10:00 ` [PATCH 0/2] 390/qeth: Fine-tuning for qeth_core_set_online() SF Markus Elfring
2016-01-03 10:02   ` [PATCH 1/2] 390/qeth: Delete an unnecessary variable initialisation in qeth_core_set_online() SF Markus Elfring
2016-01-04 11:29     ` Heiko Carstens
2016-01-07 14:33     ` Ursula Braun
2016-01-08  7:18       ` SF Markus Elfring
2016-01-08  8:25         ` Ursula Braun
2016-01-08 12:00           ` SF Markus Elfring
2016-01-03 10:02   ` [PATCH 2/2] 390/qeth: Refactoring for qeth_core_set_online() SF Markus Elfring
2016-01-04 11:30     ` Heiko Carstens
2016-01-04 13:10       ` SF Markus Elfring
2016-01-04 14:04         ` Heiko Carstens
2016-01-04 14:10           ` SF Markus Elfring
2016-01-05  7:54             ` Heiko Carstens
2016-01-03 16:32 ` [PATCH] staging-slicoss: Replace variable initialisations by assignments in slic_if_init() SF Markus Elfring
2016-01-03 16:41   ` Julia Lawall
2016-01-03 17:48     ` SF Markus Elfring
2016-01-03 17:58       ` Greg Kroah-Hartman
2016-01-03 18:16         ` SF Markus Elfring
2016-01-03 18:26           ` Greg Kroah-Hartman
2016-01-03 18:50             ` SF Markus Elfring
2016-01-03 19:45               ` Greg Kroah-Hartman
2016-01-03 20:10                 ` SF Markus Elfring
2016-01-03 20:15                   ` Greg Kroah-Hartman
2016-01-03 20:21                     ` SF Markus Elfring
2016-07-02 19:00 ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling in psif_probe() SF Markus Elfring
2016-07-02 19:05   ` [PATCH 1/2] Input-at32psif: Return directly after a failed kzalloc() " SF Markus Elfring
2016-07-02 19:07   ` [PATCH 2/2] Input-at32psif: Remove OOM messages " SF Markus Elfring
2016-07-02 19:29     ` Julia Lawall
2016-07-02 20:45   ` [PATCH 0/2] Input-at32psif: Fine-tuning for OOM handling " Joe Perches
2016-07-03  8:01     ` SF Markus Elfring
2016-07-13 22:01   ` Dmitry Torokhov
2016-08-18  9:48 ` [PATCH 0/5] block-cciss: Fine-tuning for two function implementations SF Markus Elfring
2016-08-18  9:55   ` [PATCH 1/5] block-cciss: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-18  9:56   ` [PATCH 2/5] block-cciss: Less function calls in cciss_bigpassthru() after error detection SF Markus Elfring
2016-08-18 10:00   ` [PATCH 3/5] block-cciss: Delete unnecessary initialisations in cciss_bigpassthru() SF Markus Elfring
2016-08-18 10:02   ` [PATCH 4/5] block-cciss: Move an assignment for the variable "sg_used" " SF Markus Elfring
2016-08-18 10:03   ` [PATCH 5/5] block-cciss: Replace three kzalloc() calls by kcalloc() SF Markus Elfring
2016-08-18 19:42 ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() SF Markus Elfring
2016-08-18 19:45   ` [PATCH 1/2] GPU-DRM-Savage: Use memdup_user() rather than duplicating SF Markus Elfring
2016-08-18 19:48   ` [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection SF Markus Elfring
2016-08-19  7:50     ` Daniel Vetter
2016-08-19  7:41   ` [PATCH 0/2] GPU-DRM-Savage: Fine-tuning for savage_bci_cmdbuf() Daniel Vetter
2016-08-19  9:17 ` [PATCH 0/2] uvc_v4l2: Fine-tuning for uvc_ioctl_ctrl_map() SF Markus Elfring
2016-08-19  9:23   ` [PATCH 1/2] uvc_v4l2: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-19  9:25   ` [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection SF Markus Elfring
2016-08-19 18:27 ` [PATCH 0/2] misc/mic/vop: Fine-tuning for vop_ioctl() SF Markus Elfring
2016-08-19 18:28   ` [PATCH 1/2] misc/mic/vop: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-19 18:30   ` [PATCH 2/2] misc/mic/vop: Rename jump labels in vop_ioctl() SF Markus Elfring
2016-08-19 19:21 ` [PATCH] VMCI: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-19 21:07 ` [PATCH 0/2] mmc-block: Fine-tuning for mmc_blk_ioctl_copy_from_user() SF Markus Elfring
2016-08-19 21:10   ` [PATCH 1/2] mmc-block: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20  9:25     ` walter harms
2016-08-19 21:12   ` [PATCH 2/2] mmc-block: Rename jump labels in mmc_blk_ioctl_copy_from_user() SF Markus Elfring
2016-08-20  6:01 ` [PATCH] mlx5/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20  9:32   ` walter harms
2016-08-23  0:05   ` David Miller
2016-08-20  7:27 ` [PATCH 0/2] tun: Fine-tuning for update_filter() SF Markus Elfring
2016-08-20  7:34   ` [PATCH 1/2] tun: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20 11:47     ` Shmulik Ladkani
2016-08-22  1:43     ` Michael S. Tsirkin
2016-08-20  7:37   ` [PATCH 2/2] tun: Rename a jump label in update_filter() SF Markus Elfring
2016-08-22  1:41     ` Michael S. Tsirkin
2016-08-22  5:26       ` Mike Rapoport
2016-08-21  2:11   ` [PATCH 0/2] tun: Fine-tuning for update_filter() David Miller
2016-08-20 16:43 ` [PATCH 0/3] hostap: Fine-tuning for a few functions SF Markus Elfring
2016-08-20 16:45   ` [PATCH 1/3] hostap: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20 16:46   ` [PATCH 2/3] hostap: Delete an unnecessary jump label in prism2_ioctl_priv_hostapd() SF Markus Elfring
2016-08-21  1:45     ` Julian Calaby
2016-08-20 16:48   ` [PATCH 3/3] hostap: Delete unnecessary initialisations for the variable "ret" SF Markus Elfring
2016-08-20 19:26   ` [PATCH 0/3] hostap: Fine-tuning for a few functions Arend van Spriel
2016-08-22 15:49     ` Kalle Valo
2016-08-22 16:18       ` Joe Perches
2016-08-22 18:17       ` [PATCH] checkpatch: See if modified files are marked obsolete in MAINTAINERS Joe Perches
2016-08-22 20:50         ` SF Markus Elfring
2016-08-22 20:56           ` Joe Perches
2016-08-23  7:26         ` SF Markus Elfring
2016-08-23 10:18           ` Julia Lawall
2016-08-20 17:32 ` [PATCH] s390/tape: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-22  6:24   ` Martin Schwidefsky
2016-08-21  7:14 ` [PATCH 0/7] aacraid: Fine-tuning for a few functions SF Markus Elfring
2016-08-21  7:19   ` [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-22 18:00     ` David Carroll
2016-08-22 20:23       ` SF Markus Elfring
2016-08-24 23:01         ` David Carroll
2016-08-21  7:20   ` [PATCH 2/7] aacraid: One function call less in aac_send_raw_srb() after error detection SF Markus Elfring
2016-08-21  7:22   ` [PATCH 3/7] aacraid: Delete unnecessary initialisations in aac_send_raw_srb() SF Markus Elfring
2016-08-21  7:24   ` [PATCH 4/7] aacraid: Delete unnecessary braces SF Markus Elfring
2016-08-21  7:25   ` [PATCH 5/7] aacraid: Add spaces after control flow keywords SF Markus Elfring
2016-08-21  7:27   ` [PATCH 6/7] aacraid: Improve determination of a few sizes SF Markus Elfring
2016-08-21  7:29   ` [PATCH 7/7] aacraid: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
2016-08-21  8:48 ` [PATCH] megaraid_sas: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-22  9:31   ` Sumit Saxena
2016-08-24  2:47   ` Martin K. Petersen
2016-08-21  9:45 ` [PATCH] staging/lustre/llite: " SF Markus Elfring
2016-08-21  9:59   ` Christophe JAILLET
2016-08-21 10:31     ` Julia Lawall
2016-08-21 10:55       ` Vaishali Thakkar
2016-08-21 11:01         ` Julia Lawall
2016-08-21 12:09           ` Vaishali Thakkar
2016-08-21 13:50 ` [PATCH 0/7] USB-iowarrior: Fine-tuning for some function implementations SF Markus Elfring
2016-08-21 13:55   ` [PATCH 1/7] USB-iowarrior: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-21 13:56   ` [PATCH 2/7] USB-iowarrior: Delete unnecessary initialisations for the variable "dev" SF Markus Elfring
2016-08-21 13:58   ` [PATCH 3/7] USB-iowarrior: Delete an unnecessary initialisation in iowarrior_release() SF Markus Elfring
2016-08-21 14:00   ` [PATCH 4/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_open() SF Markus Elfring
2016-08-21 14:02   ` [PATCH 5/7] USB-iowarrior: Delete unnecessary initialisations in iowarrior_write() SF Markus Elfring
2016-08-21 14:04   ` [PATCH 6/7] USB-iowarrior: Delete unnecessary braces SF Markus Elfring
2016-08-21 14:06   ` [PATCH 7/7] USB-iowarrior: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
2016-08-21 17:39 ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() SF Markus Elfring
2016-08-21 17:42   ` [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-21 17:45   ` [PATCH 2/2] IB/core: Delete an unnecessary initialisation in ib_is_udata_cleared() SF Markus Elfring
2016-08-21 18:03   ` [PATCH 0/2] IB/core: Fine-tuning for ib_is_udata_cleared() Joe Perches
2016-08-21 19:51     ` SF Markus Elfring
2016-08-21 19:53       ` Joe Perches
2016-08-21 20:15         ` SF Markus Elfring
2016-08-22  9:46           ` Yann Droneaud
2016-08-22 16:30             ` [PATCH v2] IB/core: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-23 16:43               ` Doug Ledford
2016-08-21 18:26 ` [PATCH] Smack: " SF Markus Elfring
2016-08-23 21:56   ` Casey Schaufler
2016-08-21 19:41 ` [PATCH 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
2016-08-21 19:43   ` [PATCH 1/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-22  5:01     ` Vinod Koul
2016-08-22 12:05     ` [alsa-devel] " Takashi Iwai
2016-08-23  3:55       ` Vinod Koul
2016-08-21 19:45   ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() SF Markus Elfring
2016-08-21 19:51     ` Joe Perches
2016-08-22  8:34       ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() SF Markus Elfring
2016-08-22  8:38         ` [PATCH v2 1/2] ALSA: compress: Restructure source code around an if statement in snd_compr_set_params() SF Markus Elfring
2016-08-22  8:40         ` [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-23  4:04         ` [PATCH v2 0/2] ALSA: compress: Fine-tuning for snd_compr_set_params() Vinod Koul
2016-08-21 20:36     ` [PATCH 2/2] ALSA: compress: Reduce the scope for two variables in snd_compr_set_params() Julia Lawall
2016-08-22  5:01       ` Vinod Koul
2016-08-22  7:20     ` walter harms
2016-08-26 12:43 ` [PATCH 0/8] cris-cryptocop: Fine-tuning for some function implementations SF Markus Elfring
2016-08-26 12:48   ` [PATCH 1/8] cris-cryptocop: Use kmalloc_array() in two functions SF Markus Elfring
2016-08-26 12:50   ` [PATCH 2/8] cris-cryptocop: Improve determination of sizes in five functions SF Markus Elfring
2016-08-26 12:51   ` [PATCH 3/8] cris-cryptocop: Delete unnecessary braces SF Markus Elfring
2016-08-26 12:54   ` [PATCH 4/8] cris-cryptocop: Less function calls in cryptocop_ioctl_process() after error detection SF Markus Elfring
2016-08-26 12:55   ` [PATCH 5/8] cris-cryptocop: Move an assignment for the variable "nooutpages" in cryptocop_ioctl_process() SF Markus Elfring
2016-08-27 19:07     ` Julia Lawall
2016-08-28  7:28       ` SF Markus Elfring
2016-08-28 10:24         ` Julia Lawall
2016-08-26 12:56   ` [PATCH 6/8] cris-cryptocop: Delete two variables " SF Markus Elfring
2016-08-26 12:58   ` [PATCH 7/8] cris-cryptocop: Delete unnecessary variable initialisations " SF Markus Elfring
2016-08-26 13:00   ` [PATCH 8/8] cris-cryptocop: Apply another recommendation from "checkpatch.pl" SF Markus Elfring
2016-08-27 19:06     ` Julia Lawall
2016-08-28  7:18       ` SF Markus Elfring
2016-08-28 10:25         ` Julia Lawall
2016-08-28 13:22           ` SF Markus Elfring
2016-08-28 17:09 ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations SF Markus Elfring
2016-08-28 17:12   ` [PATCH 1/6] KVM: PPC: e500: Use kmalloc_array() in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
2016-08-28 17:14   ` [PATCH 2/6] KVM: PPC: e500: Less function calls in kvm_vcpu_ioctl_config_tlb() after error detection SF Markus Elfring
2016-08-28 17:15   ` [PATCH 3/6] KVM: PPC: e500: Delete an unnecessary initialisation in kvm_vcpu_ioctl_config_tlb() SF Markus Elfring
2016-08-28 17:16   ` [PATCH 4/6] KVM: PPC: e500: Replace kzalloc() calls by kcalloc() in two functions SF Markus Elfring
2016-08-28 17:18   ` [PATCH 5/6] KVM: PPC: e500: Use kmalloc_array() in kvmppc_e500_tlb_init() SF Markus Elfring
2016-08-28 17:46     ` Julia Lawall
2016-08-28 17:19   ` [PATCH 6/6] KVM: PPC: e500: Rename jump labels " SF Markus Elfring
2016-08-28 17:48     ` Julia Lawall
2016-09-11 23:25     ` Paul Mackerras
2016-09-12 21:00       ` [PATCH] " SF Markus Elfring
2016-09-12  0:54   ` [PATCH 0/6] KVM: PPC: e500: Fine-tuning for two function implementations Paul Mackerras
2016-08-29 11:00 ` [PATCH 0/5] PowerPC: Fine-tuning for three " SF Markus Elfring
2016-08-29 11:00 ` SF Markus Elfring
2016-08-29 11:07   ` [PATCH 1/5] powerpc-mpic: Use kmalloc_array() in mpic_init() SF Markus Elfring
2016-08-29 11:09   ` [PATCH 2/5] powerpc-MSI: Use kmalloc_array() in ppc4xx_setup_msi_irqs() SF Markus Elfring
2016-08-29 11:10   ` [PATCH 3/5] powerpc-MSI-HSTA: Use kmalloc_array() in hsta_msi_probe() SF Markus Elfring
2016-08-29 11:12   ` [PATCH 4/5] powerpc-MSI-HSTA: Rename jump labels " SF Markus Elfring
2016-08-29 11:13   ` [PATCH 5/5] powerpc-MSI-HSTA: Move three assignments " SF Markus Elfring
2016-09-03 12:04 ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations SF Markus Elfring
2016-09-03 12:10   ` [PATCH 01/17] s390/debug: Use kmalloc_array() in debug_areas_alloc() SF Markus Elfring
2016-09-03 12:13   ` [PATCH 02/17] s390/debug: Delete unnecessary braces SF Markus Elfring
2016-09-03 12:14   ` [PATCH 03/17] s390/debug: Add some spaces for better code readability SF Markus Elfring
2016-09-03 12:16   ` [PATCH 04/17] s390/debug: Rename jump labels in debug_areas_alloc() SF Markus Elfring
2016-09-03 12:18   ` [PATCH 05/17] s390/debug: Fix jump targets in debug_info_alloc() SF Markus Elfring
2016-09-03 12:20   ` [PATCH 06/17] s390/debug: Rename jump labels in debug_info_copy() SF Markus Elfring
2016-09-03 12:21   ` [PATCH 07/17] s390/debug: Rename jump labels in debug_open() SF Markus Elfring
2016-09-03 12:23   ` [PATCH 08/17] s390/debug: Fix a jump target in debug_register_mode() SF Markus Elfring
2016-09-03 12:24   ` [PATCH 09/17] s390/debug: Return directly if a null pointer was passed to debug_unregister() SF Markus Elfring
2016-09-03 12:42     ` walter harms
2016-09-03 12:26   ` [PATCH 10/17] s390/debug: Delete an unnecessary initialisation in debug_prolog_level_fn() SF Markus Elfring
2016-09-03 12:28   ` [PATCH 11/17] s390/debug: Fix indentation in 13 functions SF Markus Elfring
2016-09-03 12:30   ` [PATCH 12/17] s390/debug: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-09-03 13:10     ` kbuild test robot
2016-09-03 12:32   ` [PATCH 13/17] s390/debug: Improve a size determination in debug_open() SF Markus Elfring
2016-09-03 12:34   ` [PATCH 14/17] s390/debug: Improve a size determination in debug_sprintf_format_fn() SF Markus Elfring
2016-09-03 12:36   ` [PATCH 15/17] s390/debug: Improve a size determination in debug_raw_header_fn() SF Markus Elfring
2016-09-03 12:38   ` [PATCH 16/17] s390/debug: Improve determination of sizes in debug_info_alloc() SF Markus Elfring
2016-09-03 12:40   ` [PATCH 17/17] s390/debug: Improve another size determination " SF Markus Elfring
2016-09-05 10:31   ` [PATCH 00/17] s390/debug: Fine-tuning for several function implementations Martin Schwidefsky
2016-09-05 10:40     ` SF Markus Elfring
2016-09-09 16:50     ` SF Markus Elfring
2016-09-03 16:33 ` [PATCH 0/4] sparc: bpf_jit: Fine-tuning for bpf_jit_compile() SF Markus Elfring
2016-09-03 16:36   ` [PATCH 1/4] sparc: bpf_jit: Use kmalloc_array() in bpf_jit_compile() SF Markus Elfring
2016-09-03 16:51     ` Daniel Borkmann
2016-09-03 16:38   ` [PATCH 2/4] sparc: bpf_jit: Move four assignments " SF Markus Elfring
2016-09-04  3:21     ` Julian Calaby
2016-09-04  4:33       ` SF Markus Elfring
2016-09-04  4:44         ` Julian Calaby
2016-09-04  5:00           ` SF Markus Elfring
2016-09-04  5:16             ` Julian Calaby
2016-09-04  5:45               ` SF Markus Elfring
2016-09-04  5:59                 ` Julian Calaby
2016-09-04  6:28                   ` SF Markus Elfring
2016-09-04  6:34                 ` David Miller
2016-09-04  6:32             ` David Miller
2016-09-04  6:44               ` Julian Calaby
2016-09-04  7:07                 ` SF Markus Elfring
2016-09-04  7:18                   ` Julian Calaby
2016-09-04 19:33           ` [PATCH 2/4] " Bjørn Mork
2016-09-03 16:40   ` [PATCH 3/4] sparc: bpf_jit: Avoid assignment for "flen" if BPF JIT is disabled SF Markus Elfring
2016-09-03 16:58     ` Daniel Borkmann
2016-09-03 16:41   ` [PATCH 4/4] sparc: bpf_jit: Rename jump labels in bpf_jit_compile() SF Markus Elfring
2016-09-03 16:52     ` Daniel Borkmann
2016-09-04  6:06       ` David Miller
2016-09-04  6:50         ` SF Markus Elfring
2016-09-04  6:59           ` David Miller
2016-09-04  7:20             ` SF Markus Elfring
2016-09-04  7:32               ` David Miller
2016-09-04  7:40                 ` SF Markus Elfring
2016-09-04  9:56               ` Daniel Borkmann
2016-09-04 13:50                 ` Clarification for source code formatting around jump labels SF Markus Elfring
2016-09-04 17:04                   ` Daniel Borkmann
2016-09-05 11:07                 ` sparc: bpf_jit: Rename jump labels in bpf_jit_compile() Jean Delvare
2016-09-05 11:37                   ` Peter Zijlstra
2016-09-05 11:54                     ` Jean Delvare
2016-09-05 11:58                       ` Peter Zijlstra
2016-09-06 14:34                         ` Jean Delvare
2016-09-06 14:47                           ` Peter Zijlstra
2016-09-06 15:29                             ` Joe Perches
2016-09-07 12:30                             ` Jean Delvare
2016-09-03 19:00 ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() SF Markus Elfring
2016-09-03 19:01   ` [PATCH 1/2] tile-module: Use kmalloc_array() in module_alloc() SF Markus Elfring
2016-09-03 19:02   ` [PATCH 2/2] tile-module: Rename jump labels " SF Markus Elfring
2016-09-06 15:25   ` [PATCH 0/2] tile-module: Fine-tuning for module_alloc() Chris Metcalf
2016-09-04 17:49 ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations SF Markus Elfring
2016-09-04 17:54   ` [PATCH 1/4] perf/x86/cqm: Use kmalloc_array() in intel_mbm_init() SF Markus Elfring
2016-09-05  7:52     ` Peter Zijlstra
2016-09-04 17:56   ` [PATCH 2/4] perf/x86/cqm: Replace two kmalloc() calls by " SF Markus Elfring
2016-09-05  7:53     ` Peter Zijlstra
2016-09-04 17:58   ` [PATCH 3/4] perf/x86/cqm: One check and another variable less " SF Markus Elfring
2016-09-05  7:54     ` Peter Zijlstra
2016-09-04 18:00   ` [PATCH 4/4] perf/x86/cqm: Rename jump labels in intel_cqm_init() SF Markus Elfring
2016-09-05  7:55   ` [PATCH 0/4] perf/x86/cqm: Fine-tuning for two function implementations Peter Zijlstra
2016-09-05 16:42 ` [PATCH 00/21] ACPI-video: Fine-tuning for several " SF Markus Elfring
2016-09-05 16:45   ` [PATCH 01/21] ACPI-video: Use kmalloc_array() in acpi_video_get_levels() SF Markus Elfring
2016-09-05 16:46   ` [PATCH 02/21] ACPI-video: Return directly after a failed device query SF Markus Elfring
2016-09-05 16:48   ` [PATCH 03/21] ACPI-video: Delete an error message for a failed kzalloc() call SF Markus Elfring
2016-09-05 16:50   ` [PATCH 04/21] ACPI-video: Rename jump labels in acpi_video_get_levels() SF Markus Elfring
2016-09-05 16:51   ` [PATCH 05/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-05 16:52   ` [PATCH 06/21] ACPI-video: Move four assignments " SF Markus Elfring
2016-09-05 16:53   ` [PATCH 07/21] ACPI-video: Rename jump labels in acpi_video_bus_add() SF Markus Elfring
2016-09-05 16:54   ` [PATCH 08/21] ACPI-video: Improve a size determination " SF Markus Elfring
2016-09-05 16:56   ` [PATCH 09/21] ACPI-video: Rename jump labels in acpi_video_register() SF Markus Elfring
2016-09-05 16:57   ` [PATCH 10/21] ACPI-video: Return directly after a failed input_allocate_device() SF Markus Elfring
2016-09-05 16:58   ` [PATCH 11/21] ACPI-video: Rename jump labels in acpi_video_bus_add_notify_handler() SF Markus Elfring
2016-09-05 16:59   ` [PATCH 12/21] ACPI-video: Delete unnecessary if statement in acpi_video_switch_brightness() SF Markus Elfring
2016-09-05 17:00   ` [PATCH 13/21] ACPI-video: Improve a jump target " SF Markus Elfring
2016-09-05 17:01   ` [PATCH 14/21] ACPI-video: Improve a size determination in acpi_video_device_enumerate() SF Markus Elfring
2016-09-05 17:02   ` [PATCH 15/21] ACPI-video: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-05 17:03   ` [PATCH 16/21] ACPI-video: Rename jump labels " SF Markus Elfring
2016-09-05 17:04   ` [PATCH 17/21] ACPI-video: Delete an unnecessary initialisation in acpi_video_init_brightness() SF Markus Elfring
2016-09-05 17:05   ` [PATCH 18/21] ACPI-video: Rename jump labels " SF Markus Elfring
2016-09-05 17:06   ` [PATCH 19/21] ACPI-video: Rename a jump label in acpi_video_device_lcd_query_levels() SF Markus Elfring
2016-09-05 17:07   ` [PATCH 20/21] ACPI-video: Improve a size determination in acpi_video_dev_register_backlight() SF Markus Elfring
2016-09-05 17:09   ` [PATCH 21/21] ACPI-video: Improve a size determination in acpi_video_bus_get_one_device() SF Markus Elfring
2016-09-05 21:41   ` [PATCH 00/21] ACPI-video: Fine-tuning for several function implementations Rafael J. Wysocki
2016-09-06  3:28     ` SF Markus Elfring
2016-09-06 11:21       ` Rafael J. Wysocki
2016-09-06 14:10         ` SF Markus Elfring
2016-09-06 21:05           ` Rafael J. Wysocki
2016-09-07  6:40             ` SF Markus Elfring
2016-09-05 20:12 ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three " SF Markus Elfring
2016-09-05 20:15   ` [PATCH 1/7] ACPI-APEI-HEST: Fix a typo in a comment line SF Markus Elfring
2016-09-05 20:17   ` [PATCH 2/7] ACPI-APEI-HEST: Use kmalloc_array() in hest_ghes_dev_register() SF Markus Elfring
2016-09-05 20:18   ` [PATCH 3/7] ACPI-APEI-HEST: Move an assignment " SF Markus Elfring
2016-09-05 20:20   ` [PATCH 4/7] ACPI-APEI-HEST: Rename jump labels " SF Markus Elfring
2016-09-05 20:21   ` [PATCH 5/7] ACPI-APEI-HEST: Rename jump labels in acpi_hest_init() SF Markus Elfring
2016-09-05 20:22   ` [PATCH 6/7] ACPI-APEI-HEST: Reduce the scope for a variable " SF Markus Elfring
2016-09-05 20:23   ` [PATCH 7/7] ACPI-APEI-HEST: Rename jump labels in hest_parse_ghes() SF Markus Elfring
2016-09-05 21:43   ` [PATCH 0/7] ACPI-APEI-HEST: Fine-tuning for three function implementations Rafael J. Wysocki
2016-09-06  3:38     ` SF Markus Elfring
2016-09-06 11:25       ` Rafael J. Wysocki
2016-09-06 14:21         ` SF Markus Elfring
2016-09-10 14:20 ` [PATCH 0/7] cfag12864b: Fine-tuning for cfag12864b_init() SF Markus Elfring
2016-09-10 14:23   ` [PATCH 1/7] cfag12864b: Use kmalloc_array() in cfag12864b_init() SF Markus Elfring
2016-09-10 14:26   ` [PATCH 2/7] cfag12864b: Delete an error message for a failed kmalloc_array() call SF Markus Elfring
2016-09-10 14:27   ` [PATCH 3/7] cfag12864b: Return directly if the driver "ks0108" was not initialized SF Markus Elfring
2016-09-10 14:28   ` [PATCH 4/7] cfag12864b: Return directly after a failed get_zeroed_page() SF Markus Elfring
2016-09-10 14:29   ` [PATCH 5/7] cfag12864b: Rename jump labels in cfag12864b_init() SF Markus Elfring
2016-09-10 14:30   ` [PATCH 6/7] cfag12864b: Return an error code only as a constant " SF Markus Elfring
2016-09-10 14:32   ` [PATCH 7/7] cfag12864b: Adjust two checks for null pointers " SF Markus Elfring
2016-09-12 18:40 ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations SF Markus Elfring
2016-09-12 18:42   ` [PATCH 01/47] block-rbd: Use kmalloc_array() in rbd_header_from_disk() SF Markus Elfring
2016-09-14 15:25     ` Ilya Dryomov
2016-09-12 18:43   ` [PATCH 02/47] block-rbd: Less function calls in rbd_header_from_disk() after error detection SF Markus Elfring
2016-09-13  7:58     ` Ilya Dryomov
2016-09-12 18:44   ` [PATCH 03/47] block-rbd: Adjust the position of a jump label in rbd_header_from_disk() SF Markus Elfring
2016-09-13  8:01     ` Ilya Dryomov
2016-09-13  8:12       ` SF Markus Elfring
2016-09-13  9:16         ` Ilya Dryomov
2016-09-13 14:36           ` Jean Delvare
2016-09-13 15:30             ` Ilya Dryomov
2016-09-13 16:50               ` Jean Delvare
2016-09-13 18:31                 ` Ilya Dryomov
2016-09-19  9:37                   ` Jean Delvare
2016-09-12 18:45   ` [PATCH 04/47] block-rbd: Refactor two calls for memory allocations in rbd_dev_image_id() SF Markus Elfring
2016-09-13  8:03     ` Ilya Dryomov
2016-09-13  8:36       ` SF Markus Elfring
2016-09-12 18:46   ` [PATCH 05/47] block-rbd: One function call less in rbd_dev_image_id() after error detection SF Markus Elfring
2016-09-12 18:46   ` [PATCH 00/47] RADOS Block Device: Fine-tuning for several function implementations Joe Perches
2016-09-12 18:47   ` [PATCH 06/47] block-rbd: Rename jump labels in rbd_add_parse_args() SF Markus Elfring
2016-09-13  8:05     ` Ilya Dryomov
2016-09-12 18:48   ` [PATCH 07/47] block-rbd: Rename a jump label in rbd_dev_v2_snap_name() SF Markus Elfring
2016-09-12 18:49   ` [PATCH 08/47] block-rbd: Rename jump labels in rbd_dev_v2_snap_context() SF Markus Elfring
2016-09-12 18:50   ` [PATCH 09/47] block-rbd: Rename a jump label in rbd_spec_fill_names() SF Markus Elfring
2016-09-12 18:51   ` [PATCH 10/47] block-rbd: One function call less in rbd_dev_image_name() after error detection SF Markus Elfring
2016-09-12 18:54   ` [PATCH 11/47] block-rbd: Delete three unnecessary initialisations in rbd_dev_image_name() SF Markus Elfring
2016-09-12 18:57   ` [PATCH 12/47] block-rbd: One function call less in rbd_dev_v2_parent_info() after error detection SF Markus Elfring
2016-09-12 18:58   ` [PATCH 13/47] block-rbd: Delete an unnecessary initialisation in rbd_dev_v2_parent_info() SF Markus Elfring
2016-09-12 18:59   ` [PATCH 14/47] block-rbd: Rename a jump label in rbd_dev_v2_object_prefix() SF Markus Elfring
2016-09-12 19:00   ` [PATCH 15/47] block-rbd: Rename jump labels in rbd_dev_create() SF Markus Elfring
2016-09-13  8:07     ` Ilya Dryomov
2016-09-12 19:01   ` [PATCH 16/47] block-rbd: Rename jump labels in rbd_dev_v1_header_info() SF Markus Elfring
2016-09-12 19:03   ` [PATCH 17/47] block-rbd: Rename jump labels in rbd_init_disk() SF Markus Elfring
2016-09-12 19:04   ` [PATCH 18/47] block-rbd: Fix jump targets in rbd_queue_workfn() SF Markus Elfring
2016-09-12 19:05   ` [PATCH 19/47] block-rbd: Rename a jump label in rbd_reregister_watch() SF Markus Elfring
2016-09-12 19:06   ` [PATCH 20/47] block-rbd: Rename a jump label in rbd_register_watch() SF Markus Elfring
2016-09-12 19:07   ` [PATCH 21/47] block-rbd: Rename jump labels in rbd_try_lock() SF Markus Elfring
2016-09-12 19:08   ` [PATCH 22/47] block-rbd: Rename a jump label in find_watcher() SF Markus Elfring
2016-09-12 19:09   ` [PATCH 23/47] block-rbd: Rename jump labels in get_lock_owner_info() SF Markus Elfring
2016-09-12 19:10   ` [PATCH 24/47] block-rbd: Rename jump labels in rbd_request_lock() SF Markus Elfring
2016-09-12 19:11   ` [PATCH 25/47] block-rbd: Fix jump targets in rbd_img_parent_read() SF Markus Elfring
2016-09-12 19:12   ` [PATCH 26/47] block-rbd: Rename a jump label in rbd_img_parent_read_callback() SF Markus Elfring
2016-09-12 19:13   ` [PATCH 27/47] block-rbd: Rename a jump label in rbd_img_request_submit() SF Markus Elfring
2016-09-12 19:14   ` [PATCH 28/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_submit() SF Markus Elfring
2016-09-13  8:10     ` Ilya Dryomov
2016-09-12 19:15   ` [PATCH 29/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-12 19:16   ` [PATCH 30/47] block-rbd: Refactor a jump target in rbd_img_obj_exists_callback() SF Markus Elfring
2016-09-12 19:18   ` [PATCH 31/47] block-rbd: Fix three jump targets in rbd_img_obj_parent_read_full() SF Markus Elfring
2016-09-12 19:20   ` [PATCH 32/47] block-rbd: Rename a jump label in rbd_img_obj_parent_read_full_callback() SF Markus Elfring
2016-09-12 19:22   ` [PATCH 33/47] block-rbd: Adjust the position of a jump label in rbd_img_request_fill() SF Markus Elfring
2016-09-12 19:23   ` [PATCH 34/47] block-rbd: Rename a jump label in rbd_img_obj_callback() SF Markus Elfring
2016-09-12 19:24   ` [PATCH 35/47] block-rbd: Rename jump labels in rbd_osd_req_create_copyup() SF Markus Elfring
2016-09-12 19:25   ` [PATCH 36/47] block-rbd: Rename jump labels in rbd_osd_req_create() SF Markus Elfring
2016-09-12 19:26   ` [PATCH 37/47] block-rbd: Rename a jump label in bio_chain_clone_range() SF Markus Elfring
2016-09-12 19:27   ` [PATCH 38/47] block-rbd: Rename jump labels in rbd_client_create() SF Markus Elfring
2016-09-12 19:28   ` [PATCH 39/47] block-rbd: Rename a jump label in rbd_ioctl_set_ro() SF Markus Elfring
2016-09-12 19:29   ` [PATCH 40/47] block-rbd: One function call less in rbd_dev_probe_parent() after error detection SF Markus Elfring
2016-09-12 19:30   ` [PATCH 41/47] block-rbd: Rename jump labels in rbd_dev_device_setup() SF Markus Elfring
2016-09-12 19:31   ` [PATCH 42/47] block-rbd: Rename jump labels in rbd_dev_image_probe() SF Markus Elfring
2016-09-12 19:32   ` [PATCH 43/47] block-rbd: Rename jump labels in do_rbd_add() SF Markus Elfring
2016-09-12 19:33   ` [PATCH 44/47] block-rbd: Delete an unnecessary initialisation " SF Markus Elfring
2016-09-12 19:34   ` [PATCH 45/47] block-rbd: Rename a jump label in rbd_slab_init() SF Markus Elfring
2016-09-12 19:35   ` [PATCH 46/47] block-rbd: Rename jump labels in rbd_init() SF Markus Elfring
2016-09-12 19:36   ` [PATCH 47/47] block-rbd: Delete unwanted spaces behind usages of the sizeof operator SF Markus Elfring
2016-09-13 12:10 ` [PATCH 0/4] block-virtio: Fine-tuning for two function implementations SF Markus Elfring
2016-09-13 12:12   ` [PATCH 1/4] virtio_blk: Use kmalloc_array() in init_vq() SF Markus Elfring
2016-09-13 12:13   ` [PATCH 2/4] virtio_blk: Less function calls in init_vq() after error detection SF Markus Elfring
2016-09-13 12:54     ` Christian Borntraeger
2016-09-13 14:33       ` SF Markus Elfring
2016-09-13 17:30       ` SF Markus Elfring
2016-09-13 18:24         ` Christian Borntraeger
2016-09-14  6:56           ` SF Markus Elfring
2016-09-14  8:10           ` Cornelia Huck
2016-09-14  9:09             ` virtio_blk: Clarification for communication difficulties? SF Markus Elfring
2016-09-13 12:14   ` [PATCH 3/4] virtio_blk: Delete an unnecessary initialisation in init_vq() SF Markus Elfring
2016-09-13 12:15   ` [PATCH 4/4] virtio_blk: Rename a jump label in virtblk_get_id() SF Markus Elfring
2016-09-13 20:38 ` [PATCH 0/7] AGPGART: Fine-tuning for four function implementations SF Markus Elfring
2016-09-13 20:42   ` [PATCH 1/7] AGPGART: Use kmalloc_array() in compat_agpioc_reserve_wrap() SF Markus Elfring
2016-09-13 20:43   ` [PATCH 2/7] AGPGART: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-09-13 20:44   ` [PATCH 3/7] AGPGART: Rename jump labels in compat_agp_ioctl() SF Markus Elfring
2016-09-13 20:46   ` [PATCH 4/7] AGPGART-SGI: Use kmalloc_array() in agp_sgi_init() SF Markus Elfring
2016-09-13 20:47   ` [PATCH 5/7] AGPGART-UniNorth: Use kmalloc_array() in uninorth_create_gatt_table() SF Markus Elfring
2016-09-13 20:48   ` [PATCH 6/7] AGPGART-UniNorth: Rename a jump label " SF Markus Elfring
2016-09-15 17:37     ` kbuild test robot
2016-09-15 18:26       ` SF Markus Elfring
2016-09-13 20:50   ` [PATCH 7/7] AGPGART-UniNorth: Delete an unnecessary check " SF Markus Elfring
2016-09-14 13:56 ` [PATCH 00/11] virtio-console: Fine-tuning for 14 function implementations SF Markus Elfring
2016-09-14 14:00   ` [PATCH 01/11] virtio_console: Use kmalloc_array() in init_vqs() SF Markus Elfring
2016-09-14 14:01   ` [PATCH 02/11] virtio_console: Less function calls in init_vqs() after error detection SF Markus Elfring
2016-09-21 12:10     ` Amit Shah
2016-09-21 13:06       ` SF Markus Elfring
2016-09-14 14:02   ` [PATCH 03/11] virtio_console: Rename a jump label in init() SF Markus Elfring
2016-09-14 14:03   ` [PATCH 04/11] virtio_console: Rename jump labels in virtcons_probe() SF Markus Elfring
2016-09-14 14:04   ` [PATCH 05/11] virtio_console: Rename jump labels in add_port() SF Markus Elfring
2016-09-14 14:05   ` [PATCH 06/11] virtio_console: Rename a jump label in port_fops_open() SF Markus Elfring
2016-09-14 14:06   ` [PATCH 07/11] virtio_console: Rename a jump label in port_fops_splice_write() SF Markus Elfring
2016-09-14 14:07   ` [PATCH 08/11] virtio_console: Rename jump labels in port_fops_write() SF Markus Elfring
2016-09-14 14:08   ` [PATCH 09/11] virtio_console: Rename a jump label in __send_to_port() SF Markus Elfring
2016-09-14 14:09   ` [PATCH 10/11] virtio_console: Rename jump labels in alloc_buf() SF Markus Elfring
2016-09-14 14:10   ` [PATCH 11/11] virtio_console: Rename a jump label in five functions SF Markus Elfring
2016-09-14 19:56 ` [PATCH 0/4] clk/Renesas-MSTP: Fine-tuning for two function implementations SF Markus Elfring
2016-09-14 20:00   ` [PATCH 1/4] clk/Renesas-MSTP: Use kmalloc_array() in cpg_mstp_clocks_init() SF Markus Elfring
2016-09-15 19:11     ` Geert Uytterhoeven
2016-09-16 23:13     ` Stephen Boyd
2016-09-14 20:01   ` [PATCH 2/4] clk/Renesas-MSTP: Delete an error message for a failed memory allocation SF Markus Elfring
2016-09-15 19:07     ` Geert Uytterhoeven
2016-09-15 19:13       ` Laurent Pinchart
2016-09-15 19:41         ` Wolfram Sang
2016-09-15 20:17         ` SF Markus Elfring
2016-09-15 22:55           ` Laurent Pinchart
2016-09-16  5:21             ` SF Markus Elfring
2016-09-14 20:03   ` [PATCH 3/4] clk/Renesas-MSTP: Less function calls in cpg_mstp_clocks_init() after error detection SF Markus Elfring
2016-09-15 19:11     ` Geert Uytterhoeven
2016-09-15 20:40       ` SF Markus Elfring
2016-09-15 20:48         ` Geert Uytterhoeven
2016-09-16  5:32           ` SF Markus Elfring
2016-09-14 20:04   ` [PATCH 4/4] clk/Renesas-MSTP: Rename jump labels in cpg_mstp_attach_dev() SF Markus Elfring
2016-09-15 19:18     ` Geert Uytterhoeven
2016-09-16  6:00       ` SF Markus Elfring
2016-09-15 14:36 ` crypto-caamhash: Fine-tuning for several function implementations SF Markus Elfring
2016-09-15 14:40   ` [PATCH 1/6] crypto-caamhash: Use kmalloc_array() in ahash_setkey() SF Markus Elfring
2016-09-15 15:12     ` Horia Geanta Neag
2016-09-15 14:41   ` [PATCH 2/6] crypto-caamhash: Rename jump labels " SF Markus Elfring
2016-09-15 14:42   ` [PATCH 3/6] crypto-caamhash: Rename a jump label in five functions SF Markus Elfring
2016-09-15 14:43   ` [PATCH 4/6] crypto-caamhash: Return a value directly in caam_hash_cra_init() SF Markus Elfring
2016-09-15 14:44   ` [PATCH 5/6] crypto-caamhash: Delete an unnecessary initialisation in seven functions SF Markus Elfring
2016-09-15 14:45   ` [PATCH 6/6] crypto-caamhash: Move common error handling code in two functions SF Markus Elfring
2016-09-15 15:30   ` crypto-caamhash: Fine-tuning for several function implementations Horia Geanta Neag
2016-09-22 10:44   ` Herbert Xu
2016-09-17 15:05 ` [PATCH 00/24] ste_dma40: " SF Markus Elfring
2016-09-17 15:07   ` [PATCH 01/24] ste_dma40: Use kmalloc_array() in d40_lcla_allocate() SF Markus Elfring
2016-09-17 15:08   ` [PATCH 02/24] ste_dma40: Return directly after a failed kmalloc_array() SF Markus Elfring
2016-09-17 15:09   ` [PATCH 03/24] ste_dma40: Rename a jump label in d40_lcla_allocate() SF Markus Elfring
2016-09-17 15:10   ` [PATCH 04/24] ste_dma40: Move an assignment " SF Markus Elfring
2016-09-17 15:11   ` [PATCH 05/24] ste_dma40: Improve a size determination in d40_of_probe() SF Markus Elfring
2016-09-17 15:12   ` [PATCH 06/24] ste_dma40: Replace four kzalloc() calls by kcalloc() in d40_hw_detect_init() SF Markus Elfring
2016-09-17 15:15   ` [PATCH 07/24] ste_dma40: Use kmalloc_array() " SF Markus Elfring
2016-09-17 15:16   ` [PATCH 08/24] ste_dma40: Less checks in d40_hw_detect_init() after error detection SF Markus Elfring
2016-09-17 15:17   ` [PATCH 09/24] ste_dma40: Delete unnecessary variable initialisations in d40_hw_detect_init() SF Markus Elfring
2016-09-17 15:18   ` [PATCH 10/24] ste_dma40: Adjust the position of a jump label in d40_probe() SF Markus Elfring
2016-09-17 15:19   ` [PATCH 11/24] ste_dma40: Rename " SF Markus Elfring
2016-09-17 15:20   ` [PATCH 12/24] ste_dma40: Rename jump labels in d40_dmaengine_init() SF Markus Elfring
2016-09-17 15:22   ` [PATCH 13/24] ste_dma40: Rename a jump label in d40_alloc_chan_resources() SF Markus Elfring
2016-09-17 15:23   ` [PATCH 14/24] ste_dma40: One check less in d40_prep_sg() after error detection SF Markus Elfring
2016-09-17 15:25   ` [PATCH 15/24] ste_dma40: Move two assignments in d40_prep_sg() SF Markus Elfring
2016-09-17 15:26   ` [PATCH 16/24] ste_dma40: Rename a jump label in d40_prep_desc() SF Markus Elfring
2016-09-17 15:27   ` [PATCH 17/24] ste_dma40: Move an assignment " SF Markus Elfring
2016-09-17 15:30   ` [PATCH 18/24] ste_dma40: Rename a jump label in d40_is_paused() SF Markus Elfring
2016-09-17 15:31   ` [PATCH 19/24] ste_dma40: Rename a jump label in d40_free_dma() SF Markus Elfring
2016-09-17 15:32   ` [PATCH 20/24] ste_dma40: Rename a jump label in d40_alloc_mask_free() SF Markus Elfring
2016-09-17 15:33   ` [PATCH 21/24] ste_dma40: Rename jump labels in d40_alloc_mask_set() SF Markus Elfring
2016-09-17 15:34   ` [PATCH 22/24] ste_dma40: Rename a jump label in dma_tasklet() SF Markus Elfring
2016-09-17 15:35   ` [PATCH 23/24] ste_dma40: Rename a jump label in __d40_execute_command_phy() SF Markus Elfring
2016-09-17 15:36   ` [PATCH 24/24] ste_dma40: Rename a jump label in d40_log_lli_to_lcxa() SF Markus Elfring
2016-09-23  9:41   ` [PATCH 00/24] ste_dma40: Fine-tuning for several function implementations Linus Walleij
2016-09-18  6:08 ` [PATCH 00/10] firewire-net: " SF Markus Elfring
2016-09-18  6:10   ` [PATCH 01/] firewire-net: Use kmalloc_array() in fwnet_broadcast_start() SF Markus Elfring
2016-09-24 11:41     ` Stefan Richter
2016-09-24 15:29       ` [PATCH 01/10] " SF Markus Elfring
2016-09-18  6:12   ` [PATCH 02/10] firewire-net: Rename a jump label " SF Markus Elfring
2016-09-24 12:58     ` Stefan Richter
2016-09-18  6:14   ` [PATCH 03/10] firewire-net: Rename jump labels in fwnet_init() SF Markus Elfring
2016-09-18  6:15   ` [PATCH 04/10] firewire-net: Rename jump labels in fwnet_probe() SF Markus Elfring
2016-09-18  6:16   ` [PATCH 05/10] firewire-net: Rename a jump label in fwnet_tx() SF Markus Elfring
2016-09-18  6:17   ` [PATCH 06/10] firewire-net: Rename a jump label in fwnet_send_packet() SF Markus Elfring
2016-09-18  6:18   ` [PATCH 07/10] firewire-net: Rename a jump label in fwnet_incoming_packet() SF Markus Elfring
2016-09-18  6:19   ` [PATCH 08/10] firewire-net: Rename a jump label in fwnet_finish_incoming_packet() SF Markus Elfring
2016-09-18  6:21   ` [PATCH 09/10] firewire-net: Rename jump labels in fwnet_pd_new() SF Markus Elfring
2016-09-18  6:22   ` [PATCH 10/10] firewire-net: Adjust checks for null pointers in five functions SF Markus Elfring
2016-09-24 12:06     ` Stefan Richter
2016-09-18 12:48 ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations SF Markus Elfring
2016-09-18 12:50   ` [PATCH 1/6] firmware-qemu_fw_cfg: Use kmalloc_array() in fw_cfg_register_dir_entries() SF Markus Elfring
2016-09-18 12:52   ` [PATCH 2/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_register_file() SF Markus Elfring
2016-09-18 12:53   ` [PATCH 3/6] firmware-qemu_fw_cfg: Rename jump labels " SF Markus Elfring
2016-09-18 12:55   ` [PATCH 4/6] firmware-qemu_fw_cfg: Improve a size determination in fw_cfg_build_symlink() SF Markus Elfring
2016-09-18 12:56   ` [PATCH 5/6] firmware-qemu_fw_cfg: Rename jump labels in fw_cfg_sysfs_probe() SF Markus Elfring
2016-09-18 12:58   ` [PATCH 6/6] firmware-qemu_fw_cfg: Move a variable assignment " SF Markus Elfring
2016-09-20 11:09   ` [PATCH 0/6] firmware-qemu_fw_cfg: Fine-tuning for four function implementations Gabriel L. Somlo
2016-09-18 16:48 ` [PATCH 0/5] drm/amdgpu: Fine-tuning for several " SF Markus Elfring
2016-09-18 16:50   ` [PATCH 1/5] drm/amdgpu: Use kmalloc_array() in amdgpu_debugfs_gca_config_read() SF Markus Elfring
2016-09-19 17:25     ` Alex Deucher
2016-09-18 16:51   ` [PATCH 2/5] drm/amdgpu: Improve determination of sizes in two functions SF Markus Elfring
2016-09-18 16:52   ` [PATCH 3/5] drm/amdgpu: Rename a jump label in amdgpu_debugfs_regs_read() SF Markus Elfring
2016-09-18 16:53   ` [PATCH 4/5] drm/amdgpu: Rename a jump label in amdgpu_device_init() SF Markus Elfring
2016-09-19 13:56     ` Deucher, Alexander
2016-09-18 16:54   ` [PATCH 5/5] drm/amdgpu: Adjust checks for null pointers in nine functions SF Markus Elfring
2016-09-19 15:51 ` [PATCH 0/5] GPU-DRM: Fine-tuning for four function implementations SF Markus Elfring
2016-09-19 15:53   ` [PATCH 1/5] GPU-DRM: Use kmalloc_array() in drm_legacy_addbufs_pci() SF Markus Elfring
2016-09-19 15:54   ` [PATCH 2/5] GPU-DRM: Replace two kzalloc() calls by kcalloc() " SF Markus Elfring
2016-09-19 15:55   ` [PATCH 3/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_agp() SF Markus Elfring
2016-09-19 15:56   ` [PATCH 4/5] GPU-DRM: Replace a kzalloc() call by kcalloc() in drm_legacy_addbufs_sg() SF Markus Elfring
2016-09-21 11:22     ` Daniel Vetter
2016-09-19 15:58   ` [PATCH 5/5] GPU-DRM: Rename a jump label in drm_legacy_mapbufs() SF Markus Elfring
2016-09-20  8:54 ` [PATCH 0/6] GPU-DRM-GMA500: Fine-tuning for two function implementations SF Markus Elfring
2016-09-20  8:55   ` [PATCH 1/6] GPU-DRM-GMA500: Use kmalloc_array() in mid_get_vbt_data_r10() SF Markus Elfring
2016-09-20 10:06     ` Jani Nikula
2016-09-20 10:30       ` SF Markus Elfring
2016-09-20  8:57   ` [PATCH 2/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
2016-09-20 10:05     ` Jani Nikula
2016-09-20  8:58   ` [PATCH 3/6] GPU-DRM-GMA500: Move a variable assignment " SF Markus Elfring
2016-09-20  8:59   ` [PATCH 4/6] GPU-DRM-GMA500: Fix indentation for a function call parameter " SF Markus Elfring
2016-09-20  9:00   ` [PATCH 5/6] GPU-DRM-GMA500: One error message less for a GCT revision mismatch in mid_get_vbt_data() SF Markus Elfring
2016-09-20 10:07     ` Jani Nikula
2016-09-20 10:32       ` SF Markus Elfring
2016-09-20 10:48       ` [PATCH 5/6] " Dan Carpenter
2016-09-20 11:03         ` SF Markus Elfring
2016-09-20 11:17           ` Dan Carpenter
2016-09-20 11:30             ` SF Markus Elfring
2016-09-20 12:08         ` [PATCH 5/6] " Jani Nikula
2016-09-20 20:23           ` Patrik Jakobsson
2016-09-20  9:01   ` [PATCH 6/6] GPU-DRM-GMA500: Rename a jump label " SF Markus Elfring
2016-09-20 10:08     ` Jani Nikula
2016-09-20 12:40       ` Dan Carpenter
2016-09-21 16:35 ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations SF Markus Elfring
2016-09-21 16:38   ` [PATCH 01/14] GPU-DRM-OMAP: Use kmalloc_array() in tiler_map_show() SF Markus Elfring
2016-09-21 16:39   ` [PATCH 02/14] GPU-DRM-OMAP: Replace another kmalloc() call by " SF Markus Elfring
2016-09-21 16:40   ` [PATCH 03/14] GPU-DRM-OMAP: Less function calls in tiler_map_show() after error detection SF Markus Elfring
2016-09-21 16:41   ` [PATCH 04/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation in tiler_map_show() Markus Elfring
2016-09-21 16:45   ` SF Markus Elfring
2016-09-21 16:46   ` [PATCH 05/14] GPU-DRM-OMAP: Improve a size determination in dmm_txn_append() SF Markus Elfring
2016-09-21 16:47   ` [PATCH 06/14] GPU-DRM-OMAP: Improve a size determination in omap_dmm_probe() SF Markus Elfring
2016-09-21 16:48   ` [PATCH 07/14] GPU-DRM-OMAP: Rename a jump label " SF Markus Elfring
2016-09-21 16:49   ` [PATCH 08/14] GPU-DRM-OMAP: Rename a jump label in dmm_txn_commit() SF Markus Elfring
2016-09-21 16:50   ` [PATCH 09/14] GPU-DRM-OMAP: Delete an unnecessary variable initialisation " SF Markus Elfring
2016-09-21 16:52   ` [PATCH 10/14] GPU-DRM-OMAP: Use kmalloc_array() in omap_gem_attach_pages() SF Markus Elfring
2016-09-21 16:53   ` [PATCH 11/14] GPU-DRM-OMAP: Replace a kzalloc() call by kcalloc() " SF Markus Elfring
2016-09-21 16:54   ` [PATCH 12/14] GPU-DRM-OMAP: Move a variable assignment " SF Markus Elfring
2016-09-21 16:55   ` [PATCH 13/14] GPU-DRM-OMAP: Rename a jump label in omap_gem_new_dmabuf() SF Markus Elfring
2016-09-21 16:56   ` [PATCH 14/14] GPU-DRM-OMAP: Rename a jump label in four functions SF Markus Elfring
2016-09-22  6:45   ` [PATCH 00/14] GPU-DRM-OMAP: Fine-tuning for several function implementations Daniel Vetter
2016-09-22  6:54     ` Laurent Pinchart
2016-09-22  9:11       ` SF Markus Elfring
2016-09-22  8:30 ` [PATCH 0/4] GPU-DRM-TILCDC: Fine-tuning for two " SF Markus Elfring
2016-09-22  8:31   ` [PATCH 1/4] GPU-DRM-TILCDC: Use kmalloc_array() in kfree_table_init() SF Markus Elfring
2016-09-22 16:55     ` Jyri Sarha
2016-09-22  8:32   ` [PATCH 2/4] GPU-DRM-TILCDC: Return directly after a failed kfree_table_init() in tilcdc_convert_slave_node() SF Markus Elfring
2016-09-22 10:58     ` Dan Carpenter
2016-09-22 16:57     ` Jyri Sarha
2016-09-22 18:17       ` SF Markus Elfring
2016-09-22  8:33   ` [PATCH 3/4] GPU-DRM-TILCDC: Less function calls in tilcdc_convert_slave_node() after error detection SF Markus Elfring
2016-09-22 17:04     ` Jyri Sarha
2016-09-22 18:38       ` SF Markus Elfring
2016-09-22 20:22         ` Jyri Sarha
2016-09-23  7:36           ` SF Markus Elfring
2016-09-23 10:37             ` Jyri Sarha
2016-09-23 10:55               ` SF Markus Elfring
2016-09-23 10:58         ` Rob Clark
2016-09-23 11:19           ` SF Markus Elfring
2016-09-23 11:31             ` Rob Clark
2016-09-23 12:17               ` SF Markus Elfring
2016-09-23 13:04                 ` Rob Clark
2016-09-22  8:34   ` [PATCH 4/4] GPU-DRM-TILCDC: Delete unnecessary variable initialisations in tilcdc_convert_slave_node() SF Markus Elfring
2016-09-22 17:32 ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations SF Markus Elfring
2016-09-22 17:33   ` [PATCH 01/14] GPU-DRM-TTM: Use kmalloc_array() in two functions SF Markus Elfring
2016-09-22 17:34   ` [PATCH 02/14] GPU-DRM-TTM: Rename a jump label in ttm_alloc_new_pages() SF Markus Elfring
2016-09-22 17:35   ` [PATCH 03/14] GPU-DRM-TTM: Rename jump labels in ttm_page_pool_free() SF Markus Elfring
2016-09-22 17:36   ` [PATCH 04/14] GPU-DRM-TTM: Rename a jump label in ttm_page_pool_get_pages() SF Markus Elfring
2016-09-22 17:37   ` [PATCH 05/14] GPU-DRM-TTM: Use kmalloc_array() in two more functions SF Markus Elfring
2016-09-22 17:38   ` [PATCH 06/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_alloc_new_pages() SF Markus Elfring
2016-09-22 17:39   ` [PATCH 07/14] GPU-DRM-TTM: Rename jump labels in ttm_dma_page_pool_free() SF Markus Elfring
2016-09-22 17:40   ` [PATCH 08/14] GPU-DRM-TTM: Rename a jump label in ttm_dma_pool_shrink_scan() SF Markus Elfring
2016-09-22 17:41   ` [PATCH 09/14] GPU-DRM-TTM: Return directly after a failed kzalloc() in ttm_dma_page_alloc_init() SF Markus Elfring
2016-09-22 17:42   ` [PATCH 10/14] GPU-DRM-TTM: Return directly after a failed kobject_init_and_add() " SF Markus Elfring
2016-09-22 17:43   ` [PATCH 11/14] GPU-DRM-TTM: Return an error code only as a constant in ttm_dma_pool_init() SF Markus Elfring
2016-09-22 17:44   ` [PATCH 12/14] GPU-DRM-TTM: Less function calls in ttm_dma_pool_init() after error detection SF Markus Elfring
2016-09-22 17:45   ` [PATCH 13/14] GPU-DRM-TTM: Delete unnecessary variable initialisations in ttm_dma_pool_init() SF Markus Elfring
2016-09-22 17:46   ` [PATCH 14/14] GPU-DRM-TTM: Mark an array of text strings as "const" " SF Markus Elfring
2016-09-22 18:49     ` Joe Perches
2016-09-23  9:44   ` [PATCH 00/14] GPU-DRM-TTM: Fine-tuning for several function implementations Christian König
2016-09-23 10:20     ` SF Markus Elfring
2016-09-23 10:38       ` Christian König
2016-09-23 11:07         ` SF Markus Elfring
2016-09-23 11:17           ` Christian König
2016-09-23 11:49             ` SF Markus Elfring
2016-09-23 13:06               ` Christian König
2016-09-23 12:55       ` Dan Carpenter
2016-09-23 13:46         ` SF Markus Elfring
2016-09-23 19:42 ` [PATCH 0/4] i2c-dev: Fine-tuning for four " SF Markus Elfring
2016-09-23 19:44   ` [PATCH 1/4] i2c-dev: Use kmalloc_array() in i2cdev_ioctl_rdwr() SF Markus Elfring
2016-09-23 19:45   ` [PATCH 2/4] i2c-dev: Improve another size determination " SF Markus Elfring
2016-09-23 19:46   ` [PATCH 3/4] i2c-dev: Rename jump labels in i2cdev_attach_adapter() SF Markus Elfring
2016-09-23 19:47   ` [PATCH 4/4] i2c-dev: Adjust checks for null pointers in three functions SF Markus Elfring
2016-09-24  6:22 ` [PATCH 0/7] iio: Fine-tuning for several function implementations SF Markus Elfring
2016-09-24  6:24   ` [PATCH 1/7] iio: Use kmalloc_array() in iio_scan_mask_set() SF Markus Elfring
2016-09-24 15:36     ` Jonathan Cameron
2016-09-24 16:18       ` SF Markus Elfring
2016-09-24 16:36         ` Jonathan Cameron
2016-09-24  6:25   ` [PATCH 2/7] iio: Rename a jump label in iio_buffer_store_watermark() SF Markus Elfring
2016-09-24 15:32     ` Jonathan Cameron
2016-09-24 19:21       ` SF Markus Elfring
2016-09-24  6:26   ` [PATCH 3/7] iio: Rename a jump label in iio_buffer_store_enable() SF Markus Elfring
2016-09-24  6:28   ` [PATCH 4/7] iio: Rename a jump label in iio_buffer_write_length() SF Markus Elfring
2016-09-24  6:29   ` [PATCH 5/7] iio: Rename a jump label in iio_scan_el_ts_store() SF Markus Elfring
2016-09-24  6:30   ` [PATCH 6/7] iio: Rename a jump label in iio_scan_el_store() SF Markus Elfring
2016-09-24  6:31   ` [PATCH 7/7] iio: Adjust checks for null pointers in six functions SF Markus Elfring
2016-09-24 11:07 ` [PATCH 0/2] Input-evdev: Fine-tuning for three function implementations SF Markus Elfring
2016-09-24 11:08   ` [PATCH 1/2] Input-evdev: Use kmalloc_array() in evdev_handle_get_val() SF Markus Elfring
2016-09-24 17:54     ` Dmitry Torokhov
2016-09-24 18:16       ` SF Markus Elfring
2016-09-24 18:34         ` Dmitry Torokhov
2016-09-24 19:04           ` SF Markus Elfring
2016-09-24 11:10   ` [PATCH 2/2] Input-evdev: Rename a jump label in two functions SF Markus Elfring
2016-09-24 17:47     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).