In status_post_select(), if read_nonblock() succeeds (ret >= 0)
but for_each_stat_item() fails (ret2 < 0), para_gui aborts with
para_gui: error.h:639: para_strerror: Assertion `num > 0' failed.
This happens for example if the user is not allowed to connect to
para_audiod.
The problem is that the (non-positive) value -ret is passed to
para_strerror() as the error code rather than -ret2. This commit
fixes the bug. It was introduced one year ago in commit
f840be8d
(gui: Introduce status_post_select()).
ret2 = for_each_stat_item(st->buf, st->loaded, update_item);
if (ret < 0 || ret2 < 0) {
st->loaded = 0;
- PARA_NOTICE_LOG("closing stat pipe: %s\n", para_strerror(-ret));
+ PARA_NOTICE_LOG("closing stat pipe: %s\n",
+ para_strerror(ret < 0? -ret : -ret2));
close(st->fd);
st->fd = -1;
clear_all_items();