mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nick Terrell <terrelln@fb.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nick Terrell <nickrterrell@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	linux-parisc <linux-parisc@vger.kernel.org>,
	Helge Deller <deller@gmx.de>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	kernel test robot <lkp@intel.com>
Subject: Re: [PATCH 1/3] lib: zstd: Fix unused variable warning
Date: Wed, 17 Nov 2021 17:02:08 +0000	[thread overview]
Message-ID: <47A2B47F-CAC5-4DAA-A8FD-1D3E08E7CA73@fb.com> (raw)
In-Reply-To: <CAHk-=wibYLDep=BPrUaw_wuZRDXnq5BVtG-6gLuBq6+3fdMhOQ@mail.gmail.com>



> On Nov 17, 2021, at 8:45 AM, Linus Torvalds <torvalds@linux-foundation.org> wrote:
> 
> On Tue, Nov 16, 2021 at 5:43 PM Nick Terrell <nickrterrell@gmail.com> wrote:
>> 
>> From: Nick Terrell <terrelln@fb.com>
>> 
>> Backport the fix from upstream PR #2838 [0]. Found by the Kernel test
>> robot in [1].
> 
> Ugh. Mind having a better commit message?
> 
> This just tells you that it's a backport. It doesn't actually talk
> about what it fixes.
>
> Yes, the summary line says "Fix unused variable warning", but it
> doesn't talk about why that variable is unused and why it's not
> removed entirely.
> 
> And it's not obvious in the diff either, because the context isn't
> sufficiently large.
> 
> So a comment along the lines of "the variable is only used by an
> 'assert()', so when asserts are disabled the compiler sees no use at
> all" or similar would be appreciated.

Yeah of course, thanks for the review! I’ll put up a fix shortly.

> Of course, the alternative would be to make the backup definition of
> 'assert()' actually evaluate the argument. That's not what the
> standard assert() is supposed to do, but whatever, and the zstd use
> doesn't care.
> 
> So using
> 
>    #define assert(condition) ((void)(condition))
> 
> instead would also fix the warning at least in kernel use (but not
> necessarily outside the kernel - the standard C 'assert.h' is just
> evil).

I totally agree that the standard C assert is not ideal, however I’d
be hesitant to do that in a quick fix. Just because zstd assumes
that asserts are removed from production builds, so there are at
least a few places where it makes potentially expensive function
calls.

I may be able to try something like:

  #define assert(condition) do { if (0) { (void)(condition) } } while (0)

But, the code in the asserts hasn’t yet been tested to build. So we
may run into build issues, like the presence of division, or
dependency on libc.

I’ll take a stab at it, but if it ends up requiring too large of a change,
I will tend to continue with the current approach.

Best,
Nick Terrell

>                  Linus


  reply	other threads:[~2021-11-17 17:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17  1:49 [PATCH 0/3] Fix stack usage on parisc & improve code size bloat Nick Terrell
2021-11-17  1:49 ` [PATCH 1/3] lib: zstd: Fix unused variable warning Nick Terrell
2021-11-17 16:45   ` Linus Torvalds
2021-11-17 17:02     ` Nick Terrell [this message]
2021-11-17  1:49 ` [PATCH 2/3] lib: zstd: Don't inline functions in zstd_opt.c Nick Terrell
2021-11-17  1:49 ` [PATCH 3/3] lib: zstd: Don't add -O3 to cflags Nick Terrell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47A2B47F-CAC5-4DAA-A8FD-1D3E08E7CA73@fb.com \
    --to=terrelln@fb.com \
    --cc=deller@gmx.de \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=nickrterrell@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®