Mesa (main): pan/bi: Fix format specifiers in disassembler

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 25 20:18:05 UTC 2021


Module: Mesa
Branch: main
Commit: c4b5921d5545e3bbfeb9f27765b1fc9a0a5cb875
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c4b5921d5545e3bbfeb9f27765b1fc9a0a5cb875

Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date:   Tue Aug 24 16:44:28 2021 -0400

pan/bi: Fix format specifiers in disassembler

Flagged by cppcheck.

Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12530>

---

 src/panfrost/bifrost/disassemble.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c
index 494c4c73f3b..1bc98e40596 100644
--- a/src/panfrost/bifrost/disassemble.c
+++ b/src/panfrost/bifrost/disassemble.c
@@ -75,7 +75,7 @@ struct bifrost_reg_ctrl {
 
 static void dump_header(FILE *fp, struct bifrost_header header, bool verbose)
 {
-        fprintf(fp, "ds(%du) ", header.dependency_slot);
+        fprintf(fp, "ds(%u) ", header.dependency_slot);
 
         if (header.staging_barrier)
                 fprintf(fp, "osrb ");
@@ -123,7 +123,7 @@ static void dump_header(FILE *fp, struct bifrost_header header, bool verbose)
                                 if (!first) {
                                         fprintf(fp, ", ");
                                 }
-                                fprintf(fp, "%d", i);
+                                fprintf(fp, "%u", i);
                                 first = false;
                         }
                 }
@@ -164,27 +164,27 @@ static void dump_regs(FILE *fp, struct bifrost_regs srcs, bool first)
         struct bifrost_reg_ctrl ctrl = DecodeRegCtrl(fp, srcs, first);
         fprintf(fp, "    # ");
         if (ctrl.read_reg0)
-                fprintf(fp, "slot 0: r%d ", get_reg0(srcs));
+                fprintf(fp, "slot 0: r%u ", get_reg0(srcs));
         if (ctrl.read_reg1)
-                fprintf(fp, "slot 1: r%d ", get_reg1(srcs));
+                fprintf(fp, "slot 1: r%u ", get_reg1(srcs));
 
         const char *slot3_fma = ctrl.slot23.slot3_fma ? "FMA" : "ADD";
 
         if (ctrl.slot23.slot2 == BIFROST_OP_WRITE)
-                fprintf(fp, "slot 2: r%d (write FMA) ", srcs.reg2);
+                fprintf(fp, "slot 2: r%u (write FMA) ", srcs.reg2);
         else if (ctrl.slot23.slot2 == BIFROST_OP_WRITE_LO)
-                fprintf(fp, "slot 2: r%d (write lo FMA) ", srcs.reg2);
+                fprintf(fp, "slot 2: r%u (write lo FMA) ", srcs.reg2);
         else if (ctrl.slot23.slot2 == BIFROST_OP_WRITE_HI)
-                fprintf(fp, "slot 2: r%d (write hi FMA) ", srcs.reg2);
+                fprintf(fp, "slot 2: r%u (write hi FMA) ", srcs.reg2);
         else if (ctrl.slot23.slot2 == BIFROST_OP_READ)
-                fprintf(fp, "slot 2: r%d (read) ", srcs.reg2);
+                fprintf(fp, "slot 2: r%u (read) ", srcs.reg2);
 
         if (ctrl.slot23.slot3 == BIFROST_OP_WRITE)
-                fprintf(fp, "slot 3: r%d (write %s) ", srcs.reg3, slot3_fma);
+                fprintf(fp, "slot 3: r%u (write %s) ", srcs.reg3, slot3_fma);
         else if (ctrl.slot23.slot3 == BIFROST_OP_WRITE_LO)
-                fprintf(fp, "slot 3: r%d (write lo %s) ", srcs.reg3, slot3_fma);
+                fprintf(fp, "slot 3: r%u (write lo %s) ", srcs.reg3, slot3_fma);
         else if (ctrl.slot23.slot3 == BIFROST_OP_WRITE_HI)
-                fprintf(fp, "slot 3: r%d (write hi %s) ", srcs.reg3, slot3_fma);
+                fprintf(fp, "slot 3: r%u (write hi %s) ", srcs.reg3, slot3_fma);
 
         if (srcs.fau_idx)
                 fprintf(fp, "fau %X ", srcs.fau_idx);
@@ -305,7 +305,7 @@ static void dump_fau_src(FILE *fp, struct bifrost_regs srcs, unsigned branch_off
 {
         if (srcs.fau_idx & 0x80) {
                 unsigned uniform = (srcs.fau_idx & 0x7f);
-                fprintf(fp, "u%d.w%d", uniform, high32);
+                fprintf(fp, "u%u.w%u", uniform, high32);
         } else if (srcs.fau_idx >= 0x20) {
                 unsigned idx = const_fau_to_idx(srcs.fau_idx >> 4);
                 uint64_t imm = consts->raw[idx];
@@ -366,13 +366,13 @@ dump_src(FILE *fp, unsigned src, struct bifrost_regs srcs, unsigned branch_offse
 {
         switch (src) {
         case 0:
-                fprintf(fp, "r%d", get_reg0(srcs));
+                fprintf(fp, "r%u", get_reg0(srcs));
                 break;
         case 1:
-                fprintf(fp, "r%d", get_reg1(srcs));
+                fprintf(fp, "r%u", get_reg1(srcs));
                 break;
         case 2:
-                fprintf(fp, "r%d", srcs.reg2);
+                fprintf(fp, "r%u", srcs.reg2);
                 break;
         case 3:
                 if (isFMA)
@@ -698,7 +698,7 @@ void disassemble_bifrost(FILE *fp, uint8_t *code, size_t size, bool verbose)
                 if (*words == 0)
                         break;
 
-                fprintf(fp, "clause_%d:\n", offset);
+                fprintf(fp, "clause_%u:\n", offset);
 
                 unsigned size;
                 dump_clause(fp, words, &size, offset, verbose);



More information about the mesa-commit mailing list