On 26 March 2013 15:11, Anthony Liguori <aligu...@us.ibm.com> wrote: > +int qemu_chr_fe_write_all(CharDriverState *s, const uint8_t *buf, int len) > +{ > + int offset = 0; > + int res; > + > + while (offset < len) { > + do { > + res = s->chr_write(s, buf + offset, len - offset); > + if (res == -1 && errno == EAGAIN) { > + g_usleep(100); > + } > + } while (res == -1 && errno == EAGAIN);
for (;;) { res = s->chr_write(s, buf + offset, len - offset); if (!(res == -1 && errno == EAGAIN)) { break; } g_usleep(100); } would avoid the duplication of the retry condition. -- PMM