diff mbox series

[v8,2/4] Make checks for termio flags more strict

Message ID 20231025110835.28832-3-mkittler@suse.de
State Changes Requested
Headers show
Series Improve ioctl02.c | expand

Commit Message

Marius Kittler Oct. 25, 2023, 11:08 a.m. UTC
The checks for termio flags can actually use a `!=` check to
also fail when any unexpected flags are present.

Signed-off-by: Marius Kittler <mkittler@suse.de>
---
 testcases/kernel/syscalls/ioctl/ioctl02.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Petr Vorel Oct. 25, 2023, 10:31 p.m. UTC | #1
Hi Marius,

...
> -	if (!
> -	    (termio.c_lflag
> -	     && (ISIG | ICANON | XCASE | ECHO | ECHOE | NOFLSH))) {
> +	if (termio.c_lflag != (ISIG | ICANON | XCASE | ECHO | ECHOE
> +		 | NOFLSH)) {
Shouldn't this be using & ~() ?

	if ((termio.c_lflag & ~(ISIG | ICANON | XCASE | ECHO | ECHOE | NOFLSH))) {

Also the other two.

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/ioctl/ioctl02.c b/testcases/kernel/syscalls/ioctl/ioctl02.c
index 23a52151b..cfc081e9c 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl02.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl02.c
@@ -157,24 +157,21 @@  static void chk_tty_parms(void)
 		}
 	}
 
-	if (!
-	    (termio.c_lflag
-	     && (ISIG | ICANON | XCASE | ECHO | ECHOE | NOFLSH))) {
+	if (termio.c_lflag != (ISIG | ICANON | XCASE | ECHO | ECHOE
+		 | NOFLSH)) {
 		tst_res(TFAIL, "lflag has incorrect value. %o",
 			 termio.c_lflag);
 		flag++;
 	}
 
-	if (!
-	    (termio.c_iflag
-	     && (BRKINT | IGNPAR | INPCK | ISTRIP | ICRNL | IUCLC | IXON | IXANY
-		 | IXOFF))) {
+	if (termio.c_iflag != (BRKINT | IGNPAR | INPCK | ISTRIP
+		 | ICRNL | IUCLC | IXON | IXANY | IXOFF)) {
 		tst_res(TFAIL, "iflag has incorrect value. %o",
 			 termio.c_iflag);
 		flag++;
 	}
 
-	if (!(termio.c_oflag && (OPOST | OLCUC | ONLCR | ONOCR))) {
+	if (termio.c_oflag != (OPOST | OLCUC | ONLCR | ONOCR)) {
 		tst_res(TFAIL, "oflag has incorrect value. %o",
 			 termio.c_oflag);
 		flag++;