From: Marius Kittler <mkittler@suse.de>
To: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v9 4/4] Extend ioctl02 to test termio and termios
Date: Thu, 02 Nov 2023 14:15:15 +0100 [thread overview]
Message-ID: <1880149.tdWV9SEqCh@linux-9lzf> (raw)
In-Reply-To: <ZTvQMpx-q4LnBJgN@yuki>
Am Freitag, 27. Oktober 2023, 16:58:58 CET schrieb Cyril Hrubis:
> Hi!
>
> > +static void chk_tty_parms_termio(void)
> > +{
> > + int i, flag = 0;
> >
> > + CMP_ATTR(termio_exp, termio, c_line);
> > + CHECK_CONTROL_CHARS(termio);
> > + CMP_ATTR(termio_exp, termio, c_lflag);
> > + CMP_ATTR(termio_exp, termio, c_iflag);
> > + CMP_ATTR(termio_exp, termio, c_oflag);
>
> I do not see a reason why this cannot be a function, the only difference
> would be that we would have to do cmp_attr(termio_exp, termio->c_line)
> instead.
I'm not sure whether I understand this suggestion. If the first parameter is
still just termio_exp, how would that function know what field in termio_exp to
compare with? I guess you had an invocation like this in mind:
cmp_attr(termio_exp->c_line, termio->c_line)
That would be possible. The repetition of the attribute name is not nice. Of
course we'd also lose the attribute name in the error message. This could be
solved by passing it as string and doing a dynamic string concatenation in the
function, so the invocation would look like this:
cmp_attr(termio_exp->c_line, termio->c_line, "c_line")
This would also mean two additional implicit type conversions per call of this
function within chk_tty_parms_termio() because termio uses smaller sized types
than termios and the cmp_attr() function would need to decide on one type (and
we'd have to pick the larger size).
So I'm honestly not sure whether any of this is better than just making it a
macro or maybe I don't understand your suggestion.
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-11-02 13:15 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-26 11:47 [LTP] [PATCH v9 0/4] Improve ioctl02.c Marius Kittler
2023-10-26 11:47 ` [LTP] [PATCH v9 1/4] Refactor ioctl02.c to use the new test API Marius Kittler
2023-10-26 13:31 ` Petr Vorel
2023-10-26 11:47 ` [LTP] [PATCH v9 2/4] Make checks for termio flags more strict Marius Kittler
2023-10-26 13:32 ` Petr Vorel
2023-10-26 11:47 ` [LTP] [PATCH v9 3/4] Remove disabled code in ioctl02.c Marius Kittler
2023-10-26 13:32 ` Petr Vorel
[not found] ` <ZTvPszXRVkkh4vcL@yuki>
2023-10-30 11:21 ` Petr Vorel
2023-10-26 11:47 ` [LTP] [PATCH v9 4/4] Extend ioctl02 to test termio and termios Marius Kittler
[not found] ` <ZTvQMpx-q4LnBJgN@yuki>
2023-11-02 13:15 ` Marius Kittler [this message]
2023-11-02 13:26 ` Cyril Hrubis
2023-11-02 15:26 ` Marius Kittler
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=1880149.tdWV9SEqCh@linux-9lzf \
--to=mkittler@suse.de \
--cc=ltp@lists.linux.it \
/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