* [PATCH] nvme: host: core: fix precedence of ternary operator
@ 2018-05-23 14:56 Ivan Bornyakov
2018-05-23 15:07 ` Max Gurtovoy
0 siblings, 1 reply; 3+ messages in thread
From: Ivan Bornyakov @ 2018-05-23 14:56 UTC (permalink / raw)
To: linux-nvme; +Cc: keith.busch, axboe, hch, sagi, linux-kernel, Ivan Bornyakov
Ternary operator have lower precedence then bitwise or, so 'cdw10' was
calculated wrong.
Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
---
drivers/nvme/host/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index b070c659391f..1eba9b0cb9dc 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1577,7 +1577,7 @@ static int nvme_pr_reserve(struct block_device *bdev, u64 key,
static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new,
enum pr_type type, bool abort)
{
- u32 cdw10 = nvme_pr_type(type) << 8 | abort ? 2 : 1;
+ u32 cdw10 = nvme_pr_type(type) << 8 | (abort ? 2 : 1);
return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire);
}
@@ -1589,7 +1589,7 @@ static int nvme_pr_clear(struct block_device *bdev, u64 key)
static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
{
- u32 cdw10 = nvme_pr_type(type) << 8 | key ? 1 << 3 : 0;
+ u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0);
return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
}
--
2.16.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: host: core: fix precedence of ternary operator
2018-05-23 14:56 [PATCH] nvme: host: core: fix precedence of ternary operator Ivan Bornyakov
@ 2018-05-23 15:07 ` Max Gurtovoy
2018-05-23 15:16 ` Keith Busch
0 siblings, 1 reply; 3+ messages in thread
From: Max Gurtovoy @ 2018-05-23 15:07 UTC (permalink / raw)
To: Ivan Bornyakov, linux-nvme; +Cc: axboe, sagi, linux-kernel, keith.busch, hch
On 5/23/2018 5:56 PM, Ivan Bornyakov wrote:
> Ternary operator have lower precedence then bitwise or, so 'cdw10' was
> calculated wrong.
>
> Signed-off-by: Ivan Bornyakov <brnkv.i1@gmail.com>
> ---
> drivers/nvme/host/core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index b070c659391f..1eba9b0cb9dc 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1577,7 +1577,7 @@ static int nvme_pr_reserve(struct block_device *bdev, u64 key,
> static int nvme_pr_preempt(struct block_device *bdev, u64 old, u64 new,
> enum pr_type type, bool abort)
> {
> - u32 cdw10 = nvme_pr_type(type) << 8 | abort ? 2 : 1;
> + u32 cdw10 = nvme_pr_type(type) << 8 | (abort ? 2 : 1);
> return nvme_pr_command(bdev, cdw10, old, new, nvme_cmd_resv_acquire);
> }
>
> @@ -1589,7 +1589,7 @@ static int nvme_pr_clear(struct block_device *bdev, u64 key)
>
> static int nvme_pr_release(struct block_device *bdev, u64 key, enum pr_type type)
> {
> - u32 cdw10 = nvme_pr_type(type) << 8 | key ? 1 << 3 : 0;
> + u32 cdw10 = nvme_pr_type(type) << 8 | (key ? 1 << 3 : 0);
> return nvme_pr_command(bdev, cdw10, key, 0, nvme_cmd_resv_release);
> }
>
>
Looks good,
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: host: core: fix precedence of ternary operator
2018-05-23 15:07 ` Max Gurtovoy
@ 2018-05-23 15:16 ` Keith Busch
0 siblings, 0 replies; 3+ messages in thread
From: Keith Busch @ 2018-05-23 15:16 UTC (permalink / raw)
To: Max Gurtovoy
Cc: Ivan Bornyakov, linux-nvme, axboe, keith.busch, hch, sagi, linux-kernel
Thanks, applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-05-23 15:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-23 14:56 [PATCH] nvme: host: core: fix precedence of ternary operator Ivan Bornyakov
2018-05-23 15:07 ` Max Gurtovoy
2018-05-23 15:16 ` Keith Busch
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).