poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] poke: fix .sub dot-command when no name specified


From: Jose E. Marchesi
Subject: [COMMITTED] poke: fix .sub dot-command when no name specified
Date: Sat, 15 Jul 2023 13:25:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

commit 1ffb8b816c01107aa15087d85878bbc4ca94ef50
Author: Jose E. Marchesi <jose.marchesi@oracle.com>
Date:   Sat Jul 15 13:22:57 2023 +0200

    poke: fix .sub dot-command when no name specified
    
    2023-07-15  Jose E. Marchesi  <jemarch@gnu.org>
    
            * poke/pk-cmd-ios.c (pk_cmd_sub): Avoid assert when no name is
            specified for the sub IO space.
            * testsuite/poke.cmd/sub-1.pk: New test.
            * testsuite/poke.cmd/sub-2.pk: Likewise.
            * testsuite/Makefile.am (EXTRA_DIST): Add new tests.

diff --git a/ChangeLog b/ChangeLog
index 200db0a9..618574b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-07-15  Jose E. Marchesi  <jemarch@gnu.org>
+
+       * poke/pk-cmd-ios.c (pk_cmd_sub): Avoid assert when no name is
+       specified for the sub IO space.
+       * testsuite/poke.cmd/sub-1.pk: New test.
+       * testsuite/poke.cmd/sub-2.pk: Likewise.
+       * testsuite/Makefile.am (EXTRA_DIST): Add new tests.
+
 2023-07-06  Mohammad-Reza Nabipoor  <mnabipoor@gnu.org>
 
        * libpoke/pkl-gen.pks (struct_mapper): Make sure `@field' is of
diff --git a/poke/pk-cmd-ios.c b/poke/pk-cmd-ios.c
index d93d533f..b73a85fb 100644
--- a/poke/pk-cmd-ios.c
+++ b/poke/pk-cmd-ios.c
@@ -84,12 +84,13 @@ pk_cmd_sub (int argc, struct pk_cmd_arg argv[], uint64_t 
uflags)
   assert (PK_CMD_ARG_TYPE (argv[3]) == PK_CMD_ARG_INT);
   size = PK_CMD_ARG_INT (argv[3]);
 
-  assert (PK_CMD_ARG_TYPE (argv[4]) == PK_CMD_ARG_STR);
-  name = PK_CMD_ARG_STR (argv[4]);
+  name = (PK_CMD_ARG_TYPE (argv[4]) == PK_CMD_ARG_STR
+          ? PK_CMD_ARG_STR (argv[4])
+          : NULL);
 
   /* Build the handler.  */
   if (asprintf (&handler, "sub://%d/0x%" PRIx64 "/0x%" PRIx64 "/%s",
-                ios, base, size, name) == -1)
+                ios, base, size, name ? name : "") == -1)
     return 0;
 
   /* Open the IOS.  */
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
index f888d4b3..22ea486e 100644
--- a/testsuite/Makefile.am
+++ b/testsuite/Makefile.am
@@ -130,6 +130,8 @@ EXTRA_DIST = \
   poke.cmd/set-oindent.pk \
   poke.cmd/set-omaps-1.pk \
   poke.cmd/set-omode.pk \
+  poke.cmd/sub-1.pk \
+  poke.cmd/sub-2.pk \
   poke.map/map.exp \
   poke.map/ass-map-1.pk \
   poke.map/ass-map-2.pk \
diff --git a/testsuite/poke.cmd/sub-1.pk b/testsuite/poke.cmd/sub-1.pk
new file mode 100644
index 00000000..216589cc
--- /dev/null
+++ b/testsuite/poke.cmd/sub-1.pk
@@ -0,0 +1,6 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40  0x50 0x60 0x70 0x80   0x90 0xa0 0xb0 
0xc0} } */
+
+/* { dg-command { .sub #0,0x2,0x5,sub1 } } */
+/* { dg-command { iohandler (1) } } */
+/* { dg-output "sub://0/0x2/0x5/sub1" } */
diff --git a/testsuite/poke.cmd/sub-2.pk b/testsuite/poke.cmd/sub-2.pk
new file mode 100644
index 00000000..7db87f3f
--- /dev/null
+++ b/testsuite/poke.cmd/sub-2.pk
@@ -0,0 +1,6 @@
+/* { dg-do run } */
+/* { dg-data {c*} {0x10 0x20 0x30 0x40  0x50 0x60 0x70 0x80   0x90 0xa0 0xb0 
0xc0} } */
+
+/* { dg-command { .sub #0,0x2,0x5 } } */
+/* { dg-command { iohandler (1) } } */
+/* { dg-output "sub://0/0x2/0x5/" } */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]