mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Andrey Smirnov <andrew.smirnov@gmail.com>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH] commands: don't use stale errno when calling fb_open
Date: Mon, 3 Jun 2019 12:20:28 -0700	[thread overview]
Message-ID: <CAHQ1cqGxnQSHQ9fuCikVMEGN5jOe7y7H4MXn6G3UhBov_TGq-w@mail.gmail.com> (raw)
In-Reply-To: <20190603190535.15346-1-a.fatoum@pengutronix.de>

On Mon, Jun 3, 2019 at 12:05 PM Ahmad Fatoum <a.fatoum@pengutronix.de> wrote:
>
> fb_open returns a pointer and doesn't populate errno, which will
> results in a stale errno being evaluated by perror() on failure.
> Fix this by populating errno manually at call sites.
>

Why not just convert the code to use strerror() instead? Seems a bit
more straightforward plus changing errno outside of our "POSIX/C"
layer seems a bit out of place. Not a big deal though.

Thanks,
Andrey Smirnov

> While at it, correct the typo in the prefix passed to perror().
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
>  commands/fbtest.c | 5 +++--
>  commands/splash.c | 5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/commands/fbtest.c b/commands/fbtest.c
> index e5dd8ba7fabf..2c589f77d3b8 100644
> --- a/commands/fbtest.c
> +++ b/commands/fbtest.c
> @@ -271,8 +271,9 @@ static int do_fbtest(int argc, char *argv[])
>
>         sc = fb_open(fbdev);
>         if (IS_ERR(sc)) {
> -               perror("fd_open");
> -               return PTR_ERR(sc);
> +               errno = PTR_ERR(sc);
> +               perror("fb_open");
> +               return errno;
>         }
>
>         if (!pattern_name) {
> diff --git a/commands/splash.c b/commands/splash.c
> index 2b70b296837e..75b3ee3fadaf 100644
> --- a/commands/splash.c
> +++ b/commands/splash.c
> @@ -54,8 +54,9 @@ static int do_splash(int argc, char *argv[])
>
>         sc = fb_open(fbdev);
>         if (IS_ERR(sc)) {
> -               perror("fd_open");
> -               return PTR_ERR(sc);
> +               errno = PTR_ERR(sc);
> +               perror("fb_open");
> +               return errno;
>         }
>
>         buf = gui_screen_render_buffer(sc);
> --
> 2.20.1
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2019-06-03 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-03 19:05 Ahmad Fatoum
2019-06-03 19:20 ` Andrey Smirnov [this message]
2019-06-04  8:08 ` Sascha Hauer

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=CAHQ1cqGxnQSHQ9fuCikVMEGN5jOe7y7H4MXn6G3UhBov_TGq-w@mail.gmail.com \
    --to=andrew.smirnov@gmail.com \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.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