diff --git a/qdl.c b/qdl.c index cd94600..b9f96b9 100644 --- a/qdl.c +++ b/qdl.c @@ -463,6 +463,7 @@ int main(int argc, char **argv) unsigned int slot = UINT_MAX; struct qdl_device *qdl = NULL; enum QDL_DEVICE_TYPE qdl_dev_type = QDL_DEVICE_USB; + bool run_firehose = false; static struct option options[] = { {"debug", no_argument, 0, 'd'}, @@ -534,8 +535,8 @@ int main(int argc, char **argv) } } - /* at least 2 non optional args required */ - if ((optind + 2) > argc) { + /* the programmer arg is always required. */ + if ((optind + 1) > argc) { print_usage(stderr); return 1; } @@ -574,7 +575,8 @@ int main(int argc, char **argv) if (ret < 0) exit(1); - do { + while (optind < argc) { + run_firehose = true; type = detect_type(argv[optind]); if (type < 0 || type == QDL_FILE_UNKNOWN) errx(1, "failed to detect file type of %s\n", argv[optind]); @@ -627,7 +629,8 @@ int main(int argc, char **argv) errx(1, "%s type not yet supported", argv[optind]); break; } - } while (++optind < argc); + ++optind; + } ret = qdl_open(qdl, serial); if (ret) @@ -639,9 +642,9 @@ int main(int argc, char **argv) if (ret < 0) goto out_cleanup; - if (ufs_need_provisioning()) + if (run_firehose && ufs_need_provisioning()) ret = firehose_provision(qdl); - else + else if (run_firehose) ret = firehose_run(qdl); if (ret < 0) goto out_cleanup;