X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fsvf%2Fsvf.c;h=223af7e182bbe3693fa18c857b780fcb7326ea57;hb=3117a318d42606cbcfd39559e144f6f6b0313fe9;hp=7b7b8d09d0a187ecabace4ed1aee4378bcd2ad8b;hpb=a652a4ea209d24d0f0ebcc73e5eaab14169f958d;p=openocd.git diff --git a/src/svf/svf.c b/src/svf/svf.c index 7b7b8d09d0..223af7e182 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -13,9 +13,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * + * along with this program. If not, see . * ***************************************************************************/ /* The specification for SVF is available here: @@ -363,7 +361,7 @@ COMMAND_HANDLER(handle_svf_command) #define SVF_MAX_NUM_OF_OPTIONS 5 int command_num = 0; int ret = ERROR_OK; - long long time_measure_ms; + int64_t time_measure_ms; int time_measure_s, time_measure_m; /* use NULL to indicate a "plain" svf file which accounts for @@ -537,7 +535,7 @@ COMMAND_HANDLER(handle_svf_command) time_measure_s %= 60; if (time_measure_ms < 1000) command_print(CMD_CTX, - "\r\nTime used: %dm%ds%lldms ", + "\r\nTime used: %dm%ds%" PRId64 "ms ", time_measure_m, time_measure_s, time_measure_ms); @@ -663,11 +661,13 @@ static int svf_read_command_from_file(FILE *fd) if (svf_getline(&svf_read_line, &svf_read_line_size, svf_fd) <= 0) return ERROR_FAIL; i = -1; + /* fallthrough */ case '\r': slash = 0; /* Don't save '\r' and '\n' if no data is parsed */ if (!cmd_pos) break; + /* fallthrough */ default: /* The parsing code currently expects a space * before parentheses -- "TDI (123)". Also a @@ -741,6 +741,9 @@ parse_char: pos++; } + if (num == 0) + return ERROR_FAIL; + *num_of_argu = num; return ERROR_OK; @@ -1313,7 +1316,7 @@ XXR_common: * SEC]] [ENDSTATE end_state] */ /* RUNTEST [run_state] min_time SEC [MAXIMUM max_time SEC] [ENDSTATE * end_state] */ - if ((num_of_argu < 3) && (num_of_argu > 11)) { + if ((num_of_argu < 3) || (num_of_argu > 11)) { LOG_ERROR("invalid parameter of %s", argus[0]); return ERROR_FAIL; }