diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index 58e627aa7030ab5cb8dfb0df9c3767024f39fa14..3fd31a8dff5b9855f665a96a6217a450312e20ab 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -255,13 +255,10 @@ int _native_popsig(void) */ void native_irq_handler(void) { - int sig; - DEBUG("\n\n\t\tnative_irq_handler\n\n"); while (_native_sigpend > 0) { - - sig = _native_popsig(); + int sig = _native_popsig(); _native_sigpend--; if (native_irq_handlers[sig].func != NULL) { diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c index dfde2e371577d89e61814f59a0ddec6880f588b3..5c20956aa64cedb82623eb3f72daccb1a6c1c285 100644 --- a/cpu/native/native_cpu.c +++ b/cpu/native/native_cpu.c @@ -101,7 +101,7 @@ char *thread_stack_init(thread_task_func_t task_func, void *arg, void *stack_sta unsigned int *stk; ucontext_t *p; - VALGRIND_STACK_REGISTER(stack_start, stack_start + stacksize); + VALGRIND_STACK_REGISTER(stack_start, (char *) stack_start + stacksize); VALGRIND_DEBUG("VALGRIND_STACK_REGISTER(%p, %p)\n", stack_start, (void*)((int)stack_start + stacksize)); DEBUG("thread_stack_init()\n"); diff --git a/cpu/native/syscalls.c b/cpu/native/syscalls.c index 2f407bac62347f66a825f95bd8d04fd8d4e1aebe..f7aba006e6ff24bc12d130a0f8f28e7f38808cce 100644 --- a/cpu/native/syscalls.c +++ b/cpu/native/syscalls.c @@ -188,15 +188,15 @@ int puts(const char *s) char *make_message(const char *format, va_list argp) { - int n; int size = 100; char *message, *temp; - if ((message = malloc(size)) == NULL) + if ((message = malloc(size)) == NULL) { return NULL; + } while (1) { - n = vsnprintf(message, size, format, argp); + int n = vsnprintf(message, size, format, argp); if (n < 0) return NULL; if (n < size) diff --git a/cpu/x86/x86_memory.c b/cpu/x86/x86_memory.c index e78e49ec6fbe33d1a0ceb710b5706666725e3a58..9d8c2da268c27c152010b38ada48df83102bc4a9 100644 --- a/cpu/x86/x86_memory.c +++ b/cpu/x86/x86_memory.c @@ -365,7 +365,7 @@ static void pagefault_handler(uint8_t intr_num, struct x86_pushad *orig_ctx, uns /* print a warning if the page was read before written */ if (!(error_code & PF_EC_W)) { unsigned long *sp = (void *) orig_ctx->sp; /* ip, cs, flags */ - printf("DEBUG: Read before write on heap address 0x%08x (physical: 0x%016llx) at 0x%08x.\n", + printf("DEBUG: Read before write on heap address 0x%08x (physical: 0x%016llx) at 0x%08lx.\n", virtual_addr, pte & PT_ADDR_MASK, sp[0]); } } diff --git a/cpu/x86/x86_pci.c b/cpu/x86/x86_pci.c index 08f20983db87bddfaac989531711eb2907cfe69d..36820a1bbb22e53668f2a97eaf16fe0c95caaa10 100644 --- a/cpu/x86/x86_pci.c +++ b/cpu/x86/x86_pci.c @@ -218,6 +218,7 @@ static void pci_find_function(unsigned bus, unsigned dev, unsigned fun) printf(" %02x:%02x.%x \"%s\": \"%s\" (%s: %s, rev: %02hhx)\n", bus, dev, fun, vendor_name, device_name, baseclass_name, subclass_name, class.revision_id); + /* cppcheck-suppress memleakOnRealloc */ known_pci_devices = realloc(known_pci_devices, sizeof (*known_pci_devices) * (num_known_pci_devices + 1)); struct x86_known_pci_device *d = calloc(1, sizeof *d); known_pci_devices[num_known_pci_devices] = d; diff --git a/cpu/x86/x86_pic.c b/cpu/x86/x86_pic.c index 80c1fabc9371ead1c32a51dc0fcd3ec469070c86..549e7d3fde56c57989cc887045572851a570066c 100644 --- a/cpu/x86/x86_pic.c +++ b/cpu/x86/x86_pic.c @@ -64,7 +64,8 @@ static bool spurious_irq(uint8_t irq_num) return (inb(PIC_MASTER + PIC_COMMAND) & (1 << irq_num)) == 0; } - return false; // TODO: does not work + return false; +#if 0 /* TODO: does not work */ irq_num -= 8; outb(PIC_SLAVE + PIC_COMMAND, PIC_READ_ISR); if (inb(PIC_SLAVE + PIC_COMMAND) & (1 << irq_num)) { @@ -72,6 +73,7 @@ static bool spurious_irq(uint8_t irq_num) return true; } return false; +#endif } static void pic_interrupt_entry(uint8_t intr_num, struct x86_pushad *orig_ctx, unsigned long error_code) diff --git a/tests/test_float/main.c b/tests/test_float/main.c index 6bf27340bdb49804dca54d1f12e68085151df6d3..fe95806b1b10d279a5d814bfa82ab998494b08be 100644 --- a/tests/test_float/main.c +++ b/tests/test_float/main.c @@ -25,11 +25,11 @@ int main(void) { - double x = 1234567. / 1024., z; + double x = 1234567.0 / 1024.0; while (1) { x += 0.1; - z = x - floor(x); + double z = x - floor(x); if (z >= 1) { putchar('+'); diff --git a/tests/test_net_if/main.c b/tests/test_net_if/main.c index c9af411703a05d1d091a81a82e9ca2cb94120728..22585b1f4bceb8cf9c5c027be553d797bbc35ef7 100644 --- a/tests/test_net_if/main.c +++ b/tests/test_net_if/main.c @@ -339,27 +339,26 @@ int test_net_if_get_set_hardware_address(int iface, uint16_t addr) int test_net_if_get_set_pan_id(int iface) { - int32_t res; uint16_t pan_id = 0xabcd; - if ((res = net_if_get_pan_id(iface + 1)) >= 0) { + if (net_if_get_pan_id(iface + 1) >= 0) { printf("FAILED: net_if_get_pan_id(%d) not failed\n", iface); return 0; } - if ((res = net_if_set_pan_id(iface, pan_id)) < 0) { + if (net_if_set_pan_id(iface, pan_id) < 0) { printf("FAILED: net_if_set_pan_id(%d, 0x%04x) failed\n", iface, pan_id); return 0; } #if MODULE_AT86RF231 || MODULE_CC2420 || MODULE_MC1322X - - if ((res = net_if_get_pan_id(iface)) < 0) { + int32_t res = net_if_get_pan_id(iface); + if (res < 0) { printf("FAILED: net_if_get_pan_id(%d) failed\n", iface); return 0; } - pan_id = (uint16_t)res; + pan_id = (uint16_t) res; #else pan_id = 0; #endif diff --git a/tests/test_thread_cooperation/main.c b/tests/test_thread_cooperation/main.c index 85c128dbbcbc9aa3c733efc370685e9fe6c3cffe..41c8e809b19b01c33f765c6af6c5cbe911b30ea8 100644 --- a/tests/test_thread_cooperation/main.c +++ b/tests/test_thread_cooperation/main.c @@ -37,25 +37,20 @@ void *run(void *arg) { (void) arg; - int err; int me = thread_getpid(); printf("I am alive (%d)\n", me); msg_t m; - err = msg_receive(&m); + msg_receive(&m); printf("Thread %d has arg %" PRIu32 "\n", me, m.content.value); - err = mutex_lock(&mtx); - - if (err < 1) { - printf("[!!!] mutex_lock failed with %d\n", err); - } + mutex_lock(&mtx); storage *= m.content.value; mutex_unlock(&mtx); msg_t final; final.content.value = me; - err = msg_send(&final, main_id, 1); + int err = msg_send(&final, main_id, 1); if (err < 0) { printf("[!!!] Failed to send message from %d to main\n", me); @@ -66,14 +61,9 @@ void *run(void *arg) int main(void) { - int err; main_id = thread_getpid(); - err = mutex_init(&mtx); - - if (err < 1) { - printf("[!!!] mutex_init failed with %d\n", err); - } + mutex_init(&mtx); printf("Problem: %d\n", PROBLEM); @@ -86,12 +76,12 @@ int main(void) run, NULL, "thread"); if (ths[i] < 0) { - printf("[!!!] Creating thread failed with %d\n", err); + printf("[!!!] Creating thread failed.\n"); } else { args[i].content.value = i + 1; - err = msg_send(&args[i], ths[i], 1); + int err = msg_send(&args[i], ths[i], 1); if (err < 0) { printf("[!!!] Sending message to thread %d failed\n", ths[i]); } diff --git a/tests/test_vtimer_msg_diff/main.c b/tests/test_vtimer_msg_diff/main.c index cb3747b0f09ee5a8ae896a7e436c2b17ef4e9361..608b02e344da35317828365503a632617d2b7325 100644 --- a/tests/test_vtimer_msg_diff/main.c +++ b/tests/test_vtimer_msg_diff/main.c @@ -113,7 +113,7 @@ int main(void) "timer"); for (unsigned i = 0; i < sizeof(timer_msgs)/sizeof(struct timer_msg); i++) { - printf("Sending timer msg %d...\n", i); + printf("Sending timer msg %u...\n", i); m.content.ptr = (char *) &timer_msgs[i]; msg_send(&m, pid, false); } diff --git a/tests/unittests/embunit/embUnit/TestSuite.c b/tests/unittests/embunit/embUnit/TestSuite.c index e04d25cfad4fc3b0c91800b5433a27d7030c8b21..64fd614cfe6eacba763d2d85e4bbd6e4cead0e82 100644 --- a/tests/unittests/embunit/embUnit/TestSuite.c +++ b/tests/unittests/embunit/embUnit/TestSuite.c @@ -42,11 +42,9 @@ char* TestSuite_name(TestSuite* self) void TestSuite_run(TestSuite* self,TestResult* result) { - int i; - Test* test; if (self->tests) { - for (i=0; i<self->numberOfTests; i++) { - test = self->tests[i]; + for (int i = 0; i < self->numberOfTests; i++) { + Test* test = self->tests[i]; Test_run(test, result); } } @@ -55,11 +53,9 @@ void TestSuite_run(TestSuite* self,TestResult* result) int TestSuite_countTestCases(TestSuite* self) { int count = 0; - int i; - Test* test; if (self->tests) { - for (i=0; i<self->numberOfTests; i++) { - test = self->tests[i]; + for (int i = 0; i < self->numberOfTests; i++) { + Test* test = self->tests[i]; count += Test_countTestCases(test); } }