[PATCH v2 3/4] hxtool: Split srst/erst add checks

dave@treblig.org posted 4 patches 3 weeks, 1 day ago
Maintainers: "Dr. David Alan Gilbert" <dave@treblig.org>
[PATCH v2 3/4] hxtool: Split srst/erst add checks
Posted by dave@treblig.org 3 weeks, 1 day ago
From: "Dr. David Alan Gilbert" <dave@treblig.org>

Split the SRST/ERST case and add some checks.
This is mainly to make it easier to add some checks in following
patches.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
---
 scripts/hxtool | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/scripts/hxtool b/scripts/hxtool
index 80516b9437..51dc841479 100755
--- a/scripts/hxtool
+++ b/scripts/hxtool
@@ -2,15 +2,29 @@
 
 hxtoh()
 {
-    flag=1
+    in_rst=0
     while read -r str; do
         case $str in
             HXCOMM*)
             ;;
-            SRST*|ERST*) flag=$(($flag^1))
+            SRST*)
+              if [ $in_rst -eq 1 ]
+              then
+                echo "Error: SRST inside another RST" >&2
+                exit 1
+              fi
+              in_rst=1
+            ;;
+            ERST*)
+              if [ $in_rst -eq 0 ]
+              then
+                echo "Error: ERST already outside RST" >&2
+                exit 1
+              fi
+              in_rst=0
             ;;
             *)
-            test $flag -eq 1 && printf "%s\n" "$str"
+            test $in_rst -eq 0 && printf "%s\n" "$str"
             ;;
         esac
     done
-- 
2.52.0
Re: [PATCH v2 3/4] hxtool: Split srst/erst add checks
Posted by Markus Armbruster 3 weeks ago
dave@treblig.org writes:

> From: "Dr. David Alan Gilbert" <dave@treblig.org>
>
> Split the SRST/ERST case and add some checks.
> This is mainly to make it easier to add some checks in following
> patches.
>
> Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>

Reviewed-by: Markus Armbruster <armbru@redhat.com>
Re: [PATCH v2 3/4] hxtool: Split srst/erst add checks
Posted by Thomas Huth 3 weeks ago
On 16/01/2026 01.50, dave@treblig.org wrote:
> From: "Dr. David Alan Gilbert" <dave@treblig.org>
> 
> Split the SRST/ERST case and add some checks.
> This is mainly to make it easier to add some checks in following
> patches.
> 
> Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>
> ---
>   scripts/hxtool | 20 +++++++++++++++++---
>   1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/hxtool b/scripts/hxtool
> index 80516b9437..51dc841479 100755
> --- a/scripts/hxtool
> +++ b/scripts/hxtool
> @@ -2,15 +2,29 @@
>   
>   hxtoh()
>   {
> -    flag=1
> +    in_rst=0
>       while read -r str; do
>           case $str in
>               HXCOMM*)
>               ;;
> -            SRST*|ERST*) flag=$(($flag^1))
> +            SRST*)
> +              if [ $in_rst -eq 1 ]
> +              then
> +                echo "Error: SRST inside another RST" >&2
> +                exit 1
> +              fi
> +              in_rst=1
> +            ;;
> +            ERST*)
> +              if [ $in_rst -eq 0 ]
> +              then
> +                echo "Error: ERST already outside RST" >&2
> +                exit 1
> +              fi
> +              in_rst=0
>               ;;
>               *)
> -            test $flag -eq 1 && printf "%s\n" "$str"
> +            test $in_rst -eq 0 && printf "%s\n" "$str"
>               ;;
>           esac
>       done

Reviewed-by: Thomas Huth <thuth@redhat.com>