diff mbox series

[RESEND] scsi: aacraid: aachba: replace if with max()

Message ID 20210722173212.GA5685@pc
State New
Headers show
Series [RESEND] scsi: aacraid: aachba: replace if with max() | expand

Commit Message

Salah Triki July 22, 2021, 5:32 p.m. UTC
Replace if with max() in order to make code more clean.

Signed-off-by: Salah Triki <salah.triki@gmail.com>
---
 drivers/scsi/aacraid/aachba.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Steffen Maier July 23, 2021, 4:56 p.m. UTC | #1
On 7/22/21 7:32 PM, Salah Triki wrote:
> Replace if with max() in order to make code more clean.

> 

> Signed-off-by: Salah Triki <salah.triki@gmail.com>

> ---

>   drivers/scsi/aacraid/aachba.c | 4 ++--

>   1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c

> index 46b8dffce2dd..330224f08fd3 100644

> --- a/drivers/scsi/aacraid/aachba.c

> +++ b/drivers/scsi/aacraid/aachba.c

> @@ -485,8 +485,8 @@ int aac_get_containers(struct aac_dev *dev)

>   	if (status != -ERESTARTSYS)

>   		aac_fib_free(fibptr);

> 

> -	if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)

> -		maximum_num_containers = MAXIMUM_NUM_CONTAINERS;

> +	maximum_num_containers = max(maximum_num_containers, MAXIMUM_NUM_CONTAINERS);

> +


Haven't really looked closely, but isn't the old code more like a min() rather 
than a max()? maximum_num_containers being at least MAXIMUM_NUM_CONTAINERS or 
higher?


-- 
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z Development

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
Steffen Maier July 23, 2021, 5:19 p.m. UTC | #2
On 7/23/21 6:56 PM, Steffen Maier wrote:
> On 7/22/21 7:32 PM, Salah Triki wrote:

>> Replace if with max() in order to make code more clean.

>>

>> Signed-off-by: Salah Triki <salah.triki@gmail.com>

>> ---

>>   drivers/scsi/aacraid/aachba.c | 4 ++--

>>   1 file changed, 2 insertions(+), 2 deletions(-)

>>

>> diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c

>> index 46b8dffce2dd..330224f08fd3 100644

>> --- a/drivers/scsi/aacraid/aachba.c

>> +++ b/drivers/scsi/aacraid/aachba.c

>> @@ -485,8 +485,8 @@ int aac_get_containers(struct aac_dev *dev)

>>       if (status != -ERESTARTSYS)

>>           aac_fib_free(fibptr);

>>

>> -    if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)

>> -        maximum_num_containers = MAXIMUM_NUM_CONTAINERS;

>> +    maximum_num_containers = max(maximum_num_containers, 

>> MAXIMUM_NUM_CONTAINERS);

>> +

> 

> Haven't really looked closely, but isn't the old code more like a min() rather 

> than a max()? maximum_num_containers being at least MAXIMUM_NUM_CONTAINERS or 

> higher?


Sorry, scratch that, it was nonsense.


-- 
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z Development

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Matthias Hartmann
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
Salah Triki July 23, 2021, 5:22 p.m. UTC | #3
On Fri, Jul 23, 2021 at 06:56:51PM +0200, Steffen Maier wrote:
> On 7/22/21 7:32 PM, Salah Triki wrote:

> > Replace if with max() in order to make code more clean.

> > 

> > Signed-off-by: Salah Triki <salah.triki@gmail.com>

> > ---

> >   drivers/scsi/aacraid/aachba.c | 4 ++--

> >   1 file changed, 2 insertions(+), 2 deletions(-)

> > 

> > diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c

> > index 46b8dffce2dd..330224f08fd3 100644

> > --- a/drivers/scsi/aacraid/aachba.c

> > +++ b/drivers/scsi/aacraid/aachba.c

> > @@ -485,8 +485,8 @@ int aac_get_containers(struct aac_dev *dev)

> >   	if (status != -ERESTARTSYS)

> >   		aac_fib_free(fibptr);

> > 

> > -	if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)

> > -		maximum_num_containers = MAXIMUM_NUM_CONTAINERS;

> > +	maximum_num_containers = max(maximum_num_containers, MAXIMUM_NUM_CONTAINERS);

> > +

> 

> Haven't really looked closely, but isn't the old code more like a min()

> rather than a max()? maximum_num_containers being at least

> MAXIMUM_NUM_CONTAINERS or higher?

> 


In the old code, maximum_num_containers gets the value MAXIMUM_NUM_CONTAINERS if
it is less than this value.

Thanx
Martin K. Petersen July 24, 2021, 2:32 a.m. UTC | #4
Salah,

> Replace if with max() in order to make code more clean.


I find the original code much easier to wrap my head around than the
proposed replacement.

-- 
Martin K. Petersen	Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c
index 46b8dffce2dd..330224f08fd3 100644
--- a/drivers/scsi/aacraid/aachba.c
+++ b/drivers/scsi/aacraid/aachba.c
@@ -485,8 +485,8 @@  int aac_get_containers(struct aac_dev *dev)
 	if (status != -ERESTARTSYS)
 		aac_fib_free(fibptr);
 
-	if (maximum_num_containers < MAXIMUM_NUM_CONTAINERS)
-		maximum_num_containers = MAXIMUM_NUM_CONTAINERS;
+	maximum_num_containers = max(maximum_num_containers, MAXIMUM_NUM_CONTAINERS);
+
 	if (dev->fsa_dev == NULL ||
 		dev->maximum_num_containers != maximum_num_containers) {