MantisBT - Doomseeker
View Issue Details
0003812Doomseeker[All Projects] Cleanuppublic2020-06-07 04:462020-06-08 02:17
WubTheCaptain 
 
nonetweakrandom
acknowledgedopen 
1.3.1 
 
0003812: Some null pointer constants use 0 instead of the C++11 nullptr keyword
Much of the Doomseeker codebase uses nullptr keyword already, but there are few lines where that isn't the case.
Because, you know, NULL or 0 is so much like C++98 (inherited from C).
The nullptr keyword was introduced in C++11.
grep -r "\*" src/ | grep "= 0" | less may be of interest. Here's some hand-filtered results:
src/plugins/zandronum/huffman/huffman.cpp:static HuffmanCodec * __codec = 0;
src/plugins/zandronum/huffman/huffman.cpp:                      *outputBufferSize = 0;
src/plugins/zandronum/huffman/huffman.cpp:                      *outputBufferSize = 0;
src/wadseeker/zip/un7zip.cpp:           *size = 0;
src/core/irc/ircadapterbase.h:  virtual IRCNetworkAdapter *network() = 0;
src/core/configuration/serverpassword.cpp:                      *outSimilarity = 0.0f;
src/core/serverapi/broadcast.h: virtual EnginePlugin *plugin() const = 0;
src/core/serverapi/server.h:    virtual EnginePlugin *plugin() const = 0;
src/core/serverapi/masterclient.h:      virtual const EnginePlugin *plugin() const = 0;
'https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html [^]'
'https://en.cppreference.com/w/cpp/language/nullptr [^]'
No tags attached.
child of 0003803confirmed  C++11 support 
Issue History
2020-06-07 04:46WubTheCaptainNew Issue
2020-06-07 04:47WubTheCaptainSummarySome null pointer constants use NULL or 0 instead of the C++11 nullptr keyword => Some null pointer constants use 0 instead of the C++11 nullptr keyword
2020-06-07 04:50WubTheCaptainNote Added: 0021364
2020-06-07 04:51WubTheCaptainPrioritynormal => none
2020-06-07 04:51WubTheCaptainRelationship addedchild of 0003803
2020-06-07 20:29Pol MNote Added: 0021385
2020-06-07 20:29Pol MStatusnew => confirmed
2020-06-08 01:15Blzut3Note Added: 0021405
2020-06-08 01:19Blzut3Note Edited: 0021405bug_revision_view_page.php?bugnote_id=21405#r13156
2020-06-08 02:17WubTheCaptainStatusconfirmed => acknowledged

Notes
(0021364)
WubTheCaptain   
2020-06-07 04:50   
Particularly bothered by *plugin() and *network(). Makes no sense to be an integer zero.
(0021385)
Pol M   
2020-06-07 20:29   
You have listed some more pure virtual functions here. These are 0 intentionally, they have nothing to do with the pointer they return. Also, the:
*outSimilarity = 0.0f;
is actually a pointer to a float getting dereferenced into the float it is pointing to, and then assigning a 0.0f into said float.
You can indeed change any 0 that should be a nullptr, if there are any.
(0021405)
Blzut3   
2020-06-08 01:15   
(edited on: 2020-06-08 01:19)
Yeah if you can find any first party cases of 0 being used instead of nullptr then do submit a patch for that. Like Pol M said the function ones you mention are pure virtual member functions and the "= 0;" is just part of C++'s syntax and nullptr won't work there. (NULL would but only because that's technically a macro for 0.)

Edit: See C++ standard class.mem pure-specifier.