All of lore.kernel.org
 help / color / mirror / Atom feed
* Source code review around jump label usage
@ 2015-12-11 12:08 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Source code review around jump label usage
@ 2015-12-11 12:08 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-11 12:14   ` Julia Lawall
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Source code review around jump label usage
@ 2015-12-11 12:14   ` Julia Lawall
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-11 12:48   ` Dan Carpenter
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Source code review around jump label usage
@ 2015-12-11 12:48   ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Source code review around jump label usage
  2015-12-11 12:08 ` SF Markus Elfring
                   ` (2 preceding siblings ...)
  (?)
@ 2015-12-11 18:00 ` Christophe JAILLET
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/2] block: Fine-tuning for two function implementations
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-11 18:19   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/2] block: Fine-tuning for two function implementations
@ 2015-12-11 18:19   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-11 18:19   ` SF Markus Elfring
@ 2015-12-11 18:24     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
@ 2015-12-11 18:24     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/2] z2ram: Delete a jump label in z2_init()
  2015-12-11 18:19   ` SF Markus Elfring
@ 2015-12-11 18:26     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/2] z2ram: Delete a jump label in z2_init()
@ 2015-12-11 18:26     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-12  9:16   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
@ 2015-12-12  9:16   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-12 14:30   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/7] iSCSI-target: Fine-tuning for three function implementations
@ 2015-12-12 14:30   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 14:30   ` SF Markus Elfring
@ 2015-12-12 14:34     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
@ 2015-12-12 14:34     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection
  2015-12-12 14:30   ` SF Markus Elfring
@ 2015-12-12 14:37     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/7] iscsi-target: Less checks in iscsi_set_default_param() after error detection
@ 2015-12-12 14:37     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_params()
  2015-12-12 14:30   ` SF Markus Elfring
@ 2015-12-12 14:40     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/7] iscsi-target: Delete an unnecessary variable initialisation in iscsi_create_default_para
@ 2015-12-12 14:40     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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   ` SF Markus Elfring
@ 2015-12-12 14:41     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_default_
@ 2015-12-12 14:41     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/7] iscsi-target: Rename a jump label in iscsi_create_default_params()
  2015-12-12 14:30   ` SF Markus Elfring
@ 2015-12-12 14:42     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/7] iscsi-target: Rename a jump label in iscsi_create_default_params()
@ 2015-12-12 14:42     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_support()
  2015-12-12 14:30   ` SF Markus Elfring
@ 2015-12-12 14:43     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 6/7] iscsi-target: Delete unnecessary variable initialisations in iscsi_check_valuelist_for_s
@ 2015-12-12 14:43     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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   ` SF Markus Elfring
@ 2015-12-12 14:45     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious in iscsi_check_valuel
@ 2015-12-12 14:45     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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 in iscsi_create_default_ SF Markus Elfring
@ 2015-12-12 14:45       ` Julia Lawall
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_defa
@ 2015-12-12 14:45       ` Julia Lawall
  0 siblings, 0 replies; 3085+ 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] 3085+ 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       ` [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_defa Julia Lawall
@ 2015-12-12 15:02         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 4/7] iscsi-target: Make a variable initialisation a bit more obvious in iscsi_create_defa
@ 2015-12-12 15:02         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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 in iscsi_check_valuel SF Markus Elfring
@ 2015-12-12 17:17       ` walter harms
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 7/7] iscsi-target: Make two variable initialisations a bit more obvious in iscsi_check_va
@ 2015-12-12 17:17       ` walter harms
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
  2015-12-12 14:34     ` SF Markus Elfring
@ 2015-12-12 19:49       ` Dan Carpenter
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
@ 2015-12-12 21:22         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
  2015-12-12  9:16   ` SF Markus Elfring
@ 2015-12-12 22:23     ` Dmitry Torokhov
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH] uinput: Rename a jump label in uinput_ioctl_handler()
@ 2015-12-12 22:23     ` Dmitry Torokhov
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations
  2015-12-11 12:08 ` SF Markus Elfring
  (?)
@ 2015-12-13 13:48   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations
@ 2015-12-13 13:48   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 0/7] staging-Lustre: Fine-tuning for some function implementations
@ 2015-12-13 13:48   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:48 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ messages in thread

