[PATCH] commands: don't use stale errno when calling fb_open

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

While at it, correct the typo in the prefix passed to perror().

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux