summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-30 05:12:46 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-30 05:12:46 -0400
commit2aff35215fbe24459aa4057d5b31ea7490046ca6 (patch)
tree6a79a3d84e352e3b3647484b0daf38b1ae6aa81f /amount.cc
parent230d7fd6027d05422f4bb26e9bfb3758a9cb16ea (diff)
downloadledger-2aff35215fbe24459aa4057d5b31ea7490046ca6.tar.gz
ledger-2aff35215fbe24459aa4057d5b31ea7490046ca6.tar.bz2
ledger-2aff35215fbe24459aa4057d5b31ea7490046ca6.zip
Enabled a huge number of warning flags for g++ in acprep, and fixed them all
except for several unused parameter warnings (because there is so much code still #if 0'd out), and one implicit conversion from long long to long which still has to be dealt with.
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc27
1 files changed, 14 insertions, 13 deletions
diff --git a/amount.cc b/amount.cc
index 1749013e..617402fd 100644
--- a/amount.cc
+++ b/amount.cc
@@ -1283,7 +1283,7 @@ void amount_t::read(std::istream& in)
quantity = new bigint_t;
unsigned short len;
- in.read((char *)&len, sizeof(len));
+ in.read(reinterpret_cast<char *>(&len), sizeof(len));
assert(len < 4096);
in.read(buf, len);
mpz_import(MPZ(quantity), len / sizeof(short), 1, sizeof(short),
@@ -1294,10 +1294,10 @@ void amount_t::read(std::istream& in)
if (negative)
mpz_neg(MPZ(quantity), MPZ(quantity));
- in.read((char *)&quantity->prec, sizeof(quantity->prec));
+ in.read(reinterpret_cast<char *>(&quantity->prec), sizeof(quantity->prec));
bigint_t::flags_t tflags;
- in.read((char *)&tflags, sizeof(tflags));
+ in.read(reinterpret_cast<char *>(&tflags), sizeof(tflags));
quantity->set_flags(tflags);
}
else {
@@ -1328,13 +1328,14 @@ void amount_t::read(const char *& data)
if (byte < 3) {
if (byte == 2) {
- quantity = new((bigint_t *)bigints_next) bigint_t;
+ quantity = new(reinterpret_cast<bigint_t *>(bigints_next)) bigint_t;
bigints_next += sizeof(bigint_t);
} else {
quantity = new bigint_t;
}
- unsigned short len = *((unsigned short *) data);
+ unsigned short len =
+ *reinterpret_cast<unsigned short *>(const_cast<char *>(data));
data += sizeof(unsigned short);
mpz_import(MPZ(quantity), len / sizeof(short), 1, sizeof(short),
0, 0, data);
@@ -1344,18 +1345,18 @@ void amount_t::read(const char *& data)
if (negative)
mpz_neg(MPZ(quantity), MPZ(quantity));
- quantity->prec = *((precision_t *) data);
+ quantity->prec = *reinterpret_cast<precision_t *>(const_cast<char *>(data));
data += sizeof(precision_t);
- quantity->set_flags(*((flags_t *) data));
+ quantity->set_flags(*reinterpret_cast<flags_t *>(const_cast<char *>(data)));
data += sizeof(flags_t);
if (byte == 2)
quantity->add_flags(BIGINT_BULK_ALLOC);
} else {
- uint_fast32_t index = *((uint_fast32_t *) data);
+ uint_fast32_t index = *reinterpret_cast<uint_fast32_t *>(const_cast<char *>(data));
data += sizeof(uint_fast32_t);
- quantity = (bigint_t *) (bigints + (index - 1) * sizeof(bigint_t));
+ quantity = reinterpret_cast<bigint_t *>(bigints + (index - 1) * sizeof(bigint_t));
DEBUG("amounts.refs",
quantity << " ref++, now " << (quantity->ref + 1));
quantity->ref++;
@@ -1393,7 +1394,7 @@ void amount_t::write(std::ostream& out, bool optimized) const
std::size_t size;
mpz_export(buf, &size, 1, sizeof(short), 0, 0, MPZ(quantity));
unsigned short len = size * sizeof(short);
- out.write((char *)&len, sizeof(len));
+ out.write(reinterpret_cast<char *>(&len), sizeof(len));
if (len) {
assert(len < 4096);
out.write(buf, len);
@@ -1402,10 +1403,10 @@ void amount_t::write(std::ostream& out, bool optimized) const
byte = mpz_sgn(MPZ(quantity)) < 0 ? 1 : 0;
out.write(&byte, sizeof(byte));
- out.write((char *)&quantity->prec, sizeof(quantity->prec));
+ out.write(reinterpret_cast<char *>(&quantity->prec), sizeof(quantity->prec));
bigint_t::flags_t tflags = quantity->flags() & ~BIGINT_BULK_ALLOC;
assert(sizeof(tflags) == sizeof(bigint_t::flags_t));
- out.write((char *)&tflags, sizeof(tflags));
+ out.write(reinterpret_cast<char *>(&tflags), sizeof(tflags));
} else {
assert(quantity->ref > 1);
@@ -1413,7 +1414,7 @@ void amount_t::write(std::ostream& out, bool optimized) const
// out a reference to which one it was.
byte = 3;
out.write(&byte, sizeof(byte));
- out.write((char *)&quantity->index, sizeof(quantity->index));
+ out.write(reinterpret_cast<char *>(&quantity->index), sizeof(quantity->index));
}
}