@samitouri / QOSamiQemu / commits / a048b4e796

hxtool: Split srst/erst add checks

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: Thomas Huth <thuth@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20260504174914.122607-3-dave@treblig.org> Signed-off-by: Markus Armbruster <armbru@redhat.com>

Dr. David Alan Gilbert committed May 4, 2026 at 18:49 UTC a048b4e7966699865e228a22f27b0b427389f7fe
1 file changed +17 -3
scripts/hxtool
+17 -3
@@ -2,15 +2,29 @@
2
3 hxtoh()
4 {
5 - flag=1
5 + in_rst=0
6 while read -r str; do
7 case $str in
8 HXCOMM*)
9 ;;
10 - SRST*|ERST*) flag=$(($flag^1))
10 + SRST*)
11 + if [ $in_rst -eq 1 ]
12 + then
13 + echo "Error: SRST inside another RST" >&2
14 + exit 1
15 + fi
16 + in_rst=1
17 + ;;
18 + ERST*)
19 + if [ $in_rst -eq 0 ]
20 + then
21 + echo "Error: ERST already outside RST" >&2
22 + exit 1
23 + fi
24 + in_rst=0
25 ;;
26 *)
13 - test $flag -eq 1 && printf "%s\n" "$str"
27 + test $in_rst -eq 0 && printf "%s\n" "$str"
28 ;;
29 esac
30 done