Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4024848imw; Thu, 7 Jul 2022 11:21:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1veUczw3UhM90Bxo4htEYYgK89MD1jMKRr2BQp6zYPZ3Na4C6Gwxfz8mV1vjGql8Mm4V+2J X-Received: by 2002:a17:902:ef4f:b0:16b:8744:6c5f with SMTP id e15-20020a170902ef4f00b0016b87446c5fmr52742116plx.60.1657218118672; Thu, 07 Jul 2022 11:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657218118; cv=none; d=google.com; s=arc-20160816; b=h1u+UR/ONJ6ewHe0RWEgqFhukzzOCrHpxRO48q1pebtlQCX/3fMxBLhAiwLCE6Skoi kzpbGq4m48YQa2kEQ532hKaiYPx2cxlu8cgkvdv1/0wk3D/uTGZ9HbgJVXwxyLC/M/WJ /skP33Qa+I/Tj43iJS6dEnLWqJpiqc9Dcd71paYWP/1UuQ6zbspXt9vX7gS8AggcH/eb 0QOW4TPZf5iaiOgys+qNXtzpIA2s2tLh/19zyKal5yDsS5qES4v7826I29UuCBTNoGce VqSBLd7UkShrKWBVsN6s36ttwvHre8HqRhpcfCqr2HlCcdjwgE7e8UJ1ckVXVPdIDAwI nRbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=UFJkgdkNMH3aWMIofTNStOt1Q6h+X1VsvJJ67z/A/RY=; b=Rdaghj4VwJyE4So+IFyMpBEG91kQSZ91ZpJfgkJpQi9a+/xv0wN3/sCntFPSoTowFL R94kbygbi+w3jRl6130o4uvNjyeEpmL6GhTCo1v1PY23dbsfFLg2tThwegzLbPqTWAv7 IAsYqCOE8Ld9o3YP8dQeMOfpbA+ZlGMW8YK7k89VThfR71Ja8JrAM7Pd9sbbuRWYN1TG MAne5lFWyX0nWFAwPeXP6CRCDToI4HcfpqdfzY8A8xdvVucZ8CqOHTDZZx1IX+4UCjUJ CQcV0rWuHnHP3Y+t+HxPvcyNUkFg/mKngheyhs/SdOPwluNvoo71nVQyYjFnXaNwygbI iLPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t75-20020a635f4e000000b00412b29016eesi4851914pgb.260.2022.07.07.11.21.47; Thu, 07 Jul 2022 11:21:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235546AbiGGSBf convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Jul 2022 14:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235422AbiGGSBe (ORCPT ); Thu, 7 Jul 2022 14:01:34 -0400 Received: from relay5.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113B126132 for ; Thu, 7 Jul 2022 11:01:33 -0700 (PDT) Received: from omf11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 1B3526101C; Thu, 7 Jul 2022 18:01:31 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA id E45E020037; Thu, 7 Jul 2022 18:01:27 +0000 (UTC) Message-ID: Subject: Re: [PATCH] net: ipv4: fix clang -Wformat warning From: Joe Perches To: Justin Stitt Cc: Steffen Klassert , Herbert Xu , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor , Nick Desaulniers , Tom Rix , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Date: Thu, 07 Jul 2022 11:01:26 -0700 In-Reply-To: References: <20220707173040.704116-1-justinstitt@google.com> <6f5a1c04746feb04add15107c70332ac603e4561.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.1-0ubuntu1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_NONE,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Stat-Signature: 9hji8x14hjnfib6t8mqzghy4hgmidssk X-Rspamd-Server: rspamout05 X-Rspamd-Queue-Id: E45E020037 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+YCj/8yCY3yEUbxnuMVC5Ve/GvPfwKDhc= X-HE-Tag: 1657216887-660842 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2022-07-07 at 10:47 -0700, Justin Stitt wrote: > On Thu, Jul 7, 2022 at 10:40 AM Joe Perches wrote: > > > > On Thu, 2022-07-07 at 10:30 -0700, Justin Stitt wrote: > > > When building with Clang we encounter this warning: > > > > net/ipv4/ah4.c:513:4: error: format specifies type 'unsigned short' but > > > > the argument has type 'int' [-Werror,-Wformat] > > > > aalg_desc->uinfo.auth.icv_fullbits / 8); > > > > > > `aalg_desc->uinfo.auth.icv_fullbits` is a u16 but due to default > > > argument promotion becomes an int. > > > > > > Variadic functions (printf-like) undergo default argument promotion. > > > Documentation/core-api/printk-formats.rst specifically recommends using > > > the promoted-to-type's format flag. > > > > > > As per C11 6.3.1.1: > > > (https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1548.pdf) `If an int > > > can represent all values of the original type ..., the value is > > > converted to an int; otherwise, it is converted to an unsigned int. > > > These are called the integer promotions.` Thus it makes sense to change > > > %hu to %d not only to follow this standard but to suppress the warning > > > as well. > > > > I think it also makes sense to use %u and not %d > > as the original type is unsigned. > Yeah, that would also work. An integer (even a signed one) fully > encompasses a u16 so it's really a choice of style. Do you think the > change to %u warrants a v2 of this patch? As it's rather odd output to use '%u != %d', probably. Your patch, up to you. > > > > > diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c > > [] > > > @@ -507,7 +507,7 @@ static int ah_init_state(struct xfrm_state *x) > > > > > > if (aalg_desc->uinfo.auth.icv_fullbits/8 != > > > crypto_ahash_digestsize(ahash)) { > > > - pr_info("%s: %s digestsize %u != %hu\n", > > > + pr_info("%s: %s digestsize %u != %d\n", > > > __func__, x->aalg->alg_name, > > > crypto_ahash_digestsize(ahash), > > > aalg_desc->uinfo.auth.icv_fullbits / 8); > >