diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-11-24 13:10:04 +0100 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2022-11-24 13:13:58 +0100 |
commit | 02cc30befa2d5cdfa1d1c214012490332a88a333 (patch) | |
tree | fb241a34f0451f68ca5ba1bd31b1ffdee1c2eb5b /util.c | |
parent | dcf512bb44c5a83540295115ec46633affd8c646 (diff) | |
download | libsigrokdecode-02cc30befa2d5cdfa1d1c214012490332a88a333.tar.gz libsigrokdecode-02cc30befa2d5cdfa1d1c214012490332a88a333.zip |
util: silence printf format compiler warnings (Python ssize_t)
On some platforms PY_FORMAT_SIZE_T seems to be ineffective, resulting in
compiler warnings about printf format data type mismatches (observed in
MXE builds).
Silence the warnings. Prefer the ssize_t data type instead which we know
the printf format of, reliably.
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -115,7 +115,7 @@ err: SRD_PRIV int py_attr_as_strlist(PyObject *py_obj, const char *attr, GSList **outstrlist) { PyObject *py_list; - Py_ssize_t i; + ssize_t idx; int ret; char *outstr; PyGILState_STATE gstate; @@ -139,10 +139,10 @@ SRD_PRIV int py_attr_as_strlist(PyObject *py_obj, const char *attr, GSList **out *outstrlist = NULL; - for (i = 0; i < PyList_Size(py_list); i++) { - ret = py_listitem_as_str(py_list, i, &outstr); + for (idx = 0; idx < PyList_Size(py_list); idx++) { + ret = py_listitem_as_str(py_list, idx, &outstr); if (ret < 0) { - srd_dbg("Couldn't get item %" PY_FORMAT_SIZE_T "d.", i); + srd_dbg("Couldn't get item %zd.", idx); goto err; } *outstrlist = g_slist_append(*outstrlist, outstr); @@ -217,8 +217,9 @@ err: SRD_PRIV int py_listitem_as_str(PyObject *py_obj, Py_ssize_t idx, char **outstr) { - PyObject *py_value; PyGILState_STATE gstate; + ssize_t item_idx; + PyObject *py_value; gstate = PyGILState_Ensure(); @@ -227,8 +228,9 @@ SRD_PRIV int py_listitem_as_str(PyObject *py_obj, Py_ssize_t idx, goto err; } - if (!(py_value = PyList_GetItem(py_obj, idx))) { - srd_dbg("Couldn't get list item %" PY_FORMAT_SIZE_T "d.", idx); + item_idx = idx; + if (!(py_value = PyList_GetItem(py_obj, item_idx))) { + srd_dbg("Couldn't get list item %zd.", item_idx); goto err; } |