diff mbox series

scsi: qedi: add printf attribute to log function

Message ID 20201221162335.3756353-1-trix@redhat.com
State New
Headers show
Series scsi: qedi: add printf attribute to log function | expand

Commit Message

Tom Rix Dec. 21, 2020, 4:23 p.m. UTC
From: Tom Rix <trix@redhat.com>

Attributing the function allows the compiler to more thoroughly
check the use of the function with -Wformat and similar flags.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/scsi/qedi/qedi_dbg.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Manish Rangankar Dec. 28, 2020, 6:14 a.m. UTC | #1
> -----Original Message-----

> From: trix@redhat.com <trix@redhat.com>

> Sent: Monday, December 21, 2020 9:54 PM

> To: Nilesh Javali <njavali@marvell.com>; Manish Rangankar

> <mrangankar@marvell.com>; jejb@linux.ibm.com;

> martin.petersen@oracle.com

> Cc: GR-QLogic-Storage-Upstream <GR-QLogic-Storage-

> Upstream@marvell.com>; linux-scsi@vger.kernel.org; linux-

> kernel@vger.kernel.org; Tom Rix <trix@redhat.com>

> Subject: [PATCH] scsi: qedi: add printf attribute to log function

> 

> From: Tom Rix <trix@redhat.com>

> 

> Attributing the function allows the compiler to more thoroughly check the

> use of the function with -Wformat and similar flags.

> 

> Signed-off-by: Tom Rix <trix@redhat.com>

> ---

>  drivers/scsi/qedi/qedi_dbg.h | 5 ++++-

>  1 file changed, 4 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/scsi/qedi/qedi_dbg.h b/drivers/scsi/qedi/qedi_dbg.h

> index 37d084086fd4..b2c9b0a2db6a 100644

> --- a/drivers/scsi/qedi/qedi_dbg.h

> +++ b/drivers/scsi/qedi/qedi_dbg.h

> @@ -78,13 +78,16 @@ struct qedi_dbg_ctx {

>  #define QEDI_INFO(pdev, level, fmt, ...)	\

>  		qedi_dbg_info(pdev, __func__, __LINE__, level, fmt,	\

>  			      ## __VA_ARGS__)

> -

> +__printf(4, 5)

>  void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,

>  		  const char *fmt, ...);

> +__printf(4, 5)

>  void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,

>  		   const char *fmt, ...);

> +__printf(4, 5)

>  void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32

> line,

>  		     const char *fmt, ...);

> +__printf(5, 6)

>  void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,

>  		   u32 info, const char *fmt, ...);

> 


Thanks,
Acked-by: Manish Rangankar <mrangankar@marvell.com>
kernel test robot Dec. 28, 2020, 9:37 a.m. UTC | #2
Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next v5.11-rc1 next-20201223]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/trix-redhat-com/scsi-qedi-add-printf-attribute-to-log-function/20201222-002559
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/d3e320669a713151990301b3ed5209a6b684869b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review trix-redhat-com/scsi-qedi-add-printf-attribute-to-log-function/20201222-002559
        git checkout d3e320669a713151990301b3ed5209a6b684869b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_main.c:27:
   drivers/scsi/qedi/qedi_main.c: In function 'qedi_schedule_hw_err_handler':
>> drivers/scsi/qedi/qedi_main.c:1131:5: warning: format '%x' expects argument of type 'unsigned int', but argument 7 has type 'long unsigned int' [-Wformat=]

    1131 |     "HW error handler scheduled, err=%d err_flags=0x%x\n",
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1132 |     err_type, qedi->qedi_err_flags);
         |               ~~~~~~~~~~~~~~~~~~~~
         |                   |
         |                   long unsigned int
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_main.c:1131:54: note: format string is defined here
    1131 |     "HW error handler scheduled, err=%d err_flags=0x%x\n",
         |                                                     ~^
         |                                                      |
         |                                                      unsigned int
         |                                                     %lx
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_main.c:27:
   drivers/scsi/qedi/qedi_main.c: In function 'qedi_alloc_nvm_iscsi_cfg':
