Skip to content

Commit db75611

Browse files
author
martin
committed
Convert returned numbers to the appropriate symbolic exit codes and correct a few cases.
1 parent 27304c0 commit db75611

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

regression/goto-analyzer/regenerate-entry-function/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CORE
22
main.c
33
--function fun --show-goto-functions
44
^\s*fun\(x\);$
5-
^EXIT=6$
5+
^EXIT=0$
66
^SIGNAL=0$
77
--
88
^warning: ignoring

regression/goto-cc-goto-analyzer/regenerate-entry-function/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CORE
22
main.c
33
'--function fun --show-goto-functions'
44
^\s*fun\(x\);$
5-
^EXIT=6$
5+
^EXIT=0$
66
^SIGNAL=0$
77
--
88
^warning: ignoring

src/goto-analyzer/goto_analyzer_parse_options.cpp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void goto_analyzer_parse_optionst::get_command_line_options(optionst &options)
9999
if(config.set(cmdline))
100100
{
101101
usage_error();
102-
exit(1);
102+
exit(CPROVER_EXIT_USAGE_ERROR);
103103
}
104104

105105
#if 0
@@ -373,7 +373,7 @@ int goto_analyzer_parse_optionst::doit()
373373
if(cmdline.isset("version"))
374374
{
375375
std::cout << CBMC_VERSION << '\n';
376-
return 0;
376+
return CPROVER_EXIT_SUCCESS;
377377
}
378378

379379
//
@@ -402,35 +402,36 @@ int goto_analyzer_parse_optionst::doit()
402402
catch(const char *e)
403403
{
404404
error() << e << eom;
405-
return true;
405+
return CPROVER_EXIT_EXCEPTION;
406406
}
407407

408408
catch(const std::string &e)
409409
{
410410
error() << e << eom;
411-
return true;
411+
return CPROVER_EXIT_EXCEPTION;
412412
}
413413

414-
catch(int)
414+
catch(int e)
415415
{
416-
return true;
416+
error() << "Numeric exception: " << e << eom;
417+
return CPROVER_EXIT_EXCEPTION;
417418
}
418419

419420
if(process_goto_program(options))
420-
return 6;
421+
return CPROVER_EXIT_INTERNAL_ERROR;
421422

422423
// show it?
423424
if(cmdline.isset("show-symbol-table"))
424425
{
425426
::show_symbol_table(goto_model.symbol_table, get_ui());
426-
return 6;
427+
return CPROVER_EXIT_SUCCESS;
427428
}
428429

429430
// show it?
430431
if(cmdline.isset("show-goto-functions"))
431432
{
432433
show_goto_functions(goto_model, get_ui());
433-
return 6;
434+
return CPROVER_EXIT_SUCCESS;
434435
}
435436

436437
try
@@ -474,15 +475,15 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
474475
if(cmdline.isset("show-taint"))
475476
{
476477
taint_analysis(goto_model, taint_file, get_message_handler(), true, "");
477-
return 0;
478+
return CPROVER_EXIT_SUCCESS;
478479
}
479480
else
480481
{
481482
std::string json_file=cmdline.get_value("json");
482483
bool result=
483484
taint_analysis(
484485
goto_model, taint_file, get_message_handler(), false, json_file);
485-
return result?10:0;
486+
return result ? CPROVER_EXIT_VERIFICATION_UNSAFE : CPROVER_EXIT_SUCCESS;
486487
}
487488
}
488489

@@ -503,13 +504,13 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
503504
{
504505
error() << "Failed to open json output `"
505506
<< json_file << "'" << eom;
506-
return 6;
507+
return CPROVER_EXIT_INTERNAL_ERROR;
507508
}
508509

509510
unreachable_instructions(goto_model, true, ofs);
510511
}
511512

512-
return 0;
513+
return CPROVER_EXIT_SUCCESS;
513514
}
514515

515516
if(options.get_bool_option("unreachable-functions") &&
@@ -528,13 +529,13 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
528529
{
529530
error() << "Failed to open json output `"
530531
<< json_file << "'" << eom;
531-
return 6;
532+
return CPROVER_EXIT_INTERNAL_ERROR;
532533
}
533534

534535
unreachable_functions(goto_model, true, ofs);
535536
}
536537

537-
return 0;
538+
return CPROVER_EXIT_SUCCESS;
538539
}
539540

540541
if(options.get_bool_option("reachable-functions") &&
@@ -553,13 +554,13 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
553554
{
554555
error() << "Failed to open json output `"
555556
<< json_file << "'" << eom;
556-
return 6;
557+
return CPROVER_EXIT_INTERNAL_ERROR;
557558
}
558559

559560
reachable_functions(goto_model, true, ofs);
560561
}
561562

562-
return 0;
563+
return CPROVER_EXIT_SUCCESS;
563564
}
564565

565566
if(options.get_bool_option("show-local-may-alias"))
@@ -576,19 +577,19 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
576577
std::cout << '\n';
577578
}
578579

579-
return 0;
580+
return CPROVER_EXIT_SUCCESS;
580581
}
581582

582583
label_properties(goto_model);
583584

584585
if(cmdline.isset("show-properties"))
585586
{
586587
show_properties(goto_model, get_ui());
587-
return 0;
588+
return CPROVER_EXIT_SUCCESS;
588589
}
589590

590591
if(set_properties())
591-
return 7;
592+
return CPROVER_EXIT_SET_PROPERTIES_FAILED;
592593

593594
if(options.get_bool_option("general-analysis"))
594595
{
@@ -689,7 +690,7 @@ int goto_analyzer_parse_optionst::perform_analysis(const optionst &options)
689690
// Final defensive error case
690691
error() << "no analysis option given -- consider reading --help"
691692
<< eom;
692-
return 6;
693+
return CPROVER_EXIT_USAGE_ERROR;
693694
}
694695

695696
bool goto_analyzer_parse_optionst::set_properties()

0 commit comments

Comments
 (0)