diff options
author | Simon Ser <contact@emersion.fr> | 2022-05-23 10:32:26 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-05-26 13:36:06 +0000 |
commit | be86145322e6157994b348711b7bedd209b565ea (patch) | |
tree | 6bb25298bff2a0b6be3db64769b9f103d789cd64 /backend/x11 | |
parent | 2e69eb10303f3074d6cafef30e7e1ce49cb7a1ac (diff) | |
download | wlroots-be86145322e6157994b348711b7bedd209b565ea.tar.xz |
output: turn make/model/serial into char *
This allows the make/model/serial to be NULL when unset, and allows
them to be longer than the hardcoded array length.
This is a breaking change: compositors need to handle the new NULL
case, and we stop setting make/model to useless "headless" or
"wayland" strings.
Diffstat (limited to 'backend/x11')
-rw-r--r-- | backend/x11/output.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/backend/x11/output.c b/backend/x11/output.c index 86e1dfd8..38310374 100644 --- a/backend/x11/output.c +++ b/backend/x11/output.c @@ -33,12 +33,19 @@ static void parse_xcb_setup(struct wlr_output *output, xcb_connection_t *xcb) { const xcb_setup_t *xcb_setup = xcb_get_setup(xcb); - snprintf(output->make, sizeof(output->make), "%.*s", - xcb_setup_vendor_length(xcb_setup), - xcb_setup_vendor(xcb_setup)); - snprintf(output->model, sizeof(output->model), "%"PRIu16".%"PRIu16, - xcb_setup->protocol_major_version, - xcb_setup->protocol_minor_version); + output->make = calloc(1, xcb_setup_vendor_length(xcb_setup) + 1); + if (output->make == NULL) { + wlr_log_errno(WLR_ERROR, "Allocation failed"); + return; + } + memcpy(output->make, xcb_setup_vendor(xcb_setup), + xcb_setup_vendor_length(xcb_setup)); + + char model[64]; + snprintf(model, sizeof(model), "%"PRIu16".%"PRIu16, + xcb_setup->protocol_major_version, + xcb_setup->protocol_minor_version); + output->model = strdup(output->model); } static struct wlr_x11_output *get_x11_output_from_output( |