[LTP] [PATCH v9 4/4] Extend ioctl02 to test termio and termios

Marius Kittler mkittler@suse.de
Thu Nov 2 14:15:15 CET 2023


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.




More information about the ltp mailing list