This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Correct memset calls in ser-{pipe,tcp,unix}.c
- From: Ian Lance Taylor <ian at airs dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: 5 May 2003 23:27:33 -0700
- Subject: Correct memset calls in ser-{pipe,tcp,unix}.c
There are some incorrect memset calls in ser-{pipe,tcp,unix}.c. When
these calls were introduced, probably by Andrew Cagney on 16 Sep 1999,
the arguments were reversed, putting the size second and the value
last. Since the value in each case was intended to be 0, the effect
was to pass the size as 0, making the memset calls into no-ops.
It's rather unlikely that this makes any difference in practice, since
the structure fields are then initialized, but it seems best to do it
right.
I'm not currently subscribed to gdb-patches, so please CC me on any
replies.
Ian
2003-05-05 Ian Lance Taylor <ian@airs.com>
* ser-pipe.c (_initialize_ser_pipe): Correct call to memset--swap
second and third arguments.
* ser-tcp.c (_initialize_ser_tcp): Likewise.
* ser-unix.c (_initialize_ser_hardwire): Likewise.
Index: ser-pipe.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-pipe.c,v
retrieving revision 1.11
diff -p -u -r1.11 ser-pipe.c
--- ser-pipe.c 11 Jul 2001 17:52:32 -0000 1.11
+++ ser-pipe.c 6 May 2003 06:02:34 -0000
@@ -138,7 +138,7 @@ void
_initialize_ser_pipe (void)
{
struct serial_ops *ops = XMALLOC (struct serial_ops);
- memset (ops, sizeof (struct serial_ops), 0);
+ memset (ops, 0, sizeof (struct serial_ops));
ops->name = "pipe";
ops->next = 0;
ops->open = pipe_open;
Index: ser-tcp.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-tcp.c,v
retrieving revision 1.12
diff -p -u -r1.12 ser-tcp.c
--- ser-tcp.c 16 May 2002 19:51:08 -0000 1.12
+++ ser-tcp.c 6 May 2003 06:02:34 -0000
@@ -208,7 +208,7 @@ void
_initialize_ser_tcp (void)
{
struct serial_ops *ops = XMALLOC (struct serial_ops);
- memset (ops, sizeof (struct serial_ops), 0);
+ memset (ops, 0, sizeof (struct serial_ops));
ops->name = "tcp";
ops->next = 0;
ops->open = net_open;
Index: ser-unix.c
===================================================================
RCS file: /cvs/src/src/gdb/ser-unix.c,v
retrieving revision 1.15
diff -p -u -r1.15 ser-unix.c
--- ser-unix.c 15 Jul 2001 20:34:14 -0000 1.15
+++ ser-unix.c 6 May 2003 06:02:34 -0000
@@ -1337,7 +1337,7 @@ void
_initialize_ser_hardwire (void)
{
struct serial_ops *ops = XMALLOC (struct serial_ops);
- memset (ops, sizeof (struct serial_ops), 0);
+ memset (ops, 0, sizeof (struct serial_ops));
ops->name = "hardwire";
ops->next = 0;
ops->open = hardwire_open;