memononen / nanosvg

Simple stupid SVG parser
zlib License
1.69k stars 357 forks source link

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

Open gunterkoenigsmann opened 4 years ago

gunterkoenigsmann commented 4 years ago

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 commented 2 years ago

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 commented 2 years ago

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