aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/lpfc/lpfc_attr.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2016-06-15 16:42:17 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2016-07-20 19:53:07 -0400
commitde8c36bba33380fcc8564e69c039a4b84166e66d (patch)
tree60c6ff48578edf4dbd816d9c94b6780a5cc63585 /drivers/scsi/lpfc/lpfc_attr.c
parent9a6cf881df0293cc1c06d31bcbeda6c23b95dcac (diff)
scsi: lpfc: avoid harmless comparison warning
When building with -Wextra, we get a lot of warnings for the lpfc driver concerning expressions that are always true, starting with: drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_enable_npiv_init': drivers/scsi/lpfc/lpfc_attr.c:2786:77: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_enable_rrq_init': drivers/scsi/lpfc/lpfc_attr.c:2802:76: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_suppress_link_up_init': drivers/scsi/lpfc/lpfc_attr.c:2812:2050: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_log_verbose_init': drivers/scsi/lpfc/lpfc_attr.c:3064:1930: error: comparison of unsigned expression >= 0 is always true [-Werror=type-limits] The code works as intended, but it would be nice to shut up the warning so we don't clutter up build logs with this. Using a separate inline function for it makes it clear to the compiler that the comparison is necessary in the caller but still lets it do the constant-folding. [mkp: fix typo] Signed-off-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Acked-by: James Smart <james.smart@broadcom.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/lpfc/lpfc_attr.c')
-rw-r--r--drivers/scsi/lpfc/lpfc_attr.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index 6793df86a425..f1019908800e 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -1621,6 +1621,11 @@ lpfc_sriov_hw_max_virtfn_show(struct device *dev,
1621 return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn); 1621 return snprintf(buf, PAGE_SIZE, "%d\n", max_nr_virtfn);
1622} 1622}
1623 1623
1624static inline bool lpfc_rangecheck(uint val, uint min, uint max)
1625{
1626 return val >= min && val <= max;
1627}
1628
1624/** 1629/**
1625 * lpfc_param_show - Return a cfg attribute value in decimal 1630 * lpfc_param_show - Return a cfg attribute value in decimal
1626 * 1631 *
@@ -1698,7 +1703,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1698static int \ 1703static int \
1699lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \ 1704lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1700{ \ 1705{ \
1701 if (val >= minval && val <= maxval) {\ 1706 if (lpfc_rangecheck(val, minval, maxval)) {\
1702 phba->cfg_##attr = val;\ 1707 phba->cfg_##attr = val;\
1703 return 0;\ 1708 return 0;\
1704 }\ 1709 }\
@@ -1733,7 +1738,7 @@ lpfc_##attr##_init(struct lpfc_hba *phba, uint val) \
1733static int \ 1738static int \
1734lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \ 1739lpfc_##attr##_set(struct lpfc_hba *phba, uint val) \
1735{ \ 1740{ \
1736 if (val >= minval && val <= maxval) {\ 1741 if (lpfc_rangecheck(val, minval, maxval)) {\
1737 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \ 1742 lpfc_printf_log(phba, KERN_ERR, LOG_INIT, \
1738 "3052 lpfc_" #attr " changed from %d to %d\n", \ 1743 "3052 lpfc_" #attr " changed from %d to %d\n", \
1739 phba->cfg_##attr, val); \ 1744 phba->cfg_##attr, val); \
@@ -1857,7 +1862,7 @@ lpfc_##attr##_show(struct device *dev, struct device_attribute *attr, \
1857static int \ 1862static int \
1858lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \ 1863lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1859{ \ 1864{ \
1860 if (val >= minval && val <= maxval) {\ 1865 if (lpfc_rangecheck(val, minval, maxval)) {\
1861 vport->cfg_##attr = val;\ 1866 vport->cfg_##attr = val;\
1862 return 0;\ 1867 return 0;\
1863 }\ 1868 }\
@@ -1889,7 +1894,7 @@ lpfc_##attr##_init(struct lpfc_vport *vport, uint val) \
1889static int \ 1894static int \
1890lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \ 1895lpfc_##attr##_set(struct lpfc_vport *vport, uint val) \
1891{ \ 1896{ \
1892 if (val >= minval && val <= maxval) {\ 1897 if (lpfc_rangecheck(val, minval, maxval)) {\
1893 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \ 1898 lpfc_printf_vlog(vport, KERN_ERR, LOG_INIT, \
1894 "3053 lpfc_" #attr \ 1899 "3053 lpfc_" #attr \
1895 " changed from %d (x%x) to %d (x%x)\n", \ 1900 " changed from %d (x%x) to %d (x%x)\n", \