swaybar: improve read_pixmap routine

This commit is contained in:
Nathan Schulte 2020-10-05 01:09:09 -05:00
parent e4f5e7ec90
commit e478df4184

View file

@ -43,12 +43,13 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
if (sd_bus_message_at_end(msg, 0)) { if (sd_bus_message_at_end(msg, 0)) {
sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop); sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop);
return ret; goto finish;
} }
list_t *pixmaps = create_list(); list_t *pixmaps = create_list();
if (!pixmaps) { if (!pixmaps) {
return -12; // -ENOMEM ret = -12; // -ENOMEM
goto finish;
} }
while (!sd_bus_message_at_end(msg, 0)) { while (!sd_bus_message_at_end(msg, 0)) {
@ -93,7 +94,7 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
} }
if (pixmaps->length < 1) { if (pixmaps->length < 1) {
sway_log(SWAY_DEBUG, "%s %s no. of icons = 0", sni->watcher_id, prop); sway_log(SWAY_ERROR, "%s %s no. of icons = 0", sni->watcher_id, prop);
goto error; goto error;
} }
@ -102,9 +103,11 @@ static int read_pixmap(sd_bus_message *msg, struct swaybar_sni *sni,
sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop, sway_log(SWAY_DEBUG, "%s %s no. of icons = %d", sni->watcher_id, prop,
pixmaps->length); pixmaps->length);
return ret; goto finish;
error: error:
list_free_items_and_destroy(pixmaps); list_free_items_and_destroy(pixmaps);
finish:
sd_bus_message_exit_container(msg);
return ret; return ret;
} }