Null pointer checks

This commit is contained in:
Pavel Kirienko
2014-04-19 16:47:14 +04:00
parent efb2251ef8
commit acff3d274c
2 changed files with 9 additions and 2 deletions
@@ -9,6 +9,7 @@ namespace uavcan
void ScalarCodec::swapByteOrder(uint8_t* const bytes, const unsigned len)
{
assert(bytes);
for (int i = 0, j = len - 1; i < j; i++, j--)
{
const uint8_t c = bytes[i];
@@ -19,6 +20,7 @@ void ScalarCodec::swapByteOrder(uint8_t* const bytes, const unsigned len)
int ScalarCodec::encodeBytesImpl(uint8_t* const bytes, const unsigned bitlen)
{
assert(bytes);
// Underlying stream class assumes that more significant bits have lower index, so we need to shift some.
if (bitlen % 8)
{
@@ -29,6 +31,7 @@ int ScalarCodec::encodeBytesImpl(uint8_t* const bytes, const unsigned bitlen)
int ScalarCodec::decodeBytesImpl(uint8_t* const bytes, const unsigned bitlen)
{
assert(bytes);
const int read_res = stream_.read(bytes, bitlen);
if (read_res > 0)
{