From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C326E7E0 for ; Tue, 26 Jul 2022 08:07:47 +0000 (UTC) Received: by mail-ed1-f50.google.com with SMTP id f15so8335286edc.4 for ; Tue, 26 Jul 2022 01:07:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tPpfPzEfkaH/DAxlv4YpUMCrqo4JJIKHjJP/Tdj1qsc=; b=ZTDShWMSIpO+K5aDdsP3PaORf+TOqh67JQ2rXzK0jh9LoBDfAiELXAfWeBtWdjLlAv UUO9Lq3cAe/0PGrQVj7nKz4GQbSZcJ82lUqMen2NU/9dn7F9ip6UX8oL8zXBrjJoD5Mh fstJDoVK1Wns8OoPmkoooRSoJaRJ2ZqZxGVKy5yl2Rq9sEo5WOsPlUmqNqg147s8M6UG s/eCPigRwpaQw3CYpFVxvMVIfAXtYL4nUeF29ZLMhWnumW/JGYB2tvo6j0o23RzQRlIi 382mO0J/d3g+GfzjrvVBUhta4/1p1U2XIJuBuhVhJvYIqeu1cZLnX/K1JDlBNZyVJFpm QSUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tPpfPzEfkaH/DAxlv4YpUMCrqo4JJIKHjJP/Tdj1qsc=; b=mODO5LcfkkXUGf1Nu7LxmRdE66nzv7sL5gOySCYCyMqB+ohA0rWCUJhsSQsyqX1i0r eO1a/TlQYdWpVS5/6hBi/4ja2DOQKtdBymGsQQ/2v+9Pn5nNSpC3psWzzcxQX0Dq/JPr meHjG73p9ASLrbSM0LNXTEQ/3bVs4QYNjq+WasyDh8wtHalB2aaAy0eq3hqVAFz+OLhB 3I5uhfEkKj9KzSgTNFx/inz9JZvNoSA6ADBDGM1pZRCvaXifTjGuC9ooSFcbfSQMcvbm 1oBe+3dxmN+VnGroGUPdprIKdqS4jXmo8RiQ+Z9wd8ftBn/BMEbG4awU+yqmvEyN3ci3 eRYQ== X-Gm-Message-State: AJIora9MrUKm05C6uAheJolQlH9zC2Er7ql44PhRaSGIG2L7DyWZQEA3 397OVeRllArWbzKrdRfkxkg8Zi6yOCNJ5r+r4JE= X-Google-Smtp-Source: AGRyM1va5bJezG2AlV7JDDBBM0PCq1kn7W/ABDMasJ//2+C5ERRcQOFVfGw0sNfXmhwcJb/v8gYhV+jxHi07WE3KWMo= X-Received: by 2002:a05:6402:34c5:b0:43a:8f90:e643 with SMTP id w5-20020a05640234c500b0043a8f90e643mr16958490edc.88.1658822865859; Tue, 26 Jul 2022 01:07:45 -0700 (PDT) Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <202207251140.M7YAqoLC-lkp@intel.com> In-Reply-To: <202207251140.M7YAqoLC-lkp@intel.com> From: Andy Shevchenko Date: Tue, 26 Jul 2022 10:07:09 +0200 Message-ID: Subject: Re: drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed member 'data' of class or structure 'tsc2046_adc_atom' may result in an unaligned pointer value To: kernel test robot , Nathan Chancellor , Nick Desaulniers Cc: Oleksij Rempel , llvm@lists.linux.dev, kbuild-all@lists.01.org, Linux Kernel Mailing List , Jonathan Cameron Content-Type: text/plain; charset="UTF-8" Seems yet another false positive from Clang. On Mon, Jul 25, 2022 at 5:55 AM kernel test robot wrote: > > Hi Oleksij, > > FYI, the error/warning still remains. > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > head: e0dccc3b76fb35bb257b4118367a883073d7390e > commit: 9374e8f5a38defe90bc65b2decf317c1c62d91dd iio: adc: add ADC driver for the TI TSC2046 controller > date: 1 year, 2 months ago > config: arm-randconfig-r025-20220724 (https://download.01.org/0day-ci/archive/20220725/202207251140.M7YAqoLC-lkp@intel.com/config) > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 9e88cbcc403bdf82f29259ad60ff60a8fc4434a1) > 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 arm cross compiling tool for clang build > # apt-get install binutils-arm-linux-gnueabi > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9374e8f5a38defe90bc65b2decf317c1c62d91dd > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git > git fetch --no-tags linus master > git checkout 9374e8f5a38defe90bc65b2decf317c1c62d91dd > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/iio/adc/ drivers/staging/ fs/ > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot > > All warnings (new ones prefixed by >>): > > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed member 'data' of class or structure 'tsc2046_adc_atom' may result in an unaligned pointer value [-Waddress-of-packed-member] What the heck? The get_unaligned_*() is exactly to get unaligned data. > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&buf->data)); > ^~~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) > include/linux/compiler_types.h:308:9: note: expanded from macro '__compiletime_assert' > if (!(condition)) \ > ^~~~~~~~~ > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^~~~ > include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^~~~ > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed member 'data' of class or structure 'tsc2046_adc_atom' may result in an unaligned pointer value [-Waddress-of-packed-member] > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&buf->data)); > ^~~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) > include/linux/compiler_types.h:308:9: note: expanded from macro '__compiletime_assert' > if (!(condition)) \ > ^~~~~~~~~ > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^~~~ > include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^~~~ > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed member 'data' of class or structure 'tsc2046_adc_atom' may result in an unaligned pointer value [-Waddress-of-packed-member] > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&buf->data)); > ^~~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all) > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) ) > ^~~~ > include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond)) > ^~~~ > include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_value' > (cond) ? \ > ^~~~ > 3 warnings generated. > > > vim +242 drivers/iio/adc/ti-tsc2046.c > > 239 > 240 static u16 tsc2046_adc_get_value(struct tsc2046_adc_atom *buf) > 241 { > > 242 return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&buf->data)); > 243 } -- With Best Regards, Andy Shevchenko From mboxrd@z Thu Jan 1 00:00:00 1970 Content-Type: multipart/mixed; boundary="===============0182982335946304119==" MIME-Version: 1.0 From: Andy Shevchenko To: kbuild-all@lists.01.org Subject: Re: drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed member 'data' of class or structure 'tsc2046_adc_atom' may result in an unaligned pointer value Date: Tue, 26 Jul 2022 10:07:09 +0200 Message-ID: In-Reply-To: <202207251140.M7YAqoLC-lkp@intel.com> List-Id: --===============0182982335946304119== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Seems yet another false positive from Clang. On Mon, Jul 25, 2022 at 5:55 AM kernel test robot wrote: > > Hi Oleksij, > > FYI, the error/warning still remains. > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.gi= t master > head: e0dccc3b76fb35bb257b4118367a883073d7390e > commit: 9374e8f5a38defe90bc65b2decf317c1c62d91dd iio: adc: add ADC driver= for the TI TSC2046 controller > date: 1 year, 2 months ago > config: arm-randconfig-r025-20220724 (https://download.01.org/0day-ci/arc= hive/20220725/202207251140.M7YAqoLC-lkp(a)intel.com/config) > compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 9e88= cbcc403bdf82f29259ad60ff60a8fc4434a1) > reproduce (this is a W=3D1 build): > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbi= n/make.cross -O ~/bin/make.cross > chmod +x ~/bin/make.cross > # install arm cross compiling tool for clang build > # apt-get install binutils-arm-linux-gnueabi > # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.= git/commit/?id=3D9374e8f5a38defe90bc65b2decf317c1c62d91dd > git remote add linus https://git.kernel.org/pub/scm/linux/kernel/= git/torvalds/linux.git > git fetch --no-tags linus master > git checkout 9374e8f5a38defe90bc65b2decf317c1c62d91dd > # save the config file > mkdir build_dir && cp config build_dir/.config > COMPILER_INSTALL_PATH=3D$HOME/0day COMPILER=3Dclang make.cross W= =3D1 O=3Dbuild_dir ARCH=3Darm SHELL=3D/bin/bash drivers/iio/adc/ drivers/st= aging/ fs/ > > If you fix the issue, kindly add following tag where applicable > Reported-by: kernel test robot > > All warnings (new ones prefixed by >>): > > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed= member 'data' of class or structure 'tsc2046_adc_atom' may result in an un= aligned pointer value [-Waddress-of-packed-member] What the heck? The get_unaligned_*() is exactly to get unaligned data. > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&bu= f->data)); > ^~= ~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); = \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_= CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, = \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_= ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit= =3D0 to see all) > include/linux/compiler_types.h:308:9: note: expanded from macro '__com= piletime_assert' > if (!(condition)) = \ > ^~~~~~~~~ > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) )= ) > ^~~~ > include/linux/compiler.h:58:52: note: expanded from macro '__trace_if_= var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __= trace_if_value(cond)) > ^~~~ > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed= member 'data' of class or structure 'tsc2046_adc_atom' may result in an un= aligned pointer value [-Waddress-of-packed-member] > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&bu= f->data)); > ^~= ~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); = \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_= CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, = \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_= ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 2 expansions in backtrace; use -fmacro-backtrace-limit= =3D0 to see all) > include/linux/compiler_types.h:308:9: note: expanded from macro '__com= piletime_assert' > if (!(condition)) = \ > ^~~~~~~~~ > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) )= ) > ^~~~ > include/linux/compiler.h:58:61: note: expanded from macro '__trace_if_= var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __= trace_if_value(cond)) > ^~~~ > >> drivers/iio/adc/ti-tsc2046.c:242:62: warning: taking address of packed= member 'data' of class or structure 'tsc2046_adc_atom' may result in an un= aligned pointer value [-Waddress-of-packed-member] > return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be16(&bu= f->data)); > ^~= ~~~~~~~ > include/linux/bitfield.h:108:27: note: expanded from macro 'FIELD_GET' > __BF_FIELD_CHECK(_mask, _reg, 0U, "FIELD_GET: "); = \ > ^~~~ > include/linux/bitfield.h:52:38: note: expanded from macro '__BF_FIELD_= CHECK' > BUILD_BUG_ON_MSG((_mask) > (typeof(_reg))~0ull, = \ > ^~~~ > include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_= ON_MSG' > #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) > ^~~~ > note: (skipping 3 expansions in backtrace; use -fmacro-backtrace-limit= =3D0 to see all) > include/linux/compiler.h:56:47: note: expanded from macro 'if' > #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) )= ) > ^~~~ > include/linux/compiler.h:58:86: note: expanded from macro '__trace_if_= var' > #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __= trace_if_value(cond)) > = ^~~~ > include/linux/compiler.h:69:3: note: expanded from macro '__trace_if_v= alue' > (cond) ? \ > ^~~~ > 3 warnings generated. > > > vim +242 drivers/iio/adc/ti-tsc2046.c > > 239 > 240 static u16 tsc2046_adc_get_value(struct tsc2046_adc_atom *buf) > 241 { > > 242 return FIELD_GET(TI_TSC2046_DATA_12BIT, get_unaligned_be1= 6(&buf->data)); > 243 } -- = With Best Regards, Andy Shevchenko --===============0182982335946304119==--