From 534425ba2f6527666401b9cab6960c977ca22308 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 21 Jul 2023 14:32:46 +1200 Subject: [PATCH] python: Remove const from PyList_AsStringList() The returned strings are not owned by python, so need not be const. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15289 Signed-off-by: Andrew Bartlett Reviewed-by: Douglas Bagnall (cherry picked from commit 5afd206d1d8f0344a2f1fa7a238204d1fb164eda) --- python/modules.c | 8 ++++---- python/modules.h | 4 ++-- source4/auth/pyauth.c | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python/modules.c b/python/modules.c index 83dc91c08a1..ca563ff07d2 100644 --- a/python/modules.c +++ b/python/modules.c @@ -72,16 +72,16 @@ error: return false; } -const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list, - const char *paramname) +char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list, + const char *paramname) { - const char **ret; + char **ret; Py_ssize_t i; if (!PyList_Check(list)) { PyErr_Format(PyExc_TypeError, "%s is not a list", paramname); return NULL; } - ret = talloc_array(NULL, const char *, PyList_Size(list)+1); + ret = talloc_array(NULL, char *, PyList_Size(list)+1); if (ret == NULL) { PyErr_NoMemory(); return NULL; diff --git a/python/modules.h b/python/modules.h index 331adde0230..356937d71f9 100644 --- a/python/modules.h +++ b/python/modules.h @@ -26,8 +26,8 @@ bool py_update_path(void); /* discard signature of 'func' in favour of 'target_sig' */ #define PY_DISCARD_FUNC_SIG(target_sig, func) (target_sig)(void(*)(void))func -const char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list, - const char *paramname); +char **PyList_AsStringList(TALLOC_CTX *mem_ctx, PyObject *list, + const char *paramname); #endif /* __SAMBA_PYTHON_MODULES_H__ */ diff --git a/source4/auth/pyauth.c b/source4/auth/pyauth.c index ee36b5e5efa..b41108b7072 100644 --- a/source4/auth/pyauth.c +++ b/source4/auth/pyauth.c @@ -367,7 +367,7 @@ static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObjec struct tevent_context *ev; struct ldb_context *ldb = NULL; NTSTATUS nt_status; - const char **methods; + const char *const *methods; const char *const kwnames[] = {"lp_ctx", "ldb", "methods", NULL}; @@ -413,7 +413,7 @@ static PyObject *py_auth_context_new(PyTypeObject *type, PyObject *args, PyObjec mem_ctx, ev, NULL, lp_ctx, &auth_context); } else { if (py_methods != Py_None) { - methods = PyList_AsStringList(mem_ctx, py_methods, "methods"); + methods = (const char * const *)PyList_AsStringList(mem_ctx, py_methods, "methods"); if (methods == NULL) { talloc_free(mem_ctx); return NULL;