Message ID | 20220420132624.2439741-33-marcandre.lureau@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Misc cleanups | expand |
On Wed, Apr 20, 2022 at 05:26:15PM +0400, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > Reuse qemu_write_full(). > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > tests/qtest/libqtest.c | 16 ++-------------- > 1 file changed, 2 insertions(+), 14 deletions(-) > > diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c > index 7b5890dcc487..2b9bdb947d6f 100644 > --- a/tests/qtest/libqtest.c > +++ b/tests/qtest/libqtest.c > @@ -414,21 +414,9 @@ void qtest_quit(QTestState *s) > > static void socket_send(int fd, const char *buf, size_t size) > { > - size_t offset; > - > - offset = 0; > - while (offset < size) { > - ssize_t len; > + size_t res = qemu_write_full(fd, buf, size); > > - len = write(fd, buf + offset, size - offset); > - if (len == -1 && errno == EINTR) { > - continue; > - } > - > - g_assert_cmpint(len, >, 0); > - > - offset += len; > - } > + assert(res == size); > } IMHO socket_send should jsut be deleted, with the few callers directly using qemu_write_full With regards, Daniel
Hi On Wed, Apr 20, 2022 at 8:20 PM Daniel P. Berrangé <berrange@redhat.com> wrote: > On Wed, Apr 20, 2022 at 05:26:15PM +0400, marcandre.lureau@redhat.com > wrote: > > From: Marc-André Lureau <marcandre.lureau@redhat.com> > > > > Reuse qemu_write_full(). > > > > Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> > > --- > > tests/qtest/libqtest.c | 16 ++-------------- > > 1 file changed, 2 insertions(+), 14 deletions(-) > > > > diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c > > index 7b5890dcc487..2b9bdb947d6f 100644 > > --- a/tests/qtest/libqtest.c > > +++ b/tests/qtest/libqtest.c > > @@ -414,21 +414,9 @@ void qtest_quit(QTestState *s) > > > > static void socket_send(int fd, const char *buf, size_t size) > > { > > - size_t offset; > > - > > - offset = 0; > > - while (offset < size) { > > - ssize_t len; > > + size_t res = qemu_write_full(fd, buf, size); > > > > - len = write(fd, buf + offset, size - offset); > > - if (len == -1 && errno == EINTR) { > > - continue; > > - } > > - > > - g_assert_cmpint(len, >, 0); > > - > > - offset += len; > > - } > > + assert(res == size); > > } > > IMHO socket_send should jsut be deleted, with the few callers > directly using qemu_write_full > It's not a big deal, it's an internal helper. There is an additional assert() there, and the socket_send_fds() pair. I'll leave it for now. thanks
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index 7b5890dcc487..2b9bdb947d6f 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -414,21 +414,9 @@ void qtest_quit(QTestState *s) static void socket_send(int fd, const char *buf, size_t size) { - size_t offset; - - offset = 0; - while (offset < size) { - ssize_t len; + size_t res = qemu_write_full(fd, buf, size); - len = write(fd, buf + offset, size - offset); - if (len == -1 && errno == EINTR) { - continue; - } - - g_assert_cmpint(len, >, 0); - - offset += len; - } + assert(res == size); } static void qtest_client_socket_send(QTestState *s, const char *buf)