From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id EBACF6EC40; Tue, 17 Aug 2021 15:17:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org EBACF6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629202630; bh=CTOTYpCNf5uM/obl6kjE+PS0AyrNCylDupK9jkb6qpY=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=OuUsrMhHfoU1hP/keCQz36ujEoa10OWWMsrMCMirNsqthX+E5uuW1sLv4n/DClLjd 7By3CU3CPFribLJBf/62vkNNUBbM2xyvgWheCWDl1IeqGHu2Ghd2a0aulQ0uBdkMva HBaQWIaEAnmNrdB6XQs8ups1ZfpuzWSv1JEn4noA= Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [94.100.177.89]) (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 7CACB6EC40 for ; Tue, 17 Aug 2021 15:15:53 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7CACB6EC40 Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1mFy0W-0001J6-Bo; Tue, 17 Aug 2021 15:15:52 +0300 To: Safin Timur References: <5e5afbb7249c1dfa56f2695fc6a7140be98fa39d.1629071531.git.tsafin@tarantool.org> <8bec4ec7-71fa-71cf-dd4a-73ce470c7283@tarantool.org> Message-ID: <9f0f9279-2372-e6f4-b5e7-c0e539a6a9bf@tarantool.org> Date: Tue, 17 Aug 2021 15:15:51 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <8bec4ec7-71fa-71cf-dd4a-73ce470c7283@tarantool.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-GB X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD91BCCB18F2C129F87F36E61E9E4584E9D182A05F5380850402C5B59F15E35DC25CA31B78E8D229350B6BB4944950879E77C4100E2E81CD14F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE732F68F8AF5E5BA59EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637E8F1A1743CF948808638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D836FD02D6DA7573B64F3116B8DDA8356E117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF1175FABE1C0F9B6A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B67ECBC18655D52CDF089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: 0D63561A33F958A518EC06A823986E409D6741A574F56BED10E7882CF3861F12D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7567C209D01CC1E34B410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34CC972AA0E2E780C4B94FD9B0407406C09258E29BD9718BD5628A23726668BE29FA8FFC3C70F1BB771D7E09C32AA3244C482BBB3D72B3A084B58329DE6742EBABC3B3ADDA61883BB583B48618A63566E0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojuRQ/H5n28tpzbWUpBiluSA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A446536073F9A9F7FACE1CC46211DC858E63DBC91E654210EB0A424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v5 4/8] box, datetime: messagepack support for datetime X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 16.08.2021 03:20, Safin Timur via Tarantool-patches пишет: > > > On 16.08.2021 2:59, Timur Safin wrote: >> Serialize datetime_t as newly introduced MP_EXT type. >> It saves 1 required integer field and upto 2 optional >> unsigned fields in very compact fashion. >> - secs is required field; >> - but nsec, offset are both optional; >> >> * json, yaml serialization formats, lua output mode >>    supported; >> * exported symbols for datetime messagepack size calculations >>    so they are available for usage on Lua side. >> >> Part of #5941 >> Part of #5946 > ... > >> diff --git a/src/lib/core/mp_datetime.c b/src/lib/core/mp_datetime.c >> new file mode 100644 >> index 000000000..d0a3e562c >> --- /dev/null >> +++ b/src/lib/core/mp_datetime.c > ... > >> + >> +int >> +mp_snprint_datetime(char *buf, int size, const char **data, uint32_t >> len) >> +{ >> +    struct datetime date = {0}; > > Due to old gcc compiler used by CentOS7 I had to modify these 2 > functions - see incremental patch below... >> + >> +    if (datetime_unpack(data, len, &date) == NULL) >> +        return -1; >> + >> +    return datetime_to_string(&date, buf, size); >> +} >> + >> +int >> +mp_fprint_datetime(FILE *file, const char **data, uint32_t len) >> +{ >> +    struct datetime date; >> + >> +    if (datetime_unpack(data, len, &date) == NULL) >> +        return -1; >> + >> +    char buf[48]; >> +    datetime_to_string(&date, buf, sizeof buf); >> + >> +    return fprintf(file, "%s", buf); >> +} >> + > > ---------------------------------------------------------------- > 03:15 $ git diff > diff --git a/src/lib/core/mp_datetime.c b/src/lib/core/mp_datetime.c > index d0a3e562c..7e475d5f1 100644 > --- a/src/lib/core/mp_datetime.c > +++ b/src/lib/core/mp_datetime.c > @@ -165,7 +165,7 @@ mp_encode_datetime(char *data, const struct > datetime *date) >  int >  mp_snprint_datetime(char *buf, int size, const char **data, uint32_t > len) >  { > -       struct datetime date = {0}; > +       struct datetime date = {0, 0, 0}; Please, use designated initializers here: struct datetime date = {     .secs = ...,     .nsec = ..., ... > >         if (datetime_unpack(data, len, &date) == NULL) >                 return -1; > @@ -176,7 +176,7 @@ mp_snprint_datetime(char *buf, int size, const > char **data, uint32_t len) >  int >  mp_fprint_datetime(FILE *file, const char **data, uint32_t len) >  { > -       struct datetime date; > +       struct datetime date = {0, 0, 0}; > >         if (datetime_unpack(data, len, &date) == NULL) >                 return -1; > ---------------------------------------------------------------- > > Sorry for the inconvenience! > > [Applied and force pushed] > > Timur -- Serge Petrenko