Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(c11): Add additional warning flags #147

Merged
merged 10 commits into from
May 23, 2024
Merged

Conversation

miguelafsilva5
Copy link
Member

This PR introduces several compiler flags that issue warnings from additional sources.
The goal of these flags is to help complying with some MISRA directives. The flags include: forcing explicit casts, adding missing protypes, removing unused macros and functions, etc.

This PR depends on #146

The code was tested in the following platforms:

  • qemu-aarch64-virt
  • qemu-riscv64-virt

@DavidMCerdeira
Copy link
Member

@miguelafsilva5 note that one of the checks is failing

@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch 4 times, most recently from b8c156a to a9b25fc Compare May 22, 2024 13:31
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from a9b25fc to 535347c Compare May 22, 2024 13:46
@miguelafsilva5
Copy link
Member Author

@miguelafsilva5 note that one of the checks is failing

The code was not formatted properly. It is fixed in the recent commits.

@josecm josecm force-pushed the feat/extra_flag branch from 62f2efe to 80d8d5c Compare May 22, 2024 13:57
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from 535347c to 6ea3093 Compare May 22, 2024 13:59
@miguelafsilva5 miguelafsilva5 force-pushed the feat/extra_flag branch 3 times, most recently from a097b1b to 75858f3 Compare May 22, 2024 14:25
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from 6ea3093 to e1c6a76 Compare May 22, 2024 14:32
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from e1c6a76 to fb1daef Compare May 22, 2024 14:45
@DavidMCerdeira DavidMCerdeira self-assigned this May 23, 2024
Makefile Outdated Show resolved Hide resolved
src/arch/armv8/cache.c Show resolved Hide resolved
src/arch/armv8/inc/arch/gicv3.h Show resolved Hide resolved
src/arch/armv8/psci.c Outdated Show resolved Hide resolved
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from fb1daef to 04774f2 Compare May 23, 2024 11:21
Base automatically changed from feat/extra_flag to main May 23, 2024 12:09
This commit adds warning flags that are not included in -wall and -wextra.
These flags will help dealing with some MISRA directives (e.g., forcing
explicit casts, adding missing prototypes, etc.)

Signed-off-by: Miguel Silva <[email protected]>
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from 04774f2 to d2ebc8a Compare May 23, 2024 12:43
src/arch/armv8/gicv3.c Outdated Show resolved Hide resolved
src/arch/armv8/inc/arch/gic.h Show resolved Hide resolved
src/arch/armv8/inc/arch/gicv2.h Outdated Show resolved Hide resolved
src/arch/armv8/vgic.c Outdated Show resolved Hide resolved
src/arch/armv8/inc/arch/gicv3.h Show resolved Hide resolved
@josecm
Copy link
Member

josecm commented May 23, 2024

@miguelafsilva5 this is not compiling for the fvp-a-aarch32 platform.

@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from d2ebc8a to 28d90fb Compare May 23, 2024 13:50
@DavidMCerdeira DavidMCerdeira self-requested a review May 23, 2024 13:54
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from 28d90fb to 9cdbbcb Compare May 23, 2024 13:58
With the additional compiler flags, most implicit casts are not allowed.
This commit achieves this by forcing explicit casts, refactoring some variable
types and fixing literal values.

Signed-off-by: Miguel Silva <[email protected]>
The missing prototype error was being triggered due to one of the
following:

- the prototype was effectively missing;
- the prototype was ill defined (mainly, no paramter function prototypes
  missed 'void' as paramter list;
- the function did not have a prototype but did not require it. Mostly,
  because it was only used in the compilation unit - in this case to avoid,
  the error it must be defined as static;
  In some other cases these functions had a prototype defined which was
  not necessary and was thus removed.

Signed-off-by: Miguel Silva <[email protected]>
Switch statements without a default case cause errors with the
-Wswitch-default flag.

Signed-off-by: Miguel Silva <[email protected]>
The flag -Wcast-qual issues errors when a qualifier (e.g., const) is removed
through a cast.

Signed-off-by: Miguel Silva <[email protected]>
The Wshadow flag warns whenever a local variable or type declaration
shadows another variable (e.g., global variables)

Signed-off-by: Miguel Silva <[email protected]>
The compiler issues errors when trying to get the reference of elements of
packed structs since it might result in unaligned pointer values.
As such we forced the elements in question to be aligned inside the struct.

Signed-off-by: Miguel Silva <[email protected]>
@miguelafsilva5 miguelafsilva5 force-pushed the feat/stricter_error_flags branch from 9cdbbcb to 2dff14e Compare May 23, 2024 14:02
@DavidMCerdeira DavidMCerdeira merged commit d2d208f into main May 23, 2024
15 checks passed
@DavidMCerdeira DavidMCerdeira deleted the feat/stricter_error_flags branch May 23, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants