Fix compiler warnings

Added missing checks for return values of various function calls. Fixed
binlogrouter strerror_r usage and wrong buffer sizes.
This commit is contained in:
Markus Mäkelä
2017-02-13 11:41:58 +02:00
parent eb1e163bdf
commit acd66b4eb3
7 changed files with 78 additions and 27 deletions

View File

@ -17,6 +17,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <maxscale/alloc.h>
#include <maxscale/atomic.h>
#include <maxscale/hashtable.h>
@ -741,7 +742,12 @@ hashtable_save(HASHTABLE *table, const char *filename,
close(fd);
return -1;
}
write(fd, &rval, sizeof(rval)); // Write zero counter, will be overrwriten at end
if (write(fd, &rval, sizeof(rval)) == -1) // Write zero counter, will be overrwriten at end
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to write hashtable item count: %d, %s", errno,
strerror_r(errno, err, sizeof(err)));
}
if ((iter = hashtable_iterator(table)) != NULL)
{
while ((key = hashtable_next(iter)) != NULL)
@ -766,7 +772,12 @@ hashtable_save(HASHTABLE *table, const char *filename,
/* Now go back and write the count of entries */
if (lseek(fd, 7L, SEEK_SET) != -1)
{
write(fd, &rval, sizeof(rval));
if (write(fd, &rval, sizeof(rval)) == -1)
{
char err[MXS_STRERROR_BUFLEN];
MXS_ERROR("Failed to write hashtable item count: %d, %s", errno,
strerror_r(errno, err, sizeof(err)));
}
}
close(fd);