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

Remove warnings #561

Merged
merged 4 commits into from
Apr 8, 2023
Merged

Remove warnings #561

merged 4 commits into from
Apr 8, 2023

Conversation

emb4fun
Copy link
Collaborator

@emb4fun emb4fun commented Mar 25, 2023

Remove some GCC warnings

@stnolting
Copy link
Owner

Could you provide some more information? What is this pragma GCC diagnostic ignored "-Wtype-limits" about?

@stnolting stnolting added the SW software-related label Mar 25, 2023
@stnolting stnolting self-assigned this Mar 25, 2023
@emb4fun
Copy link
Collaborator Author

emb4fun commented Mar 26, 2023

I like to try to have 0 warnings. I got the following warning:

comparison is always true due to limited range of data type [-Wtype-limits]

This is generated by the following line:

if ((id >= RTE_TRAP_I_MISALIGNED) && (id <= RTE_TRAP_FIRQ_15)) {

id is here a uint8_t. This means that any value greater than is equal RTE_TRAP_I_MISALIGNED, because RTE_TRAP_I_MISALIGNED is 0. Actually, you would have to change the code as follows to no longer get the warning:

if (id <= RTE_TRAP_FIRQ_15) {

But I didn't want to make the change to keep the understanding of the code. That's why I turned off the warning for the small part.

@stnolting
Copy link
Owner

Ah, now I understand.

I would actually do change the code base here. Having those pragmas makes the code base harder to understand. Furthermore, these pragmas might not be supported by other compilers like LLVM.

So here is my proposal: add a "last" identifier to the trap ID enum:

  RTE_TRAP_FIRQ_14      = 27, /**< Fast interrupt channel 14 */
  RTE_TRAP_FIRQ_15      = 28, /**< Fast interrupt channel 15 */

  RTE_TRAP_enum_last = RTE_TRAP_FIRQ_15
};

and then use that for the range check:

  // id valid?
  if (id > RTE_TRAP_enum_last) {

Furthermore, I would change the type of the id argument from uint8_t to plain int. This seems to be more straightforward here.

Copy link

@Arun789788 Arun789788 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sw/lib/source/neorv32_rte.c

@stnolting
Copy link
Owner

Hey @Arun789788

sw/lib/source/neorv32_rte.c

What do you mean with that?

@stnolting stnolting marked this pull request as draft April 7, 2023 08:12
@emb4fun emb4fun marked this pull request as ready for review April 8, 2023 11:55
@stnolting stnolting added the coding-style Related to the HW/SW coding style label Apr 8, 2023
@stnolting
Copy link
Owner

Thank you very much for fixing!

@stnolting stnolting merged commit 4f89972 into stnolting:main Apr 8, 2023
@emb4fun emb4fun deleted the remove_warning branch April 8, 2023 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coding-style Related to the HW/SW coding style SW software-related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants