diff options
author | Simon Ser <contact@emersion.fr> | 2022-05-26 21:24:46 +0200 |
---|---|---|
committer | Simon Zeni <simon@bl4ckb0ne.ca> | 2022-05-26 15:42:56 -0400 |
commit | d0b9bf94a5c6e88b13c6fa7f9b41af0a94ea1a3e (patch) | |
tree | 7cd4e2a3d36becffe8c72ddcc3bac3ecb20216ec | |
parent | f0d57da315ecbc44a444f76a7a8cde4045009453 (diff) |
Handle NULL output make/model/serial
-rw-r--r-- | sway/config/output.c | 6 | ||||
-rw-r--r-- | sway/ipc-json.c | 6 |
2 files changed, 7 insertions, 5 deletions
diff --git a/sway/config/output.c b/sway/config/output.c index 88514ac0..aa4cf946 100644 --- a/sway/config/output.c +++ b/sway/config/output.c @@ -27,8 +27,10 @@ int output_name_cmp(const void *item, const void *data) { void output_get_identifier(char *identifier, size_t len, struct sway_output *output) { struct wlr_output *wlr_output = output->wlr_output; - snprintf(identifier, len, "%s %s %s", wlr_output->make, wlr_output->model, - wlr_output->serial); + snprintf(identifier, len, "%s %s %s", + wlr_output->make ? wlr_output->make : "Unknown", + wlr_output->model ? wlr_output->model : "Unknown", + wlr_output->serial ? wlr_output->serial : "Unknown"); } const char *sway_output_scale_filter_to_string(enum scale_filter_mode scale_filter) { diff --git a/sway/ipc-json.c b/sway/ipc-json.c index 06121d62..e682bc36 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c @@ -248,11 +248,11 @@ static void ipc_json_describe_output(struct sway_output *output, json_object_object_add(object, "primary", json_object_new_boolean(false)); json_object_object_add(object, "make", - json_object_new_string(wlr_output->make)); + json_object_new_string(wlr_output->make ? wlr_output->make : "Unknown")); json_object_object_add(object, "model", - json_object_new_string(wlr_output->model)); + json_object_new_string(wlr_output->model ? wlr_output->model : "Unknown")); json_object_object_add(object, "serial", - json_object_new_string(wlr_output->serial)); + json_object_new_string(wlr_output->serial ? wlr_output->serial : "Unknown")); json_object *modes_array = json_object_new_array(); struct wlr_output_mode *mode; |