More compliance fixes

This commit is contained in:
Pavel Kirienko
2014-04-17 12:23:31 +04:00
parent cff3a24883
commit 03ff492bc4
4 changed files with 6 additions and 6 deletions
@@ -52,7 +52,7 @@ public:
{
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType IntType;
typedef typename NativeFloatSelector<BitLen>::Type FloatType;
StaticAssert<sizeof(FloatType) * 8 == BitLen && std::numeric_limits<FloatType>::is_iec559>::check();
StaticAssert<sizeof(FloatType) * 8 == BitLen>::check();
union { IntType i; FloatType f; } u;
u.f = value;
return u.i;
@@ -64,7 +64,7 @@ public:
{
typedef typename IntegerSpec<BitLen, SignednessUnsigned, CastModeTruncate>::StorageType IntType;
typedef typename NativeFloatSelector<BitLen>::Type FloatType;
StaticAssert<sizeof(FloatType) * 8 == BitLen && std::numeric_limits<FloatType>::is_iec559>::check();
StaticAssert<sizeof(FloatType) * 8 == BitLen>::check();
union { IntType i; FloatType f; } u;
u.i = value;
return u.f;
@@ -126,7 +126,7 @@ int ScalarCodec::decode(T& value)
if (read_res > 0)
{
convertByteOrder<BitLen>(byte_union.bytes);
fixTwosComplement<BitLen>(byte_union.value);
fixTwosComplement<BitLen, T>(byte_union.value);
value = byte_union.value;
}
return read_res;
+2 -2
View File
@@ -57,7 +57,7 @@ bool Frame::parse(const CanFrame& can_frame)
return false;
}
if (can_frame.dlc > sizeof(CanFrame::data))
if (can_frame.dlc > sizeof(can_frame.data))
{
assert(0); // This is not a protocol error, so assert() is ok
return false;
@@ -148,7 +148,7 @@ bool Frame::compile(CanFrame& out_can_frame) const
case TransferTypeServiceRequest:
case TransferTypeMessageUnicast:
{
assert((payload_len_ + 1) <= sizeof(CanFrame::data));
assert((payload_len_ + 1) <= sizeof(out_can_frame.data));
out_can_frame.data[0] = dst_node_id_.get();
out_can_frame.dlc = payload_len_ + 1;
std::copy(payload_, payload_ + payload_len_, out_can_frame.data + 1);
@@ -44,7 +44,7 @@ int TransferSender::send(const uint8_t* payload, int payload_len, MonotonicTime
TransferCRC crc = crc_base_;
crc.add(payload, payload_len);
static const int BUFLEN = sizeof(CanFrame::data);
static const int BUFLEN = sizeof(static_cast<CanFrame*>(0)->data);
uint8_t buf[BUFLEN];
buf[0] = crc.get() & 0xFF; // Transfer CRC, little endian