* [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:52     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-13 13:52     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-13 13:52     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:52 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:54     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-13 13:54     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-13 13:54     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:54 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:55     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call
@ 2015-12-13 13:55     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 3/7] staging: lustre: Rename a jump label for a kfree(key) call
@ 2015-12-13 13:55     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:55 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:56     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_lo
@ 2015-12-13 13:56     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 4/7] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
@ 2015-12-13 13:56     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:56 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:57     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-13 13:57     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-13 13:57     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:57 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ 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   ` SF Markus Elfring
  (?)
@ 2015-12-13 13:58     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection
@ 2015-12-13 13:58     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 6/7] staging: lustre: A few checks less in mgc_process_recover_log() after error detection
@ 2015-12-13 13:58     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 13:58 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls
  2015-12-13 13:48   ` SF Markus Elfring
  (?)
@ 2015-12-13 14:00     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls
@ 2015-12-13 14:00     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [lustre-devel] [PATCH 7/7] staging: lustre: Rename a jump label for module_put() calls
@ 2015-12-13 14:00     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-13 14:00 UTC (permalink / raw)
  To: lustre-devel

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	[flat|nested] 3085+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
  2015-12-11 18:24     ` SF Markus Elfring
@ 2015-12-14  0:27       ` Sergey Senozhatsky
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
@ 2015-12-14  0:27       ` Sergey Senozhatsky
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/2] z2ram: Delete a jump label in z2_init()
  2015-12-11 18:26     ` SF Markus Elfring
@ 2015-12-14  0:36       ` Sergey Senozhatsky
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/2] z2ram: Delete a jump label in z2_init()
@ 2015-12-14  0:36       ` Sergey Senozhatsky
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
  2015-12-13 13:54     ` SF Markus Elfring
  (?)
@ 2015-12-14  6:53       ` Dan Carpenter
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14  6:53       ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-14  6:53 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
@ 2015-12-14  7:17           ` Julia Lawall
  0 siblings, 0 replies; 3085+ 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] 3085+ 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-14  8:41         ` Johannes Thumshirn
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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
--
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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14  9:08         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-14  9:08 UTC (permalink / raw)
  To: 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.
? Avoid using GW-BASIC names ?
?"

Regards,
Markus

^ permalink raw reply	[flat|nested] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/2] z2ram: Delete a jump label in z2_init()
@ 2015-12-14  9:10         ` Geert Uytterhoeven
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14  9:31           ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 2/7] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14  9:31           ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-14  9:31 UTC (permalink / raw)
  To: 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] 3085+ 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 10:03           ` Sergey Senozhatsky
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
@ 2015-12-14 10:03           ` Sergey Senozhatsky
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14 10:03             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Rename a jump label for ptlrpc_req_finished() calls
@ 2015-12-14 10:03             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-14 10:03 UTC (permalink / raw)
  To: 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] 3085+ messages in thread

* Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-13 13:57     ` SF Markus Elfring
  (?)
@ 2015-12-14 11:00       ` Dan Carpenter
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 11:00       ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-14 11:00 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] iscsi-target: Use a variable initialisation in iscsi_set_default_param() directly
@ 2015-12-14 11:38           ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 12:04         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-14 12:04 UTC (permalink / raw)
  To: lustre-devel

>> 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 12:38           ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 5/7] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 12:38           ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-14 12:38 UTC (permalink / raw)
  To: 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 12:45             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 12:45             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-14 12:45 UTC (permalink / raw)
  To: 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 13:57               ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 13:57               ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-14 13:57 UTC (permalink / raw)
  To: 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/2] zram: Less checks in zram_bvec_write() after error detection
@ 2015-12-14 14:03             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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
--
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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 17:43                 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-14 17:43                 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-14 17:43 UTC (permalink / raw)
  To: 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] 3085+ messages in thread

* [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-14 22:10   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
@ 2015-12-14 22:10   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
  2015-12-14 22:10   ` SF Markus Elfring
@ 2015-12-14 22:20     ` Scott Wood
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [POWERPC] bootwrapper: One check less in fsl_get_immr() after error detection
@ 2015-12-14 22:20     ` Scott Wood
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-15 11:42                   ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-15 11:42                   ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-15 11:42 UTC (permalink / raw)
  To: 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-13 13:52     ` SF Markus Elfring
  (?)
@ 2015-12-15 14:27       ` Joe Perches
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 14:27       ` Joe Perches
  0 siblings, 0 replies; 3085+ 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.,,
--
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] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 14:27       ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 14:27 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 14:41         ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 14:41         ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-15 14:41 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-15 15:00                     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-15 15:00                     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-15 15:00 UTC (permalink / raw)
  To: 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 15:02           ` Joe Perches
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 15:02           ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 15:02 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 17:48             ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 17:48             ` Dan Carpenter
  0 siblings, 0 replies; 3085+ messages in thread
From: Dan Carpenter @ 2015-12-15 17:48 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-15 15:02           ` Joe Perches
  (?)
