1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-18 12:52:44 +01:00

Merge pull request #17271 from yarrick/cppcheck

Fix some cppcheck errors
This commit is contained in:
Gunar Schorcht 2021-11-26 08:14:55 +01:00 committed by GitHub
commit 86e5374393
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 5 deletions

View File

@ -259,10 +259,12 @@ int thread_isr_stack_usage(void)
{
uint32_t *ptr = &_sstack;
while(((*ptr) == STACK_CANARY_WORD) && (ptr < &_estack)) {
/* cppcheck-suppress comparePointers */
while (((*ptr) == STACK_CANARY_WORD) && (ptr < &_estack)) {
++ptr;
}
/* cppcheck-suppress comparePointers */
ptrdiff_t num_used_words = &_estack - ptr;
return num_used_words * sizeof(*ptr);
}

View File

@ -56,6 +56,7 @@ void esp_riot_init(void)
extern uint8_t _rtc_bss_start, _rtc_bss_end;
esp_reset_reason_t reset_reason = esp_reset_reason();
if (reset_reason != ESP_RST_DEEPSLEEP && reset_reason != ESP_RST_SW) {
/* cppcheck-suppress comparePointers */
memset(&_rtc_bss_start, 0, (&_rtc_bss_end - &_rtc_bss_start));
}

View File

@ -97,6 +97,7 @@ void IRAM_ATTR _lock_init(_lock_t *lock)
memset(mtx, 0, sizeof(mutex_t));
*lock = (_lock_t)mtx;
}
/* cppcheck-suppress memleak; mtx is stored in lock */
}
void IRAM_ATTR _lock_init_recursive(_lock_t *lock)
@ -128,6 +129,7 @@ void IRAM_ATTR _lock_init_recursive(_lock_t *lock)
memset(rmtx, 0, sizeof(rmutex_t));
*lock = (_lock_t)rmtx;
}
/* cppcheck-suppress memleak; rmtx is stored in lock */
}
void IRAM_ATTR _lock_close(_lock_t *lock)
@ -257,7 +259,7 @@ void IRAM_ATTR _lock_release_recursive(_lock_t *lock)
#ifdef MODULE_ESP_IDF_HEAP
#define heap_caps_malloc_default(s) heap_caps_malloc(s, MALLOC_CAP_DEFAULT)
#define heap_caps_realloc_default(p,s) heap_caps_realloc(p, s, MALLOC_CAP_DEFAULT)
#define heap_caps_realloc_default(p, s) heap_caps_realloc(p, s, MALLOC_CAP_DEFAULT)
void* IRAM_ATTR __wrap__malloc_r(struct _reent *r, size_t size)
{
@ -362,6 +364,7 @@ extern uint8_t _eheap3;
unsigned int IRAM_ATTR get_free_heap_size(void)
{
struct mallinfo minfo = mallinfo();
/* cppcheck-suppress comparePointers */
unsigned int heap_size = &_eheap - &_sheap;
#if NUM_HEAPS > 1
heap_size += &_eheap1 - &_sheap1;

View File

@ -352,6 +352,7 @@ void thread_isr_stack_init(void)
uintptr_t *stackmax = (uintptr_t *)(uintptr_t)sp;
uintptr_t *stackp = (uintptr_t *)(uintptr_t)&port_IntStack;
/* cppcheck-suppress comparePointers */
while (stackp < stackmax) {
*stackp = (uintptr_t) stackp;
stackp++;

View File

@ -185,6 +185,7 @@ void heap_stats(void)
extern char _sheap; /* defined in linker script */
extern char _eheap; /* defined in linker script */
/* cppcheck-suppress comparePointers */
long int heap_size = &_eheap - &_sheap;
struct mallinfo minfo = mallinfo();

View File

@ -36,11 +36,14 @@
int main(void)
{
puts("Fault handler test application");
printf("This application will crash by attempting to write to address 0x%08x\n", FORBIDDEN_ADDRESS);
printf("This application will crash by attempting to write to address 0x%08x\n",
FORBIDDEN_ADDRESS);
puts("Waiting 1 second before crashing...");
xtimer_usleep(1000000lu);
puts("Write to forbidden address " PRINT_MACRO(FORBIDDEN_ADDRESS));
/* cppcheck-suppress nullPointer */
*((volatile unsigned int *) FORBIDDEN_ADDRESS) = 12345u;
/* cppcheck-suppress nullPointer */
unsigned int readback = *((volatile unsigned int *) FORBIDDEN_ADDRESS);
printf("readback: 0x%08x\n", readback);
puts("We did not expect the application to survive the previous write.");
@ -48,6 +51,6 @@ int main(void)
puts(PRINT_MACRO(INVALID_INSTRUCTION));
INVALID_INSTRUCTION;
puts("Failed to crash the program, hanging...");
while(1) {}
while (1) {}
return 0;
}

View File

@ -120,7 +120,7 @@ int main(void)
#pragma GCC diagnostic ignored "-Walloc-size-larger-than="
#endif
/* test if an overflow is correctly detected by calloc(): the size below overflows by 1 byte */
/* cppcheck-suppress leakReturnValNotUsed (should return NULL, so nothing to free anyway) */
/* cppcheck-suppress leakReturnValNotUsed; (should return NULL, so nothing to free anyway) */
expect(NULL == calloc(SIZE_MAX / 16 + 1, 16));
#pragma GCC diagnostic pop