Skip to content
Snippets Groups Projects
Commit 09861628 authored by Philipp Spilger's avatar Philipp Spilger
Browse files

Fix cppcheck warnings

Change-Id: I2729658802e43d1cb653e3ae71101da170110d8f
parent 3a2fb5da
No related branches found
No related tags found
No related merge requests found
......@@ -17,9 +17,13 @@ int32_t exp_6(int32_t x)
/* avoid overflow problems for the multiplication */
if( (x < FP(1.0)) && (x > FP(-1.0)) ) {
// cppcheck-suppress integerOverflowCond
x2 = (x * x ) / INV_SCALE;
// cppcheck-suppress integerOverflowCond
x3 = (x2 * x ) / INV_SCALE;
// cppcheck-suppress integerOverflowCond
x4 = (x2 * x2) / INV_SCALE;
// cppcheck-suppress integerOverflowCond
x5 = (x3 * x2) / INV_SCALE;
} else {
x2 = x * (x / INV_SCALE);
......@@ -76,6 +80,7 @@ int32_t exp_6b(int32_t x)
else if( ik < -11 )
res_i = -65535;
else
// cppcheck-suppress arrayIndexOutOfBoundsCond
res_i = lut[ik+11];
// calculate exponential for the fractional part
......
......@@ -2,7 +2,9 @@
extern "C" void __call_constructors() {
extern void (*__init_array_start)();
extern void (*__init_array_end)();
for (void (**p)() = &__init_array_start; p < &__init_array_end; ++p) {
for (void (**p)() = &__init_array_start;
reinterpret_cast<unsigned long>(p) < reinterpret_cast<unsigned long>(&__init_array_end);
++p) {
(*p)();
}
}
......@@ -10,7 +12,9 @@ extern "C" void __call_constructors() {
extern "C" void __call_destructors() {
extern void (*__fini_array_start)();
extern void (*__fini_array_end)();
for (void (**p)() = &__fini_array_start; p < &__fini_array_end; ++p) {
for (void (**p)() = &__fini_array_start;
reinterpret_cast<unsigned long>(p) < reinterpret_cast<unsigned long>(&__fini_array_end);
++p) {
(*p)();
}
}
......@@ -47,7 +47,8 @@ uint32_t mailbox_read(uint8_t * dest, uint32_t const offset, uint32_t const size
}
uint8_t libnux_mailbox_read_u8(uint32_t const offset) {
if (&mailbox_base + offset < &mailbox_end) {
if (reinterpret_cast<unsigned long>(&mailbox_base + offset) <
reinterpret_cast<unsigned long>(&mailbox_end)) {
return *(&mailbox_base + offset);
} else {
/* TODO set errno ERANGE as soon as implemented */
......@@ -56,7 +57,8 @@ uint8_t libnux_mailbox_read_u8(uint32_t const offset) {
}
void libnux_mailbox_write_u8(uint32_t const offset, uint8_t const byte) {
if (&mailbox_base + offset < &mailbox_end) {
if (reinterpret_cast<unsigned long>(&mailbox_base + offset) <
reinterpret_cast<unsigned long>(&mailbox_end)) {
*(&mailbox_base + offset) = byte;
} else {
/* TODO set errno ERANGE as soon as implemented */
......
......@@ -45,7 +45,7 @@ void measure_int_multiply_not_optimized_away(char const* msg, times<N>& t)
{
int a = 10;
int b = 20;
ATTRIB_UNUSED int c;
ATTRIB_UNUSED int c{};
do_not_optimize_away(a);
do_not_optimize_away(b);
do_not_optimize_away(c);
......
......@@ -9,6 +9,7 @@ int start(void)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
/* Write out of bounds into array, overwriting stack-guard magic value. */
// cppcheck-suppress arrayIndexOutOfBounds
a[2] = 5;
#pragma GCC diagnostic pop
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment