Skip to contentSkip to conversation

staging: comedi: Compress return logic into one line.

PATCH Superseded Varsha Rao 2 participants 2 messages Mar 12, 2017 Staging

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Varsha Rao

author
#0 lore raw

PATCH v2 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,ret;
@@

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

---
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
#1 lore raw
Quoted 5 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,ret;

If you change the declaration of ret from expression to local idexpression, then you will be perfectly safe. Coccinelle will only report on cases where the variable is local.

julia

Quoted 42 lines

@@

(quoted diff) +1 -2
-ret = e;
-return ret;
+return e;

---
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/58c55fcb.cb2a620a.8e3bd.8223%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.