mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-29 00:41:33 +00:00
It was not clear when req_cmd_notification was called.
This code reproduce just the old behavior but is easier to read.
Steps are:
// original
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES ||
worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
worker->display_poll_tries++;
return n;
}
continue;
// split if
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
return n;
}
if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
worker->display_poll_tries++;
return n;
}
continue;
// order inside if
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
worker->display_poll_tries++;
return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
return n;
}
if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
worker->display_poll_tries++;
return n;
}
continue;
// consider cases
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
worker->display_poll_tries++;
return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
return n;
}
if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
if (worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
worker->display_poll_tries++;
return n;
}
continue;
}
// unreachable
// invert if
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
worker->display_poll_tries++;
return n;
}
if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
worker->display_poll_tries++;
return n;
}
if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
continue;
}
worker->display_poll_tries++;
return n;
}
// unreachable
// reuse code
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries > CMD_RING_POLL_RETRIES) {
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
continue;
}
}
worker->display_poll_tries++;
return n;
// remove empty if
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES) {
if (!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
continue;
}
}
worker->display_poll_tries++;
return n;
// collapse two conditions
if (worker->display_poll_tries < CMD_RING_POLL_RETRIES) {
worker->event_timeout = MIN(worker->event_timeout, CMD_RING_POLL_TIMEOUT);
} else if (worker->display_poll_tries == CMD_RING_POLL_RETRIES &&
!worker->qxl->st->qif->req_cmd_notification(worker->qxl)) {
continue;
}
worker->display_poll_tries++;
return n;
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
|
||
|---|---|---|
| .. | ||
| tests | ||
| .gitignore | ||
| agent-msg-filter.c | ||
| agent-msg-filter.h | ||
| cache-item.h | ||
| cache-item.tmpl.c | ||
| char-device.c | ||
| char-device.h | ||
| cursor-channel.c | ||
| cursor-channel.h | ||
| dcc-encoders.c | ||
| dcc-encoders.h | ||
| dcc-send.c | ||
| dcc.c | ||
| dcc.h | ||
| demarshallers.h | ||
| dispatcher.c | ||
| dispatcher.h | ||
| display-channel.c | ||
| display-channel.h | ||
| display-limits.h | ||
| event-loop.c | ||
| glz-encode-match.tmpl.c | ||
| glz-encode.tmpl.c | ||
| glz-encoder-dict.c | ||
| glz-encoder-dict.h | ||
| glz-encoder-priv.h | ||
| glz-encoder.c | ||
| glz-encoder.h | ||
| image-cache.c | ||
| image-cache.h | ||
| inputs-channel.c | ||
| inputs-channel.h | ||
| jpeg-encoder.c | ||
| jpeg-encoder.h | ||
| lz4-encoder.c | ||
| lz4-encoder.h | ||
| main-channel.c | ||
| main-channel.h | ||
| main-dispatcher.c | ||
| main-dispatcher.h | ||
| Makefile.am | ||
| memslot.c | ||
| memslot.h | ||
| migration-protocol.h | ||
| mjpeg-encoder.c | ||
| mjpeg-encoder.h | ||
| pixmap-cache.c | ||
| pixmap-cache.h | ||
| red-channel.c | ||
| red-channel.h | ||
| red-common.h | ||
| red-dispatcher.c | ||
| red-dispatcher.h | ||
| red-parse-qxl.c | ||
| red-parse-qxl.h | ||
| red-record-qxl.c | ||
| red-record-qxl.h | ||
| red-replay-qxl.c | ||
| red-replay-qxl.h | ||
| red-worker.c | ||
| red-worker.h | ||
| reds-private.h | ||
| reds-stream.c | ||
| reds-stream.h | ||
| reds.c | ||
| reds.h | ||
| smartcard.c | ||
| smartcard.h | ||
| sound.c | ||
| sound.h | ||
| spice-audio.h | ||
| spice-bitmap-utils.c | ||
| spice-bitmap-utils.h | ||
| spice-bitmap-utils.tmpl.c | ||
| spice-char.h | ||
| spice-core.h | ||
| spice-experimental.h | ||
| spice-input.h | ||
| spice-migration.h | ||
| spice-qxl.h | ||
| spice-server.h | ||
| spice-server.syms | ||
| spice-version.h.in | ||
| spice.h | ||
| spicevmc.c | ||
| stat.h | ||
| stream.c | ||
| stream.h | ||
| sw-canvas.c | ||
| sw-canvas.h | ||
| tree.c | ||
| tree.h | ||
| utils.c | ||
| utils.h | ||
| zlib-encoder.c | ||
| zlib-encoder.h | ||