staging: comedi: Compress return logic into one line.
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
@@ -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
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;Signed-off-by Varsha Rao <[email protected]>---
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@@ -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.