Skip to contentSkip to conversation

drivers/scsi: Adjust confusing if indentation

PATCH Applied Julia Lawall 4 participants 6 messages Aug 5, 2010 – Aug 9, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 9/42 drivers/scsi: Adjust confusing if indentation

From: Julia Lawall <[email protected]>

Outdent the code following the if.

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

// <smpl>
@r disable braces4@
position p1,p2;
statement S1,S2;
@@

(
if (...) { ... }
|
if (...) S1@p1 S2@p2
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

if (p1[0].column = p2[0].column):
cocci.print_main("branch",p1)
cocci.print_secs("after",p2)
// </smpl>

---
This might be the wrong fix, however it doesn't change the current semantics.

 drivers/scsi/arcmsr/arcmsr_hba.c    |    4 ++--
 drivers/scsi/mpt2sas/mpt2sas_base.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/arcmsr/arcmsr_hba.c +2 -2
index 95a895d..c4e5cdc 100644
@@ -877,8 +877,8 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb,
 	if (!error) {
 		if (acb->devstate[id][lun] = ARECA_RAID_GONE)
 			acb->devstate[id][lun] = ARECA_RAID_GOOD;
-			ccb->pcmd->result = DID_OK << 16;
-			arcmsr_ccb_complete(ccb);
+		ccb->pcmd->result = DID_OK << 16;
+		arcmsr_ccb_complete(ccb);
 	}else{
 		switch (ccb->arcmsr_cdb.DeviceStatus) {
 		case ARCMSR_DEV_SELECT_TIMEOUT: {
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
index 57bcd5c..12faf64 100644
@@ -534,7 +534,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
 		if (event_data->DiscoveryStatus)
 			printk("discovery_status(0x%08x)",
 			    le32_to_cpu(event_data->DiscoveryStatus));
-			printk("\n");
+		printk("\n");
 		return;
 	}
 	case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
#1 lore raw

This should go to Nick Cheng. He would know about the arcmsr driver.

regards,
dan carpenter

Quoted 70 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Outdent the code following the if.

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

// <smpl>
@r disable braces4@
position p1,p2;
statement S1,S2;
@@

(
if (...) { ... }
|
if (...) S1@p1 S2@p2
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

if (p1[0].column = p2[0].column):
cocci.print_main("branch",p1)
cocci.print_secs("after",p2)
// </smpl>

---
This might be the wrong fix, however it doesn't change the current semantics.

 drivers/scsi/arcmsr/arcmsr_hba.c    |    4 ++--
 drivers/scsi/mpt2sas/mpt2sas_base.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/arcmsr/arcmsr_hba.c +2 -2
index 95a895d..c4e5cdc 100644
@@ -877,8 +877,8 @@ static void arcmsr_report_ccb_state(struct AdapterControlBlock *acb,
 	if (!error) {
 		if (acb->devstate[id][lun] = ARECA_RAID_GONE)
 			acb->devstate[id][lun] = ARECA_RAID_GOOD;
-			ccb->pcmd->result = DID_OK << 16;
-			arcmsr_ccb_complete(ccb);
+		ccb->pcmd->result = DID_OK << 16;
+		arcmsr_ccb_complete(ccb);
 	}else{
 		switch (ccb->arcmsr_cdb.DeviceStatus) {
 		case ARCMSR_DEV_SELECT_TIMEOUT: {
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -2
index 57bcd5c..12faf64 100644
@@ -534,7 +534,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
 		if (event_data->DiscoveryStatus)
 			printk("discovery_status(0x%08x)",
 			    le32_to_cpu(event_data->DiscoveryStatus));
-			printk("\n");
+		printk("\n");
 		return;
 	}
 	case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
--

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

#2 lore raw

I agree.

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Friday, August 06, 2010 3:50 PM
To: Julia Lawall
Cc: James E.J. Bottomley; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH 9/42] drivers/scsi: Adjust confusing if indentation

This should go to Nick Cheng. He would know about the arcmsr driver.

regards,
dan carpenter

Quoted 29 lines · Julia Lawall

From: Julia Lawall <[email protected]>

Outdent the code following the if.

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

// <smpl>
@r disable braces4@
position p1,p2;
statement S1,S2;
@@

(
if (...) { ... }
|
if (...) S1@p1 S2@p2
)

@script:python@
p1 << r.p1;
p2 << r.p2;
@@

if (p1[0].column = p2[0].column):
cocci.print_main("branch",p1)
cocci.print_secs("after",p2)
// </smpl>

Quoted 4 lines

---
This might be the wrong fix, however it doesn't change the current

semantics.

Review

Quoted 6 lines
 drivers/scsi/arcmsr/arcmsr_hba.c    |    4 ++--
 drivers/scsi/mpt2sas/mpt2sas_base.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/arcmsr/arcmsr_hba.c

drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_report_ccb_state(struct

Quoted 4 lines

index 95a895d..c4e5cdc 100644

drivers/scsi/arcmsr/arcmsr_hba.c +0 -0
@@ -877,8 +877,8 @@ static void arcmsr_report_ccb_state(struct

AdapterControlBlock *acb,

Review

Quoted 11 lines
drivers/scsi/arcmsr/arcmsr_hba.c +2 -2
 	if (!error) {
 		if (acb->devstate[id][lun] = ARECA_RAID_GONE)
 			acb->devstate[id][lun] = ARECA_RAID_GOOD;
-			ccb->pcmd->result = DID_OK << 16;
-			arcmsr_ccb_complete(ccb);
+		ccb->pcmd->result = DID_OK << 16;
+		arcmsr_ccb_complete(ccb);
 	}else{
 		switch (ccb->arcmsr_cdb.DeviceStatus) {
 		case ARCMSR_DEV_SELECT_TIMEOUT: {
(quoted diff) +0 -0

b/drivers/scsi/mpt2sas/mpt2sas_base.c

Quoted 13 lines

index 57bcd5c..12faf64 100644

drivers/scsi/mpt2sas/mpt2sas_base.c +1 -2
@@ -534,7 +534,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
 		if (event_data->DiscoveryStatus)
 			printk("discovery_status(0x%08x)",
 			    le32_to_cpu(event_data->DiscoveryStatus));
-			printk("\n");
+		printk("\n");
 		return;
 	}
 	case MPI2_EVENT_SAS_BROADCAST_PRIMITIVE:
--
Quoted 1 line

To unsubscribe from this list: send the line "unsubscribe kernel-janitors"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

PATCH 1/1 scsi: mpt2sas: Add space in printk

In reply to Julia Lawall

Add a space in the output:

old:  Discovery: (stop)discovery_status(0x%08x)
new:  Discovery: (stop) discovery_status(0x%08x)

---
This goes on top of Julia's [PATCH 9/42] drivers/scsi: Adjust confusing if indentation

drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
index 12faf64..562b909 100644
@@ -532,7 +532,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER *ioc,
 		    (event_data->ReasonCode = MPI2_EVENT_SAS_DISC_RC_STARTED) ?
 		    "start" : "stop");
 		if (event_data->DiscoveryStatus)
-			printk("discovery_status(0x%08x)",
+			printk(" discovery_status(0x%08x)",
 			    le32_to_cpu(event_data->DiscoveryStatus));
 		printk("\n");
 		return;
#4 lore raw

RE: [PATCH] scsi: mpt2sas: Add space in printk

Quoted 29 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Friday, August 06, 2010 1:29 PM
To: Julia Lawall
Cc: James E.J. Bottomley; [email protected]; linux- [email protected]; [email protected]; Moore, Eric; Desai, Kashyap
Subject: [PATCH] scsi: mpt2sas: Add space in printk

Add a space in the output:

old:  Discovery: (stop)discovery_status(0x%08x)
new:  Discovery: (stop) discovery_status(0x%08x)

---
This goes on top of Julia's [PATCH 9/42] drivers/scsi: Adjust confusing if indentation

drivers/scsi/mpt2sas/mpt2sas_base.c +0 -0
index 12faf64..562b909 100644
@@ -532,7 +532,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER
 *ioc,
 		    (event_data->ReasonCode ==

MPI2_EVENT_SAS_DISC_RC_STARTED) ?

drivers/scsi/mpt2sas/mpt2sas_base.c _base_display_event_data(struct MPT2SAS_ADAPTER *ioc, · line 535

Quoted 4 lines
drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
 		    "start" : "stop");
 		if (event_data->DiscoveryStatus)
-			printk("discovery_status(0x%08x)",
+			printk(" discovery_status(0x%08x)",

I don't see any significant reason for changing print. It not adding any benefit. Thanks, Kashyap

Quoted 3 lines
drivers/scsi/mpt2sas/mpt2sas_base.c +0 -0
 			    le32_to_cpu(event_data->DiscoveryStatus));
 		printk("\n");
 		return;
#5 lore raw

RE: [PATCH] scsi: mpt2sas: Add space in printk

Quoted 20 lines · Kashyap
Quoted 20 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Friday, August 06, 2010 1:29 PM
To: Julia Lawall
Cc: James E.J. Bottomley; [email protected]; linux- [email protected]; [email protected]; Moore, Eric; Desai, Kashyap
Subject: [PATCH] scsi: mpt2sas: Add space in printk

Add a space in the output:

old:  Discovery: (stop)discovery_status(0x%08x)
new:  Discovery: (stop) discovery_status(0x%08x)

---
This goes on top of Julia's [PATCH 9/42] drivers/scsi: Adjust confusing if indentation

Quoted 14 lines

drivers/scsi/mpt2sas/mpt2sas_base.c _base_display_event_data(struct MPT2SAS_ADAPTER *ioc, · line 535

Quoted 13 lines
drivers/scsi/mpt2sas/mpt2sas_base.c +0 -0
index 12faf64..562b909 100644
@@ -532,7 +532,7 @@ _base_display_event_data(struct MPT2SAS_ADAPTER
 *ioc,
 		    (event_data->ReasonCode =

MPI2_EVENT_SAS_DISC_RC_STARTED) ?

drivers/scsi/mpt2sas/mpt2sas_base.c +1 -1
 		    "start" : "stop");
 		if (event_data->DiscoveryStatus)
-			printk("discovery_status(0x%08x)",
+			printk(" discovery_status(0x%08x)",

I don't see any significant reason for changing print. It not adding any benefit.

It would look a little nicer to have a space after the ) that is printed by the previous statement.

julia