[LTP] [PATCH v8 4/4] Extend ioctl02 to test termio and termios
Petr Vorel
pvorel@suse.cz
Thu Oct 26 00:13:49 CEST 2023
Hi Marius
...
> - 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++;
> +#define CMP_ATTR(tcexp, tcval, attr) \
> + do { \
> + if ((tcval).attr != (tcexp).attr) { \
> + tst_res(TINFO, #attr " has incorrect value %o", \
> + (tcval).attr); \
> + flag++; \
> + } \
> + } while (0)
> +
> +#define CECK_CONTROL_CHARS(tcval) \
> + for (i = 0; i < NCC; i++) { \
> + if (i == VEOL2) { \
> + if (!(tcval).c_cc[i]) { \
> + continue; \
> + } else { \
> + tst_res(TFAIL, "control char %d has " \
> + "incorrect value %d", i, (tcval).c_cc[i]); \
> + flag++; \
> + continue; \
> + } \
> + } \
> + if ((tcval).c_cc[i] != CSTART) { \
> + tst_res(TFAIL, "control char %d has incorrect " \
> + "value %d.", i, (tcval).c_cc[i]); \
> + flag++; \
> + } \
> }
Could be this written as a function? Or what is the benefit of it? Because
readability suffers. (We prefer avoid macros, tst_test_macros.h is the exception
due using kernel syscalls, but readability also suffers).
I know you mentioned C++ in cover letter, but please no C++ :).
Kind regards,
Petr
More information about the ltp
mailing list