[v2,1/7] app/procinfo: fix redundant condition

Message ID 20201118114525.99053-2-ferruh.yigit@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series cppcheck |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ferruh Yigit Nov. 18, 2020, 11:45 a.m. UTC
  '_filters' is compared twice, second one will be always false, removing
it using the message more relevant to the '_filters'.

Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 app/proc-info/main.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

David Marchand Nov. 18, 2020, 2:10 p.m. UTC | #1
On Wed, Nov 18, 2020 at 12:46 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>
> '_filters' is compared twice, second one will be always false, removing
> it using the message more relevant to the '_filters'.
>
> Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
> Cc: stable@dpdk.org
>
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>  app/proc-info/main.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/app/proc-info/main.c b/app/proc-info/main.c
> index d743209f0d..35e5b596eb 100644
> --- a/app/proc-info/main.c
> +++ b/app/proc-info/main.c
> @@ -420,11 +420,9 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
>         } else if ((type_end != NULL) &&
>                    (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
>                 if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
> -                       strlcpy(cnt_type, "operations", cnt_type_len);
> +                       strlcpy(cnt_type, "filter_result", cnt_type_len);

Do you know what impact this change of type could have?
  
Ferruh Yigit Nov. 19, 2020, 9:34 a.m. UTC | #2
On 11/18/2020 2:10 PM, David Marchand wrote:
> On Wed, Nov 18, 2020 at 12:46 PM Ferruh Yigit <ferruh.yigit@intel.com> wrote:
>>
>> '_filters' is compared twice, second one will be always false, removing
>> it using the message more relevant to the '_filters'.
>>
>> Fixes: 2deb6b5246d7 ("app/procinfo: add collectd format and host id")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>>   app/proc-info/main.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/app/proc-info/main.c b/app/proc-info/main.c
>> index d743209f0d..35e5b596eb 100644
>> --- a/app/proc-info/main.c
>> +++ b/app/proc-info/main.c
>> @@ -420,11 +420,9 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
>>          } else if ((type_end != NULL) &&
>>                     (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
>>                  if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
>> -                       strlcpy(cnt_type, "operations", cnt_type_len);
>> +                       strlcpy(cnt_type, "filter_result", cnt_type_len);
> 
> Do you know what impact this change of type could have?
> 

Since the default behavior is changing it has potential to impact it's users but 
I don't know.

"_filters" stat was searched twice and type were set "operations" & 
"filter_result" respectively, I unified it to one and selected "filter_result" 
which seems more relevant.
  

Patch

diff --git a/app/proc-info/main.c b/app/proc-info/main.c
index d743209f0d..35e5b596eb 100644
--- a/app/proc-info/main.c
+++ b/app/proc-info/main.c
@@ -420,11 +420,9 @@  static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len,
 	} else if ((type_end != NULL) &&
 		   (strncmp(cnt_name, "flow_", strlen("flow_"))) == 0) {
 		if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
-			strlcpy(cnt_type, "operations", cnt_type_len);
+			strlcpy(cnt_type, "filter_result", cnt_type_len);
 		else if (strncmp(type_end, "_errors", strlen("_errors")) == 0)
 			strlcpy(cnt_type, "errors", cnt_type_len);
-		else if (strncmp(type_end, "_filters", strlen("_filters")) == 0)
-			strlcpy(cnt_type, "filter_result", cnt_type_len);
 	} else if ((type_end != NULL) &&
 		   (strncmp(cnt_name, "mac_", strlen("mac_"))) == 0) {
 		if (strncmp(type_end, "_errors", strlen("_errors")) == 0)