MantisBT - Doomseeker |
View Issue Details |
|
ID | Project | Category | View Status | Date Submitted | Last Update |
0003812 | Doomseeker | [All Projects] Cleanup | public | 2020-06-07 04:46 | 2020-06-08 02:17 |
|
Reporter | WubTheCaptain | |
Assigned To | | |
Priority | none | Severity | tweak | Reproducibility | random |
Status | acknowledged | Resolution | open | |
Platform | | OS | | OS Version | |
Product Version | 1.3.1 | |
Target Version | | Fixed in Version | | |
|
Summary | 0003812: Some null pointer constants use 0 instead of the C++11 nullptr keyword |
Description | 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. |
Steps To Reproduce | 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;
|
Additional Information | 'https://clang.llvm.org/extra/clang-tidy/checks/modernize-use-nullptr.html [^]'
'https://en.cppreference.com/w/cpp/language/nullptr [^]' |
Tags | No tags attached. |
Relationships | child of | 0003803 | confirmed | | C++11 support |
|
Attached Files | |
|
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 | bug_revision_view_page.php?bugnote_id=21405#r13156 |
2020-06-08 02:17 | WubTheCaptain | Status | confirmed => acknowledged |
Notes |
|
|
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.
|
|