From owner-dev-commits-src-main@freebsd.org Wed Sep 1 10:34:19 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 18DC8667D84; Wed, 1 Sep 2021 10:34:19 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4H00mB0wzsz3sg0; Wed, 1 Sep 2021 10:34:18 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 181AY9CD090942 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 1 Sep 2021 13:34:12 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 181AY9CD090942 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 181AY9Ex090941; Wed, 1 Sep 2021 13:34:09 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 1 Sep 2021 13:34:09 +0300 From: Konstantin Belousov To: Kristof Provost , Dimitry Andric Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 5b8f07b12f84 - main - Fix -Wformat errors in pfctl on 32-bit architectures Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4H00mB0wzsz3sg0 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-2.99 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_SPF_SOFTFAIL(0.00)[~all:c]; RCPT_COUNT_FIVE(0.00)[5]; NEURAL_HAM_SHORT(-0.99)[-0.993]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; MIME_TRACE(0.00)[0:+]; MAILMAN_DEST(0.00)[dev-commits-src-all,dev-commits-src-main]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Sep 2021 10:34:19 -0000 On Tue, Aug 31, 2021 at 09:54:32AM +0200, Kristof Provost wrote: > On 31 Aug 2021, at 1:33, Konstantin Belousov wrote: > > On Sun, Aug 29, 2021 at 07:40:09PM +0200, Dimitry Andric wrote: > >> On 29 Aug 2021, at 18:00, Kristof Provost wrote: > >>> > >>> On 29 Aug 2021, at 17:31, Dimitry Andric wrote: > >>>> The branch main has been updated by dim: > >>>> > >>>> URL: https://cgit.FreeBSD.org/src/commit/?id=5b8f07b12f8477f1679013d6b3abdab8d33c7243 > >>>> > >>>> commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 > >>>> Author: Dimitry Andric > >>>> AuthorDate: 2021-08-29 15:31:28 +0000 > >>>> Commit: Dimitry Andric > >>>> CommitDate: 2021-08-29 15:31:28 +0000 > >>>> > >>>> Fix -Wformat errors in pfctl on 32-bit architectures > >>>> > >>>> Use PRIu64 to printf(3) uint64_t quantities, otherwise this will result > >>>> in "error: format specifies type 'unsigned long' but the argument has > >>>> type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 32-bit > >>>> architectures. > >>>> > >>>> Fixes: 80078d9d38fd > >>>> MFC after: 1 week > >>> > >>> Thanks! > >>> > >>> I was running test builds for a fix, but it is so much more convenient when other people fix my mistakes for me. > >> > >> I was trying buildworld on i386 for something totally unrelated, and ran > >> into these -Wformat errors so I took the liberty of patching them up > >> quickly. :) > > > > Generally we do not use the PRIu64 (you should remember the term > > abomination). Why not cast to uintmax_t and use %ju as we typically do > > in other places. > > > There are a couple of examples in the tree, but it is indeed rare. > > I wanted to avoid casting so that the compiler would still shout at me if data types changed. It’s much easier to miss places where a variable is used (and that need to be updated) if they’re getting cast to something. > You do not need to cast after uintmax_t cast. Point is that the type is the highest rank integer on the arch. Of course, uintmax_t on all existing arches is 64bit, and would stay the same even after 128bit integers (like long long long) are introduced. But I do not think it is relevant there. > If this is something the project has strong feelings about I’ll change it, but I think I like this slightly better than casting to uintmax_t. > > Best regards, > Kristof On Tue, Aug 31, 2021 at 11:03:12AM +0200, Dimitry Andric wrote: > On 31 Aug 2021, at 01:33, Konstantin Belousov wrote: > > > > On Sun, Aug 29, 2021 at 07:40:09PM +0200, Dimitry Andric wrote: > >> On 29 Aug 2021, at 18:00, Kristof Provost wrote: > >>> > >>> On 29 Aug 2021, at 17:31, Dimitry Andric wrote: > >>>> The branch main has been updated by dim: > >>>> > >>>> URL: https://cgit.FreeBSD.org/src/commit/?id=5b8f07b12f8477f1679013d6b3abdab8d33c7243 > >>>> > >>>> commit 5b8f07b12f8477f1679013d6b3abdab8d33c7243 > >>>> Author: Dimitry Andric > >>>> AuthorDate: 2021-08-29 15:31:28 +0000 > >>>> Commit: Dimitry Andric > >>>> CommitDate: 2021-08-29 15:31:28 +0000 > >>>> > >>>> Fix -Wformat errors in pfctl on 32-bit architectures > >>>> > >>>> Use PRIu64 to printf(3) uint64_t quantities, otherwise this will result > >>>> in "error: format specifies type 'unsigned long' but the argument has > >>>> type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]" on 32-bit > >>>> architectures. > >>>> > >>>> Fixes: 80078d9d38fd > >>>> MFC after: 1 week > >>> > >>> Thanks! > >>> > >>> I was running test builds for a fix, but it is so much more convenient when other people fix my mistakes for me. > >> > >> I was trying buildworld on i386 for something totally unrelated, and ran > >> into these -Wformat errors so I took the liberty of patching them up > >> quickly. :) > > > > Generally we do not use the PRIu64 (you should remember the term > > abomination). Why not cast to uintmax_t and use %ju as we typically do > > in other places. > > I personally see nothing wrong with PRIu64, but in this case I just > copied the existing coding style. Well, PRIu64 is ugly. %ju is much easier to read and write. Anyway, I do not insist, just pointing out common practice for this specific case.