public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Marius Kittler <mkittler@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] Use correct ioctl request for termios
Date: Mon, 4 Sep 2023 17:04:51 +0200	[thread overview]
Message-ID: <ZPXyE9O38JHxfiV0@yuki> (raw)
In-Reply-To: <20230904145035.22939-1-mkittler@suse.de>

Hi!
>  testcases/kernel/syscalls/ioctl/ioctl01.c | 19 ++++++++++---------
>  1 file changed, 10 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl01.c b/testcases/kernel/syscalls/ioctl/ioctl01.c
> index 1be38e79d..983208925 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl01.c
> @@ -36,34 +36,35 @@ static struct termios termios;
>  
>  static struct tcase {
>  	int *fd;
> -	int request;
> +	int request_tio;
> +	int request_tios;
>  	struct termio *s_tio;
>  	struct termios *s_tios;
>  	int error;

I guess that it would be cleaner to keep the single request, but define
the s_tio as a void * here.

That way we can add test on a separate lines:

	{&bfd, TCGETA, &termio, EBADF},
	{&bfd, TCGETS, &termios, EBADF},
	...


And have single TST_EXP_FAIL() in the verify function.

>  } tcases[] = {
>  	/* file descriptor is invalid */
> -	{&bfd, TCGETA, &termio, &termios, EBADF},
> +	{&bfd, TCGETA, TCGETS, &termio, &termios, EBADF},
>  	/* termio address is invalid */
> -	{&fd, TCGETA, (struct termio *)-1, (struct termios *)-1, EFAULT},
> -	/* command is invalid */
> +	{&fd, TCGETA, TCGETS, (struct termio *)-1, (struct termios *)-1, EFAULT},
> +	// /* command is invalid */
>  	/* This errno value was changed from EINVAL to ENOTTY
>  	 * by kernel commit 07d106d0 and bbb63c51
>  	 */
> -	{&fd, INVAL_IOCTL, &termio, &termios, ENOTTY},
> +	{&fd, INVAL_IOCTL, INVAL_IOCTL, &termio, &termios, ENOTTY},
>  	/* file descriptor is for a regular file */
> -	{&fd_file, TCGETA, &termio, &termios, ENOTTY},
> +	{&fd_file, TCGETA, TCGETS, &termio, &termios, ENOTTY},
>  	/* termio is NULL */
> -	{&fd, TCGETA, NULL, NULL, EFAULT}
> +	{&fd, TCGETA, TCGETS, NULL, NULL, EFAULT}
>  };
>  
>  static char *device;
>  
>  static void verify_ioctl(unsigned int i)
>  {
> -	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tio),
> +	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tio, tcases[i].s_tio),
>  		     tcases[i].error);
>  
> -	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request, tcases[i].s_tios),
> +	TST_EXP_FAIL(ioctl(*(tcases[i].fd), tcases[i].request_tios, tcases[i].s_tios),
>  		     tcases[i].error);
>  }
>  
> -- 
> 2.41.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-09-04 15:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 14:50 [LTP] [PATCH] Use correct ioctl request for termios Marius Kittler
2023-09-04 15:04 ` Cyril Hrubis [this message]
2023-09-04 15:18   ` Marius Kittler
2023-09-04 16:11     ` Cyril Hrubis

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=ZPXyE9O38JHxfiV0@yuki \
    --to=chrubis@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