chiark / gitweb /
Consistently make keyword-lists be static and read-only.
authorMark Wooding <mdw@distorted.org.uk>
Fri, 9 Nov 2018 12:16:59 +0000 (12:16 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Sat, 10 Nov 2018 01:30:58 +0000 (01:30 +0000)
We had an exciting mix of static and automatic storage durations, and
none were marked as `const'.  Python isn't `const'-correct, so we have
to cast away the `const'-ness: introduce a new macro `KWLIST' to do
this.

Also constify some other related tables, such as method names in
`pgev_python'.

15 files changed:
algorithms.c
buffer.c
bytestring.c
catacomb-python.h
ec.c
field.c
group.c
key.c
mp.c
passphrase.c
pgen.c
pubkey.c
rand.c
share.c
util.c

index 7eab3ae4571c9cb1fe543b7a591621808d9b4180..3e1866f060d83a047600465d79b611decc1acdbe 100644 (file)
@@ -83,11 +83,11 @@ PyObject *keysz_pywrap(const octet *k)
 static PyObject *keyszany_pynew(PyTypeObject *ty,
                                PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "default", 0 };
+  static const char *const kwlist[] = { "default", 0 };
   int dfl;
   keysz_pyobj *o;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i:new", kwlist, &dfl))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i:new", KWLIST, &dfl))
     goto end;
   if (dfl < 0) VALERR("key size cannot be negative");
   o = (keysz_pyobj *)ty->tp_alloc(ty, 0);
@@ -100,11 +100,11 @@ end:
 static PyObject *keyszrange_pynew(PyTypeObject *ty,
                                  PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "default", "min", "max", "mod", 0 };
+  static const char *const kwlist[] = { "default", "min", "max", "mod", 0 };
   int dfl, min = 0, max = 0, mod = 1;
   keyszrange_pyobj *o;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|iii:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|iii:new", KWLIST,
                                   &dfl, &min, &max, &mod))
     goto end;
   if (dfl < 0 || min < 0) VALERR("key size cannot be negative");
@@ -124,13 +124,13 @@ end:
 static PyObject *keyszset_pynew(PyTypeObject *ty,
                                PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "default", "set", 0 };
+  static const char *const kwlist[] = { "default", "set", 0 };
   int dfl, i, n, xx;
   PyObject *set = 0;
   PyObject *x = 0, *l = 0;
   keyszset_pyobj *o = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|O:new", kwlist, &dfl, &set))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|O:new", KWLIST, &dfl, &set))
     goto end;
   if (!set) set = PyTuple_New(0);
   else Py_INCREF(set);
@@ -470,11 +470,11 @@ PyObject *gcipher_pywrap(PyObject *cobj, gcipher *c, unsigned f)
 
 static PyObject *gcipher_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "k", 0 };
+  static const char *const kwlist[] = { "k", 0 };
   char *k;
   Py_ssize_t sz;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &k, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &k, &sz))
     goto end;
   if (keysz(sz, GCCIPHER_CC(ty)->keysz) != sz) VALERR("bad key length");
   return (gcipher_pywrap((PyObject *)ty,
@@ -722,8 +722,8 @@ CONVFUNC(ghash, ghash *, GHASH_H)
 
 static PyObject *ghash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", kwlist))
+  static const char *const kwlist[] = { 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST))
     goto end;
   return (ghash_pywrap((PyObject *)ty, GH_INIT(GCHASH_CH(ty)), f_freeme));
 end:
@@ -960,11 +960,11 @@ CONVFUNC(gmhash, ghash *, GHASH_H)
 
 static PyObject *gmac_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "k", 0 };
+  static const char *const kwlist[] = { "k", 0 };
   char *k;
   Py_ssize_t sz;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &k, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &k, &sz))
     goto end;
   if (keysz(sz, GCMAC_CM(ty)->keysz) != sz) VALERR("bad key length");
   return (gmac_pywrap((PyObject *)ty,
@@ -976,10 +976,10 @@ end:
 
 static PyObject *gmhash_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { 0 };
+  static const char *const kwlist[] = { 0 };
   ghash_pyobj *g;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", kwlist)) return (0);
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST)) return (0);
   g = PyObject_NEW(ghash_pyobj, ty);
   g->h = GM_INIT(GMAC_M(ty));
   g->f = f_freeme;
@@ -1220,13 +1220,13 @@ CONVFUNC(poly1305hash, poly1305_ctx *, P1305_CTX)
 static PyObject *poly1305hash_pynew(PyTypeObject *ty,
                                    PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "mask", 0 };
+  static const char *const kwlist[] = { "mask", 0 };
   poly1305key_pyobj *pk = (poly1305key_pyobj *)ty;
   poly1305hash_pyobj *ph;
   char *m = 0;
   Py_ssize_t sz;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s#:new", kwlist, &m, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s#:new", KWLIST, &m, &sz))
     return (0);
   if (m && sz != POLY1305_MASKSZ) VALERR("bad mask length");
   ph = PyObject_NEW(poly1305hash_pyobj, ty);
@@ -1242,12 +1242,12 @@ end:
 static PyObject *poly1305key_pynew(PyTypeObject *ty,
                                   PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "k", 0 };
+  static const char *const kwlist[] = { "k", 0 };
   poly1305key_pyobj *pk;
   char *k;
   Py_ssize_t sz;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &k, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &k, &sz))
     goto end;
   if (keysz(sz, poly1305_keysz) != sz) VALERR("bad key length");
 
@@ -1600,8 +1600,8 @@ static PyObject *kxvik_pynew(PyTypeObject *ty,
 {
   unsigned n = 24;
   kxvik_pyobj *rc = 0;
-  char *kwlist[] = { "nround", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", kwlist,
+  static const char *const kwlist[] = { "nround", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", KWLIST,
                                   convuint, &n))
     goto end;
   rc = (kxvik_pyobj *)ty->tp_alloc(ty, 0);
@@ -1764,9 +1764,9 @@ static PyObject *shake_dopynew(void (*initfn)(shake_ctx *,
   shake_pyobj *rc = 0;
   char *p = 0, *f = 0;
   Py_ssize_t psz = 0, fsz = 0;
-  char *kwlist[] = { "perso", "func", 0 };
+  static const char *const kwlist[] = { "perso", "func", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s#s#:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s#s#:new", KWLIST,
                                   &p, &psz, &f, &fsz))
     goto end;
   rc = (shake_pyobj *)ty->tp_alloc(ty, 0);
@@ -2148,13 +2148,13 @@ typedef struct prp {
 
 static PyObject *gprp_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "key", 0 };
+  static const char *const kwlist[] = { "key", 0 };
   char *k;
   Py_ssize_t sz;
   const prpinfo *prp = GCPRP_PRP(ty);
   PyObject *me;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &k, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &k, &sz))
     goto end;
   if (keysz(sz, prp->keysz) != sz) VALERR("bad key length");
   me = (PyObject *)ty->tp_alloc(ty, 0);
index bf1cadc554a5cc00d8e070b810a9868d2eb8c4c0..b88232b158dca1e21a32f446364178114c17d3fe 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -55,9 +55,9 @@ static PyObject *rbuf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   char *p, *q;
   Py_ssize_t n;
   buf_pyobj *me = 0;
-  static char *kwlist[] = { "data", 0 };
+  static const char *const kwlist[] = { "data", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &p, &n))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &p, &n))
     goto end;
   q = xmalloc(n);
   memcpy(q, p, n);
@@ -171,9 +171,9 @@ end:
 static PyObject *rbmeth_getecpt(PyObject *me, PyObject *arg, PyObject *kw)
 {
   PyObject *cobj = Py_None;
-  static char *kwlist[] = { "curve", 0 };
+  static const char *const kwlist[] = { "curve", 0 };
   ec pt = EC_INIT;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:getecpt", kwlist, &cobj))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:getecpt", KWLIST, &cobj))
     goto end;
   if (cobj == Py_None) cobj = (PyObject *)ecpt_pytype;
   if (!PyType_Check(cobj) ||
@@ -354,9 +354,9 @@ static PyObject *wbuf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   char *p;
   size_t n = 64;
   buf_pyobj *me = 0;
-  static char *kwlist[] = { "size", 0 };
+  static const char *const kwlist[] = { "size", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", KWLIST,
                                   convszt, &n))
     goto end;
   me = (buf_pyobj *)ty->tp_alloc(ty, 0);
index 0c68d4321d23e5c78e41b35762b885c0887a52a6..67eb500ec2dbffba733fd015a1e49688cdedcac5 100644 (file)
@@ -55,8 +55,8 @@ static PyObject *bytestring_pynew(PyTypeObject *ty,
 {
   const char *p;
   Py_ssize_t n;
-  static char *kwlist[] = { "data", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &p, &n))
+  static const char *const kwlist[] = { "data", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &p, &n))
     return (0);
   return (dowrap(ty, p, n));
 }
index 1989cd0409c388af6bbe2aaec1036044b568be18..bbb5fac76e41388fc10a81e7010427cae8a05822 100644 (file)
@@ -231,6 +231,8 @@ MODULES(DO)
     return (d);                                                                \
   }
 
+#define KWLIST (/*unconst*/ char **)kwlist
+
 struct nameval { const char *name; unsigned long value; };
 extern void setconstants(PyObject *, const struct nameval *);
 
diff --git a/ec.c b/ec.c
index da4cc34d5dc095bf1fb1fd90fb34dddd2cbc0382..f7d61814b5cf5f3d7e14fbe4e2979ee52dae8ff8 100644 (file)
--- a/ec.c
+++ b/ec.c
@@ -299,9 +299,9 @@ static PyObject *epmeth_ec2osp(PyObject *me, PyObject *arg, PyObject *kw)
   ec pp = EC_INIT;
   int f = EC_EXPLY;
   int len;
-  char *kwlist[] = { "flags", 0 };
+  static const char *const kwlist[] = { "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:ectosp", kwlist, &f))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:ectosp", KWLIST, &f))
     return (0);
   len = c->f->noctets * 2 + 1;
   rc = bytestring_pywrap(0, len);
@@ -507,9 +507,9 @@ static PyObject *ecptnc_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   PyObject *x = 0, *y = 0, *z = 0;
   ec p = EC_INIT;
-  char *kwlist[] = { "x", "y", 0 };
+  static const char *const kwlist[] = { "x", "y", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|OO:new", kwlist, &x, &y) ||
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|OO:new", KWLIST, &x, &y) ||
       ecptxl(0, &p, x, y, z))
     goto end;
   return (ecpt_pywrapout(ty, &p));
@@ -548,9 +548,9 @@ static PyObject *ecpt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   PyObject *x = 0, *y = 0, *z = 0;
   ec p = EC_INIT;
-  char *kwlist[] = { "x", "y", "z", 0 };
+  static const char *const kwlist[] = { "x", "y", "z", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|OOO:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|OOO:new", KWLIST,
                                   &x, &y, &z) ||
       ecptxl(ECCURVE_C(ty), &p, x, y, z))
     goto end;
@@ -865,9 +865,9 @@ static PyObject *meth__ECPtCurve_os2ecp(PyObject *me,
   ec_curve *cc;
   int f = EC_XONLY | EC_LSB | EC_SORT | EC_EXPLY;
   ec pp = EC_INIT;
-  char *kwlist[] = { "buf", "flags", 0 };
+  static const char *const kwlist[] = { "buf", "flags", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|f:os2ecp", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|f:os2ecp", KWLIST,
                                   &me, &p, &len, &f))
     return (0);
   buf_init(&b, p, len);
@@ -943,11 +943,11 @@ end:
 
 static PyObject *ecmeth_rand(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   grand *r = &rand_global;
   ec p = EC_INIT;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:rand", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:rand", KWLIST,
                                   convgrand, &r))
     return (0);
   ec_rand(ECCURVE_C(me), &p, r);
@@ -1003,10 +1003,10 @@ static PyObject *eccurve_pynew(PyTypeObject *ty,
 {
   PyObject *fobj;
   PyObject *cobj = 0;
-  char *kwlist[] = { "field", "a", "b", 0 };
+  static const char *const kwlist[] = { "field", "a", "b", 0 };
   mp *aa = 0, *bb = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&O&", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O&O&", KWLIST,
                                   field_pytype, &fobj,
                                   convmp, &aa, convmp, &bb))
     goto end;
@@ -1378,10 +1378,10 @@ static PyObject *ecinfo_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   ec_info ei = { 0 };
   PyObject *e, *g;
-  char *kwlist[] = { "curve", "G", "r", "h", 0 };
+  static const char *const kwlist[] = { "curve", "G", "r", "h", 0 };
   ecinfo_pyobj *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!O&O&:new", KWLIST,
                                   eccurve_pytype, &e, ecpt_pytype, &g,
                                   convmp, &ei.r, convmp, &ei.h))
     goto end;
@@ -1449,11 +1449,11 @@ end:
 
 static PyObject *eimeth_check(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   grand *r = &rand_global;
   const char *p;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:check", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:check", KWLIST,
                                   convgrand, &r))
     goto end;
   if ((p = ec_checkinfo(ECINFO_EI(me), r)) != 0)
diff --git a/field.c b/field.c
index 35cd452f79a1ae7ae2277693e89198b76a94b9e0..f2a0d2f855282e23dadbb3fddeed97045c674249 100644 (file)
--- a/field.c
+++ b/field.c
@@ -42,9 +42,9 @@ static PyObject *fe_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   PyObject *x;
   mp *z;
-  char *kwlist[] = { "x", 0 };
+  static const char *const kwlist[] = { "x", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:fe", kwlist, &x))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:fe", KWLIST, &x))
     return (0);
   if (FE_PYCHECK(x) && FE_F(x) == FIELD_F(ty)) RETURN_OBJ(x);
   if ((z = getmp(x)) == 0) return (0);
@@ -474,10 +474,10 @@ end:
 
 static PyObject *fmeth_rand(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   grand *r = &rand_global;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:rand", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:rand", KWLIST,
                                   convgrand, &r))
     return (0);
   return (fe_pywrap(me, F_RAND(FIELD_F(me), MP_NEW, r)));
@@ -593,9 +593,9 @@ static PyObject *primefield_pynew(PyTypeObject *ty,
 {
   mp *xx = 0;
   field *f;
-  char *kwlist[] = { "p", 0 };
+  static const char *const kwlist[] = { "p", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:primefield", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:primefield", KWLIST,
                                   convmp, &xx))
     goto end;
   if ((f = field_prime(xx)) == 0)
@@ -669,10 +669,10 @@ static PyObject *niceprimefield_pynew(PyTypeObject *ty,
 {
   mp *xx = 0;
   field *f;
-  char *kwlist[] = { "p", 0 };
+  static const char *const kwlist[] = { "p", 0 };
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:niceprimefield",
-                                  kwlist, convmp, &xx))
+                                  KWLIST, convmp, &xx))
     goto end;
   if ((f = field_niceprime(xx)) == 0)
     VALERR("bad prime for niceprimefield");
@@ -796,9 +796,9 @@ static PyObject *binpolyfield_pynew(PyTypeObject *ty,
 {
   mp *xx = 0;
   field *f;
-  char *kwlist[] = { "p", 0 };
+  static const char *const kwlist[] = { "p", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:binpolyfield", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:binpolyfield", KWLIST,
                                   convgf, &xx))
     goto end;
   if ((f = field_binpoly(xx)) == 0) VALERR("bad poly for binpolyfield");
@@ -869,10 +869,10 @@ static PyObject *binnormfield_pynew(PyTypeObject *ty,
 {
   mp *xx = 0, *yy = 0;
   field *f;
-  char *kwlist[] = { "p", "beta", 0 };
+  static const char *const kwlist[] = { "p", "beta", 0 };
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:binnormfield",
-                                  kwlist, convgf, &xx, convgf, &yy))
+                                  KWLIST, convgf, &xx, convgf, &yy))
     goto end;
   if ((f = field_binnorm(xx, yy)) == 0) VALERR("bad args for binnormfield");
   MP_DROP(xx); MP_DROP(yy);
diff --git a/group.c b/group.c
index b3c8b6a9d0f0d642f8c222f9941cdd846d560668..b5a1815ff459a14c6fc44c10027f6937ff74ea47 100644 (file)
--- a/group.c
+++ b/group.c
@@ -40,11 +40,11 @@ PyObject *fginfo_pywrap(gprime_param *dp, PyTypeObject *ty)
 static PyObject *fginfo_pynew(PyTypeObject *ty,
                              PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "p", "r", "g", 0 };
+  static const char *const kwlist[] = { "p", "r", "g", 0 };
   gprime_param dp = { 0 };
   fginfo_pyobj *z = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&O&:new", KWLIST,
                                   convmp, &dp.p,
                                   convmp, &dp.q,
                                   convmp, &dp.g))
@@ -93,11 +93,11 @@ static PyObject *meth__DHInfo_generate(PyObject *me,
   unsigned steps = 0;
   grand *r = &rand_global;
   pgev evt = { 0 };
-  char *kwlist[] =
+  static const char *const kwlist[] =
     { "class", "pbits", "qbits", "event", "rng", "nsteps", 0 };
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", KWLIST,
                                   &me, convuint, &pl, convuint, &ql,
                                   convpgev, &evt, convgrand, &r,
                                   convuint, &steps))
@@ -120,14 +120,16 @@ static PyObject *meth__DHInfo_genlimlee(PyObject *me,
   pgev oe = { 0 }, ie = { 0 };
   int subgroupp = 1;
   unsigned f = 0;
-  char *kwlist[] = { "class", "pbits", "qbits", "event", "ievent",
-                    "rng", "nsteps", "subgroupp", 0 };
+  static const char *const kwlist[] = {
+    "class", "pbits", "qbits", "event", "ievent",
+    "rng", "nsteps", "subgroupp", 0
+  };
   size_t i, nf;
   mp **v = 0;
   PyObject *rc = 0, *vec = 0;
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw,
-                                  "OO&O&|O&O&O&O&O&:genlimlee", kwlist,
+                                  "OO&O&|O&O&O&O&O&:genlimlee", KWLIST,
                                   &me, convuint, &pl, convuint, &ql,
                                   convpgev, &oe, convpgev, &ie,
                                   convgrand, &r, convuint, &steps,
@@ -155,12 +157,12 @@ static PyObject *meth__DHInfo_genkcdsa(PyObject *me,
   unsigned steps = 0;
   grand *r = &rand_global;
   pgev evt = { 0 };
-  char *kwlist[] = { "class", "pbits", "qbits",
-                    "event", "rng", "nsteps", 0 };
+  static const char *const kwlist[] =
+    { "class", "pbits", "qbits", "event", "rng", "nsteps", 0 };
   mp *v = MP_NEW;
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|O&O&O&:genkcdsa", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|O&O&O&:genkcdsa", KWLIST,
                                   &me, convuint, &pl, convuint, &ql,
                                   convpgev, &evt, convgrand, &r,
                                   convuint, &steps))
@@ -186,11 +188,11 @@ static PyObject *meth__DHInfo_gendsa(PyObject *me,
   char *k;
   Py_ssize_t ksz;
   pgev evt = { 0 };
-  char *kwlist[] =
+  static const char *const kwlist[] =
     { "class", "pbits", "qbits", "seed", "event", "nsteps", 0 };
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&s#|O&O&:gendsa", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&s#|O&O&:gendsa", KWLIST,
                                   &me, convuint, &pl, convuint, &ql,
                                   &k, &ksz, convpgev, &evt,
                                   convuint, &steps))
@@ -493,7 +495,7 @@ PyObject *ge_pywrap(PyObject *gobj, ge *x)
 
 static PyObject *ge_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "x", 0 };
+  static const char *const kwlist[] = { "x", 0 };
   PyObject *x;
   group *g;
   ec p = EC_INIT;
@@ -502,7 +504,7 @@ static PyObject *ge_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   mptext_stringctx sc;
 
   g = GROUP_G(ty);
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &x)) goto end;
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &x)) goto end;
   xx = G_CREATE(g);
   if (ECPT_PYCHECK(x)) {
     getecptout(&p, x);
@@ -716,14 +718,14 @@ end:
 
 static PyObject *gemeth_toec(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "curve", 0 };
+  static const char *const kwlist[] = { "curve", 0 };
   PyTypeObject *cty = 0;
   PyObject *rc = 0;
   group *g;
   ec_curve *c;
   ec p = EC_INIT;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:toec", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O:toec", KWLIST,
                                   &cty)) goto end;
   g = GROUP_G(GE_GOBJ(me));
   if (cty) {
@@ -800,11 +802,11 @@ static PyObject *gmeth_mexp(PyObject *me, PyObject *arg)
 
 static PyObject *gmeth_checkgroup(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   grand *r = &rand_global;
   const char *p;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:checkgroup", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:checkgroup", KWLIST,
                                   convgrand, &r))
     goto end;
   if ((p = G_CHECK(GROUP_G(me), r)) != 0)
@@ -1153,9 +1155,9 @@ static PyObject *primegroup_pynew(PyTypeObject *ty,
                                  PyObject *arg, PyObject *kw)
 {
   PyObject *i;
-  char *kwlist[] = { "info", 0 };
+  static const char *const kwlist[] = { "info", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", KWLIST,
                                   dhinfo_pytype, &i))
     return (0);
   return (group_dopywrap(ty, group_prime(FGINFO_DP(i))));
@@ -1230,9 +1232,9 @@ static PyObject *bingroup_pynew(PyTypeObject *ty,
                                PyObject *arg, PyObject *kw)
 {
   PyObject *i;
-  char *kwlist[] = { "info", 0 };
+  static const char *const kwlist[] = { "info", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", KWLIST,
                                   bindhinfo_pytype, &i))
     return (0);
   return (group_dopywrap(ty, group_binary(FGINFO_DP(i))));
@@ -1307,9 +1309,9 @@ static PyObject *ecgroup_pynew(PyTypeObject *ty,
 {
   PyObject *i;
   ec_info ei;
-  char *kwlist[] = { "info", 0 };
+  static const char *const kwlist[] = { "info", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!:new", KWLIST,
                                   ecinfo_pytype, &i))
     return (0);
   ecinfo_copy(&ei, ECINFO_EI(i));
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))
diff --git a/mp.c b/mp.c
index b253dba7723c77aa7f9d041b8a053353c9fb1e6e..e0f72d4b32ac732d6dff4624253a6c52af3a040e 100644 (file)
--- a/mp.c
+++ b/mp.c
@@ -527,9 +527,9 @@ static PyObject *mp_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   mp *z;
   mp_pyobj *zz = 0;
   int radix = 0;
-  char *kwlist[] = { "x", "radix", 0 };
+  static const char *const kwlist[] = { "x", "radix", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O|i:new", kwlist, &x, &radix))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O|i:new", KWLIST, &x, &radix))
     goto end;
   if (MP_PYCHECK(x)) RETURN_OBJ(x);
   if (!good_radix_p(radix, 1)) VALERR("bad radix");
@@ -659,8 +659,8 @@ end:
 static PyObject *mpmeth_tostring(PyObject *me, PyObject *arg, PyObject *kw)
 {
   int radix = 10;
-  char *kwlist[] = { "radix", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:tostring", kwlist, &radix))
+  static const char *const kwlist[] = { "radix", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|i:tostring", KWLIST, &radix))
     goto end;
   if (!good_radix_p(radix, 0)) VALERR("bad radix");
   return (mp_topystring(MP_X(me), radix, 0, 0, 0));
@@ -700,11 +700,11 @@ end:
                                 PyObject *arg, PyObject *kw)           \
   {                                                                    \
     long len = -1;                                                     \
-    char *kwlist[] = { "len", 0 };                                     \
+    static const char *const kwlist[] = { "len", 0 };                                  \
     PyObject *rc = 0;                                                  \
                                                                        \
     if (!PyArg_ParseTupleAndKeywords(arg, kw, "|l:" #name,             \
-                                   kwlist, &len))                      \
+                                   KWLIST, &len))                      \
       goto end;                                                                \
     if (len < 0) {                                                     \
       len = mp_octets##c(MP_X(me));                                    \
@@ -763,10 +763,10 @@ static PyObject *mpmeth_tobuf(PyObject *me, PyObject *arg)
 static PyObject *mpmeth_primep(PyObject *me, PyObject *arg, PyObject *kw)
 {
   grand *r = &rand_global;
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&", kwlist, convgrand, &r))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&", KWLIST, convgrand, &r))
     goto end;
   rc = getbool(pgen_primep(MP_X(me), r));
 end:
@@ -930,10 +930,10 @@ static PyObject *meth__MP_fromstring(PyObject *me,
   PyObject *z = 0;
   mp *zz;
   mptext_stringctx sc;
-  char *kwlist[] = { "class", "x", "radix", 0 };
+  static const char *const kwlist[] = { "class", "x", "radix", 0 };
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|i:fromstring",
-                                  kwlist, &me, &p, &len, &r))
+                                  KWLIST, &me, &p, &len, &r))
     goto end;
   if (!good_radix_p(r, 1)) VALERR("bad radix");
   sc.buf = p; sc.lim = p + len;
@@ -1294,10 +1294,10 @@ static void mpmont_pydealloc(PyObject *me)
 static PyObject *mpmont_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mpmont_pyobj *mm = 0;
-  char *kwlist[] = { "m", 0 };
+  static const char *const kwlist[] = { "m", 0 };
   mp *xx = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmp, &xx))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmp, &xx))
     goto end;
   if (!MP_POSP(xx) || !MP_ODDP(xx)) VALERR("m must be positive and odd");
   mm = (mpmont_pyobj *)ty->tp_alloc(ty, 0);
@@ -1448,10 +1448,10 @@ static PyObject *mpbarrett_pynew(PyTypeObject *ty,
                                 PyObject *arg, PyObject *kw)
 {
   mpbarrett_pyobj *mb = 0;
-  char *kwlist[] = { "m", 0 };
+  static const char *const kwlist[] = { "m", 0 };
   mp *xx = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmp, &xx))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmp, &xx))
     goto end;
   if (!MP_POSP(xx)) VALERR("m must be positive");
   mb = (mpbarrett_pyobj *)ty->tp_alloc(ty, 0);
@@ -1578,10 +1578,10 @@ static PyObject *mpreduce_pynew(PyTypeObject *ty,
 {
   mpreduce_pyobj *mr = 0;
   mpreduce r;
-  char *kwlist[] = { "m", 0 };
+  static const char *const kwlist[] = { "m", 0 };
   mp *xx = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmp, &xx))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmp, &xx))
     goto end;
   if (!MP_POSP(xx)) VALERR("m must be positive");
   if (mpreduce_create(&r, xx)) VALERR("bad modulus (must be 2^k - ...)");
@@ -1713,14 +1713,14 @@ static PyObject *mpcrt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mpcrt_mod *v = 0;
   int n, i = 0;
-  char *kwlist[] = { "mv", 0 };
+  static const char *const kwlist[] = { "mv", 0 };
   PyObject *q = 0, *x;
   mp *xx;
   mpcrt_pyobj *c = 0;
 
   if (PyTuple_Size(arg) > 1)
     q = arg;
-  else if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &q))
+  else if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &q))
     goto end;
   Py_INCREF(q);
   if (!PySequence_Check(q)) TYERR("want a sequence of moduli");
@@ -1864,9 +1864,9 @@ static PyObject *gf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   mp *z;
   mp_pyobj *zz = 0;
   int radix = 0;
-  char *kwlist[] = { "x", "radix", 0 };
+  static const char *const kwlist[] = { "x", "radix", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O|i:gf", kwlist, &x, &radix))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O|i:gf", KWLIST, &x, &radix))
     goto end;
   if (GF_PYCHECK(x)) RETURN_OBJ(x);
   if (!good_radix_p(radix, 1)) VALERR("radix out of range");
@@ -2131,10 +2131,10 @@ static PyObject *meth__GF_fromstring(PyObject *me,
   PyObject *z = 0;
   mp *zz;
   mptext_stringctx sc;
-  char *kwlist[] = { "class", "x", "radix", 0 };
+  static const char *const kwlist[] = { "class", "x", "radix", 0 };
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "Os#|i:fromstring",
-                                  kwlist, &me, &p, &len, &r))
+                                  KWLIST, &me, &p, &len, &r))
     goto end;
   if (!good_radix_p(r, 1)) VALERR("bad radix");
   sc.buf = p; sc.lim = p + len;
@@ -2249,10 +2249,10 @@ static PyObject *gfreduce_pynew(PyTypeObject *ty,
 {
   gfreduce_pyobj *mr = 0;
   gfreduce r;
-  char *kwlist[] = { "m", 0 };
+  static const char *const kwlist[] = { "m", 0 };
   mp *xx = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convgf, &xx))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convgf, &xx))
     goto end;
   if (MP_ZEROP(xx)) ZDIVERR("modulus is zero!");
   gfreduce_create(&r, xx);
@@ -2351,9 +2351,9 @@ static PyObject *gfn_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mp *p = 0, *beta = 0;
   gfn_pyobj *gg = 0;
-  char *kwlist[] = { "p", "beta", 0 };
+  static const char *const kwlist[] = { "p", "beta", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
                                   convgf, &p, convgf, &beta))
     goto end;
   gg = PyObject_New(gfn_pyobj, ty);
index fd55bb475fbb501064d6496b141fda143913e9b1..1796629ce8b85eb6fce2d60c5b3a1f193e34d5d7 100644 (file)
@@ -54,11 +54,11 @@ end:
 static PyObject *pixie_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   pixie_pyobj *rc = 0;
-  char *kwlist[] = { "socket", 0 };
+  static const char *const kwlist[] = { "socket", 0 };
   char *sock = 0;
   int fd;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s:new", kwlist, &sock))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|s:new", KWLIST, &sock))
     goto end;
   if ((fd = pixie_open(sock)) < 0)
     OSERR(sock);
@@ -78,12 +78,12 @@ static PyObject *pixmeth_read(PyObject *me, PyObject *arg, PyObject *kw)
 {
   unsigned mode = PMODE_READ;
   char *tag;
-  char *kwlist[] = { "tag", "mode", 0 };
+  static const char *const kwlist[] = { "tag", "mode", 0 };
   PyObject *rc = 0;
   int r;
   char buf[1024];
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:read", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:read", KWLIST,
                                   &tag, convuint, &mode))
     goto end;
   r = pixie_read(PIXIE_FD(me), tag, mode, buf, sizeof(buf));
@@ -182,10 +182,10 @@ static PyObject *meth_ppread(PyObject *me, PyObject *arg, PyObject *kw)
   char *tag;
   unsigned f = PMODE_READ;
   PyObject *rc = 0;
-  char *kwlist[] = { "tag", "mode", 0 };
+  static const char *const kwlist[] = { "tag", "mode", 0 };
   char buf[1024];
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:ppread", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s|O&:ppread", KWLIST,
                                   &tag, convuint, &f))
     goto end;
   if (passphrase_read(tag, f, buf, sizeof(buf)))
diff --git a/pgen.c b/pgen.c
index c1795f792436d836fdce36ad4b27c58f4b50920c..18b0c2688f0385474e17d3cd7eb29d2566babcdb 100644 (file)
--- a/pgen.c
+++ b/pgen.c
@@ -57,10 +57,10 @@ end:
 
 static PyObject *pfilt_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "x", 0 };
+  static const char *const kwlist[] = { "x", 0 };
   PyObject *xobj;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &xobj))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &xobj))
     return (0);
   return (pfilt_pymake(ty, xobj));
 }
@@ -256,9 +256,9 @@ static PyObject *rabin_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mp *x = 0;
   rabin_pyobj *o = 0;
-  char *kwlist[] = { "x", 0 };
+  static const char *const kwlist[] = { "x", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmp, &x))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmp, &x))
     goto end;
   if (!MP_POSP(x) || MP_EVENP(x)) VALERR("must be positive and odd");
   o = (rabin_pyobj *)ty->tp_alloc(ty, 0);
@@ -548,15 +548,15 @@ static int pgev_python(int rq, pgen_event *ev, void *p)
   PyObject *rc = 0;
   int st = PGEN_ABORT;
   long l;
-  char *meth[] = {
-    "pg_abort", "pg_done", "pg_begin", "pg_try", "pg_fail", "pg_pass"
-  };
+  static const char *const meth[] =
+    { "pg_abort", "pg_done", "pg_begin", "pg_try", "pg_fail", "pg_pass" };
 
   Py_INCREF(py);
   rq++;
   if (rq > N(meth)) SYSERR("event code out of range");
   pyev = pgevent_pywrap(ev);
-  if ((rc = PyObject_CallMethod(py, meth[rq], "(O)", pyev)) == 0)
+  if ((rc = PyObject_CallMethod(py, (/*unconst*/ char *)meth[rq],
+                               "(O)", pyev)) == 0)
     goto end;
   if (rc == Py_None)
     st = PGEN_TRY;
@@ -697,9 +697,9 @@ static PyObject *pgstep_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mpw s;
   pgstep_pyobj *rc = 0;
-  char *kwlist[] = { "step", 0 };
+  static const char *const kwlist[] = { "step", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", kwlist, convmpw, &s))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&:new", KWLIST, convmpw, &s))
     goto end;
   rc = (pgstep_pyobj *)ty->tp_alloc(ty, 0);
   rc->f.step = s;
@@ -771,9 +771,9 @@ static PyObject *pgjump_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   PyObject *o, *fobj;
   pgjump_pyobj *rc = 0;
-  char *kwlist[] = { "jump", 0 };
+  static const char *const kwlist[] = { "jump", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", kwlist, &o) ||
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O:new", KWLIST, &o) ||
       (fobj = pfilt_pymake(pfilt_pytype, o)) == 0)
     goto end;
   rc = (pgjump_pyobj *)ty->tp_alloc(ty, 0);
@@ -852,9 +852,9 @@ static PyTypeObject pgjump_pytype_skel = {
 static PyObject *pgtest_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   pgtest_pyobj *rc = 0;
-  char *kwlist[] = { 0 };
+  static const char *const kwlist[] = { 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", kwlist)) goto end;
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST)) goto end;
   rc = (pgtest_pyobj *)ty->tp_alloc(ty, 0);
   rc->pg.proc = pgen_test;
   rc->pg.ctx = &rc->r;
@@ -928,12 +928,12 @@ static PyObject *meth_pgen(PyObject *me, PyObject *arg, PyObject *kw)
   rabin tc;
   pgev step = { 0 }, test = { 0 }, evt = { 0 };
   unsigned nsteps = 0, ntests = 0;
-  char *kwlist[] = { "start", "name", "stepper", "tester", "event",
-                    "nsteps", "ntests", 0 };
+  static const char *const kwlist[] =
+    { "start", "name", "stepper", "tester", "event", "nsteps", "ntests", 0 };
 
   step.proc = pgen_filter; step.ctx = &fc;
   test.proc = pgen_test; test.ctx = &tc;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&O&O&:pgen", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&O&O&:pgen", KWLIST,
                                   convmp, &x, &p, convpgev, &step,
                                   convpgev, &test, convpgev, &evt,
                                   convuint, &nsteps, convuint, &ntests))
@@ -963,9 +963,10 @@ static PyObject *meth_strongprime_setup(PyObject *me,
   unsigned n = 0;
   pgev evt = { 0 };
   PyObject *rc = 0;
-  char *kwlist[] = { "nbits", "name", "event", "rng", "nsteps", 0 };
+  static const char *const kwlist[] =
+    { "nbits", "name", "event", "rng", "nsteps", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", KWLIST,
                                   convuint, &nbits, &name,
                                   convpgev, &evt, convgrand, &r,
                                   convuint, &n))
@@ -990,9 +991,10 @@ static PyObject *meth_strongprime(PyObject *me, PyObject *arg, PyObject *kw)
   unsigned n = 0;
   pgev evt = { 0 };
   PyObject *rc = 0;
-  char *kwlist[] = { "nbits", "name", "event", "rng", "nsteps", 0 };
+  static const char *const kwlist[] =
+    { "nbits", "name", "event", "rng", "nsteps", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|sO&O&O&", KWLIST,
                                   convuint, &nbits, &name,
                                   convpgev, &evt, convgrand, &r,
                                   convuint, &n))
@@ -1017,11 +1019,11 @@ static PyObject *meth_limlee(PyObject *me, PyObject *arg, PyObject *kw)
   unsigned on = 0;
   size_t i, nf = 0;
   PyObject *rc = 0, *vec;
-  char *kwlist[] = { "pbits", "qbits", "name", "event", "ievent",
-                    "rng", "nsteps", 0 };
+  static const char *const kwlist[] =
+    { "pbits", "qbits", "name", "event", "ievent", "rng", "nsteps", 0 };
   mp *x = 0, **v = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|sO&O&O&O&:limlee", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|sO&O&O&O&:limlee", KWLIST,
                                   convuint, &pl, convuint, &ql,
                                   &p, convpgev, &oe, convpgev, &ie,
                                   convgrand, &r, convuint, &on))
index 56b7d9ca41c5df37188f1bb20746bd2de0aed742..6cdfad93c6e48d46c7dca78e1c64eae9e11d8050 100644 (file)
--- a/pubkey.c
+++ b/pubkey.c
@@ -96,9 +96,9 @@ static PyObject *dsapub_pynew(PyTypeObject *ty,
 {
   PyObject *G, *p, *rng = rand_pyobj, *hash = sha_pyobj;
   PyObject *rc = 0;
-  char *kwlist[] = { "G", "p", "hash", "rng", 0 };
+  static const char *const kwlist[] = { "G", "p", "hash", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", KWLIST,
                                   group_pytype, &G,
                                   ge_pytype, &p,
                                   gchash_pytype, &hash,
@@ -135,9 +135,9 @@ static PyObject *dsameth_sign(PyObject *me, PyObject *arg, PyObject *kw)
   Py_ssize_t n;
   mp *k = 0;
   PyObject *rc = 0;
-  char *kwlist[] = { "msg", "k", 0 };
+  static const char *const kwlist[] = { "msg", "k", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", KWLIST,
                                   &p, &n, convmp, &k))
     goto end;
   if (n != DSA_D(me)->h->hashsz)
@@ -175,9 +175,9 @@ static PyObject *dsapriv_pynew(PyTypeObject *ty,
 {
   PyObject *G, *p = 0, *u, *rng = rand_pyobj, *hash = sha_pyobj;
   PyObject *rc = 0;
-  char *kwlist[] = { "G", "u", "p", "hash", "rng", 0 };
+  static const char *const kwlist[] = { "G", "u", "p", "hash", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", KWLIST,
                                   group_pytype, &G,
                                   &u,
                                   ge_pytype, &p,
@@ -323,9 +323,9 @@ static PyObject *kcdsapub_pynew(PyTypeObject *ty,
 {
   PyObject *G, *p, *rng = rand_pyobj, *hash = has160_pyobj;
   PyObject *rc = 0;
-  char *kwlist[] = { "G", "p", "hash", "rng", 0 };
+  static const char *const kwlist[] = { "G", "p", "hash", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O!|O!O!:new", KWLIST,
                                   group_pytype, &G,
                                   ge_pytype, &p,
                                   gchash_pytype, &hash,
@@ -348,9 +348,9 @@ static PyObject *kcdsapriv_pynew(PyTypeObject *ty,
 {
   PyObject *G, *u, *p = 0, *rng = rand_pyobj, *hash = has160_pyobj;
   PyObject *rc = 0;
-  char *kwlist[] = { "G", "u", "p", "hash", "rng", 0 };
+  static const char *const kwlist[] = { "G", "u", "p", "hash", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O!O|O!O!O!:new", KWLIST,
                                   group_pytype, &G,
                                   &u,
                                   ge_pytype, &p,
@@ -389,9 +389,9 @@ static PyObject *kcdsameth_sign(PyObject *me, PyObject *arg, PyObject *kw)
   Py_ssize_t n;
   mp *k = 0;
   PyObject *r = 0, *rc = 0;
-  char *kwlist[] = { "msg", "k", 0 };
+  static const char *const kwlist[] = { "msg", "k", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#|O&:sign", KWLIST,
                                   &p, &n, convmp, &k))
     goto end;
   if (n != DSA_D(me)->h->hashsz)
@@ -569,9 +569,9 @@ static PyObject *rsapub_pynew(PyTypeObject *ty,
 {
   rsa_pub rp = { 0 };
   rsapub_pyobj *o;
-  char *kwlist[] = { "n", "e", 0 };
+  static const char *const kwlist[] = { "n", "e", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
                                   convmp, &rp.n, convmp, &rp.e))
     goto end;
   if (!MP_ODDP(rp.n)) VALERR("RSA modulus must be even");
@@ -636,10 +636,10 @@ static PyObject *rsapriv_pynew(PyTypeObject *ty,
 {
   rsa_priv rp = { 0 };
   PyObject *rng = Py_None;
-  char *kwlist[] =
+  static const char *const kwlist[] =
     { "n", "e", "d", "p", "q", "dp", "dq", "q_inv", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&O&O&O&O&O:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&O&O&O&O&O:new", KWLIST,
                                   convmp, &rp.n, convmp, &rp.e,
                                   convmp, &rp.d,
                                   convmp, &rp.p, convmp, &rp.q,
@@ -711,9 +711,9 @@ static PyObject *rsameth_privop(PyObject *me, PyObject *arg, PyObject *kw)
   PyObject *rng = RSA_RNG(me);
   mp *x = 0;
   PyObject *rc = 0;
-  char *kwlist[] = { "x", "rng", 0 };
+  static const char *const kwlist[] = { "x", "rng", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O:privop", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O:privop", KWLIST,
                                   convmp, &x, &rng))
     goto end;
   if (rng != Py_None && !GRAND_PYCHECK(rng))
@@ -734,10 +734,11 @@ static PyObject *meth__RSAPriv_generate(PyObject *me,
   rsa_priv rp;
   mp *e = 0;
   pgev evt = { 0 };
-  char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "e", 0 };
+  static const char *const kwlist[] =
+    { "class", "nbits", "event", "rng", "nsteps", "e", 0 };
   PyObject *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", KWLIST,
                                   &me, convuint, &nbits, convpgev, &evt,
                                   convgrand, &r, convuint, &n,
                                   convmp, &e))
@@ -898,10 +899,10 @@ static PyObject *meth__p1crypt_encode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x;
-  char *kwlist[] = { "msg", "nbits", "ep", "rng", 0 };
+  static const char *const kwlist[] = { "msg", "nbits", "ep", "rng", 0 };
 
   p1.r = &rand_global; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", KWLIST,
                                   &m, &msz, convulong, &nbits,
                                   &ep, &epsz, convgrand, &p1.r))
     goto end;
@@ -928,10 +929,10 @@ static PyObject *meth__p1crypt_decode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x = 0;
-  char *kwlist[] = { "ct", "nbits", "ep", "rng", 0 };
+  static const char *const kwlist[] = { "ct", "nbits", "ep", "rng", 0 };
 
   p1.r = &rand_global; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|s#O&:decode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|s#O&:decode", KWLIST,
                                   convmp, &x, convulong, &nbits,
                                   &ep, &epsz, convgrand, &p1.r))
     goto end;
@@ -959,10 +960,10 @@ static PyObject *meth__p1sig_encode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x;
-  char *kwlist[] = { "msg", "nbits", "ep", "rng", 0 };
+  static const char *const kwlist[] = { "msg", "nbits", "ep", "rng", 0 };
 
   p1.r = &rand_global; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|s#O&:encode", KWLIST,
                                   &m, &msz, convulong, &nbits,
                                   &ep, &epsz, convgrand, &p1.r))
     goto end;
@@ -990,10 +991,11 @@ static PyObject *meth__p1sig_decode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x = 0;
-  char *kwlist[] = { "msg", "sig", "nbits", "ep", "rng", 0 };
+  static const char *const kwlist[] =
+    { "msg", "sig", "nbits", "ep", "rng", 0 };
 
   p1.r = &rand_global; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|s#O&:decode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&O&|s#O&:decode", KWLIST,
                                   &hukairz, convmp, &x, convulong, &nbits,
                                   &ep, &epsz, convgrand, &p1.r))
     goto end;
@@ -1021,10 +1023,11 @@ static PyObject *meth__oaep_encode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x;
-  char *kwlist[] = { "msg", "nbits", "mgf", "hash", "ep", "rng", 0 };
+  static const char *const kwlist[] =
+    { "msg", "nbits", "mgf", "hash", "ep", "rng", 0 };
 
   o.r = &rand_global; o.cc = &sha_mgf; o.ch = &sha; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&s#O&:encode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&s#O&:encode", KWLIST,
                                   &m, &msz, convulong, &nbits,
                                   convgccipher, &o.cc,
                                   convgchash, &o.ch,
@@ -1054,10 +1057,11 @@ static PyObject *meth__oaep_decode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x = 0;
-  char *kwlist[] = { "ct", "nbits", "mgf", "hash", "ep", "rng", 0 };
+  static const char *const kwlist[] =
+    { "ct", "nbits", "mgf", "hash", "ep", "rng", 0 };
 
   o.r = &rand_global; o.cc = &sha_mgf; o.ch = &sha; ep = 0; epsz = 0;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&s#O&:decode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&s#O&:decode", KWLIST,
                                   convmp, &x, convulong, &nbits,
                                   convgccipher, &o.cc,
                                   convgchash, &o.ch,
@@ -1088,10 +1092,11 @@ static PyObject *meth__pss_encode(PyObject *me,
   octet *b = 0;
   size_t sz;
   mp *x = 0;
-  char *kwlist[] = { "msg", "nbits", "mgf", "hash", "saltsz", "rng", 0 };
+  static const char *const kwlist[] =
+    { "msg", "nbits", "mgf", "hash", "saltsz", "rng", 0 };
 
   p.cc = &sha_mgf; p.ch = &sha; p.r = &rand_global; p.ssz = (size_t)-1;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&O&O&:encode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&|O&O&O&O&:encode", KWLIST,
                                   &m, &msz, convulong, &nbits,
                                   convgccipher, &p.cc,
                                   convgchash, &p.ch,
@@ -1121,11 +1126,11 @@ static PyObject *meth__pss_decode(PyObject *me,
   size_t sz;
   int n;
   mp *x = 0;
-  char *kwlist[] =
+  static const char *const kwlist[] =
     { "msg", "sig", "nbits", "mgf", "hash", "saltsz", "rng", 0 };
 
   p.cc = &sha_mgf; p.ch = &sha; p.r = &rand_global; p.ssz = (size_t)-1;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&O&|O&O&O&O&:decode", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&O&|O&O&O&O&:decode", KWLIST,
                                   &m, &msz, convmp, &x, convulong, &nbits,
                                   convgccipher, &p.cc,
                                   convgchash, &p.ch,
@@ -1201,10 +1206,11 @@ XDHS(DEFXDH)
     int ph = phdflt;                                                   \
     PyObject *rc = 0;                                                  \
     octet pp[ED##_PUBSZ];                                              \
-    char *kwlist[] = { "key", "msg", "pub", "perso", "phflag", 0 };    \
+    static const char *const kwlist[] =                                        \
+      { "key", "msg", "pub", "perso", "phflag", 0 };                   \
     if (!PyArg_ParseTupleAndKeywords(arg, kw,                          \
                                     "s#s#|s#s#O&:" #ed "_sign",        \
-                                    kwlist,                            \
+                                    KWLIST,                            \
                                     &k, &ksz, &m, &msz, &p, &psz,      \
                                     &c, &csz, convbool, &ph))          \
       goto end;                                                                \
@@ -1228,10 +1234,11 @@ XDHS(DEFXDH)
     Py_ssize_t psz, csz = 0, msz, ssz;                                 \
     int ph = phdflt;                                                   \
     PyObject *rc = 0;                                                  \
-    char *kwlist[] = { "pub", "msg", "sig", "perso", "phflag", 0 };    \
+    static const char *const kwlist[] =                                        \
+      { "pub", "msg", "sig", "perso", "phflag", 0 };                   \
     if (!PyArg_ParseTupleAndKeywords(arg, kw,                          \
                                     "s#s#s#|s#O&:" #ed "_verify",      \
-                                    kwlist,                            \
+                                    KWLIST,                            \
                                     &p, &psz, &m, &msz, &s, &ssz,      \
                                     &c, &csz, convbool, &ph))          \
       goto end;                                                                \
diff --git a/rand.c b/rand.c
index e2082375a2a39f2bf41ff9700ddba1ec6591c48c..9afb271c86b26e17bf02e0ff5c6b01d4cf4419c8 100644 (file)
--- a/rand.c
+++ b/rand.c
@@ -124,9 +124,9 @@ static PyObject *grmeth_mp(PyObject *me, PyObject *arg, PyObject *kw)
 {
   size_t l;
   mpw o = 0;
-  char *kwlist[] = { "bits", "or", 0 };
+  static const char *const kwlist[] = { "bits", "or", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:mp", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:mp", KWLIST,
                                   convszt, &l, convmpw, &o))
     goto end;
   if (grand_check(me)) return (0);
@@ -214,10 +214,10 @@ end:
 
 static PyObject *grmeth_seedrand(PyObject *me, PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { "rng", 0 };
+  static const char *const kwlist[] = { "rng", 0 };
   grand *r = GRAND_R(me);
   grand *rr = &rand_global;
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:seedrand", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:seedrand", KWLIST,
                                   convgrand, &rr) ||
       grand_check(me) || checkop(r, GRAND_SEEDRAND, "seedrand"))
     goto end;
@@ -332,8 +332,8 @@ static PyTypeObject grand_pytype_skel = {
 static PyObject *lcrand_pynew(PyTypeObject *me, PyObject *arg, PyObject *kw)
 {
   uint32 n = 0;
-  char *kwlist[] = { "seed", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", kwlist, convu32, &n))
+  static const char *const kwlist[] = { "seed", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", KWLIST, convu32, &n))
     return (0);
   return (grand_dopywrap(lcrand_pytype, lcrand_create(n), f_freeme));
 }
@@ -389,8 +389,8 @@ static PyTypeObject lcrand_pytype_skel = {
 static PyObject *fibrand_pynew(PyTypeObject *me, PyObject *arg, PyObject *kw)
 {
   uint32 n = 0;
-  char *kwlist[] = { "seed", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", kwlist, convu32, &n))
+  static const char *const kwlist[] = { "seed", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:new", KWLIST, convu32, &n))
     return (0);
   return (grand_dopywrap(fibrand_pytype, fibrand_create(n), f_freeme));
 }
@@ -503,10 +503,10 @@ static PyObject *trmeth_timer(PyObject *me, PyObject *arg)
 static PyObject *truerand_pynew(PyTypeObject *ty,
                                PyObject *arg, PyObject *kw)
 {
-  char *kwlist[] = { 0 };
+  static const char *const kwlist[] = { 0 };
   grand *r;
   PyObject *rc = 0;
-  if (PyArg_ParseTupleAndKeywords(arg, kw, ":new", kwlist)) goto end;
+  if (PyArg_ParseTupleAndKeywords(arg, kw, ":new", KWLIST)) goto end;
   r = rand_create();
   r->ops->misc(r, RAND_NOISESRC, &noise_source);
   r->ops->misc(r, RAND_SEED, 160);
@@ -639,11 +639,11 @@ static const gccrand_info *const gcrandtab[] = {
 static PyObject *gcrand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   const gccrand_info *info = GCCRAND_INFO(ty);
-  static char *kwlist[] = { "key", 0 };
+  static const char *const kwlist[] = { "key", 0 };
   char *k;
   Py_ssize_t n;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &k, &n))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &k, &n))
     goto end;
   if (keysz(n, info->keysz) != n) VALERR("bad key length");
   return (grand_dopywrap(ty, info->func(k, n), f_freeme));
@@ -655,11 +655,11 @@ static PyObject *gcirand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   const gccrand_info *info = GCCRAND_INFO(ty);
   uint32 i = 0;
-  static char *kwlist[] = { "key", "i", 0 };
+  static const char *const kwlist[] = { "key", "i", 0 };
   char *k;
   Py_ssize_t n;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#O&:new", KWLIST,
                                   &k, &n, convu32, &i))
     goto end;
   if (keysz(n, info->keysz) != n) VALERR("bad key length");
@@ -673,11 +673,11 @@ end:
 static PyObject *gcnrand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   const gccrand_info *info = GCCRAND_INFO(ty);
-  static char *kwlist[] = { "key", "nonce", 0 };
+  static const char *const kwlist[] = { "key", "nonce", 0 };
   char *k, *n;
   Py_ssize_t ksz, nsz;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#:new", KWLIST,
                                   &k, &ksz, &n, &nsz))
     goto end;
   if (keysz(ksz, info->keysz) != ksz) VALERR("bad key length");
@@ -693,15 +693,18 @@ static PyObject *gcshakyrand_pynew(PyTypeObject *ty,
                                   PyObject *arg, PyObject *kw)
 {
   const gccrand_info *info = GCCRAND_INFO(ty);
-  static char *kwlist_shake[] = { "key", "func", "perso", 0 };
-  static char *kwlist_func[] = { "key", "perso", 0 };
+  static const char
+    *const kwlist_shake[] = { "key", "func", "perso", 0 },
+    *const kwlist_func[] = { "key", "perso", 0 };
   char *k, *f = 0, *p = 0;
   Py_ssize_t ksz, fsz = 0, psz = 0;
 
   if ((info->f&RNGF_MASK) == RNG_SHAKE
-       ? !PyArg_ParseTupleAndKeywords(arg, kw, "s#|s#s#:new", kwlist_shake,
+       ? !PyArg_ParseTupleAndKeywords(arg, kw, "s#|s#s#:new",
+                                      (/*unconst*/ char **)kwlist_shake,
                                       &k, &ksz, &f, &fsz, &p, &psz)
-       : !PyArg_ParseTupleAndKeywords(arg, kw, "s#|s#:new", kwlist_func,
+       : !PyArg_ParseTupleAndKeywords(arg, kw, "s#|s#:new",
+                                      (/*unconst*/ char **)kwlist_func,
                                       &k, &ksz, &p, &psz))
     goto end;
   if (keysz(ksz, info->keysz) != ksz) VALERR("bad key length");
@@ -938,9 +941,9 @@ static PyObject *sslprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   int ksz, ssz;
   const gchash *hco = &md5, *hci = &sha;
   PyObject *rc = 0;
-  char *kwlist[] = { "key", "seed", "ohash", "ihash", 0 };
+  static const char *const kwlist[] = { "key", "seed", "ohash", "ihash", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&O&:new", KWLIST,
                                   &k, &ksz, &s, &ssz,
                                   convgchash, &hco, convgchash, &hci))
     goto end;
@@ -955,9 +958,9 @@ static PyObject *tlsdx_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   int ksz, ssz;
   const gcmac *mc = &sha_hmac;
   PyObject *rc = 0;
-  char *kwlist[] = { "key", "seed", "mac", 0 };
+  static const char *const kwlist[] = { "key", "seed", "mac", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&:new", KWLIST,
                                   &k, &ksz, &s, &ssz,
                                   convgcmac, &mc))
     goto end;
@@ -972,9 +975,9 @@ static PyObject *tlsprf_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   int ksz, ssz;
   const gcmac *mcl = &md5_hmac, *mcr = &sha_hmac;
   PyObject *rc = 0;
-  char *kwlist[] = { "key", "seed", "lmac", "rmac", 0 };
+  static const char *const kwlist[] = { "key", "seed", "lmac", "rmac", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#s#|O&O&:new", KWLIST,
                                   &k, &ksz, &s, &ssz,
                                   convgcmac, &mcl, convgcmac, &mcr))
     goto end;
@@ -1137,9 +1140,9 @@ static PyObject *dsarand_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
   char *p;
   int sz;
   PyObject *rc = 0;
-  char *kwlist[] = { "seed", 0 };
+  static const char *const kwlist[] = { "seed", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", kwlist, &p, &sz))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "s#:new", KWLIST, &p, &sz))
     goto end;
   rc = grand_dopywrap(ty, dsarand_create(p, sz), f_freeme);
 end:
@@ -1216,9 +1219,9 @@ static PyObject *bbs_pynew(PyTypeObject *ty, PyObject *arg, PyObject *kw)
 {
   mp *n = 0, *x = MP_TWO;
   PyObject *rc = 0;
-  char *kwlist[] = { "n", "x", 0 };
+  static const char *const kwlist[] = { "n", "x", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&|O&:new", KWLIST,
                                   convmp, &n, convmp, &x))
     goto end;
   rc = grand_dopywrap(ty, bbs_rand(n, x), f_freeme);
@@ -1354,9 +1357,9 @@ static PyObject *bbspriv_pynew(PyTypeObject *ty,
 {
   mp *p = 0, *q = 0, *n = 0, *x = MP_TWO;
   bbspriv_pyobj *rc = 0;
-  char *kwlist[] = { "n", "p", "q", "seed", 0 };
+  static const char *const kwlist[] = { "n", "p", "q", "seed", 0 };
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&:new", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&O&O&O&:new", KWLIST,
                                   convmp, &n, convmp, &p, convmp, &q,
                                   convmp, &x))
     goto end;
@@ -1383,10 +1386,11 @@ static PyObject *meth__BBSPriv_generate(PyObject *me,
   pgev evt = { 0 };
   unsigned nbits, n = 0;
   grand *r = &rand_global;
-  char *kwlist[] = { "class", "nbits", "event", "rng", "nsteps", "seed", 0 };
+  static const char *const kwlist[] =
+    { "class", "nbits", "event", "rng", "nsteps", "seed", 0 };
   bbspriv_pyobj *rc = 0;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", kwlist,
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO&|O&O&O&O&:generate", KWLIST,
                                   &me, convuint, &nbits, convpgev, &evt,
                                   convgrand, &r, convuint, &n, convmp, &x))
     goto end;
diff --git a/share.c b/share.c
index 3d4817e5dac98b7cb8be79e2beb4c2c86d68ae70..77da423571f8a8b7378a64bf10e3b705cc21326e 100644 (file)
--- a/share.c
+++ b/share.c
@@ -117,8 +117,8 @@ static PyObject *gfsharesplit_pynew(PyTypeObject *ty,
   unsigned t;
   grand *r = &rand_global;
   gfshare_pyobj *s;
-  char *kwlist[] = { "threshold", "secret", "rng", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", kwlist,
+  static const char *const kwlist[] = { "threshold", "secret", "rng", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&s#|O&:new", KWLIST,
                                   convuint, &t, &p, &n, convgrand, &r))
     goto end;
   if (!t || t > 255) VALERR("threshold must be nonzero and < 256");
@@ -203,8 +203,8 @@ static PyObject *gfsharejoin_pynew(PyTypeObject *ty,
 {
   unsigned t, sz;
   gfshare_pyobj *s;
-  char *kwlist[] = { "threshold", "size", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+  static const char *const kwlist[] = { "threshold", "size", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
                                   convuint, &t, convuint, &sz))
     goto end;
   if (!t || t > 255) VALERR("threshold must be nonzero and < 256");
@@ -409,8 +409,10 @@ static PyObject *sharesplit_pynew(PyTypeObject *ty,
   grand *r = &rand_global;
   mp *m = 0;
   share_pyobj *s;
-  char *kwlist[] = { "threshold", "secret", "modulus", "rng", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", kwlist,
+  static const char *const kwlist[] =
+    { "threshold", "secret", "modulus", "rng", 0 };
+
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&|O&O&:new", KWLIST,
                                   convuint, &t, convmp, &sec,
                                   convmp, &m, convgrand, &r))
     goto end;
@@ -499,8 +501,8 @@ static PyObject *sharejoin_pynew(PyTypeObject *ty,
   unsigned t;
   mp *m = 0;
   share_pyobj *s;
-  char *kwlist[] = { "threshold", "modulus", 0 };
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", kwlist,
+  static const char *const kwlist[] = { "threshold", "modulus", 0 };
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "O&O&:new", KWLIST,
                                   convuint, &t, convmp, &m))
     goto end;
   if (!t) VALERR("threshold must be nonzero");
diff --git a/util.c b/util.c
index 7118bfb7b59f64d3408bc4a533a2c7170600f1ff..2e6ee258db18d622c549bd209bf95d9fc2143ebc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -603,13 +603,15 @@ end:
   return (rc);
 }
 
-static char *def_kwlist[] = { "key", "default", 0 };
+static const char *const def_kwlist[] = { "key", "default", 0 };
 
 PyObject *gmapmeth_get(PyObject *me, PyObject *arg, PyObject *kw)
 {
   PyObject *k, *def = Py_None, *v;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:get", def_kwlist, &k, &def))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:get",
+                                  (/*unconst*/ char **)def_kwlist,
+                                  &k, &def))
     return (0);
   if ((v = PyObject_GetItem(me, k)) != 0) return (v);
   PyErr_Clear();
@@ -621,7 +623,8 @@ PyObject *gmapmeth_setdefault(PyObject *me, PyObject *arg, PyObject *kw)
   PyObject *k, *def = Py_None, *v;
 
   if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:setdefault",
-                                  def_kwlist, &k, &def))
+                                  (/*unconst*/ char **)def_kwlist,
+                                  &k, &def))
     return (0);
   if ((v = PyObject_GetItem(me, k)) != 0) return (v);
   PyErr_Clear();
@@ -633,7 +636,9 @@ PyObject *gmapmeth_pop(PyObject *me, PyObject *arg, PyObject *kw)
 {
   PyObject *k, *def = 0, *v;
 
-  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:pop", def_kwlist, &k, &def))
+  if (!PyArg_ParseTupleAndKeywords(arg, kw, "OO:pop",
+                                  (/*unconst*/ char **)def_kwlist,
+                                  &k, &def))
     return (0);
   if ((v = PyObject_GetItem(me, k)) != 0) {
     PyObject_DelItem(me, k);