encoding: silence gcc-4.8 overflow warnings.
Change-Id: I9a7e08b5c03a5811e846b9a545169e6d76e608ff
Refs: #1459
diff --git a/src/encoding/tlv.hpp b/src/encoding/tlv.hpp
index 60fad5d..80b17b5 100644
--- a/src/encoding/tlv.hpp
+++ b/src/encoding/tlv.hpp
@@ -344,23 +344,23 @@
writeVarNumber(std::ostream& os, uint64_t varNumber)
{
if (varNumber < 253) {
- os.put(static_cast<uint8_t> (varNumber));
+ os.put(static_cast<char>(varNumber));
return 1;
}
else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
- os.put(253);
- uint16_t value = htobe16(static_cast<uint16_t> (varNumber));
+ os.put(static_cast<char>(253));
+ uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
os.write(reinterpret_cast<const char*>(&value), 2);
return 3;
}
else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
- os.put(254);
- uint32_t value = htobe32(static_cast<uint32_t> (varNumber));
+ os.put(static_cast<char>(254));
+ uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
os.write(reinterpret_cast<const char*>(&value), 4);
return 5;
}
else {
- os.put(255);
+ os.put(static_cast<char>(255));
uint64_t value = htobe64(varNumber);
os.write(reinterpret_cast<const char*>(&value), 8);
return 9;
@@ -499,16 +499,16 @@
writeNonNegativeInteger(std::ostream& os, uint64_t varNumber)
{
if (varNumber < 253) {
- os.put(static_cast<uint8_t> (varNumber));
+ os.put(static_cast<char>(varNumber));
return 1;
}
else if (varNumber <= std::numeric_limits<uint16_t>::max()) {
- uint16_t value = htobe16(static_cast<uint16_t> (varNumber));
+ uint16_t value = htobe16(static_cast<uint16_t>(varNumber));
os.write(reinterpret_cast<const char*>(&value), 2);
return 2;
}
else if (varNumber <= std::numeric_limits<uint32_t>::max()) {
- uint32_t value = htobe32(static_cast<uint32_t> (varNumber));
+ uint32_t value = htobe32(static_cast<uint32_t>(varNumber));
os.write(reinterpret_cast<const char*>(&value), 4);
return 4;
}