@ 2015-12-15 18:02             ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:02             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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
--
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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:02             ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:02 UTC (permalink / raw)
  To: lustre-devel

> 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:10               ` Joe Perches
  0 siblings, 0 replies; 3085+ 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
--
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] 3085+ messages in thread

* [lustre-devel] [PATCH 1/7] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:10               ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 18:10 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:22               ` Joe Perches
  0 siblings, 0 replies; 3085+ 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.
--
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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:22               ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 18:22 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:26                 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:26                 ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:26 UTC (permalink / raw)
  To: lustre-devel


> 	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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:34                   ` Joe Perches
  0 siblings, 0 replies; 3085+ 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.

--
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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:34                   ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 18:34 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:49                     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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
--
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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:49                     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-15 18:49 UTC (permalink / raw)
  To: lustre-devel

> 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:55                       ` Joe Perches
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [lustre-devel] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-15 18:55                       ` Joe Perches
  0 siblings, 0 replies; 3085+ messages in thread
From: Joe Perches @ 2015-12-15 18:55 UTC (permalink / raw)
  To: lustre-devel

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] 3085+ messages in thread

* [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations
  2015-12-13 13:48   ` SF Markus Elfring
@ 2015-12-21 19:05     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH v2 0/4] staging-Lustre: Fine-tuning for some function implementations
@ 2015-12-21 19:05     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions
  2015-12-21 19:05     ` SF Markus Elfring
@ 2015-12-21 19:09       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 1/4] staging: lustre: Delete unnecessary goto statements in six functions
@ 2015-12-21 19:09       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover_log()
  2015-12-21 19:05     ` SF Markus Elfring
@ 2015-12-21 19:10       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 2/4] staging: lustre: Delete an unnecessary variable initialisation in mgc_process_recover
@ 2015-12-21 19:10       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
  2015-12-21 19:05     ` SF Markus Elfring
@ 2015-12-21 19:12       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-21 19:12       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info()
  2015-12-21 19:05     ` SF Markus Elfring
@ 2015-12-21 19:13       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 4/4] staging: lustre: Fix a jump label position in osc_get_info()
@ 2015-12-21 19:13       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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       ` SF Markus Elfring
@ 2015-12-21 23:48         ` Greg Kroah-Hartman
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-22  7:15           ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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  8:00           ` Dan Carpenter
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH v2 3/4] staging: lustre: Less checks in mgc_process_recover_log() after error detection
@ 2015-12-22  8:00           ` Dan Carpenter
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-23  9:43   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
@ 2015-12-23  9:43   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-23  9:43   ` SF Markus Elfring
@ 2015-12-23 10:41     ` Julia Lawall
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
@ 2015-12-23 10:41     ` Julia Lawall
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/5] block-LDM: Improvements for exception handling
@ 2015-12-23 18:02       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
  2015-12-23 18:02       ` SF Markus Elfring
@ 2015-12-23 18:06         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/5] block-LDM: One function call less in ldm_validate_tocblocks() after error detection
@ 2015-12-23 18:06         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures
  2015-12-23 18:02       ` SF Markus Elfring
@ 2015-12-23 18:09         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/5] block-LDM: Delete extra log messages for memory allocation failures
@ 2015-12-23 18:09         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection
  2015-12-23 18:02       ` SF Markus Elfring
@ 2015-12-23 18:10         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/5] block-LDM: One function call less in ldm_partition() after error detection
@ 2015-12-23 18:10         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() after error detection
  2015-12-23 18:02       ` SF Markus Elfring
@ 2015-12-23 18:12         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 4/5] block-LDM: Less function calls in ldm_validate_privheads() after error detection
@ 2015-12-23 18:12         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting
  2015-12-23 18:02       ` SF Markus Elfring
@ 2015-12-23 18:13         ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/5] block-LDM: Fine-tuning for the source code formatting
@ 2015-12-23 18:13         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-24 12:31   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/3] Documentation-getdelays: Fine-tuning for two functions
@ 2015-12-24 12:31   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
  2015-12-24 12:31   ` SF Markus Elfring
@ 2015-12-24 12:34     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
@ 2015-12-24 12:34     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
  2015-12-24 12:31   ` SF Markus Elfring
@ 2015-12-24 12:36     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
@ 2015-12-24 12:36     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
  2015-12-24 12:31   ` SF Markus Elfring
@ 2015-12-24 12:38     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
@ 2015-12-24 12:38     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
  2015-12-24 12:34     ` SF Markus Elfring
