Skip to content

Commit 6171f06

Browse files
author
owen-jones-diffblue
authored
Merge pull request diffblue#392 from diffblue/owen-jones-diffblue/use-macros-for-exit-codes
Use existing macros for exit codes
2 parents 321746e + 949fb9b commit 6171f06

File tree

2 files changed

+286
-284
lines changed

2 files changed

+286
-284
lines changed

src/driver/sec_driver_parse_options.cpp

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include <util/msgstream.h>
4747
#include <util/prefix.h>
4848
#include <util/json_map_serializer.h>
49+
#include <util/exit_codes.h>
4950

5051
#include <cbmc/version.h>
5152

@@ -135,7 +136,7 @@ int sec_driver_parse_optionst::doit()
135136
if(cmdline.isset("version"))
136137
{
137138
std::cout << CBMC_VERSION << std::endl;
138-
return 0;
139+
return CPROVER_EXIT_SUCCESS;
139140
}
140141

141142
//
@@ -176,7 +177,7 @@ int sec_driver_parse_optionst::doit()
176177
{
177178
error() << "lazy-methods-context-sensitive requires --function to be set"
178179
<< messaget::eom;
179-
return 6;
180+
return CPROVER_EXIT_USAGE_ERROR;
180181
}
181182
csvsa_analysis=
182183
csvsa_load_and_analyze_functions(lazy_goto_model, get_message_handler());
@@ -189,14 +190,14 @@ int sec_driver_parse_optionst::doit()
189190
if(cmdline.isset("show-symbol-table"))
190191
{
191192
::show_symbol_table(lazy_goto_model.symbol_table, get_ui());
192-
return 6;
193+
return CPROVER_EXIT_SUCCESS;
193194
}
194195

195196
std::unique_ptr<goto_modelt> maybe_goto_model =
196197
lazy_goto_modelt::process_whole_model_and_freeze(
197198
std::move(lazy_goto_model));
198199
if(maybe_goto_model == nullptr)
199-
return 6;
200+
return CPROVER_EXIT_INTERNAL_ERROR;
200201
goto_modelt &goto_model = *maybe_goto_model;
201202

202203
// show it?
@@ -205,7 +206,7 @@ int sec_driver_parse_optionst::doit()
205206
namespacet ns(goto_model.symbol_table);
206207

207208
goto_model.goto_functions.output(ns, std::cout);
208-
return 6;
209+
return CPROVER_EXIT_SUCCESS;
209210
}
210211

211212
if (cmdline.isset("do-not-use-precise-access-paths"))
@@ -215,11 +216,20 @@ int sec_driver_parse_optionst::doit()
215216

216217
if (cmdline.isset("security-scanner"))
217218
{
218-
return taint_do_security_scan(
219-
cmdline.get_value("security-scanner"),
220-
goto_model,
221-
cmdline.isset("rebuild-taint-cache"),
222-
*this) ? 0 : 127;
219+
try
220+
{
221+
return taint_do_security_scan(
222+
cmdline.get_value("security-scanner"),
223+
goto_model,
224+
cmdline.isset("rebuild-taint-cache"),
225+
*this) ? CPROVER_EXIT_SUCCESS : CPROVER_EXIT_INCORRECT_TASK;
226+
}
227+
catch(const std::exception &e)
228+
{
229+
error()
230+
<< "ERROR: This exception was raised: " << e.what() << messaget::eom;
231+
return CPROVER_EXIT_EXCEPTION;
232+
}
223233
}
224234

225235
if(cmdline.isset("local-value-set-analysis"))
@@ -228,7 +238,7 @@ int sec_driver_parse_optionst::doit()
228238
if(dbpath=="")
229239
{
230240
error() << "Must specify lvsa-summary-directory" << eom;
231-
abort();
241+
return CPROVER_EXIT_USAGE_ERROR;
232242
}
233243

234244
json_map_serializert<irep_idt, lvsaa_single_external_set_summaryt>
@@ -252,7 +262,7 @@ int sec_driver_parse_optionst::doit()
252262
debug() << " " << f.first.c_str() << "\n";
253263
}
254264
debug() << eom;
255-
abort();
265+
return CPROVER_EXIT_INCORRECT_TASK;
256266
}
257267
const auto& gf=goto_model.goto_functions.function_map.at(fname);
258268
class_hierarchyt class_hierarchy;
@@ -330,7 +340,7 @@ int sec_driver_parse_optionst::doit()
330340
status() << dump_message << eom;
331341
}
332342
}
333-
return 0;
343+
return CPROVER_EXIT_SUCCESS;
334344
}
335345

336346
if(cmdline.isset("dump-html-program"))
@@ -347,7 +357,7 @@ int sec_driver_parse_optionst::doit()
347357
<< cmdline.get_value("dump-html-program")
348358
<< "' for the HTML dump exists."
349359
<< eom;
350-
return -1;
360+
return CPROVER_EXIT_INCORRECT_TASK;
351361
}
352362
class_hierarchyt class_hierarchy;
353363
class_hierarchy(goto_model.symbol_table);
@@ -361,12 +371,12 @@ int sec_driver_parse_optionst::doit()
361371
goto_model.symbol_table,
362372
inverted_topological_order,
363373
cmdline.get_value("dump-html-program"));
364-
return 0;
374+
return CPROVER_EXIT_SUCCESS;
365375
}
366376

367377
error() << "no analysis option given -- consider reading --help"
368378
<< eom;
369-
return 6;
379+
return CPROVER_EXIT_INCORRECT_TASK;
370380
}
371381

372382
void sec_driver_parse_optionst::process_goto_function(

0 commit comments

Comments
 (0)