From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2EC3341C45; Thu, 9 Feb 2023 03:03:46 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E9BE40DDA; Thu, 9 Feb 2023 03:03:46 +0100 (CET) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 260C44067B for ; Thu, 9 Feb 2023 03:03:44 +0100 (CET) Received: from kwepemm600004.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PC0Ww04D6zbnk4; Thu, 9 Feb 2023 10:03:23 +0800 (CST) Received: from [10.67.103.231] (10.67.103.231) by kwepemm600004.china.huawei.com (7.193.23.242) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 9 Feb 2023 10:03:41 +0800 Message-ID: Date: Thu, 9 Feb 2023 10:03:41 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH] telemetry: rework code to avoid compiler warnings To: Bruce Richardson , CC: =?UTF-8?Q?Morten_Br=c3=b8rup?= , fengchengwen References: <20230208143742.493533-1-bruce.richardson@intel.com> From: "lihuisong (C)" In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.67.103.231] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600004.china.huawei.com (7.193.23.242) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 在 2023/2/9 9:07, fengchengwen 写道: > Beatutiful +1 > > Acked-by: Chengwen Feng Perfect Tested-by: Huisong Li > > On 2023/2/8 22:37, Bruce Richardson wrote: >> When printing values as hex strings, the telemetry code temporarily >> disabled warnings about non-literal format strings. This was because the >> actual format string was built-up programmatically to ensure the output >> was of the desired bitwidth. >> >> However, this code can be reworked and shortened by taking advantage of >> the "*" printf flag, which is used to specify that the output width is >> given by a separate printf parameter. This allows the format to be a >> literal string in all cases, and also allows the code in the function to >> be shortened considerably. >> >> Note: the type of the width should be an "int" variable, which is why >> this patch changes the type of the existing variable. Also, while we >> could shorten the format string by using the "#" flag in place of an >> explicit "0x", this would make the code more confusing because it would >> mean that the "0x" would be included in the specified with, forcing us >> to add 2 to the existing computed width. >> >> Signed-off-by: Bruce Richardson >> --- > ... > .