Skip to contentSkip to conversation

staging: rts5208: Remove multiple assignments

PATCH In review Bhaktipriya Shridhar 2 participants 2 messages Feb 23, 2016 – Feb 24, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rts5208: Remove multiple assignments

This patch removes multiple assignments by factorizing them.

This was done with Coccinelle.

@ identifier i1,i2; constant c; @@
- i1=i2=c;
+ i1=c;
+ i2=c;

---
 drivers/staging/rts5208/rtsx_scsi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/staging/rts5208/rtsx_scsi.c +8 -4
index 16284ca..9e1c324 100644
@@ -3025,10 +3025,14 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 		return TRANSPORT_FAILED;
 	}
 
-	if (dev_info_id == 0x15)
-		buf_len = data_len = 0x3A;
-	else
-		buf_len = data_len = 0x6A;
+	if (dev_info_id == 0x15) {
+		buf_len = 0x3A;
+		data_len = 0x3A;
+	}
+	else {
+		buf_len = 0x6A;
+		data_len = 0x6A;
+	}
 
 	buf = kmalloc(buf_len, GFP_KERNEL);
 	if (!buf) {

--
2.1.4

#1 lore raw
Quoted 24 lines · Bhaktipriya Shridhar

This patch removes multiple assignments by factorizing them.

This was done with Coccinelle.

@ identifier i1,i2; constant c; @@
- i1=i2=c;
+ i1=c;
+ i2=c;

---
 drivers/staging/rts5208/rtsx_scsi.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/staging/rts5208/rtsx_scsi.c +0 -2
index 16284ca..9e1c324 100644
@@ -3025,10 +3025,14 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
 		return TRANSPORT_FAILED;
 	}
 
-	if (dev_info_id == 0x15)
-		buf_len = data_len = 0x3A;

drivers/staging/rts5208/rtsx_scsi.c static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) · line 3035

Quoted 10 lines
drivers/staging/rts5208/rtsx_scsi.c +8 -2
-	else
-		buf_len = data_len = 0x6A;
+	if (dev_info_id == 0x15) {
+		buf_len = 0x3A;
+		data_len = 0x3A;
+	}
+	else {
+		buf_len = 0x6A;
+		data_len = 0x6A;
+	}

Maybe it would be better to have an if for initializing buf_len and then initialize data_len afterwards, to the value of buf_len. That would make the connection betwen them more clear.

julia

Quoted 13 lines
drivers/staging/rts5208/rtsx_scsi.c +0 -1
 	buf = kmalloc(buf_len, GFP_KERNEL);
 	if (!buf) {
--

2.1.4

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160223212929.GA24472%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.