瀏覽代碼

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
Victor Seva 9 月之前
父節點
當前提交
7f24bc0986
共有 2 個文件被更改,包括 9 次插入6 次删除
  1. 8 5
      src/modules/db_unixodbc/connection.c
  2. 1 1
      src/modules/db_unixodbc/connection.h

+ 8 - 5
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);
 }
 
 

+ 1 - 1
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);