Skip to contentSkip to conversation

staging: comedi: Compress return logic into one line.

PATCH In review Varsha Rao 2 participants 2 messages Mar 12, 2017 Staging

lore
Share & tools
lore

Varsha Rao

author
#0 lore raw

PATCH v3 1/1 staging: comedi: Compress return logic into one line.

Simplify function return by merging assignment and return into a single line. The following coccinelle script is used to fix this issue.

@@
expression e;
local idexpression ret;
@@

-ret = e;
-return ret;
+return e;

---
Changes in v3:

- Modified coccinelle script.

Changes in v2:

- It is not a good idea to remove structure member initialisations. As the value of structure members are not limited to scope of the function. So it has not been included in this patch version.

 drivers/staging/comedi/drivers/cb_pcidas64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/cb_pcidas64.c +1 -3
index 3b98193..b761f00 100644
@@ -1417,9 +1417,7 @@ static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
 	if (retval < 0)
 		return retval;
 
-	num_samples = retval * fifo->num_segments * fifo->sample_packing_ratio;
-
-	return num_samples;
+	return retval * fifo->num_segments * fifo->sample_packing_ratio;
 }
 
 /* query length of fifo */
Signature · 1 line
2.9.3
Acked-by on v3 1/1
#1 lore raw
Quoted 12 lines · Varsha Rao

Simplify function return by merging assignment and return into a single line. The following coccinelle script is used to fix this issue.

@@
expression e;
local idexpression ret;
@@

(quoted diff) +1 -2
-ret = e;
-return ret;
+return e;
Quoted 1 line
Quoted 39 lines

---
Changes in v3:

- Modified coccinelle script.

Changes in v2:

- It is not a good idea to remove structure member initialisations. As the value of structure members are not limited to scope of the function. So it has not been included in this patch version.

 drivers/staging/comedi/drivers/cb_pcidas64.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/staging/comedi/drivers/cb_pcidas64.c +1 -4
index 3b98193..b761f00 100644
@@ -1417,9 +1417,7 @@ static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
 	if (retval < 0)
 		return retval;
 
-	num_samples = retval * fifo->num_segments * fifo->sample_packing_ratio;
-
-	return num_samples;
+	return retval * fifo->num_segments * fifo->sample_packing_ratio;
 }
 
 /* query length of fifo */
--

2.9.3

--
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/58c5643a.d30d620a.814ee.7d75%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.