Changes in v2:
 - Incrementally fix added warnings and disable Werror step by step.
   (This is cumbersome for Wextra since it adds multiple warnings at
    once. For Wextra I disabled Werror and then enabled it again after
    the series of fixes. The fixes are nonetheless incremental.)
 - move __page_pool into paging.h
 - Rebase on next.
 - Group patches by areas.

As part of a project I was experimenting with compiler warning options
that partially cover coding standard rules from e.g., MISRA 2012. An
example is Wconversion, and the narrower sign-conversion, sign-compare,
pointer-arch, cast-qual. E.g., Wconversion covers MISRA 2012 10.3 (and
partially 10.4, 10.1).

Before enabling those, I've enabled some other warnings to filter out
definition/declaration "issues" that would clutter the compilation
otherwise. I've added: -Wextra -Wundef -Wnested-externs -Wshadow
-Wredundant-decls -Wdeprecated

The warnings were not too many (most of them related to
unused-parameters), but there were some interesting ones e.g.:

hypervisor: move declaration of __page_pool into paging.h
hypervisor: introduce uptr_t (depending on the wordsize) and define size_t 
accordingly
hypervisor, arm-common: provide an explicit uint INVALID_CPU_ID

I've compile-checked x86, arm, arm64, and tested arm64 (ZCU102).

Additional info:
gcc (Debian 10.2.0-13) 10.2.0

JFTR:
Wcast-qual generates 276 warnings on arm64 (but they looks ~ the same,
it could be feasible fixing them) Wconversion + Wpointer-arith are a
worse beast (~ 1400 occurrences), and the "int" return convention in
Linux doesn't make it easy to cleanly fix them.

Andrea Bastoni (33):
  hypervisor: Makefile: hook-in -Wnested-externs
  hypervisor: move declaration of __page_pool into paging.h
  hypervisor: Makefile: hook-in -Wshadow
  x86: iommu: Wshadow, fault_reporting_cpu is global
  arm64: smmu-v3: avoid shadowing smmu
  hypervisor: Makefile: hook-in -Wredundant-decls
  hypervisor: protect inclusion of string.h
  hypervisor: protect inclusion of processor.h
  hypervisor: Makefile: hook-in -Wdeprecated and -Wundef
  hypervisor: Makefile: temporarily remove Werror and hook-in Wextra
  hypervisor: introduce uptr_t (depending on the wordsize) and define
    size_t accordingly
  hypervisor, arm-common: provide an explicit uint INVALID_CPU_ID
  hypervisor: mmio: fix Wsign-compare by casting index to u32.
  hypervisor: printk: Fix Wsign-compare in align()
  hypervisor: Wsign-compare: force the "right" promotion direction
  arm-common: paging: fix old style declaration
    (-Wold-style-declaration)
  arm-common: provide unsigned int PSCI_INVALID_ADDRESS
  arm-common: gic*: use uint instead of int when needed (Wsign-compare)
  arm, arm-common: Wsign-compare: arm_dcaches_flush(): take unsigned
    long as size
  arm64: smmu-v3: use uint instead of int when needed (Wsign-compare)
  arm64: ti-pvu: fix Wsign-compare by casting size to u64.
  arm64: smmu: Wsign-compare: make iterator uint
  x86: fix simple Wsign-compare warnings
  x86: apic: Wsign-compare change to uint and update comparison check
    accordingly
  x86: cat: fix Wsign-compare
  x86: vtd: fix Wsign-compare
  x86: control, vcpu: force cast to prevent Wsign-compare
  hypervisor: -Wunused-parameter: keep compiler happy
  arm: -Wunused-parameter: keep compiler happy
  arm-common: -Wunused-parameter: keep compiler happy
  arm64: -Wunused-parameter: keep compiler happy
  x86: -Wunused-parameter: keep compiler happy
  hypervisor: Makefile: re-introduce -Werror and remove -Wno-error=*

 hypervisor/Makefile                           |  5 ++++-
 hypervisor/arch/arm-common/gic-v2.c           | 12 ++++++-----
 hypervisor/arch/arm-common/gic-v3.c           |  9 +++++----
 .../arch/arm-common/include/asm/dcaches.h     |  2 +-
 hypervisor/arch/arm-common/include/asm/psci.h |  2 +-
 hypervisor/arch/arm-common/irqchip.c          |  4 ++--
 hypervisor/arch/arm-common/lib.c              |  2 +-
 hypervisor/arch/arm-common/paging.c           |  8 +++++---
 hypervisor/arch/arm-common/pci.c              | 13 ++++++++++++
 hypervisor/arch/arm-common/psci.c             |  4 ++--
 hypervisor/arch/arm-common/uart-imx-lpuart.c  |  1 +
 hypervisor/arch/arm-common/uart-imx.c         |  1 +
 hypervisor/arch/arm-common/uart-mvebu.c       |  1 +
 hypervisor/arch/arm-common/uart-xuartps.c     |  1 +
 hypervisor/arch/arm/control.c                 |  2 +-
 hypervisor/arch/arm/iommu.c                   |  5 +++++
 hypervisor/arch/arm/mmio.c                    |  1 +
 hypervisor/arch/arm/mmu_hyp.c                 |  4 ++--
 hypervisor/arch/arm/traps.c                   |  2 ++
 hypervisor/arch/arm64/mmio.c                  |  2 ++
 hypervisor/arch/arm64/smmu-v3.c               | 20 ++++++++++++++-----
 hypervisor/arch/arm64/smmu.c                  |  3 ++-
 hypervisor/arch/arm64/ti-pvu.c                |  2 +-
 hypervisor/arch/arm64/traps.c                 |  1 +
 hypervisor/arch/x86/amd_iommu.c               | 14 +++++++++++++
 hypervisor/arch/x86/apic.c                    |  4 ++--
 hypervisor/arch/x86/cat.c                     |  3 ++-
 hypervisor/arch/x86/control.c                 |  2 +-
 hypervisor/arch/x86/iommu.c                   |  2 +-
 hypervisor/arch/x86/ivshmem.c                 |  2 ++
 hypervisor/arch/x86/paging.c                  |  2 +-
 hypervisor/arch/x86/setup.c                   |  1 +
 hypervisor/arch/x86/svm.c                     |  2 +-
 hypervisor/arch/x86/vcpu.c                    |  2 +-
 hypervisor/arch/x86/vmx.c                     |  1 +
 hypervisor/arch/x86/vtd.c                     | 11 +++++-----
 hypervisor/control.c                          |  4 +++-
 hypervisor/include/jailhouse/control.h        |  5 +++--
 hypervisor/include/jailhouse/paging.h         |  3 +++
 hypervisor/include/jailhouse/percpu.h         |  3 +--
 hypervisor/include/jailhouse/processor.h      |  4 ++++
 hypervisor/include/jailhouse/string.h         | 10 ++++++++--
 hypervisor/include/jailhouse/types.h          |  8 ++++++++
 hypervisor/include/jailhouse/unit.h           |  2 +-
 hypervisor/lib.c                              |  6 +++---
 hypervisor/mmio.c                             |  2 +-
 hypervisor/paging.c                           |  6 ++++--
 hypervisor/pci.c                              |  8 +++++++-
 hypervisor/printk.c                           |  6 +++---
 hypervisor/setup.c                            |  6 +++---
 50 files changed, 162 insertions(+), 64 deletions(-)

-- 
2.28.0

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jailhouse-dev/20201022175826.199614-1-andrea.bastoni%40tum.de.

Reply via email to