---
** [tickets:#262] typo in svf parameters renders no usable error message**
**Status:** new
**Milestone:** 0.9.0
**Created:** Fri Mar 20, 2020 02:39 PM UTC by Christian Braschwitz
**Last Updated:** Fri Mar 20, 2020 02:39 PM UTC
**Owner:** nobody
a typo like "svf myfile.svf -ignore_errors" (notice the s at the end) leads to
processing "-ignore_errors" as a file, overwriting the actual file variables,
not being able to open the file and eventually outputting the standart output,
even though "svf processing file: ..." was being printed.
svf.c
~~~
/* parse command line */
377 svf_quiet = 0;
378 svf_nil = 0;
379 svf_progress_enabled = 0;
380 svf_ignore_error = 0;
381 for (unsigned int i = 0; i < CMD_ARGC; i++) {
382 if (strcmp(CMD_ARGV[i], "-tap") == 0) {
383 tap = jtag_tap_by_string(CMD_ARGV[i+1]);
384 if (!tap) {
385 command_print(CMD_CTX, "Tap: %s unknown", CMD_ARGV[i+1]);
386 return ERROR_FAIL;
387 }
388 i++;
389 } else if ((strcmp(CMD_ARGV[i],
390 "quiet") == 0) || (strcmp(CMD_ARGV[i], "-quiet") == 0))
391 svf_quiet = 1;
392 else if ((strcmp(CMD_ARGV[i], "nil") == 0) ||
(strcmp(CMD_ARGV[i], "-nil") == 0))
393 svf_nil = 1;
394 else if ((strcmp(CMD_ARGV[i],
395 "progress") == 0) || (strcmp(CMD_ARGV[i], "-progress")
== 0))
396 svf_progress_enabled = 1;
397 else if ((strcmp(CMD_ARGV[i],
398 "ignore_error") == 0) || (strcmp(CMD_ARGV[i],
"-ignore_error") == 0))
399 svf_ignore_error = 1;
400 else {
401 svf_fd = fopen(CMD_ARGV[i], "r");
402 if (svf_fd == NULL) {
403 int err = errno;
404 command_print(CMD_CTX, "open(\"%s\"): %s", CMD_ARGV[i],
strerror(err));
405 /* no need to free anything now */
406 return ERROR_COMMAND_SYNTAX_ERROR;
407 } else
408 LOG_USER("svf processing file: \"%s\"", CMD_ARGV[i]);
409 }
410 }
~~~
I suggest there can only be one argument without a "-" in the beginning. every
other argmuent, must start with an "-", to differentiate between them.
---
Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is
subscribed to https://sourceforge.net/p/openocd/tickets/
To unsubscribe from further messages, a project admin can change settings at
https://sourceforge.net/p/openocd/admin/tickets/options. Or, if this is a
mailing list, you can unsubscribe from the mailing list.
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel