From 390e030f84237666129e7c5de69d815bbe26e960 Mon Sep 17 00:00:00 2001 From: kushalsingh007 Date: Tue, 10 Mar 2015 01:41:39 +0530 Subject: [PATCH] Removing the warnings after running static code analyser. -Changes to fix all the clarifyCalulation warnings. -Fixes a part of issue number 480 --- cpu/x86/x86_memory.c | 4 ++-- cpu/x86/x86_pci.c | 2 +- cpu/x86/x86_rtc.c | 8 ++++---- sys/cbor/cbor.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/cpu/x86/x86_memory.c b/cpu/x86/x86_memory.c index 9d8c2da268..d9dacae467 100644 --- a/cpu/x86/x86_memory.c +++ b/cpu/x86/x86_memory.c @@ -371,13 +371,13 @@ static void pagefault_handler(uint8_t intr_num, struct x86_pushad *orig_ctx, uns } #endif else if (error_code & PF_EC_P) { - printf("Page fault: access violation while %s present page.\n", error_code & PF_EC_W ? "writing to" : "reading from"); + printf("Page fault: access violation while %s present page.\n", (error_code & PF_EC_W) ? "writing to" : "reading from"); x86_print_registers(orig_ctx, error_code); puts("Halting."); x86_hlt(); } else { - printf("Page fault: access violation while %s non-present page.\n", error_code & PF_EC_W ? "writing to" : "reading from"); + printf("Page fault: access violation while %s non-present page.\n", (error_code & PF_EC_W) ? "writing to" : "reading from"); x86_print_registers(orig_ctx, error_code); puts("Halting."); x86_hlt(); diff --git a/cpu/x86/x86_pci.c b/cpu/x86/x86_pci.c index 36820a1bbb..706af0ba93 100644 --- a/cpu/x86/x86_pci.c +++ b/cpu/x86/x86_pci.c @@ -149,7 +149,7 @@ static void pci_setup_ios(struct x86_known_pci_device *dev) io->bar_num = bar_num; ++dev->io_count; - unsigned addr_offs = tmp_bar & PCI_BAR_IO_SPACE ? PCI_BAR_ADDR_OFFS_IO : PCI_BAR_ADDR_OFFS_MEM; + unsigned addr_offs = (tmp_bar & PCI_BAR_IO_SPACE) ? PCI_BAR_ADDR_OFFS_IO : PCI_BAR_ADDR_OFFS_MEM; uint32_t length_tmp = tmp_bar >> addr_offs; uint32_t length = 1 << addr_offs; while ((length_tmp & 1) == 0) { diff --git a/cpu/x86/x86_rtc.c b/cpu/x86/x86_rtc.c index 4e3b73ae09..81813766da 100644 --- a/cpu/x86/x86_rtc.c +++ b/cpu/x86/x86_rtc.c @@ -98,10 +98,10 @@ static void rtc_irq_handler(uint8_t irq_num) (void) irq_num; /* == PIC_NUM_RTC */ uint8_t c = x86_cmos_read(RTC_REG_C); - DEBUG("RTC: c = 0x%02x, IRQ=%u, A=%u, P=%u, U=%u\n", c, c & RTC_REG_C_IRQ ? 1 : 0, - c & RTC_REG_C_IRQ_ALARM ? 1 : 0, - c & RTC_REG_C_IRQ_PERIODIC ? 1 : 0, - c & RTC_REG_C_IRQ_UPDATE ? 1 : 0); + DEBUG("RTC: c = 0x%02x, IRQ=%u, A=%u, P=%u, U=%u\n", c, (c & RTC_REG_C_IRQ) ? 1 : 0, + (c & RTC_REG_C_IRQ_ALARM) ? 1 : 0, + (c & RTC_REG_C_IRQ_PERIODIC) ? 1 : 0, + (c & RTC_REG_C_IRQ_UPDATE) ? 1 : 0); if (!(c & RTC_REG_C_IRQ)) { return; } diff --git a/sys/cbor/cbor.c b/sys/cbor/cbor.c index 2061fff908..55c64b6f70 100644 --- a/sys/cbor/cbor.c +++ b/sys/cbor/cbor.c @@ -157,7 +157,7 @@ double decode_float_half(unsigned char *halfp) val = mant == 0 ? INFINITY : NAN; } - return half & 0x8000 ? -val : val; + return (half & 0x8000) ? -val : val; } /**