[PATCH] compositor-drm: pass only const strings as backend parameters
Quentin Glidic
sardemff7+wayland at sardemff7.net
Wed May 25 07:46:57 UTC 2016
On 24/05/2016 18:50, Giulio Camuffo wrote:
> This makes more clear that the backend doesn't take ownership
> of the data and it makes the API more usable.
>
> Signed-off-by: Giulio Camuffo <giuliocamuffo at gmail.com>
Good idea, but one little flaw.
> ---
> src/compositor-drm.h | 10 +++++-----
> src/main.c | 18 ++++++++++++------
> 2 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/src/compositor-drm.h b/src/compositor-drm.h
> index 3f150db..24f60f8 100644
> --- a/src/compositor-drm.h
> +++ b/src/compositor-drm.h
> @@ -58,13 +58,13 @@ struct weston_drm_backend_output_config {
> * - "rgb565"
> * - "xrgb2101010"
> */
> - char *gbm_format;
> + const char *gbm_format;
> /** The seat to be used by the output. Set to NULL to use the
> * default seat. */
> - char *seat;
> + const char *seat;
> /** The modeline to be used by the output. Refer to the documentation
> * of WESTON_DRM_BACKEND_OUTPUT_PREFERRED for details. */
> - char *modeline;
> + const char *modeline;
> };
>
> /** The backend configuration struct.
> @@ -93,7 +93,7 @@ struct weston_drm_backend_config {
> * take ownership of the seat_id pointer and will free it on
> * backend destruction.
> */
> - char *seat_id;
> + const char *seat_id;
>
> /** The pixel format of the framebuffer to be used.
> *
> @@ -105,7 +105,7 @@ struct weston_drm_backend_config {
> * The backend will take ownership of the format pointer and will free
> * it on backend destruction.
> */
> - char *gbm_format;
> + const char *gbm_format;
>
> /** Callback used to configure the outputs.
> *
> diff --git a/src/main.c b/src/main.c
> index d1c569d..c3d0d0b 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -972,6 +972,7 @@ drm_configure_output(struct weston_compositor *c,
> struct weston_config *wc = weston_compositor_get_user_data(c);
> struct weston_config_section *section;
> char *s;
> + char *seat, *gbm_format;
> int scale;
> enum weston_drm_backend_output_mode mode =
> WESTON_DRM_BACKEND_OUTPUT_PREFERRED;
> @@ -1000,8 +1001,10 @@ drm_configure_output(struct weston_compositor *c,
> free(s);
>
> weston_config_section_get_string(section,
> - "gbm-format", &config->gbm_format, NULL);
> - weston_config_section_get_string(section, "seat", &config->seat, "");
> + "gbm-format", &gbm_format, NULL);
> + weston_config_section_get_string(section, "seat", &seat, "");
> + config->gbm_format = gbm_format;
> + config->seat = seat;
Where do you free gbm_format and seat here?
Cheers,
--
Quentin “Sardem FF7” Glidic
More information about the wayland-devel
mailing list