X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-cli.git;a=blobdiff_plain;f=input.c;h=cce0d9ff916b9a159f0f3400d80bd5d96df263eb;hp=eb496ee7a54d4c2a806c248f282bbf05efb94178;hb=HEAD;hpb=2b29fb3954da8ede79ade2e4940f95b3ef836d8f diff --git a/input.c b/input.c index eb496ee..cce0d9f 100644 --- a/input.c +++ b/input.c @@ -68,7 +68,7 @@ static void load_input_file_module(struct df_arg_desc *df_arg) if ((options = sr_input_options_get(imod))) { mod_opts = generic_arg_to_opt(options, mod_args); (void)warn_unknown_keys(options, mod_args, NULL); - sr_output_options_free(options); + sr_input_options_free(options); } else { mod_opts = NULL; } @@ -105,7 +105,7 @@ static void load_input_file_module(struct df_arg_desc *df_arg) g_critical("Failed to load %s: %s.", opt_input_file, g_strerror(errno)); } - if ((len = read(fd, buf->str, CHUNK_SIZE)) < 1) + if ((len = read(fd, buf->str, buf->allocated_len)) < 1) g_critical("Failed to read %s: %s.", opt_input_file, g_strerror(errno)); buf->len = len; @@ -139,7 +139,7 @@ static void load_input_file_module(struct df_arg_desc *df_arg) if (push_scan_data) len = 0; else - len = read(fd, buf->str, CHUNK_SIZE); + len = read(fd, buf->str, buf->allocated_len); if (len < 0) g_critical("Read failed: %s", g_strerror(errno)); if (len == 0 && !push_scan_data) @@ -147,14 +147,18 @@ static void load_input_file_module(struct df_arg_desc *df_arg) break; push_scan_data = FALSE; buf->len = len; - if (sr_input_send(in, buf) != SR_OK) + if (sr_input_send(in, buf) != SR_OK) { + g_critical("File import failed (read)"); break; + } sdi = sr_input_dev_inst_get(in); if (!got_sdi && sdi) { /* First time we got a valid sdi. */ - if (select_channels(sdi) != SR_OK) + if (select_channels(sdi) != SR_OK) { + g_critical("File import failed (channels)"); return; + } if (sr_session_dev_add(session, sdi) != SR_OK) { g_critical("Failed to use device."); sr_session_destroy(session); @@ -166,6 +170,7 @@ static void load_input_file_module(struct df_arg_desc *df_arg) sr_input_end(in); sr_input_free(in); g_string_free(buf, TRUE); + close(fd); df_arg->session = NULL; sr_session_destroy(session);