Skip to content

Commit 4b1f29f

Browse files
fweimer-rhHuidaeCho
authored andcommitted
lib: Use integer port argument with mysql_real_connect (OSGeo#3325)
The port argument is not a string, but a plain integer. In the past, compilers ignore such type errors and produced a warning only, but this is changing, so this change also addresses a potential build failure. Unlike PQsetdbLogin() which uses char *, mysql_real_connect() uses unsigned int for the port. Found as part of Porting To Modern C in the Fedora Project.
1 parent d096c3d commit 4b1f29f

File tree

1 file changed

+3
-2
lines changed
  • db/drivers/mysql

1 file changed

+3
-2
lines changed

db/drivers/mysql/db.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ int db__driver_open_database(dbHandle *handle)
5353
db_get_login2("mysql", name, &user, &password, &host, &port);
5454

5555
connection = mysql_init(NULL);
56-
res = mysql_real_connect(connection, host, user, password,
57-
connpar.dbname, port, NULL, 0);
56+
res =
57+
mysql_real_connect(connection, host, user, password, connpar.dbname,
58+
port != NULL ? atoi(port) : 0, NULL, 0);
5859

5960
if (res == NULL) {
6061
db_d_append_error("%s\n%s", _("Connection failed."),

0 commit comments

Comments
 (0)