From 03544f0b770a537d9cee885f2c935260c5406525 Mon Sep 17 00:00:00 2001 From: Flavio Ceolin Date: Fri, 2 Apr 2021 22:44:10 -0700 Subject: [PATCH] arch: x86: Fix 10.4 violations Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. Signed-off-by: Flavio Ceolin --- arch/x86/core/acpi.c | 4 ++-- arch/x86/core/fatal.c | 2 +- arch/x86/core/intel64/cpu.c | 2 +- arch/x86/core/intel64/thread.c | 2 +- arch/x86/core/multiboot.c | 4 ++-- arch/x86/core/pcie.c | 2 +- arch/x86/core/x86_mmu.c | 2 +- arch/x86/timing.c | 2 +- arch/x86/zefi/zefi.c | 4 ++-- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/arch/x86/core/acpi.c b/arch/x86/core/acpi.c index 240aa472d0e..96e5ca40b8c 100644 --- a/arch/x86/core/acpi.c +++ b/arch/x86/core/acpi.c @@ -12,13 +12,13 @@ bool is_dmar_searched; static bool check_sum(struct acpi_sdt *t) { - uint8_t sum = 0, *p = (uint8_t *)t; + uint8_t sum = 0U, *p = (uint8_t *)t; for (int i = 0; i < t->length; i++) { sum += p[i]; } - return sum == 0; + return sum == 0U; } diff --git a/arch/x86/core/fatal.c b/arch/x86/core/fatal.c index 0770ae043dd..75762f2f912 100644 --- a/arch/x86/core/fatal.c +++ b/arch/x86/core/fatal.c @@ -70,7 +70,7 @@ bool z_x86_check_stack_bounds(uintptr_t addr, size_t size, uint16_t cs) z_interrupt_stacks[cpu_id]); end = start + CONFIG_ISR_STACK_SIZE; #ifdef CONFIG_USERSPACE - } else if ((cs & 0x3U) == 0 && + } else if ((cs & 0x3U) == 0U && (_current->base.user_options & K_USER) != 0) { /* The low two bits of the CS register is the privilege * level. It will be 0 in supervisor mode and 3 in user mode diff --git a/arch/x86/core/intel64/cpu.c b/arch/x86/core/intel64/cpu.c index fd31d3719cf..8ba79b7b339 100644 --- a/arch/x86/core/intel64/cpu.c +++ b/arch/x86/core/intel64/cpu.c @@ -166,7 +166,7 @@ FUNC_NORETURN void z_x86_cpu_init(struct x86_cpuboot *cpuboot) /* The internal cpu_number is the index to x86_cpuboot[] */ unsigned char cpu_num = (unsigned char)(cpuboot - x86_cpuboot); - if (cpu_num == 0) { + if (cpu_num == 0U) { /* Only need to do these once per boot */ z_bss_zero(); #ifdef CONFIG_XIP diff --git a/arch/x86/core/intel64/thread.c b/arch/x86/core/intel64/thread.c index d0e44503948..a941022f9fa 100644 --- a/arch/x86/core/intel64/thread.c +++ b/arch/x86/core/intel64/thread.c @@ -43,7 +43,7 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack, switch_entry = z_thread_entry; #endif iframe = Z_STACK_PTR_TO_FRAME(struct x86_initial_frame, stack_ptr); - iframe->rip = 0; + iframe->rip = 0U; thread->callee_saved.rsp = (long) iframe; thread->callee_saved.rip = (long) switch_entry; thread->callee_saved.rflags = EFLAGS_INITIAL; diff --git a/arch/x86/core/multiboot.c b/arch/x86/core/multiboot.c index cdf0a71cbd9..62220261e50 100644 --- a/arch/x86/core/multiboot.c +++ b/arch/x86/core/multiboot.c @@ -162,8 +162,8 @@ static int multiboot_framebuf_init(const struct device *dev) adj_x = info->fb_width - CONFIG_MULTIBOOT_FRAMEBUF_X; adj_y = info->fb_height - CONFIG_MULTIBOOT_FRAMEBUF_Y; data->pitch = (info->fb_pitch / 4) + adj_x; - adj_x /= 2; - adj_y /= 2; + adj_x /= 2U; + adj_y /= 2U; buffer = (uint32_t *) (uintptr_t) info->fb_addr_lo; buffer += adj_x; buffer += adj_y * data->pitch; diff --git a/arch/x86/core/pcie.c b/arch/x86/core/pcie.c index 71db9a5b977..45f7214146a 100644 --- a/arch/x86/core/pcie.c +++ b/arch/x86/core/pcie.c @@ -144,7 +144,7 @@ static inline void pcie_conf(pcie_bdf_t bdf, unsigned int reg, uint32_t pcie_conf_read(pcie_bdf_t bdf, unsigned int reg) { - uint32_t data = 0; + uint32_t data = 0U; pcie_conf(bdf, reg, false, &data); return data; diff --git a/arch/x86/core/x86_mmu.c b/arch/x86/core/x86_mmu.c index 871cb33800a..fe30b4a1975 100644 --- a/arch/x86/core/x86_mmu.c +++ b/arch/x86/core/x86_mmu.c @@ -1855,7 +1855,7 @@ uintptr_t arch_page_info_get(void *addr, uintptr_t *phys, bool clear_accessed) * page table and makes no changes */ mask = 0; - options = 0; + options = 0U; } page_map_set(z_x86_kernel_ptables, addr, 0, &all_pte, mask, options); diff --git a/arch/x86/timing.c b/arch/x86/timing.c index c81c654c96c..e90f28b8dd0 100644 --- a/arch/x86/timing.c +++ b/arch/x86/timing.c @@ -83,5 +83,5 @@ uint64_t arch_timing_cycles_to_ns_avg(uint64_t cycles, uint32_t count) uint32_t arch_timing_freq_get_mhz(void) { - return (uint32_t)(arch_timing_freq_get() / 1000000); + return (uint32_t)(arch_timing_freq_get() / 1000000U); } diff --git a/arch/x86/zefi/zefi.c b/arch/x86/zefi/zefi.c index b12dcca3aea..5c1a8ea9f8e 100644 --- a/arch/x86/zefi/zefi.c +++ b/arch/x86/zefi/zefi.c @@ -36,7 +36,7 @@ static void efi_putchar(int c) efibuf[n++] = c; if (c == '\n' || n == PUTCHAR_BUFSZ) { - efibuf[n] = 0; + efibuf[n] = 0U; efi->ConOut->OutputString(efi->ConOut, efibuf); n = 0; } @@ -77,7 +77,7 @@ uintptr_t __abi efi_entry(void *img_handle, struct efi_system_table *sys_tab) printf("Zeroing %d bytes of memory at %p\n", bytes, dst); for (int j = 0; j < bytes; j++) { - dst[j] = 0; + dst[j] = 0U; } }