[pci:wip/bjorn-vpd-v2 5/9] drivers/pci/vpd.c:89:7: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'unsigned char'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git wip/bjorn-vpd-v2
head:   d4466f3225fe2067d1a815ce03e1ab7abc6c3c28
commit: 49c5c3061498060f93d08a2386503596e0ff14be [5/9] PCI/VPD: Don't check Large Resource Item Names for validity
config: x86_64-randconfig-c001-20210730 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 4f71f59bf3d9914188a11d0c41bedbb339d36ff5)
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://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?id=49c5c3061498060f93d08a2386503596e0ff14be
        git remote add pci https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git
        git fetch --no-tags pci wip/bjorn-vpd-v2
        git checkout 49c5c3061498060f93d08a2386503596e0ff14be
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

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

All warnings (new ones prefixed by >>):

>> drivers/pci/vpd.c:89:7: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'unsigned char' [-Wformat]
                                            tag, off + 1);
                                            ^~~
   include/linux/pci.h:2465:67: note: expanded from macro 'pci_warn'
   #define pci_warn(pdev, fmt, arg...)     dev_warn(&(pdev)->dev, fmt, ##arg)
                                                                  ~~~    ^~~
   include/linux/dev_printk.h:114:33: note: expanded from macro 'dev_warn'
           _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
                                  ~~~     ^~~~~~~~~~~
>> drivers/pci/vpd.c:89:12: warning: data argument not used by format string [-Wformat-extra-args]
                                            tag, off + 1);
                                                 ^
   include/linux/pci.h:2465:67: note: expanded from macro 'pci_warn'
   #define pci_warn(pdev, fmt, arg...)     dev_warn(&(pdev)->dev, fmt, ##arg)
                                                                  ~~~    ^
   include/linux/dev_printk.h:114:33: note: expanded from macro 'dev_warn'
           _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
                                  ~~~     ^
>> drivers/pci/vpd.c:89:7: warning: variable 'tag' is uninitialized when used here [-Wuninitialized]
                                            tag, off + 1);
                                            ^~~
   include/linux/pci.h:2465:67: note: expanded from macro 'pci_warn'
   #define pci_warn(pdev, fmt, arg...)     dev_warn(&(pdev)->dev, fmt, ##arg)
                                                                         ^~~
   include/linux/dev_printk.h:114:33: note: expanded from macro 'dev_warn'
           _dev_warn(dev, dev_fmt(fmt), ##__VA_ARGS__)
                                          ^~~~~~~~~~~
   drivers/pci/vpd.c:79:20: note: initialize the variable 'tag' to silence this warning
                   unsigned char tag;
                                    ^
                                     = '\0'
   3 warnings generated.


vim +89 drivers/pci/vpd.c

    67	
    68	/**
    69	 * pci_vpd_size - determine actual size of Vital Product Data
    70	 * @dev:	pci device struct
    71	 * @old_size:	current assumed size, also maximum allowed size
    72	 */
    73	static size_t pci_vpd_size(struct pci_dev *dev, size_t old_size)
    74	{
    75		size_t off = 0;
    76		unsigned char header[1+2];	/* 1 byte tag, 2 bytes length */
    77	
    78		while (off < old_size && pci_read_vpd(dev, off, 1, header) == 1) {
    79			unsigned char tag;
    80			size_t size;
    81	
    82			if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
    83				goto error;
    84	
    85			if (header[0] & PCI_VPD_LRDT) {
    86				/* Large Resource Data Type Tag */
    87				if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
    88					pci_warn(dev, "failed VPD read at offset %zu\n",
  > 89						 tag, off + 1);
    90					return 0;
    91				}
    92				size = pci_vpd_lrdt_size(header);
    93				if (off + size > PCI_VPD_MAX_SIZE)
    94					goto error;
    95	
    96				off += PCI_VPD_LRDT_TAG_SIZE + size;
    97			} else {
    98				/* Short Resource Data Type Tag */
    99				tag = pci_vpd_srdt_tag(header);
   100				size = pci_vpd_srdt_size(header);
   101				if (size == 0 || off + size > PCI_VPD_MAX_SIZE)
   102					goto error;
   103	
   104				off += PCI_VPD_SRDT_TAG_SIZE + size;
   105				if (tag == PCI_VPD_STIN_END)	/* End tag descriptor */
   106					return off;
   107			}
   108		}
   109		return 0;
   110	
   111	error:
   112		pci_info(dev, "invalid VPD tag %#04x at offset %zu%s\n",
   113			 header[0], off, off == 0 ?
   114			 "; assume missing optional EEPROM" : "");
   115		return 0;
   116	}
   117	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux