From: Petr Vorel <pvorel@suse.cz>
To: Marius Kittler <mkittler@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v3 1/1] Extend ioctl02 to test termio and termios
Date: Fri, 1 Dec 2023 19:48:16 +0100 [thread overview]
Message-ID: <20231201184816.GF2829815@pevik> (raw)
In-Reply-To: <20231114150922.28652-2-mkittler@suse.de>
I posted it to the cover letter, but better to add it also to the patch:
BTW this v3 is exactly the same as v2. What am I missing?
Cyril asked you [1] to pass flag parameter to the macro, because you modify it
and it's not a good code to modify variable in macro without passing it.
Obviously you should return it as well (not that compact code, but it's really
better).
I understood it like:
#define CMP_ATTR(term_exp, term, attr, flag) \
({ \
flag += cmp_attr((term_exp).attr, (term).attr, #attr); \
flag; \
})
To speedup this, I merged with following diff below.
Thanks!
Kind regards,
Petr
[1] https://lore.kernel.org/ltp/ZUUV9MiVadNA75WY@yuki/
+++ testcases/kernel/syscalls/ioctl/ioctl02.c
@@ -8,8 +8,7 @@
/*\
* [Description]
*
- * Testcase to test the TCGETA/TCGETS, and TCSETA/TCSETS ioctl
- * implementations for the tty driver
+ * Test TCGETA/TCGETS and TCSETA/TCSETS ioctl implementations for tty driver.
*
* In this test, the parent and child open the parentty and the childtty
* respectively. After opening the childtty the child flushes the stream
@@ -27,19 +26,10 @@
#include <stdio.h>
#include <stdlib.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/wait.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <termios.h>
#include "lapi/ioctl.h"
-
-#include "tst_checkpoint.h"
#include "tst_test.h"
-#include "tst_safe_macros.h"
static struct termio termio, termio_exp;
static struct termios termios, termios_exp, termios_bak;
@@ -176,21 +166,28 @@ static int cmp_c_cc(unsigned char *exp_c_cc, unsigned char *act_c_cc, int ncc)
return fails;
}
-#define CMP_ATTR(term_exp, term, attr) \
- (flag += cmp_attr((term_exp).attr, (term).attr, #attr))
+#define CMP_ATTR(term_exp, term, attr, flag) \
+({ \
+ flag += cmp_attr((term_exp).attr, (term).attr, #attr); \
+ flag; \
+})
-#define CMP_C_CC(term_exp, term) \
- (flag += cmp_c_cc(term_exp.c_cc, term.c_cc, sizeof(term.c_cc)))
+#define CMP_C_CC(term_exp, term, flag) \
+({ \
+ flag += cmp_c_cc(term_exp.c_cc, term.c_cc, sizeof(term.c_cc)); \
+ flag; \
+})
static void chk_tty_parms_termio(void)
{
int flag = 0;
- CMP_ATTR(termio_exp, termio, c_line);
- CMP_C_CC(termio_exp, termio);
- CMP_ATTR(termio_exp, termio, c_lflag);
- CMP_ATTR(termio_exp, termio, c_iflag);
- CMP_ATTR(termio_exp, termio, c_oflag);
+ flag = CMP_ATTR(termio_exp, termio, c_line, flag);
+ flag = CMP_C_CC(termio_exp, termio, flag);
+ flag = CMP_ATTR(termio_exp, termio, c_lflag, flag);
+ flag = CMP_ATTR(termio_exp, termio, c_iflag, flag);
+ flag = CMP_ATTR(termio_exp, termio, c_oflag, flag);
+
if (!flag)
tst_res(TPASS, "TCGETA/TCSETA tests");
}
@@ -199,11 +196,12 @@ static void chk_tty_parms_termios(void)
{
int flag = 0;
- CMP_ATTR(termios_exp, termios, c_line);
- CMP_C_CC(termios_exp, termios);
- CMP_ATTR(termios_exp, termios, c_lflag);
- CMP_ATTR(termios_exp, termios, c_iflag);
- CMP_ATTR(termios_exp, termios, c_oflag);
+ flag = CMP_ATTR(termios_exp, termios, c_line, flag);
+ flag = CMP_C_CC(termios_exp, termios, flag);
+ flag = CMP_ATTR(termios_exp, termios, c_lflag, flag);
+ flag = CMP_ATTR(termios_exp, termios, c_iflag, flag);
+ flag = CMP_ATTR(termios_exp, termios, c_oflag, flag);
+
if (!flag)
tst_res(TPASS, "TCGETS/TCSETS tests");
}
@@ -255,4 +253,4 @@ static struct tst_test test = {
{"D:", &device, "Tty device. For example, /dev/tty[0-9]"},
{}
}
-};
\ No newline at end of file
+};
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-12-01 18:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-14 15:09 [LTP] [PATCH v3 0/1] *** Extend ioctl02 to test termio and termios *** Marius Kittler
2023-11-14 15:09 ` [LTP] [PATCH v3 1/1] Extend ioctl02 to test termio and termios Marius Kittler
2023-12-01 18:48 ` Petr Vorel [this message]
2023-11-28 13:29 ` [LTP] [PATCH v3 0/1] *** Extend ioctl02 to test termio and termios *** Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231201184816.GF2829815@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=mkittler@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox