Staging: dgnc: Clean up Macros
PATCH 1/1 Staging: dgnc: Clean up Macros
Fix checkpatch warning: Macros with flow control statements should be avoided
Because Macros with flow control statements (goto and return) are not very nice to read as any flow movement is unexpected.
--- drivers/staging/dgnc/dgnc_sysfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/staging/dgnc/dgnc_sysfs.c +10 -10
@@ -90,16 +90,16 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)driver_remove_file (driverfs, &driver_attr_pollrate); } -#define DGNC_VERIFY_BOARD (p, bd) \ - do { \ - if (!p) \ - return 0; \ - \ - bd = dev_get_drvdata(p); \ - if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ - return 0; \ - if (bd->state != BOARD_READY) \ - return 0; \ +#define DGNC_VERIFY_BOARD (p, bd) +do { +if (!p) +return 0 ; + + bd =dev_get_drvdata (p); +if (!bd || bd->magic !=DGNC_BOARD_MAGIC ) +return 0 ; +if (bd->state !=BOARD_READY ) +return 0 ; } while (0) static ssize_t vpd_show(struct device *p, struct device_attribute *attr,
Signature · 1 line
2.7.4
Quoted 29 lines · Siddhi Dave
Fix checkpatch warning: Macros with flow control statements should be avoided
Because Macros with flow control statements (goto and return) are not very nice to read as any flow movement is unexpected.
Signed-off-by Siddhi Dave <[email protected]>--- drivers/staging/dgnc/dgnc_sysfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/staging/dgnc/dgnc_sysfs.c +1
-10@@ -90,16 +90,16 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)driver_remove_file (driverfs, &driver_attr_pollrate); } -#define DGNC_VERIFY_BOARD (p, bd) \ - do { \ - if (!p) \ - return 0; \ - \ - bd = dev_get_drvdata(p); \ - if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ - return 0; \ - if (bd->state != BOARD_READY) \ - return 0; \ +#define DGNC_VERIFY_BOARD (p, bd)
drivers/staging/dgnc/dgnc_sysfs.c void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) · line 103
Quoted 10 lines
drivers/staging/dgnc/dgnc_sysfs.c +9
-0+do { +if (!p) +return 0 ; + + bd =dev_get_drvdata (p); +if (!bd || bd->magic !=DGNC_BOARD_MAGIC ) +return 0 ; +if (bd->state !=BOARD_READY ) +return 0 ; }while (0 )
This does not look correct. You are still sort of defining a macro, except that you have dropped all of the \s. A macro has to be defined on a single line, or a line continued with \, so this would cause major syntax errors. I think that someone else worked on similar code and found that some of the tests were also not needed in the context in which this code is used.
julia
Quoted 12 lines
drivers/staging/dgnc/dgnc_sysfs.c +0
-1static ssize_t vpd_show(struct device *p, struct device_attribute *attr, --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/20161016124231.GA18162%40siddhi-home-laptop.
For more options, visit https://groups.google.com/d/optout.
Greg KH
maintainerQuoted 31 lines · Siddhi Dave
Fix checkpatch warning: Macros with flow control statements should be avoided
Because Macros with flow control statements (goto and return) are not very nice to read as any flow movement is unexpected.
Signed-off-by Siddhi Dave <[email protected]>--- drivers/staging/dgnc/dgnc_sysfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/staging/dgnc/dgnc_sysfs.c +3
-10@@ -90,16 +90,16 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)driver_remove_file (driverfs, &driver_attr_pollrate); } -#define DGNC_VERIFY_BOARD (p, bd) \ - do { \ - if (!p) \ - return 0; \ - \ - bd = dev_get_drvdata(p); \ - if (!bd || bd->magic != DGNC_BOARD_MAGIC) \ - return 0; \ - if (bd->state != BOARD_READY) \ - return 0; \ +#define DGNC_VERIFY_BOARD (p, bd) +do { + if (!p)
drivers/staging/dgnc/dgnc_sysfs.c void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver) · line 105
Quoted 10 lines
drivers/staging/dgnc/dgnc_sysfs.c +7
-0+return 0 ; + + bd =dev_get_drvdata (p); +if (!bd || bd->magic !=DGNC_BOARD_MAGIC ) +return 0 ; +if (bd->state !=BOARD_READY ) +return 0 ; }while (0 ) static ssize_t vpd_show(struct device *p, struct device_attribute *attr,
You didn't test-build this code, why not?
Also, please see the archives for why this type of change is not going to be correct and I can't take it.
And finally, you sent 3 copies of this, why?
thanks,
greg k-h