chiark / gitweb /
Consistently make keyword-lists be static and read-only.
[catacomb-python] / key.c
diff --git a/key.c b/key.c
index c5b0ac042bfc8bfaa420b921c144256aaaa78dda..1700259d02946d918787ac74398ee840ab2fc21b 100644 (file)
--- a/key.c
+++ b/key.c
@@ -351,10 +351,10 @@ static PyObject *kdmeth_split(PyObject *me, PyObject *arg)
 static PyObject *kdmeth_copy(PyObject *me, PyObject *arg, PyObject *kw)
 {
   key_filter f = { 0, 0 };
-  static char *kwlist[] = { "filter", 0 };
+  static const char *const kwlist[] = { "filter", 0 };
   key_data *kd;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:copy", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:copy", KWLIST,
                                   convfilter, &f))
     return (0);
   if ((kd = key_copydata(KEYDATA_KD(me), &f)) == 0)
@@ -368,9 +368,9 @@ static PyObject *kdmeth_write(PyObject *me, PyObject *arg, PyObject *kw)
   key_filter f = { 0, 0 };
   dstr d = DSTR_INIT;
   PyObject *rc = 0;
-  static char *kwlist[] = { "filter", 0 };
+  static const char *const kwlist[] = { "filter", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:write", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:write", KWLIST,
                                   convfilter, &f))
     return (0);
   key_write(KEYDATA_KD(me), &d, &f);
@@ -384,9 +384,9 @@ static PyObject *kdmeth_encode(PyObject *me, PyObject *arg, PyObject *kw)
   key_filter f = { 0, 0 };
   dstr d = DSTR_INIT;
   PyObject *rc = 0;
-  static char *kwlist[] = { "filter", 0 };
+  static const char *const kwlist[] = { "filter", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:encode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:encode", KWLIST,
                                   convfilter, &f))
     return (0);
   key_encode(KEYDATA_KD(me), &d, &f);
@@ -536,9 +536,9 @@ static PyObject *keydatabin_pynew(PyTypeObject *ty,
   Py_ssize_t n;
   unsigned f = 0;
   keydata_pyobj *me = 0;
-  static char *kwlist[] = { "key", "flags", 0 };
+  static const char *const kwlist[] = { "key", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", KWLIST,
                                   &p, &n, convflags, &f))
     goto end;
   me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
@@ -613,9 +613,9 @@ static PyObject *keydataenc_pynew(PyTypeObject *ty,
   Py_ssize_t n;
   unsigned f = 0;
   keydata_pyobj *me = 0;
-  static char *kwlist[] = { "key", "flags", 0 };
+  static const char *const kwlist[] = { "key", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:new", KWLIST,
                                   &p, &n, convflags, &f))
     goto end;
   me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
@@ -749,9 +749,9 @@ static PyObject *keydatamp_pynew(PyTypeObject *ty,
   mp *x = 0;
   unsigned f = 0;
   keydata_pyobj *me = 0;
-  static char *kwlist[] = { "key", "flags", 0 };
+  static const char *const kwlist[] = { "key", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", KWLIST,
                                   convmp, &x, convflags, &f))
     goto end;
   me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
@@ -825,9 +825,9 @@ static PyObject *keydatastr_pynew(PyTypeObject *ty,
   char *p;
   unsigned f = 0;
   keydata_pyobj *me = 0;
-  static char *kwlist[] = { "key", "flags", 0 };
+  static const char *const kwlist[] = { "key", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:new", KWLIST,
                                   &p, convflags, &f))
     goto end;
   me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
@@ -900,9 +900,9 @@ static PyObject *keydataec_pynew(PyTypeObject *ty,
   ec x = EC_INIT;
   unsigned f = 0;
   keydata_pyobj *me = 0;
-  static char *kwlist[] = { "key", "flags", 0 };
+  static const char *const kwlist[] = { "key", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", KWLIST,
                                   convecpt, &x, convflags, &f))
     goto end;
   me = (keydata_pyobj *)ty->tp_alloc(ty, 0);