>> drivers/scsi/qedi/qedi_main.c:1488:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type 'dma_addr_t' {aka 'unsigned int'} [-Wformat=]

    1488 |     "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_image,
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1489 |     qedi->nvm_buf_dma);
         |     ~~~~~~~~~~~~~~~~~
         |         |
         |         dma_addr_t {aka unsigned int}
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_main.c:1488:33: note: format string is defined here
    1488 |     "NVM BUF addr=0x%p dma=0x%llx.\n", qedi->iscsi_image,
         |                              ~~~^
         |                                 |
         |                                 long long unsigned int
         |                              %x
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_main.c:27:
   drivers/scsi/qedi/qedi_main.c: In function 'qedi_alloc_bdq':
>> drivers/scsi/qedi/qedi_main.c:1585:6: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type '__le32' {aka 'unsigned int'} [-Wformat=]

    1585 |      "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx], idx [%d]\n",
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1586 |      pbl, pbl->address.hi, pbl->address.lo, i);
         |           ~~~~~~~~~~~~~~~
         |                       |
         |                       __le32 {aka unsigned int}
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_main.c:1585:40: note: format string is defined here
    1585 |      "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx], idx [%d]\n",
         |                                     ~~~^
         |                                        |
         |                                        long long unsigned int
         |                                     %x
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_main.c:27:
   drivers/scsi/qedi/qedi_main.c:1585:6: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 8 has type '__le32' {aka 'unsigned int'} [-Wformat=]
    1585 |      "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx], idx [%d]\n",
         |      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    1586 |      pbl, pbl->address.hi, pbl->address.lo, i);
         |                            ~~~~~~~~~~~~~~~
         |                                        |
         |                                        __le32 {aka unsigned int}
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_main.c:1585:52: note: format string is defined here
    1585 |      "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx], idx [%d]\n",
         |                                                 ~~~^
         |                                                    |
         |                                                    long long unsigned int
         |                                                 %x
--
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_fw.c:11:
   drivers/scsi/qedi/qedi_fw.c: In function 'qedi_get_rq_bdq_buf':
>> drivers/scsi/qedi/qedi_fw.c:341:5: warning: format '%p' expects argument of type 'void *', but argument 6 has type 'int' [-Wformat=]

     341 |     "rqe_opaque [0x%p], idx [%d]\n", cqe->rqe_opaque, idx);
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~~~~~~~~~
         |                                         |
         |                                         int
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_fw.c:341:21: note: format string is defined here
     341 |     "rqe_opaque [0x%p], idx [%d]\n", cqe->rqe_opaque, idx);
         |                    ~^
         |                     |
         |                     void *
         |                    %d
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_fw.c:11:
   drivers/scsi/qedi/qedi_fw.c: In function 'qedi_put_rq_bdq_buf':
