]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
s390x: In s390_disasm_aux - simplify control flow a bit.
authorFlorian Krohm <flo2030@eich-krohm.de>
Fri, 11 Apr 2025 11:55:24 +0000 (11:55 +0000)
committerFlorian Krohm <flo2030@eich-krohm.de>
Fri, 11 Apr 2025 11:55:24 +0000 (11:55 +0000)
VEX/priv/s390_disasm.c

index 139e1419909191dc3150f722c551c5da5241d2e3..0b03c14edd29b2ac20dd8b76e4f85bb097c29f22 100644 (file)
@@ -1093,14 +1093,11 @@ s390_disasm_aux(const s390_opnd *opnds, const HChar *xmnm, HChar *p,
    vassert(opnds[0].kind == S390_OPND_MNM ||
            opnds[0].kind == S390_OPND_XMNM);
 
-   Int separator = 0;
+   Int write_separator = 0;   // no separator after mnemonic
 
    for (UInt ix = 0; opnds[ix].kind != S390_OPND_DONE; ++ix) {
       const s390_opnd *opnd = opnds + ix;
 
-      if (ix > 1 && separator)
-         *p++ = ',';
-
       switch (opnd->kind) {
       case S390_OPND_MNM:
          p += vex_sprintf(p, "%s", padmnm(opnd->mnm));
@@ -1132,13 +1129,9 @@ s390_disasm_aux(const s390_opnd *opnds, const HChar *xmnm, HChar *p,
          UInt value;
          if (mh && mh(ix, opnd->mask, &value))
             p += vex_sprintf(p, "%u", value);
-         else {
-            if (ix != 1)
-               (*--p) = '\0';   // overwrite the separator
-            else
-               separator = 0;
-         }
-         continue;  // *not* break
+         else
+            write_separator = 0;
+         break;
       }
 
       case S390_OPND_UINT:
@@ -1204,8 +1197,14 @@ s390_disasm_aux(const s390_opnd *opnds, const HChar *xmnm, HChar *p,
          break;
       }
 
-      separator = ',';
+      if (write_separator)
+         *p++ = ',';
+      write_separator = 1;
    }
+
+   if (p[-1] == ',')    // remove trailing separator, if any
+      *--p = '\0';
+
    return p;
 }