@@ -145,7 +145,10 @@ pub(crate) fn set_termios(fd: RawFd, termios: &Termios) -> Result<()> {
145145 crate :: posix:: ioctl:: tcsets2 ( fd, termios)
146146}
147147
148- pub ( crate ) fn set_parity ( termios : & mut Termios , parity : Parity ) {
148+ // The Result return will seem pointless on platforms that support all parity variants, but we need
149+ // it for the others.
150+ #[ allow( clippy:: unnecessary_wraps) ]
151+ pub ( crate ) fn set_parity ( termios : & mut Termios , parity : Parity ) -> Result < ( ) > {
149152 match parity {
150153 Parity :: None => {
151154 termios. c_cflag &= !( libc:: PARENB | libc:: PARODD ) ;
@@ -163,27 +166,38 @@ pub(crate) fn set_parity(termios: &mut Termios, parity: Parity) {
163166 termios. c_iflag |= libc:: INPCK ;
164167 termios. c_iflag &= !libc:: IGNPAR ;
165168 }
169+ #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
166170 Parity :: Mark => {
167171 termios. c_cflag |= libc:: PARODD ;
168172 termios. c_cflag |= libc:: PARENB ;
169173 termios. c_iflag |= libc:: INPCK ;
170174 termios. c_iflag &= !libc:: IGNPAR ;
171- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
172- {
173- termios. c_iflag |= libc:: CMSPAR ;
174- }
175+ termios. c_iflag |= libc:: CMSPAR ;
175176 }
177+ #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
176178 Parity :: Space => {
177179 termios. c_cflag &= !libc:: PARODD ;
178180 termios. c_cflag |= libc:: PARENB ;
179181 termios. c_iflag |= libc:: INPCK ;
180182 termios. c_iflag &= !libc:: IGNPAR ;
181- #[ cfg( any( target_os = "linux" , target_os = "android" ) ) ]
182- {
183- termios. c_iflag |= libc:: CMSPAR ;
184- }
183+ termios. c_iflag |= libc:: CMSPAR ;
184+ }
185+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
186+ Parity :: Mark => {
187+ return Err ( crate :: Error :: new (
188+ crate :: ErrorKind :: InvalidInput ,
189+ "Mark parity not supported on this platform" ,
190+ ) ) ;
191+ }
192+ #[ cfg( not( any( target_os = "linux" , target_os = "android" ) ) ) ]
193+ Parity :: Space => {
194+ return Err ( crate :: Error :: new (
195+ crate :: ErrorKind :: InvalidInput ,
196+ "Space parity not supported on this platform" ,
197+ ) ) ;
185198 }
186199 } ;
200+ Ok ( ( ) )
187201}
188202
189203pub ( crate ) fn set_flow_control ( termios : & mut Termios , flow_control : FlowControl ) {
0 commit comments