From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 88590469710 for ; Wed, 13 May 2020 15:31:46 +0300 (MSK) Date: Wed, 13 May 2020 12:31:45 +0000 From: Nikita Pettik Message-ID: <20200513123145.GA16814@tarantool.org> References: <22a830fb9d2dbc3883b9710d36ab88c638101002.1589240704.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <22a830fb9d2dbc3883b9710d36ab88c638101002.1589240704.git.v.shpilevoy@tarantool.org> Subject: Re: [Tarantool-patches] [PATCH 4/5] error: provide MP_ERROR extension serializer List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy Cc: tarantool-patches@dev.tarantool.org 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) */ > +