drivers/net/ethernet/mediatek/mtk_ppe_offload.c:89:19: sparse: sparse: cast to restricted __be32

kernel test robot
2021-12-05T03:44:37Z

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 23b55d673d7527b093cd97b7c217c82e70cd1af0
commit: 502e84e2382d92654a2ecbc52cdbdb5a11cdcec7 net: ethernet: mtk_eth_soc: add flow offloading support
date: 9 months ago
config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20211205/202112051143.BEmnOe4O-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=502e84e2382d92654a2ecbc52cdbdb5a11cdcec7
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 502e84e2382d92654a2ecbc52cdbdb5a11cdcec7
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm SHELL=/bin/bash drivers/dma/ drivers/gpu/drm/msm/ drivers/gpu/drm/tegra/ drivers/interconnect/qcom/ drivers/net/ethernet/mediatek/ drivers/net/vmxnet3/ drivers/net/wireless/mediatek/mt76/mt7915/ drivers/remoteproc/ drivers/scsi/bnx2fc/ drivers/scsi/lpfc/ drivers/staging/ fs/proc/

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

sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/mediatek/mtk_ppe_offload.c:89:19: sparse: sparse: cast to restricted __be32
>> drivers/net/ethernet/mediatek/mtk_ppe_offload.c:93:41: sparse: sparse: restricted __be32 degrades to integer
drivers/net/ethernet/mediatek/mtk_ppe_offload.c:46:10: sparse: sparse: Initializer entry defined twice
drivers/net/ethernet/mediatek/mtk_ppe_offload.c:47:10: sparse: also defined here

vim +89 drivers/net/ethernet/mediatek/mtk_ppe_offload.c

83
84
85 static int
86 mtk_flow_mangle_ports(const struct flow_action_entry *act,
87 struct mtk_flow_data *data)
88 {
> 89 u32 val = ntohl(act->mangle.val);
90
91 switch (act->mangle.offset) {
92 case 0:
> 93 if (act->mangle.mask == ~htonl(0xffff))
94 data->dst_port = cpu_to_be16(val);
95 else
96 data->src_port = cpu_to_be16(val >> 16);
97 break;
98 case 2:
99 data->dst_port = cpu_to_be16(val);
100 break;
101 default:
102 return -EINVAL;
103 }
104
105 return 0;
106 }
107

---
0-DAY CI Kernel Test Service, Intel Corporation