1
0
mirror of https://github.com/UzixLS/picocom.git synced 2025-07-19 07:21:18 +03:00

termios2: Clear both CBAUD and CBAUDEX bits. Not only CBAUD.

This is pure pedantry since CBAUDEX *is* included in CBAUD, but lets be
explicit.
This commit is contained in:
Nick Patavalis
2015-08-19 21:31:35 +03:00
parent 6642a7f1f2
commit a5208a560b

View File

@ -147,7 +147,8 @@ cf2setospeed_custom(struct termios *tios, int speed)
errno = EINVAL;
return -1;
}
tios->c_cflag = (tios->c_cflag & ~CBAUD) | BOTHER;
tios->c_cflag &= ~(CBAUD | CBAUDEX);
tios->c_cflag |= BOTHER;
tios->c_ospeed = speed;
return 0;
@ -164,11 +165,11 @@ cf2setispeed_custom(struct termios *tios, int speed)
/* Special case: ispeed == 0 means "same as ospeed". Kernel
* does this if it sees B0 in the "CIBAUD" field (i.e. in
* CBAUD << IBSHIFT) */
tios->c_cflag =
(tios->c_cflag & ~(CBAUD << IBSHIFT)) | (B0 << IBSHIFT);
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
tios->c_cflag |= (B0 << IBSHIFT);
} else {
tios->c_cflag =
(tios->c_cflag & ~(CBAUD << IBSHIFT)) | (BOTHER << IBSHIFT);
tios->c_cflag &= ~((CBAUD | CBAUDEX) << IBSHIFT);
tios->c_cflag |= (BOTHER << IBSHIFT);
tios->c_ispeed = speed;
}