From d6617aac65a3e5acc91ea0905a0bdd543a821f2d Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 19 Apr 2013 15:26:16 +0000 Subject: serial_write: change prototype to take a void-pointer buffer. While remote.c works with "char *" buffers most of the time, other remote targets have binary-ish-er protocols, and choose to use "unsigned char" throughout, like e.g., remote-mips.c or remote-m32r-sdi.c. That results in -Wpointer-sign warnings in those targets, unless we add casts in calls to serial_write. Since serial_write is only concerned about sending raw host bytes out, and serial_ops->write_prim already works with "void *"/"size_t", a similar interface to the "write" or "send" system calls, I find it natural to change serial_write's prototype accordingly, avoiding the need for casts. Tested on x86_64 Fedora 17, and also by building x86_64-mingw32 and DJGPP/go32 -hosted gdbs. gdb/ 2013-04-19 Pedro Alves * ser-base.c (ser_base_write): Change prototype -- take 'void *' buffer and size_t size. Adjust. * ser-base.h (ser_base_write): Adjust. * ser-go32.c (cnts): Change type to size_t. (dos_write): Change prototype -- take 'void *' buffer and size_t size. Adjust. (dos_info): Print elements of 'cnts' as unsigned long. * serial.c (serial_write): Likewise. * serial.h (serial_write): Adjust. (struct serial_ops) : Change prototype -- take 'void *' buffer and size_t size. Adjust. --- gdb/serial.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gdb/serial.h') diff --git a/gdb/serial.h b/gdb/serial.h index a91c8b812a4..7a97e282a0b 100644 --- a/gdb/serial.h +++ b/gdb/serial.h @@ -104,10 +104,10 @@ enum serial_rc { extern int serial_readchar (struct serial *scb, int timeout); -/* Write LEN chars from STRING to the port SCB. Returns 0 for +/* Write COUNT bytes from BUF to the port SCB. Returns 0 for success, non-zero for failure. */ -extern int serial_write (struct serial *scb, const char *str, int len); +extern int serial_write (struct serial *scb, const void *buf, size_t count); /* Write a printf style string onto the serial port. */ @@ -256,7 +256,7 @@ struct serial_ops void (*close) (struct serial *); int (*fdopen) (struct serial *, int fd); int (*readchar) (struct serial *, int timeout); - int (*write) (struct serial *, const char *str, int len); + int (*write) (struct serial *, const void *buf, size_t count); /* Discard pending output */ int (*flush_output) (struct serial *); /* Discard pending input */ -- cgit v1.2.1