@ 2015-12-24 14:22       ` Jonathan Corbet
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/3] Documentation-getdelays: Fix a check for container file usage in main()
@ 2015-12-24 14:22       ` Jonathan Corbet
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
  2015-12-24 12:36     ` SF Markus Elfring
@ 2015-12-24 14:22       ` Jonathan Corbet
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 2/3] Documentation-getdelays: Apply a recommendation from "checkpatch.pl" in main()
@ 2015-12-24 14:22       ` Jonathan Corbet
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
  2015-12-24 12:38     ` SF Markus Elfring
@ 2015-12-24 14:23       ` Jonathan Corbet
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 3/3] Documentation-getdelays: Less function calls in usage()
@ 2015-12-24 14:23       ` Jonathan Corbet
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Documentation-getdelays: Fix a check for container file usage in main()
@ 2015-12-24 17:54         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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€c75a0f1d81922bf322c0634d1e1a15825a89e6#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
--
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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: Documentation-getdelays: Less function calls in usage()
@ 2015-12-24 19:40         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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€c75a0f1d81922bf322c0634d1e1a15825a89e6#n4837

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] 3085+ messages in thread

* ACPI-fan: Another source code review around null pointer handling?
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-25 10:35   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* ACPI-fan: Another source code review around null pointer handling?
@ 2015-12-25 10:35   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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€c75a0f1d81922bf322c0634d1e1a15825a89e6#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
--
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] 3085+ messages in thread

* sata_mv: Another source code review around exception handling?
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-25 16:00   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* sata_mv: Another source code review around exception handling?
@ 2015-12-25 16:00   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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€c75a0f1d81922bf322c0634d1e1a15825a89e6#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
--
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] 3085+ messages in thread

* [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe()
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-25 18:49   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] gpio-ucb1400: Delete an unnecessary variable initialisation in ucb1400_gpio_probe()
@ 2015-12-25 18:49   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-26  6:34   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
@ 2015-12-26  6:34   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
  2015-12-26  6:34   ` SF Markus Elfring
@ 2015-12-26  6:47     ` kbuild test robot
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
@ 2015-12-26  6:47     ` kbuild test robot
  0 siblings, 0 replies; 3085+ messages in thread
From: kbuild test robot @ 2015-12-26  6:47 UTC (permalink / raw)
  To: kernel-janitors

[-- 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
@ 2015-12-26  7:08       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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       ` SF Markus Elfring
@ 2015-12-26  7:48         ` Wolfram Sang
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection
@ 2015-12-26  7:48         ` Wolfram Sang
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-26 10:10   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
@ 2015-12-26 10:10   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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   ` SF Markus Elfring
@ 2015-12-26 10:15     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/3] IDE-ACPI: One function call less in ide_get_dev_handle() after error detection
@ 2015-12-26 10:15     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle()
  2015-12-26 10:10   ` SF Markus Elfring
@ 2015-12-26 10:17     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/3] IDE-ACPI: Delete unnecessary null pointer checks in ide_get_dev_handle()
@ 2015-12-26 10:17     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/3] IDE-ACPI: Move an assignment for one variable in ide_get_dev_handle()
  2015-12-26 10:10   ` SF Markus Elfring
@ 2015-12-26 10:20     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/3] IDE-ACPI: Move an assignment for one variable in ide_get_dev_handle()
@ 2015-12-26 10:20     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-26 13:04   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] iio: qcom-spmi-vadc: One check less in vadc_measure_ref_points() after error detection
@ 2015-12-26 13:04   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-26 10:10   ` SF Markus Elfring
@ 2015-12-26 18:12     ` David Miller
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
@ 2015-12-26 18:12     ` David Miller
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-26 18:39   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/6] InfiniBand-ocrdma: Fine-tuning for some function implementations
@ 2015-12-26 18:39   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ 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
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
  2015-12-26 18:39   ` SF Markus Elfring
@ 2015-12-26 18:43     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
@ 2015-12-26 18:43     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
  2015-12-26 18:39   ` SF Markus Elfring
  (?)
@ 2015-12-26 18:45       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:45 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
@ 2015-12-26 18:45       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/6] InfiniBand-ocrdma: Delete unnecessary variable initialisations in 11 functions
@ 2015-12-26 18:45       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:45 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
  2015-12-26 18:39   ` SF Markus Elfring
  (?)
@ 2015-12-26 18:47       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
@ 2015-12-26 18:47       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 3/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_qp_state_change()
@ 2015-12-26 18:47       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:47 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, 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	[flat|nested] 3085+ 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   ` SF Markus Elfring
  (?)
@ 2015-12-26 18:49       ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:49 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, Julia Lawall

