diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2018-12-28 03:33:53 +0100 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2019-01-21 02:00:04 +0000 |
commit | 2a05aa2c4327e4bcdcc9da9c903fe7e0534ee308 (patch) | |
tree | 5feb26b50afc4026dd8e04bb00b3c788fb86da22 | |
parent | 43d779966b5eeb5db210d58e07d787fae89bcc4f (diff) | |
download | psycopg2-2a05aa2c4327e4bcdcc9da9c903fe7e0534ee308.tar.gz |
Move var setting into the only case using it
The original function was more complex than this. This refactoring
avoids a false positive in the static checker
-rw-r--r-- | psycopg/bytes_format.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/psycopg/bytes_format.c b/psycopg/bytes_format.c index cd06b1c..767aafa 100644 --- a/psycopg/bytes_format.c +++ b/psycopg/bytes_format.c @@ -207,11 +207,6 @@ Bytes_Format(PyObject *format, PyObject *args) "incomplete format"); goto error; } - if (c != '%') { - v = getnextarg(args, arglen, &argidx); - if (v == NULL) - goto error; - } switch (c) { case '%': pbuf = "%"; @@ -219,6 +214,8 @@ Bytes_Format(PyObject *format, PyObject *args) break; case 's': /* only bytes! */ + if (!(v = getnextarg(args, arglen, &argidx))) + goto error; if (!Bytes_CheckExact(v)) { PyErr_Format(PyExc_ValueError, "only bytes values expected, got %s", |