Fixed minor format errors and resource leaks

Some format strings used integer values for unsigned integers.
Memory and file descriptors leaked in some error conditions.
This commit is contained in:
Markus Makela 2015-11-25 10:40:16 +02:00
parent dcf0d4ef4b
commit 038877b8db
6 changed files with 7 additions and 6 deletions

View File

@ -1633,8 +1633,7 @@ int main(int argc, char **argv)
MXS_ERROR("%s", errorbuffer);
if (!daemon_mode)
{
strncat(errorbuffer, "\n", STRING_BUFFER_SIZE);
fprintf(stderr, "%s", errorbuffer);
fprintf(stderr, "%s\n", errorbuffer);
}
rc = MAXSCALE_BADCONFIG;

View File

@ -1718,10 +1718,10 @@ RESULT_ROW *row;
buf[39] = '\0';
resultset_row_set(row, 0, buf);
}
snprintf(buf,39, "%d", queueStats.qtimes[*rowno]);
snprintf(buf,39, "%u", queueStats.qtimes[*rowno]);
buf[39] = '\0';
resultset_row_set(row, 1, buf);
snprintf(buf,39, "%d", queueStats.exectimes[*rowno]);
snprintf(buf,39, "%u", queueStats.exectimes[*rowno]);
buf[39] = '\0';
resultset_row_set(row, 2, buf);
(*rowno)++;

View File

@ -1242,6 +1242,7 @@ createInstance(char **options, FILTER_PARAMETER **params)
if ((my_instance = calloc(1, sizeof(FW_INSTANCE))) == NULL ||
(my_instance->lock = (SPINLOCK*) malloc(sizeof(SPINLOCK))) == NULL)
{
free(my_instance);
MXS_ERROR("Memory allocation for firewall filter failed.");
return NULL;
}

View File

@ -199,7 +199,7 @@ int i,cflags = 0;
else
{
MXS_ERROR("lagfilter: unsupported option '%s'.",
options[i])));
options[i]);
}
}
}

View File

@ -1623,6 +1623,7 @@ char err_msg[STRERROR_BUFLEN];
if(chmod(tmp_file, S_IRUSR | S_IWUSR) < 0) {
snprintf(error, BINLOG_ERROR_MSG_LEN, "%s, errno %u", strerror_r(errno, err_msg, sizeof(err_msg)), errno);
fclose(config_file);
return 2;
}

View File

@ -3462,7 +3462,7 @@ static bool select_connect_backend_servers(
MXS_WARNING("Couldn't connect to any of the %d "
"slaves. Routing to %s only.",
slaves_found,
(is_synced_master ? "Galera nodes" : "Master"))));
(is_synced_master ? "Galera nodes" : "Master"));
#endif
}
else if (slaves_found == 0)