@@ -479,7 +479,7 @@ static int baum_eat_packet(BaumChardev *baum, const uint8_t *buf, int len)
}
/* The other end is writing some data. Store it and try to interpret */
-static int baum_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t baum_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
BaumChardev *baum = BAUM_CHARDEV(chr);
int tocopy, cur, eaten, orig_len = len;
@@ -32,7 +32,7 @@
#include "chardev/char-io.h"
/* Called with chr_write_lock held. */
-static int fd_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t fd_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
FDChardev *s = FD_CHARDEV(chr);
@@ -33,7 +33,7 @@
/* MUX driver for serial I/O splitting */
/* Called with chr_write_lock held. */
-static int mux_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t mux_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
MuxChardev *d = MUX_CHARDEV(chr);
int ret;
@@ -125,7 +125,7 @@ static void pty_chr_update_read_handler(Chardev *chr)
}
/* Called with chr_write_lock held. */
-static int char_pty_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t char_pty_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
PtyChardev *s = PTY_CHARDEV(chr);
@@ -49,12 +49,12 @@ static size_t ringbuf_count(const Chardev *chr)
return d->prod - d->cons;
}
-static int ringbuf_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t ringbuf_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
RingBufChardev *d = RINGBUF_CHARDEV(chr);
int i;
- if (!buf || (len < 0)) {
+ if (!buf) {
return -1;
}
@@ -124,7 +124,7 @@ static gboolean tcp_chr_read_poll(void *opaque);
static void tcp_chr_disconnect(Chardev *chr);
/* Called with chr_write_lock held. */
-static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t tcp_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
SocketChardev *s = SOCKET_CHARDEV(chr);
@@ -45,7 +45,7 @@ typedef struct {
#define UDP_CHARDEV(obj) OBJECT_CHECK(UdpChardev, (obj), TYPE_CHARDEV_UDP)
/* Called with chr_write_lock held. */
-static int udp_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t udp_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
UdpChardev *s = UDP_CHARDEV(chr);
@@ -245,7 +245,7 @@ static void char_init(Object *obj)
qemu_mutex_init(&chr->chr_write_lock);
}
-static int null_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t null_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
return len;
}
@@ -133,7 +133,7 @@ static void msmouse_input_sync(DeviceState *dev)
msmouse_chr_accept_input(chr);
}
-static int msmouse_chr_write(struct Chardev *s, const uint8_t *buf, int len)
+static size_t msmouse_chr_write(struct Chardev *s, const uint8_t *buf, size_t len)
{
/* Ignore writes to mouse port */
return len;
@@ -193,7 +193,7 @@ static GSource *spice_chr_add_watch(Chardev *chr, GIOCondition cond)
return (GSource *)src;
}
-static int spice_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t spice_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
SpiceChardev *s = SPICE_CHARDEV(chr);
int read_bytes;
@@ -82,7 +82,7 @@ static int testdev_eat_packet(TestdevChardev *testdev)
}
/* The other end is writing some data. Store it and try to interpret */
-static int testdev_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t testdev_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
TestdevChardev *testdev = TESTDEV_CHARDEV(chr);
int tocopy, eaten, orig_len = len;
@@ -203,8 +203,8 @@ static void wctablet_chr_accept_input(Chardev *chr)
}
}
-static int wctablet_chr_write(struct Chardev *chr,
- const uint8_t *buf, int len)
+static size_t wctablet_chr_write(struct Chardev *chr,
+ const uint8_t *buf, size_t len)
{
TabletChardev *tablet = WCTABLET_CHARDEV(chr);
unsigned int i, clen;
@@ -1955,7 +1955,7 @@ static void gdb_monitor_output(GDBState *s, const char *msg, int len)
put_packet(s, buf);
}
-static int gdb_monitor_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t gdb_monitor_write(Chardev *chr, const uint8_t *buf, size_t len)
{
const char *p = (const char *)buf;
int max_sz;
@@ -314,8 +314,8 @@ static void csrhci_ready_for_next_inpkt(struct csrhci_s *s)
s->in_hdr = INT_MAX;
}
-static int csrhci_write(struct Chardev *chr,
- const uint8_t *buf, int len)
+static size_t csrhci_write(struct Chardev *chr,
+ const uint8_t *buf, size_t len)
{
struct csrhci_s *s = (struct csrhci_s *)chr;
int total = 0;
@@ -250,7 +250,7 @@ typedef struct ChardevClass {
void (*open)(Chardev *chr, ChardevBackend *backend,
bool *be_opened, Error **errp);
- int (*chr_write)(Chardev *s, const uint8_t *buf, int len);
+ size_t (*chr_write)(Chardev *s, const uint8_t *buf, size_t len);
size_t (*chr_sync_read)(Chardev *s, const uint8_t *buf, size_t len);
GSource *(*chr_add_watch)(Chardev *s, GIOCondition cond);
void (*chr_update_read_handler)(Chardev *s);
@@ -1080,7 +1080,7 @@ typedef struct VCChardev {
#define TYPE_CHARDEV_VC "chardev-vc"
#define VC_CHARDEV(obj) OBJECT_CHECK(VCChardev, (obj), TYPE_CHARDEV_VC)
-static int vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t vc_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
VCChardev *drv = VC_CHARDEV(chr);
QemuConsole *s = drv->console;
@@ -1842,7 +1842,7 @@ static void gd_vc_adjustment_changed(GtkAdjustment *adjustment, void *opaque)
}
}
-static int gd_vc_chr_write(Chardev *chr, const uint8_t *buf, int len)
+static size_t gd_vc_chr_write(Chardev *chr, const uint8_t *buf, size_t len)
{
VCChardev *vcd = VC_CHARDEV(chr);
VirtualConsole *vc = vcd->console;
Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- chardev/baum.c | 2 +- chardev/char-fd.c | 2 +- chardev/char-mux.c | 2 +- chardev/char-pty.c | 2 +- chardev/char-ringbuf.c | 4 ++-- chardev/char-socket.c | 2 +- chardev/char-udp.c | 2 +- chardev/char.c | 2 +- chardev/msmouse.c | 2 +- chardev/spice.c | 2 +- chardev/testdev.c | 2 +- chardev/wctablet.c | 4 ++-- gdbstub.c | 2 +- hw/bt/hci-csr.c | 4 ++-- include/chardev/char.h | 2 +- ui/console.c | 2 +- ui/gtk.c | 2 +- 17 files changed, 20 insertions(+), 20 deletions(-)