From c628b528e091211bd746e5c9b18b5bc7298d01f3 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Fri, 19 Apr 2013 15:26:17 +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.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'gdb/serial.c') diff --git a/gdb/serial.c b/gdb/serial.c index 3202b0f..ee3f1ea 100644 --- a/gdb/serial.c +++ b/gdb/serial.c @@ -398,14 +398,15 @@ serial_readchar (struct serial *scb, int timeout) } int -serial_write (struct serial *scb, const char *str, int len) +serial_write (struct serial *scb, const void *buf, size_t count) { if (serial_logfp != NULL) { - int count; + const char *str = buf; + size_t c; - for (count = 0; count < len; count++) - serial_logchar (serial_logfp, 'w', str[count] & 0xff, 0); + for (c = 0; c < count; c++) + serial_logchar (serial_logfp, 'w', str[c] & 0xff, 0); /* Make sure that the log file is as up-to-date as possible, in case we are getting ready to dump core or something. */ @@ -413,9 +414,10 @@ serial_write (struct serial *scb, const char *str, int len) } if (serial_debug_p (scb)) { - int count; + const char *str = buf; + size_t c; - for (count = 0; count < len; count++) + for (c = 0; c < count; c++) { fprintf_unfiltered (gdb_stdlog, "["); serial_logchar (gdb_stdlog, 'w', str[count] & 0xff, 0); @@ -424,7 +426,7 @@ serial_write (struct serial *scb, const char *str, int len) gdb_flush (gdb_stdlog); } - return (scb->ops->write (scb, str, len)); + return (scb->ops->write (scb, buf, count)); } void -- cgit v1.1