diff options
author | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-01 02:45:48 +0000 |
---|---|---|
committer | Daniele Varrazzo <daniele.varrazzo@gmail.com> | 2012-03-01 02:53:28 +0000 |
commit | e1266d52cd9fb48585fb7eb152389b314c1610a8 (patch) | |
tree | dd4f119660f3783112d32e1c009a268e4c7d6ab1 /psycopg/connection_int.c | |
parent | 5bfb6cdefed3754b2a15e1e3372630691392ca47 (diff) | |
download | psycopg2-e1266d52cd9fb48585fb7eb152389b314c1610a8.tar.gz |
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
Diffstat (limited to 'psycopg/connection_int.c')
-rw-r--r-- | psycopg/connection_int.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/psycopg/connection_int.c b/psycopg/connection_int.c index 4d1ffb9..abc61e8 100644 --- a/psycopg/connection_int.c +++ b/psycopg/connection_int.c @@ -332,7 +332,7 @@ exit: * * Return 0 on success, else nonzero. */ -static int +RAISES_NEG static int conn_read_encoding(connectionObject *self, PGconn *pgconn) { char *enc = NULL, *codec = NULL; @@ -468,7 +468,7 @@ conn_is_datestyle_ok(PGconn *pgconn) /* conn_setup - setup and read basic information about the connection */ -int +RAISES_NEG int conn_setup(connectionObject *self, PGconn *pgconn) { PGresult *pgres = NULL; @@ -482,7 +482,7 @@ conn_setup(connectionObject *self, PGconn *pgconn) return -1; } - if (conn_read_encoding(self, pgconn)) { + if (0 > conn_read_encoding(self, pgconn)) { return -1; } @@ -496,7 +496,7 @@ conn_setup(connectionObject *self, PGconn *pgconn) pthread_mutex_lock(&self->lock); Py_BLOCK_THREADS; - if (psyco_green() && (pq_set_non_blocking(self, 1, 1) != 0)) { + if (psyco_green() && (0 > pq_set_non_blocking(self, 1))) { return -1; } @@ -774,7 +774,7 @@ _conn_poll_setup_async(connectionObject *self) switch (self->status) { case CONN_STATUS_CONNECTING: /* Set the connection to nonblocking now. */ - if (pq_set_non_blocking(self, 1, 1) != 0) { + if (pq_set_non_blocking(self, 1) != 0) { break; } @@ -785,7 +785,7 @@ _conn_poll_setup_async(connectionObject *self) PyErr_SetString(InterfaceError, "only protocol 3 supported"); break; } - if (conn_read_encoding(self, self->pgconn)) { + if (0 > conn_read_encoding(self, self->pgconn)) { break; } self->cancel = conn_get_cancel(self->pgconn); @@ -971,7 +971,7 @@ conn_rollback(connectionObject *self) return res; } -int +RAISES_NEG int conn_set_session(connectionObject *self, const char *isolevel, const char *readonly, const char *deferrable, int autocommit) |