Skip to content

clang-tidy error (on not-linux): use nullptr instead of NULL #261

Closed

Description

@pinheadmz

Running clang-tidy on macos I get this error:

/Users/matthewzipkin/Desktop/work/bitcoin/src/ipc/libmultiprocess/src/mp/util.cpp:84:25: error: use nullptr [modernize-use-nullptr,-warnings-as-errors]
   84 |     pthread_threadid_np(NULL, &tid);
      |                         ^~~~
      |                         nullptr

I suspect the reason this hasn't triggered failures on our CI is that this code block is not compiled on linux:

#ifdef __linux__
buffer << syscall(SYS_gettid);
#elif defined(HAVE_PTHREAD_THREADID_NP)
uint64_t tid = 0;
pthread_threadid_np(NULL, &tid);
buffer << tid;
#elif defined(HAVE_PTHREAD_GETTHREADID_NP)
buffer << pthread_getthreadid_np();
#else
buffer << std::this_thread::get_id();
#endif

Activity

  1. Sjors commented on Mar 20, 2026

    @Sjors
    Member

    One does not simply ... run clang-tidy on macOS. Anything special needed to reproduce this?

  2. pinheadmz commented on Mar 20, 2026

    @pinheadmz
    Author

    Simple!

    brew install llvm:

    --> which clang-tidy
    /opt/homebrew/Cellar/llvm/22.1.1/bin/clang-tidy
    --> clang-tidy --version
    Homebrew LLVM version 22.1.1
      Optimized build.

    Modified some code from bitcoin core ci/test/03_test_script.sh and added to .bash_profile:

    bctidy(){
      cd /Users/matthewzipkin/Desktop/work/bitcoin
      cmake -B build_tidy -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
      cmake --build build_tidy -j 8
    
      set -eo pipefail
      (
        cd ./src/ &&
        if ! ( PYTHONUNBUFFERED=1  run-clang-tidy -p ../build_tidy -quiet -config-file=.clang-tidy -j 8 | tee  ../build_tidy/tidy-out.txt ); then
          echo
          echo "Failure generated from clang-tidy:"
          grep -C5 "error: " ../build_tidy/tidy-out.txt
        fi
      )
    }
    
  3. Sjors commented on Mar 20, 2026

    @Sjors
    Member

    Thanks, managed to reproduce. I also made a utility out of your script: https://github.com/Sjors/dev-utils/tree/master?tab=readme-ov-file#tidy-btc-maczsh

  4. Sjors commented on Mar 20, 2026

    @Sjors
    Member

    Fixed in #262.

  5. added a commit that references this issue on Mar 23, 2026
  6. fanquake commented on May 11, 2026

    @fanquake
    Member

    Closed with #262?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions