Staging: i2o: Move assignment out of if statement
Subsystems (2)
PATCH 1/2 Staging: i2o: Move assignment out of if statement
Checkpatch.pl suggest to avoid assignment in if statement.
This patch moves assignments out of the if statement and place it before the if statement. This is done using following coccinelle script.
@@
expression E1;
identifier p;
statement S;
@@
- if ((p = E1))
+ p = E1;
+ if (p)
S
--- drivers/staging/i2o/bus-osm.c | 3 ++- drivers/staging/i2o/iop.c | 24 ++++++++++++++++-------- drivers/staging/i2o/pci.c | 9 ++++++--- 3 files changed, 24 insertions(+), 12 deletions(-)
drivers/staging/i2o/bus-osm.c +2 -1
@@ -69,7 +69,8 @@ static ssize_t i2o_bus_store_scan(struct device *d,struct i2o_device *i2o_dev =to_i2o_device (d);int rc; -if ((rc =i2o_bus_scan (i2o_dev))) + rc =i2o_bus_scan (i2o_dev); +if (rc)osm_warn ("bus scan failed %d\n" , rc);return count;
drivers/staging/i2o/iop.c +16 -8
@@ -1096,7 +1096,8 @@ int i2o_iop_add(struct i2o_controller *c) {int rc; -if ((rc =device_add (&c->device))) { + rc =device_add (&c->device); +if (rc) {osm_err ("%s: could not add controller\n" , c->name); goto iop_reset; }
@@ -1105,24 +1106,28 @@ int i2o_iop_add(struct i2o_controller *c)osm_info ("%s: This may take a few minutes if there are many devices\n" , c->name); -if ((rc =i2o_iop_activate (c))) { + rc =i2o_iop_activate (c); +if (rc) {osm_err ("%s: could not activate controller\n" , c->name); goto device_del; }osm_debug ("%s: building sys table...\n" , c->name); -if ((rc =i2o_systab_build ())) + rc =i2o_systab_build (); +if (rc) goto device_del;osm_debug ("%s: online controller...\n" , c->name); -if ((rc =i2o_iop_online (c))) + rc =i2o_iop_online (c); +if (rc) goto device_del;osm_debug ("%s: getting LCT...\n" , c->name); -if ((rc =i2o_exec_lct_get (c))) + rc =i2o_exec_lct_get (c); +if (rc) goto device_del;list_add (&c->list, &i2o_controllers);
@@ -1192,13 +1197,16 @@ static int __init i2o_iop_init(void) printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); -if ((rc =i2o_driver_init ())) + rc =i2o_driver_init (); +if (rc) goto exit; -if ((rc =i2o_exec_init ())) + rc =i2o_exec_init (); +if (rc) goto driver_exit; -if ((rc =i2o_pci_init ())) + rc =i2o_pci_init (); +if (rc) goto exec_exit;return 0 ;
drivers/staging/i2o/pci.c +6 -3
@@ -329,7 +329,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENODEV ; } -if ((rc =pci_enable_device (pdev))) { + rc =pci_enable_device (pdev); +if (rc) {printk (KERN_WARNING "i2o: couldn't enable device %s\n" ,pci_name (pdev));return rc;
@@ -410,7 +411,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)#endif } -if ((rc =i2o_pci_alloc (c))) { + rc =i2o_pci_alloc (c); +if (rc) {printk (KERN_ERR "%s: DMA / IO allocation for I2O controller " "failed\n" , c->name); goto free_controller;
@@ -422,7 +424,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto free_pci; } -if ((rc =i2o_iop_add (c))) + rc =i2o_iop_add (c); +if (rc) goto uninstall;if (i960)
Signature · 1 line
1.9.1
PATCH 2/2 Staging: sm750fb: Move assignment out of if statement
Checkpatch.pl suggest to avoid assignment in if statement.
This patch moves assignments out of the if statement and place it before the if statement. This is done using following coccinelle script.
@@
expression E1;
identifier p;
statement S;
@@
- if ((p = E1))
+ p = E1;
+ if (p)
S
--- drivers/staging/sm750fb/sm750_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/sm750fb/sm750_hw.c +2 -1
@@ -44,7 +44,8 @@ int hw_sm750_map(struct lynx_share* share,struct pci_dev* pdev)* successfully * */ -if ((ret =pci_request_region (pdev,1 ,"sm750fb" ))) + ret =pci_request_region (pdev,1 ,"sm750fb" ); +if (ret) {pr_err ("Can not request PCI regions.\n" ); goto exit;
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [Outreachy kernel] [PATCH 2/2] Staging: sm750fb: Move assignment out of if statement
Quoted 16 lines · Somya Anand
Checkpatch.pl suggest to avoid assignment in if statement.
This patch moves assignments out of the if statement and place it before the if statement. This is done using following coccinelle script.
@@
expression E1;
identifier p;
statement S;
@@
- if ((p = E1))
+ p = E1;
+ if (p)
S
Quoted 4 lines
Signed-off-by Somya Anand <[email protected]>--- drivers/staging/sm750fb/sm750_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
Doesn't apply to my tree :(
Re: [Outreachy kernel] [PATCH 2/2] Staging: sm750fb: Move assignment out of if statement
Quoted 17 lines · Greg KH
Quoted 16 lines · Somya Anand
Checkpatch.pl suggest to avoid assignment in if statement.
This patch moves assignments out of the if statement and place it before the if statement. This is done using following coccinelle script.
@@
expression E1;
identifier p;
statement S;
@@
- if ((p = E1))
+ p = E1;
+ if (p)
S
Quoted 7 lines
Quoted 4 lines
Signed-off-by Somya Anand <[email protected]>--- drivers/staging/sm750fb/sm750_hw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)Doesn't apply to my tree :(
Ok I will check it again.
Somya
Actually, i2o is on the way out of the kernel, so there is no point in changing it. There is a list of drivers to avoid here:
http://kernelnewbies.org/Outreachyfirstpatch
julia
Quoted 148 lines · Somya Anand
Checkpatch.pl suggest to avoid assignment in if statement.
This patch moves assignments out of the if statement and place it before the if statement. This is done using following coccinelle script.
@@
expression E1;
identifier p;
statement S;
@@
- if ((p = E1))
+ p = E1;
+ if (p)
SSigned-off-by Somya Anand <[email protected]>--- drivers/staging/i2o/bus-osm.c | 3 ++- drivers/staging/i2o/iop.c | 24 ++++++++++++++++-------- drivers/staging/i2o/pci.c | 9 ++++++--- 3 files changed, 24 insertions(+), 12 deletions(-)drivers/staging/i2o/bus-osm.c +2
-1@@ -69,7 +69,8 @@ static ssize_t i2o_bus_store_scan(struct device *d,struct i2o_device *i2o_dev =to_i2o_device (d);int rc; -if ((rc =i2o_bus_scan (i2o_dev))) + rc =i2o_bus_scan (i2o_dev); +if (rc)osm_warn ("bus scan failed %d\n" , rc);return count;drivers/staging/i2o/iop.c +16
-8@@ -1096,7 +1096,8 @@ int i2o_iop_add(struct i2o_controller *c) {int rc; -if ((rc =device_add (&c->device))) { + rc =device_add (&c->device); +if (rc) {osm_err ("%s: could not add controller\n" , c->name); goto iop_reset; }@@ -1105,24 +1106,28 @@ int i2o_iop_add(struct i2o_controller *c)osm_info ("%s: This may take a few minutes if there are many devices\n" , c->name); -if ((rc =i2o_iop_activate (c))) { + rc =i2o_iop_activate (c); +if (rc) {osm_err ("%s: could not activate controller\n" , c->name); goto device_del; }osm_debug ("%s: building sys table...\n" , c->name); -if ((rc =i2o_systab_build ())) + rc =i2o_systab_build (); +if (rc) goto device_del;osm_debug ("%s: online controller...\n" , c->name); -if ((rc =i2o_iop_online (c))) + rc =i2o_iop_online (c); +if (rc) goto device_del;osm_debug ("%s: getting LCT...\n" , c->name); -if ((rc =i2o_exec_lct_get (c))) + rc =i2o_exec_lct_get (c); +if (rc) goto device_del;list_add (&c->list, &i2o_controllers);@@ -1192,13 +1197,16 @@ static int __init i2o_iop_init(void) printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n"); -if ((rc =i2o_driver_init ())) + rc =i2o_driver_init (); +if (rc) goto exit; -if ((rc =i2o_exec_init ())) + rc =i2o_exec_init (); +if (rc) goto driver_exit; -if ((rc =i2o_pci_init ())) + rc =i2o_pci_init (); +if (rc) goto exec_exit;return 0 ;drivers/staging/i2o/pci.c +6
-4@@ -329,7 +329,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)return -ENODEV ; } -if ((rc =pci_enable_device (pdev))) { + rc =pci_enable_device (pdev); +if (rc) {printk (KERN_WARNING "i2o: couldn't enable device %s\n" ,pci_name (pdev));return rc;@@ -410,7 +411,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)#endif } -if ((rc =i2o_pci_alloc (c))) { + rc =i2o_pci_alloc (c); +if (rc) {printk (KERN_ERR "%s: DMA / IO allocation for I2O controller " "failed\n" , c->name); goto free_controller;@@ -422,7 +424,8 @@ static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) goto free_pci; } -if ((rc =i2o_iop_add (c))) + rc =i2o_iop_add (c); +if (rc) goto uninstall;if (i960) --1.9.1
--
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/1426267392-27533-1-git-send-email-somyaanand214%40gmail.com.
For more options, visit https://groups.google.com/d/optout.