From 7a7010d4f5935ca31dc3aee285bb95ecfd6bbef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20=C5=9Alusarz?= Date: Mon, 30 Nov 2020 13:18:42 +0100 Subject: [PATCH] intel/tools/aubinator_error_decode: allow "-" as an input file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marcin Ĺšlusarz Reviewed-by: Lionel Landwerlin Part-of: --- src/intel/tools/aubinator_error_decode.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/intel/tools/aubinator_error_decode.c b/src/intel/tools/aubinator_error_decode.c index b7bdd88de2f..e1d86be8a59 100644 --- a/src/intel/tools/aubinator_error_decode.c +++ b/src/intel/tools/aubinator_error_decode.c @@ -749,7 +749,7 @@ print_help(const char *progname, FILE *file) int main(int argc, char *argv[]) { - FILE *file; + FILE *file = NULL; const char *path; struct stat st; int c, i, error; @@ -820,11 +820,14 @@ main(int argc, char *argv[]) } } else { path = argv[optind]; - error = stat(path, &st); - if (error != 0) { - fprintf(stderr, "Error opening %s: %s\n", - path, strerror(errno)); - exit(EXIT_FAILURE); + if (strcmp(path, "-") == 0) { + file = stdin; + } else { + error = stat(path, &st); + if (error != 0) { + fprintf(stderr, "Error opening %s: %s\n", path, strerror(errno)); + exit(EXIT_FAILURE); + } } } @@ -834,7 +837,7 @@ main(int argc, char *argv[]) if (isatty(1) && pager) setup_pager(); - if (S_ISDIR(st.st_mode)) { + if (!file && S_ISDIR(st.st_mode)) { ASSERTED int ret; char *filename; @@ -860,7 +863,7 @@ main(int argc, char *argv[]) path); return EXIT_FAILURE; } - } else { + } else if (!file) { file = fopen(path, "r"); if (!file) { fprintf(stderr, "Failed to open %s: %s\n",