Skip to content

Commit

Permalink
mx_mysql: mx_mysql_option_set_default_file: Fix warning
Browse files Browse the repository at this point in the history
If the file is not readable, don't emit a warning but save it to be
retrievable by caller. Also shorten the text from

    MySQL ignoring defaults file: euidaccess("/etc/mxq/mysql_ro.cnfX", R_OK) failed: No such file or directory
    MySQL falling back to mysql default config search path.

to

    /etc/mxq/mysql_ro.cnfX: No such file or directory - falling back to mysql default config search path
  • Loading branch information
donald committed Dec 29, 2023
1 parent ff46678 commit 941277e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions mx_mysql.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ static void mx_mysql_save_error(const char *err) {
strncpy(mx_mysql_last_error, err, len+1);
}

__attribute__ ((format (printf, 1, 2)))
static void mx_mysql_save_error_va(const char *restrict fmt, ...) {
char *s;
va_list ap;
va_start(ap, fmt);
int res = vasprintf(&s, fmt, ap);
va_end(ap);
if (res == -1)
return;
mx_mysql_save_error(s);
free(s);
}

char *mx_mysql_error(void) {
return mx_mysql_last_error == NULL ? "no error information" : mx_mysql_last_error;
}
Expand Down Expand Up @@ -614,8 +627,7 @@ int mx_mysql_option_set_default_file(struct mx_mysql *mysql, char *fname)
mx_assert_return_minus_errno(mysql, EINVAL);

if (fname && (*fname == '/') && (euidaccess(fname, R_OK) != 0)) {
mx_log_warning("MySQL ignoring defaults file: euidaccess(\"%s\", R_OK) failed: %m", fname);
mx_log_warning("MySQL falling back to mysql default config search path.");
mx_mysql_save_error_va("%s: %m - falling back to mysql default config search path", fname);
return -errno;
}

Expand Down

0 comments on commit 941277e

Please sign in to comment.