Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3990351imw; Thu, 7 Jul 2022 10:46:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vhptymVsQqEQRhnUdnT6snyDnHSRjyHv88IhR/0a3k37K7hX/4IURn1XNx66YwqId7UZW5 X-Received: by 2002:a17:907:7612:b0:72a:fb4b:5cf9 with SMTP id jx18-20020a170907761200b0072afb4b5cf9mr9007205ejc.463.1657215977954; Thu, 07 Jul 2022 10:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657215977; cv=none; d=google.com; s=arc-20160816; b=Xi7Rh+qKMtDD+7URSp7GhBs/U/xCyKYPp1KhpxuSVDjXNz3fhlk2DIBYZ64W7vjogl Bv8x43wMqhwgCWVAuI6A7xOpnNsAg3SAPgUfShvfO7XH8st+ielIWLX1Hs7nhbxiS1Sy 1IccA8tOyuGWupzUIpGyP2PbP2mjIHy4rwa+qBNo5JRlYPmef5Q8kXIriP5S0U2OmGvd x6uD1vrY3InEwAxjFtm1ozeAKGc442ACiyNwYNBc5IDC3IUXQiyGUMZVhF3RtOtkS0J3 Jm7sRluQbCnr3GhnkP5Qae7IQH9/dtRDqB4iEIk4uWfxUQpLRngf8zJz0wbfSbzbypPM 6QfQ== 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=CWTX2NDdTHl2objVHkXj+aC5hXn5d7mgcQKwW272UBM=; b=xSZSBnl3RzJUyj+o6E9MuOcSL7NeiOKv3wnXxdj06gWlJNYin6fLpwZCKwOc/CsDot Ce1WpXlxCSxiScfi3TyklI9/WttJwX0gvG1tN5SPhgMPFc5+FeVZzyaTeiTk7R9emo63 Q7EV73g6zSrw9RBSDe1xfkv8OaDC7ySkFY0zV3kAJFDP19NBhd5wKBz391YdUIGcJUUq Zxv91hDY3xNIeE+8OoA5kAfi04/KNbcpSeBP2kXAJizEe0wdRPa0VKN8NyTy3rPTn7Z+ sY4r/gOA028VQPy7JADwHR2HLzLDShHW7hXt8X+MRQtf6afXFUdZ4xQ7KFSNKy4hNfMt HofQ== 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 cw11-20020a170906478b00b00711efd98320si22017791ejc.241.2022.07.07.10.45.51; Thu, 07 Jul 2022 10:46:17 -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 S236559AbiGGRkp convert rfc822-to-8bit (ORCPT + 99 others); Thu, 7 Jul 2022 13:40:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbiGGRkg (ORCPT ); Thu, 7 Jul 2022 13:40:36 -0400 Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EF12237F1 for ; Thu, 7 Jul 2022 10:40:35 -0700 (PDT) Received: from omf08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 1E8C4203B6; Thu, 7 Jul 2022 17:40:33 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA id 065072002C; Thu, 7 Jul 2022 17:40:29 +0000 (UTC) Message-ID: <6f5a1c04746feb04add15107c70332ac603e4561.camel@perches.com> Subject: Re: [PATCH] net: ipv4: fix clang -Wformat warning From: Joe Perches To: Justin Stitt , Steffen Klassert , Herbert Xu , "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Nathan Chancellor , Nick Desaulniers , Tom Rix , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Date: Thu, 07 Jul 2022 10:40:29 -0700 In-Reply-To: <20220707173040.704116-1-justinstitt@google.com> References: <20220707173040.704116-1-justinstitt@google.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-Stat-Signature: x68hfi6hchp93cc8y3oo9c1sywe99651 X-Rspamd-Server: rspamout07 X-Rspamd-Queue-Id: 065072002C 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-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX19a/HDLIuVNWG7/7X2HRQkb389SoTBTrZA= X-HE-Tag: 1657215629-849573 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: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. > 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);