@samitouri / QOSamiQemu / commits / 7297a02ca8

io/channel-socket: Document why we can ignore socket_set_cork() errors

In qio_channel_socket_set_cork(), we call socket_set_cork() but ignore its success/failure return value. This is OK because we are implementing qio_channel_set_cork() here, and that function's API documentation states that the setting is merely a hint. So even if setting TCP_CORK on the underlying socket fails for some reason, this isn't going to be a problem for the caller; correspondingly the qio_channel_set_cork() function has no error return. Add a comment in qio_channel_socket_set_cork() explaining why we don't check for errors. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/2254 Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>

Peter Maydell committed Jun 30, 2026 at 10:35 UTC 7297a02ca82f8692ac4ccaab808d52f810c61aac
1 file changed +6
io/channel-socket.c
+6
@@ -946,6 +946,12 @@ qio_channel_socket_set_cork(QIOChannel *ioc,
946 QIOChannelSocket *sioc = QIO_CHANNEL_SOCKET(ioc);
947 int v = enabled ? 1 : 0;
948
949 + /*
950 + * We can ignore the error return from socket_set_cork() because
951 + * at the QIO API level set_cork is only a hint, and so
952 + * qio_channel_set_cork() can never fail even if it didn't
953 + * actually do anything.
954 + */
955 socket_set_cork(sioc->fd, v);
956 }
957