[PATCH 4/4] rkimage: improve error handling
Sascha Hauer
s.hauer at pengutronix.de
Wed Apr 29 03:19:56 PDT 2026
Complain when outfile is not given. Also, mention that we actually can't
create a file which is more accurate than just saying "open". While at
it fix some tab/whitespace issues.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
scripts/rkimage.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/scripts/rkimage.c b/scripts/rkimage.c
index 2dc67f499b..8243742d65 100644
--- a/scripts/rkimage.c
+++ b/scripts/rkimage.c
@@ -389,8 +389,8 @@ static int sign_newidb(struct newidb *idb, const char *path)
#else
static int sign_newidb(struct newidb *idb, const char *path)
{
- fprintf(stderr, "Signing support requires at least OpenSSL 3.0\n");
- return -ENOSYS;
+ fprintf(stderr, "Signing support requires at least OpenSSL 3.0\n");
+ return -ENOSYS;
}
#endif
@@ -481,6 +481,12 @@ int main(int argc, char *argv[])
n_code = argc - optind;
+ if (!outfile) {
+ fprintf(stderr, "No output file specified, use -o\n");
+ usage(argv[0]);
+ exit(1);
+ }
+
if (re_sign) {
if (n_code) {
fprintf(stderr, "unhandled non-opt arguments\n");
@@ -543,7 +549,7 @@ int main(int argc, char *argv[])
fd = creat(outfile, 0644);
if (fd < 0) {
- fprintf(stderr, "Cannot open %s: %s\n", outfile, strerror(errno));
+ fprintf(stderr, "Cannot create %s: %s\n", outfile, strerror(errno));
exit(1);
}
--
2.47.3
More information about the barebox
mailing list