Skip to content

Commit 2aaaac2

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

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-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

+12-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,14 @@ 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 different a different branch. If we hit the code below, it means
68+
// that something has gone wrong - normally both the happy and the error paths
69+
// should be handled through the dispatching if blocks above, but we need a
70+
// return statement to satisfy the compiler and the signature of `doit()`,
71+
// hence why we have this here as a dummy return value that attempts to be
72+
// somewhat semantically relevant and consistent to the behaviour of other
73+
// tools.
6774
return CPROVER_EXIT_INCORRECT_TASK;
6875
}
6976

0 commit comments

Comments
 (0)