diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-03-06 23:49:26 -0800 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-03-12 16:16:14 +0100 |
commit | 14ad13bfc3e83e7b9befb78b837d28427d8eacdf (patch) | |
tree | c67d85ea070994e42da5f9dc4483b487d90594ac | |
parent | 64ecfeb65e49bddf5605328bc9da3980137acf23 (diff) | |
download | barebox-14ad13bfc3e83e7b9befb78b837d28427d8eacdf.tar.gz barebox-14ad13bfc3e83e7b9befb78b837d28427d8eacdf.tar.xz |
commands: loadb: 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>
-rw-r--r-- | commands/loadb.c | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/commands/loadb.c b/commands/loadb.c index 8c3906ca42..37c272f6c7 100644 --- a/commands/loadb.c +++ b/commands/loadb.c @@ -33,6 +33,7 @@ #include <command.h> #include <console.h> #include <errno.h> +#include <libfile.h> #include <environment.h> #include <cache.h> #include <getopt.h> @@ -661,21 +662,11 @@ static int do_load_serial_bin(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; - } - } printf("## Ready for binary (kermit) download " "to 0x%08lX offset on %s device at %d bps...\n", offset, |