diff mbox series

[3/3] IB/isert: simplify signature cap check

Message ID 20210110111903.486681-3-mgurtovoy@nvidia.com (mailing list archive)
State Accepted
Delegated to: Jason Gunthorpe
Headers show
Series [1/3] IB/isert: remove unneeded new lines | expand

Commit Message

Max Gurtovoy Jan. 10, 2021, 11:19 a.m. UTC
Use if/else clause instead of "condition ? val1 : val2" to make the code
cleaner and simpler.

Reviewed-by: Israel Rukshin <israelr@nvidia.com>
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
 drivers/infiniband/ulp/isert/ib_isert.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Sagi Grimberg Jan. 14, 2021, 12:08 a.m. UTC | #1
> Use if/else clause instead of "condition ? val1 : val2" to make the code
> cleaner and simpler.

Not sure what is cleaner and simpler for a simple condition, but I don't
mind either way...

Acked-by: Sagi Grimberg <sagi@grimberg.me>
Leon Romanovsky Jan. 14, 2021, 7:29 a.m. UTC | #2
On Wed, Jan 13, 2021 at 04:08:29PM -0800, Sagi Grimberg wrote:
>
> > Use if/else clause instead of "condition ? val1 : val2" to make the code
> > cleaner and simpler.
>
> Not sure what is cleaner and simpler for a simple condition, but I don't
> mind either way...

Agree, probably even more cleaner variant will be:
 device->pi_capable = !!(ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER);

Thanks
Jason Gunthorpe Jan. 14, 2021, 12:49 p.m. UTC | #3
On Thu, Jan 14, 2021 at 09:29:38AM +0200, Leon Romanovsky wrote:
> On Wed, Jan 13, 2021 at 04:08:29PM -0800, Sagi Grimberg wrote:
> >
> > > Use if/else clause instead of "condition ? val1 : val2" to make the code
> > > cleaner and simpler.
> >
> > Not sure what is cleaner and simpler for a simple condition, but I don't
> > mind either way...
> 
> Agree, probably even more cleaner variant will be:
>  device->pi_capable = !!(ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER);

Gah, !! is rarely a sign of something good..

Jason
Max Gurtovoy Jan. 14, 2021, 12:54 p.m. UTC | #4
On 1/14/2021 2:49 PM, Jason Gunthorpe wrote:
> On Thu, Jan 14, 2021 at 09:29:38AM +0200, Leon Romanovsky wrote:
>> On Wed, Jan 13, 2021 at 04:08:29PM -0800, Sagi Grimberg wrote:
>>>> Use if/else clause instead of "condition ? val1 : val2" to make the code
>>>> cleaner and simpler.
>>> Not sure what is cleaner and simpler for a simple condition, but I don't
>>> mind either way...
>> Agree, probably even more cleaner variant will be:
>>   device->pi_capable = !!(ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER);
> Gah, !! is rarely a sign of something good..

can we take the series as-is ?

We have enough Acks and eyes on these minor cleanups.


>
> Jason
Leon Romanovsky Jan. 14, 2021, 12:59 p.m. UTC | #5
On Thu, Jan 14, 2021 at 08:49:39AM -0400, Jason Gunthorpe wrote:
> On Thu, Jan 14, 2021 at 09:29:38AM +0200, Leon Romanovsky wrote:
> > On Wed, Jan 13, 2021 at 04:08:29PM -0800, Sagi Grimberg wrote:
> > >
> > > > Use if/else clause instead of "condition ? val1 : val2" to make the code
> > > > cleaner and simpler.
> > >
> > > Not sure what is cleaner and simpler for a simple condition, but I don't
> > > mind either way...
> >
> > Agree, probably even more cleaner variant will be:
> >  device->pi_capable = !!(ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER);
>
> Gah, !! is rarely a sign of something good..

You see, three of us see same code differently.

>
> Jason
Leon Romanovsky Jan. 14, 2021, 1 p.m. UTC | #6
On Thu, Jan 14, 2021 at 02:54:29PM +0200, Max Gurtovoy wrote:
>
> On 1/14/2021 2:49 PM, Jason Gunthorpe wrote:
> > On Thu, Jan 14, 2021 at 09:29:38AM +0200, Leon Romanovsky wrote:
> > > On Wed, Jan 13, 2021 at 04:08:29PM -0800, Sagi Grimberg wrote:
> > > > > Use if/else clause instead of "condition ? val1 : val2" to make the code
> > > > > cleaner and simpler.
> > > > Not sure what is cleaner and simpler for a simple condition, but I don't
> > > > mind either way...
> > > Agree, probably even more cleaner variant will be:
> > >   device->pi_capable = !!(ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER);
> > Gah, !! is rarely a sign of something good..
>
> can we take the series as-is ?

Of course :)

Thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c
index 96514f675427..7305ed8976c2 100644
--- a/drivers/infiniband/ulp/isert/ib_isert.c
+++ b/drivers/infiniband/ulp/isert/ib_isert.c
@@ -230,8 +230,10 @@  isert_create_device_ib_res(struct isert_device *device)
 	}
 
 	/* Check signature cap */
-	device->pi_capable = ib_dev->attrs.device_cap_flags &
-			     IB_DEVICE_INTEGRITY_HANDOVER ? true : false;
+	if (ib_dev->attrs.device_cap_flags & IB_DEVICE_INTEGRITY_HANDOVER)
+		device->pi_capable = true;
+	else
+		device->pi_capable = false;
 
 	return 0;
 }