[Intel-gfx] [PATCH 3/4] lib/igt_* Use igt macros in igt libaries

Daniel Vetter daniel.vetter at ffwll.ch
Tue Aug 26 19:36:13 CEST 2014


Except in igt_core since that would lead to some hilarious recursions.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 lib/igt_aux.c     |  9 ++++-----
 lib/igt_debugfs.c | 14 +++++++-------
 lib/igt_kms.c     | 43 ++++++++++++++++++-------------------------
 3 files changed, 29 insertions(+), 37 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 3357f1f09942..5ddc8b610895 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -233,7 +233,7 @@ void igt_progress(const char *header, uint64_t i, uint64_t total)
 		return;
 
 	if (i+1 >= total) {
-		fprintf(stderr, "\r%s100%%\n", header);
+		igt_warn("\r%s100%%\n", header);
 		return;
 	}
 
@@ -241,10 +241,9 @@ void igt_progress(const char *header, uint64_t i, uint64_t total)
 		divider = 1;
 
 	/* only bother updating about every 0.5% */
-	if (i % (total / divider) == 0 || i+1 >= total) {
-		fprintf(stderr, "\r%s%3llu%%", header,
-			(long long unsigned) i * 100 / total);
-	}
+	igt_warn_on_f(i % (total / divider) == 0 || i + 1 >= total,
+		      "\r%s%3llu%%", header,
+		      (long long unsigned)i * 100 / total);
 }
 
 /* mappable aperture trasher helper */
diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index f6f509dd1875..123cf13e9b22 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -200,10 +200,10 @@ bool igt_crc_is_null(igt_crc_t *crc)
 	int i;
 
 	for (i = 0; i < crc->n_words; i++) {
-		if (crc->crc[i] == 0xffffffff)
-			igt_warn("Suspicious CRC: it looks like the CRC "
-				 "read back was from a register in a powered "
-				 "down well\n");
+		igt_warn_on_f(crc->crc[i] == 0xffffffff,
+			      "Suspicious CRC: it looks like the CRC "
+			      "read back was from a register in a powered "
+			      "down well\n");
 		if (crc->crc[i])
 			return false;
 	}
@@ -731,7 +731,7 @@ void igt_set_stop_rings(enum stop_ring_flags flags)
 
 	stop_rings_write(flags);
 	current = igt_get_stop_rings();
-	if (current != flags)
-		igt_warn("i915_ring_stop readback mismatch 0x%x vs 0x%x\n",
-			 flags, current);
+	igt_warn_on_f(current != flags,
+		      "i915_ring_stop readback mismatch 0x%x vs 0x%x\n",
+		      flags, current);
 }
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a414d960d24b..0497042eac0c 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -202,23 +202,15 @@ void kmstest_dump_mode(drmModeModeInfo *mode)
 {
 	const char *stereo = mode_stereo_name(mode);
 
-	printf("  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d%s%s%s\n",
-	       mode->name,
-	       mode->vrefresh,
-	       mode->hdisplay,
-	       mode->hsync_start,
-	       mode->hsync_end,
-	       mode->htotal,
-	       mode->vdisplay,
-	       mode->vsync_start,
-	       mode->vsync_end,
-	       mode->vtotal,
-	       mode->flags,
-	       mode->type,
-	       mode->clock,
-	       stereo ? " (3D:" : "",
-	       stereo ? stereo : "",
-	       stereo ? ")" : "");
+	igt_info("  %s %d %d %d %d %d %d %d %d %d 0x%x 0x%x %d%s%s%s\n",
+		 mode->name, mode->vrefresh,
+		 mode->hdisplay, mode->hsync_start,
+		 mode->hsync_end, mode->htotal,
+		 mode->vdisplay, mode->vsync_start,
+		 mode->vsync_end, mode->vtotal,
+		 mode->flags, mode->type, mode->clock,
+		 stereo ? " (3D:" : "",
+		 stereo ? stereo : "", stereo ? ")" : "");
 	fflush(stdout);
 }
 
@@ -438,8 +430,8 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 	int i;
 
 	if (!connector->count_modes) {
-		fprintf(stderr, "no modes for connector %d\n",
-			connector->connector_id);
+		igt_warn("no modes for connector %d\n",
+			 connector->connector_id);
 		return false;
 	}
 
@@ -476,7 +468,7 @@ bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 
 	resources = drmModeGetResources(drm_fd);
 	if (!resources) {
-		perror("drmModeGetResources failed");
+		igt_warn("drmModeGetResources failed");
 		goto err1;
 	}
 
@@ -489,13 +481,13 @@ bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 		goto err3;
 
 	if (!connector->count_modes) {
-		fprintf(stderr, "connector %d has no modes\n", connector_id);
+		igt_warn("connector %d has no modes\n", connector_id);
 		goto err3;
 	}
 
 	if (connector->connector_id != connector_id) {
-		fprintf(stderr, "connector id doesn't match (%d != %d)\n",
-			connector->connector_id, connector_id);
+		igt_warn("connector id doesn't match (%d != %d)\n",
+			 connector->connector_id, connector_id);
 		goto err3;
 	}
 
@@ -515,8 +507,9 @@ bool kmstest_get_connector_config(int drm_fd, uint32_t connector_id,
 						    connector->encoders[j]);
 
 			if (!encoder) {
-				fprintf(stderr, "could not get encoder %d: %s\n",
-					resources->encoders[j], strerror(errno));
+				igt_warn("could not get encoder %d: %s\n",
+					 resources->encoders[j],
+					 strerror(errno));
 
 				continue;
 			}
-- 
2.0.1




More information about the Intel-gfx mailing list