From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Wagner Date: Wed, 23 Nov 2011 21:28:14 +0100 Subject: [U-Boot] [PATCH 5/9] mkenvimage: Read from stdin if the filename is "-" In-Reply-To: <1322080098-3151-1-git-send-email-david.wagner@free-electrons.com> References: <1322080098-3151-1-git-send-email-david.wagner@free-electrons.com> Message-ID: <1322080098-3151-6-git-send-email-david.wagner@free-electrons.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Signed-off-by: David Wagner --- tools/mkenvimage.c | 11 +++-------- 1 files changed, 3 insertions(+), 8 deletions(-) diff --git a/tools/mkenvimage.c b/tools/mkenvimage.c index b6e7f14..86a4e05 100644 --- a/tools/mkenvimage.c +++ b/tools/mkenvimage.c @@ -154,15 +154,9 @@ int main(int argc, char **argv) memset(envptr, padbyte, envsize); /* Open the input file ... */ - if (optind >= argc) { - fprintf(stderr, "Please specify an input filename\n"); - return EXIT_FAILURE; - } - - txt_filename = argv[optind]; - if (strcmp(txt_filename, "-") == 0) { + if (optind >= argc || strcmp(argv[optind], "-") == 0) { int readbytes = 0; - int readlen = sizeof(*envptr) * 2048; + int readlen = sizeof(*envptr) * 4096; txt_fd = STDIN_FILENO; do { @@ -180,6 +174,7 @@ int main(int argc, char **argv) } while (readbytes == readlen); } else { + txt_filename = argv[optind]; txt_fd = open(txt_filename, O_RDONLY); if (txt_fd == -1) { fprintf(stderr, "Can't open \"%s\": %s\n", -- 1.7.7.3