staging: comedi: Replace ternary operator with min macro
PATCH 1/1 staging: comedi: Replace ternary operator with min macro
Use macro min() to get the minimum of two values for brevity and readability.
Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)
--- drivers/staging/comedi/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/comedi/drivers.c +1 -1
@@ -815,7 +815,7 @@ int comedi_load_firmware(struct comedi_device *dev,release_firmware (fw); } -return ret <0 ? ret :0 ; +return min (ret,0 ); }EXPORT_SYMBOL_GPL (comedi_load_firmware);
Signature · 1 line
2.7.4
Quoted 13 lines · Gargi Sharma
Use macro
min()to get the minimum of two values for brevity and readability.Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+min(x,y)
|
- x > y ? x : y
+max(x,y)
)
Quoted 1 line
Signed-off-by Gargi Sharma <[email protected]>
Quoted 27 lines
--- drivers/staging/comedi/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/comedi/drivers.c +1
-2@@ -815,7 +815,7 @@ int comedi_load_firmware(struct comedi_device *dev,release_firmware (fw); } -return ret <0 ? ret :0 ; +return min (ret,0 ); }EXPORT_SYMBOL_GPL (comedi_load_firmware); --2.7.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1488906954-25933-1-git-send-email-gs051095%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 24 lines · Gargi Sharma
Use macro
min()to get the minimum of two values for brevity and readability.Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+min(x,y)
|
- x > y ? x : y
+max(x,y)
)Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/comedi/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/comedi/drivers.c +0
-0
drivers/staging/comedi/drivers.c int comedi_load_firmware(struct comedi_device *dev, · line 820
Quoted 7 lines
drivers/staging/comedi/drivers.c +1
-1@@ -815,7 +815,7 @@ int comedi_load_firmware(struct comedi_device *dev,release_firmware (fw); } -return ret <0 ? ret :0 ; +return min (ret,0 ); }EXPORT_SYMBOL_GPL (comedi_load_firmware);
Technically this patch is correct. But, logically it might be confusing.
This function either returns an error code (ret < 0) or success (0). The min() macro makes it look like this function returns a minimum value.
Just my two cents...
Regards,
Hartley
Quoted 35 lines · Hartley Sweeten
Quoted 24 lines · Gargi Sharma
Use macro
min()to get the minimum of two values for brevity and readability.Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+min(x,y)
|
- x > y ? x : y
+max(x,y)
)Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/comedi/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/comedi/drivers.c +0
-0drivers/staging/comedi/drivers.c int comedi_load_firmware(struct comedi_device *dev, · line 820
Quoted 7 lines
drivers/staging/comedi/drivers.c +1
-1@@ -815,7 +815,7 @@ int comedi_load_firmware(struct comedi_device *dev,release_firmware (fw); } -return ret <0 ? ret :0 ; +return min (ret,0 ); }EXPORT_SYMBOL_GPL (comedi_load_firmware);Technically this patch is correct. But, logically it might be confusing.
Quoted 2 lines
This function either returns an error code (ret < 0) or success (0). The
min()macro makes it look like this function returns a minimum value.
Agreed. The ? is a bit ugly, but the min does not seem like the normal way of returning an error code.
julia
Quoted 13 lines
Just my two cents...
Regards,
Hartley--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/SN1PR0101MB15652DA28CB022F0A3A8ED02D02F0%40SN1PR0101MB1565.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 39 lines · Julia Lawall
Quoted 35 lines · Hartley Sweeten
Quoted 24 lines · Gargi Sharma
Use macro
min()to get the minimum of two values for brevity and readability.Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+min(x,y)
|
- x > y ? x : y
+max(x,y)
)Signed-off-by Gargi Sharma <[email protected]>--- drivers/staging/comedi/drivers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/staging/comedi/drivers.c +0
-0drivers/staging/comedi/drivers.c int comedi_load_firmware(struct comedi_device *dev, · line 820
Quoted 7 lines
drivers/staging/comedi/drivers.c +1
-1@@ -815,7 +815,7 @@ int comedi_load_firmware(struct comedi_device *dev,release_firmware (fw); } -return ret <0 ? ret :0 ; +return min (ret,0 ); }EXPORT_SYMBOL_GPL (comedi_load_firmware);Technically this patch is correct. But, logically it might be confusing.
Quoted 5 lines
Quoted 2 lines
This function either returns an error code (ret < 0) or success (0). The
min()macro makes it look like this function returns a minimum value.Agreed. The ? is a bit ugly, but the min does not seem like the normal way of returning an error code.
Yeah, this makes sense. I'll redact this patch then. :)
thanks,
gargi
Quoted 16 lines
julia
Quoted 13 lines
Just my two cents...
Regards,
Hartley--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/SN1PR0101MB15652DA28CB022F0A3A8ED02D02F0%40SN1PR0101MB1565.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.