[C++/mingw] ser-tcp.c casts
authorPedro Alves <palves@redhat.com>
Tue, 17 Nov 2015 15:17:45 +0000 (15:17 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 17 Nov 2015 15:20:03 +0000 (15:20 +0000)
Fixes a few errors like these:

../../src/gdb/ser-tcp.c: In function 'int net_open(serial*, const char*)':
../../src/gdb/ser-tcp.c:286:73: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
     res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len);
                                                                         ^

gdb/ChangeLog:
2015-11-17  Pedro Alves  <palves@redhat.com>

* ser-tcp.c (net_open) : Cast getsockopt argument to char *
instead of void *.  Update comment.
(net_read_prim): Cast recv argument to char * instead of void *.
(net_write_prim): Cast send argument to char *.  Add comment.

gdb/ChangeLog
gdb/ser-tcp.c

index ddd17a7a0a0bd5f32f699cd69313773ba940c034..3bec8cbea274d7208b6d4d347fed8de4082778d6 100644 (file)
@@ -1,3 +1,10 @@
+2015-11-17  Pedro Alves  <palves@redhat.com>
+
+       * ser-tcp.c (net_open) : Cast getsockopt argument to char *
+       instead of void *.  Update comment.
+       (net_read_prim): Cast recv argument to char * instead of void *.
+       (net_write_prim): Cast send argument to char *.  Add comment.
+
 2015-11-17  Pedro Alves  <palves@redhat.com>
 
        * win32-i386-low.c (update_debug_registers_callback)
index ce40b6160148ac776572f8f2aff498d04ca56d1f..36196f3a3979cc34ba7b6412cc1403c5971fdf41 100644 (file)
@@ -280,10 +280,10 @@ net_open (struct serial *scb, const char *name)
 
     len = sizeof (err);
     /* On Windows, the fourth parameter to getsockopt is a "char *";
-       on UNIX systems it is generally "void *".  The cast to "void *"
-       is OK everywhere, since in C "void *" can be implicitly
-       converted to any pointer type.  */
-    res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (void *) &err, &len);
+       on UNIX systems it is generally "void *".  The cast to "char *"
+       is OK everywhere, since in C++ any data pointer type can be
+       implicitly converted to "void *".  */
+    res = getsockopt (scb->fd, SOL_SOCKET, SO_ERROR, (char *) &err, &len);
     if (res < 0 || err)
       {
        /* Maybe the target still isn't ready to accept the connection.  */
@@ -342,13 +342,17 @@ net_read_prim (struct serial *scb, size_t count)
   /* Need to cast to silence -Wpointer-sign on MinGW, as Winsock's
      'recv' takes 'char *' as second argument, while 'scb->buf' is
      'unsigned char *'.  */
-  return recv (scb->fd, (void *) scb->buf, count, 0);
+  return recv (scb->fd, (char *) scb->buf, count, 0);
 }
 
 int
 net_write_prim (struct serial *scb, const void *buf, size_t count)
 {
-  return send (scb->fd, buf, count, 0);
+  /* On Windows, the second parameter to send is a "const char *"; on
+     UNIX systems it is generally "const void *".  The cast to "const
+     char *" is OK everywhere, since in C++ any data pointer type can
+     be implicitly converted to "const void *".  */
+  return send (scb->fd, (const char *) buf, count, 0);
 }
 
 int
This page took 0.036968 seconds and 4 git commands to generate.