lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240930202642.GA1497385@thelio-3990X>
Date: Mon, 30 Sep 2024 13:26:42 -0700
From: Nathan Chancellor <nathan@...nel.org>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>
Cc: David Binderman <dcb314@...mail.com>,
	"jagathjog1996@...il.com" <jagathjog1996@...il.com>,
	"jic23@...nel.org" <jic23@...nel.org>,
	"lars@...afoo.de" <lars@...afoo.de>,
	"linux-iio@...r.kernel.org" <linux-iio@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: linux-6.12-rc1/drivers/iio/imu/bmi323/bmi323_core.c:133: Array
 contents defined but not used ?

Hi Javier,

On Mon, Sep 30, 2024 at 06:50:14PM +0200, Javier Carrasco wrote:
> But if that wasn't the case, and since you can't use sizeof(<type>),
> should it be marked with __maybe_unused / __attribute__((unused)) even
> though it's known in advance that it won't be used, or at least that its
> use will be to get its size?

Correct.

> Is it then just to silence the warning, or does it have other
> implications? Thanks again!

Yes, the use of the unused attribute would just be to silence the
warning; the variable would still not be emitted in the final binary.
clang's behavior matches GCC's (aside from the special warning):

https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute

If the variable needed to be emitted in the object file,
__attribute__((used)) would need to be used, which explicitly has code
generation implications:

https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute

A contrived example:

https://godbolt.org/z/oGGbqK98o

Cheers,
Nathan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