Get rid of perror()
It prints to stderr and that's not what we want necesserily;
using msg_*err gives us more control.
Corresponding to flashrom svn r1668.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/flashrom.c b/flashrom.c
index 14bb1b3..c11f723 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -29,6 +29,7 @@
#endif
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include <ctype.h>
#include <getopt.h>
#if HAVE_UTSNAME == 1
@@ -1158,11 +1159,11 @@
struct stat image_stat;
if ((image = fopen(filename, "rb")) == NULL) {
- perror(filename);
+ msg_gerr("Error: opening file \"%s\" failed: %s\n", filename, strerror(errno));
return 1;
}
if (fstat(fileno(image), &image_stat) != 0) {
- perror(filename);
+ msg_gerr("Error: getting metadata of file \"%s\" failed: %s\n", filename, strerror(errno));
fclose(image);
return 1;
}
@@ -1174,7 +1175,7 @@
}
numbytes = fread(buf, 1, size, image);
if (fclose(image)) {
- perror(filename);
+ msg_gerr("Error: closing file \"%s\" failed: %s\n", filename, strerror(errno));
return 1;
}
if (numbytes != size) {
@@ -1196,7 +1197,7 @@
return 1;
}
if ((image = fopen(filename, "wb")) == NULL) {
- perror(filename);
+ msg_gerr("Error: opening file \"%s\" failed: %s\n", filename, strerror(errno));
return 1;
}