>> drivers/scsi/qedi/qedi_fw.c:380:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 7 has type '__le32' {aka 'unsigned int'} [-Wformat=]

     380 |     "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx] idx [%d]\n",
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     381 |     pbl, pbl->address.hi, pbl->address.lo, idx);
         |          ~~~~~~~~~~~~~~~
         |                      |
         |                      __le32 {aka unsigned int}
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_fw.c:380:39: note: format string is defined here
     380 |     "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx] idx [%d]\n",
         |                                    ~~~^
         |                                       |
         |                                       long long unsigned int
         |                                    %x
   In file included from drivers/scsi/qedi/qedi.h:19,
                    from drivers/scsi/qedi/qedi_fw.c:11:
   drivers/scsi/qedi/qedi_fw.c:380:5: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 8 has type '__le32' {aka 'unsigned int'} [-Wformat=]
     380 |     "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx] idx [%d]\n",
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     381 |     pbl, pbl->address.hi, pbl->address.lo, idx);
         |                           ~~~~~~~~~~~~~~~
         |                                       |
         |                                       __le32 {aka unsigned int}
   drivers/scsi/qedi/qedi_dbg.h:79:50: note: in definition of macro 'QEDI_INFO'
      79 |   qedi_dbg_info(pdev, __func__, __LINE__, level, fmt, \
         |                                                  ^~~
   drivers/scsi/qedi/qedi_fw.c:380:51: note: format string is defined here
     380 |     "pbl [0x%p] pbl->address hi [0x%llx] lo [0x%llx] idx [%d]\n",
         |                                                ~~~^
         |                                                   |
         |                                                   long long unsigned int
         |                                                %x


vim +1131 drivers/scsi/qedi/qedi_main.c

534bbdf8832ae48 Manish Rangankar 2018-05-22  1120  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1121  void qedi_schedule_hw_err_handler(void *dev,
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1122  				  enum qed_hw_err_type err_type)
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1123  {
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1124  	struct qedi_ctx *qedi = (struct qedi_ctx *)dev;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1125  	unsigned long override_flags = qedi_flags_override;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1126  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1127  	if (override_flags && test_bit(QEDI_ERR_OVERRIDE_EN, &override_flags))
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1128  		qedi->qedi_err_flags = qedi_flags_override;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1129  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1130  	QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_INFO,
f4ba4e55db6db7e Manish Rangankar 2020-09-08 @1131  		  "HW error handler scheduled, err=%d err_flags=0x%x\n",
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1132  		  err_type, qedi->qedi_err_flags);
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1133  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1134  	switch (err_type) {
7dc71ac8eb0bcaa Manish Rangankar 2020-09-24  1135  	case QED_HW_ERR_FAN_FAIL:
7dc71ac8eb0bcaa Manish Rangankar 2020-09-24  1136  		schedule_delayed_work(&qedi->board_disable_work, 0);
7dc71ac8eb0bcaa Manish Rangankar 2020-09-24  1137  		break;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1138  	case QED_HW_ERR_MFW_RESP_FAIL:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1139  	case QED_HW_ERR_HW_ATTN:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1140  	case QED_HW_ERR_DMAE_FAIL:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1141  	case QED_HW_ERR_RAMROD_FAIL:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1142  	case QED_HW_ERR_FW_ASSERT:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1143  		/* Prevent HW attentions from being reasserted */
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1144  		if (test_bit(QEDI_ERR_ATTN_CLR_EN, &qedi->qedi_err_flags))
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1145  			qedi_ops->common->attn_clr_enable(qedi->cdev, true);
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1146  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1147  		if (err_type == QED_HW_ERR_RAMROD_FAIL &&
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1148  		    test_bit(QEDI_ERR_IS_RECOVERABLE, &qedi->qedi_err_flags))
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1149  			qedi_ops->common->recovery_process(qedi->cdev);
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1150  
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1151  		break;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1152  	default:
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1153  		break;
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1154  	}
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1155  }
f4ba4e55db6db7e Manish Rangankar 2020-09-08  1156  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

diff --git a/drivers/scsi/qedi/qedi_dbg.h b/drivers/scsi/qedi/qedi_dbg.h
index 37d084086fd4..b2c9b0a2db6a 100644
--- a/drivers/scsi/qedi/qedi_dbg.h
+++ b/drivers/scsi/qedi/qedi_dbg.h
@@ -78,13 +78,16 @@  struct qedi_dbg_ctx {
 #define QEDI_INFO(pdev, level, fmt, ...)	\
 		qedi_dbg_info(pdev, __func__, __LINE__, level, fmt,	\
 			      ## __VA_ARGS__)
-
+__printf(4, 5)
 void qedi_dbg_err(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 		  const char *fmt, ...);
+__printf(4, 5)
 void qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 		   const char *fmt, ...);
+__printf(4, 5)
 void qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 		     const char *fmt, ...);
+__printf(5, 6)
 void qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 		   u32 info, const char *fmt, ...);