libweston: weston_output_init(..., +name)

Add 'name' argument to weston_output_init(). This is much more obvious
than the assert inside weston_output_init() to ensure the caller has set
a field in weston_output first.

Now weston_output_init() will strdup() the name itself, which means we
can drop a whole bunch of strdup()s in the backends. This matches
weston_output_destroy() which was already calling free() on the name.

All backends are slightly reordered to call weston_output_init() before
accessing any fields of weston_output, except the Wayland backend which
would make it a little awkward to do it in this patch. Mind, that
weston_output_init() still does not reset the struct to zero - it is
presumed the caller has done it, since weston_output is embedded in the
backend output structs.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ian Ray <ian.ray@ge.com>
Reviewed-by: David Fort <contact@hardening-consulting.com>
[Daniel: document name copying]
Acked-by Daniel Stone <daniels@collabora.com>
diff --git a/libweston/compositor-wayland.c b/libweston/compositor-wayland.c
index 1fb1be6..dee972c 100644
--- a/libweston/compositor-wayland.c
+++ b/libweston/compositor-wayland.c
@@ -1265,7 +1265,6 @@
 	output->base.destroy = wayland_output_destroy;
 	output->base.disable = wayland_output_disable;
 	output->base.enable = wayland_output_enable;
-	output->base.name = strdup(name);
 
 	return output;
 }
@@ -1278,7 +1277,7 @@
 	if (!output)
 		return -1;
 
-	weston_output_init(&output->base, compositor);
+	weston_output_init(&output->base, compositor, name);
 	weston_compositor_add_pending_output(&output->base, compositor);
 
 	return 0;
@@ -1354,7 +1353,7 @@
 		goto out;
 	}
 
-	weston_output_init(&output->base, b->compositor);
+	weston_output_init(&output->base, b->compositor, "wlparent");
 
 	output->base.scale = 1;
 	output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;
@@ -1393,7 +1392,7 @@
 	if (!output)
 		return -1;
 
-	weston_output_init(&output->base, b->compositor);
+	weston_output_init(&output->base, b->compositor, "wayland-fullscreen");
 
 	output->base.scale = 1;
 	output->base.transform = WL_OUTPUT_TRANSFORM_NORMAL;