From: Petri Latvala <petri.latvala@intel.com>
To: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] lib: Reset errno to 0 after isatty
Date: Wed, 10 Apr 2019 12:55:46 +0300 [thread overview]
Message-ID: <20190410095546.GF22949@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20190409142141.13924-1-arkadiusz.hiler@intel.com>
On Tue, Apr 09, 2019 at 05:21:41PM +0300, Arkadiusz Hiler wrote:
> Since igt_assert family of functions logs last errno we get a lot of
> those: "Last errno: 25, Inappropriate ioctl for device"
>
> isatty() seems to be the biggest offender in that area, so this patch
> should limit amount of confusing messages significantly.
>
> Cc: Martin Peres <martin.peres@linux.intel.com>
> Cc: Petri Latvala <petri.latvala@intel.com>
> Signed-off-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Reviewed-by: Petri Latvala <petri.latvala@intel.com>
> ---
> lib/igt_aux.c | 12 +++++++++---
> lib/igt_core.c | 2 ++
> 2 files changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/lib/igt_aux.c b/lib/igt_aux.c
> index 266aa832..a3c904d7 100644
> --- a/lib/igt_aux.c
> +++ b/lib/igt_aux.c
> @@ -631,8 +631,10 @@ static void igt_interactive_info(const char *format, ...)
> {
> va_list args;
>
> - if (!isatty(STDERR_FILENO) || __igt_plain_output)
> + if (!isatty(STDERR_FILENO) || __igt_plain_output) {
> + errno = 0; /* otherwise would be either ENOTTY or EBADF */
> return;
> + }
>
> if (igt_log_level > IGT_LOG_INFO)
> return;
> @@ -984,8 +986,10 @@ void igt_debug_wait_for_keypress(const char *var)
> {
> struct termios oldt, newt;
>
> - if (!isatty(STDIN_FILENO))
> + if (!isatty(STDIN_FILENO)) {
> + errno = 0; /* otherwise would be either ENOTTY or EBADF */
> return;
> + }
>
> if (!igt_interactive_debug)
> return;
> @@ -1030,8 +1034,10 @@ void igt_debug_manual_check(const char *var, const char *expected)
> struct termios oldt, newt;
> char key;
>
> - if (!isatty(STDIN_FILENO))
> + if (!isatty(STDIN_FILENO)) {
> + errno = 0; /* otherwise would be either ENOTTY or EBADF */
> return;
> + }
>
> if (!igt_interactive_debug)
> return;
> diff --git a/lib/igt_core.c b/lib/igt_core.c
> index 6eb4798e..ae03e909 100644
> --- a/lib/igt_core.c
> +++ b/lib/igt_core.c
> @@ -630,6 +630,8 @@ static void common_init_env(void)
> if (!isatty(STDOUT_FILENO) || getenv("IGT_PLAIN_OUTPUT"))
> __igt_plain_output = true;
>
> + errno = 0; /* otherwise may be either ENOTTY or EBADF because of isatty */
> +
> if (!__igt_plain_output)
> setlocale(LC_ALL, "");
>
> --
> 2.20.1
>
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
prev parent reply other threads:[~2019-04-10 9:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-09 14:21 [igt-dev] [PATCH i-g-t] lib: Reset errno to 0 after isatty Arkadiusz Hiler
2019-04-09 15:52 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2019-04-10 1:49 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2019-04-10 9:55 ` Petri Latvala [this message]
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=20190410095546.GF22949@platvala-desk.ger.corp.intel.com \
--to=petri.latvala@intel.com \
--cc=arkadiusz.hiler@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/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