* [PATCH] io/channel: Have read/write functions take void * buffer argument
@ 2025-10-31 9:13 Philippe Mathieu-Daudé
2025-10-31 11:40 ` Daniel P. Berrangé
2025-10-31 13:53 ` Daniel P. Berrangé
0 siblings, 2 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-31 9:13 UTC (permalink / raw)
To: qemu-devel; +Cc: Daniel P. Berrangé, Philippe Mathieu-Daudé
I/O channel read/write functions can operate on any area of
memory, regardless of the content their represent. Do not
restrict to array of char, use the void* type, which is also
the type of the underlying iovec::iov_base field.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/crypto/tlssession.h | 4 ++--
include/io/channel.h | 14 +++++++-------
io/channel-tls.c | 4 ++--
io/channel.c | 14 +++++++-------
4 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/include/crypto/tlssession.h b/include/crypto/tlssession.h
index 2e9fe11cf6e..28e419681e4 100644
--- a/include/crypto/tlssession.h
+++ b/include/crypto/tlssession.h
@@ -199,11 +199,11 @@ int qcrypto_tls_session_check_credentials(QCryptoTLSSession *sess,
* These must return QCRYPTO_TLS_SESSION_ERR_BLOCK if the I/O
* would block, but on other errors, must fill 'errp'
*/
-typedef ssize_t (*QCryptoTLSSessionWriteFunc)(const char *buf,
+typedef ssize_t (*QCryptoTLSSessionWriteFunc)(const void *buf,
size_t len,
void *opaque,
Error **errp);
-typedef ssize_t (*QCryptoTLSSessionReadFunc)(char *buf,
+typedef ssize_t (*QCryptoTLSSessionReadFunc)(void *buf,
size_t len,
void *opaque,
Error **errp);
diff --git a/include/io/channel.h b/include/io/channel.h
index 0f25ae0069f..db893a36288 100644
--- a/include/io/channel.h
+++ b/include/io/channel.h
@@ -437,7 +437,7 @@ ssize_t qio_channel_writev(QIOChannel *ioc,
* a single memory region.
*/
ssize_t qio_channel_read(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp);
@@ -453,7 +453,7 @@ ssize_t qio_channel_read(QIOChannel *ioc,
* single memory region.
*/
ssize_t qio_channel_write(QIOChannel *ioc,
- const char *buf,
+ const void *buf,
size_t buflen,
Error **errp);
@@ -475,7 +475,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
* without data, or -1 on error
*/
int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp);
@@ -495,7 +495,7 @@ int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
* Returns: 0 if all bytes were read, or -1 on error
*/
int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp);
@@ -514,7 +514,7 @@ int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
* Returns: 0 if all bytes were written, or -1 on error
*/
int coroutine_mixed_fn qio_channel_write_all(QIOChannel *ioc,
- const char *buf,
+ const void *buf,
size_t buflen,
Error **errp);
@@ -595,7 +595,7 @@ ssize_t qio_channel_pwritev(QIOChannel *ioc, const struct iovec *iov,
* flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method.
*
*/
-ssize_t qio_channel_pwrite(QIOChannel *ioc, char *buf, size_t buflen,
+ssize_t qio_channel_pwrite(QIOChannel *ioc, void *buf, size_t buflen,
off_t offset, Error **errp);
/**
@@ -631,7 +631,7 @@ ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov,
* flag QIO_CHANNEL_FEATURE_SEEKABLE prior to calling this method.
*
*/
-ssize_t qio_channel_pread(QIOChannel *ioc, char *buf, size_t buflen,
+ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen,
off_t offset, Error **errp);
/**
diff --git a/io/channel-tls.c b/io/channel-tls.c
index ce041795c19..b0cec27cb9c 100644
--- a/io/channel-tls.c
+++ b/io/channel-tls.c
@@ -26,7 +26,7 @@
#include "qemu/atomic.h"
-static ssize_t qio_channel_tls_write_handler(const char *buf,
+static ssize_t qio_channel_tls_write_handler(const void *buf,
size_t len,
void *opaque,
Error **errp)
@@ -43,7 +43,7 @@ static ssize_t qio_channel_tls_write_handler(const char *buf,
return ret;
}
-static ssize_t qio_channel_tls_read_handler(char *buf,
+static ssize_t qio_channel_tls_read_handler(void *buf,
size_t len,
void *opaque,
Error **errp)
diff --git a/io/channel.c b/io/channel.c
index 852e684938c..8e8bd2efa84 100644
--- a/io/channel.c
+++ b/io/channel.c
@@ -310,7 +310,7 @@ ssize_t qio_channel_writev(QIOChannel *ioc,
ssize_t qio_channel_read(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp)
{
@@ -320,7 +320,7 @@ ssize_t qio_channel_read(QIOChannel *ioc,
ssize_t qio_channel_write(QIOChannel *ioc,
- const char *buf,
+ const void *buf,
size_t buflen,
Error **errp)
{
@@ -330,7 +330,7 @@ ssize_t qio_channel_write(QIOChannel *ioc,
int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp)
{
@@ -340,7 +340,7 @@ int coroutine_mixed_fn qio_channel_read_all_eof(QIOChannel *ioc,
int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
- char *buf,
+ void *buf,
size_t buflen,
Error **errp)
{
@@ -350,7 +350,7 @@ int coroutine_mixed_fn qio_channel_read_all(QIOChannel *ioc,
int coroutine_mixed_fn qio_channel_write_all(QIOChannel *ioc,
- const char *buf,
+ const void *buf,
size_t buflen,
Error **errp)
{
@@ -475,7 +475,7 @@ ssize_t qio_channel_pwritev(QIOChannel *ioc, const struct iovec *iov,
return klass->io_pwritev(ioc, iov, niov, offset, errp);
}
-ssize_t qio_channel_pwrite(QIOChannel *ioc, char *buf, size_t buflen,
+ssize_t qio_channel_pwrite(QIOChannel *ioc, void *buf, size_t buflen,
off_t offset, Error **errp)
{
struct iovec iov = {
@@ -504,7 +504,7 @@ ssize_t qio_channel_preadv(QIOChannel *ioc, const struct iovec *iov,
return klass->io_preadv(ioc, iov, niov, offset, errp);
}
-ssize_t qio_channel_pread(QIOChannel *ioc, char *buf, size_t buflen,
+ssize_t qio_channel_pread(QIOChannel *ioc, void *buf, size_t buflen,
off_t offset, Error **errp)
{
struct iovec iov = {
--
2.51.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] io/channel: Have read/write functions take void * buffer argument
2025-10-31 9:13 [PATCH] io/channel: Have read/write functions take void * buffer argument Philippe Mathieu-Daudé
@ 2025-10-31 11:40 ` Daniel P. Berrangé
2025-10-31 13:53 ` Daniel P. Berrangé
1 sibling, 0 replies; 4+ messages in thread
From: Daniel P. Berrangé @ 2025-10-31 11:40 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Fri, Oct 31, 2025 at 10:13:51AM +0100, Philippe Mathieu-Daudé wrote:
> I/O channel read/write functions can operate on any area of
> memory, regardless of the content their represent. Do not
> restrict to array of char, use the void* type, which is also
> the type of the underlying iovec::iov_base field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/crypto/tlssession.h | 4 ++--
> include/io/channel.h | 14 +++++++-------
> io/channel-tls.c | 4 ++--
> io/channel.c | 14 +++++++-------
> 4 files changed, 18 insertions(+), 18 deletions(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] io/channel: Have read/write functions take void * buffer argument
2025-10-31 9:13 [PATCH] io/channel: Have read/write functions take void * buffer argument Philippe Mathieu-Daudé
2025-10-31 11:40 ` Daniel P. Berrangé
@ 2025-10-31 13:53 ` Daniel P. Berrangé
2025-10-31 13:55 ` Philippe Mathieu-Daudé
1 sibling, 1 reply; 4+ messages in thread
From: Daniel P. Berrangé @ 2025-10-31 13:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel
On Fri, Oct 31, 2025 at 10:13:51AM +0100, Philippe Mathieu-Daudé wrote:
> I/O channel read/write functions can operate on any area of
> memory, regardless of the content their represent. Do not
> restrict to array of char, use the void* type, which is also
> the type of the underlying iovec::iov_base field.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
> include/crypto/tlssession.h | 4 ++--
> include/io/channel.h | 14 +++++++-------
> io/channel-tls.c | 4 ++--
> io/channel.c | 14 +++++++-------
> 4 files changed, 18 insertions(+), 18 deletions(-)
Also needs a change to tests:
diff --git a/tests/unit/test-crypto-tlssession.c b/tests/unit/test-crypto-tlssession.c
index d0baf3b304..0d06a6892e 100644
--- a/tests/unit/test-crypto-tlssession.c
+++ b/tests/unit/test-crypto-tlssession.c
@@ -36,7 +36,7 @@
#define KEYFILE WORKDIR "key-ctx.pem"
static ssize_t
-testWrite(const char *buf, size_t len, void *opaque, Error **errp)
+testWrite(const void *buf, size_t len, void *opaque, Error **errp)
{
int *fd = opaque;
int ret;
@@ -54,7 +54,7 @@ testWrite(const char *buf, size_t len, void *opaque, Error **errp)
}
static ssize_t
-testRead(char *buf, size_t len, void *opaque, Error **errp)
+testRead(void *buf, size_t len, void *opaque, Error **errp)
{
int *fd = opaque;
int ret;
which I've made locally when queuing this patch, so no need to resend.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] io/channel: Have read/write functions take void * buffer argument
2025-10-31 13:53 ` Daniel P. Berrangé
@ 2025-10-31 13:55 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-10-31 13:55 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-devel
On 31/10/25 14:53, Daniel P. Berrangé wrote:
> On Fri, Oct 31, 2025 at 10:13:51AM +0100, Philippe Mathieu-Daudé wrote:
>> I/O channel read/write functions can operate on any area of
>> memory, regardless of the content their represent. Do not
>> restrict to array of char, use the void* type, which is also
>> the type of the underlying iovec::iov_base field.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>> include/crypto/tlssession.h | 4 ++--
>> include/io/channel.h | 14 +++++++-------
>> io/channel-tls.c | 4 ++--
>> io/channel.c | 14 +++++++-------
>> 4 files changed, 18 insertions(+), 18 deletions(-)
>
> Also needs a change to tests:
>
>
> diff --git a/tests/unit/test-crypto-tlssession.c b/tests/unit/test-crypto-tlssession.c
> index d0baf3b304..0d06a6892e 100644
> --- a/tests/unit/test-crypto-tlssession.c
> +++ b/tests/unit/test-crypto-tlssession.c
> @@ -36,7 +36,7 @@
> #define KEYFILE WORKDIR "key-ctx.pem"
>
> static ssize_t
> -testWrite(const char *buf, size_t len, void *opaque, Error **errp)
> +testWrite(const void *buf, size_t len, void *opaque, Error **errp)
> {
> int *fd = opaque;
> int ret;
> @@ -54,7 +54,7 @@ testWrite(const char *buf, size_t len, void *opaque, Error **errp)
> }
>
> static ssize_t
> -testRead(char *buf, size_t len, void *opaque, Error **errp)
> +testRead(void *buf, size_t len, void *opaque, Error **errp)
> {
> int *fd = opaque;
> int ret;
>
>
> which I've made locally when queuing this patch, so no need to resend.
Oops, sorry and thanks for fixing up!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-31 13:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-31 9:13 [PATCH] io/channel: Have read/write functions take void * buffer argument Philippe Mathieu-Daudé
2025-10-31 11:40 ` Daniel P. Berrangé
2025-10-31 13:53 ` Daniel P. Berrangé
2025-10-31 13:55 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).