From: David Sterba <dsterba@suse.cz>
To: Nikolay Borisov <nborisov@suse.com>
Cc: Arnd Bergmann <arnd@arndb.de>, Chris Mason <clm@fb.com>,
Josef Bacik <josef@toxicpanda.com>,
Nathan Chancellor <natechancellor@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
clang-built-linux@googlegroups.com,
Liu Bo <bo.liu@linux.alibaba.com>,
Anand Jain <Anand.Jain@oracle.com>,
Filipe Manana <FdManana@suse.com>, WenRuo Qu <wqu@suse.com>,
Johannes Thumshirn <jthumshirn@suse.de>,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] btrfs: use BUG() instead of BUG_ON(1)
Date: Mon, 25 Mar 2019 14:13:05 +0100 [thread overview]
Message-ID: <20190325131305.GD10640@suse.cz> (raw)
In-Reply-To: <78cd318c-2094-87ca-4843-46af5e3d11ef@suse.com>
On Mon, Mar 25, 2019 at 03:06:12PM +0200, Nikolay Borisov wrote:
>
>
> On 25.03.19 г. 15:02 ч., Arnd Bergmann wrote:
> > BUG_ON(1) leads to bogus warnings from clang when
> > CONFIG_PROFILE_ANNOTATED_BRANCHES is set:
> >
> > fs/btrfs/volumes.c:5041:3: error: variable 'max_chunk_size' is used uninitialized whenever 'if' condition is false
> > [-Werror,-Wsometimes-uninitialized]
> > BUG_ON(1);
> > ^~~~~~~~~
> > include/asm-generic/bug.h:61:36: note: expanded from macro 'BUG_ON'
> > #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
> > ^~~~~~~~~~~~~~~~~~~
> > include/linux/compiler.h:48:23: note: expanded from macro 'unlikely'
> > # define unlikely(x) (__branch_check__(x, 0, __builtin_constant_p(x)))
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > fs/btrfs/volumes.c:5046:9: note: uninitialized use occurs here
> > max_chunk_size);
> > ^~~~~~~~~~~~~~
> > include/linux/kernel.h:860:36: note: expanded from macro 'min'
> > #define min(x, y) __careful_cmp(x, y, <)
> > ^
> > include/linux/kernel.h:853:17: note: expanded from macro '__careful_cmp'
> > __cmp_once(x, y, __UNIQUE_ID(__x), __UNIQUE_ID(__y), op))
> > ^
> > include/linux/kernel.h:847:25: note: expanded from macro '__cmp_once'
> > typeof(y) unique_y = (y); \
> > ^
> > fs/btrfs/volumes.c:5041:3: note: remove the 'if' if its condition is always true
> > BUG_ON(1);
> > ^
> > include/asm-generic/bug.h:61:32: note: expanded from macro 'BUG_ON'
> > #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
> > ^
> > fs/btrfs/volumes.c:4993:20: note: initialize the variable 'max_chunk_size' to silence this warning
> > u64 max_chunk_size;
> > ^
> > = 0
> >
> > Change it to BUG() so clang can see that this code path can never
> > continue.
>
> Long-term we have to eliminate to bug_on's but until then:
I think in those places it's "this must never happen", so it's not the
the typical example of BUG_ON misuse we want to eliminate. Fixing the
compiler waring is ok though.
prev parent reply other threads:[~2019-03-25 13:11 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-25 13:02 [PATCH] btrfs: use BUG() instead of BUG_ON(1) Arnd Bergmann
2019-03-25 13:06 ` Nikolay Borisov
2019-03-25 13:13 ` David Sterba [this message]
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=20190325131305.GD10640@suse.cz \
--to=dsterba@suse.cz \
--cc=Anand.Jain@oracle.com \
--cc=FdManana@suse.com \
--cc=arnd@arndb.de \
--cc=bo.liu@linux.alibaba.com \
--cc=clang-built-linux@googlegroups.com \
--cc=clm@fb.com \
--cc=josef@toxicpanda.com \
--cc=jthumshirn@suse.de \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=nborisov@suse.com \
--cc=ndesaulniers@google.com \
--cc=wqu@suse.com \
/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