Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: replace NULL with nullptr #11627

Merged
merged 2 commits into from Dec 26, 2023
Merged

Conversation

rubidium42
Copy link
Contributor

Motivation / Problem

Someone commenting on NULL in a diff, made me wonder if there's still any NULL left. There is.

Description

Replace NULL with nullptr, in two commits; one for squirrel and one for the rest.

Limitations

There are still some NULLs in the code, but that's in printf output, comments and json.hpp defines.

./saveload/compat/cheat_sl_compat.h:26: SLC(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS().
./saveload/compat/cheat_sl_compat.h:30: SLC(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS().
./saveload/compat/cheat_sl_compat.h:36: SLC(1, SL_MIN_VERSION, SLV_TABLE_CHUNKS), // Need to be two NULL fields. See Load_CHTS().
./saveload/saveload.h:708:      uint16_t length;                ///< Length of the NULL field.
./saveload/saveload.cpp:310:     * during NULLing; especially those that try to get
./stdafx.h:145:#        pragma warning(disable: 6011)   // code analyzer: Dereferencing NULL pointer 'pfGetAddrInfo': Lines: 995, 996, 998, 999, 1001
./fontcache.cpp:67:             return "[NULL]";
./3rdparty/squirrel/squirrel/sqvm.cpp:1583:             case OT:                        printf("NULL"); break;
./3rdparty/squirrel/sqstdlib/sqstdaux.cpp:56:                                   pf(v,fmt::format("[{}] NULL\n",name));
./3rdparty/nlohmann/json.hpp:2198:    #elif defined(NULL)
./3rdparty/nlohmann/json.hpp:2199:        #define JSON_HEDLEY NULL
./3rdparty/nlohmann/json.hpp:2203:#elif defined(NULL)
./3rdparty/nlohmann/json.hpp:2204:    #define JSON_HEDLEY NULL
./3rdparty/catch2/catch.hpp:2314:    // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)

The Microsoft API uses NULL, which also allows nullptr. We were already using nullptr in some places so I made it consistent.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR touches english.txt or translations? Check the guidelines
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, game_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Copy link
Member

@TrueBrain TrueBrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@rubidium42 rubidium42 merged commit e0c670c into OpenTTD:master Dec 26, 2023
19 checks passed
@rubidium42 rubidium42 deleted the nullptr branch December 26, 2023 06:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants