DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Morten Brørup" <mb@smartsharesystems.com>
To: "Bruce Richardson" <bruce.richardson@intel.com>, <dev@dpdk.org>
Cc: "Huisong Li" <lihuisong@huawei.com>,
	"Chengwen Feng" <fengchengwen@huawei.com>
Subject: RE: [PATCH] telemetry: rework code to avoid compiler warnings
Date: Wed, 8 Feb 2023 16:00:49 +0100	[thread overview]
Message-ID: <98CBD80474FA8B44BF855DF32C47DC35D87717@smartserver.smartshare.dk> (raw)
In-Reply-To: <20230208143742.493533-1-bruce.richardson@intel.com>

> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Wednesday, 8 February 2023 15.38
> To: dev@dpdk.org
> Cc: Huisong Li; Chengwen Feng; Morten Brørup; Bruce Richardson
> Subject: [PATCH] telemetry: rework code to avoid compiler warnings
> 
> 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 <bruce.richardson@intel.com>
> ---

Beautiful.

Acked-by: Morten Brørup <mb@smartsharesystems.com>


  reply	other threads:[~2023-02-08 15:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-08 14:37 Bruce Richardson
2023-02-08 15:00 ` Morten Brørup [this message]
2023-02-08 15:05 ` Wiles, Keith
2023-02-09  1:07 ` fengchengwen
2023-02-09  2:03   ` lihuisong (C)
2023-02-09  7:45 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=98CBD80474FA8B44BF855DF32C47DC35D87717@smartserver.smartshare.dk \
    --to=mb@smartsharesystems.com \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=lihuisong@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).