mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
Merge pull request #1472 from LudwigOrtmann/cpp-check-a-bit
Fix a few cppcheck findings
This commit is contained in:
commit
f2344a9b57
@ -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) {
|
||||
|
@ -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");
|
||||
|
@ -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)
|
||||
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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('+');
|
||||
|
@ -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
|
||||
|
@ -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]);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user