From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTPS id 0D4C53858C39 for ; Fri, 19 Nov 2021 13:11:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0D4C53858C39 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-585-AJ4f2BX1PPaLdqYwx2gZmA-1; Fri, 19 Nov 2021 08:11:48 -0500 X-MC-Unique: AJ4f2BX1PPaLdqYwx2gZmA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3FFAA84F209; Fri, 19 Nov 2021 13:11:47 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.131]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C472660BF1; Fri, 19 Nov 2021 13:11:45 +0000 (UTC) From: Florian Weimer To: Cyril Hrubis Cc: linux-api@vger.kernel.org, ltp@lists.linux.it, libc-alpha@sourceware.org Subject: Re: asm-generic/int-ll64.h wrongly used on x86_64? References: Date: Fri, 19 Nov 2021 14:11:43 +0100 In-Reply-To: (Cyril Hrubis's message of "Fri, 19 Nov 2021 13:38:06 +0100") Message-ID: <877dd4cmsw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham 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: Fri, 19 Nov 2021 13:11:56 -0000 * Cyril Hrubis: > Hi! > I was writing simple userspace code that prints the values from the > struct statx the line in question looks like: > > printf("%" PRIu64 "\n", st.stx_size); > > This unexpectedly gives me warning on x86_64: > > warning: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type '__u64' {aka 'long long unsigned int'} The correct format depends on whether you use struct statx from the glibc headers or the Linux UAPI headers. glibc uses uint64_t, Linux uses __u64. uint64_t in glibc prefers unsigned long if the type is 64-bit, Linux uses unsigned long long unconditionally. One solution is to use %ju and cast to (uintmax_t). Other cast-based approaches are possible as well. I'm not happy with the situation because those casts reduce type safety and may suppress relevant compiler warnings. Thanks, Florian