[PATCH] Two branches in a conditional structure should not have exactly the same implementation

dinglimin posted 1 patch 1 year, 7 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220916021500.1311-1-dinglimin@cmss.chinamobile.com
There is a newer version of this series
scripts/apibuild.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH] Two branches in a conditional structure should not have exactly the same implementation
Posted by dinglimin 1 year, 7 months ago
Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
---
 scripts/apibuild.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/apibuild.py b/scripts/apibuild.py
index c232b4e2c8..5993318490 100755
--- a/scripts/apibuild.py
+++ b/scripts/apibuild.py
@@ -1248,10 +1248,8 @@ class CParser:
                                token[1] == "," or token[1] == "="):
                                 self.index_add_ref(oldtok[1], self.filename,
                                                    0, "type")
-                    elif oldtok[0] == "name" and oldtok[1][0:4] == "XEN_":
-                        self.index_add_ref(oldtok[1], self.filename,
-                                           0, "typedef")
-                    elif oldtok[0] == "name" and oldtok[1][0:7] == "LIBXEN_":
+                    elif oldtok[0] == "name" and (oldtok[1][0:4] == "XEN_" or
+                          oldtok[1][0:7] == "LIBXEN_"):
                         self.index_add_ref(oldtok[1], self.filename,
                                            0, "typedef")
 
-- 
2.30.0.windows.2
Re: [PATCH] Two branches in a conditional structure should not have exactly the same implementation
Posted by Peter Krempa 1 year, 7 months ago
On Fri, Sep 16, 2022 at 10:15:00 +0800, dinglimin wrote:

Please don't write all of your patch's description into the summary line
and also make sure to follow the established formatting we have for
almost all patches.

> Signed-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
> ---
>  scripts/apibuild.py | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/scripts/apibuild.py b/scripts/apibuild.py
> index c232b4e2c8..5993318490 100755
> --- a/scripts/apibuild.py
> +++ b/scripts/apibuild.py
> @@ -1248,10 +1248,8 @@ class CParser:
>                                 token[1] == "," or token[1] == "="):
>                                  self.index_add_ref(oldtok[1], self.filename,
>                                                     0, "type")
> -                    elif oldtok[0] == "name" and oldtok[1][0:4] == "XEN_":
> -                        self.index_add_ref(oldtok[1], self.filename,
> -                                           0, "typedef")
> -                    elif oldtok[0] == "name" and oldtok[1][0:7] == "LIBXEN_":
> +                    elif oldtok[0] == "name" and (oldtok[1][0:4] == "XEN_" or
> +                          oldtok[1][0:7] == "LIBXEN_"):

Breaks syntax-check. Please always make sure to run the test-suite
before posting patches [1] :


/home/pipo/libvirt/scripts/apibuild.py:1252:27: E128 continuation line under-indented for visual indent
                          oldtok[1][0:7] == "LIBXEN_"):
                          ^


[1] https://www.libvirt.org/hacking.html#preparing-patches

>                          self.index_add_ref(oldtok[1], self.filename,
>                                             0, "typedef")
>  
> -- 
> 2.30.0.windows.2

If running the test suite is problematic in your setup you can also fork
libvirt on gitlab and push into your private fork, which triggers the CI
pipeline.