[igt-dev] [PATCH i-g-t 2/8] lib/igt_frame: Move frame dump logging to function

Maxime Ripard maxime at cerno.tech
Tue Mar 8 15:21:35 UTC 2022


The igt_write_frame_to_png() has some logic to log into a text file the
path to the PNG file it will generate. Since we'll need it in a future
version, let's move it to a separate function.

Signed-off-by: Maxime Ripard <maxime at cerno.tech>
---
 lib/igt_frame.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/lib/igt_frame.c b/lib/igt_frame.c
index 03aeb24d6edb..530ccbc32df2 100644
--- a/lib/igt_frame.c
+++ b/lib/igt_frame.c
@@ -57,6 +57,18 @@ bool igt_frame_dump_is_enabled(void)
 	return igt_frame_dump_path != NULL;
 }
 
+static void igt_log_frame_path(int summary_fd, char *path)
+{
+	int index = strlen(path);
+
+	if (summary_fd >= 0 && index < (PATH_MAX - 1)) {
+		path[index++] = '\n';
+		path[index] = '\0';
+
+		write(summary_fd, path, strlen(path));
+	}
+}
+
 static void igt_write_frame_to_png(cairo_surface_t *surface, int summary_fd,
 				   const char *qualifier, const char *suffix)
 {
@@ -83,14 +95,7 @@ static void igt_write_frame_to_png(cairo_surface_t *surface, int summary_fd,
 
 	igt_assert_eq(status, CAIRO_STATUS_SUCCESS);
 
-	index = strlen(path);
-
-	if (summary_fd >= 0 && index < (PATH_MAX - 1)) {
-		path[index++] = '\n';
-		path[index] = '\0';
-
-		write(summary_fd, path, strlen(path));
-	}
+	igt_log_frame_path(summary_fd, path);
 }
 
 /**
-- 
2.35.1



More information about the igt-dev mailing list