[Tarantool-patches] [PATCH v3 00/10] fix say_x format and rework fibers
Cyrill Gorcunov
gorcunov at gmail.com
Thu May 13 11:17:00 MSK 2021
On Wed, May 12, 2021 at 08:41:42PM +0200, Vladislav Shpilevoy wrote:
> >
> > static int
> > lbox_fiber_top_entry(struct fiber *f, void *cb_ctx)
> > {
> > struct lua_State *L = (struct lua_State *) cb_ctx;
> >
> > --> lua_pushfstring(L, "%f/%s", (lua_Number)f->fid, f->name);
> >
> > why do we use float formate here at all?!
>
> Because lua_pushfstring() does not support %llu.
What about the idea below? float is 4 byte len and won't cover the
8 byte integer so we will have a rounding error.
---
[cyrill at grain tarantool.git] git diff
diff --git a/src/lua/fiber.c b/src/lua/fiber.c
index 02ec3d158..753b9aa16 100644
--- a/src/lua/fiber.c
+++ b/src/lua/fiber.c
@@ -337,7 +337,10 @@ lbox_fiber_top_entry(struct fiber *f, void *cb_ctx)
{
struct lua_State *L = (struct lua_State *) cb_ctx;
- lua_pushfstring(L, "%f/%s", (lua_Number)f->fid, f->name);
+ char sbuf[FIBER_NAME_MAX + 32];
+ snprintf(sbuf, sizeof(sbuf), "%llu/%s",
+ (long long)f->fid, f->name);
+ lua_pushstring(L, sbuf);
lua_newtable(L);
More information about the Tarantool-patches
mailing list