From: Gerhard Sittig Date: Tue, 16 Apr 2019 18:52:45 +0000 (+0200) Subject: session: print error message when output file creation fails X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9ed80f1d862aa90d47fde48e0e1e924d1ad5e4a3;p=sigrok-cli.git 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. --- 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; }