summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorAndres Noetzli <noetzli@stanford.edu>2017-05-15 08:39:16 -0700
committerAndres Noetzli <noetzli@stanford.edu>2017-05-15 14:53:38 -0700
commit41460b380a9538e2bd06c42c25ccf20f0644f600 (patch)
tree682070ddc170cfd4aa9ebfcce08475b949c5d9e0 /src/util
parent31681c7ff2a1469f5efc325fc1b3a406e3a85949 (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/util')
-rw-r--r--src/util/safe_print.cpp7
-rw-r--r--src/util/statistics.cpp4
-rw-r--r--src/util/statistics_registry.h2
3 files changed, 6 insertions, 7 deletions
diff --git a/src/util/safe_print.cpp b/src/util/safe_print.cpp
index ff5a7aa7e..dc986e251 100644
--- a/src/util/safe_print.cpp
+++ b/src/util/safe_print.cpp
@@ -128,9 +128,8 @@ void safe_print(int fd, const double& _d) {
d -= c;
i++;
}
- if (i == 0) {
- safe_print(fd, "0");
- } else if (write(fd, buf, i) != i) {
+
+ if (write(fd, buf, i) != i) {
abort();
}
}
@@ -172,7 +171,7 @@ void safe_print_hex(int fd, uint64_t i) {
// This loop fills the buffer from the end. The number of elements in the
// buffer is BUFER_SIZE - idx - 1 and they start at position idx + 1.
- size_t idx = BUFFER_SIZE - 1;
+ ssize_t idx = BUFFER_SIZE - 1;
while (i != 0 && idx >= 0) {
char current = i % 16;
if (current <= 9) {
diff --git a/src/util/statistics.cpp b/src/util/statistics.cpp
index 73ea5b1b1..9423c9379 100644
--- a/src/util/statistics.cpp
+++ b/src/util/statistics.cpp
@@ -122,8 +122,8 @@ void StatisticsBase::safeFlushInformation(int fd) const {
for (StatSet::iterator i = d_stats.begin(); i != d_stats.end(); ++i) {
Stat* s = *i;
if (d_prefix.size() != 0) {
- safe_print(fd, d_prefix.c_str());
- safe_print(fd, s_regDelim.c_str());
+ safe_print(fd, d_prefix);
+ safe_print(fd, s_regDelim);
}
s->safeFlushStat(fd);
safe_print(fd, "\n");
diff --git a/src/util/statistics_registry.h b/src/util/statistics_registry.h
index 1206a3e4a..bd7f87b44 100644
--- a/src/util/statistics_registry.h
+++ b/src/util/statistics_registry.h
@@ -137,7 +137,7 @@ public:
*/
virtual void safeFlushStat(int fd) const {
if (__CVC4_USE_STATISTICS) {
- safe_print(fd, d_name.c_str());
+ safe_print(fd, d_name);
safe_print(fd, ", ");
safeFlushInformation(fd);
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback