From ddcedfd9d040b053ccfd33a29cfa6d49512756c6 Mon Sep 17 00:00:00 2001 From: Pavel Kirienko Date: Sat, 19 Apr 2014 19:05:34 +0400 Subject: [PATCH] Fixed sizeof(ptr) in test (detected by clang static analyzer) --- libuavcan/test/transport/transfer_buffer.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libuavcan/test/transport/transfer_buffer.cpp b/libuavcan/test/transport/transfer_buffer.cpp index 0ae0b17b6b..8cd58527dc 100644 --- a/libuavcan/test/transport/transfer_buffer.cpp +++ b/libuavcan/test/transport/transfer_buffer.cpp @@ -14,18 +14,18 @@ static const std::string TEST_DATA = "pawnbroker, who had to be murdered too to get money from her trunk (for his career, you understand). " "Well, would he have brought himself to that if there had been no other means?"; -template -static bool allEqual(const T a) +template +static bool allEqual(const T (&a)[Size]) { - int n = sizeof(a) / sizeof(a[0]); - while (--n > 0 && a[n] == a[0]) { } + unsigned n = Size; + while ((--n > 0) && (a[n] == a[0])) { } return n == 0; } -template -static void fill(const T a, int value) +template +static void fill(T (&a)[Size], int value) { - for (unsigned i = 0; i < sizeof(a) / sizeof(a[0]); i++) + for (unsigned i = 0; i < Size; i++) { a[i] = value; }