joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.53k stars 371 forks source link

Use nullptr/NULL instead of 0 for pointers, two fixes for undefined behavior #4996

Closed jaakristioja closed 1 month ago

jaakristioja commented 1 month ago

This commit fixes most -Wzero-as-null-pointer-constant warnings, except in some places which appear to be vendored 3rd party libraries, e.g. in sdl_ttf.c, libchdr, physfs and gmock and in 3rd party components therein. Since it might make more sense to update this 3rd party code to some later versions instead of fixing the warnings manually, I decided not to enable the C++ compiler flag in configure.ac at this point.

In two functions with the return type of std::string executed return 0; statements, causing std::string to be constructed from a null pointer. To avoid undefined behavior these were changed to return {};.