Skip to content

Commit

Permalink
staging: gdm724x: Replace ternary operator with min macro
Browse files Browse the repository at this point in the history
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)
)

Signed-off-by: Gargi Sharma <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
gs0510 authored and gregkh committed Mar 9, 2017
1 parent 9304b5b commit c95d2e8
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/staging/gdm724x/gdm_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c95d2e8

Please sign in to comment.