summaryrefslogtreecommitdiff
path: root/libweston
diff options
context:
space:
mode:
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-04-03 13:33:26 +0300
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-09-25 12:07:05 +0300
commit1f21ef1df77fc105502cdad3b72f14bbf6ef4b9d (patch)
tree8b882ca8b938af021fb0d92f8dbecc1e16a38272 /libweston
parent13404c40161c6ca432c5fa24432c991bb7850a7a (diff)
compositor-drm: use asprintf in make_connector_name()
Gets rid of the constant size char array. While here, document the function. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Ian Ray <ian.ray@ge.com>
Diffstat (limited to 'libweston')
-rw-r--r--libweston/compositor-drm.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 1a961389..578ff9d6 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -2508,11 +2508,20 @@ static const char * const connector_type_names[] = {
#endif
};
+/** Create a name given a DRM connector
+ *
+ * \param con The DRM connector whose type and id form the name.
+ * \return A newly allocate string, or NULL on error. Must be free()'d
+ * after use.
+ *
+ * The name does not identify the DRM display device.
+ */
static char *
make_connector_name(const drmModeConnector *con)
{
- char name[32];
+ char *name;
const char *type_name = NULL;
+ int ret;
if (con->connector_type < ARRAY_LENGTH(connector_type_names))
type_name = connector_type_names[con->connector_type];
@@ -2520,9 +2529,11 @@ make_connector_name(const drmModeConnector *con)
if (!type_name)
type_name = "UNNAMED";
- snprintf(name, sizeof name, "%s-%d", type_name, con->connector_type_id);
+ ret = asprintf(&name, "%s-%d", type_name, con->connector_type_id);
+ if (ret < 0)
+ return NULL;
- return strdup(name);
+ return name;
}
static int