From a83d9b66d7d976d4943919f8faeabcbdf3f12368 Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 11 Dec 2024 00:09:02 +0100 Subject: [PATCH] [PATCH] db_unixodbc: fix incompatible-pointer-types warning > dbase.c: In function 'db_unixodbc_close_impl': > dbase.c:261:32: error: passing argument 2 of 'db_do_close' from incompatible pointer type [-Wincompatible-pointer-types] > 261 | return db_do_close(_h, db_unixodbc_free_connection); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ > | | > | void (*)(struct my_con *) > In file included from val.h:34, > from dbase.c:33: > ../../lib/srdb1/db.h:495:40: note: expected 'void (*)(struct pool_con *)' but argument is of type 'void (*)(struct my_con *)' > 495 | void db_do_close(db1_con_t *_h, void (*free_connection)(struct pool_con *)); > | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > make[2]: *** [../../Makefile.rules:101: dbase.o] Error 1 related #4064 (cherry picked from commit 7f24bc09863220b4c14e2046708c10ff0891c038) Gbp-Pq: Topic upstream Gbp-Pq: Name 0002-db_unixodbc-fix-incompatible-pointer-types-warning.patch --- src/modules/db_unixodbc/connection.c | 13 ++++++++----- src/modules/db_unixodbc/connection.h | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/modules/db_unixodbc/connection.c b/src/modules/db_unixodbc/connection.c index 92b1cdb9..d56f2ac3 100644 --- a/src/modules/db_unixodbc/connection.c +++ b/src/modules/db_unixodbc/connection.c @@ -179,14 +179,17 @@ err2: /* * Close the connection and release memory */ -void db_unixodbc_free_connection(struct my_con *con) +void db_unixodbc_free_connection(struct pool_con *con) { + struct my_con *_c; + if(!con) return; - SQLFreeHandle(SQL_HANDLE_ENV, con->env); - SQLDisconnect(con->dbc); - SQLFreeHandle(SQL_HANDLE_DBC, con->dbc); - pkg_free(con); + _c = (struct my_con *)con; + SQLFreeHandle(SQL_HANDLE_ENV, _c->env); + SQLDisconnect(_c->dbc); + SQLFreeHandle(SQL_HANDLE_DBC, _c->dbc); + pkg_free(_c); } diff --git a/src/modules/db_unixodbc/connection.h b/src/modules/db_unixodbc/connection.h index d94f0b48..a37bb1e3 100644 --- a/src/modules/db_unixodbc/connection.h +++ b/src/modules/db_unixodbc/connection.h @@ -83,7 +83,7 @@ struct my_con *db_unixodbc_new_connection(struct db_id *id); /* * Close the connection and release memory */ -void db_unixodbc_free_connection(struct my_con *con); +void db_unixodbc_free_connection(struct pool_con *con); char *db_unixodbc_build_conn_str(const struct db_id *id, char *buf); -- 2.30.2