[v4,2/5] telemetry: fix repeat display when callback don't init dict

Message ID 20230120033456.29710-3-fengchengwen@huawei.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series support dmadev/ethdev stats reset |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

fengchengwen Jan. 20, 2023, 3:34 a.m. UTC
  When a telemetry callback doesn't initialize the telemetry data
structure and returns a non-negative number, the telemetry will repeat
to display the last result. This patch zero the data structure to avoid
the problem.

Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
Cc: stable@dpdk.org

Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/telemetry/telemetry.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Bruce Richardson Feb. 8, 2023, 2:15 p.m. UTC | #1
On Fri, Jan 20, 2023 at 03:34:53AM +0000, Chengwen Feng wrote:
> When a telemetry callback doesn't initialize the telemetry data
> structure and returns a non-negative number, the telemetry will repeat
> to display the last result. This patch zero the data structure to avoid
> the problem.
> 
> Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
>  lib/telemetry/telemetry.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
> index 8fbb4f3060..7b905355cd 100644
> --- a/lib/telemetry/telemetry.c
> +++ b/lib/telemetry/telemetry.c
> @@ -333,7 +333,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
>  static void
>  perform_command(telemetry_cb fn, const char *cmd, const char *param, int s)
>  {
> -	struct rte_tel_data data;
> +	struct rte_tel_data data = {0};
>  
>  	int ret = fn(cmd, param, &data);
>  	if (ret < 0) {
> -- 

Hi Chengwen,

this patch is not directly relevant to the rest of the patchset and is a
necessary fix. Can you perhaps submit this fix separately so it can be
merged, even when the rest of the patchset is looking for reviews?

Thanks,
/Bruce
  
fengchengwen Feb. 9, 2023, 1:33 a.m. UTC | #2
On 2023/2/8 22:15, Bruce Richardson wrote:
> On Fri, Jan 20, 2023 at 03:34:53AM +0000, Chengwen Feng wrote:
>> When a telemetry callback doesn't initialize the telemetry data
>> structure and returns a non-negative number, the telemetry will repeat
>> to display the last result. This patch zero the data structure to avoid
>> the problem.
>>
>> Fixes: 6dd571fd07c3 ("telemetry: introduce new functionality")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Chengwen Feng <fengchengwen@huawei.com>
>> Reviewed-by: Bruce Richardson <bruce.richardson@intel.com>
>> ---
>>  lib/telemetry/telemetry.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
>> index 8fbb4f3060..7b905355cd 100644
>> --- a/lib/telemetry/telemetry.c
>> +++ b/lib/telemetry/telemetry.c
>> @@ -333,7 +333,7 @@ output_json(const char *cmd, const struct rte_tel_data *d, int s)
>>  static void
>>  perform_command(telemetry_cb fn, const char *cmd, const char *param, int s)
>>  {
>> -	struct rte_tel_data data;
>> +	struct rte_tel_data data = {0};
>>  
>>  	int ret = fn(cmd, param, &data);
>>  	if (ret < 0) {
>> -- 
> 
> Hi Chengwen,
> 
> this patch is not directly relevant to the rest of the patchset and is a
> necessary fix. Can you perhaps submit this fix separately so it can be
> merged, even when the rest of the patchset is looking for reviews?

done, thanks.

> 
> Thanks,
> /Bruce
> 
> .
>
  

Patch

diff --git a/lib/telemetry/telemetry.c b/lib/telemetry/telemetry.c
index 8fbb4f3060..7b905355cd 100644
--- a/lib/telemetry/telemetry.c
+++ b/lib/telemetry/telemetry.c
@@ -333,7 +333,7 @@  output_json(const char *cmd, const struct rte_tel_data *d, int s)
 static void
 perform_command(telemetry_cb fn, const char *cmd, const char *param, int s)
 {
-	struct rte_tel_data data;
+	struct rte_tel_data data = {0};
 
 	int ret = fn(cmd, param, &data);
 	if (ret < 0) {