summaryrefslogtreecommitdiffstats
path: root/lib/misc.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2023-08-16 11:36:54 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2023-08-18 07:37:45 +0200
commit57b568dc570f5ecc73d0657af868ba7d04df39a0 (patch)
tree46e679c04e33b8b905232fd9da38cd42b50976d5 /lib/misc.c
parent06703b05b8ce26ee396cb986a904416cd7e0798f (diff)
downloadbarebox-57b568dc570f5ecc73d0657af868ba7d04df39a0.tar.gz
barebox-57b568dc570f5ecc73d0657af868ba7d04df39a0.tar.xz
lib: open_and_lseek(): move error messages to callers
For some cases like in common/filetype.c the caller already prints an error message, so to avoid duplicated error messages leave it up to the caller to print an error. This also adds error messages to all callers where necessary. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/misc.c')
-rw-r--r--lib/misc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/misc.c b/lib/misc.c
index 2d5f7c1985..1cb2a6b9b5 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -209,11 +209,14 @@ int memcpy_parse_options(int argc, char *argv[], int *sourcefd,
destfile = destfile ?: "/dev/mem";
*sourcefd = open_and_lseek(sourcefile, mode | O_RDONLY, src);
- if (*sourcefd < 0)
+ if (*sourcefd < 0) {
+ printf("Could not open source file \"%s\": %m\n", sourcefile);
return -1;
+ }
*destfd = open_and_lseek(destfile, mode | destmode, dest);
if (*destfd < 0) {
+ printf("Could not open destination file \"%s\": %m\n", destfile);
close(*sourcefd);
return -1;
}