public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/11] trivial: use BUG_ON
@ 2011-08-02 10:34 Julia Lawall
  2011-08-02 10:34 ` [PATCH 1/11] kernel/kfifo.c: " Julia Lawall
                   ` (10 more replies)
  0 siblings, 11 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors

These patches convert conditionals containing only a call to BUG() to a
call to BUG_ON in some trivial cases.


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

* [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-02 11:33   ` Andrea Righi
  2011-08-02 10:34 ` [PATCH 2/11] drivers/message/fusion/mptsas.c: " Julia Lawall
                   ` (9 subsequent siblings)
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Andrew Morton, trivial
  Cc: kernel-janitors, Stefani Seibold, Andrea Righi, Ira W. Snyder,
	linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 kernel/kfifo.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -562,8 +562,7 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
 unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
+	BUG_ON(!nents);
 
 	len = __kfifo_max_r(len, recsize);
 
@@ -586,8 +585,7 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
 unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
+	BUG_ON(!nents);
 
 	len = __kfifo_max_r(len, recsize);
 


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

* [PATCH 2/11] drivers/message/fusion/mptsas.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
  2011-08-02 10:34 ` [PATCH 1/11] kernel/kfifo.c: " Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-04  6:54   ` Nandigama, Nagalakshmi
  2011-08-02 10:34 ` [PATCH 3/11] arch/arm/mach-s3c64xx/dma.c: " Julia Lawall
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Eric Moore, trivial
  Cc: kernel-janitors, support, DL-MPTFusionLinux, linux-scsi,
	linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/message/fusion/mptsas.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -3410,8 +3410,7 @@ mptsas_expander_event_add(MPT_ADAPTER *i
 	__le64 sas_address;
 
 	port_info = kzalloc(sizeof(struct mptsas_portinfo), GFP_KERNEL);
-	if (!port_info)
-		BUG();
+	BUG_ON(!port_info);
 	port_info->num_phys = (expander_data->NumPhys) ?
 	    expander_data->NumPhys : 1;
 	port_info->phy_info = kcalloc(port_info->num_phys,


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

* [PATCH 3/11] arch/arm/mach-s3c64xx/dma.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
  2011-08-02 10:34 ` [PATCH 1/11] kernel/kfifo.c: " Julia Lawall
  2011-08-02 10:34 ` [PATCH 2/11] drivers/message/fusion/mptsas.c: " Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-02 10:34 ` [PATCH 4/11] arch/x86/kvm/vmx.c: " Julia Lawall
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Ben Dooks, trivial
  Cc: kernel-janitors, Russell King, linux-arm-kernel, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/arm/mach-s3c64xx/dma.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/arm/mach-s3c64xx/dma.c b/arch/arm/mach-s3c64xx/dma.c
--- a/arch/arm/mach-s3c64xx/dma.c
+++ b/arch/arm/mach-s3c64xx/dma.c
@@ -603,8 +603,7 @@ static irqreturn_t s3c64xx_dma_irq(int i
 				&& buff->next != chan->next)
 			buff = buff->next;
 
-		if (!buff)
-			BUG();
+		BUG_ON(!buff);
 
 		if (buff == chan->next)
 			buff = chan->end;


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

* [PATCH 4/11] arch/x86/kvm/vmx.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (2 preceding siblings ...)
  2011-08-02 10:34 ` [PATCH 3/11] arch/arm/mach-s3c64xx/dma.c: " Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-02 16:44   ` Marcelo Tosatti
  2011-08-02 10:34 ` [PATCH 5/11] kernel/sysctl.c: " Julia Lawall
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Avi Kivity, trivial
  Cc: kernel-janitors, Marcelo Tosatti, Thomas Gleixner, Ingo Molnar,
	H. Peter Anvin, x86, kvm, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/x86/kvm/vmx.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -4115,8 +4115,7 @@ static int handle_exception(struct kvm_v
 		error_code = vmcs_read32(VM_EXIT_INTR_ERROR_CODE);
 	if (is_page_fault(intr_info)) {
 		/* EPT won't cause page fault directly */
-		if (enable_ept)
-			BUG();
+		BUG_ON(enable_ept);
 		cr2 = vmcs_readl(EXIT_QUALIFICATION);
 		trace_kvm_page_fault(cr2, error_code);
 


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

* [PATCH 5/11] kernel/sysctl.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (3 preceding siblings ...)
  2011-08-02 10:34 ` [PATCH 4/11] arch/x86/kvm/vmx.c: " Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-02 10:34 ` [PATCH 6/11] drivers/iommu/iommu.c: " Julia Lawall
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Ingo Molnar, trivial
  Cc: kernel-janitors, Andrew Morton, Peter Zijlstra, Al Viro,
	Eric Paris, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 kernel/sysctl.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/kernel/sysctl.c b/kernel/sysctl.c
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -1600,8 +1600,7 @@ void sysctl_head_put(struct ctl_table_he
 
 struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
 {
-	if (!head)
-		BUG();
+	BUG_ON(!head);
 	spin_lock(&sysctl_lock);
 	if (!use_table(head))
 		head = ERR_PTR(-ENOENT);


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

* [PATCH 6/11] drivers/iommu/iommu.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (4 preceding siblings ...)
  2011-08-02 10:34 ` [PATCH 5/11] kernel/sysctl.c: " Julia Lawall
@ 2011-08-02 10:34 ` Julia Lawall
  2011-08-02 10:35 ` [PATCH 7/11] arch/m32r/kernel/smp.c: " Julia Lawall
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:34 UTC (permalink / raw)
  To: Ohad Ben-Cohen, trivial; +Cc: kernel-janitors, Joerg Roedel, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/iommu/iommu.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -27,8 +27,7 @@ static struct iommu_ops *iommu_ops;
 
 void register_iommu(struct iommu_ops *ops)
 {
-	if (iommu_ops)
-		BUG();
+	BUG_ON(iommu_ops);
 
 	iommu_ops = ops;
 }


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

* [PATCH 7/11] arch/m32r/kernel/smp.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (5 preceding siblings ...)
  2011-08-02 10:34 ` [PATCH 6/11] drivers/iommu/iommu.c: " Julia Lawall
@ 2011-08-02 10:35 ` Julia Lawall
  2011-08-02 10:55   ` KOSAKI Motohiro
  2011-08-02 10:35 ` [PATCH 8/11] fs/btrfs/volumes.c: " Julia Lawall
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:35 UTC (permalink / raw)
  To: Hirokazu Takata, trivial
  Cc: kernel-janitors, Andrew Morton, KOSAKI Motohiro,
	Benjamin Herrenschmidt, Jesper Nilsson, Chris Metcalf, linux-m32r,
	linux-m32r-ja, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/m32r/kernel/smp.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c
--- a/arch/m32r/kernel/smp.c
+++ b/arch/m32r/kernel/smp.c
@@ -327,8 +327,7 @@ void smp_flush_tlb_page(struct vm_area_s
 	cpumask_clear_cpu(cpu_id, &cpu_mask);
 
 #ifdef DEBUG_SMP
-	if (!mm)
-		BUG();
+	BUG_ON(!mm);
 #endif
 
 	if (*mmc != NO_CONTEXT) {


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

* [PATCH 8/11] fs/btrfs/volumes.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (6 preceding siblings ...)
  2011-08-02 10:35 ` [PATCH 7/11] arch/m32r/kernel/smp.c: " Julia Lawall
@ 2011-08-02 10:35 ` Julia Lawall
  2011-08-02 10:35 ` [PATCH 9/11] drivers/target/target_core_rd.c: " Julia Lawall
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:35 UTC (permalink / raw)
  To: Chris Mason, trivial; +Cc: kernel-janitors, linux-btrfs, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 fs/btrfs/volumes.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 19450bc..275be0f 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1983,8 +1983,8 @@ again:
 						   found_key.offset);
 			if (ret == -ENOSPC)
 				failed++;
-			else if (ret)
-				BUG();
+			else
+				BUG_ON(ret);
 		}
 
 		if (found_key.offset == 0)


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

* [PATCH 9/11] drivers/target/target_core_rd.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (7 preceding siblings ...)
  2011-08-02 10:35 ` [PATCH 8/11] fs/btrfs/volumes.c: " Julia Lawall
@ 2011-08-02 10:35 ` Julia Lawall
  2011-08-04 18:05   ` Nicholas A. Bellinger
  2011-08-02 10:35 ` [PATCH 10/11] arch/openrisc/mm/init.c: " Julia Lawall
  2011-08-02 10:35 ` [PATCH 11/11] arch/tile/mm/init.c: " Julia Lawall
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:35 UTC (permalink / raw)
  To: Nicholas A. Bellinger, trivial; +Cc: kernel-janitors, linux-scsi, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/target/target_core_rd.c |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff -u -p a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
--- a/drivers/target/target_core_rd.c
+++ b/drivers/target/target_core_rd.c
@@ -390,12 +390,10 @@ static int rd_MEMCPY_read(struct rd_requ
 				length = req->rd_size;
 
 			dst = sg_virt(&sg_d[i++]) + dst_offset;
-			if (!dst)
-				BUG();
+			BUG_ON(!dst);
 
 			src = sg_virt(&sg_s[j]) + src_offset;
-			if (!src)
-				BUG();
+			BUG_ON(!src);
 
 			dst_offset = 0;
 			src_offset = length;
@@ -415,8 +413,7 @@ static int rd_MEMCPY_read(struct rd_requ
 				length = req->rd_size;
 
 			dst = sg_virt(&sg_d[i]) + dst_offset;
-			if (!dst)
-				BUG();
+			BUG_ON(!dst);
 
 			if (sg_d[i].length == length) {
 				i++;
@@ -425,8 +422,7 @@ static int rd_MEMCPY_read(struct rd_requ
 				dst_offset = length;
 
 			src = sg_virt(&sg_s[j++]) + src_offset;
-			if (!src)
-				BUG();
+			BUG_ON(!src);
 
 			src_offset = 0;
 			page_end = 1;
@@ -510,12 +506,10 @@ static int rd_MEMCPY_write(struct rd_req
 				length = req->rd_size;
 
 			src = sg_virt(&sg_s[i++]) + src_offset;
-			if (!src)
-				BUG();
+			BUG_ON(!src);
 
 			dst = sg_virt(&sg_d[j]) + dst_offset;
-			if (!dst)
-				BUG();
+			BUG_ON(!dst);
 
 			src_offset = 0;
 			dst_offset = length;
@@ -535,8 +529,7 @@ static int rd_MEMCPY_write(struct rd_req
 				length = req->rd_size;
 
 			src = sg_virt(&sg_s[i]) + src_offset;
-			if (!src)
-				BUG();
+			BUG_ON(!src);
 
 			if (sg_s[i].length == length) {
 				i++;
@@ -545,8 +538,7 @@ static int rd_MEMCPY_write(struct rd_req
 				src_offset = length;
 
 			dst = sg_virt(&sg_d[j++]) + dst_offset;
-			if (!dst)
-				BUG();
+			BUG_ON(!dst);
 
 			dst_offset = 0;
 			page_end = 1;


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

* [PATCH 10/11] arch/openrisc/mm/init.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (8 preceding siblings ...)
  2011-08-02 10:35 ` [PATCH 9/11] drivers/target/target_core_rd.c: " Julia Lawall
@ 2011-08-02 10:35 ` Julia Lawall
  2011-08-02 13:55   ` Jonas Bonn
  2011-08-02 10:35 ` [PATCH 11/11] arch/tile/mm/init.c: " Julia Lawall
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:35 UTC (permalink / raw)
  To: Jonas Bonn, trivial; +Cc: kernel-janitors, Arnd Bergmann, linux, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/openrisc/mm/init.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/openrisc/mm/init.c b/arch/openrisc/mm/init.c
--- a/arch/openrisc/mm/init.c
+++ b/arch/openrisc/mm/init.c
@@ -222,8 +222,7 @@ void __init mem_init(void)
 {
 	int codesize, reservedpages, datasize, initsize;
 
-	if (!mem_map)
-		BUG();
+	BUG_ON(!mem_map);
 
 	set_max_mapnr_init();
 


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

* [PATCH 11/11] arch/tile/mm/init.c: trivial: use BUG_ON
  2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
                   ` (9 preceding siblings ...)
  2011-08-02 10:35 ` [PATCH 10/11] arch/openrisc/mm/init.c: " Julia Lawall
@ 2011-08-02 10:35 ` Julia Lawall
  2011-08-02 20:28   ` Chris Metcalf
  10 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 10:35 UTC (permalink / raw)
  To: Chris Metcalf, trivial
  Cc: kernel-janitors, Andrew Morton, Peter Zijlstra, linux-kernel

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 arch/tile/mm/init.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/arch/tile/mm/init.c b/arch/tile/mm/init.c
--- a/arch/tile/mm/init.c
+++ b/arch/tile/mm/init.c
@@ -836,8 +836,7 @@ void __init mem_init(void)
 #endif
 
 #ifdef CONFIG_FLATMEM
-	if (!mem_map)
-		BUG();
+	BUG_ON(!mem_map);
 #endif
 
 #ifdef CONFIG_HIGHMEM


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

* Re: [PATCH 7/11] arch/m32r/kernel/smp.c: trivial: use BUG_ON
  2011-08-02 10:35 ` [PATCH 7/11] arch/m32r/kernel/smp.c: " Julia Lawall
@ 2011-08-02 10:55   ` KOSAKI Motohiro
  0 siblings, 0 replies; 25+ messages in thread
From: KOSAKI Motohiro @ 2011-08-02 10:55 UTC (permalink / raw)
  To: julia
  Cc: takata, trivial, kernel-janitors, akpm, benh, jesper.nilsson,
	cmetcalf, linux-m32r, linux-m32r-ja, linux-kernel

(2011/08/02 19:35), Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Use BUG_ON(x) rather than if(x) BUG();
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@ identifier x; @@
> -if (x) BUG();
> +BUG_ON(x);
> 
> @@ identifier x; @@
> -if (!x) BUG();
> +BUG_ON(!x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Indeed.
 Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>


> 
> ---
>  arch/m32r/kernel/smp.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff -u -p a/arch/m32r/kernel/smp.c b/arch/m32r/kernel/smp.c
> --- a/arch/m32r/kernel/smp.c
> +++ b/arch/m32r/kernel/smp.c
> @@ -327,8 +327,7 @@ void smp_flush_tlb_page(struct vm_area_s
>  	cpumask_clear_cpu(cpu_id, &cpu_mask);
>  
>  #ifdef DEBUG_SMP
> -	if (!mm)
> -		BUG();
> +	BUG_ON(!mm);
>  #endif
>  
>  	if (*mmc != NO_CONTEXT) {
> 
> 
> 



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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 10:34 ` [PATCH 1/11] kernel/kfifo.c: " Julia Lawall
@ 2011-08-02 11:33   ` Andrea Righi
  2011-08-02 11:52     ` Julia Lawall
  0 siblings, 1 reply; 25+ messages in thread
From: Andrea Righi @ 2011-08-02 11:33 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

On Tue, Aug 02, 2011 at 12:34:54PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Use BUG_ON(x) rather than if(x) BUG();
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@ identifier x; @@
> -if (x) BUG();
> +BUG_ON(x);
> 
> @@ identifier x; @@
> -if (!x) BUG();
> +BUG_ON(!x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 

The patch looks good. However, I think we should just get rid of the
BUG_ON() there. If nents is 0, setup_sgl_buf() would just returns 0 and
nothing critical will happen.

Also consider that in __kfifo_dma_in_prepare(), the equivalent of
__kfifo_dma_in_prepare_r() when recsize is 0, we don't check nents at
all.

-Andrea

> ---
>  kernel/kfifo.c |    6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
> --- a/kernel/kfifo.c
> +++ b/kernel/kfifo.c
> @@ -562,8 +562,7 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
>  unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
>  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
>  {
> -	if (!nents)
> -		BUG();
> +	BUG_ON(!nents);
>  
>  	len = __kfifo_max_r(len, recsize);
>  
> @@ -586,8 +585,7 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
>  unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
>  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
>  {
> -	if (!nents)
> -		BUG();
> +	BUG_ON(!nents);
>  
>  	len = __kfifo_max_r(len, recsize);
>  

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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 11:33   ` Andrea Righi
@ 2011-08-02 11:52     ` Julia Lawall
  2011-08-02 12:03       ` Andrea Righi
                         ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 11:52 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

On Tue, 2 Aug 2011, Andrea Righi wrote:

> On Tue, Aug 02, 2011 at 12:34:54PM +0200, Julia Lawall wrote:
> > From: Julia Lawall <julia@diku.dk>
> > 
> > Use BUG_ON(x) rather than if(x) BUG();
> > 
> > The semantic patch that fixes this problem is as follows:
> > (http://coccinelle.lip6.fr/)
> > 
> > // <smpl>
> > @@ identifier x; @@
> > -if (x) BUG();
> > +BUG_ON(x);
> > 
> > @@ identifier x; @@
> > -if (!x) BUG();
> > +BUG_ON(!x);
> > // </smpl>
> > 
> > Signed-off-by: Julia Lawall <julia@diku.dk>
> > 
> 
> The patch looks good. However, I think we should just get rid of the
> BUG_ON() there. If nents is 0, setup_sgl_buf() would just returns 0 and
> nothing critical will happen.

I don't know the code at all.  Indeed, I'm not sure to see any uses of eg 
__kfifo_dma_in_prepare_r, except in demo code.  But that would imply 
returning 0 for two different reasons: asking for nothing and being out of 
space.

julia

> Also consider that in __kfifo_dma_in_prepare(), the equivalent of
> __kfifo_dma_in_prepare_r() when recsize is 0, we don't check nents at
> all.
> 
> -Andrea
> 
> > ---
> >  kernel/kfifo.c |    6 ++----
> >  1 file changed, 2 insertions(+), 4 deletions(-)
> > 
> > diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
> > --- a/kernel/kfifo.c
> > +++ b/kernel/kfifo.c
> > @@ -562,8 +562,7 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
> >  unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
> >  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
> >  {
> > -	if (!nents)
> > -		BUG();
> > +	BUG_ON(!nents);
> >  
> >  	len = __kfifo_max_r(len, recsize);
> >  
> > @@ -586,8 +585,7 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
> >  unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
> >  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
> >  {
> > -	if (!nents)
> > -		BUG();
> > +	BUG_ON(!nents);
> >  
> >  	len = __kfifo_max_r(len, recsize);
> >  
> --
> 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] 25+ messages in thread

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 11:52     ` Julia Lawall
@ 2011-08-02 12:03       ` Andrea Righi
  2011-08-02 15:20         ` Julia Lawall
  2011-08-02 19:27       ` Julia Lawall
  2011-08-03  6:30       ` Stefani Seibold
  2 siblings, 1 reply; 25+ messages in thread
From: Andrea Righi @ 2011-08-02 12:03 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

On Tue, Aug 02, 2011 at 01:52:49PM +0200, Julia Lawall wrote:
> On Tue, 2 Aug 2011, Andrea Righi wrote:
> 
> > On Tue, Aug 02, 2011 at 12:34:54PM +0200, Julia Lawall wrote:
> > > From: Julia Lawall <julia@diku.dk>
> > > 
> > > Use BUG_ON(x) rather than if(x) BUG();
> > > 
> > > The semantic patch that fixes this problem is as follows:
> > > (http://coccinelle.lip6.fr/)
> > > 
> > > // <smpl>
> > > @@ identifier x; @@
> > > -if (x) BUG();
> > > +BUG_ON(x);
> > > 
> > > @@ identifier x; @@
> > > -if (!x) BUG();
> > > +BUG_ON(!x);
> > > // </smpl>
> > > 
> > > Signed-off-by: Julia Lawall <julia@diku.dk>
> > > 
> > 
> > The patch looks good. However, I think we should just get rid of the
> > BUG_ON() there. If nents is 0, setup_sgl_buf() would just returns 0 and
> > nothing critical will happen.
> 
> I don't know the code at all.  Indeed, I'm not sure to see any uses of eg 
> __kfifo_dma_in_prepare_r, except in demo code.  But that would imply 
> returning 0 for two different reasons: asking for nothing and being out of 
> space.
> 
> julia

Right. But I'd prefer to return nothing also when asking nothing rather
than crashing the kernel.

-Andrea

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

* Re: [PATCH 10/11] arch/openrisc/mm/init.c: trivial: use BUG_ON
  2011-08-02 10:35 ` [PATCH 10/11] arch/openrisc/mm/init.c: " Julia Lawall
@ 2011-08-02 13:55   ` Jonas Bonn
  0 siblings, 0 replies; 25+ messages in thread
From: Jonas Bonn @ 2011-08-02 13:55 UTC (permalink / raw)
  To: Julia Lawall; +Cc: trivial, kernel-janitors, Arnd Bergmann, linux, linux-kernel


On Tue, 2011-08-02 at 12:35 +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Use BUG_ON(x) rather than if(x) BUG();
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@ identifier x; @@
> -if (x) BUG();
> +BUG_ON(x);
> 
> @@ identifier x; @@
> -if (!x) BUG();
> +BUG_ON(!x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 

Will apply.  Thanks.

Best regards,
Jonas



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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 12:03       ` Andrea Righi
@ 2011-08-02 15:20         ` Julia Lawall
  0 siblings, 0 replies; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 15:20 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

On Tue, 2 Aug 2011, Andrea Righi wrote:

> On Tue, Aug 02, 2011 at 01:52:49PM +0200, Julia Lawall wrote:
> > On Tue, 2 Aug 2011, Andrea Righi wrote:
> > 
> > > On Tue, Aug 02, 2011 at 12:34:54PM +0200, Julia Lawall wrote:
> > > > From: Julia Lawall <julia@diku.dk>
> > > > 
> > > > Use BUG_ON(x) rather than if(x) BUG();
> > > > 
> > > > The semantic patch that fixes this problem is as follows:
> > > > (http://coccinelle.lip6.fr/)
> > > > 
> > > > // <smpl>
> > > > @@ identifier x; @@
> > > > -if (x) BUG();
> > > > +BUG_ON(x);
> > > > 
> > > > @@ identifier x; @@
> > > > -if (!x) BUG();
> > > > +BUG_ON(!x);
> > > > // </smpl>
> > > > 
> > > > Signed-off-by: Julia Lawall <julia@diku.dk>
> > > > 
> > > 
> > > The patch looks good. However, I think we should just get rid of the
> > > BUG_ON() there. If nents is 0, setup_sgl_buf() would just returns 0 and
> > > nothing critical will happen.
> > 
> > I don't know the code at all.  Indeed, I'm not sure to see any uses of eg 
> > __kfifo_dma_in_prepare_r, except in demo code.  But that would imply 
> > returning 0 for two different reasons: asking for nothing and being out of 
> > space.
> > 
> > julia
> 
> Right. But I'd prefer to return nothing also when asking nothing rather
> than crashing the kernel.

OK, that seems like a good point too.  I will send a new patch.

julia

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

* Re: [PATCH 4/11] arch/x86/kvm/vmx.c: trivial: use BUG_ON
  2011-08-02 10:34 ` [PATCH 4/11] arch/x86/kvm/vmx.c: " Julia Lawall
@ 2011-08-02 16:44   ` Marcelo Tosatti
  0 siblings, 0 replies; 25+ messages in thread
From: Marcelo Tosatti @ 2011-08-02 16:44 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Avi Kivity, trivial, kernel-janitors, Thomas Gleixner,
	Ingo Molnar, H. Peter Anvin, x86, kvm, linux-kernel

On Tue, Aug 02, 2011 at 12:34:57PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Use BUG_ON(x) rather than if(x) BUG();
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@ identifier x; @@
> -if (x) BUG();
> +BUG_ON(x);
> 
> @@ identifier x; @@
> -if (!x) BUG();
> +BUG_ON(!x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Applied, thanks.


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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 11:52     ` Julia Lawall
  2011-08-02 12:03       ` Andrea Righi
@ 2011-08-02 19:27       ` Julia Lawall
  2011-08-02 20:09         ` Andrea Righi
  2011-08-03  6:30       ` Stefani Seibold
  2 siblings, 1 reply; 25+ messages in thread
From: Julia Lawall @ 2011-08-02 19:27 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

From: Julia Lawall <julia@diku.dk>

Allow the function to return 0 when 0 elements are asked for rather than
crashing the kernel with BUG.

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 var/julia/linuxcopy/kernel/kfifo.c |    6 ------
 1 file changed, 6 deletions(-)

diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
index 01a0700..9f928ef 100644
--- a/var/linuxes/linux-next/kernel/kfifo.c
+++ b/var/julia/linuxcopy/kernel/kfifo.c
@@ -562,9 +562,6 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
 unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
-
 	len = __kfifo_max_r(len, recsize);
 
 	if (len + recsize > kfifo_unused(fifo))
@@ -586,9 +583,6 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
 unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
-
 	len = __kfifo_max_r(len, recsize);
 
 	if (len + recsize > fifo->in - fifo->out)

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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 19:27       ` Julia Lawall
@ 2011-08-02 20:09         ` Andrea Righi
  0 siblings, 0 replies; 25+ messages in thread
From: Andrea Righi @ 2011-08-02 20:09 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

On Tue, Aug 02, 2011 at 09:27:38PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Allow the function to return 0 when 0 elements are asked for rather than
> crashing the kernel with BUG.
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>

Reviewed-by: Andrea Righi <andrea@betterlinux.com>

Thanks,
-Andrea

> 
> ---
>  var/julia/linuxcopy/kernel/kfifo.c |    6 ------
>  1 file changed, 6 deletions(-)
> 
> diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
> index 01a0700..9f928ef 100644
> --- a/var/linuxes/linux-next/kernel/kfifo.c
> +++ b/var/julia/linuxcopy/kernel/kfifo.c
> @@ -562,9 +562,6 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
>  unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
>  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
>  {
> -	if (!nents)
> -		BUG();
> -
>  	len = __kfifo_max_r(len, recsize);
>  
>  	if (len + recsize > kfifo_unused(fifo))
> @@ -586,9 +583,6 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
>  unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
>  	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
>  {
> -	if (!nents)
> -		BUG();
> -
>  	len = __kfifo_max_r(len, recsize);
>  
>  	if (len + recsize > fifo->in - fifo->out)

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

* Re: [PATCH 11/11] arch/tile/mm/init.c: trivial: use BUG_ON
  2011-08-02 10:35 ` [PATCH 11/11] arch/tile/mm/init.c: " Julia Lawall
@ 2011-08-02 20:28   ` Chris Metcalf
  0 siblings, 0 replies; 25+ messages in thread
From: Chris Metcalf @ 2011-08-02 20:28 UTC (permalink / raw)
  To: Julia Lawall
  Cc: trivial, kernel-janitors, Andrew Morton, Peter Zijlstra,
	linux-kernel

On 8/2/2011 6:35 AM, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Use BUG_ON(x) rather than if(x) BUG();

Thanks, accepted into the tile tree.

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


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

* Re: [PATCH 1/11] kernel/kfifo.c: trivial: use BUG_ON
  2011-08-02 11:52     ` Julia Lawall
  2011-08-02 12:03       ` Andrea Righi
  2011-08-02 19:27       ` Julia Lawall
@ 2011-08-03  6:30       ` Stefani Seibold
  2 siblings, 0 replies; 25+ messages in thread
From: Stefani Seibold @ 2011-08-03  6:30 UTC (permalink / raw)
  To: Andrea Righi
  Cc: Andrew Morton, trivial, kernel-janitors, Stefani Seibold,
	Ira W. Snyder, linux-kernel

From: Julia Lawall <julia@diku.dk>

Allow the function to return 0 when 0 elements are asked for rather than
crashing the kernel with BUG.

Signed-off-by: Julia Lawall <julia@diku.dk>
Acked-by: Stefano Seibold <stefani@seibold.net>

---
 var/julia/linuxcopy/kernel/kfifo.c |    6 ------
 1 file changed, 6 deletions(-)

diff -u -p a/kernel/kfifo.c b/kernel/kfifo.c
index 01a0700..9f928ef 100644
--- a/var/linuxes/linux-next/kernel/kfifo.c
+++ b/var/julia/linuxcopy/kernel/kfifo.c
@@ -562,9 +562,6 @@ EXPORT_SYMBOL(__kfifo_to_user_r);
 unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
-
 	len = __kfifo_max_r(len, recsize);
 
 	if (len + recsize > kfifo_unused(fifo))
@@ -586,9 +583,6 @@ EXPORT_SYMBOL(__kfifo_dma_in_finish_r);
 unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
 	struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
 {
-	if (!nents)
-		BUG();
-
 	len = __kfifo_max_r(len, recsize);
 
 	if (len + recsize > fifo->in - fifo->out)



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

* RE: [PATCH 2/11] drivers/message/fusion/mptsas.c: trivial: use BUG_ON
  2011-08-02 10:34 ` [PATCH 2/11] drivers/message/fusion/mptsas.c: " Julia Lawall
@ 2011-08-04  6:54   ` Nandigama, Nagalakshmi
  0 siblings, 0 replies; 25+ messages in thread
From: Nandigama, Nagalakshmi @ 2011-08-04  6:54 UTC (permalink / raw)
  To: Julia Lawall, Moore, Eric, trivial@kernel.org
  Cc: kernel-janitors@vger.kernel.org, Support, DL-MPT Fusion Linux,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org

The patch seem to be fine. Please consider this patch as an Acked by me

Regards,
Nagalakshmi


-----Original Message-----
From: Julia Lawall [mailto:julia@diku.dk] 
Sent: Tuesday, August 02, 2011 4:05 PM
To: Moore, Eric; trivial@kernel.org
Cc: kernel-janitors@vger.kernel.org; Support; DL-MPT Fusion Linux; linux-scsi@vger.kernel.org; linux-kernel@vger.kernel.org
Subject: [PATCH 2/11] drivers/message/fusion/mptsas.c: trivial: use BUG_ON

From: Julia Lawall <julia@diku.dk>

Use BUG_ON(x) rather than if(x) BUG();

The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@ identifier x; @@
-if (x) BUG();
+BUG_ON(x);

@@ identifier x; @@
-if (!x) BUG();
+BUG_ON(!x);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 drivers/message/fusion/mptsas.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff -u -p a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -3410,8 +3410,7 @@ mptsas_expander_event_add(MPT_ADAPTER *i
 	__le64 sas_address;
 
 	port_info = kzalloc(sizeof(struct mptsas_portinfo), GFP_KERNEL);
-	if (!port_info)
-		BUG();
+	BUG_ON(!port_info);
 	port_info->num_phys = (expander_data->NumPhys) ?
 	    expander_data->NumPhys : 1;
 	port_info->phy_info = kcalloc(port_info->num_phys,


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

* Re: [PATCH 9/11] drivers/target/target_core_rd.c: trivial: use BUG_ON
  2011-08-02 10:35 ` [PATCH 9/11] drivers/target/target_core_rd.c: " Julia Lawall
@ 2011-08-04 18:05   ` Nicholas A. Bellinger
  0 siblings, 0 replies; 25+ messages in thread
From: Nicholas A. Bellinger @ 2011-08-04 18:05 UTC (permalink / raw)
  To: Julia Lawall
  Cc: trivial, kernel-janitors, linux-scsi, linux-kernel, target-devel

On Tue, 2011-08-02 at 12:35 +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> Use BUG_ON(x) rather than if(x) BUG();
> 
> The semantic patch that fixes this problem is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@ identifier x; @@
> -if (x) BUG();
> +BUG_ON(x);
> 
> @@ identifier x; @@
> -if (!x) BUG();
> +BUG_ON(!x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@diku.dk>
> 

Hi Julia,

Committed as 5acbe8a85d7 into lio-core-2.6.git/master, and will be
queued for the next round of target updates.

Thanks!

--nab

> ---
>  drivers/target/target_core_rd.c |   24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff -u -p a/drivers/target/target_core_rd.c b/drivers/target/target_core_rd.c
> --- a/drivers/target/target_core_rd.c
> +++ b/drivers/target/target_core_rd.c
> @@ -390,12 +390,10 @@ static int rd_MEMCPY_read(struct rd_requ
>  				length = req->rd_size;
>  
>  			dst = sg_virt(&sg_d[i++]) + dst_offset;
> -			if (!dst)
> -				BUG();
> +			BUG_ON(!dst);
>  
>  			src = sg_virt(&sg_s[j]) + src_offset;
> -			if (!src)
> -				BUG();
> +			BUG_ON(!src);
>  
>  			dst_offset = 0;
>  			src_offset = length;
> @@ -415,8 +413,7 @@ static int rd_MEMCPY_read(struct rd_requ
>  				length = req->rd_size;
>  
>  			dst = sg_virt(&sg_d[i]) + dst_offset;
> -			if (!dst)
> -				BUG();
> +			BUG_ON(!dst);
>  
>  			if (sg_d[i].length == length) {
>  				i++;
> @@ -425,8 +422,7 @@ static int rd_MEMCPY_read(struct rd_requ
>  				dst_offset = length;
>  
>  			src = sg_virt(&sg_s[j++]) + src_offset;
> -			if (!src)
> -				BUG();
> +			BUG_ON(!src);
>  
>  			src_offset = 0;
>  			page_end = 1;
> @@ -510,12 +506,10 @@ static int rd_MEMCPY_write(struct rd_req
>  				length = req->rd_size;
>  
>  			src = sg_virt(&sg_s[i++]) + src_offset;
> -			if (!src)
> -				BUG();
> +			BUG_ON(!src);
>  
>  			dst = sg_virt(&sg_d[j]) + dst_offset;
> -			if (!dst)
> -				BUG();
> +			BUG_ON(!dst);
>  
>  			src_offset = 0;
>  			dst_offset = length;
> @@ -535,8 +529,7 @@ static int rd_MEMCPY_write(struct rd_req
>  				length = req->rd_size;
>  
>  			src = sg_virt(&sg_s[i]) + src_offset;
> -			if (!src)
> -				BUG();
> +			BUG_ON(!src);
>  
>  			if (sg_s[i].length == length) {
>  				i++;
> @@ -545,8 +538,7 @@ static int rd_MEMCPY_write(struct rd_req
>  				src_offset = length;
>  
>  			dst = sg_virt(&sg_d[j++]) + dst_offset;
> -			if (!dst)
> -				BUG();
> +			BUG_ON(!dst);
>  
>  			dst_offset = 0;
>  			page_end = 1;
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 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] 25+ messages in thread

end of thread, other threads:[~2011-08-04 18:15 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-02 10:34 [PATCH 0/11] trivial: use BUG_ON Julia Lawall
2011-08-02 10:34 ` [PATCH 1/11] kernel/kfifo.c: " Julia Lawall
2011-08-02 11:33   ` Andrea Righi
2011-08-02 11:52     ` Julia Lawall
2011-08-02 12:03       ` Andrea Righi
2011-08-02 15:20         ` Julia Lawall
2011-08-02 19:27       ` Julia Lawall
2011-08-02 20:09         ` Andrea Righi
2011-08-03  6:30       ` Stefani Seibold
2011-08-02 10:34 ` [PATCH 2/11] drivers/message/fusion/mptsas.c: " Julia Lawall
2011-08-04  6:54   ` Nandigama, Nagalakshmi
2011-08-02 10:34 ` [PATCH 3/11] arch/arm/mach-s3c64xx/dma.c: " Julia Lawall
2011-08-02 10:34 ` [PATCH 4/11] arch/x86/kvm/vmx.c: " Julia Lawall
2011-08-02 16:44   ` Marcelo Tosatti
2011-08-02 10:34 ` [PATCH 5/11] kernel/sysctl.c: " Julia Lawall
2011-08-02 10:34 ` [PATCH 6/11] drivers/iommu/iommu.c: " Julia Lawall
2011-08-02 10:35 ` [PATCH 7/11] arch/m32r/kernel/smp.c: " Julia Lawall
2011-08-02 10:55   ` KOSAKI Motohiro
2011-08-02 10:35 ` [PATCH 8/11] fs/btrfs/volumes.c: " Julia Lawall
2011-08-02 10:35 ` [PATCH 9/11] drivers/target/target_core_rd.c: " Julia Lawall
2011-08-04 18:05   ` Nicholas A. Bellinger
2011-08-02 10:35 ` [PATCH 10/11] arch/openrisc/mm/init.c: " Julia Lawall
2011-08-02 13:55   ` Jonas Bonn
2011-08-02 10:35 ` [PATCH 11/11] arch/tile/mm/init.c: " Julia Lawall
2011-08-02 20:28   ` Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox