* [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
@ 2015-06-12 10:38 dcb
2015-06-12 11:01 ` Peter Maydell
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: dcb @ 2015-06-12 10:38 UTC (permalink / raw)
To: qemu-devel
Public bug reported:
1.
[qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A && (!A
|| B)' is equivalent to 'A || B'
if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
2.
[qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A && (!A
|| B)' is equivalent to 'A || B'
if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
3.
[qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
if (!tpm_pt->tpm_op_canceled ||
(tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
4.
[qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
size<3. 'A && (!A || B)' is equivalent to 'A || B'
if (size > 3
|| (size < 3 && is_q)
|| (size == 3 && !is_q)) {
** Affects: qemu
Importance: Undecided
Status: New
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1464611
Title:
4 * redundant conditions
Status in QEMU:
New
Bug description:
1.
[qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
2.
[qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
3.
[qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
if (!tpm_pt->tpm_op_canceled ||
(tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
4.
[qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
size<3. 'A && (!A || B)' is equivalent to 'A || B'
if (size > 3
|| (size < 3 && is_q)
|| (size == 3 && !is_q)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1464611/+subscriptions
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
@ 2015-06-12 11:01 ` Peter Maydell
2015-06-12 13:03 ` Eric Blake
2015-06-12 15:30 ` [Qemu-devel] [Bug 1464611] " dcb
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2015-06-12 11:01 UTC (permalink / raw)
To: Bug 1464611; +Cc: QEMU Developers
On 12 June 2015 at 11:38, dcb <1464611@bugs.launchpad.net> wrote:
> Public bug reported:
>
>
> 1.
>
> [qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A && (!A
> || B)' is equivalent to 'A || B'
>
> if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
>
> 2.
>
> [qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A && (!A
> || B)' is equivalent to 'A || B'
>
> if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
>
> 3.
>
> [qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
> tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
>
> if (!tpm_pt->tpm_op_canceled ||
> (tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
These three are all straightforward and would look simpler
in their simplified versions...
> 4.
>
> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
> size<3. 'A && (!A || B)' is equivalent to 'A || B'
>
> if (size > 3
> || (size < 3 && is_q)
> || (size == 3 && !is_q)) {
...but I'm less sure about this one. I'm not even sure
what it's trying to suggest this should simplify to:
just dropping "size < 3" is obviously wrong, and the
condition format isn't "A && (!A || B)" either.
thanks
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
2015-06-12 11:01 ` Peter Maydell
@ 2015-06-12 13:03 ` Eric Blake
2015-06-12 13:11 ` Peter Maydell
0 siblings, 1 reply; 7+ messages in thread
From: Eric Blake @ 2015-06-12 13:03 UTC (permalink / raw)
To: Peter Maydell, Bug 1464611; +Cc: QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 1069 bytes --]
On 06/12/2015 05:01 AM, Peter Maydell wrote:
>> 4.
>>
>> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
>> size<3. 'A && (!A || B)' is equivalent to 'A || B'
>>
>> if (size > 3
>> || (size < 3 && is_q)
>> || (size == 3 && !is_q)) {
>
> ...but I'm less sure about this one. I'm not even sure
> what it's trying to suggest this should simplify to:
> just dropping "size < 3" is obviously wrong, and the
> condition format isn't "A && (!A || B)" either.
Let's break it down into the 6 possibilities based on the binary *
ternary conditions being checked:
> 3, is_q => accept
> 3, !is_q => accept
== 3, is_q => reject
== 3, !is_q => accept
< 3, is_q => accept
< 3, !is_q => reject
Here's a shorter conditional with the same properties, but it's gross:
if (size > 3 || (is_q != (size == 3))) {
Too much mental thought to prove it accepts the same set of conditions.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
2015-06-12 13:03 ` Eric Blake
@ 2015-06-12 13:11 ` Peter Maydell
0 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2015-06-12 13:11 UTC (permalink / raw)
To: Eric Blake; +Cc: QEMU Developers, Bug 1464611
On 12 June 2015 at 14:03, Eric Blake <eblake@redhat.com> wrote:
> On 06/12/2015 05:01 AM, Peter Maydell wrote:
>
>>> 4.
>>>
>>> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
>>> size<3. 'A && (!A || B)' is equivalent to 'A || B'
>>>
>>> if (size > 3
>>> || (size < 3 && is_q)
>>> || (size == 3 && !is_q)) {
>>
>> ...but I'm less sure about this one. I'm not even sure
>> what it's trying to suggest this should simplify to:
>> just dropping "size < 3" is obviously wrong, and the
>> condition format isn't "A && (!A || B)" either.
>
> Let's break it down into the 6 possibilities based on the binary *
> ternary conditions being checked:
>
>> 3, is_q => accept
>> 3, !is_q => accept
> == 3, is_q => reject
> == 3, !is_q => accept
> < 3, is_q => accept
> < 3, !is_q => reject
>
> Here's a shorter conditional with the same properties, but it's gross:
>
> if (size > 3 || (is_q != (size == 3))) {
>
> Too much mental thought to prove it accepts the same set of conditions.
Yeah, I think this is the kind of thing where I say "the compiler
should do this simplification if it cares enough" :-)
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [Bug 1464611] Re: 4 * redundant conditions
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
2015-06-12 11:01 ` Peter Maydell
@ 2015-06-12 15:30 ` dcb
2016-10-31 16:35 ` Thomas Huth
2017-01-11 6:44 ` Thomas Huth
3 siblings, 0 replies; 7+ messages in thread
From: dcb @ 2015-06-12 15:30 UTC (permalink / raw)
To: qemu-devel
>These three are all straightforward and would look simpler
>in their simplified versions...
Agreed. The first 3 look valid candidates for simplification.
> 4.
>
> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
> size<3. 'A && (!A || B)' is equivalent to 'A || B'
>
> if (size > 3
> || (size < 3 && is_q)
> || (size == 3 && !is_q)) {
>...but I'm less sure about this one.
Me too. Suggest regard as a false positive from the static analysis tool
and so leave the original code alone.
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1464611
Title:
4 * redundant conditions
Status in QEMU:
New
Bug description:
1.
[qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
2.
[qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
3.
[qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
if (!tpm_pt->tpm_op_canceled ||
(tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
4.
[qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
size<3. 'A && (!A || B)' is equivalent to 'A || B'
if (size > 3
|| (size < 3 && is_q)
|| (size == 3 && !is_q)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1464611/+subscriptions
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [Bug 1464611] Re: 4 * redundant conditions
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
2015-06-12 11:01 ` Peter Maydell
2015-06-12 15:30 ` [Qemu-devel] [Bug 1464611] " dcb
@ 2016-10-31 16:35 ` Thomas Huth
2017-01-11 6:44 ` Thomas Huth
3 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2016-10-31 16:35 UTC (permalink / raw)
To: qemu-devel
Patches have been committed:
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=f96fe6b5c27b9a66dba71
http://git.qemu.org/?p=qemu.git;a=commitdiff;h=5f333d79a4337b390fa41
** Changed in: qemu
Status: New => Fix Committed
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1464611
Title:
4 * redundant conditions
Status in QEMU:
Fix Committed
Bug description:
1.
[qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
2.
[qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
3.
[qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
if (!tpm_pt->tpm_op_canceled ||
(tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
4.
[qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
size<3. 'A && (!A || B)' is equivalent to 'A || B'
if (size > 3
|| (size < 3 && is_q)
|| (size == 3 && !is_q)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1464611/+subscriptions
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [Bug 1464611] Re: 4 * redundant conditions
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
` (2 preceding siblings ...)
2016-10-31 16:35 ` Thomas Huth
@ 2017-01-11 6:44 ` Thomas Huth
3 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2017-01-11 6:44 UTC (permalink / raw)
To: qemu-devel
Released with version 2.8
** Changed in: qemu
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of qemu-
devel-ml, which is subscribed to QEMU.
https://bugs.launchpad.net/bugs/1464611
Title:
4 * redundant conditions
Status in QEMU:
Fix Released
Bug description:
1.
[qemu/hw/block/nvme.c:355]: (style) Redundant condition: sqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
2.
[qemu/hw/block/nvme.c:429]: (style) Redundant condition: cqid. 'A &&
(!A || B)' is equivalent to 'A || B'
if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
3.
[qemu/hw/tpm/tpm_passthrough.c:157]: (style) Redundant condition:
tpm_pt.tpm_op_canceled. 'A && (!A || B)' is equivalent to 'A || B'
if (!tpm_pt->tpm_op_canceled ||
(tpm_pt->tpm_op_canceled && errno != ECANCELED)) {
4.
[qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
size<3. 'A && (!A || B)' is equivalent to 'A || B'
if (size > 3
|| (size < 3 && is_q)
|| (size == 3 && !is_q)) {
To manage notifications about this bug go to:
https://bugs.launchpad.net/qemu/+bug/1464611/+subscriptions
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-01-11 6:55 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
2015-06-12 11:01 ` Peter Maydell
2015-06-12 13:03 ` Eric Blake
2015-06-12 13:11 ` Peter Maydell
2015-06-12 15:30 ` [Qemu-devel] [Bug 1464611] " dcb
2016-10-31 16:35 ` Thomas Huth
2017-01-11 6:44 ` Thomas Huth
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.