summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAndrey Smirnov <andrew.smirnov@gmail.com>2019-03-06 23:49:25 -0800
committerSascha Hauer <s.hauer@pengutronix.de>2019-03-11 07:55:46 +0100
commit64ecfeb65e49bddf5605328bc9da3980137acf23 (patch)
treedf91c99fce0bc2f9d7fe0ef7aec961477c30ab36 /commands
parent5eadd11d4795afb6b521b5c3249c6341c0be7117 (diff)
downloadbarebox-64ecfeb65e49bddf5605328bc9da3980137acf23.tar.gz
commands: loadxy: Make use of open_and_lseek()
Save a bit of extra code by replacing explict calls to open() and lseek() with a single call to open_and_lseek(). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands')
-rw-r--r--commands/loadxy.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/commands/loadxy.c b/commands/loadxy.c
index 2bfe482..85efad6 100644
--- a/commands/loadxy.c
+++ b/commands/loadxy.c
@@ -37,6 +37,7 @@
#include <fcntl.h>
#include <fs.h>
#include <malloc.h>
+#include <libfile.h>
#define DEF_FILE "image.bin"
@@ -176,21 +177,11 @@ static int do_loadx(int argc, char *argv[])
output_file = DEF_FILE;
/* File should exist */
- ofd = open(output_file, O_WRONLY | O_CREAT);
+ ofd = open_and_lseek(output_file, O_WRONLY | O_CREAT, offset);
if (ofd < 0) {
perror(argv[0]);
return 3;
}
- /* Seek to the right offset */
- if (offset) {
- int seek = lseek(ofd, offset, SEEK_SET);
- if (seek != offset) {
- close(ofd);
- ofd = 0;
- perror(argv[0]);
- return 4;
- }
- }
current_baudrate = console_get_baudrate(cdev);