[PATCH i-g-t 2/3] lib/kms: Simplify force_connectors[] error handling

Ville Syrjala ville.syrjala at linux.intel.com
Wed Apr 10 15:02:28 UTC 2024


From: Ville Syrjälä <ville.syrjala at linux.intel.com>

The failure to allocate a forced_connector entry is entirely
our own fault. If we hit this then we've screwd up and made
the array too small. Skip the error handling and just assert
that we must have enough room in the array.

Cc: Kunal Joshi <kunal1.joshi at intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 lib/igt_kms.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f7dd1db91827..19bb4ac66ece 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1518,8 +1518,7 @@ static struct igt_forced_connector *forced_connector_alloc(void)
 	for (i = 0; forced_connectors[i].connector_type; i++)
 		;
 
-	if (i >= ARRAY_SIZE(forced_connectors))
-		return NULL;
+	igt_assert_lt(i, ARRAY_SIZE(forced_connectors));
 
 	return &forced_connectors[i];
 }
@@ -1558,11 +1557,6 @@ static bool force_connector(int drm_fd,
 	}
 
 	c = forced_connector_alloc();
-	if (!c) {
-		igt_warn("Connector limit reached, %s will not be reset\n", name);
-		close(dir);
-		return true;
-	}
 
 	c->idx = idx;
 	c->connector_type = connector->connector_type;
-- 
2.43.2



More information about the igt-dev mailing list