qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit
@ 2016-10-12 15:18 Thomas Huth
  2016-10-12 15:27 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Thomas Huth @ 2016-10-12 15:18 UTC (permalink / raw)
  To: Keith Busch, qemu-devel; +Cc: qemu-block, qemu-trivial

The condition  '!A || (A && B)' is equivalent to '!A || B'.

Buglink: https://bugs.launchpad.net/qemu/+bug/1464611
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 hw/block/nvme.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hw/block/nvme.c b/hw/block/nvme.c
index cef3bb4..53d9d2e 100644
--- a/hw/block/nvme.c
+++ b/hw/block/nvme.c
@@ -373,7 +373,7 @@ static uint16_t nvme_create_sq(NvmeCtrl *n, NvmeCmd *cmd)
     if (!cqid || nvme_check_cqid(n, cqid)) {
         return NVME_INVALID_CQID | NVME_DNR;
     }
-    if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
+    if (!sqid || !nvme_check_sqid(n, sqid)) {
         return NVME_INVALID_QID | NVME_DNR;
     }
     if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) {
@@ -447,7 +447,7 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeCmd *cmd)
     uint16_t qflags = le16_to_cpu(c->cq_flags);
     uint64_t prp1 = le64_to_cpu(c->prp1);
 
-    if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
+    if (!cqid || !nvme_check_cqid(n, cqid)) {
         return NVME_INVALID_CQID | NVME_DNR;
     }
     if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit
  2016-10-12 15:18 [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit Thomas Huth
@ 2016-10-12 15:27 ` Peter Maydell
  2016-10-14 16:47 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
  2016-10-15 12:41 ` [Qemu-devel] " Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-10-12 15:27 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Keith Busch, QEMU Developers, QEMU Trivial, Qemu-block

On 12 October 2016 at 16:18, Thomas Huth <thuth@redhat.com> wrote:
> The condition  '!A || (A && B)' is equivalent to '!A || B'.
>
> Buglink: https://bugs.launchpad.net/qemu/+bug/1464611
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/block/nvme.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
> index cef3bb4..53d9d2e 100644
> --- a/hw/block/nvme.c
> +++ b/hw/block/nvme.c
> @@ -373,7 +373,7 @@ static uint16_t nvme_create_sq(NvmeCtrl *n, NvmeCmd *cmd)
>      if (!cqid || nvme_check_cqid(n, cqid)) {
>          return NVME_INVALID_CQID | NVME_DNR;
>      }
> -    if (!sqid || (sqid && !nvme_check_sqid(n, sqid))) {
> +    if (!sqid || !nvme_check_sqid(n, sqid)) {
>          return NVME_INVALID_QID | NVME_DNR;
>      }
>      if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) {
> @@ -447,7 +447,7 @@ static uint16_t nvme_create_cq(NvmeCtrl *n, NvmeCmd *cmd)
>      uint16_t qflags = le16_to_cpu(c->cq_flags);
>      uint64_t prp1 = le64_to_cpu(c->prp1);
>
> -    if (!cqid || (cqid && !nvme_check_cqid(n, cqid))) {
> +    if (!cqid || !nvme_check_cqid(n, cqid)) {
>          return NVME_INVALID_CQID | NVME_DNR;
>      }
>      if (!qsize || qsize > NVME_CAP_MQES(n->bar.cap)) {

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] hw/block/nvme: Simplify if-statements a little bit
  2016-10-12 15:18 [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit Thomas Huth
  2016-10-12 15:27 ` Peter Maydell
@ 2016-10-14 16:47 ` Stefan Hajnoczi
  2016-10-15 12:41 ` [Qemu-devel] " Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2016-10-14 16:47 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Keith Busch, qemu-devel, qemu-trivial, qemu-block

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

On Wed, Oct 12, 2016 at 05:18:40PM +0200, Thomas Huth wrote:
> The condition  '!A || (A && B)' is equivalent to '!A || B'.
> 
> Buglink: https://bugs.launchpad.net/qemu/+bug/1464611
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  hw/block/nvme.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit
  2016-10-12 15:18 [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit Thomas Huth
  2016-10-12 15:27 ` Peter Maydell
  2016-10-14 16:47 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
@ 2016-10-15 12:41 ` Michael Tokarev
  2 siblings, 0 replies; 4+ messages in thread
From: Michael Tokarev @ 2016-10-15 12:41 UTC (permalink / raw)
  To: Thomas Huth, Keith Busch, qemu-devel; +Cc: qemu-trivial, qemu-block

12.10.2016 18:18, Thomas Huth wrote:
> The condition  '!A || (A && B)' is equivalent to '!A || B'.

Applied to -trivial, thanks!

/mjt

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-10-15 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-12 15:18 [Qemu-devel] [PATCH] hw/block/nvme: Simplify if-statements a little bit Thomas Huth
2016-10-12 15:27 ` Peter Maydell
2016-10-14 16:47 ` [Qemu-devel] [Qemu-block] " Stefan Hajnoczi
2016-10-15 12:41 ` [Qemu-devel] " Michael Tokarev

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).