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 0FB7041C45; Thu, 9 Feb 2023 02:07:19 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E304840DDA; Thu, 9 Feb 2023 02:07:18 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 3EC174067B for ; Thu, 9 Feb 2023 02:07:17 +0100 (CET) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4PBzF86wBdzJrLW; Thu, 9 Feb 2023 09:05:32 +0800 (CST) Received: from [10.67.100.224] (10.67.100.224) by dggpeml500024.china.huawei.com (7.185.36.10) 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 09:07:14 +0800 Subject: Re: [PATCH] telemetry: rework code to avoid compiler warnings To: Bruce Richardson , CC: Huisong Li , =?UTF-8?Q?Morten_Br=c3=b8rup?= References: <20230208143742.493533-1-bruce.richardson@intel.com> From: fengchengwen Message-ID: Date: Thu, 9 Feb 2023 09:07:14 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0 MIME-Version: 1.0 In-Reply-To: <20230208143742.493533-1-bruce.richardson@intel.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.100.224] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpeml500024.china.huawei.com (7.185.36.10) 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 Beatutiful +1 Acked-by: Chengwen Feng 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 > --- ...