[PATCH 2/3] xen/misra: xen-analysis.py: Fix latent bug

Luca Fancellu posted 3 patches 1 year, 1 month ago
[PATCH 2/3] xen/misra: xen-analysis.py: Fix latent bug
Posted by Luca Fancellu 1 year, 1 month ago
Currenly there is a latent bug that is not triggered because
the function cppcheck_merge_txt_fragments is called with the
parameter strip_paths having a list of only one element.

The bug is that the split function should not be in the
loop for strip_paths, but one level before, fix it.

Fixes: 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/scripts/xen_analysis/cppcheck_report_utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/scripts/xen_analysis/cppcheck_report_utils.py b/xen/scripts/xen_analysis/cppcheck_report_utils.py
index c5f466aff141..fdc299c7e029 100644
--- a/xen/scripts/xen_analysis/cppcheck_report_utils.py
+++ b/xen/scripts/xen_analysis/cppcheck_report_utils.py
@@ -104,8 +104,8 @@ def cppcheck_merge_txt_fragments(fragments_list, out_txt_file, strip_paths):
                 for path in strip_paths:
                     text_report_content[i] = text_report_content[i].replace(
                                                                 path + "/", "")
-                    # Split by : separator
-                    text_report_content[i] = text_report_content[i].split(":")
+                # Split by : separator
+                text_report_content[i] = text_report_content[i].split(":")
 
             # sort alphabetically for second field (misra rule) and as second
             # criteria for the first field (file name)
-- 
2.34.1
Re: [PATCH 2/3] xen/misra: xen-analysis.py: Fix latent bug
Posted by Jan Beulich 1 year ago
On 19.05.2023 11:30, Luca Fancellu wrote:
> Currenly there is a latent bug that is not triggered because
> the function cppcheck_merge_txt_fragments is called with the
> parameter strip_paths having a list of only one element.
> 
> The bug is that the split function should not be in the
> loop for strip_paths, but one level before, fix it.
> 
> Fixes: 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>

Just wanted to mention it: I've committed the patch as is, but in
the future could you please try to find slightly more specific a
title for such a change? The way it is now, someone going over
just the titles in the log will have no clue at all what kind of
bug was addressed here.

Jan
Re: [PATCH 2/3] xen/misra: xen-analysis.py: Fix latent bug
Posted by Luca Fancellu 1 year ago

> On 30 May 2023, at 11:32, Jan Beulich <jbeulich@suse.com> wrote:
> 
> On 19.05.2023 11:30, Luca Fancellu wrote:
>> Currenly there is a latent bug that is not triggered because
>> the function cppcheck_merge_txt_fragments is called with the
>> parameter strip_paths having a list of only one element.
>> 
>> The bug is that the split function should not be in the
>> loop for strip_paths, but one level before, fix it.
>> 
>> Fixes: 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
>> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
> 
> Just wanted to mention it: I've committed the patch as is, but in
> the future could you please try to find slightly more specific a
> title for such a change? The way it is now, someone going over
> just the titles in the log will have no clue at all what kind of
> bug was addressed here.

Sure, I will be more specific in the future, thank you

> 
> Jan
Re: [PATCH 2/3] xen/misra: xen-analysis.py: Fix latent bug
Posted by Stefano Stabellini 1 year ago
On Fri, 19 May 2023, Luca Fancellu wrote:
> Currenly there is a latent bug that is not triggered because
> the function cppcheck_merge_txt_fragments is called with the
> parameter strip_paths having a list of only one element.
> 
> The bug is that the split function should not be in the
> loop for strip_paths, but one level before, fix it.
> 
> Fixes: 02b26c02c7c4 ("xen/scripts: add cppcheck tool to the xen-analysis.py script")
> Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>

Acked-by: Stefano Stabellini <sstabellini@kernel.org>
Tested-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/scripts/xen_analysis/cppcheck_report_utils.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/xen/scripts/xen_analysis/cppcheck_report_utils.py b/xen/scripts/xen_analysis/cppcheck_report_utils.py
> index c5f466aff141..fdc299c7e029 100644
> --- a/xen/scripts/xen_analysis/cppcheck_report_utils.py
> +++ b/xen/scripts/xen_analysis/cppcheck_report_utils.py
> @@ -104,8 +104,8 @@ def cppcheck_merge_txt_fragments(fragments_list, out_txt_file, strip_paths):
>                  for path in strip_paths:
>                      text_report_content[i] = text_report_content[i].replace(
>                                                                  path + "/", "")
> -                    # Split by : separator
> -                    text_report_content[i] = text_report_content[i].split(":")
> +                # Split by : separator
> +                text_report_content[i] = text_report_content[i].split(":")
>  
>              # sort alphabetically for second field (misra rule) and as second
>              # criteria for the first field (file name)
> -- 
> 2.34.1
>