[Tarantool-patches] [PATCH 5/5] msgpuck: activate MP_EXT custom serializers

Nikita Pettik korablev at tarantool.org
Thu May 14 00:06:33 MSK 2020


On 12 May 01:45, Vladislav Shpilevoy wrote:
> +
> +static int
> +msgpack_fprint_ext(FILE *file, const char **data, int depth)
> +{
> +	int8_t type;
> +	uint32_t len = mp_decode_extl(data, &type);
> +	switch(type) {
> +	case MP_DECIMAL:
> +		return mp_fprint_decimal(file, data, len);
> +	case MP_UUID:
> +		return mp_fprint_uuid(file, data, len);
> +	case MP_ERROR:
> +		return mp_fprint_error(file, data, depth);
> +	default:
> +		return fprintf(file, "undefined");

I'd come up with more sensible message in case of "undefined" mp_ type.
For instance: ("undefined mgpack extension (%d)", type).

> +	}
> +}
> +
> +static int
> +msgpack_snprint_ext(char *buf, int size, const char **data, int depth)
> +{
> +	int8_t type;
> +	uint32_t len = mp_decode_extl(data, &type);
> +	switch(type) {
> +	case MP_DECIMAL:
> +		return mp_snprint_decimal(buf, size, data, len);
> +	case MP_UUID:
> +		return mp_snprint_uuid(buf, size, data, len);
> +	case MP_ERROR:
> +		return mp_snprint_error(buf, size, data, depth);
> +	default:
> +		return snprintf(buf, size, "undefined");

Same here.



More information about the Tarantool-patches mailing list