Skip to content

Commit c5599a0

Browse files
r-barnesfacebook-github-bot
authored andcommitted
Fix deprecated use of 0/NULL in faiss/python/python_callbacks.cpp + 1
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
1 parent a233bc9 commit c5599a0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

faiss/python/python_callbacks.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ size_t PyCallbackIOWriter::operator()(
4646
size_t wi = ws > bs ? bs : ws;
4747
PyObject* result = PyObject_CallFunction(
4848
callback, "(N)", PyBytes_FromStringAndSize(ptr, wi));
49-
if (result == NULL) {
49+
if (result == nullptr) {
5050
FAISS_THROW_MSG("py err");
5151
}
5252
// TODO check nb of bytes written
@@ -77,7 +77,7 @@ size_t PyCallbackIOReader::operator()(void* ptrv, size_t size, size_t nitems) {
7777
while (rs > 0) {
7878
size_t ri = rs > bs ? bs : rs;
7979
PyObject* result = PyObject_CallFunction(callback, "(n)", ri);
80-
if (result == NULL) {
80+
if (result == nullptr) {
8181
FAISS_THROW_MSG("propagate py error");
8282
}
8383
if (!PyBytes_Check(result)) {
@@ -122,7 +122,7 @@ bool PyCallbackIDSelector::is_member(faiss::idx_t id) const {
122122
FAISS_THROW_IF_NOT((id >> 32) == 0);
123123
PyThreadLock gil;
124124
PyObject* result = PyObject_CallFunction(callback, "(n)", int(id));
125-
if (result == NULL) {
125+
if (result == nullptr) {
126126
FAISS_THROW_MSG("propagate py error");
127127
}
128128
bool b = PyObject_IsTrue(result);

0 commit comments

Comments
 (0)