From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hacpP-0003VQ-9j for barebox@lists.infradead.org; Tue, 11 Jun 2019 09:12:28 +0000 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hacpL-0003Q2-P7 for barebox@lists.infradead.org; Tue, 11 Jun 2019 11:12:23 +0200 Received: from afa by dude.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1hacpL-000362-Hx for barebox@lists.infradead.org; Tue, 11 Jun 2019 11:12:23 +0200 From: Ahmad Fatoum Date: Tue, 11 Jun 2019 11:12:22 +0200 Message-Id: <20190611091222.10461-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "barebox" Errors-To: barebox-bounces+u.kleine-koenig=pengutronix.de@lists.infradead.org Subject: [PATCH v2] commands: don't use stale errno when calling fb_open To: barebox@lists.infradead.org fb_open returns a pointer and doesn't populate errno, which will result in a stale errno being evaluated by perror() on failure. Fix this by using strerror with the proper argument instead at call sites. While at it, correct the message prefix typo (s/fb_open/fb_open/). Signed-off-by: Ahmad Fatoum --- Changes since v1: * use strerror instead of perror/errno as suggested by Andrey & Sascha * negated PTR_ERR output, so the error is positive 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..ff24a8252a8c 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); + int ret = -PTR_ERR(sc); + printf("fb_open: %s\n", strerror(ret)); + return ret; } if (!pattern_name) { diff --git a/commands/splash.c b/commands/splash.c index 2b70b296837e..abd82873cb6d 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); + int ret = -PTR_ERR(sc); + printf("fb_open: %s\n", strerror(ret)); + return ret; } buf = gui_screen_render_buffer(sc); -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox