Skip to contentSkip to conversation

scsi: aacraid: aachba: replace if with max()

PATCH RESEND In review Salah Triki 3 participants 5 messages Jul 22, 2021 – Jul 24, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 scsi: aacraid: aachba: replace if with max()

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

---
 drivers/scsi/aacraid/aachba.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/aachba.c +2 -2
index 46b8dffce2dd..330224f08fd3 100644
@@ -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) {
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 12 lines · Salah Triki

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

---
  drivers/scsi/aacraid/aachba.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/aachba.c +0 -0
index 46b8dffce2dd..330224f08fd3 100644

drivers/scsi/aacraid/aachba.c int aac_get_containers(struct aac_dev *dev) · line 489

Quoted 7 lines
drivers/scsi/aacraid/aachba.c +2 -2
@@ -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?

Signature · 11 lines
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
#2 lore raw
Quoted 16 lines · Steffen Maier
Quoted 15 lines · Salah Triki

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

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

  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/aachba.c +0 -0
index 46b8dffce2dd..330224f08fd3 100644
@@ -485,8 +485,8 @@ int aac_get_containers(struct aac_dev *dev)
       if (status != -ERESTARTSYS)
           aac_fib_free(fibptr);
 
Quoted 7 lines

drivers/scsi/aacraid/aachba.c int aac_get_containers(struct aac_dev *dev) · line 489

Quoted 5 lines
drivers/scsi/aacraid/aachba.c +2 -2
-    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.

Signature · 11 lines
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
#3 lore raw
In reply to Steffen Maier
Quoted 16 lines · Steffen Maier
Quoted 15 lines · Salah Triki

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

---
  drivers/scsi/aacraid/aachba.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/aacraid/aachba.c +0 -0
index 46b8dffce2dd..330224f08fd3 100644
@@ -485,8 +485,8 @@ int aac_get_containers(struct aac_dev *dev)
  	if (status != -ERESTARTSYS)
  		aac_fib_free(fibptr);
 
Quoted 9 lines

drivers/scsi/aacraid/aachba.c int aac_get_containers(struct aac_dev *dev) · line 489

Quoted 4 lines
drivers/scsi/aacraid/aachba.c +2 -2
-	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

#4 lore raw
In reply to Salah Triki

Salah,

Quoted 1 line

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.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering