drivers/input/touchscreen/ads7846.c:705:24: warning: taking address of packed member 'data' of class or structure 'ads7846_buf' may result in an unaligned pointer value

From: kernel test robot
Date: Mon May 03 2021 - 19:16:55 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5e321ded302da4d8c5d5dd953423d9b748ab3775
commit: 6965eece2a89c3f1d00881c6052ee1e987870c08 Input: ads7846 - convert to one message
date: 3 months ago
config: mips-randconfig-r026-20210504 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 8f5a2a5836cc8e4c1def2bdeb022e7b496623439)
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
# install mips cross compiling tool for clang build
# apt-get install binutils-mips-linux-gnu
# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6965eece2a89c3f1d00881c6052ee1e987870c08
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 6965eece2a89c3f1d00881c6052ee1e987870c08
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=mips

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

All warnings (new ones prefixed by >>):

# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:20:
In file included from include/linux/sched.h:12:
In file included from ./arch/mips/include/generated/asm/current.h:1:
In file included from include/asm-generic/current.h:5:
In file included from include/linux/thread_info.h:38:
In file included from arch/mips/include/asm/thread_info.h:16:
In file included from arch/mips/include/asm/processor.h:14:
In file included from include/linux/atomic.h:7:
arch/mips/include/asm/atomic.h:257:1: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
ATOMIC_SIP_OP(atomic, int, subu, ll, sc)
^
arch/mips/include/asm/atomic.h:251:7: note: expanded from macro 'ATOMIC_SIP_OP'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:20:
In file included from include/linux/sched.h:12:
In file included from ./arch/mips/include/generated/asm/current.h:1:
In file included from include/asm-generic/current.h:5:
In file included from include/linux/thread_info.h:38:
In file included from arch/mips/include/asm/thread_info.h:16:
In file included from arch/mips/include/asm/processor.h:14:
In file included from include/linux/atomic.h:7:
arch/mips/include/asm/atomic.h:261:1: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
ATOMIC_SIP_OP(atomic64, s64, dsubu, lld, scd)
^
arch/mips/include/asm/atomic.h:251:7: note: expanded from macro 'ATOMIC_SIP_OP'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:20:
In file included from include/linux/sched.h:14:
In file included from include/linux/pid.h:5:
In file included from include/linux/rculist.h:11:
In file included from include/linux/rcupdate.h:29:
In file included from include/linux/lockdep.h:14:
In file included from include/linux/smp.h:15:
In file included from include/linux/smp_types.h:5:
include/linux/llist.h:222:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
return xchg(&head->first, NULL);
^
arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:20:
In file included from include/linux/sched.h:14:
In file included from include/linux/pid.h:5:
In file included from include/linux/rculist.h:11:
In file included from include/linux/rcupdate.h:29:
In file included from include/linux/lockdep.h:27:
include/linux/debug_locks.h:17:9: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
return xchg(&debug_locks, 0);
^
arch/mips/include/asm/cmpxchg.h:102:7: note: expanded from macro 'xchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:31:
In file included from include/linux/spi/spi.h:14:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
cmpxchg64(&buddy->pte, 0, _PAGE_GLOBAL);
^
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:194:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
In file included from drivers/input/touchscreen/ads7846.c:31:
In file included from include/linux/spi/spi.h:14:
In file included from include/linux/scatterlist.h:8:
In file included from include/linux/mm.h:33:
In file included from include/linux/pgtable.h:6:
arch/mips/include/asm/pgtable.h:210:3: warning: converting the result of '<<' to a boolean always evaluates to true [-Wtautological-constant-compare]
arch/mips/include/asm/cmpxchg.h:220:2: note: expanded from macro 'cmpxchg64'
cmpxchg((ptr), (o), (n)); \
^
arch/mips/include/asm/cmpxchg.h:204:7: note: expanded from macro 'cmpxchg'
if (!__SYNC_loongson3_war) \
^
arch/mips/include/asm/sync.h:147:34: note: expanded from macro '__SYNC_loongson3_war'
# define __SYNC_loongson3_war (1 << 31)
^
>> drivers/input/touchscreen/ads7846.c:705:24: warning: taking address of packed member 'data' of class or structure 'ads7846_buf' may result in an unaligned pointer value [-Waddress-of-packed-member]
value = be16_to_cpup(&buf->data);
^~~~~~~~~
13 warnings generated.


vim +705 drivers/input/touchscreen/ads7846.c

700
701 static int ads7846_get_value(struct ads7846_buf *buf)
702 {
703 int value;
704
> 705 value = be16_to_cpup(&buf->data);
706
707 /* enforce ADC output is 12 bits width */
708 return (value >> 3) & 0xfff;
709 }
710

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

Attachment: .config.gz
Description: application/gzip