diff options
author | Andres Noetzli <noetzli@stanford.edu> | 2017-05-15 08:39:16 -0700 |
---|---|---|
committer | Andres Noetzli <noetzli@stanford.edu> | 2017-05-15 14:53:38 -0700 |
commit | 41460b380a9538e2bd06c42c25ccf20f0644f600 (patch) | |
tree | 682070ddc170cfd4aa9ebfcce08475b949c5d9e0 /src/main | |
parent | 31681c7ff2a1469f5efc325fc1b3a406e3a85949 (diff) |
Minor fix in safe_print function
This commit fixes two issues reported by Coverity:
- Fixes the check whether the buffer is full in safe_print_hex
- Removes dead code in safe_print for floating-point values
Additionally, it fixes an issue reported by Andy where the names of the
statistics were printed as "<unsupported>" due to calling the const char*
version instead of the std::string version of safe_print.
Finally, this fixes an issue where --segv-spin would not print the program name
because it was a const char*. The program name is now stored as a string.
NOTE: As a side effect, the last part also fixes Coverity issue 1362944, which
has been in CVC4 for a long time.
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/driver_unified.cpp | 5 | ||||
-rw-r--r-- | src/main/main.h | 2 | ||||
-rw-r--r-- | src/main/util.cpp | 12 |
3 files changed, 10 insertions, 9 deletions
diff --git a/src/main/driver_unified.cpp b/src/main/driver_unified.cpp index 6de4f9ff4..5113bab10 100644 --- a/src/main/driver_unified.cpp +++ b/src/main/driver_unified.cpp @@ -61,7 +61,7 @@ namespace CVC4 { const char *progPath; /** Just the basename component of argv[0] */ - const char *progName; + const std::string *progName; /** A pointer to the CommandExecutor (the signal handlers need it) */ CVC4::main::CommandExecutor* pExecutor = NULL; @@ -112,7 +112,8 @@ int runCvc4(int argc, char* argv[], Options& opts) { } # endif - progName = opts.getBinaryName().c_str(); + string progNameStr = opts.getBinaryName(); + progName = &progNameStr; if( opts.getHelp() ) { printUsage(opts, true); diff --git a/src/main/main.h b/src/main/main.h index 8277d366a..e4723a743 100644 --- a/src/main/main.h +++ b/src/main/main.h @@ -38,7 +38,7 @@ class CommandExecutor; extern const char* progPath; /** Just the basename component of argv[0] */ -extern const char* progName; +extern const std::string* progName; /** A reference for use by the signal handlers to print statistics */ extern CVC4::main::CommandExecutor* pExecutor; diff --git a/src/main/util.cpp b/src/main/util.cpp index 744122cc8..9dc5049a9 100644 --- a/src/main/util.cpp +++ b/src/main/util.cpp @@ -112,14 +112,14 @@ void segv_handler(int sig, siginfo_t* info, void* c) { safe_print(STDERR_FILENO, "Spinning so that a debugger can be connected.\n"); safe_print(STDERR_FILENO, "Try: gdb "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, " "); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, "\n"); safe_print(STDERR_FILENO, " or: gdb --pid="); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, " "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, "\n"); for(;;) { sleep(60); @@ -156,14 +156,14 @@ void ill_handler(int sig, siginfo_t* info, void*) { safe_print(STDERR_FILENO, "Spinning so that a debugger can be connected.\n"); safe_print(STDERR_FILENO, "Try: gdb "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, " "); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, "\n"); safe_print(STDERR_FILENO, " or: gdb --pid="); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, " "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, "\n"); for(;;) { sleep(60); @@ -206,14 +206,14 @@ void cvc4unexpected() { safe_print(STDERR_FILENO, "Spinning so that a debugger can be connected.\n"); safe_print(STDERR_FILENO, "Try: gdb "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, " "); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, "\n"); safe_print(STDERR_FILENO, " or: gdb --pid="); safe_print<int64_t>(STDERR_FILENO, getpid()); safe_print(STDERR_FILENO, " "); - safe_print(STDERR_FILENO, progName); + safe_print(STDERR_FILENO, *progName); safe_print(STDERR_FILENO, "\n"); for(;;) { sleep(60); |