From: Mark Wooding Date: Sat, 29 Jul 2017 00:10:52 +0000 (+0100) Subject: algorithms.c: Reformat some of the `keysz' code. X-Git-Tag: 1.3.0~28 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/catacomb-python/commitdiff_plain/838ab173c38713fbf8aebde9417ff6b78275b579 algorithms.c: Reformat some of the `keysz' code. Nothing major. Remove the separate check that max >= 0 since it's implied by 0 <= min <= dfl <= max. --- diff --git a/algorithms.c b/algorithms.c index 0f05f75..e55456e 100644 --- a/algorithms.c +++ b/algorithms.c @@ -107,11 +107,9 @@ static PyObject *keyszrange_pynew(PyTypeObject *ty, if (!PyArg_ParseTupleAndKeywords(arg, kw, "i|iii:new", kwlist, &dfl, &min, &max, &mod)) goto end; - if (dfl < 0 || min < 0 || max < 0) - VALERR("key size cannot be negative"); - if (min > dfl || (max && dfl > max)) - VALERR("bad key size bounds"); - if (mod <= 0 || dfl % mod || min % mod || max % mod) + if (dfl < 0 || min < 0) VALERR("key size cannot be negative"); + if (min > dfl || (max && dfl > max)) VALERR("bad key size bounds"); + if (mod <= 0 || dfl%mod || min%mod || max%mod) VALERR("bad key size modulus"); o = (keyszrange_pyobj *)ty->tp_alloc(ty, 0); o->dfl = dfl; @@ -132,8 +130,7 @@ static PyObject *keyszset_pynew(PyTypeObject *ty, 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);