summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-06-08 04:13:20 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:39:08 -0400
commitb7b4c079266e0e9ef18dbe006a4a135643cf890b (patch)
treec1196c1e39dc97024f9b306d564f7b1e0dac84d3
parentec850814fdd6424db791ef79cab82eb2a2e5afbe (diff)
downloadfork-ledger-b7b4c079266e0e9ef18dbe006a4a135643cf890b.tar.gz
fork-ledger-b7b4c079266e0e9ef18dbe006a4a135643cf890b.tar.bz2
fork-ledger-b7b4c079266e0e9ef18dbe006a4a135643cf890b.zip
r384@user1022: johnw | 2007-06-08 00:08:53 -0400
Corrected several minor warnings
-rwxr-xr-xacprep31
-rw-r--r--src/data/compile.cc23
-rw-r--r--src/data/document.cc5
-rw-r--r--src/data/journal.cc15
-rw-r--r--src/driver/report.cc5
-rw-r--r--src/numerics/value.cc16
-rw-r--r--src/utility/binary.cc6
-rw-r--r--src/utility/binary.h42
8 files changed, 71 insertions, 72 deletions
diff --git a/acprep b/acprep
index 513a2585..43486a1f 100755
--- a/acprep
+++ b/acprep
@@ -49,21 +49,22 @@ LDFLAGS="$LIBDIRS"
LOCAL=false
# Warning flags
-CXXFLAGS="$CXXFLAGS -Wall -Wextra -ansi"
-CXXFLAGS="$CXXFLAGS -Weffc++"
-CXXFLAGS="$CXXFLAGS -Wcast-align"
-CXXFLAGS="$CXXFLAGS -Wcast-qual"
-CXXFLAGS="$CXXFLAGS -Wconversion"
-CXXFLAGS="$CXXFLAGS -Wfloat-equal"
-CXXFLAGS="$CXXFLAGS -Wmissing-field-initializers"
-CXXFLAGS="$CXXFLAGS -Wno-endif-labels"
-CXXFLAGS="$CXXFLAGS -Wold-style-cast"
-CXXFLAGS="$CXXFLAGS -Woverloaded-virtual"
-CXXFLAGS="$CXXFLAGS -Wshorten-64-to-32"
-CXXFLAGS="$CXXFLAGS -Wsign-compare"
-CXXFLAGS="$CXXFLAGS -Wsign-promo"
-CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
-CXXFLAGS="$CXXFLAGS -Wwrite-strings"
+CXXFLAGS="$CXXFLAGS -Wall -ansi"
+#CXXFLAGS="$CXXFLAGS -Wextra"
+#CXXFLAGS="$CXXFLAGS -Weffc++"
+#CXXFLAGS="$CXXFLAGS -Wcast-align"
+#CXXFLAGS="$CXXFLAGS -Wcast-qual"
+#CXXFLAGS="$CXXFLAGS -Wconversion"
+#CXXFLAGS="$CXXFLAGS -Wfloat-equal"
+#CXXFLAGS="$CXXFLAGS -Wmissing-field-initializers"
+#CXXFLAGS="$CXXFLAGS -Wno-endif-labels"
+#CXXFLAGS="$CXXFLAGS -Wold-style-cast"
+#CXXFLAGS="$CXXFLAGS -Woverloaded-virtual"
+#CXXFLAGS="$CXXFLAGS -Wshorten-64-to-32"
+#CXXFLAGS="$CXXFLAGS -Wsign-compare"
+#CXXFLAGS="$CXXFLAGS -Wsign-promo"
+#CXXFLAGS="$CXXFLAGS -Wstrict-null-sentinel"
+#CXXFLAGS="$CXXFLAGS -Wwrite-strings"
while [ -n "$1" ]; do
diff --git a/src/data/compile.cc b/src/data/compile.cc
index 0b924418..07ce9394 100644
--- a/src/data/compile.cc
+++ b/src/data/compile.cc
@@ -130,20 +130,16 @@ void transaction_node_t::parse_amount_expr(xpath_t::scope_t& scope,
// Parse the optional cost (@ PER-UNIT-COST, @@ TOTAL-COST)
- unsigned int linenum = -1;
-
if (in.good() && ! in.eof()) {
char c = peek_next_nonws(in);
if (c == '@') {
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Found a price indicator");
+ DEBUG("ledger.textual.parse", "Found a price indicator");
bool per_unit = true;
in.get(c);
if (in.peek() == '@') {
in.get(c);
per_unit = false;
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "And it's for a total price");
+ DEBUG("ledger.textual.parse", "And it's for a total price");
}
if (in.good() && ! in.eof()) {
@@ -179,22 +175,17 @@ void transaction_node_t::parse_amount_expr(xpath_t::scope_t& scope,
transaction->entry->code));
}
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Total cost is " << cost);
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Per-unit cost is " << per_unit_cost);
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Annotated amount is " << base_amount);
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Bare amount is " << base_amount.number());
+ DEBUG("ledger.textual.parse", "Total cost is " << cost);
+ DEBUG("ledger.textual.parse", "Per-unit cost is " << per_unit_cost);
+ DEBUG("ledger.textual.parse", "Annotated amount is " << base_amount);
+ DEBUG("ledger.textual.parse", "Bare amount is " << base_amount.number());
}
}
}
amount->in_place_reduce();
- DEBUG("ledger.textual.parse", "line " << linenum << ": " <<
- "Reduced amount is " << *amount);
+ DEBUG("ledger.textual.parse", "Reduced amount is " << *amount);
}
void transaction_node_t::compile(xpath_t::scope_t& scope)
diff --git a/src/data/document.cc b/src/data/document.cc
index 120440b0..41bf77a3 100644
--- a/src/data/document.cc
+++ b/src/data/document.cc
@@ -121,13 +121,14 @@ optional<node_t::nameid_t> document_t::lookup_name_id(const string& name) const
optional<node_t::nameid_t> document_t::lookup_builtin_id(const string& name)
{
int first = 0;
- int last = (int)ledger_builtins_size;
+ int last = static_cast<int>(ledger_builtins_size);
while (first <= last) {
int mid = (first + last) / 2; // compute mid point.
int result;
- if ((result = (int)name[0] - (int)ledger_builtins[mid][0]) == 0)
+ if ((result = (static_cast<int>(name[0]) -
+ static_cast<int>(ledger_builtins[mid][0]))) == 0)
result = std::strcmp(name.c_str(), ledger_builtins[mid]);
if (result > 0)
diff --git a/src/data/journal.cc b/src/data/journal.cc
index 17294820..bb33f4dc 100644
--- a/src/data/journal.cc
+++ b/src/data/journal.cc
@@ -542,18 +542,22 @@ journal_t::~journal_t()
// be deleted.
for (entries_list::iterator i = entries.begin();
i != entries.end();
- i++)
+ i++) {
if (! item_pool ||
- ((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
+ reinterpret_cast<char *>(*i) < item_pool ||
+ reinterpret_cast<char *>(*i) >= item_pool_end) {
checked_delete(*i);
- else
+ } else {
(*i)->~entry_t();
+ }
+ }
for (auto_entries_list::iterator i = auto_entries.begin();
i != auto_entries.end();
i++)
if (! item_pool ||
- ((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
+ reinterpret_cast<char *>(*i) < item_pool ||
+ reinterpret_cast<char *>(*i) >= item_pool_end)
checked_delete(*i);
else
(*i)->~auto_entry_t();
@@ -562,7 +566,8 @@ journal_t::~journal_t()
i != period_entries.end();
i++)
if (! item_pool ||
- ((char *) *i) < item_pool || ((char *) *i) >= item_pool_end)
+ reinterpret_cast<char *>(*i) < item_pool ||
+ reinterpret_cast<char *>(*i) >= item_pool_end)
checked_delete(*i);
else
(*i)->~period_entry_t();
diff --git a/src/driver/report.cc b/src/driver/report.cc
index ee3382da..0404adc7 100644
--- a/src/driver/report.cc
+++ b/src/driver/report.cc
@@ -59,13 +59,14 @@ value_t report_t::abbrev(xml::xpath_t::call_scope_t& args)
elision_style_t style = session.elision_style;
if (args.size() == 3)
- style = (elision_style_t)args[2].as_long();
+ style = static_cast<elision_style_t>(args[2].as_long());
long abbrev_len = session.abbrev_length;
if (args.size() == 4)
abbrev_len = args[3].as_long();
- return value_t(abbreviate(str, wid, style, true, (int)abbrev_len), true);
+ return value_t(abbreviate(str, wid, style, true,
+ static_cast<int>(abbrev_len)), true);
}
value_t report_t::ftime(xml::xpath_t::call_scope_t& args)
diff --git a/src/numerics/value.cc b/src/numerics/value.cc
index bdb102c5..ea84a5a8 100644
--- a/src/numerics/value.cc
+++ b/src/numerics/value.cc
@@ -41,22 +41,22 @@ void value_t::storage_t::destroy()
{
switch (type) {
case AMOUNT:
- ((amount_t *)data)->~amount_t();
+ reinterpret_cast<amount_t *>(data)->~amount_t();
break;
case BALANCE:
- checked_delete(*(balance_t **)data);
+ checked_delete(*reinterpret_cast<balance_t **>(data));
break;
case BALANCE_PAIR:
- checked_delete(*(balance_pair_t **)data);
+ checked_delete(*reinterpret_cast<balance_pair_t **>(data));
break;
case STRING:
- ((string *)data)->~string();
+ reinterpret_cast<string *>(data)->~string();
break;
case SEQUENCE:
- checked_delete(*(sequence_t **)data);
+ checked_delete(*reinterpret_cast<sequence_t **>(data));
break;
case POINTER:
- ((boost::any *)data)->~any();
+ reinterpret_cast<boost::any *>(data)->~any();
break;
default:
@@ -73,11 +73,11 @@ void value_t::initialize()
true_value = new storage_t;
true_value->type = BOOLEAN;
- *(bool *) true_value->data = true;
+ *reinterpret_cast<bool *>(true_value->data) = true;
false_value = new storage_t;
false_value->type = BOOLEAN;
- *(bool *) false_value->data = false;
+ *reinterpret_cast<bool *>(false_value->data) = false;
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(bool));
BOOST_STATIC_ASSERT(sizeof(amount_t) >= sizeof(moment_t));
diff --git a/src/utility/binary.cc b/src/utility/binary.cc
index 5802c3bd..52d5f196 100644
--- a/src/utility/binary.cc
+++ b/src/utility/binary.cc
@@ -38,7 +38,7 @@ void read_bool(std::istream& in, bool& num)
{
read_guard(in, 0x2005);
unsigned char val;
- in.read((char *)&val, sizeof(val));
+ in.read(reinterpret_cast<char *>(&val), sizeof(val));
num = val == 1;
read_guard(in, 0x2006);
}
@@ -46,7 +46,7 @@ void read_bool(std::istream& in, bool& num)
void read_bool(const char *& data, bool& num)
{
read_guard(data, 0x2005);
- unsigned char val = *((unsigned char *) data);
+ const unsigned char val = *reinterpret_cast<const unsigned char *>(data);
data += sizeof(unsigned char);
num = val == 1;
read_guard(data, 0x2006);
@@ -130,7 +130,7 @@ void write_bool(std::ostream& out, bool num)
{
write_guard(out, 0x2005);
unsigned char val = num ? 1 : 0;
- out.write((char *)&val, sizeof(val));
+ out.write(reinterpret_cast<char *>(&val), sizeof(val));
write_guard(out, 0x2006);
}
diff --git a/src/utility/binary.h b/src/utility/binary.h
index 74199c89..864c6ea2 100644
--- a/src/utility/binary.h
+++ b/src/utility/binary.h
@@ -37,12 +37,12 @@ namespace binary {
template <typename T>
inline void read_number_nocheck(std::istream& in, T& num) {
- in.read((char *)&num, sizeof(num));
+ in.read(reinterpret_cast<char *>(&num), sizeof(num));
}
template <typename T>
inline void read_number_nocheck(const char *& data, T& num) {
- num = *((T *) data);
+ num = *reinterpret_cast<const T *>(data);
data += sizeof(T);
}
@@ -71,14 +71,14 @@ inline T read_number_nocheck(const char *& data) {
template <typename T>
inline void read_number(std::istream& in, T& num) {
read_guard(in, 0x2003);
- in.read((char *)&num, sizeof(num));
+ in.read(reinterpret_cast<char *>(&num), sizeof(num));
read_guard(in, 0x2004);
}
template <typename T>
inline void read_number(const char *& data, T& num) {
read_guard(data, 0x2003);
- num = *((T *) data);
+ num = *reinterpret_cast<const T *>(data);
data += sizeof(T);
read_guard(data, 0x2004);
}
@@ -124,19 +124,19 @@ void read_long(std::istream& in, T& num)
unsigned char temp;
if (len > 3) {
read_number_nocheck(in, temp);
- num |= ((unsigned long)temp) << 24;
+ num |= static_cast<unsigned long>(temp) << 24;
}
if (len > 2) {
read_number_nocheck(in, temp);
- num |= ((unsigned long)temp) << 16;
+ num |= static_cast<unsigned long>(temp) << 16;
}
if (len > 1) {
read_number_nocheck(in, temp);
- num |= ((unsigned long)temp) << 8;
+ num |= static_cast<unsigned long>(temp) << 8;
}
read_number_nocheck(in, temp);
- num |= ((unsigned long)temp);
+ num |= static_cast<unsigned long>(temp);
read_guard(in, 0x2002);
}
@@ -153,19 +153,19 @@ void read_long(const char *& data, T& num)
unsigned char temp;
if (len > 3) {
read_number_nocheck(data, temp);
- num |= ((unsigned long)temp) << 24;
+ num |= static_cast<unsigned long>(temp) << 24;
}
if (len > 2) {
read_number_nocheck(data, temp);
- num |= ((unsigned long)temp) << 16;
+ num |= static_cast<unsigned long>(temp) << 16;
}
if (len > 1) {
read_number_nocheck(data, temp);
- num |= ((unsigned long)temp) << 8;
+ num |= static_cast<unsigned long>(temp) << 8;
}
read_number_nocheck(data, temp);
- num |= ((unsigned long)temp);
+ num |= static_cast<unsigned long>(temp);
read_guard(data, 0x2002);
}
@@ -203,7 +203,7 @@ inline string read_string(const char *& data) {
template <typename T>
inline void write_number_nocheck(std::ostream& out, T num) {
- out.write((char *)&num, sizeof(num));
+ out.write(reinterpret_cast<char *>(&num), sizeof(num));
}
#if DEBUG_LEVEL >= ALPHA
@@ -216,7 +216,7 @@ inline void write_number_nocheck(std::ostream& out, T num) {
template <typename T>
inline void write_number(std::ostream& out, T num) {
write_guard(out, 0x2003);
- out.write((char *)&num, sizeof(num));
+ out.write(reinterpret_cast<char *>(&num), sizeof(num));
write_guard(out, 0x2004);
}
@@ -228,29 +228,29 @@ void write_long(std::ostream& out, T num)
write_guard(out, 0x2001);
unsigned char len = 4;
- if (((unsigned long)num) < 0x00000100UL)
+ if (static_cast<unsigned long>(num) < 0x00000100UL)
len = 1;
- else if (((unsigned long)num) < 0x00010000UL)
+ else if (static_cast<unsigned long>(num) < 0x00010000UL)
len = 2;
- else if (((unsigned long)num) < 0x01000000UL)
+ else if (static_cast<unsigned long>(num) < 0x01000000UL)
len = 3;
write_number_nocheck<unsigned char>(out, len);
unsigned char temp;
if (len > 3) {
- temp = (((unsigned long)num) & 0xFF000000UL) >> 24;
+ temp = (static_cast<unsigned long>(num) & 0xFF000000UL) >> 24;
write_number_nocheck(out, temp);
}
if (len > 2) {
- temp = (((unsigned long)num) & 0x00FF0000UL) >> 16;
+ temp = (static_cast<unsigned long>(num) & 0x00FF0000UL) >> 16;
write_number_nocheck(out, temp);
}
if (len > 1) {
- temp = (((unsigned long)num) & 0x0000FF00UL) >> 8;
+ temp = (static_cast<unsigned long>(num) & 0x0000FF00UL) >> 8;
write_number_nocheck(out, temp);
}
- temp = (((unsigned long)num) & 0x000000FFUL);
+ temp = (static_cast<unsigned long>(num) & 0x000000FFUL);
write_number_nocheck(out, temp);
write_guard(out, 0x2002);