Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1031472imw; Fri, 8 Jul 2022 17:05:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tqoRT1ogAw8r9Y+xtYsGYMQFhdzMOTvPuzzEt0HZ26pmEDHPNbs5kfGow90Jk3YxsR4bOf X-Received: by 2002:aa7:8054:0:b0:528:9ace:a78a with SMTP id y20-20020aa78054000000b005289acea78amr5959390pfm.49.1657325150994; Fri, 08 Jul 2022 17:05:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657325150; cv=none; d=google.com; s=arc-20160816; b=O53LE2cZq+SAXR0MQXb5haEB5sLX8teovleLBjxuLDeHzg1c3Ne1Sh9FK9en2PX8fJ mj3+3Rj7IDeiaHJGSOCDza3HvN4rdj4e9Cw+5RThX0dfnyVcfWr2NlZt38BFHNfsep8t dIFBsRr+kzHb/NxBDRZe0hD+U/1YI9Wpuao9ivE5vULhQnDwf6PdQHLG+lfQV1Oy2Ow+ n69uXfFudzJStvFXU7Ispuiasw9M8E1H+nbVGCG/T7VSyyOgnpVlO0FZUeonYyET30Re hwdeGNLsypDfQlaZTnq9HV2xnvw25Xx6Timu2mINNptDOlDUnpEMPx8dB83NK0h+w8cn xWzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pv/kMkRXLTmjNlh49xKQLUzHkabn6pqCOnhb5uu/n7E=; b=SykJWxhZoWXmyLtGEW+oXfWkWp2UonidJhfcX3t9W8IhjENWhWxSX0C+0FeupElQiz n0l9ESwpd1dUa/LZjnJmHVNc4ZMbd5fWxhyXu1QkZMxoDCe/sMMqhl9GbUp56JFOW5vO 4fRm2Pp/1O/lAIEVhDK1cQlMeQX80Sg4AcmoCVP0IKrQoTamV1ciOUSCSToaf9DBirIR vfFt7B13O96Y4W5BoT8KeNN71UnuYJrmsGmTtFReP7Ek9ZAKpSkKafXoQdci4wC3Ks6P z0Vi1xKZ5asqZdZ/7Lt8DSJuSUckR1/pFMu79M7IHJ7tmoMvzD7efgaj5076AvzVb/6W H0vQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Iqd/944B"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638b49000000b004159dcfc650si81886pge.674.2022.07.08.17.05.39; Fri, 08 Jul 2022 17:05:50 -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; dkim=pass header.i=@google.com header.s=20210112 header.b="Iqd/944B"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229379AbiGHXsR (ORCPT + 99 others); Fri, 8 Jul 2022 19:48:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiGHXsP (ORCPT ); Fri, 8 Jul 2022 19:48:15 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34CDDA79F7 for ; Fri, 8 Jul 2022 16:48:13 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id u13so176385lfn.5 for ; Fri, 08 Jul 2022 16:48:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pv/kMkRXLTmjNlh49xKQLUzHkabn6pqCOnhb5uu/n7E=; b=Iqd/944B5JiBG7p6ksdmO0GUZ4qrnQMi/cOZtevlIaX7we0yVtFSiQV6u/gVu87PVu iSdor1XOrotUAnhOBPJnkHwpepagsDEG7xfH1y7+7UwJnJHrhiBpn0rqcXVAv/btO3ko t/fEV8xFM8pDS3IaDHC5dcc6c4kMMjBwu8a7Pk4HB0XtW03UwVqZ0acr6lq97X7/9MSn OMtrHoVJgmuF8/yNZnpIA9Ko+0UDIRksYUoZE0w5bgsaI68L0hszdNPHfh2zTm+Ll9Vi ycVv4QI8zAXSdOBrYxfw3A5x3VjJnvrw49gQM+Eh+dFXuNmCY8NK0u5F5M3HFGYNuyT9 eTbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pv/kMkRXLTmjNlh49xKQLUzHkabn6pqCOnhb5uu/n7E=; b=ppcR65Tp2KNt5vrbsJwyPz22k0T5bOa88MY/9CZpr/HVWxosV6t+ylm7eky9BdYzkJ 4IK6udNnO/sKMF7UERW6aWWvKIhCfBXg/IU83olFogqX5snT8Ao2Ghnyn2sCVEyQBrzJ KYz8Ysz0d2XMFnk6227La53qZzW6WPQbYcWHR8gTbFulhsa9kr+bPH4G3Jv63ZWWAL0k zLulcfLAnz8JN+S+DDK27SOizpx/hZSmAWuP4FOyG0Bqc5vX7hrgSlouuopZTnsMQUxq T8Cf8apYUagT8VRl/kIlsvZaF1hRY3gZwb/8VD4n12YUNQ8bW/IYfK14ryHofrh89yS1 jmHw== X-Gm-Message-State: AJIora+w3/c9Z7ERAdfZ/CeX/AhcZmysMdMjayT2Y9JLSSO45VKrd6DA 8fPpPllm4wn4FQgjAGZQ5rQdDYM0Ge2g0noFIr3EPA== X-Received: by 2002:a05:6512:2623:b0:47d:ace7:c804 with SMTP id bt35-20020a056512262300b0047dace7c804mr3937905lfb.647.1657324091178; Fri, 08 Jul 2022 16:48:11 -0700 (PDT) MIME-Version: 1.0 References: <20220708232653.556488-1-justinstitt@google.com> In-Reply-To: <20220708232653.556488-1-justinstitt@google.com> From: Nick Desaulniers Date: Fri, 8 Jul 2022 16:47:59 -0700 Message-ID: Subject: Re: [PATCH] amd-xgbe: fix clang -Wformat warnings To: Justin Stitt Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Tom Lendacky , Nathan Chancellor , Tom Rix , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 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 Fri, Jul 8, 2022 at 4:27 PM Justin Stitt wrote: > > When building with Clang we encounter the following warning: > | drivers/net/ethernet/amd/xgbe/xgbe-dcb.c:234:42: error: format specifies > | type 'unsigned char' but the argument has type '__u16' (aka 'unsigned > | short') [-Werror,-Wformat] pfc->pfc_cap, pfc->pfc_en, pfc->mbc, > | pfc->delay); > > pfc->pfc_cap , pfc->pfc_cn, pfc->mbc are all of type `u8` while pfc->delay is > of type `u16`. The correct format specifiers `%hh[u|x]` were used for > the first three but not for pfc->delay, which is causing the warning > above. > > Variadic functions (printf-like) undergo default argument promotion. > Documentation/core-api/printk-formats.rst specifically recommends using > the promoted-to-type's format flag. In this case `%d` (or `%x` to > maintain hex representation) should be used since both u8's and u16's > are fully representable by an int. > > Moreover, C11 6.3.1.1 states: > (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.` > > Link: https://github.com/ClangBuiltLinux/linux/issues/378 > Signed-off-by: Justin Stitt Thanks for the patch, this fixes an instance of -Wformat I observe for x86_64 allmodconfig. I thought you had already fixed this file up? https://lore.kernel.org/llvm/20220607191119.20686-1-jstitt007@gmail.com/ which was merged. I'm guessing that was from a defconfig, while this was from an allmodconfig? Seems like there's a bunch of config ifdef'ery around the definition of netif_dbg. Either way, thanks for the patches and Reviewed-by: Nick Desaulniers Tested-by: Nick Desaulniers > --- > For clarification, the first three parameters given to netif_dbg did NOT > cause a -Wformat warning. I changed them simply to follow what the > standard and documentation recommend. > > drivers/net/ethernet/amd/xgbe/xgbe-dcb.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c > index 895d35639129..c68ace804e37 100644 > --- a/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c > +++ b/drivers/net/ethernet/amd/xgbe/xgbe-dcb.c > @@ -230,7 +230,7 @@ static int xgbe_dcb_ieee_setpfc(struct net_device *netdev, > struct xgbe_prv_data *pdata = netdev_priv(netdev); > > netif_dbg(pdata, drv, netdev, > - "cap=%hhu, en=%#hhx, mbc=%hhu, delay=%hhu\n", > + "cap=%d, en=%#x, mbc=%d, delay=%d\n", > pfc->pfc_cap, pfc->pfc_en, pfc->mbc, pfc->delay); > > /* Check PFC for supported number of traffic classes */ > -- > 2.37.0.rc0.161.g10f37bed90-goog > -- Thanks, ~Nick Desaulniers