@@ -1053,10 +1053,10 @@ static PyObject *keydatastruct_pynew(PyTypeObject *ty,
   char *p;
   keydata_pyobj *me = 0;
   key_data *kd = 0;
-  static char *kwlist[] = { "subkeys", 0 };
+  static const char *const kwlist[] = { "subkeys", 0 };
 
   Py_XINCREF(arg); Py_XINCREF(kw);
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:new", kwlist, &sub))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:new", KWLIST, &sub))
     goto end;
   kd = key_newstruct();
   if (sub) {
@@ -1386,11 +1386,12 @@ static PyObject *key_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   uint32 id;
   char *type;
   unsigned long exptime = KEXP_FOREVER;
-  static char *kwlist[] = { "keyfile", "id", "type", "exptime", 0 };
+  static const char *const kwlist[] =
+    { "keyfile", "id", "type", "exptime", 0 };
   key *k;
   int err;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&s|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&s|O&:new", KWLIST,
                                   keyfile_pytype, &kfobj, convu32, &id,
                                   &type, convulong, &exptime))
     goto end;
@@ -1448,9 +1449,9 @@ static PyObject *kmeth_extract(PyObject *me, PyObject *arg, PyObject *kw)
   PyObject *nameobj;
   char *name;
   FILE *fp;
-  static char *kwlist[] = { "file", "filter", 0 };
+  static const char *const kwlist[] = { "file", "filter", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:extract", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O&:extract", KWLIST,
                                   &PyFile_Type, &file,
                                   convfilter, &f) ||
       (fp = PyFile_AsFile(file)) == 0 ||
@@ -1469,9 +1470,9 @@ static PyObject *kmeth_fingerprint(PyObject *me,
 {
   ghash *h;
   key_filter f = { KF_NONSECRET, KF_NONSECRET };
-  static char *kwlist[] = { "hash", "filter", 0 };
+  static const char *const kwlist[] = { "hash", "filter", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:fingerprint", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:fingerprint", KWLIST,
                                   convghash, &h, convfilter, &f))
     return (0);
   return (getbool(key_fingerprint(KEY_K(me), h, &f)));
@@ -1773,10 +1774,10 @@ static PyObject *keyfile_pynew(PyTypeObject *ty,
   char *file = 0;
   unsigned how = KOPEN_READ;
   keyfile_pyobj *rc = 0;
-  static char *kwlist[] = { "file", "how", "report", 0 };
+  static const char *const kwlist[] = { "file", "how", "report", 0 };
 
   Py_XINCREF(arg); Py_XINCREF(kw);
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|iO:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|iO:new", KWLIST,
                                   &file, &how, &ri.func))
     goto end;
   if (ri.func && !PyCallable_Check(ri.func))
@@ -1832,10 +1833,10 @@ static PyObject *kfmeth_merge(PyObject *me, PyObject *arg, PyObject *kw)
   PyObject *x = 0;
   FILE *fp = 0;
   int rc;
-  static char *kwlist[] = { "file", "report", 0 };
+  static const char *const kwlist[] = { "file", "report", 0 };
 
   Py_XINCREF(arg); Py_XINCREF(kw);
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O:merge", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!|O:merge", KWLIST,
                                   &PyFile_Type, &x, &ri.func))
     goto end;
   if (ri.func && !PyCallable_Check(ri.func))
@@ -1931,11 +1932,11 @@ static PyObject *kfmeth_newkey(PyObject *me, PyObject *arg, PyObject *kw)
   uint32 id;
   char *type;
   long exptime = KEXP_FOREVER;
-  static char *kwlist[] = { "id", "type", "exptime", 0 };
+  static const char *const kwlist[] = { "id", "type", "exptime", 0 };
   key *k;
   int err;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s|l:newkey", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s|l:newkey", KWLIST,
                                   convu32, &id, &type, &exptime))
     goto end;
   if ((err = key_new(KEYFILE_KF(me), id, type, exptime, &k)) != 0)
@@ -1953,9 +1954,9 @@ static PyObject *kfmeth_qtag(PyObject *me, PyObject *arg, PyObject *kw)
   char *tag;
   dstr d = DSTR_INIT;
   PyObject *rc = 0;
-  static char *kwlist[] = { "tag", "new", 0 };
+  static const char *const kwlist[] = { "tag", "new", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O!:qtag", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O!:qtag", KWLIST,
                                   &tag, keydata_pytype, &newkdobj))
     goto end;
   if (key_qtag(KEYFILE_KF(me), tag, &d, &k, &kd))