Staging: i4l: No assignment in if statements
PATCH 1/1 Staging: i4l: No assignment in if statements
Does the assignment before the statement 'if'.
Found with Coccinelle:
@r1@
identifier ptr;
expression fn;
statement S;
constant c;
@@
-if ((ptr = fn) < c ) S
+ptr = fn;
+if (ptr < c ) S
--- drivers/staging/i4l/pcbit/callbacks.c | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-)
drivers/staging/i4l/pcbit/callbacks.c +20 -17
@@ -56,9 +56,8 @@ void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan,* - kfree when msg has been sent */ -if ((len =capi_conn_req (cbdata->data.setup.CalledPN, &skb, - chan->proto)) <0 ) - { + len =capi_conn_req (cbdata->data.setup.CalledPN, &skb, chan->proto); +if (len <0 ) {printk ("capi_conn_req failed\n" );return ; }
@@ -89,8 +88,8 @@ void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_conn_active_resp (chan, &skb)) <0 ) - { + len =capi_conn_active_resp (chan, &skb); +if (len <0 ) {printk ("capi_conn_active_req failed\n" );return ; }
@@ -110,10 +109,11 @@ void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan,/* Select protocol */ -if ((len =capi_select_proto_req (chan, &skb,1 /*outgoing*/ )) <0 ) { + len =capi_select_proto_req (chan, &skb,1 ); +if (len <0 ) {printk ("capi_select_proto_req failed\n" );return ; - } + }/*outgoing*/ refnum = last_ref_num++ &0x7fffU ; chan->s_refnum = refnum;
@@ -170,7 +170,8 @@ void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, dev->dev_if->statcallb (&ictl); -if ((len =capi_conn_resp (chan, &skb)) <0 ) { + len =capi_conn_resp (chan, &skb); +if (len <0 ) {printk (KERN_DEBUG "capi_conn_resp failed\n" );return ; }
@@ -194,7 +195,8 @@ void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan,struct sk_buff *skb;int len; -if ((len =capi_conn_active_req (chan, &skb)) <0 ) { + len =capi_conn_active_req (chan, &skb); +if (len <0 ) {printk (KERN_DEBUG "capi_conn_active_req failed\n" );return ; }
@@ -220,11 +222,11 @@ void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan,struct sk_buff *skb;int len; -if ((len =capi_select_proto_req (chan, &skb,0 /*incoming*/ )) <0 ) - { + len =capi_select_proto_req (chan, &skb,0 ); +if (len <0 ) {printk ("capi_select_proto_req failed\n" );return ; - } + }/*incoming*/ refnum = last_ref_num++ &0x7fffU ; chan->s_refnum = refnum;
@@ -247,7 +249,8 @@ void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan,ushort refnum;isdn_ctrl ictl; -if ((len =capi_disc_resp (chan, &skb)) <0 ) { + len =capi_disc_resp (chan, &skb); +if (len <0 ) {printk ("capi_disc_resp failed\n" );return ; }
@@ -275,8 +278,8 @@ void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_disc_req (chan->callref, &skb,CAUSE_NORMAL )) <0 ) - { + len =capi_disc_req (chan->callref, &skb,CAUSE_NORMAL ); +if (len <0 ) {printk ("capi_disc_req failed\n" );return ; }
@@ -318,8 +321,8 @@ void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_activate_transp_req (chan, &skb)) <0 ) - { + len =capi_activate_transp_req (chan, &skb); +if (len <0 ) {printk ("capi_conn_activate_transp_req failed\n" );return ; }
Signature · 1 line
2.7.4
Quoted 1 line · Mihaela Muraru
Does the assignment before the statement 'if'.
Does -> Move.
There are some cases below where a comment got moved around. This is perhaps the fault of Coccinelle, but you should put the comments back where they were.
Review
Quoted 11 lines
Found with Coccinelle:
@r1@
identifier ptr;
expression fn;
statement S;
constant c;
@@(quoted diff) +2
-1-if ((ptr = fn) < c ) S +ptr = fn; +if (ptr < c ) S
Actually, this rule could be:
+ptr=fn;
-if ((ptr=fn) < c)
+if (ptr<c)
S
That is, you don't need toremove and add back S. This may help with the comment issue (not sure).
julia
Quoted 124 lines
Signed-off-by Mihaela Muraru <[email protected]>--- drivers/staging/i4l/pcbit/callbacks.c | 37 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 17 deletions(-)drivers/staging/i4l/pcbit/callbacks.c +20
-18@@ -56,9 +56,8 @@ void cb_out_1(struct pcbit_dev *dev, struct pcbit_chan *chan,* - kfree when msg has been sent */ -if ((len =capi_conn_req (cbdata->data.setup.CalledPN, &skb, - chan->proto)) <0 ) - { + len =capi_conn_req (cbdata->data.setup.CalledPN, &skb, chan->proto); +if (len <0 ) {printk ("capi_conn_req failed\n" );return ; }@@ -89,8 +88,8 @@ void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_conn_active_resp (chan, &skb)) <0 ) - { + len =capi_conn_active_resp (chan, &skb); +if (len <0 ) {printk ("capi_conn_active_req failed\n" );return ; }@@ -110,10 +109,11 @@ void cb_out_2(struct pcbit_dev *dev, struct pcbit_chan *chan,/* Select protocol */ -if ((len =capi_select_proto_req (chan, &skb,1 /*outgoing*/ )) <0 ) { + len =capi_select_proto_req (chan, &skb,1 ); +if (len <0 ) {printk ("capi_select_proto_req failed\n" );return ; - } + }/*outgoing*/ refnum = last_ref_num++ &0x7fffU ; chan->s_refnum = refnum;@@ -170,7 +170,8 @@ void cb_in_1(struct pcbit_dev *dev, struct pcbit_chan *chan, dev->dev_if->statcallb (&ictl); -if ((len =capi_conn_resp (chan, &skb)) <0 ) { + len =capi_conn_resp (chan, &skb); +if (len <0 ) {printk (KERN_DEBUG "capi_conn_resp failed\n" );return ; }@@ -194,7 +195,8 @@ void cb_in_2(struct pcbit_dev *dev, struct pcbit_chan *chan,struct sk_buff *skb;int len; -if ((len =capi_conn_active_req (chan, &skb)) <0 ) { + len =capi_conn_active_req (chan, &skb); +if (len <0 ) {printk (KERN_DEBUG "capi_conn_active_req failed\n" );return ; }@@ -220,11 +222,11 @@ void cb_in_3(struct pcbit_dev *dev, struct pcbit_chan *chan,struct sk_buff *skb;int len; -if ((len =capi_select_proto_req (chan, &skb,0 /*incoming*/ )) <0 ) - { + len =capi_select_proto_req (chan, &skb,0 ); +if (len <0 ) {printk ("capi_select_proto_req failed\n" );return ; - } + }/*incoming*/ refnum = last_ref_num++ &0x7fffU ; chan->s_refnum = refnum;@@ -247,7 +249,8 @@ void cb_disc_1(struct pcbit_dev *dev, struct pcbit_chan *chan,ushort refnum;isdn_ctrl ictl; -if ((len =capi_disc_resp (chan, &skb)) <0 ) { + len =capi_disc_resp (chan, &skb); +if (len <0 ) {printk ("capi_disc_resp failed\n" );return ; }@@ -275,8 +278,8 @@ void cb_disc_2(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_disc_req (chan->callref, &skb,CAUSE_NORMAL )) <0 ) - { + len =capi_disc_req (chan->callref, &skb,CAUSE_NORMAL ); +if (len <0 ) {printk ("capi_disc_req failed\n" );return ; }@@ -318,8 +321,8 @@ void cb_selp_1(struct pcbit_dev *dev, struct pcbit_chan *chan,int len;ushort refnum; -if ((len =capi_activate_transp_req (chan, &skb)) <0 ) - { + len =capi_activate_transp_req (chan, &skb); +if (len <0 ) {printk ("capi_conn_activate_transp_req failed\n" );return ; } --2.7.4
--
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/20161015121929.GA17750%40domino-MS-16Y1.
For more options, visit https://groups.google.com/d/optout.