diff mbox series

drivers: target: Fix the conversion to bool in iblock_execute_pr_out

Message ID 20230612081006.40821-1-luhongfei@vivo.com (mailing list archive)
State New, archived
Headers show
Series drivers: target: Fix the conversion to bool in iblock_execute_pr_out | expand

Commit Message

Lu Hongfei June 12, 2023, 8:10 a.m. UTC
The return value of the '==' or '!=' operator are bool, so there's
no need to convert it to bool again in iblock_execute_pr_out.

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
---
 drivers/target/target_core_iblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Chaitanya Kulkarni June 12, 2023, 10:04 a.m. UTC | #1
On 6/12/23 01:10, Lu Hongfei wrote:
> The return value of the '==' or '!=' operator are bool, so there's
> no need to convert it to bool again in iblock_execute_pr_out.
>
> Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
> ---
>   drivers/target/target_core_iblock.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
> index 254c33c9788e..ea42cb5d06d4
> --- a/drivers/target/target_core_iblock.c
> +++ b/drivers/target/target_core_iblock.c
> @@ -889,7 +889,7 @@ static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key,
>   
>   		ret = ops->pr_preempt(bdev, key, sa_key,
>   				      scsi_pr_type_to_block(type),
> -				      sa == PRO_PREEMPT ? false : true);
> +				      sa != PRO_PREEMPT);
>   		break;
>   	case PRO_RELEASE:
>   		if (!ops->pr_clear) {

this not a fix as current code is not broken ..

-ck
Konstantin Shelekhin June 13, 2023, 4:01 a.m. UTC | #2
On Mon, Jun 12, 2023 at 10:04:28AM +0000, Chaitanya Kulkarni wrote:
> On 6/12/23 01:10, Lu Hongfei wrote:
> > The return value of the '==' or '!=' operator are bool, so there's
> > no need to convert it to bool again in iblock_execute_pr_out.
> >
> > Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
> > ---
> >   drivers/target/target_core_iblock.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
> > index 254c33c9788e..ea42cb5d06d4
> > --- a/drivers/target/target_core_iblock.c
> > +++ b/drivers/target/target_core_iblock.c
> > @@ -889,7 +889,7 @@ static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key,
> >
> >               ret = ops->pr_preempt(bdev, key, sa_key,
> >                                     scsi_pr_type_to_block(type),
> > -                                   sa == PRO_PREEMPT ? false : true);
> > +                                   sa != PRO_PREEMPT);
> >               break;
> >       case PRO_RELEASE:
> >               if (!ops->pr_clear) {
> 
> this not a fix as current code is not broken ..

It looks much better though. And it's easier to understand.
diff mbox series

Patch

diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index 254c33c9788e..ea42cb5d06d4
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -889,7 +889,7 @@  static sense_reason_t iblock_execute_pr_out(struct se_cmd *cmd, u8 sa, u64 key,
 
 		ret = ops->pr_preempt(bdev, key, sa_key,
 				      scsi_pr_type_to_block(type),
-				      sa == PRO_PREEMPT ? false : true);
+				      sa != PRO_PREEMPT);
 		break;
 	case PRO_RELEASE:
 		if (!ops->pr_clear) {