Skip to contentSkip to conversation

staging: gdm724x: Replace ternary operator with min macro

PATCH New Gargi Sharma 1 participant 1 message Mar 7, 2017 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 staging: gdm724x: Replace ternary operator with min macro

Use macro min() to get the minimum of two values for brevity and readability. The macro MUX_TX_MAX_SIZE has a value of 2048 which is well within the integer limits. This check was done manually.

Found using Coccinelle:
@@ type T; T x; T y; @@
(
- x < y ? x : y
+ min(x,y)
|
- x > y ? x : y
+ max(x,y)
)

---
Changes in v2:
- Made the commit message clearer.

---
 drivers/staging/gdm724x/gdm_tty.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/gdm724x/gdm_tty.c +1 -2
index ae39663..fc7682c 100644
@@ -190,8 +190,7 @@ static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf,
 		return 0;
 
 	while (1) {
-		sending_len = remain > MUX_TX_MAX_SIZE ? MUX_TX_MAX_SIZE :
-							 remain;
+		sending_len = min(MUX_TX_MAX_SIZE, remain);
 		gdm_tty_send(gdm,
 			     (void *)(buf + sent_len),
 			     sending_len,
Signature · 1 line
2.7.4