From e1266d52cd9fb48585fb7eb152389b314c1610a8 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Thu, 1 Mar 2012 02:45:48 +0000 Subject: More functions annotated for static analysis Also more return values checked for values < 0 for errors, instead of checking == 0 and leaving the positive side unchecked --- psycopg/pqpath.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'psycopg/pqpath.c') diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 899c331..e8b8dc6 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -304,19 +304,16 @@ pq_clear_async(connectionObject *conn) Accepted arg values are 1 (nonblocking) and 0 (blocking). - Return 0 if everything ok, else nonzero. - - In case of error, if pyerr is nonzero, set a Python exception. + Return 0 if everything ok, else < 0 and set an exception. */ -int -pq_set_non_blocking(connectionObject *conn, int arg, int pyerr) +RAISES_NEG int +pq_set_non_blocking(connectionObject *conn, int arg) { int ret = PQsetnonblocking(conn->pgconn, arg); if (0 != ret) { Dprintf("PQsetnonblocking(%d) FAILED", arg); - if (pyerr) { - PyErr_SetString(OperationalError, "PQsetnonblocking() failed"); - } + PyErr_SetString(OperationalError, "PQsetnonblocking() failed"); + ret = -1; } return ret; } -- cgit v1.2.1