From: Florian Krohm Date: Fri, 11 Apr 2025 11:55:24 +0000 (+0000) Subject: s390x: In s390_disasm_aux - simplify control flow a bit. X-Git-Tag: VALGRIND_3_25_0~52 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=e4fa98e0eac13b9c1333711288af707cb4dccd10;p=thirdparty%2Fvalgrind.git s390x: In s390_disasm_aux - simplify control flow a bit. --- diff --git a/VEX/priv/s390_disasm.c b/VEX/priv/s390_disasm.c index 139e14199..0b03c14ed 100644 --- a/VEX/priv/s390_disasm.c +++ b/VEX/priv/s390_disasm.c @@ -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; }