Skip to content

build: Don't use 0 as NULL/nullptr in pointer compare and assignment#4179

Open
BsAtHome wants to merge 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_null-0-confusion
Open

build: Don't use 0 as NULL/nullptr in pointer compare and assignment#4179
BsAtHome wants to merge 1 commit into
LinuxCNC:masterfrom
BsAtHome:fix_null-0-confusion

Conversation

@BsAtHome

Copy link
Copy Markdown
Contributor

There are many places in the sources where the value 0 is used to mean NULL or nullptr. The ultimate value of these may all be zero, but they are of very different types (pointer vs. integer). This leads to confusion in comparison and wrong assignments where one forgets to dereference or an instance in classicladder assigning FALSE to a pointer.

This PR fixes all (detected) instances that gcc and clang could find using the -Wzero-as-null-pointer-constant option and is selectable at configure time. There are a few instances in the C/C++ to Python interface code where this option is explicitly ignored with a pragma because the system's headers use the same confusion and cannot be easily fixed.

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.

1 participant