[PATCH i-g-t v2 2/4] lib/intel_bufops: Use printf style filename formatting
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Mar 6 15:02:17 UTC 2024
Dumping to png where we want to pass width, height and/or other
values is much easier when we use printf style filename formatting
instead preparing string with filename separately. Replace current
write to raw png from single string to string formatting.
Cc: Matthew Auld <matthew.auld at intel.com>
Reviewed-by: Matthew Auld <matthew.auld at intel.com>
Link: https://lore.kernel.org/r/20240305054056.139691-3-zbigniew.kempczynski@intel.com
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
lib/intel_bufops.c | 14 +++++++++++++-
lib/intel_bufops.h | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 5e2701a7dc..e45b17b0a8 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -1367,9 +1367,21 @@ static void __intel_buf_raw_write_to_png(struct buf_ops *bops,
munmap(linear, buf->bo_size);
}
-void intel_buf_raw_write_to_png(struct intel_buf *buf, const char *filename)
+__attribute__((format(printf, 2, 3)))
+void intel_buf_raw_write_to_png(struct intel_buf *buf, const char *namefmt, ...)
{
+ char *filename;
+ int ret;
+ va_list ap;
+
+ va_start(ap, namefmt);
+ ret = vasprintf(&filename, namefmt, ap);
+ igt_assert(ret >= 0);
+ va_end(ap);
+
__intel_buf_raw_write_to_png(buf->bops, buf, filename);
+
+ free(filename);
}
static void *alloc_aligned(uint64_t size)
diff --git a/lib/intel_bufops.h b/lib/intel_bufops.h
index 363f7abaad..828ed7be9d 100644
--- a/lib/intel_bufops.h
+++ b/lib/intel_bufops.h
@@ -221,7 +221,7 @@ const char *intel_buf_set_name(struct intel_buf *buf, const char *name);
void intel_buf_write_to_png(struct intel_buf *buf, const char *filename);
void intel_buf_write_aux_to_png(struct intel_buf *buf, const char *filename);
-void intel_buf_raw_write_to_png(struct intel_buf *buf, const char *filename);
+void intel_buf_raw_write_to_png(struct intel_buf *buf, const char *namefmt, ...);
void intel_buf_draw_pattern(struct buf_ops *bops, struct intel_buf *buf,
int x, int y, int w, int h,
int cx, int cy, int cw, int ch,
--
2.34.1
More information about the igt-dev
mailing list