]> git.ipfire.org Git - pakfire.git/commitdiff
python: Correctly initialize and cast keyword arguments
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 14:19:37 +0000 (14:19 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 9 Oct 2024 15:14:07 +0000 (15:14 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/_pakfire/archive.c
src/_pakfire/key.c
src/_pakfire/package.c
src/_pakfire/pakfire.c
src/_pakfire/repo.c

index f3a34dea93535dd656f1efb2d3a512d0f92452a7..da293ba31bc2cf48e878d0dfd9fb321b9ffc895c 100644 (file)
@@ -137,11 +137,11 @@ static PyObject* Archive_verify(ArchiveObject* self) {
 }
 
 static PyObject* Archive_extract(ArchiveObject* self, PyObject* args, PyObject* kwargs) {
-       char* kwlist[] = { "path", NULL };
+       const char* kwlist[] = { "path", NULL };
        const char* path = NULL;
        const int flags = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|z", kwlist, &path))
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|z", (char**)kwlist, &path))
                return NULL;
 
        // Extract payload
index 9bf6935ceed21e3d6a37c6e67650297d159fc7f9..dcda49b61e744102532e101100656c392b975b28 100644 (file)
@@ -146,7 +146,7 @@ ERROR:
 }
 
 static PyObject* Key_sign(KeyObject* self, PyObject* args, PyObject* kwargs) {
-       char* kwlist[] = { "data", "comment", NULL };
+       const char* kwlist[] = { "data", "comment", NULL };
        PyObject* object = NULL;
        const char* data = NULL;
        Py_ssize_t data_length = 0;
@@ -155,7 +155,7 @@ static PyObject* Key_sign(KeyObject* self, PyObject* args, PyObject* kwargs) {
        size_t signature_length = 0;
        int r;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y#|z", kwlist,
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "y#|z", (char**)kwlist,
                        &data, &data_length, &comment))
                return NULL;
 
index a28bca09d65d1b62a49a7313f8e08c09ec3d8e84..17c8e3a19347c154066259505b1ad6a2fa85bbd2 100644 (file)
@@ -686,12 +686,12 @@ static int Package_set_filelist(PackageObject* self, PyObject* value) {
 }
 
 static PyObject* Package_dump(PackageObject* self, PyObject *args, PyObject* kwds) {
-       static char* kwlist[] = {"long", "filelist", NULL};
+       const char* kwlist[] = { "long", "filelist", NULL };
 
        int long_format = 0;
        int filelist = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii", kwlist, &long_format, &filelist))
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|ii", (char**)kwlist, &long_format, &filelist))
                return NULL;
 
        int flags = 0;
index 4a387b64eb448a0cf38af7bf1b6feee4db266582..61c366e148bffa118388bff9f9369a45d496c9d0 100644 (file)
@@ -58,13 +58,7 @@ static PyObject* Pakfire_new(PyTypeObject* type, PyObject* args, PyObject* kwds)
 }
 
 static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = {
-               "ctx",
-               "path",
-               "arch",
-               "conf",
-               NULL,
-       };
+       const char* kwlist[] = { "ctx", "path", "arch", "conf", NULL };
        CtxObject* ctx = NULL;
        const char* path = NULL;
        const char* arch = NULL;
@@ -73,7 +67,7 @@ static int Pakfire_init(PakfireObject* self, PyObject* args, PyObject* kwds) {
 
        FILE* fconf = NULL;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|zzO", kwlist,
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|zzO", (char**)kwlist,
                        &CtxType, &ctx, &path, &arch, &conf))
                goto ERROR;
 
@@ -174,12 +168,12 @@ static PyObject* Pakfire_get_repo(PakfireObject* self, PyObject* args) {
        XXX This could be moved out of here as this no longer depends on Pakfire
 */
 static PyObject* Pakfire_generate_key(PakfireObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = { "algorithm", "comment", NULL };
+       const char* kwlist[] = { "algorithm", "comment", NULL };
        struct pakfire_key* key = NULL;
        pakfire_key_algo_t algo = PAKFIRE_KEY_ALGO_NULL;
        const char* comment = NULL;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "is", kwlist, &algo, &comment))
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "is", (char**)kwlist, &algo, &comment))
                return NULL;
 
        // Generate a new key
@@ -305,7 +299,7 @@ ERROR:
 }
 
 static PyObject* Pakfire_search(PakfireObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = { "pattern", "name_only", NULL };
+       const char* kwlist[] = { "pattern", "name_only", NULL };
        struct pakfire_packagelist* list = NULL;
        const char* pattern = NULL;
        int name_only = 0;
@@ -313,7 +307,7 @@ static PyObject* Pakfire_search(PakfireObject* self, PyObject* args, PyObject* k
        PyObject* ret = NULL;
        int r;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|$p", kwlist, &pattern, &name_only))
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "s|$p", (char**)kwlist, &pattern, &name_only))
                return NULL;
 
        // Search for package names only
@@ -393,14 +387,7 @@ ERROR:
 }
 
 static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = {
-               "command",
-               "environ",
-               "bind",
-               "callback",
-               "nice",
-               NULL
-       };
+       const char* kwlist[] = { "command", "environ", "bind", "callback", "nice", NULL };
 
        struct pakfire_jail* jail = NULL;
        const char** argv = NULL;
@@ -413,7 +400,7 @@ static PyObject* Pakfire_execute(PakfireObject* self, PyObject* args, PyObject*
        PyObject* callback = NULL;
        int nice = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOi", kwlist, &command, &environ,
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "O|OOOi", (char**)kwlist, &command, &environ,
                        &bind, &callback, &nice))
                return NULL;
 
@@ -696,14 +683,15 @@ static PyObject* Pakfire_open(PakfireObject* self, PyObject* args) {
 }
 
 static PyObject* Pakfire_repo_compose(PakfireObject* self, PyObject* args, PyObject* kwargs) {
-       char* kwlist[] = { "path", "files", "key", NULL };
+       const char* kwlist[] = { "path", "files", "key", NULL };
        const char* path = NULL;
        PyObject* list = NULL;
        KeyObject* key = NULL;
 
        PyObject* ret = NULL;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO|O!", kwlist, &path, &list, &KeyType, &key))
+       if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO|O!", (char**)kwlist,
+                       &path, &list, &KeyType, &key))
                return NULL;
 
        // List must be a sequence
index 497185ae51db54057ec7152f8c54ee799f196a5e..8e29cacd7e0ade94765391849ddee22dafc705b3 100644 (file)
@@ -216,11 +216,11 @@ static int Repo_set_mirrorlist(RepoObject* self, PyObject* value) {
 }
 
 static PyObject* Repo_refresh(RepoObject* self, PyObject* args, PyObject* kwds) {
-       char* kwlist[] = { "force", NULL };
+       const char* kwlist[] = { "force", NULL };
 
        int force = 0;
 
-       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p", kwlist, &force))
+       if (!PyArg_ParseTupleAndKeywords(args, kwds, "|p", (char**)kwlist, &force))
                return NULL;
 
        Py_BEGIN_ALLOW_THREADS