Skip to content

Commit 753197c

Browse files
authored
Fix compiler warnings on Py_SET_REFCNT() (#3236)
Cast `size_t` to `Py_ssize_t` to avoid compiler warnings in `Py_SET_REFCNT()`.
1 parent 3f5ea50 commit 753197c

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/core/buffer.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
930930
for (size_t i = 0; i < n; ++i) {
931931
data[i] = Py_None;
932932
}
933-
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n);
933+
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n));
934934
}
935935
impl_->contains_pyobjects_ = true;
936936
return *this;
@@ -955,7 +955,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
955955
if (n_new > n_old) {
956956
PyObject** data = static_cast<PyObject**>(xptr());
957957
for (size_t i = n_old; i < n_new; ++i) data[i] = Py_None;
958-
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n_new - n_old);
958+
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n_new - n_old));
959959
}
960960
} else {
961961
impl_->resize(newsize);
@@ -1019,7 +1019,7 @@ class Mmap_BufferImpl : public BufferImpl, MemoryMapWorker {
10191019
size_t i = 0;
10201020
for (; i < n_copy; ++i) Py_INCREF(newdata[i]);
10211021
for (; i < n_new; ++i) newdata[i] = Py_None;
1022-
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + n_new - n_copy);
1022+
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(n_new - n_copy));
10231023
}
10241024
impl_->release(); // noexcept
10251025
}

src/core/column/const_na.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ static Column _fw_col(size_t nrows, SType stype) {
8585
});
8686

8787
if (std::is_same<T, PyObject*>::value) {
88-
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + nrows);
88+
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(nrows));
8989
buf.set_pyobjects(/* clear_data= */ false);
9090
}
9191
return Column(new ColClass(nrows, stype, std::move(buf)));
@@ -102,7 +102,7 @@ static Column _special_col(size_t nrows) {
102102
});
103103

104104
if (std::is_same<T, PyObject*>::value) {
105-
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + nrows);
105+
Py_SET_REFCNT(Py_None, Py_REFCNT(Py_None) + static_cast<Py_ssize_t>(nrows));
106106
buf.set_pyobjects(/* clear_data= */ false);
107107
}
108108
return Column(new ColClass(nrows, std::move(buf)));

0 commit comments

Comments
 (0)