From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BF498C43460 for ; Wed, 5 May 2021 22:22:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F57D61157 for ; Wed, 5 May 2021 22:22:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234073AbhEEWXV (ORCPT ); Wed, 5 May 2021 18:23:21 -0400 Received: from esa4.mentor.iphmx.com ([68.232.137.252]:57192 "EHLO esa4.mentor.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229897AbhEEWXU (ORCPT ); Wed, 5 May 2021 18:23:20 -0400 IronPort-SDR: SlZz+qtjNJar1cuRTb3RsH2YyzRNfwRCERsi+CelErtf0Bp4FqQ01OJSEXCDBT70XCy9wZcnGV CpVP5ZArBBhesEl4raRJKGxmRMY3Cwe0N4CzCcIA3hg35SZGJhvm6yWoylwlAFdZHUl2uwVWgy FdkYI3HWLg5BDOEOVa2ykGtmamv7ax/XaVQzVhkQNdS/n1xg04k44V7Z2CPO7gqlobb/25KzUr 77KM7Y7esxA38v0VSAL7fFdtmE15L0TeNQTu8R2LnaHhWMa2lYGNUNnwCaqwdiFyrkXOGJ9uNO LC0= X-IronPort-AV: E=Sophos;i="5.82,276,1613462400"; d="scan'208";a="61033681" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 05 May 2021 14:22:23 -0800 IronPort-SDR: yYRQC2BGZ2EAkI+dghDlrq62ctnEzUdDXVCbEBB5v6z8SaTasrZVI5bDosiuTWtKQ2NxHxdwWc 3oaEz2Y7c647UoXHvp0Jj2i9+uTeeFU1nNVPEyxqSbzUptTVOede61SgQjqXAIbOkz6stZVKDn mIPzoD9dlTOxe3+0gwdVKx2TfSeRTKAuPj/prdhV8xBVRK9GeA3DHNoj16s0xugWhT0J5x8xoZ cXwQBuJ8n5lEUZvbfkJnbYidEW5iYccXWAiDJhogWxOLWMfHI0nrP95kZXqh7LHnNFKdajOksb CZc= Date: Wed, 5 May 2021 22:22:18 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: David Laight CC: 'Florian Weimer' , "Alejandro Colomar (man-pages)" , linux-man , Daniel Borkmann , Greg KH , LKML , GCC , "Michael Kerrisk (man-pages)" , glibc , bpf , Alexei Starovoitov Subject: RE: [RFC v2] bpf.2: Use standard types and attributes In-Reply-To: Message-ID: References: <20210423230609.13519-1-alx.manpages@gmail.com> <20210504110519.16097-1-alx.manpages@gmail.com> <69fb22e0-84bd-47fb-35b5-537a7d39c692@gmail.com> <6740a229-842e-b368-86eb-defc786b3658@gmail.com> <87r1imgu5g.fsf@oldenburg.str.redhat.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 5 May 2021, David Laight via Libc-alpha wrote: > > __u64 can't be formatted with %llu on all architectures. That's not > > true for uint64_t, where you have to use %lu on some architectures to > > avoid compiler warnings (and technically undefined behavior). There are > > preprocessor macros to get the expected format specifiers, but they are > > clunky. I don't know if the problem applies to uint32_t. It does > > happen with size_t and ptrdiff_t on 32-bit targets (both vary between > > int and long). > > uint32_t can be 'randomly' either int or long on typical 32bit architectures. > The correct way to print it is with eg "xxx %5.4" PRI_u32 " yyy". C2X adds printf length modifiers such as "w32", so you can use a friendlier %w32u, for example. (Not yet implemented in glibc or in GCC's format checking.) -- Joseph S. Myers joseph@codesourcery.com