Skip to content

Commit

Permalink
Fix deprecated use of 0/NULL in faiss/python/python_callbacks.cpp + 1
Browse files Browse the repository at this point in the history
Summary:
`nullptr` is typesafe. `0` and `NULL` are not. In the future, only `nullptr` will be allowed.

This diff helps us embrace the future _now_ in service of enabling `-Wzero-as-null-pointer-constant`.

Reviewed By: palmje

Differential Revision: D56650318

fbshipit-source-id: 803ae62114c39143b65946f6f0387715eaf7f534
  • Loading branch information
r-barnes authored and facebook-github-bot committed Apr 27, 2024
1 parent a233bc9 commit c5599a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions faiss/python/python_callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ size_t PyCallbackIOWriter::operator()(
size_t wi = ws > bs ? bs : ws;
PyObject* result = PyObject_CallFunction(
callback, "(N)", PyBytes_FromStringAndSize(ptr, wi));
if (result == NULL) {
if (result == nullptr) {
FAISS_THROW_MSG("py err");
}
// TODO check nb of bytes written
Expand Down Expand Up @@ -77,7 +77,7 @@ size_t PyCallbackIOReader::operator()(void* ptrv, size_t size, size_t nitems) {
while (rs > 0) {
size_t ri = rs > bs ? bs : rs;
PyObject* result = PyObject_CallFunction(callback, "(n)", ri);
if (result == NULL) {
if (result == nullptr) {
FAISS_THROW_MSG("propagate py error");
}
if (!PyBytes_Check(result)) {
Expand Down Expand Up @@ -122,7 +122,7 @@ bool PyCallbackIDSelector::is_member(faiss::idx_t id) const {
FAISS_THROW_IF_NOT((id >> 32) == 0);
PyThreadLock gil;
PyObject* result = PyObject_CallFunction(callback, "(n)", int(id));
if (result == NULL) {
if (result == nullptr) {
FAISS_THROW_MSG("propagate py error");
}
bool b = PyObject_IsTrue(result);
Expand Down

0 comments on commit c5599a0

Please sign in to comment.