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

const qualifier mismatch warnings #1879

Closed
obones opened this issue Nov 16, 2021 · 3 comments
Closed

const qualifier mismatch warnings #1879

obones opened this issue Nov 16, 2021 · 3 comments
Labels
bug There is a defect in the code feedback request for more information; may be closed id 30d if not received

Comments

@obones
Copy link
Contributor

obones commented Nov 16, 2021

This is a spin off from #1866 as I believe it requires a bit of discussion.

Compiling with VS2019, I get those three warnings:

File Line Code Message
data_tag.c 234 C4090 'function': different 'const' qualifiers
r_api.c 923 C4090 'function': different 'const' qualifiers
rtl_433.c 1431 C4090 'function': different 'const' qualifiers

They all come from a line that calls the free method to free memory allocated earlier. But the argument given to free is always a char const ** when the method expects a non const pointer.

Could it be that the const keyword is wrongly placed in the variable/return type declaration? I must admit that I'm always a bit confused by the possible positions of the const keyword and their respective meanings.

Any suggestion is most welcome

@zuckschwerdt
Copy link
Collaborator

I follow the handy rule to read types right-to-left, so a pointer to a pointer to const-chars. These instances are arrays of char const *. The contents must never be touched or free'd but the array itself is short-lived heap memory.

@gdt
Copy link
Collaborator

gdt commented Oct 2, 2023

Is this still a problem with current code?

@gdt gdt added bug There is a defect in the code feedback request for more information; may be closed id 30d if not received labels Oct 2, 2023
@obones
Copy link
Contributor Author

obones commented Oct 3, 2023

This appears to have been fixed by d67ee96

@obones obones closed this as completed Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug There is a defect in the code feedback request for more information; may be closed id 30d if not received
Projects
None yet
Development

No branches or pull requests

3 participants