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

Suppress cppcheck's memset-on-floats warnings #174

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

gunterkoenigsmann
Copy link

CppCheck, if all warnings are enabled, complains if one calls memset on something that contains a float variable.
In our case setting the variable to 0 is what we actually intent which means we can tell cppcheck to mute these warnings.

CppCheck, if all warnings are enabled, complains if one calls
memset on something that contains a float variable.

In our case setting the variable to 0 is what we actually intent
which means we can tell cppcheck to mute these warnings.
@v0lt
Copy link

v0lt commented May 30, 2022

I think writing weird comments is a bad idea.
I can suggest replacing calls to malloc and memset with a single call to calloc.

It was:

p = (NSVGparser*)malloc(sizeof(NSVGparser));
if (p == NULL) goto error;
memset(p, 0, sizeof(NSVGparser));

It became:

p = (NSVGparser*)calloc(1, sizeof(NSVGparser));
if (p == NULL) goto error;

@v0lt
Copy link

v0lt commented May 30, 2022

I also think it's bad form to create a lot of pull requests based on cosmetic statistical analyzer warnings.

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