Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1283520pxv; Fri, 25 Jun 2021 09:20:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPryU6JzVsHYSxoWgxCMlRzw6DEIOzScjfCcQxPjGQge6+5u1aqkyvvx1Bnajpc+0eeb0a X-Received: by 2002:a05:6638:2143:: with SMTP id z3mr10310794jaj.103.1624638038182; Fri, 25 Jun 2021 09:20:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624638038; cv=none; d=google.com; s=arc-20160816; b=Jwc6qTHKkDTnXTjEXYrCMlHUcJHUwDf2D3qJuqbvfiuzObWvb1UTpcvzwUUw0Vj3qz 4qTsKRahmPeK421E0asl9MdxQBuynDe8NwFAkDoK3Xi3UfNsLhoIY7bS8Wk4AtVL4UEs XgO/6Ft397cUcqe7T59PdUnYEVVNvn4T/HXRy7RtrMCE7bfnnnF045wEZPoA0IBMqnAD 3aS+iLYm1UzN2lhimtm1Tgx7OsL00enQDZVImT3RmzBzXbyiZgFcYTQHvO0II3YB1YCL 0RXjCgozq9bSx++Xs50M7anYZ5PVCrqZvWwq2Fsj/9/ZUpFU9U5sInezd2L/dpdCo5Ra Ue/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:dkim-signature:dkim-filter; bh=GXwzMqahWVrY5lhUBS+Ylk89C/7XJ7PWpUAttwGCH8E=; b=rIl7WKR45bP35OMo8wUfVu0fdsTP0/LP8598uNS6eSenw5Dn/KOzytvaTSZvAQM0VK wate9h3wWUOoOZXO1j8CDVyycUah3sixf1w0Ub4ydepLDuia45QGNXCmrIiQz3DAxy4b kwHSpZ+mHw9ATf9mIwuePju8tKzBuEtkf4u0gdrpqfg1Vmo7FWPc5imBmCISNOLNwRNR 0ltEriBeTQ6DuVRJmaVvy3af3f3vWv2yz+jXw7V4cYMC+YiAfAQglekHX+wYTDpK8ECN SwlblFf5LTK3UObtDFT8A+cug6SoiY8L6fY9tHU579pso/wadb81z/A5M04CejwplGIK +VRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@zytor.com header.s=2021052901 header.b=K+ku9mTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g9si7631737ilq.106.2021.06.25.09.20.25; Fri, 25 Jun 2021 09:20:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@zytor.com header.s=2021052901 header.b=K+ku9mTC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zytor.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbhFYQWP (ORCPT + 99 others); Fri, 25 Jun 2021 12:22:15 -0400 Received: from terminus.zytor.com ([198.137.202.136]:37927 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbhFYQWP (ORCPT ); Fri, 25 Jun 2021 12:22:15 -0400 Received: from [IPv6:2601:646:8602:8be1:493a:1894:bb79:383b] ([IPv6:2601:646:8602:8be1:493a:1894:bb79:383b]) (authenticated bits=0) by mail.zytor.com (8.16.1/8.15.2) with ESMTPSA id 15PGJkkS2433945 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NO); Fri, 25 Jun 2021 09:19:46 -0700 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.zytor.com 15PGJkkS2433945 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zytor.com; s=2021052901; t=1624637986; bh=GXwzMqahWVrY5lhUBS+Ylk89C/7XJ7PWpUAttwGCH8E=; h=Date:In-Reply-To:References:Subject:To:CC:From:From; b=K+ku9mTCiqHwOcY97VZvMVkuSiTtKg1CfvYWLA35kU8IwV1b6fZZzdlVpV/j2dxKn Ae6XrSiPR9AwIstna17qrlcQUmlqhLEeRe7x3mjUebr04DkXq7XsYGMRBrLWsnKbS7 tJgJOfybN0OIykf71Jlt3c6p1m11bzHN/03vXyQp0zo2NtQ5FtGHlOap4OiLSGMqLk pL7E5+3y+B/aoMr/buAKSgTCv0MNYY1/h1EaXajLEAlfWp/AiI3V7blqTtbx71hQ+m S4TOcEA8Q9ceECBKaR7yN+hITgBV/fwUx+n8+mfMBR64Vh5Mwdw40MZuedLLszYqNk WIGc+aUmp5RMA== Date: Fri, 25 Jun 2021 09:19:38 -0700 User-Agent: K-9 Mail for Android In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [RESEND PATCH] x86/tools/relocs: add __printf attribute to die() To: Borislav Petkov , Greg Kroah-Hartman CC: x86@kernel.org, Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org From: "H. Peter Anvin" Message-ID: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a user space build time tool=2E You can use PRIu32/64 or cast to unsigned long long; it's not like the per= formance for this case is going to matter one iota=2E On June 25, 2021 7:12:36 AM PDT, Borislav Petkov wrote: >On Fri, Jun 25, 2021 at 02:06:59PM +0200, Greg Kroah-Hartman wrote: >> Casting seems to be the only way to make this "quiet" that I can >tell=2E >>=20 >> Unless someone else has a good idea? > >Hmm, so in Documentation/core-api/printk-formats=2Erst we say that for >printk() with different size types, we should "use a format specifier >of >its largest possible type and explicitly cast to it=2E" > >And that kinda sounds ok to me because we don't potentially lose >through >the casting=2E > >IOW, I guess something like this below=2E > >--- >diff --git a/arch/x86/tools/relocs=2Ec b/arch/x86/tools/relocs=2Ec >index 04c5a44b9682=2E=2E42b0f425a2c7 100644 >--- a/arch/x86/tools/relocs=2Ec >+++ b/arch/x86/tools/relocs=2Ec >@@ -389,7 +389,7 @@ static void read_ehdr(FILE *fp) > Elf_Shdr shdr; >=20 > if (fseek(fp, ehdr=2Ee_shoff, SEEK_SET) < 0) >- die("Seek to %d failed: %s\n", ehdr=2Ee_shoff, strerror(errno)); >+ die("Seek to %lu failed: %s\n", (unsigned long)ehdr=2Ee_shoff, >strerror(errno)); >=20 > if (fread(&shdr, sizeof(shdr), 1, fp) !=3D 1) > die("Cannot read initial ELF section header: %s\n", >strerror(errno)); >@@ -412,17 +412,17 @@ static void read_shdrs(FILE *fp) >=20 > secs =3D calloc(shnum, sizeof(struct section)); > if (!secs) { >- die("Unable to allocate %d section headers\n", >+ die("Unable to allocate %ld section headers\n", > shnum); > } > if (fseek(fp, ehdr=2Ee_shoff, SEEK_SET) < 0) { >- die("Seek to %d failed: %s\n", >- ehdr=2Ee_shoff, strerror(errno)); >+ die("Seek to %lu failed: %s\n", >+ (unsigned long)ehdr=2Ee_shoff, strerror(errno)); > } > for (i =3D 0; i < shnum; i++) { > struct section *sec =3D &secs[i]; > if (fread(&shdr, sizeof(shdr), 1, fp) !=3D 1) >- die("Cannot read ELF section headers %d/%d: %s\n", >+ die("Cannot read ELF section headers %d/%ld: %s\n", > i, shnum, strerror(errno)); > sec->shdr=2Esh_name =3D elf_word_to_cpu(shdr=2Esh_name); > sec->shdr=2Esh_type =3D elf_word_to_cpu(shdr=2Esh_type); >@@ -450,12 +450,12 @@ static void read_strtabs(FILE *fp) > } > sec->strtab =3D malloc(sec->shdr=2Esh_size); > if (!sec->strtab) { >- die("malloc of %d bytes for strtab failed\n", >- sec->shdr=2Esh_size); >+ die("malloc of %lu bytes for strtab failed\n", >+ (unsigned long)sec->shdr=2Esh_size); > } > if (fseek(fp, sec->shdr=2Esh_offset, SEEK_SET) < 0) { >- die("Seek to %d failed: %s\n", >- sec->shdr=2Esh_offset, strerror(errno)); >+ die("Seek to %lu failed: %s\n", >+ (unsigned long)sec->shdr=2Esh_offset, strerror(errno)); > } > if (fread(sec->strtab, 1, sec->shdr=2Esh_size, fp) > !=3D sec->shdr=2Esh_size) { >@@ -475,12 +475,12 @@ static void read_symtabs(FILE *fp) > } > sec->symtab =3D malloc(sec->shdr=2Esh_size); > if (!sec->symtab) { >- die("malloc of %d bytes for symtab failed\n", >- sec->shdr=2Esh_size); >+ die("malloc of %lu bytes for symtab failed\n", >+ (unsigned long)sec->shdr=2Esh_size); > } > if (fseek(fp, sec->shdr=2Esh_offset, SEEK_SET) < 0) { >- die("Seek to %d failed: %s\n", >- sec->shdr=2Esh_offset, strerror(errno)); >+ die("Seek to %lu failed: %s\n", >+ (unsigned long)sec->shdr=2Esh_offset, strerror(errno)); > } > if (fread(sec->symtab, 1, sec->shdr=2Esh_size, fp) > !=3D sec->shdr=2Esh_size) { >@@ -508,12 +508,12 @@ static void read_relocs(FILE *fp) > } > sec->reltab =3D malloc(sec->shdr=2Esh_size); > if (!sec->reltab) { >- die("malloc of %d bytes for relocs failed\n", >- sec->shdr=2Esh_size); >+ die("malloc of %lu bytes for relocs failed\n", >+ (unsigned long)sec->shdr=2Esh_size); > } > if (fseek(fp, sec->shdr=2Esh_offset, SEEK_SET) < 0) { >- die("Seek to %d failed: %s\n", >- sec->shdr=2Esh_offset, strerror(errno)); >+ die("Seek to %lu failed: %s\n", >+ (unsigned long)sec->shdr=2Esh_offset, strerror(errno)); > } > if (fread(sec->reltab, 1, sec->shdr=2Esh_size, fp) > !=3D sec->shdr=2Esh_size) { >diff --git a/arch/x86/tools/relocs=2Eh b/arch/x86/tools/relocs=2Eh >index 43c83c0fd22c=2E=2E4c49c82446eb 100644 >--- a/arch/x86/tools/relocs=2Eh >+++ b/arch/x86/tools/relocs=2Eh >@@ -17,6 +17,7 @@ > #include > #include >=20 >+__attribute__((__format__(printf, 1, 2))) > void die(char *fmt, =2E=2E=2E) __attribute__((noreturn)); >=20 > #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) --=20 Sent from my Android device with K-9 Mail=2E Please excuse my brevity=2E