From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc2b.google.com (mail-oo1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) by sourceware.org (Postfix) with ESMTPS id 756843858D37 for ; Mon, 21 Feb 2022 14:01:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 756843858D37 Received: by mail-oo1-xc2b.google.com with SMTP id d134-20020a4a528c000000b00319244f4b04so13270024oob.8 for ; Mon, 21 Feb 2022 06:01:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=/PgKZcsc80rI+mgEim39wogliTk4iEO+q9mZCW3HJJg=; b=PvYHUJgJ1mJGWu2AN/bu7PhB1YvS4EpQbCRfqGtko5gy7GC4DsJO0tkINPwGS53GMN 1itJS0vb0KpdslDF4lLyGx6eo0kzRb+ddGXS8zOPrgzuIICb6mqn1kbMafkkAnfjQ5Ky hw+XPzw5mcXp8L1tdh5i3jpfhtGHbejV4ImnMkny64ACn5L9p9nSLZv9s0HmmwdeW7lZ TXb+zltE+aQfSqaIji00dJn1noH6ezOfiVFLLJnXuomyEec+4k1tHpv5owXZEryQwXCJ yfgEzADt7c7rokBs19DOZG/BXlZgBmJZy4niy4XUZ2PDJiKv+Ax13HRtzDJ+kDcxlxL/ ACTQ== X-Gm-Message-State: AOAM531r/W5ZE0Cdb5TesF6DVU3WV92YSnHZ40iTdiO4fjY1N0K96YES CD+ccYMNCsDJCf5B+7pD/nlVU7RX7mKCEw== X-Google-Smtp-Source: ABdhPJw+QoHJ+iS1OWzA67q1MXhZhwky9Y7kaXaOP4HInux+c3W73tfGXss+i+vq1Tjc+qbsFsjRig== X-Received: by 2002:a05:6870:f604:b0:d1:bd6e:47e3 with SMTP id ek4-20020a056870f60400b000d1bd6e47e3mr7866590oab.30.1645452088639; Mon, 21 Feb 2022 06:01:28 -0800 (PST) Received: from ?IPV6:2804:431:c7ca:cb36:ae42:babb:bfa3:4f13? ([2804:431:c7ca:cb36:ae42:babb:bfa3:4f13]) by smtp.gmail.com with ESMTPSA id bd10sm1074694oib.28.2022.02.21.06.01.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Feb 2022 06:01:28 -0800 (PST) Message-ID: Date: Mon, 21 Feb 2022 11:01:25 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH v2 7/7] misc: syslog: Use RFC5424 Content-Language: en-US To: Paul Eggert Cc: libc-alpha@sourceware.org References: <20220218142322.432304-1-adhemerval.zanella@linaro.org> <20220218142322.432304-8-adhemerval.zanella@linaro.org> From: Adhemerval Zanella In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00, BODY_8BITS, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Feb 2022 14:01:31 -0000 On 19/02/2022 00:50, Paul Eggert wrote: > There should be documentation about the change, somewhere. > > On 2/18/22 06:23, Adhemerval Zanella via Libc-alpha wrote: > >> +  struct tm *gmtm = __gmtime64_r (&ts.tv_sec, &now_tm); >> +  if (gmtm == NULL) >> +    strcpy (timebuf->b, NILVALUE); > > RFC 5424 requires unsigned four-digit years, so change "gmtm == NULL" to "gmtm == NULL || ! (-1900 <= gmtm->tm_year && gmtm->tm_year <= 9999 - 1900)". Or, if the idea is to depart from RFC 5424 for out-of-range years (which might be better), document the departure. Indeed I don't see why we can't support out-of-range years in such case. I will add a comment. > >> +  else >> +    { >> +      size_t datebytes = __strftime_l (timebuf->b, sizeof timebuf->b, >> +                       "%FT%T", gmtm, _nl_C_locobj_ptr); > RFC 5424 does not allow leap seconds, so something like this: > >     if (gmtm->tv_sec == 60) >       { >          gmtm->tv_sec = 59; >          gmtm->tv_nsec = 999999999; >       } > > before calling __strftime_l. (Or again, if the idea is to depart from RFC 5424, document the departure.) I think this is worth to support, I will add such test. > >> +      int usec = ts.tv_nsec / 1000; > > Typically fewer instructions (and still correct) if you replace 1000 with 1000ul (admittedly a microoptimization....). Ack.