From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
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-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
@ 2015-12-26 18:49       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 4/6] InfiniBand-ocrdma: Return a value from a function call in _ocrdma_modify_qp() directly
@ 2015-12-26 18:49       ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ messages in thread
From: SF Markus Elfring @ 2015-12-26 18:49 UTC (permalink / raw)
  To: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Devesh Sharma, Doug Ledford,
	Hal Rosenstock, Mitesh Ahuja, Sean Hefty, Selvin Xavier
  Cc: LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
  2015-12-26 18:39   ` SF Markus Elfring
@ 2015-12-26 18:50     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 5/6] InfiniBand-ocrdma: Returning only value constants in ocrdma_resize_cq()
@ 2015-12-26 18:50     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
  2015-12-26 18:39   ` SF Markus Elfring
@ 2015-12-26 18:51     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 6/6] InfiniBand-ocrdma: Delete an unnecessary variable in ocrdma_dealloc_pd()
@ 2015-12-26 18:51     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: i2c-core: One function call less in acpi_i2c_space_handler() after error detection
@ 2015-12-26 19:30               ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ 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     ` SF Markus Elfring
@ 2015-12-26 19:41       ` kbuild test robot
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 1/6] InfiniBand-ocrdma: One variable and jump label less in ocrdma_alloc_ucontext_pd()
@ 2015-12-26 19:41       ` kbuild test robot
  0 siblings, 0 replies; 3085+ messages in thread
From: kbuild test robot @ 2015-12-26 19:41 UTC (permalink / raw)
  To: kernel-janitors

[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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH v2 1/6] InfiniBand-ocrdma: One jump label less in ocrdma_alloc_ucontext_pd()
@ 2015-12-26 21:28         ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
  2015-12-26 18:12     ` David Miller
@ 2015-12-26 23:43       ` Joe Perches
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
@ 2015-12-26 23:43       ` Joe Perches
  0 siblings, 0 replies; 3085+ 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] 3085+ 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
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/3] IDE-ACPI: Fine-tuning for a function
@ 2015-12-27  6:08         ` Julia Lawall
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-27 12:36   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 12:36   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr()
  2015-12-27 12:36   ` SF Markus Elfring
@ 2015-12-27 12:40     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 1/2] InfiniBand-iSER: One jump label less in iser_reg_sig_mr()
@ 2015-12-27 12:40     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr()
  2015-12-27 12:36   ` SF Markus Elfring
@ 2015-12-27 12:41     ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH 2/2] InfiniBand-iSER-target: One jump label less in isert_reg_sig_mr()
@ 2015-12-27 12:41     ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

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

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> 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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 12:43       ` Leon Romanovsky
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 12:43       ` Leon Romanovsky
  0 siblings, 0 replies; 3085+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:43 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	target-devel-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, 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] 3085+ messages in thread

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

On Sun, Dec 27, 2015 at 01:36:30PM +0100, SF Markus Elfring wrote:
> From: Markus Elfring <elfring-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>
> 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-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

> 
>  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-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 12:52       ` Leon Romanovsky
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 12:52       ` Leon Romanovsky
  0 siblings, 0 replies; 3085+ messages in thread
From: Leon Romanovsky @ 2015-12-27 12:52 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	target-devel-u79uwXL29TY76Z2rM5mHXA, Doug Ledford,
	Hal Rosenstock, Or Gerlitz, Roi Dayan, Sagi Grimberg, Sean Hefty,
	LKML, kernel-janitors-u79uwXL29TY76Z2rM5mHXA, 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] 3085+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
  2015-12-27 12:36   ` SF Markus Elfring
@ 2015-12-27 15:26     ` Sagi Grimberg
  -1 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* Re: [PATCH 0/2] InfiniBand-iSER: Refactoring for two function implementations
@ 2015-12-27 15:26     ` Sagi Grimberg
  0 siblings, 0 replies; 3085+ 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] 3085+ messages in thread

* [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-27 17:33   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] [media] si2165: Refactoring for si2165_writereg_mask8()
@ 2015-12-27 17:33   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] [media] bttv: Returning only value constants in two functions
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-27 21:22   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] [media] bttv: Returning only value constants in two functions
@ 2015-12-27 21:22   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-11 12:08 ` SF Markus Elfring
@ 2015-12-28  9:15   ` SF Markus Elfring
  -1 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
@ 2015-12-28  9:15   ` SF Markus Elfring
  0 siblings, 0 replies; 3085+ 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	[flat|nested] 3085+ messages in thread

* Re: [PATCH] [media] tuners: One check less in m88rs6000t_get_rf_strength() after error detection
  2015-12-28  9:15   ` SF Markus Elfring
@ 2015-12-28  9:20     ` Julia Lawall
  -1 siblings, 0 replies; 3085+ 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;
&