Use more compact macros to annotate functions for the static checker

This commit is contained in:
Daniele Varrazzo 2012-03-01 00:57:52 +00:00
parent f2e4a8ed78
commit 5bfb6cdefe
13 changed files with 54 additions and 100 deletions

View File

@ -86,8 +86,7 @@
/* Helpers for formatstring */ /* Helpers for formatstring */
CPYCHECKER_RETURNS_BORROWED_REF BORROWED Py_LOCAL_INLINE(PyObject *)
Py_LOCAL_INLINE(PyObject *)
getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx) getnextarg(PyObject *args, Py_ssize_t arglen, Py_ssize_t *p_argidx)
{ {
Py_ssize_t argidx = *p_argidx; Py_ssize_t argidx = *p_argidx;

View File

@ -162,31 +162,31 @@ static double round(double num)
/* decorators for the gcc cpychecker plugin */ /* decorators for the gcc cpychecker plugin */
#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE) #if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)
#define CPYCHECKER_RETURNS_BORROWED_REF \ #define BORROWED \
__attribute__((cpychecker_returns_borrowed_ref)) __attribute__((cpychecker_returns_borrowed_ref))
#else #else
#define CPYCHECKER_RETURNS_BORROWED_REF #define BORROWED
#endif #endif
#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE) #if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)
#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \ #define STEALS(n) \
__attribute__((cpychecker_steals_reference_to_arg(n))) __attribute__((cpychecker_steals_reference_to_arg(n)))
#else #else
#define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) #define STEALS(n)
#endif #endif
#if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE) #if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE)
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION \ #define RAISES_NEG \
__attribute__((cpychecker_negative_result_sets_exception)) __attribute__((cpychecker_negative_result_sets_exception))
#else #else
#define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION #define RAISES_NEG
#endif #endif
#if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE) #if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE)
#define CPYCHECKER_SETS_EXCEPTION \ #define RAISES \
__attribute__((cpychecker_sets_exception)) __attribute__((cpychecker_sets_exception))
#else #else
#define CPYCHECKER_SETS_EXCEPTION #define RAISES
#endif #endif
#endif /* !defined(PSYCOPG_CONFIG_H) */ #endif /* !defined(PSYCOPG_CONFIG_H) */

View File

@ -131,8 +131,7 @@ typedef struct {
/* C-callable functions in connection_int.c and connection_ext.c */ /* C-callable functions in connection_int.c and connection_ext.c */
HIDDEN PyObject *conn_text_from_chars(connectionObject *pgconn, const char *str); HIDDEN PyObject *conn_text_from_chars(connectionObject *pgconn, const char *str);
HIDDEN int conn_get_standard_conforming_strings(PGconn *pgconn); HIDDEN int conn_get_standard_conforming_strings(PGconn *pgconn);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int conn_get_isolation_level(connectionObject *self);
HIDDEN int conn_get_isolation_level(connectionObject *self);
HIDDEN int conn_get_protocol_version(PGconn *pgconn); HIDDEN int conn_get_protocol_version(PGconn *pgconn);
HIDDEN int conn_get_server_version(PGconn *pgconn); HIDDEN int conn_get_server_version(PGconn *pgconn);
HIDDEN PGcancel *conn_get_cancel(PGconn *pgconn); HIDDEN PGcancel *conn_get_cancel(PGconn *pgconn);
@ -142,23 +141,17 @@ HIDDEN void conn_notifies_process(connectionObject *self);
HIDDEN int conn_setup(connectionObject *self, PGconn *pgconn); HIDDEN int conn_setup(connectionObject *self, PGconn *pgconn);
HIDDEN int conn_connect(connectionObject *self, long int async); HIDDEN int conn_connect(connectionObject *self, long int async);
HIDDEN void conn_close(connectionObject *self); HIDDEN void conn_close(connectionObject *self);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int conn_commit(connectionObject *self);
HIDDEN int conn_commit(connectionObject *self); RAISES_NEG HIDDEN int conn_rollback(connectionObject *self);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
HIDDEN int conn_rollback(connectionObject *self);
HIDDEN int conn_set_session(connectionObject *self, const char *isolevel, HIDDEN int conn_set_session(connectionObject *self, const char *isolevel,
const char *readonly, const char *deferrable, const char *readonly, const char *deferrable,
int autocommit); int autocommit);
HIDDEN int conn_set_autocommit(connectionObject *self, int value); HIDDEN int conn_set_autocommit(connectionObject *self, int value);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int conn_switch_isolation_level(connectionObject *self, int level);
HIDDEN int conn_switch_isolation_level(connectionObject *self, int level); RAISES_NEG HIDDEN int conn_set_client_encoding(connectionObject *self, const char *enc);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
HIDDEN int conn_set_client_encoding(connectionObject *self, const char *enc);
HIDDEN int conn_poll(connectionObject *self); HIDDEN int conn_poll(connectionObject *self);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int conn_tpc_begin(connectionObject *self, XidObject *xid);
HIDDEN int conn_tpc_begin(connectionObject *self, XidObject *xid); RAISES_NEG HIDDEN int conn_tpc_command(connectionObject *self,
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
HIDDEN int conn_tpc_command(connectionObject *self,
const char *cmd, XidObject *xid); const char *cmd, XidObject *xid);
HIDDEN PyObject *conn_tpc_recover(connectionObject *self); HIDDEN PyObject *conn_tpc_recover(connectionObject *self);

View File

@ -253,8 +253,7 @@ conn_get_standard_conforming_strings(PGconn *pgconn)
* Return a buffer allocated on Python heap into 'clean' and return 0 on * Return a buffer allocated on Python heap into 'clean' and return 0 on
* success, otherwise return -1 and set an exception. * success, otherwise return -1 and set an exception.
*/ */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
clear_encoding_name(const char *enc, char **clean) clear_encoding_name(const char *enc, char **clean)
{ {
const char *i = enc; const char *i = enc;
@ -292,8 +291,7 @@ exit:
* *
* 'enc' should be already normalized (uppercase, no - or _). * 'enc' should be already normalized (uppercase, no - or _).
*/ */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
conn_encoding_to_codec(const char *enc, char **codec) conn_encoding_to_codec(const char *enc, char **codec)
{ {
char *tmp; char *tmp;
@ -376,8 +374,7 @@ exit:
} }
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_get_isolation_level(connectionObject *self) conn_get_isolation_level(connectionObject *self)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;
@ -954,8 +951,7 @@ conn_close(connectionObject *self)
/* conn_commit - commit on a connection */ /* conn_commit - commit on a connection */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_commit(connectionObject *self) conn_commit(connectionObject *self)
{ {
int res; int res;
@ -966,8 +962,7 @@ conn_commit(connectionObject *self)
/* conn_rollback - rollback a connection */ /* conn_rollback - rollback a connection */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_rollback(connectionObject *self) conn_rollback(connectionObject *self)
{ {
int res; int res;
@ -1049,8 +1044,7 @@ conn_set_autocommit(connectionObject *self, int value)
/* conn_switch_isolation_level - switch isolation level on the connection */ /* conn_switch_isolation_level - switch isolation level on the connection */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_switch_isolation_level(connectionObject *self, int level) conn_switch_isolation_level(connectionObject *self, int level)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;
@ -1132,8 +1126,7 @@ endlock:
/* conn_set_client_encoding - switch client encoding on connection */ /* conn_set_client_encoding - switch client encoding on connection */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_set_client_encoding(connectionObject *self, const char *enc) conn_set_client_encoding(connectionObject *self, const char *enc)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;
@ -1206,8 +1199,7 @@ exit:
* in regular transactions, as PostgreSQL won't even know we are in a TPC * in regular transactions, as PostgreSQL won't even know we are in a TPC
* until PREPARE. */ * until PREPARE. */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_tpc_begin(connectionObject *self, XidObject *xid) conn_tpc_begin(connectionObject *self, XidObject *xid)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;
@ -1241,8 +1233,7 @@ conn_tpc_begin(connectionObject *self, XidObject *xid)
* The function doesn't change the connection state as it can be used * The function doesn't change the connection state as it can be used
* for many commands and for recovered transactions. */ * for many commands and for recovered transactions. */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid) conn_tpc_command(connectionObject *self, const char *cmd, XidObject *xid)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;

View File

@ -550,8 +550,7 @@ psyco_conn_autocommit_get(connectionObject *self)
return ret; return ret;
} }
CPYCHECKER_RETURNS_BORROWED_REF BORROWED static PyObject *
static PyObject *
_psyco_conn_autocommit_set_checks(connectionObject *self) _psyco_conn_autocommit_set_checks(connectionObject *self)
{ {
/* wrapper to use the EXC_IF macros. /* wrapper to use the EXC_IF macros.

View File

@ -85,8 +85,7 @@ struct cursorObject {
/* C-callable functions in cursor_int.c and cursor_ext.c */ /* C-callable functions in cursor_int.c and cursor_ext.c */
CPYCHECKER_RETURNS_BORROWED_REF BORROWED HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid);
HIDDEN PyObject *curs_get_cast(cursorObject *self, PyObject *oid);
HIDDEN void curs_reset(cursorObject *self); HIDDEN void curs_reset(cursorObject *self);
/* exception-raising macros */ /* exception-raising macros */

View File

@ -38,8 +38,7 @@
* Return a borrowed reference. * Return a borrowed reference.
*/ */
CPYCHECKER_RETURNS_BORROWED_REF BORROWED PyObject *
PyObject *
curs_get_cast(cursorObject *self, PyObject *oid) curs_get_cast(cursorObject *self, PyObject *oid)
{ {
PyObject *cast; PyObject *cast;

View File

@ -75,8 +75,7 @@ psyco_curs_close(cursorObject *self, PyObject *args)
/* mogrify a query string and build argument array or dict */ /* mogrify a query string and build argument array or dict */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
_mogrify(PyObject *var, PyObject *fmt, cursorObject *curs, PyObject **new) _mogrify(PyObject *var, PyObject *fmt, cursorObject *curs, PyObject **new)
{ {
PyObject *key, *value, *n; PyObject *key, *value, *n;
@ -360,8 +359,7 @@ _psyco_curs_merge_query_args(cursorObject *self,
#define psyco_curs_execute_doc \ #define psyco_curs_execute_doc \
"execute(query, vars=None) -- Execute query with bound vars." "execute(query, vars=None) -- Execute query with bound vars."
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
_psyco_curs_execute(cursorObject *self, _psyco_curs_execute(cursorObject *self,
PyObject *operation, PyObject *vars, long int async) PyObject *operation, PyObject *vars, long int async)
{ {
@ -645,8 +643,7 @@ psyco_curs_cast(cursorObject *self, PyObject *args)
"default) or using the sequence factory previously set in the\n" \ "default) or using the sequence factory previously set in the\n" \
"`row_factory` attribute. Return `!None` when no more data is available.\n" "`row_factory` attribute. Return `!None` when no more data is available.\n"
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
_psyco_curs_prefetch(cursorObject *self) _psyco_curs_prefetch(cursorObject *self)
{ {
int i = 0; int i = 0;
@ -663,8 +660,7 @@ _psyco_curs_prefetch(cursorObject *self)
return i; return i;
} }
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
_psyco_curs_buildrow_fill(cursorObject *self, PyObject *res, _psyco_curs_buildrow_fill(cursorObject *self, PyObject *res,
int row, int n, int istuple) int row, int n, int istuple)
{ {

View File

@ -64,8 +64,7 @@ strip_severity(const char *msg)
code. A list of error codes can be found at: code. A list of error codes can be found at:
http://www.postgresql.org/docs/current/static/errcodes-appendix.html */ http://www.postgresql.org/docs/current/static/errcodes-appendix.html */
CPYCHECKER_RETURNS_BORROWED_REF BORROWED static PyObject *
static PyObject *
exception_from_sqlstate(const char *sqlstate) exception_from_sqlstate(const char *sqlstate)
{ {
switch (sqlstate[0]) { switch (sqlstate[0]) {
@ -152,8 +151,7 @@ exception_from_sqlstate(const char *sqlstate)
This function should be called while holding the GIL. */ This function should be called while holding the GIL. */
CPYCHECKER_SETS_EXCEPTION RAISES static void
static void
pq_raise(connectionObject *conn, cursorObject *curs, PGresult *pgres) pq_raise(connectionObject *conn, cursorObject *curs, PGresult *pgres)
{ {
PyObject *exc = NULL; PyObject *exc = NULL;
@ -253,8 +251,7 @@ pq_clear_critical(connectionObject *conn)
/* return -1 if the exception is set (i.e. if conn->critical is set), /* return -1 if the exception is set (i.e. if conn->critical is set),
* else 0 */ * else 0 */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
pq_resolve_critical(connectionObject *conn, int close) pq_resolve_critical(connectionObject *conn, int close)
{ {
Dprintf("pq_resolve_critical: resolving %s", conn->critical); Dprintf("pq_resolve_critical: resolving %s", conn->critical);
@ -389,8 +386,7 @@ cleanup:
This function should be called while holding the global interpreter This function should be called while holding the global interpreter
lock. lock.
*/ */
CPYCHECKER_SETS_EXCEPTION RAISES void
void
pq_complete_error(connectionObject *conn, PGresult **pgres, char **error) pq_complete_error(connectionObject *conn, PGresult **pgres, char **error)
{ {
Dprintf("pq_complete_error: pgconn = %p, pgres = %p, error = %s", Dprintf("pq_complete_error: pgconn = %p, pgres = %p, error = %s",
@ -483,8 +479,7 @@ pq_commit(connectionObject *conn)
return retvalue; return retvalue;
} }
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
pq_abort_locked(connectionObject *conn, PGresult **pgres, char **error, pq_abort_locked(connectionObject *conn, PGresult **pgres, char **error,
PyThreadState **tstate) PyThreadState **tstate)
{ {
@ -511,8 +506,7 @@ pq_abort_locked(connectionObject *conn, PGresult **pgres, char **error,
This function should be called while holding the global interpreter This function should be called while holding the global interpreter
lock. */ lock. */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
pq_abort(connectionObject *conn) pq_abort(connectionObject *conn)
{ {
int retvalue = -1; int retvalue = -1;
@ -554,8 +548,7 @@ pq_abort(connectionObject *conn)
connection without holding the global interpreter lock. connection without holding the global interpreter lock.
*/ */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
pq_reset_locked(connectionObject *conn, PGresult **pgres, char **error, pq_reset_locked(connectionObject *conn, PGresult **pgres, char **error,
PyThreadState **tstate) PyThreadState **tstate)
{ {
@ -847,8 +840,7 @@ pq_flush(connectionObject *conn)
this fucntion locks the connection object this fucntion locks the connection object
this function call Py_*_ALLOW_THREADS macros */ this function call Py_*_ALLOW_THREADS macros */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
pq_execute(cursorObject *curs, const char *query, int async) pq_execute(cursorObject *curs, const char *query, int async)
{ {
PGresult *pgres = NULL; PGresult *pgres = NULL;
@ -1028,8 +1020,7 @@ pq_get_last_result(connectionObject *conn)
1 - result from backend (possibly data is ready) 1 - result from backend (possibly data is ready)
*/ */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG static int
static int
_pq_fetch_tuples(cursorObject *curs) _pq_fetch_tuples(cursorObject *curs)
{ {
int i, *dsize = NULL; int i, *dsize = NULL;

View File

@ -35,23 +35,18 @@
/* exported functions */ /* exported functions */
HIDDEN PGresult *pq_get_last_result(connectionObject *conn); HIDDEN PGresult *pq_get_last_result(connectionObject *conn);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int pq_fetch(cursorObject *curs);
HIDDEN int pq_fetch(cursorObject *curs); RAISES_NEG HIDDEN int pq_execute(cursorObject *curs, const char *query, int async);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION
HIDDEN int pq_execute(cursorObject *curs, const char *query, int async);
HIDDEN int pq_send_query(connectionObject *conn, const char *query); HIDDEN int pq_send_query(connectionObject *conn, const char *query);
HIDDEN int pq_begin_locked(connectionObject *conn, PGresult **pgres, HIDDEN int pq_begin_locked(connectionObject *conn, PGresult **pgres,
char **error, PyThreadState **tstate); char **error, PyThreadState **tstate);
HIDDEN int pq_commit(connectionObject *conn); HIDDEN int pq_commit(connectionObject *conn);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int pq_abort_locked(connectionObject *conn, PGresult **pgres,
HIDDEN int pq_abort_locked(connectionObject *conn, PGresult **pgres,
char **error, PyThreadState **tstate); char **error, PyThreadState **tstate);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int pq_abort(connectionObject *conn);
HIDDEN int pq_abort(connectionObject *conn);
HIDDEN int pq_reset_locked(connectionObject *conn, PGresult **pgres, HIDDEN int pq_reset_locked(connectionObject *conn, PGresult **pgres,
char **error, PyThreadState **tstate); char **error, PyThreadState **tstate);
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG HIDDEN int pq_reset(connectionObject *conn);
HIDDEN int pq_reset(connectionObject *conn);
HIDDEN char *pq_get_guc_locked(connectionObject *conn, const char *param, HIDDEN char *pq_get_guc_locked(connectionObject *conn, const char *param,
PGresult **pgres, PGresult **pgres,
char **error, PyThreadState **tstate); char **error, PyThreadState **tstate);
@ -74,8 +69,7 @@ HIDDEN int pq_execute_command_locked(connectionObject *conn,
const char *query, const char *query,
PGresult **pgres, char **error, PGresult **pgres, char **error,
PyThreadState **tstate); PyThreadState **tstate);
CPYCHECKER_SETS_EXCEPTION RAISES HIDDEN void pq_complete_error(connectionObject *conn, PGresult **pgres,
HIDDEN void pq_complete_error(connectionObject *conn, PGresult **pgres,
char **error); char **error);
#endif /* !defined(PSYCOPG_PQPATH_H) */ #endif /* !defined(PSYCOPG_PQPATH_H) */

View File

@ -120,8 +120,7 @@ HIDDEN PyObject *psyco_GetDecimalType(void);
typedef struct cursorObject cursorObject; typedef struct cursorObject cursorObject;
/* some utility functions */ /* some utility functions */
CPYCHECKER_SETS_EXCEPTION RAISES HIDDEN void psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg,
HIDDEN void psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg,
const char *pgerror, const char *pgcode); const char *pgerror, const char *pgcode);
HIDDEN char *psycopg_escape_string(PyObject *conn, HIDDEN char *psycopg_escape_string(PyObject *conn,
@ -130,11 +129,9 @@ HIDDEN char *psycopg_escape_identifier_easy(const char *from, Py_ssize_t len);
HIDDEN int psycopg_strdup(char **to, const char *from, Py_ssize_t len); HIDDEN int psycopg_strdup(char **to, const char *from, Py_ssize_t len);
HIDDEN int psycopg_is_text_file(PyObject *f); HIDDEN int psycopg_is_text_file(PyObject *f);
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1) STEALS(1) HIDDEN PyObject * psycopg_ensure_bytes(PyObject *obj);
HIDDEN PyObject * psycopg_ensure_bytes(PyObject *obj);
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1) STEALS(1) HIDDEN PyObject * psycopg_ensure_text(PyObject *obj);
HIDDEN PyObject * psycopg_ensure_text(PyObject *obj);
/* Exceptions docstrings */ /* Exceptions docstrings */
#define Error_doc \ #define Error_doc \

View File

@ -600,8 +600,7 @@ psyco_errors_set(PyObject *type)
Create a new error of the given type with extra attributes. */ Create a new error of the given type with extra attributes. */
CPYCHECKER_SETS_EXCEPTION RAISES void
void
psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg, psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg,
const char *pgerror, const char *pgcode) const char *pgerror, const char *pgcode)
{ {

View File

@ -116,8 +116,7 @@ psycopg_escape_identifier_easy(const char *from, Py_ssize_t len)
* Store the return in 'to' and return 0 in case of success, else return -1 * Store the return in 'to' and return 0 in case of success, else return -1
* and raise an exception. * and raise an exception.
*/ */
CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION RAISES_NEG int
int
psycopg_strdup(char **to, const char *from, Py_ssize_t len) psycopg_strdup(char **to, const char *from, Py_ssize_t len)
{ {
if (!len) { len = strlen(from); } if (!len) { len = strlen(from); }
@ -139,8 +138,7 @@ psycopg_strdup(char **to, const char *from, Py_ssize_t len)
* *
* It is safe to call the function on NULL. * It is safe to call the function on NULL.
*/ */
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1) STEALS(1) PyObject *
PyObject *
psycopg_ensure_bytes(PyObject *obj) psycopg_ensure_bytes(PyObject *obj)
{ {
PyObject *rv = NULL; PyObject *rv = NULL;
@ -170,8 +168,7 @@ psycopg_ensure_bytes(PyObject *obj)
* The function is ref neutral: steals a ref from obj and adds one to the * The function is ref neutral: steals a ref from obj and adds one to the
* return value. It is safe to call it on NULL. * return value. It is safe to call it on NULL.
*/ */
CPYCHECKER_STEALS_REFERENCE_TO_ARG(1) STEALS(1) PyObject *
PyObject *
psycopg_ensure_text(PyObject *obj) psycopg_ensure_text(PyObject *obj)
{ {
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3