[Tarantool-patches] [PATCH 4/5] error: provide MP_ERROR extension serializer

Nikita Pettik korablev at tarantool.org
Wed May 13 15:31:45 MSK 2020


On 12 May 01:45, Vladislav Shpilevoy wrote:
>  src/box/mp_error.h        |  29 ++++
>  test/unit/mp_error.cc     | 270 +++++++++++++++++++++++++++++++++++++-
>  test/unit/mp_error.result |  72 +++++++++-
>  4 files changed, 529 insertions(+), 3 deletions(-)
> +
> +#define MP_ERROR_PRINT_DEFINITION
> +#define MP_PRINT_FUNC snprintf
> +#define MP_PRINT_SUFFIX snprint
> +#define MP_PRINT_2(total, func, ...)						\
> +	SNPRINT(total, func, buf, size, __VA_ARGS__)
> +#define MP_PRINT_ARGS_DECL char *buf, int size
> +#include __FILE__
> +
> +#define MP_ERROR_PRINT_DEFINITION
> +#define MP_PRINT_FUNC fprintf
> +#define MP_PRINT_SUFFIX fprint
> +#define MP_PRINT_2(total, func, ...) do {							\
> +	int bytes = func(file, __VA_ARGS__);					\
> +	if (bytes < 0)								\
> +		return -1;							\
> +	total += bytes;								\
> +} while (0)
> +#define MP_PRINT_ARGS_DECL FILE *file
> +#include __FILE__

I've failed to understand how this is supposed to work.
Why do you have to include file itself? Why do you have to do it twice?
This macro related part definitely lacks some comments.

> +/* !defined(MP_ERROR_PRINT_DEFINITION) */
> +#else
> +/* defined(MP_ERROR_PRINT_DEFINITION) */
> +


More information about the Tarantool-patches mailing list