]> sigrok.org Git - sigrok-cli.git/commitdiff
session: print error message when output file creation fails
authorGerhard Sittig <redacted>
Tue, 16 Apr 2019 18:52:45 +0000 (20:52 +0200)
committerUwe Hermann <redacted>
Tue, 14 May 2019 22:16:37 +0000 (00:16 +0200)
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

index 65352bbd841481b31219c0d20111f65d3fb9d3b6..3b3e962d3706ad46c28132f1fece9068d42ac405 100644 (file)
--- 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;
        }