[Tarantool-patches] [PATCH] say: fix format for fiber()->fid

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Feb 23 23:41:46 MSK 2021


Hi! Please, add a changelog file. This is user-visible behaviour
so it must be reflected in the changes.

On 22.02.2021 19:20, Cyrill Gorcunov wrote:
> The fiber's ID (fiber::fid) is unsigned integer so
> we should use a proper format specificator when printing
> it out, otherwise the logger show us weird strings like
> 
>  | main/-244760339/cartridge.failover.task I> Instance state changed
> 
> Fixes #5846
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>  src/lib/core/say.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lib/core/say.c b/src/lib/core/say.c
> index cbd10e107..6138752a7 100644
> --- a/src/lib/core/say.c
> +++ b/src/lib/core/say.c
> @@ -792,7 +792,7 @@ say_format_plain_tail(char *buf, int len, int level, const char *filename,
>  	if (cord) {
>  		SNPRINT(total, snprintf, buf, len, " %s", cord->name);
>  		if (fiber() && fiber()->fid != FIBER_ID_SCHED) {
> -			SNPRINT(total, snprintf, buf, len, "/%i/%s",
> +			SNPRINT(total, snprintf, buf, len, "/%u/%s",
>  				fiber()->fid, fiber_name(fiber()));

I remember we had some issues about %u not being compatible with uint32_t so
we did manual casts to 'unsigned'. Not sure though what was the commit/ticket,
or if it really happened.

I am fine with not using the cast as long as all platforms and compilers
build flawlessly. Also it is ok for me if you will add an explicit cast in
the next version of the patch. Up to you. The same below.

>  		}
>  	}
> @@ -918,7 +918,7 @@ say_format_json(struct log *log, char *buf, int len, int level, const char *file
>  		SNPRINT(total, snprintf, buf, len, "\"");
>  		if (fiber() && fiber()->fid != FIBER_ID_SCHED) {
>  			SNPRINT(total, snprintf, buf, len,
> -				", \"fiber_id\": %i, ", fiber()->fid);
> +				", \"fiber_id\": %u, ", fiber()->fid);
>  			SNPRINT(total, snprintf, buf, len,
>  				"\"fiber_name\": \"");
>  			SNPRINT(total, json_escape, buf, len,
> 
> base-commit: 6610bce9bf43a139043518cd76d3c0c81c981ce2


More information about the Tarantool-patches mailing list