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 ABDD041C49; Thu, 9 Feb 2023 08:45:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 98F6840DDA; Thu, 9 Feb 2023 08:45:45 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 191CD4067B for ; Thu, 9 Feb 2023 08:45:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675928743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=cUt4Kf1T4OCvep0UJLmn2kdbcxQVrEIGZLUD0JWHGNs=; b=EDZAonnp6JbXF1yaXEwuk8r4+2YF6FNvxMqXpgZ+c9VoA5tv04GF83QkElUwjyzLnWSBm5 PmpVw4a2sERzIWyYN4XfisxwqwNMiyKkrvfeO/Mz8I6mzz3SQj+CnIjNWLBGhIsuWb9A/H wKGwLFapYZcrxyfU5st6bxHHBdfwugs= Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-125-eZaDdt7OPk2fV2f-6lurbw-1; Thu, 09 Feb 2023 02:45:42 -0500 X-MC-Unique: eZaDdt7OPk2fV2f-6lurbw-1 Received: by mail-pl1-f199.google.com with SMTP id ji6-20020a170903324600b00199420887b0so894567plb.3 for ; Wed, 08 Feb 2023 23:45:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cUt4Kf1T4OCvep0UJLmn2kdbcxQVrEIGZLUD0JWHGNs=; b=BK7VQyM7uiLIw1UPFqEIjxhgndGfVunohP3zbVjS+80oi0r6Jawbjw7iVtehYc962L gKh5y3B2OXxS+BUzswP24APxoj8JuPNVz/VnjJumDNWfYFGYiwvuoZzHmzWjUBXh2PYX teY6FDJqK3mGnaT7GqZP96/TOrGanuIH53VLBK3ep+msOlpgm3NnnhyiQ6685WjUpdTX O+rOGdM6m8nc2dq+so4mHWJpqgUiJoN/bpDcMUDwUWUt0wrnyIUIqCyS67q0ZcyHDSHK iBEUeZmeg/QyaEW0oyzP6hAM+MnU+NB+z7+iDbmFRVJM3MPUy4SLf6MrpeZEOtmmDC9t LzeA== X-Gm-Message-State: AO0yUKXzEVY64y0JzmzGWt1wT2p7z5cB8bsAqixaMMVvRSthJ5+3lGIR 4PBbVhSWQTNL3HCca84s8fXz/LVf26aHR0j2OsPfZqzNuhV/wj4KhQhYlyHWtFvsZMHsBwYEJLO tO33UgajcAnDfxyS/Vvc= X-Received: by 2002:a17:90b:78a:b0:230:fd8a:de61 with SMTP id l10-20020a17090b078a00b00230fd8ade61mr1519713pjz.83.1675928741121; Wed, 08 Feb 2023 23:45:41 -0800 (PST) X-Google-Smtp-Source: AK7set/Qkd0YRhvgD0yCjLEaxSfaLCf62m+/Cvhp11YAT4zIdQ6Q68ld062T3fy1R+Znvx03ZGT+tbidLBjCvc4yeqs= X-Received: by 2002:a17:90b:78a:b0:230:fd8a:de61 with SMTP id l10-20020a17090b078a00b00230fd8ade61mr1519706pjz.83.1675928740862; Wed, 08 Feb 2023 23:45:40 -0800 (PST) MIME-Version: 1.0 References: <20230208143742.493533-1-bruce.richardson@intel.com> In-Reply-To: <20230208143742.493533-1-bruce.richardson@intel.com> From: David Marchand Date: Thu, 9 Feb 2023 08:45:29 +0100 Message-ID: Subject: Re: [PATCH] telemetry: rework code to avoid compiler warnings To: Bruce Richardson Cc: dev@dpdk.org, Huisong Li , Chengwen Feng , =?UTF-8?Q?Morten_Br=C3=B8rup?= X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" 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 On Wed, Feb 8, 2023 at 3:38 PM 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 Applied, thanks. -- David Marchand