Skip to content

Commit b79bfaa

Browse files
committed
Add explanation for return value and tighten error checking for number of args passed
1 parent 075630b commit b79bfaa

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

doc/man/goto-inspect.1

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ If you encounter a problem please create an issue at
3030
.BR goto-cc (1)
3131
.BR goto-instrument (1)
3232
.SH COPYRIGHT
33-
2023, Fotis Koutoulakis
33+
2023, Diffblue Ltd.

src/goto-inspect/goto_inspect_parse_options.cpp

+11-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ int goto_inspect_parse_optionst::doit()
2121
return CPROVER_EXIT_SUCCESS;
2222
}
2323

24-
// Before we do anything else, positional arguments needs to be > 1.
25-
// (i.e. a filename has been given).
26-
if(cmdline.args.size() < 1)
24+
// Before we do anything else, ensure that positional + optional arguments > 2.
25+
// (i.e. a filename and an inspection option has been given).
26+
if(cmdline.args.size() < 2)
2727
{
2828
help();
2929
throw invalid_command_line_argument_exceptiont{
30-
"failed to supply a goto-binary name",
30+
"failed to supply a goto-binary name or an option for inspection",
3131
"<input goto-binary> <inspection-option>"};
3232
}
3333

@@ -63,7 +63,13 @@ int goto_inspect_parse_optionst::doit()
6363
return CPROVER_EXIT_SUCCESS;
6464
}
6565

66-
// No options was passed in - erroneously?
66+
// If an option + binary was provided, the program will have exited gracefully
67+
// through a different branch. If we hit the code below, it means that something
68+
// has gone wrong - normally both the happy and the error paths should be handled
69+
// through the dispatching if blocks above, but we need a return statement to
70+
// satisfy the compiler and the signature of `doit()`, hence why we have this
71+
// here as a dummy return value that attempts to be somewhat semantically relevant
72+
// and consistent to the behaviour of other tools.
6773
return CPROVER_EXIT_INCORRECT_TASK;
6874
}
6975

0 commit comments

Comments
 (0)