[asahilinux:pr/22 95/189] lib/vsprintf.c:1804:30: sparse: sparse: cast to restricted __le32

From: kernel test robot
Date: Thu Apr 28 2022 - 12:17:32 EST


tree: https://github.com/AsahiLinux/linux pr/22
head: 7ee315306d1a3b0da8cf2a53e7f55889d0e7f034
commit: 87176f64712bb42092a6c89189f8b788f36eb70b [95/189] lib/vsprintf: Add support for generic FOURCCs by extending %p4cc
config: powerpc-randconfig-s031-20220427 (https://download.01.org/0day-ci/archive/20220429/202204290013.olXBPppO-lkp@xxxxxxxxx/config)
compiler: powerpc-linux-gcc (GCC) 11.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/AsahiLinux/linux/commit/87176f64712bb42092a6c89189f8b788f36eb70b
git remote add asahilinux https://github.com/AsahiLinux/linux
git fetch --no-tags asahilinux pr/22
git checkout 87176f64712bb42092a6c89189f8b788f36eb70b
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=powerpc SHELL=/bin/bash

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


sparse warnings: (new ones prefixed by >>)
>> lib/vsprintf.c:1804:30: sparse: sparse: cast to restricted __le32
>> lib/vsprintf.c:1807:30: sparse: sparse: cast to restricted __be32

vim +1804 lib/vsprintf.c

1778
1779 static noinline_for_stack
1780 char *fourcc_string(char *buf, char *end, const u32 *fourcc,
1781 struct printf_spec spec, const char *fmt)
1782 {
1783 char output[sizeof("0123 little-endian (0x01234567)")];
1784 char *p = output;
1785 unsigned int i;
1786 bool pix_fmt = false;
1787 u32 orig, val;
1788
1789 if (fmt[1] != 'c')
1790 return error_string(buf, end, "(%p4?)", spec);
1791
1792 if (check_pointer(&buf, end, fourcc, spec))
1793 return buf;
1794
1795 orig = get_unaligned(fourcc);
1796 switch (fmt[2]) {
1797 case 'h':
1798 val = orig;
1799 break;
1800 case 'r':
1801 val = orig = swab32(orig);
1802 break;
1803 case 'l':
> 1804 val = orig = le32_to_cpu(orig);
1805 break;
1806 case 'b':
> 1807 val = orig = be32_to_cpu(orig);
1808 break;
1809 case 'c':
1810 /* Pixel formats are printed LSB-first */
1811 val = swab32(orig & ~BIT(31));
1812 pix_fmt = true;
1813 break;
1814 default:
1815 return error_string(buf, end, "(%p4?)", spec);
1816 }
1817
1818 for (i = 0; i < sizeof(u32); i++) {
1819 unsigned char c = val >> ((3 - i) * 8);
1820
1821 /* Print non-control ASCII characters as-is, dot otherwise */
1822 *p++ = isascii(c) && isprint(c) ? c : '.';
1823 }
1824
1825 if (pix_fmt) {
1826 *p++ = ' ';
1827 strcpy(p, orig & BIT(31) ? "big-endian" : "little-endian");
1828 p += strlen(p);
1829 }
1830
1831 *p++ = ' ';
1832 *p++ = '(';
1833 p = special_hex_number(p, output + sizeof(output) - 2, orig, sizeof(u32));
1834 *p++ = ')';
1835 *p = '\0';
1836
1837 return string(buf, end, output, spec);
1838 }
1839

--
0-DAY CI Kernel Test Service
https://01.org/lkp