Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3246414imw; Mon, 18 Jul 2022 04:56:25 -0700 (PDT) X-Google-Smtp-Source: AGRyM1siaa1h0rMMoDbAMlJBXW6v289UKnyzBD3U+Dr8IWUs7aBhYYlw3lqnj/114g3toANwZesw X-Received: by 2002:a05:6402:35d4:b0:43a:df89:94e2 with SMTP id z20-20020a05640235d400b0043adf8994e2mr37375036edc.149.1658145384915; Mon, 18 Jul 2022 04:56:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658145384; cv=none; d=google.com; s=arc-20160816; b=GqeqRghL4/E0QTEABdbM9FToBdYa1p+gZyVeJYuS3rPz807nlUKNFQxC9iDEJzpTsg tVGFNXowEgBJraKiqR1lX/SDAspmFVfZJFIje7VvXEa4L+BF1avrEDJII4i+B7OyZfPE vCOevF6mymMScxV325A6IPqzUXPDRS+Ploy+9PZLXdTdy8A6rmbaUuWA+rseQ9GXw8Y+ XweysnB9jQuOpz4bZUW/KZGQjyItcq7wxQfElzb734H5+ZvNXg/Q/xzNY30z3QgES0ZU GjLF2FDJuXCeU3BIFXTsz4QRnLlREs7mkBLVmE0mKIoEj1oNq/mAnSZdr+BWukum25tQ 5N3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dkim-signature; bh=muns5i3N4GWLuWCPo/1wFXyzGgs1LfHaK1f53fXYY0Y=; b=NyaQOo41objhOtJnQTjCsFzaOj2HBaPCmm3qpMrb2RVUAiYyFT13wMjxkvFAYD9jYM BEmDHvfaHwnBerGrrK6PKvB3rF7vT3Mb9IecfcWlHNtpDDKnhf1iux4u8rkleWIK5ifT gPvZGNJDU/eCDKPVbzOE0XqK5GqOmu7GDMOhRrIXV4p5QpmEsFTcxmiSxYrUcvF+4QoO I1qVxbkLt+XPQlq9sJU7fuRJsXCffby8qCW2x4ffuhRoWczrY5nYGW/1qR4eilZe004G rY/D/mteleWt5gJF5XBcblUwBasMCF4nMHv9vX03JiICMKqiSSg/eoSW4Uiq8ijCqeQC IT8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LyhqHG+1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e22-20020a17090658d600b0072f25c0af43si6414898ejs.576.2022.07.18.04.56.07; Mon, 18 Jul 2022 04:56:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@kernel.org header.s=k20201202 header.b=LyhqHG+1; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234000AbiGRLyg (ORCPT + 65 others); Mon, 18 Jul 2022 07:54:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230182AbiGRLyf (ORCPT ); Mon, 18 Jul 2022 07:54:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D0962C1; Mon, 18 Jul 2022 04:54:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B91636143D; Mon, 18 Jul 2022 11:54:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90053C341C0; Mon, 18 Jul 2022 11:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1658145272; bh=JO1/+51IzIqWlRVWa3wn637GFpPwLMpOLbdkHlx7z6s=; h=Subject:From:In-Reply-To:References:To:Cc:Date:From; b=LyhqHG+1nHgHhSWyS0qNHxtwg2KvdDfaLkocSe8qQpmPpduziHZ2lrRXhKkLOyq9r DXnLHnYom0JqG0h1Kyx5UjCBFoE6Hil+1Bw4Ihe/CLl8/k3AJqnMdXnoGr14BRnKfa 3LGFydaAbvOfagpqm9rZEbVWcsWNEhqpWbzkEFaDvq0BocuJBw00UUajV4zhqENzbL ijtdjZqzrZ/F4hDItOADXSFs6Cp1jtY1godjsymHtLIqRz2DzXCAuqiim95HV0y21w fFslpygl9J3WkEBeU+qwUwk7qoBa1pH62ehtVrpOJvXNEIZJOmIclJ/6RaMNtBG7VX uZAzVyGyQVq7w== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: wifi: mt7601u: fix clang -Wformat warning From: Kalle Valo In-Reply-To: <20220711212932.1501592-1-justinstitt@google.com> References: <20220711212932.1501592-1-justinstitt@google.com> To: Justin Stitt Cc: Jakub Kicinski , "David S . Miller" , Eric Dumazet , Paolo Abeni , Matthias Brugger , Nathan Chancellor , Nick Desaulniers , Tom Rix , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Justin Stitt User-Agent: pwcli/0.1.1-git (https://github.com/kvalo/pwcli/) Python/3.7.3 Message-ID: <165814526751.17539.17204768341511432544.kvalo@kernel.org> Date: Mon, 18 Jul 2022 11:54:29 +0000 (UTC) X-Spam-Status: No, score=-5.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,URI_DOTEDU 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-wireless@vger.kernel.org Justin Stitt wrote: > When building with Clang we encounter this warning: > | drivers/net/wireless/mediatek/mt7601u/debugfs.c:92:6: error: format > | specifies type 'unsigned char' but the argument has type 'int' > | [-Werror,-Wformat] dev->ee->reg.start + dev->ee->reg.num - 1); > > The format specifier used is `%hhu` which describes a u8. Both > `dev->ee->reg.start` and `.num` are u8 as well. However, the expression > as a whole is promoted to an int as you cannot get smaller-than-int from > addition. Therefore, to fix the warning, use the promoted-to-type's > format specifier -- in this case `%d`. > > example: > ``` > uint8_t a = 4, b = 7; > int size = sizeof(a + b - 1); > printf("%d\n", size); > // output: 4 > ``` > > See more: > (https://wiki.sei.cmu.edu/confluence/display/c/INT02-C.+Understand+integer+conversion+rules) > "Integer types smaller than int are promoted when an operation is > performed on them. If all values of the original type can be represented > as an int, the value of the smaller type is converted to an int; > otherwise, it is converted to an unsigned int." > > Signed-off-by: Justin Stitt > Acked-by: Jakub Kicinski Patch applied to wireless-next.git, thanks. 68204a696505 wifi: mt7601u: fix clang -Wformat warning -- https://patchwork.kernel.org/project/linux-wireless/patch/20220711212932.1501592-1-justinstitt@google.com/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches