Skip to content

Commit

Permalink
Fix deprecated use of 0/NULL (#3817)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #3817

`nullptr` is typesafe. `0` and `NULL` are not. We are interested in enabling `-Wzero-as-null-pointer-constant` for first-party code, and only `nullptr` will be allowed.

Reviewed By: zertosh

Differential Revision: D62083883

fbshipit-source-id: 9f19434ff72faa1444dec72ec182a41398b575fe
  • Loading branch information
David Tolnay authored and facebook-github-bot committed Sep 1, 2024
1 parent 383b5d9 commit c418b30
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion faiss/gpu/test/demo_ivfpq_indexing_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

double elapsed() {
struct timeval tv;
gettimeofday(&tv, NULL);
gettimeofday(&tv, nullptr);
return tv.tv_sec + tv.tv_usec * 1e-6;
}

Expand Down
5 changes: 4 additions & 1 deletion faiss/gpu/utils/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ namespace faiss {
namespace gpu {

KernelTimer::KernelTimer(cudaStream_t stream)
: startEvent_(0), stopEvent_(0), stream_(stream), valid_(true) {
: startEvent_(nullptr),
stopEvent_(nullptr),
stream_(stream),
valid_(true) {
CUDA_VERIFY(cudaEventCreate(&startEvent_));
CUDA_VERIFY(cudaEventCreate(&stopEvent_));

Expand Down
2 changes: 1 addition & 1 deletion faiss/gpu/utils/Timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class KernelTimer {
public:
/// Constructor starts the timer and adds an event into the current
/// device stream
KernelTimer(cudaStream_t stream = 0);
KernelTimer(cudaStream_t stream = nullptr);

/// Destructor releases event resources
~KernelTimer();
Expand Down

0 comments on commit c418b30

Please sign in to comment.