summaryrefslogtreecommitdiff
path: root/lib/igt_chamelium.c
diff options
context:
space:
mode:
authorSimon Ser <simon.ser@intel.com>2019-06-19 10:49:58 +0300
committerSimon Ser <simon.ser@intel.com>2019-07-19 10:52:58 +0300
commitc002f3ef5a51b27df0f28e8a64a7a5381aa2e158 (patch)
treeeb004a681478851b719886e4fc022dca21231766 /lib/igt_chamelium.c
parent043dae641dd5b2d403eda0a94da9a4d81ebff244 (diff)
lib/igt_chamelium: add CHAMELIUM_MAX_PORTS
We will always be able to find an upper bound for the number of connectors supported by a Chamelium board. Instead of using dynamic arrays, simplify the code by using static ones. More code will need to have arrays of ports in the future. Signed-off-by: Simon Ser <simon.ser@intel.com> Reviewed-by: Arkadiusz Hiler <arkadiusz.hiler@intel.com>
Diffstat (limited to 'lib/igt_chamelium.c')
-rw-r--r--lib/igt_chamelium.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 7198df63..2a49bf56 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -121,7 +121,7 @@ struct chamelium {
int drm_fd;
struct igt_list edids;
- struct chamelium_port *ports;
+ struct chamelium_port ports[CHAMELIUM_MAX_PORTS];
int port_count;
};
@@ -1804,11 +1804,9 @@ static bool chamelium_read_port_mappings(struct chamelium *chamelium,
if (strstr(group_list[i], "Chamelium:"))
chamelium->port_count++;
}
+ igt_assert(chamelium->port_count <= CHAMELIUM_MAX_PORTS);
- chamelium->ports = calloc(sizeof(struct chamelium_port),
- chamelium->port_count);
port_i = 0;
-
for (i = 0; group_list[i] != NULL; i++) {
group = group_list[i];
@@ -2008,7 +2006,6 @@ void chamelium_deinit(struct chamelium *chamelium)
for (i = 0; i < chamelium->port_count; i++)
free(chamelium->ports[i].name);
- free(chamelium->ports);
free(chamelium);
}