> From: Bruce Richardson [mailto:bruce.richard...@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.richard...@intel.com> > ---
Beautiful. Acked-by: Morten Brørup <m...@smartsharesystems.com>