]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/PyModule: use Py_ssize_t for the PyList index
authorKefu Chai <kchai@redhat.com>
Sat, 8 May 2021 12:59:07 +0000 (20:59 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 11 May 2021 01:31:52 +0000 (09:31 +0800)
also silences the warnings like:

mgr/PyModule.cc:574:30: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'Py_ssize_t' {aka 'int'} [-Wsign-compare]
  574 |       for (unsigned i = 0; i < PyList_Size(p); ++i) {
      |                            ~~^~~~~~~~~~~~~~~~

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/mgr/PyModule.cc

index 28c76fe7edcdb881f08883aba65f1dd697f29b2e..ff1ff85e7eaa53697fa04f6595f958906a95bf7c 100644 (file)
@@ -562,7 +562,7 @@ int PyModule::load_options()
     }
     p = PyDict_GetItemString(pOption, "enum_allowed");
     if (p && PyObject_TypeCheck(p, &PyList_Type)) {
-      for (unsigned i = 0; i < PyList_Size(p); ++i) {
+      for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) {
        auto q = PyList_GetItem(p, i);
        if (q) {
          auto r = PyObject_Str(q);
@@ -573,7 +573,7 @@ int PyModule::load_options()
     }
     p = PyDict_GetItemString(pOption, "see_also");
     if (p && PyObject_TypeCheck(p, &PyList_Type)) {
-      for (unsigned i = 0; i < PyList_Size(p); ++i) {
+      for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) {
        auto q = PyList_GetItem(p, i);
        if (q && PyObject_TypeCheck(q, &PyUnicode_Type)) {
          option.see_also.insert(PyUnicode_AsUTF8(q));
@@ -582,7 +582,7 @@ int PyModule::load_options()
     }
     p = PyDict_GetItemString(pOption, "tags");
     if (p && PyObject_TypeCheck(p, &PyList_Type)) {
-      for (unsigned i = 0; i < PyList_Size(p); ++i) {
+      for (Py_ssize_t i = 0; i < PyList_Size(p); ++i) {
        auto q = PyList_GetItem(p, i);
        if (q && PyObject_TypeCheck(q, &PyUnicode_Type)) {
          option.tags.insert(PyUnicode_AsUTF8(q));