Skip to content

Commit

Permalink
mx_mysql: Refactor two functions into void functions
Browse files Browse the repository at this point in the history
mx_mysql_option_set_default_group() and mx_mysql_option_set_reconnect()
can't fail, so make them void functions.
  • Loading branch information
donald committed Jan 10, 2024
1 parent 3963e71 commit 673fa5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 2 additions & 5 deletions mx_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,24 +630,21 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname)
return 0;
}

int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group)
void mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group)
{
assert(mysql);

if (group && !(*group))
group = NULL;

mysql->default_group = group;

return 0;
}

int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect)
void mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect)
{
assert(mysql);

mysql->reconnect = (bool)!!reconnect;
return 0;
}

static int mx_mysql_real_connect(struct mx_mysql *mysql, const char *host, const char *user, const char *passwd, const char *db, unsigned int port, const char *unix_socket, unsigned long client_flag)
Expand Down
4 changes: 2 additions & 2 deletions mx_mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ struct mx_mysql_stmt {
int mx_mysql_initialize(struct mx_mysql **mysql);

int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname) __attribute__ ((warn_unused_result));
int mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group);
int mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect);
void mx_mysql_option_set_default_group(struct mx_mysql *mysql, char *group);
void mx_mysql_option_set_reconnect(struct mx_mysql *mysql, int reconnect);

int mx_mysql_connect(struct mx_mysql **mysql);
int mx_mysql_connect_forever_sec(struct mx_mysql **mysql, unsigned int seconds);
Expand Down

0 comments on commit 673fa5e

Please sign in to comment.