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: <874jaih04p.fsf@alyssa.is>
Date: Tue, 28 May 2024 09:21:58 +0200
From: Alyssa Ross <hi@...ssa.is>
To: Theodore Ts'o <tytso@....edu>
Cc: linux-ext4@...r.kernel.org
Subject: Re: [PATCH] libext2fs: fix unused parameter warnings/errors

"Theodore Ts'o" <tytso@....edu> writes:

> On Mon, May 27, 2024 at 11:15:43AM +0200, Alyssa Ross wrote:
>> This fixes building dependent packages that use -Werror.
>> 
>> Signed-off-by: Alyssa Ross <hi@...ssa.is>
>> ---
>> I'm assuming here that it is actually intentional that these variables 
>> are unused!  I don't understand the code enough to know for sure — 
>> I'm just trying to fix some build regressions after updating e2fsprogs. :)
>
> Well, note that you only get the warning at all if you use
> -Wunused-parameter, "-Wunused -Wextra", or "-Wall -Wextra".  The
> unused-parameter warning is not enabled unless you **really** go out
> of your way to enable it, because it has so many false positives.  The
> gcc maintainers do not enable this insanity even with -Wall, so
> someone really went out of their way to make your life miserable.  :-)

Yeah…
https://github.com/storaged-project/libblockdev/blob/7cd19d14e61c8964187eac99cf276e6c999dc93e/src/plugins/fs/Makefile.am#L5

(In this case it /did/ end up with me having to look at the code and
notice the SIZEOF_SIZE_T bug I sent another patch for, so something
useful did actually come out of it this time…)

> I generally think it's a really bad idea to turn on warnings as if
> they are overdone Christmas tree lights.  However, to accomodate this,
> the normal way to suppress this is via __attribute__(unused).  To do
> this in a portable way to avoid breaking compilers which don't
> understand said attribute:
>
> /* this is usually predfined in some header file like compiler.h */
> #ifdef __GNUC__
> #define EXT2FS_ATTR(x) __attribute__(x)
> #else
> #define EXT2FS_ATTR(x)
> #endif
>
> ...
> _INLINE_ errcode_t ext2fs_resize_mem(unsigned long EXT2FS_ATTR((unused)) old_size,
> 				     unsigned long size, void *ptr)
> ...

Okay, I'll send a v2 using this approach.

> You can also play this game if you really have a huge number of stupid
> gcc warnings that you want to suppress:
>
> /* this is usually predfined in some header file like compiler.h */
> #ifndef __GNUC_PREREQ
> #if defined(__GNUC__) && defined(__GNUC_MINOR__)
> #define __GNUC_PREREQ(maj, min) \
> 	((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
> #else
> #define __GNUC_PREREQ(maj, min) 0
> #endif
> #endif
>
> #if __GNUC_PREREQ (4, 6)
> #pragma GCC diagnostic push
> #pragma GCC diagnostic ignored "-Wunused-function"
> #pragma GCC diagnostic ignored "-Wunused-parameter"
> #endif
>
> ...
>
> #if __GNUC_PREREQ (4, 6)
> #pragma GCC diagnostic pop
> #endif
>
> I do this when I'm defining a lot of inline functions in a header
> file, and some stupid person thinks that -Wunused -Wextra is actually
> a good idea (hint: it's not), and I just want to shut up the
> completely unnecessary warnings.
>
> Cheers,
>
> 					- Ted

Download attachment "signature.asc" of type "application/pgp-signature" (833 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