This commit is contained in:
Pavel Kirienko 2014-08-07 21:02:00 +04:00
commit 8d306a90b8
11 changed files with 13 additions and 14 deletions

View File

@ -14,4 +14,5 @@ echo "Number of threads for cppcheck: $num_cores"
# TODO: with future versions of cppcheck, add --library=glibc
cppcheck . --error-exitcode=1 --quiet --enable=all --platform=unix64 --std=c99 --std=c++11 \
--inline-suppr --force --template=gcc -j$num_cores \
-U__BIGGEST_ALIGNMENT__ -UUAVCAN_MEM_POOL_BLOCK_SIZE -UBIG_ENDIAN -UBYTE_ORDER \
-Iinclude $@

View File

@ -232,7 +232,7 @@ template <int _tmpl>
::uavcan::DataTypeSignature ${t.cpp_type_name}<_tmpl>::getDataTypeSignature()
% endif
{
::uavcan::DataTypeSignature signature(${'0x%08X' % t.get_dsdl_signature()}UL);
::uavcan::DataTypeSignature signature(${'0x%08X' % t.get_dsdl_signature()}ULL);
<!--(macro extend_signature_per_field)--> #! scope_prefix, fields
% for a in fields:
${scope_prefix}FieldTypes::${a.name}::extendDataTypeSignature(signature);

View File

@ -168,7 +168,7 @@ struct UAVCAN_EXPORT IsDynamicallyAllocatable
{
static void check()
{
char dummy[(sizeof(T) <= MemPoolBlockSize) ? 1 : -1];
char dummy[(sizeof(T) <= MemPoolBlockSize) ? 1 : -1] = { '0' };
(void)dummy;
}
};

View File

@ -210,7 +210,7 @@ class UAVCAN_EXPORT YamlStreamer<FloatSpec<BitLen, CastMode> >
typedef typename FloatSpec<BitLen, CastMode>::StorageType StorageType;
public:
template <typename Stream>
template <typename Stream> // cppcheck-suppress passedByValue
static void stream(Stream& s, const StorageType value, int)
{
s << value;

View File

@ -153,7 +153,7 @@ class UAVCAN_EXPORT YamlStreamer<IntegerSpec<BitLen, Signedness, CastMode> >
typedef typename RawType::StorageType StorageType;
public:
template <typename Stream>
template <typename Stream> // cppcheck-suppress passedByValue
static void stream(Stream& s, const StorageType value, int)
{
// Get rid of character types - we want its integer representation, not ASCII code

View File

@ -76,7 +76,7 @@ private:
uint32_t response_failure_count_;
ResponseType response_;
void handleReceivedDataStruct(ReceivedDataStructure<RequestType>& request)
virtual void handleReceivedDataStruct(ReceivedDataStructure<RequestType>& request)
{
UAVCAN_ASSERT(request.getTransferType() == TransferTypeServiceRequest);
if (try_implicit_cast<bool>(callback_, true))

View File

@ -69,7 +69,7 @@ private:
Callback callback_;
void handleReceivedDataStruct(ReceivedDataStructure<DataType_>& msg)
virtual void handleReceivedDataStruct(ReceivedDataStructure<DataType_>& msg)
{
if (try_implicit_cast<bool>(callback_, true))
{

View File

@ -41,6 +41,7 @@ static inline bool isnan(T arg)
#if UAVCAN_CPP_VERSION >= UAVCAN_CPP11
return std::isnan(arg);
#else
// cppcheck-suppress duplicateExpression
return arg != arg;
#endif
}

View File

@ -15,11 +15,8 @@ TEST(FloatSpec, Limits)
using uavcan::CastModeTruncate;
typedef FloatSpec<16, CastModeSaturate> F16S;
typedef FloatSpec<16, CastModeTruncate> F16T;
typedef FloatSpec<32, CastModeSaturate> F32S;
typedef FloatSpec<32, CastModeTruncate> F32T;
typedef FloatSpec<64, CastModeSaturate> F64S;
typedef FloatSpec<64, CastModeTruncate> F64T;
ASSERT_FALSE(F16S::IsExactRepresentation);
ASSERT_FLOAT_EQ(65504.0, F16S::max());

View File

@ -87,7 +87,7 @@ TEST(ServiceServer, Basic)
uavcan::Frame fr;
ASSERT_TRUE(fr.parse(can_driver.ifaces[0].popTxFrame()));
std::cout << fr.toString() << std::endl;
ASSERT_STREQ(payloads[0], reinterpret_cast<const char*>(fr.getPayloadPtr() + 2)); // Skipping CRC
ASSERT_FALSE(std::strncmp(payloads[0], reinterpret_cast<const char*>(fr.getPayloadPtr() + 2), 5)); // No CRC
ASSERT_EQ(i, fr.getTransferID().get());
ASSERT_EQ(uavcan::TransferTypeServiceResponse, fr.getTransferType());
@ -96,7 +96,8 @@ TEST(ServiceServer, Basic)
// Second frame
ASSERT_TRUE(fr.parse(can_driver.ifaces[0].popTxFrame()));
std::cout << fr.toString() << std::endl;
ASSERT_STREQ(payloads[1], reinterpret_cast<const char*>(fr.getPayloadPtr()));
// cppcheck-suppress arrayIndexOutOfBounds
ASSERT_FALSE(std::strncmp(payloads[1], reinterpret_cast<const char*>(fr.getPayloadPtr()), 7));
ASSERT_EQ(i, fr.getTransferID().get());
ASSERT_EQ(uavcan::TransferTypeServiceResponse, fr.getTransferType());

View File

@ -73,7 +73,7 @@ struct PairableCanDriver : public uavcan::ICanDriver, public uavcan::ICanIface
assert(other);
if (inout_masks.read == 1)
{
inout_masks.read = (read_queue.size() || loopback_queue.size()) ? 1 : 0;
inout_masks.read = (!read_queue.empty() || !loopback_queue.empty()) ? 1 : 0;
}
if (inout_masks.read || inout_masks.write)
{
@ -160,8 +160,7 @@ struct InterlinkedTestNodes
nspins2 = nspins2 ? nspins2 : 1;
while (nspins2 --> 0)
{
int ret = -1;
ret = a.spin(uavcan::MonotonicDuration::fromMSec(1));
int ret = a.spin(uavcan::MonotonicDuration::fromMSec(1));
if (ret < 0)
{
return ret;