From 9ed80f1d862aa90d47fde48e0e1e924d1ad5e4a3 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Tue, 16 Apr 2019 20:52:45 +0200 Subject: [PATCH] session: print error message when output file creation fails Failure to create an output file from within the sigrok-cli component previously went unnoticed. Emit an error message to make users aware. This addresses the sigrok-cli side of bug #1372. --- session.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/session.c b/session.c index 65352bb..3b3e962 100644 --- a/session.c +++ b/session.c @@ -107,10 +107,15 @@ const struct sr_output *setup_output_format(const struct sr_dev_inst *sdi, FILE o = sr_output_new(omod, fmtopts, sdi, opt_output_file); if (opt_output_file) { - if (!sr_output_test_flag(omod, SR_OUTPUT_INTERNAL_IO_HANDLING)) + if (!sr_output_test_flag(omod, SR_OUTPUT_INTERNAL_IO_HANDLING)) { *outfile = g_fopen(opt_output_file, "wb"); - else + if (!*outfile) { + g_critical("Cannot write to output file '%s'.", + opt_output_file); + } + } else { *outfile = NULL; + } } else { *outfile = stdout; } -- 2.30.2