Skip to content

Clang 20.1 UT Errors#764

Merged
bocchino merged 2 commits intonasa:mainfrom
m-aleem:devel-3360
Jul 31, 2025
Merged

Clang 20.1 UT Errors#764
bocchino merged 2 commits intonasa:mainfrom
m-aleem:devel-3360

Conversation

@m-aleem
Copy link
Collaborator

@m-aleem m-aleem commented Jul 29, 2025

Associated with nasa/fprime#3360

@m-aleem m-aleem marked this pull request as ready for review July 29, 2025 22:20
@m-aleem
Copy link
Collaborator Author

m-aleem commented Jul 30, 2025

@bocchino @thomas-bc Following up on the tagup discussion relating to this PR:

I tried to change the autocoder to do const char* severityString = "SEVERITY ERROR"; and then remove assignment in the default case. Interestingly this gives the same error (seems like a false positive?):

Value stored to 'severityString' during its initialization is never read

So I think we have a couple options to keep the static analyzer happy:

  1. const char* severityString; as currently proposed and keep the switch case as-is
  2. const char* severityString = nullptr; and keep the switch case as-is
  3. const char* severityString = "UNKNOWN"; //NOLINT(clang-analyzer-deadcode.DeadStores) and keep the switch case as-is
  4. const char* severityString = "SEVERITY ERROR"; //NOLINT(clang-analyzer-deadcode.DeadStores) and update the default switch case to be empty/just break

Preferences?

Copy link
Collaborator

@bocchino bocchino left a comment

Choose a reason for hiding this comment

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

Looks good, but could we still initialize the severityString variable while avoiding the compiler warning? What happens if we initialize the variable to ""? Does the compiler still warn?

@m-aleem
Copy link
Collaborator Author

m-aleem commented Jul 30, 2025

That will give the same error.

@m-aleem
Copy link
Collaborator Author

m-aleem commented Jul 30, 2025

So to initialize it without warning I think we'd need to use the //NOLINT (and might as well keep the UNKNOWN in that case, I think)

@m-aleem m-aleem marked this pull request as draft July 31, 2025 01:05
@m-aleem m-aleem marked this pull request as ready for review July 31, 2025 01:28
Copy link
Collaborator

@bocchino bocchino left a comment

Choose a reason for hiding this comment

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

Looks good!

@bocchino bocchino merged commit 019328c into nasa:main Jul 31, 2025
16 checks passed
@m-aleem m-aleem deleted the devel-3360 branch July 31, 2025 16:16
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.

2 participants