Skip to content

Commit 271fc32

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

File tree

2 files changed

+11
-6
lines changed

2 files changed

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

+10-5
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ 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 a file argument has been given.
25+
if(cmdline.args.size() != 1)
2726
{
2827
help();
2928
throw invalid_command_line_argument_exceptiont{
30-
"failed to supply a goto-binary name",
29+
"failed to supply a goto-binary name or an option for inspection",
3130
"<input goto-binary> <inspection-option>"};
3231
}
3332

@@ -63,7 +62,13 @@ int goto_inspect_parse_optionst::doit()
6362
return CPROVER_EXIT_SUCCESS;
6463
}
6564

66-
// No options was passed in - erroneously?
65+
// If an option + binary was provided, the program will have exited gracefully
66+
// through a different branch. If we hit the code below, it means that something
67+
// has gone wrong - it's also possible to fall through this case if no optional
68+
// inspection flag is present in the argument vector. This will ensure that the
69+
// return value in that case is semantically meaningful, and provide a return
70+
// value that also satisfies the compiler's requirements based on the signature
71+
// of `doit()`.
6772
return CPROVER_EXIT_INCORRECT_TASK;
6873
}
6974

0 commit comments

Comments
 (0)