Skip to content

Commit c43b156

Browse files
committed
Make clangtidy happy
1 parent 655db8a commit c43b156

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

include/pybind11/detail/argument_vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ struct small_vector {
197197
}
198198

199199
void sort() {
200-
T *begin;
200+
T *begin = nullptr;
201201
if (is_inline()) {
202202
begin = &m_repr.iarray.arr[0];
203203
} else {

include/pybind11/pybind11.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -847,10 +847,8 @@ class cpp_function : public function {
847847
}
848848

849849
/// Main dispatch logic for calls to functions bound using pybind11
850-
static PyObject *dispatcher(PyObject *self,
851-
PyObject *const *args_in_arr,
852-
Py_ssize_t nargsf,
853-
PyObject *kwnames_in) {
850+
static PyObject *
851+
dispatcher(PyObject *self, PyObject *const *args_in_arr, size_t nargsf, PyObject *kwnames_in) {
854852
using namespace detail;
855853
const function_record *overloads = function_record_ptr_from_PyObject(self);
856854
assert(overloads != nullptr);
@@ -860,7 +858,7 @@ class cpp_function : public function {
860858

861859
/* Need to know how many arguments + keyword arguments there are to pick the right
862860
overload */
863-
const size_t n_args_in = PyVectorcall_NARGS(nargsf);
861+
const auto n_args_in = static_cast<size_t>(PyVectorcall_NARGS(nargsf));
864862

865863
handle parent = n_args_in > 0 ? args_in_arr[0] : nullptr,
866864
result = PYBIND11_TRY_NEXT_OVERLOAD;
@@ -1011,7 +1009,7 @@ class cpp_function : public function {
10111009
// 2. Check kwargs and, failing that, defaults that may help complete the list
10121010
small_vector<size_t, arg_vector_small_size> used_kwargs;
10131011
if (kwnames_in) {
1014-
used_kwargs.reserve(PyTuple_GET_SIZE(kwnames_in));
1012+
used_kwargs.reserve(static_cast<size_t>(PyTuple_GET_SIZE(kwnames_in)));
10151013
}
10161014
if (args_copied < num_args) {
10171015
for (; args_copied < num_args; ++args_copied) {
@@ -1021,8 +1019,8 @@ class cpp_function : public function {
10211019
if (kwnames_in && arg_rec.name) {
10221020
ssize_t i = keyword_index(kwnames_in, arg_rec.name);
10231021
if (i >= 0) {
1024-
value = args_in_arr[n_args_in + i];
1025-
used_kwargs.emplace_back(i);
1022+
value = args_in_arr[n_args_in + static_cast<size_t>(i)];
1023+
used_kwargs.emplace_back(static_cast<size_t>(i));
10261024
}
10271025
}
10281026

@@ -1083,7 +1081,8 @@ class cpp_function : public function {
10831081
if (func.has_kwargs) {
10841082
dict kwargs;
10851083
size_t used_i = 0;
1086-
size_t name_count = kwnames_in ? PyTuple_GET_SIZE(kwnames_in) : 0;
1084+
size_t name_count
1085+
= kwnames_in ? static_cast<size_t>(PyTuple_GET_SIZE(kwnames_in)) : 0;
10871086
used_kwargs.sort();
10881087
for (size_t i = 0; i < name_count; ++i) {
10891088
if (used_i < used_kwargs.size() && used_kwargs[used_i] == i) {
@@ -1249,7 +1248,7 @@ class cpp_function : public function {
12491248
}
12501249
msg += "kwargs: ";
12511250
bool first = true;
1252-
for (ssize_t i = 0; i < PyTuple_GET_SIZE(kwnames_in); ++i) {
1251+
for (size_t i = 0; i < static_cast<size_t>(PyTuple_GET_SIZE(kwnames_in)); ++i) {
12531252
if (first) {
12541253
first = false;
12551254
} else {

0 commit comments

Comments
 (0)