From: Martin Wilck <mwilck@suse.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
Linux SCSI List <linux-scsi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Hannes Reinecke <hare@suse.de>,
James Bottomley <jejb@linux.vnet.ibm.com>,
Xose Vazquez Perez <xose.vazquez@gmail.com>,
Bart Van Assche <Bart.VanAssche@sandisk.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Jonathan Corbet <corbet@lwn.net>,
Randy Dunlap <rdunlap@infradead.org>
Subject: Re: [PATCH v3 1/6] ilog2: create truly constant version for sparse
Date: Wed, 18 Apr 2018 10:12:54 +0200 [thread overview]
Message-ID: <1524039174.3028.24.camel@suse.com> (raw)
In-Reply-To: <CA+55aFxLY2=RVAD8m-3bf4vKWpPKWSmjN_tLVWwb4Y7w81UTbA@mail.gmail.com>
On Tue, 2018-04-17 at 17:07 -0700, Linus Torvalds wrote:
> On Tue, Apr 17, 2018 at 4:35 PM, Martin Wilck <mwilck@suse.com>
> wrote:
> > Sparse emits errors about ilog2() in array indices because of the
> > use of
> > __ilog2_32() and __ilog2_64(),
>
> If sparse warns about it, then presumably gcc with -Wvla warns about
> it too?
No, it doesn't (gcc 7.3.0). -> https://paste.opensuse.org/27471594
It doesn't even warn on an expression like this:
#define SIZE (1<<10)
static int foo[ilog2(SIZE)];
sparse 0.5.2 doesn't warn about that either. It emits "error: bad
integer constant expression" only if ilog2 is used in an array
initializer, like this:
#define SIZE (1<<10)
#define SUBS (1<<5)
static int foo [ilog2(SIZE)] = {
[ilog2(SUBS)] = 0,
};
So maybe I was wrong, and this is actually a false positive in sparse.
> So I suspect that what you'd want is
>
> #define ilog2(n) \
> __builtin_choose_expr(__is_constexpr(n), \
> const_ilog2(n), \
> __builtin_choose_expr(sizeof(n) <= 4, \
> __ilog2_u32(n), \
> __ilog2_u64(n)))
>
> or something. Hmm?
Do you want me to convert the patch to your approach anyway?
Or should I throw this away and report to sparse?
Regards and thanks,
Martin
PS: apologies to all recipients for the broken cc list in my post.
--
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
next prev parent reply other threads:[~2018-04-18 8:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-17 23:35 [PATCH v3 0/6] scsi: handle special return codes for ABORTED COMMAND Martin Wilck
2018-04-17 23:35 ` [PATCH v3 1/6] ilog2: create truly constant version for sparse Martin Wilck
2018-04-18 0:07 ` Linus Torvalds
2018-04-18 8:12 ` Martin Wilck [this message]
2018-04-18 8:30 ` Luc Van Oostenryck
2018-04-18 21:21 ` Linus Torvalds
2018-04-19 8:19 ` Rasmus Villemoes
2018-04-17 23:35 ` [PATCH v3 2/6] scsi: use const_ilog2 for array indices Martin Wilck
2018-04-17 23:35 ` [PATCH v3 3/6] scsi: devinfo: change blist_flag_t to 64bit Martin Wilck
2018-04-17 23:35 ` [PATCH v3 4/6] scsi: devinfo: warn on undefined blist flags Martin Wilck
2018-04-17 23:35 ` [PATCH v3 5/6] scsi: devinfo: add BLIST_RETRY_ITF for EMC Symmetrix Martin Wilck
2018-04-17 23:35 ` [PATCH v3 6/6] scsi: devinfo: BLIST_RETRY_ASC_C1 for Fujitsu ETERNUS Martin Wilck
2018-04-20 23:15 ` [PATCH v3 0/6] scsi: handle special return codes for ABORTED COMMAND Martin K. Petersen
2018-04-23 9:33 ` Martin Wilck
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=1524039174.3028.24.camel@suse.com \
--to=mwilck@suse.com \
--cc=Bart.VanAssche@sandisk.com \
--cc=ard.biesheuvel@linaro.org \
--cc=corbet@lwn.net \
--cc=hare@suse.de \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=rdunlap@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=xose.vazquez@gmail.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;
as well as URLs for NNTP newsgroup(s).