Zandronum Chat @ irc.zandronum.com
#zandronum
Get the latest version: 3.0
Source Code

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0003812Doomseeker[All Projects] Cleanuppublic2020-06-07 04:462020-06-08 02:17
ReporterWubTheCaptain 
Assigned To 
PrioritynoneSeveritytweakReproducibilityrandom
StatusacknowledgedResolutionopen 
PlatformOSOS Version
Product Version1.3.1 
Target VersionFixed in Version 
Summary0003812: Some null pointer constants use 0 instead of the C++11 nullptr keyword
DescriptionMuch 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.
Steps To Reproducegrep -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;
Additional Informationhttps://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html [^]
https://en.cppreference.com/w/cpp/language/nullptr [^]
Attached Files

- Relationships
child of 0003803confirmed C++11 support 

-  Notes
User avatar (0021364)
WubTheCaptain (developer)
2020-06-07 04:50

Particularly bothered by *plugin() and *network(). Makes no sense to be an integer zero.
User avatar (0021385)
Pol M (developer)
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.
User avatar (0021405)
Blzut3 (administrator)
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.


Issue Community Support
Only registered users can voice their support. Click here to register, or here to log in.
Supporters: No one explicitly supports this issue yet.
Opponents: No one explicitly opposes this issue yet.

- Issue History
Date Modified Username Field Change
2020-06-07 04:46 WubTheCaptain New Issue
2020-06-07 04:47 WubTheCaptain Summary Some 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:50 WubTheCaptain Note Added: 0021364
2020-06-07 04:51 WubTheCaptain Priority normal => none
2020-06-07 04:51 WubTheCaptain Relationship added child of 0003803
2020-06-07 20:29 Pol M Note Added: 0021385
2020-06-07 20:29 Pol M Status new => confirmed
2020-06-08 01:15 Blzut3 Note Added: 0021405
2020-06-08 01:19 Blzut3 Note Edited: 0021405 View Revisions
2020-06-08 02:17 WubTheCaptain Status confirmed => acknowledged






Questions or other issues? Contact Us.

Links


Copyright © 2000 - 2020 MantisBT Team
Powered by Mantis Bugtracker