Print this page
patch fixup2

@@ -2476,16 +2476,25 @@
         [IF_SSf]        = fmt_ss_f,
         [IF_SSE]        = fmt_sse,
         [IF_SSF]        = fmt_ssf,
 };
 
-static int
+/*
+ * Even if we don't know how to disassemble the instruction, we know how long
+ * it is, so we always succeed.  That is why we can get away with returning
+ * void.
+ */
+static void
 dis_s390(uint64_t addr, union inst *inst, char *buf, size_t buflen, int mach)
 {
         const struct inst_table *tbl = &tbl_xx[inst->raw[0]];
         int tmp;
 
+        /* nothing to do */
+        if (buflen == 0)
+                return;
+
         while (tbl->it_fmt == IF_TBL || tbl->it_fmt == IF_MULTI) {
                 if (tbl->it_fmt == IF_TBL) {
                         int idx;
 
                         idx   = inst->raw[tbl->it_u.it_table.it_off];

@@ -2503,24 +2512,20 @@
 
         if ((tbl->it_u.it_inst.it_flags & mach) == 0)
                 goto inval;
 
         tmp = snprintf(buf, buflen, "%-7s ", tbl->it_u.it_inst.it_name);
+        if (tmp < 0)
+                return;
 
         fmt_fxns[tbl->it_fmt](addr, inst, buf + tmp, buflen - tmp,
             tbl->it_u.it_inst.it_flags);
 
-        return (0);
+        return;
 
 inval:
         (void) snprintf(buf, buflen, "??");
-
-        /*
-         * Even if we don't know how to disassemble the instruction, we know
-         * how long it is, so we "succeed" even when we fail.
-         */
-        return (0);
 }
 
 static int
 dis_s390_supports_flags(int flags)
 {

@@ -2560,11 +2565,13 @@
                 case DIS_S390_64:
                         mach = F_Z;
                         break;
         }
 
-        return (dis_s390(addr, &inst, buf, buflen, mach));
+        dis_s390(addr, &inst, buf, buflen, mach);
+
+        return (0);
 }
 
 /* ARGSUSED */
 static int
 dis_s390_min_instrlen(dis_handle_t *dhp)