summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Kempczyński <zbigniew.kempczynski@intel.com>2020-09-11 10:07:50 +0200
committerChris Wilson <chris@chris-wilson.co.uk>2020-09-16 14:15:27 +0100
commit7906d212bfcba8710fa1330032b8b299be4d842c (patch)
tree25d86e04ba55077d6fc49473c50172e666cbb53a
parenta324199fbeb7687811e79512ed9927a44c20b58e (diff)
lib/intel_batchbuffer: address review comments (base64 dump)
Simplify base64 dump + add linelen. Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com> Cc: Dominik Grzegorzek <dominik.grzegorzek@intel.com> Cc: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--lib/intel_batchbuffer.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 8aa6de76..be764646 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -1958,8 +1958,7 @@ static void intel_bb_dump_execbuf(struct intel_bb *ibb,
}
}
-#define LINELEN 76
-static void intel_bb_dump_base64(struct intel_bb *ibb)
+static void intel_bb_dump_base64(struct intel_bb *ibb, int linelen)
{
int outsize;
gchar *str, *pos;
@@ -1968,18 +1967,12 @@ static void intel_bb_dump_base64(struct intel_bb *ibb)
pos = str = g_base64_encode((const guchar *) ibb->batch, ibb->size);
outsize = strlen(str);
- while (pos) {
- char line[LINELEN + 1];
- int to_copy = min(LINELEN, outsize);
-
- memcpy(line, pos, to_copy);
- line[to_copy] = 0;
- igt_info("%s\n", line);
- pos += LINELEN;
- outsize -= to_copy;
- if (outsize == 0)
- break;
+ while (outsize > 0) {
+ igt_info("%.*s\n", min(outsize, linelen), pos);
+ pos += linelen;
+ outsize -= linelen;
}
+
free(str);
}
@@ -2031,6 +2024,7 @@ static void update_offsets(struct intel_bb *ibb,
}
}
+#define LINELEN 76
/*
* @__intel_bb_exec:
* @ibb: pointer to intel_bb
@@ -2070,7 +2064,7 @@ int __intel_bb_exec(struct intel_bb *ibb, uint32_t end_offset,
execbuf.rsvd2 = 0;
if (ibb->dump_base64)
- intel_bb_dump_base64(ibb);
+ intel_bb_dump_base64(ibb, LINELEN);
ret = __gem_execbuf_wr(ibb->i915, &execbuf);
if (ret) {