Merge branch '2.0' into 2.1

This commit is contained in:
Markus Mäkelä
2017-02-20 11:17:49 +02:00
7 changed files with 139 additions and 89 deletions

View File

@ -12,6 +12,7 @@
*/
#include "maxavro.h"
#include "skygw_utils.h"
#include <errno.h>
#include <string.h>
#include <maxscale/log_manager.h>
@ -49,11 +50,12 @@ bool maxavro_verify_block(MAXAVRO_FILE *file)
int rc = fread(sync, 1, SYNC_MARKER_SIZE, file->file);
if (rc != SYNC_MARKER_SIZE)
{
if (rc == -1)
if (ferror(file->file))
{
MXS_ERROR("Failed to read file: %d %s", errno, strerror(errno));
char err[STRERROR_BUFLEN];
MXS_ERROR("Failed to read file: %d %s", errno, strerror_r(errno, err, sizeof(err)));
}
else
else if (rc > 0 || !feof(file->file))
{
MXS_ERROR("Short read when reading sync marker. Read %d bytes instead of %d",
rc, SYNC_MARKER_SIZE);

View File

@ -49,9 +49,11 @@ static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *fie
case MAXAVRO_TYPE_LONG:
{
uint64_t val = 0;
maxavro_read_integer(file, &val);
json_int_t jsonint = val;
value = json_pack("I", jsonint);
if (maxavro_read_integer(file, &val))
{
json_int_t jsonint = val;
value = json_pack("I", jsonint);
}
}
break;
@ -74,11 +76,23 @@ static json_t* read_and_pack_value(MAXAVRO_FILE *file, MAXAVRO_SCHEMA_FIELD *fie
break;
case MAXAVRO_TYPE_FLOAT:
{
float f = 0;
if (maxavro_read_float(file, &f))
{
double d = f;
value = json_pack("f", d);
}
}
break;
case MAXAVRO_TYPE_DOUBLE:
{
double d = 0;
maxavro_read_double(file, &d);
value = json_pack("f", d);
if (maxavro_read_double(file, &d))
{
value = json_pack("f", d);
}
}
break;