Remove unnecessary condition check in uart.c 46/138946/1
authorHyeongsik Min <hyeongsik.min@samsung.com>
Fri, 14 Jul 2017 09:36:49 +0000 (18:36 +0900)
committerHyeongsik Min <hyeongsik.min@samsung.com>
Fri, 14 Jul 2017 09:36:49 +0000 (18:36 +0900)
bytesize is always greater than zero.

Change-Id: Iae6a882a8cb1fcaee215602ef7d8dccafa2af99d
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
src/interface/uart.c

index e262a1a..310d273 100644 (file)
@@ -163,6 +163,11 @@ int uart_set_mode(int file_hndl, uart_bytesize_e bytesize, uart_parity_e parity,
                return -EINVAL;
        }
 
+       if (bytesize > UART_BYTESIZE_8BIT) {
+               _E("Invalid bytesize parameter");
+               return -EINVAL;
+       }
+
        ret = tcgetattr(file_hndl, &tio);
        if (ret) {
                char errmsg[MAX_ERR_LEN];
@@ -172,10 +177,6 @@ int uart_set_mode(int file_hndl, uart_bytesize_e bytesize, uart_parity_e parity,
        }
 
        /* set byte size */
-       if (bytesize < UART_BYTESIZE_5BIT || bytesize > UART_BYTESIZE_8BIT) {
-               _E("Invalid parameter bytesize");
-               return -EINVAL;
-       }
        tio.c_cflag &= ~CSIZE;
        tio.c_cflag |= byteinfo[bytesize];
        tio.c_cflag |= (CLOCAL | CREAD);