Closed SRSaunders closed 10 months ago
I had to look over this twice but I like that almost everything is now based on idStr::vsnPrintf(). It simplifies the implementation and also the changes in the filesystem seem to be save. I'm not sure about the UINT_MAX changes but I trust you that those are correct too.
Yes, the Doom Classic negative uint math was using a compiler trick to calculate complementary angles which seems brittle to me, and causes warnings on newer compilers (e.g. clang). Adding UINT_MAX + 1 is like adding 0 to the original calculation, but when done in proper order (i.e. UINT_MAX - x + 1) results in a calculation that is more understandable and does not cause warnings with modern compilers.
This is a relatively simple, but medium-sized pull request that solves most compiler warnings. It was motivated by me moving my dev machine to macOS Ventura with Xcode 14 / Apple clang 14.0.3 which is based on LLVM 15. This resulted in tons of new compiler warnings, fortunately concentrated on a small number of things. After solving those, I decided to attack linux gcc and clang 15 warnings and finally Visual Studio 2019's MSVC warnings. Solutions are in three broad categories:
sprintf()
andvsprintf()
,std::iterator
as well as fixes for several specific areas:
LRESULT
andSetWindowLongPtr()
One of the main issues involving many files was the unexpected deprecation of
sprintf()
andvsprintf()
by the Apple clang 14.0.3 compiler. This seems a little aggressive on Apple's part, but I guess is the right thing to do for buffer security. Fortunately there is a relatively easy solution withidStr::snPrintf()
andidStr::vsnPrintf()
which are cross platform portable implementations with consistent length, null termination and error reporting behaviour. As part of this fix, I updated the implementation ofidStr::snPrintf()
to be based onidStr::vsnPrintf()
without need for an internal buffer versus the old implementation usingvsprintf()
with a large 32K internal buffer. This should make things a little more memory efficient for all platforms.