How can I configure SonarQube so that it knows the pointer size for my architecture (32-bit, ARM)?

I am trying out SonarCloud for the first time and was able to link my GitHub organization and analyze a C project. However, there seem to be many incorrectly flagged bugs. For example, one that I see says
“An integral type is too small to hold a pointer value.” (Intentionality: Not logical)
& “Pointers should not be cast to integral types.”

The line in question looks like this:

DMA_InitStructure.DMA_MemoryBaseAddr = (uint32_t)&adc_values_from_dma[0];  

It’s part of a structure initialization that is passed to HAL_DMA_Init, which is part of the vendor provided HAL library. While on one hand, the HAL is violating the part about casting a pointer to an integer, the pointer size is only 32-bits so there is no actual problem with it being “too small”. Hence the severity of this finding should probably be reduced.

  • Is there a place to configure settings like the pointer size for the architecture of the project? (It seems like SonarCloud is assuming that pointers are larger than 32-bit size, which is wrong.)
  • Is there a way to mark the issue as invalid / incorrect?

Hi @jacobq ,

are you using the SonarCloud Automatic Analysis feature?

At the moment, there is no feature to force the architecture of the project when using the Automatic Analysis feature on SonarCloud. If you want to have the architecture of the project detected you would need to configure the manual analysis in your CI.
See:

Yes, each issue has a status that you can change on the UI: https://docs.sonarsource.com/sonarcloud/digging-deeper/issues/#statuses

I have experimented with both automatic analysis and CI-triggered analysis but would prefer to use the automated option.

  • Could you open a feature request for configuring options such as architecture / pointer-size when automated analysis is used?
  • Can you open a feature request to allow some projects to use automatic analysis and others not to? (It seems that this is currently a “global” setting)

I created a ticket for that: [CPP-5070] - Jira

You can already do it per project, in the project’s AdministrationAnalysis Method.

I created a ticket for that: [CPP-5070] - Jira

Thank you!

You can already do it per project, in the project’s AdministrationAnalysis Method .

Ah, so this is not a global setting – perfect. Thank you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.